From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758348AbcHaJlY (ORCPT ); Wed, 31 Aug 2016 05:41:24 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:34524 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750708AbcHaJlX (ORCPT ); Wed, 31 Aug 2016 05:41:23 -0400 Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.wolfsonmicro.com From: Charles Keepax To: CC: , Subject: [PATCH v2] mfd: arizona: Add sensible return value to some error paths Date: Wed, 31 Aug 2016 10:41:30 +0100 Message-ID: <1472636490-8930-1-git-send-email-ckeepax@opensource.wolfsonmicro.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1608310124 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are some cases in arizona_dev_init, such as where we don't recognise the chip ID, in which we head to the error path without setting a sensible error code in ret. This would lead to the chip silently failing probe, as it would still return 0. Fix this up by adding appropriate sets of the return value. Whilst adding these update the existing paths that do return an error when the chip is not recognised to use ENODEV, which seems like a better fit. Signed-off-by: Charles Keepax --- Changes since v1: - Update return codes to use ENODEV rather than EINVAL. Thanks, Charles drivers/mfd/arizona-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index e4f97b3..cdbb8a2 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c @@ -1035,7 +1035,7 @@ int arizona_dev_init(struct arizona *arizona) default: dev_err(arizona->dev, "Unknown device type %d\n", arizona->type); - return -EINVAL; + return -ENODEV; } /* Mark DCVDD as external, LDO1 driver will clear if internal */ @@ -1121,6 +1121,7 @@ int arizona_dev_init(struct arizona *arizona) break; default: dev_err(arizona->dev, "Unknown device ID: %x\n", reg); + ret = -ENODEV; goto err_reset; } @@ -1280,12 +1281,14 @@ int arizona_dev_init(struct arizona *arizona) break; default: dev_err(arizona->dev, "Unknown device ID %x\n", reg); + ret = -ENODEV; goto err_reset; } if (!subdevs) { dev_err(arizona->dev, "No kernel support for device ID %x\n", reg); + ret = -ENODEV; goto err_reset; } -- 2.1.4