Skip to contentSkip to conversation

regulator: tps65090: Use IS_ERR to check return value of regulator_register

PATCH Applied Axel Lin 3 participants 5 messages Mar 24, 2012 – Mar 26, 2012 Voltage and current regulator framework

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/2 regulator: tps65090: Use IS_ERR to check return value of regulator_register

regulator_register never returns NULL.

---
 drivers/regulator/tps65090-regulator.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/regulator/tps65090-regulator.c +1 -1
index 6c28e3a..470ca7e 100644
@@ -153,7 +153,7 @@ static int __devinit tps65090_regulator_probe(struct platform_device *pdev)
 
 	rdev = regulator_register(&ri->desc, &pdev->dev,
 				&tps_pdata->regulator, ri, NULL);
-	if (IS_ERR_OR_NULL(rdev)) {
+	if (IS_ERR(rdev)) {
 		dev_err(&pdev->dev, "failed to register regulator %s\n",
 				ri->desc.name);
 		return PTR_ERR(rdev);
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH 2/2 regulator: Remove _en_reg, _en_bit and _ops parameters from tps65090_REG macro

Both _en_bit and _ops parameters for all DCDCs and FETs are the same, so we can hardcode it in tps65090_REG macro.

_en_reg can be calculated by _id + 12, so we can also remove it.

---
 drivers/regulator/tps65090-regulator.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)
drivers/regulator/tps65090-regulator.c +14 -14
index 470ca7e..7baff2e 100644
@@ -94,31 +94,31 @@ static struct regulator_ops tps65090_ops = {
 	.is_enabled	= tps65090_reg_is_enabled,
 };
 
-#define tps65090_REG(_id, _en_reg, _en_bit, _ops)	\
+#define tps65090_REG(_id)				\
 {							\
-	.reg_en_reg	= _en_reg,			\
-	.en_bit		= _en_bit,			\
+	.reg_en_reg	= (TPS65090_ID_##_id) + 12,	\
+	.en_bit		= 0,				\
 	.id		= TPS65090_ID_##_id,		\
 	.desc = {					\
 		.name = tps65090_rails(_id),		\
 		.id = TPS65090_ID_##_id,		\
-		.ops = &_ops,				\
+		.ops = &tps65090_ops,			\
 		.type = REGULATOR_VOLTAGE,		\
 		.owner = THIS_MODULE,			\
 	},						\
 }
 
 static struct tps65090_regulator TPS65090_regulator[] = {
-	tps65090_REG(DCDC1, 12, 0, tps65090_ops),
-	tps65090_REG(DCDC2, 13, 0, tps65090_ops),
-	tps65090_REG(DCDC3, 14, 0, tps65090_ops),
-	tps65090_REG(FET1,  15, 0, tps65090_ops),
-	tps65090_REG(FET2,  16, 0, tps65090_ops),
-	tps65090_REG(FET3,  17, 0, tps65090_ops),
-	tps65090_REG(FET4,  18, 0, tps65090_ops),
-	tps65090_REG(FET5,  19, 0, tps65090_ops),
-	tps65090_REG(FET6,  20, 0, tps65090_ops),
-	tps65090_REG(FET7,  21, 0, tps65090_ops),
+	tps65090_REG(DCDC1),
+	tps65090_REG(DCDC2),
+	tps65090_REG(DCDC3),
+	tps65090_REG(FET1),
+	tps65090_REG(FET2),
+	tps65090_REG(FET3),
+	tps65090_REG(FET4),
+	tps65090_REG(FET5),
+	tps65090_REG(FET6),
+	tps65090_REG(FET7),
 };
 
 static inline struct tps65090_regulator *find_regulator_info(int id)
Signature · 1 line
1.7.5.4
#2 lore raw

RE: [PATCH 2/2] regulator: Remove _en_reg, _en_bit and _ops parameters from tps65090_REG macro

Quoted 4 lines

Both _en_bit and _ops parameters for all DCDCs and FETs are the same, so we can hardcode it in tps65090_REG macro.

_en_reg can be calculated by _id + 12, so we can also remove it.

Looks good to me.
Acked by: Venu Byravarasu <[email protected]>

Quoted 57 lines
---
 drivers/regulator/tps65090-regulator.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)
drivers/regulator/tps65090-regulator.c +14 -15
index 470ca7e..7baff2e 100644
@@ -94,31 +94,31 @@ static struct regulator_ops tps65090_ops = {
 	.is_enabled	= tps65090_reg_is_enabled,
 };
 
-#define tps65090_REG(_id, _en_reg, _en_bit, _ops)	\
+#define tps65090_REG(_id)				\
 {							\
-	.reg_en_reg	= _en_reg,			\
-	.en_bit		= _en_bit,			\
+	.reg_en_reg	= (TPS65090_ID_##_id) + 12,	\
+	.en_bit		= 0,				\
 	.id		= TPS65090_ID_##_id,		\
 	.desc = {					\
 		.name = tps65090_rails(_id),		\
 		.id = TPS65090_ID_##_id,		\
-		.ops = &_ops,				\
+		.ops = &tps65090_ops,			\
 		.type = REGULATOR_VOLTAGE,		\
 		.owner = THIS_MODULE,			\
 	},						\
 }
 
 static struct tps65090_regulator TPS65090_regulator[] = {
-	tps65090_REG(DCDC1, 12, 0, tps65090_ops),
-	tps65090_REG(DCDC2, 13, 0, tps65090_ops),
-	tps65090_REG(DCDC3, 14, 0, tps65090_ops),
-	tps65090_REG(FET1,  15, 0, tps65090_ops),
-	tps65090_REG(FET2,  16, 0, tps65090_ops),
-	tps65090_REG(FET3,  17, 0, tps65090_ops),
-	tps65090_REG(FET4,  18, 0, tps65090_ops),
-	tps65090_REG(FET5,  19, 0, tps65090_ops),
-	tps65090_REG(FET6,  20, 0, tps65090_ops),
-	tps65090_REG(FET7,  21, 0, tps65090_ops),
+	tps65090_REG(DCDC1),
+	tps65090_REG(DCDC2),
+	tps65090_REG(DCDC3),
+	tps65090_REG(FET1),
+	tps65090_REG(FET2),
+	tps65090_REG(FET3),
+	tps65090_REG(FET4),
+	tps65090_REG(FET5),
+	tps65090_REG(FET6),
+	tps65090_REG(FET7),
 };
 
 static inline struct tps65090_regulator *find_regulator_info(int id)
--
Quoted 3 lines

1.7.5.4

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

Acked-by on v1 1/2
#3 lore raw
In reply to Axel Lin

drivers/regulator/tps65090-regulator.c static int __devinit tps65090_regulator_probe(struct platform_device *pdev) · line 156

Quoted 4 lines
drivers/regulator/tps65090-regulator.c +1 -1
 	rdev = regulator_register(&ri->desc, &pdev->dev,
 				&tps_pdata->regulator, ri, NULL);
-	if (IS_ERR_OR_NULL(rdev)) {
+	if (IS_ERR(rdev)) {

Thanks Axel, for this patch.
Just today I saw Mark's mail and about to make this change.

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

Applied
#4 lore raw
In reply to Axel Lin
Quoted 1 line · Axel Lin

regulator_register never returns NULL.

Applied both, thanks. In theory it may return NULL but that's not an error code.