* [PATCH 1/2] regulator: da9063: Optimize da9063_set_current_limit implementation
@ 2013-08-30 12:07 Axel Lin
2013-08-30 12:08 ` [PATCH 2/2] regulator: da9063: Use IS_ERR to check return value of regulator_register() Axel Lin
2013-08-30 14:24 ` [PATCH 1/2] regulator: da9063: Optimize da9063_set_current_limit implementation Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2013-08-30 12:07 UTC (permalink / raw)
To: Mark Brown; +Cc: Krystian Garbaciak, Philipp Zabel, Liam Girdwood, linux-kernel
All the current limit tables have the values in ascend order.
So we can slightly optimize the for loop iteration because the first match
is the minimal value.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/regulator/da9063-regulator.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
index fc2871cb..f29e729 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -166,22 +166,15 @@ static int da9063_set_current_limit(struct regulator_dev *rdev,
{
struct da9063_regulator *regl = rdev_get_drvdata(rdev);
const struct da9063_regulator_info *rinfo = regl->info;
- int val = INT_MAX;
- unsigned sel = 0;
- int n;
- int tval;
+ int n, tval;
for (n = 0; n < rinfo->n_current_limits; n++) {
tval = rinfo->current_limits[n];
- if (tval >= min_uA && tval <= max_uA && val > tval) {
- val = tval;
- sel = n;
- }
+ if (tval >= min_uA && tval <= max_uA)
+ return regmap_field_write(regl->ilimit, n);
}
- if (val == INT_MAX)
- return -EINVAL;
- return regmap_field_write(regl->ilimit, sel);
+ return -EINVAL;
}
static int da9063_get_current_limit(struct regulator_dev *rdev)
--
1.8.1.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] regulator: da9063: Use IS_ERR to check return value of regulator_register()
2013-08-30 12:07 [PATCH 1/2] regulator: da9063: Optimize da9063_set_current_limit implementation Axel Lin
@ 2013-08-30 12:08 ` Axel Lin
2013-08-30 14:24 ` [PATCH 1/2] regulator: da9063: Optimize da9063_set_current_limit implementation Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Axel Lin @ 2013-08-30 12:08 UTC (permalink / raw)
To: Mark Brown; +Cc: Krystian Garbaciak, Philipp Zabel, Liam Girdwood, linux-kernel
regulator_register() does not return NULL, it returns ERR_PTR on error.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/regulator/da9063-regulator.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
index f29e729..139ad45 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -848,7 +848,7 @@ static int da9063_regulator_probe(struct platform_device *pdev)
config.of_node = da9063_reg_matches[id].of_node;
config.regmap = da9063->regmap;
regl->rdev = regulator_register(®l->desc, &config);
- if (IS_ERR_OR_NULL(regl->rdev)) {
+ if (IS_ERR(regl->rdev)) {
dev_err(&pdev->dev,
"Failed to register %s regulator\n",
regl->desc.name);
--
1.8.1.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] regulator: da9063: Optimize da9063_set_current_limit implementation
2013-08-30 12:07 [PATCH 1/2] regulator: da9063: Optimize da9063_set_current_limit implementation Axel Lin
2013-08-30 12:08 ` [PATCH 2/2] regulator: da9063: Use IS_ERR to check return value of regulator_register() Axel Lin
@ 2013-08-30 14:24 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2013-08-30 14:24 UTC (permalink / raw)
To: Axel Lin; +Cc: Krystian Garbaciak, Philipp Zabel, Liam Girdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 246 bytes --]
On Fri, Aug 30, 2013 at 08:07:38PM +0800, Axel Lin wrote:
> All the current limit tables have the values in ascend order.
> So we can slightly optimize the for loop iteration because the first match
> is the minimal value.
Applied both, 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:[~2013-08-30 14:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-30 12:07 [PATCH 1/2] regulator: da9063: Optimize da9063_set_current_limit implementation Axel Lin
2013-08-30 12:08 ` [PATCH 2/2] regulator: da9063: Use IS_ERR to check return value of regulator_register() Axel Lin
2013-08-30 14:24 ` [PATCH 1/2] regulator: da9063: Optimize da9063_set_current_limit implementation Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox