lkml.org 
[lkml]   [2000]   [Oct]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: IDE-Floppy and devfs
Hi Paul, hi Richard, hi linux-kernel audience,

Paul Bristow wrote:
> Hi Andreas,
>
> Could you re-send the patch, as it didn't make it with your last
> message?

Sorry, my mailer crashed when I sent this message and I didn't even
notice it got sent :-) So here's what you're waitung for (at least
I hope so). I have done some further cleanups for module initialization
et al., to make it look more like other (newer) drivers I saw elsewhere
in the source tree.

So here it comes (attached).

Greetings,
Andreas

PS: Sorry for this extra resend to linux-kernel, I incorrectly tried
to CC linux­kernel@vger.rutgers.edu im my mail to Paul and Richard,
which didn't
work as I could have expected, if it wasn't that late.

--
->>>----------------------- Andreas Franck --------<<<-
---<<<---- Andreas.Franck@post.rwth-aachen.de --->>>---
->>>---- Keep smiling! ----------------------------<<<---- linux/drivers/ide/ide-floppy.c.old Sun Oct 8 16:42:21 2000
+++ linux/drivers/ide/ide-floppy.c Wed Oct 11 02:15:22 2000
@@ -29,6 +29,15 @@
* Ver 0.9 Jul 4 99 Fix a bug which might have caused the number of
* bytes requested on each interrupt to be zero.
* Thanks to <shanos@es.co.nz> for pointing this out.
+ * Ver 0.10 Oct 8 00 Fix devfs support - now a /dev/ide/.../lun0/floppy
+ * entry, four partition entries (part1..part4), and
+ * symlinks in /dev/ide/floppy are created for each
+ * IDE floppy device.
+ *
+ */
+
+/*
+ * Changed to support devfs registration - 8.10.2000 Andreas Franck <afranck@gmx.de>
*/

#define IDEFLOPPY_VERSION "0.9"
@@ -48,6 +57,7 @@
#include <linux/malloc.h>
#include <linux/cdrom.h>
#include <linux/ide.h>
+#include <linux/devfs_fs_kernel.h>

#include <asm/byteorder.h>
#include <asm/irq.h>
@@ -236,7 +246,8 @@
idefloppy_capacity_descriptor_t capacity; /* Last format capacity */
idefloppy_flexible_disk_page_t flexible_disk_page; /* Copy of the flexible disk page */
int wp; /* Write protect */
-
+ devfs_handle_t de; /* devfs entry */
+
unsigned int flags; /* Status/Action flags */
} idefloppy_floppy_t;

@@ -1526,6 +1537,21 @@

}

+/*
+ * Register drive with devfs
+ */
+static int idefloppy_register (ide_drive_t *drive, int major, int minor)
+{
+ idefloppy_floppy_t *floppy = drive->driver_data;
+
+ floppy->de = devfs_register (drive->de, "floppy", DEVFS_FL_DEFAULT,
+ major, minor,
+ S_IFBLK | S_IRUGO | S_IWUGO,
+ ide_fops, NULL);
+
+ return 0;
+}
+
/*
* Driver initialization.
*/
@@ -1560,13 +1586,28 @@
max_sectors[major][minor + i] = 64;
}

+
+ idefloppy_register (drive, major, minor);
+
(void) idefloppy_get_capacity (drive);
idefloppy_add_settings(drive);
for (i = 0; i < MAX_DRIVES; ++i) {
ide_hwif_t *hwif = HWIF(drive);

if (drive != &hwif->drives[i]) continue;
- hwif->gd->de_arr[i] = drive->de;
+ hwif->gd->de_arr[i] = drive->de;
+
+ /*
+ * Stop grok_partitions from building
+ * the devfs "disc" and "part[1..n]"
+ * entries, we'll try to do it a little
+ * bit smarter so partitions exist without
+ * media. If media is inserted, this partition
+ * assumptions are corrected to reflect the actual
+ * partition settings.
+ */
+/* hwif->gd->de_arr[i] = 0; */
+
if (drive->removable)
hwif->gd->flags[i] |= GENHD_FL_REMOVABLE;
break;
@@ -1579,6 +1620,9 @@

if (ide_unregister_subdriver (drive))
return 1;
+
+ devfs_unregister(floppy->de);
+
drive->driver_data = NULL;
kfree (floppy);
return 0;
@@ -1601,24 +1645,24 @@
* IDE subdriver functions, registered with ide.c
*/
static ide_driver_t idefloppy_driver = {
- "ide-floppy", /* name */
- IDEFLOPPY_VERSION, /* version */
- ide_floppy, /* media */
- 0, /* busy */
- 1, /* supports_dma */
- 0, /* supports_dsc_overlap */
- idefloppy_cleanup, /* cleanup */
- idefloppy_do_request, /* do_request */
- idefloppy_end_request, /* end_request */
- idefloppy_ioctl, /* ioctl */
- idefloppy_open, /* open */
- idefloppy_release, /* release */
- idefloppy_media_change, /* media_change */
- idefloppy_revalidate, /* media_change */
- NULL, /* pre_reset */
- idefloppy_capacity, /* capacity */
- NULL, /* special */
- idefloppy_proc /* proc */
+ name: "ide-floppy", /* name */
+ version: IDEFLOPPY_VERSION, /* version */
+ media: ide_floppy, /* media */
+ busy: 0, /* busy */
+ supports_dma: 1, /* supports_dma */
+ supports_dsc_overlap: 0, /* supports_dsc_overlap */
+ cleanup: idefloppy_cleanup, /* cleanup */
+ do_request: idefloppy_do_request, /* do_request */
+ end_request: idefloppy_end_request, /* end_request */
+ ioctl: idefloppy_ioctl, /* ioctl */
+ open: idefloppy_open, /* open */
+ release: idefloppy_release, /* release */
+ media_change: idefloppy_media_change, /* media_change */
+ revalidate: idefloppy_revalidate, /* revalidate */
+ pre_reset: NULL, /* pre_reset */
+ capacity: idefloppy_capacity, /* capacity */
+ special: NULL, /* special */
+ proc: idefloppy_proc /* proc */
};

int idefloppy_init (void);
@@ -1639,7 +1683,7 @@
int failed = 0;

MOD_INC_USE_COUNT;
- while ((drive = ide_scan_devices (ide_floppy, idefloppy_driver.name, NULL, failed++)) != NULL) {
+ while ((drive = ide_scan_devices (ide_floppy, idefloppy_driver.name, NULL, failed++)) != NULL) {
if (!idefloppy_identify_device (drive, drive->id)) {
printk (KERN_ERR "ide-floppy: %s: not supported by this version of ide-floppy\n", drive->name);
continue;
@@ -1656,29 +1700,29 @@
printk (KERN_ERR "ide-floppy: %s: Failed to register the driver with ide.c\n", drive->name);
kfree (floppy);
continue;
- }
+ }
+ DRIVER(drive)->busy++;
+ printk(KERN_INFO "%s: calling idefloppy_setup\n", drive->name);
idefloppy_setup (drive, floppy);
+ printk(KERN_INFO "%s: idefloppy_setup finished\n", drive->name);
+ DRIVER(drive)->busy--;
failed--;
}
+ printk(KERN_INFO "calling ide_register_module\n");
ide_register_module(&idefloppy_module);
+ printk(KERN_INFO "ide_register_module finished\n");
MOD_DEC_USE_COUNT;
return 0;
}

-#ifdef MODULE
-int init_module (void)
-{
- return idefloppy_init ();
-}
-
-void cleanup_module (void)
+static void __exit idefloppy_exit (void)
{
ide_drive_t *drive;
int failed = 0;

while ((drive = ide_scan_devices (ide_floppy, idefloppy_driver.name, &idefloppy_driver, failed)) != NULL) {
if (idefloppy_cleanup (drive)) {
- printk ("%s: cleanup_module() called while still busy\n", drive->name);
+ printk ("%s: idefloppy_exit() called while still busy\n", drive->name);
failed++;
}
/* We must remove proc entries defined in this module.
@@ -1688,4 +1732,7 @@
}
ide_unregister_module(&idefloppy_module);
}
-#endif /* MODULE */
+
+module_init(idefloppy_init);
+module_exit(idefloppy_exit);
+
\
 
 \ /
  Last update: 2005-03-22 12:41    [W:0.035 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site