lkml.org 
[lkml]   [2021]   [Dec]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 6/9] misc: smpro-errmon: Add Ampere's SMpro error monitor driver
On Fri, Dec 24, 2021 at 11:13:49AM +0700, Quan Nguyen wrote:

> +static int read_i2c_block_data(struct i2c_client *client, u16 address, u16 length, u8 *data)
> +{
> + unsigned char outbuf[MAX_READ_BLOCK_LENGTH];
> + unsigned char inbuf[2];
> + struct i2c_msg msgs[2];
> + ssize_t ret;
> +
> + inbuf[0] = (address & 0xff);
> + inbuf[1] = length;
> +
> + msgs[0].addr = client->addr;
> + msgs[0].flags = client->flags & I2C_M_TEN;
> + msgs[0].len = 2;
> + msgs[0].buf = inbuf;
> +
> + msgs[1].addr = client->addr;
> + msgs[1].flags = (client->flags & I2C_M_TEN) | I2C_M_RD;
> + msgs[1].len = length;
> + msgs[1].buf = outbuf;
> +
> + ret = i2c_transfer(client->adapter, msgs, NUM_I2C_MESSAGES);
> + if (ret < 0)

regmap already supports bulk data access so it's not clear why we
would open code this. Given that this is a single I2C transfer
it's also unclear why we'd need to export the regmap lock - a
single I2C transfer is atomic at the bus level so the regmap lock
isn't providing any additional concurrency protection.
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2021-12-24 14:29    [W:0.043 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site