Skip to content

Commit d5d359b

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input fixes from Dmitry Torokhov: - add sanity checks to USB endpoints in various dirvers - max77650-onkey was missing an OF table which was preventing module autoloading - a revert and a different fix for F54 handling in Synaptics dirver - a fixup for handling register in pm8xxx vibrator driver * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: Input: pm8xxx-vib - fix handling of separate enable register Input: keyspan-remote - fix control-message timeouts Input: max77650-onkey - add of_match table Input: rmi_f54 - read from FIFO in 32 byte blocks Revert "Input: synaptics-rmi4 - don't increment rmiaddr for SMBus transfers" Input: sur40 - fix interface sanity checks Input: gtco - drop redundant variable reinit Input: gtco - fix extra-descriptor debug message Input: gtco - fix endpoint sanity check Input: aiptek - use descriptors of current altsetting Input: aiptek - fix endpoint sanity check Input: pegasus_notetaker - fix endpoint sanity check Input: sun4i-ts - add a check for devm_thermal_zone_of_sensor_register Input: evdev - convert kzalloc()/vzalloc() to kvzalloc()
2 parents 6381b44 + 996d5d5 commit d5d359b

File tree

11 files changed

+59
-40
lines changed

11 files changed

+59
-40
lines changed

drivers/input/evdev.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,7 @@ static int evdev_open(struct inode *inode, struct file *file)
484484
struct evdev_client *client;
485485
int error;
486486

487-
client = kzalloc(struct_size(client, buffer, bufsize),
488-
GFP_KERNEL | __GFP_NOWARN);
489-
if (!client)
490-
client = vzalloc(struct_size(client, buffer, bufsize));
487+
client = kvzalloc(struct_size(client, buffer, bufsize), GFP_KERNEL);
491488
if (!client)
492489
return -ENOMEM;
493490

drivers/input/misc/keyspan_remote.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,23 +336,26 @@ static int keyspan_setup(struct usb_device* dev)
336336
int retval = 0;
337337

338338
retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
339-
0x11, 0x40, 0x5601, 0x0, NULL, 0, 0);
339+
0x11, 0x40, 0x5601, 0x0, NULL, 0,
340+
USB_CTRL_SET_TIMEOUT);
340341
if (retval) {
341342
dev_dbg(&dev->dev, "%s - failed to set bit rate due to error: %d\n",
342343
__func__, retval);
343344
return(retval);
344345
}
345346

346347
retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
347-
0x44, 0x40, 0x0, 0x0, NULL, 0, 0);
348+
0x44, 0x40, 0x0, 0x0, NULL, 0,
349+
USB_CTRL_SET_TIMEOUT);
348350
if (retval) {
349351
dev_dbg(&dev->dev, "%s - failed to set resume sensitivity due to error: %d\n",
350352
__func__, retval);
351353
return(retval);
352354
}
353355

354356
retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
355-
0x22, 0x40, 0x0, 0x0, NULL, 0, 0);
357+
0x22, 0x40, 0x0, 0x0, NULL, 0,
358+
USB_CTRL_SET_TIMEOUT);
356359
if (retval) {
357360
dev_dbg(&dev->dev, "%s - failed to turn receive on due to error: %d\n",
358361
__func__, retval);

drivers/input/misc/max77650-onkey.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,16 @@ static int max77650_onkey_probe(struct platform_device *pdev)
108108
return input_register_device(onkey->input);
109109
}
110110

111+
static const struct of_device_id max77650_onkey_of_match[] = {
112+
{ .compatible = "maxim,max77650-onkey" },
113+
{ }
114+
};
115+
MODULE_DEVICE_TABLE(of, max77650_onkey_of_match);
116+
111117
static struct platform_driver max77650_onkey_driver = {
112118
.driver = {
113119
.name = "max77650-onkey",
120+
.of_match_table = max77650_onkey_of_match,
114121
},
115122
.probe = max77650_onkey_probe,
116123
};

drivers/input/misc/pm8xxx-vibrator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static int pm8xxx_vib_set(struct pm8xxx_vib *vib, bool on)
9090

9191
if (regs->enable_mask)
9292
rc = regmap_update_bits(vib->regmap, regs->enable_addr,
93-
on ? regs->enable_mask : 0, val);
93+
regs->enable_mask, on ? ~0 : 0);
9494

9595
return rc;
9696
}

drivers/input/rmi4/rmi_f54.c

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
#define F54_NUM_TX_OFFSET 1
2525
#define F54_NUM_RX_OFFSET 0
2626

27+
/*
28+
* The smbus protocol can read only 32 bytes max at a time.
29+
* But this should be fine for i2c/spi as well.
30+
*/
31+
#define F54_REPORT_DATA_SIZE 32
32+
2733
/* F54 commands */
2834
#define F54_GET_REPORT 1
2935
#define F54_FORCE_CAL 2
@@ -526,6 +532,7 @@ static void rmi_f54_work(struct work_struct *work)
526532
int report_size;
527533
u8 command;
528534
int error;
535+
int i;
529536

530537
report_size = rmi_f54_get_report_size(f54);
531538
if (report_size == 0) {
@@ -558,23 +565,27 @@ static void rmi_f54_work(struct work_struct *work)
558565

559566
rmi_dbg(RMI_DEBUG_FN, &fn->dev, "Get report command completed, reading data\n");
560567

561-
fifo[0] = 0;
562-
fifo[1] = 0;
563-
error = rmi_write_block(fn->rmi_dev,
564-
fn->fd.data_base_addr + F54_FIFO_OFFSET,
565-
fifo, sizeof(fifo));
566-
if (error) {
567-
dev_err(&fn->dev, "Failed to set fifo start offset\n");
568-
goto abort;
569-
}
568+
for (i = 0; i < report_size; i += F54_REPORT_DATA_SIZE) {
569+
int size = min(F54_REPORT_DATA_SIZE, report_size - i);
570+
571+
fifo[0] = i & 0xff;
572+
fifo[1] = i >> 8;
573+
error = rmi_write_block(fn->rmi_dev,
574+
fn->fd.data_base_addr + F54_FIFO_OFFSET,
575+
fifo, sizeof(fifo));
576+
if (error) {
577+
dev_err(&fn->dev, "Failed to set fifo start offset\n");
578+
goto abort;
579+
}
570580

571-
error = rmi_read_block(fn->rmi_dev, fn->fd.data_base_addr +
572-
F54_REPORT_DATA_OFFSET, f54->report_data,
573-
report_size);
574-
if (error) {
575-
dev_err(&fn->dev, "%s: read [%d bytes] returned %d\n",
576-
__func__, report_size, error);
577-
goto abort;
581+
error = rmi_read_block(fn->rmi_dev, fn->fd.data_base_addr +
582+
F54_REPORT_DATA_OFFSET,
583+
f54->report_data + i, size);
584+
if (error) {
585+
dev_err(&fn->dev, "%s: read [%d bytes] returned %d\n",
586+
__func__, size, error);
587+
goto abort;
588+
}
578589
}
579590

580591
abort:

drivers/input/rmi4/rmi_smbus.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ static int rmi_smb_write_block(struct rmi_transport_dev *xport, u16 rmiaddr,
163163
/* prepare to write next block of bytes */
164164
cur_len -= SMB_MAX_COUNT;
165165
databuff += SMB_MAX_COUNT;
166+
rmiaddr += SMB_MAX_COUNT;
166167
}
167168
exit:
168169
mutex_unlock(&rmi_smb->page_mutex);
@@ -214,6 +215,7 @@ static int rmi_smb_read_block(struct rmi_transport_dev *xport, u16 rmiaddr,
214215
/* prepare to read next block of bytes */
215216
cur_len -= SMB_MAX_COUNT;
216217
databuff += SMB_MAX_COUNT;
218+
rmiaddr += SMB_MAX_COUNT;
217219
}
218220

219221
retval = 0;

drivers/input/tablet/aiptek.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
17131713

17141714
aiptek->inputdev = inputdev;
17151715
aiptek->intf = intf;
1716-
aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber;
1716+
aiptek->ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
17171717
aiptek->inDelay = 0;
17181718
aiptek->endDelay = 0;
17191719
aiptek->previousJitterable = 0;
@@ -1802,14 +1802,14 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
18021802
input_set_abs_params(inputdev, ABS_WHEEL, AIPTEK_WHEEL_MIN, AIPTEK_WHEEL_MAX - 1, 0, 0);
18031803

18041804
/* Verify that a device really has an endpoint */
1805-
if (intf->altsetting[0].desc.bNumEndpoints < 1) {
1805+
if (intf->cur_altsetting->desc.bNumEndpoints < 1) {
18061806
dev_err(&intf->dev,
18071807
"interface has %d endpoints, but must have minimum 1\n",
1808-
intf->altsetting[0].desc.bNumEndpoints);
1808+
intf->cur_altsetting->desc.bNumEndpoints);
18091809
err = -EINVAL;
18101810
goto fail3;
18111811
}
1812-
endpoint = &intf->altsetting[0].endpoint[0].desc;
1812+
endpoint = &intf->cur_altsetting->endpoint[0].desc;
18131813

18141814
/* Go set up our URB, which is called when the tablet receives
18151815
* input.

drivers/input/tablet/gtco.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -875,18 +875,14 @@ static int gtco_probe(struct usb_interface *usbinterface,
875875
}
876876

877877
/* Sanity check that a device has an endpoint */
878-
if (usbinterface->altsetting[0].desc.bNumEndpoints < 1) {
878+
if (usbinterface->cur_altsetting->desc.bNumEndpoints < 1) {
879879
dev_err(&usbinterface->dev,
880880
"Invalid number of endpoints\n");
881881
error = -EINVAL;
882882
goto err_free_urb;
883883
}
884884

885-
/*
886-
* The endpoint is always altsetting 0, we know this since we know
887-
* this device only has one interrupt endpoint
888-
*/
889-
endpoint = &usbinterface->altsetting[0].endpoint[0].desc;
885+
endpoint = &usbinterface->cur_altsetting->endpoint[0].desc;
890886

891887
/* Some debug */
892888
dev_dbg(&usbinterface->dev, "gtco # interfaces: %d\n", usbinterface->num_altsetting);
@@ -896,7 +892,8 @@ static int gtco_probe(struct usb_interface *usbinterface,
896892
if (usb_endpoint_xfer_int(endpoint))
897893
dev_dbg(&usbinterface->dev, "endpoint: we have interrupt endpoint\n");
898894

899-
dev_dbg(&usbinterface->dev, "endpoint extra len:%d\n", usbinterface->altsetting[0].extralen);
895+
dev_dbg(&usbinterface->dev, "interface extra len:%d\n",
896+
usbinterface->cur_altsetting->extralen);
900897

901898
/*
902899
* Find the HID descriptor so we can find out the size of the
@@ -973,8 +970,6 @@ static int gtco_probe(struct usb_interface *usbinterface,
973970
input_dev->dev.parent = &usbinterface->dev;
974971

975972
/* Setup the URB, it will be posted later on open of input device */
976-
endpoint = &usbinterface->altsetting[0].endpoint[0].desc;
977-
978973
usb_fill_int_urb(gtco->urbinfo,
979974
udev,
980975
usb_rcvintpipe(udev,

drivers/input/tablet/pegasus_notetaker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static int pegasus_probe(struct usb_interface *intf,
275275
return -ENODEV;
276276

277277
/* Sanity check that the device has an endpoint */
278-
if (intf->altsetting[0].desc.bNumEndpoints < 1) {
278+
if (intf->cur_altsetting->desc.bNumEndpoints < 1) {
279279
dev_err(&intf->dev, "Invalid number of endpoints\n");
280280
return -EINVAL;
281281
}

drivers/input/touchscreen/sun4i-ts.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ static int sun4i_ts_probe(struct platform_device *pdev)
237237
struct device *dev = &pdev->dev;
238238
struct device_node *np = dev->of_node;
239239
struct device *hwmon;
240+
struct thermal_zone_device *thermal;
240241
int error;
241242
u32 reg;
242243
bool ts_attached;
@@ -355,7 +356,10 @@ static int sun4i_ts_probe(struct platform_device *pdev)
355356
if (IS_ERR(hwmon))
356357
return PTR_ERR(hwmon);
357358

358-
devm_thermal_zone_of_sensor_register(ts->dev, 0, ts, &sun4i_ts_tz_ops);
359+
thermal = devm_thermal_zone_of_sensor_register(ts->dev, 0, ts,
360+
&sun4i_ts_tz_ops);
361+
if (IS_ERR(thermal))
362+
return PTR_ERR(thermal);
359363

360364
writel(TEMP_IRQ_EN(1), ts->base + TP_INT_FIFOC);
361365

0 commit comments

Comments
 (0)