Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp761093imm; Mon, 21 May 2018 13:57:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqZrRBL2nyIZ/0fFdtzmp5BbFFv+Q/t89e/AZ2jXqFTxCKpeoPN13aBmA4LcGeok9MaRObl X-Received: by 2002:a65:50c7:: with SMTP id s7-v6mr3507704pgp.359.1526936267561; Mon, 21 May 2018 13:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526936267; cv=none; d=google.com; s=arc-20160816; b=sDH2QHApI9/R8OqIN9G7BjCbHv6AefSeRrTjeZjJy9DNn+pCfOjrDnOX4TemOatPah n2QdamnNNAjhmrUlB594qlvgIdwsK3vIQ3xRe8/pPRjzzobylwaicDcyAUuuyAS/KXt5 xI8jdYDi4bJ+W5YY7/vfVCmdfDjnSuuYFLgNngctOSVexRVOQ7tEMH78lSF54/t3E06h 0r9U9scgdiaPMLv20CmR9Jns3zm7aJvXkPF8AXm/4fU17L9w75lkw0v8rEmidDITNoiD NWeHHmqXAP5Y5A12w+mXgrvC487n3j1G82mysWwNvR29SsUtzvp9uTNtJGtsGxiV7umJ OlMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=ISNfW8k5vTqTPxuHVqbpT2ZuWHRhcWfmHOiVuG9l3rY=; b=tdOfQjXjucWOR0cSb9iC6tcq0VELycVFldhIg5aahSNh80KuqNnzQAZhZNx2XoBbOT 9ILFpxVgx+PBMj9RM79+Gy35doWE7qmdJDnqpNl0ULtVFOMsO3XOQrpvdl2Zs2X+5rfc r/2cJb1Sq+4egPBicVd8aPr7fmR/0uhQmWLNJGjpgMYTdnBZNEoQQYWIZKahNMARfpTI D1PYk+tC6+aOaKGPcXHET/SyMLqKIYoSMIFukhsl+NANT3ymrwtfX4nNHk2II2eLc748 JIPXtJUoL0Q5XCKsNso7t9Ck88q1kqElQR1pZGk2ZHICtOc2csR5iY8z0o+n1H3UaI47 Knqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PN1uT3ka; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w61-v6si13536477plb.288.2018.05.21.13.57.30; Mon, 21 May 2018 13:57:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PN1uT3ka; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1751171AbeEUU5S (ORCPT + 99 others); Mon, 21 May 2018 16:57:18 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:43508 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750942AbeEUU5P (ORCPT ); Mon, 21 May 2018 16:57:15 -0400 Received: by mail-pg0-f68.google.com with SMTP id p8-v6so6856726pgq.10; Mon, 21 May 2018 13:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ISNfW8k5vTqTPxuHVqbpT2ZuWHRhcWfmHOiVuG9l3rY=; b=PN1uT3kaNUPgWk+iJ9YhbiSVMZmd/1vOERRzKKxubAxSgjFuaxFdhcK9TEg7P8i5b9 Ry2/+DmDtL9Sd2DnpR4yRfqM/kxm/bzjb7BBvsnJeM5ULHF4frLh3LWu/lNzC/Z107kT OmndiMDpE+jle812qTtaM51qr2JiE+4PLlCWOtPPoKHcf36EpRwTN3dMQ12RErOsPraD WM9/0CS5V80wTVO8ymM0G1L3Jv5UftRXUdAM+nK3JzaH9YAJ9qOtWCgLDxeYDUhqaJjr FAF9TBm7I0cd1+TOzUvGv3s1gloM24rLW9ZdE2hmQ77wYZvHznWCWEN1d7yF5Wsc+ihW AJ0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ISNfW8k5vTqTPxuHVqbpT2ZuWHRhcWfmHOiVuG9l3rY=; b=mq+O0pLWi2B9GHGAA/C7vsC6MgibwG98FV/hIgJV8PuBrL7eqFsjWWpnfIFBKUAs3Q myRnKjSkNZFm4wE2CIKl/Bcohq8oLigDe08tWR457ouH2+FrmLKy3UlP33JL6IGwUNK6 6gdtxnyQy+tbF1MO9E/au5djWOmTORiRS6Qjoz2soyDXOtWa1FSyG3XO1riDvl0OizhN kyJl7LfyunCRGIL++7eXsgNOEUWD8SipY6R/uzPRAcw3Ac5e0rrKx6H16Q+lFvC4Xcnc LHcaABLmXdIn1ZtQprwadt1NumVMpk7bsquwdnizBuyKI7AbcIxBppKbBATLExem6I0Q MYEg== X-Gm-Message-State: ALKqPwcFUh3u4HaOvIIZXXHsZbeh08c5zpv0l7d46RPC/pL8090CWpJ7 hF2UwnkYFtt0p3ETUKapGouxMHjW X-Received: by 2002:a63:66c2:: with SMTP id a185-v6mr17287784pgc.347.1526936234501; Mon, 21 May 2018 13:57:14 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1511:8de6:27a8:ed13:2ef5]) by smtp.gmail.com with ESMTPSA id e25-v6sm28389917pfn.88.2018.05.21.13.57.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 May 2018 13:57:13 -0700 (PDT) Date: Mon, 21 May 2018 13:57:11 -0700 From: Dmitry Torokhov To: Janusz Krzysztofik Cc: Ladislav Michl , Andy Shevchenko , linux-fbdev@vger.kernel.org, ALSA Development Mailing List , Aaro Koskinen , Tony Lindgren , Richard Weinberger , Mark Brown , Liam Girdwood , Linux Kernel Mailing List , Peter Ujfalusi , Boris Brezillon , Tomi Valkeinen , "open list:MEMORY TECHNOLOGY..." , linux-arm Mailing List , linux-input , Linux OMAP Mailing List , Jarkko Nikula Subject: Re: [alsa-devel] [PATCH 5/6] mtd: rawnand: ams-delta: use GPIO lookup table Message-ID: <20180521205711.GA74396@dtor-ws> References: <20180518210954.29044-1-jmkrzyszt@gmail.com> <20180520192705.GA12883@lenoch> <20180520200822.GA119427@dtor-ws> <19579964.NkVAqtTb47@z50> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <19579964.NkVAqtTb47@z50> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 21, 2018 at 10:21:46PM +0200, Janusz Krzysztofik wrote: > On Sunday, May 20, 2018 10:08:22 PM CEST Dmitry Torokhov wrote: > > On Sun, May 20, 2018 at 09:27:05PM +0200, Ladislav Michl wrote: > > > On Sat, May 19, 2018 at 11:55:51PM +0200, Janusz Krzysztofik wrote: > > > > On Saturday, May 19, 2018 8:00:38 PM CEST Andy Shevchenko wrote: > > > > > On Sat, May 19, 2018 at 2:15 AM, Janusz Krzysztofik > > > > > > > > > > > > > wrote: > > > > > > On Friday, May 18, 2018 11:21:14 PM CEST Andy Shevchenko wrote: > > > > > >> On Sat, May 19, 2018 at 12:09 AM, Janusz Krzysztofik > > > > > >> > > > > > >> wrote: > > > > > >> > + gpiod_rdy = devm_gpiod_get_optional(&pdev->dev, "rdy", > > > > > >> > GPIOD_IN); > > > > > >> > + if (!IS_ERR_OR_NULL(gpiod_rdy)) { > > > > > >> > > > > > >> So, is it optional or not at the end? > > > > > >> If it is, why do we check for NULL? > > > > > > > > > > > > As far as I can understand, nand_chip->dev_ready() callback is > > > > > > optional. > > > > > > That's why I decided to use the _optional variant of > > > > > > devm_gpiod_get(). In > > > > > > case of ams-delta, the dev_ready() callback depends on availability > > > > > > of > > > > > > the 'rdy' GPIO pin. As a consequence, I'm checking for both NULL and > > > > > > ERR > > > > > > in order to decide if dev_ready() will be supported. > > > > > > > > > > > > I can pretty well replace it with the standard form and check for > > > > > > ERR only > > > > > > if the purpose of the _optional form is different. > > > > > > > > > > NULL check in practice discards the _optional part of gpiod_get(). So, > > > > > either you use non-optional variant and decide how to handle an > > > > > errors, or user _optional w/o NULL check. > > > > > > > > OK, I'm going to use something like the below while submitting v2: > > > > > > > > - gpiod_rdy = devm_gpiod_get_optional(&pdev->dev, "rdy", GPIOD_IN); > > > > - if (!IS_ERR_OR_NULL(gpiod_rdy)) { > > > > - this->dev_ready = ams_delta_nand_ready; > > > > - } else { > > > > - this->dev_ready = NULL; > > > > - pr_notice("Couldn't request gpio for Delta NAND ready.\n"); > > > > + priv->gpiod_rdy = devm_gpiod_get_optional(&pdev->dev, "rdy", > > > > + GPIOD_IN); > > > > + if (IS_ERR(priv->gpiod_rdy)) { > > > > + err = PTR_ERR(priv->gpiod_nwp); > > > > > > ??? --------------------------------^^^^^^^^^ > > > > > > > + dev_warn(&pdev->dev, "RDY GPIO request failed (%d)\n", err); > > > > + goto err_gpiod; > > > > > > Driver will just use worst case delay instead of RDY signal, so this > > > is perhaps too strict. I will work with degraded performance. > > > > If RDY signal is not available then the board should not define it. > > Degrading performance and having users wondering because RDY is > > sometimes not available is not great. Especially if we get -EPROBE_DEFER > > here. > > Hi, > > I'm a bit lost after your comments. > > As far as I can read the code of gpiod_get_optional and underlying functions, > if a board doesn't define the "rdy" pin in a respective lookup table, the > function returns NULL and the device gets a chance to work in degraded mode. > > NULL may also happen if the driver probes the device before the lookup table > is added. In that case other non-optional pin requests fail with -ENOENT, the > probe is deferred and the device gets a chance to probe successfully in > late_init if the table is added but fails if not. > > If the pin is defined but GPIO device providing that pin is not available > (-ENODEV), the probe is initially deferred and may succeed in late_init if the > GPIO device appears but fails otherwise. > > Isn't that behavior acceptable, close enough to the expected even if not > strictly because of that -EPROBE_DEFER? Yes, this is correct. I was responding to the comment that erroring out in "if (IS_ERR(priv->gpiod_rdy))" branch is too strict. My assertion that it is not. If a board defines RDY pin we should use it and not try to degrade to lower performance mode. Thanks. -- Dmitry