Message ID | 20230517160326.10732-1-osmtendev@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1257431vqo; Wed, 17 May 2023 09:17:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ZueTxa8jnJesd+aI3LsKNyVZXIwPRz6QEi5i1087jbGUyVpHU2FI8+qgkO273IZVfHLAf X-Received: by 2002:a17:90a:d193:b0:24e:5a5a:1050 with SMTP id fu19-20020a17090ad19300b0024e5a5a1050mr199283pjb.24.1684340248461; Wed, 17 May 2023 09:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684340248; cv=none; d=google.com; s=arc-20160816; b=XVfmAENeEBRyAmOr6GFskCf0V2w6aerUrTYKSVdaFLQKdeBuSuIbe8sB6KZh2eoYCy x9acejJr8x4dD3S1qTfwlyn3hGFL8ayhENtDwldTsoGlo8se4Kty+oGWjsIjWQADWgMN 5cchqWabsliP4d8FhAC7hC1VhYow/JK/8/aDtPrE8Wqpl+K9CwZfMa09PDbbvHEzjvMt DV2zEh7UbbPw5085K8YX+/MdAiEubrzpepTW4l/JSbC1wUgdFg7YQ2sYeARISh6UyxEs W2GE2Lbs9GVU9zqU6rYamVpaEIaZH2TvnxK8Eyd9lD1vu1x9BCjL1pBIGsHJuX6l4X5z dJkQ== 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=JbDnB2PXIbg1nrLsvecGt1DuT+K73v6dCg1HZevcZvc=; b=WugLA+4FcVOKEdKuvY8nhmyYNg3rVOEasJIQaj1tnjrozdVK3GvHscwInMC6i37kPH 16XNo/YSyjqqZpQHxEoxEp53XDYTQhtdtA28K6ZKlO16HQYRxgKhqzS+0kp1bpQzZ7qa M6sCyXSgRwa5255sbQe7ONQaB+IlgKfjRU1IrV0WIYg34Rh/oG4Abvu42F7+xLeFISBh jVnYAayRcn/bzPMQj/rI2Ed43C7VjX/YQvdTdLE1NdJMofpwQRmkjbeTyplrqBVT6yEp 7na1XVW7otyxemuhPmaEjhaaB8eQ10BLfjko6FLSIiYISDwNyh50pyBWphydfegeLcmb ARJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="R+JAY/0n"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id on11-20020a17090b1d0b00b0024e24699dfdsi2300143pjb.78.2023.05.17.09.17.15; Wed, 17 May 2023 09:17:28 -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=@gmail.com header.s=20221208 header.b="R+JAY/0n"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231622AbjEQQF2 (ORCPT <rfc822;abdi.embedded@gmail.com> + 99 others); Wed, 17 May 2023 12:05:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbjEQQF0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 17 May 2023 12:05:26 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97109110; Wed, 17 May 2023 09:05:25 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-52c30fbccd4so816815a12.0; Wed, 17 May 2023 09:05:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684339525; x=1686931525; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JbDnB2PXIbg1nrLsvecGt1DuT+K73v6dCg1HZevcZvc=; b=R+JAY/0n8zLGV8wFotOEzEJpiiGuPQJiOm3W4d16A9wrPM1VEk7cqZDc7jDh7VwHLe bMfHTeB3HFe7LBnZYLy7u9GRO9cQp9E7/Jg/2Vbjq5L9P7NGAxrkq/yNS/oDK1S3rb0W t9YJJ7xXTylFuZbhTJcmFSWCJJLRU12eopskn9Dy224gmIMOaP8JSFVepuxZfT10XCIw 0MjvLgzetNIOv0z0ngngo7kh8a3lsXnIfZ93k/eTETASKJZlEg2EBMgQDdx0Dmnrj3tY nqyGZIaDur0HDgK+/Gy3hwzO3fth3LXQKpSiqX2QJsssWza9bQS3nZntIgG9rnIsZ30m HADg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684339525; x=1686931525; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JbDnB2PXIbg1nrLsvecGt1DuT+K73v6dCg1HZevcZvc=; b=N/43dhOqs62g2dLEahPWPiMST66f4C8siv5W+I5AwMX5gBHu67KYSA8kmk4DFFvxe8 RuoTmt/fNT+PnVS9FxTcJdlfW703mxCrvlxNkv2ikWUTej74MJghpTtFr3UE46CeC3Pk rq3cle3jufoEasf67AlqMoir51tXzZnaGSllQyqTjj8RqRez37eRa9QJ3ENa9ka36IOH 3rjCHLDJ7i78LuA6ETvwExmTSTlAxgV9Ga9nzZdcvomNph3F/nShGwPCEIe9AJDuBzfI B0F9ldHl62q+wi1tlQQb28pUMC+o15yUCezzMchtSvHjUf7OFqkmWOmA6SRL9XxRbLIy bzbw== X-Gm-Message-State: AC+VfDzCzWMt/e1j4KCHHUoUZaK3dC5ccXbbGQVIyl/NYz/HcHYkv7dA 0urb4yrXU7WCVtZBboXVPBQ= X-Received: by 2002:a17:90b:3645:b0:250:d137:e2ae with SMTP id nh5-20020a17090b364500b00250d137e2aemr168165pjb.23.1684339524459; Wed, 17 May 2023 09:05:24 -0700 (PDT) Received: from Osmten.. ([103.84.150.101]) by smtp.gmail.com with ESMTPSA id o4-20020a17090ad20400b00250c1392ed3sm1761949pju.55.2023.05.17.09.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 09:05:23 -0700 (PDT) From: Osama Muhammad <osmtendev@gmail.com> To: rafael@kernel.org, daniel.lezcano@linaro.org, amitk@kernel.org, rui.zhang@intel.com, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, bchihi@baylibre.com, wenst@chromium.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Osama Muhammad <osmtendev@gmail.com> Subject: [PATCH] lvts_thermal.c: Fix error checking for debugfs_create_dir Date: Wed, 17 May 2023 21:03:26 +0500 Message-Id: <20230517160326.10732-1-osmtendev@gmail.com> 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,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766158760216331632?= X-GMAIL-MSGID: =?utf-8?q?1766158760216331632?= |
Series |
lvts_thermal.c: Fix error checking for debugfs_create_dir
|
|
Commit Message
Osama Muhammad
May 17, 2023, 4:03 p.m. UTC
This patch fixes the error checking in lvts_thermal.c in
debugfs_create_dir. The correct way to check if an error occurred
is 'IS_ERR' inline function.
Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 17/05/2023 18:03, Osama Muhammad wrote: > This patch fixes the error checking in lvts_thermal.c in > debugfs_create_dir. The correct way to check if an error occurred > is 'IS_ERR' inline function. We do no longer check debugfs functions return values. eg. https://www.spinics.net/lists/linux-spi/msg37903.html https://lore.kernel.org/lkml/2023052835-oxidant-doily-404f@gregkh/ > Signed-off-by: Osama Muhammad <osmtendev@gmail.com> > --- > drivers/thermal/mediatek/lvts_thermal.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c > index d0a3f95b7884..61386be78fa0 100644 > --- a/drivers/thermal/mediatek/lvts_thermal.c > +++ b/drivers/thermal/mediatek/lvts_thermal.c > @@ -188,7 +188,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td) > int i; > > lvts_td->dom_dentry = debugfs_create_dir(dev_name(dev), NULL); > - if (!lvts_td->dom_dentry) > + if (IS_ERR(lvts_td->dom_dentry)) > return 0; > > for (i = 0; i < lvts_td->num_lvts_ctrl; i++) { > @@ -197,7 +197,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td) > > sprintf(name, "controller%d", i); > dentry = debugfs_create_dir(name, lvts_td->dom_dentry); > - if (!dentry) > + if (IS_ERR(dentry)) > continue; > > regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL);
Hi, After Reading more about it I also learned about this and I was planning to send a patch to remove the error checking for debugfs API.Should I send the patch for it? Thanks osmten On Tue, 30 May 2023 at 20:47, Daniel Lezcano <daniel.lezcano@linaro.org> wrote: > > On 17/05/2023 18:03, Osama Muhammad wrote: > > This patch fixes the error checking in lvts_thermal.c in > > debugfs_create_dir. The correct way to check if an error occurred > > is 'IS_ERR' inline function. > > We do no longer check debugfs functions return values. > > eg. > > https://www.spinics.net/lists/linux-spi/msg37903.html > https://lore.kernel.org/lkml/2023052835-oxidant-doily-404f@gregkh/ > > > > Signed-off-by: Osama Muhammad <osmtendev@gmail.com> > > --- > > drivers/thermal/mediatek/lvts_thermal.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c > > index d0a3f95b7884..61386be78fa0 100644 > > --- a/drivers/thermal/mediatek/lvts_thermal.c > > +++ b/drivers/thermal/mediatek/lvts_thermal.c > > @@ -188,7 +188,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td) > > int i; > > > > lvts_td->dom_dentry = debugfs_create_dir(dev_name(dev), NULL); > > - if (!lvts_td->dom_dentry) > > + if (IS_ERR(lvts_td->dom_dentry)) > > return 0; > > > > for (i = 0; i < lvts_td->num_lvts_ctrl; i++) { > > @@ -197,7 +197,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td) > > > > sprintf(name, "controller%d", i); > > dentry = debugfs_create_dir(name, lvts_td->dom_dentry); > > - if (!dentry) > > + if (IS_ERR(dentry)) > > continue; > > > > regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL); > > -- > <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs > > Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | > <http://twitter.com/#!/linaroorg> Twitter | > <http://www.linaro.org/linaro-blog/> Blog >
On 30/05/2023 17:54, Osama Muhammad wrote: > Hi, > > After Reading more about it I also learned about this and I was > planning to send a patch to remove the error checking for debugfs > API.Should I send the patch for it? > Yes, you can change also the prototype of the lvts_debugfs_init() function by returning void And then replace the call site: return lvts_debugfs_init(dev, lvts_td); by: lvts_debugfs_init(dev, lvts_td); return 0; > osmten > > > On Tue, 30 May 2023 at 20:47, Daniel Lezcano <daniel.lezcano@linaro.org> wrote: >> >> On 17/05/2023 18:03, Osama Muhammad wrote: >>> This patch fixes the error checking in lvts_thermal.c in >>> debugfs_create_dir. The correct way to check if an error occurred >>> is 'IS_ERR' inline function. >> >> We do no longer check debugfs functions return values. >> >> eg. >> >> https://www.spinics.net/lists/linux-spi/msg37903.html >> https://lore.kernel.org/lkml/2023052835-oxidant-doily-404f@gregkh/ >> >> >>> Signed-off-by: Osama Muhammad <osmtendev@gmail.com> >>> --- >>> drivers/thermal/mediatek/lvts_thermal.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c >>> index d0a3f95b7884..61386be78fa0 100644 >>> --- a/drivers/thermal/mediatek/lvts_thermal.c >>> +++ b/drivers/thermal/mediatek/lvts_thermal.c >>> @@ -188,7 +188,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td) >>> int i; >>> >>> lvts_td->dom_dentry = debugfs_create_dir(dev_name(dev), NULL); >>> - if (!lvts_td->dom_dentry) >>> + if (IS_ERR(lvts_td->dom_dentry)) >>> return 0; >>> >>> for (i = 0; i < lvts_td->num_lvts_ctrl; i++) { >>> @@ -197,7 +197,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td) >>> >>> sprintf(name, "controller%d", i); >>> dentry = debugfs_create_dir(name, lvts_td->dom_dentry); >>> - if (!dentry) >>> + if (IS_ERR(dentry)) >>> continue; >>> >>> regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL); >> >> -- >> <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs >> >> Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | >> <http://twitter.com/#!/linaroorg> Twitter | >> <http://www.linaro.org/linaro-blog/> Blog >>
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c index d0a3f95b7884..61386be78fa0 100644 --- a/drivers/thermal/mediatek/lvts_thermal.c +++ b/drivers/thermal/mediatek/lvts_thermal.c @@ -188,7 +188,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td) int i; lvts_td->dom_dentry = debugfs_create_dir(dev_name(dev), NULL); - if (!lvts_td->dom_dentry) + if (IS_ERR(lvts_td->dom_dentry)) return 0; for (i = 0; i < lvts_td->num_lvts_ctrl; i++) { @@ -197,7 +197,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td) sprintf(name, "controller%d", i); dentry = debugfs_create_dir(name, lvts_td->dom_dentry); - if (!dentry) + if (IS_ERR(dentry)) continue; regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL);