linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: accel: mma9551: Check gpiod_to_irq return value
@ 2015-03-02 10:39 Roberta Dobrescu
  2015-03-02 11:18 ` Lars-Peter Clausen
  2015-03-02 14:09 ` Daniel Baluta
  0 siblings, 2 replies; 9+ messages in thread
From: Roberta Dobrescu @ 2015-03-02 10:39 UTC (permalink / raw)
  To: linux-iio
  Cc: daniel.baluta, octavian.purdila, jic23, knaack.h, lars, pmeerw,
	vlad.dogaru, Roberta Dobrescu

The return value of gpiod_to_irq should be checked before giving
it to devm_request_threaded_irq in order to not pass an error
code in case it fails.

Signed-off-by: Roberta Dobrescu <roberta.dobrescu@gmail.com>
Reviewed-by: Vlad Dogaru <vlad.dogaru@intel.com>
---
gpiod_to_irq also appears in the following drivers:
	* drivers/iio/accel/bmc150-accel.c
	* drivers/iio/accel/kxcjk-1013.c
	* drivers/iio/accel/mma9553.c
	* drivers/iio/gyro/bmg160.c
	* drivers/iio/imu/kmx61.c
	* drivers/iio/proximity/sx9500.c,

something like this:

<code>
	ret = gpiod_to_irq(gpio);

	dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);

	return ret;
</code>

The return value of the functions containing the above code is checked,
so the only problem would be that the debug message would contain a wrong
value for irq in case gpiod_to_irq fails. So it doesn't affects much.

 drivers/iio/accel/mma9551.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/accel/mma9551.c b/drivers/iio/accel/mma9551.c
index 46c3835..b6f3041 100644
--- a/drivers/iio/accel/mma9551.c
+++ b/drivers/iio/accel/mma9551.c
@@ -428,7 +428,11 @@ static int mma9551_gpio_probe(struct iio_dev *indio_dev)
 		if (ret)
 			return ret;
 
-		data->irqs[i] = gpiod_to_irq(gpio);
+		ret = gpiod_to_irq(gpio);
+		if (ret < 0)
+			return ret;
+
+		data->irqs[i] = ret;
 		ret = devm_request_threaded_irq(dev, data->irqs[i],
 				NULL, mma9551_event_handler,
 				IRQF_TRIGGER_RISING | IRQF_ONESHOT,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-03-09 13:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-02 10:39 [PATCH] iio: accel: mma9551: Check gpiod_to_irq return value Roberta Dobrescu
2015-03-02 11:18 ` Lars-Peter Clausen
2015-03-07 19:08   ` Jonathan Cameron
2015-03-02 14:09 ` Daniel Baluta
2015-03-02 16:15   ` Uwe Kleine-König
2015-03-03  7:02     ` Vlad Dogaru
2015-03-08 11:03       ` Jonathan Cameron
2015-03-09 12:34         ` Vlad Dogaru
2015-03-09 13:29           ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).