aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2005-07-15 04:09:25 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-05 19:03:10 -0400
commit94fd0db7bfb4a03da202fd426d4e8e7eab42ab86 (patch)
tree3b440ad6560e832f2b91629e6af7fa9b602f75c0 /drivers
parent76d1ce00bdd76c2987fbfb763cd40447413a55b3 (diff)
[PATCH] Floppy: Add cmos attribute to floppy driver
Currently only a device 'fdX' shows up in sysfs; the other possible device for this drive (like fd0h1440 etc) must be guessed from there. This patch corrects the floppy driver to create a platform device for each floppy found; each platform device also has an attribute 'cmos' which represents the cmos type for this drive. From this attribute the other possible device types can be computed. From: Hannes Reinecke <hare@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/floppy.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index f0c1084b840f..21f58c4b3c79 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -493,6 +493,8 @@ static struct floppy_struct user_params[N_DRIVE];
493 493
494static sector_t floppy_sizes[256]; 494static sector_t floppy_sizes[256];
495 495
496static char floppy_device_name[] = "floppy";
497
496/* 498/*
497 * The driver is trying to determine the correct media format 499 * The driver is trying to determine the correct media format
498 * while probing is set. rw_interrupt() clears it after a 500 * while probing is set. rw_interrupt() clears it after a
@@ -4191,18 +4193,25 @@ static int __init floppy_setup(char *str)
4191 4193
4192static int have_no_fdc = -ENODEV; 4194static int have_no_fdc = -ENODEV;
4193 4195
4196static ssize_t floppy_cmos_show(struct device *dev, struct device_attribute *attr, char *buf)
4197{
4198 struct platform_device *p = container_of(dev,struct platform_device,dev);
4199 int drive = p->id;
4200 ssize_t retval;
4201
4202 retval = sprintf(buf,"%X\n", UDP->cmos);
4203
4204 return retval;
4205}
4206
4207DEVICE_ATTR(cmos,S_IRUGO,floppy_cmos_show,NULL);
4208
4194static void floppy_device_release(struct device *dev) 4209static void floppy_device_release(struct device *dev)
4195{ 4210{
4196 complete(&device_release); 4211 complete(&device_release);
4197} 4212}
4198 4213
4199static struct platform_device floppy_device = { 4214static struct platform_device floppy_device[N_DRIVE];
4200 .name = "floppy",
4201 .id = 0,
4202 .dev = {
4203 .release = floppy_device_release,
4204 }
4205};
4206 4215
4207static struct kobject *floppy_find(dev_t dev, int *part, void *data) 4216static struct kobject *floppy_find(dev_t dev, int *part, void *data)
4208{ 4217{
@@ -4370,20 +4379,26 @@ static int __init floppy_init(void)
4370 goto out_flush_work; 4379 goto out_flush_work;
4371 } 4380 }
4372 4381
4373 err = platform_device_register(&floppy_device);
4374 if (err)
4375 goto out_flush_work;
4376
4377 for (drive = 0; drive < N_DRIVE; drive++) { 4382 for (drive = 0; drive < N_DRIVE; drive++) {
4378 if (!(allowed_drive_mask & (1 << drive))) 4383 if (!(allowed_drive_mask & (1 << drive)))
4379 continue; 4384 continue;
4380 if (fdc_state[FDC(drive)].version == FDC_NONE) 4385 if (fdc_state[FDC(drive)].version == FDC_NONE)
4381 continue; 4386 continue;
4387
4388 floppy_device[drive].name = floppy_device_name;
4389 floppy_device[drive].id = drive;
4390 floppy_device[drive].dev.release = floppy_device_release;
4391
4392 err = platform_device_register(&floppy_device[drive]);
4393 if (err)
4394 goto out_flush_work;
4395
4396 device_create_file(&floppy_device[drive].dev,&dev_attr_cmos);
4382 /* to be cleaned up... */ 4397 /* to be cleaned up... */
4383 disks[drive]->private_data = (void *)(long)drive; 4398 disks[drive]->private_data = (void *)(long)drive;
4384 disks[drive]->queue = floppy_queue; 4399 disks[drive]->queue = floppy_queue;
4385 disks[drive]->flags |= GENHD_FL_REMOVABLE; 4400 disks[drive]->flags |= GENHD_FL_REMOVABLE;
4386 disks[drive]->driverfs_dev = &floppy_device.dev; 4401 disks[drive]->driverfs_dev = &floppy_device[drive].dev;
4387 add_disk(disks[drive]); 4402 add_disk(disks[drive]);
4388 } 4403 }
4389 4404
@@ -4603,10 +4618,11 @@ void cleanup_module(void)
4603 fdc_state[FDC(drive)].version != FDC_NONE) { 4618 fdc_state[FDC(drive)].version != FDC_NONE) {
4604 del_gendisk(disks[drive]); 4619 del_gendisk(disks[drive]);
4605 unregister_devfs_entries(drive); 4620 unregister_devfs_entries(drive);
4621 device_remove_file(&floppy_device[drive].dev, &dev_attr_cmos);
4622 platform_device_unregister(&floppy_device[drive]);
4606 } 4623 }
4607 put_disk(disks[drive]); 4624 put_disk(disks[drive]);
4608 } 4625 }
4609 platform_device_unregister(&floppy_device);
4610 devfs_remove("floppy"); 4626 devfs_remove("floppy");
4611 4627
4612 del_timer_sync(&fd_timeout); 4628 del_timer_sync(&fd_timeout);