Skip to content

Commit

Permalink
Input: drivers/joystick - fix various sparse warnings
Browse files Browse the repository at this point in the history
Fix various issues pointed by sparse:
 - module_param_array_named() takes unsigned int as number
   of parameters argument
 - shadowing of global variables is not healthy. I think there was
   once a bug in db9 caused by it.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
  • Loading branch information
Dmitry Torokhov committed May 3, 2007
1 parent dec3eb0 commit 7816723
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion drivers/input/joystick/analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ MODULE_LICENSE("GPL");
#define ANALOG_PORTS 16

static char *js[ANALOG_PORTS];
static int js_nargs;
static unsigned int js_nargs;
static int analog_options[ANALOG_PORTS];
module_param_array_named(map, js, charp, &js_nargs, 0);
MODULE_PARM_DESC(map, "Describes analog joysticks type/capabilities");
Expand Down
18 changes: 9 additions & 9 deletions drivers/input/joystick/db9.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ MODULE_LICENSE("GPL");

struct db9_config {
int args[2];
int nargs;
unsigned int nargs;
};

#define DB9_MAX_PORTS 3
static struct db9_config db9[DB9_MAX_PORTS] __initdata;
static struct db9_config db9_cfg[DB9_MAX_PORTS] __initdata;

module_param_array_named(dev, db9[0].args, int, &db9[0].nargs, 0);
module_param_array_named(dev, db9_cfg[0].args, int, &db9_cfg[0].nargs, 0);
MODULE_PARM_DESC(dev, "Describes first attached device (<parport#>,<type>)");
module_param_array_named(dev2, db9[1].args, int, &db9[0].nargs, 0);
module_param_array_named(dev2, db9_cfg[1].args, int, &db9_cfg[0].nargs, 0);
MODULE_PARM_DESC(dev2, "Describes second attached device (<parport#>,<type>)");
module_param_array_named(dev3, db9[2].args, int, &db9[2].nargs, 0);
module_param_array_named(dev3, db9_cfg[2].args, int, &db9_cfg[2].nargs, 0);
MODULE_PARM_DESC(dev3, "Describes third attached device (<parport#>,<type>)");

#define DB9_ARG_PARPORT 0
Expand Down Expand Up @@ -680,17 +680,17 @@ static int __init db9_init(void)
int err = 0;

for (i = 0; i < DB9_MAX_PORTS; i++) {
if (db9[i].nargs == 0 || db9[i].args[DB9_ARG_PARPORT] < 0)
if (db9_cfg[i].nargs == 0 || db9_cfg[i].args[DB9_ARG_PARPORT] < 0)
continue;

if (db9[i].nargs < 2) {
if (db9_cfg[i].nargs < 2) {
printk(KERN_ERR "db9.c: Device type must be specified.\n");
err = -EINVAL;
break;
}

db9_base[i] = db9_probe(db9[i].args[DB9_ARG_PARPORT],
db9[i].args[DB9_ARG_MODE]);
db9_base[i] = db9_probe(db9_cfg[i].args[DB9_ARG_PARPORT],
db9_cfg[i].args[DB9_ARG_MODE]);
if (IS_ERR(db9_base[i])) {
err = PTR_ERR(db9_base[i]);
break;
Expand Down
17 changes: 9 additions & 8 deletions drivers/input/joystick/gamecon.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ MODULE_LICENSE("GPL");

struct gc_config {
int args[GC_MAX_DEVICES + 1];
int nargs;
unsigned int nargs;
};

static struct gc_config gc[GC_MAX_PORTS] __initdata;
static struct gc_config gc_cfg[GC_MAX_PORTS] __initdata;

module_param_array_named(map, gc[0].args, int, &gc[0].nargs, 0);
module_param_array_named(map, gc_cfg[0].args, int, &gc_cfg[0].nargs, 0);
MODULE_PARM_DESC(map, "Describes first set of devices (<parport#>,<pad1>,<pad2>,..<pad5>)");
module_param_array_named(map2, gc[1].args, int, &gc[1].nargs, 0);
module_param_array_named(map2, gc_cfg[1].args, int, &gc_cfg[1].nargs, 0);
MODULE_PARM_DESC(map2, "Describes second set of devices");
module_param_array_named(map3, gc[2].args, int, &gc[2].nargs, 0);
module_param_array_named(map3, gc_cfg[2].args, int, &gc_cfg[2].nargs, 0);
MODULE_PARM_DESC(map3, "Describes third set of devices");

/* see also gs_psx_delay parameter in PSX support section */
Expand Down Expand Up @@ -810,16 +810,17 @@ static int __init gc_init(void)
int err = 0;

for (i = 0; i < GC_MAX_PORTS; i++) {
if (gc[i].nargs == 0 || gc[i].args[0] < 0)
if (gc_cfg[i].nargs == 0 || gc_cfg[i].args[0] < 0)
continue;

if (gc[i].nargs < 2) {
if (gc_cfg[i].nargs < 2) {
printk(KERN_ERR "gamecon.c: at least one device must be specified\n");
err = -EINVAL;
break;
}

gc_base[i] = gc_probe(gc[i].args[0], gc[i].args + 1, gc[i].nargs - 1);
gc_base[i] = gc_probe(gc_cfg[i].args[0],
gc_cfg[i].args + 1, gc_cfg[i].nargs - 1);
if (IS_ERR(gc_base[i])) {
err = PTR_ERR(gc_base[i]);
break;
Expand Down
2 changes: 1 addition & 1 deletion drivers/input/joystick/iforce/iforce.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ struct iforce {
/* Buffer used for asynchronous sending of bytes to the device */
struct circ_buf xmit;
unsigned char xmit_data[XMIT_SIZE];
long xmit_flags[1];
unsigned long xmit_flags[1];

/* Force Feedback */
wait_queue_head_t wait;
Expand Down
18 changes: 10 additions & 8 deletions drivers/input/joystick/turbografx.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ MODULE_LICENSE("GPL");

struct tgfx_config {
int args[TGFX_MAX_DEVICES + 1];
int nargs;
unsigned int nargs;
};

static struct tgfx_config tgfx[TGFX_MAX_PORTS] __initdata;
static struct tgfx_config tgfx_cfg[TGFX_MAX_PORTS] __initdata;

module_param_array_named(map, tgfx[0].args, int, &tgfx[0].nargs, 0);
module_param_array_named(map, tgfx_cfg[0].args, int, &tgfx_cfg[0].nargs, 0);
MODULE_PARM_DESC(map, "Describes first set of devices (<parport#>,<js1>,<js2>,..<js7>");
module_param_array_named(map2, tgfx[1].args, int, &tgfx[1].nargs, 0);
module_param_array_named(map2, tgfx_cfg[1].args, int, &tgfx_cfg[1].nargs, 0);
MODULE_PARM_DESC(map2, "Describes second set of devices");
module_param_array_named(map3, tgfx[2].args, int, &tgfx[2].nargs, 0);
module_param_array_named(map3, tgfx_cfg[2].args, int, &tgfx_cfg[2].nargs, 0);
MODULE_PARM_DESC(map3, "Describes third set of devices");

#define TGFX_REFRESH_TIME HZ/100 /* 10 ms */
Expand Down Expand Up @@ -283,16 +283,18 @@ static int __init tgfx_init(void)
int err = 0;

for (i = 0; i < TGFX_MAX_PORTS; i++) {
if (tgfx[i].nargs == 0 || tgfx[i].args[0] < 0)
if (tgfx_cfg[i].nargs == 0 || tgfx_cfg[i].args[0] < 0)
continue;

if (tgfx[i].nargs < 2) {
if (tgfx_cfg[i].nargs < 2) {
printk(KERN_ERR "turbografx.c: at least one joystick must be specified\n");
err = -EINVAL;
break;
}

tgfx_base[i] = tgfx_probe(tgfx[i].args[0], tgfx[i].args + 1, tgfx[i].nargs - 1);
tgfx_base[i] = tgfx_probe(tgfx_cfg[i].args[0],
tgfx_cfg[i].args + 1,
tgfx_cfg[i].nargs - 1);
if (IS_ERR(tgfx_base[i])) {
err = PTR_ERR(tgfx_base[i]);
break;
Expand Down

0 comments on commit 7816723

Please sign in to comment.