kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] remoteproc: fix a.vs ~ typo
@ 2018-12-18  8:16 Dan Carpenter
  2018-12-20 10:05 ` Patrice CHOTARD
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2018-12-18  8:16 UTC (permalink / raw)
  To: Patrice Chotard, Peter Griffin
  Cc: Ohad Ben-Cohen, Bjorn Andersson, linux-remoteproc,
	kernel-janitors

This is from static analysis and not from testing.  It doesn't really
make sense to talk about !BIT(0) so probably ~BIT(0) was intended.
I had to cast it from unsigned long to unsigned int to silence a GCC
warning.

Fixes: bb6869b21478 ("Peter Griffin <peter.griffin@linaro.org>")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---

Sorry for the crap commit message.  I'm pretty sure the static checker
warning is correct, but I don't know what the run time impact of this
bug would be.

 drivers/remoteproc/st_slim_rproc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/st_slim_rproc.c b/drivers/remoteproc/st_slim_rproc.c
index d711d9430a4f..a646dfb9d6cd 100644
--- a/drivers/remoteproc/st_slim_rproc.c
+++ b/drivers/remoteproc/st_slim_rproc.c
@@ -128,7 +128,7 @@ static int slim_rproc_start(struct rproc *rproc)
 	writel(SLIM_STBUS_SYNC_DIS, slim_rproc->peri + SLIM_STBUS_SYNC_OFST);
 
 	/* enable cpu pipeline clock */
-	writel(!SLIM_CLK_GATE_DIS,
+	writel((unsigned int)~SLIM_CLK_GATE_DIS,
 		slim_rproc->slimcore + SLIM_CLK_GATE_OFST);
 
 	/* clear int & cmd mailbox */
@@ -167,7 +167,7 @@ static int slim_rproc_stop(struct rproc *rproc)
 	/* disable cpu pipeline clock */
 	writel(SLIM_CLK_GATE_DIS, slim_rproc->slimcore + SLIM_CLK_GATE_OFST);
 
-	writel(!SLIM_EN_RUN, slim_rproc->slimcore + SLIM_EN_OFST);
+	writel((unsigned int)~SLIM_EN_RUN, slim_rproc->slimcore + SLIM_EN_OFST);
 
 	val = readl(slim_rproc->slimcore + SLIM_EN_OFST);
 	if (val & SLIM_EN_RUN)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] remoteproc: fix a.vs ~ typo
  2018-12-18  8:16 [PATCH] remoteproc: fix a.vs ~ typo Dan Carpenter
@ 2018-12-20 10:05 ` Patrice CHOTARD
  2018-12-20 10:14   ` Dan Carpenter
  2018-12-20 10:17   ` Dan Carpenter
  0 siblings, 2 replies; 4+ messages in thread
From: Patrice CHOTARD @ 2018-12-20 10:05 UTC (permalink / raw)
  To: Dan Carpenter, Peter Griffin
  Cc: Ohad Ben-Cohen, Bjorn Andersson, linux-remoteproc@vger.kernel.org,
	kernel-janitors@vger.kernel.org, Loic PALLARDY

SGkgRGFuDQoNCk9uIDEyLzE4LzE4IDk6MTYgQU0sIERhbiBDYXJwZW50ZXIgd3JvdGU6DQo+IFRo
aXMgaXMgZnJvbSBzdGF0aWMgYW5hbHlzaXMgYW5kIG5vdCBmcm9tIHRlc3RpbmcuICBJdCBkb2Vz
bid0IHJlYWxseQ0KPiBtYWtlIHNlbnNlIHRvIHRhbGsgYWJvdXQgIUJJVCgwKSBzbyBwcm9iYWJs
eSB+QklUKDApIHdhcyBpbnRlbmRlZC4NCj4gSSBoYWQgdG8gY2FzdCBpdCBmcm9tIHVuc2lnbmVk
IGxvbmcgdG8gdW5zaWduZWQgaW50IHRvIHNpbGVuY2UgYSBHQ0MNCj4gd2FybmluZy4NCj4gDQo+
IEZpeGVzOiBiYjY4NjliMjE0NzggKCJQZXRlciBHcmlmZmluIDxwZXRlci5ncmlmZmluQGxpbmFy
by5vcmc+IikNCj4gU2lnbmVkLW9mZi1ieTogRGFuIENhcnBlbnRlciA8ZGFuLmNhcnBlbnRlckBv
cmFjbGUuY29tPg0KPiAtLS0NCj4gDQo+IFNvcnJ5IGZvciB0aGUgY3JhcCBjb21taXQgbWVzc2Fn
ZS4gIEknbSBwcmV0dHkgc3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IgaW50ICYg
Y21kIG1haWxib3ggKi8NCj4gQEAgLTE2Nyw3ICsxNjcsNyBAQCBzdGF0aWMgaW50IHNsaW1fcnBy
b2Nfc3RvcChzdHJ1Y3QgcnByb2MgKnJwcm9jKQ0KPiAgCS8qIGRpc2FibGUgY3B1IHBpcGVsaW5l
IGNsb2NrICovDQo+ICAJd3JpdGVsKFNMSU1fQ0xLX0dBVEVfRElTLCBzbGltX3Jwcm9jLT5zbGlt
Y29yZSArIFNMSU1fQ0xLX0dBVEVfT0ZTVCk7DQo+ICANCj4gLQl3cml0ZWwoIVNMSU1fRU5fUlVO
LCBzbGltX3Jwcm9jLT5zbGltY29yZSArIFNMSU1fRU5fT0ZTVCk7DQo+ICsJd3JpdGVsKCh1bnNp
Z25lZCBpbnQpflNMSU1fRU5fUlVOLCBzbGltX3Jwcm9jLT5zbGltY29yZSArIFNMSU1fRU5fT0ZT
VCk7DQo+ICANCj4gIAl2YWwgPSByZWFkbChzbGltX3Jwcm9jLT5zbGltY29yZSArIFNMSU1fRU5f
T0ZTVCk7DQo+ICAJaWYgKHZhbCAmIFNMSU1fRU5fUlVOKQ0KPiANCg0KV3JpdGluZyAhU0xJTV9D
TEtfR0FURV9ESVMgb3IgKHVuc2lnbmVkIGludCl+U0xJTV9DTEtfR0FURV9ESVMgZG9uJ3QNCmdp
dmUgdGhlIHNhbWUgcmVzdWx0Og0KDQohU0xJTV9DTEtfR0FURV9ESVMgPSAwDQoNCih1bnNpZ25l
ZCBpbnQpflNMSU1fQ0xLX0dBVEVfRElTID0gMHhmZmZmZmZmZQ0KDQpQYXRyaWNlDQoNCg=

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] remoteproc: fix a.vs ~ typo
  2018-12-20 10:05 ` Patrice CHOTARD
@ 2018-12-20 10:14   ` Dan Carpenter
  2018-12-20 10:17   ` Dan Carpenter
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2018-12-20 10:14 UTC (permalink / raw)
  To: Patrice CHOTARD
  Cc: Peter Griffin, Ohad Ben-Cohen, Bjorn Andersson,
	linux-remoteproc@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Loic PALLARDY

On Thu, Dec 20, 2018 at 10:05:55AM +0000, Patrice CHOTARD wrote:
> > -	writel(!SLIM_EN_RUN, slim_rproc->slimcore + SLIM_EN_OFST);
> > +	writel((unsigned int)~SLIM_EN_RUN, slim_rproc->slimcore + SLIM_EN_OFST);
> >  
> >  	val = readl(slim_rproc->slimcore + SLIM_EN_OFST);
> >  	if (val & SLIM_EN_RUN)
> > 
> 
> Writing !SLIM_CLK_GATE_DIS or (unsigned int)~SLIM_CLK_GATE_DIS don't
> give the same result:
> 
> !SLIM_CLK_GATE_DIS = 0
> 
> (unsigned int)~SLIM_CLK_GATE_DIS = 0xfffffffe

Right.  !BIT(0) is zero.  I'm pretty sure we meant to do a bitwise
negate and not a logical negate from looking at the code, but I don't
know the real world impact and can't test it.  It's kind of a crap
patch, but I think it's correct.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] remoteproc: fix a.vs ~ typo
  2018-12-20 10:05 ` Patrice CHOTARD
  2018-12-20 10:14   ` Dan Carpenter
@ 2018-12-20 10:17   ` Dan Carpenter
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2018-12-20 10:17 UTC (permalink / raw)
  To: Patrice CHOTARD
  Cc: Peter Griffin, Ohad Ben-Cohen, Bjorn Andersson,
	linux-remoteproc@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Loic PALLARDY

On Thu, Dec 20, 2018 at 10:05:55AM +0000, Patrice CHOTARD wrote:
> Hi Dan
> 
> On 12/18/18 9:16 AM, Dan Carpenter wrote:
> > This is from static analysis and not from testing.  It doesn't really
> > make sense to talk about !BIT(0) so probably ~BIT(0) was intended.
> > I had to cast it from unsigned long to unsigned int to silence a GCC
> > warning.
> > 
> > Fixes: bb6869b21478 ("Peter Griffin <peter.griffin@linaro.org>")

And oh...  I put Peter's email here instead of the commit title.  Sorry.

I will resend if we decide the patch is required.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-20 10:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-18  8:16 [PATCH] remoteproc: fix a.vs ~ typo Dan Carpenter
2018-12-20 10:05 ` Patrice CHOTARD
2018-12-20 10:14   ` Dan Carpenter
2018-12-20 10:17   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).