aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/floppy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/floppy.c')
-rw-r--r--drivers/block/floppy.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index f0c1084b840f..888dad5eef34 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,24 @@ 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,
4197 struct device_attribute *attr, char *buf)
4198{
4199 struct platform_device *p;
4200 int drive;
4201
4202 p = container_of(dev, struct platform_device,dev);
4203 drive = p->id;
4204 return sprintf(buf, "%X\n", UDP->cmos);
4205}
4206DEVICE_ATTR(cmos,S_IRUGO,floppy_cmos_show,NULL);
4207
4194static void floppy_device_release(struct device *dev) 4208static void floppy_device_release(struct device *dev)
4195{ 4209{
4196 complete(&device_release); 4210 complete(&device_release);
4197} 4211}
4198 4212
4199static struct platform_device floppy_device = { 4213static struct platform_device floppy_device[N_DRIVE];
4200 .name = "floppy",
4201 .id = 0,
4202 .dev = {
4203 .release = floppy_device_release,
4204 }
4205};
4206 4214
4207static struct kobject *floppy_find(dev_t dev, int *part, void *data) 4215static struct kobject *floppy_find(dev_t dev, int *part, void *data)
4208{ 4216{
@@ -4370,20 +4378,26 @@ static int __init floppy_init(void)
4370 goto out_flush_work; 4378 goto out_flush_work;
4371 } 4379 }
4372 4380
4373 err = platform_device_register(&floppy_device);
4374 if (err)
4375 goto out_flush_work;
4376
4377 for (drive = 0; drive < N_DRIVE; drive++) { 4381 for (drive = 0; drive < N_DRIVE; drive++) {
4378 if (!(allowed_drive_mask & (1 << drive))) 4382 if (!(allowed_drive_mask & (1 << drive)))
4379 continue; 4383 continue;
4380 if (fdc_state[FDC(drive)].version == FDC_NONE) 4384 if (fdc_state[FDC(drive)].version == FDC_NONE)
4381 continue; 4385 continue;
4386
4387 floppy_device[drive].name = floppy_device_name;
4388 floppy_device[drive].id = drive;
4389 floppy_device[drive].dev.release = floppy_device_release;
4390
4391 err = platform_device_register(&floppy_device[drive]);
4392 if (err)
4393 goto out_flush_work;
4394
4395 device_create_file(&floppy_device[drive].dev,&dev_attr_cmos);
4382 /* to be cleaned up... */ 4396 /* to be cleaned up... */
4383 disks[drive]->private_data = (void *)(long)drive; 4397 disks[drive]->private_data = (void *)(long)drive;
4384 disks[drive]->queue = floppy_queue; 4398 disks[drive]->queue = floppy_queue;
4385 disks[drive]->flags |= GENHD_FL_REMOVABLE; 4399 disks[drive]->flags |= GENHD_FL_REMOVABLE;
4386 disks[drive]->driverfs_dev = &floppy_device.dev; 4400 disks[drive]->driverfs_dev = &floppy_device[drive].dev;
4387 add_disk(disks[drive]); 4401 add_disk(disks[drive]);
4388 } 4402 }
4389 4403
@@ -4603,10 +4617,11 @@ void cleanup_module(void)
4603 fdc_state[FDC(drive)].version != FDC_NONE) { 4617 fdc_state[FDC(drive)].version != FDC_NONE) {
4604 del_gendisk(disks[drive]); 4618 del_gendisk(disks[drive]);
4605 unregister_devfs_entries(drive); 4619 unregister_devfs_entries(drive);
4620 device_remove_file(&floppy_device[drive].dev, &dev_attr_cmos);
4621 platform_device_unregister(&floppy_device[drive]);
4606 } 4622 }
4607 put_disk(disks[drive]); 4623 put_disk(disks[drive]);
4608 } 4624 }
4609 platform_device_unregister(&floppy_device);
4610 devfs_remove("floppy"); 4625 devfs_remove("floppy");
4611 4626
4612 del_timer_sync(&fd_timeout); 4627 del_timer_sync(&fd_timeout);