public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Joe Perches <joe@perches.com>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	Vinod Koul <vkoul@kernel.org>,
	devel@driverdev.osuosl.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Yu Chen <chenyu56@huawei.com>,
	Alex Dewar <alex.dewar90@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/4] staging: hikey9xx: phy-hi3670-usb3.c: hi3670_is_abbclk_seleted() returns bool
Date: Tue, 19 Jan 2021 09:56:31 +0300	[thread overview]
Message-ID: <20210119065630.GE2696@kadam> (raw)
In-Reply-To: <d9ebc10ac5c4ba5231ed50ef0d2a15f424547736.camel@perches.com>

On Thu, Jan 14, 2021 at 09:56:41AM -0800, Joe Perches wrote:
> On Thu, 2021-01-14 at 18:35 +0100, Mauro Carvalho Chehab wrote:
> > Instead of using 1/0 for true/false, change the type to boolean
> > and change the returned value.
> []
> > diff --git a/drivers/staging/hikey9xx/phy-hi3670-usb3.c b/drivers/staging/hikey9xx/phy-hi3670-usb3.c
> []
> > @@ -326,24 +326,24 @@ static int hi3670_phy_set_params(struct hi3670_priv *priv)
> >  	return ret;
> >  }
> > 
> > -static int hi3670_is_abbclk_seleted(struct hi3670_priv *priv)
> > +static bool hi3670_is_abbclk_seleted(struct hi3670_priv *priv)
> 
> Presumably this should be "selected" not "seleted"
> 
> >  {
> >  	u32 reg;
> > 
> >  	if (!priv->sctrl) {
> >  		dev_err(priv->dev, "priv->sctrl is null!\n");
> > -		return 1;
> > +		return true;
> >  	}
> > 
> >  	if (regmap_read(priv->sctrl, SCTRL_SCDEEPSLEEPED, &reg)) {
> >  		dev_err(priv->dev, "SCTRL_SCDEEPSLEEPED read failed!\n");
> > -		return 1;
> > +		return true;
> >  	}
> > 
> >  	if ((reg & USB_CLK_SELECTED) == 0)
> > -		return 1;
> > +		return true;
> > 
> > -	return 0;
> > +	return false;
> >  }
> 
> 	if (foo)
> 		return true;
> 	return false;
> 
> should generally be consolidated into a single test.

I quite prefer the original format, but you're right about the return
looking reversed.  Using "return !!(reg & USB_CLK_SELECTED);" is
especially problematic.  I like !! but Linus has commented a couple
times that he doesn't like !!.

regards,
dan carpenter



  reply	other threads:[~2021-01-19  6:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-14 17:35 [PATCH v2 0/4] Promote Hikey 970 USB phy out of staging Mauro Carvalho Chehab
2021-01-14 17:35 ` [PATCH v2 1/4] staging: hikey9xx: phy-hi3670-usb3.c: use bitfield macros Mauro Carvalho Chehab
2021-01-14 17:35 ` [PATCH v2 2/4] staging: hikey9xx: phy-hi3670-usb3.c: adjust retry logic Mauro Carvalho Chehab
2021-01-14 17:35 ` [PATCH v2 3/4] staging: hikey9xx: phy-hi3670-usb3.c: hi3670_is_abbclk_seleted() returns bool Mauro Carvalho Chehab
2021-01-14 17:56   ` Joe Perches
2021-01-19  6:56     ` Dan Carpenter [this message]
2021-01-14 17:35 ` [PATCH v2 4/4] phy: phy-hi3670-usb3: move driver from staging into phy Mauro Carvalho Chehab
2021-01-14 22:54   ` Rob Herring
2021-01-15  1:47   ` Rob Herring
2021-01-19 10:26     ` Mauro Carvalho Chehab
2021-01-22 14:51       ` Rob Herring
2021-01-22 15:57         ` Mauro Carvalho Chehab

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=20210119065630.GE2696@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=alex.dewar90@gmail.com \
    --cc=chenyu56@huawei.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=vkoul@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