All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Matt Ranostay <mranostay@gmail.com>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Matt Ranostay <matt.ranostay@intel.com>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>
Subject: Re: [PATCH 1/3] iio: pressure: bmp280: add initial support for multiple chips
Date: Sun, 17 Apr 2016 12:51:16 +0100	[thread overview]
Message-ID: <571378B4.4060709@kernel.org> (raw)
In-Reply-To: <CAKzfze9GLqEUXhnVvOxbV9jf+8G6ZUDHRf2-w4g2WpWVyReYmw@mail.gmail.com>

On 12/04/16 06:27, Matt Ranostay wrote:
> Ah noticed that just now... ironically I was thinking about submitting
> this last night :)
> 
Life's like that sometimes.  Anyhow, please rebase on Akinobu's
series once he's sent a V2.

Bad luck!

Jonathan

p.s. The silly thing here is that I review backwards from latest emails
so you might well have gotten merged if Peter hadn't pointed this out!

> On Mon, Apr 11, 2016 at 10:23 PM, Peter Meerwald-Stadler
> <pmeerw@pmeerw.net> wrote:
>>
>>> Bosch has several chipsets that use BMP280 as core features, this enables
>>> chip information for each variant.
>>
>> these patches clash with work to add BMP180 to the same driver, Akinobu
>> Mita was first :)
>>
>>> Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
>>> ---
>>>  drivers/iio/pressure/bmp280.c | 59 +++++++++++++++++++++++++++++++++++++++----
>>>  1 file changed, 54 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/iio/pressure/bmp280.c b/drivers/iio/pressure/bmp280.c
>>> index a2602d8dd6d5..2e7cff38f5ff 100644
>>> --- a/drivers/iio/pressure/bmp280.c
>>> +++ b/drivers/iio/pressure/bmp280.c
>>> @@ -66,12 +66,15 @@
>>>  #define BMP280_MODE_NORMAL           (BIT(1) | BIT(0))
>>>
>>>  #define BMP280_CHIP_ID                       0x58
>>> +#define BME280_CHIP_ID                       0x60
>>> +
>>>  #define BMP280_SOFT_RESET_VAL                0xB6
>>>
>>>  struct bmp280_data {
>>>       struct i2c_client *client;
>>>       struct mutex lock;
>>>       struct regmap *regmap;
>>> +     struct bmp280_chip_info *chip;
>>>
>>>       /*
>>>        * Carryover value from temperature conversion, used in pressure
>>> @@ -80,6 +83,24 @@ struct bmp280_data {
>>>       s32 t_fine;
>>>  };
>>>
>>> +enum { bmp280, bme280 };
>>> +
>>> +struct bmp280_chip_info {
>>> +     int id;
>>> +     int num_channels;
>>> +};
>>> +
>>> +static struct bmp280_chip_info bmp280_chip_info_table[] = {
>>> +     [bmp280] = {
>>> +             .id = BMP280_CHIP_ID,
>>> +             .num_channels = 2,
>>> +     },
>>> +     [bme280] = {
>>> +             .id = BME280_CHIP_ID,
>>> +             .num_channels = 2,
>>> +     },
>>> +};
>>> +
>>>  /*
>>>   * These enums are used for indexing into the array of compensation
>>>   * parameters.
>>> @@ -344,6 +365,20 @@ static int bmp280_chip_init(struct bmp280_data *data)
>>>       return ret;
>>>  }
>>>
>>> +static int bmp280_match_acpi_device(struct device *dev,
>>> +                                 struct bmp280_chip_info **chipset)
>>> +{
>>> +     const struct acpi_device_id *id;
>>> +
>>> +     id = acpi_match_device(dev->driver->acpi_match_table, dev);
>>> +     if (!id)
>>> +             return -ENODEV;
>>> +
>>> +     *chipset = &bmp280_chip_info_table[id->driver_data];
>>> +
>>> +     return 0;
>>> +}
>>> +
>>>  static int bmp280_probe(struct i2c_client *client,
>>>                       const struct i2c_device_id *id)
>>>  {
>>> @@ -357,13 +392,25 @@ static int bmp280_probe(struct i2c_client *client,
>>>               return -ENOMEM;
>>>
>>>       data = iio_priv(indio_dev);
>>> +
>>> +     if (id) {
>>> +             data->chip = &bmp280_chip_info_table[id->driver_data];
>>> +     } else if (ACPI_HANDLE(&client->dev)) {
>>> +             ret = bmp280_match_acpi_device(&client->dev, &data->chip);
>>> +             if (ret < 0)
>>> +                     return ret;
>>> +     } else {
>>> +             /* Don't break sysfs registration of BMP280 devices */
>>> +             data->chip = &bmp280_chip_info_table[bmp280];
>>> +     }
>>> +
>>>       mutex_init(&data->lock);
>>>       data->client = client;
>>>
>>>       indio_dev->dev.parent = &client->dev;
>>>       indio_dev->name = id->name;
>>>       indio_dev->channels = bmp280_channels;
>>> -     indio_dev->num_channels = ARRAY_SIZE(bmp280_channels);
>>> +     indio_dev->num_channels = data->chip->num_channels;
>>>       indio_dev->info = &bmp280_info;
>>>       indio_dev->modes = INDIO_DIRECT_MODE;
>>>
>>> @@ -376,9 +423,9 @@ static int bmp280_probe(struct i2c_client *client,
>>>       ret = regmap_read(data->regmap, BMP280_REG_ID, &chip_id);
>>>       if (ret < 0)
>>>               return ret;
>>> -     if (chip_id != BMP280_CHIP_ID) {
>>> +     if (chip_id != data->chip->id) {
>>>               dev_err(&client->dev, "bad chip id.  expected %x got %x\n",
>>> -                     BMP280_CHIP_ID, chip_id);
>>> +                     data->chip->id, chip_id);
>>>               return -EINVAL;
>>>       }
>>>
>>> @@ -390,13 +437,15 @@ static int bmp280_probe(struct i2c_client *client,
>>>  }
>>>
>>>  static const struct acpi_device_id bmp280_acpi_match[] = {
>>> -     {"BMP0280", 0},
>>> +     {"BMP0280", bmp280},
>>> +     {"BME0280", bme280},
>>>       { },
>>>  };
>>>  MODULE_DEVICE_TABLE(acpi, bmp280_acpi_match);
>>>
>>>  static const struct i2c_device_id bmp280_id[] = {
>>> -     {"bmp280", 0},
>>> +     {"bmp280", bmp280},
>>> +     {"bme280", bme280},
>>>       { },
>>>  };
>>>  MODULE_DEVICE_TABLE(i2c, bmp280_id);
>>>
>>
>> --
>>
>> Peter Meerwald-Stadler
>> +43-664-2444418 (mobile)
>> --
>> 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
> --
> 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
> 


  reply	other threads:[~2016-04-17 11:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-12  5:21 [PATCH 0/3] iio: pressure: bmp280: add BME280 part support Matt Ranostay
2016-04-12  5:21 ` [PATCH 1/3] iio: pressure: bmp280: add initial support for multiple chips Matt Ranostay
2016-04-12  5:23   ` Peter Meerwald-Stadler
2016-04-12  5:27     ` Matt Ranostay
2016-04-17 11:51       ` Jonathan Cameron [this message]
2016-04-12  5:21 ` [PATCH 2/3] iio: pressure: bmp280: add per chip initialize function pointer Matt Ranostay
2016-04-12  5:17   ` Peter Meerwald-Stadler
2016-04-12  5:21 ` [PATCH 3/3] iio: pressure: bmp280: add humidity support Matt Ranostay
2016-04-12  5:21   ` Peter Meerwald-Stadler
2016-04-12  5:42     ` Matt Ranostay

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=571378B4.4060709@kernel.org \
    --to=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=matt.ranostay@intel.com \
    --cc=mranostay@gmail.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 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.