0004-surface-sam-over-hid.patch 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. From 14bc7782c703218156fe5fd6b8df97a5f25f8d3e Mon Sep 17 00:00:00 2001
  2. From: Maximilian Luz <luzmaximilian@gmail.com>
  3. Date: Sat, 25 Jul 2020 17:19:53 +0200
  4. Subject: [PATCH 4/6] surface-sam-over-hid
  5. ---
  6. drivers/i2c/i2c-core-acpi.c | 35 +++++++++++++++++++++++++++++++++++
  7. 1 file changed, 35 insertions(+)
  8. diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
  9. index ce70b5288472c..5df647c4d9a51 100644
  10. --- a/drivers/i2c/i2c-core-acpi.c
  11. +++ b/drivers/i2c/i2c-core-acpi.c
  12. @@ -582,6 +582,28 @@ static int acpi_gsb_i2c_write_bytes(struct i2c_client *client,
  13. return (ret == 1) ? 0 : -EIO;
  14. }
  15. +static int acpi_gsb_i2c_write_raw_bytes(struct i2c_client *client,
  16. + u8 *data, u8 data_len)
  17. +{
  18. + struct i2c_msg msgs[1];
  19. + int ret = AE_OK;
  20. +
  21. + msgs[0].addr = client->addr;
  22. + msgs[0].flags = client->flags;
  23. + msgs[0].len = data_len + 1;
  24. + msgs[0].buf = data;
  25. +
  26. + ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
  27. +
  28. + if (ret < 0) {
  29. + dev_err(&client->adapter->dev, "i2c write failed: %d\n", ret);
  30. + return ret;
  31. + }
  32. +
  33. + /* 1 transfer must have completed successfully */
  34. + return (ret == 1) ? 0 : -EIO;
  35. +}
  36. +
  37. static acpi_status
  38. i2c_acpi_space_handler(u32 function, acpi_physical_address command,
  39. u32 bits, u64 *value64,
  40. @@ -683,6 +705,19 @@ i2c_acpi_space_handler(u32 function, acpi_physical_address command,
  41. }
  42. break;
  43. + case ACPI_GSB_ACCESS_ATTRIB_RAW_BYTES:
  44. + if (action == ACPI_READ) {
  45. + dev_warn(&adapter->dev,
  46. + "protocol 0x%02x not supported for client 0x%02x\n",
  47. + accessor_type, client->addr);
  48. + ret = AE_BAD_PARAMETER;
  49. + goto err;
  50. + } else {
  51. + status = acpi_gsb_i2c_write_raw_bytes(client,
  52. + gsb->data, info->access_length);
  53. + }
  54. + break;
  55. +
  56. default:
  57. dev_warn(&adapter->dev, "protocol 0x%02x not supported for client 0x%02x\n",
  58. accessor_type, client->addr);
  59. --
  60. 2.28.0