struct max517_data {
struct iio_dev *indio_dev;
+ struct i2c_client *client;
unsigned short vref_mv[2];
};
struct device_attribute *attr,
const char *buf, size_t count, int channel)
{
- struct i2c_client *client = to_i2c_client(dev);
+ struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct max517_data *data = iio_dev_get_devdata(dev_info);
+ struct i2c_client *client = data->client;
u8 outbuf[4]; /* 1x or 2x command + value */
int outbuf_size = 0;
int res;
}
static IIO_DEVICE_ATTR(out2_scale, S_IRUGO, max517_show_scale2, NULL, 0);
-/* On MAX517 variant, we have two outputs */
+/* On MAX517 variant, we have one output */
static struct attribute *max517_attributes[] = {
&iio_dev_attr_out1_raw.dev_attr.attr,
&iio_dev_attr_out1_scale.dev_attr.attr,
.attrs = max517_attributes,
};
-/* On MAX518 and MAX518 variant, we have two outputs */
+/* On MAX518 and MAX519 variant, we have two outputs */
static struct attribute *max518_attributes[] = {
&iio_dev_attr_out1_raw.dev_attr.attr,
&iio_dev_attr_out1_scale.dev_attr.attr,
i2c_set_clientdata(client, data);
+ data->client = client;
+
data->indio_dev = iio_allocate_device();
if (data->indio_dev == NULL) {
err = -ENOMEM;