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

mfd: menelaus: Fix error return code

Convert a zero return value on error to a negative one, as returned
elsewhere in the function.

Additionally, converted 1 << 7 to BIT(7) at the suggestion of Lee Jones.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}

// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Julia Lawall and committed by
Lee Jones
42a71ef9 2a3377ee

+4 -4
+4 -4
drivers/mfd/menelaus.c
··· 1183 1183 const struct i2c_device_id *id) 1184 1184 { 1185 1185 struct menelaus_chip *menelaus; 1186 - int rev = 0, val; 1186 + int rev = 0; 1187 1187 int err = 0; 1188 1188 struct menelaus_platform_data *menelaus_pdata = 1189 1189 dev_get_platdata(&client->dev); ··· 1236 1236 1237 1237 pr_info("Menelaus rev %d.%d\n", rev >> 4, rev & 0x0f); 1238 1238 1239 - val = menelaus_read_reg(MENELAUS_VCORE_CTRL1); 1240 - if (val < 0) 1239 + err = menelaus_read_reg(MENELAUS_VCORE_CTRL1); 1240 + if (err < 0) 1241 1241 goto fail; 1242 - if (val & (1 << 7)) 1242 + if (err & BIT(7)) 1243 1243 menelaus->vcore_hw_mode = 1; 1244 1244 else 1245 1245 menelaus->vcore_hw_mode = 0;