lkml.org 
[lkml]   [2014]   [Apr]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH v2] regmap: smbus: add support for regmap over SMBus
On Mon, Apr 14, 2014 at 03:08:05PM +0200, Boris BREZILLON wrote:
> SMBus is a subset of the I2C protocol, oftenly used to access registers on
> external devices.

This is basically fine. However...

> + switch (ctx->transfer_type) {
> + case REGMAP_SMBUS_BYTE_TRANSFER:
> + while (count > 0 && !ret) {
> + ret = i2c_smbus_write_byte_data(ctx->i2c, reg++,
> + *(u8 *)data++);
> +
> + count--;
> + }
> + break;

The transfer type gets set once per device at init time so why not just
parameterise based on val_bytes?

> + case REGMAP_SMBUS_I2C_BLOCK_TRANSFER:
> + while (count > 0 && !ret) {
> + ret = i2c_smbus_write_i2c_block_data(ctx->i2c,
> + reg,
> + ctx->val_bytes,
> + (const u8 *)data);

Fix the const correctness of the API rather than casting.

> + reg += ctx->val_bytes;
> + count -= ctx->val_bytes;
> + data += ctx->val_bytes;
> + }

I'm assuming this will only be used if val_bytes isn't 1 or 2?
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2014-04-14 23:21    [W:0.090 / U:0.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site