1

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>
This commit is contained in:
Erick Archer 2024-06-08 16:34:49 +02:00 committed by Dmitry Torokhov
parent f4c7fa7c05
commit f81d03d439
17 changed files with 24 additions and 23 deletions

View File

@ -232,7 +232,7 @@ static int da9052_ts_probe(struct platform_device *pdev)
if (!da9052) if (!da9052)
return -EINVAL; return -EINVAL;
tsi = kzalloc(sizeof(struct da9052_tsi), GFP_KERNEL); tsi = kzalloc(sizeof(*tsi), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!tsi || !input_dev) { if (!tsi || !input_dev) {
error = -ENOMEM; error = -ENOMEM;

View File

@ -110,7 +110,7 @@ static int dynapro_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int err; int err;
pdynapro = kzalloc(sizeof(struct dynapro), GFP_KERNEL); pdynapro = kzalloc(sizeof(*pdynapro), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!pdynapro || !input_dev) { if (!pdynapro || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -99,7 +99,7 @@ static int egalax_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int error; int error;
egalax = kzalloc(sizeof(struct egalax), GFP_KERNEL); egalax = kzalloc(sizeof(*egalax), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!egalax || !input_dev) { if (!egalax || !input_dev) {
error = -ENOMEM; error = -ENOMEM;

View File

@ -307,7 +307,7 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int err; int err;
elo = kzalloc(sizeof(struct elo), GFP_KERNEL); elo = kzalloc(sizeof(*elo), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!elo || !input_dev) { if (!elo || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -99,7 +99,7 @@ static int fujitsu_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int err; int err;
fujitsu = kzalloc(sizeof(struct fujitsu), GFP_KERNEL); fujitsu = kzalloc(sizeof(*fujitsu), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!fujitsu || !input_dev) { if (!fujitsu || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -97,7 +97,7 @@ static int gunze_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int err; int err;
gunze = kzalloc(sizeof(struct gunze), GFP_KERNEL); gunze = kzalloc(sizeof(*gunze), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!gunze || !input_dev) { if (!gunze || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -109,7 +109,7 @@ static int hampshire_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int err; int err;
phampshire = kzalloc(sizeof(struct hampshire), GFP_KERNEL); phampshire = kzalloc(sizeof(*phampshire), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!phampshire || !input_dev) { if (!phampshire || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -114,7 +114,7 @@ static int inexio_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int err; int err;
pinexio = kzalloc(sizeof(struct inexio), GFP_KERNEL); pinexio = kzalloc(sizeof(*pinexio), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!pinexio || !input_dev) { if (!pinexio || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -128,7 +128,7 @@ static int mtouch_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int err; int err;
mtouch = kzalloc(sizeof(struct mtouch), GFP_KERNEL); mtouch = kzalloc(sizeof(*mtouch), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!mtouch || !input_dev) { if (!mtouch || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -199,7 +199,7 @@ static int pm_connect(struct serio *serio, struct serio_driver *drv)
int max_x, max_y; int max_x, max_y;
int err; int err;
pm = kzalloc(sizeof(struct pm), GFP_KERNEL); pm = kzalloc(sizeof(*pm), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!pm || !input_dev) { if (!pm || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -672,7 +672,7 @@ static int sur40_probe(struct usb_interface *interface,
return -ENODEV; return -ENODEV;
/* Allocate memory for our device state and initialize it. */ /* 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) if (!sur40)
return -ENOMEM; return -ENOMEM;

View File

@ -139,7 +139,7 @@ static int touchit213_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int err; int err;
touchit213 = kzalloc(sizeof(struct touchit213), GFP_KERNEL); touchit213 = kzalloc(sizeof(*touchit213), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!touchit213 || !input_dev) { if (!touchit213 || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -102,7 +102,7 @@ static int tr_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int err; int err;
tr = kzalloc(sizeof(struct tr), GFP_KERNEL); tr = kzalloc(sizeof(*tr), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!tr || !input_dev) { if (!tr || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -109,7 +109,7 @@ static int tw_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int err; int err;
tw = kzalloc(sizeof(struct tw), GFP_KERNEL); tw = kzalloc(sizeof(*tw), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!tw || !input_dev) { if (!tw || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -83,7 +83,7 @@ static int tsc_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int error; int error;
ptsc = kzalloc(sizeof(struct tsc_ser), GFP_KERNEL); ptsc = kzalloc(sizeof(*ptsc), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!ptsc || !input_dev) { if (!ptsc || !input_dev) {
error = -ENOMEM; error = -ENOMEM;

View File

@ -505,12 +505,14 @@ free:
static int mtouch_alloc(struct usbtouch_usb *usbtouch) static int mtouch_alloc(struct usbtouch_usb *usbtouch)
{ {
struct mtouch_priv *priv;
int ret; int ret;
usbtouch->priv = kmalloc(sizeof(struct mtouch_priv), GFP_KERNEL); priv = kmalloc(sizeof(*priv), GFP_KERNEL);
if (!usbtouch->priv) if (!priv)
return -ENOMEM; return -ENOMEM;
usbtouch->priv = priv;
ret = sysfs_create_group(&usbtouch->interface->dev.kobj, ret = sysfs_create_group(&usbtouch->interface->dev.kobj,
&mtouch_attr_group); &mtouch_attr_group);
if (ret) { if (ret) {
@ -924,12 +926,11 @@ static int nexio_alloc(struct usbtouch_usb *usbtouch)
struct nexio_priv *priv; struct nexio_priv *priv;
int ret = -ENOMEM; int ret = -ENOMEM;
usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL); priv = kmalloc(sizeof(*priv), GFP_KERNEL);
if (!usbtouch->priv) if (!priv)
goto out_buf; goto out_buf;
priv = usbtouch->priv; usbtouch->priv = priv;
priv->ack_buf = kmemdup(nexio_ack_pkt, sizeof(nexio_ack_pkt), priv->ack_buf = kmemdup(nexio_ack_pkt, sizeof(nexio_ack_pkt),
GFP_KERNEL); GFP_KERNEL);
if (!priv->ack_buf) if (!priv->ack_buf)
@ -1661,7 +1662,7 @@ static int usbtouch_probe(struct usb_interface *intf,
if (!endpoint) if (!endpoint)
return -ENXIO; return -ENXIO;
usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL); usbtouch = kzalloc(sizeof(*usbtouch), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!usbtouch || !input_dev) if (!usbtouch || !input_dev)
goto out_free; goto out_free;

View File

@ -598,7 +598,7 @@ static int w8001_connect(struct serio *serio, struct serio_driver *drv)
char basename[64] = "Wacom Serial"; char basename[64] = "Wacom Serial";
int err, err_pen, err_touch; 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_pen = input_allocate_device();
input_dev_touch = input_allocate_device(); input_dev_touch = input_allocate_device();
if (!w8001 || !input_dev_pen || !input_dev_touch) { if (!w8001 || !input_dev_pen || !input_dev_touch) {