Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

remove lots of IS_ERR_VALUE abuses

Most users of IS_ERR_VALUE() in the kernel are wrong, as they
pass an 'int' into a function that takes an 'unsigned long'
argument. This happens to work because the type is sign-extended
on 64-bit architectures before it gets converted into an
unsigned type.

However, anything that passes an 'unsigned short' or 'unsigned int'
argument into IS_ERR_VALUE() is guaranteed to be broken, as are
8-bit integers and types that are wider than 'unsigned long'.

Andrzej Hajda has already fixed a lot of the worst abusers that
were causing actual bugs, but it would be nice to prevent any
users that are not passing 'unsigned long' arguments.

This patch changes all users of IS_ERR_VALUE() that I could find
on 32-bit ARM randconfig builds and x86 allmodconfig. For the
moment, this doesn't change the definition of IS_ERR_VALUE()
because there are probably still architecture specific users
elsewhere.

Almost all the warnings I got are for files that are better off
using 'if (err)' or 'if (err < 0)'.
The only legitimate user I could find that we get a warning for
is the (32-bit only) freescale fman driver, so I did not remove
the IS_ERR_VALUE() there but changed the type to 'unsigned long'.
For 9pfs, I just worked around one user whose calling conventions
are so obscure that I did not dare change the behavior.

I was using this definition for testing:

#define IS_ERR_VALUE(x) ((unsigned long*)NULL == (typeof (x)*)NULL && \
unlikely((unsigned long long)(x) >= (unsigned long long)(typeof(x))-MAX_ERRNO))

which ends up making all 16-bit or wider types work correctly with
the most plausible interpretation of what IS_ERR_VALUE() was supposed
to return according to its users, but also causes a compile-time
warning for any users that do not pass an 'unsigned long' argument.

I suggested this approach earlier this year, but back then we ended
up deciding to just fix the users that are obviously broken. After
the initial warning that caused me to get involved in the discussion
(fs/gfs2/dir.c) showed up again in the mainline kernel, Linus
asked me to send the whole thing again.

[ Updated the 9p parts as per Al Viro - Linus ]

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: https://lkml.org/lkml/2016/1/7/363
Link: https://lkml.org/lkml/2016/5/27/486
Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> # For nvmem part
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Arnd Bergmann and committed by
Linus Torvalds
287980e4 7ded384a

+102 -103
+11 -11
drivers/acpi/acpi_dbg.c
··· 265 265 char *p; 266 266 267 267 ret = acpi_aml_lock_write(crc, ACPI_AML_OUT_KERN); 268 - if (IS_ERR_VALUE(ret)) 268 + if (ret < 0) 269 269 return ret; 270 270 /* sync tail before inserting logs */ 271 271 smp_mb(); ··· 286 286 char *p; 287 287 288 288 ret = acpi_aml_lock_read(crc, ACPI_AML_IN_KERN); 289 - if (IS_ERR_VALUE(ret)) 289 + if (ret < 0) 290 290 return ret; 291 291 /* sync head before removing cmds */ 292 292 smp_rmb(); ··· 330 330 goto again; 331 331 break; 332 332 } 333 - if (IS_ERR_VALUE(ret)) 333 + if (ret < 0) 334 334 break; 335 335 size += ret; 336 336 count -= ret; ··· 373 373 if (ret == 0) 374 374 goto again; 375 375 } 376 - if (IS_ERR_VALUE(ret)) 376 + if (ret < 0) 377 377 break; 378 378 *(msg + size) = (char)ret; 379 379 size++; ··· 526 526 } 527 527 acpi_aml_io.users++; 528 528 err_lock: 529 - if (IS_ERR_VALUE(ret)) { 529 + if (ret < 0) { 530 530 if (acpi_aml_active_reader == file) 531 531 acpi_aml_active_reader = NULL; 532 532 } ··· 587 587 char *p; 588 588 589 589 ret = acpi_aml_lock_read(crc, ACPI_AML_OUT_USER); 590 - if (IS_ERR_VALUE(ret)) 590 + if (ret < 0) 591 591 return ret; 592 592 /* sync head before removing logs */ 593 593 smp_rmb(); ··· 602 602 crc->tail = (crc->tail + n) & (ACPI_AML_BUF_SIZE - 1); 603 603 ret = n; 604 604 out: 605 - acpi_aml_unlock_fifo(ACPI_AML_OUT_USER, !IS_ERR_VALUE(ret)); 605 + acpi_aml_unlock_fifo(ACPI_AML_OUT_USER, !ret); 606 606 return ret; 607 607 } 608 608 ··· 634 634 goto again; 635 635 } 636 636 } 637 - if (IS_ERR_VALUE(ret)) { 637 + if (ret < 0) { 638 638 if (!acpi_aml_running()) 639 639 ret = 0; 640 640 break; ··· 657 657 char *p; 658 658 659 659 ret = acpi_aml_lock_write(crc, ACPI_AML_IN_USER); 660 - if (IS_ERR_VALUE(ret)) 660 + if (ret < 0) 661 661 return ret; 662 662 /* sync tail before inserting cmds */ 663 663 smp_mb(); ··· 672 672 crc->head = (crc->head + n) & (ACPI_AML_BUF_SIZE - 1); 673 673 ret = n; 674 674 out: 675 - acpi_aml_unlock_fifo(ACPI_AML_IN_USER, !IS_ERR_VALUE(ret)); 675 + acpi_aml_unlock_fifo(ACPI_AML_IN_USER, !ret); 676 676 return n; 677 677 } 678 678 ··· 704 704 goto again; 705 705 } 706 706 } 707 - if (IS_ERR_VALUE(ret)) { 707 + if (ret < 0) { 708 708 if (!acpi_aml_running()) 709 709 ret = 0; 710 710 break;
+1 -1
drivers/ata/sata_highbank.c
··· 197 197 198 198 for (i = 0; i < SGPIO_PINS; i++) { 199 199 err = of_get_named_gpio(np, "calxeda,sgpio-gpio", i); 200 - if (IS_ERR_VALUE(err)) 200 + if (err < 0) 201 201 return; 202 202 203 203 pdata->sgpio_gpio[i] = err;
+1 -1
drivers/clk/tegra/clk-tegra210.c
··· 1221 1221 p = rate >= params->vco_min ? 1 : -EINVAL; 1222 1222 } 1223 1223 1224 - if (IS_ERR_VALUE(p)) 1224 + if (p < 0) 1225 1225 return -EINVAL; 1226 1226 1227 1227 cfg->m = tegra_pll_get_fixed_mdiv(hw, input_rate);
+1 -1
drivers/cpufreq/omap-cpufreq.c
··· 54 54 55 55 freq = new_freq * 1000; 56 56 ret = clk_round_rate(policy->clk, freq); 57 - if (IS_ERR_VALUE(ret)) { 57 + if (ret < 0) { 58 58 dev_warn(mpu_dev, 59 59 "CPUfreq: Cannot find matching frequency for %lu\n", 60 60 freq);
+1 -1
drivers/crypto/caam/ctrl.c
··· 402 402 ret = of_property_read_u32(caam_node, "fsl,sec-era", &prop); 403 403 of_node_put(caam_node); 404 404 405 - return IS_ERR_VALUE(ret) ? -ENOTSUPP : prop; 405 + return ret ? -ENOTSUPP : prop; 406 406 } 407 407 EXPORT_SYMBOL(caam_get_era); 408 408
+8 -8
drivers/dma/sun4i-dma.c
··· 461 461 462 462 /* Source burst */ 463 463 ret = convert_burst(sconfig->src_maxburst); 464 - if (IS_ERR_VALUE(ret)) 464 + if (ret < 0) 465 465 goto fail; 466 466 promise->cfg |= SUN4I_DMA_CFG_SRC_BURST_LENGTH(ret); 467 467 468 468 /* Destination burst */ 469 469 ret = convert_burst(sconfig->dst_maxburst); 470 - if (IS_ERR_VALUE(ret)) 470 + if (ret < 0) 471 471 goto fail; 472 472 promise->cfg |= SUN4I_DMA_CFG_DST_BURST_LENGTH(ret); 473 473 474 474 /* Source bus width */ 475 475 ret = convert_buswidth(sconfig->src_addr_width); 476 - if (IS_ERR_VALUE(ret)) 476 + if (ret < 0) 477 477 goto fail; 478 478 promise->cfg |= SUN4I_DMA_CFG_SRC_DATA_WIDTH(ret); 479 479 480 480 /* Destination bus width */ 481 481 ret = convert_buswidth(sconfig->dst_addr_width); 482 - if (IS_ERR_VALUE(ret)) 482 + if (ret < 0) 483 483 goto fail; 484 484 promise->cfg |= SUN4I_DMA_CFG_DST_DATA_WIDTH(ret); 485 485 ··· 518 518 519 519 /* Source burst */ 520 520 ret = convert_burst(sconfig->src_maxburst); 521 - if (IS_ERR_VALUE(ret)) 521 + if (ret < 0) 522 522 goto fail; 523 523 promise->cfg |= SUN4I_DMA_CFG_SRC_BURST_LENGTH(ret); 524 524 525 525 /* Destination burst */ 526 526 ret = convert_burst(sconfig->dst_maxburst); 527 - if (IS_ERR_VALUE(ret)) 527 + if (ret < 0) 528 528 goto fail; 529 529 promise->cfg |= SUN4I_DMA_CFG_DST_BURST_LENGTH(ret); 530 530 531 531 /* Source bus width */ 532 532 ret = convert_buswidth(sconfig->src_addr_width); 533 - if (IS_ERR_VALUE(ret)) 533 + if (ret < 0) 534 534 goto fail; 535 535 promise->cfg |= SUN4I_DMA_CFG_SRC_DATA_WIDTH(ret); 536 536 537 537 /* Destination bus width */ 538 538 ret = convert_buswidth(sconfig->dst_addr_width); 539 - if (IS_ERR_VALUE(ret)) 539 + if (ret < 0) 540 540 goto fail; 541 541 promise->cfg |= SUN4I_DMA_CFG_DST_DATA_WIDTH(ret); 542 542
+1 -1
drivers/gpio/gpio-xlp.c
··· 393 393 irq_base = irq_alloc_descs(-1, 0, gc->ngpio, 0); 394 394 else 395 395 irq_base = irq_alloc_descs(-1, XLP_GPIO_IRQ_BASE, gc->ngpio, 0); 396 - if (IS_ERR_VALUE(irq_base)) { 396 + if (irq_base < 0) { 397 397 dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n"); 398 398 return irq_base; 399 399 }
+2 -2
drivers/gpu/drm/sti/sti_vtg.c
··· 437 437 return -EPROBE_DEFER; 438 438 } else { 439 439 vtg->irq = platform_get_irq(pdev, 0); 440 - if (IS_ERR_VALUE(vtg->irq)) { 440 + if (vtg->irq < 0) { 441 441 DRM_ERROR("Failed to get VTG interrupt\n"); 442 442 return vtg->irq; 443 443 } ··· 447 447 ret = devm_request_threaded_irq(dev, vtg->irq, vtg_irq, 448 448 vtg_irq_thread, IRQF_ONESHOT, 449 449 dev_name(dev), vtg); 450 - if (IS_ERR_VALUE(ret)) { 450 + if (ret < 0) { 451 451 DRM_ERROR("Failed to register VTG interrupt\n"); 452 452 return ret; 453 453 }
+1 -1
drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
··· 342 342 343 343 tfp410_mod->gpio = of_get_named_gpio_flags(node, "powerdn-gpio", 344 344 0, NULL); 345 - if (IS_ERR_VALUE(tfp410_mod->gpio)) { 345 + if (tfp410_mod->gpio < 0) { 346 346 dev_warn(&pdev->dev, "No power down GPIO\n"); 347 347 } else { 348 348 ret = gpio_request(tfp410_mod->gpio, "DVI_PDn");
+1 -1
drivers/gpu/host1x/hw/intr_hw.c
··· 85 85 err = devm_request_irq(host->dev, host->intr_syncpt_irq, 86 86 syncpt_thresh_isr, IRQF_SHARED, 87 87 "host1x_syncpt", host); 88 - if (IS_ERR_VALUE(err)) { 88 + if (err < 0) { 89 89 WARN_ON(1); 90 90 return err; 91 91 }
+9 -9
drivers/iommu/arm-smmu-v3.c
··· 1477 1477 struct arm_smmu_s1_cfg *cfg = &smmu_domain->s1_cfg; 1478 1478 1479 1479 asid = arm_smmu_bitmap_alloc(smmu->asid_map, smmu->asid_bits); 1480 - if (IS_ERR_VALUE(asid)) 1480 + if (asid < 0) 1481 1481 return asid; 1482 1482 1483 1483 cfg->cdptr = dmam_alloc_coherent(smmu->dev, CTXDESC_CD_DWORDS << 3, ··· 1508 1508 struct arm_smmu_s2_cfg *cfg = &smmu_domain->s2_cfg; 1509 1509 1510 1510 vmid = arm_smmu_bitmap_alloc(smmu->vmid_map, smmu->vmid_bits); 1511 - if (IS_ERR_VALUE(vmid)) 1511 + if (vmid < 0) 1512 1512 return vmid; 1513 1513 1514 1514 cfg->vmid = (u16)vmid; ··· 1569 1569 smmu_domain->pgtbl_ops = pgtbl_ops; 1570 1570 1571 1571 ret = finalise_stage_fn(smmu_domain, &pgtbl_cfg); 1572 - if (IS_ERR_VALUE(ret)) 1572 + if (ret < 0) 1573 1573 free_io_pgtable_ops(pgtbl_ops); 1574 1574 1575 1575 return ret; ··· 1642 1642 struct arm_smmu_group *smmu_group = arm_smmu_group_get(dev); 1643 1643 1644 1644 smmu_group->ste.bypass = true; 1645 - if (IS_ERR_VALUE(arm_smmu_install_ste_for_group(smmu_group))) 1645 + if (arm_smmu_install_ste_for_group(smmu_group) < 0) 1646 1646 dev_warn(dev, "failed to install bypass STE\n"); 1647 1647 1648 1648 smmu_group->domain = NULL; ··· 1694 1694 smmu_group->ste.bypass = domain->type == IOMMU_DOMAIN_DMA; 1695 1695 1696 1696 ret = arm_smmu_install_ste_for_group(smmu_group); 1697 - if (IS_ERR_VALUE(ret)) 1697 + if (ret < 0) 1698 1698 smmu_group->domain = NULL; 1699 1699 1700 1700 out_unlock: ··· 2235 2235 arm_smmu_evtq_handler, 2236 2236 arm_smmu_evtq_thread, 2237 2237 0, "arm-smmu-v3-evtq", smmu); 2238 - if (IS_ERR_VALUE(ret)) 2238 + if (ret < 0) 2239 2239 dev_warn(smmu->dev, "failed to enable evtq irq\n"); 2240 2240 } 2241 2241 ··· 2244 2244 ret = devm_request_irq(smmu->dev, irq, 2245 2245 arm_smmu_cmdq_sync_handler, 0, 2246 2246 "arm-smmu-v3-cmdq-sync", smmu); 2247 - if (IS_ERR_VALUE(ret)) 2247 + if (ret < 0) 2248 2248 dev_warn(smmu->dev, "failed to enable cmdq-sync irq\n"); 2249 2249 } 2250 2250 ··· 2252 2252 if (irq) { 2253 2253 ret = devm_request_irq(smmu->dev, irq, arm_smmu_gerror_handler, 2254 2254 0, "arm-smmu-v3-gerror", smmu); 2255 - if (IS_ERR_VALUE(ret)) 2255 + if (ret < 0) 2256 2256 dev_warn(smmu->dev, "failed to enable gerror irq\n"); 2257 2257 } 2258 2258 ··· 2264 2264 arm_smmu_priq_thread, 2265 2265 0, "arm-smmu-v3-priq", 2266 2266 smmu); 2267 - if (IS_ERR_VALUE(ret)) 2267 + if (ret < 0) 2268 2268 dev_warn(smmu->dev, 2269 2269 "failed to enable priq irq\n"); 2270 2270 else
+4 -4
drivers/iommu/arm-smmu.c
··· 950 950 951 951 ret = __arm_smmu_alloc_bitmap(smmu->context_map, start, 952 952 smmu->num_context_banks); 953 - if (IS_ERR_VALUE(ret)) 953 + if (ret < 0) 954 954 goto out_unlock; 955 955 956 956 cfg->cbndx = ret; ··· 989 989 irq = smmu->irqs[smmu->num_global_irqs + cfg->irptndx]; 990 990 ret = request_irq(irq, arm_smmu_context_fault, IRQF_SHARED, 991 991 "arm-smmu-context-fault", domain); 992 - if (IS_ERR_VALUE(ret)) { 992 + if (ret < 0) { 993 993 dev_err(smmu->dev, "failed to request context IRQ %d (%u)\n", 994 994 cfg->irptndx, irq); 995 995 cfg->irptndx = INVALID_IRPTNDX; ··· 1099 1099 for (i = 0; i < cfg->num_streamids; ++i) { 1100 1100 int idx = __arm_smmu_alloc_bitmap(smmu->smr_map, 0, 1101 1101 smmu->num_mapping_groups); 1102 - if (IS_ERR_VALUE(idx)) { 1102 + if (idx < 0) { 1103 1103 dev_err(smmu->dev, "failed to allocate free SMR\n"); 1104 1104 goto err_free_smrs; 1105 1105 } ··· 1233 1233 1234 1234 /* Ensure that the domain is finalised */ 1235 1235 ret = arm_smmu_init_domain_context(domain, smmu); 1236 - if (IS_ERR_VALUE(ret)) 1236 + if (ret < 0) 1237 1237 return ret; 1238 1238 1239 1239 /*
+1 -1
drivers/irqchip/irq-clps711x.c
··· 182 182 writel_relaxed(0, clps711x_intc->intmr[2]); 183 183 184 184 err = irq_alloc_descs(-1, 0, ARRAY_SIZE(clps711x_irqs), numa_node_id()); 185 - if (IS_ERR_VALUE(err)) 185 + if (err < 0) 186 186 goto out_iounmap; 187 187 188 188 clps711x_intc->ops.map = clps711x_intc_irq_map;
+1 -1
drivers/irqchip/irq-gic.c
··· 1123 1123 1124 1124 irq_base = irq_alloc_descs(irq_start, 16, gic_irqs, 1125 1125 numa_node_id()); 1126 - if (IS_ERR_VALUE(irq_base)) { 1126 + if (irq_base < 0) { 1127 1127 WARN(1, "Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n", 1128 1128 irq_start); 1129 1129 irq_base = irq_start;
+1 -1
drivers/irqchip/irq-hip04.c
··· 402 402 nr_irqs -= hwirq_base; /* calculate # of irqs to allocate */ 403 403 404 404 irq_base = irq_alloc_descs(-1, hwirq_base, nr_irqs, numa_node_id()); 405 - if (IS_ERR_VALUE(irq_base)) { 405 + if (irq_base < 0) { 406 406 pr_err("failed to allocate IRQ numbers\n"); 407 407 return -EINVAL; 408 408 }
+1 -1
drivers/irqchip/spear-shirq.c
··· 232 232 nr_irqs += shirq_blocks[i]->nr_irqs; 233 233 234 234 virq_base = irq_alloc_descs(-1, 0, nr_irqs, 0); 235 - if (IS_ERR_VALUE(virq_base)) { 235 + if (virq_base < 0) { 236 236 pr_err("%s: irq desc alloc failed\n", __func__); 237 237 goto err_unmap; 238 238 }
+5 -5
drivers/media/i2c/adp1653.c
··· 95 95 int rval; 96 96 97 97 fault = i2c_smbus_read_byte_data(client, ADP1653_REG_FAULT); 98 - if (IS_ERR_VALUE(fault)) 98 + if (fault < 0) 99 99 return fault; 100 100 101 101 flash->fault |= fault; ··· 105 105 106 106 /* Clear faults. */ 107 107 rval = i2c_smbus_write_byte_data(client, ADP1653_REG_OUT_SEL, 0); 108 - if (IS_ERR_VALUE(rval)) 108 + if (rval < 0) 109 109 return rval; 110 110 111 111 flash->led_mode->val = V4L2_FLASH_LED_MODE_NONE; 112 112 113 113 rval = adp1653_update_hw(flash); 114 - if (IS_ERR_VALUE(rval)) 114 + if (rval) 115 115 return rval; 116 116 117 117 return flash->fault; ··· 158 158 int rval; 159 159 160 160 rval = adp1653_get_fault(flash); 161 - if (IS_ERR_VALUE(rval)) 161 + if (rval) 162 162 return rval; 163 163 164 164 ctrl->cur.val = 0; ··· 184 184 int rval; 185 185 186 186 rval = adp1653_get_fault(flash); 187 - if (IS_ERR_VALUE(rval)) 187 + if (rval) 188 188 return rval; 189 189 if ((rval & (ADP1653_REG_FAULT_FLT_SCP | 190 190 ADP1653_REG_FAULT_FLT_OT |
+1 -1
drivers/media/platform/s5p-tv/mixer_drv.c
··· 146 146 147 147 /* returning 1 means that power is already enabled, 148 148 * so zero success be returned */ 149 - if (IS_ERR_VALUE(ret)) 149 + if (ret < 0) 150 150 return ret; 151 151 return 0; 152 152 }
+1 -1
drivers/mfd/twl4030-irq.c
··· 696 696 nr_irqs = TWL4030_PWR_NR_IRQS + TWL4030_CORE_NR_IRQS; 697 697 698 698 irq_base = irq_alloc_descs(-1, 0, nr_irqs, 0); 699 - if (IS_ERR_VALUE(irq_base)) { 699 + if (irq_base < 0) { 700 700 dev_err(dev, "Fail to allocate IRQ descs\n"); 701 701 return irq_base; 702 702 }
+2 -2
drivers/mmc/core/mmc.c
··· 1276 1276 * switch to HS200 mode if bus width is set successfully. 1277 1277 */ 1278 1278 err = mmc_select_bus_width(card); 1279 - if (!IS_ERR_VALUE(err)) { 1279 + if (!err) { 1280 1280 val = EXT_CSD_TIMING_HS200 | 1281 1281 card->drive_strength << EXT_CSD_DRV_STR_SHIFT; 1282 1282 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, ··· 1583 1583 } else if (mmc_card_hs(card)) { 1584 1584 /* Select the desired bus width optionally */ 1585 1585 err = mmc_select_bus_width(card); 1586 - if (!IS_ERR_VALUE(err)) { 1586 + if (!err) { 1587 1587 err = mmc_select_hs_ddr(card); 1588 1588 if (err) 1589 1589 goto free_card;
+3 -3
drivers/mmc/host/dw_mmc.c
··· 1431 1431 int gpio_ro = mmc_gpio_get_ro(mmc); 1432 1432 1433 1433 /* Use platform get_ro function, else try on board write protect */ 1434 - if (!IS_ERR_VALUE(gpio_ro)) 1434 + if (gpio_ro >= 0) 1435 1435 read_only = gpio_ro; 1436 1436 else 1437 1437 read_only = ··· 1454 1454 if ((mmc->caps & MMC_CAP_NEEDS_POLL) || 1455 1455 (mmc->caps & MMC_CAP_NONREMOVABLE)) 1456 1456 present = 1; 1457 - else if (!IS_ERR_VALUE(gpio_cd)) 1457 + else if (gpio_cd >= 0) 1458 1458 present = gpio_cd; 1459 1459 else 1460 1460 present = (mci_readl(slot->host, CDETECT) & (1 << slot->id)) ··· 2927 2927 if (slot->mmc->caps & MMC_CAP_NEEDS_POLL) 2928 2928 return; 2929 2929 2930 - if (IS_ERR_VALUE(mmc_gpio_get_cd(slot->mmc))) 2930 + if (mmc_gpio_get_cd(slot->mmc) < 0) 2931 2931 break; 2932 2932 } 2933 2933 if (i == host->num_slots)
+1 -1
drivers/mmc/host/sdhci-esdhc-imx.c
··· 1011 1011 if (ret) 1012 1012 return ret; 1013 1013 1014 - if (!IS_ERR_VALUE(mmc_gpio_get_cd(host->mmc))) 1014 + if (mmc_gpio_get_cd(host->mmc) >= 0) 1015 1015 host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION; 1016 1016 1017 1017 return 0;
+1 -1
drivers/mmc/host/sdhci-of-at91.c
··· 289 289 * to enable polling via device tree with broken-cd property. 290 290 */ 291 291 if (!(host->mmc->caps & MMC_CAP_NONREMOVABLE) && 292 - IS_ERR_VALUE(mmc_gpio_get_cd(host->mmc))) { 292 + mmc_gpio_get_cd(host->mmc) < 0) { 293 293 host->mmc->caps |= MMC_CAP_NEEDS_POLL; 294 294 host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION; 295 295 }
+2 -2
drivers/mmc/host/sdhci.c
··· 1624 1624 * Try slot gpio detect, if defined it take precedence 1625 1625 * over build in controller functionality 1626 1626 */ 1627 - if (!IS_ERR_VALUE(gpio_cd)) 1627 + if (gpio_cd >= 0) 1628 1628 return !!gpio_cd; 1629 1629 1630 1630 /* If polling, assume that the card is always present. */ ··· 3077 3077 3078 3078 if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) && 3079 3079 !(mmc->caps & MMC_CAP_NONREMOVABLE) && 3080 - IS_ERR_VALUE(mmc_gpio_get_cd(host->mmc))) 3080 + mmc_gpio_get_cd(host->mmc) < 0) 3081 3081 mmc->caps |= MMC_CAP_NEEDS_POLL; 3082 3082 3083 3083 /* If there are external regulators, get them */
+1 -1
drivers/net/ethernet/freescale/fman/fman.c
··· 615 615 struct fman_cfg *cfg; 616 616 struct muram_info *muram; 617 617 /* cam section in muram */ 618 - int cam_offset; 618 + unsigned long cam_offset; 619 619 size_t cam_size; 620 620 /* Fifo in MURAM */ 621 621 int fifo_offset;
+2 -2
drivers/net/ethernet/freescale/fman/fman_muram.c
··· 129 129 * 130 130 * Return: address of the allocated memory; NULL otherwise. 131 131 */ 132 - int fman_muram_alloc(struct muram_info *muram, size_t size) 132 + unsigned long fman_muram_alloc(struct muram_info *muram, size_t size) 133 133 { 134 134 unsigned long vaddr; 135 135 ··· 150 150 * 151 151 * Free an allocated memory from FM-MURAM partition. 152 152 */ 153 - void fman_muram_free_mem(struct muram_info *muram, u32 offset, size_t size) 153 + void fman_muram_free_mem(struct muram_info *muram, unsigned long offset, size_t size) 154 154 { 155 155 unsigned long addr = fman_muram_offset_to_vbase(muram, offset); 156 156
+2 -2
drivers/net/ethernet/freescale/fman/fman_muram.h
··· 44 44 unsigned long fman_muram_offset_to_vbase(struct muram_info *muram, 45 45 unsigned long offset); 46 46 47 - int fman_muram_alloc(struct muram_info *muram, size_t size); 47 + unsigned long fman_muram_alloc(struct muram_info *muram, size_t size); 48 48 49 - void fman_muram_free_mem(struct muram_info *muram, u32 offset, size_t size); 49 + void fman_muram_free_mem(struct muram_info *muram, unsigned long offset, size_t size); 50 50 51 51 #endif /* __FM_MURAM_EXT */
+2 -2
drivers/net/wireless/ti/wlcore/spi.c
··· 382 382 383 383 ret = of_property_read_u32(dt_node, "ref-clock-frequency", 384 384 &pdev_data->ref_clock_freq); 385 - if (IS_ERR_VALUE(ret)) { 385 + if (ret) { 386 386 dev_err(glue->dev, 387 387 "can't get reference clock frequency (%d)\n", ret); 388 388 return ret; ··· 425 425 } 426 426 427 427 ret = wlcore_probe_of(spi, glue, &pdev_data); 428 - if (IS_ERR_VALUE(ret)) { 428 + if (ret) { 429 429 dev_err(glue->dev, 430 430 "can't get device tree parameters (%d)\n", ret); 431 431 return ret;
+11 -11
drivers/nvmem/core.c
··· 113 113 114 114 rc = nvmem_reg_read(nvmem, pos, buf, count); 115 115 116 - if (IS_ERR_VALUE(rc)) 116 + if (rc) 117 117 return rc; 118 118 119 119 return count; ··· 147 147 148 148 rc = nvmem_reg_write(nvmem, pos, buf, count); 149 149 150 - if (IS_ERR_VALUE(rc)) 150 + if (rc) 151 151 return rc; 152 152 153 153 return count; ··· 366 366 } 367 367 368 368 rval = nvmem_cell_info_to_nvmem_cell(nvmem, &info[i], cells[i]); 369 - if (IS_ERR_VALUE(rval)) { 369 + if (rval) { 370 370 kfree(cells[i]); 371 371 goto err; 372 372 } ··· 963 963 964 964 rc = nvmem_reg_read(nvmem, cell->offset, buf, cell->bytes); 965 965 966 - if (IS_ERR_VALUE(rc)) 966 + if (rc) 967 967 return rc; 968 968 969 969 /* shift bits in-place */ ··· 998 998 return ERR_PTR(-ENOMEM); 999 999 1000 1000 rc = __nvmem_cell_read(nvmem, cell, buf, len); 1001 - if (IS_ERR_VALUE(rc)) { 1001 + if (rc) { 1002 1002 kfree(buf); 1003 1003 return ERR_PTR(rc); 1004 1004 } ··· 1083 1083 if (cell->bit_offset || cell->nbits) 1084 1084 kfree(buf); 1085 1085 1086 - if (IS_ERR_VALUE(rc)) 1086 + if (rc) 1087 1087 return rc; 1088 1088 1089 1089 return len; ··· 1111 1111 return -EINVAL; 1112 1112 1113 1113 rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell); 1114 - if (IS_ERR_VALUE(rc)) 1114 + if (rc) 1115 1115 return rc; 1116 1116 1117 1117 rc = __nvmem_cell_read(nvmem, &cell, buf, &len); 1118 - if (IS_ERR_VALUE(rc)) 1118 + if (rc) 1119 1119 return rc; 1120 1120 1121 1121 return len; ··· 1141 1141 return -EINVAL; 1142 1142 1143 1143 rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell); 1144 - if (IS_ERR_VALUE(rc)) 1144 + if (rc) 1145 1145 return rc; 1146 1146 1147 1147 return nvmem_cell_write(&cell, buf, cell.bytes); ··· 1170 1170 1171 1171 rc = nvmem_reg_read(nvmem, offset, buf, bytes); 1172 1172 1173 - if (IS_ERR_VALUE(rc)) 1173 + if (rc) 1174 1174 return rc; 1175 1175 1176 1176 return bytes; ··· 1198 1198 1199 1199 rc = nvmem_reg_write(nvmem, offset, buf, bytes); 1200 1200 1201 - if (IS_ERR_VALUE(rc)) 1201 + if (rc) 1202 1202 return rc; 1203 1203 1204 1204
+1 -1
drivers/tty/serial/amba-pl011.c
··· 2360 2360 return ret; 2361 2361 2362 2362 ret = of_alias_get_id(np, "serial"); 2363 - if (IS_ERR_VALUE(ret)) { 2363 + if (ret < 0) { 2364 2364 seen_dev_without_alias = true; 2365 2365 ret = index; 2366 2366 } else {
+1 -1
drivers/tty/serial/sprd_serial.c
··· 654 654 return ret; 655 655 656 656 ret = of_alias_get_id(np, "serial"); 657 - if (IS_ERR_VALUE(ret)) 657 + if (ret < 0) 658 658 ret = index; 659 659 else if (ret >= ARRAY_SIZE(sprd_port) || sprd_port[ret] != NULL) { 660 660 dev_warn(dev, "requested serial port %d not available.\n", ret);
+2 -2
drivers/video/fbdev/da8xx-fb.c
··· 713 713 714 714 if (par->lcdc_clk_rate != lcdc_clk_rate) { 715 715 ret = clk_set_rate(par->lcdc_clk, lcdc_clk_rate); 716 - if (IS_ERR_VALUE(ret)) { 716 + if (ret) { 717 717 dev_err(par->dev, 718 718 "unable to set clock rate at %u\n", 719 719 lcdc_clk_rate); ··· 784 784 int ret = 0; 785 785 786 786 ret = da8xx_fb_calc_config_clk_divider(par, panel); 787 - if (IS_ERR_VALUE(ret)) { 787 + if (ret) { 788 788 dev_err(par->dev, "unable to configure clock\n"); 789 789 return ret; 790 790 }
-4
fs/afs/write.c
··· 643 643 return 0; 644 644 645 645 result = generic_file_write_iter(iocb, from); 646 - if (IS_ERR_VALUE(result)) { 647 - _leave(" = %zd", result); 648 - return result; 649 - } 650 646 651 647 _leave(" = %zd", result); 652 648 return result;
+3 -3
fs/binfmt_flat.c
··· 337 337 "(%d != %d)", (unsigned) r, curid, id); 338 338 goto failed; 339 339 } else if ( ! p->lib_list[id].loaded && 340 - IS_ERR_VALUE(load_flat_shared_library(id, p))) { 340 + load_flat_shared_library(id, p) < 0) { 341 341 printk("BINFMT_FLAT: failed to load library %d", id); 342 342 goto failed; 343 343 } ··· 837 837 838 838 res = prepare_binprm(&bprm); 839 839 840 - if (!IS_ERR_VALUE(res)) 840 + if (!res) 841 841 res = load_flat_file(&bprm, libs, id, NULL); 842 842 843 843 abort_creds(bprm.cred); ··· 883 883 stack_len += FLAT_STACK_ALIGN - 1; /* reserve for upcoming alignment */ 884 884 885 885 res = load_flat_file(bprm, &libinfo, 0, &stack_len); 886 - if (IS_ERR_VALUE(res)) 886 + if (res < 0) 887 887 return res; 888 888 889 889 /* Update data segment pointers for all libraries */
+9 -6
fs/gfs2/dir.c
··· 783 783 u64 *leaf_out) 784 784 { 785 785 __be64 *hash; 786 + int error; 786 787 787 788 hash = gfs2_dir_get_hash_table(dip); 788 - if (IS_ERR(hash)) 789 - return PTR_ERR(hash); 790 - *leaf_out = be64_to_cpu(*(hash + index)); 791 - return 0; 789 + error = PTR_ERR_OR_ZERO(hash); 790 + 791 + if (!error) 792 + *leaf_out = be64_to_cpu(*(hash + index)); 793 + 794 + return error; 792 795 } 793 796 794 797 static int get_first_leaf(struct gfs2_inode *dip, u32 index, ··· 801 798 int error; 802 799 803 800 error = get_leaf_nr(dip, index, &leaf_no); 804 - if (!IS_ERR_VALUE(error)) 801 + if (!error) 805 802 error = get_leaf(dip, leaf_no, bh_out); 806 803 807 804 return error; ··· 1017 1014 1018 1015 index = name->hash >> (32 - dip->i_depth); 1019 1016 error = get_leaf_nr(dip, index, &leaf_no); 1020 - if (IS_ERR_VALUE(error)) 1017 + if (error) 1021 1018 return error; 1022 1019 1023 1020 /* Get the old leaf block */
+1 -1
kernel/pid.c
··· 311 311 pid->level = ns->level; 312 312 for (i = ns->level; i >= 0; i--) { 313 313 nr = alloc_pidmap(tmp); 314 - if (IS_ERR_VALUE(nr)) { 314 + if (nr < 0) { 315 315 retval = nr; 316 316 goto out_free; 317 317 }
+4 -4
net/9p/client.c
··· 518 518 if (err) 519 519 goto out_err; 520 520 521 - if (p9_is_proto_dotu(c)) 521 + if (p9_is_proto_dotu(c) && ecode < 512) 522 522 err = -ecode; 523 523 524 - if (!err || !IS_ERR_VALUE(err)) { 524 + if (!err) { 525 525 err = p9_errstr2errno(ename, strlen(ename)); 526 526 527 527 p9_debug(P9_DEBUG_9P, "<<< RERROR (%d) %s\n", ··· 605 605 if (err) 606 606 goto out_err; 607 607 608 - if (p9_is_proto_dotu(c)) 608 + if (p9_is_proto_dotu(c) && ecode < 512) 609 609 err = -ecode; 610 610 611 - if (!err || !IS_ERR_VALUE(err)) { 611 + if (!err) { 612 612 err = p9_errstr2errno(ename, strlen(ename)); 613 613 614 614 p9_debug(P9_DEBUG_9P, "<<< RERROR (%d) %s\n",
+2 -2
sound/soc/qcom/lpass-platform.c
··· 491 491 data->rdma_ch = v->alloc_dma_channel(drvdata, 492 492 SNDRV_PCM_STREAM_PLAYBACK); 493 493 494 - if (IS_ERR_VALUE(data->rdma_ch)) 494 + if (data->rdma_ch < 0) 495 495 return data->rdma_ch; 496 496 497 497 drvdata->substream[data->rdma_ch] = psubstream; ··· 518 518 data->wrdma_ch = v->alloc_dma_channel(drvdata, 519 519 SNDRV_PCM_STREAM_CAPTURE); 520 520 521 - if (IS_ERR_VALUE(data->wrdma_ch)) 521 + if (data->wrdma_ch < 0) 522 522 goto capture_alloc_err; 523 523 524 524 drvdata->substream[data->wrdma_ch] = csubstream;