Skip to content

Commit aaa2ced

Browse files
haukelinvjw
authored andcommitted
bcma: fix error code handling on 64 Bit systems
On most 64 Bit systems unsigned long is 64 bit long and then -MAX_ERRNO is out of the range of a u32 used to store the error code in. This patch casts the -MAX_ERRNO to a u32 instead. This fixes a regression introduced in: commit fd4edf1 Author: Hauke Mehrtens <hauke@hauke-m.de> Date: Mon Jul 15 13:15:08 2013 +0200 bcma: fix handling of big addrl Reported-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Tested-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 8a10da2 commit aaa2ced

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎drivers/bcma/scan.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ static struct bcma_device *bcma_find_core_reverse(struct bcma_bus *bus, u16 core
269269
return NULL;
270270
}
271271

272+
#define IS_ERR_VALUE_U32(x) ((x) >= (u32)-MAX_ERRNO)
273+
272274
static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
273275
struct bcma_device_id *match, int core_num,
274276
struct bcma_device *core)
@@ -351,11 +353,11 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
351353
* the main register space for the core
352354
*/
353355
tmp = bcma_erom_get_addr_desc(bus, eromptr, SCAN_ADDR_TYPE_SLAVE, 0);
354-
if (tmp == 0 || IS_ERR_VALUE(tmp)) {
356+
if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) {
355357
/* Try again to see if it is a bridge */
356358
tmp = bcma_erom_get_addr_desc(bus, eromptr,
357359
SCAN_ADDR_TYPE_BRIDGE, 0);
358-
if (tmp == 0 || IS_ERR_VALUE(tmp)) {
360+
if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) {
359361
return -EILSEQ;
360362
} else {
361363
bcma_info(bus, "Bridge found\n");
@@ -369,7 +371,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
369371
for (j = 0; ; j++) {
370372
tmp = bcma_erom_get_addr_desc(bus, eromptr,
371373
SCAN_ADDR_TYPE_SLAVE, i);
372-
if (IS_ERR_VALUE(tmp)) {
374+
if (IS_ERR_VALUE_U32(tmp)) {
373375
/* no more entries for port _i_ */
374376
/* pr_debug("erom: slave port %d "
375377
* "has %d descriptors\n", i, j); */
@@ -386,7 +388,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
386388
for (j = 0; ; j++) {
387389
tmp = bcma_erom_get_addr_desc(bus, eromptr,
388390
SCAN_ADDR_TYPE_MWRAP, i);
389-
if (IS_ERR_VALUE(tmp)) {
391+
if (IS_ERR_VALUE_U32(tmp)) {
390392
/* no more entries for port _i_ */
391393
/* pr_debug("erom: master wrapper %d "
392394
* "has %d descriptors\n", i, j); */
@@ -404,7 +406,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
404406
for (j = 0; ; j++) {
405407
tmp = bcma_erom_get_addr_desc(bus, eromptr,
406408
SCAN_ADDR_TYPE_SWRAP, i + hack);
407-
if (IS_ERR_VALUE(tmp)) {
409+
if (IS_ERR_VALUE_U32(tmp)) {
408410
/* no more entries for port _i_ */
409411
/* pr_debug("erom: master wrapper %d "
410412
* has %d descriptors\n", i, j); */

0 commit comments

Comments
 (0)