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

Input: touchscreen - use sizeof(*pointer) instead of sizeof(type)

It is preferred to use sizeof(*pointer) instead of sizeof(type)
due to the type of the variable can change and one needs not
change the former (unlike the latter).

The refactoring is mostly trivial except for "usbtouchscreen.c"
file. Here, in the "mtouch_alloc" and "nexio_alloc" functions,
it is necessary to use a variable with a predefined type instead
of the "usbtouch->priv" variable (void * type). This way, the
"sizeof" operator can now know the correct size. Moreover, we
need to set the "usbtouch->priv" pointer after the memory
allocation since now the "kmalloc" return value is not assigned
directly.

This patch has no effect on runtime behavior.

Signed-off-by: Erick Archer <erick.archer@outlook.com>
Link: https://lore.kernel.org/r/AS8PR02MB723708364CC0DF2EAAFEE5968BC42@AS8PR02MB7237.eurprd02.prod.outlook.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Erick Archer and committed by
Dmitry Torokhov
f81d03d4 f4c7fa7c

+24 -23
+1 -1
drivers/input/touchscreen/da9052_tsi.c
··· 232 232 if (!da9052) 233 233 return -EINVAL; 234 234 235 - tsi = kzalloc(sizeof(struct da9052_tsi), GFP_KERNEL); 235 + tsi = kzalloc(sizeof(*tsi), GFP_KERNEL); 236 236 input_dev = input_allocate_device(); 237 237 if (!tsi || !input_dev) { 238 238 error = -ENOMEM;
+1 -1
drivers/input/touchscreen/dynapro.c
··· 110 110 struct input_dev *input_dev; 111 111 int err; 112 112 113 - pdynapro = kzalloc(sizeof(struct dynapro), GFP_KERNEL); 113 + pdynapro = kzalloc(sizeof(*pdynapro), GFP_KERNEL); 114 114 input_dev = input_allocate_device(); 115 115 if (!pdynapro || !input_dev) { 116 116 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/egalax_ts_serial.c
··· 99 99 struct input_dev *input_dev; 100 100 int error; 101 101 102 - egalax = kzalloc(sizeof(struct egalax), GFP_KERNEL); 102 + egalax = kzalloc(sizeof(*egalax), GFP_KERNEL); 103 103 input_dev = input_allocate_device(); 104 104 if (!egalax || !input_dev) { 105 105 error = -ENOMEM;
+1 -1
drivers/input/touchscreen/elo.c
··· 307 307 struct input_dev *input_dev; 308 308 int err; 309 309 310 - elo = kzalloc(sizeof(struct elo), GFP_KERNEL); 310 + elo = kzalloc(sizeof(*elo), GFP_KERNEL); 311 311 input_dev = input_allocate_device(); 312 312 if (!elo || !input_dev) { 313 313 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/fujitsu_ts.c
··· 99 99 struct input_dev *input_dev; 100 100 int err; 101 101 102 - fujitsu = kzalloc(sizeof(struct fujitsu), GFP_KERNEL); 102 + fujitsu = kzalloc(sizeof(*fujitsu), GFP_KERNEL); 103 103 input_dev = input_allocate_device(); 104 104 if (!fujitsu || !input_dev) { 105 105 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/gunze.c
··· 97 97 struct input_dev *input_dev; 98 98 int err; 99 99 100 - gunze = kzalloc(sizeof(struct gunze), GFP_KERNEL); 100 + gunze = kzalloc(sizeof(*gunze), GFP_KERNEL); 101 101 input_dev = input_allocate_device(); 102 102 if (!gunze || !input_dev) { 103 103 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/hampshire.c
··· 109 109 struct input_dev *input_dev; 110 110 int err; 111 111 112 - phampshire = kzalloc(sizeof(struct hampshire), GFP_KERNEL); 112 + phampshire = kzalloc(sizeof(*phampshire), GFP_KERNEL); 113 113 input_dev = input_allocate_device(); 114 114 if (!phampshire || !input_dev) { 115 115 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/inexio.c
··· 114 114 struct input_dev *input_dev; 115 115 int err; 116 116 117 - pinexio = kzalloc(sizeof(struct inexio), GFP_KERNEL); 117 + pinexio = kzalloc(sizeof(*pinexio), GFP_KERNEL); 118 118 input_dev = input_allocate_device(); 119 119 if (!pinexio || !input_dev) { 120 120 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/mtouch.c
··· 128 128 struct input_dev *input_dev; 129 129 int err; 130 130 131 - mtouch = kzalloc(sizeof(struct mtouch), GFP_KERNEL); 131 + mtouch = kzalloc(sizeof(*mtouch), GFP_KERNEL); 132 132 input_dev = input_allocate_device(); 133 133 if (!mtouch || !input_dev) { 134 134 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/penmount.c
··· 199 199 int max_x, max_y; 200 200 int err; 201 201 202 - pm = kzalloc(sizeof(struct pm), GFP_KERNEL); 202 + pm = kzalloc(sizeof(*pm), GFP_KERNEL); 203 203 input_dev = input_allocate_device(); 204 204 if (!pm || !input_dev) { 205 205 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/sur40.c
··· 672 672 return -ENODEV; 673 673 674 674 /* Allocate memory for our device state and initialize it. */ 675 - sur40 = kzalloc(sizeof(struct sur40_state), GFP_KERNEL); 675 + sur40 = kzalloc(sizeof(*sur40), GFP_KERNEL); 676 676 if (!sur40) 677 677 return -ENOMEM; 678 678
+1 -1
drivers/input/touchscreen/touchit213.c
··· 139 139 struct input_dev *input_dev; 140 140 int err; 141 141 142 - touchit213 = kzalloc(sizeof(struct touchit213), GFP_KERNEL); 142 + touchit213 = kzalloc(sizeof(*touchit213), GFP_KERNEL); 143 143 input_dev = input_allocate_device(); 144 144 if (!touchit213 || !input_dev) { 145 145 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/touchright.c
··· 102 102 struct input_dev *input_dev; 103 103 int err; 104 104 105 - tr = kzalloc(sizeof(struct tr), GFP_KERNEL); 105 + tr = kzalloc(sizeof(*tr), GFP_KERNEL); 106 106 input_dev = input_allocate_device(); 107 107 if (!tr || !input_dev) { 108 108 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/touchwin.c
··· 109 109 struct input_dev *input_dev; 110 110 int err; 111 111 112 - tw = kzalloc(sizeof(struct tw), GFP_KERNEL); 112 + tw = kzalloc(sizeof(*tw), GFP_KERNEL); 113 113 input_dev = input_allocate_device(); 114 114 if (!tw || !input_dev) { 115 115 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/tsc40.c
··· 83 83 struct input_dev *input_dev; 84 84 int error; 85 85 86 - ptsc = kzalloc(sizeof(struct tsc_ser), GFP_KERNEL); 86 + ptsc = kzalloc(sizeof(*ptsc), GFP_KERNEL); 87 87 input_dev = input_allocate_device(); 88 88 if (!ptsc || !input_dev) { 89 89 error = -ENOMEM;
+8 -7
drivers/input/touchscreen/usbtouchscreen.c
··· 505 505 506 506 static int mtouch_alloc(struct usbtouch_usb *usbtouch) 507 507 { 508 + struct mtouch_priv *priv; 508 509 int ret; 509 510 510 - usbtouch->priv = kmalloc(sizeof(struct mtouch_priv), GFP_KERNEL); 511 - if (!usbtouch->priv) 511 + priv = kmalloc(sizeof(*priv), GFP_KERNEL); 512 + if (!priv) 512 513 return -ENOMEM; 513 514 515 + usbtouch->priv = priv; 514 516 ret = sysfs_create_group(&usbtouch->interface->dev.kobj, 515 517 &mtouch_attr_group); 516 518 if (ret) { ··· 926 924 struct nexio_priv *priv; 927 925 int ret = -ENOMEM; 928 926 929 - usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL); 930 - if (!usbtouch->priv) 927 + priv = kmalloc(sizeof(*priv), GFP_KERNEL); 928 + if (!priv) 931 929 goto out_buf; 932 930 933 - priv = usbtouch->priv; 934 - 931 + usbtouch->priv = priv; 935 932 priv->ack_buf = kmemdup(nexio_ack_pkt, sizeof(nexio_ack_pkt), 936 933 GFP_KERNEL); 937 934 if (!priv->ack_buf) ··· 1662 1661 if (!endpoint) 1663 1662 return -ENXIO; 1664 1663 1665 - usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL); 1664 + usbtouch = kzalloc(sizeof(*usbtouch), GFP_KERNEL); 1666 1665 input_dev = input_allocate_device(); 1667 1666 if (!usbtouch || !input_dev) 1668 1667 goto out_free;
+1 -1
drivers/input/touchscreen/wacom_w8001.c
··· 598 598 char basename[64] = "Wacom Serial"; 599 599 int err, err_pen, err_touch; 600 600 601 - w8001 = kzalloc(sizeof(struct w8001), GFP_KERNEL); 601 + w8001 = kzalloc(sizeof(*w8001), GFP_KERNEL); 602 602 input_dev_pen = input_allocate_device(); 603 603 input_dev_touch = input_allocate_device(); 604 604 if (!w8001 || !input_dev_pen || !input_dev_touch) {