aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2017-02-27 15:42:16 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-01 03:23:56 -0500
commita45e47f4b342884dcf9e40a530033f64c379ffc7 (patch)
treee0b03ca2eecce3749b24197e5ced67e33452c207
parent87bfbddd0935f7a3acf36b883707aee816d4bb49 (diff)
staging: fsl-mc: fix warning in DT ranges parser
The fsl-mc-bus driver in staging contains a copy of the standard 'ranges' property parsing algorithm with a hack to treat a missing property the same way as an empty one. This code produces false-positive warnings for me in an allmodconfig build: drivers/staging/fsl-mc/bus/fsl-mc-bus.c: In function 'fsl_mc_bus_probe': drivers/staging/fsl-mc/bus/fsl-mc-bus.c:645:6: error: 'mc_size_cells' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/staging/fsl-mc/bus/fsl-mc-bus.c:682:8: error: 'mc_addr_cells' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/staging/fsl-mc/bus/fsl-mc-bus.c:644:6: note: 'mc_addr_cells' was declared here drivers/staging/fsl-mc/bus/fsl-mc-bus.c:684:8: error: 'paddr_cells' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/staging/fsl-mc/bus/fsl-mc-bus.c:643:6: note: 'paddr_cells' was declared here To avoid the warnings, I'm simplifying the argument handling to pass the number of valid ranges in the property as the function return code rather than passing it by reference. With this change, gcc can see that we don't evaluate the cell numbers for an missing ranges property. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Laurentiu Tudor <laurentiu.tudor@nxp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/fsl-mc/bus/fsl-mc-bus.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
index 47acb0a29842..3be5f25ff113 100644
--- a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
@@ -588,8 +588,7 @@ static int parse_mc_ranges(struct device *dev,
588 int *paddr_cells, 588 int *paddr_cells,
589 int *mc_addr_cells, 589 int *mc_addr_cells,
590 int *mc_size_cells, 590 int *mc_size_cells,
591 const __be32 **ranges_start, 591 const __be32 **ranges_start)
592 u8 *num_ranges)
593{ 592{
594 const __be32 *prop; 593 const __be32 *prop;
595 int range_tuple_cell_count; 594 int range_tuple_cell_count;
@@ -602,8 +601,6 @@ static int parse_mc_ranges(struct device *dev,
602 dev_warn(dev, 601 dev_warn(dev,
603 "missing or empty ranges property for device tree node '%s'\n", 602 "missing or empty ranges property for device tree node '%s'\n",
604 mc_node->name); 603 mc_node->name);
605
606 *num_ranges = 0;
607 return 0; 604 return 0;
608 } 605 }
609 606
@@ -630,8 +627,7 @@ static int parse_mc_ranges(struct device *dev,
630 return -EINVAL; 627 return -EINVAL;
631 } 628 }
632 629
633 *num_ranges = ranges_len / tuple_len; 630 return ranges_len / tuple_len;
634 return 0;
635} 631}
636 632
637static int get_mc_addr_translation_ranges(struct device *dev, 633static int get_mc_addr_translation_ranges(struct device *dev,
@@ -639,7 +635,7 @@ static int get_mc_addr_translation_ranges(struct device *dev,
639 **ranges, 635 **ranges,
640 u8 *num_ranges) 636 u8 *num_ranges)
641{ 637{
642 int error; 638 int ret;
643 int paddr_cells; 639 int paddr_cells;
644 int mc_addr_cells; 640 int mc_addr_cells;
645 int mc_size_cells; 641 int mc_size_cells;
@@ -647,16 +643,16 @@ static int get_mc_addr_translation_ranges(struct device *dev,
647 const __be32 *ranges_start; 643 const __be32 *ranges_start;
648 const __be32 *cell; 644 const __be32 *cell;
649 645
650 error = parse_mc_ranges(dev, 646 ret = parse_mc_ranges(dev,
651 &paddr_cells, 647 &paddr_cells,
652 &mc_addr_cells, 648 &mc_addr_cells,
653 &mc_size_cells, 649 &mc_size_cells,
654 &ranges_start, 650 &ranges_start);
655 num_ranges); 651 if (ret < 0)
656 if (error < 0) 652 return ret;
657 return error;
658 653
659 if (!(*num_ranges)) { 654 *num_ranges = ret;
655 if (!ret) {
660 /* 656 /*
661 * Missing or empty ranges property ("ranges;") for the 657 * Missing or empty ranges property ("ranges;") for the
662 * 'fsl,qoriq-mc' node. In this case, identity mapping 658 * 'fsl,qoriq-mc' node. In this case, identity mapping