Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6095226ybi; Wed, 29 May 2019 02:47:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXdL8zJbNMGGVWxTaJBDPXb8f0Bf5acwgej/pb+F0k0rq3RDxYEK4LrUypTSmL+M8eJFBB X-Received: by 2002:a63:561c:: with SMTP id k28mr26747457pgb.412.1559123265974; Wed, 29 May 2019 02:47:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559123265; cv=none; d=google.com; s=arc-20160816; b=QH+Cz9TH+F/8KBCDYY1L+e9/aKJJG6Ahsno0y573BWropPKd3IChHemJicg/afEEww jXt0Ng+YQ2+vAcHjXZsHh1KXpEabX0G1c1bf8+ZOIFjcPo3WzFeBdl3mebhmXJ1sQpr1 4grO+F6xi3i9oii7/IQ7Qj4w3TBVUho4kVyUjSSe8Bt/HZeicfh1ANM5oy/UMeQKQiOH sYDJpR5Bxo6fNs5TtyHJ6e39BYOHgS7XtsBRTcSuryxs7+4Nf4vQ/aUV+OSLj2CuK4qV 6Dy7tkekpYAVbJOpGaQ5yo3HX2CvxNZbAJcNJW1OjSdi8C5EEEU6npJr+YLDClNmGh3T ZKYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=B5DTYOqiAhd2Mk6K1y61itE9HPAtSYzIUN4mT0lvc9g=; b=zTG6DUSErXypJ5XLBxy3wbn+R3H9SCZDtBnoDBae9NEKIwOqxxBQPXL/d0hhw2W/ZL gKeXjEZBBZ7NZXUqouRQZRWYOmys6qy3yG2tGogXUywFp+ylhAaANNu6WrRrl6oyOHG0 f5yocA5pS6uIAQfS3+cE0EX7bZCsVqjv0wbPR75aQj5eY0B2JkODgT2L42vWYSgx/qsd lg/BtfHr1kdvWS87Q1g7LHxr5ijPcfN9pPrL87bOQAf2ZFKHXmX7J69onL9MZ6gA5dxw VO0cA57aCyFl0z2L7vbLzXZFMKdmkQbj7rTdSxbJTauGO8m9F7oKj/y6pf1Yged46AaX 7tHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3si6355235pjb.19.2019.05.29.02.47.29; Wed, 29 May 2019 02:47:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726254AbfE2JqL (ORCPT + 99 others); Wed, 29 May 2019 05:46:11 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:51466 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725874AbfE2JqK (ORCPT ); Wed, 29 May 2019 05:46:10 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4T9e2uY018012; Wed, 29 May 2019 04:46:07 -0500 Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail1.cirrus.com (mail1.cirrus.com [141.131.3.20]) by mx0a-001ae601.pphosted.com with ESMTP id 2sq340mmf2-1; Wed, 29 May 2019 04:46:07 -0500 Received: from EDIEX01.ad.cirrus.com (unknown [198.61.84.80]) by mail1.cirrus.com (Postfix) with ESMTP id 6756E611C8BD; Wed, 29 May 2019 04:46:06 -0500 (CDT) Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Wed, 29 May 2019 10:46:05 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Wed, 29 May 2019 10:46:05 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id BC5B044; Wed, 29 May 2019 10:46:05 +0100 (BST) From: Charles Keepax To: CC: , , Subject: [PATCH v2] extcon: arizona: Correct error handling on regmap_update_bits_check Date: Wed, 29 May 2019 10:46:05 +0100 Message-ID: <20190529094605.9838-1-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905290065 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ensure the case when regmap_update_bits_check fails and the change variable is not updated is handled correctly. Signed-off-by: Charles Keepax --- Changes since v1: - Print error message in driver remove Thanks, Charles drivers/extcon/extcon-arizona.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index 9327479c719c2..519e89aedd4a0 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -335,10 +335,12 @@ static void arizona_start_mic(struct arizona_extcon_info *info) arizona_extcon_pulse_micbias(info); - regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1, - ARIZONA_MICD_ENA, ARIZONA_MICD_ENA, - &change); - if (!change) { + ret = regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1, + ARIZONA_MICD_ENA, ARIZONA_MICD_ENA, + &change); + if (ret < 0) { + dev_err(arizona->dev, "Failed to enable micd: %d\n", ret); + } else if (!change) { regulator_disable(info->micvdd); pm_runtime_put_autosuspend(info->dev); } @@ -350,12 +352,14 @@ static void arizona_stop_mic(struct arizona_extcon_info *info) const char *widget = arizona_extcon_get_micbias(info); struct snd_soc_dapm_context *dapm = arizona->dapm; struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); - bool change; + bool change = false; int ret; - regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1, - ARIZONA_MICD_ENA, 0, - &change); + ret = regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1, + ARIZONA_MICD_ENA, 0, + &change); + if (ret < 0) + dev_err(arizona->dev, "Failed to disable micd: %d\n", ret); ret = snd_soc_component_disable_pin(component, widget); if (ret != 0) @@ -1727,12 +1731,15 @@ static int arizona_extcon_remove(struct platform_device *pdev) struct arizona *arizona = info->arizona; int jack_irq_rise, jack_irq_fall; bool change; + int ret; - regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1, - ARIZONA_MICD_ENA, 0, - &change); - - if (change) { + ret = regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1, + ARIZONA_MICD_ENA, 0, + &change); + if (ret < 0) { + dev_err(&pdev->dev, "Failed to disable micd on remove: %d\n", + ret); + } else if (change) { regulator_disable(info->micvdd); pm_runtime_put(info->dev); } -- 2.11.0