bcm53xx: add initial support for ARM based BCM47XX and BCM53XX SoCs
[openwrt/openwrt.git] / target / linux / bcm53xx / patches-3.10 / 0015-bcma-fix-handling-of-big-addrl.patch
1 From 8204277ed0f4aeb7bb38d0d5f39d9ebcced92576 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Fri, 5 Jul 2013 00:24:38 +0200
4 Subject: [PATCH 15/17] bcma: fix handling of big addrl
5
6 The return value of bcma_erom_get_addr_desc() is a unsigned value and it
7 could wrap around in the two complement writing.
8
9 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
10 ---
11 drivers/bcma/scan.c | 16 ++++++++--------
12 1 file changed, 8 insertions(+), 8 deletions(-)
13
14 --- a/drivers/bcma/scan.c
15 +++ b/drivers/bcma/scan.c
16 @@ -213,7 +213,7 @@ static s32 bcma_erom_get_mst_port(struct
17 return ent;
18 }
19
20 -static s32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr,
21 +static u32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr,
22 u32 type, u8 port)
23 {
24 u32 addrl, addrh, sizel, sizeh = 0;
25 @@ -225,7 +225,7 @@ static s32 bcma_erom_get_addr_desc(struc
26 ((ent & SCAN_ADDR_TYPE) != type) ||
27 (((ent & SCAN_ADDR_PORT) >> SCAN_ADDR_PORT_SHIFT) != port)) {
28 bcma_erom_push_ent(eromptr);
29 - return -EINVAL;
30 + return (u32)-EINVAL;
31 }
32
33 addrl = ent & SCAN_ADDR_ADDR;
34 @@ -273,7 +273,7 @@ static int bcma_get_next_core(struct bcm
35 struct bcma_device_id *match, int core_num,
36 struct bcma_device *core)
37 {
38 - s32 tmp;
39 + u32 tmp;
40 u8 i, j;
41 s32 cia, cib;
42 u8 ports[2], wrappers[2];
43 @@ -351,11 +351,11 @@ static int bcma_get_next_core(struct bcm
44 * the main register space for the core
45 */
46 tmp = bcma_erom_get_addr_desc(bus, eromptr, SCAN_ADDR_TYPE_SLAVE, 0);
47 - if (tmp <= 0) {
48 + if (tmp == 0 || IS_ERR_VALUE(tmp)) {
49 /* Try again to see if it is a bridge */
50 tmp = bcma_erom_get_addr_desc(bus, eromptr,
51 SCAN_ADDR_TYPE_BRIDGE, 0);
52 - if (tmp <= 0) {
53 + if (tmp == 0 || IS_ERR_VALUE(tmp)) {
54 return -EILSEQ;
55 } else {
56 bcma_info(bus, "Bridge found\n");
57 @@ -369,7 +369,7 @@ static int bcma_get_next_core(struct bcm
58 for (j = 0; ; j++) {
59 tmp = bcma_erom_get_addr_desc(bus, eromptr,
60 SCAN_ADDR_TYPE_SLAVE, i);
61 - if (tmp < 0) {
62 + if (IS_ERR_VALUE(tmp)) {
63 /* no more entries for port _i_ */
64 /* pr_debug("erom: slave port %d "
65 * "has %d descriptors\n", i, j); */
66 @@ -386,7 +386,7 @@ static int bcma_get_next_core(struct bcm
67 for (j = 0; ; j++) {
68 tmp = bcma_erom_get_addr_desc(bus, eromptr,
69 SCAN_ADDR_TYPE_MWRAP, i);
70 - if (tmp < 0) {
71 + if (IS_ERR_VALUE(tmp)) {
72 /* no more entries for port _i_ */
73 /* pr_debug("erom: master wrapper %d "
74 * "has %d descriptors\n", i, j); */
75 @@ -404,7 +404,7 @@ static int bcma_get_next_core(struct bcm
76 for (j = 0; ; j++) {
77 tmp = bcma_erom_get_addr_desc(bus, eromptr,
78 SCAN_ADDR_TYPE_SWRAP, i + hack);
79 - if (tmp < 0) {
80 + if (IS_ERR_VALUE(tmp)) {
81 /* no more entries for port _i_ */
82 /* pr_debug("erom: master wrapper %d "
83 * has %d descriptors\n", i, j); */