From: Jonathan Cameron <jic23@kernel.org>
To: Peter Meerwald <pmeerw@pmeerw.net>
Cc: linux-iio@vger.kernel.org,
Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
Subject: Re: [PATCH v2 08/11] iio:bma180: Introduce part-specific _config() and disable() code
Date: Sun, 14 Sep 2014 20:25:25 +0100 [thread overview]
Message-ID: <5415EBA5.4090901@kernel.org> (raw)
In-Reply-To: <5415EA84.6050005@kernel.org>
On 14/09/14 20:20, Jonathan Cameron wrote:
> On 19/08/14 23:43, Peter Meerwald wrote:
>> move part of bma180_init() to bma180_config() (split initialization and
>> configuration code); configuration is heavily chip-specific
>>
>> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
>> Cc: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
> applied
Actually - minor fixlet in here as well.
>> ---
>> drivers/iio/accel/bma180.c | 31 +++++++++++++++++++++----------
>> 1 file changed, 21 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
>> index fc7c7b8..a25b060 100644
>> --- a/drivers/iio/accel/bma180.c
>> +++ b/drivers/iio/accel/bma180.c
>> @@ -37,6 +37,8 @@ struct bma180_part_info {
>> unsigned num_scales;
>> const int *bw_table;
>> unsigned num_bw;
>> + int (*chip_config)(struct bma180_data *data);
>> + void (*chip_disable)(struct bma180_data *data);
struct bma180_data hasn't been defined yet. I've added a forward definition above this
to fix that up rather that reordering the rest of the file.
Jonathan
>> };
>>
>> /* Register set */
>> @@ -279,21 +281,28 @@ static int bma180_chip_init(struct bma180_data *data)
>> int ret = i2c_smbus_read_byte_data(data->client, BMA180_CHIP_ID);
>>
>> if (ret < 0)
>> - goto err;
>> - if (ret != BMA180_ID_REG_VAL) {
>> - ret = -ENODEV;
>> - goto err;
>> - }
>> + return ret;
>> + if (ret != BMA180_ID_REG_VAL)
>> + return -ENODEV;
>>
>> ret = bma180_soft_reset(data);
>> if (ret)
>> - goto err;
>> + return ret;
>> /*
>> * No serial transaction should occur within minimum 10 us
>> * after soft_reset command
>> */
>> msleep(20);
>>
>> + return 0;
>> +}
>> +
>> +static int bma180_chip_config(struct bma180_data *data)
>> +{
>> + int ret = bma180_chip_init(data);
>> +
>> + if (ret)
>> + goto err;
>> ret = bma180_set_bits(data, BMA180_CTRL_REG0, BMA180_DIS_WAKE_UP, 1);
>> if (ret)
>> goto err;
>> @@ -319,7 +328,7 @@ static int bma180_chip_init(struct bma180_data *data)
>> return 0;
>>
>> err:
>> - dev_err(&data->client->dev, "failed to init the chip\n");
>> + dev_err(&data->client->dev, "failed to config the chip\n");
>> return ret;
>> }
>>
>> @@ -507,6 +516,8 @@ static const struct bma180_part_info bma180_part_info[] = {
>> bma180_channels, ARRAY_SIZE(bma180_channels),
>> bma180_scale_table, ARRAY_SIZE(bma180_scale_table),
>> bma180_bw_table, ARRAY_SIZE(bma180_bw_table),
>> + bma180_chip_config,
>> + bma180_chip_disable,
>> },
>> };
>>
>> @@ -578,7 +589,7 @@ static int bma180_probe(struct i2c_client *client,
>> data->client = client;
>> data->part_info = &bma180_part_info[id->driver_data];
>>
>> - ret = bma180_chip_init(data);
>> + ret = data->part_info->chip_config(data);
>> if (ret < 0)
>> goto err_chip_disable;
>>
>> @@ -640,7 +651,7 @@ err_trigger_unregister:
>> err_trigger_free:
>> iio_trigger_free(data->trig);
>> err_chip_disable:
>> - bma180_chip_disable(data);
>> + data->part_info->chip_disable(data);
>>
>> return ret;
>> }
>> @@ -658,7 +669,7 @@ static int bma180_remove(struct i2c_client *client)
>> }
>>
>> mutex_lock(&data->mutex);
>> - bma180_chip_disable(data);
>> + data->part_info->chip_disable(data);
>> mutex_unlock(&data->mutex);
>>
>> 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:[~2014-09-14 19:25 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-19 22:43 [PATCH v2 00/11] iio:bma180: Add BMA250 support v2 Peter Meerwald
2014-08-19 22:43 ` [PATCH v2 01/11] iio:bma180: Enable use of device without IRQ Peter Meerwald
2014-09-14 17:47 ` Jonathan Cameron
2014-08-19 22:43 ` [PATCH v2 02/11] iio:bma180: Prefix remaining tables and functions with bma18_ Peter Meerwald
2014-09-14 17:47 ` Jonathan Cameron
2014-08-19 22:43 ` [PATCH v2 03/11] iio:bma180: Rename BMA_180 to BMA180_ Peter Meerwald
2014-09-14 17:48 ` Jonathan Cameron
2014-08-19 22:43 ` [PATCH v2 04/11] iio:bma180: Use bool instead of int for state Peter Meerwald
2014-09-14 17:48 ` Jonathan Cameron
2014-08-19 22:43 ` [PATCH v2 05/11] iio:bma180: Expose temperature channel Peter Meerwald
2014-08-20 8:56 ` Daniel Baluta
2014-08-19 22:43 ` [PATCH v2 06/11] iio:bma180: Drop _update_scan_mode() Peter Meerwald
2014-09-14 19:20 ` Jonathan Cameron
2014-08-19 22:43 ` [PATCH v2 07/11] iio:bma180: Introduce part_info to differentiate further chip variants Peter Meerwald
2014-09-14 19:20 ` Jonathan Cameron
2014-09-14 19:22 ` Jonathan Cameron
2014-08-19 22:43 ` [PATCH v2 08/11] iio:bma180: Introduce part-specific _config() and disable() code Peter Meerwald
2014-09-14 19:20 ` Jonathan Cameron
2014-09-14 19:25 ` Jonathan Cameron [this message]
2014-08-19 22:43 ` [PATCH v2 09/11] iio:bma180: Prepare for accelerometer channels with different resolutions Peter Meerwald
2014-09-14 19:26 ` Jonathan Cameron
2014-08-19 22:43 ` [PATCH v2 10/11] iio:bma180: Implement _available sysfs attribute dynamically Peter Meerwald
2014-09-14 19:26 ` Jonathan Cameron
2014-08-19 22:43 ` [PATCH v2 11/11] iio:bma180: Add BMA250 chip support Peter Meerwald
2014-09-14 19:28 ` Jonathan Cameron
2014-09-14 20:00 ` Peter Meerwald
2014-09-14 20:41 ` Jonathan Cameron
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=5415EBA5.4090901@kernel.org \
--to=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=o.v.kravchenko@globallogic.com \
--cc=pmeerw@pmeerw.net \
/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;
as well as URLs for NNTP newsgroup(s).