Re: [PATCH V4 2/2] staging: iio: light: isl29018: use regmap forregister access

From: Grant Grundler
Date: Fri Apr 20 2012 - 11:04:13 EST


On Fri, Apr 20, 2012 at 12:27 AM, Laxman Dewangan <ldewangan@xxxxxxxxxx> wrote:
> Using regmap for accessing register through i2c bus. This will
> remove the code for caching registers, read-modify-write logics.
> Also it will provide the debugfs feature to dump register
> through regmap debugfs.
>
> Signed-off-by: Laxman Dewangan <ldewangan@xxxxxxxxxx>

Reviewed-by: Grant Grundler <grundler@xxxxxxxxxxxx>

Thanks for explaining the COMMAND1 register usage and volatile bits. LGTM.

cheers,
grant

> ---
> Change from V1:
> - Spliting the changes in two patches.
> - Separate patch for indenting cleanups.
> - Rebased the code on top of -next which have Jonathan's recent changes.
>
> Changes from V2:
> - Taken care of Lars's review comment about wrong return.
>
> Changes from V3:
> Taken care of Lars's and Grant's comment about COMMAND1 register access.
> -Use regmap_write() for ADD_COMMAND1 and keeping this as volatile.
>
> Âdrivers/staging/iio/light/Kconfig  Â|  Â1 +
> Âdrivers/staging/iio/light/isl29018.c | Â178 +++++++++++++++++-----------------
> Â2 files changed, 91 insertions(+), 88 deletions(-)
>
> diff --git a/drivers/staging/iio/light/Kconfig b/drivers/staging/iio/light/Kconfig
> index bb633f6..fd39f72 100644
> --- a/drivers/staging/iio/light/Kconfig
> +++ b/drivers/staging/iio/light/Kconfig
> @@ -6,6 +6,7 @@ menu "Light sensors"
> Âconfig SENSORS_ISL29018
> Â Â Â Âtristate "ISL 29018 light and proximity sensor"
> Â Â Â Âdepends on I2C
> + Â Â Â select REGMAP_I2C
> Â Â Â Âdefault n
> Â Â Â Âhelp
> Â Â Â Â If you say yes here you get support for ambient light sensing and
> diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
> index 073e899..de079ae 100644
> --- a/drivers/staging/iio/light/isl29018.c
> +++ b/drivers/staging/iio/light/isl29018.c
> @@ -26,9 +26,11 @@
> Â#include <linux/err.h>
> Â#include <linux/mutex.h>
> Â#include <linux/delay.h>
> +#include <linux/regmap.h>
> Â#include <linux/slab.h>
> Â#include "../iio.h"
> Â#include "../sysfs.h"
> +
> Â#define CONVERSION_TIME_MS Â Â Â Â Â Â 100
>
> Â#define ISL29018_REG_ADD_COMMAND1 Â Â Â0x00
> @@ -51,49 +53,22 @@
>
> Â#define ISL29018_REG_ADD_DATA_LSB Â Â Â0x02
> Â#define ISL29018_REG_ADD_DATA_MSB Â Â Â0x03
> -#define ISL29018_MAX_REGS Â Â Â Â Â Â Â(ISL29018_REG_ADD_DATA_MSB+1)
>
> Â#define ISL29018_REG_TEST Â Â Â Â Â Â Â0x08
> Â#define ISL29018_TEST_SHIFT Â Â Â Â Â Â0
> Â#define ISL29018_TEST_MASK Â Â Â Â Â Â (0xFF << ISL29018_TEST_SHIFT)
>
> Âstruct isl29018_chip {
> -    struct i2c_client    *client;
> +    struct device      *dev;
> +    struct regmap      *regmap;
>    Âstruct mutex      Âlock;
>    Âunsigned int      Âlux_scale;
>    Âunsigned int      Ârange;
>    Âunsigned int      Âadc_bit;
>    Âint           prox_scheme;
> - Â Â Â u8 Â Â Â Â Â Â Â Â Â Â Âreg_cache[ISL29018_MAX_REGS];
> Â};
>
> -static int isl29018_write_data(struct i2c_client *client, u8 reg,
> - Â Â Â Â Â Â Â Â Â Â Â u8 val, u8 mask, u8 shift)
> -{
> - Â Â Â u8 regval = val;
> - Â Â Â int ret;
> - Â Â Â struct isl29018_chip *chip = iio_priv(i2c_get_clientdata(client));
> -
> - Â Â Â /* don't cache or mask REG_TEST */
> - Â Â Â if (reg < ISL29018_MAX_REGS) {
> - Â Â Â Â Â Â Â regval = chip->reg_cache[reg];
> - Â Â Â Â Â Â Â regval &= ~mask;
> - Â Â Â Â Â Â Â regval |= val << shift;
> - Â Â Â }
> -
> - Â Â Â ret = i2c_smbus_write_byte_data(client, reg, regval);
> - Â Â Â if (ret) {
> - Â Â Â Â Â Â Â dev_err(&client->dev, "Write to device fails status %x\n", ret);
> - Â Â Â } else {
> - Â Â Â Â Â Â Â /* don't update cache on err */
> - Â Â Â Â Â Â Â if (reg < ISL29018_MAX_REGS)
> - Â Â Â Â Â Â Â Â Â Â Â chip->reg_cache[reg] = regval;
> - Â Â Â }
> -
> - Â Â Â return ret;
> -}
> -
> -static int isl29018_set_range(struct i2c_client *client, unsigned long range,
> +static int isl29018_set_range(struct isl29018_chip *chip, unsigned long range,
> Â Â Â Â Â Â Â Âunsigned int *new_range)
> Â{
> Â Â Â Âstatic const unsigned long supp_ranges[] = {1000, 4000, 16000, 64000};
> @@ -109,11 +84,11 @@ static int isl29018_set_range(struct i2c_client *client, unsigned long range,
> Â Â Â Âif (i >= ARRAY_SIZE(supp_ranges))
> Â Â Â Â Â Â Â Âreturn -EINVAL;
>
> - Â Â Â return isl29018_write_data(client, ISL29018_REG_ADD_COMMANDII,
> - Â Â Â Â Â Â Â Â Â Â Â i, COMMANDII_RANGE_MASK, COMMANDII_RANGE_SHIFT);
> + Â Â Â return regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII,
> + Â Â Â Â Â Â Â Â Â Â Â COMMANDII_RANGE_MASK, i << COMMANDII_RANGE_SHIFT);
> Â}
>
> -static int isl29018_set_resolution(struct i2c_client *client,
> +static int isl29018_set_resolution(struct isl29018_chip *chip,
> Â Â Â Â Â Â Â Â Â Â Â Âunsigned long adcbit, unsigned int *conf_adc_bit)
> Â{
> Â Â Â Âstatic const unsigned long supp_adcbit[] = {16, 12, 8, 4};
> @@ -129,48 +104,49 @@ static int isl29018_set_resolution(struct i2c_client *client,
> Â Â Â Âif (i >= ARRAY_SIZE(supp_adcbit))
> Â Â Â Â Â Â Â Âreturn -EINVAL;
>
> - Â Â Â return isl29018_write_data(client, ISL29018_REG_ADD_COMMANDII,
> - Â Â Â Â Â Â Â Â Â Â Â i, COMMANDII_RESOLUTION_MASK,
> - Â Â Â Â Â Â Â Â Â Â Â COMMANDII_RESOLUTION_SHIFT);
> + Â Â Â return regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII,
> + Â Â Â Â Â Â Â Â Â Â Â COMMANDII_RESOLUTION_MASK,
> + Â Â Â Â Â Â Â Â Â Â Â i << COMMANDII_RESOLUTION_SHIFT);
> Â}
>
> -static int isl29018_read_sensor_input(struct i2c_client *client, int mode)
> +static int isl29018_read_sensor_input(struct isl29018_chip *chip, int mode)
> Â{
> Â Â Â Âint status;
> - Â Â Â int lsb;
> - Â Â Â int msb;
> + Â Â Â unsigned int lsb;
> + Â Â Â unsigned int msb;
>
> Â Â Â Â/* Set mode */
> - Â Â Â status = isl29018_write_data(client, ISL29018_REG_ADD_COMMAND1,
> - Â Â Â Â Â Â Â Â Â Â Â mode, COMMMAND1_OPMODE_MASK, COMMMAND1_OPMODE_SHIFT);
> + Â Â Â status = regmap_write(chip->regmap, ISL29018_REG_ADD_COMMAND1,
> + Â Â Â Â Â Â Â Â Â Â Â mode << COMMMAND1_OPMODE_SHIFT);
> Â Â Â Âif (status) {
> - Â Â Â Â Â Â Â dev_err(&client->dev, "Error in setting operating mode\n");
> + Â Â Â Â Â Â Â dev_err(chip->dev,
> + Â Â Â Â Â Â Â Â Â Â Â "Error in setting operating mode err %d\n", status);
> Â Â Â Â Â Â Â Âreturn status;
> Â Â Â Â}
> Â Â Â Âmsleep(CONVERSION_TIME_MS);
> - Â Â Â lsb = i2c_smbus_read_byte_data(client, ISL29018_REG_ADD_DATA_LSB);
> - Â Â Â if (lsb < 0) {
> - Â Â Â Â Â Â Â dev_err(&client->dev, "Error in reading LSB DATA\n");
> - Â Â Â Â Â Â Â return lsb;
> + Â Â Â status = regmap_read(chip->regmap, ISL29018_REG_ADD_DATA_LSB, &lsb);
> + Â Â Â if (status < 0) {
> + Â Â Â Â Â Â Â dev_err(chip->dev,
> + Â Â Â Â Â Â Â Â Â Â Â "Error in reading LSB DATA with err %d\n", status);
> + Â Â Â Â Â Â Â return status;
> Â Â Â Â}
>
> - Â Â Â msb = i2c_smbus_read_byte_data(client, ISL29018_REG_ADD_DATA_MSB);
> - Â Â Â if (msb < 0) {
> - Â Â Â Â Â Â Â dev_err(&client->dev, "Error in reading MSB DATA\n");
> - Â Â Â Â Â Â Â return msb;
> + Â Â Â status = regmap_read(chip->regmap, ISL29018_REG_ADD_DATA_MSB, &msb);
> + Â Â Â if (status < 0) {
> + Â Â Â Â Â Â Â dev_err(chip->dev,
> + Â Â Â Â Â Â Â Â Â Â Â "Error in reading MSB DATA with error %d\n", status);
> + Â Â Â Â Â Â Â return status;
> Â Â Â Â}
> - Â Â Â dev_vdbg(&client->dev, "MSB 0x%x and LSB 0x%x\n", msb, lsb);
> + Â Â Â dev_vdbg(chip->dev, "MSB 0x%x and LSB 0x%x\n", msb, lsb);
>
> Â Â Â Âreturn (msb << 8) | lsb;
> Â}
>
> -static int isl29018_read_lux(struct i2c_client *client, int *lux)
> +static int isl29018_read_lux(struct isl29018_chip *chip, int *lux)
> Â{
> Â Â Â Âint lux_data;
> - Â Â Â struct isl29018_chip *chip = iio_priv(i2c_get_clientdata(client));
>
> - Â Â Â lux_data = isl29018_read_sensor_input(client,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â COMMMAND1_OPMODE_ALS_ONCE);
> + Â Â Â lux_data = isl29018_read_sensor_input(chip, COMMMAND1_OPMODE_ALS_ONCE);
>
> Â Â Â Âif (lux_data < 0)
> Â Â Â Â Â Â Â Âreturn lux_data;
> @@ -180,11 +156,11 @@ static int isl29018_read_lux(struct i2c_client *client, int *lux)
> Â Â Â Âreturn 0;
> Â}
>
> -static int isl29018_read_ir(struct i2c_client *client, int *ir)
> +static int isl29018_read_ir(struct isl29018_chip *chip, int *ir)
> Â{
> Â Â Â Âint ir_data;
>
> - Â Â Â ir_data = isl29018_read_sensor_input(client, COMMMAND1_OPMODE_IR_ONCE);
> + Â Â Â ir_data = isl29018_read_sensor_input(chip, COMMMAND1_OPMODE_IR_ONCE);
>
> Â Â Â Âif (ir_data < 0)
> Â Â Â Â Â Â Â Âreturn ir_data;
> @@ -194,7 +170,7 @@ static int isl29018_read_ir(struct i2c_client *client, int *ir)
> Â Â Â Âreturn 0;
> Â}
>
> -static int isl29018_read_proximity_ir(struct i2c_client *client, int scheme,
> +static int isl29018_read_proximity_ir(struct isl29018_chip *chip, int scheme,
> Â Â Â Â Â Â Â Âint *near_ir)
> Â{
> Â Â Â Âint status;
> @@ -202,14 +178,15 @@ static int isl29018_read_proximity_ir(struct i2c_client *client, int scheme,
> Â Â Â Âint ir_data = -1;
>
> Â Â Â Â/* Do proximity sensing with required scheme */
> - Â Â Â status = isl29018_write_data(client, ISL29018_REG_ADD_COMMANDII,
> - Â Â Â Â Â Â Â Â Â Â Â scheme, COMMANDII_SCHEME_MASK, COMMANDII_SCHEME_SHIFT);
> + Â Â Â status = regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII,
> + Â Â Â Â Â Â Â Â Â Â Â COMMANDII_SCHEME_MASK,
> + Â Â Â Â Â Â Â Â Â Â Â scheme << COMMANDII_SCHEME_SHIFT);
> Â Â Â Âif (status) {
> - Â Â Â Â Â Â Â dev_err(&client->dev, "Error in setting operating mode\n");
> + Â Â Â Â Â Â Â dev_err(chip->dev, "Error in setting operating mode\n");
> Â Â Â Â Â Â Â Âreturn status;
> Â Â Â Â}
>
> - Â Â Â prox_data = isl29018_read_sensor_input(client,
> + Â Â Â prox_data = isl29018_read_sensor_input(chip,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂCOMMMAND1_OPMODE_PROX_ONCE);
> Â Â Â Âif (prox_data < 0)
> Â Â Â Â Â Â Â Âreturn prox_data;
> @@ -219,8 +196,7 @@ static int isl29018_read_proximity_ir(struct i2c_client *client, int scheme,
> Â Â Â Â Â Â Â Âreturn 0;
> Â Â Â Â}
>
> - Â Â Â ir_data = isl29018_read_sensor_input(client,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â COMMMAND1_OPMODE_IR_ONCE);
> + Â Â Â ir_data = isl29018_read_sensor_input(chip, COMMMAND1_OPMODE_IR_ONCE);
>
> Â Â Â Âif (ir_data < 0)
> Â Â Â Â Â Â Â Âreturn ir_data;
> @@ -249,7 +225,6 @@ static ssize_t store_range(struct device *dev,
> Â{
> Â Â Â Âstruct iio_dev *indio_dev = dev_get_drvdata(dev);
> Â Â Â Âstruct isl29018_chip *chip = iio_priv(indio_dev);
> - Â Â Â struct i2c_client *client = chip->client;
> Â Â Â Âint status;
> Â Â Â Âunsigned long lval;
> Â Â Â Âunsigned int new_range;
> @@ -264,10 +239,11 @@ static ssize_t store_range(struct device *dev,
> Â Â Â Â}
>
> Â Â Â Âmutex_lock(&chip->lock);
> - Â Â Â status = isl29018_set_range(client, lval, &new_range);
> + Â Â Â status = isl29018_set_range(chip, lval, &new_range);
> Â Â Â Âif (status < 0) {
> Â Â Â Â Â Â Â Âmutex_unlock(&chip->lock);
> - Â Â Â Â Â Â Â dev_err(dev, "Error in setting max range\n");
> + Â Â Â Â Â Â Â dev_err(dev,
> + Â Â Â Â Â Â Â Â Â Â Â "Error in setting max range with err %d\n", status);
> Â Â Â Â Â Â Â Âreturn status;
> Â Â Â Â}
> Â Â Â Âchip->range = new_range;
> @@ -291,7 +267,6 @@ static ssize_t store_resolution(struct device *dev,
> Â{
> Â Â Â Âstruct iio_dev *indio_dev = dev_get_drvdata(dev);
> Â Â Â Âstruct isl29018_chip *chip = iio_priv(indio_dev);
> - Â Â Â struct i2c_client *client = chip->client;
> Â Â Â Âint status;
> Â Â Â Âunsigned long lval;
> Â Â Â Âunsigned int new_adc_bit;
> @@ -304,7 +279,7 @@ static ssize_t store_resolution(struct device *dev,
> Â Â Â Â}
>
> Â Â Â Âmutex_lock(&chip->lock);
> - Â Â Â status = isl29018_set_resolution(client, lval, &new_adc_bit);
> + Â Â Â status = isl29018_set_resolution(chip, lval, &new_adc_bit);
> Â Â Â Âif (status < 0) {
> Â Â Â Â Â Â Â Âmutex_unlock(&chip->lock);
> Â Â Â Â Â Â Â Âdev_err(dev, "Error in setting resolution\n");
> @@ -379,7 +354,6 @@ static int isl29018_read_raw(struct iio_dev *indio_dev,
> Â{
> Â Â Â Âint ret = -EINVAL;
> Â Â Â Âstruct isl29018_chip *chip = iio_priv(indio_dev);
> - Â Â Â struct i2c_client *client = chip->client;
>
> Â Â Â Âmutex_lock(&chip->lock);
> Â Â Â Âswitch (mask) {
> @@ -387,13 +361,13 @@ static int isl29018_read_raw(struct iio_dev *indio_dev,
> Â Â Â Âcase IIO_CHAN_INFO_PROCESSED:
> Â Â Â Â Â Â Â Âswitch (chan->type) {
> Â Â Â Â Â Â Â Âcase IIO_LIGHT:
> - Â Â Â Â Â Â Â Â Â Â Â ret = isl29018_read_lux(client, val);
> + Â Â Â Â Â Â Â Â Â Â Â ret = isl29018_read_lux(chip, val);
> Â Â Â Â Â Â Â Â Â Â Â Âbreak;
> Â Â Â Â Â Â Â Âcase IIO_INTENSITY:
> - Â Â Â Â Â Â Â Â Â Â Â ret = isl29018_read_ir(client, val);
> + Â Â Â Â Â Â Â Â Â Â Â ret = isl29018_read_ir(chip, val);
> Â Â Â Â Â Â Â Â Â Â Â Âbreak;
> Â Â Â Â Â Â Â Âcase IIO_PROXIMITY:
> - Â Â Â Â Â Â Â Â Â Â Â ret = isl29018_read_proximity_ir(client,
> + Â Â Â Â Â Â Â Â Â Â Â ret = isl29018_read_proximity_ir(chip,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âchip->prox_scheme, val);
> Â Â Â Â Â Â Â Â Â Â Â Âbreak;
> Â Â Â Â Â Â Â Âdefault:
> @@ -459,15 +433,12 @@ static const struct attribute_group isl29108_group = {
> Â Â Â Â.attrs = isl29018_attributes,
> Â};
>
> -static int isl29018_chip_init(struct i2c_client *client)
> +static int isl29018_chip_init(struct isl29018_chip *chip)
> Â{
> - Â Â Â struct isl29018_chip *chip = iio_priv(i2c_get_clientdata(client));
> Â Â Â Âint status;
> Â Â Â Âint new_adc_bit;
> Â Â Â Âunsigned int new_range;
>
> - Â Â Â memset(chip->reg_cache, 0, sizeof(chip->reg_cache));
> -
> Â Â Â Â/* Code added per Intersil Application Note 1534:
> Â Â Â Â * Â Â When VDD sinks to approximately 1.8V or below, some of
> Â Â Â Â * the part's registers may change their state. When VDD
> @@ -488,10 +459,9 @@ static int isl29018_chip_init(struct i2c_client *client)
> Â Â Â Â * the same thing EXCEPT the data sheet asks for a 1ms delay after
> Â Â Â Â * writing the CMD1 register.
> Â Â Â Â */
> - Â Â Â status = isl29018_write_data(client, ISL29018_REG_TEST, 0,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ISL29018_TEST_MASK, ISL29018_TEST_SHIFT);
> + Â Â Â status = regmap_write(chip->regmap, ISL29018_REG_TEST, 0x0);
> Â Â Â Âif (status < 0) {
> - Â Â Â Â Â Â Â dev_err(&client->dev, "Failed to clear isl29018 TEST reg."
> + Â Â Â Â Â Â Â dev_err(chip->dev, "Failed to clear isl29018 TEST reg."
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â"(%d)\n", status);
> Â Â Â Â Â Â Â Âreturn status;
> Â Â Â Â}
> @@ -500,10 +470,9 @@ static int isl29018_chip_init(struct i2c_client *client)
> Â Â Â Â * "Operating Mode" (COMMAND1) register is reprogrammed when
> Â Â Â Â * data is read from the device.
> Â Â Â Â */
> - Â Â Â status = isl29018_write_data(client, ISL29018_REG_ADD_COMMAND1, 0,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0xff, 0);
> + Â Â Â status = regmap_write(chip->regmap, ISL29018_REG_ADD_COMMAND1, 0);
> Â Â Â Âif (status < 0) {
> - Â Â Â Â Â Â Â dev_err(&client->dev, "Failed to clear isl29018 CMD1 reg."
> + Â Â Â Â Â Â Â dev_err(chip->dev, "Failed to clear isl29018 CMD1 reg."
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â"(%d)\n", status);
> Â Â Â Â Â Â Â Âreturn status;
> Â Â Â Â}
> @@ -511,13 +480,13 @@ static int isl29018_chip_init(struct i2c_client *client)
> Â Â Â Âmsleep(1); Â Â Â/* per data sheet, page 10 */
>
> Â Â Â Â/* set defaults */
> - Â Â Â status = isl29018_set_range(client, chip->range, &new_range);
> + Â Â Â status = isl29018_set_range(chip, chip->range, &new_range);
> Â Â Â Âif (status < 0) {
> - Â Â Â Â Â Â Â dev_err(&client->dev, "Init of isl29018 fails\n");
> + Â Â Â Â Â Â Â dev_err(chip->dev, "Init of isl29018 fails\n");
> Â Â Â Â Â Â Â Âreturn status;
> Â Â Â Â}
>
> - Â Â Â status = isl29018_set_resolution(client, chip->adc_bit,
> + Â Â Â status = isl29018_set_resolution(chip, chip->adc_bit,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â&new_adc_bit);
>
> Â Â Â Âreturn 0;
> @@ -530,6 +499,32 @@ static const struct iio_info isl29108_info = {
> Â Â Â Â.write_raw = &isl29018_write_raw,
> Â};
>
> +static bool is_volatile_reg(struct device *dev, unsigned int reg)
> +{
> + Â Â Â switch (reg) {
> + Â Â Â case ISL29018_REG_ADD_DATA_LSB:
> + Â Â Â case ISL29018_REG_ADD_DATA_MSB:
> + Â Â Â case ISL29018_REG_ADD_COMMAND1:
> + Â Â Â case ISL29018_REG_TEST:
> + Â Â Â Â Â Â Â return true;
> + Â Â Â default:
> + Â Â Â Â Â Â Â return false;
> + Â Â Â }
> +}
> +
> +/*
> + * isl29018_regmap_config: regmap configuration.
> + * Use RBTREE mechanism for caching.
> + */
> +static const struct regmap_config isl29018_regmap_config = {
> + Â Â Â .reg_bits = 8,
> + Â Â Â .val_bits = 8,
> + Â Â Â .volatile_reg = is_volatile_reg,
> + Â Â Â .max_register = ISL29018_REG_TEST,
> + Â Â Â .num_reg_defaults_raw = ISL29018_REG_TEST + 1,
> + Â Â Â .cache_type = REGCACHE_RBTREE,
> +};
> +
> Âstatic int __devinit isl29018_probe(struct i2c_client *client,
> Â Â Â Â Â Â Â Â Â Â Â Â const struct i2c_device_id *id)
> Â{
> @@ -546,7 +541,7 @@ static int __devinit isl29018_probe(struct i2c_client *client,
> Â Â Â Âchip = iio_priv(indio_dev);
>
> Â Â Â Âi2c_set_clientdata(client, indio_dev);
> - Â Â Â chip->client = client;
> + Â Â Â chip->dev = &client->dev;
>
> Â Â Â Âmutex_init(&chip->lock);
>
> @@ -554,7 +549,14 @@ static int __devinit isl29018_probe(struct i2c_client *client,
> Â Â Â Âchip->range = 1000;
> Â Â Â Âchip->adc_bit = 16;
>
> - Â Â Â err = isl29018_chip_init(client);
> + Â Â Â chip->regmap = devm_regmap_init_i2c(client, &isl29018_regmap_config);
> + Â Â Â if (IS_ERR(chip->regmap)) {
> + Â Â Â Â Â Â Â err = PTR_ERR(chip->regmap);
> + Â Â Â Â Â Â Â dev_err(chip->dev, "regmap initialization failed: %d\n", err);
> + Â Â Â Â Â Â Â goto exit;
> + Â Â Â }
> +
> + Â Â Â err = isl29018_chip_init(chip);
> Â Â Â Âif (err)
> Â Â Â Â Â Â Â Âgoto exit_iio_free;
>
> --
> 1.7.1.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/