diff options
author | Sven Wegener <sven.wegener@stealer.net> | 2021-06-12 21:56:21 +0200 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2022-09-18 15:39:41 +0100 |
commit | b5665a004526aff62b07d7c729f8ef9e9d98a8e7 (patch) | |
tree | d543ad5255d79e1bdf2527df8cc7bdb270eeabb2 | |
parent | cd0283788fdb73a832f8476f94a3f357bcb89e65 (diff) | |
download | upstream-b5665a004526aff62b07d7c729f8ef9e9d98a8e7.tar.gz upstream-b5665a004526aff62b07d7c729f8ef9e9d98a8e7.tar.bz2 upstream-b5665a004526aff62b07d7c729f8ef9e9d98a8e7.zip |
mediatek: support reading more than one byte of response
There are commands that return more than one byte of response.
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
(cherry picked from commit 7c852e7df50e370b26b060c96c3cc4491cee88eb)
-rw-r--r-- | target/linux/mediatek/files-5.10/drivers/leds/leds-ubnt-ledbar.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/target/linux/mediatek/files-5.10/drivers/leds/leds-ubnt-ledbar.c b/target/linux/mediatek/files-5.10/drivers/leds/leds-ubnt-ledbar.c index 8168391d7e..c62e233e6d 100644 --- a/target/linux/mediatek/files-5.10/drivers/leds/leds-ubnt-ledbar.c +++ b/target/linux/mediatek/files-5.10/drivers/leds/leds-ubnt-ledbar.c @@ -41,16 +41,17 @@ struct ubnt_ledbar { struct gpio_desc *enable_gpio; }; -static int ubnt_ledbar_perform_transaction(struct ubnt_ledbar *ledbar, - char *transaction) +static void ubnt_ledbar_perform_transaction(struct ubnt_ledbar *ledbar, + const char *transaction, int len, + char *result, int result_len) { - int ret; int i; - for (i = 0; i < UBNT_LEDBAR_TRANSACTION_LENGTH; i++) + for (i = 0; i < len; i++) i2c_smbus_write_byte(ledbar->client, transaction[i]); - return i2c_smbus_read_byte(ledbar->client); + for (i = 0; i < result_len; i++) + result[i] = i2c_smbus_read_byte(ledbar->client); } static int ubnt_ledbar_apply_state(struct ubnt_ledbar *ledbar) @@ -72,14 +73,14 @@ static int ubnt_ledbar_apply_state(struct ubnt_ledbar *ledbar) msleep(10); - i2c_response = ubnt_ledbar_perform_transaction(ledbar, setup_msg); + ubnt_ledbar_perform_transaction(ledbar, setup_msg, sizeof(setup_msg), &i2c_response, sizeof(i2c_response)); if (i2c_response != UBNT_LEDBAR_TRANSACTION_SUCCESS) { dev_err(&ledbar->client->dev, "Error initializing LED transaction: %02hhx\n", i2c_response); ret = -EINVAL; goto out_gpio; } - i2c_response = ubnt_ledbar_perform_transaction(ledbar, led_msg); + ubnt_ledbar_perform_transaction(ledbar, led_msg, sizeof(led_msg), &i2c_response, sizeof(i2c_response)); if (i2c_response != UBNT_LEDBAR_TRANSACTION_SUCCESS) { dev_err(&ledbar->client->dev, "Failed LED transaction: %02hhx\n", i2c_response); ret = -EINVAL; |