[media] tda18212: rename state from 'priv' to 'dev'
authorAntti Palosaari <crope@iki.fi>
Mon, 4 Aug 2014 02:40:23 +0000 (23:40 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Sun, 21 Sep 2014 23:05:46 +0000 (20:05 -0300)
foo_dev seems to be most correct term for the structure holding data
of each device instance. It is most used term in Kernel codebase and also
examples from book Linux Device Drivers, Third Edition, uses it.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/tuners/tda18212.c

index 5d1d78595c8699d025b20a9f0c2cbf461eb39256..24948c7971e3b11ad0d124f00bdeb620e1afdf94 100644 (file)
@@ -23,7 +23,7 @@
 /* Max transfer size done by I2C transfer functions */
 #define MAX_XFER_SIZE  64
 
-struct tda18212_priv {
+struct tda18212_dev {
        struct tda18212_config cfg;
        struct i2c_client *client;
 
@@ -31,14 +31,13 @@ struct tda18212_priv {
 };
 
 /* write multiple registers */
-static int tda18212_wr_regs(struct tda18212_priv *priv, u8 reg, u8 *val,
-       int len)
+static int tda18212_wr_regs(struct tda18212_dev *dev, u8 reg, u8 *val, int len)
 {
        int ret;
        u8 buf[MAX_XFER_SIZE];
        struct i2c_msg msg[1] = {
                {
-                       .addr = priv->client->addr,
+                       .addr = dev->client->addr,
                        .flags = 0,
                        .len = 1 + len,
                        .buf = buf,
@@ -46,7 +45,7 @@ static int tda18212_wr_regs(struct tda18212_priv *priv, u8 reg, u8 *val,
        };
 
        if (1 + len > sizeof(buf)) {
-               dev_warn(&priv->client->dev,
+               dev_warn(&dev->client->dev,
                                "i2c wr reg=%04x: len=%d is too big!\n",
                                reg, len);
                return -EINVAL;
@@ -55,11 +54,11 @@ static int tda18212_wr_regs(struct tda18212_priv *priv, u8 reg, u8 *val,
        buf[0] = reg;
        memcpy(&buf[1], val, len);
 
-       ret = i2c_transfer(priv->client->adapter, msg, 1);
+       ret = i2c_transfer(dev->client->adapter, msg, 1);
        if (ret == 1) {
                ret = 0;
        } else {
-               dev_warn(&priv->client->dev,
+               dev_warn(&dev->client->dev,
                                "i2c wr failed=%d reg=%02x len=%d\n",
                                ret, reg, len);
                ret = -EREMOTEIO;
@@ -68,19 +67,18 @@ static int tda18212_wr_regs(struct tda18212_priv *priv, u8 reg, u8 *val,
 }
 
 /* read multiple registers */
-static int tda18212_rd_regs(struct tda18212_priv *priv, u8 reg, u8 *val,
-       int len)
+static int tda18212_rd_regs(struct tda18212_dev *dev, u8 reg, u8 *val, int len)
 {
        int ret;
        u8 buf[MAX_XFER_SIZE];
        struct i2c_msg msg[2] = {
                {
-                       .addr = priv->client->addr,
+                       .addr = dev->client->addr,
                        .flags = 0,
                        .len = 1,
                        .buf = &reg,
                }, {
-                       .addr = priv->client->addr,
+                       .addr = dev->client->addr,
                        .flags = I2C_M_RD,
                        .len = len,
                        .buf = buf,
@@ -88,18 +86,18 @@ static int tda18212_rd_regs(struct tda18212_priv *priv, u8 reg, u8 *val,
        };
 
        if (len > sizeof(buf)) {
-               dev_warn(&priv->client->dev,
+               dev_warn(&dev->client->dev,
                                "i2c rd reg=%04x: len=%d is too big!\n",
                                reg, len);
                return -EINVAL;
        }
 
-       ret = i2c_transfer(priv->client->adapter, msg, 2);
+       ret = i2c_transfer(dev->client->adapter, msg, 2);
        if (ret == 2) {
                memcpy(val, buf, len);
                ret = 0;
        } else {
-               dev_warn(&priv->client->dev,
+               dev_warn(&dev->client->dev,
                                "i2c rd failed=%d reg=%02x len=%d\n",
                                ret, reg, len);
                ret = -EREMOTEIO;
@@ -109,26 +107,26 @@ static int tda18212_rd_regs(struct tda18212_priv *priv, u8 reg, u8 *val,
 }
 
 /* write single register */
-static int tda18212_wr_reg(struct tda18212_priv *priv, u8 reg, u8 val)
+static int tda18212_wr_reg(struct tda18212_dev *dev, u8 reg, u8 val)
 {
-       return tda18212_wr_regs(priv, reg, &val, 1);
+       return tda18212_wr_regs(dev, reg, &val, 1);
 }
 
 /* read single register */
-static int tda18212_rd_reg(struct tda18212_priv *priv, u8 reg, u8 *val)
+static int tda18212_rd_reg(struct tda18212_dev *dev, u8 reg, u8 *val)
 {
-       return tda18212_rd_regs(priv, reg, val, 1);
+       return tda18212_rd_regs(dev, reg, val, 1);
 }
 
 #if 0 /* keep, useful when developing driver */
-static void tda18212_dump_regs(struct tda18212_priv *priv)
+static void tda18212_dump_regs(struct tda18212_dev *dev)
 {
        int i;
        u8 buf[256];
 
        #define TDA18212_RD_LEN 32
        for (i = 0; i < sizeof(buf); i += TDA18212_RD_LEN)
-               tda18212_rd_regs(priv, i, &buf[i], TDA18212_RD_LEN);
+               tda18212_rd_regs(dev, i, &buf[i], TDA18212_RD_LEN);
 
        print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 32, 1, buf,
                sizeof(buf), true);
@@ -139,7 +137,7 @@ static void tda18212_dump_regs(struct tda18212_priv *priv)
 
 static int tda18212_set_params(struct dvb_frontend *fe)
 {
-       struct tda18212_priv *priv = fe->tuner_priv;
+       struct tda18212_dev *dev = fe->tuner_priv;
        struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        int ret, i;
        u32 if_khz;
@@ -168,7 +166,7 @@ static int tda18212_set_params(struct dvb_frontend *fe)
                [ATSC_QAM] = { 0x7d, 0x20, 0x63 },
        };
 
-       dev_dbg(&priv->client->dev,
+       dev_dbg(&dev->client->dev,
                        "delivery_system=%d frequency=%d bandwidth_hz=%d\n",
                        c->delivery_system, c->frequency,
                        c->bandwidth_hz);
@@ -178,25 +176,25 @@ static int tda18212_set_params(struct dvb_frontend *fe)
 
        switch (c->delivery_system) {
        case SYS_ATSC:
-               if_khz = priv->cfg.if_atsc_vsb;
+               if_khz = dev->cfg.if_atsc_vsb;
                i = ATSC_VSB;
                break;
        case SYS_DVBC_ANNEX_B:
-               if_khz = priv->cfg.if_atsc_qam;
+               if_khz = dev->cfg.if_atsc_qam;
                i = ATSC_QAM;
                break;
        case SYS_DVBT:
                switch (c->bandwidth_hz) {
                case 6000000:
-                       if_khz = priv->cfg.if_dvbt_6;
+                       if_khz = dev->cfg.if_dvbt_6;
                        i = DVBT_6;
                        break;
                case 7000000:
-                       if_khz = priv->cfg.if_dvbt_7;
+                       if_khz = dev->cfg.if_dvbt_7;
                        i = DVBT_7;
                        break;
                case 8000000:
-                       if_khz = priv->cfg.if_dvbt_8;
+                       if_khz = dev->cfg.if_dvbt_8;
                        i = DVBT_8;
                        break;
                default:
@@ -207,15 +205,15 @@ static int tda18212_set_params(struct dvb_frontend *fe)
        case SYS_DVBT2:
                switch (c->bandwidth_hz) {
                case 6000000:
-                       if_khz = priv->cfg.if_dvbt2_6;
+                       if_khz = dev->cfg.if_dvbt2_6;
                        i = DVBT2_6;
                        break;
                case 7000000:
-                       if_khz = priv->cfg.if_dvbt2_7;
+                       if_khz = dev->cfg.if_dvbt2_7;
                        i = DVBT2_7;
                        break;
                case 8000000:
-                       if_khz = priv->cfg.if_dvbt2_8;
+                       if_khz = dev->cfg.if_dvbt2_8;
                        i = DVBT2_8;
                        break;
                default:
@@ -225,7 +223,7 @@ static int tda18212_set_params(struct dvb_frontend *fe)
                break;
        case SYS_DVBC_ANNEX_A:
        case SYS_DVBC_ANNEX_C:
-               if_khz = priv->cfg.if_dvbc;
+               if_khz = dev->cfg.if_dvbc;
                i = DVBC_8;
                break;
        default:
@@ -233,15 +231,15 @@ static int tda18212_set_params(struct dvb_frontend *fe)
                goto error;
        }
 
-       ret = tda18212_wr_reg(priv, 0x23, bw_params[i][2]);
+       ret = tda18212_wr_reg(dev, 0x23, bw_params[i][2]);
        if (ret)
                goto error;
 
-       ret = tda18212_wr_reg(priv, 0x06, 0x00);
+       ret = tda18212_wr_reg(dev, 0x06, 0x00);
        if (ret)
                goto error;
 
-       ret = tda18212_wr_reg(priv, 0x0f, bw_params[i][0]);
+       ret = tda18212_wr_reg(dev, 0x0f, bw_params[i][0]);
        if (ret)
                goto error;
 
@@ -254,12 +252,12 @@ static int tda18212_set_params(struct dvb_frontend *fe)
        buf[6] = ((c->frequency / 1000) >>  0) & 0xff;
        buf[7] = 0xc1;
        buf[8] = 0x01;
-       ret = tda18212_wr_regs(priv, 0x12, buf, sizeof(buf));
+       ret = tda18212_wr_regs(dev, 0x12, buf, sizeof(buf));
        if (ret)
                goto error;
 
        /* actual IF rounded as it is on register */
-       priv->if_frequency = buf[3] * 50 * 1000;
+       dev->if_frequency = buf[3] * 50 * 1000;
 
 exit:
        if (fe->ops.i2c_gate_ctrl)
@@ -268,15 +266,15 @@ exit:
        return ret;
 
 error:
-       dev_dbg(&priv->client->dev, "failed=%d\n", ret);
+       dev_dbg(&dev->client->dev, "failed=%d\n", ret);
        goto exit;
 }
 
 static int tda18212_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
 {
-       struct tda18212_priv *priv = fe->tuner_priv;
+       struct tda18212_dev *dev = fe->tuner_priv;
 
-       *frequency = priv->if_frequency;
+       *frequency = dev->if_frequency;
 
        return 0;
 }
@@ -299,27 +297,27 @@ static int tda18212_probe(struct i2c_client *client,
 {
        struct tda18212_config *cfg = client->dev.platform_data;
        struct dvb_frontend *fe = cfg->fe;
-       struct tda18212_priv *priv;
+       struct tda18212_dev *dev;
        int ret;
        u8 chip_id = chip_id;
        char *version;
 
-       priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-       if (!priv) {
+       dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+       if (dev == NULL) {
                ret = -ENOMEM;
                dev_err(&client->dev, "kzalloc() failed\n");
                goto err;
        }
 
-       memcpy(&priv->cfg, cfg, sizeof(struct tda18212_config));
-       priv->client = client;
+       memcpy(&dev->cfg, cfg, sizeof(struct tda18212_config));
+       dev->client = client;
 
        /* check if the tuner is there */
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */
 
-       ret = tda18212_rd_reg(priv, 0x00, &chip_id);
-       dev_dbg(&priv->client->dev, "chip_id=%02x\n", chip_id);
+       ret = tda18212_rd_reg(dev, 0x00, &chip_id);
+       dev_dbg(&dev->client->dev, "chip_id=%02x\n", chip_id);
 
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */
@@ -339,31 +337,31 @@ static int tda18212_probe(struct i2c_client *client,
                goto err;
        }
 
-       dev_info(&priv->client->dev,
+       dev_info(&dev->client->dev,
                        "NXP TDA18212HN/%s successfully identified\n", version);
 
-       fe->tuner_priv = priv;
+       fe->tuner_priv = dev;
        memcpy(&fe->ops.tuner_ops, &tda18212_tuner_ops,
                        sizeof(struct dvb_tuner_ops));
-       i2c_set_clientdata(client, priv);
+       i2c_set_clientdata(client, dev);
 
        return 0;
 err:
        dev_dbg(&client->dev, "failed=%d\n", ret);
-       kfree(priv);
+       kfree(dev);
        return ret;
 }
 
 static int tda18212_remove(struct i2c_client *client)
 {
-       struct tda18212_priv *priv = i2c_get_clientdata(client);
-       struct dvb_frontend *fe = priv->cfg.fe;
+       struct tda18212_dev *dev = i2c_get_clientdata(client);
+       struct dvb_frontend *fe = dev->cfg.fe;
 
        dev_dbg(&client->dev, "\n");
 
        memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops));
        fe->tuner_priv = NULL;
-       kfree(priv);
+       kfree(dev);
 
        return 0;
 }