From: Arnd Bergmann <arnd@arndb.de>
To: Bin Liu <b-liu@ti.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
David Lechner <david@lechnology.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] usb: musb: fix error handling message in probe
Date: Sat, 17 Sep 2016 00:21:25 +0200 [thread overview]
Message-ID: <20160916222153.1023842-1-arnd@arndb.de> (raw)
We print an error message when platform_device_register_full()
fails, but the initialization of the argument has been removed,
as shown in this warning:
drivers/usb/musb/da8xx.c: In function 'da8xx_probe':
drivers/usb/musb/da8xx.c:521:3: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
This modifies the function to assign the return code before
checking it, and does uses the same method in the check for
usb_phy_generic_register() as well.
Fixes: 947c49afe41f ("usb: musb: da8xx: Remove mach code")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/usb/musb/da8xx.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 2358f636e48c..210b7e43a6fd 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -462,7 +462,6 @@ static int da8xx_probe(struct platform_device *pdev)
{
struct resource musb_resources[2];
struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev);
- struct platform_device *musb;
struct da8xx_glue *glue;
struct platform_device_info pinfo;
struct clk *clk;
@@ -490,9 +489,10 @@ static int da8xx_probe(struct platform_device *pdev)
pdata->platform_ops = &da8xx_ops;
glue->usb_phy = usb_phy_generic_register();
- if (IS_ERR(glue->usb_phy)) {
+ ret = PTR_ERR_OR_ZERO(glue->usb_phy);
+ if (ret) {
dev_err(&pdev->dev, "failed to register usb_phy\n");
- return PTR_ERR(glue->usb_phy);
+ return ret;
}
platform_set_drvdata(pdev, glue);
@@ -516,14 +516,14 @@ static int da8xx_probe(struct platform_device *pdev)
pinfo.data = pdata;
pinfo.size_data = sizeof(*pdata);
- glue->musb = musb = platform_device_register_full(&pinfo);
- if (IS_ERR(musb)) {
+ glue->musb = platform_device_register_full(&pinfo);
+ ret = PTR_ERR_OR_ZERO(glue->musb);
+ if (ret) {
dev_err(&pdev->dev, "failed to register musb device: %d\n", ret);
usb_phy_generic_unregister(glue->usb_phy);
- return PTR_ERR(musb);
}
- return 0;
+ return ret;
}
static int da8xx_remove(struct platform_device *pdev)
--
2.9.0
next reply other threads:[~2016-09-16 22:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-16 22:21 Arnd Bergmann [this message]
2016-09-21 20:46 ` Bin Liu
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=20160916222153.1023842-1-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=b-liu@ti.com \
--cc=david@lechnology.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@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®