* [PATCH RFT] regulator: tps65090: Use generic regmap enable/disable operations
@ 2012-04-17 9:08 Axel Lin
2012-04-18 5:07 ` Venu Byravarasu
2012-04-18 16:42 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2012-04-17 9:08 UTC (permalink / raw)
To: linux-kernel; +Cc: Venu Byravarasu, Liam Girdwood, Mark Brown, Samuel Ortiz
This patch converts tps65090 regulator driver to use generic regmap
enable/disable operations.
Also move struct tps65090 to include/linux/mfd/tps65090.h because
the regulator driver needs to access the rmap field of struct tps65090.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/mfd/tps65090.c | 11 -----
drivers/regulator/tps65090-regulator.c | 64 +++----------------------------
include/linux/mfd/tps65090.h | 13 ++++++
3 files changed, 20 insertions(+), 68 deletions(-)
diff --git a/drivers/mfd/tps65090.c b/drivers/mfd/tps65090.c
index a66d4df..47f802b 100644
--- a/drivers/mfd/tps65090.c
+++ b/drivers/mfd/tps65090.c
@@ -78,17 +78,6 @@ static struct mfd_cell tps65090s[] = {
},
};
-struct tps65090 {
- struct mutex lock;
- struct device *dev;
- struct i2c_client *client;
- struct regmap *rmap;
- struct irq_chip irq_chip;
- struct mutex irq_lock;
- int irq_base;
- unsigned int id;
-};
-
int tps65090_write(struct device *dev, int reg, uint8_t val)
{
struct tps65090 *tps = dev_get_drvdata(dev);
diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c
index 6bbf760..299237d 100644
--- a/drivers/regulator/tps65090-regulator.c
+++ b/drivers/regulator/tps65090-regulator.c
@@ -29,10 +29,6 @@
struct tps65090_regulator {
int id;
- /* Regulator register address.*/
- u8 reg_en_reg;
- u8 en_bit;
-
/* used by regulator core */
struct regulator_desc desc;
@@ -40,64 +36,14 @@ struct tps65090_regulator {
struct device *dev;
};
-static inline struct device *to_tps65090_dev(struct regulator_dev *rdev)
-{
- return rdev_get_dev(rdev)->parent->parent;
-}
-
-static int tps65090_reg_is_enabled(struct regulator_dev *rdev)
-{
- struct tps65090_regulator *ri = rdev_get_drvdata(rdev);
- struct device *parent = to_tps65090_dev(rdev);
- uint8_t control;
- int ret;
-
- ret = tps65090_read(parent, ri->reg_en_reg, &control);
- if (ret < 0) {
- dev_err(&rdev->dev, "Error in reading reg 0x%x\n",
- ri->reg_en_reg);
- return ret;
- }
- return (((control >> ri->en_bit) & 1) == 1);
-}
-
-static int tps65090_reg_enable(struct regulator_dev *rdev)
-{
- struct tps65090_regulator *ri = rdev_get_drvdata(rdev);
- struct device *parent = to_tps65090_dev(rdev);
- int ret;
-
- ret = tps65090_set_bits(parent, ri->reg_en_reg, ri->en_bit);
- if (ret < 0)
- dev_err(&rdev->dev, "Error in updating reg 0x%x\n",
- ri->reg_en_reg);
- return ret;
-}
-
-static int tps65090_reg_disable(struct regulator_dev *rdev)
-{
- struct tps65090_regulator *ri = rdev_get_drvdata(rdev);
- struct device *parent = to_tps65090_dev(rdev);
- int ret;
-
- ret = tps65090_clr_bits(parent, ri->reg_en_reg, ri->en_bit);
- if (ret < 0)
- dev_err(&rdev->dev, "Error in updating reg 0x%x\n",
- ri->reg_en_reg);
-
- return ret;
-}
-
static struct regulator_ops tps65090_ops = {
- .enable = tps65090_reg_enable,
- .disable = tps65090_reg_disable,
- .is_enabled = tps65090_reg_is_enabled,
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
};
#define tps65090_REG(_id) \
{ \
- .reg_en_reg = (TPS65090_ID_##_id) + 12, \
- .en_bit = 0, \
.id = TPS65090_ID_##_id, \
.desc = { \
.name = tps65090_rails(_id), \
@@ -105,6 +51,8 @@ static struct regulator_ops tps65090_ops = {
.ops = &tps65090_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
+ .enable_reg = (TPS65090_ID_##_id) + 12, \
+ .enable_mask = BIT(0), \
}, \
}
@@ -136,6 +84,7 @@ static inline struct tps65090_regulator *find_regulator_info(int id)
static int __devinit tps65090_regulator_probe(struct platform_device *pdev)
{
+ struct tps65090 *tps65090_mfd = dev_get_drvdata(pdev->dev.parent);
struct tps65090_regulator *ri = NULL;
struct regulator_config config = { };
struct regulator_dev *rdev;
@@ -155,6 +104,7 @@ static int __devinit tps65090_regulator_probe(struct platform_device *pdev)
config.dev = &pdev->dev;
config.init_data = &tps_pdata->regulator;
config.driver_data = ri;
+ config.regmap = tps65090_mfd->rmap;
rdev = regulator_register(&ri->desc, &config);
if (IS_ERR(rdev)) {
diff --git a/include/linux/mfd/tps65090.h b/include/linux/mfd/tps65090.h
index 38e31c5..6bc31d8 100644
--- a/include/linux/mfd/tps65090.h
+++ b/include/linux/mfd/tps65090.h
@@ -22,6 +22,19 @@
#ifndef __LINUX_MFD_TPS65090_H
#define __LINUX_MFD_TPS65090_H
+#include <linux/irq.h>
+
+struct tps65090 {
+ struct mutex lock;
+ struct device *dev;
+ struct i2c_client *client;
+ struct regmap *rmap;
+ struct irq_chip irq_chip;
+ struct mutex irq_lock;
+ int irq_base;
+ unsigned int id;
+};
+
struct tps65090_subdev_info {
int id;
const char *name;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH RFT] regulator: tps65090: Use generic regmap enable/disable operations
2012-04-17 9:08 [PATCH RFT] regulator: tps65090: Use generic regmap enable/disable operations Axel Lin
@ 2012-04-18 5:07 ` Venu Byravarasu
2012-04-18 16:42 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Venu Byravarasu @ 2012-04-18 5:07 UTC (permalink / raw)
To: Axel Lin, linux-kernel@vger.kernel.org
Cc: Liam Girdwood, Mark Brown, Samuel Ortiz
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 5650 bytes --]
Looks good to me.
Acked by: Venu Byravarasu <vbyravarasu@nvidia.com>
> -----Original Message-----
> From: Axel Lin [mailto:axel.lin@gmail.com]
> Sent: Tuesday, April 17, 2012 2:39 PM
> To: linux-kernel@vger.kernel.org
> Cc: Venu Byravarasu; Liam Girdwood; Mark Brown; Samuel Ortiz
> Subject: [PATCH RFT] regulator: tps65090: Use generic regmap enable/disable
> operations
>
> This patch converts tps65090 regulator driver to use generic regmap
> enable/disable operations.
>
> Also move struct tps65090 to include/linux/mfd/tps65090.h because
> the regulator driver needs to access the rmap field of struct tps65090.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
> drivers/mfd/tps65090.c | 11 -----
> drivers/regulator/tps65090-regulator.c | 64 +++----------------------------
> include/linux/mfd/tps65090.h | 13 ++++++
> 3 files changed, 20 insertions(+), 68 deletions(-)
>
> diff --git a/drivers/mfd/tps65090.c b/drivers/mfd/tps65090.c
> index a66d4df..47f802b 100644
> --- a/drivers/mfd/tps65090.c
> +++ b/drivers/mfd/tps65090.c
> @@ -78,17 +78,6 @@ static struct mfd_cell tps65090s[] = {
> },
> };
>
> -struct tps65090 {
> - struct mutex lock;
> - struct device *dev;
> - struct i2c_client *client;
> - struct regmap *rmap;
> - struct irq_chip irq_chip;
> - struct mutex irq_lock;
> - int irq_base;
> - unsigned int id;
> -};
> -
> int tps65090_write(struct device *dev, int reg, uint8_t val)
> {
> struct tps65090 *tps = dev_get_drvdata(dev);
> diff --git a/drivers/regulator/tps65090-regulator.c
> b/drivers/regulator/tps65090-regulator.c
> index 6bbf760..299237d 100644
> --- a/drivers/regulator/tps65090-regulator.c
> +++ b/drivers/regulator/tps65090-regulator.c
> @@ -29,10 +29,6 @@
>
> struct tps65090_regulator {
> int id;
> - /* Regulator register address.*/
> - u8 reg_en_reg;
> - u8 en_bit;
> -
> /* used by regulator core */
> struct regulator_desc desc;
>
> @@ -40,64 +36,14 @@ struct tps65090_regulator {
> struct device *dev;
> };
>
> -static inline struct device *to_tps65090_dev(struct regulator_dev *rdev)
> -{
> - return rdev_get_dev(rdev)->parent->parent;
> -}
> -
> -static int tps65090_reg_is_enabled(struct regulator_dev *rdev)
> -{
> - struct tps65090_regulator *ri = rdev_get_drvdata(rdev);
> - struct device *parent = to_tps65090_dev(rdev);
> - uint8_t control;
> - int ret;
> -
> - ret = tps65090_read(parent, ri->reg_en_reg, &control);
> - if (ret < 0) {
> - dev_err(&rdev->dev, "Error in reading reg 0x%x\n",
> - ri->reg_en_reg);
> - return ret;
> - }
> - return (((control >> ri->en_bit) & 1) == 1);
> -}
> -
> -static int tps65090_reg_enable(struct regulator_dev *rdev)
> -{
> - struct tps65090_regulator *ri = rdev_get_drvdata(rdev);
> - struct device *parent = to_tps65090_dev(rdev);
> - int ret;
> -
> - ret = tps65090_set_bits(parent, ri->reg_en_reg, ri->en_bit);
> - if (ret < 0)
> - dev_err(&rdev->dev, "Error in updating reg 0x%x\n",
> - ri->reg_en_reg);
> - return ret;
> -}
> -
> -static int tps65090_reg_disable(struct regulator_dev *rdev)
> -{
> - struct tps65090_regulator *ri = rdev_get_drvdata(rdev);
> - struct device *parent = to_tps65090_dev(rdev);
> - int ret;
> -
> - ret = tps65090_clr_bits(parent, ri->reg_en_reg, ri->en_bit);
> - if (ret < 0)
> - dev_err(&rdev->dev, "Error in updating reg 0x%x\n",
> - ri->reg_en_reg);
> -
> - return ret;
> -}
> -
> static struct regulator_ops tps65090_ops = {
> - .enable = tps65090_reg_enable,
> - .disable = tps65090_reg_disable,
> - .is_enabled = tps65090_reg_is_enabled,
> + .enable = regulator_enable_regmap,
> + .disable = regulator_disable_regmap,
> + .is_enabled = regulator_is_enabled_regmap,
> };
>
> #define tps65090_REG(_id) \
> { \
> - .reg_en_reg = (TPS65090_ID_##_id) + 12, \
> - .en_bit = 0, \
> .id = TPS65090_ID_##_id, \
> .desc = { \
> .name = tps65090_rails(_id), \
> @@ -105,6 +51,8 @@ static struct regulator_ops tps65090_ops = {
> .ops = &tps65090_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> + .enable_reg = (TPS65090_ID_##_id) + 12, \
> + .enable_mask = BIT(0), \
> }, \
> }
>
> @@ -136,6 +84,7 @@ static inline struct tps65090_regulator
> *find_regulator_info(int id)
>
> static int __devinit tps65090_regulator_probe(struct platform_device *pdev)
> {
> + struct tps65090 *tps65090_mfd = dev_get_drvdata(pdev-
> >dev.parent);
> struct tps65090_regulator *ri = NULL;
> struct regulator_config config = { };
> struct regulator_dev *rdev;
> @@ -155,6 +104,7 @@ static int __devinit tps65090_regulator_probe(struct
> platform_device *pdev)
> config.dev = &pdev->dev;
> config.init_data = &tps_pdata->regulator;
> config.driver_data = ri;
> + config.regmap = tps65090_mfd->rmap;
>
> rdev = regulator_register(&ri->desc, &config);
> if (IS_ERR(rdev)) {
> diff --git a/include/linux/mfd/tps65090.h b/include/linux/mfd/tps65090.h
> index 38e31c5..6bc31d8 100644
> --- a/include/linux/mfd/tps65090.h
> +++ b/include/linux/mfd/tps65090.h
> @@ -22,6 +22,19 @@
> #ifndef __LINUX_MFD_TPS65090_H
> #define __LINUX_MFD_TPS65090_H
>
> +#include <linux/irq.h>
> +
> +struct tps65090 {
> + struct mutex lock;
> + struct device *dev;
> + struct i2c_client *client;
> + struct regmap *rmap;
> + struct irq_chip irq_chip;
> + struct mutex irq_lock;
> + int irq_base;
> + unsigned int id;
> +};
> +
> struct tps65090_subdev_info {
> int id;
> const char *name;
> --
> 1.7.5.4
>
>
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFT] regulator: tps65090: Use generic regmap enable/disable operations
2012-04-17 9:08 [PATCH RFT] regulator: tps65090: Use generic regmap enable/disable operations Axel Lin
2012-04-18 5:07 ` Venu Byravarasu
@ 2012-04-18 16:42 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2012-04-18 16:42 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Venu Byravarasu, Liam Girdwood, Samuel Ortiz
[-- Attachment #1: Type: text/plain, Size: 175 bytes --]
On Tue, Apr 17, 2012 at 05:08:56PM +0800, Axel Lin wrote:
> This patch converts tps65090 regulator driver to use generic regmap
> enable/disable operations.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-04-18 16:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-17 9:08 [PATCH RFT] regulator: tps65090: Use generic regmap enable/disable operations Axel Lin
2012-04-18 5:07 ` Venu Byravarasu
2012-04-18 16:42 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox