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>
This commit is contained in:
parent
e9a22ce253
commit
7c852e7df5
1 changed files with 8 additions and 7 deletions
|
@ -41,16 +41,17 @@ struct ubnt_ledbar {
|
||||||
struct gpio_desc *enable_gpio;
|
struct gpio_desc *enable_gpio;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int ubnt_ledbar_perform_transaction(struct ubnt_ledbar *ledbar,
|
static void ubnt_ledbar_perform_transaction(struct ubnt_ledbar *ledbar,
|
||||||
char *transaction)
|
const char *transaction, int len,
|
||||||
|
char *result, int result_len)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
int i;
|
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]);
|
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)
|
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);
|
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) {
|
if (i2c_response != UBNT_LEDBAR_TRANSACTION_SUCCESS) {
|
||||||
dev_err(&ledbar->client->dev, "Error initializing LED transaction: %02hhx\n", i2c_response);
|
dev_err(&ledbar->client->dev, "Error initializing LED transaction: %02hhx\n", i2c_response);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out_gpio;
|
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) {
|
if (i2c_response != UBNT_LEDBAR_TRANSACTION_SUCCESS) {
|
||||||
dev_err(&ledbar->client->dev, "Failed LED transaction: %02hhx\n", i2c_response);
|
dev_err(&ledbar->client->dev, "Failed LED transaction: %02hhx\n", i2c_response);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
|
Loading…
Reference in a new issue