From patchwork Sat Jun 17 10:01:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 109450 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1896921vqr; Sat, 17 Jun 2023 03:35:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7FPC1/ic7Bq5pX7EOvYC+Xs83/1LSxEbzF7+6+K6MIGvEIps7ASjg44M2jtcCA9L1xXr3W X-Received: by 2002:a05:6a20:4404:b0:11f:f6b6:ef38 with SMTP id ce4-20020a056a20440400b0011ff6b6ef38mr35585pzb.6.1686998100385; Sat, 17 Jun 2023 03:35:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686998100; cv=none; d=google.com; s=arc-20160816; b=igt4zBLP/VIIxeFloWrm8rcttPylXCK0aMxSS1EpdXutMfuM9bKLB9nVjZQc+kwo/b ccJV9G7kpxaAjPvLH8B0Ep8QXO4VcOZLDFw+CM0qE7d32JpF5KtoUzOXDmpQ67h0iu73 HhI+5ZWFKVHhFXC+pYKuiOwcprBHWwZZIxdm9h08Zvlt5pNz3vL17JLXRAxW2Sc7n3pp tz9kq8Yw5wATJzyx5SxDzdV5MrXA7RS1DrZfDpb+RtdP+Vm5pSIaMuoqJ1dd/OpoMm01 8uoD2JakNhfUqyucBRKGQe+Lmddsvz5dXkKBgUgUdTSl+QfexopzLzrpqG68/Cja2Hc2 WGcg== 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=My7bkAqqo/A13fUh68OM/EOPED/a4hAqbxm3emWVh6Q=; b=GYLRYcvhKr9u7mZDxoYSRHLqWCz7NoiYSpxI5Ed7yugwVBkmn/hScdfexXGz256PCQ fou/XgYB88minhFGWBez+gaaKcVpKycd9PTYmqPr5zzAMD40JjEzS5/Qs3BQGE7bRKdM QdSDluc4g8d7h06Jm0aipSh0WTespvlshOrUN9qydI5dzET7ar4uMf/aBHmcGzc8n07z JXZO2/cZhU0wEYCvTuXB6M4Ra/j+1aq5GS/mWG76youMpFZNpSW/1X2IZorQWLdywgos HjK48u6fbc8XzwkRHa+SU6FUb64NrnBb4og1E4PQMAEUYE/Kx6Nt17iNwTyU0mUTtXxD NkkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=txjyvPXy; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020a170903231100b001ac671a8fd3si17700866plh.110.2023.06.17.03.34.41; Sat, 17 Jun 2023 03:35:00 -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=txjyvPXy; 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 S235663AbjFQKBc (ORCPT + 99 others); Sat, 17 Jun 2023 06:01:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231894AbjFQKB1 (ORCPT ); Sat, 17 Jun 2023 06:01:27 -0400 Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72044172D for ; Sat, 17 Jun 2023 03:01:26 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id ASkFqraCDtjdEASkFq3cXf; Sat, 17 Jun 2023 12:01:24 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1686996084; bh=My7bkAqqo/A13fUh68OM/EOPED/a4hAqbxm3emWVh6Q=; h=From:To:Cc:Subject:Date; b=txjyvPXyxY/c9L2a3sslO8/y2dVdUo/Maev0q63jXxrWeTnEotTvqnOB+hnzs9set fIjxlB9PRvwKXeqbXuxjFSX69EJFleDEuxwA/mHDXsWjXJHDrRtmSedffM7NNv8kzW tfKXqkHYGkLbbI0sRP2J/Z0k/0d2yDkcsGcm941fwJjKkoV/N8Id4F2zvXRoTOmO0l 7UO8sbA6JEb/hZGpOCUwtOOZfepR/F/GugdCQZDNCvc1yca8hQJ98i25GMA5UCJRdi 0Fq4IyRtWlWh37spsyOuybl7/0CoUX76XjhbXBOZ9z0DlfDD2XFQHkZRCL2gC7qSFl Nd+eokj8R0ObA== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 17 Jun 2023 12:01:24 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Johan Hovold , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] gnss: ubx: Use devm_regulator_get_enable_optional() Date: Sat, 17 Jun 2023 12:01:22 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768945719751489973?= X-GMAIL-MSGID: =?utf-8?q?1768945719751489973?= Use devm_regulator_get_enable_optional() instead of hand writing it. It saves some line of code. Signed-off-by: Christophe JAILLET --- 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/ubx.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/drivers/gnss/ubx.c b/drivers/gnss/ubx.c index c951be202ca2..0ad2a10fc9a2 100644 --- a/drivers/gnss/ubx.c +++ b/drivers/gnss/ubx.c @@ -17,7 +17,6 @@ #include "serial.h" struct ubx_data { - struct regulator *v_bckp; struct regulator *vcc; }; @@ -87,30 +86,16 @@ static int ubx_probe(struct serdev_device *serdev) goto err_free_gserial; } - data->v_bckp = devm_regulator_get_optional(&serdev->dev, "v-bckp"); - if (IS_ERR(data->v_bckp)) { - ret = PTR_ERR(data->v_bckp); - if (ret == -ENODEV) - data->v_bckp = NULL; - else - goto err_free_gserial; - } - - if (data->v_bckp) { - ret = regulator_enable(data->v_bckp); - if (ret) - goto err_free_gserial; - } + ret = devm_regulator_get_enable_optional(&serdev->dev, "v-bckp"); + if (ret) + goto err_free_gserial; ret = gnss_serial_register(gserial); if (ret) - goto err_disable_v_bckp; + goto err_free_gserial; return 0; -err_disable_v_bckp: - if (data->v_bckp) - regulator_disable(data->v_bckp); err_free_gserial: gnss_serial_free(gserial); @@ -120,11 +105,8 @@ static int ubx_probe(struct serdev_device *serdev) static void ubx_remove(struct serdev_device *serdev) { struct gnss_serial *gserial = serdev_device_get_drvdata(serdev); - struct ubx_data *data = gnss_serial_get_drvdata(gserial); gnss_serial_deregister(gserial); - if (data->v_bckp) - regulator_disable(data->v_bckp); gnss_serial_free(gserial); }