From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752754AbdLEPEX (ORCPT ); Tue, 5 Dec 2017 10:04:23 -0500 Received: from conssluserg-02.nifty.com ([210.131.2.81]:49611 "EHLO conssluserg-02.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752413AbdLEPET (ORCPT ); Tue, 5 Dec 2017 10:04:19 -0500 X-Greylist: delayed 38810 seconds by postgrey-1.27 at vger.kernel.org; Tue, 05 Dec 2017 10:04:18 EST DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com vB5F4Aga014618 X-Nifty-SrcIP: [209.85.217.180] X-Google-Smtp-Source: AGs4zMZSPu146Ios7op0puFqG/yLk/IN7kkX6pc895klWDkOxehwWInBNYpLW90uuvKGIFHtcr3FLkFObLMCL4/4wo4= MIME-Version: 1.0 In-Reply-To: <20171204151320.4ypa2y5r335hcg7j@ninjato> References: <1511540697-27387-1-git-send-email-yamada.masahiro@socionext.com> <1511540697-27387-11-git-send-email-yamada.masahiro@socionext.com> <20171204151320.4ypa2y5r335hcg7j@ninjato> From: Masahiro Yamada Date: Wed, 6 Dec 2017 00:03:29 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 10/22] mmc: tmio: support IP-builtin card detection logic To: Wolfram Sang Cc: linux-mmc , Wolfram Sang , Simon Horman , Yoshihiro Shimoda , linux-renesas-soc@vger.kernel.org, Linux Kernel Mailing List , Ulf Hansson Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2017-12-05 0:13 GMT+09:00 Wolfram Sang : >> +static int tmio_mmc_get_cd(struct mmc_host *mmc) >> +{ >> + struct tmio_mmc_host *host = mmc_priv(mmc); >> + int ret; >> + >> + ret = mmc_gpio_get_cd(mmc); >> + if (ret >= 0) >> + return ret; >> + >> + return !!(sd_ctrl_read16_and_16_as_32(host, CTL_STATUS) & >> + TMIO_STAT_SIGSTATE); >> +} I just followed tmio_mmc_get_ro() implementation. If we do not care the symmetry between _get_ro() and _get_cd() hooks, yes, your suggestion makes sense. > I wonder if we shouldn't do something like: > > if (mmc_can_gpio_cd()) > return mmc_gpio_get_cd() > else > return !!(sd_ctrl_read16_and_16_as_32...) > > If we have a GPIO CD defined, I think we want the value of > mmc_gpio_get_cd() in all cases. It makes clearer that this is an > 'either-or' case and not a fallback mechanism. > Another possibility would select this in _probe(). We would need to evaluate mmc_can_gpio_cd() only once when probing. I will follow your suggestion, though. Either way is fine with me. static int tmio_mmc_get_cd(struct mmc_host *mmc) { struct tmio_mmc_host *host = mmc_priv(mmc); return !!(sd_ctrl_read16_and_16_as_32(host, CTL_STATUS) & TMIO_STAT_SIGSTATE); } static const struct mmc_host_ops tmio_mmc_ops = { ... .get_cd = tmio_mmc_get_cd, ... }; int tmio_mmc_host_probe( ... ) { .... /* replace get_cd hook when we use GPIO for card detection */ if (mmc_can_gpio_cd(mmc)) _host->ops.get_cd = mmc_gpio_get_cd; } -- Best Regards Masahiro Yamada