Skip to contentSkip to conversation

regulator: ad5398: show changing current in uA

PATCH Applied Axel Lin 3 participants 5 messages Mar 27, 2012 – Mar 28, 2012

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/2 regulator: ad5398: show changing current in uA

Integer division may truncate the result.
Current code shows changing current is 0mA when selector is 1 ... 8.

For example:
selector = 1
ad5398_calc_current returns 117, debug message shows 117/1000 = 0mA selector = 2
ad5398_calc_current returns 234, debug message shows 234/1000 = 0mA selector = 3
ad5398_calc_current returns 351, debug message shows 351/1000 = 0mA
............
selector = 8
ad5398_calc_current returns 937, debug message shows 937/1000 = 0mA

Show the changing current in uA makes it easier for debugging.

---
 drivers/regulator/ad5398.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/ad5398.c +2 -2
index 26d23ad..ed58798 100644
@@ -99,8 +99,8 @@ static int ad5398_set_current_limit(struct regulator_dev *rdev, int min_uA, int
 	if (ad5398_calc_current(chip, selector) > max_uA)
 		return -EINVAL;
 
-	dev_dbg(&client->dev, "changing current %dmA\n",
-		ad5398_calc_current(chip, selector) / 1000);
+	dev_dbg(&client->dev, "changing current %duA\n",
+		ad5398_calc_current(chip, selector));
 
 	/* read chip enable bit */
 	ret = ad5398_read_reg(client, &data);
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH 2/2 regulator: ad5398: Use devm_kzalloc

---
 drivers/regulator/ad5398.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
drivers/regulator/ad5398.c +1 -4
index ed58798..7d51793 100644
@@ -220,7 +220,7 @@ static int __devinit ad5398_probe(struct i2c_client *client,
 	if (!init_data)
 		return -EINVAL;
 
-	chip = kzalloc(sizeof(*chip), GFP_KERNEL);
+	chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
 	if (!chip)
 		return -ENOMEM;
 
@@ -246,7 +246,6 @@ static int __devinit ad5398_probe(struct i2c_client *client,
 	return 0;
 
 err:
-	kfree(chip);
 	return ret;
 }
 
@@ -255,8 +254,6 @@ static int __devexit ad5398_remove(struct i2c_client *client)
 	struct ad5398_chip_info *chip = i2c_get_clientdata(client);
 
 	regulator_unregister(chip->rdev);
-	kfree(chip);
-
 	return 0;
 }
 
Signature · 1 line
1.7.5.4
Acked-by on v1 2/2
#2 lore raw

RE: [PATCH 2/2] regulator: ad5398: Use devm_kzalloc

-----Original Message-----
From: Axel Lin [mailto:[email protected]]
Sent: Tuesday, March 27, 2012 10:10 AM
To: [email protected]
Cc: Zhang, Sonic; Liam Girdwood; Mark Brown
Subject: [PATCH 2/2] regulator: ad5398: Use devm_kzalloc

---
 drivers/regulator/ad5398.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
drivers/regulator/ad5398.c +1 -4
index ed58798..7d51793 100644
@@ -220,7 +220,7 @@ static int __devinit ad5398_probe(struct i2c_client *client,
        if (!init_data)
                return -EINVAL;
 
-       chip = kzalloc(sizeof(*chip), GFP_KERNEL);
+       chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
        if (!chip)
                return -ENOMEM;
 
@@ -246,7 +246,6 @@ static int __devinit ad5398_probe(struct i2c_client *client,
        return 0;
 
 err:
-       kfree(chip);
        return ret;
 }
 
@@ -255,8 +254,6 @@ static int __devexit ad5398_remove(struct i2c_client *client)
        struct ad5398_chip_info *chip = i2c_get_clientdata(client);
 
        regulator_unregister(chip->rdev);
-       kfree(chip);
-
        return 0;
 }
 

--
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

-----Original Message-----
From: Axel Lin [mailto:[email protected]]
Sent: Tuesday, March 27, 2012 10:08 AM
To: [email protected]
Cc: Zhang, Sonic; Liam Girdwood; Mark Brown
Subject: [PATCH 1/2] regulator: ad5398: show changing current in uA

Integer division may truncate the result.
Current code shows changing current is 0mA when selector is 1 ... 8.

For example:
selector = 1
ad5398_calc_current returns 117, debug message shows 117/1000 = 0mA selector = 2
ad5398_calc_current returns 234, debug message shows 234/1000 = 0mA selector = 3
ad5398_calc_current returns 351, debug message shows 351/1000 = 0mA
............
selector = 8
ad5398_calc_current returns 937, debug message shows 937/1000 = 0mA

Show the changing current in uA makes it easier for debugging.

---
 drivers/regulator/ad5398.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/ad5398.c +2 -2
index 26d23ad..ed58798 100644
@@ -99,8 +99,8 @@ static int ad5398_set_current_limit(struct regulator_dev *rdev, int min_uA, int
        if (ad5398_calc_current(chip, selector) > max_uA)
                return -EINVAL;
 
-       dev_dbg(&client->dev, "changing current %dmA\n",
-               ad5398_calc_current(chip, selector) / 1000);
+       dev_dbg(&client->dev, "changing current %duA\n",
+               ad5398_calc_current(chip, selector));
 
        /* read chip enable bit */
        ret = ad5398_read_reg(client, &data);

--
1.7.5.4

���{.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 2 lines · Axel Lin

Integer division may truncate the result.
Current code shows changing current is 0mA when selector is 1 ... 8.

Applied both, thanks.