From: Wolfram Sang <wsa+renesas@sang-engineering.com> Date: 2021-01-12 16:42:36
The bigger picture is that I want to extend the maximum block length for
SMBus block transfers from 32 (SMBus2) to 255 (SMBus3). That needs some
cleanups and refactoring first. To make that easier, it would be helpful
if all in-kernel users would call the helper functions of the I2C core
for SMBus block transfers and not open code it via the generic
smbus_xfer.
This series converts the three users doing that. I don't have the
hardware, so these patches are only build tested. Please let me know
what you think.
Wolfram Sang (3):
media: i2c: adv7842: remove open coded version of SMBus block write
media: i2c: adv7842: remove open coded version of SMBus block read
ipmi: remove open coded version of SMBus block write
drivers/char/ipmi/ipmb_dev_int.c | 21 +++++++----------
drivers/media/i2c/adv7511-v4l2.c | 40 +++++++++++---------------------
drivers/media/i2c/adv7842.c | 14 +----------
3 files changed, 23 insertions(+), 52 deletions(-)
--
2.29.2
From: Wolfram Sang <wsa+renesas@sang-engineering.com> Date: 2021-01-12 16:42:36
The version here is identical to the one in the I2C core, so use a
define to keep the original name within the driver but call the I2C core
function instead.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/media/i2c/adv7842.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
From: Wolfram Sang <wsa+renesas@sang-engineering.com> Date: 2021-01-12 16:42:36
The block-write function of the core was not used because there was no
client-struct to use. However, in this case it seems apropriate to use a
temporary client struct. Because we are answering a request we recieved
when being a client ourselves. So, convert the code to use a temporary
client and use the block-write function of the I2C core.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/char/ipmi/ipmb_dev_int.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
From: Wolfram Sang <wsa+renesas@sang-engineering.com> Date: 2021-01-12 16:42:37
The open coded version differs from the one in the core in one way: the
buffer will be always copied back, even when the transfer failed. It
looks like it is expected that the sanity check for a correct CRC and
header will bail out later.
Use the block read from the I2C core and propagate a potential errno
further to the sanity check.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Note: we could now make the error checking even stronger by checking if
the number of received bytes is I2C_SMBUS_BLOCK_MAX. But to avoid
regressions, I kept the logic as is, i.e. only check for errno.
drivers/media/i2c/adv7511-v4l2.c | 40 +++++++++++---------------------
1 file changed, 14 insertions(+), 26 deletions(-)
From: Wolfram Sang <wsa+renesas@sang-engineering.com> Date: 2021-01-12 16:45:22
On Tue, Jan 12, 2021 at 05:41:28PM +0100, Wolfram Sang wrote:
The open coded version differs from the one in the core in one way: the
buffer will be always copied back, even when the transfer failed. It
looks like it is expected that the sanity check for a correct CRC and
header will bail out later.
Use the block read from the I2C core and propagate a potential errno
further to the sanity check.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
And 'len' here shadows the function argument :( Ok, I need to resend
this patch. Still, looking forward to a comment if an approach like this
is acceptable.
On Tue, Jan 12, 2021 at 05:41:29PM +0100, Wolfram Sang wrote:
The block-write function of the core was not used because there was no
client-struct to use. However, in this case it seems apropriate to use a
temporary client struct. Because we are answering a request we recieved
when being a client ourselves. So, convert the code to use a temporary
client and use the block-write function of the I2C core.
I asked the original authors of this about the change, and apparently is
results in a stack size warning. Arnd Bergmann ask for it to be changed
from what you are suggesting to what it currently is. See:
https://www.lkml.org/lkml/2019/6/19/440
So apparently this change will cause compile warnings due to the size of
struct i2c_client.
-corey
From: Wolfram Sang <wsa+renesas@sang-engineering.com> Date: 2021-01-14 14:05:05
I asked the original authors of this about the change, and apparently is
results in a stack size warning. Arnd Bergmann ask for it to be changed
from what you are suggesting to what it currently is. See:
https://www.lkml.org/lkml/2019/6/19/440
So apparently this change will cause compile warnings due to the size of
struct i2c_client.
Wow, didn't know that my patch was actually a revert. I replaced now the
stack usage with kmemdup and will have a second thought about this
patch. Thanks for the heads up!
From: Hans Verkuil <hidden> Date: 2021-01-18 09:39:03
Hi Wolfram,
On 12/01/2021 17:41, Wolfram Sang wrote:
The open coded version differs from the one in the core in one way: the
buffer will be always copied back, even when the transfer failed. It
looks like it is expected that the sanity check for a correct CRC and
header will bail out later.
Nah, it's just a bug. It should have returned and checked the error code,
so your patch does the right thing.
Regards,
Hans
quoted hunk
Use the block read from the I2C core and propagate a potential errno
further to the sanity check.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Note: we could now make the error checking even stronger by checking if
the number of received bytes is I2C_SMBUS_BLOCK_MAX. But to avoid
regressions, I kept the logic as is, i.e. only check for errno.
drivers/media/i2c/adv7511-v4l2.c | 40 +++++++++++---------------------
1 file changed, 14 insertions(+), 26 deletions(-)
I would prefer it if the driver just uses i2c_smbus_write_i2c_block_data
directly instead of relying on this define. It's used only 5 times, so
it should be a trivial change.
From: Wolfram Sang <wsa+renesas@sang-engineering.com> Date: 2021-01-18 09:47:31
Hello Hans,
I hope you are well!
quoted
The open coded version differs from the one in the core in one way: the
buffer will be always copied back, even when the transfer failed. It
looks like it is expected that the sanity check for a correct CRC and
header will bail out later.
Nah, it's just a bug. It should have returned and checked the error code,
so your patch does the right thing.
I see. So, I will only update the commit message.
Thanks for the reviews!
All the best,
Wolfram
From: Hans Verkuil <hidden> Date: 2021-01-18 10:20:11
On 12/01/2021 17:41, Wolfram Sang wrote:
quoted hunk
The version here is identical to the one in the I2C core, so use a
define to keep the original name within the driver but call the I2C core
function instead.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/media/i2c/adv7842.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
I would prefer it if the driver just uses i2c_smbus_write_i2c_block_data
directly instead of relying on this define. It's used only 5 times, so
it should be a trivial change.
Regards,
Hans