Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 18446 - Patch for ide-floppy for devfs support
Summary: Patch for ide-floppy for devfs support
Status: RESOLVED WONTFIX
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: x86 Linux
: Normal normal (vote)
Assignee: x86-kernel@gentoo.org (DEPRECATED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-29 16:15 UTC by Chris Gianelloni (RETIRED)
Modified: 2011-10-30 22:20 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch for devfs and ide-floppy (ide-floppy-devfs-patch,110.73 KB, patch)
2003-03-29 16:17 UTC, Chris Gianelloni (RETIRED)
Details | Diff
Corrected patch (ide-floppy-devfs-patch,3.96 KB, patch)
2003-03-29 16:30 UTC, Chris Gianelloni (RETIRED)
Details | Diff
New patch version (ide-floppy-devfs-patch,5.57 KB, patch)
2003-05-14 15:31 UTC, Chris Gianelloni (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Gianelloni (RETIRED) gentoo-dev 2003-03-29 16:15:41 UTC
The ide-floppy driver does not have support for devfs.  The homepage for this
driver is located at http://paulbristow.net/linux/idefloppy.html and contains a
devfs patch.  I have created a patch against gentoo-sources-2.4.20-r2 which is
available at http://www.faradic.net/~twi/ide-floppy-devfs-patch for download.
Comment 1 Chris Gianelloni (RETIRED) gentoo-dev 2003-03-29 16:17:03 UTC
Created attachment 9995 [details, diff]
Patch for devfs and ide-floppy
Comment 2 Chris Gianelloni (RETIRED) gentoo-dev 2003-03-29 16:25:04 UTC
Comment on attachment 9995 [details, diff]
Patch for devfs and ide-floppy

>diff -urN linux-2.4.20-gentoo-r2/drivers/ide/ide-floppy.c linux-2.4.20-gentoo-r2-fixed/drivers/ide/ide-floppy.c
>--- linux-2.4.20-gentoo-r2/drivers/ide/ide-floppy.c	2003-03-29 15:26:31.000000000 -0500
>+++ linux-2.4.20-gentoo-r2-fixed/drivers/ide/ide-floppy.c	2003-03-29 15:19:33.000000000 -0500
>@@ -97,6 +97,7 @@
> #include <linux/slab.h>
> #include <linux/cdrom.h>
> #include <linux/ide.h>
>+#include <linux/devfs_fs_kernel.h>
> 
> #include <asm/byteorder.h>
> #include <asm/irq.h>
>@@ -271,6 +272,7 @@
>  */
> typedef struct {
> 	ide_drive_t *drive;
>+	devfs_handle_t de;			/* devfs entry */
> 
> 	idefloppy_pc_t *pc;			/* Current packet command */
> 	idefloppy_pc_t *failed_pc; 		/* Last failed packet command */
>@@ -661,6 +663,8 @@
> #define IDEFLOPPY_MIN(a,b)	((a)<(b) ? (a):(b))
> #define	IDEFLOPPY_MAX(a,b)	((a)>(b) ? (a):(b))
> 
>+extern devfs_handle_t ide_devfs_handle; /* Hook into ide devfs chain */
>+
> /*
>  *	Too bad. The drive wants to send us data which we are not ready to accept.
>  *	Just throw it away.
>@@ -1457,9 +1461,14 @@
>                         if (memcmp (descriptor, &floppy->capacity, sizeof (idefloppy_capacity_descriptor_t)))
>                                 printk (KERN_INFO "%s: %dkB, %d blocks, %d sector size\n", drive->name, blocks * length / 1024, blocks, length);
>                         floppy->capacity = *descriptor;
>-                        if (!length || length % 512)
>+                        		if (!length || length % 512) {
>                                 printk (KERN_NOTICE "%s: %d bytes block size not supported\n", drive->name, length);
>-                        else {
>+			} else if (!i && descriptor->dc == CAPACITY_NO_CARTRIDGE 				&& drive->removable && !(length % 512)) {
>+			/* Set these two so that idefloppy_capacity returns a
>+			   positive value, needed for devfs registration. */
>+				floppy->blocks = blocks;
>+				floppy->bs_factor = length / 512;
>+                        	} else {
>                                 floppy->blocks = blocks;
>                                 floppy->block_size = length;
>                                 if ((floppy->bs_factor = length / 512) != 1)
>@@ -2010,6 +2019,9 @@
> 	struct idefloppy_id_gcw gcw;
> 	int major = HWIF(drive)->major, i;
> 	int minor = drive->select.b.unit << PARTN_BITS;
>+	char fname[64],iname[64]; /* for devfs */
>+	devfs_handle_t idefloppy_devfs_handle; /* for devfs */
>+	ide_hwif_t *hwif = HWIF(drive);
> 
> 	*((unsigned short *) &gcw) = drive->id->config;
> 	drive->driver_data = floppy;
>@@ -2063,6 +2075,21 @@
> 			hwif->gd->flags[i] |= GENHD_FL_REMOVABLE;
> 		break;
> 	}
>+
>+/* Always register drive with devfs */
>+	floppy->de = devfs_register (drive->de, "disc", DEVFS_FL_REMOVABLE,
>+				major, minor,
>+					S_IFBLK | S_IRUGO | S_IWUGO,
>+					ide_fops, NULL);
>+	/* Create ide/fd entry in devfs */
>+idefloppy_devfs_handle = devfs_mk_dir(ide_devfs_handle,"fd",NULL);
>+
>+	sprintf (fname, "c%db%dt%du%d",
>+		(hwif->channel && hwif->mate) ? hwif->mate->index : hwif->index,		hwif->channel, i, hwif->drives[i].lun);
>+	sprintf (iname, "../host%d/bus%d/target%d/lun%d/disc",
>+		(hwif->channel && hwif->mate) ? hwif->mate->index : hwif->index,
>+		hwif->channel, i, hwif->drives[i].lun);
>+devfs_mk_symlink(idefloppy_devfs_handle, fname, DEVFS_FL_REMOVABLE, iname, NULL, NULL);
> }
> 
> static int idefloppy_cleanup (ide_drive_t *drive)
>@@ -2071,6 +2098,8 @@
> 
> 	if (ide_unregister_subdriver (drive))
> 		return 1;
>+	devfs_unregister(floppy->de);
>+
> 	drive->driver_data = NULL;
> 	kfree (floppy);
> 	return 0;
>diff -urN linux-2.4.20-gentoo-r2/drivers/ide/ide-probe.c linux-2.4.20-gentoo-r2-fixed/drivers/ide/ide-probe.c
>--- linux-2.4.20-gentoo-r2/drivers/ide/ide-probe.c	2003-03-29 15:26:31.000000000 -0500
>+++ linux-2.4.20-gentoo-r2-fixed/drivers/ide/ide-probe.c	2003-03-29 15:21:32.000000000 -0500
>@@ -124,6 +124,7 @@
> 					if (!strstr(id->model, "oppy") && !strstr(id->model, "poyp") && !strstr(id->model, "ZIP"))
> 						printk("cdrom or floppy?, assuming ");
> 					if (drive->media != ide_cdrom) {
>+						drive->removable = 1;
> 						printk ("FLOPPY");
> 						break;
> 					}
Comment 3 Chris Gianelloni (RETIRED) gentoo-dev 2003-03-29 16:25:40 UTC
Comment on attachment 9995 [details, diff]
Patch for devfs and ide-floppy

Remove this patch
Comment 4 Chris Gianelloni (RETIRED) gentoo-dev 2003-03-29 16:30:03 UTC
Created attachment 9996 [details, diff]
Corrected patch
Comment 5 Chris Gianelloni (RETIRED) gentoo-dev 2003-03-30 10:10:55 UTC
Using this patch, I do get errors in mlogs that say:

devfs_register(disc): could not append to parent, err: -17
 /dev/ide/host0/bus0/target0/lun0: p1 p2 p3 p4
Comment 6 Jay Pfeifer (RETIRED) gentoo-dev 2003-03-30 13:03:48 UTC
i'll look @ here in the coming week. 
 
Thanks, 
 
Jay 
Comment 7 Jay Pfeifer (RETIRED) gentoo-dev 2003-04-27 02:39:35 UTC
i won't add this patch @ this time. 
 
sorry, 
 
Jay 
Comment 8 Chris Gianelloni (RETIRED) gentoo-dev 2003-05-14 15:31:31 UTC
Created attachment 11985 [details, diff]
New patch version

Without this patch, LS-120, Click! and Zip drives are useless in Gentoo using
the ide-floppy driver.