Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Hannes Reinecke and committed by
Greg Kroah-Hartman
94fd0db7 76d1ce00

+29 -13
+29 -13
drivers/block/floppy.c
··· 493 493 494 494 static sector_t floppy_sizes[256]; 495 495 496 + static char floppy_device_name[] = "floppy"; 497 + 496 498 /* 497 499 * The driver is trying to determine the correct media format 498 500 * while probing is set. rw_interrupt() clears it after a ··· 4193 4191 4194 4192 static int have_no_fdc = -ENODEV; 4195 4193 4194 + static ssize_t floppy_cmos_show(struct device *dev, struct device_attribute *attr, char *buf) 4195 + { 4196 + struct platform_device *p = container_of(dev,struct platform_device,dev); 4197 + int drive = p->id; 4198 + ssize_t retval; 4199 + 4200 + retval = sprintf(buf,"%X\n", UDP->cmos); 4201 + 4202 + return retval; 4203 + } 4204 + 4205 + DEVICE_ATTR(cmos,S_IRUGO,floppy_cmos_show,NULL); 4206 + 4196 4207 static void floppy_device_release(struct device *dev) 4197 4208 { 4198 4209 complete(&device_release); 4199 4210 } 4200 4211 4201 - static struct platform_device floppy_device = { 4202 - .name = "floppy", 4203 - .id = 0, 4204 - .dev = { 4205 - .release = floppy_device_release, 4206 - } 4207 - }; 4212 + static struct platform_device floppy_device[N_DRIVE]; 4208 4213 4209 4214 static struct kobject *floppy_find(dev_t dev, int *part, void *data) 4210 4215 { ··· 4379 4370 goto out_flush_work; 4380 4371 } 4381 4372 4382 - err = platform_device_register(&floppy_device); 4383 - if (err) 4384 - goto out_flush_work; 4385 - 4386 4373 for (drive = 0; drive < N_DRIVE; drive++) { 4387 4374 if (!(allowed_drive_mask & (1 << drive))) 4388 4375 continue; 4389 4376 if (fdc_state[FDC(drive)].version == FDC_NONE) 4390 4377 continue; 4378 + 4379 + floppy_device[drive].name = floppy_device_name; 4380 + floppy_device[drive].id = drive; 4381 + floppy_device[drive].dev.release = floppy_device_release; 4382 + 4383 + err = platform_device_register(&floppy_device[drive]); 4384 + if (err) 4385 + goto out_flush_work; 4386 + 4387 + device_create_file(&floppy_device[drive].dev,&dev_attr_cmos); 4391 4388 /* to be cleaned up... */ 4392 4389 disks[drive]->private_data = (void *)(long)drive; 4393 4390 disks[drive]->queue = floppy_queue; 4394 4391 disks[drive]->flags |= GENHD_FL_REMOVABLE; 4395 - disks[drive]->driverfs_dev = &floppy_device.dev; 4392 + disks[drive]->driverfs_dev = &floppy_device[drive].dev; 4396 4393 add_disk(disks[drive]); 4397 4394 } 4398 4395 ··· 4618 4603 fdc_state[FDC(drive)].version != FDC_NONE) { 4619 4604 del_gendisk(disks[drive]); 4620 4605 unregister_devfs_entries(drive); 4606 + device_remove_file(&floppy_device[drive].dev, &dev_attr_cmos); 4607 + platform_device_unregister(&floppy_device[drive]); 4621 4608 } 4622 4609 put_disk(disks[drive]); 4623 4610 } 4624 - platform_device_unregister(&floppy_device); 4625 4611 devfs_remove("floppy"); 4626 4612 4627 4613 del_timer_sync(&fd_timeout);