]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
staging: gpib: Avoid plain integers as NULL pointers
authorDave Penkler <dpenkler@gmail.com>
Tue, 14 Jan 2025 16:54:02 +0000 (17:54 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Jan 2025 17:35:57 +0000 (18:35 +0100)
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 <dpenkler@gmail.com>
Link: https://lore.kernel.org/r/20250114165403.16410-4-dpenkler@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/gpib/cb7210/cb7210.c
drivers/staging/gpib/common/gpib_os.c
drivers/staging/gpib/common/iblib.c
drivers/staging/gpib/gpio/gpib_bitbang.c
drivers/staging/gpib/ines/ines_gpib.c
drivers/staging/gpib/pc2/pc2_gpib.c
drivers/staging/gpib/tnt4882/tnt4882_gpib.c

index e5436f55c630f89c325f5fac29a07f223ed3f91d..ae373005389b3cca5caa2d96461a2646b57a07bd 100644 (file)
@@ -1040,7 +1040,7 @@ int cb_isa_attach(gpib_board_t *board, const gpib_board_config_t *config)
                return retval;
        cb_priv = board->private_data;
        nec_priv = &cb_priv->nec7210_priv;
-       if (request_region(config->ibbase, cb7210_iosize, "cb7210") == 0) {
+       if (!request_region(config->ibbase, cb7210_iosize, "cb7210")) {
                pr_err("gpib: ioports starting at 0x%u are already in use\n", config->ibbase);
                return -EIO;
        }
@@ -1459,8 +1459,8 @@ int cb_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config)
        cb_priv = board->private_data;
        nec_priv = &cb_priv->nec7210_priv;
 
-       if (request_region(curr_dev->resource[0]->start, resource_size(curr_dev->resource[0]),
-                          "cb7210") == 0)      {
+       if (!request_region(curr_dev->resource[0]->start, resource_size(curr_dev->resource[0]),
+                           "cb7210"))  {
                pr_err("gpib: ioports starting at 0x%lx are already in use\n",
                       (unsigned long)curr_dev->resource[0]->start);
                return -EIO;
index 69fe39aa0dafcc8eb8a1511da1b0a84a5c720ab9..3234d434895727d71698f66b694310bbb509de7b 100644 (file)
@@ -2197,7 +2197,7 @@ static int __init gpib_common_init_module(void)
                return PTR_ERR(gpib_class);
        }
        for (i = 0; i < GPIB_MAX_NUM_BOARDS; ++i)
-               board_array[i].gpib_dev = device_create(gpib_class, 0,
+               board_array[i].gpib_dev = device_create(gpib_class, NULL,
                                                        MKDEV(GPIB_CODE, i), NULL, "gpib%i", i);
 
        return 0;
index db1911cc1b263836484f3e37e0e102745e7c3ce7..5f6fa135f5057b88f5130638b2c5447bbcbef471 100644 (file)
@@ -695,7 +695,7 @@ int ibwait(gpib_board_t *board, int wait_mask, int clear_mask, int set_mask,
 
        /* make sure we only clear status bits that we are reporting */
        if (*status & clear_mask || set_mask)
-               general_ibstatus(board, status_queue, *status & clear_mask, set_mask, 0);
+               general_ibstatus(board, status_queue, *status & clear_mask, set_mask, NULL);
 
        return 0;
 }
index ad49a5644ab887e4908f5b31250b7b6b13608e59..16e2d0c5642e887b4e3647b7913965fdb33d7fc2 100644 (file)
@@ -265,7 +265,7 @@ static struct gpiod_lookup_table gpib_gpio_table_0 = {
 static struct gpiod_lookup_table *lookup_tables[] = {
        &gpib_gpio_table_0,
        &gpib_gpio_table_1,
-       0
+       NULL
 };
 
 /* struct which defines private_data for gpio driver */
@@ -1119,7 +1119,7 @@ static void release_gpios(void)
        for (j = 0 ; j < NUM_PINS ; j++) {
                if (all_descriptors[j]) {
                        gpiod_put(all_descriptors[j]);
-                       all_descriptors[j] = 0;
+                       all_descriptors[j] = NULL;
                }
        }
 }
index 2c970bab654591e58f672f27d6370327668582cb..846dafc85c116813ecc79eab2ba279f3d253cb9f 100644 (file)
@@ -1342,8 +1342,8 @@ int ines_common_pcmcia_attach(gpib_board_t *board)
        ines_priv = board->private_data;
        nec_priv = &ines_priv->nec7210_priv;
 
-       if (request_region(curr_dev->resource[0]->start,
-                          resource_size(curr_dev->resource[0]), "ines_gpib") == 0) {
+       if (!request_region(curr_dev->resource[0]->start,
+                           resource_size(curr_dev->resource[0]), "ines_gpib")) {
                pr_err("ines_gpib: ioports at 0x%lx already in use\n",
                       (unsigned long)(curr_dev->resource[0]->start));
                return -1;
index 2fb2b51fbb0fcc0349b066f6c4bcdbc45e380a53..c0b07cb63d9aca43652f5f67451b4e88bd3dea9f 100644 (file)
@@ -426,7 +426,7 @@ int pc2_attach(gpib_board_t *board, const gpib_board_config_t *config)
        nec_priv = &pc2_priv->nec7210_priv;
        nec_priv->offset = pc2_reg_offset;
 
-       if (request_region(config->ibbase, pc2_iosize, "pc2") == 0) {
+       if (!request_region(config->ibbase, pc2_iosize, "pc2")) {
                pr_err("gpib: ioports are already in use\n");
                return -1;
        }
index 2fd1a29f0c8be257c96ebed0ce528e5ea2cfe194..b39ab2abe495c380734e5d2260cbc0b2f19fe0a7 100644 (file)
@@ -1896,8 +1896,8 @@ int ni_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config)
        nec_priv->offset = atgpib_reg_offset;
 
        DEBUG(0, "ioport1 window attributes: 0x%lx\n", curr_dev->resource[0]->flags);
-       if (request_region(curr_dev->resource[0]->start, resource_size(curr_dev->resource[0]),
-                          "tnt4882") == 0) {
+       if (!request_region(curr_dev->resource[0]->start, resource_size(curr_dev->resource[0]),
+                           "tnt4882")) {
                pr_err("gpib: ioports starting at 0x%lx are already in use\n",
                       (unsigned long)curr_dev->resource[0]->start);
                return -EIO;