Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4349146rwb; Tue, 6 Sep 2022 06:23:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Zm1NQBSo4vRK2Sv9i9hkjQ/w3zOdhfqqHVybNmI7kt8HMyTznyDJ5ryvQwZx2F+5Sm7qe X-Received: by 2002:a17:907:75db:b0:741:4155:b52f with SMTP id jl27-20020a17090775db00b007414155b52fmr33482292ejc.638.1662470599311; Tue, 06 Sep 2022 06:23:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662470599; cv=none; d=google.com; s=arc-20160816; b=Kb9eJrD5OKBJaCfm81dYmXoSiKx4Q5yArbVC2spbKumuwPzxVihsPVVTa/yHBdvOey quVUwrv/za8mb/fMIeVI0dZVZ+rPu9RzDGw3PqCAgjCwGnq+PtqEUtQSM2o7ro5Adwai B2uWAElEQtbQS0NcXh+DbbKsDaehp7oKOX2D5e4p4l6s1vJEDa/mywhVw8VRlo0O0PdY nz9i2sVPzGuUddpJus0bcD2f/DvIVWXtkeqSgNLepk2Qz8dcPojHukvI9WgAerXPuuTW Dj9GORd+xMn5EpnsG7XPE22g2VQHn3Nutk33teA3Y1WGikHipzQNCzlgx6pfPmfhr1CF FAaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=jaPmLaiTyYqNThiFWw3quUJEuHmJ6yBq1I3Inpj/5YY=; b=owlxCAtYP5pFcp4UEWWfXYBuWa/I5pYRla/JFqeH2oSGFgGwByWyRKs3E4UGDxymAn 1fu1MvnxTqcRa8D25szyAWxrJnaS/kBg/D0Cb2Xcc+bZmeF+mC96Y+f50CuNV34oyZpq 4EYJgYuCD8VxLXdpL+r9Wn5DCr5WcdKKPYuiI0zz/JbcyjA+6vcOngWi92JUKSpRNjRm p8b308d9jxHNVgb988xQz6GN7VJYCndgcq7GAIGCyiA2tkxkNOHFYVLAfsQnSrbxFODS P0C622EutUIcbo7bG8Gi6HXaoCKuRDeU1oK5gUx44GtTSqOqEjuijE2Ykv8mJA+zPM7b SIQw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fp32-20020a1709069e2000b00741795a8603si8324753ejc.196.2022.09.06.06.22.53; Tue, 06 Sep 2022 06:23:19 -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; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240051AbiIFMbO (ORCPT + 99 others); Tue, 6 Sep 2022 08:31:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239968AbiIFMaz (ORCPT ); Tue, 6 Sep 2022 08:30:55 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E144E275C2; Tue, 6 Sep 2022 05:27:46 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6500,9779,10461"; a="296579839" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="296579839" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 05:27:45 -0700 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="565074197" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 05:27:36 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1oVXfv-00975d-2X; Tue, 06 Sep 2022 15:27:31 +0300 Date: Tue, 6 Sep 2022 15:27:31 +0300 From: Andy Shevchenko To: Guenter Roeck Cc: Dmitry Torokhov , Thierry Reding , Mark Brown , Matti Vaittinen , Lorenzo Pieralisi , Claudiu Beznea , Liam Girdwood , Wim Van Sebroeck , Greg Kroah-Hartman , Miquel Raynal , Linus Walleij , Felipe Balbi , Alexandre Belloni , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Vignesh Raghavendra , Daniel Vetter , Thomas Petazzoni , Alexandre Torgue , Marc Zyngier , Richard Weinberger , David Airlie , Nicolas Ferre , Alyssa Rosenzweig , Bartosz Golaszewski , Jonathan Hunter , Rob Herring , Maxime Coquelin , Bjorn Helgaas , Pali =?iso-8859-1?Q?Roh=E1r?= , LINUXWATCHDOG , USB , "open list:GPIO SUBSYSTEM" , linux-pci , linux-tegra , "open list:MEMORY TECHNOLOGY..." , Linux Kernel Mailing List , dri-devel , linux-stm32@st-md-mailman.stormreply.com, linux-arm Mailing List Subject: Re: [PATCH v1 04/11] usb: phy: tegra: switch to using devm_gpiod_get() Message-ID: References: <20220903-gpiod_get_from_of_node-remove-v1-0-b29adfb27a6c@gmail.com> <20220903-gpiod_get_from_of_node-remove-v1-4-b29adfb27a6c@gmail.com> <4a0d089d-6ac6-b92e-6ac7-3d3de0144b4b@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4a0d089d-6ac6-b92e-6ac7-3d3de0144b4b@roeck-us.net> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_SOFTFAIL,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 On Mon, Sep 05, 2022 at 03:07:48PM -0700, Guenter Roeck wrote: > On 9/5/22 12:55, Andy Shevchenko wrote: > > On Mon, Sep 5, 2022 at 10:51 PM Dmitry Torokhov > > wrote: > > > On Mon, Sep 05, 2022 at 10:41:40PM +0300, Andy Shevchenko wrote: > > > > On Mon, Sep 5, 2022 at 10:40 PM Dmitry Torokhov > > > > wrote: > > > > > On Mon, Sep 05, 2022 at 01:59:44PM +0300, Andy Shevchenko wrote: > > > > > > On Mon, Sep 5, 2022 at 9:32 AM Dmitry Torokhov > > > > > > wrote: ... > > > > > > > + gpiod = devm_gpiod_get(&pdev->dev, "nvidia,phy-reset", > > > > > > > + GPIOD_OUT_HIGH); > > > > > > > err = PTR_ERR_OR_ZERO(gpiod); > > > > > > > > > > > > What does _OR_ZERO mean now? > > > > > > > > > > This converts a pointer to an error code if a pointer represents > > > > > ERR_PTR() encoded error, or 0 to indicate success. > > > > > > > > Yes, I know that. My point is, how is it useful now (or even before)? > > > > I mean that devm_gpio_get() never returns NULL, right? > > > > > > What does returning NULL have to do with anything. > > > > It has to do with a dead code. If defm_gpiod_get() does not return > > NULL, then why do we even bother to check? > > PTR_ERR_OR_ZERO() converts into an error code (if the pointer is an > ERR_PTR) or 0 if it is a real pointer. Its purpose is not to convert > NULL into 0, its purpose is to convert a pointer either into an error > code or 0. That is what is done here, and it is done all over the place > in the kernel. I don't see your problem with it. Care to explain ? > > > > It converts a pointer > > > to a "classic" return code, with negative errors and 0 on success. > > > > > > It allows to not use multiple IS_ERR/PTR_ERR in the code (I'd need 1 > > > IS_ERR and 2 PTR_ERR, one in dev_err() and another to return). > > > > I don't see how this is relevant. > > You lost me. Really, please explain your problem with PTR_ERR_OR_ZERO(). I don't know what I was thinking about... You, guys, are right, sorry for my noise. -- With Best Regards, Andy Shevchenko