From: Brian Masney <masneyb@onstation.org> To: jic23@kernel.org, linux-iio@vger.kernel.org Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org, lars@metafoo.de, pmeerw@pmeerw.net, knaack.h@gmx.de, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, robh+dt@kernel.org, Mark.Rutland@arm.com Subject: [PATCH 05/10] staging: iio: tsl2583: check return values from taos_chip_{on,off} Date: Fri, 28 Oct 2016 06:00:16 -0400 [thread overview] Message-ID: <1477648821-3786-6-git-send-email-masneyb@onstation.org> (raw) In-Reply-To: <1477648821-3786-1-git-send-email-masneyb@onstation.org> The return value from taos_chip_on() and taos_chip_off() was not checked in taos_luxtable_store() and taos_probe(). This patch adds proper error checking to these function calls. Signed-off-by: Brian Masney <masneyb@onstation.org> --- drivers/staging/iio/light/tsl2583.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index f8ccb4d..e975bba 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -727,7 +727,7 @@ static ssize_t taos_luxtable_store(struct device *dev, struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2583_chip *chip = iio_priv(indio_dev); int value[ARRAY_SIZE(taos_device_lux) * 3 + 1]; - int n; + int n, ret = -EINVAL; get_options(buf, ARRAY_SIZE(value), value); @@ -739,23 +739,31 @@ static ssize_t taos_luxtable_store(struct device *dev, n = value[0]; if ((n % 3) || n < 6 || n > ((ARRAY_SIZE(taos_device_lux) - 1) * 3)) { dev_info(dev, "LUX TABLE INPUT ERROR 1 Value[0]=%d\n", n); - return -EINVAL; + goto done; } if ((value[(n - 2)] | value[(n - 1)] | value[n]) != 0) { dev_info(dev, "LUX TABLE INPUT ERROR 2 Value[0]=%d\n", n); - return -EINVAL; + goto done; } - if (chip->taos_chip_status == TSL258X_CHIP_WORKING) - taos_chip_off(indio_dev); + if (chip->taos_chip_status == TSL258X_CHIP_WORKING) { + ret = taos_chip_off(indio_dev); + if (ret < 0) + goto done; + } /* Zero out the table */ memset(taos_device_lux, 0, sizeof(taos_device_lux)); memcpy(taos_device_lux, &value[1], (value[0] * 4)); - taos_chip_on(indio_dev); + ret = taos_chip_on(indio_dev); + if (ret < 0) + goto done; - return len; + ret = len; + +done: + return ret; } static DEVICE_ATTR(illuminance0_calibscale, S_IRUGO | S_IWUSR, @@ -883,7 +891,9 @@ static int taos_probe(struct i2c_client *clientp, taos_defaults(chip); /* Make sure the chip is on */ - taos_chip_on(indio_dev); + ret = taos_chip_on(indio_dev); + if (ret < 0) + return ret; dev_info(&clientp->dev, "Light sensor found.\n"); return 0; -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: Brian Masney <masneyb@onstation.org> To: jic23@kernel.org, linux-iio@vger.kernel.org Cc: devel@driverdev.osuosl.org, devicetree@vger.kernel.org, lars@metafoo.de, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, pmeerw@pmeerw.net, knaack.h@gmx.de, Mark.Rutland@arm.com Subject: [PATCH 05/10] staging: iio: tsl2583: check return values from taos_chip_{on, off} Date: Fri, 28 Oct 2016 06:00:16 -0400 [thread overview] Message-ID: <1477648821-3786-6-git-send-email-masneyb@onstation.org> (raw) In-Reply-To: <1477648821-3786-1-git-send-email-masneyb@onstation.org> The return value from taos_chip_on() and taos_chip_off() was not checked in taos_luxtable_store() and taos_probe(). This patch adds proper error checking to these function calls. Signed-off-by: Brian Masney <masneyb@onstation.org> --- drivers/staging/iio/light/tsl2583.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index f8ccb4d..e975bba 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -727,7 +727,7 @@ static ssize_t taos_luxtable_store(struct device *dev, struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2583_chip *chip = iio_priv(indio_dev); int value[ARRAY_SIZE(taos_device_lux) * 3 + 1]; - int n; + int n, ret = -EINVAL; get_options(buf, ARRAY_SIZE(value), value); @@ -739,23 +739,31 @@ static ssize_t taos_luxtable_store(struct device *dev, n = value[0]; if ((n % 3) || n < 6 || n > ((ARRAY_SIZE(taos_device_lux) - 1) * 3)) { dev_info(dev, "LUX TABLE INPUT ERROR 1 Value[0]=%d\n", n); - return -EINVAL; + goto done; } if ((value[(n - 2)] | value[(n - 1)] | value[n]) != 0) { dev_info(dev, "LUX TABLE INPUT ERROR 2 Value[0]=%d\n", n); - return -EINVAL; + goto done; } - if (chip->taos_chip_status == TSL258X_CHIP_WORKING) - taos_chip_off(indio_dev); + if (chip->taos_chip_status == TSL258X_CHIP_WORKING) { + ret = taos_chip_off(indio_dev); + if (ret < 0) + goto done; + } /* Zero out the table */ memset(taos_device_lux, 0, sizeof(taos_device_lux)); memcpy(taos_device_lux, &value[1], (value[0] * 4)); - taos_chip_on(indio_dev); + ret = taos_chip_on(indio_dev); + if (ret < 0) + goto done; - return len; + ret = len; + +done: + return ret; } static DEVICE_ATTR(illuminance0_calibscale, S_IRUGO | S_IWUSR, @@ -883,7 +891,9 @@ static int taos_probe(struct i2c_client *clientp, taos_defaults(chip); /* Make sure the chip is on */ - taos_chip_on(indio_dev); + ret = taos_chip_on(indio_dev); + if (ret < 0) + return ret; dev_info(&clientp->dev, "Light sensor found.\n"); return 0; -- 2.7.4
next prev parent reply other threads:[~2016-10-28 10:02 UTC|newest] Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-10-28 10:00 [PATCH 00/10] staging: iio: tsl2583: staging cleanups Brian Masney 2016-10-28 10:00 ` Brian Masney 2016-10-28 10:00 ` [PATCH 01/10] staging: iio: tsl2583: add of_match table for device tree support Brian Masney 2016-10-28 10:00 ` Brian Masney 2016-10-30 17:43 ` Jonathan Cameron 2016-10-30 17:43 ` Jonathan Cameron 2016-10-30 17:44 ` Jonathan Cameron 2016-10-30 17:44 ` Jonathan Cameron 2016-10-31 6:06 ` Rob Herring 2016-10-28 10:00 ` [PATCH 02/10] staging: iio: tsl2583: check for error code from i2c_smbus_read_byte() Brian Masney 2016-10-28 10:00 ` Brian Masney 2016-10-30 17:49 ` Jonathan Cameron 2016-10-30 17:49 ` Jonathan Cameron 2016-10-28 10:00 ` [PATCH 03/10] staging: iio: tsl2583: return proper error code instead of -1 Brian Masney 2016-10-28 10:00 ` Brian Masney 2016-10-30 17:50 ` Jonathan Cameron 2016-10-30 17:50 ` Jonathan Cameron 2016-10-28 10:00 ` [PATCH 04/10] staging: iio: tsl2583: remove redundant power_state sysfs attribute Brian Masney 2016-10-28 10:00 ` Brian Masney 2016-10-30 17:51 ` Jonathan Cameron 2016-10-30 17:51 ` Jonathan Cameron 2016-10-28 10:00 ` Brian Masney [this message] 2016-10-28 10:00 ` [PATCH 05/10] staging: iio: tsl2583: check return values from taos_chip_{on, off} Brian Masney 2016-10-30 17:54 ` [PATCH 05/10] staging: iio: tsl2583: check return values from taos_chip_{on,off} Jonathan Cameron 2016-10-30 17:54 ` Jonathan Cameron 2016-10-28 10:00 ` [PATCH 06/10] staging: iio: tsl2583: convert to use iio_chan_spec and {read,write}_raw Brian Masney 2016-10-28 10:00 ` [PATCH 06/10] staging: iio: tsl2583: convert to use iio_chan_spec and {read, write}_raw Brian Masney 2016-10-30 18:04 ` [PATCH 06/10] staging: iio: tsl2583: convert to use iio_chan_spec and {read,write}_raw Jonathan Cameron 2016-10-30 18:04 ` Jonathan Cameron 2016-10-28 10:00 ` [PATCH 07/10] staging: iio: tsl2583: convert illuminance0_calibscale sysfs attr to use iio_chan_spec Brian Masney 2016-10-28 10:00 ` Brian Masney 2016-10-30 18:37 ` Jonathan Cameron 2016-10-30 18:37 ` Jonathan Cameron 2016-10-30 20:04 ` Brian Masney 2016-10-30 20:04 ` Brian Masney 2016-10-30 20:29 ` Jonathan Cameron 2016-10-30 20:29 ` Jonathan Cameron 2016-10-28 10:00 ` [PATCH 08/10] staging: iio: tsl2583: use IIO_*_ATTR* macros to create sysfs entries Brian Masney 2016-10-28 10:00 ` Brian Masney 2016-10-30 18:38 ` Jonathan Cameron 2016-10-30 18:38 ` Jonathan Cameron 2016-10-28 10:00 ` [PATCH 09/10] staging: iio: tsl2583: add error code to sysfs store functions Brian Masney 2016-10-28 10:00 ` Brian Masney 2016-10-30 18:39 ` Jonathan Cameron 2016-10-30 18:39 ` Jonathan Cameron 2016-10-28 10:00 ` [PATCH 10/10] staging: iio: tsl2583: add locking to sysfs attributes Brian Masney 2016-10-28 10:00 ` Brian Masney 2016-10-30 18:43 ` Jonathan Cameron 2016-10-30 18:43 ` Jonathan Cameron
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1477648821-3786-6-git-send-email-masneyb@onstation.org \ --to=masneyb@onstation.org \ --cc=Mark.Rutland@arm.com \ --cc=devel@driverdev.osuosl.org \ --cc=devicetree@vger.kernel.org \ --cc=gregkh@linuxfoundation.org \ --cc=jic23@kernel.org \ --cc=knaack.h@gmx.de \ --cc=lars@metafoo.de \ --cc=linux-iio@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=pmeerw@pmeerw.net \ --cc=robh+dt@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.