Commit 7d17577d authored by Alexandru Ardelean's avatar Alexandru Ardelean Committed by Jonathan Cameron

iio: humidity: hts221: remove usage of iio_priv_to_dev()

We may want to get rid of the iio_priv_to_dev() helper. That's a bit
uncertain at this point. The reason is that we will hide some of the
members of the iio_dev structure (to prevent drivers from accessing them
directly), and that will also mean hiding the implementation of the
iio_priv_to_dev() helper inside the IIO core.

Hiding the implementation of iio_priv_to_dev() implies that some fast-paths
may not be fast anymore, so a general idea is to try to get rid of the
iio_priv_to_dev() altogether.

For this driver, removing the iio_priv_to_dev() helper means passing the
iio_dev object on hts221_allocate_buffers() & hts221_allocate_trigger().
Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 4de87f45
...@@ -46,7 +46,7 @@ extern const struct dev_pm_ops hts221_pm_ops; ...@@ -46,7 +46,7 @@ extern const struct dev_pm_ops hts221_pm_ops;
int hts221_probe(struct device *dev, int irq, const char *name, int hts221_probe(struct device *dev, int irq, const char *name,
struct regmap *regmap); struct regmap *regmap);
int hts221_set_enable(struct hts221_hw *hw, bool enable); int hts221_set_enable(struct hts221_hw *hw, bool enable);
int hts221_allocate_buffers(struct hts221_hw *hw); int hts221_allocate_buffers(struct iio_dev *iio_dev);
int hts221_allocate_trigger(struct hts221_hw *hw); int hts221_allocate_trigger(struct iio_dev *iio_dev);
#endif /* HTS221_H */ #endif /* HTS221_H */
...@@ -72,10 +72,10 @@ static irqreturn_t hts221_trigger_handler_thread(int irq, void *private) ...@@ -72,10 +72,10 @@ static irqreturn_t hts221_trigger_handler_thread(int irq, void *private)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
int hts221_allocate_trigger(struct hts221_hw *hw) int hts221_allocate_trigger(struct iio_dev *iio_dev)
{ {
struct hts221_hw *hw = iio_priv(iio_dev);
struct st_sensors_platform_data *pdata = dev_get_platdata(hw->dev); struct st_sensors_platform_data *pdata = dev_get_platdata(hw->dev);
struct iio_dev *iio_dev = iio_priv_to_dev(hw);
bool irq_active_low = false, open_drain = false; bool irq_active_low = false, open_drain = false;
unsigned long irq_type; unsigned long irq_type;
int err; int err;
...@@ -190,9 +190,10 @@ static irqreturn_t hts221_buffer_handler_thread(int irq, void *p) ...@@ -190,9 +190,10 @@ static irqreturn_t hts221_buffer_handler_thread(int irq, void *p)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
int hts221_allocate_buffers(struct hts221_hw *hw) int hts221_allocate_buffers(struct iio_dev *iio_dev)
{ {
return devm_iio_triggered_buffer_setup(hw->dev, iio_priv_to_dev(hw), struct hts221_hw *hw = iio_priv(iio_dev);
return devm_iio_triggered_buffer_setup(hw->dev, iio_dev,
NULL, hts221_buffer_handler_thread, NULL, hts221_buffer_handler_thread,
&hts221_buffer_ops); &hts221_buffer_ops);
} }
......
...@@ -621,11 +621,11 @@ int hts221_probe(struct device *dev, int irq, const char *name, ...@@ -621,11 +621,11 @@ int hts221_probe(struct device *dev, int irq, const char *name,
} }
if (hw->irq > 0) { if (hw->irq > 0) {
err = hts221_allocate_buffers(hw); err = hts221_allocate_buffers(iio_dev);
if (err < 0) if (err < 0)
return err; return err;
err = hts221_allocate_trigger(hw); err = hts221_allocate_trigger(iio_dev);
if (err) if (err)
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment