Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp730679imm; Mon, 21 May 2018 13:22:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpsEFtSNtTUSrxYXJg8WgftOndPtgJOB7TDs58+VoQppCeY8zK62AGP33u9ltz+UkJmcO9z X-Received: by 2002:a17:902:52ed:: with SMTP id a100-v6mr21867966pli.131.1526934123642; Mon, 21 May 2018 13:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526934123; cv=none; d=google.com; s=arc-20160816; b=J7V8Ius4W2PAalHbi8aqzG1vv1Rg9UTyQ5y7f9TsUaA514DMlixCVYmtkTq8zsdj0S Pdw5ND++9g1LL+KzTf5PjvXA60YeU75ZORYojRDm8THiGhNmvHR3xCddL9gUk6iLf2ii WAsQVdmgoaS5FYeA7yTpMxNwi4V1Ul0VoRH6RsnOOQxweJeVX5GW8SGIxHOH1CpocGMF 0BqO03RHxv8D4eXqUeinREzsBs3m/o8QbGMePZSUHpUUBb+oVierVjZ5jst1vuWuMAQH cKxVXJYKOoqc22IXSZ9LlJmbGA49AhZBpZbjaRLGFfmE4vbDz/8IKMXiR8KsXLsJDn74 A9SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=GfCJSTbNkb8XwD19nReuyl7/8Sy1DTnzAS474SYSukE=; b=SUMRnOZocuDbZgcrin2ar8Z9D8fJqS0oKd8VLQx+iKC01Bas4JlyLXhH22tD/RXVJf K57IW3GdCNn/ztSH83wR5Oih2amBjyvFNQ97SkJYYh3LAu7Ubv06r8tt3qDXlAM8Q5td 9S2seqvQk1RlgByF+WHFYmYikTuL5gvWcTEj++NbQiGOhW8BPFcrCXwUzHwjYZST6cer mBAZLjUrKcZrrj42OON2eq5N7vASDHZ5mFLn0qJS0zpbPiFgHl5KmhfcQ8WcfoG7DMmc i8adeUZJ3O7Mvl/EGAQMRgrmzKmJQ2n+I/jtR0VL6z9v6RFqtSptT7GYerlqR4aGyOMP a1Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=I/kqqyIb; 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 z7-v6si11484728pgv.614.2018.05.21.13.21.48; Mon, 21 May 2018 13:22:03 -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=I/kqqyIb; 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 S1751087AbeEUUVj (ORCPT + 99 others); Mon, 21 May 2018 16:21:39 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:37591 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750778AbeEUUVg (ORCPT ); Mon, 21 May 2018 16:21:36 -0400 Received: by mail-lf0-f67.google.com with SMTP id r2-v6so25779373lff.4; Mon, 21 May 2018 13:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GfCJSTbNkb8XwD19nReuyl7/8Sy1DTnzAS474SYSukE=; b=I/kqqyIbP0g7qfMUgG87BCEAHvJ7lm7pT/CajX8oQXvHjq7hD6YrB6CAA/IrL5/elw 6Vfww6+qjE1AMElyMjT3C1PXmkD4tf1luRgMiGtyNYyfx8MHt3Iz1E0Zp7b2xwcJURJn DFEoRPg30WTmdoXHXVXcetDRr2UOdwyXmiZIp6xDZV5P9VAqcbMaLPW+TKkqhX9+3mU7 vpD+/6P6o/SJyEFTVHOmeLwOLBkUssvXgnQsoltxsIytS5znnEytLuc+RtGG3kWS9kDK /JP4xDdWbZLRJSJ64Lx96ePMBPIg/78fvB3Kg7Ya7PtZQABOQIEhcpG4COcCgOJi70O/ 6Pjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GfCJSTbNkb8XwD19nReuyl7/8Sy1DTnzAS474SYSukE=; b=Fc1xYNqCf8dRlrbipMkGChy31xRVpjJPeZvZ2C7P1RejT39gbIcJbv+PxkQqvWlx6A cLtNj72mWOlESuAlZuD5Cnol+yWUqGZy4wKpPR9D7cgpPawqxX3zDpbJkC/lOENqY6IS qCjWBLOL8jPxm+vQF4WtkqbX6PyayR6RBrrDnHpODjkN5w0BbhJO0KZw9VnDVhUBkhV/ QgsMVxQA1oIQrMCO2mjMjko7GJsRAKQSbNysdvcjTd/MAHmzirsHVfICz8k/AJMKslIU s9Anc5FeOKmvspdqpjIYZS9UE94n4RA1wGjnMh6LMqs+HltDy5ImETBTc0Xs/lmh/9Va sCOw== X-Gm-Message-State: ALKqPwdk7m1eB+2wwMeHbVZa5eqxGM71EeV2Ft8AbWynOXKE3h9dlczZ 8INQ2KjeT82HSSHSgpPh68w= X-Received: by 2002:a19:a591:: with SMTP id o139-v6mr29490549lfe.146.1526934094727; Mon, 21 May 2018 13:21:34 -0700 (PDT) Received: from z50.localnet (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id m81-v6sm3592179lfi.1.2018.05.21.13.21.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 13:21:33 -0700 (PDT) From: Janusz Krzysztofik To: Dmitry Torokhov 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 Date: Mon, 21 May 2018 22:21:46 +0200 Message-ID: <19579964.NkVAqtTb47@z50> In-Reply-To: <20180520200822.GA119427@dtor-ws> References: <20180518210954.29044-1-jmkrzyszt@gmail.com> <20180520192705.GA12883@lenoch> <20180520200822.GA119427@dtor-ws> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Thanks, Janusz