* PATCH: add drive_to_key functions
@ 2004-08-15 14:58 Alan Cox
2004-08-16 17:12 ` Bartlomiej Zolnierkiewicz
0 siblings, 1 reply; 3+ messages in thread
From: Alan Cox @ 2004-08-15 14:58 UTC (permalink / raw)
To: linux-ide, linux-kernel, torvalds
Clear new remove field
Clear pci_dev field on init
Add functions that allow us to keep persistent (reasonably so anyway) keys
not pointers to drive objects in the /proc file. Worst case is you
reload the driver 64K times and get the new data not an error.
Clean up ide_system_bus_speed docs
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.8-rc3/drivers/ide/ide.c linux-2.6.8-rc3/drivers/ide/ide.c
--- linux.vanilla-2.6.8-rc3/drivers/ide/ide.c 2004-08-09 15:51:00.000000000 +0100
+++ linux-2.6.8-rc3/drivers/ide/ide.c 2004-08-12 17:55:05.000000000 +0100
@@ -219,12 +219,15 @@
hwif->name[3] = '0' + index;
hwif->bus_state = BUSSTATE_ON;
-
+
hwif->atapi_dma = 0; /* disable all atapi dma */
hwif->ultra_mask = 0x80; /* disable all ultra */
hwif->mwdma_mask = 0x80; /* disable all mwdma */
hwif->swdma_mask = 0x80; /* disable all swdma */
+ hwif->pci_dev = NULL;
+ hwif->remove = NULL;
+
sema_init(&hwif->gendev_rel_sem, 0);
default_hwif_iops(hwif);
@@ -321,12 +324,67 @@
}
/*
- * ide_system_bus_speed() returns what we think is the system VESA/PCI
- * bus speed (in MHz). This is used for calculating interface PIO timings.
- * The default is 40 for known PCI systems, 50 otherwise.
- * The "idebus=xx" parameter can be used to override this value.
- * The actual value to be used is computed/displayed the first time through.
+ * ide_drive_from_key - turn key into drive
+ * @kval: persistent key
+ *
+ * Convert a key into a drive. Currently the key is packed as
+ * [keyval] << 16 | hwif << 8 | drive_num. Caller must hold
+ * ide_settings_sem for the duration of the returned reference
+ */
+
+ide_drive_t *ide_drive_from_key(void *kval)
+{
+ unsigned long key = (unsigned long) kval;
+ int idx = (key >> 8) & 0xFF;
+ int drive = key & 3;
+ ide_hwif_t *hwif = &ide_hwifs[idx];
+ ide_drive_t *ret;
+
+ key >>= 16;
+
+ if(hwif->configured == 0 || hwif->present == 0 || hwif->drives[drive].dead || hwif->key != key)
+ ret = NULL;
+ else
+ ret = &ide_hwifs[idx].drives[drive];
+
+ return ret;
+}
+
+EXPORT_SYMBOL_GPL(ide_drive_from_key);
+
+/*
+ * ide_drive_to_key - turn drive to persistent key
+ * @drive: drive to use
+ *
+ * Convert drive into a key. Currently the key is packed as
+ * [keyval] << 16 | hwif << 8 | drive_num. Caller must hold
+ * ide_settings_sem for the duration of the returned reference
*/
+
+void *ide_drive_to_key(ide_drive_t *drive)
+{
+ ide_hwif_t *hwif = HWIF(drive);
+ unsigned long val;
+
+ val = (hwif->index << 8) | (hwif->key << 16) | drive->select.b.unit;
+ return (void *)val;
+}
+
+EXPORT_SYMBOL_GPL(ide_drive_to_key);
+
+/**
+ * ide_system_bus_speed - guess bus speed
+ *
+ * ide_system_bus_speed() returns what we think is the system VESA/PCI
+ * bus speed (in MHz). This is used for calculating interface PIO timings.
+ * The default is 40 for known PCI systems, 50 otherwise.
+ * The "idebus=xx" parameter can be used to override this value.
+ * The actual value to be used is computed/displayed the first time
+ * through. Drivers should only use this as a last resort.
+ *
+ * Returns a guessed speed in Mhz
+ */
+
int ide_system_bus_speed (void)
{
if (!system_bus_speed) {
Signed-off-by: Alan Cox <alan@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: add drive_to_key functions
2004-08-15 14:58 PATCH: add drive_to_key functions Alan Cox
@ 2004-08-16 17:12 ` Bartlomiej Zolnierkiewicz
2004-08-16 17:38 ` Alan Cox
0 siblings, 1 reply; 3+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-08-16 17:12 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-ide, linux-kernel, torvalds
On Sunday 15 August 2004 16:58, Alan Cox wrote:
> Clear new remove field
> Clear pci_dev field on init
> Add functions that allow us to keep persistent (reasonably so anyway) keys
> not pointers to drive objects in the /proc file. Worst case is you
> reload the driver 64K times and get the new data not an error.
> Clean up ide_system_bus_speed docs
>
>
> diff -u --new-file --recursive --exclude-from /usr/src/exclude
> linux.vanilla-2.6.8-rc3/drivers/ide/ide.c linux-2.6.8-rc3/drivers/ide/ide.c
> --- linux.vanilla-2.6.8-rc3/drivers/ide/ide.c 2004-08-09 15:51:00.000000000
> +0100 +++ linux-2.6.8-rc3/drivers/ide/ide.c 2004-08-12 17:55:05.000000000
> +0100 @@ -219,12 +219,15 @@
> hwif->name[3] = '0' + index;
>
> hwif->bus_state = BUSSTATE_ON;
> -
> +
whitespace damage
> hwif->atapi_dma = 0; /* disable all atapi dma */
> hwif->ultra_mask = 0x80; /* disable all ultra */
> hwif->mwdma_mask = 0x80; /* disable all mwdma */
> hwif->swdma_mask = 0x80; /* disable all swdma */
>
> + hwif->pci_dev = NULL;
> + hwif->remove = NULL;
> +
not needed - memsetting to zero is done earlier
> sema_init(&hwif->gendev_rel_sem, 0);
>
> default_hwif_iops(hwif);
> @@ -321,12 +324,67 @@
> }
>
> /*
> - * ide_system_bus_speed() returns what we think is the system VESA/PCI
> - * bus speed (in MHz). This is used for calculating interface PIO
> timings. - * The default is 40 for known PCI systems, 50 otherwise.
> - * The "idebus=xx" parameter can be used to override this value.
> - * The actual value to be used is computed/displayed the first time
> through. + * ide_drive_from_key - turn key into drive
> + * @kval: persistent key
> + *
> + * Convert a key into a drive. Currently the key is packed as
> + * [keyval] << 16 | hwif << 8 | drive_num. Caller must hold
> + * ide_settings_sem for the duration of the returned reference
> + */
> +
> +ide_drive_t *ide_drive_from_key(void *kval)
> +{
> + unsigned long key = (unsigned long) kval;
> + int idx = (key >> 8) & 0xFF;
> + int drive = key & 3;
> + ide_hwif_t *hwif = &ide_hwifs[idx];
> + ide_drive_t *ret;
> +
> + key >>= 16;
> +
> + if(hwif->configured == 0 || hwif->present == 0 ||
> hwif->drives[drive].dead || hwif->key != key) + ret = NULL;
> + else
> + ret = &ide_hwifs[idx].drives[drive];
> +
> + return ret;
> +}
> +
> +EXPORT_SYMBOL_GPL(ide_drive_from_key);
> +
> +/*
> + * ide_drive_to_key - turn drive to persistent key
> + * @drive: drive to use
> + *
> + * Convert drive into a key. Currently the key is packed as
> + * [keyval] << 16 | hwif << 8 | drive_num. Caller must hold
> + * ide_settings_sem for the duration of the returned reference
> */
> +
> +void *ide_drive_to_key(ide_drive_t *drive)
> +{
> + ide_hwif_t *hwif = HWIF(drive);
> + unsigned long val;
> +
> + val = (hwif->index << 8) | (hwif->key << 16) | drive->select.b.unit;
> + return (void *)val;
> +}
> +
> +EXPORT_SYMBOL_GPL(ide_drive_to_key);
AFAICS ide_drive_[from,to]_key are to be used only from ide-proc.c
so EXPORT_SYMBOLs are not needed
> +/**
> + * ide_system_bus_speed - guess bus speed
> + *
> + * ide_system_bus_speed() returns what we think is the system VESA/PCI
> + * bus speed (in MHz). This is used for calculating interface PIO
> timings. + * The default is 40 for known PCI systems, 50 otherwise.
> + * The "idebus=xx" parameter can be used to override this value.
> + * The actual value to be used is computed/displayed the first time
> + * through. Drivers should only use this as a last resort.
> + *
> + * Returns a guessed speed in Mhz
> + */
> +
> int ide_system_bus_speed (void)
> {
> if (!system_bus_speed) {
>
This change belongs to "ide DocBook fixes" patch.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: add drive_to_key functions
2004-08-16 17:12 ` Bartlomiej Zolnierkiewicz
@ 2004-08-16 17:38 ` Alan Cox
0 siblings, 0 replies; 3+ messages in thread
From: Alan Cox @ 2004-08-16 17:38 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz
Cc: Alan Cox, linux-ide, Linux Kernel Mailing List, torvalds
On Llu, 2004-08-16 at 18:12, Bartlomiej Zolnierkiewicz wrote:
> > hwif->atapi_dma = 0; /* disable all atapi dma */
> > hwif->ultra_mask = 0x80; /* disable all ultra */
> > hwif->mwdma_mask = 0x80; /* disable all mwdma */
> > hwif->swdma_mask = 0x80; /* disable all swdma */
> >
> > + hwif->pci_dev = NULL;
> > + hwif->remove = NULL;
> > +
>
> not needed - memsetting to zero is done earlier
Ok fixed in my tree.
> > +EXPORT_SYMBOL_GPL(ide_drive_to_key);
>
> AFAICS ide_drive_[from,to]_key are to be used only from ide-proc.c
> so EXPORT_SYMBOLs are not needed
Good point I forgot they were linked together. Fixed
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-08-16 18:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-15 14:58 PATCH: add drive_to_key functions Alan Cox
2004-08-16 17:12 ` Bartlomiej Zolnierkiewicz
2004-08-16 17:38 ` Alan Cox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).