From: Leon Romanovsky <leon@leon.nu>
To: Peter Rosin <peda@axentia.se>
Cc: linux-kernel@vger.kernel.org, Wolfram Sang <wsa@the-dreams.de>,
linux-i2c@vger.kernel.org
Subject: Re: [PATCH] i2c: mux: only print failure message on error
Date: Mon, 15 May 2017 07:53:22 +0300 [thread overview]
Message-ID: <20170515045322.GX3616@mtr-leonro.local> (raw)
In-Reply-To: <1494780073-13713-1-git-send-email-peda@axentia.se>
[-- Attachment #1: Type: text/plain, Size: 1606 bytes --]
On Sun, May 14, 2017 at 06:41:13PM +0200, Peter Rosin wrote:
> As is, a failure message is printed unconditionally, which is confusing.
> And noisy.
>
> Fixes: 8d4d159f25a7 ("i2c: mux: provide more info on failure in i2c_mux_add_adapter")
> Signed-off-by: Peter Rosin <peda@axentia.se>
> ---
> drivers/i2c/i2c-mux.c | 24 ++++++++++++++----------
> 1 file changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
> index 26f7237558ba..ccf2ce1836c8 100644
> --- a/drivers/i2c/i2c-mux.c
> +++ b/drivers/i2c/i2c-mux.c
> @@ -395,18 +395,22 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc,
> if (force_nr) {
> priv->adap.nr = force_nr;
> ret = i2c_add_numbered_adapter(&priv->adap);
> - dev_err(&parent->dev,
> - "failed to add mux-adapter %u as bus %u (error=%d)\n",
> - chan_id, force_nr, ret);
> + if (ret < 0) {
> + dev_err(&parent->dev,
> + "failed to add mux-adapter %u as bus %u (error=%d)\n",
> + chan_id, force_nr, ret);
> + kfree(priv);
> + return ret;
> + }
> } else {
> ret = i2c_add_adapter(&priv->adap);
> - dev_err(&parent->dev,
> - "failed to add mux-adapter %u (error=%d)\n",
> - chan_id, ret);
> - }
> - if (ret < 0) {
> - kfree(priv);
> - return ret;
> + if (ret < 0) {
> + dev_err(&parent->dev,
> + "failed to add mux-adapter %u (error=%d)\n",
> + chan_id, ret);
> + kfree(priv);
> + return ret;
It is better to add goto label, this will give one place for kfree->return code.
Thanks
> + }
> }
>
> WARN(sysfs_create_link(&priv->adap.dev.kobj, &muxc->dev->kobj,
> --
> 2.1.4
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-05-15 4:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-14 16:41 Peter Rosin
2017-05-15 4:53 ` Leon Romanovsky [this message]
2017-05-15 6:59 ` Peter Rosin
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=20170515045322.GX3616@mtr-leonro.local \
--to=leon@leon.nu \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@axentia.se \
--cc=wsa@the-dreams.de \
/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®