Skip to content

Commit da83fd1

Browse files
andy-shevjic23
authored andcommitted
iio: imu: st_lsm6dsx: Remove useless dev_fwnode() calls
The device property APIs designed that way that they will return an error when there is no valid fwnode provided. Moreover, the check for NULL of dev_fwnode() is not fully correct as in some (currently rare) cases it may contain an error pointer. This is not a problem anyway (see keyword 'valid' above) that's why the code works properly even without this change. Signed-off-by: Andy Shevchenko <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 17601ab commit da83fd1

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,25 +2127,15 @@ static const struct iio_info st_lsm6dsx_gyro_info = {
21272127
.write_raw_get_fmt = st_lsm6dsx_write_raw_get_fmt,
21282128
};
21292129

2130-
static int st_lsm6dsx_get_drdy_pin(struct st_lsm6dsx_hw *hw, int *drdy_pin)
2131-
{
2132-
struct device *dev = hw->dev;
2133-
2134-
if (!dev_fwnode(dev))
2135-
return -EINVAL;
2136-
2137-
return device_property_read_u32(dev, "st,drdy-int-pin", drdy_pin);
2138-
}
2139-
21402130
static int
21412131
st_lsm6dsx_get_drdy_reg(struct st_lsm6dsx_hw *hw,
21422132
const struct st_lsm6dsx_reg **drdy_reg)
21432133
{
2134+
struct device *dev = hw->dev;
21442135
int err = 0, drdy_pin;
21452136

2146-
if (st_lsm6dsx_get_drdy_pin(hw, &drdy_pin) < 0) {
2137+
if (device_property_read_u32(dev, "st,drdy-int-pin", &drdy_pin) < 0) {
21472138
struct st_sensors_platform_data *pdata;
2148-
struct device *dev = hw->dev;
21492139

21502140
pdata = (struct st_sensors_platform_data *)dev->platform_data;
21512141
drdy_pin = pdata ? pdata->drdy_int_pin : 1;
@@ -2180,7 +2170,7 @@ static int st_lsm6dsx_init_shub(struct st_lsm6dsx_hw *hw)
21802170
hub_settings = &hw->settings->shub_settings;
21812171

21822172
pdata = (struct st_sensors_platform_data *)dev->platform_data;
2183-
if ((dev_fwnode(dev) && device_property_read_bool(dev, "st,pullups")) ||
2173+
if (device_property_read_bool(dev, "st,pullups") ||
21842174
(pdata && pdata->pullups)) {
21852175
if (hub_settings->pullup_en.sec_page) {
21862176
err = st_lsm6dsx_set_page(hw, true);
@@ -2565,7 +2555,7 @@ static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw)
25652555
return err;
25662556

25672557
pdata = (struct st_sensors_platform_data *)dev->platform_data;
2568-
if ((dev_fwnode(dev) && device_property_read_bool(dev, "drive-open-drain")) ||
2558+
if (device_property_read_bool(dev, "drive-open-drain") ||
25692559
(pdata && pdata->open_drain)) {
25702560
reg = &hw->settings->irq_config.od;
25712561
err = regmap_update_bits(hw->regmap, reg->addr, reg->mask,
@@ -2693,8 +2683,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
26932683

26942684
hub_settings = &hw->settings->shub_settings;
26952685
if (hub_settings->master_en.addr &&
2696-
(!dev_fwnode(dev) ||
2697-
!device_property_read_bool(dev, "st,disable-sensor-hub"))) {
2686+
!device_property_read_bool(dev, "st,disable-sensor-hub")) {
26982687
err = st_lsm6dsx_shub_probe(hw, name);
26992688
if (err < 0)
27002689
return err;
@@ -2735,7 +2724,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
27352724
return err;
27362725
}
27372726

2738-
if ((dev_fwnode(dev) && device_property_read_bool(dev, "wakeup-source")) ||
2727+
if (device_property_read_bool(dev, "wakeup-source") ||
27392728
(pdata && pdata->wakeup_source))
27402729
device_init_wakeup(dev, true);
27412730

0 commit comments

Comments
 (0)