* [PATCHv3 0/3] bmp085: add support for bmp18x chip
@ 2012-04-04 19:45 Eric Andersson
2012-04-04 19:45 ` [PATCHv3 1/3] misc: clean up bmp085 driver Eric Andersson
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Eric Andersson @ 2012-04-04 19:45 UTC (permalink / raw)
To: linux-kernel
Cc: gregkh, alan, arnd, zhengguang.guo, peter.moeller, stefan.nilsson,
broonie, Eric Andersson
Hi,
This is version 3 of the patch-set that adds support for the latest pressure
sensors from Bosch Sensortec.
Changes from last version:
- Dropped the platform data in favor of devicetree properties.
- Use regmap as communication layer.
- Changed Kconfig logic.
- Keep the original bmp085 file name.
- Use EXPORT_SYMBOL_GPL.
--
Best regards,
Eric
http://www.unixphere.com
Eric Andersson (3):
misc: clean up bmp085 driver
misc: bmp085: add device tree properties
misc: add support for bmp18x chips to the bmp085 driver
Documentation/devicetree/bindings/misc/bmp085.txt | 20 ++
drivers/misc/Kconfig | 26 ++-
drivers/misc/Makefile | 2 +
drivers/misc/bmp085-i2c.c | 87 +++++
drivers/misc/bmp085-spi.c | 89 +++++
drivers/misc/bmp085.c | 356 +++++++++++----------
drivers/misc/bmp085.h | 33 ++
7 files changed, 434 insertions(+), 179 deletions(-)
create mode 100644 Documentation/devicetree/bindings/misc/bmp085.txt
create mode 100644 drivers/misc/bmp085-i2c.c
create mode 100644 drivers/misc/bmp085-spi.c
create mode 100644 drivers/misc/bmp085.h
--
1.7.3.4
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv3 1/3] misc: clean up bmp085 driver
2012-04-04 19:45 [PATCHv3 0/3] bmp085: add support for bmp18x chip Eric Andersson
@ 2012-04-04 19:45 ` Eric Andersson
2012-04-04 19:55 ` Joe Perches
2012-04-04 19:45 ` [PATCHv3 2/3] misc: bmp085: add device tree properties Eric Andersson
` (2 subsequent siblings)
3 siblings, 1 reply; 12+ messages in thread
From: Eric Andersson @ 2012-04-04 19:45 UTC (permalink / raw)
To: linux-kernel
Cc: gregkh, alan, arnd, zhengguang.guo, peter.moeller, stefan.nilsson,
broonie, Eric Andersson
This patch includes various cleaning of the bmp085 driver including:
- Whitespaces and alignment fixes
- Minor typos
- Consistency fixes
Reviewed-by: Stefan Nilsson <stefan.nilsson@unixphere.com>
Signed-off-by: Eric Andersson <eric.andersson@unixphere.com>
---
drivers/misc/bmp085.c | 204 ++++++++++++++++++++++++------------------------
1 files changed, 102 insertions(+), 102 deletions(-)
diff --git a/drivers/misc/bmp085.c b/drivers/misc/bmp085.c
index 76c3064..1b20974 100644
--- a/drivers/misc/bmp085.c
+++ b/drivers/misc/bmp085.c
@@ -1,62 +1,63 @@
/* Copyright (c) 2010 Christoph Mair <christoph.mair@gmail.com>
-
- This driver supports the bmp085 digital barometric pressure
- and temperature sensor from Bosch Sensortec. The datasheet
- is available from their website:
- http://www.bosch-sensortec.com/content/language1/downloads/BST-BMP085-DS000-05.pdf
-
- A pressure measurement is issued by reading from pressure0_input.
- The return value ranges from 30000 to 110000 pascal with a resulution
- of 1 pascal (0.01 millibar) which enables measurements from 9000m above
- to 500m below sea level.
-
- The temperature can be read from temp0_input. Values range from
- -400 to 850 representing the ambient temperature in degree celsius
- multiplied by 10.The resolution is 0.1 celsius.
-
- Because ambient pressure is temperature dependent, a temperature
- measurement will be executed automatically even if the user is reading
- from pressure0_input. This happens if the last temperature measurement
- has been executed more then one second ago.
-
- To decrease RMS noise from pressure measurements, the bmp085 can
- autonomously calculate the average of up to eight samples. This is
- set up by writing to the oversampling sysfs file. Accepted values
- are 0, 1, 2 and 3. 2^x when x is the value written to this file
- specifies the number of samples used to calculate the ambient pressure.
- RMS noise is specified with six pascal (without averaging) and decreases
- down to 3 pascal when using an oversampling setting of 3.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
+ * Copyright (c) 2012 Bosch Sensortec GmbH
+ * Copyright (c) 2012 Unixphere AB
+ *
+ * This driver supports the bmp085 digital barometric pressure
+ * and temperature sensor from Bosch Sensortec. The datasheet
+ * is available from their website:
+ * http://www.bosch-sensortec.com/content/language1/downloads/BST-BMP085-DS000-05.pdf
+ *
+ * A pressure measurement is issued by reading from pressure0_input.
+ * The return value ranges from 30000 to 110000 pascal with a resulution
+ * of 1 pascal (0.01 millibar) which enables measurements from 9000m above
+ * to 500m below sea level.
+ *
+ * The temperature can be read from temp0_input. Values range from
+ * -400 to 850 representing the ambient temperature in degree celsius
+ * multiplied by 10.The resolution is 0.1 celsius.
+ *
+ * Because ambient pressure is temperature dependent, a temperature
+ * measurement will be executed automatically even if the user is reading
+ * from pressure0_input. This happens if the last temperature measurement
+ * has been executed more then one second ago.
+ *
+ * To decrease RMS noise from pressure measurements, the bmp085 can
+ * autonomously calculate the average of up to eight samples. This is
+ * set up by writing to the oversampling sysfs file. Accepted values
+ * are 0, 1, 2 and 3. 2^x when x is the value written to this file
+ * specifies the number of samples used to calculate the ambient pressure.
+ * RMS noise is specified with six pascal (without averaging) and decreases
+ * down to 3 pascal when using an oversampling setting of 3.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
#include <linux/module.h>
+#include <linux/device.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/delay.h>
-
+#define BMP085_NAME "bmp085"
#define BMP085_I2C_ADDRESS 0x77
#define BMP085_CHIP_ID 0x55
#define BMP085_CALIBRATION_DATA_START 0xAA
#define BMP085_CALIBRATION_DATA_LENGTH 11 /* 16 bit values */
#define BMP085_CHIP_ID_REG 0xD0
-#define BMP085_VERSION_REG 0xD1
#define BMP085_CTRL_REG 0xF4
#define BMP085_TEMP_MEASUREMENT 0x2E
#define BMP085_PRESSURE_MEASUREMENT 0x34
@@ -65,9 +66,6 @@
#define BMP085_CONVERSION_REGISTER_XLSB 0xF8
#define BMP085_TEMP_CONVERSION_TIME 5
-#define BMP085_CLIENT_NAME "bmp085"
-
-
static const unsigned short normal_i2c[] = { BMP085_I2C_ADDRESS,
I2C_CLIENT_END };
@@ -78,20 +76,18 @@ struct bmp085_calibration_data {
s16 MB, MC, MD;
};
-
-/* Each client has this additional data */
struct bmp085_data {
- struct i2c_client *client;
- struct mutex lock;
- struct bmp085_calibration_data calibration;
- u32 raw_temperature;
- u32 raw_pressure;
- unsigned char oversampling_setting;
+ struct i2c_client *client;
+ struct mutex lock;
+ struct bmp085_calibration_data calibration;
+ u8 oversampling_setting;
+ u32 raw_temperature;
+ u32 raw_pressure;
+ u32 temp_measurement_period;
unsigned long last_temp_measurement;
- s32 b6; /* calculated temperature correction coefficient */
+ s32 b6; /* calculated temperature correction coefficient */
};
-
static s32 bmp085_read_calibration_data(struct i2c_client *client)
{
u16 tmp[BMP085_CALIBRATION_DATA_LENGTH];
@@ -99,12 +95,12 @@ static s32 bmp085_read_calibration_data(struct i2c_client *client)
struct bmp085_calibration_data *cali = &(data->calibration);
s32 status = i2c_smbus_read_i2c_block_data(client,
BMP085_CALIBRATION_DATA_START,
- BMP085_CALIBRATION_DATA_LENGTH*sizeof(u16),
+ (BMP085_CALIBRATION_DATA_LENGTH << 1),
(u8 *)tmp);
if (status < 0)
return status;
- if (status != BMP085_CALIBRATION_DATA_LENGTH*sizeof(u16))
+ if (status != (BMP085_CALIBRATION_DATA_LENGTH << 1))
return -EIO;
cali->AC1 = be16_to_cpu(tmp[0]);
@@ -121,7 +117,6 @@ static s32 bmp085_read_calibration_data(struct i2c_client *client)
return 0;
}
-
static s32 bmp085_update_raw_temperature(struct bmp085_data *data)
{
u16 tmp;
@@ -130,7 +125,7 @@ static s32 bmp085_update_raw_temperature(struct bmp085_data *data)
mutex_lock(&data->lock);
status = i2c_smbus_write_byte_data(data->client, BMP085_CTRL_REG,
BMP085_TEMP_MEASUREMENT);
- if (status != 0) {
+ if (status < 0) {
dev_err(&data->client->dev,
"Error while requesting temperature measurement.\n");
goto exit;
@@ -163,8 +158,9 @@ static s32 bmp085_update_raw_pressure(struct bmp085_data *data)
mutex_lock(&data->lock);
status = i2c_smbus_write_byte_data(data->client, BMP085_CTRL_REG,
- BMP085_PRESSURE_MEASUREMENT + (data->oversampling_setting<<6));
- if (status != 0) {
+ BMP085_PRESSURE_MEASUREMENT +
+ (data->oversampling_setting << 6));
+ if (status < 0) {
dev_err(&data->client->dev,
"Error while requesting pressure measurement.\n");
goto exit;
@@ -193,7 +189,6 @@ exit:
return status;
}
-
/*
* This function starts the temperature measurement and returns the value
* in tenth of a degree celsius.
@@ -205,7 +200,7 @@ static s32 bmp085_get_temperature(struct bmp085_data *data, int *temperature)
int status;
status = bmp085_update_raw_temperature(data);
- if (status != 0)
+ if (status < 0)
goto exit;
x1 = ((data->raw_temperature - cali->AC6) * cali->AC5) >> 15;
@@ -222,8 +217,10 @@ exit:
/*
* This function starts the pressure measurement and returns the value
* in millibar. Since the pressure depends on the ambient temperature,
- * a temperature measurement is executed if the last known value is older
- * than one second.
+ * a temperature measurement is executed according to the given temperature
+ * measurememt period (default is 1 sec boundary). This period could vary
+ * and needs to be adjusted according to the sensor environment, i.e. if big
+ * temperature variations then the temperature needs to be read out often.
*/
static s32 bmp085_get_pressure(struct bmp085_data *data, int *pressure)
{
@@ -234,16 +231,16 @@ static s32 bmp085_get_pressure(struct bmp085_data *data, int *pressure)
int status;
/* alt least every second force an update of the ambient temperature */
- if (data->last_temp_measurement == 0 ||
- time_is_before_jiffies(data->last_temp_measurement + 1*HZ)) {
+ if ((data->last_temp_measurement == 0) ||
+ time_is_before_jiffies(data->last_temp_measurement + 1*HZ)) {
status = bmp085_get_temperature(data, NULL);
- if (status != 0)
- goto exit;
+ if (status < 0)
+ return status;
}
status = bmp085_update_raw_pressure(data);
- if (status != 0)
- goto exit;
+ if (status < 0)
+ return status;
x1 = (data->b6 * data->b6) >> 12;
x1 *= cali->B2;
@@ -274,15 +271,14 @@ static s32 bmp085_get_pressure(struct bmp085_data *data, int *pressure)
*pressure = p;
-exit:
- return status;
+ return 0;
}
/*
* This function sets the chip-internal oversampling. Valid values are 0..3.
* The chip will use 2^oversampling samples for internal averaging.
* This influences the measurement time and the accuracy; larger values
- * increase both. The datasheet gives on overview on how measurement time,
+ * increase both. The datasheet gives an overview on how measurement time,
* accuracy and noise correlate.
*/
static void bmp085_set_oversampling(struct bmp085_data *data,
@@ -309,12 +305,16 @@ static ssize_t set_oversampling(struct device *dev,
struct i2c_client *client = to_i2c_client(dev);
struct bmp085_data *data = i2c_get_clientdata(client);
unsigned long oversampling;
- int success = strict_strtoul(buf, 10, &oversampling);
- if (success == 0) {
+ int err = kstrtoul(buf, 10, &oversampling);
+
+ if (err == 0) {
+ mutex_lock(&data->lock);
bmp085_set_oversampling(data, oversampling);
+ mutex_unlock(&data->lock);
return count;
}
- return success;
+
+ return err;
}
static ssize_t show_oversampling(struct device *dev,
@@ -322,6 +322,7 @@ static ssize_t show_oversampling(struct device *dev,
{
struct i2c_client *client = to_i2c_client(dev);
struct bmp085_data *data = i2c_get_clientdata(client);
+
return sprintf(buf, "%u\n", bmp085_get_oversampling(data));
}
static DEVICE_ATTR(oversampling, S_IWUSR | S_IRUGO,
@@ -337,7 +338,7 @@ static ssize_t show_temperature(struct device *dev,
struct bmp085_data *data = i2c_get_clientdata(client);
status = bmp085_get_temperature(data, &temperature);
- if (status != 0)
+ if (status < 0)
return status;
else
return sprintf(buf, "%d\n", temperature);
@@ -354,7 +355,7 @@ static ssize_t show_pressure(struct device *dev,
struct bmp085_data *data = i2c_get_clientdata(client);
status = bmp085_get_pressure(data, &pressure);
- if (status != 0)
+ if (status < 0)
return status;
else
return sprintf(buf, "%d\n", pressure);
@@ -386,25 +387,23 @@ static int bmp085_detect(struct i2c_client *client, struct i2c_board_info *info)
static int bmp085_init_client(struct i2c_client *client)
{
- unsigned char version;
- int status;
struct bmp085_data *data = i2c_get_clientdata(client);
+ int status = bmp085_read_calibration_data(client);
+
+ if (status < 0)
+ return status;
+
data->client = client;
- status = bmp085_read_calibration_data(client);
- if (status != 0)
- goto exit;
- version = i2c_smbus_read_byte_data(client, BMP085_VERSION_REG);
data->last_temp_measurement = 0;
+ data->temp_measurement_period = 1*HZ;
data->oversampling_setting = 3;
mutex_init(&data->lock);
- dev_info(&data->client->dev, "BMP085 ver. %d.%d found.\n",
- (version & 0x0F), (version & 0xF0) >> 4);
-exit:
- return status;
+
+ return 0;
}
static int __devinit bmp085_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
+ const struct i2c_device_id *id)
{
struct bmp085_data *data;
int err = 0;
@@ -415,14 +414,11 @@ static int __devinit bmp085_probe(struct i2c_client *client,
goto exit;
}
- /* default settings after POR */
- data->oversampling_setting = 0x00;
-
i2c_set_clientdata(client, data);
/* Initialize the BMP085 chip */
err = bmp085_init_client(client);
- if (err != 0)
+ if (err < 0)
goto exit_free;
/* Register sysfs hooks */
@@ -430,8 +426,9 @@ static int __devinit bmp085_probe(struct i2c_client *client,
if (err)
goto exit_free;
- dev_info(&data->client->dev, "Successfully initialized bmp085!\n");
- goto exit;
+ dev_info(&client->dev, "Succesfully initialized %s!\n", BMP085_NAME);
+
+ return 0;
exit_free:
kfree(data);
@@ -441,13 +438,16 @@ exit:
static int __devexit bmp085_remove(struct i2c_client *client)
{
+ struct bmp085_data *data = i2c_get_clientdata(client);
+
sysfs_remove_group(&client->dev.kobj, &bmp085_attr_group);
- kfree(i2c_get_clientdata(client));
+ kfree(data);
+
return 0;
}
static const struct i2c_device_id bmp085_id[] = {
- { "bmp085", 0 },
+ { BMP085_NAME, 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, bmp085_id);
@@ -455,7 +455,7 @@ MODULE_DEVICE_TABLE(i2c, bmp085_id);
static struct i2c_driver bmp085_driver = {
.driver = {
.owner = THIS_MODULE,
- .name = "bmp085"
+ .name = BMP085_NAME
},
.id_table = bmp085_id,
.probe = bmp085_probe,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCHv3 2/3] misc: bmp085: add device tree properties
2012-04-04 19:45 [PATCHv3 0/3] bmp085: add support for bmp18x chip Eric Andersson
2012-04-04 19:45 ` [PATCHv3 1/3] misc: clean up bmp085 driver Eric Andersson
@ 2012-04-04 19:45 ` Eric Andersson
2012-04-04 19:45 ` [PATCHv3 3/3] misc: add support for bmp18x chips to the bmp085 driver Eric Andersson
2012-04-04 19:52 ` [PATCHv3 0/3] bmp085: add support for bmp18x chip Arnd Bergmann
3 siblings, 0 replies; 12+ messages in thread
From: Eric Andersson @ 2012-04-04 19:45 UTC (permalink / raw)
To: linux-kernel
Cc: gregkh, alan, arnd, zhengguang.guo, peter.moeller, stefan.nilsson,
broonie, Eric Andersson
Reviewed-by: Stefan Nilsson <stefan.nilsson@unixphere.com>
Signed-off-by: Eric Andersson <eric.andersson@unixphere.com>
---
Documentation/devicetree/bindings/misc/bmp085.txt | 20 +++++++++++
drivers/misc/bmp085.c | 37 ++++++++++++++++++++-
2 files changed, 56 insertions(+), 1 deletions(-)
create mode 100644 Documentation/devicetree/bindings/misc/bmp085.txt
diff --git a/Documentation/devicetree/bindings/misc/bmp085.txt b/Documentation/devicetree/bindings/misc/bmp085.txt
new file mode 100644
index 0000000..1672b03
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/bmp085.txt
@@ -0,0 +1,20 @@
+BMP085/BMP18x digital pressure sensors
+
+Required properties:
+- compatible: bosch-sensortec,bmp085
+
+Optional properties:
+- chip-id: configurable chip id for non-default chip revisions
+- temp-measurement-period: temperature measurement period (milliseconds)
+- default-oversampling: default oversampling value to be used at startup,
+ value range is 0-3 with rising sensitivity.
+
+Example:
+
+pressure@77 {
+ compatible = "bosch-sensortec,bmp085";
+ reg = <0x77>;
+ chip-id = <10>;
+ temp-measurement-period = <10>;
+ default-oversampling = <2>;
+};
diff --git a/drivers/misc/bmp085.c b/drivers/misc/bmp085.c
index 1b20974..bdd369d 100644
--- a/drivers/misc/bmp085.c
+++ b/drivers/misc/bmp085.c
@@ -50,6 +50,7 @@
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/delay.h>
+#include <linux/of.h>
#define BMP085_NAME "bmp085"
#define BMP085_I2C_ADDRESS 0x77
@@ -85,6 +86,7 @@ struct bmp085_data {
u32 raw_pressure;
u32 temp_measurement_period;
unsigned long last_temp_measurement;
+ u8 chip_id;
s32 b6; /* calculated temperature correction coefficient */
};
@@ -385,6 +387,27 @@ static int bmp085_detect(struct i2c_client *client, struct i2c_board_info *info)
return 0;
}
+static void __init bmp085_get_of_properties(struct i2c_client *client,
+ struct bmp085_data *data)
+{
+#ifdef CONFIG_OF
+ struct device_node *np = client->dev.of_node;
+ u32 prop;
+
+ if (!np)
+ return;
+
+ if (!of_property_read_u32(np, "chip-id", &prop))
+ data->chip_id = prop & 0xff;
+
+ if (!of_property_read_u32(np, "temp-measurement-period", &prop))
+ data->temp_measurement_period = (prop/100)*HZ;
+
+ if (!of_property_read_u32(np, "default-oversampling", &prop))
+ data->oversampling_setting = prop & 0xff;
+#endif
+}
+
static int bmp085_init_client(struct i2c_client *client)
{
struct bmp085_data *data = i2c_get_clientdata(client);
@@ -393,10 +416,15 @@ static int bmp085_init_client(struct i2c_client *client)
if (status < 0)
return status;
+ /* default settings */
data->client = client;
+ data->chip_id = BMP085_CHIP_ID;
data->last_temp_measurement = 0;
data->temp_measurement_period = 1*HZ;
data->oversampling_setting = 3;
+
+ bmp085_get_of_properties(client, data);
+
mutex_init(&data->lock);
return 0;
@@ -446,6 +474,12 @@ static int __devexit bmp085_remove(struct i2c_client *client)
return 0;
}
+static const struct of_device_id bmp085_of_match[] = {
+ { .compatible = "bosch-sensortec,bmp085", },
+ { },
+};
+MODULE_DEVICE_TABLE(of, bmp085_of_match);
+
static const struct i2c_device_id bmp085_id[] = {
{ BMP085_NAME, 0 },
{ }
@@ -455,7 +489,8 @@ MODULE_DEVICE_TABLE(i2c, bmp085_id);
static struct i2c_driver bmp085_driver = {
.driver = {
.owner = THIS_MODULE,
- .name = BMP085_NAME
+ .name = BMP085_NAME,
+ .of_match_table = bmp085_of_match
},
.id_table = bmp085_id,
.probe = bmp085_probe,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCHv3 3/3] misc: add support for bmp18x chips to the bmp085 driver
2012-04-04 19:45 [PATCHv3 0/3] bmp085: add support for bmp18x chip Eric Andersson
2012-04-04 19:45 ` [PATCHv3 1/3] misc: clean up bmp085 driver Eric Andersson
2012-04-04 19:45 ` [PATCHv3 2/3] misc: bmp085: add device tree properties Eric Andersson
@ 2012-04-04 19:45 ` Eric Andersson
2012-04-04 19:55 ` Mark Brown
2012-04-04 19:52 ` [PATCHv3 0/3] bmp085: add support for bmp18x chip Arnd Bergmann
3 siblings, 1 reply; 12+ messages in thread
From: Eric Andersson @ 2012-04-04 19:45 UTC (permalink / raw)
To: linux-kernel
Cc: gregkh, alan, arnd, zhengguang.guo, peter.moeller, stefan.nilsson,
broonie, Eric Andersson
The bmp18x chip family comes in an I2C respectively SPI variant.
Hence, the bmp085 driver was split to support both buses.
Tested-by: Zhengguang Guo <zhengguang.guo@bosch-sensortec.com>
Reviewed-by: Stefan Nilsson <stefan.nilsson@unixphere.com>
Signed-off-by: Eric Andersson <eric.andersson@unixphere.com>
---
drivers/misc/Kconfig | 26 ++++++-
drivers/misc/Makefile | 2 +
drivers/misc/bmp085-i2c.c | 87 ++++++++++++++++++++++++
drivers/misc/bmp085-spi.c | 89 ++++++++++++++++++++++++
drivers/misc/bmp085.c | 163 ++++++++++++++++++--------------------------
drivers/misc/bmp085.h | 33 +++++++++
6 files changed, 300 insertions(+), 100 deletions(-)
create mode 100644 drivers/misc/bmp085-i2c.c
create mode 100644 drivers/misc/bmp085-spi.c
create mode 100644 drivers/misc/bmp085.h
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index c779509..9684695 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -452,14 +452,32 @@ config ARM_CHARLCD
still useful.
config BMP085
- tristate "BMP085 digital pressure sensor"
+ bool
+ depends on SYSFS
+
+config BMP085_I2C
+ tristate "BMP085 digital pressure sensor on I2C"
+ select BMP085
+ select REGMAP_I2C
depends on I2C && SYSFS
help
- If you say yes here you get support for the Bosch Sensortec
- BMP085 digital pressure sensor.
+ Say Y here if you want to support Bosch Sensortec's digital pressure
+ sensor hooked to an I2C bus.
+
+ To compile this driver as a module, choose M here: the
+ module will be called bmp085-i2c.
+
+config BMP085_SPI
+ tristate "BMP085 digital pressure sensor on SPI"
+ select BMP085
+ select REGMAP_SPI
+ depends on SPI_MASTER && SYSFS
+ help
+ Say Y here if you want to support Bosch Sensortec's digital pressure
+ sensor hooked to an SPI bus.
To compile this driver as a module, choose M here: the
- module will be called bmp085.
+ module will be called bmp085-spi.
config PCH_PHUB
tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) PHUB"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 3e1d801..509d056 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -11,6 +11,8 @@ obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o
obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o
obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o
obj-$(CONFIG_BMP085) += bmp085.o
+obj-$(CONFIG_BMP085_I2C) += bmp085-i2c.o
+obj-$(CONFIG_BMP085_SPI) += bmp085-spi.o
obj-$(CONFIG_ICS932S401) += ics932s401.o
obj-$(CONFIG_LKDTM) += lkdtm.o
obj-$(CONFIG_TIFM_CORE) += tifm_core.o
diff --git a/drivers/misc/bmp085-i2c.c b/drivers/misc/bmp085-i2c.c
new file mode 100644
index 0000000..1b5f7f1
--- /dev/null
+++ b/drivers/misc/bmp085-i2c.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2012 Bosch Sensortec GmbH
+ * Copyright (c) 2012 Unixphere AB
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include "bmp085.h"
+
+#define BMP085_I2C_ADDRESS 0x77
+
+static const unsigned short normal_i2c[] = { BMP085_I2C_ADDRESS,
+ I2C_CLIENT_END };
+
+static int bmp085_i2c_detect(struct i2c_client *client,
+ struct i2c_board_info *info)
+{
+ if (client->addr != BMP085_I2C_ADDRESS)
+ return -ENODEV;
+
+ return bmp085_detect(&client->dev);
+}
+
+static int __devinit bmp085_i2c_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct regmap *regmap = regmap_init_i2c(client, &bmp085_regmap_config);
+
+ if (!regmap) {
+ dev_err(&client->dev, "Failed to init regmap!\n");
+ return -ENOMEM;
+ }
+
+ return bmp085_probe(&client->dev, regmap);
+}
+
+static int bmp085_i2c_remove(struct i2c_client *client)
+{
+ return bmp085_remove(&client->dev);
+}
+
+static const struct of_device_id bmp085_of_match[] = {
+ { .compatible = "bosch-sensortec,bmp085", },
+ { },
+};
+MODULE_DEVICE_TABLE(of, bmp085_of_match);
+
+static const struct i2c_device_id bmp085_id[] = {
+ { BMP085_NAME, 0 },
+ { "bmp180", 0 },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, bmp085_id);
+
+static struct i2c_driver bmp085_i2c_driver = {
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = BMP085_NAME,
+ .of_match_table = bmp085_of_match
+ },
+ .id_table = bmp085_id,
+ .probe = bmp085_i2c_probe,
+ .remove = __devexit_p(bmp085_i2c_remove),
+
+ .detect = bmp085_i2c_detect,
+ .address_list = normal_i2c
+};
+
+module_i2c_driver(bmp085_i2c_driver);
+
+MODULE_AUTHOR("Eric Andersson <eric.andersson@unixphere.com>");
+MODULE_DESCRIPTION("BMP085 I2C bus driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/misc/bmp085-spi.c b/drivers/misc/bmp085-spi.c
new file mode 100644
index 0000000..96c20c8
--- /dev/null
+++ b/drivers/misc/bmp085-spi.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2012 Bosch Sensortec GmbH
+ * Copyright (c) 2012 Unixphere AB
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/spi/spi.h>
+#include "bmp085.h"
+
+static int __devinit bmp085_spi_probe(struct spi_device *client)
+{
+ int err;
+ struct regmap *regmap;
+
+ client->bits_per_word = 8;
+ err = spi_setup(client);
+ if (err < 0) {
+ dev_err(&client->dev, "spi_setup failed!\n");
+ return err;
+ }
+
+ regmap = regmap_init_spi(client, &bmp085_regmap_config);
+ if (!regmap) {
+ dev_err(&client->dev, "Failed to init regmap!\n");
+ return -ENOMEM;
+ }
+
+ return bmp085_probe(&client->dev, regmap);
+}
+
+static int bmp085_spi_remove(struct spi_device *client)
+{
+ return bmp085_remove(&client->dev);
+}
+
+static const struct of_device_id bmp085_of_match[] = {
+ { .compatible = "bosch-sensortec,bmp085", },
+ { },
+};
+MODULE_DEVICE_TABLE(of, bmp085_of_match);
+
+static const struct spi_device_id bmp085_id[] = {
+ { "bmp180", 0 },
+ { "bmp181", 0 },
+ { }
+};
+MODULE_DEVICE_TABLE(spi, bmp085_id);
+
+static struct spi_driver bmp085_spi_driver = {
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = BMP085_NAME,
+ .of_match_table = bmp085_of_match
+ },
+ .id_table = bmp085_id,
+ .probe = bmp085_spi_probe,
+ .remove = __devexit_p(bmp085_spi_remove)
+};
+
+static int __init bmp085_spi_init(void)
+{
+ return spi_register_driver(&bmp085_spi_driver);
+}
+
+static void __exit bmp085_spi_exit(void)
+{
+ spi_unregister_driver(&bmp085_spi_driver);
+}
+
+MODULE_AUTHOR("Eric Andersson <eric.andersson@unixphere.com>");
+MODULE_DESCRIPTION("BMP085 SPI bus driver");
+MODULE_LICENSE("GPL");
+
+module_init(bmp085_spi_init);
+module_exit(bmp085_spi_exit);
diff --git a/drivers/misc/bmp085.c b/drivers/misc/bmp085.c
index bdd369d..bc7b44c 100644
--- a/drivers/misc/bmp085.c
+++ b/drivers/misc/bmp085.c
@@ -2,10 +2,11 @@
* Copyright (c) 2012 Bosch Sensortec GmbH
* Copyright (c) 2012 Unixphere AB
*
- * This driver supports the bmp085 digital barometric pressure
- * and temperature sensor from Bosch Sensortec. The datasheet
- * is available from their website:
+ * This driver supports the bmp085 and bmp18x digital barometric pressure
+ * and temperature sensors from Bosch Sensortec. The datasheets
+ * are available from their website:
* http://www.bosch-sensortec.com/content/language1/downloads/BST-BMP085-DS000-05.pdf
+ * http://www.bosch-sensortec.com/content/language1/downloads/BST-BMP180-DS000-07.pdf
*
* A pressure measurement is issued by reading from pressure0_input.
* The return value ranges from 30000 to 110000 pascal with a resulution
@@ -47,15 +48,12 @@
#include <linux/module.h>
#include <linux/device.h>
#include <linux/init.h>
-#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/of.h>
+#include "bmp085.h"
-#define BMP085_NAME "bmp085"
-#define BMP085_I2C_ADDRESS 0x77
#define BMP085_CHIP_ID 0x55
-
#define BMP085_CALIBRATION_DATA_START 0xAA
#define BMP085_CALIBRATION_DATA_LENGTH 11 /* 16 bit values */
#define BMP085_CHIP_ID_REG 0xD0
@@ -67,9 +65,6 @@
#define BMP085_CONVERSION_REGISTER_XLSB 0xF8
#define BMP085_TEMP_CONVERSION_TIME 5
-static const unsigned short normal_i2c[] = { BMP085_I2C_ADDRESS,
- I2C_CLIENT_END };
-
struct bmp085_calibration_data {
s16 AC1, AC2, AC3;
u16 AC4, AC5, AC6;
@@ -78,7 +73,8 @@ struct bmp085_calibration_data {
};
struct bmp085_data {
- struct i2c_client *client;
+ struct device *dev;
+ struct regmap *regmap;
struct mutex lock;
struct bmp085_calibration_data calibration;
u8 oversampling_setting;
@@ -90,21 +86,16 @@ struct bmp085_data {
s32 b6; /* calculated temperature correction coefficient */
};
-static s32 bmp085_read_calibration_data(struct i2c_client *client)
+static s32 bmp085_read_calibration_data(struct bmp085_data *data)
{
u16 tmp[BMP085_CALIBRATION_DATA_LENGTH];
- struct bmp085_data *data = i2c_get_clientdata(client);
struct bmp085_calibration_data *cali = &(data->calibration);
- s32 status = i2c_smbus_read_i2c_block_data(client,
- BMP085_CALIBRATION_DATA_START,
- (BMP085_CALIBRATION_DATA_LENGTH << 1),
- (u8 *)tmp);
+ s32 status = regmap_bulk_read(data->regmap,
+ BMP085_CALIBRATION_DATA_START, (u8 *)tmp,
+ (BMP085_CALIBRATION_DATA_LENGTH << 1));
if (status < 0)
return status;
- if (status != (BMP085_CALIBRATION_DATA_LENGTH << 1))
- return -EIO;
-
cali->AC1 = be16_to_cpu(tmp[0]);
cali->AC2 = be16_to_cpu(tmp[1]);
cali->AC3 = be16_to_cpu(tmp[2]);
@@ -125,23 +116,20 @@ static s32 bmp085_update_raw_temperature(struct bmp085_data *data)
s32 status;
mutex_lock(&data->lock);
- status = i2c_smbus_write_byte_data(data->client, BMP085_CTRL_REG,
- BMP085_TEMP_MEASUREMENT);
+ status = regmap_write(data->regmap, BMP085_CTRL_REG,
+ BMP085_TEMP_MEASUREMENT);
if (status < 0) {
- dev_err(&data->client->dev,
+ dev_err(data->dev,
"Error while requesting temperature measurement.\n");
goto exit;
}
msleep(BMP085_TEMP_CONVERSION_TIME);
- status = i2c_smbus_read_i2c_block_data(data->client,
- BMP085_CONVERSION_REGISTER_MSB, sizeof(tmp), (u8 *)&tmp);
- if (status < 0)
- goto exit;
- if (status != sizeof(tmp)) {
- dev_err(&data->client->dev,
+ status = regmap_bulk_read(data->regmap, BMP085_CONVERSION_REGISTER_MSB,
+ (u8 *)&tmp, sizeof(tmp));
+ if (status < 0) {
+ dev_err(data->dev,
"Error while reading temperature measurement result\n");
- status = -EIO;
goto exit;
}
data->raw_temperature = be16_to_cpu(tmp);
@@ -159,11 +147,11 @@ static s32 bmp085_update_raw_pressure(struct bmp085_data *data)
s32 status;
mutex_lock(&data->lock);
- status = i2c_smbus_write_byte_data(data->client, BMP085_CTRL_REG,
+ status = regmap_write(data->regmap, BMP085_CTRL_REG,
BMP085_PRESSURE_MEASUREMENT +
(data->oversampling_setting << 6));
if (status < 0) {
- dev_err(&data->client->dev,
+ dev_err(data->dev,
"Error while requesting pressure measurement.\n");
goto exit;
}
@@ -172,14 +160,11 @@ static s32 bmp085_update_raw_pressure(struct bmp085_data *data)
msleep(2+(3 << data->oversampling_setting));
/* copy data into a u32 (4 bytes), but skip the first byte. */
- status = i2c_smbus_read_i2c_block_data(data->client,
- BMP085_CONVERSION_REGISTER_MSB, 3, ((u8 *)&tmp)+1);
- if (status < 0)
- goto exit;
- if (status != 3) {
- dev_err(&data->client->dev,
+ status = regmap_bulk_read(data->regmap, BMP085_CONVERSION_REGISTER_MSB,
+ ((u8 *)&tmp)+1, 3);
+ if (status < 0) {
+ dev_err(data->dev,
"Error while reading pressure measurement results\n");
- status = -EIO;
goto exit;
}
data->raw_pressure = be32_to_cpu((tmp));
@@ -304,8 +289,7 @@ static ssize_t set_oversampling(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct i2c_client *client = to_i2c_client(dev);
- struct bmp085_data *data = i2c_get_clientdata(client);
+ struct bmp085_data *data = dev_get_drvdata(dev);
unsigned long oversampling;
int err = kstrtoul(buf, 10, &oversampling);
@@ -322,8 +306,7 @@ static ssize_t set_oversampling(struct device *dev,
static ssize_t show_oversampling(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct i2c_client *client = to_i2c_client(dev);
- struct bmp085_data *data = i2c_get_clientdata(client);
+ struct bmp085_data *data = dev_get_drvdata(dev);
return sprintf(buf, "%u\n", bmp085_get_oversampling(data));
}
@@ -336,8 +319,7 @@ static ssize_t show_temperature(struct device *dev,
{
int temperature;
int status;
- struct i2c_client *client = to_i2c_client(dev);
- struct bmp085_data *data = i2c_get_clientdata(client);
+ struct bmp085_data *data = dev_get_drvdata(dev);
status = bmp085_get_temperature(data, &temperature);
if (status < 0)
@@ -353,8 +335,7 @@ static ssize_t show_pressure(struct device *dev,
{
int pressure;
int status;
- struct i2c_client *client = to_i2c_client(dev);
- struct bmp085_data *data = i2c_get_clientdata(client);
+ struct bmp085_data *data = dev_get_drvdata(dev);
status = bmp085_get_pressure(data, &pressure);
if (status < 0)
@@ -376,22 +357,27 @@ static const struct attribute_group bmp085_attr_group = {
.attrs = bmp085_attributes,
};
-static int bmp085_detect(struct i2c_client *client, struct i2c_board_info *info)
+int bmp085_detect(struct device *dev)
{
- if (client->addr != BMP085_I2C_ADDRESS)
- return -ENODEV;
+ struct bmp085_data *data = dev_get_drvdata(dev);
+ unsigned int id;
+ int ret;
+
+ ret = regmap_read(data->regmap, BMP085_CHIP_ID_REG, &id);
+ if (ret < 0)
+ return ret;
- if (i2c_smbus_read_byte_data(client, BMP085_CHIP_ID_REG) != BMP085_CHIP_ID)
+ if (id != data->chip_id)
return -ENODEV;
return 0;
}
+EXPORT_SYMBOL_GPL(bmp085_detect);
-static void __init bmp085_get_of_properties(struct i2c_client *client,
- struct bmp085_data *data)
+static void __init bmp085_get_of_properties(struct bmp085_data *data)
{
#ifdef CONFIG_OF
- struct device_node *np = client->dev.of_node;
+ struct device_node *np = data->dev->of_node;
u32 prop;
if (!np)
@@ -408,30 +394,33 @@ static void __init bmp085_get_of_properties(struct i2c_client *client,
#endif
}
-static int bmp085_init_client(struct i2c_client *client)
+static int bmp085_init_client(struct bmp085_data *data)
{
- struct bmp085_data *data = i2c_get_clientdata(client);
- int status = bmp085_read_calibration_data(client);
+ int status = bmp085_read_calibration_data(data);
if (status < 0)
return status;
/* default settings */
- data->client = client;
data->chip_id = BMP085_CHIP_ID;
data->last_temp_measurement = 0;
data->temp_measurement_period = 1*HZ;
data->oversampling_setting = 3;
- bmp085_get_of_properties(client, data);
+ bmp085_get_of_properties(data);
mutex_init(&data->lock);
return 0;
}
-static int __devinit bmp085_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
+struct regmap_config bmp085_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8
+};
+EXPORT_SYMBOL_GPL(bmp085_regmap_config);
+
+__devinit int bmp085_probe(struct device *dev, struct regmap *regmap)
{
struct bmp085_data *data;
int err = 0;
@@ -442,19 +431,27 @@ static int __devinit bmp085_probe(struct i2c_client *client,
goto exit;
}
- i2c_set_clientdata(client, data);
+ dev_set_drvdata(dev, data);
+ data->dev = dev;
+ data->regmap = regmap;
/* Initialize the BMP085 chip */
- err = bmp085_init_client(client);
+ err = bmp085_init_client(data);
if (err < 0)
goto exit_free;
+ err = bmp085_detect(dev);
+ if (err < 0) {
+ dev_err(dev, "%s: chip_id failed!\n", BMP085_NAME);
+ goto exit_free;
+ }
+
/* Register sysfs hooks */
- err = sysfs_create_group(&client->dev.kobj, &bmp085_attr_group);
+ err = sysfs_create_group(&dev->kobj, &bmp085_attr_group);
if (err)
goto exit_free;
- dev_info(&client->dev, "Succesfully initialized %s!\n", BMP085_NAME);
+ dev_info(dev, "Succesfully initialized %s!\n", BMP085_NAME);
return 0;
@@ -463,44 +460,18 @@ exit_free:
exit:
return err;
}
+EXPORT_SYMBOL_GPL(bmp085_probe);
-static int __devexit bmp085_remove(struct i2c_client *client)
+int bmp085_remove(struct device *dev)
{
- struct bmp085_data *data = i2c_get_clientdata(client);
+ struct bmp085_data *data = dev_get_drvdata(dev);
- sysfs_remove_group(&client->dev.kobj, &bmp085_attr_group);
+ sysfs_remove_group(&data->dev->kobj, &bmp085_attr_group);
kfree(data);
return 0;
}
-
-static const struct of_device_id bmp085_of_match[] = {
- { .compatible = "bosch-sensortec,bmp085", },
- { },
-};
-MODULE_DEVICE_TABLE(of, bmp085_of_match);
-
-static const struct i2c_device_id bmp085_id[] = {
- { BMP085_NAME, 0 },
- { }
-};
-MODULE_DEVICE_TABLE(i2c, bmp085_id);
-
-static struct i2c_driver bmp085_driver = {
- .driver = {
- .owner = THIS_MODULE,
- .name = BMP085_NAME,
- .of_match_table = bmp085_of_match
- },
- .id_table = bmp085_id,
- .probe = bmp085_probe,
- .remove = __devexit_p(bmp085_remove),
-
- .detect = bmp085_detect,
- .address_list = normal_i2c
-};
-
-module_i2c_driver(bmp085_driver);
+EXPORT_SYMBOL_GPL(bmp085_remove);
MODULE_AUTHOR("Christoph Mair <christoph.mair@gmail.com");
MODULE_DESCRIPTION("BMP085 driver");
diff --git a/drivers/misc/bmp085.h b/drivers/misc/bmp085.h
new file mode 100644
index 0000000..2b8f615
--- /dev/null
+++ b/drivers/misc/bmp085.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2012 Bosch Sensortec GmbH
+ * Copyright (c) 2012 Unixphere AB
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _BMP085_H
+#define _BMP085_H
+
+#include <linux/regmap.h>
+
+#define BMP085_NAME "bmp085"
+
+extern struct regmap_config bmp085_regmap_config;
+
+int bmp085_probe(struct device *dev, struct regmap *regmap);
+int bmp085_remove(struct device *dev);
+int bmp085_detect(struct device *dev);
+
+#endif
--
1.7.3.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCHv3 0/3] bmp085: add support for bmp18x chip
2012-04-04 19:45 [PATCHv3 0/3] bmp085: add support for bmp18x chip Eric Andersson
` (2 preceding siblings ...)
2012-04-04 19:45 ` [PATCHv3 3/3] misc: add support for bmp18x chips to the bmp085 driver Eric Andersson
@ 2012-04-04 19:52 ` Arnd Bergmann
3 siblings, 0 replies; 12+ messages in thread
From: Arnd Bergmann @ 2012-04-04 19:52 UTC (permalink / raw)
To: Eric Andersson
Cc: linux-kernel, gregkh, alan, zhengguang.guo, peter.moeller,
stefan.nilsson, broonie
On Wednesday 04 April 2012, Eric Andersson wrote:
> This is version 3 of the patch-set that adds support for the latest pressure
> sensors from Bosch Sensortec.
>
> Changes from last version:
> - Dropped the platform data in favor of devicetree properties.
> - Use regmap as communication layer.
> - Changed Kconfig logic.
> - Keep the original bmp085 file name.
> - Use EXPORT_SYMBOL_GPL.
>
Looks all good to me now,
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv3 3/3] misc: add support for bmp18x chips to the bmp085 driver
2012-04-04 19:45 ` [PATCHv3 3/3] misc: add support for bmp18x chips to the bmp085 driver Eric Andersson
@ 2012-04-04 19:55 ` Mark Brown
2012-04-04 20:00 ` Arnd Bergmann
0 siblings, 1 reply; 12+ messages in thread
From: Mark Brown @ 2012-04-04 19:55 UTC (permalink / raw)
To: Eric Andersson
Cc: linux-kernel, gregkh, alan, arnd, zhengguang.guo, peter.moeller,
stefan.nilsson
[-- Attachment #1: Type: text/plain, Size: 1034 bytes --]
On Wed, Apr 04, 2012 at 09:45:59PM +0200, Eric Andersson wrote:
> +static int __devinit bmp085_i2c_probe(struct i2c_client *client,
> + const struct i2c_device_id *id)
> +{
> + struct regmap *regmap = regmap_init_i2c(client, &bmp085_regmap_config);
> +
> + if (!regmap) {
Should be IS_ERR() - regmap uses PTR_ERR() and for error return values.
I'd also consider devm_regmap_init_i2c() (introduced in the merge
window) which saves you bothering to free it later on...
> + dev_err(&client->dev, "Failed to init regmap!\n");
> + return -ENOMEM;
> + }
> +
> + return bmp085_probe(&client->dev, regmap);
...right now it gets leaked so this would also fix an error.
> +static const struct of_device_id bmp085_of_match[] = {
> + { .compatible = "bosch-sensortec,bmp085", },
Traditionally the stock ticker symbol would be used.
> + status = regmap_bulk_read(data->regmap, BMP085_CONVERSION_REGISTER_MSB,
> + (u8 *)&tmp, sizeof(tmp));
Should be no need for the cast, the destination array argument is a
pointer to void.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv3 1/3] misc: clean up bmp085 driver
2012-04-04 19:45 ` [PATCHv3 1/3] misc: clean up bmp085 driver Eric Andersson
@ 2012-04-04 19:55 ` Joe Perches
2012-04-05 6:30 ` Eric Andersson
0 siblings, 1 reply; 12+ messages in thread
From: Joe Perches @ 2012-04-04 19:55 UTC (permalink / raw)
To: Eric Andersson
Cc: linux-kernel, gregkh, alan, arnd, zhengguang.guo, peter.moeller,
stefan.nilsson, broonie
On Wed, 2012-04-04 at 21:45 +0200, Eric Andersson wrote:
> This patch includes various cleaning of the bmp085 driver including:
> - Whitespaces and alignment fixes
> - Minor typos
> - Consistency fixes
just some more trivial things:
> diff --git a/drivers/misc/bmp085.c b/drivers/misc/bmp085.c
[]
> @@ -222,8 +217,10 @@ exit:
> /*
> * This function starts the pressure measurement and returns the value
> * in millibar. Since the pressure depends on the ambient temperature,
> - * a temperature measurement is executed if the last known value is older
> - * than one second.
> + * a temperature measurement is executed according to the given temperature
> + * measurememt period (default is 1 sec boundary). This period could vary
typo: measurement
> + * and needs to be adjusted according to the sensor environment, i.e. if big
> + * temperature variations then the temperature needs to be read out often.
> @@ -386,25 +387,23 @@ static int bmp085_detect(struct i2c_client *client, struct i2c_board_info *info)
>
> static int bmp085_init_client(struct i2c_client *client)
[]
> - dev_info(&data->client->dev, "BMP085 ver. %d.%d found.\n",
> - (version & 0x0F), (version & 0xF0) >> 4);
Why remove the "version" output?
[]
> static int __devinit bmp085_probe(struct i2c_client *client,
> - const struct i2c_device_id *id)
> + const struct i2c_device_id *id)
[]
> @@ -430,8 +426,9 @@ static int __devinit bmp085_probe(struct i2c_client *client,
> if (err)
> goto exit_free;
>
> - dev_info(&data->client->dev, "Successfully initialized bmp085!\n");
> - goto exit;
> + dev_info(&client->dev, "Succesfully initialized %s!\n", BMP085_NAME);
typo: successfully
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv3 3/3] misc: add support for bmp18x chips to the bmp085 driver
2012-04-04 19:55 ` Mark Brown
@ 2012-04-04 20:00 ` Arnd Bergmann
2012-04-04 20:11 ` Mark Brown
0 siblings, 1 reply; 12+ messages in thread
From: Arnd Bergmann @ 2012-04-04 20:00 UTC (permalink / raw)
To: Mark Brown
Cc: Eric Andersson, linux-kernel, gregkh, alan, zhengguang.guo,
peter.moeller, stefan.nilsson
On Wednesday 04 April 2012, Mark Brown wrote:
> > +static const struct of_device_id bmp085_of_match[] = {
> > + { .compatible = "bosch-sensortec,bmp085", },
>
> Traditionally the stock ticker symbol would be used.
I though about commenting on that as well, but since Bosch is a foundation
and not publically traded, that would be hard to accomplish. Is there
an official fallback for companies that don't have a stock ticker symbol?
Arnd
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv3 3/3] misc: add support for bmp18x chips to the bmp085 driver
2012-04-04 20:00 ` Arnd Bergmann
@ 2012-04-04 20:11 ` Mark Brown
2012-04-05 6:53 ` Eric Andersson
2012-04-07 1:37 ` Grant Likely
0 siblings, 2 replies; 12+ messages in thread
From: Mark Brown @ 2012-04-04 20:11 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Eric Andersson, linux-kernel, gregkh, alan, zhengguang.guo,
peter.moeller, stefan.nilsson, devicetree-discuss
[-- Attachment #1: Type: text/plain, Size: 681 bytes --]
On Wed, Apr 04, 2012 at 08:00:33PM +0000, Arnd Bergmann wrote:
> On Wednesday 04 April 2012, Mark Brown wrote:
> > > +static const struct of_device_id bmp085_of_match[] = {
> > > + { .compatible = "bosch-sensortec,bmp085", },
> > Traditionally the stock ticker symbol would be used.
> I though about commenting on that as well, but since Bosch is a foundation
> and not publically traded, that would be hard to accomplish. Is there
> an official fallback for companies that don't have a stock ticker symbol?
Guess we should ask the DT people... I mostly just noticed that the
name appeared somewhat verbose - perhaps just plain "bosch" if there's
not a better abbrevation?
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv3 1/3] misc: clean up bmp085 driver
2012-04-04 19:55 ` Joe Perches
@ 2012-04-05 6:30 ` Eric Andersson
0 siblings, 0 replies; 12+ messages in thread
From: Eric Andersson @ 2012-04-05 6:30 UTC (permalink / raw)
To: Joe Perches
Cc: linux-kernel, gregkh, alan, arnd, zhengguang.guo, peter.moeller,
stefan.nilsson, broonie
Hi Joe,
On 12:55 Wed 04 Apr , Joe Perches wrote:
> On Wed, 2012-04-04 at 21:45 +0200, Eric Andersson wrote:
> > This patch includes various cleaning of the bmp085 driver including:
> > - Whitespaces and alignment fixes
> > - Minor typos
> > - Consistency fixes
>
> just some more trivial things:
>
> > diff --git a/drivers/misc/bmp085.c b/drivers/misc/bmp085.c
> []
> > @@ -222,8 +217,10 @@ exit:
> > /*
> > * This function starts the pressure measurement and returns the value
> > * in millibar. Since the pressure depends on the ambient temperature,
> > - * a temperature measurement is executed if the last known value is older
> > - * than one second.
> > + * a temperature measurement is executed according to the given temperature
> > + * measurememt period (default is 1 sec boundary). This period could vary
>
> typo: measurement
>
> > + * and needs to be adjusted according to the sensor environment, i.e. if big
> > + * temperature variations then the temperature needs to be read out often.
>
> > @@ -386,25 +387,23 @@ static int bmp085_detect(struct i2c_client *client, struct i2c_board_info *info)
> >
> > static int bmp085_init_client(struct i2c_client *client)
> []
> > - dev_info(&data->client->dev, "BMP085 ver. %d.%d found.\n",
> > - (version & 0x0F), (version & 0xF0) >> 4);
>
> Why remove the "version" output?
The version register is actually not an official register and is subject to
change in the future.
I'll fix the typos in next version!
Thanks!
--
Best regards,
Eric
http://www.unixphere.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv3 3/3] misc: add support for bmp18x chips to the bmp085 driver
2012-04-04 20:11 ` Mark Brown
@ 2012-04-05 6:53 ` Eric Andersson
2012-04-07 1:37 ` Grant Likely
1 sibling, 0 replies; 12+ messages in thread
From: Eric Andersson @ 2012-04-05 6:53 UTC (permalink / raw)
To: Mark Brown
Cc: Arnd Bergmann, linux-kernel, gregkh, alan, zhengguang.guo,
peter.moeller, stefan.nilsson, devicetree-discuss
Hi,
Thanks for the review guys!
On 21:11 Wed 04 Apr , Mark Brown wrote:
> On Wed, Apr 04, 2012 at 08:00:33PM +0000, Arnd Bergmann wrote:
> > On Wednesday 04 April 2012, Mark Brown wrote:
> > > > +static const struct of_device_id bmp085_of_match[] = {
> > > > + { .compatible = "bosch-sensortec,bmp085", },
>
> > > Traditionally the stock ticker symbol would be used.
>
> > I though about commenting on that as well, but since Bosch is a foundation
> > and not publically traded, that would be hard to accomplish. Is there
> > an official fallback for companies that don't have a stock ticker symbol?
>
> Guess we should ask the DT people... I mostly just noticed that the
> name appeared somewhat verbose - perhaps just plain "bosch" if there's
> not a better abbrevation?
If there are no further objections let's go with "bosch". I'll prepare a
new patch-set ASAP.
--
Best regards,
Eric
http://www.unixphere.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv3 3/3] misc: add support for bmp18x chips to the bmp085 driver
2012-04-04 20:11 ` Mark Brown
2012-04-05 6:53 ` Eric Andersson
@ 2012-04-07 1:37 ` Grant Likely
1 sibling, 0 replies; 12+ messages in thread
From: Grant Likely @ 2012-04-07 1:37 UTC (permalink / raw)
To: Mark Brown, Arnd Bergmann
Cc: Eric Andersson, linux-kernel, gregkh, alan, zhengguang.guo,
peter.moeller, stefan.nilsson, devicetree-discuss
On Wed, 4 Apr 2012 21:11:17 +0100, Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:
> On Wed, Apr 04, 2012 at 08:00:33PM +0000, Arnd Bergmann wrote:
> > On Wednesday 04 April 2012, Mark Brown wrote:
> > > > +static const struct of_device_id bmp085_of_match[] = {
> > > > + { .compatible = "bosch-sensortec,bmp085", },
>
> > > Traditionally the stock ticker symbol would be used.
>
> > I though about commenting on that as well, but since Bosch is a foundation
> > and not publically traded, that would be hard to accomplish. Is there
> > an official fallback for companies that don't have a stock ticker symbol?
>
> Guess we should ask the DT people... I mostly just noticed that the
> name appeared somewhat verbose - perhaps just plain "bosch" if there's
> not a better abbrevation?
*MY* official fallback is go with whatever is documented in
Documentation/devicetree/bindings/vendor-prefixes.txt. If the needed
value isn't there, then add it! :-)
g.
--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies,Ltd.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-04-07 1:37 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-04 19:45 [PATCHv3 0/3] bmp085: add support for bmp18x chip Eric Andersson
2012-04-04 19:45 ` [PATCHv3 1/3] misc: clean up bmp085 driver Eric Andersson
2012-04-04 19:55 ` Joe Perches
2012-04-05 6:30 ` Eric Andersson
2012-04-04 19:45 ` [PATCHv3 2/3] misc: bmp085: add device tree properties Eric Andersson
2012-04-04 19:45 ` [PATCHv3 3/3] misc: add support for bmp18x chips to the bmp085 driver Eric Andersson
2012-04-04 19:55 ` Mark Brown
2012-04-04 20:00 ` Arnd Bergmann
2012-04-04 20:11 ` Mark Brown
2012-04-05 6:53 ` Eric Andersson
2012-04-07 1:37 ` Grant Likely
2012-04-04 19:52 ` [PATCHv3 0/3] bmp085: add support for bmp18x chip Arnd Bergmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.