mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-28 14:44:10 +08:00
media: don't do a 31 bit shift on a signed int
On 32-bits archs, a signed integer has 31 bits plus on extra bit for signal. Due to that, touching the 32th bit with something like: int bar = 1 << 31; has an undefined behavior in C on 32 bit architectures, as it touches the signal bit. This is warned by cppcheck. Instead, force the numbers to be unsigned, in order to solve this issue. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
cce8ccca80
commit
95c520690f
@ -431,7 +431,7 @@ static u32 cx24123_int_log2(u32 a, u32 b)
|
||||
u32 div = a / b;
|
||||
if (a % b >= b / 2)
|
||||
++div;
|
||||
if (div < (1 << 31)) {
|
||||
if (div < (1UL << 31)) {
|
||||
for (exp = 1; div > exp; nearest++)
|
||||
exp += exp;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
|
||||
data = ir_extract_bits(gpio, ir->mask_keycode);
|
||||
|
||||
/* Check if it is keyup */
|
||||
keyup = (gpio & ir->mask_keyup) ? 1 << 31 : 0;
|
||||
keyup = (gpio & ir->mask_keyup) ? 1UL << 31 : 0;
|
||||
|
||||
if ((ir->last_gpio & 0x7f) != data) {
|
||||
dprintk("gpio=0x%x code=%d | %s\n",
|
||||
@ -95,7 +95,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
|
||||
if (keyup)
|
||||
rc_keyup(ir->dev);
|
||||
} else {
|
||||
if ((ir->last_gpio & 1 << 31) == keyup)
|
||||
if ((ir->last_gpio & 1UL << 31) == keyup)
|
||||
return;
|
||||
|
||||
dprintk("(cnt) gpio=0x%x code=%d | %s\n",
|
||||
|
@ -78,7 +78,7 @@ static u16 select_service_from_set(int field, int line, u16 set, int is_pal)
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < 32; i++) {
|
||||
if ((1 << i) & set)
|
||||
if (BIT(i) & set)
|
||||
return 1 << i;
|
||||
}
|
||||
return 0;
|
||||
|
@ -910,7 +910,7 @@ static void ivtv_load_and_init_modules(struct ivtv *itv)
|
||||
|
||||
/* check which i2c devices are actually found */
|
||||
for (i = 0; i < 32; i++) {
|
||||
u32 device = 1 << i;
|
||||
u32 device = BIT(i);
|
||||
|
||||
if (!(device & hw))
|
||||
continue;
|
||||
|
@ -73,8 +73,8 @@ static u16 select_service_from_set(int field, int line, u16 set, int is_pal)
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < 32; i++) {
|
||||
if ((1 << i) & set)
|
||||
return 1 << i;
|
||||
if (BIT(i) & set)
|
||||
return BIT(i);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -39,13 +39,13 @@ static void solo_gpio_mode(struct solo_dev *solo_dev,
|
||||
ret = solo_reg_read(solo_dev, SOLO_GPIO_CONFIG_1);
|
||||
|
||||
for (port = 0; port < 16; port++) {
|
||||
if (!((1 << (port + 16)) & port_mask))
|
||||
if (!((1UL << (port + 16)) & port_mask))
|
||||
continue;
|
||||
|
||||
if (!mode)
|
||||
ret &= ~(1 << port);
|
||||
ret &= ~(1UL << port);
|
||||
else
|
||||
ret |= 1 << port;
|
||||
ret |= 1UL << port;
|
||||
}
|
||||
|
||||
/* Enable GPIO[31:16] */
|
||||
|
@ -41,7 +41,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-2)");
|
||||
/* CSIS global control */
|
||||
#define S5PCSIS_CTRL 0x00
|
||||
#define S5PCSIS_CTRL_DPDN_DEFAULT (0 << 31)
|
||||
#define S5PCSIS_CTRL_DPDN_SWAP (1 << 31)
|
||||
#define S5PCSIS_CTRL_DPDN_SWAP (1UL << 31)
|
||||
#define S5PCSIS_CTRL_ALIGN_32BIT (1 << 20)
|
||||
#define S5PCSIS_CTRL_UPDATE_SHADOW (1 << 16)
|
||||
#define S5PCSIS_CTRL_WCLK_EXTCLK (1 << 8)
|
||||
@ -65,7 +65,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-2)");
|
||||
|
||||
/* Interrupt mask */
|
||||
#define S5PCSIS_INTMSK 0x10
|
||||
#define S5PCSIS_INTMSK_EVEN_BEFORE (1 << 31)
|
||||
#define S5PCSIS_INTMSK_EVEN_BEFORE (1UL << 31)
|
||||
#define S5PCSIS_INTMSK_EVEN_AFTER (1 << 30)
|
||||
#define S5PCSIS_INTMSK_ODD_BEFORE (1 << 29)
|
||||
#define S5PCSIS_INTMSK_ODD_AFTER (1 << 28)
|
||||
@ -83,7 +83,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-2)");
|
||||
|
||||
/* Interrupt source */
|
||||
#define S5PCSIS_INTSRC 0x14
|
||||
#define S5PCSIS_INTSRC_EVEN_BEFORE (1 << 31)
|
||||
#define S5PCSIS_INTSRC_EVEN_BEFORE (1UL << 31)
|
||||
#define S5PCSIS_INTSRC_EVEN_AFTER (1 << 30)
|
||||
#define S5PCSIS_INTSRC_EVEN (0x3 << 30)
|
||||
#define S5PCSIS_INTSRC_ODD_BEFORE (1 << 29)
|
||||
|
@ -214,7 +214,7 @@ enum status_config {
|
||||
FIELD_NO = 0x01 << 28, /* Field number */
|
||||
DITHER_ON = 0x01 << 29, /* Dithering is on */
|
||||
ROUND_ON = 0x01 << 30, /* Round is on */
|
||||
MODE_32BIT = 0x01 << 31, /* Data in RGBa888,
|
||||
MODE_32BIT = 1UL << 31, /* Data in RGBa888,
|
||||
* 0 in RGB565
|
||||
*/
|
||||
};
|
||||
|
@ -120,7 +120,7 @@ module_param(debug, bool, 0644);
|
||||
#define PRP_CNTL_RZ_FIFO_LEVEL(x) ((x) << 27)
|
||||
#define PRP_CNTL_CH2B1EN (1 << 29)
|
||||
#define PRP_CNTL_CH2B2EN (1 << 30)
|
||||
#define PRP_CNTL_CH2FEN (1 << 31)
|
||||
#define PRP_CNTL_CH2FEN (1UL << 31)
|
||||
|
||||
#define PRP_SIZE_HEIGHT(x) (x)
|
||||
#define PRP_SIZE_WIDTH(x) ((x) << 16)
|
||||
|
@ -64,7 +64,7 @@
|
||||
#define CIBR1 0x0030
|
||||
#define CIBR2 0x0038
|
||||
|
||||
#define CICR0_DMAEN (1 << 31) /* DMA request enable */
|
||||
#define CICR0_DMAEN (1UL << 31) /* DMA request enable */
|
||||
#define CICR0_PAR_EN (1 << 30) /* Parity enable */
|
||||
#define CICR0_SL_CAP_EN (1 << 29) /* Capture enable for slave mode */
|
||||
#define CICR0_ENB (1 << 28) /* Camera interface enable */
|
||||
@ -81,7 +81,7 @@
|
||||
#define CICR0_EOFM (1 << 1) /* End-of-frame mask */
|
||||
#define CICR0_FOM (1 << 0) /* FIFO-overrun mask */
|
||||
|
||||
#define CICR1_TBIT (1 << 31) /* Transparency bit */
|
||||
#define CICR1_TBIT (1UL << 31) /* Transparency bit */
|
||||
#define CICR1_RGBT_CONV (0x3 << 29) /* RGBT conversion mask */
|
||||
#define CICR1_PPL (0x7ff << 15) /* Pixels per line mask */
|
||||
#define CICR1_RGB_CONV (0x7 << 12) /* RGB conversion mask */
|
||||
|
@ -198,7 +198,7 @@ static int venus_enumerate_codecs(struct venus_core *core, u32 type)
|
||||
goto err;
|
||||
|
||||
for (i = 0; i < MAX_CODEC_NUM; i++) {
|
||||
codec = (1 << i) & codecs;
|
||||
codec = (1UL << i) & codecs;
|
||||
if (!codec)
|
||||
continue;
|
||||
|
||||
|
@ -121,14 +121,14 @@
|
||||
|
||||
/* JPEG timer setting register */
|
||||
#define S5P_JPG_TIMER_SE 0x7c
|
||||
#define S5P_TIMER_INT_EN_MASK (0x1 << 31)
|
||||
#define S5P_TIMER_INT_EN (0x1 << 31)
|
||||
#define S5P_TIMER_INT_EN_MASK (0x1UL << 31)
|
||||
#define S5P_TIMER_INT_EN (0x1UL << 31)
|
||||
#define S5P_TIMER_INIT_MASK 0x7fffffff
|
||||
|
||||
/* JPEG timer status register */
|
||||
#define S5P_JPG_TIMER_ST 0x80
|
||||
#define S5P_TIMER_INT_STAT_SHIFT 31
|
||||
#define S5P_TIMER_INT_STAT_MASK (0x1 << S5P_TIMER_INT_STAT_SHIFT)
|
||||
#define S5P_TIMER_INT_STAT_MASK (0x1UL << S5P_TIMER_INT_STAT_SHIFT)
|
||||
#define S5P_TIMER_CNT_SHIFT 0
|
||||
#define S5P_TIMER_CNT_MASK 0x7fffffff
|
||||
|
||||
@ -562,13 +562,13 @@
|
||||
/* JPEG timer setting register */
|
||||
#define EXYNOS3250_TIMER_SE 0x148
|
||||
#define EXYNOS3250_TIMER_INT_EN_SHIFT 31
|
||||
#define EXYNOS3250_TIMER_INT_EN (1 << EXYNOS3250_TIMER_INT_EN_SHIFT)
|
||||
#define EXYNOS3250_TIMER_INT_EN (1UL << EXYNOS3250_TIMER_INT_EN_SHIFT)
|
||||
#define EXYNOS3250_TIMER_INIT_MASK 0x7fffffff
|
||||
|
||||
/* JPEG timer status register */
|
||||
#define EXYNOS3250_TIMER_ST 0x14c
|
||||
#define EXYNOS3250_TIMER_INT_STAT_SHIFT 31
|
||||
#define EXYNOS3250_TIMER_INT_STAT (1 << EXYNOS3250_TIMER_INT_STAT_SHIFT)
|
||||
#define EXYNOS3250_TIMER_INT_STAT (1UL << EXYNOS3250_TIMER_INT_STAT_SHIFT)
|
||||
#define EXYNOS3250_TIMER_CNT_SHIFT 0
|
||||
#define EXYNOS3250_TIMER_CNT_MASK 0x7fffffff
|
||||
|
||||
|
@ -711,7 +711,7 @@ static int s5p_mfc_set_enc_params(struct s5p_mfc_ctx *ctx)
|
||||
reg = mfc_read(dev, S5P_FIMV_ENC_PADDING_CTRL);
|
||||
if (p->pad) {
|
||||
/** enable */
|
||||
reg |= (1 << 31);
|
||||
reg |= (1UL << 31);
|
||||
/** cr value */
|
||||
reg &= ~(0xFF << 16);
|
||||
reg |= (p->pad_cr << 16);
|
||||
@ -955,7 +955,7 @@ static int s5p_mfc_set_enc_params_mpeg4(struct s5p_mfc_ctx *ctx)
|
||||
S5P_FIMV_ENC_RC_FRAME_RATE);
|
||||
shm = s5p_mfc_read_info_v5(ctx, RC_VOP_TIMING);
|
||||
shm &= ~(0xFFFFFFFF);
|
||||
shm |= (1 << 31);
|
||||
shm |= (1UL << 31);
|
||||
shm |= ((p->rc_framerate_num & 0x7FFF) << 16);
|
||||
shm |= (p->rc_framerate_denom & 0xFFFF);
|
||||
s5p_mfc_write_info_v5(ctx, shm, RC_VOP_TIMING);
|
||||
|
@ -840,7 +840,7 @@ static int s5p_mfc_set_enc_params(struct s5p_mfc_ctx *ctx)
|
||||
if (p->pad) {
|
||||
reg = 0;
|
||||
/** enable */
|
||||
reg |= (1 << 31);
|
||||
reg |= (1UL << 31);
|
||||
/** cr value */
|
||||
reg |= ((p->pad_cr & 0xFF) << 16);
|
||||
/** cb value */
|
||||
|
@ -125,7 +125,7 @@ struct gemtek {
|
||||
#define BU2614_FMUN_SHIFT (BU2614_VOID2_BITS + BU2614_VOID2_SHIFT)
|
||||
#define BU2614_TEST_SHIFT (BU2614_FMUN_BITS + BU2614_FMUN_SHIFT)
|
||||
|
||||
#define MKMASK(field) (((1<<BU2614_##field##_BITS) - 1) << \
|
||||
#define MKMASK(field) (((1UL<<BU2614_##field##_BITS) - 1) << \
|
||||
BU2614_##field##_SHIFT)
|
||||
#define BU2614_PORT_MASK MKMASK(PORT)
|
||||
#define BU2614_FREQ_MASK MKMASK(FREQ)
|
||||
|
@ -353,7 +353,7 @@ static int friio_ext_ctl(struct dvb_usb_device *d,
|
||||
ret += i2c_transfer(&d->i2c_adap, &msg, 1);
|
||||
|
||||
/* send 32bit(satur, R, G, B) data in serial */
|
||||
mask = 1 << 31;
|
||||
mask = 1UL << 31;
|
||||
for (i = 0; i < 32; i++) {
|
||||
buf[1] = power | FRIIO_CTL_STROBE;
|
||||
if (sat_color & mask)
|
||||
|
@ -660,7 +660,7 @@ static int ctrl_check_input(struct pvr2_ctrl *cptr,int v)
|
||||
{
|
||||
if (v < 0 || v > PVR2_CVAL_INPUT_MAX)
|
||||
return 0;
|
||||
return ((1 << v) & cptr->hdw->input_allowed_mask) != 0;
|
||||
return ((1UL << v) & cptr->hdw->input_allowed_mask) != 0;
|
||||
}
|
||||
|
||||
static int ctrl_set_input(struct pvr2_ctrl *cptr,int m,int v)
|
||||
@ -2445,7 +2445,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
|
||||
/* Ensure that default input choice is a valid one. */
|
||||
m = hdw->input_avail_mask;
|
||||
if (m) for (idx = 0; idx < (sizeof(m) << 3); idx++) {
|
||||
if (!((1 << idx) & m)) continue;
|
||||
if (!((1UL << idx) & m)) continue;
|
||||
hdw->input_val = idx;
|
||||
break;
|
||||
}
|
||||
@ -2501,11 +2501,11 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
|
||||
// Initialize control data regarding video standard masks
|
||||
valid_std_mask = pvr2_std_get_usable();
|
||||
for (idx = 0; idx < 32; idx++) {
|
||||
if (!(valid_std_mask & (1 << idx))) continue;
|
||||
if (!(valid_std_mask & (1UL << idx))) continue;
|
||||
cnt1 = pvr2_std_id_to_str(
|
||||
hdw->std_mask_names[idx],
|
||||
sizeof(hdw->std_mask_names[idx])-1,
|
||||
1 << idx);
|
||||
1UL << idx);
|
||||
hdw->std_mask_names[idx][cnt1] = 0;
|
||||
}
|
||||
cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDAVAIL);
|
||||
@ -4672,7 +4672,7 @@ static unsigned int print_input_mask(unsigned int msk,
|
||||
unsigned int idx,ccnt;
|
||||
unsigned int tcnt = 0;
|
||||
for (idx = 0; idx < ARRAY_SIZE(control_values_input); idx++) {
|
||||
if (!((1 << idx) & msk)) continue;
|
||||
if (!((1UL << idx) & msk)) continue;
|
||||
ccnt = scnprintf(buf+tcnt,
|
||||
acnt-tcnt,
|
||||
"%s%s",
|
||||
@ -5099,7 +5099,7 @@ int pvr2_hdw_set_input_allowed(struct pvr2_hdw *hdw,
|
||||
break;
|
||||
}
|
||||
hdw->input_allowed_mask = nv;
|
||||
if ((1 << hdw->input_val) & hdw->input_allowed_mask) {
|
||||
if ((1UL << hdw->input_val) & hdw->input_allowed_mask) {
|
||||
/* Current mode is still in the allowed mask, so
|
||||
we're done. */
|
||||
break;
|
||||
@ -5112,7 +5112,7 @@ int pvr2_hdw_set_input_allowed(struct pvr2_hdw *hdw,
|
||||
}
|
||||
m = hdw->input_allowed_mask;
|
||||
for (idx = 0; idx < (sizeof(m) << 3); idx++) {
|
||||
if (!((1 << idx) & m)) continue;
|
||||
if (!((1UL << idx) & m)) continue;
|
||||
pvr2_hdw_set_input(hdw,idx);
|
||||
break;
|
||||
}
|
||||
|
@ -1003,7 +1003,7 @@ static int pvr2_v4l2_open(struct file *file)
|
||||
input_mask &= pvr2_hdw_get_input_available(hdw);
|
||||
input_cnt = 0;
|
||||
for (idx = 0; idx < (sizeof(input_mask) << 3); idx++) {
|
||||
if (input_mask & (1 << idx)) input_cnt++;
|
||||
if (input_mask & (1UL << idx)) input_cnt++;
|
||||
}
|
||||
fhp->input_cnt = input_cnt;
|
||||
fhp->input_map = kzalloc(input_cnt,GFP_KERNEL);
|
||||
@ -1018,7 +1018,7 @@ static int pvr2_v4l2_open(struct file *file)
|
||||
}
|
||||
input_cnt = 0;
|
||||
for (idx = 0; idx < (sizeof(input_mask) << 3); idx++) {
|
||||
if (!(input_mask & (1 << idx))) continue;
|
||||
if (!(input_mask & (1UL << idx))) continue;
|
||||
fhp->input_map[input_cnt++] = idx;
|
||||
}
|
||||
|
||||
|
@ -1388,7 +1388,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
|
||||
(char)((fmt->pixelformat >> 8) & 0x7f),
|
||||
(char)((fmt->pixelformat >> 16) & 0x7f),
|
||||
(char)((fmt->pixelformat >> 24) & 0x7f),
|
||||
(fmt->pixelformat & (1 << 31)) ? "-BE" : "");
|
||||
(fmt->pixelformat & (1UL << 31)) ? "-BE" : "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user