From: boris.brezillon@free-electrons.com (Boris BREZILLON)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH v2] regmap: smbus: add support for regmap over SMBus
Date: Tue, 15 Apr 2014 13:54:02 +0200 [thread overview]
Message-ID: <534D1DDA.40207@free-electrons.com> (raw)
In-Reply-To: <20140415100922.GN12304@sirena.org.uk>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 15/04/2014 12:09, Mark Brown wrote:
> On Tue, Apr 15, 2014 at 09:36:13AM +0200, Boris BREZILLON wrote:
>> On 14/04/2014 23:04, Mark Brown wrote:
>
>>> The transfer type gets set once per device at init time so why not
>>> just parameterise based on val_bytes?
>
>> Actually, you may want to transfer 1 byte registers using the block
>> method (if your device only support block transfers). This depends on
>> the device being accessed and what it supports, but I'm not sure we can
>> assume 1 byte registers will always be transferred using SMBUS byte
>> transfers.
>
> OK, so if this a realistic issue then it seems like it's better to
> implement three different buses - there is not really any common code
> between the various paths.
Okay, I'll create 4 different busses (one for each access type).
BTW, should I keep these implementations in the same source file
(regmap-smbus.c) ?
And, should I keep one method to register an smbus regmap or should I
provide one method per access type and get rid of the
regmap_smbus_transfer_type enum ?
> This would also mean that you avoid having
> gather write when it can't be implemented.
Correct me if I'm wrong, but they all support gather write.
>
>
> The code is also not validating the lengths for two byte values.
I'm not sure I get this one.
Do you mean I should check that val_size is a 2 byte multiple ?
If this is what you meant, then I should also check it for block transfers.
>
>
>>>> + 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.
>
>> The API is correct because the i2c_smbus_write_i2c_block does not modify
>> the data pointer.
>> Just removing the const keyword in the cast should be enough, because
>> you can safely cast a non const pointer to a const one.
>
> If you need to cast away from void at all something is going wrong (and
> we appear to be always passing in write buffers as const too, I can't
> remember which operation this was though).
You're right, removing the cast when passing the val argument to the i2c
block transfer functions works.
Best Regards,
Boris
- --
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJTTR3aAAoJEHLimErDqMKy3w0H/07ZyPXLB5YB3irMT0+eOqtS
spxzeZDv3OKT2Rggsz7wAjkRhFbFT9rAMtGJyrmo2js7CPh5cXEg+oWWeTeLpqjF
xeCyJW6yoihI0JbF2fsYlkuLqGIKrFYTeGzSWgP1DlLdxwJ//lxqQrayOMzd5exS
KbQglfzUEVJ5W5n65CGjmNBYW2/QWasAQGwzgypv3gWVLfQzd+n/vCnHBvn81bfe
Ry8nTMEOLpV3rJSGiNZZQL1TIsDiAUQuxKh+n4mc2ntIgLZcb2l6mjGA/36ziQaA
Gfpc1zTGTQWaY4ZdQuvljAEOl2yBUZrkuf+ZVrv26l6saIQv9ekxSCmVRP/CmbY=
=Bt4h
-----END PGP SIGNATURE-----
WARNING: multiple messages have this Message-ID (diff)
From: Boris BREZILLON <boris.brezillon@free-electrons.com>
To: Mark Brown <broonie@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Maxime Ripard <maxime.ripard@free-electrons.com>,
Shuge <shuge@allwinnertech.com>,
kevin@allwinnertech.com, Chen-Yu Tsai <wens@csie.org>,
Hans de Goede <hdegoede@redhat.com>,
Carlo Caione <carlo@caione.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, dev@linux-sunxi.org
Subject: Re: [RFC PATCH v2] regmap: smbus: add support for regmap over SMBus
Date: Tue, 15 Apr 2014 13:54:02 +0200 [thread overview]
Message-ID: <534D1DDA.40207@free-electrons.com> (raw)
In-Reply-To: <20140415100922.GN12304@sirena.org.uk>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 15/04/2014 12:09, Mark Brown wrote:
> On Tue, Apr 15, 2014 at 09:36:13AM +0200, Boris BREZILLON wrote:
>> On 14/04/2014 23:04, Mark Brown wrote:
>
>>> The transfer type gets set once per device at init time so why not
>>> just parameterise based on val_bytes?
>
>> Actually, you may want to transfer 1 byte registers using the block
>> method (if your device only support block transfers). This depends on
>> the device being accessed and what it supports, but I'm not sure we can
>> assume 1 byte registers will always be transferred using SMBUS byte
>> transfers.
>
> OK, so if this a realistic issue then it seems like it's better to
> implement three different buses - there is not really any common code
> between the various paths.
Okay, I'll create 4 different busses (one for each access type).
BTW, should I keep these implementations in the same source file
(regmap-smbus.c) ?
And, should I keep one method to register an smbus regmap or should I
provide one method per access type and get rid of the
regmap_smbus_transfer_type enum ?
> This would also mean that you avoid having
> gather write when it can't be implemented.
Correct me if I'm wrong, but they all support gather write.
>
>
> The code is also not validating the lengths for two byte values.
I'm not sure I get this one.
Do you mean I should check that val_size is a 2 byte multiple ?
If this is what you meant, then I should also check it for block transfers.
>
>
>>>> + 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.
>
>> The API is correct because the i2c_smbus_write_i2c_block does not modify
>> the data pointer.
>> Just removing the const keyword in the cast should be enough, because
>> you can safely cast a non const pointer to a const one.
>
> If you need to cast away from void at all something is going wrong (and
> we appear to be always passing in write buffers as const too, I can't
> remember which operation this was though).
You're right, removing the cast when passing the val argument to the i2c
block transfer functions works.
Best Regards,
Boris
- --
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJTTR3aAAoJEHLimErDqMKy3w0H/07ZyPXLB5YB3irMT0+eOqtS
spxzeZDv3OKT2Rggsz7wAjkRhFbFT9rAMtGJyrmo2js7CPh5cXEg+oWWeTeLpqjF
xeCyJW6yoihI0JbF2fsYlkuLqGIKrFYTeGzSWgP1DlLdxwJ//lxqQrayOMzd5exS
KbQglfzUEVJ5W5n65CGjmNBYW2/QWasAQGwzgypv3gWVLfQzd+n/vCnHBvn81bfe
Ry8nTMEOLpV3rJSGiNZZQL1TIsDiAUQuxKh+n4mc2ntIgLZcb2l6mjGA/36ziQaA
Gfpc1zTGTQWaY4ZdQuvljAEOl2yBUZrkuf+ZVrv26l6saIQv9ekxSCmVRP/CmbY=
=Bt4h
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2014-04-15 11:54 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-12 8:45 [RFC PATCH] regmap: smbus: add support for regmap over SMBus Boris BREZILLON
2014-04-12 8:45 ` Boris BREZILLON
2014-04-12 9:02 ` Boris BREZILLON
2014-04-12 9:02 ` Boris BREZILLON
2014-04-14 13:08 ` [RFC PATCH v2] " Boris BREZILLON
2014-04-14 13:08 ` Boris BREZILLON
2014-04-14 21:04 ` Mark Brown
2014-04-14 21:04 ` Mark Brown
2014-04-15 7:36 ` Boris BREZILLON
2014-04-15 7:36 ` Boris BREZILLON
2014-04-15 10:09 ` Mark Brown
2014-04-15 10:09 ` Mark Brown
2014-04-15 11:54 ` Boris BREZILLON [this message]
2014-04-15 11:54 ` Boris BREZILLON
2014-04-15 12:10 ` Mark Brown
2014-04-15 12:10 ` Mark Brown
2014-04-15 12:25 ` Lars-Peter Clausen
2014-04-15 12:25 ` Lars-Peter Clausen
2014-04-15 12:40 ` Boris BREZILLON
2014-04-15 12:40 ` Boris BREZILLON
2014-04-15 13:08 ` Lars-Peter Clausen
2014-04-15 13:08 ` Lars-Peter Clausen
2014-04-15 12:56 ` [RFC PATCH v2] regmap: smbus: add support for regmap over smbus Mark Brown
2014-04-15 12:56 ` Mark Brown
2014-04-15 13:34 ` Lars-Peter Clausen
2014-04-15 13:34 ` Lars-Peter Clausen
2014-04-15 16:46 ` Mark Brown
2014-04-15 16:46 ` Mark Brown
2014-04-15 19:18 ` Lars-Peter Clausen
2014-04-15 19:18 ` Lars-Peter Clausen
2014-04-15 22:38 ` Mark Brown
2014-04-15 22:38 ` Mark Brown
2014-04-16 8:16 ` [PATCH] regmap: i2c: fallback to SMBus if the adapter does not support standard I2C Boris BREZILLON
2014-04-16 8:16 ` Boris BREZILLON
2014-04-16 17:06 ` Mark Brown
2014-04-16 17:06 ` Mark Brown
2014-04-16 17:16 ` Boris BREZILLON
2014-04-16 17:16 ` Boris BREZILLON
2014-04-16 21:00 ` Mark Brown
2014-04-16 21:00 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=534D1DDA.40207@free-electrons.com \
--to=boris.brezillon@free-electrons.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.