From: Guenter Roeck <linux@roeck-us.net>
To: Zhouyang Jia <jiazhouyang09@gmail.com>
Cc: Jean Delvare <jdelvare@suse.com>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hwmon: (w83792d) add error handling for i2c_new_dummy
Date: Tue, 12 Jun 2018 06:18:55 -0700 [thread overview]
Message-ID: <8cdd8a0b-00e9-7e47-d0e2-bb43bab8fcce@roeck-us.net> (raw)
In-Reply-To: <1528774289-38443-1-git-send-email-jiazhouyang09@gmail.com>
On 06/11/2018 08:31 PM, Zhouyang Jia wrote:
> When i2c_new_dummy fails, the lack of error-handling code may
> cause unexpected results.
>
What are those unexpected results ? The i2c devicees are not really used;
the only reason to allocate them was for address reservation purposes.
This is why the result was ignored, since it does not really matter
for driver operation. I don't see the point of making that fatal.
NACK, sorry.
Guenter
> This patch adds error-handling code after calling i2c_new_dummy.
>
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
> ---
> drivers/hwmon/w83792d.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
> index 76aa39e..2c168c5 100644
> --- a/drivers/hwmon/w83792d.c
> +++ b/drivers/hwmon/w83792d.c
> @@ -961,8 +961,15 @@ w83792d_detect_subclients(struct i2c_client *new_client)
> }
>
> val = w83792d_read_value(new_client, W83792D_REG_I2C_SUBADDR);
> - if (!(val & 0x08))
> + if (!(val & 0x08)) {
> data->lm75[0] = i2c_new_dummy(adapter, 0x48 + (val & 0x7));
> + if (data->lm75[0] == NULL) {
> + dev_err(&new_client->dev,
> + "Failed to allocate I2C device\n");
> + err = -ENODEV;
> + goto ERROR_SC_1;
> + }
> + }
> if (!(val & 0x80)) {
> if ((data->lm75[0] != NULL) &&
> ((val & 0x7) == ((val >> 4) & 0x7))) {
> @@ -974,6 +981,12 @@ w83792d_detect_subclients(struct i2c_client *new_client)
> }
> data->lm75[1] = i2c_new_dummy(adapter,
> 0x48 + ((val >> 4) & 0x7));
> + if (data->lm75[1] == NULL) {
> + dev_err(&new_client->dev,
> + "Failed to allocate I2C device\n");
> + err = -ENODEV;
> + goto ERROR_SC_1;
> + }
> }
>
> return 0;
>
prev parent reply other threads:[~2018-06-12 13:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-12 3:31 Zhouyang Jia
2018-06-12 13:18 ` Guenter Roeck [this message]
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=8cdd8a0b-00e9-7e47-d0e2-bb43bab8fcce@roeck-us.net \
--to=linux@roeck-us.net \
--cc=jdelvare@suse.com \
--cc=jiazhouyang09@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®