aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-10-03 07:17:51 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-10-14 20:59:59 -0400
commit061adc064adbbdd9eb127ab2e86b7a71f4ccaf2e (patch)
treea967814d5255d9b8d25f4153d774160dace93201 /drivers/base
parente3549cd01347ef211d01353bdf2572b086574007 (diff)
regmap: When we sanity check during range adds say what errors we find
Rather than just returning a single error code for every possible thing we can notice print an error message saying what the problem was. This makes it very much easier to figure out what's wrong and fix it. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/regmap/regmap.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index ea9d6eb826bd..0544f63ecd31 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -524,11 +524,29 @@ struct regmap *regmap_init(struct device *dev,
524 struct regmap_range_node *new; 524 struct regmap_range_node *new;
525 525
526 /* Sanity check */ 526 /* Sanity check */
527 if (range_cfg->range_max < range_cfg->range_min || 527 if (range_cfg->range_max < range_cfg->range_min) {
528 range_cfg->range_max > map->max_register || 528 dev_err(map->dev, "Invalid range %d: %d < %d\n", i,
529 range_cfg->selector_reg > map->max_register || 529 range_cfg->range_max, range_cfg->range_min);
530 range_cfg->window_len == 0)
531 goto err_range; 530 goto err_range;
531 }
532
533 if (range_cfg->range_max > map->max_register) {
534 dev_err(map->dev, "Invalid range %d: %d > %d\n", i,
535 range_cfg->range_max, map->max_register);
536 goto err_range;
537 }
538
539 if (range_cfg->selector_reg > map->max_register) {
540 dev_err(map->dev,
541 "Invalid range %d: selector out of map\n", i);
542 goto err_range;
543 }
544
545 if (range_cfg->window_len == 0) {
546 dev_err(map->dev, "Invalid range %d: window_len 0\n",
547 i);
548 goto err_range;
549 }
532 550
533 /* Make sure, that this register range has no selector 551 /* Make sure, that this register range has no selector
534 or data window within its boundary */ 552 or data window within its boundary */
@@ -540,11 +558,17 @@ struct regmap *regmap_init(struct device *dev,
540 558
541 if (range_cfg->range_min <= sel_reg && 559 if (range_cfg->range_min <= sel_reg &&
542 sel_reg <= range_cfg->range_max) { 560 sel_reg <= range_cfg->range_max) {
561 dev_err(map->dev,
562 "Range %d: selector for %d in window\n",
563 i, j);
543 goto err_range; 564 goto err_range;
544 } 565 }
545 566
546 if (!(win_max < range_cfg->range_min || 567 if (!(win_max < range_cfg->range_min ||
547 win_min > range_cfg->range_max)) { 568 win_min > range_cfg->range_max)) {
569 dev_err(map->dev,
570 "Range %d: window for %d in window\n",
571 i, j);
548 goto err_range; 572 goto err_range;
549 } 573 }
550 } 574 }
@@ -564,6 +588,7 @@ struct regmap *regmap_init(struct device *dev,
564 new->window_len = range_cfg->window_len; 588 new->window_len = range_cfg->window_len;
565 589
566 if (_regmap_range_add(map, new) == false) { 590 if (_regmap_range_add(map, new) == false) {
591 dev_err(map->dev, "Failed to add range %d\n", i);
567 kfree(new); 592 kfree(new);
568 goto err_range; 593 goto err_range;
569 } 594 }