Commit 42a71ef97b7ac31ae8f929c36048fec5cd201a49
Committed by
Lee Jones
1 parent
2a3377ee2d
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
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>
Showing 1 changed file with 4 additions and 4 deletions Side-by-side Diff
drivers/mfd/menelaus.c
... | ... | @@ -1183,7 +1183,7 @@ |
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); |
1190 | 1190 | |
... | ... | @@ -1236,10 +1236,10 @@ |
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; |