* [PATCH] floppy.c: pass physical device to device registration
@ 2005-01-16 19:55 Kay Sievers
0 siblings, 0 replies; 2+ messages in thread
From: Kay Sievers @ 2005-01-16 19:55 UTC (permalink / raw)
To: linux-kernel
With this patch the floppy driver creates the usual symlink in sysfs to
the physical device backing the block device:
$tree /sys/block/
/sys/block/
|-- fd0
| |-- dev
| |-- device -> ../../devices/platform/floppy0
...
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
===== drivers/block/floppy.c 1.111 vs edited =====
--- 1.111/drivers/block/floppy.c 2005-01-08 06:44:29 +01:00
+++ edited/drivers/block/floppy.c 2005-01-16 20:24:56 +01:00
@@ -4370,6 +4370,10 @@ int __init floppy_init(void)
goto out_flush_work;
}
+ err = platform_device_register(&floppy_device);
+ if (err)
+ goto out_flush_work;
+
for (drive = 0; drive < N_DRIVE; drive++) {
if (!(allowed_drive_mask & (1 << drive)))
continue;
@@ -4379,23 +4383,12 @@ int __init floppy_init(void)
disks[drive]->private_data = (void *)(long)drive;
disks[drive]->queue = floppy_queue;
disks[drive]->flags |= GENHD_FL_REMOVABLE;
+ disks[drive]->driverfs_dev = &floppy_device.dev;
add_disk(disks[drive]);
}
- err = platform_device_register(&floppy_device);
- if (err)
- goto out_del_disk;
-
return 0;
-out_del_disk:
- for (drive = 0; drive < N_DRIVE; drive++) {
- if (!(allowed_drive_mask & (1 << drive)))
- continue;
- if (fdc_state[FDC(drive)].version == FDC_NONE)
- continue;
- del_gendisk(disks[drive]);
- }
out_flush_work:
flush_scheduled_work();
if (usage_count)
@@ -4600,7 +4593,6 @@ void cleanup_module(void)
int drive;
init_completion(&device_release);
- platform_device_unregister(&floppy_device);
blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
unregister_blkdev(FLOPPY_MAJOR, "fd");
@@ -4614,6 +4606,7 @@ void cleanup_module(void)
}
put_disk(disks[drive]);
}
+ platform_device_unregister(&floppy_device);
devfs_remove("floppy");
del_timer_sync(&fd_timeout);
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH] Driver core: add "bus" symlink to class/block devices
@ 2005-03-10 0:34 Greg KH
2005-03-10 0:34 ` [PATCH] floppy.c: pass physical device to device registration Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Greg KH @ 2005-03-10 0:34 UTC (permalink / raw)
To: linux-kernel; +Cc: kay.sievers
ChangeSet 1.2046, 2005/03/09 09:52:48-08:00, kay.sievers@vrfy.org
[PATCH] Driver core: add "bus" symlink to class/block devices
On Tue, Feb 15, 2005 at 09:53:44PM +0100, Kay Sievers wrote:
> Add a "bus" symlink to the class and block devices, just like the "driver"
> and "device" links. This may be a huge speed gain for e.g. udev to determine
> the bus value of a device, as we currently need to do a brute-force scan in
> /sys/bus/* to find this value.
Hmm, while playing around with it, I think we should create the "bus"
link on the physical device on not on the class device.
Also the current "driver" link at the class device should be removed,
cause class devices don't have a driver. Block devices never had this
misleading symlink.
From the class device we point with the "device" link to the physical
device, and only the physical device should have the "driver" and the
"bus" link, as it represents the real relationship.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/bus.c | 2 ++
drivers/base/class.c | 36 +++++-------------------------------
2 files changed, 7 insertions(+), 31 deletions(-)
diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
--- a/drivers/base/bus.c 2005-03-09 16:29:06 -08:00
+++ b/drivers/base/bus.c 2005-03-09 16:29:06 -08:00
@@ -465,6 +465,7 @@
up_write(&dev->bus->subsys.rwsem);
device_add_attrs(bus, dev);
sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
+ sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus");
}
return error;
}
@@ -481,6 +482,7 @@
void bus_remove_device(struct device * dev)
{
if (dev->bus) {
+ sysfs_remove_link(&dev->kobj, "bus");
sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
device_remove_attrs(dev->bus, dev);
down_write(&dev->bus->subsys.rwsem);
diff -Nru a/drivers/base/class.c b/drivers/base/class.c
--- a/drivers/base/class.c 2005-03-09 16:29:06 -08:00
+++ b/drivers/base/class.c 2005-03-09 16:29:06 -08:00
@@ -196,33 +196,6 @@
sysfs_remove_bin_file(&class_dev->kobj, attr);
}
-static int class_device_dev_link(struct class_device * class_dev)
-{
- if (class_dev->dev)
- return sysfs_create_link(&class_dev->kobj,
- &class_dev->dev->kobj, "device");
- return 0;
-}
-
-static void class_device_dev_unlink(struct class_device * class_dev)
-{
- sysfs_remove_link(&class_dev->kobj, "device");
-}
-
-static int class_device_driver_link(struct class_device * class_dev)
-{
- if ((class_dev->dev) && (class_dev->dev->driver))
- return sysfs_create_link(&class_dev->kobj,
- &class_dev->dev->driver->kobj, "driver");
- return 0;
-}
-
-static void class_device_driver_unlink(struct class_device * class_dev)
-{
- sysfs_remove_link(&class_dev->kobj, "driver");
-}
-
-
static ssize_t
class_device_attr_show(struct kobject * kobj, struct attribute * attr,
char * buf)
@@ -452,8 +425,9 @@
class_device_create_file(class_dev, &class_device_attr_dev);
class_device_add_attrs(class_dev);
- class_device_dev_link(class_dev);
- class_device_driver_link(class_dev);
+ if (class_dev->dev)
+ sysfs_create_link(&class_dev->kobj,
+ &class_dev->dev->kobj, "device");
register_done:
if (error && parent)
@@ -482,8 +456,8 @@
up_write(&parent->subsys.rwsem);
}
- class_device_dev_unlink(class_dev);
- class_device_driver_unlink(class_dev);
+ if (class_dev->dev)
+ sysfs_remove_link(&class_dev->kobj, "device");
class_device_remove_attrs(class_dev);
kobject_del(&class_dev->kobj);
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH] floppy.c: pass physical device to device registration
2005-03-10 0:34 [PATCH] Driver core: add "bus" symlink to class/block devices Greg KH
@ 2005-03-10 0:34 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2005-03-10 0:34 UTC (permalink / raw)
To: linux-kernel; +Cc: kay.sievers
ChangeSet 1.2047, 2005/03/09 09:53:08-08:00, kay.sievers@vrfy.org
[PATCH] floppy.c: pass physical device to device registration
With this patch the floppy driver creates the usual symlink in sysfs to
the physical device backing the block device:
$tree /sys/block/
/sys/block/
|-- fd0
| |-- dev
| |-- device -> ../../devices/platform/floppy0
...
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/block/floppy.c | 19 ++++++-------------
1 files changed, 6 insertions(+), 13 deletions(-)
diff -Nru a/drivers/block/floppy.c b/drivers/block/floppy.c
--- a/drivers/block/floppy.c 2005-03-09 16:28:59 -08:00
+++ b/drivers/block/floppy.c 2005-03-09 16:28:59 -08:00
@@ -4370,6 +4370,10 @@
goto out_flush_work;
}
+ err = platform_device_register(&floppy_device);
+ if (err)
+ goto out_flush_work;
+
for (drive = 0; drive < N_DRIVE; drive++) {
if (!(allowed_drive_mask & (1 << drive)))
continue;
@@ -4379,23 +4383,12 @@
disks[drive]->private_data = (void *)(long)drive;
disks[drive]->queue = floppy_queue;
disks[drive]->flags |= GENHD_FL_REMOVABLE;
+ disks[drive]->driverfs_dev = &floppy_device.dev;
add_disk(disks[drive]);
}
- err = platform_device_register(&floppy_device);
- if (err)
- goto out_del_disk;
-
return 0;
-out_del_disk:
- for (drive = 0; drive < N_DRIVE; drive++) {
- if (!(allowed_drive_mask & (1 << drive)))
- continue;
- if (fdc_state[FDC(drive)].version == FDC_NONE)
- continue;
- del_gendisk(disks[drive]);
- }
out_flush_work:
flush_scheduled_work();
if (usage_count)
@@ -4600,7 +4593,6 @@
int drive;
init_completion(&device_release);
- platform_device_unregister(&floppy_device);
blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
unregister_blkdev(FLOPPY_MAJOR, "fd");
@@ -4614,6 +4606,7 @@
}
put_disk(disks[drive]);
}
+ platform_device_unregister(&floppy_device);
devfs_remove("floppy");
del_timer_sync(&fd_timeout);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-03-10 1:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-16 19:55 [PATCH] floppy.c: pass physical device to device registration Kay Sievers
2005-03-10 0:34 [PATCH] Driver core: add "bus" symlink to class/block devices Greg KH
2005-03-10 0:34 ` [PATCH] floppy.c: pass physical device to device registration Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®