Commit 64670869 authored by Alison Schofield's avatar Alison Schofield Committed by Jonathan Cameron

staging: iio: isl29018: use regmap to retrieve struct device

Remove struct device from drivers global data and use regmap
API to retrieve device info instead.

This replacement can be done for drivers that include regmap
in their global data.
Signed-off-by: default avatarAlison Schofield <amsfield22@gmail.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 1b983bf4
...@@ -100,7 +100,6 @@ static const struct isl29018_scale { ...@@ -100,7 +100,6 @@ static const struct isl29018_scale {
}; };
struct isl29018_chip { struct isl29018_chip {
struct device *dev;
struct regmap *regmap; struct regmap *regmap;
struct mutex lock; struct mutex lock;
int type; int type;
...@@ -180,30 +179,31 @@ static int isl29018_read_sensor_input(struct isl29018_chip *chip, int mode) ...@@ -180,30 +179,31 @@ static int isl29018_read_sensor_input(struct isl29018_chip *chip, int mode)
int status; int status;
unsigned int lsb; unsigned int lsb;
unsigned int msb; unsigned int msb;
struct device *dev = regmap_get_device(chip->regmap);
/* Set mode */ /* Set mode */
status = regmap_write(chip->regmap, ISL29018_REG_ADD_COMMAND1, status = regmap_write(chip->regmap, ISL29018_REG_ADD_COMMAND1,
mode << COMMMAND1_OPMODE_SHIFT); mode << COMMMAND1_OPMODE_SHIFT);
if (status) { if (status) {
dev_err(chip->dev, dev_err(dev,
"Error in setting operating mode err %d\n", status); "Error in setting operating mode err %d\n", status);
return status; return status;
} }
msleep(CONVERSION_TIME_MS); msleep(CONVERSION_TIME_MS);
status = regmap_read(chip->regmap, ISL29018_REG_ADD_DATA_LSB, &lsb); status = regmap_read(chip->regmap, ISL29018_REG_ADD_DATA_LSB, &lsb);
if (status < 0) { if (status < 0) {
dev_err(chip->dev, dev_err(dev,
"Error in reading LSB DATA with err %d\n", status); "Error in reading LSB DATA with err %d\n", status);
return status; return status;
} }
status = regmap_read(chip->regmap, ISL29018_REG_ADD_DATA_MSB, &msb); status = regmap_read(chip->regmap, ISL29018_REG_ADD_DATA_MSB, &msb);
if (status < 0) { if (status < 0) {
dev_err(chip->dev, dev_err(dev,
"Error in reading MSB DATA with error %d\n", status); "Error in reading MSB DATA with error %d\n", status);
return status; return status;
} }
dev_vdbg(chip->dev, "MSB 0x%x and LSB 0x%x\n", msb, lsb); dev_vdbg(dev, "MSB 0x%x and LSB 0x%x\n", msb, lsb);
return (msb << 8) | lsb; return (msb << 8) | lsb;
} }
...@@ -246,13 +246,14 @@ static int isl29018_read_proximity_ir(struct isl29018_chip *chip, int scheme, ...@@ -246,13 +246,14 @@ static int isl29018_read_proximity_ir(struct isl29018_chip *chip, int scheme,
int status; int status;
int prox_data = -1; int prox_data = -1;
int ir_data = -1; int ir_data = -1;
struct device *dev = regmap_get_device(chip->regmap);
/* Do proximity sensing with required scheme */ /* Do proximity sensing with required scheme */
status = regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII, status = regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII,
COMMANDII_SCHEME_MASK, COMMANDII_SCHEME_MASK,
scheme << COMMANDII_SCHEME_SHIFT); scheme << COMMANDII_SCHEME_SHIFT);
if (status) { if (status) {
dev_err(chip->dev, "Error in setting operating mode\n"); dev_err(dev, "Error in setting operating mode\n");
return status; return status;
} }
...@@ -518,10 +519,11 @@ static int isl29035_detect(struct isl29018_chip *chip) ...@@ -518,10 +519,11 @@ static int isl29035_detect(struct isl29018_chip *chip)
{ {
int status; int status;
unsigned int id; unsigned int id;
struct device *dev = regmap_get_device(chip->regmap);
status = regmap_read(chip->regmap, ISL29035_REG_DEVICE_ID, &id); status = regmap_read(chip->regmap, ISL29035_REG_DEVICE_ID, &id);
if (status < 0) { if (status < 0) {
dev_err(chip->dev, dev_err(dev,
"Error reading ID register with error %d\n", "Error reading ID register with error %d\n",
status); status);
return status; return status;
...@@ -546,6 +548,7 @@ enum { ...@@ -546,6 +548,7 @@ enum {
static int isl29018_chip_init(struct isl29018_chip *chip) static int isl29018_chip_init(struct isl29018_chip *chip)
{ {
int status; int status;
struct device *dev = regmap_get_device(chip->regmap);
if (chip->type == isl29035) { if (chip->type == isl29035) {
status = isl29035_detect(chip); status = isl29035_detect(chip);
...@@ -575,7 +578,7 @@ static int isl29018_chip_init(struct isl29018_chip *chip) ...@@ -575,7 +578,7 @@ static int isl29018_chip_init(struct isl29018_chip *chip)
*/ */
status = regmap_write(chip->regmap, ISL29018_REG_TEST, 0x0); status = regmap_write(chip->regmap, ISL29018_REG_TEST, 0x0);
if (status < 0) { if (status < 0) {
dev_err(chip->dev, "Failed to clear isl29018 TEST reg.(%d)\n", dev_err(dev, "Failed to clear isl29018 TEST reg.(%d)\n",
status); status);
return status; return status;
} }
...@@ -586,7 +589,7 @@ static int isl29018_chip_init(struct isl29018_chip *chip) ...@@ -586,7 +589,7 @@ static int isl29018_chip_init(struct isl29018_chip *chip)
*/ */
status = regmap_write(chip->regmap, ISL29018_REG_ADD_COMMAND1, 0); status = regmap_write(chip->regmap, ISL29018_REG_ADD_COMMAND1, 0);
if (status < 0) { if (status < 0) {
dev_err(chip->dev, "Failed to clear isl29018 CMD1 reg.(%d)\n", dev_err(dev, "Failed to clear isl29018 CMD1 reg.(%d)\n",
status); status);
return status; return status;
} }
...@@ -597,14 +600,14 @@ static int isl29018_chip_init(struct isl29018_chip *chip) ...@@ -597,14 +600,14 @@ static int isl29018_chip_init(struct isl29018_chip *chip)
status = isl29018_set_scale(chip, chip->scale.scale, status = isl29018_set_scale(chip, chip->scale.scale,
chip->scale.uscale); chip->scale.uscale);
if (status < 0) { if (status < 0) {
dev_err(chip->dev, "Init of isl29018 fails\n"); dev_err(dev, "Init of isl29018 fails\n");
return status; return status;
} }
status = isl29018_set_integration_time(chip, status = isl29018_set_integration_time(chip,
isl29018_int_utimes[chip->type][chip->int_time]); isl29018_int_utimes[chip->type][chip->int_time]);
if (status < 0) { if (status < 0) {
dev_err(chip->dev, "Init of isl29018 fails\n"); dev_err(dev, "Init of isl29018 fails\n");
return status; return status;
} }
...@@ -721,7 +724,6 @@ static int isl29018_probe(struct i2c_client *client, ...@@ -721,7 +724,6 @@ static int isl29018_probe(struct i2c_client *client,
chip = iio_priv(indio_dev); chip = iio_priv(indio_dev);
i2c_set_clientdata(client, indio_dev); i2c_set_clientdata(client, indio_dev);
chip->dev = &client->dev;
if (id) { if (id) {
name = id->name; name = id->name;
...@@ -744,7 +746,7 @@ static int isl29018_probe(struct i2c_client *client, ...@@ -744,7 +746,7 @@ static int isl29018_probe(struct i2c_client *client,
chip_info_tbl[dev_id].regmap_cfg); chip_info_tbl[dev_id].regmap_cfg);
if (IS_ERR(chip->regmap)) { if (IS_ERR(chip->regmap)) {
err = PTR_ERR(chip->regmap); err = PTR_ERR(chip->regmap);
dev_err(chip->dev, "regmap initialization failed: %d\n", err); dev_err(&client->dev, "regmap initialization fails: %d\n", err);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment