From patchwork Mon Dec 12 19:51:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 9471139 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 56D9C60476 for ; Mon, 12 Dec 2016 19:51:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40456284BD for ; Mon, 12 Dec 2016 19:51:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F459284F0; Mon, 12 Dec 2016 19:51:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF5D5284BD for ; Mon, 12 Dec 2016 19:51:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753025AbcLLTvu (ORCPT ); Mon, 12 Dec 2016 14:51:50 -0500 Received: from www.zeus03.de ([194.117.254.33]:41890 "EHLO mail.zeus03.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752801AbcLLTvs (ORCPT ); Mon, 12 Dec 2016 14:51:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references; s=k1; bh=7z2K3Os0paX47hcj+FQHFasPHvJM7EH7PNSeAVttQLk=; b=kmOleFl6Y2qu ouacjNXXALjYi24gcmrgCQb1H5ihH3+hJ65yZSY1JHQ8I0dWDcgxyqgwpAUMCzZZ B/jT+tEYxbOMvoaxnUoCkwVjTWLPKnwveZ45c1OjxmtP31fckoz7fpkaaHkzDbJk KggulvWsne/l102N8h8KcsRd0sOKMyM= Received: (qmail 2237 invoked from network); 12 Dec 2016 20:51:47 +0100 Received: from p54b33eed.dip0.t-ipconnect.de (HELO localhost) (l3s3148p1@84.179.62.237) by mail.zeus03.de with ESMTPSA (ECDHE-RSA-AES256-GCM-SHA384 encrypted, authenticated); 12 Dec 2016 20:51:47 +0100 From: Wolfram Sang To: linux-mmc@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Simon Horman , Wolfram Sang Subject: [PATCH 3/9] mmc: sh_mobile_sdhi: improve prerequisites for tuning Date: Mon, 12 Dec 2016 20:51:22 +0100 Message-Id: <20161212195128.16633-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161212195128.16633-1-wsa+renesas@sang-engineering.com> References: <20161212195128.16633-1-wsa+renesas@sang-engineering.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Prerequisites for tuning are the same as for hw_reset. We need an SCC and a supported mode. Populate the tuning related functions only when those conditions are met. This also removes a tiny race window. Previously, the functions were populated when the SCC offset was not initialized which could have led to an OOPS. Signed-off-by: Wolfram Sang --- drivers/mmc/host/sh_mobile_sdhi.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index f3ea2c8b12040c..96ebe985d5cdc6 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c @@ -611,11 +611,6 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) host->card_busy = sh_mobile_sdhi_card_busy; host->start_signal_voltage_switch = sh_mobile_sdhi_start_signal_voltage_switch; - host->init_tuning = sh_mobile_sdhi_init_tuning; - host->prepare_tuning = sh_mobile_sdhi_prepare_tuning; - host->select_tuning = sh_mobile_sdhi_select_tuning; - host->check_scc_error = sh_mobile_sdhi_check_scc_error; - host->hw_reset = sh_mobile_sdhi_hw_reset; } /* Orginally registers were 16 bit apart, could be 32 or 64 nowadays */ @@ -656,6 +651,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) if (ret < 0) goto efree; + /* Enable tuning iff we have an SCC and a supported mode */ if (of_data && of_data->scc_offset && host->mmc->caps & MMC_CAP_UHS_SDR104) { const struct sh_mobile_sdhi_scc *taps = of_data->taps; bool hit = false; @@ -675,6 +671,11 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) dev_warn(&host->pdev->dev, "Unknown clock rate for SDR104\n"); priv->scc_ctl = host->ctl + of_data->scc_offset; + host->init_tuning = sh_mobile_sdhi_init_tuning; + host->prepare_tuning = sh_mobile_sdhi_prepare_tuning; + host->select_tuning = sh_mobile_sdhi_select_tuning; + host->check_scc_error = sh_mobile_sdhi_check_scc_error; + host->hw_reset = sh_mobile_sdhi_hw_reset; } i = 0;