From patchwork Tue Nov 7 08:09:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 118119 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3685904qgn; Tue, 7 Nov 2017 00:11:15 -0800 (PST) X-Google-Smtp-Source: ABhQp+QTmy48/XjazGuE9hEKTFxYyC/Gu76+cQjKD3vPoTs4aR2C8nSBWs8/sngf6KliuUY9BWtG X-Received: by 10.159.235.147 with SMTP id f19mr17399455plr.42.1510042275416; Tue, 07 Nov 2017 00:11:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510042275; cv=none; d=google.com; s=arc-20160816; b=oprDXoOAfDjzCb+Vbo23HS+hogXkZ8nKt7gLDk82bDl/FQujXnne1loQNg+FbswbZ7 09EI+b3z51KA6Cfgmv7cHaXuxnEFF5UDYI7x1PSS5QNqcpvzlTguiTEzwvnGLjEASJEF DM9KllOhUEnnw7ZEcROkqlKBwVknppviur/LIGmvgtPuEbcayL6AtZUHwWXn8nMZ50Cs ltDxZ8qCs5iHQaGXrPcXV5yTcmx8JDnIJvNV85dp9prVVgL01I91QrjH/2wLn0zVjZlZ V3Sx9fV5hpXUb0oaEM7+gSpNE/OpGBVz9c9Dh8YSyW0EjyQ94RhLZskvRwfA+uW9HJHs C63A== 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=INAJOaawGKkfHGq22YsS3yh4bPVyazEPnngjscbfTwY=; b=A+cfL8ePec9vmxLo+139CY4VbtMasxkqc5hmoaV/8ijE3ItRw9OmX+Vo6ZB4MS6o1T d/SDecyg25IRS/Dn+1Q1ceb+3+BI2fJfIVFx1Xc53PJvpxMYR4WGPMUneW7tm2mod3DX lnxNCgETeTds3RZmWuyU4r79FB2fRLZdz29Fd0vD7HRUMk6IG9EQy1u++XafOmfmFfcl Pme2pXX0c79uOJFSkRLoFlyUQTuvVae0tyf1deh3Qp7JMStpBWxRqJO7KZFsyAWPU8Fn m8GFkps5fPo0hNTfEfJr/w7eBkrGP2kUrkreL37heZKfEEuGmorbXrlM76jm7nytoLPu /AKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=1mHPHa+M; 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 n73si639753pfb.254.2017.11.07.00.11.15; Tue, 07 Nov 2017 00:11:15 -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=1mHPHa+M; 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 S932699AbdKGILN (ORCPT + 26 others); Tue, 7 Nov 2017 03:11:13 -0500 Received: from conuserg-09.nifty.com ([210.131.2.76]:24937 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932525AbdKGIKz (ORCPT ); Tue, 7 Nov 2017 03:10:55 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id vA789u4M027191; Tue, 7 Nov 2017 17:09:59 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com vA789u4M027191 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1510042200; bh=INAJOaawGKkfHGq22YsS3yh4bPVyazEPnngjscbfTwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1mHPHa+M+icTsvQk2ZxPqZUC7YfoOV95NfOsSgcoTN3YxJb0RyieJfO6ZSwjAIFyl 8atzBQOmiOs/vMF89Qew/OX7Mq2UVRuJBJY6c0vmEu+jnBWPfU/lYkUnXnIzw7s7v4 DPBzOGKwy04Yz9xHIOJVqrSIz6YJKb7oGarRgEv7Lo8I92n7Sd3oiimWSkiZHgABl3 6UwLlpnFOxIo8nWJrc243ZivKOLsechzNA+7No0rfexZhlJbsG96NeAOWHvsVADAso lSZZWT4OWYuZAeMP/OzLd/nyfMrkf/IP0RgFLK8wA518EaEd9X1FxzdQjBU2SRej+6 8P6wnRa8O1TNQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Wolfram Sang , linux-mmc@vger.kernel.org Cc: Simon Horman , Yoshihiro Shimoda , Masahiro Yamada , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 4/6] mmc: tmio: move mmc_host_ops to struct tmio_mmc_host from static data Date: Tue, 7 Nov 2017 17:09:30 +0900 Message-Id: <1510042172-27220-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510042172-27220-1-git-send-email-yamada.masahiro@socionext.com> References: <1510042172-27220-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 Currently, tmio_mmc_ops is static data and tmio_mmc_host_probe() updates some hooks in the static data. This is a problem when two or more instances call tmio_mmc_host_probe() and each of them requests to use its own card_busy/start_signal_voltage_switch. We can borrow a solution from sdhci_alloc_host(). Copy the whole ops structure to host->mmc_host_ops, then override the hooks in malloc'ed data. Constify tmio_mmc_ops since it is a template ops used by default. Signed-off-by: Masahiro Yamada --- drivers/mmc/host/tmio_mmc.h | 1 + drivers/mmc/host/tmio_mmc_core.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) -- 2.7.4 Reviewed-by: Wolfram Sang Tested-by: Wolfram Sang diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index 3e6ff89..b251f1c 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h @@ -134,6 +134,7 @@ struct tmio_mmc_host { struct mmc_request *mrq; struct mmc_data *data; struct mmc_host *mmc; + struct mmc_host_ops mmc_host_ops; /* Callbacks for clock / power control */ void (*set_pwr)(struct platform_device *host, int state); diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 0db6cac..3c84044 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1098,7 +1098,7 @@ static int tmio_multi_io_quirk(struct mmc_card *card, return blk_size; } -static struct mmc_host_ops tmio_mmc_ops = { +static const struct mmc_host_ops tmio_mmc_ops = { .request = tmio_mmc_request, .set_ios = tmio_mmc_set_ios, .get_ro = tmio_mmc_get_ro, @@ -1155,6 +1155,8 @@ tmio_mmc_host_alloc(struct platform_device *pdev) host = mmc_priv(mmc); host->mmc = mmc; host->pdev = pdev; + host->mmc_host_ops = tmio_mmc_ops; + mmc->ops = &host->mmc_host_ops; return host; } @@ -1200,10 +1202,9 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host, if (ret < 0) return ret; - tmio_mmc_ops.card_busy = _host->card_busy; - tmio_mmc_ops.start_signal_voltage_switch = + _host->mmc_host_ops.card_busy = _host->card_busy; + _host->mmc_host_ops.start_signal_voltage_switch = _host->start_signal_voltage_switch; - mmc->ops = &tmio_mmc_ops; mmc->caps |= MMC_CAP_4_BIT_DATA | pdata->capabilities; mmc->caps2 |= pdata->capabilities2;