[PATCH 3/3] misc: bmp085: Add missing platform data.

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

 




DT bindings contains more parameters to set so add them to platform data also
to have possibility to use on arch where DT isn't available yet.

Signed-off-by: Marek Belisko <marek@xxxxxxxxxxxxx>
---
 drivers/misc/bmp085.c      | 21 +++++++++++++++++----
 include/linux/i2c/bmp085.h |  7 +++++++
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/bmp085.c b/drivers/misc/bmp085.c
index 9792ce2..530b4a1 100644
--- a/drivers/misc/bmp085.c
+++ b/drivers/misc/bmp085.c
@@ -408,13 +408,15 @@ static void bmp085_get_of_properties(struct bmp085_data *data,
 		return;
 
 	if (!of_property_read_u32(np, "chip-id", &prop))
-		data->chip_id = prop & 0xff;
+		pdata->chip_id = prop & 0xff;
 
 	if (!of_property_read_u32(np, "temp-measurement-period", &prop))
-		data->temp_measurement_period = (prop/100)*HZ;
+		pdata->temp_measurement_period = (prop/100)*HZ;
 
 	if (!of_property_read_u32(np, "default-oversampling", &prop))
-		data->oversampling_setting = prop & 0xff;
+		pdata->default_oversampling = prop & 0xff;
+	else
+		pdata->default_oversampling = -1;
 
 	pdata->gpio = of_get_named_gpio(np, "gpio", 0);
 	of_property_read_u32(np, "irq", &pdata->irq);
@@ -443,9 +445,20 @@ static int bmp085_init_client(struct device *dev, struct bmp085_data *data)
 					GFP_KERNEL);
 		if (!pdata)
 			return -ENOMEM;
+
+		bmp085_get_of_properties(data, pdata);
 	}
 
-	bmp085_get_of_properties(data, pdata);
+	if (pdata->chip_id)
+		data->chip_id = pdata->chip_id;
+
+	if (pdata->temp_measurement_period > 0)
+		data->temp_measurement_period =
+			(pdata->temp_measurement_period/100)*HZ;
+
+	if (pdata->default_oversampling >= 0 &&
+		pdata->default_oversampling <= 3)
+		data->oversampling_setting = pdata->default_oversampling;
 
 	if (gpio_is_valid(pdata->gpio)) {
 		err = devm_gpio_request(dev, pdata->gpio, "bmp085_eoc_irq");
diff --git a/include/linux/i2c/bmp085.h b/include/linux/i2c/bmp085.h
index b66cb98..addb972 100644
--- a/include/linux/i2c/bmp085.h
+++ b/include/linux/i2c/bmp085.h
@@ -5,11 +5,18 @@
 
 /*
  * bmp085 platform data
+ * @chip_id: configurable chip id for non-default chip revisions
+ * @temp_measurement_period: in milliseconds
+ * @default_oversampling: used at startup, range is 0-3 with rising sensitivity
+ * set it to -1 when don't want to change default value (3)
  * @gpio: if is set it is the End Of Conversion line which is high when
  * conversion is finished
  * @irq: if gpio < 0 and irq > 0, then it is an interrupt with no gpio
  */
 struct bmp085_platform_data {
+	int	chip_id;
+	int	temp_measurement_period;
+	int	default_oversampling;
 	int	gpio;
 	int	irq;
 };
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux