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 07/11] iio:bma180: Introduce part_info to differentiate further chip variants
Date: Sun, 14 Sep 2014 20:22:58 +0100 [thread overview]
Message-ID: <5415EB12.3080203@kernel.org> (raw)
In-Reply-To: <5415EA7C.2020200@kernel.org>
On 14/09/14 20:20, Jonathan Cameron wrote:
> On 19/08/14 23:43, Peter Meerwald wrote:
>> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
>> Cc: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
> applied
Actually - one minor fixlet.
>> ---
>> drivers/iio/accel/bma180.c | 41 ++++++++++++++++++++++++++++++++---------
>> 1 file changed, 32 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
>> index 5838318..fc7c7b8 100644
>> --- a/drivers/iio/accel/bma180.c
>> +++ b/drivers/iio/accel/bma180.c
>> @@ -26,6 +26,19 @@
>> #define BMA180_DRV_NAME "bma180"
>> #define BMA180_IRQ_NAME "bma180_event"
>>
>> +enum {
>> + BMA180,
>> +};
>> +
>> +struct bma180_part_info {
>> + const struct iio_chan_spec *channels;
>> + unsigned num_channels;
>> + const int *scale_table;
>> + unsigned num_scales;
>> + const int *bw_table;
>> + unsigned num_bw;
>> +};
>> +
>> /* Register set */
>> #define BMA180_CHIP_ID 0x00 /* Need to distinguish BMA180 from other */
>> #define BMA180_ACC_X_LSB 0x02 /* First of 6 registers of accel data */
>> @@ -77,6 +90,7 @@
>> struct bma180_data {
>> struct i2c_client *client;
>> struct iio_trigger *trig;
>> + const struct bma180_part_info *part_info;
>> struct mutex mutex;
>> bool sleep_state;
>> int scale;
>> @@ -193,8 +207,8 @@ static int bma180_set_bw(struct bma180_data *data, int val)
>> if (data->sleep_state)
>> return -EBUSY;
>>
>> - for (i = 0; i < ARRAY_SIZE(bma180_bw_table); ++i) {
>> - if (bma180_bw_table[i] == val) {
>> + for (i = 0; i < data->part_info->num_bw; ++i) {
>> + if (data->part_info->bw_table[i] == val) {
>> ret = bma180_set_bits(data,
>> BMA180_BW_TCS, BMA180_BW, i);
>> if (ret) {
>> @@ -217,8 +231,8 @@ static int bma180_set_scale(struct bma180_data *data, int val)
>> if (data->sleep_state)
>> return -EBUSY;
>>
>> - for (i = 0; i < ARRAY_SIZE(bma180_scale_table); ++i)
>> - if (bma180_scale_table[i] == val) {
>> + for (i = 0; i < data->part_info->num_scales; ++i)
>> + if (data->part_info->scale_table[i] == val) {
>> ret = bma180_set_bits(data,
>> BMA180_OFFSET_LSB1, BMA180_RANGE, i);
>> if (ret) {
>> @@ -488,6 +502,14 @@ static const struct iio_chan_spec bma180_channels[] = {
>> IIO_CHAN_SOFT_TIMESTAMP(4),
>> };
>>
>> +static const struct bma180_part_info bma180_part_info[] = {
>> + [BMA180] = {
>> + bma180_channels, ARRAY_SIZE(bma180_channels),
>> + bma180_scale_table, ARRAY_SIZE(bma180_scale_table),
>> + bma180_bw_table, ARRAY_SIZE(bma180_bw_table),
>> + },
>> +};
>> +
>> static irqreturn_t bma180_trigger_handler(int irq, void *p)
>> {
>> struct iio_poll_func *pf = p;
>> @@ -554,6 +576,7 @@ static int bma180_probe(struct i2c_client *client,
>> data = iio_priv(indio_dev);
>> i2c_set_clientdata(client, indio_dev);
>> data->client = client;
>> + data->part_info = &bma180_part_info[id->driver_data];
>>
>> ret = bma180_chip_init(data);
>> if (ret < 0)
>> @@ -562,8 +585,8 @@ static int bma180_probe(struct i2c_client *client,
>> mutex_init(&data->mutex);
>>
>> indio_dev->dev.parent = &client->dev;
>> - indio_dev->channels = bma180_channels;
>> - indio_dev->num_channels = ARRAY_SIZE(bma180_channels);
>> + indio_dev->channels = data->part_info->channels;
>> + indio_dev->num_channels = data->part_info->num_channels;
>> indio_dev->name = BMA180_DRV_NAME;
>> indio_dev->modes = INDIO_DIRECT_MODE;
>> indio_dev->info = &bma180_info;
>> @@ -674,8 +697,8 @@ static SIMPLE_DEV_PM_OPS(bma180_pm_ops, bma180_suspend, bma180_resume);
>> #define BMA180_PM_OPS NULL
>> #endif
>>
>> -static struct i2c_device_id bma180_id[] = {
>> - { BMA180_DRV_NAME, 0 },
>> +static struct i2c_device_id bma180_ids[] = {
>> + { BMA180_DRV_NAME, BMA180 },
>> { }
>> };
You didn't update the module_device_id reference to bma180_id.
Fixed up in tree.
>>
>> @@ -689,7 +712,7 @@ static struct i2c_driver bma180_driver = {
>> },
>> .probe = bma180_probe,
>> .remove = bma180_remove,
>> - .id_table = bma180_id,
>> + .id_table = bma180_ids,
>> };
>>
>> module_i2c_driver(bma180_driver);
>>
> --
> 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:23 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 [this message]
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
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=5415EB12.3080203@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).