[PATCH 9/15] ide: factor out code removing port from hwgroup from ide_unregister()

2008-01-04 Thread Bartlomiej Zolnierkiewicz
Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide.c |   65 +-
 1 file changed, 36 insertions(+), 29 deletions(-)

Index: b/drivers/ide/ide.c
===
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -461,6 +461,41 @@ static void ide_hwif_restore(ide_hwif_t 
hwif-hwif_data = tmp_hwif-hwif_data;
 }
 
+static void ide_remove_port_from_hwgroup(ide_hwif_t *hwif)
+{
+   ide_hwgroup_t *hwgroup = hwif-hwgroup;
+
+   spin_lock_irq(ide_lock);
+   /*
+* Remove us from the hwgroup, and free
+* the hwgroup if we were the only member
+*/
+   if (hwif-next == hwif) {
+   BUG_ON(hwgroup-hwif != hwif);
+   kfree(hwgroup);
+   } else {
+   /* There is another interface in hwgroup.
+* Unlink us, and set hwgroup-drive and -hwif to
+* something sane.
+*/
+   ide_hwif_t *g = hwgroup-hwif;
+
+   while (g-next != hwif)
+   g = g-next;
+   g-next = hwif-next;
+   if (hwgroup-hwif == hwif) {
+   /* Chose a random hwif for hwgroup-hwif.
+* It's guaranteed that there are no drives
+* left in the hwgroup.
+*/
+   BUG_ON(hwgroup-drive != NULL);
+   hwgroup-hwif = g;
+   }
+   BUG_ON(hwgroup-hwif == hwif);
+   }
+   spin_unlock_irq(ide_lock);
+}
+
 /**
  * ide_unregister  -   free an IDE interface
  * @index: index of interface (will change soon to a pointer)
@@ -528,36 +563,8 @@ void ide_unregister(unsigned int index)
if (irq_count == 1)
free_irq(hwif-irq, hwgroup);
 
-   spin_lock_irq(ide_lock);
-   /*
-* Remove us from the hwgroup, and free
-* the hwgroup if we were the only member
-*/
-   if (hwif-next == hwif) {
-   BUG_ON(hwgroup-hwif != hwif);
-   kfree(hwgroup);
-   } else {
-   /* There is another interface in hwgroup.
-* Unlink us, and set hwgroup-drive and -hwif to
-* something sane.
-*/
-   g = hwgroup-hwif;
-   while (g-next != hwif)
-   g = g-next;
-   g-next = hwif-next;
-   if (hwgroup-hwif == hwif) {
-   /* Chose a random hwif for hwgroup-hwif.
-* It's guaranteed that there are no drives
-* left in the hwgroup.
-*/
-   BUG_ON(hwgroup-drive != NULL);
-   hwgroup-hwif = g;
-   }
-   BUG_ON(hwgroup-hwif == hwif);
-   }
+   ide_remove_port_from_hwgroup(hwif);
 
-   /* More messed up locking ... */
-   spin_unlock_irq(ide_lock);
device_unregister(hwif-gendev);
wait_for_completion(hwif-gendev_rel_comp);
 
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 8/15] ide: I/O resources are released too early in ide_unregister()

2008-01-04 Thread Bartlomiej Zolnierkiewicz
Release I/O resources after releasing DMA.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide.c |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

Index: b/drivers/ide/ide.c
===
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -529,13 +529,6 @@ void ide_unregister(unsigned int index)
 
spin_lock_irq(ide_lock);
/*
-* Note that we only release the standard ports,
-* and do not even try to handle any extra ports
-* allocated for weird IDE interface chipsets.
-*/
-   ide_hwif_release_regions(hwif);
-
-   /*
 * Remove us from the hwgroup, and free
 * the hwgroup if we were the only member
 */
@@ -589,6 +582,13 @@ void ide_unregister(unsigned int index)
hwif-extra_ports = 0;
}
 
+   /*
+* Note that we only release the standard ports,
+* and do not even try to handle any extra ports
+* allocated for weird IDE interface chipsets.
+*/
+   ide_hwif_release_regions(hwif);
+
/* copy original settings */
tmp_hwif = *hwif;
 
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/15] ide_platform: remove struct hwif_prop

2008-01-04 Thread Bartlomiej Zolnierkiewicz
* Remove 'if (hwif != hwif_prop.hwif)' check from plat_ide_remove()
  (pdev-dev.driver_data and hwif_prop.hwif are set at the same time
   in plat_ide_probe() and are identical).

* Use hwif-index for ide_unregister() in plat_ide_remove().

* Use local variables instead of hwif_prop.plat_ide[_alt]_mapbase in
  plat_ide_probe() and remove no longer needed struct hwif_prop.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-150 bytes
 drivers/ide/legacy/ide_platform.c |   34 --
 1 file changed, 8 insertions(+), 26 deletions(-)

Index: b/drivers/ide/legacy/ide_platform.c
===
--- a/drivers/ide/legacy/ide_platform.c
+++ b/drivers/ide/legacy/ide_platform.c
@@ -21,13 +21,6 @@
 #include linux/platform_device.h
 #include linux/io.h
 
-static struct {
-   void __iomem *plat_ide_mapbase;
-   void __iomem *plat_ide_alt_mapbase;
-   ide_hwif_t *hwif;
-   int index;
-} hwif_prop;
-
 static void __devinit plat_ide_setup_ports(hw_regs_t *hw,
   void __iomem *base,
   void __iomem *ctrl,
@@ -54,6 +47,7 @@ static void __devinit plat_ide_setup_por
 static int __devinit plat_ide_probe(struct platform_device *pdev)
 {
struct resource *res_base, *res_alt, *res_irq;
+   void __iomem *base, *alt_base;
ide_hwif_t *hwif;
struct pata_platform_info *pdata;
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
@@ -84,27 +78,25 @@ static int __devinit plat_ide_probe(stru
}
 
if (mmio) {
-   hwif_prop.plat_ide_mapbase = devm_ioremap(pdev-dev,
+   base = devm_ioremap(pdev-dev,
res_base-start, res_base-end - res_base-start + 1);
-   hwif_prop.plat_ide_alt_mapbase = devm_ioremap(pdev-dev,
+   alt_base = devm_ioremap(pdev-dev,
res_alt-start, res_alt-end - res_alt-start + 1);
} else {
-   hwif_prop.plat_ide_mapbase = devm_ioport_map(pdev-dev,
+   base = devm_ioport_map(pdev-dev,
res_base-start, res_base-end - res_base-start + 1);
-   hwif_prop.plat_ide_alt_mapbase = devm_ioport_map(pdev-dev,
+   alt_base = devm_ioport_map(pdev-dev,
res_alt-start, res_alt-end - res_alt-start + 1);
}
 
-   hwif = ide_find_port((unsigned long)hwif_prop.plat_ide_mapbase);
+   hwif = ide_find_port((unsigned long)base);
if (!hwif) {
ret = -ENODEV;
goto out;
}
 
memset(hw, 0, sizeof(hw));
-   plat_ide_setup_ports(hw, hwif_prop.plat_ide_mapbase,
-hwif_prop.plat_ide_alt_mapbase,
-pdata, res_irq-start);
+   plat_ide_setup_ports(hw, base, alt_base, pdata, res_irq-start);
hw.dev = pdev-dev;
 
ide_init_port_hw(hwif, hw);
@@ -114,9 +106,6 @@ static int __devinit plat_ide_probe(stru
default_hwif_mmiops(hwif);
}
 
-   hwif_prop.hwif = hwif;
-   hwif_prop.index = hwif-index;
-
idx[0] = hwif-index;
 
ide_device_add(idx);
@@ -133,14 +122,7 @@ static int __devexit plat_ide_remove(str
 {
ide_hwif_t *hwif = pdev-dev.driver_data;
 
-   if (hwif != hwif_prop.hwif) {
-   dev_printk(KERN_DEBUG, pdev-dev, %s: hwif value error,
-  pdev-name);
-   } else {
-   ide_unregister(hwif_prop.index);
-   hwif_prop.index = 0;
-   hwif_prop.hwif = NULL;
-   }
+   ide_unregister(hwif-index);
 
return 0;
 }
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/15] ide: move wait_hwif_ready() documentation in the right place

2008-01-04 Thread Bartlomiej Zolnierkiewicz
* Move wait_hwif_ready() documentation before this function.

* Fix trailing whitespaces.

* s/wait-for-busy/wait-for-non-busy/

* Remove no longer valid comment about the current code behavior.

* Docbook-ize it.

* Rename wait_hwif_ready() to ide_port_wait_ready().

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-probe.c |   49 +++-
 1 file changed, 28 insertions(+), 21 deletions(-)

Index: b/drivers/ide/ide-probe.c
===
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -634,7 +634,33 @@ static void hwif_register (ide_hwif_t *h
__FUNCTION__, ret);
 }
 
-static int wait_hwif_ready(ide_hwif_t *hwif)
+/**
+ * ide_port_wait_ready -   wait for port to become ready
+ * @hwif: IDE port
+ *
+ * This is needed on some PPCs and a bunch of BIOS-less embedded
+ * platforms.  Typical cases are:
+ *
+ * - The firmware hard reset the disk before booting the kernel,
+ *   the drive is still doing it's poweron-reset sequence, that
+ *   can take up to 30 seconds.
+ *
+ * - The firmware does nothing (or no firmware), the device is
+ *   still in POST state (same as above actually).
+ *
+ * - Some CD/DVD/Writer combo drives tend to drive the bus during
+ *   their reset sequence even when they are non-selected slave
+ *   devices, thus preventing discovery of the main HD.
+ *
+ * Doing this wait-for-non-busy should not harm any existing
+ * configuration and fix some issues like the above.
+ *
+ * BenH.
+ *
+ * Returns 0 on success, error code ( 0) otherwise.
+ */
+
+static int ide_port_wait_ready(ide_hwif_t *hwif)
 {
int unit, rc;
 
@@ -742,26 +768,7 @@ static void probe_hwif(ide_hwif_t *hwif)
 
local_irq_set(flags);
 
-   /* This is needed on some PPCs and a bunch of BIOS-less embedded
-* platforms. Typical cases are:
-* 
-*  - The firmware hard reset the disk before booting the kernel,
-*the drive is still doing it's poweron-reset sequence, that
-*can take up to 30 seconds
-*  - The firmware does nothing (or no firmware), the device is
-*still in POST state (same as above actually).
-*  - Some CD/DVD/Writer combo drives tend to drive the bus during
-*their reset sequence even when they are non-selected slave
-*devices, thus preventing discovery of the main HD
-*
-*  Doing this wait-for-busy should not harm any existing configuration
-*  (at least things won't be worse than what current code does, that
-*  is blindly go  talk to the drive) and fix some issues like the
-*  above.
-*  
-*  BenH.
-*/
-   if (wait_hwif_ready(hwif) == -EBUSY)
+   if (ide_port_wait_ready(hwif) == -EBUSY)
printk(KERN_DEBUG %s: Wait for ready failed before probe !\n, 
hwif-name);
 
/*
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/15] ide: fix handling of busy I/O resources in probe_hwif()

2008-01-04 Thread Bartlomiej Zolnierkiewicz
It could be that I/O resources are busy because some other host driver
has already claimed them so don't unregister the devices.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-94 bytes
 drivers/ide/ide-probe.c |   13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

Index: b/drivers/ide/ide-probe.c
===
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -727,18 +727,7 @@ static void probe_hwif(ide_hwif_t *hwif)
 
if ((hwif-chipset != ide_4drives || !hwif-mate || 
!hwif-mate-present) 
(ide_hwif_request_regions(hwif))) {
-   u16 msgout = 0;
-   for (unit = 0; unit  MAX_DRIVES; ++unit) {
-   ide_drive_t *drive = hwif-drives[unit];
-   if (drive-present) {
-   drive-present = 0;
-   printk(KERN_ERR %s: ERROR, PORTS ALREADY IN 
USE\n,
-   drive-name);
-   msgout = 1;
-   }
-   }
-   if (!msgout)
-   printk(KERN_ERR %s: ports already in use, skipping 
probe\n,
+   printk(KERN_ERR %s: ports already in use, skipping probe\n,
hwif-name);
return; 
}
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/15] ide: remove hwif-present manipulations from hwif_init()

2008-01-04 Thread Bartlomiej Zolnierkiewicz
* Call hwif_init() only if hwif-present is set.

* If hwif_init() fails clear hwif-present.

* Remove hwif-present manipulations from hwif_init().

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-24 bytes
 drivers/ide/ide-probe.c |   18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

Index: b/drivers/ide/ide-probe.c
===
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1245,28 +1245,21 @@ static int hwif_init(ide_hwif_t *hwif)
 {
int old_irq;
 
-   /* Return success if no device is connected */
-   if (!hwif-present)
-   return 1;
-
if (!hwif-irq) {
if (!(hwif-irq = 
ide_default_irq(hwif-io_ports[IDE_DATA_OFFSET])))
{
printk(%s: DISABLED, NO IRQ\n, hwif-name);
-   return (hwif-present = 0);
+   return 0;
}
}
 #ifdef CONFIG_BLK_DEV_HD
if (hwif-irq == HD_IRQ  hwif-io_ports[IDE_DATA_OFFSET] != HD_DATA) {
printk(%s: CANNOT SHARE IRQ WITH OLD 
HARDDISK DRIVER (hd.c)\n, hwif-name);
-   return (hwif-present = 0);
+   return 0;
}
 #endif /* CONFIG_BLK_DEV_HD */
 
-   /* we set it back to 1 if all is ok below */
-   hwif-present = 0;
-
if (register_blkdev(hwif-major, hwif-name))
return 0;
 
@@ -1305,10 +1298,7 @@ static int hwif_init(ide_hwif_t *hwif)
 
 done:
init_gendisk(hwif);
-
ide_acpi_init(hwif);
-
-   hwif-present = 1;  /* success */
return 1;
 
 out:
@@ -1352,9 +1342,13 @@ int ide_device_add_all(u8 *idx)
 
hwif = ide_hwifs[idx[i]];
 
+   if (!hwif-present)
+   continue;
+
if (hwif_init(hwif) == 0) {
printk(KERN_INFO %s: failed to initialize IDE 
 interface\n, hwif-name);
+   hwif-present = 0;
rc = -1;
continue;
}
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/15] ide: remove unused ide_hwgroup_t fields

2008-01-04 Thread Bartlomiej Zolnierkiewicz
Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 include/linux/ide.h |   14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

Index: b/include/linux/ide.h
===
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -628,8 +628,7 @@ typedef int (ide_expiry_t)(ide_drive_t *
 typedef struct hwgroup_s {
/* irq handler, if active */
ide_startstop_t (*handler)(ide_drive_t *);
-   /* irq handler, suspended if active */
-   ide_startstop_t (*handler_save)(ide_drive_t *);
+
/* BOOL: protects all fields below */
volatile int busy;
/* BOOL: wake us up on timer expiry */
@@ -644,25 +643,18 @@ typedef struct hwgroup_s {
/* ptr to current hwif in linked-list */
ide_hwif_t *hwif;
 
-   /* for pci chipsets */
-   struct pci_dev *pci_dev;
-
/* current request */
struct request *rq;
+
/* failsafe timer */
struct timer_list timer;
-   /* local copy of current write rq */
-   struct request wrq;
/* timeout value during long polls */
unsigned long poll_timeout;
/* queried upon timeouts */
int (*expiry)(ide_drive_t *);
-   /* ide_system_bus_speed */
-   int pio_clock;
+
int req_gen;
int req_gen_timer;
-
-   unsigned char cmd_buf[4];
 } ide_hwgroup_t;
 
 typedef struct ide_driver_s ide_driver_t;
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/15] ide: remove needless zeroing of hwgroup fields from init_irq()

2008-01-04 Thread Bartlomiej Zolnierkiewicz
Since kmalloc_node() is called with __GFP_ZERO flag there is no need to
explicitly zero hwgroup fields.

While at it:

* Use 'hwif' instead of 'hwif-drives[0].hwif' for kmalloc_node() call.

* Fix whitespace damage.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-27 bytes
 drivers/ide/ide-probe.c |   15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

Index: b/drivers/ide/ide-probe.c
===
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -998,19 +998,14 @@ static int init_irq (ide_hwif_t *hwif)
hwgroup-hwif-next = hwif;
spin_unlock_irq(ide_lock);
} else {
-   hwgroup = kmalloc_node(sizeof(ide_hwgroup_t),
-   GFP_KERNEL | __GFP_ZERO,
-   hwif_to_node(hwif-drives[0].hwif));
-   if (!hwgroup)
-   goto out_up;
+   hwgroup = kmalloc_node(sizeof(*hwgroup), GFP_KERNEL|__GFP_ZERO,
+  hwif_to_node(hwif));
+   if (hwgroup == NULL)
+   goto out_up;
 
hwif-hwgroup = hwgroup;
+   hwgroup-hwif = hwif-next = hwif;
 
-   hwgroup-hwif = hwif-next = hwif;
-   hwgroup-rq   = NULL;
-   hwgroup-handler  = NULL;
-   hwgroup-drive= NULL;
-   hwgroup-busy = 0;
init_timer(hwgroup-timer);
hwgroup-timer.function = ide_timer_expiry;
hwgroup-timer.data = (unsigned long) hwgroup;
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/15] ide: cleanup ide_system_bus_speed()

2008-01-04 Thread Bartlomiej Zolnierkiewicz
Use the facts that:

* When ide_init() is called 'system_bus_speed' always equals zero.

* system_bus_clock() is never called before ide_init().

and:

* Move printk() from ide_system_bus_speed() to ide_init().

* Don't assign 'system_bus_speed' in ide_system_bus_speed().

* Don't call ide_system_bus_speed() in system_bus_clock().

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-39 bytes
 drivers/ide/ide.c |   28 +++-
 1 file changed, 11 insertions(+), 17 deletions(-)

Index: b/drivers/ide/ide.c
===
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -240,22 +240,12 @@ static int ide_system_bus_speed(void)
 #define pci_default 0
 #endif /* CONFIG_PCI */
 
-   if (!system_bus_speed) {
-   if (idebus_parameter) {
-   /* user supplied value */
-   system_bus_speed = idebus_parameter;
-   } else if (pci_dev_present(pci_default)) {
-   /* safe default value for PCI */
-   system_bus_speed = 33;
-   } else {
-   /* safe default value for VESA and PCI */
-   system_bus_speed = 50;
-   }
-   printk(KERN_INFO ide: Assuming %dMHz system bus speed 
-   for PIO modes%s\n, system_bus_speed,
-   idebus_parameter ?  : ; override with idebus=xx);
-   }
-   return system_bus_speed;
+   /* user supplied value */
+   if (idebus_parameter)
+   return idebus_parameter;
+
+   /* safe default value for PCI or VESA and PCI*/
+   return pci_dev_present(pci_default) ? 33 : 50;
 }
 
 ide_hwif_t * ide_find_port(unsigned long base)
@@ -912,7 +902,7 @@ static int set_unmaskirq(ide_drive_t *dr
 
 int system_bus_clock (void)
 {
-   return((int) ((!system_bus_speed) ? ide_system_bus_speed() : 
system_bus_speed ));
+   return system_bus_speed;
 }
 
 EXPORT_SYMBOL(system_bus_clock);
@@ -1667,6 +1657,10 @@ static int __init ide_init(void)
printk(KERN_INFO Uniform Multi-Platform E-IDE driver  REVISION \n);
system_bus_speed = ide_system_bus_speed();
 
+   printk(KERN_INFO ide: Assuming %dMHz system bus speed 
+for PIO modes%s\n, system_bus_speed,
+   idebus_parameter ?  : ; override with idebus=xx);
+
ret = bus_register(ide_bus_type);
if (ret  0) {
printk(KERN_WARNING IDE: bus_register error: %d\n, ret);
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/15] ide: use ide_remove_port_from_hwgroup in init_irq()

2008-01-04 Thread Bartlomiej Zolnierkiewicz
There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-77 bytes
 drivers/ide/ide-probe.c |   18 +-
 drivers/ide/ide.c   |2 +-
 include/linux/ide.h |1 +
 3 files changed, 3 insertions(+), 18 deletions(-)

Index: b/drivers/ide/ide-probe.c
===
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1074,23 +1074,7 @@ static int init_irq (ide_hwif_t *hwif)
mutex_unlock(ide_cfg_mtx);
return 0;
 out_unlink:
-   spin_lock_irq(ide_lock);
-   if (hwif-next == hwif) {
-   BUG_ON(hwgroup-hwif != hwif);
-   kfree(hwgroup);
-   } else {
-   ide_hwif_t *g;
-   g = hwgroup-hwif;
-   while (g-next != hwif)
-   g = g-next;
-   g-next = hwif-next;
-   if (hwgroup-hwif == hwif) {
-   BUG_ON(hwgroup-drive);
-   hwgroup-hwif = g;
-   }
-   BUG_ON(hwgroup-hwif == hwif);
-   }
-   spin_unlock_irq(ide_lock);
+   ide_remove_port_from_hwgroup(hwif);
 out_up:
mutex_unlock(ide_cfg_mtx);
return 1;
Index: b/drivers/ide/ide.c
===
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -461,7 +461,7 @@ static void ide_hwif_restore(ide_hwif_t 
hwif-hwif_data = tmp_hwif-hwif_data;
 }
 
-static void ide_remove_port_from_hwgroup(ide_hwif_t *hwif)
+void ide_remove_port_from_hwgroup(ide_hwif_t *hwif)
 {
ide_hwgroup_t *hwgroup = hwif-hwgroup;
 
Index: b/include/linux/ide.h
===
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1194,6 +1194,7 @@ static inline void ide_acpi_init(ide_hwi
 static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {}
 #endif
 
+void ide_remove_port_from_hwgroup(ide_hwif_t *);
 extern int ide_hwif_request_regions(ide_hwif_t *hwif);
 extern void ide_hwif_release_regions(ide_hwif_t* hwif);
 extern void ide_unregister (unsigned int index);
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/15] ide: make probe_hwif() return an error value

2008-01-04 Thread Bartlomiej Zolnierkiewicz
Make probe_hwif() return an error value.

While at it:

* Remove comment about MAX_DRIVES == 2 limitation (it is not special to
  probe_hwif(), it is a general assumption taken by a lot of IDE code).

* Rename probe_hwif() to ide_probe_port().

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-iops.c|2 +-
 drivers/ide/ide-probe.c   |   16 +++-
 drivers/ide/pci/ns87415.c |4 ++--
 3 files changed, 10 insertions(+), 12 deletions(-)

Index: b/drivers/ide/ide-iops.c
===
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -1166,7 +1166,7 @@ EXPORT_SYMBOL(ide_do_reset);
 
 /*
  * ide_wait_not_busy() waits for the currently selected device on the hwif
- * to report a non-busy status, see comments in probe_hwif().
+ * to report a non-busy status, see comments in ide_probe_port().
  */
 int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
 {
Index: b/drivers/ide/ide-probe.c
===
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -738,24 +738,20 @@ void ide_undecoded_slave(ide_drive_t *dr
 
 EXPORT_SYMBOL_GPL(ide_undecoded_slave);
 
-/*
- * This routine only knows how to look for drive units 0 and 1
- * on an interface, so any setting of MAX_DRIVES  2 won't work here.
- */
-static void probe_hwif(ide_hwif_t *hwif)
+static int ide_probe_port(ide_hwif_t *hwif)
 {
unsigned long flags;
unsigned int irqd;
int unit;
 
if (hwif-noprobe)
-   return;
+   return -EACCES;
 
if ((hwif-chipset != ide_4drives || !hwif-mate || 
!hwif-mate-present) 
(ide_hwif_request_regions(hwif))) {
printk(KERN_ERR %s: ports already in use, skipping probe\n,
hwif-name);
-   return; 
+   return -EBUSY;
}
 
/*
@@ -804,7 +800,7 @@ static void probe_hwif(ide_hwif_t *hwif)
 
if (!hwif-present) {
ide_hwif_release_regions(hwif);
-   return;
+   return -ENODEV;
}
 
for (unit = 0; unit  MAX_DRIVES; unit++) {
@@ -840,6 +836,8 @@ static void probe_hwif(ide_hwif_t *hwif)
else
drive-no_io_32bit = drive-id-dword_io ? 1 : 0;
}
+
+   return 0;
 }
 
 #if MAX_HWIFS  1
@@ -1311,7 +1309,7 @@ int ide_device_add_all(u8 *idx)
if (idx[i] == 0xff)
continue;
 
-   probe_hwif(ide_hwifs[idx[i]]);
+   (void)ide_probe_port(ide_hwifs[idx[i]]);
}
 
for (i = 0; i  MAX_HWIFS; i++) {
Index: b/drivers/ide/pci/ns87415.c
===
--- a/drivers/ide/pci/ns87415.c
+++ b/drivers/ide/pci/ns87415.c
@@ -229,8 +229,8 @@ static void __devinit init_hwif_ns87415 
 
 #ifdef __sparc_v9__
/*
-* XXX: Reset the device, if we don't it will not respond
-*  to SELECT_DRIVE() properly during first probe_hwif().
+* XXX: Reset the device, if we don't it will not respond to
+*  SELECT_DRIVE() properly during first ide_probe_port().
 */
timeout = 1;
outb(12, hwif-io_ports[IDE_CONTROL_OFFSET]);
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/15] ide: factor out code for tuning devices from ide_probe_port()

2008-01-04 Thread Bartlomiej Zolnierkiewicz
* Factor out code for tuning devices from ide_probe_port()
  to ide_port_tune_devices().

* Move ide_port_tune_devices() call from ide_probe_port()
  to ide_device_add_all().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-probe.c |   15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

Index: b/drivers/ide/ide-probe.c
===
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -794,6 +794,13 @@ static int ide_probe_port(ide_hwif_t *hw
if (!hwif-present)
return -ENODEV;
 
+   return 0;
+}
+
+static void ide_port_tune_devices(ide_hwif_t *hwif)
+{
+   int unit;
+
for (unit = 0; unit  MAX_DRIVES; unit++) {
ide_drive_t *drive = hwif-drives[unit];
 
@@ -827,8 +834,6 @@ static int ide_probe_port(ide_hwif_t *hw
else
drive-no_io_32bit = drive-id-dword_io ? 1 : 0;
}
-
-   return 0;
 }
 
 #if MAX_HWIFS  1
@@ -1309,8 +1314,12 @@ int ide_device_add_all(u8 *idx)
continue;
}
 
-   if (ide_probe_port(hwif)  0)
+   if (ide_probe_port(hwif)  0) {
ide_hwif_release_regions(hwif);
+   continue;
+   }
+
+   ide_port_tune_devices(hwif);
}
 
for (i = 0; i  MAX_HWIFS; i++) {
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/15] ide: move hwif_register() call out of ide_probe_port()

2008-01-04 Thread Bartlomiej Zolnierkiewicz
* Add BUG_ON(hwif-present) at the start of ide_probe_port().

* Move hwif_register() call (along with setting hwif-present) from
  ide_probe_port() to ide_device_add_all().

  As a result the port will be registered with the device tree _after_:
  - probing both devices (if both are present)
  - port reset (if hwif-reset is set)
  - restoring local IRQs state and re-enabling port IRQ

While at it:

* Rename hwif_register() to ide_register_port().

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
+17 bytes
 drivers/ide/ide-probe.c |   27 +--
 1 file changed, 13 insertions(+), 14 deletions(-)

Index: b/drivers/ide/ide-probe.c
===
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -613,7 +613,7 @@ static void hwif_release_dev (struct dev
complete(hwif-gendev_rel_comp);
 }
 
-static void hwif_register (ide_hwif_t *hwif)
+static void ide_register_port(ide_hwif_t *hwif)
 {
int ret;
 
@@ -742,7 +742,9 @@ static int ide_probe_port(ide_hwif_t *hw
 {
unsigned long flags;
unsigned int irqd;
-   int unit;
+   int unit, rc = -ENODEV;
+
+   BUG_ON(hwif-present);
 
if (hwif-noprobe)
return -EACCES;
@@ -767,14 +769,8 @@ static int ide_probe_port(ide_hwif_t *hw
ide_drive_t *drive = hwif-drives[unit];
drive-dn = (hwif-channel ? 2 : 0) + unit;
(void) probe_for_drive(drive);
-   if (drive-present  !hwif-present) {
-   hwif-present = 1;
-   if (hwif-chipset != ide_4drives ||
-   !hwif-mate || 
-   !hwif-mate-present) {
-   hwif_register(hwif);
-   }
-   }
+   if (drive-present)
+   rc = 0;
}
if (hwif-io_ports[IDE_CONTROL_OFFSET]  hwif-reset) {
printk(KERN_WARNING %s: reset\n, hwif-name);
@@ -791,10 +787,7 @@ static int ide_probe_port(ide_hwif_t *hw
if (irqd)
enable_irq(irqd);
 
-   if (!hwif-present)
-   return -ENODEV;
-
-   return 0;
+   return rc;
 }
 
 static void ide_port_tune_devices(ide_hwif_t *hwif)
@@ -1319,6 +1312,12 @@ int ide_device_add_all(u8 *idx)
continue;
}
 
+   hwif-present = 1;
+
+   if (hwif-chipset != ide_4drives || !hwif-mate ||
+   !hwif-mate-present)
+   ide_register_port(hwif);
+
ide_port_tune_devices(hwif);
}
 
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH 02/10] ide-floppy: move ide-floppy struct and macro defs into its own header. While at it

2008-01-04 Thread Bartlomiej Zolnierkiewicz

Hi,

Hmm, contrary to ide-cd.c case there doesn't seem to be a need currently for
moving code out of ide-floppy.c (and this patch series doesn't change that).

Besides it would be better to just remove some structs like it has been done
with i.e. struct atapi_capabilities_page in ide-cd.c case [1] because:

* it is easier to audit/debug the code if you don't have to look at typedefs
  all the time just to see which bytes/bits the code is really accessing

* not using typedefs will make the source code significantly smaller

* documentation is publically available

* these structs are not memory mapped

[1] http://www.mail-archive.com/[EMAIL PROTECTED]/msg242747.html

On Thursday 03 January 2008, Borislav Petkov wrote:
 - do a white-space cleanup
 - remove old crufty code untouched since at least 2005

Please try to not mix things like moving code around and doing actual
changes because it makes patch review difficult (i.e. it took me quite a
while to find old crufty code that has been removed)...

Sometimes having more trivial patches is better...

 - shorten lines longer than 80ish columns
 - shorten some LAAARGE typenames.

typedefs are evil (exceptions are rare) and should die :)

 There should be no functional changes resulting from this patch.
 
 Signed-off-by: Borislav Petkov [EMAIL PROTECTED]
 ---
  drivers/ide/ide-floppy.c |  763 
 --
  drivers/ide/ide-floppy.h |  382 +++
  2 files changed, 581 insertions(+), 564 deletions(-)
 
 diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
 index 785fbde..52d09c1 100644
 --- a/drivers/ide/ide-floppy.c
 +++ b/drivers/ide/ide-floppy.c

[...]

 -} idefloppy_capabilities_page_t;

[...]

 -} idefloppy_flexible_disk_page_t;

[...]

 -} idefloppy_capacity_descriptor_t;

as mentioned earlier it would be best to just remove these structs/typedefs

[ respective structures are described in SFF-8070i spec, it is useful to audit
  the final code against the spec to catch potential coding mistakes early ]

[...]

 -#if 0
 -/*
 - *   Special requests for our block device strategy routine.
 - */
 -#define  IDEFLOPPY_FIRST_RQ  90
 -
 -/*
 - *   IDEFLOPPY_PC_RQ is used to queue a packet command in the request queue.
 - */
 -#define  IDEFLOPPY_PC_RQ 90
 -
 -#define IDEFLOPPY_LAST_RQ90
 -
 -/*
 - *   A macro which can be used to check if a given request command
 - *   originated in the driver or in the buffer cache layer.
 - */
 -#define IDEFLOPPY_RQ_CMD(cmd)((cmd = IDEFLOPPY_FIRST_RQ)  (cmd = 
 IDEFLOPPY_LAST_RQ))
 -
 -#endif

Well, it was already removed, the patch is in IDE tree (and thus in -mm).

http://kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.24-rc6/2.6.24-rc6-mm1/broken-out/ide-mm-ide-floppy-remove-dead-code.patch

If possible please base your patches against IDE tree or the latest -mm patch.

[...]

 -} idefloppy_inquiry_result_t;

[...]

 -} idefloppy_request_sense_result_t;

[...]

 -} idefloppy_mode_parameter_header_t;

more structs/typedefs heading for /dev/null

[...]

 @@ -1689,9 +1304,12 @@ static int idefloppy_identify_device (ide_drive_t 
 *drive,struct hd_driveid *id)
   printk(KERN_INFO Write buffer size(?): %d bytes\n,id-buf_size*512);
   printk(KERN_INFO DMA: %s,id-capability  0x01 ? Yes\n:No\n);
   printk(KERN_INFO LBA: %s,id-capability  0x02 ? Yes\n:No\n);
 - printk(KERN_INFO IORDY can be disabled: %s,id-capability  0x04 ? 
 Yes\n:No\n);
 - printk(KERN_INFO IORDY supported: %s,id-capability  0x08 ? 
 Yes\n:Unknown\n);
 - printk(KERN_INFO ATAPI overlap supported: %s,id-capability  0x20 ? 
 Yes\n:No\n);
 + printk(KERN_INFO IORDY can be disabled: %s,
 + id-capability  0x04 ? Yes\n:No\n);
 + printk(KERN_INFO IORDY supported: %s,
 + id-capability  0x08 ? Yes\n:Unknown\n);
 + printk(KERN_INFO ATAPI overlap supported: %s,
 + id-capability  0x20 ? Yes\n:No\n);
   printk(KERN_INFO PIO Cycle Timing Category: %d\n,id-tPIO);
   printk(KERN_INFO DMA Cycle Timing Category: %d\n,id-tDMA);
   printk(KERN_INFO Single Word DMA supported modes:\n);
 @@ -1713,12 +1331,16 @@ static int idefloppy_identify_device (ide_drive_t 
 *drive,struct hd_driveid *id)
   sprintf(buffer, Not supported);
   else
   sprintf(buffer, %d ns,id-eide_dma_min);
 - printk(KERN_INFO Minimum Multi-word DMA cycle per word: %s\n, 
 buffer);
 + printk(KERN_INFO Minimum Multi-word DMA cycle per word: %s\n,
 + buffer);
 +
   if (id-eide_dma_time == 0)
   sprintf(buffer, Not supported);
   else
   sprintf(buffer, %d ns,id-eide_dma_time);
 - printk(KERN_INFO Manufacturer\'s Recommended Multi-word cycle: 
 %s\n, buffer);
 + printk(KERN_INFO Manufacturer\'s Recommended Multi-word
 +  

Re: [RESEND PATCH 01/10] move ide-floppy historical changelog to Documentation/ide/ChangeLog.ide-floppy.1996-2002;

2008-01-03 Thread Bartlomiej Zolnierkiewicz
On Thursday 03 January 2008, Borislav Petkov wrote:
 Signed-off-by: Borislav Petkov [EMAIL PROTECTED]

applied with two minor fixes (and sorry for being such a pedant ;):

* Summary line moved to patch description and ide-floppy: cleanup header
  used instead.  Please try to keep summary line within 80-columns limit,
  otherwise it makes git-log output etc ugly.

* I don't know why scripts/checkpatch.pl doesn't complain but quilt did:

  Warning: trailing whitespace in lines 44,46,61,62 of 
Documentation/ide/ChangeLog.ide-floppy.1996-2002

  so I fixed it manually.
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH 0/10] ide-floppy redux p1

2008-01-03 Thread Bartlomiej Zolnierkiewicz

Hi,

On Thursday 03 January 2008, Borislav Petkov wrote:
 
 Hi Bart,
 
 here's the unfinished redux of ide-floppy which i'm REsending now so that we 
 could
 sinchronize trees. The original send got busted in vger's filters due to 
 syntax
 error in the Message-ID tag.
 
  Documentation/ide/ChangeLog.ide-floppy.1996-2002 |   64 ++
  drivers/ide/ide-floppy.c | 1248 
 +++---
  drivers/ide/ide-floppy.h |  351 ++
  include/linux/cdrom.h|1 +
  4 files changed, 819 insertions(+), 845 deletions(-)

I applied patch #1, patches #3, #4, #7 and #10 can be applied immediately
if you move them at the beggining of the patch series.  The rest requires
some more work but they are almost there (more comments in replies to
particular patches).

Thanks,
Bart
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH 03/10] ide-floppy: convert to generic packet commands

2008-01-03 Thread Bartlomiej Zolnierkiewicz
On Thursday 03 January 2008, Borislav Petkov wrote:
 Replace the ide-floppy packet commands opcode defines with the generic ones.
 Add a missing GPCMD_WRITE_12 (opcode 0xaa) to the generic ones in cdrom.h. The
 last one can be found in the current version of INF-8090, p.905.
 
 CC: Jens Axboe [EMAIL PROTECTED]
 Signed-off-by: Borislav Petkov [EMAIL PROTECTED]

please move this patch at the beggining of the patch series so it can be
applied immediately (patch #2 needs some more work)

 ---
  drivers/ide/ide-floppy.c |   26 +-
  drivers/ide/ide-floppy.h |   21 -

Please also note that patch #2 moved these defines to ide-floppy.h and now
patch #3 removes them so by re-ordering patches you can make patch #2 simpler.

[ This is a general hint for optimizing patches to make them smaller and easier
  to maintain, it also makes reviewer's job easier. ]

[...]

 --- a/include/linux/cdrom.h
 +++ b/include/linux/cdrom.h
 @@ -480,6 +480,7 @@ struct cdrom_generic_command
  #define GPCMD_TEST_UNIT_READY0x00
  #define GPCMD_VERIFY_10  0x2f
  #define GPCMD_WRITE_10   0x2a
 +#define GPCMD_WRITE_12   0xaa/* ide floppy */

0xaa is a generic SCSI opcode so the above comment is not necessary

  #define GPCMD_WRITE_AND_VERIFY_100x2e
  /* This is listed as optional in ATAPI 2.6, but is (curiously) 
   * missing from Mt. Fuji, Table 57.  It _is_ mentioned in Mt. Fuji
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH 04/10] ide-floppy: cleanup debugging macros

2008-01-03 Thread Bartlomiej Zolnierkiewicz
On Thursday 03 January 2008, Borislav Petkov wrote:
 There should be no functional change resulting from this patch.

the patch is fine but the description is a bit inaccurate:

* some debug_log() calls were not using ide-floppy:  prefix

* a few used printk levels different than KERN_INFO (KERN_NOTICE
  and KERN_ERR, which is the default one if no level is given)

please fix the description and move the patch at the beggining of
the patch series

 Signed-off-by: Borislav Petkov [EMAIL PROTECTED]
 ---
  drivers/ide/ide-floppy.c |   58 +
  drivers/ide/ide-floppy.h |3 +-
  2 files changed, 29 insertions(+), 32 deletions(-)
 
 diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
 index 4fb6128..196a697 100644
 --- a/drivers/ide/ide-floppy.c
 +++ b/drivers/ide/ide-floppy.c
 @@ -105,7 +105,7 @@ static int idefloppy_do_end_request(ide_drive_t *drive, 
 int uptodate, int nsecs)
   struct request *rq = HWGROUP(drive)-rq;
   int error;
  
 - debug_log(KERN_INFO Reached idefloppy_end_request\n);
 + debug_log(Reached %s\n, __FUNCTION__);
  
   switch (uptodate) {
   case 0: error = IDEFLOPPY_ERROR_GENERAL; break;
 @@ -257,13 +257,12 @@ static void idefloppy_analyze_error (ide_drive_t *drive,
   floppy-progress_indication = result-sksv[0]  0x80 ?
   (u16)get_unaligned((u16 *)(result-sksv+1)):0x1;
   if (floppy-failed_pc)
 - debug_log(KERN_INFO ide-floppy: pc = %x, sense key = %x, 
 - asc = %x, ascq = %x\n, floppy-failed_pc-c[0],
 - result-sense_key, result-asc, result-ascq);
 + debug_log(pc = %x, sense key = %x, asc = %x, ascq = %x\n,
 + floppy-failed_pc-c[0], result-sense_key,
 + result-asc, result-ascq);
   else
 - debug_log(KERN_INFO ide-floppy: sense key = %x, asc = %x, 
 - ascq = %x\n, result-sense_key,
 - result-asc, result-ascq);
 + debug_log(sense key = %x, asc = %x, ascq = %x\n,
 + result-sense_key, result-asc, result-ascq);
  }
  
  static void idefloppy_request_sense_callback (ide_drive_t *drive)
 @@ -271,7 +270,7 @@ static void idefloppy_request_sense_callback (ide_drive_t 
 *drive)
   idefloppy_t *floppy = drive-driver_data;
   u8 *buf = floppy-pc-buffer;
  
 - debug_log(KERN_INFO ide-floppy: Reached %s\n, __FUNCTION__);
 + debug_log(Reached %s\n, __FUNCTION__);
  
   if (!floppy-pc-error) {
   idefloppy_analyze_error(drive, (rq_sense_res_t *) buf);
 @@ -291,7 +290,7 @@ static void idefloppy_pc_callback (ide_drive_t *drive)
  {
   idefloppy_t *floppy = drive-driver_data;
  
 - debug_log(KERN_INFO ide-floppy: Reached %s\n, __FUNCTION__);
 + debug_log(Reached %s\n, __FUNCTION__);
  
   idefloppy_do_end_request(drive, floppy-pc-error ? 0 : 1, 0);
  }
 @@ -351,8 +350,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t 
 *drive)
   struct request *rq = pc-rq;
   unsigned int temp;
  
 - debug_log(KERN_INFO ide-floppy: Reached %s interrupt handler\n,
 - __FUNCTION__);
 + debug_log(Reached %s interrupt handler\n, __FUNCTION__);
  
   if (test_bit(PC_DMA_IN_PROGRESS, pc-flags)) {
   if (HWIF(drive)-ide_dma_end(drive)) {
 @@ -361,23 +359,23 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t 
 *drive)
   pc-actually_transferred = pc-request_transfer;
   idefloppy_update_buffers(drive, pc);
   }
 - debug_log(KERN_INFO ide-floppy: DMA finished\n);
 + debug_log(%s: DMA finished\n, __FUNCTION__);
   }
  
   /* Clear the interrupt */
   status.all = HWIF(drive)-INB(IDE_STATUS_REG);
  
   if (!status.b.drq) {/* No more interrupts */
 - debug_log(KERN_INFO Packet command completed, %d bytes 
 - transferred\n, pc-actually_transferred);
 + debug_log(Packet command completed, %d bytes transferred\n,
 + pc-actually_transferred);
 +
   clear_bit(PC_DMA_IN_PROGRESS, pc-flags);
  
   local_irq_enable_in_hardirq();
  
   if (status.b.check || test_bit(PC_DMA_ERROR, pc-flags)) {
   /* Error detected */
 - debug_log(KERN_INFO ide-floppy: %s: I/O error\n,
 - drive-name);
 + debug_log(%s: I/O error\n, drive-name);
   rq-errors++;
   if (pc-c[0] == GPCMD_REQUEST_SENSE) {
   printk(KERN_ERR ide-floppy: I/O error in 
 @@ -438,9 +436,8 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t 
 *drive)
   NULL);
   return ide_started;
   }
 - 

Re: [RESEND PATCH 10/10] ide-floppy: replace ntoh{s,l} and hton{s,l} calls with the generic byteorder macros

2008-01-03 Thread Bartlomiej Zolnierkiewicz
On Thursday 03 January 2008, Borislav Petkov wrote:
 Signed-off-by: Borislav Petkov [EMAIL PROTECTED]

minor thing:

WARNING: line over 80 characters
#88: FILE: drivers/ide/ide-floppy.c:759:
+   put_unaligned(cpu_to_be16(blocks), (unsigned short *) 
pc-c[7]);

seems like it can be fixed by removing space between '(unsigned short *)'
and 'pc-c[7]'

otherwise looks good, please move it at the beginning of the patch series

PS I need some sleep so the rest of patches have to wait till tomorrow...
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH 07/10] ide-floppy: remove unnecessary -handler != NULL check

2008-01-03 Thread Bartlomiej Zolnierkiewicz

On Thursday 03 January 2008, Borislav Petkov wrote:
 This BUG_ON is unneeded since the -handler != NULL check is performed in
 ide_set_handler().
 
 Signed-off-by: Borislav Petkov [EMAIL PROTECTED]

looks good, please move it at the beginning of the patch series
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] pata_pdc202xx_old: Further fixups

2008-01-03 Thread Bartlomiej Zolnierkiewicz
On Friday 04 January 2008, Alan Cox wrote:
 Turns out distros always enabled burst mode and it is pretty essential so

Yeah and datasheet confirms that so burst mode config option should die
(now if somebody could hit me with a patch)...

Bart
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] ide: use MODULE_VERSION()

2008-01-02 Thread Bartlomiej Zolnierkiewicz
On Wednesday 02 January 2008, Matt Domsch wrote:
 On Tue, Jan 01, 2008 at 09:32:36PM -0500, Jon Masters wrote:
  On Tue, 2008-01-01 at 19:33 +0100, Bartlomiej Zolnierkiewicz wrote:
  
   On the second thought: maybe we will be better off with limiting
   MODULE_VERSION() to the device drivers and the IDE core module for now,
   and just removing all these private version numbers from host drivers
   (with one or two exceptions they are not printed or exported currently,
   moreover exceptions are the cases like stale version numbers from 199x)?
  
  Things like checkpatch could help advise people to bump the version
  number, but it's a bit iffy. Matt D. actually uses the special source
  version modinfo for DKMS - which is different - but it makes me wonder
  whether dynamically generating a version based on source SHA1 wouldn't
  be a better idea in most cases than an outdated hard-coded one.
 
 We've got that already, it's called 'srcversion', and it's a CRC32

Neat.

 IIRC after some limited parsing to let it ignore whitspace changes and
 comment changes only.  
 
 $ modinfo dell_rbu | grep version
 version:3.2
 srcversion: 1D4815D7D6FBEE6612F3C18

Unfortunately 'srcversion' is set only if MODULE_VERSION() is used... :(

Anyway I'm dropping this patch and removing all versions from comments
for now (patch #2 respin in few minutes)...

Thanks,
Bart
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ide: delete filenames/versions from comments

2008-01-02 Thread Bartlomiej Zolnierkiewicz

Delete filenames/versions from comments.

I'm leaving decisions about adding DRV_VERSION defines and MODULE_VERSION()-s
to maintainers of the respective drivers.

While at it:

* Remove unused VERSION define from ide.c.

* Remove unused/stale DRV_VERSION define from au1xxx-ide.c.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
a replacement patch for ide: delete filenames from comments one

 drivers/ide/arm/bast-ide.c |3 +--
 drivers/ide/arm/icside.c   |2 --
 drivers/ide/arm/rapide.c   |2 --
 drivers/ide/cris/ide-cris.c|3 +--
 drivers/ide/h8300/ide-h8300.c  |1 -
 drivers/ide/ide-acpi.c |1 -
 drivers/ide/ide-cd.h   |2 --
 drivers/ide/ide-disk.c |2 --
 drivers/ide/ide-dma.c  |3 +--
 drivers/ide/ide-floppy.c   |2 --
 drivers/ide/ide-iops.c |2 --
 drivers/ide/ide-pnp.c  |2 --
 drivers/ide/ide-probe.c|2 --
 drivers/ide/ide-proc.c |2 --
 drivers/ide/ide-tape.c |2 --
 drivers/ide/ide-taskfile.c |2 --
 drivers/ide/ide-timing.h   |2 --
 drivers/ide/ide.c  |3 ---
 drivers/ide/legacy/ali14xx.c   |2 --
 drivers/ide/legacy/buddha.c|2 +-
 drivers/ide/legacy/dtc2278.c   |2 --
 drivers/ide/legacy/falconide.c |2 +-
 drivers/ide/legacy/gayle.c |2 +-
 drivers/ide/legacy/ht6560b.c   |2 --
 drivers/ide/legacy/ide-cs.c|2 --
 drivers/ide/legacy/macide.c|2 +-
 drivers/ide/legacy/q40ide.c|2 +-
 drivers/ide/legacy/qd65xx.c|2 --
 drivers/ide/legacy/qd65xx.h|2 --
 drivers/ide/legacy/umc8672.c   |2 --
 drivers/ide/mips/au1xxx-ide.c  |3 ---
 drivers/ide/pci/aec62xx.c  |2 --
 drivers/ide/pci/alim15x3.c |2 --
 drivers/ide/pci/amd74xx.c  |2 --
 drivers/ide/pci/atiixp.c   |2 --
 drivers/ide/pci/cmd640.c   |2 --
 drivers/ide/pci/cmd64x.c   |2 --
 drivers/ide/pci/cs5530.c   |2 --
 drivers/ide/pci/cs5535.c   |2 --
 drivers/ide/pci/cy82c693.c |2 --
 drivers/ide/pci/delkin_cb.c|2 --
 drivers/ide/pci/generic.c  |2 --
 drivers/ide/pci/hpt34x.c   |3 +--
 drivers/ide/pci/hpt366.c   |2 --
 drivers/ide/pci/it821x.c   |3 ---
 drivers/ide/pci/ns87415.c  |2 --
 drivers/ide/pci/opti621.c  |2 --
 drivers/ide/pci/pdc202xx_old.c |2 --
 drivers/ide/pci/piix.c |2 --
 drivers/ide/pci/rz1000.c   |2 --
 drivers/ide/pci/sc1200.c   |2 --
 drivers/ide/pci/serverworks.c  |2 --
 drivers/ide/pci/siimage.c  |2 --
 drivers/ide/pci/sis5513.c  |2 --
 drivers/ide/pci/sl82c105.c |2 --
 drivers/ide/pci/slc90e66.c |2 --
 drivers/ide/pci/tc86c001.c |2 --
 drivers/ide/pci/triflex.c  |2 --
 drivers/ide/pci/trm290.c   |3 +--
 drivers/ide/pci/via82cxxx.c|3 ---
 drivers/ide/ppc/mpc8xx.c   |2 --
 drivers/ide/ppc/pmac.c |3 +--
 drivers/ide/setup-pci.c|4 +---
 drivers/scsi/ide-scsi.c|2 --
 64 files changed, 12 insertions(+), 126 deletions(-)

Index: b/drivers/ide/arm/bast-ide.c
===
--- a/drivers/ide/arm/bast-ide.c
+++ b/drivers/ide/arm/bast-ide.c
@@ -1,5 +1,4 @@
-/* linux/drivers/ide/arm/bast-ide.c
- *
+/*
  * Copyright (c) 2003-2004 Simtec Electronics
  *  Ben Dooks [EMAIL PROTECTED]
  *
Index: b/drivers/ide/arm/icside.c
===
--- a/drivers/ide/arm/icside.c
+++ b/drivers/ide/arm/icside.c
@@ -1,6 +1,4 @@
 /*
- * linux/drivers/ide/arm/icside.c
- *
  * Copyright (c) 1996-2004 Russell King.
  *
  * Please note that this platform does not support 32-bit IDE IO.
Index: b/drivers/ide/arm/rapide.c
===
--- a/drivers/ide/arm/rapide.c
+++ b/drivers/ide/arm/rapide.c
@@ -1,6 +1,4 @@
 /*
- * linux/drivers/ide/arm/rapide.c
- *
  * Copyright (c) 1996-2002 Russell King.
  */
 
Index: b/drivers/ide/cris/ide-cris.c
===
--- a/drivers/ide/cris/ide-cris.c
+++ b/drivers/ide/cris/ide-cris.c
@@ -1,5 +1,4 @@
-/* $Id: cris-ide-driver.patch,v 1.1 2005/06/29 21:39:07 akpm Exp $
- *
+/*
  * Etrax specific IDE functions, like init and PIO-mode setting etc.
  * Almost the entire ide.c is used for the rest of the Etrax ATA driver.
  * Copyright (c) 2000-2005 Axis Communications AB
Index: b/drivers/ide/h8300/ide-h8300.c
===
--- a/drivers/ide/h8300/ide-h8300.c
+++ b/drivers/ide/h8300/ide-h8300.c
@@ -1,5 +1,4 @@
 /*
- * drivers/ide/h8300/ide-h8300.c
  * H8/300 generic IDE interface
  */
 
Index: b/drivers/ide/ide-acpi.c
===
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -1,5 +1,4

Re: [PATCH 1/2] trm290: cannot call ide_setup_dma()

2008-01-01 Thread Bartlomiej Zolnierkiewicz
On Sunday 30 December 2007, Sergei Shtylyov wrote:
 The TRM-290 chip is *not* SFF-8038i compatible and therefore can *not* call
 ide_setup_dma() -- fix this and also cleanup the code a bit...
 
 Signed-off-by: Sergei Shtylyov [EMAIL PROTECTED]

applied
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] ide_setup_dma() assumes 8 ports

2008-01-01 Thread Bartlomiej Zolnierkiewicz
On Sunday 30 December 2007, Sergei Shtylyov wrote:
 According to http://marc.info/?l=linux-idem=114346138611631, the drivers must
 always register 8 DMA ports with ide_setup_dma(), so its last argument is  not
 needed. While at it, kill some useless parens in that function...
 
 Signed-off-by: Sergei Shtylyov [EMAIL PROTECTED]

applied
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] ide: use MODULE_VERSION()

2008-01-01 Thread Bartlomiej Zolnierkiewicz

* Replace driver versions in comments by DRV_VERSION define.

* Add MODULE_VERSION(DRV_VERSION) to drivers defining DRV_VERSION.

While at it:

* Replace local version defines by DRV_VERSION.

* Bump driver version in ide-floppy to match generic format
  (0.99.newide - 1.00).

* Change printk() level in ide-floppy banner message to KERN_INFO.

* Bump driver version in IDE core module to match generic format
  (Id: ide.c 7.00a2 20020906 - 7.00).

* Remove unused REVISION define from ide.c.

* Update (the previously unused) DRV_VERSION define in au1xxx-ide.c.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c   |7 ---
 drivers/ide/ide-disk.c |9 +
 drivers/ide/ide-floppy.c   |   12 +++-
 drivers/ide/ide-tape.c |9 +
 drivers/ide/ide.c  |   11 ++-
 drivers/ide/legacy/ali14xx.c   |5 -
 drivers/ide/legacy/dtc2278.c   |5 -
 drivers/ide/legacy/ht6560b.c   |9 ++---
 drivers/ide/legacy/ide-cs.c|5 -
 drivers/ide/legacy/qd65xx.c|5 -
 drivers/ide/legacy/umc8672.c   |5 -
 drivers/ide/mips/au1xxx-ide.c  |5 +++--
 drivers/ide/pci/aec62xx.c  |5 -
 drivers/ide/pci/alim15x3.c |5 -
 drivers/ide/pci/amd74xx.c  |5 +++--
 drivers/ide/pci/atiixp.c   |5 -
 drivers/ide/pci/cmd640.c   |5 -
 drivers/ide/pci/cmd64x.c   |5 -
 drivers/ide/pci/cs5530.c   |5 -
 drivers/ide/pci/cy82c693.c |5 -
 drivers/ide/pci/generic.c  |5 -
 drivers/ide/pci/hpt34x.c   |5 -
 drivers/ide/pci/hpt366.c   |5 -
 drivers/ide/pci/it821x.c   |5 -
 drivers/ide/pci/ns87415.c  |5 -
 drivers/ide/pci/opti621.c  |5 -
 drivers/ide/pci/pdc202xx_old.c |5 -
 drivers/ide/pci/piix.c |5 -
 drivers/ide/pci/rz1000.c   |6 --
 drivers/ide/pci/sc1200.c   |5 -
 drivers/ide/pci/serverworks.c  |5 -
 drivers/ide/pci/siimage.c  |5 -
 drivers/ide/pci/sis5513.c  |5 -
 drivers/ide/pci/slc90e66.c |5 -
 drivers/ide/pci/tc86c001.c |5 -
 drivers/ide/pci/trm290.c   |5 -
 drivers/ide/pci/via82cxxx.c|6 +++---
 drivers/scsi/ide-scsi.c|9 +
 38 files changed, 159 insertions(+), 64 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -23,8 +23,6 @@
  * Documentation/ide/ChangeLog.ide-cd.1994-2004
  */
 
-#define IDECD_VERSION 5.00
-
 #include linux/module.h
 #include linux/types.h
 #include linux/kernel.h
@@ -49,6 +47,8 @@
 
 #include ide-cd.h
 
+#define DRV_VERSION5.00
+
 static DEFINE_MUTEX(idecd_ref_mutex);
 
 #define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref) 
@@ -2054,7 +2054,7 @@ static ide_driver_t ide_cdrom_driver = {
},
.probe  = ide_cd_probe,
.remove = ide_cd_remove,
-   .version= IDECD_VERSION,
+   .version= DRV_VERSION,
.media  = ide_cdrom,
.supports_dsc_overlap   = 1,
.do_request = ide_do_rw_cdrom,
@@ -2275,3 +2275,4 @@ MODULE_ALIAS(ide-cd);
 module_init(ide_cdrom_init);
 module_exit(ide_cdrom_exit);
 MODULE_LICENSE(GPL);
+MODULE_VERSION(DRV_VERSION);
Index: b/drivers/ide/ide-disk.c
===
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -1,5 +1,5 @@
 /*
- *  linux/drivers/ide/ide-disk.c   Version 1.18Mar 05, 2003
+ *  linux/drivers/ide/ide-disk.c
  *
  *  Copyright (C) 1994-1998  Linus Torvalds  authors (see below)
  *  Copyright (C) 1998-2002  Linux ATA Development
@@ -15,8 +15,6 @@
  * This is the IDE/ATA disk driver, as evolved from hd.c and ide.c.
  */
 
-#define IDEDISK_VERSION1.18
-
 //#define DEBUG
 
 #include linux/module.h
@@ -44,6 +42,8 @@
 #include asm/io.h
 #include asm/div64.h
 
+#define DRV_VERSION1.18
+
 struct ide_disk_obj {
ide_drive_t *drive;
ide_driver_t*driver;
@@ -959,7 +959,7 @@ static ide_driver_t idedisk_driver = {
.remove = ide_disk_remove,
.resume = ide_disk_resume,
.shutdown   = ide_device_shutdown,
-   .version= IDEDISK_VERSION,
+   .version= DRV_VERSION,
.media  = ide_disk,
.supports_dsc_overlap   = 0,
.do_request = ide_do_rw_disk,
@@ -1193,3 +1193,4 @@ MODULE_ALIAS(ide:*m-disk*);
 module_init(idedisk_init);
 module_exit(idedisk_exit);
 MODULE_LICENSE(GPL);
+MODULE_VERSION(DRV_VERSION);
Index: b/drivers/ide/ide-floppy.c
===
--- a/drivers/ide/ide-floppy.c

[PATCH 3/3] ide: update/add my Copyrights

2008-01-01 Thread Bartlomiej Zolnierkiewicz

The last years stuff and a trip down memory lane...

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c   |8 
 drivers/ide/ide-disk.c |9 +
 drivers/ide/ide-dma.c  |7 +++
 drivers/ide/ide-floppy.c   |5 +++--
 drivers/ide/ide-probe.c|3 ++-
 drivers/ide/ide-tape.c |3 ++-
 drivers/ide/ide-taskfile.c |8 
 drivers/ide/ide.c  |3 ++-
 drivers/ide/setup-pci.c|5 +++--
 drivers/scsi/ide-scsi.c|3 ++-
 10 files changed, 30 insertions(+), 24 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1,10 +1,10 @@
 /*
  * ATAPI CD-ROM driver.
  *
- * Copyright (C) 1994-1996  Scott Snyder [EMAIL PROTECTED]
- * Copyright (C) 1996-1998  Erik Andersen [EMAIL PROTECTED]
- * Copyright (C) 1998-2000  Jens Axboe [EMAIL PROTECTED]
- * Copyright (C)  2007  Bartlomiej Zolnierkiewicz
+ * Copyright (C) 1994-1996   Scott Snyder [EMAIL PROTECTED]
+ * Copyright (C) 1996-1998   Erik Andersen [EMAIL PROTECTED]
+ * Copyright (C) 1998-2000   Jens Axboe [EMAIL PROTECTED]
+ * Copyright (C) 2005, 2007  Bartlomiej Zolnierkiewicz
  *
  * May be copied or modified under the terms of the GNU General Public
  * License.  See linux/COPYING for more information.
Index: b/drivers/ide/ide-disk.c
===
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -1,8 +1,9 @@
 /*
- *  Copyright (C) 1994-1998  Linus Torvalds  authors (see below)
- *  Copyright (C) 1998-2002  Linux ATA Development
- * Andre Hedrick [EMAIL PROTECTED]
- *  Copyright (C) 2003  Red Hat [EMAIL PROTECTED]
+ *  Copyright (C) 1994-1998   Linus Torvalds  authors (see below)
+ *  Copyright (C) 1998-2002   Linux ATA Development
+ *   Andre Hedrick [EMAIL PROTECTED]
+ *  Copyright (C) 2003Red Hat [EMAIL PROTECTED]
+ *  Copyright (C) 2003-2005, 2007  Bartlomiej Zolnierkiewicz
  */
 
 /*
Index: b/drivers/ide/ide-dma.c
===
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -1,14 +1,13 @@
 /*
- *  Copyright (c) 1999-2000Andre Hedrick [EMAIL PROTECTED]
+ *  Copyright (C) 1995-1998   Mark Lord
+ *  Copyright (C) 1999-2000   Andre Hedrick [EMAIL PROTECTED]
+ *  Copyright (C) 2004, 2007  Bartlomiej Zolnierkiewicz
  *
  *  May be copied or modified under the terms of the GNU General Public License
  */
 
 /*
  *  Special Thanks to Mark for his Six years of work.
- *
- *  Copyright (c) 1995-1998  Mark Lord
- *  May be copied or modified under the terms of the GNU General Public License
  */
 
 /*
Index: b/drivers/ide/ide-floppy.c
===
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -1,6 +1,7 @@
 /*
- * Copyright (C) 1996 - 1999 Gadi Oxman [EMAIL PROTECTED]
- * Copyright (C) 2000 - 2002 Paul Bristow [EMAIL PROTECTED]
+ * Copyright (C) 1996-1999  Gadi Oxman [EMAIL PROTECTED]
+ * Copyright (C) 2000-2002  Paul Bristow [EMAIL PROTECTED]
+ * Copyright (C) 2005   Bartlomiej Zolnierkiewicz
  */
 
 /*
Index: b/drivers/ide/ide-probe.c
===
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1,5 +1,6 @@
 /*
- *  Copyright (C) 1994-1998  Linus Torvalds  authors (see below)
+ *  Copyright (C) 1994-1998   Linus Torvalds  authors (see below)
+ *  Copyright (C) 2005, 2007  Bartlomiej Zolnierkiewicz
  */
 
 /*
Index: b/drivers/ide/ide-tape.c
===
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 1995 - 1999 Gadi Oxman [EMAIL PROTECTED]
+ * Copyright (C) 1995-1999  Gadi Oxman [EMAIL PROTECTED]
+ * Copyright (C) 2003-2005  Bartlomiej Zolnierkiewicz
  *
  * $Header$
  *
Index: b/drivers/ide/ide-taskfile.c
===
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -1,9 +1,9 @@
 /*
- *  Copyright (C) 2000-2002Michael Cornwell [EMAIL PROTECTED]
- *  Copyright (C) 2000-2002Andre Hedrick [EMAIL PROTECTED]
- *  Copyright (C) 2001-2002Klaus Smolin
+ *  Copyright (C) 2000-2002   Michael Cornwell [EMAIL PROTECTED]
+ *  Copyright (C) 2000-2002   Andre Hedrick [EMAIL PROTECTED]
+ *  Copyright (C) 2001-2002   Klaus Smolin
  * IBM Storage Technology Division
- *  Copyright (C) 2003-2004Bartlomiej Zolnierkiewicz
+ *  Copyright (C) 2003-2004, 2007  Bartlomiej Zolnierkiewicz
  *
  *  The big the bad and the ugly.
  */
Index: b/drivers/ide/ide.c
===
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c

[PATCH 2/3] ide: delete filenames from comments

2008-01-01 Thread Bartlomiej Zolnierkiewicz

Delete filenames from comments.

While at it:

* Delete versions from comments in ide-dma.c, ide-iops.c, ide-probe.c,
  ide-proc.c, ide-taskfile.c, and setup-pci.c (all these files are a part
  of IDE core module), and also ide-timing.h.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/arm/bast-ide.c |3 +--
 drivers/ide/arm/icside.c   |2 --
 drivers/ide/arm/rapide.c   |2 --
 drivers/ide/cris/ide-cris.c|3 +--
 drivers/ide/h8300/ide-h8300.c  |1 -
 drivers/ide/ide-acpi.c |1 -
 drivers/ide/ide-cd.h   |2 --
 drivers/ide/ide-disk.c |2 --
 drivers/ide/ide-dma.c  |3 +--
 drivers/ide/ide-floppy.c   |2 --
 drivers/ide/ide-iops.c |2 --
 drivers/ide/ide-pnp.c  |2 --
 drivers/ide/ide-probe.c|2 --
 drivers/ide/ide-proc.c |2 --
 drivers/ide/ide-tape.c |2 --
 drivers/ide/ide-taskfile.c |2 --
 drivers/ide/ide-timing.h   |2 --
 drivers/ide/ide.c  |2 --
 drivers/ide/legacy/ali14xx.c   |2 --
 drivers/ide/legacy/buddha.c|2 +-
 drivers/ide/legacy/dtc2278.c   |2 --
 drivers/ide/legacy/falconide.c |2 +-
 drivers/ide/legacy/gayle.c |2 +-
 drivers/ide/legacy/ht6560b.c   |2 --
 drivers/ide/legacy/ide-cs.c|2 --
 drivers/ide/legacy/macide.c|2 +-
 drivers/ide/legacy/q40ide.c|2 +-
 drivers/ide/legacy/qd65xx.c|2 --
 drivers/ide/legacy/qd65xx.h|2 --
 drivers/ide/legacy/umc8672.c   |2 --
 drivers/ide/mips/au1xxx-ide.c  |2 --
 drivers/ide/pci/aec62xx.c  |2 --
 drivers/ide/pci/alim15x3.c |2 --
 drivers/ide/pci/atiixp.c   |2 --
 drivers/ide/pci/cmd640.c   |2 --
 drivers/ide/pci/cmd64x.c   |2 --
 drivers/ide/pci/cs5530.c   |2 --
 drivers/ide/pci/cs5535.c   |2 --
 drivers/ide/pci/cy82c693.c |2 --
 drivers/ide/pci/delkin_cb.c|2 --
 drivers/ide/pci/generic.c  |2 --
 drivers/ide/pci/hpt34x.c   |3 +--
 drivers/ide/pci/hpt366.c   |2 --
 drivers/ide/pci/it821x.c   |3 ---
 drivers/ide/pci/ns87415.c  |2 --
 drivers/ide/pci/opti621.c  |2 --
 drivers/ide/pci/pdc202xx_old.c |2 --
 drivers/ide/pci/piix.c |2 --
 drivers/ide/pci/rz1000.c   |2 --
 drivers/ide/pci/sc1200.c   |2 --
 drivers/ide/pci/serverworks.c  |2 --
 drivers/ide/pci/siimage.c  |2 --
 drivers/ide/pci/sis5513.c  |2 --
 drivers/ide/pci/sl82c105.c |2 --
 drivers/ide/pci/slc90e66.c |2 --
 drivers/ide/pci/tc86c001.c |2 --
 drivers/ide/pci/triflex.c  |2 --
 drivers/ide/pci/trm290.c   |3 +--
 drivers/ide/ppc/mpc8xx.c   |2 --
 drivers/ide/ppc/pmac.c |3 +--
 drivers/ide/setup-pci.c|4 +---
 drivers/scsi/ide-scsi.c|2 --
 62 files changed, 12 insertions(+), 119 deletions(-)

Index: b/drivers/ide/arm/bast-ide.c
===
--- a/drivers/ide/arm/bast-ide.c
+++ b/drivers/ide/arm/bast-ide.c
@@ -1,5 +1,4 @@
-/* linux/drivers/ide/arm/bast-ide.c
- *
+/*
  * Copyright (c) 2003-2004 Simtec Electronics
  *  Ben Dooks [EMAIL PROTECTED]
  *
Index: b/drivers/ide/arm/icside.c
===
--- a/drivers/ide/arm/icside.c
+++ b/drivers/ide/arm/icside.c
@@ -1,6 +1,4 @@
 /*
- * linux/drivers/ide/arm/icside.c
- *
  * Copyright (c) 1996-2004 Russell King.
  *
  * Please note that this platform does not support 32-bit IDE IO.
Index: b/drivers/ide/arm/rapide.c
===
--- a/drivers/ide/arm/rapide.c
+++ b/drivers/ide/arm/rapide.c
@@ -1,6 +1,4 @@
 /*
- * linux/drivers/ide/arm/rapide.c
- *
  * Copyright (c) 1996-2002 Russell King.
  */
 
Index: b/drivers/ide/cris/ide-cris.c
===
--- a/drivers/ide/cris/ide-cris.c
+++ b/drivers/ide/cris/ide-cris.c
@@ -1,5 +1,4 @@
-/* $Id: cris-ide-driver.patch,v 1.1 2005/06/29 21:39:07 akpm Exp $
- *
+/*
  * Etrax specific IDE functions, like init and PIO-mode setting etc.
  * Almost the entire ide.c is used for the rest of the Etrax ATA driver.
  * Copyright (c) 2000-2005 Axis Communications AB
Index: b/drivers/ide/h8300/ide-h8300.c
===
--- a/drivers/ide/h8300/ide-h8300.c
+++ b/drivers/ide/h8300/ide-h8300.c
@@ -1,5 +1,4 @@
 /*
- * drivers/ide/h8300/ide-h8300.c
  * H8/300 generic IDE interface
  */
 
Index: b/drivers/ide/ide-acpi.c
===
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -1,5 +1,4 @@
 /*
- * ide-acpi.c
  * Provides ACPI support for IDE drives.
  *
  * Copyright (C) 2005 Intel Corp.
Index: b/drivers/ide/ide-cd.h

Re: [PATCH 1/3] ide: use MODULE_VERSION()

2008-01-01 Thread Bartlomiej Zolnierkiewicz
On Tuesday 01 January 2008, Adrian Bunk wrote:
 On Tue, Jan 01, 2008 at 06:40:38PM +0100, Bartlomiej Zolnierkiewicz wrote:
  
  * Replace driver versions in comments by DRV_VERSION define.
  
  * Add MODULE_VERSION(DRV_VERSION) to drivers defining DRV_VERSION.
 ...
 
 Could you limit this to actively maintained version numbers and also 
 remove the others from .version, printk's,...?
 
 An example:
 
  --- a/drivers/ide/legacy/umc8672.c
  +++ b/drivers/ide/legacy/umc8672.c
  @@ -1,5 +1,5 @@
   /*
  - *  linux/drivers/ide/legacy/umc8672.c Version 0.05Jul 31, 
  1996
  + *  linux/drivers/ide/legacy/umc8672.c
*
*  Copyright (C) 1995-1996  Linus Torvalds  author (see below)
*/
  @@ -53,6 +53,8 @@
   
   #include asm/io.h
   
  +#define DRV_VERSION0.05
  +
   /*
* Default speeds.  These can be changed with auto-tune and/or hdparm.
*/
  @@ -185,3 +187,4 @@ module_init(umc8672_init);
   MODULE_AUTHOR(Wolfram Podien);
   MODULE_DESCRIPTION(Support for UMC 8672 IDE chipset);
   MODULE_LICENSE(GPL);
  +MODULE_VERSION(DRV_VERSION);
 ...
 
 I do not see any value in printing a version number from 1996 (sic),
 and the driver has for sure changed without any update of the 
 version number.
 
 For actively maintained version numbers (and even more when 
 distributions backport more recent versions of a driver) printing a 
 (maintained) driver version number makes sense, but otherwise the kernel 
 version contains more information and a stale version number only gives 
 the false impression the driver hadn't changed.

Good point.

On the second thought: maybe we will be better off with limiting
MODULE_VERSION() to the device drivers and the IDE core module for now,
and just removing all these private version numbers from host drivers
(with one or two exceptions they are not printed or exported currently,
moreover exceptions are the cases like stale version numbers from 199x)?

Bart
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] ide: add IDE_HFLAG_NO_DSC host flag

2007-12-30 Thread Bartlomiej Zolnierkiewicz
On Saturday 29 December 2007, Sergei Shtylyov wrote:
 Bartlomiej Zolnierkiewicz wrote:
  * Add IDE_HFLAG_NO_DSC host flag for hosts that doesn't support DSC overlap.
 
  * Set it in aec62xx (for ATP850UF only) and hpt34x host drivers.
 
  * Convert ide-tape device driver to check for IDE_HFLAG_NO_DSC flag.
 
  Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
 
 Acked-by: Sergei Shtylyov [EMAIL PROTECTED]
 
  Index: b/include/linux/ide.h
  ===
  --- a/include/linux/ide.h
  +++ b/include/linux/ide.h
  @@ -1098,6 +1098,8 @@ enum {
  IDE_HFLAG_CY82C693  = (1  27),
  /* force host out of simplex mode */
  IDE_HFLAG_CLEAR_SIMPLEX = (1  28),
  +   /* DSC overlap is unsupported */
  +   IDE_HFLAG_NO_DSC= (1  29),
   };
 
 Too many flags -- you'll run out of sizeof(unsigned) soon. :-)

Actually I'm already one bit short for WIP patches :)

I can compensate for it by using the same bit for IDE_HFLAG_CS5520
and IDE_HFLAG_VDMA for now (they are set only by cs5520 host driver)
but long-term we should get rid of some flags (IDE_HFLAG_ABUSE*,
especially IDE_HFLAG_ABUSE_DMA_MODES, sound like a good candidates
for extermination) or make flags field u64 (eeew)...

Bart
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] au1xxx-ide: device tree bugfix

2007-12-30 Thread Bartlomiej Zolnierkiewicz

Add missing hw.dev setup (so hwif-gendev.parent will be set by
ide_init_port_hw() to point to the parent device).

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/mips/au1xxx-ide.c |1 +
 1 file changed, 1 insertion(+)

Index: b/drivers/ide/mips/au1xxx-ide.c
===
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/mips/au1xxx-ide.c
@@ -602,6 +602,7 @@ static int au_ide_probe(struct device *d
memset(hw, 0, sizeof(hw));
auide_setup_ports(hw, ahwif);
hw.irq = ahwif-irq;
+   hw.dev = dev;
hw.chipset = ide_au1xxx;
 
ide_init_port_hw(hwif, hw);
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] piix: remove stale comments

2007-12-30 Thread Bartlomiej Zolnierkiewicz
On Friday 28 December 2007, Sergei Shtylyov wrote:
 Hello.
 
 Bartlomiej Zolnierkiewicz wrote:
  Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
 
 Acked-by: Sergei Shtylyov [EMAIL PROTECTED]
 
  Index: b/drivers/ide/pci/piix.c
  ===
  --- a/drivers/ide/pci/piix.c
  +++ b/drivers/ide/pci/piix.c
  @@ -8,53 +8,8 @@
*
*  May be copied or modified under the terms of the GNU General Public 
  License
*
  - *  PIO mode setting function for Intel chipsets.
  - *  For use instead of BIOS settings.
  + * Documentation:
*
  - * 40-41
  - * 42-43
  - * 
  - * 41
  - * 43
  - *
  - * | PIO 0   | c0 | 80 | 0 |
  - * | PIO 2 | SW2 | d0 | 90 | 4 |
  - * | PIO 3 | MW1 | e1 | a1 | 9 |
  - * | PIO 4 | MW2 | e3 | a3 | b |
  - *
  - * sitre = word40  0x4000; primary
  - * sitre = word42  0x4000; secondary
  - *
  - * 44 8421|8421hdd|hdb
  - *
  - * 48 8421 hdd|hdc|hdb|hda udma enabled
  - *
  - *0001 hda
  - *0010 hdb
  - *0100 hdc
  - *1000 hdd
  - *
  - * 4a 84|21hdb|hda
  - * 4b 84|21hdd|hdc
  - *
  - *ata-33/82371AB
  - *ata-33/82371EB
  - *ata-33/82801ABata-66/82801AA
  - *00|00 udma 0  00|00 reserved
  - *01|01 udma 1  01|01 udma 3
  - *10|10 udma 2  10|10 udma 4
  - *11|11 reserved11|11 reserved
  - *
  - * 54 8421|8421ata66 drive|ata66 enable
 
 You could have left te progarmming info intact...

Well, I thought about that but:

* It referenced ATA devices using hd[a-d] naming which while matches with
  most of use cases is not 100% correct (piix driver can be modular etc).

* Right below there is a note about the official Intel documentation
  (which is publically available).

* The piix.c code is self-documenting nowadays (in large parts thanks to
  your efforts). :)

Thanks,
Bart
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] ide-pmac: macio resource freeing bugfix

2007-12-30 Thread Bartlomiej Zolnierkiewicz

Release DMA resource before zeroing pmif.

Cc: Benjamin Herrenschmidt [EMAIL PROTECTED]
Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ppc/pmac.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: b/drivers/ide/ppc/pmac.c
===
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1228,12 +1228,12 @@ pmac_ide_macio_attach(struct macio_dev *
/* The inteface is released to the common IDE layer */
dev_set_drvdata(mdev-ofdev.dev, NULL);
iounmap(base);
-   if (pmif-dma_regs)
+   if (pmif-dma_regs) {
iounmap(pmif-dma_regs);
+   macio_release_resource(mdev, 1);
+   }
memset(pmif, 0, sizeof(*pmif));
macio_release_resource(mdev, 0);
-   if (pmif-dma_regs)
-   macio_release_resource(mdev, 1);
}
 
return rc;
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] au1xxx-ide/rapide: use hwif-index for ide_unregister()

2007-12-30 Thread Bartlomiej Zolnierkiewicz

Cc: Russell King [EMAIL PROTECTED]
Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/arm/rapide.c  |4 ++--
 drivers/ide/mips/au1xxx-ide.c |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Index: b/drivers/ide/arm/rapide.c
===
--- a/drivers/ide/arm/rapide.c
+++ b/drivers/ide/arm/rapide.c
@@ -78,8 +78,8 @@ static void __devexit rapide_remove(stru
 
ecard_set_drvdata(ec, NULL);
 
-   /* there must be a better way */
-   ide_unregister(hwif - ide_hwifs);
+   ide_unregister(hwif-index);
+
ecard_release_resources(ec);
 }
 
Index: b/drivers/ide/mips/au1xxx-ide.c
===
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/mips/au1xxx-ide.c
@@ -691,7 +691,7 @@ static int au_ide_remove(struct device *
ide_hwif_t *hwif = dev_get_drvdata(dev);
_auide_hwif *ahwif = auide_hwif;
 
-   ide_unregister(hwif - ide_hwifs);
+   ide_unregister(hwif-index);
 
iounmap((void *)ahwif-regbase);
 
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ide-cd: move the remaining cdrom.c ioctl handling code to ide-cd_ioctl.c

2007-12-27 Thread Bartlomiej Zolnierkiewicz
On Wednesday 26 December 2007, Borislav Petkov wrote:
 On Wed, Dec 26, 2007 at 09:50:14PM +0100, Borislav Petkov wrote:
 
 Actually you should drop the previous one for it wasn't incomplete. Here's,
 hopefully, a better one :).
 --
 From: Borislav Petkov [EMAIL PROTECTED]
 
 There should be no functional changes from this.
 
 Signed-off-by: Borislav Petkov [EMAIL PROTECTED]

applied, thanks
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] trm290: do hook dma_host_{on,off} methods (take 2)

2007-12-27 Thread Bartlomiej Zolnierkiewicz
On Thursday 27 December 2007, Sergei Shtylyov wrote:
 Using default methods caused the chip's DMA PRD count registers, inadvertently
 starting DMA!  While fixing it, also do:

nasty, this could possibly explain the following trm290.c hack:

...
#if 0 /* play it safe for now */
  IDE_HFLAG_TRUST_BIOS_FOR_DMA |
#endif
...

 - get rid of the 'ide_' prefixes in several functions for which the prefix in
   the method's name has been 'ide_' ectomized already;
 
 - align the code hooking the IDE DMA methods in init_hwif_trm290()...
 
 ---
 Fixed the header, added 'static' to the new method definitions.
 The patch is against Linus' kernel tree...
 
 Signed-off-by: Sergei Shtylyov [EMAIL PROTECTED]

applied
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] amd74xx: remove amd_ide_chips table

2007-12-27 Thread Bartlomiej Zolnierkiewicz

* Remove no longer needed assertion from amd74xx_probe().

* Factor out cable detection for AMD7409 to amd7409_cable_detect() and for
  chipsets = AMD7411 to amd7411_cable_detect().

* Use dev-vendor and dev-device instead of amd_config-udma_mask when
  selecting cable detection method and checking for broken FIFO support in
  init_chipset_amd74xx().

* Remove no longer needed AMD_BAD_FIFO define.

* Add 'swdma' parameter for setting .swdma_mask to DECLARE_AMD_DEV() macro.

* Add 'udma' parameter for setting .udma_mask to DECLARE_{AMD,NV}_DEV() macro.

* Keep a copy of a current amd74xx_chipsets[] entry in amd74xx_probe()
  in order to fix -swdma_mask on early AMD7409 revisions and -udma_mask
  on Serenade mainboards.

* Remove no longer needed fixups from init_chipset_amd74xx()
  and AMD_CHECK_{SWDMA,SERENADE} defines.

* Move printing banner message from init_chipset_amd74xx() to amd74xx_probe(),
  also remove incorrect comment while at it.

* Use hwif-ultra_mask instead of amd_config-udma_mask in amd_set_drive().

* Add 'udma_mask' argument to amd_set_speed() and pass UDMA mask from
  amd_set_drive() instead of using amd_config-udma_mask.

* Move amd_config-base from AMD_* defines to users of these defines and add
  0x40 the defined values.  Then add amd_offset() inline helper for selecting
  offset from 0x40 base (needed for nVidia controllers) and finally use it in
  amd_set_speed(), amd7411_cable_detect() and init_chipset_amd74xx() instead
  of amd_config-base.

* Remove no longer needed AMD_BAD_SWDMA define, -{swdma,ultra}_mask setup
  from init_hwif_amd74xx(), amd_{config,chipset} variables and amd_ide_chips
  table.

* Fix init_chipset_amd74xx() comment.

* Bump driver version.

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-305 bytes
 drivers/ide/pci/amd74xx.c |  275 --
 1 file changed, 124 insertions(+), 151 deletions(-)

Index: b/drivers/ide/pci/amd74xx.c
===
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -1,5 +1,5 @@
 /*
- * Version 2.24
+ * Version 2.25
  *
  * AMD 755/756/766/8111 and nVidia nForce/2/2s/3/3s/CK804/MCP04
  * IDE driver for Linux.
@@ -28,81 +28,46 @@
 
 #include ide-timing.h
 
-#define AMD_IDE_CONFIG (0x01 + amd_config-base)
-#define AMD_CABLE_DETECT   (0x02 + amd_config-base)
-#define AMD_DRIVE_TIMING   (0x08 + amd_config-base)
-#define AMD_8BIT_TIMING(0x0e + amd_config-base)
-#define AMD_ADDRESS_SETUP  (0x0c + amd_config-base)
-#define AMD_UDMA_TIMING(0x10 + amd_config-base)
-
-#define AMD_CHECK_SWDMA0x08
-#define AMD_BAD_SWDMA  0x10
-#define AMD_BAD_FIFO   0x20
-#define AMD_CHECK_SERENADE 0x40
-
-/*
- * AMD SouthBridge chips.
- */
-
-static struct amd_ide_chip {
-   unsigned short id;
-   u8 base;
-   u8 udma_mask;
-   u8 flags;
-} amd_ide_chips[] = {
-   { PCI_DEVICE_ID_AMD_COBRA_7401,  0x40, ATA_UDMA2, AMD_BAD_SWDMA 
},
-   { PCI_DEVICE_ID_AMD_VIPER_7409,  0x40, ATA_UDMA4, 
AMD_CHECK_SWDMA },
-   { PCI_DEVICE_ID_AMD_VIPER_7411,  0x40, ATA_UDMA5, AMD_BAD_FIFO 
},
-   { PCI_DEVICE_ID_AMD_OPUS_7441,   0x40, ATA_UDMA5, },
-   { PCI_DEVICE_ID_AMD_8111_IDE,0x40, ATA_UDMA6, 
AMD_CHECK_SERENADE },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE_IDE,   0x50, ATA_UDMA5, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE,  0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE, 0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA,0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE,  0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE, 0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA,0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2,   0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, 0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, 0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, 0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, 0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, 0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, 0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, 0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE, 0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE, 0x50, ATA_UDMA6, },
-   { PCI_DEVICE_ID_AMD_CS5536_IDE,  0x40, ATA_UDMA5, },
-   { 0 }
+enum {
+   AMD_IDE_CONFIG  = 0x41,
+   AMD_CABLE_DETECT= 0x42,
+   AMD_DRIVE_TIMING= 0x48,
+   AMD_8BIT_TIMING = 0x4e,
+   AMD_ADDRESS_SETUP   = 0x4c,
+   AMD_UDMA_TIMING = 0x50,
 };
 
-static struct amd_ide_chip

[PATCH 2/3] ide: add IDE_HFLAG_CLEAR_SIMPLEX host flag

2007-12-27 Thread Bartlomiej Zolnierkiewicz

* Rename 'simplex_stat' variable to 'dma_stat' in ide_get_or_set_dma_base().

* Factor out code for forcing host out of simplex mode from
  ide_get_or_set_dma_base() to ide_pci_clear_simplex() helper.

* Add IDE_HFLAG_CLEAR_SIMPLEX host flag and set it in alim15x3 (for M5229),
  amd74xx (for AMD 7409), cmd64x (for CMD643), generic (for Netcell) and
  serverworks (for CSB5) host drivers.

* Make ide_get_or_set_dma_base() test for IDE_HFLAG_CLEAR_SIMPLEX host flag
  instead of checking dev-device (BTW the code was buggy because it didn't
  check for dev-vendor, luckily none of these PCI Device IDs was used by
  some other vendor for PCI IDE controller).

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/pci/alim15x3.c|7 ++-
 drivers/ide/pci/amd74xx.c |1 
 drivers/ide/pci/cmd64x.c  |4 +-
 drivers/ide/pci/generic.c |3 +
 drivers/ide/pci/serverworks.c |4 +-
 drivers/ide/setup-pci.c   |   77 ++
 include/linux/ide.h   |2 +
 7 files changed, 49 insertions(+), 49 deletions(-)

Index: b/drivers/ide/pci/alim15x3.c
===
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -775,7 +775,7 @@ static int __devinit alim15x3_init_one(s
};
 
struct ide_port_info d = ali15x3_chipset;
-   u8 rev = dev-revision;
+   u8 rev = dev-revision, idx = id-driver_data;
 
if (pci_dev_present(ati_rs100))
printk(KERN_WARNING alim15x3: ATI Radeon IGP Northbridge is 
not yet fully tested.\n);
@@ -798,6 +798,9 @@ static int __devinit alim15x3_init_one(s
d.udma_mask = ATA_UDMA6;
}
 
+   if (idx == 0)
+   d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX;
+
 #if defined(CONFIG_SPARC64)
d.init_hwif = init_hwif_common_ali15x3;
 #endif /* CONFIG_SPARC64 */
@@ -807,7 +810,7 @@ static int __devinit alim15x3_init_one(s
 
 static const struct pci_device_id alim15x3_pci_tbl[] = {
{ PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5229), 0 },
-   { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), 0 },
+   { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), 1 },
{ 0, },
 };
 MODULE_DEVICE_TABLE(pci, alim15x3_pci_tbl);
Index: b/drivers/ide/pci/amd74xx.c
===
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -295,6 +295,7 @@ static int __devinit amd74xx_probe(struc
if (idx == 1) {
if (dev-revision = 7)
d.swdma_mask = 0;
+   d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX;
} else if (idx == 4) {
if (dev-subsystem_vendor == PCI_VENDOR_ID_AMD 
dev-subsystem_device == PCI_DEVICE_ID_AMD_SERENADE)
Index: b/drivers/ide/pci/cmd64x.c
===
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -443,7 +443,9 @@ static const struct ide_port_info cmd64x
.init_chipset   = init_chipset_cmd64x,
.init_hwif  = init_hwif_cmd64x,
.enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}},
-   .host_flags = IDE_HFLAG_ABUSE_PREFETCH | IDE_HFLAG_BOOTABLE,
+   .host_flags = IDE_HFLAG_CLEAR_SIMPLEX |
+ IDE_HFLAG_ABUSE_PREFETCH |
+ IDE_HFLAG_BOOTABLE,
.pio_mask   = ATA_PIO5,
.mwdma_mask = ATA_MWDMA2,
.udma_mask  = 0x00, /* no udma */
Index: b/drivers/ide/pci/generic.c
===
--- a/drivers/ide/pci/generic.c
+++ b/drivers/ide/pci/generic.c
@@ -104,7 +104,8 @@ static const struct ide_port_info generi
 
{   /* 14 */
.name   = Revolution,
-   .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA |
+   .host_flags = IDE_HFLAG_CLEAR_SIMPLEX |
+ IDE_HFLAG_TRUST_BIOS_FOR_DMA |
  IDE_HFLAG_OFF_BOARD,
.swdma_mask = ATA_SWDMA2,
.mwdma_mask = ATA_MWDMA2,
Index: b/drivers/ide/pci/serverworks.c
===
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -418,7 +418,9 @@ static int __devinit svwks_init_one(stru
 
d = serverworks_chipsets[idx];
 
-   if (idx == 2 || idx == 3) {
+   if (idx == 1)
+   d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX;
+   else if (idx == 2 || idx == 3) {
if ((PCI_FUNC(dev-devfn)  1) == 0) {
if (pci_resource_start(dev, 0) != 0x01f1)
d.host_flags = ~IDE_HFLAG_BOOTABLE;
Index: b/drivers/ide/setup-pci.c

[PATCH 3/3] ide: add IDE_HFLAG_NO_DSC host flag

2007-12-27 Thread Bartlomiej Zolnierkiewicz

* Add IDE_HFLAG_NO_DSC host flag for hosts that doesn't support DSC overlap.

* Set it in aec62xx (for ATP850UF only) and hpt34x host drivers.

* Convert ide-tape device driver to check for IDE_HFLAG_NO_DSC flag.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-tape.c|   16 
 drivers/ide/pci/aec62xx.c |1 +
 drivers/ide/pci/hpt34x.c  |1 +
 include/linux/ide.h   |2 ++
 4 files changed, 8 insertions(+), 12 deletions(-)

Index: b/drivers/ide/ide-tape.c
===
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -4532,19 +4532,11 @@ static void idetape_setup (ide_drive_t *
 
spin_lock_init(tape-spinlock);
drive-dsc_overlap = 1;
-#ifdef CONFIG_BLK_DEV_IDEPCI
-   if (HWIF(drive)-pci_dev != NULL) {
-   /*
-* These two ide-pci host adapters appear to need DSC overlap 
disabled.
-* This probably needs further analysis.
-*/
-   if ((HWIF(drive)-pci_dev-device == 
PCI_DEVICE_ID_ARTOP_ATP850UF) ||
-   (HWIF(drive)-pci_dev-device == PCI_DEVICE_ID_TTI_HPT343)) 
{
-   printk(KERN_INFO ide-tape: %s: disabling DSC 
overlap\n, tape-name);
-   drive-dsc_overlap = 0;
-   }
+   if (drive-hwif-host_flags  IDE_HFLAG_NO_DSC) {
+   printk(KERN_INFO ide-tape: %s: disabling DSC overlap\n,
+tape-name);
+   drive-dsc_overlap = 0;
}
-#endif /* CONFIG_BLK_DEV_IDEPCI */
/* Seagate Travan drives do not support DSC overlap. */
if (strstr(drive-id-model, Seagate STT3401))
drive-dsc_overlap = 0;
Index: b/drivers/ide/pci/aec62xx.c
===
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -202,6 +202,7 @@ static const struct ide_port_info aec62x
.enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
.host_flags = IDE_HFLAG_SERIALIZE |
  IDE_HFLAG_NO_ATAPI_DMA |
+ IDE_HFLAG_NO_DSC |
  IDE_HFLAG_ABUSE_SET_DMA_MODE |
  IDE_HFLAG_OFF_BOARD,
.pio_mask   = ATA_PIO4,
Index: b/drivers/ide/pci/hpt34x.c
===
--- a/drivers/ide/pci/hpt34x.c
+++ b/drivers/ide/pci/hpt34x.c
@@ -131,6 +131,7 @@ static void __devinit init_hwif_hpt34x(i
 
 #define IDE_HFLAGS_HPT34X \
(IDE_HFLAG_NO_ATAPI_DMA | \
+IDE_HFLAG_NO_DSC | \
 IDE_HFLAG_ABUSE_SET_DMA_MODE | \
 IDE_HFLAG_NO_AUTODMA)
 
Index: b/include/linux/ide.h
===
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1098,6 +1098,8 @@ enum {
IDE_HFLAG_CY82C693  = (1  27),
/* force host out of simplex mode */
IDE_HFLAG_CLEAR_SIMPLEX = (1  28),
+   /* DSC overlap is unsupported */
+   IDE_HFLAG_NO_DSC= (1  29),
 };
 
 #ifdef CONFIG_BLK_DEV_OFFBOARD
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 9/9] ide: use ide_build_sglist() and ide_destroy_dmatable() in non-PCI host drivers

2007-12-27 Thread Bartlomiej Zolnierkiewicz
* Make ide_build_sglist() and ide_destroy_dmatable() available also when
  CONFIG_BLK_DEV_IDEDMA_PCI=n.

* Use ide_build_sglist() and ide_destroy_dmatable() in {ics,au1xxx-}ide.c
  and remove no longer needed {ics,au}ide_build_sglist().

There should be no functionality changes caused by this patch.

Cc: Russell King [EMAIL PROTECTED]
Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/arm/icside.c  |   21 ++---
 drivers/ide/ide-dma.c |4 +++-
 drivers/ide/mips/au1xxx-ide.c |   28 +++-
 include/linux/ide.h   |5 +++--
 4 files changed, 11 insertions(+), 47 deletions(-)

Index: b/drivers/ide/arm/icside.c
===
--- a/drivers/ide/arm/icside.c
+++ b/drivers/ide/arm/icside.c
@@ -204,22 +204,6 @@ static void icside_maskproc(ide_drive_t 
  * interfaces use the same IRQ, which should guarantee this.
  */
 
-static void icside_build_sglist(ide_drive_t *drive, struct request *rq)
-{
-   ide_hwif_t *hwif = drive-hwif;
-   struct scatterlist *sg = hwif-sg_table;
-
-   ide_map_sg(drive, rq);
-
-   if (rq_data_dir(rq) == READ)
-   hwif-sg_dma_direction = DMA_FROM_DEVICE;
-   else
-   hwif-sg_dma_direction = DMA_TO_DEVICE;
-
-   hwif-sg_nents = dma_map_sg(hwif-dev, sg, hwif-sg_nents,
-   hwif-sg_dma_direction);
-}
-
 /*
  * Configure the IOMD to give the appropriate timings for the transfer
  * mode being requested.  We take the advice of the ATA standards, and
@@ -298,8 +282,7 @@ static int icside_dma_end(ide_drive_t *d
disable_dma(ec-dma);
 
/* Teardown mappings after DMA has completed. */
-   dma_unmap_sg(hwif-dev, hwif-sg_table, hwif-sg_nents,
-hwif-sg_dma_direction);
+   ide_destroy_dmatable(drive);
 
return get_dma_residue(ec-dma) != 0;
 }
@@ -331,7 +314,7 @@ static int icside_dma_setup(ide_drive_t 
 */
BUG_ON(dma_channel_active(ec-dma));
 
-   icside_build_sglist(drive, rq);
+   hwif-sg_nents = ide_build_sglist(drive, rq);
 
/*
 * Ensure that we have the right interrupt routed.
Index: b/drivers/ide/ide-dma.c
===
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -170,7 +170,6 @@ static int ide_dma_good_drive(ide_drive_
return ide_in_drive_list(drive-id, drive_whitelist);
 }
 
-#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
 /**
  * ide_build_sglist-   map IDE scatter gather for DMA I/O
  * @drive: the drive to build the DMA table for
@@ -200,6 +199,7 @@ int ide_build_sglist(ide_drive_t *drive,
 
 EXPORT_SYMBOL_GPL(ide_build_sglist);
 
+#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
 /**
  * ide_build_dmatable  -   build IDE DMA table
  *
@@ -294,6 +294,7 @@ use_pio_instead:
 }
 
 EXPORT_SYMBOL_GPL(ide_build_dmatable);
+#endif
 
 /**
  * ide_destroy_dmatable-   clean up DMA mapping
@@ -316,6 +317,7 @@ void ide_destroy_dmatable (ide_drive_t *
 
 EXPORT_SYMBOL_GPL(ide_destroy_dmatable);
 
+#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
 /**
  * config_drive_for_dma-   attempt to activate IDE DMA
  * @drive: the drive to place in DMA mode
Index: b/drivers/ide/mips/au1xxx-ide.c
===
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/mips/au1xxx-ide.c
@@ -209,23 +209,6 @@ static void auide_set_dma_mode(ide_drive
  */
 
 #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
-
-static int auide_build_sglist(ide_drive_t *drive,  struct request *rq)
-{
-   ide_hwif_t *hwif = drive-hwif;
-   struct scatterlist *sg = hwif-sg_table;
-
-   ide_map_sg(drive, rq);
-
-   if (rq_data_dir(rq) == READ)
-   hwif-sg_dma_direction = DMA_FROM_DEVICE;
-   else
-   hwif-sg_dma_direction = DMA_TO_DEVICE;
-
-   return dma_map_sg(hwif-dev, sg, hwif-sg_nents,
- hwif-sg_dma_direction);
-}
-
 static int auide_build_dmatable(ide_drive_t *drive)
 {
int i, iswrite, count = 0;
@@ -240,8 +223,7 @@ static int auide_build_dmatable(ide_driv
/* Save for interrupt context */
ahwif-drive = drive;
 
-   /* Build sglist */
-   hwif-sg_nents = i = auide_build_sglist(drive, rq);
+   hwif-sg_nents = i = ide_build_sglist(drive, rq);
 
if (!i)
return 0;
@@ -299,10 +281,7 @@ static int auide_build_dmatable(ide_driv
return 1;
 
  use_pio_instead:
-   dma_unmap_sg(hwif-dev,
-hwif-sg_table,
-hwif-sg_nents,
-hwif-sg_dma_direction);
+   ide_destroy_dmatable(drive);
 
return 0; /* revert to PIO for this request */
 }
@@ -312,8 +291,7 @@ static int auide_dma_end(ide_drive_t *dr
ide_hwif_t *hwif = HWIF(drive);
 
if (hwif-sg_nents) {
-   dma_unmap_sg(hwif

[PATCH 8/9] ide: switch to DMA-mapping API

2007-12-27 Thread Bartlomiej Zolnierkiewicz
* pci_map_sg() - dma_map_sg() in ide_build_sglist().

* pci_unmap_sg() - dma_unmap_sg() in ide_destroy_dmatable().

There should be no functionality changes caused by this patch except
for blackfin arch whose dma_[un]map_sg() implementation differs from
pci_[un]map_sg() one (on s390 arch there is no PCI, on avr32 and h8300
archs PCI is currently unsupported, on m32r arch PCI support depends
on BROKEN, on m68k arch PCI support depends on HADES which in turn
depends on BROKEN, on all other archs dma_[un]map_sg() functionality
matches with pci_[un]map_sg() one).

Cc: Bryan Wu [EMAIL PROTECTED]
Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
It seems like blackfin arch should be using asm-generic/pci-dma-compat.h
in asm-blackfin/pci.h or drivers still using PCI DMA-mapping API instead
of the generic one won't work but I'll leave this to blackfin gurus...

[ Bryan, could you please take a look?  Thanks. ]

 drivers/ide/ide-dma.c |   18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

Index: b/drivers/ide/ide-dma.c
===
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -85,6 +85,7 @@
 #include linux/ide.h
 #include linux/delay.h
 #include linux/scatterlist.h
+#include linux/dma-mapping.h
 
 #include asm/io.h
 #include asm/irq.h
@@ -175,26 +176,26 @@ static int ide_dma_good_drive(ide_drive_
  * @drive: the drive to build the DMA table for
  * @rq: the request holding the sg list
  *
- * Perform the PCI mapping magic necessary to access the source or
- * target buffers of a request via PCI DMA. The lower layers of the
+ * Perform the DMA mapping magic necessary to access the source or
+ * target buffers of a request via DMA.  The lower layers of the
  * kernel provide the necessary cache management so that we can
- * operate in a portable fashion
+ * operate in a portable fashion.
  */
 
 int ide_build_sglist(ide_drive_t *drive, struct request *rq)
 {
ide_hwif_t *hwif = HWIF(drive);
-   struct pci_dev *pdev = to_pci_dev(hwif-dev);
struct scatterlist *sg = hwif-sg_table;
 
ide_map_sg(drive, rq);
 
if (rq_data_dir(rq) == READ)
-   hwif-sg_dma_direction = PCI_DMA_FROMDEVICE;
+   hwif-sg_dma_direction = DMA_FROM_DEVICE;
else
-   hwif-sg_dma_direction = PCI_DMA_TODEVICE;
+   hwif-sg_dma_direction = DMA_TO_DEVICE;
 
-   return pci_map_sg(pdev, sg, hwif-sg_nents, hwif-sg_dma_direction);
+   return dma_map_sg(hwif-dev, sg, hwif-sg_nents,
+ hwif-sg_dma_direction);
 }
 
 EXPORT_SYMBOL_GPL(ide_build_sglist);
@@ -308,9 +309,8 @@ EXPORT_SYMBOL_GPL(ide_build_dmatable);
 void ide_destroy_dmatable (ide_drive_t *drive)
 {
ide_hwif_t *hwif = drive-hwif;
-   struct pci_dev *pdev = to_pci_dev(hwif-dev);
 
-   pci_unmap_sg(pdev, hwif-sg_table, hwif-sg_nents,
+   dma_unmap_sg(hwif-dev, hwif-sg_table, hwif-sg_nents,
 hwif-sg_dma_direction);
 }
 
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/9] ide: fix ide_intr() for non-PCI devices and CONFIG_BLK_DEV_IDEPCI=y

2007-12-27 Thread Bartlomiej Zolnierkiewicz
'hwif-pci_dev  !hwif-pci_dev-vendor' condition is never true,
check for 'hwif-chipset != ide_pci' instead.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-io.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: b/drivers/ide/ide-io.c
===
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -1487,7 +1487,7 @@ irqreturn_t ide_intr (int irq, void *dev
 * remove all the ifdef PCI crap
 */
 #ifdef CONFIG_BLK_DEV_IDEPCI
-   if (hwif-pci_dev  !hwif-pci_dev-vendor)
+   if (hwif-chipset != ide_pci)
 #endif /* CONFIG_BLK_DEV_IDEPCI */
{
/*
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/9] ide: switch to generic DMA-mapping API

2007-12-27 Thread Bartlomiej Zolnierkiewicz

Make IDE core PCI independent by replacing hwif-pci_dev (struct pci_dev *)
with hwif-dev (struct device *) and switch to using generic DMA-mapping API.

This is on top of IDE quilt tree + 3 patches posted today.

diffstat:

 drivers/ide/arm/icside.c  |   52 
 drivers/ide/ide-dma.c |   55 +++---
 drivers/ide/ide-io.c  |2 -
 drivers/ide/ide-lib.c |6 ++-
 drivers/ide/ide-probe.c   |4 +-
 drivers/ide/ide.c |3 +
 drivers/ide/mips/au1xxx-ide.c |   43 ---
 drivers/ide/pci/aec62xx.c |8 ++--
 drivers/ide/pci/alim15x3.c|9 ++--
 drivers/ide/pci/amd74xx.c |7 ++-
 drivers/ide/pci/atiixp.c  |9 ++--
 drivers/ide/pci/cmd64x.c  |   14 +++
 drivers/ide/pci/cs5520.c  |2 -
 drivers/ide/pci/cs5535.c  |4 +-
 drivers/ide/pci/cy82c693.c|5 +-
 drivers/ide/pci/delkin_cb.c   |2 -
 drivers/ide/pci/hpt34x.c  |2 -
 drivers/ide/pci/hpt366.c  |   29 +--
 drivers/ide/pci/it8213.c  |7 ++-
 drivers/ide/pci/it821x.c  |   47 +++--
 drivers/ide/pci/jmicron.c |2 -
 drivers/ide/pci/ns87415.c |   14 +++
 drivers/ide/pci/pdc202xx_new.c|6 ++-
 drivers/ide/pci/pdc202xx_old.c|   11 +++---
 drivers/ide/pci/piix.c|   53 ++--
 drivers/ide/pci/rz1000.c  |2 -
 drivers/ide/pci/sc1200.c  |   12 +++---
 drivers/ide/pci/scc_pata.c|   13 +++
 drivers/ide/pci/serverworks.c |   18 ++---
 drivers/ide/pci/sgiioc4.c |   19 --
 drivers/ide/pci/siimage.c |   51 ---
 drivers/ide/pci/sis5513.c |   22 ++--
 drivers/ide/pci/sl82c105.c|   17 +
 drivers/ide/pci/slc90e66.c|7 ++-
 drivers/ide/pci/tc86c001.c|3 +
 drivers/ide/pci/triflex.c |2 -
 drivers/ide/pci/trm290.c  |2 -
 drivers/ide/pci/via82cxxx.c   |   12 +++---
 drivers/ide/ppc/pmac.c|   24 ++---
 drivers/ide/setup-pci.c   |6 +--
 include/asm-mips/mach-au1x00/au1xxx_ide.h |1
 include/linux/ide.h   |   10 +++--
 42 files changed, 288 insertions(+), 329 deletions(-)

Thanks,
Bart
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/9] piix: remove stale comments

2007-12-27 Thread Bartlomiej Zolnierkiewicz

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/pci/piix.c |   47 +--
 1 file changed, 1 insertion(+), 46 deletions(-)

Index: b/drivers/ide/pci/piix.c
===
--- a/drivers/ide/pci/piix.c
+++ b/drivers/ide/pci/piix.c
@@ -8,53 +8,8 @@
  *
  *  May be copied or modified under the terms of the GNU General Public License
  *
- *  PIO mode setting function for Intel chipsets.
- *  For use instead of BIOS settings.
+ * Documentation:
  *
- * 40-41
- * 42-43
- * 
- * 41
- * 43
- *
- * | PIO 0   | c0 | 80 | 0 |
- * | PIO 2 | SW2 | d0 | 90 | 4 |
- * | PIO 3 | MW1 | e1 | a1 | 9 |
- * | PIO 4 | MW2 | e3 | a3 | b |
- *
- * sitre = word40  0x4000; primary
- * sitre = word42  0x4000; secondary
- *
- * 44 8421|8421hdd|hdb
- *
- * 48 8421 hdd|hdc|hdb|hda udma enabled
- *
- *0001 hda
- *0010 hdb
- *0100 hdc
- *1000 hdd
- *
- * 4a 84|21hdb|hda
- * 4b 84|21hdd|hdc
- *
- *ata-33/82371AB
- *ata-33/82371EB
- *ata-33/82801ABata-66/82801AA
- *00|00 udma 0  00|00 reserved
- *01|01 udma 1  01|01 udma 3
- *10|10 udma 2  10|10 udma 4
- *11|11 reserved11|11 reserved
- *
- * 54 8421|8421ata66 drive|ata66 enable
- *
- * pci_read_config_word(HWIF(drive)-pci_dev, 0x40, reg40);
- * pci_read_config_word(HWIF(drive)-pci_dev, 0x42, reg42);
- * pci_read_config_word(HWIF(drive)-pci_dev, 0x44, reg44);
- * pci_read_config_byte(HWIF(drive)-pci_dev, 0x48, reg48);
- * pci_read_config_word(HWIF(drive)-pci_dev, 0x4a, reg4a);
- * pci_read_config_byte(HWIF(drive)-pci_dev, 0x54, reg54);
- *
- * Documentation
  * Publically available from Intel web site. Errata documentation
  * is also publically available. As an aide to anyone hacking on this
  * driver the list of errata that are relevant is below.going back to
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/9] ide: remove BUG_ON() from ide_build_sglist()

2007-12-27 Thread Bartlomiej Zolnierkiewicz
do_rw_taskfile() has been fixed to check the return value
of -dma_setup method so this BUG_ON() is no longer needed.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-dma.c |2 --
 1 file changed, 2 deletions(-)

Index: b/drivers/ide/ide-dma.c
===
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -186,8 +186,6 @@ int ide_build_sglist(ide_drive_t *drive,
ide_hwif_t *hwif = HWIF(drive);
struct scatterlist *sg = hwif-sg_table;
 
-   BUG_ON((rq-cmd_type == REQ_TYPE_ATA_TASKFILE)  rq-nr_sectors  256);
-
ide_map_sg(drive, rq);
 
if (rq_data_dir(rq) == READ)
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/9] ide: use ide_destroy_dmatable() instead of pci_unmap_sg()

2007-12-27 Thread Bartlomiej Zolnierkiewicz
Use ide_destroy_dmatable() in:
* ide-dma.c::ide_build_dmatable()
* sgiioc4.c::sgiioc4_build_dma_table()
* pmac.c::pmac_ide_{build,destroy}_dmatable()

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-dma.c |8 
 drivers/ide/pci/sgiioc4.c |3 +--
 drivers/ide/ppc/pmac.c|   14 +-
 3 files changed, 10 insertions(+), 15 deletions(-)

Index: b/drivers/ide/ide-dma.c
===
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -282,12 +282,12 @@ int ide_build_dmatable (ide_drive_t *dri
*--table |= cpu_to_le32(0x8000);
return count;
}
+
printk(KERN_ERR %s: empty DMA table?\n, drive-name);
+
 use_pio_instead:
-   pci_unmap_sg(hwif-pci_dev,
-hwif-sg_table,
-hwif-sg_nents,
-hwif-sg_dma_direction);
+   ide_destroy_dmatable(drive);
+
return 0; /* revert to PIO for this request */
 }
 
Index: b/drivers/ide/pci/sgiioc4.c
===
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -517,8 +517,7 @@ sgiioc4_build_dma_table(ide_drive_t * dr
}
 
 use_pio_instead:
-   pci_unmap_sg(hwif-pci_dev, hwif-sg_table, hwif-sg_nents,
-hwif-sg_dma_direction);
+   ide_destroy_dmatable(drive);
 
return 0;   /* revert to PIO for this request */
 }
Index: b/drivers/ide/ppc/pmac.c
===
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1535,11 +1535,10 @@ pmac_ide_build_dmatable(ide_drive_t *dri
}
 
printk(KERN_DEBUG %s: empty DMA table?\n, drive-name);
- use_pio_instead:
-   pci_unmap_sg(hwif-pci_dev,
-hwif-sg_table,
-hwif-sg_nents,
-hwif-sg_dma_direction);
+
+use_pio_instead:
+   ide_destroy_dmatable(drive);
+
return 0; /* revert to PIO for this request */
 }
 
@@ -1548,12 +1547,9 @@ static void
 pmac_ide_destroy_dmatable (ide_drive_t *drive)
 {
ide_hwif_t *hwif = drive-hwif;
-   struct pci_dev *dev = HWIF(drive)-pci_dev;
-   struct scatterlist *sg = hwif-sg_table;
-   int nents = hwif-sg_nents;
 
if (nents) {
-   pci_unmap_sg(dev, sg, nents, hwif-sg_dma_direction);
+   ide_destroy_dmatable(drive);
hwif-sg_nents = 0;
}
 }
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/9] au1xxx-ide: use hwif-dev

2007-12-27 Thread Bartlomiej Zolnierkiewicz
* Setup hwif-dev in au_ide_probe().

* Use hwif-dev instead of ahwif-dev in auide_build_sglist(),
  auide_build_dmatable(), auide_dma_end() and auide_ddma_init().

* Remove no longer needed 'dev' field from _auide_hwif type.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/mips/au1xxx-ide.c |   15 ++-
 include/asm-mips/mach-au1x00/au1xxx_ide.h |1 -
 2 files changed, 6 insertions(+), 10 deletions(-)

Index: b/drivers/ide/mips/au1xxx-ide.c
===
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/mips/au1xxx-ide.c
@@ -213,7 +213,6 @@ static void auide_set_dma_mode(ide_drive
 static int auide_build_sglist(ide_drive_t *drive,  struct request *rq)
 {
ide_hwif_t *hwif = drive-hwif;
-   _auide_hwif *ahwif = (_auide_hwif*)hwif-hwif_data;
struct scatterlist *sg = hwif-sg_table;
 
ide_map_sg(drive, rq);
@@ -223,7 +222,7 @@ static int auide_build_sglist(ide_drive_
else
hwif-sg_dma_direction = DMA_TO_DEVICE;
 
-   return dma_map_sg(ahwif-dev, sg, hwif-sg_nents,
+   return dma_map_sg(hwif-dev, sg, hwif-sg_nents,
  hwif-sg_dma_direction);
 }
 
@@ -300,7 +299,7 @@ static int auide_build_dmatable(ide_driv
return 1;
 
  use_pio_instead:
-   dma_unmap_sg(ahwif-dev,
+   dma_unmap_sg(hwif-dev,
 hwif-sg_table,
 hwif-sg_nents,
 hwif-sg_dma_direction);
@@ -311,10 +310,9 @@ static int auide_build_dmatable(ide_driv
 static int auide_dma_end(ide_drive_t *drive)
 {
ide_hwif_t *hwif = HWIF(drive);
-   _auide_hwif *ahwif = (_auide_hwif*)hwif-hwif_data;
 
if (hwif-sg_nents) {
-   dma_unmap_sg(ahwif-dev, hwif-sg_table, hwif-sg_nents,
+   dma_unmap_sg(hwif-dev, hwif-sg_table, hwif-sg_nents,
 hwif-sg_dma_direction);
hwif-sg_nents = 0;
}
@@ -504,7 +502,7 @@ static int auide_ddma_init(_auide_hwif *
auide-rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide-rx_chan,
 NUM_DESCRIPTORS);
  
-   hwif-dmatable_cpu = dma_alloc_coherent(auide-dev,
+   hwif-dmatable_cpu = dma_alloc_coherent(hwif-dev,
PRD_ENTRIES * PRD_BYTES,
/* 1 Page */
hwif-dmatable_dma, 
GFP_KERNEL);

@@ -592,9 +590,6 @@ static int au_ide_probe(struct device *d
 #endif
 
memset(auide_hwif, 0, sizeof(_auide_hwif));
-   auide_hwif.dev  = 0;
-
-   ahwif-dev = dev;
ahwif-irq = platform_get_irq(pdev, 0);
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -633,6 +628,8 @@ static int au_ide_probe(struct device *d
 
ide_init_port_hw(hwif, hw);
 
+   hwif-dev = dev;
+
hwif-ultra_mask= 0x0;  /* Disable Ultra DMA */
 #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
hwif-mwdma_mask= 0x07; /* Multimode-2 DMA  */
Index: b/include/asm-mips/mach-au1x00/au1xxx_ide.h
===
--- a/include/asm-mips/mach-au1x00/au1xxx_ide.h
+++ b/include/asm-mips/mach-au1x00/au1xxx_ide.h
@@ -74,7 +74,6 @@ typedef struct
 struct dbdma_cmd*dma_table_cpu;
 dma_addr_t  dma_table_dma;
 #endif
-struct device   *dev;
int irq;
u32 regbase;
 #ifdef CONFIG_PM
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/9] icside: use hwif-dev

2007-12-27 Thread Bartlomiej Zolnierkiewicz
* Setup hwif-dev in icside_setup().

* Use hwif-dev instead of state-dev in icside_build_sglist(),
  icside_dma_end(), icside_dma_start() and icside_dma_setup().

* Remove no longer needed 'dev' field from struct icside_state.

Cc: Russell King [EMAIL PROTECTED]
Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/arm/icside.c |   31 ++-
 1 file changed, 14 insertions(+), 17 deletions(-)

Index: b/drivers/ide/arm/icside.c
===
--- a/drivers/ide/arm/icside.c
+++ b/drivers/ide/arm/icside.c
@@ -71,8 +71,6 @@ struct icside_state {
void __iomem *irq_port;
void __iomem *ioc_base;
unsigned int type;
-   /* parent device... until the IDE core gets one of its own */
-   struct device *dev;
ide_hwif_t *hwif[2];
 };
 
@@ -209,7 +207,6 @@ static void icside_maskproc(ide_drive_t 
 static void icside_build_sglist(ide_drive_t *drive, struct request *rq)
 {
ide_hwif_t *hwif = drive-hwif;
-   struct icside_state *state = hwif-hwif_data;
struct scatterlist *sg = hwif-sg_table;
 
ide_map_sg(drive, rq);
@@ -219,7 +216,7 @@ static void icside_build_sglist(ide_driv
else
hwif-sg_dma_direction = DMA_TO_DEVICE;
 
-   hwif-sg_nents = dma_map_sg(state-dev, sg, hwif-sg_nents,
+   hwif-sg_nents = dma_map_sg(hwif-dev, sg, hwif-sg_nents,
hwif-sg_dma_direction);
 }
 
@@ -294,33 +291,33 @@ static void icside_dma_host_set(ide_driv
 static int icside_dma_end(ide_drive_t *drive)
 {
ide_hwif_t *hwif = HWIF(drive);
-   struct icside_state *state = hwif-hwif_data;
+   struct expansion_card *ec = ECARD_DEV(hwif-dev);
 
drive-waiting_for_dma = 0;
 
-   disable_dma(ECARD_DEV(state-dev)-dma);
+   disable_dma(ec-dma);
 
/* Teardown mappings after DMA has completed. */
-   dma_unmap_sg(state-dev, hwif-sg_table, hwif-sg_nents,
+   dma_unmap_sg(hwif-dev, hwif-sg_table, hwif-sg_nents,
 hwif-sg_dma_direction);
 
-   return get_dma_residue(ECARD_DEV(state-dev)-dma) != 0;
+   return get_dma_residue(ec-dma) != 0;
 }
 
 static void icside_dma_start(ide_drive_t *drive)
 {
ide_hwif_t *hwif = HWIF(drive);
-   struct icside_state *state = hwif-hwif_data;
+   struct expansion_card *ec = ECARD_DEV(hwif-dev);
 
/* We can not enable DMA on both channels simultaneously. */
-   BUG_ON(dma_channel_active(ECARD_DEV(state-dev)-dma));
-   enable_dma(ECARD_DEV(state-dev)-dma);
+   BUG_ON(dma_channel_active(ec-dma));
+   enable_dma(ec-dma);
 }
 
 static int icside_dma_setup(ide_drive_t *drive)
 {
ide_hwif_t *hwif = HWIF(drive);
-   struct icside_state *state = hwif-hwif_data;
+   struct expansion_card *ec = ECARD_DEV(hwif-dev);
struct request *rq = hwif-hwgroup-rq;
unsigned int dma_mode;
 
@@ -332,7 +329,7 @@ static int icside_dma_setup(ide_drive_t 
/*
 * We can not enable DMA on both channels.
 */
-   BUG_ON(dma_channel_active(ECARD_DEV(state-dev)-dma));
+   BUG_ON(dma_channel_active(ec-dma));
 
icside_build_sglist(drive, rq);
 
@@ -349,14 +346,14 @@ static int icside_dma_setup(ide_drive_t 
/*
 * Select the correct timing for this drive.
 */
-   set_dma_speed(ECARD_DEV(state-dev)-dma, drive-drive_data);
+   set_dma_speed(ec-dma, drive-drive_data);
 
/*
 * Tell the DMA engine about the SG table and
 * data direction.
 */
-   set_dma_sg(ECARD_DEV(state-dev)-dma, hwif-sg_table, hwif-sg_nents);
-   set_dma_mode(ECARD_DEV(state-dev)-dma, dma_mode);
+   set_dma_sg(ec-dma, hwif-sg_table, hwif-sg_nents);
+   set_dma_mode(ec-dma, dma_mode);
 
drive-waiting_for_dma = 1;
 
@@ -444,6 +441,7 @@ icside_setup(void __iomem *base, struct 
hwif-noprobe = 0;
hwif-chipset = ide_acorn;
hwif-gendev.parent = ec-dev;
+   hwif-dev = ec-dev;
}
 
return hwif;
@@ -591,7 +589,6 @@ icside_probe(struct expansion_card *ec, 
}
 
state-type = ICS_TYPE_NOTYPE;
-   state-dev  = ec-dev;
 
idmem = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
if (idmem) {
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] cmd64x: fix hwif-chipset setup

2007-12-24 Thread Bartlomiej Zolnierkiewicz

commit 528a572daea90aa41db92683e5a8756acef514c4 (ide: add -chipset field
to ide_pci_device_t) broke hwif-chipset setup (it is now set to ide_cmd646
for CMD648 instead of CMD646).  It seems that the breakage happend while
I was moving patches around (cmd64x_chipsets[] entries for CMD646 and CMD648
are identical except for 'name' field).  Fix it and bump driver version.

Cc: Sergei Shtylyov [EMAIL PROTECTED]
Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/pci/cmd64x.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: b/drivers/ide/pci/cmd64x.c
===
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -1,5 +1,5 @@
 /*
- * linux/drivers/ide/pci/cmd64x.c  Version 1.51Nov 8, 2007
+ * linux/drivers/ide/pci/cmd64x.c  Version 1.52Dec 24, 2007
  *
  * cmd64x.c: Enable interrupts at initialization time on Ultra/PCI machines.
  *   Due to massive hardware bugs, UltraDMA is only supported
@@ -564,6 +564,7 @@ static const struct ide_port_info cmd64x
.init_chipset   = init_chipset_cmd64x,
.init_hwif  = init_hwif_cmd64x,
.enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
+   .chipset= ide_cmd646,
.host_flags = IDE_HFLAG_ABUSE_PREFETCH | IDE_HFLAG_BOOTABLE,
.pio_mask   = ATA_PIO5,
.mwdma_mask = ATA_MWDMA2,
@@ -573,7 +574,6 @@ static const struct ide_port_info cmd64x
.init_chipset   = init_chipset_cmd64x,
.init_hwif  = init_hwif_cmd64x,
.enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
-   .chipset= ide_cmd646,
.host_flags = IDE_HFLAG_ABUSE_PREFETCH | IDE_HFLAG_BOOTABLE,
.pio_mask   = ATA_PIO5,
.mwdma_mask = ATA_MWDMA2,
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[git patches] IDE fixes

2007-12-24 Thread Bartlomiej Zolnierkiewicz

cmd64x regression bugfix, few obvious ide-cd fixes from the redux patch
peries and ide-cd MAINTAINERS entry update (Borislav, welcome on board!).

Oh yes, I would forget...

Merry Christmas!


Linus, please pull from:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/

to receive the following updates:

 MAINTAINERS  |4 ++-
 drivers/ide/ide-cd.c |   66 +++--
 drivers/ide/ide-cd.h |3 +-
 drivers/ide/pci/cmd64x.c |4 +-
 drivers/ide/pci/cs5535.c |2 +-
 5 files changed, 42 insertions(+), 37 deletions(-)


Bartlomiej Zolnierkiewicz (10):
  ide-cd: fix SAMSUNG CD-ROM SCR-3231 quirk
  ide-cd: fix ACER/AOpen 24X CDROM speed reporting on big-endian machines
  ide-cd: use ide_cd_release() in ide_cd_probe()
  ide-cd: fix error messages in cdrom_{read,write}_check_ireason()
  ide-cd: add missing 'ireason' masking to cdrom_write_intr()
  ide-cd: fix error messages in cdrom_write_intr()
  ide-cd: add error message for DMA error to cdrom_read_intr()
  ide-cd: fix error message in cdrom_pc_intr()
  ide-cd: fix 'ireason' reporting in cdrom_pc_intr()
  cmd64x: fix hwif-chipset setup

Borislav Petkov (1):
  MAINTAINERS: update ide-cd entry

Joe Perches (1):
  drivers/ide/: Spelling fixes


diff --git a/MAINTAINERS b/MAINTAINERS
index 3d567fd..79c711e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1870,8 +1870,10 @@ T:   quilt 
kernel.org/pub/linux/kernel/people/bart/pata-2.6/
 S: Maintained
 
 IDE/ATAPI CDROM DRIVER
+P: Borislav Petkov
+M: [EMAIL PROTECTED]
 L: linux-ide@vger.kernel.org
-S: Unmaintained
+S: Maintained
 
 IDE/ATAPI FLOPPY DRIVERS
 P: Paul Bristow
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 92ac658..c7d77f0 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1068,8 +1068,8 @@ int cdrom_read_check_ireason (ide_drive_t *drive, int 
len, int ireason)
return 0;
else if (ireason == 0) {
/* Whoops... The drive is expecting to receive data from us! */
-   printk(KERN_ERR %s: read_intr: Drive wants to transfer data 
the 
-   wrong way!\n, drive-name);
+   printk(KERN_ERR %s: %s: wrong transfer direction!\n,
+   drive-name, __FUNCTION__);
 
/* Throw some data at the drive so it doesn't hang
   and quit this request. */
@@ -1086,8 +1086,8 @@ int cdrom_read_check_ireason (ide_drive_t *drive, int 
len, int ireason)
return 0;
} else {
/* Drive wants a command packet, or invalid ireason... */
-   printk(KERN_ERR %s: read_intr: bad interrupt reason %x\n, 
drive-name,
-   ireason);
+   printk(KERN_ERR %s: %s: bad interrupt reason 0x%02x\n,
+   drive-name, __FUNCTION__, ireason);
}
 
cdrom_end_request(drive, 0);
@@ -1112,8 +1112,11 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t 
*drive)
 */
if (dma) {
info-dma = 0;
-   if ((dma_error = HWIF(drive)-ide_dma_end(drive)))
+   dma_error = HWIF(drive)-ide_dma_end(drive);
+   if (dma_error) {
+   printk(KERN_ERR %s: DMA read error\n, drive-name);
ide_dma_off(drive);
+   }
}
 
if (cdrom_decode_status(drive, 0, stat))
@@ -1443,7 +1446,7 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
return ide_stopped;
 
/* Read the interrupt reason and the transfer length. */
-   ireason = HWIF(drive)-INB(IDE_IREASON_REG);
+   ireason = HWIF(drive)-INB(IDE_IREASON_REG)  0x3;
lowcyl  = HWIF(drive)-INB(IDE_BCOUNTL_REG);
highcyl = HWIF(drive)-INB(IDE_BCOUNTH_REG);
 
@@ -1484,7 +1487,7 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
if (thislen  len) thislen = len;
 
/* The drive wants to be written to. */
-   if ((ireason  3) == 0) {
+   if (ireason == 0) {
if (!rq-data) {
blk_dump_rq_flags(rq, cdrom_pc_intr, write);
goto confused;
@@ -1506,9 +1509,9 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
}
 
/* Same drill for reading. */
-   else if ((ireason  3) == 2) {
+   else if (ireason == 2) {
if (!rq-data) {
-   blk_dump_rq_flags(rq, cdrom_pc_intr, write);
+   blk_dump_rq_flags(rq, cdrom_pc_intr, read);
goto confused;
}
/* Transfer the data. */
@@ -1632,8 +1635,8 @@ static int cdrom_write_check_ireason(ide_drive_t *drive, 
int len, int ireason)
return 0;
else if (ireason == 2

Re: [git patches] IDE fixes

2007-12-24 Thread Bartlomiej Zolnierkiewicz

[ added Linus to Cc: ]

On Monday 24 December 2007, Bartlomiej Zolnierkiewicz wrote:
 
 cmd64x regression bugfix, few obvious ide-cd fixes from the redux patch
 peries and ide-cd MAINTAINERS entry update (Borislav, welcome on board!).
 
 Oh yes, I would forget...
 
 Merry Christmas!

Well, I forgot to send this to Linus instead...  :-)

 Linus, please pull from:
 
 master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/
 
 to receive the following updates:
 
  MAINTAINERS  |4 ++-
  drivers/ide/ide-cd.c |   66 +++--
  drivers/ide/ide-cd.h |3 +-
  drivers/ide/pci/cmd64x.c |4 +-
  drivers/ide/pci/cs5535.c |2 +-
  5 files changed, 42 insertions(+), 37 deletions(-)
 
 
 Bartlomiej Zolnierkiewicz (10):
   ide-cd: fix SAMSUNG CD-ROM SCR-3231 quirk
   ide-cd: fix ACER/AOpen 24X CDROM speed reporting on big-endian machines
   ide-cd: use ide_cd_release() in ide_cd_probe()
   ide-cd: fix error messages in cdrom_{read,write}_check_ireason()
   ide-cd: add missing 'ireason' masking to cdrom_write_intr()
   ide-cd: fix error messages in cdrom_write_intr()
   ide-cd: add error message for DMA error to cdrom_read_intr()
   ide-cd: fix error message in cdrom_pc_intr()
   ide-cd: fix 'ireason' reporting in cdrom_pc_intr()
   cmd64x: fix hwif-chipset setup
 
 Borislav Petkov (1):
   MAINTAINERS: update ide-cd entry
 
 Joe Perches (1):
   drivers/ide/: Spelling fixes
 
 
 diff --git a/MAINTAINERS b/MAINTAINERS
 index 3d567fd..79c711e 100644
 --- a/MAINTAINERS
 +++ b/MAINTAINERS
 @@ -1870,8 +1870,10 @@ T: quilt 
 kernel.org/pub/linux/kernel/people/bart/pata-2.6/
  S:   Maintained
  
  IDE/ATAPI CDROM DRIVER
 +P:   Borislav Petkov
 +M:   [EMAIL PROTECTED]
  L:   linux-ide@vger.kernel.org
 -S:   Unmaintained
 +S:   Maintained
  
  IDE/ATAPI FLOPPY DRIVERS
  P:   Paul Bristow
 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
 index 92ac658..c7d77f0 100644
 --- a/drivers/ide/ide-cd.c
 +++ b/drivers/ide/ide-cd.c
 @@ -1068,8 +1068,8 @@ int cdrom_read_check_ireason (ide_drive_t *drive, int 
 len, int ireason)
   return 0;
   else if (ireason == 0) {
   /* Whoops... The drive is expecting to receive data from us! */
 - printk(KERN_ERR %s: read_intr: Drive wants to transfer data 
 the 
 - wrong way!\n, drive-name);
 + printk(KERN_ERR %s: %s: wrong transfer direction!\n,
 + drive-name, __FUNCTION__);
  
   /* Throw some data at the drive so it doesn't hang
  and quit this request. */
 @@ -1086,8 +1086,8 @@ int cdrom_read_check_ireason (ide_drive_t *drive, int 
 len, int ireason)
   return 0;
   } else {
   /* Drive wants a command packet, or invalid ireason... */
 - printk(KERN_ERR %s: read_intr: bad interrupt reason %x\n, 
 drive-name,
 - ireason);
 + printk(KERN_ERR %s: %s: bad interrupt reason 0x%02x\n,
 + drive-name, __FUNCTION__, ireason);
   }
  
   cdrom_end_request(drive, 0);
 @@ -1112,8 +1112,11 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t 
 *drive)
*/
   if (dma) {
   info-dma = 0;
 - if ((dma_error = HWIF(drive)-ide_dma_end(drive)))
 + dma_error = HWIF(drive)-ide_dma_end(drive);
 + if (dma_error) {
 + printk(KERN_ERR %s: DMA read error\n, drive-name);
   ide_dma_off(drive);
 + }
   }
  
   if (cdrom_decode_status(drive, 0, stat))
 @@ -1443,7 +1446,7 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t 
 *drive)
   return ide_stopped;
  
   /* Read the interrupt reason and the transfer length. */
 - ireason = HWIF(drive)-INB(IDE_IREASON_REG);
 + ireason = HWIF(drive)-INB(IDE_IREASON_REG)  0x3;
   lowcyl  = HWIF(drive)-INB(IDE_BCOUNTL_REG);
   highcyl = HWIF(drive)-INB(IDE_BCOUNTH_REG);
  
 @@ -1484,7 +1487,7 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t 
 *drive)
   if (thislen  len) thislen = len;
  
   /* The drive wants to be written to. */
 - if ((ireason  3) == 0) {
 + if (ireason == 0) {
   if (!rq-data) {
   blk_dump_rq_flags(rq, cdrom_pc_intr, write);
   goto confused;
 @@ -1506,9 +1509,9 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t 
 *drive)
   }
  
   /* Same drill for reading. */
 - else if ((ireason  3) == 2) {
 + else if (ireason == 2) {
   if (!rq-data) {
 - blk_dump_rq_flags(rq, cdrom_pc_intr, write);
 + blk_dump_rq_flags(rq, cdrom_pc_intr, read);
   goto confused;
   }
   /* Transfer the data. */
 @@ -1632,8 +1635,8

[PATCH 1/2] ide: add ide_dump_identify() debug helper

2007-12-23 Thread Bartlomiej Zolnierkiewicz

* Add ide_dump_identify() debug helper for dumping raw identify data in
  the hdparm friendly format (== the identify data can be extracted from
  dmesg output and passed to hdparm --Istdin).

* Dump identify data in ide-probe.c::do_identify() if DEBUG is enabled.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-probe.c |4 
 include/linux/ide.h |5 +
 2 files changed, 9 insertions(+)

Index: b/drivers/ide/ide-probe.c
===
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -129,6 +129,10 @@ static inline void do_identify (ide_driv
 
drive-id_read = 1;
local_irq_enable();
+#ifdef DEBUG
+   printk(KERN_INFO %s: dumping identify data\n, drive-name);
+   ide_dump_identify((u8 *)id);
+#endif
ide_fix_driveid(id);
 
 #if defined (CONFIG_SCSI_EATA_PIO) || defined (CONFIG_SCSI_EATA)
Index: b/include/linux/ide.h
===
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1291,6 +1291,11 @@ extern struct bus_type ide_bus_type;
 #define ide_id_has_flush_cache_ext(id) \
(((id)-cfs_enable_2  0x2400) == 0x2400)
 
+static inline void ide_dump_identify(u8 *id)
+{
+   print_hex_dump(KERN_INFO, , DUMP_PREFIX_NONE, 16, 2, id, 512, 0);
+}
+
 static inline int hwif_to_node(ide_hwif_t *hwif)
 {
struct pci_dev *dev = hwif-pci_dev;
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] ide-{floppy,tape}: remove debug code for dumping identify data

2007-12-23 Thread Bartlomiej Zolnierkiewicz

IDE core supports dumping raw identify data in hdparm friendly format now
so verbose identify dumping in ide-{floppy,tape}.c device drivers (done iff
IDE{FLOPPY,TAPE}_DEBUG_INFO is defined to '1' and it is '0' by default)
is no longer nedeed.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-floppy.c |   50 ---
 drivers/ide/ide-tape.c   |   59 ---
 2 files changed, 109 deletions(-)

Index: b/drivers/ide/ide-floppy.c
===
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -1658,7 +1658,6 @@ static int idefloppy_identify_device (id
 {
struct idefloppy_id_gcw gcw;
 #if IDEFLOPPY_DEBUG_INFO
-   u16 mask,i;
char buffer[80];
 #endif /* IDEFLOPPY_DEBUG_INFO */
 
@@ -1705,55 +1704,6 @@ static int idefloppy_identify_device (id
default: sprintf(buffer, Reserved);break;
}
printk(KERN_INFO Command Packet Size: %s\n, buffer);
-   printk(KERN_INFO Model: %.40s\n,id-model);
-   printk(KERN_INFO Firmware Revision: %.8s\n,id-fw_rev);
-   printk(KERN_INFO Serial Number: %.20s\n,id-serial_no);
-   printk(KERN_INFO Write buffer size(?): %d bytes\n,id-buf_size*512);
-   printk(KERN_INFO DMA: %s,id-capability  0x01 ? Yes\n:No\n);
-   printk(KERN_INFO LBA: %s,id-capability  0x02 ? Yes\n:No\n);
-   printk(KERN_INFO IORDY can be disabled: %s,id-capability  0x04 ? 
Yes\n:No\n);
-   printk(KERN_INFO IORDY supported: %s,id-capability  0x08 ? 
Yes\n:Unknown\n);
-   printk(KERN_INFO ATAPI overlap supported: %s,id-capability  0x20 ? 
Yes\n:No\n);
-   printk(KERN_INFO PIO Cycle Timing Category: %d\n,id-tPIO);
-   printk(KERN_INFO DMA Cycle Timing Category: %d\n,id-tDMA);
-   printk(KERN_INFO Single Word DMA supported modes:\n);
-   for (i=0,mask=1;i8;i++,mask=mask  1) {
-   if (id-dma_1word  mask)
-   printk(KERN_INFOMode %d%s\n, i,
-   (id-dma_1word  (mask  8)) ?  (active) : );
-   }
-   printk(KERN_INFO Multi Word DMA supported modes:\n);
-   for (i=0,mask=1;i8;i++,mask=mask  1) {
-   if (id-dma_mword  mask)
-   printk(KERN_INFOMode %d%s\n, i,
-   (id-dma_mword  (mask  8)) ?  (active) : );
-   }
-   if (id-field_valid  0x0002) {
-   printk(KERN_INFO Enhanced PIO Modes: %s\n,
-   id-eide_pio_modes  1 ? Mode 3:None);
-   if (id-eide_dma_min == 0)
-   sprintf(buffer, Not supported);
-   else
-   sprintf(buffer, %d ns,id-eide_dma_min);
-   printk(KERN_INFO Minimum Multi-word DMA cycle per word: %s\n, 
buffer);
-   if (id-eide_dma_time == 0)
-   sprintf(buffer, Not supported);
-   else
-   sprintf(buffer, %d ns,id-eide_dma_time);
-   printk(KERN_INFO Manufacturer\'s Recommended Multi-word cycle: 
%s\n, buffer);
-   if (id-eide_pio == 0)
-   sprintf(buffer, Not supported);
-   else
-   sprintf(buffer, %d ns,id-eide_pio);
-   printk(KERN_INFO Minimum PIO cycle without IORDY: %s\n,
-   buffer);
-   if (id-eide_pio_iordy == 0)
-   sprintf(buffer, Not supported);
-   else
-   sprintf(buffer, %d ns,id-eide_pio_iordy);
-   printk(KERN_INFO Minimum PIO cycle with IORDY: %s\n, buffer);
-   } else
-   printk(KERN_INFO According to the device, fields 64-70 are not 
valid.\n);
 #endif /* IDEFLOPPY_DEBUG_INFO */
 
if (gcw.protocol != 2)
Index: b/drivers/ide/ide-tape.c
===
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -4291,9 +4291,6 @@ static int idetape_identify_device (ide_
 {
struct idetape_id_gcw gcw;
struct hd_driveid *id = drive-id;
-#if IDETAPE_DEBUG_INFO
-   unsigned short mask,i;
-#endif /* IDETAPE_DEBUG_INFO */
 
if (drive-id_read == 0)
return 1;
@@ -4333,62 +4330,6 @@ static int idetape_identify_device (ide_
case 1: printk(16 bytes\n);break;
default: printk(Reserved\n);break;
}
-   printk(KERN_INFO ide-tape: Model: %.40s\n,id-model);
-   printk(KERN_INFO ide-tape: Firmware Revision: %.8s\n,id-fw_rev);
-   printk(KERN_INFO ide-tape: Serial Number: %.20s\n,id-serial_no);
-   printk(KERN_INFO ide-tape: Write buffer size: %d 
bytes\n,id-buf_size*512);
-   printk(KERN_INFO ide-tape: DMA: %s,id-capability  0x01 ? 
Yes\n:No\n);
-   printk(KERN_INFO ide-tape: LBA: %s,id-capability  0x02 ? 
Yes\n:No\n);
-   printk(KERN_INFO ide-tape: IORDY can be disabled: %s,id-capability

Re: [PATCH 00/63] ide-cd: redux

2007-12-23 Thread Bartlomiej Zolnierkiewicz
On Sunday 23 December 2007, Borislav Petkov wrote:
 On Fri, Dec 21, 2007 at 08:57:49PM +0100, Bartlomiej Zolnierkiewicz wrote:
  On Thursday 20 December 2007, Borislav Petkov wrote:
   On Thu, Dec 20, 2007 at 01:48:49AM +0100, Bartlomiej Zolnierkiewicz wrote:
   Hi Bart,
   Hi all,
   
PS ide-cd Maintainer position is still open...
   i'd like to take that position if nobody objects. I've done some work 
   around the
   kernel here and there and i think its time for me to get serious.
  
  Great!
  
  Please send me a patch for MAINTAINERS file updating ide-cd entry.
 
 Sure, there it is:
 
 ---
 
 Reopen ide-cd for maintainership.
 
 Signed-off-by: Borislav Petkov [EMAIL PROTECTED]

applied, thanks
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 00/63] ide-cd: redux

2007-12-21 Thread Bartlomiej Zolnierkiewicz
On Thursday 20 December 2007, Borislav Petkov wrote:
 On Thu, Dec 20, 2007 at 01:48:49AM +0100, Bartlomiej Zolnierkiewicz wrote:
 Hi Bart,
 Hi all,
 
  PS ide-cd Maintainer position is still open...
 i'd like to take that position if nobody objects. I've done some work around 
 the
 kernel here and there and i think its time for me to get serious.

Great!

Please send me a patch for MAINTAINERS file updating ide-cd entry.

Thanks,
Bart
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 00/63] ide-cd: redux

2007-12-21 Thread Bartlomiej Zolnierkiewicz
On Thursday 20 December 2007, Phillip Susi wrote:
 Bartlomiej Zolnierkiewicz wrote:
  Hi,
  
  This patch series is a major rework of the ide-cd driver.
 
 Hi, in the future could you please post big patchbombs like this as 
 replies to the first one so they fold nicely into one thread?  IIRC, 
 git-send-email does this by default now.

Sure, sorry for forgetting about it this time.

Bart
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/63] ide-cd: redux

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Hi,

This patch series is a major rework of the ide-cd driver.

The motivations behind it are twofold:

* ide-cd is still in use but because it has been out of luck for maintainers
  lately the code become quite hard to debug and maintain - this puts it back
  into the shape

* aid efforts of developers (Tejun and Alan) who are working on libata ATAPI
  support - it should be now a lot easier to spot the various quirks for
  weird/buggy devices, differences between sr/ide-cd etc.

This patch series contains only safe/straightforward changes (some risky
ones are scheduled for later time) and should be fully bisectable.


Changes:

* unify _four_ slightly different IRQ handlers into one

* re-organize handling of quirky-devices (group quirks scattered
  all over the driver in the table and handle them using flags)

* move code for verbose error logging to ide-cd_verbose.c (this
  code doesn't have any IDE subsystem dependencies so if desired
  it can be easily converted into generic IDE/libata library)

* move code handling cdrom.c IOCTLs to ide-cd_ioctl.c

* remove duplicated/dead code ( 700 LOC gone)

* move historical changelog to Documentation/ide/

* fix few bugs discovered during rewrite


diffstat:

 Documentation/ide/ChangeLog.ide-cd.1994-2004 |  268 ++
 drivers/cdrom/cdrom.c|6
 drivers/ide/Kconfig  |9
 drivers/ide/Makefile |6
 drivers/ide/ide-cd.c | 3236 +--
 drivers/ide/ide-cd.h |  737 --
 drivers/ide/ide-cd_ioctl.c   |  265 ++
 drivers/ide/ide-cd_verbose.c |  359 ++
 include/linux/cdrom.h|   14
 9 files changed, 2095 insertions(+), 2805 deletions(-)


PS ide-cd Maintainer position is still open...

Thanks,
Bart
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/63] ide-cd: fix ACER/AOpen 24X CDROM speed reporting on big-endian machines

2007-12-19 Thread Bartlomiej Zolnierkiewicz

* Fix ACER/AOpen 24X CDROM speed reporting on big-endian machines
  by adding missing le16_to_cpu() calls.

While at it:
* Replace ntohs() by be16_to_cpu().

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -2682,14 +2682,14 @@ void ide_cdrom_update_speed (ide_drive_t
if (!drive-id-model[0] 
!strncmp(drive-id-fw_rev, 241N, 4)) {
CDROM_STATE_FLAGS(drive)-current_speed  =
-   (((unsigned int)cap-curspeed) + (176/2)) / 176;
+   (le16_to_cpu(cap-curspeed) + (176/2)) / 176;
CDROM_CONFIG_FLAGS(drive)-max_speed =
-   (((unsigned int)cap-maxspeed) + (176/2)) / 176;
+   (le16_to_cpu(cap-maxspeed) + (176/2)) / 176;
} else {
CDROM_STATE_FLAGS(drive)-current_speed  =
-   (ntohs(cap-curspeed) + (176/2)) / 176;
+   (be16_to_cpu(cap-curspeed) + (176/2)) / 176;
CDROM_CONFIG_FLAGS(drive)-max_speed =
-   (ntohs(cap-maxspeed) + (176/2)) / 176;
+   (be16_to_cpu(cap-maxspeed) + (176/2)) / 176;
}
 }
 
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/63] ide-cd: fix SAMSUNG CD-ROM SCR-3231 quirk

2007-12-19 Thread Bartlomiej Zolnierkiewicz

cdi-mask is cleared by ide_cdrom_register() which is called after the quirk.

Fix it by adding new -no_speed_select flag to struct ide_cd_config_flags
and using it in ide_cdrom_register() to set CDC_SELECT_SPEED flag.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |5 -
 drivers/ide/ide-cd.h |3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -2903,6 +2903,9 @@ static int ide_cdrom_register (ide_drive
if (!CDROM_CONFIG_FLAGS(drive)-ram)
devinfo-mask |= CDC_RAM;
 
+   if (CDROM_CONFIG_FLAGS(drive)-no_speed_select)
+   devinfo-mask |= CDC_SELECT_SPEED;
+
devinfo-disk = info-disk;
return register_cdrom(devinfo);
 }
@@ -3155,7 +3158,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
CDROM_CONFIG_FLAGS(drive)-limit_nframes = 1;
/* the 3231 model does not support the SET_CD_SPEED command */
else if (!strcmp(drive-id-model, SAMSUNG CD-ROM SCR-3231))
-   cdi-mask |= CDC_SELECT_SPEED;
+   CDROM_CONFIG_FLAGS(drive)-no_speed_select = 1;
 
 #if ! STANDARD_ATAPI
/* by default Sanyo 3 CD changer support is turned off and
Index: b/drivers/ide/ide-cd.h
===
--- a/drivers/ide/ide-cd.h
+++ b/drivers/ide/ide-cd.h
@@ -91,7 +91,8 @@ struct ide_cd_config_flags {
__u8 close_tray : 1; /* can close the tray */
__u8 writing: 1; /* pseudo write in progress */
__u8 mo_drive   : 1; /* drive is an MO device */
-   __u8 reserved   : 2;
+   __u8 no_speed_select: 1; /* SET_CD_SPEED command is unsupported. */
+   __u8 reserved   : 1;
byte max_speed;  /* Max speed of the drive */
 };
 #define CDROM_CONFIG_FLAGS(drive) struct cdrom_info 
*)(drive-driver_data))-config_flags))
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/63] ide-cd: use ide_cd_release() in ide_cd_probe()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Use ide_cd_release() to do the cleanup if ide_cdrom_setup() fails.

It fixes:
- the default drive-dsc_overlap value not being restored
- the default drive-queue's prep_rq_fn not being restored
- struct gendisk 'g' not being freed
- wrong function name being reported on unregister_cdrom() error

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-164 bytes
 drivers/ide/ide-cd.c |9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -3501,15 +3501,8 @@ static int ide_cd_probe(ide_drive_t *dri
g-driverfs_dev = drive-gendev;
g-flags = GENHD_FL_CD | GENHD_FL_REMOVABLE;
if (ide_cdrom_setup(drive)) {
-   struct cdrom_device_info *devinfo = info-devinfo;
ide_proc_unregister_driver(drive, ide_cdrom_driver);
-   kfree(info-buffer);
-   kfree(info-toc);
-   kfree(info-changer_info);
-   if (devinfo-handle == drive  unregister_cdrom(devinfo))
-   printk (KERN_ERR %s: ide_cdrom_cleanup failed to 
unregister device from the cdrom 
driver.\n, drive-name);
-   kfree(info);
-   drive-driver_data = NULL;
+   ide_cd_release(info-kref);
goto failed;
}
 
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/63] ide-cd: fix error messages in cdrom_{read,write}_check_ireason()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1062,8 +1062,8 @@ int cdrom_read_check_ireason (ide_drive_
return 0;
else if (ireason == 0) {
/* Whoops... The drive is expecting to receive data from us! */
-   printk(KERN_ERR %s: read_intr: Drive wants to transfer data 
the 
-   wrong way!\n, drive-name);
+   printk(KERN_ERR %s: %s: wrong transfer direction!\n,
+   drive-name, __FUNCTION__);
 
/* Throw some data at the drive so it doesn't hang
   and quit this request. */
@@ -1080,8 +1080,8 @@ int cdrom_read_check_ireason (ide_drive_
return 0;
} else {
/* Drive wants a command packet, or invalid ireason... */
-   printk(KERN_ERR %s: read_intr: bad interrupt reason %x\n, 
drive-name,
-   ireason);
+   printk(KERN_ERR %s: %s: bad interrupt reason 0x%02x\n,
+   drive-name, __FUNCTION__, ireason);
}
 
cdrom_end_request(drive, 0);
@@ -1626,8 +1626,8 @@ static int cdrom_write_check_ireason(ide
return 0;
else if (ireason == 2) {
/* Whoops... The drive wants to send data. */
-   printk(KERN_ERR %s: write_intr: wrong transfer direction!\n,
-   drive-name);
+   printk(KERN_ERR %s: %s: wrong transfer direction!\n,
+   drive-name, __FUNCTION__);
 
while (len  0) {
int dum = 0;
@@ -1636,8 +1636,8 @@ static int cdrom_write_check_ireason(ide
}
} else {
/* Drive wants a command packet, or invalid ireason... */
-   printk(KERN_ERR %s: write_intr: bad interrupt reason %x\n,
-   drive-name, ireason);
+   printk(KERN_ERR %s: %s: bad interrupt reason 0x%02x\n,
+   drive-name, __FUNCTION__, ireason);
}
 
cdrom_end_request(drive, 0);
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/63] ide-cd: fix error message in cdrom_pc_intr()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1505,7 +1505,7 @@ static ide_startstop_t cdrom_pc_intr (id
/* Same drill for reading. */
else if ((ireason  3) == 2) {
if (!rq-data) {
-   blk_dump_rq_flags(rq, cdrom_pc_intr, write);
+   blk_dump_rq_flags(rq, cdrom_pc_intr, read);
goto confused;
}
/* Transfer the data. */
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/63] ide-cd: use xfer_func_t in cdrom_pc_intr()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Unify writing and reading handling in cdrom_pc_intr() using xfer_func_t.

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |   47 +--
 1 file changed, 17 insertions(+), 30 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1005,6 +1005,8 @@ static ide_startstop_t cdrom_transfer_pa
  * Block read functions.
  */
 
+typedef void (xfer_func_t)(ide_drive_t *, void *, u32);
+
 /*
  * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector
  * buffer.  Once the first sector is added, any subsequent sectors are
@@ -1430,10 +1432,10 @@ static ide_startstop_t cdrom_start_read 
 /* Interrupt routine for packet command completion. */
 static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
 {
-   int ireason, len, thislen;
struct request *rq = HWGROUP(drive)-rq;
+   xfer_func_t *xferfunc = NULL;
+   int stat, ireason, len, thislen, write;
u8 lowcyl = 0, highcyl = 0;
-   int stat;
 
/* Check for errors. */
if (cdrom_decode_status(drive, 0, stat))
@@ -1478,44 +1480,31 @@ static ide_startstop_t cdrom_pc_intr (id
 
/* Figure out how much data to transfer. */
thislen = rq-data_len;
-   if (thislen  len) thislen = len;
+   if (thislen  len)
+   thislen = len;
 
-   /* The drive wants to be written to. */
if (ireason == 0) {
-   if (!rq-data) {
-   blk_dump_rq_flags(rq, cdrom_pc_intr, write);
-   goto confused;
-   }
-   /* Transfer the data. */
-   HWIF(drive)-atapi_output_bytes(drive, rq-data, thislen);
-
-   /* If we haven't moved enough data to satisfy the drive,
-  add some padding. */
-   while (len  thislen) {
-   int dum = 0;
-   HWIF(drive)-atapi_output_bytes(drive, dum, 
sizeof(dum));
-   len -= sizeof(dum);
-   }
-
-   /* Keep count of how much data we've moved. */
-   rq-data += thislen;
-   rq-data_len -= thislen;
+   write = 1;
+   xferfunc = HWIF(drive)-atapi_output_bytes;
+   } else if (ireason == 2) {
+   write = 0;
+   xferfunc = HWIF(drive)-atapi_input_bytes;
}
 
-   /* Same drill for reading. */
-   else if (ireason == 2) {
+   if (xferfunc) {
if (!rq-data) {
-   blk_dump_rq_flags(rq, cdrom_pc_intr, read);
+   blk_dump_rq_flags(rq, write ? cdrom_pc_intr, write
+   : cdrom_pc_intr, read);
goto confused;
}
/* Transfer the data. */
-   HWIF(drive)-atapi_input_bytes(drive, rq-data, thislen);
+   xferfunc(drive, rq-data, thislen);
 
/* If we haven't moved enough data to satisfy the drive,
   add some padding. */
while (len  thislen) {
int dum = 0;
-   HWIF(drive)-atapi_input_bytes(drive, dum, 
sizeof(dum));
+   xferfunc(drive, dum, sizeof(dum));
len -= sizeof(dum);
}
 
@@ -1523,7 +1512,7 @@ static ide_startstop_t cdrom_pc_intr (id
rq-data += thislen;
rq-data_len -= thislen;
 
-   if (blk_sense_request(rq))
+   if (write  blk_sense_request(rq))
rq-sense_len += thislen;
} else {
 confused:
@@ -1647,8 +1636,6 @@ static int cdrom_write_check_ireason(ide
return 1;
 }
 
-typedef void (xfer_func_t)(ide_drive_t *, void *, u32);
-
 /*
  * best way to deal with dma that is not sector aligned right now... note
  * that in this path we are not using -data or -buffer at all. this irs
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/63] ide-cd: fix 'ireason' reporting in cdrom_pc_intr()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Mask 'ireason' variable so only the valid interrupt reason bits
will be reported on drive appears confused error.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1440,7 +1440,7 @@ static ide_startstop_t cdrom_pc_intr (id
return ide_stopped;
 
/* Read the interrupt reason and the transfer length. */
-   ireason = HWIF(drive)-INB(IDE_IREASON_REG);
+   ireason = HWIF(drive)-INB(IDE_IREASON_REG)  0x3;
lowcyl  = HWIF(drive)-INB(IDE_BCOUNTL_REG);
highcyl = HWIF(drive)-INB(IDE_BCOUNTH_REG);
 
@@ -1481,7 +1481,7 @@ static ide_startstop_t cdrom_pc_intr (id
if (thislen  len) thislen = len;
 
/* The drive wants to be written to. */
-   if ((ireason  3) == 0) {
+   if (ireason == 0) {
if (!rq-data) {
blk_dump_rq_flags(rq, cdrom_pc_intr, write);
goto confused;
@@ -1503,7 +1503,7 @@ static ide_startstop_t cdrom_pc_intr (id
}
 
/* Same drill for reading. */
-   else if ((ireason  3) == 2) {
+   else if (ireason == 2) {
if (!rq-data) {
blk_dump_rq_flags(rq, cdrom_pc_intr, read);
goto confused;
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/63] ide-cd: fix DMA error handling in cdrom_newpc_intr()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Make cdrom_newpc_intr() match cdrom_{read,write}_intr() w.r.t.
handling DMA errors:

* disable DMA before cdrom_decode_status() call

* log the device name and the type of the request (read/write)

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1663,6 +1663,11 @@ static ide_startstop_t cdrom_newpc_intr(
if (dma) {
info-dma = 0;
dma_error = HWIF(drive)-ide_dma_end(drive);
+   if (dma_error) {
+   printk(KERN_ERR %s: DMA %s error\n, drive-name,
+   rq_data_dir(rq) ? write : read);
+   ide_dma_off(drive);
+   }
}
 
if (cdrom_decode_status(drive, 0, stat))
@@ -1672,11 +1677,8 @@ static ide_startstop_t cdrom_newpc_intr(
 * using dma, transfer is complete now
 */
if (dma) {
-   if (dma_error) {
-   printk(KERN_ERR ide-cd: dma error\n);
-   ide_dma_off(drive);
+   if (dma_error)
return ide_error(drive, dma error, stat);
-   }
 
end_that_request_chunk(rq, 1, rq-data_len);
rq-data_len = 0;
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/63] ide-cd: move historical changelog to Documentation/ide/ChangeLog.ide-cd.1994-2004

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 Documentation/ide/ChangeLog.ide-cd.1994-2004 |  268 ++
 drivers/ide/ide-cd.c |  274 ---
 2 files changed, 272 insertions(+), 270 deletions(-)

Index: b/Documentation/ide/ChangeLog.ide-cd.1994-2004
===
--- /dev/null
+++ b/Documentation/ide/ChangeLog.ide-cd.1994-2004
@@ -0,0 +1,268 @@
+/*
+ * 1.00  Oct 31, 1994 -- Initial version.
+ * 1.01  Nov  2, 1994 -- Fixed problem with starting request in
+ *   cdrom_check_status.
+ * 1.03  Nov 25, 1994 -- leaving unmask_intr[] as a user-setting (as for disks)
+ * (from mlord)   -- minor changes to cdrom_setup()
+ *-- renamed ide_dev_s to ide_drive_t, enable irq on 
command
+ * 2.00  Nov 27, 1994 -- Generalize packet command interface;
+ *   add audio ioctls.
+ * 2.01  Dec  3, 1994 -- Rework packet command interface to handle devices
+ *   which send an interrupt when ready for a command.
+ * 2.02  Dec 11, 1994 -- Cache the TOC in the driver.
+ *   Don't use SCMD_PLAYAUDIO_TI; it's not included
+ *   in the current version of ATAPI.
+ *   Try to use LBA instead of track or MSF addressing
+ *   when possible.
+ *   Don't wait for READY_STAT.
+ * 2.03  Jan 10, 1995 -- Rewrite block read routines to handle block sizes
+ *   other than 2k and to move multiple sectors in a
+ *   single transaction.
+ * 2.04  Apr 21, 1995 -- Add work-around for Creative Labs CD220E drives.
+ *   Thanks to Nick Saw [EMAIL PROTECTED] for
+ *   help in figuring this out.  Ditto for Acer and
+ *   Aztech drives, which seem to have the same problem.
+ * 2.04b May 30, 1995 -- Fix to match changes in ide.c version 3.16 -ml
+ * 2.05  Jun  8, 1995 -- Don't attempt to retry after an illegal request
+ *or data protect error.
+ *   Use HWIF and DEV_HWIF macros as in ide.c.
+ *   Always try to do a request_sense after
+ *a failed command.
+ *   Include an option to give textual descriptions
+ *of ATAPI errors.
+ *   Fix a bug in handling the sector cache which
+ *showed up if the drive returned data in 512 byte
+ *blocks (like Pioneer drives).  Thanks to
+ *Richard Hirst [EMAIL PROTECTED] for diagnosing 
this.
+ *   Properly supply the page number field in the
+ *MODE_SELECT command.
+ *   PLAYAUDIO12 is broken on the Aztech; work around it.
+ * 2.05x Aug 11, 1995 -- lots of data structure renaming/restructuring in ide.c
+ *   (my apologies to Scott, but now ide-cd.c is 
independent)
+ * 3.00  Aug 22, 1995 -- Implement CDROMMULTISESSION ioctl.
+ *   Implement CDROMREADAUDIO ioctl (UNTESTED).
+ *   Use input_ide_data() and output_ide_data().
+ *   Add door locking.
+ *   Fix usage count leak in cdrom_open, which happened
+ *when a read-write mount was attempted.
+ *   Try to load the disk on open.
+ *   Implement CDROMEJECT_SW ioctl (off by default).
+ *   Read total cdrom capacity during open.
+ *   Rearrange logic in cdrom_decode_status.  Issue
+ *request sense commands for failed packet commands
+ *from here instead of from cdrom_queue_packet_command.
+ *Fix a race condition in retrieving error information.
+ *   Suppress printing normal unit attention errors and
+ *some drive not ready errors.
+ *   Implement CDROMVOLREAD ioctl.
+ *   Implement CDROMREADMODE1/2 ioctls.
+ *   Fix race condition in setting up interrupt handlers
+ *when the `serialize' option is used.
+ * 3.01  Sep  2, 1995 -- Fix ordering of reenabling interrupts in
+ *cdrom_queue_request.
+ *   Another try at using ide_[input,output]_data.
+ * 3.02  Sep 16, 1995 -- Stick total disk capacity in partition table as well.
+ *   Make VERBOSE_IDE_CD_ERRORS dump failed command again.
+ *   Dump out more information for ILLEGAL REQUEST errs.
+ *   Fix handling of errors occurring before the
+ *packet command is transferred.
+ *   Fix transfers

[PATCH 16/63] ide-cd: remove stale cdrom_transfer_packet_command() comment

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |4 
 1 file changed, 4 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -684,10 +684,6 @@ static ide_startstop_t cdrom_start_packe
by cdrom_start_packet_command.
HANDLER is the interrupt handler to call when the command completes
or there's data ready. */
-/*
- * changed 5 parameters to 3 for dvd-ram
- * struct packet_command *pc; now packet_command_t *pc;
- */
 #define ATAPI_MIN_CDB_BYTES 12
 static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
  struct request *rq,
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/63] ide-cd: remove dead code from cdrom_pc_intr()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |7 ---
 1 file changed, 7 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1201,13 +1201,6 @@ static ide_startstop_t cdrom_pc_intr (id
if (rq-data_len == 0)
cdrom_end_request(drive, 1);
else {
-   /* Comment this out, because this always happens 
-  right after a reset occurs, and it is annoying to 
-  always print expected stuff.  */
-   /*
-   printk (%s: cdrom_pc_intr: data underrun %d\n,
-   drive-name, pc-buflen);
-   */
rq-cmd_flags |= REQ_FAILED;
cdrom_end_request(drive, 0);
}
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 19/63] ide-cd: remove unused struct atapi_cdrom_subchnl

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.h |   32 
 1 file changed, 32 deletions(-)

Index: b/drivers/ide/ide-cd.h
===
--- a/drivers/ide/ide-cd.h
+++ b/drivers/ide/ide-cd.h
@@ -145,38 +145,6 @@ struct atapi_toc {
  /* One extra for the leadout. */
 };
 
-
-/* This structure is annoyingly close to, but not identical with,
-   the cdrom_subchnl structure from cdrom.h. */
-struct atapi_cdrom_subchnl {
-   u_char  acdsc_reserved;
-   u_char  acdsc_audiostatus;
-   u_short acdsc_length;
-   u_char  acdsc_format;
-
-#if defined(__BIG_ENDIAN_BITFIELD)
-   u_char  acdsc_ctrl: 4;
-   u_char  acdsc_adr:  4;
-#elif defined(__LITTLE_ENDIAN_BITFIELD)
-   u_char  acdsc_adr:  4;
-   u_char  acdsc_ctrl: 4;
-#else
-#error Please fix asm/byteorder.h
-#endif
-   u_char  acdsc_trk;
-   u_char  acdsc_ind;
-   union {
-   struct atapi_msf msf;
-   int lba;
-   } acdsc_absaddr;
-   union {
-   struct atapi_msf msf;
-   int lba;
-   } acdsc_reladdr;
-};
-
-
-
 /* This should probably go into cdrom.h along with the other
  * generic stuff now in the Mt. Fuji spec.
  */
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/63] ide-cd: fix missing data handling in cdrom_pc_intr()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

If drive still wants to transfer the data we need to pad the transfer
instead of just finishing the request.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1500,9 +1500,11 @@ static ide_startstop_t cdrom_pc_intr (id
 
if (xferfunc) {
if (!rq-data) {
+   printk(KERN_ERR %s: confused, missing data\n,
+   drive-name);
blk_dump_rq_flags(rq, write ? cdrom_pc_intr, write
: cdrom_pc_intr, read);
-   goto confused;
+   goto pad;
}
/* Transfer the data. */
xferfunc(drive, rq-data, thislen);
@@ -1515,7 +1517,6 @@ static ide_startstop_t cdrom_pc_intr (id
if (write  blk_sense_request(rq))
rq-sense_len += thislen;
} else {
-confused:
printk (KERN_ERR %s: cdrom_pc_intr: The drive 
appears confused (ireason = 0x%02x). 
Trying to recover by ending request.\n,
@@ -1524,7 +1525,7 @@ confused:
cdrom_end_request(drive, 0);
return ide_stopped;
}
-
+pad:
/*
 * If we haven't moved enough data to satisfy the drive,
 * add some padding.
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 20/63] ide-cd: remove needless zeroing of 'info' fields from ide_cdrom_setup()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

ide_cd_probe() zeroes 'info' prior to calling ide_cdrom_setup() so there
is no need to explicitly zero 'info' fields in the latter function.

Ditto for fields of CDROM_STATE_FLAGS(), CDROM_CONFIG_FLAGS() and 'cdi'
(all are embedded in 'info').

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-254 bytes
 drivers/ide/ide-cd.c |   44 +++-
 1 file changed, 7 insertions(+), 37 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -2844,30 +2844,16 @@ int ide_cdrom_setup (ide_drive_t *drive)
drive-special.all  = 0;
 
CDROM_STATE_FLAGS(drive)-media_changed = 1;
-   CDROM_STATE_FLAGS(drive)-toc_valid = 0;
-   CDROM_STATE_FLAGS(drive)-door_locked   = 0;
 
 #if NO_DOOR_LOCKING
CDROM_CONFIG_FLAGS(drive)-no_doorlock = 1;
-#else
-   CDROM_CONFIG_FLAGS(drive)-no_doorlock = 0;
 #endif
-
-   CDROM_CONFIG_FLAGS(drive)-drq_interrupt = ((drive-id-config  
0x0060) == 0x20);
-   CDROM_CONFIG_FLAGS(drive)-is_changer = 0;
-   CDROM_CONFIG_FLAGS(drive)-cd_r = 0;
-   CDROM_CONFIG_FLAGS(drive)-cd_rw = 0;
-   CDROM_CONFIG_FLAGS(drive)-test_write = 0;
-   CDROM_CONFIG_FLAGS(drive)-dvd = 0;
-   CDROM_CONFIG_FLAGS(drive)-dvd_r = 0;
-   CDROM_CONFIG_FLAGS(drive)-dvd_ram = 0;
+   if ((drive-id-config  0x0060) == 0x20)
+   CDROM_CONFIG_FLAGS(drive)-drq_interrupt = 1;
CDROM_CONFIG_FLAGS(drive)-no_eject = 1;
-   CDROM_CONFIG_FLAGS(drive)-supp_disc_present = 0;
-   CDROM_CONFIG_FLAGS(drive)-audio_play = 0;
CDROM_CONFIG_FLAGS(drive)-close_tray = 1;
-   
+
/* limit transfer size per interrupt. */
-   CDROM_CONFIG_FLAGS(drive)-limit_nframes = 0;
/* a testament to the nice quality of Samsung drives... */
if (!strcmp(drive-id-model, SAMSUNG CD-ROM SCR-2430))
CDROM_CONFIG_FLAGS(drive)-limit_nframes = 1;
@@ -2878,16 +2864,6 @@ int ide_cdrom_setup (ide_drive_t *drive)
CDROM_CONFIG_FLAGS(drive)-no_speed_select = 1;
 
 #if ! STANDARD_ATAPI
-   /* by default Sanyo 3 CD changer support is turned off and
-   ATAPI Rev 2.2+ standard support for CD changers is used */
-   cdi-sanyo_slot = 0;
-
-   CDROM_CONFIG_FLAGS(drive)-nec260 = 0;
-   CDROM_CONFIG_FLAGS(drive)-toctracks_as_bcd = 0;
-   CDROM_CONFIG_FLAGS(drive)-tocaddr_as_bcd = 0;
-   CDROM_CONFIG_FLAGS(drive)-playmsf_as_bcd = 0;
-   CDROM_CONFIG_FLAGS(drive)-subchan_as_bcd = 0;
-
if (strcmp (drive-id-model, V003S0DS) == 0 
drive-id-fw_rev[4] == '1' 
drive-id-fw_rev[6] = '2') {
@@ -2921,8 +2897,10 @@ int ide_cdrom_setup (ide_drive_t *drive)
CDROM_CONFIG_FLAGS(drive)-playmsf_as_bcd = 1;
CDROM_CONFIG_FLAGS(drive)-subchan_as_bcd = 1;
}
-/* Sanyo 3 CD changer uses a non-standard command
-   for CD changing */
+   /*
+* Sanyo 3 CD changer uses a non-standard command for CD changing
+* (by default standard ATAPI support for CD changers is used).
+*/
 else if ((strcmp(drive-id-model, CD-ROM CDR-C3 G) == 0) ||
  (strcmp(drive-id-model, CD-ROM CDR-C3G) == 0) ||
  (strcmp(drive-id-model, CD-ROM CDR_C36) == 0)) {
@@ -2931,14 +2909,6 @@ int ide_cdrom_setup (ide_drive_t *drive)
 }
 #endif /* not STANDARD_ATAPI */
 
-   info-toc   = NULL;
-   info-buffer= NULL;
-   info-sector_buffered   = 0;
-   info-nsectors_buffered = 0;
-   info-changer_info  = NULL;
-   info-last_block= 0;
-   info-start_seek= 0;
-
nslots = ide_cdrom_probe_capabilities (drive);
 
/*
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 21/63] ide-cd: remove unused and write-only struct ide_cd_config_flags fields

2007-12-19 Thread Bartlomiej Zolnierkiewicz

unused fields:
* -writing
* -reserved

write-only fields:
* -playmsf_as_bcd
* -subchan_as_bcd
* -test_write
* -supp_disc_present

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-120 bytes
 drivers/ide/ide-cd.c |   18 ++
 drivers/ide/ide-cd.h |7 ---
 2 files changed, 2 insertions(+), 23 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -2672,8 +2672,6 @@ int ide_cdrom_probe_capabilities (ide_dr
CDROM_CONFIG_FLAGS(drive)-cd_rw = 1;
CDROM_CONFIG_FLAGS(drive)-ram = 1;
}
-   if (cap.test_write)
-   CDROM_CONFIG_FLAGS(drive)-test_write = 1;
if (cap.dvd_ram_read || cap.dvd_r_read || cap.dvd_rom)
CDROM_CONFIG_FLAGS(drive)-dvd = 1;
if (cap.dvd_ram_write) {
@@ -2706,10 +2704,9 @@ int ide_cdrom_probe_capabilities (ide_dr
 #endif /* not STANDARD_ATAPI */
if (cap.mechtype == mechtype_individual_changer ||
cap.mechtype == mechtype_cartridge_changer) {
-   if ((nslots = cdrom_number_of_slots(cdi))  1) {
+   nslots = cdrom_number_of_slots(cdi);
+   if (nslots  1)
CDROM_CONFIG_FLAGS(drive)-is_changer = 1;
-   CDROM_CONFIG_FLAGS(drive)-supp_disc_present = 1;
-   }
}
 
ide_cdrom_update_speed(drive, cap);
@@ -2871,10 +2868,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
   Some versions of this drive like to talk BCD. */
CDROM_CONFIG_FLAGS(drive)-toctracks_as_bcd = 1;
CDROM_CONFIG_FLAGS(drive)-tocaddr_as_bcd = 1;
-   CDROM_CONFIG_FLAGS(drive)-playmsf_as_bcd = 1;
-   CDROM_CONFIG_FLAGS(drive)-subchan_as_bcd = 1;
}
-
else if (strcmp (drive-id-model, V006E0DS) == 0 
drive-id-fw_rev[4] == '1' 
drive-id-fw_rev[6] = '2') {
@@ -2887,16 +2881,8 @@ int ide_cdrom_setup (ide_drive_t *drive)
   This drive was released before the 1.2 version
   of the spec. */
CDROM_CONFIG_FLAGS(drive)-tocaddr_as_bcd = 1;
-   CDROM_CONFIG_FLAGS(drive)-playmsf_as_bcd = 1;
-   CDROM_CONFIG_FLAGS(drive)-subchan_as_bcd = 1;
CDROM_CONFIG_FLAGS(drive)-nec260 = 1;
}
-   else if (strcmp(drive-id-model, WEARNES CDD-120) == 0 
-strncmp(drive-id-fw_rev, A1.1, 4) == 0) { /* FIXME */
-   /* Wearnes */
-   CDROM_CONFIG_FLAGS(drive)-playmsf_as_bcd = 1;
-   CDROM_CONFIG_FLAGS(drive)-subchan_as_bcd = 1;
-   }
/*
 * Sanyo 3 CD changer uses a non-standard command for CD changing
 * (by default standard ATAPI support for CD changers is used).
Index: b/drivers/ide/ide-cd.h
===
--- a/drivers/ide/ide-cd.h
+++ b/drivers/ide/ide-cd.h
@@ -59,10 +59,8 @@ struct ide_cd_config_flags {
__u8 no_doorlock: 1; /* Drive cannot lock the door. */
__u8 no_eject   : 1; /* Drive cannot eject the disc. */
__u8 nec260 : 1; /* Drive is a pre-1.2 NEC 260 drive. */
-   __u8 playmsf_as_bcd : 1; /* PLAYMSF command takes BCD args. */
__u8 tocaddr_as_bcd : 1; /* TOC addresses are in BCD. */
__u8 toctracks_as_bcd   : 1; /* TOC track numbers are in BCD. */
-   __u8 subchan_as_bcd : 1; /* Subchannel info is in BCD. */
__u8 is_changer : 1; /* Drive is a changer. */
__u8 cd_r   : 1; /* Drive can write to CD-R media . */
__u8 cd_rw  : 1; /* Drive can write to CD-R/W media . */
@@ -70,19 +68,14 @@ struct ide_cd_config_flags {
__u8 dvd_r  : 1; /* Drive can write DVD-R */
__u8 dvd_ram: 1; /* Drive can write DVD-RAM */
__u8 ram: 1; /* generic WRITE (dvd-ram/mrw) */
-   __u8 test_write : 1; /* Drive can fake writes */
-   __u8 supp_disc_present  : 1; /* Changer can report exact contents
-   of slots. */
__u8 limit_nframes  : 1; /* Drive does not provide data in
multiples of SECTOR_SIZE when more
than one interrupt is needed. */
__u8 seeking: 1; /* Seeking in progress */
__u8 audio_play : 1; /* can do audio related commands */
__u8 close_tray : 1; /* can close the tray */
-   __u8 writing: 1; /* pseudo write in progress */
__u8 mo_drive   : 1; /* drive is an MO device */
__u8 no_speed_select: 1; /* SET_CD_SPEED command is unsupported. */
-   __u8 reserved   : 1;
byte max_speed;  /* Max speed of the drive */
 };
 #define

[PATCH 22/63] ide-cd: remove struct atapi_{mechstat_header,changer_info,slot}

2007-12-19 Thread Bartlomiej Zolnierkiewicz

* Remove -changer_info from struct cdrom_info (it is never allocated).

* Remove unused struct atapi_{mechstat_header,changer_info,slot}.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-11 bytes
 drivers/ide/ide-cd.c |1 
 drivers/ide/ide-cd.h |   55 ---
 2 files changed, 56 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -2948,7 +2948,6 @@ static void ide_cd_release(struct kref *
 
kfree(info-buffer);
kfree(info-toc);
-   kfree(info-changer_info);
if (devinfo-handle == drive  unregister_cdrom(devinfo))
printk(KERN_ERR %s: %s failed to unregister device from the 
cdrom 
driver.\n, __FUNCTION__, drive-name);
Index: b/drivers/ide/ide-cd.h
===
--- a/drivers/ide/ide-cd.h
+++ b/drivers/ide/ide-cd.h
@@ -357,59 +357,6 @@ struct atapi_capabilities_page {
char pad[4];
 };
 
-
-struct atapi_mechstat_header {
-#if defined(__BIG_ENDIAN_BITFIELD)
-   __u8 fault : 1;
-   __u8 changer_state : 2;
-   __u8 curslot   : 5;
-#elif defined(__LITTLE_ENDIAN_BITFIELD)
-   __u8 curslot   : 5;
-   __u8 changer_state : 2;
-   __u8 fault : 1;
-#else
-#error Please fix asm/byteorder.h
-#endif
-
-#if defined(__BIG_ENDIAN_BITFIELD)
-   __u8 mech_state: 3;
-   __u8 door_open : 1;
-   __u8 reserved1 : 4;
-#elif defined(__LITTLE_ENDIAN_BITFIELD)
-   __u8 reserved1 : 4;
-   __u8 door_open : 1;
-   __u8 mech_state: 3;
-#else
-#error Please fix asm/byteorder.h
-#endif
-
-   byte curlba[3];
-   byte nslots;
-   __u16slot_tablelen;
-};
-
-
-struct atapi_slot {
-#if defined(__BIG_ENDIAN_BITFIELD)
-   __u8 disc_present : 1;
-   __u8 reserved1: 6;
-   __u8 change   : 1;
-#elif defined(__LITTLE_ENDIAN_BITFIELD)
-   __u8 change   : 1;
-   __u8 reserved1: 6;
-   __u8 disc_present : 1;
-#else
-#error Please fix asm/byteorder.h
-#endif
-
-   byte reserved2[3];
-};
-
-struct atapi_changer_info {
-   struct atapi_mechstat_header hdr;
-   struct atapi_slot slots[0];
-};
-
 /* Extra per-device info for cdrom drives. */
 struct cdrom_info {
ide_drive_t *drive;
@@ -434,8 +381,6 @@ struct cdrom_info {
int dma;
unsigned long last_block;
unsigned long start_seek;
-   /* Buffer to hold mechanism status and changer slot table. */
-   struct atapi_changer_info *changer_info;
 
struct ide_cd_config_flags  config_flags;
struct ide_cd_state_flags   state_flags;
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 23/63] ide-cd: cleanup ide_cdrom_update_speed()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-39 bytes
 drivers/ide/ide-cd.c |   17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -2395,19 +2395,20 @@ int ide_cdrom_get_capabilities(ide_drive
 static
 void ide_cdrom_update_speed (ide_drive_t *drive, struct 
atapi_capabilities_page *cap)
 {
+   u16 curspeed, maxspeed;
+
/* The ACER/AOpen 24X cdrom has the speed fields byte-swapped */
if (!drive-id-model[0] 
!strncmp(drive-id-fw_rev, 241N, 4)) {
-   CDROM_STATE_FLAGS(drive)-current_speed  =
-   (le16_to_cpu(cap-curspeed) + (176/2)) / 176;
-   CDROM_CONFIG_FLAGS(drive)-max_speed =
-   (le16_to_cpu(cap-maxspeed) + (176/2)) / 176;
+   curspeed = le16_to_cpu(cap-curspeed);
+   maxspeed = le16_to_cpu(cap-maxspeed);
} else {
-   CDROM_STATE_FLAGS(drive)-current_speed  =
-   (be16_to_cpu(cap-curspeed) + (176/2)) / 176;
-   CDROM_CONFIG_FLAGS(drive)-max_speed =
-   (be16_to_cpu(cap-maxspeed) + (176/2)) / 176;
+   curspeed = be16_to_cpu(cap-curspeed);
+   maxspeed = be16_to_cpu(cap-maxspeed);
}
+
+   CDROM_STATE_FLAGS(drive)-current_speed = (curspeed + (176/2)) / 176;
+   CDROM_CONFIG_FLAGS(drive)-max_speed = (maxspeed + (176/2)) / 176;
 }
 
 static
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 25/63] ide-cd: remove redundant config flags

2007-12-19 Thread Bartlomiej Zolnierkiewicz

* Use CDC_* flags directly and remove redundant flags from -config_flags.

While at it:
* Add KERN_CONT to printk()-s in ide_cdrom_probe_capabilities().

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-294 bytes
 drivers/ide/ide-cd.c |  102 ---
 drivers/ide/ide-cd.h |   10 -
 2 files changed, 40 insertions(+), 72 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1868,6 +1868,8 @@ cdrom_lockdoor(ide_drive_t *drive, int l
 static int cdrom_eject(ide_drive_t *drive, int ejectflag,
   struct request_sense *sense)
 {
+   struct cdrom_info *cd = drive-driver_data;
+   struct cdrom_device_info *cdi = cd-devinfo;
struct request req;
char loej = 0x02;
 
@@ -1881,7 +1883,7 @@ static int cdrom_eject(ide_drive_t *driv
cdrom_prepare_request(drive, req);
 
/* only tell drive to close tray if open, if it can do that */
-   if (ejectflag  !CDROM_CONFIG_FLAGS(drive)-close_tray)
+   if (ejectflag  (cdi-mask  CDC_CLOSE_TRAY))
loej = 0;
 
req.sense = sense;
@@ -2142,6 +2144,8 @@ static int cdrom_read_subchannel(ide_dri
 static int cdrom_select_speed(ide_drive_t *drive, int speed,
  struct request_sense *sense)
 {
+   struct cdrom_info *cd = drive-driver_data;
+   struct cdrom_device_info *cdi = cd-devinfo;
struct request req;
cdrom_prepare_request(drive, req);
 
@@ -2156,9 +2160,8 @@ static int cdrom_select_speed(ide_drive_
req.cmd[2] = (speed  8)  0xff;   
/* Read Drive speed in kbytes/second LSB */
req.cmd[3] = speed  0xff;
-   if (CDROM_CONFIG_FLAGS(drive)-cd_r ||
-   CDROM_CONFIG_FLAGS(drive)-cd_rw ||
-   CDROM_CONFIG_FLAGS(drive)-dvd_r) {
+   if ((cdi-mask  (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) !=
+   (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) {
/* Write Drive speed in kbytes/second MSB */
req.cmd[4] = (speed  8)  0xff;
/* Write Drive speed in kbytes/second LSB */
@@ -2588,33 +2591,10 @@ static int ide_cdrom_register (ide_drive
struct cdrom_device_info *devinfo = info-devinfo;
 
devinfo-ops = ide_cdrom_dops;
-   devinfo-mask = 0;
devinfo-speed = CDROM_STATE_FLAGS(drive)-current_speed;
devinfo-capacity = nslots;
devinfo-handle = drive;
strcpy(devinfo-name, drive-name);
-   
-   /* set capability mask to match the probe. */
-   if (!CDROM_CONFIG_FLAGS(drive)-cd_r)
-   devinfo-mask |= CDC_CD_R;
-   if (!CDROM_CONFIG_FLAGS(drive)-cd_rw)
-   devinfo-mask |= CDC_CD_RW;
-   if (!CDROM_CONFIG_FLAGS(drive)-dvd)
-   devinfo-mask |= CDC_DVD;
-   if (!CDROM_CONFIG_FLAGS(drive)-dvd_r)
-   devinfo-mask |= CDC_DVD_R;
-   if (!CDROM_CONFIG_FLAGS(drive)-dvd_ram)
-   devinfo-mask |= CDC_DVD_RAM;
-   if (!CDROM_CONFIG_FLAGS(drive)-is_changer)
-   devinfo-mask |= CDC_SELECT_DISC;
-   if (!CDROM_CONFIG_FLAGS(drive)-audio_play)
-   devinfo-mask |= CDC_PLAY_AUDIO;
-   if (!CDROM_CONFIG_FLAGS(drive)-close_tray)
-   devinfo-mask |= CDC_CLOSE_TRAY;
-   if (!CDROM_CONFIG_FLAGS(drive)-mo_drive)
-   devinfo-mask |= CDC_MO_DRIVE;
-   if (!CDROM_CONFIG_FLAGS(drive)-ram)
-   devinfo-mask |= CDC_RAM;
 
if (CDROM_CONFIG_FLAGS(drive)-no_speed_select)
devinfo-mask |= CDC_SELECT_SPEED;
@@ -2631,9 +2611,12 @@ int ide_cdrom_probe_capabilities (ide_dr
struct atapi_capabilities_page cap;
int nslots = 1;
 
+   cdi-mask = (CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R |
+CDC_DVD_RAM | CDC_SELECT_DISC | CDC_PLAY_AUDIO |
+CDC_MO_DRIVE | CDC_RAM);
+
if (drive-media == ide_optical) {
-   CDROM_CONFIG_FLAGS(drive)-mo_drive = 1;
-   CDROM_CONFIG_FLAGS(drive)-ram = 1;
+   cdi-mask = ~(CDC_MO_DRIVE | CDC_RAM);
printk(KERN_ERR %s: ATAPI magneto-optical drive\n, 
drive-name);
return nslots;
}
@@ -2641,7 +2624,7 @@ int ide_cdrom_probe_capabilities (ide_dr
if (CDROM_CONFIG_FLAGS(drive)-nec260 ||
!strcmp(drive-id-model,STINGRAY 8422 IDE 8X CD-ROM 7-27-95)) {
CDROM_CONFIG_FLAGS(drive)-no_eject = 0;
-   CDROM_CONFIG_FLAGS(drive)-audio_play = 1;
+   cdi-mask = ~CDC_PLAY_AUDIO;
return nslots;
}
 
@@ -2663,23 +2646,19 @@ int ide_cdrom_probe_capabilities (ide_dr
if (cap.eject)
CDROM_CONFIG_FLAGS(drive)-no_eject = 0;
if (cap.cd_r_write)
-   CDROM_CONFIG_FLAGS(drive)-cd_r = 1;
-   if (cap.cd_rw_write) {
-   CDROM_CONFIG_FLAGS(drive)-cd_rw

[PATCH 27/63] ide-cd: kill CDROM_STATE_FLAGS() macro

2007-12-19 Thread Bartlomiej Zolnierkiewicz

While at it rename 'info' variable to 'cd' in cdrom_saw_media_change().

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-49 bytes
 drivers/ide/ide-cd.c |   44 
 drivers/ide/ide-cd.h |2 --
 2 files changed, 24 insertions(+), 22 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -93,11 +93,11 @@ static void ide_cd_put(struct cdrom_info
buffers. */
 static void cdrom_saw_media_change (ide_drive_t *drive)
 {
-   struct cdrom_info *info = drive-driver_data;
-   
-   CDROM_STATE_FLAGS (drive)-media_changed = 1;
-   CDROM_STATE_FLAGS (drive)-toc_valid = 0;
-   info-nsectors_buffered = 0;
+   struct cdrom_info *cd = drive-driver_data;
+
+   cd-state_flags.media_changed = 1;
+   cd-state_flags.toc_valid = 0;
+   cd-nsectors_buffered = 0;
 }
 
 static int cdrom_log_sense(ide_drive_t *drive, struct request *rq,
@@ -1859,7 +1859,7 @@ cdrom_lockdoor(ide_drive_t *drive, int l
stat = 0;
 
if (stat == 0)
-   CDROM_STATE_FLAGS(drive)-door_locked = lockflag;
+   cd-state_flags.door_locked = lockflag;
 
return stat;
 }
@@ -1879,7 +1879,7 @@ static int cdrom_eject(ide_drive_t *driv
return -EDRIVE_CANT_DO_THIS;
 
/* reload fails on some drives, if the tray is locked */
-   if (CDROM_STATE_FLAGS(drive)-door_locked  ejectflag)
+   if (cd-state_flags.door_locked  ejectflag)
return 0;
 
cdrom_prepare_request(drive, req);
@@ -1977,7 +1977,7 @@ static int cdrom_read_toc(ide_drive_t *d
   If it is, just return. */
(void) cdrom_check_status(drive, sense);
 
-   if (CDROM_STATE_FLAGS(drive)-toc_valid)
+   if (info-state_flags.toc_valid)
return 0;
 
/* Try to get the total cdrom capacity and sector size. */
@@ -2116,7 +2116,7 @@ static int cdrom_read_toc(ide_drive_t *d
}
 
/* Remember that we've read this stuff. */
-   CDROM_STATE_FLAGS(drive)-toc_valid = 1;
+   info-state_flags.toc_valid = 1;
 
return 0;
 }
@@ -2198,7 +2198,7 @@ static int cdrom_get_toc_entry(ide_drive
/*
 * don't serve cached data, if the toc isn't valid
 */
-   if (!CDROM_STATE_FLAGS(drive)-toc_valid)
+   if (!info-state_flags.toc_valid)
return -EINVAL;
 
/* Check validity of requested track number. */
@@ -2330,6 +2330,7 @@ static
 int ide_cdrom_reset (struct cdrom_device_info *cdi)
 {
ide_drive_t *drive = cdi-handle;
+   struct cdrom_info *cd = drive-driver_data;
struct request_sense sense;
struct request req;
int ret;
@@ -2343,7 +2344,7 @@ int ide_cdrom_reset (struct cdrom_device
 * A reset will unlock the door. If it was previously locked,
 * lock it again.
 */
-   if (CDROM_STATE_FLAGS(drive)-door_locked)
+   if (cd-state_flags.door_locked)
(void) cdrom_lockdoor(drive, 1, sense);
 
return ret;
@@ -2413,7 +2414,7 @@ void ide_cdrom_update_speed (ide_drive_t
maxspeed = be16_to_cpu(cap-maxspeed);
}
 
-   CDROM_STATE_FLAGS(drive)-current_speed = (curspeed + (176/2)) / 176;
+   cd-state_flags.current_speed = (curspeed + (176/2)) / 176;
cd-config_flags.max_speed = (maxspeed + (176/2)) / 176;
 }
 
@@ -2421,6 +2422,7 @@ static
 int ide_cdrom_select_speed (struct cdrom_device_info *cdi, int speed)
 {
ide_drive_t *drive = cdi-handle;
+   struct cdrom_info *cd = drive-driver_data;
struct request_sense sense;
struct atapi_capabilities_page cap;
int stat;
@@ -2430,7 +2432,7 @@ int ide_cdrom_select_speed (struct cdrom
 
if (!ide_cdrom_get_capabilities(drive, cap)) {
ide_cdrom_update_speed(drive, cap);
-   cdi-speed = CDROM_STATE_FLAGS(drive)-current_speed;
+   cdi-speed = cd-state_flags.current_speed;
}
 return 0;
 }
@@ -2491,7 +2493,7 @@ int ide_cdrom_get_last_session (struct c
struct request_sense sense;
int ret;
 
-   if (!CDROM_STATE_FLAGS(drive)-toc_valid || info-toc == NULL)
+   if (!info-state_flags.toc_valid || info-toc == NULL)
if ((ret = cdrom_read_toc(drive, sense)))
return ret;
 
@@ -2533,12 +2535,13 @@ int ide_cdrom_check_media_change_real (s
   int slot_nr)
 {
ide_drive_t *drive = cdi-handle;
+   struct cdrom_info *cd = drive-driver_data;
int retval;
-   
+
if (slot_nr == CDSL_CURRENT) {
(void) cdrom_check_status(drive, NULL);
-   retval = CDROM_STATE_FLAGS(drive)-media_changed;
-   CDROM_STATE_FLAGS(drive)-media_changed = 0;
+   retval = cd-state_flags.media_changed;
+   cd

[PATCH 30/63] ide-cd: remove NO_DOOR_LOCKING define

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |3 ---
 drivers/ide/ide-cd.h |7 ---
 2 files changed, 10 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -2834,9 +2834,6 @@ int ide_cdrom_setup (ide_drive_t *drive)
 
cd-cd_flags |= IDE_CD_FLAG_MEDIA_CHANGED;
 
-#if NO_DOOR_LOCKING
-   cd-cd_flags |= IDE_CD_FLAG_NO_DOORLOCK;
-#endif
if ((drive-id-config  0x0060) == 0x20)
cd-cd_flags |= IDE_CD_FLAG_DRQ_INTERRUPT;
cd-cd_flags |= IDE_CD_FLAG_NO_EJECT;
Index: b/drivers/ide/ide-cd.h
===
--- a/drivers/ide/ide-cd.h
+++ b/drivers/ide/ide-cd.h
@@ -28,13 +28,6 @@
 #endif
 
 
-/* Turning this on will disable the door-locking functionality.
-   This is apparently needed for supermount. */
-
-#ifndef NO_DOOR_LOCKING
-#define NO_DOOR_LOCKING 0
-#endif
-
 /*
  * typical timeout for packet command
  */
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 31/63] ide-cd: remove STANDARD_ATAPI define

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Remove STANDARD_ATAPI define + drive-by coding style fixes.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |   43 ++-
 drivers/ide/ide-cd.h |   10 --
 2 files changed, 10 insertions(+), 43 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1754,7 +1754,6 @@ ide_do_rw_cdrom (ide_drive_t *drive, str
  * can also be NULL, in which case no sense information is returned.
  */
 
-#if ! STANDARD_ATAPI
 static inline
 int bin2bcd (int x)
 {
@@ -1776,9 +1775,6 @@ void msf_from_bcd (struct atapi_msf *msf
msf-frame  = bcd2bin (msf-frame);
 }
 
-#endif /* not STANDARD_ATAPI */
-
-
 static inline
 void lba_to_msf (int lba, byte *m, byte *s, byte *f)
 {
@@ -1809,12 +1805,11 @@ static int cdrom_check_status(ide_drive_
req.cmd[0] = GPCMD_TEST_UNIT_READY;
req.cmd_flags |= REQ_QUIET;
 
-#if ! STANDARD_ATAPI
-/* the Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to 
-   switch CDs instead of supporting the LOAD_UNLOAD opcode   */
-
+   /*
+* Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to
+* switch CDs instead of supporting the LOAD_UNLOAD opcode.
+*/
req.cmd[7] = cdi-sanyo_slot % 3;
-#endif /* not STANDARD_ATAPI */
 
return cdrom_queue_packet_command(drive, req);
 }
@@ -2003,12 +1998,10 @@ static int cdrom_read_toc(ide_drive_t *d
if (stat)
return stat;
 
-#if ! STANDARD_ATAPI
if (info-cd_flags  IDE_CD_FLAG_TOCTRACKS_AS_BCD) {
toc-hdr.first_track = bcd2bin(toc-hdr.first_track);
toc-hdr.last_track  = bcd2bin(toc-hdr.last_track);
}
-#endif  /* not STANDARD_ATAPI */
 
ntracks = toc-hdr.last_track - toc-hdr.first_track + 1;
if (ntracks = 0)
@@ -2040,16 +2033,13 @@ static int cdrom_read_toc(ide_drive_t *d
   (ntracks + 1) *
   sizeof(struct atapi_toc_entry),
   sense);
-   if (stat) {
+   if (stat)
return stat;
-   }
-#if ! STANDARD_ATAPI
+
if (info-cd_flags  IDE_CD_FLAG_TOCTRACKS_AS_BCD) {
toc-hdr.first_track = bin2bcd(CDROM_LEADOUT);
toc-hdr.last_track = bin2bcd(CDROM_LEADOUT);
-   } else
-#endif  /* not STANDARD_ATAPI */
-   {
+   } else {
toc-hdr.first_track = CDROM_LEADOUT;
toc-hdr.last_track = CDROM_LEADOUT;
}
@@ -2060,21 +2050,17 @@ static int cdrom_read_toc(ide_drive_t *d
 
toc-hdr.toc_length = ntohs (toc-hdr.toc_length);
 
-#if ! STANDARD_ATAPI
if (info-cd_flags  IDE_CD_FLAG_TOCTRACKS_AS_BCD) {
toc-hdr.first_track = bcd2bin(toc-hdr.first_track);
toc-hdr.last_track  = bcd2bin(toc-hdr.last_track);
}
-#endif  /* not STANDARD_ATAPI */
 
-   for (i=0; i=ntracks; i++) {
-#if ! STANDARD_ATAPI
+   for (i = 0; i = ntracks; i++) {
if (info-cd_flags  IDE_CD_FLAG_TOCADDR_AS_BCD) {
if (info-cd_flags  IDE_CD_FLAG_TOCTRACKS_AS_BCD)
toc-ent[i].track = bcd2bin(toc-ent[i].track);
msf_from_bcd(toc-ent[i].addr.msf);
}
-#endif  /* not STANDARD_ATAPI */
toc-ent[i].addr.lba = msf_to_lba (toc-ent[i].addr.msf.minute,
   toc-ent[i].addr.msf.second,
   toc-ent[i].addr.msf.frame);
@@ -2094,7 +2080,6 @@ static int cdrom_read_toc(ide_drive_t *d
toc-last_session_lba = msf_to_lba(0, 2, 0); /* 0m 2s 0f */
}
 
-#if ! STANDARD_ATAPI
if (info-cd_flags  IDE_CD_FLAG_TOCADDR_AS_BCD) {
/* Re-read multisession information using MSF format */
stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)ms_tmp,
@@ -2107,7 +2092,6 @@ static int cdrom_read_toc(ide_drive_t *d
   ms_tmp.ent.addr.msf.second,
   ms_tmp.ent.addr.msf.frame);
}
-#endif  /* not STANDARD_ATAPI */
 
toc-xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track);
 
@@ -2684,16 +2668,11 @@ int ide_cdrom_probe_capabilities (ide_dr
strcmp(drive-id-model, MATSHITADVD-ROM SR-8174) == 0)
cdi-mask = ~CDC_PLAY_AUDIO;
 
-#if ! STANDARD_ATAPI
if (cdi-sanyo_slot  0) {
cdi-mask = ~CDC_SELECT_DISC;
nslots = 3;
-   }
-
-   else
-#endif /* not STANDARD_ATAPI */
-   if (mechtype == mechtype_individual_changer ||
-   mechtype == mechtype_cartridge_changer

[PATCH 33/63] ide-cd: re-organize handling of quirky devices

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Re-organize handling of quirky devices:

* Add struct cd_list_entry, ide_cd_quirks_list[] and ide_cd_flags() helper.

* Set flags returned by ide_cd_flags() in ide_cdrom_setup().

* Add IDE_CD_FLAG_VERTOS_{300_SSD,600_ESD} and IDE_CD_FLAG_SANYO_3CD flags.

* Move device quirks from ide_cdrom_setup() to ide_cd_quirks_list[].

* Rename IDE_CD_FLAG_NEC260 to IDE_CD_FLAG_PRE_ATAPI12 and handle
  quirky Stingray 8X CD-ROM using ide_cd_quirks_list[].

* Add IDE_CD_FLAG_FULL_CAPS_PAGE flag and handle quirky ACER 50X CD-ROM
  / WPI 32X CD-ROM using ide_cd_quirk_list[].

* Add IDE_CD_FLAG_PLAY_AUDIO_OK flag and handle quirky MATSHITA DVD-ROMs
  using ide_cd_quirks_list[].

* Add IDE_CD_FLAG_LE_SPEED_FIELDS flag and handle quirky ACER/AOpen 24X
  CD-ROM using ide_cd_quirk_list[].

* Fix some comments about quirky devices while at it.

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |  138 ---
 drivers/ide/ide-cd.h |   10 ++-
 2 files changed, 84 insertions(+), 64 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -2356,12 +2356,7 @@ static int ide_cdrom_get_capabilities(id
struct packet_command cgc;
int stat, attempts = 3, size = ATAPI_CAPABILITIES_PAGE_SIZE;
 
-   /*
-* ACER50 (and others?) require the full spec length mode sense
-* page capabilities size, but older drives break.
-*/
-   if (!(!strcmp(drive-id-model, ATAPI CD ROM DRIVE 50X MAX) ||
-   !strcmp(drive-id-model, WPI CDS-32X)))
+   if ((info-cd_flags  IDE_CD_FLAG_FULL_CAPS_PAGE) == 0)
size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE;
 
init_cdrom_command(cgc, buf, size, CGC_DATA_UNKNOWN);
@@ -2381,9 +2376,7 @@ static void ide_cdrom_update_speed(ide_d
curspeed = *(u16 *)buf[8 +  8];
maxspeed = *(u16 *)buf[8 + 14];
 
-   /* The ACER/AOpen 24X cdrom has the speed fields byte-swapped */
-   if (!drive-id-model[0] 
-   !strncmp(drive-id-fw_rev, 241N, 4)) {
+   if (cd-cd_flags  IDE_CD_FLAG_LE_SPEED_FIELDS) {
curspeed = le16_to_cpu(curspeed);
maxspeed = le16_to_cpu(maxspeed);
} else {
@@ -2606,8 +2599,7 @@ int ide_cdrom_probe_capabilities (ide_dr
return nslots;
}
 
-   if ((cd-cd_flags  IDE_CD_FLAG_NEC260) ||
-   !strcmp(drive-id-model,STINGRAY 8422 IDE 8X CD-ROM 7-27-95)) {
+   if (cd-cd_flags  IDE_CD_FLAG_PRE_ATAPI12) {
cd-cd_flags = ~IDE_CD_FLAG_NO_EJECT;
cdi-mask = ~CDC_PLAY_AUDIO;
return nslots;
@@ -2640,22 +2632,13 @@ int ide_cdrom_probe_capabilities (ide_dr
cdi-mask = ~(CDC_DVD_RAM | CDC_RAM);
if (buf[8 + 3]  0x10)
cdi-mask = ~CDC_DVD_R;
-   if (buf[8 + 4]  0x01)
+   if ((buf[8 + 4]  0x01) || (cd-cd_flags  IDE_CD_FLAG_PLAY_AUDIO_OK))
cdi-mask = ~CDC_PLAY_AUDIO;
 
mechtype = buf[8 + 6]  5;
if (mechtype == mechtype_caddy || mechtype == mechtype_popup)
cdi-mask |= CDC_CLOSE_TRAY;
 
-   /* Some drives used by Apple don't advertise audio play
-* but they do support reading TOC  audio datas
-*/
-   if (strcmp(drive-id-model, MATSHITADVD-ROM SR-8187) == 0 ||
-   strcmp(drive-id-model, MATSHITADVD-ROM SR-8186) == 0 ||
-   strcmp(drive-id-model, MATSHITADVD-ROM SR-8176) == 0 ||
-   strcmp(drive-id-model, MATSHITADVD-ROM SR-8174) == 0)
-   cdi-mask = ~CDC_PLAY_AUDIO;
-
if (cdi-sanyo_slot  0) {
cdi-mask = ~CDC_SELECT_DISC;
nslots = 3;
@@ -2784,11 +2767,74 @@ static int ide_cdrom_prep_fn(struct requ
return 0;
 }
 
+struct cd_list_entry {
+   const char  *id_model;
+   const char  *id_firmware;
+   unsigned intcd_flags;
+};
+
+static const struct cd_list_entry ide_cd_quirks_list[] = {
+   /* Limit transfer size per interrupt. */
+   { SAMSUNG CD-ROM SCR-2430, NULL,   IDE_CD_FLAG_LIMIT_NFRAMES  },
+   { SAMSUNG CD-ROM SCR-2432, NULL,   IDE_CD_FLAG_LIMIT_NFRAMES  },
+   /* SCR-3231 doesn't support the SET_CD_SPEED command. */
+   { SAMSUNG CD-ROM SCR-3231, NULL,   IDE_CD_FLAG_NO_SPEED_SELECT},
+   /* Old NEC260 (not R) was released before ATAPI 1.2 spec. */
+   { NEC CD-ROM DRIVE:260,1.01, IDE_CD_FLAG_TOCADDR_AS_BCD |
+IDE_CD_FLAG_PRE_ATAPI12,   },
+   /* Vertos 300, some versions of this drive like to talk BCD. */
+   { V003S0DS,NULL,   IDE_CD_FLAG_VERTOS_300_SSD,},
+   /* Vertos 600 ESD. */
+   { V006E0DS,NULL,   IDE_CD_FLAG_VERTOS_600_ESD,},
+   /*
+* Sanyo 3 CD changer uses a non

[PATCH 36/63] ide-cd: move VERBOSE_IDE_CD_ERRORS code to ide-cd_verbose.c

2007-12-19 Thread Bartlomiej Zolnierkiewicz

* Rename ide-cd kernel module to ide-cd_mod in preparation to moving code out
  from ide-cd.[c,h].   Add MODULE_ALIAS(ide-cd) to preserve compatibility.

* Move VERBOSE_IDE_CD_ERRORS code from ide-cd.[c,h] to ide-cd_verbose.c.

  ide-cd_verbose.c is IDE subsystem independent and may be easily converted
  into generic library usable by other drivers (i.e. libata) if needed.

* Add CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS config option to drivers/ide/Kconfig
  replacing VERBOSE_IDE_CD_ERRORS define.  Make this config option enabled by
  default and visible only if CONFIG_EMBEDDED is defined.

before the patch:
   textdata bss dec hex filename
  22841 3601056   242575ec1 drivers/ide/ide-cd.o

after the patch w/ CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=y:
   textdata bss dec hex filename
  22857 3601056   242735ed1 drivers/ide/ide-cd_mod.o

after the patch w/ CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=n:
   textdata bss dec hex filename
  15091 3601056   16507407b drivers/ide/ide-cd_mod.o

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/Kconfig  |9 +
 drivers/ide/Makefile |4 
 drivers/ide/ide-cd.c |  124 --
 drivers/ide/ide-cd.h |  237 
 drivers/ide/ide-cd_verbose.c |  359 +++
 5 files changed, 375 insertions(+), 358 deletions(-)

Index: b/drivers/ide/Kconfig
===
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -206,6 +206,15 @@ config BLK_DEV_IDECD
  To compile this driver as a module, choose M here: the
  module will be called ide-cd.
 
+config BLK_DEV_IDECD_VERBOSE_ERRORS
+   bool Verbose error logging for IDE/ATAPI CDROM driver if EMBEDDED
+   depends on BLK_DEV_IDECD
+   default y
+   help
+ Turn this on to have the driver print out the meanings of the
+ ATAPI error codes.  This will use up additional 8kB of kernel-space
+ memory, though.
+
 config BLK_DEV_IDETAPE
tristate Include IDE/ATAPI TAPE support (EXPERIMENTAL)
depends on EXPERIMENTAL
Index: b/drivers/ide/Makefile
===
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -40,8 +40,10 @@ obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp
 obj-$(CONFIG_IDE_H8300)+= h8300/
 obj-$(CONFIG_IDE_GENERIC)  += ide-generic.o
 
+ide-cd_mod-y += ide-cd.o ide-cd_verbose.o
+
 obj-$(CONFIG_BLK_DEV_IDEDISK)  += ide-disk.o
-obj-$(CONFIG_BLK_DEV_IDECD)+= ide-cd.o
+obj-$(CONFIG_BLK_DEV_IDECD)+= ide-cd_mod.o
 obj-$(CONFIG_BLK_DEV_IDETAPE)  += ide-tape.o
 obj-$(CONFIG_BLK_DEV_IDEFLOPPY)+= ide-floppy.o
 
Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -199,129 +199,8 @@ void cdrom_analyze_sense_data(ide_drive_
}
}
}
-#if VERBOSE_IDE_CD_ERRORS
-   {
-   int i;
-   const char *s = bad sense key!;
-   char buf[80];
-
-   printk(KERN_ERR ATAPI device %s:\n, drive-name);
-   if (sense-error_code == 0x70)
-   printk(KERN_CONT   Error: );
-   else if (sense-error_code == 0x71)
-   printk(  Deferred Error: );
-   else if (sense-error_code == 0x7f)
-   printk(KERN_CONT   Vendor-specific Error: );
-   else
-   printk(KERN_CONT   Unknown Error Type: );
-
-   if (sense-sense_key  ARRAY_SIZE(sense_key_texts))
-   s = sense_key_texts[sense-sense_key];
-
-   printk(KERN_CONT %s -- (Sense key=0x%02x)\n,
-s, sense-sense_key);
-
-   if (sense-asc == 0x40) {
-   sprintf(buf, Diagnostic failure on component 0x%02x,
-   sense-ascq);
-   s = buf;
-   } else {
-   int lo = 0, mid, hi = ARRAY_SIZE(sense_data_texts);
-   unsigned long key = (sense-sense_key  16);
-
-   key |= (sense-asc  8);
-   if (!(sense-ascq = 0x80  sense-ascq = 0xdd))
-   key |= sense-ascq;
-   s = NULL;
-
-   while (hi  lo) {
-   mid = (lo + hi) / 2;
-   if (sense_data_texts[mid].asc_ascq == key ||
-   sense_data_texts[mid].asc_ascq == 
(0xff|key)) {
-   s = sense_data_texts[mid].text;
-   break

[PATCH 38/63] ide-cd: merge cdrom_play_audio() into ide_cd_fake_play_trkind()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |   26 ++
 1 file changed, 10 insertions(+), 16 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -2047,21 +2047,6 @@ static int cdrom_select_speed(ide_drive_
return cdrom_queue_packet_command(drive, req);
 }
 
-static int cdrom_play_audio(ide_drive_t *drive, int lba_start, int lba_end)
-{
-   struct request_sense sense;
-   struct request req;
-
-   cdrom_prepare_request(drive, req);
-
-   req.sense = sense;
-   req.cmd[0] = GPCMD_PLAY_AUDIO_MSF;
-   lba_to_msf(lba_start, req.cmd[3], req.cmd[4], req.cmd[5]);
-   lba_to_msf(lba_end-1, req.cmd[6], req.cmd[7], req.cmd[8]);
-
-   return cdrom_queue_packet_command(drive, req);
-}
-
 static int cdrom_get_toc_entry(ide_drive_t *drive, int track,
struct atapi_toc_entry **ent)
 {
@@ -2118,6 +2103,8 @@ static int ide_cd_fake_play_trkind(ide_d
struct atapi_toc_entry *first_toc, *last_toc;
unsigned long lba_start, lba_end;
int stat;
+   struct request rq;
+   struct request_sense sense;
 
stat = cdrom_get_toc_entry(drive, ti-cdti_trk0, first_toc);
if (stat)
@@ -2135,7 +2122,14 @@ static int ide_cd_fake_play_trkind(ide_d
if (lba_end = lba_start)
return -EINVAL;
 
-   return cdrom_play_audio(drive, lba_start, lba_end);
+   cdrom_prepare_request(drive, rq);
+
+   rq.sense = sense;
+   rq.cmd[0] = GPCMD_PLAY_AUDIO_MSF;
+   lba_to_msf(lba_start,   rq.cmd[3], rq.cmd[4], rq.cmd[5]);
+   lba_to_msf(lba_end - 1, rq.cmd[6], rq.cmd[7], rq.cmd[8]);
+
+   return cdrom_queue_packet_command(drive, rq);
 }
 
 /* the generic packet interface to cdrom.c */
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 39/63] ide-cd: merge cdrom_read_subchannel() into ide_cdrom_get_mcn()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-19 bytes
 drivers/ide/ide-cd.c |   53 ---
 1 file changed, 21 insertions(+), 32 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1996,25 +1996,6 @@ static int ide_cd_read_tochdr(ide_drive_
return 0;
 }
 
-static int cdrom_read_subchannel(ide_drive_t *drive, int format, char *buf,
-int buflen, struct request_sense *sense)
-{
-   struct request req;
-
-   cdrom_prepare_request(drive, req);
-
-   req.sense = sense;
-   req.data = buf;
-   req.data_len = buflen;
-   req.cmd[0] = GPCMD_READ_SUBCHANNEL;
-   req.cmd[1] = 2; /* MSF addressing */
-   req.cmd[2] = 0x40;  /* request subQ data */
-   req.cmd[3] = format;
-   req.cmd[7] = (buflen  8);
-   req.cmd[8] = (buflen  0xff);
-   return cdrom_queue_packet_command(drive, req);
-}
-
 /* ATAPI cdrom drives are free to select the speed you request or any slower
rate :-( Requesting too fast a speed will _not_ produce an error. */
 static int cdrom_select_speed(ide_drive_t *drive, int speed,
@@ -2356,28 +2337,36 @@ int ide_cdrom_get_last_session (struct c
return 0;
 }
 
-static
-int ide_cdrom_get_mcn (struct cdrom_device_info *cdi,
-  struct cdrom_mcn *mcn_info)
+static int ide_cdrom_get_mcn(struct cdrom_device_info *cdi,
+struct cdrom_mcn *mcn_info)
 {
-   int stat;
-   char mcnbuf[24];
ide_drive_t *drive = cdi-handle;
+   int stat, mcnlen;
+   struct request rq;
+   char buf[24];
+
+   cdrom_prepare_request(drive, rq);
+
+   rq.data = buf;
+   rq.data_len = sizeof(buf);
 
-/* get MCN */
-   if ((stat = cdrom_read_subchannel(drive, 2, mcnbuf, sizeof (mcnbuf), 
NULL)))
+   rq.cmd[0] = GPCMD_READ_SUBCHANNEL;
+   rq.cmd[1] = 2;  /* MSF addressing */
+   rq.cmd[2] = 0x40;   /* request subQ data */
+   rq.cmd[3] = 2;  /* format */
+   rq.cmd[8] = sizeof(buf);
+
+   stat = cdrom_queue_packet_command(drive, rq);
+   if (stat)
return stat;
 
-   memcpy (mcn_info-medium_catalog_number, mcnbuf+9,
-   sizeof (mcn_info-medium_catalog_number)-1);
-   mcn_info-medium_catalog_number[sizeof 
(mcn_info-medium_catalog_number)-1]
-   = '\0';
+   mcnlen = sizeof(mcn_info-medium_catalog_number) - 1;
+   memcpy(mcn_info-medium_catalog_number, buf + 9, mcnlen);
+   mcn_info-medium_catalog_number[mcnlen] = '\0';
 
return 0;
 }
 
-
-
 /
  * Other driver requests (open, close, check media change).
  */
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/63] ide-cd: add ide_cd_pad_transfer() helper

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Add ide_cd_pad_transfer() helper and use it in cdrom_[new]pc_intr()
and cdrom_{read,write}_check_ireason().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-39 bytes
 drivers/ide/ide-cd.c |   51 +--
 1 file changed, 25 insertions(+), 26 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1007,6 +1007,15 @@ static ide_startstop_t cdrom_transfer_pa
 
 typedef void (xfer_func_t)(ide_drive_t *, void *, u32);
 
+static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len)
+{
+   while (len  0) {
+   int dum = 0;
+   xf(drive, dum, sizeof(dum));
+   len -= sizeof(dum);
+   }
+}
+
 /*
  * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector
  * buffer.  Once the first sector is added, any subsequent sectors are
@@ -1063,17 +1072,15 @@ int cdrom_read_check_ireason (ide_drive_
if (ireason == 2)
return 0;
else if (ireason == 0) {
+   ide_hwif_t *hwif = drive-hwif;
+
/* Whoops... The drive is expecting to receive data from us! */
printk(KERN_ERR %s: %s: wrong transfer direction!\n,
drive-name, __FUNCTION__);
 
/* Throw some data at the drive so it doesn't hang
   and quit this request. */
-   while (len  0) {
-   int dum = 0;
-   HWIF(drive)-atapi_output_bytes(drive, dum, sizeof 
(dum));
-   len -= sizeof (dum);
-   }
+   ide_cd_pad_transfer(drive, hwif-atapi_output_bytes, len);
} else  if (ireason == 1) {
/* Some drives (ASUS) seem to tell us that status
 * info is available. just get it and ignore.
@@ -1500,15 +1507,8 @@ static ide_startstop_t cdrom_pc_intr (id
/* Transfer the data. */
xferfunc(drive, rq-data, thislen);
 
-   /* If we haven't moved enough data to satisfy the drive,
-  add some padding. */
-   while (len  thislen) {
-   int dum = 0;
-   xferfunc(drive, dum, sizeof(dum));
-   len -= sizeof(dum);
-   }
-
/* Keep count of how much data we've moved. */
+   len -= thislen;
rq-data += thislen;
rq-data_len -= thislen;
 
@@ -1525,6 +1525,13 @@ confused:
return ide_stopped;
}
 
+   /*
+* If we haven't moved enough data to satisfy the drive,
+* add some padding.
+*/
+   if (len  0)
+   ide_cd_pad_transfer(drive, xferfunc, len);
+
/* Now we wait for another interrupt. */
ide_set_handler(drive, cdrom_pc_intr, ATAPI_WAIT_PC, 
cdrom_timer_expiry);
return ide_started;
@@ -1617,15 +1624,13 @@ static int cdrom_write_check_ireason(ide
if (ireason == 0)
return 0;
else if (ireason == 2) {
+   ide_hwif_t *hwif = drive-hwif;
+
/* Whoops... The drive wants to send data. */
printk(KERN_ERR %s: %s: wrong transfer direction!\n,
drive-name, __FUNCTION__);
 
-   while (len  0) {
-   int dum = 0;
-   HWIF(drive)-atapi_input_bytes(drive, dum, 
sizeof(dum));
-   len -= sizeof(dum);
-   }
+   ide_cd_pad_transfer(drive, hwif-atapi_input_bytes, len);
} else {
/* Drive wants a command packet, or invalid ireason... */
printk(KERN_ERR %s: %s: bad interrupt reason 0x02%x\n,
@@ -1754,14 +1759,8 @@ static ide_startstop_t cdrom_newpc_intr(
/*
 * pad, if necessary
 */
-   if (len  0) {
-   while (len  0) {
-   int pad = 0;
-
-   xferfunc(drive, pad, sizeof(pad));
-   len -= sizeof(pad);
-   }
-   }
+   if (len  0)
+   ide_cd_pad_transfer(drive, xferfunc, len);
 
BUG_ON(HWGROUP(drive)-handler != NULL);
 
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 44/63] ide-cd: move code handling cdrom.c IOCTLs to ide-cd_ioctl.c

2007-12-19 Thread Bartlomiej Zolnierkiewicz

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/Makefile   |2 
 drivers/ide/ide-cd.c   |  271 +
 drivers/ide/ide-cd.h   |   17 ++
 drivers/ide/ide-cd_ioctl.c |  265 
 4 files changed, 290 insertions(+), 265 deletions(-)

Index: b/drivers/ide/Makefile
===
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -40,7 +40,7 @@ obj-$(CONFIG_BLK_DEV_IDEPNP)  += ide-pnp
 obj-$(CONFIG_IDE_H8300)+= h8300/
 obj-$(CONFIG_IDE_GENERIC)  += ide-generic.o
 
-ide-cd_mod-y += ide-cd.o ide-cd_verbose.o
+ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o
 
 obj-$(CONFIG_BLK_DEV_IDEDISK)  += ide-disk.o
 obj-$(CONFIG_BLK_DEV_IDECD)+= ide-cd_mod.o
Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -206,7 +206,7 @@ void cdrom_analyze_sense_data(ide_drive_
 /*
  * Initialize a ide-cd packet command request
  */
-static void ide_cd_init_rq(ide_drive_t *drive, struct request *rq)
+void ide_cd_init_rq(ide_drive_t *drive, struct request *rq)
 {
struct cdrom_info *cd = drive-driver_data;
 
@@ -1168,7 +1168,7 @@ static ide_startstop_t cdrom_do_packet_c
return cdrom_start_packet_command(drive, len, cdrom_do_pc_continuation);
 }
 
-static int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq)
+int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq)
 {
struct request_sense sense;
int retries = 10;
@@ -1664,8 +1664,8 @@ static int cdrom_check_status(ide_drive_
 }
 
 /* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */
-static int ide_cd_lockdoor(ide_drive_t *drive, int lockflag,
-  struct request_sense *sense)
+int ide_cd_lockdoor(ide_drive_t *drive, int lockflag,
+   struct request_sense *sense)
 {
struct cdrom_info *cd = drive-driver_data;
struct request_sense my_sense;
@@ -1796,9 +1796,8 @@ static int cdrom_read_tocentry(ide_drive
return ide_cd_queue_pc(drive, req);
 }
 
-
 /* Try to read the entire TOC for the disk into our internal buffer. */
-static int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
+int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
 {
int stat, ntracks, i;
struct cdrom_info *info = drive-driver_data;
@@ -1958,112 +1957,6 @@ static int ide_cd_read_toc(ide_drive_t *
return 0;
 }
 
-static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg)
-{
-   struct cdrom_info *cd = drive-driver_data;
-   struct cdrom_tochdr *tochdr = arg;
-   struct atapi_toc *toc;
-   int stat;
-
-   /* Make sure our saved TOC is valid. */
-   stat = ide_cd_read_toc(drive, NULL);
-   if (stat)
-   return stat;
-
-   toc = cd-toc;
-   tochdr-cdth_trk0 = toc-hdr.first_track;
-   tochdr-cdth_trk1 = toc-hdr.last_track;
-
-   return 0;
-}
-
-static int ide_cd_get_toc_entry(ide_drive_t *drive, int track,
-   struct atapi_toc_entry **ent)
-{
-   struct cdrom_info *info = drive-driver_data;
-   struct atapi_toc *toc = info-toc;
-   int ntracks;
-
-   /*
-* don't serve cached data, if the toc isn't valid
-*/
-   if ((info-cd_flags  IDE_CD_FLAG_TOC_VALID) == 0)
-   return -EINVAL;
-
-   /* Check validity of requested track number. */
-   ntracks = toc-hdr.last_track - toc-hdr.first_track + 1;
-
-   if (toc-hdr.first_track == CDROM_LEADOUT)
-   ntracks = 0;
-
-   if (track == CDROM_LEADOUT)
-   *ent = toc-ent[ntracks];
-   else if (track  toc-hdr.first_track || track  toc-hdr.last_track)
-   return -EINVAL;
-   else
-   *ent = toc-ent[track - toc-hdr.first_track];
-
-   return 0;
-}
-
-static int ide_cd_read_tocentry(ide_drive_t *drive, void *arg)
-{
-   struct cdrom_tocentry *tocentry = arg;
-   struct atapi_toc_entry *toce;
-   int stat;
-
-   stat = ide_cd_get_toc_entry(drive, tocentry-cdte_track, toce);
-   if (stat)
-   return stat;
-
-   tocentry-cdte_ctrl = toce-control;
-   tocentry-cdte_adr  = toce-adr;
-   if (tocentry-cdte_format == CDROM_MSF) {
-   lba_to_msf(toce-addr.lba,
-  tocentry-cdte_addr.msf.minute,
-  tocentry-cdte_addr.msf.second,
-  tocentry-cdte_addr.msf.frame);
-   } else
-   tocentry-cdte_addr.lba = toce-addr.lba;
-
-   return 0;
-}
-
-static int ide_cd_fake_play_trkind(ide_drive_t *drive, void *arg)
-{
-   struct cdrom_ti *ti = arg;
-   struct atapi_toc_entry

[PATCH 46/63] ide-cd: call blk_dump_rq_flags() on missing data in cdrom_newpc_intr()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1343,7 +1343,11 @@ static ide_startstop_t cdrom_newpc_intr(
}
 
if (!ptr) {
-   printk(KERN_ERR %s: confused, missing data\n, 
drive-name);
+   printk(KERN_ERR %s: confused, missing data\n,
+   drive-name);
+   blk_dump_rq_flags(rq, rq_data_dir(rq)
+ ? cdrom_newpc_intr, write
+ : cdrom_newpc_intr, read);
break;
}
 
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 63/63] ide-cd: update driver version, comments and copyrights

2007-12-19 Thread Bartlomiej Zolnierkiewicz

* Bump driver version.

* Remove filename and stale TODO from comments.

* Add my copyrights.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |   17 -
 1 file changed, 4 insertions(+), 13 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1,14 +1,14 @@
 /*
- * linux/drivers/ide/ide-cd.c
+ * ATAPI CD-ROM driver.
  *
- * Copyright (C) 1994, 1995, 1996  scott snyder  [EMAIL PROTECTED]
+ * Copyright (C) 1994-1996  Scott Snyder [EMAIL PROTECTED]
  * Copyright (C) 1996-1998  Erik Andersen [EMAIL PROTECTED]
  * Copyright (C) 1998-2000  Jens Axboe [EMAIL PROTECTED]
+ * Copyright (C)  2007  Bartlomiej Zolnierkiewicz
  *
  * May be copied or modified under the terms of the GNU General Public
  * License.  See linux/COPYING for more information.
  *
- * ATAPI CD-ROM driver.  To be used with ide.c.
  * See Documentation/cdrom/ide-cd for usage information.
  *
  * Suggestions are welcome. Patches that work are more welcome though. ;-)
@@ -19,20 +19,11 @@
  * 
ftp://fission.dt.wdc.com/pub/standards/SFF_atapi/spec/SFF8020-r2.6/PS/8020r26.ps
  * ftp://ftp.avc-pioneer.com/Mtfuji4/Spec/Fuji4r10.pdf
  *
- * Drives that deviate from these standards will be accommodated as much
- * as possible via compile time or command-line options.  Since I only have
- * a few drives, you generally need to send me patches...
- *
- * --
- * TO DO LIST:
- * -Make it so that Pioneer CD DR-A24X and friends don't get screwed up on
- *   boot
- *
  * For historical changelog please see:
  * Documentation/ide/ChangeLog.ide-cd.1994-2004
  */
 
-#define IDECD_VERSION 4.61
+#define IDECD_VERSION 5.00
 
 #include linux/module.h
 #include linux/types.h
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 61/63] ide-cd: merge cdrom_write_check_ireason() and cdrom_read_check_ireason()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Add 'rw' parameter to cdrom_read_check_ireason(), make it handle
both read and write checking, rename it to ide_cd_check_ireason(),
finally remove no longer needed cdrom_write_check_ireason().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-61 bytes
 drivers/ide/ide-cd.c |   64 +++
 1 file changed, 15 insertions(+), 49 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -683,21 +683,25 @@ static void cdrom_buffer_sectors (ide_dr
  * ok; nonzero if the request has been terminated.
  */
 static
-int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason)
+int ide_cd_check_ireason(ide_drive_t *drive, int len, int ireason, int rw)
 {
-   if (ireason == 2)
+   /*
+* ireason == 0: the drive wants to receive data from us
+* ireason == 2: the drive is expecting to transfer data to us
+*/
+   if (ireason == (!rw  1))
return 0;
-   else if (ireason == 0) {
+   else if (ireason == (rw  1)) {
ide_hwif_t *hwif = drive-hwif;
+   xfer_func_t *xf;
 
-   /* Whoops... The drive is expecting to receive data from us! */
+   /* Whoops... */
printk(KERN_ERR %s: %s: wrong transfer direction!\n,
drive-name, __FUNCTION__);
 
-   /* Throw some data at the drive so it doesn't hang
-  and quit this request. */
-   ide_cd_pad_transfer(drive, hwif-atapi_output_bytes, len);
-   } else  if (ireason == 1) {
+   xf = rw ? hwif-atapi_output_bytes : hwif-atapi_input_bytes;
+   ide_cd_pad_transfer(drive, xf, len);
+   } else  if (rw == 0  ireason == 1) {
/* Some drives (ASUS) seem to tell us that status
 * info is available. just get it and ignore.
 */
@@ -984,35 +988,6 @@ int ide_cd_queue_pc(ide_drive_t *drive, 
return (rq-cmd_flags  REQ_FAILED) ? -EIO : 0;
 }
 
-/*
- * Write handling
- */
-static int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ireason)
-{
-   /* Two notes about IDE interrupt reason here - 0 means that
-* the drive wants to receive data from us, 2 means that
-* the drive is expecting to transfer data to us.
-*/
-   if (ireason == 0)
-   return 0;
-   else if (ireason == 2) {
-   ide_hwif_t *hwif = drive-hwif;
-
-   /* Whoops... The drive wants to send data. */
-   printk(KERN_ERR %s: %s: wrong transfer direction!\n,
-   drive-name, __FUNCTION__);
-
-   ide_cd_pad_transfer(drive, hwif-atapi_input_bytes, len);
-   } else {
-   /* Drive wants a command packet, or invalid ireason... */
-   printk(KERN_ERR %s: %s: bad interrupt reason 0x%02x\n,
-   drive-name, __FUNCTION__, ireason);
-   }
-
-   cdrom_end_request(drive, 0);
-   return 1;
-}
-
 static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
 {
struct cdrom_info *info = drive-driver_data;
@@ -1100,20 +1075,11 @@ static ide_startstop_t cdrom_newpc_intr(
/*
 * check which way to transfer data
 */
-   if ((blk_fs_request(rq) || blk_pc_request(rq))  write) {
-   /*
-* write to drive
-*/
-   if (cdrom_write_check_ireason(drive, len, ireason))
-   return ide_stopped;
-   } else if (blk_fs_request(rq) || blk_pc_request(rq)) {
-   /*
-* read from drive
-*/
-   if (cdrom_read_check_ireason(drive, len, ireason))
+   if (blk_fs_request(rq) || blk_pc_request(rq)) {
+   if (ide_cd_check_ireason(drive, len, ireason, write))
return ide_stopped;
 
-   if (blk_fs_request(rq)) {
+   if (blk_fs_request(rq)  write == 0) {
int nskip;
 
if (ide_cd_check_transfer_size(drive, len)) {
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 60/63] ide-cd: merge cdrom_rw_intr() and cdrom_newpc_intr()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Add handling of fs read/write requests to cdrom_nepwc_intr()
and remove no longer needed cdrom_rw_intr().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-496 bytes
 drivers/ide/ide-cd.c |  272 +--
 1 file changed, 94 insertions(+), 178 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -797,7 +797,7 @@ static int cdrom_read_from_buffer (ide_d
return 0;
 }
 
-static ide_startstop_t cdrom_rw_intr(ide_drive_t *);
+static ide_startstop_t cdrom_newpc_intr(ide_drive_t *);
 
 /*
  * Routine to send a read/write packet command to the drive.
@@ -846,7 +846,7 @@ static ide_startstop_t cdrom_start_rw_co
rq-timeout = ATAPI_WAIT_PC;
 
/* Send the command to the drive and return. */
-   return cdrom_transfer_packet_command(drive, rq, cdrom_rw_intr);
+   return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr);
 }
 
 #define IDECD_SEEK_THRESHOLD   (1000)  /* 1000 blocks */
@@ -1013,17 +1013,12 @@ static int cdrom_write_check_ireason(ide
return 1;
 }
 
-/*
- * best way to deal with dma that is not sector aligned right now... note
- * that in this path we are not using -data or -buffer at all. this irs
- * can replace cdrom_rw_intr() in the future.
- */
 static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
 {
struct cdrom_info *info = drive-driver_data;
struct request *rq = HWGROUP(drive)-rq;
xfer_func_t *xferfunc;
-   ide_expiry_t *expiry;
+   ide_expiry_t *expiry = NULL;
int dma_error = 0, dma, stat, ireason, len, thislen, uptodate = 0;
int write = (rq_data_dir(rq) == WRITE) ? 1 : 0;
unsigned int timeout;
@@ -1051,6 +1046,10 @@ static ide_startstop_t cdrom_newpc_intr(
if (dma_error)
return ide_error(drive, dma error, stat);
 
+   if (blk_fs_request(rq)) {
+   ide_end_request(drive, 1, rq-nr_sectors);
+   return ide_stopped;
+   }
end_that_request_chunk(rq, 1, rq-data_len);
rq-data_len = 0;
goto end_request;
@@ -1064,7 +1063,8 @@ static ide_startstop_t cdrom_newpc_intr(
highcyl = HWIF(drive)-INB(IDE_BCOUNTH_REG);
 
len = lowcyl + (256 * highcyl);
-   thislen = rq-data_len;
+
+   thislen = blk_fs_request(rq) ? len : rq-data_len;
if (thislen  len)
thislen = len;
 
@@ -1072,7 +1072,24 @@ static ide_startstop_t cdrom_newpc_intr(
 * If DRQ is clear, the command has completed.
 */
if ((stat  DRQ_STAT) == 0) {
-   if (!blk_pc_request(rq)) {
+   if (blk_fs_request(rq)) {
+   /*
+* If we're not done reading/writing, complain.
+* Otherwise, complete the command normally.
+*/
+   uptodate = 1;
+   if (rq-current_nr_sectors  0) {
+   printk(KERN_ERR %s: %s: data underrun 
+   (%d blocks)\n,
+   drive-name, __FUNCTION__,
+   rq-current_nr_sectors);
+   if (!write)
+   rq-cmd_flags |= REQ_FAILED;
+   uptodate = 0;
+   }
+   cdrom_end_request(drive, uptodate);
+   return ide_stopped;
+   } else if (!blk_pc_request(rq)) {
ide_cd_request_sense_fixup(rq);
/* Complain if we still have data left to transfer. */
uptodate = rq-data_len ? 0 : 1;
@@ -1083,24 +1100,47 @@ static ide_startstop_t cdrom_newpc_intr(
/*
 * check which way to transfer data
 */
-   if (blk_pc_request(rq)  rq_data_dir(rq) == WRITE) {
+   if ((blk_fs_request(rq) || blk_pc_request(rq))  write) {
/*
 * write to drive
 */
if (cdrom_write_check_ireason(drive, len, ireason))
return ide_stopped;
-   } else if (blk_pc_request(rq)) {
+   } else if (blk_fs_request(rq) || blk_pc_request(rq)) {
/*
 * read from drive
 */
if (cdrom_read_check_ireason(drive, len, ireason))
return ide_stopped;
+
+   if (blk_fs_request(rq)) {
+   int nskip;
+
+   if (ide_cd_check_transfer_size(drive, len)) {
+   cdrom_end_request(drive, 0);
+   return

[PATCH 59/63] ide-cd: call blk_dump_rq_flags() on missing data in cdrom_rw_intr()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1301,10 +1301,12 @@ static ide_startstop_t cdrom_rw_intr(ide
 */
cdrom_buffer_sectors(drive, rq-sector,
 thislen  9);
-   else
+   else {
printk(KERN_ERR %s: %s: confused, missing 
data\n,
drive-name, __FUNCTION__);
+   blk_dump_rq_flags(rq, cdrom_rw_intr, write);
+   }
break;
}
 
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 58/63] ide-cd: prepare cdrom_rw_intr() and cdrom_newpc_intr() to be merged

2007-12-19 Thread Bartlomiej Zolnierkiewicz

In cdrom_newpc_intr():
* cleanup variables in the 'transfer data' loop

In cdrom_rw_intr():
* rename 'sectors_to_transfer' to 'thislen'
* rename 'this_transfer' to 'blen'
* keep number of bytes (instead of sectors) in 'thislen' and 'blen'
* call 'xferfunc' only once for 'blen'
* cache 'rq-buffer' in 'ptr' variable
* check for 'rq-bio' before setting 'ptr' and 'blen'
* check for 'ptr' instead of 'rq-current_nr_sectors'

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
+54 bytes
 drivers/ide/ide-cd.c |   45 +
 1 file changed, 25 insertions(+), 20 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1115,8 +1115,8 @@ static ide_startstop_t cdrom_newpc_intr(
 * transfer data
 */
while (thislen  0) {
-   int blen = blen = rq-data_len;
-   char *ptr = rq-data;
+   u8 *ptr = rq-data;
+   int blen = rq-data_len;
 
/*
 * bio backed?
@@ -1192,7 +1192,7 @@ static ide_startstop_t cdrom_rw_intr(ide
struct cdrom_info *info = drive-driver_data;
struct request *rq = HWGROUP(drive)-rq;
xfer_func_t *xferfunc;
-   int stat, ireason, len, sectors_to_transfer, uptodate, nskip;
+   int stat, ireason, len, thislen, uptodate, nskip;
int dma_error = 0, dma = info-dma, write = rq_data_dir(rq) == WRITE;
u8 lowcyl = 0, highcyl = 0;
 
@@ -1247,7 +1247,7 @@ static ide_startstop_t cdrom_rw_intr(ide
return ide_stopped;
}
 
-   sectors_to_transfer = len / SECTOR_SIZE;
+   thislen = len;
 
/* Check that the drive is expecting to do the same thing we are. */
if (write) {
@@ -1270,12 +1270,12 @@ static ide_startstop_t cdrom_rw_intr(ide
 */
nskip = min_t(int, rq-current_nr_sectors
   - bio_cur_sectors(rq-bio),
-  sectors_to_transfer);
+  thislen  9);
 
if (nskip  0) {
ide_cd_drain_data(drive, nskip);
rq-current_nr_sectors -= nskip;
-   sectors_to_transfer -= nskip;
+   thislen -= (nskip  9);
}
 
xferfunc = HWIF(drive)-atapi_input_bytes;
@@ -1284,17 +1284,23 @@ static ide_startstop_t cdrom_rw_intr(ide
/*
 * now loop and read/write the data
 */
-   while (sectors_to_transfer  0) {
-   int this_transfer;
+   while (thislen  0) {
+   u8 *ptr = NULL;
+   int blen;
+
+   if (rq-bio) {
+   ptr = rq-buffer;
+   blen = rq-current_nr_sectors  9;
+   }
 
-   if (!rq-current_nr_sectors) {
+   if (!ptr) {
if (!write)
/*
 * If the buffers are full, cache the rest
 * of the data in our internal buffer.
 */
cdrom_buffer_sectors(drive, rq-sector,
-sectors_to_transfer);
+thislen  9);
else
printk(KERN_ERR %s: %s: confused, missing 
data\n,
@@ -1305,17 +1311,16 @@ static ide_startstop_t cdrom_rw_intr(ide
/*
 * Figure out how many sectors we can transfer
 */
-   this_transfer = min_t(int, sectors_to_transfer, 
rq-current_nr_sectors);
+   if (blen  thislen)
+   blen = thislen;
 
-   while (this_transfer  0) {
-   xferfunc(drive, rq-buffer, SECTOR_SIZE);
-   rq-buffer += SECTOR_SIZE;
-   --rq-nr_sectors;
-   --rq-current_nr_sectors;
-   ++rq-sector;
-   --this_transfer;
-   --sectors_to_transfer;
-   }
+   xferfunc(drive, ptr, blen);
+
+   thislen -= blen;
+   rq-buffer += blen;
+   rq-nr_sectors -= (blen  9);
+   rq-current_nr_sectors -= (blen  9);
+   rq-sector += (blen  9);
 
/*
 * current buffer complete, move on
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 57/63] ide-cd: unify moving to the next buffer in cdrom_rw_intr()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Use the fact that for the first loop rq-current_nr_sectors is always
set and unify moving to the next buffer for read/write requests.

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-46 bytes
 drivers/ide/ide-cd.c |9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1287,13 +1287,6 @@ static ide_startstop_t cdrom_rw_intr(ide
while (sectors_to_transfer  0) {
int this_transfer;
 
-   /*
-* If we've filled the present buffer but there's another
-* chained buffer after it, move on.
-*/
-   if (!write  rq-current_nr_sectors == 0  rq-nr_sectors)
-   cdrom_end_request(drive, 1);
-
if (!rq-current_nr_sectors) {
if (!write)
/*
@@ -1327,7 +1320,7 @@ static ide_startstop_t cdrom_rw_intr(ide
/*
 * current buffer complete, move on
 */
-   if (write  rq-current_nr_sectors == 0  rq-nr_sectors)
+   if (rq-current_nr_sectors == 0  rq-nr_sectors)
cdrom_end_request(drive, 1);
}
 
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 56/63] ide-cd: merge cdrom_start_read() and cdrom_start_write()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Add handling of read requests to cdrom_start_write(), rename it
to cdrom_start_rw() and remove no longer needed cdrom_start_read().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-20 bytes
 drivers/ide/ide-cd.c |  101 ---
 1 file changed, 40 insertions(+), 61 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -918,38 +918,6 @@ static void restore_request (struct requ
rq-q-prep_rq_fn(rq-q, rq);
 }
 
-/*
- * Start a read request from the CD-ROM.
- */
-static ide_startstop_t cdrom_start_read (ide_drive_t *drive, unsigned int 
block)
-{
-   struct cdrom_info *info = drive-driver_data;
-   struct request *rq = HWGROUP(drive)-rq;
-   unsigned short sectors_per_frame;
-
-   sectors_per_frame = queue_hardsect_size(drive-queue)  SECTOR_BITS;
-
-   /* We may be retrying this request after an error.  Fix up
-  any weirdness which might be present in the request packet. */
-   restore_request(rq);
-
-   /* Satisfy whatever we can of this request from our cached sector. */
-   if (cdrom_read_from_buffer(drive))
-   return ide_stopped;
-
-   /* Clear the local sector buffer. */
-   info-nsectors_buffered = 0;
-
-   /* use dma, if possible. */
-   info-dma = drive-using_dma;
-   if ((rq-sector  (sectors_per_frame - 1)) ||
-   (rq-nr_sectors  (sectors_per_frame - 1)))
-   info-dma = 0;
-
-   /* Start sending the read request to the drive. */
-   return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont);
-}
-
 /
  * Execute all other packet commands.
  */
@@ -1368,38 +1336,53 @@ static ide_startstop_t cdrom_rw_intr(ide
return ide_started;
 }
 
-static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request 
*rq)
+static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
 {
-   struct cdrom_info *info = drive-driver_data;
-   struct gendisk *g = info-disk;
-   unsigned short sectors_per_frame = queue_hardsect_size(drive-queue)  
SECTOR_BITS;
+   struct cdrom_info *cd = drive-driver_data;
+   int write = rq_data_dir(rq) == WRITE;
+   unsigned short sectors_per_frame =
+   queue_hardsect_size(drive-queue)  SECTOR_BITS;
 
-   /*
-* writes *must* be hardware frame aligned
-*/
-   if ((rq-nr_sectors  (sectors_per_frame - 1)) ||
-   (rq-sector  (sectors_per_frame - 1))) {
-   cdrom_end_request(drive, 0);
-   return ide_stopped;
+   if (write) {
+   /*
+* disk has become write protected
+*/
+   if (cd-disk-policy) {
+   cdrom_end_request(drive, 0);
+   return ide_stopped;
+   }
+   } else {
+   /*
+* We may be retrying this request after an error.  Fix up any
+* weirdness which might be present in the request packet.
+*/
+   restore_request(rq);
+
+   /* Satisfy whatever we can of this request from our cache. */
+   if (cdrom_read_from_buffer(drive))
+   return ide_stopped;
}
 
/*
-* disk has become write protected
+* use DMA, if possible / writes *must* be hardware frame aligned
 */
-   if (g-policy) {
-   cdrom_end_request(drive, 0);
-   return ide_stopped;
-   }
-
-   info-nsectors_buffered = 0;
+   if ((rq-nr_sectors  (sectors_per_frame - 1)) ||
+   (rq-sector  (sectors_per_frame - 1))) {
+   if (write) {
+   cdrom_end_request(drive, 0);
+   return ide_stopped;
+   }
+   cd-dma = 0;
+   } else
+   cd-dma = drive-using_dma;
 
-   /* use dma, if possible. we don't need to check more, since we
-* know that the transfer is always (at least!) frame aligned */
-   info-dma = drive-using_dma ? 1 : 0;
+   /* Clear the local sector buffer. */
+   cd-nsectors_buffered = 0;
 
-   info-devinfo.media_written = 1;
+   if (write)
+   cd-devinfo.media_written = 1;
 
-   /* Start sending the write request to the drive. */
+   /* Start sending the read/write request to the drive. */
return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont);
 }
 
@@ -1472,12 +1455,8 @@ ide_do_rw_cdrom (ide_drive_t *drive, str
}
if ((rq_data_dir(rq) == READ)  
IDE_LARGE_SEEK(info-last_block, block, IDECD_SEEK_THRESHOLD) 
 drive-dsc_overlap) {
action = cdrom_start_seek

[PATCH 55/63] ide-cd: merge cdrom_start_read_continuation() and cdrom_start_rw_cont()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

* Add handling of write requests to cdrom_start_read_continuation(),
  rename it to cdrom_start_rw_cont() and remove no longer needed
  cdrom_start_write_cont().

* Remove redundant '(rq-sector  (sectors_per_frame - 1)' check.

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-51 bytes
 drivers/ide/ide-cd.c |   74 ---
 1 file changed, 35 insertions(+), 39 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -800,39 +800,48 @@ static int cdrom_read_from_buffer (ide_d
 static ide_startstop_t cdrom_rw_intr(ide_drive_t *);
 
 /*
- * Routine to send a read packet command to the drive.
- * This is usually called directly from cdrom_start_read.
+ * Routine to send a read/write packet command to the drive.
+ * This is usually called directly from cdrom_start_{read,write}().
  * However, for drq_interrupt devices, it is called from an interrupt
  * when the drive is ready to accept the command.
  */
-static ide_startstop_t cdrom_start_read_continuation (ide_drive_t *drive)
+static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive)
 {
struct request *rq = HWGROUP(drive)-rq;
-   unsigned short sectors_per_frame;
-   int nskip;
 
-   sectors_per_frame = queue_hardsect_size(drive-queue)  SECTOR_BITS;
+   if (rq_data_dir(rq) == READ) {
+   unsigned short sectors_per_frame =
+   queue_hardsect_size(drive-queue)  SECTOR_BITS;
+   int nskip = rq-sector  (sectors_per_frame - 1);
 
-   /* If the requested sector doesn't start on a cdrom block boundary,
-  we must adjust the start of the transfer so that it does,
-  and remember to skip the first few sectors.
-  If the CURRENT_NR_SECTORS field is larger than the size
-  of the buffer, it will mean that we're to skip a number
-  of sectors equal to the amount by which CURRENT_NR_SECTORS
-  is larger than the buffer size. */
-   nskip = rq-sector  (sectors_per_frame - 1);
-   if (nskip  0) {
-   /* Sanity check... */
-   if (rq-current_nr_sectors != bio_cur_sectors(rq-bio) 
-   (rq-sector  (sectors_per_frame - 1))) {
-   printk(KERN_ERR %s: cdrom_start_read_continuation: 
buffer botch (%u)\n,
-   drive-name, rq-current_nr_sectors);
-   cdrom_end_request(drive, 0);
-   return ide_stopped;
+   /*
+* If the requested sector doesn't start on a frame boundary,
+* we must adjust the start of the transfer so that it does,
+* and remember to skip the first few sectors.
+*
+* If the rq-current_nr_sectors field is larger than the size
+* of the buffer, it will mean that we're to skip a number of
+* sectors equal to the amount by which rq-current_nr_sectors
+* is larger than the buffer size.
+*/
+   if (nskip  0) {
+   /* Sanity check... */
+   if (rq-current_nr_sectors !=
+   bio_cur_sectors(rq-bio)) {
+   printk(KERN_ERR %s: %s: buffer botch (%u)\n,
+   drive-name, __FUNCTION__,
+   rq-current_nr_sectors);
+   cdrom_end_request(drive, 0);
+   return ide_stopped;
+   }
+   rq-current_nr_sectors += nskip;
}
-   rq-current_nr_sectors += nskip;
}
-
+#if 0
+   else
+   /* the immediate bit */
+   rq-cmd[1] = 1  3;
+#endif
/* Set up the command */
rq-timeout = ATAPI_WAIT_PC;
 
@@ -840,7 +849,6 @@ static ide_startstop_t cdrom_start_read_
return cdrom_transfer_packet_command(drive, rq, cdrom_rw_intr);
 }
 
-
 #define IDECD_SEEK_THRESHOLD   (1000)  /* 1000 blocks */
 #define IDECD_SEEK_TIMER   (5 * WAIT_MIN_SLEEP)/* 100 ms */
 #define IDECD_SEEK_TIMEOUT (2 * WAIT_CMD)  /* 20 sec */
@@ -939,7 +947,7 @@ static ide_startstop_t cdrom_start_read 
info-dma = 0;
 
/* Start sending the read request to the drive. */
-   return cdrom_start_packet_command(drive, 32768, 
cdrom_start_read_continuation);
+   return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont);
 }
 
 /
@@ -1360,18 +1368,6 @@ static ide_startstop_t cdrom_rw_intr(ide
return ide_started;
 }
 
-static ide_startstop_t cdrom_start_write_cont(ide_drive_t *drive

[PATCH 54/63] ide-cd: merge cdrom_read_intr() and cdrom_write_intr()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Add handling of read requests to cdrom_write_intr(), rename it
to cdrom_rw_intr() and remove no longer needed cdrom_read_intr().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-368 bytes
 drivers/ide/ide-cd.c |  207 +--
 1 file changed, 69 insertions(+), 138 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -739,125 +739,6 @@ static int ide_cd_check_transfer_size(id
 }
 
 /*
- * Interrupt routine.  Called when a read request has completed.
- */
-static ide_startstop_t cdrom_read_intr (ide_drive_t *drive)
-{
-   int stat;
-   int ireason, len, sectors_to_transfer, nskip;
-   struct cdrom_info *info = drive-driver_data;
-   u8 lowcyl = 0, highcyl = 0;
-   int dma = info-dma, dma_error = 0;
-
-   struct request *rq = HWGROUP(drive)-rq;
-
-   /*
-* handle dma case
-*/
-   if (dma) {
-   info-dma = 0;
-   dma_error = HWIF(drive)-ide_dma_end(drive);
-   if (dma_error) {
-   printk(KERN_ERR %s: DMA read error\n, drive-name);
-   ide_dma_off(drive);
-   }
-   }
-
-   if (cdrom_decode_status(drive, 0, stat))
-   return ide_stopped;
-
-   if (dma) {
-   if (!dma_error) {
-   ide_end_request(drive, 1, rq-nr_sectors);
-   return ide_stopped;
-   } else
-   return ide_error(drive, dma error, stat);
-   }
-
-   /* Read the interrupt reason and the transfer length. */
-   ireason = HWIF(drive)-INB(IDE_IREASON_REG)  0x3;
-   lowcyl  = HWIF(drive)-INB(IDE_BCOUNTL_REG);
-   highcyl = HWIF(drive)-INB(IDE_BCOUNTH_REG);
-
-   len = lowcyl + (256 * highcyl);
-
-   /* If DRQ is clear, the command has completed. */
-   if ((stat  DRQ_STAT) == 0) {
-   /* If we're not done filling the current buffer, complain.
-  Otherwise, complete the command normally. */
-   if (rq-current_nr_sectors  0) {
-   printk (KERN_ERR %s: cdrom_read_intr: data underrun 
(%d blocks)\n,
-   drive-name, rq-current_nr_sectors);
-   rq-cmd_flags |= REQ_FAILED;
-   cdrom_end_request(drive, 0);
-   } else
-   cdrom_end_request(drive, 1);
-   return ide_stopped;
-   }
-
-   /* Check that the drive is expecting to do the same thing we are. */
-   if (cdrom_read_check_ireason (drive, len, ireason))
-   return ide_stopped;
-
-   if (ide_cd_check_transfer_size(drive, len)) {
-   cdrom_end_request(drive, 0);
-   return ide_stopped;
-   }
-
-   /* The number of sectors we need to read from the drive. */
-   sectors_to_transfer = len / SECTOR_SIZE;
-
-   /* First, figure out if we need to bit-bucket
-  any of the leading sectors. */
-   nskip = min_t(int, rq-current_nr_sectors - bio_cur_sectors(rq-bio), 
sectors_to_transfer);
-
-   if (nskip  0) {
-   ide_cd_drain_data(drive, nskip);
-   rq-current_nr_sectors -= nskip;
-   sectors_to_transfer -= nskip;
-   }
-
-   /* Now loop while we still have data to read from the drive. */
-   while (sectors_to_transfer  0) {
-   int this_transfer;
-
-   /* If we've filled the present buffer but there's another
-  chained buffer after it, move on. */
-   if (rq-current_nr_sectors == 0  rq-nr_sectors)
-   cdrom_end_request(drive, 1);
-
-   /* If the buffers are full, cache the rest of the data in our
-  internal buffer. */
-   if (rq-current_nr_sectors == 0) {
-   cdrom_buffer_sectors(drive, rq-sector, 
sectors_to_transfer);
-   sectors_to_transfer = 0;
-   } else {
-   /* Transfer data to the buffers.
-  Figure out how many sectors we can transfer
-  to the current buffer. */
-   this_transfer = min_t(int, sectors_to_transfer,
-rq-current_nr_sectors);
-
-   /* Read this_transfer sectors
-  into the current buffer. */
-   while (this_transfer  0) {
-   HWIF(drive)-atapi_input_bytes(drive, 
rq-buffer, SECTOR_SIZE);
-   rq-buffer += SECTOR_SIZE;
-   --rq-nr_sectors;
-   --rq-current_nr_sectors;
-   ++rq-sector

[PATCH 53/63] ide-cd: factor out transfer size checking from cdrom_read_intr()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

This is a preparation for cdrom_read_intr() and cdrom_write_intr() merge.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
+26 bytes
 drivers/ide/ide-cd.c |   38 ++
 1 file changed, 26 insertions(+), 12 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -714,6 +714,31 @@ int cdrom_read_check_ireason (ide_drive_
 }
 
 /*
+ * Assume that the drive will always provide data in multiples of at least
+ * SECTOR_SIZE, as it gets hairy to keep track of the transfers otherwise.
+ */
+static int ide_cd_check_transfer_size(ide_drive_t *drive, int len)
+{
+   struct cdrom_info *cd = drive-driver_data;
+
+   if ((len % SECTOR_SIZE) == 0)
+   return 0;
+
+   printk(KERN_ERR %s: %s: Bad transfer size %d\n,
+   drive-name, __FUNCTION__, len);
+
+   if (cd-cd_flags  IDE_CD_FLAG_LIMIT_NFRAMES)
+   printk(KERN_ERR   This drive is not supported by 
+   this version of the driver\n);
+   else {
+   printk(KERN_ERR   Trying to limit transfer sizes\n);
+   cd-cd_flags |= IDE_CD_FLAG_LIMIT_NFRAMES;
+   }
+
+   return 1;
+}
+
+/*
  * Interrupt routine.  Called when a read request has completed.
  */
 static ide_startstop_t cdrom_read_intr (ide_drive_t *drive)
@@ -774,18 +799,7 @@ static ide_startstop_t cdrom_read_intr (
if (cdrom_read_check_ireason (drive, len, ireason))
return ide_stopped;
 
-   /* Assume that the drive will always provide data in multiples
-  of at least SECTOR_SIZE, as it gets hairy to keep track
-  of the transfers otherwise. */
-   if ((len % SECTOR_SIZE) != 0) {
-   printk (KERN_ERR %s: cdrom_read_intr: Bad transfer size %d\n,
-   drive-name, len);
-   if (info-cd_flags  IDE_CD_FLAG_LIMIT_NFRAMES)
-   printk (KERN_ERR   This drive is not supported by this 
version of the driver\n);
-   else {
-   printk (KERN_ERR   Trying to limit transfer sizes\n);
-   info-cd_flags |= IDE_CD_FLAG_LIMIT_NFRAMES;
-   }
+   if (ide_cd_check_transfer_size(drive, len)) {
cdrom_end_request(drive, 0);
return ide_stopped;
}
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 52/63] ide-cd: add ide_cd_drain_data() helper

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Add ide_cd_drain_data() and use it in cdrom_{buffer_sectors,read_intr}()
(as a nice side-effect this cuts 0.5kB of code from ide-cd.o).

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-511 bytes
 drivers/ide/ide-cd.c |   28 +++-
 1 file changed, 15 insertions(+), 13 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -626,6 +626,16 @@ static void ide_cd_pad_transfer(ide_driv
}
 }
 
+static void ide_cd_drain_data(ide_drive_t *drive, int nsects)
+{
+   while (nsects  0) {
+   static char dum[SECTOR_SIZE];
+
+   drive-hwif-atapi_input_bytes(drive, dum, sizeof(dum));
+   nsects--;
+   }
+}
+
 /*
  * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector
  * buffer.  Once the first sector is added, any subsequent sectors are
@@ -664,11 +674,7 @@ static void cdrom_buffer_sectors (ide_dr
}
 
/* Throw away any remaining data. */
-   while (sectors_to_transfer  0) {
-   static char dum[SECTOR_SIZE];
-   HWIF(drive)-atapi_input_bytes(drive, dum, sizeof (dum));
-   --sectors_to_transfer;
-   }
+   ide_cd_drain_data(drive, sectors_to_transfer);
 }
 
 /*
@@ -791,14 +797,10 @@ static ide_startstop_t cdrom_read_intr (
   any of the leading sectors. */
nskip = min_t(int, rq-current_nr_sectors - bio_cur_sectors(rq-bio), 
sectors_to_transfer);
 
-   while (nskip  0) {
-   /* We need to throw away a sector. */
-   static char dum[SECTOR_SIZE];
-   HWIF(drive)-atapi_input_bytes(drive, dum, sizeof (dum));
-
-   --rq-current_nr_sectors;
-   --nskip;
-   --sectors_to_transfer;
+   if (nskip  0) {
+   ide_cd_drain_data(drive, nskip);
+   rq-current_nr_sectors -= nskip;
+   sectors_to_transfer -= nskip;
}
 
/* Now loop while we still have data to read from the drive. */
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 50/63] ide-cd: remove cdrom_do_pc_continuation()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

cdrom_do_pc_continuation() is now identical to cdrom_do_newpc_cont()
so just always use the latter function.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-49 bytes
 drivers/ide/ide-cd.c |   15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1061,18 +1061,7 @@ static void ide_cd_request_sense_fixup(s
}
 }
 
-static ide_startstop_t cdrom_newpc_intr(ide_drive_t *);
-
-static ide_startstop_t cdrom_do_pc_continuation (ide_drive_t *drive)
-{
-   struct request *rq = HWGROUP(drive)-rq;
-
-   if (!rq-timeout)
-   rq-timeout = ATAPI_WAIT_PC;
-
-   /* Send the command to the drive and return. */
-   return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr);
-}
+static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *);
 
 static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive)
 {
@@ -1085,7 +1074,7 @@ static ide_startstop_t cdrom_do_packet_c
len = rq-data_len;
 
/* Start sending the command to the drive. */
-   return cdrom_start_packet_command(drive, len, cdrom_do_pc_continuation);
+   return cdrom_start_packet_command(drive, len, cdrom_do_newpc_cont);
 }
 
 int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq)
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 49/63] ide-cd: merge cdrom_pc_intr() and cdrom_newpc_intr()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

Add handling of REQ_TYPE_{SENSE,ATA_PC} requests to cdrom_newpc_intr()
(please note that these requests never have 'bio' attached to them
and they never use DMA), then remove no longer needed cdrom_pc_intr().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
-264 bytes
 drivers/ide/ide-cd.c |  159 +--
 1 file changed, 55 insertions(+), 104 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1061,90 +1061,7 @@ static void ide_cd_request_sense_fixup(s
}
 }
 
-/* Interrupt routine for packet command completion. */
-static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
-{
-   struct request *rq = HWGROUP(drive)-rq;
-   xfer_func_t *xferfunc = NULL;
-   int stat, ireason, len, thislen, write, update;
-   u8 lowcyl = 0, highcyl = 0;
-
-   /* Check for errors. */
-   if (cdrom_decode_status(drive, 0, stat))
-   return ide_stopped;
-
-   /* Read the interrupt reason and the transfer length. */
-   ireason = HWIF(drive)-INB(IDE_IREASON_REG)  0x3;
-   lowcyl  = HWIF(drive)-INB(IDE_BCOUNTL_REG);
-   highcyl = HWIF(drive)-INB(IDE_BCOUNTH_REG);
-
-   len = lowcyl + (256 * highcyl);
-
-   /* If DRQ is clear, the command has completed.
-  Complain if we still have data left to transfer. */
-   if ((stat  DRQ_STAT) == 0) {
-   ide_cd_request_sense_fixup(rq);
-   update = rq-data_len ? 0 : 1;
-   goto end_request;
-   }
-
-   /* Figure out how much data to transfer. */
-   thislen = rq-data_len;
-   if (thislen  len)
-   thislen = len;
-
-   if (ireason == 0) {
-   write = 1;
-   xferfunc = HWIF(drive)-atapi_output_bytes;
-   } else if (ireason == 2) {
-   write = 0;
-   xferfunc = HWIF(drive)-atapi_input_bytes;
-   }
-
-   if (xferfunc) {
-   if (!rq-data) {
-   printk(KERN_ERR %s: confused, missing data\n,
-   drive-name);
-   blk_dump_rq_flags(rq, write ? cdrom_pc_intr, write
-   : cdrom_pc_intr, read);
-   goto pad;
-   }
-   /* Transfer the data. */
-   xferfunc(drive, rq-data, thislen);
-
-   /* Keep count of how much data we've moved. */
-   len -= thislen;
-   rq-data += thislen;
-   rq-data_len -= thislen;
-
-   if (write  blk_sense_request(rq))
-   rq-sense_len += thislen;
-   } else {
-   printk (KERN_ERR %s: cdrom_pc_intr: The drive 
-   appears confused (ireason = 0x%02x). 
-   Trying to recover by ending request.\n,
-   drive-name, ireason);
-   update = 0;
-   goto end_request;
-   }
-pad:
-   /*
-* If we haven't moved enough data to satisfy the drive,
-* add some padding.
-*/
-   if (len  0)
-   ide_cd_pad_transfer(drive, xferfunc, len);
-
-   /* Now we wait for another interrupt. */
-   ide_set_handler(drive, cdrom_pc_intr, ATAPI_WAIT_PC, 
cdrom_timer_expiry);
-   return ide_started;
-
-end_request:
-   if (!update)
-   rq-cmd_flags |= REQ_FAILED;
-   cdrom_end_request(drive, update);
-   return ide_stopped;
-}
+static ide_startstop_t cdrom_newpc_intr(ide_drive_t *);
 
 static ide_startstop_t cdrom_do_pc_continuation (ide_drive_t *drive)
 {
@@ -1154,10 +1071,9 @@ static ide_startstop_t cdrom_do_pc_conti
rq-timeout = ATAPI_WAIT_PC;
 
/* Send the command to the drive and return. */
-   return cdrom_transfer_packet_command(drive, rq, cdrom_pc_intr);
+   return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr);
 }
 
-
 static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive)
 {
int len;
@@ -1252,27 +1168,27 @@ static int cdrom_write_check_ireason(ide
 /*
  * best way to deal with dma that is not sector aligned right now... note
  * that in this path we are not using -data or -buffer at all. this irs
- * can replace cdrom_pc_intr, cdrom_read_intr, and cdrom_write_intr in the
- * future.
+ * can replace cdrom_read_intr() and cdrom_write_intr() in the future.
  */
 static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
 {
struct cdrom_info *info = drive-driver_data;
struct request *rq = HWGROUP(drive)-rq;
-   int dma_error, dma, stat, ireason, len, thislen;
-   u8 lowcyl, highcyl;
xfer_func_t *xferfunc;
-   unsigned long flags;
+   ide_expiry_t *expiry;
+   int dma_error = 0, dma, stat, ireason, len

[PATCH 48/63] ide-cd: unify request end exit path in cdrom_pc_intr()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

This is a preparation for cdrom_pc_intr() and cdrom_newpc_intr() merge.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
+10 bytes
 drivers/ide/ide-cd.c |   23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1066,7 +1066,7 @@ static ide_startstop_t cdrom_pc_intr (id
 {
struct request *rq = HWGROUP(drive)-rq;
xfer_func_t *xferfunc = NULL;
-   int stat, ireason, len, thislen, write;
+   int stat, ireason, len, thislen, write, update;
u8 lowcyl = 0, highcyl = 0;
 
/* Check for errors. */
@@ -1084,14 +1084,8 @@ static ide_startstop_t cdrom_pc_intr (id
   Complain if we still have data left to transfer. */
if ((stat  DRQ_STAT) == 0) {
ide_cd_request_sense_fixup(rq);
-
-   if (rq-data_len == 0)
-   cdrom_end_request(drive, 1);
-   else {
-   rq-cmd_flags |= REQ_FAILED;
-   cdrom_end_request(drive, 0);
-   }
-   return ide_stopped;
+   update = rq-data_len ? 0 : 1;
+   goto end_request;
}
 
/* Figure out how much data to transfer. */
@@ -1130,9 +1124,8 @@ static ide_startstop_t cdrom_pc_intr (id
appears confused (ireason = 0x%02x). 
Trying to recover by ending request.\n,
drive-name, ireason);
-   rq-cmd_flags |= REQ_FAILED;
-   cdrom_end_request(drive, 0);
-   return ide_stopped;
+   update = 0;
+   goto end_request;
}
 pad:
/*
@@ -1145,6 +1138,12 @@ pad:
/* Now we wait for another interrupt. */
ide_set_handler(drive, cdrom_pc_intr, ATAPI_WAIT_PC, 
cdrom_timer_expiry);
return ide_started;
+
+end_request:
+   if (!update)
+   rq-cmd_flags |= REQ_FAILED;
+   cdrom_end_request(drive, update);
+   return ide_stopped;
 }
 
 static ide_startstop_t cdrom_do_pc_continuation (ide_drive_t *drive)
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 47/63] ide-cd: factor out request sense fixup from cdrom_pc_intr()

2007-12-19 Thread Bartlomiej Zolnierkiewicz

This is a preparation for cdrom_pc_intr() and cdrom_newpc_intr() merge.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |   25 +++--
 1 file changed, 15 insertions(+), 10 deletions(-)

Index: b/drivers/ide/ide-cd.c
===
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1047,6 +1047,20 @@ static ide_startstop_t cdrom_start_read 
  * Execute all other packet commands.
  */
 
+static void ide_cd_request_sense_fixup(struct request *rq)
+{
+   /*
+* Some of the trailing request sense fields are optional,
+* and some drives don't send them.  Sigh.
+*/
+   if (rq-cmd[0] == GPCMD_REQUEST_SENSE 
+   rq-data_len  0  rq-data_len = 5)
+   while (rq-data_len  0) {
+   *(u8 *)rq-data++ = 0;
+   --rq-data_len;
+   }
+}
+
 /* Interrupt routine for packet command completion. */
 static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
 {
@@ -1069,16 +1083,7 @@ static ide_startstop_t cdrom_pc_intr (id
/* If DRQ is clear, the command has completed.
   Complain if we still have data left to transfer. */
if ((stat  DRQ_STAT) == 0) {
-   /* Some of the trailing request sense fields are optional, and
-  some drives don't send them.  Sigh. */
-   if (rq-cmd[0] == GPCMD_REQUEST_SENSE 
-   rq-data_len  0 
-   rq-data_len = 5) {
-   while (rq-data_len  0) {
-   *(unsigned char *)rq-data++ = 0;
-   --rq-data_len;
-   }
-   }
+   ide_cd_request_sense_fixup(rq);
 
if (rq-data_len == 0)
cdrom_end_request(drive, 1);
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


<    1   2   3   4   5   6   7   8   9   10   >