LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 3/28] Driver core: convert SPI code to use struct device
Date: Wed,  7 Feb 2007 16:29:51 -0800	[thread overview]
Message-ID: <11708946251265-git-send-email-greg@kroah.com> (raw)
In-Reply-To: <1170894620889-git-send-email-greg@kroah.com>

From: Greg Kroah-Hartman <gregkh@suse.de>

Converts from using struct "class_device" to "struct device" making
everything show up properly in /sys/devices/ with symlinks from the
/sys/class directory.

Cc: <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/spi/pxa2xx_spi.c    |    2 +-
 drivers/spi/spi.c           |   32 ++++++++++++++++----------------
 drivers/spi/spi_bitbang.c   |    6 +++---
 drivers/spi/spi_butterfly.c |    4 ++--
 include/linux/spi/spi.h     |   10 +++++-----
 5 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 8b41f9c..dccdc50 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -1234,7 +1234,7 @@ static int init_queue(struct driver_data *drv_data)
 
 	INIT_WORK(&drv_data->pump_messages, pump_messages);
 	drv_data->workqueue = create_singlethread_workqueue(
-					drv_data->master->cdev.dev->bus_id);
+					drv_data->master->dev.parent->bus_id);
 	if (drv_data->workqueue == NULL)
 		return -EBUSY;
 
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 6307428..35d8c01 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -193,7 +193,7 @@ struct spi_device *__init_or_module
 spi_new_device(struct spi_master *master, struct spi_board_info *chip)
 {
 	struct spi_device	*proxy;
-	struct device		*dev = master->cdev.dev;
+	struct device		*dev = &master->dev;
 	int			status;
 
 	/* NOTE:  caller did any chip->bus_num checks necessary */
@@ -215,7 +215,7 @@ spi_new_device(struct spi_master *master, struct spi_board_info *chip)
 	proxy->modalias = chip->modalias;
 
 	snprintf(proxy->dev.bus_id, sizeof proxy->dev.bus_id,
-			"%s.%u", master->cdev.class_id,
+			"%s.%u", master->dev.bus_id,
 			chip->chip_select);
 	proxy->dev.parent = dev;
 	proxy->dev.bus = &spi_bus_type;
@@ -290,7 +290,7 @@ static void __init_or_module
 scan_boardinfo(struct spi_master *master)
 {
 	struct boardinfo	*bi;
-	struct device		*dev = master->cdev.dev;
+	struct device		*dev = master->dev.parent;
 
 	down(&board_lock);
 	list_for_each_entry(bi, &board_list, list) {
@@ -319,18 +319,18 @@ scan_boardinfo(struct spi_master *master)
 
 /*-------------------------------------------------------------------------*/
 
-static void spi_master_release(struct class_device *cdev)
+static void spi_master_release(struct device *dev)
 {
 	struct spi_master *master;
 
-	master = container_of(cdev, struct spi_master, cdev);
+	master = container_of(dev, struct spi_master, dev);
 	kfree(master);
 }
 
 static struct class spi_master_class = {
 	.name		= "spi_master",
 	.owner		= THIS_MODULE,
-	.release	= spi_master_release,
+	.dev_release	= spi_master_release,
 };
 
 
@@ -364,9 +364,9 @@ spi_alloc_master(struct device *dev, unsigned size)
 	if (!master)
 		return NULL;
 
-	class_device_initialize(&master->cdev);
-	master->cdev.class = &spi_master_class;
-	master->cdev.dev = get_device(dev);
+	device_initialize(&master->dev);
+	master->dev.class = &spi_master_class;
+	master->dev.parent = get_device(dev);
 	spi_master_set_devdata(master, &master[1]);
 
 	return master;
@@ -396,7 +396,7 @@ int __init_or_module
 spi_register_master(struct spi_master *master)
 {
 	static atomic_t		dyn_bus_id = ATOMIC_INIT((1<<16) - 1);
-	struct device		*dev = master->cdev.dev;
+	struct device		*dev = master->dev.parent;
 	int			status = -ENODEV;
 	int			dynamic = 0;
 
@@ -412,12 +412,12 @@ spi_register_master(struct spi_master *master)
 	/* register the device, then userspace will see it.
 	 * registration fails if the bus ID is in use.
 	 */
-	snprintf(master->cdev.class_id, sizeof master->cdev.class_id,
+	snprintf(master->dev.bus_id, sizeof master->dev.bus_id,
 		"spi%u", master->bus_num);
-	status = class_device_add(&master->cdev);
+	status = device_add(&master->dev);
 	if (status < 0)
 		goto done;
-	dev_dbg(dev, "registered master %s%s\n", master->cdev.class_id,
+	dev_dbg(dev, "registered master %s%s\n", master->dev.bus_id,
 			dynamic ? " (dynamic)" : "");
 
 	/* populate children from any spi device tables */
@@ -449,8 +449,8 @@ void spi_unregister_master(struct spi_master *master)
 {
 	int dummy;
 
-	dummy = device_for_each_child(master->cdev.dev, NULL, __unregister);
-	class_device_unregister(&master->cdev);
+	dummy = device_for_each_child(&master->dev, NULL, __unregister);
+	device_unregister(&master->dev);
 }
 EXPORT_SYMBOL_GPL(spi_unregister_master);
 
@@ -471,7 +471,7 @@ struct spi_master *spi_busnum_to_master(u16 bus_num)
 
 	down(&spi_master_class.sem);
 	list_for_each_entry(cdev, &spi_master_class.children, node) {
-		m = container_of(cdev, struct spi_master, cdev);
+		m = container_of(cdev, struct spi_master, dev.kobj);
 		if (m->bus_num == bus_num) {
 			master = spi_master_get(m);
 			break;
diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c
index 57289b6..4638e6c 100644
--- a/drivers/spi/spi_bitbang.c
+++ b/drivers/spi/spi_bitbang.c
@@ -479,7 +479,7 @@ int spi_bitbang_start(struct spi_bitbang *bitbang)
 	/* this task is the only thing to touch the SPI bits */
 	bitbang->busy = 0;
 	bitbang->workqueue = create_singlethread_workqueue(
-			bitbang->master->cdev.dev->bus_id);
+			bitbang->master->dev.parent->bus_id);
 	if (bitbang->workqueue == NULL) {
 		status = -EBUSY;
 		goto err1;
@@ -513,14 +513,14 @@ int spi_bitbang_stop(struct spi_bitbang *bitbang)
 	while (!list_empty(&bitbang->queue) && limit--) {
 		spin_unlock_irq(&bitbang->lock);
 
-		dev_dbg(bitbang->master->cdev.dev, "wait for queue\n");
+		dev_dbg(&bitbang->master->dev, "wait for queue\n");
 		msleep(10);
 
 		spin_lock_irq(&bitbang->lock);
 	}
 	spin_unlock_irq(&bitbang->lock);
 	if (!list_empty(&bitbang->queue)) {
-		dev_err(bitbang->master->cdev.dev, "queue didn't empty\n");
+		dev_err(&bitbang->master->dev, "queue didn't empty\n");
 		return -EBUSY;
 	}
 
diff --git a/drivers/spi/spi_butterfly.c b/drivers/spi/spi_butterfly.c
index 312987a..31b7970 100644
--- a/drivers/spi/spi_butterfly.c
+++ b/drivers/spi/spi_butterfly.c
@@ -246,7 +246,7 @@ static void butterfly_attach(struct parport *p)
 	 * and no way to be selective about what it binds to.
 	 */
 
-	/* FIXME where should master->cdev.dev come from?
+	/* FIXME where should master->dev.parent come from?
 	 * e.g. /sys/bus/pnp0/00:0b, some PCI thing, etc
 	 * setting up a platform device like this is an ugly kluge...
 	 */
@@ -386,7 +386,7 @@ static void butterfly_detach(struct parport *p)
 	butterfly = NULL;
 
 	/* stop() unregisters child devices too */
-	pdev = to_platform_device(pp->bitbang.master->cdev.dev);
+	pdev = to_platform_device(pp->bitbang.master->dev.parent);
 	status = spi_bitbang_stop(&pp->bitbang);
 
 	/* turn off VCC */
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 176f6e3..8c2edd8 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -170,7 +170,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
  * message's completion function when the transaction completes.
  */
 struct spi_master {
-	struct class_device	cdev;
+	struct device		dev;
 
 	/* other than negative (== assign one dynamically), bus_num is fully
 	 * board-specific.  usually that simplifies to being SOC-specific.
@@ -216,17 +216,17 @@ struct spi_master {
 
 static inline void *spi_master_get_devdata(struct spi_master *master)
 {
-	return class_get_devdata(&master->cdev);
+	return dev_get_drvdata(&master->dev);
 }
 
 static inline void spi_master_set_devdata(struct spi_master *master, void *data)
 {
-	class_set_devdata(&master->cdev, data);
+	dev_set_drvdata(&master->dev, data);
 }
 
 static inline struct spi_master *spi_master_get(struct spi_master *master)
 {
-	if (!master || !class_device_get(&master->cdev))
+	if (!master || !get_device(&master->dev))
 		return NULL;
 	return master;
 }
@@ -234,7 +234,7 @@ static inline struct spi_master *spi_master_get(struct spi_master *master)
 static inline void spi_master_put(struct spi_master *master)
 {
 	if (master)
-		class_device_put(&master->cdev);
+		put_device(&master->dev);
 }
 
 
-- 
1.4.4.4


  reply	other threads:[~2007-02-08  0:31 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-08  0:29 [GIT PATCH] Driver core patches for 2.6.20 Greg KH
2007-02-08  0:29 ` [PATCH 1/28] Kobject: make kobject apis more robust in handling NULL pointers Greg KH
2007-02-08  0:29   ` [PATCH 2/28] Driver core: convert pcmcia code to use struct device Greg KH
2007-02-08  0:29     ` Greg KH [this message]
2007-02-08  0:29       ` [PATCH 4/28] Network: convert network devices to use struct device instead of class_device Greg KH
2007-02-08  0:29         ` [PATCH 5/28] driver core: Remove device_is_registered() in device_move() Greg KH
2007-02-08  0:29           ` [PATCH 6/28] driver core: Allow device_move(dev, NULL) Greg KH
2007-02-08  0:29             ` [PATCH 7/28] MODULES: add the module name for built in kernel drivers Greg KH
2007-02-08  0:29               ` [PATCH 8/28] Modules: only add drivers/ direcory if needed Greg KH
2007-02-08  0:29                 ` [PATCH 9/28] PCI: add the sysfs driver name to all modules Greg KH
2007-02-08  0:29                   ` [PATCH 10/28] SERIO: " Greg KH
2007-02-08  0:29                     ` [PATCH 11/28] USB: " Greg KH
2007-02-08  0:30                       ` [PATCH 12/28] /sys/modules/*/holders Greg KH
2007-02-08  0:30                         ` [PATCH 13/28] driver core fixes: make_class_name() retval checks Greg KH
2007-02-08  0:30                           ` [PATCH 14/28] driver core fixes: device_register() retval check in platform.c Greg KH
2007-02-08  0:30                             ` [PATCH 15/28] driver core: Don't stop probing on ->probe errors Greg KH
2007-02-08  0:30                               ` [PATCH 16/28] driver core: Change function call order in device_bind_driver() Greg KH
2007-02-08  0:30                                 ` [PATCH 17/28] Driver core: fix race in sysfs between sysfs_remove_file() and read()/write() Greg KH
2007-02-08  0:30                                   ` [PATCH 18/28] sysfs: suppress lockdep warnings Greg KH
2007-02-08  0:30                                     ` [PATCH 19/28] sysfs: kobject_put cleanup Greg KH
2007-02-08  0:30                                       ` [PATCH 20/28] kobject: " Greg KH
2007-02-08  0:30                                         ` [PATCH 21/28] sysfs: error handling in sysfs, fill_read_buffer() Greg KH
2007-02-08  0:30                                           ` [PATCH 22/28] HOWTO: Add a reference to Harbison and Steele Greg KH
2007-02-08  0:30                                             ` [PATCH 23/28] SYSFS: Fix missing include of list.h in sysfs.h Greg KH
2007-02-08  0:30                                               ` [PATCH 24/28] Driver core: add uevent vars for devices of a class Greg KH
2007-02-08  0:30                                                 ` [PATCH 25/28] Driver core: add device_type to struct device Greg KH
2007-02-08  0:30                                                   ` [PATCH 26/28] Driver core: allow to delay the uevent at device creation time Greg KH
2007-02-08  0:30                                                     ` [PATCH 27/28] Driver Core: Increase the default timeout value of the firmware subsystem Greg KH
2007-02-08  0:30                                                       ` [PATCH 28/28] sysfs: Shadow directory support Greg KH
2007-02-08 17:20                     ` [PATCH 10/28] SERIO: add the sysfs driver name to all modules Dmitry Torokhov
2007-02-08 18:51                       ` Greg KH
2007-02-08  1:34 [PATCH 3/28] Driver core: convert SPI code to use struct device David Brownell

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=11708946251265-git-send-email-greg@kroah.com \
    --to=greg@kroah.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 3/28] Driver core: convert SPI code to use struct device' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).