Skip to contentSkip to conversation

iio: adc: ti-ads1015: fix incorrect referencing of ads1015_data pointer

PATCH In review Matt Ranostay 4 participants 5 messages Jul 28, 2016 – Aug 21, 2016 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: adc: ti-ads1015: fix incorrect referencing of ads1015_data pointer

---
 drivers/iio/adc/ti-ads1015.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/ti-ads1015.c +2 -1
index 73cbf0b54e54..fe96af6059d5 100644
@@ -403,7 +403,8 @@ static const struct iio_info ads1015_info = {
 #ifdef CONFIG_OF
 static int ads1015_get_channels_config_of(struct i2c_client *client)
 {
-	struct ads1015_data *data = i2c_get_clientdata(client);
+	struct iio_dev *indio_dev = i2c_get_clientdata(client);
+	struct ads1015_data *data = iio_priv(indio_dev);
 	struct device_node *node;
 
 	if (!client->dev.of_node ||
Signature · 1 line
2.7.4
#1 lore raw
Quoted 12 lines · Matt Ranostay
---
 drivers/iio/adc/ti-ads1015.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/ti-ads1015.c +0 -0
index 73cbf0b54e54..fe96af6059d5 100644

drivers/iio/adc/ti-ads1015.c static const struct iio_info ads1015_info = {

Quoted 10 lines
drivers/iio/adc/ti-ads1015.c +2 -2
@@ -403,7 +403,8 @@ static const struct iio_info ads1015_info = {
 #ifdef CONFIG_OF
 static int ads1015_get_channels_config_of(struct i2c_client *client)
 {
-       struct ads1015_data *data = i2c_get_clientdata(client);
+       struct iio_dev *indio_dev = i2c_get_clientdata(client);
+       struct ads1015_data *data = iio_priv(indio_dev);
        struct device_node *node;
 
        if (!client->dev.of_node ||
--

Hi Matt,

Giorgio already sent a patch for this. I think we should go on his way since he found the bug.

Daniel.

#2 lore raw
Quoted 21 lines · Daniel Baluta
Quoted 20 lines · Matt Ranostay
---
 drivers/iio/adc/ti-ads1015.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/ti-ads1015.c +2 -1
index 73cbf0b54e54..fe96af6059d5 100644
@@ -403,7 +403,8 @@ static const struct iio_info ads1015_info = {
 #ifdef CONFIG_OF
 static int ads1015_get_channels_config_of(struct i2c_client *client)
 {
-       struct ads1015_data *data = i2c_get_clientdata(client);
+       struct iio_dev *indio_dev = i2c_get_clientdata(client);
+       struct ads1015_data *data = iio_priv(indio_dev);
        struct device_node *node;
 
Quoted 7 lines

drivers/iio/adc/ti-ads1015.c static const struct iio_info ads1015_info = {

Quoted 2 lines
drivers/iio/adc/ti-ads1015.c +0 -1
        if (!client->dev.of_node ||
--

Hi Matt,

Giorgio already sent a patch for this. I think we should go on his way since he found the bug.

Ah! see both a bug report and patch earlier now :)

Although do you know if there are anymore drivers we had to make a iio version of hwmon for the triggered buffer? I suspect this was a simple copy and paste error from the hwmon driver

Quoted 2 lines

Daniel.

#3 lore raw

PATCH 1/1 iio:ti-ads1015: fix a wrong pointer definition.

The call to i2c_get_clientdata(client) returns a struct iio_dev*, not the needed struct ads1015_data*. We need here an intermediate step as in the function: void ads1015_get_channels_config(struct i2c_client *client).

---
 drivers/iio/adc/ti-ads1015.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/ti-ads1015.c +2 -1
index 1ef39877..066abaf 100644
@@ -489,7 +489,8 @@ static struct iio_info ads1115_info = {
 #ifdef CONFIG_OF
 static int ads1015_get_channels_config_of(struct i2c_client *client)
 {
-	struct ads1015_data *data = i2c_get_clientdata(client);
+	struct iio_dev *indio_dev = i2c_get_clientdata(client);
+	struct ads1015_data *data = iio_priv(indio_dev);
 	struct device_node *node;
 
 	if (!client->dev.of_node ||
Signature · 1 line
2.9.3
maintainer
#4 lore raw

Re: [PATCH 1/1] iio:ti-ads1015: fix a wrong pointer definition.

Quoted 5 lines · Giorgio Dal Molin

The call to i2c_get_clientdata(client) returns a struct iio_dev*, not the needed struct ads1015_data*. We need here an intermediate step as in the function: void ads1015_get_channels_config(struct i2c_client *client).

Applied with the addition of a fixes tag to the fixes-togreg branch of iio.git.

I've also marked this for stable.

Thanks,

Jonathan

Quoted 19 lines
---
 drivers/iio/adc/ti-ads1015.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/ti-ads1015.c +2 -1
index 1ef39877..066abaf 100644
@@ -489,7 +489,8 @@ static struct iio_info ads1115_info = {
 #ifdef CONFIG_OF
 static int ads1015_get_channels_config_of(struct i2c_client *client)
 {
-	struct ads1015_data *data = i2c_get_clientdata(client);
+	struct iio_dev *indio_dev = i2c_get_clientdata(client);
+	struct ads1015_data *data = iio_priv(indio_dev);
 	struct device_node *node;
 
 	if (!client->dev.of_node ||