summaryrefslogtreecommitdiff
path: root/drivers/input/joystick
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/joystick')
-rw-r--r--drivers/input/joystick/a3d.c2
-rw-r--r--drivers/input/joystick/adc-joystick.c130
-rw-r--r--drivers/input/joystick/adi.c2
-rw-r--r--drivers/input/joystick/analog.c3
-rw-r--r--drivers/input/joystick/as5011.c2
-rw-r--r--drivers/input/joystick/cobra.c2
-rw-r--r--drivers/input/joystick/db9.c2
-rw-r--r--drivers/input/joystick/gamecon.c2
-rw-r--r--drivers/input/joystick/gf2k.c2
-rw-r--r--drivers/input/joystick/grip.c3
-rw-r--r--drivers/input/joystick/grip_mp.c3
-rw-r--r--drivers/input/joystick/guillemot.c2
-rw-r--r--drivers/input/joystick/interact.c2
-rw-r--r--drivers/input/joystick/magellan.c2
-rw-r--r--drivers/input/joystick/maplecontrol.c2
-rw-r--r--drivers/input/joystick/n64joy.c2
-rw-r--r--drivers/input/joystick/sidewinder.c2
-rw-r--r--drivers/input/joystick/spaceball.c2
-rw-r--r--drivers/input/joystick/spaceorb.c2
-rw-r--r--drivers/input/joystick/stinger.c2
-rw-r--r--drivers/input/joystick/tmdc.c3
-rw-r--r--drivers/input/joystick/turbografx.c2
-rw-r--r--drivers/input/joystick/twidjoy.c2
-rw-r--r--drivers/input/joystick/warrior.c2
-rw-r--r--drivers/input/joystick/xpad.c4
-rw-r--r--drivers/input/joystick/zhenhua.c2
26 files changed, 109 insertions, 77 deletions
diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c
index fd1827baf27c..15182f16ed19 100644
--- a/drivers/input/joystick/a3d.c
+++ b/drivers/input/joystick/a3d.c
@@ -249,7 +249,7 @@ static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv)
int i;
int err;
- a3d = kzalloc(sizeof(struct a3d), GFP_KERNEL);
+ a3d = kzalloc(sizeof(*a3d), GFP_KERNEL);
input_dev = input_allocate_device();
if (!a3d || !input_dev) {
err = -ENOMEM;
diff --git a/drivers/input/joystick/adc-joystick.c b/drivers/input/joystick/adc-joystick.c
index c0deff5d4282..5f46a7104b52 100644
--- a/drivers/input/joystick/adc-joystick.c
+++ b/drivers/input/joystick/adc-joystick.c
@@ -15,20 +15,26 @@
struct adc_joystick_axis {
u32 code;
- s32 range[2];
- s32 fuzz;
- s32 flat;
+ bool inverted;
};
struct adc_joystick {
struct input_dev *input;
struct iio_cb_buffer *buffer;
- struct adc_joystick_axis *axes;
struct iio_channel *chans;
- int num_chans;
- bool polled;
+ unsigned int num_chans;
+ struct adc_joystick_axis axes[] __counted_by(num_chans);
};
+static int adc_joystick_invert(struct input_dev *dev,
+ unsigned int axis, int val)
+{
+ int min = input_abs_get_min(dev, axis);
+ int max = input_abs_get_max(dev, axis);
+
+ return (max + min) - val;
+}
+
static void adc_joystick_poll(struct input_dev *input)
{
struct adc_joystick *joy = input_get_drvdata(input);
@@ -38,6 +44,8 @@ static void adc_joystick_poll(struct input_dev *input)
ret = iio_read_channel_raw(&joy->chans[i], &val);
if (ret < 0)
return;
+ if (joy->axes[i].inverted)
+ val = adc_joystick_invert(input, i, val);
input_report_abs(input, joy->axes[i].code, val);
}
input_sync(input);
@@ -86,6 +94,8 @@ static int adc_joystick_handle(const void *data, void *private)
val = sign_extend32(val, msb);
else
val &= GENMASK(msb, 0);
+ if (joy->axes[i].inverted)
+ val = adc_joystick_invert(joy->input, i, val);
input_report_abs(joy->input, joy->axes[i].code, val);
}
@@ -121,9 +131,11 @@ static void adc_joystick_cleanup(void *data)
static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy)
{
- struct adc_joystick_axis *axes;
+ struct adc_joystick_axis *axes = joy->axes;
struct fwnode_handle *child;
- int num_axes, error, i;
+ s32 range[2], fuzz, flat;
+ unsigned int num_axes;
+ int error, i;
num_axes = device_get_child_node_count(dev);
if (!num_axes) {
@@ -137,10 +149,6 @@ static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy)
return -EINVAL;
}
- axes = devm_kmalloc_array(dev, num_axes, sizeof(*axes), GFP_KERNEL);
- if (!axes)
- return -ENOMEM;
-
device_for_each_child_node(dev, child) {
error = fwnode_property_read_u32(child, "reg", &i);
if (error) {
@@ -162,23 +170,25 @@ static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy)
}
error = fwnode_property_read_u32_array(child, "abs-range",
- axes[i].range, 2);
+ range, 2);
if (error) {
dev_err(dev, "abs-range invalid or missing\n");
goto err_fwnode_put;
}
- fwnode_property_read_u32(child, "abs-fuzz", &axes[i].fuzz);
- fwnode_property_read_u32(child, "abs-flat", &axes[i].flat);
+ if (range[0] > range[1]) {
+ dev_dbg(dev, "abs-axis %d inverted\n", i);
+ axes[i].inverted = true;
+ swap(range[0], range[1]);
+ }
+
+ fwnode_property_read_u32(child, "abs-fuzz", &fuzz);
+ fwnode_property_read_u32(child, "abs-flat", &flat);
input_set_abs_params(joy->input, axes[i].code,
- axes[i].range[0], axes[i].range[1],
- axes[i].fuzz, axes[i].flat);
- input_set_capability(joy->input, EV_ABS, axes[i].code);
+ range[0], range[1], fuzz, flat);
}
- joy->axes = axes;
-
return 0;
err_fwnode_put:
@@ -186,23 +196,50 @@ err_fwnode_put:
return error;
}
+
+static int adc_joystick_count_channels(struct device *dev,
+ const struct iio_channel *chans,
+ bool polled,
+ unsigned int *num_chans)
+{
+ int bits;
+ int i;
+
+ /*
+ * Count how many channels we got. NULL terminated.
+ * Do not check the storage size if using polling.
+ */
+ for (i = 0; chans[i].indio_dev; i++) {
+ if (polled)
+ continue;
+ bits = chans[i].channel->scan_type.storagebits;
+ if (!bits || bits > 16) {
+ dev_err(dev, "Unsupported channel storage size\n");
+ return -EINVAL;
+ }
+ if (bits != chans[0].channel->scan_type.storagebits) {
+ dev_err(dev, "Channels must have equal storage size\n");
+ return -EINVAL;
+ }
+ }
+
+ *num_chans = i;
+ return 0;
+}
+
static int adc_joystick_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
+ struct iio_channel *chans;
struct adc_joystick *joy;
struct input_dev *input;
+ unsigned int poll_interval = 0;
+ unsigned int num_chans;
int error;
- int bits;
- int i;
- unsigned int poll_interval;
-
- joy = devm_kzalloc(dev, sizeof(*joy), GFP_KERNEL);
- if (!joy)
- return -ENOMEM;
- joy->chans = devm_iio_channel_get_all(dev);
- if (IS_ERR(joy->chans)) {
- error = PTR_ERR(joy->chans);
+ chans = devm_iio_channel_get_all(dev);
+ error = PTR_ERR_OR_ZERO(chans);
+ if (error) {
if (error != -EPROBE_DEFER)
dev_err(dev, "Unable to get IIO channels");
return error;
@@ -216,28 +253,19 @@ static int adc_joystick_probe(struct platform_device *pdev)
} else if (poll_interval == 0) {
dev_err(dev, "Unable to get poll-interval\n");
return -EINVAL;
- } else {
- joy->polled = true;
}
- /*
- * Count how many channels we got. NULL terminated.
- * Do not check the storage size if using polling.
- */
- for (i = 0; joy->chans[i].indio_dev; i++) {
- if (joy->polled)
- continue;
- bits = joy->chans[i].channel->scan_type.storagebits;
- if (!bits || bits > 16) {
- dev_err(dev, "Unsupported channel storage size\n");
- return -EINVAL;
- }
- if (bits != joy->chans[0].channel->scan_type.storagebits) {
- dev_err(dev, "Channels must have equal storage size\n");
- return -EINVAL;
- }
- }
- joy->num_chans = i;
+ error = adc_joystick_count_channels(dev, chans, poll_interval != 0,
+ &num_chans);
+ if (error)
+ return error;
+
+ joy = devm_kzalloc(dev, struct_size(joy, axes, num_chans), GFP_KERNEL);
+ if (!joy)
+ return -ENOMEM;
+
+ joy->chans = chans;
+ joy->num_chans = num_chans;
input = devm_input_allocate_device(dev);
if (!input) {
@@ -253,7 +281,7 @@ static int adc_joystick_probe(struct platform_device *pdev)
if (error)
return error;
- if (joy->polled) {
+ if (poll_interval != 0) {
input_setup_polling(input, adc_joystick_poll);
input_set_poll_interval(input, poll_interval);
} else {
diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
index f1a720be458b..963250de24b7 100644
--- a/drivers/input/joystick/adi.c
+++ b/drivers/input/joystick/adi.c
@@ -456,7 +456,7 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
int i;
int err;
- port = kzalloc(sizeof(struct adi_port), GFP_KERNEL);
+ port = kzalloc(sizeof(*port), GFP_KERNEL);
if (!port)
return -ENOMEM;
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
index 0c9e172a9818..c709b58d770a 100644
--- a/drivers/input/joystick/analog.c
+++ b/drivers/input/joystick/analog.c
@@ -582,7 +582,8 @@ static int analog_connect(struct gameport *gameport, struct gameport_driver *drv
int i;
int err;
- if (!(port = kzalloc(sizeof(struct analog_port), GFP_KERNEL)))
+ port = kzalloc(sizeof(*port), GFP_KERNEL);
+ if (!port)
return -ENOMEM;
err = analog_init_port(gameport, drv, port);
diff --git a/drivers/input/joystick/as5011.c b/drivers/input/joystick/as5011.c
index 407062bcc84b..49a0dfbbeb49 100644
--- a/drivers/input/joystick/as5011.c
+++ b/drivers/input/joystick/as5011.c
@@ -237,7 +237,7 @@ static int as5011_probe(struct i2c_client *client)
return -ENODEV;
}
- as5011 = kmalloc(sizeof(struct as5011_device), GFP_KERNEL);
+ as5011 = kmalloc(sizeof(*as5011), GFP_KERNEL);
input_dev = input_allocate_device();
if (!as5011 || !input_dev) {
dev_err(&client->dev,
diff --git a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c
index 7ff78c9388bd..5a0ea3ad5efa 100644
--- a/drivers/input/joystick/cobra.c
+++ b/drivers/input/joystick/cobra.c
@@ -141,7 +141,7 @@ static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv)
int i, j;
int err;
- cobra = kzalloc(sizeof(struct cobra), GFP_KERNEL);
+ cobra = kzalloc(sizeof(*cobra), GFP_KERNEL);
if (!cobra)
return -ENOMEM;
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c
index 3ef66e458544..6373d7aa739a 100644
--- a/drivers/input/joystick/db9.c
+++ b/drivers/input/joystick/db9.c
@@ -587,7 +587,7 @@ static void db9_attach(struct parport *pp)
return;
}
- db9 = kzalloc(sizeof(struct db9), GFP_KERNEL);
+ db9 = kzalloc(sizeof(*db9), GFP_KERNEL);
if (!db9)
goto err_unreg_pardev;
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index 7ed4892749fa..2b553e2d838f 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -950,7 +950,7 @@ static void gc_attach(struct parport *pp)
return;
}
- gc = kzalloc(sizeof(struct gc), GFP_KERNEL);
+ gc = kzalloc(sizeof(*gc), GFP_KERNEL);
if (!gc) {
pr_err("Not enough memory\n");
goto err_unreg_pardev;
diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c
index abefbd1484df..e7ff7bdb1a3a 100644
--- a/drivers/input/joystick/gf2k.c
+++ b/drivers/input/joystick/gf2k.c
@@ -222,7 +222,7 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv)
unsigned char data[GF2K_LENGTH];
int i, err;
- gf2k = kzalloc(sizeof(struct gf2k), GFP_KERNEL);
+ gf2k = kzalloc(sizeof(*gf2k), GFP_KERNEL);
input_dev = input_allocate_device();
if (!gf2k || !input_dev) {
err = -ENOMEM;
diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c
index 0e86b269a90e..f339ce2b7a33 100644
--- a/drivers/input/joystick/grip.c
+++ b/drivers/input/joystick/grip.c
@@ -284,7 +284,8 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
int i, j, t;
int err;
- if (!(grip = kzalloc(sizeof(struct grip), GFP_KERNEL)))
+ grip = kzalloc(sizeof(*grip), GFP_KERNEL);
+ if (!grip)
return -ENOMEM;
grip->gameport = gameport;
diff --git a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c
index 056a89ac2bdf..5eadb5a3ca37 100644
--- a/drivers/input/joystick/grip_mp.c
+++ b/drivers/input/joystick/grip_mp.c
@@ -632,7 +632,8 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
struct grip_mp *grip;
int err;
- if (!(grip = kzalloc(sizeof(struct grip_mp), GFP_KERNEL)))
+ grip = kzalloc(sizeof(*grip), GFP_KERNEL);
+ if (!grip)
return -ENOMEM;
grip->gameport = gameport;
diff --git a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c
index 205eb6f8b84d..1c5a76f72239 100644
--- a/drivers/input/joystick/guillemot.c
+++ b/drivers/input/joystick/guillemot.c
@@ -163,7 +163,7 @@ static int guillemot_connect(struct gameport *gameport, struct gameport_driver *
int i, t;
int err;
- guillemot = kzalloc(sizeof(struct guillemot), GFP_KERNEL);
+ guillemot = kzalloc(sizeof(*guillemot), GFP_KERNEL);
input_dev = input_allocate_device();
if (!guillemot || !input_dev) {
err = -ENOMEM;
diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c
index 03a9f0829f7e..262f022e5695 100644
--- a/drivers/input/joystick/interact.c
+++ b/drivers/input/joystick/interact.c
@@ -192,7 +192,7 @@ static int interact_connect(struct gameport *gameport, struct gameport_driver *d
int i, t;
int err;
- interact = kzalloc(sizeof(struct interact), GFP_KERNEL);
+ interact = kzalloc(sizeof(*interact), GFP_KERNEL);
input_dev = input_allocate_device();
if (!interact || !input_dev) {
err = -ENOMEM;
diff --git a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c
index 017ef8c6170b..2eaa25c9c68c 100644
--- a/drivers/input/joystick/magellan.c
+++ b/drivers/input/joystick/magellan.c
@@ -132,7 +132,7 @@ static int magellan_connect(struct serio *serio, struct serio_driver *drv)
int err = -ENOMEM;
int i;
- magellan = kzalloc(sizeof(struct magellan), GFP_KERNEL);
+ magellan = kzalloc(sizeof(*magellan), GFP_KERNEL);
input_dev = input_allocate_device();
if (!magellan || !input_dev)
goto fail1;
diff --git a/drivers/input/joystick/maplecontrol.c b/drivers/input/joystick/maplecontrol.c
index 3833ac47b2b8..8b54f9b18e7c 100644
--- a/drivers/input/joystick/maplecontrol.c
+++ b/drivers/input/joystick/maplecontrol.c
@@ -102,7 +102,7 @@ static int probe_maple_controller(struct device *dev)
struct input_dev *idev;
unsigned long data = be32_to_cpu(mdev->devinfo.function_data[0]);
- pad = kzalloc(sizeof(struct dc_pad), GFP_KERNEL);
+ pad = kzalloc(sizeof(*pad), GFP_KERNEL);
idev = input_allocate_device();
if (!pad || !idev) {
error = -ENOMEM;
diff --git a/drivers/input/joystick/n64joy.c b/drivers/input/joystick/n64joy.c
index 9dbca366613e..b0986d2195d6 100644
--- a/drivers/input/joystick/n64joy.c
+++ b/drivers/input/joystick/n64joy.c
@@ -246,7 +246,7 @@ static int __init n64joy_probe(struct platform_device *pdev)
int err = 0;
u32 i, j, found = 0;
- priv = kzalloc(sizeof(struct n64joy_priv), GFP_KERNEL);
+ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
mutex_init(&priv->n64joy_mutex);
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
index 7282301c3ae7..f6e92db4d789 100644
--- a/drivers/input/joystick/sidewinder.c
+++ b/drivers/input/joystick/sidewinder.c
@@ -577,7 +577,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
comment[0] = 0;
- sw = kzalloc(sizeof(struct sw), GFP_KERNEL);
+ sw = kzalloc(sizeof(*sw), GFP_KERNEL);
buf = kmalloc(SW_LENGTH, GFP_KERNEL);
idbuf = kmalloc(SW_LENGTH, GFP_KERNEL);
if (!sw || !buf || !idbuf) {
diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c
index fa8ec533cd69..49101f1c858b 100644
--- a/drivers/input/joystick/spaceball.c
+++ b/drivers/input/joystick/spaceball.c
@@ -199,7 +199,7 @@ static int spaceball_connect(struct serio *serio, struct serio_driver *drv)
if ((id = serio->id.id) > SPACEBALL_MAX_ID)
return -ENODEV;
- spaceball = kmalloc(sizeof(struct spaceball), GFP_KERNEL);
+ spaceball = kmalloc(sizeof(*spaceball), GFP_KERNEL);
input_dev = input_allocate_device();
if (!spaceball || !input_dev)
goto fail1;
diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c
index dbbc69f17c89..7250d74d62a1 100644
--- a/drivers/input/joystick/spaceorb.c
+++ b/drivers/input/joystick/spaceorb.c
@@ -147,7 +147,7 @@ static int spaceorb_connect(struct serio *serio, struct serio_driver *drv)
int err = -ENOMEM;
int i;
- spaceorb = kzalloc(sizeof(struct spaceorb), GFP_KERNEL);
+ spaceorb = kzalloc(sizeof(*spaceorb), GFP_KERNEL);
input_dev = input_allocate_device();
if (!spaceorb || !input_dev)
goto fail1;
diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c
index 530de468cb61..1b24ea21aa30 100644
--- a/drivers/input/joystick/stinger.c
+++ b/drivers/input/joystick/stinger.c
@@ -118,7 +118,7 @@ static int stinger_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev;
int err = -ENOMEM;
- stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL);
+ stinger = kmalloc(sizeof(*stinger), GFP_KERNEL);
input_dev = input_allocate_device();
if (!stinger || !input_dev)
goto fail1;
diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c
index 93562ecc0ca1..514b1026e379 100644
--- a/drivers/input/joystick/tmdc.c
+++ b/drivers/input/joystick/tmdc.c
@@ -348,7 +348,8 @@ static int tmdc_connect(struct gameport *gameport, struct gameport_driver *drv)
int i;
int err;
- if (!(tmdc = kzalloc(sizeof(struct tmdc), GFP_KERNEL)))
+ tmdc = kzalloc(sizeof(*tmdc), GFP_KERNEL);
+ if (!tmdc)
return -ENOMEM;
tmdc->gameport = gameport;
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c
index baa14acaa3a8..0a78dda3e0ea 100644
--- a/drivers/input/joystick/turbografx.c
+++ b/drivers/input/joystick/turbografx.c
@@ -172,7 +172,7 @@ static void tgfx_attach(struct parport *pp)
return;
}
- tgfx = kzalloc(sizeof(struct tgfx), GFP_KERNEL);
+ tgfx = kzalloc(sizeof(*tgfx), GFP_KERNEL);
if (!tgfx) {
printk(KERN_ERR "turbografx.c: Not enough memory\n");
goto err_unreg_pardev;
diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c
index 9b6792ac27f1..ab99d76e5d8d 100644
--- a/drivers/input/joystick/twidjoy.c
+++ b/drivers/input/joystick/twidjoy.c
@@ -171,7 +171,7 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv)
int err = -ENOMEM;
int i;
- twidjoy = kzalloc(sizeof(struct twidjoy), GFP_KERNEL);
+ twidjoy = kzalloc(sizeof(*twidjoy), GFP_KERNEL);
input_dev = input_allocate_device();
if (!twidjoy || !input_dev)
goto fail1;
diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c
index f66bddf145c2..ebeab441e9ec 100644
--- a/drivers/input/joystick/warrior.c
+++ b/drivers/input/joystick/warrior.c
@@ -124,7 +124,7 @@ static int warrior_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev;
int err = -ENOMEM;
- warrior = kzalloc(sizeof(struct warrior), GFP_KERNEL);
+ warrior = kzalloc(sizeof(*warrior), GFP_KERNEL);
input_dev = input_allocate_device();
if (!warrior || !input_dev)
goto fail1;
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 2b8370ecf42a..4eda18f4f46e 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -1687,7 +1687,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX360W)
return 0;
- xpad->led = led = kzalloc(sizeof(struct xpad_led), GFP_KERNEL);
+ xpad->led = led = kzalloc(sizeof(*led), GFP_KERNEL);
if (!led)
return -ENOMEM;
@@ -2023,7 +2023,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
break;
}
- xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);
+ xpad = kzalloc(sizeof(*xpad), GFP_KERNEL);
if (!xpad)
return -ENOMEM;
diff --git a/drivers/input/joystick/zhenhua.c b/drivers/input/joystick/zhenhua.c
index 3f2460e2b095..cc0e2a77ac5e 100644
--- a/drivers/input/joystick/zhenhua.c
+++ b/drivers/input/joystick/zhenhua.c
@@ -131,7 +131,7 @@ static int zhenhua_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev;
int err = -ENOMEM;
- zhenhua = kzalloc(sizeof(struct zhenhua), GFP_KERNEL);
+ zhenhua = kzalloc(sizeof(*zhenhua), GFP_KERNEL);
input_dev = input_allocate_device();
if (!zhenhua || !input_dev)
goto fail1;