aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 }