diff mbox series

iio: adc: ti-ads1015: Use correct pga upper bound

Message ID 20240106174836.1086714-1-mab.kernel@gmail.com (mailing list archive)
State Accepted
Headers show
Series iio: adc: ti-ads1015: Use correct pga upper bound | expand

Commit Message

Mohammed Billoo Jan. 6, 2024, 5:48 p.m. UTC
The devicetree binding and datasheets (for both the ADS1015 and
ADS1115) show that the PGA index should have a maximum value of 5,
and not 6.

Signed-off-by: Mohammed Billoo <mab.kernel@gmail.com>
---
 drivers/iio/adc/ti-ads1015.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jonathan Cameron Jan. 7, 2024, 4:15 p.m. UTC | #1
On Sat,  6 Jan 2024 12:48:35 -0500
Mohammed Billoo <mab.kernel@gmail.com> wrote:

> The devicetree binding and datasheets (for both the ADS1015 and
> ADS1115) show that the PGA index should have a maximum value of 5,
> and not 6.
> 
> Signed-off-by: Mohammed Billoo <mab.kernel@gmail.com>

Hi Mohammed,

Seems correct, but I'm curious - did you see an actual problem with
setting the value to 6?  From my reading of the ads1115 datasheet
6 and 7 should be functionally identical to 5.

Anyhow, good to clean it up anyway so applied to the togreg branch of
iio.git but that tree will be rebased on rc1 once available so for
now I'll just push it as testing for 0-day to get started on testing it.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/ti-ads1015.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
> index 6799ea49dbc7..6ae967e4d8fa 100644
> --- a/drivers/iio/adc/ti-ads1015.c
> +++ b/drivers/iio/adc/ti-ads1015.c
> @@ -925,7 +925,7 @@ static int ads1015_client_get_channels_config(struct i2c_client *client)
>  
>  		if (!fwnode_property_read_u32(node, "ti,gain", &pval)) {
>  			pga = pval;
> -			if (pga > 6) {
> +			if (pga > 5) {
>  				dev_err(dev, "invalid gain on %pfw\n", node);
>  				fwnode_handle_put(node);
>  				return -EINVAL;
Mohammed Billoo Jan. 8, 2024, 1:37 p.m. UTC | #2
> Seems correct, but I'm curious - did you see an actual problem with
> setting the value to 6?  From my reading of the ads1115 datasheet
> 6 and 7 should be functionally identical to 5.

Hi Jonathan,

No, the behavior was fine. When I was trying to adjust the voltage range via the
pga setting, I noticed that the implementation didn't match the comment in the binding
for the max value.
diff mbox series

Patch

diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index 6799ea49dbc7..6ae967e4d8fa 100644
--- a/drivers/iio/adc/ti-ads1015.c
+++ b/drivers/iio/adc/ti-ads1015.c
@@ -925,7 +925,7 @@  static int ads1015_client_get_channels_config(struct i2c_client *client)
 
 		if (!fwnode_property_read_u32(node, "ti,gain", &pval)) {
 			pga = pval;
-			if (pga > 6) {
+			if (pga > 5) {
 				dev_err(dev, "invalid gain on %pfw\n", node);
 				fwnode_handle_put(node);
 				return -EINVAL;