]> www.infradead.org Git - linux.git/commitdiff
Input: touchscreen - use sizeof(*pointer) instead of sizeof(type)
authorErick Archer <erick.archer@outlook.com>
Sat, 8 Jun 2024 14:34:49 +0000 (16:34 +0200)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sun, 9 Jun 2024 21:38:38 +0000 (14:38 -0700)
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>
17 files changed:
drivers/input/touchscreen/da9052_tsi.c
drivers/input/touchscreen/dynapro.c
drivers/input/touchscreen/egalax_ts_serial.c
drivers/input/touchscreen/elo.c
drivers/input/touchscreen/fujitsu_ts.c
drivers/input/touchscreen/gunze.c
drivers/input/touchscreen/hampshire.c
drivers/input/touchscreen/inexio.c
drivers/input/touchscreen/mtouch.c
drivers/input/touchscreen/penmount.c
drivers/input/touchscreen/sur40.c
drivers/input/touchscreen/touchit213.c
drivers/input/touchscreen/touchright.c
drivers/input/touchscreen/touchwin.c
drivers/input/touchscreen/tsc40.c
drivers/input/touchscreen/usbtouchscreen.c
drivers/input/touchscreen/wacom_w8001.c

index d71690ce64633ff90f83cd2875439e3911718aec..52e0e834e76fba58414c65357dfc4f528015d8c5 100644 (file)
@@ -232,7 +232,7 @@ static int da9052_ts_probe(struct platform_device *pdev)
        if (!da9052)
                return -EINVAL;
 
-       tsi = kzalloc(sizeof(struct da9052_tsi), GFP_KERNEL);
+       tsi = kzalloc(sizeof(*tsi), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!tsi || !input_dev) {
                error = -ENOMEM;
index dc07fca7c5edc03351344ce457857f96e9ba1e97..fe626a226b85a348dcc10cfcaa79047b0c1f0bbd 100644 (file)
@@ -110,7 +110,7 @@ static int dynapro_connect(struct serio *serio, struct serio_driver *drv)
        struct input_dev *input_dev;
        int err;
 
-       pdynapro = kzalloc(sizeof(struct dynapro), GFP_KERNEL);
+       pdynapro = kzalloc(sizeof(*pdynapro), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!pdynapro || !input_dev) {
                err = -ENOMEM;
index 375922d3a6d18e21eb3a491b7711cf1bf2fd3ce9..07a4aa1c19bbca9f47662b143819ddbfd532140c 100644 (file)
@@ -99,7 +99,7 @@ static int egalax_connect(struct serio *serio, struct serio_driver *drv)
        struct input_dev *input_dev;
        int error;
 
-       egalax = kzalloc(sizeof(struct egalax), GFP_KERNEL);
+       egalax = kzalloc(sizeof(*egalax), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!egalax || !input_dev) {
                error = -ENOMEM;
index 96173232e53fec54a2b74a00f976394a7c624d0d..eb883db5542057c75e4f7145a148c7785630cd92 100644 (file)
@@ -307,7 +307,7 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv)
        struct input_dev *input_dev;
        int err;
 
-       elo = kzalloc(sizeof(struct elo), GFP_KERNEL);
+       elo = kzalloc(sizeof(*elo), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!elo || !input_dev) {
                err = -ENOMEM;
index 3b0b8fccc3f0ac654ef044919b9ed067e9841d5c..1a3e14ea2e08e29a46c454379bc99b7011de240f 100644 (file)
@@ -99,7 +99,7 @@ static int fujitsu_connect(struct serio *serio, struct serio_driver *drv)
        struct input_dev *input_dev;
        int err;
 
-       fujitsu = kzalloc(sizeof(struct fujitsu), GFP_KERNEL);
+       fujitsu = kzalloc(sizeof(*fujitsu), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!fujitsu || !input_dev) {
                err = -ENOMEM;
index 5a5f9da73fa180b60e3c1452f29803166eca137c..dbf92fb02f80b298ecd59dcb918052f00ac72071 100644 (file)
@@ -97,7 +97,7 @@ static int gunze_connect(struct serio *serio, struct serio_driver *drv)
        struct input_dev *input_dev;
        int err;
 
-       gunze = kzalloc(sizeof(struct gunze), GFP_KERNEL);
+       gunze = kzalloc(sizeof(*gunze), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!gunze || !input_dev) {
                err = -ENOMEM;
index 5c4d877564eeeb332f3addd3f1e21802cfc513be..dc0a2482ddd6ec4ac158870d0a6b08094e1789d2 100644 (file)
@@ -109,7 +109,7 @@ static int hampshire_connect(struct serio *serio, struct serio_driver *drv)
        struct input_dev *input_dev;
        int err;
 
-       phampshire = kzalloc(sizeof(struct hampshire), GFP_KERNEL);
+       phampshire = kzalloc(sizeof(*phampshire), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!phampshire || !input_dev) {
                err = -ENOMEM;
index 1d7e4c3966ce7f2aef42c39a8fa39f1a84707521..82f7ac62a4f2c22c103afcd3c2ab56657ed92f52 100644 (file)
@@ -114,7 +114,7 @@ static int inexio_connect(struct serio *serio, struct serio_driver *drv)
        struct input_dev *input_dev;
        int err;
 
-       pinexio = kzalloc(sizeof(struct inexio), GFP_KERNEL);
+       pinexio = kzalloc(sizeof(*pinexio), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!pinexio || !input_dev) {
                err = -ENOMEM;
index 28e449eea318dcc75db8f8be1418fa3ce643258e..eefae96a2d40794be9ec1dd249116da971a68a74 100644 (file)
@@ -128,7 +128,7 @@ static int mtouch_connect(struct serio *serio, struct serio_driver *drv)
        struct input_dev *input_dev;
        int err;
 
-       mtouch = kzalloc(sizeof(struct mtouch), GFP_KERNEL);
+       mtouch = kzalloc(sizeof(*mtouch), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!mtouch || !input_dev) {
                err = -ENOMEM;
index 12abb3b361287bae23a9c37a2cdce52eadbc3218..95adede267032b236ee2afee0c03511887ae1770 100644 (file)
@@ -199,7 +199,7 @@ static int pm_connect(struct serio *serio, struct serio_driver *drv)
        int max_x, max_y;
        int err;
 
-       pm = kzalloc(sizeof(struct pm), GFP_KERNEL);
+       pm = kzalloc(sizeof(*pm), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!pm || !input_dev) {
                err = -ENOMEM;
index 5f2cf8881e72495dec5be729e77b350f42657b50..8365a2ac6fce65aeedc72c187053fcdaea6720a4 100644 (file)
@@ -672,7 +672,7 @@ static int sur40_probe(struct usb_interface *interface,
                return -ENODEV;
 
        /* Allocate memory for our device state and initialize it. */
-       sur40 = kzalloc(sizeof(struct sur40_state), GFP_KERNEL);
+       sur40 = kzalloc(sizeof(*sur40), GFP_KERNEL);
        if (!sur40)
                return -ENOMEM;
 
index fb49687da40532d06711b780f37cb9633d81a002..c2718350815cd62b60a3ab287da4e94eb06dadbd 100644 (file)
@@ -139,7 +139,7 @@ static int touchit213_connect(struct serio *serio, struct serio_driver *drv)
        struct input_dev *input_dev;
        int err;
 
-       touchit213 = kzalloc(sizeof(struct touchit213), GFP_KERNEL);
+       touchit213 = kzalloc(sizeof(*touchit213), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!touchit213 || !input_dev) {
                err = -ENOMEM;
index 3cd58a13e44feaba0e57e6613c1aee29b4f4fa89..30ba97bd00a1aea73e4c252a23d804dea8b32377 100644 (file)
@@ -102,7 +102,7 @@ static int tr_connect(struct serio *serio, struct serio_driver *drv)
        struct input_dev *input_dev;
        int err;
 
-       tr = kzalloc(sizeof(struct tr), GFP_KERNEL);
+       tr = kzalloc(sizeof(*tr), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!tr || !input_dev) {
                err = -ENOMEM;
index bde3c6ee3c60570ddd55c1edde06d0f4e2488296..fbd72789ea8095504bc612f82cc5d739f0ac3a40 100644 (file)
@@ -109,7 +109,7 @@ static int tw_connect(struct serio *serio, struct serio_driver *drv)
        struct input_dev *input_dev;
        int err;
 
-       tw = kzalloc(sizeof(struct tw), GFP_KERNEL);
+       tw = kzalloc(sizeof(*tw), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!tw || !input_dev) {
                err = -ENOMEM;
index 13957702141369dd2d12251e94f233f826663189..9f485cf57a72987cb7656c3da155226cd4d8a4e0 100644 (file)
@@ -83,7 +83,7 @@ static int tsc_connect(struct serio *serio, struct serio_driver *drv)
        struct input_dev *input_dev;
        int error;
 
-       ptsc = kzalloc(sizeof(struct tsc_ser), GFP_KERNEL);
+       ptsc = kzalloc(sizeof(*ptsc), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!ptsc || !input_dev) {
                error = -ENOMEM;
index 60354ebc7242493ed7625db8e647101b28142748..dd6b12c6dc5818039fd6cec414996e9e2083f6c6 100644 (file)
@@ -505,12 +505,14 @@ free:
 
 static int mtouch_alloc(struct usbtouch_usb *usbtouch)
 {
+       struct mtouch_priv *priv;
        int ret;
 
-       usbtouch->priv = kmalloc(sizeof(struct mtouch_priv), GFP_KERNEL);
-       if (!usbtouch->priv)
+       priv = kmalloc(sizeof(*priv), GFP_KERNEL);
+       if (!priv)
                return -ENOMEM;
 
+       usbtouch->priv = priv;
        ret = sysfs_create_group(&usbtouch->interface->dev.kobj,
                                 &mtouch_attr_group);
        if (ret) {
@@ -924,12 +926,11 @@ static int nexio_alloc(struct usbtouch_usb *usbtouch)
        struct nexio_priv *priv;
        int ret = -ENOMEM;
 
-       usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL);
-       if (!usbtouch->priv)
+       priv = kmalloc(sizeof(*priv), GFP_KERNEL);
+       if (!priv)
                goto out_buf;
 
-       priv = usbtouch->priv;
-
+       usbtouch->priv = priv;
        priv->ack_buf = kmemdup(nexio_ack_pkt, sizeof(nexio_ack_pkt),
                                GFP_KERNEL);
        if (!priv->ack_buf)
@@ -1661,7 +1662,7 @@ static int usbtouch_probe(struct usb_interface *intf,
        if (!endpoint)
                return -ENXIO;
 
-       usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL);
+       usbtouch = kzalloc(sizeof(*usbtouch), GFP_KERNEL);
        input_dev = input_allocate_device();
        if (!usbtouch || !input_dev)
                goto out_free;
index 4ddb6b3baba53ee57f6261a96fadc8c55aebcb08..c8abb9557ee86d8005cb2cf3d10a95afd7a55fe6 100644 (file)
@@ -598,7 +598,7 @@ static int w8001_connect(struct serio *serio, struct serio_driver *drv)
        char basename[64] = "Wacom Serial";
        int err, err_pen, err_touch;
 
-       w8001 = kzalloc(sizeof(struct w8001), GFP_KERNEL);
+       w8001 = kzalloc(sizeof(*w8001), GFP_KERNEL);
        input_dev_pen = input_allocate_device();
        input_dev_touch = input_allocate_device();
        if (!w8001 || !input_dev_pen || !input_dev_touch) {