Commit 287980e4 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Linus Torvalds

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