... > > + > > +static int tla2528_probe(struct i2c_client *client, > > + const struct i2c_device_id *id) > > +{ > > + struct iio_dev *indio_dev; > > + struct tla2528_st *st; > > + int ret; > > + > > + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C | > > + I2C_FUNC_SMBUS_WRITE_BYTE)) > > + return -EOPNOTSUPP; > > + > > + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st)); > > + if (!indio_dev) > > + return -ENOMEM; > > + > > + st = iio_priv(indio_dev); > > + i2c_set_clientdata(client, indio_dev); > > + st->client = client; > > + > > + indio_dev->name = id->name; > > + indio_dev->info = &tla2528_info; > > + indio_dev->modes = INDIO_DIRECT_MODE; > > + indio_dev->channels = tla2528_channel; > > + indio_dev->num_channels = ARRAY_SIZE(tla2528_channel); > > + > > + st->ref = devm_regulator_get(&client->dev, "vref"); > > + if (IS_ERR(st->ref)) > > + return PTR_ERR(st->ref); > > + > > + ret = regulator_enable(st->ref); > > + if (ret < 0) > > + return ret; > > + > > I was thinking about whether to mention this earlier. > But, an idea, is to do: > > ret = devm_add_action_or_reset(&spi->dev, tla2528_reg_disable, > st->vref); > if (ret) > return ret; > > Then the i2c_set_clientdata() call can be removed, and the > tla2528_remove() hook as well. > A simple example can be seen in drivers/iio/adc/ti-ads8344.c > > I'm not insisting on it. Since the driver is simple enough. I'd prefer this, because otherwise someone will come along and change it later creating more patches for me to review :) Jonathan