Skip to content

Commit b3beeee

Browse files
dpenklergregkh
authored andcommitted
staging: gpib: Avoid plain integers as NULL pointers
A number of drivers were comparing request_region() with 0, others were passing 0 instead of NULL as a pointer argument. This led to the following sparse warning, for example: cb7210/cb7210.c:1043:72: warning: Using plain integer as NULL pointer Use !request_region() to test for NULL return and use NULL instead of 0 as pointer parameter. Signed-off-by: Dave Penkler <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8e7ff4e commit b3beeee

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

drivers/staging/gpib/cb7210/cb7210.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ int cb_isa_attach(gpib_board_t *board, const gpib_board_config_t *config)
10401040
return retval;
10411041
cb_priv = board->private_data;
10421042
nec_priv = &cb_priv->nec7210_priv;
1043-
if (request_region(config->ibbase, cb7210_iosize, "cb7210") == 0) {
1043+
if (!request_region(config->ibbase, cb7210_iosize, "cb7210")) {
10441044
pr_err("gpib: ioports starting at 0x%u are already in use\n", config->ibbase);
10451045
return -EIO;
10461046
}
@@ -1459,8 +1459,8 @@ int cb_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config)
14591459
cb_priv = board->private_data;
14601460
nec_priv = &cb_priv->nec7210_priv;
14611461

1462-
if (request_region(curr_dev->resource[0]->start, resource_size(curr_dev->resource[0]),
1463-
"cb7210") == 0) {
1462+
if (!request_region(curr_dev->resource[0]->start, resource_size(curr_dev->resource[0]),
1463+
"cb7210")) {
14641464
pr_err("gpib: ioports starting at 0x%lx are already in use\n",
14651465
(unsigned long)curr_dev->resource[0]->start);
14661466
return -EIO;

drivers/staging/gpib/common/gpib_os.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2197,7 +2197,7 @@ static int __init gpib_common_init_module(void)
21972197
return PTR_ERR(gpib_class);
21982198
}
21992199
for (i = 0; i < GPIB_MAX_NUM_BOARDS; ++i)
2200-
board_array[i].gpib_dev = device_create(gpib_class, 0,
2200+
board_array[i].gpib_dev = device_create(gpib_class, NULL,
22012201
MKDEV(GPIB_CODE, i), NULL, "gpib%i", i);
22022202

22032203
return 0;

drivers/staging/gpib/common/iblib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ int ibwait(gpib_board_t *board, int wait_mask, int clear_mask, int set_mask,
695695

696696
/* make sure we only clear status bits that we are reporting */
697697
if (*status & clear_mask || set_mask)
698-
general_ibstatus(board, status_queue, *status & clear_mask, set_mask, 0);
698+
general_ibstatus(board, status_queue, *status & clear_mask, set_mask, NULL);
699699

700700
return 0;
701701
}

drivers/staging/gpib/gpio/gpib_bitbang.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ static struct gpiod_lookup_table gpib_gpio_table_0 = {
265265
static struct gpiod_lookup_table *lookup_tables[] = {
266266
&gpib_gpio_table_0,
267267
&gpib_gpio_table_1,
268-
0
268+
NULL
269269
};
270270

271271
/* struct which defines private_data for gpio driver */
@@ -1119,7 +1119,7 @@ static void release_gpios(void)
11191119
for (j = 0 ; j < NUM_PINS ; j++) {
11201120
if (all_descriptors[j]) {
11211121
gpiod_put(all_descriptors[j]);
1122-
all_descriptors[j] = 0;
1122+
all_descriptors[j] = NULL;
11231123
}
11241124
}
11251125
}

drivers/staging/gpib/ines/ines_gpib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,8 +1342,8 @@ int ines_common_pcmcia_attach(gpib_board_t *board)
13421342
ines_priv = board->private_data;
13431343
nec_priv = &ines_priv->nec7210_priv;
13441344

1345-
if (request_region(curr_dev->resource[0]->start,
1346-
resource_size(curr_dev->resource[0]), "ines_gpib") == 0) {
1345+
if (!request_region(curr_dev->resource[0]->start,
1346+
resource_size(curr_dev->resource[0]), "ines_gpib")) {
13471347
pr_err("ines_gpib: ioports at 0x%lx already in use\n",
13481348
(unsigned long)(curr_dev->resource[0]->start));
13491349
return -1;

drivers/staging/gpib/pc2/pc2_gpib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ int pc2_attach(gpib_board_t *board, const gpib_board_config_t *config)
426426
nec_priv = &pc2_priv->nec7210_priv;
427427
nec_priv->offset = pc2_reg_offset;
428428

429-
if (request_region(config->ibbase, pc2_iosize, "pc2") == 0) {
429+
if (!request_region(config->ibbase, pc2_iosize, "pc2")) {
430430
pr_err("gpib: ioports are already in use\n");
431431
return -1;
432432
}

drivers/staging/gpib/tnt4882/tnt4882_gpib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,8 +1896,8 @@ int ni_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config)
18961896
nec_priv->offset = atgpib_reg_offset;
18971897

18981898
DEBUG(0, "ioport1 window attributes: 0x%lx\n", curr_dev->resource[0]->flags);
1899-
if (request_region(curr_dev->resource[0]->start, resource_size(curr_dev->resource[0]),
1900-
"tnt4882") == 0) {
1899+
if (!request_region(curr_dev->resource[0]->start, resource_size(curr_dev->resource[0]),
1900+
"tnt4882")) {
19011901
pr_err("gpib: ioports starting at 0x%lx are already in use\n",
19021902
(unsigned long)curr_dev->resource[0]->start);
19031903
return -EIO;

0 commit comments

Comments
 (0)