* [PATCH 1/1] i2c: core: fix a code to suppress a warning
@ 2015-09-15 10:11 Andy Shevchenko
[not found] ` <1442311867-60185-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2015-09-15 10:11 UTC (permalink / raw)
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang,
mika.westerberg-ral2JQCrhuEAvxtiuMwx3w
Cc: Andy Shevchenko
There is a warning when compiling i2c-core.c
drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y
Fix it by using ternary operator.
Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/i2c/i2c-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 3a4c54e..d13a8a0 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -2591,7 +2591,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count)
static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg)
{
/* The address will be sent first */
- u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD);
+ u8 addr = (msg->addr << 1) | ((msg->flags & I2C_M_RD) ? 1 : 0);
pec = i2c_smbus_pec(pec, &addr, 1);
/* The data buffer follows */
--
2.5.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] i2c: core: fix a code to suppress a warning
[not found] ` <1442311867-60185-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2015-09-15 11:23 ` Alexander Sverdlin
2015-09-15 11:25 ` Vladimir Zapolskiy
1 sibling, 0 replies; 7+ messages in thread
From: Alexander Sverdlin @ 2015-09-15 11:23 UTC (permalink / raw)
To: EXT Andy Shevchenko, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
Wolfram Sang, mika.westerberg-ral2JQCrhuEAvxtiuMwx3w
On 15/09/15 12:11, EXT Andy Shevchenko wrote:
> There is a warning when compiling i2c-core.c
> drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y
>
> Fix it by using ternary operator.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Reviewed-by: Alexander Sverdlin <alexander.sverdlin-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
> ---
> drivers/i2c/i2c-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 3a4c54e..d13a8a0 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -2591,7 +2591,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count)
> static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg)
> {
> /* The address will be sent first */
> - u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD);
> + u8 addr = (msg->addr << 1) | ((msg->flags & I2C_M_RD) ? 1 : 0);
> pec = i2c_smbus_pec(pec, &addr, 1);
>
> /* The data buffer follows */
--
Best regards,
Alexander Sverdlin.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] i2c: core: fix a code to suppress a warning
[not found] ` <1442311867-60185-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-09-15 11:23 ` Alexander Sverdlin
@ 2015-09-15 11:25 ` Vladimir Zapolskiy
[not found] ` <55F80047.4000805-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
1 sibling, 1 reply; 7+ messages in thread
From: Vladimir Zapolskiy @ 2015-09-15 11:25 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang,
mika.westerberg-ral2JQCrhuEAvxtiuMwx3w
Hello Andy,
On 15.09.2015 13:11, Andy Shevchenko wrote:
> There is a warning when compiling i2c-core.c
> drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y
>
> Fix it by using ternary operator.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> ---
> drivers/i2c/i2c-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 3a4c54e..d13a8a0 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -2591,7 +2591,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count)
> static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg)
> {
> /* The address will be sent first */
> - u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD);
> + u8 addr = (msg->addr << 1) | ((msg->flags & I2C_M_RD) ? 1 : 0);
> pec = i2c_smbus_pec(pec, &addr, 1);
>
> /* The data buffer follows */
>
I2C_M_RD is defined as 1, probably (msg->flags & I2C_M_RD) is good
enough here.
--
With best wishes,
Vladimir
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] i2c: core: fix a code to suppress a warning
[not found] ` <55F80047.4000805-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
@ 2015-09-15 12:06 ` Andy Shevchenko
[not found] ` <1442318818.8361.29.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2015-09-15 12:06 UTC (permalink / raw)
To: Vladimir Zapolskiy
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang,
mika.westerberg-ral2JQCrhuEAvxtiuMwx3w
On Tue, 2015-09-15 at 14:25 +0300, Vladimir Zapolskiy wrote:
> Hello Andy,
>
> On 15.09.2015 13:11, Andy Shevchenko wrote:
> > There is a warning when compiling i2c-core.c
> > drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y
> >
> > Fix it by using ternary operator.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> > ---
> > drivers/i2c/i2c-core.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> > index 3a4c54e..d13a8a0 100644
> > --- a/drivers/i2c/i2c-core.c
> > +++ b/drivers/i2c/i2c-core.c
> > @@ -2591,7 +2591,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t
> > count)
> > static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg)
> > {
> > /* The address will be sent first */
> > - u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD);
> > + u8 addr = (msg->addr << 1) | ((msg->flags & I2C_M_RD) ? 1
> > : 0);
> > pec = i2c_smbus_pec(pec, &addr, 1);
> >
> > /* The data buffer follows */
> >
>
> I2C_M_RD is defined as 1, probably (msg->flags & I2C_M_RD) is good
> enough here.
Today is 1, tomorrow is 0x80, so, I would stay as I put in the initial
fix.
>
> --
> With best wishes,
> Vladimir
--
Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Intel Finland Oy
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] i2c: core: fix a code to suppress a warning
[not found] ` <1442318818.8361.29.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2015-09-15 12:47 ` Vladimir Zapolskiy
[not found] ` <55F8134F.5080401-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Vladimir Zapolskiy @ 2015-09-15 12:47 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang,
mika.westerberg-ral2JQCrhuEAvxtiuMwx3w
On 15.09.2015 15:06, Andy Shevchenko wrote:
> On Tue, 2015-09-15 at 14:25 +0300, Vladimir Zapolskiy wrote:
>> Hello Andy,
>>
>> On 15.09.2015 13:11, Andy Shevchenko wrote:
>>> There is a warning when compiling i2c-core.c
>>> drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y
>>>
>>> Fix it by using ternary operator.
>>>
>>> Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
>>> ---
>>> drivers/i2c/i2c-core.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
>>> index 3a4c54e..d13a8a0 100644
>>> --- a/drivers/i2c/i2c-core.c
>>> +++ b/drivers/i2c/i2c-core.c
>>> @@ -2591,7 +2591,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t
>>> count)
>>> static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg)
>>> {
>>> /* The address will be sent first */
>>> - u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD);
>>> + u8 addr = (msg->addr << 1) | ((msg->flags & I2C_M_RD) ? 1
>>> : 0);
>>> pec = i2c_smbus_pec(pec, &addr, 1);
>>>
>>> /* The data buffer follows */
>>>
>>
>> I2C_M_RD is defined as 1, probably (msg->flags & I2C_M_RD) is good
>> enough here.
>
> Today is 1, tomorrow is 0x80, so, I would stay as I put in the initial
> fix.
I believe I2C_M_RD will never get any other value than 1, since this
value is deliberately set to 1 and it is in active use by userspace
applications for years, nobody intends to break ABI tomorrow.
--
With best wishes,
Vladimir
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] i2c: core: fix a code to suppress a warning
[not found] ` <55F8134F.5080401-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
@ 2015-09-15 13:00 ` Wolfram Sang
2015-09-15 13:34 ` Andy Shevchenko
0 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2015-09-15 13:00 UTC (permalink / raw)
To: Vladimir Zapolskiy
Cc: Andy Shevchenko, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
mika.westerberg-ral2JQCrhuEAvxtiuMwx3w
[-- Attachment #1: Type: text/plain, Size: 632 bytes --]
> >> I2C_M_RD is defined as 1, probably (msg->flags & I2C_M_RD) is good
> >> enough here.
> >
> > Today is 1, tomorrow is 0x80, so, I would stay as I put in the initial
> > fix.
>
> I believe I2C_M_RD will never get any other value than 1, since this
> value is deliberately set to 1 and it is in active use by userspace
> applications for years, nobody intends to break ABI tomorrow.
I agree. That is one thing that permanently slips through the cracks,
but I wanted to add a comment saying the I2C_M_RD is guaranteed to be 1
and then simplify the drivers.
Maybe I should start with the comment right now...
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] i2c: core: fix a code to suppress a warning
2015-09-15 13:00 ` Wolfram Sang
@ 2015-09-15 13:34 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2015-09-15 13:34 UTC (permalink / raw)
To: Wolfram Sang, Vladimir Zapolskiy
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
mika.westerberg-ral2JQCrhuEAvxtiuMwx3w
On Tue, 2015-09-15 at 15:00 +0200, Wolfram Sang wrote:
> >
> > > > I2C_M_RD is defined as 1, probably (msg->flags & I2C_M_RD) is
> > > > good
> > > > enough here.
> > >
> > > Today is 1, tomorrow is 0x80, so, I would stay as I put in the
> > > initial
> > > fix.
> >
> > I believe I2C_M_RD will never get any other value than 1, since
> > this
> > value is deliberately set to 1 and it is in active use by userspace
> > applications for years, nobody intends to break ABI tomorrow.
>
> I agree. That is one thing that permanently slips through the cracks,
> but I wanted to add a comment saying the I2C_M_RD is guaranteed to be
> 1
> and then simplify the drivers.
Yes, with comment on I2C_M_RD we may drop wrong assumptions.
>
> Maybe I should start with the comment right now...
Please, update my patch accordingly, or ping me to update it.
Right now busy with something else.
--
Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Intel Finland Oy
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-09-15 13:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-15 10:11 [PATCH 1/1] i2c: core: fix a code to suppress a warning Andy Shevchenko
[not found] ` <1442311867-60185-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-09-15 11:23 ` Alexander Sverdlin
2015-09-15 11:25 ` Vladimir Zapolskiy
[not found] ` <55F80047.4000805-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2015-09-15 12:06 ` Andy Shevchenko
[not found] ` <1442318818.8361.29.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-09-15 12:47 ` Vladimir Zapolskiy
[not found] ` <55F8134F.5080401-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2015-09-15 13:00 ` Wolfram Sang
2015-09-15 13:34 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox