Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1163479imu; Wed, 16 Jan 2019 13:58:04 -0800 (PST) X-Google-Smtp-Source: ALg8bN7yI7sySwPx2iZ8XqoLQz76IOYJhYM71INKTPJ70a38/Q9MwzYjJATFT6kYNTHWBCH0x32C X-Received: by 2002:a63:7306:: with SMTP id o6mr10673926pgc.343.1547675884294; Wed, 16 Jan 2019 13:58:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547675884; cv=none; d=google.com; s=arc-20160816; b=S0N+TsuAwcPGwRidwKMD2u2whVtIEVjNh3rWS2h1RihgrYz3G+PkFfasMpJSbaNZu8 LYYUMTPZryAnoGAOFLYAzExb7r6zLXKW59P7wHsuR9Qltc7t/cQgivfjBfrHnwPOYYkr 8oCJymDw8WtN2N1apl78s+RuzkmlI78cdEBMl1Zvmo1ODAmcEWpUDBd+sY7bqrLYoVrc x+Coz+69SaHPbpEcbZCLIVVGstJ/FpxLwQm+wAcH0Rbt8BIKC8MfWtMktkf9U/lj8VA+ X5nR1W3fgAfPKIwolKUvrRMqCXhrA2vYDuC6aDivbv/3hKfSYdiIMl1ZvrW9+1hrF4Pb 23sg== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=XiwHPPVW9pKbQq8bsy6vvG34GjMokIlbXkiIDeCTNAQ=; b=JDBON9M7ozqEApmRA/mNfNv2MyY6JBkhGa0HAn2rvm9/G54P6lkerW9R2VD4IwIcY8 Wb4eOk4N2jictdDEaGtM78kS3V6tvTWpVqhckHluMrVzI+j85VZjUKQLwOrguP35S6Td +80yvSE5fwigp7Md5PpNKR7n0DOEAV+EY5DDZBhlGSf/b1JOcXTvKyz5+8ZoOPb6neor 51FVEy4iI7XCQRTZYE7rKlzSZ1TBOrT0uAHSNWaxy6WtZHjCKFavl7DwwvXdS0+ot7jq Z2ISPKbwkekpL1Dt5yPu/+Vx/HZo/aaq7Bik5FnSmpGhz27ljjC6qAZ8VPQQQFf8DMQY Ci7w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p17si7374323pfk.275.2019.01.16.13.57.49; Wed, 16 Jan 2019 13:58:04 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393121AbfAPNUp (ORCPT + 99 others); Wed, 16 Jan 2019 08:20:45 -0500 Received: from mail.bootlin.com ([62.4.15.54]:59122 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731240AbfAPNUo (ORCPT ); Wed, 16 Jan 2019 08:20:44 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id F08DB20955; Wed, 16 Jan 2019 14:20:41 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from windsurf (aaubervilliers-681-1-37-87.w90-88.abo.wanadoo.fr [90.88.156.87]) by mail.bootlin.com (Postfix) with ESMTPSA id A2731207AC; Wed, 16 Jan 2019 14:20:31 +0100 (CET) Date: Wed, 16 Jan 2019 14:20:31 +0100 From: Thomas Petazzoni To: Adrian Hunter Cc: Kishon Vijay Abraham I , Ulf Hansson , Thierry Reding , Jonathan Hunter , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, Gregory Clement Subject: Re: [PATCH 1/3] mmc: sdhci: use WP GPIO in sdhci_check_ro() Message-ID: <20190116142031.54bc0f9a@windsurf> In-Reply-To: References: <20190115162837.5399-1-thomas.petazzoni@bootlin.com> <20190115162837.5399-2-thomas.petazzoni@bootlin.com> Organization: Bootlin X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Adrian, On Wed, 16 Jan 2019 14:59:32 +0200, Adrian Hunter wrote: > > The below patch simply changes sdhci_check_ro() to use the value of > > the WP GPIO if available. We need to adjust the prototype of the > > function to use a mmc_host* as argument instead of sdhci_host*, since > > the mmc_can_gpio_ro() and mmc_gpio_get_ro() helpers take a mmc_host*. > > Why not just use host->mmc Could do that. I just found it weird that the calling function has the mmc_host structure, does some gymnastic to find sdhci_host, and then in the called function, we do the opposite gymnastic to find mmc_host from sdhci_host. But if that's the preference, I'm happy to change the patch accordingly. > > if (host->flags & SDHCI_DEVICE_DEAD) > > is_readonly = 0; > > + else if (mmc_can_gpio_ro(mmc)) > > + is_readonly = mmc_gpio_get_ro(mmc); > > Perhaps host->ops->get_ro should be checked before mmc_can_gpio_ro()? That is actually a good point, using ->get_ro() should come before using the GPIO. Indeed, some drivers may potentially have a ->get_ro with custom logic *and* a WP GPIO, and in this case, we want ->get_ro to take precedence. I'll send a v2 with this, once you let me know your decision about the previous point. Thanks, Thomas -- Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com