[PATCH]staging:iio:ad799x make use of platform_data optional

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

 



Setting Vref with platform_data is a neat feature, though it is not essential
for operating these devices. So make the use of platform_data optional and set
default value of 1000 mV if nothing else is defined.

Signed-off-by: Hartmut Knaack <knaack.h@xxxxxx>
---
diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c
index 9428be8..e32a555 100644
--- a/drivers/staging/iio/adc/ad799x_core.c
+++ b/drivers/staging/iio/adc/ad799x_core.c
@@ -545,10 +545,12 @@ static int ad799x_probe(struct i2c_client *client,
 
 	/* TODO: Add pdata options for filtering and bit delay */
 
-	if (!pdata)
-		return -EINVAL;
-
-	st->int_vref_mv = pdata->vref_mv;
+	if ((!pdata) || (!pdata->vref_mv)) {
+		dev_warn(&client->dev,
+			 "No platform data found, setting Vref to 1000 mV\n");
+		st->int_vref_mv = 1000;
+	} else
+		st->int_vref_mv = pdata->vref_mv;
 
 	st->reg = devm_regulator_get(&client->dev, "vcc");
 	if (!IS_ERR(st->reg)) {
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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