From patchwork Wed Jan 17 16:28:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 124853 Delivered-To: patch@linaro.org Received: by 10.46.62.1 with SMTP id l1csp107586lja; Wed, 17 Jan 2018 08:41:40 -0800 (PST) X-Google-Smtp-Source: ACJfBovYkZ2UdRawBVveWwWasAWpX+Bxzj2ihxpioHbSR8OurWJfIva3S+XCAgyXp4bPtO6x+U4Z X-Received: by 10.99.96.210 with SMTP id u201mr32896844pgb.248.1516207300781; Wed, 17 Jan 2018 08:41:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516207300; cv=none; d=google.com; s=arc-20160816; b=maGGWqDlmzmOdZpyOXLj7KZT8EqQkaBvR/dwF3Ovcr7buF0GQICVJ5v4fhaoLBhJ0T YFsvn3frdypj0LQji5Nx2ra+2kCDiPlmNGXVfd80zaou2V/XRPobrd++n+Zphew72Z4t BhNCZjtpqNziKdLwsLK7U/KrCv+w9yJgJk+nrYVVWQPKiCCueCN/tC+kJ/PASPCmWyS1 UpMJmFwvW/jgzUXj8Vl8T6pRYCKMhCd+bRGxGHypEp3ci3zLM6Vh3IhgsSmlSi1AGvfk FiaqH5uV7wE0Q8IlPLFrY9492li2ryFq/SqXRPfr8ef+Q8U2pVge8GGfNivouM6wMZNx 1Wug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=wH/PHfL4hb/LgN7K8zg1Hwzn9h5eS6SMZaKfIThz8M8=; b=BNNNoOHdI4R49fZjtnOeYoA9dqTK93Ag1NRJtMex21MXVlj1wCsfvMIp/opgL3B5T4 Ai4a4vl7EDFza9TS2ZLVB4iKtEzX1pdHEZQw56qrI+1GtbM+eBIRtO/XnY4WixO4Isjt 6ISbfd4aOe5USLtZ05CufnKF8AKJrUFTfAo/RuMjb8Xr/wd5ZyCfLocNKKrD3kviMOf8 8yZ3JWxuSdzKDnxao3CyG0WNhCCZMW1PD/LXiddvxOYyxSp4BTcKFbBzJ4zXLRD63H9P nxwCFdFLQdo/cX7E+dHOb0s73G2lNBYKC8ESnO0F0jQlcFTklrs5gOKyKo4/0S95mVHF z4Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=K7l0hANE; 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 l22si4686060pfb.353.2018.01.17.08.41.40; Wed, 17 Jan 2018 08:41:40 -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; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=K7l0hANE; 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 S1754393AbeAQQlY (ORCPT + 28 others); Wed, 17 Jan 2018 11:41:24 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:36689 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753839AbeAQQ3d (ORCPT ); Wed, 17 Jan 2018 11:29:33 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-08.nifty.com with ESMTP id w0HGSIKq014790; Thu, 18 Jan 2018 01:28:24 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w0HGSIKq014790 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1516206505; bh=wH/PHfL4hb/LgN7K8zg1Hwzn9h5eS6SMZaKfIThz8M8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K7l0hANEXhXajSrSu+PZyRkCSngaYuQC3UgloMXZ8EP8HOGeGcQlu6xYCHbO3i6R9 LyNsFQCzls6E3YOR26D8xUw0S45TbPUi4dSo0f2UxzFlS34tlRlOJ8lvTRYzSQbLNI VJKjgWSf7Er3/jmIUXEsNjowZ3ch2l8v5zWH9YfuDDPH5CtAbXibcG0ySfdgDbMl4+ DsCqCc5fS7xkrcSMrtGvhE1LmSpPzO5C52K6O2IaWbs9MZXduV2Xnby3h8bHNJBAMX xddpBBV80zeovs1ZmOkxeJq4AG3iVQmL8Vs/nmRwHnQsNFeGmkDppAr4WCg0ipVBEb 8H5ALEOORh5Ug== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-mmc@vger.kernel.org, Wolfram Sang Cc: Ulf Magnusson , Geert Uytterhoeven , Simon Horman , Yoshihiro Shimoda , linux-renesas-soc@vger.kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 06/16] mmc: tmio: refactor .get_ro hook Date: Thu, 18 Jan 2018 01:28:06 +0900 Message-Id: <1516206496-16612-7-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516206496-16612-1-git-send-email-yamada.masahiro@socionext.com> References: <1516206496-16612-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This IP provides the write protect signal level in the status register, but it is also possible to use GPIO for WP. They are exclusive, so it is not efficient to call mmc_gpio_get_ro() every time from tmio_mmc_get_ro() if we know gpio_ro is not used. Check the capability of gpio_ro just once in the probe function, then set mmc_gpio_get_ro to .get_ro if it is the case. Signed-off-by: Masahiro Yamada --- Changes in v3: - newly added Changes in v2: None drivers/mmc/host/tmio_mmc_core.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index d092b0f..0032707 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1076,15 +1076,9 @@ static int tmio_mmc_get_ro(struct mmc_host *mmc) { struct tmio_mmc_host *host = mmc_priv(mmc); struct tmio_mmc_data *pdata = host->pdata; - int ret = mmc_gpio_get_ro(mmc); - if (ret >= 0) - return ret; - - ret = !((pdata->flags & TMIO_MMC_WRPROTECT_DISABLE) || - (sd_ctrl_read16_and_16_as_32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT)); - - return ret; + return !((pdata->flags & TMIO_MMC_WRPROTECT_DISABLE) || + (sd_ctrl_read16_and_16_as_32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT)); } static int tmio_multi_io_quirk(struct mmc_card *card, @@ -1247,6 +1241,9 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) } mmc->max_seg_size = mmc->max_req_size; + if (mmc_can_gpio_ro(mmc)) + _host->ops.get_ro = mmc_gpio_get_ro; + _host->native_hotplug = !(mmc_can_gpio_cd(mmc) || mmc->caps & MMC_CAP_NEEDS_POLL || !mmc_card_is_removable(mmc));