Skip to contentSkip to conversation

regulator: lp872x: Remove _rdev_to_offset() function

PATCH In review Axel Lin 3 participants 4 messages Jan 18, 2013 1 message not in the archive Voltage and current regulator framework

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 regulator: lp872x: Remove _rdev_to_offset() function

There is only one caller calling _rdev_to_offset(), and the code looks simper if we remove _rdev_to_offset(). Thus remove it.

---
 drivers/regulator/lp872x.c |   32 +++++---------------------------
 1 file changed, 5 insertions(+), 27 deletions(-)
drivers/regulator/lp872x.c +5 -27
index 9289ead..41bdbbe 100644
@@ -181,20 +181,6 @@ static inline int lp872x_update_bits(struct lp872x *lp, u8 addr,
 	return regmap_update_bits(lp->regmap, addr, mask, data);
 }
 
-static int _rdev_to_offset(struct regulator_dev *rdev)
-{
-	enum lp872x_regulator_id id = rdev_get_id(rdev);
-
-	switch (id) {
-	case LP8720_ID_LDO1 ... LP8720_ID_BUCK:
-		return id;
-	case LP8725_ID_LDO1 ... LP8725_ID_BUCK2:
-		return id - LP8725_ID_BASE;
-	default:
-		return -EINVAL;
-	}
-}
-
 static int lp872x_get_timestep_usec(struct lp872x *lp)
 {
 	enum lp872x_id chip = lp->chipid;
@@ -236,26 +222,18 @@ static int lp872x_regulator_enable_time(struct regulator_dev *rdev)
 	struct lp872x *lp = rdev_get_drvdata(rdev);
 	enum lp872x_regulator_id regulator = rdev_get_id(rdev);
 	int time_step_us = lp872x_get_timestep_usec(lp);
-	int ret, offset;
+	int ret;
 	u8 addr, val;
 
 	if (time_step_us < 0)
 		return -EINVAL;
 
 	switch (regulator) {
-	case LP8720_ID_LDO1 ... LP8720_ID_LDO5:
-	case LP8725_ID_LDO1 ... LP8725_ID_LILO2:
-		offset = _rdev_to_offset(rdev);
-		if (offset < 0)
-			return -EINVAL;
-
-		addr = LP872X_LDO1_VOUT + offset;
-		break;
-	case LP8720_ID_BUCK:
-		addr = LP8720_BUCK_VOUT1;
+	case LP8720_ID_LDO1 ... LP8720_ID_BUCK:
+		addr = LP872X_LDO1_VOUT + regulator;
 		break;
-	case LP8725_ID_BUCK1:
-		addr = LP8725_BUCK1_VOUT1;
+	case LP8725_ID_LDO1 ... LP8725_ID_BUCK1:
+		addr = LP872X_LDO1_VOUT + regulator - LP8725_ID_BASE;
 		break;
 	case LP8725_ID_BUCK2:
 		addr = LP8725_BUCK2_VOUT1;
Signature · 1 line
1.7.9.5
Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines

There is only one caller calling _rdev_to_offset(), and the code looks simper if we remove _rdev_to_offset(). Thus remove it.

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

#2 lore raw
In reply to Axel Lin
Quoted 2 lines · Axel Lin

There is only one caller calling _rdev_to_offset(), and the code looks simper if we remove _rdev_to_offset(). Thus remove it.

This doesn't seem to apply to topic/lp872x?

#4 lore raw
In reply to a message not in the archive
Quoted 9 lines · Axel Lin

2013/1/18 Mark Brown <[email protected]>

Quoted 5 lines · Axel Lin
Quoted 2 lines

There is only one caller calling _rdev_to_offset(), and the code looks simper if we remove _rdev_to_offset(). Thus remove it.

This doesn't seem to apply to topic/lp872x?

I cannot find topic/lp872x branch on your tree.
I generate the patch against linux-next.

I'd forgotten to push it out, done now - actually looks to be pretty much the same code.