Remove BQ27xxx platform interface
Subsystems (4)
PATCH v2 2/2 power: supply: bq27xxx: move platform driver code into bq27xxx_battery_hdq.c
In reply to Andrew F. DavisWhen the BQ27xxx driver was originally written the w1 subsystem only allowed device drivers for w1 attached devices to live in the w1 subsystem. Kernel driver subsystems expect that the driver for a device live in the directory of the subsystem for which it implements functionality, not in the directory of the bus that it is attached. To work around this, the BQ27xxx driver was implemented as a platform device driver and the interface driver would instantiate this device from within the w1 directory, then pass a w1 read callback as platform data.
As we can now have the w1 interface driver in the power/supply directory (like we do already with the i2c interface driver) we can remove this middle-layer platform driver.
--- drivers/power/supply/bq27xxx_battery.c | 104 ------------ drivers/power/supply/bq27xxx_battery_hdq.c | 250 ++++++++++++++++------------- include/linux/power/bq27xxx_battery.h | 17 -- 3 files changed, 135 insertions(+), 236 deletions(-)
rewrite drivers/power/supply/bq27xxx_battery_hdq.c (72%)
drivers/power/supply/bq27xxx_battery.c +0 -104
@@ -1938,110 +1938,6 @@ void bq27xxx_battery_teardown(struct bq27xxx_device_info *di) }EXPORT_SYMBOL_GPL (bq27xxx_battery_teardown); -static int bq27xxx_battery_platform_read (struct bq27xxx_device_info *di,u8 reg, -bool single) -{ -struct device *dev = di->dev; -struct bq27xxx_platform_data *pdata = dev->platform_data; -unsigned int timeout =3 ; -int upper, lower; -int temp; - -if (!single) { -/* Make sure the value has not changed in between reading the -* lower and the upper part */ - upper = pdata->read (dev, reg +1 ); -do { - temp = upper; -if (upper <0 ) -return upper; - - lower = pdata->read (dev, reg); -if (lower <0 ) -return lower; - - upper = pdata->read (dev, reg +1 ); - }while (temp != upper && --timeout); - -if (timeout ==0 ) -return -EIO ; - -return (upper <<8 ) | lower; - } - -return pdata->read (dev, reg); -} - -static int bq27xxx_battery_platform_probe (struct platform_device *pdev) -{ -struct bq27xxx_device_info *di; -struct bq27xxx_platform_data *pdata = pdev->dev.platform_data; - -if (!pdata) { -dev_err (&pdev->dev,"no platform_data supplied\n" ); -return -EINVAL ; - } - -if (!pdata->read) { -dev_err (&pdev->dev,"no hdq read callback supplied\n" ); -return -EINVAL ; - } - -if (!pdata->chip) { -dev_err (&pdev->dev,"no device supplied\n" ); -return -EINVAL ; - } - - di =devm_kzalloc (&pdev->dev,sizeof (*di),GFP_KERNEL ); -if (!di) -return -ENOMEM ; - -platform_set_drvdata (pdev, di); - - di->dev = &pdev->dev; - di->chip = pdata->chip; - di->name = pdata->name ?:dev_name (&pdev->dev); - di->bus.read = bq27xxx_battery_platform_read; - -return bq27xxx_battery_setup (di); -} - -static int bq27xxx_battery_platform_remove (struct platform_device *pdev) -{ -struct bq27xxx_device_info *di =platform_get_drvdata (pdev); - -bq27xxx_battery_teardown (di); - -return 0 ; -} - -static const struct platform_device_id bq27xxx_battery_platform_id_table[] = { - {"bq27000-battery" , }, - {/* sentinel */ } -}; -MODULE_DEVICE_TABLE (platform, bq27xxx_battery_platform_id_table); - -#ifdef CONFIG_OF -static const struct of_device_id bq27xxx_battery_platform_of_match_table[] = { - { .compatible ="ti,bq27000" }, - {}, -}; -MODULE_DEVICE_TABLE (of, bq27xxx_battery_platform_of_match_table); -#endif - -static struct platform_driver bq27xxx_battery_platform_driver = { - .probe = bq27xxx_battery_platform_probe, - .remove = bq27xxx_battery_platform_remove, - .driver = { - .name ="bq27000-battery" , - .of_match_table =of_match_ptr (bq27xxx_battery_platform_of_match_table), - }, - .id_table = bq27xxx_battery_platform_id_table, -}; -module_platform_driver (bq27xxx_battery_platform_driver); - -MODULE_ALIAS ("platform:bq27000-battery" ); -MODULE_AUTHOR ("Rodolfo Giometti <[email protected]>" );MODULE_DESCRIPTION ("BQ27xxx battery monitor driver" );MODULE_LICENSE ("GPL" );
drivers/power/supply/bq27xxx_battery_hdq.c +135 -115
250 lines not on this page · raw message
include/linux/power/bq27xxx_battery.h +0 -17
@@ -20,23 +20,6 @@ enum bq27xxx_chip { BQ27421, /* bq27421, bq27425, bq27441, bq27621 */ }; -/** -* struct bq27xxx_plaform_data - Platform data for bq27xxx devices -* @name: Name of the battery. -* @chip: Chip class number of this device. -* @read: HDQ read callback. -* This function should provide access to the HDQ bus the battery is -* connected to. -* The first parameter is a pointer to the battery device, the second the -* register to be read. The return value should either be the content of -* the passed register or an error value. -*/ -struct bq27xxx_platform_data { -const char *name; -enum bq27xxx_chip chip; -int (*read)(struct device *dev,unsigned int ); -}; -struct bq27xxx_device_info ;struct bq27xxx_access_methods {int (*read)(struct bq27xxx_device_info *di,u8 reg,bool single);
Signature · 1 line
2.13.0
v2 cover Remove BQ27xxx platform interface
To finish the work started in this patch[0] we needed to reorganize the 1-wire subsystem a bit, this is done here[1]. After that is taken this series can remove the need for a platform driver for supporting 1-wire connected BQ27xxx devices.
Thanks,
Andrew
Changes from v1:
- Rebased on v4.13-rc1
- [1] has been taken, this series can now be merged
[0] https://patchwork.kernel.org/patch/7684371/
[1] https://lkml.org/lkml/2017/3/16/604
Andrew F. Davis (2):
power: supply: move HDQ interface for bq27xxx from w1 to power/supply
power: supply: bq27xxx: move platform driver code into
bq27xxx_battery_hdq.c
drivers/power/supply/Kconfig | 9 ++ drivers/power/supply/Makefile | 1 + drivers/power/supply/bq27xxx_battery.c | 104 ---------------------- drivers/power/supply/bq27xxx_battery_hdq.c | 135 +++++++++++++++++++++++++++++ drivers/w1/slaves/Kconfig | 6 -- drivers/w1/slaves/Makefile | 1 - drivers/w1/slaves/w1_bq27000.c | 117 ------------------------- include/linux/power/bq27xxx_battery.h | 17 ---- 8 files changed, 145 insertions(+), 245 deletions(-) create mode 100644 drivers/power/supply/bq27xxx_battery_hdq.c delete mode 100644 drivers/w1/slaves/w1_bq27000.c
Signature · 1 line
2.13.0
PATCH v2 1/2 power: supply: move HDQ interface for bq27xxx from w1 to power/supply
The HDQ interface driver should be in this folder just like the I2C interface driver. Move this driver out of drivers/w1/slave and into drivers/power/supply.
---
drivers/power/supply/Kconfig | 9 +++++++++
drivers/power/supply/Makefile | 1 +
.../slaves/w1_bq27000.c => power/supply/bq27xxx_battery_hdq.c} | 2 --
drivers/w1/slaves/Kconfig | 6 ------
drivers/w1/slaves/Makefile | 1 -
5 files changed, 10 insertions(+), 9 deletions(-)
rename drivers/{w1/slaves/w1_bq27000.c => power/supply/bq27xxx_battery_hdq.c} (98%)drivers/power/supply/Kconfig +9 -0
@@ -198,6 +198,15 @@ config BATTERY_BQ27XXX_I2C Say Y here to enable support for batteries with BQ27xxx chips connected over an I2C bus. +config BATTERY_BQ27XXX_HDQ + tristate "BQ27xxx HDQ support" + depends on BATTERY_BQ27XXX + depends on W1 + default y + help + Say Y here to enable support for batteries with BQ27xxx chips + connected over an HDQ bus. + config BATTERY_BQ27XXX_DT_UPDATES_NVM bool "BQ27xxx support for update of NVM/flash data memory" depends on BATTERY_BQ27XXX_I2C
drivers/power/supply/Makefile +1 -0
@@ -38,6 +38,7 @@ obj-$(CONFIG_BATTERY_SBS) += sbs-battery.o obj-$(CONFIG_CHARGER_SBS) += sbs-charger.o obj-$(CONFIG_BATTERY_BQ27XXX) += bq27xxx_battery.o obj-$(CONFIG_BATTERY_BQ27XXX_I2C) += bq27xxx_battery_i2c.o +obj-$(CONFIG_BATTERY_BQ27XXX_HDQ) += bq27xxx_battery_hdq.o obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o obj-$(CONFIG_BATTERY_DA9052) += da9052-battery.o obj-$(CONFIG_CHARGER_DA9150) += da9150-charger.o
drivers/power/supply/bq27xxx_battery_hdq.c renamed from drivers/w1/slaves/w1_bq27000.c +0 -2
@@ -1,6 +1,4 @@/* -* drivers/w1/slaves/w1_bq27000.c -* * Copyright (C) 2007 Texas Instruments, Inc. * * This file is licensed under the terms of the GNU General Public License
drivers/w1/slaves/Kconfig +0 -6
@@ -140,10 +140,4 @@ config W1_SLAVE_DS28E04 If you are unsure, say N. -config W1_SLAVE_BQ27000 - tristate "BQ27000 slave support" - help - Say Y here if you want to use a hdq - bq27000 slave support. - endmenu
drivers/w1/slaves/Makefile +0 -1
@@ -15,5 +15,4 @@ obj-$(CONFIG_W1_SLAVE_DS2438) += w1_ds2438.o obj-$(CONFIG_W1_SLAVE_DS2760) += w1_ds2760.o obj-$(CONFIG_W1_SLAVE_DS2780) += w1_ds2780.o obj-$(CONFIG_W1_SLAVE_DS2781) += w1_ds2781.o -obj-$(CONFIG_W1_SLAVE_BQ27000) += w1_bq27000.o obj-$(CONFIG_W1_SLAVE_DS28E04) += w1_ds28e04.o
Signature · 1 line
2.13.0
Re: [PATCH v2 1/2] power: supply: move HDQ interface for bq27xxx from w1 to power/supply
Hi,
Quoted 7 lines · Andrew F. Davis
The HDQ interface driver should be in this folder just like the I2C interface driver. Move this driver out of
drivers/w1/slaveand intodrivers/power/supply.Signed-off-by Andrew F. Davis <[email protected]>Acked-by Pali Rohár <[email protected]>
Thanks, queued to power-supply's for-next branch. I prepared a immutable branch/tag for the w1 tree and will send a pull request for that in a minute.
-- Sebastian
Quoted 82 lines
drivers/power/supply/Kconfig | 9 +++++++++ drivers/power/supply/Makefile | 1 + .../slaves/w1_bq27000.c => power/supply/bq27xxx_battery_hdq.c} | 2 -- drivers/w1/slaves/Kconfig | 6 ------ drivers/w1/slaves/Makefile | 1 - 5 files changed, 10 insertions(+), 9 deletions(-) rename drivers/{w1/slaves/w1_bq27000.c => power/supply/bq27xxx_battery_hdq.c} (98%)drivers/power/supply/Kconfig +9
-0@@ -198,6 +198,15 @@ config BATTERY_BQ27XXX_I2C Say Y here to enable support for batteries with BQ27xxx chips connected over an I2C bus. +config BATTERY_BQ27XXX_HDQ + tristate "BQ27xxx HDQ support" + depends on BATTERY_BQ27XXX + depends on W1 + default y + help + Say Y here to enable support for batteries with BQ27xxx chips + connected over an HDQ bus. + config BATTERY_BQ27XXX_DT_UPDATES_NVM bool "BQ27xxx support for update of NVM/flash data memory" depends on BATTERY_BQ27XXX_I2Cdrivers/power/supply/Makefile +1
-0@@ -38,6 +38,7 @@ obj-$(CONFIG_BATTERY_SBS) += sbs-battery.o obj-$(CONFIG_CHARGER_SBS) += sbs-charger.o obj-$(CONFIG_BATTERY_BQ27XXX) += bq27xxx_battery.o obj-$(CONFIG_BATTERY_BQ27XXX_I2C) += bq27xxx_battery_i2c.o +obj-$(CONFIG_BATTERY_BQ27XXX_HDQ) += bq27xxx_battery_hdq.o obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o obj-$(CONFIG_BATTERY_DA9052) += da9052-battery.o obj-$(CONFIG_CHARGER_DA9150) += da9150-charger.odrivers/power/supply/bq27xxx_battery_hdq.c renamed from drivers/w1/slaves/w1_bq27000.c +0
-2@@ -1,6 +1,4 @@/* -* drivers/w1/slaves/w1_bq27000.c -* * Copyright (C) 2007 Texas Instruments, Inc. * * This file is licensed under the terms of the GNU General Public License drivers/w1/slaves/Kconfig +0
-6@@ -140,10 +140,4 @@ config W1_SLAVE_DS28E04 If you are unsure, say N. -config W1_SLAVE_BQ27000 - tristate "BQ27000 slave support" - help - Say Y here if you want to use a hdq - bq27000 slave support. - endmenudrivers/w1/slaves/Makefile +0
-1@@ -15,5 +15,4 @@ obj-$(CONFIG_W1_SLAVE_DS2438) += w1_ds2438.o obj-$(CONFIG_W1_SLAVE_DS2760) += w1_ds2760.o obj-$(CONFIG_W1_SLAVE_DS2780) += w1_ds2780.o obj-$(CONFIG_W1_SLAVE_DS2781) += w1_ds2781.o -obj-$(CONFIG_W1_SLAVE_BQ27000) += w1_bq27000.o obj-$(CONFIG_W1_SLAVE_DS28E04) += w1_ds28e04.oSignature · 1 line
2.13.0
Re: [PATCH v2 2/2] power: supply: bq27xxx: move platform driver code into bq27xxx_battery_hdq.c
In reply to Andrew F. DavisHi,
Quoted 9 lines · Andrew F. Davis
When the BQ27xxx driver was originally written the w1 subsystem only allowed device drivers for w1 attached devices to live in the w1 subsystem. Kernel driver subsystems expect that the driver for a device live in the directory of the subsystem for which it implements functionality, not in the directory of the bus that it is attached. To work around this, the BQ27xxx driver was implemented as a platform device driver and the interface driver would instantiate this device from within the w1 directory, then pass a w1 read callback as platform data.
Quoted 7 lines
As we can now have the w1 interface driver in the power/supply directory (like we do already with the i2c interface driver) we can remove this middle-layer platform driver.
Signed-off-by Andrew F. Davis <[email protected]>Acked-by Pali Rohár <[email protected]>
Thanks, queued to power-supply's for-next branch.
-- Sebastian
Quoted 408 lines
drivers/power/supply/bq27xxx_battery.c | 104 ------------ drivers/power/supply/bq27xxx_battery_hdq.c | 250 ++++++++++++++++------------- include/linux/power/bq27xxx_battery.h | 17 -- 3 files changed, 135 insertions(+), 236 deletions(-)rewrite
drivers/power/supply/bq27xxx_battery_hdq.c(72%)drivers/power/supply/bq27xxx_battery.c +0
-104@@ -1938,110 +1938,6 @@ void bq27xxx_battery_teardown(struct bq27xxx_device_info *di) }EXPORT_SYMBOL_GPL (bq27xxx_battery_teardown); -static int bq27xxx_battery_platform_read (struct bq27xxx_device_info *di,u8 reg, -bool single) -{ -struct device *dev = di->dev; -struct bq27xxx_platform_data *pdata = dev->platform_data; -unsigned int timeout =3 ; -int upper, lower; -int temp; - -if (!single) { -/* Make sure the value has not changed in between reading the -* lower and the upper part */ - upper = pdata->read (dev, reg +1 ); -do { - temp = upper; -if (upper <0 ) -return upper; - - lower = pdata->read (dev, reg); -if (lower <0 ) -return lower; - - upper = pdata->read (dev, reg +1 ); - }while (temp != upper && --timeout); - -if (timeout ==0 ) -return -EIO ; - -return (upper <<8 ) | lower; - } - -return pdata->read (dev, reg); -} - -static int bq27xxx_battery_platform_probe (struct platform_device *pdev) -{ -struct bq27xxx_device_info *di; -struct bq27xxx_platform_data *pdata = pdev->dev.platform_data; - -if (!pdata) { -dev_err (&pdev->dev,"no platform_data supplied\n" ); -return -EINVAL ; - } - -if (!pdata->read) { -dev_err (&pdev->dev,"no hdq read callback supplied\n" ); -return -EINVAL ; - } - -if (!pdata->chip) { -dev_err (&pdev->dev,"no device supplied\n" ); -return -EINVAL ; - } - - di =devm_kzalloc (&pdev->dev,sizeof (*di),GFP_KERNEL ); -if (!di) -return -ENOMEM ; - -platform_set_drvdata (pdev, di); - - di->dev = &pdev->dev; - di->chip = pdata->chip; - di->name = pdata->name ?:dev_name (&pdev->dev); - di->bus.read = bq27xxx_battery_platform_read; - -return bq27xxx_battery_setup (di); -} - -static int bq27xxx_battery_platform_remove (struct platform_device *pdev) -{ -struct bq27xxx_device_info *di =platform_get_drvdata (pdev); - -bq27xxx_battery_teardown (di); - -return 0 ; -} - -static const struct platform_device_id bq27xxx_battery_platform_id_table[] = { - {"bq27000-battery" , }, - {/* sentinel */ } -}; -MODULE_DEVICE_TABLE (platform, bq27xxx_battery_platform_id_table); - -#ifdef CONFIG_OF -static const struct of_device_id bq27xxx_battery_platform_of_match_table[] = { - { .compatible ="ti,bq27000" }, - {}, -}; -MODULE_DEVICE_TABLE (of, bq27xxx_battery_platform_of_match_table); -#endif - -static struct platform_driver bq27xxx_battery_platform_driver = { - .probe = bq27xxx_battery_platform_probe, - .remove = bq27xxx_battery_platform_remove, - .driver = { - .name ="bq27000-battery" , - .of_match_table =of_match_ptr (bq27xxx_battery_platform_of_match_table), - }, - .id_table = bq27xxx_battery_platform_id_table, -}; -module_platform_driver (bq27xxx_battery_platform_driver); - -MODULE_ALIAS ("platform:bq27000-battery" ); -MODULE_AUTHOR ("Rodolfo Giometti <[email protected]>" );MODULE_DESCRIPTION ("BQ27xxx battery monitor driver" );MODULE_LICENSE ("GPL" );drivers/power/supply/bq27xxx_battery_hdq.c +135
-115@@ -1,115 +1,135 @@ -/* -* Copyright (C) 2007 Texas Instruments, Inc. -* -* This file is licensed under the terms of the GNU General Public License -* version 2. This program is licensed "as is" without any warranty of any -* kind, whether express or implied. -* -*/ - -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/device.h> -#include <linux/types.h> -#include <linux/platform_device.h> -#include <linux/mutex.h> -#include <linux/power/bq27xxx_battery.h> - -#include <linux/w1.h> - -#define W1_FAMILY_BQ27000 0x01 - -#define HDQ_CMD_READ (0) -#define HDQ_CMD_WRITE (1<<7) - -static int F_ID ; -module_param (F_ID , int,S_IRUSR ); -MODULE_PARM_DESC (F_ID ,"1-wire slave FID for BQ device" ); - -static int w1_bq27000_read (struct device *dev,unsigned int reg) -{ -u8 val; - struct w1_slave *sl = container_of(dev->parent, struct w1_slave, dev); - -mutex_lock (&sl->master->bus_mutex); -w1_write_8 (sl->master,HDQ_CMD_READ | reg); - val =w1_read_8 (sl->master); -mutex_unlock (&sl->master->bus_mutex); - -return val; -} - -static struct bq27xxx_platform_data bq27000_battery_info = { - .read = w1_bq27000_read, - .name ="bq27000-battery" , - .chip =BQ27000 , -}; - -static int w1_bq27000_add_slave (struct w1_slave *sl) -{ -int ret; -struct platform_device *pdev; - - pdev =platform_device_alloc ("bq27000-battery" ,-1 ); -if (!pdev) { - ret = -ENOMEM ; -return ret; - } - ret =platform_device_add_data (pdev, - &bq27000_battery_info, -sizeof (bq27000_battery_info)); -if (ret) - goto pdev_add_failed; - pdev->dev.parent = &sl->dev; - - ret =platform_device_add (pdev); -if (ret) - goto pdev_add_failed; - -dev_set_drvdata (&sl->dev, pdev); - - goto success; - -pdev_add_failed: -platform_device_put (pdev); -success: -return ret; -} - -static void w1_bq27000_remove_slave (struct w1_slave *sl) -{ -struct platform_device *pdev =dev_get_drvdata (&sl->dev); - -platform_device_unregister (pdev); -} - -static struct w1_family_ops w1_bq27000_fops = { - .add_slave = w1_bq27000_add_slave, - .remove_slave = w1_bq27000_remove_slave, -}; - -static struct w1_family w1_bq27000_family = { - .fid =W1_FAMILY_BQ27000 , - .fops = &w1_bq27000_fops, -}; - -static int __init w1_bq27000_init (void ) -{ -if (F_ID ) - w1_bq27000_family.fid =F_ID ; - -return w1_register_family (&w1_bq27000_family); -} - -static void __exit w1_bq27000_exit(void) -{ -w1_unregister_family (&w1_bq27000_family); -} - -module_init (w1_bq27000_init); -module_exit (w1_bq27000_exit); - -MODULE_AUTHOR ("Texas Instruments Ltd" ); -MODULE_DESCRIPTION ("HDQ/1-wire slave driver bq27000 battery monitor chip" ); -MODULE_LICENSE ("GPL" ); -MODULE_ALIAS ("w1-family-" __stringify(W1_FAMILY_BQ27000 )); +/* +* BQ27xxx battery monitor HDQ/1-wire driver +* +* Copyright (C) 2007-2017 Texas Instruments Incorporated - http://www.ti.com/ +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed "as is" WITHOUT ANY WARRANTY of any +* kind, whether express or implied; without even the implied warranty +* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/device.h> +#include <linux/types.h> +#include <linux/platform_device.h> +#include <linux/mutex.h> +#include <linux/power/bq27xxx_battery.h> + +#include <linux/w1.h> + +#define W1_FAMILY_BQ27000 0x01 + +#define HDQ_CMD_READ (0 << 7) +#define HDQ_CMD_WRITE (1 << 7) + +static int F_ID ; +module_param (F_ID , int,S_IRUSR ); +MODULE_PARM_DESC (F_ID ,"1-wire slave FID for BQ27xxx device" ); + +static int w1_bq27000_read (struct w1_slave *sl,unsigned int reg) +{ +u8 val; + +mutex_lock (&sl->master->bus_mutex); +w1_write_8 (sl->master,HDQ_CMD_READ | reg); + val =w1_read_8 (sl->master); +mutex_unlock (&sl->master->bus_mutex); + +return val; +} + +static int bq27xxx_battery_hdq_read (struct bq27xxx_device_info *di,u8 reg, +bool single) +{ +struct w1_slave *sl =dev_to_w1_slave (di->dev); +unsigned int timeout =3 ; +int upper, lower; +int temp; + +if (!single) { +/* +* Make sure the value has not changed in between reading the +* lower and the upper part +*/ + upper =w1_bq27000_read (sl, reg +1 ); +do { + temp = upper; +if (upper <0 ) +return upper; + + lower =w1_bq27000_read (sl, reg); +if (lower <0 ) +return lower; + + upper =w1_bq27000_read (sl, reg +1 ); + }while (temp != upper && --timeout); + +if (timeout ==0 ) +return -EIO ; + +return (upper <<8 ) | lower; + } + +return w1_bq27000_read (sl, reg); +} + +static int bq27xxx_battery_hdq_add_slave (struct w1_slave *sl) +{ +struct bq27xxx_device_info *di; + + di =devm_kzalloc (&sl->dev,sizeof (*di),GFP_KERNEL ); +if (!di) +return -ENOMEM ; + +dev_set_drvdata (&sl->dev, di); + + di->dev = &sl->dev; + di->chip =BQ27000 ; + di->name ="bq27000-battery" ; + di->bus.read = bq27xxx_battery_hdq_read; + +return bq27xxx_battery_setup (di); +} + +static void bq27xxx_battery_hdq_remove_slave (struct w1_slave *sl) +{ +struct bq27xxx_device_info *di =dev_get_drvdata (&sl->dev); + +bq27xxx_battery_teardown (di); +} + +static struct w1_family_ops bq27xxx_battery_hdq_fops = { + .add_slave = bq27xxx_battery_hdq_add_slave, + .remove_slave = bq27xxx_battery_hdq_remove_slave, +}; + +static struct w1_family bq27xxx_battery_hdq_family = { + .fid =W1_FAMILY_BQ27000 , + .fops = &bq27xxx_battery_hdq_fops, +}; + +static int __init bq27xxx_battery_hdq_init (void ) +{ +if (F_ID ) + bq27xxx_battery_hdq_family.fid =F_ID ; + +return w1_register_family (&bq27xxx_battery_hdq_family); +} +module_init (bq27xxx_battery_hdq_init); + +static void __exit bq27xxx_battery_hdq_exit(void) +{ +w1_unregister_family (&bq27xxx_battery_hdq_family); +} +module_exit (bq27xxx_battery_hdq_exit); + +MODULE_AUTHOR ("Texas Instruments Ltd" ); +MODULE_DESCRIPTION ("BQ27xxx battery monitor HDQ/1-wire driver" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("w1-family-" __stringify(W1_FAMILY_BQ27000 ));include/linux/power/bq27xxx_battery.h +0
-17@@ -20,23 +20,6 @@ enum bq27xxx_chip { BQ27421, /* bq27421, bq27425, bq27441, bq27621 */ }; -/** -* struct bq27xxx_plaform_data - Platform data for bq27xxx devices -* @name: Name of the battery. -* @chip: Chip class number of this device. -* @read: HDQ read callback. -* This function should provide access to the HDQ bus the battery is -* connected to. -* The first parameter is a pointer to the battery device, the second the -* register to be read. The return value should either be the content of -* the passed register or an error value. -*/ -struct bq27xxx_platform_data { -const char *name; -enum bq27xxx_chip chip; -int (*read)(struct device *dev,unsigned int ); -}; -struct bq27xxx_device_info ;struct bq27xxx_access_methods {int (*read)(struct bq27xxx_device_info *di,u8 reg,bool single);Signature · 1 line
2.13.0
Re: [PATCH v2 1/2] power: supply: move HDQ interface for bq27xxx from w1 to power/supply
In reply to Sebastian ReichelHi Greg & Evgeniy,
Here is a signed immutable branch for Andrew's patch, which moves bq27000 w1 driver to the power-supply subsystem. I guess git will figure everything out without this, but better safe than sorry :)
The following changes since commit 520eccdfe187591a51ea9ab4c1a024ae4d0f68d9:
Linux 4.13-rc2 (2017-07-23 16:15:17 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git tags/ib-w1-bq27000-4.14
for you to fetch changes up to 55a9db679183bcf85a6e5c44a4f92f158bb6f03d:
power: supply: move HDQ interface for bq27xxx from w1 to power/supply (2017-07-25 15:17:39 +0200)
----------------------------------------------------------------
immutable branch moving bq2700 driver from w1 to power-supply
----------------------------------------------------------------
Andrew F. Davis (1):
power: supply: move HDQ interface for bq27xxx from w1 to power/supply
drivers/power/supply/Kconfig | 9 +++++++++
drivers/power/supply/Makefile | 1 +
.../slaves/w1_bq27000.c => power/supply/bq27xxx_battery_hdq.c} | 2 --
drivers/w1/slaves/Kconfig | 6 ------
drivers/w1/slaves/Makefile | 1 -
5 files changed, 10 insertions(+), 9 deletions(-)
rename drivers/{w1/slaves/w1_bq27000.c => power/supply/bq27xxx_battery_hdq.c} (98%)-- Sebastian
Quoted 99 lines · Sebastian Reichel
Hi,
Quoted 7 lines · Andrew F. Davis
The HDQ interface driver should be in this folder just like the I2C interface driver. Move this driver out of
drivers/w1/slaveand intodrivers/power/supply.Signed-off-by Andrew F. Davis <[email protected]>Acked-by Pali Rohár <[email protected]>Thanks, queued to power-supply's for-next branch. I prepared a immutable branch/tag for the w1 tree and will send a pull request for that in a minute.
-- Sebastian
Quoted 82 lines
drivers/power/supply/Kconfig | 9 +++++++++ drivers/power/supply/Makefile | 1 + .../slaves/w1_bq27000.c => power/supply/bq27xxx_battery_hdq.c} | 2 -- drivers/w1/slaves/Kconfig | 6 ------ drivers/w1/slaves/Makefile | 1 - 5 files changed, 10 insertions(+), 9 deletions(-) rename drivers/{w1/slaves/w1_bq27000.c => power/supply/bq27xxx_battery_hdq.c} (98%)drivers/power/supply/Kconfig +9
-0@@ -198,6 +198,15 @@ config BATTERY_BQ27XXX_I2C Say Y here to enable support for batteries with BQ27xxx chips connected over an I2C bus. +config BATTERY_BQ27XXX_HDQ + tristate "BQ27xxx HDQ support" + depends on BATTERY_BQ27XXX + depends on W1 + default y + help + Say Y here to enable support for batteries with BQ27xxx chips + connected over an HDQ bus. + config BATTERY_BQ27XXX_DT_UPDATES_NVM bool "BQ27xxx support for update of NVM/flash data memory" depends on BATTERY_BQ27XXX_I2Cdrivers/power/supply/Makefile +1
-0@@ -38,6 +38,7 @@ obj-$(CONFIG_BATTERY_SBS) += sbs-battery.o obj-$(CONFIG_CHARGER_SBS) += sbs-charger.o obj-$(CONFIG_BATTERY_BQ27XXX) += bq27xxx_battery.o obj-$(CONFIG_BATTERY_BQ27XXX_I2C) += bq27xxx_battery_i2c.o +obj-$(CONFIG_BATTERY_BQ27XXX_HDQ) += bq27xxx_battery_hdq.o obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o obj-$(CONFIG_BATTERY_DA9052) += da9052-battery.o obj-$(CONFIG_CHARGER_DA9150) += da9150-charger.odrivers/power/supply/bq27xxx_battery_hdq.c renamed from drivers/w1/slaves/w1_bq27000.c +0
-2@@ -1,6 +1,4 @@/* -* drivers/w1/slaves/w1_bq27000.c -* * Copyright (C) 2007 Texas Instruments, Inc. * * This file is licensed under the terms of the GNU General Public License drivers/w1/slaves/Kconfig +0
-6@@ -140,10 +140,4 @@ config W1_SLAVE_DS28E04 If you are unsure, say N. -config W1_SLAVE_BQ27000 - tristate "BQ27000 slave support" - help - Say Y here if you want to use a hdq - bq27000 slave support. - endmenudrivers/w1/slaves/Makefile +0
-1@@ -15,5 +15,4 @@ obj-$(CONFIG_W1_SLAVE_DS2438) += w1_ds2438.o obj-$(CONFIG_W1_SLAVE_DS2760) += w1_ds2760.o obj-$(CONFIG_W1_SLAVE_DS2780) += w1_ds2780.o obj-$(CONFIG_W1_SLAVE_DS2781) += w1_ds2781.o -obj-$(CONFIG_W1_SLAVE_BQ27000) += w1_bq27000.o obj-$(CONFIG_W1_SLAVE_DS28E04) += w1_ds28e04.oSignature · 1 line
2.13.0
Re: [PATCH v2 1/2] power: supply: move HDQ interface for bq27xxx from w1 to power/supply
Hi everyone
Sorry for long delay
25.07.2017, 16:48, "Sebastian Reichel" <[email protected]>:
Quoted 8 lines
Here is a signed immutable branch for Andrew's patch, which moves bq27000 w1 driver to the power-supply subsystem. I guess git will figure everything out without this, but better safe than sorry :)
The following changes since commit
520eccdfe187591a51ea9ab4c1a024ae4d0f68d9:Linux 4.13-rc2 (2017-07-23 16:15:17 -0700)
Quoted 7 lines
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git tags/ib-w1-bq27000-4.14
for you to fetch changes up to
55a9db679183bcf85a6e5c44a4f92f158bb6f03d:power: supply: move HDQ interface for bq27xxx from w1 to power/supply (2017-07-25 15:17:39 +0200)
Greg, should it be pulled into your tree or submitted as a separate pull request or as set of patches? Either way looks good to me, please get it into your tree.