Loading drivers/staging/iio/dac/max517.c +14 −26 Original line number Original line Diff line number Diff line Loading @@ -59,7 +59,7 @@ static ssize_t max517_set_value(struct device *dev, const char *buf, size_t count, int channel) const char *buf, size_t count, int channel) { { struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev); struct max517_data *data = iio_dev_get_devdata(dev_info); struct max517_data *data = iio_priv(dev_info); struct i2c_client *client = data->client; struct i2c_client *client = data->client; u8 outbuf[4]; /* 1x or 2x command + value */ u8 outbuf[4]; /* 1x or 2x command + value */ int outbuf_size = 0; int outbuf_size = 0; Loading Loading @@ -127,7 +127,7 @@ static ssize_t max517_show_scale(struct device *dev, char *buf, int channel) char *buf, int channel) { { struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev); struct max517_data *data = iio_dev_get_devdata(dev_info); struct max517_data *data = iio_priv(dev_info); /* Corresponds to Vref / 2^(bits) */ /* Corresponds to Vref / 2^(bits) */ unsigned int scale_uv = (data->vref_mv[channel - 1] * 1000) >> 8; unsigned int scale_uv = (data->vref_mv[channel - 1] * 1000) >> 8; Loading Loading @@ -203,35 +203,28 @@ static int max517_probe(struct i2c_client *client, const struct i2c_device_id *id) const struct i2c_device_id *id) { { struct max517_data *data; struct max517_data *data; struct iio_dev *indio_dev; struct max517_platform_data *platform_data = client->dev.platform_data; struct max517_platform_data *platform_data = client->dev.platform_data; int err; int err; data = kzalloc(sizeof(struct max517_data), GFP_KERNEL); indio_dev = iio_allocate_device(sizeof(*data)); if (!data) { if (indio_dev == NULL) { err = -ENOMEM; err = -ENOMEM; goto exit; goto exit; } } data = iio_priv(indio_dev); i2c_set_clientdata(client, data); i2c_set_clientdata(client, indio_dev); data->client = client; data->client = client; data->indio_dev = iio_allocate_device(0); if (data->indio_dev == NULL) { err = -ENOMEM; goto exit_free_data; } /* establish that the iio_dev is a child of the i2c device */ /* establish that the iio_dev is a child of the i2c device */ data->indio_dev->dev.parent = &client->dev; indio_dev->dev.parent = &client->dev; /* reduced attribute set for MAX517 */ /* reduced attribute set for MAX517 */ if (id->driver_data == ID_MAX517) if (id->driver_data == ID_MAX517) data->indio_dev->info = &max517_info; indio_dev->info = &max517_info; else else data->indio_dev->info = &max518_info; indio_dev->info = &max518_info; data->indio_dev->dev_data = (void *)(data); indio_dev->modes = INDIO_DIRECT_MODE; data->indio_dev->modes = INDIO_DIRECT_MODE; /* /* * Reference voltage on MAX518 and default is 5V, else take vref_mv * Reference voltage on MAX518 and default is 5V, else take vref_mv Loading @@ -244,7 +237,7 @@ static int max517_probe(struct i2c_client *client, data->vref_mv[1] = platform_data->vref_mv[1]; data->vref_mv[1] = platform_data->vref_mv[1]; } } err = iio_device_register(data->indio_dev); err = iio_device_register(indio_dev); if (err) if (err) goto exit_free_device; goto exit_free_device; Loading @@ -253,19 +246,14 @@ static int max517_probe(struct i2c_client *client, return 0; return 0; exit_free_device: exit_free_device: iio_free_device(data->indio_dev); iio_free_device(indio_dev); exit_free_data: kfree(data); exit: exit: return err; return err; } } static int max517_remove(struct i2c_client *client) static int max517_remove(struct i2c_client *client) { { struct max517_data *data = i2c_get_clientdata(client); iio_free_device(i2c_get_clientdata(client)); iio_free_device(data->indio_dev); kfree(data); return 0; return 0; } } Loading Loading
drivers/staging/iio/dac/max517.c +14 −26 Original line number Original line Diff line number Diff line Loading @@ -59,7 +59,7 @@ static ssize_t max517_set_value(struct device *dev, const char *buf, size_t count, int channel) const char *buf, size_t count, int channel) { { struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev); struct max517_data *data = iio_dev_get_devdata(dev_info); struct max517_data *data = iio_priv(dev_info); struct i2c_client *client = data->client; struct i2c_client *client = data->client; u8 outbuf[4]; /* 1x or 2x command + value */ u8 outbuf[4]; /* 1x or 2x command + value */ int outbuf_size = 0; int outbuf_size = 0; Loading Loading @@ -127,7 +127,7 @@ static ssize_t max517_show_scale(struct device *dev, char *buf, int channel) char *buf, int channel) { { struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev); struct max517_data *data = iio_dev_get_devdata(dev_info); struct max517_data *data = iio_priv(dev_info); /* Corresponds to Vref / 2^(bits) */ /* Corresponds to Vref / 2^(bits) */ unsigned int scale_uv = (data->vref_mv[channel - 1] * 1000) >> 8; unsigned int scale_uv = (data->vref_mv[channel - 1] * 1000) >> 8; Loading Loading @@ -203,35 +203,28 @@ static int max517_probe(struct i2c_client *client, const struct i2c_device_id *id) const struct i2c_device_id *id) { { struct max517_data *data; struct max517_data *data; struct iio_dev *indio_dev; struct max517_platform_data *platform_data = client->dev.platform_data; struct max517_platform_data *platform_data = client->dev.platform_data; int err; int err; data = kzalloc(sizeof(struct max517_data), GFP_KERNEL); indio_dev = iio_allocate_device(sizeof(*data)); if (!data) { if (indio_dev == NULL) { err = -ENOMEM; err = -ENOMEM; goto exit; goto exit; } } data = iio_priv(indio_dev); i2c_set_clientdata(client, data); i2c_set_clientdata(client, indio_dev); data->client = client; data->client = client; data->indio_dev = iio_allocate_device(0); if (data->indio_dev == NULL) { err = -ENOMEM; goto exit_free_data; } /* establish that the iio_dev is a child of the i2c device */ /* establish that the iio_dev is a child of the i2c device */ data->indio_dev->dev.parent = &client->dev; indio_dev->dev.parent = &client->dev; /* reduced attribute set for MAX517 */ /* reduced attribute set for MAX517 */ if (id->driver_data == ID_MAX517) if (id->driver_data == ID_MAX517) data->indio_dev->info = &max517_info; indio_dev->info = &max517_info; else else data->indio_dev->info = &max518_info; indio_dev->info = &max518_info; data->indio_dev->dev_data = (void *)(data); indio_dev->modes = INDIO_DIRECT_MODE; data->indio_dev->modes = INDIO_DIRECT_MODE; /* /* * Reference voltage on MAX518 and default is 5V, else take vref_mv * Reference voltage on MAX518 and default is 5V, else take vref_mv Loading @@ -244,7 +237,7 @@ static int max517_probe(struct i2c_client *client, data->vref_mv[1] = platform_data->vref_mv[1]; data->vref_mv[1] = platform_data->vref_mv[1]; } } err = iio_device_register(data->indio_dev); err = iio_device_register(indio_dev); if (err) if (err) goto exit_free_device; goto exit_free_device; Loading @@ -253,19 +246,14 @@ static int max517_probe(struct i2c_client *client, return 0; return 0; exit_free_device: exit_free_device: iio_free_device(data->indio_dev); iio_free_device(indio_dev); exit_free_data: kfree(data); exit: exit: return err; return err; } } static int max517_remove(struct i2c_client *client) static int max517_remove(struct i2c_client *client) { { struct max517_data *data = i2c_get_clientdata(client); iio_free_device(i2c_get_clientdata(client)); iio_free_device(data->indio_dev); kfree(data); return 0; return 0; } } Loading