Skip to contentSkip to conversation

More patches to convert from struct class_device to struct device

PATCH In review [email protected] 7 participants 39 messages Aug 20, 2007 – Aug 26, 2007 SPI

lore
Share & tools
lore
#0 lore raw

cover More patches to convert from struct class_device to struct device

Signature · 14 lines
[patch 01/14] block/paride
[patch 02/14] block/pktcdvd
[patch 03/14] block/aoechr
[patch 04/14] drivers/macintosh
[patch 05/14] cosa sync driver
[patch 06/14] MTD/mtdchar
[patch 07/14] IDE/ide-tape
[patch 08/14] DMA engine
[patch 09/14] SPI
[patch 10/14] USB core
[patch 11/14] USB host
[patch 12/14] TI flash media
[patch 13/14] UCB1x00
[patch 14/14] ISDN capi
#1 lore raw

PATCH 1/14 Convert from class_device to device for block/paride

Signature · 64 lines
Content-Disposition: inline; filename=paride.patch

Convert from class_device to device for block/paride.  This is part of the
work to eliminate struct class_device.

Signed-off-by: Tony Jones <[email protected]>

---
 drivers/block/paride/pg.c |    6 +++---
 drivers/block/paride/pt.c |   12 ++++++------
 2 files changed, 9 insertions(+), 9 deletions(-)

--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -676,8 +676,8 @@ static int __init pg_init(void)
 	for (unit = 0; unit < PG_UNITS; unit++) {
 		struct pg *dev = &devices[unit];
 		if (dev->present)
-			class_device_create(pg_class, NULL, MKDEV(major, unit),
-					NULL, "pg%u", unit);
+			device_create(pg_class, NULL, MKDEV(major, unit),
+				      "pg%u", unit);
 	}
 	err = 0;
 	goto out;
@@ -695,7 +695,7 @@ static void __exit pg_exit(void)
 	for (unit = 0; unit < PG_UNITS; unit++) {
 		struct pg *dev = &devices[unit];
 		if (dev->present)
-			class_device_destroy(pg_class, MKDEV(major, unit));
+			device_destroy(pg_class, MKDEV(major, unit));
 	}
 	class_destroy(pg_class);
 	unregister_chrdev(major, name);
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -972,10 +972,10 @@ static int __init pt_init(void)
 
 	for (unit = 0; unit < PT_UNITS; unit++)
 		if (pt[unit].present) {
-			class_device_create(pt_class, NULL, MKDEV(major, unit),
-					NULL, "pt%d", unit);
-			class_device_create(pt_class, NULL, MKDEV(major, unit + 128),
-					NULL, "pt%dn", unit);
+			device_create(pt_class, NULL, MKDEV(major, unit),
+				      "pt%d", unit);
+			device_create(pt_class, NULL, MKDEV(major, unit + 128),
+				      "pt%dn", unit);
 		}
 	goto out;
 
@@ -990,8 +990,8 @@ static void __exit pt_exit(void)
 	int unit;
 	for (unit = 0; unit < PT_UNITS; unit++)
 		if (pt[unit].present) {
-			class_device_destroy(pt_class, MKDEV(major, unit));
-			class_device_destroy(pt_class, MKDEV(major, unit + 128));
+			device_destroy(pt_class, MKDEV(major, unit));
+			device_destroy(pt_class, MKDEV(major, unit + 128));
 		}
 	class_destroy(pt_class);
 	unregister_chrdev(major, name);

-- 
#2 lore raw

PATCH 2/14 Convert from class_device to device for block/pktcdvd

In reply to [email protected]
Signature · 58 lines
Content-Disposition: inline; filename=block.patch

Convert from class_device to device for block/pktcdvd.  

---
 drivers/block/pktcdvd.c |   16 +++++++---------
 include/linux/pktcdvd.h |    2 +-
 2 files changed, 8 insertions(+), 10 deletions(-)

--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -299,18 +299,16 @@ static struct kobj_type kobj_pkt_type_wq
 static void pkt_sysfs_dev_new(struct pktcdvd_device *pd)
 {
 	if (class_pktcdvd) {
-		pd->clsdev = class_device_create(class_pktcdvd,
-					NULL, pd->pkt_dev,
-					NULL, "%s", pd->name);
-		if (IS_ERR(pd->clsdev))
-			pd->clsdev = NULL;
+		pd->dev = device_create(class_pktcdvd, NULL, pd->pkt_dev, "%s", pd->name);
+		if (IS_ERR(pd->dev))
+			pd->dev = NULL;
 	}
-	if (pd->clsdev) {
+	if (pd->dev) {
 		pd->kobj_stat = pkt_kobj_create(pd, "stat",
-					&pd->clsdev->kobj,
+					&pd->dev->kobj,
 					&kobj_pkt_type_stat);
 		pd->kobj_wqueue = pkt_kobj_create(pd, "write_queue",
-					&pd->clsdev->kobj,
+					&pd->dev->kobj,
 					&kobj_pkt_type_wqueue);
 	}
 }
@@ -320,7 +318,7 @@ static void pkt_sysfs_dev_remove(struct 
 	pkt_kobj_remove(pd->kobj_stat);
 	pkt_kobj_remove(pd->kobj_wqueue);
 	if (class_pktcdvd)
-		class_device_destroy(class_pktcdvd, pd->pkt_dev);
+		device_destroy(class_pktcdvd, pd->pkt_dev);
 }
 
 
--- a/include/linux/pktcdvd.h
+++ b/include/linux/pktcdvd.h
@@ -290,7 +290,7 @@ struct pktcdvd_device
 	int			write_congestion_off;
 	int			write_congestion_on;
 
-	struct class_device	*clsdev;	/* sysfs pktcdvd[0-7] class dev */
+	struct device		*dev;		/* sysfs pktcdvd[0-7] dev */
 	struct pktcdvd_kobj	*kobj_stat;	/* sysfs pktcdvd[0-7]/stat/     */
 	struct pktcdvd_kobj	*kobj_wqueue;	/* sysfs pktcdvd[0-7]/write_queue/ */
 

-- 
author
#3 lore raw

Re: [patch 02/14] Convert from class_device to device for block/pktcdvd

Quoted 4 lines · On Mon, Aug 20, 2007 at 03:48:08PM -0700, [email protected] wrote:
Signature · 3 lines
Content-Disposition: inline; filename=block.patch

Convert from class_device to device for block/pktcdvd.  
#4 lore raw

PATCH 3/14 Convert from class_device to device for block/aoechr

In reply to [email protected]
Signature · 34 lines
Content-Disposition: inline; filename=aoechr.patch

Convert from class_device to device for block/aoechr.  This is part of the
work to eliminate struct class_device.

---
 drivers/block/aoe/aoechr.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -259,9 +259,8 @@ aoechr_init(void)
 		return PTR_ERR(aoe_class);
 	}
 	for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
-		class_device_create(aoe_class, NULL,
-					MKDEV(AOE_MAJOR, chardevs[i].minor),
-					NULL, chardevs[i].name);
+		device_create(aoe_class, NULL,
+			      MKDEV(AOE_MAJOR, chardevs[i].minor), chardevs[i].name);
 
 	return 0;
 }
@@ -272,7 +271,7 @@ aoechr_exit(void)
 	int i;
 
 	for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
-		class_device_destroy(aoe_class, MKDEV(AOE_MAJOR, chardevs[i].minor));
+		device_destroy(aoe_class, MKDEV(AOE_MAJOR, chardevs[i].minor));
 	class_destroy(aoe_class);
 	unregister_chrdev(AOE_MAJOR, "aoechr");
 }

-- 
author
#5 lore raw

Re: [patch 03/14] Convert from class_device to device for block/aoechr

Quoted 5 lines · On Mon, Aug 20, 2007 at 03:48:09PM -0700, [email protected] wrote:
Signature · 4 lines
Content-Disposition: inline; filename=aoechr.patch

Convert from class_device to device for block/aoechr.  This is part of the
work to eliminate struct class_device.
#6 lore raw

PATCH 4/14 Convert from class_device to device for drivers/macintosh

In reply to [email protected]
Signature · 20 lines
Content-Disposition: inline; filename=macintosh.patch

Convert from class_device to device for macintosh.  This is part of the
work to eliminate struct class_device.

---
 drivers/macintosh/adb.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -875,5 +875,5 @@ adbdev_init(void)
 	adb_dev_class = class_create(THIS_MODULE, "adb");
 	if (IS_ERR(adb_dev_class))
 		return;
-	class_device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
+	device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), "adb");
 }

-- 
author
#7 lore raw

Re: [patch 04/14] Convert from class_device to device for drivers/macintosh

Quoted 5 lines · On Mon, Aug 20, 2007 at 03:48:10PM -0700, [email protected] wrote:
Signature · 4 lines
Content-Disposition: inline; filename=macintosh.patch

Convert from class_device to device for macintosh.  This is part of the
work to eliminate struct class_device.
#8 lore raw

Re: [patch 04/14] Convert from class_device to device for drivers/macintosh

In reply to [email protected]
Quoted 5 lines · On Mon, 2007-08-20 at 15:48 -0700, [email protected] wrote:
Signature · 4 lines
Content-Disposition: inline; filename=macintosh.patch

Convert from class_device to device for macintosh.  This is part of the
work to eliminate struct class_device.

Good. That stuff shouldn't have been a class in the first place. ADB is a bus type, not a class.

Ben.

Quoted 14 lines
---
 drivers/macintosh/adb.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/macintosh/adb.c +1 -1
@@ -875,5 +875,5 @@ adbdev_init(void)
 	adb_dev_class = class_create(THIS_MODULE, "adb");
 	if (IS_ERR(adb_dev_class))
 		return;
-	class_device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
+	device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), "adb");
 }
#9 lore raw

PATCH 5/14 Convert from class_device to device for cosa sync driver

In reply to [email protected]
Signature · 32 lines
Content-Disposition: inline; filename=wan.patch

Convert from class_device to device for drivers/net/wan/cosa.  This is part of 
the work to eliminate struct class_device.

---
 drivers/net/wan/cosa.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -395,8 +395,7 @@ static int __init cosa_init(void)
 		goto out_chrdev;
 	}
 	for (i=0; i<nr_cards; i++) {
-		class_device_create(cosa_class, NULL, MKDEV(cosa_major, i),
-				NULL, "cosa%d", i);
+		device_create(cosa_class, NULL, MKDEV(cosa_major, i), "cosa%d", i);
 	}
 	err = 0;
 	goto out;
@@ -415,7 +414,7 @@ static void __exit cosa_exit(void)
 	printk(KERN_INFO "Unloading the cosa module\n");
 
 	for (i=0; i<nr_cards; i++)
-		class_device_destroy(cosa_class, MKDEV(cosa_major, i));
+		device_destroy(cosa_class, MKDEV(cosa_major, i));
 	class_destroy(cosa_class);
 	for (cosa=cosa_cards; nr_cards--; cosa++) {
 		/* Clean up the per-channel data */

-- 
author
#10 lore raw

Re: [patch 05/14] Convert from class_device to device for cosa sync driver

Quoted 5 lines · On Mon, Aug 20, 2007 at 03:48:11PM -0700, [email protected] wrote:
Signature · 4 lines
Content-Disposition: inline; filename=wan.patch

Convert from class_device to device for drivers/net/wan/cosa.  This is part of 
the work to eliminate struct class_device.
Acked-by
#11 lore raw

Re: [patch 05/14] Convert from class_device to device for cosa sync driver

Tony Jones wrote:
: On Mon, Aug 20, 2007 at 03:48:11PM -0700, [email protected] wrote:
: > --
: > Content-Disposition: inline; filename=wan.patch
: >
: > Convert from class_device to device for drivers/net/wan/cosa. This is part of : > the work to eliminate struct class_device.
:
: Signed-off-by: Tony Jones <[email protected]>

-Yenya

Signature · 5 lines
| Jan "Yenya" Kasprzak  <kas at {fi.muni.cz - work | yenya.net - private}> |
| GPG: ID 1024/D3498839      Fingerprint 0D99A7FB206605D7 8B35FCDE05B18A5E |
| http://www.fi.muni.cz/~kas/    Journal: http://www.fi.muni.cz/~kas/blog/ |
========== Pruning mailbox after being ~10 days offline.
========== Sorry for the possibly delayed reply.
#12 lore raw

PATCH 6/14 Convert from class_device to device for MTD/mtdchar

In reply to [email protected]
Signature · 40 lines
Content-Disposition: inline; filename=mtd.patch

Convert from class_device to device for drivers/mtd/mtdchar.  This is part of 
the work to eliminate struct class_device.

---
 drivers/mtd/mtdchar.c |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -27,12 +27,10 @@ static void mtd_notify_add(struct mtd_in
 	if (!mtd)
 		return;
 
-	class_device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
-			    NULL, "mtd%d", mtd->index);
+	device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2), "mtd%d", mtd->index);
 
-	class_device_create(mtd_class, NULL,
-			    MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
-			    NULL, "mtd%dro", mtd->index);
+	device_create(mtd_class, NULL,
+		      MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), "mtd%dro", mtd->index);
 }
 
 static void mtd_notify_remove(struct mtd_info* mtd)
@@ -40,8 +38,8 @@ static void mtd_notify_remove(struct mtd
 	if (!mtd)
 		return;
 
-	class_device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2));
-	class_device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1));
+	device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2));
+	device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1));
 }
 
 static struct mtd_notifier notifier = {

-- 
author
#13 lore raw

Re: [patch 06/14] Convert from class_device to device for MTD/mtdchar

Quoted 5 lines · On Mon, Aug 20, 2007 at 03:48:12PM -0700, [email protected] wrote:
Signature · 4 lines
Content-Disposition: inline; filename=mtd.patch

Convert from class_device to device for drivers/mtd/mtdchar.  This is part of 
the work to eliminate struct class_device.
#14 lore raw

PATCH 7/14 Convert from class_device to device for IDE/ide-tape

In reply to [email protected]
Signature · 41 lines
Content-Disposition: inline; filename=ide.patch

Convert from class_device to device for drivers/drivers/ide/ide-tape.  This is 
part of the work to eliminate struct class_device.

---
 drivers/ide/ide-tape.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -4725,10 +4725,8 @@ static void ide_tape_release(struct kref
 
 	drive->dsc_overlap = 0;
 	drive->driver_data = NULL;
-	class_device_destroy(idetape_sysfs_class,
-			MKDEV(IDETAPE_MAJOR, tape->minor));
-	class_device_destroy(idetape_sysfs_class,
-			MKDEV(IDETAPE_MAJOR, tape->minor + 128));
+	device_destroy(idetape_sysfs_class, MKDEV(IDETAPE_MAJOR, tape->minor));
+	device_destroy(idetape_sysfs_class, MKDEV(IDETAPE_MAJOR, tape->minor + 128));
 	idetape_devs[tape->minor] = NULL;
 	g->private_data = NULL;
 	put_disk(g);
@@ -4885,10 +4883,10 @@ static int ide_tape_probe(ide_drive_t *d
 
 	idetape_setup(drive, tape, minor);
 
-	class_device_create(idetape_sysfs_class, NULL,
-			MKDEV(IDETAPE_MAJOR, minor), &drive->gendev, "%s", tape->name);
-	class_device_create(idetape_sysfs_class, NULL,
-			MKDEV(IDETAPE_MAJOR, minor + 128), &drive->gendev, "n%s", tape->name);
+	device_create(idetape_sysfs_class, &drive->gendev,
+		      MKDEV(IDETAPE_MAJOR, minor), "%s", tape->name);
+	device_create(idetape_sysfs_class, &drive->gendev,
+			MKDEV(IDETAPE_MAJOR, minor + 128), "n%s", tape->name);
 
 	g->fops = &idetape_block_ops;
 	ide_register_region(g);

-- 
author
#15 lore raw

Re: [patch 07/14] Convert from class_device to device for IDE/ide-tape

Quoted 5 lines · On Mon, Aug 20, 2007 at 03:48:13PM -0700, [email protected] wrote:
Signature · 4 lines
Content-Disposition: inline; filename=ide.patch

Convert from class_device to device for drivers/drivers/ide/ide-tape.  This is 
part of the work to eliminate struct class_device.
#16 lore raw

PATCH 8/14 Convert from class_device to device for DMA engine

In reply to [email protected]
Signature · 152 lines
Content-Disposition: inline; filename=dma.patch

Convert from class_device to device for drivers/dma/dmaengine.  This is
part of the work to eliminate struct class_device.

---
 drivers/dma/dmaengine.c   |   43 ++++++++++++++++++++++---------------------
 include/linux/dmaengine.h |    3 ++-
 2 files changed, 24 insertions(+), 22 deletions(-)

--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -41,12 +41,12 @@
  * the definition of dma_event_callback in dmaengine.h.
  *
  * Each device has a kref, which is initialized to 1 when the device is
- * registered. A kref_get is done for each class_device registered.  When the
- * class_device is released, the coresponding kref_put is done in the release
+ * registered. A kref_get is done for each device registered.  When the
+ * device is released, the coresponding kref_put is done in the release
  * method. Every time one of the device's channels is allocated to a client,
  * a kref_get occurs.  When the channel is freed, the coresponding kref_put
  * happens. The device's release function does a completion, so
- * unregister_device does a remove event, class_device_unregister, a kref_put
+ * unregister_device does a remove event, device_unregister, a kref_put
  * for the first reference, then waits on the completion for all other
  * references to finish.
  *
@@ -77,9 +77,9 @@ static LIST_HEAD(dma_client_list);
 
 /* --- sysfs implementation --- */
 
-static ssize_t show_memcpy_count(struct class_device *cd, char *buf)
+static ssize_t show_memcpy_count(struct device *dev, struct device_attribute *attr, char *buf)
 {
-	struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev);
+	struct dma_chan *chan = to_dma_chan(dev);
 	unsigned long count = 0;
 	int i;
 
@@ -89,9 +89,10 @@ static ssize_t show_memcpy_count(struct 
 	return sprintf(buf, "%lu\n", count);
 }
 
-static ssize_t show_bytes_transferred(struct class_device *cd, char *buf)
+static ssize_t show_bytes_transferred(struct device *dev, struct device_attribute *attr,
+				      char *buf)
 {
-	struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev);
+	struct dma_chan *chan = to_dma_chan(dev);
 	unsigned long count = 0;
 	int i;
 
@@ -101,9 +102,9 @@ static ssize_t show_bytes_transferred(st
 	return sprintf(buf, "%lu\n", count);
 }
 
-static ssize_t show_in_use(struct class_device *cd, char *buf)
+static ssize_t show_in_use(struct device *dev, struct device_attribute *attr, char *buf)
 {
-	struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev);
+	struct dma_chan *chan = to_dma_chan(dev);
 	int in_use = 0;
 
 	if (unlikely(chan->slow_ref) &&
@@ -119,7 +120,7 @@ static ssize_t show_in_use(struct class_
 	return sprintf(buf, "%d\n", in_use);
 }
 
-static struct class_device_attribute dma_class_attrs[] = {
+static struct device_attribute dma_attrs[] = {
 	__ATTR(memcpy_count, S_IRUGO, show_memcpy_count, NULL),
 	__ATTR(bytes_transferred, S_IRUGO, show_bytes_transferred, NULL),
 	__ATTR(in_use, S_IRUGO, show_in_use, NULL),
@@ -128,16 +129,16 @@ static struct class_device_attribute dma
 
 static void dma_async_device_cleanup(struct kref *kref);
 
-static void dma_class_dev_release(struct class_device *cd)
+static void dma_dev_release(struct device *dev)
 {
-	struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev);
+	struct dma_chan *chan = to_dma_chan(dev);
 	kref_put(&chan->device->refcount, dma_async_device_cleanup);
 }
 
 static struct class dma_devclass = {
-	.name            = "dma",
-	.class_dev_attrs = dma_class_attrs,
-	.release = dma_class_dev_release,
+	.name		= "dma",
+	.dev_attrs	= dma_attrs,
+	.dev_release	= dma_dev_release,
 };
 
 /* --- client and device registration --- */
@@ -384,12 +385,12 @@ int dma_async_device_register(struct dma
 			continue;
 
 		chan->chan_id = chancnt++;
-		chan->class_dev.class = &dma_devclass;
-		chan->class_dev.dev = NULL;
-		snprintf(chan->class_dev.class_id, BUS_ID_SIZE, "dma%dchan%d",
+		chan->dev.class = &dma_devclass;
+		chan->dev.parent = NULL;
+		snprintf(chan->dev.bus_id, BUS_ID_SIZE, "dma%dchan%d",
 		         device->dev_id, chan->chan_id);
 
-		rc = class_device_register(&chan->class_dev);
+		rc = device_register(&chan->dev);
 		if (rc) {
 			chancnt--;
 			free_percpu(chan->local);
@@ -416,7 +417,7 @@ err_out:
 		if (chan->local == NULL)
 			continue;
 		kref_put(&device->refcount, dma_async_device_cleanup);
-		class_device_unregister(&chan->class_dev);
+		device_unregister(&chan->dev);
 		chancnt--;
 		free_percpu(chan->local);
 	}
@@ -450,7 +451,7 @@ void dma_async_device_unregister(struct 
 
 	list_for_each_entry(chan, &device->channels, device_node) {
 		dma_clients_notify_removed(chan);
-		class_device_unregister(&chan->class_dev);
+		device_unregister(&chan->dev);
 		dma_chan_release(chan);
 	}
 
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -132,7 +132,7 @@ struct dma_chan {
 
 	/* sysfs */
 	int chan_id;
-	struct class_device class_dev;
+	struct device dev;
 
 	struct kref refcount;
 	int slow_ref;
@@ -142,6 +142,7 @@ struct dma_chan {
 	struct dma_chan_percpu *local;
 };
 
+#define to_dma_chan(p) container_of(p, struct dma_chan, dev)
 
 void dma_chan_cleanup(struct kref *kref);
 

-- 
author
#17 lore raw

Re: [patch 08/14] Convert from class_device to device for DMA engine

Quoted 5 lines · On Mon, Aug 20, 2007 at 03:48:14PM -0700, [email protected] wrote:
Signature · 4 lines
Content-Disposition: inline; filename=dma.patch

Convert from class_device to device for drivers/dma/dmaengine.  This is
part of the work to eliminate struct class_device.
#18 lore raw

PATCH 9/14 Convert from class_device to device for SPI

In reply to [email protected]
Signature · 203 lines
Content-Disposition: inline; filename=spi.patch

Convert from class_device to device for drivers/spi.  This is part of the work 
to eliminate struct class_device.

---
 drivers/spi/spi.c         |   36 ++++++++++++++++++------------------
 drivers/spi/spi_bitbang.c |    2 +-
 drivers/spi/spi_lm70llp.c |    2 +-
 include/linux/spi/spi.h   |   12 ++++++------
 4 files changed, 26 insertions(+), 26 deletions(-)

--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -207,7 +207,7 @@ struct spi_device *spi_new_device(struct
 				  struct spi_board_info *chip)
 {
 	struct spi_device	*proxy;
-	struct device		*dev = master->cdev.dev;
+	struct device		*dev = master->dev.parent;
 	int			status;
 
 	/* NOTE:  caller did any chip->bus_num checks necessary.
@@ -242,7 +242,7 @@ struct spi_device *spi_new_device(struct
 	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;
@@ -341,18 +341,18 @@ static void scan_boardinfo(struct spi_ma
 
 /*-------------------------------------------------------------------------*/
 
-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,
 };
 
 
@@ -360,7 +360,7 @@ static struct class spi_master_class = {
  * spi_alloc_master - allocate SPI master controller
  * @dev: the controller, possibly using the platform_bus
  * @size: how much zeroed driver-private data to allocate; the pointer to this
- *	memory is in the class_data field of the returned class_device,
+ *	memory is in the driver_data field of the returned device,
  *	accessible with spi_master_get_devdata().
  * Context: can sleep
  *
@@ -386,9 +386,9 @@ struct spi_master *spi_alloc_master(stru
 	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;
@@ -418,7 +418,7 @@ EXPORT_SYMBOL_GPL(spi_alloc_master);
 int spi_register_master(struct spi_master *master)
 {
 	static atomic_t		dyn_bus_id = ATOMIC_INIT((1<<15) - 1);
-	struct device		*dev = master->cdev.dev;
+	struct device		*dev = master->dev.parent;
 	int			status = -ENODEV;
 	int			dynamic = 0;
 
@@ -443,12 +443,12 @@ int spi_register_master(struct spi_maste
 	/* 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 */
@@ -481,8 +481,8 @@ void spi_unregister_master(struct spi_ma
 {
 	int dummy;
 
-	dummy = device_for_each_child(master->cdev.dev, NULL, __unregister);
-	class_device_unregister(&master->cdev);
+	dummy = device_for_each_child(master->dev.parent, NULL, __unregister);
+	device_unregister(&master->dev);
 }
 EXPORT_SYMBOL_GPL(spi_unregister_master);
 
@@ -498,13 +498,13 @@ EXPORT_SYMBOL_GPL(spi_unregister_master)
  */
 struct spi_master *spi_busnum_to_master(u16 bus_num)
 {
-	struct class_device	*cdev;
+	struct device		*dev;
 	struct spi_master	*master = NULL;
 	struct spi_master	*m;
 
 	down(&spi_master_class.sem);
-	list_for_each_entry(cdev, &spi_master_class.children, node) {
-		m = container_of(cdev, struct spi_master, cdev);
+	list_for_each_entry(dev, &spi_master_class.children, node) {
+		m = container_of(dev, struct spi_master, dev);
 		if (m->bus_num == bus_num) {
 			master = spi_master_get(m);
 			break;
--- a/drivers/spi/spi_lm70llp.c
+++ b/drivers/spi/spi_lm70llp.c
@@ -82,7 +82,7 @@ struct spi_lm70llp {
 	struct pardevice	*pd;
 	struct spi_device	*spidev_lm70;
 	struct spi_board_info	info;
-	struct class_device	*cdev;
+	//struct device		*dev;
 };
 
 /* REVISIT : ugly global ; provides "exclusive open" facility */
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -195,7 +195,7 @@ static inline void spi_unregister_driver
 
 /**
  * struct spi_master - interface to SPI master controller
- * @cdev: class interface to this driver
+ * @dev: device interface to this driver
  * @bus_num: board-specific (and often SOC-specific) identifier for a
  *	given SPI controller.
  * @num_chipselect: chipselects are used to distinguish individual
@@ -222,7 +222,7 @@ static inline void spi_unregister_driver
  * 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.
@@ -268,17 +268,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;
 }
@@ -286,7 +286,7 @@ static inline struct spi_master *spi_mas
 static inline void spi_master_put(struct spi_master *master)
 {
 	if (master)
-		class_device_put(&master->cdev);
+		put_device(&master->dev);
 }
 
 
--- a/drivers/spi/spi_bitbang.c
+++ b/drivers/spi/spi_bitbang.c
@@ -472,7 +472,7 @@ int spi_bitbang_start(struct spi_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;

-- 
author
#19 lore raw

Re: [patch 09/14] Convert from class_device to device for SPI

Quoted 5 lines · On Mon, Aug 20, 2007 at 03:48:15PM -0700, [email protected] wrote:
Signature · 4 lines
Content-Disposition: inline; filename=spi.patch

Convert from class_device to device for drivers/spi.  This is part of the work 
to eliminate struct class_device.
#20 lore raw

Re: [patch 09/14] Convert from class_device to device for SPI

Quoted 6 lines · Tony Jones
Quoted 3 lines · On Mon, Aug 20, 2007 at 03:48:15PM -0700, [email protected] wrote:

Convert from class_device to device for drivers/spi. This is part of the work to eliminate struct class_device.

Yeah, "no signoff" was one of my first reactions to that. :)

Can you update the Documentation/spi/spi-summary text which is invalidated by this change? That's part of why I rejected an earlier version of this patch: since it broke the documentation, it was incomplete.

The other reason was to explore removing the "struct class" too, since it's not necessary. But it turns out to be simpler to keep it in there to allocate the bus IDs. So I've changed my mind, and will merge a patch like $SUBJECT if it's complete (i.e. doesn't leave broken/invalid docs).

- Dave

author
#21 lore raw

Re: [patch 09/14] Convert from class_device to device for SPI

Quoted 9 lines · David Brownell
Quoted 6 lines · Tony Jones
Quoted 3 lines · On Mon, Aug 20, 2007 at 03:48:15PM -0700, [email protected] wrote:

Convert from class_device to device for drivers/spi. This is part of the work to eliminate struct class_device.

Yeah, "no signoff" was one of my first reactions to that. :)

Yeah, sorry, had it in the first patch but cut-n-pasted it into oblivion :)

Quoted 2 lines

Can you update the Documentation/spi/spi-summary text which is invalidated by this change? That's part of why I rejected an

Will do. Thanks!

Tony

author
#22 lore raw

Re: [patch 09/14] Convert from class_device to device for SPI

In reply to David Brownell
Quoted 4 lines · David Brownell

Can you update the Documentation/spi/spi-summary text which is invalidated by this change? That's part of why I rejected an earlier version of this patch: since it broke the documentation, it was incomplete.

I believe this is the necessary documentation changes. Alas I can't write verbiage you are necessarily happy with, only you can do that, if there is a factual error, I'll be happy to correct but feel free to edit for personal style. I'll be gone thru Sunday so if it needs more adjustment I'll do it then.

Tony

------------------------------------------------------------------------------

Convert from class_device to device for drivers/spi. This is part of the work to eliminate struct class_device.

---
 Documentation/spi/spi-summary |   13 +++++++------
 drivers/spi/spi.c             |   36 ++++++++++++++++++------------------
 drivers/spi/spi_bitbang.c     |    2 +-
 drivers/spi/spi_lm70llp.c     |    2 +-
 include/linux/spi/spi.h       |   12 ++++++------
 5 files changed, 33 insertions(+), 32 deletions(-)
drivers/spi/spi.c +18 -18
@@ -207,7 +207,7 @@ struct spi_device *spi_new_device(struct
 				  struct spi_board_info *chip)
 {
 	struct spi_device	*proxy;
-	struct device		*dev = master->cdev.dev;
+	struct device		*dev = master->dev.parent;
 	int			status;
 
 	/* NOTE:  caller did any chip->bus_num checks necessary.
@@ -242,7 +242,7 @@ struct spi_device *spi_new_device(struct
 	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;
@@ -341,18 +341,18 @@ static void scan_boardinfo(struct spi_ma
 
 /*-------------------------------------------------------------------------*/
 
-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,
 };
 
 
@@ -360,7 +360,7 @@ static struct class spi_master_class = {
  * spi_alloc_master - allocate SPI master controller
  * @dev: the controller, possibly using the platform_bus
  * @size: how much zeroed driver-private data to allocate; the pointer to this
- *	memory is in the class_data field of the returned class_device,
+ *	memory is in the driver_data field of the returned device,
  *	accessible with spi_master_get_devdata().
  * Context: can sleep
  *
@@ -386,9 +386,9 @@ struct spi_master *spi_alloc_master(stru
 	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;
@@ -418,7 +418,7 @@ EXPORT_SYMBOL_GPL(spi_alloc_master);
 int spi_register_master(struct spi_master *master)
 {
 	static atomic_t		dyn_bus_id = ATOMIC_INIT((1<<15) - 1);
-	struct device		*dev = master->cdev.dev;
+	struct device		*dev = master->dev.parent;
 	int			status = -ENODEV;
 	int			dynamic = 0;
 
@@ -443,12 +443,12 @@ int spi_register_master(struct spi_maste
 	/* 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 */
@@ -481,8 +481,8 @@ void spi_unregister_master(struct spi_ma
 {
 	int dummy;
 
-	dummy = device_for_each_child(master->cdev.dev, NULL, __unregister);
-	class_device_unregister(&master->cdev);
+	dummy = device_for_each_child(master->dev.parent, NULL, __unregister);
+	device_unregister(&master->dev);
 }
 EXPORT_SYMBOL_GPL(spi_unregister_master);
 
@@ -498,13 +498,13 @@ EXPORT_SYMBOL_GPL(spi_unregister_master)
  */
 struct spi_master *spi_busnum_to_master(u16 bus_num)
 {
-	struct class_device	*cdev;
+	struct device		*dev;
 	struct spi_master	*master = NULL;
 	struct spi_master	*m;
 
 	down(&spi_master_class.sem);
-	list_for_each_entry(cdev, &spi_master_class.children, node) {
-		m = container_of(cdev, struct spi_master, cdev);
+	list_for_each_entry(dev, &spi_master_class.children, node) {
+		m = container_of(dev, struct spi_master, dev);
 		if (m->bus_num == bus_num) {
 			master = spi_master_get(m);
 			break;
drivers/spi/spi_lm70llp.c +1 -1
@@ -82,7 +82,7 @@ struct spi_lm70llp {
 	struct pardevice	*pd;
 	struct spi_device	*spidev_lm70;
 	struct spi_board_info	info;
-	struct class_device	*cdev;
+	//struct device		*dev;
 };
 
 /* REVISIT : ugly global ; provides "exclusive open" facility */
include/linux/spi/spi.h +6 -6
@@ -195,7 +195,7 @@ static inline void spi_unregister_driver
 
 /**
  * struct spi_master - interface to SPI master controller
- * @cdev: class interface to this driver
+ * @dev: device interface to this driver
  * @bus_num: board-specific (and often SOC-specific) identifier for a
  *	given SPI controller.
  * @num_chipselect: chipselects are used to distinguish individual
@@ -222,7 +222,7 @@ static inline void spi_unregister_driver
  * 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.
@@ -268,17 +268,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;
 }
@@ -286,7 +286,7 @@ static inline struct spi_master *spi_mas
 static inline void spi_master_put(struct spi_master *master)
 {
 	if (master)
-		class_device_put(&master->cdev);
+		put_device(&master->dev);
 }
 
 
drivers/spi/spi_bitbang.c +1 -1
@@ -472,7 +472,7 @@ int spi_bitbang_start(struct spi_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;
Documentation/spi/spi-summary +7 -6
@@ -167,9 +167,9 @@ shows up in sysfs in several locations:
 
    /sys/bus/spi/drivers/D ... driver for one or more spi*.* devices
 
-   /sys/class/spi_master/spiB ... class device for the controller
-	managing bus "B".  All the spiB.* devices share the same
-	physical SPI bus segment, with SCLK, MOSI, and MISO.
+   /sys/class/spi_master/spiB ... device for the controller managing bus "B".
+	All the spiB.* devices share the same physical SPI bus segment, with
+	SCLK, MOSI, and MISO.
 
 
 How does board-specific init code declare SPI devices?
@@ -337,7 +337,8 @@ SPI protocol drivers somewhat resemble p
 
 The driver core will autmatically attempt to bind this driver to any SPI
 device whose board_info gave a modalias of "CHIP".  Your probe() code
-might look like this unless you're creating a class_device:
+might look like this unless you're creating a device which is managing a bus
+(appearing under /sys/class/spi_master).
 
 	static int __devinit CHIP_probe(struct spi_device *spi)
 	{
@@ -442,7 +443,7 @@ An SPI controller will probably be regis
 a driver to bind to the device, whichever bus is involved.
 
 The main task of this type of driver is to provide an "spi_master".
-Use spi_alloc_master() to allocate the master, and class_get_devdata()
+Use spi_alloc_master() to allocate the master, and spi_master_get_devdata()
 to get the driver-private data allocated for that device.
 
 	struct spi_master	*master;
@@ -452,7 +453,7 @@ to get the driver-private data allocated
 	if (!master)
 		return -ENODEV;
 
-	c = class_get_devdata(&master->cdev);
+	c = spi_master_get_devdata(master);
 
 The driver will initialize the fields of that spi_master, including the
 bus number (maybe the same as the platform device ID) and three methods
#23 lore raw

Re: [patch 09/14] Convert from class_device to device for SPI

Quoted 1 line · Tony Jones

I believe this is the necessary documentation changes.

Thanks. I have an update, plus updates for the mmc_spi driver (now in MM) which you didn't update.

By the way, it's worth noting an incompatibility introduced through these conversions and CONFIG_SYSFS_DEPRECATED=n:

- previously .../controller/spi_master:spi2 would be a symlink to /sys/class/spi_master/spi2

- now, /sys/class/spi_master/spi2 is a symlink to .../controller/spi_master (with DEPRECATED=n).

The symlink direction is just noise ... the issue is that with this approach it's no longer possible to have one controller handle multiple SPI busses! A fix would involve maintaining the original "spi_master:spi2" name.

I don't happen to know of such a controller, and one would surprise me a bit. Exactly like the fact that several I2C adapters work that way was a surprise: one PCI function controlling several different I2C busses, rather than one function per bus.

- Dave

#24 lore raw

Re: [patch 09/14] Convert from class_device to device for SPI

Quoted 11 lines · David Brownell
Quoted 1 line · Tony Jones

I believe this is the necessary documentation changes.

Thanks. I have an update, plus updates for the mmc_spi driver (now in MM) which you didn't update.

By the way, it's worth noting an incompatibility introduced through these conversions and CONFIG_SYSFS_DEPRECATED=n:

- previously .../controller/spi_master:spi2 would be a symlink to /sys/class/spi_master/spi2

These "find the class device which has me as the parent"-symlinks are removed with CONFIG_SYSFS_DEPRECATED=n, because these devices are direct child directories now below the bus device and there is no need for such links.

Quoted 2 lines

- now, /sys/class/spi_master/spi2 is a symlink to .../controller/spi_master (with DEPRECATED=n).

Ugh! Are you sure, that is doesn't point to:
.../controller/spi_master/spi2/ ?

Quoted 4 lines

The symlink direction is just noise ... the issue is that with this approach it's no longer possible to have one controller handle multiple SPI busses! A fix would involve maintaining the original "spi_master:spi2" name.

Sounds like a bug if that's what happened. Can you paste the output of "tree" for the relevant parts here?

Thanks,
Kay

#25 lore raw

Re: [patch 09/14] Convert from class_device to device for SPI

Quoted 10 lines · Kay Sievers
Quoted 9 lines · David Brownell
Quoted 1 line · Tony Jones

I believe this is the necessary documentation changes.

Thanks. I have an update, plus updates for the mmc_spi driver (now in MM) which you didn't update.

By the way, it's worth noting an incompatibility introduced through these conversions and CONFIG_SYSFS_DEPRECATED=n:

Quoted 7 lines
Quoted 4 lines

...

- now, /sys/class/spi_master/spi2 is a symlink to .../controller/spi_master (with DEPRECATED=n).

Ugh! Are you sure, that is doesn't point to:
.../controller/spi_master/spi2/ ?

Turns out that it does -- once you tell Minicom to change its bogus default of discarding data rather than line wrapping! Which means there can still be multiple class instances that get coupled to a given physical device; no lossage there.

Sigh. It's hard sometimes to remember to apply all the right bug workarounds, when some of them are in userspace.

Still, that's a needless incompatibility. Why isn't that pointing to a .../controller/spi_master:spi2 directory, so that the pathnames don't change (only symlink polarity)?

- Dave

#26 lore raw

Re: [patch 09/14] Convert from class_device to device for SPI

Quoted 16 lines · David Brownell
Quoted 15 lines · Kay Sievers
Quoted 13 lines · David Brownell
Quoted 1 line · Tony Jones

I believe this is the necessary documentation changes.

Thanks. I have an update, plus updates for the mmc_spi driver (now in MM) which you didn't update.

By the way, it's worth noting an incompatibility introduced through these conversions and CONFIG_SYSFS_DEPRECATED=n:

...

- now, /sys/class/spi_master/spi2 is a symlink to .../controller/spi_master (with DEPRECATED=n).

Quoted 7 lines
Quoted 2 lines

Ugh! Are you sure, that is doesn't point to:
.../controller/spi_master/spi2/ ?

Turns out that it does -- once you tell Minicom to change its bogus default of discarding data rather than line wrapping! Which means there can still be multiple class instances that get coupled to a given physical device; no lossage there.

Great.

Quoted 2 lines

Sigh. It's hard sometimes to remember to apply all the right bug workarounds, when some of them are in userspace.

Yeah, it's a mess, I totally know that feeling. :)

Quoted 3 lines

Still, that's a needless incompatibility. Why isn't that pointing to a .../controller/spi_master:spi2 directory, so that the pathnames don't change (only symlink polarity)?

The directory name is the kernel's kobject name used by userspace, we can't change the name. Most of these names are used to name the device nodes.

Also the link would just point to the direct child directory with the same name, which would be kind of strange. We could add them back, if really needed, but they didn't exist for long, so we think it's fine to get rid of them when !DEPRECATED is used.

With the hierarchy of class devices in recently changed subsytems, it would be totally inconsistent to make a difference between a class device parent/child (no "device" link, no <class>:<devname> link) and a bus device parent/child (links). For userspace, there is no interesting difference between class or bus device parents.

These links are really only needed with the !DEPRECATED mode, with the directories all spread around in different places, and you need to use these magic links to reconstruct the virtual device tree from it. They are the counterpart of the "device" link which is also not too useful in !DEPRECATED mode, because it's always just the next parent device.

With !DEPRECATED we get a big unified device tree with all devices in _one_ hierarchy. All Child/parent relationships can be read by just walking the up and down the tree. All the classification directories (bus/, class/, block/) will only be lists of symlinks pointing to a specific entry point in the unified tree. From there you can walk upward or downwards the path, without any magic rules.

Thanks,
Kay

#27 lore raw

PATCH 10/14 Convert from class_device to device for USB core

In reply to [email protected]
Signature · 56 lines
Content-Disposition: inline; filename=usb-core.patch

Convert from class_device to device for drivers/ide/usb/core.   Greg, not
sure if you're looking for a patch for this. Kay mentioned maybe it was to
be superceded by a diff mechanism.  Free free to drop if so.

---
 drivers/usb/core/hcd.c |   12 ++++++------
 include/linux/usb.h    |    2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -739,15 +739,15 @@ static int usb_register_bus(struct usb_b
 		return -E2BIG;
 	}
 
-	bus->class_dev = class_device_create(usb_host_class, NULL, MKDEV(0,0),
-					     bus->controller, "usb_host%d", busnum);
-	if (IS_ERR(bus->class_dev)) {
+	bus->dev = device_create(usb_host_class, bus->controller, MKDEV(0,0),
+				 "usb_host%d", busnum);
+	if (IS_ERR(bus->dev)) {
 		clear_bit(busnum, busmap.busmap);
 		mutex_unlock(&usb_bus_list_lock);
-		return PTR_ERR(bus->class_dev);
+		return PTR_ERR(bus->dev);
 	}
 
-	class_set_devdata(bus->class_dev, bus);
+	dev_set_drvdata(bus->dev, bus);
 
 	/* Add it to the local list of buses */
 	list_add (&bus->bus_list, &usb_bus_list);
@@ -784,7 +784,7 @@ static void usb_deregister_bus (struct u
 
 	clear_bit (bus->busnum, busmap.busmap);
 
-	class_device_unregister(bus->class_dev);
+	device_unregister(bus->dev);
 }
 
 /**
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -314,7 +314,7 @@ struct usb_bus {
 #ifdef CONFIG_USB_DEVICEFS
 	struct dentry *usbfs_dentry;	/* usbfs dentry entry for the bus */
 #endif
-	struct class_device *class_dev;	/* class device for this bus */
+	struct device *dev;		/* device for this bus */
 
 #if defined(CONFIG_USB_MON)
 	struct mon_bus *mon_bus;	/* non-null when associated */

-- 
author
#28 lore raw

Re: [patch 10/14] Convert from class_device to device for USB core

Quoted 6 lines · On Mon, Aug 20, 2007 at 03:48:16PM -0700, [email protected] wrote:
Signature · 5 lines
Content-Disposition: inline; filename=usb-core.patch

Convert from class_device to device for drivers/ide/usb/core.   Greg, not
sure if you're looking for a patch for this. Kay mentioned maybe it was to
be superceded by a diff mechanism.  Free free to drop if so.
#29 lore raw

PATCH 11/14 Convert from class_device to device for USB host

In reply to [email protected]
Signature · 295 lines
Content-Disposition: inline; filename=usb-host.patch

Convert from class_device to device for drivers/ide/usb/host.   Greg, not
sure if you're looking for a patch for this. Kay mentioned maybe it was to
be superceded by a diff mechanism.  Free free to drop if so. Thanks!

---
 drivers/usb/host/ehci-dbg.c |   34 +++++++++++++++++-----------------
 drivers/usb/host/ehci-hub.c |   23 +++++++++++++----------
 drivers/usb/host/ohci-dbg.c |   34 +++++++++++++++++-----------------
 3 files changed, 47 insertions(+), 44 deletions(-)

--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -442,7 +442,7 @@ done:
 }
 
 static ssize_t
-show_async (struct class_device *class_dev, char *buf)
+show_async (struct device *dev, struct device_attribute *attr, char *buf)
 {
 	struct usb_bus		*bus;
 	struct usb_hcd		*hcd;
@@ -454,7 +454,7 @@ show_async (struct class_device *class_d
 
 	*buf = 0;
 
-	bus = class_get_devdata(class_dev);
+	bus = dev_get_drvdata(dev);
 	hcd = bus_to_hcd(bus);
 	ehci = hcd_to_ehci (hcd);
 	next = buf;
@@ -479,12 +479,12 @@ show_async (struct class_device *class_d
 
 	return strlen (buf);
 }
-static CLASS_DEVICE_ATTR (async, S_IRUGO, show_async, NULL);
+static DEVICE_ATTR (async, S_IRUGO, show_async, NULL);
 
 #define DBG_SCHED_LIMIT 64
 
 static ssize_t
-show_periodic (struct class_device *class_dev, char *buf)
+show_periodic (struct device *dev, struct device_attribute *attr, char *buf)
 {
 	struct usb_bus		*bus;
 	struct usb_hcd		*hcd;
@@ -500,7 +500,7 @@ show_periodic (struct class_device *clas
 		return 0;
 	seen_count = 0;
 
-	bus = class_get_devdata(class_dev);
+	bus = dev_get_drvdata(dev);
 	hcd = bus_to_hcd(bus);
 	ehci = hcd_to_ehci (hcd);
 	next = buf;
@@ -623,12 +623,12 @@ show_periodic (struct class_device *clas
 
 	return PAGE_SIZE - size;
 }
-static CLASS_DEVICE_ATTR (periodic, S_IRUGO, show_periodic, NULL);
+static DEVICE_ATTR (periodic, S_IRUGO, show_periodic, NULL);
 
 #undef DBG_SCHED_LIMIT
 
 static ssize_t
-show_registers (struct class_device *class_dev, char *buf)
+show_registers (struct device *dev, struct device_attribute *attr, char *buf)
 {
 	struct usb_bus		*bus;
 	struct usb_hcd		*hcd;
@@ -639,7 +639,7 @@ show_registers (struct class_device *cla
 	static char		fmt [] = "%*s\n";
 	static char		label [] = "";
 
-	bus = class_get_devdata(class_dev);
+	bus = dev_get_drvdata(dev);
 	hcd = bus_to_hcd(bus);
 	ehci = hcd_to_ehci (hcd);
 	next = buf;
@@ -789,25 +789,25 @@ done:
 
 	return PAGE_SIZE - size;
 }
-static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
+static DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
 
 static inline void create_debug_files (struct ehci_hcd *ehci)
 {
-	struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev;
+	struct device *dev = ehci_to_hcd(ehci)->self.dev;
 	int retval;
 
-	retval = class_device_create_file(cldev, &class_device_attr_async);
-	retval = class_device_create_file(cldev, &class_device_attr_periodic);
-	retval = class_device_create_file(cldev, &class_device_attr_registers);
+	retval = device_create_file(cldev, &device_attr_async);
+	retval = device_create_file(cldev, &device_attr_periodic);
+	retval = device_create_file(cldev, &device_attr_registers);
 }
 
 static inline void remove_debug_files (struct ehci_hcd *ehci)
 {
-	struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev;
+	struct device *dev = ehci_to_hcd(ehci)->self.dev;
 
-	class_device_remove_file(cldev, &class_device_attr_async);
-	class_device_remove_file(cldev, &class_device_attr_periodic);
-	class_device_remove_file(cldev, &class_device_attr_registers);
+	device_remove_file(cldev, &device_attr_async);
+	device_remove_file(cldev, &device_attr_periodic);
+	device_remove_file(cldev, &device_attr_registers);
 }
 
 #endif /* STUB_DEBUG_FILES */
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -291,14 +291,16 @@ static int ehci_bus_resume (struct usb_h
 /*-------------------------------------------------------------------------*/
 
 /* Display the ports dedicated to the companion controller */
-static ssize_t show_companion(struct class_device *class_dev, char *buf)
+static ssize_t show_companion(struct device *dev,
+			      struct device_attribute *attr,
+			      char *buf)
 {
 	struct ehci_hcd		*ehci;
 	int			nports, index, n;
 	int			count = PAGE_SIZE;
 	char			*ptr = buf;
 
-	ehci = hcd_to_ehci(bus_to_hcd(class_get_devdata(class_dev)));
+	ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev)));
 	nports = HCS_N_PORTS(ehci->hcs_params);
 
 	for (index = 0; index < nports; ++index) {
@@ -316,15 +318,16 @@ static ssize_t show_companion(struct cla
  * Syntax is "[-]portnum", where a leading '-' sign means
  * return control of the port to the EHCI controller.
  */
-static ssize_t store_companion(struct class_device *class_dev,
-		const char *buf, size_t count)
+static ssize_t store_companion(struct device *dev,
+			       struct device_attribute *attr,
+			       const char *buf, size_t count)
 {
 	struct ehci_hcd		*ehci;
 	int			portnum, new_owner, try;
 	u32 __iomem		*status_reg;
 	u32			port_status;
 
-	ehci = hcd_to_ehci(bus_to_hcd(class_get_devdata(class_dev)));
+	ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev)));
 	new_owner = PORT_OWNER;		/* Owned by companion */
 	if (sscanf(buf, "%d", &portnum) != 1)
 		return -EINVAL;
@@ -364,7 +367,7 @@ static ssize_t store_companion(struct cl
 	}
 	return count;
 }
-static CLASS_DEVICE_ATTR(companion, 0644, show_companion, store_companion);
+static DEVICE_ATTR(companion, 0644, show_companion, store_companion);
 
 static inline void create_companion_file(struct ehci_hcd *ehci)
 {
@@ -372,16 +375,16 @@ static inline void create_companion_file
 
 	/* with integrated TT there is no companion! */
 	if (!ehci_is_TDI(ehci))
-		i = class_device_create_file(ehci_to_hcd(ehci)->self.class_dev,
-				&class_device_attr_companion);
+		i = device_create_file(ehci_to_hcd(ehci)->self.dev,
+				       &dev_attr_companion);
 }
 
 static inline void remove_companion_file(struct ehci_hcd *ehci)
 {
 	/* with integrated TT there is no companion! */
 	if (!ehci_is_TDI(ehci))
-		class_device_remove_file(ehci_to_hcd(ehci)->self.class_dev,
-				&class_device_attr_companion);
+		device_remove_file(ehci_to_hcd(ehci)->self.dev,
+				   &dev_attr_companion);
 }
 
 
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -468,7 +468,7 @@ show_list (struct ohci_hcd *ohci, char *
 }
 
 static ssize_t
-show_async (struct class_device *class_dev, char *buf)
+show_async (struct device *dev, struct device_attribute *attr, char *buf)
 {
 	struct usb_bus		*bus;
 	struct usb_hcd		*hcd;
@@ -476,7 +476,7 @@ show_async (struct class_device *class_d
 	size_t			temp;
 	unsigned long		flags;
 
-	bus = class_get_devdata(class_dev);
+	bus = dev_get_drvdata(dev);
 	hcd = bus_to_hcd(bus);
 	ohci = hcd_to_ohci(hcd);
 
@@ -488,13 +488,13 @@ show_async (struct class_device *class_d
 
 	return temp;
 }
-static CLASS_DEVICE_ATTR (async, S_IRUGO, show_async, NULL);
+static DEVICE_ATTR (async, S_IRUGO, show_async, NULL);
 
 
 #define DBG_SCHED_LIMIT 64
 
 static ssize_t
-show_periodic (struct class_device *class_dev, char *buf)
+show_periodic (struct device *dev, struct device_attribute *attr, char *buf)
 {
 	struct usb_bus		*bus;
 	struct usb_hcd		*hcd;
@@ -509,7 +509,7 @@ show_periodic (struct class_device *clas
 		return 0;
 	seen_count = 0;
 
-	bus = class_get_devdata(class_dev);
+	bus = dev_get_drvdata(dev);
 	hcd = bus_to_hcd(bus);
 	ohci = hcd_to_ohci(hcd);
 	next = buf;
@@ -589,13 +589,13 @@ show_periodic (struct class_device *clas
 
 	return PAGE_SIZE - size;
 }
-static CLASS_DEVICE_ATTR (periodic, S_IRUGO, show_periodic, NULL);
+static DEVICE_ATTR (periodic, S_IRUGO, show_periodic, NULL);
 
 
 #undef DBG_SCHED_LIMIT
 
 static ssize_t
-show_registers (struct class_device *class_dev, char *buf)
+show_registers (struct device *dev, struct device_attribute *attr, char *buf)
 {
 	struct usb_bus		*bus;
 	struct usb_hcd		*hcd;
@@ -606,7 +606,7 @@ show_registers (struct class_device *cla
 	char			*next;
 	u32			rdata;
 
-	bus = class_get_devdata(class_dev);
+	bus = dev_get_drvdata(dev);
 	hcd = bus_to_hcd(bus);
 	ohci = hcd_to_ohci(hcd);
 	regs = ohci->regs;
@@ -679,27 +679,27 @@ done:
 	spin_unlock_irqrestore (&ohci->lock, flags);
 	return PAGE_SIZE - size;
 }
-static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
+static DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
 
 
 static inline void create_debug_files (struct ohci_hcd *ohci)
 {
-	struct class_device *cldev = ohci_to_hcd(ohci)->self.class_dev;
+	struct device *dev = ohci_to_hcd(ohci)->self.dev;
 	int retval;
 
-	retval = class_device_create_file(cldev, &class_device_attr_async);
-	retval = class_device_create_file(cldev, &class_device_attr_periodic);
-	retval = class_device_create_file(cldev, &class_device_attr_registers);
+	retval = device_create_file(cldev, &device_attr_async);
+	retval = device_create_file(cldev, &device_attr_periodic);
+	retval = device_create_file(cldev, &device_attr_registers);
 	ohci_dbg (ohci, "created debug files\n");
 }
 
 static inline void remove_debug_files (struct ohci_hcd *ohci)
 {
-	struct class_device *cldev = ohci_to_hcd(ohci)->self.class_dev;
+	struct device *dev = ohci_to_hcd(ohci)->self.dev;
 
-	class_device_remove_file(cldev, &class_device_attr_async);
-	class_device_remove_file(cldev, &class_device_attr_periodic);
-	class_device_remove_file(cldev, &class_device_attr_registers);
+	device_remove_file(cldev, &device_attr_async);
+	device_remove_file(cldev, &device_attr_periodic);
+	device_remove_file(cldev, &device_attr_registers);
 }
 
 #endif

-- 
author
#30 lore raw

Re: [patch 11/14] Convert from class_device to device for USB host

Quoted 6 lines · On Mon, Aug 20, 2007 at 03:48:17PM -0700, [email protected] wrote:
Signature · 5 lines
Content-Disposition: inline; filename=usb-host.patch

Convert from class_device to device for drivers/ide/usb/host.   Greg, not
sure if you're looking for a patch for this. Kay mentioned maybe it was to
be superceded by a diff mechanism.  Free free to drop if so. Thanks!
#31 lore raw

Re: [patch 11/14] Convert from class_device to device for USB host

In reply to [email protected]
Quoted 6 lines · On Mon, Aug 20, 2007 at 03:48:17PM -0700, [email protected] wrote:
Signature · 5 lines
Content-Disposition: inline; filename=usb-host.patch

Convert from class_device to device for drivers/ide/usb/host.   Greg, not
sure if you're looking for a patch for this. Kay mentioned maybe it was to
be superceded by a diff mechanism.  Free free to drop if so. Thanks!

Yeah, these files all need to go to debugfs, not stay as sysfs files. If you want to do that, that would be wonderful, I'd really appreciate it. Otherwise it's going to be a few weeks before I can do this.

thanks,

greg k-h

#32 lore raw

PATCH 12/14 Convert from class_device to device for TI flash media

In reply to [email protected]
Signature · 118 lines
Content-Disposition: inline; filename=misc.patch

Convert from class_device to device for drivers/misc/tifm.  This is
part of the work to eliminate struct class_device.

---
 drivers/misc/tifm_7xx1.c |    4 ++--
 drivers/misc/tifm_core.c |   24 ++++++++++++------------
 include/linux/tifm.h     |    2 +-
 3 files changed, 15 insertions(+), 15 deletions(-)

--- a/drivers/misc/tifm_core.c
+++ b/drivers/misc/tifm_core.c
@@ -165,16 +165,16 @@ static struct bus_type tifm_bus_type = {
 	.resume    = tifm_device_resume
 };
 
-static void tifm_free(struct class_device *cdev)
+static void tifm_free(struct device *dev)
 {
-	struct tifm_adapter *fm = container_of(cdev, struct tifm_adapter, cdev);
+	struct tifm_adapter *fm = container_of(dev, struct tifm_adapter, dev);
 
 	kfree(fm);
 }
 
 static struct class tifm_adapter_class = {
 	.name    = "tifm_adapter",
-	.release = tifm_free
+	.dev_release = tifm_free
 };
 
 struct tifm_adapter *tifm_alloc_adapter(unsigned int num_sockets,
@@ -185,9 +185,9 @@ struct tifm_adapter *tifm_alloc_adapter(
 	fm = kzalloc(sizeof(struct tifm_adapter)
 		     + sizeof(struct tifm_dev*) * num_sockets, GFP_KERNEL);
 	if (fm) {
-		fm->cdev.class = &tifm_adapter_class;
-		fm->cdev.dev = dev;
-		class_device_initialize(&fm->cdev);
+		fm->dev.class = &tifm_adapter_class;
+		fm->dev.parent = dev;
+		device_initialize(&fm->dev);
 		spin_lock_init(&fm->lock);
 		fm->num_sockets = num_sockets;
 	}
@@ -208,8 +208,8 @@ int tifm_add_adapter(struct tifm_adapter
 	if (rc)
 		return rc;
 
-	snprintf(fm->cdev.class_id, BUS_ID_SIZE, "tifm%u", fm->id);
-	rc = class_device_add(&fm->cdev);
+	snprintf(fm->dev.bus_id, BUS_ID_SIZE, "tifm%u", fm->id);
+	rc = device_add(&fm->dev);
 	if (rc) {
 		spin_lock(&tifm_adapter_lock);
 		idr_remove(&tifm_adapter_idr, fm->id);
@@ -233,13 +233,13 @@ void tifm_remove_adapter(struct tifm_ada
 	spin_lock(&tifm_adapter_lock);
 	idr_remove(&tifm_adapter_idr, fm->id);
 	spin_unlock(&tifm_adapter_lock);
-	class_device_del(&fm->cdev);
+	device_del(&fm->dev);
 }
 EXPORT_SYMBOL(tifm_remove_adapter);
 
 void tifm_free_adapter(struct tifm_adapter *fm)
 {
-	class_device_put(&fm->cdev);
+	put_device(&fm->dev);
 }
 EXPORT_SYMBOL(tifm_free_adapter);
 
@@ -266,9 +266,9 @@ struct tifm_dev *tifm_alloc_device(struc
 		sock->card_event = tifm_dummy_event;
 		sock->data_event = tifm_dummy_event;
 
-		sock->dev.parent = fm->cdev.dev;
+		sock->dev.parent = fm->dev.parent;
 		sock->dev.bus = &tifm_bus_type;
-		sock->dev.dma_mask = fm->cdev.dev->dma_mask;
+		sock->dev.dma_mask = fm->dev.parent->dma_mask;
 		sock->dev.release = tifm_free_device;
 
 		snprintf(sock->dev.bus_id, BUS_ID_SIZE,
--- a/include/linux/tifm.h
+++ b/include/linux/tifm.h
@@ -120,7 +120,7 @@ struct tifm_adapter {
 	struct completion   *finish_me;
 
 	struct work_struct  media_switcher;
-	struct class_device cdev;
+	struct device	    dev;
 
 	void                (*eject)(struct tifm_adapter *fm,
 				     struct tifm_dev *sock);
--- a/drivers/misc/tifm_7xx1.c
+++ b/drivers/misc/tifm_7xx1.c
@@ -149,7 +149,7 @@ static void tifm_7xx1_switch_media(struc
 	socket_change_set = fm->socket_change_set;
 	fm->socket_change_set = 0;
 
-	dev_dbg(fm->cdev.dev, "checking media set %x\n",
+	dev_dbg(fm->dev.parent, "checking media set %x\n",
 		socket_change_set);
 
 	if (!socket_change_set) {
@@ -164,7 +164,7 @@ static void tifm_7xx1_switch_media(struc
 		if (sock) {
 			printk(KERN_INFO
 			       "%s : demand removing card from socket %u:%u\n",
-			       fm->cdev.class_id, fm->id, cnt);
+			       fm->dev.bus_id, fm->id, cnt);
 			fm->sockets[cnt] = NULL;
 			sock_addr = sock->addr;
 			spin_unlock_irqrestore(&fm->lock, flags);

-- 
author
#33 lore raw

Re: [patch 12/14] Convert from class_device to device for TI flash media

Quoted 5 lines · On Mon, Aug 20, 2007 at 03:48:18PM -0700, [email protected] wrote:
Signature · 4 lines
Content-Disposition: inline; filename=misc.patch

Convert from class_device to device for drivers/misc/tifm.  This is
part of the work to eliminate struct class_device.
#34 lore raw

PATCH 13/14 Convert from class_device to device for UCB1x00

In reply to [email protected]
Signature · 129 lines
Content-Disposition: inline; filename=mfd.patch

Convert from class_device to device for drivers/mfd/ucb1x00.  This is
part of the work to eliminate struct class_device.

---
 drivers/mfd/ucb1x00-assabet.c |   17 +++++++++--------
 drivers/mfd/ucb1x00-core.c    |   14 +++++++-------
 drivers/mfd/ucb1x00.h         |    4 ++--
 3 files changed, 18 insertions(+), 17 deletions(-)

--- a/drivers/mfd/ucb1x00-assabet.c
+++ b/drivers/mfd/ucb1x00-assabet.c
@@ -20,7 +20,8 @@
 #include "ucb1x00.h"
 
 #define UCB1X00_ATTR(name,input)\
-static ssize_t name##_show(struct class_device *dev, char *buf)	\
+static ssize_t name##_show(struct device *dev, struct device_attribute *attr,
+			   char *buf)	\
 {								\
 	struct ucb1x00 *ucb = classdev_to_ucb1x00(dev);		\
 	int val;						\
@@ -29,7 +30,7 @@ static ssize_t name##_show(struct class_
 	ucb1x00_adc_disable(ucb);				\
 	return sprintf(buf, "%d\n", val);			\
 }								\
-static CLASS_DEVICE_ATTR(name,0444,name##_show,NULL)
+static DEVICE_ATTR(name,0444,name##_show,NULL)
 
 UCB1X00_ATTR(vbatt, UCB_ADC_INP_AD1);
 UCB1X00_ATTR(vcharger, UCB_ADC_INP_AD0);
@@ -37,17 +38,17 @@ UCB1X00_ATTR(batt_temp, UCB_ADC_INP_AD2)
 
 static int ucb1x00_assabet_add(struct ucb1x00_dev *dev)
 {
-	class_device_create_file(&dev->ucb->cdev, &class_device_attr_vbatt);
-	class_device_create_file(&dev->ucb->cdev, &class_device_attr_vcharger);
-	class_device_create_file(&dev->ucb->cdev, &class_device_attr_batt_temp);
+	device_create_file(&dev->ucb->dev, &device_attr_vbatt);
+	device_create_file(&dev->ucb->dev, &device_attr_vcharger);
+	device_create_file(&dev->ucb->dev, &device_attr_batt_temp);
 	return 0;
 }
 
 static void ucb1x00_assabet_remove(struct ucb1x00_dev *dev)
 {
-	class_device_remove_file(&dev->ucb->cdev, &class_device_attr_batt_temp);
-	class_device_remove_file(&dev->ucb->cdev, &class_device_attr_vcharger);
-	class_device_remove_file(&dev->ucb->cdev, &class_device_attr_vbatt);
+	device_remove_file(&dev->ucb->cdev, &device_attr_batt_temp);
+	device_remove_file(&dev->ucb->cdev, &device_attr_vcharger);
+	device_remove_file(&dev->ucb->cdev, &device_attr_vbatt);
 }
 
 static struct ucb1x00_driver ucb1x00_assabet_driver = {
--- a/drivers/mfd/ucb1x00-core.c
+++ b/drivers/mfd/ucb1x00-core.c
@@ -458,7 +458,7 @@ static int ucb1x00_detect_irq(struct ucb
 	return probe_irq_off(mask);
 }
 
-static void ucb1x00_release(struct class_device *dev)
+static void ucb1x00_release(struct device *dev)
 {
 	struct ucb1x00 *ucb = classdev_to_ucb1x00(dev);
 	kfree(ucb);
@@ -466,7 +466,7 @@ static void ucb1x00_release(struct class
 
 static struct class ucb1x00_class = {
 	.name		= "ucb1x00",
-	.release	= ucb1x00_release,
+	.dev_release	= ucb1x00_release,
 };
 
 static int ucb1x00_probe(struct mcp *mcp)
@@ -490,9 +490,9 @@ static int ucb1x00_probe(struct mcp *mcp
 		goto err_disable;
 
 
-	ucb->cdev.class = &ucb1x00_class;
-	ucb->cdev.dev = &mcp->attached_device;
-	strlcpy(ucb->cdev.class_id, "ucb1x00", sizeof(ucb->cdev.class_id));
+	ucb->dev.class = &ucb1x00_class;
+	ucb->dev.parent = &mcp->attached_device;
+	strlcpy(ucb->dev.bus_id, "ucb1x00", sizeof(ucb->dev.bus_id));
 
 	spin_lock_init(&ucb->lock);
 	spin_lock_init(&ucb->io_lock);
@@ -517,7 +517,7 @@ static int ucb1x00_probe(struct mcp *mcp
 
 	mcp_set_drvdata(mcp, ucb);
 
-	ret = class_device_register(&ucb->cdev);
+	ret = device_register(&ucb->dev);
 	if (ret)
 		goto err_irq;
 
@@ -554,7 +554,7 @@ static void ucb1x00_remove(struct mcp *m
 	mutex_unlock(&ucb1x00_mutex);
 
 	free_irq(ucb->irq, ucb);
-	class_device_unregister(&ucb->cdev);
+	device_unregister(&ucb->dev);
 }
 
 int ucb1x00_register_driver(struct ucb1x00_driver *drv)
--- a/drivers/mfd/ucb1x00.h
+++ b/drivers/mfd/ucb1x00.h
@@ -120,7 +120,7 @@ struct ucb1x00 {
 	u16			irq_fal_enbl;
 	u16			irq_ris_enbl;
 	struct ucb1x00_irq	irq_handler[16];
-	struct class_device	cdev;
+	struct device		dev;
 	struct list_head	node;
 	struct list_head	devs;
 };
@@ -144,7 +144,7 @@ struct ucb1x00_driver {
 	int	(*resume)(struct ucb1x00_dev *dev);
 };
 
-#define classdev_to_ucb1x00(cd)	container_of(cd, struct ucb1x00, cdev)
+#define classdev_to_ucb1x00(cd)	container_of(cd, struct ucb1x00, dev)
 
 int ucb1x00_register_driver(struct ucb1x00_driver *);
 void ucb1x00_unregister_driver(struct ucb1x00_driver *);

-- 
author
#35 lore raw

Re: [patch 13/14] Convert from class_device to device for UCB1x00

Quoted 5 lines · On Mon, Aug 20, 2007 at 03:48:19PM -0700, [email protected] wrote:
Signature · 4 lines
Content-Disposition: inline; filename=mfd.patch

Convert from class_device to device for drivers/mfd/ucb1x00.  This is
part of the work to eliminate struct class_device.
#36 lore raw

PATCH 14/14 Convert from class_device to device for ISDN capi

In reply to [email protected]
Signature · 36 lines
Content-Disposition: inline; filename=isdn-capi.patch

Convert from class_device to device for drivers/isdn/capi.  This is
part of the work to eliminate struct class_device.

---
 drivers/isdn/capi/capi.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1544,11 +1544,11 @@ static int __init capi_init(void)
 		return PTR_ERR(capi_class);
 	}
 
-	class_device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi");
+	device_create(capi_class, NULL, MKDEV(capi_major, 0), "capi");
 
 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
 	if (capinc_tty_init() < 0) {
-		class_device_destroy(capi_class, MKDEV(capi_major, 0));
+		device_destroy(capi_class, MKDEV(capi_major, 0));
 		class_destroy(capi_class);
 		unregister_chrdev(capi_major, "capi20");
 		return -ENOMEM;
@@ -1576,7 +1576,7 @@ static void __exit capi_exit(void)
 {
 	proc_exit();
 
-	class_device_destroy(capi_class, MKDEV(capi_major, 0));
+	device_destroy(capi_class, MKDEV(capi_major, 0));
 	class_destroy(capi_class);
 	unregister_chrdev(capi_major, "capi20");
 

-- 
#37 lore raw

Re: [patch 14/14] Convert from class_device to device for ISDN capi

Quoted 6 lines · On Mon, Aug 20, 2007 at 03:48:20PM -0700, [email protected] wrote:
Signature · 4 lines
Content-Disposition: inline; filename=isdn-capi.patch

Convert from class_device to device for drivers/isdn/capi.  This is
part of the work to eliminate struct class_device.

If you add a Signed-off-by:
I'll ack this patch.

Quoted 31 lines
---
 drivers/isdn/capi/capi.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/isdn/capi/capi.c +3 -3
@@ -1544,11 +1544,11 @@ static int __init capi_init(void)
 		return PTR_ERR(capi_class);
 	}
 
-	class_device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi");
+	device_create(capi_class, NULL, MKDEV(capi_major, 0), "capi");
 
 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
 	if (capinc_tty_init() < 0) {
-		class_device_destroy(capi_class, MKDEV(capi_major, 0));
+		device_destroy(capi_class, MKDEV(capi_major, 0));
 		class_destroy(capi_class);
 		unregister_chrdev(capi_major, "capi20");
 		return -ENOMEM;
@@ -1576,7 +1576,7 @@ static void __exit capi_exit(void)
 {
 	proc_exit();
 
-	class_device_destroy(capi_class, MKDEV(capi_major, 0));
+	device_destroy(capi_class, MKDEV(capi_major, 0));
 	class_destroy(capi_class);
 	unregister_chrdev(capi_major, "capi20");
 
Signature · 1 line
-- 
Signature · 4 lines
Karsten Keil
SuSE Labs
ISDN and VOIP development
SUSE LINUX Products GmbH, Maxfeldstr.5 90409 Nuernberg, GF: Markus Rex, HRB 16746 (AG Nuernberg)
author
#38 lore raw

Re: [patch 14/14] Convert from class_device to device for ISDN capi

Quoted 10 lines · Karsten Keil
Quoted 6 lines · On Mon, Aug 20, 2007 at 03:48:20PM -0700, [email protected] wrote:
Signature · 4 lines
Content-Disposition: inline; filename=isdn-capi.patch

Convert from class_device to device for drivers/isdn/capi.  This is
part of the work to eliminate struct class_device.

If you add a Signed-off-by:
I'll ack this patch.

Sorry, I added one for the first but the remainders got lost in the cut-paste.

--------

Subject: Convert from class_device to device for ISDN capi

Convert from class_device to device for drivers/isdn/capi. This is part of the work to eliminate struct class_device.

---
 drivers/isdn/capi/capi.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/isdn/capi/capi.c +3 -3
@@ -1544,11 +1544,11 @@ static int __init capi_init(void)
 		return PTR_ERR(capi_class);
 	}
 
-	class_device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi");
+	device_create(capi_class, NULL, MKDEV(capi_major, 0), "capi");
 
 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
 	if (capinc_tty_init() < 0) {
-		class_device_destroy(capi_class, MKDEV(capi_major, 0));
+		device_destroy(capi_class, MKDEV(capi_major, 0));
 		class_destroy(capi_class);
 		unregister_chrdev(capi_major, "capi20");
 		return -ENOMEM;
@@ -1576,7 +1576,7 @@ static void __exit capi_exit(void)
 {
 	proc_exit();
 
-	class_device_destroy(capi_class, MKDEV(capi_major, 0));
+	device_destroy(capi_class, MKDEV(capi_major, 0));
 	class_destroy(capi_class);
 	unregister_chrdev(capi_major, "capi20");