From patchwork Fri Aug 20 07:46:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 177272 Return-path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on void.printf.net X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.9 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.2.5 Envelope-to: chris@printf.net Delivery-date: Fri, 20 Aug 2010 08:46:32 +0100 Received: from lists.laptop.org ([18.85.2.145] helo=mail.laptop.org) by void.printf.net with esmtp (Exim 4.69) (envelope-from ) id 1OmMJ6-0001f4-0Q for chris@printf.net; Fri, 20 Aug 2010 08:46:32 +0100 Received: by mail.laptop.org (Postfix) id 9027123B92; Fri, 20 Aug 2010 03:46:13 -0400 (EDT) Delivered-To: cjb@laptop.org Received: from spam.laptop.org (spam.laptop.org [18.85.46.23]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.laptop.org (Postfix) with ESMTPS id 81B5223B91 for ; Fri, 20 Aug 2010 03:46:13 -0400 (EDT) X-ASG-Debug-ID: 1282290385-0b740f130002-zHW3sV Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by spam.laptop.org with ESMTP id PJ0VsjarMrZP4zim for ; Fri, 20 Aug 2010 03:46:29 -0400 (EDT) X-Barracuda-Envelope-From: linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751102Ab0HTHqF (ORCPT ); Fri, 20 Aug 2010 03:46:05 -0400 Received: from mail-ew0-f46.google.com ([209.85.215.46]:34672 "EHLO mail-ew0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751028Ab0HTHqD (ORCPT ); Fri, 20 Aug 2010 03:46:03 -0400 Received: by ewy23 with SMTP id 23so1899961ewy.19 for ; Fri, 20 Aug 2010 00:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=spzzCtt6ODNa9qwbEBDBjKwUxO5GRkT5mtMB4sSG7K0=; b=k5F2t5KVlli9Ez8bZxY+4q8flfMujHzRwRF6XN4VT/mznU0OmwJyPTTljYuXlQ6aHq y0jBuT/ImRqrZhiZz+haMd+rMFcX96p8Tk7u0rK4cHKfFb/G/SxIcAtp3wLKp7aZLekC iLMJyCFibVQ6Oi4e1XZ5D7PCczUdpJ/GOWHxU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=n667FKwfQN9nyYyWZPGh7U6k3K0lUe/HyBRZcNELLHfwzIFnDDjTBAsSrJBKnv665U ln4oZSXldnzIYdMWdsL0y/yYT1+5rP0ifW/Cb0AFzOa5Q0SWN/ejI2YBQ83MMHqjw2ER zIpeW637W559tS2yCrozjhiHCIBccLziiWSmo= Received: by 10.213.13.133 with SMTP id c5mr2862eba.4.1282290362098; Fri, 20 Aug 2010 00:46:02 -0700 (PDT) Received: from localhost.localdomain (starua.cc.colocall.com [62.149.23.157]) by mx.google.com with ESMTPS id v8sm4242809eeh.8.2010.08.20.00.45.59 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 20 Aug 2010 00:46:01 -0700 (PDT) From: Andy Shevchenko To: linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Adrian Hunter , linux-mmc@vger.kernel.org, Andrew Morton X-ASG-Orig-Subj: [PATCHv2] mmc: make mmc_dev_to_card() macro public Subject: [PATCHv2] mmc: make mmc_dev_to_card() macro public Date: Fri, 20 Aug 2010 10:46:46 +0300 Message-Id: <1282290406-13198-1-git-send-email-ext-andriy.shevchenko@nokia.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <20100820002332.93b0c44d.akpm@linux-foundation.org> References: <20100820002332.93b0c44d.akpm@linux-foundation.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Barracuda-Connect: vger.kernel.org[209.132.180.67] X-Barracuda-Start-Time: 1282290386 X-Barracuda-URL: http://18.85.46.23:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at laptop.org X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.5 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.38491 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c index 5dd8576..b992725 100644 --- a/drivers/mmc/card/mmc_test.c +++ b/drivers/mmc/card/mmc_test.c @@ -1935,12 +1935,10 @@ static ssize_t mmc_test_show(struct device *dev, static ssize_t mmc_test_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct mmc_card *card; + struct mmc_card *card = mmc_dev_to_card(dev); struct mmc_test_card *test; int testcase; - card = container_of(dev, struct mmc_card, dev); - testcase = simple_strtol(buf, NULL, 10); test = kzalloc(sizeof(struct mmc_test_card), GFP_KERNEL); diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index 7cd9749..e70bd66 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c @@ -22,13 +22,12 @@ #include "sdio_cis.h" #include "bus.h" -#define dev_to_mmc_card(d) container_of(d, struct mmc_card, dev) #define to_mmc_driver(d) container_of(d, struct mmc_driver, drv) static ssize_t mmc_type_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct mmc_card *card = dev_to_mmc_card(dev); + struct mmc_card *card = mmc_dev_to_card(dev); switch (card->type) { case MMC_TYPE_MMC: @@ -62,7 +61,7 @@ static int mmc_bus_match(struct device *dev, struct device_driver *drv) static int mmc_bus_uevent(struct device *dev, struct kobj_uevent_env *env) { - struct mmc_card *card = dev_to_mmc_card(dev); + struct mmc_card *card = mmc_dev_to_card(dev); const char *type; int retval = 0; @@ -105,7 +104,7 @@ mmc_bus_uevent(struct device *dev, struct kobj_uevent_env *env) static int mmc_bus_probe(struct device *dev) { struct mmc_driver *drv = to_mmc_driver(dev->driver); - struct mmc_card *card = dev_to_mmc_card(dev); + struct mmc_card *card = mmc_dev_to_card(dev); return drv->probe(card); } @@ -113,7 +112,7 @@ static int mmc_bus_probe(struct device *dev) static int mmc_bus_remove(struct device *dev) { struct mmc_driver *drv = to_mmc_driver(dev->driver); - struct mmc_card *card = dev_to_mmc_card(dev); + struct mmc_card *card = mmc_dev_to_card(dev); drv->remove(card); @@ -123,7 +122,7 @@ static int mmc_bus_remove(struct device *dev) static int mmc_bus_suspend(struct device *dev, pm_message_t state) { struct mmc_driver *drv = to_mmc_driver(dev->driver); - struct mmc_card *card = dev_to_mmc_card(dev); + struct mmc_card *card = mmc_dev_to_card(dev); int ret = 0; if (dev->driver && drv->suspend) @@ -134,7 +133,7 @@ static int mmc_bus_suspend(struct device *dev, pm_message_t state) static int mmc_bus_resume(struct device *dev) { struct mmc_driver *drv = to_mmc_driver(dev->driver); - struct mmc_card *card = dev_to_mmc_card(dev); + struct mmc_card *card = mmc_dev_to_card(dev); int ret = 0; if (dev->driver && drv->resume) @@ -189,7 +188,7 @@ EXPORT_SYMBOL(mmc_unregister_driver); static void mmc_release_card(struct device *dev) { - struct mmc_card *card = dev_to_mmc_card(dev); + struct mmc_card *card = mmc_dev_to_card(dev); sdio_free_common_cis(card); diff --git a/drivers/mmc/core/bus.h b/drivers/mmc/core/bus.h index 1817876..00a1971 100644 --- a/drivers/mmc/core/bus.h +++ b/drivers/mmc/core/bus.h @@ -14,7 +14,7 @@ #define MMC_DEV_ATTR(name, fmt, args...) \ static ssize_t mmc_##name##_show (struct device *dev, struct device_attribute *attr, char *buf) \ { \ - struct mmc_card *card = container_of(dev, struct mmc_card, dev); \ + struct mmc_card *card = mmc_dev_to_card(dev); \ return sprintf(buf, fmt, args); \ } \ static DEVICE_ATTR(name, S_IRUGO, mmc_##name##_show, NULL) diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index 6b75250..7bd4923 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -173,6 +173,8 @@ static inline int mmc_blksz_for_byte_mode(const struct mmc_card *c) #define mmc_card_name(c) ((c)->cid.prod_name) #define mmc_card_id(c) (dev_name(&(c)->dev)) +#define mmc_dev_to_card(d) container_of(d, struct mmc_card, dev) + #define mmc_list_to_card(l) container_of(l, struct mmc_card, node) #define mmc_get_drvdata(c) dev_get_drvdata(&(c)->dev) #define mmc_set_drvdata(c,d) dev_set_drvdata(&(c)->dev, d)