Skip to content

Commit

Permalink
iio: adc: xilinx-xadc: Drop duplicate NULL check in xadc_parse_dt()
Browse files Browse the repository at this point in the history
The fwnode_for_each_child_node() is NULL-aware, no need to check
its parameters outside. Drop duplicate NULL check in xadc_parse_dt().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220531141118.64540-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
  • Loading branch information
Andy Shevchenko authored and Jonathan Cameron committed Jul 13, 2022
1 parent 59b2947 commit 568f686
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions drivers/iio/adc/xilinx-xadc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1247,30 +1247,28 @@ static int xadc_parse_dt(struct iio_dev *indio_dev, unsigned int *conf, int irq)
chan = &channels[9];

chan_node = device_get_named_child_node(dev, "xlnx,channels");
if (chan_node) {
fwnode_for_each_child_node(chan_node, child) {
if (num_channels >= max_channels) {
fwnode_handle_put(child);
break;
}
fwnode_for_each_child_node(chan_node, child) {
if (num_channels >= max_channels) {
fwnode_handle_put(child);
break;
}

ret = fwnode_property_read_u32(child, "reg", &reg);
if (ret || reg > 16)
continue;
ret = fwnode_property_read_u32(child, "reg", &reg);
if (ret || reg > 16)
continue;

if (fwnode_property_read_bool(child, "xlnx,bipolar"))
chan->scan_type.sign = 's';
if (fwnode_property_read_bool(child, "xlnx,bipolar"))
chan->scan_type.sign = 's';

if (reg == 0) {
chan->scan_index = 11;
chan->address = XADC_REG_VPVN;
} else {
chan->scan_index = 15 + reg;
chan->address = XADC_REG_VAUX(reg - 1);
}
num_channels++;
chan++;
if (reg == 0) {
chan->scan_index = 11;
chan->address = XADC_REG_VPVN;
} else {
chan->scan_index = 15 + reg;
chan->address = XADC_REG_VAUX(reg - 1);
}
num_channels++;
chan++;
}
fwnode_handle_put(chan_node);

Expand Down

0 comments on commit 568f686

Please sign in to comment.