Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3606900rwb; Mon, 5 Sep 2022 15:10:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR4C2Io3cGjg+JUS9EhisgiNhieKUYT+Pc2GRM5sPxqprQyr3xYDu9/E3u87KhqN5o97MHX/ X-Received: by 2002:a17:902:694a:b0:172:bd15:3ece with SMTP id k10-20020a170902694a00b00172bd153ecemr51694859plt.116.1662415837590; Mon, 05 Sep 2022 15:10:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662415837; cv=none; d=google.com; s=arc-20160816; b=hp55sfliyr0iQ53uPFfo3/mggfQLRaVIDlR3WDze4Pl98nQxepHG2qYTwT/hXewoxA 0MvSdhaJYFgNcImQu+abMXHPjjpP41Mv5dn5+gnPOP/izbpQ05KupS3grTfZ4XS2oB6q 6P2LNPkWl+MCqdRgOCiKfnmzgJWhd1NyltsySO+C1Hs18RqP+CvIih9RqAxX3J69N+Pl ioiEhj8m0BqMDWw/rkd/AF1uchWKXP5bNqXij2tRu0ZP6kVn3lZkhKlJKSARYj2jlCe+ 0BbiDid7lnOWaunz3WBqyMitgDs78x97gXIHQtJCsftdPe97/yrA+EU27crz911c70VJ Kx9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:sender:dkim-signature; bh=DI+EGf5Iiw4yLnQOM0iLSEUhYarB1qtVETYwX3ATTlI=; b=FdFfUH555k9gt0TohM+knEdVmCZyljmofXxOZ/hmKAeltR0pqRc27benfsbpODr0Ef CEiLn5jgmoEu3+0OmEk8NC+9tm0l1fJM35L2KSGw3NeBFp4jC0h8AdLGrqrNpj/i0oK5 8zJJ4jFhtjqFdf2LA+5jRBBG+yied/hfW382oX4tHbxUy/PMdrmyybexOfxSwOXeD2VN S3J4Quwx7Ovqo7IL1WkGRW3jhXk/nyoOKiTU0g0iNDe+KWMb/Udp+Fbdnt9bcBgWWzk3 /0ubMZQqAGckJ5dDnaUlFLyIZyJTgCTkjJ7VIJ8P/GSBDcVArr0P94xKnPHDN6EdB7gn cFcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KDxaSPeO; 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 t4-20020a17090aba8400b0020038eb8b5asi6497780pjr.21.2022.09.05.15.10.24; Mon, 05 Sep 2022 15:10:37 -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=20210112 header.b=KDxaSPeO; 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 S232388AbiIEWIC (ORCPT + 99 others); Mon, 5 Sep 2022 18:08:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231331AbiIEWH6 (ORCPT ); Mon, 5 Sep 2022 18:07:58 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30ADF51A0D; Mon, 5 Sep 2022 15:07:53 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id h188so8956130pgc.12; Mon, 05 Sep 2022 15:07:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id:sender :from:to:cc:subject:date; bh=DI+EGf5Iiw4yLnQOM0iLSEUhYarB1qtVETYwX3ATTlI=; b=KDxaSPeOmIAHodHZoxO7+rPppr+0nc84E7WjJr09aHXf0y70VUqQeiGwM4ZbMT1+IG aswpW6qIia4RuP0oy/zixSqOkdUMGcBdQBZ+zCXrSbs5gzJjxQbyCJKm+qaEmHP0fbLr p+VnLtgDb/UqRnZ5jH6rY49caFH+X+TV7pDArSwV7zY/jQ9Qvi10MQT7HP3yHqCz6Ymq 3ER0a2FyOYkl9+aJiUSNvNKZnQFKEXdO6qjVPIArqiSCS2eFf74FcrePSlFKeiFjZiPh a3swNk1c3KCQbDFwBwgMcHrg1CM/Xc0KnXfSUNi2LqKeA1gvQb715UJnDwV5eFIZMn4E JSRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id:sender :x-gm-message-state:from:to:cc:subject:date; bh=DI+EGf5Iiw4yLnQOM0iLSEUhYarB1qtVETYwX3ATTlI=; b=vBmhdeYALxw43twfMlS5Zd7LvvqaHOdzCCq/lo+5jKZWE+Sa/TE24Gbh9H3DLAnKXp oiwpsuUHxJTxrtSdu+KB+CeZWkAwbMcjsHb5/4yo/gAt81l5XpmV5S2YaM6sG7G+oPpE A48KR2KrVNuA3/DPyI35cAGYZzJHKGpNe8IJeKIT8FX8DnjfyOz7gDJ89OSEDg92BtRx cSjTMKU9U1Nu4M9zfXzNQ0vMqTfLlwPCCYPVMnR18ZVxPID6wV2IQJCoc6d8tXFBfnXV PCixZPH99k4zVdsSaVEcdPiKSFhRMOvzuWXHaPTbzsMRq5SODm7hgm5sfrrQHi3W+2TA n3sA== X-Gm-Message-State: ACgBeo35q2vU7tTZkaJAOy4bwpZbvFRIudGhEALraggx/oIpYvzHLqHu PXR2iKdPaPfzXAk8gFasguY= X-Received: by 2002:a63:2cc2:0:b0:41c:681d:60d2 with SMTP id s185-20020a632cc2000000b0041c681d60d2mr41816293pgs.502.1662415672598; Mon, 05 Sep 2022 15:07:52 -0700 (PDT) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id m16-20020a170902db1000b00172dd10f64fsm8157821plx.263.2022.09.05.15.07.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Sep 2022 15:07:51 -0700 (PDT) Sender: Guenter Roeck Message-ID: <4a0d089d-6ac6-b92e-6ac7-3d3de0144b4b@roeck-us.net> Date: Mon, 5 Sep 2022 15:07:48 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US To: Andy Shevchenko , Dmitry Torokhov Cc: 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 , =?UTF-8?Q?Krzysztof_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 , =?UTF-8?Q?Pali_Roh=c3=a1r?= , 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 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> From: Guenter Roeck Subject: Re: [PATCH v1 04/11] usb: phy: tegra: switch to using devm_gpiod_get() In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, NICE_REPLY_A,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: X-Mailing-List: linux-kernel@vger.kernel.org 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_from_of_node(&pdev->dev, np, >>>>>> - "nvidia,phy-reset-gpio", >>>>>> - 0, GPIOD_OUT_HIGH, >>>>>> - "ulpi_phy_reset_b"); >>>>>> + 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(). Thanks, Guenter