All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomasz Duszynski <tduszyns@gmail.com>
To: Daniel Baluta <daniel.baluta@gmail.com>
Cc: Tomasz Duszynski <tduszyns@gmail.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald <pmeerw@pmeerw.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>
Subject: Re: [PATCH] iio: light: add support for ROHM BH1710/BH1715/BH1721/BH1750/BH1751 ambient light sensors
Date: Thu, 23 Apr 2015 21:42:17 +0200	[thread overview]
Message-ID: <20150423194217.GA24769@Arch.lan> (raw)
In-Reply-To: <CAEnQRZBNMZTT7oB8xV+NU1gJg9FJXi_gqJivt3X1hkDhrtkcAA@mail.gmail.com>

On Thu, Apr 23, 2015 at 10:30:09AM +0300, Daniel Baluta wrote:
> On Tue, Apr 21, 2015 at 9:43 PM, Tomasz Duszynski <tduszyns@gmail.com> wrote:
> > Add support for ROHM BH1710/BH1715/BH1721/BH1750/BH1751 ambient light
> > sensors.
> >
> > Signed-off-by: Tomasz Duszynski <tduszyns@gmail.com>
> > ---
> >  drivers/iio/light/Kconfig  |  10 ++
> >  drivers/iio/light/Makefile |   1 +
> >  drivers/iio/light/bh1750.c | 322 +++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 333 insertions(+)
> >  create mode 100644 drivers/iio/light/bh1750.c
> >
> > diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
> > index 5a3237b..9fb79ca 100644
> > --- a/drivers/iio/light/Kconfig
> > +++ b/drivers/iio/light/Kconfig
> > @@ -37,6 +37,16 @@ config APDS9300
> >          To compile this driver as a module, choose M here: the
> >          module will be called apds9300.
> >
> > +config BH1750
> > +       tristate "BH1750 ambient light sensor"
>
> Better use ROHM BH1750 .. here.
>
>
Did git blame on Kconfig and among newest sensors some
have this manufacturer prefix while others don't, but still no problem
for me to add that.
> > +static const struct iio_chan_spec bh1750_channels[] = {
> > +       {
> > +               .type = IIO_INTENSITY,
>
> Shouldn't this be IIO_LIGHT channel type?
>
> Users will get illuminance after multiplying raw value with scale.
>
That naming is misleading. Thanks for pointing this out.
> > +        .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> > +                                     BIT(IIO_CHAN_INFO_SCALE) |
> > +                                     BIT(IIO_CHAN_INFO_INT_TIME)
> > +       }
> > +};
> > +
> > +static int bh1750_probe(struct i2c_client *client,
> > +                       const struct i2c_device_id *id)
> > +{
> > +       int ret, usec;
> > +       struct bh1750_data *data;
> > +       struct iio_dev *indio_dev;
> > +
> > +       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C |
> > +                               I2C_FUNC_SMBUS_WRITE_BYTE))
> > +               return -ENODEV;
> > +
> > +       indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
> > +       if (!indio_dev)
> > +               return -ENOMEM;
> > +
> > +       data = iio_priv(indio_dev);
> > +       i2c_set_clientdata(client, indio_dev);
> > +       data->client = client;
> > +       data->chip_info = &chip_info_tbl[id->driver_data];
> > +
> > +       usec = data->chip_info->mtreg_to_usec * data->chip_info->mtreg_default;
> > +       ret = bh1750_change_int_time(data, usec);
> > +       if (ret < 0)
> > +               return ret;
> > +
> > +       mutex_init(&data->lock);
> > +       indio_dev->dev.parent = &client->dev;
> > +       indio_dev->info = &bh1750_info;
> > +       indio_dev->name = id->name;
> > +       indio_dev->channels = bh1750_channels;
> > +       indio_dev->num_channels = ARRAY_SIZE(bh1750_channels);
> > +       indio_dev->modes = INDIO_DIRECT_MODE;
> > +
> > +       return devm_iio_device_register(&client->dev, indio_dev);
>
> You need also to add a remove function where the chip is powered down. Then
> you shouldn't use devm_iio_device_register here, because you need to control
> the order of chip powerdown/ device unregister operations at remove.
>
Right.
> thanks,
> Daniel.

Thanks for review!

      reply	other threads:[~2015-04-23 19:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21 18:43 [PATCH] iio: light: add support for ROHM BH1710/BH1715/BH1721/BH1750/BH1751 ambient light sensors Tomasz Duszynski
2015-04-22  8:49 ` Peter Meerwald
2015-04-22 17:36   ` tduszyns
2015-04-23  7:30 ` Daniel Baluta
2015-04-23 19:42   ` Tomasz Duszynski [this message]

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=20150423194217.GA24769@Arch.lan \
    --to=tduszyns@gmail.com \
    --cc=daniel.baluta@gmail.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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.