staging:iio:magnetometer:ak8975 use platform_data to pass the gpio number.
Subsystems (4)
PATCH 1/3 staging:iio:magnetometer:ak8975 use platform_data to pass the gpio number.
From: Jonathan Cameron <[email protected]>
Tegra doesn't have irq_to_gpio() any more, and ak8975 is included in tegra_defconfig. This causes a build failure. Instead, pass the GPIO name through platform data.
[swarren: Rewrote commit description when I squashed this with my patch to remove the irq_to_gpio() call]
--- drivers/staging/iio/magnetometer/ak8975.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/staging/iio/magnetometer/ak8975.c +4 -1
@@ -477,7 +477,10 @@ static int ak8975_probe(struct i2c_client *client,int err;/* Grab and set up the supplied GPIO. */ - eoc_gpio =irq_to_gpio (client->irq); +if (client->dev.platform_data ==NULL ) + eoc_gpio =-1 ; +else + eoc_gpio = *(int *)(client->dev.platform_data);/* We may not have a GPIO based IRQ to scan, that is fine, we will poll if so */
Signature · 1 line
1.7.0.4
PATCH 2/3 staging:iio:magnetometer:ak8975: Don't assume 0 is an invalid GPIO
gpio_is_valid() is the defined mechanism to determine whether a GPIO is valid. Use this instead of assuming that 0 is an invalid GPIO.
--- drivers/staging/iio/magnetometer/ak8975.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)
drivers/staging/iio/magnetometer/ak8975.c +5 -6
@@ -373,7 +373,7 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val) }/* Wait for the conversion to complete. */ -if (data->eoc_gpio) +if (gpio_is_valid (data->eoc_gpio)) ret =wait_conversion_complete_gpio (data);else ret =wait_conversion_complete_polled (data);
@@ -484,7 +484,7 @@ static int ak8975_probe(struct i2c_client *client,/* We may not have a GPIO based IRQ to scan, that is fine, we will poll if so */ -if (eoc_gpio >0 ) { +if (gpio_is_valid (eoc_gpio)) { err =gpio_request (eoc_gpio,"ak_8975" );if (err <0 ) { dev_err(&client->dev,
@@ -500,8 +500,7 @@ static int ak8975_probe(struct i2c_client *client, eoc_gpio, err); goto exit_gpio; } - }else - eoc_gpio =0 ;/* No GPIO available */ + }/* Register with IIO */ indio_dev =iio_allocate_device (sizeof (*data));
@@ -537,7 +536,7 @@ static int ak8975_probe(struct i2c_client *client, exit_free_iio:iio_free_device (indio_dev); exit_gpio: -if (eoc_gpio) +if (gpio_is_valid (eoc_gpio))gpio_free (eoc_gpio); exit:return err;
@@ -552,7 +551,7 @@ static int ak8975_remove(struct i2c_client *client)iio_device_unregister (indio_dev);iio_free_device (indio_dev); -if (eoc_gpio) +if (gpio_is_valid (eoc_gpio))gpio_free (eoc_gpio);return 0 ;
Signature · 1 line
1.7.0.4
PATCH 3/3 staging:iio:magnetometer:ak8975: Fix probe() error-handling
In reply to Stephen WarrenFix ak8975_probe() to jump to the appropriate exit labels when an error occurs. With the previous code, some cleanup actions were being skipped for some error conditions.
--- drivers/staging/iio/magnetometer/ak8975.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/iio/magnetometer/ak8975.c +1 -1
@@ -513,7 +513,7 @@ static int ak8975_probe(struct i2c_client *client, err =ak8975_setup (client);if (err <0 ) {dev_err (&client->dev,"AK8975 initialization fails\n" ); - goto exit_gpio; + goto exit_free_iio; }i2c_set_clientdata (client, indio_dev);
Signature · 1 line
1.7.0.4
Quoted 8 lines · Stephen Warren
From: Jonathan Cameron <jic23-KWPb1pKIrIJaa/[email protected]>
Tegra doesn't have
irq_to_gpio()any more, and ak8975 is included integra_defconfig. This causes a build failure. Instead, pass the GPIO name through platform data.[swarren: Rewrote commit description when I squashed this with my patch to remove the
irq_to_gpio()call]
As I've stated elsewhere, this is the wrong fix for this particular driver, but it is the one with minimal impact and as such I'm happy for it to go in as a stop gap until someone has time (and hardware) to clean this driver up to make 'correct' use of interrupts. Note it's not going to leave staging until that is done or someone explains why it can't be!
Quoted 3 lines
Signed-off-by Jonathan Cameron <jic23-KWPb1pKIrIJaa/[email protected]>Signed-off-by Stephen Warren <[email protected]>
Second one has some trivial one line fuzz against what I think is the current state of Greg's tree - I'll push these on in the series I'll be sending to Greg later today. Obviously fine if Greg has already merged them and fixed it up!
Thanks,
Jonathan
Quoted 20 lines
--- drivers/staging/iio/magnetometer/ak8975.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)drivers/staging/iio/magnetometer/ak8975.c +4
-1@@ -477,7 +477,10 @@ static int ak8975_probe(struct i2c_client *client,int err;/* Grab and set up the supplied GPIO. */ - eoc_gpio =irq_to_gpio (client->irq); +if (client->dev.platform_data ==NULL ) + eoc_gpio =-1 ; +else + eoc_gpio = *(int *)(client->dev.platform_data);/* We may not have a GPIO based IRQ to scan, that is fine, we will poll if so */