From patchwork Sat Jun 17 09:57:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13283489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ADF06EB64DA for ; Sat, 17 Jun 2023 09:57:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=P+/NdTCRG9iuSgF/9MytCHl6ncymbaJcrbwcZCCDBuc=; b=kUiw6LzxqM/7ZW P3iVrRaxoU2BciI+Hx4wlfx/LMXYP/wXqVsHHRv3zzdrbTFDJ2aOo5o7qmroBJcds1yc9lqNqGH1u tBLdaJrl8slr0dhsvvmNhYswKNNoS9JNkbvwnN4dMVksaBp2zxdpYq9TZ+xMRo0dgZZ8xnuEQsdz4 5L+EnO/wWXdepwnQSDSUKxnJ+RZ6jPMdZdA0g+Rmbxj1jS2VsH3l98DFoxM/xhHW8KnqzzWw/Qq01 hmajH8ViPZkH6LXxZIvVQNJ5nzGEnCX4uJv820ieV8mByolLFMC5Mlp/FOdq5CTah9lZbpgw5Eql2 IMqu5TdIil/UdK0Wkx4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qASgO-003Cng-2D; Sat, 17 Jun 2023 09:57:24 +0000 Received: from smtp-26.smtpout.orange.fr ([80.12.242.26] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qASgJ-003Cme-0J for linux-arm-kernel@lists.infradead.org; Sat, 17 Jun 2023 09:57:21 +0000 Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id ASgAqUsC7EYhqASgBqk5h0; Sat, 17 Jun 2023 11:57:15 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1686995835; bh=haiC7wDeOkzD6Zrppzqp1H4WJr8jevDuZHEsdYQ8KDc=; h=From:To:Cc:Subject:Date; b=ali9cnV7fC8/R6pOrB1uVH0nh2XxHo70SOAnhlm3Zi+WfN/0mgK/mxUKsSbz8H65x oVetSEqsuZy9z1U6t4X0Rv4Xx/K1GnahMxK9pwQG90CfShmI9U8W3YXQzfdIMLU89B D0b1VTqRiYzTGjhdfGoz6i3NBoOmi41gNYFtlBNP6+onKSguXa3sFgmYo6c3W/Sd1x Vb/vh9QgiNU0ErO5qN6l1c0f98OdxRpRIO+TtJJSozVToRPG/JUzK32gfEmvpg4fIf sjvmvqn+hCZCviVbY+J6BHyi3G+jyFiwWv6JIDm2sZvfQK0VlmQUkvsQ0vte4cFyp6 i065cPRc9jVLg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 17 Jun 2023 11:57:15 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Johan Hovold , Matthias Brugger , AngeloGioacchino Del Regno , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH] gnss: Use devm_regulator_get_enable_optional() Date: Sat, 17 Jun 2023 11:57:09 +0200 Message-Id: <62effa7aa1a2023a77709e6416c57d9cb79a5ccc.1686995765.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230617_025719_547326_3CD4BAD2 X-CRM114-Status: GOOD ( 12.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use devm_regulator_get_enable_optional() instead of hand writing it. It saves some line of code. Signed-off-by: Christophe JAILLET Reviewed-by: AngeloGioacchino Del Regno --- Note that regulator_disable() is now called after gnss_serial_free() in the error handling path of the probe and in the remove function, but it looks harmless to me. --- drivers/gnss/mtk.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/drivers/gnss/mtk.c b/drivers/gnss/mtk.c index c62b1211f4fe..d3d31295d4e0 100644 --- a/drivers/gnss/mtk.c +++ b/drivers/gnss/mtk.c @@ -17,7 +17,6 @@ #include "serial.h" struct mtk_data { - struct regulator *vbackup; struct regulator *vcc; }; @@ -87,30 +86,16 @@ static int mtk_probe(struct serdev_device *serdev) goto err_free_gserial; } - data->vbackup = devm_regulator_get_optional(&serdev->dev, "vbackup"); - if (IS_ERR(data->vbackup)) { - ret = PTR_ERR(data->vbackup); - if (ret == -ENODEV) - data->vbackup = NULL; - else - goto err_free_gserial; - } - - if (data->vbackup) { - ret = regulator_enable(data->vbackup); - if (ret) - goto err_free_gserial; - } + ret = devm_regulator_get_enable_optional(&serdev->dev, "vbackup"); + if (ret) + goto err_free_gserial; ret = gnss_serial_register(gserial); if (ret) - goto err_disable_vbackup; + goto err_free_gserial; return 0; -err_disable_vbackup: - if (data->vbackup) - regulator_disable(data->vbackup); err_free_gserial: gnss_serial_free(gserial); @@ -120,11 +105,8 @@ static int mtk_probe(struct serdev_device *serdev) static void mtk_remove(struct serdev_device *serdev) { struct gnss_serial *gserial = serdev_device_get_drvdata(serdev); - struct mtk_data *data = gnss_serial_get_drvdata(gserial); gnss_serial_deregister(gserial); - if (data->vbackup) - regulator_disable(data->vbackup); gnss_serial_free(gserial); }