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