From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Laxman Dewangan <ldewangan@nvidia.com>, linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio:magnetometer:ak8975 move out of staging
Date: Sun, 10 Feb 2013 11:58:16 +0000 [thread overview]
Message-ID: <51178B58.20603@kernel.org> (raw)
In-Reply-To: <51177476.3010307@metafoo.de>
On 02/10/2013 10:20 AM, Lars-Peter Clausen wrote:
> On 02/09/2013 05:55 PM, Jonathan Cameron wrote:
>> This driver has been clean and correct for quite some time.
>> It is simple and uses only straight forward standard
>> interfaces.
>>
>> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
>
> Two comments, which don't necessarily need to be addressed before moving it
> out of staging, but should probably should be fixed at some point.
>
>> ---
>> drivers/iio/magnetometer/Kconfig | 11 +
>> drivers/iio/magnetometer/Makefile | 1 +
>> drivers/iio/magnetometer/ak8975.c | 520 ++++++++++++++++++++++++++++++
>> drivers/staging/iio/magnetometer/Kconfig | 11 -
>> drivers/staging/iio/magnetometer/Makefile | 1 -
>> drivers/staging/iio/magnetometer/ak8975.c | 520 ------------------------------
>> 6 files changed, 532 insertions(+), 532 deletions(-)
>>
> [...]
>> +struct ak8975_data {
>> + struct i2c_client *client;
>> + struct attribute_group attrs;
>> + struct mutex lock;
>> + u8 asa[3];
>> + long raw_to_gauss[3];
>> + u8 reg_cache[AK8975_MAX_REGS];
>> + int eoc_gpio;
>> + int eoc_irq;
>
> eoc_irq is never really used.
Good spot, I'll put out a trivial patch to remove that before move
this driver.
>
>> +};
>> +
>> +static const int ak8975_index_to_reg[] = {
>> + AK8975_REG_HXL, AK8975_REG_HYL, AK8975_REG_HZL,
>> +};
>> +
>> +/*
>> + * Helper function to write to the I2C device's registers.
>> + */
>> +static int ak8975_write_data(struct i2c_client *client,
>> + u8 reg, u8 val, u8 mask, u8 shift)
>> +{
>> + struct iio_dev *indio_dev = i2c_get_clientdata(client);
>> + struct ak8975_data *data = iio_priv(indio_dev);
>> + u8 regval;
>> + int ret;
>> +
>> + regval = (data->reg_cache[reg] & ~mask) | (val << shift);
>> + ret = i2c_smbus_write_byte_data(client, reg, regval);
>> + if (ret < 0) {
>> + dev_err(&client->dev, "Write to device fails status %x\n", ret);
>> + return ret;
>> + }
>> + data->reg_cache[reg] = regval;
>
> The reg cache is written to here, but it is never read from again. It may
> make sense to convert the driver to using regmap instead of open-coding the
> register read/write functions.
It is used just above in this function to avoid a read when doing masked writes.
Using regmap might make sense but is not something I'm going to do without
hardware and in this case the gains will be pretty small.
Laxman, do you recall why we have the I2C_M_NOSTART in the driver? If nothing
else the ability to do that should be checked for as it's in the category of
protocol mangling.
>
>> +
>> + return 0;
>> +}
>> +
> [...]
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2013-02-10 11:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-09 16:55 [PATCH] iio:magnetometer:ak8975 move out of staging Jonathan Cameron
2013-02-10 10:20 ` Lars-Peter Clausen
2013-02-10 11:58 ` Jonathan Cameron [this message]
2013-02-10 12:14 ` Jonathan Cameron
2013-02-10 15:25 ` Lars-Peter Clausen
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=51178B58.20603@kernel.org \
--to=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=ldewangan@nvidia.com \
--cc=linux-iio@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox