diff options
author | Erick Archer <erick.archer@outlook.com> | 2024-06-08 16:34:49 +0200 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2024-06-09 14:38:38 -0700 |
commit | f81d03d43965261056d963572d0335645008a8e8 (patch) | |
tree | a7bdc0045c86c059a48b3dc44de24d53a608df4b /drivers/input/touchscreen | |
parent | f4c7fa7c058b9893b7a949cdb2f2aa504903f497 (diff) |
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>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r-- | drivers/input/touchscreen/da9052_tsi.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/dynapro.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/egalax_ts_serial.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/elo.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/fujitsu_ts.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/gunze.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/hampshire.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/inexio.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/mtouch.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/penmount.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/sur40.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/touchit213.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/touchright.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/touchwin.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/tsc40.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/usbtouchscreen.c | 15 | ||||
-rw-r--r-- | drivers/input/touchscreen/wacom_w8001.c | 2 |
17 files changed, 24 insertions, 23 deletions
diff --git a/drivers/input/touchscreen/da9052_tsi.c b/drivers/input/touchscreen/da9052_tsi.c index d71690ce6463..52e0e834e76f 100644 --- a/drivers/input/touchscreen/da9052_tsi.c +++ b/drivers/input/touchscreen/da9052_tsi.c @@ -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; diff --git a/drivers/input/touchscreen/dynapro.c b/drivers/input/touchscreen/dynapro.c index dc07fca7c5ed..fe626a226b85 100644 --- a/drivers/input/touchscreen/dynapro.c +++ b/drivers/input/touchscreen/dynapro.c @@ -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; diff --git a/drivers/input/touchscreen/egalax_ts_serial.c b/drivers/input/touchscreen/egalax_ts_serial.c index 375922d3a6d1..07a4aa1c19bb 100644 --- a/drivers/input/touchscreen/egalax_ts_serial.c +++ b/drivers/input/touchscreen/egalax_ts_serial.c @@ -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; diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c index 96173232e53f..eb883db55420 100644 --- a/drivers/input/touchscreen/elo.c +++ b/drivers/input/touchscreen/elo.c @@ -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; diff --git a/drivers/input/touchscreen/fujitsu_ts.c b/drivers/input/touchscreen/fujitsu_ts.c index 3b0b8fccc3f0..1a3e14ea2e08 100644 --- a/drivers/input/touchscreen/fujitsu_ts.c +++ b/drivers/input/touchscreen/fujitsu_ts.c @@ -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; diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c index 5a5f9da73fa1..dbf92fb02f80 100644 --- a/drivers/input/touchscreen/gunze.c +++ b/drivers/input/touchscreen/gunze.c @@ -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; diff --git a/drivers/input/touchscreen/hampshire.c b/drivers/input/touchscreen/hampshire.c index 5c4d877564ee..dc0a2482ddd6 100644 --- a/drivers/input/touchscreen/hampshire.c +++ b/drivers/input/touchscreen/hampshire.c @@ -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; diff --git a/drivers/input/touchscreen/inexio.c b/drivers/input/touchscreen/inexio.c index 1d7e4c3966ce..82f7ac62a4f2 100644 --- a/drivers/input/touchscreen/inexio.c +++ b/drivers/input/touchscreen/inexio.c @@ -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; diff --git a/drivers/input/touchscreen/mtouch.c b/drivers/input/touchscreen/mtouch.c index 28e449eea318..eefae96a2d40 100644 --- a/drivers/input/touchscreen/mtouch.c +++ b/drivers/input/touchscreen/mtouch.c @@ -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; diff --git a/drivers/input/touchscreen/penmount.c b/drivers/input/touchscreen/penmount.c index 12abb3b36128..95adede26703 100644 --- a/drivers/input/touchscreen/penmount.c +++ b/drivers/input/touchscreen/penmount.c @@ -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; diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c index 5f2cf8881e72..8365a2ac6fce 100644 --- a/drivers/input/touchscreen/sur40.c +++ b/drivers/input/touchscreen/sur40.c @@ -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; diff --git a/drivers/input/touchscreen/touchit213.c b/drivers/input/touchscreen/touchit213.c index fb49687da405..c2718350815c 100644 --- a/drivers/input/touchscreen/touchit213.c +++ b/drivers/input/touchscreen/touchit213.c @@ -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; diff --git a/drivers/input/touchscreen/touchright.c b/drivers/input/touchscreen/touchright.c index 3cd58a13e44f..30ba97bd00a1 100644 --- a/drivers/input/touchscreen/touchright.c +++ b/drivers/input/touchscreen/touchright.c @@ -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; diff --git a/drivers/input/touchscreen/touchwin.c b/drivers/input/touchscreen/touchwin.c index bde3c6ee3c60..fbd72789ea80 100644 --- a/drivers/input/touchscreen/touchwin.c +++ b/drivers/input/touchscreen/touchwin.c @@ -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; diff --git a/drivers/input/touchscreen/tsc40.c b/drivers/input/touchscreen/tsc40.c index 139577021413..9f485cf57a72 100644 --- a/drivers/input/touchscreen/tsc40.c +++ b/drivers/input/touchscreen/tsc40.c @@ -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; diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index 60354ebc7242..dd6b12c6dc58 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c @@ -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; diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c index 4ddb6b3baba5..c8abb9557ee8 100644 --- a/drivers/input/touchscreen/wacom_w8001.c +++ b/drivers/input/touchscreen/wacom_w8001.c @@ -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) { |