Skip to content

Commit c01063c

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 3fe2699 commit c01063c

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,
@@ -971,9 +972,15 @@ int spihid_apple_core_probe(struct spi_device *spi, struct spihid_apple_ops *ops
971972
// init spi
972973
spi_set_drvdata(spi, spihid);
973974

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

0 commit comments

Comments
 (0)