Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1206188 > unrolled thread
| Started by | Markus Pargmann <mpa@pengutronix.de> |
|---|---|
| First post | 2015-08-12 17:00 +0200 |
| Last post | 2015-08-17 11:30 +0200 |
| Articles | 11 — 5 participants |
Back to article view | Back to linux.kernel
[PATCH v3 0/6] iio: bmg160: Add SPI connection Markus Pargmann <mpa@pengutronix.de> - 2015-08-12 17:00 +0200
[PATCH v3 5/6] iio: bmg160: Separate i2c and core driver Markus Pargmann <mpa@pengutronix.de> - 2015-08-12 17:00 +0200
Re: [PATCH v3 5/6] iio: bmg160: Separate i2c and core driver Jonathan Cameron <jic23@kernel.org> - 2015-08-15 17:00 +0200
[PATCH v3 3/6] iio: bmg160: Use generic dev_drvdata Markus Pargmann <mpa@pengutronix.de> - 2015-08-12 17:00 +0200
Re: [PATCH v3 3/6] iio: bmg160: Use generic dev_drvdata Jonathan Cameron <jic23@kernel.org> - 2015-08-15 17:00 +0200
[PATCH v3 4/6] iio: bmg160: Remove remaining uses of i2c_client Markus Pargmann <mpa@pengutronix.de> - 2015-08-12 17:00 +0200
Re: [PATCH v3 4/6] iio: bmg160: Remove remaining uses of i2c_client Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> - 2015-08-12 18:10 +0200
Re: [PATCH v3 4/6] iio: bmg160: Remove remaining uses of i2c_client Jonathan Cameron <jic23@kernel.org> - 2015-08-15 17:00 +0200
Re: [PATCH v3 0/6] iio: bmg160: Add SPI connection Lars-Peter Clausen <lars@metafoo.de> - 2015-08-12 17:10 +0200
Re: [PATCH v3 0/6] iio: bmg160: Add SPI connection Jonathan Cameron <jic23@kernel.org> - 2015-08-15 16:50 +0200
RE: [PATCH v3 0/6] iio: bmg160: Add SPI connection "Tirdea, Irina" <irina.tirdea@intel.com> - 2015-08-17 11:30 +0200
| From | Markus Pargmann <mpa@pengutronix.de> |
|---|---|
| Date | 2015-08-12 17:00 +0200 |
| Subject | [PATCH v3 0/6] iio: bmg160: Add SPI connection |
| Message-ID | <pWFFw-7yz-13@gated-at.bofh.it> |
Hi,
bmg160 and bmi055 can be used via I2C and SPI. This series converts the driver
to regmap and splits core driver and I2C/SPI.
Changes in v3:
- removed 'select REGMAP' as it is selected by REGMAP_I2C
- added EXPORT_SYMBOL_GPL for the core functions
- removed default values from regmap_config
- Added max_register and unset use_single_rw in regmap_config
- Changed Makefile to always compile bmg160-core with either spi or i2c. It is
not possible now to compile the core alone.
Changes in v2:
- Added the id->name from the SPI driver to be used as iio device name
- Fixed Kconfig in patch 2 to add selects for REGMAP_I2C
- Fixed regmap configs to be static const
Best regards,
Markus
Markus Pargmann (6):
iio: bmg160: Use i2c regmap instead of direct i2c access
iio: bmg160: Remove i2c_client from data struct
iio: bmg160: Use generic dev_drvdata
iio: bmg160: Remove remaining uses of i2c_client
iio: bmg160: Separate i2c and core driver
iio: bmg160: Add SPI driver
drivers/iio/gyro/Kconfig | 28 ++-
drivers/iio/gyro/Makefile | 3 +-
drivers/iio/gyro/bmg160.h | 10 +
drivers/iio/gyro/{bmg160.c => bmg160_core.c} | 358 +++++++++++----------------
drivers/iio/gyro/bmg160_i2c.c | 71 ++++++
drivers/iio/gyro/bmg160_spi.c | 57 +++++
6 files changed, 306 insertions(+), 221 deletions(-)
create mode 100644 drivers/iio/gyro/bmg160.h
rename drivers/iio/gyro/{bmg160.c => bmg160_core.c} (74%)
create mode 100644 drivers/iio/gyro/bmg160_i2c.c
create mode 100644 drivers/iio/gyro/bmg160_spi.c
--
2.4.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Markus Pargmann <mpa@pengutronix.de> |
|---|---|
| Date | 2015-08-12 17:00 +0200 |
| Subject | [PATCH v3 5/6] iio: bmg160: Separate i2c and core driver |
| Message-ID | <pWFFx-7yz-49@gated-at.bofh.it> |
| In reply to | #1206188 |
This patch separates the core driver using regmap and the i2c driver
which creates the i2c regmap. Also in the Kconfig file BMG160 and
BMG160_I2C are separate now.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
drivers/iio/gyro/Kconfig | 18 +++++--
drivers/iio/gyro/Makefile | 2 +-
drivers/iio/gyro/bmg160.h | 10 ++++
drivers/iio/gyro/{bmg160.c => bmg160_core.c} | 77 +++++-----------------------
drivers/iio/gyro/bmg160_i2c.c | 71 +++++++++++++++++++++++++
5 files changed, 109 insertions(+), 69 deletions(-)
create mode 100644 drivers/iio/gyro/bmg160.h
rename drivers/iio/gyro/{bmg160.c => bmg160_core.c} (94%)
create mode 100644 drivers/iio/gyro/bmg160_i2c.c
diff --git a/drivers/iio/gyro/Kconfig b/drivers/iio/gyro/Kconfig
index cf82d74139a2..13f8e0051615 100644
--- a/drivers/iio/gyro/Kconfig
+++ b/drivers/iio/gyro/Kconfig
@@ -51,17 +51,27 @@ config ADXRS450
will be called adxrs450.
config BMG160
- tristate "BOSCH BMG160 Gyro Sensor"
- depends on I2C
+ bool "BOSCH BMG160 Gyro Sensor"
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
- select REGMAP_I2C
help
Say yes here to build support for Bosch BMG160 Tri-axis Gyro Sensor
driver. This driver also supports BMI055 gyroscope.
+if BMG160
+
+config BMG160_I2C
+ tristate "Driver for connection via I2C"
+ depends on I2C
+ select REGMAP_I2C
+ help
+ Say yes here to build support for Bosch BMG160 Tri-axis Gyro Sensor
+ driver connected via I2C. This driver also supports BMI055 gyroscope.
+
This driver can also be built as a module. If so, the module
- will be called bmg160.
+ will be called bmg160_i2c.
+
+endif
config HID_SENSOR_GYRO_3D
depends on HID_SENSOR_HUB
diff --git a/drivers/iio/gyro/Makefile b/drivers/iio/gyro/Makefile
index f46341b39139..73b41e43a974 100644
--- a/drivers/iio/gyro/Makefile
+++ b/drivers/iio/gyro/Makefile
@@ -8,7 +8,7 @@ obj-$(CONFIG_ADIS16130) += adis16130.o
obj-$(CONFIG_ADIS16136) += adis16136.o
obj-$(CONFIG_ADIS16260) += adis16260.o
obj-$(CONFIG_ADXRS450) += adxrs450.o
-obj-$(CONFIG_BMG160) += bmg160.o
+obj-$(CONFIG_BMG160_I2C) += bmg160_core.o bmg160_i2c.o
obj-$(CONFIG_HID_SENSOR_GYRO_3D) += hid-sensor-gyro-3d.o
diff --git a/drivers/iio/gyro/bmg160.h b/drivers/iio/gyro/bmg160.h
new file mode 100644
index 000000000000..72db723c8fb6
--- /dev/null
+++ b/drivers/iio/gyro/bmg160.h
@@ -0,0 +1,10 @@
+#ifndef BMG160_H_
+#define BMG160_H_
+
+extern const struct dev_pm_ops bmg160_pm_ops;
+
+int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq,
+ const char *name);
+void bmg160_core_remove(struct device *dev);
+
+#endif /* BMG160_H_ */
diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160_core.c
similarity index 94%
rename from drivers/iio/gyro/bmg160.c
rename to drivers/iio/gyro/bmg160_core.c
index 39df64fb4262..d64e3a87e0a1 100644
--- a/drivers/iio/gyro/bmg160.c
+++ b/drivers/iio/gyro/bmg160_core.c
@@ -13,7 +13,6 @@
*/
#include <linux/module.h>
-#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/slab.h>
@@ -30,7 +29,6 @@
#include <linux/iio/triggered_buffer.h>
#include <linux/regmap.h>
-#define BMG160_DRV_NAME "bmg160"
#define BMG160_IRQ_NAME "bmg160_event"
#define BMG160_GPIO_NAME "gpio_int"
@@ -137,12 +135,6 @@ static const struct {
{ 133, BMG160_RANGE_250DPS},
{ 66, BMG160_RANGE_125DPS} };
-struct regmap_config bmg160_regmap_i2c_conf = {
- .reg_bits = 8,
- .val_bits = 8,
- .max_register = 0x3f
-};
-
static int bmg160_set_mode(struct bmg160_data *data, u8 mode)
{
int ret;
@@ -996,31 +988,22 @@ static const char *bmg160_match_acpi_device(struct device *dev)
return dev_name(dev);
}
-static int bmg160_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
+int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq,
+ const char *name)
{
struct bmg160_data *data;
struct iio_dev *indio_dev;
int ret;
- const char *name = NULL;
- struct regmap *regmap;
- struct device *dev = &client->dev;
-
- regmap = devm_regmap_init_i2c(client, &bmg160_regmap_i2c_conf);
- if (IS_ERR(regmap)) {
- dev_err(&client->dev, "Failed to register i2c regmap %d\n",
- (int)PTR_ERR(regmap));
- return PTR_ERR(regmap);
- }
- indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
if (!indio_dev)
return -ENOMEM;
data = iio_priv(indio_dev);
dev_set_drvdata(dev, indio_dev);
data->dev = dev;
- data->irq = client->irq;
+ data->irq = irq;
+ data->regmap = regmap;
ret = bmg160_chip_init(data);
if (ret < 0)
@@ -1028,9 +1011,6 @@ static int bmg160_probe(struct i2c_client *client,
mutex_init(&data->mutex);
- if (id)
- name = id->name;
-
if (ACPI_HANDLE(dev))
name = bmg160_match_acpi_device(dev);
@@ -1125,15 +1105,16 @@ err_trigger_unregister:
return ret;
}
+EXPORT_SYMBOL_GPL(bmg160_core_probe);
-static int bmg160_remove(struct i2c_client *client)
+void bmg160_core_remove(struct device *dev)
{
- struct iio_dev *indio_dev = i2c_get_clientdata(client);
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct bmg160_data *data = iio_priv(indio_dev);
- pm_runtime_disable(&client->dev);
- pm_runtime_set_suspended(&client->dev);
- pm_runtime_put_noidle(&client->dev);
+ pm_runtime_disable(dev);
+ pm_runtime_set_suspended(dev);
+ pm_runtime_put_noidle(dev);
iio_device_unregister(indio_dev);
iio_triggered_buffer_cleanup(indio_dev);
@@ -1146,9 +1127,8 @@ static int bmg160_remove(struct i2c_client *client)
mutex_lock(&data->mutex);
bmg160_set_mode(data, BMG160_MODE_DEEP_SUSPEND);
mutex_unlock(&data->mutex);
-
- return 0;
}
+EXPORT_SYMBOL_GPL(bmg160_core_remove);
#ifdef CONFIG_PM_SLEEP
static int bmg160_suspend(struct device *dev)
@@ -1210,40 +1190,9 @@ static int bmg160_runtime_resume(struct device *dev)
}
#endif
-static const struct dev_pm_ops bmg160_pm_ops = {
+const struct dev_pm_ops bmg160_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(bmg160_suspend, bmg160_resume)
SET_RUNTIME_PM_OPS(bmg160_runtime_suspend,
bmg160_runtime_resume, NULL)
};
-static const struct acpi_device_id bmg160_acpi_match[] = {
- {"BMG0160", 0},
- {"BMI055B", 0},
- {},
-};
-
-MODULE_DEVICE_TABLE(acpi, bmg160_acpi_match);
-
-static const struct i2c_device_id bmg160_id[] = {
- {"bmg160", 0},
- {"bmi055_gyro", 0},
- {}
-};
-
-MODULE_DEVICE_TABLE(i2c, bmg160_id);
-
-static struct i2c_driver bmg160_driver = {
- .driver = {
- .name = BMG160_DRV_NAME,
- .acpi_match_table = ACPI_PTR(bmg160_acpi_match),
- .pm = &bmg160_pm_ops,
- },
- .probe = bmg160_probe,
- .remove = bmg160_remove,
- .id_table = bmg160_id,
-};
-module_i2c_driver(bmg160_driver);
-
-MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
-MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("BMG160 Gyro driver");
diff --git a/drivers/iio/gyro/bmg160_i2c.c b/drivers/iio/gyro/bmg160_i2c.c
new file mode 100644
index 000000000000..90126a5a7663
--- /dev/null
+++ b/drivers/iio/gyro/bmg160_i2c.c
@@ -0,0 +1,71 @@
+#include <linux/i2c.h>
+#include <linux/regmap.h>
+#include <linux/iio/iio.h>
+#include <linux/module.h>
+#include <linux/acpi.h>
+
+#include "bmg160.h"
+
+static const struct regmap_config bmg160_regmap_i2c_conf = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = 0x3f
+};
+
+static int bmg160_i2c_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct regmap *regmap;
+ const char *name = NULL;
+
+ regmap = devm_regmap_init_i2c(client, &bmg160_regmap_i2c_conf);
+ if (IS_ERR(regmap)) {
+ dev_err(&client->dev, "Failed to register i2c regmap %d\n",
+ (int)PTR_ERR(regmap));
+ return PTR_ERR(regmap);
+ }
+
+ if (id)
+ name = id->name;
+
+ return bmg160_core_probe(&client->dev, regmap, client->irq, name);
+}
+
+static int bmg160_i2c_remove(struct i2c_client *client)
+{
+ bmg160_core_remove(&client->dev);
+
+ return 0;
+}
+
+static const struct acpi_device_id bmg160_acpi_match[] = {
+ {"BMG0160", 0},
+ {"BMI055B", 0},
+ {},
+};
+
+MODULE_DEVICE_TABLE(acpi, bmg160_acpi_match);
+
+static const struct i2c_device_id bmg160_i2c_id[] = {
+ {"bmg160", 0},
+ {"bmi055_gyro", 0},
+ {}
+};
+
+MODULE_DEVICE_TABLE(i2c, bmg160_i2c_id);
+
+static struct i2c_driver bmg160_i2c_driver = {
+ .driver = {
+ .name = "bmg160_i2c",
+ .acpi_match_table = ACPI_PTR(bmg160_acpi_match),
+ .pm = &bmg160_pm_ops,
+ },
+ .probe = bmg160_i2c_probe,
+ .remove = bmg160_i2c_remove,
+ .id_table = bmg160_i2c_id,
+};
+module_i2c_driver(bmg160_i2c_driver);
+
+MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("BMG160 I2C Gyro driver");
--
2.4.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jonathan Cameron <jic23@kernel.org> |
|---|---|
| Date | 2015-08-15 17:00 +0200 |
| Subject | Re: [PATCH v3 5/6] iio: bmg160: Separate i2c and core driver |
| Message-ID | <pXL6a-4B6-27@gated-at.bofh.it> |
| In reply to | #1206192 |
On 12/08/15 17:16, Srinivas Pandruvada wrote:
> On Wed, 2015-08-12 at 16:50 +0200, Markus Pargmann wrote:
>> This patch separates the core driver using regmap and the i2c driver
>> which creates the i2c regmap. Also in the Kconfig file BMG160 and
>> BMG160_I2C are separate now.
>>
>> Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
As I mentioned in the review of you other recent set, I'm not so keen on
the way you have the Kconfig.
>> ---
>> drivers/iio/gyro/Kconfig | 18 +++++--
>> drivers/iio/gyro/Makefile | 2 +-
>> drivers/iio/gyro/bmg160.h | 10 ++++
>> drivers/iio/gyro/{bmg160.c => bmg160_core.c} | 77 +++++-----------------------
>> drivers/iio/gyro/bmg160_i2c.c | 71 +++++++++++++++++++++++++
>> 5 files changed, 109 insertions(+), 69 deletions(-)
>> create mode 100644 drivers/iio/gyro/bmg160.h
>> rename drivers/iio/gyro/{bmg160.c => bmg160_core.c} (94%)
>> create mode 100644 drivers/iio/gyro/bmg160_i2c.c
>>
>> diff --git a/drivers/iio/gyro/Kconfig b/drivers/iio/gyro/Kconfig
>> index cf82d74139a2..13f8e0051615 100644
>> --- a/drivers/iio/gyro/Kconfig
>> +++ b/drivers/iio/gyro/Kconfig
>> @@ -51,17 +51,27 @@ config ADXRS450
>> will be called adxrs450.
>>
>> config BMG160
>> - tristate "BOSCH BMG160 Gyro Sensor"
>> - depends on I2C
>> + bool "BOSCH BMG160 Gyro Sensor"
This prevents building the core as a module?
>> select IIO_BUFFER
>> select IIO_TRIGGERED_BUFFER
>> - select REGMAP_I2C
>> help
>> Say yes here to build support for Bosch BMG160 Tri-axis Gyro Sensor
>> driver. This driver also supports BMI055 gyroscope.
I prefer the logic the way the ST accelerometer driver has it. A core
module that you get to pick in the menu, then building the i2c / spi
parts dependent on their dependencies being met. Cuts down on the
complexity of presented configuration.
Jonathan
>>
>> +if BMG160
>> +
>> +config BMG160_I2C
>> + tristate "Driver for connection via I2C"
>> + depends on I2C
>> + select REGMAP_I2C
>> + help
>> + Say yes here to build support for Bosch BMG160 Tri-axis Gyro Sensor
>> + driver connected via I2C. This driver also supports BMI055 gyroscope.
>> +
>> This driver can also be built as a module. If so, the module
>> - will be called bmg160.
>> + will be called bmg160_i2c.
>> +
>> +endif
>>
>> config HID_SENSOR_GYRO_3D
>> depends on HID_SENSOR_HUB
>> diff --git a/drivers/iio/gyro/Makefile b/drivers/iio/gyro/Makefile
>> index f46341b39139..73b41e43a974 100644
>> --- a/drivers/iio/gyro/Makefile
>> +++ b/drivers/iio/gyro/Makefile
>> @@ -8,7 +8,7 @@ obj-$(CONFIG_ADIS16130) += adis16130.o
>> obj-$(CONFIG_ADIS16136) += adis16136.o
>> obj-$(CONFIG_ADIS16260) += adis16260.o
>> obj-$(CONFIG_ADXRS450) += adxrs450.o
>> -obj-$(CONFIG_BMG160) += bmg160.o
>> +obj-$(CONFIG_BMG160_I2C) += bmg160_core.o bmg160_i2c.o
>>
>> obj-$(CONFIG_HID_SENSOR_GYRO_3D) += hid-sensor-gyro-3d.o
>>
>> diff --git a/drivers/iio/gyro/bmg160.h b/drivers/iio/gyro/bmg160.h
>> new file mode 100644
>> index 000000000000..72db723c8fb6
>> --- /dev/null
>> +++ b/drivers/iio/gyro/bmg160.h
>> @@ -0,0 +1,10 @@
>> +#ifndef BMG160_H_
>> +#define BMG160_H_
>> +
>> +extern const struct dev_pm_ops bmg160_pm_ops;
>> +
>> +int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq,
>> + const char *name);
>> +void bmg160_core_remove(struct device *dev);
>> +
>> +#endif /* BMG160_H_ */
>> diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160_core.c
>> similarity index 94%
>> rename from drivers/iio/gyro/bmg160.c
>> rename to drivers/iio/gyro/bmg160_core.c
>> index 39df64fb4262..d64e3a87e0a1 100644
>> --- a/drivers/iio/gyro/bmg160.c
>> +++ b/drivers/iio/gyro/bmg160_core.c
>> @@ -13,7 +13,6 @@
>> */
>>
>> #include <linux/module.h>
>> -#include <linux/i2c.h>
>> #include <linux/interrupt.h>
>> #include <linux/delay.h>
>> #include <linux/slab.h>
>> @@ -30,7 +29,6 @@
>> #include <linux/iio/triggered_buffer.h>
>> #include <linux/regmap.h>
>>
>> -#define BMG160_DRV_NAME "bmg160"
>> #define BMG160_IRQ_NAME "bmg160_event"
>> #define BMG160_GPIO_NAME "gpio_int"
>>
>> @@ -137,12 +135,6 @@ static const struct {
>> { 133, BMG160_RANGE_250DPS},
>> { 66, BMG160_RANGE_125DPS} };
>>
>> -struct regmap_config bmg160_regmap_i2c_conf = {
>> - .reg_bits = 8,
>> - .val_bits = 8,
>> - .max_register = 0x3f
>> -};
>> -
>> static int bmg160_set_mode(struct bmg160_data *data, u8 mode)
>> {
>> int ret;
>> @@ -996,31 +988,22 @@ static const char *bmg160_match_acpi_device(struct device *dev)
>> return dev_name(dev);
>> }
>>
>> -static int bmg160_probe(struct i2c_client *client,
>> - const struct i2c_device_id *id)
>> +int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq,
>> + const char *name)
>> {
>> struct bmg160_data *data;
>> struct iio_dev *indio_dev;
>> int ret;
>> - const char *name = NULL;
>> - struct regmap *regmap;
>> - struct device *dev = &client->dev;
>> -
>> - regmap = devm_regmap_init_i2c(client, &bmg160_regmap_i2c_conf);
>> - if (IS_ERR(regmap)) {
>> - dev_err(&client->dev, "Failed to register i2c regmap %d\n",
>> - (int)PTR_ERR(regmap));
>> - return PTR_ERR(regmap);
>> - }
>>
>> - indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
>> + indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
>> if (!indio_dev)
>> return -ENOMEM;
>>
>> data = iio_priv(indio_dev);
>> dev_set_drvdata(dev, indio_dev);
>> data->dev = dev;
>> - data->irq = client->irq;
>> + data->irq = irq;
>> + data->regmap = regmap;
>>
>> ret = bmg160_chip_init(data);
>> if (ret < 0)
>> @@ -1028,9 +1011,6 @@ static int bmg160_probe(struct i2c_client *client,
>>
>> mutex_init(&data->mutex);
>>
>> - if (id)
>> - name = id->name;
>> -
>> if (ACPI_HANDLE(dev))
>> name = bmg160_match_acpi_device(dev);
>>
>> @@ -1125,15 +1105,16 @@ err_trigger_unregister:
>>
>> return ret;
>> }
>> +EXPORT_SYMBOL_GPL(bmg160_core_probe);
>>
>> -static int bmg160_remove(struct i2c_client *client)
>> +void bmg160_core_remove(struct device *dev)
>> {
>> - struct iio_dev *indio_dev = i2c_get_clientdata(client);
>> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
>> struct bmg160_data *data = iio_priv(indio_dev);
>>
>> - pm_runtime_disable(&client->dev);
>> - pm_runtime_set_suspended(&client->dev);
>> - pm_runtime_put_noidle(&client->dev);
>> + pm_runtime_disable(dev);
>> + pm_runtime_set_suspended(dev);
>> + pm_runtime_put_noidle(dev);
>>
>> iio_device_unregister(indio_dev);
>> iio_triggered_buffer_cleanup(indio_dev);
>> @@ -1146,9 +1127,8 @@ static int bmg160_remove(struct i2c_client *client)
>> mutex_lock(&data->mutex);
>> bmg160_set_mode(data, BMG160_MODE_DEEP_SUSPEND);
>> mutex_unlock(&data->mutex);
>> -
>> - return 0;
>> }
>> +EXPORT_SYMBOL_GPL(bmg160_core_remove);
>>
>> #ifdef CONFIG_PM_SLEEP
>> static int bmg160_suspend(struct device *dev)
>> @@ -1210,40 +1190,9 @@ static int bmg160_runtime_resume(struct device *dev)
>> }
>> #endif
>>
>> -static const struct dev_pm_ops bmg160_pm_ops = {
>> +const struct dev_pm_ops bmg160_pm_ops = {
>> SET_SYSTEM_SLEEP_PM_OPS(bmg160_suspend, bmg160_resume)
>> SET_RUNTIME_PM_OPS(bmg160_runtime_suspend,
>> bmg160_runtime_resume, NULL)
>> };
>>
>> -static const struct acpi_device_id bmg160_acpi_match[] = {
>> - {"BMG0160", 0},
>> - {"BMI055B", 0},
>> - {},
>> -};
>> -
>> -MODULE_DEVICE_TABLE(acpi, bmg160_acpi_match);
>> -
>> -static const struct i2c_device_id bmg160_id[] = {
>> - {"bmg160", 0},
>> - {"bmi055_gyro", 0},
>> - {}
>> -};
>> -
>> -MODULE_DEVICE_TABLE(i2c, bmg160_id);
>> -
>> -static struct i2c_driver bmg160_driver = {
>> - .driver = {
>> - .name = BMG160_DRV_NAME,
>> - .acpi_match_table = ACPI_PTR(bmg160_acpi_match),
>> - .pm = &bmg160_pm_ops,
>> - },
>> - .probe = bmg160_probe,
>> - .remove = bmg160_remove,
>> - .id_table = bmg160_id,
>> -};
>> -module_i2c_driver(bmg160_driver);
>> -
>> -MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
>> -MODULE_LICENSE("GPL v2");
>> -MODULE_DESCRIPTION("BMG160 Gyro driver");
>> diff --git a/drivers/iio/gyro/bmg160_i2c.c b/drivers/iio/gyro/bmg160_i2c.c
>> new file mode 100644
>> index 000000000000..90126a5a7663
>> --- /dev/null
>> +++ b/drivers/iio/gyro/bmg160_i2c.c
>> @@ -0,0 +1,71 @@
>> +#include <linux/i2c.h>
>> +#include <linux/regmap.h>
>> +#include <linux/iio/iio.h>
>> +#include <linux/module.h>
>> +#include <linux/acpi.h>
>> +
>> +#include "bmg160.h"
>> +
>> +static const struct regmap_config bmg160_regmap_i2c_conf = {
>> + .reg_bits = 8,
>> + .val_bits = 8,
>> + .max_register = 0x3f
>> +};
>> +
>> +static int bmg160_i2c_probe(struct i2c_client *client,
>> + const struct i2c_device_id *id)
>> +{
>> + struct regmap *regmap;
>> + const char *name = NULL;
>> +
>> + regmap = devm_regmap_init_i2c(client, &bmg160_regmap_i2c_conf);
>> + if (IS_ERR(regmap)) {
>> + dev_err(&client->dev, "Failed to register i2c regmap %d\n",
>> + (int)PTR_ERR(regmap));
>> + return PTR_ERR(regmap);
>> + }
>> +
>> + if (id)
>> + name = id->name;
>> +
>> + return bmg160_core_probe(&client->dev, regmap, client->irq, name);
>> +}
>> +
>> +static int bmg160_i2c_remove(struct i2c_client *client)
>> +{
>> + bmg160_core_remove(&client->dev);
>> +
>> + return 0;
>> +}
>> +
>> +static const struct acpi_device_id bmg160_acpi_match[] = {
>> + {"BMG0160", 0},
>> + {"BMI055B", 0},
>> + {},
>> +};
>> +
>> +MODULE_DEVICE_TABLE(acpi, bmg160_acpi_match);
>> +
>> +static const struct i2c_device_id bmg160_i2c_id[] = {
>> + {"bmg160", 0},
>> + {"bmi055_gyro", 0},
>> + {}
>> +};
>> +
>> +MODULE_DEVICE_TABLE(i2c, bmg160_i2c_id);
>> +
>> +static struct i2c_driver bmg160_i2c_driver = {
>> + .driver = {
>> + .name = "bmg160_i2c",
>> + .acpi_match_table = ACPI_PTR(bmg160_acpi_match),
>> + .pm = &bmg160_pm_ops,
>> + },
>> + .probe = bmg160_i2c_probe,
>> + .remove = bmg160_i2c_remove,
>> + .id_table = bmg160_i2c_id,
>> +};
>> +module_i2c_driver(bmg160_i2c_driver);
>> +
>> +MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
>> +MODULE_LICENSE("GPL v2");
>> +MODULE_DESCRIPTION("BMG160 I2C Gyro driver");
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Markus Pargmann <mpa@pengutronix.de> |
|---|---|
| Date | 2015-08-12 17:00 +0200 |
| Subject | [PATCH v3 3/6] iio: bmg160: Use generic dev_drvdata |
| Message-ID | <pWFFy-7yz-55@gated-at.bofh.it> |
| In reply to | #1206188 |
i2c_get_clientdata() is specifically for i2c. Replace it with the
generic dev_get/set_drvdata() to support different protocols.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
drivers/iio/gyro/bmg160.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c
index 4701ea17baea..6eab91ba8977 100644
--- a/drivers/iio/gyro/bmg160.c
+++ b/drivers/iio/gyro/bmg160.c
@@ -1020,7 +1020,7 @@ static int bmg160_probe(struct i2c_client *client,
return -ENOMEM;
data = iio_priv(indio_dev);
- i2c_set_clientdata(client, indio_dev);
+ dev_set_drvdata(&client->dev, indio_dev);
data->dev = &client->dev;
ret = bmg160_chip_init(data);
@@ -1154,7 +1154,7 @@ static int bmg160_remove(struct i2c_client *client)
#ifdef CONFIG_PM_SLEEP
static int bmg160_suspend(struct device *dev)
{
- struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct bmg160_data *data = iio_priv(indio_dev);
mutex_lock(&data->mutex);
@@ -1166,7 +1166,7 @@ static int bmg160_suspend(struct device *dev)
static int bmg160_resume(struct device *dev)
{
- struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct bmg160_data *data = iio_priv(indio_dev);
mutex_lock(&data->mutex);
@@ -1182,7 +1182,7 @@ static int bmg160_resume(struct device *dev)
#ifdef CONFIG_PM
static int bmg160_runtime_suspend(struct device *dev)
{
- struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct bmg160_data *data = iio_priv(indio_dev);
int ret;
@@ -1197,7 +1197,7 @@ static int bmg160_runtime_suspend(struct device *dev)
static int bmg160_runtime_resume(struct device *dev)
{
- struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct bmg160_data *data = iio_priv(indio_dev);
int ret;
--
2.4.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jonathan Cameron <jic23@kernel.org> |
|---|---|
| Date | 2015-08-15 17:00 +0200 |
| Subject | Re: [PATCH v3 3/6] iio: bmg160: Use generic dev_drvdata |
| Message-ID | <pXL6b-4B6-31@gated-at.bofh.it> |
| In reply to | #1206193 |
On 12/08/15 17:05, Srinivas Pandruvada wrote:
> On Wed, 2015-08-12 at 16:50 +0200, Markus Pargmann wrote:
>> i2c_get_clientdata() is specifically for i2c. Replace it with the
>> generic dev_get/set_drvdata() to support different protocols.
>>
>> Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Applied.
>> ---
>> drivers/iio/gyro/bmg160.c | 10 +++++-----
>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c
>> index 4701ea17baea..6eab91ba8977 100644
>> --- a/drivers/iio/gyro/bmg160.c
>> +++ b/drivers/iio/gyro/bmg160.c
>> @@ -1020,7 +1020,7 @@ static int bmg160_probe(struct i2c_client *client,
>> return -ENOMEM;
>>
>> data = iio_priv(indio_dev);
>> - i2c_set_clientdata(client, indio_dev);
>> + dev_set_drvdata(&client->dev, indio_dev);
>> data->dev = &client->dev;
>>
>> ret = bmg160_chip_init(data);
>> @@ -1154,7 +1154,7 @@ static int bmg160_remove(struct i2c_client *client)
>> #ifdef CONFIG_PM_SLEEP
>> static int bmg160_suspend(struct device *dev)
>> {
>> - struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
>> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
>> struct bmg160_data *data = iio_priv(indio_dev);
>>
>> mutex_lock(&data->mutex);
>> @@ -1166,7 +1166,7 @@ static int bmg160_suspend(struct device *dev)
>>
>> static int bmg160_resume(struct device *dev)
>> {
>> - struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
>> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
>> struct bmg160_data *data = iio_priv(indio_dev);
>>
>> mutex_lock(&data->mutex);
>> @@ -1182,7 +1182,7 @@ static int bmg160_resume(struct device *dev)
>> #ifdef CONFIG_PM
>> static int bmg160_runtime_suspend(struct device *dev)
>> {
>> - struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
>> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
>> struct bmg160_data *data = iio_priv(indio_dev);
>> int ret;
>>
>> @@ -1197,7 +1197,7 @@ static int bmg160_runtime_suspend(struct device *dev)
>>
>> static int bmg160_runtime_resume(struct device *dev)
>> {
>> - struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
>> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
>> struct bmg160_data *data = iio_priv(indio_dev);
>> int ret;
>>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Markus Pargmann <mpa@pengutronix.de> |
|---|---|
| Date | 2015-08-12 17:00 +0200 |
| Subject | [PATCH v3 4/6] iio: bmg160: Remove remaining uses of i2c_client |
| Message-ID | <pWFFy-7yz-57@gated-at.bofh.it> |
| In reply to | #1206188 |
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
drivers/iio/gyro/bmg160.c | 55 +++++++++++++++++++++++------------------------
1 file changed, 27 insertions(+), 28 deletions(-)
diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c
index 6eab91ba8977..39df64fb4262 100644
--- a/drivers/iio/gyro/bmg160.c
+++ b/drivers/iio/gyro/bmg160.c
@@ -110,6 +110,7 @@ struct bmg160_data {
int slope_thres;
bool dready_trigger_on;
bool motion_trigger_on;
+ int irq;
};
enum bmg160_axis {
@@ -961,18 +962,14 @@ static const struct iio_buffer_setup_ops bmg160_buffer_setup_ops = {
.postdisable = bmg160_buffer_postdisable,
};
-static int bmg160_gpio_probe(struct i2c_client *client,
- struct bmg160_data *data)
+static int bmg160_gpio_probe(struct bmg160_data *data)
{
struct device *dev;
struct gpio_desc *gpio;
int ret;
- if (!client)
- return -EINVAL;
-
- dev = &client->dev;
+ dev = data->dev;
/* data ready gpio interrupt pin */
gpio = devm_gpiod_get_index(dev, BMG160_GPIO_NAME, 0, GPIOD_IN);
@@ -981,11 +978,11 @@ static int bmg160_gpio_probe(struct i2c_client *client,
return PTR_ERR(gpio);
}
- ret = gpiod_to_irq(gpio);
+ data->irq = gpiod_to_irq(gpio);
dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
- return ret;
+ return 0;
}
static const char *bmg160_match_acpi_device(struct device *dev)
@@ -1007,6 +1004,7 @@ static int bmg160_probe(struct i2c_client *client,
int ret;
const char *name = NULL;
struct regmap *regmap;
+ struct device *dev = &client->dev;
regmap = devm_regmap_init_i2c(client, &bmg160_regmap_i2c_conf);
if (IS_ERR(regmap)) {
@@ -1020,8 +1018,9 @@ static int bmg160_probe(struct i2c_client *client,
return -ENOMEM;
data = iio_priv(indio_dev);
- dev_set_drvdata(&client->dev, indio_dev);
- data->dev = &client->dev;
+ dev_set_drvdata(dev, indio_dev);
+ data->dev = dev;
+ data->irq = client->irq;
ret = bmg160_chip_init(data);
if (ret < 0)
@@ -1032,22 +1031,22 @@ static int bmg160_probe(struct i2c_client *client,
if (id)
name = id->name;
- if (ACPI_HANDLE(&client->dev))
- name = bmg160_match_acpi_device(&client->dev);
+ if (ACPI_HANDLE(dev))
+ name = bmg160_match_acpi_device(dev);
- indio_dev->dev.parent = &client->dev;
+ indio_dev->dev.parent = dev;
indio_dev->channels = bmg160_channels;
indio_dev->num_channels = ARRAY_SIZE(bmg160_channels);
indio_dev->name = name;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &bmg160_info;
- if (client->irq <= 0)
- client->irq = bmg160_gpio_probe(client, data);
+ if (data->irq <= 0)
+ bmg160_gpio_probe(data);
- if (client->irq > 0) {
- ret = devm_request_threaded_irq(&client->dev,
- client->irq,
+ if (data->irq > 0) {
+ ret = devm_request_threaded_irq(dev,
+ data->irq,
bmg160_data_rdy_trig_poll,
bmg160_event_handler,
IRQF_TRIGGER_RISING,
@@ -1056,28 +1055,28 @@ static int bmg160_probe(struct i2c_client *client,
if (ret)
return ret;
- data->dready_trig = devm_iio_trigger_alloc(&client->dev,
+ data->dready_trig = devm_iio_trigger_alloc(dev,
"%s-dev%d",
indio_dev->name,
indio_dev->id);
if (!data->dready_trig)
return -ENOMEM;
- data->motion_trig = devm_iio_trigger_alloc(&client->dev,
+ data->motion_trig = devm_iio_trigger_alloc(dev,
"%s-any-motion-dev%d",
indio_dev->name,
indio_dev->id);
if (!data->motion_trig)
return -ENOMEM;
- data->dready_trig->dev.parent = &client->dev;
+ data->dready_trig->dev.parent = dev;
data->dready_trig->ops = &bmg160_trigger_ops;
iio_trigger_set_drvdata(data->dready_trig, indio_dev);
ret = iio_trigger_register(data->dready_trig);
if (ret)
return ret;
- data->motion_trig->dev.parent = &client->dev;
+ data->motion_trig->dev.parent = dev;
data->motion_trig->ops = &bmg160_trigger_ops;
iio_trigger_set_drvdata(data->motion_trig, indio_dev);
ret = iio_trigger_register(data->motion_trig);
@@ -1092,25 +1091,25 @@ static int bmg160_probe(struct i2c_client *client,
bmg160_trigger_handler,
&bmg160_buffer_setup_ops);
if (ret < 0) {
- dev_err(&client->dev,
+ dev_err(dev,
"iio triggered buffer setup failed\n");
goto err_trigger_unregister;
}
ret = iio_device_register(indio_dev);
if (ret < 0) {
- dev_err(&client->dev, "unable to register iio device\n");
+ dev_err(dev, "unable to register iio device\n");
goto err_buffer_cleanup;
}
- ret = pm_runtime_set_active(&client->dev);
+ ret = pm_runtime_set_active(dev);
if (ret)
goto err_iio_unregister;
- pm_runtime_enable(&client->dev);
- pm_runtime_set_autosuspend_delay(&client->dev,
+ pm_runtime_enable(dev);
+ pm_runtime_set_autosuspend_delay(dev,
BMG160_AUTO_SUSPEND_DELAY_MS);
- pm_runtime_use_autosuspend(&client->dev);
+ pm_runtime_use_autosuspend(dev);
return 0;
--
2.4.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> |
|---|---|
| Date | 2015-08-12 18:10 +0200 |
| Subject | Re: [PATCH v3 4/6] iio: bmg160: Remove remaining uses of i2c_client |
| Message-ID | <pWGLg-Uh-21@gated-at.bofh.it> |
| In reply to | #1206194 |
Can you not merge this with patch 2/6?
On Wed, 2015-08-12 at 16:50 +0200, Markus Pargmann wrote:
> Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
> ---
> drivers/iio/gyro/bmg160.c | 55 +++++++++++++++++++++++------------------------
> 1 file changed, 27 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c
> index 6eab91ba8977..39df64fb4262 100644
> --- a/drivers/iio/gyro/bmg160.c
> +++ b/drivers/iio/gyro/bmg160.c
> @@ -110,6 +110,7 @@ struct bmg160_data {
> int slope_thres;
> bool dready_trigger_on;
> bool motion_trigger_on;
> + int irq;
> };
>
> enum bmg160_axis {
> @@ -961,18 +962,14 @@ static const struct iio_buffer_setup_ops bmg160_buffer_setup_ops = {
> .postdisable = bmg160_buffer_postdisable,
> };
>
> -static int bmg160_gpio_probe(struct i2c_client *client,
> - struct bmg160_data *data)
> +static int bmg160_gpio_probe(struct bmg160_data *data)
>
> {
> struct device *dev;
> struct gpio_desc *gpio;
> int ret;
>
> - if (!client)
> - return -EINVAL;
> -
> - dev = &client->dev;
> + dev = data->dev;
>
> /* data ready gpio interrupt pin */
> gpio = devm_gpiod_get_index(dev, BMG160_GPIO_NAME, 0, GPIOD_IN);
> @@ -981,11 +978,11 @@ static int bmg160_gpio_probe(struct i2c_client *client,
> return PTR_ERR(gpio);
> }
>
> - ret = gpiod_to_irq(gpio);
> + data->irq = gpiod_to_irq(gpio);
>
> dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
>
> - return ret;
> + return 0;
> }
>
> static const char *bmg160_match_acpi_device(struct device *dev)
> @@ -1007,6 +1004,7 @@ static int bmg160_probe(struct i2c_client *client,
> int ret;
> const char *name = NULL;
> struct regmap *regmap;
> + struct device *dev = &client->dev;
>
> regmap = devm_regmap_init_i2c(client, &bmg160_regmap_i2c_conf);
> if (IS_ERR(regmap)) {
> @@ -1020,8 +1018,9 @@ static int bmg160_probe(struct i2c_client *client,
> return -ENOMEM;
>
> data = iio_priv(indio_dev);
> - dev_set_drvdata(&client->dev, indio_dev);
> - data->dev = &client->dev;
> + dev_set_drvdata(dev, indio_dev);
> + data->dev = dev;
> + data->irq = client->irq;
>
> ret = bmg160_chip_init(data);
> if (ret < 0)
> @@ -1032,22 +1031,22 @@ static int bmg160_probe(struct i2c_client *client,
> if (id)
> name = id->name;
>
> - if (ACPI_HANDLE(&client->dev))
> - name = bmg160_match_acpi_device(&client->dev);
> + if (ACPI_HANDLE(dev))
> + name = bmg160_match_acpi_device(dev);
>
> - indio_dev->dev.parent = &client->dev;
> + indio_dev->dev.parent = dev;
> indio_dev->channels = bmg160_channels;
> indio_dev->num_channels = ARRAY_SIZE(bmg160_channels);
> indio_dev->name = name;
> indio_dev->modes = INDIO_DIRECT_MODE;
> indio_dev->info = &bmg160_info;
>
> - if (client->irq <= 0)
> - client->irq = bmg160_gpio_probe(client, data);
> + if (data->irq <= 0)
> + bmg160_gpio_probe(data);
>
> - if (client->irq > 0) {
> - ret = devm_request_threaded_irq(&client->dev,
> - client->irq,
> + if (data->irq > 0) {
> + ret = devm_request_threaded_irq(dev,
> + data->irq,
> bmg160_data_rdy_trig_poll,
> bmg160_event_handler,
> IRQF_TRIGGER_RISING,
> @@ -1056,28 +1055,28 @@ static int bmg160_probe(struct i2c_client *client,
> if (ret)
> return ret;
>
> - data->dready_trig = devm_iio_trigger_alloc(&client->dev,
> + data->dready_trig = devm_iio_trigger_alloc(dev,
> "%s-dev%d",
> indio_dev->name,
> indio_dev->id);
> if (!data->dready_trig)
> return -ENOMEM;
>
> - data->motion_trig = devm_iio_trigger_alloc(&client->dev,
> + data->motion_trig = devm_iio_trigger_alloc(dev,
> "%s-any-motion-dev%d",
> indio_dev->name,
> indio_dev->id);
> if (!data->motion_trig)
> return -ENOMEM;
>
> - data->dready_trig->dev.parent = &client->dev;
> + data->dready_trig->dev.parent = dev;
> data->dready_trig->ops = &bmg160_trigger_ops;
> iio_trigger_set_drvdata(data->dready_trig, indio_dev);
> ret = iio_trigger_register(data->dready_trig);
> if (ret)
> return ret;
>
> - data->motion_trig->dev.parent = &client->dev;
> + data->motion_trig->dev.parent = dev;
> data->motion_trig->ops = &bmg160_trigger_ops;
> iio_trigger_set_drvdata(data->motion_trig, indio_dev);
> ret = iio_trigger_register(data->motion_trig);
> @@ -1092,25 +1091,25 @@ static int bmg160_probe(struct i2c_client *client,
> bmg160_trigger_handler,
> &bmg160_buffer_setup_ops);
> if (ret < 0) {
> - dev_err(&client->dev,
> + dev_err(dev,
> "iio triggered buffer setup failed\n");
> goto err_trigger_unregister;
> }
>
> ret = iio_device_register(indio_dev);
> if (ret < 0) {
> - dev_err(&client->dev, "unable to register iio device\n");
> + dev_err(dev, "unable to register iio device\n");
> goto err_buffer_cleanup;
> }
>
> - ret = pm_runtime_set_active(&client->dev);
> + ret = pm_runtime_set_active(dev);
> if (ret)
> goto err_iio_unregister;
>
> - pm_runtime_enable(&client->dev);
> - pm_runtime_set_autosuspend_delay(&client->dev,
> + pm_runtime_enable(dev);
> + pm_runtime_set_autosuspend_delay(dev,
> BMG160_AUTO_SUSPEND_DELAY_MS);
> - pm_runtime_use_autosuspend(&client->dev);
> + pm_runtime_use_autosuspend(dev);
>
> return 0;
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jonathan Cameron <jic23@kernel.org> |
|---|---|
| Date | 2015-08-15 17:00 +0200 |
| Subject | Re: [PATCH v3 4/6] iio: bmg160: Remove remaining uses of i2c_client |
| Message-ID | <pXL6a-4B6-29@gated-at.bofh.it> |
| In reply to | #1206227 |
On 12/08/15 17:08, Srinivas Pandruvada wrote:
> Can you not merge this with patch 2/6?
Meh, I already took that one so will take this one separately.
You are correct of course that it might makes sense to do this
all together. Ah well ;)
> On Wed, 2015-08-12 at 16:50 +0200, Markus Pargmann wrote:
>> Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Applied.
>> ---
>> drivers/iio/gyro/bmg160.c | 55 +++++++++++++++++++++++------------------------
>> 1 file changed, 27 insertions(+), 28 deletions(-)
>>
>> diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c
>> index 6eab91ba8977..39df64fb4262 100644
>> --- a/drivers/iio/gyro/bmg160.c
>> +++ b/drivers/iio/gyro/bmg160.c
>> @@ -110,6 +110,7 @@ struct bmg160_data {
>> int slope_thres;
>> bool dready_trigger_on;
>> bool motion_trigger_on;
>> + int irq;
>> };
>>
>> enum bmg160_axis {
>> @@ -961,18 +962,14 @@ static const struct iio_buffer_setup_ops bmg160_buffer_setup_ops = {
>> .postdisable = bmg160_buffer_postdisable,
>> };
>>
>> -static int bmg160_gpio_probe(struct i2c_client *client,
>> - struct bmg160_data *data)
>> +static int bmg160_gpio_probe(struct bmg160_data *data)
>>
>> {
>> struct device *dev;
>> struct gpio_desc *gpio;
>> int ret;
>>
>> - if (!client)
>> - return -EINVAL;
>> -
>> - dev = &client->dev;
>> + dev = data->dev;
>>
>> /* data ready gpio interrupt pin */
>> gpio = devm_gpiod_get_index(dev, BMG160_GPIO_NAME, 0, GPIOD_IN);
>> @@ -981,11 +978,11 @@ static int bmg160_gpio_probe(struct i2c_client *client,
>> return PTR_ERR(gpio);
>> }
>>
>> - ret = gpiod_to_irq(gpio);
>> + data->irq = gpiod_to_irq(gpio);
>>
>> dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
>>
>> - return ret;
>> + return 0;
>> }
>>
>> static const char *bmg160_match_acpi_device(struct device *dev)
>> @@ -1007,6 +1004,7 @@ static int bmg160_probe(struct i2c_client *client,
>> int ret;
>> const char *name = NULL;
>> struct regmap *regmap;
>> + struct device *dev = &client->dev;
>>
>> regmap = devm_regmap_init_i2c(client, &bmg160_regmap_i2c_conf);
>> if (IS_ERR(regmap)) {
>> @@ -1020,8 +1018,9 @@ static int bmg160_probe(struct i2c_client *client,
>> return -ENOMEM;
>>
>> data = iio_priv(indio_dev);
>> - dev_set_drvdata(&client->dev, indio_dev);
>> - data->dev = &client->dev;
>> + dev_set_drvdata(dev, indio_dev);
>> + data->dev = dev;
>> + data->irq = client->irq;
>>
>> ret = bmg160_chip_init(data);
>> if (ret < 0)
>> @@ -1032,22 +1031,22 @@ static int bmg160_probe(struct i2c_client *client,
>> if (id)
>> name = id->name;
>>
>> - if (ACPI_HANDLE(&client->dev))
>> - name = bmg160_match_acpi_device(&client->dev);
>> + if (ACPI_HANDLE(dev))
>> + name = bmg160_match_acpi_device(dev);
>>
>> - indio_dev->dev.parent = &client->dev;
>> + indio_dev->dev.parent = dev;
>> indio_dev->channels = bmg160_channels;
>> indio_dev->num_channels = ARRAY_SIZE(bmg160_channels);
>> indio_dev->name = name;
>> indio_dev->modes = INDIO_DIRECT_MODE;
>> indio_dev->info = &bmg160_info;
>>
>> - if (client->irq <= 0)
>> - client->irq = bmg160_gpio_probe(client, data);
>> + if (data->irq <= 0)
>> + bmg160_gpio_probe(data);
>>
>> - if (client->irq > 0) {
>> - ret = devm_request_threaded_irq(&client->dev,
>> - client->irq,
>> + if (data->irq > 0) {
>> + ret = devm_request_threaded_irq(dev,
>> + data->irq,
>> bmg160_data_rdy_trig_poll,
>> bmg160_event_handler,
>> IRQF_TRIGGER_RISING,
>> @@ -1056,28 +1055,28 @@ static int bmg160_probe(struct i2c_client *client,
>> if (ret)
>> return ret;
>>
>> - data->dready_trig = devm_iio_trigger_alloc(&client->dev,
>> + data->dready_trig = devm_iio_trigger_alloc(dev,
>> "%s-dev%d",
>> indio_dev->name,
>> indio_dev->id);
>> if (!data->dready_trig)
>> return -ENOMEM;
>>
>> - data->motion_trig = devm_iio_trigger_alloc(&client->dev,
>> + data->motion_trig = devm_iio_trigger_alloc(dev,
>> "%s-any-motion-dev%d",
>> indio_dev->name,
>> indio_dev->id);
>> if (!data->motion_trig)
>> return -ENOMEM;
>>
>> - data->dready_trig->dev.parent = &client->dev;
>> + data->dready_trig->dev.parent = dev;
>> data->dready_trig->ops = &bmg160_trigger_ops;
>> iio_trigger_set_drvdata(data->dready_trig, indio_dev);
>> ret = iio_trigger_register(data->dready_trig);
>> if (ret)
>> return ret;
>>
>> - data->motion_trig->dev.parent = &client->dev;
>> + data->motion_trig->dev.parent = dev;
>> data->motion_trig->ops = &bmg160_trigger_ops;
>> iio_trigger_set_drvdata(data->motion_trig, indio_dev);
>> ret = iio_trigger_register(data->motion_trig);
>> @@ -1092,25 +1091,25 @@ static int bmg160_probe(struct i2c_client *client,
>> bmg160_trigger_handler,
>> &bmg160_buffer_setup_ops);
>> if (ret < 0) {
>> - dev_err(&client->dev,
>> + dev_err(dev,
>> "iio triggered buffer setup failed\n");
>> goto err_trigger_unregister;
>> }
>>
>> ret = iio_device_register(indio_dev);
>> if (ret < 0) {
>> - dev_err(&client->dev, "unable to register iio device\n");
>> + dev_err(dev, "unable to register iio device\n");
>> goto err_buffer_cleanup;
>> }
>>
>> - ret = pm_runtime_set_active(&client->dev);
>> + ret = pm_runtime_set_active(dev);
>> if (ret)
>> goto err_iio_unregister;
>>
>> - pm_runtime_enable(&client->dev);
>> - pm_runtime_set_autosuspend_delay(&client->dev,
>> + pm_runtime_enable(dev);
>> + pm_runtime_set_autosuspend_delay(dev,
>> BMG160_AUTO_SUSPEND_DELAY_MS);
>> - pm_runtime_use_autosuspend(&client->dev);
>> + pm_runtime_use_autosuspend(dev);
>>
>> return 0;
>>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Lars-Peter Clausen <lars@metafoo.de> |
|---|---|
| Date | 2015-08-12 17:10 +0200 |
| Message-ID | <pWFPc-7Zw-9@gated-at.bofh.it> |
| In reply to | #1206188 |
Hi,
Markus and Irina can you try to synchronize your efforts. This series will
conflict with http://marc.info/?l=linux-iio&m=143938994602171&w=2
I think it would be best if the multi-read emulation support is added to
regmap (which I think Markus' earlier series did).
- Lars
On 08/12/2015 04:50 PM, Markus Pargmann wrote:
> Hi,
>
> bmg160 and bmi055 can be used via I2C and SPI. This series converts the driver
> to regmap and splits core driver and I2C/SPI.
>
> Changes in v3:
> - removed 'select REGMAP' as it is selected by REGMAP_I2C
> - added EXPORT_SYMBOL_GPL for the core functions
> - removed default values from regmap_config
> - Added max_register and unset use_single_rw in regmap_config
> - Changed Makefile to always compile bmg160-core with either spi or i2c. It is
> not possible now to compile the core alone.
>
> Changes in v2:
> - Added the id->name from the SPI driver to be used as iio device name
> - Fixed Kconfig in patch 2 to add selects for REGMAP_I2C
> - Fixed regmap configs to be static const
>
>
> Best regards,
>
> Markus
>
>
> Markus Pargmann (6):
> iio: bmg160: Use i2c regmap instead of direct i2c access
> iio: bmg160: Remove i2c_client from data struct
> iio: bmg160: Use generic dev_drvdata
> iio: bmg160: Remove remaining uses of i2c_client
> iio: bmg160: Separate i2c and core driver
> iio: bmg160: Add SPI driver
>
> drivers/iio/gyro/Kconfig | 28 ++-
> drivers/iio/gyro/Makefile | 3 +-
> drivers/iio/gyro/bmg160.h | 10 +
> drivers/iio/gyro/{bmg160.c => bmg160_core.c} | 358 +++++++++++----------------
> drivers/iio/gyro/bmg160_i2c.c | 71 ++++++
> drivers/iio/gyro/bmg160_spi.c | 57 +++++
> 6 files changed, 306 insertions(+), 221 deletions(-)
> create mode 100644 drivers/iio/gyro/bmg160.h
> rename drivers/iio/gyro/{bmg160.c => bmg160_core.c} (74%)
> create mode 100644 drivers/iio/gyro/bmg160_i2c.c
> create mode 100644 drivers/iio/gyro/bmg160_spi.c
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jonathan Cameron <jic23@kernel.org> |
|---|---|
| Date | 2015-08-15 16:50 +0200 |
| Message-ID | <pXKWt-4ph-11@gated-at.bofh.it> |
| In reply to | #1206197 |
On 12/08/15 16:04, Lars-Peter Clausen wrote:
> Hi,
>
> Markus and Irina can you try to synchronize your efforts. This series will
> conflict with http://marc.info/?l=linux-iio&m=143938994602171&w=2
>
> I think it would be best if the multi-read emulation support is added to
> regmap (which I think Markus' earlier series did).
Good spot Lars, I'd managed to miss this clash entirely (and had both sets
marked for applying - though I'd marked them for such on totally different
days!)
Anyhow, I'm going to take this series for now and we'll have to deal with
the emulation stuff on top of it.
Jonathan
>
> - Lars
>
> On 08/12/2015 04:50 PM, Markus Pargmann wrote:
>> Hi,
>>
>> bmg160 and bmi055 can be used via I2C and SPI. This series converts the driver
>> to regmap and splits core driver and I2C/SPI.
>>
>> Changes in v3:
>> - removed 'select REGMAP' as it is selected by REGMAP_I2C
>> - added EXPORT_SYMBOL_GPL for the core functions
>> - removed default values from regmap_config
>> - Added max_register and unset use_single_rw in regmap_config
>> - Changed Makefile to always compile bmg160-core with either spi or i2c. It is
>> not possible now to compile the core alone.
>>
>> Changes in v2:
>> - Added the id->name from the SPI driver to be used as iio device name
>> - Fixed Kconfig in patch 2 to add selects for REGMAP_I2C
>> - Fixed regmap configs to be static const
>>
>>
>> Best regards,
>>
>> Markus
>>
>>
>> Markus Pargmann (6):
>> iio: bmg160: Use i2c regmap instead of direct i2c access
>> iio: bmg160: Remove i2c_client from data struct
>> iio: bmg160: Use generic dev_drvdata
>> iio: bmg160: Remove remaining uses of i2c_client
>> iio: bmg160: Separate i2c and core driver
>> iio: bmg160: Add SPI driver
>>
>> drivers/iio/gyro/Kconfig | 28 ++-
>> drivers/iio/gyro/Makefile | 3 +-
>> drivers/iio/gyro/bmg160.h | 10 +
>> drivers/iio/gyro/{bmg160.c => bmg160_core.c} | 358 +++++++++++----------------
>> drivers/iio/gyro/bmg160_i2c.c | 71 ++++++
>> drivers/iio/gyro/bmg160_spi.c | 57 +++++
>> 6 files changed, 306 insertions(+), 221 deletions(-)
>> create mode 100644 drivers/iio/gyro/bmg160.h
>> rename drivers/iio/gyro/{bmg160.c => bmg160_core.c} (74%)
>> create mode 100644 drivers/iio/gyro/bmg160_i2c.c
>> create mode 100644 drivers/iio/gyro/bmg160_spi.c
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Tirdea, Irina" <irina.tirdea@intel.com> |
|---|---|
| Date | 2015-08-17 11:30 +0200 |
| Message-ID | <pYoTT-3bm-1@gated-at.bofh.it> |
| In reply to | #1206197 |
> -----Original Message-----
> From: Lars-Peter Clausen [mailto:lars@metafoo.de]
> Sent: 12 August, 2015 18:04
> To: Markus Pargmann; Jonathan Cameron
> Cc: Srinivas Pandruvada; Dogaru, Vlad; Paul Bolle; linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org; kernel@pengutronix.de;
> Tirdea, Irina
> Subject: Re: [PATCH v3 0/6] iio: bmg160: Add SPI connection
>
> Hi,
>
> Markus and Irina can you try to synchronize your efforts. This series will
> conflict with http://marc.info/?l=linux-iio&m=143938994602171&w=2
>
Hi Lars,
Good catch, especially since those patches might have been merged
through another tree. Completely missed this one.
> I think it would be best if the multi-read emulation support is added to
> regmap (which I think Markus' earlier series did).
>
I think my i2c controllers will work directly with regmap_bulk_read,
so I probably won't need additional changes for regmap. I will rebase
the bmg160 patches on top of the ones that add regmap support.
Thanks,
Irina
> - Lars
>
> On 08/12/2015 04:50 PM, Markus Pargmann wrote:
> > Hi,
> >
> > bmg160 and bmi055 can be used via I2C and SPI. This series converts the driver
> > to regmap and splits core driver and I2C/SPI.
> >
> > Changes in v3:
> > - removed 'select REGMAP' as it is selected by REGMAP_I2C
> > - added EXPORT_SYMBOL_GPL for the core functions
> > - removed default values from regmap_config
> > - Added max_register and unset use_single_rw in regmap_config
> > - Changed Makefile to always compile bmg160-core with either spi or i2c. It is
> > not possible now to compile the core alone.
> >
> > Changes in v2:
> > - Added the id->name from the SPI driver to be used as iio device name
> > - Fixed Kconfig in patch 2 to add selects for REGMAP_I2C
> > - Fixed regmap configs to be static const
> >
> >
> > Best regards,
> >
> > Markus
> >
> >
> > Markus Pargmann (6):
> > iio: bmg160: Use i2c regmap instead of direct i2c access
> > iio: bmg160: Remove i2c_client from data struct
> > iio: bmg160: Use generic dev_drvdata
> > iio: bmg160: Remove remaining uses of i2c_client
> > iio: bmg160: Separate i2c and core driver
> > iio: bmg160: Add SPI driver
> >
> > drivers/iio/gyro/Kconfig | 28 ++-
> > drivers/iio/gyro/Makefile | 3 +-
> > drivers/iio/gyro/bmg160.h | 10 +
> > drivers/iio/gyro/{bmg160.c => bmg160_core.c} | 358 +++++++++++----------------
> > drivers/iio/gyro/bmg160_i2c.c | 71 ++++++
> > drivers/iio/gyro/bmg160_spi.c | 57 +++++
> > 6 files changed, 306 insertions(+), 221 deletions(-)
> > create mode 100644 drivers/iio/gyro/bmg160.h
> > rename drivers/iio/gyro/{bmg160.c => bmg160_core.c} (74%)
> > create mode 100644 drivers/iio/gyro/bmg160_i2c.c
> > create mode 100644 drivers/iio/gyro/bmg160_spi.c
> >
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web