* [PATCH 00/11] treewide: mask then shift defects and style updates @ 2014-10-27 5:24 Joe Perches 2014-10-27 5:25 ` [PATCH 04/11] dvb-net: Fix probable mask then right shift defects Joe Perches 2014-10-27 5:25 ` [PATCH 05/11] cx25840/cx18: Use standard ordering of mask and shift Joe Perches 0 siblings, 2 replies; 4+ messages in thread From: Joe Perches @ 2014-10-27 5:24 UTC (permalink / raw) To: linux-kernel, linux-nvme, dri-devel, ivtv-devel, linux-media, patches, netdev, linux-usb, linux-parisc Cc: linux-input, linux-wireless, alsa-devel logical mask has lower precedence than shift but should be done before the shift so parentheses are generally required. And when masking with a fixed value after a shift, normal kernel style has the shift on the left, then the shift on the right so convert a few non-conforming uses. Joe Perches (11): block: nvme-scsi: Fix probable mask then right shift defects radeon: evergreen: Fix probable mask then right shift defects aiptek: Fix probable mask then right shift defects dvb-net: Fix probable mask then right shift defects cx25840/cx18: Use standard ordering of mask and shift wm8350-core: Fix probable mask then right shift defect iwlwifi: dvm: Fix probable mask then right shift defect ssb: driver_chip_comon_pmu: Fix probable mask then right shift defect tty: ipwireless: Fix probable mask then right shift defects hwa-hc: Fix probable mask then right shift defect sound: ad1889: Fix probable mask then right shift defects drivers/block/nvme-scsi.c | 12 ++++++------ drivers/gpu/drm/radeon/evergreen.c | 3 ++- drivers/input/tablet/aiptek.c | 6 +++--- drivers/media/dvb-core/dvb_net.c | 4 +++- drivers/media/i2c/cx25840/cx25840-core.c | 12 ++++++------ drivers/media/pci/cx18/cx18-av-core.c | 16 ++++++++-------- drivers/mfd/wm8350-core.c | 2 +- drivers/net/wireless/iwlwifi/dvm/lib.c | 4 ++-- drivers/ssb/driver_chipcommon_pmu.c | 4 ++-- drivers/tty/ipwireless/hardware.c | 12 ++++++------ drivers/usb/host/hwa-hc.c | 2 +- sound/pci/ad1889.c | 8 ++++---- 12 files changed, 44 insertions(+), 41 deletions(-) -- 2.1.2 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 04/11] dvb-net: Fix probable mask then right shift defects 2014-10-27 5:24 [PATCH 00/11] treewide: mask then shift defects and style updates Joe Perches @ 2014-10-27 5:25 ` Joe Perches 2014-10-27 5:25 ` [PATCH 05/11] cx25840/cx18: Use standard ordering of mask and shift Joe Perches 1 sibling, 0 replies; 4+ messages in thread From: Joe Perches @ 2014-10-27 5:25 UTC (permalink / raw) To: linux-kernel; +Cc: Mauro Carvalho Chehab, linux-media Precedence of & and >> is not the same and is not left to right. shift has higher precedence and should be done after the mask. Add parentheses around the mask. Signed-off-by: Joe Perches <joe@perches.com> --- drivers/media/dvb-core/dvb_net.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c index 059e611..441814b 100644 --- a/drivers/media/dvb-core/dvb_net.c +++ b/drivers/media/dvb-core/dvb_net.c @@ -379,7 +379,9 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) /* Check TS error conditions: sync_byte, transport_error_indicator, scrambling_control . */ if ((ts[0] != TS_SYNC) || (ts[1] & TS_TEI) || ((ts[3] & TS_SC) != 0)) { printk(KERN_WARNING "%lu: Invalid TS cell: SYNC %#x, TEI %u, SC %#x.\n", - priv->ts_count, ts[0], ts[1] & TS_TEI >> 7, ts[3] & 0xC0 >> 6); + priv->ts_count, ts[0], + (ts[1] & TS_TEI) >> 7, + (ts[3] & 0xC0) >> 6); /* Drop partly decoded SNDU, reset state, resync on PUSI. */ if (priv->ule_skb) { -- 2.1.2 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 05/11] cx25840/cx18: Use standard ordering of mask and shift 2014-10-27 5:24 [PATCH 00/11] treewide: mask then shift defects and style updates Joe Perches 2014-10-27 5:25 ` [PATCH 04/11] dvb-net: Fix probable mask then right shift defects Joe Perches @ 2014-10-27 5:25 ` Joe Perches 2014-11-08 13:41 ` Andy Walls 1 sibling, 1 reply; 4+ messages in thread From: Joe Perches @ 2014-10-27 5:25 UTC (permalink / raw) To: linux-kernel, Andy Walls; +Cc: Mauro Carvalho Chehab, linux-media, ivtv-devel Precedence of & and >> is not the same and is not left to right. shift has higher precedence and should be done after the mask. This use has a mask then shift which is not the normal style. Move the shift before the mask to match nearly all the other uses in kernel. Signed-off-by: Joe Perches <joe@perches.com> --- drivers/media/i2c/cx25840/cx25840-core.c | 12 ++++++------ drivers/media/pci/cx18/cx18-av-core.c | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c index e453a3f..0327032 100644 --- a/drivers/media/i2c/cx25840/cx25840-core.c +++ b/drivers/media/i2c/cx25840/cx25840-core.c @@ -879,7 +879,7 @@ void cx25840_std_setup(struct i2c_client *client) /* Sets horizontal blanking delay and active lines */ cx25840_write(client, 0x470, hblank); cx25840_write(client, 0x471, - 0xff & (((hblank >> 8) & 0x3) | (hactive << 4))); + (((hblank >> 8) & 0x3) | (hactive << 4)) & 0xff); cx25840_write(client, 0x472, hactive >> 4); /* Sets burst gate delay */ @@ -888,13 +888,13 @@ void cx25840_std_setup(struct i2c_client *client) /* Sets vertical blanking delay and active duration */ cx25840_write(client, 0x474, vblank); cx25840_write(client, 0x475, - 0xff & (((vblank >> 8) & 0x3) | (vactive << 4))); + (((vblank >> 8) & 0x3) | (vactive << 4)) & 0xff); cx25840_write(client, 0x476, vactive >> 4); cx25840_write(client, 0x477, vblank656); /* Sets src decimation rate */ - cx25840_write(client, 0x478, 0xff & src_decimation); - cx25840_write(client, 0x479, 0xff & (src_decimation >> 8)); + cx25840_write(client, 0x478, src_decimation & 0xff); + cx25840_write(client, 0x479, (src_decimation >> 8) & 0xff); /* Sets Luma and UV Low pass filters */ cx25840_write(client, 0x47a, luma_lpf << 6 | ((uv_lpf << 4) & 0x30)); @@ -904,8 +904,8 @@ void cx25840_std_setup(struct i2c_client *client) /* Sets SC Step*/ cx25840_write(client, 0x47c, sc); - cx25840_write(client, 0x47d, 0xff & sc >> 8); - cx25840_write(client, 0x47e, 0xff & sc >> 16); + cx25840_write(client, 0x47d, (sc >> 8) & 0xff); + cx25840_write(client, 0x47e, (sc >> 16) & 0xff); /* Sets VBI parameters */ if (std & V4L2_STD_625_50) { diff --git a/drivers/media/pci/cx18/cx18-av-core.c b/drivers/media/pci/cx18/cx18-av-core.c index 2d3afe0..45be26c 100644 --- a/drivers/media/pci/cx18/cx18-av-core.c +++ b/drivers/media/pci/cx18/cx18-av-core.c @@ -490,8 +490,8 @@ void cx18_av_std_setup(struct cx18 *cx) /* Sets horizontal blanking delay and active lines */ cx18_av_write(cx, 0x470, hblank); - cx18_av_write(cx, 0x471, 0xff & (((hblank >> 8) & 0x3) | - (hactive << 4))); + cx18_av_write(cx, 0x471, + (((hblank >> 8) & 0x3) | (hactive << 4)) & 0xff); cx18_av_write(cx, 0x472, hactive >> 4); /* Sets burst gate delay */ @@ -499,14 +499,14 @@ void cx18_av_std_setup(struct cx18 *cx) /* Sets vertical blanking delay and active duration */ cx18_av_write(cx, 0x474, vblank); - cx18_av_write(cx, 0x475, 0xff & (((vblank >> 8) & 0x3) | - (vactive << 4))); + cx18_av_write(cx, 0x475, + (((vblank >> 8) & 0x3) | (vactive << 4)) & 0xff); cx18_av_write(cx, 0x476, vactive >> 4); cx18_av_write(cx, 0x477, vblank656); /* Sets src decimation rate */ - cx18_av_write(cx, 0x478, 0xff & src_decimation); - cx18_av_write(cx, 0x479, 0xff & (src_decimation >> 8)); + cx18_av_write(cx, 0x478, src_decimation & 0xff); + cx18_av_write(cx, 0x479, (src_decimation >> 8) & 0xff); /* Sets Luma and UV Low pass filters */ cx18_av_write(cx, 0x47a, luma_lpf << 6 | ((uv_lpf << 4) & 0x30)); @@ -516,8 +516,8 @@ void cx18_av_std_setup(struct cx18 *cx) /* Sets SC Step*/ cx18_av_write(cx, 0x47c, sc); - cx18_av_write(cx, 0x47d, 0xff & sc >> 8); - cx18_av_write(cx, 0x47e, 0xff & sc >> 16); + cx18_av_write(cx, 0x47d, (sc >> 8) & 0xff); + cx18_av_write(cx, 0x47e, (sc >> 16) & 0xff); if (std & V4L2_STD_625_50) { state->slicer_line_delay = 1; -- 2.1.2 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 05/11] cx25840/cx18: Use standard ordering of mask and shift 2014-10-27 5:25 ` [PATCH 05/11] cx25840/cx18: Use standard ordering of mask and shift Joe Perches @ 2014-11-08 13:41 ` Andy Walls 0 siblings, 0 replies; 4+ messages in thread From: Andy Walls @ 2014-11-08 13:41 UTC (permalink / raw) To: Joe Perches; +Cc: linux-kernel, Mauro Carvalho Chehab, linux-media On Sun, 2014-10-26 at 22:25 -0700, Joe Perches wrote: > Precedence of & and >> is not the same and is not left to right. > shift has higher precedence and should be done after the mask. > > This use has a mask then shift which is not the normal style. > > Move the shift before the mask to match nearly all the other > uses in kernel. > > Signed-off-by: Joe Perches <joe@perches.com> The patch is technically correct. Reviewed-by: Andy Walls <awalls@md.metrocast.net> > --- > drivers/media/i2c/cx25840/cx25840-core.c | 12 ++++++------ > drivers/media/pci/cx18/cx18-av-core.c | 16 ++++++++-------- > 2 files changed, 14 insertions(+), 14 deletions(-) > > diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c > index e453a3f..0327032 100644 > --- a/drivers/media/i2c/cx25840/cx25840-core.c > +++ b/drivers/media/i2c/cx25840/cx25840-core.c > @@ -879,7 +879,7 @@ void cx25840_std_setup(struct i2c_client *client) > /* Sets horizontal blanking delay and active lines */ > cx25840_write(client, 0x470, hblank); > cx25840_write(client, 0x471, > - 0xff & (((hblank >> 8) & 0x3) | (hactive << 4))); > + (((hblank >> 8) & 0x3) | (hactive << 4)) & 0xff); > cx25840_write(client, 0x472, hactive >> 4); > > /* Sets burst gate delay */ > @@ -888,13 +888,13 @@ void cx25840_std_setup(struct i2c_client *client) > /* Sets vertical blanking delay and active duration */ > cx25840_write(client, 0x474, vblank); > cx25840_write(client, 0x475, > - 0xff & (((vblank >> 8) & 0x3) | (vactive << 4))); > + (((vblank >> 8) & 0x3) | (vactive << 4)) & 0xff); > cx25840_write(client, 0x476, vactive >> 4); > cx25840_write(client, 0x477, vblank656); > > /* Sets src decimation rate */ > - cx25840_write(client, 0x478, 0xff & src_decimation); > - cx25840_write(client, 0x479, 0xff & (src_decimation >> 8)); > + cx25840_write(client, 0x478, src_decimation & 0xff); > + cx25840_write(client, 0x479, (src_decimation >> 8) & 0xff); > > /* Sets Luma and UV Low pass filters */ > cx25840_write(client, 0x47a, luma_lpf << 6 | ((uv_lpf << 4) & 0x30)); > @@ -904,8 +904,8 @@ void cx25840_std_setup(struct i2c_client *client) > > /* Sets SC Step*/ > cx25840_write(client, 0x47c, sc); > - cx25840_write(client, 0x47d, 0xff & sc >> 8); > - cx25840_write(client, 0x47e, 0xff & sc >> 16); > + cx25840_write(client, 0x47d, (sc >> 8) & 0xff); > + cx25840_write(client, 0x47e, (sc >> 16) & 0xff); > > /* Sets VBI parameters */ > if (std & V4L2_STD_625_50) { > diff --git a/drivers/media/pci/cx18/cx18-av-core.c b/drivers/media/pci/cx18/cx18-av-core.c > index 2d3afe0..45be26c 100644 > --- a/drivers/media/pci/cx18/cx18-av-core.c > +++ b/drivers/media/pci/cx18/cx18-av-core.c > @@ -490,8 +490,8 @@ void cx18_av_std_setup(struct cx18 *cx) > > /* Sets horizontal blanking delay and active lines */ > cx18_av_write(cx, 0x470, hblank); > - cx18_av_write(cx, 0x471, 0xff & (((hblank >> 8) & 0x3) | > - (hactive << 4))); > + cx18_av_write(cx, 0x471, > + (((hblank >> 8) & 0x3) | (hactive << 4)) & 0xff); > cx18_av_write(cx, 0x472, hactive >> 4); > > /* Sets burst gate delay */ > @@ -499,14 +499,14 @@ void cx18_av_std_setup(struct cx18 *cx) > > /* Sets vertical blanking delay and active duration */ > cx18_av_write(cx, 0x474, vblank); > - cx18_av_write(cx, 0x475, 0xff & (((vblank >> 8) & 0x3) | > - (vactive << 4))); > + cx18_av_write(cx, 0x475, > + (((vblank >> 8) & 0x3) | (vactive << 4)) & 0xff); > cx18_av_write(cx, 0x476, vactive >> 4); > cx18_av_write(cx, 0x477, vblank656); > > /* Sets src decimation rate */ > - cx18_av_write(cx, 0x478, 0xff & src_decimation); > - cx18_av_write(cx, 0x479, 0xff & (src_decimation >> 8)); > + cx18_av_write(cx, 0x478, src_decimation & 0xff); > + cx18_av_write(cx, 0x479, (src_decimation >> 8) & 0xff); > > /* Sets Luma and UV Low pass filters */ > cx18_av_write(cx, 0x47a, luma_lpf << 6 | ((uv_lpf << 4) & 0x30)); > @@ -516,8 +516,8 @@ void cx18_av_std_setup(struct cx18 *cx) > > /* Sets SC Step*/ > cx18_av_write(cx, 0x47c, sc); > - cx18_av_write(cx, 0x47d, 0xff & sc >> 8); > - cx18_av_write(cx, 0x47e, 0xff & sc >> 16); > + cx18_av_write(cx, 0x47d, (sc >> 8) & 0xff); > + cx18_av_write(cx, 0x47e, (sc >> 16) & 0xff); > > if (std & V4L2_STD_625_50) { > state->slicer_line_delay = 1; ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-08 13:36 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-10-27 5:24 [PATCH 00/11] treewide: mask then shift defects and style updates Joe Perches 2014-10-27 5:25 ` [PATCH 04/11] dvb-net: Fix probable mask then right shift defects Joe Perches 2014-10-27 5:25 ` [PATCH 05/11] cx25840/cx18: Use standard ordering of mask and shift Joe Perches 2014-11-08 13:41 ` Andy Walls
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).