Commit 27c7b710 authored by Mike Isely's avatar Mike Isely Committed by Mauro Carvalho Chehab

V4L/DVB (5092): Pvrusb2: Use ARRAY_SIZE wherever possible

Signed-off-by: default avatarMike Isely <isely@pobox.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent ca545f7c
...@@ -98,8 +98,7 @@ static int msp3400_check(struct pvr2_msp3400_handler *ctxt) ...@@ -98,8 +98,7 @@ static int msp3400_check(struct pvr2_msp3400_handler *ctxt)
unsigned long msk; unsigned long msk;
unsigned int idx; unsigned int idx;
for (idx = 0; idx < sizeof(msp3400_ops)/sizeof(msp3400_ops[0]); for (idx = 0; idx < ARRAY_SIZE(msp3400_ops); idx++) {
idx++) {
msk = 1 << idx; msk = 1 << idx;
if (ctxt->stale_mask & msk) continue; if (ctxt->stale_mask & msk) continue;
if (msp3400_ops[idx].check(ctxt)) { if (msp3400_ops[idx].check(ctxt)) {
...@@ -115,8 +114,7 @@ static void msp3400_update(struct pvr2_msp3400_handler *ctxt) ...@@ -115,8 +114,7 @@ static void msp3400_update(struct pvr2_msp3400_handler *ctxt)
unsigned long msk; unsigned long msk;
unsigned int idx; unsigned int idx;
for (idx = 0; idx < sizeof(msp3400_ops)/sizeof(msp3400_ops[0]); for (idx = 0; idx < ARRAY_SIZE(msp3400_ops); idx++) {
idx++) {
msk = 1 << idx; msk = 1 << idx;
if (!(ctxt->stale_mask & msk)) continue; if (!(ctxt->stale_mask & msk)) continue;
ctxt->stale_mask &= ~msk; ctxt->stale_mask &= ~msk;
...@@ -159,8 +157,7 @@ int pvr2_i2c_msp3400_setup(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp) ...@@ -159,8 +157,7 @@ int pvr2_i2c_msp3400_setup(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
ctxt->i2c_handler.func_table = &msp3400_funcs; ctxt->i2c_handler.func_table = &msp3400_funcs;
ctxt->client = cp; ctxt->client = cp;
ctxt->hdw = hdw; ctxt->hdw = hdw;
ctxt->stale_mask = (1 << (sizeof(msp3400_ops)/ ctxt->stale_mask = (1 << ARRAY_SIZE(msp3400_ops)) - 1;
sizeof(msp3400_ops[0]))) - 1;
cp->handler = &ctxt->i2c_handler; cp->handler = &ctxt->i2c_handler;
pvr2_trace(PVR2_TRACE_CHIPS,"i2c 0x%x msp3400 V4L2 handler set up", pvr2_trace(PVR2_TRACE_CHIPS,"i2c 0x%x msp3400 V4L2 handler set up",
cp->client->addr); cp->client->addr);
......
...@@ -515,9 +515,8 @@ int pvr2_ctrl_sym_to_value(struct pvr2_ctrl *cptr, ...@@ -515,9 +515,8 @@ int pvr2_ctrl_sym_to_value(struct pvr2_ctrl *cptr,
} }
if (maskptr) *maskptr = ~0; if (maskptr) *maskptr = ~0;
} else if (cptr->info->type == pvr2_ctl_bool) { } else if (cptr->info->type == pvr2_ctl_bool) {
ret = parse_token( ret = parse_token(ptr,len,valptr,boolNames,
ptr,len,valptr,boolNames, ARRAY_SIZE(boolNames));
sizeof(boolNames)/sizeof(boolNames[0]));
if (ret == 1) { if (ret == 1) {
*valptr = *valptr ? !0 : 0; *valptr = *valptr ? !0 : 0;
} else if (ret == 0) { } else if (ret == 0) {
......
...@@ -150,8 +150,7 @@ static int decoder_check(struct pvr2_v4l_cx2584x *ctxt) ...@@ -150,8 +150,7 @@ static int decoder_check(struct pvr2_v4l_cx2584x *ctxt)
unsigned long msk; unsigned long msk;
unsigned int idx; unsigned int idx;
for (idx = 0; idx < sizeof(decoder_ops)/sizeof(decoder_ops[0]); for (idx = 0; idx < ARRAY_SIZE(decoder_ops); idx++) {
idx++) {
msk = 1 << idx; msk = 1 << idx;
if (ctxt->stale_mask & msk) continue; if (ctxt->stale_mask & msk) continue;
if (decoder_ops[idx].check(ctxt)) { if (decoder_ops[idx].check(ctxt)) {
...@@ -167,8 +166,7 @@ static void decoder_update(struct pvr2_v4l_cx2584x *ctxt) ...@@ -167,8 +166,7 @@ static void decoder_update(struct pvr2_v4l_cx2584x *ctxt)
unsigned long msk; unsigned long msk;
unsigned int idx; unsigned int idx;
for (idx = 0; idx < sizeof(decoder_ops)/sizeof(decoder_ops[0]); for (idx = 0; idx < ARRAY_SIZE(decoder_ops); idx++) {
idx++) {
msk = 1 << idx; msk = 1 << idx;
if (!(ctxt->stale_mask & msk)) continue; if (!(ctxt->stale_mask & msk)) continue;
ctxt->stale_mask &= ~msk; ctxt->stale_mask &= ~msk;
...@@ -242,8 +240,7 @@ int pvr2_i2c_cx2584x_v4l_setup(struct pvr2_hdw *hdw, ...@@ -242,8 +240,7 @@ int pvr2_i2c_cx2584x_v4l_setup(struct pvr2_hdw *hdw,
ctxt->ctrl.force_reset = (void (*)(void*))decoder_reset; ctxt->ctrl.force_reset = (void (*)(void*))decoder_reset;
ctxt->client = cp; ctxt->client = cp;
ctxt->hdw = hdw; ctxt->hdw = hdw;
ctxt->stale_mask = (1 << (sizeof(decoder_ops)/ ctxt->stale_mask = (1 << ARRAY_SIZE(decoder_ops)) - 1;
sizeof(decoder_ops[0]))) - 1;
hdw->decoder_ctrl = &ctxt->ctrl; hdw->decoder_ctrl = &ctxt->ctrl;
cp->handler = &ctxt->handler; cp->handler = &ctxt->handler;
{ {
......
...@@ -152,7 +152,7 @@ static unsigned long debugifc_find_mask(const char *buf,unsigned int count) ...@@ -152,7 +152,7 @@ static unsigned long debugifc_find_mask(const char *buf,unsigned int count)
{ {
struct debugifc_mask_item *mip; struct debugifc_mask_item *mip;
unsigned int idx; unsigned int idx;
for (idx = 0; idx < sizeof(mask_items)/sizeof(mask_items[0]); idx++) { for (idx = 0; idx < ARRAY_SIZE(mask_items); idx++) {
mip = mask_items + idx; mip = mask_items + idx;
if (debugifc_match_keyword(buf,count,mip->name)) { if (debugifc_match_keyword(buf,count,mip->name)) {
return mip->msk; return mip->msk;
...@@ -169,7 +169,7 @@ static int debugifc_print_mask(char *buf,unsigned int sz, ...@@ -169,7 +169,7 @@ static int debugifc_print_mask(char *buf,unsigned int sz,
unsigned int idx; unsigned int idx;
int bcnt = 0; int bcnt = 0;
int ccnt; int ccnt;
for (idx = 0; idx < sizeof(mask_items)/sizeof(mask_items[0]); idx++) { for (idx = 0; idx < ARRAY_SIZE(mask_items); idx++) {
mip = mask_items + idx; mip = mask_items + idx;
if (!(mip->msk & msk)) continue; if (!(mip->msk & msk)) continue;
ccnt = scnprintf(buf,sz,"%s%c%s", ccnt = scnprintf(buf,sz,"%s%c%s",
......
...@@ -102,9 +102,8 @@ static u8 *pvr2_eeprom_fetch(struct pvr2_hdw *hdw) ...@@ -102,9 +102,8 @@ static u8 *pvr2_eeprom_fetch(struct pvr2_hdw *hdw)
} }
msg[1].len = pcnt; msg[1].len = pcnt;
msg[1].buf = eeprom+tcnt; msg[1].buf = eeprom+tcnt;
if ((ret = i2c_transfer( if ((ret = i2c_transfer(&hdw->i2c_adap,
&hdw->i2c_adap, msg,ARRAY_SIZE(msg))) != 2) {
msg,sizeof(msg)/sizeof(msg[0]))) != 2) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS, pvr2_trace(PVR2_TRACE_ERROR_LEGS,
"eeprom fetch set offs err=%d",ret); "eeprom fetch set offs err=%d",ret);
kfree(eeprom); kfree(eeprom);
......
...@@ -723,7 +723,7 @@ static void ctrl_stdenumcur_clear_dirty(struct pvr2_ctrl *cptr) ...@@ -723,7 +723,7 @@ static void ctrl_stdenumcur_clear_dirty(struct pvr2_ctrl *cptr)
#define DEFENUM(tab) \ #define DEFENUM(tab) \
.type = pvr2_ctl_enum, \ .type = pvr2_ctl_enum, \
.def.type_enum.count = (sizeof(tab)/sizeof((tab)[0])), \ .def.type_enum.count = ARRAY_SIZE(tab), \
.def.type_enum.value_names = tab .def.type_enum.value_names = tab
#define DEFBOOL \ #define DEFBOOL \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment