lkml.org 
[lkml]   [2013]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] mfd: tps6586x: add version detection
Am 2013-11-27 17:58, schrieb Stephen Warren:
<snip>
>> + tps6586x = devm_kzalloc(&client->dev, sizeof(*tps6586x), GFP_KERNEL);
>> + if (tps6586x == NULL) {
>> + dev_err(&client->dev, "memory for tps6586x alloc failed\n");
>> + return -ENOMEM;
>> + }
>
>> + tps6586x->version = (enum tps6586x_version)ret;
>
> Why not make the version variable an integer of some kind. Then, the
> cast wouldn't be required. The values like TPS658621A can be #defines or
> const u32.
>
Yep this would work too. Whatever is preferred, maybe define would be
more consistent since SLEW_RATE are defines too (both, the VERSIONCRC
and SLEW_RATE values are possible content of registers).

>> + switch (ret) {
>
> That should switch on tps6586x->version since that's been assigned;
> it'll make the purpose a bit clearer.
>
>> + default:
>> + name = "TPS6586X";
>> + break;
>> }
>
> I hope the rest of the code deals with unknown values of
> tps6586x->version OK.
>
Well, the tps6586x->version is not completly unknown, its something
valid which is returned by i2c_smbus_read_byte_data. According to the
data sheet this should be a 8-Bit value.

However, the patch should handle every version, since I tried to make
the change backward compatible: The driver now and then supports every
device version, just the default voltage table are applied if there are
no specific tables available.


\
 
 \ /
  Last update: 2013-11-27 23:01    [W:0.127 / U:23.540 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site