public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pierre Ossman <drzeus-list@drzeus.cx>
To: Russell King <rmk+lkml@arm.linux.org.uk>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] MMC host class
Date: Wed, 13 Jul 2005 17:52:52 +0200	[thread overview]
Message-ID: <42D538D4.7050803@drzeus.cx> (raw)

[-- Attachment #1: Type: text/plain, Size: 241 bytes --]

Create a mmc_host class to allow enumeration of MMC host controllers
even though they have no card(s) inserted.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>

(This will also allow cards to be enumerated by being able to find the
hosts.)

[-- Attachment #2: mmc-class.patch --]
[-- Type: text/x-patch, Size: 3039 bytes --]

Index: linux-wbsd/drivers/mmc/mmc.h
===================================================================
--- linux-wbsd/drivers/mmc/mmc.h	(revision 134)
+++ linux-wbsd/drivers/mmc/mmc.h	(working copy)
@@ -13,4 +13,6 @@
 void mmc_init_card(struct mmc_card *card, struct mmc_host *host);
 int mmc_register_card(struct mmc_card *card);
 void mmc_remove_card(struct mmc_card *card);
+int mmc_register_host(struct mmc_host *host);
+void mmc_unregister_host(struct mmc_host *host);
 #endif
Index: linux-wbsd/drivers/mmc/mmc_sysfs.c
===================================================================
--- linux-wbsd/drivers/mmc/mmc_sysfs.c	(revision 153)
+++ linux-wbsd/drivers/mmc/mmc_sysfs.c	(working copy)
@@ -20,6 +20,7 @@
 
 #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)
+#define cls_to_mmc_host(d)	container_of(d, struct mmc_host, class_dev)
 
 #define MMC_ATTR(name, fmt, args...)					\
 static ssize_t mmc_##name##_show (struct device *dev, char *buf)	\
@@ -224,14 +225,51 @@
 	put_device(&card->dev);
 }
 
+static void mmc_host_class_dev_release(struct class_device *dev)
+{
+}
+
+static struct class mmc_host_class = {
+	.name =		"mmc_host",
+	.release =	&mmc_host_class_dev_release,
+};
+
+/*
+ * Internal function. Register a new MMC host with the MMC class.
+ */
+int mmc_register_host(struct mmc_host *host)
+{
+	host->class_dev.dev = host->dev;
+	host->class_dev.class = &mmc_host_class;
+	strlcpy(host->class_dev.class_id, host->host_name, BUS_ID_SIZE);
+
+	return class_device_register(&host->class_dev);
+}
+
+/*
+ * Internal function. Unregister a MMC host with the MMC class.
+ */
+void mmc_unregister_host(struct mmc_host *host)
+{
+	class_device_unregister(&host->class_dev);
+}
 
 static int __init mmc_init(void)
 {
-	return bus_register(&mmc_bus_type);
+	int retval;
+	
+	retval = bus_register(&mmc_bus_type);
+	if (retval)
+		return retval;
+	retval = class_register(&mmc_host_class);
+	if (retval)
+		return retval;
+	return 0;
 }
 
 static void __exit mmc_exit(void)
 {
+	class_unregister(&mmc_host_class);
 	bus_unregister(&mmc_bus_type);
 }
 
Index: linux-wbsd/drivers/mmc/mmc.c
===================================================================
--- linux-wbsd/drivers/mmc/mmc.c	(revision 153)
+++ linux-wbsd/drivers/mmc/mmc.c	(working copy)
@@ -1196,6 +1196,8 @@
 	snprintf(host->host_name, sizeof(host->host_name),
 		 "mmc%d", host_num++);
 
+	mmc_register_host(host);
+	
 	mmc_power_off(host);
 	mmc_detect_change(host);
 
@@ -1220,6 +1222,8 @@
 
 		mmc_remove_card(card);
 	}
+	
+	mmc_unregister_host(host);
 
 	mmc_power_off(host);
 }
Index: linux-wbsd/include/linux/mmc/host.h
===================================================================
--- linux-wbsd/include/linux/mmc/host.h	(revision 153)
+++ linux-wbsd/include/linux/mmc/host.h	(working copy)
@@ -69,6 +69,7 @@
 
 struct mmc_host {
 	struct device		*dev;
+	struct class_device	class_dev;
 	struct mmc_host_ops	*ops;
 	unsigned int		f_min;
 	unsigned int		f_max;

             reply	other threads:[~2005-07-13 15:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-13 15:52 Pierre Ossman [this message]
2005-07-15  8:31 ` [PATCH] MMC host class Russell King
2005-07-15 12:26   ` Pierre Ossman
2005-07-15 20:21   ` Pierre Ossman
2005-07-18 17:45     ` Russell King
2005-07-18 18:22       ` Pierre Ossman
2005-08-08 11:38       ` Pierre Ossman
2005-08-18 23:09         ` Russell King
2005-08-19  6:14           ` Pierre Ossman
2005-08-19  7:49             ` Russell King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42D538D4.7050803@drzeus.cx \
    --to=drzeus-list@drzeus.cx \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk+lkml@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox