From patchwork Tue Apr 14 11:54:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 47144 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5A7E32121F for ; Tue, 14 Apr 2015 11:54:27 +0000 (UTC) Received: by widjs5 with SMTP id js5sf3673583wid.3 for ; Tue, 14 Apr 2015 04:54:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:subject:date :message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=/j07gQyxQonILSuiWkps5Ad4CXhGDzFUk3ocFfa1qzM=; b=FmSCsz+4m7n6weH2Qbj1AG60Kkr4A8wq7nw9YMh8bfgmB8jsqlYzAsx9jDS9rNE/6F nL9BLMPMPDjr4qIk27Fgpu7GdfyUoyjMTa4YFO7m+JUqWTeCqE2NwNYog/XfP4dLKsMz R9WY+wjZpSVn9EfIzhppMVuyuMT/Sr/ZN3g18ZW1JjhzbBCabhEVcrxJbjLhvaLi+IRd dCFMH3vXn3J1z7uGBw5lx1EnvPR87QlQ8sdIOTK2IDBGUfy+Fo5LyYTkON5d1g32T7jL GRkiaGQ92mC1jeJ6Xv1ek3nYQARJMxJRL2a6k9cyzcja7ExpA01ZWv+2dVse7nuqPQIK z52g== X-Gm-Message-State: ALoCoQl90XDkO3PJNPhmObNzxA0lYy31vlDS3zGfhtZ3qMmAV7xCLCbB1TSGAeIPEo3b55D2BQBi X-Received: by 10.180.105.226 with SMTP id gp2mr2713822wib.1.1429012466694; Tue, 14 Apr 2015 04:54:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.67 with SMTP id o3ls29816laj.67.gmail; Tue, 14 Apr 2015 04:54:26 -0700 (PDT) X-Received: by 10.152.238.7 with SMTP id vg7mr17949094lac.3.1429012466539; Tue, 14 Apr 2015 04:54:26 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id f1si704593laa.117.2015.04.14.04.54.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Apr 2015 04:54:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by labbd9 with SMTP id bd9so5831929lab.2 for ; Tue, 14 Apr 2015 04:54:26 -0700 (PDT) X-Received: by 10.152.87.204 with SMTP id ba12mr18312849lab.35.1429012466413; Tue, 14 Apr 2015 04:54:26 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1808152lbt; Tue, 14 Apr 2015 04:54:25 -0700 (PDT) X-Received: by 10.152.120.106 with SMTP id lb10mr10482381lab.92.1429012465895; Tue, 14 Apr 2015 04:54:25 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id 2si703425lap.120.2015.04.14.04.54.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Apr 2015 04:54:25 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by lbbuc2 with SMTP id uc2so6101595lbb.2 for ; Tue, 14 Apr 2015 04:54:25 -0700 (PDT) X-Received: by 10.152.198.200 with SMTP id je8mr10099531lac.29.1429012465756; Tue, 14 Apr 2015 04:54:25 -0700 (PDT) Received: from uffe-Latitude-E6430s.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id oy3sm189495lbb.1.2015.04.14.04.54.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Apr 2015 04:54:24 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Subject: [PATCH] Revert "mmc: core: Convert mmc_driver to device_driver" Date: Tue, 14 Apr 2015 13:54:16 +0200 Message-Id: <1429012456-29648-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This reverts commit 6685ac62b2f0 ("mmc: core: Convert mmc_driver to device_driver") The reverted commit went too far in simplifing the device driver parts for mmc. Let's restore the old mmc_driver to enable driver core to sooner or later to remove the ->probe(), ->remove() and ->shutdown() callbacks from the struct device_driver. Note that, the old ->suspend|resume() callbacks in the struct mmc_driver don't need to be restored, since the mmc block layer has converted to the modern system PM ops. Fixes: 6685ac62b2f0 ("mmc: core: Convert mmc_driver to device_driver") Signed-off-by: Ulf Hansson --- drivers/mmc/card/block.c | 34 +++++++++++++++++----------------- drivers/mmc/card/mmc_test.c | 18 +++++++----------- drivers/mmc/core/bus.c | 41 +++++++++++++++++++++++++++++++++-------- include/linux/mmc/card.h | 14 ++++++++++++-- 4 files changed, 69 insertions(+), 38 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index c69afb5..e192bf1 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -2418,9 +2418,8 @@ static const struct mmc_fixup blk_fixups[] = END_FIXUP }; -static int mmc_blk_probe(struct device *dev) +static int mmc_blk_probe(struct mmc_card *card) { - struct mmc_card *card = mmc_dev_to_card(dev); struct mmc_blk_data *md, *part_md; char cap_str[10]; @@ -2445,7 +2444,7 @@ static int mmc_blk_probe(struct device *dev) if (mmc_blk_alloc_parts(card, md)) goto out; - dev_set_drvdata(dev, md); + dev_set_drvdata(&card->dev, md); if (mmc_add_disk(md)) goto out; @@ -2475,10 +2474,9 @@ static int mmc_blk_probe(struct device *dev) return 0; } -static int mmc_blk_remove(struct device *dev) +static void mmc_blk_remove(struct mmc_card *card) { - struct mmc_card *card = mmc_dev_to_card(dev); - struct mmc_blk_data *md = dev_get_drvdata(dev); + struct mmc_blk_data *md = dev_get_drvdata(&card->dev); mmc_blk_remove_parts(card, md); pm_runtime_get_sync(&card->dev); @@ -2489,15 +2487,13 @@ static int mmc_blk_remove(struct device *dev) pm_runtime_disable(&card->dev); pm_runtime_put_noidle(&card->dev); mmc_blk_remove_req(md); - dev_set_drvdata(dev, NULL); - - return 0; + dev_set_drvdata(&card->dev, NULL); } -static int _mmc_blk_suspend(struct device *dev) +static int _mmc_blk_suspend(struct mmc_card *card) { struct mmc_blk_data *part_md; - struct mmc_blk_data *md = dev_get_drvdata(dev); + struct mmc_blk_data *md = dev_get_drvdata(&card->dev); if (md) { mmc_queue_suspend(&md->queue); @@ -2508,15 +2504,17 @@ static int _mmc_blk_suspend(struct device *dev) return 0; } -static void mmc_blk_shutdown(struct device *dev) +static void mmc_blk_shutdown(struct mmc_card *card) { - _mmc_blk_suspend(dev); + _mmc_blk_suspend(card); } #ifdef CONFIG_PM_SLEEP static int mmc_blk_suspend(struct device *dev) { - return _mmc_blk_suspend(dev); + struct mmc_card *card = mmc_dev_to_card(dev); + + return _mmc_blk_suspend(card); } static int mmc_blk_resume(struct device *dev) @@ -2541,9 +2539,11 @@ static int mmc_blk_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(mmc_blk_pm_ops, mmc_blk_suspend, mmc_blk_resume); -static struct device_driver mmc_driver = { - .name = "mmcblk", - .pm = &mmc_blk_pm_ops, +static struct mmc_driver mmc_driver = { + .drv = { + .name = "mmcblk", + .pm = &mmc_blk_pm_ops, + }, .probe = mmc_blk_probe, .remove = mmc_blk_remove, .shutdown = mmc_blk_shutdown, diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c index 7dac469..53b7413 100644 --- a/drivers/mmc/card/mmc_test.c +++ b/drivers/mmc/card/mmc_test.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include /* For nr_free_buffer_pages() */ @@ -2996,9 +2995,8 @@ err: return ret; } -static int mmc_test_probe(struct device *dev) +static int mmc_test_probe(struct mmc_card *card) { - struct mmc_card *card = mmc_dev_to_card(dev); int ret; if (!mmc_card_mmc(card) && !mmc_card_sd(card)) @@ -3013,22 +3011,20 @@ static int mmc_test_probe(struct device *dev) return 0; } -static int mmc_test_remove(struct device *dev) +static void mmc_test_remove(struct mmc_card *card) { - struct mmc_card *card = mmc_dev_to_card(dev); - mmc_test_free_result(card); mmc_test_free_dbgfs_file(card); - - return 0; } -static void mmc_test_shutdown(struct device *dev) +static void mmc_test_shutdown(struct mmc_card *card) { } -static struct device_driver mmc_driver = { - .name = "mmc_test", +static struct mmc_driver mmc_driver = { + .drv = { + .name = "mmc_test", + }, .probe = mmc_test_probe, .remove = mmc_test_remove, .shutdown = mmc_test_shutdown, diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index c5ef100..972ff84 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c @@ -26,6 +26,8 @@ #include "sdio_cis.h" #include "bus.h" +#define to_mmc_driver(d) container_of(d, struct mmc_driver, drv) + static ssize_t type_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -105,14 +107,33 @@ mmc_bus_uevent(struct device *dev, struct kobj_uevent_env *env) return retval; } +static int mmc_bus_probe(struct device *dev) +{ + struct mmc_driver *drv = to_mmc_driver(dev->driver); + struct mmc_card *card = mmc_dev_to_card(dev); + + return drv->probe(card); +} + +static int mmc_bus_remove(struct device *dev) +{ + struct mmc_driver *drv = to_mmc_driver(dev->driver); + struct mmc_card *card = mmc_dev_to_card(dev); + + drv->remove(card); + + return 0; +} + static void mmc_bus_shutdown(struct device *dev) { + struct mmc_driver *drv = to_mmc_driver(dev->driver); struct mmc_card *card = mmc_dev_to_card(dev); struct mmc_host *host = card->host; int ret; - if (dev->driver && dev->driver->shutdown) - dev->driver->shutdown(dev); + if (dev->driver && drv->shutdown) + drv->shutdown(card); if (host->bus_ops->shutdown) { ret = host->bus_ops->shutdown(host); @@ -181,6 +202,8 @@ static struct bus_type mmc_bus_type = { .dev_groups = mmc_dev_groups, .match = mmc_bus_match, .uevent = mmc_bus_uevent, + .probe = mmc_bus_probe, + .remove = mmc_bus_remove, .shutdown = mmc_bus_shutdown, .pm = &mmc_bus_pm_ops, }; @@ -199,22 +222,24 @@ void mmc_unregister_bus(void) * mmc_register_driver - register a media driver * @drv: MMC media driver */ -int mmc_register_driver(struct device_driver *drv) +int mmc_register_driver(struct mmc_driver *drv) { - drv->bus = &mmc_bus_type; - return driver_register(drv); + drv->drv.bus = &mmc_bus_type; + return driver_register(&drv->drv); } + EXPORT_SYMBOL(mmc_register_driver); /** * mmc_unregister_driver - unregister a media driver * @drv: MMC media driver */ -void mmc_unregister_driver(struct device_driver *drv) +void mmc_unregister_driver(struct mmc_driver *drv) { - drv->bus = &mmc_bus_type; - driver_unregister(drv); + drv->drv.bus = &mmc_bus_type; + driver_unregister(&drv->drv); } + EXPORT_SYMBOL(mmc_unregister_driver); static void mmc_release_card(struct device *dev) diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index a6cf4c0..19f0175 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -512,8 +512,18 @@ static inline int mmc_card_broken_irq_polling(const struct mmc_card *c) #define mmc_dev_to_card(d) container_of(d, struct mmc_card, dev) -extern int mmc_register_driver(struct device_driver *); -extern void mmc_unregister_driver(struct device_driver *); +/* + * MMC device driver (e.g., Flash card, I/O card...) + */ +struct mmc_driver { + struct device_driver drv; + int (*probe)(struct mmc_card *); + void (*remove)(struct mmc_card *); + void (*shutdown)(struct mmc_card *); +}; + +extern int mmc_register_driver(struct mmc_driver *); +extern void mmc_unregister_driver(struct mmc_driver *); extern void mmc_fixup_device(struct mmc_card *card, const struct mmc_fixup *table);