Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3879405rwd; Sat, 17 Jun 2023 04:00:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ64wTN8I35pH53Vy89Nu/TC3yDPgBYVdoeRwbMC5uooZ6cIqFATT6cQ6v/wP9Od533g0rum X-Received: by 2002:a05:6808:1413:b0:39d:f03e:71c8 with SMTP id w19-20020a056808141300b0039df03e71c8mr7423220oiv.53.1686999634542; Sat, 17 Jun 2023 04:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686999634; cv=none; d=google.com; s=arc-20160816; b=Td8ajzjO8CC727K/pjPGGErSQhWC9FywHiUnSRP9mAvNUjU6r9aEil0qVpH9kLIJf2 SO7z69wyxaH1SXcWQciuMJgFFr6kzL1SgDpqtK7dXF/J2rDKTwUmi+skaA7/RwBTuQdQ zK6vqJzb4qCTYS7sz2106a1kj1tklo2l1ZQ5OjYqCETi9vXBypoCRmXDQFsQ94z3PvbL 5ENvWwkhZ0tfFgjNJEFvyv9GJ+1pILCeBPQok63UqUL+A+iTFxshB/nQB1zs9TgSgI8B gINY5SJ3pBuX6R+xZRQ6+gzpeRwTITy4iI7++o2nOoFq0Pzsx9eT7kW3+YR3bbVmf1n8 Ncng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=dKDAfxkXlHVsJUzF+jDhXkw3h2hy4fQcOsDAMiH6vY4=; b=LXuujt0ZOyszQ8ZmBRXGRhirKCrYzDQpGd4rx+j5x4kns3KezxFHcOTax845hOOXn7 caihM/QMMO0VK78tjOZLY/FM4P7beSQIlmVHmokgXrOaKWHU7gIkTOMXtRBlveK9B/75 gsga8+pnj3tHYNhwaIm8hrnC0m+/zi15PuiUnR/G/bU6hzze4KUuGvk1LHL1GeVAyZgl 7FY1d3otTeB3PuuK8I3GM1ofYdTz96+7T36Gt2dOwv3cvw5cpEhUQHB0Z2UTsF+Kw3WS zThQ508eyBRjJS0PZZq0+cOZbza0cCcPWfRAbA3js49Ml8a0CQ6YAmYB9ONAfgrgL55c 0AFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="N/+2G7ro"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p1-20020a170902e74100b001b1bf4c8688si13628844plf.231.2023.06.17.04.00.12; Sat, 17 Jun 2023 04:00:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="N/+2G7ro"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234157AbjFQKpE (ORCPT + 99 others); Sat, 17 Jun 2023 06:45:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235296AbjFQKnZ (ORCPT ); Sat, 17 Jun 2023 06:43:25 -0400 Received: from smtp.smtpout.orange.fr (smtp-21.smtpout.orange.fr [80.12.242.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CE0A123 for ; Sat, 17 Jun 2023 03:43:23 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id ATOnqRvYtW2GfATOnqWHgB; Sat, 17 Jun 2023 12:43:21 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1686998601; bh=dKDAfxkXlHVsJUzF+jDhXkw3h2hy4fQcOsDAMiH6vY4=; h=From:To:Cc:Subject:Date; b=N/+2G7ro0cOieiYfSGRu4oOD4rzio+1S+cwLFwFObllOAg8gR9n3DI6lSql7Ys5yO bDXtmMNOuAnwGZLvBScxHFBcFKktnUhVoBqWBMyyVJ43QAWohlcMcEuz0E1nS7ajAI rbtw+vf3nqzq9Y8YAOTzCF3kFZlKtIASBcXAyNQEGtNysmwhHZcz8KyrfX8NbrOvmg /f0GsPsJPxW7DygrYPTAyZ+399BQdlioSgCEMqvAaZIBQB783lHDJaOrLgEHc4D8WA nygElOWOyjkpM5Mi6QzVPrRra6cZ2iSmDm95azheQieqVvlXHGqh0Uqyu1F4VsTEwj X5oa76s2Az5YA== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 17 Jun 2023 12:43:21 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Lee Jones , Maxime Coquelin , Alexandre Torgue , Linus Walleij Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH] mfd: stmpe: Fix a corner case in stmpe_probe() Date: Sat, 17 Jun 2023 12:43:16 +0200 Message-Id: <8de3aaf297931d655b9ad6aed548f4de8b85425a.1686998575.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In stmpe_probe(), if some regulator_enable() calls fail, probing continues and there is only a dev_warn(). So, if stmpe_probe() is called the regulator may not be enabled. It is cleaner to test it before calling regulator_disable() in the remove function. Fixes: 9c9e321455fb ("mfd: stmpe: add optional regulators") Signed-off-by: Christophe JAILLET --- drivers/mfd/stmpe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index a92301dfc712..9c3cf58457a7 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c @@ -1485,9 +1485,9 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum) void stmpe_remove(struct stmpe *stmpe) { - if (!IS_ERR(stmpe->vio)) + if (!IS_ERR(stmpe->vio) && regulator_is_enabled(stmpe->vio)) regulator_disable(stmpe->vio); - if (!IS_ERR(stmpe->vcc)) + if (!IS_ERR(stmpe->vcc) && regulator_is_enabled(stmpe->vcc)) regulator_disable(stmpe->vcc); __stmpe_disable(stmpe, STMPE_BLOCK_ADC); -- 2.34.1