Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: constify gpio_chip structures

These structures are only used to copy into other structures, so declare
them as const.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct gpio_chip i@p = { ... };

@ok@
identifier r.i;
expression e;
position p;
@@
e = i@p;

@bad@
position p != {r.p,ok.p};
identifier r.i;
struct gpio_chip e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
struct gpio_chip i = { ... };
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Joachim Eastwood <manabian@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Julia Lawall and committed by
Linus Walleij
e35b5ab0 9d99c41a

+20 -20
+1 -1
drivers/gpio/gpio-arizona.c
··· 79 79 ARIZONA_GPN_LVL, value); 80 80 } 81 81 82 - static struct gpio_chip template_chip = { 82 + static const struct gpio_chip template_chip = { 83 83 .label = "arizona", 84 84 .owner = THIS_MODULE, 85 85 .direction_input = arizona_gpio_direction_in,
+1 -1
drivers/gpio/gpio-bcm-kona.c
··· 308 308 return 0; 309 309 } 310 310 311 - static struct gpio_chip template_chip = { 311 + static const struct gpio_chip template_chip = { 312 312 .label = "bcm-kona-gpio", 313 313 .owner = THIS_MODULE, 314 314 .request = bcm_kona_gpio_request,
+1 -1
drivers/gpio/gpio-da9052.c
··· 184 184 return irq; 185 185 } 186 186 187 - static struct gpio_chip reference_gp = { 187 + static const struct gpio_chip reference_gp = { 188 188 .label = "da9052-gpio", 189 189 .owner = THIS_MODULE, 190 190 .get = da9052_gpio_get,
+1 -1
drivers/gpio/gpio-da9055.c
··· 121 121 DA9055_IRQ_GPI0 + offset); 122 122 } 123 123 124 - static struct gpio_chip reference_gp = { 124 + static const struct gpio_chip reference_gp = { 125 125 .label = "da9055-gpio", 126 126 .owner = THIS_MODULE, 127 127 .get = da9055_gpio_get,
+1 -1
drivers/gpio/gpio-it87.c
··· 273 273 return rc; 274 274 } 275 275 276 - static struct gpio_chip it87_template_chip = { 276 + static const struct gpio_chip it87_template_chip = { 277 277 .label = KBUILD_MODNAME, 278 278 .owner = THIS_MODULE, 279 279 .request = it87_gpio_request,
+1 -1
drivers/gpio/gpio-lp873x.c
··· 124 124 } 125 125 } 126 126 127 - static struct gpio_chip template_chip = { 127 + static const struct gpio_chip template_chip = { 128 128 .label = "lp873x-gpio", 129 129 .owner = THIS_MODULE, 130 130 .request = lp873x_gpio_request,
+1 -1
drivers/gpio/gpio-lpc18xx.c
··· 78 78 return lpc18xx_gpio_direction(chip, offset, true); 79 79 } 80 80 81 - static struct gpio_chip lpc18xx_chip = { 81 + static const struct gpio_chip lpc18xx_chip = { 82 82 .label = "lpc18xx/43xx-gpio", 83 83 .request = gpiochip_generic_request, 84 84 .free = gpiochip_generic_free,
+1 -1
drivers/gpio/gpio-pisosr.c
··· 90 90 return (gpio->buffer[offset / 8] >> (offset % 8)) & 0x1; 91 91 } 92 92 93 - static struct gpio_chip template_chip = { 93 + static const struct gpio_chip template_chip = { 94 94 .label = "pisosr-gpio", 95 95 .owner = THIS_MODULE, 96 96 .get_direction = pisosr_gpio_get_direction,
+1 -1
drivers/gpio/gpio-sch.c
··· 138 138 return 0; 139 139 } 140 140 141 - static struct gpio_chip sch_gpio_chip = { 141 + static const struct gpio_chip sch_gpio_chip = { 142 142 .label = "sch_gpio", 143 143 .owner = THIS_MODULE, 144 144 .direction_input = sch_gpio_direction_in,
+1 -1
drivers/gpio/gpio-stmpe.c
··· 121 121 return stmpe_set_altfunc(stmpe, 1 << offset, STMPE_BLOCK_GPIO); 122 122 } 123 123 124 - static struct gpio_chip template_chip = { 124 + static const struct gpio_chip template_chip = { 125 125 .label = "stmpe", 126 126 .owner = THIS_MODULE, 127 127 .get_direction = stmpe_gpio_get_direction,
+1 -1
drivers/gpio/gpio-tc3589x.c
··· 124 124 return -ENOTSUPP; 125 125 } 126 126 127 - static struct gpio_chip template_chip = { 127 + static const struct gpio_chip template_chip = { 128 128 .label = "tc3589x", 129 129 .owner = THIS_MODULE, 130 130 .direction_input = tc3589x_gpio_direction_input,
+1 -1
drivers/gpio/gpio-tpic2810.c
··· 87 87 tpic2810_set_mask_bits(chip, *mask, *bits); 88 88 } 89 89 90 - static struct gpio_chip template_chip = { 90 + static const struct gpio_chip template_chip = { 91 91 .label = "tpic2810", 92 92 .owner = THIS_MODULE, 93 93 .get_direction = tpic2810_get_direction,
+1 -1
drivers/gpio/gpio-tps65086.c
··· 72 72 BIT(4 + offset), value ? BIT(4 + offset) : 0); 73 73 } 74 74 75 - static struct gpio_chip template_chip = { 75 + static const struct gpio_chip template_chip = { 76 76 .label = "tps65086-gpio", 77 77 .owner = THIS_MODULE, 78 78 .get_direction = tps65086_gpio_get_direction,
+1 -1
drivers/gpio/gpio-tps65218.c
··· 172 172 return -ENOTSUPP; 173 173 } 174 174 175 - static struct gpio_chip template_chip = { 175 + static const struct gpio_chip template_chip = { 176 176 .label = "gpio-tps65218", 177 177 .owner = THIS_MODULE, 178 178 .request = tps65218_gpio_request,
+1 -1
drivers/gpio/gpio-tps65912.c
··· 90 90 GPIO_SET_MASK, value ? GPIO_SET_MASK : 0); 91 91 } 92 92 93 - static struct gpio_chip template_chip = { 93 + static const struct gpio_chip template_chip = { 94 94 .label = "tps65912-gpio", 95 95 .owner = THIS_MODULE, 96 96 .get_direction = tps65912_gpio_get_direction,
+1 -1
drivers/gpio/gpio-ts4900.c
··· 101 101 .val_bits = 8, 102 102 }; 103 103 104 - static struct gpio_chip template_chip = { 104 + static const struct gpio_chip template_chip = { 105 105 .label = "ts4900-gpio", 106 106 .owner = THIS_MODULE, 107 107 .get_direction = ts4900_gpio_get_direction,
+1 -1
drivers/gpio/gpio-twl4030.c
··· 381 381 : -EINVAL; 382 382 } 383 383 384 - static struct gpio_chip template_chip = { 384 + static const struct gpio_chip template_chip = { 385 385 .label = "twl4030", 386 386 .owner = THIS_MODULE, 387 387 .request = twl_request,
+1 -1
drivers/gpio/gpio-wm831x.c
··· 247 247 #define wm831x_gpio_dbg_show NULL 248 248 #endif 249 249 250 - static struct gpio_chip template_chip = { 250 + static const struct gpio_chip template_chip = { 251 251 .label = "wm831x", 252 252 .owner = THIS_MODULE, 253 253 .direction_input = wm831x_gpio_direction_in,
+1 -1
drivers/gpio/gpio-wm8350.c
··· 93 93 return wm8350->irq_base + WM8350_IRQ_GPIO(offset); 94 94 } 95 95 96 - static struct gpio_chip template_chip = { 96 + static const struct gpio_chip template_chip = { 97 97 .label = "wm8350", 98 98 .owner = THIS_MODULE, 99 99 .direction_input = wm8350_gpio_direction_in,
+1 -1
drivers/gpio/gpio-wm8994.c
··· 249 249 #define wm8994_gpio_dbg_show NULL 250 250 #endif 251 251 252 - static struct gpio_chip template_chip = { 252 + static const struct gpio_chip template_chip = { 253 253 .label = "wm8994", 254 254 .owner = THIS_MODULE, 255 255 .request = wm8994_gpio_request,