From: Dan Carpenter <dan.carpenter@oracle.com>
To: mihail.chindris@analog.com
Cc: linux-iio@vger.kernel.org
Subject: [bug report] drivers:iio:dac: Add AD3552R driver support
Date: Fri, 1 Apr 2022 13:06:01 +0300 [thread overview]
Message-ID: <20220401100601.GA29860@kili> (raw)
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
next reply other threads:[~2022-04-01 10:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-01 10:06 Dan Carpenter [this message]
2022-04-01 12:07 ` [bug report] drivers:iio:dac: Add AD3552R driver support Sa, Nuno
-- strict thread matches above, loose matches on Subject: below --
2022-01-06 10:35 Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220401100601.GA29860@kili \
--to=dan.carpenter@oracle.com \
--cc=linux-iio@vger.kernel.org \
--cc=mihail.chindris@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox