From: Hans de Goede <hdegoede@redhat.com>
To: Darren Hart <dvhart@infradead.org>, Andy Shevchenko <andy@infradead.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] platform/x86: surface3_power: i2c_acpi_new_device() returns a PTR_ERR
Date: Tue, 21 Apr 2020 00:04:21 +0200 [thread overview]
Message-ID: <20200420220421.171298-1-hdegoede@redhat.com> (raw)
i2c_acpi_new_device() never returns NULL, it either returns an i2c_client
or a PTR_ERR. Adjust the mshw0011_probe() error handling to take this
into account.
Note the goto out_err will cause i2c_unregister_device() to get called
even though the i2c_acpi_new_device() fails, this is ok as it accepts
a NULL pointer argument (and treats it as a no-op).
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/platform/x86/surface3_power.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/surface3_power.c b/drivers/platform/x86/surface3_power.c
index 946ac2dc08ae..32e6e86e27dd 100644
--- a/drivers/platform/x86/surface3_power.c
+++ b/drivers/platform/x86/surface3_power.c
@@ -522,8 +522,10 @@ static int mshw0011_probe(struct i2c_client *client)
strlcpy(board_info.type, "MSHW0011-bat0", I2C_NAME_SIZE);
bat0 = i2c_acpi_new_device(dev, 1, &board_info);
- if (!bat0)
- return -ENOMEM;
+ if (IS_ERR(bat0)) {
+ error = PTR_ERR(bat0);
+ goto out_err;
+ }
data->bat0 = bat0;
i2c_set_clientdata(bat0, data);
--
2.26.0
next reply other threads:[~2020-04-20 22:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-20 22:04 Hans de Goede [this message]
2020-04-20 22:33 ` Andy Shevchenko
2020-04-21 7:40 ` Hans de Goede
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=20200420220421.171298-1-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=andy@infradead.org \
--cc=dvhart@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@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®