]> git.baikalelectronics.ru Git - kernel.git/commitdiff
remove lots of IS_ERR_VALUE abuses
authorArnd Bergmann <arnd@arndb.de>
Fri, 27 May 2016 21:23:25 +0000 (23:23 +0200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 27 May 2016 22:26:11 +0000 (15:26 -0700)
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>
38 files changed:
drivers/acpi/acpi_dbg.c
drivers/ata/sata_highbank.c
drivers/clk/tegra/clk-tegra210.c
drivers/cpufreq/omap-cpufreq.c
drivers/crypto/caam/ctrl.c
drivers/dma/sun4i-dma.c
drivers/gpio/gpio-xlp.c
drivers/gpu/drm/sti/sti_vtg.c
drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
drivers/gpu/host1x/hw/intr_hw.c
drivers/iommu/arm-smmu-v3.c
drivers/iommu/arm-smmu.c
drivers/irqchip/irq-clps711x.c
drivers/irqchip/irq-gic.c
drivers/irqchip/irq-hip04.c
drivers/irqchip/spear-shirq.c
drivers/media/i2c/adp1653.c
drivers/media/platform/s5p-tv/mixer_drv.c
drivers/mfd/twl4030-irq.c
drivers/mmc/core/mmc.c
drivers/mmc/host/dw_mmc.c
drivers/mmc/host/sdhci-esdhc-imx.c
drivers/mmc/host/sdhci-of-at91.c
drivers/mmc/host/sdhci.c
drivers/net/ethernet/freescale/fman/fman.c
drivers/net/ethernet/freescale/fman/fman_muram.c
drivers/net/ethernet/freescale/fman/fman_muram.h
drivers/net/wireless/ti/wlcore/spi.c
drivers/nvmem/core.c
drivers/tty/serial/amba-pl011.c
drivers/tty/serial/sprd_serial.c
drivers/video/fbdev/da8xx-fb.c
fs/afs/write.c
fs/binfmt_flat.c
fs/gfs2/dir.c
kernel/pid.c
net/9p/client.c
sound/soc/qcom/lpass-platform.c

index 15e4604efba7d298f8a5e1931eb3919452f26dbf..1f4128487dd4be1b342df522e010de6c29c6756b 100644 (file)
@@ -265,7 +265,7 @@ static int acpi_aml_write_kern(const char *buf, int len)
        char *p;
 
        ret = acpi_aml_lock_write(crc, ACPI_AML_OUT_KERN);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                return ret;
        /* sync tail before inserting logs */
        smp_mb();
@@ -286,7 +286,7 @@ static int acpi_aml_readb_kern(void)
        char *p;
 
        ret = acpi_aml_lock_read(crc, ACPI_AML_IN_KERN);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                return ret;
        /* sync head before removing cmds */
        smp_rmb();
@@ -330,7 +330,7 @@ again:
                                goto again;
                        break;
                }
-               if (IS_ERR_VALUE(ret))
+               if (ret < 0)
                        break;
                size += ret;
                count -= ret;
@@ -373,7 +373,7 @@ again:
                        if (ret == 0)
                                goto again;
                }
-               if (IS_ERR_VALUE(ret))
+               if (ret < 0)
                        break;
                *(msg + size) = (char)ret;
                size++;
@@ -526,7 +526,7 @@ static int acpi_aml_open(struct inode *inode, struct file *file)
        }
        acpi_aml_io.users++;
 err_lock:
-       if (IS_ERR_VALUE(ret)) {
+       if (ret < 0) {
                if (acpi_aml_active_reader == file)
                        acpi_aml_active_reader = NULL;
        }
@@ -587,7 +587,7 @@ static int acpi_aml_read_user(char __user *buf, int len)
        char *p;
 
        ret = acpi_aml_lock_read(crc, ACPI_AML_OUT_USER);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                return ret;
        /* sync head before removing logs */
        smp_rmb();
@@ -602,7 +602,7 @@ static int acpi_aml_read_user(char __user *buf, int len)
        crc->tail = (crc->tail + n) & (ACPI_AML_BUF_SIZE - 1);
        ret = n;
 out:
-       acpi_aml_unlock_fifo(ACPI_AML_OUT_USER, !IS_ERR_VALUE(ret));
+       acpi_aml_unlock_fifo(ACPI_AML_OUT_USER, !ret);
        return ret;
 }
 
@@ -634,7 +634,7 @@ again:
                                        goto again;
                        }
                }
-               if (IS_ERR_VALUE(ret)) {
+               if (ret < 0) {
                        if (!acpi_aml_running())
                                ret = 0;
                        break;
@@ -657,7 +657,7 @@ static int acpi_aml_write_user(const char __user *buf, int len)
        char *p;
 
        ret = acpi_aml_lock_write(crc, ACPI_AML_IN_USER);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                return ret;
        /* sync tail before inserting cmds */
        smp_mb();
@@ -672,7 +672,7 @@ static int acpi_aml_write_user(const char __user *buf, int len)
        crc->head = (crc->head + n) & (ACPI_AML_BUF_SIZE - 1);
        ret = n;
 out:
-       acpi_aml_unlock_fifo(ACPI_AML_IN_USER, !IS_ERR_VALUE(ret));
+       acpi_aml_unlock_fifo(ACPI_AML_IN_USER, !ret);
        return n;
 }
 
@@ -704,7 +704,7 @@ again:
                                        goto again;
                        }
                }
-               if (IS_ERR_VALUE(ret)) {
+               if (ret < 0) {
                        if (!acpi_aml_running())
                                ret = 0;
                        break;
index 8638d575b2b99baef3d9a429e99fbc5287b4f1e1..aafb8cc03523212dee4d8d3fe66434af2406ae76 100644 (file)
@@ -197,7 +197,7 @@ static void highbank_set_em_messages(struct device *dev,
 
        for (i = 0; i < SGPIO_PINS; i++) {
                err = of_get_named_gpio(np, "calxeda,sgpio-gpio", i);
-               if (IS_ERR_VALUE(err))
+               if (err < 0)
                        return;
 
                pdata->sgpio_gpio[i] = err;
index b8551813ec4363908b19e405d166ee445719a0fe..456cf586d2c2b86a23d74680787190ac44048989 100644 (file)
@@ -1221,7 +1221,7 @@ static int tegra210_pll_fixed_mdiv_cfg(struct clk_hw *hw,
                p = rate >= params->vco_min ? 1 : -EINVAL;
        }
 
-       if (IS_ERR_VALUE(p))
+       if (p < 0)
                return -EINVAL;
 
        cfg->m = tegra_pll_get_fixed_mdiv(hw, input_rate);
index cead9bec4843a18e0d564e4b5d3522d0681cd778..376e63ca94e840e5334ae4d803dc9a173a69ab15 100644 (file)
@@ -54,7 +54,7 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index)
 
        freq = new_freq * 1000;
        ret = clk_round_rate(policy->clk, freq);
-       if (IS_ERR_VALUE(ret)) {
+       if (ret < 0) {
                dev_warn(mpu_dev,
                         "CPUfreq: Cannot find matching frequency for %lu\n",
                         freq);
index 44d30b45f3cc35a44ee692bc6b48706e819b760c..5ad5f3009ae013407b80c88f23c7eaa769fcc095 100644 (file)
@@ -402,7 +402,7 @@ int caam_get_era(void)
        ret = of_property_read_u32(caam_node, "fsl,sec-era", &prop);
        of_node_put(caam_node);
 
-       return IS_ERR_VALUE(ret) ? -ENOTSUPP : prop;
+       return ret ? -ENOTSUPP : prop;
 }
 EXPORT_SYMBOL(caam_get_era);
 
index e0df233dde929b4fc5390104ed9b3227d3bd663e..57aa227bfadb3eae97cb348372cacdf6eafc4586 100644 (file)
@@ -461,25 +461,25 @@ generate_ndma_promise(struct dma_chan *chan, dma_addr_t src, dma_addr_t dest,
 
        /* Source burst */
        ret = convert_burst(sconfig->src_maxburst);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                goto fail;
        promise->cfg |= SUN4I_DMA_CFG_SRC_BURST_LENGTH(ret);
 
        /* Destination burst */
        ret = convert_burst(sconfig->dst_maxburst);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                goto fail;
        promise->cfg |= SUN4I_DMA_CFG_DST_BURST_LENGTH(ret);
 
        /* Source bus width */
        ret = convert_buswidth(sconfig->src_addr_width);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                goto fail;
        promise->cfg |= SUN4I_DMA_CFG_SRC_DATA_WIDTH(ret);
 
        /* Destination bus width */
        ret = convert_buswidth(sconfig->dst_addr_width);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                goto fail;
        promise->cfg |= SUN4I_DMA_CFG_DST_DATA_WIDTH(ret);
 
@@ -518,25 +518,25 @@ generate_ddma_promise(struct dma_chan *chan, dma_addr_t src, dma_addr_t dest,
 
        /* Source burst */
        ret = convert_burst(sconfig->src_maxburst);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                goto fail;
        promise->cfg |= SUN4I_DMA_CFG_SRC_BURST_LENGTH(ret);
 
        /* Destination burst */
        ret = convert_burst(sconfig->dst_maxburst);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                goto fail;
        promise->cfg |= SUN4I_DMA_CFG_DST_BURST_LENGTH(ret);
 
        /* Source bus width */
        ret = convert_buswidth(sconfig->src_addr_width);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                goto fail;
        promise->cfg |= SUN4I_DMA_CFG_SRC_DATA_WIDTH(ret);
 
        /* Destination bus width */
        ret = convert_buswidth(sconfig->dst_addr_width);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                goto fail;
        promise->cfg |= SUN4I_DMA_CFG_DST_DATA_WIDTH(ret);
 
index 08897dc1191555f56c9dd108a9863fe1f5394f32..1a33a19d95b98bd01744a3d2200db212f1ab60c7 100644 (file)
@@ -393,7 +393,7 @@ static int xlp_gpio_probe(struct platform_device *pdev)
                irq_base = irq_alloc_descs(-1, 0, gc->ngpio, 0);
        else
                irq_base = irq_alloc_descs(-1, XLP_GPIO_IRQ_BASE, gc->ngpio, 0);
-       if (IS_ERR_VALUE(irq_base)) {
+       if (irq_base < 0) {
                dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n");
                return irq_base;
        }
index 32c7986b63ab30e7f8b20036d98dd28e83d9e17c..6bf4ce466d20fc194e968098bf76cca1efa77d84 100644 (file)
@@ -437,7 +437,7 @@ static int vtg_probe(struct platform_device *pdev)
                        return -EPROBE_DEFER;
        } else {
                vtg->irq = platform_get_irq(pdev, 0);
-               if (IS_ERR_VALUE(vtg->irq)) {
+               if (vtg->irq < 0) {
                        DRM_ERROR("Failed to get VTG interrupt\n");
                        return vtg->irq;
                }
@@ -447,7 +447,7 @@ static int vtg_probe(struct platform_device *pdev)
                ret = devm_request_threaded_irq(dev, vtg->irq, vtg_irq,
                                vtg_irq_thread, IRQF_ONESHOT,
                                dev_name(dev), vtg);
-               if (IS_ERR_VALUE(ret)) {
+               if (ret < 0) {
                        DRM_ERROR("Failed to register VTG interrupt\n");
                        return ret;
                }
index 7716f42f8aab3449105bd070189d28e287aaa420..6b8c5b3bf588b01b56a8a398f0f61918507086c3 100644 (file)
@@ -342,7 +342,7 @@ static int tfp410_probe(struct platform_device *pdev)
 
        tfp410_mod->gpio = of_get_named_gpio_flags(node, "powerdn-gpio",
                        0, NULL);
-       if (IS_ERR_VALUE(tfp410_mod->gpio)) {
+       if (tfp410_mod->gpio < 0) {
                dev_warn(&pdev->dev, "No power down GPIO\n");
        } else {
                ret = gpio_request(tfp410_mod->gpio, "DVI_PDn");
index 498b37e39058a6c212ff581e54c676465c826ec0..e1e31e9e67cd96bdb17297ec66fb1ad8415a0ebd 100644 (file)
@@ -85,7 +85,7 @@ static int _host1x_intr_init_host_sync(struct host1x *host, u32 cpm,
        err = devm_request_irq(host->dev, host->intr_syncpt_irq,
                               syncpt_thresh_isr, IRQF_SHARED,
                               "host1x_syncpt", host);
-       if (IS_ERR_VALUE(err)) {
+       if (err < 0) {
                WARN_ON(1);
                return err;
        }
index ebab33e77d6729d5f3d2450d42761355f7cd29b8..94b68213c50dae945b9c0789afe8b6465dfd5411 100644 (file)
@@ -1477,7 +1477,7 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain,
        struct arm_smmu_s1_cfg *cfg = &smmu_domain->s1_cfg;
 
        asid = arm_smmu_bitmap_alloc(smmu->asid_map, smmu->asid_bits);
-       if (IS_ERR_VALUE(asid))
+       if (asid < 0)
                return asid;
 
        cfg->cdptr = dmam_alloc_coherent(smmu->dev, CTXDESC_CD_DWORDS << 3,
@@ -1508,7 +1508,7 @@ static int arm_smmu_domain_finalise_s2(struct arm_smmu_domain *smmu_domain,
        struct arm_smmu_s2_cfg *cfg = &smmu_domain->s2_cfg;
 
        vmid = arm_smmu_bitmap_alloc(smmu->vmid_map, smmu->vmid_bits);
-       if (IS_ERR_VALUE(vmid))
+       if (vmid < 0)
                return vmid;
 
        cfg->vmid       = (u16)vmid;
@@ -1569,7 +1569,7 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain)
        smmu_domain->pgtbl_ops = pgtbl_ops;
 
        ret = finalise_stage_fn(smmu_domain, &pgtbl_cfg);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                free_io_pgtable_ops(pgtbl_ops);
 
        return ret;
@@ -1642,7 +1642,7 @@ static void arm_smmu_detach_dev(struct device *dev)
        struct arm_smmu_group *smmu_group = arm_smmu_group_get(dev);
 
        smmu_group->ste.bypass = true;
-       if (IS_ERR_VALUE(arm_smmu_install_ste_for_group(smmu_group)))
+       if (arm_smmu_install_ste_for_group(smmu_group) < 0)
                dev_warn(dev, "failed to install bypass STE\n");
 
        smmu_group->domain = NULL;
@@ -1694,7 +1694,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
        smmu_group->ste.bypass  = domain->type == IOMMU_DOMAIN_DMA;
 
        ret = arm_smmu_install_ste_for_group(smmu_group);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                smmu_group->domain = NULL;
 
 out_unlock:
@@ -2235,7 +2235,7 @@ static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu)
                                                arm_smmu_evtq_handler,
                                                arm_smmu_evtq_thread,
                                                0, "arm-smmu-v3-evtq", smmu);
-               if (IS_ERR_VALUE(ret))
+               if (ret < 0)
                        dev_warn(smmu->dev, "failed to enable evtq irq\n");
        }
 
@@ -2244,7 +2244,7 @@ static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu)
                ret = devm_request_irq(smmu->dev, irq,
                                       arm_smmu_cmdq_sync_handler, 0,
                                       "arm-smmu-v3-cmdq-sync", smmu);
-               if (IS_ERR_VALUE(ret))
+               if (ret < 0)
                        dev_warn(smmu->dev, "failed to enable cmdq-sync irq\n");
        }
 
@@ -2252,7 +2252,7 @@ static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu)
        if (irq) {
                ret = devm_request_irq(smmu->dev, irq, arm_smmu_gerror_handler,
                                       0, "arm-smmu-v3-gerror", smmu);
-               if (IS_ERR_VALUE(ret))
+               if (ret < 0)
                        dev_warn(smmu->dev, "failed to enable gerror irq\n");
        }
 
@@ -2264,7 +2264,7 @@ static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu)
                                                        arm_smmu_priq_thread,
                                                        0, "arm-smmu-v3-priq",
                                                        smmu);
-                       if (IS_ERR_VALUE(ret))
+                       if (ret < 0)
                                dev_warn(smmu->dev,
                                         "failed to enable priq irq\n");
                        else
index e206ce7a4e4bdb7ed2fb1a7d60dd1ea90e15cb0c..9345a3fcb706dc00ce0e202ab87f2ddc64078fee 100644 (file)
@@ -950,7 +950,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
 
        ret = __arm_smmu_alloc_bitmap(smmu->context_map, start,
                                      smmu->num_context_banks);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                goto out_unlock;
 
        cfg->cbndx = ret;
@@ -989,7 +989,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
        irq = smmu->irqs[smmu->num_global_irqs + cfg->irptndx];
        ret = request_irq(irq, arm_smmu_context_fault, IRQF_SHARED,
                          "arm-smmu-context-fault", domain);
-       if (IS_ERR_VALUE(ret)) {
+       if (ret < 0) {
                dev_err(smmu->dev, "failed to request context IRQ %d (%u)\n",
                        cfg->irptndx, irq);
                cfg->irptndx = INVALID_IRPTNDX;
@@ -1099,7 +1099,7 @@ static int arm_smmu_master_configure_smrs(struct arm_smmu_device *smmu,
        for (i = 0; i < cfg->num_streamids; ++i) {
                int idx = __arm_smmu_alloc_bitmap(smmu->smr_map, 0,
                                                  smmu->num_mapping_groups);
-               if (IS_ERR_VALUE(idx)) {
+               if (idx < 0) {
                        dev_err(smmu->dev, "failed to allocate free SMR\n");
                        goto err_free_smrs;
                }
@@ -1233,7 +1233,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
 
        /* Ensure that the domain is finalised */
        ret = arm_smmu_init_domain_context(domain, smmu);
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                return ret;
 
        /*
index eb5eb0cd414d21a78e6bbc59704c809287dffdd0..2223b3f15d6809b11dec6e0e69dc379e4dbb8093 100644 (file)
@@ -182,7 +182,7 @@ static int __init _clps711x_intc_init(struct device_node *np,
        writel_relaxed(0, clps711x_intc->intmr[2]);
 
        err = irq_alloc_descs(-1, 0, ARRAY_SIZE(clps711x_irqs), numa_node_id());
-       if (IS_ERR_VALUE(err))
+       if (err < 0)
                goto out_iounmap;
 
        clps711x_intc->ops.map = clps711x_intc_irq_map;
index b4e647179346611a5a296a373a0aacdabf9fc9b0..fbc4ae2afd294934f8a1bc8321b8c29c2f73d1ed 100644 (file)
@@ -1123,7 +1123,7 @@ static int __init __gic_init_bases(struct gic_chip_data *gic, int irq_start,
 
                irq_base = irq_alloc_descs(irq_start, 16, gic_irqs,
                                           numa_node_id());
-               if (IS_ERR_VALUE(irq_base)) {
+               if (irq_base < 0) {
                        WARN(1, "Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n",
                             irq_start);
                        irq_base = irq_start;
index 9688d2e2a6364d2accbe77f323dd3b9f1d735dfa..9e25d8ce08e5b48f91b7dccc6c44e2eedea8151f 100644 (file)
@@ -402,7 +402,7 @@ hip04_of_init(struct device_node *node, struct device_node *parent)
        nr_irqs -= hwirq_base; /* calculate # of irqs to allocate */
 
        irq_base = irq_alloc_descs(-1, hwirq_base, nr_irqs, numa_node_id());
-       if (IS_ERR_VALUE(irq_base)) {
+       if (irq_base < 0) {
                pr_err("failed to allocate IRQ numbers\n");
                return -EINVAL;
        }
index 1ccd2abed65f5348d0beaa114a2d1326c8cc1b67..1518ba31a80c99ba67d11ce8c83aa8988486cbd3 100644 (file)
@@ -232,7 +232,7 @@ static int __init shirq_init(struct spear_shirq **shirq_blocks, int block_nr,
                nr_irqs += shirq_blocks[i]->nr_irqs;
 
        virq_base = irq_alloc_descs(-1, 0, nr_irqs, 0);
-       if (IS_ERR_VALUE(virq_base)) {
+       if (virq_base < 0) {
                pr_err("%s: irq desc alloc failed\n", __func__);
                goto err_unmap;
        }
index 9e1731c565e7eb2e6a7b57f8be4a172b4da2b094..e191e295c95116e311fc226f64dc850b6a4ba196 100644 (file)
@@ -95,7 +95,7 @@ static int adp1653_get_fault(struct adp1653_flash *flash)
        int rval;
 
        fault = i2c_smbus_read_byte_data(client, ADP1653_REG_FAULT);
-       if (IS_ERR_VALUE(fault))
+       if (fault < 0)
                return fault;
 
        flash->fault |= fault;
@@ -105,13 +105,13 @@ static int adp1653_get_fault(struct adp1653_flash *flash)
 
        /* Clear faults. */
        rval = i2c_smbus_write_byte_data(client, ADP1653_REG_OUT_SEL, 0);
-       if (IS_ERR_VALUE(rval))
+       if (rval < 0)
                return rval;
 
        flash->led_mode->val = V4L2_FLASH_LED_MODE_NONE;
 
        rval = adp1653_update_hw(flash);
-       if (IS_ERR_VALUE(rval))
+       if (rval)
                return rval;
 
        return flash->fault;
@@ -158,7 +158,7 @@ static int adp1653_get_ctrl(struct v4l2_ctrl *ctrl)
        int rval;
 
        rval = adp1653_get_fault(flash);
-       if (IS_ERR_VALUE(rval))
+       if (rval)
                return rval;
 
        ctrl->cur.val = 0;
@@ -184,7 +184,7 @@ static int adp1653_set_ctrl(struct v4l2_ctrl *ctrl)
        int rval;
 
        rval = adp1653_get_fault(flash);
-       if (IS_ERR_VALUE(rval))
+       if (rval)
                return rval;
        if ((rval & (ADP1653_REG_FAULT_FLT_SCP |
                     ADP1653_REG_FAULT_FLT_OT |
index 5ef67774971dc34225c9079533287a33c6e1d659..8a5d19469ddc2d126602e0f9f47f4152a9e89309 100644 (file)
@@ -146,7 +146,7 @@ int mxr_power_get(struct mxr_device *mdev)
 
        /* returning 1 means that power is already enabled,
         * so zero success be returned */
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                return ret;
        return 0;
 }
index 40e51b0baa46b57ec10a2ec0893ca0d6d1c82884..b46c0cfc27d9586c946474853c1b3dd8eaaf1e92 100644 (file)
@@ -696,7 +696,7 @@ int twl4030_init_irq(struct device *dev, int irq_num)
        nr_irqs = TWL4030_PWR_NR_IRQS + TWL4030_CORE_NR_IRQS;
 
        irq_base = irq_alloc_descs(-1, 0, nr_irqs, 0);
-       if (IS_ERR_VALUE(irq_base)) {
+       if (irq_base < 0) {
                dev_err(dev, "Fail to allocate IRQ descs\n");
                return irq_base;
        }
index b81b08f81325721037362213997618b7ebfc1e10..c984321d1881d90ea8b7633abd0c55a605d78502 100644 (file)
@@ -1276,7 +1276,7 @@ static int mmc_select_hs200(struct mmc_card *card)
         * switch to HS200 mode if bus width is set successfully.
         */
        err = mmc_select_bus_width(card);
-       if (!IS_ERR_VALUE(err)) {
+       if (!err) {
                val = EXT_CSD_TIMING_HS200 |
                      card->drive_strength << EXT_CSD_DRV_STR_SHIFT;
                err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
@@ -1583,7 +1583,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
        } else if (mmc_card_hs(card)) {
                /* Select the desired bus width optionally */
                err = mmc_select_bus_width(card);
-               if (!IS_ERR_VALUE(err)) {
+               if (!err) {
                        err = mmc_select_hs_ddr(card);
                        if (err)
                                goto free_card;
index 829a6eebcdcee551ee23f9679f2fb4c8bac46b13..2cc6123b1df98a0c188d3a7626fa8f72424e4f22 100644 (file)
@@ -1431,7 +1431,7 @@ static int dw_mci_get_ro(struct mmc_host *mmc)
        int gpio_ro = mmc_gpio_get_ro(mmc);
 
        /* Use platform get_ro function, else try on board write protect */
-       if (!IS_ERR_VALUE(gpio_ro))
+       if (gpio_ro >= 0)
                read_only = gpio_ro;
        else
                read_only =
@@ -1454,7 +1454,7 @@ static int dw_mci_get_cd(struct mmc_host *mmc)
        if ((mmc->caps & MMC_CAP_NEEDS_POLL) ||
            (mmc->caps & MMC_CAP_NONREMOVABLE))
                present = 1;
-       else if (!IS_ERR_VALUE(gpio_cd))
+       else if (gpio_cd >= 0)
                present = gpio_cd;
        else
                present = (mci_readl(slot->host, CDETECT) & (1 << slot->id))
@@ -2927,7 +2927,7 @@ static void dw_mci_enable_cd(struct dw_mci *host)
                if (slot->mmc->caps & MMC_CAP_NEEDS_POLL)
                        return;
 
-               if (IS_ERR_VALUE(mmc_gpio_get_cd(slot->mmc)))
+               if (mmc_gpio_get_cd(slot->mmc) < 0)
                        break;
        }
        if (i == host->num_slots)
index 2d300d87cda8b867075daaa06754bc29b2438214..9d3ae1f4bd3cc799b6716355f19dbbbec2ceeda4 100644 (file)
@@ -1011,7 +1011,7 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
        if (ret)
                return ret;
 
-       if (!IS_ERR_VALUE(mmc_gpio_get_cd(host->mmc)))
+       if (mmc_gpio_get_cd(host->mmc) >= 0)
                host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
 
        return 0;
index 25f779e09d8e81e12b038157188ae446bf69eebe..d4cef713d246451c9187af6f314f2183db2a9353 100644 (file)
@@ -289,7 +289,7 @@ static int sdhci_at91_probe(struct platform_device *pdev)
         * to enable polling via device tree with broken-cd property.
         */
        if (!(host->mmc->caps & MMC_CAP_NONREMOVABLE) &&
-           IS_ERR_VALUE(mmc_gpio_get_cd(host->mmc))) {
+           mmc_gpio_get_cd(host->mmc) < 0) {
                host->mmc->caps |= MMC_CAP_NEEDS_POLL;
                host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
        }
index e010ea4eb6f5672ecc4d1f7e8cfac98856e6b243..0e3d7c056cb135dfc1408dd30950f4327ccd84ba 100644 (file)
@@ -1624,7 +1624,7 @@ static int sdhci_get_cd(struct mmc_host *mmc)
         * Try slot gpio detect, if defined it take precedence
         * over build in controller functionality
         */
-       if (!IS_ERR_VALUE(gpio_cd))
+       if (gpio_cd >= 0)
                return !!gpio_cd;
 
        /* If polling, assume that the card is always present. */
@@ -3077,7 +3077,7 @@ int sdhci_add_host(struct sdhci_host *host)
 
        if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) &&
            !(mmc->caps & MMC_CAP_NONREMOVABLE) &&
-           IS_ERR_VALUE(mmc_gpio_get_cd(host->mmc)))
+           mmc_gpio_get_cd(host->mmc) < 0)
                mmc->caps |= MMC_CAP_NEEDS_POLL;
 
        /* If there are external regulators, get them */
index bcb9dccada4dcbb898e3660d6dd1cf11ec588423..1de2e1e51c2be6c2259f8d6dca61b92a1338597e 100644 (file)
@@ -615,7 +615,7 @@ struct fman {
        struct fman_cfg *cfg;
        struct muram_info *muram;
        /* cam section in muram */
-       int cam_offset;
+       unsigned long cam_offset;
        size_t cam_size;
        /* Fifo in MURAM */
        int fifo_offset;
index 4eb0e9ac7182479724fb44e1997c4560e79775f9..47394c45b6e8e4598827d9b1979e5a7116b612d0 100644 (file)
@@ -129,7 +129,7 @@ unsigned long fman_muram_offset_to_vbase(struct muram_info *muram,
  *
  * Return: address of the allocated memory; NULL otherwise.
  */
-int fman_muram_alloc(struct muram_info *muram, size_t size)
+unsigned long fman_muram_alloc(struct muram_info *muram, size_t size)
 {
        unsigned long vaddr;
 
@@ -150,7 +150,7 @@ int fman_muram_alloc(struct muram_info *muram, size_t size)
  *
  * Free an allocated memory from FM-MURAM partition.
  */
-void fman_muram_free_mem(struct muram_info *muram, u32 offset, size_t size)
+void fman_muram_free_mem(struct muram_info *muram, unsigned long offset, size_t size)
 {
        unsigned long addr = fman_muram_offset_to_vbase(muram, offset);
 
index dbf0af9e5bb584d6b5934183cd68da04670606d2..889649ad89316587eeb9dc636e4d6d6756ea6efb 100644 (file)
@@ -44,8 +44,8 @@ struct muram_info *fman_muram_init(phys_addr_t base, size_t size);
 unsigned long fman_muram_offset_to_vbase(struct muram_info *muram,
                                         unsigned long offset);
 
-int fman_muram_alloc(struct muram_info *muram, size_t size);
+unsigned long fman_muram_alloc(struct muram_info *muram, size_t size);
 
-void fman_muram_free_mem(struct muram_info *muram, u32 offset, size_t size);
+void fman_muram_free_mem(struct muram_info *muram, unsigned long offset, size_t size);
 
 #endif /* __FM_MURAM_EXT */
index 020ac1a4b40834131d6355a7464b73129fd93ad1..cea9443c22a6b6983e5697dc5a027dcf867cd033 100644 (file)
@@ -382,7 +382,7 @@ static int wlcore_probe_of(struct spi_device *spi, struct wl12xx_spi_glue *glue,
 
        ret = of_property_read_u32(dt_node, "ref-clock-frequency",
                                   &pdev_data->ref_clock_freq);
-       if (IS_ERR_VALUE(ret)) {
+       if (ret) {
                dev_err(glue->dev,
                        "can't get reference clock frequency (%d)\n", ret);
                return ret;
@@ -425,7 +425,7 @@ static int wl1271_probe(struct spi_device *spi)
        }
 
        ret = wlcore_probe_of(spi, glue, &pdev_data);
-       if (IS_ERR_VALUE(ret)) {
+       if (ret) {
                dev_err(glue->dev,
                        "can't get device tree parameters (%d)\n", ret);
                return ret;
index bb4ea123547f169b02044d6cc15f867b188f6f5c..965911d9b36a77af3867ff6361169f977e71392b 100644 (file)
@@ -113,7 +113,7 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj,
 
        rc = nvmem_reg_read(nvmem, pos, buf, count);
 
-       if (IS_ERR_VALUE(rc))
+       if (rc)
                return rc;
 
        return count;
@@ -147,7 +147,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
 
        rc = nvmem_reg_write(nvmem, pos, buf, count);
 
-       if (IS_ERR_VALUE(rc))
+       if (rc)
                return rc;
 
        return count;
@@ -366,7 +366,7 @@ static int nvmem_add_cells(struct nvmem_device *nvmem,
                }
 
                rval = nvmem_cell_info_to_nvmem_cell(nvmem, &info[i], cells[i]);
-               if (IS_ERR_VALUE(rval)) {
+               if (rval) {
                        kfree(cells[i]);
                        goto err;
                }
@@ -963,7 +963,7 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem,
 
        rc = nvmem_reg_read(nvmem, cell->offset, buf, cell->bytes);
 
-       if (IS_ERR_VALUE(rc))
+       if (rc)
                return rc;
 
        /* shift bits in-place */
@@ -998,7 +998,7 @@ void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len)
                return ERR_PTR(-ENOMEM);
 
        rc = __nvmem_cell_read(nvmem, cell, buf, len);
-       if (IS_ERR_VALUE(rc)) {
+       if (rc) {
                kfree(buf);
                return ERR_PTR(rc);
        }
@@ -1083,7 +1083,7 @@ int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len)
        if (cell->bit_offset || cell->nbits)
                kfree(buf);
 
-       if (IS_ERR_VALUE(rc))
+       if (rc)
                return rc;
 
        return len;
@@ -1111,11 +1111,11 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
                return -EINVAL;
 
        rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell);
-       if (IS_ERR_VALUE(rc))
+       if (rc)
                return rc;
 
        rc = __nvmem_cell_read(nvmem, &cell, buf, &len);
-       if (IS_ERR_VALUE(rc))
+       if (rc)
                return rc;
 
        return len;
@@ -1141,7 +1141,7 @@ int nvmem_device_cell_write(struct nvmem_device *nvmem,
                return -EINVAL;
 
        rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell);
-       if (IS_ERR_VALUE(rc))
+       if (rc)
                return rc;
 
        return nvmem_cell_write(&cell, buf, cell.bytes);
@@ -1170,7 +1170,7 @@ int nvmem_device_read(struct nvmem_device *nvmem,
 
        rc = nvmem_reg_read(nvmem, offset, buf, bytes);
 
-       if (IS_ERR_VALUE(rc))
+       if (rc)
                return rc;
 
        return bytes;
@@ -1198,7 +1198,7 @@ int nvmem_device_write(struct nvmem_device *nvmem,
 
        rc = nvmem_reg_write(nvmem, offset, buf, bytes);
 
-       if (IS_ERR_VALUE(rc))
+       if (rc)
                return rc;
 
 
index a2aa655f56c4a8175c56d12845607dcb84786c14..1b7331e40d795e1ec5482d6a82871bd5ce050b60 100644 (file)
@@ -2360,7 +2360,7 @@ static int pl011_probe_dt_alias(int index, struct device *dev)
                return ret;
 
        ret = of_alias_get_id(np, "serial");
-       if (IS_ERR_VALUE(ret)) {
+       if (ret < 0) {
                seen_dev_without_alias = true;
                ret = index;
        } else {
index 18971063f95fa17f4929e4cbc7014fff65172148..699447aa8b4344ecbfc721fae03154ea6480df6c 100644 (file)
@@ -654,7 +654,7 @@ static int sprd_probe_dt_alias(int index, struct device *dev)
                return ret;
 
        ret = of_alias_get_id(np, "serial");
-       if (IS_ERR_VALUE(ret))
+       if (ret < 0)
                ret = index;
        else if (ret >= ARRAY_SIZE(sprd_port) || sprd_port[ret] != NULL) {
                dev_warn(dev, "requested serial port %d not available.\n", ret);
index d8d583d32a37bda2867e4a0af6627c8aa1cfccb6..c229b1a0d13b350bce029d2fcd78ef60bd4c65b1 100644 (file)
@@ -713,7 +713,7 @@ static int da8xx_fb_config_clk_divider(struct da8xx_fb_par *par,
 
        if (par->lcdc_clk_rate != lcdc_clk_rate) {
                ret = clk_set_rate(par->lcdc_clk, lcdc_clk_rate);
-               if (IS_ERR_VALUE(ret)) {
+               if (ret) {
                        dev_err(par->dev,
                                "unable to set clock rate at %u\n",
                                lcdc_clk_rate);
@@ -784,7 +784,7 @@ static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg,
        int ret = 0;
 
        ret = da8xx_fb_calc_config_clk_divider(par, panel);
-       if (IS_ERR_VALUE(ret)) {
+       if (ret) {
                dev_err(par->dev, "unable to configure clock\n");
                return ret;
        }
index 65de439bdc4f5402bc513eae3e66c09ce685965f..14d506efd1aaabebd33d4e08a3891e001da2b80f 100644 (file)
@@ -643,10 +643,6 @@ ssize_t afs_file_write(struct kiocb *iocb, struct iov_iter *from)
                return 0;
 
        result = generic_file_write_iter(iocb, from);
-       if (IS_ERR_VALUE(result)) {
-               _leave(" = %zd", result);
-               return result;
-       }
 
        _leave(" = %zd", result);
        return result;
index f723cd3a455cbde47e5be8cabb798e0725eefb8e..caf9e39bb82b7fbd0b2387b6dea5332cdc5699de 100644 (file)
@@ -337,7 +337,7 @@ calc_reloc(unsigned long r, struct lib_info *p, int curid, int internalp)
                                        "(%d != %d)", (unsigned) r, curid, id);
                        goto failed;
                } else if ( ! p->lib_list[id].loaded &&
-                               IS_ERR_VALUE(load_flat_shared_library(id, p))) {
+                               load_flat_shared_library(id, p) < 0) {
                        printk("BINFMT_FLAT: failed to load library %d", id);
                        goto failed;
                }
@@ -837,7 +837,7 @@ static int load_flat_shared_library(int id, struct lib_info *libs)
 
        res = prepare_binprm(&bprm);
 
-       if (!IS_ERR_VALUE(res))
+       if (!res)
                res = load_flat_file(&bprm, libs, id, NULL);
 
        abort_creds(bprm.cred);
@@ -883,7 +883,7 @@ static int load_flat_binary(struct linux_binprm * bprm)
        stack_len += FLAT_STACK_ALIGN - 1;  /* reserve for upcoming alignment */
        
        res = load_flat_file(bprm, &libinfo, 0, &stack_len);
-       if (IS_ERR_VALUE(res))
+       if (res < 0)
                return res;
        
        /* Update data segment pointers for all libraries */
index 4a01f30e99954616811a932dc1f54644f0e0f68d..271d93905bac6eed449f6d968324497f22a38301 100644 (file)
@@ -783,12 +783,15 @@ static int get_leaf_nr(struct gfs2_inode *dip, u32 index,
                       u64 *leaf_out)
 {
        __be64 *hash;
+       int error;
 
        hash = gfs2_dir_get_hash_table(dip);
-       if (IS_ERR(hash))
-               return PTR_ERR(hash);
-       *leaf_out = be64_to_cpu(*(hash + index));
-       return 0;
+       error = PTR_ERR_OR_ZERO(hash);
+
+       if (!error)
+               *leaf_out = be64_to_cpu(*(hash + index));
+
+       return error;
 }
 
 static int get_first_leaf(struct gfs2_inode *dip, u32 index,
@@ -798,7 +801,7 @@ static int get_first_leaf(struct gfs2_inode *dip, u32 index,
        int error;
 
        error = get_leaf_nr(dip, index, &leaf_no);
-       if (!IS_ERR_VALUE(error))
+       if (!error)
                error = get_leaf(dip, leaf_no, bh_out);
 
        return error;
@@ -1014,7 +1017,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
 
        index = name->hash >> (32 - dip->i_depth);
        error = get_leaf_nr(dip, index, &leaf_no);
-       if (IS_ERR_VALUE(error))
+       if (error)
                return error;
 
        /*  Get the old leaf block  */
index 4d73a834c7e6590e29eb0d1a71645caf6c274016..f66162f2359bfb2e85777ce4c5faed637a15db60 100644 (file)
@@ -311,7 +311,7 @@ struct pid *alloc_pid(struct pid_namespace *ns)
        pid->level = ns->level;
        for (i = ns->level; i >= 0; i--) {
                nr = alloc_pidmap(tmp);
-               if (IS_ERR_VALUE(nr)) {
+               if (nr < 0) {
                        retval = nr;
                        goto out_free;
                }
index ea79ee9a73489f43a88e57c2eb529fc11d894e5f..3fc94a49ccd53c2dba661acb4d6b0433de9c393b 100644 (file)
@@ -518,10 +518,10 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
                if (err)
                        goto out_err;
 
-               if (p9_is_proto_dotu(c))
+               if (p9_is_proto_dotu(c) && ecode < 512)
                        err = -ecode;
 
-               if (!err || !IS_ERR_VALUE(err)) {
+               if (!err) {
                        err = p9_errstr2errno(ename, strlen(ename));
 
                        p9_debug(P9_DEBUG_9P, "<<< RERROR (%d) %s\n",
@@ -605,10 +605,10 @@ static int p9_check_zc_errors(struct p9_client *c, struct p9_req_t *req,
                if (err)
                        goto out_err;
 
-               if (p9_is_proto_dotu(c))
+               if (p9_is_proto_dotu(c) && ecode < 512)
                        err = -ecode;
 
-               if (!err || !IS_ERR_VALUE(err)) {
+               if (!err) {
                        err = p9_errstr2errno(ename, strlen(ename));
 
                        p9_debug(P9_DEBUG_9P, "<<< RERROR (%d) %s\n",
index 6e8665430bd5efc22e06f6934a7133d1b62306ea..ddfe34434765ce8e40ae297ca98110d4fcb35f08 100644 (file)
@@ -491,7 +491,7 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime)
                        data->rdma_ch = v->alloc_dma_channel(drvdata,
                                                SNDRV_PCM_STREAM_PLAYBACK);
 
-               if (IS_ERR_VALUE(data->rdma_ch))
+               if (data->rdma_ch < 0)
                        return data->rdma_ch;
 
                drvdata->substream[data->rdma_ch] = psubstream;
@@ -518,7 +518,7 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime)
                        data->wrdma_ch = v->alloc_dma_channel(drvdata,
                                                SNDRV_PCM_STREAM_CAPTURE);
 
-               if (IS_ERR_VALUE(data->wrdma_ch))
+               if (data->wrdma_ch < 0)
                        goto capture_alloc_err;
 
                drvdata->substream[data->wrdma_ch] = csubstream;