Skip to content

Commit 47958f9

Browse files
committed
HID: transport: spi: apple: Increase receive buffer size
The SPI receive buffer is passed directly to hid_input_report() if it contains a complete report. It is then passed to hid_report_raw_event() which computes the expected report size and memsets the "missing trailing data up to HID_MAX_BUFFER_SIZE (16K) or hid_ll_driver.max_buffer_size (if set) to zero. Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 258694d commit 47958f9

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

drivers/hid/spi-hid/spi-hid-apple-core.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ static struct hid_ll_driver apple_hid_ll = {
395395
.parse = &apple_ll_parse,
396396
.raw_request = &apple_ll_raw_request,
397397
.output_report = &apple_ll_output_report,
398+
.max_buffer_size = SPIHID_MAX_INPUT_REPORT_SIZE,
398399
};
399400

400401
static struct spihid_interface *spihid_get_iface(struct spihid_apple *spihid,
@@ -968,9 +969,15 @@ int spihid_apple_core_probe(struct spi_device *spi, struct spihid_apple_ops *ops
968969
// init spi
969970
spi_set_drvdata(spi, spihid);
970971

971-
/* allocate SPI buffers */
972+
/*
973+
* allocate SPI buffers
974+
* Overallocate the receice buffer since it passed directly into
975+
* hid_input_report / hid_report_raw_event. The later expects the buffer
976+
* to be HID_MAX_BUFFER_SIZE (16k) or hid_ll_driver.max_buffer_size if
977+
* set.
978+
*/
972979
spihid->rx_buf = devm_kmalloc(
973-
&spi->dev, sizeof(struct spihid_transfer_packet), GFP_KERNEL);
980+
&spi->dev, SPIHID_MAX_INPUT_REPORT_SIZE, GFP_KERNEL);
974981
spihid->tx_buf = devm_kmalloc(
975982
&spi->dev, sizeof(struct spihid_transfer_packet), GFP_KERNEL);
976983
spihid->status_buf = devm_kmalloc(

0 commit comments

Comments
 (0)