From patchwork Fri Nov 24 16:24:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 119613 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2447239qgn; Fri, 24 Nov 2017 08:30:41 -0800 (PST) X-Google-Smtp-Source: AGs4zMYJ2aILKDrtsrEcUt4qID6BudhWFHoZoWaUXgLaWXtSy5auLgDpojh1746OCvafb35GgfHH X-Received: by 10.84.217.2 with SMTP id o2mr29356407pli.338.1511541041768; Fri, 24 Nov 2017 08:30:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511541041; cv=none; d=google.com; s=arc-20160816; b=N1a3uEkgLBoPDkGOOj7QDDeEizW0qA4KOVixMZ2nPDI4KY2g1xi9RdNbu2gIGi+KyV BeIWyHX1YsLjjsOEOvXnEWpdWlyjZuU2TQeczcp2gwxjrPXtMeriWKMRQd+Hr/c3UnSj S+WHdjw9I2zNvc3+md4JiDvSQHdPz7LIeyHn/7rjurFbyXXLbPcGoihIepSaRO4TFOP1 07mZE6briU63Z6G34fUCWcA4q49MHoxdZqSwK5cOd+mcezamYwhlKsakw1f5lHVKpim6 OrdjtUij6JJNo+0ikAzfrIH4X0c8EsHjR5rqUX6SN3M4IX0RAFcYZxvBV2SyBU3G7Y13 qiEA== 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=/E6/PZuAK/B1YhoA74t3FXm2eN+o/w6GynzTGbcmx4g=; b=UVL4N2LJ9Ip6jqM6JV0FUcEufEQSSa0c5HgX6CBHxQz7r69BsKzS7jTqanfYixhZ2o J7MjSXo3yImampr6/Pm7335l8ZqLnJNN0VFE/42FQmxYfzgxwTr9J/sUcbOcOJEbp9yD 4SLR9GDHX+grNwMNGLTUpMGYkXgDiJBWug10mtaygvo86AOis2bi0wZGypWaqLKemclL B6s9aXw4+2ZHBQbceP0NcZZ2+Z6gqQhazd11seZ/5cyoaQ2TrNHV3QwgM/LyAihIgs30 AEoyaBQ09fMKUseyoiAYhDFMcwZGTQDYlg5l5/udqDpm3RZKYPZCXxXuZAmCA13MtIex gY2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=0Bs2vydU; 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 n2si18330057pgv.530.2017.11.24.08.30.41; Fri, 24 Nov 2017 08:30:41 -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=0Bs2vydU; 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 S1753973AbdKXQak (ORCPT + 28 others); Fri, 24 Nov 2017 11:30:40 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:61481 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753751AbdKXQ0B (ORCPT ); Fri, 24 Nov 2017 11:26:01 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-11.nifty.com with ESMTP id vAOGP9Vq007100; Sat, 25 Nov 2017 01:25:14 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com vAOGP9Vq007100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1511540715; bh=/E6/PZuAK/B1YhoA74t3FXm2eN+o/w6GynzTGbcmx4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Bs2vydUc85TzVr8HjSBz4nCu8PRX+tKf+/KW59pqmfoTWZoG4fUqw3omdcAWAf+K i2uDrw05sqzZOayauvw86ZyL2posU9BeVunsP1Yn3fBJq/ZmPIVXqKyPQKqLRn+a0S 4W6jvBE8EPeuasdVHANhBXJqLmxhcLAB0oTHMgsDuRU2eIfDQIdbN7Eu6S7yMC8fpE w9VMyeqCRZOVjDOQG6d+ogdTD9L+F9oBjbaP0Wsj1Y5Kmb/d6y3BrqcaJ/CIMhBAHB rdzoSwBrkluPRY0+69v58Ly74ruEjTDZFdcS7mz2EMPZAaIZnz6T5GNFMPeQn/UtGB yzWDjqeUOsXdg== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-mmc@vger.kernel.org, Wolfram Sang Cc: Simon Horman , Yoshihiro Shimoda , linux-renesas-soc@vger.kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 06/22] mmc: tmio: move mmc_host_ops to struct tmio_mmc_host from static data Date: Sat, 25 Nov 2017 01:24:41 +0900 Message-Id: <1511540697-27387-7-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511540697-27387-1-git-send-email-yamada.masahiro@socionext.com> References: <1511540697-27387-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 now a template ops used by default. Signed-off-by: Masahiro Yamada Reviewed-by: Wolfram Sang Tested-by: Wolfram Sang --- Changes in v2: - Rename "mmc_host_ops" to "ops" per Wolfram Sang 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 diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index 3e6ff89..4fdb51b 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 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 d3b7af9..af9ed6a 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, @@ -1158,6 +1158,8 @@ tmio_mmc_host_alloc(struct platform_device *pdev) host = mmc_priv(mmc); host->mmc = mmc; host->pdev = pdev; + host->ops = tmio_mmc_ops; + mmc->ops = &host->ops; return host; } @@ -1203,10 +1205,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->ops.card_busy = _host->card_busy; + _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;