[bug report] drivers:iio:dac: Add AD3552R driver support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Mihail Chindris,

The patch 8f2b54824b28: "drivers:iio:dac: Add AD3552R driver support"
from Dec 13, 2021, leads to the following Smatch static checker
warning:

	drivers/iio/dac/ad3552r.c:812 ad3552r_configure_custom_gain()
	warn: 'gain_child' is not an error pointer

drivers/iio/dac/ad3552r.c
    799 static int ad3552r_configure_custom_gain(struct ad3552r_desc *dac,
    800                                          struct fwnode_handle *child,
    801                                          u32 ch)
    802 {
    803         struct device *dev = &dac->spi->dev;
    804         struct fwnode_handle *gain_child;
    805         u32 val;
    806         int err;
    807         u8 addr;
    808         u16 reg = 0, offset;
    809 
    810         gain_child = fwnode_get_named_child_node(child,
    811                                                  "custom-output-range-config");
--> 812         if (IS_ERR(gain_child)) {

This should probably be a NULL check right?  return -EINVAL;?

    813                 dev_err(dev,
    814                         "mandatory custom-output-range-config property missing\n");
    815                 return PTR_ERR(gain_child);
    816         }
    817 
    818         dac->ch_data[ch].range_override = 1;
    819         reg |= ad3552r_field_prep(1, AD3552R_MASK_CH_RANGE_OVERRIDE);
    820 
    821         err = fwnode_property_read_u32(gain_child, "adi,gain-scaling-p", &val);
    822         if (err) {
    823                 dev_err(dev, "mandatory adi,gain-scaling-p property missing\n");
    824                 goto put_child;
    825         }
    826         reg |= ad3552r_field_prep(val, AD3552R_MASK_CH_GAIN_SCALING_P);
    827         dac->ch_data[ch].p = val;
    828 
    829         err = fwnode_property_read_u32(gain_child, "adi,gain-scaling-n", &val);
    830         if (err) {
    831                 dev_err(dev, "mandatory adi,gain-scaling-n property missing\n");
    832                 goto put_child;
    833         }
    834         reg |= ad3552r_field_prep(val, AD3552R_MASK_CH_GAIN_SCALING_N);
    835         dac->ch_data[ch].n = val;
    836 
    837         err = fwnode_property_read_u32(gain_child, "adi,rfb-ohms", &val);
    838         if (err) {
    839                 dev_err(dev, "mandatory adi,rfb-ohms property missing\n");
    840                 goto put_child;
    841         }
    842         dac->ch_data[ch].rfb = val;
    843 
    844         err = fwnode_property_read_u32(gain_child, "adi,gain-offset", &val);
    845         if (err) {
    846                 dev_err(dev, "mandatory adi,gain-offset property missing\n");
    847                 goto put_child;
    848         }
    849         dac->ch_data[ch].gain_offset = val;
    850 
    851         offset = abs((s32)val);
    852         reg |= ad3552r_field_prep((offset >> 8), AD3552R_MASK_CH_OFFSET_BIT_8);
    853 
    854         reg |= ad3552r_field_prep((s32)val < 0, AD3552R_MASK_CH_OFFSET_POLARITY);
    855         addr = AD3552R_REG_ADDR_CH_GAIN(ch);
    856         err = ad3552r_write_reg(dac, addr,
    857                                 offset & AD3552R_MASK_CH_OFFSET_BITS_0_7);
    858         if (err) {
    859                 dev_err(dev, "Error writing register\n");
    860                 goto put_child;
    861         }
    862 
    863         err = ad3552r_write_reg(dac, addr, reg);
    864         if (err) {
    865                 dev_err(dev, "Error writing register\n");
    866                 goto put_child;
    867         }
    868 
    869 put_child:
    870         fwnode_handle_put(gain_child);
    871 
    872         return err;
    873 }

regards,
dan carpenter



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux