diff options
author | Lorenzo Bianconi <lorenzo.bianconi@redhat.com> | 2017-12-30 02:33:04 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-01-08 18:03:43 +0300 |
commit | e1ca114100b2b1409193eacc83fd12992eb4be23 (patch) | |
tree | 5a4ed604ca0f0d4c21d5462a3000362b42a61bdb /drivers/iio/humidity/hts221_core.c | |
parent | 2e419aec3b86aa76a34cb30ec4865060a6013366 (diff) | |
download | linux-e1ca114100b2b1409193eacc83fd12992eb4be23.tar.xz |
iio: humidity: hts221: move common code in hts221_core
Move duplicated i2c/spi probe code in hts221_probe()
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/iio/humidity/hts221_core.c')
-rw-r--r-- | drivers/iio/humidity/hts221_core.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c index daef177219b6..d3f7904766bd 100644 --- a/drivers/iio/humidity/hts221_core.c +++ b/drivers/iio/humidity/hts221_core.c @@ -581,12 +581,26 @@ static const struct iio_info hts221_info = { static const unsigned long hts221_scan_masks[] = {0x3, 0x0}; -int hts221_probe(struct iio_dev *iio_dev) +int hts221_probe(struct device *dev, int irq, const char *name, + const struct hts221_transfer_function *tf_ops) { - struct hts221_hw *hw = iio_priv(iio_dev); + struct iio_dev *iio_dev; + struct hts221_hw *hw; int err; u8 data; + iio_dev = devm_iio_device_alloc(dev, sizeof(*hw)); + if (!iio_dev) + return -ENOMEM; + + dev_set_drvdata(dev, (void *)iio_dev); + + hw = iio_priv(iio_dev); + hw->name = name; + hw->dev = dev; + hw->irq = irq; + hw->tf = tf_ops; + mutex_init(&hw->lock); err = hts221_check_whoami(hw); |