diff options
Diffstat (limited to 'drivers')
215 files changed, 9765 insertions, 6144 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index ae19c9b30d15..ba8f7f4dfa11 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
@@ -69,7 +69,7 @@ config ATA_PIIX | |||
69 | 69 | ||
70 | config SATA_MV | 70 | config SATA_MV |
71 | tristate "Marvell SATA support (HIGHLY EXPERIMENTAL)" | 71 | tristate "Marvell SATA support (HIGHLY EXPERIMENTAL)" |
72 | depends on PCI && EXPERIMENTAL | 72 | depends on EXPERIMENTAL |
73 | help | 73 | help |
74 | This option enables support for the Marvell Serial ATA family. | 74 | This option enables support for the Marvell Serial ATA family. |
75 | Currently supports 88SX[56]0[48][01] chips. | 75 | Currently supports 88SX[56]0[48][01] chips. |
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 6f089b899a1a..27c8d56111c2 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -475,6 +475,8 @@ static const struct pci_device_id ahci_pci_tbl[] = { | |||
475 | { PCI_VDEVICE(INTEL, 0x294e), board_ahci }, /* ICH9M */ | 475 | { PCI_VDEVICE(INTEL, 0x294e), board_ahci }, /* ICH9M */ |
476 | { PCI_VDEVICE(INTEL, 0x502a), board_ahci }, /* Tolapai */ | 476 | { PCI_VDEVICE(INTEL, 0x502a), board_ahci }, /* Tolapai */ |
477 | { PCI_VDEVICE(INTEL, 0x502b), board_ahci }, /* Tolapai */ | 477 | { PCI_VDEVICE(INTEL, 0x502b), board_ahci }, /* Tolapai */ |
478 | { PCI_VDEVICE(INTEL, 0x3a05), board_ahci }, /* ICH10 */ | ||
479 | { PCI_VDEVICE(INTEL, 0x3a25), board_ahci }, /* ICH10 */ | ||
478 | 480 | ||
479 | /* JMicron 360/1/3/5/6, match class to avoid IDE function */ | 481 | /* JMicron 360/1/3/5/6, match class to avoid IDE function */ |
480 | { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, | 482 | { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, |
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index a65c8ae5c461..47892e6f5ded 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c | |||
@@ -267,6 +267,14 @@ static const struct pci_device_id piix_pci_tbl[] = { | |||
267 | { 0x8086, 0x292e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | 267 | { 0x8086, 0x292e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, |
268 | /* SATA Controller IDE (Tolapai) */ | 268 | /* SATA Controller IDE (Tolapai) */ |
269 | { 0x8086, 0x5028, PCI_ANY_ID, PCI_ANY_ID, 0, 0, tolapai_sata_ahci }, | 269 | { 0x8086, 0x5028, PCI_ANY_ID, PCI_ANY_ID, 0, 0, tolapai_sata_ahci }, |
270 | /* SATA Controller IDE (ICH10) */ | ||
271 | { 0x8086, 0x3a00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | ||
272 | /* SATA Controller IDE (ICH10) */ | ||
273 | { 0x8086, 0x3a06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, | ||
274 | /* SATA Controller IDE (ICH10) */ | ||
275 | { 0x8086, 0x3a20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | ||
276 | /* SATA Controller IDE (ICH10) */ | ||
277 | { 0x8086, 0x3a26, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, | ||
270 | 278 | ||
271 | { } /* terminate list */ | 279 | { } /* terminate list */ |
272 | }; | 280 | }; |
@@ -1068,7 +1076,7 @@ static void piix_sidpr_write(struct ata_device *dev, unsigned int reg, u32 val) | |||
1068 | iowrite32(val, hpriv->sidpr + PIIX_SIDPR_DATA); | 1076 | iowrite32(val, hpriv->sidpr + PIIX_SIDPR_DATA); |
1069 | } | 1077 | } |
1070 | 1078 | ||
1071 | u32 piix_merge_scr(u32 val0, u32 val1, const int * const *merge_tbl) | 1079 | static u32 piix_merge_scr(u32 val0, u32 val1, const int * const *merge_tbl) |
1072 | { | 1080 | { |
1073 | u32 val = 0; | 1081 | u32 val = 0; |
1074 | int i, mi; | 1082 | int i, mi; |
diff --git a/drivers/ata/pata_bf54x.c b/drivers/ata/pata_bf54x.c index a32e3c44a606..7f87f105c2f6 100644 --- a/drivers/ata/pata_bf54x.c +++ b/drivers/ata/pata_bf54x.c | |||
@@ -299,7 +299,7 @@ static void bfin_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
299 | */ | 299 | */ |
300 | n6 = num_clocks_min(t6min, fsclk); | 300 | n6 = num_clocks_min(t6min, fsclk); |
301 | if (mode >= 0 && mode <= 4 && n6 >= 1) { | 301 | if (mode >= 0 && mode <= 4 && n6 >= 1) { |
302 | pr_debug("set piomode: mode=%d, fsclk=%ud\n", mode, fsclk); | 302 | dev_dbg(adev->link->ap->dev, "set piomode: mode=%d, fsclk=%ud\n", mode, fsclk); |
303 | /* calculate the timing values for register transfers. */ | 303 | /* calculate the timing values for register transfers. */ |
304 | while (mode > 0 && pio_fsclk[mode] > fsclk) | 304 | while (mode > 0 && pio_fsclk[mode] > fsclk) |
305 | mode--; | 305 | mode--; |
@@ -376,7 +376,7 @@ static void bfin_set_dmamode(struct ata_port *ap, struct ata_device *adev) | |||
376 | 376 | ||
377 | mode = adev->dma_mode - XFER_UDMA_0; | 377 | mode = adev->dma_mode - XFER_UDMA_0; |
378 | if (mode >= 0 && mode <= 5) { | 378 | if (mode >= 0 && mode <= 5) { |
379 | pr_debug("set udmamode: mode=%d\n", mode); | 379 | dev_dbg(adev->link->ap->dev, "set udmamode: mode=%d\n", mode); |
380 | /* the most restrictive timing value is t6 and tc, | 380 | /* the most restrictive timing value is t6 and tc, |
381 | * the DIOW - data hold. If one SCLK pulse is longer | 381 | * the DIOW - data hold. If one SCLK pulse is longer |
382 | * than this minimum value then register | 382 | * than this minimum value then register |
@@ -433,7 +433,7 @@ static void bfin_set_dmamode(struct ata_port *ap, struct ata_device *adev) | |||
433 | 433 | ||
434 | mode = adev->dma_mode - XFER_MW_DMA_0; | 434 | mode = adev->dma_mode - XFER_MW_DMA_0; |
435 | if (mode >= 0 && mode <= 2) { | 435 | if (mode >= 0 && mode <= 2) { |
436 | pr_debug("set mdmamode: mode=%d\n", mode); | 436 | dev_dbg(adev->link->ap->dev, "set mdmamode: mode=%d\n", mode); |
437 | /* the most restrictive timing value is tf, the DMACK to | 437 | /* the most restrictive timing value is tf, the DMACK to |
438 | * read data released. If one SCLK pulse is longer than | 438 | * read data released. If one SCLK pulse is longer than |
439 | * this maximum value then the MDMA mode | 439 | * this maximum value then the MDMA mode |
@@ -697,7 +697,7 @@ static void bfin_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) | |||
697 | write_atapi_register(base, ATA_REG_LBAL, tf->hob_lbal); | 697 | write_atapi_register(base, ATA_REG_LBAL, tf->hob_lbal); |
698 | write_atapi_register(base, ATA_REG_LBAM, tf->hob_lbam); | 698 | write_atapi_register(base, ATA_REG_LBAM, tf->hob_lbam); |
699 | write_atapi_register(base, ATA_REG_LBAH, tf->hob_lbah); | 699 | write_atapi_register(base, ATA_REG_LBAH, tf->hob_lbah); |
700 | pr_debug("hob: feat 0x%X nsect 0x%X, lba 0x%X " | 700 | dev_dbg(ap->dev, "hob: feat 0x%X nsect 0x%X, lba 0x%X " |
701 | "0x%X 0x%X\n", | 701 | "0x%X 0x%X\n", |
702 | tf->hob_feature, | 702 | tf->hob_feature, |
703 | tf->hob_nsect, | 703 | tf->hob_nsect, |
@@ -711,7 +711,7 @@ static void bfin_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) | |||
711 | write_atapi_register(base, ATA_REG_LBAL, tf->lbal); | 711 | write_atapi_register(base, ATA_REG_LBAL, tf->lbal); |
712 | write_atapi_register(base, ATA_REG_LBAM, tf->lbam); | 712 | write_atapi_register(base, ATA_REG_LBAM, tf->lbam); |
713 | write_atapi_register(base, ATA_REG_LBAH, tf->lbah); | 713 | write_atapi_register(base, ATA_REG_LBAH, tf->lbah); |
714 | pr_debug("feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n", | 714 | dev_dbg(ap->dev, "feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n", |
715 | tf->feature, | 715 | tf->feature, |
716 | tf->nsect, | 716 | tf->nsect, |
717 | tf->lbal, | 717 | tf->lbal, |
@@ -721,7 +721,7 @@ static void bfin_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) | |||
721 | 721 | ||
722 | if (tf->flags & ATA_TFLAG_DEVICE) { | 722 | if (tf->flags & ATA_TFLAG_DEVICE) { |
723 | write_atapi_register(base, ATA_REG_DEVICE, tf->device); | 723 | write_atapi_register(base, ATA_REG_DEVICE, tf->device); |
724 | pr_debug("device 0x%X\n", tf->device); | 724 | dev_dbg(ap->dev, "device 0x%X\n", tf->device); |
725 | } | 725 | } |
726 | 726 | ||
727 | ata_wait_idle(ap); | 727 | ata_wait_idle(ap); |
@@ -782,7 +782,7 @@ static void bfin_exec_command(struct ata_port *ap, | |||
782 | const struct ata_taskfile *tf) | 782 | const struct ata_taskfile *tf) |
783 | { | 783 | { |
784 | void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; | 784 | void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; |
785 | pr_debug("ata%u: cmd 0x%X\n", ap->print_id, tf->command); | 785 | dev_dbg(ap->dev, "ata%u: cmd 0x%X\n", ap->print_id, tf->command); |
786 | 786 | ||
787 | write_atapi_register(base, ATA_REG_CMD, tf->command); | 787 | write_atapi_register(base, ATA_REG_CMD, tf->command); |
788 | ata_pause(ap); | 788 | ata_pause(ap); |
@@ -834,7 +834,7 @@ static void bfin_bmdma_setup(struct ata_queued_cmd *qc) | |||
834 | struct scatterlist *sg; | 834 | struct scatterlist *sg; |
835 | unsigned int si; | 835 | unsigned int si; |
836 | 836 | ||
837 | pr_debug("in atapi dma setup\n"); | 837 | dev_dbg(qc->ap->dev, "in atapi dma setup\n"); |
838 | /* Program the ATA_CTRL register with dir */ | 838 | /* Program the ATA_CTRL register with dir */ |
839 | if (qc->tf.flags & ATA_TFLAG_WRITE) { | 839 | if (qc->tf.flags & ATA_TFLAG_WRITE) { |
840 | /* fill the ATAPI DMA controller */ | 840 | /* fill the ATAPI DMA controller */ |
@@ -870,7 +870,7 @@ static void bfin_bmdma_start(struct ata_queued_cmd *qc) | |||
870 | struct scatterlist *sg; | 870 | struct scatterlist *sg; |
871 | unsigned int si; | 871 | unsigned int si; |
872 | 872 | ||
873 | pr_debug("in atapi dma start\n"); | 873 | dev_dbg(qc->ap->dev, "in atapi dma start\n"); |
874 | if (!(ap->udma_mask || ap->mwdma_mask)) | 874 | if (!(ap->udma_mask || ap->mwdma_mask)) |
875 | return; | 875 | return; |
876 | 876 | ||
@@ -888,7 +888,7 @@ static void bfin_bmdma_start(struct ata_queued_cmd *qc) | |||
888 | sg_dma_address(sg) + sg_dma_len(sg)); | 888 | sg_dma_address(sg) + sg_dma_len(sg)); |
889 | } | 889 | } |
890 | enable_dma(CH_ATAPI_TX); | 890 | enable_dma(CH_ATAPI_TX); |
891 | pr_debug("enable udma write\n"); | 891 | dev_dbg(qc->ap->dev, "enable udma write\n"); |
892 | 892 | ||
893 | /* Send ATA DMA write command */ | 893 | /* Send ATA DMA write command */ |
894 | bfin_exec_command(ap, &qc->tf); | 894 | bfin_exec_command(ap, &qc->tf); |
@@ -898,7 +898,7 @@ static void bfin_bmdma_start(struct ata_queued_cmd *qc) | |||
898 | | XFER_DIR)); | 898 | | XFER_DIR)); |
899 | } else { | 899 | } else { |
900 | enable_dma(CH_ATAPI_RX); | 900 | enable_dma(CH_ATAPI_RX); |
901 | pr_debug("enable udma read\n"); | 901 | dev_dbg(qc->ap->dev, "enable udma read\n"); |
902 | 902 | ||
903 | /* Send ATA DMA read command */ | 903 | /* Send ATA DMA read command */ |
904 | bfin_exec_command(ap, &qc->tf); | 904 | bfin_exec_command(ap, &qc->tf); |
@@ -936,7 +936,7 @@ static void bfin_bmdma_stop(struct ata_queued_cmd *qc) | |||
936 | struct scatterlist *sg; | 936 | struct scatterlist *sg; |
937 | unsigned int si; | 937 | unsigned int si; |
938 | 938 | ||
939 | pr_debug("in atapi dma stop\n"); | 939 | dev_dbg(qc->ap->dev, "in atapi dma stop\n"); |
940 | if (!(ap->udma_mask || ap->mwdma_mask)) | 940 | if (!(ap->udma_mask || ap->mwdma_mask)) |
941 | return; | 941 | return; |
942 | 942 | ||
@@ -1147,15 +1147,15 @@ static unsigned char bfin_bmdma_status(struct ata_port *ap) | |||
1147 | void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; | 1147 | void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; |
1148 | unsigned short int_status = ATAPI_GET_INT_STATUS(base); | 1148 | unsigned short int_status = ATAPI_GET_INT_STATUS(base); |
1149 | 1149 | ||
1150 | if (ATAPI_GET_STATUS(base) & (MULTI_XFER_ON|ULTRA_XFER_ON)) { | 1150 | if (ATAPI_GET_STATUS(base) & (MULTI_XFER_ON|ULTRA_XFER_ON)) |
1151 | host_stat |= ATA_DMA_ACTIVE; | 1151 | host_stat |= ATA_DMA_ACTIVE; |
1152 | } | 1152 | if (int_status & (MULTI_DONE_INT|UDMAIN_DONE_INT|UDMAOUT_DONE_INT| |
1153 | if (int_status & (MULTI_DONE_INT|UDMAIN_DONE_INT|UDMAOUT_DONE_INT)) { | 1153 | ATAPI_DEV_INT)) |
1154 | host_stat |= ATA_DMA_INTR; | 1154 | host_stat |= ATA_DMA_INTR; |
1155 | } | 1155 | if (int_status & (MULTI_TERM_INT|UDMAIN_TERM_INT|UDMAOUT_TERM_INT)) |
1156 | if (int_status & (MULTI_TERM_INT|UDMAIN_TERM_INT|UDMAOUT_TERM_INT)) { | 1156 | host_stat |= ATA_DMA_ERR|ATA_DMA_INTR; |
1157 | host_stat |= ATA_DMA_ERR; | 1157 | |
1158 | } | 1158 | dev_dbg(ap->dev, "ATAPI: host_stat=0x%x\n", host_stat); |
1159 | 1159 | ||
1160 | return host_stat; | 1160 | return host_stat; |
1161 | } | 1161 | } |
@@ -1213,8 +1213,7 @@ static void bfin_irq_clear(struct ata_port *ap) | |||
1213 | { | 1213 | { |
1214 | void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; | 1214 | void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; |
1215 | 1215 | ||
1216 | pr_debug("in atapi irq clear\n"); | 1216 | dev_dbg(ap->dev, "in atapi irq clear\n"); |
1217 | |||
1218 | ATAPI_SET_INT_STATUS(base, ATAPI_GET_INT_STATUS(base)|ATAPI_DEV_INT | 1217 | ATAPI_SET_INT_STATUS(base, ATAPI_GET_INT_STATUS(base)|ATAPI_DEV_INT |
1219 | | MULTI_DONE_INT | UDMAIN_DONE_INT | UDMAOUT_DONE_INT | 1218 | | MULTI_DONE_INT | UDMAIN_DONE_INT | UDMAOUT_DONE_INT |
1220 | | MULTI_TERM_INT | UDMAIN_TERM_INT | UDMAOUT_TERM_INT); | 1219 | | MULTI_TERM_INT | UDMAIN_TERM_INT | UDMAOUT_TERM_INT); |
@@ -1232,7 +1231,7 @@ static unsigned char bfin_irq_on(struct ata_port *ap) | |||
1232 | void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; | 1231 | void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; |
1233 | u8 tmp; | 1232 | u8 tmp; |
1234 | 1233 | ||
1235 | pr_debug("in atapi irq on\n"); | 1234 | dev_dbg(ap->dev, "in atapi irq on\n"); |
1236 | ap->ctl &= ~ATA_NIEN; | 1235 | ap->ctl &= ~ATA_NIEN; |
1237 | ap->last_ctl = ap->ctl; | 1236 | ap->last_ctl = ap->ctl; |
1238 | 1237 | ||
@@ -1255,7 +1254,7 @@ static void bfin_bmdma_freeze(struct ata_port *ap) | |||
1255 | { | 1254 | { |
1256 | void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; | 1255 | void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; |
1257 | 1256 | ||
1258 | pr_debug("in atapi dma freeze\n"); | 1257 | dev_dbg(ap->dev, "in atapi dma freeze\n"); |
1259 | ap->ctl |= ATA_NIEN; | 1258 | ap->ctl |= ATA_NIEN; |
1260 | ap->last_ctl = ap->ctl; | 1259 | ap->last_ctl = ap->ctl; |
1261 | 1260 | ||
@@ -1328,7 +1327,7 @@ static void bfin_error_handler(struct ata_port *ap) | |||
1328 | 1327 | ||
1329 | static void bfin_port_stop(struct ata_port *ap) | 1328 | static void bfin_port_stop(struct ata_port *ap) |
1330 | { | 1329 | { |
1331 | pr_debug("in atapi port stop\n"); | 1330 | dev_dbg(ap->dev, "in atapi port stop\n"); |
1332 | if (ap->udma_mask != 0 || ap->mwdma_mask != 0) { | 1331 | if (ap->udma_mask != 0 || ap->mwdma_mask != 0) { |
1333 | free_dma(CH_ATAPI_RX); | 1332 | free_dma(CH_ATAPI_RX); |
1334 | free_dma(CH_ATAPI_TX); | 1333 | free_dma(CH_ATAPI_TX); |
@@ -1337,7 +1336,7 @@ static void bfin_port_stop(struct ata_port *ap) | |||
1337 | 1336 | ||
1338 | static int bfin_port_start(struct ata_port *ap) | 1337 | static int bfin_port_start(struct ata_port *ap) |
1339 | { | 1338 | { |
1340 | pr_debug("in atapi port start\n"); | 1339 | dev_dbg(ap->dev, "in atapi port start\n"); |
1341 | if (!(ap->udma_mask || ap->mwdma_mask)) | 1340 | if (!(ap->udma_mask || ap->mwdma_mask)) |
1342 | return 0; | 1341 | return 0; |
1343 | 1342 | ||
@@ -1373,10 +1372,6 @@ static struct scsi_host_template bfin_sht = { | |||
1373 | .slave_configure = ata_scsi_slave_config, | 1372 | .slave_configure = ata_scsi_slave_config, |
1374 | .slave_destroy = ata_scsi_slave_destroy, | 1373 | .slave_destroy = ata_scsi_slave_destroy, |
1375 | .bios_param = ata_std_bios_param, | 1374 | .bios_param = ata_std_bios_param, |
1376 | #ifdef CONFIG_PM | ||
1377 | .resume = ata_scsi_device_resume, | ||
1378 | .suspend = ata_scsi_device_suspend, | ||
1379 | #endif | ||
1380 | }; | 1375 | }; |
1381 | 1376 | ||
1382 | static const struct ata_port_operations bfin_pata_ops = { | 1377 | static const struct ata_port_operations bfin_pata_ops = { |
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c index 1388cef52c07..81ef207f8265 100644 --- a/drivers/ata/pata_sl82c105.c +++ b/drivers/ata/pata_sl82c105.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/libata.h> | 26 | #include <linux/libata.h> |
27 | 27 | ||
28 | #define DRV_NAME "pata_sl82c105" | 28 | #define DRV_NAME "pata_sl82c105" |
29 | #define DRV_VERSION "0.3.2" | 29 | #define DRV_VERSION "0.3.3" |
30 | 30 | ||
31 | enum { | 31 | enum { |
32 | /* | 32 | /* |
@@ -206,6 +206,34 @@ static void sl82c105_bmdma_stop(struct ata_queued_cmd *qc) | |||
206 | sl82c105_set_piomode(ap, qc->dev); | 206 | sl82c105_set_piomode(ap, qc->dev); |
207 | } | 207 | } |
208 | 208 | ||
209 | /** | ||
210 | * sl82c105_qc_defer - implement serialization | ||
211 | * @qc: command | ||
212 | * | ||
213 | * We must issue one command per host not per channel because | ||
214 | * of the reset bug. | ||
215 | * | ||
216 | * Q: is the scsi host lock sufficient ? | ||
217 | */ | ||
218 | |||
219 | static int sl82c105_qc_defer(struct ata_queued_cmd *qc) | ||
220 | { | ||
221 | struct ata_host *host = qc->ap->host; | ||
222 | struct ata_port *alt = host->ports[1 ^ qc->ap->port_no]; | ||
223 | int rc; | ||
224 | |||
225 | /* First apply the usual rules */ | ||
226 | rc = ata_std_qc_defer(qc); | ||
227 | if (rc != 0) | ||
228 | return rc; | ||
229 | |||
230 | /* Now apply serialization rules. Only allow a command if the | ||
231 | other channel state machine is idle */ | ||
232 | if (alt && alt->qc_active) | ||
233 | return ATA_DEFER_PORT; | ||
234 | return 0; | ||
235 | } | ||
236 | |||
209 | static struct scsi_host_template sl82c105_sht = { | 237 | static struct scsi_host_template sl82c105_sht = { |
210 | .module = THIS_MODULE, | 238 | .module = THIS_MODULE, |
211 | .name = DRV_NAME, | 239 | .name = DRV_NAME, |
@@ -245,6 +273,7 @@ static struct ata_port_operations sl82c105_port_ops = { | |||
245 | .bmdma_stop = sl82c105_bmdma_stop, | 273 | .bmdma_stop = sl82c105_bmdma_stop, |
246 | .bmdma_status = ata_bmdma_status, | 274 | .bmdma_status = ata_bmdma_status, |
247 | 275 | ||
276 | .qc_defer = sl82c105_qc_defer, | ||
248 | .qc_prep = ata_qc_prep, | 277 | .qc_prep = ata_qc_prep, |
249 | .qc_issue = ata_qc_issue_prot, | 278 | .qc_issue = ata_qc_issue_prot, |
250 | 279 | ||
@@ -312,7 +341,7 @@ static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id | |||
312 | }; | 341 | }; |
313 | /* for now use only the first port */ | 342 | /* for now use only the first port */ |
314 | const struct ata_port_info *ppi[] = { &info_early, | 343 | const struct ata_port_info *ppi[] = { &info_early, |
315 | &ata_dummy_port_info }; | 344 | NULL }; |
316 | u32 val; | 345 | u32 val; |
317 | int rev; | 346 | int rev; |
318 | 347 | ||
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index 7e72463a90eb..3c1b5c9027db 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
@@ -29,7 +29,13 @@ | |||
29 | I distinctly remember a couple workarounds (one related to PCI-X) | 29 | I distinctly remember a couple workarounds (one related to PCI-X) |
30 | are still needed. | 30 | are still needed. |
31 | 31 | ||
32 | 4) Add NCQ support (easy to intermediate, once new-EH support appears) | 32 | 2) Improve/fix IRQ and error handling sequences. |
33 | |||
34 | 3) ATAPI support (Marvell claims the 60xx/70xx chips can do it). | ||
35 | |||
36 | 4) Think about TCQ support here, and for libata in general | ||
37 | with controllers that suppport it via host-queuing hardware | ||
38 | (a software-only implementation could be a nightmare). | ||
33 | 39 | ||
34 | 5) Investigate problems with PCI Message Signalled Interrupts (MSI). | 40 | 5) Investigate problems with PCI Message Signalled Interrupts (MSI). |
35 | 41 | ||
@@ -53,8 +59,6 @@ | |||
53 | Target mode, for those without docs, is the ability to directly | 59 | Target mode, for those without docs, is the ability to directly |
54 | connect two SATA controllers. | 60 | connect two SATA controllers. |
55 | 61 | ||
56 | 13) Verify that 7042 is fully supported. I only have a 6042. | ||
57 | |||
58 | */ | 62 | */ |
59 | 63 | ||
60 | 64 | ||
@@ -73,7 +77,7 @@ | |||
73 | #include <linux/libata.h> | 77 | #include <linux/libata.h> |
74 | 78 | ||
75 | #define DRV_NAME "sata_mv" | 79 | #define DRV_NAME "sata_mv" |
76 | #define DRV_VERSION "1.01" | 80 | #define DRV_VERSION "1.20" |
77 | 81 | ||
78 | enum { | 82 | enum { |
79 | /* BAR's are enumerated in terms of pci_resource_start() terms */ | 83 | /* BAR's are enumerated in terms of pci_resource_start() terms */ |
@@ -107,14 +111,12 @@ enum { | |||
107 | 111 | ||
108 | /* CRQB needs alignment on a 1KB boundary. Size == 1KB | 112 | /* CRQB needs alignment on a 1KB boundary. Size == 1KB |
109 | * CRPB needs alignment on a 256B boundary. Size == 256B | 113 | * CRPB needs alignment on a 256B boundary. Size == 256B |
110 | * SG count of 176 leads to MV_PORT_PRIV_DMA_SZ == 4KB | ||
111 | * ePRD (SG) entries need alignment on a 16B boundary. Size == 16B | 114 | * ePRD (SG) entries need alignment on a 16B boundary. Size == 16B |
112 | */ | 115 | */ |
113 | MV_CRQB_Q_SZ = (32 * MV_MAX_Q_DEPTH), | 116 | MV_CRQB_Q_SZ = (32 * MV_MAX_Q_DEPTH), |
114 | MV_CRPB_Q_SZ = (8 * MV_MAX_Q_DEPTH), | 117 | MV_CRPB_Q_SZ = (8 * MV_MAX_Q_DEPTH), |
115 | MV_MAX_SG_CT = 176, | 118 | MV_MAX_SG_CT = 256, |
116 | MV_SG_TBL_SZ = (16 * MV_MAX_SG_CT), | 119 | MV_SG_TBL_SZ = (16 * MV_MAX_SG_CT), |
117 | MV_PORT_PRIV_DMA_SZ = (MV_CRQB_Q_SZ + MV_CRPB_Q_SZ + MV_SG_TBL_SZ), | ||
118 | 120 | ||
119 | MV_PORTS_PER_HC = 4, | 121 | MV_PORTS_PER_HC = 4, |
120 | /* == (port / MV_PORTS_PER_HC) to determine HC from 0-7 port */ | 122 | /* == (port / MV_PORTS_PER_HC) to determine HC from 0-7 port */ |
@@ -125,6 +127,9 @@ enum { | |||
125 | /* Host Flags */ | 127 | /* Host Flags */ |
126 | MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */ | 128 | MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */ |
127 | MV_FLAG_IRQ_COALESCE = (1 << 29), /* IRQ coalescing capability */ | 129 | MV_FLAG_IRQ_COALESCE = (1 << 29), /* IRQ coalescing capability */ |
130 | /* SoC integrated controllers, no PCI interface */ | ||
131 | MV_FLAG_SOC = (1 << 28), | ||
132 | |||
128 | MV_COMMON_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 133 | MV_COMMON_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
129 | ATA_FLAG_MMIO | ATA_FLAG_NO_ATAPI | | 134 | ATA_FLAG_MMIO | ATA_FLAG_NO_ATAPI | |
130 | ATA_FLAG_PIO_POLLING, | 135 | ATA_FLAG_PIO_POLLING, |
@@ -170,7 +175,7 @@ enum { | |||
170 | 175 | ||
171 | PCIE_IRQ_CAUSE_OFS = 0x1900, | 176 | PCIE_IRQ_CAUSE_OFS = 0x1900, |
172 | PCIE_IRQ_MASK_OFS = 0x1910, | 177 | PCIE_IRQ_MASK_OFS = 0x1910, |
173 | PCIE_UNMASK_ALL_IRQS = 0x70a, /* assorted bits */ | 178 | PCIE_UNMASK_ALL_IRQS = 0x40a, /* assorted bits */ |
174 | 179 | ||
175 | HC_MAIN_IRQ_CAUSE_OFS = 0x1d60, | 180 | HC_MAIN_IRQ_CAUSE_OFS = 0x1d60, |
176 | HC_MAIN_IRQ_MASK_OFS = 0x1d64, | 181 | HC_MAIN_IRQ_MASK_OFS = 0x1d64, |
@@ -210,6 +215,7 @@ enum { | |||
210 | /* SATA registers */ | 215 | /* SATA registers */ |
211 | SATA_STATUS_OFS = 0x300, /* ctrl, err regs follow status */ | 216 | SATA_STATUS_OFS = 0x300, /* ctrl, err regs follow status */ |
212 | SATA_ACTIVE_OFS = 0x350, | 217 | SATA_ACTIVE_OFS = 0x350, |
218 | SATA_FIS_IRQ_CAUSE_OFS = 0x364, | ||
213 | PHY_MODE3 = 0x310, | 219 | PHY_MODE3 = 0x310, |
214 | PHY_MODE4 = 0x314, | 220 | PHY_MODE4 = 0x314, |
215 | PHY_MODE2 = 0x330, | 221 | PHY_MODE2 = 0x330, |
@@ -222,11 +228,11 @@ enum { | |||
222 | 228 | ||
223 | /* Port registers */ | 229 | /* Port registers */ |
224 | EDMA_CFG_OFS = 0, | 230 | EDMA_CFG_OFS = 0, |
225 | EDMA_CFG_Q_DEPTH = 0, /* queueing disabled */ | 231 | EDMA_CFG_Q_DEPTH = 0x1f, /* max device queue depth */ |
226 | EDMA_CFG_NCQ = (1 << 5), | 232 | EDMA_CFG_NCQ = (1 << 5), /* for R/W FPDMA queued */ |
227 | EDMA_CFG_NCQ_GO_ON_ERR = (1 << 14), /* continue on error */ | 233 | EDMA_CFG_NCQ_GO_ON_ERR = (1 << 14), /* continue on error */ |
228 | EDMA_CFG_RD_BRST_EXT = (1 << 11), /* read burst 512B */ | 234 | EDMA_CFG_RD_BRST_EXT = (1 << 11), /* read burst 512B */ |
229 | EDMA_CFG_WR_BUFF_LEN = (1 << 13), /* write buffer 512B */ | 235 | EDMA_CFG_WR_BUFF_LEN = (1 << 13), /* write buffer 512B */ |
230 | 236 | ||
231 | EDMA_ERR_IRQ_CAUSE_OFS = 0x8, | 237 | EDMA_ERR_IRQ_CAUSE_OFS = 0x8, |
232 | EDMA_ERR_IRQ_MASK_OFS = 0xc, | 238 | EDMA_ERR_IRQ_MASK_OFS = 0xc, |
@@ -244,14 +250,33 @@ enum { | |||
244 | EDMA_ERR_CRPB_PAR = (1 << 10), /* CRPB parity error */ | 250 | EDMA_ERR_CRPB_PAR = (1 << 10), /* CRPB parity error */ |
245 | EDMA_ERR_INTRL_PAR = (1 << 11), /* internal parity error */ | 251 | EDMA_ERR_INTRL_PAR = (1 << 11), /* internal parity error */ |
246 | EDMA_ERR_IORDY = (1 << 12), /* IORdy timeout */ | 252 | EDMA_ERR_IORDY = (1 << 12), /* IORdy timeout */ |
253 | |||
247 | EDMA_ERR_LNK_CTRL_RX = (0xf << 13), /* link ctrl rx error */ | 254 | EDMA_ERR_LNK_CTRL_RX = (0xf << 13), /* link ctrl rx error */ |
248 | EDMA_ERR_LNK_CTRL_RX_2 = (1 << 15), | 255 | EDMA_ERR_LNK_CTRL_RX_0 = (1 << 13), /* transient: CRC err */ |
256 | EDMA_ERR_LNK_CTRL_RX_1 = (1 << 14), /* transient: FIFO err */ | ||
257 | EDMA_ERR_LNK_CTRL_RX_2 = (1 << 15), /* fatal: caught SYNC */ | ||
258 | EDMA_ERR_LNK_CTRL_RX_3 = (1 << 16), /* transient: FIS rx err */ | ||
259 | |||
249 | EDMA_ERR_LNK_DATA_RX = (0xf << 17), /* link data rx error */ | 260 | EDMA_ERR_LNK_DATA_RX = (0xf << 17), /* link data rx error */ |
261 | |||
250 | EDMA_ERR_LNK_CTRL_TX = (0x1f << 21), /* link ctrl tx error */ | 262 | EDMA_ERR_LNK_CTRL_TX = (0x1f << 21), /* link ctrl tx error */ |
263 | EDMA_ERR_LNK_CTRL_TX_0 = (1 << 21), /* transient: CRC err */ | ||
264 | EDMA_ERR_LNK_CTRL_TX_1 = (1 << 22), /* transient: FIFO err */ | ||
265 | EDMA_ERR_LNK_CTRL_TX_2 = (1 << 23), /* transient: caught SYNC */ | ||
266 | EDMA_ERR_LNK_CTRL_TX_3 = (1 << 24), /* transient: caught DMAT */ | ||
267 | EDMA_ERR_LNK_CTRL_TX_4 = (1 << 25), /* transient: FIS collision */ | ||
268 | |||
251 | EDMA_ERR_LNK_DATA_TX = (0x1f << 26), /* link data tx error */ | 269 | EDMA_ERR_LNK_DATA_TX = (0x1f << 26), /* link data tx error */ |
270 | |||
252 | EDMA_ERR_TRANS_PROTO = (1 << 31), /* transport protocol error */ | 271 | EDMA_ERR_TRANS_PROTO = (1 << 31), /* transport protocol error */ |
253 | EDMA_ERR_OVERRUN_5 = (1 << 5), | 272 | EDMA_ERR_OVERRUN_5 = (1 << 5), |
254 | EDMA_ERR_UNDERRUN_5 = (1 << 6), | 273 | EDMA_ERR_UNDERRUN_5 = (1 << 6), |
274 | |||
275 | EDMA_ERR_IRQ_TRANSIENT = EDMA_ERR_LNK_CTRL_RX_0 | | ||
276 | EDMA_ERR_LNK_CTRL_RX_1 | | ||
277 | EDMA_ERR_LNK_CTRL_RX_3 | | ||
278 | EDMA_ERR_LNK_CTRL_TX, | ||
279 | |||
255 | EDMA_EH_FREEZE = EDMA_ERR_D_PAR | | 280 | EDMA_EH_FREEZE = EDMA_ERR_D_PAR | |
256 | EDMA_ERR_PRD_PAR | | 281 | EDMA_ERR_PRD_PAR | |
257 | EDMA_ERR_DEV_DCON | | 282 | EDMA_ERR_DEV_DCON | |
@@ -311,12 +336,14 @@ enum { | |||
311 | 336 | ||
312 | /* Port private flags (pp_flags) */ | 337 | /* Port private flags (pp_flags) */ |
313 | MV_PP_FLAG_EDMA_EN = (1 << 0), /* is EDMA engine enabled? */ | 338 | MV_PP_FLAG_EDMA_EN = (1 << 0), /* is EDMA engine enabled? */ |
339 | MV_PP_FLAG_NCQ_EN = (1 << 1), /* is EDMA set up for NCQ? */ | ||
314 | MV_PP_FLAG_HAD_A_RESET = (1 << 2), /* 1st hard reset complete? */ | 340 | MV_PP_FLAG_HAD_A_RESET = (1 << 2), /* 1st hard reset complete? */ |
315 | }; | 341 | }; |
316 | 342 | ||
317 | #define IS_GEN_I(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_I) | 343 | #define IS_GEN_I(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_I) |
318 | #define IS_GEN_II(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_II) | 344 | #define IS_GEN_II(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_II) |
319 | #define IS_GEN_IIE(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_IIE) | 345 | #define IS_GEN_IIE(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_IIE) |
346 | #define HAS_PCI(host) (!((host)->ports[0]->flags & MV_FLAG_SOC)) | ||
320 | 347 | ||
321 | enum { | 348 | enum { |
322 | /* DMA boundary 0xffff is required by the s/g splitting | 349 | /* DMA boundary 0xffff is required by the s/g splitting |
@@ -379,8 +406,8 @@ struct mv_port_priv { | |||
379 | dma_addr_t crqb_dma; | 406 | dma_addr_t crqb_dma; |
380 | struct mv_crpb *crpb; | 407 | struct mv_crpb *crpb; |
381 | dma_addr_t crpb_dma; | 408 | dma_addr_t crpb_dma; |
382 | struct mv_sg *sg_tbl; | 409 | struct mv_sg *sg_tbl[MV_MAX_Q_DEPTH]; |
383 | dma_addr_t sg_tbl_dma; | 410 | dma_addr_t sg_tbl_dma[MV_MAX_Q_DEPTH]; |
384 | 411 | ||
385 | unsigned int req_idx; | 412 | unsigned int req_idx; |
386 | unsigned int resp_idx; | 413 | unsigned int resp_idx; |
@@ -400,6 +427,14 @@ struct mv_host_priv { | |||
400 | u32 irq_cause_ofs; | 427 | u32 irq_cause_ofs; |
401 | u32 irq_mask_ofs; | 428 | u32 irq_mask_ofs; |
402 | u32 unmask_all_irqs; | 429 | u32 unmask_all_irqs; |
430 | /* | ||
431 | * These consistent DMA memory pools give us guaranteed | ||
432 | * alignment for hardware-accessed data structures, | ||
433 | * and less memory waste in accomplishing the alignment. | ||
434 | */ | ||
435 | struct dma_pool *crqb_pool; | ||
436 | struct dma_pool *crpb_pool; | ||
437 | struct dma_pool *sg_tbl_pool; | ||
403 | }; | 438 | }; |
404 | 439 | ||
405 | struct mv_hw_ops { | 440 | struct mv_hw_ops { |
@@ -411,7 +446,7 @@ struct mv_hw_ops { | |||
411 | int (*reset_hc)(struct mv_host_priv *hpriv, void __iomem *mmio, | 446 | int (*reset_hc)(struct mv_host_priv *hpriv, void __iomem *mmio, |
412 | unsigned int n_hc); | 447 | unsigned int n_hc); |
413 | void (*reset_flash)(struct mv_host_priv *hpriv, void __iomem *mmio); | 448 | void (*reset_flash)(struct mv_host_priv *hpriv, void __iomem *mmio); |
414 | void (*reset_bus)(struct pci_dev *pdev, void __iomem *mmio); | 449 | void (*reset_bus)(struct ata_host *host, void __iomem *mmio); |
415 | }; | 450 | }; |
416 | 451 | ||
417 | static void mv_irq_clear(struct ata_port *ap); | 452 | static void mv_irq_clear(struct ata_port *ap); |
@@ -425,10 +460,9 @@ static void mv_qc_prep(struct ata_queued_cmd *qc); | |||
425 | static void mv_qc_prep_iie(struct ata_queued_cmd *qc); | 460 | static void mv_qc_prep_iie(struct ata_queued_cmd *qc); |
426 | static unsigned int mv_qc_issue(struct ata_queued_cmd *qc); | 461 | static unsigned int mv_qc_issue(struct ata_queued_cmd *qc); |
427 | static void mv_error_handler(struct ata_port *ap); | 462 | static void mv_error_handler(struct ata_port *ap); |
428 | static void mv_post_int_cmd(struct ata_queued_cmd *qc); | ||
429 | static void mv_eh_freeze(struct ata_port *ap); | 463 | static void mv_eh_freeze(struct ata_port *ap); |
430 | static void mv_eh_thaw(struct ata_port *ap); | 464 | static void mv_eh_thaw(struct ata_port *ap); |
431 | static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); | 465 | static void mv6_dev_config(struct ata_device *dev); |
432 | 466 | ||
433 | static void mv5_phy_errata(struct mv_host_priv *hpriv, void __iomem *mmio, | 467 | static void mv5_phy_errata(struct mv_host_priv *hpriv, void __iomem *mmio, |
434 | unsigned int port); | 468 | unsigned int port); |
@@ -438,7 +472,7 @@ static void mv5_read_preamp(struct mv_host_priv *hpriv, int idx, | |||
438 | static int mv5_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio, | 472 | static int mv5_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio, |
439 | unsigned int n_hc); | 473 | unsigned int n_hc); |
440 | static void mv5_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio); | 474 | static void mv5_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio); |
441 | static void mv5_reset_bus(struct pci_dev *pdev, void __iomem *mmio); | 475 | static void mv5_reset_bus(struct ata_host *host, void __iomem *mmio); |
442 | 476 | ||
443 | static void mv6_phy_errata(struct mv_host_priv *hpriv, void __iomem *mmio, | 477 | static void mv6_phy_errata(struct mv_host_priv *hpriv, void __iomem *mmio, |
444 | unsigned int port); | 478 | unsigned int port); |
@@ -448,10 +482,17 @@ static void mv6_read_preamp(struct mv_host_priv *hpriv, int idx, | |||
448 | static int mv6_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio, | 482 | static int mv6_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio, |
449 | unsigned int n_hc); | 483 | unsigned int n_hc); |
450 | static void mv6_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio); | 484 | static void mv6_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio); |
451 | static void mv_reset_pci_bus(struct pci_dev *pdev, void __iomem *mmio); | 485 | static void mv_reset_pci_bus(struct ata_host *host, void __iomem *mmio); |
452 | static void mv_channel_reset(struct mv_host_priv *hpriv, void __iomem *mmio, | 486 | static void mv_channel_reset(struct mv_host_priv *hpriv, void __iomem *mmio, |
453 | unsigned int port_no); | 487 | unsigned int port_no); |
488 | static void mv_edma_cfg(struct mv_port_priv *pp, struct mv_host_priv *hpriv, | ||
489 | void __iomem *port_mmio, int want_ncq); | ||
490 | static int __mv_stop_dma(struct ata_port *ap); | ||
454 | 491 | ||
492 | /* .sg_tablesize is (MV_MAX_SG_CT / 2) in the structures below | ||
493 | * because we have to allow room for worst case splitting of | ||
494 | * PRDs for 64K boundaries in mv_fill_sg(). | ||
495 | */ | ||
455 | static struct scsi_host_template mv5_sht = { | 496 | static struct scsi_host_template mv5_sht = { |
456 | .module = THIS_MODULE, | 497 | .module = THIS_MODULE, |
457 | .name = DRV_NAME, | 498 | .name = DRV_NAME, |
@@ -475,7 +516,8 @@ static struct scsi_host_template mv6_sht = { | |||
475 | .name = DRV_NAME, | 516 | .name = DRV_NAME, |
476 | .ioctl = ata_scsi_ioctl, | 517 | .ioctl = ata_scsi_ioctl, |
477 | .queuecommand = ata_scsi_queuecmd, | 518 | .queuecommand = ata_scsi_queuecmd, |
478 | .can_queue = ATA_DEF_QUEUE, | 519 | .change_queue_depth = ata_scsi_change_queue_depth, |
520 | .can_queue = MV_MAX_Q_DEPTH - 1, | ||
479 | .this_id = ATA_SHT_THIS_ID, | 521 | .this_id = ATA_SHT_THIS_ID, |
480 | .sg_tablesize = MV_MAX_SG_CT / 2, | 522 | .sg_tablesize = MV_MAX_SG_CT / 2, |
481 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, | 523 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, |
@@ -505,7 +547,6 @@ static const struct ata_port_operations mv5_ops = { | |||
505 | .irq_on = ata_irq_on, | 547 | .irq_on = ata_irq_on, |
506 | 548 | ||
507 | .error_handler = mv_error_handler, | 549 | .error_handler = mv_error_handler, |
508 | .post_internal_cmd = mv_post_int_cmd, | ||
509 | .freeze = mv_eh_freeze, | 550 | .freeze = mv_eh_freeze, |
510 | .thaw = mv_eh_thaw, | 551 | .thaw = mv_eh_thaw, |
511 | 552 | ||
@@ -517,6 +558,7 @@ static const struct ata_port_operations mv5_ops = { | |||
517 | }; | 558 | }; |
518 | 559 | ||
519 | static const struct ata_port_operations mv6_ops = { | 560 | static const struct ata_port_operations mv6_ops = { |
561 | .dev_config = mv6_dev_config, | ||
520 | .tf_load = ata_tf_load, | 562 | .tf_load = ata_tf_load, |
521 | .tf_read = ata_tf_read, | 563 | .tf_read = ata_tf_read, |
522 | .check_status = ata_check_status, | 564 | .check_status = ata_check_status, |
@@ -533,9 +575,9 @@ static const struct ata_port_operations mv6_ops = { | |||
533 | .irq_on = ata_irq_on, | 575 | .irq_on = ata_irq_on, |
534 | 576 | ||
535 | .error_handler = mv_error_handler, | 577 | .error_handler = mv_error_handler, |
536 | .post_internal_cmd = mv_post_int_cmd, | ||
537 | .freeze = mv_eh_freeze, | 578 | .freeze = mv_eh_freeze, |
538 | .thaw = mv_eh_thaw, | 579 | .thaw = mv_eh_thaw, |
580 | .qc_defer = ata_std_qc_defer, | ||
539 | 581 | ||
540 | .scr_read = mv_scr_read, | 582 | .scr_read = mv_scr_read, |
541 | .scr_write = mv_scr_write, | 583 | .scr_write = mv_scr_write, |
@@ -561,9 +603,9 @@ static const struct ata_port_operations mv_iie_ops = { | |||
561 | .irq_on = ata_irq_on, | 603 | .irq_on = ata_irq_on, |
562 | 604 | ||
563 | .error_handler = mv_error_handler, | 605 | .error_handler = mv_error_handler, |
564 | .post_internal_cmd = mv_post_int_cmd, | ||
565 | .freeze = mv_eh_freeze, | 606 | .freeze = mv_eh_freeze, |
566 | .thaw = mv_eh_thaw, | 607 | .thaw = mv_eh_thaw, |
608 | .qc_defer = ata_std_qc_defer, | ||
567 | 609 | ||
568 | .scr_read = mv_scr_read, | 610 | .scr_read = mv_scr_read, |
569 | .scr_write = mv_scr_write, | 611 | .scr_write = mv_scr_write, |
@@ -592,26 +634,29 @@ static const struct ata_port_info mv_port_info[] = { | |||
592 | .port_ops = &mv5_ops, | 634 | .port_ops = &mv5_ops, |
593 | }, | 635 | }, |
594 | { /* chip_604x */ | 636 | { /* chip_604x */ |
595 | .flags = MV_COMMON_FLAGS | MV_6XXX_FLAGS, | 637 | .flags = MV_COMMON_FLAGS | MV_6XXX_FLAGS | |
638 | ATA_FLAG_NCQ, | ||
596 | .pio_mask = 0x1f, /* pio0-4 */ | 639 | .pio_mask = 0x1f, /* pio0-4 */ |
597 | .udma_mask = ATA_UDMA6, | 640 | .udma_mask = ATA_UDMA6, |
598 | .port_ops = &mv6_ops, | 641 | .port_ops = &mv6_ops, |
599 | }, | 642 | }, |
600 | { /* chip_608x */ | 643 | { /* chip_608x */ |
601 | .flags = MV_COMMON_FLAGS | MV_6XXX_FLAGS | | 644 | .flags = MV_COMMON_FLAGS | MV_6XXX_FLAGS | |
602 | MV_FLAG_DUAL_HC, | 645 | ATA_FLAG_NCQ | MV_FLAG_DUAL_HC, |
603 | .pio_mask = 0x1f, /* pio0-4 */ | 646 | .pio_mask = 0x1f, /* pio0-4 */ |
604 | .udma_mask = ATA_UDMA6, | 647 | .udma_mask = ATA_UDMA6, |
605 | .port_ops = &mv6_ops, | 648 | .port_ops = &mv6_ops, |
606 | }, | 649 | }, |
607 | { /* chip_6042 */ | 650 | { /* chip_6042 */ |
608 | .flags = MV_COMMON_FLAGS | MV_6XXX_FLAGS, | 651 | .flags = MV_COMMON_FLAGS | MV_6XXX_FLAGS | |
652 | ATA_FLAG_NCQ, | ||
609 | .pio_mask = 0x1f, /* pio0-4 */ | 653 | .pio_mask = 0x1f, /* pio0-4 */ |
610 | .udma_mask = ATA_UDMA6, | 654 | .udma_mask = ATA_UDMA6, |
611 | .port_ops = &mv_iie_ops, | 655 | .port_ops = &mv_iie_ops, |
612 | }, | 656 | }, |
613 | { /* chip_7042 */ | 657 | { /* chip_7042 */ |
614 | .flags = MV_COMMON_FLAGS | MV_6XXX_FLAGS, | 658 | .flags = MV_COMMON_FLAGS | MV_6XXX_FLAGS | |
659 | ATA_FLAG_NCQ, | ||
615 | .pio_mask = 0x1f, /* pio0-4 */ | 660 | .pio_mask = 0x1f, /* pio0-4 */ |
616 | .udma_mask = ATA_UDMA6, | 661 | .udma_mask = ATA_UDMA6, |
617 | .port_ops = &mv_iie_ops, | 662 | .port_ops = &mv_iie_ops, |
@@ -648,13 +693,6 @@ static const struct pci_device_id mv_pci_tbl[] = { | |||
648 | { } /* terminate list */ | 693 | { } /* terminate list */ |
649 | }; | 694 | }; |
650 | 695 | ||
651 | static struct pci_driver mv_pci_driver = { | ||
652 | .name = DRV_NAME, | ||
653 | .id_table = mv_pci_tbl, | ||
654 | .probe = mv_init_one, | ||
655 | .remove = ata_pci_remove_one, | ||
656 | }; | ||
657 | |||
658 | static const struct mv_hw_ops mv5xxx_ops = { | 696 | static const struct mv_hw_ops mv5xxx_ops = { |
659 | .phy_errata = mv5_phy_errata, | 697 | .phy_errata = mv5_phy_errata, |
660 | .enable_leds = mv5_enable_leds, | 698 | .enable_leds = mv5_enable_leds, |
@@ -674,45 +712,6 @@ static const struct mv_hw_ops mv6xxx_ops = { | |||
674 | }; | 712 | }; |
675 | 713 | ||
676 | /* | 714 | /* |
677 | * module options | ||
678 | */ | ||
679 | static int msi; /* Use PCI msi; either zero (off, default) or non-zero */ | ||
680 | |||
681 | |||
682 | /* move to PCI layer or libata core? */ | ||
683 | static int pci_go_64(struct pci_dev *pdev) | ||
684 | { | ||
685 | int rc; | ||
686 | |||
687 | if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) { | ||
688 | rc = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK); | ||
689 | if (rc) { | ||
690 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | ||
691 | if (rc) { | ||
692 | dev_printk(KERN_ERR, &pdev->dev, | ||
693 | "64-bit DMA enable failed\n"); | ||
694 | return rc; | ||
695 | } | ||
696 | } | ||
697 | } else { | ||
698 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | ||
699 | if (rc) { | ||
700 | dev_printk(KERN_ERR, &pdev->dev, | ||
701 | "32-bit DMA enable failed\n"); | ||
702 | return rc; | ||
703 | } | ||
704 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | ||
705 | if (rc) { | ||
706 | dev_printk(KERN_ERR, &pdev->dev, | ||
707 | "32-bit consistent DMA enable failed\n"); | ||
708 | return rc; | ||
709 | } | ||
710 | } | ||
711 | |||
712 | return rc; | ||
713 | } | ||
714 | |||
715 | /* | ||
716 | * Functions | 715 | * Functions |
717 | */ | 716 | */ |
718 | 717 | ||
@@ -815,19 +814,46 @@ static void mv_set_edma_ptrs(void __iomem *port_mmio, | |||
815 | * LOCKING: | 814 | * LOCKING: |
816 | * Inherited from caller. | 815 | * Inherited from caller. |
817 | */ | 816 | */ |
818 | static void mv_start_dma(void __iomem *base, struct mv_host_priv *hpriv, | 817 | static void mv_start_dma(struct ata_port *ap, void __iomem *port_mmio, |
819 | struct mv_port_priv *pp) | 818 | struct mv_port_priv *pp, u8 protocol) |
820 | { | 819 | { |
820 | int want_ncq = (protocol == ATA_PROT_NCQ); | ||
821 | |||
822 | if (pp->pp_flags & MV_PP_FLAG_EDMA_EN) { | ||
823 | int using_ncq = ((pp->pp_flags & MV_PP_FLAG_NCQ_EN) != 0); | ||
824 | if (want_ncq != using_ncq) | ||
825 | __mv_stop_dma(ap); | ||
826 | } | ||
821 | if (!(pp->pp_flags & MV_PP_FLAG_EDMA_EN)) { | 827 | if (!(pp->pp_flags & MV_PP_FLAG_EDMA_EN)) { |
828 | struct mv_host_priv *hpriv = ap->host->private_data; | ||
829 | int hard_port = mv_hardport_from_port(ap->port_no); | ||
830 | void __iomem *hc_mmio = mv_hc_base_from_port( | ||
831 | ap->host->iomap[MV_PRIMARY_BAR], hard_port); | ||
832 | u32 hc_irq_cause, ipending; | ||
833 | |||
822 | /* clear EDMA event indicators, if any */ | 834 | /* clear EDMA event indicators, if any */ |
823 | writelfl(0, base + EDMA_ERR_IRQ_CAUSE_OFS); | 835 | writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); |
836 | |||
837 | /* clear EDMA interrupt indicator, if any */ | ||
838 | hc_irq_cause = readl(hc_mmio + HC_IRQ_CAUSE_OFS); | ||
839 | ipending = (DEV_IRQ << hard_port) | | ||
840 | (CRPB_DMA_DONE << hard_port); | ||
841 | if (hc_irq_cause & ipending) { | ||
842 | writelfl(hc_irq_cause & ~ipending, | ||
843 | hc_mmio + HC_IRQ_CAUSE_OFS); | ||
844 | } | ||
845 | |||
846 | mv_edma_cfg(pp, hpriv, port_mmio, want_ncq); | ||
847 | |||
848 | /* clear FIS IRQ Cause */ | ||
849 | writelfl(0, port_mmio + SATA_FIS_IRQ_CAUSE_OFS); | ||
824 | 850 | ||
825 | mv_set_edma_ptrs(base, hpriv, pp); | 851 | mv_set_edma_ptrs(port_mmio, hpriv, pp); |
826 | 852 | ||
827 | writelfl(EDMA_EN, base + EDMA_CMD_OFS); | 853 | writelfl(EDMA_EN, port_mmio + EDMA_CMD_OFS); |
828 | pp->pp_flags |= MV_PP_FLAG_EDMA_EN; | 854 | pp->pp_flags |= MV_PP_FLAG_EDMA_EN; |
829 | } | 855 | } |
830 | WARN_ON(!(EDMA_EN & readl(base + EDMA_CMD_OFS))); | 856 | WARN_ON(!(EDMA_EN & readl(port_mmio + EDMA_CMD_OFS))); |
831 | } | 857 | } |
832 | 858 | ||
833 | /** | 859 | /** |
@@ -1003,38 +1029,76 @@ static int mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val) | |||
1003 | return -EINVAL; | 1029 | return -EINVAL; |
1004 | } | 1030 | } |
1005 | 1031 | ||
1006 | static void mv_edma_cfg(struct ata_port *ap, struct mv_host_priv *hpriv, | 1032 | static void mv6_dev_config(struct ata_device *adev) |
1007 | void __iomem *port_mmio) | ||
1008 | { | 1033 | { |
1009 | u32 cfg = readl(port_mmio + EDMA_CFG_OFS); | 1034 | /* |
1035 | * We don't have hob_nsect when doing NCQ commands on Gen-II. | ||
1036 | * See mv_qc_prep() for more info. | ||
1037 | */ | ||
1038 | if (adev->flags & ATA_DFLAG_NCQ) | ||
1039 | if (adev->max_sectors > ATA_MAX_SECTORS) | ||
1040 | adev->max_sectors = ATA_MAX_SECTORS; | ||
1041 | } | ||
1042 | |||
1043 | static void mv_edma_cfg(struct mv_port_priv *pp, struct mv_host_priv *hpriv, | ||
1044 | void __iomem *port_mmio, int want_ncq) | ||
1045 | { | ||
1046 | u32 cfg; | ||
1010 | 1047 | ||
1011 | /* set up non-NCQ EDMA configuration */ | 1048 | /* set up non-NCQ EDMA configuration */ |
1012 | cfg &= ~(1 << 9); /* disable eQue */ | 1049 | cfg = EDMA_CFG_Q_DEPTH; /* always 0x1f for *all* chips */ |
1013 | 1050 | ||
1014 | if (IS_GEN_I(hpriv)) { | 1051 | if (IS_GEN_I(hpriv)) |
1015 | cfg &= ~0x1f; /* clear queue depth */ | ||
1016 | cfg |= (1 << 8); /* enab config burst size mask */ | 1052 | cfg |= (1 << 8); /* enab config burst size mask */ |
1017 | } | ||
1018 | 1053 | ||
1019 | else if (IS_GEN_II(hpriv)) { | 1054 | else if (IS_GEN_II(hpriv)) |
1020 | cfg &= ~0x1f; /* clear queue depth */ | ||
1021 | cfg |= EDMA_CFG_RD_BRST_EXT | EDMA_CFG_WR_BUFF_LEN; | 1055 | cfg |= EDMA_CFG_RD_BRST_EXT | EDMA_CFG_WR_BUFF_LEN; |
1022 | cfg &= ~(EDMA_CFG_NCQ | EDMA_CFG_NCQ_GO_ON_ERR); /* clear NCQ */ | ||
1023 | } | ||
1024 | 1056 | ||
1025 | else if (IS_GEN_IIE(hpriv)) { | 1057 | else if (IS_GEN_IIE(hpriv)) { |
1026 | cfg |= (1 << 23); /* do not mask PM field in rx'd FIS */ | 1058 | cfg |= (1 << 23); /* do not mask PM field in rx'd FIS */ |
1027 | cfg |= (1 << 22); /* enab 4-entry host queue cache */ | 1059 | cfg |= (1 << 22); /* enab 4-entry host queue cache */ |
1028 | cfg &= ~(1 << 19); /* dis 128-entry queue (for now?) */ | ||
1029 | cfg |= (1 << 18); /* enab early completion */ | 1060 | cfg |= (1 << 18); /* enab early completion */ |
1030 | cfg |= (1 << 17); /* enab cut-through (dis stor&forwrd) */ | 1061 | cfg |= (1 << 17); /* enab cut-through (dis stor&forwrd) */ |
1031 | cfg &= ~(1 << 16); /* dis FIS-based switching (for now) */ | ||
1032 | cfg &= ~(EDMA_CFG_NCQ); /* clear NCQ */ | ||
1033 | } | 1062 | } |
1034 | 1063 | ||
1064 | if (want_ncq) { | ||
1065 | cfg |= EDMA_CFG_NCQ; | ||
1066 | pp->pp_flags |= MV_PP_FLAG_NCQ_EN; | ||
1067 | } else | ||
1068 | pp->pp_flags &= ~MV_PP_FLAG_NCQ_EN; | ||
1069 | |||
1035 | writelfl(cfg, port_mmio + EDMA_CFG_OFS); | 1070 | writelfl(cfg, port_mmio + EDMA_CFG_OFS); |
1036 | } | 1071 | } |
1037 | 1072 | ||
1073 | static void mv_port_free_dma_mem(struct ata_port *ap) | ||
1074 | { | ||
1075 | struct mv_host_priv *hpriv = ap->host->private_data; | ||
1076 | struct mv_port_priv *pp = ap->private_data; | ||
1077 | int tag; | ||
1078 | |||
1079 | if (pp->crqb) { | ||
1080 | dma_pool_free(hpriv->crqb_pool, pp->crqb, pp->crqb_dma); | ||
1081 | pp->crqb = NULL; | ||
1082 | } | ||
1083 | if (pp->crpb) { | ||
1084 | dma_pool_free(hpriv->crpb_pool, pp->crpb, pp->crpb_dma); | ||
1085 | pp->crpb = NULL; | ||
1086 | } | ||
1087 | /* | ||
1088 | * For GEN_I, there's no NCQ, so we have only a single sg_tbl. | ||
1089 | * For later hardware, we have one unique sg_tbl per NCQ tag. | ||
1090 | */ | ||
1091 | for (tag = 0; tag < MV_MAX_Q_DEPTH; ++tag) { | ||
1092 | if (pp->sg_tbl[tag]) { | ||
1093 | if (tag == 0 || !IS_GEN_I(hpriv)) | ||
1094 | dma_pool_free(hpriv->sg_tbl_pool, | ||
1095 | pp->sg_tbl[tag], | ||
1096 | pp->sg_tbl_dma[tag]); | ||
1097 | pp->sg_tbl[tag] = NULL; | ||
1098 | } | ||
1099 | } | ||
1100 | } | ||
1101 | |||
1038 | /** | 1102 | /** |
1039 | * mv_port_start - Port specific init/start routine. | 1103 | * mv_port_start - Port specific init/start routine. |
1040 | * @ap: ATA channel to manipulate | 1104 | * @ap: ATA channel to manipulate |
@@ -1051,51 +1115,47 @@ static int mv_port_start(struct ata_port *ap) | |||
1051 | struct mv_host_priv *hpriv = ap->host->private_data; | 1115 | struct mv_host_priv *hpriv = ap->host->private_data; |
1052 | struct mv_port_priv *pp; | 1116 | struct mv_port_priv *pp; |
1053 | void __iomem *port_mmio = mv_ap_base(ap); | 1117 | void __iomem *port_mmio = mv_ap_base(ap); |
1054 | void *mem; | ||
1055 | dma_addr_t mem_dma; | ||
1056 | unsigned long flags; | 1118 | unsigned long flags; |
1057 | int rc; | 1119 | int tag, rc; |
1058 | 1120 | ||
1059 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); | 1121 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); |
1060 | if (!pp) | 1122 | if (!pp) |
1061 | return -ENOMEM; | 1123 | return -ENOMEM; |
1062 | 1124 | ap->private_data = pp; | |
1063 | mem = dmam_alloc_coherent(dev, MV_PORT_PRIV_DMA_SZ, &mem_dma, | ||
1064 | GFP_KERNEL); | ||
1065 | if (!mem) | ||
1066 | return -ENOMEM; | ||
1067 | memset(mem, 0, MV_PORT_PRIV_DMA_SZ); | ||
1068 | 1125 | ||
1069 | rc = ata_pad_alloc(ap, dev); | 1126 | rc = ata_pad_alloc(ap, dev); |
1070 | if (rc) | 1127 | if (rc) |
1071 | return rc; | 1128 | return rc; |
1072 | 1129 | ||
1073 | /* First item in chunk of DMA memory: | 1130 | pp->crqb = dma_pool_alloc(hpriv->crqb_pool, GFP_KERNEL, &pp->crqb_dma); |
1074 | * 32-slot command request table (CRQB), 32 bytes each in size | 1131 | if (!pp->crqb) |
1075 | */ | 1132 | return -ENOMEM; |
1076 | pp->crqb = mem; | 1133 | memset(pp->crqb, 0, MV_CRQB_Q_SZ); |
1077 | pp->crqb_dma = mem_dma; | ||
1078 | mem += MV_CRQB_Q_SZ; | ||
1079 | mem_dma += MV_CRQB_Q_SZ; | ||
1080 | 1134 | ||
1081 | /* Second item: | 1135 | pp->crpb = dma_pool_alloc(hpriv->crpb_pool, GFP_KERNEL, &pp->crpb_dma); |
1082 | * 32-slot command response table (CRPB), 8 bytes each in size | 1136 | if (!pp->crpb) |
1083 | */ | 1137 | goto out_port_free_dma_mem; |
1084 | pp->crpb = mem; | 1138 | memset(pp->crpb, 0, MV_CRPB_Q_SZ); |
1085 | pp->crpb_dma = mem_dma; | ||
1086 | mem += MV_CRPB_Q_SZ; | ||
1087 | mem_dma += MV_CRPB_Q_SZ; | ||
1088 | 1139 | ||
1089 | /* Third item: | 1140 | /* |
1090 | * Table of scatter-gather descriptors (ePRD), 16 bytes each | 1141 | * For GEN_I, there's no NCQ, so we only allocate a single sg_tbl. |
1142 | * For later hardware, we need one unique sg_tbl per NCQ tag. | ||
1091 | */ | 1143 | */ |
1092 | pp->sg_tbl = mem; | 1144 | for (tag = 0; tag < MV_MAX_Q_DEPTH; ++tag) { |
1093 | pp->sg_tbl_dma = mem_dma; | 1145 | if (tag == 0 || !IS_GEN_I(hpriv)) { |
1146 | pp->sg_tbl[tag] = dma_pool_alloc(hpriv->sg_tbl_pool, | ||
1147 | GFP_KERNEL, &pp->sg_tbl_dma[tag]); | ||
1148 | if (!pp->sg_tbl[tag]) | ||
1149 | goto out_port_free_dma_mem; | ||
1150 | } else { | ||
1151 | pp->sg_tbl[tag] = pp->sg_tbl[0]; | ||
1152 | pp->sg_tbl_dma[tag] = pp->sg_tbl_dma[0]; | ||
1153 | } | ||
1154 | } | ||
1094 | 1155 | ||
1095 | spin_lock_irqsave(&ap->host->lock, flags); | 1156 | spin_lock_irqsave(&ap->host->lock, flags); |
1096 | 1157 | ||
1097 | mv_edma_cfg(ap, hpriv, port_mmio); | 1158 | mv_edma_cfg(pp, hpriv, port_mmio, 0); |
1098 | |||
1099 | mv_set_edma_ptrs(port_mmio, hpriv, pp); | 1159 | mv_set_edma_ptrs(port_mmio, hpriv, pp); |
1100 | 1160 | ||
1101 | spin_unlock_irqrestore(&ap->host->lock, flags); | 1161 | spin_unlock_irqrestore(&ap->host->lock, flags); |
@@ -1104,8 +1164,11 @@ static int mv_port_start(struct ata_port *ap) | |||
1104 | * we'll be unable to send non-data, PIO, etc due to restricted access | 1164 | * we'll be unable to send non-data, PIO, etc due to restricted access |
1105 | * to shadow regs. | 1165 | * to shadow regs. |
1106 | */ | 1166 | */ |
1107 | ap->private_data = pp; | ||
1108 | return 0; | 1167 | return 0; |
1168 | |||
1169 | out_port_free_dma_mem: | ||
1170 | mv_port_free_dma_mem(ap); | ||
1171 | return -ENOMEM; | ||
1109 | } | 1172 | } |
1110 | 1173 | ||
1111 | /** | 1174 | /** |
@@ -1120,6 +1183,7 @@ static int mv_port_start(struct ata_port *ap) | |||
1120 | static void mv_port_stop(struct ata_port *ap) | 1183 | static void mv_port_stop(struct ata_port *ap) |
1121 | { | 1184 | { |
1122 | mv_stop_dma(ap); | 1185 | mv_stop_dma(ap); |
1186 | mv_port_free_dma_mem(ap); | ||
1123 | } | 1187 | } |
1124 | 1188 | ||
1125 | /** | 1189 | /** |
@@ -1138,7 +1202,7 @@ static void mv_fill_sg(struct ata_queued_cmd *qc) | |||
1138 | struct mv_sg *mv_sg, *last_sg = NULL; | 1202 | struct mv_sg *mv_sg, *last_sg = NULL; |
1139 | unsigned int si; | 1203 | unsigned int si; |
1140 | 1204 | ||
1141 | mv_sg = pp->sg_tbl; | 1205 | mv_sg = pp->sg_tbl[qc->tag]; |
1142 | for_each_sg(qc->sg, sg, qc->n_elem, si) { | 1206 | for_each_sg(qc->sg, sg, qc->n_elem, si) { |
1143 | dma_addr_t addr = sg_dma_address(sg); | 1207 | dma_addr_t addr = sg_dma_address(sg); |
1144 | u32 sg_len = sg_dma_len(sg); | 1208 | u32 sg_len = sg_dma_len(sg); |
@@ -1194,7 +1258,8 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) | |||
1194 | u16 flags = 0; | 1258 | u16 flags = 0; |
1195 | unsigned in_index; | 1259 | unsigned in_index; |
1196 | 1260 | ||
1197 | if (qc->tf.protocol != ATA_PROT_DMA) | 1261 | if ((qc->tf.protocol != ATA_PROT_DMA) && |
1262 | (qc->tf.protocol != ATA_PROT_NCQ)) | ||
1198 | return; | 1263 | return; |
1199 | 1264 | ||
1200 | /* Fill in command request block | 1265 | /* Fill in command request block |
@@ -1203,15 +1268,14 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) | |||
1203 | flags |= CRQB_FLAG_READ; | 1268 | flags |= CRQB_FLAG_READ; |
1204 | WARN_ON(MV_MAX_Q_DEPTH <= qc->tag); | 1269 | WARN_ON(MV_MAX_Q_DEPTH <= qc->tag); |
1205 | flags |= qc->tag << CRQB_TAG_SHIFT; | 1270 | flags |= qc->tag << CRQB_TAG_SHIFT; |
1206 | flags |= qc->tag << CRQB_IOID_SHIFT; /* 50xx appears to ignore this*/ | ||
1207 | 1271 | ||
1208 | /* get current queue index from software */ | 1272 | /* get current queue index from software */ |
1209 | in_index = pp->req_idx & MV_MAX_Q_DEPTH_MASK; | 1273 | in_index = pp->req_idx & MV_MAX_Q_DEPTH_MASK; |
1210 | 1274 | ||
1211 | pp->crqb[in_index].sg_addr = | 1275 | pp->crqb[in_index].sg_addr = |
1212 | cpu_to_le32(pp->sg_tbl_dma & 0xffffffff); | 1276 | cpu_to_le32(pp->sg_tbl_dma[qc->tag] & 0xffffffff); |
1213 | pp->crqb[in_index].sg_addr_hi = | 1277 | pp->crqb[in_index].sg_addr_hi = |
1214 | cpu_to_le32((pp->sg_tbl_dma >> 16) >> 16); | 1278 | cpu_to_le32((pp->sg_tbl_dma[qc->tag] >> 16) >> 16); |
1215 | pp->crqb[in_index].ctrl_flags = cpu_to_le16(flags); | 1279 | pp->crqb[in_index].ctrl_flags = cpu_to_le16(flags); |
1216 | 1280 | ||
1217 | cw = &pp->crqb[in_index].ata_cmd[0]; | 1281 | cw = &pp->crqb[in_index].ata_cmd[0]; |
@@ -1231,13 +1295,11 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) | |||
1231 | case ATA_CMD_WRITE_FUA_EXT: | 1295 | case ATA_CMD_WRITE_FUA_EXT: |
1232 | mv_crqb_pack_cmd(cw++, tf->hob_nsect, ATA_REG_NSECT, 0); | 1296 | mv_crqb_pack_cmd(cw++, tf->hob_nsect, ATA_REG_NSECT, 0); |
1233 | break; | 1297 | break; |
1234 | #ifdef LIBATA_NCQ /* FIXME: remove this line when NCQ added */ | ||
1235 | case ATA_CMD_FPDMA_READ: | 1298 | case ATA_CMD_FPDMA_READ: |
1236 | case ATA_CMD_FPDMA_WRITE: | 1299 | case ATA_CMD_FPDMA_WRITE: |
1237 | mv_crqb_pack_cmd(cw++, tf->hob_feature, ATA_REG_FEATURE, 0); | 1300 | mv_crqb_pack_cmd(cw++, tf->hob_feature, ATA_REG_FEATURE, 0); |
1238 | mv_crqb_pack_cmd(cw++, tf->feature, ATA_REG_FEATURE, 0); | 1301 | mv_crqb_pack_cmd(cw++, tf->feature, ATA_REG_FEATURE, 0); |
1239 | break; | 1302 | break; |
1240 | #endif /* FIXME: remove this line when NCQ added */ | ||
1241 | default: | 1303 | default: |
1242 | /* The only other commands EDMA supports in non-queued and | 1304 | /* The only other commands EDMA supports in non-queued and |
1243 | * non-NCQ mode are: [RW] STREAM DMA and W DMA FUA EXT, none | 1305 | * non-NCQ mode are: [RW] STREAM DMA and W DMA FUA EXT, none |
@@ -1286,7 +1348,8 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc) | |||
1286 | unsigned in_index; | 1348 | unsigned in_index; |
1287 | u32 flags = 0; | 1349 | u32 flags = 0; |
1288 | 1350 | ||
1289 | if (qc->tf.protocol != ATA_PROT_DMA) | 1351 | if ((qc->tf.protocol != ATA_PROT_DMA) && |
1352 | (qc->tf.protocol != ATA_PROT_NCQ)) | ||
1290 | return; | 1353 | return; |
1291 | 1354 | ||
1292 | /* Fill in Gen IIE command request block | 1355 | /* Fill in Gen IIE command request block |
@@ -1296,15 +1359,14 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc) | |||
1296 | 1359 | ||
1297 | WARN_ON(MV_MAX_Q_DEPTH <= qc->tag); | 1360 | WARN_ON(MV_MAX_Q_DEPTH <= qc->tag); |
1298 | flags |= qc->tag << CRQB_TAG_SHIFT; | 1361 | flags |= qc->tag << CRQB_TAG_SHIFT; |
1299 | flags |= qc->tag << CRQB_IOID_SHIFT; /* "I/O Id" is -really- | 1362 | flags |= qc->tag << CRQB_HOSTQ_SHIFT; |
1300 | what we use as our tag */ | ||
1301 | 1363 | ||
1302 | /* get current queue index from software */ | 1364 | /* get current queue index from software */ |
1303 | in_index = pp->req_idx & MV_MAX_Q_DEPTH_MASK; | 1365 | in_index = pp->req_idx & MV_MAX_Q_DEPTH_MASK; |
1304 | 1366 | ||
1305 | crqb = (struct mv_crqb_iie *) &pp->crqb[in_index]; | 1367 | crqb = (struct mv_crqb_iie *) &pp->crqb[in_index]; |
1306 | crqb->addr = cpu_to_le32(pp->sg_tbl_dma & 0xffffffff); | 1368 | crqb->addr = cpu_to_le32(pp->sg_tbl_dma[qc->tag] & 0xffffffff); |
1307 | crqb->addr_hi = cpu_to_le32((pp->sg_tbl_dma >> 16) >> 16); | 1369 | crqb->addr_hi = cpu_to_le32((pp->sg_tbl_dma[qc->tag] >> 16) >> 16); |
1308 | crqb->flags = cpu_to_le32(flags); | 1370 | crqb->flags = cpu_to_le32(flags); |
1309 | 1371 | ||
1310 | tf = &qc->tf; | 1372 | tf = &qc->tf; |
@@ -1351,10 +1413,10 @@ static unsigned int mv_qc_issue(struct ata_queued_cmd *qc) | |||
1351 | struct ata_port *ap = qc->ap; | 1413 | struct ata_port *ap = qc->ap; |
1352 | void __iomem *port_mmio = mv_ap_base(ap); | 1414 | void __iomem *port_mmio = mv_ap_base(ap); |
1353 | struct mv_port_priv *pp = ap->private_data; | 1415 | struct mv_port_priv *pp = ap->private_data; |
1354 | struct mv_host_priv *hpriv = ap->host->private_data; | ||
1355 | u32 in_index; | 1416 | u32 in_index; |
1356 | 1417 | ||
1357 | if (qc->tf.protocol != ATA_PROT_DMA) { | 1418 | if ((qc->tf.protocol != ATA_PROT_DMA) && |
1419 | (qc->tf.protocol != ATA_PROT_NCQ)) { | ||
1358 | /* We're about to send a non-EDMA capable command to the | 1420 | /* We're about to send a non-EDMA capable command to the |
1359 | * port. Turn off EDMA so there won't be problems accessing | 1421 | * port. Turn off EDMA so there won't be problems accessing |
1360 | * shadow block, etc registers. | 1422 | * shadow block, etc registers. |
@@ -1363,13 +1425,7 @@ static unsigned int mv_qc_issue(struct ata_queued_cmd *qc) | |||
1363 | return ata_qc_issue_prot(qc); | 1425 | return ata_qc_issue_prot(qc); |
1364 | } | 1426 | } |
1365 | 1427 | ||
1366 | mv_start_dma(port_mmio, hpriv, pp); | 1428 | mv_start_dma(ap, port_mmio, pp, qc->tf.protocol); |
1367 | |||
1368 | in_index = pp->req_idx & MV_MAX_Q_DEPTH_MASK; | ||
1369 | |||
1370 | /* until we do queuing, the queue should be empty at this point */ | ||
1371 | WARN_ON(in_index != ((readl(port_mmio + EDMA_REQ_Q_OUT_PTR_OFS) | ||
1372 | >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK)); | ||
1373 | 1429 | ||
1374 | pp->req_idx++; | 1430 | pp->req_idx++; |
1375 | 1431 | ||
@@ -1437,6 +1493,7 @@ static void mv_err_intr(struct ata_port *ap, struct ata_queued_cmd *qc) | |||
1437 | ata_ehi_hotplugged(ehi); | 1493 | ata_ehi_hotplugged(ehi); |
1438 | ata_ehi_push_desc(ehi, edma_err_cause & EDMA_ERR_DEV_DCON ? | 1494 | ata_ehi_push_desc(ehi, edma_err_cause & EDMA_ERR_DEV_DCON ? |
1439 | "dev disconnect" : "dev connect"); | 1495 | "dev disconnect" : "dev connect"); |
1496 | action |= ATA_EH_HARDRESET; | ||
1440 | } | 1497 | } |
1441 | 1498 | ||
1442 | if (IS_GEN_I(hpriv)) { | 1499 | if (IS_GEN_I(hpriv)) { |
@@ -1465,7 +1522,7 @@ static void mv_err_intr(struct ata_port *ap, struct ata_queued_cmd *qc) | |||
1465 | } | 1522 | } |
1466 | 1523 | ||
1467 | /* Clear EDMA now that SERR cleanup done */ | 1524 | /* Clear EDMA now that SERR cleanup done */ |
1468 | writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); | 1525 | writelfl(~edma_err_cause, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); |
1469 | 1526 | ||
1470 | if (!err_mask) { | 1527 | if (!err_mask) { |
1471 | err_mask = AC_ERR_OTHER; | 1528 | err_mask = AC_ERR_OTHER; |
@@ -1538,23 +1595,17 @@ static void mv_intr_edma(struct ata_port *ap) | |||
1538 | * support for queueing. this works transparently for | 1595 | * support for queueing. this works transparently for |
1539 | * queued and non-queued modes. | 1596 | * queued and non-queued modes. |
1540 | */ | 1597 | */ |
1541 | else if (IS_GEN_II(hpriv)) | 1598 | else |
1542 | tag = (le16_to_cpu(pp->crpb[out_index].id) | 1599 | tag = le16_to_cpu(pp->crpb[out_index].id) & 0x1f; |
1543 | >> CRPB_IOID_SHIFT_6) & 0x3f; | ||
1544 | |||
1545 | else /* IS_GEN_IIE */ | ||
1546 | tag = (le16_to_cpu(pp->crpb[out_index].id) | ||
1547 | >> CRPB_IOID_SHIFT_7) & 0x3f; | ||
1548 | 1600 | ||
1549 | qc = ata_qc_from_tag(ap, tag); | 1601 | qc = ata_qc_from_tag(ap, tag); |
1550 | 1602 | ||
1551 | /* lower 8 bits of status are EDMA_ERR_IRQ_CAUSE_OFS | 1603 | /* For non-NCQ mode, the lower 8 bits of status |
1552 | * bits (WARNING: might not necessarily be associated | 1604 | * are from EDMA_ERR_IRQ_CAUSE_OFS, |
1553 | * with this command), which -should- be clear | 1605 | * which should be zero if all went well. |
1554 | * if all is well | ||
1555 | */ | 1606 | */ |
1556 | status = le16_to_cpu(pp->crpb[out_index].flags); | 1607 | status = le16_to_cpu(pp->crpb[out_index].flags); |
1557 | if (unlikely(status & 0xff)) { | 1608 | if ((status & 0xff) && !(pp->pp_flags & MV_PP_FLAG_NCQ_EN)) { |
1558 | mv_err_intr(ap, qc); | 1609 | mv_err_intr(ap, qc); |
1559 | return; | 1610 | return; |
1560 | } | 1611 | } |
@@ -1715,20 +1766,21 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance) | |||
1715 | struct ata_host *host = dev_instance; | 1766 | struct ata_host *host = dev_instance; |
1716 | unsigned int hc, handled = 0, n_hcs; | 1767 | unsigned int hc, handled = 0, n_hcs; |
1717 | void __iomem *mmio = host->iomap[MV_PRIMARY_BAR]; | 1768 | void __iomem *mmio = host->iomap[MV_PRIMARY_BAR]; |
1718 | u32 irq_stat; | 1769 | u32 irq_stat, irq_mask; |
1719 | 1770 | ||
1771 | spin_lock(&host->lock); | ||
1720 | irq_stat = readl(mmio + HC_MAIN_IRQ_CAUSE_OFS); | 1772 | irq_stat = readl(mmio + HC_MAIN_IRQ_CAUSE_OFS); |
1773 | irq_mask = readl(mmio + HC_MAIN_IRQ_MASK_OFS); | ||
1721 | 1774 | ||
1722 | /* check the cases where we either have nothing pending or have read | 1775 | /* check the cases where we either have nothing pending or have read |
1723 | * a bogus register value which can indicate HW removal or PCI fault | 1776 | * a bogus register value which can indicate HW removal or PCI fault |
1724 | */ | 1777 | */ |
1725 | if (!irq_stat || (0xffffffffU == irq_stat)) | 1778 | if (!(irq_stat & irq_mask) || (0xffffffffU == irq_stat)) |
1726 | return IRQ_NONE; | 1779 | goto out_unlock; |
1727 | 1780 | ||
1728 | n_hcs = mv_get_hc_count(host->ports[0]->flags); | 1781 | n_hcs = mv_get_hc_count(host->ports[0]->flags); |
1729 | spin_lock(&host->lock); | ||
1730 | 1782 | ||
1731 | if (unlikely(irq_stat & PCI_ERR)) { | 1783 | if (unlikely((irq_stat & PCI_ERR) && HAS_PCI(host))) { |
1732 | mv_pci_error(host, mmio); | 1784 | mv_pci_error(host, mmio); |
1733 | handled = 1; | 1785 | handled = 1; |
1734 | goto out_unlock; /* skip all other HC irq handling */ | 1786 | goto out_unlock; /* skip all other HC irq handling */ |
@@ -1799,8 +1851,9 @@ static int mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val) | |||
1799 | return -EINVAL; | 1851 | return -EINVAL; |
1800 | } | 1852 | } |
1801 | 1853 | ||
1802 | static void mv5_reset_bus(struct pci_dev *pdev, void __iomem *mmio) | 1854 | static void mv5_reset_bus(struct ata_host *host, void __iomem *mmio) |
1803 | { | 1855 | { |
1856 | struct pci_dev *pdev = to_pci_dev(host->dev); | ||
1804 | int early_5080; | 1857 | int early_5080; |
1805 | 1858 | ||
1806 | early_5080 = (pdev->device == 0x5080) && (pdev->revision == 0); | 1859 | early_5080 = (pdev->device == 0x5080) && (pdev->revision == 0); |
@@ -1811,7 +1864,7 @@ static void mv5_reset_bus(struct pci_dev *pdev, void __iomem *mmio) | |||
1811 | writel(tmp, mmio + MV_PCI_EXP_ROM_BAR_CTL); | 1864 | writel(tmp, mmio + MV_PCI_EXP_ROM_BAR_CTL); |
1812 | } | 1865 | } |
1813 | 1866 | ||
1814 | mv_reset_pci_bus(pdev, mmio); | 1867 | mv_reset_pci_bus(host, mmio); |
1815 | } | 1868 | } |
1816 | 1869 | ||
1817 | static void mv5_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio) | 1870 | static void mv5_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio) |
@@ -1935,9 +1988,8 @@ static int mv5_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio, | |||
1935 | 1988 | ||
1936 | #undef ZERO | 1989 | #undef ZERO |
1937 | #define ZERO(reg) writel(0, mmio + (reg)) | 1990 | #define ZERO(reg) writel(0, mmio + (reg)) |
1938 | static void mv_reset_pci_bus(struct pci_dev *pdev, void __iomem *mmio) | 1991 | static void mv_reset_pci_bus(struct ata_host *host, void __iomem *mmio) |
1939 | { | 1992 | { |
1940 | struct ata_host *host = dev_get_drvdata(&pdev->dev); | ||
1941 | struct mv_host_priv *hpriv = host->private_data; | 1993 | struct mv_host_priv *hpriv = host->private_data; |
1942 | u32 tmp; | 1994 | u32 tmp; |
1943 | 1995 | ||
@@ -2329,11 +2381,6 @@ static void mv_error_handler(struct ata_port *ap) | |||
2329 | mv_hardreset, mv_postreset); | 2381 | mv_hardreset, mv_postreset); |
2330 | } | 2382 | } |
2331 | 2383 | ||
2332 | static void mv_post_int_cmd(struct ata_queued_cmd *qc) | ||
2333 | { | ||
2334 | mv_stop_dma(qc->ap); | ||
2335 | } | ||
2336 | |||
2337 | static void mv_eh_freeze(struct ata_port *ap) | 2384 | static void mv_eh_freeze(struct ata_port *ap) |
2338 | { | 2385 | { |
2339 | void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR]; | 2386 | void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR]; |
@@ -2427,8 +2474,8 @@ static void mv_port_init(struct ata_ioports *port, void __iomem *port_mmio) | |||
2427 | writelfl(readl(port_mmio + serr_ofs), port_mmio + serr_ofs); | 2474 | writelfl(readl(port_mmio + serr_ofs), port_mmio + serr_ofs); |
2428 | writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); | 2475 | writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); |
2429 | 2476 | ||
2430 | /* unmask all EDMA error interrupts */ | 2477 | /* unmask all non-transient EDMA error interrupts */ |
2431 | writelfl(~0, port_mmio + EDMA_ERR_IRQ_MASK_OFS); | 2478 | writelfl(~EDMA_ERR_IRQ_TRANSIENT, port_mmio + EDMA_ERR_IRQ_MASK_OFS); |
2432 | 2479 | ||
2433 | VPRINTK("EDMA cfg=0x%08x EDMA IRQ err cause/mask=0x%08x/0x%08x\n", | 2480 | VPRINTK("EDMA cfg=0x%08x EDMA IRQ err cause/mask=0x%08x/0x%08x\n", |
2434 | readl(port_mmio + EDMA_CFG_OFS), | 2481 | readl(port_mmio + EDMA_CFG_OFS), |
@@ -2586,7 +2633,6 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx) | |||
2586 | static int mv_init_host(struct ata_host *host, unsigned int board_idx) | 2633 | static int mv_init_host(struct ata_host *host, unsigned int board_idx) |
2587 | { | 2634 | { |
2588 | int rc = 0, n_hc, port, hc; | 2635 | int rc = 0, n_hc, port, hc; |
2589 | struct pci_dev *pdev = to_pci_dev(host->dev); | ||
2590 | void __iomem *mmio = host->iomap[MV_PRIMARY_BAR]; | 2636 | void __iomem *mmio = host->iomap[MV_PRIMARY_BAR]; |
2591 | struct mv_host_priv *hpriv = host->private_data; | 2637 | struct mv_host_priv *hpriv = host->private_data; |
2592 | 2638 | ||
@@ -2607,7 +2653,7 @@ static int mv_init_host(struct ata_host *host, unsigned int board_idx) | |||
2607 | goto done; | 2653 | goto done; |
2608 | 2654 | ||
2609 | hpriv->ops->reset_flash(hpriv, mmio); | 2655 | hpriv->ops->reset_flash(hpriv, mmio); |
2610 | hpriv->ops->reset_bus(pdev, mmio); | 2656 | hpriv->ops->reset_bus(host, mmio); |
2611 | hpriv->ops->enable_leds(hpriv, mmio); | 2657 | hpriv->ops->enable_leds(hpriv, mmio); |
2612 | 2658 | ||
2613 | for (port = 0; port < host->n_ports; port++) { | 2659 | for (port = 0; port < host->n_ports; port++) { |
@@ -2630,8 +2676,10 @@ static int mv_init_host(struct ata_host *host, unsigned int board_idx) | |||
2630 | 2676 | ||
2631 | mv_port_init(&ap->ioaddr, port_mmio); | 2677 | mv_port_init(&ap->ioaddr, port_mmio); |
2632 | 2678 | ||
2679 | #ifdef CONFIG_PCI | ||
2633 | ata_port_pbar_desc(ap, MV_PRIMARY_BAR, -1, "mmio"); | 2680 | ata_port_pbar_desc(ap, MV_PRIMARY_BAR, -1, "mmio"); |
2634 | ata_port_pbar_desc(ap, MV_PRIMARY_BAR, offset, "port"); | 2681 | ata_port_pbar_desc(ap, MV_PRIMARY_BAR, offset, "port"); |
2682 | #endif | ||
2635 | } | 2683 | } |
2636 | 2684 | ||
2637 | for (hc = 0; hc < n_hc; hc++) { | 2685 | for (hc = 0; hc < n_hc; hc++) { |
@@ -2668,6 +2716,55 @@ done: | |||
2668 | return rc; | 2716 | return rc; |
2669 | } | 2717 | } |
2670 | 2718 | ||
2719 | #ifdef CONFIG_PCI | ||
2720 | static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); | ||
2721 | |||
2722 | static struct pci_driver mv_pci_driver = { | ||
2723 | .name = DRV_NAME, | ||
2724 | .id_table = mv_pci_tbl, | ||
2725 | .probe = mv_init_one, | ||
2726 | .remove = ata_pci_remove_one, | ||
2727 | }; | ||
2728 | |||
2729 | /* | ||
2730 | * module options | ||
2731 | */ | ||
2732 | static int msi; /* Use PCI msi; either zero (off, default) or non-zero */ | ||
2733 | |||
2734 | |||
2735 | /* move to PCI layer or libata core? */ | ||
2736 | static int pci_go_64(struct pci_dev *pdev) | ||
2737 | { | ||
2738 | int rc; | ||
2739 | |||
2740 | if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) { | ||
2741 | rc = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK); | ||
2742 | if (rc) { | ||
2743 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | ||
2744 | if (rc) { | ||
2745 | dev_printk(KERN_ERR, &pdev->dev, | ||
2746 | "64-bit DMA enable failed\n"); | ||
2747 | return rc; | ||
2748 | } | ||
2749 | } | ||
2750 | } else { | ||
2751 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | ||
2752 | if (rc) { | ||
2753 | dev_printk(KERN_ERR, &pdev->dev, | ||
2754 | "32-bit DMA enable failed\n"); | ||
2755 | return rc; | ||
2756 | } | ||
2757 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | ||
2758 | if (rc) { | ||
2759 | dev_printk(KERN_ERR, &pdev->dev, | ||
2760 | "32-bit consistent DMA enable failed\n"); | ||
2761 | return rc; | ||
2762 | } | ||
2763 | } | ||
2764 | |||
2765 | return rc; | ||
2766 | } | ||
2767 | |||
2671 | /** | 2768 | /** |
2672 | * mv_print_info - Dump key info to kernel log for perusal. | 2769 | * mv_print_info - Dump key info to kernel log for perusal. |
2673 | * @host: ATA host to print info about | 2770 | * @host: ATA host to print info about |
@@ -2710,6 +2807,26 @@ static void mv_print_info(struct ata_host *host) | |||
2710 | scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx"); | 2807 | scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx"); |
2711 | } | 2808 | } |
2712 | 2809 | ||
2810 | static int mv_create_dma_pools(struct mv_host_priv *hpriv, struct device *dev) | ||
2811 | { | ||
2812 | hpriv->crqb_pool = dmam_pool_create("crqb_q", dev, MV_CRQB_Q_SZ, | ||
2813 | MV_CRQB_Q_SZ, 0); | ||
2814 | if (!hpriv->crqb_pool) | ||
2815 | return -ENOMEM; | ||
2816 | |||
2817 | hpriv->crpb_pool = dmam_pool_create("crpb_q", dev, MV_CRPB_Q_SZ, | ||
2818 | MV_CRPB_Q_SZ, 0); | ||
2819 | if (!hpriv->crpb_pool) | ||
2820 | return -ENOMEM; | ||
2821 | |||
2822 | hpriv->sg_tbl_pool = dmam_pool_create("sg_tbl", dev, MV_SG_TBL_SZ, | ||
2823 | MV_SG_TBL_SZ, 0); | ||
2824 | if (!hpriv->sg_tbl_pool) | ||
2825 | return -ENOMEM; | ||
2826 | |||
2827 | return 0; | ||
2828 | } | ||
2829 | |||
2713 | /** | 2830 | /** |
2714 | * mv_init_one - handle a positive probe of a Marvell host | 2831 | * mv_init_one - handle a positive probe of a Marvell host |
2715 | * @pdev: PCI device found | 2832 | * @pdev: PCI device found |
@@ -2755,6 +2872,10 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2755 | if (rc) | 2872 | if (rc) |
2756 | return rc; | 2873 | return rc; |
2757 | 2874 | ||
2875 | rc = mv_create_dma_pools(hpriv, &pdev->dev); | ||
2876 | if (rc) | ||
2877 | return rc; | ||
2878 | |||
2758 | /* initialize adapter */ | 2879 | /* initialize adapter */ |
2759 | rc = mv_init_host(host, board_idx); | 2880 | rc = mv_init_host(host, board_idx); |
2760 | if (rc) | 2881 | if (rc) |
@@ -2772,15 +2893,22 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2772 | return ata_host_activate(host, pdev->irq, mv_interrupt, IRQF_SHARED, | 2893 | return ata_host_activate(host, pdev->irq, mv_interrupt, IRQF_SHARED, |
2773 | IS_GEN_I(hpriv) ? &mv5_sht : &mv6_sht); | 2894 | IS_GEN_I(hpriv) ? &mv5_sht : &mv6_sht); |
2774 | } | 2895 | } |
2896 | #endif | ||
2775 | 2897 | ||
2776 | static int __init mv_init(void) | 2898 | static int __init mv_init(void) |
2777 | { | 2899 | { |
2778 | return pci_register_driver(&mv_pci_driver); | 2900 | int rc = -ENODEV; |
2901 | #ifdef CONFIG_PCI | ||
2902 | rc = pci_register_driver(&mv_pci_driver); | ||
2903 | #endif | ||
2904 | return rc; | ||
2779 | } | 2905 | } |
2780 | 2906 | ||
2781 | static void __exit mv_exit(void) | 2907 | static void __exit mv_exit(void) |
2782 | { | 2908 | { |
2909 | #ifdef CONFIG_PCI | ||
2783 | pci_unregister_driver(&mv_pci_driver); | 2910 | pci_unregister_driver(&mv_pci_driver); |
2911 | #endif | ||
2784 | } | 2912 | } |
2785 | 2913 | ||
2786 | MODULE_AUTHOR("Brett Russ"); | 2914 | MODULE_AUTHOR("Brett Russ"); |
@@ -2789,8 +2917,10 @@ MODULE_LICENSE("GPL"); | |||
2789 | MODULE_DEVICE_TABLE(pci, mv_pci_tbl); | 2917 | MODULE_DEVICE_TABLE(pci, mv_pci_tbl); |
2790 | MODULE_VERSION(DRV_VERSION); | 2918 | MODULE_VERSION(DRV_VERSION); |
2791 | 2919 | ||
2920 | #ifdef CONFIG_PCI | ||
2792 | module_param(msi, int, 0444); | 2921 | module_param(msi, int, 0444); |
2793 | MODULE_PARM_DESC(msi, "Enable use of PCI MSI (0=off, 1=on)"); | 2922 | MODULE_PARM_DESC(msi, "Enable use of PCI MSI (0=off, 1=on)"); |
2923 | #endif | ||
2794 | 2924 | ||
2795 | module_init(mv_init); | 2925 | module_init(mv_init); |
2796 | module_exit(mv_exit); | 2926 | module_exit(mv_exit); |
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index a0f98fdab7a0..bfe92a43cf89 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c | |||
@@ -1011,14 +1011,20 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) | |||
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | if (status & (NV_ADMA_STAT_DONE | | 1013 | if (status & (NV_ADMA_STAT_DONE | |
1014 | NV_ADMA_STAT_CPBERR)) { | 1014 | NV_ADMA_STAT_CPBERR | |
1015 | u32 check_commands; | 1015 | NV_ADMA_STAT_CMD_COMPLETE)) { |
1016 | u32 check_commands = notifier_clears[i]; | ||
1016 | int pos, error = 0; | 1017 | int pos, error = 0; |
1017 | 1018 | ||
1018 | if (ata_tag_valid(ap->link.active_tag)) | 1019 | if (status & NV_ADMA_STAT_CPBERR) { |
1019 | check_commands = 1 << ap->link.active_tag; | 1020 | /* Check all active commands */ |
1020 | else | 1021 | if (ata_tag_valid(ap->link.active_tag)) |
1021 | check_commands = ap->link.sactive; | 1022 | check_commands = 1 << |
1023 | ap->link.active_tag; | ||
1024 | else | ||
1025 | check_commands = ap-> | ||
1026 | link.sactive; | ||
1027 | } | ||
1022 | 1028 | ||
1023 | /** Check CPBs for completed commands */ | 1029 | /** Check CPBs for completed commands */ |
1024 | while ((pos = ffs(check_commands)) && !error) { | 1030 | while ((pos = ffs(check_commands)) && !error) { |
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index c6179d6ac6e4..a70c1c29a7aa 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -922,11 +922,6 @@ static int ub_scsi_cmd_start(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
922 | usb_fill_bulk_urb(&sc->work_urb, sc->dev, sc->send_bulk_pipe, | 922 | usb_fill_bulk_urb(&sc->work_urb, sc->dev, sc->send_bulk_pipe, |
923 | bcb, US_BULK_CB_WRAP_LEN, ub_urb_complete, sc); | 923 | bcb, US_BULK_CB_WRAP_LEN, ub_urb_complete, sc); |
924 | 924 | ||
925 | /* Fill what we shouldn't be filling, because usb-storage did so. */ | ||
926 | sc->work_urb.actual_length = 0; | ||
927 | sc->work_urb.error_count = 0; | ||
928 | sc->work_urb.status = 0; | ||
929 | |||
930 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { | 925 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { |
931 | /* XXX Clear stalls */ | 926 | /* XXX Clear stalls */ |
932 | ub_complete(&sc->work_done); | 927 | ub_complete(&sc->work_done); |
@@ -1313,9 +1308,6 @@ static void ub_data_start(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1313 | sc->last_pipe = pipe; | 1308 | sc->last_pipe = pipe; |
1314 | usb_fill_bulk_urb(&sc->work_urb, sc->dev, pipe, sg_virt(sg), | 1309 | usb_fill_bulk_urb(&sc->work_urb, sc->dev, pipe, sg_virt(sg), |
1315 | sg->length, ub_urb_complete, sc); | 1310 | sg->length, ub_urb_complete, sc); |
1316 | sc->work_urb.actual_length = 0; | ||
1317 | sc->work_urb.error_count = 0; | ||
1318 | sc->work_urb.status = 0; | ||
1319 | 1311 | ||
1320 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { | 1312 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { |
1321 | /* XXX Clear stalls */ | 1313 | /* XXX Clear stalls */ |
@@ -1356,9 +1348,6 @@ static int __ub_state_stat(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1356 | sc->last_pipe = sc->recv_bulk_pipe; | 1348 | sc->last_pipe = sc->recv_bulk_pipe; |
1357 | usb_fill_bulk_urb(&sc->work_urb, sc->dev, sc->recv_bulk_pipe, | 1349 | usb_fill_bulk_urb(&sc->work_urb, sc->dev, sc->recv_bulk_pipe, |
1358 | &sc->work_bcs, US_BULK_CS_WRAP_LEN, ub_urb_complete, sc); | 1350 | &sc->work_bcs, US_BULK_CS_WRAP_LEN, ub_urb_complete, sc); |
1359 | sc->work_urb.actual_length = 0; | ||
1360 | sc->work_urb.error_count = 0; | ||
1361 | sc->work_urb.status = 0; | ||
1362 | 1351 | ||
1363 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { | 1352 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { |
1364 | /* XXX Clear stalls */ | 1353 | /* XXX Clear stalls */ |
@@ -1473,9 +1462,6 @@ static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | |||
1473 | 1462 | ||
1474 | usb_fill_control_urb(&sc->work_urb, sc->dev, sc->send_ctrl_pipe, | 1463 | usb_fill_control_urb(&sc->work_urb, sc->dev, sc->send_ctrl_pipe, |
1475 | (unsigned char*) cr, NULL, 0, ub_urb_complete, sc); | 1464 | (unsigned char*) cr, NULL, 0, ub_urb_complete, sc); |
1476 | sc->work_urb.actual_length = 0; | ||
1477 | sc->work_urb.error_count = 0; | ||
1478 | sc->work_urb.status = 0; | ||
1479 | 1465 | ||
1480 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { | 1466 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { |
1481 | ub_complete(&sc->work_done); | 1467 | ub_complete(&sc->work_done); |
@@ -1953,9 +1939,6 @@ static int ub_sync_reset(struct ub_dev *sc) | |||
1953 | 1939 | ||
1954 | usb_fill_control_urb(&sc->work_urb, sc->dev, sc->send_ctrl_pipe, | 1940 | usb_fill_control_urb(&sc->work_urb, sc->dev, sc->send_ctrl_pipe, |
1955 | (unsigned char*) cr, NULL, 0, ub_probe_urb_complete, &compl); | 1941 | (unsigned char*) cr, NULL, 0, ub_probe_urb_complete, &compl); |
1956 | sc->work_urb.actual_length = 0; | ||
1957 | sc->work_urb.error_count = 0; | ||
1958 | sc->work_urb.status = 0; | ||
1959 | 1942 | ||
1960 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) { | 1943 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) { |
1961 | printk(KERN_WARNING | 1944 | printk(KERN_WARNING |
@@ -2007,9 +1990,6 @@ static int ub_sync_getmaxlun(struct ub_dev *sc) | |||
2007 | 1990 | ||
2008 | usb_fill_control_urb(&sc->work_urb, sc->dev, sc->recv_ctrl_pipe, | 1991 | usb_fill_control_urb(&sc->work_urb, sc->dev, sc->recv_ctrl_pipe, |
2009 | (unsigned char*) cr, p, 1, ub_probe_urb_complete, &compl); | 1992 | (unsigned char*) cr, p, 1, ub_probe_urb_complete, &compl); |
2010 | sc->work_urb.actual_length = 0; | ||
2011 | sc->work_urb.error_count = 0; | ||
2012 | sc->work_urb.status = 0; | ||
2013 | 1993 | ||
2014 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) | 1994 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) |
2015 | goto err_submit; | 1995 | goto err_submit; |
@@ -2077,9 +2057,6 @@ static int ub_probe_clear_stall(struct ub_dev *sc, int stalled_pipe) | |||
2077 | 2057 | ||
2078 | usb_fill_control_urb(&sc->work_urb, sc->dev, sc->send_ctrl_pipe, | 2058 | usb_fill_control_urb(&sc->work_urb, sc->dev, sc->send_ctrl_pipe, |
2079 | (unsigned char*) cr, NULL, 0, ub_probe_urb_complete, &compl); | 2059 | (unsigned char*) cr, NULL, 0, ub_probe_urb_complete, &compl); |
2080 | sc->work_urb.actual_length = 0; | ||
2081 | sc->work_urb.error_count = 0; | ||
2082 | sc->work_urb.status = 0; | ||
2083 | 2060 | ||
2084 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) { | 2061 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) { |
2085 | printk(KERN_WARNING | 2062 | printk(KERN_WARNING |
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index af0561053167..47e5b40510cb 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
@@ -2787,12 +2787,6 @@ int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi, | |||
2787 | return -ENOSYS; | 2787 | return -ENOSYS; |
2788 | } | 2788 | } |
2789 | 2789 | ||
2790 | static inline | ||
2791 | int msf_to_lba(char m, char s, char f) | ||
2792 | { | ||
2793 | return (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET; | ||
2794 | } | ||
2795 | |||
2796 | /* | 2790 | /* |
2797 | * Required when we need to use READ_10 to issue other than 2048 block | 2791 | * Required when we need to use READ_10 to issue other than 2048 block |
2798 | * reads | 2792 | * reads |
diff --git a/drivers/char/tty_audit.c b/drivers/char/tty_audit.c index d222012c1b0c..bacded0eefab 100644 --- a/drivers/char/tty_audit.c +++ b/drivers/char/tty_audit.c | |||
@@ -73,6 +73,7 @@ static void tty_audit_buf_put(struct tty_audit_buf *buf) | |||
73 | * @tsk with @loginuid. @buf->mutex must be locked. | 73 | * @tsk with @loginuid. @buf->mutex must be locked. |
74 | */ | 74 | */ |
75 | static void tty_audit_buf_push(struct task_struct *tsk, uid_t loginuid, | 75 | static void tty_audit_buf_push(struct task_struct *tsk, uid_t loginuid, |
76 | unsigned int sessionid, | ||
76 | struct tty_audit_buf *buf) | 77 | struct tty_audit_buf *buf) |
77 | { | 78 | { |
78 | struct audit_buffer *ab; | 79 | struct audit_buffer *ab; |
@@ -85,9 +86,9 @@ static void tty_audit_buf_push(struct task_struct *tsk, uid_t loginuid, | |||
85 | if (ab) { | 86 | if (ab) { |
86 | char name[sizeof(tsk->comm)]; | 87 | char name[sizeof(tsk->comm)]; |
87 | 88 | ||
88 | audit_log_format(ab, "tty pid=%u uid=%u auid=%u major=%d " | 89 | audit_log_format(ab, "tty pid=%u uid=%u auid=%u ses=%u " |
89 | "minor=%d comm=", tsk->pid, tsk->uid, | 90 | "major=%d minor=%d comm=", tsk->pid, tsk->uid, |
90 | loginuid, buf->major, buf->minor); | 91 | loginuid, sessionid, buf->major, buf->minor); |
91 | get_task_comm(name, tsk); | 92 | get_task_comm(name, tsk); |
92 | audit_log_untrustedstring(ab, name); | 93 | audit_log_untrustedstring(ab, name); |
93 | audit_log_format(ab, " data="); | 94 | audit_log_format(ab, " data="); |
@@ -105,8 +106,9 @@ static void tty_audit_buf_push(struct task_struct *tsk, uid_t loginuid, | |||
105 | */ | 106 | */ |
106 | static void tty_audit_buf_push_current(struct tty_audit_buf *buf) | 107 | static void tty_audit_buf_push_current(struct tty_audit_buf *buf) |
107 | { | 108 | { |
108 | tty_audit_buf_push(current, audit_get_loginuid(current->audit_context), | 109 | uid_t auid = audit_get_loginuid(current); |
109 | buf); | 110 | unsigned int sessionid = audit_get_sessionid(current); |
111 | tty_audit_buf_push(current, auid, sessionid, buf); | ||
110 | } | 112 | } |
111 | 113 | ||
112 | /** | 114 | /** |
@@ -152,6 +154,11 @@ void tty_audit_fork(struct signal_struct *sig) | |||
152 | void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid) | 154 | void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid) |
153 | { | 155 | { |
154 | struct tty_audit_buf *buf; | 156 | struct tty_audit_buf *buf; |
157 | /* FIXME I think this is correct. Check against netlink once that is | ||
158 | * I really need to read this code more closely. But that's for | ||
159 | * another patch. | ||
160 | */ | ||
161 | unsigned int sessionid = audit_get_sessionid(tsk); | ||
155 | 162 | ||
156 | spin_lock_irq(&tsk->sighand->siglock); | 163 | spin_lock_irq(&tsk->sighand->siglock); |
157 | buf = tsk->signal->tty_audit_buf; | 164 | buf = tsk->signal->tty_audit_buf; |
@@ -162,7 +169,7 @@ void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid) | |||
162 | return; | 169 | return; |
163 | 170 | ||
164 | mutex_lock(&buf->mutex); | 171 | mutex_lock(&buf->mutex); |
165 | tty_audit_buf_push(tsk, loginuid, buf); | 172 | tty_audit_buf_push(tsk, loginuid, sessionid, buf); |
166 | mutex_unlock(&buf->mutex); | 173 | mutex_unlock(&buf->mutex); |
167 | 174 | ||
168 | tty_audit_buf_put(buf); | 175 | tty_audit_buf_put(buf); |
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 64df55e20ab5..e42a465f5717 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -206,6 +206,15 @@ config BLK_DEV_IDECD | |||
206 | To compile this driver as a module, choose M here: the | 206 | To compile this driver as a module, choose M here: the |
207 | module will be called ide-cd. | 207 | module will be called ide-cd. |
208 | 208 | ||
209 | config BLK_DEV_IDECD_VERBOSE_ERRORS | ||
210 | bool "Verbose error logging for IDE/ATAPI CDROM driver" if EMBEDDED | ||
211 | depends on BLK_DEV_IDECD | ||
212 | default y | ||
213 | help | ||
214 | Turn this on to have the driver print out the meanings of the | ||
215 | ATAPI error codes. This will use up additional 8kB of kernel-space | ||
216 | memory, though. | ||
217 | |||
209 | config BLK_DEV_IDETAPE | 218 | config BLK_DEV_IDETAPE |
210 | tristate "Include IDE/ATAPI TAPE support (EXPERIMENTAL)" | 219 | tristate "Include IDE/ATAPI TAPE support (EXPERIMENTAL)" |
211 | depends on EXPERIMENTAL | 220 | depends on EXPERIMENTAL |
@@ -617,8 +626,8 @@ config BLK_DEV_SC1200 | |||
617 | tristate "National SCx200 chipset support" | 626 | tristate "National SCx200 chipset support" |
618 | select BLK_DEV_IDEDMA_PCI | 627 | select BLK_DEV_IDEDMA_PCI |
619 | help | 628 | help |
620 | This driver adds support for the built in IDE on the National | 629 | This driver adds support for the on-board IDE controller on the |
621 | SCx200 series of embedded x86 "Geode" systems | 630 | National SCx200 series of embedded x86 "Geode" systems. |
622 | 631 | ||
623 | config BLK_DEV_PIIX | 632 | config BLK_DEV_PIIX |
624 | tristate "Intel PIIXn chipsets support" | 633 | tristate "Intel PIIXn chipsets support" |
@@ -793,22 +802,22 @@ config BLK_DEV_CELLEB | |||
793 | depends on PPC_CELLEB | 802 | depends on PPC_CELLEB |
794 | select BLK_DEV_IDEDMA_PCI | 803 | select BLK_DEV_IDEDMA_PCI |
795 | help | 804 | help |
796 | This driver provides support for the built-in IDE controller on | 805 | This driver provides support for the on-board IDE controller on |
797 | Toshiba Cell Reference Board. | 806 | Toshiba Cell Reference Board. |
798 | If unsure, say Y. | 807 | If unsure, say Y. |
799 | 808 | ||
800 | endif | 809 | endif |
801 | 810 | ||
802 | config BLK_DEV_IDE_PMAC | 811 | config BLK_DEV_IDE_PMAC |
803 | tristate "Builtin PowerMac IDE support" | 812 | tristate "PowerMac on-board IDE support" |
804 | depends on PPC_PMAC && IDE=y && BLK_DEV_IDE=y | 813 | depends on PPC_PMAC && IDE=y && BLK_DEV_IDE=y |
805 | help | 814 | help |
806 | This driver provides support for the built-in IDE controller on | 815 | This driver provides support for the on-board IDE controller on |
807 | most of the recent Apple Power Macintoshes and PowerBooks. | 816 | most of the recent Apple Power Macintoshes and PowerBooks. |
808 | If unsure, say Y. | 817 | If unsure, say Y. |
809 | 818 | ||
810 | config BLK_DEV_IDE_PMAC_ATA100FIRST | 819 | config BLK_DEV_IDE_PMAC_ATA100FIRST |
811 | bool "Probe internal ATA/100 (Kauai) first" | 820 | bool "Probe on-board ATA/100 (Kauai) first" |
812 | depends on BLK_DEV_IDE_PMAC | 821 | depends on BLK_DEV_IDE_PMAC |
813 | help | 822 | help |
814 | This option will cause the ATA/100 controller found in UniNorth2 | 823 | This option will cause the ATA/100 controller found in UniNorth2 |
@@ -823,7 +832,7 @@ config BLK_DEV_IDEDMA_PMAC | |||
823 | depends on BLK_DEV_IDE_PMAC | 832 | depends on BLK_DEV_IDE_PMAC |
824 | select BLK_DEV_IDEDMA_PCI | 833 | select BLK_DEV_IDEDMA_PCI |
825 | help | 834 | help |
826 | This option allows the driver for the built-in IDE controller on | 835 | This option allows the driver for the on-board IDE controller on |
827 | Power Macintoshes and PowerBooks to use DMA (direct memory access) | 836 | Power Macintoshes and PowerBooks to use DMA (direct memory access) |
828 | to transfer data to and from memory. Saying Y is safe and improves | 837 | to transfer data to and from memory. Saying Y is safe and improves |
829 | performance. | 838 | performance. |
@@ -934,7 +943,7 @@ config BLK_DEV_GAYLE | |||
934 | help | 943 | help |
935 | This is the IDE driver for the Amiga Gayle IDE interface. It supports | 944 | This is the IDE driver for the Amiga Gayle IDE interface. It supports |
936 | both the `A1200 style' and `A4000 style' of the Gayle IDE interface, | 945 | both the `A1200 style' and `A4000 style' of the Gayle IDE interface, |
937 | This includes builtin IDE interfaces on some Amiga models (A600, | 946 | This includes on-board IDE interfaces on some Amiga models (A600, |
938 | A1200, A4000, and A4000T), and IDE interfaces on the Zorro expansion | 947 | A1200, A4000, and A4000T), and IDE interfaces on the Zorro expansion |
939 | bus (M-Tech E-Matrix 530 expansion card). | 948 | bus (M-Tech E-Matrix 530 expansion card). |
940 | Say Y if you have an Amiga with a Gayle IDE interface and want to use | 949 | Say Y if you have an Amiga with a Gayle IDE interface and want to use |
@@ -948,10 +957,10 @@ config BLK_DEV_IDEDOUBLER | |||
948 | depends on BLK_DEV_GAYLE && EXPERIMENTAL | 957 | depends on BLK_DEV_GAYLE && EXPERIMENTAL |
949 | ---help--- | 958 | ---help--- |
950 | This driver provides support for the so-called `IDE doublers' (made | 959 | This driver provides support for the so-called `IDE doublers' (made |
951 | by various manufacturers, e.g. Eyetech) that can be connected to the | 960 | by various manufacturers, e.g. Eyetech) that can be connected to |
952 | builtin IDE interface of some Amiga models. Using such an IDE | 961 | the on-board IDE interface of some Amiga models. Using such an IDE |
953 | doubler, you can connect up to four instead of two IDE devices on | 962 | doubler, you can connect up to four instead of two IDE devices to |
954 | the Amiga's builtin IDE interface. | 963 | the Amiga's on-board IDE interface. |
955 | 964 | ||
956 | Note that the normal Amiga Gayle IDE driver may not work correctly | 965 | Note that the normal Amiga Gayle IDE driver may not work correctly |
957 | if you have an IDE doubler and don't enable this driver! | 966 | if you have an IDE doubler and don't enable this driver! |
@@ -963,9 +972,9 @@ config BLK_DEV_BUDDHA | |||
963 | tristate "Buddha/Catweasel/X-Surf IDE interface support (EXPERIMENTAL)" | 972 | tristate "Buddha/Catweasel/X-Surf IDE interface support (EXPERIMENTAL)" |
964 | depends on ZORRO && EXPERIMENTAL | 973 | depends on ZORRO && EXPERIMENTAL |
965 | help | 974 | help |
966 | This is the IDE driver for the IDE interfaces on the Buddha, | 975 | This is the IDE driver for the IDE interfaces on the Buddha, Catweasel |
967 | Catweasel and X-Surf expansion boards. It supports up to two interfaces | 976 | and X-Surf expansion boards. It supports up to two interfaces on the |
968 | on the Buddha, three on the Catweasel and two on the X-Surf. | 977 | Buddha, three on the Catweasel and two on the X-Surf. |
969 | 978 | ||
970 | Say Y if you have a Buddha or Catweasel expansion board and want to | 979 | Say Y if you have a Buddha or Catweasel expansion board and want to |
971 | use IDE devices (hard disks, CD-ROM drives, etc.) that are connected | 980 | use IDE devices (hard disks, CD-ROM drives, etc.) that are connected |
@@ -975,23 +984,23 @@ config BLK_DEV_FALCON_IDE | |||
975 | tristate "Falcon IDE interface support" | 984 | tristate "Falcon IDE interface support" |
976 | depends on ATARI | 985 | depends on ATARI |
977 | help | 986 | help |
978 | This is the IDE driver for the builtin IDE interface on the Atari | 987 | This is the IDE driver for the on-board IDE interface on the Atari |
979 | Falcon. Say Y if you have a Falcon and want to use IDE devices (hard | 988 | Falcon. Say Y if you have a Falcon and want to use IDE devices (hard |
980 | disks, CD-ROM drives, etc.) that are connected to the builtin IDE | 989 | disks, CD-ROM drives, etc.) that are connected to the on-board IDE |
981 | interface. | 990 | interface. |
982 | 991 | ||
983 | config BLK_DEV_MAC_IDE | 992 | config BLK_DEV_MAC_IDE |
984 | tristate "Macintosh Quadra/Powerbook IDE interface support" | 993 | tristate "Macintosh Quadra/Powerbook IDE interface support" |
985 | depends on MAC | 994 | depends on MAC |
986 | help | 995 | help |
987 | This is the IDE driver for the builtin IDE interface on some m68k | 996 | This is the IDE driver for the on-board IDE interface on some m68k |
988 | Macintosh models. It supports both the `Quadra style' (used in | 997 | Macintosh models. It supports both the `Quadra style' (used in |
989 | Quadra/ Centris 630 and Performa 588 models) and `Powerbook style' | 998 | Quadra/ Centris 630 and Performa 588 models) and `Powerbook style' |
990 | (used in the Powerbook 150 and 190 models) IDE interface. | 999 | (used in the Powerbook 150 and 190 models) IDE interface. |
991 | 1000 | ||
992 | Say Y if you have such an Macintosh model and want to use IDE | 1001 | Say Y if you have such an Macintosh model and want to use IDE |
993 | devices (hard disks, CD-ROM drives, etc.) that are connected to the | 1002 | devices (hard disks, CD-ROM drives, etc.) that are connected to the |
994 | builtin IDE interface. | 1003 | on-board IDE interface. |
995 | 1004 | ||
996 | config BLK_DEV_Q40IDE | 1005 | config BLK_DEV_Q40IDE |
997 | tristate "Q40/Q60 IDE interface support" | 1006 | tristate "Q40/Q60 IDE interface support" |
@@ -1062,8 +1071,8 @@ config BLK_DEV_ALI14XX | |||
1062 | boot parameter. It enables support for the secondary IDE interface | 1071 | boot parameter. It enables support for the secondary IDE interface |
1063 | of the ALI M1439/1443/1445/1487/1489 chipsets, and permits faster | 1072 | of the ALI M1439/1443/1445/1487/1489 chipsets, and permits faster |
1064 | I/O speeds to be set as well. See the files | 1073 | I/O speeds to be set as well. See the files |
1065 | <file:Documentation/ide.txt> and <file:drivers/ide/legacy/ali14xx.c> for | 1074 | <file:Documentation/ide.txt> and <file:drivers/ide/legacy/ali14xx.c> |
1066 | more info. | 1075 | for more info. |
1067 | 1076 | ||
1068 | config BLK_DEV_DTC2278 | 1077 | config BLK_DEV_DTC2278 |
1069 | tristate "DTC-2278 support" | 1078 | tristate "DTC-2278 support" |
@@ -1088,8 +1097,8 @@ config BLK_DEV_QD65XX | |||
1088 | help | 1097 | help |
1089 | This driver is enabled at runtime using the "qd65xx.probe" kernel | 1098 | This driver is enabled at runtime using the "qd65xx.probe" kernel |
1090 | boot parameter. It permits faster I/O speeds to be set. See the | 1099 | boot parameter. It permits faster I/O speeds to be set. See the |
1091 | <file:Documentation/ide.txt> and <file:drivers/ide/legacy/qd65xx.c> for | 1100 | <file:Documentation/ide.txt> and <file:drivers/ide/legacy/qd65xx.c> |
1092 | more info. | 1101 | for more info. |
1093 | 1102 | ||
1094 | config BLK_DEV_UMC8672 | 1103 | config BLK_DEV_UMC8672 |
1095 | tristate "UMC-8672 support" | 1104 | tristate "UMC-8672 support" |
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile index 0d2da89d15cf..a4a4323be911 100644 --- a/drivers/ide/Makefile +++ b/drivers/ide/Makefile | |||
@@ -40,8 +40,10 @@ obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o | |||
40 | obj-$(CONFIG_IDE_H8300) += h8300/ | 40 | obj-$(CONFIG_IDE_H8300) += h8300/ |
41 | obj-$(CONFIG_IDE_GENERIC) += ide-generic.o | 41 | obj-$(CONFIG_IDE_GENERIC) += ide-generic.o |
42 | 42 | ||
43 | ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o | ||
44 | |||
43 | obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.o | 45 | obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.o |
44 | obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd.o | 46 | obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd_mod.o |
45 | obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o | 47 | obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o |
46 | obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o | 48 | obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o |
47 | 49 | ||
diff --git a/drivers/ide/arm/bast-ide.c b/drivers/ide/arm/bast-ide.c index 45bf9c825f2b..037300fa284c 100644 --- a/drivers/ide/arm/bast-ide.c +++ b/drivers/ide/arm/bast-ide.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* linux/drivers/ide/arm/bast-ide.c | 1 | /* |
2 | * | ||
3 | * Copyright (c) 2003-2004 Simtec Electronics | 2 | * Copyright (c) 2003-2004 Simtec Electronics |
4 | * Ben Dooks <ben@simtec.co.uk> | 3 | * Ben Dooks <ben@simtec.co.uk> |
5 | * | 4 | * |
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index 8a5c7205b77c..8d2cc47a362e 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/arm/icside.c | ||
3 | * | ||
4 | * Copyright (c) 1996-2004 Russell King. | 2 | * Copyright (c) 1996-2004 Russell King. |
5 | * | 3 | * |
6 | * Please note that this platform does not support 32-bit IDE IO. | 4 | * Please note that this platform does not support 32-bit IDE IO. |
@@ -71,8 +69,6 @@ struct icside_state { | |||
71 | void __iomem *irq_port; | 69 | void __iomem *irq_port; |
72 | void __iomem *ioc_base; | 70 | void __iomem *ioc_base; |
73 | unsigned int type; | 71 | unsigned int type; |
74 | /* parent device... until the IDE core gets one of its own */ | ||
75 | struct device *dev; | ||
76 | ide_hwif_t *hwif[2]; | 72 | ide_hwif_t *hwif[2]; |
77 | }; | 73 | }; |
78 | 74 | ||
@@ -206,23 +202,6 @@ static void icside_maskproc(ide_drive_t *drive, int mask) | |||
206 | * interfaces use the same IRQ, which should guarantee this. | 202 | * interfaces use the same IRQ, which should guarantee this. |
207 | */ | 203 | */ |
208 | 204 | ||
209 | static void icside_build_sglist(ide_drive_t *drive, struct request *rq) | ||
210 | { | ||
211 | ide_hwif_t *hwif = drive->hwif; | ||
212 | struct icside_state *state = hwif->hwif_data; | ||
213 | struct scatterlist *sg = hwif->sg_table; | ||
214 | |||
215 | ide_map_sg(drive, rq); | ||
216 | |||
217 | if (rq_data_dir(rq) == READ) | ||
218 | hwif->sg_dma_direction = DMA_FROM_DEVICE; | ||
219 | else | ||
220 | hwif->sg_dma_direction = DMA_TO_DEVICE; | ||
221 | |||
222 | hwif->sg_nents = dma_map_sg(state->dev, sg, hwif->sg_nents, | ||
223 | hwif->sg_dma_direction); | ||
224 | } | ||
225 | |||
226 | /* | 205 | /* |
227 | * Configure the IOMD to give the appropriate timings for the transfer | 206 | * Configure the IOMD to give the appropriate timings for the transfer |
228 | * mode being requested. We take the advice of the ATA standards, and | 207 | * mode being requested. We take the advice of the ATA standards, and |
@@ -294,33 +273,32 @@ static void icside_dma_host_set(ide_drive_t *drive, int on) | |||
294 | static int icside_dma_end(ide_drive_t *drive) | 273 | static int icside_dma_end(ide_drive_t *drive) |
295 | { | 274 | { |
296 | ide_hwif_t *hwif = HWIF(drive); | 275 | ide_hwif_t *hwif = HWIF(drive); |
297 | struct icside_state *state = hwif->hwif_data; | 276 | struct expansion_card *ec = ECARD_DEV(hwif->dev); |
298 | 277 | ||
299 | drive->waiting_for_dma = 0; | 278 | drive->waiting_for_dma = 0; |
300 | 279 | ||
301 | disable_dma(ECARD_DEV(state->dev)->dma); | 280 | disable_dma(ec->dma); |
302 | 281 | ||
303 | /* Teardown mappings after DMA has completed. */ | 282 | /* Teardown mappings after DMA has completed. */ |
304 | dma_unmap_sg(state->dev, hwif->sg_table, hwif->sg_nents, | 283 | ide_destroy_dmatable(drive); |
305 | hwif->sg_dma_direction); | ||
306 | 284 | ||
307 | return get_dma_residue(ECARD_DEV(state->dev)->dma) != 0; | 285 | return get_dma_residue(ec->dma) != 0; |
308 | } | 286 | } |
309 | 287 | ||
310 | static void icside_dma_start(ide_drive_t *drive) | 288 | static void icside_dma_start(ide_drive_t *drive) |
311 | { | 289 | { |
312 | ide_hwif_t *hwif = HWIF(drive); | 290 | ide_hwif_t *hwif = HWIF(drive); |
313 | struct icside_state *state = hwif->hwif_data; | 291 | struct expansion_card *ec = ECARD_DEV(hwif->dev); |
314 | 292 | ||
315 | /* We can not enable DMA on both channels simultaneously. */ | 293 | /* We can not enable DMA on both channels simultaneously. */ |
316 | BUG_ON(dma_channel_active(ECARD_DEV(state->dev)->dma)); | 294 | BUG_ON(dma_channel_active(ec->dma)); |
317 | enable_dma(ECARD_DEV(state->dev)->dma); | 295 | enable_dma(ec->dma); |
318 | } | 296 | } |
319 | 297 | ||
320 | static int icside_dma_setup(ide_drive_t *drive) | 298 | static int icside_dma_setup(ide_drive_t *drive) |
321 | { | 299 | { |
322 | ide_hwif_t *hwif = HWIF(drive); | 300 | ide_hwif_t *hwif = HWIF(drive); |
323 | struct icside_state *state = hwif->hwif_data; | 301 | struct expansion_card *ec = ECARD_DEV(hwif->dev); |
324 | struct request *rq = hwif->hwgroup->rq; | 302 | struct request *rq = hwif->hwgroup->rq; |
325 | unsigned int dma_mode; | 303 | unsigned int dma_mode; |
326 | 304 | ||
@@ -332,9 +310,9 @@ static int icside_dma_setup(ide_drive_t *drive) | |||
332 | /* | 310 | /* |
333 | * We can not enable DMA on both channels. | 311 | * We can not enable DMA on both channels. |
334 | */ | 312 | */ |
335 | BUG_ON(dma_channel_active(ECARD_DEV(state->dev)->dma)); | 313 | BUG_ON(dma_channel_active(ec->dma)); |
336 | 314 | ||
337 | icside_build_sglist(drive, rq); | 315 | hwif->sg_nents = ide_build_sglist(drive, rq); |
338 | 316 | ||
339 | /* | 317 | /* |
340 | * Ensure that we have the right interrupt routed. | 318 | * Ensure that we have the right interrupt routed. |
@@ -349,14 +327,14 @@ static int icside_dma_setup(ide_drive_t *drive) | |||
349 | /* | 327 | /* |
350 | * Select the correct timing for this drive. | 328 | * Select the correct timing for this drive. |
351 | */ | 329 | */ |
352 | set_dma_speed(ECARD_DEV(state->dev)->dma, drive->drive_data); | 330 | set_dma_speed(ec->dma, drive->drive_data); |
353 | 331 | ||
354 | /* | 332 | /* |
355 | * Tell the DMA engine about the SG table and | 333 | * Tell the DMA engine about the SG table and |
356 | * data direction. | 334 | * data direction. |
357 | */ | 335 | */ |
358 | set_dma_sg(ECARD_DEV(state->dev)->dma, hwif->sg_table, hwif->sg_nents); | 336 | set_dma_sg(ec->dma, hwif->sg_table, hwif->sg_nents); |
359 | set_dma_mode(ECARD_DEV(state->dev)->dma, dma_mode); | 337 | set_dma_mode(ec->dma, dma_mode); |
360 | 338 | ||
361 | drive->waiting_for_dma = 1; | 339 | drive->waiting_for_dma = 1; |
362 | 340 | ||
@@ -444,6 +422,7 @@ icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *e | |||
444 | hwif->noprobe = 0; | 422 | hwif->noprobe = 0; |
445 | hwif->chipset = ide_acorn; | 423 | hwif->chipset = ide_acorn; |
446 | hwif->gendev.parent = &ec->dev; | 424 | hwif->gendev.parent = &ec->dev; |
425 | hwif->dev = &ec->dev; | ||
447 | } | 426 | } |
448 | 427 | ||
449 | return hwif; | 428 | return hwif; |
@@ -591,7 +570,6 @@ icside_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
591 | } | 570 | } |
592 | 571 | ||
593 | state->type = ICS_TYPE_NOTYPE; | 572 | state->type = ICS_TYPE_NOTYPE; |
594 | state->dev = &ec->dev; | ||
595 | 573 | ||
596 | idmem = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); | 574 | idmem = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); |
597 | if (idmem) { | 575 | if (idmem) { |
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c index e6b56d1d48f4..c8b6581e624e 100644 --- a/drivers/ide/arm/rapide.c +++ b/drivers/ide/arm/rapide.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/arm/rapide.c | ||
3 | * | ||
4 | * Copyright (c) 1996-2002 Russell King. | 2 | * Copyright (c) 1996-2002 Russell King. |
5 | */ | 3 | */ |
6 | 4 | ||
@@ -78,8 +76,8 @@ static void __devexit rapide_remove(struct expansion_card *ec) | |||
78 | 76 | ||
79 | ecard_set_drvdata(ec, NULL); | 77 | ecard_set_drvdata(ec, NULL); |
80 | 78 | ||
81 | /* there must be a better way */ | 79 | ide_unregister(hwif->index); |
82 | ide_unregister(hwif - ide_hwifs); | 80 | |
83 | ecard_release_resources(ec); | 81 | ecard_release_resources(ec); |
84 | } | 82 | } |
85 | 83 | ||
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c index 8c3294c4d23e..0640a38ff127 100644 --- a/drivers/ide/cris/ide-cris.c +++ b/drivers/ide/cris/ide-cris.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* $Id: cris-ide-driver.patch,v 1.1 2005/06/29 21:39:07 akpm Exp $ | 1 | /* |
2 | * | ||
3 | * Etrax specific IDE functions, like init and PIO-mode setting etc. | 2 | * Etrax specific IDE functions, like init and PIO-mode setting etc. |
4 | * Almost the entire ide.c is used for the rest of the Etrax ATA driver. | 3 | * Almost the entire ide.c is used for the rest of the Etrax ATA driver. |
5 | * Copyright (c) 2000-2005 Axis Communications AB | 4 | * Copyright (c) 2000-2005 Axis Communications AB |
diff --git a/drivers/ide/h8300/ide-h8300.c b/drivers/ide/h8300/ide-h8300.c index 4f6d0191cf6c..02432958dfe1 100644 --- a/drivers/ide/h8300/ide-h8300.c +++ b/drivers/ide/h8300/ide-h8300.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/ide/h8300/ide-h8300.c | ||
3 | * H8/300 generic IDE interface | 2 | * H8/300 generic IDE interface |
4 | */ | 3 | */ |
5 | 4 | ||
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index e888fc35b27c..68bc61844780 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * ide-acpi.c | ||
3 | * Provides ACPI support for IDE drives. | 2 | * Provides ACPI support for IDE drives. |
4 | * | 3 | * |
5 | * Copyright (C) 2005 Intel Corp. | 4 | * Copyright (C) 2005 Intel Corp. |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index bee05a3f52ae..23074e84472e 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -1,14 +1,14 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/ide-cd.c | 2 | * ATAPI CD-ROM driver. |
3 | * | 3 | * |
4 | * Copyright (C) 1994, 1995, 1996 scott snyder <snyder@fnald0.fnal.gov> | 4 | * Copyright (C) 1994-1996 Scott Snyder <snyder@fnald0.fnal.gov> |
5 | * Copyright (C) 1996-1998 Erik Andersen <andersee@debian.org> | 5 | * Copyright (C) 1996-1998 Erik Andersen <andersee@debian.org> |
6 | * Copyright (C) 1998-2000 Jens Axboe <axboe@suse.de> | 6 | * Copyright (C) 1998-2000 Jens Axboe <axboe@suse.de> |
7 | * Copyright (C) 2005, 2007 Bartlomiej Zolnierkiewicz | ||
7 | * | 8 | * |
8 | * May be copied or modified under the terms of the GNU General Public | 9 | * May be copied or modified under the terms of the GNU General Public |
9 | * License. See linux/COPYING for more information. | 10 | * License. See linux/COPYING for more information. |
10 | * | 11 | * |
11 | * ATAPI CD-ROM driver. To be used with ide.c. | ||
12 | * See Documentation/cdrom/ide-cd for usage information. | 12 | * See Documentation/cdrom/ide-cd for usage information. |
13 | * | 13 | * |
14 | * Suggestions are welcome. Patches that work are more welcome though. ;-) | 14 | * Suggestions are welcome. Patches that work are more welcome though. ;-) |
@@ -19,287 +19,11 @@ | |||
19 | * ftp://fission.dt.wdc.com/pub/standards/SFF_atapi/spec/SFF8020-r2.6/PS/8020r26.ps | 19 | * ftp://fission.dt.wdc.com/pub/standards/SFF_atapi/spec/SFF8020-r2.6/PS/8020r26.ps |
20 | * ftp://ftp.avc-pioneer.com/Mtfuji4/Spec/Fuji4r10.pdf | 20 | * ftp://ftp.avc-pioneer.com/Mtfuji4/Spec/Fuji4r10.pdf |
21 | * | 21 | * |
22 | * Drives that deviate from these standards will be accommodated as much | 22 | * For historical changelog please see: |
23 | * as possible via compile time or command-line options. Since I only have | 23 | * Documentation/ide/ChangeLog.ide-cd.1994-2004 |
24 | * a few drives, you generally need to send me patches... | 24 | */ |
25 | * | 25 | |
26 | * ---------------------------------- | 26 | #define IDECD_VERSION "5.00" |
27 | * TO DO LIST: | ||
28 | * -Make it so that Pioneer CD DR-A24X and friends don't get screwed up on | ||
29 | * boot | ||
30 | * | ||
31 | * ---------------------------------- | ||
32 | * 1.00 Oct 31, 1994 -- Initial version. | ||
33 | * 1.01 Nov 2, 1994 -- Fixed problem with starting request in | ||
34 | * cdrom_check_status. | ||
35 | * 1.03 Nov 25, 1994 -- leaving unmask_intr[] as a user-setting (as for disks) | ||
36 | * (from mlord) -- minor changes to cdrom_setup() | ||
37 | * -- renamed ide_dev_s to ide_drive_t, enable irq on command | ||
38 | * 2.00 Nov 27, 1994 -- Generalize packet command interface; | ||
39 | * add audio ioctls. | ||
40 | * 2.01 Dec 3, 1994 -- Rework packet command interface to handle devices | ||
41 | * which send an interrupt when ready for a command. | ||
42 | * 2.02 Dec 11, 1994 -- Cache the TOC in the driver. | ||
43 | * Don't use SCMD_PLAYAUDIO_TI; it's not included | ||
44 | * in the current version of ATAPI. | ||
45 | * Try to use LBA instead of track or MSF addressing | ||
46 | * when possible. | ||
47 | * Don't wait for READY_STAT. | ||
48 | * 2.03 Jan 10, 1995 -- Rewrite block read routines to handle block sizes | ||
49 | * other than 2k and to move multiple sectors in a | ||
50 | * single transaction. | ||
51 | * 2.04 Apr 21, 1995 -- Add work-around for Creative Labs CD220E drives. | ||
52 | * Thanks to Nick Saw <cwsaw@pts7.pts.mot.com> for | ||
53 | * help in figuring this out. Ditto for Acer and | ||
54 | * Aztech drives, which seem to have the same problem. | ||
55 | * 2.04b May 30, 1995 -- Fix to match changes in ide.c version 3.16 -ml | ||
56 | * 2.05 Jun 8, 1995 -- Don't attempt to retry after an illegal request | ||
57 | * or data protect error. | ||
58 | * Use HWIF and DEV_HWIF macros as in ide.c. | ||
59 | * Always try to do a request_sense after | ||
60 | * a failed command. | ||
61 | * Include an option to give textual descriptions | ||
62 | * of ATAPI errors. | ||
63 | * Fix a bug in handling the sector cache which | ||
64 | * showed up if the drive returned data in 512 byte | ||
65 | * blocks (like Pioneer drives). Thanks to | ||
66 | * Richard Hirst <srh@gpt.co.uk> for diagnosing this. | ||
67 | * Properly supply the page number field in the | ||
68 | * MODE_SELECT command. | ||
69 | * PLAYAUDIO12 is broken on the Aztech; work around it. | ||
70 | * 2.05x Aug 11, 1995 -- lots of data structure renaming/restructuring in ide.c | ||
71 | * (my apologies to Scott, but now ide-cd.c is independent) | ||
72 | * 3.00 Aug 22, 1995 -- Implement CDROMMULTISESSION ioctl. | ||
73 | * Implement CDROMREADAUDIO ioctl (UNTESTED). | ||
74 | * Use input_ide_data() and output_ide_data(). | ||
75 | * Add door locking. | ||
76 | * Fix usage count leak in cdrom_open, which happened | ||
77 | * when a read-write mount was attempted. | ||
78 | * Try to load the disk on open. | ||
79 | * Implement CDROMEJECT_SW ioctl (off by default). | ||
80 | * Read total cdrom capacity during open. | ||
81 | * Rearrange logic in cdrom_decode_status. Issue | ||
82 | * request sense commands for failed packet commands | ||
83 | * from here instead of from cdrom_queue_packet_command. | ||
84 | * Fix a race condition in retrieving error information. | ||
85 | * Suppress printing normal unit attention errors and | ||
86 | * some drive not ready errors. | ||
87 | * Implement CDROMVOLREAD ioctl. | ||
88 | * Implement CDROMREADMODE1/2 ioctls. | ||
89 | * Fix race condition in setting up interrupt handlers | ||
90 | * when the `serialize' option is used. | ||
91 | * 3.01 Sep 2, 1995 -- Fix ordering of reenabling interrupts in | ||
92 | * cdrom_queue_request. | ||
93 | * Another try at using ide_[input,output]_data. | ||
94 | * 3.02 Sep 16, 1995 -- Stick total disk capacity in partition table as well. | ||
95 | * Make VERBOSE_IDE_CD_ERRORS dump failed command again. | ||
96 | * Dump out more information for ILLEGAL REQUEST errs. | ||
97 | * Fix handling of errors occurring before the | ||
98 | * packet command is transferred. | ||
99 | * Fix transfers with odd bytelengths. | ||
100 | * 3.03 Oct 27, 1995 -- Some Creative drives have an id of just `CD'. | ||
101 | * `DCI-2S10' drives are broken too. | ||
102 | * 3.04 Nov 20, 1995 -- So are Vertos drives. | ||
103 | * 3.05 Dec 1, 1995 -- Changes to go with overhaul of ide.c and ide-tape.c | ||
104 | * 3.06 Dec 16, 1995 -- Add support needed for partitions. | ||
105 | * More workarounds for Vertos bugs (based on patches | ||
106 | * from Holger Dietze <dietze@aix520.informatik.uni-leipzig.de>). | ||
107 | * Try to eliminate byteorder assumptions. | ||
108 | * Use atapi_cdrom_subchnl struct definition. | ||
109 | * Add STANDARD_ATAPI compilation option. | ||
110 | * 3.07 Jan 29, 1996 -- More twiddling for broken drives: Sony 55D, | ||
111 | * Vertos 300. | ||
112 | * Add NO_DOOR_LOCKING configuration option. | ||
113 | * Handle drive_cmd requests w/NULL args (for hdparm -t). | ||
114 | * Work around sporadic Sony55e audio play problem. | ||
115 | * 3.07a Feb 11, 1996 -- check drive->id for NULL before dereferencing, to fix | ||
116 | * problem with "hde=cdrom" with no drive present. -ml | ||
117 | * 3.08 Mar 6, 1996 -- More Vertos workarounds. | ||
118 | * 3.09 Apr 5, 1996 -- Add CDROMCLOSETRAY ioctl. | ||
119 | * Switch to using MSF addressing for audio commands. | ||
120 | * Reformat to match kernel tabbing style. | ||
121 | * Add CDROM_GET_UPC ioctl. | ||
122 | * 3.10 Apr 10, 1996 -- Fix compilation error with STANDARD_ATAPI. | ||
123 | * 3.11 Apr 29, 1996 -- Patch from Heiko Eißfeldt <heiko@colossus.escape.de> | ||
124 | * to remove redundant verify_area calls. | ||
125 | * 3.12 May 7, 1996 -- Rudimentary changer support. Based on patches | ||
126 | * from Gerhard Zuber <zuber@berlin.snafu.de>. | ||
127 | * Let open succeed even if there's no loaded disc. | ||
128 | * 3.13 May 19, 1996 -- Fixes for changer code. | ||
129 | * 3.14 May 29, 1996 -- Add work-around for Vertos 600. | ||
130 | * (From Hennus Bergman <hennus@sky.ow.nl>.) | ||
131 | * 3.15 July 2, 1996 -- Added support for Sanyo 3 CD changers | ||
132 | * from Ben Galliart <bgallia@luc.edu> with | ||
133 | * special help from Jeff Lightfoot | ||
134 | * <jeffml@pobox.com> | ||
135 | * 3.15a July 9, 1996 -- Improved Sanyo 3 CD changer identification | ||
136 | * 3.16 Jul 28, 1996 -- Fix from Gadi to reduce kernel stack usage for ioctl. | ||
137 | * 3.17 Sep 17, 1996 -- Tweak audio reads for some drives. | ||
138 | * Start changing CDROMLOADFROMSLOT to CDROM_SELECT_DISC. | ||
139 | * 3.18 Oct 31, 1996 -- Added module and DMA support. | ||
140 | * | ||
141 | * | ||
142 | * 4.00 Nov 5, 1996 -- New ide-cd maintainer, | ||
143 | * Erik B. Andersen <andersee@debian.org> | ||
144 | * -- Newer Creative drives don't always set the error | ||
145 | * register correctly. Make sure we see media changes | ||
146 | * regardless. | ||
147 | * -- Integrate with generic cdrom driver. | ||
148 | * -- CDROMGETSPINDOWN and CDROMSETSPINDOWN ioctls, based on | ||
149 | * a patch from Ciro Cattuto <>. | ||
150 | * -- Call set_device_ro. | ||
151 | * -- Implement CDROMMECHANISMSTATUS and CDROMSLOTTABLE | ||
152 | * ioctls, based on patch by Erik Andersen | ||
153 | * -- Add some probes of drive capability during setup. | ||
154 | * | ||
155 | * 4.01 Nov 11, 1996 -- Split into ide-cd.c and ide-cd.h | ||
156 | * -- Removed CDROMMECHANISMSTATUS and CDROMSLOTTABLE | ||
157 | * ioctls in favor of a generalized approach | ||
158 | * using the generic cdrom driver. | ||
159 | * -- Fully integrated with the 2.1.X kernel. | ||
160 | * -- Other stuff that I forgot (lots of changes) | ||
161 | * | ||
162 | * 4.02 Dec 01, 1996 -- Applied patch from Gadi Oxman <gadio@netvision.net.il> | ||
163 | * to fix the drive door locking problems. | ||
164 | * | ||
165 | * 4.03 Dec 04, 1996 -- Added DSC overlap support. | ||
166 | * 4.04 Dec 29, 1996 -- Added CDROMREADRAW ioclt based on patch | ||
167 | * by Ales Makarov (xmakarov@sun.felk.cvut.cz) | ||
168 | * | ||
169 | * 4.05 Nov 20, 1997 -- Modified to print more drive info on init | ||
170 | * Minor other changes | ||
171 | * Fix errors on CDROMSTOP (If you have a "Dolphin", | ||
172 | * you must define IHAVEADOLPHIN) | ||
173 | * Added identifier so new Sanyo CD-changer works | ||
174 | * Better detection if door locking isn't supported | ||
175 | * | ||
176 | * 4.06 Dec 17, 1997 -- fixed endless "tray open" messages -ml | ||
177 | * 4.07 Dec 17, 1997 -- fallback to set pc->stat on "tray open" | ||
178 | * 4.08 Dec 18, 1997 -- spew less noise when tray is empty | ||
179 | * -- fix speed display for ACER 24X, 18X | ||
180 | * 4.09 Jan 04, 1998 -- fix handling of the last block so we return | ||
181 | * an end of file instead of an I/O error (Gadi) | ||
182 | * 4.10 Jan 24, 1998 -- fixed a bug so now changers can change to a new | ||
183 | * slot when there is no disc in the current slot. | ||
184 | * -- Fixed a memory leak where info->changer_info was | ||
185 | * malloc'ed but never free'd when closing the device. | ||
186 | * -- Cleaned up the global namespace a bit by making more | ||
187 | * functions static that should already have been. | ||
188 | * 4.11 Mar 12, 1998 -- Added support for the CDROM_SELECT_SPEED ioctl | ||
189 | * based on a patch for 2.0.33 by Jelle Foks | ||
190 | * <jelle@scintilla.utwente.nl>, a patch for 2.0.33 | ||
191 | * by Toni Giorgino <toni@pcape2.pi.infn.it>, the SCSI | ||
192 | * version, and my own efforts. -erik | ||
193 | * -- Fixed a stupid bug which egcs was kind enough to | ||
194 | * inform me of where "Illegal mode for this track" | ||
195 | * was never returned due to a comparison on data | ||
196 | * types of limited range. | ||
197 | * 4.12 Mar 29, 1998 -- Fixed bug in CDROM_SELECT_SPEED so write speed is | ||
198 | * now set ionly for CD-R and CD-RW drives. I had | ||
199 | * removed this support because it produced errors. | ||
200 | * It produced errors _only_ for non-writers. duh. | ||
201 | * 4.13 May 05, 1998 -- Suppress useless "in progress of becoming ready" | ||
202 | * messages, since this is not an error. | ||
203 | * -- Change error messages to be const | ||
204 | * -- Remove a "\t" which looks ugly in the syslogs | ||
205 | * 4.14 July 17, 1998 -- Change to pointing to .ps version of ATAPI spec | ||
206 | * since the .pdf version doesn't seem to work... | ||
207 | * -- Updated the TODO list to something more current. | ||
208 | * | ||
209 | * 4.15 Aug 25, 1998 -- Updated ide-cd.h to respect mechine endianess, | ||
210 | * patch thanks to "Eddie C. Dost" <ecd@skynet.be> | ||
211 | * | ||
212 | * 4.50 Oct 19, 1998 -- New maintainers! | ||
213 | * Jens Axboe <axboe@image.dk> | ||
214 | * Chris Zwilling <chris@cloudnet.com> | ||
215 | * | ||
216 | * 4.51 Dec 23, 1998 -- Jens Axboe <axboe@image.dk> | ||
217 | * - ide_cdrom_reset enabled since the ide subsystem | ||
218 | * handles resets fine now. <axboe@image.dk> | ||
219 | * - Transfer size fix for Samsung CD-ROMs, thanks to | ||
220 | * "Ville Hallik" <ville.hallik@mail.ee>. | ||
221 | * - other minor stuff. | ||
222 | * | ||
223 | * 4.52 Jan 19, 1999 -- Jens Axboe <axboe@image.dk> | ||
224 | * - Detect DVD-ROM/RAM drives | ||
225 | * | ||
226 | * 4.53 Feb 22, 1999 - Include other model Samsung and one Goldstar | ||
227 | * drive in transfer size limit. | ||
228 | * - Fix the I/O error when doing eject without a medium | ||
229 | * loaded on some drives. | ||
230 | * - CDROMREADMODE2 is now implemented through | ||
231 | * CDROMREADRAW, since many drives don't support | ||
232 | * MODE2 (even though ATAPI 2.6 says they must). | ||
233 | * - Added ignore parameter to ide-cd (as a module), eg | ||
234 | * insmod ide-cd ignore='hda hdb' | ||
235 | * Useful when using ide-cd in conjunction with | ||
236 | * ide-scsi. TODO: non-modular way of doing the | ||
237 | * same. | ||
238 | * | ||
239 | * 4.54 Aug 5, 1999 - Support for MMC2 class commands through the generic | ||
240 | * packet interface to cdrom.c. | ||
241 | * - Unified audio ioctl support, most of it. | ||
242 | * - cleaned up various deprecated verify_area(). | ||
243 | * - Added ide_cdrom_packet() as the interface for | ||
244 | * the Uniform generic_packet(). | ||
245 | * - bunch of other stuff, will fill in logs later. | ||
246 | * - report 1 slot for non-changers, like the other | ||
247 | * cd-rom drivers. don't report select disc for | ||
248 | * non-changers as well. | ||
249 | * - mask out audio playing, if the device can't do it. | ||
250 | * | ||
251 | * 4.55 Sep 1, 1999 - Eliminated the rest of the audio ioctls, except | ||
252 | * for CDROMREADTOC[ENTRY|HEADER]. Some of the drivers | ||
253 | * use this independently of the actual audio handling. | ||
254 | * They will disappear later when I get the time to | ||
255 | * do it cleanly. | ||
256 | * - Minimize the TOC reading - only do it when we | ||
257 | * know a media change has occurred. | ||
258 | * - Moved all the CDROMREADx ioctls to the Uniform layer. | ||
259 | * - Heiko Eißfeldt <heiko@colossus.escape.de> supplied | ||
260 | * some fixes for CDI. | ||
261 | * - CD-ROM leaving door locked fix from Andries | ||
262 | * Brouwer <Andries.Brouwer@cwi.nl> | ||
263 | * - Erik Andersen <andersen@xmission.com> unified | ||
264 | * commands across the various drivers and how | ||
265 | * sense errors are handled. | ||
266 | * | ||
267 | * 4.56 Sep 12, 1999 - Removed changer support - it is now in the | ||
268 | * Uniform layer. | ||
269 | * - Added partition based multisession handling. | ||
270 | * - Mode sense and mode select moved to the | ||
271 | * Uniform layer. | ||
272 | * - Fixed a problem with WPI CDS-32X drive - it | ||
273 | * failed the capabilities | ||
274 | * | ||
275 | * 4.57 Apr 7, 2000 - Fixed sense reporting. | ||
276 | * - Fixed possible oops in ide_cdrom_get_last_session() | ||
277 | * - Fix locking mania and make ide_cdrom_reset relock | ||
278 | * - Stop spewing errors to log when magicdev polls with | ||
279 | * TEST_UNIT_READY on some drives. | ||
280 | * - Various fixes from Tobias Ringstrom: | ||
281 | * tray if it was locked prior to the reset. | ||
282 | * - cdrom_read_capacity returns one frame too little. | ||
283 | * - Fix real capacity reporting. | ||
284 | * | ||
285 | * 4.58 May 1, 2000 - Clean up ACER50 stuff. | ||
286 | * - Fix small problem with ide_cdrom_capacity | ||
287 | * | ||
288 | * 4.59 Aug 11, 2000 - Fix changer problem in cdrom_read_toc, we weren't | ||
289 | * correctly sensing a disc change. | ||
290 | * - Rearranged some code | ||
291 | * - Use extended sense on drives that support it for | ||
292 | * correctly reporting tray status -- from | ||
293 | * Michael D Johnson <johnsom@orst.edu> | ||
294 | * 4.60 Dec 17, 2003 - Add mt rainier support | ||
295 | * - Bump timeout for packet commands, matches sr | ||
296 | * - Odd stuff | ||
297 | * 4.61 Jan 22, 2004 - support hardware sector sizes other than 2kB, | ||
298 | * Pascal Schmidt <der.eremit@email.de> | ||
299 | * | ||
300 | *************************************************************************/ | ||
301 | |||
302 | #define IDECD_VERSION "4.61" | ||
303 | 27 | ||
304 | #include <linux/module.h> | 28 | #include <linux/module.h> |
305 | #include <linux/types.h> | 29 | #include <linux/types.h> |
@@ -313,6 +37,7 @@ | |||
313 | #include <linux/ide.h> | 37 | #include <linux/ide.h> |
314 | #include <linux/completion.h> | 38 | #include <linux/completion.h> |
315 | #include <linux/mutex.h> | 39 | #include <linux/mutex.h> |
40 | #include <linux/bcd.h> | ||
316 | 41 | ||
317 | #include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */ | 42 | #include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */ |
318 | 43 | ||
@@ -360,11 +85,11 @@ static void ide_cd_put(struct cdrom_info *cd) | |||
360 | buffers. */ | 85 | buffers. */ |
361 | static void cdrom_saw_media_change (ide_drive_t *drive) | 86 | static void cdrom_saw_media_change (ide_drive_t *drive) |
362 | { | 87 | { |
363 | struct cdrom_info *info = drive->driver_data; | 88 | struct cdrom_info *cd = drive->driver_data; |
364 | 89 | ||
365 | CDROM_STATE_FLAGS (drive)->media_changed = 1; | 90 | cd->cd_flags |= IDE_CD_FLAG_MEDIA_CHANGED; |
366 | CDROM_STATE_FLAGS (drive)->toc_valid = 0; | 91 | cd->cd_flags &= ~IDE_CD_FLAG_TOC_VALID; |
367 | info->nsectors_buffered = 0; | 92 | cd->nsectors_buffered = 0; |
368 | } | 93 | } |
369 | 94 | ||
370 | static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, | 95 | static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, |
@@ -465,134 +190,14 @@ void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
465 | } | 190 | } |
466 | } | 191 | } |
467 | } | 192 | } |
468 | #if VERBOSE_IDE_CD_ERRORS | ||
469 | { | ||
470 | int i; | ||
471 | const char *s = "bad sense key!"; | ||
472 | char buf[80]; | ||
473 | |||
474 | printk ("ATAPI device %s:\n", drive->name); | ||
475 | if (sense->error_code==0x70) | ||
476 | printk(" Error: "); | ||
477 | else if (sense->error_code==0x71) | ||
478 | printk(" Deferred Error: "); | ||
479 | else if (sense->error_code == 0x7f) | ||
480 | printk(" Vendor-specific Error: "); | ||
481 | else | ||
482 | printk(" Unknown Error Type: "); | ||
483 | |||
484 | if (sense->sense_key < ARRAY_SIZE(sense_key_texts)) | ||
485 | s = sense_key_texts[sense->sense_key]; | ||
486 | |||
487 | printk("%s -- (Sense key=0x%02x)\n", s, sense->sense_key); | ||
488 | |||
489 | if (sense->asc == 0x40) { | ||
490 | sprintf(buf, "Diagnostic failure on component 0x%02x", | ||
491 | sense->ascq); | ||
492 | s = buf; | ||
493 | } else { | ||
494 | int lo = 0, mid, hi = ARRAY_SIZE(sense_data_texts); | ||
495 | unsigned long key = (sense->sense_key << 16); | ||
496 | key |= (sense->asc << 8); | ||
497 | if (!(sense->ascq >= 0x80 && sense->ascq <= 0xdd)) | ||
498 | key |= sense->ascq; | ||
499 | s = NULL; | ||
500 | |||
501 | while (hi > lo) { | ||
502 | mid = (lo + hi) / 2; | ||
503 | if (sense_data_texts[mid].asc_ascq == key || | ||
504 | sense_data_texts[mid].asc_ascq == (0xff0000|key)) { | ||
505 | s = sense_data_texts[mid].text; | ||
506 | break; | ||
507 | } | ||
508 | else if (sense_data_texts[mid].asc_ascq > key) | ||
509 | hi = mid; | ||
510 | else | ||
511 | lo = mid+1; | ||
512 | } | ||
513 | } | ||
514 | |||
515 | if (s == NULL) { | ||
516 | if (sense->asc > 0x80) | ||
517 | s = "(vendor-specific error)"; | ||
518 | else | ||
519 | s = "(reserved error code)"; | ||
520 | } | ||
521 | |||
522 | printk(KERN_ERR " %s -- (asc=0x%02x, ascq=0x%02x)\n", | ||
523 | s, sense->asc, sense->ascq); | ||
524 | |||
525 | if (failed_command != NULL) { | ||
526 | |||
527 | int lo=0, mid, hi= ARRAY_SIZE(packet_command_texts); | ||
528 | s = NULL; | ||
529 | |||
530 | while (hi > lo) { | ||
531 | mid = (lo + hi) / 2; | ||
532 | if (packet_command_texts[mid].packet_command == | ||
533 | failed_command->cmd[0]) { | ||
534 | s = packet_command_texts[mid].text; | ||
535 | break; | ||
536 | } | ||
537 | if (packet_command_texts[mid].packet_command > | ||
538 | failed_command->cmd[0]) | ||
539 | hi = mid; | ||
540 | else | ||
541 | lo = mid+1; | ||
542 | } | ||
543 | |||
544 | printk (KERN_ERR " The failed \"%s\" packet command was: \n \"", s); | ||
545 | for (i=0; i<sizeof (failed_command->cmd); i++) | ||
546 | printk ("%02x ", failed_command->cmd[i]); | ||
547 | printk ("\"\n"); | ||
548 | } | ||
549 | |||
550 | /* The SKSV bit specifies validity of the sense_key_specific | ||
551 | * in the next two commands. It is bit 7 of the first byte. | ||
552 | * In the case of NOT_READY, if SKSV is set the drive can | ||
553 | * give us nice ETA readings. | ||
554 | */ | ||
555 | if (sense->sense_key == NOT_READY && (sense->sks[0] & 0x80)) { | ||
556 | int progress = (sense->sks[1] << 8 | sense->sks[2]) * 100; | ||
557 | printk(KERN_ERR " Command is %02d%% complete\n", progress / 0xffff); | ||
558 | |||
559 | } | ||
560 | |||
561 | if (sense->sense_key == ILLEGAL_REQUEST && | ||
562 | (sense->sks[0] & 0x80) != 0) { | ||
563 | printk(KERN_ERR " Error in %s byte %d", | ||
564 | (sense->sks[0] & 0x40) != 0 ? | ||
565 | "command packet" : "command data", | ||
566 | (sense->sks[1] << 8) + sense->sks[2]); | ||
567 | |||
568 | if ((sense->sks[0] & 0x40) != 0) | ||
569 | printk (" bit %d", sense->sks[0] & 0x07); | ||
570 | 193 | ||
571 | printk ("\n"); | 194 | ide_cd_log_error(drive->name, failed_command, sense); |
572 | } | ||
573 | } | ||
574 | |||
575 | #else /* not VERBOSE_IDE_CD_ERRORS */ | ||
576 | |||
577 | /* Suppress printing unit attention and `in progress of becoming ready' | ||
578 | errors when we're not being verbose. */ | ||
579 | |||
580 | if (sense->sense_key == UNIT_ATTENTION || | ||
581 | (sense->sense_key == NOT_READY && (sense->asc == 4 || | ||
582 | sense->asc == 0x3a))) | ||
583 | return; | ||
584 | |||
585 | printk(KERN_ERR "%s: error code: 0x%02x sense_key: 0x%02x asc: 0x%02x ascq: 0x%02x\n", | ||
586 | drive->name, | ||
587 | sense->error_code, sense->sense_key, | ||
588 | sense->asc, sense->ascq); | ||
589 | #endif /* not VERBOSE_IDE_CD_ERRORS */ | ||
590 | } | 195 | } |
591 | 196 | ||
592 | /* | 197 | /* |
593 | * Initialize a ide-cd packet command request | 198 | * Initialize a ide-cd packet command request |
594 | */ | 199 | */ |
595 | static void cdrom_prepare_request(ide_drive_t *drive, struct request *rq) | 200 | void ide_cd_init_rq(ide_drive_t *drive, struct request *rq) |
596 | { | 201 | { |
597 | struct cdrom_info *cd = drive->driver_data; | 202 | struct cdrom_info *cd = drive->driver_data; |
598 | 203 | ||
@@ -611,7 +216,7 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | |||
611 | sense = &info->sense_data; | 216 | sense = &info->sense_data; |
612 | 217 | ||
613 | /* stuff the sense request in front of our current request */ | 218 | /* stuff the sense request in front of our current request */ |
614 | cdrom_prepare_request(drive, rq); | 219 | ide_cd_init_rq(drive, rq); |
615 | 220 | ||
616 | rq->data = sense; | 221 | rq->data = sense; |
617 | rq->cmd[0] = GPCMD_REQUEST_SENSE; | 222 | rq->cmd[0] = GPCMD_REQUEST_SENSE; |
@@ -718,7 +323,6 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
718 | 323 | ||
719 | } else if (blk_pc_request(rq) || rq->cmd_type == REQ_TYPE_ATA_PC) { | 324 | } else if (blk_pc_request(rq) || rq->cmd_type == REQ_TYPE_ATA_PC) { |
720 | /* All other functions, except for READ. */ | 325 | /* All other functions, except for READ. */ |
721 | unsigned long flags; | ||
722 | 326 | ||
723 | /* | 327 | /* |
724 | * if we have an error, pass back CHECK_CONDITION as the | 328 | * if we have an error, pass back CHECK_CONDITION as the |
@@ -756,15 +360,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
756 | * remove failed request completely and end it when the | 360 | * remove failed request completely and end it when the |
757 | * request sense has completed | 361 | * request sense has completed |
758 | */ | 362 | */ |
759 | if (stat & ERR_STAT) { | 363 | goto end_request; |
760 | spin_lock_irqsave(&ide_lock, flags); | ||
761 | blkdev_dequeue_request(rq); | ||
762 | HWGROUP(drive)->rq = NULL; | ||
763 | spin_unlock_irqrestore(&ide_lock, flags); | ||
764 | |||
765 | cdrom_queue_request_sense(drive, rq->sense, rq); | ||
766 | } else | ||
767 | cdrom_end_request(drive, 0); | ||
768 | 364 | ||
769 | } else if (blk_fs_request(rq)) { | 365 | } else if (blk_fs_request(rq)) { |
770 | int do_end_request = 0; | 366 | int do_end_request = 0; |
@@ -844,23 +440,15 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
844 | sense data. We need this in order to perform end of media | 440 | sense data. We need this in order to perform end of media |
845 | processing */ | 441 | processing */ |
846 | 442 | ||
847 | if (do_end_request) { | 443 | if (do_end_request) |
848 | if (stat & ERR_STAT) { | 444 | goto end_request; |
849 | unsigned long flags; | ||
850 | spin_lock_irqsave(&ide_lock, flags); | ||
851 | blkdev_dequeue_request(rq); | ||
852 | HWGROUP(drive)->rq = NULL; | ||
853 | spin_unlock_irqrestore(&ide_lock, flags); | ||
854 | 445 | ||
855 | cdrom_queue_request_sense(drive, rq->sense, rq); | 446 | /* |
856 | } else | 447 | * If we got a CHECK_CONDITION status, |
857 | cdrom_end_request(drive, 0); | 448 | * queue a request sense command. |
858 | } else { | 449 | */ |
859 | /* If we got a CHECK_CONDITION status, | 450 | if (stat & ERR_STAT) |
860 | queue a request sense command. */ | 451 | cdrom_queue_request_sense(drive, NULL, NULL); |
861 | if (stat & ERR_STAT) | ||
862 | cdrom_queue_request_sense(drive, NULL, NULL); | ||
863 | } | ||
864 | } else { | 452 | } else { |
865 | blk_dump_rq_flags(rq, "ide-cd: bad rq"); | 453 | blk_dump_rq_flags(rq, "ide-cd: bad rq"); |
866 | cdrom_end_request(drive, 0); | 454 | cdrom_end_request(drive, 0); |
@@ -868,6 +456,21 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
868 | 456 | ||
869 | /* Retry, or handle the next request. */ | 457 | /* Retry, or handle the next request. */ |
870 | return 1; | 458 | return 1; |
459 | |||
460 | end_request: | ||
461 | if (stat & ERR_STAT) { | ||
462 | unsigned long flags; | ||
463 | |||
464 | spin_lock_irqsave(&ide_lock, flags); | ||
465 | blkdev_dequeue_request(rq); | ||
466 | HWGROUP(drive)->rq = NULL; | ||
467 | spin_unlock_irqrestore(&ide_lock, flags); | ||
468 | |||
469 | cdrom_queue_request_sense(drive, rq->sense, rq); | ||
470 | } else | ||
471 | cdrom_end_request(drive, 0); | ||
472 | |||
473 | return 1; | ||
871 | } | 474 | } |
872 | 475 | ||
873 | static int cdrom_timer_expiry(ide_drive_t *drive) | 476 | static int cdrom_timer_expiry(ide_drive_t *drive) |
@@ -924,8 +527,8 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
924 | /* Set up the controller registers. */ | 527 | /* Set up the controller registers. */ |
925 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL | | 528 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL | |
926 | IDE_TFLAG_NO_SELECT_MASK, xferlen, info->dma); | 529 | IDE_TFLAG_NO_SELECT_MASK, xferlen, info->dma); |
927 | 530 | ||
928 | if (CDROM_CONFIG_FLAGS (drive)->drq_interrupt) { | 531 | if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { |
929 | /* waiting for CDB interrupt, not DMA yet. */ | 532 | /* waiting for CDB interrupt, not DMA yet. */ |
930 | if (info->dma) | 533 | if (info->dma) |
931 | drive->waiting_for_dma = 0; | 534 | drive->waiting_for_dma = 0; |
@@ -951,10 +554,6 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
951 | by cdrom_start_packet_command. | 554 | by cdrom_start_packet_command. |
952 | HANDLER is the interrupt handler to call when the command completes | 555 | HANDLER is the interrupt handler to call when the command completes |
953 | or there's data ready. */ | 556 | or there's data ready. */ |
954 | /* | ||
955 | * changed 5 parameters to 3 for dvd-ram | ||
956 | * struct packet_command *pc; now packet_command_t *pc; | ||
957 | */ | ||
958 | #define ATAPI_MIN_CDB_BYTES 12 | 557 | #define ATAPI_MIN_CDB_BYTES 12 |
959 | static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, | 558 | static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, |
960 | struct request *rq, | 559 | struct request *rq, |
@@ -965,7 +564,7 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, | |||
965 | struct cdrom_info *info = drive->driver_data; | 564 | struct cdrom_info *info = drive->driver_data; |
966 | ide_startstop_t startstop; | 565 | ide_startstop_t startstop; |
967 | 566 | ||
968 | if (CDROM_CONFIG_FLAGS(drive)->drq_interrupt) { | 567 | if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { |
969 | /* Here we should have been called after receiving an interrupt | 568 | /* Here we should have been called after receiving an interrupt |
970 | from the device. DRQ should how be set. */ | 569 | from the device. DRQ should how be set. */ |
971 | 570 | ||
@@ -1005,6 +604,27 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, | |||
1005 | * Block read functions. | 604 | * Block read functions. |
1006 | */ | 605 | */ |
1007 | 606 | ||
607 | typedef void (xfer_func_t)(ide_drive_t *, void *, u32); | ||
608 | |||
609 | static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len) | ||
610 | { | ||
611 | while (len > 0) { | ||
612 | int dum = 0; | ||
613 | xf(drive, &dum, sizeof(dum)); | ||
614 | len -= sizeof(dum); | ||
615 | } | ||
616 | } | ||
617 | |||
618 | static void ide_cd_drain_data(ide_drive_t *drive, int nsects) | ||
619 | { | ||
620 | while (nsects > 0) { | ||
621 | static char dum[SECTOR_SIZE]; | ||
622 | |||
623 | drive->hwif->atapi_input_bytes(drive, dum, sizeof(dum)); | ||
624 | nsects--; | ||
625 | } | ||
626 | } | ||
627 | |||
1008 | /* | 628 | /* |
1009 | * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector | 629 | * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector |
1010 | * buffer. Once the first sector is added, any subsequent sectors are | 630 | * buffer. Once the first sector is added, any subsequent sectors are |
@@ -1043,11 +663,7 @@ static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector, | |||
1043 | } | 663 | } |
1044 | 664 | ||
1045 | /* Throw away any remaining data. */ | 665 | /* Throw away any remaining data. */ |
1046 | while (sectors_to_transfer > 0) { | 666 | ide_cd_drain_data(drive, sectors_to_transfer); |
1047 | static char dum[SECTOR_SIZE]; | ||
1048 | HWIF(drive)->atapi_input_bytes(drive, dum, sizeof (dum)); | ||
1049 | --sectors_to_transfer; | ||
1050 | } | ||
1051 | } | 667 | } |
1052 | 668 | ||
1053 | /* | 669 | /* |
@@ -1056,23 +672,25 @@ static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector, | |||
1056 | * ok; nonzero if the request has been terminated. | 672 | * ok; nonzero if the request has been terminated. |
1057 | */ | 673 | */ |
1058 | static | 674 | static |
1059 | int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason) | 675 | int ide_cd_check_ireason(ide_drive_t *drive, int len, int ireason, int rw) |
1060 | { | 676 | { |
1061 | if (ireason == 2) | 677 | /* |
678 | * ireason == 0: the drive wants to receive data from us | ||
679 | * ireason == 2: the drive is expecting to transfer data to us | ||
680 | */ | ||
681 | if (ireason == (!rw << 1)) | ||
1062 | return 0; | 682 | return 0; |
1063 | else if (ireason == 0) { | 683 | else if (ireason == (rw << 1)) { |
1064 | /* Whoops... The drive is expecting to receive data from us! */ | 684 | ide_hwif_t *hwif = drive->hwif; |
685 | xfer_func_t *xf; | ||
686 | |||
687 | /* Whoops... */ | ||
1065 | printk(KERN_ERR "%s: %s: wrong transfer direction!\n", | 688 | printk(KERN_ERR "%s: %s: wrong transfer direction!\n", |
1066 | drive->name, __FUNCTION__); | 689 | drive->name, __FUNCTION__); |
1067 | 690 | ||
1068 | /* Throw some data at the drive so it doesn't hang | 691 | xf = rw ? hwif->atapi_output_bytes : hwif->atapi_input_bytes; |
1069 | and quit this request. */ | 692 | ide_cd_pad_transfer(drive, xf, len); |
1070 | while (len > 0) { | 693 | } else if (rw == 0 && ireason == 1) { |
1071 | int dum = 0; | ||
1072 | HWIF(drive)->atapi_output_bytes(drive, &dum, sizeof (dum)); | ||
1073 | len -= sizeof (dum); | ||
1074 | } | ||
1075 | } else if (ireason == 1) { | ||
1076 | /* Some drives (ASUS) seem to tell us that status | 694 | /* Some drives (ASUS) seem to tell us that status |
1077 | * info is available. just get it and ignore. | 695 | * info is available. just get it and ignore. |
1078 | */ | 696 | */ |
@@ -1089,137 +707,28 @@ int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason) | |||
1089 | } | 707 | } |
1090 | 708 | ||
1091 | /* | 709 | /* |
1092 | * Interrupt routine. Called when a read request has completed. | 710 | * Assume that the drive will always provide data in multiples of at least |
711 | * SECTOR_SIZE, as it gets hairy to keep track of the transfers otherwise. | ||
1093 | */ | 712 | */ |
1094 | static ide_startstop_t cdrom_read_intr (ide_drive_t *drive) | 713 | static int ide_cd_check_transfer_size(ide_drive_t *drive, int len) |
1095 | { | 714 | { |
1096 | int stat; | 715 | struct cdrom_info *cd = drive->driver_data; |
1097 | int ireason, len, sectors_to_transfer, nskip; | ||
1098 | struct cdrom_info *info = drive->driver_data; | ||
1099 | u8 lowcyl = 0, highcyl = 0; | ||
1100 | int dma = info->dma, dma_error = 0; | ||
1101 | |||
1102 | struct request *rq = HWGROUP(drive)->rq; | ||
1103 | |||
1104 | /* | ||
1105 | * handle dma case | ||
1106 | */ | ||
1107 | if (dma) { | ||
1108 | info->dma = 0; | ||
1109 | dma_error = HWIF(drive)->ide_dma_end(drive); | ||
1110 | if (dma_error) { | ||
1111 | printk(KERN_ERR "%s: DMA read error\n", drive->name); | ||
1112 | ide_dma_off(drive); | ||
1113 | } | ||
1114 | } | ||
1115 | |||
1116 | if (cdrom_decode_status(drive, 0, &stat)) | ||
1117 | return ide_stopped; | ||
1118 | |||
1119 | if (dma) { | ||
1120 | if (!dma_error) { | ||
1121 | ide_end_request(drive, 1, rq->nr_sectors); | ||
1122 | return ide_stopped; | ||
1123 | } else | ||
1124 | return ide_error(drive, "dma error", stat); | ||
1125 | } | ||
1126 | |||
1127 | /* Read the interrupt reason and the transfer length. */ | ||
1128 | ireason = HWIF(drive)->INB(IDE_IREASON_REG) & 0x3; | ||
1129 | lowcyl = HWIF(drive)->INB(IDE_BCOUNTL_REG); | ||
1130 | highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG); | ||
1131 | |||
1132 | len = lowcyl + (256 * highcyl); | ||
1133 | |||
1134 | /* If DRQ is clear, the command has completed. */ | ||
1135 | if ((stat & DRQ_STAT) == 0) { | ||
1136 | /* If we're not done filling the current buffer, complain. | ||
1137 | Otherwise, complete the command normally. */ | ||
1138 | if (rq->current_nr_sectors > 0) { | ||
1139 | printk (KERN_ERR "%s: cdrom_read_intr: data underrun (%d blocks)\n", | ||
1140 | drive->name, rq->current_nr_sectors); | ||
1141 | rq->cmd_flags |= REQ_FAILED; | ||
1142 | cdrom_end_request(drive, 0); | ||
1143 | } else | ||
1144 | cdrom_end_request(drive, 1); | ||
1145 | return ide_stopped; | ||
1146 | } | ||
1147 | |||
1148 | /* Check that the drive is expecting to do the same thing we are. */ | ||
1149 | if (cdrom_read_check_ireason (drive, len, ireason)) | ||
1150 | return ide_stopped; | ||
1151 | |||
1152 | /* Assume that the drive will always provide data in multiples | ||
1153 | of at least SECTOR_SIZE, as it gets hairy to keep track | ||
1154 | of the transfers otherwise. */ | ||
1155 | if ((len % SECTOR_SIZE) != 0) { | ||
1156 | printk (KERN_ERR "%s: cdrom_read_intr: Bad transfer size %d\n", | ||
1157 | drive->name, len); | ||
1158 | if (CDROM_CONFIG_FLAGS(drive)->limit_nframes) | ||
1159 | printk (KERN_ERR " This drive is not supported by this version of the driver\n"); | ||
1160 | else { | ||
1161 | printk (KERN_ERR " Trying to limit transfer sizes\n"); | ||
1162 | CDROM_CONFIG_FLAGS(drive)->limit_nframes = 1; | ||
1163 | } | ||
1164 | cdrom_end_request(drive, 0); | ||
1165 | return ide_stopped; | ||
1166 | } | ||
1167 | |||
1168 | /* The number of sectors we need to read from the drive. */ | ||
1169 | sectors_to_transfer = len / SECTOR_SIZE; | ||
1170 | |||
1171 | /* First, figure out if we need to bit-bucket | ||
1172 | any of the leading sectors. */ | ||
1173 | nskip = min_t(int, rq->current_nr_sectors - bio_cur_sectors(rq->bio), sectors_to_transfer); | ||
1174 | |||
1175 | while (nskip > 0) { | ||
1176 | /* We need to throw away a sector. */ | ||
1177 | static char dum[SECTOR_SIZE]; | ||
1178 | HWIF(drive)->atapi_input_bytes(drive, dum, sizeof (dum)); | ||
1179 | |||
1180 | --rq->current_nr_sectors; | ||
1181 | --nskip; | ||
1182 | --sectors_to_transfer; | ||
1183 | } | ||
1184 | 716 | ||
1185 | /* Now loop while we still have data to read from the drive. */ | 717 | if ((len % SECTOR_SIZE) == 0) |
1186 | while (sectors_to_transfer > 0) { | 718 | return 0; |
1187 | int this_transfer; | ||
1188 | 719 | ||
1189 | /* If we've filled the present buffer but there's another | 720 | printk(KERN_ERR "%s: %s: Bad transfer size %d\n", |
1190 | chained buffer after it, move on. */ | 721 | drive->name, __FUNCTION__, len); |
1191 | if (rq->current_nr_sectors == 0 && rq->nr_sectors) | ||
1192 | cdrom_end_request(drive, 1); | ||
1193 | 722 | ||
1194 | /* If the buffers are full, cache the rest of the data in our | 723 | if (cd->cd_flags & IDE_CD_FLAG_LIMIT_NFRAMES) |
1195 | internal buffer. */ | 724 | printk(KERN_ERR " This drive is not supported by " |
1196 | if (rq->current_nr_sectors == 0) { | 725 | "this version of the driver\n"); |
1197 | cdrom_buffer_sectors(drive, rq->sector, sectors_to_transfer); | 726 | else { |
1198 | sectors_to_transfer = 0; | 727 | printk(KERN_ERR " Trying to limit transfer sizes\n"); |
1199 | } else { | 728 | cd->cd_flags |= IDE_CD_FLAG_LIMIT_NFRAMES; |
1200 | /* Transfer data to the buffers. | ||
1201 | Figure out how many sectors we can transfer | ||
1202 | to the current buffer. */ | ||
1203 | this_transfer = min_t(int, sectors_to_transfer, | ||
1204 | rq->current_nr_sectors); | ||
1205 | |||
1206 | /* Read this_transfer sectors | ||
1207 | into the current buffer. */ | ||
1208 | while (this_transfer > 0) { | ||
1209 | HWIF(drive)->atapi_input_bytes(drive, rq->buffer, SECTOR_SIZE); | ||
1210 | rq->buffer += SECTOR_SIZE; | ||
1211 | --rq->nr_sectors; | ||
1212 | --rq->current_nr_sectors; | ||
1213 | ++rq->sector; | ||
1214 | --this_transfer; | ||
1215 | --sectors_to_transfer; | ||
1216 | } | ||
1217 | } | ||
1218 | } | 729 | } |
1219 | 730 | ||
1220 | /* Done moving data! Wait for another interrupt. */ | 731 | return 1; |
1221 | ide_set_handler(drive, &cdrom_read_intr, ATAPI_WAIT_PC, NULL); | ||
1222 | return ide_started; | ||
1223 | } | 732 | } |
1224 | 733 | ||
1225 | /* | 734 | /* |
@@ -1281,48 +790,58 @@ static int cdrom_read_from_buffer (ide_drive_t *drive) | |||
1281 | return 0; | 790 | return 0; |
1282 | } | 791 | } |
1283 | 792 | ||
793 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); | ||
794 | |||
1284 | /* | 795 | /* |
1285 | * Routine to send a read packet command to the drive. | 796 | * Routine to send a read/write packet command to the drive. |
1286 | * This is usually called directly from cdrom_start_read. | 797 | * This is usually called directly from cdrom_start_{read,write}(). |
1287 | * However, for drq_interrupt devices, it is called from an interrupt | 798 | * However, for drq_interrupt devices, it is called from an interrupt |
1288 | * when the drive is ready to accept the command. | 799 | * when the drive is ready to accept the command. |
1289 | */ | 800 | */ |
1290 | static ide_startstop_t cdrom_start_read_continuation (ide_drive_t *drive) | 801 | static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) |
1291 | { | 802 | { |
1292 | struct request *rq = HWGROUP(drive)->rq; | 803 | struct request *rq = HWGROUP(drive)->rq; |
1293 | unsigned short sectors_per_frame; | ||
1294 | int nskip; | ||
1295 | 804 | ||
1296 | sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS; | 805 | if (rq_data_dir(rq) == READ) { |
806 | unsigned short sectors_per_frame = | ||
807 | queue_hardsect_size(drive->queue) >> SECTOR_BITS; | ||
808 | int nskip = rq->sector & (sectors_per_frame - 1); | ||
1297 | 809 | ||
1298 | /* If the requested sector doesn't start on a cdrom block boundary, | 810 | /* |
1299 | we must adjust the start of the transfer so that it does, | 811 | * If the requested sector doesn't start on a frame boundary, |
1300 | and remember to skip the first few sectors. | 812 | * we must adjust the start of the transfer so that it does, |
1301 | If the CURRENT_NR_SECTORS field is larger than the size | 813 | * and remember to skip the first few sectors. |
1302 | of the buffer, it will mean that we're to skip a number | 814 | * |
1303 | of sectors equal to the amount by which CURRENT_NR_SECTORS | 815 | * If the rq->current_nr_sectors field is larger than the size |
1304 | is larger than the buffer size. */ | 816 | * of the buffer, it will mean that we're to skip a number of |
1305 | nskip = rq->sector & (sectors_per_frame - 1); | 817 | * sectors equal to the amount by which rq->current_nr_sectors |
1306 | if (nskip > 0) { | 818 | * is larger than the buffer size. |
1307 | /* Sanity check... */ | 819 | */ |
1308 | if (rq->current_nr_sectors != bio_cur_sectors(rq->bio) && | 820 | if (nskip > 0) { |
1309 | (rq->sector & (sectors_per_frame - 1))) { | 821 | /* Sanity check... */ |
1310 | printk(KERN_ERR "%s: cdrom_start_read_continuation: buffer botch (%u)\n", | 822 | if (rq->current_nr_sectors != |
1311 | drive->name, rq->current_nr_sectors); | 823 | bio_cur_sectors(rq->bio)) { |
1312 | cdrom_end_request(drive, 0); | 824 | printk(KERN_ERR "%s: %s: buffer botch (%u)\n", |
1313 | return ide_stopped; | 825 | drive->name, __FUNCTION__, |
826 | rq->current_nr_sectors); | ||
827 | cdrom_end_request(drive, 0); | ||
828 | return ide_stopped; | ||
829 | } | ||
830 | rq->current_nr_sectors += nskip; | ||
1314 | } | 831 | } |
1315 | rq->current_nr_sectors += nskip; | ||
1316 | } | 832 | } |
1317 | 833 | #if 0 | |
834 | else | ||
835 | /* the immediate bit */ | ||
836 | rq->cmd[1] = 1 << 3; | ||
837 | #endif | ||
1318 | /* Set up the command */ | 838 | /* Set up the command */ |
1319 | rq->timeout = ATAPI_WAIT_PC; | 839 | rq->timeout = ATAPI_WAIT_PC; |
1320 | 840 | ||
1321 | /* Send the command to the drive and return. */ | 841 | /* Send the command to the drive and return. */ |
1322 | return cdrom_transfer_packet_command(drive, rq, &cdrom_read_intr); | 842 | return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); |
1323 | } | 843 | } |
1324 | 844 | ||
1325 | |||
1326 | #define IDECD_SEEK_THRESHOLD (1000) /* 1000 blocks */ | 845 | #define IDECD_SEEK_THRESHOLD (1000) /* 1000 blocks */ |
1327 | #define IDECD_SEEK_TIMER (5 * WAIT_MIN_SLEEP) /* 100 ms */ | 846 | #define IDECD_SEEK_TIMER (5 * WAIT_MIN_SLEEP) /* 100 ms */ |
1328 | #define IDECD_SEEK_TIMEOUT (2 * WAIT_CMD) /* 20 sec */ | 847 | #define IDECD_SEEK_TIMEOUT (2 * WAIT_CMD) /* 20 sec */ |
@@ -1335,7 +854,8 @@ static ide_startstop_t cdrom_seek_intr (ide_drive_t *drive) | |||
1335 | 854 | ||
1336 | if (cdrom_decode_status(drive, 0, &stat)) | 855 | if (cdrom_decode_status(drive, 0, &stat)) |
1337 | return ide_stopped; | 856 | return ide_stopped; |
1338 | CDROM_CONFIG_FLAGS(drive)->seeking = 1; | 857 | |
858 | info->cd_flags |= IDE_CD_FLAG_SEEKING; | ||
1339 | 859 | ||
1340 | if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) { | 860 | if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) { |
1341 | if (--retry == 0) { | 861 | if (--retry == 0) { |
@@ -1391,184 +911,25 @@ static void restore_request (struct request *rq) | |||
1391 | rq->q->prep_rq_fn(rq->q, rq); | 911 | rq->q->prep_rq_fn(rq->q, rq); |
1392 | } | 912 | } |
1393 | 913 | ||
1394 | /* | ||
1395 | * Start a read request from the CD-ROM. | ||
1396 | */ | ||
1397 | static ide_startstop_t cdrom_start_read (ide_drive_t *drive, unsigned int block) | ||
1398 | { | ||
1399 | struct cdrom_info *info = drive->driver_data; | ||
1400 | struct request *rq = HWGROUP(drive)->rq; | ||
1401 | unsigned short sectors_per_frame; | ||
1402 | |||
1403 | sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS; | ||
1404 | |||
1405 | /* We may be retrying this request after an error. Fix up | ||
1406 | any weirdness which might be present in the request packet. */ | ||
1407 | restore_request(rq); | ||
1408 | |||
1409 | /* Satisfy whatever we can of this request from our cached sector. */ | ||
1410 | if (cdrom_read_from_buffer(drive)) | ||
1411 | return ide_stopped; | ||
1412 | |||
1413 | /* Clear the local sector buffer. */ | ||
1414 | info->nsectors_buffered = 0; | ||
1415 | |||
1416 | /* use dma, if possible. */ | ||
1417 | info->dma = drive->using_dma; | ||
1418 | if ((rq->sector & (sectors_per_frame - 1)) || | ||
1419 | (rq->nr_sectors & (sectors_per_frame - 1))) | ||
1420 | info->dma = 0; | ||
1421 | |||
1422 | /* Start sending the read request to the drive. */ | ||
1423 | return cdrom_start_packet_command(drive, 32768, cdrom_start_read_continuation); | ||
1424 | } | ||
1425 | |||
1426 | /**************************************************************************** | 914 | /**************************************************************************** |
1427 | * Execute all other packet commands. | 915 | * Execute all other packet commands. |
1428 | */ | 916 | */ |
1429 | 917 | ||
1430 | /* Interrupt routine for packet command completion. */ | 918 | static void ide_cd_request_sense_fixup(struct request *rq) |
1431 | static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive) | ||
1432 | { | 919 | { |
1433 | int ireason, len, thislen; | 920 | /* |
1434 | struct request *rq = HWGROUP(drive)->rq; | 921 | * Some of the trailing request sense fields are optional, |
1435 | u8 lowcyl = 0, highcyl = 0; | 922 | * and some drives don't send them. Sigh. |
1436 | int stat; | 923 | */ |
1437 | 924 | if (rq->cmd[0] == GPCMD_REQUEST_SENSE && | |
1438 | /* Check for errors. */ | 925 | rq->data_len > 0 && rq->data_len <= 5) |
1439 | if (cdrom_decode_status(drive, 0, &stat)) | 926 | while (rq->data_len > 0) { |
1440 | return ide_stopped; | 927 | *(u8 *)rq->data++ = 0; |
1441 | 928 | --rq->data_len; | |
1442 | /* Read the interrupt reason and the transfer length. */ | ||
1443 | ireason = HWIF(drive)->INB(IDE_IREASON_REG) & 0x3; | ||
1444 | lowcyl = HWIF(drive)->INB(IDE_BCOUNTL_REG); | ||
1445 | highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG); | ||
1446 | |||
1447 | len = lowcyl + (256 * highcyl); | ||
1448 | |||
1449 | /* If DRQ is clear, the command has completed. | ||
1450 | Complain if we still have data left to transfer. */ | ||
1451 | if ((stat & DRQ_STAT) == 0) { | ||
1452 | /* Some of the trailing request sense fields are optional, and | ||
1453 | some drives don't send them. Sigh. */ | ||
1454 | if (rq->cmd[0] == GPCMD_REQUEST_SENSE && | ||
1455 | rq->data_len > 0 && | ||
1456 | rq->data_len <= 5) { | ||
1457 | while (rq->data_len > 0) { | ||
1458 | *(unsigned char *)rq->data++ = 0; | ||
1459 | --rq->data_len; | ||
1460 | } | ||
1461 | } | ||
1462 | |||
1463 | if (rq->data_len == 0) | ||
1464 | cdrom_end_request(drive, 1); | ||
1465 | else { | ||
1466 | /* Comment this out, because this always happens | ||
1467 | right after a reset occurs, and it is annoying to | ||
1468 | always print expected stuff. */ | ||
1469 | /* | ||
1470 | printk ("%s: cdrom_pc_intr: data underrun %d\n", | ||
1471 | drive->name, pc->buflen); | ||
1472 | */ | ||
1473 | rq->cmd_flags |= REQ_FAILED; | ||
1474 | cdrom_end_request(drive, 0); | ||
1475 | } | ||
1476 | return ide_stopped; | ||
1477 | } | ||
1478 | |||
1479 | /* Figure out how much data to transfer. */ | ||
1480 | thislen = rq->data_len; | ||
1481 | if (thislen > len) thislen = len; | ||
1482 | |||
1483 | /* The drive wants to be written to. */ | ||
1484 | if (ireason == 0) { | ||
1485 | if (!rq->data) { | ||
1486 | blk_dump_rq_flags(rq, "cdrom_pc_intr, write"); | ||
1487 | goto confused; | ||
1488 | } | ||
1489 | /* Transfer the data. */ | ||
1490 | HWIF(drive)->atapi_output_bytes(drive, rq->data, thislen); | ||
1491 | |||
1492 | /* If we haven't moved enough data to satisfy the drive, | ||
1493 | add some padding. */ | ||
1494 | while (len > thislen) { | ||
1495 | int dum = 0; | ||
1496 | HWIF(drive)->atapi_output_bytes(drive, &dum, sizeof(dum)); | ||
1497 | len -= sizeof(dum); | ||
1498 | } | ||
1499 | |||
1500 | /* Keep count of how much data we've moved. */ | ||
1501 | rq->data += thislen; | ||
1502 | rq->data_len -= thislen; | ||
1503 | } | ||
1504 | |||
1505 | /* Same drill for reading. */ | ||
1506 | else if (ireason == 2) { | ||
1507 | if (!rq->data) { | ||
1508 | blk_dump_rq_flags(rq, "cdrom_pc_intr, read"); | ||
1509 | goto confused; | ||
1510 | } | ||
1511 | /* Transfer the data. */ | ||
1512 | HWIF(drive)->atapi_input_bytes(drive, rq->data, thislen); | ||
1513 | |||
1514 | /* If we haven't moved enough data to satisfy the drive, | ||
1515 | add some padding. */ | ||
1516 | while (len > thislen) { | ||
1517 | int dum = 0; | ||
1518 | HWIF(drive)->atapi_input_bytes(drive, &dum, sizeof(dum)); | ||
1519 | len -= sizeof(dum); | ||
1520 | } | 929 | } |
1521 | |||
1522 | /* Keep count of how much data we've moved. */ | ||
1523 | rq->data += thislen; | ||
1524 | rq->data_len -= thislen; | ||
1525 | |||
1526 | if (blk_sense_request(rq)) | ||
1527 | rq->sense_len += thislen; | ||
1528 | } else { | ||
1529 | confused: | ||
1530 | printk (KERN_ERR "%s: cdrom_pc_intr: The drive " | ||
1531 | "appears confused (ireason = 0x%02x). " | ||
1532 | "Trying to recover by ending request.\n", | ||
1533 | drive->name, ireason); | ||
1534 | rq->cmd_flags |= REQ_FAILED; | ||
1535 | cdrom_end_request(drive, 0); | ||
1536 | return ide_stopped; | ||
1537 | } | ||
1538 | |||
1539 | /* Now we wait for another interrupt. */ | ||
1540 | ide_set_handler(drive, &cdrom_pc_intr, ATAPI_WAIT_PC, cdrom_timer_expiry); | ||
1541 | return ide_started; | ||
1542 | } | 930 | } |
1543 | 931 | ||
1544 | static ide_startstop_t cdrom_do_pc_continuation (ide_drive_t *drive) | 932 | int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq) |
1545 | { | ||
1546 | struct request *rq = HWGROUP(drive)->rq; | ||
1547 | |||
1548 | if (!rq->timeout) | ||
1549 | rq->timeout = ATAPI_WAIT_PC; | ||
1550 | |||
1551 | /* Send the command to the drive and return. */ | ||
1552 | return cdrom_transfer_packet_command(drive, rq, &cdrom_pc_intr); | ||
1553 | } | ||
1554 | |||
1555 | |||
1556 | static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive) | ||
1557 | { | ||
1558 | int len; | ||
1559 | struct request *rq = HWGROUP(drive)->rq; | ||
1560 | struct cdrom_info *info = drive->driver_data; | ||
1561 | |||
1562 | info->dma = 0; | ||
1563 | rq->cmd_flags &= ~REQ_FAILED; | ||
1564 | len = rq->data_len; | ||
1565 | |||
1566 | /* Start sending the command to the drive. */ | ||
1567 | return cdrom_start_packet_command(drive, len, cdrom_do_pc_continuation); | ||
1568 | } | ||
1569 | |||
1570 | |||
1571 | static int cdrom_queue_packet_command(ide_drive_t *drive, struct request *rq) | ||
1572 | { | 933 | { |
1573 | struct request_sense sense; | 934 | struct request_sense sense; |
1574 | int retries = 10; | 935 | int retries = 10; |
@@ -1617,37 +978,6 @@ static int cdrom_queue_packet_command(ide_drive_t *drive, struct request *rq) | |||
1617 | } | 978 | } |
1618 | 979 | ||
1619 | /* | 980 | /* |
1620 | * Write handling | ||
1621 | */ | ||
1622 | static int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ireason) | ||
1623 | { | ||
1624 | /* Two notes about IDE interrupt reason here - 0 means that | ||
1625 | * the drive wants to receive data from us, 2 means that | ||
1626 | * the drive is expecting to transfer data to us. | ||
1627 | */ | ||
1628 | if (ireason == 0) | ||
1629 | return 0; | ||
1630 | else if (ireason == 2) { | ||
1631 | /* Whoops... The drive wants to send data. */ | ||
1632 | printk(KERN_ERR "%s: %s: wrong transfer direction!\n", | ||
1633 | drive->name, __FUNCTION__); | ||
1634 | |||
1635 | while (len > 0) { | ||
1636 | int dum = 0; | ||
1637 | HWIF(drive)->atapi_input_bytes(drive, &dum, sizeof(dum)); | ||
1638 | len -= sizeof(dum); | ||
1639 | } | ||
1640 | } else { | ||
1641 | /* Drive wants a command packet, or invalid ireason... */ | ||
1642 | printk(KERN_ERR "%s: %s: bad interrupt reason 0x%02x\n", | ||
1643 | drive->name, __FUNCTION__, ireason); | ||
1644 | } | ||
1645 | |||
1646 | cdrom_end_request(drive, 0); | ||
1647 | return 1; | ||
1648 | } | ||
1649 | |||
1650 | /* | ||
1651 | * Called from blk_end_request_callback() after the data of the request | 981 | * Called from blk_end_request_callback() after the data of the request |
1652 | * is completed and before the request is completed. | 982 | * is completed and before the request is completed. |
1653 | * By returning value '1', blk_end_request_callback() returns immediately | 983 | * By returning value '1', blk_end_request_callback() returns immediately |
@@ -1658,29 +988,27 @@ static int cdrom_newpc_intr_dummy_cb(struct request *rq) | |||
1658 | return 1; | 988 | return 1; |
1659 | } | 989 | } |
1660 | 990 | ||
1661 | typedef void (xfer_func_t)(ide_drive_t *, void *, u32); | ||
1662 | |||
1663 | /* | ||
1664 | * best way to deal with dma that is not sector aligned right now... note | ||
1665 | * that in this path we are not using ->data or ->buffer at all. this irs | ||
1666 | * can replace cdrom_pc_intr, cdrom_read_intr, and cdrom_write_intr in the | ||
1667 | * future. | ||
1668 | */ | ||
1669 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | 991 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) |
1670 | { | 992 | { |
1671 | struct cdrom_info *info = drive->driver_data; | 993 | struct cdrom_info *info = drive->driver_data; |
1672 | struct request *rq = HWGROUP(drive)->rq; | 994 | struct request *rq = HWGROUP(drive)->rq; |
1673 | int dma_error, dma, stat, ireason, len, thislen; | ||
1674 | u8 lowcyl, highcyl; | ||
1675 | xfer_func_t *xferfunc; | 995 | xfer_func_t *xferfunc; |
1676 | unsigned long flags; | 996 | ide_expiry_t *expiry = NULL; |
997 | int dma_error = 0, dma, stat, ireason, len, thislen, uptodate = 0; | ||
998 | int write = (rq_data_dir(rq) == WRITE) ? 1 : 0; | ||
999 | unsigned int timeout; | ||
1000 | u8 lowcyl, highcyl; | ||
1677 | 1001 | ||
1678 | /* Check for errors. */ | 1002 | /* Check for errors. */ |
1679 | dma_error = 0; | ||
1680 | dma = info->dma; | 1003 | dma = info->dma; |
1681 | if (dma) { | 1004 | if (dma) { |
1682 | info->dma = 0; | 1005 | info->dma = 0; |
1683 | dma_error = HWIF(drive)->ide_dma_end(drive); | 1006 | dma_error = HWIF(drive)->ide_dma_end(drive); |
1007 | if (dma_error) { | ||
1008 | printk(KERN_ERR "%s: DMA %s error\n", drive->name, | ||
1009 | write ? "write" : "read"); | ||
1010 | ide_dma_off(drive); | ||
1011 | } | ||
1684 | } | 1012 | } |
1685 | 1013 | ||
1686 | if (cdrom_decode_status(drive, 0, &stat)) | 1014 | if (cdrom_decode_status(drive, 0, &stat)) |
@@ -1690,19 +1018,13 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1690 | * using dma, transfer is complete now | 1018 | * using dma, transfer is complete now |
1691 | */ | 1019 | */ |
1692 | if (dma) { | 1020 | if (dma) { |
1693 | if (dma_error) { | 1021 | if (dma_error) |
1694 | printk(KERN_ERR "ide-cd: dma error\n"); | ||
1695 | ide_dma_off(drive); | ||
1696 | return ide_error(drive, "dma error", stat); | 1022 | return ide_error(drive, "dma error", stat); |
1023 | if (blk_fs_request(rq)) { | ||
1024 | ide_end_request(drive, 1, rq->nr_sectors); | ||
1025 | return ide_stopped; | ||
1697 | } | 1026 | } |
1698 | 1027 | goto end_request; | |
1699 | spin_lock_irqsave(&ide_lock, flags); | ||
1700 | if (__blk_end_request(rq, 0, rq->data_len)) | ||
1701 | BUG(); | ||
1702 | HWGROUP(drive)->rq = NULL; | ||
1703 | spin_unlock_irqrestore(&ide_lock, flags); | ||
1704 | |||
1705 | return ide_stopped; | ||
1706 | } | 1028 | } |
1707 | 1029 | ||
1708 | /* | 1030 | /* |
@@ -1713,7 +1035,8 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1713 | highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG); | 1035 | highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG); |
1714 | 1036 | ||
1715 | len = lowcyl + (256 * highcyl); | 1037 | len = lowcyl + (256 * highcyl); |
1716 | thislen = rq->data_len; | 1038 | |
1039 | thislen = blk_fs_request(rq) ? len : rq->data_len; | ||
1717 | if (thislen > len) | 1040 | if (thislen > len) |
1718 | thislen = len; | 1041 | thislen = len; |
1719 | 1042 | ||
@@ -1721,53 +1044,111 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1721 | * If DRQ is clear, the command has completed. | 1044 | * If DRQ is clear, the command has completed. |
1722 | */ | 1045 | */ |
1723 | if ((stat & DRQ_STAT) == 0) { | 1046 | if ((stat & DRQ_STAT) == 0) { |
1724 | spin_lock_irqsave(&ide_lock, flags); | 1047 | if (blk_fs_request(rq)) { |
1725 | if (__blk_end_request(rq, 0, rq->data_len)) | 1048 | /* |
1726 | BUG(); | 1049 | * If we're not done reading/writing, complain. |
1727 | HWGROUP(drive)->rq = NULL; | 1050 | * Otherwise, complete the command normally. |
1728 | spin_unlock_irqrestore(&ide_lock, flags); | 1051 | */ |
1729 | 1052 | uptodate = 1; | |
1730 | return ide_stopped; | 1053 | if (rq->current_nr_sectors > 0) { |
1054 | printk(KERN_ERR "%s: %s: data underrun " | ||
1055 | "(%d blocks)\n", | ||
1056 | drive->name, __FUNCTION__, | ||
1057 | rq->current_nr_sectors); | ||
1058 | if (!write) | ||
1059 | rq->cmd_flags |= REQ_FAILED; | ||
1060 | uptodate = 0; | ||
1061 | } | ||
1062 | cdrom_end_request(drive, uptodate); | ||
1063 | return ide_stopped; | ||
1064 | } else if (!blk_pc_request(rq)) { | ||
1065 | ide_cd_request_sense_fixup(rq); | ||
1066 | /* Complain if we still have data left to transfer. */ | ||
1067 | uptodate = rq->data_len ? 0 : 1; | ||
1068 | } | ||
1069 | goto end_request; | ||
1731 | } | 1070 | } |
1732 | 1071 | ||
1733 | /* | 1072 | /* |
1734 | * check which way to transfer data | 1073 | * check which way to transfer data |
1735 | */ | 1074 | */ |
1736 | if (rq_data_dir(rq) == WRITE) { | 1075 | if (blk_fs_request(rq) || blk_pc_request(rq)) { |
1737 | /* | 1076 | if (ide_cd_check_ireason(drive, len, ireason, write)) |
1738 | * write to drive | ||
1739 | */ | ||
1740 | if (cdrom_write_check_ireason(drive, len, ireason)) | ||
1741 | return ide_stopped; | 1077 | return ide_stopped; |
1742 | 1078 | ||
1743 | xferfunc = HWIF(drive)->atapi_output_bytes; | 1079 | if (blk_fs_request(rq) && write == 0) { |
1744 | } else { | 1080 | int nskip; |
1745 | /* | ||
1746 | * read from drive | ||
1747 | */ | ||
1748 | if (cdrom_read_check_ireason(drive, len, ireason)) | ||
1749 | return ide_stopped; | ||
1750 | 1081 | ||
1082 | if (ide_cd_check_transfer_size(drive, len)) { | ||
1083 | cdrom_end_request(drive, 0); | ||
1084 | return ide_stopped; | ||
1085 | } | ||
1086 | |||
1087 | /* | ||
1088 | * First, figure out if we need to bit-bucket | ||
1089 | * any of the leading sectors. | ||
1090 | */ | ||
1091 | nskip = min_t(int, rq->current_nr_sectors | ||
1092 | - bio_cur_sectors(rq->bio), | ||
1093 | thislen >> 9); | ||
1094 | if (nskip > 0) { | ||
1095 | ide_cd_drain_data(drive, nskip); | ||
1096 | rq->current_nr_sectors -= nskip; | ||
1097 | thislen -= (nskip << 9); | ||
1098 | } | ||
1099 | } | ||
1100 | } | ||
1101 | |||
1102 | if (ireason == 0) { | ||
1103 | write = 1; | ||
1104 | xferfunc = HWIF(drive)->atapi_output_bytes; | ||
1105 | } else if (ireason == 2 || (ireason == 1 && | ||
1106 | (blk_fs_request(rq) || blk_pc_request(rq)))) { | ||
1107 | write = 0; | ||
1751 | xferfunc = HWIF(drive)->atapi_input_bytes; | 1108 | xferfunc = HWIF(drive)->atapi_input_bytes; |
1109 | } else { | ||
1110 | printk(KERN_ERR "%s: %s: The drive " | ||
1111 | "appears confused (ireason = 0x%02x). " | ||
1112 | "Trying to recover by ending request.\n", | ||
1113 | drive->name, __FUNCTION__, ireason); | ||
1114 | goto end_request; | ||
1752 | } | 1115 | } |
1753 | 1116 | ||
1754 | /* | 1117 | /* |
1755 | * transfer data | 1118 | * transfer data |
1756 | */ | 1119 | */ |
1757 | while (thislen > 0) { | 1120 | while (thislen > 0) { |
1758 | int blen = blen = rq->data_len; | 1121 | u8 *ptr = blk_fs_request(rq) ? NULL : rq->data; |
1759 | char *ptr = rq->data; | 1122 | int blen = rq->data_len; |
1760 | 1123 | ||
1761 | /* | 1124 | /* |
1762 | * bio backed? | 1125 | * bio backed? |
1763 | */ | 1126 | */ |
1764 | if (rq->bio) { | 1127 | if (rq->bio) { |
1765 | ptr = bio_data(rq->bio); | 1128 | if (blk_fs_request(rq)) { |
1766 | blen = bio_iovec(rq->bio)->bv_len; | 1129 | ptr = rq->buffer; |
1130 | blen = rq->current_nr_sectors << 9; | ||
1131 | } else { | ||
1132 | ptr = bio_data(rq->bio); | ||
1133 | blen = bio_iovec(rq->bio)->bv_len; | ||
1134 | } | ||
1767 | } | 1135 | } |
1768 | 1136 | ||
1769 | if (!ptr) { | 1137 | if (!ptr) { |
1770 | printk(KERN_ERR "%s: confused, missing data\n", drive->name); | 1138 | if (blk_fs_request(rq) && !write) |
1139 | /* | ||
1140 | * If the buffers are full, cache the rest | ||
1141 | * of the data in our internal buffer. | ||
1142 | */ | ||
1143 | cdrom_buffer_sectors(drive, rq->sector, | ||
1144 | thislen >> 9); | ||
1145 | else { | ||
1146 | printk(KERN_ERR "%s: confused, missing data\n", | ||
1147 | drive->name); | ||
1148 | blk_dump_rq_flags(rq, rq_data_dir(rq) | ||
1149 | ? "cdrom_newpc_intr, write" | ||
1150 | : "cdrom_newpc_intr, read"); | ||
1151 | } | ||
1771 | break; | 1152 | break; |
1772 | } | 1153 | } |
1773 | 1154 | ||
@@ -1778,185 +1159,117 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1778 | 1159 | ||
1779 | thislen -= blen; | 1160 | thislen -= blen; |
1780 | len -= blen; | 1161 | len -= blen; |
1781 | rq->data_len -= blen; | ||
1782 | 1162 | ||
1783 | if (rq->bio) | 1163 | if (blk_fs_request(rq)) { |
1164 | rq->buffer += blen; | ||
1165 | rq->nr_sectors -= (blen >> 9); | ||
1166 | rq->current_nr_sectors -= (blen >> 9); | ||
1167 | rq->sector += (blen >> 9); | ||
1168 | |||
1169 | if (rq->current_nr_sectors == 0 && rq->nr_sectors) | ||
1170 | cdrom_end_request(drive, 1); | ||
1171 | } else { | ||
1172 | rq->data_len -= blen; | ||
1173 | |||
1784 | /* | 1174 | /* |
1785 | * The request can't be completed until DRQ is cleared. | 1175 | * The request can't be completed until DRQ is cleared. |
1786 | * So complete the data, but don't complete the request | 1176 | * So complete the data, but don't complete the request |
1787 | * using the dummy function for the callback feature | 1177 | * using the dummy function for the callback feature |
1788 | * of blk_end_request_callback(). | 1178 | * of blk_end_request_callback(). |
1789 | */ | 1179 | */ |
1790 | blk_end_request_callback(rq, 0, blen, | 1180 | if (rq->bio) |
1181 | blk_end_request_callback(rq, 0, blen, | ||
1791 | cdrom_newpc_intr_dummy_cb); | 1182 | cdrom_newpc_intr_dummy_cb); |
1792 | else | 1183 | else |
1793 | rq->data += blen; | 1184 | rq->data += blen; |
1794 | } | ||
1795 | |||
1796 | /* | ||
1797 | * pad, if necessary | ||
1798 | */ | ||
1799 | if (len > 0) { | ||
1800 | while (len > 0) { | ||
1801 | int pad = 0; | ||
1802 | |||
1803 | xferfunc(drive, &pad, sizeof(pad)); | ||
1804 | len -= sizeof(pad); | ||
1805 | } | ||
1806 | } | ||
1807 | |||
1808 | BUG_ON(HWGROUP(drive)->handler != NULL); | ||
1809 | |||
1810 | ide_set_handler(drive, cdrom_newpc_intr, rq->timeout, NULL); | ||
1811 | return ide_started; | ||
1812 | } | ||
1813 | |||
1814 | static ide_startstop_t cdrom_write_intr(ide_drive_t *drive) | ||
1815 | { | ||
1816 | int stat, ireason, len, sectors_to_transfer, uptodate; | ||
1817 | struct cdrom_info *info = drive->driver_data; | ||
1818 | int dma_error = 0, dma = info->dma; | ||
1819 | u8 lowcyl = 0, highcyl = 0; | ||
1820 | |||
1821 | struct request *rq = HWGROUP(drive)->rq; | ||
1822 | |||
1823 | /* Check for errors. */ | ||
1824 | if (dma) { | ||
1825 | info->dma = 0; | ||
1826 | dma_error = HWIF(drive)->ide_dma_end(drive); | ||
1827 | if (dma_error) { | ||
1828 | printk(KERN_ERR "%s: DMA write error\n", drive->name); | ||
1829 | ide_dma_off(drive); | ||
1830 | } | 1185 | } |
1831 | } | 1186 | } |
1832 | 1187 | ||
1833 | if (cdrom_decode_status(drive, 0, &stat)) | 1188 | if (write && blk_sense_request(rq)) |
1834 | return ide_stopped; | 1189 | rq->sense_len += thislen; |
1835 | 1190 | ||
1836 | /* | 1191 | /* |
1837 | * using dma, transfer is complete now | 1192 | * pad, if necessary |
1838 | */ | 1193 | */ |
1839 | if (dma) { | 1194 | if (!blk_fs_request(rq) && len > 0) |
1840 | if (dma_error) | 1195 | ide_cd_pad_transfer(drive, xferfunc, len); |
1841 | return ide_error(drive, "dma error", stat); | ||
1842 | 1196 | ||
1843 | ide_end_request(drive, 1, rq->nr_sectors); | 1197 | if (blk_pc_request(rq)) { |
1844 | return ide_stopped; | 1198 | timeout = rq->timeout; |
1199 | } else { | ||
1200 | timeout = ATAPI_WAIT_PC; | ||
1201 | if (!blk_fs_request(rq)) | ||
1202 | expiry = cdrom_timer_expiry; | ||
1845 | } | 1203 | } |
1846 | 1204 | ||
1847 | /* Read the interrupt reason and the transfer length. */ | 1205 | ide_set_handler(drive, cdrom_newpc_intr, timeout, expiry); |
1848 | ireason = HWIF(drive)->INB(IDE_IREASON_REG) & 0x3; | 1206 | return ide_started; |
1849 | lowcyl = HWIF(drive)->INB(IDE_BCOUNTL_REG); | ||
1850 | highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG); | ||
1851 | 1207 | ||
1852 | len = lowcyl + (256 * highcyl); | 1208 | end_request: |
1209 | if (blk_pc_request(rq)) { | ||
1210 | unsigned long flags; | ||
1853 | 1211 | ||
1854 | /* If DRQ is clear, the command has completed. */ | 1212 | spin_lock_irqsave(&ide_lock, flags); |
1855 | if ((stat & DRQ_STAT) == 0) { | 1213 | if (__blk_end_request(rq, 0, rq->data_len)) |
1856 | /* If we're not done writing, complain. | 1214 | BUG(); |
1857 | * Otherwise, complete the command normally. | 1215 | HWGROUP(drive)->rq = NULL; |
1858 | */ | 1216 | spin_unlock_irqrestore(&ide_lock, flags); |
1859 | uptodate = 1; | 1217 | } else { |
1860 | if (rq->current_nr_sectors > 0) { | 1218 | if (!uptodate) |
1861 | printk(KERN_ERR "%s: %s: data underrun (%d blocks)\n", | 1219 | rq->cmd_flags |= REQ_FAILED; |
1862 | drive->name, __FUNCTION__, | ||
1863 | rq->current_nr_sectors); | ||
1864 | uptodate = 0; | ||
1865 | } | ||
1866 | cdrom_end_request(drive, uptodate); | 1220 | cdrom_end_request(drive, uptodate); |
1867 | return ide_stopped; | ||
1868 | } | 1221 | } |
1222 | return ide_stopped; | ||
1223 | } | ||
1869 | 1224 | ||
1870 | /* Check that the drive is expecting to do the same thing we are. */ | 1225 | static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) |
1871 | if (cdrom_write_check_ireason(drive, len, ireason)) | 1226 | { |
1872 | return ide_stopped; | 1227 | struct cdrom_info *cd = drive->driver_data; |
1873 | 1228 | int write = rq_data_dir(rq) == WRITE; | |
1874 | sectors_to_transfer = len / SECTOR_SIZE; | 1229 | unsigned short sectors_per_frame = |
1875 | 1230 | queue_hardsect_size(drive->queue) >> SECTOR_BITS; | |
1876 | /* | ||
1877 | * now loop and write out the data | ||
1878 | */ | ||
1879 | while (sectors_to_transfer > 0) { | ||
1880 | int this_transfer; | ||
1881 | |||
1882 | if (!rq->current_nr_sectors) { | ||
1883 | printk(KERN_ERR "%s: %s: confused, missing data\n", | ||
1884 | drive->name, __FUNCTION__); | ||
1885 | break; | ||
1886 | } | ||
1887 | 1231 | ||
1232 | if (write) { | ||
1888 | /* | 1233 | /* |
1889 | * Figure out how many sectors we can transfer | 1234 | * disk has become write protected |
1890 | */ | 1235 | */ |
1891 | this_transfer = min_t(int, sectors_to_transfer, rq->current_nr_sectors); | 1236 | if (cd->disk->policy) { |
1892 | 1237 | cdrom_end_request(drive, 0); | |
1893 | while (this_transfer > 0) { | 1238 | return ide_stopped; |
1894 | HWIF(drive)->atapi_output_bytes(drive, rq->buffer, SECTOR_SIZE); | ||
1895 | rq->buffer += SECTOR_SIZE; | ||
1896 | --rq->nr_sectors; | ||
1897 | --rq->current_nr_sectors; | ||
1898 | ++rq->sector; | ||
1899 | --this_transfer; | ||
1900 | --sectors_to_transfer; | ||
1901 | } | 1239 | } |
1902 | 1240 | } else { | |
1903 | /* | 1241 | /* |
1904 | * current buffer complete, move on | 1242 | * We may be retrying this request after an error. Fix up any |
1243 | * weirdness which might be present in the request packet. | ||
1905 | */ | 1244 | */ |
1906 | if (rq->current_nr_sectors == 0 && rq->nr_sectors) | 1245 | restore_request(rq); |
1907 | cdrom_end_request(drive, 1); | ||
1908 | } | ||
1909 | |||
1910 | /* re-arm handler */ | ||
1911 | ide_set_handler(drive, &cdrom_write_intr, ATAPI_WAIT_PC, NULL); | ||
1912 | return ide_started; | ||
1913 | } | ||
1914 | |||
1915 | static ide_startstop_t cdrom_start_write_cont(ide_drive_t *drive) | ||
1916 | { | ||
1917 | struct request *rq = HWGROUP(drive)->rq; | ||
1918 | 1246 | ||
1919 | #if 0 /* the immediate bit */ | 1247 | /* Satisfy whatever we can of this request from our cache. */ |
1920 | rq->cmd[1] = 1 << 3; | 1248 | if (cdrom_read_from_buffer(drive)) |
1921 | #endif | 1249 | return ide_stopped; |
1922 | rq->timeout = ATAPI_WAIT_PC; | 1250 | } |
1923 | |||
1924 | return cdrom_transfer_packet_command(drive, rq, cdrom_write_intr); | ||
1925 | } | ||
1926 | |||
1927 | static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq) | ||
1928 | { | ||
1929 | struct cdrom_info *info = drive->driver_data; | ||
1930 | struct gendisk *g = info->disk; | ||
1931 | unsigned short sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS; | ||
1932 | 1251 | ||
1933 | /* | 1252 | /* |
1934 | * writes *must* be hardware frame aligned | 1253 | * use DMA, if possible / writes *must* be hardware frame aligned |
1935 | */ | 1254 | */ |
1936 | if ((rq->nr_sectors & (sectors_per_frame - 1)) || | 1255 | if ((rq->nr_sectors & (sectors_per_frame - 1)) || |
1937 | (rq->sector & (sectors_per_frame - 1))) { | 1256 | (rq->sector & (sectors_per_frame - 1))) { |
1938 | cdrom_end_request(drive, 0); | 1257 | if (write) { |
1939 | return ide_stopped; | 1258 | cdrom_end_request(drive, 0); |
1940 | } | 1259 | return ide_stopped; |
1941 | 1260 | } | |
1942 | /* | 1261 | cd->dma = 0; |
1943 | * disk has become write protected | 1262 | } else |
1944 | */ | 1263 | cd->dma = drive->using_dma; |
1945 | if (g->policy) { | ||
1946 | cdrom_end_request(drive, 0); | ||
1947 | return ide_stopped; | ||
1948 | } | ||
1949 | |||
1950 | info->nsectors_buffered = 0; | ||
1951 | 1264 | ||
1952 | /* use dma, if possible. we don't need to check more, since we | 1265 | /* Clear the local sector buffer. */ |
1953 | * know that the transfer is always (at least!) frame aligned */ | 1266 | cd->nsectors_buffered = 0; |
1954 | info->dma = drive->using_dma ? 1 : 0; | ||
1955 | 1267 | ||
1956 | info->devinfo.media_written = 1; | 1268 | if (write) |
1269 | cd->devinfo.media_written = 1; | ||
1957 | 1270 | ||
1958 | /* Start sending the write request to the drive. */ | 1271 | /* Start sending the read/write request to the drive. */ |
1959 | return cdrom_start_packet_command(drive, 32768, cdrom_start_write_cont); | 1272 | return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont); |
1960 | } | 1273 | } |
1961 | 1274 | ||
1962 | static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive) | 1275 | static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive) |
@@ -1973,7 +1286,10 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
1973 | { | 1286 | { |
1974 | struct cdrom_info *info = drive->driver_data; | 1287 | struct cdrom_info *info = drive->driver_data; |
1975 | 1288 | ||
1976 | rq->cmd_flags |= REQ_QUIET; | 1289 | if (blk_pc_request(rq)) |
1290 | rq->cmd_flags |= REQ_QUIET; | ||
1291 | else | ||
1292 | rq->cmd_flags &= ~REQ_FAILED; | ||
1977 | 1293 | ||
1978 | info->dma = 0; | 1294 | info->dma = 0; |
1979 | 1295 | ||
@@ -2010,7 +1326,7 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block) | |||
2010 | struct cdrom_info *info = drive->driver_data; | 1326 | struct cdrom_info *info = drive->driver_data; |
2011 | 1327 | ||
2012 | if (blk_fs_request(rq)) { | 1328 | if (blk_fs_request(rq)) { |
2013 | if (CDROM_CONFIG_FLAGS(drive)->seeking) { | 1329 | if (info->cd_flags & IDE_CD_FLAG_SEEKING) { |
2014 | unsigned long elapsed = jiffies - info->start_seek; | 1330 | unsigned long elapsed = jiffies - info->start_seek; |
2015 | int stat = HWIF(drive)->INB(IDE_STATUS_REG); | 1331 | int stat = HWIF(drive)->INB(IDE_STATUS_REG); |
2016 | 1332 | ||
@@ -2021,22 +1337,16 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block) | |||
2021 | } | 1337 | } |
2022 | printk (KERN_ERR "%s: DSC timeout\n", drive->name); | 1338 | printk (KERN_ERR "%s: DSC timeout\n", drive->name); |
2023 | } | 1339 | } |
2024 | CDROM_CONFIG_FLAGS(drive)->seeking = 0; | 1340 | info->cd_flags &= ~IDE_CD_FLAG_SEEKING; |
2025 | } | 1341 | } |
2026 | if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) { | 1342 | if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) { |
2027 | action = cdrom_start_seek(drive, block); | 1343 | action = cdrom_start_seek(drive, block); |
2028 | } else { | 1344 | } else |
2029 | if (rq_data_dir(rq) == READ) | 1345 | action = cdrom_start_rw(drive, rq); |
2030 | action = cdrom_start_read(drive, block); | ||
2031 | else | ||
2032 | action = cdrom_start_write(drive, rq); | ||
2033 | } | ||
2034 | info->last_block = block; | 1346 | info->last_block = block; |
2035 | return action; | 1347 | return action; |
2036 | } else if (rq->cmd_type == REQ_TYPE_SENSE || | 1348 | } else if (blk_sense_request(rq) || blk_pc_request(rq) || |
2037 | rq->cmd_type == REQ_TYPE_ATA_PC) { | 1349 | rq->cmd_type == REQ_TYPE_ATA_PC) { |
2038 | return cdrom_do_packet_command(drive); | ||
2039 | } else if (blk_pc_request(rq)) { | ||
2040 | return cdrom_do_block_pc(drive, rq); | 1350 | return cdrom_do_block_pc(drive, rq); |
2041 | } else if (blk_special_request(rq)) { | 1351 | } else if (blk_special_request(rq)) { |
2042 | /* | 1352 | /* |
@@ -2063,141 +1373,33 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block) | |||
2063 | * can also be NULL, in which case no sense information is returned. | 1373 | * can also be NULL, in which case no sense information is returned. |
2064 | */ | 1374 | */ |
2065 | 1375 | ||
2066 | #if ! STANDARD_ATAPI | ||
2067 | static inline | ||
2068 | int bin2bcd (int x) | ||
2069 | { | ||
2070 | return (x%10) | ((x/10) << 4); | ||
2071 | } | ||
2072 | |||
2073 | |||
2074 | static inline | ||
2075 | int bcd2bin (int x) | ||
2076 | { | ||
2077 | return (x >> 4) * 10 + (x & 0x0f); | ||
2078 | } | ||
2079 | |||
2080 | static | 1376 | static |
2081 | void msf_from_bcd (struct atapi_msf *msf) | 1377 | void msf_from_bcd (struct atapi_msf *msf) |
2082 | { | 1378 | { |
2083 | msf->minute = bcd2bin (msf->minute); | 1379 | msf->minute = BCD2BIN(msf->minute); |
2084 | msf->second = bcd2bin (msf->second); | 1380 | msf->second = BCD2BIN(msf->second); |
2085 | msf->frame = bcd2bin (msf->frame); | 1381 | msf->frame = BCD2BIN(msf->frame); |
2086 | } | ||
2087 | |||
2088 | #endif /* not STANDARD_ATAPI */ | ||
2089 | |||
2090 | |||
2091 | static inline | ||
2092 | void lba_to_msf (int lba, byte *m, byte *s, byte *f) | ||
2093 | { | ||
2094 | lba += CD_MSF_OFFSET; | ||
2095 | lba &= 0xffffff; /* negative lbas use only 24 bits */ | ||
2096 | *m = lba / (CD_SECS * CD_FRAMES); | ||
2097 | lba %= (CD_SECS * CD_FRAMES); | ||
2098 | *s = lba / CD_FRAMES; | ||
2099 | *f = lba % CD_FRAMES; | ||
2100 | } | ||
2101 | |||
2102 | |||
2103 | static inline | ||
2104 | int msf_to_lba (byte m, byte s, byte f) | ||
2105 | { | ||
2106 | return (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET; | ||
2107 | } | 1382 | } |
2108 | 1383 | ||
2109 | static int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) | 1384 | int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) |
2110 | { | 1385 | { |
2111 | struct request req; | 1386 | struct request req; |
2112 | struct cdrom_info *info = drive->driver_data; | 1387 | struct cdrom_info *info = drive->driver_data; |
2113 | struct cdrom_device_info *cdi = &info->devinfo; | 1388 | struct cdrom_device_info *cdi = &info->devinfo; |
2114 | 1389 | ||
2115 | cdrom_prepare_request(drive, &req); | 1390 | ide_cd_init_rq(drive, &req); |
2116 | 1391 | ||
2117 | req.sense = sense; | 1392 | req.sense = sense; |
2118 | req.cmd[0] = GPCMD_TEST_UNIT_READY; | 1393 | req.cmd[0] = GPCMD_TEST_UNIT_READY; |
2119 | req.cmd_flags |= REQ_QUIET; | 1394 | req.cmd_flags |= REQ_QUIET; |
2120 | 1395 | ||
2121 | #if ! STANDARD_ATAPI | 1396 | /* |
2122 | /* the Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to | 1397 | * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to |
2123 | switch CDs instead of supporting the LOAD_UNLOAD opcode */ | 1398 | * switch CDs instead of supporting the LOAD_UNLOAD opcode. |
2124 | 1399 | */ | |
2125 | req.cmd[7] = cdi->sanyo_slot % 3; | 1400 | req.cmd[7] = cdi->sanyo_slot % 3; |
2126 | #endif /* not STANDARD_ATAPI */ | ||
2127 | |||
2128 | return cdrom_queue_packet_command(drive, &req); | ||
2129 | } | ||
2130 | |||
2131 | |||
2132 | /* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */ | ||
2133 | static int | ||
2134 | cdrom_lockdoor(ide_drive_t *drive, int lockflag, struct request_sense *sense) | ||
2135 | { | ||
2136 | struct request_sense my_sense; | ||
2137 | struct request req; | ||
2138 | int stat; | ||
2139 | |||
2140 | if (sense == NULL) | ||
2141 | sense = &my_sense; | ||
2142 | |||
2143 | /* If the drive cannot lock the door, just pretend. */ | ||
2144 | if (CDROM_CONFIG_FLAGS(drive)->no_doorlock) { | ||
2145 | stat = 0; | ||
2146 | } else { | ||
2147 | cdrom_prepare_request(drive, &req); | ||
2148 | req.sense = sense; | ||
2149 | req.cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; | ||
2150 | req.cmd[4] = lockflag ? 1 : 0; | ||
2151 | stat = cdrom_queue_packet_command(drive, &req); | ||
2152 | } | ||
2153 | |||
2154 | /* If we got an illegal field error, the drive | ||
2155 | probably cannot lock the door. */ | ||
2156 | if (stat != 0 && | ||
2157 | sense->sense_key == ILLEGAL_REQUEST && | ||
2158 | (sense->asc == 0x24 || sense->asc == 0x20)) { | ||
2159 | printk (KERN_ERR "%s: door locking not supported\n", | ||
2160 | drive->name); | ||
2161 | CDROM_CONFIG_FLAGS(drive)->no_doorlock = 1; | ||
2162 | stat = 0; | ||
2163 | } | ||
2164 | |||
2165 | /* no medium, that's alright. */ | ||
2166 | if (stat != 0 && sense->sense_key == NOT_READY && sense->asc == 0x3a) | ||
2167 | stat = 0; | ||
2168 | |||
2169 | if (stat == 0) | ||
2170 | CDROM_STATE_FLAGS(drive)->door_locked = lockflag; | ||
2171 | |||
2172 | return stat; | ||
2173 | } | ||
2174 | 1401 | ||
2175 | 1402 | return ide_cd_queue_pc(drive, &req); | |
2176 | /* Eject the disk if EJECTFLAG is 0. | ||
2177 | If EJECTFLAG is 1, try to reload the disk. */ | ||
2178 | static int cdrom_eject(ide_drive_t *drive, int ejectflag, | ||
2179 | struct request_sense *sense) | ||
2180 | { | ||
2181 | struct request req; | ||
2182 | char loej = 0x02; | ||
2183 | |||
2184 | if (CDROM_CONFIG_FLAGS(drive)->no_eject && !ejectflag) | ||
2185 | return -EDRIVE_CANT_DO_THIS; | ||
2186 | |||
2187 | /* reload fails on some drives, if the tray is locked */ | ||
2188 | if (CDROM_STATE_FLAGS(drive)->door_locked && ejectflag) | ||
2189 | return 0; | ||
2190 | |||
2191 | cdrom_prepare_request(drive, &req); | ||
2192 | |||
2193 | /* only tell drive to close tray if open, if it can do that */ | ||
2194 | if (ejectflag && !CDROM_CONFIG_FLAGS(drive)->close_tray) | ||
2195 | loej = 0; | ||
2196 | |||
2197 | req.sense = sense; | ||
2198 | req.cmd[0] = GPCMD_START_STOP_UNIT; | ||
2199 | req.cmd[4] = loej | (ejectflag != 0); | ||
2200 | return cdrom_queue_packet_command(drive, &req); | ||
2201 | } | 1403 | } |
2202 | 1404 | ||
2203 | static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, | 1405 | static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, |
@@ -2212,7 +1414,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, | |||
2212 | int stat; | 1414 | int stat; |
2213 | struct request req; | 1415 | struct request req; |
2214 | 1416 | ||
2215 | cdrom_prepare_request(drive, &req); | 1417 | ide_cd_init_rq(drive, &req); |
2216 | 1418 | ||
2217 | req.sense = sense; | 1419 | req.sense = sense; |
2218 | req.cmd[0] = GPCMD_READ_CDVD_CAPACITY; | 1420 | req.cmd[0] = GPCMD_READ_CDVD_CAPACITY; |
@@ -2220,7 +1422,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, | |||
2220 | req.data_len = sizeof(capbuf); | 1422 | req.data_len = sizeof(capbuf); |
2221 | req.cmd_flags |= REQ_QUIET; | 1423 | req.cmd_flags |= REQ_QUIET; |
2222 | 1424 | ||
2223 | stat = cdrom_queue_packet_command(drive, &req); | 1425 | stat = ide_cd_queue_pc(drive, &req); |
2224 | if (stat == 0) { | 1426 | if (stat == 0) { |
2225 | *capacity = 1 + be32_to_cpu(capbuf.lba); | 1427 | *capacity = 1 + be32_to_cpu(capbuf.lba); |
2226 | *sectors_per_frame = | 1428 | *sectors_per_frame = |
@@ -2236,7 +1438,7 @@ static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag, | |||
2236 | { | 1438 | { |
2237 | struct request req; | 1439 | struct request req; |
2238 | 1440 | ||
2239 | cdrom_prepare_request(drive, &req); | 1441 | ide_cd_init_rq(drive, &req); |
2240 | 1442 | ||
2241 | req.sense = sense; | 1443 | req.sense = sense; |
2242 | req.data = buf; | 1444 | req.data = buf; |
@@ -2251,12 +1453,11 @@ static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag, | |||
2251 | if (msf_flag) | 1453 | if (msf_flag) |
2252 | req.cmd[1] = 2; | 1454 | req.cmd[1] = 2; |
2253 | 1455 | ||
2254 | return cdrom_queue_packet_command(drive, &req); | 1456 | return ide_cd_queue_pc(drive, &req); |
2255 | } | 1457 | } |
2256 | 1458 | ||
2257 | |||
2258 | /* Try to read the entire TOC for the disk into our internal buffer. */ | 1459 | /* Try to read the entire TOC for the disk into our internal buffer. */ |
2259 | static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense) | 1460 | int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) |
2260 | { | 1461 | { |
2261 | int stat, ntracks, i; | 1462 | int stat, ntracks, i; |
2262 | struct cdrom_info *info = drive->driver_data; | 1463 | struct cdrom_info *info = drive->driver_data; |
@@ -2283,7 +1484,7 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
2283 | If it is, just return. */ | 1484 | If it is, just return. */ |
2284 | (void) cdrom_check_status(drive, sense); | 1485 | (void) cdrom_check_status(drive, sense); |
2285 | 1486 | ||
2286 | if (CDROM_STATE_FLAGS(drive)->toc_valid) | 1487 | if (info->cd_flags & IDE_CD_FLAG_TOC_VALID) |
2287 | return 0; | 1488 | return 0; |
2288 | 1489 | ||
2289 | /* Try to get the total cdrom capacity and sector size. */ | 1490 | /* Try to get the total cdrom capacity and sector size. */ |
@@ -2305,12 +1506,10 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
2305 | if (stat) | 1506 | if (stat) |
2306 | return stat; | 1507 | return stat; |
2307 | 1508 | ||
2308 | #if ! STANDARD_ATAPI | 1509 | if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) { |
2309 | if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) { | 1510 | toc->hdr.first_track = BCD2BIN(toc->hdr.first_track); |
2310 | toc->hdr.first_track = bcd2bin(toc->hdr.first_track); | 1511 | toc->hdr.last_track = BCD2BIN(toc->hdr.last_track); |
2311 | toc->hdr.last_track = bcd2bin(toc->hdr.last_track); | ||
2312 | } | 1512 | } |
2313 | #endif /* not STANDARD_ATAPI */ | ||
2314 | 1513 | ||
2315 | ntracks = toc->hdr.last_track - toc->hdr.first_track + 1; | 1514 | ntracks = toc->hdr.last_track - toc->hdr.first_track + 1; |
2316 | if (ntracks <= 0) | 1515 | if (ntracks <= 0) |
@@ -2342,16 +1541,13 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
2342 | (ntracks + 1) * | 1541 | (ntracks + 1) * |
2343 | sizeof(struct atapi_toc_entry), | 1542 | sizeof(struct atapi_toc_entry), |
2344 | sense); | 1543 | sense); |
2345 | if (stat) { | 1544 | if (stat) |
2346 | return stat; | 1545 | return stat; |
2347 | } | 1546 | |
2348 | #if ! STANDARD_ATAPI | 1547 | if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) { |
2349 | if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) { | 1548 | toc->hdr.first_track = (u8)BIN2BCD(CDROM_LEADOUT); |
2350 | toc->hdr.first_track = bin2bcd(CDROM_LEADOUT); | 1549 | toc->hdr.last_track = (u8)BIN2BCD(CDROM_LEADOUT); |
2351 | toc->hdr.last_track = bin2bcd(CDROM_LEADOUT); | 1550 | } else { |
2352 | } else | ||
2353 | #endif /* not STANDARD_ATAPI */ | ||
2354 | { | ||
2355 | toc->hdr.first_track = CDROM_LEADOUT; | 1551 | toc->hdr.first_track = CDROM_LEADOUT; |
2356 | toc->hdr.last_track = CDROM_LEADOUT; | 1552 | toc->hdr.last_track = CDROM_LEADOUT; |
2357 | } | 1553 | } |
@@ -2362,21 +1558,17 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
2362 | 1558 | ||
2363 | toc->hdr.toc_length = ntohs (toc->hdr.toc_length); | 1559 | toc->hdr.toc_length = ntohs (toc->hdr.toc_length); |
2364 | 1560 | ||
2365 | #if ! STANDARD_ATAPI | 1561 | if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) { |
2366 | if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) { | 1562 | toc->hdr.first_track = BCD2BIN(toc->hdr.first_track); |
2367 | toc->hdr.first_track = bcd2bin(toc->hdr.first_track); | 1563 | toc->hdr.last_track = BCD2BIN(toc->hdr.last_track); |
2368 | toc->hdr.last_track = bcd2bin(toc->hdr.last_track); | ||
2369 | } | 1564 | } |
2370 | #endif /* not STANDARD_ATAPI */ | ||
2371 | 1565 | ||
2372 | for (i=0; i<=ntracks; i++) { | 1566 | for (i = 0; i <= ntracks; i++) { |
2373 | #if ! STANDARD_ATAPI | 1567 | if (info->cd_flags & IDE_CD_FLAG_TOCADDR_AS_BCD) { |
2374 | if (CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd) { | 1568 | if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) |
2375 | if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) | 1569 | toc->ent[i].track = BCD2BIN(toc->ent[i].track); |
2376 | toc->ent[i].track = bcd2bin(toc->ent[i].track); | ||
2377 | msf_from_bcd(&toc->ent[i].addr.msf); | 1570 | msf_from_bcd(&toc->ent[i].addr.msf); |
2378 | } | 1571 | } |
2379 | #endif /* not STANDARD_ATAPI */ | ||
2380 | toc->ent[i].addr.lba = msf_to_lba (toc->ent[i].addr.msf.minute, | 1572 | toc->ent[i].addr.lba = msf_to_lba (toc->ent[i].addr.msf.minute, |
2381 | toc->ent[i].addr.msf.second, | 1573 | toc->ent[i].addr.msf.second, |
2382 | toc->ent[i].addr.msf.frame); | 1574 | toc->ent[i].addr.msf.frame); |
@@ -2396,8 +1588,7 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
2396 | toc->last_session_lba = msf_to_lba(0, 2, 0); /* 0m 2s 0f */ | 1588 | toc->last_session_lba = msf_to_lba(0, 2, 0); /* 0m 2s 0f */ |
2397 | } | 1589 | } |
2398 | 1590 | ||
2399 | #if ! STANDARD_ATAPI | 1591 | if (info->cd_flags & IDE_CD_FLAG_TOCADDR_AS_BCD) { |
2400 | if (CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd) { | ||
2401 | /* Re-read multisession information using MSF format */ | 1592 | /* Re-read multisession information using MSF format */ |
2402 | stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp, | 1593 | stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp, |
2403 | sizeof(ms_tmp), sense); | 1594 | sizeof(ms_tmp), sense); |
@@ -2409,7 +1600,6 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
2409 | ms_tmp.ent.addr.msf.second, | 1600 | ms_tmp.ent.addr.msf.second, |
2410 | ms_tmp.ent.addr.msf.frame); | 1601 | ms_tmp.ent.addr.msf.frame); |
2411 | } | 1602 | } |
2412 | #endif /* not STANDARD_ATAPI */ | ||
2413 | 1603 | ||
2414 | toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track); | 1604 | toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track); |
2415 | 1605 | ||
@@ -2422,278 +1612,22 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
2422 | } | 1612 | } |
2423 | 1613 | ||
2424 | /* Remember that we've read this stuff. */ | 1614 | /* Remember that we've read this stuff. */ |
2425 | CDROM_STATE_FLAGS(drive)->toc_valid = 1; | 1615 | info->cd_flags |= IDE_CD_FLAG_TOC_VALID; |
2426 | 1616 | ||
2427 | return 0; | 1617 | return 0; |
2428 | } | 1618 | } |
2429 | 1619 | ||
2430 | 1620 | int ide_cdrom_get_capabilities(ide_drive_t *drive, u8 *buf) | |
2431 | static int cdrom_read_subchannel(ide_drive_t *drive, int format, char *buf, | ||
2432 | int buflen, struct request_sense *sense) | ||
2433 | { | ||
2434 | struct request req; | ||
2435 | |||
2436 | cdrom_prepare_request(drive, &req); | ||
2437 | |||
2438 | req.sense = sense; | ||
2439 | req.data = buf; | ||
2440 | req.data_len = buflen; | ||
2441 | req.cmd[0] = GPCMD_READ_SUBCHANNEL; | ||
2442 | req.cmd[1] = 2; /* MSF addressing */ | ||
2443 | req.cmd[2] = 0x40; /* request subQ data */ | ||
2444 | req.cmd[3] = format; | ||
2445 | req.cmd[7] = (buflen >> 8); | ||
2446 | req.cmd[8] = (buflen & 0xff); | ||
2447 | return cdrom_queue_packet_command(drive, &req); | ||
2448 | } | ||
2449 | |||
2450 | /* ATAPI cdrom drives are free to select the speed you request or any slower | ||
2451 | rate :-( Requesting too fast a speed will _not_ produce an error. */ | ||
2452 | static int cdrom_select_speed(ide_drive_t *drive, int speed, | ||
2453 | struct request_sense *sense) | ||
2454 | { | ||
2455 | struct request req; | ||
2456 | cdrom_prepare_request(drive, &req); | ||
2457 | |||
2458 | req.sense = sense; | ||
2459 | if (speed == 0) | ||
2460 | speed = 0xffff; /* set to max */ | ||
2461 | else | ||
2462 | speed *= 177; /* Nx to kbytes/s */ | ||
2463 | |||
2464 | req.cmd[0] = GPCMD_SET_SPEED; | ||
2465 | /* Read Drive speed in kbytes/second MSB */ | ||
2466 | req.cmd[2] = (speed >> 8) & 0xff; | ||
2467 | /* Read Drive speed in kbytes/second LSB */ | ||
2468 | req.cmd[3] = speed & 0xff; | ||
2469 | if (CDROM_CONFIG_FLAGS(drive)->cd_r || | ||
2470 | CDROM_CONFIG_FLAGS(drive)->cd_rw || | ||
2471 | CDROM_CONFIG_FLAGS(drive)->dvd_r) { | ||
2472 | /* Write Drive speed in kbytes/second MSB */ | ||
2473 | req.cmd[4] = (speed >> 8) & 0xff; | ||
2474 | /* Write Drive speed in kbytes/second LSB */ | ||
2475 | req.cmd[5] = speed & 0xff; | ||
2476 | } | ||
2477 | |||
2478 | return cdrom_queue_packet_command(drive, &req); | ||
2479 | } | ||
2480 | |||
2481 | static int cdrom_play_audio(ide_drive_t *drive, int lba_start, int lba_end) | ||
2482 | { | ||
2483 | struct request_sense sense; | ||
2484 | struct request req; | ||
2485 | |||
2486 | cdrom_prepare_request(drive, &req); | ||
2487 | |||
2488 | req.sense = &sense; | ||
2489 | req.cmd[0] = GPCMD_PLAY_AUDIO_MSF; | ||
2490 | lba_to_msf(lba_start, &req.cmd[3], &req.cmd[4], &req.cmd[5]); | ||
2491 | lba_to_msf(lba_end-1, &req.cmd[6], &req.cmd[7], &req.cmd[8]); | ||
2492 | |||
2493 | return cdrom_queue_packet_command(drive, &req); | ||
2494 | } | ||
2495 | |||
2496 | static int cdrom_get_toc_entry(ide_drive_t *drive, int track, | ||
2497 | struct atapi_toc_entry **ent) | ||
2498 | { | ||
2499 | struct cdrom_info *info = drive->driver_data; | ||
2500 | struct atapi_toc *toc = info->toc; | ||
2501 | int ntracks; | ||
2502 | |||
2503 | /* | ||
2504 | * don't serve cached data, if the toc isn't valid | ||
2505 | */ | ||
2506 | if (!CDROM_STATE_FLAGS(drive)->toc_valid) | ||
2507 | return -EINVAL; | ||
2508 | |||
2509 | /* Check validity of requested track number. */ | ||
2510 | ntracks = toc->hdr.last_track - toc->hdr.first_track + 1; | ||
2511 | if (toc->hdr.first_track == CDROM_LEADOUT) ntracks = 0; | ||
2512 | if (track == CDROM_LEADOUT) | ||
2513 | *ent = &toc->ent[ntracks]; | ||
2514 | else if (track < toc->hdr.first_track || | ||
2515 | track > toc->hdr.last_track) | ||
2516 | return -EINVAL; | ||
2517 | else | ||
2518 | *ent = &toc->ent[track - toc->hdr.first_track]; | ||
2519 | |||
2520 | return 0; | ||
2521 | } | ||
2522 | |||
2523 | /* the generic packet interface to cdrom.c */ | ||
2524 | static int ide_cdrom_packet(struct cdrom_device_info *cdi, | ||
2525 | struct packet_command *cgc) | ||
2526 | { | ||
2527 | struct request req; | ||
2528 | ide_drive_t *drive = cdi->handle; | ||
2529 | |||
2530 | if (cgc->timeout <= 0) | ||
2531 | cgc->timeout = ATAPI_WAIT_PC; | ||
2532 | |||
2533 | /* here we queue the commands from the uniform CD-ROM | ||
2534 | layer. the packet must be complete, as we do not | ||
2535 | touch it at all. */ | ||
2536 | cdrom_prepare_request(drive, &req); | ||
2537 | memcpy(req.cmd, cgc->cmd, CDROM_PACKET_SIZE); | ||
2538 | if (cgc->sense) | ||
2539 | memset(cgc->sense, 0, sizeof(struct request_sense)); | ||
2540 | req.data = cgc->buffer; | ||
2541 | req.data_len = cgc->buflen; | ||
2542 | req.timeout = cgc->timeout; | ||
2543 | |||
2544 | if (cgc->quiet) | ||
2545 | req.cmd_flags |= REQ_QUIET; | ||
2546 | |||
2547 | req.sense = cgc->sense; | ||
2548 | cgc->stat = cdrom_queue_packet_command(drive, &req); | ||
2549 | if (!cgc->stat) | ||
2550 | cgc->buflen -= req.data_len; | ||
2551 | return cgc->stat; | ||
2552 | } | ||
2553 | |||
2554 | static | ||
2555 | int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi, | ||
2556 | unsigned int cmd, void *arg) | ||
2557 | |||
2558 | { | ||
2559 | ide_drive_t *drive = cdi->handle; | ||
2560 | struct cdrom_info *info = drive->driver_data; | ||
2561 | int stat; | ||
2562 | |||
2563 | switch (cmd) { | ||
2564 | /* | ||
2565 | * emulate PLAY_AUDIO_TI command with PLAY_AUDIO_10, since | ||
2566 | * atapi doesn't support it | ||
2567 | */ | ||
2568 | case CDROMPLAYTRKIND: { | ||
2569 | unsigned long lba_start, lba_end; | ||
2570 | struct cdrom_ti *ti = arg; | ||
2571 | struct atapi_toc_entry *first_toc, *last_toc; | ||
2572 | |||
2573 | stat = cdrom_get_toc_entry(drive, ti->cdti_trk0, &first_toc); | ||
2574 | if (stat) | ||
2575 | return stat; | ||
2576 | |||
2577 | stat = cdrom_get_toc_entry(drive, ti->cdti_trk1, &last_toc); | ||
2578 | if (stat) | ||
2579 | return stat; | ||
2580 | |||
2581 | if (ti->cdti_trk1 != CDROM_LEADOUT) | ||
2582 | ++last_toc; | ||
2583 | lba_start = first_toc->addr.lba; | ||
2584 | lba_end = last_toc->addr.lba; | ||
2585 | |||
2586 | if (lba_end <= lba_start) | ||
2587 | return -EINVAL; | ||
2588 | |||
2589 | return cdrom_play_audio(drive, lba_start, lba_end); | ||
2590 | } | ||
2591 | |||
2592 | case CDROMREADTOCHDR: { | ||
2593 | struct cdrom_tochdr *tochdr = arg; | ||
2594 | struct atapi_toc *toc; | ||
2595 | |||
2596 | /* Make sure our saved TOC is valid. */ | ||
2597 | stat = cdrom_read_toc(drive, NULL); | ||
2598 | if (stat) | ||
2599 | return stat; | ||
2600 | |||
2601 | toc = info->toc; | ||
2602 | tochdr->cdth_trk0 = toc->hdr.first_track; | ||
2603 | tochdr->cdth_trk1 = toc->hdr.last_track; | ||
2604 | |||
2605 | return 0; | ||
2606 | } | ||
2607 | |||
2608 | case CDROMREADTOCENTRY: { | ||
2609 | struct cdrom_tocentry *tocentry = arg; | ||
2610 | struct atapi_toc_entry *toce; | ||
2611 | |||
2612 | stat = cdrom_get_toc_entry(drive, tocentry->cdte_track, &toce); | ||
2613 | if (stat) | ||
2614 | return stat; | ||
2615 | |||
2616 | tocentry->cdte_ctrl = toce->control; | ||
2617 | tocentry->cdte_adr = toce->adr; | ||
2618 | if (tocentry->cdte_format == CDROM_MSF) { | ||
2619 | lba_to_msf (toce->addr.lba, | ||
2620 | &tocentry->cdte_addr.msf.minute, | ||
2621 | &tocentry->cdte_addr.msf.second, | ||
2622 | &tocentry->cdte_addr.msf.frame); | ||
2623 | } else | ||
2624 | tocentry->cdte_addr.lba = toce->addr.lba; | ||
2625 | |||
2626 | return 0; | ||
2627 | } | ||
2628 | |||
2629 | default: | ||
2630 | return -EINVAL; | ||
2631 | } | ||
2632 | } | ||
2633 | |||
2634 | static | ||
2635 | int ide_cdrom_reset (struct cdrom_device_info *cdi) | ||
2636 | { | ||
2637 | ide_drive_t *drive = cdi->handle; | ||
2638 | struct request_sense sense; | ||
2639 | struct request req; | ||
2640 | int ret; | ||
2641 | |||
2642 | cdrom_prepare_request(drive, &req); | ||
2643 | req.cmd_type = REQ_TYPE_SPECIAL; | ||
2644 | req.cmd_flags = REQ_QUIET; | ||
2645 | ret = ide_do_drive_cmd(drive, &req, ide_wait); | ||
2646 | |||
2647 | /* | ||
2648 | * A reset will unlock the door. If it was previously locked, | ||
2649 | * lock it again. | ||
2650 | */ | ||
2651 | if (CDROM_STATE_FLAGS(drive)->door_locked) | ||
2652 | (void) cdrom_lockdoor(drive, 1, &sense); | ||
2653 | |||
2654 | return ret; | ||
2655 | } | ||
2656 | |||
2657 | |||
2658 | static | ||
2659 | int ide_cdrom_tray_move (struct cdrom_device_info *cdi, int position) | ||
2660 | { | ||
2661 | ide_drive_t *drive = cdi->handle; | ||
2662 | struct request_sense sense; | ||
2663 | |||
2664 | if (position) { | ||
2665 | int stat = cdrom_lockdoor(drive, 0, &sense); | ||
2666 | if (stat) | ||
2667 | return stat; | ||
2668 | } | ||
2669 | |||
2670 | return cdrom_eject(drive, !position, &sense); | ||
2671 | } | ||
2672 | |||
2673 | static | ||
2674 | int ide_cdrom_lock_door (struct cdrom_device_info *cdi, int lock) | ||
2675 | { | ||
2676 | ide_drive_t *drive = cdi->handle; | ||
2677 | return cdrom_lockdoor(drive, lock, NULL); | ||
2678 | } | ||
2679 | |||
2680 | static | ||
2681 | int ide_cdrom_get_capabilities(ide_drive_t *drive, struct atapi_capabilities_page *cap) | ||
2682 | { | 1621 | { |
2683 | struct cdrom_info *info = drive->driver_data; | 1622 | struct cdrom_info *info = drive->driver_data; |
2684 | struct cdrom_device_info *cdi = &info->devinfo; | 1623 | struct cdrom_device_info *cdi = &info->devinfo; |
2685 | struct packet_command cgc; | 1624 | struct packet_command cgc; |
2686 | int stat, attempts = 3, size = sizeof(*cap); | 1625 | int stat, attempts = 3, size = ATAPI_CAPABILITIES_PAGE_SIZE; |
2687 | 1626 | ||
2688 | /* | 1627 | if ((info->cd_flags & IDE_CD_FLAG_FULL_CAPS_PAGE) == 0) |
2689 | * ACER50 (and others?) require the full spec length mode sense | 1628 | size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE; |
2690 | * page capabilities size, but older drives break. | ||
2691 | */ | ||
2692 | if (!(!strcmp(drive->id->model, "ATAPI CD ROM DRIVE 50X MAX") || | ||
2693 | !strcmp(drive->id->model, "WPI CDS-32X"))) | ||
2694 | size -= sizeof(cap->pad); | ||
2695 | 1629 | ||
2696 | init_cdrom_command(&cgc, cap, size, CGC_DATA_UNKNOWN); | 1630 | init_cdrom_command(&cgc, buf, size, CGC_DATA_UNKNOWN); |
2697 | do { /* we seem to get stat=0x01,err=0x00 the first time (??) */ | 1631 | do { /* we seem to get stat=0x01,err=0x00 the first time (??) */ |
2698 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0); | 1632 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0); |
2699 | if (!stat) | 1633 | if (!stat) |
@@ -2702,177 +1636,33 @@ int ide_cdrom_get_capabilities(ide_drive_t *drive, struct atapi_capabilities_pag | |||
2702 | return stat; | 1636 | return stat; |
2703 | } | 1637 | } |
2704 | 1638 | ||
2705 | static | 1639 | void ide_cdrom_update_speed(ide_drive_t *drive, u8 *buf) |
2706 | void ide_cdrom_update_speed (ide_drive_t *drive, struct atapi_capabilities_page *cap) | ||
2707 | { | ||
2708 | /* The ACER/AOpen 24X cdrom has the speed fields byte-swapped */ | ||
2709 | if (!drive->id->model[0] && | ||
2710 | !strncmp(drive->id->fw_rev, "241N", 4)) { | ||
2711 | CDROM_STATE_FLAGS(drive)->current_speed = | ||
2712 | (le16_to_cpu(cap->curspeed) + (176/2)) / 176; | ||
2713 | CDROM_CONFIG_FLAGS(drive)->max_speed = | ||
2714 | (le16_to_cpu(cap->maxspeed) + (176/2)) / 176; | ||
2715 | } else { | ||
2716 | CDROM_STATE_FLAGS(drive)->current_speed = | ||
2717 | (be16_to_cpu(cap->curspeed) + (176/2)) / 176; | ||
2718 | CDROM_CONFIG_FLAGS(drive)->max_speed = | ||
2719 | (be16_to_cpu(cap->maxspeed) + (176/2)) / 176; | ||
2720 | } | ||
2721 | } | ||
2722 | |||
2723 | static | ||
2724 | int ide_cdrom_select_speed (struct cdrom_device_info *cdi, int speed) | ||
2725 | { | ||
2726 | ide_drive_t *drive = cdi->handle; | ||
2727 | struct request_sense sense; | ||
2728 | struct atapi_capabilities_page cap; | ||
2729 | int stat; | ||
2730 | |||
2731 | if ((stat = cdrom_select_speed(drive, speed, &sense)) < 0) | ||
2732 | return stat; | ||
2733 | |||
2734 | if (!ide_cdrom_get_capabilities(drive, &cap)) { | ||
2735 | ide_cdrom_update_speed(drive, &cap); | ||
2736 | cdi->speed = CDROM_STATE_FLAGS(drive)->current_speed; | ||
2737 | } | ||
2738 | return 0; | ||
2739 | } | ||
2740 | |||
2741 | /* | ||
2742 | * add logic to try GET_EVENT command first to check for media and tray | ||
2743 | * status. this should be supported by newer cd-r/w and all DVD etc | ||
2744 | * drives | ||
2745 | */ | ||
2746 | static | ||
2747 | int ide_cdrom_drive_status (struct cdrom_device_info *cdi, int slot_nr) | ||
2748 | { | ||
2749 | ide_drive_t *drive = cdi->handle; | ||
2750 | struct media_event_desc med; | ||
2751 | struct request_sense sense; | ||
2752 | int stat; | ||
2753 | |||
2754 | if (slot_nr != CDSL_CURRENT) | ||
2755 | return -EINVAL; | ||
2756 | |||
2757 | stat = cdrom_check_status(drive, &sense); | ||
2758 | if (!stat || sense.sense_key == UNIT_ATTENTION) | ||
2759 | return CDS_DISC_OK; | ||
2760 | |||
2761 | if (!cdrom_get_media_event(cdi, &med)) { | ||
2762 | if (med.media_present) | ||
2763 | return CDS_DISC_OK; | ||
2764 | else if (med.door_open) | ||
2765 | return CDS_TRAY_OPEN; | ||
2766 | else | ||
2767 | return CDS_NO_DISC; | ||
2768 | } | ||
2769 | |||
2770 | if (sense.sense_key == NOT_READY && sense.asc == 0x04 && sense.ascq == 0x04) | ||
2771 | return CDS_DISC_OK; | ||
2772 | |||
2773 | /* | ||
2774 | * If not using Mt Fuji extended media tray reports, | ||
2775 | * just return TRAY_OPEN since ATAPI doesn't provide | ||
2776 | * any other way to detect this... | ||
2777 | */ | ||
2778 | if (sense.sense_key == NOT_READY) { | ||
2779 | if (sense.asc == 0x3a && sense.ascq == 1) | ||
2780 | return CDS_NO_DISC; | ||
2781 | else | ||
2782 | return CDS_TRAY_OPEN; | ||
2783 | } | ||
2784 | return CDS_DRIVE_NOT_READY; | ||
2785 | } | ||
2786 | |||
2787 | static | ||
2788 | int ide_cdrom_get_last_session (struct cdrom_device_info *cdi, | ||
2789 | struct cdrom_multisession *ms_info) | ||
2790 | { | 1640 | { |
2791 | struct atapi_toc *toc; | 1641 | struct cdrom_info *cd = drive->driver_data; |
2792 | ide_drive_t *drive = cdi->handle; | 1642 | u16 curspeed, maxspeed; |
2793 | struct cdrom_info *info = drive->driver_data; | ||
2794 | struct request_sense sense; | ||
2795 | int ret; | ||
2796 | |||
2797 | if (!CDROM_STATE_FLAGS(drive)->toc_valid || info->toc == NULL) | ||
2798 | if ((ret = cdrom_read_toc(drive, &sense))) | ||
2799 | return ret; | ||
2800 | |||
2801 | toc = info->toc; | ||
2802 | ms_info->addr.lba = toc->last_session_lba; | ||
2803 | ms_info->xa_flag = toc->xa_flag; | ||
2804 | |||
2805 | return 0; | ||
2806 | } | ||
2807 | |||
2808 | static | ||
2809 | int ide_cdrom_get_mcn (struct cdrom_device_info *cdi, | ||
2810 | struct cdrom_mcn *mcn_info) | ||
2811 | { | ||
2812 | int stat; | ||
2813 | char mcnbuf[24]; | ||
2814 | ide_drive_t *drive = cdi->handle; | ||
2815 | |||
2816 | /* get MCN */ | ||
2817 | if ((stat = cdrom_read_subchannel(drive, 2, mcnbuf, sizeof (mcnbuf), NULL))) | ||
2818 | return stat; | ||
2819 | |||
2820 | memcpy (mcn_info->medium_catalog_number, mcnbuf+9, | ||
2821 | sizeof (mcn_info->medium_catalog_number)-1); | ||
2822 | mcn_info->medium_catalog_number[sizeof (mcn_info->medium_catalog_number)-1] | ||
2823 | = '\0'; | ||
2824 | |||
2825 | return 0; | ||
2826 | } | ||
2827 | |||
2828 | |||
2829 | 1643 | ||
2830 | /**************************************************************************** | 1644 | curspeed = *(u16 *)&buf[8 + 14]; |
2831 | * Other driver requests (open, close, check media change). | 1645 | maxspeed = *(u16 *)&buf[8 + 8]; |
2832 | */ | ||
2833 | 1646 | ||
2834 | static | 1647 | if (cd->cd_flags & IDE_CD_FLAG_LE_SPEED_FIELDS) { |
2835 | int ide_cdrom_check_media_change_real (struct cdrom_device_info *cdi, | 1648 | curspeed = le16_to_cpu(curspeed); |
2836 | int slot_nr) | 1649 | maxspeed = le16_to_cpu(maxspeed); |
2837 | { | ||
2838 | ide_drive_t *drive = cdi->handle; | ||
2839 | int retval; | ||
2840 | |||
2841 | if (slot_nr == CDSL_CURRENT) { | ||
2842 | (void) cdrom_check_status(drive, NULL); | ||
2843 | retval = CDROM_STATE_FLAGS(drive)->media_changed; | ||
2844 | CDROM_STATE_FLAGS(drive)->media_changed = 0; | ||
2845 | return retval; | ||
2846 | } else { | 1650 | } else { |
2847 | return -EINVAL; | 1651 | curspeed = be16_to_cpu(curspeed); |
1652 | maxspeed = be16_to_cpu(maxspeed); | ||
2848 | } | 1653 | } |
2849 | } | ||
2850 | |||
2851 | 1654 | ||
2852 | static | 1655 | cd->current_speed = (curspeed + (176/2)) / 176; |
2853 | int ide_cdrom_open_real (struct cdrom_device_info *cdi, int purpose) | 1656 | cd->max_speed = (maxspeed + (176/2)) / 176; |
2854 | { | ||
2855 | return 0; | ||
2856 | } | 1657 | } |
2857 | 1658 | ||
2858 | /* | 1659 | #define IDE_CD_CAPABILITIES \ |
2859 | * Close down the device. Invalidate all cached blocks. | 1660 | (CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | \ |
2860 | */ | 1661 | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | \ |
2861 | 1662 | CDC_PLAY_AUDIO | CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R | \ | |
2862 | static | 1663 | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM | CDC_GENERIC_PACKET | \ |
2863 | void ide_cdrom_release_real (struct cdrom_device_info *cdi) | 1664 | CDC_MO_DRIVE | CDC_MRW | CDC_MRW_W | CDC_RAM) |
2864 | { | ||
2865 | ide_drive_t *drive = cdi->handle; | ||
2866 | |||
2867 | if (!cdi->use_count) | ||
2868 | CDROM_STATE_FLAGS(drive)->toc_valid = 0; | ||
2869 | } | ||
2870 | 1665 | ||
2871 | |||
2872 | |||
2873 | /**************************************************************************** | ||
2874 | * Device initialization. | ||
2875 | */ | ||
2876 | static struct cdrom_device_ops ide_cdrom_dops = { | 1666 | static struct cdrom_device_ops ide_cdrom_dops = { |
2877 | .open = ide_cdrom_open_real, | 1667 | .open = ide_cdrom_open_real, |
2878 | .release = ide_cdrom_release_real, | 1668 | .release = ide_cdrom_release_real, |
@@ -2885,14 +1675,7 @@ static struct cdrom_device_ops ide_cdrom_dops = { | |||
2885 | .get_mcn = ide_cdrom_get_mcn, | 1675 | .get_mcn = ide_cdrom_get_mcn, |
2886 | .reset = ide_cdrom_reset, | 1676 | .reset = ide_cdrom_reset, |
2887 | .audio_ioctl = ide_cdrom_audio_ioctl, | 1677 | .audio_ioctl = ide_cdrom_audio_ioctl, |
2888 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | | 1678 | .capability = IDE_CD_CAPABILITIES, |
2889 | CDC_SELECT_SPEED | CDC_SELECT_DISC | | ||
2890 | CDC_MULTI_SESSION | CDC_MCN | | ||
2891 | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | | ||
2892 | CDC_DRIVE_STATUS | CDC_CD_R | | ||
2893 | CDC_CD_RW | CDC_DVD | CDC_DVD_R| CDC_DVD_RAM | | ||
2894 | CDC_GENERIC_PACKET | CDC_MO_DRIVE | CDC_MRW | | ||
2895 | CDC_MRW_W | CDC_RAM, | ||
2896 | .generic_packet = ide_cdrom_packet, | 1679 | .generic_packet = ide_cdrom_packet, |
2897 | }; | 1680 | }; |
2898 | 1681 | ||
@@ -2902,35 +1685,12 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots) | |||
2902 | struct cdrom_device_info *devinfo = &info->devinfo; | 1685 | struct cdrom_device_info *devinfo = &info->devinfo; |
2903 | 1686 | ||
2904 | devinfo->ops = &ide_cdrom_dops; | 1687 | devinfo->ops = &ide_cdrom_dops; |
2905 | devinfo->mask = 0; | 1688 | devinfo->speed = info->current_speed; |
2906 | devinfo->speed = CDROM_STATE_FLAGS(drive)->current_speed; | ||
2907 | devinfo->capacity = nslots; | 1689 | devinfo->capacity = nslots; |
2908 | devinfo->handle = drive; | 1690 | devinfo->handle = drive; |
2909 | strcpy(devinfo->name, drive->name); | 1691 | strcpy(devinfo->name, drive->name); |
2910 | 1692 | ||
2911 | /* set capability mask to match the probe. */ | 1693 | if (info->cd_flags & IDE_CD_FLAG_NO_SPEED_SELECT) |
2912 | if (!CDROM_CONFIG_FLAGS(drive)->cd_r) | ||
2913 | devinfo->mask |= CDC_CD_R; | ||
2914 | if (!CDROM_CONFIG_FLAGS(drive)->cd_rw) | ||
2915 | devinfo->mask |= CDC_CD_RW; | ||
2916 | if (!CDROM_CONFIG_FLAGS(drive)->dvd) | ||
2917 | devinfo->mask |= CDC_DVD; | ||
2918 | if (!CDROM_CONFIG_FLAGS(drive)->dvd_r) | ||
2919 | devinfo->mask |= CDC_DVD_R; | ||
2920 | if (!CDROM_CONFIG_FLAGS(drive)->dvd_ram) | ||
2921 | devinfo->mask |= CDC_DVD_RAM; | ||
2922 | if (!CDROM_CONFIG_FLAGS(drive)->is_changer) | ||
2923 | devinfo->mask |= CDC_SELECT_DISC; | ||
2924 | if (!CDROM_CONFIG_FLAGS(drive)->audio_play) | ||
2925 | devinfo->mask |= CDC_PLAY_AUDIO; | ||
2926 | if (!CDROM_CONFIG_FLAGS(drive)->close_tray) | ||
2927 | devinfo->mask |= CDC_CLOSE_TRAY; | ||
2928 | if (!CDROM_CONFIG_FLAGS(drive)->mo_drive) | ||
2929 | devinfo->mask |= CDC_MO_DRIVE; | ||
2930 | if (!CDROM_CONFIG_FLAGS(drive)->ram) | ||
2931 | devinfo->mask |= CDC_RAM; | ||
2932 | |||
2933 | if (CDROM_CONFIG_FLAGS(drive)->no_speed_select) | ||
2934 | devinfo->mask |= CDC_SELECT_SPEED; | 1694 | devinfo->mask |= CDC_SELECT_SPEED; |
2935 | 1695 | ||
2936 | devinfo->disk = info->disk; | 1696 | devinfo->disk = info->disk; |
@@ -2940,22 +1700,25 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots) | |||
2940 | static | 1700 | static |
2941 | int ide_cdrom_probe_capabilities (ide_drive_t *drive) | 1701 | int ide_cdrom_probe_capabilities (ide_drive_t *drive) |
2942 | { | 1702 | { |
2943 | struct cdrom_info *info = drive->driver_data; | 1703 | struct cdrom_info *cd = drive->driver_data; |
2944 | struct cdrom_device_info *cdi = &info->devinfo; | 1704 | struct cdrom_device_info *cdi = &cd->devinfo; |
2945 | struct atapi_capabilities_page cap; | 1705 | u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; |
1706 | mechtype_t mechtype; | ||
2946 | int nslots = 1; | 1707 | int nslots = 1; |
2947 | 1708 | ||
1709 | cdi->mask = (CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | | ||
1710 | CDC_DVD_RAM | CDC_SELECT_DISC | CDC_PLAY_AUDIO | | ||
1711 | CDC_MO_DRIVE | CDC_RAM); | ||
1712 | |||
2948 | if (drive->media == ide_optical) { | 1713 | if (drive->media == ide_optical) { |
2949 | CDROM_CONFIG_FLAGS(drive)->mo_drive = 1; | 1714 | cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM); |
2950 | CDROM_CONFIG_FLAGS(drive)->ram = 1; | ||
2951 | printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", drive->name); | 1715 | printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", drive->name); |
2952 | return nslots; | 1716 | return nslots; |
2953 | } | 1717 | } |
2954 | 1718 | ||
2955 | if (CDROM_CONFIG_FLAGS(drive)->nec260 || | 1719 | if (cd->cd_flags & IDE_CD_FLAG_PRE_ATAPI12) { |
2956 | !strcmp(drive->id->model,"STINGRAY 8422 IDE 8X CD-ROM 7-27-95")) { | 1720 | cd->cd_flags &= ~IDE_CD_FLAG_NO_EJECT; |
2957 | CDROM_CONFIG_FLAGS(drive)->no_eject = 0; | 1721 | cdi->mask &= ~CDC_PLAY_AUDIO; |
2958 | CDROM_CONFIG_FLAGS(drive)->audio_play = 1; | ||
2959 | return nslots; | 1722 | return nslots; |
2960 | } | 1723 | } |
2961 | 1724 | ||
@@ -2969,83 +1732,66 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) | |||
2969 | cdi->handle = drive; | 1732 | cdi->handle = drive; |
2970 | cdi->ops = &ide_cdrom_dops; | 1733 | cdi->ops = &ide_cdrom_dops; |
2971 | 1734 | ||
2972 | if (ide_cdrom_get_capabilities(drive, &cap)) | 1735 | if (ide_cdrom_get_capabilities(drive, buf)) |
2973 | return 0; | 1736 | return 0; |
2974 | 1737 | ||
2975 | if (cap.lock == 0) | 1738 | if ((buf[8 + 6] & 0x01) == 0) |
2976 | CDROM_CONFIG_FLAGS(drive)->no_doorlock = 1; | 1739 | cd->cd_flags |= IDE_CD_FLAG_NO_DOORLOCK; |
2977 | if (cap.eject) | 1740 | if (buf[8 + 6] & 0x08) |
2978 | CDROM_CONFIG_FLAGS(drive)->no_eject = 0; | 1741 | cd->cd_flags &= ~IDE_CD_FLAG_NO_EJECT; |
2979 | if (cap.cd_r_write) | 1742 | if (buf[8 + 3] & 0x01) |
2980 | CDROM_CONFIG_FLAGS(drive)->cd_r = 1; | 1743 | cdi->mask &= ~CDC_CD_R; |
2981 | if (cap.cd_rw_write) { | 1744 | if (buf[8 + 3] & 0x02) |
2982 | CDROM_CONFIG_FLAGS(drive)->cd_rw = 1; | 1745 | cdi->mask &= ~(CDC_CD_RW | CDC_RAM); |
2983 | CDROM_CONFIG_FLAGS(drive)->ram = 1; | 1746 | if (buf[8 + 2] & 0x38) |
2984 | } | 1747 | cdi->mask &= ~CDC_DVD; |
2985 | if (cap.test_write) | 1748 | if (buf[8 + 3] & 0x20) |
2986 | CDROM_CONFIG_FLAGS(drive)->test_write = 1; | 1749 | cdi->mask &= ~(CDC_DVD_RAM | CDC_RAM); |
2987 | if (cap.dvd_ram_read || cap.dvd_r_read || cap.dvd_rom) | 1750 | if (buf[8 + 3] & 0x10) |
2988 | CDROM_CONFIG_FLAGS(drive)->dvd = 1; | 1751 | cdi->mask &= ~CDC_DVD_R; |
2989 | if (cap.dvd_ram_write) { | 1752 | if ((buf[8 + 4] & 0x01) || (cd->cd_flags & IDE_CD_FLAG_PLAY_AUDIO_OK)) |
2990 | CDROM_CONFIG_FLAGS(drive)->dvd_ram = 1; | 1753 | cdi->mask &= ~CDC_PLAY_AUDIO; |
2991 | CDROM_CONFIG_FLAGS(drive)->ram = 1; | 1754 | |
2992 | } | 1755 | mechtype = buf[8 + 6] >> 5; |
2993 | if (cap.dvd_r_write) | 1756 | if (mechtype == mechtype_caddy || mechtype == mechtype_popup) |
2994 | CDROM_CONFIG_FLAGS(drive)->dvd_r = 1; | 1757 | cdi->mask |= CDC_CLOSE_TRAY; |
2995 | if (cap.audio_play) | ||
2996 | CDROM_CONFIG_FLAGS(drive)->audio_play = 1; | ||
2997 | if (cap.mechtype == mechtype_caddy || cap.mechtype == mechtype_popup) | ||
2998 | CDROM_CONFIG_FLAGS(drive)->close_tray = 0; | ||
2999 | |||
3000 | /* Some drives used by Apple don't advertise audio play | ||
3001 | * but they do support reading TOC & audio datas | ||
3002 | */ | ||
3003 | if (strcmp(drive->id->model, "MATSHITADVD-ROM SR-8187") == 0 || | ||
3004 | strcmp(drive->id->model, "MATSHITADVD-ROM SR-8186") == 0 || | ||
3005 | strcmp(drive->id->model, "MATSHITADVD-ROM SR-8176") == 0 || | ||
3006 | strcmp(drive->id->model, "MATSHITADVD-ROM SR-8174") == 0) | ||
3007 | CDROM_CONFIG_FLAGS(drive)->audio_play = 1; | ||
3008 | 1758 | ||
3009 | #if ! STANDARD_ATAPI | ||
3010 | if (cdi->sanyo_slot > 0) { | 1759 | if (cdi->sanyo_slot > 0) { |
3011 | CDROM_CONFIG_FLAGS(drive)->is_changer = 1; | 1760 | cdi->mask &= ~CDC_SELECT_DISC; |
3012 | nslots = 3; | 1761 | nslots = 3; |
1762 | } else if (mechtype == mechtype_individual_changer || | ||
1763 | mechtype == mechtype_cartridge_changer) { | ||
1764 | nslots = cdrom_number_of_slots(cdi); | ||
1765 | if (nslots > 1) | ||
1766 | cdi->mask &= ~CDC_SELECT_DISC; | ||
3013 | } | 1767 | } |
3014 | 1768 | ||
3015 | else | 1769 | ide_cdrom_update_speed(drive, buf); |
3016 | #endif /* not STANDARD_ATAPI */ | ||
3017 | if (cap.mechtype == mechtype_individual_changer || | ||
3018 | cap.mechtype == mechtype_cartridge_changer) { | ||
3019 | if ((nslots = cdrom_number_of_slots(cdi)) > 1) { | ||
3020 | CDROM_CONFIG_FLAGS(drive)->is_changer = 1; | ||
3021 | CDROM_CONFIG_FLAGS(drive)->supp_disc_present = 1; | ||
3022 | } | ||
3023 | } | ||
3024 | 1770 | ||
3025 | ide_cdrom_update_speed(drive, &cap); | ||
3026 | /* don't print speed if the drive reported 0. | ||
3027 | */ | ||
3028 | printk(KERN_INFO "%s: ATAPI", drive->name); | 1771 | printk(KERN_INFO "%s: ATAPI", drive->name); |
3029 | if (CDROM_CONFIG_FLAGS(drive)->max_speed) | ||
3030 | printk(" %dX", CDROM_CONFIG_FLAGS(drive)->max_speed); | ||
3031 | printk(" %s", CDROM_CONFIG_FLAGS(drive)->dvd ? "DVD-ROM" : "CD-ROM"); | ||
3032 | 1772 | ||
3033 | if (CDROM_CONFIG_FLAGS(drive)->dvd_r|CDROM_CONFIG_FLAGS(drive)->dvd_ram) | 1773 | /* don't print speed if the drive reported 0 */ |
3034 | printk(" DVD%s%s", | 1774 | if (cd->max_speed) |
3035 | (CDROM_CONFIG_FLAGS(drive)->dvd_r)? "-R" : "", | 1775 | printk(KERN_CONT " %dX", cd->max_speed); |
3036 | (CDROM_CONFIG_FLAGS(drive)->dvd_ram)? "-RAM" : ""); | ||
3037 | 1776 | ||
3038 | if (CDROM_CONFIG_FLAGS(drive)->cd_r|CDROM_CONFIG_FLAGS(drive)->cd_rw) | 1777 | printk(KERN_CONT " %s", (cdi->mask & CDC_DVD) ? "CD-ROM" : "DVD-ROM"); |
3039 | printk(" CD%s%s", | ||
3040 | (CDROM_CONFIG_FLAGS(drive)->cd_r)? "-R" : "", | ||
3041 | (CDROM_CONFIG_FLAGS(drive)->cd_rw)? "/RW" : ""); | ||
3042 | 1778 | ||
3043 | if (CDROM_CONFIG_FLAGS(drive)->is_changer) | 1779 | if ((cdi->mask & CDC_DVD_R) == 0 || (cdi->mask & CDC_DVD_RAM) == 0) |
3044 | printk(" changer w/%d slots", nslots); | 1780 | printk(KERN_CONT " DVD%s%s", |
3045 | else | 1781 | (cdi->mask & CDC_DVD_R) ? "" : "-R", |
3046 | printk(" drive"); | 1782 | (cdi->mask & CDC_DVD_RAM) ? "" : "-RAM"); |
3047 | 1783 | ||
3048 | printk(KERN_CONT ", %dkB Cache\n", be16_to_cpu(cap.buffer_size)); | 1784 | if ((cdi->mask & CDC_CD_R) == 0 || (cdi->mask & CDC_CD_RW) == 0) |
1785 | printk(KERN_CONT " CD%s%s", | ||
1786 | (cdi->mask & CDC_CD_R) ? "" : "-R", | ||
1787 | (cdi->mask & CDC_CD_RW) ? "" : "/RW"); | ||
1788 | |||
1789 | if ((cdi->mask & CDC_SELECT_DISC) == 0) | ||
1790 | printk(KERN_CONT " changer w/%d slots", nslots); | ||
1791 | else | ||
1792 | printk(KERN_CONT " drive"); | ||
1793 | |||
1794 | printk(KERN_CONT ", %dkB Cache\n", be16_to_cpu(*(u16 *)&buf[8 + 12])); | ||
3049 | 1795 | ||
3050 | return nslots; | 1796 | return nslots; |
3051 | } | 1797 | } |
@@ -3138,11 +1884,74 @@ static int ide_cdrom_prep_fn(struct request_queue *q, struct request *rq) | |||
3138 | return 0; | 1884 | return 0; |
3139 | } | 1885 | } |
3140 | 1886 | ||
1887 | struct cd_list_entry { | ||
1888 | const char *id_model; | ||
1889 | const char *id_firmware; | ||
1890 | unsigned int cd_flags; | ||
1891 | }; | ||
1892 | |||
1893 | static const struct cd_list_entry ide_cd_quirks_list[] = { | ||
1894 | /* Limit transfer size per interrupt. */ | ||
1895 | { "SAMSUNG CD-ROM SCR-2430", NULL, IDE_CD_FLAG_LIMIT_NFRAMES }, | ||
1896 | { "SAMSUNG CD-ROM SCR-2432", NULL, IDE_CD_FLAG_LIMIT_NFRAMES }, | ||
1897 | /* SCR-3231 doesn't support the SET_CD_SPEED command. */ | ||
1898 | { "SAMSUNG CD-ROM SCR-3231", NULL, IDE_CD_FLAG_NO_SPEED_SELECT }, | ||
1899 | /* Old NEC260 (not R) was released before ATAPI 1.2 spec. */ | ||
1900 | { "NEC CD-ROM DRIVE:260", "1.01", IDE_CD_FLAG_TOCADDR_AS_BCD | | ||
1901 | IDE_CD_FLAG_PRE_ATAPI12, }, | ||
1902 | /* Vertos 300, some versions of this drive like to talk BCD. */ | ||
1903 | { "V003S0DS", NULL, IDE_CD_FLAG_VERTOS_300_SSD, }, | ||
1904 | /* Vertos 600 ESD. */ | ||
1905 | { "V006E0DS", NULL, IDE_CD_FLAG_VERTOS_600_ESD, }, | ||
1906 | /* | ||
1907 | * Sanyo 3 CD changer uses a non-standard command for CD changing | ||
1908 | * (by default standard ATAPI support for CD changers is used). | ||
1909 | */ | ||
1910 | { "CD-ROM CDR-C3 G", NULL, IDE_CD_FLAG_SANYO_3CD }, | ||
1911 | { "CD-ROM CDR-C3G", NULL, IDE_CD_FLAG_SANYO_3CD }, | ||
1912 | { "CD-ROM CDR_C36", NULL, IDE_CD_FLAG_SANYO_3CD }, | ||
1913 | /* Stingray 8X CD-ROM. */ | ||
1914 | { "STINGRAY 8422 IDE 8X CD-ROM 7-27-95", NULL, IDE_CD_FLAG_PRE_ATAPI12}, | ||
1915 | /* | ||
1916 | * ACER 50X CD-ROM and WPI 32X CD-ROM require the full spec length | ||
1917 | * mode sense page capabilities size, but older drives break. | ||
1918 | */ | ||
1919 | { "ATAPI CD ROM DRIVE 50X MAX", NULL, IDE_CD_FLAG_FULL_CAPS_PAGE }, | ||
1920 | { "WPI CDS-32X", NULL, IDE_CD_FLAG_FULL_CAPS_PAGE }, | ||
1921 | /* ACER/AOpen 24X CD-ROM has the speed fields byte-swapped. */ | ||
1922 | { "", "241N", IDE_CD_FLAG_LE_SPEED_FIELDS }, | ||
1923 | /* | ||
1924 | * Some drives used by Apple don't advertise audio play | ||
1925 | * but they do support reading TOC & audio datas. | ||
1926 | */ | ||
1927 | { "MATSHITADVD-ROM SR-8187", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, | ||
1928 | { "MATSHITADVD-ROM SR-8186", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, | ||
1929 | { "MATSHITADVD-ROM SR-8176", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, | ||
1930 | { "MATSHITADVD-ROM SR-8174", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, | ||
1931 | { NULL, NULL, 0 } | ||
1932 | }; | ||
1933 | |||
1934 | static unsigned int ide_cd_flags(struct hd_driveid *id) | ||
1935 | { | ||
1936 | const struct cd_list_entry *cle = ide_cd_quirks_list; | ||
1937 | |||
1938 | while (cle->id_model) { | ||
1939 | if (strcmp(cle->id_model, id->model) == 0 && | ||
1940 | (cle->id_firmware == NULL || | ||
1941 | strstr(id->fw_rev, cle->id_firmware))) | ||
1942 | return cle->cd_flags; | ||
1943 | cle++; | ||
1944 | } | ||
1945 | |||
1946 | return 0; | ||
1947 | } | ||
1948 | |||
3141 | static | 1949 | static |
3142 | int ide_cdrom_setup (ide_drive_t *drive) | 1950 | int ide_cdrom_setup (ide_drive_t *drive) |
3143 | { | 1951 | { |
3144 | struct cdrom_info *info = drive->driver_data; | 1952 | struct cdrom_info *cd = drive->driver_data; |
3145 | struct cdrom_device_info *cdi = &info->devinfo; | 1953 | struct cdrom_device_info *cdi = &cd->devinfo; |
1954 | struct hd_driveid *id = drive->id; | ||
3146 | int nslots; | 1955 | int nslots; |
3147 | 1956 | ||
3148 | blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn); | 1957 | blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn); |
@@ -3153,101 +1962,21 @@ int ide_cdrom_setup (ide_drive_t *drive) | |||
3153 | 1962 | ||
3154 | drive->special.all = 0; | 1963 | drive->special.all = 0; |
3155 | 1964 | ||
3156 | CDROM_STATE_FLAGS(drive)->media_changed = 1; | 1965 | cd->cd_flags = IDE_CD_FLAG_MEDIA_CHANGED | IDE_CD_FLAG_NO_EJECT | |
3157 | CDROM_STATE_FLAGS(drive)->toc_valid = 0; | 1966 | ide_cd_flags(id); |
3158 | CDROM_STATE_FLAGS(drive)->door_locked = 0; | ||
3159 | 1967 | ||
3160 | #if NO_DOOR_LOCKING | 1968 | if ((id->config & 0x0060) == 0x20) |
3161 | CDROM_CONFIG_FLAGS(drive)->no_doorlock = 1; | 1969 | cd->cd_flags |= IDE_CD_FLAG_DRQ_INTERRUPT; |
3162 | #else | ||
3163 | CDROM_CONFIG_FLAGS(drive)->no_doorlock = 0; | ||
3164 | #endif | ||
3165 | 1970 | ||
3166 | CDROM_CONFIG_FLAGS(drive)->drq_interrupt = ((drive->id->config & 0x0060) == 0x20); | 1971 | if ((cd->cd_flags & IDE_CD_FLAG_VERTOS_300_SSD) && |
3167 | CDROM_CONFIG_FLAGS(drive)->is_changer = 0; | 1972 | id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') |
3168 | CDROM_CONFIG_FLAGS(drive)->cd_r = 0; | 1973 | cd->cd_flags |= (IDE_CD_FLAG_TOCTRACKS_AS_BCD | |
3169 | CDROM_CONFIG_FLAGS(drive)->cd_rw = 0; | 1974 | IDE_CD_FLAG_TOCADDR_AS_BCD); |
3170 | CDROM_CONFIG_FLAGS(drive)->test_write = 0; | 1975 | else if ((cd->cd_flags & IDE_CD_FLAG_VERTOS_600_ESD) && |
3171 | CDROM_CONFIG_FLAGS(drive)->dvd = 0; | 1976 | id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') |
3172 | CDROM_CONFIG_FLAGS(drive)->dvd_r = 0; | 1977 | cd->cd_flags |= IDE_CD_FLAG_TOCTRACKS_AS_BCD; |
3173 | CDROM_CONFIG_FLAGS(drive)->dvd_ram = 0; | 1978 | else if (cd->cd_flags & IDE_CD_FLAG_SANYO_3CD) |
3174 | CDROM_CONFIG_FLAGS(drive)->no_eject = 1; | 1979 | cdi->sanyo_slot = 3; /* 3 => use CD in slot 0 */ |
3175 | CDROM_CONFIG_FLAGS(drive)->supp_disc_present = 0; | ||
3176 | CDROM_CONFIG_FLAGS(drive)->audio_play = 0; | ||
3177 | CDROM_CONFIG_FLAGS(drive)->close_tray = 1; | ||
3178 | |||
3179 | /* limit transfer size per interrupt. */ | ||
3180 | CDROM_CONFIG_FLAGS(drive)->limit_nframes = 0; | ||
3181 | /* a testament to the nice quality of Samsung drives... */ | ||
3182 | if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-2430")) | ||
3183 | CDROM_CONFIG_FLAGS(drive)->limit_nframes = 1; | ||
3184 | else if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-2432")) | ||
3185 | CDROM_CONFIG_FLAGS(drive)->limit_nframes = 1; | ||
3186 | /* the 3231 model does not support the SET_CD_SPEED command */ | ||
3187 | else if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-3231")) | ||
3188 | CDROM_CONFIG_FLAGS(drive)->no_speed_select = 1; | ||
3189 | |||
3190 | #if ! STANDARD_ATAPI | ||
3191 | /* by default Sanyo 3 CD changer support is turned off and | ||
3192 | ATAPI Rev 2.2+ standard support for CD changers is used */ | ||
3193 | cdi->sanyo_slot = 0; | ||
3194 | |||
3195 | CDROM_CONFIG_FLAGS(drive)->nec260 = 0; | ||
3196 | CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd = 0; | ||
3197 | CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd = 0; | ||
3198 | CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 0; | ||
3199 | CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 0; | ||
3200 | |||
3201 | if (strcmp (drive->id->model, "V003S0DS") == 0 && | ||
3202 | drive->id->fw_rev[4] == '1' && | ||
3203 | drive->id->fw_rev[6] <= '2') { | ||
3204 | /* Vertos 300. | ||
3205 | Some versions of this drive like to talk BCD. */ | ||
3206 | CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd = 1; | ||
3207 | CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd = 1; | ||
3208 | CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 1; | ||
3209 | CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 1; | ||
3210 | } | ||
3211 | |||
3212 | else if (strcmp (drive->id->model, "V006E0DS") == 0 && | ||
3213 | drive->id->fw_rev[4] == '1' && | ||
3214 | drive->id->fw_rev[6] <= '2') { | ||
3215 | /* Vertos 600 ESD. */ | ||
3216 | CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd = 1; | ||
3217 | } | ||
3218 | else if (strcmp(drive->id->model, "NEC CD-ROM DRIVE:260") == 0 && | ||
3219 | strncmp(drive->id->fw_rev, "1.01", 4) == 0) { /* FIXME */ | ||
3220 | /* Old NEC260 (not R). | ||
3221 | This drive was released before the 1.2 version | ||
3222 | of the spec. */ | ||
3223 | CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd = 1; | ||
3224 | CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 1; | ||
3225 | CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 1; | ||
3226 | CDROM_CONFIG_FLAGS(drive)->nec260 = 1; | ||
3227 | } | ||
3228 | else if (strcmp(drive->id->model, "WEARNES CDD-120") == 0 && | ||
3229 | strncmp(drive->id->fw_rev, "A1.1", 4) == 0) { /* FIXME */ | ||
3230 | /* Wearnes */ | ||
3231 | CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 1; | ||
3232 | CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 1; | ||
3233 | } | ||
3234 | /* Sanyo 3 CD changer uses a non-standard command | ||
3235 | for CD changing */ | ||
3236 | else if ((strcmp(drive->id->model, "CD-ROM CDR-C3 G") == 0) || | ||
3237 | (strcmp(drive->id->model, "CD-ROM CDR-C3G") == 0) || | ||
3238 | (strcmp(drive->id->model, "CD-ROM CDR_C36") == 0)) { | ||
3239 | /* uses CD in slot 0 when value is set to 3 */ | ||
3240 | cdi->sanyo_slot = 3; | ||
3241 | } | ||
3242 | #endif /* not STANDARD_ATAPI */ | ||
3243 | |||
3244 | info->toc = NULL; | ||
3245 | info->buffer = NULL; | ||
3246 | info->sector_buffered = 0; | ||
3247 | info->nsectors_buffered = 0; | ||
3248 | info->changer_info = NULL; | ||
3249 | info->last_block = 0; | ||
3250 | info->start_seek = 0; | ||
3251 | 1980 | ||
3252 | nslots = ide_cdrom_probe_capabilities (drive); | 1981 | nslots = ide_cdrom_probe_capabilities (drive); |
3253 | 1982 | ||
@@ -3262,7 +1991,7 @@ int ide_cdrom_setup (ide_drive_t *drive) | |||
3262 | 1991 | ||
3263 | if (ide_cdrom_register(drive, nslots)) { | 1992 | if (ide_cdrom_register(drive, nslots)) { |
3264 | printk (KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name); | 1993 | printk (KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name); |
3265 | info->devinfo.handle = NULL; | 1994 | cd->devinfo.handle = NULL; |
3266 | return 1; | 1995 | return 1; |
3267 | } | 1996 | } |
3268 | ide_cdrom_add_settings(drive); | 1997 | ide_cdrom_add_settings(drive); |
@@ -3302,7 +2031,6 @@ static void ide_cd_release(struct kref *kref) | |||
3302 | 2031 | ||
3303 | kfree(info->buffer); | 2032 | kfree(info->buffer); |
3304 | kfree(info->toc); | 2033 | kfree(info->toc); |
3305 | kfree(info->changer_info); | ||
3306 | if (devinfo->handle == drive && unregister_cdrom(devinfo)) | 2034 | if (devinfo->handle == drive && unregister_cdrom(devinfo)) |
3307 | printk(KERN_ERR "%s: %s failed to unregister device from the cdrom " | 2035 | printk(KERN_ERR "%s: %s failed to unregister device from the cdrom " |
3308 | "driver.\n", __FUNCTION__, drive->name); | 2036 | "driver.\n", __FUNCTION__, drive->name); |
@@ -3458,7 +2186,9 @@ static int idecd_revalidate_disk(struct gendisk *disk) | |||
3458 | { | 2186 | { |
3459 | struct cdrom_info *info = ide_cd_g(disk); | 2187 | struct cdrom_info *info = ide_cd_g(disk); |
3460 | struct request_sense sense; | 2188 | struct request_sense sense; |
3461 | cdrom_read_toc(info->drive, &sense); | 2189 | |
2190 | ide_cd_read_toc(info->drive, &sense); | ||
2191 | |||
3462 | return 0; | 2192 | return 0; |
3463 | } | 2193 | } |
3464 | 2194 | ||
@@ -3533,7 +2263,7 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
3533 | goto failed; | 2263 | goto failed; |
3534 | } | 2264 | } |
3535 | 2265 | ||
3536 | cdrom_read_toc(drive, &sense); | 2266 | ide_cd_read_toc(drive, &sense); |
3537 | g->fops = &idecd_ops; | 2267 | g->fops = &idecd_ops; |
3538 | g->flags |= GENHD_FL_REMOVABLE; | 2268 | g->flags |= GENHD_FL_REMOVABLE; |
3539 | add_disk(g); | 2269 | add_disk(g); |
@@ -3556,6 +2286,7 @@ static int __init ide_cdrom_init(void) | |||
3556 | } | 2286 | } |
3557 | 2287 | ||
3558 | MODULE_ALIAS("ide:*m-cdrom*"); | 2288 | MODULE_ALIAS("ide:*m-cdrom*"); |
2289 | MODULE_ALIAS("ide-cd"); | ||
3559 | module_init(ide_cdrom_init); | 2290 | module_init(ide_cdrom_init); |
3560 | module_exit(ide_cdrom_exit); | 2291 | module_exit(ide_cdrom_exit); |
3561 | MODULE_LICENSE("GPL"); | 2292 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h index 1b302fe2724d..22e3751a681e 100644 --- a/drivers/ide/ide-cd.h +++ b/drivers/ide/ide-cd.h | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/ide_cd.h | ||
3 | * | ||
4 | * Copyright (C) 1996-98 Erik Andersen | 2 | * Copyright (C) 1996-98 Erik Andersen |
5 | * Copyright (C) 1998-2000 Jens Axboe | 3 | * Copyright (C) 1998-2000 Jens Axboe |
6 | */ | 4 | */ |
@@ -10,31 +8,6 @@ | |||
10 | #include <linux/cdrom.h> | 8 | #include <linux/cdrom.h> |
11 | #include <asm/byteorder.h> | 9 | #include <asm/byteorder.h> |
12 | 10 | ||
13 | /* Turn this on to have the driver print out the meanings of the | ||
14 | ATAPI error codes. This will use up additional kernel-space | ||
15 | memory, though. */ | ||
16 | |||
17 | #ifndef VERBOSE_IDE_CD_ERRORS | ||
18 | #define VERBOSE_IDE_CD_ERRORS 1 | ||
19 | #endif | ||
20 | |||
21 | |||
22 | /* Turning this on will remove code to work around various nonstandard | ||
23 | ATAPI implementations. If you know your drive follows the standard, | ||
24 | this will give you a slightly smaller kernel. */ | ||
25 | |||
26 | #ifndef STANDARD_ATAPI | ||
27 | #define STANDARD_ATAPI 0 | ||
28 | #endif | ||
29 | |||
30 | |||
31 | /* Turning this on will disable the door-locking functionality. | ||
32 | This is apparently needed for supermount. */ | ||
33 | |||
34 | #ifndef NO_DOOR_LOCKING | ||
35 | #define NO_DOOR_LOCKING 0 | ||
36 | #endif | ||
37 | |||
38 | /* | 11 | /* |
39 | * typical timeout for packet command | 12 | * typical timeout for packet command |
40 | */ | 13 | */ |
@@ -49,68 +22,47 @@ | |||
49 | #endif | 22 | #endif |
50 | #define SECTORS_PER_FRAME (CD_FRAMESIZE >> SECTOR_BITS) | 23 | #define SECTORS_PER_FRAME (CD_FRAMESIZE >> SECTOR_BITS) |
51 | #define SECTOR_BUFFER_SIZE (CD_FRAMESIZE * 32) | 24 | #define SECTOR_BUFFER_SIZE (CD_FRAMESIZE * 32) |
52 | #define SECTORS_BUFFER (SECTOR_BUFFER_SIZE >> SECTOR_BITS) | ||
53 | #define SECTORS_MAX (131072 >> SECTOR_BITS) | ||
54 | |||
55 | #define BLOCKS_PER_FRAME (CD_FRAMESIZE / BLOCK_SIZE) | ||
56 | |||
57 | /* special command codes for strategy routine. */ | ||
58 | #define PACKET_COMMAND 4315 | ||
59 | #define REQUEST_SENSE_COMMAND 4316 | ||
60 | #define RESET_DRIVE_COMMAND 4317 | ||
61 | |||
62 | |||
63 | /* Configuration flags. These describe the capabilities of the drive. | ||
64 | They generally do not change after initialization, unless we learn | ||
65 | more about the drive from stuff failing. */ | ||
66 | struct ide_cd_config_flags { | ||
67 | __u8 drq_interrupt : 1; /* Device sends an interrupt when ready | ||
68 | for a packet command. */ | ||
69 | __u8 no_doorlock : 1; /* Drive cannot lock the door. */ | ||
70 | __u8 no_eject : 1; /* Drive cannot eject the disc. */ | ||
71 | __u8 nec260 : 1; /* Drive is a pre-1.2 NEC 260 drive. */ | ||
72 | __u8 playmsf_as_bcd : 1; /* PLAYMSF command takes BCD args. */ | ||
73 | __u8 tocaddr_as_bcd : 1; /* TOC addresses are in BCD. */ | ||
74 | __u8 toctracks_as_bcd : 1; /* TOC track numbers are in BCD. */ | ||
75 | __u8 subchan_as_bcd : 1; /* Subchannel info is in BCD. */ | ||
76 | __u8 is_changer : 1; /* Drive is a changer. */ | ||
77 | __u8 cd_r : 1; /* Drive can write to CD-R media . */ | ||
78 | __u8 cd_rw : 1; /* Drive can write to CD-R/W media . */ | ||
79 | __u8 dvd : 1; /* Drive is a DVD-ROM */ | ||
80 | __u8 dvd_r : 1; /* Drive can write DVD-R */ | ||
81 | __u8 dvd_ram : 1; /* Drive can write DVD-RAM */ | ||
82 | __u8 ram : 1; /* generic WRITE (dvd-ram/mrw) */ | ||
83 | __u8 test_write : 1; /* Drive can fake writes */ | ||
84 | __u8 supp_disc_present : 1; /* Changer can report exact contents | ||
85 | of slots. */ | ||
86 | __u8 limit_nframes : 1; /* Drive does not provide data in | ||
87 | multiples of SECTOR_SIZE when more | ||
88 | than one interrupt is needed. */ | ||
89 | __u8 seeking : 1; /* Seeking in progress */ | ||
90 | __u8 audio_play : 1; /* can do audio related commands */ | ||
91 | __u8 close_tray : 1; /* can close the tray */ | ||
92 | __u8 writing : 1; /* pseudo write in progress */ | ||
93 | __u8 mo_drive : 1; /* drive is an MO device */ | ||
94 | __u8 no_speed_select : 1; /* SET_CD_SPEED command is unsupported. */ | ||
95 | __u8 reserved : 1; | ||
96 | byte max_speed; /* Max speed of the drive */ | ||
97 | }; | ||
98 | #define CDROM_CONFIG_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->config_flags)) | ||
99 | 25 | ||
100 | 26 | /* Capabilities Page size including 8 bytes of Mode Page Header */ | |
101 | /* State flags. These give information about the current state of the | 27 | #define ATAPI_CAPABILITIES_PAGE_SIZE (8 + 20) |
102 | drive, and will change during normal operation. */ | 28 | #define ATAPI_CAPABILITIES_PAGE_PAD_SIZE 4 |
103 | struct ide_cd_state_flags { | 29 | |
104 | __u8 media_changed : 1; /* Driver has noticed a media change. */ | 30 | enum { |
105 | __u8 toc_valid : 1; /* Saved TOC information is current. */ | 31 | /* Device sends an interrupt when ready for a packet command. */ |
106 | __u8 door_locked : 1; /* We think that the drive door is locked. */ | 32 | IDE_CD_FLAG_DRQ_INTERRUPT = (1 << 0), |
107 | __u8 writing : 1; /* the drive is currently writing */ | 33 | /* Drive cannot lock the door. */ |
108 | __u8 reserved : 4; | 34 | IDE_CD_FLAG_NO_DOORLOCK = (1 << 1), |
109 | byte current_speed; /* Current speed of the drive */ | 35 | /* Drive cannot eject the disc. */ |
36 | IDE_CD_FLAG_NO_EJECT = (1 << 2), | ||
37 | /* Drive is a pre ATAPI 1.2 drive. */ | ||
38 | IDE_CD_FLAG_PRE_ATAPI12 = (1 << 3), | ||
39 | /* TOC addresses are in BCD. */ | ||
40 | IDE_CD_FLAG_TOCADDR_AS_BCD = (1 << 4), | ||
41 | /* TOC track numbers are in BCD. */ | ||
42 | IDE_CD_FLAG_TOCTRACKS_AS_BCD = (1 << 5), | ||
43 | /* | ||
44 | * Drive does not provide data in multiples of SECTOR_SIZE | ||
45 | * when more than one interrupt is needed. | ||
46 | */ | ||
47 | IDE_CD_FLAG_LIMIT_NFRAMES = (1 << 6), | ||
48 | /* Seeking in progress. */ | ||
49 | IDE_CD_FLAG_SEEKING = (1 << 7), | ||
50 | /* Driver has noticed a media change. */ | ||
51 | IDE_CD_FLAG_MEDIA_CHANGED = (1 << 8), | ||
52 | /* Saved TOC information is current. */ | ||
53 | IDE_CD_FLAG_TOC_VALID = (1 << 9), | ||
54 | /* We think that the drive door is locked. */ | ||
55 | IDE_CD_FLAG_DOOR_LOCKED = (1 << 10), | ||
56 | /* SET_CD_SPEED command is unsupported. */ | ||
57 | IDE_CD_FLAG_NO_SPEED_SELECT = (1 << 11), | ||
58 | IDE_CD_FLAG_VERTOS_300_SSD = (1 << 12), | ||
59 | IDE_CD_FLAG_VERTOS_600_ESD = (1 << 13), | ||
60 | IDE_CD_FLAG_SANYO_3CD = (1 << 14), | ||
61 | IDE_CD_FLAG_FULL_CAPS_PAGE = (1 << 15), | ||
62 | IDE_CD_FLAG_PLAY_AUDIO_OK = (1 << 16), | ||
63 | IDE_CD_FLAG_LE_SPEED_FIELDS = (1 << 17), | ||
110 | }; | 64 | }; |
111 | 65 | ||
112 | #define CDROM_STATE_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->state_flags)) | ||
113 | |||
114 | /* Structure of a MSF cdrom address. */ | 66 | /* Structure of a MSF cdrom address. */ |
115 | struct atapi_msf { | 67 | struct atapi_msf { |
116 | byte reserved; | 68 | byte reserved; |
@@ -155,310 +107,6 @@ struct atapi_toc { | |||
155 | /* One extra for the leadout. */ | 107 | /* One extra for the leadout. */ |
156 | }; | 108 | }; |
157 | 109 | ||
158 | |||
159 | /* This structure is annoyingly close to, but not identical with, | ||
160 | the cdrom_subchnl structure from cdrom.h. */ | ||
161 | struct atapi_cdrom_subchnl { | ||
162 | u_char acdsc_reserved; | ||
163 | u_char acdsc_audiostatus; | ||
164 | u_short acdsc_length; | ||
165 | u_char acdsc_format; | ||
166 | |||
167 | #if defined(__BIG_ENDIAN_BITFIELD) | ||
168 | u_char acdsc_ctrl: 4; | ||
169 | u_char acdsc_adr: 4; | ||
170 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | ||
171 | u_char acdsc_adr: 4; | ||
172 | u_char acdsc_ctrl: 4; | ||
173 | #else | ||
174 | #error "Please fix <asm/byteorder.h>" | ||
175 | #endif | ||
176 | u_char acdsc_trk; | ||
177 | u_char acdsc_ind; | ||
178 | union { | ||
179 | struct atapi_msf msf; | ||
180 | int lba; | ||
181 | } acdsc_absaddr; | ||
182 | union { | ||
183 | struct atapi_msf msf; | ||
184 | int lba; | ||
185 | } acdsc_reladdr; | ||
186 | }; | ||
187 | |||
188 | |||
189 | |||
190 | /* This should probably go into cdrom.h along with the other | ||
191 | * generic stuff now in the Mt. Fuji spec. | ||
192 | */ | ||
193 | struct atapi_capabilities_page { | ||
194 | struct mode_page_header header; | ||
195 | #if defined(__BIG_ENDIAN_BITFIELD) | ||
196 | __u8 parameters_saveable : 1; | ||
197 | __u8 reserved1 : 1; | ||
198 | __u8 page_code : 6; | ||
199 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | ||
200 | __u8 page_code : 6; | ||
201 | __u8 reserved1 : 1; | ||
202 | __u8 parameters_saveable : 1; | ||
203 | #else | ||
204 | #error "Please fix <asm/byteorder.h>" | ||
205 | #endif | ||
206 | |||
207 | byte page_length; | ||
208 | |||
209 | #if defined(__BIG_ENDIAN_BITFIELD) | ||
210 | __u8 reserved2 : 2; | ||
211 | /* Drive supports reading of DVD-RAM discs */ | ||
212 | __u8 dvd_ram_read : 1; | ||
213 | /* Drive supports reading of DVD-R discs */ | ||
214 | __u8 dvd_r_read : 1; | ||
215 | /* Drive supports reading of DVD-ROM discs */ | ||
216 | __u8 dvd_rom : 1; | ||
217 | /* Drive supports reading CD-R discs with addressing method 2 */ | ||
218 | __u8 method2 : 1; /* reserved in 1.2 */ | ||
219 | /* Drive can read from CD-R/W (CD-E) discs (orange book, part III) */ | ||
220 | __u8 cd_rw_read : 1; /* reserved in 1.2 */ | ||
221 | /* Drive supports read from CD-R discs (orange book, part II) */ | ||
222 | __u8 cd_r_read : 1; /* reserved in 1.2 */ | ||
223 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | ||
224 | /* Drive supports read from CD-R discs (orange book, part II) */ | ||
225 | __u8 cd_r_read : 1; /* reserved in 1.2 */ | ||
226 | /* Drive can read from CD-R/W (CD-E) discs (orange book, part III) */ | ||
227 | __u8 cd_rw_read : 1; /* reserved in 1.2 */ | ||
228 | /* Drive supports reading CD-R discs with addressing method 2 */ | ||
229 | __u8 method2 : 1; | ||
230 | /* Drive supports reading of DVD-ROM discs */ | ||
231 | __u8 dvd_rom : 1; | ||
232 | /* Drive supports reading of DVD-R discs */ | ||
233 | __u8 dvd_r_read : 1; | ||
234 | /* Drive supports reading of DVD-RAM discs */ | ||
235 | __u8 dvd_ram_read : 1; | ||
236 | __u8 reserved2 : 2; | ||
237 | #else | ||
238 | #error "Please fix <asm/byteorder.h>" | ||
239 | #endif | ||
240 | |||
241 | #if defined(__BIG_ENDIAN_BITFIELD) | ||
242 | __u8 reserved3 : 2; | ||
243 | /* Drive can write DVD-RAM discs */ | ||
244 | __u8 dvd_ram_write : 1; | ||
245 | /* Drive can write DVD-R discs */ | ||
246 | __u8 dvd_r_write : 1; | ||
247 | __u8 reserved3a : 1; | ||
248 | /* Drive can fake writes */ | ||
249 | __u8 test_write : 1; | ||
250 | /* Drive can write to CD-R/W (CD-E) discs (orange book, part III) */ | ||
251 | __u8 cd_rw_write : 1; /* reserved in 1.2 */ | ||
252 | /* Drive supports write to CD-R discs (orange book, part II) */ | ||
253 | __u8 cd_r_write : 1; /* reserved in 1.2 */ | ||
254 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | ||
255 | /* Drive can write to CD-R discs (orange book, part II) */ | ||
256 | __u8 cd_r_write : 1; /* reserved in 1.2 */ | ||
257 | /* Drive can write to CD-R/W (CD-E) discs (orange book, part III) */ | ||
258 | __u8 cd_rw_write : 1; /* reserved in 1.2 */ | ||
259 | /* Drive can fake writes */ | ||
260 | __u8 test_write : 1; | ||
261 | __u8 reserved3a : 1; | ||
262 | /* Drive can write DVD-R discs */ | ||
263 | __u8 dvd_r_write : 1; | ||
264 | /* Drive can write DVD-RAM discs */ | ||
265 | __u8 dvd_ram_write : 1; | ||
266 | __u8 reserved3 : 2; | ||
267 | #else | ||
268 | #error "Please fix <asm/byteorder.h>" | ||
269 | #endif | ||
270 | |||
271 | #if defined(__BIG_ENDIAN_BITFIELD) | ||
272 | __u8 reserved4 : 1; | ||
273 | /* Drive can read multisession discs. */ | ||
274 | __u8 multisession : 1; | ||
275 | /* Drive can read mode 2, form 2 data. */ | ||
276 | __u8 mode2_form2 : 1; | ||
277 | /* Drive can read mode 2, form 1 (XA) data. */ | ||
278 | __u8 mode2_form1 : 1; | ||
279 | /* Drive supports digital output on port 2. */ | ||
280 | __u8 digport2 : 1; | ||
281 | /* Drive supports digital output on port 1. */ | ||
282 | __u8 digport1 : 1; | ||
283 | /* Drive can deliver a composite audio/video data stream. */ | ||
284 | __u8 composite : 1; | ||
285 | /* Drive supports audio play operations. */ | ||
286 | __u8 audio_play : 1; | ||
287 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | ||
288 | /* Drive supports audio play operations. */ | ||
289 | __u8 audio_play : 1; | ||
290 | /* Drive can deliver a composite audio/video data stream. */ | ||
291 | __u8 composite : 1; | ||
292 | /* Drive supports digital output on port 1. */ | ||
293 | __u8 digport1 : 1; | ||
294 | /* Drive supports digital output on port 2. */ | ||
295 | __u8 digport2 : 1; | ||
296 | /* Drive can read mode 2, form 1 (XA) data. */ | ||
297 | __u8 mode2_form1 : 1; | ||
298 | /* Drive can read mode 2, form 2 data. */ | ||
299 | __u8 mode2_form2 : 1; | ||
300 | /* Drive can read multisession discs. */ | ||
301 | __u8 multisession : 1; | ||
302 | __u8 reserved4 : 1; | ||
303 | #else | ||
304 | #error "Please fix <asm/byteorder.h>" | ||
305 | #endif | ||
306 | |||
307 | #if defined(__BIG_ENDIAN_BITFIELD) | ||
308 | __u8 reserved5 : 1; | ||
309 | /* Drive can return Media Catalog Number (UPC) info. */ | ||
310 | __u8 upc : 1; | ||
311 | /* Drive can return International Standard Recording Code info. */ | ||
312 | __u8 isrc : 1; | ||
313 | /* Drive supports C2 error pointers. */ | ||
314 | __u8 c2_pointers : 1; | ||
315 | /* R-W data will be returned deinterleaved and error corrected. */ | ||
316 | __u8 rw_corr : 1; | ||
317 | /* Subchannel reads can return combined R-W information. */ | ||
318 | __u8 rw_supported : 1; | ||
319 | /* Drive can continue a read cdda operation from a loss of streaming.*/ | ||
320 | __u8 cdda_accurate : 1; | ||
321 | /* Drive can read Red Book audio data. */ | ||
322 | __u8 cdda : 1; | ||
323 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | ||
324 | /* Drive can read Red Book audio data. */ | ||
325 | __u8 cdda : 1; | ||
326 | /* Drive can continue a read cdda operation from a loss of streaming.*/ | ||
327 | __u8 cdda_accurate : 1; | ||
328 | /* Subchannel reads can return combined R-W information. */ | ||
329 | __u8 rw_supported : 1; | ||
330 | /* R-W data will be returned deinterleaved and error corrected. */ | ||
331 | __u8 rw_corr : 1; | ||
332 | /* Drive supports C2 error pointers. */ | ||
333 | __u8 c2_pointers : 1; | ||
334 | /* Drive can return International Standard Recording Code info. */ | ||
335 | __u8 isrc : 1; | ||
336 | /* Drive can return Media Catalog Number (UPC) info. */ | ||
337 | __u8 upc : 1; | ||
338 | __u8 reserved5 : 1; | ||
339 | #else | ||
340 | #error "Please fix <asm/byteorder.h>" | ||
341 | #endif | ||
342 | |||
343 | #if defined(__BIG_ENDIAN_BITFIELD) | ||
344 | /* Drive mechanism types. */ | ||
345 | mechtype_t mechtype : 3; | ||
346 | __u8 reserved6 : 1; | ||
347 | /* Drive can eject a disc or changer cartridge. */ | ||
348 | __u8 eject : 1; | ||
349 | /* State of prevent/allow jumper. */ | ||
350 | __u8 prevent_jumper : 1; | ||
351 | /* Present state of door lock. */ | ||
352 | __u8 lock_state : 1; | ||
353 | /* Drive can lock the door. */ | ||
354 | __u8 lock : 1; | ||
355 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | ||
356 | |||
357 | /* Drive can lock the door. */ | ||
358 | __u8 lock : 1; | ||
359 | /* Present state of door lock. */ | ||
360 | __u8 lock_state : 1; | ||
361 | /* State of prevent/allow jumper. */ | ||
362 | __u8 prevent_jumper : 1; | ||
363 | /* Drive can eject a disc or changer cartridge. */ | ||
364 | __u8 eject : 1; | ||
365 | __u8 reserved6 : 1; | ||
366 | /* Drive mechanism types. */ | ||
367 | mechtype_t mechtype : 3; | ||
368 | #else | ||
369 | #error "Please fix <asm/byteorder.h>" | ||
370 | #endif | ||
371 | |||
372 | #if defined(__BIG_ENDIAN_BITFIELD) | ||
373 | __u8 reserved7 : 4; | ||
374 | /* Drive supports software slot selection. */ | ||
375 | __u8 sss : 1; /* reserved in 1.2 */ | ||
376 | /* Changer can report exact contents of slots. */ | ||
377 | __u8 disc_present : 1; /* reserved in 1.2 */ | ||
378 | /* Audio for each channel can be muted independently. */ | ||
379 | __u8 separate_mute : 1; | ||
380 | /* Audio level for each channel can be controlled independently. */ | ||
381 | __u8 separate_volume : 1; | ||
382 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | ||
383 | |||
384 | /* Audio level for each channel can be controlled independently. */ | ||
385 | __u8 separate_volume : 1; | ||
386 | /* Audio for each channel can be muted independently. */ | ||
387 | __u8 separate_mute : 1; | ||
388 | /* Changer can report exact contents of slots. */ | ||
389 | __u8 disc_present : 1; /* reserved in 1.2 */ | ||
390 | /* Drive supports software slot selection. */ | ||
391 | __u8 sss : 1; /* reserved in 1.2 */ | ||
392 | __u8 reserved7 : 4; | ||
393 | #else | ||
394 | #error "Please fix <asm/byteorder.h>" | ||
395 | #endif | ||
396 | |||
397 | /* Note: the following four fields are returned in big-endian form. */ | ||
398 | /* Maximum speed (in kB/s). */ | ||
399 | unsigned short maxspeed; | ||
400 | /* Number of discrete volume levels. */ | ||
401 | unsigned short n_vol_levels; | ||
402 | /* Size of cache in drive, in kB. */ | ||
403 | unsigned short buffer_size; | ||
404 | /* Current speed (in kB/s). */ | ||
405 | unsigned short curspeed; | ||
406 | char pad[4]; | ||
407 | }; | ||
408 | |||
409 | |||
410 | struct atapi_mechstat_header { | ||
411 | #if defined(__BIG_ENDIAN_BITFIELD) | ||
412 | __u8 fault : 1; | ||
413 | __u8 changer_state : 2; | ||
414 | __u8 curslot : 5; | ||
415 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | ||
416 | __u8 curslot : 5; | ||
417 | __u8 changer_state : 2; | ||
418 | __u8 fault : 1; | ||
419 | #else | ||
420 | #error "Please fix <asm/byteorder.h>" | ||
421 | #endif | ||
422 | |||
423 | #if defined(__BIG_ENDIAN_BITFIELD) | ||
424 | __u8 mech_state : 3; | ||
425 | __u8 door_open : 1; | ||
426 | __u8 reserved1 : 4; | ||
427 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | ||
428 | __u8 reserved1 : 4; | ||
429 | __u8 door_open : 1; | ||
430 | __u8 mech_state : 3; | ||
431 | #else | ||
432 | #error "Please fix <asm/byteorder.h>" | ||
433 | #endif | ||
434 | |||
435 | byte curlba[3]; | ||
436 | byte nslots; | ||
437 | __u16 slot_tablelen; | ||
438 | }; | ||
439 | |||
440 | |||
441 | struct atapi_slot { | ||
442 | #if defined(__BIG_ENDIAN_BITFIELD) | ||
443 | __u8 disc_present : 1; | ||
444 | __u8 reserved1 : 6; | ||
445 | __u8 change : 1; | ||
446 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | ||
447 | __u8 change : 1; | ||
448 | __u8 reserved1 : 6; | ||
449 | __u8 disc_present : 1; | ||
450 | #else | ||
451 | #error "Please fix <asm/byteorder.h>" | ||
452 | #endif | ||
453 | |||
454 | byte reserved2[3]; | ||
455 | }; | ||
456 | |||
457 | struct atapi_changer_info { | ||
458 | struct atapi_mechstat_header hdr; | ||
459 | struct atapi_slot slots[0]; | ||
460 | }; | ||
461 | |||
462 | /* Extra per-device info for cdrom drives. */ | 110 | /* Extra per-device info for cdrom drives. */ |
463 | struct cdrom_info { | 111 | struct cdrom_info { |
464 | ide_drive_t *drive; | 112 | ide_drive_t *drive; |
@@ -483,11 +131,11 @@ struct cdrom_info { | |||
483 | int dma; | 131 | int dma; |
484 | unsigned long last_block; | 132 | unsigned long last_block; |
485 | unsigned long start_seek; | 133 | unsigned long start_seek; |
486 | /* Buffer to hold mechanism status and changer slot table. */ | ||
487 | struct atapi_changer_info *changer_info; | ||
488 | 134 | ||
489 | struct ide_cd_config_flags config_flags; | 135 | unsigned int cd_flags; |
490 | struct ide_cd_state_flags state_flags; | 136 | |
137 | u8 max_speed; /* Max speed of the drive. */ | ||
138 | u8 current_speed; /* Current speed of the drive. */ | ||
491 | 139 | ||
492 | /* Per-device info needed by cdrom.c generic driver. */ | 140 | /* Per-device info needed by cdrom.c generic driver. */ |
493 | struct cdrom_device_info devinfo; | 141 | struct cdrom_device_info devinfo; |
@@ -495,250 +143,30 @@ struct cdrom_info { | |||
495 | unsigned long write_timeout; | 143 | unsigned long write_timeout; |
496 | }; | 144 | }; |
497 | 145 | ||
498 | /**************************************************************************** | 146 | /* ide-cd_verbose.c */ |
499 | * Descriptions of ATAPI error codes. | 147 | void ide_cd_log_error(const char *, struct request *, struct request_sense *); |
500 | */ | 148 | |
501 | 149 | /* ide-cd.c functions used by ide-cd_ioctl.c */ | |
502 | /* This stuff should be in cdrom.h, since it is now generic... */ | 150 | void ide_cd_init_rq(ide_drive_t *, struct request *); |
503 | 151 | int ide_cd_queue_pc(ide_drive_t *, struct request *); | |
504 | /* ATAPI sense keys (from table 140 of ATAPI 2.6) */ | 152 | int ide_cd_read_toc(ide_drive_t *, struct request_sense *); |
505 | #define NO_SENSE 0x00 | 153 | int ide_cdrom_get_capabilities(ide_drive_t *, u8 *); |
506 | #define RECOVERED_ERROR 0x01 | 154 | void ide_cdrom_update_speed(ide_drive_t *, u8 *); |
507 | #define NOT_READY 0x02 | 155 | int cdrom_check_status(ide_drive_t *, struct request_sense *); |
508 | #define MEDIUM_ERROR 0x03 | 156 | |
509 | #define HARDWARE_ERROR 0x04 | 157 | /* ide-cd_ioctl.c */ |
510 | #define ILLEGAL_REQUEST 0x05 | 158 | int ide_cdrom_open_real(struct cdrom_device_info *, int); |
511 | #define UNIT_ATTENTION 0x06 | 159 | void ide_cdrom_release_real(struct cdrom_device_info *); |
512 | #define DATA_PROTECT 0x07 | 160 | int ide_cdrom_drive_status(struct cdrom_device_info *, int); |
513 | #define BLANK_CHECK 0x08 | 161 | int ide_cdrom_check_media_change_real(struct cdrom_device_info *, int); |
514 | #define ABORTED_COMMAND 0x0b | 162 | int ide_cdrom_tray_move(struct cdrom_device_info *, int); |
515 | #define MISCOMPARE 0x0e | 163 | int ide_cdrom_lock_door(struct cdrom_device_info *, int); |
516 | 164 | int ide_cdrom_select_speed(struct cdrom_device_info *, int); | |
517 | 165 | int ide_cdrom_get_last_session(struct cdrom_device_info *, | |
518 | 166 | struct cdrom_multisession *); | |
519 | /* This stuff should be in cdrom.h, since it is now generic... */ | 167 | int ide_cdrom_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *); |
520 | #if VERBOSE_IDE_CD_ERRORS | 168 | int ide_cdrom_reset(struct cdrom_device_info *cdi); |
521 | 169 | int ide_cdrom_audio_ioctl(struct cdrom_device_info *, unsigned int, void *); | |
522 | /* The generic packet command opcodes for CD/DVD Logical Units, | 170 | int ide_cdrom_packet(struct cdrom_device_info *, struct packet_command *); |
523 | * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ | ||
524 | static const struct { | ||
525 | unsigned short packet_command; | ||
526 | const char * const text; | ||
527 | } packet_command_texts[] = { | ||
528 | { GPCMD_TEST_UNIT_READY, "Test Unit Ready" }, | ||
529 | { GPCMD_REQUEST_SENSE, "Request Sense" }, | ||
530 | { GPCMD_FORMAT_UNIT, "Format Unit" }, | ||
531 | { GPCMD_INQUIRY, "Inquiry" }, | ||
532 | { GPCMD_START_STOP_UNIT, "Start/Stop Unit" }, | ||
533 | { GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL, "Prevent/Allow Medium Removal" }, | ||
534 | { GPCMD_READ_FORMAT_CAPACITIES, "Read Format Capacities" }, | ||
535 | { GPCMD_READ_CDVD_CAPACITY, "Read Cd/Dvd Capacity" }, | ||
536 | { GPCMD_READ_10, "Read 10" }, | ||
537 | { GPCMD_WRITE_10, "Write 10" }, | ||
538 | { GPCMD_SEEK, "Seek" }, | ||
539 | { GPCMD_WRITE_AND_VERIFY_10, "Write and Verify 10" }, | ||
540 | { GPCMD_VERIFY_10, "Verify 10" }, | ||
541 | { GPCMD_FLUSH_CACHE, "Flush Cache" }, | ||
542 | { GPCMD_READ_SUBCHANNEL, "Read Subchannel" }, | ||
543 | { GPCMD_READ_TOC_PMA_ATIP, "Read Table of Contents" }, | ||
544 | { GPCMD_READ_HEADER, "Read Header" }, | ||
545 | { GPCMD_PLAY_AUDIO_10, "Play Audio 10" }, | ||
546 | { GPCMD_GET_CONFIGURATION, "Get Configuration" }, | ||
547 | { GPCMD_PLAY_AUDIO_MSF, "Play Audio MSF" }, | ||
548 | { GPCMD_PLAYAUDIO_TI, "Play Audio TrackIndex" }, | ||
549 | { GPCMD_GET_EVENT_STATUS_NOTIFICATION, "Get Event Status Notification" }, | ||
550 | { GPCMD_PAUSE_RESUME, "Pause/Resume" }, | ||
551 | { GPCMD_STOP_PLAY_SCAN, "Stop Play/Scan" }, | ||
552 | { GPCMD_READ_DISC_INFO, "Read Disc Info" }, | ||
553 | { GPCMD_READ_TRACK_RZONE_INFO, "Read Track Rzone Info" }, | ||
554 | { GPCMD_RESERVE_RZONE_TRACK, "Reserve Rzone Track" }, | ||
555 | { GPCMD_SEND_OPC, "Send OPC" }, | ||
556 | { GPCMD_MODE_SELECT_10, "Mode Select 10" }, | ||
557 | { GPCMD_REPAIR_RZONE_TRACK, "Repair Rzone Track" }, | ||
558 | { GPCMD_MODE_SENSE_10, "Mode Sense 10" }, | ||
559 | { GPCMD_CLOSE_TRACK, "Close Track" }, | ||
560 | { GPCMD_BLANK, "Blank" }, | ||
561 | { GPCMD_SEND_EVENT, "Send Event" }, | ||
562 | { GPCMD_SEND_KEY, "Send Key" }, | ||
563 | { GPCMD_REPORT_KEY, "Report Key" }, | ||
564 | { GPCMD_LOAD_UNLOAD, "Load/Unload" }, | ||
565 | { GPCMD_SET_READ_AHEAD, "Set Read-ahead" }, | ||
566 | { GPCMD_READ_12, "Read 12" }, | ||
567 | { GPCMD_GET_PERFORMANCE, "Get Performance" }, | ||
568 | { GPCMD_SEND_DVD_STRUCTURE, "Send DVD Structure" }, | ||
569 | { GPCMD_READ_DVD_STRUCTURE, "Read DVD Structure" }, | ||
570 | { GPCMD_SET_STREAMING, "Set Streaming" }, | ||
571 | { GPCMD_READ_CD_MSF, "Read CD MSF" }, | ||
572 | { GPCMD_SCAN, "Scan" }, | ||
573 | { GPCMD_SET_SPEED, "Set Speed" }, | ||
574 | { GPCMD_PLAY_CD, "Play CD" }, | ||
575 | { GPCMD_MECHANISM_STATUS, "Mechanism Status" }, | ||
576 | { GPCMD_READ_CD, "Read CD" }, | ||
577 | }; | ||
578 | |||
579 | |||
580 | |||
581 | /* From Table 303 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ | ||
582 | static const char * const sense_key_texts[16] = { | ||
583 | "No sense data", | ||
584 | "Recovered error", | ||
585 | "Not ready", | ||
586 | "Medium error", | ||
587 | "Hardware error", | ||
588 | "Illegal request", | ||
589 | "Unit attention", | ||
590 | "Data protect", | ||
591 | "Blank check", | ||
592 | "(reserved)", | ||
593 | "(reserved)", | ||
594 | "Aborted command", | ||
595 | "(reserved)", | ||
596 | "(reserved)", | ||
597 | "Miscompare", | ||
598 | "(reserved)", | ||
599 | }; | ||
600 | |||
601 | /* From Table 304 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ | ||
602 | static const struct { | ||
603 | unsigned long asc_ascq; | ||
604 | const char * const text; | ||
605 | } sense_data_texts[] = { | ||
606 | { 0x000000, "No additional sense information" }, | ||
607 | { 0x000011, "Play operation in progress" }, | ||
608 | { 0x000012, "Play operation paused" }, | ||
609 | { 0x000013, "Play operation successfully completed" }, | ||
610 | { 0x000014, "Play operation stopped due to error" }, | ||
611 | { 0x000015, "No current audio status to return" }, | ||
612 | { 0x010c0a, "Write error - padding blocks added" }, | ||
613 | { 0x011700, "Recovered data with no error correction applied" }, | ||
614 | { 0x011701, "Recovered data with retries" }, | ||
615 | { 0x011702, "Recovered data with positive head offset" }, | ||
616 | { 0x011703, "Recovered data with negative head offset" }, | ||
617 | { 0x011704, "Recovered data with retries and/or CIRC applied" }, | ||
618 | { 0x011705, "Recovered data using previous sector ID" }, | ||
619 | { 0x011800, "Recovered data with error correction applied" }, | ||
620 | { 0x011801, "Recovered data with error correction and retries applied"}, | ||
621 | { 0x011802, "Recovered data - the data was auto-reallocated" }, | ||
622 | { 0x011803, "Recovered data with CIRC" }, | ||
623 | { 0x011804, "Recovered data with L-EC" }, | ||
624 | { 0x015d00, | ||
625 | "Failure prediction threshold exceeded - Predicted logical unit failure" }, | ||
626 | { 0x015d01, | ||
627 | "Failure prediction threshold exceeded - Predicted media failure" }, | ||
628 | { 0x015dff, "Failure prediction threshold exceeded - False" }, | ||
629 | { 0x017301, "Power calibration area almost full" }, | ||
630 | { 0x020400, "Logical unit not ready - cause not reportable" }, | ||
631 | /* Following is misspelled in ATAPI 2.6, _and_ in Mt. Fuji */ | ||
632 | { 0x020401, | ||
633 | "Logical unit not ready - in progress [sic] of becoming ready" }, | ||
634 | { 0x020402, "Logical unit not ready - initializing command required" }, | ||
635 | { 0x020403, "Logical unit not ready - manual intervention required" }, | ||
636 | { 0x020404, "Logical unit not ready - format in progress" }, | ||
637 | { 0x020407, "Logical unit not ready - operation in progress" }, | ||
638 | { 0x020408, "Logical unit not ready - long write in progress" }, | ||
639 | { 0x020600, "No reference position found (media may be upside down)" }, | ||
640 | { 0x023000, "Incompatible medium installed" }, | ||
641 | { 0x023a00, "Medium not present" }, | ||
642 | { 0x025300, "Media load or eject failed" }, | ||
643 | { 0x025700, "Unable to recover table of contents" }, | ||
644 | { 0x030300, "Peripheral device write fault" }, | ||
645 | { 0x030301, "No write current" }, | ||
646 | { 0x030302, "Excessive write errors" }, | ||
647 | { 0x030c00, "Write error" }, | ||
648 | { 0x030c01, "Write error - Recovered with auto reallocation" }, | ||
649 | { 0x030c02, "Write error - auto reallocation failed" }, | ||
650 | { 0x030c03, "Write error - recommend reassignment" }, | ||
651 | { 0x030c04, "Compression check miscompare error" }, | ||
652 | { 0x030c05, "Data expansion occurred during compress" }, | ||
653 | { 0x030c06, "Block not compressible" }, | ||
654 | { 0x030c07, "Write error - recovery needed" }, | ||
655 | { 0x030c08, "Write error - recovery failed" }, | ||
656 | { 0x030c09, "Write error - loss of streaming" }, | ||
657 | { 0x031100, "Unrecovered read error" }, | ||
658 | { 0x031106, "CIRC unrecovered error" }, | ||
659 | { 0x033101, "Format command failed" }, | ||
660 | { 0x033200, "No defect spare location available" }, | ||
661 | { 0x033201, "Defect list update failure" }, | ||
662 | { 0x035100, "Erase failure" }, | ||
663 | { 0x037200, "Session fixation error" }, | ||
664 | { 0x037201, "Session fixation error writin lead-in" }, | ||
665 | { 0x037202, "Session fixation error writin lead-out" }, | ||
666 | { 0x037300, "CD control error" }, | ||
667 | { 0x037302, "Power calibration area is full" }, | ||
668 | { 0x037303, "Power calibration area error" }, | ||
669 | { 0x037304, "Program memory area / RMA update failure" }, | ||
670 | { 0x037305, "Program memory area / RMA is full" }, | ||
671 | { 0x037306, "Program memory area / RMA is (almost) full" }, | ||
672 | |||
673 | { 0x040200, "No seek complete" }, | ||
674 | { 0x040300, "Write fault" }, | ||
675 | { 0x040900, "Track following error" }, | ||
676 | { 0x040901, "Tracking servo failure" }, | ||
677 | { 0x040902, "Focus servo failure" }, | ||
678 | { 0x040903, "Spindle servo failure" }, | ||
679 | { 0x041500, "Random positioning error" }, | ||
680 | { 0x041501, "Mechanical positioning or changer error" }, | ||
681 | { 0x041502, "Positioning error detected by read of medium" }, | ||
682 | { 0x043c00, "Mechanical positioning or changer error" }, | ||
683 | { 0x044000, "Diagnostic failure on component (ASCQ)" }, | ||
684 | { 0x044400, "Internal CD/DVD logical unit failure" }, | ||
685 | { 0x04b600, "Media load mechanism failed" }, | ||
686 | { 0x051a00, "Parameter list length error" }, | ||
687 | { 0x052000, "Invalid command operation code" }, | ||
688 | { 0x052100, "Logical block address out of range" }, | ||
689 | { 0x052102, "Invalid address for write" }, | ||
690 | { 0x052400, "Invalid field in command packet" }, | ||
691 | { 0x052600, "Invalid field in parameter list" }, | ||
692 | { 0x052601, "Parameter not supported" }, | ||
693 | { 0x052602, "Parameter value invalid" }, | ||
694 | { 0x052700, "Write protected media" }, | ||
695 | { 0x052c00, "Command sequence error" }, | ||
696 | { 0x052c03, "Current program area is not empty" }, | ||
697 | { 0x052c04, "Current program area is empty" }, | ||
698 | { 0x053001, "Cannot read medium - unknown format" }, | ||
699 | { 0x053002, "Cannot read medium - incompatible format" }, | ||
700 | { 0x053900, "Saving parameters not supported" }, | ||
701 | { 0x054e00, "Overlapped commands attempted" }, | ||
702 | { 0x055302, "Medium removal prevented" }, | ||
703 | { 0x055500, "System resource failure" }, | ||
704 | { 0x056300, "End of user area encountered on this track" }, | ||
705 | { 0x056400, "Illegal mode for this track or incompatible medium" }, | ||
706 | { 0x056f00, "Copy protection key exchange failure - Authentication failure" }, | ||
707 | { 0x056f01, "Copy protection key exchange failure - Key not present" }, | ||
708 | { 0x056f02, "Copy protection key exchange failure - Key not established" }, | ||
709 | { 0x056f03, "Read of scrambled sector without authentication" }, | ||
710 | { 0x056f04, "Media region code is mismatched to logical unit" }, | ||
711 | { 0x056f05, "Drive region must be permanent / region reset count error" }, | ||
712 | { 0x057203, "Session fixation error - incomplete track in session" }, | ||
713 | { 0x057204, "Empty or partially written reserved track" }, | ||
714 | { 0x057205, "No more RZONE reservations are allowed" }, | ||
715 | { 0x05bf00, "Loss of streaming" }, | ||
716 | { 0x062800, "Not ready to ready transition, medium may have changed" }, | ||
717 | { 0x062900, "Power on, reset or hardware reset occurred" }, | ||
718 | { 0x062a00, "Parameters changed" }, | ||
719 | { 0x062a01, "Mode parameters changed" }, | ||
720 | { 0x062e00, "Insufficient time for operation" }, | ||
721 | { 0x063f00, "Logical unit operating conditions have changed" }, | ||
722 | { 0x063f01, "Microcode has been changed" }, | ||
723 | { 0x065a00, "Operator request or state change input (unspecified)" }, | ||
724 | { 0x065a01, "Operator medium removal request" }, | ||
725 | { 0x0bb900, "Play operation aborted" }, | ||
726 | |||
727 | /* Here we use 0xff for the key (not a valid key) to signify | ||
728 | * that these can have _any_ key value associated with them... */ | ||
729 | { 0xff0401, "Logical unit is in process of becoming ready" }, | ||
730 | { 0xff0400, "Logical unit not ready, cause not reportable" }, | ||
731 | { 0xff0402, "Logical unit not ready, initializing command required" }, | ||
732 | { 0xff0403, "Logical unit not ready, manual intervention required" }, | ||
733 | { 0xff0500, "Logical unit does not respond to selection" }, | ||
734 | { 0xff0800, "Logical unit communication failure" }, | ||
735 | { 0xff0802, "Logical unit communication parity error" }, | ||
736 | { 0xff0801, "Logical unit communication time-out" }, | ||
737 | { 0xff2500, "Logical unit not supported" }, | ||
738 | { 0xff4c00, "Logical unit failed self-configuration" }, | ||
739 | { 0xff3e00, "Logical unit has not self-configured yet" }, | ||
740 | }; | ||
741 | #endif | ||
742 | |||
743 | 171 | ||
744 | #endif /* _IDE_CD_H */ | 172 | #endif /* _IDE_CD_H */ |
diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c new file mode 100644 index 000000000000..b68284de4e85 --- /dev/null +++ b/drivers/ide/ide-cd_ioctl.c | |||
@@ -0,0 +1,475 @@ | |||
1 | /* | ||
2 | * cdrom.c IOCTLs handling for ide-cd driver. | ||
3 | * | ||
4 | * Copyright (C) 1994-1996 Scott Snyder <snyder@fnald0.fnal.gov> | ||
5 | * Copyright (C) 1996-1998 Erik Andersen <andersee@debian.org> | ||
6 | * Copyright (C) 1998-2000 Jens Axboe <axboe@suse.de> | ||
7 | */ | ||
8 | |||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/cdrom.h> | ||
11 | #include <linux/ide.h> | ||
12 | #include <scsi/scsi.h> | ||
13 | |||
14 | #include "ide-cd.h" | ||
15 | |||
16 | /**************************************************************************** | ||
17 | * Other driver requests (open, close, check media change). | ||
18 | */ | ||
19 | int ide_cdrom_open_real(struct cdrom_device_info *cdi, int purpose) | ||
20 | { | ||
21 | return 0; | ||
22 | } | ||
23 | |||
24 | /* | ||
25 | * Close down the device. Invalidate all cached blocks. | ||
26 | */ | ||
27 | void ide_cdrom_release_real(struct cdrom_device_info *cdi) | ||
28 | { | ||
29 | ide_drive_t *drive = cdi->handle; | ||
30 | struct cdrom_info *cd = drive->driver_data; | ||
31 | |||
32 | if (!cdi->use_count) | ||
33 | cd->cd_flags &= ~IDE_CD_FLAG_TOC_VALID; | ||
34 | } | ||
35 | |||
36 | /* | ||
37 | * add logic to try GET_EVENT command first to check for media and tray | ||
38 | * status. this should be supported by newer cd-r/w and all DVD etc | ||
39 | * drives | ||
40 | */ | ||
41 | int ide_cdrom_drive_status(struct cdrom_device_info *cdi, int slot_nr) | ||
42 | { | ||
43 | ide_drive_t *drive = cdi->handle; | ||
44 | struct media_event_desc med; | ||
45 | struct request_sense sense; | ||
46 | int stat; | ||
47 | |||
48 | if (slot_nr != CDSL_CURRENT) | ||
49 | return -EINVAL; | ||
50 | |||
51 | stat = cdrom_check_status(drive, &sense); | ||
52 | if (!stat || sense.sense_key == UNIT_ATTENTION) | ||
53 | return CDS_DISC_OK; | ||
54 | |||
55 | if (!cdrom_get_media_event(cdi, &med)) { | ||
56 | if (med.media_present) | ||
57 | return CDS_DISC_OK; | ||
58 | else if (med.door_open) | ||
59 | return CDS_TRAY_OPEN; | ||
60 | else | ||
61 | return CDS_NO_DISC; | ||
62 | } | ||
63 | |||
64 | if (sense.sense_key == NOT_READY && sense.asc == 0x04 | ||
65 | && sense.ascq == 0x04) | ||
66 | return CDS_DISC_OK; | ||
67 | |||
68 | /* | ||
69 | * If not using Mt Fuji extended media tray reports, | ||
70 | * just return TRAY_OPEN since ATAPI doesn't provide | ||
71 | * any other way to detect this... | ||
72 | */ | ||
73 | if (sense.sense_key == NOT_READY) { | ||
74 | if (sense.asc == 0x3a && sense.ascq == 1) | ||
75 | return CDS_NO_DISC; | ||
76 | else | ||
77 | return CDS_TRAY_OPEN; | ||
78 | } | ||
79 | return CDS_DRIVE_NOT_READY; | ||
80 | } | ||
81 | |||
82 | int ide_cdrom_check_media_change_real(struct cdrom_device_info *cdi, | ||
83 | int slot_nr) | ||
84 | { | ||
85 | ide_drive_t *drive = cdi->handle; | ||
86 | struct cdrom_info *cd = drive->driver_data; | ||
87 | int retval; | ||
88 | |||
89 | if (slot_nr == CDSL_CURRENT) { | ||
90 | (void) cdrom_check_status(drive, NULL); | ||
91 | retval = (cd->cd_flags & IDE_CD_FLAG_MEDIA_CHANGED) ? 1 : 0; | ||
92 | cd->cd_flags &= ~IDE_CD_FLAG_MEDIA_CHANGED; | ||
93 | return retval; | ||
94 | } else { | ||
95 | return -EINVAL; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | /* Eject the disk if EJECTFLAG is 0. | ||
100 | If EJECTFLAG is 1, try to reload the disk. */ | ||
101 | static | ||
102 | int cdrom_eject(ide_drive_t *drive, int ejectflag, | ||
103 | struct request_sense *sense) | ||
104 | { | ||
105 | struct cdrom_info *cd = drive->driver_data; | ||
106 | struct cdrom_device_info *cdi = &cd->devinfo; | ||
107 | struct request req; | ||
108 | char loej = 0x02; | ||
109 | |||
110 | if ((cd->cd_flags & IDE_CD_FLAG_NO_EJECT) && !ejectflag) | ||
111 | return -EDRIVE_CANT_DO_THIS; | ||
112 | |||
113 | /* reload fails on some drives, if the tray is locked */ | ||
114 | if ((cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) && ejectflag) | ||
115 | return 0; | ||
116 | |||
117 | ide_cd_init_rq(drive, &req); | ||
118 | |||
119 | /* only tell drive to close tray if open, if it can do that */ | ||
120 | if (ejectflag && (cdi->mask & CDC_CLOSE_TRAY)) | ||
121 | loej = 0; | ||
122 | |||
123 | req.sense = sense; | ||
124 | req.cmd[0] = GPCMD_START_STOP_UNIT; | ||
125 | req.cmd[4] = loej | (ejectflag != 0); | ||
126 | |||
127 | return ide_cd_queue_pc(drive, &req); | ||
128 | } | ||
129 | |||
130 | /* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */ | ||
131 | static | ||
132 | int ide_cd_lockdoor(ide_drive_t *drive, int lockflag, | ||
133 | struct request_sense *sense) | ||
134 | { | ||
135 | struct cdrom_info *cd = drive->driver_data; | ||
136 | struct request_sense my_sense; | ||
137 | struct request req; | ||
138 | int stat; | ||
139 | |||
140 | if (sense == NULL) | ||
141 | sense = &my_sense; | ||
142 | |||
143 | /* If the drive cannot lock the door, just pretend. */ | ||
144 | if (cd->cd_flags & IDE_CD_FLAG_NO_DOORLOCK) { | ||
145 | stat = 0; | ||
146 | } else { | ||
147 | ide_cd_init_rq(drive, &req); | ||
148 | req.sense = sense; | ||
149 | req.cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; | ||
150 | req.cmd[4] = lockflag ? 1 : 0; | ||
151 | stat = ide_cd_queue_pc(drive, &req); | ||
152 | } | ||
153 | |||
154 | /* If we got an illegal field error, the drive | ||
155 | probably cannot lock the door. */ | ||
156 | if (stat != 0 && | ||
157 | sense->sense_key == ILLEGAL_REQUEST && | ||
158 | (sense->asc == 0x24 || sense->asc == 0x20)) { | ||
159 | printk(KERN_ERR "%s: door locking not supported\n", | ||
160 | drive->name); | ||
161 | cd->cd_flags |= IDE_CD_FLAG_NO_DOORLOCK; | ||
162 | stat = 0; | ||
163 | } | ||
164 | |||
165 | /* no medium, that's alright. */ | ||
166 | if (stat != 0 && sense->sense_key == NOT_READY && sense->asc == 0x3a) | ||
167 | stat = 0; | ||
168 | |||
169 | if (stat == 0) { | ||
170 | if (lockflag) | ||
171 | cd->cd_flags |= IDE_CD_FLAG_DOOR_LOCKED; | ||
172 | else | ||
173 | cd->cd_flags &= ~IDE_CD_FLAG_DOOR_LOCKED; | ||
174 | } | ||
175 | |||
176 | return stat; | ||
177 | } | ||
178 | |||
179 | int ide_cdrom_tray_move(struct cdrom_device_info *cdi, int position) | ||
180 | { | ||
181 | ide_drive_t *drive = cdi->handle; | ||
182 | struct request_sense sense; | ||
183 | |||
184 | if (position) { | ||
185 | int stat = ide_cd_lockdoor(drive, 0, &sense); | ||
186 | |||
187 | if (stat) | ||
188 | return stat; | ||
189 | } | ||
190 | |||
191 | return cdrom_eject(drive, !position, &sense); | ||
192 | } | ||
193 | |||
194 | int ide_cdrom_lock_door(struct cdrom_device_info *cdi, int lock) | ||
195 | { | ||
196 | ide_drive_t *drive = cdi->handle; | ||
197 | |||
198 | return ide_cd_lockdoor(drive, lock, NULL); | ||
199 | } | ||
200 | |||
201 | /* | ||
202 | * ATAPI devices are free to select the speed you request or any slower | ||
203 | * rate. :-( Requesting too fast a speed will _not_ produce an error. | ||
204 | */ | ||
205 | int ide_cdrom_select_speed(struct cdrom_device_info *cdi, int speed) | ||
206 | { | ||
207 | ide_drive_t *drive = cdi->handle; | ||
208 | struct cdrom_info *cd = drive->driver_data; | ||
209 | struct request rq; | ||
210 | struct request_sense sense; | ||
211 | u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; | ||
212 | int stat; | ||
213 | |||
214 | ide_cd_init_rq(drive, &rq); | ||
215 | |||
216 | rq.sense = &sense; | ||
217 | |||
218 | if (speed == 0) | ||
219 | speed = 0xffff; /* set to max */ | ||
220 | else | ||
221 | speed *= 177; /* Nx to kbytes/s */ | ||
222 | |||
223 | rq.cmd[0] = GPCMD_SET_SPEED; | ||
224 | /* Read Drive speed in kbytes/second MSB/LSB */ | ||
225 | rq.cmd[2] = (speed >> 8) & 0xff; | ||
226 | rq.cmd[3] = speed & 0xff; | ||
227 | if ((cdi->mask & (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) != | ||
228 | (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) { | ||
229 | /* Write Drive speed in kbytes/second MSB/LSB */ | ||
230 | rq.cmd[4] = (speed >> 8) & 0xff; | ||
231 | rq.cmd[5] = speed & 0xff; | ||
232 | } | ||
233 | |||
234 | stat = ide_cd_queue_pc(drive, &rq); | ||
235 | |||
236 | if (!ide_cdrom_get_capabilities(drive, buf)) { | ||
237 | ide_cdrom_update_speed(drive, buf); | ||
238 | cdi->speed = cd->current_speed; | ||
239 | } | ||
240 | |||
241 | return 0; | ||
242 | } | ||
243 | |||
244 | int ide_cdrom_get_last_session(struct cdrom_device_info *cdi, | ||
245 | struct cdrom_multisession *ms_info) | ||
246 | { | ||
247 | struct atapi_toc *toc; | ||
248 | ide_drive_t *drive = cdi->handle; | ||
249 | struct cdrom_info *info = drive->driver_data; | ||
250 | struct request_sense sense; | ||
251 | int ret; | ||
252 | |||
253 | if ((info->cd_flags & IDE_CD_FLAG_TOC_VALID) == 0 || !info->toc) { | ||
254 | ret = ide_cd_read_toc(drive, &sense); | ||
255 | if (ret) | ||
256 | return ret; | ||
257 | } | ||
258 | |||
259 | toc = info->toc; | ||
260 | ms_info->addr.lba = toc->last_session_lba; | ||
261 | ms_info->xa_flag = toc->xa_flag; | ||
262 | |||
263 | return 0; | ||
264 | } | ||
265 | |||
266 | int ide_cdrom_get_mcn(struct cdrom_device_info *cdi, | ||
267 | struct cdrom_mcn *mcn_info) | ||
268 | { | ||
269 | ide_drive_t *drive = cdi->handle; | ||
270 | int stat, mcnlen; | ||
271 | struct request rq; | ||
272 | char buf[24]; | ||
273 | |||
274 | ide_cd_init_rq(drive, &rq); | ||
275 | |||
276 | rq.data = buf; | ||
277 | rq.data_len = sizeof(buf); | ||
278 | |||
279 | rq.cmd[0] = GPCMD_READ_SUBCHANNEL; | ||
280 | rq.cmd[1] = 2; /* MSF addressing */ | ||
281 | rq.cmd[2] = 0x40; /* request subQ data */ | ||
282 | rq.cmd[3] = 2; /* format */ | ||
283 | rq.cmd[8] = sizeof(buf); | ||
284 | |||
285 | stat = ide_cd_queue_pc(drive, &rq); | ||
286 | if (stat) | ||
287 | return stat; | ||
288 | |||
289 | mcnlen = sizeof(mcn_info->medium_catalog_number) - 1; | ||
290 | memcpy(mcn_info->medium_catalog_number, buf + 9, mcnlen); | ||
291 | mcn_info->medium_catalog_number[mcnlen] = '\0'; | ||
292 | |||
293 | return 0; | ||
294 | } | ||
295 | |||
296 | int ide_cdrom_reset(struct cdrom_device_info *cdi) | ||
297 | { | ||
298 | ide_drive_t *drive = cdi->handle; | ||
299 | struct cdrom_info *cd = drive->driver_data; | ||
300 | struct request_sense sense; | ||
301 | struct request req; | ||
302 | int ret; | ||
303 | |||
304 | ide_cd_init_rq(drive, &req); | ||
305 | req.cmd_type = REQ_TYPE_SPECIAL; | ||
306 | req.cmd_flags = REQ_QUIET; | ||
307 | ret = ide_do_drive_cmd(drive, &req, ide_wait); | ||
308 | |||
309 | /* | ||
310 | * A reset will unlock the door. If it was previously locked, | ||
311 | * lock it again. | ||
312 | */ | ||
313 | if (cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) | ||
314 | (void)ide_cd_lockdoor(drive, 1, &sense); | ||
315 | |||
316 | return ret; | ||
317 | } | ||
318 | |||
319 | static int ide_cd_get_toc_entry(ide_drive_t *drive, int track, | ||
320 | struct atapi_toc_entry **ent) | ||
321 | { | ||
322 | struct cdrom_info *info = drive->driver_data; | ||
323 | struct atapi_toc *toc = info->toc; | ||
324 | int ntracks; | ||
325 | |||
326 | /* | ||
327 | * don't serve cached data, if the toc isn't valid | ||
328 | */ | ||
329 | if ((info->cd_flags & IDE_CD_FLAG_TOC_VALID) == 0) | ||
330 | return -EINVAL; | ||
331 | |||
332 | /* Check validity of requested track number. */ | ||
333 | ntracks = toc->hdr.last_track - toc->hdr.first_track + 1; | ||
334 | |||
335 | if (toc->hdr.first_track == CDROM_LEADOUT) | ||
336 | ntracks = 0; | ||
337 | |||
338 | if (track == CDROM_LEADOUT) | ||
339 | *ent = &toc->ent[ntracks]; | ||
340 | else if (track < toc->hdr.first_track || track > toc->hdr.last_track) | ||
341 | return -EINVAL; | ||
342 | else | ||
343 | *ent = &toc->ent[track - toc->hdr.first_track]; | ||
344 | |||
345 | return 0; | ||
346 | } | ||
347 | |||
348 | static int ide_cd_fake_play_trkind(ide_drive_t *drive, void *arg) | ||
349 | { | ||
350 | struct cdrom_ti *ti = arg; | ||
351 | struct atapi_toc_entry *first_toc, *last_toc; | ||
352 | unsigned long lba_start, lba_end; | ||
353 | int stat; | ||
354 | struct request rq; | ||
355 | struct request_sense sense; | ||
356 | |||
357 | stat = ide_cd_get_toc_entry(drive, ti->cdti_trk0, &first_toc); | ||
358 | if (stat) | ||
359 | return stat; | ||
360 | |||
361 | stat = ide_cd_get_toc_entry(drive, ti->cdti_trk1, &last_toc); | ||
362 | if (stat) | ||
363 | return stat; | ||
364 | |||
365 | if (ti->cdti_trk1 != CDROM_LEADOUT) | ||
366 | ++last_toc; | ||
367 | lba_start = first_toc->addr.lba; | ||
368 | lba_end = last_toc->addr.lba; | ||
369 | |||
370 | if (lba_end <= lba_start) | ||
371 | return -EINVAL; | ||
372 | |||
373 | ide_cd_init_rq(drive, &rq); | ||
374 | |||
375 | rq.sense = &sense; | ||
376 | rq.cmd[0] = GPCMD_PLAY_AUDIO_MSF; | ||
377 | lba_to_msf(lba_start, &rq.cmd[3], &rq.cmd[4], &rq.cmd[5]); | ||
378 | lba_to_msf(lba_end - 1, &rq.cmd[6], &rq.cmd[7], &rq.cmd[8]); | ||
379 | |||
380 | return ide_cd_queue_pc(drive, &rq); | ||
381 | } | ||
382 | |||
383 | static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg) | ||
384 | { | ||
385 | struct cdrom_info *cd = drive->driver_data; | ||
386 | struct cdrom_tochdr *tochdr = arg; | ||
387 | struct atapi_toc *toc; | ||
388 | int stat; | ||
389 | |||
390 | /* Make sure our saved TOC is valid. */ | ||
391 | stat = ide_cd_read_toc(drive, NULL); | ||
392 | if (stat) | ||
393 | return stat; | ||
394 | |||
395 | toc = cd->toc; | ||
396 | tochdr->cdth_trk0 = toc->hdr.first_track; | ||
397 | tochdr->cdth_trk1 = toc->hdr.last_track; | ||
398 | |||
399 | return 0; | ||
400 | } | ||
401 | |||
402 | static int ide_cd_read_tocentry(ide_drive_t *drive, void *arg) | ||
403 | { | ||
404 | struct cdrom_tocentry *tocentry = arg; | ||
405 | struct atapi_toc_entry *toce; | ||
406 | int stat; | ||
407 | |||
408 | stat = ide_cd_get_toc_entry(drive, tocentry->cdte_track, &toce); | ||
409 | if (stat) | ||
410 | return stat; | ||
411 | |||
412 | tocentry->cdte_ctrl = toce->control; | ||
413 | tocentry->cdte_adr = toce->adr; | ||
414 | if (tocentry->cdte_format == CDROM_MSF) { | ||
415 | lba_to_msf(toce->addr.lba, | ||
416 | &tocentry->cdte_addr.msf.minute, | ||
417 | &tocentry->cdte_addr.msf.second, | ||
418 | &tocentry->cdte_addr.msf.frame); | ||
419 | } else | ||
420 | tocentry->cdte_addr.lba = toce->addr.lba; | ||
421 | |||
422 | return 0; | ||
423 | } | ||
424 | |||
425 | int ide_cdrom_audio_ioctl(struct cdrom_device_info *cdi, | ||
426 | unsigned int cmd, void *arg) | ||
427 | { | ||
428 | ide_drive_t *drive = cdi->handle; | ||
429 | |||
430 | switch (cmd) { | ||
431 | /* | ||
432 | * emulate PLAY_AUDIO_TI command with PLAY_AUDIO_10, since | ||
433 | * atapi doesn't support it | ||
434 | */ | ||
435 | case CDROMPLAYTRKIND: | ||
436 | return ide_cd_fake_play_trkind(drive, arg); | ||
437 | case CDROMREADTOCHDR: | ||
438 | return ide_cd_read_tochdr(drive, arg); | ||
439 | case CDROMREADTOCENTRY: | ||
440 | return ide_cd_read_tocentry(drive, arg); | ||
441 | default: | ||
442 | return -EINVAL; | ||
443 | } | ||
444 | } | ||
445 | |||
446 | /* the generic packet interface to cdrom.c */ | ||
447 | int ide_cdrom_packet(struct cdrom_device_info *cdi, | ||
448 | struct packet_command *cgc) | ||
449 | { | ||
450 | struct request req; | ||
451 | ide_drive_t *drive = cdi->handle; | ||
452 | |||
453 | if (cgc->timeout <= 0) | ||
454 | cgc->timeout = ATAPI_WAIT_PC; | ||
455 | |||
456 | /* here we queue the commands from the uniform CD-ROM | ||
457 | layer. the packet must be complete, as we do not | ||
458 | touch it at all. */ | ||
459 | ide_cd_init_rq(drive, &req); | ||
460 | memcpy(req.cmd, cgc->cmd, CDROM_PACKET_SIZE); | ||
461 | if (cgc->sense) | ||
462 | memset(cgc->sense, 0, sizeof(struct request_sense)); | ||
463 | req.data = cgc->buffer; | ||
464 | req.data_len = cgc->buflen; | ||
465 | req.timeout = cgc->timeout; | ||
466 | |||
467 | if (cgc->quiet) | ||
468 | req.cmd_flags |= REQ_QUIET; | ||
469 | |||
470 | req.sense = cgc->sense; | ||
471 | cgc->stat = ide_cd_queue_pc(drive, &req); | ||
472 | if (!cgc->stat) | ||
473 | cgc->buflen -= req.data_len; | ||
474 | return cgc->stat; | ||
475 | } | ||
diff --git a/drivers/ide/ide-cd_verbose.c b/drivers/ide/ide-cd_verbose.c new file mode 100644 index 000000000000..6ed7ca071331 --- /dev/null +++ b/drivers/ide/ide-cd_verbose.c | |||
@@ -0,0 +1,359 @@ | |||
1 | /* | ||
2 | * Verbose error logging for ATAPI CD/DVD devices. | ||
3 | * | ||
4 | * Copyright (C) 1994-1996 Scott Snyder <snyder@fnald0.fnal.gov> | ||
5 | * Copyright (C) 1996-1998 Erik Andersen <andersee@debian.org> | ||
6 | * Copyright (C) 1998-2000 Jens Axboe <axboe@suse.de> | ||
7 | */ | ||
8 | |||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/blkdev.h> | ||
11 | #include <linux/cdrom.h> | ||
12 | #include <scsi/scsi.h> | ||
13 | |||
14 | #ifndef CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS | ||
15 | void ide_cd_log_error(const char *name, struct request *failed_command, | ||
16 | struct request_sense *sense) | ||
17 | { | ||
18 | /* Suppress printing unit attention and `in progress of becoming ready' | ||
19 | errors when we're not being verbose. */ | ||
20 | if (sense->sense_key == UNIT_ATTENTION || | ||
21 | (sense->sense_key == NOT_READY && (sense->asc == 4 || | ||
22 | sense->asc == 0x3a))) | ||
23 | return; | ||
24 | |||
25 | printk(KERN_ERR "%s: error code: 0x%02x sense_key: 0x%02x " | ||
26 | "asc: 0x%02x ascq: 0x%02x\n", | ||
27 | name, sense->error_code, sense->sense_key, | ||
28 | sense->asc, sense->ascq); | ||
29 | } | ||
30 | #else | ||
31 | /* The generic packet command opcodes for CD/DVD Logical Units, | ||
32 | * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ | ||
33 | static const struct { | ||
34 | unsigned short packet_command; | ||
35 | const char * const text; | ||
36 | } packet_command_texts[] = { | ||
37 | { GPCMD_TEST_UNIT_READY, "Test Unit Ready" }, | ||
38 | { GPCMD_REQUEST_SENSE, "Request Sense" }, | ||
39 | { GPCMD_FORMAT_UNIT, "Format Unit" }, | ||
40 | { GPCMD_INQUIRY, "Inquiry" }, | ||
41 | { GPCMD_START_STOP_UNIT, "Start/Stop Unit" }, | ||
42 | { GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL, "Prevent/Allow Medium Removal" }, | ||
43 | { GPCMD_READ_FORMAT_CAPACITIES, "Read Format Capacities" }, | ||
44 | { GPCMD_READ_CDVD_CAPACITY, "Read Cd/Dvd Capacity" }, | ||
45 | { GPCMD_READ_10, "Read 10" }, | ||
46 | { GPCMD_WRITE_10, "Write 10" }, | ||
47 | { GPCMD_SEEK, "Seek" }, | ||
48 | { GPCMD_WRITE_AND_VERIFY_10, "Write and Verify 10" }, | ||
49 | { GPCMD_VERIFY_10, "Verify 10" }, | ||
50 | { GPCMD_FLUSH_CACHE, "Flush Cache" }, | ||
51 | { GPCMD_READ_SUBCHANNEL, "Read Subchannel" }, | ||
52 | { GPCMD_READ_TOC_PMA_ATIP, "Read Table of Contents" }, | ||
53 | { GPCMD_READ_HEADER, "Read Header" }, | ||
54 | { GPCMD_PLAY_AUDIO_10, "Play Audio 10" }, | ||
55 | { GPCMD_GET_CONFIGURATION, "Get Configuration" }, | ||
56 | { GPCMD_PLAY_AUDIO_MSF, "Play Audio MSF" }, | ||
57 | { GPCMD_PLAYAUDIO_TI, "Play Audio TrackIndex" }, | ||
58 | { GPCMD_GET_EVENT_STATUS_NOTIFICATION, | ||
59 | "Get Event Status Notification" }, | ||
60 | { GPCMD_PAUSE_RESUME, "Pause/Resume" }, | ||
61 | { GPCMD_STOP_PLAY_SCAN, "Stop Play/Scan" }, | ||
62 | { GPCMD_READ_DISC_INFO, "Read Disc Info" }, | ||
63 | { GPCMD_READ_TRACK_RZONE_INFO, "Read Track Rzone Info" }, | ||
64 | { GPCMD_RESERVE_RZONE_TRACK, "Reserve Rzone Track" }, | ||
65 | { GPCMD_SEND_OPC, "Send OPC" }, | ||
66 | { GPCMD_MODE_SELECT_10, "Mode Select 10" }, | ||
67 | { GPCMD_REPAIR_RZONE_TRACK, "Repair Rzone Track" }, | ||
68 | { GPCMD_MODE_SENSE_10, "Mode Sense 10" }, | ||
69 | { GPCMD_CLOSE_TRACK, "Close Track" }, | ||
70 | { GPCMD_BLANK, "Blank" }, | ||
71 | { GPCMD_SEND_EVENT, "Send Event" }, | ||
72 | { GPCMD_SEND_KEY, "Send Key" }, | ||
73 | { GPCMD_REPORT_KEY, "Report Key" }, | ||
74 | { GPCMD_LOAD_UNLOAD, "Load/Unload" }, | ||
75 | { GPCMD_SET_READ_AHEAD, "Set Read-ahead" }, | ||
76 | { GPCMD_READ_12, "Read 12" }, | ||
77 | { GPCMD_GET_PERFORMANCE, "Get Performance" }, | ||
78 | { GPCMD_SEND_DVD_STRUCTURE, "Send DVD Structure" }, | ||
79 | { GPCMD_READ_DVD_STRUCTURE, "Read DVD Structure" }, | ||
80 | { GPCMD_SET_STREAMING, "Set Streaming" }, | ||
81 | { GPCMD_READ_CD_MSF, "Read CD MSF" }, | ||
82 | { GPCMD_SCAN, "Scan" }, | ||
83 | { GPCMD_SET_SPEED, "Set Speed" }, | ||
84 | { GPCMD_PLAY_CD, "Play CD" }, | ||
85 | { GPCMD_MECHANISM_STATUS, "Mechanism Status" }, | ||
86 | { GPCMD_READ_CD, "Read CD" }, | ||
87 | }; | ||
88 | |||
89 | /* From Table 303 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ | ||
90 | static const char * const sense_key_texts[16] = { | ||
91 | "No sense data", | ||
92 | "Recovered error", | ||
93 | "Not ready", | ||
94 | "Medium error", | ||
95 | "Hardware error", | ||
96 | "Illegal request", | ||
97 | "Unit attention", | ||
98 | "Data protect", | ||
99 | "Blank check", | ||
100 | "(reserved)", | ||
101 | "(reserved)", | ||
102 | "Aborted command", | ||
103 | "(reserved)", | ||
104 | "(reserved)", | ||
105 | "Miscompare", | ||
106 | "(reserved)", | ||
107 | }; | ||
108 | |||
109 | /* From Table 304 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ | ||
110 | static const struct { | ||
111 | unsigned long asc_ascq; | ||
112 | const char * const text; | ||
113 | } sense_data_texts[] = { | ||
114 | { 0x000000, "No additional sense information" }, | ||
115 | { 0x000011, "Play operation in progress" }, | ||
116 | { 0x000012, "Play operation paused" }, | ||
117 | { 0x000013, "Play operation successfully completed" }, | ||
118 | { 0x000014, "Play operation stopped due to error" }, | ||
119 | { 0x000015, "No current audio status to return" }, | ||
120 | { 0x010c0a, "Write error - padding blocks added" }, | ||
121 | { 0x011700, "Recovered data with no error correction applied" }, | ||
122 | { 0x011701, "Recovered data with retries" }, | ||
123 | { 0x011702, "Recovered data with positive head offset" }, | ||
124 | { 0x011703, "Recovered data with negative head offset" }, | ||
125 | { 0x011704, "Recovered data with retries and/or CIRC applied" }, | ||
126 | { 0x011705, "Recovered data using previous sector ID" }, | ||
127 | { 0x011800, "Recovered data with error correction applied" }, | ||
128 | { 0x011801, "Recovered data with error correction and retries applied"}, | ||
129 | { 0x011802, "Recovered data - the data was auto-reallocated" }, | ||
130 | { 0x011803, "Recovered data with CIRC" }, | ||
131 | { 0x011804, "Recovered data with L-EC" }, | ||
132 | { 0x015d00, "Failure prediction threshold exceeded" | ||
133 | " - Predicted logical unit failure" }, | ||
134 | { 0x015d01, "Failure prediction threshold exceeded" | ||
135 | " - Predicted media failure" }, | ||
136 | { 0x015dff, "Failure prediction threshold exceeded - False" }, | ||
137 | { 0x017301, "Power calibration area almost full" }, | ||
138 | { 0x020400, "Logical unit not ready - cause not reportable" }, | ||
139 | /* Following is misspelled in ATAPI 2.6, _and_ in Mt. Fuji */ | ||
140 | { 0x020401, "Logical unit not ready" | ||
141 | " - in progress [sic] of becoming ready" }, | ||
142 | { 0x020402, "Logical unit not ready - initializing command required" }, | ||
143 | { 0x020403, "Logical unit not ready - manual intervention required" }, | ||
144 | { 0x020404, "Logical unit not ready - format in progress" }, | ||
145 | { 0x020407, "Logical unit not ready - operation in progress" }, | ||
146 | { 0x020408, "Logical unit not ready - long write in progress" }, | ||
147 | { 0x020600, "No reference position found (media may be upside down)" }, | ||
148 | { 0x023000, "Incompatible medium installed" }, | ||
149 | { 0x023a00, "Medium not present" }, | ||
150 | { 0x025300, "Media load or eject failed" }, | ||
151 | { 0x025700, "Unable to recover table of contents" }, | ||
152 | { 0x030300, "Peripheral device write fault" }, | ||
153 | { 0x030301, "No write current" }, | ||
154 | { 0x030302, "Excessive write errors" }, | ||
155 | { 0x030c00, "Write error" }, | ||
156 | { 0x030c01, "Write error - Recovered with auto reallocation" }, | ||
157 | { 0x030c02, "Write error - auto reallocation failed" }, | ||
158 | { 0x030c03, "Write error - recommend reassignment" }, | ||
159 | { 0x030c04, "Compression check miscompare error" }, | ||
160 | { 0x030c05, "Data expansion occurred during compress" }, | ||
161 | { 0x030c06, "Block not compressible" }, | ||
162 | { 0x030c07, "Write error - recovery needed" }, | ||
163 | { 0x030c08, "Write error - recovery failed" }, | ||
164 | { 0x030c09, "Write error - loss of streaming" }, | ||
165 | { 0x031100, "Unrecovered read error" }, | ||
166 | { 0x031106, "CIRC unrecovered error" }, | ||
167 | { 0x033101, "Format command failed" }, | ||
168 | { 0x033200, "No defect spare location available" }, | ||
169 | { 0x033201, "Defect list update failure" }, | ||
170 | { 0x035100, "Erase failure" }, | ||
171 | { 0x037200, "Session fixation error" }, | ||
172 | { 0x037201, "Session fixation error writin lead-in" }, | ||
173 | { 0x037202, "Session fixation error writin lead-out" }, | ||
174 | { 0x037300, "CD control error" }, | ||
175 | { 0x037302, "Power calibration area is full" }, | ||
176 | { 0x037303, "Power calibration area error" }, | ||
177 | { 0x037304, "Program memory area / RMA update failure" }, | ||
178 | { 0x037305, "Program memory area / RMA is full" }, | ||
179 | { 0x037306, "Program memory area / RMA is (almost) full" }, | ||
180 | { 0x040200, "No seek complete" }, | ||
181 | { 0x040300, "Write fault" }, | ||
182 | { 0x040900, "Track following error" }, | ||
183 | { 0x040901, "Tracking servo failure" }, | ||
184 | { 0x040902, "Focus servo failure" }, | ||
185 | { 0x040903, "Spindle servo failure" }, | ||
186 | { 0x041500, "Random positioning error" }, | ||
187 | { 0x041501, "Mechanical positioning or changer error" }, | ||
188 | { 0x041502, "Positioning error detected by read of medium" }, | ||
189 | { 0x043c00, "Mechanical positioning or changer error" }, | ||
190 | { 0x044000, "Diagnostic failure on component (ASCQ)" }, | ||
191 | { 0x044400, "Internal CD/DVD logical unit failure" }, | ||
192 | { 0x04b600, "Media load mechanism failed" }, | ||
193 | { 0x051a00, "Parameter list length error" }, | ||
194 | { 0x052000, "Invalid command operation code" }, | ||
195 | { 0x052100, "Logical block address out of range" }, | ||
196 | { 0x052102, "Invalid address for write" }, | ||
197 | { 0x052400, "Invalid field in command packet" }, | ||
198 | { 0x052600, "Invalid field in parameter list" }, | ||
199 | { 0x052601, "Parameter not supported" }, | ||
200 | { 0x052602, "Parameter value invalid" }, | ||
201 | { 0x052700, "Write protected media" }, | ||
202 | { 0x052c00, "Command sequence error" }, | ||
203 | { 0x052c03, "Current program area is not empty" }, | ||
204 | { 0x052c04, "Current program area is empty" }, | ||
205 | { 0x053001, "Cannot read medium - unknown format" }, | ||
206 | { 0x053002, "Cannot read medium - incompatible format" }, | ||
207 | { 0x053900, "Saving parameters not supported" }, | ||
208 | { 0x054e00, "Overlapped commands attempted" }, | ||
209 | { 0x055302, "Medium removal prevented" }, | ||
210 | { 0x055500, "System resource failure" }, | ||
211 | { 0x056300, "End of user area encountered on this track" }, | ||
212 | { 0x056400, "Illegal mode for this track or incompatible medium" }, | ||
213 | { 0x056f00, "Copy protection key exchange failure" | ||
214 | " - Authentication failure" }, | ||
215 | { 0x056f01, "Copy protection key exchange failure - Key not present" }, | ||
216 | { 0x056f02, "Copy protection key exchange failure" | ||
217 | " - Key not established" }, | ||
218 | { 0x056f03, "Read of scrambled sector without authentication" }, | ||
219 | { 0x056f04, "Media region code is mismatched to logical unit" }, | ||
220 | { 0x056f05, "Drive region must be permanent" | ||
221 | " / region reset count error" }, | ||
222 | { 0x057203, "Session fixation error - incomplete track in session" }, | ||
223 | { 0x057204, "Empty or partially written reserved track" }, | ||
224 | { 0x057205, "No more RZONE reservations are allowed" }, | ||
225 | { 0x05bf00, "Loss of streaming" }, | ||
226 | { 0x062800, "Not ready to ready transition, medium may have changed" }, | ||
227 | { 0x062900, "Power on, reset or hardware reset occurred" }, | ||
228 | { 0x062a00, "Parameters changed" }, | ||
229 | { 0x062a01, "Mode parameters changed" }, | ||
230 | { 0x062e00, "Insufficient time for operation" }, | ||
231 | { 0x063f00, "Logical unit operating conditions have changed" }, | ||
232 | { 0x063f01, "Microcode has been changed" }, | ||
233 | { 0x065a00, "Operator request or state change input (unspecified)" }, | ||
234 | { 0x065a01, "Operator medium removal request" }, | ||
235 | { 0x0bb900, "Play operation aborted" }, | ||
236 | /* Here we use 0xff for the key (not a valid key) to signify | ||
237 | * that these can have _any_ key value associated with them... */ | ||
238 | { 0xff0401, "Logical unit is in process of becoming ready" }, | ||
239 | { 0xff0400, "Logical unit not ready, cause not reportable" }, | ||
240 | { 0xff0402, "Logical unit not ready, initializing command required" }, | ||
241 | { 0xff0403, "Logical unit not ready, manual intervention required" }, | ||
242 | { 0xff0500, "Logical unit does not respond to selection" }, | ||
243 | { 0xff0800, "Logical unit communication failure" }, | ||
244 | { 0xff0802, "Logical unit communication parity error" }, | ||
245 | { 0xff0801, "Logical unit communication time-out" }, | ||
246 | { 0xff2500, "Logical unit not supported" }, | ||
247 | { 0xff4c00, "Logical unit failed self-configuration" }, | ||
248 | { 0xff3e00, "Logical unit has not self-configured yet" }, | ||
249 | }; | ||
250 | |||
251 | void ide_cd_log_error(const char *name, struct request *failed_command, | ||
252 | struct request_sense *sense) | ||
253 | { | ||
254 | int i; | ||
255 | const char *s = "bad sense key!"; | ||
256 | char buf[80]; | ||
257 | |||
258 | printk(KERN_ERR "ATAPI device %s:\n", name); | ||
259 | if (sense->error_code == 0x70) | ||
260 | printk(KERN_CONT " Error: "); | ||
261 | else if (sense->error_code == 0x71) | ||
262 | printk(" Deferred Error: "); | ||
263 | else if (sense->error_code == 0x7f) | ||
264 | printk(KERN_CONT " Vendor-specific Error: "); | ||
265 | else | ||
266 | printk(KERN_CONT " Unknown Error Type: "); | ||
267 | |||
268 | if (sense->sense_key < ARRAY_SIZE(sense_key_texts)) | ||
269 | s = sense_key_texts[sense->sense_key]; | ||
270 | |||
271 | printk(KERN_CONT "%s -- (Sense key=0x%02x)\n", s, sense->sense_key); | ||
272 | |||
273 | if (sense->asc == 0x40) { | ||
274 | sprintf(buf, "Diagnostic failure on component 0x%02x", | ||
275 | sense->ascq); | ||
276 | s = buf; | ||
277 | } else { | ||
278 | int lo = 0, mid, hi = ARRAY_SIZE(sense_data_texts); | ||
279 | unsigned long key = (sense->sense_key << 16); | ||
280 | |||
281 | key |= (sense->asc << 8); | ||
282 | if (!(sense->ascq >= 0x80 && sense->ascq <= 0xdd)) | ||
283 | key |= sense->ascq; | ||
284 | s = NULL; | ||
285 | |||
286 | while (hi > lo) { | ||
287 | mid = (lo + hi) / 2; | ||
288 | if (sense_data_texts[mid].asc_ascq == key || | ||
289 | sense_data_texts[mid].asc_ascq == (0xff0000|key)) { | ||
290 | s = sense_data_texts[mid].text; | ||
291 | break; | ||
292 | } else if (sense_data_texts[mid].asc_ascq > key) | ||
293 | hi = mid; | ||
294 | else | ||
295 | lo = mid + 1; | ||
296 | } | ||
297 | } | ||
298 | |||
299 | if (s == NULL) { | ||
300 | if (sense->asc > 0x80) | ||
301 | s = "(vendor-specific error)"; | ||
302 | else | ||
303 | s = "(reserved error code)"; | ||
304 | } | ||
305 | |||
306 | printk(KERN_ERR " %s -- (asc=0x%02x, ascq=0x%02x)\n", | ||
307 | s, sense->asc, sense->ascq); | ||
308 | |||
309 | if (failed_command != NULL) { | ||
310 | int lo = 0, mid, hi = ARRAY_SIZE(packet_command_texts); | ||
311 | s = NULL; | ||
312 | |||
313 | while (hi > lo) { | ||
314 | mid = (lo + hi) / 2; | ||
315 | if (packet_command_texts[mid].packet_command == | ||
316 | failed_command->cmd[0]) { | ||
317 | s = packet_command_texts[mid].text; | ||
318 | break; | ||
319 | } | ||
320 | if (packet_command_texts[mid].packet_command > | ||
321 | failed_command->cmd[0]) | ||
322 | hi = mid; | ||
323 | else | ||
324 | lo = mid + 1; | ||
325 | } | ||
326 | |||
327 | printk(KERN_ERR " The failed \"%s\" packet command " | ||
328 | "was: \n \"", s); | ||
329 | for (i = 0; i < sizeof(failed_command->cmd); i++) | ||
330 | printk(KERN_CONT "%02x ", failed_command->cmd[i]); | ||
331 | printk(KERN_CONT "\"\n"); | ||
332 | } | ||
333 | |||
334 | /* The SKSV bit specifies validity of the sense_key_specific | ||
335 | * in the next two commands. It is bit 7 of the first byte. | ||
336 | * In the case of NOT_READY, if SKSV is set the drive can | ||
337 | * give us nice ETA readings. | ||
338 | */ | ||
339 | if (sense->sense_key == NOT_READY && (sense->sks[0] & 0x80)) { | ||
340 | int progress = (sense->sks[1] << 8 | sense->sks[2]) * 100; | ||
341 | |||
342 | printk(KERN_ERR " Command is %02d%% complete\n", | ||
343 | progress / 0xffff); | ||
344 | } | ||
345 | |||
346 | if (sense->sense_key == ILLEGAL_REQUEST && | ||
347 | (sense->sks[0] & 0x80) != 0) { | ||
348 | printk(KERN_ERR " Error in %s byte %d", | ||
349 | (sense->sks[0] & 0x40) != 0 ? | ||
350 | "command packet" : "command data", | ||
351 | (sense->sks[1] << 8) + sense->sks[2]); | ||
352 | |||
353 | if ((sense->sks[0] & 0x40) != 0) | ||
354 | printk(KERN_CONT " bit %d", sense->sks[0] & 0x07); | ||
355 | |||
356 | printk(KERN_CONT "\n"); | ||
357 | } | ||
358 | } | ||
359 | #endif | ||
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 717e114ced52..3c69822507e2 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -1,10 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/ide-disk.c Version 1.18 Mar 05, 2003 | 2 | * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) |
3 | * | 3 | * Copyright (C) 1998-2002 Linux ATA Development |
4 | * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) | 4 | * Andre Hedrick <andre@linux-ide.org> |
5 | * Copyright (C) 1998-2002 Linux ATA Development | 5 | * Copyright (C) 2003 Red Hat <alan@redhat.com> |
6 | * Andre Hedrick <andre@linux-ide.org> | 6 | * Copyright (C) 2003-2005, 2007 Bartlomiej Zolnierkiewicz |
7 | * Copyright (C) 2003 Red Hat <alan@redhat.com> | ||
8 | */ | 7 | */ |
9 | 8 | ||
10 | /* | 9 | /* |
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 5bf32038dc43..7beaf1e9be12 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -1,15 +1,13 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/ide-dma.c Version 4.10 June 9, 2000 | 2 | * Copyright (C) 1995-1998 Mark Lord |
3 | * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> | ||
4 | * Copyright (C) 2004, 2007 Bartlomiej Zolnierkiewicz | ||
3 | * | 5 | * |
4 | * Copyright (c) 1999-2000 Andre Hedrick <andre@linux-ide.org> | ||
5 | * May be copied or modified under the terms of the GNU General Public License | 6 | * May be copied or modified under the terms of the GNU General Public License |
6 | */ | 7 | */ |
7 | 8 | ||
8 | /* | 9 | /* |
9 | * Special Thanks to Mark for his Six years of work. | 10 | * Special Thanks to Mark for his Six years of work. |
10 | * | ||
11 | * Copyright (c) 1995-1998 Mark Lord | ||
12 | * May be copied or modified under the terms of the GNU General Public License | ||
13 | */ | 11 | */ |
14 | 12 | ||
15 | /* | 13 | /* |
@@ -85,6 +83,7 @@ | |||
85 | #include <linux/ide.h> | 83 | #include <linux/ide.h> |
86 | #include <linux/delay.h> | 84 | #include <linux/delay.h> |
87 | #include <linux/scatterlist.h> | 85 | #include <linux/scatterlist.h> |
86 | #include <linux/dma-mapping.h> | ||
88 | 87 | ||
89 | #include <asm/io.h> | 88 | #include <asm/io.h> |
90 | #include <asm/irq.h> | 89 | #include <asm/irq.h> |
@@ -169,16 +168,15 @@ static int ide_dma_good_drive(ide_drive_t *drive) | |||
169 | return ide_in_drive_list(drive->id, drive_whitelist); | 168 | return ide_in_drive_list(drive->id, drive_whitelist); |
170 | } | 169 | } |
171 | 170 | ||
172 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | ||
173 | /** | 171 | /** |
174 | * ide_build_sglist - map IDE scatter gather for DMA I/O | 172 | * ide_build_sglist - map IDE scatter gather for DMA I/O |
175 | * @drive: the drive to build the DMA table for | 173 | * @drive: the drive to build the DMA table for |
176 | * @rq: the request holding the sg list | 174 | * @rq: the request holding the sg list |
177 | * | 175 | * |
178 | * Perform the PCI mapping magic necessary to access the source or | 176 | * Perform the DMA mapping magic necessary to access the source or |
179 | * target buffers of a request via PCI DMA. The lower layers of the | 177 | * target buffers of a request via DMA. The lower layers of the |
180 | * kernel provide the necessary cache management so that we can | 178 | * kernel provide the necessary cache management so that we can |
181 | * operate in a portable fashion | 179 | * operate in a portable fashion. |
182 | */ | 180 | */ |
183 | 181 | ||
184 | int ide_build_sglist(ide_drive_t *drive, struct request *rq) | 182 | int ide_build_sglist(ide_drive_t *drive, struct request *rq) |
@@ -186,20 +184,20 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq) | |||
186 | ide_hwif_t *hwif = HWIF(drive); | 184 | ide_hwif_t *hwif = HWIF(drive); |
187 | struct scatterlist *sg = hwif->sg_table; | 185 | struct scatterlist *sg = hwif->sg_table; |
188 | 186 | ||
189 | BUG_ON((rq->cmd_type == REQ_TYPE_ATA_TASKFILE) && rq->nr_sectors > 256); | ||
190 | |||
191 | ide_map_sg(drive, rq); | 187 | ide_map_sg(drive, rq); |
192 | 188 | ||
193 | if (rq_data_dir(rq) == READ) | 189 | if (rq_data_dir(rq) == READ) |
194 | hwif->sg_dma_direction = PCI_DMA_FROMDEVICE; | 190 | hwif->sg_dma_direction = DMA_FROM_DEVICE; |
195 | else | 191 | else |
196 | hwif->sg_dma_direction = PCI_DMA_TODEVICE; | 192 | hwif->sg_dma_direction = DMA_TO_DEVICE; |
197 | 193 | ||
198 | return pci_map_sg(hwif->pci_dev, sg, hwif->sg_nents, hwif->sg_dma_direction); | 194 | return dma_map_sg(hwif->dev, sg, hwif->sg_nents, |
195 | hwif->sg_dma_direction); | ||
199 | } | 196 | } |
200 | 197 | ||
201 | EXPORT_SYMBOL_GPL(ide_build_sglist); | 198 | EXPORT_SYMBOL_GPL(ide_build_sglist); |
202 | 199 | ||
200 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | ||
203 | /** | 201 | /** |
204 | * ide_build_dmatable - build IDE DMA table | 202 | * ide_build_dmatable - build IDE DMA table |
205 | * | 203 | * |
@@ -284,16 +282,17 @@ int ide_build_dmatable (ide_drive_t *drive, struct request *rq) | |||
284 | *--table |= cpu_to_le32(0x80000000); | 282 | *--table |= cpu_to_le32(0x80000000); |
285 | return count; | 283 | return count; |
286 | } | 284 | } |
285 | |||
287 | printk(KERN_ERR "%s: empty DMA table?\n", drive->name); | 286 | printk(KERN_ERR "%s: empty DMA table?\n", drive->name); |
287 | |||
288 | use_pio_instead: | 288 | use_pio_instead: |
289 | pci_unmap_sg(hwif->pci_dev, | 289 | ide_destroy_dmatable(drive); |
290 | hwif->sg_table, | 290 | |
291 | hwif->sg_nents, | ||
292 | hwif->sg_dma_direction); | ||
293 | return 0; /* revert to PIO for this request */ | 291 | return 0; /* revert to PIO for this request */ |
294 | } | 292 | } |
295 | 293 | ||
296 | EXPORT_SYMBOL_GPL(ide_build_dmatable); | 294 | EXPORT_SYMBOL_GPL(ide_build_dmatable); |
295 | #endif | ||
297 | 296 | ||
298 | /** | 297 | /** |
299 | * ide_destroy_dmatable - clean up DMA mapping | 298 | * ide_destroy_dmatable - clean up DMA mapping |
@@ -308,15 +307,15 @@ EXPORT_SYMBOL_GPL(ide_build_dmatable); | |||
308 | 307 | ||
309 | void ide_destroy_dmatable (ide_drive_t *drive) | 308 | void ide_destroy_dmatable (ide_drive_t *drive) |
310 | { | 309 | { |
311 | struct pci_dev *dev = HWIF(drive)->pci_dev; | 310 | ide_hwif_t *hwif = drive->hwif; |
312 | struct scatterlist *sg = HWIF(drive)->sg_table; | ||
313 | int nents = HWIF(drive)->sg_nents; | ||
314 | 311 | ||
315 | pci_unmap_sg(dev, sg, nents, HWIF(drive)->sg_dma_direction); | 312 | dma_unmap_sg(hwif->dev, hwif->sg_table, hwif->sg_nents, |
313 | hwif->sg_dma_direction); | ||
316 | } | 314 | } |
317 | 315 | ||
318 | EXPORT_SYMBOL_GPL(ide_destroy_dmatable); | 316 | EXPORT_SYMBOL_GPL(ide_destroy_dmatable); |
319 | 317 | ||
318 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | ||
320 | /** | 319 | /** |
321 | * config_drive_for_dma - attempt to activate IDE DMA | 320 | * config_drive_for_dma - attempt to activate IDE DMA |
322 | * @drive: the drive to place in DMA mode | 321 | * @drive: the drive to place in DMA mode |
@@ -474,8 +473,6 @@ void ide_dma_on(ide_drive_t *drive) | |||
474 | drive->hwif->dma_host_set(drive, 1); | 473 | drive->hwif->dma_host_set(drive, 1); |
475 | } | 474 | } |
476 | 475 | ||
477 | EXPORT_SYMBOL(ide_dma_on); | ||
478 | |||
479 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 476 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
480 | /** | 477 | /** |
481 | * ide_dma_setup - begin a DMA phase | 478 | * ide_dma_setup - begin a DMA phase |
@@ -847,10 +844,10 @@ EXPORT_SYMBOL(ide_dma_timeout); | |||
847 | static void ide_release_dma_engine(ide_hwif_t *hwif) | 844 | static void ide_release_dma_engine(ide_hwif_t *hwif) |
848 | { | 845 | { |
849 | if (hwif->dmatable_cpu) { | 846 | if (hwif->dmatable_cpu) { |
850 | pci_free_consistent(hwif->pci_dev, | 847 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
851 | PRD_ENTRIES * PRD_BYTES, | 848 | |
852 | hwif->dmatable_cpu, | 849 | pci_free_consistent(pdev, PRD_ENTRIES * PRD_BYTES, |
853 | hwif->dmatable_dma); | 850 | hwif->dmatable_cpu, hwif->dmatable_dma); |
854 | hwif->dmatable_cpu = NULL; | 851 | hwif->dmatable_cpu = NULL; |
855 | } | 852 | } |
856 | } | 853 | } |
@@ -878,7 +875,9 @@ int ide_release_dma(ide_hwif_t *hwif) | |||
878 | 875 | ||
879 | static int ide_allocate_dma_engine(ide_hwif_t *hwif) | 876 | static int ide_allocate_dma_engine(ide_hwif_t *hwif) |
880 | { | 877 | { |
881 | hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev, | 878 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
879 | |||
880 | hwif->dmatable_cpu = pci_alloc_consistent(pdev, | ||
882 | PRD_ENTRIES * PRD_BYTES, | 881 | PRD_ENTRIES * PRD_BYTES, |
883 | &hwif->dmatable_dma); | 882 | &hwif->dmatable_dma); |
884 | 883 | ||
@@ -891,19 +890,19 @@ static int ide_allocate_dma_engine(ide_hwif_t *hwif) | |||
891 | return 1; | 890 | return 1; |
892 | } | 891 | } |
893 | 892 | ||
894 | static int ide_mapped_mmio_dma(ide_hwif_t *hwif, unsigned long base, unsigned int ports) | 893 | static int ide_mapped_mmio_dma(ide_hwif_t *hwif, unsigned long base) |
895 | { | 894 | { |
896 | printk(KERN_INFO " %s: MMIO-DMA ", hwif->name); | 895 | printk(KERN_INFO " %s: MMIO-DMA ", hwif->name); |
897 | 896 | ||
898 | return 0; | 897 | return 0; |
899 | } | 898 | } |
900 | 899 | ||
901 | static int ide_iomio_dma(ide_hwif_t *hwif, unsigned long base, unsigned int ports) | 900 | static int ide_iomio_dma(ide_hwif_t *hwif, unsigned long base) |
902 | { | 901 | { |
903 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx", | 902 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx", |
904 | hwif->name, base, base + ports - 1); | 903 | hwif->name, base, base + 7); |
905 | 904 | ||
906 | if (!request_region(base, ports, hwif->name)) { | 905 | if (!request_region(base, 8, hwif->name)) { |
907 | printk(" -- Error, ports in use.\n"); | 906 | printk(" -- Error, ports in use.\n"); |
908 | return 1; | 907 | return 1; |
909 | } | 908 | } |
@@ -915,7 +914,7 @@ static int ide_iomio_dma(ide_hwif_t *hwif, unsigned long base, unsigned int port | |||
915 | if (!request_region(hwif->extra_base, | 914 | if (!request_region(hwif->extra_base, |
916 | hwif->cds->extra, hwif->cds->name)) { | 915 | hwif->cds->extra, hwif->cds->name)) { |
917 | printk(" -- Error, extra ports in use.\n"); | 916 | printk(" -- Error, extra ports in use.\n"); |
918 | release_region(base, ports); | 917 | release_region(base, 8); |
919 | return 1; | 918 | return 1; |
920 | } | 919 | } |
921 | hwif->extra_ports = hwif->cds->extra; | 920 | hwif->extra_ports = hwif->cds->extra; |
@@ -925,17 +924,19 @@ static int ide_iomio_dma(ide_hwif_t *hwif, unsigned long base, unsigned int port | |||
925 | return 0; | 924 | return 0; |
926 | } | 925 | } |
927 | 926 | ||
928 | static int ide_dma_iobase(ide_hwif_t *hwif, unsigned long base, unsigned int ports) | 927 | static int ide_dma_iobase(ide_hwif_t *hwif, unsigned long base) |
929 | { | 928 | { |
930 | if (hwif->mmio) | 929 | if (hwif->mmio) |
931 | return ide_mapped_mmio_dma(hwif, base,ports); | 930 | return ide_mapped_mmio_dma(hwif, base); |
932 | 931 | ||
933 | return ide_iomio_dma(hwif, base, ports); | 932 | return ide_iomio_dma(hwif, base); |
934 | } | 933 | } |
935 | 934 | ||
936 | void ide_setup_dma(ide_hwif_t *hwif, unsigned long base, unsigned num_ports) | 935 | void ide_setup_dma(ide_hwif_t *hwif, unsigned long base) |
937 | { | 936 | { |
938 | if (ide_dma_iobase(hwif, base, num_ports)) | 937 | u8 dma_stat; |
938 | |||
939 | if (ide_dma_iobase(hwif, base)) | ||
939 | return; | 940 | return; |
940 | 941 | ||
941 | if (ide_allocate_dma_engine(hwif)) { | 942 | if (ide_allocate_dma_engine(hwif)) { |
@@ -945,16 +946,16 @@ void ide_setup_dma(ide_hwif_t *hwif, unsigned long base, unsigned num_ports) | |||
945 | 946 | ||
946 | hwif->dma_base = base; | 947 | hwif->dma_base = base; |
947 | 948 | ||
948 | if (!(hwif->dma_command)) | 949 | if (!hwif->dma_command) |
949 | hwif->dma_command = hwif->dma_base; | 950 | hwif->dma_command = hwif->dma_base + 0; |
950 | if (!(hwif->dma_vendor1)) | 951 | if (!hwif->dma_vendor1) |
951 | hwif->dma_vendor1 = (hwif->dma_base + 1); | 952 | hwif->dma_vendor1 = hwif->dma_base + 1; |
952 | if (!(hwif->dma_status)) | 953 | if (!hwif->dma_status) |
953 | hwif->dma_status = (hwif->dma_base + 2); | 954 | hwif->dma_status = hwif->dma_base + 2; |
954 | if (!(hwif->dma_vendor3)) | 955 | if (!hwif->dma_vendor3) |
955 | hwif->dma_vendor3 = (hwif->dma_base + 3); | 956 | hwif->dma_vendor3 = hwif->dma_base + 3; |
956 | if (!(hwif->dma_prdtable)) | 957 | if (!hwif->dma_prdtable) |
957 | hwif->dma_prdtable = (hwif->dma_base + 4); | 958 | hwif->dma_prdtable = hwif->dma_base + 4; |
958 | 959 | ||
959 | if (!hwif->dma_host_set) | 960 | if (!hwif->dma_host_set) |
960 | hwif->dma_host_set = &ide_dma_host_set; | 961 | hwif->dma_host_set = &ide_dma_host_set; |
@@ -973,13 +974,10 @@ void ide_setup_dma(ide_hwif_t *hwif, unsigned long base, unsigned num_ports) | |||
973 | if (!hwif->dma_lost_irq) | 974 | if (!hwif->dma_lost_irq) |
974 | hwif->dma_lost_irq = &ide_dma_lost_irq; | 975 | hwif->dma_lost_irq = &ide_dma_lost_irq; |
975 | 976 | ||
976 | if (hwif->chipset != ide_trm290) { | 977 | dma_stat = hwif->INB(hwif->dma_status); |
977 | u8 dma_stat = hwif->INB(hwif->dma_status); | 978 | printk(KERN_CONT ", BIOS settings: %s:%s, %s:%s\n", |
978 | printk(", BIOS settings: %s:%s, %s:%s", | 979 | hwif->drives[0].name, (dma_stat & 0x20) ? "DMA" : "PIO", |
979 | hwif->drives[0].name, (dma_stat & 0x20) ? "DMA" : "pio", | 980 | hwif->drives[1].name, (dma_stat & 0x40) ? "DMA" : "PIO"); |
980 | hwif->drives[1].name, (dma_stat & 0x40) ? "DMA" : "pio"); | ||
981 | } | ||
982 | printk("\n"); | ||
983 | } | 981 | } |
984 | 982 | ||
985 | EXPORT_SYMBOL_GPL(ide_setup_dma); | 983 | EXPORT_SYMBOL_GPL(ide_setup_dma); |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index ff8232ef9659..3512637ae8d4 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -1,13 +1,12 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/ide-floppy.c Version 0.99 Feb 24 2002 | 2 | * IDE ATAPI floppy driver. |
3 | * | 3 | * |
4 | * Copyright (C) 1996 - 1999 Gadi Oxman <gadio@netvision.net.il> | 4 | * Copyright (C) 1996-1999 Gadi Oxman <gadio@netvision.net.il> |
5 | * Copyright (C) 2000 - 2002 Paul Bristow <paul@paulbristow.net> | 5 | * Copyright (C) 2000-2002 Paul Bristow <paul@paulbristow.net> |
6 | * Copyright (C) 2005 Bartlomiej Zolnierkiewicz | ||
6 | */ | 7 | */ |
7 | 8 | ||
8 | /* | 9 | /* |
9 | * IDE ATAPI floppy driver. | ||
10 | * | ||
11 | * The driver currently doesn't have any fancy features, just the bare | 10 | * The driver currently doesn't have any fancy features, just the bare |
12 | * minimum read/write support. | 11 | * minimum read/write support. |
13 | * | 12 | * |
@@ -17,67 +16,8 @@ | |||
17 | * Iomega Zip 100/250 | 16 | * Iomega Zip 100/250 |
18 | * Iomega PC Card Clik!/PocketZip | 17 | * Iomega PC Card Clik!/PocketZip |
19 | * | 18 | * |
20 | * Many thanks to Lode Leroy <Lode.Leroy@www.ibase.be>, who tested so many | 19 | * For a historical changelog see |
21 | * ALPHA patches to this driver on an EASYSTOR LS-120 ATAPI floppy drive. | 20 | * Documentation/ide/ChangeLog.ide-floppy.1996-2002 |
22 | * | ||
23 | * Ver 0.1 Oct 17 96 Initial test version, mostly based on ide-tape.c. | ||
24 | * Ver 0.2 Oct 31 96 Minor changes. | ||
25 | * Ver 0.3 Dec 2 96 Fixed error recovery bug. | ||
26 | * Ver 0.4 Jan 26 97 Add support for the HDIO_GETGEO ioctl. | ||
27 | * Ver 0.5 Feb 21 97 Add partitions support. | ||
28 | * Use the minimum of the LBA and CHS capacities. | ||
29 | * Avoid hwgroup->rq == NULL on the last irq. | ||
30 | * Fix potential null dereferencing with DEBUG_LOG. | ||
31 | * Ver 0.8 Dec 7 97 Increase irq timeout from 10 to 50 seconds. | ||
32 | * Add media write-protect detection. | ||
33 | * Issue START command only if TEST UNIT READY fails. | ||
34 | * Add work-around for IOMEGA ZIP revision 21.D. | ||
35 | * Remove idefloppy_get_capabilities(). | ||
36 | * Ver 0.9 Jul 4 99 Fix a bug which might have caused the number of | ||
37 | * bytes requested on each interrupt to be zero. | ||
38 | * Thanks to <shanos@es.co.nz> for pointing this out. | ||
39 | * Ver 0.9.sv Jan 6 01 Sam Varshavchik <mrsam@courier-mta.com> | ||
40 | * Implement low level formatting. Reimplemented | ||
41 | * IDEFLOPPY_CAPABILITIES_PAGE, since we need the srfp | ||
42 | * bit. My LS-120 drive barfs on | ||
43 | * IDEFLOPPY_CAPABILITIES_PAGE, but maybe it's just me. | ||
44 | * Compromise by not reporting a failure to get this | ||
45 | * mode page. Implemented four IOCTLs in order to | ||
46 | * implement formatting. IOCTls begin with 0x4600, | ||
47 | * 0x46 is 'F' as in Format. | ||
48 | * Jan 9 01 Userland option to select format verify. | ||
49 | * Added PC_SUPPRESS_ERROR flag - some idefloppy drives | ||
50 | * do not implement IDEFLOPPY_CAPABILITIES_PAGE, and | ||
51 | * return a sense error. Suppress error reporting in | ||
52 | * this particular case in order to avoid spurious | ||
53 | * errors in syslog. The culprit is | ||
54 | * idefloppy_get_capability_page(), so move it to | ||
55 | * idefloppy_begin_format() so that it's not used | ||
56 | * unless absolutely necessary. | ||
57 | * If drive does not support format progress indication | ||
58 | * monitor the dsc bit in the status register. | ||
59 | * Also, O_NDELAY on open will allow the device to be | ||
60 | * opened without a disk available. This can be used to | ||
61 | * open an unformatted disk, or get the device capacity. | ||
62 | * Ver 0.91 Dec 11 99 Added IOMEGA Clik! drive support by | ||
63 | * <paul@paulbristow.net> | ||
64 | * Ver 0.92 Oct 22 00 Paul Bristow became official maintainer for this | ||
65 | * driver. Included Powerbook internal zip kludge. | ||
66 | * Ver 0.93 Oct 24 00 Fixed bugs for Clik! drive | ||
67 | * no disk on insert and disk change now works | ||
68 | * Ver 0.94 Oct 27 00 Tidied up to remove strstr(Clik) everywhere | ||
69 | * Ver 0.95 Nov 7 00 Brought across to kernel 2.4 | ||
70 | * Ver 0.96 Jan 7 01 Actually in line with release version of 2.4.0 | ||
71 | * including set_bit patch from Rusty Russell | ||
72 | * Ver 0.97 Jul 22 01 Merge 0.91-0.96 onto 0.9.sv for ac series | ||
73 | * Ver 0.97.sv Aug 3 01 Backported from 2.4.7-ac3 | ||
74 | * Ver 0.98 Oct 26 01 Split idefloppy_transfer_pc into two pieces to | ||
75 | * fix a lost interrupt problem. It appears the busy | ||
76 | * bit was being deasserted by my IOMEGA ATAPI ZIP 100 | ||
77 | * drive before the drive was actually ready. | ||
78 | * Ver 0.98a Oct 29 01 Expose delay value so we can play. | ||
79 | * Ver 0.99 Feb 24 02 Remove duplicate code, modify clik! detection code | ||
80 | * to support new PocketZip drives | ||
81 | */ | 21 | */ |
82 | 22 | ||
83 | #define IDEFLOPPY_VERSION "0.99.newide" | 23 | #define IDEFLOPPY_VERSION "0.99.newide" |
@@ -1658,7 +1598,6 @@ static int idefloppy_identify_device (ide_drive_t *drive,struct hd_driveid *id) | |||
1658 | { | 1598 | { |
1659 | struct idefloppy_id_gcw gcw; | 1599 | struct idefloppy_id_gcw gcw; |
1660 | #if IDEFLOPPY_DEBUG_INFO | 1600 | #if IDEFLOPPY_DEBUG_INFO |
1661 | u16 mask,i; | ||
1662 | char buffer[80]; | 1601 | char buffer[80]; |
1663 | #endif /* IDEFLOPPY_DEBUG_INFO */ | 1602 | #endif /* IDEFLOPPY_DEBUG_INFO */ |
1664 | 1603 | ||
@@ -1705,55 +1644,6 @@ static int idefloppy_identify_device (ide_drive_t *drive,struct hd_driveid *id) | |||
1705 | default: sprintf(buffer, "Reserved");break; | 1644 | default: sprintf(buffer, "Reserved");break; |
1706 | } | 1645 | } |
1707 | printk(KERN_INFO "Command Packet Size: %s\n", buffer); | 1646 | printk(KERN_INFO "Command Packet Size: %s\n", buffer); |
1708 | printk(KERN_INFO "Model: %.40s\n",id->model); | ||
1709 | printk(KERN_INFO "Firmware Revision: %.8s\n",id->fw_rev); | ||
1710 | printk(KERN_INFO "Serial Number: %.20s\n",id->serial_no); | ||
1711 | printk(KERN_INFO "Write buffer size(?): %d bytes\n",id->buf_size*512); | ||
1712 | printk(KERN_INFO "DMA: %s",id->capability & 0x01 ? "Yes\n":"No\n"); | ||
1713 | printk(KERN_INFO "LBA: %s",id->capability & 0x02 ? "Yes\n":"No\n"); | ||
1714 | printk(KERN_INFO "IORDY can be disabled: %s",id->capability & 0x04 ? "Yes\n":"No\n"); | ||
1715 | printk(KERN_INFO "IORDY supported: %s",id->capability & 0x08 ? "Yes\n":"Unknown\n"); | ||
1716 | printk(KERN_INFO "ATAPI overlap supported: %s",id->capability & 0x20 ? "Yes\n":"No\n"); | ||
1717 | printk(KERN_INFO "PIO Cycle Timing Category: %d\n",id->tPIO); | ||
1718 | printk(KERN_INFO "DMA Cycle Timing Category: %d\n",id->tDMA); | ||
1719 | printk(KERN_INFO "Single Word DMA supported modes:\n"); | ||
1720 | for (i=0,mask=1;i<8;i++,mask=mask << 1) { | ||
1721 | if (id->dma_1word & mask) | ||
1722 | printk(KERN_INFO " Mode %d%s\n", i, | ||
1723 | (id->dma_1word & (mask << 8)) ? " (active)" : ""); | ||
1724 | } | ||
1725 | printk(KERN_INFO "Multi Word DMA supported modes:\n"); | ||
1726 | for (i=0,mask=1;i<8;i++,mask=mask << 1) { | ||
1727 | if (id->dma_mword & mask) | ||
1728 | printk(KERN_INFO " Mode %d%s\n", i, | ||
1729 | (id->dma_mword & (mask << 8)) ? " (active)" : ""); | ||
1730 | } | ||
1731 | if (id->field_valid & 0x0002) { | ||
1732 | printk(KERN_INFO "Enhanced PIO Modes: %s\n", | ||
1733 | id->eide_pio_modes & 1 ? "Mode 3":"None"); | ||
1734 | if (id->eide_dma_min == 0) | ||
1735 | sprintf(buffer, "Not supported"); | ||
1736 | else | ||
1737 | sprintf(buffer, "%d ns",id->eide_dma_min); | ||
1738 | printk(KERN_INFO "Minimum Multi-word DMA cycle per word: %s\n", buffer); | ||
1739 | if (id->eide_dma_time == 0) | ||
1740 | sprintf(buffer, "Not supported"); | ||
1741 | else | ||
1742 | sprintf(buffer, "%d ns",id->eide_dma_time); | ||
1743 | printk(KERN_INFO "Manufacturer\'s Recommended Multi-word cycle: %s\n", buffer); | ||
1744 | if (id->eide_pio == 0) | ||
1745 | sprintf(buffer, "Not supported"); | ||
1746 | else | ||
1747 | sprintf(buffer, "%d ns",id->eide_pio); | ||
1748 | printk(KERN_INFO "Minimum PIO cycle without IORDY: %s\n", | ||
1749 | buffer); | ||
1750 | if (id->eide_pio_iordy == 0) | ||
1751 | sprintf(buffer, "Not supported"); | ||
1752 | else | ||
1753 | sprintf(buffer, "%d ns",id->eide_pio_iordy); | ||
1754 | printk(KERN_INFO "Minimum PIO cycle with IORDY: %s\n", buffer); | ||
1755 | } else | ||
1756 | printk(KERN_INFO "According to the device, fields 64-70 are not valid.\n"); | ||
1757 | #endif /* IDEFLOPPY_DEBUG_INFO */ | 1647 | #endif /* IDEFLOPPY_DEBUG_INFO */ |
1758 | 1648 | ||
1759 | if (gcw.protocol != 2) | 1649 | if (gcw.protocol != 2) |
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index e6bb9cf24e3d..4bddef0c0b96 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -1487,7 +1487,7 @@ irqreturn_t ide_intr (int irq, void *dev_id) | |||
1487 | * remove all the ifdef PCI crap | 1487 | * remove all the ifdef PCI crap |
1488 | */ | 1488 | */ |
1489 | #ifdef CONFIG_BLK_DEV_IDEPCI | 1489 | #ifdef CONFIG_BLK_DEV_IDEPCI |
1490 | if (hwif->pci_dev && !hwif->pci_dev->vendor) | 1490 | if (hwif->chipset != ide_pci) |
1491 | #endif /* CONFIG_BLK_DEV_IDEPCI */ | 1491 | #endif /* CONFIG_BLK_DEV_IDEPCI */ |
1492 | { | 1492 | { |
1493 | /* | 1493 | /* |
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index e2a7e95e1636..16b1f6e12781 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/ide-iops.c Version 0.37 Mar 05, 2003 | ||
3 | * | ||
4 | * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> | 2 | * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> |
5 | * Copyright (C) 2003 Red Hat <alan@redhat.com> | 3 | * Copyright (C) 2003 Red Hat <alan@redhat.com> |
6 | * | 4 | * |
@@ -1168,7 +1166,7 @@ EXPORT_SYMBOL(ide_do_reset); | |||
1168 | 1166 | ||
1169 | /* | 1167 | /* |
1170 | * ide_wait_not_busy() waits for the currently selected device on the hwif | 1168 | * ide_wait_not_busy() waits for the currently selected device on the hwif |
1171 | * to report a non-busy status, see comments in probe_hwif(). | 1169 | * to report a non-busy status, see comments in ide_probe_port(). |
1172 | */ | 1170 | */ |
1173 | int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout) | 1171 | int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout) |
1174 | { | 1172 | { |
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 9b44fbdfe41f..b42940d8bf70 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c | |||
@@ -358,8 +358,10 @@ void ide_toggle_bounce(ide_drive_t *drive, int on) | |||
358 | if (!PCI_DMA_BUS_IS_PHYS) { | 358 | if (!PCI_DMA_BUS_IS_PHYS) { |
359 | addr = BLK_BOUNCE_ANY; | 359 | addr = BLK_BOUNCE_ANY; |
360 | } else if (on && drive->media == ide_disk) { | 360 | } else if (on && drive->media == ide_disk) { |
361 | if (HWIF(drive)->pci_dev) | 361 | struct device *dev = drive->hwif->dev; |
362 | addr = HWIF(drive)->pci_dev->dma_mask; | 362 | |
363 | if (dev && dev->dma_mask) | ||
364 | addr = *dev->dma_mask; | ||
363 | } | 365 | } |
364 | 366 | ||
365 | if (drive->queue) | 367 | if (drive->queue) |
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c index cbbb0f75be92..4bda5cf2be37 100644 --- a/drivers/ide/ide-pnp.c +++ b/drivers/ide/ide-pnp.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/ide-pnp.c | ||
3 | * | ||
4 | * This file provides autodetection for ISA PnP IDE interfaces. | 2 | * This file provides autodetection for ISA PnP IDE interfaces. |
5 | * It was tested with "ESS ES1868 Plug and Play AudioDrive" IDE interface. | 3 | * It was tested with "ESS ES1868 Plug and Play AudioDrive" IDE interface. |
6 | * | 4 | * |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index edf650b20c67..98a8af44bf64 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/ide-probe.c Version 1.11 Mar 05, 2003 | 2 | * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) |
3 | * | 3 | * Copyright (C) 2005, 2007 Bartlomiej Zolnierkiewicz |
4 | * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) | ||
5 | */ | 4 | */ |
6 | 5 | ||
7 | /* | 6 | /* |
@@ -129,6 +128,10 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
129 | 128 | ||
130 | drive->id_read = 1; | 129 | drive->id_read = 1; |
131 | local_irq_enable(); | 130 | local_irq_enable(); |
131 | #ifdef DEBUG | ||
132 | printk(KERN_INFO "%s: dumping identify data\n", drive->name); | ||
133 | ide_dump_identify((u8 *)id); | ||
134 | #endif | ||
132 | ide_fix_driveid(id); | 135 | ide_fix_driveid(id); |
133 | 136 | ||
134 | #if defined (CONFIG_SCSI_EATA_PIO) || defined (CONFIG_SCSI_EATA) | 137 | #if defined (CONFIG_SCSI_EATA_PIO) || defined (CONFIG_SCSI_EATA) |
@@ -610,7 +613,7 @@ static void hwif_release_dev (struct device *dev) | |||
610 | complete(&hwif->gendev_rel_comp); | 613 | complete(&hwif->gendev_rel_comp); |
611 | } | 614 | } |
612 | 615 | ||
613 | static void hwif_register (ide_hwif_t *hwif) | 616 | static void ide_register_port(ide_hwif_t *hwif) |
614 | { | 617 | { |
615 | int ret; | 618 | int ret; |
616 | 619 | ||
@@ -618,8 +621,8 @@ static void hwif_register (ide_hwif_t *hwif) | |||
618 | strlcpy(hwif->gendev.bus_id,hwif->name,BUS_ID_SIZE); | 621 | strlcpy(hwif->gendev.bus_id,hwif->name,BUS_ID_SIZE); |
619 | hwif->gendev.driver_data = hwif; | 622 | hwif->gendev.driver_data = hwif; |
620 | if (hwif->gendev.parent == NULL) { | 623 | if (hwif->gendev.parent == NULL) { |
621 | if (hwif->pci_dev) | 624 | if (hwif->dev) |
622 | hwif->gendev.parent = &hwif->pci_dev->dev; | 625 | hwif->gendev.parent = hwif->dev; |
623 | else | 626 | else |
624 | /* Would like to do = &device_legacy */ | 627 | /* Would like to do = &device_legacy */ |
625 | hwif->gendev.parent = NULL; | 628 | hwif->gendev.parent = NULL; |
@@ -631,7 +634,33 @@ static void hwif_register (ide_hwif_t *hwif) | |||
631 | __FUNCTION__, ret); | 634 | __FUNCTION__, ret); |
632 | } | 635 | } |
633 | 636 | ||
634 | static int wait_hwif_ready(ide_hwif_t *hwif) | 637 | /** |
638 | * ide_port_wait_ready - wait for port to become ready | ||
639 | * @hwif: IDE port | ||
640 | * | ||
641 | * This is needed on some PPCs and a bunch of BIOS-less embedded | ||
642 | * platforms. Typical cases are: | ||
643 | * | ||
644 | * - The firmware hard reset the disk before booting the kernel, | ||
645 | * the drive is still doing it's poweron-reset sequence, that | ||
646 | * can take up to 30 seconds. | ||
647 | * | ||
648 | * - The firmware does nothing (or no firmware), the device is | ||
649 | * still in POST state (same as above actually). | ||
650 | * | ||
651 | * - Some CD/DVD/Writer combo drives tend to drive the bus during | ||
652 | * their reset sequence even when they are non-selected slave | ||
653 | * devices, thus preventing discovery of the main HD. | ||
654 | * | ||
655 | * Doing this wait-for-non-busy should not harm any existing | ||
656 | * configuration and fix some issues like the above. | ||
657 | * | ||
658 | * BenH. | ||
659 | * | ||
660 | * Returns 0 on success, error code (< 0) otherwise. | ||
661 | */ | ||
662 | |||
663 | static int ide_port_wait_ready(ide_hwif_t *hwif) | ||
635 | { | 664 | { |
636 | int unit, rc; | 665 | int unit, rc; |
637 | 666 | ||
@@ -709,36 +738,16 @@ void ide_undecoded_slave(ide_drive_t *drive1) | |||
709 | 738 | ||
710 | EXPORT_SYMBOL_GPL(ide_undecoded_slave); | 739 | EXPORT_SYMBOL_GPL(ide_undecoded_slave); |
711 | 740 | ||
712 | /* | 741 | static int ide_probe_port(ide_hwif_t *hwif) |
713 | * This routine only knows how to look for drive units 0 and 1 | ||
714 | * on an interface, so any setting of MAX_DRIVES > 2 won't work here. | ||
715 | */ | ||
716 | static void probe_hwif(ide_hwif_t *hwif) | ||
717 | { | 742 | { |
718 | unsigned long flags; | 743 | unsigned long flags; |
719 | unsigned int irqd; | 744 | unsigned int irqd; |
720 | int unit; | 745 | int unit, rc = -ENODEV; |
721 | 746 | ||
722 | if (hwif->noprobe) | 747 | BUG_ON(hwif->present); |
723 | return; | ||
724 | 748 | ||
725 | if ((hwif->chipset != ide_4drives || !hwif->mate || !hwif->mate->present) && | 749 | if (hwif->noprobe) |
726 | (ide_hwif_request_regions(hwif))) { | 750 | return -EACCES; |
727 | u16 msgout = 0; | ||
728 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | ||
729 | ide_drive_t *drive = &hwif->drives[unit]; | ||
730 | if (drive->present) { | ||
731 | drive->present = 0; | ||
732 | printk(KERN_ERR "%s: ERROR, PORTS ALREADY IN USE\n", | ||
733 | drive->name); | ||
734 | msgout = 1; | ||
735 | } | ||
736 | } | ||
737 | if (!msgout) | ||
738 | printk(KERN_ERR "%s: ports already in use, skipping probe\n", | ||
739 | hwif->name); | ||
740 | return; | ||
741 | } | ||
742 | 751 | ||
743 | /* | 752 | /* |
744 | * We must always disable IRQ, as probe_for_drive will assert IRQ, but | 753 | * We must always disable IRQ, as probe_for_drive will assert IRQ, but |
@@ -750,26 +759,7 @@ static void probe_hwif(ide_hwif_t *hwif) | |||
750 | 759 | ||
751 | local_irq_set(flags); | 760 | local_irq_set(flags); |
752 | 761 | ||
753 | /* This is needed on some PPCs and a bunch of BIOS-less embedded | 762 | if (ide_port_wait_ready(hwif) == -EBUSY) |
754 | * platforms. Typical cases are: | ||
755 | * | ||
756 | * - The firmware hard reset the disk before booting the kernel, | ||
757 | * the drive is still doing it's poweron-reset sequence, that | ||
758 | * can take up to 30 seconds | ||
759 | * - The firmware does nothing (or no firmware), the device is | ||
760 | * still in POST state (same as above actually). | ||
761 | * - Some CD/DVD/Writer combo drives tend to drive the bus during | ||
762 | * their reset sequence even when they are non-selected slave | ||
763 | * devices, thus preventing discovery of the main HD | ||
764 | * | ||
765 | * Doing this wait-for-busy should not harm any existing configuration | ||
766 | * (at least things won't be worse than what current code does, that | ||
767 | * is blindly go & talk to the drive) and fix some issues like the | ||
768 | * above. | ||
769 | * | ||
770 | * BenH. | ||
771 | */ | ||
772 | if (wait_hwif_ready(hwif) == -EBUSY) | ||
773 | printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); | 763 | printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); |
774 | 764 | ||
775 | /* | 765 | /* |
@@ -779,14 +769,8 @@ static void probe_hwif(ide_hwif_t *hwif) | |||
779 | ide_drive_t *drive = &hwif->drives[unit]; | 769 | ide_drive_t *drive = &hwif->drives[unit]; |
780 | drive->dn = (hwif->channel ? 2 : 0) + unit; | 770 | drive->dn = (hwif->channel ? 2 : 0) + unit; |
781 | (void) probe_for_drive(drive); | 771 | (void) probe_for_drive(drive); |
782 | if (drive->present && !hwif->present) { | 772 | if (drive->present) |
783 | hwif->present = 1; | 773 | rc = 0; |
784 | if (hwif->chipset != ide_4drives || | ||
785 | !hwif->mate || | ||
786 | !hwif->mate->present) { | ||
787 | hwif_register(hwif); | ||
788 | } | ||
789 | } | ||
790 | } | 774 | } |
791 | if (hwif->io_ports[IDE_CONTROL_OFFSET] && hwif->reset) { | 775 | if (hwif->io_ports[IDE_CONTROL_OFFSET] && hwif->reset) { |
792 | printk(KERN_WARNING "%s: reset\n", hwif->name); | 776 | printk(KERN_WARNING "%s: reset\n", hwif->name); |
@@ -803,10 +787,12 @@ static void probe_hwif(ide_hwif_t *hwif) | |||
803 | if (irqd) | 787 | if (irqd) |
804 | enable_irq(irqd); | 788 | enable_irq(irqd); |
805 | 789 | ||
806 | if (!hwif->present) { | 790 | return rc; |
807 | ide_hwif_release_regions(hwif); | 791 | } |
808 | return; | 792 | |
809 | } | 793 | static void ide_port_tune_devices(ide_hwif_t *hwif) |
794 | { | ||
795 | int unit; | ||
810 | 796 | ||
811 | for (unit = 0; unit < MAX_DRIVES; unit++) { | 797 | for (unit = 0; unit < MAX_DRIVES; unit++) { |
812 | ide_drive_t *drive = &hwif->drives[unit]; | 798 | ide_drive_t *drive = &hwif->drives[unit]; |
@@ -997,21 +983,17 @@ static int init_irq (ide_hwif_t *hwif) | |||
997 | spin_lock_irq(&ide_lock); | 983 | spin_lock_irq(&ide_lock); |
998 | hwif->next = hwgroup->hwif->next; | 984 | hwif->next = hwgroup->hwif->next; |
999 | hwgroup->hwif->next = hwif; | 985 | hwgroup->hwif->next = hwif; |
986 | BUG_ON(hwif->next == hwif); | ||
1000 | spin_unlock_irq(&ide_lock); | 987 | spin_unlock_irq(&ide_lock); |
1001 | } else { | 988 | } else { |
1002 | hwgroup = kmalloc_node(sizeof(ide_hwgroup_t), | 989 | hwgroup = kmalloc_node(sizeof(*hwgroup), GFP_KERNEL|__GFP_ZERO, |
1003 | GFP_KERNEL | __GFP_ZERO, | 990 | hwif_to_node(hwif)); |
1004 | hwif_to_node(hwif->drives[0].hwif)); | 991 | if (hwgroup == NULL) |
1005 | if (!hwgroup) | 992 | goto out_up; |
1006 | goto out_up; | ||
1007 | 993 | ||
1008 | hwif->hwgroup = hwgroup; | 994 | hwif->hwgroup = hwgroup; |
995 | hwgroup->hwif = hwif->next = hwif; | ||
1009 | 996 | ||
1010 | hwgroup->hwif = hwif->next = hwif; | ||
1011 | hwgroup->rq = NULL; | ||
1012 | hwgroup->handler = NULL; | ||
1013 | hwgroup->drive = NULL; | ||
1014 | hwgroup->busy = 0; | ||
1015 | init_timer(&hwgroup->timer); | 997 | init_timer(&hwgroup->timer); |
1016 | hwgroup->timer.function = &ide_timer_expiry; | 998 | hwgroup->timer.function = &ide_timer_expiry; |
1017 | hwgroup->timer.data = (unsigned long) hwgroup; | 999 | hwgroup->timer.data = (unsigned long) hwgroup; |
@@ -1079,25 +1061,7 @@ static int init_irq (ide_hwif_t *hwif) | |||
1079 | mutex_unlock(&ide_cfg_mtx); | 1061 | mutex_unlock(&ide_cfg_mtx); |
1080 | return 0; | 1062 | return 0; |
1081 | out_unlink: | 1063 | out_unlink: |
1082 | spin_lock_irq(&ide_lock); | 1064 | ide_remove_port_from_hwgroup(hwif); |
1083 | if (hwif->next == hwif) { | ||
1084 | BUG_ON(match); | ||
1085 | BUG_ON(hwgroup->hwif != hwif); | ||
1086 | kfree(hwgroup); | ||
1087 | } else { | ||
1088 | ide_hwif_t *g; | ||
1089 | g = hwgroup->hwif; | ||
1090 | while (g->next != hwif) | ||
1091 | g = g->next; | ||
1092 | g->next = hwif->next; | ||
1093 | if (hwgroup->hwif == hwif) { | ||
1094 | /* Impossible. */ | ||
1095 | printk(KERN_ERR "Duh. Uninitialized hwif listed as active hwif.\n"); | ||
1096 | hwgroup->hwif = g; | ||
1097 | } | ||
1098 | BUG_ON(hwgroup->hwif == hwif); | ||
1099 | } | ||
1100 | spin_unlock_irq(&ide_lock); | ||
1101 | out_up: | 1065 | out_up: |
1102 | mutex_unlock(&ide_cfg_mtx); | 1066 | mutex_unlock(&ide_cfg_mtx); |
1103 | return 1; | 1067 | return 1; |
@@ -1246,28 +1210,21 @@ static int hwif_init(ide_hwif_t *hwif) | |||
1246 | { | 1210 | { |
1247 | int old_irq; | 1211 | int old_irq; |
1248 | 1212 | ||
1249 | /* Return success if no device is connected */ | ||
1250 | if (!hwif->present) | ||
1251 | return 1; | ||
1252 | |||
1253 | if (!hwif->irq) { | 1213 | if (!hwif->irq) { |
1254 | if (!(hwif->irq = ide_default_irq(hwif->io_ports[IDE_DATA_OFFSET]))) | 1214 | if (!(hwif->irq = ide_default_irq(hwif->io_ports[IDE_DATA_OFFSET]))) |
1255 | { | 1215 | { |
1256 | printk("%s: DISABLED, NO IRQ\n", hwif->name); | 1216 | printk("%s: DISABLED, NO IRQ\n", hwif->name); |
1257 | return (hwif->present = 0); | 1217 | return 0; |
1258 | } | 1218 | } |
1259 | } | 1219 | } |
1260 | #ifdef CONFIG_BLK_DEV_HD | 1220 | #ifdef CONFIG_BLK_DEV_HD |
1261 | if (hwif->irq == HD_IRQ && hwif->io_ports[IDE_DATA_OFFSET] != HD_DATA) { | 1221 | if (hwif->irq == HD_IRQ && hwif->io_ports[IDE_DATA_OFFSET] != HD_DATA) { |
1262 | printk("%s: CANNOT SHARE IRQ WITH OLD " | 1222 | printk("%s: CANNOT SHARE IRQ WITH OLD " |
1263 | "HARDDISK DRIVER (hd.c)\n", hwif->name); | 1223 | "HARDDISK DRIVER (hd.c)\n", hwif->name); |
1264 | return (hwif->present = 0); | 1224 | return 0; |
1265 | } | 1225 | } |
1266 | #endif /* CONFIG_BLK_DEV_HD */ | 1226 | #endif /* CONFIG_BLK_DEV_HD */ |
1267 | 1227 | ||
1268 | /* we set it back to 1 if all is ok below */ | ||
1269 | hwif->present = 0; | ||
1270 | |||
1271 | if (register_blkdev(hwif->major, hwif->name)) | 1228 | if (register_blkdev(hwif->major, hwif->name)) |
1272 | return 0; | 1229 | return 0; |
1273 | 1230 | ||
@@ -1306,10 +1263,7 @@ static int hwif_init(ide_hwif_t *hwif) | |||
1306 | 1263 | ||
1307 | done: | 1264 | done: |
1308 | init_gendisk(hwif); | 1265 | init_gendisk(hwif); |
1309 | |||
1310 | ide_acpi_init(hwif); | 1266 | ide_acpi_init(hwif); |
1311 | |||
1312 | hwif->present = 1; /* success */ | ||
1313 | return 1; | 1267 | return 1; |
1314 | 1268 | ||
1315 | out: | 1269 | out: |
@@ -1344,7 +1298,27 @@ int ide_device_add_all(u8 *idx) | |||
1344 | if (idx[i] == 0xff) | 1298 | if (idx[i] == 0xff) |
1345 | continue; | 1299 | continue; |
1346 | 1300 | ||
1347 | probe_hwif(&ide_hwifs[idx[i]]); | 1301 | hwif = &ide_hwifs[idx[i]]; |
1302 | |||
1303 | if ((hwif->chipset != ide_4drives || !hwif->mate || | ||
1304 | !hwif->mate->present) && ide_hwif_request_regions(hwif)) { | ||
1305 | printk(KERN_ERR "%s: ports already in use, " | ||
1306 | "skipping probe\n", hwif->name); | ||
1307 | continue; | ||
1308 | } | ||
1309 | |||
1310 | if (ide_probe_port(hwif) < 0) { | ||
1311 | ide_hwif_release_regions(hwif); | ||
1312 | continue; | ||
1313 | } | ||
1314 | |||
1315 | hwif->present = 1; | ||
1316 | |||
1317 | if (hwif->chipset != ide_4drives || !hwif->mate || | ||
1318 | !hwif->mate->present) | ||
1319 | ide_register_port(hwif); | ||
1320 | |||
1321 | ide_port_tune_devices(hwif); | ||
1348 | } | 1322 | } |
1349 | 1323 | ||
1350 | for (i = 0; i < MAX_HWIFS; i++) { | 1324 | for (i = 0; i < MAX_HWIFS; i++) { |
@@ -1353,9 +1327,13 @@ int ide_device_add_all(u8 *idx) | |||
1353 | 1327 | ||
1354 | hwif = &ide_hwifs[idx[i]]; | 1328 | hwif = &ide_hwifs[idx[i]]; |
1355 | 1329 | ||
1330 | if (!hwif->present) | ||
1331 | continue; | ||
1332 | |||
1356 | if (hwif_init(hwif) == 0) { | 1333 | if (hwif_init(hwif) == 0) { |
1357 | printk(KERN_INFO "%s: failed to initialize IDE " | 1334 | printk(KERN_INFO "%s: failed to initialize IDE " |
1358 | "interface\n", hwif->name); | 1335 | "interface\n", hwif->name); |
1336 | hwif->present = 0; | ||
1359 | rc = -1; | 1337 | rc = -1; |
1360 | continue; | 1338 | continue; |
1361 | } | 1339 | } |
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index aa663e7f46f2..00c249cba236 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/ide-proc.c Version 1.05 Mar 05, 2003 | ||
3 | * | ||
4 | * Copyright (C) 1997-1998 Mark Lord | 2 | * Copyright (C) 1997-1998 Mark Lord |
5 | * Copyright (C) 2003 Red Hat <alan@redhat.com> | 3 | * Copyright (C) 2003 Red Hat <alan@redhat.com> |
6 | * | 4 | * |
diff --git a/drivers/ide/ide-scan-pci.c b/drivers/ide/ide-scan-pci.c index 7ffa332d77ce..93d2e41be853 100644 --- a/drivers/ide/ide-scan-pci.c +++ b/drivers/ide/ide-scan-pci.c | |||
@@ -81,7 +81,7 @@ static int __init ide_scan_pcidev(struct pci_dev *dev) | |||
81 | * module ordering not traditionally ordered. | 81 | * module ordering not traditionally ordered. |
82 | */ | 82 | */ |
83 | 83 | ||
84 | int __init ide_scan_pcibus(void) | 84 | static int __init ide_scan_pcibus(void) |
85 | { | 85 | { |
86 | struct pci_dev *dev = NULL; | 86 | struct pci_dev *dev = NULL; |
87 | struct pci_driver *d; | 87 | struct pci_driver *d; |
@@ -113,9 +113,4 @@ int __init ide_scan_pcibus(void) | |||
113 | return 0; | 113 | return 0; |
114 | } | 114 | } |
115 | 115 | ||
116 | static int __init ide_scan_pci(void) | 116 | module_init(ide_scan_pcibus); |
117 | { | ||
118 | return ide_scan_pcibus(); | ||
119 | } | ||
120 | |||
121 | module_init(ide_scan_pci); | ||
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index d71a584f0765..5aef63acf1e8 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/ide-tape.c Version 1.19 Nov, 2003 | 2 | * Copyright (C) 1995-1999 Gadi Oxman <gadio@netvision.net.il> |
3 | * | 3 | * Copyright (C) 2003-2005 Bartlomiej Zolnierkiewicz |
4 | * Copyright (C) 1995 - 1999 Gadi Oxman <gadio@netvision.net.il> | ||
5 | * | 4 | * |
6 | * $Header$ | 5 | * $Header$ |
7 | * | 6 | * |
@@ -4291,9 +4290,6 @@ static int idetape_identify_device (ide_drive_t *drive) | |||
4291 | { | 4290 | { |
4292 | struct idetape_id_gcw gcw; | 4291 | struct idetape_id_gcw gcw; |
4293 | struct hd_driveid *id = drive->id; | 4292 | struct hd_driveid *id = drive->id; |
4294 | #if IDETAPE_DEBUG_INFO | ||
4295 | unsigned short mask,i; | ||
4296 | #endif /* IDETAPE_DEBUG_INFO */ | ||
4297 | 4293 | ||
4298 | if (drive->id_read == 0) | 4294 | if (drive->id_read == 0) |
4299 | return 1; | 4295 | return 1; |
@@ -4333,62 +4329,6 @@ static int idetape_identify_device (ide_drive_t *drive) | |||
4333 | case 1: printk("16 bytes\n");break; | 4329 | case 1: printk("16 bytes\n");break; |
4334 | default: printk("Reserved\n");break; | 4330 | default: printk("Reserved\n");break; |
4335 | } | 4331 | } |
4336 | printk(KERN_INFO "ide-tape: Model: %.40s\n",id->model); | ||
4337 | printk(KERN_INFO "ide-tape: Firmware Revision: %.8s\n",id->fw_rev); | ||
4338 | printk(KERN_INFO "ide-tape: Serial Number: %.20s\n",id->serial_no); | ||
4339 | printk(KERN_INFO "ide-tape: Write buffer size: %d bytes\n",id->buf_size*512); | ||
4340 | printk(KERN_INFO "ide-tape: DMA: %s",id->capability & 0x01 ? "Yes\n":"No\n"); | ||
4341 | printk(KERN_INFO "ide-tape: LBA: %s",id->capability & 0x02 ? "Yes\n":"No\n"); | ||
4342 | printk(KERN_INFO "ide-tape: IORDY can be disabled: %s",id->capability & 0x04 ? "Yes\n":"No\n"); | ||
4343 | printk(KERN_INFO "ide-tape: IORDY supported: %s",id->capability & 0x08 ? "Yes\n":"Unknown\n"); | ||
4344 | printk(KERN_INFO "ide-tape: ATAPI overlap supported: %s",id->capability & 0x20 ? "Yes\n":"No\n"); | ||
4345 | printk(KERN_INFO "ide-tape: PIO Cycle Timing Category: %d\n",id->tPIO); | ||
4346 | printk(KERN_INFO "ide-tape: DMA Cycle Timing Category: %d\n",id->tDMA); | ||
4347 | printk(KERN_INFO "ide-tape: Single Word DMA supported modes: "); | ||
4348 | for (i=0,mask=1;i<8;i++,mask=mask << 1) { | ||
4349 | if (id->dma_1word & mask) | ||
4350 | printk("%d ",i); | ||
4351 | if (id->dma_1word & (mask << 8)) | ||
4352 | printk("(active) "); | ||
4353 | } | ||
4354 | printk("\n"); | ||
4355 | printk(KERN_INFO "ide-tape: Multi Word DMA supported modes: "); | ||
4356 | for (i=0,mask=1;i<8;i++,mask=mask << 1) { | ||
4357 | if (id->dma_mword & mask) | ||
4358 | printk("%d ",i); | ||
4359 | if (id->dma_mword & (mask << 8)) | ||
4360 | printk("(active) "); | ||
4361 | } | ||
4362 | printk("\n"); | ||
4363 | if (id->field_valid & 0x0002) { | ||
4364 | printk(KERN_INFO "ide-tape: Enhanced PIO Modes: %s\n", | ||
4365 | id->eide_pio_modes & 1 ? "Mode 3":"None"); | ||
4366 | printk(KERN_INFO "ide-tape: Minimum Multi-word DMA cycle per word: "); | ||
4367 | if (id->eide_dma_min == 0) | ||
4368 | printk("Not supported\n"); | ||
4369 | else | ||
4370 | printk("%d ns\n",id->eide_dma_min); | ||
4371 | |||
4372 | printk(KERN_INFO "ide-tape: Manufacturer\'s Recommended Multi-word cycle: "); | ||
4373 | if (id->eide_dma_time == 0) | ||
4374 | printk("Not supported\n"); | ||
4375 | else | ||
4376 | printk("%d ns\n",id->eide_dma_time); | ||
4377 | |||
4378 | printk(KERN_INFO "ide-tape: Minimum PIO cycle without IORDY: "); | ||
4379 | if (id->eide_pio == 0) | ||
4380 | printk("Not supported\n"); | ||
4381 | else | ||
4382 | printk("%d ns\n",id->eide_pio); | ||
4383 | |||
4384 | printk(KERN_INFO "ide-tape: Minimum PIO cycle with IORDY: "); | ||
4385 | if (id->eide_pio_iordy == 0) | ||
4386 | printk("Not supported\n"); | ||
4387 | else | ||
4388 | printk("%d ns\n",id->eide_pio_iordy); | ||
4389 | |||
4390 | } else | ||
4391 | printk(KERN_INFO "ide-tape: According to the device, fields 64-70 are not valid.\n"); | ||
4392 | #endif /* IDETAPE_DEBUG_INFO */ | 4332 | #endif /* IDETAPE_DEBUG_INFO */ |
4393 | 4333 | ||
4394 | /* Check that we can support this device */ | 4334 | /* Check that we can support this device */ |
@@ -4591,19 +4531,11 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
4591 | 4531 | ||
4592 | spin_lock_init(&tape->spinlock); | 4532 | spin_lock_init(&tape->spinlock); |
4593 | drive->dsc_overlap = 1; | 4533 | drive->dsc_overlap = 1; |
4594 | #ifdef CONFIG_BLK_DEV_IDEPCI | 4534 | if (drive->hwif->host_flags & IDE_HFLAG_NO_DSC) { |
4595 | if (HWIF(drive)->pci_dev != NULL) { | 4535 | printk(KERN_INFO "ide-tape: %s: disabling DSC overlap\n", |
4596 | /* | 4536 | tape->name); |
4597 | * These two ide-pci host adapters appear to need DSC overlap disabled. | 4537 | drive->dsc_overlap = 0; |
4598 | * This probably needs further analysis. | ||
4599 | */ | ||
4600 | if ((HWIF(drive)->pci_dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) || | ||
4601 | (HWIF(drive)->pci_dev->device == PCI_DEVICE_ID_TTI_HPT343)) { | ||
4602 | printk(KERN_INFO "ide-tape: %s: disabling DSC overlap\n", tape->name); | ||
4603 | drive->dsc_overlap = 0; | ||
4604 | } | ||
4605 | } | 4538 | } |
4606 | #endif /* CONFIG_BLK_DEV_IDEPCI */ | ||
4607 | /* Seagate Travan drives do not support DSC overlap. */ | 4539 | /* Seagate Travan drives do not support DSC overlap. */ |
4608 | if (strstr(drive->id->model, "Seagate STT3401")) | 4540 | if (strstr(drive->id->model, "Seagate STT3401")) |
4609 | drive->dsc_overlap = 0; | 4541 | drive->dsc_overlap = 0; |
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 5eb6fa15dc4d..16a9a581d089 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c | |||
@@ -1,11 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/ide-taskfile.c Version 0.38 March 05, 2003 | 2 | * Copyright (C) 2000-2002 Michael Cornwell <cornwell@acm.org> |
3 | * | 3 | * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> |
4 | * Copyright (C) 2000-2002 Michael Cornwell <cornwell@acm.org> | 4 | * Copyright (C) 2001-2002 Klaus Smolin |
5 | * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> | ||
6 | * Copyright (C) 2001-2002 Klaus Smolin | ||
7 | * IBM Storage Technology Division | 5 | * IBM Storage Technology Division |
8 | * Copyright (C) 2003-2004 Bartlomiej Zolnierkiewicz | 6 | * Copyright (C) 2003-2004, 2007 Bartlomiej Zolnierkiewicz |
9 | * | 7 | * |
10 | * The big the bad and the ugly. | 8 | * The big the bad and the ugly. |
11 | */ | 9 | */ |
@@ -260,7 +258,7 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *drive) | |||
260 | return ide_stopped; | 258 | return ide_stopped; |
261 | } | 259 | } |
262 | 260 | ||
263 | u8 wait_drive_not_busy(ide_drive_t *drive) | 261 | static u8 wait_drive_not_busy(ide_drive_t *drive) |
264 | { | 262 | { |
265 | ide_hwif_t *hwif = HWIF(drive); | 263 | ide_hwif_t *hwif = HWIF(drive); |
266 | int retries; | 264 | int retries; |
diff --git a/drivers/ide/ide-timing.h b/drivers/ide/ide-timing.h index daffbb9797e1..adeda7626529 100644 --- a/drivers/ide/ide-timing.h +++ b/drivers/ide/ide-timing.h | |||
@@ -2,8 +2,6 @@ | |||
2 | #define _IDE_TIMING_H | 2 | #define _IDE_TIMING_H |
3 | 3 | ||
4 | /* | 4 | /* |
5 | * $Id: ide-timing.h,v 1.6 2001/12/23 22:47:56 vojtech Exp $ | ||
6 | * | ||
7 | * Copyright (c) 1999-2001 Vojtech Pavlik | 5 | * Copyright (c) 1999-2001 Vojtech Pavlik |
8 | */ | 6 | */ |
9 | 7 | ||
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 97894abd9ebc..ab9ca2b5b66c 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/ide.c Version 7.00beta2 Mar 05 2003 | 2 | * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) |
3 | * | 3 | * Copyrifht (C) 2003-2005, 2007 Bartlomiej Zolnierkiewicz |
4 | * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) | ||
5 | */ | 4 | */ |
6 | 5 | ||
7 | /* | 6 | /* |
@@ -46,7 +45,6 @@ | |||
46 | */ | 45 | */ |
47 | 46 | ||
48 | #define REVISION "Revision: 7.00alpha2" | 47 | #define REVISION "Revision: 7.00alpha2" |
49 | #define VERSION "Id: ide.c 7.00a2 20020906" | ||
50 | 48 | ||
51 | #define _IDE_C /* Tell ide.h it's really us */ | 49 | #define _IDE_C /* Tell ide.h it's really us */ |
52 | 50 | ||
@@ -242,22 +240,12 @@ static int ide_system_bus_speed(void) | |||
242 | #define pci_default 0 | 240 | #define pci_default 0 |
243 | #endif /* CONFIG_PCI */ | 241 | #endif /* CONFIG_PCI */ |
244 | 242 | ||
245 | if (!system_bus_speed) { | 243 | /* user supplied value */ |
246 | if (idebus_parameter) { | 244 | if (idebus_parameter) |
247 | /* user supplied value */ | 245 | return idebus_parameter; |
248 | system_bus_speed = idebus_parameter; | 246 | |
249 | } else if (pci_dev_present(pci_default)) { | 247 | /* safe default value for PCI or VESA and PCI*/ |
250 | /* safe default value for PCI */ | 248 | return pci_dev_present(pci_default) ? 33 : 50; |
251 | system_bus_speed = 33; | ||
252 | } else { | ||
253 | /* safe default value for VESA and PCI */ | ||
254 | system_bus_speed = 50; | ||
255 | } | ||
256 | printk(KERN_INFO "ide: Assuming %dMHz system bus speed " | ||
257 | "for PIO modes%s\n", system_bus_speed, | ||
258 | idebus_parameter ? "" : "; override with idebus=xx"); | ||
259 | } | ||
260 | return system_bus_speed; | ||
261 | } | 249 | } |
262 | 250 | ||
263 | ide_hwif_t * ide_find_port(unsigned long base) | 251 | ide_hwif_t * ide_find_port(unsigned long base) |
@@ -405,8 +393,9 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif) | |||
405 | hwif->chipset = tmp_hwif->chipset; | 393 | hwif->chipset = tmp_hwif->chipset; |
406 | hwif->hold = tmp_hwif->hold; | 394 | hwif->hold = tmp_hwif->hold; |
407 | 395 | ||
396 | hwif->dev = tmp_hwif->dev; | ||
397 | |||
408 | #ifdef CONFIG_BLK_DEV_IDEPCI | 398 | #ifdef CONFIG_BLK_DEV_IDEPCI |
409 | hwif->pci_dev = tmp_hwif->pci_dev; | ||
410 | hwif->cds = tmp_hwif->cds; | 399 | hwif->cds = tmp_hwif->cds; |
411 | #endif | 400 | #endif |
412 | 401 | ||
@@ -472,6 +461,41 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif) | |||
472 | hwif->hwif_data = tmp_hwif->hwif_data; | 461 | hwif->hwif_data = tmp_hwif->hwif_data; |
473 | } | 462 | } |
474 | 463 | ||
464 | void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) | ||
465 | { | ||
466 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | ||
467 | |||
468 | spin_lock_irq(&ide_lock); | ||
469 | /* | ||
470 | * Remove us from the hwgroup, and free | ||
471 | * the hwgroup if we were the only member | ||
472 | */ | ||
473 | if (hwif->next == hwif) { | ||
474 | BUG_ON(hwgroup->hwif != hwif); | ||
475 | kfree(hwgroup); | ||
476 | } else { | ||
477 | /* There is another interface in hwgroup. | ||
478 | * Unlink us, and set hwgroup->drive and ->hwif to | ||
479 | * something sane. | ||
480 | */ | ||
481 | ide_hwif_t *g = hwgroup->hwif; | ||
482 | |||
483 | while (g->next != hwif) | ||
484 | g = g->next; | ||
485 | g->next = hwif->next; | ||
486 | if (hwgroup->hwif == hwif) { | ||
487 | /* Chose a random hwif for hwgroup->hwif. | ||
488 | * It's guaranteed that there are no drives | ||
489 | * left in the hwgroup. | ||
490 | */ | ||
491 | BUG_ON(hwgroup->drive != NULL); | ||
492 | hwgroup->hwif = g; | ||
493 | } | ||
494 | BUG_ON(hwgroup->hwif == hwif); | ||
495 | } | ||
496 | spin_unlock_irq(&ide_lock); | ||
497 | } | ||
498 | |||
475 | /** | 499 | /** |
476 | * ide_unregister - free an IDE interface | 500 | * ide_unregister - free an IDE interface |
477 | * @index: index of interface (will change soon to a pointer) | 501 | * @index: index of interface (will change soon to a pointer) |
@@ -539,43 +563,8 @@ void ide_unregister(unsigned int index) | |||
539 | if (irq_count == 1) | 563 | if (irq_count == 1) |
540 | free_irq(hwif->irq, hwgroup); | 564 | free_irq(hwif->irq, hwgroup); |
541 | 565 | ||
542 | spin_lock_irq(&ide_lock); | 566 | ide_remove_port_from_hwgroup(hwif); |
543 | /* | ||
544 | * Note that we only release the standard ports, | ||
545 | * and do not even try to handle any extra ports | ||
546 | * allocated for weird IDE interface chipsets. | ||
547 | */ | ||
548 | ide_hwif_release_regions(hwif); | ||
549 | |||
550 | /* | ||
551 | * Remove us from the hwgroup, and free | ||
552 | * the hwgroup if we were the only member | ||
553 | */ | ||
554 | if (hwif->next == hwif) { | ||
555 | BUG_ON(hwgroup->hwif != hwif); | ||
556 | kfree(hwgroup); | ||
557 | } else { | ||
558 | /* There is another interface in hwgroup. | ||
559 | * Unlink us, and set hwgroup->drive and ->hwif to | ||
560 | * something sane. | ||
561 | */ | ||
562 | g = hwgroup->hwif; | ||
563 | while (g->next != hwif) | ||
564 | g = g->next; | ||
565 | g->next = hwif->next; | ||
566 | if (hwgroup->hwif == hwif) { | ||
567 | /* Chose a random hwif for hwgroup->hwif. | ||
568 | * It's guaranteed that there are no drives | ||
569 | * left in the hwgroup. | ||
570 | */ | ||
571 | BUG_ON(hwgroup->drive != NULL); | ||
572 | hwgroup->hwif = g; | ||
573 | } | ||
574 | BUG_ON(hwgroup->hwif == hwif); | ||
575 | } | ||
576 | 567 | ||
577 | /* More messed up locking ... */ | ||
578 | spin_unlock_irq(&ide_lock); | ||
579 | device_unregister(&hwif->gendev); | 568 | device_unregister(&hwif->gendev); |
580 | wait_for_completion(&hwif->gendev_rel_comp); | 569 | wait_for_completion(&hwif->gendev_rel_comp); |
581 | 570 | ||
@@ -601,6 +590,13 @@ void ide_unregister(unsigned int index) | |||
601 | hwif->extra_ports = 0; | 590 | hwif->extra_ports = 0; |
602 | } | 591 | } |
603 | 592 | ||
593 | /* | ||
594 | * Note that we only release the standard ports, | ||
595 | * and do not even try to handle any extra ports | ||
596 | * allocated for weird IDE interface chipsets. | ||
597 | */ | ||
598 | ide_hwif_release_regions(hwif); | ||
599 | |||
604 | /* copy original settings */ | 600 | /* copy original settings */ |
605 | tmp_hwif = *hwif; | 601 | tmp_hwif = *hwif; |
606 | 602 | ||
@@ -913,7 +909,7 @@ static int set_unmaskirq(ide_drive_t *drive, int arg) | |||
913 | 909 | ||
914 | int system_bus_clock (void) | 910 | int system_bus_clock (void) |
915 | { | 911 | { |
916 | return((int) ((!system_bus_speed) ? ide_system_bus_speed() : system_bus_speed )); | 912 | return system_bus_speed; |
917 | } | 913 | } |
918 | 914 | ||
919 | EXPORT_SYMBOL(system_bus_clock); | 915 | EXPORT_SYMBOL(system_bus_clock); |
@@ -1668,6 +1664,10 @@ static int __init ide_init(void) | |||
1668 | printk(KERN_INFO "Uniform Multi-Platform E-IDE driver " REVISION "\n"); | 1664 | printk(KERN_INFO "Uniform Multi-Platform E-IDE driver " REVISION "\n"); |
1669 | system_bus_speed = ide_system_bus_speed(); | 1665 | system_bus_speed = ide_system_bus_speed(); |
1670 | 1666 | ||
1667 | printk(KERN_INFO "ide: Assuming %dMHz system bus speed " | ||
1668 | "for PIO modes%s\n", system_bus_speed, | ||
1669 | idebus_parameter ? "" : "; override with idebus=xx"); | ||
1670 | |||
1671 | ret = bus_register(&ide_bus_type); | 1671 | ret = bus_register(&ide_bus_type); |
1672 | if (ret < 0) { | 1672 | if (ret < 0) { |
1673 | printk(KERN_WARNING "IDE: bus_register error: %d\n", ret); | 1673 | printk(KERN_WARNING "IDE: bus_register error: %d\n", ret); |
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c index 5ec0be4cbad7..e3ea2096804a 100644 --- a/drivers/ide/legacy/ali14xx.c +++ b/drivers/ide/legacy/ali14xx.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/legacy/ali14xx.c Version 0.03 Feb 09, 1996 | ||
3 | * | ||
4 | * Copyright (C) 1996 Linus Torvalds & author (see below) | 2 | * Copyright (C) 1996 Linus Torvalds & author (see below) |
5 | */ | 3 | */ |
6 | 4 | ||
diff --git a/drivers/ide/legacy/buddha.c b/drivers/ide/legacy/buddha.c index 74d28e058f55..dd3d198ade47 100644 --- a/drivers/ide/legacy/buddha.c +++ b/drivers/ide/legacy/buddha.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/legacy/buddha.c -- Amiga Buddha, Catweasel and X-Surf IDE Driver | 2 | * Amiga Buddha, Catweasel and X-Surf IDE Driver |
3 | * | 3 | * |
4 | * Copyright (C) 1997, 2001 by Geert Uytterhoeven and others | 4 | * Copyright (C) 1997, 2001 by Geert Uytterhoeven and others |
5 | * | 5 | * |
diff --git a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c index 13eee6da2806..611c9705a3ae 100644 --- a/drivers/ide/legacy/dtc2278.c +++ b/drivers/ide/legacy/dtc2278.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/legacy/dtc2278.c Version 0.02 Feb 10, 1996 | ||
3 | * | ||
4 | * Copyright (C) 1996 Linus Torvalds & author (see below) | 2 | * Copyright (C) 1996 Linus Torvalds & author (see below) |
5 | */ | 3 | */ |
6 | 4 | ||
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c index 2860956bdcb0..c9bd6bfb1f3b 100644 --- a/drivers/ide/legacy/falconide.c +++ b/drivers/ide/legacy/falconide.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/legacy/falconide.c -- Atari Falcon IDE Driver | 2 | * Atari Falcon IDE Driver |
3 | * | 3 | * |
4 | * Created 12 Jul 1997 by Geert Uytterhoeven | 4 | * Created 12 Jul 1997 by Geert Uytterhoeven |
5 | * | 5 | * |
@@ -66,6 +66,7 @@ static int __init falconide_init(void) | |||
66 | { | 66 | { |
67 | if (MACH_IS_ATARI && ATARIHW_PRESENT(IDE)) { | 67 | if (MACH_IS_ATARI && ATARIHW_PRESENT(IDE)) { |
68 | hw_regs_t hw; | 68 | hw_regs_t hw; |
69 | ide_hwif_t *hwif; | ||
69 | 70 | ||
70 | printk(KERN_INFO "ide: Falcon IDE controller\n"); | 71 | printk(KERN_INFO "ide: Falcon IDE controller\n"); |
71 | 72 | ||
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c index 492fa047efc0..f67c51a2c84a 100644 --- a/drivers/ide/legacy/gayle.c +++ b/drivers/ide/legacy/gayle.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/legacy/gayle.c -- Amiga Gayle IDE Driver | 2 | * Amiga Gayle IDE Driver |
3 | * | 3 | * |
4 | * Created 9 Jul 1997 by Geert Uytterhoeven | 4 | * Created 9 Jul 1997 by Geert Uytterhoeven |
5 | * | 5 | * |
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c index 8da5031a6d05..57bc15cddca0 100644 --- a/drivers/ide/legacy/ht6560b.c +++ b/drivers/ide/legacy/ht6560b.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/legacy/ht6560b.c Version 0.07 Feb 1, 2000 | ||
3 | * | ||
4 | * Copyright (C) 1995-2000 Linus Torvalds & author (see below) | 2 | * Copyright (C) 1995-2000 Linus Torvalds & author (see below) |
5 | */ | 3 | */ |
6 | 4 | ||
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index f4ea15b32969..3bd29676ef6a 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c | |||
@@ -2,8 +2,6 @@ | |||
2 | 2 | ||
3 | A driver for PCMCIA IDE/ATA disk cards | 3 | A driver for PCMCIA IDE/ATA disk cards |
4 | 4 | ||
5 | ide-cs.c 1.3 2002/10/26 05:45:31 | ||
6 | |||
7 | The contents of this file are subject to the Mozilla Public | 5 | The contents of this file are subject to the Mozilla Public |
8 | License Version 1.1 (the "License"); you may not use this file | 6 | License Version 1.1 (the "License"); you may not use this file |
9 | except in compliance with the License. You may obtain a copy of | 7 | except in compliance with the License. You may obtain a copy of |
diff --git a/drivers/ide/legacy/ide_platform.c b/drivers/ide/legacy/ide_platform.c index 69a0fb0e564f..7c3231a21d17 100644 --- a/drivers/ide/legacy/ide_platform.c +++ b/drivers/ide/legacy/ide_platform.c | |||
@@ -21,13 +21,6 @@ | |||
21 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | 23 | ||
24 | static struct { | ||
25 | void __iomem *plat_ide_mapbase; | ||
26 | void __iomem *plat_ide_alt_mapbase; | ||
27 | ide_hwif_t *hwif; | ||
28 | int index; | ||
29 | } hwif_prop; | ||
30 | |||
31 | static void __devinit plat_ide_setup_ports(hw_regs_t *hw, | 24 | static void __devinit plat_ide_setup_ports(hw_regs_t *hw, |
32 | void __iomem *base, | 25 | void __iomem *base, |
33 | void __iomem *ctrl, | 26 | void __iomem *ctrl, |
@@ -54,6 +47,7 @@ static void __devinit plat_ide_setup_ports(hw_regs_t *hw, | |||
54 | static int __devinit plat_ide_probe(struct platform_device *pdev) | 47 | static int __devinit plat_ide_probe(struct platform_device *pdev) |
55 | { | 48 | { |
56 | struct resource *res_base, *res_alt, *res_irq; | 49 | struct resource *res_base, *res_alt, *res_irq; |
50 | void __iomem *base, *alt_base; | ||
57 | ide_hwif_t *hwif; | 51 | ide_hwif_t *hwif; |
58 | struct pata_platform_info *pdata; | 52 | struct pata_platform_info *pdata; |
59 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 53 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
@@ -84,27 +78,25 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) | |||
84 | } | 78 | } |
85 | 79 | ||
86 | if (mmio) { | 80 | if (mmio) { |
87 | hwif_prop.plat_ide_mapbase = devm_ioremap(&pdev->dev, | 81 | base = devm_ioremap(&pdev->dev, |
88 | res_base->start, res_base->end - res_base->start + 1); | 82 | res_base->start, res_base->end - res_base->start + 1); |
89 | hwif_prop.plat_ide_alt_mapbase = devm_ioremap(&pdev->dev, | 83 | alt_base = devm_ioremap(&pdev->dev, |
90 | res_alt->start, res_alt->end - res_alt->start + 1); | 84 | res_alt->start, res_alt->end - res_alt->start + 1); |
91 | } else { | 85 | } else { |
92 | hwif_prop.plat_ide_mapbase = devm_ioport_map(&pdev->dev, | 86 | base = devm_ioport_map(&pdev->dev, |
93 | res_base->start, res_base->end - res_base->start + 1); | 87 | res_base->start, res_base->end - res_base->start + 1); |
94 | hwif_prop.plat_ide_alt_mapbase = devm_ioport_map(&pdev->dev, | 88 | alt_base = devm_ioport_map(&pdev->dev, |
95 | res_alt->start, res_alt->end - res_alt->start + 1); | 89 | res_alt->start, res_alt->end - res_alt->start + 1); |
96 | } | 90 | } |
97 | 91 | ||
98 | hwif = ide_find_port((unsigned long)hwif_prop.plat_ide_mapbase); | 92 | hwif = ide_find_port((unsigned long)base); |
99 | if (!hwif) { | 93 | if (!hwif) { |
100 | ret = -ENODEV; | 94 | ret = -ENODEV; |
101 | goto out; | 95 | goto out; |
102 | } | 96 | } |
103 | 97 | ||
104 | memset(&hw, 0, sizeof(hw)); | 98 | memset(&hw, 0, sizeof(hw)); |
105 | plat_ide_setup_ports(&hw, hwif_prop.plat_ide_mapbase, | 99 | plat_ide_setup_ports(&hw, base, alt_base, pdata, res_irq->start); |
106 | hwif_prop.plat_ide_alt_mapbase, | ||
107 | pdata, res_irq->start); | ||
108 | hw.dev = &pdev->dev; | 100 | hw.dev = &pdev->dev; |
109 | 101 | ||
110 | ide_init_port_hw(hwif, &hw); | 102 | ide_init_port_hw(hwif, &hw); |
@@ -114,9 +106,6 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) | |||
114 | default_hwif_mmiops(hwif); | 106 | default_hwif_mmiops(hwif); |
115 | } | 107 | } |
116 | 108 | ||
117 | hwif_prop.hwif = hwif; | ||
118 | hwif_prop.index = hwif->index; | ||
119 | |||
120 | idx[0] = hwif->index; | 109 | idx[0] = hwif->index; |
121 | 110 | ||
122 | ide_device_add(idx); | 111 | ide_device_add(idx); |
@@ -133,14 +122,7 @@ static int __devexit plat_ide_remove(struct platform_device *pdev) | |||
133 | { | 122 | { |
134 | ide_hwif_t *hwif = pdev->dev.driver_data; | 123 | ide_hwif_t *hwif = pdev->dev.driver_data; |
135 | 124 | ||
136 | if (hwif != hwif_prop.hwif) { | 125 | ide_unregister(hwif->index); |
137 | dev_printk(KERN_DEBUG, &pdev->dev, "%s: hwif value error", | ||
138 | pdev->name); | ||
139 | } else { | ||
140 | ide_unregister(hwif_prop.index); | ||
141 | hwif_prop.index = 0; | ||
142 | hwif_prop.hwif = NULL; | ||
143 | } | ||
144 | 126 | ||
145 | return 0; | 127 | return 0; |
146 | } | 128 | } |
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c index 782d4c76c0e5..c54d07ff64fe 100644 --- a/drivers/ide/legacy/macide.c +++ b/drivers/ide/legacy/macide.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/legacy/macide.c -- Macintosh IDE Driver | 2 | * Macintosh IDE Driver |
3 | * | 3 | * |
4 | * Copyright (C) 1998 by Michael Schmitz | 4 | * Copyright (C) 1998 by Michael Schmitz |
5 | * | 5 | * |
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c index f5329730df99..a9c6b0609c54 100644 --- a/drivers/ide/legacy/q40ide.c +++ b/drivers/ide/legacy/q40ide.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/legacy/q40ide.c -- Q40 I/O port IDE Driver | 2 | * Q40 I/O port IDE Driver |
3 | * | 3 | * |
4 | * (c) Richard Zidlicky | 4 | * (c) Richard Zidlicky |
5 | * | 5 | * |
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c index 2bac4c1a6532..37534bb483a7 100644 --- a/drivers/ide/legacy/qd65xx.c +++ b/drivers/ide/legacy/qd65xx.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/legacy/qd65xx.c Version 0.07 Sep 30, 2001 | ||
3 | * | ||
4 | * Copyright (C) 1996-2001 Linus Torvalds & author (see below) | 2 | * Copyright (C) 1996-2001 Linus Torvalds & author (see below) |
5 | */ | 3 | */ |
6 | 4 | ||
diff --git a/drivers/ide/legacy/qd65xx.h b/drivers/ide/legacy/qd65xx.h index 633a42456ef6..28dd50a15d55 100644 --- a/drivers/ide/legacy/qd65xx.h +++ b/drivers/ide/legacy/qd65xx.h | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/legacy/qd65xx.h | ||
3 | * | ||
4 | * Copyright (c) 2000 Linus Torvalds & authors | 2 | * Copyright (c) 2000 Linus Torvalds & authors |
5 | */ | 3 | */ |
6 | 4 | ||
diff --git a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c index a1ae1ae6699d..26f38ce58776 100644 --- a/drivers/ide/legacy/umc8672.c +++ b/drivers/ide/legacy/umc8672.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/legacy/umc8672.c Version 0.05 Jul 31, 1996 | ||
3 | * | ||
4 | * Copyright (C) 1995-1996 Linus Torvalds & author (see below) | 2 | * Copyright (C) 1995-1996 Linus Torvalds & author (see below) |
5 | */ | 3 | */ |
6 | 4 | ||
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c index 2d3e5115b834..cd42b30a7a3b 100644 --- a/drivers/ide/mips/au1xxx-ide.c +++ b/drivers/ide/mips/au1xxx-ide.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/mips/au1xxx-ide.c version 01.30.00 Aug. 02 2005 | ||
3 | * | ||
4 | * BRIEF MODULE DESCRIPTION | 2 | * BRIEF MODULE DESCRIPTION |
5 | * AMD Alchemy Au1xxx IDE interface routines over the Static Bus | 3 | * AMD Alchemy Au1xxx IDE interface routines over the Static Bus |
6 | * | 4 | * |
@@ -50,7 +48,6 @@ | |||
50 | #include <asm/mach-au1x00/au1xxx_ide.h> | 48 | #include <asm/mach-au1x00/au1xxx_ide.h> |
51 | 49 | ||
52 | #define DRV_NAME "au1200-ide" | 50 | #define DRV_NAME "au1200-ide" |
53 | #define DRV_VERSION "1.0" | ||
54 | #define DRV_AUTHOR "Enrico Walther <enrico.walther@amd.com> / Pete Popov <ppopov@embeddedalley.com>" | 51 | #define DRV_AUTHOR "Enrico Walther <enrico.walther@amd.com> / Pete Popov <ppopov@embeddedalley.com>" |
55 | 52 | ||
56 | /* enable the burstmode in the dbdma */ | 53 | /* enable the burstmode in the dbdma */ |
@@ -209,24 +206,6 @@ static void auide_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
209 | */ | 206 | */ |
210 | 207 | ||
211 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | 208 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA |
212 | |||
213 | static int auide_build_sglist(ide_drive_t *drive, struct request *rq) | ||
214 | { | ||
215 | ide_hwif_t *hwif = drive->hwif; | ||
216 | _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data; | ||
217 | struct scatterlist *sg = hwif->sg_table; | ||
218 | |||
219 | ide_map_sg(drive, rq); | ||
220 | |||
221 | if (rq_data_dir(rq) == READ) | ||
222 | hwif->sg_dma_direction = DMA_FROM_DEVICE; | ||
223 | else | ||
224 | hwif->sg_dma_direction = DMA_TO_DEVICE; | ||
225 | |||
226 | return dma_map_sg(ahwif->dev, sg, hwif->sg_nents, | ||
227 | hwif->sg_dma_direction); | ||
228 | } | ||
229 | |||
230 | static int auide_build_dmatable(ide_drive_t *drive) | 209 | static int auide_build_dmatable(ide_drive_t *drive) |
231 | { | 210 | { |
232 | int i, iswrite, count = 0; | 211 | int i, iswrite, count = 0; |
@@ -241,8 +220,7 @@ static int auide_build_dmatable(ide_drive_t *drive) | |||
241 | /* Save for interrupt context */ | 220 | /* Save for interrupt context */ |
242 | ahwif->drive = drive; | 221 | ahwif->drive = drive; |
243 | 222 | ||
244 | /* Build sglist */ | 223 | hwif->sg_nents = i = ide_build_sglist(drive, rq); |
245 | hwif->sg_nents = i = auide_build_sglist(drive, rq); | ||
246 | 224 | ||
247 | if (!i) | 225 | if (!i) |
248 | return 0; | 226 | return 0; |
@@ -300,10 +278,7 @@ static int auide_build_dmatable(ide_drive_t *drive) | |||
300 | return 1; | 278 | return 1; |
301 | 279 | ||
302 | use_pio_instead: | 280 | use_pio_instead: |
303 | dma_unmap_sg(ahwif->dev, | 281 | ide_destroy_dmatable(drive); |
304 | hwif->sg_table, | ||
305 | hwif->sg_nents, | ||
306 | hwif->sg_dma_direction); | ||
307 | 282 | ||
308 | return 0; /* revert to PIO for this request */ | 283 | return 0; /* revert to PIO for this request */ |
309 | } | 284 | } |
@@ -311,11 +286,9 @@ static int auide_build_dmatable(ide_drive_t *drive) | |||
311 | static int auide_dma_end(ide_drive_t *drive) | 286 | static int auide_dma_end(ide_drive_t *drive) |
312 | { | 287 | { |
313 | ide_hwif_t *hwif = HWIF(drive); | 288 | ide_hwif_t *hwif = HWIF(drive); |
314 | _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data; | ||
315 | 289 | ||
316 | if (hwif->sg_nents) { | 290 | if (hwif->sg_nents) { |
317 | dma_unmap_sg(ahwif->dev, hwif->sg_table, hwif->sg_nents, | 291 | ide_destroy_dmatable(drive); |
318 | hwif->sg_dma_direction); | ||
319 | hwif->sg_nents = 0; | 292 | hwif->sg_nents = 0; |
320 | } | 293 | } |
321 | 294 | ||
@@ -504,7 +477,7 @@ static int auide_ddma_init(_auide_hwif *auide) { | |||
504 | auide->rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->rx_chan, | 477 | auide->rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->rx_chan, |
505 | NUM_DESCRIPTORS); | 478 | NUM_DESCRIPTORS); |
506 | 479 | ||
507 | hwif->dmatable_cpu = dma_alloc_coherent(auide->dev, | 480 | hwif->dmatable_cpu = dma_alloc_coherent(hwif->dev, |
508 | PRD_ENTRIES * PRD_BYTES, /* 1 Page */ | 481 | PRD_ENTRIES * PRD_BYTES, /* 1 Page */ |
509 | &hwif->dmatable_dma, GFP_KERNEL); | 482 | &hwif->dmatable_dma, GFP_KERNEL); |
510 | 483 | ||
@@ -592,9 +565,6 @@ static int au_ide_probe(struct device *dev) | |||
592 | #endif | 565 | #endif |
593 | 566 | ||
594 | memset(&auide_hwif, 0, sizeof(_auide_hwif)); | 567 | memset(&auide_hwif, 0, sizeof(_auide_hwif)); |
595 | auide_hwif.dev = 0; | ||
596 | |||
597 | ahwif->dev = dev; | ||
598 | ahwif->irq = platform_get_irq(pdev, 0); | 568 | ahwif->irq = platform_get_irq(pdev, 0); |
599 | 569 | ||
600 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 570 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -629,10 +599,13 @@ static int au_ide_probe(struct device *dev) | |||
629 | memset(&hw, 0, sizeof(hw)); | 599 | memset(&hw, 0, sizeof(hw)); |
630 | auide_setup_ports(&hw, ahwif); | 600 | auide_setup_ports(&hw, ahwif); |
631 | hw.irq = ahwif->irq; | 601 | hw.irq = ahwif->irq; |
602 | hw.dev = dev; | ||
632 | hw.chipset = ide_au1xxx; | 603 | hw.chipset = ide_au1xxx; |
633 | 604 | ||
634 | ide_init_port_hw(hwif, &hw); | 605 | ide_init_port_hw(hwif, &hw); |
635 | 606 | ||
607 | hwif->dev = dev; | ||
608 | |||
636 | hwif->ultra_mask = 0x0; /* Disable Ultra DMA */ | 609 | hwif->ultra_mask = 0x0; /* Disable Ultra DMA */ |
637 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | 610 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA |
638 | hwif->mwdma_mask = 0x07; /* Multimode-2 DMA */ | 611 | hwif->mwdma_mask = 0x07; /* Multimode-2 DMA */ |
@@ -715,7 +688,7 @@ static int au_ide_remove(struct device *dev) | |||
715 | ide_hwif_t *hwif = dev_get_drvdata(dev); | 688 | ide_hwif_t *hwif = dev_get_drvdata(dev); |
716 | _auide_hwif *ahwif = &auide_hwif; | 689 | _auide_hwif *ahwif = &auide_hwif; |
717 | 690 | ||
718 | ide_unregister(hwif - ide_hwifs); | 691 | ide_unregister(hwif->index); |
719 | 692 | ||
720 | iounmap((void *)ahwif->regbase); | 693 | iounmap((void *)ahwif->regbase); |
721 | 694 | ||
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c index 7f4d1857d555..824df78c7012 100644 --- a/drivers/ide/pci/aec62xx.c +++ b/drivers/ide/pci/aec62xx.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/aec62xx.c Version 0.27 Sep 16, 2007 | ||
3 | * | ||
4 | * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org> | 2 | * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org> |
5 | * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com> | 3 | * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com> |
6 | * | 4 | * |
@@ -90,7 +88,7 @@ static u8 pci_bus_clock_list_ultra (u8 speed, struct chipset_bus_clock_list_entr | |||
90 | static void aec6210_set_mode(ide_drive_t *drive, const u8 speed) | 88 | static void aec6210_set_mode(ide_drive_t *drive, const u8 speed) |
91 | { | 89 | { |
92 | ide_hwif_t *hwif = HWIF(drive); | 90 | ide_hwif_t *hwif = HWIF(drive); |
93 | struct pci_dev *dev = hwif->pci_dev; | 91 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
94 | u16 d_conf = 0; | 92 | u16 d_conf = 0; |
95 | u8 ultra = 0, ultra_conf = 0; | 93 | u8 ultra = 0, ultra_conf = 0; |
96 | u8 tmp0 = 0, tmp1 = 0, tmp2 = 0; | 94 | u8 tmp0 = 0, tmp1 = 0, tmp2 = 0; |
@@ -116,7 +114,7 @@ static void aec6210_set_mode(ide_drive_t *drive, const u8 speed) | |||
116 | static void aec6260_set_mode(ide_drive_t *drive, const u8 speed) | 114 | static void aec6260_set_mode(ide_drive_t *drive, const u8 speed) |
117 | { | 115 | { |
118 | ide_hwif_t *hwif = HWIF(drive); | 116 | ide_hwif_t *hwif = HWIF(drive); |
119 | struct pci_dev *dev = hwif->pci_dev; | 117 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
120 | u8 unit = (drive->select.b.unit & 0x01); | 118 | u8 unit = (drive->select.b.unit & 0x01); |
121 | u8 tmp1 = 0, tmp2 = 0; | 119 | u8 tmp1 = 0, tmp2 = 0; |
122 | u8 ultra = 0, drive_conf = 0, ultra_conf = 0; | 120 | u8 ultra = 0, drive_conf = 0, ultra_conf = 0; |
@@ -170,7 +168,7 @@ static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const ch | |||
170 | 168 | ||
171 | static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) | 169 | static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) |
172 | { | 170 | { |
173 | struct pci_dev *dev = hwif->pci_dev; | 171 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
174 | 172 | ||
175 | hwif->set_pio_mode = &aec_set_pio_mode; | 173 | hwif->set_pio_mode = &aec_set_pio_mode; |
176 | 174 | ||
@@ -188,7 +186,7 @@ static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) | |||
188 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) { | 186 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) { |
189 | u8 ata66 = 0, mask = hwif->channel ? 0x02 : 0x01; | 187 | u8 ata66 = 0, mask = hwif->channel ? 0x02 : 0x01; |
190 | 188 | ||
191 | pci_read_config_byte(hwif->pci_dev, 0x49, &ata66); | 189 | pci_read_config_byte(dev, 0x49, &ata66); |
192 | 190 | ||
193 | hwif->cbl = (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | 191 | hwif->cbl = (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; |
194 | } | 192 | } |
@@ -202,6 +200,7 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
202 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, | 200 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, |
203 | .host_flags = IDE_HFLAG_SERIALIZE | | 201 | .host_flags = IDE_HFLAG_SERIALIZE | |
204 | IDE_HFLAG_NO_ATAPI_DMA | | 202 | IDE_HFLAG_NO_ATAPI_DMA | |
203 | IDE_HFLAG_NO_DSC | | ||
205 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | 204 | IDE_HFLAG_ABUSE_SET_DMA_MODE | |
206 | IDE_HFLAG_OFF_BOARD, | 205 | IDE_HFLAG_OFF_BOARD, |
207 | .pio_mask = ATA_PIO4, | 206 | .pio_mask = ATA_PIO4, |
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index 49aa82e412b6..130cc6e784e5 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/alim15x3.c Version 0.29 Sep 16 2007 | ||
3 | * | ||
4 | * Copyright (C) 1998-2000 Michel Aubry, Maintainer | 2 | * Copyright (C) 1998-2000 Michel Aubry, Maintainer |
5 | * Copyright (C) 1998-2000 Andrzej Krzysztofowicz, Maintainer | 3 | * Copyright (C) 1998-2000 Andrzej Krzysztofowicz, Maintainer |
6 | * Copyright (C) 1999-2000 CJ, cjtsai@ali.com.tw, Maintainer | 4 | * Copyright (C) 1999-2000 CJ, cjtsai@ali.com.tw, Maintainer |
@@ -293,7 +291,7 @@ static int ali_get_info (char *buffer, char **addr, off_t offset, int count) | |||
293 | static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio) | 291 | static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio) |
294 | { | 292 | { |
295 | ide_hwif_t *hwif = HWIF(drive); | 293 | ide_hwif_t *hwif = HWIF(drive); |
296 | struct pci_dev *dev = hwif->pci_dev; | 294 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
297 | int s_time, a_time, c_time; | 295 | int s_time, a_time, c_time; |
298 | u8 s_clc, a_clc, r_clc; | 296 | u8 s_clc, a_clc, r_clc; |
299 | unsigned long flags; | 297 | unsigned long flags; |
@@ -396,7 +394,7 @@ static u8 ali_udma_filter(ide_drive_t *drive) | |||
396 | static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed) | 394 | static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed) |
397 | { | 395 | { |
398 | ide_hwif_t *hwif = HWIF(drive); | 396 | ide_hwif_t *hwif = HWIF(drive); |
399 | struct pci_dev *dev = hwif->pci_dev; | 397 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
400 | u8 speed1 = speed; | 398 | u8 speed1 = speed; |
401 | u8 unit = (drive->select.b.unit & 0x01); | 399 | u8 unit = (drive->select.b.unit & 0x01); |
402 | u8 tmpbyte = 0x00; | 400 | u8 tmpbyte = 0x00; |
@@ -625,7 +623,7 @@ static int ali_cable_override(struct pci_dev *pdev) | |||
625 | 623 | ||
626 | static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif) | 624 | static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif) |
627 | { | 625 | { |
628 | struct pci_dev *dev = hwif->pci_dev; | 626 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
629 | unsigned long flags; | 627 | unsigned long flags; |
630 | u8 cbl = ATA_CBL_PATA40, tmpbyte; | 628 | u8 cbl = ATA_CBL_PATA40, tmpbyte; |
631 | 629 | ||
@@ -688,12 +686,13 @@ static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif) | |||
688 | 686 | ||
689 | static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif) | 687 | static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif) |
690 | { | 688 | { |
689 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
691 | u8 ideic, inmir; | 690 | u8 ideic, inmir; |
692 | s8 irq_routing_table[] = { -1, 9, 3, 10, 4, 5, 7, 6, | 691 | s8 irq_routing_table[] = { -1, 9, 3, 10, 4, 5, 7, 6, |
693 | 1, 11, 0, 12, 0, 14, 0, 15 }; | 692 | 1, 11, 0, 12, 0, 14, 0, 15 }; |
694 | int irq = -1; | 693 | int irq = -1; |
695 | 694 | ||
696 | if (hwif->pci_dev->device == PCI_DEVICE_ID_AL_M5229) | 695 | if (dev->device == PCI_DEVICE_ID_AL_M5229) |
697 | hwif->irq = hwif->channel ? 15 : 14; | 696 | hwif->irq = hwif->channel ? 15 : 14; |
698 | 697 | ||
699 | if (isa_dev) { | 698 | if (isa_dev) { |
@@ -745,7 +744,7 @@ static void __devinit init_dma_ali15x3 (ide_hwif_t *hwif, unsigned long dmabase) | |||
745 | return; | 744 | return; |
746 | if (!hwif->channel) | 745 | if (!hwif->channel) |
747 | outb(inb(dmabase + 2) & 0x60, dmabase + 2); | 746 | outb(inb(dmabase + 2) & 0x60, dmabase + 2); |
748 | ide_setup_dma(hwif, dmabase, 8); | 747 | ide_setup_dma(hwif, dmabase); |
749 | } | 748 | } |
750 | 749 | ||
751 | static const struct ide_port_info ali15x3_chipset __devinitdata = { | 750 | static const struct ide_port_info ali15x3_chipset __devinitdata = { |
@@ -775,7 +774,7 @@ static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_dev | |||
775 | }; | 774 | }; |
776 | 775 | ||
777 | struct ide_port_info d = ali15x3_chipset; | 776 | struct ide_port_info d = ali15x3_chipset; |
778 | u8 rev = dev->revision; | 777 | u8 rev = dev->revision, idx = id->driver_data; |
779 | 778 | ||
780 | if (pci_dev_present(ati_rs100)) | 779 | if (pci_dev_present(ati_rs100)) |
781 | printk(KERN_WARNING "alim15x3: ATI Radeon IGP Northbridge is not yet fully tested.\n"); | 780 | printk(KERN_WARNING "alim15x3: ATI Radeon IGP Northbridge is not yet fully tested.\n"); |
@@ -798,6 +797,9 @@ static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_dev | |||
798 | d.udma_mask = ATA_UDMA6; | 797 | d.udma_mask = ATA_UDMA6; |
799 | } | 798 | } |
800 | 799 | ||
800 | if (idx == 0) | ||
801 | d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; | ||
802 | |||
801 | #if defined(CONFIG_SPARC64) | 803 | #if defined(CONFIG_SPARC64) |
802 | d.init_hwif = init_hwif_common_ali15x3; | 804 | d.init_hwif = init_hwif_common_ali15x3; |
803 | #endif /* CONFIG_SPARC64 */ | 805 | #endif /* CONFIG_SPARC64 */ |
@@ -807,7 +809,7 @@ static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_dev | |||
807 | 809 | ||
808 | static const struct pci_device_id alim15x3_pci_tbl[] = { | 810 | static const struct pci_device_id alim15x3_pci_tbl[] = { |
809 | { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5229), 0 }, | 811 | { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5229), 0 }, |
810 | { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), 0 }, | 812 | { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), 1 }, |
811 | { 0, }, | 813 | { 0, }, |
812 | }; | 814 | }; |
813 | MODULE_DEVICE_TABLE(pci, alim15x3_pci_tbl); | 815 | MODULE_DEVICE_TABLE(pci, alim15x3_pci_tbl); |
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index cee51fdafcf6..8c52bc9eaa59 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Version 2.24 | ||
3 | * | ||
4 | * AMD 755/756/766/8111 and nVidia nForce/2/2s/3/3s/CK804/MCP04 | 2 | * AMD 755/756/766/8111 and nVidia nForce/2/2s/3/3s/CK804/MCP04 |
5 | * IDE driver for Linux. | 3 | * IDE driver for Linux. |
6 | * | 4 | * |
@@ -28,81 +26,46 @@ | |||
28 | 26 | ||
29 | #include "ide-timing.h" | 27 | #include "ide-timing.h" |
30 | 28 | ||
31 | #define AMD_IDE_CONFIG (0x01 + amd_config->base) | 29 | enum { |
32 | #define AMD_CABLE_DETECT (0x02 + amd_config->base) | 30 | AMD_IDE_CONFIG = 0x41, |
33 | #define AMD_DRIVE_TIMING (0x08 + amd_config->base) | 31 | AMD_CABLE_DETECT = 0x42, |
34 | #define AMD_8BIT_TIMING (0x0e + amd_config->base) | 32 | AMD_DRIVE_TIMING = 0x48, |
35 | #define AMD_ADDRESS_SETUP (0x0c + amd_config->base) | 33 | AMD_8BIT_TIMING = 0x4e, |
36 | #define AMD_UDMA_TIMING (0x10 + amd_config->base) | 34 | AMD_ADDRESS_SETUP = 0x4c, |
37 | 35 | AMD_UDMA_TIMING = 0x50, | |
38 | #define AMD_CHECK_SWDMA 0x08 | ||
39 | #define AMD_BAD_SWDMA 0x10 | ||
40 | #define AMD_BAD_FIFO 0x20 | ||
41 | #define AMD_CHECK_SERENADE 0x40 | ||
42 | |||
43 | /* | ||
44 | * AMD SouthBridge chips. | ||
45 | */ | ||
46 | |||
47 | static struct amd_ide_chip { | ||
48 | unsigned short id; | ||
49 | u8 base; | ||
50 | u8 udma_mask; | ||
51 | u8 flags; | ||
52 | } amd_ide_chips[] = { | ||
53 | { PCI_DEVICE_ID_AMD_COBRA_7401, 0x40, ATA_UDMA2, AMD_BAD_SWDMA }, | ||
54 | { PCI_DEVICE_ID_AMD_VIPER_7409, 0x40, ATA_UDMA4, AMD_CHECK_SWDMA }, | ||
55 | { PCI_DEVICE_ID_AMD_VIPER_7411, 0x40, ATA_UDMA5, AMD_BAD_FIFO }, | ||
56 | { PCI_DEVICE_ID_AMD_OPUS_7441, 0x40, ATA_UDMA5, }, | ||
57 | { PCI_DEVICE_ID_AMD_8111_IDE, 0x40, ATA_UDMA6, AMD_CHECK_SERENADE }, | ||
58 | { PCI_DEVICE_ID_NVIDIA_NFORCE_IDE, 0x50, ATA_UDMA5, }, | ||
59 | { PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE, 0x50, ATA_UDMA6, }, | ||
60 | { PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE, 0x50, ATA_UDMA6, }, | ||
61 | { PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA, 0x50, ATA_UDMA6, }, | ||
62 | { PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE, 0x50, ATA_UDMA6, }, | ||
63 | { PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE, 0x50, ATA_UDMA6, }, | ||
64 | { PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA, 0x50, ATA_UDMA6, }, | ||
65 | { PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2, 0x50, ATA_UDMA6, }, | ||
66 | { PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, 0x50, ATA_UDMA6, }, | ||
67 | { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, 0x50, ATA_UDMA6, }, | ||
68 | { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, 0x50, ATA_UDMA6, }, | ||
69 | { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, 0x50, ATA_UDMA6, }, | ||
70 | { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, 0x50, ATA_UDMA6, }, | ||
71 | { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, 0x50, ATA_UDMA6, }, | ||
72 | { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, 0x50, ATA_UDMA6, }, | ||
73 | { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE, 0x50, ATA_UDMA6, }, | ||
74 | { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE, 0x50, ATA_UDMA6, }, | ||
75 | { PCI_DEVICE_ID_AMD_CS5536_IDE, 0x40, ATA_UDMA5, }, | ||
76 | { 0 } | ||
77 | }; | 36 | }; |
78 | 37 | ||
79 | static struct amd_ide_chip *amd_config; | ||
80 | static const struct ide_port_info *amd_chipset; | ||
81 | static unsigned int amd_80w; | 38 | static unsigned int amd_80w; |
82 | static unsigned int amd_clock; | 39 | static unsigned int amd_clock; |
83 | 40 | ||
84 | static char *amd_dma[] = { "16", "25", "33", "44", "66", "100", "133" }; | 41 | static char *amd_dma[] = { "16", "25", "33", "44", "66", "100", "133" }; |
85 | static unsigned char amd_cyc2udma[] = { 6, 6, 5, 4, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 7 }; | 42 | static unsigned char amd_cyc2udma[] = { 6, 6, 5, 4, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 7 }; |
86 | 43 | ||
44 | static inline u8 amd_offset(struct pci_dev *dev) | ||
45 | { | ||
46 | return (dev->vendor == PCI_VENDOR_ID_NVIDIA) ? 0x10 : 0; | ||
47 | } | ||
48 | |||
87 | /* | 49 | /* |
88 | * amd_set_speed() writes timing values to the chipset registers | 50 | * amd_set_speed() writes timing values to the chipset registers |
89 | */ | 51 | */ |
90 | 52 | ||
91 | static void amd_set_speed(struct pci_dev *dev, unsigned char dn, struct ide_timing *timing) | 53 | static void amd_set_speed(struct pci_dev *dev, u8 dn, u8 udma_mask, |
54 | struct ide_timing *timing) | ||
92 | { | 55 | { |
93 | unsigned char t; | 56 | u8 t = 0, offset = amd_offset(dev); |
94 | 57 | ||
95 | pci_read_config_byte(dev, AMD_ADDRESS_SETUP, &t); | 58 | pci_read_config_byte(dev, AMD_ADDRESS_SETUP + offset, &t); |
96 | t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); | 59 | t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); |
97 | pci_write_config_byte(dev, AMD_ADDRESS_SETUP, t); | 60 | pci_write_config_byte(dev, AMD_ADDRESS_SETUP + offset, t); |
98 | 61 | ||
99 | pci_write_config_byte(dev, AMD_8BIT_TIMING + (1 - (dn >> 1)), | 62 | pci_write_config_byte(dev, AMD_8BIT_TIMING + offset + (1 - (dn >> 1)), |
100 | ((FIT(timing->act8b, 1, 16) - 1) << 4) | (FIT(timing->rec8b, 1, 16) - 1)); | 63 | ((FIT(timing->act8b, 1, 16) - 1) << 4) | (FIT(timing->rec8b, 1, 16) - 1)); |
101 | 64 | ||
102 | pci_write_config_byte(dev, AMD_DRIVE_TIMING + (3 - dn), | 65 | pci_write_config_byte(dev, AMD_DRIVE_TIMING + offset + (3 - dn), |
103 | ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1)); | 66 | ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1)); |
104 | 67 | ||
105 | switch (amd_config->udma_mask) { | 68 | switch (udma_mask) { |
106 | case ATA_UDMA2: t = timing->udma ? (0xc0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; | 69 | case ATA_UDMA2: t = timing->udma ? (0xc0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; |
107 | case ATA_UDMA4: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 2, 10)]) : 0x03; break; | 70 | case ATA_UDMA4: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 2, 10)]) : 0x03; break; |
108 | case ATA_UDMA5: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 1, 10)]) : 0x03; break; | 71 | case ATA_UDMA5: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 1, 10)]) : 0x03; break; |
@@ -110,7 +73,7 @@ static void amd_set_speed(struct pci_dev *dev, unsigned char dn, struct ide_timi | |||
110 | default: return; | 73 | default: return; |
111 | } | 74 | } |
112 | 75 | ||
113 | pci_write_config_byte(dev, AMD_UDMA_TIMING + (3 - dn), t); | 76 | pci_write_config_byte(dev, AMD_UDMA_TIMING + offset + (3 - dn), t); |
114 | } | 77 | } |
115 | 78 | ||
116 | /* | 79 | /* |
@@ -120,12 +83,15 @@ static void amd_set_speed(struct pci_dev *dev, unsigned char dn, struct ide_timi | |||
120 | 83 | ||
121 | static void amd_set_drive(ide_drive_t *drive, const u8 speed) | 84 | static void amd_set_drive(ide_drive_t *drive, const u8 speed) |
122 | { | 85 | { |
123 | ide_drive_t *peer = HWIF(drive)->drives + (~drive->dn & 1); | 86 | ide_hwif_t *hwif = drive->hwif; |
87 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
88 | ide_drive_t *peer = hwif->drives + (~drive->dn & 1); | ||
124 | struct ide_timing t, p; | 89 | struct ide_timing t, p; |
125 | int T, UT; | 90 | int T, UT; |
91 | u8 udma_mask = hwif->ultra_mask; | ||
126 | 92 | ||
127 | T = 1000000000 / amd_clock; | 93 | T = 1000000000 / amd_clock; |
128 | UT = (amd_config->udma_mask == ATA_UDMA2) ? T : (T / 2); | 94 | UT = (udma_mask == ATA_UDMA2) ? T : (T / 2); |
129 | 95 | ||
130 | ide_timing_compute(drive, speed, &t, T, UT); | 96 | ide_timing_compute(drive, speed, &t, T, UT); |
131 | 97 | ||
@@ -137,7 +103,7 @@ static void amd_set_drive(ide_drive_t *drive, const u8 speed) | |||
137 | if (speed == XFER_UDMA_5 && amd_clock <= 33333) t.udma = 1; | 103 | if (speed == XFER_UDMA_5 && amd_clock <= 33333) t.udma = 1; |
138 | if (speed == XFER_UDMA_6 && amd_clock <= 33333) t.udma = 15; | 104 | if (speed == XFER_UDMA_6 && amd_clock <= 33333) t.udma = 15; |
139 | 105 | ||
140 | amd_set_speed(HWIF(drive)->pci_dev, drive->dn, &t); | 106 | amd_set_speed(dev, drive->dn, udma_mask, &t); |
141 | } | 107 | } |
142 | 108 | ||
143 | /* | 109 | /* |
@@ -149,67 +115,68 @@ static void amd_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
149 | amd_set_drive(drive, XFER_PIO_0 + pio); | 115 | amd_set_drive(drive, XFER_PIO_0 + pio); |
150 | } | 116 | } |
151 | 117 | ||
152 | /* | 118 | static void __devinit amd7409_cable_detect(struct pci_dev *dev, |
153 | * The initialization callback. Here we determine the IDE chip type | 119 | const char *name) |
154 | * and initialize its drive independent registers. | 120 | { |
155 | */ | 121 | /* no host side cable detection */ |
122 | amd_80w = 0x03; | ||
123 | } | ||
156 | 124 | ||
157 | static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, const char *name) | 125 | static void __devinit amd7411_cable_detect(struct pci_dev *dev, |
126 | const char *name) | ||
158 | { | 127 | { |
159 | unsigned char t; | ||
160 | unsigned int u; | ||
161 | int i; | 128 | int i; |
129 | u32 u = 0; | ||
130 | u8 t = 0, offset = amd_offset(dev); | ||
131 | |||
132 | pci_read_config_byte(dev, AMD_CABLE_DETECT + offset, &t); | ||
133 | pci_read_config_dword(dev, AMD_UDMA_TIMING + offset, &u); | ||
134 | amd_80w = ((t & 0x3) ? 1 : 0) | ((t & 0xc) ? 2 : 0); | ||
135 | for (i = 24; i >= 0; i -= 8) | ||
136 | if (((u >> i) & 4) && !(amd_80w & (1 << (1 - (i >> 4))))) { | ||
137 | printk(KERN_WARNING "%s: BIOS didn't set cable bits " | ||
138 | "correctly. Enabling workaround.\n", | ||
139 | name); | ||
140 | amd_80w |= (1 << (1 - (i >> 4))); | ||
141 | } | ||
142 | } | ||
162 | 143 | ||
163 | /* | 144 | /* |
164 | * Check for bad SWDMA. | 145 | * The initialization callback. Initialize drive independent registers. |
165 | */ | 146 | */ |
166 | 147 | ||
167 | if (amd_config->flags & AMD_CHECK_SWDMA) { | 148 | static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, |
168 | if (dev->revision <= 7) | 149 | const char *name) |
169 | amd_config->flags |= AMD_BAD_SWDMA; | 150 | { |
170 | } | 151 | u8 t = 0, offset = amd_offset(dev); |
171 | 152 | ||
172 | /* | 153 | /* |
173 | * Check 80-wire cable presence. | 154 | * Check 80-wire cable presence. |
174 | */ | 155 | */ |
175 | 156 | ||
176 | switch (amd_config->udma_mask) { | 157 | if (dev->vendor == PCI_VENDOR_ID_AMD && |
177 | 158 | dev->device == PCI_DEVICE_ID_AMD_COBRA_7401) | |
178 | case ATA_UDMA6: | 159 | ; /* no UDMA > 2 */ |
179 | case ATA_UDMA5: | 160 | else if (dev->vendor == PCI_VENDOR_ID_AMD && |
180 | pci_read_config_byte(dev, AMD_CABLE_DETECT, &t); | 161 | dev->device == PCI_DEVICE_ID_AMD_VIPER_7409) |
181 | pci_read_config_dword(dev, AMD_UDMA_TIMING, &u); | 162 | amd7409_cable_detect(dev, name); |
182 | amd_80w = ((t & 0x3) ? 1 : 0) | ((t & 0xc) ? 2 : 0); | 163 | else |
183 | for (i = 24; i >= 0; i -= 8) | 164 | amd7411_cable_detect(dev, name); |
184 | if (((u >> i) & 4) && !(amd_80w & (1 << (1 - (i >> 4))))) { | ||
185 | printk(KERN_WARNING "%s: BIOS didn't set cable bits correctly. Enabling workaround.\n", | ||
186 | amd_chipset->name); | ||
187 | amd_80w |= (1 << (1 - (i >> 4))); | ||
188 | } | ||
189 | break; | ||
190 | |||
191 | case ATA_UDMA4: | ||
192 | /* no host side cable detection */ | ||
193 | amd_80w = 0x03; | ||
194 | break; | ||
195 | } | ||
196 | 165 | ||
197 | /* | 166 | /* |
198 | * Take care of prefetch & postwrite. | 167 | * Take care of prefetch & postwrite. |
199 | */ | 168 | */ |
200 | 169 | ||
201 | pci_read_config_byte(dev, AMD_IDE_CONFIG, &t); | 170 | pci_read_config_byte(dev, AMD_IDE_CONFIG + offset, &t); |
202 | pci_write_config_byte(dev, AMD_IDE_CONFIG, | 171 | /* |
203 | (amd_config->flags & AMD_BAD_FIFO) ? (t & 0x0f) : (t | 0xf0)); | 172 | * Check for broken FIFO support. |
204 | 173 | */ | |
205 | /* | 174 | if (dev->vendor == PCI_VENDOR_ID_AMD && |
206 | * Take care of incorrectly wired Serenade mainboards. | 175 | dev->vendor == PCI_DEVICE_ID_AMD_VIPER_7411) |
207 | */ | 176 | t &= 0x0f; |
208 | 177 | else | |
209 | if ((amd_config->flags & AMD_CHECK_SERENADE) && | 178 | t |= 0xf0; |
210 | dev->subsystem_vendor == PCI_VENDOR_ID_AMD && | 179 | pci_write_config_byte(dev, AMD_IDE_CONFIG + offset, t); |
211 | dev->subsystem_device == PCI_DEVICE_ID_AMD_SERENADE) | ||
212 | amd_config->udma_mask = ATA_UDMA5; | ||
213 | 180 | ||
214 | /* | 181 | /* |
215 | * Determine the system bus clock. | 182 | * Determine the system bus clock. |
@@ -225,25 +192,19 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, const ch | |||
225 | 192 | ||
226 | if (amd_clock < 20000 || amd_clock > 50000) { | 193 | if (amd_clock < 20000 || amd_clock > 50000) { |
227 | printk(KERN_WARNING "%s: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", | 194 | printk(KERN_WARNING "%s: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", |
228 | amd_chipset->name, amd_clock); | 195 | name, amd_clock); |
229 | amd_clock = 33333; | 196 | amd_clock = 33333; |
230 | } | 197 | } |
231 | 198 | ||
232 | /* | ||
233 | * Print the boot message. | ||
234 | */ | ||
235 | |||
236 | printk(KERN_INFO "%s: %s (rev %02x) UDMA%s controller\n", | ||
237 | amd_chipset->name, pci_name(dev), dev->revision, | ||
238 | amd_dma[fls(amd_config->udma_mask) - 1]); | ||
239 | |||
240 | return dev->irq; | 199 | return dev->irq; |
241 | } | 200 | } |
242 | 201 | ||
243 | static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | 202 | static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) |
244 | { | 203 | { |
204 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
205 | |||
245 | if (hwif->irq == 0) /* 0 is bogus but will do for now */ | 206 | if (hwif->irq == 0) /* 0 is bogus but will do for now */ |
246 | hwif->irq = pci_get_legacy_ide_irq(hwif->pci_dev, hwif->channel); | 207 | hwif->irq = pci_get_legacy_ide_irq(dev, hwif->channel); |
247 | 208 | ||
248 | hwif->set_pio_mode = &amd_set_pio_mode; | 209 | hwif->set_pio_mode = &amd_set_pio_mode; |
249 | hwif->set_dma_mode = &amd_set_drive; | 210 | hwif->set_dma_mode = &amd_set_drive; |
@@ -251,10 +212,6 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | |||
251 | if (!hwif->dma_base) | 212 | if (!hwif->dma_base) |
252 | return; | 213 | return; |
253 | 214 | ||
254 | hwif->ultra_mask = amd_config->udma_mask; | ||
255 | if (amd_config->flags & AMD_BAD_SWDMA) | ||
256 | hwif->swdma_mask = 0x00; | ||
257 | |||
258 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) { | 215 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) { |
259 | if ((amd_80w >> hwif->channel) & 1) | 216 | if ((amd_80w >> hwif->channel) & 1) |
260 | hwif->cbl = ATA_CBL_PATA80; | 217 | hwif->cbl = ATA_CBL_PATA80; |
@@ -272,7 +229,7 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | |||
272 | IDE_HFLAG_UNMASK_IRQS | \ | 229 | IDE_HFLAG_UNMASK_IRQS | \ |
273 | IDE_HFLAG_BOOTABLE) | 230 | IDE_HFLAG_BOOTABLE) |
274 | 231 | ||
275 | #define DECLARE_AMD_DEV(name_str) \ | 232 | #define DECLARE_AMD_DEV(name_str, swdma, udma) \ |
276 | { \ | 233 | { \ |
277 | .name = name_str, \ | 234 | .name = name_str, \ |
278 | .init_chipset = init_chipset_amd74xx, \ | 235 | .init_chipset = init_chipset_amd74xx, \ |
@@ -280,11 +237,12 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | |||
280 | .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ | 237 | .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ |
281 | .host_flags = IDE_HFLAGS_AMD, \ | 238 | .host_flags = IDE_HFLAGS_AMD, \ |
282 | .pio_mask = ATA_PIO5, \ | 239 | .pio_mask = ATA_PIO5, \ |
283 | .swdma_mask = ATA_SWDMA2, \ | 240 | .swdma_mask = swdma, \ |
284 | .mwdma_mask = ATA_MWDMA2, \ | 241 | .mwdma_mask = ATA_MWDMA2, \ |
242 | .udma_mask = udma, \ | ||
285 | } | 243 | } |
286 | 244 | ||
287 | #define DECLARE_NV_DEV(name_str) \ | 245 | #define DECLARE_NV_DEV(name_str, udma) \ |
288 | { \ | 246 | { \ |
289 | .name = name_str, \ | 247 | .name = name_str, \ |
290 | .init_chipset = init_chipset_amd74xx, \ | 248 | .init_chipset = init_chipset_amd74xx, \ |
@@ -294,45 +252,62 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | |||
294 | .pio_mask = ATA_PIO5, \ | 252 | .pio_mask = ATA_PIO5, \ |
295 | .swdma_mask = ATA_SWDMA2, \ | 253 | .swdma_mask = ATA_SWDMA2, \ |
296 | .mwdma_mask = ATA_MWDMA2, \ | 254 | .mwdma_mask = ATA_MWDMA2, \ |
255 | .udma_mask = udma, \ | ||
297 | } | 256 | } |
298 | 257 | ||
299 | static const struct ide_port_info amd74xx_chipsets[] __devinitdata = { | 258 | static const struct ide_port_info amd74xx_chipsets[] __devinitdata = { |
300 | /* 0 */ DECLARE_AMD_DEV("AMD7401"), | 259 | /* 0 */ DECLARE_AMD_DEV("AMD7401", 0x00, ATA_UDMA2), |
301 | /* 1 */ DECLARE_AMD_DEV("AMD7409"), | 260 | /* 1 */ DECLARE_AMD_DEV("AMD7409", ATA_SWDMA2, ATA_UDMA4), |
302 | /* 2 */ DECLARE_AMD_DEV("AMD7411"), | 261 | /* 2 */ DECLARE_AMD_DEV("AMD7411", ATA_SWDMA2, ATA_UDMA5), |
303 | /* 3 */ DECLARE_AMD_DEV("AMD7441"), | 262 | /* 3 */ DECLARE_AMD_DEV("AMD7441", ATA_SWDMA2, ATA_UDMA5), |
304 | /* 4 */ DECLARE_AMD_DEV("AMD8111"), | 263 | /* 4 */ DECLARE_AMD_DEV("AMD8111", ATA_SWDMA2, ATA_UDMA6), |
305 | 264 | ||
306 | /* 5 */ DECLARE_NV_DEV("NFORCE"), | 265 | /* 5 */ DECLARE_NV_DEV("NFORCE", ATA_UDMA5), |
307 | /* 6 */ DECLARE_NV_DEV("NFORCE2"), | 266 | /* 6 */ DECLARE_NV_DEV("NFORCE2", ATA_UDMA6), |
308 | /* 7 */ DECLARE_NV_DEV("NFORCE2-U400R"), | 267 | /* 7 */ DECLARE_NV_DEV("NFORCE2-U400R", ATA_UDMA6), |
309 | /* 8 */ DECLARE_NV_DEV("NFORCE2-U400R-SATA"), | 268 | /* 8 */ DECLARE_NV_DEV("NFORCE2-U400R-SATA", ATA_UDMA6), |
310 | /* 9 */ DECLARE_NV_DEV("NFORCE3-150"), | 269 | /* 9 */ DECLARE_NV_DEV("NFORCE3-150", ATA_UDMA6), |
311 | /* 10 */ DECLARE_NV_DEV("NFORCE3-250"), | 270 | /* 10 */ DECLARE_NV_DEV("NFORCE3-250", ATA_UDMA6), |
312 | /* 11 */ DECLARE_NV_DEV("NFORCE3-250-SATA"), | 271 | /* 11 */ DECLARE_NV_DEV("NFORCE3-250-SATA", ATA_UDMA6), |
313 | /* 12 */ DECLARE_NV_DEV("NFORCE3-250-SATA2"), | 272 | /* 12 */ DECLARE_NV_DEV("NFORCE3-250-SATA2", ATA_UDMA6), |
314 | /* 13 */ DECLARE_NV_DEV("NFORCE-CK804"), | 273 | /* 13 */ DECLARE_NV_DEV("NFORCE-CK804", ATA_UDMA6), |
315 | /* 14 */ DECLARE_NV_DEV("NFORCE-MCP04"), | 274 | /* 14 */ DECLARE_NV_DEV("NFORCE-MCP04", ATA_UDMA6), |
316 | /* 15 */ DECLARE_NV_DEV("NFORCE-MCP51"), | 275 | /* 15 */ DECLARE_NV_DEV("NFORCE-MCP51", ATA_UDMA6), |
317 | /* 16 */ DECLARE_NV_DEV("NFORCE-MCP55"), | 276 | /* 16 */ DECLARE_NV_DEV("NFORCE-MCP55", ATA_UDMA6), |
318 | /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61"), | 277 | /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61", ATA_UDMA6), |
319 | /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65"), | 278 | /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65", ATA_UDMA6), |
320 | /* 19 */ DECLARE_NV_DEV("NFORCE-MCP67"), | 279 | /* 19 */ DECLARE_NV_DEV("NFORCE-MCP67", ATA_UDMA6), |
321 | /* 20 */ DECLARE_NV_DEV("NFORCE-MCP73"), | 280 | /* 20 */ DECLARE_NV_DEV("NFORCE-MCP73", ATA_UDMA6), |
322 | /* 21 */ DECLARE_NV_DEV("NFORCE-MCP77"), | 281 | /* 21 */ DECLARE_NV_DEV("NFORCE-MCP77", ATA_UDMA6), |
323 | /* 22 */ DECLARE_AMD_DEV("AMD5536"), | 282 | |
283 | /* 22 */ DECLARE_AMD_DEV("AMD5536", ATA_SWDMA2, ATA_UDMA5), | ||
324 | }; | 284 | }; |
325 | 285 | ||
326 | static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) | 286 | static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) |
327 | { | 287 | { |
328 | amd_chipset = amd74xx_chipsets + id->driver_data; | 288 | struct ide_port_info d; |
329 | amd_config = amd_ide_chips + id->driver_data; | 289 | u8 idx = id->driver_data; |
330 | if (dev->device != amd_config->id) { | 290 | |
331 | printk(KERN_ERR "%s: assertion 0x%02x == 0x%02x failed !\n", | 291 | d = amd74xx_chipsets[idx]; |
332 | pci_name(dev), dev->device, amd_config->id); | 292 | |
333 | return -ENODEV; | 293 | /* |
294 | * Check for bad SWDMA and incorrectly wired Serenade mainboards. | ||
295 | */ | ||
296 | if (idx == 1) { | ||
297 | if (dev->revision <= 7) | ||
298 | d.swdma_mask = 0; | ||
299 | d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; | ||
300 | } else if (idx == 4) { | ||
301 | if (dev->subsystem_vendor == PCI_VENDOR_ID_AMD && | ||
302 | dev->subsystem_device == PCI_DEVICE_ID_AMD_SERENADE) | ||
303 | d.udma_mask = ATA_UDMA5; | ||
334 | } | 304 | } |
335 | return ide_setup_pci_device(dev, amd_chipset); | 305 | |
306 | printk(KERN_INFO "%s: %s (rev %02x) UDMA%s controller\n", | ||
307 | d.name, pci_name(dev), dev->revision, | ||
308 | amd_dma[fls(d.udma_mask) - 1]); | ||
309 | |||
310 | return ide_setup_pci_device(dev, &d); | ||
336 | } | 311 | } |
337 | 312 | ||
338 | static const struct pci_device_id amd74xx_pci_tbl[] = { | 313 | static const struct pci_device_id amd74xx_pci_tbl[] = { |
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c index 491871984aaa..b56274af1782 100644 --- a/drivers/ide/pci/atiixp.c +++ b/drivers/ide/pci/atiixp.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/atiixp.c Version 0.05 Nov 9 2007 | ||
3 | * | ||
4 | * Copyright (C) 2003 ATI Inc. <hyu@ati.com> | 2 | * Copyright (C) 2003 ATI Inc. <hyu@ati.com> |
5 | * Copyright (C) 2004,2007 Bartlomiej Zolnierkiewicz | 3 | * Copyright (C) 2004,2007 Bartlomiej Zolnierkiewicz |
6 | */ | 4 | */ |
@@ -55,7 +53,7 @@ static DEFINE_SPINLOCK(atiixp_lock); | |||
55 | 53 | ||
56 | static void atiixp_set_pio_mode(ide_drive_t *drive, const u8 pio) | 54 | static void atiixp_set_pio_mode(ide_drive_t *drive, const u8 pio) |
57 | { | 55 | { |
58 | struct pci_dev *dev = drive->hwif->pci_dev; | 56 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
59 | unsigned long flags; | 57 | unsigned long flags; |
60 | int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8; | 58 | int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8; |
61 | u32 pio_timing_data; | 59 | u32 pio_timing_data; |
@@ -88,7 +86,7 @@ static void atiixp_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
88 | 86 | ||
89 | static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed) | 87 | static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed) |
90 | { | 88 | { |
91 | struct pci_dev *dev = drive->hwif->pci_dev; | 89 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
92 | unsigned long flags; | 90 | unsigned long flags; |
93 | int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8; | 91 | int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8; |
94 | u32 tmp32; | 92 | u32 tmp32; |
@@ -133,9 +131,8 @@ static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
133 | 131 | ||
134 | static void __devinit init_hwif_atiixp(ide_hwif_t *hwif) | 132 | static void __devinit init_hwif_atiixp(ide_hwif_t *hwif) |
135 | { | 133 | { |
136 | u8 udma_mode = 0; | 134 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
137 | u8 ch = hwif->channel; | 135 | u8 udma_mode = 0, ch = hwif->channel; |
138 | struct pci_dev *pdev = hwif->pci_dev; | ||
139 | 136 | ||
140 | hwif->set_pio_mode = &atiixp_set_pio_mode; | 137 | hwif->set_pio_mode = &atiixp_set_pio_mode; |
141 | hwif->set_dma_mode = &atiixp_set_dma_mode; | 138 | hwif->set_dma_mode = &atiixp_set_dma_mode; |
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c index da3565e0071f..7240c20b9593 100644 --- a/drivers/ide/pci/cmd640.c +++ b/drivers/ide/pci/cmd640.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/cmd640.c Version 1.02 Sep 01, 1996 | ||
3 | * | ||
4 | * Copyright (C) 1995-1996 Linus Torvalds & authors (see below) | 2 | * Copyright (C) 1995-1996 Linus Torvalds & authors (see below) |
5 | */ | 3 | */ |
6 | 4 | ||
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index cd4eb9def151..04aa9e59670e 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/cmd64x.c Version 1.53 Dec 24, 2007 | ||
3 | * | ||
4 | * cmd64x.c: Enable interrupts at initialization time on Ultra/PCI machines. | 2 | * cmd64x.c: Enable interrupts at initialization time on Ultra/PCI machines. |
5 | * Due to massive hardware bugs, UltraDMA is only supported | 3 | * Due to massive hardware bugs, UltraDMA is only supported |
6 | * on the 646U2 and not on the 646U. | 4 | * on the 646U2 and not on the 646U. |
@@ -71,7 +69,7 @@ static u8 quantize_timing(int timing, int quant) | |||
71 | */ | 69 | */ |
72 | static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_time) | 70 | static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_time) |
73 | { | 71 | { |
74 | struct pci_dev *dev = HWIF(drive)->pci_dev; | 72 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
75 | int clock_time = 1000 / system_bus_clock(); | 73 | int clock_time = 1000 / system_bus_clock(); |
76 | u8 cycle_count, active_count, recovery_count, drwtim; | 74 | u8 cycle_count, active_count, recovery_count, drwtim; |
77 | static const u8 recovery_values[] = | 75 | static const u8 recovery_values[] = |
@@ -118,7 +116,7 @@ static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_ | |||
118 | static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio) | 116 | static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio) |
119 | { | 117 | { |
120 | ide_hwif_t *hwif = HWIF(drive); | 118 | ide_hwif_t *hwif = HWIF(drive); |
121 | struct pci_dev *dev = hwif->pci_dev; | 119 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
122 | unsigned int cycle_time; | 120 | unsigned int cycle_time; |
123 | u8 setup_count, arttim = 0; | 121 | u8 setup_count, arttim = 0; |
124 | 122 | ||
@@ -183,7 +181,7 @@ static void cmd64x_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
183 | static void cmd64x_set_dma_mode(ide_drive_t *drive, const u8 speed) | 181 | static void cmd64x_set_dma_mode(ide_drive_t *drive, const u8 speed) |
184 | { | 182 | { |
185 | ide_hwif_t *hwif = HWIF(drive); | 183 | ide_hwif_t *hwif = HWIF(drive); |
186 | struct pci_dev *dev = hwif->pci_dev; | 184 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
187 | u8 unit = drive->dn & 0x01; | 185 | u8 unit = drive->dn & 0x01; |
188 | u8 regU = 0, pciU = hwif->channel ? UDIDETCR1 : UDIDETCR0; | 186 | u8 regU = 0, pciU = hwif->channel ? UDIDETCR1 : UDIDETCR0; |
189 | 187 | ||
@@ -245,7 +243,7 @@ static int cmd648_ide_dma_end (ide_drive_t *drive) | |||
245 | static int cmd64x_ide_dma_end (ide_drive_t *drive) | 243 | static int cmd64x_ide_dma_end (ide_drive_t *drive) |
246 | { | 244 | { |
247 | ide_hwif_t *hwif = HWIF(drive); | 245 | ide_hwif_t *hwif = HWIF(drive); |
248 | struct pci_dev *dev = hwif->pci_dev; | 246 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
249 | int irq_reg = hwif->channel ? ARTTIM23 : CFR; | 247 | int irq_reg = hwif->channel ? ARTTIM23 : CFR; |
250 | u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : | 248 | u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : |
251 | CFR_INTR_CH0; | 249 | CFR_INTR_CH0; |
@@ -285,7 +283,7 @@ static int cmd648_ide_dma_test_irq (ide_drive_t *drive) | |||
285 | static int cmd64x_ide_dma_test_irq (ide_drive_t *drive) | 283 | static int cmd64x_ide_dma_test_irq (ide_drive_t *drive) |
286 | { | 284 | { |
287 | ide_hwif_t *hwif = HWIF(drive); | 285 | ide_hwif_t *hwif = HWIF(drive); |
288 | struct pci_dev *dev = hwif->pci_dev; | 286 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
289 | int irq_reg = hwif->channel ? ARTTIM23 : CFR; | 287 | int irq_reg = hwif->channel ? ARTTIM23 : CFR; |
290 | u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : | 288 | u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : |
291 | CFR_INTR_CH0; | 289 | CFR_INTR_CH0; |
@@ -375,7 +373,7 @@ static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const cha | |||
375 | 373 | ||
376 | static u8 __devinit ata66_cmd64x(ide_hwif_t *hwif) | 374 | static u8 __devinit ata66_cmd64x(ide_hwif_t *hwif) |
377 | { | 375 | { |
378 | struct pci_dev *dev = hwif->pci_dev; | 376 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
379 | u8 bmidecsr = 0, mask = hwif->channel ? 0x02 : 0x01; | 377 | u8 bmidecsr = 0, mask = hwif->channel ? 0x02 : 0x01; |
380 | 378 | ||
381 | switch (dev->device) { | 379 | switch (dev->device) { |
@@ -390,7 +388,7 @@ static u8 __devinit ata66_cmd64x(ide_hwif_t *hwif) | |||
390 | 388 | ||
391 | static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif) | 389 | static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif) |
392 | { | 390 | { |
393 | struct pci_dev *dev = hwif->pci_dev; | 391 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
394 | 392 | ||
395 | hwif->set_pio_mode = &cmd64x_set_pio_mode; | 393 | hwif->set_pio_mode = &cmd64x_set_pio_mode; |
396 | hwif->set_dma_mode = &cmd64x_set_dma_mode; | 394 | hwif->set_dma_mode = &cmd64x_set_dma_mode; |
@@ -443,7 +441,9 @@ static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { | |||
443 | .init_chipset = init_chipset_cmd64x, | 441 | .init_chipset = init_chipset_cmd64x, |
444 | .init_hwif = init_hwif_cmd64x, | 442 | .init_hwif = init_hwif_cmd64x, |
445 | .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, | 443 | .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, |
446 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH | IDE_HFLAG_BOOTABLE, | 444 | .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | |
445 | IDE_HFLAG_ABUSE_PREFETCH | | ||
446 | IDE_HFLAG_BOOTABLE, | ||
447 | .pio_mask = ATA_PIO5, | 447 | .pio_mask = ATA_PIO5, |
448 | .mwdma_mask = ATA_MWDMA2, | 448 | .mwdma_mask = ATA_MWDMA2, |
449 | .udma_mask = 0x00, /* no udma */ | 449 | .udma_mask = 0x00, /* no udma */ |
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c index 10adc49f80ca..eb68a9ad0c98 100644 --- a/drivers/ide/pci/cs5520.c +++ b/drivers/ide/pci/cs5520.c | |||
@@ -69,7 +69,7 @@ static struct pio_clocks cs5520_pio_clocks[]={ | |||
69 | static void cs5520_set_pio_mode(ide_drive_t *drive, const u8 pio) | 69 | static void cs5520_set_pio_mode(ide_drive_t *drive, const u8 pio) |
70 | { | 70 | { |
71 | ide_hwif_t *hwif = HWIF(drive); | 71 | ide_hwif_t *hwif = HWIF(drive); |
72 | struct pci_dev *pdev = hwif->pci_dev; | 72 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
73 | int controller = drive->dn > 1 ? 1 : 0; | 73 | int controller = drive->dn > 1 ? 1 : 0; |
74 | 74 | ||
75 | /* FIXME: if DMA = 1 do we need to set the DMA bit here ? */ | 75 | /* FIXME: if DMA = 1 do we need to set the DMA bit here ? */ |
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c index df5966b33460..765aac397ced 100644 --- a/drivers/ide/pci/cs5530.c +++ b/drivers/ide/pci/cs5530.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/cs5530.c Version 0.77 Sep 24 2007 | ||
3 | * | ||
4 | * Copyright (C) 2000 Andre Hedrick <andre@linux-ide.org> | 2 | * Copyright (C) 2000 Andre Hedrick <andre@linux-ide.org> |
5 | * Copyright (C) 2000 Mark Lord <mlord@pobox.com> | 3 | * Copyright (C) 2000 Mark Lord <mlord@pobox.com> |
6 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz | 4 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz |
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c index 50b3d7791f55..66433aa53f59 100644 --- a/drivers/ide/pci/cs5535.c +++ b/drivers/ide/pci/cs5535.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/cs5535.c | ||
3 | * | ||
4 | * Copyright (C) 2004-2005 Advanced Micro Devices, Inc. | 2 | * Copyright (C) 2004-2005 Advanced Micro Devices, Inc. |
5 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz | 3 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz |
6 | * | 4 | * |
@@ -177,13 +175,15 @@ static u8 __devinit cs5535_cable_detect(struct pci_dev *dev) | |||
177 | */ | 175 | */ |
178 | static void __devinit init_hwif_cs5535(ide_hwif_t *hwif) | 176 | static void __devinit init_hwif_cs5535(ide_hwif_t *hwif) |
179 | { | 177 | { |
178 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
179 | |||
180 | hwif->set_pio_mode = &cs5535_set_pio_mode; | 180 | hwif->set_pio_mode = &cs5535_set_pio_mode; |
181 | hwif->set_dma_mode = &cs5535_set_dma_mode; | 181 | hwif->set_dma_mode = &cs5535_set_dma_mode; |
182 | 182 | ||
183 | if (hwif->dma_base == 0) | 183 | if (hwif->dma_base == 0) |
184 | return; | 184 | return; |
185 | 185 | ||
186 | hwif->cbl = cs5535_cable_detect(hwif->pci_dev); | 186 | hwif->cbl = cs5535_cable_detect(dev); |
187 | } | 187 | } |
188 | 188 | ||
189 | static const struct ide_port_info cs5535_chipset __devinitdata = { | 189 | static const struct ide_port_info cs5535_chipset __devinitdata = { |
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c index 3ec4c659a37d..50100ac8770f 100644 --- a/drivers/ide/pci/cy82c693.c +++ b/drivers/ide/pci/cy82c693.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/cy82c693.c Version 0.44 Nov 8, 2007 | ||
3 | * | ||
4 | * Copyright (C) 1998-2000 Andreas S. Krebs (akrebs@altavista.net), Maintainer | 2 | * Copyright (C) 1998-2000 Andreas S. Krebs (akrebs@altavista.net), Maintainer |
5 | * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>, Integrator | 3 | * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>, Integrator |
6 | * | 4 | * |
@@ -228,7 +226,7 @@ static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
228 | static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) | 226 | static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) |
229 | { | 227 | { |
230 | ide_hwif_t *hwif = HWIF(drive); | 228 | ide_hwif_t *hwif = HWIF(drive); |
231 | struct pci_dev *dev = hwif->pci_dev; | 229 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
232 | pio_clocks_t pclk; | 230 | pio_clocks_t pclk; |
233 | unsigned int addrCtrl; | 231 | unsigned int addrCtrl; |
234 | 232 | ||
@@ -397,8 +395,9 @@ static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif) | |||
397 | static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) | 395 | static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) |
398 | { | 396 | { |
399 | static ide_hwif_t *primary; | 397 | static ide_hwif_t *primary; |
398 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
400 | 399 | ||
401 | if (PCI_FUNC(hwif->pci_dev->devfn) == 1) | 400 | if (PCI_FUNC(dev->devfn) == 1) |
402 | primary = hwif; | 401 | primary = hwif; |
403 | else { | 402 | else { |
404 | hwif->mate = primary; | 403 | hwif->mate = primary; |
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c index 26aa492071bb..27e47fc97100 100644 --- a/drivers/ide/pci/delkin_cb.c +++ b/drivers/ide/pci/delkin_cb.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/delkin_cb.c | ||
3 | * | ||
4 | * Created 20 Oct 2004 by Mark Lord | 2 | * Created 20 Oct 2004 by Mark Lord |
5 | * | 3 | * |
6 | * Basic support for Delkin/ASKA/Workbit Cardbus CompactFlash adapter | 4 | * Basic support for Delkin/ASKA/Workbit Cardbus CompactFlash adapter |
@@ -87,7 +85,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) | |||
87 | return -ENODEV; | 85 | return -ENODEV; |
88 | } | 86 | } |
89 | pci_set_drvdata(dev, hwif); | 87 | pci_set_drvdata(dev, hwif); |
90 | hwif->pci_dev = dev; | 88 | hwif->dev = &dev->dev; |
91 | drive = &hwif->drives[0]; | 89 | drive = &hwif->drives[0]; |
92 | if (drive->present) { | 90 | if (drive->present) { |
93 | drive->io_32bit = 1; | 91 | drive->io_32bit = 1; |
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c index 06885697ed7b..59ebe84f1053 100644 --- a/drivers/ide/pci/generic.c +++ b/drivers/ide/pci/generic.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/generic.c Version 0.11 December 30, 2002 | ||
3 | * | ||
4 | * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> | 2 | * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> |
5 | * Portions (C) Copyright 2002 Red Hat Inc <alan@redhat.com> | 3 | * Portions (C) Copyright 2002 Red Hat Inc <alan@redhat.com> |
6 | * | 4 | * |
@@ -104,7 +102,8 @@ static const struct ide_port_info generic_chipsets[] __devinitdata = { | |||
104 | 102 | ||
105 | { /* 14 */ | 103 | { /* 14 */ |
106 | .name = "Revolution", | 104 | .name = "Revolution", |
107 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 105 | .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | |
106 | IDE_HFLAG_TRUST_BIOS_FOR_DMA | | ||
108 | IDE_HFLAG_OFF_BOARD, | 107 | IDE_HFLAG_OFF_BOARD, |
109 | .swdma_mask = ATA_SWDMA2, | 108 | .swdma_mask = ATA_SWDMA2, |
110 | .mwdma_mask = ATA_MWDMA2, | 109 | .mwdma_mask = ATA_MWDMA2, |
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c index dfba0d13fcd3..25dbb814822d 100644 --- a/drivers/ide/pci/hpt34x.c +++ b/drivers/ide/pci/hpt34x.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/hpt34x.c Version 0.40 Sept 10, 2002 | ||
3 | * | ||
4 | * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> | 2 | * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> |
3 | * | ||
5 | * May be copied or modified under the terms of the GNU General Public License | 4 | * May be copied or modified under the terms of the GNU General Public License |
6 | * | 5 | * |
7 | * | 6 | * |
@@ -45,7 +44,7 @@ | |||
45 | 44 | ||
46 | static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed) | 45 | static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed) |
47 | { | 46 | { |
48 | struct pci_dev *dev = HWIF(drive)->pci_dev; | 47 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
49 | u32 reg1= 0, tmp1 = 0, reg2 = 0, tmp2 = 0; | 48 | u32 reg1= 0, tmp1 = 0, reg2 = 0, tmp2 = 0; |
50 | u8 hi_speed, lo_speed; | 49 | u8 hi_speed, lo_speed; |
51 | 50 | ||
@@ -131,6 +130,7 @@ static void __devinit init_hwif_hpt34x(ide_hwif_t *hwif) | |||
131 | 130 | ||
132 | #define IDE_HFLAGS_HPT34X \ | 131 | #define IDE_HFLAGS_HPT34X \ |
133 | (IDE_HFLAG_NO_ATAPI_DMA | \ | 132 | (IDE_HFLAG_NO_ATAPI_DMA | \ |
133 | IDE_HFLAG_NO_DSC | \ | ||
134 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ | 134 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ |
135 | IDE_HFLAG_NO_AUTODMA) | 135 | IDE_HFLAG_NO_AUTODMA) |
136 | 136 | ||
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 12685939a813..5623cad569da 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/hpt366.c Version 1.30 Dec 12, 2007 | ||
3 | * | ||
4 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> | 2 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> |
5 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. | 3 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. |
6 | * Portions Copyright (C) 2003 Red Hat Inc | 4 | * Portions Copyright (C) 2003 Red Hat Inc |
@@ -626,7 +624,8 @@ static int check_in_drive_list(ide_drive_t *drive, const char **list) | |||
626 | static u8 hpt3xx_udma_filter(ide_drive_t *drive) | 624 | static u8 hpt3xx_udma_filter(ide_drive_t *drive) |
627 | { | 625 | { |
628 | ide_hwif_t *hwif = HWIF(drive); | 626 | ide_hwif_t *hwif = HWIF(drive); |
629 | struct hpt_info *info = pci_get_drvdata(hwif->pci_dev); | 627 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
628 | struct hpt_info *info = pci_get_drvdata(dev); | ||
630 | u8 mask = hwif->ultra_mask; | 629 | u8 mask = hwif->ultra_mask; |
631 | 630 | ||
632 | switch (info->chip_type) { | 631 | switch (info->chip_type) { |
@@ -665,7 +664,8 @@ static u8 hpt3xx_udma_filter(ide_drive_t *drive) | |||
665 | static u8 hpt3xx_mdma_filter(ide_drive_t *drive) | 664 | static u8 hpt3xx_mdma_filter(ide_drive_t *drive) |
666 | { | 665 | { |
667 | ide_hwif_t *hwif = HWIF(drive); | 666 | ide_hwif_t *hwif = HWIF(drive); |
668 | struct hpt_info *info = pci_get_drvdata(hwif->pci_dev); | 667 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
668 | struct hpt_info *info = pci_get_drvdata(dev); | ||
669 | 669 | ||
670 | switch (info->chip_type) { | 670 | switch (info->chip_type) { |
671 | case HPT372 : | 671 | case HPT372 : |
@@ -699,7 +699,7 @@ static u32 get_speed_setting(u8 speed, struct hpt_info *info) | |||
699 | 699 | ||
700 | static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed) | 700 | static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed) |
701 | { | 701 | { |
702 | struct pci_dev *dev = HWIF(drive)->pci_dev; | 702 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
703 | struct hpt_info *info = pci_get_drvdata(dev); | 703 | struct hpt_info *info = pci_get_drvdata(dev); |
704 | struct hpt_timings *t = info->timings; | 704 | struct hpt_timings *t = info->timings; |
705 | u8 itr_addr = 0x40 + (drive->dn * 4); | 705 | u8 itr_addr = 0x40 + (drive->dn * 4); |
@@ -742,7 +742,7 @@ static void hpt3xx_quirkproc(ide_drive_t *drive) | |||
742 | static void hpt3xx_maskproc(ide_drive_t *drive, int mask) | 742 | static void hpt3xx_maskproc(ide_drive_t *drive, int mask) |
743 | { | 743 | { |
744 | ide_hwif_t *hwif = HWIF(drive); | 744 | ide_hwif_t *hwif = HWIF(drive); |
745 | struct pci_dev *dev = hwif->pci_dev; | 745 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
746 | struct hpt_info *info = pci_get_drvdata(dev); | 746 | struct hpt_info *info = pci_get_drvdata(dev); |
747 | 747 | ||
748 | if (drive->quirk_list) { | 748 | if (drive->quirk_list) { |
@@ -774,7 +774,7 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask) | |||
774 | */ | 774 | */ |
775 | static void hpt366_dma_lost_irq(ide_drive_t *drive) | 775 | static void hpt366_dma_lost_irq(ide_drive_t *drive) |
776 | { | 776 | { |
777 | struct pci_dev *dev = HWIF(drive)->pci_dev; | 777 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
778 | u8 mcr1 = 0, mcr3 = 0, scr1 = 0; | 778 | u8 mcr1 = 0, mcr3 = 0, scr1 = 0; |
779 | 779 | ||
780 | pci_read_config_byte(dev, 0x50, &mcr1); | 780 | pci_read_config_byte(dev, 0x50, &mcr1); |
@@ -790,18 +790,20 @@ static void hpt366_dma_lost_irq(ide_drive_t *drive) | |||
790 | static void hpt370_clear_engine(ide_drive_t *drive) | 790 | static void hpt370_clear_engine(ide_drive_t *drive) |
791 | { | 791 | { |
792 | ide_hwif_t *hwif = HWIF(drive); | 792 | ide_hwif_t *hwif = HWIF(drive); |
793 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
793 | 794 | ||
794 | pci_write_config_byte(hwif->pci_dev, hwif->select_data, 0x37); | 795 | pci_write_config_byte(dev, hwif->select_data, 0x37); |
795 | udelay(10); | 796 | udelay(10); |
796 | } | 797 | } |
797 | 798 | ||
798 | static void hpt370_irq_timeout(ide_drive_t *drive) | 799 | static void hpt370_irq_timeout(ide_drive_t *drive) |
799 | { | 800 | { |
800 | ide_hwif_t *hwif = HWIF(drive); | 801 | ide_hwif_t *hwif = HWIF(drive); |
802 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
801 | u16 bfifo = 0; | 803 | u16 bfifo = 0; |
802 | u8 dma_cmd; | 804 | u8 dma_cmd; |
803 | 805 | ||
804 | pci_read_config_word(hwif->pci_dev, hwif->select_data + 2, &bfifo); | 806 | pci_read_config_word(dev, hwif->select_data + 2, &bfifo); |
805 | printk(KERN_DEBUG "%s: %d bytes in FIFO\n", drive->name, bfifo & 0x1ff); | 807 | printk(KERN_DEBUG "%s: %d bytes in FIFO\n", drive->name, bfifo & 0x1ff); |
806 | 808 | ||
807 | /* get DMA command mode */ | 809 | /* get DMA command mode */ |
@@ -844,10 +846,11 @@ static void hpt370_dma_timeout(ide_drive_t *drive) | |||
844 | static int hpt374_ide_dma_test_irq(ide_drive_t *drive) | 846 | static int hpt374_ide_dma_test_irq(ide_drive_t *drive) |
845 | { | 847 | { |
846 | ide_hwif_t *hwif = HWIF(drive); | 848 | ide_hwif_t *hwif = HWIF(drive); |
849 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
847 | u16 bfifo = 0; | 850 | u16 bfifo = 0; |
848 | u8 dma_stat; | 851 | u8 dma_stat; |
849 | 852 | ||
850 | pci_read_config_word(hwif->pci_dev, hwif->select_data + 2, &bfifo); | 853 | pci_read_config_word(dev, hwif->select_data + 2, &bfifo); |
851 | if (bfifo & 0x1FF) { | 854 | if (bfifo & 0x1FF) { |
852 | // printk("%s: %d bytes in FIFO\n", drive->name, bfifo); | 855 | // printk("%s: %d bytes in FIFO\n", drive->name, bfifo); |
853 | return 0; | 856 | return 0; |
@@ -867,7 +870,7 @@ static int hpt374_ide_dma_test_irq(ide_drive_t *drive) | |||
867 | static int hpt374_ide_dma_end(ide_drive_t *drive) | 870 | static int hpt374_ide_dma_end(ide_drive_t *drive) |
868 | { | 871 | { |
869 | ide_hwif_t *hwif = HWIF(drive); | 872 | ide_hwif_t *hwif = HWIF(drive); |
870 | struct pci_dev *dev = hwif->pci_dev; | 873 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
871 | u8 mcr = 0, mcr_addr = hwif->select_data; | 874 | u8 mcr = 0, mcr_addr = hwif->select_data; |
872 | u8 bwsr = 0, mask = hwif->channel ? 0x02 : 0x01; | 875 | u8 bwsr = 0, mask = hwif->channel ? 0x02 : 0x01; |
873 | 876 | ||
@@ -942,7 +945,7 @@ static void hpt3xxn_rw_disk(ide_drive_t *drive, struct request *rq) | |||
942 | static int hpt3xx_busproc(ide_drive_t *drive, int state) | 945 | static int hpt3xx_busproc(ide_drive_t *drive, int state) |
943 | { | 946 | { |
944 | ide_hwif_t *hwif = HWIF(drive); | 947 | ide_hwif_t *hwif = HWIF(drive); |
945 | struct pci_dev *dev = hwif->pci_dev; | 948 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
946 | u8 mcr_addr = hwif->select_data + 2; | 949 | u8 mcr_addr = hwif->select_data + 2; |
947 | u8 resetmask = hwif->channel ? 0x80 : 0x40; | 950 | u8 resetmask = hwif->channel ? 0x80 : 0x40; |
948 | u8 bsr2 = 0; | 951 | u8 bsr2 = 0; |
@@ -1278,7 +1281,7 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1278 | 1281 | ||
1279 | static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | 1282 | static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) |
1280 | { | 1283 | { |
1281 | struct pci_dev *dev = hwif->pci_dev; | 1284 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
1282 | struct hpt_info *info = pci_get_drvdata(dev); | 1285 | struct hpt_info *info = pci_get_drvdata(dev); |
1283 | int serialize = HPT_SERIALIZE_IO; | 1286 | int serialize = HPT_SERIALIZE_IO; |
1284 | u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02; | 1287 | u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02; |
@@ -1393,7 +1396,7 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | |||
1393 | 1396 | ||
1394 | static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) | 1397 | static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) |
1395 | { | 1398 | { |
1396 | struct pci_dev *dev = hwif->pci_dev; | 1399 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
1397 | u8 masterdma = 0, slavedma = 0; | 1400 | u8 masterdma = 0, slavedma = 0; |
1398 | u8 dma_new = 0, dma_old = 0; | 1401 | u8 dma_new = 0, dma_old = 0; |
1399 | unsigned long flags; | 1402 | unsigned long flags; |
@@ -1413,7 +1416,7 @@ static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) | |||
1413 | 1416 | ||
1414 | local_irq_restore(flags); | 1417 | local_irq_restore(flags); |
1415 | 1418 | ||
1416 | ide_setup_dma(hwif, dmabase, 8); | 1419 | ide_setup_dma(hwif, dmabase); |
1417 | } | 1420 | } |
1418 | 1421 | ||
1419 | static void __devinit hpt374_init(struct pci_dev *dev, struct pci_dev *dev2) | 1422 | static void __devinit hpt374_init(struct pci_dev *dev, struct pci_dev *dev2) |
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c index 2a0f45c4f4c4..df74e588a530 100644 --- a/drivers/ide/pci/it8213.c +++ b/drivers/ide/pci/it8213.c | |||
@@ -28,7 +28,7 @@ | |||
28 | static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio) | 28 | static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio) |
29 | { | 29 | { |
30 | ide_hwif_t *hwif = HWIF(drive); | 30 | ide_hwif_t *hwif = HWIF(drive); |
31 | struct pci_dev *dev = hwif->pci_dev; | 31 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
32 | int is_slave = drive->dn & 1; | 32 | int is_slave = drive->dn & 1; |
33 | int master_port = 0x40; | 33 | int master_port = 0x40; |
34 | int slave_port = 0x44; | 34 | int slave_port = 0x44; |
@@ -85,7 +85,7 @@ static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
85 | static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) | 85 | static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) |
86 | { | 86 | { |
87 | ide_hwif_t *hwif = HWIF(drive); | 87 | ide_hwif_t *hwif = HWIF(drive); |
88 | struct pci_dev *dev = hwif->pci_dev; | 88 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
89 | u8 maslave = 0x40; | 89 | u8 maslave = 0x40; |
90 | int a_speed = 3 << (drive->dn * 4); | 90 | int a_speed = 3 << (drive->dn * 4); |
91 | int u_flag = 1 << drive->dn; | 91 | int u_flag = 1 << drive->dn; |
@@ -152,6 +152,7 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
152 | 152 | ||
153 | static void __devinit init_hwif_it8213(ide_hwif_t *hwif) | 153 | static void __devinit init_hwif_it8213(ide_hwif_t *hwif) |
154 | { | 154 | { |
155 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
155 | u8 reg42h = 0; | 156 | u8 reg42h = 0; |
156 | 157 | ||
157 | hwif->set_dma_mode = &it8213_set_dma_mode; | 158 | hwif->set_dma_mode = &it8213_set_dma_mode; |
@@ -160,7 +161,7 @@ static void __devinit init_hwif_it8213(ide_hwif_t *hwif) | |||
160 | if (!hwif->dma_base) | 161 | if (!hwif->dma_base) |
161 | return; | 162 | return; |
162 | 163 | ||
163 | pci_read_config_byte(hwif->pci_dev, 0x42, ®42h); | 164 | pci_read_config_byte(dev, 0x42, ®42h); |
164 | 165 | ||
165 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | 166 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) |
166 | hwif->cbl = (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | 167 | hwif->cbl = (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; |
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c index e610a5340fdc..938d35f35c81 100644 --- a/drivers/ide/pci/it821x.c +++ b/drivers/ide/pci/it821x.c | |||
@@ -1,7 +1,4 @@ | |||
1 | |||
2 | /* | 1 | /* |
3 | * linux/drivers/ide/pci/it821x.c Version 0.16 Jul 3 2007 | ||
4 | * | ||
5 | * Copyright (C) 2004 Red Hat <alan@redhat.com> | 2 | * Copyright (C) 2004 Red Hat <alan@redhat.com> |
6 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz | 3 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz |
7 | * | 4 | * |
@@ -113,7 +110,8 @@ static int it8212_noraid; | |||
113 | 110 | ||
114 | static void it821x_program(ide_drive_t *drive, u16 timing) | 111 | static void it821x_program(ide_drive_t *drive, u16 timing) |
115 | { | 112 | { |
116 | ide_hwif_t *hwif = drive->hwif; | 113 | ide_hwif_t *hwif = drive->hwif; |
114 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
117 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); | 115 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); |
118 | int channel = hwif->channel; | 116 | int channel = hwif->channel; |
119 | u8 conf; | 117 | u8 conf; |
@@ -123,7 +121,8 @@ static void it821x_program(ide_drive_t *drive, u16 timing) | |||
123 | conf = timing >> 8; | 121 | conf = timing >> 8; |
124 | else | 122 | else |
125 | conf = timing & 0xFF; | 123 | conf = timing & 0xFF; |
126 | pci_write_config_byte(hwif->pci_dev, 0x54 + 4 * channel, conf); | 124 | |
125 | pci_write_config_byte(dev, 0x54 + 4 * channel, conf); | ||
127 | } | 126 | } |
128 | 127 | ||
129 | /** | 128 | /** |
@@ -137,7 +136,8 @@ static void it821x_program(ide_drive_t *drive, u16 timing) | |||
137 | 136 | ||
138 | static void it821x_program_udma(ide_drive_t *drive, u16 timing) | 137 | static void it821x_program_udma(ide_drive_t *drive, u16 timing) |
139 | { | 138 | { |
140 | ide_hwif_t *hwif = drive->hwif; | 139 | ide_hwif_t *hwif = drive->hwif; |
140 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
141 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); | 141 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); |
142 | int channel = hwif->channel; | 142 | int channel = hwif->channel; |
143 | int unit = drive->select.b.unit; | 143 | int unit = drive->select.b.unit; |
@@ -148,11 +148,12 @@ static void it821x_program_udma(ide_drive_t *drive, u16 timing) | |||
148 | conf = timing >> 8; | 148 | conf = timing >> 8; |
149 | else | 149 | else |
150 | conf = timing & 0xFF; | 150 | conf = timing & 0xFF; |
151 | if(itdev->timing10 == 0) | 151 | |
152 | pci_write_config_byte(hwif->pci_dev, 0x56 + 4 * channel + unit, conf); | 152 | if (itdev->timing10 == 0) |
153 | pci_write_config_byte(dev, 0x56 + 4 * channel + unit, conf); | ||
153 | else { | 154 | else { |
154 | pci_write_config_byte(hwif->pci_dev, 0x56 + 4 * channel, conf); | 155 | pci_write_config_byte(dev, 0x56 + 4 * channel, conf); |
155 | pci_write_config_byte(hwif->pci_dev, 0x56 + 4 * channel + 1, conf); | 156 | pci_write_config_byte(dev, 0x56 + 4 * channel + 1, conf); |
156 | } | 157 | } |
157 | } | 158 | } |
158 | 159 | ||
@@ -167,6 +168,7 @@ static void it821x_program_udma(ide_drive_t *drive, u16 timing) | |||
167 | static void it821x_clock_strategy(ide_drive_t *drive) | 168 | static void it821x_clock_strategy(ide_drive_t *drive) |
168 | { | 169 | { |
169 | ide_hwif_t *hwif = drive->hwif; | 170 | ide_hwif_t *hwif = drive->hwif; |
171 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
170 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); | 172 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); |
171 | 173 | ||
172 | u8 unit = drive->select.b.unit; | 174 | u8 unit = drive->select.b.unit; |
@@ -205,10 +207,11 @@ static void it821x_clock_strategy(ide_drive_t *drive) | |||
205 | itdev->clock_mode = ATA_50; | 207 | itdev->clock_mode = ATA_50; |
206 | sel = 1; | 208 | sel = 1; |
207 | } | 209 | } |
208 | pci_read_config_byte(hwif->pci_dev, 0x50, &v); | 210 | |
211 | pci_read_config_byte(dev, 0x50, &v); | ||
209 | v &= ~(1 << (1 + hwif->channel)); | 212 | v &= ~(1 << (1 + hwif->channel)); |
210 | v |= sel << (1 + hwif->channel); | 213 | v |= sel << (1 + hwif->channel); |
211 | pci_write_config_byte(hwif->pci_dev, 0x50, v); | 214 | pci_write_config_byte(dev, 0x50, v); |
212 | 215 | ||
213 | /* | 216 | /* |
214 | * Reprogram the UDMA/PIO of the pair drive for the switch | 217 | * Reprogram the UDMA/PIO of the pair drive for the switch |
@@ -282,7 +285,8 @@ static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
282 | 285 | ||
283 | static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted) | 286 | static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted) |
284 | { | 287 | { |
285 | ide_hwif_t *hwif = drive->hwif; | 288 | ide_hwif_t *hwif = drive->hwif; |
289 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
286 | struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif); | 290 | struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif); |
287 | int unit = drive->select.b.unit; | 291 | int unit = drive->select.b.unit; |
288 | int channel = hwif->channel; | 292 | int channel = hwif->channel; |
@@ -297,12 +301,12 @@ static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted) | |||
297 | itdev->udma[unit] = UDMA_OFF; | 301 | itdev->udma[unit] = UDMA_OFF; |
298 | 302 | ||
299 | /* UDMA bits off - Revision 0x10 do them in pairs */ | 303 | /* UDMA bits off - Revision 0x10 do them in pairs */ |
300 | pci_read_config_byte(hwif->pci_dev, 0x50, &conf); | 304 | pci_read_config_byte(dev, 0x50, &conf); |
301 | if(itdev->timing10) | 305 | if (itdev->timing10) |
302 | conf |= channel ? 0x60: 0x18; | 306 | conf |= channel ? 0x60: 0x18; |
303 | else | 307 | else |
304 | conf |= 1 << (3 + 2 * channel + unit); | 308 | conf |= 1 << (3 + 2 * channel + unit); |
305 | pci_write_config_byte(hwif->pci_dev, 0x50, conf); | 309 | pci_write_config_byte(dev, 0x50, conf); |
306 | 310 | ||
307 | it821x_clock_strategy(drive); | 311 | it821x_clock_strategy(drive); |
308 | /* FIXME: do we need to program this ? */ | 312 | /* FIXME: do we need to program this ? */ |
@@ -320,7 +324,8 @@ static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted) | |||
320 | 324 | ||
321 | static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted) | 325 | static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted) |
322 | { | 326 | { |
323 | ide_hwif_t *hwif = drive->hwif; | 327 | ide_hwif_t *hwif = drive->hwif; |
328 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
324 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); | 329 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); |
325 | int unit = drive->select.b.unit; | 330 | int unit = drive->select.b.unit; |
326 | int channel = hwif->channel; | 331 | int channel = hwif->channel; |
@@ -337,12 +342,12 @@ static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted) | |||
337 | itdev->udma[unit] |= 0x8080; /* UDMA 5/6 select on */ | 342 | itdev->udma[unit] |= 0x8080; /* UDMA 5/6 select on */ |
338 | 343 | ||
339 | /* UDMA on. Again revision 0x10 must do the pair */ | 344 | /* UDMA on. Again revision 0x10 must do the pair */ |
340 | pci_read_config_byte(hwif->pci_dev, 0x50, &conf); | 345 | pci_read_config_byte(dev, 0x50, &conf); |
341 | if(itdev->timing10) | 346 | if (itdev->timing10) |
342 | conf &= channel ? 0x9F: 0xE7; | 347 | conf &= channel ? 0x9F: 0xE7; |
343 | else | 348 | else |
344 | conf &= ~ (1 << (3 + 2 * channel + unit)); | 349 | conf &= ~ (1 << (3 + 2 * channel + unit)); |
345 | pci_write_config_byte(hwif->pci_dev, 0x50, conf); | 350 | pci_write_config_byte(dev, 0x50, conf); |
346 | 351 | ||
347 | it821x_clock_strategy(drive); | 352 | it821x_clock_strategy(drive); |
348 | it821x_program_udma(drive, itdev->udma[unit]); | 353 | it821x_program_udma(drive, itdev->udma[unit]); |
@@ -520,6 +525,7 @@ static void __devinit it821x_quirkproc(ide_drive_t *drive) | |||
520 | 525 | ||
521 | static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | 526 | static void __devinit init_hwif_it821x(ide_hwif_t *hwif) |
522 | { | 527 | { |
528 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
523 | struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL); | 529 | struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL); |
524 | u8 conf; | 530 | u8 conf; |
525 | 531 | ||
@@ -532,7 +538,7 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | |||
532 | 538 | ||
533 | ide_set_hwifdata(hwif, idev); | 539 | ide_set_hwifdata(hwif, idev); |
534 | 540 | ||
535 | pci_read_config_byte(hwif->pci_dev, 0x50, &conf); | 541 | pci_read_config_byte(dev, 0x50, &conf); |
536 | if (conf & 1) { | 542 | if (conf & 1) { |
537 | idev->smart = 1; | 543 | idev->smart = 1; |
538 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | 544 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; |
@@ -555,7 +561,7 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | |||
555 | * this is necessary. | 561 | * this is necessary. |
556 | */ | 562 | */ |
557 | 563 | ||
558 | pci_read_config_byte(hwif->pci_dev, 0x08, &conf); | 564 | pci_read_config_byte(dev, 0x08, &conf); |
559 | if (conf == 0x10) { | 565 | if (conf == 0x10) { |
560 | idev->timing10 = 1; | 566 | idev->timing10 = 1; |
561 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | 567 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; |
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c index 0083eaf89c77..8b40f6479c55 100644 --- a/drivers/ide/pci/jmicron.c +++ b/drivers/ide/pci/jmicron.c | |||
@@ -30,7 +30,7 @@ typedef enum { | |||
30 | 30 | ||
31 | static u8 __devinit ata66_jmicron(ide_hwif_t *hwif) | 31 | static u8 __devinit ata66_jmicron(ide_hwif_t *hwif) |
32 | { | 32 | { |
33 | struct pci_dev *pdev = hwif->pci_dev; | 33 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
34 | 34 | ||
35 | u32 control; | 35 | u32 control; |
36 | u32 control5; | 36 | u32 control5; |
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c index d4df4642dbb5..fc9eee9ccac3 100644 --- a/drivers/ide/pci/ns87415.c +++ b/drivers/ide/pci/ns87415.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/ns87415.c Version 2.00 Sep. 10, 2002 | ||
3 | * | ||
4 | * Copyright (C) 1997-1998 Mark Lord <mlord@pobox.com> | 2 | * Copyright (C) 1997-1998 Mark Lord <mlord@pobox.com> |
5 | * Copyright (C) 1998 Eddie C. Dost <ecd@skynet.be> | 3 | * Copyright (C) 1998 Eddie C. Dost <ecd@skynet.be> |
6 | * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> | 4 | * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> |
@@ -71,10 +69,9 @@ static u8 superio_ide_inb (unsigned long port) | |||
71 | 69 | ||
72 | static void __devinit superio_ide_init_iops (struct hwif_s *hwif) | 70 | static void __devinit superio_ide_init_iops (struct hwif_s *hwif) |
73 | { | 71 | { |
72 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | ||
74 | u32 base, dmabase; | 73 | u32 base, dmabase; |
75 | u8 tmp; | 74 | u8 port = hwif->channel, tmp; |
76 | struct pci_dev *pdev = hwif->pci_dev; | ||
77 | u8 port = hwif->channel; | ||
78 | 75 | ||
79 | base = pci_resource_start(pdev, port * 2) & ~3; | 76 | base = pci_resource_start(pdev, port * 2) & ~3; |
80 | dmabase = pci_resource_start(pdev, 4) & ~3; | 77 | dmabase = pci_resource_start(pdev, 4) & ~3; |
@@ -93,10 +90,11 @@ static void __devinit superio_ide_init_iops (struct hwif_s *hwif) | |||
93 | 90 | ||
94 | static void __devinit init_iops_ns87415(ide_hwif_t *hwif) | 91 | static void __devinit init_iops_ns87415(ide_hwif_t *hwif) |
95 | { | 92 | { |
96 | if (PCI_SLOT(hwif->pci_dev->devfn) == 0xE) { | 93 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
94 | |||
95 | if (PCI_SLOT(dev->devfn) == 0xE) | ||
97 | /* Built-in - assume it's under superio. */ | 96 | /* Built-in - assume it's under superio. */ |
98 | superio_ide_init_iops(hwif); | 97 | superio_ide_init_iops(hwif); |
99 | } | ||
100 | } | 98 | } |
101 | #endif | 99 | #endif |
102 | 100 | ||
@@ -110,8 +108,8 @@ static unsigned int ns87415_count = 0, ns87415_control[MAX_HWIFS] = { 0 }; | |||
110 | static void ns87415_prepare_drive (ide_drive_t *drive, unsigned int use_dma) | 108 | static void ns87415_prepare_drive (ide_drive_t *drive, unsigned int use_dma) |
111 | { | 109 | { |
112 | ide_hwif_t *hwif = HWIF(drive); | 110 | ide_hwif_t *hwif = HWIF(drive); |
111 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
113 | unsigned int bit, other, new, *old = (unsigned int *) hwif->select_data; | 112 | unsigned int bit, other, new, *old = (unsigned int *) hwif->select_data; |
114 | struct pci_dev *dev = hwif->pci_dev; | ||
115 | unsigned long flags; | 113 | unsigned long flags; |
116 | 114 | ||
117 | local_irq_save(flags); | 115 | local_irq_save(flags); |
@@ -189,7 +187,7 @@ static int ns87415_ide_dma_setup(ide_drive_t *drive) | |||
189 | 187 | ||
190 | static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | 188 | static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) |
191 | { | 189 | { |
192 | struct pci_dev *dev = hwif->pci_dev; | 190 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
193 | unsigned int ctrl, using_inta; | 191 | unsigned int ctrl, using_inta; |
194 | u8 progif; | 192 | u8 progif; |
195 | #ifdef __sparc_v9__ | 193 | #ifdef __sparc_v9__ |
@@ -231,8 +229,8 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | |||
231 | 229 | ||
232 | #ifdef __sparc_v9__ | 230 | #ifdef __sparc_v9__ |
233 | /* | 231 | /* |
234 | * XXX: Reset the device, if we don't it will not respond | 232 | * XXX: Reset the device, if we don't it will not respond to |
235 | * to SELECT_DRIVE() properly during first probe_hwif(). | 233 | * SELECT_DRIVE() properly during first ide_probe_port(). |
236 | */ | 234 | */ |
237 | timeout = 10000; | 235 | timeout = 10000; |
238 | outb(12, hwif->io_ports[IDE_CONTROL_OFFSET]); | 236 | outb(12, hwif->io_ports[IDE_CONTROL_OFFSET]); |
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c index 8953d9c3926f..0ce92d323036 100644 --- a/drivers/ide/pci/opti621.c +++ b/drivers/ide/pci/opti621.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/opti621.c Version 0.9 Sep 24, 2007 | ||
3 | * | ||
4 | * Copyright (C) 1996-1998 Linus Torvalds & authors (see below) | 2 | * Copyright (C) 1996-1998 Linus Torvalds & authors (see below) |
5 | */ | 3 | */ |
6 | 4 | ||
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c index 89d2363a1ebd..bb29db03540e 100644 --- a/drivers/ide/pci/pdc202xx_new.c +++ b/drivers/ide/pci/pdc202xx_new.c | |||
@@ -149,6 +149,7 @@ static struct udma_timing { | |||
149 | static void pdcnew_set_dma_mode(ide_drive_t *drive, const u8 speed) | 149 | static void pdcnew_set_dma_mode(ide_drive_t *drive, const u8 speed) |
150 | { | 150 | { |
151 | ide_hwif_t *hwif = HWIF(drive); | 151 | ide_hwif_t *hwif = HWIF(drive); |
152 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
152 | u8 adj = (drive->dn & 1) ? 0x08 : 0x00; | 153 | u8 adj = (drive->dn & 1) ? 0x08 : 0x00; |
153 | 154 | ||
154 | /* | 155 | /* |
@@ -159,7 +160,7 @@ static void pdcnew_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
159 | * As we set up the PLL to output 133 MHz for UltraDMA/133 capable | 160 | * As we set up the PLL to output 133 MHz for UltraDMA/133 capable |
160 | * chips, we must override the default register settings... | 161 | * chips, we must override the default register settings... |
161 | */ | 162 | */ |
162 | if (max_dma_rate(hwif->pci_dev) == 4) { | 163 | if (max_dma_rate(dev) == 4) { |
163 | u8 mode = speed & 0x07; | 164 | u8 mode = speed & 0x07; |
164 | 165 | ||
165 | if (speed >= XFER_UDMA_0) { | 166 | if (speed >= XFER_UDMA_0) { |
@@ -186,9 +187,10 @@ static void pdcnew_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
186 | static void pdcnew_set_pio_mode(ide_drive_t *drive, const u8 pio) | 187 | static void pdcnew_set_pio_mode(ide_drive_t *drive, const u8 pio) |
187 | { | 188 | { |
188 | ide_hwif_t *hwif = drive->hwif; | 189 | ide_hwif_t *hwif = drive->hwif; |
190 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
189 | u8 adj = (drive->dn & 1) ? 0x08 : 0x00; | 191 | u8 adj = (drive->dn & 1) ? 0x08 : 0x00; |
190 | 192 | ||
191 | if (max_dma_rate(hwif->pci_dev) == 4) { | 193 | if (max_dma_rate(dev) == 4) { |
192 | set_indexed_reg(hwif, 0x0c + adj, pio_timings[pio].reg0c); | 194 | set_indexed_reg(hwif, 0x0c + adj, pio_timings[pio].reg0c); |
193 | set_indexed_reg(hwif, 0x0d + adj, pio_timings[pio].reg0d); | 195 | set_indexed_reg(hwif, 0x0d + adj, pio_timings[pio].reg0d); |
194 | set_indexed_reg(hwif, 0x13 + adj, pio_timings[pio].reg13); | 196 | set_indexed_reg(hwif, 0x13 + adj, pio_timings[pio].reg13); |
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c index 3a1e081fe390..31a1308414a0 100644 --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/pdc202xx_old.c Version 0.52 Aug 27, 2007 | ||
3 | * | ||
4 | * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org> | 2 | * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org> |
5 | * Copyright (C) 2006-2007 MontaVista Software, Inc. | 3 | * Copyright (C) 2006-2007 MontaVista Software, Inc. |
6 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz | 4 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz |
@@ -66,7 +64,7 @@ static void pdc_old_disable_66MHz_clock(ide_hwif_t *); | |||
66 | static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed) | 64 | static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed) |
67 | { | 65 | { |
68 | ide_hwif_t *hwif = HWIF(drive); | 66 | ide_hwif_t *hwif = HWIF(drive); |
69 | struct pci_dev *dev = hwif->pci_dev; | 67 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
70 | u8 drive_pci = 0x60 + (drive->dn << 2); | 68 | u8 drive_pci = 0x60 + (drive->dn << 2); |
71 | 69 | ||
72 | u8 AP = 0, BP = 0, CP = 0; | 70 | u8 AP = 0, BP = 0, CP = 0; |
@@ -144,9 +142,10 @@ static void pdc202xx_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
144 | 142 | ||
145 | static u8 pdc202xx_old_cable_detect (ide_hwif_t *hwif) | 143 | static u8 pdc202xx_old_cable_detect (ide_hwif_t *hwif) |
146 | { | 144 | { |
145 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
147 | u16 CIS = 0, mask = (hwif->channel) ? (1<<11) : (1<<10); | 146 | u16 CIS = 0, mask = (hwif->channel) ? (1<<11) : (1<<10); |
148 | 147 | ||
149 | pci_read_config_word(hwif->pci_dev, 0x50, &CIS); | 148 | pci_read_config_word(dev, 0x50, &CIS); |
150 | 149 | ||
151 | return (CIS & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | 150 | return (CIS & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; |
152 | } | 151 | } |
@@ -305,12 +304,14 @@ static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev, | |||
305 | 304 | ||
306 | static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif) | 305 | static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif) |
307 | { | 306 | { |
307 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
308 | |||
308 | hwif->set_pio_mode = &pdc202xx_set_pio_mode; | 309 | hwif->set_pio_mode = &pdc202xx_set_pio_mode; |
309 | hwif->set_dma_mode = &pdc202xx_set_mode; | 310 | hwif->set_dma_mode = &pdc202xx_set_mode; |
310 | 311 | ||
311 | hwif->quirkproc = &pdc202xx_quirkproc; | 312 | hwif->quirkproc = &pdc202xx_quirkproc; |
312 | 313 | ||
313 | if (hwif->pci_dev->device != PCI_DEVICE_ID_PROMISE_20246) | 314 | if (dev->device != PCI_DEVICE_ID_PROMISE_20246) |
314 | hwif->resetproc = &pdc202xx_reset; | 315 | hwif->resetproc = &pdc202xx_reset; |
315 | 316 | ||
316 | if (hwif->dma_base == 0) | 317 | if (hwif->dma_base == 0) |
@@ -319,7 +320,7 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif) | |||
319 | hwif->dma_lost_irq = &pdc202xx_dma_lost_irq; | 320 | hwif->dma_lost_irq = &pdc202xx_dma_lost_irq; |
320 | hwif->dma_timeout = &pdc202xx_dma_timeout; | 321 | hwif->dma_timeout = &pdc202xx_dma_timeout; |
321 | 322 | ||
322 | if (hwif->pci_dev->device != PCI_DEVICE_ID_PROMISE_20246) { | 323 | if (dev->device != PCI_DEVICE_ID_PROMISE_20246) { |
323 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | 324 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) |
324 | hwif->cbl = pdc202xx_old_cable_detect(hwif); | 325 | hwif->cbl = pdc202xx_old_cable_detect(hwif); |
325 | 326 | ||
@@ -334,7 +335,7 @@ static void __devinit init_dma_pdc202xx(ide_hwif_t *hwif, unsigned long dmabase) | |||
334 | u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; | 335 | u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; |
335 | 336 | ||
336 | if (hwif->channel) { | 337 | if (hwif->channel) { |
337 | ide_setup_dma(hwif, dmabase, 8); | 338 | ide_setup_dma(hwif, dmabase); |
338 | return; | 339 | return; |
339 | } | 340 | } |
340 | 341 | ||
@@ -358,7 +359,7 @@ static void __devinit init_dma_pdc202xx(ide_hwif_t *hwif, unsigned long dmabase) | |||
358 | } | 359 | } |
359 | #endif /* CONFIG_PDC202XX_BURST */ | 360 | #endif /* CONFIG_PDC202XX_BURST */ |
360 | 361 | ||
361 | ide_setup_dma(hwif, dmabase, 8); | 362 | ide_setup_dma(hwif, dmabase); |
362 | } | 363 | } |
363 | 364 | ||
364 | static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, | 365 | static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, |
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c index bd6d3f77d30c..c1a6b68337d5 100644 --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/piix.c Version 0.54 Sep 5, 2007 | ||
3 | * | ||
4 | * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer | 2 | * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer |
5 | * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> | 3 | * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> |
6 | * Copyright (C) 2003 Red Hat Inc <alan@redhat.com> | 4 | * Copyright (C) 2003 Red Hat Inc <alan@redhat.com> |
@@ -8,53 +6,8 @@ | |||
8 | * | 6 | * |
9 | * May be copied or modified under the terms of the GNU General Public License | 7 | * May be copied or modified under the terms of the GNU General Public License |
10 | * | 8 | * |
11 | * PIO mode setting function for Intel chipsets. | 9 | * Documentation: |
12 | * For use instead of BIOS settings. | ||
13 | * | ||
14 | * 40-41 | ||
15 | * 42-43 | ||
16 | * | ||
17 | * 41 | ||
18 | * 43 | ||
19 | * | ||
20 | * | PIO 0 | c0 | 80 | 0 | | ||
21 | * | PIO 2 | SW2 | d0 | 90 | 4 | | ||
22 | * | PIO 3 | MW1 | e1 | a1 | 9 | | ||
23 | * | PIO 4 | MW2 | e3 | a3 | b | | ||
24 | * | ||
25 | * sitre = word40 & 0x4000; primary | ||
26 | * sitre = word42 & 0x4000; secondary | ||
27 | * | ||
28 | * 44 8421|8421 hdd|hdb | ||
29 | * | ||
30 | * 48 8421 hdd|hdc|hdb|hda udma enabled | ||
31 | * | ||
32 | * 0001 hda | ||
33 | * 0010 hdb | ||
34 | * 0100 hdc | ||
35 | * 1000 hdd | ||
36 | * | ||
37 | * 4a 84|21 hdb|hda | ||
38 | * 4b 84|21 hdd|hdc | ||
39 | * | ||
40 | * ata-33/82371AB | ||
41 | * ata-33/82371EB | ||
42 | * ata-33/82801AB ata-66/82801AA | ||
43 | * 00|00 udma 0 00|00 reserved | ||
44 | * 01|01 udma 1 01|01 udma 3 | ||
45 | * 10|10 udma 2 10|10 udma 4 | ||
46 | * 11|11 reserved 11|11 reserved | ||
47 | * | ||
48 | * 54 8421|8421 ata66 drive|ata66 enable | ||
49 | * | ||
50 | * pci_read_config_word(HWIF(drive)->pci_dev, 0x40, ®40); | ||
51 | * pci_read_config_word(HWIF(drive)->pci_dev, 0x42, ®42); | ||
52 | * pci_read_config_word(HWIF(drive)->pci_dev, 0x44, ®44); | ||
53 | * pci_read_config_byte(HWIF(drive)->pci_dev, 0x48, ®48); | ||
54 | * pci_read_config_word(HWIF(drive)->pci_dev, 0x4a, ®4a); | ||
55 | * pci_read_config_byte(HWIF(drive)->pci_dev, 0x54, ®54); | ||
56 | * | 10 | * |
57 | * Documentation | ||
58 | * Publically available from Intel web site. Errata documentation | 11 | * Publically available from Intel web site. Errata documentation |
59 | * is also publically available. As an aide to anyone hacking on this | 12 | * is also publically available. As an aide to anyone hacking on this |
60 | * driver the list of errata that are relevant is below.going back to | 13 | * driver the list of errata that are relevant is below.going back to |
@@ -116,7 +69,7 @@ static int no_piix_dma; | |||
116 | static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio) | 69 | static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio) |
117 | { | 70 | { |
118 | ide_hwif_t *hwif = HWIF(drive); | 71 | ide_hwif_t *hwif = HWIF(drive); |
119 | struct pci_dev *dev = hwif->pci_dev; | 72 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
120 | int is_slave = drive->dn & 1; | 73 | int is_slave = drive->dn & 1; |
121 | int master_port = hwif->channel ? 0x42 : 0x40; | 74 | int master_port = hwif->channel ? 0x42 : 0x40; |
122 | int slave_port = 0x44; | 75 | int slave_port = 0x44; |
@@ -185,7 +138,7 @@ static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
185 | static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) | 138 | static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) |
186 | { | 139 | { |
187 | ide_hwif_t *hwif = HWIF(drive); | 140 | ide_hwif_t *hwif = HWIF(drive); |
188 | struct pci_dev *dev = hwif->pci_dev; | 141 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
189 | u8 maslave = hwif->channel ? 0x42 : 0x40; | 142 | u8 maslave = hwif->channel ? 0x42 : 0x40; |
190 | int a_speed = 3 << (drive->dn * 4); | 143 | int a_speed = 3 << (drive->dn * 4); |
191 | int u_flag = 1 << drive->dn; | 144 | int u_flag = 1 << drive->dn; |
@@ -305,7 +258,7 @@ static const struct ich_laptop ich_laptop[] = { | |||
305 | 258 | ||
306 | static u8 __devinit piix_cable_detect(ide_hwif_t *hwif) | 259 | static u8 __devinit piix_cable_detect(ide_hwif_t *hwif) |
307 | { | 260 | { |
308 | struct pci_dev *pdev = hwif->pci_dev; | 261 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
309 | const struct ich_laptop *lap = &ich_laptop[0]; | 262 | const struct ich_laptop *lap = &ich_laptop[0]; |
310 | u8 reg54h = 0, mask = hwif->channel ? 0xc0 : 0x30; | 263 | u8 reg54h = 0, mask = hwif->channel ? 0xc0 : 0x30; |
311 | 264 | ||
diff --git a/drivers/ide/pci/rz1000.c b/drivers/ide/pci/rz1000.c index 6b10ae260fa2..7ed6625819d4 100644 --- a/drivers/ide/pci/rz1000.c +++ b/drivers/ide/pci/rz1000.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/rz1000.c Version 0.06 January 12, 2003 | ||
3 | * | ||
4 | * Copyright (C) 1995-1998 Linus Torvalds & author (see below) | 2 | * Copyright (C) 1995-1998 Linus Torvalds & author (see below) |
5 | */ | 3 | */ |
6 | 4 | ||
@@ -32,8 +30,8 @@ | |||
32 | 30 | ||
33 | static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif) | 31 | static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif) |
34 | { | 32 | { |
33 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
35 | u16 reg; | 34 | u16 reg; |
36 | struct pci_dev *dev = hwif->pci_dev; | ||
37 | 35 | ||
38 | if (!pci_read_config_word (dev, 0x40, ®) && | 36 | if (!pci_read_config_word (dev, 0x40, ®) && |
39 | !pci_write_config_word(dev, 0x40, reg & 0xdfff)) { | 37 | !pci_write_config_word(dev, 0x40, reg & 0xdfff)) { |
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c index 32fdf53379f5..af499a60eb31 100644 --- a/drivers/ide/pci/sc1200.c +++ b/drivers/ide/pci/sc1200.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/sc1200.c Version 0.97 Aug 3 2007 | ||
3 | * | ||
4 | * Copyright (C) 2000-2002 Mark Lord <mlord@pobox.com> | 2 | * Copyright (C) 2000-2002 Mark Lord <mlord@pobox.com> |
5 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz | 3 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz |
6 | * | 4 | * |
@@ -87,7 +85,7 @@ static const unsigned int sc1200_pio_timings[4][5] = | |||
87 | static void sc1200_tunepio(ide_drive_t *drive, u8 pio) | 85 | static void sc1200_tunepio(ide_drive_t *drive, u8 pio) |
88 | { | 86 | { |
89 | ide_hwif_t *hwif = drive->hwif; | 87 | ide_hwif_t *hwif = drive->hwif; |
90 | struct pci_dev *pdev = hwif->pci_dev; | 88 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
91 | unsigned int basereg = hwif->channel ? 0x50 : 0x40, format = 0; | 89 | unsigned int basereg = hwif->channel ? 0x50 : 0x40, format = 0; |
92 | 90 | ||
93 | pci_read_config_dword(pdev, basereg + 4, &format); | 91 | pci_read_config_dword(pdev, basereg + 4, &format); |
@@ -130,6 +128,7 @@ out: | |||
130 | static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode) | 128 | static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode) |
131 | { | 129 | { |
132 | ide_hwif_t *hwif = HWIF(drive); | 130 | ide_hwif_t *hwif = HWIF(drive); |
131 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
133 | int unit = drive->select.b.unit; | 132 | int unit = drive->select.b.unit; |
134 | unsigned int reg, timings; | 133 | unsigned int reg, timings; |
135 | unsigned short pci_clock; | 134 | unsigned short pci_clock; |
@@ -160,12 +159,11 @@ static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
160 | timings = mwdma_timing[pci_clock][mode - XFER_MW_DMA_0]; | 159 | timings = mwdma_timing[pci_clock][mode - XFER_MW_DMA_0]; |
161 | 160 | ||
162 | if (unit == 0) { /* are we configuring drive0? */ | 161 | if (unit == 0) { /* are we configuring drive0? */ |
163 | pci_read_config_dword(hwif->pci_dev, basereg+4, ®); | 162 | pci_read_config_dword(dev, basereg + 4, ®); |
164 | timings |= reg & 0x80000000; /* preserve PIO format bit */ | 163 | timings |= reg & 0x80000000; /* preserve PIO format bit */ |
165 | pci_write_config_dword(hwif->pci_dev, basereg+4, timings); | 164 | pci_write_config_dword(dev, basereg + 4, timings); |
166 | } else { | 165 | } else |
167 | pci_write_config_dword(hwif->pci_dev, basereg+12, timings); | 166 | pci_write_config_dword(dev, basereg + 12, timings); |
168 | } | ||
169 | } | 167 | } |
170 | 168 | ||
171 | /* Replacement for the standard ide_dma_end action in | 169 | /* Replacement for the standard ide_dma_end action in |
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c index 24a85bbcd2a6..7694969b02ce 100644 --- a/drivers/ide/pci/scc_pata.c +++ b/drivers/ide/pci/scc_pata.c | |||
@@ -594,7 +594,7 @@ static int __devinit init_setup_scc(struct pci_dev *dev, | |||
594 | 594 | ||
595 | static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif) | 595 | static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif) |
596 | { | 596 | { |
597 | struct pci_dev *dev = hwif->pci_dev; | 597 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
598 | struct scc_ports *ports = pci_get_drvdata(dev); | 598 | struct scc_ports *ports = pci_get_drvdata(dev); |
599 | unsigned long dma_base = ports->dma; | 599 | unsigned long dma_base = ports->dma; |
600 | 600 | ||
@@ -620,7 +620,7 @@ static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif) | |||
620 | hwif->io_ports[IDE_STATUS_OFFSET] = dma_base + 0x3c; | 620 | hwif->io_ports[IDE_STATUS_OFFSET] = dma_base + 0x3c; |
621 | hwif->io_ports[IDE_CONTROL_OFFSET] = dma_base + 0x40; | 621 | hwif->io_ports[IDE_CONTROL_OFFSET] = dma_base + 0x40; |
622 | 622 | ||
623 | hwif->irq = hwif->pci_dev->irq; | 623 | hwif->irq = dev->irq; |
624 | hwif->dma_base = dma_base; | 624 | hwif->dma_base = dma_base; |
625 | hwif->config_data = ports->ctl; | 625 | hwif->config_data = ports->ctl; |
626 | hwif->mmio = 1; | 626 | hwif->mmio = 1; |
@@ -636,7 +636,8 @@ static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif) | |||
636 | 636 | ||
637 | static void __devinit init_iops_scc(ide_hwif_t *hwif) | 637 | static void __devinit init_iops_scc(ide_hwif_t *hwif) |
638 | { | 638 | { |
639 | struct pci_dev *dev = hwif->pci_dev; | 639 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
640 | |||
640 | hwif->hwif_data = NULL; | 641 | hwif->hwif_data = NULL; |
641 | if (pci_get_drvdata(dev) == NULL) | 642 | if (pci_get_drvdata(dev) == NULL) |
642 | return; | 643 | return; |
@@ -726,10 +727,8 @@ static void __devexit scc_remove(struct pci_dev *dev) | |||
726 | unsigned long dma_size = pci_resource_len(dev, 1); | 727 | unsigned long dma_size = pci_resource_len(dev, 1); |
727 | 728 | ||
728 | if (hwif->dmatable_cpu) { | 729 | if (hwif->dmatable_cpu) { |
729 | pci_free_consistent(hwif->pci_dev, | 730 | pci_free_consistent(dev, PRD_ENTRIES * PRD_BYTES, |
730 | PRD_ENTRIES * PRD_BYTES, | 731 | hwif->dmatable_cpu, hwif->dmatable_dma); |
731 | hwif->dmatable_cpu, | ||
732 | hwif->dmatable_dma); | ||
733 | hwif->dmatable_cpu = NULL; | 732 | hwif->dmatable_cpu = NULL; |
734 | } | 733 | } |
735 | 734 | ||
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c index 877c09bf4829..f495253b7d41 100644 --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/serverworks.c Version 0.22 Jun 27 2007 | ||
3 | * | ||
4 | * Copyright (C) 1998-2000 Michel Aubry | 2 | * Copyright (C) 1998-2000 Michel Aubry |
5 | * Copyright (C) 1998-2000 Andrzej Krzysztofowicz | 3 | * Copyright (C) 1998-2000 Andrzej Krzysztofowicz |
6 | * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> | 4 | * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> |
@@ -67,7 +65,7 @@ static int check_in_drive_lists (ide_drive_t *drive, const char **list) | |||
67 | 65 | ||
68 | static u8 svwks_udma_filter(ide_drive_t *drive) | 66 | static u8 svwks_udma_filter(ide_drive_t *drive) |
69 | { | 67 | { |
70 | struct pci_dev *dev = HWIF(drive)->pci_dev; | 68 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
71 | u8 mask = 0; | 69 | u8 mask = 0; |
72 | 70 | ||
73 | if (dev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) | 71 | if (dev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) |
@@ -130,7 +128,7 @@ static void svwks_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
130 | static const u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 }; | 128 | static const u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 }; |
131 | static const u8 drive_pci[] = { 0x41, 0x40, 0x43, 0x42 }; | 129 | static const u8 drive_pci[] = { 0x41, 0x40, 0x43, 0x42 }; |
132 | 130 | ||
133 | struct pci_dev *dev = drive->hwif->pci_dev; | 131 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
134 | 132 | ||
135 | pci_write_config_byte(dev, drive_pci[drive->dn], pio_modes[pio]); | 133 | pci_write_config_byte(dev, drive_pci[drive->dn], pio_modes[pio]); |
136 | 134 | ||
@@ -153,7 +151,7 @@ static void svwks_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
153 | static const u8 drive_pci2[] = { 0x45, 0x44, 0x47, 0x46 }; | 151 | static const u8 drive_pci2[] = { 0x45, 0x44, 0x47, 0x46 }; |
154 | 152 | ||
155 | ide_hwif_t *hwif = HWIF(drive); | 153 | ide_hwif_t *hwif = HWIF(drive); |
156 | struct pci_dev *dev = hwif->pci_dev; | 154 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
157 | u8 unit = (drive->select.b.unit & 0x01); | 155 | u8 unit = (drive->select.b.unit & 0x01); |
158 | 156 | ||
159 | u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0; | 157 | u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0; |
@@ -287,7 +285,8 @@ static u8 __devinit ata66_svwks_svwks(ide_hwif_t *hwif) | |||
287 | */ | 285 | */ |
288 | static u8 __devinit ata66_svwks_dell(ide_hwif_t *hwif) | 286 | static u8 __devinit ata66_svwks_dell(ide_hwif_t *hwif) |
289 | { | 287 | { |
290 | struct pci_dev *dev = hwif->pci_dev; | 288 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
289 | |||
291 | if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL && | 290 | if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL && |
292 | dev->vendor == PCI_VENDOR_ID_SERVERWORKS && | 291 | dev->vendor == PCI_VENDOR_ID_SERVERWORKS && |
293 | (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE || | 292 | (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE || |
@@ -305,7 +304,8 @@ static u8 __devinit ata66_svwks_dell(ide_hwif_t *hwif) | |||
305 | */ | 304 | */ |
306 | static u8 __devinit ata66_svwks_cobalt(ide_hwif_t *hwif) | 305 | static u8 __devinit ata66_svwks_cobalt(ide_hwif_t *hwif) |
307 | { | 306 | { |
308 | struct pci_dev *dev = hwif->pci_dev; | 307 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
308 | |||
309 | if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN && | 309 | if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN && |
310 | dev->vendor == PCI_VENDOR_ID_SERVERWORKS && | 310 | dev->vendor == PCI_VENDOR_ID_SERVERWORKS && |
311 | dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) | 311 | dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) |
@@ -316,7 +316,7 @@ static u8 __devinit ata66_svwks_cobalt(ide_hwif_t *hwif) | |||
316 | 316 | ||
317 | static u8 __devinit ata66_svwks(ide_hwif_t *hwif) | 317 | static u8 __devinit ata66_svwks(ide_hwif_t *hwif) |
318 | { | 318 | { |
319 | struct pci_dev *dev = hwif->pci_dev; | 319 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
320 | 320 | ||
321 | /* Server Works */ | 321 | /* Server Works */ |
322 | if (dev->subsystem_vendor == PCI_VENDOR_ID_SERVERWORKS) | 322 | if (dev->subsystem_vendor == PCI_VENDOR_ID_SERVERWORKS) |
@@ -340,6 +340,8 @@ static u8 __devinit ata66_svwks(ide_hwif_t *hwif) | |||
340 | 340 | ||
341 | static void __devinit init_hwif_svwks (ide_hwif_t *hwif) | 341 | static void __devinit init_hwif_svwks (ide_hwif_t *hwif) |
342 | { | 342 | { |
343 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
344 | |||
343 | hwif->set_pio_mode = &svwks_set_pio_mode; | 345 | hwif->set_pio_mode = &svwks_set_pio_mode; |
344 | hwif->set_dma_mode = &svwks_set_dma_mode; | 346 | hwif->set_dma_mode = &svwks_set_dma_mode; |
345 | hwif->udma_filter = &svwks_udma_filter; | 347 | hwif->udma_filter = &svwks_udma_filter; |
@@ -347,7 +349,7 @@ static void __devinit init_hwif_svwks (ide_hwif_t *hwif) | |||
347 | if (!hwif->dma_base) | 349 | if (!hwif->dma_base) |
348 | return; | 350 | return; |
349 | 351 | ||
350 | if (hwif->pci_dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { | 352 | if (dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { |
351 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | 353 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) |
352 | hwif->cbl = ata66_svwks(hwif); | 354 | hwif->cbl = ata66_svwks(hwif); |
353 | } | 355 | } |
@@ -418,7 +420,9 @@ static int __devinit svwks_init_one(struct pci_dev *dev, const struct pci_device | |||
418 | 420 | ||
419 | d = serverworks_chipsets[idx]; | 421 | d = serverworks_chipsets[idx]; |
420 | 422 | ||
421 | if (idx == 2 || idx == 3) { | 423 | if (idx == 1) |
424 | d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; | ||
425 | else if (idx == 2 || idx == 3) { | ||
422 | if ((PCI_FUNC(dev->devfn) & 1) == 0) { | 426 | if ((PCI_FUNC(dev->devfn) & 1) == 0) { |
423 | if (pci_resource_start(dev, 0) != 0x01f1) | 427 | if (pci_resource_start(dev, 0) != 0x01f1) |
424 | d.host_flags &= ~IDE_HFLAG_BOOTABLE; | 428 | d.host_flags &= ~IDE_HFLAG_BOOTABLE; |
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c index 9e0be7d54980..85902074b1fc 100644 --- a/drivers/ide/pci/sgiioc4.c +++ b/drivers/ide/pci/sgiioc4.c | |||
@@ -159,6 +159,7 @@ sgiioc4_clearirq(ide_drive_t * drive) | |||
159 | } | 159 | } |
160 | 160 | ||
161 | if (intr_reg & 0x02) { | 161 | if (intr_reg & 0x02) { |
162 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
162 | /* Error when transferring DMA data on PCI bus */ | 163 | /* Error when transferring DMA data on PCI bus */ |
163 | u32 pci_err_addr_low, pci_err_addr_high, | 164 | u32 pci_err_addr_low, pci_err_addr_high, |
164 | pci_stat_cmd_reg; | 165 | pci_stat_cmd_reg; |
@@ -167,7 +168,7 @@ sgiioc4_clearirq(ide_drive_t * drive) | |||
167 | readl((void __iomem *)hwif->io_ports[IDE_IRQ_OFFSET]); | 168 | readl((void __iomem *)hwif->io_ports[IDE_IRQ_OFFSET]); |
168 | pci_err_addr_high = | 169 | pci_err_addr_high = |
169 | readl((void __iomem *)(hwif->io_ports[IDE_IRQ_OFFSET] + 4)); | 170 | readl((void __iomem *)(hwif->io_ports[IDE_IRQ_OFFSET] + 4)); |
170 | pci_read_config_dword(hwif->pci_dev, PCI_COMMAND, | 171 | pci_read_config_dword(dev, PCI_COMMAND, |
171 | &pci_stat_cmd_reg); | 172 | &pci_stat_cmd_reg); |
172 | printk(KERN_ERR | 173 | printk(KERN_ERR |
173 | "%s(%s) : PCI Bus Error when doing DMA:" | 174 | "%s(%s) : PCI Bus Error when doing DMA:" |
@@ -178,8 +179,7 @@ sgiioc4_clearirq(ide_drive_t * drive) | |||
178 | __FUNCTION__, drive->name, | 179 | __FUNCTION__, drive->name, |
179 | pci_err_addr_high, pci_err_addr_low); | 180 | pci_err_addr_high, pci_err_addr_low); |
180 | /* Clear the PCI Error indicator */ | 181 | /* Clear the PCI Error indicator */ |
181 | pci_write_config_dword(hwif->pci_dev, PCI_COMMAND, | 182 | pci_write_config_dword(dev, PCI_COMMAND, 0x00000146); |
182 | 0x00000146); | ||
183 | } | 183 | } |
184 | 184 | ||
185 | /* Clear the Interrupt, Error bits on the IOC4 */ | 185 | /* Clear the Interrupt, Error bits on the IOC4 */ |
@@ -334,6 +334,7 @@ sgiioc4_INB(unsigned long port) | |||
334 | static int __devinit | 334 | static int __devinit |
335 | ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) | 335 | ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) |
336 | { | 336 | { |
337 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
337 | void __iomem *virt_dma_base; | 338 | void __iomem *virt_dma_base; |
338 | int num_ports = sizeof (ioc4_dma_regs_t); | 339 | int num_ports = sizeof (ioc4_dma_regs_t); |
339 | void *pad; | 340 | void *pad; |
@@ -359,7 +360,7 @@ ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) | |||
359 | } | 360 | } |
360 | hwif->dma_base = (unsigned long) virt_dma_base; | 361 | hwif->dma_base = (unsigned long) virt_dma_base; |
361 | 362 | ||
362 | hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev, | 363 | hwif->dmatable_cpu = pci_alloc_consistent(dev, |
363 | IOC4_PRD_ENTRIES * IOC4_PRD_BYTES, | 364 | IOC4_PRD_ENTRIES * IOC4_PRD_BYTES, |
364 | &hwif->dmatable_dma); | 365 | &hwif->dmatable_dma); |
365 | 366 | ||
@@ -368,7 +369,7 @@ ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) | |||
368 | 369 | ||
369 | hwif->sg_max_nents = IOC4_PRD_ENTRIES; | 370 | hwif->sg_max_nents = IOC4_PRD_ENTRIES; |
370 | 371 | ||
371 | pad = pci_alloc_consistent(hwif->pci_dev, IOC4_IDE_CACHELINE_SIZE, | 372 | pad = pci_alloc_consistent(dev, IOC4_IDE_CACHELINE_SIZE, |
372 | (dma_addr_t *) &(hwif->dma_status)); | 373 | (dma_addr_t *) &(hwif->dma_status)); |
373 | 374 | ||
374 | if (pad) { | 375 | if (pad) { |
@@ -376,8 +377,7 @@ ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) | |||
376 | return 0; | 377 | return 0; |
377 | } | 378 | } |
378 | 379 | ||
379 | pci_free_consistent(hwif->pci_dev, | 380 | pci_free_consistent(dev, IOC4_PRD_ENTRIES * IOC4_PRD_BYTES, |
380 | IOC4_PRD_ENTRIES * IOC4_PRD_BYTES, | ||
381 | hwif->dmatable_cpu, hwif->dmatable_dma); | 381 | hwif->dmatable_cpu, hwif->dmatable_dma); |
382 | printk(KERN_INFO | 382 | printk(KERN_INFO |
383 | "%s() -- Error! Unable to allocate DMA Maps for drive %s\n", | 383 | "%s() -- Error! Unable to allocate DMA Maps for drive %s\n", |
@@ -517,8 +517,7 @@ sgiioc4_build_dma_table(ide_drive_t * drive, struct request *rq, int ddir) | |||
517 | } | 517 | } |
518 | 518 | ||
519 | use_pio_instead: | 519 | use_pio_instead: |
520 | pci_unmap_sg(hwif->pci_dev, hwif->sg_table, hwif->sg_nents, | 520 | ide_destroy_dmatable(drive); |
521 | hwif->sg_dma_direction); | ||
522 | 521 | ||
523 | return 0; /* revert to PIO for this request */ | 522 | return 0; /* revert to PIO for this request */ |
524 | } | 523 | } |
@@ -641,7 +640,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
641 | hw.dev = &dev->dev; | 640 | hw.dev = &dev->dev; |
642 | ide_init_port_hw(hwif, &hw); | 641 | ide_init_port_hw(hwif, &hw); |
643 | 642 | ||
644 | hwif->pci_dev = dev; | 643 | hwif->dev = &dev->dev; |
645 | hwif->channel = 0; /* Single Channel chip */ | 644 | hwif->channel = 0; /* Single Channel chip */ |
646 | 645 | ||
647 | /* The IOC4 uses MMIO rather than Port IO. */ | 646 | /* The IOC4 uses MMIO rather than Port IO. */ |
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c index 908f37b4e0ee..4877bc8cd599 100644 --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/siimage.c Version 1.19 Nov 16 2007 | ||
3 | * | ||
4 | * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> | 2 | * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> |
5 | * Copyright (C) 2003 Red Hat <alan@redhat.com> | 3 | * Copyright (C) 2003 Red Hat <alan@redhat.com> |
6 | * Copyright (C) 2007 MontaVista Software, Inc. | 4 | * Copyright (C) 2007 MontaVista Software, Inc. |
@@ -79,7 +77,7 @@ static int pdev_is_sata(struct pci_dev *pdev) | |||
79 | 77 | ||
80 | static inline int is_sata(ide_hwif_t *hwif) | 78 | static inline int is_sata(ide_hwif_t *hwif) |
81 | { | 79 | { |
82 | return pdev_is_sata(hwif->pci_dev); | 80 | return pdev_is_sata(to_pci_dev(hwif->dev)); |
83 | } | 81 | } |
84 | 82 | ||
85 | /** | 83 | /** |
@@ -140,13 +138,14 @@ static inline unsigned long siimage_seldev(ide_drive_t *drive, int r) | |||
140 | static u8 sil_pata_udma_filter(ide_drive_t *drive) | 138 | static u8 sil_pata_udma_filter(ide_drive_t *drive) |
141 | { | 139 | { |
142 | ide_hwif_t *hwif = drive->hwif; | 140 | ide_hwif_t *hwif = drive->hwif; |
141 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
143 | unsigned long base = (unsigned long) hwif->hwif_data; | 142 | unsigned long base = (unsigned long) hwif->hwif_data; |
144 | u8 mask = 0, scsc = 0; | 143 | u8 mask = 0, scsc = 0; |
145 | 144 | ||
146 | if (hwif->mmio) | 145 | if (hwif->mmio) |
147 | scsc = hwif->INB(base + 0x4A); | 146 | scsc = hwif->INB(base + 0x4A); |
148 | else | 147 | else |
149 | pci_read_config_byte(hwif->pci_dev, 0x8A, &scsc); | 148 | pci_read_config_byte(dev, 0x8A, &scsc); |
150 | 149 | ||
151 | if ((scsc & 0x30) == 0x10) /* 133 */ | 150 | if ((scsc & 0x30) == 0x10) /* 133 */ |
152 | mask = ATA_UDMA6; | 151 | mask = ATA_UDMA6; |
@@ -219,19 +218,21 @@ static void sil_set_pio_mode(ide_drive_t *drive, u8 pio) | |||
219 | mode |= (unit ? 0x10 : 0x01); | 218 | mode |= (unit ? 0x10 : 0x01); |
220 | hwif->OUTB(mode, base + addr_mask); | 219 | hwif->OUTB(mode, base + addr_mask); |
221 | } else { | 220 | } else { |
222 | pci_write_config_word(hwif->pci_dev, addr, speedp); | 221 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
223 | pci_write_config_word(hwif->pci_dev, tfaddr, speedt); | 222 | |
224 | pci_read_config_word(hwif->pci_dev, tfaddr-2, &speedp); | 223 | pci_write_config_word(dev, addr, speedp); |
224 | pci_write_config_word(dev, tfaddr, speedt); | ||
225 | pci_read_config_word(dev, tfaddr - 2, &speedp); | ||
225 | speedp &= ~0x200; | 226 | speedp &= ~0x200; |
226 | /* Set IORDY for mode 3 or 4 */ | 227 | /* Set IORDY for mode 3 or 4 */ |
227 | if (pio > 2) | 228 | if (pio > 2) |
228 | speedp |= 0x200; | 229 | speedp |= 0x200; |
229 | pci_write_config_word(hwif->pci_dev, tfaddr-2, speedp); | 230 | pci_write_config_word(dev, tfaddr - 2, speedp); |
230 | 231 | ||
231 | pci_read_config_byte(hwif->pci_dev, addr_mask, &mode); | 232 | pci_read_config_byte(dev, addr_mask, &mode); |
232 | mode &= ~(unit ? 0x30 : 0x03); | 233 | mode &= ~(unit ? 0x30 : 0x03); |
233 | mode |= (unit ? 0x10 : 0x01); | 234 | mode |= (unit ? 0x10 : 0x01); |
234 | pci_write_config_byte(hwif->pci_dev, addr_mask, mode); | 235 | pci_write_config_byte(dev, addr_mask, mode); |
235 | } | 236 | } |
236 | } | 237 | } |
237 | 238 | ||
@@ -250,6 +251,7 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
250 | u16 dma[] = { 0x2208, 0x10C2, 0x10C1 }; | 251 | u16 dma[] = { 0x2208, 0x10C2, 0x10C1 }; |
251 | 252 | ||
252 | ide_hwif_t *hwif = HWIF(drive); | 253 | ide_hwif_t *hwif = HWIF(drive); |
254 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
253 | u16 ultra = 0, multi = 0; | 255 | u16 ultra = 0, multi = 0; |
254 | u8 mode = 0, unit = drive->select.b.unit; | 256 | u8 mode = 0, unit = drive->select.b.unit; |
255 | unsigned long base = (unsigned long)hwif->hwif_data; | 257 | unsigned long base = (unsigned long)hwif->hwif_data; |
@@ -266,10 +268,10 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
266 | multi = hwif->INW(ma); | 268 | multi = hwif->INW(ma); |
267 | ultra = hwif->INW(ua); | 269 | ultra = hwif->INW(ua); |
268 | } else { | 270 | } else { |
269 | pci_read_config_byte(hwif->pci_dev, 0x8A, &scsc); | 271 | pci_read_config_byte(dev, 0x8A, &scsc); |
270 | pci_read_config_byte(hwif->pci_dev, addr_mask, &mode); | 272 | pci_read_config_byte(dev, addr_mask, &mode); |
271 | pci_read_config_word(hwif->pci_dev, ma, &multi); | 273 | pci_read_config_word(dev, ma, &multi); |
272 | pci_read_config_word(hwif->pci_dev, ua, &ultra); | 274 | pci_read_config_word(dev, ua, &ultra); |
273 | } | 275 | } |
274 | 276 | ||
275 | mode &= ~((unit) ? 0x30 : 0x03); | 277 | mode &= ~((unit) ? 0x30 : 0x03); |
@@ -293,9 +295,9 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
293 | hwif->OUTW(multi, ma); | 295 | hwif->OUTW(multi, ma); |
294 | hwif->OUTW(ultra, ua); | 296 | hwif->OUTW(ultra, ua); |
295 | } else { | 297 | } else { |
296 | pci_write_config_byte(hwif->pci_dev, addr_mask, mode); | 298 | pci_write_config_byte(dev, addr_mask, mode); |
297 | pci_write_config_word(hwif->pci_dev, ma, multi); | 299 | pci_write_config_word(dev, ma, multi); |
298 | pci_write_config_word(hwif->pci_dev, ua, ultra); | 300 | pci_write_config_word(dev, ua, ultra); |
299 | } | 301 | } |
300 | } | 302 | } |
301 | 303 | ||
@@ -303,6 +305,7 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
303 | static int siimage_io_ide_dma_test_irq (ide_drive_t *drive) | 305 | static int siimage_io_ide_dma_test_irq (ide_drive_t *drive) |
304 | { | 306 | { |
305 | ide_hwif_t *hwif = HWIF(drive); | 307 | ide_hwif_t *hwif = HWIF(drive); |
308 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
306 | u8 dma_altstat = 0; | 309 | u8 dma_altstat = 0; |
307 | unsigned long addr = siimage_selreg(hwif, 1); | 310 | unsigned long addr = siimage_selreg(hwif, 1); |
308 | 311 | ||
@@ -311,7 +314,7 @@ static int siimage_io_ide_dma_test_irq (ide_drive_t *drive) | |||
311 | return 1; | 314 | return 1; |
312 | 315 | ||
313 | /* return 1 if Device INTR asserted */ | 316 | /* return 1 if Device INTR asserted */ |
314 | pci_read_config_byte(hwif->pci_dev, addr, &dma_altstat); | 317 | pci_read_config_byte(dev, addr, &dma_altstat); |
315 | if (dma_altstat & 8) | 318 | if (dma_altstat & 8) |
316 | return 0; //return 1; | 319 | return 0; //return 1; |
317 | return 0; | 320 | return 0; |
@@ -377,13 +380,14 @@ static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive) | |||
377 | static int sil_sata_busproc(ide_drive_t * drive, int state) | 380 | static int sil_sata_busproc(ide_drive_t * drive, int state) |
378 | { | 381 | { |
379 | ide_hwif_t *hwif = HWIF(drive); | 382 | ide_hwif_t *hwif = HWIF(drive); |
383 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
380 | u32 stat_config = 0; | 384 | u32 stat_config = 0; |
381 | unsigned long addr = siimage_selreg(hwif, 0); | 385 | unsigned long addr = siimage_selreg(hwif, 0); |
382 | 386 | ||
383 | if (hwif->mmio) | 387 | if (hwif->mmio) |
384 | stat_config = readl((void __iomem *)addr); | 388 | stat_config = readl((void __iomem *)addr); |
385 | else | 389 | else |
386 | pci_read_config_dword(hwif->pci_dev, addr, &stat_config); | 390 | pci_read_config_dword(dev, addr, &stat_config); |
387 | 391 | ||
388 | switch (state) { | 392 | switch (state) { |
389 | case BUSSTATE_ON: | 393 | case BUSSTATE_ON: |
@@ -643,7 +647,7 @@ static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev, const ch | |||
643 | 647 | ||
644 | static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) | 648 | static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) |
645 | { | 649 | { |
646 | struct pci_dev *dev = hwif->pci_dev; | 650 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
647 | void *addr = pci_get_drvdata(dev); | 651 | void *addr = pci_get_drvdata(dev); |
648 | u8 ch = hwif->channel; | 652 | u8 ch = hwif->channel; |
649 | hw_regs_t hw; | 653 | hw_regs_t hw; |
@@ -756,12 +760,14 @@ static void __devinit sil_quirkproc(ide_drive_t *drive) | |||
756 | 760 | ||
757 | static void __devinit init_iops_siimage(ide_hwif_t *hwif) | 761 | static void __devinit init_iops_siimage(ide_hwif_t *hwif) |
758 | { | 762 | { |
763 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
764 | |||
759 | hwif->hwif_data = NULL; | 765 | hwif->hwif_data = NULL; |
760 | 766 | ||
761 | /* Pessimal until we finish probing */ | 767 | /* Pessimal until we finish probing */ |
762 | hwif->rqsize = 15; | 768 | hwif->rqsize = 15; |
763 | 769 | ||
764 | if (pci_get_drvdata(hwif->pci_dev) == NULL) | 770 | if (pci_get_drvdata(dev) == NULL) |
765 | return; | 771 | return; |
766 | 772 | ||
767 | init_mmio_iops_siimage(hwif); | 773 | init_mmio_iops_siimage(hwif); |
@@ -777,11 +783,12 @@ static void __devinit init_iops_siimage(ide_hwif_t *hwif) | |||
777 | 783 | ||
778 | static u8 __devinit ata66_siimage(ide_hwif_t *hwif) | 784 | static u8 __devinit ata66_siimage(ide_hwif_t *hwif) |
779 | { | 785 | { |
786 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
780 | unsigned long addr = siimage_selreg(hwif, 0); | 787 | unsigned long addr = siimage_selreg(hwif, 0); |
781 | u8 ata66 = 0; | 788 | u8 ata66 = 0; |
782 | 789 | ||
783 | if (pci_get_drvdata(hwif->pci_dev) == NULL) | 790 | if (pci_get_drvdata(dev) == NULL) |
784 | pci_read_config_byte(hwif->pci_dev, addr, &ata66); | 791 | pci_read_config_byte(dev, addr, &ata66); |
785 | else | 792 | else |
786 | ata66 = hwif->INB(addr); | 793 | ata66 = hwif->INB(addr); |
787 | 794 | ||
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c index 85d36996e6af..2a461de22aa0 100644 --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/sis5513.c Version 0.31 Aug 9, 2007 | ||
3 | * | ||
4 | * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> | 2 | * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> |
5 | * Copyright (C) 2002 Lionel Bouton <Lionel.Bouton@inet6.fr>, Maintainer | 3 | * Copyright (C) 2002 Lionel Bouton <Lionel.Bouton@inet6.fr>, Maintainer |
6 | * Copyright (C) 2003 Vojtech Pavlik <vojtech@suse.cz> | 4 | * Copyright (C) 2003 Vojtech Pavlik <vojtech@suse.cz> |
@@ -197,7 +195,7 @@ static char* chipset_capability[] = { | |||
197 | 195 | ||
198 | static u8 sis_ata133_get_base(ide_drive_t *drive) | 196 | static u8 sis_ata133_get_base(ide_drive_t *drive) |
199 | { | 197 | { |
200 | struct pci_dev *dev = drive->hwif->pci_dev; | 198 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
201 | u32 reg54 = 0; | 199 | u32 reg54 = 0; |
202 | 200 | ||
203 | pci_read_config_dword(dev, 0x54, ®54); | 201 | pci_read_config_dword(dev, 0x54, ®54); |
@@ -207,7 +205,7 @@ static u8 sis_ata133_get_base(ide_drive_t *drive) | |||
207 | 205 | ||
208 | static void sis_ata16_program_timings(ide_drive_t *drive, const u8 mode) | 206 | static void sis_ata16_program_timings(ide_drive_t *drive, const u8 mode) |
209 | { | 207 | { |
210 | struct pci_dev *dev = drive->hwif->pci_dev; | 208 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
211 | u16 t1 = 0; | 209 | u16 t1 = 0; |
212 | u8 drive_pci = 0x40 + drive->dn * 2; | 210 | u8 drive_pci = 0x40 + drive->dn * 2; |
213 | 211 | ||
@@ -230,7 +228,7 @@ static void sis_ata16_program_timings(ide_drive_t *drive, const u8 mode) | |||
230 | 228 | ||
231 | static void sis_ata100_program_timings(ide_drive_t *drive, const u8 mode) | 229 | static void sis_ata100_program_timings(ide_drive_t *drive, const u8 mode) |
232 | { | 230 | { |
233 | struct pci_dev *dev = drive->hwif->pci_dev; | 231 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
234 | u8 t1, drive_pci = 0x40 + drive->dn * 2; | 232 | u8 t1, drive_pci = 0x40 + drive->dn * 2; |
235 | 233 | ||
236 | /* timing bits: 7:4 active 3:0 recovery */ | 234 | /* timing bits: 7:4 active 3:0 recovery */ |
@@ -253,7 +251,7 @@ static void sis_ata100_program_timings(ide_drive_t *drive, const u8 mode) | |||
253 | 251 | ||
254 | static void sis_ata133_program_timings(ide_drive_t *drive, const u8 mode) | 252 | static void sis_ata133_program_timings(ide_drive_t *drive, const u8 mode) |
255 | { | 253 | { |
256 | struct pci_dev *dev = drive->hwif->pci_dev; | 254 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
257 | u32 t1 = 0; | 255 | u32 t1 = 0; |
258 | u8 drive_pci = sis_ata133_get_base(drive), clk, idx; | 256 | u8 drive_pci = sis_ata133_get_base(drive), clk, idx; |
259 | 257 | ||
@@ -286,7 +284,7 @@ static void sis_program_timings(ide_drive_t *drive, const u8 mode) | |||
286 | static void config_drive_art_rwp (ide_drive_t *drive) | 284 | static void config_drive_art_rwp (ide_drive_t *drive) |
287 | { | 285 | { |
288 | ide_hwif_t *hwif = HWIF(drive); | 286 | ide_hwif_t *hwif = HWIF(drive); |
289 | struct pci_dev *dev = hwif->pci_dev; | 287 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
290 | u8 reg4bh = 0; | 288 | u8 reg4bh = 0; |
291 | u8 rw_prefetch = 0; | 289 | u8 rw_prefetch = 0; |
292 | 290 | ||
@@ -307,7 +305,7 @@ static void sis_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
307 | 305 | ||
308 | static void sis_ata133_program_udma_timings(ide_drive_t *drive, const u8 mode) | 306 | static void sis_ata133_program_udma_timings(ide_drive_t *drive, const u8 mode) |
309 | { | 307 | { |
310 | struct pci_dev *dev = drive->hwif->pci_dev; | 308 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
311 | u32 regdw = 0; | 309 | u32 regdw = 0; |
312 | u8 drive_pci = sis_ata133_get_base(drive), clk, idx; | 310 | u8 drive_pci = sis_ata133_get_base(drive), clk, idx; |
313 | 311 | ||
@@ -326,7 +324,7 @@ static void sis_ata133_program_udma_timings(ide_drive_t *drive, const u8 mode) | |||
326 | 324 | ||
327 | static void sis_ata33_program_udma_timings(ide_drive_t *drive, const u8 mode) | 325 | static void sis_ata33_program_udma_timings(ide_drive_t *drive, const u8 mode) |
328 | { | 326 | { |
329 | struct pci_dev *dev = drive->hwif->pci_dev; | 327 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
330 | u8 drive_pci = 0x40 + drive->dn * 2, reg = 0, i = chipset_family; | 328 | u8 drive_pci = 0x40 + drive->dn * 2, reg = 0, i = chipset_family; |
331 | 329 | ||
332 | pci_read_config_byte(dev, drive_pci + 1, ®); | 330 | pci_read_config_byte(dev, drive_pci + 1, ®); |
@@ -359,7 +357,7 @@ static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
359 | 357 | ||
360 | static u8 sis5513_ata133_udma_filter(ide_drive_t *drive) | 358 | static u8 sis5513_ata133_udma_filter(ide_drive_t *drive) |
361 | { | 359 | { |
362 | struct pci_dev *dev = drive->hwif->pci_dev; | 360 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
363 | u32 regdw = 0; | 361 | u32 regdw = 0; |
364 | u8 drive_pci = sis_ata133_get_base(drive); | 362 | u8 drive_pci = sis_ata133_get_base(drive); |
365 | 363 | ||
@@ -530,7 +528,7 @@ static const struct sis_laptop sis_laptop[] = { | |||
530 | 528 | ||
531 | static u8 __devinit ata66_sis5513(ide_hwif_t *hwif) | 529 | static u8 __devinit ata66_sis5513(ide_hwif_t *hwif) |
532 | { | 530 | { |
533 | struct pci_dev *pdev = hwif->pci_dev; | 531 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
534 | const struct sis_laptop *lap = &sis_laptop[0]; | 532 | const struct sis_laptop *lap = &sis_laptop[0]; |
535 | u8 ata66 = 0; | 533 | u8 ata66 = 0; |
536 | 534 | ||
@@ -545,12 +543,12 @@ static u8 __devinit ata66_sis5513(ide_hwif_t *hwif) | |||
545 | if (chipset_family >= ATA_133) { | 543 | if (chipset_family >= ATA_133) { |
546 | u16 regw = 0; | 544 | u16 regw = 0; |
547 | u16 reg_addr = hwif->channel ? 0x52: 0x50; | 545 | u16 reg_addr = hwif->channel ? 0x52: 0x50; |
548 | pci_read_config_word(hwif->pci_dev, reg_addr, ®w); | 546 | pci_read_config_word(pdev, reg_addr, ®w); |
549 | ata66 = (regw & 0x8000) ? 0 : 1; | 547 | ata66 = (regw & 0x8000) ? 0 : 1; |
550 | } else if (chipset_family >= ATA_66) { | 548 | } else if (chipset_family >= ATA_66) { |
551 | u8 reg48h = 0; | 549 | u8 reg48h = 0; |
552 | u8 mask = hwif->channel ? 0x20 : 0x10; | 550 | u8 mask = hwif->channel ? 0x20 : 0x10; |
553 | pci_read_config_byte(hwif->pci_dev, 0x48, ®48h); | 551 | pci_read_config_byte(pdev, 0x48, ®48h); |
554 | ata66 = (reg48h & mask) ? 0 : 1; | 552 | ata66 = (reg48h & mask) ? 0 : 1; |
555 | } | 553 | } |
556 | 554 | ||
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c index c7a125b66c29..da13a1298ada 100644 --- a/drivers/ide/pci/sl82c105.c +++ b/drivers/ide/pci/sl82c105.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/sl82c105.c | ||
3 | * | ||
4 | * SL82C105/Winbond 553 IDE driver | 2 | * SL82C105/Winbond 553 IDE driver |
5 | * | 3 | * |
6 | * Maintainer unknown. | 4 | * Maintainer unknown. |
@@ -78,7 +76,7 @@ static unsigned int get_pio_timings(ide_drive_t *drive, u8 pio) | |||
78 | */ | 76 | */ |
79 | static void sl82c105_set_pio_mode(ide_drive_t *drive, const u8 pio) | 77 | static void sl82c105_set_pio_mode(ide_drive_t *drive, const u8 pio) |
80 | { | 78 | { |
81 | struct pci_dev *dev = HWIF(drive)->pci_dev; | 79 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
82 | int reg = 0x44 + drive->dn * 4; | 80 | int reg = 0x44 + drive->dn * 4; |
83 | u16 drv_ctrl; | 81 | u16 drv_ctrl; |
84 | 82 | ||
@@ -147,7 +145,7 @@ static inline void sl82c105_reset_host(struct pci_dev *dev) | |||
147 | static void sl82c105_dma_lost_irq(ide_drive_t *drive) | 145 | static void sl82c105_dma_lost_irq(ide_drive_t *drive) |
148 | { | 146 | { |
149 | ide_hwif_t *hwif = HWIF(drive); | 147 | ide_hwif_t *hwif = HWIF(drive); |
150 | struct pci_dev *dev = hwif->pci_dev; | 148 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
151 | u32 val, mask = hwif->channel ? CTRL_IDE_IRQB : CTRL_IDE_IRQA; | 149 | u32 val, mask = hwif->channel ? CTRL_IDE_IRQB : CTRL_IDE_IRQA; |
152 | u8 dma_cmd; | 150 | u8 dma_cmd; |
153 | 151 | ||
@@ -184,7 +182,7 @@ static void sl82c105_dma_lost_irq(ide_drive_t *drive) | |||
184 | static void sl82c105_dma_start(ide_drive_t *drive) | 182 | static void sl82c105_dma_start(ide_drive_t *drive) |
185 | { | 183 | { |
186 | ide_hwif_t *hwif = HWIF(drive); | 184 | ide_hwif_t *hwif = HWIF(drive); |
187 | struct pci_dev *dev = hwif->pci_dev; | 185 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
188 | int reg = 0x44 + drive->dn * 4; | 186 | int reg = 0x44 + drive->dn * 4; |
189 | 187 | ||
190 | DBG(("%s(drive:%s)\n", __FUNCTION__, drive->name)); | 188 | DBG(("%s(drive:%s)\n", __FUNCTION__, drive->name)); |
@@ -197,15 +195,17 @@ static void sl82c105_dma_start(ide_drive_t *drive) | |||
197 | 195 | ||
198 | static void sl82c105_dma_timeout(ide_drive_t *drive) | 196 | static void sl82c105_dma_timeout(ide_drive_t *drive) |
199 | { | 197 | { |
198 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | ||
199 | |||
200 | DBG(("sl82c105_dma_timeout(drive:%s)\n", drive->name)); | 200 | DBG(("sl82c105_dma_timeout(drive:%s)\n", drive->name)); |
201 | 201 | ||
202 | sl82c105_reset_host(HWIF(drive)->pci_dev); | 202 | sl82c105_reset_host(dev); |
203 | ide_dma_timeout(drive); | 203 | ide_dma_timeout(drive); |
204 | } | 204 | } |
205 | 205 | ||
206 | static int sl82c105_dma_end(ide_drive_t *drive) | 206 | static int sl82c105_dma_end(ide_drive_t *drive) |
207 | { | 207 | { |
208 | struct pci_dev *dev = HWIF(drive)->pci_dev; | 208 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
209 | int reg = 0x44 + drive->dn * 4; | 209 | int reg = 0x44 + drive->dn * 4; |
210 | int ret; | 210 | int ret; |
211 | 211 | ||
@@ -224,7 +224,7 @@ static int sl82c105_dma_end(ide_drive_t *drive) | |||
224 | */ | 224 | */ |
225 | static void sl82c105_resetproc(ide_drive_t *drive) | 225 | static void sl82c105_resetproc(ide_drive_t *drive) |
226 | { | 226 | { |
227 | struct pci_dev *dev = HWIF(drive)->pci_dev; | 227 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
228 | u32 val; | 228 | u32 val; |
229 | 229 | ||
230 | DBG(("sl82c105_resetproc(drive:%s)\n", drive->name)); | 230 | DBG(("sl82c105_resetproc(drive:%s)\n", drive->name)); |
@@ -293,6 +293,7 @@ static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev, const c | |||
293 | */ | 293 | */ |
294 | static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) | 294 | static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) |
295 | { | 295 | { |
296 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
296 | unsigned int rev; | 297 | unsigned int rev; |
297 | 298 | ||
298 | DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index)); | 299 | DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index)); |
@@ -304,7 +305,7 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) | |||
304 | if (!hwif->dma_base) | 305 | if (!hwif->dma_base) |
305 | return; | 306 | return; |
306 | 307 | ||
307 | rev = sl82c105_bridge_revision(hwif->pci_dev); | 308 | rev = sl82c105_bridge_revision(dev); |
308 | if (rev <= 5) { | 309 | if (rev <= 5) { |
309 | /* | 310 | /* |
310 | * Never ever EVER under any circumstances enable | 311 | * Never ever EVER under any circumstances enable |
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c index dbbb46819a2d..a6cf810c4699 100644 --- a/drivers/ide/pci/slc90e66.c +++ b/drivers/ide/pci/slc90e66.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/slc90e66.c Version 0.19 Sep 24, 2007 | ||
3 | * | ||
4 | * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> | 2 | * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> |
5 | * Copyright (C) 2006-2007 MontaVista Software, Inc. <source@mvista.com> | 3 | * Copyright (C) 2006-2007 MontaVista Software, Inc. <source@mvista.com> |
6 | * | 4 | * |
@@ -26,7 +24,7 @@ static DEFINE_SPINLOCK(slc90e66_lock); | |||
26 | static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) | 24 | static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) |
27 | { | 25 | { |
28 | ide_hwif_t *hwif = HWIF(drive); | 26 | ide_hwif_t *hwif = HWIF(drive); |
29 | struct pci_dev *dev = hwif->pci_dev; | 27 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
30 | int is_slave = drive->dn & 1; | 28 | int is_slave = drive->dn & 1; |
31 | int master_port = hwif->channel ? 0x42 : 0x40; | 29 | int master_port = hwif->channel ? 0x42 : 0x40; |
32 | int slave_port = 0x44; | 30 | int slave_port = 0x44; |
@@ -79,7 +77,7 @@ static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
79 | static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed) | 77 | static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed) |
80 | { | 78 | { |
81 | ide_hwif_t *hwif = HWIF(drive); | 79 | ide_hwif_t *hwif = HWIF(drive); |
82 | struct pci_dev *dev = hwif->pci_dev; | 80 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
83 | u8 maslave = hwif->channel ? 0x42 : 0x40; | 81 | u8 maslave = hwif->channel ? 0x42 : 0x40; |
84 | int sitre = 0, a_speed = 7 << (drive->dn * 4); | 82 | int sitre = 0, a_speed = 7 << (drive->dn * 4); |
85 | int u_speed = 0, u_flag = 1 << drive->dn; | 83 | int u_speed = 0, u_flag = 1 << drive->dn; |
@@ -122,13 +120,14 @@ static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
122 | 120 | ||
123 | static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif) | 121 | static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif) |
124 | { | 122 | { |
123 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
125 | u8 reg47 = 0; | 124 | u8 reg47 = 0; |
126 | u8 mask = hwif->channel ? 0x01 : 0x02; /* bit0:Primary */ | 125 | u8 mask = hwif->channel ? 0x01 : 0x02; /* bit0:Primary */ |
127 | 126 | ||
128 | hwif->set_pio_mode = &slc90e66_set_pio_mode; | 127 | hwif->set_pio_mode = &slc90e66_set_pio_mode; |
129 | hwif->set_dma_mode = &slc90e66_set_dma_mode; | 128 | hwif->set_dma_mode = &slc90e66_set_dma_mode; |
130 | 129 | ||
131 | pci_read_config_byte(hwif->pci_dev, 0x47, ®47); | 130 | pci_read_config_byte(dev, 0x47, ®47); |
132 | 131 | ||
133 | if (hwif->dma_base == 0) | 132 | if (hwif->dma_base == 0) |
134 | return; | 133 | return; |
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c index e1faf6c2fe16..9fbbb4f2dd54 100644 --- a/drivers/ide/pci/tc86c001.c +++ b/drivers/ide/pci/tc86c001.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/ide/pci/tc86c001.c Version 1.01 Sep 5, 2007 | ||
3 | * | ||
4 | * Copyright (C) 2002 Toshiba Corporation | 2 | * Copyright (C) 2002 Toshiba Corporation |
5 | * Copyright (C) 2005-2006 MontaVista Software, Inc. <source@mvista.com> | 3 | * Copyright (C) 2005-2006 MontaVista Software, Inc. <source@mvista.com> |
6 | * | 4 | * |
@@ -164,7 +162,8 @@ static int tc86c001_busproc(ide_drive_t *drive, int state) | |||
164 | 162 | ||
165 | static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) | 163 | static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) |
166 | { | 164 | { |
167 | unsigned long sc_base = pci_resource_start(hwif->pci_dev, 5); | 165 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
166 | unsigned long sc_base = pci_resource_start(dev, 5); | ||
168 | u16 scr1 = inw(sc_base + 0x00); | 167 | u16 scr1 = inw(sc_base + 0x00); |
169 | 168 | ||
170 | /* System Control 1 Register bit 15 (Soft Reset) set */ | 169 | /* System Control 1 Register bit 15 (Soft Reset) set */ |
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c index ae52a96a1cf9..852b72693736 100644 --- a/drivers/ide/pci/triflex.c +++ b/drivers/ide/pci/triflex.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * triflex.c | ||
3 | * | ||
4 | * IDE Chipset driver for the Compaq TriFlex IDE controller. | 2 | * IDE Chipset driver for the Compaq TriFlex IDE controller. |
5 | * | 3 | * |
6 | * Known to work with the Compaq Workstation 5x00 series. | 4 | * Known to work with the Compaq Workstation 5x00 series. |
@@ -43,7 +41,7 @@ | |||
43 | static void triflex_set_mode(ide_drive_t *drive, const u8 speed) | 41 | static void triflex_set_mode(ide_drive_t *drive, const u8 speed) |
44 | { | 42 | { |
45 | ide_hwif_t *hwif = HWIF(drive); | 43 | ide_hwif_t *hwif = HWIF(drive); |
46 | struct pci_dev *dev = hwif->pci_dev; | 44 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
47 | u8 channel_offset = hwif->channel ? 0x74 : 0x70; | 45 | u8 channel_offset = hwif->channel ? 0x74 : 0x70; |
48 | u16 timing = 0; | 46 | u16 timing = 0; |
49 | u32 triflex_timings = 0; | 47 | u32 triflex_timings = 0; |
diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c index 04cd893e1ab0..d9ebb698953a 100644 --- a/drivers/ide/pci/trm290.c +++ b/drivers/ide/pci/trm290.c | |||
@@ -1,8 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/trm290.c Version 1.05 Dec. 26, 2007 | ||
3 | * | ||
4 | * Copyright (c) 1997-1998 Mark Lord | 2 | * Copyright (c) 1997-1998 Mark Lord |
5 | * Copyright (c) 2007 MontaVista Software, Inc. <source@mvista.com> | 3 | * Copyright (c) 2007 MontaVista Software, Inc. <source@mvista.com> |
4 | * | ||
6 | * May be copied or modified under the terms of the GNU General Public License | 5 | * May be copied or modified under the terms of the GNU General Public License |
7 | * | 6 | * |
8 | * June 22, 2004 - get rid of check_region | 7 | * June 22, 2004 - get rid of check_region |
@@ -209,10 +208,10 @@ static int trm290_dma_setup(ide_drive_t *drive) | |||
209 | } | 208 | } |
210 | /* select DMA xfer */ | 209 | /* select DMA xfer */ |
211 | trm290_prepare_drive(drive, 1); | 210 | trm290_prepare_drive(drive, 1); |
212 | outl(hwif->dmatable_dma | rw, hwif->dma_command); | 211 | outl(hwif->dmatable_dma | rw, hwif->dma_base); |
213 | drive->waiting_for_dma = 1; | 212 | drive->waiting_for_dma = 1; |
214 | /* start DMA */ | 213 | /* start DMA */ |
215 | outw((count * 2) - 1, hwif->dma_status); | 214 | outw(count * 2 - 1, hwif->dma_base + 2); |
216 | return 0; | 215 | return 0; |
217 | } | 216 | } |
218 | 217 | ||
@@ -222,23 +221,21 @@ static void trm290_dma_start(ide_drive_t *drive) | |||
222 | 221 | ||
223 | static int trm290_ide_dma_end (ide_drive_t *drive) | 222 | static int trm290_ide_dma_end (ide_drive_t *drive) |
224 | { | 223 | { |
225 | ide_hwif_t *hwif = HWIF(drive); | 224 | u16 status; |
226 | u16 status = 0; | ||
227 | 225 | ||
228 | drive->waiting_for_dma = 0; | 226 | drive->waiting_for_dma = 0; |
229 | /* purge DMA mappings */ | 227 | /* purge DMA mappings */ |
230 | ide_destroy_dmatable(drive); | 228 | ide_destroy_dmatable(drive); |
231 | status = inw(hwif->dma_status); | 229 | status = inw(HWIF(drive)->dma_base + 2); |
232 | return (status != 0x00ff); | 230 | return status != 0x00ff; |
233 | } | 231 | } |
234 | 232 | ||
235 | static int trm290_ide_dma_test_irq (ide_drive_t *drive) | 233 | static int trm290_ide_dma_test_irq (ide_drive_t *drive) |
236 | { | 234 | { |
237 | ide_hwif_t *hwif = HWIF(drive); | 235 | u16 status; |
238 | u16 status = 0; | ||
239 | 236 | ||
240 | status = inw(hwif->dma_status); | 237 | status = inw(HWIF(drive)->dma_base + 2); |
241 | return (status == 0x00ff); | 238 | return status == 0x00ff; |
242 | } | 239 | } |
243 | 240 | ||
244 | static void trm290_dma_host_set(ide_drive_t *drive, int on) | 241 | static void trm290_dma_host_set(ide_drive_t *drive, int on) |
@@ -247,21 +244,37 @@ static void trm290_dma_host_set(ide_drive_t *drive, int on) | |||
247 | 244 | ||
248 | static void __devinit init_hwif_trm290(ide_hwif_t *hwif) | 245 | static void __devinit init_hwif_trm290(ide_hwif_t *hwif) |
249 | { | 246 | { |
250 | unsigned int cfgbase = 0; | 247 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
248 | unsigned int cfg_base = pci_resource_start(dev, 4); | ||
251 | unsigned long flags; | 249 | unsigned long flags; |
252 | u8 reg = 0; | 250 | u8 reg = 0; |
253 | struct pci_dev *dev = hwif->pci_dev; | 251 | |
254 | 252 | if ((dev->class & 5) && cfg_base) | |
255 | cfgbase = pci_resource_start(dev, 4); | 253 | printk(KERN_INFO "TRM290: chip"); |
256 | if ((dev->class & 5) && cfgbase) { | 254 | else { |
257 | hwif->config_data = cfgbase; | 255 | cfg_base = 0x3df0; |
258 | printk(KERN_INFO "TRM290: chip config base at 0x%04lx\n", | 256 | printk(KERN_INFO "TRM290: using default"); |
259 | hwif->config_data); | ||
260 | } else { | ||
261 | hwif->config_data = 0x3df0; | ||
262 | printk(KERN_INFO "TRM290: using default config base at 0x%04lx\n", | ||
263 | hwif->config_data); | ||
264 | } | 257 | } |
258 | printk(KERN_CONT " config base at 0x%04x\n", cfg_base); | ||
259 | hwif->config_data = cfg_base; | ||
260 | hwif->dma_base = (cfg_base + 4) ^ (hwif->channel ? 0x80 : 0); | ||
261 | |||
262 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx", | ||
263 | hwif->name, hwif->dma_base, hwif->dma_base + 3); | ||
264 | |||
265 | if (!request_region(hwif->dma_base, 4, hwif->name)) { | ||
266 | printk(KERN_CONT " -- Error, ports in use.\n"); | ||
267 | return; | ||
268 | } | ||
269 | |||
270 | hwif->dmatable_cpu = pci_alloc_consistent(dev, PRD_ENTRIES * PRD_BYTES, | ||
271 | &hwif->dmatable_dma); | ||
272 | if (!hwif->dmatable_cpu) { | ||
273 | printk(KERN_CONT " -- Error, unable to allocate DMA table.\n"); | ||
274 | release_region(hwif->dma_base, 4); | ||
275 | return; | ||
276 | } | ||
277 | printk(KERN_CONT "\n"); | ||
265 | 278 | ||
266 | local_irq_save(flags); | 279 | local_irq_save(flags); |
267 | /* put config reg into first byte of hwif->select_data */ | 280 | /* put config reg into first byte of hwif->select_data */ |
@@ -276,15 +289,13 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif) | |||
276 | outb(reg, hwif->config_data + 3); | 289 | outb(reg, hwif->config_data + 3); |
277 | local_irq_restore(flags); | 290 | local_irq_restore(flags); |
278 | 291 | ||
279 | if ((reg & 0x10)) | 292 | if (reg & 0x10) |
280 | /* legacy mode */ | 293 | /* legacy mode */ |
281 | hwif->irq = hwif->channel ? 15 : 14; | 294 | hwif->irq = hwif->channel ? 15 : 14; |
282 | else if (!hwif->irq && hwif->mate && hwif->mate->irq) | 295 | else if (!hwif->irq && hwif->mate && hwif->mate->irq) |
283 | /* sharing IRQ with mate */ | 296 | /* sharing IRQ with mate */ |
284 | hwif->irq = hwif->mate->irq; | 297 | hwif->irq = hwif->mate->irq; |
285 | 298 | ||
286 | ide_setup_dma(hwif, (hwif->config_data + 4) ^ (hwif->channel ? 0x0080 : 0x0000), 3); | ||
287 | |||
288 | hwif->dma_host_set = &trm290_dma_host_set; | 299 | hwif->dma_host_set = &trm290_dma_host_set; |
289 | hwif->dma_setup = &trm290_dma_setup; | 300 | hwif->dma_setup = &trm290_dma_setup; |
290 | hwif->dma_exec_cmd = &trm290_dma_exec_cmd; | 301 | hwif->dma_exec_cmd = &trm290_dma_exec_cmd; |
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index 4b32c90f4896..24cb9047fb41 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c | |||
@@ -1,7 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * | ||
3 | * Version 3.50 | ||
4 | * | ||
5 | * VIA IDE driver for Linux. Supported southbridges: | 2 | * VIA IDE driver for Linux. Supported southbridges: |
6 | * | 3 | * |
7 | * vt82c576, vt82c586, vt82c586a, vt82c586b, vt82c596a, vt82c596b, | 4 | * vt82c576, vt82c586, vt82c586a, vt82c586b, vt82c596a, vt82c596b, |
@@ -121,8 +118,8 @@ struct via82cxxx_dev | |||
121 | 118 | ||
122 | static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing) | 119 | static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing) |
123 | { | 120 | { |
124 | struct pci_dev *dev = hwif->pci_dev; | 121 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
125 | struct via82cxxx_dev *vdev = pci_get_drvdata(hwif->pci_dev); | 122 | struct via82cxxx_dev *vdev = pci_get_drvdata(dev); |
126 | u8 t; | 123 | u8 t; |
127 | 124 | ||
128 | if (~vdev->via_config->flags & VIA_BAD_AST) { | 125 | if (~vdev->via_config->flags & VIA_BAD_AST) { |
@@ -159,8 +156,10 @@ static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing) | |||
159 | 156 | ||
160 | static void via_set_drive(ide_drive_t *drive, const u8 speed) | 157 | static void via_set_drive(ide_drive_t *drive, const u8 speed) |
161 | { | 158 | { |
162 | ide_drive_t *peer = HWIF(drive)->drives + (~drive->dn & 1); | 159 | ide_hwif_t *hwif = drive->hwif; |
163 | struct via82cxxx_dev *vdev = pci_get_drvdata(drive->hwif->pci_dev); | 160 | ide_drive_t *peer = hwif->drives + (~drive->dn & 1); |
161 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
162 | struct via82cxxx_dev *vdev = pci_get_drvdata(dev); | ||
164 | struct ide_timing t, p; | 163 | struct ide_timing t, p; |
165 | unsigned int T, UT; | 164 | unsigned int T, UT; |
166 | 165 | ||
@@ -408,7 +407,7 @@ static int via_cable_override(struct pci_dev *pdev) | |||
408 | 407 | ||
409 | static u8 __devinit via82cxxx_cable_detect(ide_hwif_t *hwif) | 408 | static u8 __devinit via82cxxx_cable_detect(ide_hwif_t *hwif) |
410 | { | 409 | { |
411 | struct pci_dev *pdev = hwif->pci_dev; | 410 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
412 | struct via82cxxx_dev *vdev = pci_get_drvdata(pdev); | 411 | struct via82cxxx_dev *vdev = pci_get_drvdata(pdev); |
413 | 412 | ||
414 | if (via_cable_override(pdev)) | 413 | if (via_cable_override(pdev)) |
diff --git a/drivers/ide/ppc/mpc8xx.c b/drivers/ide/ppc/mpc8xx.c index 3fd5d45b5e0e..45c1d55e60df 100644 --- a/drivers/ide/ppc/mpc8xx.c +++ b/drivers/ide/ppc/mpc8xx.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/ppc/ide-m8xx.c | ||
3 | * | ||
4 | * Copyright (C) 2000, 2001 Wolfgang Denk, wd@denx.de | 2 | * Copyright (C) 2000, 2001 Wolfgang Denk, wd@denx.de |
5 | * Modified for direct IDE interface | 3 | * Modified for direct IDE interface |
6 | * by Thomas Lange, thomas@corelatus.com | 4 | * by Thomas Lange, thomas@corelatus.com |
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index 736d12c8e68a..23112ef68f67 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/ppc/pmac.c | ||
3 | * | ||
4 | * Support for IDE interfaces on PowerMacs. | 2 | * Support for IDE interfaces on PowerMacs. |
3 | * | ||
5 | * These IDE interfaces are memory-mapped and have a DBDMA channel | 4 | * These IDE interfaces are memory-mapped and have a DBDMA channel |
6 | * for doing DMA. | 5 | * for doing DMA. |
7 | * | 6 | * |
@@ -1011,7 +1010,7 @@ pmac_ide_do_resume(ide_hwif_t *hwif) | |||
1011 | * (it is kept in 2.4). This introduce an interface numbering change on some | 1010 | * (it is kept in 2.4). This introduce an interface numbering change on some |
1012 | * rare machines unfortunately, but it's better this way. | 1011 | * rare machines unfortunately, but it's better this way. |
1013 | */ | 1012 | */ |
1014 | static int | 1013 | static int __devinit |
1015 | pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) | 1014 | pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) |
1016 | { | 1015 | { |
1017 | struct device_node *np = pmif->node; | 1016 | struct device_node *np = pmif->node; |
@@ -1200,7 +1199,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) | |||
1200 | base = ioremap(macio_resource_start(mdev, 0), 0x400); | 1199 | base = ioremap(macio_resource_start(mdev, 0), 0x400); |
1201 | regbase = (unsigned long) base; | 1200 | regbase = (unsigned long) base; |
1202 | 1201 | ||
1203 | hwif->pci_dev = mdev->bus->pdev; | 1202 | hwif->dev = &mdev->bus->pdev->dev; |
1204 | 1203 | ||
1205 | pmif->mdev = mdev; | 1204 | pmif->mdev = mdev; |
1206 | pmif->node = mdev->ofdev.node; | 1205 | pmif->node = mdev->ofdev.node; |
@@ -1228,12 +1227,12 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) | |||
1228 | /* The inteface is released to the common IDE layer */ | 1227 | /* The inteface is released to the common IDE layer */ |
1229 | dev_set_drvdata(&mdev->ofdev.dev, NULL); | 1228 | dev_set_drvdata(&mdev->ofdev.dev, NULL); |
1230 | iounmap(base); | 1229 | iounmap(base); |
1231 | if (pmif->dma_regs) | 1230 | if (pmif->dma_regs) { |
1232 | iounmap(pmif->dma_regs); | 1231 | iounmap(pmif->dma_regs); |
1232 | macio_release_resource(mdev, 1); | ||
1233 | } | ||
1233 | memset(pmif, 0, sizeof(*pmif)); | 1234 | memset(pmif, 0, sizeof(*pmif)); |
1234 | macio_release_resource(mdev, 0); | 1235 | macio_release_resource(mdev, 0); |
1235 | if (pmif->dma_regs) | ||
1236 | macio_release_resource(mdev, 1); | ||
1237 | } | 1236 | } |
1238 | 1237 | ||
1239 | return rc; | 1238 | return rc; |
@@ -1315,7 +1314,7 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1315 | return -ENXIO; | 1314 | return -ENXIO; |
1316 | } | 1315 | } |
1317 | 1316 | ||
1318 | hwif->pci_dev = pdev; | 1317 | hwif->dev = &pdev->dev; |
1319 | pmif->mdev = NULL; | 1318 | pmif->mdev = NULL; |
1320 | pmif->node = np; | 1319 | pmif->node = np; |
1321 | 1320 | ||
@@ -1535,11 +1534,10 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq) | |||
1535 | } | 1534 | } |
1536 | 1535 | ||
1537 | printk(KERN_DEBUG "%s: empty DMA table?\n", drive->name); | 1536 | printk(KERN_DEBUG "%s: empty DMA table?\n", drive->name); |
1538 | use_pio_instead: | 1537 | |
1539 | pci_unmap_sg(hwif->pci_dev, | 1538 | use_pio_instead: |
1540 | hwif->sg_table, | 1539 | ide_destroy_dmatable(drive); |
1541 | hwif->sg_nents, | 1540 | |
1542 | hwif->sg_dma_direction); | ||
1543 | return 0; /* revert to PIO for this request */ | 1541 | return 0; /* revert to PIO for this request */ |
1544 | } | 1542 | } |
1545 | 1543 | ||
@@ -1548,12 +1546,9 @@ static void | |||
1548 | pmac_ide_destroy_dmatable (ide_drive_t *drive) | 1546 | pmac_ide_destroy_dmatable (ide_drive_t *drive) |
1549 | { | 1547 | { |
1550 | ide_hwif_t *hwif = drive->hwif; | 1548 | ide_hwif_t *hwif = drive->hwif; |
1551 | struct pci_dev *dev = HWIF(drive)->pci_dev; | ||
1552 | struct scatterlist *sg = hwif->sg_table; | ||
1553 | int nents = hwif->sg_nents; | ||
1554 | 1549 | ||
1555 | if (nents) { | 1550 | if (hwif->sg_nents) { |
1556 | pci_unmap_sg(dev, sg, nents, hwif->sg_dma_direction); | 1551 | ide_destroy_dmatable(drive); |
1557 | hwif->sg_nents = 0; | 1552 | hwif->sg_nents = 0; |
1558 | } | 1553 | } |
1559 | } | 1554 | } |
@@ -1726,13 +1721,15 @@ pmac_ide_dma_lost_irq (ide_drive_t *drive) | |||
1726 | * Allocate the data structures needed for using DMA with an interface | 1721 | * Allocate the data structures needed for using DMA with an interface |
1727 | * and fill the proper list of functions pointers | 1722 | * and fill the proper list of functions pointers |
1728 | */ | 1723 | */ |
1729 | static void __init | 1724 | static void __devinit |
1730 | pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | 1725 | pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) |
1731 | { | 1726 | { |
1727 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
1728 | |||
1732 | /* We won't need pci_dev if we switch to generic consistent | 1729 | /* We won't need pci_dev if we switch to generic consistent |
1733 | * DMA routines ... | 1730 | * DMA routines ... |
1734 | */ | 1731 | */ |
1735 | if (hwif->pci_dev == NULL) | 1732 | if (dev == NULL) |
1736 | return; | 1733 | return; |
1737 | /* | 1734 | /* |
1738 | * Allocate space for the DBDMA commands. | 1735 | * Allocate space for the DBDMA commands. |
@@ -1740,7 +1737,7 @@ pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | |||
1740 | * aligning the start address to a multiple of 16 bytes. | 1737 | * aligning the start address to a multiple of 16 bytes. |
1741 | */ | 1738 | */ |
1742 | pmif->dma_table_cpu = (struct dbdma_cmd*)pci_alloc_consistent( | 1739 | pmif->dma_table_cpu = (struct dbdma_cmd*)pci_alloc_consistent( |
1743 | hwif->pci_dev, | 1740 | dev, |
1744 | (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd), | 1741 | (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd), |
1745 | &hwif->dmatable_dma); | 1742 | &hwif->dmatable_dma); |
1746 | if (pmif->dma_table_cpu == NULL) { | 1743 | if (pmif->dma_table_cpu == NULL) { |
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index cf79470a932d..05db429a7da8 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -1,9 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/setup-pci.c Version 1.10 2002/08/19 | 2 | * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> |
3 | * Copyright (C) 1995-1998 Mark Lord | ||
4 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz | ||
3 | * | 5 | * |
4 | * Copyright (c) 1998-2000 Andre Hedrick <andre@linux-ide.org> | ||
5 | * | ||
6 | * Copyright (c) 1995-1998 Mark Lord | ||
7 | * May be copied or modified under the terms of the GNU General Public License | 6 | * May be copied or modified under the terms of the GNU General Public License |
8 | */ | 7 | */ |
9 | 8 | ||
@@ -140,6 +139,16 @@ static int ide_setup_pci_baseregs (struct pci_dev *dev, const char *name) | |||
140 | } | 139 | } |
141 | 140 | ||
142 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 141 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
142 | static void ide_pci_clear_simplex(unsigned long dma_base, const char *name) | ||
143 | { | ||
144 | u8 dma_stat = inb(dma_base + 2); | ||
145 | |||
146 | outb(dma_stat & 0x60, dma_base + 2); | ||
147 | dma_stat = inb(dma_base + 2); | ||
148 | if (dma_stat & 0x80) | ||
149 | printk(KERN_INFO "%s: simplex device: DMA forced\n", name); | ||
150 | } | ||
151 | |||
143 | /** | 152 | /** |
144 | * ide_get_or_set_dma_base - setup BMIBA | 153 | * ide_get_or_set_dma_base - setup BMIBA |
145 | * @d: IDE port info | 154 | * @d: IDE port info |
@@ -152,8 +161,9 @@ static int ide_setup_pci_baseregs (struct pci_dev *dev, const char *name) | |||
152 | 161 | ||
153 | static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_hwif_t *hwif) | 162 | static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_hwif_t *hwif) |
154 | { | 163 | { |
155 | unsigned long dma_base = 0; | 164 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
156 | struct pci_dev *dev = hwif->pci_dev; | 165 | unsigned long dma_base = 0; |
166 | u8 dma_stat = 0; | ||
157 | 167 | ||
158 | if (hwif->mmio) | 168 | if (hwif->mmio) |
159 | return hwif->dma_base; | 169 | return hwif->dma_base; |
@@ -174,52 +184,30 @@ static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_ | |||
174 | if (hwif->channel) | 184 | if (hwif->channel) |
175 | dma_base += 8; | 185 | dma_base += 8; |
176 | 186 | ||
177 | if ((d->host_flags & IDE_HFLAG_CS5520) == 0) { | 187 | if (d->host_flags & IDE_HFLAG_CS5520) |
178 | u8 simplex_stat = 0; | 188 | goto out; |
179 | 189 | ||
180 | switch(dev->device) { | 190 | if (d->host_flags & IDE_HFLAG_CLEAR_SIMPLEX) { |
181 | case PCI_DEVICE_ID_AL_M5219: | 191 | ide_pci_clear_simplex(dma_base, d->name); |
182 | case PCI_DEVICE_ID_AL_M5229: | 192 | goto out; |
183 | case PCI_DEVICE_ID_AMD_VIPER_7409: | 193 | } |
184 | case PCI_DEVICE_ID_CMD_643: | 194 | |
185 | case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE: | 195 | /* |
186 | case PCI_DEVICE_ID_REVOLUTION: | 196 | * If the device claims "simplex" DMA, this means that only one of |
187 | simplex_stat = inb(dma_base + 2); | 197 | * the two interfaces can be trusted with DMA at any point in time |
188 | outb(simplex_stat & 0x60, dma_base + 2); | 198 | * (so we should enable DMA only on one of the two interfaces). |
189 | simplex_stat = inb(dma_base + 2); | 199 | * |
190 | if (simplex_stat & 0x80) { | 200 | * FIXME: At this point we haven't probed the drives so we can't make |
191 | printk(KERN_INFO "%s: simplex device: " | 201 | * the appropriate decision. Really we should defer this problem until |
192 | "DMA forced\n", | 202 | * we tune the drive then try to grab DMA ownership if we want to be |
193 | d->name); | 203 | * the DMA end. This has to be become dynamic to handle hot-plug. |
194 | } | 204 | */ |
195 | break; | 205 | dma_stat = hwif->INB(dma_base + 2); |
196 | default: | 206 | if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) { |
197 | /* | 207 | printk(KERN_INFO "%s: simplex device: DMA disabled\n", d->name); |
198 | * If the device claims "simplex" DMA, | 208 | dma_base = 0; |
199 | * this means only one of the two interfaces | ||
200 | * can be trusted with DMA at any point in time. | ||
201 | * So we should enable DMA only on one of the | ||
202 | * two interfaces. | ||
203 | */ | ||
204 | simplex_stat = hwif->INB(dma_base + 2); | ||
205 | if (simplex_stat & 0x80) { | ||
206 | /* simplex device? */ | ||
207 | /* | ||
208 | * At this point we haven't probed the drives so we can't make the | ||
209 | * appropriate decision. Really we should defer this problem | ||
210 | * until we tune the drive then try to grab DMA ownership if we want | ||
211 | * to be the DMA end. This has to be become dynamic to handle hot | ||
212 | * plug. | ||
213 | */ | ||
214 | if (hwif->mate && hwif->mate->dma_base) { | ||
215 | printk(KERN_INFO "%s: simplex device: " | ||
216 | "DMA disabled\n", | ||
217 | d->name); | ||
218 | dma_base = 0; | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | } | 209 | } |
210 | out: | ||
223 | return dma_base; | 211 | return dma_base; |
224 | } | 212 | } |
225 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | 213 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ |
@@ -404,7 +392,7 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, const struct ide_port | |||
404 | 392 | ||
405 | hwif->noprobe = oldnoprobe; | 393 | hwif->noprobe = oldnoprobe; |
406 | 394 | ||
407 | hwif->pci_dev = dev; | 395 | hwif->dev = &dev->dev; |
408 | hwif->cds = d; | 396 | hwif->cds = d; |
409 | hwif->channel = port; | 397 | hwif->channel = port; |
410 | 398 | ||
@@ -453,7 +441,7 @@ static void ide_hwif_setup_dma(struct pci_dev *dev, const struct ide_port_info * | |||
453 | if (d->init_dma) { | 441 | if (d->init_dma) { |
454 | d->init_dma(hwif, dma_base); | 442 | d->init_dma(hwif, dma_base); |
455 | } else { | 443 | } else { |
456 | ide_setup_dma(hwif, dma_base, 8); | 444 | ide_setup_dma(hwif, dma_base); |
457 | } | 445 | } |
458 | } else { | 446 | } else { |
459 | printk(KERN_INFO "%s: %s Bus-Master DMA disabled " | 447 | printk(KERN_INFO "%s: %s Bus-Master DMA disabled " |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 1f1693161956..b3e9294e4a0e 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -877,7 +877,8 @@ int pcim_enable_device(struct pci_dev *pdev) | |||
877 | dr = get_pci_dr(pdev); | 877 | dr = get_pci_dr(pdev); |
878 | if (unlikely(!dr)) | 878 | if (unlikely(!dr)) |
879 | return -ENOMEM; | 879 | return -ENOMEM; |
880 | WARN_ON(!!dr->enabled); | 880 | if (dr->enabled) |
881 | return 0; | ||
881 | 882 | ||
882 | rc = pci_enable_device(pdev); | 883 | rc = pci_enable_device(pdev); |
883 | if (!rc) { | 884 | if (!rc) { |
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index db8bc20539e1..5ed00069846d 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/scsi/ide-scsi.c Version 0.9 Jul 4, 1999 | 2 | * Copyright (C) 1996-1999 Gadi Oxman <gadio@netvision.net.il> |
3 | * | 3 | * Copyright (C) 2004-2005 Bartlomiej Zolnierkiewicz |
4 | * Copyright (C) 1996 - 1999 Gadi Oxman <gadio@netvision.net.il> | ||
5 | */ | 4 | */ |
6 | 5 | ||
7 | /* | 6 | /* |
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 7a6499008b89..755823cdf62a 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig | |||
@@ -42,6 +42,10 @@ config USB_ARCH_HAS_OHCI | |||
42 | default y if PPC_MPC52xx | 42 | default y if PPC_MPC52xx |
43 | # MIPS: | 43 | # MIPS: |
44 | default y if SOC_AU1X00 | 44 | default y if SOC_AU1X00 |
45 | # SH: | ||
46 | default y if CPU_SUBTYPE_SH7720 | ||
47 | default y if CPU_SUBTYPE_SH7721 | ||
48 | default y if CPU_SUBTYPE_SH7763 | ||
45 | # more: | 49 | # more: |
46 | default PCI | 50 | default PCI |
47 | 51 | ||
@@ -50,6 +54,7 @@ config USB_ARCH_HAS_EHCI | |||
50 | boolean | 54 | boolean |
51 | default y if PPC_83xx | 55 | default y if PPC_83xx |
52 | default y if SOC_AU1200 | 56 | default y if SOC_AU1200 |
57 | default y if ARCH_IXP4XX | ||
53 | default PCI | 58 | default PCI |
54 | 59 | ||
55 | # ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface. | 60 | # ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface. |
diff --git a/drivers/usb/atm/Kconfig b/drivers/usb/atm/Kconfig index b450cbaa3a0b..86e64035edb0 100644 --- a/drivers/usb/atm/Kconfig +++ b/drivers/usb/atm/Kconfig | |||
@@ -2,10 +2,7 @@ | |||
2 | # USB/ATM DSL configuration | 2 | # USB/ATM DSL configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "USB DSL modem support" | 5 | menuconfig USB_ATM |
6 | depends on USB | ||
7 | |||
8 | config USB_ATM | ||
9 | tristate "USB DSL modem support" | 6 | tristate "USB DSL modem support" |
10 | depends on USB && ATM | 7 | depends on USB && ATM |
11 | select CRC32 | 8 | select CRC32 |
@@ -18,6 +15,8 @@ config USB_ATM | |||
18 | To compile this driver as a module, choose M here: the | 15 | To compile this driver as a module, choose M here: the |
19 | module will be called usbatm. | 16 | module will be called usbatm. |
20 | 17 | ||
18 | if USB_ATM | ||
19 | |||
21 | config USB_SPEEDTOUCH | 20 | config USB_SPEEDTOUCH |
22 | tristate "Speedtouch USB support" | 21 | tristate "Speedtouch USB support" |
23 | depends on USB_ATM | 22 | depends on USB_ATM |
@@ -70,4 +69,4 @@ config USB_XUSBATM | |||
70 | To compile this driver as a module, choose M here: the | 69 | To compile this driver as a module, choose M here: the |
71 | module will be called xusbatm. | 70 | module will be called xusbatm. |
72 | 71 | ||
73 | endmenu | 72 | endif # USB_ATM |
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index 389c5b164eb2..c5ec1a55eee3 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c | |||
@@ -999,7 +999,7 @@ static void __uea_load_page_e4(struct uea_softc *sc, u8 pageno, int boot) | |||
999 | bi.dwAddress = swab32(blockidx->PageAddress); | 999 | bi.dwAddress = swab32(blockidx->PageAddress); |
1000 | 1000 | ||
1001 | uea_dbg(INS_TO_USBDEV(sc), | 1001 | uea_dbg(INS_TO_USBDEV(sc), |
1002 | "sending block %u for DSP page %u size %u adress %x\n", | 1002 | "sending block %u for DSP page %u size %u address %x\n", |
1003 | blockno, pageno, blocksize, le32_to_cpu(blockidx->PageAddress)); | 1003 | blockno, pageno, blocksize, le32_to_cpu(blockidx->PageAddress)); |
1004 | 1004 | ||
1005 | /* send block info through the IDMA pipe */ | 1005 | /* send block info through the IDMA pipe */ |
@@ -1990,7 +1990,7 @@ static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr) | |||
1990 | return; | 1990 | return; |
1991 | 1991 | ||
1992 | bad2: | 1992 | bad2: |
1993 | uea_err(INS_TO_USBDEV(sc), "unexpected cmv received," | 1993 | uea_err(INS_TO_USBDEV(sc), "unexpected cmv received, " |
1994 | "Function : %d, Subfunction : %d\n", | 1994 | "Function : %d, Subfunction : %d\n", |
1995 | E1_FUNCTION_TYPE(cmv->bFunction), | 1995 | E1_FUNCTION_TYPE(cmv->bFunction), |
1996 | E1_FUNCTION_SUBTYPE(cmv->bFunction)); | 1996 | E1_FUNCTION_SUBTYPE(cmv->bFunction)); |
@@ -2038,7 +2038,7 @@ static void uea_dispatch_cmv_e4(struct uea_softc *sc, struct intr_pkt *intr) | |||
2038 | return; | 2038 | return; |
2039 | 2039 | ||
2040 | bad2: | 2040 | bad2: |
2041 | uea_err(INS_TO_USBDEV(sc), "unexpected cmv received," | 2041 | uea_err(INS_TO_USBDEV(sc), "unexpected cmv received, " |
2042 | "Function : %d, Subfunction : %d\n", | 2042 | "Function : %d, Subfunction : %d\n", |
2043 | E4_FUNCTION_TYPE(cmv->wFunction), | 2043 | E4_FUNCTION_TYPE(cmv->wFunction), |
2044 | E4_FUNCTION_SUBTYPE(cmv->wFunction)); | 2044 | E4_FUNCTION_SUBTYPE(cmv->wFunction)); |
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 912d97aaf9bf..bcc42136c93f 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -496,10 +496,19 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) | |||
496 | otherwise it is scheduled, and with high data rates data can get lost. */ | 496 | otherwise it is scheduled, and with high data rates data can get lost. */ |
497 | tty->low_latency = 1; | 497 | tty->low_latency = 1; |
498 | 498 | ||
499 | if (usb_autopm_get_interface(acm->control)) { | ||
500 | mutex_unlock(&open_mutex); | ||
501 | return -EIO; | ||
502 | } | ||
503 | |||
504 | mutex_lock(&acm->mutex); | ||
505 | mutex_unlock(&open_mutex); | ||
499 | if (acm->used++) { | 506 | if (acm->used++) { |
507 | usb_autopm_put_interface(acm->control); | ||
500 | goto done; | 508 | goto done; |
501 | } | 509 | } |
502 | 510 | ||
511 | |||
503 | acm->ctrlurb->dev = acm->dev; | 512 | acm->ctrlurb->dev = acm->dev; |
504 | if (usb_submit_urb(acm->ctrlurb, GFP_KERNEL)) { | 513 | if (usb_submit_urb(acm->ctrlurb, GFP_KERNEL)) { |
505 | dbg("usb_submit_urb(ctrl irq) failed"); | 514 | dbg("usb_submit_urb(ctrl irq) failed"); |
@@ -526,14 +535,15 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) | |||
526 | 535 | ||
527 | done: | 536 | done: |
528 | err_out: | 537 | err_out: |
529 | mutex_unlock(&open_mutex); | 538 | mutex_unlock(&acm->mutex); |
530 | return rv; | 539 | return rv; |
531 | 540 | ||
532 | full_bailout: | 541 | full_bailout: |
533 | usb_kill_urb(acm->ctrlurb); | 542 | usb_kill_urb(acm->ctrlurb); |
534 | bail_out: | 543 | bail_out: |
544 | usb_autopm_put_interface(acm->control); | ||
535 | acm->used--; | 545 | acm->used--; |
536 | mutex_unlock(&open_mutex); | 546 | mutex_unlock(&acm->mutex); |
537 | return -EIO; | 547 | return -EIO; |
538 | } | 548 | } |
539 | 549 | ||
@@ -570,6 +580,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp) | |||
570 | usb_kill_urb(acm->writeurb); | 580 | usb_kill_urb(acm->writeurb); |
571 | for (i = 0; i < nr; i++) | 581 | for (i = 0; i < nr; i++) |
572 | usb_kill_urb(acm->ru[i].urb); | 582 | usb_kill_urb(acm->ru[i].urb); |
583 | usb_autopm_put_interface(acm->control); | ||
573 | } else | 584 | } else |
574 | acm_tty_unregister(acm); | 585 | acm_tty_unregister(acm); |
575 | } | 586 | } |
@@ -904,7 +915,7 @@ next_desc: | |||
904 | } | 915 | } |
905 | 916 | ||
906 | if (data_interface_num != call_interface_num) | 917 | if (data_interface_num != call_interface_num) |
907 | dev_dbg(&intf->dev,"Seperate call control interface. That is not fully supported.\n"); | 918 | dev_dbg(&intf->dev,"Separate call control interface. That is not fully supported.\n"); |
908 | 919 | ||
909 | skip_normal_probe: | 920 | skip_normal_probe: |
910 | 921 | ||
@@ -980,6 +991,7 @@ skip_normal_probe: | |||
980 | spin_lock_init(&acm->throttle_lock); | 991 | spin_lock_init(&acm->throttle_lock); |
981 | spin_lock_init(&acm->write_lock); | 992 | spin_lock_init(&acm->write_lock); |
982 | spin_lock_init(&acm->read_lock); | 993 | spin_lock_init(&acm->read_lock); |
994 | mutex_init(&acm->mutex); | ||
983 | acm->write_ready = 1; | 995 | acm->write_ready = 1; |
984 | acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress); | 996 | acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress); |
985 | 997 | ||
@@ -1096,6 +1108,25 @@ alloc_fail: | |||
1096 | return -ENOMEM; | 1108 | return -ENOMEM; |
1097 | } | 1109 | } |
1098 | 1110 | ||
1111 | static void stop_data_traffic(struct acm *acm) | ||
1112 | { | ||
1113 | int i; | ||
1114 | |||
1115 | tasklet_disable(&acm->urb_task); | ||
1116 | |||
1117 | usb_kill_urb(acm->ctrlurb); | ||
1118 | usb_kill_urb(acm->writeurb); | ||
1119 | for (i = 0; i < acm->rx_buflimit; i++) | ||
1120 | usb_kill_urb(acm->ru[i].urb); | ||
1121 | |||
1122 | INIT_LIST_HEAD(&acm->filled_read_bufs); | ||
1123 | INIT_LIST_HEAD(&acm->spare_read_bufs); | ||
1124 | |||
1125 | tasklet_enable(&acm->urb_task); | ||
1126 | |||
1127 | cancel_work_sync(&acm->work); | ||
1128 | } | ||
1129 | |||
1099 | static void acm_disconnect(struct usb_interface *intf) | 1130 | static void acm_disconnect(struct usb_interface *intf) |
1100 | { | 1131 | { |
1101 | struct acm *acm = usb_get_intfdata(intf); | 1132 | struct acm *acm = usb_get_intfdata(intf); |
@@ -1123,19 +1154,7 @@ static void acm_disconnect(struct usb_interface *intf) | |||
1123 | usb_set_intfdata(acm->control, NULL); | 1154 | usb_set_intfdata(acm->control, NULL); |
1124 | usb_set_intfdata(acm->data, NULL); | 1155 | usb_set_intfdata(acm->data, NULL); |
1125 | 1156 | ||
1126 | tasklet_disable(&acm->urb_task); | 1157 | stop_data_traffic(acm); |
1127 | |||
1128 | usb_kill_urb(acm->ctrlurb); | ||
1129 | usb_kill_urb(acm->writeurb); | ||
1130 | for (i = 0; i < acm->rx_buflimit; i++) | ||
1131 | usb_kill_urb(acm->ru[i].urb); | ||
1132 | |||
1133 | INIT_LIST_HEAD(&acm->filled_read_bufs); | ||
1134 | INIT_LIST_HEAD(&acm->spare_read_bufs); | ||
1135 | |||
1136 | tasklet_enable(&acm->urb_task); | ||
1137 | |||
1138 | flush_scheduled_work(); /* wait for acm_softint */ | ||
1139 | 1158 | ||
1140 | acm_write_buffers_free(acm); | 1159 | acm_write_buffers_free(acm); |
1141 | usb_buffer_free(usb_dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma); | 1160 | usb_buffer_free(usb_dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma); |
@@ -1156,6 +1175,46 @@ static void acm_disconnect(struct usb_interface *intf) | |||
1156 | tty_hangup(acm->tty); | 1175 | tty_hangup(acm->tty); |
1157 | } | 1176 | } |
1158 | 1177 | ||
1178 | static int acm_suspend(struct usb_interface *intf, pm_message_t message) | ||
1179 | { | ||
1180 | struct acm *acm = usb_get_intfdata(intf); | ||
1181 | |||
1182 | if (acm->susp_count++) | ||
1183 | return 0; | ||
1184 | /* | ||
1185 | we treat opened interfaces differently, | ||
1186 | we must guard against open | ||
1187 | */ | ||
1188 | mutex_lock(&acm->mutex); | ||
1189 | |||
1190 | if (acm->used) | ||
1191 | stop_data_traffic(acm); | ||
1192 | |||
1193 | mutex_unlock(&acm->mutex); | ||
1194 | return 0; | ||
1195 | } | ||
1196 | |||
1197 | static int acm_resume(struct usb_interface *intf) | ||
1198 | { | ||
1199 | struct acm *acm = usb_get_intfdata(intf); | ||
1200 | int rv = 0; | ||
1201 | |||
1202 | if (--acm->susp_count) | ||
1203 | return 0; | ||
1204 | |||
1205 | mutex_lock(&acm->mutex); | ||
1206 | if (acm->used) { | ||
1207 | rv = usb_submit_urb(acm->ctrlurb, GFP_NOIO); | ||
1208 | if (rv < 0) | ||
1209 | goto err_out; | ||
1210 | |||
1211 | tasklet_schedule(&acm->urb_task); | ||
1212 | } | ||
1213 | |||
1214 | err_out: | ||
1215 | mutex_unlock(&acm->mutex); | ||
1216 | return rv; | ||
1217 | } | ||
1159 | /* | 1218 | /* |
1160 | * USB driver structure. | 1219 | * USB driver structure. |
1161 | */ | 1220 | */ |
@@ -1208,7 +1267,10 @@ static struct usb_driver acm_driver = { | |||
1208 | .name = "cdc_acm", | 1267 | .name = "cdc_acm", |
1209 | .probe = acm_probe, | 1268 | .probe = acm_probe, |
1210 | .disconnect = acm_disconnect, | 1269 | .disconnect = acm_disconnect, |
1270 | .suspend = acm_suspend, | ||
1271 | .resume = acm_resume, | ||
1211 | .id_table = acm_ids, | 1272 | .id_table = acm_ids, |
1273 | .supports_autosuspend = 1, | ||
1212 | }; | 1274 | }; |
1213 | 1275 | ||
1214 | /* | 1276 | /* |
diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h index 09f7765dbf8d..8df6a57dcf9e 100644 --- a/drivers/usb/class/cdc-acm.h +++ b/drivers/usb/class/cdc-acm.h | |||
@@ -107,6 +107,7 @@ struct acm { | |||
107 | int write_used; /* number of non-empty write buffers */ | 107 | int write_used; /* number of non-empty write buffers */ |
108 | int write_ready; /* write urb is not running */ | 108 | int write_ready; /* write urb is not running */ |
109 | spinlock_t write_lock; | 109 | spinlock_t write_lock; |
110 | struct mutex mutex; | ||
110 | struct usb_cdc_line_coding line; /* bits, stop, parity */ | 111 | struct usb_cdc_line_coding line; /* bits, stop, parity */ |
111 | struct work_struct work; /* work queue entry for line discipline waking up */ | 112 | struct work_struct work; /* work queue entry for line discipline waking up */ |
112 | struct tasklet_struct urb_task; /* rx processing */ | 113 | struct tasklet_struct urb_task; /* rx processing */ |
@@ -120,6 +121,7 @@ struct acm { | |||
120 | unsigned char throttle; /* throttled by tty layer */ | 121 | unsigned char throttle; /* throttled by tty layer */ |
121 | unsigned char clocal; /* termios CLOCAL */ | 122 | unsigned char clocal; /* termios CLOCAL */ |
122 | unsigned int ctrl_caps; /* control capabilities from the class specific header */ | 123 | unsigned int ctrl_caps; /* control capabilities from the class specific header */ |
124 | unsigned int susp_count; /* number of suspended interfaces */ | ||
123 | }; | 125 | }; |
124 | 126 | ||
125 | #define CDC_DATA_INTERFACE_TYPE 0x0a | 127 | #define CDC_DATA_INTERFACE_TYPE 0x0a |
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig index 97b09f282705..5c33cdb9cac7 100644 --- a/drivers/usb/core/Kconfig +++ b/drivers/usb/core/Kconfig | |||
@@ -9,6 +9,21 @@ config USB_DEBUG | |||
9 | of debug messages to the system log. Select this if you are having a | 9 | of debug messages to the system log. Select this if you are having a |
10 | problem with USB support and want to see more of what is going on. | 10 | problem with USB support and want to see more of what is going on. |
11 | 11 | ||
12 | config USB_ANNOUNCE_NEW_DEVICES | ||
13 | bool "USB announce new devices" | ||
14 | depends on USB | ||
15 | default N | ||
16 | help | ||
17 | Say Y here if you want the USB core to always announce the | ||
18 | idVendor, idProduct, Manufacturer, Product, and SerialNumber | ||
19 | strings for every new USB device to the syslog. This option is | ||
20 | usually used by distro vendors to help with debugging and to | ||
21 | let users know what specific device was added to the machine | ||
22 | in what location. | ||
23 | |||
24 | If you do not want this kind of information sent to the system | ||
25 | log, or have any doubts about this, say N here. | ||
26 | |||
12 | comment "Miscellaneous USB options" | 27 | comment "Miscellaneous USB options" |
13 | depends on USB | 28 | depends on USB |
14 | 29 | ||
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c index 28d4972f7ad5..cadb2dc1d28a 100644 --- a/drivers/usb/core/buffer.c +++ b/drivers/usb/core/buffer.c | |||
@@ -53,11 +53,13 @@ int hcd_buffer_create(struct usb_hcd *hcd) | |||
53 | char name[16]; | 53 | char name[16]; |
54 | int i, size; | 54 | int i, size; |
55 | 55 | ||
56 | if (!hcd->self.controller->dma_mask) | 56 | if (!hcd->self.controller->dma_mask && |
57 | !(hcd->driver->flags & HCD_LOCAL_MEM)) | ||
57 | return 0; | 58 | return 0; |
58 | 59 | ||
59 | for (i = 0; i < HCD_BUFFER_POOLS; i++) { | 60 | for (i = 0; i < HCD_BUFFER_POOLS; i++) { |
60 | if (!(size = pool_max [i])) | 61 | size = pool_max[i]; |
62 | if (!size) | ||
61 | continue; | 63 | continue; |
62 | snprintf(name, sizeof name, "buffer-%d", size); | 64 | snprintf(name, sizeof name, "buffer-%d", size); |
63 | hcd->pool[i] = dma_pool_create(name, hcd->self.controller, | 65 | hcd->pool[i] = dma_pool_create(name, hcd->self.controller, |
@@ -80,10 +82,10 @@ int hcd_buffer_create(struct usb_hcd *hcd) | |||
80 | */ | 82 | */ |
81 | void hcd_buffer_destroy(struct usb_hcd *hcd) | 83 | void hcd_buffer_destroy(struct usb_hcd *hcd) |
82 | { | 84 | { |
83 | int i; | 85 | int i; |
84 | 86 | ||
85 | for (i = 0; i < HCD_BUFFER_POOLS; i++) { | 87 | for (i = 0; i < HCD_BUFFER_POOLS; i++) { |
86 | struct dma_pool *pool = hcd->pool[i]; | 88 | struct dma_pool *pool = hcd->pool[i]; |
87 | if (pool) { | 89 | if (pool) { |
88 | dma_pool_destroy(pool); | 90 | dma_pool_destroy(pool); |
89 | hcd->pool[i] = NULL; | 91 | hcd->pool[i] = NULL; |
@@ -107,7 +109,8 @@ void *hcd_buffer_alloc( | |||
107 | int i; | 109 | int i; |
108 | 110 | ||
109 | /* some USB hosts just use PIO */ | 111 | /* some USB hosts just use PIO */ |
110 | if (!bus->controller->dma_mask) { | 112 | if (!bus->controller->dma_mask && |
113 | !(hcd->driver->flags & HCD_LOCAL_MEM)) { | ||
111 | *dma = ~(dma_addr_t) 0; | 114 | *dma = ~(dma_addr_t) 0; |
112 | return kmalloc(size, mem_flags); | 115 | return kmalloc(size, mem_flags); |
113 | } | 116 | } |
@@ -132,7 +135,8 @@ void hcd_buffer_free( | |||
132 | if (!addr) | 135 | if (!addr) |
133 | return; | 136 | return; |
134 | 137 | ||
135 | if (!bus->controller->dma_mask) { | 138 | if (!bus->controller->dma_mask && |
139 | !(hcd->driver->flags & HCD_LOCAL_MEM)) { | ||
136 | kfree(addr); | 140 | kfree(addr); |
137 | return; | 141 | return; |
138 | } | 142 | } |
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 1a8edcee7f30..a92122a216bc 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c | |||
@@ -238,7 +238,7 @@ static int usb_parse_interface(struct device *ddev, int cfgno, | |||
238 | 238 | ||
239 | /* Allocate space for the right(?) number of endpoints */ | 239 | /* Allocate space for the right(?) number of endpoints */ |
240 | num_ep = num_ep_orig = alt->desc.bNumEndpoints; | 240 | num_ep = num_ep_orig = alt->desc.bNumEndpoints; |
241 | alt->desc.bNumEndpoints = 0; // Use as a counter | 241 | alt->desc.bNumEndpoints = 0; /* Use as a counter */ |
242 | if (num_ep > USB_MAXENDPOINTS) { | 242 | if (num_ep > USB_MAXENDPOINTS) { |
243 | dev_warn(ddev, "too many endpoints for config %d interface %d " | 243 | dev_warn(ddev, "too many endpoints for config %d interface %d " |
244 | "altsetting %d: %d, using maximum allowed: %d\n", | 244 | "altsetting %d: %d, using maximum allowed: %d\n", |
@@ -246,7 +246,8 @@ static int usb_parse_interface(struct device *ddev, int cfgno, | |||
246 | num_ep = USB_MAXENDPOINTS; | 246 | num_ep = USB_MAXENDPOINTS; |
247 | } | 247 | } |
248 | 248 | ||
249 | if (num_ep > 0) { /* Can't allocate 0 bytes */ | 249 | if (num_ep > 0) { |
250 | /* Can't allocate 0 bytes */ | ||
250 | len = sizeof(struct usb_host_endpoint) * num_ep; | 251 | len = sizeof(struct usb_host_endpoint) * num_ep; |
251 | alt->endpoint = kzalloc(len, GFP_KERNEL); | 252 | alt->endpoint = kzalloc(len, GFP_KERNEL); |
252 | if (!alt->endpoint) | 253 | if (!alt->endpoint) |
@@ -475,8 +476,9 @@ static int usb_parse_configuration(struct device *ddev, int cfgidx, | |||
475 | return 0; | 476 | return 0; |
476 | } | 477 | } |
477 | 478 | ||
478 | // hub-only!! ... and only exported for reset/reinit path. | 479 | /* hub-only!! ... and only exported for reset/reinit path. |
479 | // otherwise used internally on disconnect/destroy path | 480 | * otherwise used internally on disconnect/destroy path |
481 | */ | ||
480 | void usb_destroy_configuration(struct usb_device *dev) | 482 | void usb_destroy_configuration(struct usb_device *dev) |
481 | { | 483 | { |
482 | int c, i; | 484 | int c, i; |
@@ -498,7 +500,7 @@ void usb_destroy_configuration(struct usb_device *dev) | |||
498 | kfree(cf->string); | 500 | kfree(cf->string); |
499 | for (i = 0; i < cf->desc.bNumInterfaces; i++) { | 501 | for (i = 0; i < cf->desc.bNumInterfaces; i++) { |
500 | if (cf->intf_cache[i]) | 502 | if (cf->intf_cache[i]) |
501 | kref_put(&cf->intf_cache[i]->ref, | 503 | kref_put(&cf->intf_cache[i]->ref, |
502 | usb_release_interface_cache); | 504 | usb_release_interface_cache); |
503 | } | 505 | } |
504 | } | 506 | } |
@@ -525,7 +527,7 @@ int usb_get_configuration(struct usb_device *dev) | |||
525 | unsigned int cfgno, length; | 527 | unsigned int cfgno, length; |
526 | unsigned char *buffer; | 528 | unsigned char *buffer; |
527 | unsigned char *bigbuffer; | 529 | unsigned char *bigbuffer; |
528 | struct usb_config_descriptor *desc; | 530 | struct usb_config_descriptor *desc; |
529 | 531 | ||
530 | cfgno = 0; | 532 | cfgno = 0; |
531 | if (dev->authorized == 0) /* Not really an error */ | 533 | if (dev->authorized == 0) /* Not really an error */ |
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index 87c794d60aa0..83d9dc379d96 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c | |||
@@ -89,7 +89,7 @@ static const char *format_string_serialnumber = | |||
89 | static const char *format_bandwidth = | 89 | static const char *format_bandwidth = |
90 | /* B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd */ | 90 | /* B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd */ |
91 | "B: Alloc=%3d/%3d us (%2d%%), #Int=%3d, #Iso=%3d\n"; | 91 | "B: Alloc=%3d/%3d us (%2d%%), #Int=%3d, #Iso=%3d\n"; |
92 | 92 | ||
93 | static const char *format_device1 = | 93 | static const char *format_device1 = |
94 | /* D: Ver=xx.xx Cls=xx(sssss) Sub=xx Prot=xx MxPS=dd #Cfgs=dd */ | 94 | /* D: Ver=xx.xx Cls=xx(sssss) Sub=xx Prot=xx MxPS=dd #Cfgs=dd */ |
95 | "D: Ver=%2x.%02x Cls=%02x(%-5s) Sub=%02x Prot=%02x MxPS=%2d #Cfgs=%3d\n"; | 95 | "D: Ver=%2x.%02x Cls=%02x(%-5s) Sub=%02x Prot=%02x MxPS=%2d #Cfgs=%3d\n"; |
@@ -101,7 +101,7 @@ static const char *format_device2 = | |||
101 | static const char *format_config = | 101 | static const char *format_config = |
102 | /* C: #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA */ | 102 | /* C: #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA */ |
103 | "C:%c #Ifs=%2d Cfg#=%2d Atr=%02x MxPwr=%3dmA\n"; | 103 | "C:%c #Ifs=%2d Cfg#=%2d Atr=%02x MxPwr=%3dmA\n"; |
104 | 104 | ||
105 | static const char *format_iad = | 105 | static const char *format_iad = |
106 | /* A: FirstIf#=dd IfCount=dd Cls=xx(sssss) Sub=xx Prot=xx */ | 106 | /* A: FirstIf#=dd IfCount=dd Cls=xx(sssss) Sub=xx Prot=xx */ |
107 | "A: FirstIf#=%2d IfCount=%2d Cls=%02x(%-5s) Sub=%02x Prot=%02x\n"; | 107 | "A: FirstIf#=%2d IfCount=%2d Cls=%02x(%-5s) Sub=%02x Prot=%02x\n"; |
@@ -122,7 +122,7 @@ static const char *format_endpt = | |||
122 | */ | 122 | */ |
123 | 123 | ||
124 | static DECLARE_WAIT_QUEUE_HEAD(deviceconndiscwq); | 124 | static DECLARE_WAIT_QUEUE_HEAD(deviceconndiscwq); |
125 | static unsigned int conndiscevcnt = 0; | 125 | static unsigned int conndiscevcnt; |
126 | 126 | ||
127 | /* this struct stores the poll state for <mountpoint>/devices pollers */ | 127 | /* this struct stores the poll state for <mountpoint>/devices pollers */ |
128 | struct usb_device_status { | 128 | struct usb_device_status { |
@@ -172,12 +172,8 @@ static const char *class_decode(const int class) | |||
172 | return clas_info[ix].class_name; | 172 | return clas_info[ix].class_name; |
173 | } | 173 | } |
174 | 174 | ||
175 | static char *usb_dump_endpoint_descriptor( | 175 | static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end, |
176 | int speed, | 176 | const struct usb_endpoint_descriptor *desc) |
177 | char *start, | ||
178 | char *end, | ||
179 | const struct usb_endpoint_descriptor *desc | ||
180 | ) | ||
181 | { | 177 | { |
182 | char dir, unit, *type; | 178 | char dir, unit, *type; |
183 | unsigned interval, bandwidth = 1; | 179 | unsigned interval, bandwidth = 1; |
@@ -235,22 +231,24 @@ static char *usb_dump_endpoint_descriptor( | |||
235 | 231 | ||
236 | start += sprintf(start, format_endpt, desc->bEndpointAddress, dir, | 232 | start += sprintf(start, format_endpt, desc->bEndpointAddress, dir, |
237 | desc->bmAttributes, type, | 233 | desc->bmAttributes, type, |
238 | (le16_to_cpu(desc->wMaxPacketSize) & 0x07ff) * bandwidth, | 234 | (le16_to_cpu(desc->wMaxPacketSize) & 0x07ff) * |
235 | bandwidth, | ||
239 | interval, unit); | 236 | interval, unit); |
240 | return start; | 237 | return start; |
241 | } | 238 | } |
242 | 239 | ||
243 | static char *usb_dump_interface_descriptor(char *start, char *end, | 240 | static char *usb_dump_interface_descriptor(char *start, char *end, |
244 | const struct usb_interface_cache *intfc, | 241 | const struct usb_interface_cache *intfc, |
245 | const struct usb_interface *iface, | 242 | const struct usb_interface *iface, |
246 | int setno) | 243 | int setno) |
247 | { | 244 | { |
248 | const struct usb_interface_descriptor *desc = &intfc->altsetting[setno].desc; | 245 | const struct usb_interface_descriptor *desc; |
249 | const char *driver_name = ""; | 246 | const char *driver_name = ""; |
250 | int active = 0; | 247 | int active = 0; |
251 | 248 | ||
252 | if (start > end) | 249 | if (start > end) |
253 | return start; | 250 | return start; |
251 | desc = &intfc->altsetting[setno].desc; | ||
254 | if (iface) { | 252 | if (iface) { |
255 | driver_name = (iface->dev.driver | 253 | driver_name = (iface->dev.driver |
256 | ? iface->dev.driver->name | 254 | ? iface->dev.driver->name |
@@ -270,14 +268,10 @@ static char *usb_dump_interface_descriptor(char *start, char *end, | |||
270 | return start; | 268 | return start; |
271 | } | 269 | } |
272 | 270 | ||
273 | static char *usb_dump_interface( | 271 | static char *usb_dump_interface(int speed, char *start, char *end, |
274 | int speed, | 272 | const struct usb_interface_cache *intfc, |
275 | char *start, | 273 | const struct usb_interface *iface, int setno) |
276 | char *end, | 274 | { |
277 | const struct usb_interface_cache *intfc, | ||
278 | const struct usb_interface *iface, | ||
279 | int setno | ||
280 | ) { | ||
281 | const struct usb_host_interface *desc = &intfc->altsetting[setno]; | 275 | const struct usb_host_interface *desc = &intfc->altsetting[setno]; |
282 | int i; | 276 | int i; |
283 | 277 | ||
@@ -292,7 +286,7 @@ static char *usb_dump_interface( | |||
292 | } | 286 | } |
293 | 287 | ||
294 | static char *usb_dump_iad_descriptor(char *start, char *end, | 288 | static char *usb_dump_iad_descriptor(char *start, char *end, |
295 | const struct usb_interface_assoc_descriptor *iad) | 289 | const struct usb_interface_assoc_descriptor *iad) |
296 | { | 290 | { |
297 | if (start > end) | 291 | if (start > end) |
298 | return start; | 292 | return start; |
@@ -311,13 +305,15 @@ static char *usb_dump_iad_descriptor(char *start, char *end, | |||
311 | * 1. marking active interface altsettings (code lists all, but should mark | 305 | * 1. marking active interface altsettings (code lists all, but should mark |
312 | * which ones are active, if any) | 306 | * which ones are active, if any) |
313 | */ | 307 | */ |
314 | 308 | static char *usb_dump_config_descriptor(char *start, char *end, | |
315 | static char *usb_dump_config_descriptor(char *start, char *end, const struct usb_config_descriptor *desc, int active) | 309 | const struct usb_config_descriptor *desc, |
310 | int active) | ||
316 | { | 311 | { |
317 | if (start > end) | 312 | if (start > end) |
318 | return start; | 313 | return start; |
319 | start += sprintf(start, format_config, | 314 | start += sprintf(start, format_config, |
320 | active ? '*' : ' ', /* mark active/actual/current cfg. */ | 315 | /* mark active/actual/current cfg. */ |
316 | active ? '*' : ' ', | ||
321 | desc->bNumInterfaces, | 317 | desc->bNumInterfaces, |
322 | desc->bConfigurationValue, | 318 | desc->bConfigurationValue, |
323 | desc->bmAttributes, | 319 | desc->bmAttributes, |
@@ -325,13 +321,8 @@ static char *usb_dump_config_descriptor(char *start, char *end, const struct usb | |||
325 | return start; | 321 | return start; |
326 | } | 322 | } |
327 | 323 | ||
328 | static char *usb_dump_config ( | 324 | static char *usb_dump_config(int speed, char *start, char *end, |
329 | int speed, | 325 | const struct usb_host_config *config, int active) |
330 | char *start, | ||
331 | char *end, | ||
332 | const struct usb_host_config *config, | ||
333 | int active | ||
334 | ) | ||
335 | { | 326 | { |
336 | int i, j; | 327 | int i, j; |
337 | struct usb_interface_cache *intfc; | 328 | struct usb_interface_cache *intfc; |
@@ -339,7 +330,8 @@ static char *usb_dump_config ( | |||
339 | 330 | ||
340 | if (start > end) | 331 | if (start > end) |
341 | return start; | 332 | return start; |
342 | if (!config) /* getting these some in 2.3.7; none in 2.3.6 */ | 333 | if (!config) |
334 | /* getting these some in 2.3.7; none in 2.3.6 */ | ||
343 | return start + sprintf(start, "(null Cfg. desc.)\n"); | 335 | return start + sprintf(start, "(null Cfg. desc.)\n"); |
344 | start = usb_dump_config_descriptor(start, end, &config->desc, active); | 336 | start = usb_dump_config_descriptor(start, end, &config->desc, active); |
345 | for (i = 0; i < USB_MAXIADS; i++) { | 337 | for (i = 0; i < USB_MAXIADS; i++) { |
@@ -364,7 +356,8 @@ static char *usb_dump_config ( | |||
364 | /* | 356 | /* |
365 | * Dump the different USB descriptors. | 357 | * Dump the different USB descriptors. |
366 | */ | 358 | */ |
367 | static char *usb_dump_device_descriptor(char *start, char *end, const struct usb_device_descriptor *desc) | 359 | static char *usb_dump_device_descriptor(char *start, char *end, |
360 | const struct usb_device_descriptor *desc) | ||
368 | { | 361 | { |
369 | u16 bcdUSB = le16_to_cpu(desc->bcdUSB); | 362 | u16 bcdUSB = le16_to_cpu(desc->bcdUSB); |
370 | u16 bcdDevice = le16_to_cpu(desc->bcdDevice); | 363 | u16 bcdDevice = le16_to_cpu(desc->bcdDevice); |
@@ -374,7 +367,7 @@ static char *usb_dump_device_descriptor(char *start, char *end, const struct usb | |||
374 | start += sprintf(start, format_device1, | 367 | start += sprintf(start, format_device1, |
375 | bcdUSB >> 8, bcdUSB & 0xff, | 368 | bcdUSB >> 8, bcdUSB & 0xff, |
376 | desc->bDeviceClass, | 369 | desc->bDeviceClass, |
377 | class_decode (desc->bDeviceClass), | 370 | class_decode(desc->bDeviceClass), |
378 | desc->bDeviceSubClass, | 371 | desc->bDeviceSubClass, |
379 | desc->bDeviceProtocol, | 372 | desc->bDeviceProtocol, |
380 | desc->bMaxPacketSize0, | 373 | desc->bMaxPacketSize0, |
@@ -391,12 +384,14 @@ static char *usb_dump_device_descriptor(char *start, char *end, const struct usb | |||
391 | /* | 384 | /* |
392 | * Dump the different strings that this device holds. | 385 | * Dump the different strings that this device holds. |
393 | */ | 386 | */ |
394 | static char *usb_dump_device_strings(char *start, char *end, struct usb_device *dev) | 387 | static char *usb_dump_device_strings(char *start, char *end, |
388 | struct usb_device *dev) | ||
395 | { | 389 | { |
396 | if (start > end) | 390 | if (start > end) |
397 | return start; | 391 | return start; |
398 | if (dev->manufacturer) | 392 | if (dev->manufacturer) |
399 | start += sprintf(start, format_string_manufacturer, dev->manufacturer); | 393 | start += sprintf(start, format_string_manufacturer, |
394 | dev->manufacturer); | ||
400 | if (start > end) | 395 | if (start > end) |
401 | goto out; | 396 | goto out; |
402 | if (dev->product) | 397 | if (dev->product) |
@@ -405,7 +400,8 @@ static char *usb_dump_device_strings(char *start, char *end, struct usb_device * | |||
405 | goto out; | 400 | goto out; |
406 | #ifdef ALLOW_SERIAL_NUMBER | 401 | #ifdef ALLOW_SERIAL_NUMBER |
407 | if (dev->serial) | 402 | if (dev->serial) |
408 | start += sprintf(start, format_string_serialnumber, dev->serial); | 403 | start += sprintf(start, format_string_serialnumber, |
404 | dev->serial); | ||
409 | #endif | 405 | #endif |
410 | out: | 406 | out: |
411 | return start; | 407 | return start; |
@@ -417,12 +413,12 @@ static char *usb_dump_desc(char *start, char *end, struct usb_device *dev) | |||
417 | 413 | ||
418 | if (start > end) | 414 | if (start > end) |
419 | return start; | 415 | return start; |
420 | 416 | ||
421 | start = usb_dump_device_descriptor(start, end, &dev->descriptor); | 417 | start = usb_dump_device_descriptor(start, end, &dev->descriptor); |
422 | 418 | ||
423 | if (start > end) | 419 | if (start > end) |
424 | return start; | 420 | return start; |
425 | 421 | ||
426 | start = usb_dump_device_strings(start, end, dev); | 422 | start = usb_dump_device_strings(start, end, dev); |
427 | 423 | ||
428 | for (i = 0; i < dev->descriptor.bNumConfigurations; i++) { | 424 | for (i = 0; i < dev->descriptor.bNumConfigurations; i++) { |
@@ -439,7 +435,8 @@ static char *usb_dump_desc(char *start, char *end, struct usb_device *dev) | |||
439 | 435 | ||
440 | #ifdef PROC_EXTRA /* TBD: may want to add this code later */ | 436 | #ifdef PROC_EXTRA /* TBD: may want to add this code later */ |
441 | 437 | ||
442 | static char *usb_dump_hub_descriptor(char *start, char *end, const struct usb_hub_descriptor * desc) | 438 | static char *usb_dump_hub_descriptor(char *start, char *end, |
439 | const struct usb_hub_descriptor *desc) | ||
443 | { | 440 | { |
444 | int leng = USB_DT_HUB_NONVAR_SIZE; | 441 | int leng = USB_DT_HUB_NONVAR_SIZE; |
445 | unsigned char *ptr = (unsigned char *)desc; | 442 | unsigned char *ptr = (unsigned char *)desc; |
@@ -455,13 +452,16 @@ static char *usb_dump_hub_descriptor(char *start, char *end, const struct usb_hu | |||
455 | return start; | 452 | return start; |
456 | } | 453 | } |
457 | 454 | ||
458 | static char *usb_dump_string(char *start, char *end, const struct usb_device *dev, char *id, int index) | 455 | static char *usb_dump_string(char *start, char *end, |
456 | const struct usb_device *dev, char *id, int index) | ||
459 | { | 457 | { |
460 | if (start > end) | 458 | if (start > end) |
461 | return start; | 459 | return start; |
462 | start += sprintf(start, "Interface:"); | 460 | start += sprintf(start, "Interface:"); |
463 | if (index <= dev->maxstring && dev->stringindex && dev->stringindex[index]) | 461 | if (index <= dev->maxstring && dev->stringindex && |
464 | start += sprintf(start, "%s: %.100s ", id, dev->stringindex[index]); | 462 | dev->stringindex[index]) |
463 | start += sprintf(start, "%s: %.100s ", id, | ||
464 | dev->stringindex[index]); | ||
465 | return start; | 465 | return start; |
466 | } | 466 | } |
467 | 467 | ||
@@ -476,8 +476,10 @@ static char *usb_dump_string(char *start, char *end, const struct usb_device *de | |||
476 | * file_offset - the offset into the devices file on completion | 476 | * file_offset - the offset into the devices file on completion |
477 | * The caller must own the device lock. | 477 | * The caller must own the device lock. |
478 | */ | 478 | */ |
479 | static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, loff_t *skip_bytes, loff_t *file_offset, | 479 | static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, |
480 | struct usb_device *usbdev, struct usb_bus *bus, int level, int index, int count) | 480 | loff_t *skip_bytes, loff_t *file_offset, |
481 | struct usb_device *usbdev, struct usb_bus *bus, | ||
482 | int level, int index, int count) | ||
481 | { | 483 | { |
482 | int chix; | 484 | int chix; |
483 | int ret, cnt = 0; | 485 | int ret, cnt = 0; |
@@ -485,17 +487,19 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, loff_t *ski | |||
485 | char *pages_start, *data_end, *speed; | 487 | char *pages_start, *data_end, *speed; |
486 | unsigned int length; | 488 | unsigned int length; |
487 | ssize_t total_written = 0; | 489 | ssize_t total_written = 0; |
488 | 490 | ||
489 | /* don't bother with anything else if we're not writing any data */ | 491 | /* don't bother with anything else if we're not writing any data */ |
490 | if (*nbytes <= 0) | 492 | if (*nbytes <= 0) |
491 | return 0; | 493 | return 0; |
492 | 494 | ||
493 | if (level > MAX_TOPO_LEVEL) | 495 | if (level > MAX_TOPO_LEVEL) |
494 | return 0; | 496 | return 0; |
495 | /* allocate 2^1 pages = 8K (on i386); should be more than enough for one device */ | 497 | /* allocate 2^1 pages = 8K (on i386); |
496 | if (!(pages_start = (char*) __get_free_pages(GFP_KERNEL,1))) | 498 | * should be more than enough for one device */ |
497 | return -ENOMEM; | 499 | pages_start = (char *)__get_free_pages(GFP_KERNEL, 1); |
498 | 500 | if (!pages_start) | |
501 | return -ENOMEM; | ||
502 | |||
499 | if (usbdev->parent && usbdev->parent->devnum != -1) | 503 | if (usbdev->parent && usbdev->parent->devnum != -1) |
500 | parent_devnum = usbdev->parent->devnum; | 504 | parent_devnum = usbdev->parent->devnum; |
501 | /* | 505 | /* |
@@ -541,15 +545,16 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, loff_t *ski | |||
541 | bus->bandwidth_allocated, max, | 545 | bus->bandwidth_allocated, max, |
542 | (100 * bus->bandwidth_allocated + max / 2) | 546 | (100 * bus->bandwidth_allocated + max / 2) |
543 | / max, | 547 | / max, |
544 | bus->bandwidth_int_reqs, | 548 | bus->bandwidth_int_reqs, |
545 | bus->bandwidth_isoc_reqs); | 549 | bus->bandwidth_isoc_reqs); |
546 | 550 | ||
547 | } | 551 | } |
548 | data_end = usb_dump_desc(data_end, pages_start + (2 * PAGE_SIZE) - 256, usbdev); | 552 | data_end = usb_dump_desc(data_end, pages_start + (2 * PAGE_SIZE) - 256, |
549 | 553 | usbdev); | |
554 | |||
550 | if (data_end > (pages_start + (2 * PAGE_SIZE) - 256)) | 555 | if (data_end > (pages_start + (2 * PAGE_SIZE) - 256)) |
551 | data_end += sprintf(data_end, "(truncated)\n"); | 556 | data_end += sprintf(data_end, "(truncated)\n"); |
552 | 557 | ||
553 | length = data_end - pages_start; | 558 | length = data_end - pages_start; |
554 | /* if we can start copying some data to the user */ | 559 | /* if we can start copying some data to the user */ |
555 | if (length > *skip_bytes) { | 560 | if (length > *skip_bytes) { |
@@ -567,17 +572,18 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, loff_t *ski | |||
567 | *skip_bytes = 0; | 572 | *skip_bytes = 0; |
568 | } else | 573 | } else |
569 | *skip_bytes -= length; | 574 | *skip_bytes -= length; |
570 | 575 | ||
571 | free_pages((unsigned long)pages_start, 1); | 576 | free_pages((unsigned long)pages_start, 1); |
572 | 577 | ||
573 | /* Now look at all of this device's children. */ | 578 | /* Now look at all of this device's children. */ |
574 | for (chix = 0; chix < usbdev->maxchild; chix++) { | 579 | for (chix = 0; chix < usbdev->maxchild; chix++) { |
575 | struct usb_device *childdev = usbdev->children[chix]; | 580 | struct usb_device *childdev = usbdev->children[chix]; |
576 | 581 | ||
577 | if (childdev) { | 582 | if (childdev) { |
578 | usb_lock_device(childdev); | 583 | usb_lock_device(childdev); |
579 | ret = usb_device_dump(buffer, nbytes, skip_bytes, file_offset, childdev, | 584 | ret = usb_device_dump(buffer, nbytes, skip_bytes, |
580 | bus, level + 1, chix, ++cnt); | 585 | file_offset, childdev, bus, |
586 | level + 1, chix, ++cnt); | ||
581 | usb_unlock_device(childdev); | 587 | usb_unlock_device(childdev); |
582 | if (ret == -EFAULT) | 588 | if (ret == -EFAULT) |
583 | return total_written; | 589 | return total_written; |
@@ -587,7 +593,8 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, loff_t *ski | |||
587 | return total_written; | 593 | return total_written; |
588 | } | 594 | } |
589 | 595 | ||
590 | static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) | 596 | static ssize_t usb_device_read(struct file *file, char __user *buf, |
597 | size_t nbytes, loff_t *ppos) | ||
591 | { | 598 | { |
592 | struct usb_bus *bus; | 599 | struct usb_bus *bus; |
593 | ssize_t ret, total_written = 0; | 600 | ssize_t ret, total_written = 0; |
@@ -607,7 +614,8 @@ static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbyte | |||
607 | if (!bus->root_hub) | 614 | if (!bus->root_hub) |
608 | continue; | 615 | continue; |
609 | usb_lock_device(bus->root_hub); | 616 | usb_lock_device(bus->root_hub); |
610 | ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos, bus->root_hub, bus, 0, 0, 0); | 617 | ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos, |
618 | bus->root_hub, bus, 0, 0, 0); | ||
611 | usb_unlock_device(bus->root_hub); | 619 | usb_unlock_device(bus->root_hub); |
612 | if (ret < 0) { | 620 | if (ret < 0) { |
613 | mutex_unlock(&usb_bus_list_lock); | 621 | mutex_unlock(&usb_bus_list_lock); |
@@ -620,7 +628,8 @@ static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbyte | |||
620 | } | 628 | } |
621 | 629 | ||
622 | /* Kernel lock for "lastev" protection */ | 630 | /* Kernel lock for "lastev" protection */ |
623 | static unsigned int usb_device_poll(struct file *file, struct poll_table_struct *wait) | 631 | static unsigned int usb_device_poll(struct file *file, |
632 | struct poll_table_struct *wait) | ||
624 | { | 633 | { |
625 | struct usb_device_status *st = file->private_data; | 634 | struct usb_device_status *st = file->private_data; |
626 | unsigned int mask = 0; | 635 | unsigned int mask = 0; |
@@ -629,7 +638,8 @@ static unsigned int usb_device_poll(struct file *file, struct poll_table_struct | |||
629 | if (!st) { | 638 | if (!st) { |
630 | st = kmalloc(sizeof(struct usb_device_status), GFP_KERNEL); | 639 | st = kmalloc(sizeof(struct usb_device_status), GFP_KERNEL); |
631 | 640 | ||
632 | /* we may have dropped BKL - need to check for having lost the race */ | 641 | /* we may have dropped BKL - |
642 | * need to check for having lost the race */ | ||
633 | if (file->private_data) { | 643 | if (file->private_data) { |
634 | kfree(st); | 644 | kfree(st); |
635 | st = file->private_data; | 645 | st = file->private_data; |
@@ -652,7 +662,7 @@ static unsigned int usb_device_poll(struct file *file, struct poll_table_struct | |||
652 | } | 662 | } |
653 | lost_race: | 663 | lost_race: |
654 | if (file->f_mode & FMODE_READ) | 664 | if (file->f_mode & FMODE_READ) |
655 | poll_wait(file, &deviceconndiscwq, wait); | 665 | poll_wait(file, &deviceconndiscwq, wait); |
656 | if (st->lastev != conndiscevcnt) | 666 | if (st->lastev != conndiscevcnt) |
657 | mask |= POLLIN; | 667 | mask |= POLLIN; |
658 | st->lastev = conndiscevcnt; | 668 | st->lastev = conndiscevcnt; |
@@ -662,18 +672,18 @@ lost_race: | |||
662 | 672 | ||
663 | static int usb_device_open(struct inode *inode, struct file *file) | 673 | static int usb_device_open(struct inode *inode, struct file *file) |
664 | { | 674 | { |
665 | file->private_data = NULL; | 675 | file->private_data = NULL; |
666 | return 0; | 676 | return 0; |
667 | } | 677 | } |
668 | 678 | ||
669 | static int usb_device_release(struct inode *inode, struct file *file) | 679 | static int usb_device_release(struct inode *inode, struct file *file) |
670 | { | 680 | { |
671 | kfree(file->private_data); | 681 | kfree(file->private_data); |
672 | file->private_data = NULL; | 682 | file->private_data = NULL; |
673 | return 0; | 683 | return 0; |
674 | } | 684 | } |
675 | 685 | ||
676 | static loff_t usb_device_lseek(struct file * file, loff_t offset, int orig) | 686 | static loff_t usb_device_lseek(struct file *file, loff_t offset, int orig) |
677 | { | 687 | { |
678 | loff_t ret; | 688 | loff_t ret; |
679 | 689 | ||
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 1f4f6d02fe25..ae94176c64e4 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -75,14 +75,14 @@ struct async { | |||
75 | u32 secid; | 75 | u32 secid; |
76 | }; | 76 | }; |
77 | 77 | ||
78 | static int usbfs_snoop = 0; | 78 | static int usbfs_snoop; |
79 | module_param (usbfs_snoop, bool, S_IRUGO | S_IWUSR); | 79 | module_param(usbfs_snoop, bool, S_IRUGO | S_IWUSR); |
80 | MODULE_PARM_DESC (usbfs_snoop, "true to log all usbfs traffic"); | 80 | MODULE_PARM_DESC(usbfs_snoop, "true to log all usbfs traffic"); |
81 | 81 | ||
82 | #define snoop(dev, format, arg...) \ | 82 | #define snoop(dev, format, arg...) \ |
83 | do { \ | 83 | do { \ |
84 | if (usbfs_snoop) \ | 84 | if (usbfs_snoop) \ |
85 | dev_info( dev , format , ## arg); \ | 85 | dev_info(dev , format , ## arg); \ |
86 | } while (0) | 86 | } while (0) |
87 | 87 | ||
88 | #define USB_DEVICE_DEV MKDEV(USB_DEVICE_MAJOR, 0) | 88 | #define USB_DEVICE_DEV MKDEV(USB_DEVICE_MAJOR, 0) |
@@ -90,7 +90,7 @@ MODULE_PARM_DESC (usbfs_snoop, "true to log all usbfs traffic"); | |||
90 | 90 | ||
91 | #define MAX_USBFS_BUFFER_SIZE 16384 | 91 | #define MAX_USBFS_BUFFER_SIZE 16384 |
92 | 92 | ||
93 | static inline int connected (struct dev_state *ps) | 93 | static inline int connected(struct dev_state *ps) |
94 | { | 94 | { |
95 | return (!list_empty(&ps->list) && | 95 | return (!list_empty(&ps->list) && |
96 | ps->dev->state != USB_STATE_NOTATTACHED); | 96 | ps->dev->state != USB_STATE_NOTATTACHED); |
@@ -120,7 +120,8 @@ static loff_t usbdev_lseek(struct file *file, loff_t offset, int orig) | |||
120 | return ret; | 120 | return ret; |
121 | } | 121 | } |
122 | 122 | ||
123 | static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) | 123 | static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, |
124 | loff_t *ppos) | ||
124 | { | 125 | { |
125 | struct dev_state *ps = file->private_data; | 126 | struct dev_state *ps = file->private_data; |
126 | struct usb_device *dev = ps->dev; | 127 | struct usb_device *dev = ps->dev; |
@@ -140,7 +141,8 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, l | |||
140 | } | 141 | } |
141 | 142 | ||
142 | if (pos < sizeof(struct usb_device_descriptor)) { | 143 | if (pos < sizeof(struct usb_device_descriptor)) { |
143 | struct usb_device_descriptor temp_desc ; /* 18 bytes - fits on the stack */ | 144 | /* 18 bytes - fits on the stack */ |
145 | struct usb_device_descriptor temp_desc; | ||
144 | 146 | ||
145 | memcpy(&temp_desc, &dev->descriptor, sizeof(dev->descriptor)); | 147 | memcpy(&temp_desc, &dev->descriptor, sizeof(dev->descriptor)); |
146 | le16_to_cpus(&temp_desc.bcdUSB); | 148 | le16_to_cpus(&temp_desc.bcdUSB); |
@@ -210,17 +212,17 @@ err: | |||
210 | 212 | ||
211 | static struct async *alloc_async(unsigned int numisoframes) | 213 | static struct async *alloc_async(unsigned int numisoframes) |
212 | { | 214 | { |
213 | unsigned int assize = sizeof(struct async) + numisoframes * sizeof(struct usb_iso_packet_descriptor); | 215 | struct async *as; |
214 | struct async *as = kzalloc(assize, GFP_KERNEL); | ||
215 | 216 | ||
216 | if (!as) | 217 | as = kzalloc(sizeof(struct async), GFP_KERNEL); |
217 | return NULL; | 218 | if (!as) |
219 | return NULL; | ||
218 | as->urb = usb_alloc_urb(numisoframes, GFP_KERNEL); | 220 | as->urb = usb_alloc_urb(numisoframes, GFP_KERNEL); |
219 | if (!as->urb) { | 221 | if (!as->urb) { |
220 | kfree(as); | 222 | kfree(as); |
221 | return NULL; | 223 | return NULL; |
222 | } | 224 | } |
223 | return as; | 225 | return as; |
224 | } | 226 | } |
225 | 227 | ||
226 | static void free_async(struct async *as) | 228 | static void free_async(struct async *as) |
@@ -234,52 +236,54 @@ static void free_async(struct async *as) | |||
234 | 236 | ||
235 | static inline void async_newpending(struct async *as) | 237 | static inline void async_newpending(struct async *as) |
236 | { | 238 | { |
237 | struct dev_state *ps = as->ps; | 239 | struct dev_state *ps = as->ps; |
238 | unsigned long flags; | 240 | unsigned long flags; |
239 | 241 | ||
240 | spin_lock_irqsave(&ps->lock, flags); | 242 | spin_lock_irqsave(&ps->lock, flags); |
241 | list_add_tail(&as->asynclist, &ps->async_pending); | 243 | list_add_tail(&as->asynclist, &ps->async_pending); |
242 | spin_unlock_irqrestore(&ps->lock, flags); | 244 | spin_unlock_irqrestore(&ps->lock, flags); |
243 | } | 245 | } |
244 | 246 | ||
245 | static inline void async_removepending(struct async *as) | 247 | static inline void async_removepending(struct async *as) |
246 | { | 248 | { |
247 | struct dev_state *ps = as->ps; | 249 | struct dev_state *ps = as->ps; |
248 | unsigned long flags; | 250 | unsigned long flags; |
249 | 251 | ||
250 | spin_lock_irqsave(&ps->lock, flags); | 252 | spin_lock_irqsave(&ps->lock, flags); |
251 | list_del_init(&as->asynclist); | 253 | list_del_init(&as->asynclist); |
252 | spin_unlock_irqrestore(&ps->lock, flags); | 254 | spin_unlock_irqrestore(&ps->lock, flags); |
253 | } | 255 | } |
254 | 256 | ||
255 | static inline struct async *async_getcompleted(struct dev_state *ps) | 257 | static inline struct async *async_getcompleted(struct dev_state *ps) |
256 | { | 258 | { |
257 | unsigned long flags; | 259 | unsigned long flags; |
258 | struct async *as = NULL; | 260 | struct async *as = NULL; |
259 | 261 | ||
260 | spin_lock_irqsave(&ps->lock, flags); | 262 | spin_lock_irqsave(&ps->lock, flags); |
261 | if (!list_empty(&ps->async_completed)) { | 263 | if (!list_empty(&ps->async_completed)) { |
262 | as = list_entry(ps->async_completed.next, struct async, asynclist); | 264 | as = list_entry(ps->async_completed.next, struct async, |
263 | list_del_init(&as->asynclist); | 265 | asynclist); |
264 | } | 266 | list_del_init(&as->asynclist); |
265 | spin_unlock_irqrestore(&ps->lock, flags); | 267 | } |
266 | return as; | 268 | spin_unlock_irqrestore(&ps->lock, flags); |
269 | return as; | ||
267 | } | 270 | } |
268 | 271 | ||
269 | static inline struct async *async_getpending(struct dev_state *ps, void __user *userurb) | 272 | static inline struct async *async_getpending(struct dev_state *ps, |
273 | void __user *userurb) | ||
270 | { | 274 | { |
271 | unsigned long flags; | 275 | unsigned long flags; |
272 | struct async *as; | 276 | struct async *as; |
273 | 277 | ||
274 | spin_lock_irqsave(&ps->lock, flags); | 278 | spin_lock_irqsave(&ps->lock, flags); |
275 | list_for_each_entry(as, &ps->async_pending, asynclist) | 279 | list_for_each_entry(as, &ps->async_pending, asynclist) |
276 | if (as->userurb == userurb) { | 280 | if (as->userurb == userurb) { |
277 | list_del_init(&as->asynclist); | 281 | list_del_init(&as->asynclist); |
278 | spin_unlock_irqrestore(&ps->lock, flags); | 282 | spin_unlock_irqrestore(&ps->lock, flags); |
279 | return as; | 283 | return as; |
280 | } | 284 | } |
281 | spin_unlock_irqrestore(&ps->lock, flags); | 285 | spin_unlock_irqrestore(&ps->lock, flags); |
282 | return NULL; | 286 | return NULL; |
283 | } | 287 | } |
284 | 288 | ||
285 | static void snoop_urb(struct urb *urb, void __user *userurb) | 289 | static void snoop_urb(struct urb *urb, void __user *userurb) |
@@ -298,19 +302,19 @@ static void snoop_urb(struct urb *urb, void __user *userurb) | |||
298 | dev_info(&urb->dev->dev, "actual_length=%d\n", urb->actual_length); | 302 | dev_info(&urb->dev->dev, "actual_length=%d\n", urb->actual_length); |
299 | dev_info(&urb->dev->dev, "data: "); | 303 | dev_info(&urb->dev->dev, "data: "); |
300 | for (j = 0; j < urb->transfer_buffer_length; ++j) | 304 | for (j = 0; j < urb->transfer_buffer_length; ++j) |
301 | printk ("%02x ", data[j]); | 305 | printk("%02x ", data[j]); |
302 | printk("\n"); | 306 | printk("\n"); |
303 | } | 307 | } |
304 | 308 | ||
305 | static void async_completed(struct urb *urb) | 309 | static void async_completed(struct urb *urb) |
306 | { | 310 | { |
307 | struct async *as = urb->context; | 311 | struct async *as = urb->context; |
308 | struct dev_state *ps = as->ps; | 312 | struct dev_state *ps = as->ps; |
309 | struct siginfo sinfo; | 313 | struct siginfo sinfo; |
310 | 314 | ||
311 | spin_lock(&ps->lock); | 315 | spin_lock(&ps->lock); |
312 | list_move_tail(&as->asynclist, &ps->async_completed); | 316 | list_move_tail(&as->asynclist, &ps->async_completed); |
313 | spin_unlock(&ps->lock); | 317 | spin_unlock(&ps->lock); |
314 | as->status = urb->status; | 318 | as->status = urb->status; |
315 | if (as->signr) { | 319 | if (as->signr) { |
316 | sinfo.si_signo = as->signr; | 320 | sinfo.si_signo = as->signr; |
@@ -325,7 +329,7 @@ static void async_completed(struct urb *urb) | |||
325 | wake_up(&ps->wait); | 329 | wake_up(&ps->wait); |
326 | } | 330 | } |
327 | 331 | ||
328 | static void destroy_async (struct dev_state *ps, struct list_head *list) | 332 | static void destroy_async(struct dev_state *ps, struct list_head *list) |
329 | { | 333 | { |
330 | struct async *as; | 334 | struct async *as; |
331 | unsigned long flags; | 335 | unsigned long flags; |
@@ -348,7 +352,8 @@ static void destroy_async (struct dev_state *ps, struct list_head *list) | |||
348 | } | 352 | } |
349 | } | 353 | } |
350 | 354 | ||
351 | static void destroy_async_on_interface (struct dev_state *ps, unsigned int ifnum) | 355 | static void destroy_async_on_interface(struct dev_state *ps, |
356 | unsigned int ifnum) | ||
352 | { | 357 | { |
353 | struct list_head *p, *q, hitlist; | 358 | struct list_head *p, *q, hitlist; |
354 | unsigned long flags; | 359 | unsigned long flags; |
@@ -364,7 +369,7 @@ static void destroy_async_on_interface (struct dev_state *ps, unsigned int ifnum | |||
364 | 369 | ||
365 | static inline void destroy_all_async(struct dev_state *ps) | 370 | static inline void destroy_all_async(struct dev_state *ps) |
366 | { | 371 | { |
367 | destroy_async(ps, &ps->async_pending); | 372 | destroy_async(ps, &ps->async_pending); |
368 | } | 373 | } |
369 | 374 | ||
370 | /* | 375 | /* |
@@ -373,15 +378,15 @@ static inline void destroy_all_async(struct dev_state *ps) | |||
373 | * they're also undone when devices disconnect. | 378 | * they're also undone when devices disconnect. |
374 | */ | 379 | */ |
375 | 380 | ||
376 | static int driver_probe (struct usb_interface *intf, | 381 | static int driver_probe(struct usb_interface *intf, |
377 | const struct usb_device_id *id) | 382 | const struct usb_device_id *id) |
378 | { | 383 | { |
379 | return -ENODEV; | 384 | return -ENODEV; |
380 | } | 385 | } |
381 | 386 | ||
382 | static void driver_disconnect(struct usb_interface *intf) | 387 | static void driver_disconnect(struct usb_interface *intf) |
383 | { | 388 | { |
384 | struct dev_state *ps = usb_get_intfdata (intf); | 389 | struct dev_state *ps = usb_get_intfdata(intf); |
385 | unsigned int ifnum = intf->altsetting->desc.bInterfaceNumber; | 390 | unsigned int ifnum = intf->altsetting->desc.bInterfaceNumber; |
386 | 391 | ||
387 | if (!ps) | 392 | if (!ps) |
@@ -396,16 +401,31 @@ static void driver_disconnect(struct usb_interface *intf) | |||
396 | else | 401 | else |
397 | warn("interface number %u out of range", ifnum); | 402 | warn("interface number %u out of range", ifnum); |
398 | 403 | ||
399 | usb_set_intfdata (intf, NULL); | 404 | usb_set_intfdata(intf, NULL); |
400 | 405 | ||
401 | /* force async requests to complete */ | 406 | /* force async requests to complete */ |
402 | destroy_async_on_interface(ps, ifnum); | 407 | destroy_async_on_interface(ps, ifnum); |
403 | } | 408 | } |
404 | 409 | ||
410 | /* The following routines are merely placeholders. There is no way | ||
411 | * to inform a user task about suspend or resumes. | ||
412 | */ | ||
413 | static int driver_suspend(struct usb_interface *intf, pm_message_t msg) | ||
414 | { | ||
415 | return 0; | ||
416 | } | ||
417 | |||
418 | static int driver_resume(struct usb_interface *intf) | ||
419 | { | ||
420 | return 0; | ||
421 | } | ||
422 | |||
405 | struct usb_driver usbfs_driver = { | 423 | struct usb_driver usbfs_driver = { |
406 | .name = "usbfs", | 424 | .name = "usbfs", |
407 | .probe = driver_probe, | 425 | .probe = driver_probe, |
408 | .disconnect = driver_disconnect, | 426 | .disconnect = driver_disconnect, |
427 | .suspend = driver_suspend, | ||
428 | .resume = driver_resume, | ||
409 | }; | 429 | }; |
410 | 430 | ||
411 | static int claimintf(struct dev_state *ps, unsigned int ifnum) | 431 | static int claimintf(struct dev_state *ps, unsigned int ifnum) |
@@ -459,15 +479,16 @@ static int checkintf(struct dev_state *ps, unsigned int ifnum) | |||
459 | if (test_bit(ifnum, &ps->ifclaimed)) | 479 | if (test_bit(ifnum, &ps->ifclaimed)) |
460 | return 0; | 480 | return 0; |
461 | /* if not yet claimed, claim it for the driver */ | 481 | /* if not yet claimed, claim it for the driver */ |
462 | dev_warn(&ps->dev->dev, "usbfs: process %d (%s) did not claim interface %u before use\n", | 482 | dev_warn(&ps->dev->dev, "usbfs: process %d (%s) did not claim " |
463 | task_pid_nr(current), current->comm, ifnum); | 483 | "interface %u before use\n", task_pid_nr(current), |
484 | current->comm, ifnum); | ||
464 | return claimintf(ps, ifnum); | 485 | return claimintf(ps, ifnum); |
465 | } | 486 | } |
466 | 487 | ||
467 | static int findintfep(struct usb_device *dev, unsigned int ep) | 488 | static int findintfep(struct usb_device *dev, unsigned int ep) |
468 | { | 489 | { |
469 | unsigned int i, j, e; | 490 | unsigned int i, j, e; |
470 | struct usb_interface *intf; | 491 | struct usb_interface *intf; |
471 | struct usb_host_interface *alts; | 492 | struct usb_host_interface *alts; |
472 | struct usb_endpoint_descriptor *endpt; | 493 | struct usb_endpoint_descriptor *endpt; |
473 | 494 | ||
@@ -478,7 +499,7 @@ static int findintfep(struct usb_device *dev, unsigned int ep) | |||
478 | for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { | 499 | for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { |
479 | intf = dev->actconfig->interface[i]; | 500 | intf = dev->actconfig->interface[i]; |
480 | for (j = 0; j < intf->num_altsetting; j++) { | 501 | for (j = 0; j < intf->num_altsetting; j++) { |
481 | alts = &intf->altsetting[j]; | 502 | alts = &intf->altsetting[j]; |
482 | for (e = 0; e < alts->desc.bNumEndpoints; e++) { | 503 | for (e = 0; e < alts->desc.bNumEndpoints; e++) { |
483 | endpt = &alts->endpoint[e].desc; | 504 | endpt = &alts->endpoint[e].desc; |
484 | if (endpt->bEndpointAddress == ep) | 505 | if (endpt->bEndpointAddress == ep) |
@@ -486,10 +507,11 @@ static int findintfep(struct usb_device *dev, unsigned int ep) | |||
486 | } | 507 | } |
487 | } | 508 | } |
488 | } | 509 | } |
489 | return -ENOENT; | 510 | return -ENOENT; |
490 | } | 511 | } |
491 | 512 | ||
492 | static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, unsigned int index) | 513 | static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, |
514 | unsigned int index) | ||
493 | { | 515 | { |
494 | int ret = 0; | 516 | int ret = 0; |
495 | 517 | ||
@@ -502,7 +524,8 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, unsig | |||
502 | index &= 0xff; | 524 | index &= 0xff; |
503 | switch (requesttype & USB_RECIP_MASK) { | 525 | switch (requesttype & USB_RECIP_MASK) { |
504 | case USB_RECIP_ENDPOINT: | 526 | case USB_RECIP_ENDPOINT: |
505 | if ((ret = findintfep(ps->dev, index)) >= 0) | 527 | ret = findintfep(ps->dev, index); |
528 | if (ret >= 0) | ||
506 | ret = checkintf(ps, ret); | 529 | ret = checkintf(ps, ret); |
507 | break; | 530 | break; |
508 | 531 | ||
@@ -546,7 +569,8 @@ static int usbdev_open(struct inode *inode, struct file *file) | |||
546 | mutex_lock(&usbfs_mutex); | 569 | mutex_lock(&usbfs_mutex); |
547 | 570 | ||
548 | ret = -ENOMEM; | 571 | ret = -ENOMEM; |
549 | if (!(ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL))) | 572 | ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL); |
573 | if (!ps) | ||
550 | goto out; | 574 | goto out; |
551 | 575 | ||
552 | ret = -ENOENT; | 576 | ret = -ENOENT; |
@@ -627,15 +651,18 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
627 | 651 | ||
628 | if (copy_from_user(&ctrl, arg, sizeof(ctrl))) | 652 | if (copy_from_user(&ctrl, arg, sizeof(ctrl))) |
629 | return -EFAULT; | 653 | return -EFAULT; |
630 | if ((ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.wIndex))) | 654 | ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.wIndex); |
655 | if (ret) | ||
631 | return ret; | 656 | return ret; |
632 | if (ctrl.wLength > PAGE_SIZE) | 657 | if (ctrl.wLength > PAGE_SIZE) |
633 | return -EINVAL; | 658 | return -EINVAL; |
634 | if (!(tbuf = (unsigned char *)__get_free_page(GFP_KERNEL))) | 659 | tbuf = (unsigned char *)__get_free_page(GFP_KERNEL); |
660 | if (!tbuf) | ||
635 | return -ENOMEM; | 661 | return -ENOMEM; |
636 | tmo = ctrl.timeout; | 662 | tmo = ctrl.timeout; |
637 | if (ctrl.bRequestType & 0x80) { | 663 | if (ctrl.bRequestType & 0x80) { |
638 | if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, ctrl.wLength)) { | 664 | if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, |
665 | ctrl.wLength)) { | ||
639 | free_page((unsigned long)tbuf); | 666 | free_page((unsigned long)tbuf); |
640 | return -EINVAL; | 667 | return -EINVAL; |
641 | } | 668 | } |
@@ -646,14 +673,15 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
646 | ctrl.wIndex, ctrl.wLength); | 673 | ctrl.wIndex, ctrl.wLength); |
647 | 674 | ||
648 | usb_unlock_device(dev); | 675 | usb_unlock_device(dev); |
649 | i = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), ctrl.bRequest, ctrl.bRequestType, | 676 | i = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), ctrl.bRequest, |
650 | ctrl.wValue, ctrl.wIndex, tbuf, ctrl.wLength, tmo); | 677 | ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, |
678 | tbuf, ctrl.wLength, tmo); | ||
651 | usb_lock_device(dev); | 679 | usb_lock_device(dev); |
652 | if ((i > 0) && ctrl.wLength) { | 680 | if ((i > 0) && ctrl.wLength) { |
653 | if (usbfs_snoop) { | 681 | if (usbfs_snoop) { |
654 | dev_info(&dev->dev, "control read: data "); | 682 | dev_info(&dev->dev, "control read: data "); |
655 | for (j = 0; j < i; ++j) | 683 | for (j = 0; j < i; ++j) |
656 | printk("%02x ", (unsigned char)(tbuf)[j]); | 684 | printk("%02x ", (u8)(tbuf)[j]); |
657 | printk("\n"); | 685 | printk("\n"); |
658 | } | 686 | } |
659 | if (copy_to_user(ctrl.data, tbuf, i)) { | 687 | if (copy_to_user(ctrl.data, tbuf, i)) { |
@@ -680,12 +708,13 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
680 | printk("\n"); | 708 | printk("\n"); |
681 | } | 709 | } |
682 | usb_unlock_device(dev); | 710 | usb_unlock_device(dev); |
683 | i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, ctrl.bRequestType, | 711 | i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, |
684 | ctrl.wValue, ctrl.wIndex, tbuf, ctrl.wLength, tmo); | 712 | ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, |
713 | tbuf, ctrl.wLength, tmo); | ||
685 | usb_lock_device(dev); | 714 | usb_lock_device(dev); |
686 | } | 715 | } |
687 | free_page((unsigned long)tbuf); | 716 | free_page((unsigned long)tbuf); |
688 | if (i<0 && i != -EPIPE) { | 717 | if (i < 0 && i != -EPIPE) { |
689 | dev_printk(KERN_DEBUG, &dev->dev, "usbfs: USBDEVFS_CONTROL " | 718 | dev_printk(KERN_DEBUG, &dev->dev, "usbfs: USBDEVFS_CONTROL " |
690 | "failed cmd %s rqt %u rq %u len %u ret %d\n", | 719 | "failed cmd %s rqt %u rq %u len %u ret %d\n", |
691 | current->comm, ctrl.bRequestType, ctrl.bRequest, | 720 | current->comm, ctrl.bRequestType, ctrl.bRequest, |
@@ -705,9 +734,11 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) | |||
705 | 734 | ||
706 | if (copy_from_user(&bulk, arg, sizeof(bulk))) | 735 | if (copy_from_user(&bulk, arg, sizeof(bulk))) |
707 | return -EFAULT; | 736 | return -EFAULT; |
708 | if ((ret = findintfep(ps->dev, bulk.ep)) < 0) | 737 | ret = findintfep(ps->dev, bulk.ep); |
738 | if (ret < 0) | ||
709 | return ret; | 739 | return ret; |
710 | if ((ret = checkintf(ps, ret))) | 740 | ret = checkintf(ps, ret); |
741 | if (ret) | ||
711 | return ret; | 742 | return ret; |
712 | if (bulk.ep & USB_DIR_IN) | 743 | if (bulk.ep & USB_DIR_IN) |
713 | pipe = usb_rcvbulkpipe(dev, bulk.ep & 0x7f); | 744 | pipe = usb_rcvbulkpipe(dev, bulk.ep & 0x7f); |
@@ -735,7 +766,7 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) | |||
735 | if (usbfs_snoop) { | 766 | if (usbfs_snoop) { |
736 | dev_info(&dev->dev, "bulk read: data "); | 767 | dev_info(&dev->dev, "bulk read: data "); |
737 | for (j = 0; j < len2; ++j) | 768 | for (j = 0; j < len2; ++j) |
738 | printk("%02x ", (unsigned char)(tbuf)[j]); | 769 | printk("%02x ", (u8)(tbuf)[j]); |
739 | printk("\n"); | 770 | printk("\n"); |
740 | } | 771 | } |
741 | if (copy_to_user(bulk.data, tbuf, len2)) { | 772 | if (copy_to_user(bulk.data, tbuf, len2)) { |
@@ -775,9 +806,11 @@ static int proc_resetep(struct dev_state *ps, void __user *arg) | |||
775 | 806 | ||
776 | if (get_user(ep, (unsigned int __user *)arg)) | 807 | if (get_user(ep, (unsigned int __user *)arg)) |
777 | return -EFAULT; | 808 | return -EFAULT; |
778 | if ((ret = findintfep(ps->dev, ep)) < 0) | 809 | ret = findintfep(ps->dev, ep); |
810 | if (ret < 0) | ||
779 | return ret; | 811 | return ret; |
780 | if ((ret = checkintf(ps, ret))) | 812 | ret = checkintf(ps, ret); |
813 | if (ret) | ||
781 | return ret; | 814 | return ret; |
782 | usb_settoggle(ps->dev, ep & 0xf, !(ep & USB_DIR_IN), 0); | 815 | usb_settoggle(ps->dev, ep & 0xf, !(ep & USB_DIR_IN), 0); |
783 | return 0; | 816 | return 0; |
@@ -791,18 +824,19 @@ static int proc_clearhalt(struct dev_state *ps, void __user *arg) | |||
791 | 824 | ||
792 | if (get_user(ep, (unsigned int __user *)arg)) | 825 | if (get_user(ep, (unsigned int __user *)arg)) |
793 | return -EFAULT; | 826 | return -EFAULT; |
794 | if ((ret = findintfep(ps->dev, ep)) < 0) | 827 | ret = findintfep(ps->dev, ep); |
828 | if (ret < 0) | ||
795 | return ret; | 829 | return ret; |
796 | if ((ret = checkintf(ps, ret))) | 830 | ret = checkintf(ps, ret); |
831 | if (ret) | ||
797 | return ret; | 832 | return ret; |
798 | if (ep & USB_DIR_IN) | 833 | if (ep & USB_DIR_IN) |
799 | pipe = usb_rcvbulkpipe(ps->dev, ep & 0x7f); | 834 | pipe = usb_rcvbulkpipe(ps->dev, ep & 0x7f); |
800 | else | 835 | else |
801 | pipe = usb_sndbulkpipe(ps->dev, ep & 0x7f); | 836 | pipe = usb_sndbulkpipe(ps->dev, ep & 0x7f); |
802 | 837 | ||
803 | return usb_clear_halt(ps->dev, pipe); | 838 | return usb_clear_halt(ps->dev, pipe); |
804 | } | 839 | } |
805 | |||
806 | 840 | ||
807 | static int proc_getdriver(struct dev_state *ps, void __user *arg) | 841 | static int proc_getdriver(struct dev_state *ps, void __user *arg) |
808 | { | 842 | { |
@@ -856,23 +890,23 @@ static int proc_setconfig(struct dev_state *ps, void __user *arg) | |||
856 | { | 890 | { |
857 | int u; | 891 | int u; |
858 | int status = 0; | 892 | int status = 0; |
859 | struct usb_host_config *actconfig; | 893 | struct usb_host_config *actconfig; |
860 | 894 | ||
861 | if (get_user(u, (int __user *)arg)) | 895 | if (get_user(u, (int __user *)arg)) |
862 | return -EFAULT; | 896 | return -EFAULT; |
863 | 897 | ||
864 | actconfig = ps->dev->actconfig; | 898 | actconfig = ps->dev->actconfig; |
865 | 899 | ||
866 | /* Don't touch the device if any interfaces are claimed. | 900 | /* Don't touch the device if any interfaces are claimed. |
867 | * It could interfere with other drivers' operations, and if | 901 | * It could interfere with other drivers' operations, and if |
868 | * an interface is claimed by usbfs it could easily deadlock. | 902 | * an interface is claimed by usbfs it could easily deadlock. |
869 | */ | 903 | */ |
870 | if (actconfig) { | 904 | if (actconfig) { |
871 | int i; | 905 | int i; |
872 | 906 | ||
873 | for (i = 0; i < actconfig->desc.bNumInterfaces; ++i) { | 907 | for (i = 0; i < actconfig->desc.bNumInterfaces; ++i) { |
874 | if (usb_interface_claimed(actconfig->interface[i])) { | 908 | if (usb_interface_claimed(actconfig->interface[i])) { |
875 | dev_warn (&ps->dev->dev, | 909 | dev_warn(&ps->dev->dev, |
876 | "usbfs: interface %d claimed by %s " | 910 | "usbfs: interface %d claimed by %s " |
877 | "while '%s' sets config #%d\n", | 911 | "while '%s' sets config #%d\n", |
878 | actconfig->interface[i] | 912 | actconfig->interface[i] |
@@ -881,11 +915,11 @@ static int proc_setconfig(struct dev_state *ps, void __user *arg) | |||
881 | actconfig->interface[i] | 915 | actconfig->interface[i] |
882 | ->dev.driver->name, | 916 | ->dev.driver->name, |
883 | current->comm, u); | 917 | current->comm, u); |
884 | status = -EBUSY; | 918 | status = -EBUSY; |
885 | break; | 919 | break; |
886 | } | 920 | } |
887 | } | 921 | } |
888 | } | 922 | } |
889 | 923 | ||
890 | /* SET_CONFIGURATION is often abused as a "cheap" driver reset, | 924 | /* SET_CONFIGURATION is often abused as a "cheap" driver reset, |
891 | * so avoid usb_set_configuration()'s kick to sysfs | 925 | * so avoid usb_set_configuration()'s kick to sysfs |
@@ -901,8 +935,8 @@ static int proc_setconfig(struct dev_state *ps, void __user *arg) | |||
901 | } | 935 | } |
902 | 936 | ||
903 | static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | 937 | static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, |
904 | struct usbdevfs_iso_packet_desc __user *iso_frame_desc, | 938 | struct usbdevfs_iso_packet_desc __user *iso_frame_desc, |
905 | void __user *arg) | 939 | void __user *arg) |
906 | { | 940 | { |
907 | struct usbdevfs_iso_packet_desc *isopkt = NULL; | 941 | struct usbdevfs_iso_packet_desc *isopkt = NULL; |
908 | struct usb_host_endpoint *ep; | 942 | struct usb_host_endpoint *ep; |
@@ -917,12 +951,16 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
917 | return -EINVAL; | 951 | return -EINVAL; |
918 | if (!uurb->buffer) | 952 | if (!uurb->buffer) |
919 | return -EINVAL; | 953 | return -EINVAL; |
920 | if (uurb->signr != 0 && (uurb->signr < SIGRTMIN || uurb->signr > SIGRTMAX)) | 954 | if (uurb->signr != 0 && (uurb->signr < SIGRTMIN || |
955 | uurb->signr > SIGRTMAX)) | ||
921 | return -EINVAL; | 956 | return -EINVAL; |
922 | if (!(uurb->type == USBDEVFS_URB_TYPE_CONTROL && (uurb->endpoint & ~USB_ENDPOINT_DIR_MASK) == 0)) { | 957 | if (!(uurb->type == USBDEVFS_URB_TYPE_CONTROL && |
923 | if ((ifnum = findintfep(ps->dev, uurb->endpoint)) < 0) | 958 | (uurb->endpoint & ~USB_ENDPOINT_DIR_MASK) == 0)) { |
959 | ifnum = findintfep(ps->dev, uurb->endpoint); | ||
960 | if (ifnum < 0) | ||
924 | return ifnum; | 961 | return ifnum; |
925 | if ((ret = checkintf(ps, ifnum))) | 962 | ret = checkintf(ps, ifnum); |
963 | if (ret) | ||
926 | return ret; | 964 | return ret; |
927 | } | 965 | } |
928 | if ((uurb->endpoint & USB_ENDPOINT_DIR_MASK) != 0) { | 966 | if ((uurb->endpoint & USB_ENDPOINT_DIR_MASK) != 0) { |
@@ -938,10 +976,13 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
938 | case USBDEVFS_URB_TYPE_CONTROL: | 976 | case USBDEVFS_URB_TYPE_CONTROL: |
939 | if (!usb_endpoint_xfer_control(&ep->desc)) | 977 | if (!usb_endpoint_xfer_control(&ep->desc)) |
940 | return -EINVAL; | 978 | return -EINVAL; |
941 | /* min 8 byte setup packet, max 8 byte setup plus an arbitrary data stage */ | 979 | /* min 8 byte setup packet, |
942 | if (uurb->buffer_length < 8 || uurb->buffer_length > (8 + MAX_USBFS_BUFFER_SIZE)) | 980 | * max 8 byte setup plus an arbitrary data stage */ |
981 | if (uurb->buffer_length < 8 || | ||
982 | uurb->buffer_length > (8 + MAX_USBFS_BUFFER_SIZE)) | ||
943 | return -EINVAL; | 983 | return -EINVAL; |
944 | if (!(dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL))) | 984 | dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); |
985 | if (!dr) | ||
945 | return -ENOMEM; | 986 | return -ENOMEM; |
946 | if (copy_from_user(dr, uurb->buffer, 8)) { | 987 | if (copy_from_user(dr, uurb->buffer, 8)) { |
947 | kfree(dr); | 988 | kfree(dr); |
@@ -951,7 +992,9 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
951 | kfree(dr); | 992 | kfree(dr); |
952 | return -EINVAL; | 993 | return -EINVAL; |
953 | } | 994 | } |
954 | if ((ret = check_ctrlrecip(ps, dr->bRequestType, le16_to_cpup(&dr->wIndex)))) { | 995 | ret = check_ctrlrecip(ps, dr->bRequestType, |
996 | le16_to_cpup(&dr->wIndex)); | ||
997 | if (ret) { | ||
955 | kfree(dr); | 998 | kfree(dr); |
956 | return ret; | 999 | return ret; |
957 | } | 1000 | } |
@@ -997,11 +1040,13 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
997 | 1040 | ||
998 | case USBDEVFS_URB_TYPE_ISO: | 1041 | case USBDEVFS_URB_TYPE_ISO: |
999 | /* arbitrary limit */ | 1042 | /* arbitrary limit */ |
1000 | if (uurb->number_of_packets < 1 || uurb->number_of_packets > 128) | 1043 | if (uurb->number_of_packets < 1 || |
1044 | uurb->number_of_packets > 128) | ||
1001 | return -EINVAL; | 1045 | return -EINVAL; |
1002 | if (!usb_endpoint_xfer_isoc(&ep->desc)) | 1046 | if (!usb_endpoint_xfer_isoc(&ep->desc)) |
1003 | return -EINVAL; | 1047 | return -EINVAL; |
1004 | isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) * uurb->number_of_packets; | 1048 | isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) * |
1049 | uurb->number_of_packets; | ||
1005 | if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL))) | 1050 | if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL))) |
1006 | return -ENOMEM; | 1051 | return -ENOMEM; |
1007 | if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) { | 1052 | if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) { |
@@ -1009,7 +1054,8 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1009 | return -EFAULT; | 1054 | return -EFAULT; |
1010 | } | 1055 | } |
1011 | for (totlen = u = 0; u < uurb->number_of_packets; u++) { | 1056 | for (totlen = u = 0; u < uurb->number_of_packets; u++) { |
1012 | /* arbitrary limit, sufficient for USB 2.0 high-bandwidth iso */ | 1057 | /* arbitrary limit, |
1058 | * sufficient for USB 2.0 high-bandwidth iso */ | ||
1013 | if (isopkt[u].length > 8192) { | 1059 | if (isopkt[u].length > 8192) { |
1014 | kfree(isopkt); | 1060 | kfree(isopkt); |
1015 | return -EINVAL; | 1061 | return -EINVAL; |
@@ -1039,25 +1085,27 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1039 | default: | 1085 | default: |
1040 | return -EINVAL; | 1086 | return -EINVAL; |
1041 | } | 1087 | } |
1042 | if (!(as = alloc_async(uurb->number_of_packets))) { | 1088 | as = alloc_async(uurb->number_of_packets); |
1089 | if (!as) { | ||
1043 | kfree(isopkt); | 1090 | kfree(isopkt); |
1044 | kfree(dr); | 1091 | kfree(dr); |
1045 | return -ENOMEM; | 1092 | return -ENOMEM; |
1046 | } | 1093 | } |
1047 | if (!(as->urb->transfer_buffer = kmalloc(uurb->buffer_length, GFP_KERNEL))) { | 1094 | as->urb->transfer_buffer = kmalloc(uurb->buffer_length, GFP_KERNEL); |
1095 | if (!as->urb->transfer_buffer) { | ||
1048 | kfree(isopkt); | 1096 | kfree(isopkt); |
1049 | kfree(dr); | 1097 | kfree(dr); |
1050 | free_async(as); | 1098 | free_async(as); |
1051 | return -ENOMEM; | 1099 | return -ENOMEM; |
1052 | } | 1100 | } |
1053 | as->urb->dev = ps->dev; | 1101 | as->urb->dev = ps->dev; |
1054 | as->urb->pipe = (uurb->type << 30) | | 1102 | as->urb->pipe = (uurb->type << 30) | |
1055 | __create_pipe(ps->dev, uurb->endpoint & 0xf) | | 1103 | __create_pipe(ps->dev, uurb->endpoint & 0xf) | |
1056 | (uurb->endpoint & USB_DIR_IN); | 1104 | (uurb->endpoint & USB_DIR_IN); |
1057 | as->urb->transfer_flags = uurb->flags | | 1105 | as->urb->transfer_flags = uurb->flags | |
1058 | (is_in ? URB_DIR_IN : URB_DIR_OUT); | 1106 | (is_in ? URB_DIR_IN : URB_DIR_OUT); |
1059 | as->urb->transfer_buffer_length = uurb->buffer_length; | 1107 | as->urb->transfer_buffer_length = uurb->buffer_length; |
1060 | as->urb->setup_packet = (unsigned char*)dr; | 1108 | as->urb->setup_packet = (unsigned char *)dr; |
1061 | as->urb->start_frame = uurb->start_frame; | 1109 | as->urb->start_frame = uurb->start_frame; |
1062 | as->urb->number_of_packets = uurb->number_of_packets; | 1110 | as->urb->number_of_packets = uurb->number_of_packets; |
1063 | if (uurb->type == USBDEVFS_URB_TYPE_ISO || | 1111 | if (uurb->type == USBDEVFS_URB_TYPE_ISO || |
@@ -1065,8 +1113,8 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1065 | as->urb->interval = 1 << min(15, ep->desc.bInterval - 1); | 1113 | as->urb->interval = 1 << min(15, ep->desc.bInterval - 1); |
1066 | else | 1114 | else |
1067 | as->urb->interval = ep->desc.bInterval; | 1115 | as->urb->interval = ep->desc.bInterval; |
1068 | as->urb->context = as; | 1116 | as->urb->context = as; |
1069 | as->urb->complete = async_completed; | 1117 | as->urb->complete = async_completed; |
1070 | for (totlen = u = 0; u < uurb->number_of_packets; u++) { | 1118 | for (totlen = u = 0; u < uurb->number_of_packets; u++) { |
1071 | as->urb->iso_frame_desc[u].offset = totlen; | 1119 | as->urb->iso_frame_desc[u].offset = totlen; |
1072 | as->urb->iso_frame_desc[u].length = isopkt[u].length; | 1120 | as->urb->iso_frame_desc[u].length = isopkt[u].length; |
@@ -1074,7 +1122,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1074 | } | 1122 | } |
1075 | kfree(isopkt); | 1123 | kfree(isopkt); |
1076 | as->ps = ps; | 1124 | as->ps = ps; |
1077 | as->userurb = arg; | 1125 | as->userurb = arg; |
1078 | if (uurb->endpoint & USB_DIR_IN) | 1126 | if (uurb->endpoint & USB_DIR_IN) |
1079 | as->userbuffer = uurb->buffer; | 1127 | as->userbuffer = uurb->buffer; |
1080 | else | 1128 | else |
@@ -1093,14 +1141,15 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1093 | } | 1141 | } |
1094 | } | 1142 | } |
1095 | snoop_urb(as->urb, as->userurb); | 1143 | snoop_urb(as->urb, as->userurb); |
1096 | async_newpending(as); | 1144 | async_newpending(as); |
1097 | if ((ret = usb_submit_urb(as->urb, GFP_KERNEL))) { | 1145 | if ((ret = usb_submit_urb(as->urb, GFP_KERNEL))) { |
1098 | dev_printk(KERN_DEBUG, &ps->dev->dev, "usbfs: usb_submit_urb returned %d\n", ret); | 1146 | dev_printk(KERN_DEBUG, &ps->dev->dev, |
1099 | async_removepending(as); | 1147 | "usbfs: usb_submit_urb returned %d\n", ret); |
1100 | free_async(as); | 1148 | async_removepending(as); |
1101 | return ret; | 1149 | free_async(as); |
1102 | } | 1150 | return ret; |
1103 | return 0; | 1151 | } |
1152 | return 0; | ||
1104 | } | 1153 | } |
1105 | 1154 | ||
1106 | static int proc_submiturb(struct dev_state *ps, void __user *arg) | 1155 | static int proc_submiturb(struct dev_state *ps, void __user *arg) |
@@ -1110,7 +1159,9 @@ static int proc_submiturb(struct dev_state *ps, void __user *arg) | |||
1110 | if (copy_from_user(&uurb, arg, sizeof(uurb))) | 1159 | if (copy_from_user(&uurb, arg, sizeof(uurb))) |
1111 | return -EFAULT; | 1160 | return -EFAULT; |
1112 | 1161 | ||
1113 | return proc_do_submiturb(ps, &uurb, (((struct usbdevfs_urb __user *)arg)->iso_frame_desc), arg); | 1162 | return proc_do_submiturb(ps, &uurb, |
1163 | (((struct usbdevfs_urb __user *)arg)->iso_frame_desc), | ||
1164 | arg); | ||
1114 | } | 1165 | } |
1115 | 1166 | ||
1116 | static int proc_unlinkurb(struct dev_state *ps, void __user *arg) | 1167 | static int proc_unlinkurb(struct dev_state *ps, void __user *arg) |
@@ -1132,7 +1183,8 @@ static int processcompl(struct async *as, void __user * __user *arg) | |||
1132 | unsigned int i; | 1183 | unsigned int i; |
1133 | 1184 | ||
1134 | if (as->userbuffer) | 1185 | if (as->userbuffer) |
1135 | if (copy_to_user(as->userbuffer, urb->transfer_buffer, urb->transfer_buffer_length)) | 1186 | if (copy_to_user(as->userbuffer, urb->transfer_buffer, |
1187 | urb->transfer_buffer_length)) | ||
1136 | return -EFAULT; | 1188 | return -EFAULT; |
1137 | if (put_user(as->status, &userurb->status)) | 1189 | if (put_user(as->status, &userurb->status)) |
1138 | return -EFAULT; | 1190 | return -EFAULT; |
@@ -1159,16 +1211,17 @@ static int processcompl(struct async *as, void __user * __user *arg) | |||
1159 | return 0; | 1211 | return 0; |
1160 | } | 1212 | } |
1161 | 1213 | ||
1162 | static struct async* reap_as(struct dev_state *ps) | 1214 | static struct async *reap_as(struct dev_state *ps) |
1163 | { | 1215 | { |
1164 | DECLARE_WAITQUEUE(wait, current); | 1216 | DECLARE_WAITQUEUE(wait, current); |
1165 | struct async *as = NULL; | 1217 | struct async *as = NULL; |
1166 | struct usb_device *dev = ps->dev; | 1218 | struct usb_device *dev = ps->dev; |
1167 | 1219 | ||
1168 | add_wait_queue(&ps->wait, &wait); | 1220 | add_wait_queue(&ps->wait, &wait); |
1169 | for (;;) { | 1221 | for (;;) { |
1170 | __set_current_state(TASK_INTERRUPTIBLE); | 1222 | __set_current_state(TASK_INTERRUPTIBLE); |
1171 | if ((as = async_getcompleted(ps))) | 1223 | as = async_getcompleted(ps); |
1224 | if (as) | ||
1172 | break; | 1225 | break; |
1173 | if (signal_pending(current)) | 1226 | if (signal_pending(current)) |
1174 | break; | 1227 | break; |
@@ -1232,10 +1285,12 @@ static int proc_submiturb_compat(struct dev_state *ps, void __user *arg) | |||
1232 | { | 1285 | { |
1233 | struct usbdevfs_urb uurb; | 1286 | struct usbdevfs_urb uurb; |
1234 | 1287 | ||
1235 | if (get_urb32(&uurb,(struct usbdevfs_urb32 __user *)arg)) | 1288 | if (get_urb32(&uurb, (struct usbdevfs_urb32 __user *)arg)) |
1236 | return -EFAULT; | 1289 | return -EFAULT; |
1237 | 1290 | ||
1238 | return proc_do_submiturb(ps, &uurb, ((struct usbdevfs_urb32 __user *)arg)->iso_frame_desc, arg); | 1291 | return proc_do_submiturb(ps, &uurb, |
1292 | ((struct usbdevfs_urb32 __user *)arg)->iso_frame_desc, | ||
1293 | arg); | ||
1239 | } | 1294 | } |
1240 | 1295 | ||
1241 | static int processcompl_compat(struct async *as, void __user * __user *arg) | 1296 | static int processcompl_compat(struct async *as, void __user * __user *arg) |
@@ -1246,7 +1301,8 @@ static int processcompl_compat(struct async *as, void __user * __user *arg) | |||
1246 | unsigned int i; | 1301 | unsigned int i; |
1247 | 1302 | ||
1248 | if (as->userbuffer) | 1303 | if (as->userbuffer) |
1249 | if (copy_to_user(as->userbuffer, urb->transfer_buffer, urb->transfer_buffer_length)) | 1304 | if (copy_to_user(as->userbuffer, urb->transfer_buffer, |
1305 | urb->transfer_buffer_length)) | ||
1250 | return -EFAULT; | 1306 | return -EFAULT; |
1251 | if (put_user(as->status, &userurb->status)) | 1307 | if (put_user(as->status, &userurb->status)) |
1252 | return -EFAULT; | 1308 | return -EFAULT; |
@@ -1337,16 +1393,16 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) | |||
1337 | struct usb_driver *driver = NULL; | 1393 | struct usb_driver *driver = NULL; |
1338 | 1394 | ||
1339 | /* alloc buffer */ | 1395 | /* alloc buffer */ |
1340 | if ((size = _IOC_SIZE (ctl->ioctl_code)) > 0) { | 1396 | if ((size = _IOC_SIZE(ctl->ioctl_code)) > 0) { |
1341 | if ((buf = kmalloc (size, GFP_KERNEL)) == NULL) | 1397 | if ((buf = kmalloc(size, GFP_KERNEL)) == NULL) |
1342 | return -ENOMEM; | 1398 | return -ENOMEM; |
1343 | if ((_IOC_DIR(ctl->ioctl_code) & _IOC_WRITE)) { | 1399 | if ((_IOC_DIR(ctl->ioctl_code) & _IOC_WRITE)) { |
1344 | if (copy_from_user (buf, ctl->data, size)) { | 1400 | if (copy_from_user(buf, ctl->data, size)) { |
1345 | kfree(buf); | 1401 | kfree(buf); |
1346 | return -EFAULT; | 1402 | return -EFAULT; |
1347 | } | 1403 | } |
1348 | } else { | 1404 | } else { |
1349 | memset (buf, 0, size); | 1405 | memset(buf, 0, size); |
1350 | } | 1406 | } |
1351 | } | 1407 | } |
1352 | 1408 | ||
@@ -1357,15 +1413,15 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) | |||
1357 | 1413 | ||
1358 | if (ps->dev->state != USB_STATE_CONFIGURED) | 1414 | if (ps->dev->state != USB_STATE_CONFIGURED) |
1359 | retval = -EHOSTUNREACH; | 1415 | retval = -EHOSTUNREACH; |
1360 | else if (!(intf = usb_ifnum_to_if (ps->dev, ctl->ifno))) | 1416 | else if (!(intf = usb_ifnum_to_if(ps->dev, ctl->ifno))) |
1361 | retval = -EINVAL; | 1417 | retval = -EINVAL; |
1362 | else switch (ctl->ioctl_code) { | 1418 | else switch (ctl->ioctl_code) { |
1363 | 1419 | ||
1364 | /* disconnect kernel driver from interface */ | 1420 | /* disconnect kernel driver from interface */ |
1365 | case USBDEVFS_DISCONNECT: | 1421 | case USBDEVFS_DISCONNECT: |
1366 | if (intf->dev.driver) { | 1422 | if (intf->dev.driver) { |
1367 | driver = to_usb_driver(intf->dev.driver); | 1423 | driver = to_usb_driver(intf->dev.driver); |
1368 | dev_dbg (&intf->dev, "disconnect by usbfs\n"); | 1424 | dev_dbg(&intf->dev, "disconnect by usbfs\n"); |
1369 | usb_driver_release_interface(driver, intf); | 1425 | usb_driver_release_interface(driver, intf); |
1370 | } else | 1426 | } else |
1371 | retval = -ENODATA; | 1427 | retval = -ENODATA; |
@@ -1373,9 +1429,10 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) | |||
1373 | 1429 | ||
1374 | /* let kernel drivers try to (re)bind to the interface */ | 1430 | /* let kernel drivers try to (re)bind to the interface */ |
1375 | case USBDEVFS_CONNECT: | 1431 | case USBDEVFS_CONNECT: |
1376 | usb_unlock_device(ps->dev); | 1432 | if (!intf->dev.driver) |
1377 | retval = bus_rescan_devices(intf->dev.bus); | 1433 | retval = device_attach(&intf->dev); |
1378 | usb_lock_device(ps->dev); | 1434 | else |
1435 | retval = -EBUSY; | ||
1379 | break; | 1436 | break; |
1380 | 1437 | ||
1381 | /* talk directly to the interface's driver */ | 1438 | /* talk directly to the interface's driver */ |
@@ -1385,7 +1442,7 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) | |||
1385 | if (driver == NULL || driver->ioctl == NULL) { | 1442 | if (driver == NULL || driver->ioctl == NULL) { |
1386 | retval = -ENOTTY; | 1443 | retval = -ENOTTY; |
1387 | } else { | 1444 | } else { |
1388 | retval = driver->ioctl (intf, ctl->ioctl_code, buf); | 1445 | retval = driver->ioctl(intf, ctl->ioctl_code, buf); |
1389 | if (retval == -ENOIOCTLCMD) | 1446 | if (retval == -ENOIOCTLCMD) |
1390 | retval = -ENOTTY; | 1447 | retval = -ENOTTY; |
1391 | } | 1448 | } |
@@ -1393,9 +1450,9 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) | |||
1393 | 1450 | ||
1394 | /* cleanup and return */ | 1451 | /* cleanup and return */ |
1395 | if (retval >= 0 | 1452 | if (retval >= 0 |
1396 | && (_IOC_DIR (ctl->ioctl_code) & _IOC_READ) != 0 | 1453 | && (_IOC_DIR(ctl->ioctl_code) & _IOC_READ) != 0 |
1397 | && size > 0 | 1454 | && size > 0 |
1398 | && copy_to_user (ctl->data, buf, size) != 0) | 1455 | && copy_to_user(ctl->data, buf, size) != 0) |
1399 | retval = -EFAULT; | 1456 | retval = -EFAULT; |
1400 | 1457 | ||
1401 | kfree(buf); | 1458 | kfree(buf); |
@@ -1406,7 +1463,7 @@ static int proc_ioctl_default(struct dev_state *ps, void __user *arg) | |||
1406 | { | 1463 | { |
1407 | struct usbdevfs_ioctl ctrl; | 1464 | struct usbdevfs_ioctl ctrl; |
1408 | 1465 | ||
1409 | if (copy_from_user(&ctrl, arg, sizeof (ctrl))) | 1466 | if (copy_from_user(&ctrl, arg, sizeof(ctrl))) |
1410 | return -EFAULT; | 1467 | return -EFAULT; |
1411 | return proc_ioctl(ps, &ctrl); | 1468 | return proc_ioctl(ps, &ctrl); |
1412 | } | 1469 | } |
@@ -1434,7 +1491,8 @@ static int proc_ioctl_compat(struct dev_state *ps, compat_uptr_t arg) | |||
1434 | * are assuming that somehow the configuration has been prevented from | 1491 | * are assuming that somehow the configuration has been prevented from |
1435 | * changing. But there's no mechanism to ensure that... | 1492 | * changing. But there's no mechanism to ensure that... |
1436 | */ | 1493 | */ |
1437 | static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | 1494 | static int usbdev_ioctl(struct inode *inode, struct file *file, |
1495 | unsigned int cmd, unsigned long arg) | ||
1438 | { | 1496 | { |
1439 | struct dev_state *ps = file->private_data; | 1497 | struct dev_state *ps = file->private_data; |
1440 | struct usb_device *dev = ps->dev; | 1498 | struct usb_device *dev = ps->dev; |
@@ -1577,7 +1635,8 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
1577 | } | 1635 | } |
1578 | 1636 | ||
1579 | /* No kernel lock - fine */ | 1637 | /* No kernel lock - fine */ |
1580 | static unsigned int usbdev_poll(struct file *file, struct poll_table_struct *wait) | 1638 | static unsigned int usbdev_poll(struct file *file, |
1639 | struct poll_table_struct *wait) | ||
1581 | { | 1640 | { |
1582 | struct dev_state *ps = file->private_data; | 1641 | struct dev_state *ps = file->private_data; |
1583 | unsigned int mask = 0; | 1642 | unsigned int mask = 0; |
@@ -1648,7 +1707,7 @@ int __init usb_devio_init(void) | |||
1648 | int retval; | 1707 | int retval; |
1649 | 1708 | ||
1650 | retval = register_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX, | 1709 | retval = register_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX, |
1651 | "usb_device"); | 1710 | "usb_device"); |
1652 | if (retval) { | 1711 | if (retval) { |
1653 | err("unable to register minors for usb_device"); | 1712 | err("unable to register minors for usb_device"); |
1654 | goto out; | 1713 | goto out; |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 7c3aaa9c5402..801b6f142fa7 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -202,10 +202,10 @@ static int usb_probe_interface(struct device *dev) | |||
202 | intf = to_usb_interface(dev); | 202 | intf = to_usb_interface(dev); |
203 | udev = interface_to_usbdev(intf); | 203 | udev = interface_to_usbdev(intf); |
204 | 204 | ||
205 | if (udev->authorized == 0) { | 205 | if (udev->authorized == 0) { |
206 | dev_err(&intf->dev, "Device is not authorized for usage\n"); | 206 | dev_err(&intf->dev, "Device is not authorized for usage\n"); |
207 | return -ENODEV; | 207 | return -ENODEV; |
208 | } | 208 | } |
209 | 209 | ||
210 | id = usb_match_id(intf, driver->id_table); | 210 | id = usb_match_id(intf, driver->id_table); |
211 | if (!id) | 211 | if (!id) |
@@ -299,7 +299,7 @@ static int usb_unbind_interface(struct device *dev) | |||
299 | * lock. | 299 | * lock. |
300 | */ | 300 | */ |
301 | int usb_driver_claim_interface(struct usb_driver *driver, | 301 | int usb_driver_claim_interface(struct usb_driver *driver, |
302 | struct usb_interface *iface, void* priv) | 302 | struct usb_interface *iface, void *priv) |
303 | { | 303 | { |
304 | struct device *dev = &iface->dev; | 304 | struct device *dev = &iface->dev; |
305 | struct usb_device *udev = interface_to_usbdev(iface); | 305 | struct usb_device *udev = interface_to_usbdev(iface); |
@@ -325,7 +325,7 @@ int usb_driver_claim_interface(struct usb_driver *driver, | |||
325 | 325 | ||
326 | return retval; | 326 | return retval; |
327 | } | 327 | } |
328 | EXPORT_SYMBOL(usb_driver_claim_interface); | 328 | EXPORT_SYMBOL_GPL(usb_driver_claim_interface); |
329 | 329 | ||
330 | /** | 330 | /** |
331 | * usb_driver_release_interface - unbind a driver from an interface | 331 | * usb_driver_release_interface - unbind a driver from an interface |
@@ -370,7 +370,7 @@ void usb_driver_release_interface(struct usb_driver *driver, | |||
370 | iface->needs_remote_wakeup = 0; | 370 | iface->needs_remote_wakeup = 0; |
371 | usb_pm_unlock(udev); | 371 | usb_pm_unlock(udev); |
372 | } | 372 | } |
373 | EXPORT_SYMBOL(usb_driver_release_interface); | 373 | EXPORT_SYMBOL_GPL(usb_driver_release_interface); |
374 | 374 | ||
375 | /* returns 0 if no match, 1 if match */ | 375 | /* returns 0 if no match, 1 if match */ |
376 | int usb_match_device(struct usb_device *dev, const struct usb_device_id *id) | 376 | int usb_match_device(struct usb_device *dev, const struct usb_device_id *id) |
@@ -398,7 +398,7 @@ int usb_match_device(struct usb_device *dev, const struct usb_device_id *id) | |||
398 | return 0; | 398 | return 0; |
399 | 399 | ||
400 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && | 400 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && |
401 | (id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass)) | 401 | (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass)) |
402 | return 0; | 402 | return 0; |
403 | 403 | ||
404 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && | 404 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && |
@@ -534,15 +534,15 @@ const struct usb_device_id *usb_match_id(struct usb_interface *interface, | |||
534 | id->driver_info is the way to create an entry that | 534 | id->driver_info is the way to create an entry that |
535 | indicates that the driver want to examine every | 535 | indicates that the driver want to examine every |
536 | device and interface. */ | 536 | device and interface. */ |
537 | for (; id->idVendor || id->bDeviceClass || id->bInterfaceClass || | 537 | for (; id->idVendor || id->idProduct || id->bDeviceClass || |
538 | id->driver_info; id++) { | 538 | id->bInterfaceClass || id->driver_info; id++) { |
539 | if (usb_match_one_id(interface, id)) | 539 | if (usb_match_one_id(interface, id)) |
540 | return id; | 540 | return id; |
541 | } | 541 | } |
542 | 542 | ||
543 | return NULL; | 543 | return NULL; |
544 | } | 544 | } |
545 | EXPORT_SYMBOL_GPL_FUTURE(usb_match_id); | 545 | EXPORT_SYMBOL_GPL(usb_match_id); |
546 | 546 | ||
547 | static int usb_device_match(struct device *dev, struct device_driver *drv) | 547 | static int usb_device_match(struct device *dev, struct device_driver *drv) |
548 | { | 548 | { |
@@ -586,7 +586,7 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
586 | struct usb_device *usb_dev; | 586 | struct usb_device *usb_dev; |
587 | 587 | ||
588 | /* driver is often null here; dev_dbg() would oops */ | 588 | /* driver is often null here; dev_dbg() would oops */ |
589 | pr_debug ("usb %s: uevent\n", dev->bus_id); | 589 | pr_debug("usb %s: uevent\n", dev->bus_id); |
590 | 590 | ||
591 | if (is_usb_device(dev)) | 591 | if (is_usb_device(dev)) |
592 | usb_dev = to_usb_device(dev); | 592 | usb_dev = to_usb_device(dev); |
@@ -596,11 +596,11 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
596 | } | 596 | } |
597 | 597 | ||
598 | if (usb_dev->devnum < 0) { | 598 | if (usb_dev->devnum < 0) { |
599 | pr_debug ("usb %s: already deleted?\n", dev->bus_id); | 599 | pr_debug("usb %s: already deleted?\n", dev->bus_id); |
600 | return -ENODEV; | 600 | return -ENODEV; |
601 | } | 601 | } |
602 | if (!usb_dev->bus) { | 602 | if (!usb_dev->bus) { |
603 | pr_debug ("usb %s: bus removed?\n", dev->bus_id); | 603 | pr_debug("usb %s: bus removed?\n", dev->bus_id); |
604 | return -ENODEV; | 604 | return -ENODEV; |
605 | } | 605 | } |
606 | 606 | ||
@@ -745,7 +745,7 @@ int usb_register_driver(struct usb_driver *new_driver, struct module *owner, | |||
745 | 745 | ||
746 | return retval; | 746 | return retval; |
747 | } | 747 | } |
748 | EXPORT_SYMBOL_GPL_FUTURE(usb_register_driver); | 748 | EXPORT_SYMBOL_GPL(usb_register_driver); |
749 | 749 | ||
750 | /** | 750 | /** |
751 | * usb_deregister - unregister a USB interface driver | 751 | * usb_deregister - unregister a USB interface driver |
@@ -769,7 +769,7 @@ void usb_deregister(struct usb_driver *driver) | |||
769 | 769 | ||
770 | usbfs_update_special(); | 770 | usbfs_update_special(); |
771 | } | 771 | } |
772 | EXPORT_SYMBOL_GPL_FUTURE(usb_deregister); | 772 | EXPORT_SYMBOL_GPL(usb_deregister); |
773 | 773 | ||
774 | #ifdef CONFIG_PM | 774 | #ifdef CONFIG_PM |
775 | 775 | ||
@@ -854,8 +854,10 @@ static int usb_suspend_interface(struct usb_interface *intf, pm_message_t msg) | |||
854 | dev_err(&intf->dev, "%s error %d\n", | 854 | dev_err(&intf->dev, "%s error %d\n", |
855 | "suspend", status); | 855 | "suspend", status); |
856 | } else { | 856 | } else { |
857 | // FIXME else if there's no suspend method, disconnect... | 857 | /* |
858 | // Not possible if auto_pm is set... | 858 | * FIXME else if there's no suspend method, disconnect... |
859 | * Not possible if auto_pm is set... | ||
860 | */ | ||
859 | dev_warn(&intf->dev, "no suspend for driver %s?\n", | 861 | dev_warn(&intf->dev, "no suspend for driver %s?\n", |
860 | driver->name); | 862 | driver->name); |
861 | mark_quiesced(intf); | 863 | mark_quiesced(intf); |
@@ -894,7 +896,7 @@ static int usb_resume_interface(struct usb_interface *intf, int reset_resume) | |||
894 | dev_err(&intf->dev, "%s error %d\n", | 896 | dev_err(&intf->dev, "%s error %d\n", |
895 | "reset_resume", status); | 897 | "reset_resume", status); |
896 | } else { | 898 | } else { |
897 | // status = -EOPNOTSUPP; | 899 | /* status = -EOPNOTSUPP; */ |
898 | dev_warn(&intf->dev, "no %s for driver %s?\n", | 900 | dev_warn(&intf->dev, "no %s for driver %s?\n", |
899 | "reset_resume", driver->name); | 901 | "reset_resume", driver->name); |
900 | } | 902 | } |
@@ -905,7 +907,7 @@ static int usb_resume_interface(struct usb_interface *intf, int reset_resume) | |||
905 | dev_err(&intf->dev, "%s error %d\n", | 907 | dev_err(&intf->dev, "%s error %d\n", |
906 | "resume", status); | 908 | "resume", status); |
907 | } else { | 909 | } else { |
908 | // status = -EOPNOTSUPP; | 910 | /* status = -EOPNOTSUPP; */ |
909 | dev_warn(&intf->dev, "no %s for driver %s?\n", | 911 | dev_warn(&intf->dev, "no %s for driver %s?\n", |
910 | "resume", driver->name); | 912 | "resume", driver->name); |
911 | } | 913 | } |
@@ -1175,7 +1177,7 @@ static int usb_resume_both(struct usb_device *udev) | |||
1175 | * so if a root hub's controller is suspended | 1177 | * so if a root hub's controller is suspended |
1176 | * then we're stuck. */ | 1178 | * then we're stuck. */ |
1177 | status = usb_resume_device(udev); | 1179 | status = usb_resume_device(udev); |
1178 | } | 1180 | } |
1179 | } else { | 1181 | } else { |
1180 | 1182 | ||
1181 | /* Needed for setting udev->dev.power.power_state.event, | 1183 | /* Needed for setting udev->dev.power.power_state.event, |
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 5d860bc9b421..8133c99c6c5c 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c | |||
@@ -204,7 +204,7 @@ int usb_register_dev(struct usb_interface *intf, | |||
204 | exit: | 204 | exit: |
205 | return retval; | 205 | return retval; |
206 | } | 206 | } |
207 | EXPORT_SYMBOL(usb_register_dev); | 207 | EXPORT_SYMBOL_GPL(usb_register_dev); |
208 | 208 | ||
209 | /** | 209 | /** |
210 | * usb_deregister_dev - deregister a USB device's dynamic minor. | 210 | * usb_deregister_dev - deregister a USB device's dynamic minor. |
@@ -245,4 +245,4 @@ void usb_deregister_dev(struct usb_interface *intf, | |||
245 | intf->minor = -1; | 245 | intf->minor = -1; |
246 | destroy_usb_class(); | 246 | destroy_usb_class(); |
247 | } | 247 | } |
248 | EXPORT_SYMBOL(usb_deregister_dev); | 248 | EXPORT_SYMBOL_GPL(usb_deregister_dev); |
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 3fb9af80cbf4..84760ddbc332 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * (C) Copyright David Brownell 2000-2002 | 2 | * (C) Copyright David Brownell 2000-2002 |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms of the GNU General Public License as published by the | 5 | * under the terms of the GNU General Public License as published by the |
6 | * Free Software Foundation; either version 2 of the License, or (at your | 6 | * Free Software Foundation; either version 2 of the License, or (at your |
@@ -55,7 +55,7 @@ | |||
55 | * | 55 | * |
56 | * Store this function in the HCD's struct pci_driver as probe(). | 56 | * Store this function in the HCD's struct pci_driver as probe(). |
57 | */ | 57 | */ |
58 | int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) | 58 | int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) |
59 | { | 59 | { |
60 | struct hc_driver *driver; | 60 | struct hc_driver *driver; |
61 | struct usb_hcd *hcd; | 61 | struct usb_hcd *hcd; |
@@ -64,66 +64,71 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) | |||
64 | if (usb_disabled()) | 64 | if (usb_disabled()) |
65 | return -ENODEV; | 65 | return -ENODEV; |
66 | 66 | ||
67 | if (!id || !(driver = (struct hc_driver *) id->driver_data)) | 67 | if (!id) |
68 | return -EINVAL; | ||
69 | driver = (struct hc_driver *)id->driver_data; | ||
70 | if (!driver) | ||
68 | return -EINVAL; | 71 | return -EINVAL; |
69 | 72 | ||
70 | if (pci_enable_device (dev) < 0) | 73 | if (pci_enable_device(dev) < 0) |
71 | return -ENODEV; | 74 | return -ENODEV; |
72 | dev->current_state = PCI_D0; | 75 | dev->current_state = PCI_D0; |
73 | dev->dev.power.power_state = PMSG_ON; | 76 | dev->dev.power.power_state = PMSG_ON; |
74 | 77 | ||
75 | if (!dev->irq) { | 78 | if (!dev->irq) { |
76 | dev_err (&dev->dev, | 79 | dev_err(&dev->dev, |
77 | "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", | 80 | "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", |
78 | pci_name(dev)); | 81 | pci_name(dev)); |
79 | retval = -ENODEV; | 82 | retval = -ENODEV; |
80 | goto err1; | 83 | goto err1; |
81 | } | 84 | } |
82 | 85 | ||
83 | hcd = usb_create_hcd (driver, &dev->dev, pci_name(dev)); | 86 | hcd = usb_create_hcd(driver, &dev->dev, pci_name(dev)); |
84 | if (!hcd) { | 87 | if (!hcd) { |
85 | retval = -ENOMEM; | 88 | retval = -ENOMEM; |
86 | goto err1; | 89 | goto err1; |
87 | } | 90 | } |
88 | 91 | ||
89 | if (driver->flags & HCD_MEMORY) { // EHCI, OHCI | 92 | if (driver->flags & HCD_MEMORY) { |
90 | hcd->rsrc_start = pci_resource_start (dev, 0); | 93 | /* EHCI, OHCI */ |
91 | hcd->rsrc_len = pci_resource_len (dev, 0); | 94 | hcd->rsrc_start = pci_resource_start(dev, 0); |
92 | if (!request_mem_region (hcd->rsrc_start, hcd->rsrc_len, | 95 | hcd->rsrc_len = pci_resource_len(dev, 0); |
96 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | ||
93 | driver->description)) { | 97 | driver->description)) { |
94 | dev_dbg (&dev->dev, "controller already in use\n"); | 98 | dev_dbg(&dev->dev, "controller already in use\n"); |
95 | retval = -EBUSY; | 99 | retval = -EBUSY; |
96 | goto err2; | 100 | goto err2; |
97 | } | 101 | } |
98 | hcd->regs = ioremap_nocache (hcd->rsrc_start, hcd->rsrc_len); | 102 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); |
99 | if (hcd->regs == NULL) { | 103 | if (hcd->regs == NULL) { |
100 | dev_dbg (&dev->dev, "error mapping memory\n"); | 104 | dev_dbg(&dev->dev, "error mapping memory\n"); |
101 | retval = -EFAULT; | 105 | retval = -EFAULT; |
102 | goto err3; | 106 | goto err3; |
103 | } | 107 | } |
104 | 108 | ||
105 | } else { // UHCI | 109 | } else { |
110 | /* UHCI */ | ||
106 | int region; | 111 | int region; |
107 | 112 | ||
108 | for (region = 0; region < PCI_ROM_RESOURCE; region++) { | 113 | for (region = 0; region < PCI_ROM_RESOURCE; region++) { |
109 | if (!(pci_resource_flags (dev, region) & | 114 | if (!(pci_resource_flags(dev, region) & |
110 | IORESOURCE_IO)) | 115 | IORESOURCE_IO)) |
111 | continue; | 116 | continue; |
112 | 117 | ||
113 | hcd->rsrc_start = pci_resource_start (dev, region); | 118 | hcd->rsrc_start = pci_resource_start(dev, region); |
114 | hcd->rsrc_len = pci_resource_len (dev, region); | 119 | hcd->rsrc_len = pci_resource_len(dev, region); |
115 | if (request_region (hcd->rsrc_start, hcd->rsrc_len, | 120 | if (request_region(hcd->rsrc_start, hcd->rsrc_len, |
116 | driver->description)) | 121 | driver->description)) |
117 | break; | 122 | break; |
118 | } | 123 | } |
119 | if (region == PCI_ROM_RESOURCE) { | 124 | if (region == PCI_ROM_RESOURCE) { |
120 | dev_dbg (&dev->dev, "no i/o regions available\n"); | 125 | dev_dbg(&dev->dev, "no i/o regions available\n"); |
121 | retval = -EBUSY; | 126 | retval = -EBUSY; |
122 | goto err1; | 127 | goto err1; |
123 | } | 128 | } |
124 | } | 129 | } |
125 | 130 | ||
126 | pci_set_master (dev); | 131 | pci_set_master(dev); |
127 | 132 | ||
128 | retval = usb_add_hcd(hcd, dev->irq, IRQF_DISABLED | IRQF_SHARED); | 133 | retval = usb_add_hcd(hcd, dev->irq, IRQF_DISABLED | IRQF_SHARED); |
129 | if (retval != 0) | 134 | if (retval != 0) |
@@ -132,19 +137,19 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) | |||
132 | 137 | ||
133 | err4: | 138 | err4: |
134 | if (driver->flags & HCD_MEMORY) { | 139 | if (driver->flags & HCD_MEMORY) { |
135 | iounmap (hcd->regs); | 140 | iounmap(hcd->regs); |
136 | err3: | 141 | err3: |
137 | release_mem_region (hcd->rsrc_start, hcd->rsrc_len); | 142 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
138 | } else | 143 | } else |
139 | release_region (hcd->rsrc_start, hcd->rsrc_len); | 144 | release_region(hcd->rsrc_start, hcd->rsrc_len); |
140 | err2: | 145 | err2: |
141 | usb_put_hcd (hcd); | 146 | usb_put_hcd(hcd); |
142 | err1: | 147 | err1: |
143 | pci_disable_device (dev); | 148 | pci_disable_device(dev); |
144 | dev_err (&dev->dev, "init %s fail, %d\n", pci_name(dev), retval); | 149 | dev_err(&dev->dev, "init %s fail, %d\n", pci_name(dev), retval); |
145 | return retval; | 150 | return retval; |
146 | } | 151 | } |
147 | EXPORT_SYMBOL (usb_hcd_pci_probe); | 152 | EXPORT_SYMBOL_GPL(usb_hcd_pci_probe); |
148 | 153 | ||
149 | 154 | ||
150 | /* may be called without controller electrically present */ | 155 | /* may be called without controller electrically present */ |
@@ -161,7 +166,7 @@ EXPORT_SYMBOL (usb_hcd_pci_probe); | |||
161 | * | 166 | * |
162 | * Store this function in the HCD's struct pci_driver as remove(). | 167 | * Store this function in the HCD's struct pci_driver as remove(). |
163 | */ | 168 | */ |
164 | void usb_hcd_pci_remove (struct pci_dev *dev) | 169 | void usb_hcd_pci_remove(struct pci_dev *dev) |
165 | { | 170 | { |
166 | struct usb_hcd *hcd; | 171 | struct usb_hcd *hcd; |
167 | 172 | ||
@@ -169,17 +174,17 @@ void usb_hcd_pci_remove (struct pci_dev *dev) | |||
169 | if (!hcd) | 174 | if (!hcd) |
170 | return; | 175 | return; |
171 | 176 | ||
172 | usb_remove_hcd (hcd); | 177 | usb_remove_hcd(hcd); |
173 | if (hcd->driver->flags & HCD_MEMORY) { | 178 | if (hcd->driver->flags & HCD_MEMORY) { |
174 | iounmap (hcd->regs); | 179 | iounmap(hcd->regs); |
175 | release_mem_region (hcd->rsrc_start, hcd->rsrc_len); | 180 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
176 | } else { | 181 | } else { |
177 | release_region (hcd->rsrc_start, hcd->rsrc_len); | 182 | release_region(hcd->rsrc_start, hcd->rsrc_len); |
178 | } | 183 | } |
179 | usb_put_hcd (hcd); | 184 | usb_put_hcd(hcd); |
180 | pci_disable_device(dev); | 185 | pci_disable_device(dev); |
181 | } | 186 | } |
182 | EXPORT_SYMBOL (usb_hcd_pci_remove); | 187 | EXPORT_SYMBOL_GPL(usb_hcd_pci_remove); |
183 | 188 | ||
184 | 189 | ||
185 | #ifdef CONFIG_PM | 190 | #ifdef CONFIG_PM |
@@ -191,7 +196,7 @@ EXPORT_SYMBOL (usb_hcd_pci_remove); | |||
191 | * | 196 | * |
192 | * Store this function in the HCD's struct pci_driver as suspend(). | 197 | * Store this function in the HCD's struct pci_driver as suspend(). |
193 | */ | 198 | */ |
194 | int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) | 199 | int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message) |
195 | { | 200 | { |
196 | struct usb_hcd *hcd; | 201 | struct usb_hcd *hcd; |
197 | int retval = 0; | 202 | int retval = 0; |
@@ -246,12 +251,18 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) | |||
246 | 251 | ||
247 | /* no DMA or IRQs except when HC is active */ | 252 | /* no DMA or IRQs except when HC is active */ |
248 | if (dev->current_state == PCI_D0) { | 253 | if (dev->current_state == PCI_D0) { |
249 | pci_save_state (dev); | 254 | pci_save_state(dev); |
250 | pci_disable_device (dev); | 255 | pci_disable_device(dev); |
256 | } | ||
257 | |||
258 | if (message.event == PM_EVENT_FREEZE || | ||
259 | message.event == PM_EVENT_PRETHAW) { | ||
260 | dev_dbg(hcd->self.controller, "--> no state change\n"); | ||
261 | goto done; | ||
251 | } | 262 | } |
252 | 263 | ||
253 | if (!has_pci_pm) { | 264 | if (!has_pci_pm) { |
254 | dev_dbg (hcd->self.controller, "--> PCI D0/legacy\n"); | 265 | dev_dbg(hcd->self.controller, "--> PCI D0/legacy\n"); |
255 | goto done; | 266 | goto done; |
256 | } | 267 | } |
257 | 268 | ||
@@ -260,30 +271,30 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) | |||
260 | * PCI_D3 (but not PCI_D1 or PCI_D2) is allowed to reset | 271 | * PCI_D3 (but not PCI_D1 or PCI_D2) is allowed to reset |
261 | * some device state (e.g. as part of clock reinit). | 272 | * some device state (e.g. as part of clock reinit). |
262 | */ | 273 | */ |
263 | retval = pci_set_power_state (dev, PCI_D3hot); | 274 | retval = pci_set_power_state(dev, PCI_D3hot); |
264 | suspend_report_result(pci_set_power_state, retval); | 275 | suspend_report_result(pci_set_power_state, retval); |
265 | if (retval == 0) { | 276 | if (retval == 0) { |
266 | int wake = device_can_wakeup(&hcd->self.root_hub->dev); | 277 | int wake = device_can_wakeup(&hcd->self.root_hub->dev); |
267 | 278 | ||
268 | wake = wake && device_may_wakeup(hcd->self.controller); | 279 | wake = wake && device_may_wakeup(hcd->self.controller); |
269 | 280 | ||
270 | dev_dbg (hcd->self.controller, "--> PCI D3%s\n", | 281 | dev_dbg(hcd->self.controller, "--> PCI D3%s\n", |
271 | wake ? "/wakeup" : ""); | 282 | wake ? "/wakeup" : ""); |
272 | 283 | ||
273 | /* Ignore these return values. We rely on pci code to | 284 | /* Ignore these return values. We rely on pci code to |
274 | * reject requests the hardware can't implement, rather | 285 | * reject requests the hardware can't implement, rather |
275 | * than coding the same thing. | 286 | * than coding the same thing. |
276 | */ | 287 | */ |
277 | (void) pci_enable_wake (dev, PCI_D3hot, wake); | 288 | (void) pci_enable_wake(dev, PCI_D3hot, wake); |
278 | (void) pci_enable_wake (dev, PCI_D3cold, wake); | 289 | (void) pci_enable_wake(dev, PCI_D3cold, wake); |
279 | } else { | 290 | } else { |
280 | dev_dbg (&dev->dev, "PCI D3 suspend fail, %d\n", | 291 | dev_dbg(&dev->dev, "PCI D3 suspend fail, %d\n", |
281 | retval); | 292 | retval); |
282 | (void) usb_hcd_pci_resume (dev); | 293 | (void) usb_hcd_pci_resume(dev); |
283 | } | 294 | } |
284 | 295 | ||
285 | } else if (hcd->state != HC_STATE_HALT) { | 296 | } else if (hcd->state != HC_STATE_HALT) { |
286 | dev_dbg (hcd->self.controller, "hcd state %d; not suspended\n", | 297 | dev_dbg(hcd->self.controller, "hcd state %d; not suspended\n", |
287 | hcd->state); | 298 | hcd->state); |
288 | WARN_ON(1); | 299 | WARN_ON(1); |
289 | retval = -EINVAL; | 300 | retval = -EINVAL; |
@@ -298,7 +309,7 @@ done: | |||
298 | if (machine_is(powermac)) { | 309 | if (machine_is(powermac)) { |
299 | struct device_node *of_node; | 310 | struct device_node *of_node; |
300 | 311 | ||
301 | of_node = pci_device_to_OF_node (dev); | 312 | of_node = pci_device_to_OF_node(dev); |
302 | if (of_node) | 313 | if (of_node) |
303 | pmac_call_feature(PMAC_FTR_USB_ENABLE, | 314 | pmac_call_feature(PMAC_FTR_USB_ENABLE, |
304 | of_node, 0, 0); | 315 | of_node, 0, 0); |
@@ -308,7 +319,7 @@ done: | |||
308 | 319 | ||
309 | return retval; | 320 | return retval; |
310 | } | 321 | } |
311 | EXPORT_SYMBOL (usb_hcd_pci_suspend); | 322 | EXPORT_SYMBOL_GPL(usb_hcd_pci_suspend); |
312 | 323 | ||
313 | /** | 324 | /** |
314 | * usb_hcd_pci_resume - power management resume of a PCI-based HCD | 325 | * usb_hcd_pci_resume - power management resume of a PCI-based HCD |
@@ -316,14 +327,14 @@ EXPORT_SYMBOL (usb_hcd_pci_suspend); | |||
316 | * | 327 | * |
317 | * Store this function in the HCD's struct pci_driver as resume(). | 328 | * Store this function in the HCD's struct pci_driver as resume(). |
318 | */ | 329 | */ |
319 | int usb_hcd_pci_resume (struct pci_dev *dev) | 330 | int usb_hcd_pci_resume(struct pci_dev *dev) |
320 | { | 331 | { |
321 | struct usb_hcd *hcd; | 332 | struct usb_hcd *hcd; |
322 | int retval; | 333 | int retval; |
323 | 334 | ||
324 | hcd = pci_get_drvdata(dev); | 335 | hcd = pci_get_drvdata(dev); |
325 | if (hcd->state != HC_STATE_SUSPENDED) { | 336 | if (hcd->state != HC_STATE_SUSPENDED) { |
326 | dev_dbg (hcd->self.controller, | 337 | dev_dbg(hcd->self.controller, |
327 | "can't resume, not suspended!\n"); | 338 | "can't resume, not suspended!\n"); |
328 | return 0; | 339 | return 0; |
329 | } | 340 | } |
@@ -333,9 +344,9 @@ int usb_hcd_pci_resume (struct pci_dev *dev) | |||
333 | if (machine_is(powermac)) { | 344 | if (machine_is(powermac)) { |
334 | struct device_node *of_node; | 345 | struct device_node *of_node; |
335 | 346 | ||
336 | of_node = pci_device_to_OF_node (dev); | 347 | of_node = pci_device_to_OF_node(dev); |
337 | if (of_node) | 348 | if (of_node) |
338 | pmac_call_feature (PMAC_FTR_USB_ENABLE, | 349 | pmac_call_feature(PMAC_FTR_USB_ENABLE, |
339 | of_node, 0, 1); | 350 | of_node, 0, 1); |
340 | } | 351 | } |
341 | #endif | 352 | #endif |
@@ -374,8 +385,8 @@ int usb_hcd_pci_resume (struct pci_dev *dev) | |||
374 | } | 385 | } |
375 | #endif | 386 | #endif |
376 | /* yes, ignore these results too... */ | 387 | /* yes, ignore these results too... */ |
377 | (void) pci_enable_wake (dev, dev->current_state, 0); | 388 | (void) pci_enable_wake(dev, dev->current_state, 0); |
378 | (void) pci_enable_wake (dev, PCI_D3cold, 0); | 389 | (void) pci_enable_wake(dev, PCI_D3cold, 0); |
379 | } else { | 390 | } else { |
380 | /* Same basic cases: clean (powered/not), dirty */ | 391 | /* Same basic cases: clean (powered/not), dirty */ |
381 | dev_dbg(hcd->self.controller, "PCI legacy resume\n"); | 392 | dev_dbg(hcd->self.controller, "PCI legacy resume\n"); |
@@ -386,14 +397,14 @@ int usb_hcd_pci_resume (struct pci_dev *dev) | |||
386 | * but that won't re-enable bus mastering. Yet pci_disable_device() | 397 | * but that won't re-enable bus mastering. Yet pci_disable_device() |
387 | * explicitly disables bus mastering... | 398 | * explicitly disables bus mastering... |
388 | */ | 399 | */ |
389 | retval = pci_enable_device (dev); | 400 | retval = pci_enable_device(dev); |
390 | if (retval < 0) { | 401 | if (retval < 0) { |
391 | dev_err (hcd->self.controller, | 402 | dev_err(hcd->self.controller, |
392 | "can't re-enable after resume, %d!\n", retval); | 403 | "can't re-enable after resume, %d!\n", retval); |
393 | return retval; | 404 | return retval; |
394 | } | 405 | } |
395 | pci_set_master (dev); | 406 | pci_set_master(dev); |
396 | pci_restore_state (dev); | 407 | pci_restore_state(dev); |
397 | 408 | ||
398 | dev->dev.power.power_state = PMSG_ON; | 409 | dev->dev.power.power_state = PMSG_ON; |
399 | 410 | ||
@@ -402,15 +413,15 @@ int usb_hcd_pci_resume (struct pci_dev *dev) | |||
402 | if (hcd->driver->resume) { | 413 | if (hcd->driver->resume) { |
403 | retval = hcd->driver->resume(hcd); | 414 | retval = hcd->driver->resume(hcd); |
404 | if (retval) { | 415 | if (retval) { |
405 | dev_err (hcd->self.controller, | 416 | dev_err(hcd->self.controller, |
406 | "PCI post-resume error %d!\n", retval); | 417 | "PCI post-resume error %d!\n", retval); |
407 | usb_hc_died (hcd); | 418 | usb_hc_died(hcd); |
408 | } | 419 | } |
409 | } | 420 | } |
410 | 421 | ||
411 | return retval; | 422 | return retval; |
412 | } | 423 | } |
413 | EXPORT_SYMBOL (usb_hcd_pci_resume); | 424 | EXPORT_SYMBOL_GPL(usb_hcd_pci_resume); |
414 | 425 | ||
415 | #endif /* CONFIG_PM */ | 426 | #endif /* CONFIG_PM */ |
416 | 427 | ||
@@ -418,7 +429,7 @@ EXPORT_SYMBOL (usb_hcd_pci_resume); | |||
418 | * usb_hcd_pci_shutdown - shutdown host controller | 429 | * usb_hcd_pci_shutdown - shutdown host controller |
419 | * @dev: USB Host Controller being shutdown | 430 | * @dev: USB Host Controller being shutdown |
420 | */ | 431 | */ |
421 | void usb_hcd_pci_shutdown (struct pci_dev *dev) | 432 | void usb_hcd_pci_shutdown(struct pci_dev *dev) |
422 | { | 433 | { |
423 | struct usb_hcd *hcd; | 434 | struct usb_hcd *hcd; |
424 | 435 | ||
@@ -429,5 +440,5 @@ void usb_hcd_pci_shutdown (struct pci_dev *dev) | |||
429 | if (hcd->driver->shutdown) | 440 | if (hcd->driver->shutdown) |
430 | hcd->driver->shutdown(hcd); | 441 | hcd->driver->shutdown(hcd); |
431 | } | 442 | } |
432 | EXPORT_SYMBOL (usb_hcd_pci_shutdown); | 443 | EXPORT_SYMBOL_GPL(usb_hcd_pci_shutdown); |
433 | 444 | ||
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index d5ed3fa9e304..e52ed1663b3c 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/mutex.h> | 35 | #include <linux/mutex.h> |
36 | #include <asm/irq.h> | 36 | #include <asm/irq.h> |
37 | #include <asm/byteorder.h> | 37 | #include <asm/byteorder.h> |
38 | #include <asm/unaligned.h> | ||
38 | #include <linux/platform_device.h> | 39 | #include <linux/platform_device.h> |
39 | #include <linux/workqueue.h> | 40 | #include <linux/workqueue.h> |
40 | 41 | ||
@@ -131,8 +132,8 @@ static const u8 usb2_rh_dev_descriptor [18] = { | |||
131 | 0x01, /* __u8 bDeviceProtocol; [ usb 2.0 single TT ]*/ | 132 | 0x01, /* __u8 bDeviceProtocol; [ usb 2.0 single TT ]*/ |
132 | 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */ | 133 | 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */ |
133 | 134 | ||
134 | 0x00, 0x00, /* __le16 idVendor; */ | 135 | 0x6b, 0x1d, /* __le16 idVendor; Linux Foundation */ |
135 | 0x00, 0x00, /* __le16 idProduct; */ | 136 | 0x02, 0x00, /* __le16 idProduct; device 0x0002 */ |
136 | KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */ | 137 | KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */ |
137 | 138 | ||
138 | 0x03, /* __u8 iManufacturer; */ | 139 | 0x03, /* __u8 iManufacturer; */ |
@@ -154,8 +155,8 @@ static const u8 usb11_rh_dev_descriptor [18] = { | |||
154 | 0x00, /* __u8 bDeviceProtocol; [ low/full speeds only ] */ | 155 | 0x00, /* __u8 bDeviceProtocol; [ low/full speeds only ] */ |
155 | 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */ | 156 | 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */ |
156 | 157 | ||
157 | 0x00, 0x00, /* __le16 idVendor; */ | 158 | 0x6b, 0x1d, /* __le16 idVendor; Linux Foundation */ |
158 | 0x00, 0x00, /* __le16 idProduct; */ | 159 | 0x01, 0x00, /* __le16 idProduct; device 0x0001 */ |
159 | KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */ | 160 | KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */ |
160 | 161 | ||
161 | 0x03, /* __u8 iManufacturer; */ | 162 | 0x03, /* __u8 iManufacturer; */ |
@@ -807,13 +808,13 @@ static int usb_register_bus(struct usb_bus *bus) | |||
807 | } | 808 | } |
808 | set_bit (busnum, busmap.busmap); | 809 | set_bit (busnum, busmap.busmap); |
809 | bus->busnum = busnum; | 810 | bus->busnum = busnum; |
810 | bus->class_dev = class_device_create(usb_host_class, NULL, MKDEV(0,0), | 811 | |
811 | bus->controller, "usb_host%d", | 812 | bus->dev = device_create(usb_host_class, bus->controller, MKDEV(0, 0), |
812 | busnum); | 813 | "usb_host%d", busnum); |
813 | result = PTR_ERR(bus->class_dev); | 814 | result = PTR_ERR(bus->dev); |
814 | if (IS_ERR(bus->class_dev)) | 815 | if (IS_ERR(bus->dev)) |
815 | goto error_create_class_dev; | 816 | goto error_create_class_dev; |
816 | class_set_devdata(bus->class_dev, bus); | 817 | dev_set_drvdata(bus->dev, bus); |
817 | 818 | ||
818 | /* Add it to the local list of buses */ | 819 | /* Add it to the local list of buses */ |
819 | list_add (&bus->bus_list, &usb_bus_list); | 820 | list_add (&bus->bus_list, &usb_bus_list); |
@@ -857,7 +858,7 @@ static void usb_deregister_bus (struct usb_bus *bus) | |||
857 | 858 | ||
858 | clear_bit (bus->busnum, busmap.busmap); | 859 | clear_bit (bus->busnum, busmap.busmap); |
859 | 860 | ||
860 | class_device_unregister(bus->class_dev); | 861 | device_unregister(bus->dev); |
861 | } | 862 | } |
862 | 863 | ||
863 | /** | 864 | /** |
@@ -970,7 +971,7 @@ long usb_calc_bus_time (int speed, int is_input, int isoc, int bytecount) | |||
970 | return -1; | 971 | return -1; |
971 | } | 972 | } |
972 | } | 973 | } |
973 | EXPORT_SYMBOL (usb_calc_bus_time); | 974 | EXPORT_SYMBOL_GPL(usb_calc_bus_time); |
974 | 975 | ||
975 | 976 | ||
976 | /*-------------------------------------------------------------------------*/ | 977 | /*-------------------------------------------------------------------------*/ |
@@ -1112,48 +1113,177 @@ void usb_hcd_unlink_urb_from_ep(struct usb_hcd *hcd, struct urb *urb) | |||
1112 | } | 1113 | } |
1113 | EXPORT_SYMBOL_GPL(usb_hcd_unlink_urb_from_ep); | 1114 | EXPORT_SYMBOL_GPL(usb_hcd_unlink_urb_from_ep); |
1114 | 1115 | ||
1115 | static void map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) | 1116 | /* |
1117 | * Some usb host controllers can only perform dma using a small SRAM area. | ||
1118 | * The usb core itself is however optimized for host controllers that can dma | ||
1119 | * using regular system memory - like pci devices doing bus mastering. | ||
1120 | * | ||
1121 | * To support host controllers with limited dma capabilites we provide dma | ||
1122 | * bounce buffers. This feature can be enabled using the HCD_LOCAL_MEM flag. | ||
1123 | * For this to work properly the host controller code must first use the | ||
1124 | * function dma_declare_coherent_memory() to point out which memory area | ||
1125 | * that should be used for dma allocations. | ||
1126 | * | ||
1127 | * The HCD_LOCAL_MEM flag then tells the usb code to allocate all data for | ||
1128 | * dma using dma_alloc_coherent() which in turn allocates from the memory | ||
1129 | * area pointed out with dma_declare_coherent_memory(). | ||
1130 | * | ||
1131 | * So, to summarize... | ||
1132 | * | ||
1133 | * - We need "local" memory, canonical example being | ||
1134 | * a small SRAM on a discrete controller being the | ||
1135 | * only memory that the controller can read ... | ||
1136 | * (a) "normal" kernel memory is no good, and | ||
1137 | * (b) there's not enough to share | ||
1138 | * | ||
1139 | * - The only *portable* hook for such stuff in the | ||
1140 | * DMA framework is dma_declare_coherent_memory() | ||
1141 | * | ||
1142 | * - So we use that, even though the primary requirement | ||
1143 | * is that the memory be "local" (hence addressible | ||
1144 | * by that device), not "coherent". | ||
1145 | * | ||
1146 | */ | ||
1147 | |||
1148 | static int hcd_alloc_coherent(struct usb_bus *bus, | ||
1149 | gfp_t mem_flags, dma_addr_t *dma_handle, | ||
1150 | void **vaddr_handle, size_t size, | ||
1151 | enum dma_data_direction dir) | ||
1152 | { | ||
1153 | unsigned char *vaddr; | ||
1154 | |||
1155 | vaddr = hcd_buffer_alloc(bus, size + sizeof(vaddr), | ||
1156 | mem_flags, dma_handle); | ||
1157 | if (!vaddr) | ||
1158 | return -ENOMEM; | ||
1159 | |||
1160 | /* | ||
1161 | * Store the virtual address of the buffer at the end | ||
1162 | * of the allocated dma buffer. The size of the buffer | ||
1163 | * may be uneven so use unaligned functions instead | ||
1164 | * of just rounding up. It makes sense to optimize for | ||
1165 | * memory footprint over access speed since the amount | ||
1166 | * of memory available for dma may be limited. | ||
1167 | */ | ||
1168 | put_unaligned((unsigned long)*vaddr_handle, | ||
1169 | (unsigned long *)(vaddr + size)); | ||
1170 | |||
1171 | if (dir == DMA_TO_DEVICE) | ||
1172 | memcpy(vaddr, *vaddr_handle, size); | ||
1173 | |||
1174 | *vaddr_handle = vaddr; | ||
1175 | return 0; | ||
1176 | } | ||
1177 | |||
1178 | static void hcd_free_coherent(struct usb_bus *bus, dma_addr_t *dma_handle, | ||
1179 | void **vaddr_handle, size_t size, | ||
1180 | enum dma_data_direction dir) | ||
1181 | { | ||
1182 | unsigned char *vaddr = *vaddr_handle; | ||
1183 | |||
1184 | vaddr = (void *)get_unaligned((unsigned long *)(vaddr + size)); | ||
1185 | |||
1186 | if (dir == DMA_FROM_DEVICE) | ||
1187 | memcpy(vaddr, *vaddr_handle, size); | ||
1188 | |||
1189 | hcd_buffer_free(bus, size + sizeof(vaddr), *vaddr_handle, *dma_handle); | ||
1190 | |||
1191 | *vaddr_handle = vaddr; | ||
1192 | *dma_handle = 0; | ||
1193 | } | ||
1194 | |||
1195 | static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, | ||
1196 | gfp_t mem_flags) | ||
1116 | { | 1197 | { |
1198 | enum dma_data_direction dir; | ||
1199 | int ret = 0; | ||
1200 | |||
1117 | /* Map the URB's buffers for DMA access. | 1201 | /* Map the URB's buffers for DMA access. |
1118 | * Lower level HCD code should use *_dma exclusively, | 1202 | * Lower level HCD code should use *_dma exclusively, |
1119 | * unless it uses pio or talks to another transport. | 1203 | * unless it uses pio or talks to another transport. |
1120 | */ | 1204 | */ |
1121 | if (hcd->self.uses_dma && !is_root_hub(urb->dev)) { | 1205 | if (is_root_hub(urb->dev)) |
1122 | if (usb_endpoint_xfer_control(&urb->ep->desc) | 1206 | return 0; |
1123 | && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) | 1207 | |
1124 | urb->setup_dma = dma_map_single ( | 1208 | if (usb_endpoint_xfer_control(&urb->ep->desc) |
1209 | && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) { | ||
1210 | if (hcd->self.uses_dma) | ||
1211 | urb->setup_dma = dma_map_single( | ||
1125 | hcd->self.controller, | 1212 | hcd->self.controller, |
1126 | urb->setup_packet, | 1213 | urb->setup_packet, |
1127 | sizeof (struct usb_ctrlrequest), | 1214 | sizeof(struct usb_ctrlrequest), |
1215 | DMA_TO_DEVICE); | ||
1216 | else if (hcd->driver->flags & HCD_LOCAL_MEM) | ||
1217 | ret = hcd_alloc_coherent( | ||
1218 | urb->dev->bus, mem_flags, | ||
1219 | &urb->setup_dma, | ||
1220 | (void **)&urb->setup_packet, | ||
1221 | sizeof(struct usb_ctrlrequest), | ||
1128 | DMA_TO_DEVICE); | 1222 | DMA_TO_DEVICE); |
1129 | if (urb->transfer_buffer_length != 0 | 1223 | } |
1130 | && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) | 1224 | |
1225 | dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; | ||
1226 | if (ret == 0 && urb->transfer_buffer_length != 0 | ||
1227 | && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) { | ||
1228 | if (hcd->self.uses_dma) | ||
1131 | urb->transfer_dma = dma_map_single ( | 1229 | urb->transfer_dma = dma_map_single ( |
1132 | hcd->self.controller, | 1230 | hcd->self.controller, |
1133 | urb->transfer_buffer, | 1231 | urb->transfer_buffer, |
1134 | urb->transfer_buffer_length, | 1232 | urb->transfer_buffer_length, |
1135 | usb_urb_dir_in(urb) | 1233 | dir); |
1136 | ? DMA_FROM_DEVICE | 1234 | else if (hcd->driver->flags & HCD_LOCAL_MEM) { |
1137 | : DMA_TO_DEVICE); | 1235 | ret = hcd_alloc_coherent( |
1236 | urb->dev->bus, mem_flags, | ||
1237 | &urb->transfer_dma, | ||
1238 | &urb->transfer_buffer, | ||
1239 | urb->transfer_buffer_length, | ||
1240 | dir); | ||
1241 | |||
1242 | if (ret && usb_endpoint_xfer_control(&urb->ep->desc) | ||
1243 | && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) | ||
1244 | hcd_free_coherent(urb->dev->bus, | ||
1245 | &urb->setup_dma, | ||
1246 | (void **)&urb->setup_packet, | ||
1247 | sizeof(struct usb_ctrlrequest), | ||
1248 | DMA_TO_DEVICE); | ||
1249 | } | ||
1138 | } | 1250 | } |
1251 | return ret; | ||
1139 | } | 1252 | } |
1140 | 1253 | ||
1141 | static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) | 1254 | static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) |
1142 | { | 1255 | { |
1143 | if (hcd->self.uses_dma && !is_root_hub(urb->dev)) { | 1256 | enum dma_data_direction dir; |
1144 | if (usb_endpoint_xfer_control(&urb->ep->desc) | 1257 | |
1145 | && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) | 1258 | if (is_root_hub(urb->dev)) |
1259 | return; | ||
1260 | |||
1261 | if (usb_endpoint_xfer_control(&urb->ep->desc) | ||
1262 | && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) { | ||
1263 | if (hcd->self.uses_dma) | ||
1146 | dma_unmap_single(hcd->self.controller, urb->setup_dma, | 1264 | dma_unmap_single(hcd->self.controller, urb->setup_dma, |
1147 | sizeof(struct usb_ctrlrequest), | 1265 | sizeof(struct usb_ctrlrequest), |
1148 | DMA_TO_DEVICE); | 1266 | DMA_TO_DEVICE); |
1149 | if (urb->transfer_buffer_length != 0 | 1267 | else if (hcd->driver->flags & HCD_LOCAL_MEM) |
1150 | && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) | 1268 | hcd_free_coherent(urb->dev->bus, &urb->setup_dma, |
1269 | (void **)&urb->setup_packet, | ||
1270 | sizeof(struct usb_ctrlrequest), | ||
1271 | DMA_TO_DEVICE); | ||
1272 | } | ||
1273 | |||
1274 | dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; | ||
1275 | if (urb->transfer_buffer_length != 0 | ||
1276 | && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) { | ||
1277 | if (hcd->self.uses_dma) | ||
1151 | dma_unmap_single(hcd->self.controller, | 1278 | dma_unmap_single(hcd->self.controller, |
1152 | urb->transfer_dma, | 1279 | urb->transfer_dma, |
1153 | urb->transfer_buffer_length, | 1280 | urb->transfer_buffer_length, |
1154 | usb_urb_dir_in(urb) | 1281 | dir); |
1155 | ? DMA_FROM_DEVICE | 1282 | else if (hcd->driver->flags & HCD_LOCAL_MEM) |
1156 | : DMA_TO_DEVICE); | 1283 | hcd_free_coherent(urb->dev->bus, &urb->transfer_dma, |
1284 | &urb->transfer_buffer, | ||
1285 | urb->transfer_buffer_length, | ||
1286 | dir); | ||
1157 | } | 1287 | } |
1158 | } | 1288 | } |
1159 | 1289 | ||
@@ -1185,7 +1315,12 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags) | |||
1185 | * URBs must be submitted in process context with interrupts | 1315 | * URBs must be submitted in process context with interrupts |
1186 | * enabled. | 1316 | * enabled. |
1187 | */ | 1317 | */ |
1188 | map_urb_for_dma(hcd, urb); | 1318 | status = map_urb_for_dma(hcd, urb, mem_flags); |
1319 | if (unlikely(status)) { | ||
1320 | usbmon_urb_submit_error(&hcd->self, urb, status); | ||
1321 | goto error; | ||
1322 | } | ||
1323 | |||
1189 | if (is_root_hub(urb->dev)) | 1324 | if (is_root_hub(urb->dev)) |
1190 | status = rh_urb_enqueue(hcd, urb); | 1325 | status = rh_urb_enqueue(hcd, urb); |
1191 | else | 1326 | else |
@@ -1194,6 +1329,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags) | |||
1194 | if (unlikely(status)) { | 1329 | if (unlikely(status)) { |
1195 | usbmon_urb_submit_error(&hcd->self, urb, status); | 1330 | usbmon_urb_submit_error(&hcd->self, urb, status); |
1196 | unmap_urb_for_dma(hcd, urb); | 1331 | unmap_urb_for_dma(hcd, urb); |
1332 | error: | ||
1197 | urb->hcpriv = NULL; | 1333 | urb->hcpriv = NULL; |
1198 | INIT_LIST_HEAD(&urb->urb_list); | 1334 | INIT_LIST_HEAD(&urb->urb_list); |
1199 | atomic_dec(&urb->use_count); | 1335 | atomic_dec(&urb->use_count); |
@@ -1291,7 +1427,7 @@ void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status) | |||
1291 | wake_up (&usb_kill_urb_queue); | 1427 | wake_up (&usb_kill_urb_queue); |
1292 | usb_put_urb (urb); | 1428 | usb_put_urb (urb); |
1293 | } | 1429 | } |
1294 | EXPORT_SYMBOL (usb_hcd_giveback_urb); | 1430 | EXPORT_SYMBOL_GPL(usb_hcd_giveback_urb); |
1295 | 1431 | ||
1296 | /*-------------------------------------------------------------------------*/ | 1432 | /*-------------------------------------------------------------------------*/ |
1297 | 1433 | ||
@@ -1531,7 +1667,7 @@ int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num) | |||
1531 | mod_timer(&hcd->rh_timer, jiffies + msecs_to_jiffies(10)); | 1667 | mod_timer(&hcd->rh_timer, jiffies + msecs_to_jiffies(10)); |
1532 | return status; | 1668 | return status; |
1533 | } | 1669 | } |
1534 | EXPORT_SYMBOL (usb_bus_start_enum); | 1670 | EXPORT_SYMBOL_GPL(usb_bus_start_enum); |
1535 | 1671 | ||
1536 | #endif | 1672 | #endif |
1537 | 1673 | ||
@@ -1638,7 +1774,7 @@ struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, | |||
1638 | "USB Host Controller"; | 1774 | "USB Host Controller"; |
1639 | return hcd; | 1775 | return hcd; |
1640 | } | 1776 | } |
1641 | EXPORT_SYMBOL (usb_create_hcd); | 1777 | EXPORT_SYMBOL_GPL(usb_create_hcd); |
1642 | 1778 | ||
1643 | static void hcd_release (struct kref *kref) | 1779 | static void hcd_release (struct kref *kref) |
1644 | { | 1780 | { |
@@ -1653,14 +1789,14 @@ struct usb_hcd *usb_get_hcd (struct usb_hcd *hcd) | |||
1653 | kref_get (&hcd->kref); | 1789 | kref_get (&hcd->kref); |
1654 | return hcd; | 1790 | return hcd; |
1655 | } | 1791 | } |
1656 | EXPORT_SYMBOL (usb_get_hcd); | 1792 | EXPORT_SYMBOL_GPL(usb_get_hcd); |
1657 | 1793 | ||
1658 | void usb_put_hcd (struct usb_hcd *hcd) | 1794 | void usb_put_hcd (struct usb_hcd *hcd) |
1659 | { | 1795 | { |
1660 | if (hcd) | 1796 | if (hcd) |
1661 | kref_put (&hcd->kref, hcd_release); | 1797 | kref_put (&hcd->kref, hcd_release); |
1662 | } | 1798 | } |
1663 | EXPORT_SYMBOL (usb_put_hcd); | 1799 | EXPORT_SYMBOL_GPL(usb_put_hcd); |
1664 | 1800 | ||
1665 | /** | 1801 | /** |
1666 | * usb_add_hcd - finish generic HCD structure initialization and register | 1802 | * usb_add_hcd - finish generic HCD structure initialization and register |
@@ -1786,7 +1922,7 @@ err_register_bus: | |||
1786 | hcd_buffer_destroy(hcd); | 1922 | hcd_buffer_destroy(hcd); |
1787 | return retval; | 1923 | return retval; |
1788 | } | 1924 | } |
1789 | EXPORT_SYMBOL (usb_add_hcd); | 1925 | EXPORT_SYMBOL_GPL(usb_add_hcd); |
1790 | 1926 | ||
1791 | /** | 1927 | /** |
1792 | * usb_remove_hcd - shutdown processing for generic HCDs | 1928 | * usb_remove_hcd - shutdown processing for generic HCDs |
@@ -1828,7 +1964,7 @@ void usb_remove_hcd(struct usb_hcd *hcd) | |||
1828 | usb_deregister_bus(&hcd->self); | 1964 | usb_deregister_bus(&hcd->self); |
1829 | hcd_buffer_destroy(hcd); | 1965 | hcd_buffer_destroy(hcd); |
1830 | } | 1966 | } |
1831 | EXPORT_SYMBOL (usb_remove_hcd); | 1967 | EXPORT_SYMBOL_GPL(usb_remove_hcd); |
1832 | 1968 | ||
1833 | void | 1969 | void |
1834 | usb_hcd_platform_shutdown(struct platform_device* dev) | 1970 | usb_hcd_platform_shutdown(struct platform_device* dev) |
@@ -1838,7 +1974,7 @@ usb_hcd_platform_shutdown(struct platform_device* dev) | |||
1838 | if (hcd->driver->shutdown) | 1974 | if (hcd->driver->shutdown) |
1839 | hcd->driver->shutdown(hcd); | 1975 | hcd->driver->shutdown(hcd); |
1840 | } | 1976 | } |
1841 | EXPORT_SYMBOL (usb_hcd_platform_shutdown); | 1977 | EXPORT_SYMBOL_GPL(usb_hcd_platform_shutdown); |
1842 | 1978 | ||
1843 | /*-------------------------------------------------------------------------*/ | 1979 | /*-------------------------------------------------------------------------*/ |
1844 | 1980 | ||
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index 98e24194a4ab..2d1c3d5e47b8 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h | |||
@@ -125,7 +125,7 @@ struct usb_hcd { | |||
125 | 125 | ||
126 | /* more shared queuing code would be good; it should support | 126 | /* more shared queuing code would be good; it should support |
127 | * smarter scheduling, handle transaction translators, etc; | 127 | * smarter scheduling, handle transaction translators, etc; |
128 | * input size of periodic table to an interrupt scheduler. | 128 | * input size of periodic table to an interrupt scheduler. |
129 | * (ohci 32, uhci 1024, ehci 256/512/1024). | 129 | * (ohci 32, uhci 1024, ehci 256/512/1024). |
130 | */ | 130 | */ |
131 | 131 | ||
@@ -133,16 +133,16 @@ struct usb_hcd { | |||
133 | * this structure. | 133 | * this structure. |
134 | */ | 134 | */ |
135 | unsigned long hcd_priv[0] | 135 | unsigned long hcd_priv[0] |
136 | __attribute__ ((aligned (sizeof(unsigned long)))); | 136 | __attribute__ ((aligned(sizeof(unsigned long)))); |
137 | }; | 137 | }; |
138 | 138 | ||
139 | /* 2.4 does this a bit differently ... */ | 139 | /* 2.4 does this a bit differently ... */ |
140 | static inline struct usb_bus *hcd_to_bus (struct usb_hcd *hcd) | 140 | static inline struct usb_bus *hcd_to_bus(struct usb_hcd *hcd) |
141 | { | 141 | { |
142 | return &hcd->self; | 142 | return &hcd->self; |
143 | } | 143 | } |
144 | 144 | ||
145 | static inline struct usb_hcd *bus_to_hcd (struct usb_bus *bus) | 145 | static inline struct usb_hcd *bus_to_hcd(struct usb_bus *bus) |
146 | { | 146 | { |
147 | return container_of(bus, struct usb_hcd, self); | 147 | return container_of(bus, struct usb_hcd, self); |
148 | } | 148 | } |
@@ -165,6 +165,7 @@ struct hc_driver { | |||
165 | 165 | ||
166 | int flags; | 166 | int flags; |
167 | #define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */ | 167 | #define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */ |
168 | #define HCD_LOCAL_MEM 0x0002 /* HC needs local memory */ | ||
168 | #define HCD_USB11 0x0010 /* USB 1.1 */ | 169 | #define HCD_USB11 0x0010 /* USB 1.1 */ |
169 | #define HCD_USB2 0x0020 /* USB 2.0 */ | 170 | #define HCD_USB2 0x0020 /* USB 2.0 */ |
170 | 171 | ||
@@ -201,15 +202,18 @@ struct hc_driver { | |||
201 | struct usb_host_endpoint *ep); | 202 | struct usb_host_endpoint *ep); |
202 | 203 | ||
203 | /* root hub support */ | 204 | /* root hub support */ |
204 | int (*hub_status_data) (struct usb_hcd *hcd, char *buf); | 205 | int (*hub_status_data) (struct usb_hcd *hcd, char *buf); |
205 | int (*hub_control) (struct usb_hcd *hcd, | 206 | int (*hub_control) (struct usb_hcd *hcd, |
206 | u16 typeReq, u16 wValue, u16 wIndex, | 207 | u16 typeReq, u16 wValue, u16 wIndex, |
207 | char *buf, u16 wLength); | 208 | char *buf, u16 wLength); |
208 | int (*bus_suspend)(struct usb_hcd *); | 209 | int (*bus_suspend)(struct usb_hcd *); |
209 | int (*bus_resume)(struct usb_hcd *); | 210 | int (*bus_resume)(struct usb_hcd *); |
210 | int (*start_port_reset)(struct usb_hcd *, unsigned port_num); | 211 | int (*start_port_reset)(struct usb_hcd *, unsigned port_num); |
211 | void (*hub_irq_enable)(struct usb_hcd *); | 212 | void (*hub_irq_enable)(struct usb_hcd *); |
212 | /* Needed only if port-change IRQs are level-triggered */ | 213 | /* Needed only if port-change IRQs are level-triggered */ |
214 | |||
215 | /* force handover of high-speed port to full-speed companion */ | ||
216 | void (*relinquish_port)(struct usb_hcd *, int); | ||
213 | }; | 217 | }; |
214 | 218 | ||
215 | extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb); | 219 | extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb); |
@@ -217,56 +221,56 @@ extern int usb_hcd_check_unlink_urb(struct usb_hcd *hcd, struct urb *urb, | |||
217 | int status); | 221 | int status); |
218 | extern void usb_hcd_unlink_urb_from_ep(struct usb_hcd *hcd, struct urb *urb); | 222 | extern void usb_hcd_unlink_urb_from_ep(struct usb_hcd *hcd, struct urb *urb); |
219 | 223 | ||
220 | extern int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags); | 224 | extern int usb_hcd_submit_urb(struct urb *urb, gfp_t mem_flags); |
221 | extern int usb_hcd_unlink_urb (struct urb *urb, int status); | 225 | extern int usb_hcd_unlink_urb(struct urb *urb, int status); |
222 | extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, | 226 | extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, |
223 | int status); | 227 | int status); |
224 | extern void usb_hcd_flush_endpoint(struct usb_device *udev, | 228 | extern void usb_hcd_flush_endpoint(struct usb_device *udev, |
225 | struct usb_host_endpoint *ep); | 229 | struct usb_host_endpoint *ep); |
226 | extern void usb_hcd_disable_endpoint(struct usb_device *udev, | 230 | extern void usb_hcd_disable_endpoint(struct usb_device *udev, |
227 | struct usb_host_endpoint *ep); | 231 | struct usb_host_endpoint *ep); |
228 | extern int usb_hcd_get_frame_number (struct usb_device *udev); | 232 | extern int usb_hcd_get_frame_number(struct usb_device *udev); |
229 | 233 | ||
230 | extern struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, | 234 | extern struct usb_hcd *usb_create_hcd(const struct hc_driver *driver, |
231 | struct device *dev, char *bus_name); | 235 | struct device *dev, char *bus_name); |
232 | extern struct usb_hcd *usb_get_hcd (struct usb_hcd *hcd); | 236 | extern struct usb_hcd *usb_get_hcd(struct usb_hcd *hcd); |
233 | extern void usb_put_hcd (struct usb_hcd *hcd); | 237 | extern void usb_put_hcd(struct usb_hcd *hcd); |
234 | extern int usb_add_hcd(struct usb_hcd *hcd, | 238 | extern int usb_add_hcd(struct usb_hcd *hcd, |
235 | unsigned int irqnum, unsigned long irqflags); | 239 | unsigned int irqnum, unsigned long irqflags); |
236 | extern void usb_remove_hcd(struct usb_hcd *hcd); | 240 | extern void usb_remove_hcd(struct usb_hcd *hcd); |
237 | 241 | ||
238 | struct platform_device; | 242 | struct platform_device; |
239 | extern void usb_hcd_platform_shutdown(struct platform_device* dev); | 243 | extern void usb_hcd_platform_shutdown(struct platform_device *dev); |
240 | 244 | ||
241 | #ifdef CONFIG_PCI | 245 | #ifdef CONFIG_PCI |
242 | struct pci_dev; | 246 | struct pci_dev; |
243 | struct pci_device_id; | 247 | struct pci_device_id; |
244 | extern int usb_hcd_pci_probe (struct pci_dev *dev, | 248 | extern int usb_hcd_pci_probe(struct pci_dev *dev, |
245 | const struct pci_device_id *id); | 249 | const struct pci_device_id *id); |
246 | extern void usb_hcd_pci_remove (struct pci_dev *dev); | 250 | extern void usb_hcd_pci_remove(struct pci_dev *dev); |
247 | 251 | ||
248 | #ifdef CONFIG_PM | 252 | #ifdef CONFIG_PM |
249 | extern int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t state); | 253 | extern int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t state); |
250 | extern int usb_hcd_pci_resume (struct pci_dev *dev); | 254 | extern int usb_hcd_pci_resume(struct pci_dev *dev); |
251 | #endif /* CONFIG_PM */ | 255 | #endif /* CONFIG_PM */ |
252 | 256 | ||
253 | extern void usb_hcd_pci_shutdown (struct pci_dev *dev); | 257 | extern void usb_hcd_pci_shutdown(struct pci_dev *dev); |
254 | 258 | ||
255 | #endif /* CONFIG_PCI */ | 259 | #endif /* CONFIG_PCI */ |
256 | 260 | ||
257 | /* pci-ish (pdev null is ok) buffer alloc/mapping support */ | 261 | /* pci-ish (pdev null is ok) buffer alloc/mapping support */ |
258 | int hcd_buffer_create (struct usb_hcd *hcd); | 262 | int hcd_buffer_create(struct usb_hcd *hcd); |
259 | void hcd_buffer_destroy (struct usb_hcd *hcd); | 263 | void hcd_buffer_destroy(struct usb_hcd *hcd); |
260 | 264 | ||
261 | void *hcd_buffer_alloc (struct usb_bus *bus, size_t size, | 265 | void *hcd_buffer_alloc(struct usb_bus *bus, size_t size, |
262 | gfp_t mem_flags, dma_addr_t *dma); | 266 | gfp_t mem_flags, dma_addr_t *dma); |
263 | void hcd_buffer_free (struct usb_bus *bus, size_t size, | 267 | void hcd_buffer_free(struct usb_bus *bus, size_t size, |
264 | void *addr, dma_addr_t dma); | 268 | void *addr, dma_addr_t dma); |
265 | 269 | ||
266 | /* generic bus glue, needed for host controllers that don't use PCI */ | 270 | /* generic bus glue, needed for host controllers that don't use PCI */ |
267 | extern irqreturn_t usb_hcd_irq (int irq, void *__hcd); | 271 | extern irqreturn_t usb_hcd_irq(int irq, void *__hcd); |
268 | 272 | ||
269 | extern void usb_hc_died (struct usb_hcd *hcd); | 273 | extern void usb_hc_died(struct usb_hcd *hcd); |
270 | extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd); | 274 | extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd); |
271 | 275 | ||
272 | /* -------------------------------------------------------------------------- */ | 276 | /* -------------------------------------------------------------------------- */ |
@@ -319,9 +323,9 @@ extern void usb_destroy_configuration(struct usb_device *dev); | |||
319 | * Generic bandwidth allocation constants/support | 323 | * Generic bandwidth allocation constants/support |
320 | */ | 324 | */ |
321 | #define FRAME_TIME_USECS 1000L | 325 | #define FRAME_TIME_USECS 1000L |
322 | #define BitTime(bytecount) (7 * 8 * bytecount / 6) /* with integer truncation */ | 326 | #define BitTime(bytecount) (7 * 8 * bytecount / 6) /* with integer truncation */ |
323 | /* Trying not to use worst-case bit-stuffing | 327 | /* Trying not to use worst-case bit-stuffing |
324 | of (7/6 * 8 * bytecount) = 9.33 * bytecount */ | 328 | * of (7/6 * 8 * bytecount) = 9.33 * bytecount */ |
325 | /* bytecount = data payload byte count */ | 329 | /* bytecount = data payload byte count */ |
326 | 330 | ||
327 | #define NS_TO_US(ns) ((ns + 500L) / 1000L) | 331 | #define NS_TO_US(ns) ((ns + 500L) / 1000L) |
@@ -333,9 +337,9 @@ extern void usb_destroy_configuration(struct usb_device *dev); | |||
333 | */ | 337 | */ |
334 | #define BW_HOST_DELAY 1000L /* nanoseconds */ | 338 | #define BW_HOST_DELAY 1000L /* nanoseconds */ |
335 | #define BW_HUB_LS_SETUP 333L /* nanoseconds */ | 339 | #define BW_HUB_LS_SETUP 333L /* nanoseconds */ |
336 | /* 4 full-speed bit times (est.) */ | 340 | /* 4 full-speed bit times (est.) */ |
337 | 341 | ||
338 | #define FRAME_TIME_BITS 12000L /* frame = 1 millisecond */ | 342 | #define FRAME_TIME_BITS 12000L /* frame = 1 millisecond */ |
339 | #define FRAME_TIME_MAX_BITS_ALLOC (90L * FRAME_TIME_BITS / 100L) | 343 | #define FRAME_TIME_MAX_BITS_ALLOC (90L * FRAME_TIME_BITS / 100L) |
340 | #define FRAME_TIME_MAX_USECS_ALLOC (90L * FRAME_TIME_USECS / 100L) | 344 | #define FRAME_TIME_MAX_USECS_ALLOC (90L * FRAME_TIME_USECS / 100L) |
341 | 345 | ||
@@ -345,16 +349,16 @@ extern void usb_destroy_configuration(struct usb_device *dev); | |||
345 | * to preallocate bandwidth) | 349 | * to preallocate bandwidth) |
346 | */ | 350 | */ |
347 | #define USB2_HOST_DELAY 5 /* nsec, guess */ | 351 | #define USB2_HOST_DELAY 5 /* nsec, guess */ |
348 | #define HS_NSECS(bytes) ( ((55 * 8 * 2083) \ | 352 | #define HS_NSECS(bytes) (((55 * 8 * 2083) \ |
349 | + (2083UL * (3 + BitTime(bytes))))/1000 \ | 353 | + (2083UL * (3 + BitTime(bytes))))/1000 \ |
350 | + USB2_HOST_DELAY) | 354 | + USB2_HOST_DELAY) |
351 | #define HS_NSECS_ISO(bytes) ( ((38 * 8 * 2083) \ | 355 | #define HS_NSECS_ISO(bytes) (((38 * 8 * 2083) \ |
352 | + (2083UL * (3 + BitTime(bytes))))/1000 \ | 356 | + (2083UL * (3 + BitTime(bytes))))/1000 \ |
353 | + USB2_HOST_DELAY) | 357 | + USB2_HOST_DELAY) |
354 | #define HS_USECS(bytes) NS_TO_US (HS_NSECS(bytes)) | 358 | #define HS_USECS(bytes) NS_TO_US (HS_NSECS(bytes)) |
355 | #define HS_USECS_ISO(bytes) NS_TO_US (HS_NSECS_ISO(bytes)) | 359 | #define HS_USECS_ISO(bytes) NS_TO_US (HS_NSECS_ISO(bytes)) |
356 | 360 | ||
357 | extern long usb_calc_bus_time (int speed, int is_input, | 361 | extern long usb_calc_bus_time(int speed, int is_input, |
358 | int isoc, int bytecount); | 362 | int isoc, int bytecount); |
359 | 363 | ||
360 | /*-------------------------------------------------------------------------*/ | 364 | /*-------------------------------------------------------------------------*/ |
@@ -370,16 +374,16 @@ extern struct list_head usb_bus_list; | |||
370 | extern struct mutex usb_bus_list_lock; | 374 | extern struct mutex usb_bus_list_lock; |
371 | extern wait_queue_head_t usb_kill_urb_queue; | 375 | extern wait_queue_head_t usb_kill_urb_queue; |
372 | 376 | ||
373 | extern void usb_enable_root_hub_irq (struct usb_bus *bus); | 377 | extern void usb_enable_root_hub_irq(struct usb_bus *bus); |
374 | 378 | ||
375 | extern int usb_find_interface_driver (struct usb_device *dev, | 379 | extern int usb_find_interface_driver(struct usb_device *dev, |
376 | struct usb_interface *interface); | 380 | struct usb_interface *interface); |
377 | 381 | ||
378 | #define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) | 382 | #define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) |
379 | 383 | ||
380 | #ifdef CONFIG_PM | 384 | #ifdef CONFIG_PM |
381 | extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd); | 385 | extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd); |
382 | extern void usb_root_hub_lost_power (struct usb_device *rhdev); | 386 | extern void usb_root_hub_lost_power(struct usb_device *rhdev); |
383 | extern int hcd_bus_suspend(struct usb_device *rhdev); | 387 | extern int hcd_bus_suspend(struct usb_device *rhdev); |
384 | extern int hcd_bus_resume(struct usb_device *rhdev); | 388 | extern int hcd_bus_resume(struct usb_device *rhdev); |
385 | #else | 389 | #else |
@@ -399,13 +403,13 @@ static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd) | |||
399 | * these are expected to be called from the USB core/hub thread | 403 | * these are expected to be called from the USB core/hub thread |
400 | * with the kernel lock held | 404 | * with the kernel lock held |
401 | */ | 405 | */ |
402 | extern void usbfs_update_special (void); | 406 | extern void usbfs_update_special(void); |
403 | extern int usbfs_init(void); | 407 | extern int usbfs_init(void); |
404 | extern void usbfs_cleanup(void); | 408 | extern void usbfs_cleanup(void); |
405 | 409 | ||
406 | #else /* CONFIG_USB_DEVICEFS */ | 410 | #else /* CONFIG_USB_DEVICEFS */ |
407 | 411 | ||
408 | static inline void usbfs_update_special (void) {} | 412 | static inline void usbfs_update_special(void) {} |
409 | static inline int usbfs_init(void) { return 0; } | 413 | static inline int usbfs_init(void) { return 0; } |
410 | static inline void usbfs_cleanup(void) { } | 414 | static inline void usbfs_cleanup(void) { } |
411 | 415 | ||
@@ -460,7 +464,7 @@ static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb, | |||
460 | /*-------------------------------------------------------------------------*/ | 464 | /*-------------------------------------------------------------------------*/ |
461 | 465 | ||
462 | /* hub.h ... DeviceRemovable in 2.4.2-ac11, gone in 2.4.10 */ | 466 | /* hub.h ... DeviceRemovable in 2.4.2-ac11, gone in 2.4.10 */ |
463 | // bleech -- resurfaced in 2.4.11 or 2.4.12 | 467 | /* bleech -- resurfaced in 2.4.11 or 2.4.12 */ |
464 | #define bitmap DeviceRemovable | 468 | #define bitmap DeviceRemovable |
465 | 469 | ||
466 | 470 | ||
@@ -468,8 +472,8 @@ static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb, | |||
468 | 472 | ||
469 | /* random stuff */ | 473 | /* random stuff */ |
470 | 474 | ||
471 | #define RUN_CONTEXT (in_irq () ? "in_irq" \ | 475 | #define RUN_CONTEXT (in_irq() ? "in_irq" \ |
472 | : (in_interrupt () ? "in_interrupt" : "can sleep")) | 476 | : (in_interrupt() ? "in_interrupt" : "can sleep")) |
473 | 477 | ||
474 | 478 | ||
475 | /* This rwsem is for use only by the hub driver and ehci-hcd. | 479 | /* This rwsem is for use only by the hub driver and ehci-hcd. |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index b04d232d4c65..68fc5219ca15 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -37,6 +37,13 @@ | |||
37 | #define USB_PERSIST 0 | 37 | #define USB_PERSIST 0 |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | /* if we are in debug mode, always announce new devices */ | ||
41 | #ifdef DEBUG | ||
42 | #ifndef CONFIG_USB_ANNOUNCE_NEW_DEVICES | ||
43 | #define CONFIG_USB_ANNOUNCE_NEW_DEVICES | ||
44 | #endif | ||
45 | #endif | ||
46 | |||
40 | struct usb_hub { | 47 | struct usb_hub { |
41 | struct device *intfdev; /* the "interface" device */ | 48 | struct device *intfdev; /* the "interface" device */ |
42 | struct usb_device *hdev; | 49 | struct usb_device *hdev; |
@@ -487,6 +494,7 @@ void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe) | |||
487 | schedule_work (&tt->kevent); | 494 | schedule_work (&tt->kevent); |
488 | spin_unlock_irqrestore (&tt->lock, flags); | 495 | spin_unlock_irqrestore (&tt->lock, flags); |
489 | } | 496 | } |
497 | EXPORT_SYMBOL_GPL(usb_hub_tt_clear_buffer); | ||
490 | 498 | ||
491 | static void hub_power_on(struct usb_hub *hub) | 499 | static void hub_power_on(struct usb_hub *hub) |
492 | { | 500 | { |
@@ -1027,8 +1035,10 @@ static void recursively_mark_NOTATTACHED(struct usb_device *udev) | |||
1027 | if (udev->children[i]) | 1035 | if (udev->children[i]) |
1028 | recursively_mark_NOTATTACHED(udev->children[i]); | 1036 | recursively_mark_NOTATTACHED(udev->children[i]); |
1029 | } | 1037 | } |
1030 | if (udev->state == USB_STATE_SUSPENDED) | 1038 | if (udev->state == USB_STATE_SUSPENDED) { |
1031 | udev->discon_suspended = 1; | 1039 | udev->discon_suspended = 1; |
1040 | udev->active_duration -= jiffies; | ||
1041 | } | ||
1032 | udev->state = USB_STATE_NOTATTACHED; | 1042 | udev->state = USB_STATE_NOTATTACHED; |
1033 | } | 1043 | } |
1034 | 1044 | ||
@@ -1077,6 +1087,12 @@ void usb_set_device_state(struct usb_device *udev, | |||
1077 | else | 1087 | else |
1078 | device_init_wakeup(&udev->dev, 0); | 1088 | device_init_wakeup(&udev->dev, 0); |
1079 | } | 1089 | } |
1090 | if (udev->state == USB_STATE_SUSPENDED && | ||
1091 | new_state != USB_STATE_SUSPENDED) | ||
1092 | udev->active_duration -= jiffies; | ||
1093 | else if (new_state == USB_STATE_SUSPENDED && | ||
1094 | udev->state != USB_STATE_SUSPENDED) | ||
1095 | udev->active_duration += jiffies; | ||
1080 | udev->state = new_state; | 1096 | udev->state = new_state; |
1081 | } else | 1097 | } else |
1082 | recursively_mark_NOTATTACHED(udev); | 1098 | recursively_mark_NOTATTACHED(udev); |
@@ -1207,7 +1223,7 @@ void usb_disconnect(struct usb_device **pdev) | |||
1207 | put_device(&udev->dev); | 1223 | put_device(&udev->dev); |
1208 | } | 1224 | } |
1209 | 1225 | ||
1210 | #ifdef DEBUG | 1226 | #ifdef CONFIG_USB_ANNOUNCE_NEW_DEVICES |
1211 | static void show_string(struct usb_device *udev, char *id, char *string) | 1227 | static void show_string(struct usb_device *udev, char *id, char *string) |
1212 | { | 1228 | { |
1213 | if (!string) | 1229 | if (!string) |
@@ -1215,12 +1231,24 @@ static void show_string(struct usb_device *udev, char *id, char *string) | |||
1215 | dev_printk(KERN_INFO, &udev->dev, "%s: %s\n", id, string); | 1231 | dev_printk(KERN_INFO, &udev->dev, "%s: %s\n", id, string); |
1216 | } | 1232 | } |
1217 | 1233 | ||
1234 | static void announce_device(struct usb_device *udev) | ||
1235 | { | ||
1236 | dev_info(&udev->dev, "New USB device found, idVendor=%04x, idProduct=%04x\n", | ||
1237 | le16_to_cpu(udev->descriptor.idVendor), | ||
1238 | le16_to_cpu(udev->descriptor.idProduct)); | ||
1239 | dev_info(&udev->dev, "New USB device strings: Mfr=%d, Product=%d, " | ||
1240 | "SerialNumber=%d\n", | ||
1241 | udev->descriptor.iManufacturer, | ||
1242 | udev->descriptor.iProduct, | ||
1243 | udev->descriptor.iSerialNumber); | ||
1244 | show_string(udev, "Product", udev->product); | ||
1245 | show_string(udev, "Manufacturer", udev->manufacturer); | ||
1246 | show_string(udev, "SerialNumber", udev->serial); | ||
1247 | } | ||
1218 | #else | 1248 | #else |
1219 | static inline void show_string(struct usb_device *udev, char *id, char *string) | 1249 | static inline void announce_device(struct usb_device *udev) { } |
1220 | {} | ||
1221 | #endif | 1250 | #endif |
1222 | 1251 | ||
1223 | |||
1224 | #ifdef CONFIG_USB_OTG | 1252 | #ifdef CONFIG_USB_OTG |
1225 | #include "otg_whitelist.h" | 1253 | #include "otg_whitelist.h" |
1226 | #endif | 1254 | #endif |
@@ -1390,14 +1418,7 @@ int usb_new_device(struct usb_device *udev) | |||
1390 | } | 1418 | } |
1391 | 1419 | ||
1392 | /* Tell the world! */ | 1420 | /* Tell the world! */ |
1393 | dev_dbg(&udev->dev, "new device strings: Mfr=%d, Product=%d, " | 1421 | announce_device(udev); |
1394 | "SerialNumber=%d\n", | ||
1395 | udev->descriptor.iManufacturer, | ||
1396 | udev->descriptor.iProduct, | ||
1397 | udev->descriptor.iSerialNumber); | ||
1398 | show_string(udev, "Product", udev->product); | ||
1399 | show_string(udev, "Manufacturer", udev->manufacturer); | ||
1400 | show_string(udev, "SerialNumber", udev->serial); | ||
1401 | return err; | 1422 | return err; |
1402 | 1423 | ||
1403 | fail: | 1424 | fail: |
@@ -2482,6 +2503,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
2482 | { | 2503 | { |
2483 | struct usb_device *hdev = hub->hdev; | 2504 | struct usb_device *hdev = hub->hdev; |
2484 | struct device *hub_dev = hub->intfdev; | 2505 | struct device *hub_dev = hub->intfdev; |
2506 | struct usb_hcd *hcd = bus_to_hcd(hdev->bus); | ||
2485 | u16 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); | 2507 | u16 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); |
2486 | int status, i; | 2508 | int status, i; |
2487 | 2509 | ||
@@ -2645,6 +2667,8 @@ loop: | |||
2645 | 2667 | ||
2646 | done: | 2668 | done: |
2647 | hub_port_disable(hub, port1, 1); | 2669 | hub_port_disable(hub, port1, 1); |
2670 | if (hcd->driver->relinquish_port && !hub->hdev->parent) | ||
2671 | hcd->driver->relinquish_port(hcd, port1); | ||
2648 | } | 2672 | } |
2649 | 2673 | ||
2650 | static void hub_events(void) | 2674 | static void hub_events(void) |
@@ -2946,7 +2970,7 @@ static int config_descriptors_changed(struct usb_device *udev) | |||
2946 | if (len < le16_to_cpu(udev->config[index].desc.wTotalLength)) | 2970 | if (len < le16_to_cpu(udev->config[index].desc.wTotalLength)) |
2947 | len = le16_to_cpu(udev->config[index].desc.wTotalLength); | 2971 | len = le16_to_cpu(udev->config[index].desc.wTotalLength); |
2948 | } | 2972 | } |
2949 | buf = kmalloc (len, GFP_KERNEL); | 2973 | buf = kmalloc(len, GFP_NOIO); |
2950 | if (buf == NULL) { | 2974 | if (buf == NULL) { |
2951 | dev_err(&udev->dev, "no mem to re-read configs after reset\n"); | 2975 | dev_err(&udev->dev, "no mem to re-read configs after reset\n"); |
2952 | /* assume the worst */ | 2976 | /* assume the worst */ |
@@ -3093,7 +3117,7 @@ re_enumerate: | |||
3093 | hub_port_logical_disconnect(parent_hub, port1); | 3117 | hub_port_logical_disconnect(parent_hub, port1); |
3094 | return -ENODEV; | 3118 | return -ENODEV; |
3095 | } | 3119 | } |
3096 | EXPORT_SYMBOL(usb_reset_device); | 3120 | EXPORT_SYMBOL_GPL(usb_reset_device); |
3097 | 3121 | ||
3098 | /** | 3122 | /** |
3099 | * usb_reset_composite_device - warn interface drivers and perform a USB port reset | 3123 | * usb_reset_composite_device - warn interface drivers and perform a USB port reset |
@@ -3110,16 +3134,12 @@ EXPORT_SYMBOL(usb_reset_device); | |||
3110 | * this from a driver probe() routine after downloading new firmware. | 3134 | * this from a driver probe() routine after downloading new firmware. |
3111 | * For calls that might not occur during probe(), drivers should lock | 3135 | * For calls that might not occur during probe(), drivers should lock |
3112 | * the device using usb_lock_device_for_reset(). | 3136 | * the device using usb_lock_device_for_reset(). |
3113 | * | ||
3114 | * The interface locks are acquired during the pre_reset stage and released | ||
3115 | * during the post_reset stage. However if iface is not NULL and is | ||
3116 | * currently being probed, we assume that the caller already owns its | ||
3117 | * lock. | ||
3118 | */ | 3137 | */ |
3119 | int usb_reset_composite_device(struct usb_device *udev, | 3138 | int usb_reset_composite_device(struct usb_device *udev, |
3120 | struct usb_interface *iface) | 3139 | struct usb_interface *iface) |
3121 | { | 3140 | { |
3122 | int ret; | 3141 | int ret; |
3142 | int i; | ||
3123 | struct usb_host_config *config = udev->actconfig; | 3143 | struct usb_host_config *config = udev->actconfig; |
3124 | 3144 | ||
3125 | if (udev->state == USB_STATE_NOTATTACHED || | 3145 | if (udev->state == USB_STATE_NOTATTACHED || |
@@ -3136,16 +3156,11 @@ int usb_reset_composite_device(struct usb_device *udev, | |||
3136 | iface = NULL; | 3156 | iface = NULL; |
3137 | 3157 | ||
3138 | if (config) { | 3158 | if (config) { |
3139 | int i; | ||
3140 | struct usb_interface *cintf; | ||
3141 | struct usb_driver *drv; | ||
3142 | |||
3143 | for (i = 0; i < config->desc.bNumInterfaces; ++i) { | 3159 | for (i = 0; i < config->desc.bNumInterfaces; ++i) { |
3144 | cintf = config->interface[i]; | 3160 | struct usb_interface *cintf = config->interface[i]; |
3145 | if (cintf != iface) | 3161 | struct usb_driver *drv; |
3146 | down(&cintf->dev.sem); | 3162 | |
3147 | if (device_is_registered(&cintf->dev) && | 3163 | if (cintf->dev.driver) { |
3148 | cintf->dev.driver) { | ||
3149 | drv = to_usb_driver(cintf->dev.driver); | 3164 | drv = to_usb_driver(cintf->dev.driver); |
3150 | if (drv->pre_reset) | 3165 | if (drv->pre_reset) |
3151 | (drv->pre_reset)(cintf); | 3166 | (drv->pre_reset)(cintf); |
@@ -3157,25 +3172,20 @@ int usb_reset_composite_device(struct usb_device *udev, | |||
3157 | ret = usb_reset_device(udev); | 3172 | ret = usb_reset_device(udev); |
3158 | 3173 | ||
3159 | if (config) { | 3174 | if (config) { |
3160 | int i; | ||
3161 | struct usb_interface *cintf; | ||
3162 | struct usb_driver *drv; | ||
3163 | |||
3164 | for (i = config->desc.bNumInterfaces - 1; i >= 0; --i) { | 3175 | for (i = config->desc.bNumInterfaces - 1; i >= 0; --i) { |
3165 | cintf = config->interface[i]; | 3176 | struct usb_interface *cintf = config->interface[i]; |
3166 | if (device_is_registered(&cintf->dev) && | 3177 | struct usb_driver *drv; |
3167 | cintf->dev.driver) { | 3178 | |
3179 | if (cintf->dev.driver) { | ||
3168 | drv = to_usb_driver(cintf->dev.driver); | 3180 | drv = to_usb_driver(cintf->dev.driver); |
3169 | if (drv->post_reset) | 3181 | if (drv->post_reset) |
3170 | (drv->post_reset)(cintf); | 3182 | (drv->post_reset)(cintf); |
3171 | /* FIXME: Unbind if post_reset returns an error or isn't defined */ | 3183 | /* FIXME: Unbind if post_reset returns an error or isn't defined */ |
3172 | } | 3184 | } |
3173 | if (cintf != iface) | ||
3174 | up(&cintf->dev.sem); | ||
3175 | } | 3185 | } |
3176 | } | 3186 | } |
3177 | 3187 | ||
3178 | usb_autosuspend_device(udev); | 3188 | usb_autosuspend_device(udev); |
3179 | return ret; | 3189 | return ret; |
3180 | } | 3190 | } |
3181 | EXPORT_SYMBOL(usb_reset_composite_device); | 3191 | EXPORT_SYMBOL_GPL(usb_reset_composite_device); |
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h index cf9559c6c9b6..1551aed65e05 100644 --- a/drivers/usb/core/hub.h +++ b/drivers/usb/core/hub.h | |||
@@ -55,16 +55,16 @@ | |||
55 | #define USB_PORT_FEAT_TEST 21 | 55 | #define USB_PORT_FEAT_TEST 21 |
56 | #define USB_PORT_FEAT_INDICATOR 22 | 56 | #define USB_PORT_FEAT_INDICATOR 22 |
57 | 57 | ||
58 | /* | 58 | /* |
59 | * Hub Status and Hub Change results | 59 | * Hub Status and Hub Change results |
60 | * See USB 2.0 spec Table 11-19 and Table 11-20 | 60 | * See USB 2.0 spec Table 11-19 and Table 11-20 |
61 | */ | 61 | */ |
62 | struct usb_port_status { | 62 | struct usb_port_status { |
63 | __le16 wPortStatus; | 63 | __le16 wPortStatus; |
64 | __le16 wPortChange; | 64 | __le16 wPortChange; |
65 | } __attribute__ ((packed)); | 65 | } __attribute__ ((packed)); |
66 | 66 | ||
67 | /* | 67 | /* |
68 | * wPortStatus bit field | 68 | * wPortStatus bit field |
69 | * See USB 2.0 spec Table 11-21 | 69 | * See USB 2.0 spec Table 11-21 |
70 | */ | 70 | */ |
@@ -81,7 +81,7 @@ struct usb_port_status { | |||
81 | #define USB_PORT_STAT_INDICATOR 0x1000 | 81 | #define USB_PORT_STAT_INDICATOR 0x1000 |
82 | /* bits 13 to 15 are reserved */ | 82 | /* bits 13 to 15 are reserved */ |
83 | 83 | ||
84 | /* | 84 | /* |
85 | * wPortChange bit field | 85 | * wPortChange bit field |
86 | * See USB 2.0 spec Table 11-22 | 86 | * See USB 2.0 spec Table 11-22 |
87 | * Bits 0 to 4 shown, bits 5 to 15 are reserved | 87 | * Bits 0 to 4 shown, bits 5 to 15 are reserved |
@@ -93,7 +93,7 @@ struct usb_port_status { | |||
93 | #define USB_PORT_STAT_C_RESET 0x0010 | 93 | #define USB_PORT_STAT_C_RESET 0x0010 |
94 | 94 | ||
95 | /* | 95 | /* |
96 | * wHubCharacteristics (masks) | 96 | * wHubCharacteristics (masks) |
97 | * See USB 2.0 spec Table 11-13, offset 3 | 97 | * See USB 2.0 spec Table 11-13, offset 3 |
98 | */ | 98 | */ |
99 | #define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */ | 99 | #define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */ |
@@ -119,8 +119,8 @@ struct usb_hub_status { | |||
119 | #define HUB_CHANGE_OVERCURRENT 0x0002 | 119 | #define HUB_CHANGE_OVERCURRENT 0x0002 |
120 | 120 | ||
121 | 121 | ||
122 | /* | 122 | /* |
123 | * Hub descriptor | 123 | * Hub descriptor |
124 | * See USB 2.0 spec Table 11-13 | 124 | * See USB 2.0 spec Table 11-13 |
125 | */ | 125 | */ |
126 | 126 | ||
@@ -134,7 +134,7 @@ struct usb_hub_descriptor { | |||
134 | __le16 wHubCharacteristics; | 134 | __le16 wHubCharacteristics; |
135 | __u8 bPwrOn2PwrGood; | 135 | __u8 bPwrOn2PwrGood; |
136 | __u8 bHubContrCurrent; | 136 | __u8 bHubContrCurrent; |
137 | /* add 1 bit for hub status change; round to bytes */ | 137 | /* add 1 bit for hub status change; round to bytes */ |
138 | __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8]; | 138 | __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8]; |
139 | __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8]; | 139 | __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8]; |
140 | } __attribute__ ((packed)); | 140 | } __attribute__ ((packed)); |
@@ -190,6 +190,6 @@ struct usb_tt_clear { | |||
190 | u16 devinfo; | 190 | u16 devinfo; |
191 | }; | 191 | }; |
192 | 192 | ||
193 | extern void usb_hub_tt_clear_buffer (struct usb_device *dev, int pipe); | 193 | extern void usb_hub_tt_clear_buffer(struct usb_device *dev, int pipe); |
194 | 194 | ||
195 | #endif /* __LINUX_HUB_H */ | 195 | #endif /* __LINUX_HUB_H */ |
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index cd4f11157280..83a373e9cc36 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c | |||
@@ -38,10 +38,15 @@ | |||
38 | #include <linux/usbdevice_fs.h> | 38 | #include <linux/usbdevice_fs.h> |
39 | #include <linux/parser.h> | 39 | #include <linux/parser.h> |
40 | #include <linux/notifier.h> | 40 | #include <linux/notifier.h> |
41 | #include <linux/seq_file.h> | ||
41 | #include <asm/byteorder.h> | 42 | #include <asm/byteorder.h> |
42 | #include "usb.h" | 43 | #include "usb.h" |
43 | #include "hcd.h" | 44 | #include "hcd.h" |
44 | 45 | ||
46 | #define USBFS_DEFAULT_DEVMODE (S_IWUSR | S_IRUGO) | ||
47 | #define USBFS_DEFAULT_BUSMODE (S_IXUGO | S_IRUGO) | ||
48 | #define USBFS_DEFAULT_LISTMODE S_IRUGO | ||
49 | |||
45 | static struct super_operations usbfs_ops; | 50 | static struct super_operations usbfs_ops; |
46 | static const struct file_operations default_file_operations; | 51 | static const struct file_operations default_file_operations; |
47 | static struct vfsmount *usbfs_mount; | 52 | static struct vfsmount *usbfs_mount; |
@@ -57,9 +62,33 @@ static uid_t listuid; /* = 0 */ | |||
57 | static gid_t devgid; /* = 0 */ | 62 | static gid_t devgid; /* = 0 */ |
58 | static gid_t busgid; /* = 0 */ | 63 | static gid_t busgid; /* = 0 */ |
59 | static gid_t listgid; /* = 0 */ | 64 | static gid_t listgid; /* = 0 */ |
60 | static umode_t devmode = S_IWUSR | S_IRUGO; | 65 | static umode_t devmode = USBFS_DEFAULT_DEVMODE; |
61 | static umode_t busmode = S_IXUGO | S_IRUGO; | 66 | static umode_t busmode = USBFS_DEFAULT_BUSMODE; |
62 | static umode_t listmode = S_IRUGO; | 67 | static umode_t listmode = USBFS_DEFAULT_LISTMODE; |
68 | |||
69 | static int usbfs_show_options(struct seq_file *seq, struct vfsmount *mnt) | ||
70 | { | ||
71 | if (devuid != 0) | ||
72 | seq_printf(seq, ",devuid=%u", devuid); | ||
73 | if (devgid != 0) | ||
74 | seq_printf(seq, ",devgid=%u", devgid); | ||
75 | if (devmode != USBFS_DEFAULT_DEVMODE) | ||
76 | seq_printf(seq, ",devmode=%o", devmode); | ||
77 | if (busuid != 0) | ||
78 | seq_printf(seq, ",busuid=%u", busuid); | ||
79 | if (busgid != 0) | ||
80 | seq_printf(seq, ",busgid=%u", busgid); | ||
81 | if (busmode != USBFS_DEFAULT_BUSMODE) | ||
82 | seq_printf(seq, ",busmode=%o", busmode); | ||
83 | if (listuid != 0) | ||
84 | seq_printf(seq, ",listuid=%u", listuid); | ||
85 | if (listgid != 0) | ||
86 | seq_printf(seq, ",listgid=%u", listgid); | ||
87 | if (listmode != USBFS_DEFAULT_LISTMODE) | ||
88 | seq_printf(seq, ",listmode=%o", listmode); | ||
89 | |||
90 | return 0; | ||
91 | } | ||
63 | 92 | ||
64 | enum { | 93 | enum { |
65 | Opt_devuid, Opt_devgid, Opt_devmode, | 94 | Opt_devuid, Opt_devgid, Opt_devmode, |
@@ -93,9 +122,9 @@ static int parse_options(struct super_block *s, char *data) | |||
93 | devgid = 0; | 122 | devgid = 0; |
94 | busgid = 0; | 123 | busgid = 0; |
95 | listgid = 0; | 124 | listgid = 0; |
96 | devmode = S_IWUSR | S_IRUGO; | 125 | devmode = USBFS_DEFAULT_DEVMODE; |
97 | busmode = S_IXUGO | S_IRUGO; | 126 | busmode = USBFS_DEFAULT_BUSMODE; |
98 | listmode = S_IRUGO; | 127 | listmode = USBFS_DEFAULT_LISTMODE; |
99 | 128 | ||
100 | while ((p = strsep(&data, ",")) != NULL) { | 129 | while ((p = strsep(&data, ",")) != NULL) { |
101 | substring_t args[MAX_OPT_ARGS]; | 130 | substring_t args[MAX_OPT_ARGS]; |
@@ -418,6 +447,7 @@ static struct super_operations usbfs_ops = { | |||
418 | .statfs = simple_statfs, | 447 | .statfs = simple_statfs, |
419 | .drop_inode = generic_delete_inode, | 448 | .drop_inode = generic_delete_inode, |
420 | .remount_fs = remount, | 449 | .remount_fs = remount, |
450 | .show_options = usbfs_show_options, | ||
421 | }; | 451 | }; |
422 | 452 | ||
423 | static int usbfs_fill_super(struct super_block *sb, void *data, int silent) | 453 | static int usbfs_fill_super(struct super_block *sb, void *data, int silent) |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index fcd40ecbeecc..fefb92296e8f 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -39,7 +39,7 @@ static void usb_api_blocking_completion(struct urb *urb) | |||
39 | * own interruptible routines. | 39 | * own interruptible routines. |
40 | */ | 40 | */ |
41 | static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length) | 41 | static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length) |
42 | { | 42 | { |
43 | struct api_context ctx; | 43 | struct api_context ctx; |
44 | unsigned long expire; | 44 | unsigned long expire; |
45 | int retval; | 45 | int retval; |
@@ -74,9 +74,9 @@ out: | |||
74 | } | 74 | } |
75 | 75 | ||
76 | /*-------------------------------------------------------------------*/ | 76 | /*-------------------------------------------------------------------*/ |
77 | // returns status (negative) or length (positive) | 77 | /* returns status (negative) or length (positive) */ |
78 | static int usb_internal_control_msg(struct usb_device *usb_dev, | 78 | static int usb_internal_control_msg(struct usb_device *usb_dev, |
79 | unsigned int pipe, | 79 | unsigned int pipe, |
80 | struct usb_ctrlrequest *cmd, | 80 | struct usb_ctrlrequest *cmd, |
81 | void *data, int len, int timeout) | 81 | void *data, int len, int timeout) |
82 | { | 82 | { |
@@ -87,7 +87,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev, | |||
87 | urb = usb_alloc_urb(0, GFP_NOIO); | 87 | urb = usb_alloc_urb(0, GFP_NOIO); |
88 | if (!urb) | 88 | if (!urb) |
89 | return -ENOMEM; | 89 | return -ENOMEM; |
90 | 90 | ||
91 | usb_fill_control_urb(urb, usb_dev, pipe, (unsigned char *)cmd, data, | 91 | usb_fill_control_urb(urb, usb_dev, pipe, (unsigned char *)cmd, data, |
92 | len, usb_api_blocking_completion, NULL); | 92 | len, usb_api_blocking_completion, NULL); |
93 | 93 | ||
@@ -99,47 +99,51 @@ static int usb_internal_control_msg(struct usb_device *usb_dev, | |||
99 | } | 99 | } |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * usb_control_msg - Builds a control urb, sends it off and waits for completion | 102 | * usb_control_msg - Builds a control urb, sends it off and waits for completion |
103 | * @dev: pointer to the usb device to send the message to | 103 | * @dev: pointer to the usb device to send the message to |
104 | * @pipe: endpoint "pipe" to send the message to | 104 | * @pipe: endpoint "pipe" to send the message to |
105 | * @request: USB message request value | 105 | * @request: USB message request value |
106 | * @requesttype: USB message request type value | 106 | * @requesttype: USB message request type value |
107 | * @value: USB message value | 107 | * @value: USB message value |
108 | * @index: USB message index value | 108 | * @index: USB message index value |
109 | * @data: pointer to the data to send | 109 | * @data: pointer to the data to send |
110 | * @size: length in bytes of the data to send | 110 | * @size: length in bytes of the data to send |
111 | * @timeout: time in msecs to wait for the message to complete before | 111 | * @timeout: time in msecs to wait for the message to complete before timing |
112 | * timing out (if 0 the wait is forever) | 112 | * out (if 0 the wait is forever) |
113 | * Context: !in_interrupt () | 113 | * |
114 | * | 114 | * Context: !in_interrupt () |
115 | * This function sends a simple control message to a specified endpoint | 115 | * |
116 | * and waits for the message to complete, or timeout. | 116 | * This function sends a simple control message to a specified endpoint and |
117 | * | 117 | * waits for the message to complete, or timeout. |
118 | * If successful, it returns the number of bytes transferred, otherwise a negative error number. | 118 | * |
119 | * | 119 | * If successful, it returns the number of bytes transferred, otherwise a |
120 | * Don't use this function from within an interrupt context, like a | 120 | * negative error number. |
121 | * bottom half handler. If you need an asynchronous message, or need to send | 121 | * |
122 | * a message from within interrupt context, use usb_submit_urb() | 122 | * Don't use this function from within an interrupt context, like a bottom half |
123 | * If a thread in your driver uses this call, make sure your disconnect() | 123 | * handler. If you need an asynchronous message, or need to send a message |
124 | * method can wait for it to complete. Since you don't have a handle on | 124 | * from within interrupt context, use usb_submit_urb(). |
125 | * the URB used, you can't cancel the request. | 125 | * If a thread in your driver uses this call, make sure your disconnect() |
126 | * method can wait for it to complete. Since you don't have a handle on the | ||
127 | * URB used, you can't cancel the request. | ||
126 | */ | 128 | */ |
127 | int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, | 129 | int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, |
128 | __u16 value, __u16 index, void *data, __u16 size, int timeout) | 130 | __u8 requesttype, __u16 value, __u16 index, void *data, |
131 | __u16 size, int timeout) | ||
129 | { | 132 | { |
130 | struct usb_ctrlrequest *dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); | 133 | struct usb_ctrlrequest *dr; |
131 | int ret; | 134 | int ret; |
132 | 135 | ||
136 | dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); | ||
133 | if (!dr) | 137 | if (!dr) |
134 | return -ENOMEM; | 138 | return -ENOMEM; |
135 | 139 | ||
136 | dr->bRequestType= requesttype; | 140 | dr->bRequestType = requesttype; |
137 | dr->bRequest = request; | 141 | dr->bRequest = request; |
138 | dr->wValue = cpu_to_le16p(&value); | 142 | dr->wValue = cpu_to_le16p(&value); |
139 | dr->wIndex = cpu_to_le16p(&index); | 143 | dr->wIndex = cpu_to_le16p(&index); |
140 | dr->wLength = cpu_to_le16p(&size); | 144 | dr->wLength = cpu_to_le16p(&size); |
141 | 145 | ||
142 | //dbg("usb_control_msg"); | 146 | /* dbg("usb_control_msg"); */ |
143 | 147 | ||
144 | ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout); | 148 | ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout); |
145 | 149 | ||
@@ -147,7 +151,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u | |||
147 | 151 | ||
148 | return ret; | 152 | return ret; |
149 | } | 153 | } |
150 | 154 | EXPORT_SYMBOL_GPL(usb_control_msg); | |
151 | 155 | ||
152 | /** | 156 | /** |
153 | * usb_interrupt_msg - Builds an interrupt urb, sends it off and waits for completion | 157 | * usb_interrupt_msg - Builds an interrupt urb, sends it off and waits for completion |
@@ -155,9 +159,11 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u | |||
155 | * @pipe: endpoint "pipe" to send the message to | 159 | * @pipe: endpoint "pipe" to send the message to |
156 | * @data: pointer to the data to send | 160 | * @data: pointer to the data to send |
157 | * @len: length in bytes of the data to send | 161 | * @len: length in bytes of the data to send |
158 | * @actual_length: pointer to a location to put the actual length transferred in bytes | 162 | * @actual_length: pointer to a location to put the actual length transferred |
163 | * in bytes | ||
159 | * @timeout: time in msecs to wait for the message to complete before | 164 | * @timeout: time in msecs to wait for the message to complete before |
160 | * timing out (if 0 the wait is forever) | 165 | * timing out (if 0 the wait is forever) |
166 | * | ||
161 | * Context: !in_interrupt () | 167 | * Context: !in_interrupt () |
162 | * | 168 | * |
163 | * This function sends a simple interrupt message to a specified endpoint and | 169 | * This function sends a simple interrupt message to a specified endpoint and |
@@ -181,38 +187,38 @@ int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe, | |||
181 | EXPORT_SYMBOL_GPL(usb_interrupt_msg); | 187 | EXPORT_SYMBOL_GPL(usb_interrupt_msg); |
182 | 188 | ||
183 | /** | 189 | /** |
184 | * usb_bulk_msg - Builds a bulk urb, sends it off and waits for completion | 190 | * usb_bulk_msg - Builds a bulk urb, sends it off and waits for completion |
185 | * @usb_dev: pointer to the usb device to send the message to | 191 | * @usb_dev: pointer to the usb device to send the message to |
186 | * @pipe: endpoint "pipe" to send the message to | 192 | * @pipe: endpoint "pipe" to send the message to |
187 | * @data: pointer to the data to send | 193 | * @data: pointer to the data to send |
188 | * @len: length in bytes of the data to send | 194 | * @len: length in bytes of the data to send |
189 | * @actual_length: pointer to a location to put the actual length transferred in bytes | 195 | * @actual_length: pointer to a location to put the actual length transferred |
190 | * @timeout: time in msecs to wait for the message to complete before | 196 | * in bytes |
191 | * timing out (if 0 the wait is forever) | 197 | * @timeout: time in msecs to wait for the message to complete before |
192 | * Context: !in_interrupt () | 198 | * timing out (if 0 the wait is forever) |
193 | * | 199 | * |
194 | * This function sends a simple bulk message to a specified endpoint | 200 | * Context: !in_interrupt () |
195 | * and waits for the message to complete, or timeout. | 201 | * |
196 | * | 202 | * This function sends a simple bulk message to a specified endpoint |
197 | * If successful, it returns 0, otherwise a negative error number. | 203 | * and waits for the message to complete, or timeout. |
198 | * The number of actual bytes transferred will be stored in the | 204 | * |
199 | * actual_length paramater. | 205 | * If successful, it returns 0, otherwise a negative error number. The number |
200 | * | 206 | * of actual bytes transferred will be stored in the actual_length paramater. |
201 | * Don't use this function from within an interrupt context, like a | 207 | * |
202 | * bottom half handler. If you need an asynchronous message, or need to | 208 | * Don't use this function from within an interrupt context, like a bottom half |
203 | * send a message from within interrupt context, use usb_submit_urb() | 209 | * handler. If you need an asynchronous message, or need to send a message |
204 | * If a thread in your driver uses this call, make sure your disconnect() | 210 | * from within interrupt context, use usb_submit_urb() If a thread in your |
205 | * method can wait for it to complete. Since you don't have a handle on | 211 | * driver uses this call, make sure your disconnect() method can wait for it to |
206 | * the URB used, you can't cancel the request. | 212 | * complete. Since you don't have a handle on the URB used, you can't cancel |
207 | * | 213 | * the request. |
208 | * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT | 214 | * |
209 | * ioctl, users are forced to abuse this routine by using it to submit | 215 | * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT ioctl, |
210 | * URBs for interrupt endpoints. We will take the liberty of creating | 216 | * users are forced to abuse this routine by using it to submit URBs for |
211 | * an interrupt URB (with the default interval) if the target is an | 217 | * interrupt endpoints. We will take the liberty of creating an interrupt URB |
212 | * interrupt endpoint. | 218 | * (with the default interval) if the target is an interrupt endpoint. |
213 | */ | 219 | */ |
214 | int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, | 220 | int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, |
215 | void *data, int len, int *actual_length, int timeout) | 221 | void *data, int len, int *actual_length, int timeout) |
216 | { | 222 | { |
217 | struct urb *urb; | 223 | struct urb *urb; |
218 | struct usb_host_endpoint *ep; | 224 | struct usb_host_endpoint *ep; |
@@ -238,29 +244,30 @@ int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, | |||
238 | 244 | ||
239 | return usb_start_wait_urb(urb, timeout, actual_length); | 245 | return usb_start_wait_urb(urb, timeout, actual_length); |
240 | } | 246 | } |
247 | EXPORT_SYMBOL_GPL(usb_bulk_msg); | ||
241 | 248 | ||
242 | /*-------------------------------------------------------------------*/ | 249 | /*-------------------------------------------------------------------*/ |
243 | 250 | ||
244 | static void sg_clean (struct usb_sg_request *io) | 251 | static void sg_clean(struct usb_sg_request *io) |
245 | { | 252 | { |
246 | if (io->urbs) { | 253 | if (io->urbs) { |
247 | while (io->entries--) | 254 | while (io->entries--) |
248 | usb_free_urb (io->urbs [io->entries]); | 255 | usb_free_urb(io->urbs [io->entries]); |
249 | kfree (io->urbs); | 256 | kfree(io->urbs); |
250 | io->urbs = NULL; | 257 | io->urbs = NULL; |
251 | } | 258 | } |
252 | if (io->dev->dev.dma_mask != NULL) | 259 | if (io->dev->dev.dma_mask != NULL) |
253 | usb_buffer_unmap_sg (io->dev, usb_pipein(io->pipe), | 260 | usb_buffer_unmap_sg(io->dev, usb_pipein(io->pipe), |
254 | io->sg, io->nents); | 261 | io->sg, io->nents); |
255 | io->dev = NULL; | 262 | io->dev = NULL; |
256 | } | 263 | } |
257 | 264 | ||
258 | static void sg_complete (struct urb *urb) | 265 | static void sg_complete(struct urb *urb) |
259 | { | 266 | { |
260 | struct usb_sg_request *io = urb->context; | 267 | struct usb_sg_request *io = urb->context; |
261 | int status = urb->status; | 268 | int status = urb->status; |
262 | 269 | ||
263 | spin_lock (&io->lock); | 270 | spin_lock(&io->lock); |
264 | 271 | ||
265 | /* In 2.5 we require hcds' endpoint queues not to progress after fault | 272 | /* In 2.5 we require hcds' endpoint queues not to progress after fault |
266 | * reports, until the completion callback (this!) returns. That lets | 273 | * reports, until the completion callback (this!) returns. That lets |
@@ -276,13 +283,13 @@ static void sg_complete (struct urb *urb) | |||
276 | && (io->status != -ECONNRESET | 283 | && (io->status != -ECONNRESET |
277 | || status != -ECONNRESET) | 284 | || status != -ECONNRESET) |
278 | && urb->actual_length) { | 285 | && urb->actual_length) { |
279 | dev_err (io->dev->bus->controller, | 286 | dev_err(io->dev->bus->controller, |
280 | "dev %s ep%d%s scatterlist error %d/%d\n", | 287 | "dev %s ep%d%s scatterlist error %d/%d\n", |
281 | io->dev->devpath, | 288 | io->dev->devpath, |
282 | usb_endpoint_num(&urb->ep->desc), | 289 | usb_endpoint_num(&urb->ep->desc), |
283 | usb_urb_dir_in(urb) ? "in" : "out", | 290 | usb_urb_dir_in(urb) ? "in" : "out", |
284 | status, io->status); | 291 | status, io->status); |
285 | // BUG (); | 292 | /* BUG (); */ |
286 | } | 293 | } |
287 | 294 | ||
288 | if (io->status == 0 && status && status != -ECONNRESET) { | 295 | if (io->status == 0 && status && status != -ECONNRESET) { |
@@ -294,22 +301,22 @@ static void sg_complete (struct urb *urb) | |||
294 | * unlink pending urbs so they won't rx/tx bad data. | 301 | * unlink pending urbs so they won't rx/tx bad data. |
295 | * careful: unlink can sometimes be synchronous... | 302 | * careful: unlink can sometimes be synchronous... |
296 | */ | 303 | */ |
297 | spin_unlock (&io->lock); | 304 | spin_unlock(&io->lock); |
298 | for (i = 0, found = 0; i < io->entries; i++) { | 305 | for (i = 0, found = 0; i < io->entries; i++) { |
299 | if (!io->urbs [i] || !io->urbs [i]->dev) | 306 | if (!io->urbs [i] || !io->urbs [i]->dev) |
300 | continue; | 307 | continue; |
301 | if (found) { | 308 | if (found) { |
302 | retval = usb_unlink_urb (io->urbs [i]); | 309 | retval = usb_unlink_urb(io->urbs [i]); |
303 | if (retval != -EINPROGRESS && | 310 | if (retval != -EINPROGRESS && |
304 | retval != -ENODEV && | 311 | retval != -ENODEV && |
305 | retval != -EBUSY) | 312 | retval != -EBUSY) |
306 | dev_err (&io->dev->dev, | 313 | dev_err(&io->dev->dev, |
307 | "%s, unlink --> %d\n", | 314 | "%s, unlink --> %d\n", |
308 | __FUNCTION__, retval); | 315 | __FUNCTION__, retval); |
309 | } else if (urb == io->urbs [i]) | 316 | } else if (urb == io->urbs [i]) |
310 | found = 1; | 317 | found = 1; |
311 | } | 318 | } |
312 | spin_lock (&io->lock); | 319 | spin_lock(&io->lock); |
313 | } | 320 | } |
314 | urb->dev = NULL; | 321 | urb->dev = NULL; |
315 | 322 | ||
@@ -317,9 +324,9 @@ static void sg_complete (struct urb *urb) | |||
317 | io->bytes += urb->actual_length; | 324 | io->bytes += urb->actual_length; |
318 | io->count--; | 325 | io->count--; |
319 | if (!io->count) | 326 | if (!io->count) |
320 | complete (&io->complete); | 327 | complete(&io->complete); |
321 | 328 | ||
322 | spin_unlock (&io->lock); | 329 | spin_unlock(&io->lock); |
323 | } | 330 | } |
324 | 331 | ||
325 | 332 | ||
@@ -348,28 +355,21 @@ static void sg_complete (struct urb *urb) | |||
348 | * The request may be canceled with usb_sg_cancel(), either before or after | 355 | * The request may be canceled with usb_sg_cancel(), either before or after |
349 | * usb_sg_wait() is called. | 356 | * usb_sg_wait() is called. |
350 | */ | 357 | */ |
351 | int usb_sg_init ( | 358 | int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev, |
352 | struct usb_sg_request *io, | 359 | unsigned pipe, unsigned period, struct scatterlist *sg, |
353 | struct usb_device *dev, | 360 | int nents, size_t length, gfp_t mem_flags) |
354 | unsigned pipe, | ||
355 | unsigned period, | ||
356 | struct scatterlist *sg, | ||
357 | int nents, | ||
358 | size_t length, | ||
359 | gfp_t mem_flags | ||
360 | ) | ||
361 | { | 361 | { |
362 | int i; | 362 | int i; |
363 | int urb_flags; | 363 | int urb_flags; |
364 | int dma; | 364 | int dma; |
365 | 365 | ||
366 | if (!io || !dev || !sg | 366 | if (!io || !dev || !sg |
367 | || usb_pipecontrol (pipe) | 367 | || usb_pipecontrol(pipe) |
368 | || usb_pipeisoc (pipe) | 368 | || usb_pipeisoc(pipe) |
369 | || nents <= 0) | 369 | || nents <= 0) |
370 | return -EINVAL; | 370 | return -EINVAL; |
371 | 371 | ||
372 | spin_lock_init (&io->lock); | 372 | spin_lock_init(&io->lock); |
373 | io->dev = dev; | 373 | io->dev = dev; |
374 | io->pipe = pipe; | 374 | io->pipe = pipe; |
375 | io->sg = sg; | 375 | io->sg = sg; |
@@ -381,7 +381,7 @@ int usb_sg_init ( | |||
381 | dma = (dev->dev.dma_mask != NULL); | 381 | dma = (dev->dev.dma_mask != NULL); |
382 | if (dma) | 382 | if (dma) |
383 | io->entries = usb_buffer_map_sg(dev, usb_pipein(pipe), | 383 | io->entries = usb_buffer_map_sg(dev, usb_pipein(pipe), |
384 | sg, nents); | 384 | sg, nents); |
385 | else | 385 | else |
386 | io->entries = nents; | 386 | io->entries = nents; |
387 | 387 | ||
@@ -390,30 +390,30 @@ int usb_sg_init ( | |||
390 | return io->entries; | 390 | return io->entries; |
391 | 391 | ||
392 | io->count = io->entries; | 392 | io->count = io->entries; |
393 | io->urbs = kmalloc (io->entries * sizeof *io->urbs, mem_flags); | 393 | io->urbs = kmalloc(io->entries * sizeof *io->urbs, mem_flags); |
394 | if (!io->urbs) | 394 | if (!io->urbs) |
395 | goto nomem; | 395 | goto nomem; |
396 | 396 | ||
397 | urb_flags = URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT; | 397 | urb_flags = URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT; |
398 | if (usb_pipein (pipe)) | 398 | if (usb_pipein(pipe)) |
399 | urb_flags |= URB_SHORT_NOT_OK; | 399 | urb_flags |= URB_SHORT_NOT_OK; |
400 | 400 | ||
401 | for (i = 0; i < io->entries; i++) { | 401 | for (i = 0; i < io->entries; i++) { |
402 | unsigned len; | 402 | unsigned len; |
403 | 403 | ||
404 | io->urbs [i] = usb_alloc_urb (0, mem_flags); | 404 | io->urbs[i] = usb_alloc_urb(0, mem_flags); |
405 | if (!io->urbs [i]) { | 405 | if (!io->urbs[i]) { |
406 | io->entries = i; | 406 | io->entries = i; |
407 | goto nomem; | 407 | goto nomem; |
408 | } | 408 | } |
409 | 409 | ||
410 | io->urbs [i]->dev = NULL; | 410 | io->urbs[i]->dev = NULL; |
411 | io->urbs [i]->pipe = pipe; | 411 | io->urbs[i]->pipe = pipe; |
412 | io->urbs [i]->interval = period; | 412 | io->urbs[i]->interval = period; |
413 | io->urbs [i]->transfer_flags = urb_flags; | 413 | io->urbs[i]->transfer_flags = urb_flags; |
414 | 414 | ||
415 | io->urbs [i]->complete = sg_complete; | 415 | io->urbs[i]->complete = sg_complete; |
416 | io->urbs [i]->context = io; | 416 | io->urbs[i]->context = io; |
417 | 417 | ||
418 | /* | 418 | /* |
419 | * Some systems need to revert to PIO when DMA is temporarily | 419 | * Some systems need to revert to PIO when DMA is temporarily |
@@ -432,8 +432,8 @@ int usb_sg_init ( | |||
432 | * to prevent stale pointers and to help spot bugs. | 432 | * to prevent stale pointers and to help spot bugs. |
433 | */ | 433 | */ |
434 | if (dma) { | 434 | if (dma) { |
435 | io->urbs [i]->transfer_dma = sg_dma_address (sg + i); | 435 | io->urbs[i]->transfer_dma = sg_dma_address(sg + i); |
436 | len = sg_dma_len (sg + i); | 436 | len = sg_dma_len(sg + i); |
437 | #if defined(CONFIG_HIGHMEM) || defined(CONFIG_GART_IOMMU) | 437 | #if defined(CONFIG_HIGHMEM) || defined(CONFIG_GART_IOMMU) |
438 | io->urbs[i]->transfer_buffer = NULL; | 438 | io->urbs[i]->transfer_buffer = NULL; |
439 | #else | 439 | #else |
@@ -441,31 +441,31 @@ int usb_sg_init ( | |||
441 | #endif | 441 | #endif |
442 | } else { | 442 | } else { |
443 | /* hc may use _only_ transfer_buffer */ | 443 | /* hc may use _only_ transfer_buffer */ |
444 | io->urbs [i]->transfer_buffer = sg_virt(&sg[i]); | 444 | io->urbs[i]->transfer_buffer = sg_virt(&sg[i]); |
445 | len = sg [i].length; | 445 | len = sg[i].length; |
446 | } | 446 | } |
447 | 447 | ||
448 | if (length) { | 448 | if (length) { |
449 | len = min_t (unsigned, len, length); | 449 | len = min_t(unsigned, len, length); |
450 | length -= len; | 450 | length -= len; |
451 | if (length == 0) | 451 | if (length == 0) |
452 | io->entries = i + 1; | 452 | io->entries = i + 1; |
453 | } | 453 | } |
454 | io->urbs [i]->transfer_buffer_length = len; | 454 | io->urbs[i]->transfer_buffer_length = len; |
455 | } | 455 | } |
456 | io->urbs [--i]->transfer_flags &= ~URB_NO_INTERRUPT; | 456 | io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT; |
457 | 457 | ||
458 | /* transaction state */ | 458 | /* transaction state */ |
459 | io->status = 0; | 459 | io->status = 0; |
460 | io->bytes = 0; | 460 | io->bytes = 0; |
461 | init_completion (&io->complete); | 461 | init_completion(&io->complete); |
462 | return 0; | 462 | return 0; |
463 | 463 | ||
464 | nomem: | 464 | nomem: |
465 | sg_clean (io); | 465 | sg_clean(io); |
466 | return -ENOMEM; | 466 | return -ENOMEM; |
467 | } | 467 | } |
468 | 468 | EXPORT_SYMBOL_GPL(usb_sg_init); | |
469 | 469 | ||
470 | /** | 470 | /** |
471 | * usb_sg_wait - synchronously execute scatter/gather request | 471 | * usb_sg_wait - synchronously execute scatter/gather request |
@@ -506,31 +506,32 @@ nomem: | |||
506 | * speed interrupt endpoints, which allow at most one packet per millisecond, | 506 | * speed interrupt endpoints, which allow at most one packet per millisecond, |
507 | * of at most 8 or 64 bytes (respectively). | 507 | * of at most 8 or 64 bytes (respectively). |
508 | */ | 508 | */ |
509 | void usb_sg_wait (struct usb_sg_request *io) | 509 | void usb_sg_wait(struct usb_sg_request *io) |
510 | { | 510 | { |
511 | int i, entries = io->entries; | 511 | int i; |
512 | int entries = io->entries; | ||
512 | 513 | ||
513 | /* queue the urbs. */ | 514 | /* queue the urbs. */ |
514 | spin_lock_irq (&io->lock); | 515 | spin_lock_irq(&io->lock); |
515 | i = 0; | 516 | i = 0; |
516 | while (i < entries && !io->status) { | 517 | while (i < entries && !io->status) { |
517 | int retval; | 518 | int retval; |
518 | 519 | ||
519 | io->urbs [i]->dev = io->dev; | 520 | io->urbs[i]->dev = io->dev; |
520 | retval = usb_submit_urb (io->urbs [i], GFP_ATOMIC); | 521 | retval = usb_submit_urb(io->urbs [i], GFP_ATOMIC); |
521 | 522 | ||
522 | /* after we submit, let completions or cancelations fire; | 523 | /* after we submit, let completions or cancelations fire; |
523 | * we handshake using io->status. | 524 | * we handshake using io->status. |
524 | */ | 525 | */ |
525 | spin_unlock_irq (&io->lock); | 526 | spin_unlock_irq(&io->lock); |
526 | switch (retval) { | 527 | switch (retval) { |
527 | /* maybe we retrying will recover */ | 528 | /* maybe we retrying will recover */ |
528 | case -ENXIO: // hc didn't queue this one | 529 | case -ENXIO: /* hc didn't queue this one */ |
529 | case -EAGAIN: | 530 | case -EAGAIN: |
530 | case -ENOMEM: | 531 | case -ENOMEM: |
531 | io->urbs[i]->dev = NULL; | 532 | io->urbs[i]->dev = NULL; |
532 | retval = 0; | 533 | retval = 0; |
533 | yield (); | 534 | yield(); |
534 | break; | 535 | break; |
535 | 536 | ||
536 | /* no error? continue immediately. | 537 | /* no error? continue immediately. |
@@ -541,34 +542,35 @@ void usb_sg_wait (struct usb_sg_request *io) | |||
541 | */ | 542 | */ |
542 | case 0: | 543 | case 0: |
543 | ++i; | 544 | ++i; |
544 | cpu_relax (); | 545 | cpu_relax(); |
545 | break; | 546 | break; |
546 | 547 | ||
547 | /* fail any uncompleted urbs */ | 548 | /* fail any uncompleted urbs */ |
548 | default: | 549 | default: |
549 | io->urbs [i]->dev = NULL; | 550 | io->urbs[i]->dev = NULL; |
550 | io->urbs [i]->status = retval; | 551 | io->urbs[i]->status = retval; |
551 | dev_dbg (&io->dev->dev, "%s, submit --> %d\n", | 552 | dev_dbg(&io->dev->dev, "%s, submit --> %d\n", |
552 | __FUNCTION__, retval); | 553 | __FUNCTION__, retval); |
553 | usb_sg_cancel (io); | 554 | usb_sg_cancel(io); |
554 | } | 555 | } |
555 | spin_lock_irq (&io->lock); | 556 | spin_lock_irq(&io->lock); |
556 | if (retval && (io->status == 0 || io->status == -ECONNRESET)) | 557 | if (retval && (io->status == 0 || io->status == -ECONNRESET)) |
557 | io->status = retval; | 558 | io->status = retval; |
558 | } | 559 | } |
559 | io->count -= entries - i; | 560 | io->count -= entries - i; |
560 | if (io->count == 0) | 561 | if (io->count == 0) |
561 | complete (&io->complete); | 562 | complete(&io->complete); |
562 | spin_unlock_irq (&io->lock); | 563 | spin_unlock_irq(&io->lock); |
563 | 564 | ||
564 | /* OK, yes, this could be packaged as non-blocking. | 565 | /* OK, yes, this could be packaged as non-blocking. |
565 | * So could the submit loop above ... but it's easier to | 566 | * So could the submit loop above ... but it's easier to |
566 | * solve neither problem than to solve both! | 567 | * solve neither problem than to solve both! |
567 | */ | 568 | */ |
568 | wait_for_completion (&io->complete); | 569 | wait_for_completion(&io->complete); |
569 | 570 | ||
570 | sg_clean (io); | 571 | sg_clean(io); |
571 | } | 572 | } |
573 | EXPORT_SYMBOL_GPL(usb_sg_wait); | ||
572 | 574 | ||
573 | /** | 575 | /** |
574 | * usb_sg_cancel - stop scatter/gather i/o issued by usb_sg_wait() | 576 | * usb_sg_cancel - stop scatter/gather i/o issued by usb_sg_wait() |
@@ -578,32 +580,33 @@ void usb_sg_wait (struct usb_sg_request *io) | |||
578 | * It can also prevents one initialized by usb_sg_init() from starting, | 580 | * It can also prevents one initialized by usb_sg_init() from starting, |
579 | * so that call just frees resources allocated to the request. | 581 | * so that call just frees resources allocated to the request. |
580 | */ | 582 | */ |
581 | void usb_sg_cancel (struct usb_sg_request *io) | 583 | void usb_sg_cancel(struct usb_sg_request *io) |
582 | { | 584 | { |
583 | unsigned long flags; | 585 | unsigned long flags; |
584 | 586 | ||
585 | spin_lock_irqsave (&io->lock, flags); | 587 | spin_lock_irqsave(&io->lock, flags); |
586 | 588 | ||
587 | /* shut everything down, if it didn't already */ | 589 | /* shut everything down, if it didn't already */ |
588 | if (!io->status) { | 590 | if (!io->status) { |
589 | int i; | 591 | int i; |
590 | 592 | ||
591 | io->status = -ECONNRESET; | 593 | io->status = -ECONNRESET; |
592 | spin_unlock (&io->lock); | 594 | spin_unlock(&io->lock); |
593 | for (i = 0; i < io->entries; i++) { | 595 | for (i = 0; i < io->entries; i++) { |
594 | int retval; | 596 | int retval; |
595 | 597 | ||
596 | if (!io->urbs [i]->dev) | 598 | if (!io->urbs [i]->dev) |
597 | continue; | 599 | continue; |
598 | retval = usb_unlink_urb (io->urbs [i]); | 600 | retval = usb_unlink_urb(io->urbs [i]); |
599 | if (retval != -EINPROGRESS && retval != -EBUSY) | 601 | if (retval != -EINPROGRESS && retval != -EBUSY) |
600 | dev_warn (&io->dev->dev, "%s, unlink --> %d\n", | 602 | dev_warn(&io->dev->dev, "%s, unlink --> %d\n", |
601 | __FUNCTION__, retval); | 603 | __FUNCTION__, retval); |
602 | } | 604 | } |
603 | spin_lock (&io->lock); | 605 | spin_lock(&io->lock); |
604 | } | 606 | } |
605 | spin_unlock_irqrestore (&io->lock, flags); | 607 | spin_unlock_irqrestore(&io->lock, flags); |
606 | } | 608 | } |
609 | EXPORT_SYMBOL_GPL(usb_sg_cancel); | ||
607 | 610 | ||
608 | /*-------------------------------------------------------------------*/ | 611 | /*-------------------------------------------------------------------*/ |
609 | 612 | ||
@@ -629,12 +632,13 @@ void usb_sg_cancel (struct usb_sg_request *io) | |||
629 | * Returns the number of bytes received on success, or else the status code | 632 | * Returns the number of bytes received on success, or else the status code |
630 | * returned by the underlying usb_control_msg() call. | 633 | * returned by the underlying usb_control_msg() call. |
631 | */ | 634 | */ |
632 | int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char index, void *buf, int size) | 635 | int usb_get_descriptor(struct usb_device *dev, unsigned char type, |
636 | unsigned char index, void *buf, int size) | ||
633 | { | 637 | { |
634 | int i; | 638 | int i; |
635 | int result; | 639 | int result; |
636 | 640 | ||
637 | memset(buf,0,size); // Make sure we parse really received data | 641 | memset(buf, 0, size); /* Make sure we parse really received data */ |
638 | 642 | ||
639 | for (i = 0; i < 3; ++i) { | 643 | for (i = 0; i < 3; ++i) { |
640 | /* retry on length 0 or error; some devices are flakey */ | 644 | /* retry on length 0 or error; some devices are flakey */ |
@@ -652,6 +656,7 @@ int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char | |||
652 | } | 656 | } |
653 | return result; | 657 | return result; |
654 | } | 658 | } |
659 | EXPORT_SYMBOL_GPL(usb_get_descriptor); | ||
655 | 660 | ||
656 | /** | 661 | /** |
657 | * usb_get_string - gets a string descriptor | 662 | * usb_get_string - gets a string descriptor |
@@ -708,7 +713,7 @@ static void usb_try_string_workarounds(unsigned char *buf, int *length) | |||
708 | } | 713 | } |
709 | 714 | ||
710 | static int usb_string_sub(struct usb_device *dev, unsigned int langid, | 715 | static int usb_string_sub(struct usb_device *dev, unsigned int langid, |
711 | unsigned int index, unsigned char *buf) | 716 | unsigned int index, unsigned char *buf) |
712 | { | 717 | { |
713 | int rc; | 718 | int rc; |
714 | 719 | ||
@@ -751,7 +756,7 @@ static int usb_string_sub(struct usb_device *dev, unsigned int langid, | |||
751 | * @buf: where to put the string | 756 | * @buf: where to put the string |
752 | * @size: how big is "buf"? | 757 | * @size: how big is "buf"? |
753 | * Context: !in_interrupt () | 758 | * Context: !in_interrupt () |
754 | * | 759 | * |
755 | * This converts the UTF-16LE encoded strings returned by devices, from | 760 | * This converts the UTF-16LE encoded strings returned by devices, from |
756 | * usb_get_string_descriptor(), to null-terminated ISO-8859-1 encoded ones | 761 | * usb_get_string_descriptor(), to null-terminated ISO-8859-1 encoded ones |
757 | * that are more usable in most kernel contexts. Note that all characters | 762 | * that are more usable in most kernel contexts. Note that all characters |
@@ -787,23 +792,23 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) | |||
787 | if (!dev->have_langid) { | 792 | if (!dev->have_langid) { |
788 | err = usb_string_sub(dev, 0, 0, tbuf); | 793 | err = usb_string_sub(dev, 0, 0, tbuf); |
789 | if (err < 0) { | 794 | if (err < 0) { |
790 | dev_err (&dev->dev, | 795 | dev_err(&dev->dev, |
791 | "string descriptor 0 read error: %d\n", | 796 | "string descriptor 0 read error: %d\n", |
792 | err); | 797 | err); |
793 | goto errout; | 798 | goto errout; |
794 | } else if (err < 4) { | 799 | } else if (err < 4) { |
795 | dev_err (&dev->dev, "string descriptor 0 too short\n"); | 800 | dev_err(&dev->dev, "string descriptor 0 too short\n"); |
796 | err = -EINVAL; | 801 | err = -EINVAL; |
797 | goto errout; | 802 | goto errout; |
798 | } else { | 803 | } else { |
799 | dev->have_langid = 1; | 804 | dev->have_langid = 1; |
800 | dev->string_langid = tbuf[2] | (tbuf[3]<< 8); | 805 | dev->string_langid = tbuf[2] | (tbuf[3] << 8); |
801 | /* always use the first langid listed */ | 806 | /* always use the first langid listed */ |
802 | dev_dbg (&dev->dev, "default language 0x%04x\n", | 807 | dev_dbg(&dev->dev, "default language 0x%04x\n", |
803 | dev->string_langid); | 808 | dev->string_langid); |
804 | } | 809 | } |
805 | } | 810 | } |
806 | 811 | ||
807 | err = usb_string_sub(dev, dev->string_langid, index, tbuf); | 812 | err = usb_string_sub(dev, dev->string_langid, index, tbuf); |
808 | if (err < 0) | 813 | if (err < 0) |
809 | goto errout; | 814 | goto errout; |
@@ -821,12 +826,15 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) | |||
821 | err = idx; | 826 | err = idx; |
822 | 827 | ||
823 | if (tbuf[1] != USB_DT_STRING) | 828 | if (tbuf[1] != USB_DT_STRING) |
824 | dev_dbg(&dev->dev, "wrong descriptor type %02x for string %d (\"%s\")\n", tbuf[1], index, buf); | 829 | dev_dbg(&dev->dev, |
830 | "wrong descriptor type %02x for string %d (\"%s\")\n", | ||
831 | tbuf[1], index, buf); | ||
825 | 832 | ||
826 | errout: | 833 | errout: |
827 | kfree(tbuf); | 834 | kfree(tbuf); |
828 | return err; | 835 | return err; |
829 | } | 836 | } |
837 | EXPORT_SYMBOL_GPL(usb_string); | ||
830 | 838 | ||
831 | /** | 839 | /** |
832 | * usb_cache_string - read a string descriptor and cache it for later use | 840 | * usb_cache_string - read a string descriptor and cache it for later use |
@@ -842,9 +850,15 @@ char *usb_cache_string(struct usb_device *udev, int index) | |||
842 | char *smallbuf = NULL; | 850 | char *smallbuf = NULL; |
843 | int len; | 851 | int len; |
844 | 852 | ||
845 | if (index > 0 && (buf = kmalloc(256, GFP_KERNEL)) != NULL) { | 853 | if (index <= 0) |
846 | if ((len = usb_string(udev, index, buf, 256)) > 0) { | 854 | return NULL; |
847 | if ((smallbuf = kmalloc(++len, GFP_KERNEL)) == NULL) | 855 | |
856 | buf = kmalloc(256, GFP_KERNEL); | ||
857 | if (buf) { | ||
858 | len = usb_string(udev, index, buf, 256); | ||
859 | if (len > 0) { | ||
860 | smallbuf = kmalloc(++len, GFP_KERNEL); | ||
861 | if (!smallbuf) | ||
848 | return buf; | 862 | return buf; |
849 | memcpy(smallbuf, buf, len); | 863 | memcpy(smallbuf, buf, len); |
850 | } | 864 | } |
@@ -883,7 +897,7 @@ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size) | |||
883 | return -ENOMEM; | 897 | return -ENOMEM; |
884 | 898 | ||
885 | ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, size); | 899 | ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, size); |
886 | if (ret >= 0) | 900 | if (ret >= 0) |
887 | memcpy(&dev->descriptor, desc, size); | 901 | memcpy(&dev->descriptor, desc, size); |
888 | kfree(desc); | 902 | kfree(desc); |
889 | return ret; | 903 | return ret; |
@@ -927,6 +941,7 @@ int usb_get_status(struct usb_device *dev, int type, int target, void *data) | |||
927 | kfree(status); | 941 | kfree(status); |
928 | return ret; | 942 | return ret; |
929 | } | 943 | } |
944 | EXPORT_SYMBOL_GPL(usb_get_status); | ||
930 | 945 | ||
931 | /** | 946 | /** |
932 | * usb_clear_halt - tells device to clear endpoint halt/stall condition | 947 | * usb_clear_halt - tells device to clear endpoint halt/stall condition |
@@ -955,8 +970,8 @@ int usb_clear_halt(struct usb_device *dev, int pipe) | |||
955 | { | 970 | { |
956 | int result; | 971 | int result; |
957 | int endp = usb_pipeendpoint(pipe); | 972 | int endp = usb_pipeendpoint(pipe); |
958 | 973 | ||
959 | if (usb_pipein (pipe)) | 974 | if (usb_pipein(pipe)) |
960 | endp |= USB_DIR_IN; | 975 | endp |= USB_DIR_IN; |
961 | 976 | ||
962 | /* we don't care if it wasn't halted first. in fact some devices | 977 | /* we don't care if it wasn't halted first. in fact some devices |
@@ -985,6 +1000,7 @@ int usb_clear_halt(struct usb_device *dev, int pipe) | |||
985 | 1000 | ||
986 | return 0; | 1001 | return 0; |
987 | } | 1002 | } |
1003 | EXPORT_SYMBOL_GPL(usb_clear_halt); | ||
988 | 1004 | ||
989 | /** | 1005 | /** |
990 | * usb_disable_endpoint -- Disable an endpoint by address | 1006 | * usb_disable_endpoint -- Disable an endpoint by address |
@@ -1038,7 +1054,7 @@ void usb_disable_interface(struct usb_device *dev, struct usb_interface *intf) | |||
1038 | } | 1054 | } |
1039 | } | 1055 | } |
1040 | 1056 | ||
1041 | /* | 1057 | /** |
1042 | * usb_disable_device - Disable all the endpoints for a USB device | 1058 | * usb_disable_device - Disable all the endpoints for a USB device |
1043 | * @dev: the device whose endpoints are being disabled | 1059 | * @dev: the device whose endpoints are being disabled |
1044 | * @skip_ep0: 0 to disable endpoint 0, 1 to skip it. | 1060 | * @skip_ep0: 0 to disable endpoint 0, 1 to skip it. |
@@ -1053,7 +1069,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) | |||
1053 | int i; | 1069 | int i; |
1054 | 1070 | ||
1055 | dev_dbg(&dev->dev, "%s nuking %s URBs\n", __FUNCTION__, | 1071 | dev_dbg(&dev->dev, "%s nuking %s URBs\n", __FUNCTION__, |
1056 | skip_ep0 ? "non-ep0" : "all"); | 1072 | skip_ep0 ? "non-ep0" : "all"); |
1057 | for (i = skip_ep0; i < 16; ++i) { | 1073 | for (i = skip_ep0; i < 16; ++i) { |
1058 | usb_disable_endpoint(dev, i); | 1074 | usb_disable_endpoint(dev, i); |
1059 | usb_disable_endpoint(dev, i + USB_DIR_IN); | 1075 | usb_disable_endpoint(dev, i + USB_DIR_IN); |
@@ -1071,17 +1087,17 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) | |||
1071 | interface = dev->actconfig->interface[i]; | 1087 | interface = dev->actconfig->interface[i]; |
1072 | if (!device_is_registered(&interface->dev)) | 1088 | if (!device_is_registered(&interface->dev)) |
1073 | continue; | 1089 | continue; |
1074 | dev_dbg (&dev->dev, "unregistering interface %s\n", | 1090 | dev_dbg(&dev->dev, "unregistering interface %s\n", |
1075 | interface->dev.bus_id); | 1091 | interface->dev.bus_id); |
1076 | usb_remove_sysfs_intf_files(interface); | 1092 | usb_remove_sysfs_intf_files(interface); |
1077 | device_del (&interface->dev); | 1093 | device_del(&interface->dev); |
1078 | } | 1094 | } |
1079 | 1095 | ||
1080 | /* Now that the interfaces are unbound, nobody should | 1096 | /* Now that the interfaces are unbound, nobody should |
1081 | * try to access them. | 1097 | * try to access them. |
1082 | */ | 1098 | */ |
1083 | for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { | 1099 | for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { |
1084 | put_device (&dev->actconfig->interface[i]->dev); | 1100 | put_device(&dev->actconfig->interface[i]->dev); |
1085 | dev->actconfig->interface[i] = NULL; | 1101 | dev->actconfig->interface[i] = NULL; |
1086 | } | 1102 | } |
1087 | dev->actconfig = NULL; | 1103 | dev->actconfig = NULL; |
@@ -1090,8 +1106,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) | |||
1090 | } | 1106 | } |
1091 | } | 1107 | } |
1092 | 1108 | ||
1093 | 1109 | /** | |
1094 | /* | ||
1095 | * usb_enable_endpoint - Enable an endpoint for USB communications | 1110 | * usb_enable_endpoint - Enable an endpoint for USB communications |
1096 | * @dev: the device whose interface is being enabled | 1111 | * @dev: the device whose interface is being enabled |
1097 | * @ep: the endpoint | 1112 | * @ep: the endpoint |
@@ -1116,7 +1131,7 @@ void usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep) | |||
1116 | ep->enabled = 1; | 1131 | ep->enabled = 1; |
1117 | } | 1132 | } |
1118 | 1133 | ||
1119 | /* | 1134 | /** |
1120 | * usb_enable_interface - Enable all the endpoints for an interface | 1135 | * usb_enable_interface - Enable all the endpoints for an interface |
1121 | * @dev: the device whose interface is being enabled | 1136 | * @dev: the device whose interface is being enabled |
1122 | * @intf: pointer to the interface descriptor | 1137 | * @intf: pointer to the interface descriptor |
@@ -1172,6 +1187,8 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) | |||
1172 | struct usb_host_interface *alt; | 1187 | struct usb_host_interface *alt; |
1173 | int ret; | 1188 | int ret; |
1174 | int manual = 0; | 1189 | int manual = 0; |
1190 | unsigned int epaddr; | ||
1191 | unsigned int pipe; | ||
1175 | 1192 | ||
1176 | if (dev->state == USB_STATE_SUSPENDED) | 1193 | if (dev->state == USB_STATE_SUSPENDED) |
1177 | return -EHOSTUNREACH; | 1194 | return -EHOSTUNREACH; |
@@ -1226,11 +1243,11 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) | |||
1226 | int i; | 1243 | int i; |
1227 | 1244 | ||
1228 | for (i = 0; i < alt->desc.bNumEndpoints; i++) { | 1245 | for (i = 0; i < alt->desc.bNumEndpoints; i++) { |
1229 | unsigned int epaddr = | 1246 | epaddr = alt->endpoint[i].desc.bEndpointAddress; |
1230 | alt->endpoint[i].desc.bEndpointAddress; | 1247 | pipe = __create_pipe(dev, |
1231 | unsigned int pipe = | 1248 | USB_ENDPOINT_NUMBER_MASK & epaddr) | |
1232 | __create_pipe(dev, USB_ENDPOINT_NUMBER_MASK & epaddr) | 1249 | (usb_endpoint_out(epaddr) ? |
1233 | | (usb_endpoint_out(epaddr) ? USB_DIR_OUT : USB_DIR_IN); | 1250 | USB_DIR_OUT : USB_DIR_IN); |
1234 | 1251 | ||
1235 | usb_clear_halt(dev, pipe); | 1252 | usb_clear_halt(dev, pipe); |
1236 | } | 1253 | } |
@@ -1253,6 +1270,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) | |||
1253 | 1270 | ||
1254 | return 0; | 1271 | return 0; |
1255 | } | 1272 | } |
1273 | EXPORT_SYMBOL_GPL(usb_set_interface); | ||
1256 | 1274 | ||
1257 | /** | 1275 | /** |
1258 | * usb_reset_configuration - lightweight device reset | 1276 | * usb_reset_configuration - lightweight device reset |
@@ -1328,6 +1346,7 @@ int usb_reset_configuration(struct usb_device *dev) | |||
1328 | } | 1346 | } |
1329 | return 0; | 1347 | return 0; |
1330 | } | 1348 | } |
1349 | EXPORT_SYMBOL_GPL(usb_reset_configuration); | ||
1331 | 1350 | ||
1332 | static void usb_release_interface(struct device *dev) | 1351 | static void usb_release_interface(struct device *dev) |
1333 | { | 1352 | { |
@@ -1357,7 +1376,8 @@ static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
1357 | return -ENOMEM; | 1376 | return -ENOMEM; |
1358 | 1377 | ||
1359 | if (add_uevent_var(env, | 1378 | if (add_uevent_var(env, |
1360 | "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", | 1379 | "MODALIAS=usb:" |
1380 | "v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", | ||
1361 | le16_to_cpu(usb_dev->descriptor.idVendor), | 1381 | le16_to_cpu(usb_dev->descriptor.idVendor), |
1362 | le16_to_cpu(usb_dev->descriptor.idProduct), | 1382 | le16_to_cpu(usb_dev->descriptor.idProduct), |
1363 | le16_to_cpu(usb_dev->descriptor.bcdDevice), | 1383 | le16_to_cpu(usb_dev->descriptor.bcdDevice), |
@@ -1387,8 +1407,8 @@ struct device_type usb_if_device_type = { | |||
1387 | }; | 1407 | }; |
1388 | 1408 | ||
1389 | static struct usb_interface_assoc_descriptor *find_iad(struct usb_device *dev, | 1409 | static struct usb_interface_assoc_descriptor *find_iad(struct usb_device *dev, |
1390 | struct usb_host_config *config, | 1410 | struct usb_host_config *config, |
1391 | u8 inum) | 1411 | u8 inum) |
1392 | { | 1412 | { |
1393 | struct usb_interface_assoc_descriptor *retval = NULL; | 1413 | struct usb_interface_assoc_descriptor *retval = NULL; |
1394 | struct usb_interface_assoc_descriptor *intf_assoc; | 1414 | struct usb_interface_assoc_descriptor *intf_assoc; |
@@ -1415,7 +1435,6 @@ static struct usb_interface_assoc_descriptor *find_iad(struct usb_device *dev, | |||
1415 | return retval; | 1435 | return retval; |
1416 | } | 1436 | } |
1417 | 1437 | ||
1418 | |||
1419 | /* | 1438 | /* |
1420 | * usb_set_configuration - Makes a particular device setting be current | 1439 | * usb_set_configuration - Makes a particular device setting be current |
1421 | * @dev: the device whose configuration is being updated | 1440 | * @dev: the device whose configuration is being updated |
@@ -1533,12 +1552,12 @@ free_interfaces: | |||
1533 | * getting rid of old interfaces means unbinding their drivers. | 1552 | * getting rid of old interfaces means unbinding their drivers. |
1534 | */ | 1553 | */ |
1535 | if (dev->state != USB_STATE_ADDRESS) | 1554 | if (dev->state != USB_STATE_ADDRESS) |
1536 | usb_disable_device (dev, 1); // Skip ep0 | 1555 | usb_disable_device(dev, 1); /* Skip ep0 */ |
1537 | |||
1538 | if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | ||
1539 | USB_REQ_SET_CONFIGURATION, 0, configuration, 0, | ||
1540 | NULL, 0, USB_CTRL_SET_TIMEOUT)) < 0) { | ||
1541 | 1556 | ||
1557 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | ||
1558 | USB_REQ_SET_CONFIGURATION, 0, configuration, 0, | ||
1559 | NULL, 0, USB_CTRL_SET_TIMEOUT); | ||
1560 | if (ret < 0) { | ||
1542 | /* All the old state is gone, so what else can we do? | 1561 | /* All the old state is gone, so what else can we do? |
1543 | * The device is probably useless now anyway. | 1562 | * The device is probably useless now anyway. |
1544 | */ | 1563 | */ |
@@ -1585,11 +1604,11 @@ free_interfaces: | |||
1585 | intf->dev.bus = &usb_bus_type; | 1604 | intf->dev.bus = &usb_bus_type; |
1586 | intf->dev.type = &usb_if_device_type; | 1605 | intf->dev.type = &usb_if_device_type; |
1587 | intf->dev.dma_mask = dev->dev.dma_mask; | 1606 | intf->dev.dma_mask = dev->dev.dma_mask; |
1588 | device_initialize (&intf->dev); | 1607 | device_initialize(&intf->dev); |
1589 | mark_quiesced(intf); | 1608 | mark_quiesced(intf); |
1590 | sprintf (&intf->dev.bus_id[0], "%d-%s:%d.%d", | 1609 | sprintf(&intf->dev.bus_id[0], "%d-%s:%d.%d", |
1591 | dev->bus->busnum, dev->devpath, | 1610 | dev->bus->busnum, dev->devpath, |
1592 | configuration, alt->desc.bInterfaceNumber); | 1611 | configuration, alt->desc.bInterfaceNumber); |
1593 | } | 1612 | } |
1594 | kfree(new_interfaces); | 1613 | kfree(new_interfaces); |
1595 | 1614 | ||
@@ -1605,11 +1624,11 @@ free_interfaces: | |||
1605 | for (i = 0; i < nintf; ++i) { | 1624 | for (i = 0; i < nintf; ++i) { |
1606 | struct usb_interface *intf = cp->interface[i]; | 1625 | struct usb_interface *intf = cp->interface[i]; |
1607 | 1626 | ||
1608 | dev_dbg (&dev->dev, | 1627 | dev_dbg(&dev->dev, |
1609 | "adding %s (config #%d, interface %d)\n", | 1628 | "adding %s (config #%d, interface %d)\n", |
1610 | intf->dev.bus_id, configuration, | 1629 | intf->dev.bus_id, configuration, |
1611 | intf->cur_altsetting->desc.bInterfaceNumber); | 1630 | intf->cur_altsetting->desc.bInterfaceNumber); |
1612 | ret = device_add (&intf->dev); | 1631 | ret = device_add(&intf->dev); |
1613 | if (ret != 0) { | 1632 | if (ret != 0) { |
1614 | dev_err(&dev->dev, "device_add(%s) --> %d\n", | 1633 | dev_err(&dev->dev, "device_add(%s) --> %d\n", |
1615 | intf->dev.bus_id, ret); | 1634 | intf->dev.bus_id, ret); |
@@ -1677,22 +1696,3 @@ int usb_driver_set_configuration(struct usb_device *udev, int config) | |||
1677 | return 0; | 1696 | return 0; |
1678 | } | 1697 | } |
1679 | EXPORT_SYMBOL_GPL(usb_driver_set_configuration); | 1698 | EXPORT_SYMBOL_GPL(usb_driver_set_configuration); |
1680 | |||
1681 | // synchronous request completion model | ||
1682 | EXPORT_SYMBOL(usb_control_msg); | ||
1683 | EXPORT_SYMBOL(usb_bulk_msg); | ||
1684 | |||
1685 | EXPORT_SYMBOL(usb_sg_init); | ||
1686 | EXPORT_SYMBOL(usb_sg_cancel); | ||
1687 | EXPORT_SYMBOL(usb_sg_wait); | ||
1688 | |||
1689 | // synchronous control message convenience routines | ||
1690 | EXPORT_SYMBOL(usb_get_descriptor); | ||
1691 | EXPORT_SYMBOL(usb_get_status); | ||
1692 | EXPORT_SYMBOL(usb_string); | ||
1693 | |||
1694 | // synchronous calls that also maintain usbcore state | ||
1695 | EXPORT_SYMBOL(usb_clear_halt); | ||
1696 | EXPORT_SYMBOL(usb_reset_configuration); | ||
1697 | EXPORT_SYMBOL(usb_set_interface); | ||
1698 | |||
diff --git a/drivers/usb/core/notify.c b/drivers/usb/core/notify.c index 6b36897ca151..7542dce3f5a1 100644 --- a/drivers/usb/core/notify.c +++ b/drivers/usb/core/notify.c | |||
@@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(usb_register_notify); | |||
33 | * usb_unregister_notify - unregister a notifier callback | 33 | * usb_unregister_notify - unregister a notifier callback |
34 | * @nb: pointer to the notifier block for the callback events. | 34 | * @nb: pointer to the notifier block for the callback events. |
35 | * | 35 | * |
36 | * usb_register_notifier() must have been previously called for this function | 36 | * usb_register_notify() must have been previously called for this function |
37 | * to work properly. | 37 | * to work properly. |
38 | */ | 38 | */ |
39 | void usb_unregister_notify(struct notifier_block *nb) | 39 | void usb_unregister_notify(struct notifier_block *nb) |
diff --git a/drivers/usb/core/otg_whitelist.h b/drivers/usb/core/otg_whitelist.h index 7f31a495a25d..e8cdce571bb1 100644 --- a/drivers/usb/core/otg_whitelist.h +++ b/drivers/usb/core/otg_whitelist.h | |||
@@ -14,7 +14,7 @@ | |||
14 | * mostly use of USB_DEVICE() or USB_DEVICE_VER() entries.. | 14 | * mostly use of USB_DEVICE() or USB_DEVICE_VER() entries.. |
15 | * | 15 | * |
16 | * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING! | 16 | * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING! |
17 | */ | 17 | */ |
18 | 18 | ||
19 | static struct usb_device_id whitelist_table [] = { | 19 | static struct usb_device_id whitelist_table [] = { |
20 | 20 | ||
@@ -55,7 +55,7 @@ static int is_targeted(struct usb_device *dev) | |||
55 | return 1; | 55 | return 1; |
56 | 56 | ||
57 | /* HNP test device is _never_ targeted (see OTG spec 6.6.6) */ | 57 | /* HNP test device is _never_ targeted (see OTG spec 6.6.6) */ |
58 | if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a && | 58 | if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a && |
59 | le16_to_cpu(dev->descriptor.idProduct) == 0xbadd)) | 59 | le16_to_cpu(dev->descriptor.idProduct) == 0xbadd)) |
60 | return 0; | 60 | return 0; |
61 | 61 | ||
@@ -86,7 +86,7 @@ static int is_targeted(struct usb_device *dev) | |||
86 | continue; | 86 | continue; |
87 | 87 | ||
88 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && | 88 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && |
89 | (id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass)) | 89 | (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass)) |
90 | continue; | 90 | continue; |
91 | 91 | ||
92 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && | 92 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && |
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 32bd130b1eed..a37ccbd1e007 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -72,7 +72,7 @@ set_bConfigurationValue(struct device *dev, struct device_attribute *attr, | |||
72 | return (value < 0) ? value : count; | 72 | return (value < 0) ? value : count; |
73 | } | 73 | } |
74 | 74 | ||
75 | static DEVICE_ATTR(bConfigurationValue, S_IRUGO | S_IWUSR, | 75 | static DEVICE_ATTR(bConfigurationValue, S_IRUGO | S_IWUSR, |
76 | show_bConfigurationValue, set_bConfigurationValue); | 76 | show_bConfigurationValue, set_bConfigurationValue); |
77 | 77 | ||
78 | /* String fields */ | 78 | /* String fields */ |
@@ -249,6 +249,41 @@ static void remove_persist_attributes(struct device *dev) | |||
249 | #ifdef CONFIG_USB_SUSPEND | 249 | #ifdef CONFIG_USB_SUSPEND |
250 | 250 | ||
251 | static ssize_t | 251 | static ssize_t |
252 | show_connected_duration(struct device *dev, struct device_attribute *attr, | ||
253 | char *buf) | ||
254 | { | ||
255 | struct usb_device *udev = to_usb_device(dev); | ||
256 | |||
257 | return sprintf(buf, "%u\n", | ||
258 | jiffies_to_msecs(jiffies - udev->connect_time)); | ||
259 | } | ||
260 | |||
261 | static DEVICE_ATTR(connected_duration, S_IRUGO, show_connected_duration, NULL); | ||
262 | |||
263 | /* | ||
264 | * If the device is resumed, the last time the device was suspended has | ||
265 | * been pre-subtracted from active_duration. We add the current time to | ||
266 | * get the duration that the device was actually active. | ||
267 | * | ||
268 | * If the device is suspended, the active_duration is up-to-date. | ||
269 | */ | ||
270 | static ssize_t | ||
271 | show_active_duration(struct device *dev, struct device_attribute *attr, | ||
272 | char *buf) | ||
273 | { | ||
274 | struct usb_device *udev = to_usb_device(dev); | ||
275 | int duration; | ||
276 | |||
277 | if (udev->state != USB_STATE_SUSPENDED) | ||
278 | duration = jiffies_to_msecs(jiffies + udev->active_duration); | ||
279 | else | ||
280 | duration = jiffies_to_msecs(udev->active_duration); | ||
281 | return sprintf(buf, "%u\n", duration); | ||
282 | } | ||
283 | |||
284 | static DEVICE_ATTR(active_duration, S_IRUGO, show_active_duration, NULL); | ||
285 | |||
286 | static ssize_t | ||
252 | show_autosuspend(struct device *dev, struct device_attribute *attr, char *buf) | 287 | show_autosuspend(struct device *dev, struct device_attribute *attr, char *buf) |
253 | { | 288 | { |
254 | struct usb_device *udev = to_usb_device(dev); | 289 | struct usb_device *udev = to_usb_device(dev); |
@@ -365,6 +400,14 @@ static int add_power_attributes(struct device *dev) | |||
365 | rc = sysfs_add_file_to_group(&dev->kobj, | 400 | rc = sysfs_add_file_to_group(&dev->kobj, |
366 | &dev_attr_level.attr, | 401 | &dev_attr_level.attr, |
367 | power_group); | 402 | power_group); |
403 | if (rc == 0) | ||
404 | rc = sysfs_add_file_to_group(&dev->kobj, | ||
405 | &dev_attr_connected_duration.attr, | ||
406 | power_group); | ||
407 | if (rc == 0) | ||
408 | rc = sysfs_add_file_to_group(&dev->kobj, | ||
409 | &dev_attr_active_duration.attr, | ||
410 | power_group); | ||
368 | } | 411 | } |
369 | return rc; | 412 | return rc; |
370 | } | 413 | } |
@@ -372,6 +415,12 @@ static int add_power_attributes(struct device *dev) | |||
372 | static void remove_power_attributes(struct device *dev) | 415 | static void remove_power_attributes(struct device *dev) |
373 | { | 416 | { |
374 | sysfs_remove_file_from_group(&dev->kobj, | 417 | sysfs_remove_file_from_group(&dev->kobj, |
418 | &dev_attr_active_duration.attr, | ||
419 | power_group); | ||
420 | sysfs_remove_file_from_group(&dev->kobj, | ||
421 | &dev_attr_connected_duration.attr, | ||
422 | power_group); | ||
423 | sysfs_remove_file_from_group(&dev->kobj, | ||
375 | &dev_attr_level.attr, | 424 | &dev_attr_level.attr, |
376 | power_group); | 425 | power_group); |
377 | sysfs_remove_file_from_group(&dev->kobj, | 426 | sysfs_remove_file_from_group(&dev->kobj, |
@@ -601,21 +650,21 @@ void usb_remove_sysfs_dev_files(struct usb_device *udev) | |||
601 | /* Interface Accociation Descriptor fields */ | 650 | /* Interface Accociation Descriptor fields */ |
602 | #define usb_intf_assoc_attr(field, format_string) \ | 651 | #define usb_intf_assoc_attr(field, format_string) \ |
603 | static ssize_t \ | 652 | static ssize_t \ |
604 | show_iad_##field (struct device *dev, struct device_attribute *attr, \ | 653 | show_iad_##field(struct device *dev, struct device_attribute *attr, \ |
605 | char *buf) \ | 654 | char *buf) \ |
606 | { \ | 655 | { \ |
607 | struct usb_interface *intf = to_usb_interface (dev); \ | 656 | struct usb_interface *intf = to_usb_interface(dev); \ |
608 | \ | 657 | \ |
609 | return sprintf (buf, format_string, \ | 658 | return sprintf(buf, format_string, \ |
610 | intf->intf_assoc->field); \ | 659 | intf->intf_assoc->field); \ |
611 | } \ | 660 | } \ |
612 | static DEVICE_ATTR(iad_##field, S_IRUGO, show_iad_##field, NULL); | 661 | static DEVICE_ATTR(iad_##field, S_IRUGO, show_iad_##field, NULL); |
613 | 662 | ||
614 | usb_intf_assoc_attr (bFirstInterface, "%02x\n") | 663 | usb_intf_assoc_attr(bFirstInterface, "%02x\n") |
615 | usb_intf_assoc_attr (bInterfaceCount, "%02d\n") | 664 | usb_intf_assoc_attr(bInterfaceCount, "%02d\n") |
616 | usb_intf_assoc_attr (bFunctionClass, "%02x\n") | 665 | usb_intf_assoc_attr(bFunctionClass, "%02x\n") |
617 | usb_intf_assoc_attr (bFunctionSubClass, "%02x\n") | 666 | usb_intf_assoc_attr(bFunctionSubClass, "%02x\n") |
618 | usb_intf_assoc_attr (bFunctionProtocol, "%02x\n") | 667 | usb_intf_assoc_attr(bFunctionProtocol, "%02x\n") |
619 | 668 | ||
620 | /* Interface fields */ | 669 | /* Interface fields */ |
621 | #define usb_intf_attr(field, format_string) \ | 670 | #define usb_intf_attr(field, format_string) \ |
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index d05ead20081c..9d7e63292c01 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
@@ -42,6 +42,7 @@ void usb_init_urb(struct urb *urb) | |||
42 | INIT_LIST_HEAD(&urb->anchor_list); | 42 | INIT_LIST_HEAD(&urb->anchor_list); |
43 | } | 43 | } |
44 | } | 44 | } |
45 | EXPORT_SYMBOL_GPL(usb_init_urb); | ||
45 | 46 | ||
46 | /** | 47 | /** |
47 | * usb_alloc_urb - creates a new urb for a USB driver to use | 48 | * usb_alloc_urb - creates a new urb for a USB driver to use |
@@ -73,6 +74,7 @@ struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags) | |||
73 | usb_init_urb(urb); | 74 | usb_init_urb(urb); |
74 | return urb; | 75 | return urb; |
75 | } | 76 | } |
77 | EXPORT_SYMBOL_GPL(usb_alloc_urb); | ||
76 | 78 | ||
77 | /** | 79 | /** |
78 | * usb_free_urb - frees the memory used by a urb when all users of it are finished | 80 | * usb_free_urb - frees the memory used by a urb when all users of it are finished |
@@ -89,6 +91,7 @@ void usb_free_urb(struct urb *urb) | |||
89 | if (urb) | 91 | if (urb) |
90 | kref_put(&urb->kref, urb_destroy); | 92 | kref_put(&urb->kref, urb_destroy); |
91 | } | 93 | } |
94 | EXPORT_SYMBOL_GPL(usb_free_urb); | ||
92 | 95 | ||
93 | /** | 96 | /** |
94 | * usb_get_urb - increments the reference count of the urb | 97 | * usb_get_urb - increments the reference count of the urb |
@@ -100,12 +103,13 @@ void usb_free_urb(struct urb *urb) | |||
100 | * | 103 | * |
101 | * A pointer to the urb with the incremented reference counter is returned. | 104 | * A pointer to the urb with the incremented reference counter is returned. |
102 | */ | 105 | */ |
103 | struct urb * usb_get_urb(struct urb *urb) | 106 | struct urb *usb_get_urb(struct urb *urb) |
104 | { | 107 | { |
105 | if (urb) | 108 | if (urb) |
106 | kref_get(&urb->kref); | 109 | kref_get(&urb->kref); |
107 | return urb; | 110 | return urb; |
108 | } | 111 | } |
112 | EXPORT_SYMBOL_GPL(usb_get_urb); | ||
109 | 113 | ||
110 | /** | 114 | /** |
111 | * usb_anchor_urb - anchors an URB while it is processed | 115 | * usb_anchor_urb - anchors an URB while it is processed |
@@ -172,7 +176,7 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb); | |||
172 | * describing that request to the USB subsystem. Request completion will | 176 | * describing that request to the USB subsystem. Request completion will |
173 | * be indicated later, asynchronously, by calling the completion handler. | 177 | * be indicated later, asynchronously, by calling the completion handler. |
174 | * The three types of completion are success, error, and unlink | 178 | * The three types of completion are success, error, and unlink |
175 | * (a software-induced fault, also called "request cancellation"). | 179 | * (a software-induced fault, also called "request cancellation"). |
176 | * | 180 | * |
177 | * URBs may be submitted in interrupt context. | 181 | * URBs may be submitted in interrupt context. |
178 | * | 182 | * |
@@ -255,7 +259,7 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb); | |||
255 | * semaphores), or | 259 | * semaphores), or |
256 | * (c) current->state != TASK_RUNNING, this is the case only after | 260 | * (c) current->state != TASK_RUNNING, this is the case only after |
257 | * you've changed it. | 261 | * you've changed it. |
258 | * | 262 | * |
259 | * GFP_NOIO is used in the block io path and error handling of storage | 263 | * GFP_NOIO is used in the block io path and error handling of storage |
260 | * devices. | 264 | * devices. |
261 | * | 265 | * |
@@ -284,7 +288,8 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
284 | 288 | ||
285 | if (!urb || urb->hcpriv || !urb->complete) | 289 | if (!urb || urb->hcpriv || !urb->complete) |
286 | return -EINVAL; | 290 | return -EINVAL; |
287 | if (!(dev = urb->dev) || dev->state < USB_STATE_DEFAULT) | 291 | dev = urb->dev; |
292 | if ((!dev) || (dev->state < USB_STATE_DEFAULT)) | ||
288 | return -ENODEV; | 293 | return -ENODEV; |
289 | 294 | ||
290 | /* For now, get the endpoint from the pipe. Eventually drivers | 295 | /* For now, get the endpoint from the pipe. Eventually drivers |
@@ -347,11 +352,11 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
347 | max *= mult; | 352 | max *= mult; |
348 | } | 353 | } |
349 | 354 | ||
350 | if (urb->number_of_packets <= 0) | 355 | if (urb->number_of_packets <= 0) |
351 | return -EINVAL; | 356 | return -EINVAL; |
352 | for (n = 0; n < urb->number_of_packets; n++) { | 357 | for (n = 0; n < urb->number_of_packets; n++) { |
353 | len = urb->iso_frame_desc[n].length; | 358 | len = urb->iso_frame_desc[n].length; |
354 | if (len < 0 || len > max) | 359 | if (len < 0 || len > max) |
355 | return -EMSGSIZE; | 360 | return -EMSGSIZE; |
356 | urb->iso_frame_desc[n].status = -EXDEV; | 361 | urb->iso_frame_desc[n].status = -EXDEV; |
357 | urb->iso_frame_desc[n].actual_length = 0; | 362 | urb->iso_frame_desc[n].actual_length = 0; |
@@ -416,7 +421,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
416 | /* too big? */ | 421 | /* too big? */ |
417 | switch (dev->speed) { | 422 | switch (dev->speed) { |
418 | case USB_SPEED_HIGH: /* units are microframes */ | 423 | case USB_SPEED_HIGH: /* units are microframes */ |
419 | // NOTE usb handles 2^15 | 424 | /* NOTE usb handles 2^15 */ |
420 | if (urb->interval > (1024 * 8)) | 425 | if (urb->interval > (1024 * 8)) |
421 | urb->interval = 1024 * 8; | 426 | urb->interval = 1024 * 8; |
422 | max = 1024 * 8; | 427 | max = 1024 * 8; |
@@ -426,12 +431,12 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
426 | if (xfertype == USB_ENDPOINT_XFER_INT) { | 431 | if (xfertype == USB_ENDPOINT_XFER_INT) { |
427 | if (urb->interval > 255) | 432 | if (urb->interval > 255) |
428 | return -EINVAL; | 433 | return -EINVAL; |
429 | // NOTE ohci only handles up to 32 | 434 | /* NOTE ohci only handles up to 32 */ |
430 | max = 128; | 435 | max = 128; |
431 | } else { | 436 | } else { |
432 | if (urb->interval > 1024) | 437 | if (urb->interval > 1024) |
433 | urb->interval = 1024; | 438 | urb->interval = 1024; |
434 | // NOTE usb and ohci handle up to 2^15 | 439 | /* NOTE usb and ohci handle up to 2^15 */ |
435 | max = 1024; | 440 | max = 1024; |
436 | } | 441 | } |
437 | break; | 442 | break; |
@@ -444,6 +449,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
444 | 449 | ||
445 | return usb_hcd_submit_urb(urb, mem_flags); | 450 | return usb_hcd_submit_urb(urb, mem_flags); |
446 | } | 451 | } |
452 | EXPORT_SYMBOL_GPL(usb_submit_urb); | ||
447 | 453 | ||
448 | /*-------------------------------------------------------------------*/ | 454 | /*-------------------------------------------------------------------*/ |
449 | 455 | ||
@@ -514,6 +520,7 @@ int usb_unlink_urb(struct urb *urb) | |||
514 | return -EIDRM; | 520 | return -EIDRM; |
515 | return usb_hcd_unlink_urb(urb, -ECONNRESET); | 521 | return usb_hcd_unlink_urb(urb, -ECONNRESET); |
516 | } | 522 | } |
523 | EXPORT_SYMBOL_GPL(usb_unlink_urb); | ||
517 | 524 | ||
518 | /** | 525 | /** |
519 | * usb_kill_urb - cancel a transfer request and wait for it to finish | 526 | * usb_kill_urb - cancel a transfer request and wait for it to finish |
@@ -553,6 +560,7 @@ void usb_kill_urb(struct urb *urb) | |||
553 | --urb->reject; | 560 | --urb->reject; |
554 | mutex_unlock(&reject_mutex); | 561 | mutex_unlock(&reject_mutex); |
555 | } | 562 | } |
563 | EXPORT_SYMBOL_GPL(usb_kill_urb); | ||
556 | 564 | ||
557 | /** | 565 | /** |
558 | * usb_kill_anchored_urbs - cancel transfer requests en masse | 566 | * usb_kill_anchored_urbs - cancel transfer requests en masse |
@@ -567,7 +575,8 @@ void usb_kill_anchored_urbs(struct usb_anchor *anchor) | |||
567 | 575 | ||
568 | spin_lock_irq(&anchor->lock); | 576 | spin_lock_irq(&anchor->lock); |
569 | while (!list_empty(&anchor->urb_list)) { | 577 | while (!list_empty(&anchor->urb_list)) { |
570 | victim = list_entry(anchor->urb_list.prev, struct urb, anchor_list); | 578 | victim = list_entry(anchor->urb_list.prev, struct urb, |
579 | anchor_list); | ||
571 | /* we must make sure the URB isn't freed before we kill it*/ | 580 | /* we must make sure the URB isn't freed before we kill it*/ |
572 | usb_get_urb(victim); | 581 | usb_get_urb(victim); |
573 | spin_unlock_irq(&anchor->lock); | 582 | spin_unlock_irq(&anchor->lock); |
@@ -595,11 +604,3 @@ int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, | |||
595 | msecs_to_jiffies(timeout)); | 604 | msecs_to_jiffies(timeout)); |
596 | } | 605 | } |
597 | EXPORT_SYMBOL_GPL(usb_wait_anchor_empty_timeout); | 606 | EXPORT_SYMBOL_GPL(usb_wait_anchor_empty_timeout); |
598 | |||
599 | EXPORT_SYMBOL(usb_init_urb); | ||
600 | EXPORT_SYMBOL(usb_alloc_urb); | ||
601 | EXPORT_SYMBOL(usb_free_urb); | ||
602 | EXPORT_SYMBOL(usb_get_urb); | ||
603 | EXPORT_SYMBOL(usb_submit_urb); | ||
604 | EXPORT_SYMBOL(usb_unlink_urb); | ||
605 | EXPORT_SYMBOL(usb_kill_urb); | ||
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 8f142370103d..4e984060c984 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -96,6 +96,7 @@ struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev, | |||
96 | 96 | ||
97 | return NULL; | 97 | return NULL; |
98 | } | 98 | } |
99 | EXPORT_SYMBOL_GPL(usb_ifnum_to_if); | ||
99 | 100 | ||
100 | /** | 101 | /** |
101 | * usb_altnum_to_altsetting - get the altsetting structure with a given | 102 | * usb_altnum_to_altsetting - get the altsetting structure with a given |
@@ -115,8 +116,9 @@ struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev, | |||
115 | * Don't call this function unless you are bound to the intf interface | 116 | * Don't call this function unless you are bound to the intf interface |
116 | * or you have locked the device! | 117 | * or you have locked the device! |
117 | */ | 118 | */ |
118 | struct usb_host_interface *usb_altnum_to_altsetting(const struct usb_interface *intf, | 119 | struct usb_host_interface *usb_altnum_to_altsetting( |
119 | unsigned int altnum) | 120 | const struct usb_interface *intf, |
121 | unsigned int altnum) | ||
120 | { | 122 | { |
121 | int i; | 123 | int i; |
122 | 124 | ||
@@ -126,13 +128,14 @@ struct usb_host_interface *usb_altnum_to_altsetting(const struct usb_interface * | |||
126 | } | 128 | } |
127 | return NULL; | 129 | return NULL; |
128 | } | 130 | } |
131 | EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting); | ||
129 | 132 | ||
130 | struct find_interface_arg { | 133 | struct find_interface_arg { |
131 | int minor; | 134 | int minor; |
132 | struct usb_interface *interface; | 135 | struct usb_interface *interface; |
133 | }; | 136 | }; |
134 | 137 | ||
135 | static int __find_interface(struct device * dev, void * data) | 138 | static int __find_interface(struct device *dev, void *data) |
136 | { | 139 | { |
137 | struct find_interface_arg *arg = data; | 140 | struct find_interface_arg *arg = data; |
138 | struct usb_interface *intf; | 141 | struct usb_interface *intf; |
@@ -154,7 +157,7 @@ static int __find_interface(struct device * dev, void * data) | |||
154 | * @drv: the driver whose current configuration is considered | 157 | * @drv: the driver whose current configuration is considered |
155 | * @minor: the minor number of the desired device | 158 | * @minor: the minor number of the desired device |
156 | * | 159 | * |
157 | * This walks the driver device list and returns a pointer to the interface | 160 | * This walks the driver device list and returns a pointer to the interface |
158 | * with the matching minor. Note, this only works for devices that share the | 161 | * with the matching minor. Note, this only works for devices that share the |
159 | * USB major number. | 162 | * USB major number. |
160 | */ | 163 | */ |
@@ -170,6 +173,7 @@ struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) | |||
170 | __find_interface); | 173 | __find_interface); |
171 | return argb.interface; | 174 | return argb.interface; |
172 | } | 175 | } |
176 | EXPORT_SYMBOL_GPL(usb_find_interface); | ||
173 | 177 | ||
174 | /** | 178 | /** |
175 | * usb_release_dev - free a usb device structure when all users of it are finished. | 179 | * usb_release_dev - free a usb device structure when all users of it are finished. |
@@ -230,7 +234,7 @@ static int ksuspend_usb_init(void) | |||
230 | * singlethreaded. Its job doesn't justify running on more | 234 | * singlethreaded. Its job doesn't justify running on more |
231 | * than one CPU. | 235 | * than one CPU. |
232 | */ | 236 | */ |
233 | ksuspend_usb_wq = create_freezeable_workqueue("ksuspend_usbd"); | 237 | ksuspend_usb_wq = create_singlethread_workqueue("ksuspend_usbd"); |
234 | if (!ksuspend_usb_wq) | 238 | if (!ksuspend_usb_wq) |
235 | return -ENOMEM; | 239 | return -ENOMEM; |
236 | return 0; | 240 | return 0; |
@@ -269,8 +273,8 @@ static unsigned usb_bus_is_wusb(struct usb_bus *bus) | |||
269 | * | 273 | * |
270 | * This call may not be used in a non-sleeping context. | 274 | * This call may not be used in a non-sleeping context. |
271 | */ | 275 | */ |
272 | struct usb_device * | 276 | struct usb_device *usb_alloc_dev(struct usb_device *parent, |
273 | usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1) | 277 | struct usb_bus *bus, unsigned port1) |
274 | { | 278 | { |
275 | struct usb_device *dev; | 279 | struct usb_device *dev; |
276 | struct usb_hcd *usb_hcd = container_of(bus, struct usb_hcd, self); | 280 | struct usb_hcd *usb_hcd = container_of(bus, struct usb_hcd, self); |
@@ -339,6 +343,8 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1) | |||
339 | mutex_init(&dev->pm_mutex); | 343 | mutex_init(&dev->pm_mutex); |
340 | INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work); | 344 | INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work); |
341 | dev->autosuspend_delay = usb_autosuspend_delay * HZ; | 345 | dev->autosuspend_delay = usb_autosuspend_delay * HZ; |
346 | dev->connect_time = jiffies; | ||
347 | dev->active_duration = -jiffies; | ||
342 | #endif | 348 | #endif |
343 | if (root_hub) /* Root hub always ok [and always wired] */ | 349 | if (root_hub) /* Root hub always ok [and always wired] */ |
344 | dev->authorized = 1; | 350 | dev->authorized = 1; |
@@ -367,6 +373,7 @@ struct usb_device *usb_get_dev(struct usb_device *dev) | |||
367 | get_device(&dev->dev); | 373 | get_device(&dev->dev); |
368 | return dev; | 374 | return dev; |
369 | } | 375 | } |
376 | EXPORT_SYMBOL_GPL(usb_get_dev); | ||
370 | 377 | ||
371 | /** | 378 | /** |
372 | * usb_put_dev - release a use of the usb device structure | 379 | * usb_put_dev - release a use of the usb device structure |
@@ -380,6 +387,7 @@ void usb_put_dev(struct usb_device *dev) | |||
380 | if (dev) | 387 | if (dev) |
381 | put_device(&dev->dev); | 388 | put_device(&dev->dev); |
382 | } | 389 | } |
390 | EXPORT_SYMBOL_GPL(usb_put_dev); | ||
383 | 391 | ||
384 | /** | 392 | /** |
385 | * usb_get_intf - increments the reference count of the usb interface structure | 393 | * usb_get_intf - increments the reference count of the usb interface structure |
@@ -400,6 +408,7 @@ struct usb_interface *usb_get_intf(struct usb_interface *intf) | |||
400 | get_device(&intf->dev); | 408 | get_device(&intf->dev); |
401 | return intf; | 409 | return intf; |
402 | } | 410 | } |
411 | EXPORT_SYMBOL_GPL(usb_get_intf); | ||
403 | 412 | ||
404 | /** | 413 | /** |
405 | * usb_put_intf - release a use of the usb interface structure | 414 | * usb_put_intf - release a use of the usb interface structure |
@@ -414,7 +423,7 @@ void usb_put_intf(struct usb_interface *intf) | |||
414 | if (intf) | 423 | if (intf) |
415 | put_device(&intf->dev); | 424 | put_device(&intf->dev); |
416 | } | 425 | } |
417 | 426 | EXPORT_SYMBOL_GPL(usb_put_intf); | |
418 | 427 | ||
419 | /* USB device locking | 428 | /* USB device locking |
420 | * | 429 | * |
@@ -461,11 +470,11 @@ int usb_lock_device_for_reset(struct usb_device *udev, | |||
461 | return -EHOSTUNREACH; | 470 | return -EHOSTUNREACH; |
462 | if (iface) { | 471 | if (iface) { |
463 | switch (iface->condition) { | 472 | switch (iface->condition) { |
464 | case USB_INTERFACE_BINDING: | 473 | case USB_INTERFACE_BINDING: |
465 | return 0; | 474 | return 0; |
466 | case USB_INTERFACE_BOUND: | 475 | case USB_INTERFACE_BOUND: |
467 | break; | 476 | break; |
468 | default: | 477 | default: |
469 | return -EINTR; | 478 | return -EINTR; |
470 | } | 479 | } |
471 | } | 480 | } |
@@ -487,7 +496,7 @@ int usb_lock_device_for_reset(struct usb_device *udev, | |||
487 | } | 496 | } |
488 | return 1; | 497 | return 1; |
489 | } | 498 | } |
490 | 499 | EXPORT_SYMBOL_GPL(usb_lock_device_for_reset); | |
491 | 500 | ||
492 | static struct usb_device *match_device(struct usb_device *dev, | 501 | static struct usb_device *match_device(struct usb_device *dev, |
493 | u16 vendor_id, u16 product_id) | 502 | u16 vendor_id, u16 product_id) |
@@ -540,10 +549,10 @@ struct usb_device *usb_find_device(u16 vendor_id, u16 product_id) | |||
540 | struct list_head *buslist; | 549 | struct list_head *buslist; |
541 | struct usb_bus *bus; | 550 | struct usb_bus *bus; |
542 | struct usb_device *dev = NULL; | 551 | struct usb_device *dev = NULL; |
543 | 552 | ||
544 | mutex_lock(&usb_bus_list_lock); | 553 | mutex_lock(&usb_bus_list_lock); |
545 | for (buslist = usb_bus_list.next; | 554 | for (buslist = usb_bus_list.next; |
546 | buslist != &usb_bus_list; | 555 | buslist != &usb_bus_list; |
547 | buslist = buslist->next) { | 556 | buslist = buslist->next) { |
548 | bus = container_of(buslist, struct usb_bus, bus_list); | 557 | bus = container_of(buslist, struct usb_bus, bus_list); |
549 | if (!bus->root_hub) | 558 | if (!bus->root_hub) |
@@ -576,6 +585,7 @@ int usb_get_current_frame_number(struct usb_device *dev) | |||
576 | { | 585 | { |
577 | return usb_hcd_get_frame_number(dev); | 586 | return usb_hcd_get_frame_number(dev); |
578 | } | 587 | } |
588 | EXPORT_SYMBOL_GPL(usb_get_current_frame_number); | ||
579 | 589 | ||
580 | /*-------------------------------------------------------------------*/ | 590 | /*-------------------------------------------------------------------*/ |
581 | /* | 591 | /* |
@@ -584,7 +594,7 @@ int usb_get_current_frame_number(struct usb_device *dev) | |||
584 | */ | 594 | */ |
585 | 595 | ||
586 | int __usb_get_extra_descriptor(char *buffer, unsigned size, | 596 | int __usb_get_extra_descriptor(char *buffer, unsigned size, |
587 | unsigned char type, void **ptr) | 597 | unsigned char type, void **ptr) |
588 | { | 598 | { |
589 | struct usb_descriptor_header *header; | 599 | struct usb_descriptor_header *header; |
590 | 600 | ||
@@ -595,7 +605,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, | |||
595 | printk(KERN_ERR | 605 | printk(KERN_ERR |
596 | "%s: bogus descriptor, type %d length %d\n", | 606 | "%s: bogus descriptor, type %d length %d\n", |
597 | usbcore_name, | 607 | usbcore_name, |
598 | header->bDescriptorType, | 608 | header->bDescriptorType, |
599 | header->bLength); | 609 | header->bLength); |
600 | return -1; | 610 | return -1; |
601 | } | 611 | } |
@@ -610,6 +620,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, | |||
610 | } | 620 | } |
611 | return -1; | 621 | return -1; |
612 | } | 622 | } |
623 | EXPORT_SYMBOL_GPL(__usb_get_extra_descriptor); | ||
613 | 624 | ||
614 | /** | 625 | /** |
615 | * usb_buffer_alloc - allocate dma-consistent buffer for URB_NO_xxx_DMA_MAP | 626 | * usb_buffer_alloc - allocate dma-consistent buffer for URB_NO_xxx_DMA_MAP |
@@ -633,17 +644,14 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, | |||
633 | * | 644 | * |
634 | * When the buffer is no longer used, free it with usb_buffer_free(). | 645 | * When the buffer is no longer used, free it with usb_buffer_free(). |
635 | */ | 646 | */ |
636 | void *usb_buffer_alloc( | 647 | void *usb_buffer_alloc(struct usb_device *dev, size_t size, gfp_t mem_flags, |
637 | struct usb_device *dev, | 648 | dma_addr_t *dma) |
638 | size_t size, | ||
639 | gfp_t mem_flags, | ||
640 | dma_addr_t *dma | ||
641 | ) | ||
642 | { | 649 | { |
643 | if (!dev || !dev->bus) | 650 | if (!dev || !dev->bus) |
644 | return NULL; | 651 | return NULL; |
645 | return hcd_buffer_alloc(dev->bus, size, mem_flags, dma); | 652 | return hcd_buffer_alloc(dev->bus, size, mem_flags, dma); |
646 | } | 653 | } |
654 | EXPORT_SYMBOL_GPL(usb_buffer_alloc); | ||
647 | 655 | ||
648 | /** | 656 | /** |
649 | * usb_buffer_free - free memory allocated with usb_buffer_alloc() | 657 | * usb_buffer_free - free memory allocated with usb_buffer_alloc() |
@@ -656,12 +664,8 @@ void *usb_buffer_alloc( | |||
656 | * been allocated using usb_buffer_alloc(), and the parameters must match | 664 | * been allocated using usb_buffer_alloc(), and the parameters must match |
657 | * those provided in that allocation request. | 665 | * those provided in that allocation request. |
658 | */ | 666 | */ |
659 | void usb_buffer_free( | 667 | void usb_buffer_free(struct usb_device *dev, size_t size, void *addr, |
660 | struct usb_device *dev, | 668 | dma_addr_t dma) |
661 | size_t size, | ||
662 | void *addr, | ||
663 | dma_addr_t dma | ||
664 | ) | ||
665 | { | 669 | { |
666 | if (!dev || !dev->bus) | 670 | if (!dev || !dev->bus) |
667 | return; | 671 | return; |
@@ -669,6 +673,7 @@ void usb_buffer_free( | |||
669 | return; | 673 | return; |
670 | hcd_buffer_free(dev->bus, size, addr, dma); | 674 | hcd_buffer_free(dev->bus, size, addr, dma); |
671 | } | 675 | } |
676 | EXPORT_SYMBOL_GPL(usb_buffer_free); | ||
672 | 677 | ||
673 | /** | 678 | /** |
674 | * usb_buffer_map - create DMA mapping(s) for an urb | 679 | * usb_buffer_map - create DMA mapping(s) for an urb |
@@ -708,14 +713,15 @@ struct urb *usb_buffer_map(struct urb *urb) | |||
708 | urb->setup_packet, | 713 | urb->setup_packet, |
709 | sizeof(struct usb_ctrlrequest), | 714 | sizeof(struct usb_ctrlrequest), |
710 | DMA_TO_DEVICE); | 715 | DMA_TO_DEVICE); |
711 | // FIXME generic api broken like pci, can't report errors | 716 | /* FIXME generic api broken like pci, can't report errors */ |
712 | // if (urb->transfer_dma == DMA_ADDR_INVALID) return 0; | 717 | /* if (urb->transfer_dma == DMA_ADDR_INVALID) return 0; */ |
713 | } else | 718 | } else |
714 | urb->transfer_dma = ~0; | 719 | urb->transfer_dma = ~0; |
715 | urb->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | 720 | urb->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP |
716 | | URB_NO_SETUP_DMA_MAP); | 721 | | URB_NO_SETUP_DMA_MAP); |
717 | return urb; | 722 | return urb; |
718 | } | 723 | } |
724 | EXPORT_SYMBOL_GPL(usb_buffer_map); | ||
719 | #endif /* 0 */ | 725 | #endif /* 0 */ |
720 | 726 | ||
721 | /* XXX DISABLED, no users currently. If you wish to re-enable this | 727 | /* XXX DISABLED, no users currently. If you wish to re-enable this |
@@ -753,6 +759,7 @@ void usb_buffer_dmasync(struct urb *urb) | |||
753 | DMA_TO_DEVICE); | 759 | DMA_TO_DEVICE); |
754 | } | 760 | } |
755 | } | 761 | } |
762 | EXPORT_SYMBOL_GPL(usb_buffer_dmasync); | ||
756 | #endif | 763 | #endif |
757 | 764 | ||
758 | /** | 765 | /** |
@@ -788,6 +795,7 @@ void usb_buffer_unmap(struct urb *urb) | |||
788 | urb->transfer_flags &= ~(URB_NO_TRANSFER_DMA_MAP | 795 | urb->transfer_flags &= ~(URB_NO_TRANSFER_DMA_MAP |
789 | | URB_NO_SETUP_DMA_MAP); | 796 | | URB_NO_SETUP_DMA_MAP); |
790 | } | 797 | } |
798 | EXPORT_SYMBOL_GPL(usb_buffer_unmap); | ||
791 | #endif /* 0 */ | 799 | #endif /* 0 */ |
792 | 800 | ||
793 | /** | 801 | /** |
@@ -828,10 +836,11 @@ int usb_buffer_map_sg(const struct usb_device *dev, int is_in, | |||
828 | || !controller->dma_mask) | 836 | || !controller->dma_mask) |
829 | return -1; | 837 | return -1; |
830 | 838 | ||
831 | // FIXME generic api broken like pci, can't report errors | 839 | /* FIXME generic api broken like pci, can't report errors */ |
832 | return dma_map_sg(controller, sg, nents, | 840 | return dma_map_sg(controller, sg, nents, |
833 | is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); | 841 | is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); |
834 | } | 842 | } |
843 | EXPORT_SYMBOL_GPL(usb_buffer_map_sg); | ||
835 | 844 | ||
836 | /* XXX DISABLED, no users currently. If you wish to re-enable this | 845 | /* XXX DISABLED, no users currently. If you wish to re-enable this |
837 | * XXX please determine whether the sync is to transfer ownership of | 846 | * XXX please determine whether the sync is to transfer ownership of |
@@ -865,6 +874,7 @@ void usb_buffer_dmasync_sg(const struct usb_device *dev, int is_in, | |||
865 | dma_sync_sg(controller, sg, n_hw_ents, | 874 | dma_sync_sg(controller, sg, n_hw_ents, |
866 | is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); | 875 | is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); |
867 | } | 876 | } |
877 | EXPORT_SYMBOL_GPL(usb_buffer_dmasync_sg); | ||
868 | #endif | 878 | #endif |
869 | 879 | ||
870 | /** | 880 | /** |
@@ -891,6 +901,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in, | |||
891 | dma_unmap_sg(controller, sg, n_hw_ents, | 901 | dma_unmap_sg(controller, sg, n_hw_ents, |
892 | is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); | 902 | is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); |
893 | } | 903 | } |
904 | EXPORT_SYMBOL_GPL(usb_buffer_unmap_sg); | ||
894 | 905 | ||
895 | /* format to disable USB on kernel command line is: nousb */ | 906 | /* format to disable USB on kernel command line is: nousb */ |
896 | __module_param_call("", nousb, param_set_bool, param_get_bool, &nousb, 0444); | 907 | __module_param_call("", nousb, param_set_bool, param_get_bool, &nousb, 0444); |
@@ -902,6 +913,7 @@ int usb_disabled(void) | |||
902 | { | 913 | { |
903 | return nousb; | 914 | return nousb; |
904 | } | 915 | } |
916 | EXPORT_SYMBOL_GPL(usb_disabled); | ||
905 | 917 | ||
906 | /* | 918 | /* |
907 | * Init | 919 | * Init |
@@ -918,7 +930,7 @@ static int __init usb_init(void) | |||
918 | if (retval) | 930 | if (retval) |
919 | goto out; | 931 | goto out; |
920 | retval = bus_register(&usb_bus_type); | 932 | retval = bus_register(&usb_bus_type); |
921 | if (retval) | 933 | if (retval) |
922 | goto bus_register_failed; | 934 | goto bus_register_failed; |
923 | retval = usb_host_init(); | 935 | retval = usb_host_init(); |
924 | if (retval) | 936 | if (retval) |
@@ -983,45 +995,4 @@ static void __exit usb_exit(void) | |||
983 | 995 | ||
984 | subsys_initcall(usb_init); | 996 | subsys_initcall(usb_init); |
985 | module_exit(usb_exit); | 997 | module_exit(usb_exit); |
986 | |||
987 | /* | ||
988 | * USB may be built into the kernel or be built as modules. | ||
989 | * These symbols are exported for device (or host controller) | ||
990 | * driver modules to use. | ||
991 | */ | ||
992 | |||
993 | EXPORT_SYMBOL(usb_disabled); | ||
994 | |||
995 | EXPORT_SYMBOL_GPL(usb_get_intf); | ||
996 | EXPORT_SYMBOL_GPL(usb_put_intf); | ||
997 | |||
998 | EXPORT_SYMBOL(usb_put_dev); | ||
999 | EXPORT_SYMBOL(usb_get_dev); | ||
1000 | EXPORT_SYMBOL(usb_hub_tt_clear_buffer); | ||
1001 | |||
1002 | EXPORT_SYMBOL(usb_lock_device_for_reset); | ||
1003 | |||
1004 | EXPORT_SYMBOL(usb_find_interface); | ||
1005 | EXPORT_SYMBOL(usb_ifnum_to_if); | ||
1006 | EXPORT_SYMBOL(usb_altnum_to_altsetting); | ||
1007 | |||
1008 | EXPORT_SYMBOL(__usb_get_extra_descriptor); | ||
1009 | |||
1010 | EXPORT_SYMBOL(usb_get_current_frame_number); | ||
1011 | |||
1012 | EXPORT_SYMBOL(usb_buffer_alloc); | ||
1013 | EXPORT_SYMBOL(usb_buffer_free); | ||
1014 | |||
1015 | #if 0 | ||
1016 | EXPORT_SYMBOL(usb_buffer_map); | ||
1017 | EXPORT_SYMBOL(usb_buffer_dmasync); | ||
1018 | EXPORT_SYMBOL(usb_buffer_unmap); | ||
1019 | #endif | ||
1020 | |||
1021 | EXPORT_SYMBOL(usb_buffer_map_sg); | ||
1022 | #if 0 | ||
1023 | EXPORT_SYMBOL(usb_buffer_dmasync_sg); | ||
1024 | #endif | ||
1025 | EXPORT_SYMBOL(usb_buffer_unmap_sg); | ||
1026 | |||
1027 | MODULE_LICENSE("GPL"); | 998 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index c52626c51f70..2375194a9d43 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h | |||
@@ -1,22 +1,23 @@ | |||
1 | /* Functions local to drivers/usb/core/ */ | 1 | /* Functions local to drivers/usb/core/ */ |
2 | 2 | ||
3 | extern int usb_create_sysfs_dev_files (struct usb_device *dev); | 3 | extern int usb_create_sysfs_dev_files(struct usb_device *dev); |
4 | extern void usb_remove_sysfs_dev_files (struct usb_device *dev); | 4 | extern void usb_remove_sysfs_dev_files(struct usb_device *dev); |
5 | extern int usb_create_sysfs_intf_files (struct usb_interface *intf); | 5 | extern int usb_create_sysfs_intf_files(struct usb_interface *intf); |
6 | extern void usb_remove_sysfs_intf_files (struct usb_interface *intf); | 6 | extern void usb_remove_sysfs_intf_files(struct usb_interface *intf); |
7 | extern int usb_create_ep_files(struct device *parent, struct usb_host_endpoint *endpoint, | 7 | extern int usb_create_ep_files(struct device *parent, |
8 | struct usb_host_endpoint *endpoint, | ||
8 | struct usb_device *udev); | 9 | struct usb_device *udev); |
9 | extern void usb_remove_ep_files(struct usb_host_endpoint *endpoint); | 10 | extern void usb_remove_ep_files(struct usb_host_endpoint *endpoint); |
10 | 11 | ||
11 | extern void usb_enable_endpoint(struct usb_device *dev, | 12 | extern void usb_enable_endpoint(struct usb_device *dev, |
12 | struct usb_host_endpoint *ep); | 13 | struct usb_host_endpoint *ep); |
13 | extern void usb_disable_endpoint (struct usb_device *dev, unsigned int epaddr); | 14 | extern void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr); |
14 | extern void usb_disable_interface (struct usb_device *dev, | 15 | extern void usb_disable_interface(struct usb_device *dev, |
15 | struct usb_interface *intf); | 16 | struct usb_interface *intf); |
16 | extern void usb_release_interface_cache(struct kref *ref); | 17 | extern void usb_release_interface_cache(struct kref *ref); |
17 | extern void usb_disable_device (struct usb_device *dev, int skip_ep0); | 18 | extern void usb_disable_device(struct usb_device *dev, int skip_ep0); |
18 | extern int usb_deauthorize_device (struct usb_device *); | 19 | extern int usb_deauthorize_device(struct usb_device *); |
19 | extern int usb_authorize_device (struct usb_device *); | 20 | extern int usb_authorize_device(struct usb_device *); |
20 | extern void usb_detect_quirks(struct usb_device *udev); | 21 | extern void usb_detect_quirks(struct usb_device *udev); |
21 | 22 | ||
22 | extern int usb_get_device_descriptor(struct usb_device *dev, | 23 | extern int usb_get_device_descriptor(struct usb_device *dev, |
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 77a3759d6fc7..c13955164686 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -12,10 +12,9 @@ | |||
12 | # With help from a special transceiver and a "Mini-AB" jack, systems with | 12 | # With help from a special transceiver and a "Mini-AB" jack, systems with |
13 | # both kinds of controller can also support "USB On-the-Go" (CONFIG_USB_OTG). | 13 | # both kinds of controller can also support "USB On-the-Go" (CONFIG_USB_OTG). |
14 | # | 14 | # |
15 | menu "USB Gadget Support" | ||
16 | 15 | ||
17 | config USB_GADGET | 16 | menuconfig USB_GADGET |
18 | tristate "Support for USB Gadgets" | 17 | tristate "USB Gadget Support" |
19 | help | 18 | help |
20 | USB is a master/slave protocol, organized with one master | 19 | USB is a master/slave protocol, organized with one master |
21 | host (such as a PC) controlling up to 127 peripheral devices. | 20 | host (such as a PC) controlling up to 127 peripheral devices. |
@@ -42,6 +41,8 @@ config USB_GADGET | |||
42 | For more information, see <http://www.linux-usb.org/gadget> and | 41 | For more information, see <http://www.linux-usb.org/gadget> and |
43 | the kernel DocBook documentation for this API. | 42 | the kernel DocBook documentation for this API. |
44 | 43 | ||
44 | if USB_GADGET | ||
45 | |||
45 | config USB_GADGET_DEBUG | 46 | config USB_GADGET_DEBUG |
46 | boolean "Debugging messages" | 47 | boolean "Debugging messages" |
47 | depends on USB_GADGET && DEBUG_KERNEL && EXPERIMENTAL | 48 | depends on USB_GADGET && DEBUG_KERNEL && EXPERIMENTAL |
@@ -220,6 +221,16 @@ config USB_M66592 | |||
220 | default USB_GADGET | 221 | default USB_GADGET |
221 | select USB_GADGET_SELECTED | 222 | select USB_GADGET_SELECTED |
222 | 223 | ||
224 | config SUPERH_BUILT_IN_M66592 | ||
225 | boolean "Enable SuperH built-in USB like the M66592" | ||
226 | depends on USB_GADGET_M66592 && CPU_SUBTYPE_SH7722 | ||
227 | help | ||
228 | SH7722 has USB like the M66592. | ||
229 | |||
230 | The transfer rate is very slow when use "Ethernet Gadget". | ||
231 | However, this problem is improved if change a value of | ||
232 | NET_IP_ALIGN to 4. | ||
233 | |||
223 | config USB_GADGET_GOKU | 234 | config USB_GADGET_GOKU |
224 | boolean "Toshiba TC86C001 'Goku-S'" | 235 | boolean "Toshiba TC86C001 'Goku-S'" |
225 | depends on PCI | 236 | depends on PCI |
@@ -538,6 +549,20 @@ config USB_MIDI_GADGET | |||
538 | Say "y" to link the driver statically, or "m" to build a | 549 | Say "y" to link the driver statically, or "m" to build a |
539 | dynamically linked module called "g_midi". | 550 | dynamically linked module called "g_midi". |
540 | 551 | ||
552 | config USB_G_PRINTER | ||
553 | tristate "Printer Gadget" | ||
554 | help | ||
555 | The Printer Gadget channels data between the USB host and a | ||
556 | userspace program driving the print engine. The user space | ||
557 | program reads and writes the device file /dev/g_printer to | ||
558 | receive or send printer data. It can use ioctl calls to | ||
559 | the device file to get or set printer status. | ||
560 | |||
561 | Say "y" to link the driver statically, or "m" to build a | ||
562 | dynamically linked module called "g_printer". | ||
563 | |||
564 | For more information, see Documentation/usb/gadget_printer.txt | ||
565 | which includes sample code for accessing the device file. | ||
541 | 566 | ||
542 | # put drivers that need isochronous transfer support (for audio | 567 | # put drivers that need isochronous transfer support (for audio |
543 | # or video class gadget drivers), or specific hardware, here. | 568 | # or video class gadget drivers), or specific hardware, here. |
@@ -546,4 +571,4 @@ config USB_MIDI_GADGET | |||
546 | 571 | ||
547 | endchoice | 572 | endchoice |
548 | 573 | ||
549 | endmenu | 574 | endif # USB_GADGET |
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 904e57bf6112..c3aab80b6c76 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile | |||
@@ -28,6 +28,8 @@ g_midi-objs := gmidi.o usbstring.o config.o epautoconf.o | |||
28 | gadgetfs-objs := inode.o | 28 | gadgetfs-objs := inode.o |
29 | g_file_storage-objs := file_storage.o usbstring.o config.o \ | 29 | g_file_storage-objs := file_storage.o usbstring.o config.o \ |
30 | epautoconf.o | 30 | epautoconf.o |
31 | g_printer-objs := printer.o usbstring.o config.o \ | ||
32 | epautoconf.o | ||
31 | 33 | ||
32 | ifeq ($(CONFIG_USB_ETH_RNDIS),y) | 34 | ifeq ($(CONFIG_USB_ETH_RNDIS),y) |
33 | g_ether-objs += rndis.o | 35 | g_ether-objs += rndis.o |
@@ -38,5 +40,6 @@ obj-$(CONFIG_USB_ETH) += g_ether.o | |||
38 | obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o | 40 | obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o |
39 | obj-$(CONFIG_USB_FILE_STORAGE) += g_file_storage.o | 41 | obj-$(CONFIG_USB_FILE_STORAGE) += g_file_storage.o |
40 | obj-$(CONFIG_USB_G_SERIAL) += g_serial.o | 42 | obj-$(CONFIG_USB_G_SERIAL) += g_serial.o |
43 | obj-$(CONFIG_USB_G_PRINTER) += g_printer.o | ||
41 | obj-$(CONFIG_USB_MIDI_GADGET) += g_midi.o | 44 | obj-$(CONFIG_USB_MIDI_GADGET) += g_midi.o |
42 | 45 | ||
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index c72e9620bf8d..b663f23f2642 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c | |||
@@ -1244,7 +1244,7 @@ udc_queue(struct usb_ep *usbep, struct usb_request *usbreq, gfp_t gfp) | |||
1244 | /* stop OUT naking */ | 1244 | /* stop OUT naking */ |
1245 | if (!ep->in) { | 1245 | if (!ep->in) { |
1246 | if (!use_dma && udc_rxfifo_pending) { | 1246 | if (!use_dma && udc_rxfifo_pending) { |
1247 | DBG(dev, "udc_queue(): pending bytes in" | 1247 | DBG(dev, "udc_queue(): pending bytes in " |
1248 | "rxfifo after nyet\n"); | 1248 | "rxfifo after nyet\n"); |
1249 | /* | 1249 | /* |
1250 | * read pending bytes afer nyet: | 1250 | * read pending bytes afer nyet: |
@@ -2038,6 +2038,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
2038 | spin_unlock_irqrestore(&dev->lock, flags); | 2038 | spin_unlock_irqrestore(&dev->lock, flags); |
2039 | 2039 | ||
2040 | driver->unbind(&dev->gadget); | 2040 | driver->unbind(&dev->gadget); |
2041 | dev->gadget.dev.driver = NULL; | ||
2041 | dev->driver = NULL; | 2042 | dev->driver = NULL; |
2042 | 2043 | ||
2043 | /* set SD */ | 2044 | /* set SD */ |
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index cd62b029d176..a83e8b798ec9 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c | |||
@@ -21,8 +21,7 @@ | |||
21 | * Boston, MA 02111-1307, USA. | 21 | * Boston, MA 02111-1307, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #undef DEBUG | 24 | #undef VERBOSE_DEBUG |
25 | #undef VERBOSE | ||
26 | #undef PACKET_TRACE | 25 | #undef PACKET_TRACE |
27 | 26 | ||
28 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
@@ -46,8 +45,8 @@ | |||
46 | #include <asm/irq.h> | 45 | #include <asm/irq.h> |
47 | #include <asm/system.h> | 46 | #include <asm/system.h> |
48 | #include <asm/mach-types.h> | 47 | #include <asm/mach-types.h> |
48 | #include <asm/gpio.h> | ||
49 | 49 | ||
50 | #include <asm/arch/gpio.h> | ||
51 | #include <asm/arch/board.h> | 50 | #include <asm/arch/board.h> |
52 | #include <asm/arch/cpu.h> | 51 | #include <asm/arch/cpu.h> |
53 | #include <asm/arch/at91sam9261_matrix.h> | 52 | #include <asm/arch/at91sam9261_matrix.h> |
@@ -580,7 +579,7 @@ static int at91_ep_disable (struct usb_ep * _ep) | |||
580 | */ | 579 | */ |
581 | 580 | ||
582 | static struct usb_request * | 581 | static struct usb_request * |
583 | at91_ep_alloc_request(struct usb_ep *_ep, unsigned int gfp_flags) | 582 | at91_ep_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags) |
584 | { | 583 | { |
585 | struct at91_request *req; | 584 | struct at91_request *req; |
586 | 585 | ||
@@ -881,6 +880,8 @@ static void clk_off(struct at91_udc *udc) | |||
881 | */ | 880 | */ |
882 | static void pullup(struct at91_udc *udc, int is_on) | 881 | static void pullup(struct at91_udc *udc, int is_on) |
883 | { | 882 | { |
883 | int active = !udc->board.pullup_active_low; | ||
884 | |||
884 | if (!udc->enabled || !udc->vbus) | 885 | if (!udc->enabled || !udc->vbus) |
885 | is_on = 0; | 886 | is_on = 0; |
886 | DBG("%sactive\n", is_on ? "" : "in"); | 887 | DBG("%sactive\n", is_on ? "" : "in"); |
@@ -890,7 +891,7 @@ static void pullup(struct at91_udc *udc, int is_on) | |||
890 | at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_RXRSM); | 891 | at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_RXRSM); |
891 | at91_udp_write(udc, AT91_UDP_TXVC, 0); | 892 | at91_udp_write(udc, AT91_UDP_TXVC, 0); |
892 | if (cpu_is_at91rm9200()) | 893 | if (cpu_is_at91rm9200()) |
893 | at91_set_gpio_value(udc->board.pullup_pin, 1); | 894 | gpio_set_value(udc->board.pullup_pin, active); |
894 | else if (cpu_is_at91sam9260() || cpu_is_at91sam9263()) { | 895 | else if (cpu_is_at91sam9260() || cpu_is_at91sam9263()) { |
895 | u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC); | 896 | u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC); |
896 | 897 | ||
@@ -908,7 +909,7 @@ static void pullup(struct at91_udc *udc, int is_on) | |||
908 | at91_udp_write(udc, AT91_UDP_IDR, AT91_UDP_RXRSM); | 909 | at91_udp_write(udc, AT91_UDP_IDR, AT91_UDP_RXRSM); |
909 | at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); | 910 | at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); |
910 | if (cpu_is_at91rm9200()) | 911 | if (cpu_is_at91rm9200()) |
911 | at91_set_gpio_value(udc->board.pullup_pin, 0); | 912 | gpio_set_value(udc->board.pullup_pin, !active); |
912 | else if (cpu_is_at91sam9260() || cpu_is_at91sam9263()) { | 913 | else if (cpu_is_at91sam9260() || cpu_is_at91sam9263()) { |
913 | u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC); | 914 | u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC); |
914 | 915 | ||
@@ -1153,7 +1154,7 @@ static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr) | |||
1153 | | USB_REQ_GET_STATUS: | 1154 | | USB_REQ_GET_STATUS: |
1154 | tmp = w_index & USB_ENDPOINT_NUMBER_MASK; | 1155 | tmp = w_index & USB_ENDPOINT_NUMBER_MASK; |
1155 | ep = &udc->ep[tmp]; | 1156 | ep = &udc->ep[tmp]; |
1156 | if (tmp > NUM_ENDPOINTS || (tmp && !ep->desc)) | 1157 | if (tmp >= NUM_ENDPOINTS || (tmp && !ep->desc)) |
1157 | goto stall; | 1158 | goto stall; |
1158 | 1159 | ||
1159 | if (tmp) { | 1160 | if (tmp) { |
@@ -1176,7 +1177,7 @@ static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr) | |||
1176 | | USB_REQ_SET_FEATURE: | 1177 | | USB_REQ_SET_FEATURE: |
1177 | tmp = w_index & USB_ENDPOINT_NUMBER_MASK; | 1178 | tmp = w_index & USB_ENDPOINT_NUMBER_MASK; |
1178 | ep = &udc->ep[tmp]; | 1179 | ep = &udc->ep[tmp]; |
1179 | if (w_value != USB_ENDPOINT_HALT || tmp > NUM_ENDPOINTS) | 1180 | if (w_value != USB_ENDPOINT_HALT || tmp >= NUM_ENDPOINTS) |
1180 | goto stall; | 1181 | goto stall; |
1181 | if (!ep->desc || ep->is_iso) | 1182 | if (!ep->desc || ep->is_iso) |
1182 | goto stall; | 1183 | goto stall; |
@@ -1195,7 +1196,7 @@ static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr) | |||
1195 | | USB_REQ_CLEAR_FEATURE: | 1196 | | USB_REQ_CLEAR_FEATURE: |
1196 | tmp = w_index & USB_ENDPOINT_NUMBER_MASK; | 1197 | tmp = w_index & USB_ENDPOINT_NUMBER_MASK; |
1197 | ep = &udc->ep[tmp]; | 1198 | ep = &udc->ep[tmp]; |
1198 | if (w_value != USB_ENDPOINT_HALT || tmp > NUM_ENDPOINTS) | 1199 | if (w_value != USB_ENDPOINT_HALT || tmp >= NUM_ENDPOINTS) |
1199 | goto stall; | 1200 | goto stall; |
1200 | if (tmp == 0) | 1201 | if (tmp == 0) |
1201 | goto succeed; | 1202 | goto succeed; |
@@ -1551,7 +1552,7 @@ static irqreturn_t at91_vbus_irq(int irq, void *_udc) | |||
1551 | 1552 | ||
1552 | /* vbus needs at least brief debouncing */ | 1553 | /* vbus needs at least brief debouncing */ |
1553 | udelay(10); | 1554 | udelay(10); |
1554 | value = at91_get_gpio_value(udc->board.vbus_pin); | 1555 | value = gpio_get_value(udc->board.vbus_pin); |
1555 | if (value != udc->vbus) | 1556 | if (value != udc->vbus) |
1556 | at91_vbus_session(&udc->gadget, value); | 1557 | at91_vbus_session(&udc->gadget, value); |
1557 | 1558 | ||
@@ -1616,6 +1617,8 @@ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver) | |||
1616 | local_irq_enable(); | 1617 | local_irq_enable(); |
1617 | 1618 | ||
1618 | driver->unbind(&udc->gadget); | 1619 | driver->unbind(&udc->gadget); |
1620 | udc->gadget.dev.driver = NULL; | ||
1621 | udc->gadget.dev.driver_data = NULL; | ||
1619 | udc->driver = NULL; | 1622 | udc->driver = NULL; |
1620 | 1623 | ||
1621 | DBG("unbound from %s\n", driver->driver.name); | 1624 | DBG("unbound from %s\n", driver->driver.name); |
@@ -1645,12 +1648,12 @@ static int __init at91udc_probe(struct platform_device *pdev) | |||
1645 | } | 1648 | } |
1646 | 1649 | ||
1647 | if (pdev->num_resources != 2) { | 1650 | if (pdev->num_resources != 2) { |
1648 | DBG("invalid num_resources"); | 1651 | DBG("invalid num_resources\n"); |
1649 | return -ENODEV; | 1652 | return -ENODEV; |
1650 | } | 1653 | } |
1651 | if ((pdev->resource[0].flags != IORESOURCE_MEM) | 1654 | if ((pdev->resource[0].flags != IORESOURCE_MEM) |
1652 | || (pdev->resource[1].flags != IORESOURCE_IRQ)) { | 1655 | || (pdev->resource[1].flags != IORESOURCE_IRQ)) { |
1653 | DBG("invalid resource type"); | 1656 | DBG("invalid resource type\n"); |
1654 | return -ENODEV; | 1657 | return -ENODEV; |
1655 | } | 1658 | } |
1656 | 1659 | ||
@@ -1672,10 +1675,26 @@ static int __init at91udc_probe(struct platform_device *pdev) | |||
1672 | udc->pdev = pdev; | 1675 | udc->pdev = pdev; |
1673 | udc->enabled = 0; | 1676 | udc->enabled = 0; |
1674 | 1677 | ||
1678 | /* rm9200 needs manual D+ pullup; off by default */ | ||
1679 | if (cpu_is_at91rm9200()) { | ||
1680 | if (udc->board.pullup_pin <= 0) { | ||
1681 | DBG("no D+ pullup?\n"); | ||
1682 | retval = -ENODEV; | ||
1683 | goto fail0; | ||
1684 | } | ||
1685 | retval = gpio_request(udc->board.pullup_pin, "udc_pullup"); | ||
1686 | if (retval) { | ||
1687 | DBG("D+ pullup is busy\n"); | ||
1688 | goto fail0; | ||
1689 | } | ||
1690 | gpio_direction_output(udc->board.pullup_pin, | ||
1691 | udc->board.pullup_active_low); | ||
1692 | } | ||
1693 | |||
1675 | udc->udp_baseaddr = ioremap(res->start, res->end - res->start + 1); | 1694 | udc->udp_baseaddr = ioremap(res->start, res->end - res->start + 1); |
1676 | if (!udc->udp_baseaddr) { | 1695 | if (!udc->udp_baseaddr) { |
1677 | release_mem_region(res->start, res->end - res->start + 1); | 1696 | retval = -ENOMEM; |
1678 | return -ENOMEM; | 1697 | goto fail0a; |
1679 | } | 1698 | } |
1680 | 1699 | ||
1681 | udc_reinit(udc); | 1700 | udc_reinit(udc); |
@@ -1686,12 +1705,13 @@ static int __init at91udc_probe(struct platform_device *pdev) | |||
1686 | if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk)) { | 1705 | if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk)) { |
1687 | DBG("clocks missing\n"); | 1706 | DBG("clocks missing\n"); |
1688 | retval = -ENODEV; | 1707 | retval = -ENODEV; |
1689 | goto fail0; | 1708 | /* NOTE: we "know" here that refcounts on these are NOPs */ |
1709 | goto fail0b; | ||
1690 | } | 1710 | } |
1691 | 1711 | ||
1692 | retval = device_register(&udc->gadget.dev); | 1712 | retval = device_register(&udc->gadget.dev); |
1693 | if (retval < 0) | 1713 | if (retval < 0) |
1694 | goto fail0; | 1714 | goto fail0b; |
1695 | 1715 | ||
1696 | /* don't do anything until we have both gadget driver and VBUS */ | 1716 | /* don't do anything until we have both gadget driver and VBUS */ |
1697 | clk_enable(udc->iclk); | 1717 | clk_enable(udc->iclk); |
@@ -1703,25 +1723,32 @@ static int __init at91udc_probe(struct platform_device *pdev) | |||
1703 | 1723 | ||
1704 | /* request UDC and maybe VBUS irqs */ | 1724 | /* request UDC and maybe VBUS irqs */ |
1705 | udc->udp_irq = platform_get_irq(pdev, 0); | 1725 | udc->udp_irq = platform_get_irq(pdev, 0); |
1706 | if (request_irq(udc->udp_irq, at91_udc_irq, | 1726 | retval = request_irq(udc->udp_irq, at91_udc_irq, |
1707 | IRQF_DISABLED, driver_name, udc)) { | 1727 | IRQF_DISABLED, driver_name, udc); |
1728 | if (retval < 0) { | ||
1708 | DBG("request irq %d failed\n", udc->udp_irq); | 1729 | DBG("request irq %d failed\n", udc->udp_irq); |
1709 | retval = -EBUSY; | ||
1710 | goto fail1; | 1730 | goto fail1; |
1711 | } | 1731 | } |
1712 | if (udc->board.vbus_pin > 0) { | 1732 | if (udc->board.vbus_pin > 0) { |
1733 | retval = gpio_request(udc->board.vbus_pin, "udc_vbus"); | ||
1734 | if (retval < 0) { | ||
1735 | DBG("request vbus pin failed\n"); | ||
1736 | goto fail2; | ||
1737 | } | ||
1738 | gpio_direction_input(udc->board.vbus_pin); | ||
1739 | |||
1713 | /* | 1740 | /* |
1714 | * Get the initial state of VBUS - we cannot expect | 1741 | * Get the initial state of VBUS - we cannot expect |
1715 | * a pending interrupt. | 1742 | * a pending interrupt. |
1716 | */ | 1743 | */ |
1717 | udc->vbus = at91_get_gpio_value(udc->board.vbus_pin); | 1744 | udc->vbus = gpio_get_value(udc->board.vbus_pin); |
1718 | if (request_irq(udc->board.vbus_pin, at91_vbus_irq, | 1745 | if (request_irq(udc->board.vbus_pin, at91_vbus_irq, |
1719 | IRQF_DISABLED, driver_name, udc)) { | 1746 | IRQF_DISABLED, driver_name, udc)) { |
1720 | DBG("request vbus irq %d failed\n", | 1747 | DBG("request vbus irq %d failed\n", |
1721 | udc->board.vbus_pin); | 1748 | udc->board.vbus_pin); |
1722 | free_irq(udc->udp_irq, udc); | 1749 | free_irq(udc->udp_irq, udc); |
1723 | retval = -EBUSY; | 1750 | retval = -EBUSY; |
1724 | goto fail1; | 1751 | goto fail3; |
1725 | } | 1752 | } |
1726 | } else { | 1753 | } else { |
1727 | DBG("no VBUS detection, assuming always-on\n"); | 1754 | DBG("no VBUS detection, assuming always-on\n"); |
@@ -1734,8 +1761,18 @@ static int __init at91udc_probe(struct platform_device *pdev) | |||
1734 | INFO("%s version %s\n", driver_name, DRIVER_VERSION); | 1761 | INFO("%s version %s\n", driver_name, DRIVER_VERSION); |
1735 | return 0; | 1762 | return 0; |
1736 | 1763 | ||
1764 | fail3: | ||
1765 | if (udc->board.vbus_pin > 0) | ||
1766 | gpio_free(udc->board.vbus_pin); | ||
1767 | fail2: | ||
1768 | free_irq(udc->udp_irq, udc); | ||
1737 | fail1: | 1769 | fail1: |
1738 | device_unregister(&udc->gadget.dev); | 1770 | device_unregister(&udc->gadget.dev); |
1771 | fail0b: | ||
1772 | iounmap(udc->udp_baseaddr); | ||
1773 | fail0a: | ||
1774 | if (cpu_is_at91rm9200()) | ||
1775 | gpio_free(udc->board.pullup_pin); | ||
1739 | fail0: | 1776 | fail0: |
1740 | release_mem_region(res->start, res->end - res->start + 1); | 1777 | release_mem_region(res->start, res->end - res->start + 1); |
1741 | DBG("%s probe failed, %d\n", driver_name, retval); | 1778 | DBG("%s probe failed, %d\n", driver_name, retval); |
@@ -1756,12 +1793,18 @@ static int __exit at91udc_remove(struct platform_device *pdev) | |||
1756 | 1793 | ||
1757 | device_init_wakeup(&pdev->dev, 0); | 1794 | device_init_wakeup(&pdev->dev, 0); |
1758 | remove_debug_file(udc); | 1795 | remove_debug_file(udc); |
1759 | if (udc->board.vbus_pin > 0) | 1796 | if (udc->board.vbus_pin > 0) { |
1760 | free_irq(udc->board.vbus_pin, udc); | 1797 | free_irq(udc->board.vbus_pin, udc); |
1798 | gpio_free(udc->board.vbus_pin); | ||
1799 | } | ||
1761 | free_irq(udc->udp_irq, udc); | 1800 | free_irq(udc->udp_irq, udc); |
1762 | device_unregister(&udc->gadget.dev); | 1801 | device_unregister(&udc->gadget.dev); |
1763 | 1802 | ||
1764 | iounmap(udc->udp_baseaddr); | 1803 | iounmap(udc->udp_baseaddr); |
1804 | |||
1805 | if (cpu_is_at91rm9200()) | ||
1806 | gpio_free(udc->board.pullup_pin); | ||
1807 | |||
1765 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1808 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1766 | release_mem_region(res->start, res->end - res->start + 1); | 1809 | release_mem_region(res->start, res->end - res->start + 1); |
1767 | 1810 | ||
diff --git a/drivers/usb/gadget/at91_udc.h b/drivers/usb/gadget/at91_udc.h index 7e34e2f864f9..a973f2a50fb9 100644 --- a/drivers/usb/gadget/at91_udc.h +++ b/drivers/usb/gadget/at91_udc.h | |||
@@ -53,7 +53,7 @@ | |||
53 | #define AT91_UDP_RXRSM (1 << 9) /* USB Resume Interrupt Status */ | 53 | #define AT91_UDP_RXRSM (1 << 9) /* USB Resume Interrupt Status */ |
54 | #define AT91_UDP_EXTRSM (1 << 10) /* External Resume Interrupt Status [AT91RM9200 only] */ | 54 | #define AT91_UDP_EXTRSM (1 << 10) /* External Resume Interrupt Status [AT91RM9200 only] */ |
55 | #define AT91_UDP_SOFINT (1 << 11) /* Start of Frame Interrupt Status */ | 55 | #define AT91_UDP_SOFINT (1 << 11) /* Start of Frame Interrupt Status */ |
56 | #define AT91_UDP_ENDBUSRES (1 << 12) /* End of Bus Reset Interrpt Status */ | 56 | #define AT91_UDP_ENDBUSRES (1 << 12) /* End of Bus Reset Interrupt Status */ |
57 | #define AT91_UDP_WAKEUP (1 << 13) /* USB Wakeup Interrupt Status [AT91RM9200 only] */ | 57 | #define AT91_UDP_WAKEUP (1 << 13) /* USB Wakeup Interrupt Status [AT91RM9200 only] */ |
58 | 58 | ||
59 | #define AT91_UDP_ICR 0x20 /* Interrupt Clear Register */ | 59 | #define AT91_UDP_ICR 0x20 /* Interrupt Clear Register */ |
@@ -158,13 +158,7 @@ struct at91_request { | |||
158 | 158 | ||
159 | /*-------------------------------------------------------------------------*/ | 159 | /*-------------------------------------------------------------------------*/ |
160 | 160 | ||
161 | #ifdef DEBUG | 161 | #ifdef VERBOSE_DEBUG |
162 | #define DBG(stuff...) printk(KERN_DEBUG "udc: " stuff) | ||
163 | #else | ||
164 | #define DBG(stuff...) do{}while(0) | ||
165 | #endif | ||
166 | |||
167 | #ifdef VERBOSE | ||
168 | # define VDBG DBG | 162 | # define VDBG DBG |
169 | #else | 163 | #else |
170 | # define VDBG(stuff...) do{}while(0) | 164 | # define VDBG(stuff...) do{}while(0) |
@@ -176,9 +170,10 @@ struct at91_request { | |||
176 | # define PACKET(stuff...) do{}while(0) | 170 | # define PACKET(stuff...) do{}while(0) |
177 | #endif | 171 | #endif |
178 | 172 | ||
179 | #define ERR(stuff...) printk(KERN_ERR "udc: " stuff) | 173 | #define ERR(stuff...) pr_err("udc: " stuff) |
180 | #define WARN(stuff...) printk(KERN_WARNING "udc: " stuff) | 174 | #define WARN(stuff...) pr_warning("udc: " stuff) |
181 | #define INFO(stuff...) printk(KERN_INFO "udc: " stuff) | 175 | #define INFO(stuff...) pr_info("udc: " stuff) |
176 | #define DBG(stuff...) pr_debug("udc: " stuff) | ||
182 | 177 | ||
183 | #endif | 178 | #endif |
184 | 179 | ||
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index 4fb5ff469574..af8b2a3a2d4a 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c | |||
@@ -1384,8 +1384,7 @@ delegate: | |||
1384 | return retval; | 1384 | return retval; |
1385 | 1385 | ||
1386 | stall: | 1386 | stall: |
1387 | printk(KERN_ERR | 1387 | pr_err("udc: %s: Invalid setup request: %02x.%02x v%04x i%04x l%d, " |
1388 | "udc: %s: Invalid setup request: %02x.%02x v%04x i%04x l%d, " | ||
1389 | "halting endpoint...\n", | 1388 | "halting endpoint...\n", |
1390 | ep->ep.name, crq->bRequestType, crq->bRequest, | 1389 | ep->ep.name, crq->bRequestType, crq->bRequest, |
1391 | le16_to_cpu(crq->wValue), le16_to_cpu(crq->wIndex), | 1390 | le16_to_cpu(crq->wValue), le16_to_cpu(crq->wIndex), |
@@ -1456,8 +1455,7 @@ restart: | |||
1456 | set_protocol_stall(udc, ep); | 1455 | set_protocol_stall(udc, ep); |
1457 | break; | 1456 | break; |
1458 | default: | 1457 | default: |
1459 | printk(KERN_ERR | 1458 | pr_err("udc: %s: TXCOMP: Invalid endpoint state %d, " |
1460 | "udc: %s: TXCOMP: Invalid endpoint state %d, " | ||
1461 | "halting endpoint...\n", | 1459 | "halting endpoint...\n", |
1462 | ep->ep.name, ep->state); | 1460 | ep->ep.name, ep->state); |
1463 | set_protocol_stall(udc, ep); | 1461 | set_protocol_stall(udc, ep); |
@@ -1486,8 +1484,7 @@ restart: | |||
1486 | default: | 1484 | default: |
1487 | usba_ep_writel(ep, CLR_STA, USBA_RX_BK_RDY); | 1485 | usba_ep_writel(ep, CLR_STA, USBA_RX_BK_RDY); |
1488 | usba_ep_writel(ep, CTL_DIS, USBA_RX_BK_RDY); | 1486 | usba_ep_writel(ep, CTL_DIS, USBA_RX_BK_RDY); |
1489 | printk(KERN_ERR | 1487 | pr_err("udc: %s: RXRDY: Invalid endpoint state %d, " |
1490 | "udc: %s: RXRDY: Invalid endpoint state %d, " | ||
1491 | "halting endpoint...\n", | 1488 | "halting endpoint...\n", |
1492 | ep->ep.name, ep->state); | 1489 | ep->ep.name, ep->state); |
1493 | set_protocol_stall(udc, ep); | 1490 | set_protocol_stall(udc, ep); |
@@ -1532,7 +1529,7 @@ restart: | |||
1532 | pkt_len = USBA_BFEXT(BYTE_COUNT, usba_ep_readl(ep, STA)); | 1529 | pkt_len = USBA_BFEXT(BYTE_COUNT, usba_ep_readl(ep, STA)); |
1533 | DBG(DBG_HW, "Packet length: %u\n", pkt_len); | 1530 | DBG(DBG_HW, "Packet length: %u\n", pkt_len); |
1534 | if (pkt_len != sizeof(crq)) { | 1531 | if (pkt_len != sizeof(crq)) { |
1535 | printk(KERN_WARNING "udc: Invalid packet length %u " | 1532 | pr_warning("udc: Invalid packet length %u " |
1536 | "(expected %lu)\n", pkt_len, sizeof(crq)); | 1533 | "(expected %lu)\n", pkt_len, sizeof(crq)); |
1537 | set_protocol_stall(udc, ep); | 1534 | set_protocol_stall(udc, ep); |
1538 | return; | 1535 | return; |
diff --git a/drivers/usb/gadget/atmel_usba_udc.h b/drivers/usb/gadget/atmel_usba_udc.h index a68304e31a68..08bf6f9aaf7e 100644 --- a/drivers/usb/gadget/atmel_usba_udc.h +++ b/drivers/usb/gadget/atmel_usba_udc.h | |||
@@ -216,7 +216,6 @@ | |||
216 | #define FIFO_IOMEM_ID 0 | 216 | #define FIFO_IOMEM_ID 0 |
217 | #define CTRL_IOMEM_ID 1 | 217 | #define CTRL_IOMEM_ID 1 |
218 | 218 | ||
219 | #ifdef DEBUG | ||
220 | #define DBG_ERR 0x0001 /* report all error returns */ | 219 | #define DBG_ERR 0x0001 /* report all error returns */ |
221 | #define DBG_HW 0x0002 /* debug hardware initialization */ | 220 | #define DBG_HW 0x0002 /* debug hardware initialization */ |
222 | #define DBG_GADGET 0x0004 /* calls to/from gadget driver */ | 221 | #define DBG_GADGET 0x0004 /* calls to/from gadget driver */ |
@@ -230,14 +229,12 @@ | |||
230 | #define DBG_NONE 0x0000 | 229 | #define DBG_NONE 0x0000 |
231 | 230 | ||
232 | #define DEBUG_LEVEL (DBG_ERR) | 231 | #define DEBUG_LEVEL (DBG_ERR) |
232 | |||
233 | #define DBG(level, fmt, ...) \ | 233 | #define DBG(level, fmt, ...) \ |
234 | do { \ | 234 | do { \ |
235 | if ((level) & DEBUG_LEVEL) \ | 235 | if ((level) & DEBUG_LEVEL) \ |
236 | printk(KERN_DEBUG "udc: " fmt, ## __VA_ARGS__); \ | 236 | pr_debug("udc: " fmt, ## __VA_ARGS__); \ |
237 | } while (0) | 237 | } while (0) |
238 | #else | ||
239 | #define DBG(level, fmt...) | ||
240 | #endif | ||
241 | 238 | ||
242 | enum usba_ctrl_state { | 239 | enum usba_ctrl_state { |
243 | WAIT_FOR_SETUP, | 240 | WAIT_FOR_SETUP, |
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 9db2482bdfa2..cbe44535c0f0 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -61,6 +61,8 @@ | |||
61 | #define DRIVER_DESC "USB Host+Gadget Emulator" | 61 | #define DRIVER_DESC "USB Host+Gadget Emulator" |
62 | #define DRIVER_VERSION "02 May 2005" | 62 | #define DRIVER_VERSION "02 May 2005" |
63 | 63 | ||
64 | #define POWER_BUDGET 500 /* in mA; use 8 for low-power port testing */ | ||
65 | |||
64 | static const char driver_name [] = "dummy_hcd"; | 66 | static const char driver_name [] = "dummy_hcd"; |
65 | static const char driver_desc [] = "USB Host+Gadget Emulator"; | 67 | static const char driver_desc [] = "USB Host+Gadget Emulator"; |
66 | 68 | ||
@@ -772,18 +774,17 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
772 | list_del_init (&dum->ep [0].ep.ep_list); | 774 | list_del_init (&dum->ep [0].ep.ep_list); |
773 | INIT_LIST_HEAD(&dum->fifo_req.queue); | 775 | INIT_LIST_HEAD(&dum->fifo_req.queue); |
774 | 776 | ||
777 | driver->driver.bus = NULL; | ||
775 | dum->driver = driver; | 778 | dum->driver = driver; |
776 | dum->gadget.dev.driver = &driver->driver; | 779 | dum->gadget.dev.driver = &driver->driver; |
777 | dev_dbg (udc_dev(dum), "binding gadget driver '%s'\n", | 780 | dev_dbg (udc_dev(dum), "binding gadget driver '%s'\n", |
778 | driver->driver.name); | 781 | driver->driver.name); |
779 | if ((retval = driver->bind (&dum->gadget)) != 0) | 782 | retval = driver->bind(&dum->gadget); |
780 | goto err_bind_gadget; | 783 | if (retval) { |
781 | 784 | dum->driver = NULL; | |
782 | driver->driver.bus = dum->gadget.dev.parent->bus; | 785 | dum->gadget.dev.driver = NULL; |
783 | if ((retval = driver_register (&driver->driver)) != 0) | 786 | return retval; |
784 | goto err_register; | 787 | } |
785 | if ((retval = device_bind_driver (&dum->gadget.dev)) != 0) | ||
786 | goto err_bind_driver; | ||
787 | 788 | ||
788 | /* khubd will enumerate this in a while */ | 789 | /* khubd will enumerate this in a while */ |
789 | spin_lock_irq (&dum->lock); | 790 | spin_lock_irq (&dum->lock); |
@@ -793,20 +794,6 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
793 | 794 | ||
794 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); | 795 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); |
795 | return 0; | 796 | return 0; |
796 | |||
797 | err_bind_driver: | ||
798 | driver_unregister (&driver->driver); | ||
799 | err_register: | ||
800 | if (driver->unbind) | ||
801 | driver->unbind (&dum->gadget); | ||
802 | spin_lock_irq (&dum->lock); | ||
803 | dum->pullup = 0; | ||
804 | set_link_state (dum); | ||
805 | spin_unlock_irq (&dum->lock); | ||
806 | err_bind_gadget: | ||
807 | dum->driver = NULL; | ||
808 | dum->gadget.dev.driver = NULL; | ||
809 | return retval; | ||
810 | } | 797 | } |
811 | EXPORT_SYMBOL (usb_gadget_register_driver); | 798 | EXPORT_SYMBOL (usb_gadget_register_driver); |
812 | 799 | ||
@@ -830,11 +817,9 @@ usb_gadget_unregister_driver (struct usb_gadget_driver *driver) | |||
830 | spin_unlock_irqrestore (&dum->lock, flags); | 817 | spin_unlock_irqrestore (&dum->lock, flags); |
831 | 818 | ||
832 | driver->unbind (&dum->gadget); | 819 | driver->unbind (&dum->gadget); |
820 | dum->gadget.dev.driver = NULL; | ||
833 | dum->driver = NULL; | 821 | dum->driver = NULL; |
834 | 822 | ||
835 | device_release_driver (&dum->gadget.dev); | ||
836 | driver_unregister (&driver->driver); | ||
837 | |||
838 | spin_lock_irqsave (&dum->lock, flags); | 823 | spin_lock_irqsave (&dum->lock, flags); |
839 | dum->pullup = 0; | 824 | dum->pullup = 0; |
840 | set_link_state (dum); | 825 | set_link_state (dum); |
@@ -1827,8 +1812,7 @@ static int dummy_start (struct usb_hcd *hcd) | |||
1827 | 1812 | ||
1828 | INIT_LIST_HEAD (&dum->urbp_list); | 1813 | INIT_LIST_HEAD (&dum->urbp_list); |
1829 | 1814 | ||
1830 | /* only show a low-power port: just 8mA */ | 1815 | hcd->power_budget = POWER_BUDGET; |
1831 | hcd->power_budget = 8; | ||
1832 | hcd->state = HC_STATE_RUNNING; | 1816 | hcd->state = HC_STATE_RUNNING; |
1833 | hcd->uses_new_polling = 1; | 1817 | hcd->uses_new_polling = 1; |
1834 | 1818 | ||
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 9e732bff9df0..a70e255402b8 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -1067,19 +1067,19 @@ done: | |||
1067 | 1067 | ||
1068 | /* on error, disable any endpoints */ | 1068 | /* on error, disable any endpoints */ |
1069 | if (result < 0) { | 1069 | if (result < 0) { |
1070 | if (!subset_active(dev)) | 1070 | if (!subset_active(dev) && dev->status_ep) |
1071 | (void) usb_ep_disable (dev->status_ep); | 1071 | (void) usb_ep_disable (dev->status_ep); |
1072 | dev->status = NULL; | 1072 | dev->status = NULL; |
1073 | (void) usb_ep_disable (dev->in_ep); | 1073 | (void) usb_ep_disable (dev->in_ep); |
1074 | (void) usb_ep_disable (dev->out_ep); | 1074 | (void) usb_ep_disable (dev->out_ep); |
1075 | dev->in = NULL; | 1075 | dev->in = NULL; |
1076 | dev->out = NULL; | 1076 | dev->out = NULL; |
1077 | } else | 1077 | } |
1078 | 1078 | ||
1079 | /* activate non-CDC configs right away | 1079 | /* activate non-CDC configs right away |
1080 | * this isn't strictly according to the RNDIS spec | 1080 | * this isn't strictly according to the RNDIS spec |
1081 | */ | 1081 | */ |
1082 | if (!cdc_active (dev)) { | 1082 | else if (!cdc_active (dev)) { |
1083 | netif_carrier_on (dev->net); | 1083 | netif_carrier_on (dev->net); |
1084 | if (netif_running (dev->net)) { | 1084 | if (netif_running (dev->net)) { |
1085 | spin_unlock (&dev->lock); | 1085 | spin_unlock (&dev->lock); |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 1d174dcb3ac9..3301167d4f2a 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -275,19 +275,15 @@ MODULE_LICENSE("Dual BSD/GPL"); | |||
275 | 275 | ||
276 | /*-------------------------------------------------------------------------*/ | 276 | /*-------------------------------------------------------------------------*/ |
277 | 277 | ||
278 | #ifdef DEBUG | ||
279 | #define LDBG(lun,fmt,args...) \ | 278 | #define LDBG(lun,fmt,args...) \ |
280 | dev_dbg(&(lun)->dev , fmt , ## args) | 279 | dev_dbg(&(lun)->dev , fmt , ## args) |
281 | #define MDBG(fmt,args...) \ | 280 | #define MDBG(fmt,args...) \ |
282 | printk(KERN_DEBUG DRIVER_NAME ": " fmt , ## args) | 281 | pr_debug(DRIVER_NAME ": " fmt , ## args) |
283 | #else | 282 | |
284 | #define LDBG(lun,fmt,args...) \ | 283 | #ifndef DEBUG |
285 | do { } while (0) | ||
286 | #define MDBG(fmt,args...) \ | ||
287 | do { } while (0) | ||
288 | #undef VERBOSE_DEBUG | 284 | #undef VERBOSE_DEBUG |
289 | #undef DUMP_MSGS | 285 | #undef DUMP_MSGS |
290 | #endif /* DEBUG */ | 286 | #endif /* !DEBUG */ |
291 | 287 | ||
292 | #ifdef VERBOSE_DEBUG | 288 | #ifdef VERBOSE_DEBUG |
293 | #define VLDBG LDBG | 289 | #define VLDBG LDBG |
@@ -304,7 +300,7 @@ MODULE_LICENSE("Dual BSD/GPL"); | |||
304 | dev_info(&(lun)->dev , fmt , ## args) | 300 | dev_info(&(lun)->dev , fmt , ## args) |
305 | 301 | ||
306 | #define MINFO(fmt,args...) \ | 302 | #define MINFO(fmt,args...) \ |
307 | printk(KERN_INFO DRIVER_NAME ": " fmt , ## args) | 303 | pr_info(DRIVER_NAME ": " fmt , ## args) |
308 | 304 | ||
309 | #define DBG(d, fmt, args...) \ | 305 | #define DBG(d, fmt, args...) \ |
310 | dev_dbg(&(d)->gadget->dev , fmt , ## args) | 306 | dev_dbg(&(d)->gadget->dev , fmt , ## args) |
diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c index 038e7d7b4da1..63e8fa3a69e1 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.c +++ b/drivers/usb/gadget/fsl_usb2_udc.c | |||
@@ -776,7 +776,7 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
776 | VDBG("%s, bad params\n", __FUNCTION__); | 776 | VDBG("%s, bad params\n", __FUNCTION__); |
777 | return -EINVAL; | 777 | return -EINVAL; |
778 | } | 778 | } |
779 | if (!_ep || (!ep->desc && ep_index(ep))) { | 779 | if (unlikely(!_ep || !ep->desc)) { |
780 | VDBG("%s, bad ep\n", __FUNCTION__); | 780 | VDBG("%s, bad ep\n", __FUNCTION__); |
781 | return -EINVAL; | 781 | return -EINVAL; |
782 | } | 782 | } |
@@ -1896,7 +1896,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
1896 | 1896 | ||
1897 | spin_lock_irqsave(&udc->lock, flags); | 1897 | spin_lock_irqsave(&udc->lock, flags); |
1898 | 1898 | ||
1899 | /* ------basic driver infomation ---- */ | 1899 | /* ------basic driver information ---- */ |
1900 | t = scnprintf(next, size, | 1900 | t = scnprintf(next, size, |
1901 | DRIVER_DESC "\n" | 1901 | DRIVER_DESC "\n" |
1902 | "%s version: %s\n" | 1902 | "%s version: %s\n" |
diff --git a/drivers/usb/gadget/fsl_usb2_udc.h b/drivers/usb/gadget/fsl_usb2_udc.h index 832ab82b4882..9fb0b1ec8526 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.h +++ b/drivers/usb/gadget/fsl_usb2_udc.h | |||
@@ -551,9 +551,9 @@ static void dump_msg(const char *label, const u8 * buf, unsigned int length) | |||
551 | #define VDBG(stuff...) do{}while(0) | 551 | #define VDBG(stuff...) do{}while(0) |
552 | #endif | 552 | #endif |
553 | 553 | ||
554 | #define ERR(stuff...) printk(KERN_ERR "udc: " stuff) | 554 | #define ERR(stuff...) pr_err("udc: " stuff) |
555 | #define WARN(stuff...) printk(KERN_WARNING "udc: " stuff) | 555 | #define WARN(stuff...) pr_warning("udc: " stuff) |
556 | #define INFO(stuff...) printk(KERN_INFO "udc: " stuff) | 556 | #define INFO(stuff...) pr_info("udc: " stuff) |
557 | 557 | ||
558 | /*-------------------------------------------------------------------------*/ | 558 | /*-------------------------------------------------------------------------*/ |
559 | 559 | ||
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index 7da7fcb05640..5b42ccd0035f 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c | |||
@@ -1158,7 +1158,7 @@ static int __devinit gmidi_bind(struct usb_gadget *gadget) | |||
1158 | /* support optional vendor/distro customization */ | 1158 | /* support optional vendor/distro customization */ |
1159 | if (idVendor) { | 1159 | if (idVendor) { |
1160 | if (!idProduct) { | 1160 | if (!idProduct) { |
1161 | printk(KERN_ERR "idVendor needs idProduct!\n"); | 1161 | pr_err("idVendor needs idProduct!\n"); |
1162 | return -ENODEV; | 1162 | return -ENODEV; |
1163 | } | 1163 | } |
1164 | device_desc.idVendor = cpu_to_le16(idVendor); | 1164 | device_desc.idVendor = cpu_to_le16(idVendor); |
@@ -1190,7 +1190,7 @@ static int __devinit gmidi_bind(struct usb_gadget *gadget) | |||
1190 | in_ep = usb_ep_autoconfig(gadget, &bulk_in_desc); | 1190 | in_ep = usb_ep_autoconfig(gadget, &bulk_in_desc); |
1191 | if (!in_ep) { | 1191 | if (!in_ep) { |
1192 | autoconf_fail: | 1192 | autoconf_fail: |
1193 | printk(KERN_ERR "%s: can't autoconfigure on %s\n", | 1193 | pr_err("%s: can't autoconfigure on %s\n", |
1194 | shortname, gadget->name); | 1194 | shortname, gadget->name); |
1195 | return -ENODEV; | 1195 | return -ENODEV; |
1196 | } | 1196 | } |
@@ -1212,7 +1212,7 @@ autoconf_fail: | |||
1212 | * it SHOULD NOT have problems with bulk-capable hardware. | 1212 | * it SHOULD NOT have problems with bulk-capable hardware. |
1213 | * so warn about unrecognized controllers, don't panic. | 1213 | * so warn about unrecognized controllers, don't panic. |
1214 | */ | 1214 | */ |
1215 | printk(KERN_WARNING "%s: controller '%s' not recognized\n", | 1215 | pr_warning("%s: controller '%s' not recognized\n", |
1216 | shortname, gadget->name); | 1216 | shortname, gadget->name); |
1217 | device_desc.bcdDevice = __constant_cpu_to_le16(0x9999); | 1217 | device_desc.bcdDevice = __constant_cpu_to_le16(0x9999); |
1218 | } | 1218 | } |
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index 2ec9d196a8cf..d3e702576de6 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c | |||
@@ -1422,6 +1422,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
1422 | spin_unlock_irqrestore(&dev->lock, flags); | 1422 | spin_unlock_irqrestore(&dev->lock, flags); |
1423 | 1423 | ||
1424 | driver->unbind(&dev->gadget); | 1424 | driver->unbind(&dev->gadget); |
1425 | dev->gadget.dev.driver = NULL; | ||
1425 | 1426 | ||
1426 | DBG(dev, "unregistered driver '%s'\n", driver->driver.name); | 1427 | DBG(dev, "unregistered driver '%s'\n", driver->driver.name); |
1427 | return 0; | 1428 | return 0; |
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index 47ef8bd58a00..805602a687cb 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c | |||
@@ -1699,7 +1699,7 @@ gadgetfs_bind (struct usb_gadget *gadget) | |||
1699 | if (!dev) | 1699 | if (!dev) |
1700 | return -ESRCH; | 1700 | return -ESRCH; |
1701 | if (0 != strcmp (CHIP, gadget->name)) { | 1701 | if (0 != strcmp (CHIP, gadget->name)) { |
1702 | printk (KERN_ERR "%s expected %s controller not %s\n", | 1702 | pr_err("%s expected %s controller not %s\n", |
1703 | shortname, CHIP, gadget->name); | 1703 | shortname, CHIP, gadget->name); |
1704 | return -ENODEV; | 1704 | return -ENODEV; |
1705 | } | 1705 | } |
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c index 367b75c0b25b..37243ef7104e 100644 --- a/drivers/usb/gadget/lh7a40x_udc.c +++ b/drivers/usb/gadget/lh7a40x_udc.c | |||
@@ -474,6 +474,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
474 | spin_unlock_irqrestore(&dev->lock, flags); | 474 | spin_unlock_irqrestore(&dev->lock, flags); |
475 | 475 | ||
476 | driver->unbind(&dev->gadget); | 476 | driver->unbind(&dev->gadget); |
477 | dev->gadget.dev.driver = NULL; | ||
477 | device_del(&dev->gadget.dev); | 478 | device_del(&dev->gadget.dev); |
478 | 479 | ||
479 | udc_disable(dev); | 480 | udc_disable(dev); |
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c index ebc5536aa271..835948f0715a 100644 --- a/drivers/usb/gadget/m66592-udc.c +++ b/drivers/usb/gadget/m66592-udc.c | |||
@@ -36,9 +36,14 @@ MODULE_DESCRIPTION("M66592 USB gadget driver"); | |||
36 | MODULE_LICENSE("GPL"); | 36 | MODULE_LICENSE("GPL"); |
37 | MODULE_AUTHOR("Yoshihiro Shimoda"); | 37 | MODULE_AUTHOR("Yoshihiro Shimoda"); |
38 | 38 | ||
39 | #define DRIVER_VERSION "29 May 2007" | 39 | #define DRIVER_VERSION "18 Oct 2007" |
40 | 40 | ||
41 | /* module parameters */ | 41 | /* module parameters */ |
42 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | ||
43 | static unsigned short endian = M66592_LITTLE; | ||
44 | module_param(endian, ushort, 0644); | ||
45 | MODULE_PARM_DESC(endian, "data endian: big=0, little=0 (default=0)"); | ||
46 | #else | ||
42 | static unsigned short clock = M66592_XTAL24; | 47 | static unsigned short clock = M66592_XTAL24; |
43 | module_param(clock, ushort, 0644); | 48 | module_param(clock, ushort, 0644); |
44 | MODULE_PARM_DESC(clock, "input clock: 48MHz=32768, 24MHz=16384, 12MHz=0 " | 49 | MODULE_PARM_DESC(clock, "input clock: 48MHz=32768, 24MHz=16384, 12MHz=0 " |
@@ -56,6 +61,7 @@ static unsigned short irq_sense = M66592_INTL; | |||
56 | module_param(irq_sense, ushort, 0644); | 61 | module_param(irq_sense, ushort, 0644); |
57 | MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=2, falling edge=0 " | 62 | MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=2, falling edge=0 " |
58 | "(default=2)"); | 63 | "(default=2)"); |
64 | #endif | ||
59 | 65 | ||
60 | static const char udc_name[] = "m66592_udc"; | 66 | static const char udc_name[] = "m66592_udc"; |
61 | static const char *m66592_ep_name[] = { | 67 | static const char *m66592_ep_name[] = { |
@@ -141,7 +147,7 @@ static inline u16 control_reg_get_pid(struct m66592 *m66592, u16 pipenum) | |||
141 | offset = get_pipectr_addr(pipenum); | 147 | offset = get_pipectr_addr(pipenum); |
142 | pid = m66592_read(m66592, offset) & M66592_PID; | 148 | pid = m66592_read(m66592, offset) & M66592_PID; |
143 | } else | 149 | } else |
144 | printk(KERN_ERR "unexpect pipe num (%d)\n", pipenum); | 150 | pr_err("unexpect pipe num (%d)\n", pipenum); |
145 | 151 | ||
146 | return pid; | 152 | return pid; |
147 | } | 153 | } |
@@ -157,7 +163,7 @@ static inline void control_reg_set_pid(struct m66592 *m66592, u16 pipenum, | |||
157 | offset = get_pipectr_addr(pipenum); | 163 | offset = get_pipectr_addr(pipenum); |
158 | m66592_mdfy(m66592, pid, M66592_PID, offset); | 164 | m66592_mdfy(m66592, pid, M66592_PID, offset); |
159 | } else | 165 | } else |
160 | printk(KERN_ERR "unexpect pipe num (%d)\n", pipenum); | 166 | pr_err("unexpect pipe num (%d)\n", pipenum); |
161 | } | 167 | } |
162 | 168 | ||
163 | static inline void pipe_start(struct m66592 *m66592, u16 pipenum) | 169 | static inline void pipe_start(struct m66592 *m66592, u16 pipenum) |
@@ -186,7 +192,7 @@ static inline u16 control_reg_get(struct m66592 *m66592, u16 pipenum) | |||
186 | offset = get_pipectr_addr(pipenum); | 192 | offset = get_pipectr_addr(pipenum); |
187 | ret = m66592_read(m66592, offset); | 193 | ret = m66592_read(m66592, offset); |
188 | } else | 194 | } else |
189 | printk(KERN_ERR "unexpect pipe num (%d)\n", pipenum); | 195 | pr_err("unexpect pipe num (%d)\n", pipenum); |
190 | 196 | ||
191 | return ret; | 197 | return ret; |
192 | } | 198 | } |
@@ -203,7 +209,7 @@ static inline void control_reg_sqclr(struct m66592 *m66592, u16 pipenum) | |||
203 | offset = get_pipectr_addr(pipenum); | 209 | offset = get_pipectr_addr(pipenum); |
204 | m66592_bset(m66592, M66592_SQCLR, offset); | 210 | m66592_bset(m66592, M66592_SQCLR, offset); |
205 | } else | 211 | } else |
206 | printk(KERN_ERR "unexpect pipe num(%d)\n", pipenum); | 212 | pr_err("unexpect pipe num(%d)\n", pipenum); |
207 | } | 213 | } |
208 | 214 | ||
209 | static inline int get_buffer_size(struct m66592 *m66592, u16 pipenum) | 215 | static inline int get_buffer_size(struct m66592 *m66592, u16 pipenum) |
@@ -285,7 +291,7 @@ static int pipe_buffer_setting(struct m66592 *m66592, | |||
285 | break; | 291 | break; |
286 | } | 292 | } |
287 | if (m66592->bi_bufnum > M66592_MAX_BUFNUM) { | 293 | if (m66592->bi_bufnum > M66592_MAX_BUFNUM) { |
288 | printk(KERN_ERR "m66592 pipe memory is insufficient(%d)\n", | 294 | pr_err("m66592 pipe memory is insufficient(%d)\n", |
289 | m66592->bi_bufnum); | 295 | m66592->bi_bufnum); |
290 | return -ENOMEM; | 296 | return -ENOMEM; |
291 | } | 297 | } |
@@ -326,7 +332,7 @@ static void pipe_buffer_release(struct m66592 *m66592, | |||
326 | if (info->type == M66592_BULK) | 332 | if (info->type == M66592_BULK) |
327 | m66592->bulk--; | 333 | m66592->bulk--; |
328 | } else | 334 | } else |
329 | printk(KERN_ERR "ep_release: unexpect pipenum (%d)\n", | 335 | pr_err("ep_release: unexpect pipenum (%d)\n", |
330 | info->pipe); | 336 | info->pipe); |
331 | } | 337 | } |
332 | 338 | ||
@@ -360,6 +366,7 @@ static void m66592_ep_setting(struct m66592 *m66592, struct m66592_ep *ep, | |||
360 | ep->fifosel = M66592_D0FIFOSEL; | 366 | ep->fifosel = M66592_D0FIFOSEL; |
361 | ep->fifoctr = M66592_D0FIFOCTR; | 367 | ep->fifoctr = M66592_D0FIFOCTR; |
362 | ep->fifotrn = M66592_D0FIFOTRN; | 368 | ep->fifotrn = M66592_D0FIFOTRN; |
369 | #if !defined(CONFIG_SUPERH_BUILT_IN_M66592) | ||
363 | } else if (m66592->num_dma == 1) { | 370 | } else if (m66592->num_dma == 1) { |
364 | m66592->num_dma++; | 371 | m66592->num_dma++; |
365 | ep->use_dma = 1; | 372 | ep->use_dma = 1; |
@@ -367,6 +374,7 @@ static void m66592_ep_setting(struct m66592 *m66592, struct m66592_ep *ep, | |||
367 | ep->fifosel = M66592_D1FIFOSEL; | 374 | ep->fifosel = M66592_D1FIFOSEL; |
368 | ep->fifoctr = M66592_D1FIFOCTR; | 375 | ep->fifoctr = M66592_D1FIFOCTR; |
369 | ep->fifotrn = M66592_D1FIFOTRN; | 376 | ep->fifotrn = M66592_D1FIFOTRN; |
377 | #endif | ||
370 | } else { | 378 | } else { |
371 | ep->use_dma = 0; | 379 | ep->use_dma = 0; |
372 | ep->fifoaddr = M66592_CFIFO; | 380 | ep->fifoaddr = M66592_CFIFO; |
@@ -422,7 +430,7 @@ static int alloc_pipe_config(struct m66592_ep *ep, | |||
422 | case USB_ENDPOINT_XFER_BULK: | 430 | case USB_ENDPOINT_XFER_BULK: |
423 | if (m66592->bulk >= M66592_MAX_NUM_BULK) { | 431 | if (m66592->bulk >= M66592_MAX_NUM_BULK) { |
424 | if (m66592->isochronous >= M66592_MAX_NUM_ISOC) { | 432 | if (m66592->isochronous >= M66592_MAX_NUM_ISOC) { |
425 | printk(KERN_ERR "bulk pipe is insufficient\n"); | 433 | pr_err("bulk pipe is insufficient\n"); |
426 | return -ENODEV; | 434 | return -ENODEV; |
427 | } else { | 435 | } else { |
428 | info.pipe = M66592_BASE_PIPENUM_ISOC | 436 | info.pipe = M66592_BASE_PIPENUM_ISOC |
@@ -438,7 +446,7 @@ static int alloc_pipe_config(struct m66592_ep *ep, | |||
438 | break; | 446 | break; |
439 | case USB_ENDPOINT_XFER_INT: | 447 | case USB_ENDPOINT_XFER_INT: |
440 | if (m66592->interrupt >= M66592_MAX_NUM_INT) { | 448 | if (m66592->interrupt >= M66592_MAX_NUM_INT) { |
441 | printk(KERN_ERR "interrupt pipe is insufficient\n"); | 449 | pr_err("interrupt pipe is insufficient\n"); |
442 | return -ENODEV; | 450 | return -ENODEV; |
443 | } | 451 | } |
444 | info.pipe = M66592_BASE_PIPENUM_INT + m66592->interrupt; | 452 | info.pipe = M66592_BASE_PIPENUM_INT + m66592->interrupt; |
@@ -447,7 +455,7 @@ static int alloc_pipe_config(struct m66592_ep *ep, | |||
447 | break; | 455 | break; |
448 | case USB_ENDPOINT_XFER_ISOC: | 456 | case USB_ENDPOINT_XFER_ISOC: |
449 | if (m66592->isochronous >= M66592_MAX_NUM_ISOC) { | 457 | if (m66592->isochronous >= M66592_MAX_NUM_ISOC) { |
450 | printk(KERN_ERR "isochronous pipe is insufficient\n"); | 458 | pr_err("isochronous pipe is insufficient\n"); |
451 | return -ENODEV; | 459 | return -ENODEV; |
452 | } | 460 | } |
453 | info.pipe = M66592_BASE_PIPENUM_ISOC + m66592->isochronous; | 461 | info.pipe = M66592_BASE_PIPENUM_ISOC + m66592->isochronous; |
@@ -455,7 +463,7 @@ static int alloc_pipe_config(struct m66592_ep *ep, | |||
455 | counter = &m66592->isochronous; | 463 | counter = &m66592->isochronous; |
456 | break; | 464 | break; |
457 | default: | 465 | default: |
458 | printk(KERN_ERR "unexpect xfer type\n"); | 466 | pr_err("unexpect xfer type\n"); |
459 | return -EINVAL; | 467 | return -EINVAL; |
460 | } | 468 | } |
461 | ep->type = info.type; | 469 | ep->type = info.type; |
@@ -470,7 +478,7 @@ static int alloc_pipe_config(struct m66592_ep *ep, | |||
470 | 478 | ||
471 | ret = pipe_buffer_setting(m66592, &info); | 479 | ret = pipe_buffer_setting(m66592, &info); |
472 | if (ret < 0) { | 480 | if (ret < 0) { |
473 | printk(KERN_ERR "pipe_buffer_setting fail\n"); | 481 | pr_err("pipe_buffer_setting fail\n"); |
474 | return ret; | 482 | return ret; |
475 | } | 483 | } |
476 | 484 | ||
@@ -606,11 +614,33 @@ static void start_ep0(struct m66592_ep *ep, struct m66592_request *req) | |||
606 | control_end(ep->m66592, 0); | 614 | control_end(ep->m66592, 0); |
607 | break; | 615 | break; |
608 | default: | 616 | default: |
609 | printk(KERN_ERR "start_ep0: unexpect ctsq(%x)\n", ctsq); | 617 | pr_err("start_ep0: unexpect ctsq(%x)\n", ctsq); |
610 | break; | 618 | break; |
611 | } | 619 | } |
612 | } | 620 | } |
613 | 621 | ||
622 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | ||
623 | static void init_controller(struct m66592 *m66592) | ||
624 | { | ||
625 | usbf_start_clock(); | ||
626 | m66592_bset(m66592, M66592_HSE, M66592_SYSCFG); /* High spd */ | ||
627 | m66592_bclr(m66592, M66592_USBE, M66592_SYSCFG); | ||
628 | m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG); | ||
629 | m66592_bset(m66592, M66592_USBE, M66592_SYSCFG); | ||
630 | |||
631 | /* This is a workaound for SH7722 2nd cut */ | ||
632 | m66592_bset(m66592, 0x8000, M66592_DVSTCTR); | ||
633 | m66592_bset(m66592, 0x1000, M66592_TESTMODE); | ||
634 | m66592_bclr(m66592, 0x8000, M66592_DVSTCTR); | ||
635 | |||
636 | m66592_bset(m66592, M66592_INTL, M66592_INTENB1); | ||
637 | |||
638 | m66592_write(m66592, 0, M66592_CFBCFG); | ||
639 | m66592_write(m66592, 0, M66592_D0FBCFG); | ||
640 | m66592_bset(m66592, endian, M66592_CFBCFG); | ||
641 | m66592_bset(m66592, endian, M66592_D0FBCFG); | ||
642 | } | ||
643 | #else /* #if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ | ||
614 | static void init_controller(struct m66592 *m66592) | 644 | static void init_controller(struct m66592 *m66592) |
615 | { | 645 | { |
616 | m66592_bset(m66592, (vif & M66592_LDRV) | (endian & M66592_BIGEND), | 646 | m66592_bset(m66592, (vif & M66592_LDRV) | (endian & M66592_BIGEND), |
@@ -636,9 +666,13 @@ static void init_controller(struct m66592 *m66592) | |||
636 | m66592_write(m66592, M66592_BURST | M66592_CPU_ADR_RD_WR, | 666 | m66592_write(m66592, M66592_BURST | M66592_CPU_ADR_RD_WR, |
637 | M66592_DMA0CFG); | 667 | M66592_DMA0CFG); |
638 | } | 668 | } |
669 | #endif /* #if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ | ||
639 | 670 | ||
640 | static void disable_controller(struct m66592 *m66592) | 671 | static void disable_controller(struct m66592 *m66592) |
641 | { | 672 | { |
673 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | ||
674 | usbf_stop_clock(); | ||
675 | #else | ||
642 | m66592_bclr(m66592, M66592_SCKE, M66592_SYSCFG); | 676 | m66592_bclr(m66592, M66592_SCKE, M66592_SYSCFG); |
643 | udelay(1); | 677 | udelay(1); |
644 | m66592_bclr(m66592, M66592_PLLC, M66592_SYSCFG); | 678 | m66592_bclr(m66592, M66592_PLLC, M66592_SYSCFG); |
@@ -646,15 +680,20 @@ static void disable_controller(struct m66592 *m66592) | |||
646 | m66592_bclr(m66592, M66592_RCKE, M66592_SYSCFG); | 680 | m66592_bclr(m66592, M66592_RCKE, M66592_SYSCFG); |
647 | udelay(1); | 681 | udelay(1); |
648 | m66592_bclr(m66592, M66592_XCKE, M66592_SYSCFG); | 682 | m66592_bclr(m66592, M66592_XCKE, M66592_SYSCFG); |
683 | #endif | ||
649 | } | 684 | } |
650 | 685 | ||
651 | static void m66592_start_xclock(struct m66592 *m66592) | 686 | static void m66592_start_xclock(struct m66592 *m66592) |
652 | { | 687 | { |
688 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | ||
689 | usbf_start_clock(); | ||
690 | #else | ||
653 | u16 tmp; | 691 | u16 tmp; |
654 | 692 | ||
655 | tmp = m66592_read(m66592, M66592_SYSCFG); | 693 | tmp = m66592_read(m66592, M66592_SYSCFG); |
656 | if (!(tmp & M66592_XCKE)) | 694 | if (!(tmp & M66592_XCKE)) |
657 | m66592_bset(m66592, M66592_XCKE, M66592_SYSCFG); | 695 | m66592_bset(m66592, M66592_XCKE, M66592_SYSCFG); |
696 | #endif | ||
658 | } | 697 | } |
659 | 698 | ||
660 | /*-------------------------------------------------------------------------*/ | 699 | /*-------------------------------------------------------------------------*/ |
@@ -709,7 +748,7 @@ static void irq_ep0_write(struct m66592_ep *ep, struct m66592_request *req) | |||
709 | do { | 748 | do { |
710 | tmp = m66592_read(m66592, ep->fifoctr); | 749 | tmp = m66592_read(m66592, ep->fifoctr); |
711 | if (i++ > 100000) { | 750 | if (i++ > 100000) { |
712 | printk(KERN_ERR "pipe0 is busy. maybe cpu i/o bus" | 751 | pr_err("pipe0 is busy. maybe cpu i/o bus " |
713 | "conflict. please power off this controller."); | 752 | "conflict. please power off this controller."); |
714 | return; | 753 | return; |
715 | } | 754 | } |
@@ -759,7 +798,7 @@ static void irq_packet_write(struct m66592_ep *ep, struct m66592_request *req) | |||
759 | if (unlikely((tmp & M66592_FRDY) == 0)) { | 798 | if (unlikely((tmp & M66592_FRDY) == 0)) { |
760 | pipe_stop(m66592, pipenum); | 799 | pipe_stop(m66592, pipenum); |
761 | pipe_irq_disable(m66592, pipenum); | 800 | pipe_irq_disable(m66592, pipenum); |
762 | printk(KERN_ERR "write fifo not ready. pipnum=%d\n", pipenum); | 801 | pr_err("write fifo not ready. pipnum=%d\n", pipenum); |
763 | return; | 802 | return; |
764 | } | 803 | } |
765 | 804 | ||
@@ -808,7 +847,7 @@ static void irq_packet_read(struct m66592_ep *ep, struct m66592_request *req) | |||
808 | req->req.status = -EPIPE; | 847 | req->req.status = -EPIPE; |
809 | pipe_stop(m66592, pipenum); | 848 | pipe_stop(m66592, pipenum); |
810 | pipe_irq_disable(m66592, pipenum); | 849 | pipe_irq_disable(m66592, pipenum); |
811 | printk(KERN_ERR "read fifo not ready"); | 850 | pr_err("read fifo not ready"); |
812 | return; | 851 | return; |
813 | } | 852 | } |
814 | 853 | ||
@@ -1063,7 +1102,7 @@ static void m66592_update_usb_speed(struct m66592 *m66592) | |||
1063 | break; | 1102 | break; |
1064 | default: | 1103 | default: |
1065 | m66592->gadget.speed = USB_SPEED_UNKNOWN; | 1104 | m66592->gadget.speed = USB_SPEED_UNKNOWN; |
1066 | printk(KERN_ERR "USB speed unknown\n"); | 1105 | pr_err("USB speed unknown\n"); |
1067 | } | 1106 | } |
1068 | } | 1107 | } |
1069 | 1108 | ||
@@ -1122,7 +1161,7 @@ __acquires(m66592->lock) | |||
1122 | control_end(m66592, 0); | 1161 | control_end(m66592, 0); |
1123 | break; | 1162 | break; |
1124 | default: | 1163 | default: |
1125 | printk(KERN_ERR "ctrl_stage: unexpect ctsq(%x)\n", ctsq); | 1164 | pr_err("ctrl_stage: unexpect ctsq(%x)\n", ctsq); |
1126 | break; | 1165 | break; |
1127 | } | 1166 | } |
1128 | } | 1167 | } |
@@ -1142,6 +1181,19 @@ static irqreturn_t m66592_irq(int irq, void *_m66592) | |||
1142 | intsts0 = m66592_read(m66592, M66592_INTSTS0); | 1181 | intsts0 = m66592_read(m66592, M66592_INTSTS0); |
1143 | intenb0 = m66592_read(m66592, M66592_INTENB0); | 1182 | intenb0 = m66592_read(m66592, M66592_INTENB0); |
1144 | 1183 | ||
1184 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | ||
1185 | if (!intsts0 && !intenb0) { | ||
1186 | /* | ||
1187 | * When USB clock stops, it cannot read register. Even if a | ||
1188 | * clock stops, the interrupt occurs. So this driver turn on | ||
1189 | * a clock by this timing and do re-reading of register. | ||
1190 | */ | ||
1191 | m66592_start_xclock(m66592); | ||
1192 | intsts0 = m66592_read(m66592, M66592_INTSTS0); | ||
1193 | intenb0 = m66592_read(m66592, M66592_INTENB0); | ||
1194 | } | ||
1195 | #endif | ||
1196 | |||
1145 | savepipe = m66592_read(m66592, M66592_CFIFOSEL); | 1197 | savepipe = m66592_read(m66592, M66592_CFIFOSEL); |
1146 | 1198 | ||
1147 | mask0 = intsts0 & intenb0; | 1199 | mask0 = intsts0 & intenb0; |
@@ -1409,13 +1461,13 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
1409 | 1461 | ||
1410 | retval = device_add(&m66592->gadget.dev); | 1462 | retval = device_add(&m66592->gadget.dev); |
1411 | if (retval) { | 1463 | if (retval) { |
1412 | printk(KERN_ERR "device_add error (%d)\n", retval); | 1464 | pr_err("device_add error (%d)\n", retval); |
1413 | goto error; | 1465 | goto error; |
1414 | } | 1466 | } |
1415 | 1467 | ||
1416 | retval = driver->bind (&m66592->gadget); | 1468 | retval = driver->bind (&m66592->gadget); |
1417 | if (retval) { | 1469 | if (retval) { |
1418 | printk(KERN_ERR "bind to driver error (%d)\n", retval); | 1470 | pr_err("bind to driver error (%d)\n", retval); |
1419 | device_del(&m66592->gadget.dev); | 1471 | device_del(&m66592->gadget.dev); |
1420 | goto error; | 1472 | goto error; |
1421 | } | 1473 | } |
@@ -1456,6 +1508,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
1456 | m66592_bclr(m66592, M66592_VBSE | M66592_URST, M66592_INTENB0); | 1508 | m66592_bclr(m66592, M66592_VBSE | M66592_URST, M66592_INTENB0); |
1457 | 1509 | ||
1458 | driver->unbind(&m66592->gadget); | 1510 | driver->unbind(&m66592->gadget); |
1511 | m66592->gadget.dev.driver = NULL; | ||
1459 | 1512 | ||
1460 | init_controller(m66592); | 1513 | init_controller(m66592); |
1461 | disable_controller(m66592); | 1514 | disable_controller(m66592); |
@@ -1485,6 +1538,7 @@ static int __exit m66592_remove(struct platform_device *pdev) | |||
1485 | iounmap(m66592->reg); | 1538 | iounmap(m66592->reg); |
1486 | free_irq(platform_get_irq(pdev, 0), m66592); | 1539 | free_irq(platform_get_irq(pdev, 0), m66592); |
1487 | m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); | 1540 | m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); |
1541 | usbf_stop_clock(); | ||
1488 | kfree(m66592); | 1542 | kfree(m66592); |
1489 | return 0; | 1543 | return 0; |
1490 | } | 1544 | } |
@@ -1508,28 +1562,28 @@ static int __init m66592_probe(struct platform_device *pdev) | |||
1508 | (char *)udc_name); | 1562 | (char *)udc_name); |
1509 | if (!res) { | 1563 | if (!res) { |
1510 | ret = -ENODEV; | 1564 | ret = -ENODEV; |
1511 | printk(KERN_ERR "platform_get_resource_byname error.\n"); | 1565 | pr_err("platform_get_resource_byname error.\n"); |
1512 | goto clean_up; | 1566 | goto clean_up; |
1513 | } | 1567 | } |
1514 | 1568 | ||
1515 | irq = platform_get_irq(pdev, 0); | 1569 | irq = platform_get_irq(pdev, 0); |
1516 | if (irq < 0) { | 1570 | if (irq < 0) { |
1517 | ret = -ENODEV; | 1571 | ret = -ENODEV; |
1518 | printk(KERN_ERR "platform_get_irq error.\n"); | 1572 | pr_err("platform_get_irq error.\n"); |
1519 | goto clean_up; | 1573 | goto clean_up; |
1520 | } | 1574 | } |
1521 | 1575 | ||
1522 | reg = ioremap(res->start, resource_len(res)); | 1576 | reg = ioremap(res->start, resource_len(res)); |
1523 | if (reg == NULL) { | 1577 | if (reg == NULL) { |
1524 | ret = -ENOMEM; | 1578 | ret = -ENOMEM; |
1525 | printk(KERN_ERR "ioremap error.\n"); | 1579 | pr_err("ioremap error.\n"); |
1526 | goto clean_up; | 1580 | goto clean_up; |
1527 | } | 1581 | } |
1528 | 1582 | ||
1529 | /* initialize ucd */ | 1583 | /* initialize ucd */ |
1530 | m66592 = kzalloc(sizeof(struct m66592), GFP_KERNEL); | 1584 | m66592 = kzalloc(sizeof(struct m66592), GFP_KERNEL); |
1531 | if (m66592 == NULL) { | 1585 | if (m66592 == NULL) { |
1532 | printk(KERN_ERR "kzalloc error\n"); | 1586 | pr_err("kzalloc error\n"); |
1533 | goto clean_up; | 1587 | goto clean_up; |
1534 | } | 1588 | } |
1535 | 1589 | ||
@@ -1555,7 +1609,7 @@ static int __init m66592_probe(struct platform_device *pdev) | |||
1555 | ret = request_irq(irq, m66592_irq, IRQF_DISABLED | IRQF_SHARED, | 1609 | ret = request_irq(irq, m66592_irq, IRQF_DISABLED | IRQF_SHARED, |
1556 | udc_name, m66592); | 1610 | udc_name, m66592); |
1557 | if (ret < 0) { | 1611 | if (ret < 0) { |
1558 | printk(KERN_ERR "request_irq error (%d)\n", ret); | 1612 | pr_err("request_irq error (%d)\n", ret); |
1559 | goto clean_up; | 1613 | goto clean_up; |
1560 | } | 1614 | } |
1561 | 1615 | ||
diff --git a/drivers/usb/gadget/m66592-udc.h b/drivers/usb/gadget/m66592-udc.h index bfa0c645f229..17b792b7f6bf 100644 --- a/drivers/usb/gadget/m66592-udc.h +++ b/drivers/usb/gadget/m66592-udc.h | |||
@@ -72,6 +72,11 @@ | |||
72 | #define M66592_P_TST_J 0x0001 /* PERI TEST J */ | 72 | #define M66592_P_TST_J 0x0001 /* PERI TEST J */ |
73 | #define M66592_P_TST_NORMAL 0x0000 /* PERI Normal Mode */ | 73 | #define M66592_P_TST_NORMAL 0x0000 /* PERI Normal Mode */ |
74 | 74 | ||
75 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | ||
76 | #define M66592_CFBCFG 0x0A | ||
77 | #define M66592_D0FBCFG 0x0C | ||
78 | #define M66592_LITTLE 0x0100 /* b8: Little endian mode */ | ||
79 | #else | ||
75 | #define M66592_PINCFG 0x0A | 80 | #define M66592_PINCFG 0x0A |
76 | #define M66592_LDRV 0x8000 /* b15: Drive Current Adjust */ | 81 | #define M66592_LDRV 0x8000 /* b15: Drive Current Adjust */ |
77 | #define M66592_BIGEND 0x0100 /* b8: Big endian mode */ | 82 | #define M66592_BIGEND 0x0100 /* b8: Big endian mode */ |
@@ -91,6 +96,7 @@ | |||
91 | #define M66592_PKTM 0x0020 /* b5: Packet mode */ | 96 | #define M66592_PKTM 0x0020 /* b5: Packet mode */ |
92 | #define M66592_DENDE 0x0010 /* b4: Dend enable */ | 97 | #define M66592_DENDE 0x0010 /* b4: Dend enable */ |
93 | #define M66592_OBUS 0x0004 /* b2: OUTbus mode */ | 98 | #define M66592_OBUS 0x0004 /* b2: OUTbus mode */ |
99 | #endif /* #if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ | ||
94 | 100 | ||
95 | #define M66592_CFIFO 0x10 | 101 | #define M66592_CFIFO 0x10 |
96 | #define M66592_D0FIFO 0x14 | 102 | #define M66592_D0FIFO 0x14 |
@@ -103,9 +109,13 @@ | |||
103 | #define M66592_REW 0x4000 /* b14: Buffer rewind */ | 109 | #define M66592_REW 0x4000 /* b14: Buffer rewind */ |
104 | #define M66592_DCLRM 0x2000 /* b13: DMA buffer clear mode */ | 110 | #define M66592_DCLRM 0x2000 /* b13: DMA buffer clear mode */ |
105 | #define M66592_DREQE 0x1000 /* b12: DREQ output enable */ | 111 | #define M66592_DREQE 0x1000 /* b12: DREQ output enable */ |
112 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | ||
113 | #define M66592_MBW 0x0800 /* b11: Maximum bit width for FIFO */ | ||
114 | #else | ||
106 | #define M66592_MBW 0x0400 /* b10: Maximum bit width for FIFO */ | 115 | #define M66592_MBW 0x0400 /* b10: Maximum bit width for FIFO */ |
107 | #define M66592_MBW_8 0x0000 /* 8bit */ | 116 | #define M66592_MBW_8 0x0000 /* 8bit */ |
108 | #define M66592_MBW_16 0x0400 /* 16bit */ | 117 | #define M66592_MBW_16 0x0400 /* 16bit */ |
118 | #endif /* #if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ | ||
109 | #define M66592_TRENB 0x0200 /* b9: Transaction counter enable */ | 119 | #define M66592_TRENB 0x0200 /* b9: Transaction counter enable */ |
110 | #define M66592_TRCLR 0x0100 /* b8: Transaction counter clear */ | 120 | #define M66592_TRCLR 0x0100 /* b8: Transaction counter clear */ |
111 | #define M66592_DEZPM 0x0080 /* b7: Zero-length packet mode */ | 121 | #define M66592_DEZPM 0x0080 /* b7: Zero-length packet mode */ |
@@ -530,8 +540,13 @@ static inline void m66592_read_fifo(struct m66592 *m66592, | |||
530 | { | 540 | { |
531 | unsigned long fifoaddr = (unsigned long)m66592->reg + offset; | 541 | unsigned long fifoaddr = (unsigned long)m66592->reg + offset; |
532 | 542 | ||
543 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | ||
544 | len = (len + 3) / 4; | ||
545 | insl(fifoaddr, buf, len); | ||
546 | #else | ||
533 | len = (len + 1) / 2; | 547 | len = (len + 1) / 2; |
534 | insw(fifoaddr, buf, len); | 548 | insw(fifoaddr, buf, len); |
549 | #endif | ||
535 | } | 550 | } |
536 | 551 | ||
537 | static inline void m66592_write(struct m66592 *m66592, u16 val, | 552 | static inline void m66592_write(struct m66592 *m66592, u16 val, |
@@ -545,6 +560,24 @@ static inline void m66592_write_fifo(struct m66592 *m66592, | |||
545 | void *buf, unsigned long len) | 560 | void *buf, unsigned long len) |
546 | { | 561 | { |
547 | unsigned long fifoaddr = (unsigned long)m66592->reg + offset; | 562 | unsigned long fifoaddr = (unsigned long)m66592->reg + offset; |
563 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | ||
564 | unsigned long count; | ||
565 | unsigned char *pb; | ||
566 | int i; | ||
567 | |||
568 | count = len / 4; | ||
569 | outsl(fifoaddr, buf, count); | ||
570 | |||
571 | if (len & 0x00000003) { | ||
572 | pb = buf + count * 4; | ||
573 | for (i = 0; i < (len & 0x00000003); i++) { | ||
574 | if (m66592_read(m66592, M66592_CFBCFG)) /* little */ | ||
575 | outb(pb[i], fifoaddr + (3 - i)); | ||
576 | else | ||
577 | outb(pb[i], fifoaddr + i); | ||
578 | } | ||
579 | } | ||
580 | #else | ||
548 | unsigned long odd = len & 0x0001; | 581 | unsigned long odd = len & 0x0001; |
549 | 582 | ||
550 | len = len / 2; | 583 | len = len / 2; |
@@ -553,6 +586,7 @@ static inline void m66592_write_fifo(struct m66592 *m66592, | |||
553 | unsigned char *p = buf + len*2; | 586 | unsigned char *p = buf + len*2; |
554 | outb(*p, fifoaddr); | 587 | outb(*p, fifoaddr); |
555 | } | 588 | } |
589 | #endif /* #if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ | ||
556 | } | 590 | } |
557 | 591 | ||
558 | static inline void m66592_mdfy(struct m66592 *m66592, u16 val, u16 pat, | 592 | static inline void m66592_mdfy(struct m66592 *m66592, u16 val, u16 pat, |
@@ -570,6 +604,26 @@ static inline void m66592_mdfy(struct m66592 *m66592, u16 val, u16 pat, | |||
570 | #define m66592_bset(m66592, val, offset) \ | 604 | #define m66592_bset(m66592, val, offset) \ |
571 | m66592_mdfy(m66592, val, 0, offset) | 605 | m66592_mdfy(m66592, val, 0, offset) |
572 | 606 | ||
607 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | ||
608 | #include <asm/io.h> | ||
609 | #define MSTPCR2 0xA4150038 /* for SH7722 */ | ||
610 | #define MSTPCR2_USB 0x00000800 | ||
611 | |||
612 | static inline void usbf_start_clock(void) | ||
613 | { | ||
614 | ctrl_outl(ctrl_inl(MSTPCR2) & ~MSTPCR2_USB, MSTPCR2); | ||
615 | } | ||
616 | |||
617 | static inline void usbf_stop_clock(void) | ||
618 | { | ||
619 | ctrl_outl(ctrl_inl(MSTPCR2) | MSTPCR2_USB, MSTPCR2); | ||
620 | } | ||
621 | |||
622 | #else | ||
623 | #define usbf_start_clock(x) | ||
624 | #define usbf_stop_clock(x) | ||
625 | #endif /* if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ | ||
626 | |||
573 | #endif /* ifndef __M66592_UDC_H__ */ | 627 | #endif /* ifndef __M66592_UDC_H__ */ |
574 | 628 | ||
575 | 629 | ||
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index d5d473f8144b..33469cf5aec3 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c | |||
@@ -2435,7 +2435,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) | |||
2435 | break; | 2435 | break; |
2436 | default: | 2436 | default: |
2437 | delegate: | 2437 | delegate: |
2438 | VDEBUG (dev, "setup %02x.%02x v%04x i%04x l%04x" | 2438 | VDEBUG (dev, "setup %02x.%02x v%04x i%04x l%04x " |
2439 | "ep_cfg %08x\n", | 2439 | "ep_cfg %08x\n", |
2440 | u.r.bRequestType, u.r.bRequest, | 2440 | u.r.bRequestType, u.r.bRequest, |
2441 | w_value, w_index, w_length, | 2441 | w_value, w_index, w_length, |
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index d377154658b5..e6d68bda428a 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -4,6 +4,8 @@ | |||
4 | * Copyright (C) 2004 Texas Instruments, Inc. | 4 | * Copyright (C) 2004 Texas Instruments, Inc. |
5 | * Copyright (C) 2004-2005 David Brownell | 5 | * Copyright (C) 2004-2005 David Brownell |
6 | * | 6 | * |
7 | * OMAP2 & DMA support by Kyungmin Park <kyungmin.park@samsung.com> | ||
8 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or | 11 | * the Free Software Foundation; either version 2 of the License, or |
@@ -60,11 +62,6 @@ | |||
60 | /* bulk DMA seems to be behaving for both IN and OUT */ | 62 | /* bulk DMA seems to be behaving for both IN and OUT */ |
61 | #define USE_DMA | 63 | #define USE_DMA |
62 | 64 | ||
63 | /* FIXME: OMAP2 currently has some problem in DMA mode */ | ||
64 | #ifdef CONFIG_ARCH_OMAP2 | ||
65 | #undef USE_DMA | ||
66 | #endif | ||
67 | |||
68 | /* ISO too */ | 65 | /* ISO too */ |
69 | #define USE_ISO | 66 | #define USE_ISO |
70 | 67 | ||
@@ -73,6 +70,8 @@ | |||
73 | 70 | ||
74 | #define DMA_ADDR_INVALID (~(dma_addr_t)0) | 71 | #define DMA_ADDR_INVALID (~(dma_addr_t)0) |
75 | 72 | ||
73 | #define OMAP2_DMA_CH(ch) (((ch) - 1) << 1) | ||
74 | #define OMAP24XX_DMA(name, ch) (OMAP24XX_DMA_##name + OMAP2_DMA_CH(ch)) | ||
76 | 75 | ||
77 | /* | 76 | /* |
78 | * The OMAP UDC needs _very_ early endpoint setup: before enabling the | 77 | * The OMAP UDC needs _very_ early endpoint setup: before enabling the |
@@ -571,20 +570,25 @@ static void next_in_dma(struct omap_ep *ep, struct omap_req *req) | |||
571 | const int sync_mode = cpu_is_omap15xx() | 570 | const int sync_mode = cpu_is_omap15xx() |
572 | ? OMAP_DMA_SYNC_FRAME | 571 | ? OMAP_DMA_SYNC_FRAME |
573 | : OMAP_DMA_SYNC_ELEMENT; | 572 | : OMAP_DMA_SYNC_ELEMENT; |
573 | int dma_trigger = 0; | ||
574 | |||
575 | if (cpu_is_omap24xx()) | ||
576 | dma_trigger = OMAP24XX_DMA(USB_W2FC_TX0, ep->dma_channel); | ||
574 | 577 | ||
575 | /* measure length in either bytes or packets */ | 578 | /* measure length in either bytes or packets */ |
576 | if ((cpu_is_omap16xx() && length <= UDC_TXN_TSC) | 579 | if ((cpu_is_omap16xx() && length <= UDC_TXN_TSC) |
580 | || (cpu_is_omap24xx() && length < ep->maxpacket) | ||
577 | || (cpu_is_omap15xx() && length < ep->maxpacket)) { | 581 | || (cpu_is_omap15xx() && length < ep->maxpacket)) { |
578 | txdma_ctrl = UDC_TXN_EOT | length; | 582 | txdma_ctrl = UDC_TXN_EOT | length; |
579 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S8, | 583 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S8, |
580 | length, 1, sync_mode, 0, 0); | 584 | length, 1, sync_mode, dma_trigger, 0); |
581 | } else { | 585 | } else { |
582 | length = min(length / ep->maxpacket, | 586 | length = min(length / ep->maxpacket, |
583 | (unsigned) UDC_TXN_TSC + 1); | 587 | (unsigned) UDC_TXN_TSC + 1); |
584 | txdma_ctrl = length; | 588 | txdma_ctrl = length; |
585 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16, | 589 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16, |
586 | ep->ep.maxpacket >> 1, length, sync_mode, | 590 | ep->ep.maxpacket >> 1, length, sync_mode, |
587 | 0, 0); | 591 | dma_trigger, 0); |
588 | length *= ep->maxpacket; | 592 | length *= ep->maxpacket; |
589 | } | 593 | } |
590 | omap_set_dma_src_params(ep->lch, OMAP_DMA_PORT_EMIFF, | 594 | omap_set_dma_src_params(ep->lch, OMAP_DMA_PORT_EMIFF, |
@@ -622,20 +626,31 @@ static void finish_in_dma(struct omap_ep *ep, struct omap_req *req, int status) | |||
622 | 626 | ||
623 | static void next_out_dma(struct omap_ep *ep, struct omap_req *req) | 627 | static void next_out_dma(struct omap_ep *ep, struct omap_req *req) |
624 | { | 628 | { |
625 | unsigned packets; | 629 | unsigned packets = req->req.length - req->req.actual; |
630 | int dma_trigger = 0; | ||
631 | |||
632 | if (cpu_is_omap24xx()) | ||
633 | dma_trigger = OMAP24XX_DMA(USB_W2FC_RX0, ep->dma_channel); | ||
626 | 634 | ||
627 | /* NOTE: we filtered out "short reads" before, so we know | 635 | /* NOTE: we filtered out "short reads" before, so we know |
628 | * the buffer has only whole numbers of packets. | 636 | * the buffer has only whole numbers of packets. |
637 | * except MODE SELECT(6) sent the 24 bytes data in OMAP24XX DMA mode | ||
629 | */ | 638 | */ |
630 | 639 | if (cpu_is_omap24xx() && packets < ep->maxpacket) { | |
631 | /* set up this DMA transfer, enable the fifo, start */ | 640 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S8, |
632 | packets = (req->req.length - req->req.actual) / ep->ep.maxpacket; | 641 | packets, 1, OMAP_DMA_SYNC_ELEMENT, |
633 | packets = min(packets, (unsigned)UDC_RXN_TC + 1); | 642 | dma_trigger, 0); |
634 | req->dma_bytes = packets * ep->ep.maxpacket; | 643 | req->dma_bytes = packets; |
635 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16, | 644 | } else { |
636 | ep->ep.maxpacket >> 1, packets, | 645 | /* set up this DMA transfer, enable the fifo, start */ |
637 | OMAP_DMA_SYNC_ELEMENT, | 646 | packets /= ep->ep.maxpacket; |
638 | 0, 0); | 647 | packets = min(packets, (unsigned)UDC_RXN_TC + 1); |
648 | req->dma_bytes = packets * ep->ep.maxpacket; | ||
649 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16, | ||
650 | ep->ep.maxpacket >> 1, packets, | ||
651 | OMAP_DMA_SYNC_ELEMENT, | ||
652 | dma_trigger, 0); | ||
653 | } | ||
639 | omap_set_dma_dest_params(ep->lch, OMAP_DMA_PORT_EMIFF, | 654 | omap_set_dma_dest_params(ep->lch, OMAP_DMA_PORT_EMIFF, |
640 | OMAP_DMA_AMODE_POST_INC, req->req.dma + req->req.actual, | 655 | OMAP_DMA_AMODE_POST_INC, req->req.dma + req->req.actual, |
641 | 0, 0); | 656 | 0, 0); |
@@ -743,6 +758,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel) | |||
743 | { | 758 | { |
744 | u16 reg; | 759 | u16 reg; |
745 | int status, restart, is_in; | 760 | int status, restart, is_in; |
761 | int dma_channel; | ||
746 | 762 | ||
747 | is_in = ep->bEndpointAddress & USB_DIR_IN; | 763 | is_in = ep->bEndpointAddress & USB_DIR_IN; |
748 | if (is_in) | 764 | if (is_in) |
@@ -769,11 +785,15 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel) | |||
769 | ep->dma_channel = channel; | 785 | ep->dma_channel = channel; |
770 | 786 | ||
771 | if (is_in) { | 787 | if (is_in) { |
772 | status = omap_request_dma(OMAP_DMA_USB_W2FC_TX0 - 1 + channel, | 788 | if (cpu_is_omap24xx()) |
789 | dma_channel = OMAP24XX_DMA(USB_W2FC_TX0, channel); | ||
790 | else | ||
791 | dma_channel = OMAP_DMA_USB_W2FC_TX0 - 1 + channel; | ||
792 | status = omap_request_dma(dma_channel, | ||
773 | ep->ep.name, dma_error, ep, &ep->lch); | 793 | ep->ep.name, dma_error, ep, &ep->lch); |
774 | if (status == 0) { | 794 | if (status == 0) { |
775 | UDC_TXDMA_CFG_REG = reg; | 795 | UDC_TXDMA_CFG_REG = reg; |
776 | /* EMIFF */ | 796 | /* EMIFF or SDRC */ |
777 | omap_set_dma_src_burst_mode(ep->lch, | 797 | omap_set_dma_src_burst_mode(ep->lch, |
778 | OMAP_DMA_DATA_BURST_4); | 798 | OMAP_DMA_DATA_BURST_4); |
779 | omap_set_dma_src_data_pack(ep->lch, 1); | 799 | omap_set_dma_src_data_pack(ep->lch, 1); |
@@ -785,7 +805,12 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel) | |||
785 | 0, 0); | 805 | 0, 0); |
786 | } | 806 | } |
787 | } else { | 807 | } else { |
788 | status = omap_request_dma(OMAP_DMA_USB_W2FC_RX0 - 1 + channel, | 808 | if (cpu_is_omap24xx()) |
809 | dma_channel = OMAP24XX_DMA(USB_W2FC_RX0, channel); | ||
810 | else | ||
811 | dma_channel = OMAP_DMA_USB_W2FC_RX0 - 1 + channel; | ||
812 | |||
813 | status = omap_request_dma(dma_channel, | ||
789 | ep->ep.name, dma_error, ep, &ep->lch); | 814 | ep->ep.name, dma_error, ep, &ep->lch); |
790 | if (status == 0) { | 815 | if (status == 0) { |
791 | UDC_RXDMA_CFG_REG = reg; | 816 | UDC_RXDMA_CFG_REG = reg; |
@@ -795,7 +820,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel) | |||
795 | OMAP_DMA_AMODE_CONSTANT, | 820 | OMAP_DMA_AMODE_CONSTANT, |
796 | (unsigned long) io_v2p((u32)&UDC_DATA_DMA_REG), | 821 | (unsigned long) io_v2p((u32)&UDC_DATA_DMA_REG), |
797 | 0, 0); | 822 | 0, 0); |
798 | /* EMIFF */ | 823 | /* EMIFF or SDRC */ |
799 | omap_set_dma_dest_burst_mode(ep->lch, | 824 | omap_set_dma_dest_burst_mode(ep->lch, |
800 | OMAP_DMA_DATA_BURST_4); | 825 | OMAP_DMA_DATA_BURST_4); |
801 | omap_set_dma_dest_data_pack(ep->lch, 1); | 826 | omap_set_dma_dest_data_pack(ep->lch, 1); |
@@ -808,7 +833,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel) | |||
808 | omap_disable_dma_irq(ep->lch, OMAP_DMA_BLOCK_IRQ); | 833 | omap_disable_dma_irq(ep->lch, OMAP_DMA_BLOCK_IRQ); |
809 | 834 | ||
810 | /* channel type P: hw synch (fifo) */ | 835 | /* channel type P: hw synch (fifo) */ |
811 | if (!cpu_is_omap15xx()) | 836 | if (cpu_class_is_omap1() && !cpu_is_omap15xx()) |
812 | OMAP1_DMA_LCH_CTRL_REG(ep->lch) = 2; | 837 | OMAP1_DMA_LCH_CTRL_REG(ep->lch) = 2; |
813 | } | 838 | } |
814 | 839 | ||
@@ -926,11 +951,13 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
926 | 951 | ||
927 | /* this isn't bogus, but OMAP DMA isn't the only hardware to | 952 | /* this isn't bogus, but OMAP DMA isn't the only hardware to |
928 | * have a hard time with partial packet reads... reject it. | 953 | * have a hard time with partial packet reads... reject it. |
954 | * Except OMAP2 can handle the small packets. | ||
929 | */ | 955 | */ |
930 | if (use_dma | 956 | if (use_dma |
931 | && ep->has_dma | 957 | && ep->has_dma |
932 | && ep->bEndpointAddress != 0 | 958 | && ep->bEndpointAddress != 0 |
933 | && (ep->bEndpointAddress & USB_DIR_IN) == 0 | 959 | && (ep->bEndpointAddress & USB_DIR_IN) == 0 |
960 | && !cpu_class_is_omap2() | ||
934 | && (req->req.length % ep->ep.maxpacket) != 0) { | 961 | && (req->req.length % ep->ep.maxpacket) != 0) { |
935 | DBG("%s, no partial packet OUT reads\n", __FUNCTION__); | 962 | DBG("%s, no partial packet OUT reads\n", __FUNCTION__); |
936 | return -EMSGSIZE; | 963 | return -EMSGSIZE; |
@@ -1001,7 +1028,7 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
1001 | 1028 | ||
1002 | /* STATUS for zero length DATA stages is | 1029 | /* STATUS for zero length DATA stages is |
1003 | * always an IN ... even for IN transfers, | 1030 | * always an IN ... even for IN transfers, |
1004 | * a wierd case which seem to stall OMAP. | 1031 | * a weird case which seem to stall OMAP. |
1005 | */ | 1032 | */ |
1006 | UDC_EP_NUM_REG = (UDC_EP_SEL|UDC_EP_DIR); | 1033 | UDC_EP_NUM_REG = (UDC_EP_SEL|UDC_EP_DIR); |
1007 | UDC_CTRL_REG = UDC_CLR_EP; | 1034 | UDC_CTRL_REG = UDC_CLR_EP; |
diff --git a/drivers/usb/gadget/omap_udc.h b/drivers/usb/gadget/omap_udc.h index 1dc398bb9ab2..c6b9cbc7230a 100644 --- a/drivers/usb/gadget/omap_udc.h +++ b/drivers/usb/gadget/omap_udc.h | |||
@@ -182,21 +182,16 @@ struct omap_udc { | |||
182 | 182 | ||
183 | /*-------------------------------------------------------------------------*/ | 183 | /*-------------------------------------------------------------------------*/ |
184 | 184 | ||
185 | #ifdef DEBUG | ||
186 | #define DBG(stuff...) printk(KERN_DEBUG "udc: " stuff) | ||
187 | #else | ||
188 | #define DBG(stuff...) do{}while(0) | ||
189 | #endif | ||
190 | |||
191 | #ifdef VERBOSE | 185 | #ifdef VERBOSE |
192 | # define VDBG DBG | 186 | # define VDBG DBG |
193 | #else | 187 | #else |
194 | # define VDBG(stuff...) do{}while(0) | 188 | # define VDBG(stuff...) do{}while(0) |
195 | #endif | 189 | #endif |
196 | 190 | ||
197 | #define ERR(stuff...) printk(KERN_ERR "udc: " stuff) | 191 | #define ERR(stuff...) pr_err("udc: " stuff) |
198 | #define WARN(stuff...) printk(KERN_WARNING "udc: " stuff) | 192 | #define WARN(stuff...) pr_warning("udc: " stuff) |
199 | #define INFO(stuff...) printk(KERN_INFO "udc: " stuff) | 193 | #define INFO(stuff...) pr_info("udc: " stuff) |
194 | #define DBG(stuff...) pr_debug("udc: " stuff) | ||
200 | 195 | ||
201 | /*-------------------------------------------------------------------------*/ | 196 | /*-------------------------------------------------------------------------*/ |
202 | 197 | ||
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c new file mode 100644 index 000000000000..9fdabc8fcac4 --- /dev/null +++ b/drivers/usb/gadget/printer.c | |||
@@ -0,0 +1,1592 @@ | |||
1 | /* | ||
2 | * printer.c -- Printer gadget driver | ||
3 | * | ||
4 | * Copyright (C) 2003-2005 David Brownell | ||
5 | * Copyright (C) 2006 Craig W. Nadler | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/delay.h> | ||
25 | #include <linux/ioport.h> | ||
26 | #include <linux/sched.h> | ||
27 | #include <linux/slab.h> | ||
28 | #include <linux/smp_lock.h> | ||
29 | #include <linux/errno.h> | ||
30 | #include <linux/init.h> | ||
31 | #include <linux/timer.h> | ||
32 | #include <linux/list.h> | ||
33 | #include <linux/interrupt.h> | ||
34 | #include <linux/utsname.h> | ||
35 | #include <linux/device.h> | ||
36 | #include <linux/moduleparam.h> | ||
37 | #include <linux/fs.h> | ||
38 | #include <linux/poll.h> | ||
39 | #include <linux/types.h> | ||
40 | #include <linux/ctype.h> | ||
41 | #include <linux/cdev.h> | ||
42 | |||
43 | #include <asm/byteorder.h> | ||
44 | #include <linux/io.h> | ||
45 | #include <linux/irq.h> | ||
46 | #include <asm/system.h> | ||
47 | #include <linux/uaccess.h> | ||
48 | #include <asm/unaligned.h> | ||
49 | |||
50 | #include <linux/usb/ch9.h> | ||
51 | #include <linux/usb/gadget.h> | ||
52 | #include <linux/usb/g_printer.h> | ||
53 | |||
54 | #include "gadget_chips.h" | ||
55 | |||
56 | #define DRIVER_DESC "Printer Gadget" | ||
57 | #define DRIVER_VERSION "2007 OCT 06" | ||
58 | |||
59 | static const char shortname [] = "printer"; | ||
60 | static const char driver_desc [] = DRIVER_DESC; | ||
61 | |||
62 | static dev_t g_printer_devno; | ||
63 | |||
64 | static struct class *usb_gadget_class; | ||
65 | |||
66 | /*-------------------------------------------------------------------------*/ | ||
67 | |||
68 | struct printer_dev { | ||
69 | spinlock_t lock; /* lock this structure */ | ||
70 | /* lock buffer lists during read/write calls */ | ||
71 | spinlock_t lock_printer_io; | ||
72 | struct usb_gadget *gadget; | ||
73 | struct usb_request *req; /* for control responses */ | ||
74 | u8 config; | ||
75 | s8 interface; | ||
76 | struct usb_ep *in_ep, *out_ep; | ||
77 | const struct usb_endpoint_descriptor | ||
78 | *in, *out; | ||
79 | struct list_head rx_reqs; /* List of free RX structs */ | ||
80 | struct list_head rx_reqs_active; /* List of Active RX xfers */ | ||
81 | struct list_head rx_buffers; /* List of completed xfers */ | ||
82 | /* wait until there is data to be read. */ | ||
83 | wait_queue_head_t rx_wait; | ||
84 | struct list_head tx_reqs; /* List of free TX structs */ | ||
85 | struct list_head tx_reqs_active; /* List of Active TX xfers */ | ||
86 | /* Wait until there are write buffers available to use. */ | ||
87 | wait_queue_head_t tx_wait; | ||
88 | /* Wait until all write buffers have been sent. */ | ||
89 | wait_queue_head_t tx_flush_wait; | ||
90 | struct usb_request *current_rx_req; | ||
91 | size_t current_rx_bytes; | ||
92 | u8 *current_rx_buf; | ||
93 | u8 printer_status; | ||
94 | u8 reset_printer; | ||
95 | struct class_device *printer_class_dev; | ||
96 | struct cdev printer_cdev; | ||
97 | struct device *pdev; | ||
98 | u8 printer_cdev_open; | ||
99 | wait_queue_head_t wait; | ||
100 | }; | ||
101 | |||
102 | static struct printer_dev usb_printer_gadget; | ||
103 | |||
104 | /*-------------------------------------------------------------------------*/ | ||
105 | |||
106 | /* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! | ||
107 | * Instead: allocate your own, using normal USB-IF procedures. | ||
108 | */ | ||
109 | |||
110 | /* Thanks to NetChip Technologies for donating this product ID. | ||
111 | */ | ||
112 | #define PRINTER_VENDOR_NUM 0x0525 /* NetChip */ | ||
113 | #define PRINTER_PRODUCT_NUM 0xa4a8 /* Linux-USB Printer Gadget */ | ||
114 | |||
115 | /* Some systems will want different product identifers published in the | ||
116 | * device descriptor, either numbers or strings or both. These string | ||
117 | * parameters are in UTF-8 (superset of ASCII's 7 bit characters). | ||
118 | */ | ||
119 | |||
120 | static ushort __initdata idVendor; | ||
121 | module_param(idVendor, ushort, S_IRUGO); | ||
122 | MODULE_PARM_DESC(idVendor, "USB Vendor ID"); | ||
123 | |||
124 | static ushort __initdata idProduct; | ||
125 | module_param(idProduct, ushort, S_IRUGO); | ||
126 | MODULE_PARM_DESC(idProduct, "USB Product ID"); | ||
127 | |||
128 | static ushort __initdata bcdDevice; | ||
129 | module_param(bcdDevice, ushort, S_IRUGO); | ||
130 | MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)"); | ||
131 | |||
132 | static char *__initdata iManufacturer; | ||
133 | module_param(iManufacturer, charp, S_IRUGO); | ||
134 | MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); | ||
135 | |||
136 | static char *__initdata iProduct; | ||
137 | module_param(iProduct, charp, S_IRUGO); | ||
138 | MODULE_PARM_DESC(iProduct, "USB Product string"); | ||
139 | |||
140 | static char *__initdata iSerialNum; | ||
141 | module_param(iSerialNum, charp, S_IRUGO); | ||
142 | MODULE_PARM_DESC(iSerialNum, "1"); | ||
143 | |||
144 | static char *__initdata iPNPstring; | ||
145 | module_param(iPNPstring, charp, S_IRUGO); | ||
146 | MODULE_PARM_DESC(iPNPstring, "MFG:linux;MDL:g_printer;CLS:PRINTER;SN:1;"); | ||
147 | |||
148 | /* Number of requests to allocate per endpoint, not used for ep0. */ | ||
149 | static unsigned qlen = 10; | ||
150 | module_param(qlen, uint, S_IRUGO|S_IWUSR); | ||
151 | |||
152 | #define QLEN qlen | ||
153 | |||
154 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
155 | #define DEVSPEED USB_SPEED_HIGH | ||
156 | #else /* full speed (low speed doesn't do bulk) */ | ||
157 | #define DEVSPEED USB_SPEED_FULL | ||
158 | #endif | ||
159 | |||
160 | /*-------------------------------------------------------------------------*/ | ||
161 | |||
162 | #define xprintk(d, level, fmt, args...) \ | ||
163 | printk(level "%s: " fmt, DRIVER_DESC, ## args) | ||
164 | |||
165 | #ifdef DEBUG | ||
166 | #define DBG(dev, fmt, args...) \ | ||
167 | xprintk(dev, KERN_DEBUG, fmt, ## args) | ||
168 | #else | ||
169 | #define DBG(dev, fmt, args...) \ | ||
170 | do { } while (0) | ||
171 | #endif /* DEBUG */ | ||
172 | |||
173 | #ifdef VERBOSE | ||
174 | #define VDBG(dev, fmt, args...) \ | ||
175 | xprintk(dev, KERN_DEBUG, fmt, ## args) | ||
176 | #else | ||
177 | #define VDBG(dev, fmt, args...) \ | ||
178 | do { } while (0) | ||
179 | #endif /* VERBOSE */ | ||
180 | |||
181 | #define ERROR(dev, fmt, args...) \ | ||
182 | xprintk(dev, KERN_ERR, fmt, ## args) | ||
183 | #define WARN(dev, fmt, args...) \ | ||
184 | xprintk(dev, KERN_WARNING, fmt, ## args) | ||
185 | #define INFO(dev, fmt, args...) \ | ||
186 | xprintk(dev, KERN_INFO, fmt, ## args) | ||
187 | |||
188 | /*-------------------------------------------------------------------------*/ | ||
189 | |||
190 | /* USB DRIVER HOOKUP (to the hardware driver, below us), mostly | ||
191 | * ep0 implementation: descriptors, config management, setup(). | ||
192 | * also optional class-specific notification interrupt transfer. | ||
193 | */ | ||
194 | |||
195 | /* | ||
196 | * DESCRIPTORS ... most are static, but strings and (full) configuration | ||
197 | * descriptors are built on demand. | ||
198 | */ | ||
199 | |||
200 | #define STRING_MANUFACTURER 1 | ||
201 | #define STRING_PRODUCT 2 | ||
202 | #define STRING_SERIALNUM 3 | ||
203 | |||
204 | /* holds our biggest descriptor */ | ||
205 | #define USB_DESC_BUFSIZE 256 | ||
206 | #define USB_BUFSIZE 8192 | ||
207 | |||
208 | /* This device advertises one configuration. */ | ||
209 | #define DEV_CONFIG_VALUE 1 | ||
210 | #define PRINTER_INTERFACE 0 | ||
211 | |||
212 | static struct usb_device_descriptor device_desc = { | ||
213 | .bLength = sizeof device_desc, | ||
214 | .bDescriptorType = USB_DT_DEVICE, | ||
215 | .bcdUSB = __constant_cpu_to_le16(0x0200), | ||
216 | .bDeviceClass = USB_CLASS_PER_INTERFACE, | ||
217 | .bDeviceSubClass = 0, | ||
218 | .bDeviceProtocol = 0, | ||
219 | .idVendor = __constant_cpu_to_le16(PRINTER_VENDOR_NUM), | ||
220 | .idProduct = __constant_cpu_to_le16(PRINTER_PRODUCT_NUM), | ||
221 | .iManufacturer = STRING_MANUFACTURER, | ||
222 | .iProduct = STRING_PRODUCT, | ||
223 | .iSerialNumber = STRING_SERIALNUM, | ||
224 | .bNumConfigurations = 1 | ||
225 | }; | ||
226 | |||
227 | static struct usb_otg_descriptor otg_desc = { | ||
228 | .bLength = sizeof otg_desc, | ||
229 | .bDescriptorType = USB_DT_OTG, | ||
230 | .bmAttributes = USB_OTG_SRP | ||
231 | }; | ||
232 | |||
233 | static struct usb_config_descriptor config_desc = { | ||
234 | .bLength = sizeof config_desc, | ||
235 | .bDescriptorType = USB_DT_CONFIG, | ||
236 | |||
237 | /* compute wTotalLength on the fly */ | ||
238 | .bNumInterfaces = 1, | ||
239 | .bConfigurationValue = DEV_CONFIG_VALUE, | ||
240 | .iConfiguration = 0, | ||
241 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, | ||
242 | .bMaxPower = 1 /* Self-Powered */ | ||
243 | }; | ||
244 | |||
245 | static struct usb_interface_descriptor intf_desc = { | ||
246 | .bLength = sizeof intf_desc, | ||
247 | .bDescriptorType = USB_DT_INTERFACE, | ||
248 | .bInterfaceNumber = PRINTER_INTERFACE, | ||
249 | .bNumEndpoints = 2, | ||
250 | .bInterfaceClass = USB_CLASS_PRINTER, | ||
251 | .bInterfaceSubClass = 1, /* Printer Sub-Class */ | ||
252 | .bInterfaceProtocol = 2, /* Bi-Directional */ | ||
253 | .iInterface = 0 | ||
254 | }; | ||
255 | |||
256 | static struct usb_endpoint_descriptor fs_ep_in_desc = { | ||
257 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
258 | .bDescriptorType = USB_DT_ENDPOINT, | ||
259 | .bEndpointAddress = USB_DIR_IN, | ||
260 | .bmAttributes = USB_ENDPOINT_XFER_BULK | ||
261 | }; | ||
262 | |||
263 | static struct usb_endpoint_descriptor fs_ep_out_desc = { | ||
264 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
265 | .bDescriptorType = USB_DT_ENDPOINT, | ||
266 | .bEndpointAddress = USB_DIR_OUT, | ||
267 | .bmAttributes = USB_ENDPOINT_XFER_BULK | ||
268 | }; | ||
269 | |||
270 | static const struct usb_descriptor_header *fs_printer_function [11] = { | ||
271 | (struct usb_descriptor_header *) &otg_desc, | ||
272 | (struct usb_descriptor_header *) &intf_desc, | ||
273 | (struct usb_descriptor_header *) &fs_ep_in_desc, | ||
274 | (struct usb_descriptor_header *) &fs_ep_out_desc, | ||
275 | NULL | ||
276 | }; | ||
277 | |||
278 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
279 | |||
280 | /* | ||
281 | * usb 2.0 devices need to expose both high speed and full speed | ||
282 | * descriptors, unless they only run at full speed. | ||
283 | */ | ||
284 | |||
285 | static struct usb_endpoint_descriptor hs_ep_in_desc = { | ||
286 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
287 | .bDescriptorType = USB_DT_ENDPOINT, | ||
288 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
289 | .wMaxPacketSize = __constant_cpu_to_le16(512) | ||
290 | }; | ||
291 | |||
292 | static struct usb_endpoint_descriptor hs_ep_out_desc = { | ||
293 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
294 | .bDescriptorType = USB_DT_ENDPOINT, | ||
295 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
296 | .wMaxPacketSize = __constant_cpu_to_le16(512) | ||
297 | }; | ||
298 | |||
299 | static struct usb_qualifier_descriptor dev_qualifier = { | ||
300 | .bLength = sizeof dev_qualifier, | ||
301 | .bDescriptorType = USB_DT_DEVICE_QUALIFIER, | ||
302 | .bcdUSB = __constant_cpu_to_le16(0x0200), | ||
303 | .bDeviceClass = USB_CLASS_PRINTER, | ||
304 | .bNumConfigurations = 1 | ||
305 | }; | ||
306 | |||
307 | static const struct usb_descriptor_header *hs_printer_function [11] = { | ||
308 | (struct usb_descriptor_header *) &otg_desc, | ||
309 | (struct usb_descriptor_header *) &intf_desc, | ||
310 | (struct usb_descriptor_header *) &hs_ep_in_desc, | ||
311 | (struct usb_descriptor_header *) &hs_ep_out_desc, | ||
312 | NULL | ||
313 | }; | ||
314 | |||
315 | /* maxpacket and other transfer characteristics vary by speed. */ | ||
316 | #define ep_desc(g, hs, fs) (((g)->speed == USB_SPEED_HIGH)?(hs):(fs)) | ||
317 | |||
318 | #else | ||
319 | |||
320 | /* if there's no high speed support, maxpacket doesn't change. */ | ||
321 | #define ep_desc(g, hs, fs) (((void)(g)), (fs)) | ||
322 | |||
323 | #endif /* !CONFIG_USB_GADGET_DUALSPEED */ | ||
324 | |||
325 | /*-------------------------------------------------------------------------*/ | ||
326 | |||
327 | /* descriptors that are built on-demand */ | ||
328 | |||
329 | static char manufacturer [50]; | ||
330 | static char product_desc [40] = DRIVER_DESC; | ||
331 | static char serial_num [40] = "1"; | ||
332 | static char pnp_string [1024] = | ||
333 | "XXMFG:linux;MDL:g_printer;CLS:PRINTER;SN:1;"; | ||
334 | |||
335 | /* static strings, in UTF-8 */ | ||
336 | static struct usb_string strings [] = { | ||
337 | { STRING_MANUFACTURER, manufacturer, }, | ||
338 | { STRING_PRODUCT, product_desc, }, | ||
339 | { STRING_SERIALNUM, serial_num, }, | ||
340 | { } /* end of list */ | ||
341 | }; | ||
342 | |||
343 | static struct usb_gadget_strings stringtab = { | ||
344 | .language = 0x0409, /* en-us */ | ||
345 | .strings = strings, | ||
346 | }; | ||
347 | |||
348 | /*-------------------------------------------------------------------------*/ | ||
349 | |||
350 | static struct usb_request * | ||
351 | printer_req_alloc(struct usb_ep *ep, unsigned len, gfp_t gfp_flags) | ||
352 | { | ||
353 | struct usb_request *req; | ||
354 | |||
355 | req = usb_ep_alloc_request(ep, gfp_flags); | ||
356 | |||
357 | if (req != NULL) { | ||
358 | req->length = len; | ||
359 | req->buf = kmalloc(len, gfp_flags); | ||
360 | if (req->buf == NULL) { | ||
361 | usb_ep_free_request(ep, req); | ||
362 | return NULL; | ||
363 | } | ||
364 | } | ||
365 | |||
366 | return req; | ||
367 | } | ||
368 | |||
369 | static void | ||
370 | printer_req_free(struct usb_ep *ep, struct usb_request *req) | ||
371 | { | ||
372 | if (ep != NULL && req != NULL) { | ||
373 | kfree(req->buf); | ||
374 | usb_ep_free_request(ep, req); | ||
375 | } | ||
376 | } | ||
377 | |||
378 | /*-------------------------------------------------------------------------*/ | ||
379 | |||
380 | static void rx_complete(struct usb_ep *ep, struct usb_request *req) | ||
381 | { | ||
382 | struct printer_dev *dev = ep->driver_data; | ||
383 | int status = req->status; | ||
384 | unsigned long flags; | ||
385 | |||
386 | spin_lock_irqsave(&dev->lock, flags); | ||
387 | |||
388 | list_del_init(&req->list); /* Remode from Active List */ | ||
389 | |||
390 | switch (status) { | ||
391 | |||
392 | /* normal completion */ | ||
393 | case 0: | ||
394 | list_add_tail(&req->list, &dev->rx_buffers); | ||
395 | wake_up_interruptible(&dev->rx_wait); | ||
396 | DBG(dev, "G_Printer : rx length %d\n", req->actual); | ||
397 | break; | ||
398 | |||
399 | /* software-driven interface shutdown */ | ||
400 | case -ECONNRESET: /* unlink */ | ||
401 | case -ESHUTDOWN: /* disconnect etc */ | ||
402 | VDBG(dev, "rx shutdown, code %d\n", status); | ||
403 | list_add(&req->list, &dev->rx_reqs); | ||
404 | break; | ||
405 | |||
406 | /* for hardware automagic (such as pxa) */ | ||
407 | case -ECONNABORTED: /* endpoint reset */ | ||
408 | DBG(dev, "rx %s reset\n", ep->name); | ||
409 | list_add(&req->list, &dev->rx_reqs); | ||
410 | break; | ||
411 | |||
412 | /* data overrun */ | ||
413 | case -EOVERFLOW: | ||
414 | /* FALLTHROUGH */ | ||
415 | |||
416 | default: | ||
417 | DBG(dev, "rx status %d\n", status); | ||
418 | list_add(&req->list, &dev->rx_reqs); | ||
419 | break; | ||
420 | } | ||
421 | spin_unlock_irqrestore(&dev->lock, flags); | ||
422 | } | ||
423 | |||
424 | static void tx_complete(struct usb_ep *ep, struct usb_request *req) | ||
425 | { | ||
426 | struct printer_dev *dev = ep->driver_data; | ||
427 | |||
428 | switch (req->status) { | ||
429 | default: | ||
430 | VDBG(dev, "tx err %d\n", req->status); | ||
431 | /* FALLTHROUGH */ | ||
432 | case -ECONNRESET: /* unlink */ | ||
433 | case -ESHUTDOWN: /* disconnect etc */ | ||
434 | break; | ||
435 | case 0: | ||
436 | break; | ||
437 | } | ||
438 | |||
439 | spin_lock(&dev->lock); | ||
440 | /* Take the request struct off the active list and put it on the | ||
441 | * free list. | ||
442 | */ | ||
443 | list_del_init(&req->list); | ||
444 | list_add(&req->list, &dev->tx_reqs); | ||
445 | wake_up_interruptible(&dev->tx_wait); | ||
446 | if (likely(list_empty(&dev->tx_reqs_active))) | ||
447 | wake_up_interruptible(&dev->tx_flush_wait); | ||
448 | |||
449 | spin_unlock(&dev->lock); | ||
450 | } | ||
451 | |||
452 | /*-------------------------------------------------------------------------*/ | ||
453 | |||
454 | static int | ||
455 | printer_open(struct inode *inode, struct file *fd) | ||
456 | { | ||
457 | struct printer_dev *dev; | ||
458 | unsigned long flags; | ||
459 | int ret = -EBUSY; | ||
460 | |||
461 | dev = container_of(inode->i_cdev, struct printer_dev, printer_cdev); | ||
462 | |||
463 | spin_lock_irqsave(&dev->lock, flags); | ||
464 | |||
465 | if (!dev->printer_cdev_open) { | ||
466 | dev->printer_cdev_open = 1; | ||
467 | fd->private_data = dev; | ||
468 | ret = 0; | ||
469 | /* Change the printer status to show that it's on-line. */ | ||
470 | dev->printer_status |= PRINTER_SELECTED; | ||
471 | } | ||
472 | |||
473 | spin_unlock_irqrestore(&dev->lock, flags); | ||
474 | |||
475 | DBG(dev, "printer_open returned %x\n", ret); | ||
476 | |||
477 | return ret; | ||
478 | } | ||
479 | |||
480 | static int | ||
481 | printer_close(struct inode *inode, struct file *fd) | ||
482 | { | ||
483 | struct printer_dev *dev = fd->private_data; | ||
484 | unsigned long flags; | ||
485 | |||
486 | spin_lock_irqsave(&dev->lock, flags); | ||
487 | dev->printer_cdev_open = 0; | ||
488 | fd->private_data = NULL; | ||
489 | /* Change printer status to show that the printer is off-line. */ | ||
490 | dev->printer_status &= ~PRINTER_SELECTED; | ||
491 | spin_unlock_irqrestore(&dev->lock, flags); | ||
492 | |||
493 | DBG(dev, "printer_close\n"); | ||
494 | |||
495 | return 0; | ||
496 | } | ||
497 | |||
498 | static ssize_t | ||
499 | printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr) | ||
500 | { | ||
501 | struct printer_dev *dev = fd->private_data; | ||
502 | unsigned long flags; | ||
503 | size_t size; | ||
504 | size_t bytes_copied; | ||
505 | struct usb_request *req; | ||
506 | /* This is a pointer to the current USB rx request. */ | ||
507 | struct usb_request *current_rx_req; | ||
508 | /* This is the number of bytes in the current rx buffer. */ | ||
509 | size_t current_rx_bytes; | ||
510 | /* This is a pointer to the current rx buffer. */ | ||
511 | u8 *current_rx_buf; | ||
512 | |||
513 | if (len == 0) | ||
514 | return -EINVAL; | ||
515 | |||
516 | DBG(dev, "printer_read trying to read %d bytes\n", (int)len); | ||
517 | |||
518 | spin_lock(&dev->lock_printer_io); | ||
519 | spin_lock_irqsave(&dev->lock, flags); | ||
520 | |||
521 | /* We will use this flag later to check if a printer reset happened | ||
522 | * after we turn interrupts back on. | ||
523 | */ | ||
524 | dev->reset_printer = 0; | ||
525 | |||
526 | while (likely(!list_empty(&dev->rx_reqs))) { | ||
527 | int error; | ||
528 | |||
529 | req = container_of(dev->rx_reqs.next, | ||
530 | struct usb_request, list); | ||
531 | list_del_init(&req->list); | ||
532 | |||
533 | /* The USB Host sends us whatever amount of data it wants to | ||
534 | * so we always set the length field to the full USB_BUFSIZE. | ||
535 | * If the amount of data is more than the read() caller asked | ||
536 | * for it will be stored in the request buffer until it is | ||
537 | * asked for by read(). | ||
538 | */ | ||
539 | req->length = USB_BUFSIZE; | ||
540 | req->complete = rx_complete; | ||
541 | |||
542 | error = usb_ep_queue(dev->out_ep, req, GFP_ATOMIC); | ||
543 | if (error) { | ||
544 | DBG(dev, "rx submit --> %d\n", error); | ||
545 | list_add(&req->list, &dev->rx_reqs); | ||
546 | break; | ||
547 | } else { | ||
548 | list_add(&req->list, &dev->rx_reqs_active); | ||
549 | } | ||
550 | } | ||
551 | |||
552 | bytes_copied = 0; | ||
553 | current_rx_req = dev->current_rx_req; | ||
554 | current_rx_bytes = dev->current_rx_bytes; | ||
555 | current_rx_buf = dev->current_rx_buf; | ||
556 | dev->current_rx_req = NULL; | ||
557 | dev->current_rx_bytes = 0; | ||
558 | dev->current_rx_buf = NULL; | ||
559 | |||
560 | /* Check if there is any data in the read buffers. Please note that | ||
561 | * current_rx_bytes is the number of bytes in the current rx buffer. | ||
562 | * If it is zero then check if there are any other rx_buffers that | ||
563 | * are on the completed list. We are only out of data if all rx | ||
564 | * buffers are empty. | ||
565 | */ | ||
566 | if ((current_rx_bytes == 0) && | ||
567 | (likely(list_empty(&dev->rx_buffers)))) { | ||
568 | /* Turn interrupts back on before sleeping. */ | ||
569 | spin_unlock_irqrestore(&dev->lock, flags); | ||
570 | |||
571 | /* | ||
572 | * If no data is available check if this is a NON-Blocking | ||
573 | * call or not. | ||
574 | */ | ||
575 | if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) { | ||
576 | spin_unlock(&dev->lock_printer_io); | ||
577 | return -EAGAIN; | ||
578 | } | ||
579 | |||
580 | /* Sleep until data is available */ | ||
581 | wait_event_interruptible(dev->rx_wait, | ||
582 | (likely(!list_empty(&dev->rx_buffers)))); | ||
583 | spin_lock_irqsave(&dev->lock, flags); | ||
584 | } | ||
585 | |||
586 | /* We have data to return then copy it to the caller's buffer.*/ | ||
587 | while ((current_rx_bytes || likely(!list_empty(&dev->rx_buffers))) | ||
588 | && len) { | ||
589 | if (current_rx_bytes == 0) { | ||
590 | req = container_of(dev->rx_buffers.next, | ||
591 | struct usb_request, list); | ||
592 | list_del_init(&req->list); | ||
593 | |||
594 | if (req->actual && req->buf) { | ||
595 | current_rx_req = req; | ||
596 | current_rx_bytes = req->actual; | ||
597 | current_rx_buf = req->buf; | ||
598 | } else { | ||
599 | list_add(&req->list, &dev->rx_reqs); | ||
600 | continue; | ||
601 | } | ||
602 | } | ||
603 | |||
604 | /* Don't leave irqs off while doing memory copies */ | ||
605 | spin_unlock_irqrestore(&dev->lock, flags); | ||
606 | |||
607 | if (len > current_rx_bytes) | ||
608 | size = current_rx_bytes; | ||
609 | else | ||
610 | size = len; | ||
611 | |||
612 | size -= copy_to_user(buf, current_rx_buf, size); | ||
613 | bytes_copied += size; | ||
614 | len -= size; | ||
615 | buf += size; | ||
616 | |||
617 | spin_lock_irqsave(&dev->lock, flags); | ||
618 | |||
619 | /* We've disconnected or reset free the req and buffer */ | ||
620 | if (dev->reset_printer) { | ||
621 | printer_req_free(dev->out_ep, current_rx_req); | ||
622 | spin_unlock_irqrestore(&dev->lock, flags); | ||
623 | spin_unlock(&dev->lock_printer_io); | ||
624 | return -EAGAIN; | ||
625 | } | ||
626 | |||
627 | /* If we not returning all the data left in this RX request | ||
628 | * buffer then adjust the amount of data left in the buffer. | ||
629 | * Othewise if we are done with this RX request buffer then | ||
630 | * requeue it to get any incoming data from the USB host. | ||
631 | */ | ||
632 | if (size < current_rx_bytes) { | ||
633 | current_rx_bytes -= size; | ||
634 | current_rx_buf += size; | ||
635 | } else { | ||
636 | list_add(¤t_rx_req->list, &dev->rx_reqs); | ||
637 | current_rx_bytes = 0; | ||
638 | current_rx_buf = NULL; | ||
639 | current_rx_req = NULL; | ||
640 | } | ||
641 | } | ||
642 | |||
643 | dev->current_rx_req = current_rx_req; | ||
644 | dev->current_rx_bytes = current_rx_bytes; | ||
645 | dev->current_rx_buf = current_rx_buf; | ||
646 | |||
647 | spin_unlock_irqrestore(&dev->lock, flags); | ||
648 | spin_unlock(&dev->lock_printer_io); | ||
649 | |||
650 | DBG(dev, "printer_read returned %d bytes\n", (int)bytes_copied); | ||
651 | |||
652 | if (bytes_copied) | ||
653 | return bytes_copied; | ||
654 | else | ||
655 | return -EAGAIN; | ||
656 | } | ||
657 | |||
658 | static ssize_t | ||
659 | printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | ||
660 | { | ||
661 | struct printer_dev *dev = fd->private_data; | ||
662 | unsigned long flags; | ||
663 | size_t size; /* Amount of data in a TX request. */ | ||
664 | size_t bytes_copied = 0; | ||
665 | struct usb_request *req; | ||
666 | |||
667 | DBG(dev, "printer_write trying to send %d bytes\n", (int)len); | ||
668 | |||
669 | if (len == 0) | ||
670 | return -EINVAL; | ||
671 | |||
672 | spin_lock(&dev->lock_printer_io); | ||
673 | spin_lock_irqsave(&dev->lock, flags); | ||
674 | |||
675 | /* Check if a printer reset happens while we have interrupts on */ | ||
676 | dev->reset_printer = 0; | ||
677 | |||
678 | /* Check if there is any available write buffers */ | ||
679 | if (likely(list_empty(&dev->tx_reqs))) { | ||
680 | /* Turn interrupts back on before sleeping. */ | ||
681 | spin_unlock_irqrestore(&dev->lock, flags); | ||
682 | |||
683 | /* | ||
684 | * If write buffers are available check if this is | ||
685 | * a NON-Blocking call or not. | ||
686 | */ | ||
687 | if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) { | ||
688 | spin_unlock(&dev->lock_printer_io); | ||
689 | return -EAGAIN; | ||
690 | } | ||
691 | |||
692 | /* Sleep until a write buffer is available */ | ||
693 | wait_event_interruptible(dev->tx_wait, | ||
694 | (likely(!list_empty(&dev->tx_reqs)))); | ||
695 | spin_lock_irqsave(&dev->lock, flags); | ||
696 | } | ||
697 | |||
698 | while (likely(!list_empty(&dev->tx_reqs)) && len) { | ||
699 | |||
700 | if (len > USB_BUFSIZE) | ||
701 | size = USB_BUFSIZE; | ||
702 | else | ||
703 | size = len; | ||
704 | |||
705 | req = container_of(dev->tx_reqs.next, struct usb_request, | ||
706 | list); | ||
707 | list_del_init(&req->list); | ||
708 | |||
709 | req->complete = tx_complete; | ||
710 | req->length = size; | ||
711 | |||
712 | /* Check if we need to send a zero length packet. */ | ||
713 | if (len > size) | ||
714 | /* They will be more TX requests so no yet. */ | ||
715 | req->zero = 0; | ||
716 | else | ||
717 | /* If the data amount is not a multple of the | ||
718 | * maxpacket size then send a zero length packet. | ||
719 | */ | ||
720 | req->zero = ((len % dev->in_ep->maxpacket) == 0); | ||
721 | |||
722 | /* Don't leave irqs off while doing memory copies */ | ||
723 | spin_unlock_irqrestore(&dev->lock, flags); | ||
724 | |||
725 | if (copy_from_user(req->buf, buf, size)) { | ||
726 | list_add(&req->list, &dev->tx_reqs); | ||
727 | spin_unlock(&dev->lock_printer_io); | ||
728 | return bytes_copied; | ||
729 | } | ||
730 | |||
731 | bytes_copied += size; | ||
732 | len -= size; | ||
733 | buf += size; | ||
734 | |||
735 | spin_lock_irqsave(&dev->lock, flags); | ||
736 | |||
737 | /* We've disconnected or reset so free the req and buffer */ | ||
738 | if (dev->reset_printer) { | ||
739 | printer_req_free(dev->in_ep, req); | ||
740 | spin_unlock_irqrestore(&dev->lock, flags); | ||
741 | spin_unlock(&dev->lock_printer_io); | ||
742 | return -EAGAIN; | ||
743 | } | ||
744 | |||
745 | if (usb_ep_queue(dev->in_ep, req, GFP_ATOMIC)) { | ||
746 | list_add(&req->list, &dev->tx_reqs); | ||
747 | spin_unlock_irqrestore(&dev->lock, flags); | ||
748 | spin_unlock(&dev->lock_printer_io); | ||
749 | return -EAGAIN; | ||
750 | } | ||
751 | |||
752 | list_add(&req->list, &dev->tx_reqs_active); | ||
753 | |||
754 | } | ||
755 | |||
756 | spin_unlock_irqrestore(&dev->lock, flags); | ||
757 | spin_unlock(&dev->lock_printer_io); | ||
758 | |||
759 | DBG(dev, "printer_write sent %d bytes\n", (int)bytes_copied); | ||
760 | |||
761 | if (bytes_copied) { | ||
762 | return bytes_copied; | ||
763 | } else { | ||
764 | return -EAGAIN; | ||
765 | } | ||
766 | } | ||
767 | |||
768 | static int | ||
769 | printer_fsync(struct file *fd, struct dentry *dentry, int datasync) | ||
770 | { | ||
771 | struct printer_dev *dev = fd->private_data; | ||
772 | unsigned long flags; | ||
773 | int tx_list_empty; | ||
774 | |||
775 | spin_lock_irqsave(&dev->lock, flags); | ||
776 | tx_list_empty = (likely(list_empty(&dev->tx_reqs))); | ||
777 | spin_unlock_irqrestore(&dev->lock, flags); | ||
778 | |||
779 | if (!tx_list_empty) { | ||
780 | /* Sleep until all data has been sent */ | ||
781 | wait_event_interruptible(dev->tx_flush_wait, | ||
782 | (likely(list_empty(&dev->tx_reqs_active)))); | ||
783 | } | ||
784 | |||
785 | return 0; | ||
786 | } | ||
787 | |||
788 | static unsigned int | ||
789 | printer_poll(struct file *fd, poll_table *wait) | ||
790 | { | ||
791 | struct printer_dev *dev = fd->private_data; | ||
792 | unsigned long flags; | ||
793 | int status = 0; | ||
794 | |||
795 | poll_wait(fd, &dev->rx_wait, wait); | ||
796 | poll_wait(fd, &dev->tx_wait, wait); | ||
797 | |||
798 | spin_lock_irqsave(&dev->lock, flags); | ||
799 | if (likely(!list_empty(&dev->tx_reqs))) | ||
800 | status |= POLLOUT | POLLWRNORM; | ||
801 | |||
802 | if (likely(!list_empty(&dev->rx_buffers))) | ||
803 | status |= POLLIN | POLLRDNORM; | ||
804 | |||
805 | spin_unlock_irqrestore(&dev->lock, flags); | ||
806 | |||
807 | return status; | ||
808 | } | ||
809 | |||
810 | static int | ||
811 | printer_ioctl(struct inode *inode, struct file *fd, unsigned int code, | ||
812 | unsigned long arg) | ||
813 | { | ||
814 | struct printer_dev *dev = fd->private_data; | ||
815 | unsigned long flags; | ||
816 | int status = 0; | ||
817 | |||
818 | DBG(dev, "printer_ioctl: cmd=0x%4.4x, arg=%lu\n", code, arg); | ||
819 | |||
820 | /* handle ioctls */ | ||
821 | |||
822 | spin_lock_irqsave(&dev->lock, flags); | ||
823 | |||
824 | switch (code) { | ||
825 | case GADGET_GET_PRINTER_STATUS: | ||
826 | status = (int)dev->printer_status; | ||
827 | break; | ||
828 | case GADGET_SET_PRINTER_STATUS: | ||
829 | dev->printer_status = (u8)arg; | ||
830 | break; | ||
831 | default: | ||
832 | /* could not handle ioctl */ | ||
833 | DBG(dev, "printer_ioctl: ERROR cmd=0x%4.4xis not supported\n", | ||
834 | code); | ||
835 | status = -ENOTTY; | ||
836 | } | ||
837 | |||
838 | spin_unlock_irqrestore(&dev->lock, flags); | ||
839 | |||
840 | return status; | ||
841 | } | ||
842 | |||
843 | /* used after endpoint configuration */ | ||
844 | static struct file_operations printer_io_operations = { | ||
845 | .owner = THIS_MODULE, | ||
846 | .open = printer_open, | ||
847 | .read = printer_read, | ||
848 | .write = printer_write, | ||
849 | .fsync = printer_fsync, | ||
850 | .poll = printer_poll, | ||
851 | .ioctl = printer_ioctl, | ||
852 | .release = printer_close | ||
853 | }; | ||
854 | |||
855 | /*-------------------------------------------------------------------------*/ | ||
856 | |||
857 | static int | ||
858 | set_printer_interface(struct printer_dev *dev) | ||
859 | { | ||
860 | int result = 0; | ||
861 | |||
862 | dev->in = ep_desc(dev->gadget, &hs_ep_in_desc, &fs_ep_in_desc); | ||
863 | dev->in_ep->driver_data = dev; | ||
864 | |||
865 | dev->out = ep_desc(dev->gadget, &hs_ep_out_desc, &fs_ep_out_desc); | ||
866 | dev->out_ep->driver_data = dev; | ||
867 | |||
868 | result = usb_ep_enable(dev->in_ep, dev->in); | ||
869 | if (result != 0) { | ||
870 | DBG(dev, "enable %s --> %d\n", dev->in_ep->name, result); | ||
871 | goto done; | ||
872 | } | ||
873 | |||
874 | result = usb_ep_enable(dev->out_ep, dev->out); | ||
875 | if (result != 0) { | ||
876 | DBG(dev, "enable %s --> %d\n", dev->in_ep->name, result); | ||
877 | goto done; | ||
878 | } | ||
879 | |||
880 | done: | ||
881 | /* on error, disable any endpoints */ | ||
882 | if (result != 0) { | ||
883 | (void) usb_ep_disable(dev->in_ep); | ||
884 | (void) usb_ep_disable(dev->out_ep); | ||
885 | dev->in = NULL; | ||
886 | dev->out = NULL; | ||
887 | } | ||
888 | |||
889 | /* caller is responsible for cleanup on error */ | ||
890 | return result; | ||
891 | } | ||
892 | |||
893 | static void printer_reset_interface(struct printer_dev *dev) | ||
894 | { | ||
895 | if (dev->interface < 0) | ||
896 | return; | ||
897 | |||
898 | DBG(dev, "%s\n", __FUNCTION__); | ||
899 | |||
900 | if (dev->in) | ||
901 | usb_ep_disable(dev->in_ep); | ||
902 | |||
903 | if (dev->out) | ||
904 | usb_ep_disable(dev->out_ep); | ||
905 | |||
906 | dev->interface = -1; | ||
907 | } | ||
908 | |||
909 | /* change our operational config. must agree with the code | ||
910 | * that returns config descriptors, and altsetting code. | ||
911 | */ | ||
912 | static int | ||
913 | printer_set_config(struct printer_dev *dev, unsigned number) | ||
914 | { | ||
915 | int result = 0; | ||
916 | struct usb_gadget *gadget = dev->gadget; | ||
917 | |||
918 | if (gadget_is_sa1100(gadget) && dev->config) { | ||
919 | /* tx fifo is full, but we can't clear it...*/ | ||
920 | INFO(dev, "can't change configurations\n"); | ||
921 | return -ESPIPE; | ||
922 | } | ||
923 | |||
924 | switch (number) { | ||
925 | case DEV_CONFIG_VALUE: | ||
926 | result = 0; | ||
927 | break; | ||
928 | default: | ||
929 | result = -EINVAL; | ||
930 | /* FALL THROUGH */ | ||
931 | case 0: | ||
932 | break; | ||
933 | } | ||
934 | |||
935 | if (result) { | ||
936 | usb_gadget_vbus_draw(dev->gadget, | ||
937 | dev->gadget->is_otg ? 8 : 100); | ||
938 | } else { | ||
939 | char *speed; | ||
940 | unsigned power; | ||
941 | |||
942 | power = 2 * config_desc.bMaxPower; | ||
943 | usb_gadget_vbus_draw(dev->gadget, power); | ||
944 | |||
945 | switch (gadget->speed) { | ||
946 | case USB_SPEED_FULL: speed = "full"; break; | ||
947 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
948 | case USB_SPEED_HIGH: speed = "high"; break; | ||
949 | #endif | ||
950 | default: speed = "?"; break; | ||
951 | } | ||
952 | |||
953 | dev->config = number; | ||
954 | INFO(dev, "%s speed config #%d: %d mA, %s\n", | ||
955 | speed, number, power, driver_desc); | ||
956 | } | ||
957 | return result; | ||
958 | } | ||
959 | |||
960 | static int | ||
961 | config_buf(enum usb_device_speed speed, u8 *buf, u8 type, unsigned index, | ||
962 | int is_otg) | ||
963 | { | ||
964 | int len; | ||
965 | const struct usb_descriptor_header **function; | ||
966 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
967 | int hs = (speed == USB_SPEED_HIGH); | ||
968 | |||
969 | if (type == USB_DT_OTHER_SPEED_CONFIG) | ||
970 | hs = !hs; | ||
971 | |||
972 | if (hs) { | ||
973 | function = hs_printer_function; | ||
974 | } else { | ||
975 | function = fs_printer_function; | ||
976 | } | ||
977 | #else | ||
978 | function = fs_printer_function; | ||
979 | #endif | ||
980 | |||
981 | if (index >= device_desc.bNumConfigurations) | ||
982 | return -EINVAL; | ||
983 | |||
984 | /* for now, don't advertise srp-only devices */ | ||
985 | if (!is_otg) | ||
986 | function++; | ||
987 | |||
988 | len = usb_gadget_config_buf(&config_desc, buf, USB_DESC_BUFSIZE, | ||
989 | function); | ||
990 | if (len < 0) | ||
991 | return len; | ||
992 | ((struct usb_config_descriptor *) buf)->bDescriptorType = type; | ||
993 | return len; | ||
994 | } | ||
995 | |||
996 | /* Change our operational Interface. */ | ||
997 | static int | ||
998 | set_interface(struct printer_dev *dev, unsigned number) | ||
999 | { | ||
1000 | int result = 0; | ||
1001 | |||
1002 | if (gadget_is_sa1100(dev->gadget) && dev->interface < 0) { | ||
1003 | /* tx fifo is full, but we can't clear it...*/ | ||
1004 | INFO(dev, "can't change interfaces\n"); | ||
1005 | return -ESPIPE; | ||
1006 | } | ||
1007 | |||
1008 | /* Free the current interface */ | ||
1009 | switch (dev->interface) { | ||
1010 | case PRINTER_INTERFACE: | ||
1011 | printer_reset_interface(dev); | ||
1012 | break; | ||
1013 | } | ||
1014 | |||
1015 | switch (number) { | ||
1016 | case PRINTER_INTERFACE: | ||
1017 | result = set_printer_interface(dev); | ||
1018 | if (result) { | ||
1019 | printer_reset_interface(dev); | ||
1020 | } else { | ||
1021 | dev->interface = PRINTER_INTERFACE; | ||
1022 | } | ||
1023 | break; | ||
1024 | default: | ||
1025 | result = -EINVAL; | ||
1026 | /* FALL THROUGH */ | ||
1027 | } | ||
1028 | |||
1029 | if (!result) | ||
1030 | INFO(dev, "Using interface %x\n", number); | ||
1031 | |||
1032 | return result; | ||
1033 | } | ||
1034 | |||
1035 | static void printer_setup_complete(struct usb_ep *ep, struct usb_request *req) | ||
1036 | { | ||
1037 | if (req->status || req->actual != req->length) | ||
1038 | DBG((struct printer_dev *) ep->driver_data, | ||
1039 | "setup complete --> %d, %d/%d\n", | ||
1040 | req->status, req->actual, req->length); | ||
1041 | } | ||
1042 | |||
1043 | static void printer_soft_reset(struct printer_dev *dev) | ||
1044 | { | ||
1045 | struct usb_request *req; | ||
1046 | |||
1047 | INFO(dev, "Received Printer Reset Request\n"); | ||
1048 | |||
1049 | if (usb_ep_disable(dev->in_ep)) | ||
1050 | DBG(dev, "Failed to disable USB in_ep\n"); | ||
1051 | if (usb_ep_disable(dev->out_ep)) | ||
1052 | DBG(dev, "Failed to disable USB out_ep\n"); | ||
1053 | |||
1054 | if (dev->current_rx_req != NULL) { | ||
1055 | list_add(&dev->current_rx_req->list, &dev->rx_reqs); | ||
1056 | dev->current_rx_req = NULL; | ||
1057 | } | ||
1058 | dev->current_rx_bytes = 0; | ||
1059 | dev->current_rx_buf = NULL; | ||
1060 | dev->reset_printer = 1; | ||
1061 | |||
1062 | while (likely(!(list_empty(&dev->rx_buffers)))) { | ||
1063 | req = container_of(dev->rx_buffers.next, struct usb_request, | ||
1064 | list); | ||
1065 | list_del_init(&req->list); | ||
1066 | list_add(&req->list, &dev->rx_reqs); | ||
1067 | } | ||
1068 | |||
1069 | while (likely(!(list_empty(&dev->rx_reqs_active)))) { | ||
1070 | req = container_of(dev->rx_buffers.next, struct usb_request, | ||
1071 | list); | ||
1072 | list_del_init(&req->list); | ||
1073 | list_add(&req->list, &dev->rx_reqs); | ||
1074 | } | ||
1075 | |||
1076 | while (likely(!(list_empty(&dev->tx_reqs_active)))) { | ||
1077 | req = container_of(dev->tx_reqs_active.next, | ||
1078 | struct usb_request, list); | ||
1079 | list_del_init(&req->list); | ||
1080 | list_add(&req->list, &dev->tx_reqs); | ||
1081 | } | ||
1082 | |||
1083 | if (usb_ep_enable(dev->in_ep, dev->in)) | ||
1084 | DBG(dev, "Failed to enable USB in_ep\n"); | ||
1085 | if (usb_ep_enable(dev->out_ep, dev->out)) | ||
1086 | DBG(dev, "Failed to enable USB out_ep\n"); | ||
1087 | |||
1088 | wake_up_interruptible(&dev->tx_wait); | ||
1089 | wake_up_interruptible(&dev->tx_flush_wait); | ||
1090 | } | ||
1091 | |||
1092 | /*-------------------------------------------------------------------------*/ | ||
1093 | |||
1094 | /* | ||
1095 | * The setup() callback implements all the ep0 functionality that's not | ||
1096 | * handled lower down. | ||
1097 | */ | ||
1098 | static int | ||
1099 | printer_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | ||
1100 | { | ||
1101 | struct printer_dev *dev = get_gadget_data(gadget); | ||
1102 | struct usb_request *req = dev->req; | ||
1103 | int value = -EOPNOTSUPP; | ||
1104 | u16 wIndex = le16_to_cpu(ctrl->wIndex); | ||
1105 | u16 wValue = le16_to_cpu(ctrl->wValue); | ||
1106 | u16 wLength = le16_to_cpu(ctrl->wLength); | ||
1107 | |||
1108 | DBG(dev, "ctrl req%02x.%02x v%04x i%04x l%d\n", | ||
1109 | ctrl->bRequestType, ctrl->bRequest, wValue, wIndex, wLength); | ||
1110 | |||
1111 | req->complete = printer_setup_complete; | ||
1112 | |||
1113 | switch (ctrl->bRequestType&USB_TYPE_MASK) { | ||
1114 | |||
1115 | case USB_TYPE_STANDARD: | ||
1116 | switch (ctrl->bRequest) { | ||
1117 | |||
1118 | case USB_REQ_GET_DESCRIPTOR: | ||
1119 | if (ctrl->bRequestType != USB_DIR_IN) | ||
1120 | break; | ||
1121 | switch (wValue >> 8) { | ||
1122 | |||
1123 | case USB_DT_DEVICE: | ||
1124 | value = min(wLength, (u16) sizeof device_desc); | ||
1125 | memcpy(req->buf, &device_desc, value); | ||
1126 | break; | ||
1127 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
1128 | case USB_DT_DEVICE_QUALIFIER: | ||
1129 | if (!gadget->is_dualspeed) | ||
1130 | break; | ||
1131 | value = min(wLength, | ||
1132 | (u16) sizeof dev_qualifier); | ||
1133 | memcpy(req->buf, &dev_qualifier, value); | ||
1134 | break; | ||
1135 | |||
1136 | case USB_DT_OTHER_SPEED_CONFIG: | ||
1137 | if (!gadget->is_dualspeed) | ||
1138 | break; | ||
1139 | /* FALLTHROUGH */ | ||
1140 | #endif /* CONFIG_USB_GADGET_DUALSPEED */ | ||
1141 | case USB_DT_CONFIG: | ||
1142 | value = config_buf(gadget->speed, req->buf, | ||
1143 | wValue >> 8, | ||
1144 | wValue & 0xff, | ||
1145 | gadget->is_otg); | ||
1146 | if (value >= 0) | ||
1147 | value = min(wLength, (u16) value); | ||
1148 | break; | ||
1149 | |||
1150 | case USB_DT_STRING: | ||
1151 | value = usb_gadget_get_string(&stringtab, | ||
1152 | wValue & 0xff, req->buf); | ||
1153 | if (value >= 0) | ||
1154 | value = min(wLength, (u16) value); | ||
1155 | break; | ||
1156 | } | ||
1157 | break; | ||
1158 | |||
1159 | case USB_REQ_SET_CONFIGURATION: | ||
1160 | if (ctrl->bRequestType != 0) | ||
1161 | break; | ||
1162 | if (gadget->a_hnp_support) | ||
1163 | DBG(dev, "HNP available\n"); | ||
1164 | else if (gadget->a_alt_hnp_support) | ||
1165 | DBG(dev, "HNP needs a different root port\n"); | ||
1166 | value = printer_set_config(dev, wValue); | ||
1167 | break; | ||
1168 | case USB_REQ_GET_CONFIGURATION: | ||
1169 | if (ctrl->bRequestType != USB_DIR_IN) | ||
1170 | break; | ||
1171 | *(u8 *)req->buf = dev->config; | ||
1172 | value = min(wLength, (u16) 1); | ||
1173 | break; | ||
1174 | |||
1175 | case USB_REQ_SET_INTERFACE: | ||
1176 | if (ctrl->bRequestType != USB_RECIP_INTERFACE || | ||
1177 | !dev->config) | ||
1178 | break; | ||
1179 | |||
1180 | value = set_interface(dev, PRINTER_INTERFACE); | ||
1181 | break; | ||
1182 | case USB_REQ_GET_INTERFACE: | ||
1183 | if (ctrl->bRequestType != | ||
1184 | (USB_DIR_IN|USB_RECIP_INTERFACE) | ||
1185 | || !dev->config) | ||
1186 | break; | ||
1187 | |||
1188 | *(u8 *)req->buf = dev->interface; | ||
1189 | value = min(wLength, (u16) 1); | ||
1190 | break; | ||
1191 | |||
1192 | default: | ||
1193 | goto unknown; | ||
1194 | } | ||
1195 | break; | ||
1196 | |||
1197 | case USB_TYPE_CLASS: | ||
1198 | switch (ctrl->bRequest) { | ||
1199 | case 0: /* Get the IEEE-1284 PNP String */ | ||
1200 | /* Only one printer interface is supported. */ | ||
1201 | if ((wIndex>>8) != PRINTER_INTERFACE) | ||
1202 | break; | ||
1203 | |||
1204 | value = (pnp_string[0]<<8)|pnp_string[1]; | ||
1205 | memcpy(req->buf, pnp_string, value); | ||
1206 | DBG(dev, "1284 PNP String: %x %s\n", value, | ||
1207 | &pnp_string[2]); | ||
1208 | break; | ||
1209 | |||
1210 | case 1: /* Get Port Status */ | ||
1211 | /* Only one printer interface is supported. */ | ||
1212 | if (wIndex != PRINTER_INTERFACE) | ||
1213 | break; | ||
1214 | |||
1215 | *(u8 *)req->buf = dev->printer_status; | ||
1216 | value = min(wLength, (u16) 1); | ||
1217 | break; | ||
1218 | |||
1219 | case 2: /* Soft Reset */ | ||
1220 | /* Only one printer interface is supported. */ | ||
1221 | if (wIndex != PRINTER_INTERFACE) | ||
1222 | break; | ||
1223 | |||
1224 | printer_soft_reset(dev); | ||
1225 | |||
1226 | value = 0; | ||
1227 | break; | ||
1228 | |||
1229 | default: | ||
1230 | goto unknown; | ||
1231 | } | ||
1232 | break; | ||
1233 | |||
1234 | default: | ||
1235 | unknown: | ||
1236 | VDBG(dev, | ||
1237 | "unknown ctrl req%02x.%02x v%04x i%04x l%d\n", | ||
1238 | ctrl->bRequestType, ctrl->bRequest, | ||
1239 | wValue, wIndex, wLength); | ||
1240 | break; | ||
1241 | } | ||
1242 | |||
1243 | /* respond with data transfer before status phase? */ | ||
1244 | if (value >= 0) { | ||
1245 | req->length = value; | ||
1246 | req->zero = value < wLength | ||
1247 | && (value % gadget->ep0->maxpacket) == 0; | ||
1248 | value = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); | ||
1249 | if (value < 0) { | ||
1250 | DBG(dev, "ep_queue --> %d\n", value); | ||
1251 | req->status = 0; | ||
1252 | printer_setup_complete(gadget->ep0, req); | ||
1253 | } | ||
1254 | } | ||
1255 | |||
1256 | /* host either stalls (value < 0) or reports success */ | ||
1257 | return value; | ||
1258 | } | ||
1259 | |||
1260 | static void | ||
1261 | printer_disconnect(struct usb_gadget *gadget) | ||
1262 | { | ||
1263 | struct printer_dev *dev = get_gadget_data(gadget); | ||
1264 | unsigned long flags; | ||
1265 | |||
1266 | DBG(dev, "%s\n", __FUNCTION__); | ||
1267 | |||
1268 | spin_lock_irqsave(&dev->lock, flags); | ||
1269 | |||
1270 | printer_reset_interface(dev); | ||
1271 | |||
1272 | spin_unlock_irqrestore(&dev->lock, flags); | ||
1273 | } | ||
1274 | |||
1275 | static void | ||
1276 | printer_unbind(struct usb_gadget *gadget) | ||
1277 | { | ||
1278 | struct printer_dev *dev = get_gadget_data(gadget); | ||
1279 | struct usb_request *req; | ||
1280 | |||
1281 | |||
1282 | DBG(dev, "%s\n", __FUNCTION__); | ||
1283 | |||
1284 | /* Remove sysfs files */ | ||
1285 | device_destroy(usb_gadget_class, g_printer_devno); | ||
1286 | |||
1287 | /* Remove Character Device */ | ||
1288 | cdev_del(&dev->printer_cdev); | ||
1289 | |||
1290 | /* we must already have been disconnected ... no i/o may be active */ | ||
1291 | WARN_ON(!list_empty(&dev->tx_reqs_active)); | ||
1292 | WARN_ON(!list_empty(&dev->rx_reqs_active)); | ||
1293 | |||
1294 | /* Free all memory for this driver. */ | ||
1295 | while (!list_empty(&dev->tx_reqs)) { | ||
1296 | req = container_of(dev->tx_reqs.next, struct usb_request, | ||
1297 | list); | ||
1298 | list_del(&req->list); | ||
1299 | printer_req_free(dev->in_ep, req); | ||
1300 | } | ||
1301 | |||
1302 | if (dev->current_rx_req != NULL); | ||
1303 | printer_req_free(dev->out_ep, dev->current_rx_req); | ||
1304 | |||
1305 | while (!list_empty(&dev->rx_reqs)) { | ||
1306 | req = container_of(dev->rx_reqs.next, | ||
1307 | struct usb_request, list); | ||
1308 | list_del(&req->list); | ||
1309 | printer_req_free(dev->out_ep, req); | ||
1310 | } | ||
1311 | |||
1312 | while (!list_empty(&dev->rx_buffers)) { | ||
1313 | req = container_of(dev->rx_buffers.next, | ||
1314 | struct usb_request, list); | ||
1315 | list_del(&req->list); | ||
1316 | printer_req_free(dev->out_ep, req); | ||
1317 | } | ||
1318 | |||
1319 | if (dev->req) { | ||
1320 | printer_req_free(gadget->ep0, dev->req); | ||
1321 | dev->req = NULL; | ||
1322 | } | ||
1323 | |||
1324 | set_gadget_data(gadget, NULL); | ||
1325 | } | ||
1326 | |||
1327 | static int __init | ||
1328 | printer_bind(struct usb_gadget *gadget) | ||
1329 | { | ||
1330 | struct printer_dev *dev; | ||
1331 | struct usb_ep *in_ep, *out_ep; | ||
1332 | int status = -ENOMEM; | ||
1333 | int gcnum; | ||
1334 | size_t len; | ||
1335 | u32 i; | ||
1336 | struct usb_request *req; | ||
1337 | |||
1338 | dev = &usb_printer_gadget; | ||
1339 | |||
1340 | |||
1341 | /* Setup the sysfs files for the printer gadget. */ | ||
1342 | dev->pdev = device_create(usb_gadget_class, NULL, g_printer_devno, | ||
1343 | "g_printer"); | ||
1344 | if (IS_ERR(dev->pdev)) { | ||
1345 | ERROR(dev, "Failed to create device: g_printer\n"); | ||
1346 | goto fail; | ||
1347 | } | ||
1348 | |||
1349 | /* | ||
1350 | * Register a character device as an interface to a user mode | ||
1351 | * program that handles the printer specific functionality. | ||
1352 | */ | ||
1353 | cdev_init(&dev->printer_cdev, &printer_io_operations); | ||
1354 | dev->printer_cdev.owner = THIS_MODULE; | ||
1355 | status = cdev_add(&dev->printer_cdev, g_printer_devno, 1); | ||
1356 | if (status) { | ||
1357 | ERROR(dev, "Failed to open char device\n"); | ||
1358 | goto fail; | ||
1359 | } | ||
1360 | |||
1361 | if (gadget_is_sa1100(gadget)) { | ||
1362 | /* hardware can't write zero length packets. */ | ||
1363 | ERROR(dev, "SA1100 controller is unsupport by this driver\n"); | ||
1364 | goto fail; | ||
1365 | } | ||
1366 | |||
1367 | gcnum = usb_gadget_controller_number(gadget); | ||
1368 | if (gcnum >= 0) { | ||
1369 | device_desc.bcdDevice = cpu_to_le16(0x0200 + gcnum); | ||
1370 | } else { | ||
1371 | dev_warn(&gadget->dev, "controller '%s' not recognized\n", | ||
1372 | gadget->name); | ||
1373 | /* unrecognized, but safe unless bulk is REALLY quirky */ | ||
1374 | device_desc.bcdDevice = | ||
1375 | __constant_cpu_to_le16(0xFFFF); | ||
1376 | } | ||
1377 | snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s", | ||
1378 | init_utsname()->sysname, init_utsname()->release, | ||
1379 | gadget->name); | ||
1380 | |||
1381 | device_desc.idVendor = | ||
1382 | __constant_cpu_to_le16(PRINTER_VENDOR_NUM); | ||
1383 | device_desc.idProduct = | ||
1384 | __constant_cpu_to_le16(PRINTER_PRODUCT_NUM); | ||
1385 | |||
1386 | /* support optional vendor/distro customization */ | ||
1387 | if (idVendor) { | ||
1388 | if (!idProduct) { | ||
1389 | dev_err(&gadget->dev, "idVendor needs idProduct!\n"); | ||
1390 | return -ENODEV; | ||
1391 | } | ||
1392 | device_desc.idVendor = cpu_to_le16(idVendor); | ||
1393 | device_desc.idProduct = cpu_to_le16(idProduct); | ||
1394 | if (bcdDevice) | ||
1395 | device_desc.bcdDevice = cpu_to_le16(bcdDevice); | ||
1396 | } | ||
1397 | |||
1398 | if (iManufacturer) | ||
1399 | strlcpy(manufacturer, iManufacturer, sizeof manufacturer); | ||
1400 | |||
1401 | if (iProduct) | ||
1402 | strlcpy(product_desc, iProduct, sizeof product_desc); | ||
1403 | |||
1404 | if (iSerialNum) | ||
1405 | strlcpy(serial_num, iSerialNum, sizeof serial_num); | ||
1406 | |||
1407 | if (iPNPstring) | ||
1408 | strlcpy(&pnp_string[2], iPNPstring, (sizeof pnp_string)-2); | ||
1409 | |||
1410 | len = strlen(pnp_string); | ||
1411 | pnp_string[0] = (len >> 8) & 0xFF; | ||
1412 | pnp_string[1] = len & 0xFF; | ||
1413 | |||
1414 | /* all we really need is bulk IN/OUT */ | ||
1415 | usb_ep_autoconfig_reset(gadget); | ||
1416 | in_ep = usb_ep_autoconfig(gadget, &fs_ep_in_desc); | ||
1417 | if (!in_ep) { | ||
1418 | autoconf_fail: | ||
1419 | dev_err(&gadget->dev, "can't autoconfigure on %s\n", | ||
1420 | gadget->name); | ||
1421 | return -ENODEV; | ||
1422 | } | ||
1423 | in_ep->driver_data = in_ep; /* claim */ | ||
1424 | |||
1425 | out_ep = usb_ep_autoconfig(gadget, &fs_ep_out_desc); | ||
1426 | if (!out_ep) | ||
1427 | goto autoconf_fail; | ||
1428 | out_ep->driver_data = out_ep; /* claim */ | ||
1429 | |||
1430 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
1431 | /* assumes ep0 uses the same value for both speeds ... */ | ||
1432 | dev_qualifier.bMaxPacketSize0 = device_desc.bMaxPacketSize0; | ||
1433 | |||
1434 | /* and that all endpoints are dual-speed */ | ||
1435 | hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress; | ||
1436 | hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress; | ||
1437 | #endif /* DUALSPEED */ | ||
1438 | |||
1439 | device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket; | ||
1440 | usb_gadget_set_selfpowered(gadget); | ||
1441 | |||
1442 | if (gadget->is_otg) { | ||
1443 | otg_desc.bmAttributes |= USB_OTG_HNP, | ||
1444 | config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP; | ||
1445 | config_desc.bMaxPower = 4; | ||
1446 | } | ||
1447 | |||
1448 | spin_lock_init(&dev->lock); | ||
1449 | spin_lock_init(&dev->lock_printer_io); | ||
1450 | INIT_LIST_HEAD(&dev->tx_reqs); | ||
1451 | INIT_LIST_HEAD(&dev->tx_reqs_active); | ||
1452 | INIT_LIST_HEAD(&dev->rx_reqs); | ||
1453 | INIT_LIST_HEAD(&dev->rx_reqs_active); | ||
1454 | INIT_LIST_HEAD(&dev->rx_buffers); | ||
1455 | init_waitqueue_head(&dev->rx_wait); | ||
1456 | init_waitqueue_head(&dev->tx_wait); | ||
1457 | init_waitqueue_head(&dev->tx_flush_wait); | ||
1458 | |||
1459 | dev->config = 0; | ||
1460 | dev->interface = -1; | ||
1461 | dev->printer_cdev_open = 0; | ||
1462 | dev->printer_status = PRINTER_NOT_ERROR; | ||
1463 | dev->current_rx_req = NULL; | ||
1464 | dev->current_rx_bytes = 0; | ||
1465 | dev->current_rx_buf = NULL; | ||
1466 | |||
1467 | dev->in_ep = in_ep; | ||
1468 | dev->out_ep = out_ep; | ||
1469 | |||
1470 | /* preallocate control message data and buffer */ | ||
1471 | dev->req = printer_req_alloc(gadget->ep0, USB_DESC_BUFSIZE, | ||
1472 | GFP_KERNEL); | ||
1473 | if (!dev->req) { | ||
1474 | status = -ENOMEM; | ||
1475 | goto fail; | ||
1476 | } | ||
1477 | |||
1478 | for (i = 0; i < QLEN; i++) { | ||
1479 | req = printer_req_alloc(dev->in_ep, USB_BUFSIZE, GFP_KERNEL); | ||
1480 | if (!req) { | ||
1481 | while (!list_empty(&dev->tx_reqs)) { | ||
1482 | req = container_of(dev->tx_reqs.next, | ||
1483 | struct usb_request, list); | ||
1484 | list_del(&req->list); | ||
1485 | printer_req_free(dev->in_ep, req); | ||
1486 | } | ||
1487 | return -ENOMEM; | ||
1488 | } | ||
1489 | list_add(&req->list, &dev->tx_reqs); | ||
1490 | } | ||
1491 | |||
1492 | for (i = 0; i < QLEN; i++) { | ||
1493 | req = printer_req_alloc(dev->out_ep, USB_BUFSIZE, GFP_KERNEL); | ||
1494 | if (!req) { | ||
1495 | while (!list_empty(&dev->rx_reqs)) { | ||
1496 | req = container_of(dev->rx_reqs.next, | ||
1497 | struct usb_request, list); | ||
1498 | list_del(&req->list); | ||
1499 | printer_req_free(dev->out_ep, req); | ||
1500 | } | ||
1501 | return -ENOMEM; | ||
1502 | } | ||
1503 | list_add(&req->list, &dev->rx_reqs); | ||
1504 | } | ||
1505 | |||
1506 | dev->req->complete = printer_setup_complete; | ||
1507 | |||
1508 | /* finish hookup to lower layer ... */ | ||
1509 | dev->gadget = gadget; | ||
1510 | set_gadget_data(gadget, dev); | ||
1511 | gadget->ep0->driver_data = dev; | ||
1512 | |||
1513 | INFO(dev, "%s, version: " DRIVER_VERSION "\n", driver_desc); | ||
1514 | INFO(dev, "using %s, OUT %s IN %s\n", gadget->name, out_ep->name, | ||
1515 | in_ep->name); | ||
1516 | |||
1517 | return 0; | ||
1518 | |||
1519 | fail: | ||
1520 | printer_unbind(gadget); | ||
1521 | return status; | ||
1522 | } | ||
1523 | |||
1524 | /*-------------------------------------------------------------------------*/ | ||
1525 | |||
1526 | static struct usb_gadget_driver printer_driver = { | ||
1527 | .speed = DEVSPEED, | ||
1528 | |||
1529 | .function = (char *) driver_desc, | ||
1530 | .bind = printer_bind, | ||
1531 | .unbind = printer_unbind, | ||
1532 | |||
1533 | .setup = printer_setup, | ||
1534 | .disconnect = printer_disconnect, | ||
1535 | |||
1536 | .driver = { | ||
1537 | .name = (char *) shortname, | ||
1538 | .owner = THIS_MODULE, | ||
1539 | }, | ||
1540 | }; | ||
1541 | |||
1542 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
1543 | MODULE_AUTHOR("Craig Nadler"); | ||
1544 | MODULE_LICENSE("GPL"); | ||
1545 | |||
1546 | static int __init | ||
1547 | init(void) | ||
1548 | { | ||
1549 | int status; | ||
1550 | |||
1551 | usb_gadget_class = class_create(THIS_MODULE, "usb_printer_gadget"); | ||
1552 | if (IS_ERR(usb_gadget_class)) { | ||
1553 | status = PTR_ERR(usb_gadget_class); | ||
1554 | ERROR(dev, "unable to create usb_gadget class %d\n", status); | ||
1555 | return status; | ||
1556 | } | ||
1557 | |||
1558 | status = alloc_chrdev_region(&g_printer_devno, 0, 1, | ||
1559 | "USB printer gadget"); | ||
1560 | if (status) { | ||
1561 | ERROR(dev, "alloc_chrdev_region %d\n", status); | ||
1562 | class_destroy(usb_gadget_class); | ||
1563 | return status; | ||
1564 | } | ||
1565 | |||
1566 | status = usb_gadget_register_driver(&printer_driver); | ||
1567 | if (status) { | ||
1568 | class_destroy(usb_gadget_class); | ||
1569 | unregister_chrdev_region(g_printer_devno, 1); | ||
1570 | DBG(dev, "usb_gadget_register_driver %x\n", status); | ||
1571 | } | ||
1572 | |||
1573 | return status; | ||
1574 | } | ||
1575 | module_init(init); | ||
1576 | |||
1577 | static void __exit | ||
1578 | cleanup(void) | ||
1579 | { | ||
1580 | int status; | ||
1581 | |||
1582 | spin_lock(&usb_printer_gadget.lock_printer_io); | ||
1583 | class_destroy(usb_gadget_class); | ||
1584 | unregister_chrdev_region(g_printer_devno, 2); | ||
1585 | |||
1586 | status = usb_gadget_unregister_driver(&printer_driver); | ||
1587 | if (status) | ||
1588 | ERROR(dev, "usb_gadget_unregister_driver %x\n", status); | ||
1589 | |||
1590 | spin_unlock(&usb_printer_gadget.lock_printer_io); | ||
1591 | } | ||
1592 | module_exit(cleanup); | ||
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c index 3173b39f0bfd..4402d6f042d9 100644 --- a/drivers/usb/gadget/pxa2xx_udc.c +++ b/drivers/usb/gadget/pxa2xx_udc.c | |||
@@ -24,7 +24,7 @@ | |||
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | 26 | ||
27 | // #define VERBOSE DBG_VERBOSE | 27 | /* #define VERBOSE_DEBUG */ |
28 | 28 | ||
29 | #include <linux/device.h> | 29 | #include <linux/device.h> |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
@@ -38,13 +38,14 @@ | |||
38 | #include <linux/timer.h> | 38 | #include <linux/timer.h> |
39 | #include <linux/list.h> | 39 | #include <linux/list.h> |
40 | #include <linux/interrupt.h> | 40 | #include <linux/interrupt.h> |
41 | #include <linux/proc_fs.h> | ||
42 | #include <linux/mm.h> | 41 | #include <linux/mm.h> |
43 | #include <linux/platform_device.h> | 42 | #include <linux/platform_device.h> |
44 | #include <linux/dma-mapping.h> | 43 | #include <linux/dma-mapping.h> |
45 | #include <linux/irq.h> | 44 | #include <linux/irq.h> |
46 | #include <linux/clk.h> | 45 | #include <linux/clk.h> |
47 | #include <linux/err.h> | 46 | #include <linux/err.h> |
47 | #include <linux/seq_file.h> | ||
48 | #include <linux/debugfs.h> | ||
48 | 49 | ||
49 | #include <asm/byteorder.h> | 50 | #include <asm/byteorder.h> |
50 | #include <asm/dma.h> | 51 | #include <asm/dma.h> |
@@ -127,8 +128,10 @@ static int is_vbus_present(void) | |||
127 | { | 128 | { |
128 | struct pxa2xx_udc_mach_info *mach = the_controller->mach; | 129 | struct pxa2xx_udc_mach_info *mach = the_controller->mach; |
129 | 130 | ||
130 | if (mach->gpio_vbus) | 131 | if (mach->gpio_vbus) { |
131 | return gpio_get_value(mach->gpio_vbus); | 132 | int value = gpio_get_value(mach->gpio_vbus); |
133 | return mach->gpio_vbus_inverted ? !value : value; | ||
134 | } | ||
132 | if (mach->udc_is_connected) | 135 | if (mach->udc_is_connected) |
133 | return mach->udc_is_connected(); | 136 | return mach->udc_is_connected(); |
134 | return 1; | 137 | return 1; |
@@ -677,7 +680,7 @@ pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
677 | 680 | ||
678 | /* kickstart this i/o queue? */ | 681 | /* kickstart this i/o queue? */ |
679 | if (list_empty(&ep->queue) && !ep->stopped) { | 682 | if (list_empty(&ep->queue) && !ep->stopped) { |
680 | if (ep->desc == 0 /* ep0 */) { | 683 | if (ep->desc == NULL/* ep0 */) { |
681 | unsigned length = _req->length; | 684 | unsigned length = _req->length; |
682 | 685 | ||
683 | switch (dev->ep0state) { | 686 | switch (dev->ep0state) { |
@@ -731,7 +734,7 @@ pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
731 | } | 734 | } |
732 | 735 | ||
733 | /* pio or dma irq handler advances the queue. */ | 736 | /* pio or dma irq handler advances the queue. */ |
734 | if (likely (req != 0)) | 737 | if (likely(req != NULL)) |
735 | list_add_tail(&req->queue, &ep->queue); | 738 | list_add_tail(&req->queue, &ep->queue); |
736 | local_irq_restore(flags); | 739 | local_irq_restore(flags); |
737 | 740 | ||
@@ -991,45 +994,32 @@ static const struct usb_gadget_ops pxa2xx_udc_ops = { | |||
991 | 994 | ||
992 | /*-------------------------------------------------------------------------*/ | 995 | /*-------------------------------------------------------------------------*/ |
993 | 996 | ||
994 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES | 997 | #ifdef CONFIG_USB_GADGET_DEBUG_FS |
995 | |||
996 | static const char proc_node_name [] = "driver/udc"; | ||
997 | 998 | ||
998 | static int | 999 | static int |
999 | udc_proc_read(char *page, char **start, off_t off, int count, | 1000 | udc_seq_show(struct seq_file *m, void *d) |
1000 | int *eof, void *_dev) | ||
1001 | { | 1001 | { |
1002 | char *buf = page; | 1002 | struct pxa2xx_udc *dev = m->private; |
1003 | struct pxa2xx_udc *dev = _dev; | ||
1004 | char *next = buf; | ||
1005 | unsigned size = count; | ||
1006 | unsigned long flags; | 1003 | unsigned long flags; |
1007 | int i, t; | 1004 | int i; |
1008 | u32 tmp; | 1005 | u32 tmp; |
1009 | 1006 | ||
1010 | if (off != 0) | ||
1011 | return 0; | ||
1012 | |||
1013 | local_irq_save(flags); | 1007 | local_irq_save(flags); |
1014 | 1008 | ||
1015 | /* basic device status */ | 1009 | /* basic device status */ |
1016 | t = scnprintf(next, size, DRIVER_DESC "\n" | 1010 | seq_printf(m, DRIVER_DESC "\n" |
1017 | "%s version: %s\nGadget driver: %s\nHost %s\n\n", | 1011 | "%s version: %s\nGadget driver: %s\nHost %s\n\n", |
1018 | driver_name, DRIVER_VERSION SIZE_STR "(pio)", | 1012 | driver_name, DRIVER_VERSION SIZE_STR "(pio)", |
1019 | dev->driver ? dev->driver->driver.name : "(none)", | 1013 | dev->driver ? dev->driver->driver.name : "(none)", |
1020 | is_vbus_present() ? "full speed" : "disconnected"); | 1014 | is_vbus_present() ? "full speed" : "disconnected"); |
1021 | size -= t; | ||
1022 | next += t; | ||
1023 | 1015 | ||
1024 | /* registers for device and ep0 */ | 1016 | /* registers for device and ep0 */ |
1025 | t = scnprintf(next, size, | 1017 | seq_printf(m, |
1026 | "uicr %02X.%02X, usir %02X.%02x, ufnr %02X.%02X\n", | 1018 | "uicr %02X.%02X, usir %02X.%02x, ufnr %02X.%02X\n", |
1027 | UICR1, UICR0, USIR1, USIR0, UFNRH, UFNRL); | 1019 | UICR1, UICR0, USIR1, USIR0, UFNRH, UFNRL); |
1028 | size -= t; | ||
1029 | next += t; | ||
1030 | 1020 | ||
1031 | tmp = UDCCR; | 1021 | tmp = UDCCR; |
1032 | t = scnprintf(next, size, | 1022 | seq_printf(m, |
1033 | "udccr %02X =%s%s%s%s%s%s%s%s\n", tmp, | 1023 | "udccr %02X =%s%s%s%s%s%s%s%s\n", tmp, |
1034 | (tmp & UDCCR_REM) ? " rem" : "", | 1024 | (tmp & UDCCR_REM) ? " rem" : "", |
1035 | (tmp & UDCCR_RSTIR) ? " rstir" : "", | 1025 | (tmp & UDCCR_RSTIR) ? " rstir" : "", |
@@ -1039,11 +1029,9 @@ udc_proc_read(char *page, char **start, off_t off, int count, | |||
1039 | (tmp & UDCCR_RSM) ? " rsm" : "", | 1029 | (tmp & UDCCR_RSM) ? " rsm" : "", |
1040 | (tmp & UDCCR_UDA) ? " uda" : "", | 1030 | (tmp & UDCCR_UDA) ? " uda" : "", |
1041 | (tmp & UDCCR_UDE) ? " ude" : ""); | 1031 | (tmp & UDCCR_UDE) ? " ude" : ""); |
1042 | size -= t; | ||
1043 | next += t; | ||
1044 | 1032 | ||
1045 | tmp = UDCCS0; | 1033 | tmp = UDCCS0; |
1046 | t = scnprintf(next, size, | 1034 | seq_printf(m, |
1047 | "udccs0 %02X =%s%s%s%s%s%s%s%s\n", tmp, | 1035 | "udccs0 %02X =%s%s%s%s%s%s%s%s\n", tmp, |
1048 | (tmp & UDCCS0_SA) ? " sa" : "", | 1036 | (tmp & UDCCS0_SA) ? " sa" : "", |
1049 | (tmp & UDCCS0_RNE) ? " rne" : "", | 1037 | (tmp & UDCCS0_RNE) ? " rne" : "", |
@@ -1053,28 +1041,22 @@ udc_proc_read(char *page, char **start, off_t off, int count, | |||
1053 | (tmp & UDCCS0_FTF) ? " ftf" : "", | 1041 | (tmp & UDCCS0_FTF) ? " ftf" : "", |
1054 | (tmp & UDCCS0_IPR) ? " ipr" : "", | 1042 | (tmp & UDCCS0_IPR) ? " ipr" : "", |
1055 | (tmp & UDCCS0_OPR) ? " opr" : ""); | 1043 | (tmp & UDCCS0_OPR) ? " opr" : ""); |
1056 | size -= t; | ||
1057 | next += t; | ||
1058 | 1044 | ||
1059 | if (dev->has_cfr) { | 1045 | if (dev->has_cfr) { |
1060 | tmp = UDCCFR; | 1046 | tmp = UDCCFR; |
1061 | t = scnprintf(next, size, | 1047 | seq_printf(m, |
1062 | "udccfr %02X =%s%s\n", tmp, | 1048 | "udccfr %02X =%s%s\n", tmp, |
1063 | (tmp & UDCCFR_AREN) ? " aren" : "", | 1049 | (tmp & UDCCFR_AREN) ? " aren" : "", |
1064 | (tmp & UDCCFR_ACM) ? " acm" : ""); | 1050 | (tmp & UDCCFR_ACM) ? " acm" : ""); |
1065 | size -= t; | ||
1066 | next += t; | ||
1067 | } | 1051 | } |
1068 | 1052 | ||
1069 | if (!is_vbus_present() || !dev->driver) | 1053 | if (!is_vbus_present() || !dev->driver) |
1070 | goto done; | 1054 | goto done; |
1071 | 1055 | ||
1072 | t = scnprintf(next, size, "ep0 IN %lu/%lu, OUT %lu/%lu\nirqs %lu\n\n", | 1056 | seq_printf(m, "ep0 IN %lu/%lu, OUT %lu/%lu\nirqs %lu\n\n", |
1073 | dev->stats.write.bytes, dev->stats.write.ops, | 1057 | dev->stats.write.bytes, dev->stats.write.ops, |
1074 | dev->stats.read.bytes, dev->stats.read.ops, | 1058 | dev->stats.read.bytes, dev->stats.read.ops, |
1075 | dev->stats.irqs); | 1059 | dev->stats.irqs); |
1076 | size -= t; | ||
1077 | next += t; | ||
1078 | 1060 | ||
1079 | /* dump endpoint queues */ | 1061 | /* dump endpoint queues */ |
1080 | for (i = 0; i < PXA_UDC_NUM_ENDPOINTS; i++) { | 1062 | for (i = 0; i < PXA_UDC_NUM_ENDPOINTS; i++) { |
@@ -1082,61 +1064,68 @@ udc_proc_read(char *page, char **start, off_t off, int count, | |||
1082 | struct pxa2xx_request *req; | 1064 | struct pxa2xx_request *req; |
1083 | 1065 | ||
1084 | if (i != 0) { | 1066 | if (i != 0) { |
1085 | const struct usb_endpoint_descriptor *d; | 1067 | const struct usb_endpoint_descriptor *desc; |
1086 | 1068 | ||
1087 | d = ep->desc; | 1069 | desc = ep->desc; |
1088 | if (!d) | 1070 | if (!desc) |
1089 | continue; | 1071 | continue; |
1090 | tmp = *dev->ep [i].reg_udccs; | 1072 | tmp = *dev->ep [i].reg_udccs; |
1091 | t = scnprintf(next, size, | 1073 | seq_printf(m, |
1092 | "%s max %d %s udccs %02x irqs %lu\n", | 1074 | "%s max %d %s udccs %02x irqs %lu\n", |
1093 | ep->ep.name, le16_to_cpu (d->wMaxPacketSize), | 1075 | ep->ep.name, le16_to_cpu(desc->wMaxPacketSize), |
1094 | "pio", tmp, ep->pio_irqs); | 1076 | "pio", tmp, ep->pio_irqs); |
1095 | /* TODO translate all five groups of udccs bits! */ | 1077 | /* TODO translate all five groups of udccs bits! */ |
1096 | 1078 | ||
1097 | } else /* ep0 should only have one transfer queued */ | 1079 | } else /* ep0 should only have one transfer queued */ |
1098 | t = scnprintf(next, size, "ep0 max 16 pio irqs %lu\n", | 1080 | seq_printf(m, "ep0 max 16 pio irqs %lu\n", |
1099 | ep->pio_irqs); | 1081 | ep->pio_irqs); |
1100 | if (t <= 0 || t > size) | ||
1101 | goto done; | ||
1102 | size -= t; | ||
1103 | next += t; | ||
1104 | 1082 | ||
1105 | if (list_empty(&ep->queue)) { | 1083 | if (list_empty(&ep->queue)) { |
1106 | t = scnprintf(next, size, "\t(nothing queued)\n"); | 1084 | seq_printf(m, "\t(nothing queued)\n"); |
1107 | if (t <= 0 || t > size) | ||
1108 | goto done; | ||
1109 | size -= t; | ||
1110 | next += t; | ||
1111 | continue; | 1085 | continue; |
1112 | } | 1086 | } |
1113 | list_for_each_entry(req, &ep->queue, queue) { | 1087 | list_for_each_entry(req, &ep->queue, queue) { |
1114 | t = scnprintf(next, size, | 1088 | seq_printf(m, |
1115 | "\treq %p len %d/%d buf %p\n", | 1089 | "\treq %p len %d/%d buf %p\n", |
1116 | &req->req, req->req.actual, | 1090 | &req->req, req->req.actual, |
1117 | req->req.length, req->req.buf); | 1091 | req->req.length, req->req.buf); |
1118 | if (t <= 0 || t > size) | ||
1119 | goto done; | ||
1120 | size -= t; | ||
1121 | next += t; | ||
1122 | } | 1092 | } |
1123 | } | 1093 | } |
1124 | 1094 | ||
1125 | done: | 1095 | done: |
1126 | local_irq_restore(flags); | 1096 | local_irq_restore(flags); |
1127 | *eof = 1; | 1097 | return 0; |
1128 | return count - size; | ||
1129 | } | 1098 | } |
1130 | 1099 | ||
1131 | #define create_proc_files() \ | 1100 | static int |
1132 | create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev) | 1101 | udc_debugfs_open(struct inode *inode, struct file *file) |
1133 | #define remove_proc_files() \ | 1102 | { |
1134 | remove_proc_entry(proc_node_name, NULL) | 1103 | return single_open(file, udc_seq_show, inode->i_private); |
1104 | } | ||
1105 | |||
1106 | static const struct file_operations debug_fops = { | ||
1107 | .open = udc_debugfs_open, | ||
1108 | .read = seq_read, | ||
1109 | .llseek = seq_lseek, | ||
1110 | .release = single_release, | ||
1111 | .owner = THIS_MODULE, | ||
1112 | }; | ||
1113 | |||
1114 | #define create_debug_files(dev) \ | ||
1115 | do { \ | ||
1116 | dev->debugfs_udc = debugfs_create_file(dev->gadget.name, \ | ||
1117 | S_IRUGO, NULL, dev, &debug_fops); \ | ||
1118 | } while (0) | ||
1119 | #define remove_debug_files(dev) \ | ||
1120 | do { \ | ||
1121 | if (dev->debugfs_udc) \ | ||
1122 | debugfs_remove(dev->debugfs_udc); \ | ||
1123 | } while (0) | ||
1135 | 1124 | ||
1136 | #else /* !CONFIG_USB_GADGET_DEBUG_FILES */ | 1125 | #else /* !CONFIG_USB_GADGET_DEBUG_FILES */ |
1137 | 1126 | ||
1138 | #define create_proc_files() do {} while (0) | 1127 | #define create_debug_files(dev) do {} while (0) |
1139 | #define remove_proc_files() do {} while (0) | 1128 | #define remove_debug_files(dev) do {} while (0) |
1140 | 1129 | ||
1141 | #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ | 1130 | #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ |
1142 | 1131 | ||
@@ -1345,6 +1334,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
1345 | local_irq_enable(); | 1334 | local_irq_enable(); |
1346 | 1335 | ||
1347 | driver->unbind(&dev->gadget); | 1336 | driver->unbind(&dev->gadget); |
1337 | dev->gadget.dev.driver = NULL; | ||
1348 | dev->driver = NULL; | 1338 | dev->driver = NULL; |
1349 | 1339 | ||
1350 | device_del (&dev->gadget.dev); | 1340 | device_del (&dev->gadget.dev); |
@@ -1397,6 +1387,9 @@ static irqreturn_t udc_vbus_irq(int irq, void *_dev) | |||
1397 | struct pxa2xx_udc *dev = _dev; | 1387 | struct pxa2xx_udc *dev = _dev; |
1398 | int vbus = gpio_get_value(dev->mach->gpio_vbus); | 1388 | int vbus = gpio_get_value(dev->mach->gpio_vbus); |
1399 | 1389 | ||
1390 | if (dev->mach->gpio_vbus_inverted) | ||
1391 | vbus = !vbus; | ||
1392 | |||
1400 | pxa2xx_udc_vbus_session(&dev->gadget, vbus); | 1393 | pxa2xx_udc_vbus_session(&dev->gadget, vbus); |
1401 | return IRQ_HANDLED; | 1394 | return IRQ_HANDLED; |
1402 | } | 1395 | } |
@@ -2099,7 +2092,7 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev) | |||
2099 | /* insist on Intel/ARM/XScale */ | 2092 | /* insist on Intel/ARM/XScale */ |
2100 | asm("mrc%? p15, 0, %0, c0, c0" : "=r" (chiprev)); | 2093 | asm("mrc%? p15, 0, %0, c0, c0" : "=r" (chiprev)); |
2101 | if ((chiprev & CP15R0_VENDOR_MASK) != CP15R0_XSCALE_VALUE) { | 2094 | if ((chiprev & CP15R0_VENDOR_MASK) != CP15R0_XSCALE_VALUE) { |
2102 | printk(KERN_ERR "%s: not XScale!\n", driver_name); | 2095 | pr_err("%s: not XScale!\n", driver_name); |
2103 | return -ENODEV; | 2096 | return -ENODEV; |
2104 | } | 2097 | } |
2105 | 2098 | ||
@@ -2128,7 +2121,7 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev) | |||
2128 | break; | 2121 | break; |
2129 | #endif | 2122 | #endif |
2130 | default: | 2123 | default: |
2131 | printk(KERN_ERR "%s: unrecognized processor: %08x\n", | 2124 | pr_err("%s: unrecognized processor: %08x\n", |
2132 | driver_name, chiprev); | 2125 | driver_name, chiprev); |
2133 | /* iop3xx, ixp4xx, ... */ | 2126 | /* iop3xx, ixp4xx, ... */ |
2134 | return -ENODEV; | 2127 | return -ENODEV; |
@@ -2199,7 +2192,7 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev) | |||
2199 | retval = request_irq(irq, pxa2xx_udc_irq, | 2192 | retval = request_irq(irq, pxa2xx_udc_irq, |
2200 | IRQF_DISABLED, driver_name, dev); | 2193 | IRQF_DISABLED, driver_name, dev); |
2201 | if (retval != 0) { | 2194 | if (retval != 0) { |
2202 | printk(KERN_ERR "%s: can't get irq %d, err %d\n", | 2195 | pr_err("%s: can't get irq %d, err %d\n", |
2203 | driver_name, irq, retval); | 2196 | driver_name, irq, retval); |
2204 | goto err_irq1; | 2197 | goto err_irq1; |
2205 | } | 2198 | } |
@@ -2212,7 +2205,7 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev) | |||
2212 | IRQF_DISABLED | IRQF_SAMPLE_RANDOM, | 2205 | IRQF_DISABLED | IRQF_SAMPLE_RANDOM, |
2213 | driver_name, dev); | 2206 | driver_name, dev); |
2214 | if (retval != 0) { | 2207 | if (retval != 0) { |
2215 | printk(KERN_ERR "%s: can't get irq %i, err %d\n", | 2208 | pr_err("%s: can't get irq %i, err %d\n", |
2216 | driver_name, LUBBOCK_USB_DISC_IRQ, retval); | 2209 | driver_name, LUBBOCK_USB_DISC_IRQ, retval); |
2217 | lubbock_fail0: | 2210 | lubbock_fail0: |
2218 | goto err_irq_lub; | 2211 | goto err_irq_lub; |
@@ -2222,7 +2215,7 @@ lubbock_fail0: | |||
2222 | IRQF_DISABLED | IRQF_SAMPLE_RANDOM, | 2215 | IRQF_DISABLED | IRQF_SAMPLE_RANDOM, |
2223 | driver_name, dev); | 2216 | driver_name, dev); |
2224 | if (retval != 0) { | 2217 | if (retval != 0) { |
2225 | printk(KERN_ERR "%s: can't get irq %i, err %d\n", | 2218 | pr_err("%s: can't get irq %i, err %d\n", |
2226 | driver_name, LUBBOCK_USB_IRQ, retval); | 2219 | driver_name, LUBBOCK_USB_IRQ, retval); |
2227 | free_irq(LUBBOCK_USB_DISC_IRQ, dev); | 2220 | free_irq(LUBBOCK_USB_DISC_IRQ, dev); |
2228 | goto lubbock_fail0; | 2221 | goto lubbock_fail0; |
@@ -2235,12 +2228,12 @@ lubbock_fail0: | |||
2235 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | 2228 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
2236 | driver_name, dev); | 2229 | driver_name, dev); |
2237 | if (retval != 0) { | 2230 | if (retval != 0) { |
2238 | printk(KERN_ERR "%s: can't get irq %i, err %d\n", | 2231 | pr_err("%s: can't get irq %i, err %d\n", |
2239 | driver_name, vbus_irq, retval); | 2232 | driver_name, vbus_irq, retval); |
2240 | goto err_vbus_irq; | 2233 | goto err_vbus_irq; |
2241 | } | 2234 | } |
2242 | } | 2235 | } |
2243 | create_proc_files(); | 2236 | create_debug_files(dev); |
2244 | 2237 | ||
2245 | return 0; | 2238 | return 0; |
2246 | 2239 | ||
@@ -2277,7 +2270,7 @@ static int __exit pxa2xx_udc_remove(struct platform_device *pdev) | |||
2277 | return -EBUSY; | 2270 | return -EBUSY; |
2278 | 2271 | ||
2279 | udc_disable(dev); | 2272 | udc_disable(dev); |
2280 | remove_proc_files(); | 2273 | remove_debug_files(dev); |
2281 | 2274 | ||
2282 | if (dev->got_irq) { | 2275 | if (dev->got_irq) { |
2283 | free_irq(platform_get_irq(pdev, 0), dev); | 2276 | free_irq(platform_get_irq(pdev, 0), dev); |
@@ -2361,7 +2354,7 @@ static struct platform_driver udc_driver = { | |||
2361 | 2354 | ||
2362 | static int __init udc_init(void) | 2355 | static int __init udc_init(void) |
2363 | { | 2356 | { |
2364 | printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION); | 2357 | pr_info("%s: version %s\n", driver_name, DRIVER_VERSION); |
2365 | return platform_driver_probe(&udc_driver, pxa2xx_udc_probe); | 2358 | return platform_driver_probe(&udc_driver, pxa2xx_udc_probe); |
2366 | } | 2359 | } |
2367 | module_init(udc_init); | 2360 | module_init(udc_init); |
diff --git a/drivers/usb/gadget/pxa2xx_udc.h b/drivers/usb/gadget/pxa2xx_udc.h index 1db46d705777..b67e3ff5e4eb 100644 --- a/drivers/usb/gadget/pxa2xx_udc.h +++ b/drivers/usb/gadget/pxa2xx_udc.h | |||
@@ -129,6 +129,10 @@ struct pxa2xx_udc { | |||
129 | struct pxa2xx_udc_mach_info *mach; | 129 | struct pxa2xx_udc_mach_info *mach; |
130 | u64 dma_mask; | 130 | u64 dma_mask; |
131 | struct pxa2xx_ep ep [PXA_UDC_NUM_ENDPOINTS]; | 131 | struct pxa2xx_ep ep [PXA_UDC_NUM_ENDPOINTS]; |
132 | |||
133 | #ifdef CONFIG_USB_GADGET_DEBUG_FS | ||
134 | struct dentry *debugfs_udc; | ||
135 | #endif | ||
132 | }; | 136 | }; |
133 | 137 | ||
134 | /*-------------------------------------------------------------------------*/ | 138 | /*-------------------------------------------------------------------------*/ |
@@ -151,17 +155,19 @@ static struct pxa2xx_udc *the_controller; | |||
151 | #define DBG_NOISY 3 /* ... even more: request level */ | 155 | #define DBG_NOISY 3 /* ... even more: request level */ |
152 | #define DBG_VERY_NOISY 4 /* ... even more: packet level */ | 156 | #define DBG_VERY_NOISY 4 /* ... even more: packet level */ |
153 | 157 | ||
158 | #define DMSG(stuff...) pr_debug("udc: " stuff) | ||
159 | |||
154 | #ifdef DEBUG | 160 | #ifdef DEBUG |
155 | 161 | ||
162 | static int is_vbus_present(void); | ||
163 | |||
156 | static const char *state_name[] = { | 164 | static const char *state_name[] = { |
157 | "EP0_IDLE", | 165 | "EP0_IDLE", |
158 | "EP0_IN_DATA_PHASE", "EP0_OUT_DATA_PHASE", | 166 | "EP0_IN_DATA_PHASE", "EP0_OUT_DATA_PHASE", |
159 | "EP0_END_XFER", "EP0_STALL" | 167 | "EP0_END_XFER", "EP0_STALL" |
160 | }; | 168 | }; |
161 | 169 | ||
162 | #define DMSG(stuff...) printk(KERN_DEBUG "udc: " stuff) | 170 | #ifdef VERBOSE_DEBUG |
163 | |||
164 | #ifdef VERBOSE | ||
165 | # define UDC_DEBUG DBG_VERBOSE | 171 | # define UDC_DEBUG DBG_VERBOSE |
166 | #else | 172 | #else |
167 | # define UDC_DEBUG DBG_NORMAL | 173 | # define UDC_DEBUG DBG_NORMAL |
@@ -207,7 +213,7 @@ dump_state(struct pxa2xx_udc *dev) | |||
207 | unsigned i; | 213 | unsigned i; |
208 | 214 | ||
209 | DMSG("%s %s, uicr %02X.%02X, usir %02X.%02x, ufnr %02X.%02X\n", | 215 | DMSG("%s %s, uicr %02X.%02X, usir %02X.%02x, ufnr %02X.%02X\n", |
210 | is_usb_connected() ? "host " : "disconnected", | 216 | is_vbus_present() ? "host " : "disconnected", |
211 | state_name[dev->ep0state], | 217 | state_name[dev->ep0state], |
212 | UICR1, UICR0, USIR1, USIR0, UFNRH, UFNRL); | 218 | UICR1, UICR0, USIR1, USIR0, UFNRH, UFNRL); |
213 | dump_udccr("udccr"); | 219 | dump_udccr("udccr"); |
@@ -224,7 +230,7 @@ dump_state(struct pxa2xx_udc *dev) | |||
224 | } else | 230 | } else |
225 | DMSG("ep0 driver '%s'\n", dev->driver->driver.name); | 231 | DMSG("ep0 driver '%s'\n", dev->driver->driver.name); |
226 | 232 | ||
227 | if (!is_usb_connected()) | 233 | if (!is_vbus_present()) |
228 | return; | 234 | return; |
229 | 235 | ||
230 | dump_udccs0 ("udccs0"); | 236 | dump_udccs0 ("udccs0"); |
@@ -233,7 +239,7 @@ dump_state(struct pxa2xx_udc *dev) | |||
233 | dev->stats.read.bytes, dev->stats.read.ops); | 239 | dev->stats.read.bytes, dev->stats.read.ops); |
234 | 240 | ||
235 | for (i = 1; i < PXA_UDC_NUM_ENDPOINTS; i++) { | 241 | for (i = 1; i < PXA_UDC_NUM_ENDPOINTS; i++) { |
236 | if (dev->ep [i].desc == 0) | 242 | if (dev->ep [i].desc == NULL) |
237 | continue; | 243 | continue; |
238 | DMSG ("udccs%d = %02x\n", i, *dev->ep->reg_udccs); | 244 | DMSG ("udccs%d = %02x\n", i, *dev->ep->reg_udccs); |
239 | } | 245 | } |
@@ -241,8 +247,6 @@ dump_state(struct pxa2xx_udc *dev) | |||
241 | 247 | ||
242 | #else | 248 | #else |
243 | 249 | ||
244 | #define DMSG(stuff...) do{}while(0) | ||
245 | |||
246 | #define dump_udccr(x) do{}while(0) | 250 | #define dump_udccr(x) do{}while(0) |
247 | #define dump_udccs0(x) do{}while(0) | 251 | #define dump_udccs0(x) do{}while(0) |
248 | #define dump_state(x) do{}while(0) | 252 | #define dump_state(x) do{}while(0) |
@@ -253,8 +257,9 @@ dump_state(struct pxa2xx_udc *dev) | |||
253 | 257 | ||
254 | #define DBG(lvl, stuff...) do{if ((lvl) <= UDC_DEBUG) DMSG(stuff);}while(0) | 258 | #define DBG(lvl, stuff...) do{if ((lvl) <= UDC_DEBUG) DMSG(stuff);}while(0) |
255 | 259 | ||
256 | #define WARN(stuff...) printk(KERN_WARNING "udc: " stuff) | 260 | #define ERR(stuff...) pr_err("udc: " stuff) |
257 | #define INFO(stuff...) printk(KERN_INFO "udc: " stuff) | 261 | #define WARN(stuff...) pr_warning("udc: " stuff) |
262 | #define INFO(stuff...) pr_info("udc: " stuff) | ||
258 | 263 | ||
259 | 264 | ||
260 | #endif /* __LINUX_USB_GADGET_PXA2XX_H */ | 265 | #endif /* __LINUX_USB_GADGET_PXA2XX_H */ |
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index db1b2bfcee4e..3d036647431f 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c | |||
@@ -53,21 +53,18 @@ | |||
53 | */ | 53 | */ |
54 | 54 | ||
55 | #if 0 | 55 | #if 0 |
56 | #define DBG(str,args...) do { \ | ||
57 | if (rndis_debug) \ | ||
58 | printk(KERN_DEBUG str , ## args ); \ | ||
59 | } while (0) | ||
60 | static int rndis_debug = 0; | 56 | static int rndis_debug = 0; |
61 | |||
62 | module_param (rndis_debug, int, 0); | 57 | module_param (rndis_debug, int, 0); |
63 | MODULE_PARM_DESC (rndis_debug, "enable debugging"); | 58 | MODULE_PARM_DESC (rndis_debug, "enable debugging"); |
64 | |||
65 | #else | 59 | #else |
66 | |||
67 | #define rndis_debug 0 | 60 | #define rndis_debug 0 |
68 | #define DBG(str,args...) do{}while(0) | ||
69 | #endif | 61 | #endif |
70 | 62 | ||
63 | #define DBG(str,args...) do { \ | ||
64 | if (rndis_debug) \ | ||
65 | pr_debug(str , ## args); \ | ||
66 | } while (0) | ||
67 | |||
71 | #define RNDIS_MAX_CONFIGS 1 | 68 | #define RNDIS_MAX_CONFIGS 1 |
72 | 69 | ||
73 | 70 | ||
@@ -679,7 +676,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
679 | #endif | 676 | #endif |
680 | 677 | ||
681 | default: | 678 | default: |
682 | printk (KERN_WARNING "%s: query unknown OID 0x%08X\n", | 679 | pr_warning("%s: query unknown OID 0x%08X\n", |
683 | __FUNCTION__, OID); | 680 | __FUNCTION__, OID); |
684 | } | 681 | } |
685 | if (retval < 0) | 682 | if (retval < 0) |
@@ -804,7 +801,7 @@ update_linkstate: | |||
804 | #endif /* RNDIS_PM */ | 801 | #endif /* RNDIS_PM */ |
805 | 802 | ||
806 | default: | 803 | default: |
807 | printk (KERN_WARNING "%s: set unknown OID 0x%08X, size %d\n", | 804 | pr_warning("%s: set unknown OID 0x%08X, size %d\n", |
808 | __FUNCTION__, OID, buf_len); | 805 | __FUNCTION__, OID, buf_len); |
809 | } | 806 | } |
810 | 807 | ||
@@ -1126,8 +1123,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf) | |||
1126 | * In one case those messages seemed to relate to the host | 1123 | * In one case those messages seemed to relate to the host |
1127 | * suspending itself. | 1124 | * suspending itself. |
1128 | */ | 1125 | */ |
1129 | printk (KERN_WARNING | 1126 | pr_warning("%s: unknown RNDIS message 0x%08X len %d\n", |
1130 | "%s: unknown RNDIS message 0x%08X len %d\n", | ||
1131 | __FUNCTION__ , MsgType, MsgLength); | 1127 | __FUNCTION__ , MsgType, MsgLength); |
1132 | { | 1128 | { |
1133 | unsigned i; | 1129 | unsigned i; |
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c index 4ce050c3d13f..aadc4204d6f9 100644 --- a/drivers/usb/gadget/s3c2410_udc.c +++ b/drivers/usb/gadget/s3c2410_udc.c | |||
@@ -893,7 +893,7 @@ static void s3c2410_udc_handle_ep(struct s3c2410_ep *ep) | |||
893 | /* | 893 | /* |
894 | * s3c2410_udc_irq - interrupt handler | 894 | * s3c2410_udc_irq - interrupt handler |
895 | */ | 895 | */ |
896 | static irqreturn_t s3c2410_udc_irq(int irq, void *_dev) | 896 | static irqreturn_t s3c2410_udc_irq(int dummy, void *_dev) |
897 | { | 897 | { |
898 | struct s3c2410_udc *dev = _dev; | 898 | struct s3c2410_udc *dev = _dev; |
899 | int usb_status; | 899 | int usb_status; |
@@ -1016,7 +1016,7 @@ static irqreturn_t s3c2410_udc_irq(int irq, void *_dev) | |||
1016 | } | 1016 | } |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | dprintk(DEBUG_VERBOSE, "irq: %d s3c2410_udc_done.\n", irq); | 1019 | dprintk(DEBUG_VERBOSE, "irq: %d s3c2410_udc_done.\n", IRQ_USBD); |
1020 | 1020 | ||
1021 | /* Restore old index */ | 1021 | /* Restore old index */ |
1022 | udc_write(idx, S3C2410_UDC_INDEX_REG); | 1022 | udc_write(idx, S3C2410_UDC_INDEX_REG); |
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index f5738eb8e765..f5c3896b1d95 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -89,9 +89,9 @@ static int debug = 1; | |||
89 | #endif | 89 | #endif |
90 | 90 | ||
91 | #define gs_debug(format, arg...) \ | 91 | #define gs_debug(format, arg...) \ |
92 | do { if (debug) printk(KERN_DEBUG format, ## arg); } while(0) | 92 | do { if (debug) pr_debug(format, ## arg); } while (0) |
93 | #define gs_debug_level(level, format, arg...) \ | 93 | #define gs_debug_level(level, format, arg...) \ |
94 | do { if (debug>=level) printk(KERN_DEBUG format, ## arg); } while(0) | 94 | do { if (debug >= level) pr_debug(format, ## arg); } while (0) |
95 | 95 | ||
96 | 96 | ||
97 | /* Thanks to NetChip Technologies for donating this product ID. | 97 | /* Thanks to NetChip Technologies for donating this product ID. |
@@ -553,7 +553,8 @@ static int __init gs_module_init(void) | |||
553 | 553 | ||
554 | retval = usb_gadget_register_driver(&gs_gadget_driver); | 554 | retval = usb_gadget_register_driver(&gs_gadget_driver); |
555 | if (retval) { | 555 | if (retval) { |
556 | printk(KERN_ERR "gs_module_init: cannot register gadget driver, ret=%d\n", retval); | 556 | pr_err("gs_module_init: cannot register gadget driver, " |
557 | "ret=%d\n", retval); | ||
557 | return retval; | 558 | return retval; |
558 | } | 559 | } |
559 | 560 | ||
@@ -579,11 +580,13 @@ static int __init gs_module_init(void) | |||
579 | if (retval) { | 580 | if (retval) { |
580 | usb_gadget_unregister_driver(&gs_gadget_driver); | 581 | usb_gadget_unregister_driver(&gs_gadget_driver); |
581 | put_tty_driver(gs_tty_driver); | 582 | put_tty_driver(gs_tty_driver); |
582 | printk(KERN_ERR "gs_module_init: cannot register tty driver, ret=%d\n", retval); | 583 | pr_err("gs_module_init: cannot register tty driver, " |
584 | "ret=%d\n", retval); | ||
583 | return retval; | 585 | return retval; |
584 | } | 586 | } |
585 | 587 | ||
586 | printk(KERN_INFO "gs_module_init: %s %s loaded\n", GS_LONG_NAME, GS_VERSION_STR); | 588 | pr_info("gs_module_init: %s %s loaded\n", |
589 | GS_LONG_NAME, GS_VERSION_STR); | ||
587 | return 0; | 590 | return 0; |
588 | } | 591 | } |
589 | 592 | ||
@@ -598,7 +601,8 @@ static void __exit gs_module_exit(void) | |||
598 | put_tty_driver(gs_tty_driver); | 601 | put_tty_driver(gs_tty_driver); |
599 | usb_gadget_unregister_driver(&gs_gadget_driver); | 602 | usb_gadget_unregister_driver(&gs_gadget_driver); |
600 | 603 | ||
601 | printk(KERN_INFO "gs_module_exit: %s %s unloaded\n", GS_LONG_NAME, GS_VERSION_STR); | 604 | pr_info("gs_module_exit: %s %s unloaded\n", |
605 | GS_LONG_NAME, GS_VERSION_STR); | ||
602 | } | 606 | } |
603 | 607 | ||
604 | /* TTY Driver */ | 608 | /* TTY Driver */ |
@@ -621,7 +625,7 @@ static int gs_open(struct tty_struct *tty, struct file *file) | |||
621 | gs_debug("gs_open: (%d,%p,%p)\n", port_num, tty, file); | 625 | gs_debug("gs_open: (%d,%p,%p)\n", port_num, tty, file); |
622 | 626 | ||
623 | if (port_num < 0 || port_num >= GS_NUM_PORTS) { | 627 | if (port_num < 0 || port_num >= GS_NUM_PORTS) { |
624 | printk(KERN_ERR "gs_open: (%d,%p,%p) invalid port number\n", | 628 | pr_err("gs_open: (%d,%p,%p) invalid port number\n", |
625 | port_num, tty, file); | 629 | port_num, tty, file); |
626 | return -ENODEV; | 630 | return -ENODEV; |
627 | } | 631 | } |
@@ -629,15 +633,14 @@ static int gs_open(struct tty_struct *tty, struct file *file) | |||
629 | dev = gs_device; | 633 | dev = gs_device; |
630 | 634 | ||
631 | if (dev == NULL) { | 635 | if (dev == NULL) { |
632 | printk(KERN_ERR "gs_open: (%d,%p,%p) NULL device pointer\n", | 636 | pr_err("gs_open: (%d,%p,%p) NULL device pointer\n", |
633 | port_num, tty, file); | 637 | port_num, tty, file); |
634 | return -ENODEV; | 638 | return -ENODEV; |
635 | } | 639 | } |
636 | 640 | ||
637 | mtx = &gs_open_close_lock[port_num]; | 641 | mtx = &gs_open_close_lock[port_num]; |
638 | if (mutex_lock_interruptible(mtx)) { | 642 | if (mutex_lock_interruptible(mtx)) { |
639 | printk(KERN_ERR | 643 | pr_err("gs_open: (%d,%p,%p) interrupted waiting for mutex\n", |
640 | "gs_open: (%d,%p,%p) interrupted waiting for mutex\n", | ||
641 | port_num, tty, file); | 644 | port_num, tty, file); |
642 | return -ERESTARTSYS; | 645 | return -ERESTARTSYS; |
643 | } | 646 | } |
@@ -645,8 +648,7 @@ static int gs_open(struct tty_struct *tty, struct file *file) | |||
645 | spin_lock_irqsave(&dev->dev_lock, flags); | 648 | spin_lock_irqsave(&dev->dev_lock, flags); |
646 | 649 | ||
647 | if (dev->dev_config == GS_NO_CONFIG_ID) { | 650 | if (dev->dev_config == GS_NO_CONFIG_ID) { |
648 | printk(KERN_ERR | 651 | pr_err("gs_open: (%d,%p,%p) device is not connected\n", |
649 | "gs_open: (%d,%p,%p) device is not connected\n", | ||
650 | port_num, tty, file); | 652 | port_num, tty, file); |
651 | ret = -ENODEV; | 653 | ret = -ENODEV; |
652 | goto exit_unlock_dev; | 654 | goto exit_unlock_dev; |
@@ -655,7 +657,7 @@ static int gs_open(struct tty_struct *tty, struct file *file) | |||
655 | port = dev->dev_port[port_num]; | 657 | port = dev->dev_port[port_num]; |
656 | 658 | ||
657 | if (port == NULL) { | 659 | if (port == NULL) { |
658 | printk(KERN_ERR "gs_open: (%d,%p,%p) NULL port pointer\n", | 660 | pr_err("gs_open: (%d,%p,%p) NULL port pointer\n", |
659 | port_num, tty, file); | 661 | port_num, tty, file); |
660 | ret = -ENODEV; | 662 | ret = -ENODEV; |
661 | goto exit_unlock_dev; | 663 | goto exit_unlock_dev; |
@@ -665,7 +667,7 @@ static int gs_open(struct tty_struct *tty, struct file *file) | |||
665 | spin_unlock(&dev->dev_lock); | 667 | spin_unlock(&dev->dev_lock); |
666 | 668 | ||
667 | if (port->port_dev == NULL) { | 669 | if (port->port_dev == NULL) { |
668 | printk(KERN_ERR "gs_open: (%d,%p,%p) port disconnected (1)\n", | 670 | pr_err("gs_open: (%d,%p,%p) port disconnected (1)\n", |
669 | port_num, tty, file); | 671 | port_num, tty, file); |
670 | ret = -EIO; | 672 | ret = -EIO; |
671 | goto exit_unlock_port; | 673 | goto exit_unlock_port; |
@@ -692,8 +694,7 @@ static int gs_open(struct tty_struct *tty, struct file *file) | |||
692 | 694 | ||
693 | /* might have been disconnected while asleep, check */ | 695 | /* might have been disconnected while asleep, check */ |
694 | if (port->port_dev == NULL) { | 696 | if (port->port_dev == NULL) { |
695 | printk(KERN_ERR | 697 | pr_err("gs_open: (%d,%p,%p) port disconnected (2)\n", |
696 | "gs_open: (%d,%p,%p) port disconnected (2)\n", | ||
697 | port_num, tty, file); | 698 | port_num, tty, file); |
698 | port->port_in_use = 0; | 699 | port->port_in_use = 0; |
699 | ret = -EIO; | 700 | ret = -EIO; |
@@ -701,7 +702,8 @@ static int gs_open(struct tty_struct *tty, struct file *file) | |||
701 | } | 702 | } |
702 | 703 | ||
703 | if ((port->port_write_buf=buf) == NULL) { | 704 | if ((port->port_write_buf=buf) == NULL) { |
704 | printk(KERN_ERR "gs_open: (%d,%p,%p) cannot allocate port write buffer\n", | 705 | pr_err("gs_open: (%d,%p,%p) cannot allocate " |
706 | "port write buffer\n", | ||
705 | port_num, tty, file); | 707 | port_num, tty, file); |
706 | port->port_in_use = 0; | 708 | port->port_in_use = 0; |
707 | ret = -ENOMEM; | 709 | ret = -ENOMEM; |
@@ -714,7 +716,7 @@ static int gs_open(struct tty_struct *tty, struct file *file) | |||
714 | 716 | ||
715 | /* might have been disconnected while asleep, check */ | 717 | /* might have been disconnected while asleep, check */ |
716 | if (port->port_dev == NULL) { | 718 | if (port->port_dev == NULL) { |
717 | printk(KERN_ERR "gs_open: (%d,%p,%p) port disconnected (3)\n", | 719 | pr_err("gs_open: (%d,%p,%p) port disconnected (3)\n", |
718 | port_num, tty, file); | 720 | port_num, tty, file); |
719 | port->port_in_use = 0; | 721 | port->port_in_use = 0; |
720 | ret = -EIO; | 722 | ret = -EIO; |
@@ -762,7 +764,7 @@ static void gs_close(struct tty_struct *tty, struct file *file) | |||
762 | struct mutex *mtx; | 764 | struct mutex *mtx; |
763 | 765 | ||
764 | if (port == NULL) { | 766 | if (port == NULL) { |
765 | printk(KERN_ERR "gs_close: NULL port pointer\n"); | 767 | pr_err("gs_close: NULL port pointer\n"); |
766 | return; | 768 | return; |
767 | } | 769 | } |
768 | 770 | ||
@@ -774,8 +776,7 @@ static void gs_close(struct tty_struct *tty, struct file *file) | |||
774 | spin_lock_irq(&port->port_lock); | 776 | spin_lock_irq(&port->port_lock); |
775 | 777 | ||
776 | if (port->port_open_count == 0) { | 778 | if (port->port_open_count == 0) { |
777 | printk(KERN_ERR | 779 | pr_err("gs_close: (%d,%p,%p) port is already closed\n", |
778 | "gs_close: (%d,%p,%p) port is already closed\n", | ||
779 | port->port_num, tty, file); | 780 | port->port_num, tty, file); |
780 | goto exit; | 781 | goto exit; |
781 | } | 782 | } |
@@ -837,7 +838,7 @@ static int gs_write(struct tty_struct *tty, const unsigned char *buf, int count) | |||
837 | int ret; | 838 | int ret; |
838 | 839 | ||
839 | if (port == NULL) { | 840 | if (port == NULL) { |
840 | printk(KERN_ERR "gs_write: NULL port pointer\n"); | 841 | pr_err("gs_write: NULL port pointer\n"); |
841 | return -EIO; | 842 | return -EIO; |
842 | } | 843 | } |
843 | 844 | ||
@@ -850,14 +851,14 @@ static int gs_write(struct tty_struct *tty, const unsigned char *buf, int count) | |||
850 | spin_lock_irqsave(&port->port_lock, flags); | 851 | spin_lock_irqsave(&port->port_lock, flags); |
851 | 852 | ||
852 | if (port->port_dev == NULL) { | 853 | if (port->port_dev == NULL) { |
853 | printk(KERN_ERR "gs_write: (%d,%p) port is not connected\n", | 854 | pr_err("gs_write: (%d,%p) port is not connected\n", |
854 | port->port_num, tty); | 855 | port->port_num, tty); |
855 | ret = -EIO; | 856 | ret = -EIO; |
856 | goto exit; | 857 | goto exit; |
857 | } | 858 | } |
858 | 859 | ||
859 | if (port->port_open_count == 0) { | 860 | if (port->port_open_count == 0) { |
860 | printk(KERN_ERR "gs_write: (%d,%p) port is closed\n", | 861 | pr_err("gs_write: (%d,%p) port is closed\n", |
861 | port->port_num, tty); | 862 | port->port_num, tty); |
862 | ret = -EBADF; | 863 | ret = -EBADF; |
863 | goto exit; | 864 | goto exit; |
@@ -888,7 +889,7 @@ static void gs_put_char(struct tty_struct *tty, unsigned char ch) | |||
888 | struct gs_port *port = tty->driver_data; | 889 | struct gs_port *port = tty->driver_data; |
889 | 890 | ||
890 | if (port == NULL) { | 891 | if (port == NULL) { |
891 | printk(KERN_ERR "gs_put_char: NULL port pointer\n"); | 892 | pr_err("gs_put_char: NULL port pointer\n"); |
892 | return; | 893 | return; |
893 | } | 894 | } |
894 | 895 | ||
@@ -898,13 +899,13 @@ static void gs_put_char(struct tty_struct *tty, unsigned char ch) | |||
898 | spin_lock_irqsave(&port->port_lock, flags); | 899 | spin_lock_irqsave(&port->port_lock, flags); |
899 | 900 | ||
900 | if (port->port_dev == NULL) { | 901 | if (port->port_dev == NULL) { |
901 | printk(KERN_ERR "gs_put_char: (%d,%p) port is not connected\n", | 902 | pr_err("gs_put_char: (%d,%p) port is not connected\n", |
902 | port->port_num, tty); | 903 | port->port_num, tty); |
903 | goto exit; | 904 | goto exit; |
904 | } | 905 | } |
905 | 906 | ||
906 | if (port->port_open_count == 0) { | 907 | if (port->port_open_count == 0) { |
907 | printk(KERN_ERR "gs_put_char: (%d,%p) port is closed\n", | 908 | pr_err("gs_put_char: (%d,%p) port is closed\n", |
908 | port->port_num, tty); | 909 | port->port_num, tty); |
909 | goto exit; | 910 | goto exit; |
910 | } | 911 | } |
@@ -924,7 +925,7 @@ static void gs_flush_chars(struct tty_struct *tty) | |||
924 | struct gs_port *port = tty->driver_data; | 925 | struct gs_port *port = tty->driver_data; |
925 | 926 | ||
926 | if (port == NULL) { | 927 | if (port == NULL) { |
927 | printk(KERN_ERR "gs_flush_chars: NULL port pointer\n"); | 928 | pr_err("gs_flush_chars: NULL port pointer\n"); |
928 | return; | 929 | return; |
929 | } | 930 | } |
930 | 931 | ||
@@ -933,14 +934,13 @@ static void gs_flush_chars(struct tty_struct *tty) | |||
933 | spin_lock_irqsave(&port->port_lock, flags); | 934 | spin_lock_irqsave(&port->port_lock, flags); |
934 | 935 | ||
935 | if (port->port_dev == NULL) { | 936 | if (port->port_dev == NULL) { |
936 | printk(KERN_ERR | 937 | pr_err("gs_flush_chars: (%d,%p) port is not connected\n", |
937 | "gs_flush_chars: (%d,%p) port is not connected\n", | ||
938 | port->port_num, tty); | 938 | port->port_num, tty); |
939 | goto exit; | 939 | goto exit; |
940 | } | 940 | } |
941 | 941 | ||
942 | if (port->port_open_count == 0) { | 942 | if (port->port_open_count == 0) { |
943 | printk(KERN_ERR "gs_flush_chars: (%d,%p) port is closed\n", | 943 | pr_err("gs_flush_chars: (%d,%p) port is closed\n", |
944 | port->port_num, tty); | 944 | port->port_num, tty); |
945 | goto exit; | 945 | goto exit; |
946 | } | 946 | } |
@@ -1038,7 +1038,7 @@ static int gs_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, | |||
1038 | struct gs_port *port = tty->driver_data; | 1038 | struct gs_port *port = tty->driver_data; |
1039 | 1039 | ||
1040 | if (port == NULL) { | 1040 | if (port == NULL) { |
1041 | printk(KERN_ERR "gs_ioctl: NULL port pointer\n"); | 1041 | pr_err("gs_ioctl: NULL port pointer\n"); |
1042 | return -EIO; | 1042 | return -EIO; |
1043 | } | 1043 | } |
1044 | 1044 | ||
@@ -1076,7 +1076,7 @@ static int gs_send(struct gs_dev *dev) | |||
1076 | struct gs_req_entry *req_entry; | 1076 | struct gs_req_entry *req_entry; |
1077 | 1077 | ||
1078 | if (dev == NULL) { | 1078 | if (dev == NULL) { |
1079 | printk(KERN_ERR "gs_send: NULL device pointer\n"); | 1079 | pr_err("gs_send: NULL device pointer\n"); |
1080 | return -ENODEV; | 1080 | return -ENODEV; |
1081 | } | 1081 | } |
1082 | 1082 | ||
@@ -1103,7 +1103,7 @@ static int gs_send(struct gs_dev *dev) | |||
1103 | req->length = len; | 1103 | req->length = len; |
1104 | spin_unlock_irqrestore(&dev->dev_lock, flags); | 1104 | spin_unlock_irqrestore(&dev->dev_lock, flags); |
1105 | if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { | 1105 | if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { |
1106 | printk(KERN_ERR | 1106 | pr_err( |
1107 | "gs_send: cannot queue read request, ret=%d\n", | 1107 | "gs_send: cannot queue read request, ret=%d\n", |
1108 | ret); | 1108 | ret); |
1109 | spin_lock_irqsave(&dev->dev_lock, flags); | 1109 | spin_lock_irqsave(&dev->dev_lock, flags); |
@@ -1144,9 +1144,7 @@ static int gs_send_packet(struct gs_dev *dev, char *packet, unsigned int size) | |||
1144 | port = dev->dev_port[0]; | 1144 | port = dev->dev_port[0]; |
1145 | 1145 | ||
1146 | if (port == NULL) { | 1146 | if (port == NULL) { |
1147 | printk(KERN_ERR | 1147 | pr_err("gs_send_packet: port=%d, NULL port pointer\n", 0); |
1148 | "gs_send_packet: port=%d, NULL port pointer\n", | ||
1149 | 0); | ||
1150 | return -EIO; | 1148 | return -EIO; |
1151 | } | 1149 | } |
1152 | 1150 | ||
@@ -1193,7 +1191,7 @@ static int gs_recv_packet(struct gs_dev *dev, char *packet, unsigned int size) | |||
1193 | port = dev->dev_port[0]; | 1191 | port = dev->dev_port[0]; |
1194 | 1192 | ||
1195 | if (port == NULL) { | 1193 | if (port == NULL) { |
1196 | printk(KERN_ERR "gs_recv_packet: port=%d, NULL port pointer\n", | 1194 | pr_err("gs_recv_packet: port=%d, NULL port pointer\n", |
1197 | port->port_num); | 1195 | port->port_num); |
1198 | return -EIO; | 1196 | return -EIO; |
1199 | } | 1197 | } |
@@ -1201,7 +1199,7 @@ static int gs_recv_packet(struct gs_dev *dev, char *packet, unsigned int size) | |||
1201 | spin_lock(&port->port_lock); | 1199 | spin_lock(&port->port_lock); |
1202 | 1200 | ||
1203 | if (port->port_open_count == 0) { | 1201 | if (port->port_open_count == 0) { |
1204 | printk(KERN_ERR "gs_recv_packet: port=%d, port is closed\n", | 1202 | pr_err("gs_recv_packet: port=%d, port is closed\n", |
1205 | port->port_num); | 1203 | port->port_num); |
1206 | ret = -EIO; | 1204 | ret = -EIO; |
1207 | goto exit; | 1205 | goto exit; |
@@ -1211,14 +1209,14 @@ static int gs_recv_packet(struct gs_dev *dev, char *packet, unsigned int size) | |||
1211 | tty = port->port_tty; | 1209 | tty = port->port_tty; |
1212 | 1210 | ||
1213 | if (tty == NULL) { | 1211 | if (tty == NULL) { |
1214 | printk(KERN_ERR "gs_recv_packet: port=%d, NULL tty pointer\n", | 1212 | pr_err("gs_recv_packet: port=%d, NULL tty pointer\n", |
1215 | port->port_num); | 1213 | port->port_num); |
1216 | ret = -EIO; | 1214 | ret = -EIO; |
1217 | goto exit; | 1215 | goto exit; |
1218 | } | 1216 | } |
1219 | 1217 | ||
1220 | if (port->port_tty->magic != TTY_MAGIC) { | 1218 | if (port->port_tty->magic != TTY_MAGIC) { |
1221 | printk(KERN_ERR "gs_recv_packet: port=%d, bad tty magic\n", | 1219 | pr_err("gs_recv_packet: port=%d, bad tty magic\n", |
1222 | port->port_num); | 1220 | port->port_num); |
1223 | ret = -EIO; | 1221 | ret = -EIO; |
1224 | goto exit; | 1222 | goto exit; |
@@ -1245,7 +1243,7 @@ static void gs_read_complete(struct usb_ep *ep, struct usb_request *req) | |||
1245 | struct gs_dev *dev = ep->driver_data; | 1243 | struct gs_dev *dev = ep->driver_data; |
1246 | 1244 | ||
1247 | if (dev == NULL) { | 1245 | if (dev == NULL) { |
1248 | printk(KERN_ERR "gs_read_complete: NULL device pointer\n"); | 1246 | pr_err("gs_read_complete: NULL device pointer\n"); |
1249 | return; | 1247 | return; |
1250 | } | 1248 | } |
1251 | 1249 | ||
@@ -1256,7 +1254,7 @@ static void gs_read_complete(struct usb_ep *ep, struct usb_request *req) | |||
1256 | requeue: | 1254 | requeue: |
1257 | req->length = ep->maxpacket; | 1255 | req->length = ep->maxpacket; |
1258 | if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { | 1256 | if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { |
1259 | printk(KERN_ERR | 1257 | pr_err( |
1260 | "gs_read_complete: cannot queue read request, ret=%d\n", | 1258 | "gs_read_complete: cannot queue read request, ret=%d\n", |
1261 | ret); | 1259 | ret); |
1262 | } | 1260 | } |
@@ -1270,7 +1268,7 @@ requeue: | |||
1270 | 1268 | ||
1271 | default: | 1269 | default: |
1272 | /* unexpected */ | 1270 | /* unexpected */ |
1273 | printk(KERN_ERR | 1271 | pr_err( |
1274 | "gs_read_complete: unexpected status error, status=%d\n", | 1272 | "gs_read_complete: unexpected status error, status=%d\n", |
1275 | req->status); | 1273 | req->status); |
1276 | goto requeue; | 1274 | goto requeue; |
@@ -1287,7 +1285,7 @@ static void gs_write_complete(struct usb_ep *ep, struct usb_request *req) | |||
1287 | struct gs_req_entry *gs_req = req->context; | 1285 | struct gs_req_entry *gs_req = req->context; |
1288 | 1286 | ||
1289 | if (dev == NULL) { | 1287 | if (dev == NULL) { |
1290 | printk(KERN_ERR "gs_write_complete: NULL device pointer\n"); | 1288 | pr_err("gs_write_complete: NULL device pointer\n"); |
1291 | return; | 1289 | return; |
1292 | } | 1290 | } |
1293 | 1291 | ||
@@ -1296,8 +1294,7 @@ static void gs_write_complete(struct usb_ep *ep, struct usb_request *req) | |||
1296 | /* normal completion */ | 1294 | /* normal completion */ |
1297 | requeue: | 1295 | requeue: |
1298 | if (gs_req == NULL) { | 1296 | if (gs_req == NULL) { |
1299 | printk(KERN_ERR | 1297 | pr_err("gs_write_complete: NULL request pointer\n"); |
1300 | "gs_write_complete: NULL request pointer\n"); | ||
1301 | return; | 1298 | return; |
1302 | } | 1299 | } |
1303 | 1300 | ||
@@ -1316,7 +1313,7 @@ requeue: | |||
1316 | break; | 1313 | break; |
1317 | 1314 | ||
1318 | default: | 1315 | default: |
1319 | printk(KERN_ERR | 1316 | pr_err( |
1320 | "gs_write_complete: unexpected status error, status=%d\n", | 1317 | "gs_write_complete: unexpected status error, status=%d\n", |
1321 | req->status); | 1318 | req->status); |
1322 | goto requeue; | 1319 | goto requeue; |
@@ -1351,7 +1348,7 @@ static int __init gs_bind(struct usb_gadget *gadget) | |||
1351 | gs_device_desc.bcdDevice = | 1348 | gs_device_desc.bcdDevice = |
1352 | cpu_to_le16(GS_VERSION_NUM | gcnum); | 1349 | cpu_to_le16(GS_VERSION_NUM | gcnum); |
1353 | else { | 1350 | else { |
1354 | printk(KERN_WARNING "gs_bind: controller '%s' not recognized\n", | 1351 | pr_warning("gs_bind: controller '%s' not recognized\n", |
1355 | gadget->name); | 1352 | gadget->name); |
1356 | /* unrecognized, but safe unless bulk is REALLY quirky */ | 1353 | /* unrecognized, but safe unless bulk is REALLY quirky */ |
1357 | gs_device_desc.bcdDevice = | 1354 | gs_device_desc.bcdDevice = |
@@ -1375,7 +1372,7 @@ static int __init gs_bind(struct usb_gadget *gadget) | |||
1375 | if (use_acm) { | 1372 | if (use_acm) { |
1376 | ep = usb_ep_autoconfig(gadget, &gs_fullspeed_notify_desc); | 1373 | ep = usb_ep_autoconfig(gadget, &gs_fullspeed_notify_desc); |
1377 | if (!ep) { | 1374 | if (!ep) { |
1378 | printk(KERN_ERR "gs_bind: cannot run ACM on %s\n", gadget->name); | 1375 | pr_err("gs_bind: cannot run ACM on %s\n", gadget->name); |
1379 | goto autoconf_fail; | 1376 | goto autoconf_fail; |
1380 | } | 1377 | } |
1381 | gs_device_desc.idProduct = __constant_cpu_to_le16( | 1378 | gs_device_desc.idProduct = __constant_cpu_to_le16( |
@@ -1425,7 +1422,7 @@ static int __init gs_bind(struct usb_gadget *gadget) | |||
1425 | set_gadget_data(gadget, dev); | 1422 | set_gadget_data(gadget, dev); |
1426 | 1423 | ||
1427 | if ((ret=gs_alloc_ports(dev, GFP_KERNEL)) != 0) { | 1424 | if ((ret=gs_alloc_ports(dev, GFP_KERNEL)) != 0) { |
1428 | printk(KERN_ERR "gs_bind: cannot allocate ports\n"); | 1425 | pr_err("gs_bind: cannot allocate ports\n"); |
1429 | gs_unbind(gadget); | 1426 | gs_unbind(gadget); |
1430 | return ret; | 1427 | return ret; |
1431 | } | 1428 | } |
@@ -1441,13 +1438,13 @@ static int __init gs_bind(struct usb_gadget *gadget) | |||
1441 | 1438 | ||
1442 | gadget->ep0->driver_data = dev; | 1439 | gadget->ep0->driver_data = dev; |
1443 | 1440 | ||
1444 | printk(KERN_INFO "gs_bind: %s %s bound\n", | 1441 | pr_info("gs_bind: %s %s bound\n", |
1445 | GS_LONG_NAME, GS_VERSION_STR); | 1442 | GS_LONG_NAME, GS_VERSION_STR); |
1446 | 1443 | ||
1447 | return 0; | 1444 | return 0; |
1448 | 1445 | ||
1449 | autoconf_fail: | 1446 | autoconf_fail: |
1450 | printk(KERN_ERR "gs_bind: cannot autoconfigure on %s\n", gadget->name); | 1447 | pr_err("gs_bind: cannot autoconfigure on %s\n", gadget->name); |
1451 | return -ENODEV; | 1448 | return -ENODEV; |
1452 | } | 1449 | } |
1453 | 1450 | ||
@@ -1480,7 +1477,7 @@ static void /* __init_or_exit */ gs_unbind(struct usb_gadget *gadget) | |||
1480 | set_gadget_data(gadget, NULL); | 1477 | set_gadget_data(gadget, NULL); |
1481 | } | 1478 | } |
1482 | 1479 | ||
1483 | printk(KERN_INFO "gs_unbind: %s %s unbound\n", GS_LONG_NAME, | 1480 | pr_info("gs_unbind: %s %s unbound\n", GS_LONG_NAME, |
1484 | GS_VERSION_STR); | 1481 | GS_VERSION_STR); |
1485 | } | 1482 | } |
1486 | 1483 | ||
@@ -1513,7 +1510,8 @@ static int gs_setup(struct usb_gadget *gadget, | |||
1513 | break; | 1510 | break; |
1514 | 1511 | ||
1515 | default: | 1512 | default: |
1516 | printk(KERN_ERR "gs_setup: unknown request, type=%02x, request=%02x, value=%04x, index=%04x, length=%d\n", | 1513 | pr_err("gs_setup: unknown request, type=%02x, request=%02x, " |
1514 | "value=%04x, index=%04x, length=%d\n", | ||
1517 | ctrl->bRequestType, ctrl->bRequest, | 1515 | ctrl->bRequestType, ctrl->bRequest, |
1518 | wValue, wIndex, wLength); | 1516 | wValue, wIndex, wLength); |
1519 | break; | 1517 | break; |
@@ -1526,7 +1524,7 @@ static int gs_setup(struct usb_gadget *gadget, | |||
1526 | && (ret % gadget->ep0->maxpacket) == 0; | 1524 | && (ret % gadget->ep0->maxpacket) == 0; |
1527 | ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); | 1525 | ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); |
1528 | if (ret < 0) { | 1526 | if (ret < 0) { |
1529 | printk(KERN_ERR "gs_setup: cannot queue response, ret=%d\n", | 1527 | pr_err("gs_setup: cannot queue response, ret=%d\n", |
1530 | ret); | 1528 | ret); |
1531 | req->status = 0; | 1529 | req->status = 0; |
1532 | gs_setup_complete(gadget->ep0, req); | 1530 | gs_setup_complete(gadget->ep0, req); |
@@ -1656,7 +1654,8 @@ set_interface_done: | |||
1656 | break; | 1654 | break; |
1657 | 1655 | ||
1658 | default: | 1656 | default: |
1659 | printk(KERN_ERR "gs_setup: unknown standard request, type=%02x, request=%02x, value=%04x, index=%04x, length=%d\n", | 1657 | pr_err("gs_setup: unknown standard request, type=%02x, " |
1658 | "request=%02x, value=%04x, index=%04x, length=%d\n", | ||
1660 | ctrl->bRequestType, ctrl->bRequest, | 1659 | ctrl->bRequestType, ctrl->bRequest, |
1661 | wValue, wIndex, wLength); | 1660 | wValue, wIndex, wLength); |
1662 | break; | 1661 | break; |
@@ -1682,7 +1681,7 @@ static int gs_setup_class(struct usb_gadget *gadget, | |||
1682 | * handler copy that data to port->port_line_coding (iff | 1681 | * handler copy that data to port->port_line_coding (iff |
1683 | * it's valid) and maybe pass it on. Until then, fail. | 1682 | * it's valid) and maybe pass it on. Until then, fail. |
1684 | */ | 1683 | */ |
1685 | printk(KERN_WARNING "gs_setup: set_line_coding " | 1684 | pr_warning("gs_setup: set_line_coding " |
1686 | "unuspported\n"); | 1685 | "unuspported\n"); |
1687 | break; | 1686 | break; |
1688 | 1687 | ||
@@ -1702,12 +1701,12 @@ static int gs_setup_class(struct usb_gadget *gadget, | |||
1702 | * handler use that to set the state (iff it's valid) and | 1701 | * handler use that to set the state (iff it's valid) and |
1703 | * maybe pass it on. Until then, fail. | 1702 | * maybe pass it on. Until then, fail. |
1704 | */ | 1703 | */ |
1705 | printk(KERN_WARNING "gs_setup: set_control_line_state " | 1704 | pr_warning("gs_setup: set_control_line_state " |
1706 | "unuspported\n"); | 1705 | "unuspported\n"); |
1707 | break; | 1706 | break; |
1708 | 1707 | ||
1709 | default: | 1708 | default: |
1710 | printk(KERN_ERR "gs_setup: unknown class request, " | 1709 | pr_err("gs_setup: unknown class request, " |
1711 | "type=%02x, request=%02x, value=%04x, " | 1710 | "type=%02x, request=%02x, value=%04x, " |
1712 | "index=%04x, length=%d\n", | 1711 | "index=%04x, length=%d\n", |
1713 | ctrl->bRequestType, ctrl->bRequest, | 1712 | ctrl->bRequestType, ctrl->bRequest, |
@@ -1724,7 +1723,8 @@ static int gs_setup_class(struct usb_gadget *gadget, | |||
1724 | static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req) | 1723 | static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req) |
1725 | { | 1724 | { |
1726 | if (req->status || req->actual != req->length) { | 1725 | if (req->status || req->actual != req->length) { |
1727 | printk(KERN_ERR "gs_setup_complete: status error, status=%d, actual=%d, length=%d\n", | 1726 | pr_err("gs_setup_complete: status error, status=%d, " |
1727 | "actual=%d, length=%d\n", | ||
1728 | req->status, req->actual, req->length); | 1728 | req->status, req->actual, req->length); |
1729 | } | 1729 | } |
1730 | } | 1730 | } |
@@ -1751,11 +1751,11 @@ static void gs_disconnect(struct usb_gadget *gadget) | |||
1751 | 1751 | ||
1752 | /* re-allocate ports for the next connection */ | 1752 | /* re-allocate ports for the next connection */ |
1753 | if (gs_alloc_ports(dev, GFP_ATOMIC) != 0) | 1753 | if (gs_alloc_ports(dev, GFP_ATOMIC) != 0) |
1754 | printk(KERN_ERR "gs_disconnect: cannot re-allocate ports\n"); | 1754 | pr_err("gs_disconnect: cannot re-allocate ports\n"); |
1755 | 1755 | ||
1756 | spin_unlock_irqrestore(&dev->dev_lock, flags); | 1756 | spin_unlock_irqrestore(&dev->dev_lock, flags); |
1757 | 1757 | ||
1758 | printk(KERN_INFO "gs_disconnect: %s disconnected\n", GS_LONG_NAME); | 1758 | pr_info("gs_disconnect: %s disconnected\n", GS_LONG_NAME); |
1759 | } | 1759 | } |
1760 | 1760 | ||
1761 | /* | 1761 | /* |
@@ -1778,7 +1778,7 @@ static int gs_set_config(struct gs_dev *dev, unsigned config) | |||
1778 | struct gs_req_entry *req_entry; | 1778 | struct gs_req_entry *req_entry; |
1779 | 1779 | ||
1780 | if (dev == NULL) { | 1780 | if (dev == NULL) { |
1781 | printk(KERN_ERR "gs_set_config: NULL device pointer\n"); | 1781 | pr_err("gs_set_config: NULL device pointer\n"); |
1782 | return 0; | 1782 | return 0; |
1783 | } | 1783 | } |
1784 | 1784 | ||
@@ -1823,7 +1823,8 @@ static int gs_set_config(struct gs_dev *dev, unsigned config) | |||
1823 | dev->dev_notify_ep = ep; | 1823 | dev->dev_notify_ep = ep; |
1824 | dev->dev_notify_ep_desc = ep_desc; | 1824 | dev->dev_notify_ep_desc = ep_desc; |
1825 | } else { | 1825 | } else { |
1826 | printk(KERN_ERR "gs_set_config: cannot enable notify endpoint %s, ret=%d\n", | 1826 | pr_err("gs_set_config: cannot enable NOTIFY " |
1827 | "endpoint %s, ret=%d\n", | ||
1827 | ep->name, ret); | 1828 | ep->name, ret); |
1828 | goto exit_reset_config; | 1829 | goto exit_reset_config; |
1829 | } | 1830 | } |
@@ -1839,7 +1840,8 @@ static int gs_set_config(struct gs_dev *dev, unsigned config) | |||
1839 | dev->dev_in_ep = ep; | 1840 | dev->dev_in_ep = ep; |
1840 | dev->dev_in_ep_desc = ep_desc; | 1841 | dev->dev_in_ep_desc = ep_desc; |
1841 | } else { | 1842 | } else { |
1842 | printk(KERN_ERR "gs_set_config: cannot enable in endpoint %s, ret=%d\n", | 1843 | pr_err("gs_set_config: cannot enable IN " |
1844 | "endpoint %s, ret=%d\n", | ||
1843 | ep->name, ret); | 1845 | ep->name, ret); |
1844 | goto exit_reset_config; | 1846 | goto exit_reset_config; |
1845 | } | 1847 | } |
@@ -1855,7 +1857,8 @@ static int gs_set_config(struct gs_dev *dev, unsigned config) | |||
1855 | dev->dev_out_ep = ep; | 1857 | dev->dev_out_ep = ep; |
1856 | dev->dev_out_ep_desc = ep_desc; | 1858 | dev->dev_out_ep_desc = ep_desc; |
1857 | } else { | 1859 | } else { |
1858 | printk(KERN_ERR "gs_set_config: cannot enable out endpoint %s, ret=%d\n", | 1860 | pr_err("gs_set_config: cannot enable OUT " |
1861 | "endpoint %s, ret=%d\n", | ||
1859 | ep->name, ret); | 1862 | ep->name, ret); |
1860 | goto exit_reset_config; | 1863 | goto exit_reset_config; |
1861 | } | 1864 | } |
@@ -1865,7 +1868,7 @@ static int gs_set_config(struct gs_dev *dev, unsigned config) | |||
1865 | 1868 | ||
1866 | if (dev->dev_in_ep == NULL || dev->dev_out_ep == NULL | 1869 | if (dev->dev_in_ep == NULL || dev->dev_out_ep == NULL |
1867 | || (config != GS_BULK_CONFIG_ID && dev->dev_notify_ep == NULL)) { | 1870 | || (config != GS_BULK_CONFIG_ID && dev->dev_notify_ep == NULL)) { |
1868 | printk(KERN_ERR "gs_set_config: cannot find endpoints\n"); | 1871 | pr_err("gs_set_config: cannot find endpoints\n"); |
1869 | ret = -ENODEV; | 1872 | ret = -ENODEV; |
1870 | goto exit_reset_config; | 1873 | goto exit_reset_config; |
1871 | } | 1874 | } |
@@ -1876,11 +1879,12 @@ static int gs_set_config(struct gs_dev *dev, unsigned config) | |||
1876 | if ((req=gs_alloc_req(ep, ep->maxpacket, GFP_ATOMIC))) { | 1879 | if ((req=gs_alloc_req(ep, ep->maxpacket, GFP_ATOMIC))) { |
1877 | req->complete = gs_read_complete; | 1880 | req->complete = gs_read_complete; |
1878 | if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { | 1881 | if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { |
1879 | printk(KERN_ERR "gs_set_config: cannot queue read request, ret=%d\n", | 1882 | pr_err("gs_set_config: cannot queue read " |
1880 | ret); | 1883 | "request, ret=%d\n", ret); |
1881 | } | 1884 | } |
1882 | } else { | 1885 | } else { |
1883 | printk(KERN_ERR "gs_set_config: cannot allocate read requests\n"); | 1886 | pr_err("gs_set_config: cannot allocate " |
1887 | "read requests\n"); | ||
1884 | ret = -ENOMEM; | 1888 | ret = -ENOMEM; |
1885 | goto exit_reset_config; | 1889 | goto exit_reset_config; |
1886 | } | 1890 | } |
@@ -1893,13 +1897,14 @@ static int gs_set_config(struct gs_dev *dev, unsigned config) | |||
1893 | req_entry->re_req->complete = gs_write_complete; | 1897 | req_entry->re_req->complete = gs_write_complete; |
1894 | list_add(&req_entry->re_entry, &dev->dev_req_list); | 1898 | list_add(&req_entry->re_entry, &dev->dev_req_list); |
1895 | } else { | 1899 | } else { |
1896 | printk(KERN_ERR "gs_set_config: cannot allocate write requests\n"); | 1900 | pr_err("gs_set_config: cannot allocate " |
1901 | "write requests\n"); | ||
1897 | ret = -ENOMEM; | 1902 | ret = -ENOMEM; |
1898 | goto exit_reset_config; | 1903 | goto exit_reset_config; |
1899 | } | 1904 | } |
1900 | } | 1905 | } |
1901 | 1906 | ||
1902 | printk(KERN_INFO "gs_set_config: %s configured, %s speed %s config\n", | 1907 | pr_info("gs_set_config: %s configured, %s speed %s config\n", |
1903 | GS_LONG_NAME, | 1908 | GS_LONG_NAME, |
1904 | gadget->speed == USB_SPEED_HIGH ? "high" : "full", | 1909 | gadget->speed == USB_SPEED_HIGH ? "high" : "full", |
1905 | config == GS_BULK_CONFIG_ID ? "BULK" : "CDC-ACM"); | 1910 | config == GS_BULK_CONFIG_ID ? "BULK" : "CDC-ACM"); |
@@ -1926,7 +1931,7 @@ static void gs_reset_config(struct gs_dev *dev) | |||
1926 | struct gs_req_entry *req_entry; | 1931 | struct gs_req_entry *req_entry; |
1927 | 1932 | ||
1928 | if (dev == NULL) { | 1933 | if (dev == NULL) { |
1929 | printk(KERN_ERR "gs_reset_config: NULL device pointer\n"); | 1934 | pr_err("gs_reset_config: NULL device pointer\n"); |
1930 | return; | 1935 | return; |
1931 | } | 1936 | } |
1932 | 1937 | ||
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index fcde5d9c87df..d3d4f4048e6c 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c | |||
@@ -1115,7 +1115,7 @@ zero_bind (struct usb_gadget *gadget) | |||
1115 | ep = usb_ep_autoconfig (gadget, &fs_source_desc); | 1115 | ep = usb_ep_autoconfig (gadget, &fs_source_desc); |
1116 | if (!ep) { | 1116 | if (!ep) { |
1117 | autoconf_fail: | 1117 | autoconf_fail: |
1118 | printk (KERN_ERR "%s: can't autoconfigure on %s\n", | 1118 | pr_err("%s: can't autoconfigure on %s\n", |
1119 | shortname, gadget->name); | 1119 | shortname, gadget->name); |
1120 | return -ENODEV; | 1120 | return -ENODEV; |
1121 | } | 1121 | } |
@@ -1139,7 +1139,7 @@ autoconf_fail: | |||
1139 | * things like configuration and altsetting numbering | 1139 | * things like configuration and altsetting numbering |
1140 | * can need hardware-specific attention though. | 1140 | * can need hardware-specific attention though. |
1141 | */ | 1141 | */ |
1142 | printk (KERN_WARNING "%s: controller '%s' not recognized\n", | 1142 | pr_warning("%s: controller '%s' not recognized\n", |
1143 | shortname, gadget->name); | 1143 | shortname, gadget->name); |
1144 | device_desc.bcdDevice = __constant_cpu_to_le16 (0x9999); | 1144 | device_desc.bcdDevice = __constant_cpu_to_le16 (0x9999); |
1145 | } | 1145 | } |
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 49a91c5ee51b..d97b16b52efa 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -29,15 +29,6 @@ config USB_EHCI_HCD | |||
29 | To compile this driver as a module, choose M here: the | 29 | To compile this driver as a module, choose M here: the |
30 | module will be called ehci-hcd. | 30 | module will be called ehci-hcd. |
31 | 31 | ||
32 | config USB_EHCI_SPLIT_ISO | ||
33 | bool "Full speed ISO transactions (EXPERIMENTAL)" | ||
34 | depends on USB_EHCI_HCD && EXPERIMENTAL | ||
35 | default n | ||
36 | ---help--- | ||
37 | This code is new and hasn't been used with many different | ||
38 | EHCI or USB 2.0 transaction translator implementations. | ||
39 | It should work for ISO-OUT transfers, like audio. | ||
40 | |||
41 | config USB_EHCI_ROOT_HUB_TT | 32 | config USB_EHCI_ROOT_HUB_TT |
42 | bool "Root Hub Transaction Translators (EXPERIMENTAL)" | 33 | bool "Root Hub Transaction Translators (EXPERIMENTAL)" |
43 | depends on USB_EHCI_HCD && EXPERIMENTAL | 34 | depends on USB_EHCI_HCD && EXPERIMENTAL |
@@ -69,21 +60,30 @@ config USB_EHCI_TT_NEWSCHED | |||
69 | 60 | ||
70 | config USB_EHCI_BIG_ENDIAN_MMIO | 61 | config USB_EHCI_BIG_ENDIAN_MMIO |
71 | bool | 62 | bool |
72 | depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX) | 63 | depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX || ARCH_IXP4XX) |
73 | default y | 64 | default y |
74 | 65 | ||
75 | config USB_EHCI_BIG_ENDIAN_DESC | 66 | config USB_EHCI_BIG_ENDIAN_DESC |
76 | bool | 67 | bool |
77 | depends on USB_EHCI_HCD && 440EPX | 68 | depends on USB_EHCI_HCD && (440EPX || ARCH_IXP4XX) |
78 | default y | 69 | default y |
79 | 70 | ||
80 | config USB_EHCI_FSL | 71 | config USB_EHCI_FSL |
81 | bool | 72 | bool |
73 | depends on USB_EHCI_HCD | ||
82 | select USB_EHCI_ROOT_HUB_TT | 74 | select USB_EHCI_ROOT_HUB_TT |
83 | default y if MPC834x || PPC_MPC831x | 75 | default y if MPC834x || PPC_MPC831x |
84 | ---help--- | 76 | ---help--- |
85 | Variation of ARC USB block used in some Freescale chips. | 77 | Variation of ARC USB block used in some Freescale chips. |
86 | 78 | ||
79 | config USB_EHCI_HCD_PPC_OF | ||
80 | bool "EHCI support for PPC USB controller on OF platform bus" | ||
81 | depends on USB_EHCI_HCD && PPC_OF | ||
82 | default y | ||
83 | ---help--- | ||
84 | Enables support for the USB controller present on the PowerPC | ||
85 | OpenFirmware platform bus. | ||
86 | |||
87 | config USB_ISP116X_HCD | 87 | config USB_ISP116X_HCD |
88 | tristate "ISP116X HCD support" | 88 | tristate "ISP116X HCD support" |
89 | depends on USB | 89 | depends on USB |
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c index 766ef68a0b43..da7532d38bf1 100644 --- a/drivers/usb/host/ehci-au1xxx.c +++ b/drivers/usb/host/ehci-au1xxx.c | |||
@@ -222,6 +222,7 @@ static const struct hc_driver ehci_au1xxx_hc_driver = { | |||
222 | .hub_control = ehci_hub_control, | 222 | .hub_control = ehci_hub_control, |
223 | .bus_suspend = ehci_bus_suspend, | 223 | .bus_suspend = ehci_bus_suspend, |
224 | .bus_resume = ehci_bus_resume, | 224 | .bus_resume = ehci_bus_resume, |
225 | .relinquish_port = ehci_relinquish_port, | ||
225 | }; | 226 | }; |
226 | 227 | ||
227 | /*-------------------------------------------------------------------------*/ | 228 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c index c9cc4413198e..64ebfc5548a3 100644 --- a/drivers/usb/host/ehci-dbg.c +++ b/drivers/usb/host/ehci-dbg.c | |||
@@ -323,7 +323,43 @@ static inline void remove_debug_files (struct ehci_hcd *bus) { } | |||
323 | 323 | ||
324 | #else | 324 | #else |
325 | 325 | ||
326 | /* troubleshooting help: expose state in sysfs */ | 326 | /* troubleshooting help: expose state in debugfs */ |
327 | |||
328 | static int debug_async_open(struct inode *, struct file *); | ||
329 | static int debug_periodic_open(struct inode *, struct file *); | ||
330 | static int debug_registers_open(struct inode *, struct file *); | ||
331 | static int debug_async_open(struct inode *, struct file *); | ||
332 | static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*); | ||
333 | static int debug_close(struct inode *, struct file *); | ||
334 | |||
335 | static const struct file_operations debug_async_fops = { | ||
336 | .owner = THIS_MODULE, | ||
337 | .open = debug_async_open, | ||
338 | .read = debug_output, | ||
339 | .release = debug_close, | ||
340 | }; | ||
341 | static const struct file_operations debug_periodic_fops = { | ||
342 | .owner = THIS_MODULE, | ||
343 | .open = debug_periodic_open, | ||
344 | .read = debug_output, | ||
345 | .release = debug_close, | ||
346 | }; | ||
347 | static const struct file_operations debug_registers_fops = { | ||
348 | .owner = THIS_MODULE, | ||
349 | .open = debug_registers_open, | ||
350 | .read = debug_output, | ||
351 | .release = debug_close, | ||
352 | }; | ||
353 | |||
354 | static struct dentry *ehci_debug_root; | ||
355 | |||
356 | struct debug_buffer { | ||
357 | ssize_t (*fill_func)(struct debug_buffer *); /* fill method */ | ||
358 | struct usb_bus *bus; | ||
359 | struct mutex mutex; /* protect filling of buffer */ | ||
360 | size_t count; /* number of characters filled into buffer */ | ||
361 | char *page; | ||
362 | }; | ||
327 | 363 | ||
328 | #define speed_char(info1) ({ char tmp; \ | 364 | #define speed_char(info1) ({ char tmp; \ |
329 | switch (info1 & (3 << 12)) { \ | 365 | switch (info1 & (3 << 12)) { \ |
@@ -441,10 +477,8 @@ done: | |||
441 | *nextp = next; | 477 | *nextp = next; |
442 | } | 478 | } |
443 | 479 | ||
444 | static ssize_t | 480 | static ssize_t fill_async_buffer(struct debug_buffer *buf) |
445 | show_async (struct class_device *class_dev, char *buf) | ||
446 | { | 481 | { |
447 | struct usb_bus *bus; | ||
448 | struct usb_hcd *hcd; | 482 | struct usb_hcd *hcd; |
449 | struct ehci_hcd *ehci; | 483 | struct ehci_hcd *ehci; |
450 | unsigned long flags; | 484 | unsigned long flags; |
@@ -452,14 +486,13 @@ show_async (struct class_device *class_dev, char *buf) | |||
452 | char *next; | 486 | char *next; |
453 | struct ehci_qh *qh; | 487 | struct ehci_qh *qh; |
454 | 488 | ||
455 | *buf = 0; | 489 | hcd = bus_to_hcd(buf->bus); |
456 | |||
457 | bus = class_get_devdata(class_dev); | ||
458 | hcd = bus_to_hcd(bus); | ||
459 | ehci = hcd_to_ehci (hcd); | 490 | ehci = hcd_to_ehci (hcd); |
460 | next = buf; | 491 | next = buf->page; |
461 | size = PAGE_SIZE; | 492 | size = PAGE_SIZE; |
462 | 493 | ||
494 | *next = 0; | ||
495 | |||
463 | /* dumps a snapshot of the async schedule. | 496 | /* dumps a snapshot of the async schedule. |
464 | * usually empty except for long-term bulk reads, or head. | 497 | * usually empty except for long-term bulk reads, or head. |
465 | * one QH per line, and TDs we know about | 498 | * one QH per line, and TDs we know about |
@@ -477,16 +510,12 @@ show_async (struct class_device *class_dev, char *buf) | |||
477 | } | 510 | } |
478 | spin_unlock_irqrestore (&ehci->lock, flags); | 511 | spin_unlock_irqrestore (&ehci->lock, flags); |
479 | 512 | ||
480 | return strlen (buf); | 513 | return strlen(buf->page); |
481 | } | 514 | } |
482 | static CLASS_DEVICE_ATTR (async, S_IRUGO, show_async, NULL); | ||
483 | 515 | ||
484 | #define DBG_SCHED_LIMIT 64 | 516 | #define DBG_SCHED_LIMIT 64 |
485 | 517 | static ssize_t fill_periodic_buffer(struct debug_buffer *buf) | |
486 | static ssize_t | ||
487 | show_periodic (struct class_device *class_dev, char *buf) | ||
488 | { | 518 | { |
489 | struct usb_bus *bus; | ||
490 | struct usb_hcd *hcd; | 519 | struct usb_hcd *hcd; |
491 | struct ehci_hcd *ehci; | 520 | struct ehci_hcd *ehci; |
492 | unsigned long flags; | 521 | unsigned long flags; |
@@ -500,10 +529,9 @@ show_periodic (struct class_device *class_dev, char *buf) | |||
500 | return 0; | 529 | return 0; |
501 | seen_count = 0; | 530 | seen_count = 0; |
502 | 531 | ||
503 | bus = class_get_devdata(class_dev); | 532 | hcd = bus_to_hcd(buf->bus); |
504 | hcd = bus_to_hcd(bus); | ||
505 | ehci = hcd_to_ehci (hcd); | 533 | ehci = hcd_to_ehci (hcd); |
506 | next = buf; | 534 | next = buf->page; |
507 | size = PAGE_SIZE; | 535 | size = PAGE_SIZE; |
508 | 536 | ||
509 | temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size); | 537 | temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size); |
@@ -623,14 +651,10 @@ show_periodic (struct class_device *class_dev, char *buf) | |||
623 | 651 | ||
624 | return PAGE_SIZE - size; | 652 | return PAGE_SIZE - size; |
625 | } | 653 | } |
626 | static CLASS_DEVICE_ATTR (periodic, S_IRUGO, show_periodic, NULL); | ||
627 | |||
628 | #undef DBG_SCHED_LIMIT | 654 | #undef DBG_SCHED_LIMIT |
629 | 655 | ||
630 | static ssize_t | 656 | static ssize_t fill_registers_buffer(struct debug_buffer *buf) |
631 | show_registers (struct class_device *class_dev, char *buf) | ||
632 | { | 657 | { |
633 | struct usb_bus *bus; | ||
634 | struct usb_hcd *hcd; | 658 | struct usb_hcd *hcd; |
635 | struct ehci_hcd *ehci; | 659 | struct ehci_hcd *ehci; |
636 | unsigned long flags; | 660 | unsigned long flags; |
@@ -639,15 +663,14 @@ show_registers (struct class_device *class_dev, char *buf) | |||
639 | static char fmt [] = "%*s\n"; | 663 | static char fmt [] = "%*s\n"; |
640 | static char label [] = ""; | 664 | static char label [] = ""; |
641 | 665 | ||
642 | bus = class_get_devdata(class_dev); | 666 | hcd = bus_to_hcd(buf->bus); |
643 | hcd = bus_to_hcd(bus); | ||
644 | ehci = hcd_to_ehci (hcd); | 667 | ehci = hcd_to_ehci (hcd); |
645 | next = buf; | 668 | next = buf->page; |
646 | size = PAGE_SIZE; | 669 | size = PAGE_SIZE; |
647 | 670 | ||
648 | spin_lock_irqsave (&ehci->lock, flags); | 671 | spin_lock_irqsave (&ehci->lock, flags); |
649 | 672 | ||
650 | if (bus->controller->power.power_state.event) { | 673 | if (buf->bus->controller->power.power_state.event) { |
651 | size = scnprintf (next, size, | 674 | size = scnprintf (next, size, |
652 | "bus %s, device %s (driver " DRIVER_VERSION ")\n" | 675 | "bus %s, device %s (driver " DRIVER_VERSION ")\n" |
653 | "%s\n" | 676 | "%s\n" |
@@ -763,9 +786,7 @@ show_registers (struct class_device *class_dev, char *buf) | |||
763 | } | 786 | } |
764 | 787 | ||
765 | if (ehci->reclaim) { | 788 | if (ehci->reclaim) { |
766 | temp = scnprintf (next, size, "reclaim qh %p%s\n", | 789 | temp = scnprintf(next, size, "reclaim qh %p\n", ehci->reclaim); |
767 | ehci->reclaim, | ||
768 | ehci->reclaim_ready ? " ready" : ""); | ||
769 | size -= temp; | 790 | size -= temp; |
770 | next += temp; | 791 | next += temp; |
771 | } | 792 | } |
@@ -789,26 +810,150 @@ done: | |||
789 | 810 | ||
790 | return PAGE_SIZE - size; | 811 | return PAGE_SIZE - size; |
791 | } | 812 | } |
792 | static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL); | ||
793 | 813 | ||
794 | static inline void create_debug_files (struct ehci_hcd *ehci) | 814 | static struct debug_buffer *alloc_buffer(struct usb_bus *bus, |
815 | ssize_t (*fill_func)(struct debug_buffer *)) | ||
795 | { | 816 | { |
796 | struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev; | 817 | struct debug_buffer *buf; |
797 | int retval; | 818 | |
819 | buf = kzalloc(sizeof(struct debug_buffer), GFP_KERNEL); | ||
798 | 820 | ||
799 | retval = class_device_create_file(cldev, &class_device_attr_async); | 821 | if (buf) { |
800 | retval = class_device_create_file(cldev, &class_device_attr_periodic); | 822 | buf->bus = bus; |
801 | retval = class_device_create_file(cldev, &class_device_attr_registers); | 823 | buf->fill_func = fill_func; |
824 | mutex_init(&buf->mutex); | ||
825 | } | ||
826 | |||
827 | return buf; | ||
802 | } | 828 | } |
803 | 829 | ||
804 | static inline void remove_debug_files (struct ehci_hcd *ehci) | 830 | static int fill_buffer(struct debug_buffer *buf) |
805 | { | 831 | { |
806 | struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev; | 832 | int ret = 0; |
833 | |||
834 | if (!buf->page) | ||
835 | buf->page = (char *)get_zeroed_page(GFP_KERNEL); | ||
836 | |||
837 | if (!buf->page) { | ||
838 | ret = -ENOMEM; | ||
839 | goto out; | ||
840 | } | ||
841 | |||
842 | ret = buf->fill_func(buf); | ||
807 | 843 | ||
808 | class_device_remove_file(cldev, &class_device_attr_async); | 844 | if (ret >= 0) { |
809 | class_device_remove_file(cldev, &class_device_attr_periodic); | 845 | buf->count = ret; |
810 | class_device_remove_file(cldev, &class_device_attr_registers); | 846 | ret = 0; |
847 | } | ||
848 | |||
849 | out: | ||
850 | return ret; | ||
811 | } | 851 | } |
812 | 852 | ||
813 | #endif /* STUB_DEBUG_FILES */ | 853 | static ssize_t debug_output(struct file *file, char __user *user_buf, |
854 | size_t len, loff_t *offset) | ||
855 | { | ||
856 | struct debug_buffer *buf = file->private_data; | ||
857 | int ret = 0; | ||
858 | |||
859 | mutex_lock(&buf->mutex); | ||
860 | if (buf->count == 0) { | ||
861 | ret = fill_buffer(buf); | ||
862 | if (ret != 0) { | ||
863 | mutex_unlock(&buf->mutex); | ||
864 | goto out; | ||
865 | } | ||
866 | } | ||
867 | mutex_unlock(&buf->mutex); | ||
868 | |||
869 | ret = simple_read_from_buffer(user_buf, len, offset, | ||
870 | buf->page, buf->count); | ||
871 | |||
872 | out: | ||
873 | return ret; | ||
874 | |||
875 | } | ||
876 | |||
877 | static int debug_close(struct inode *inode, struct file *file) | ||
878 | { | ||
879 | struct debug_buffer *buf = file->private_data; | ||
814 | 880 | ||
881 | if (buf) { | ||
882 | if (buf->page) | ||
883 | free_page((unsigned long)buf->page); | ||
884 | kfree(buf); | ||
885 | } | ||
886 | |||
887 | return 0; | ||
888 | } | ||
889 | static int debug_async_open(struct inode *inode, struct file *file) | ||
890 | { | ||
891 | file->private_data = alloc_buffer(inode->i_private, fill_async_buffer); | ||
892 | |||
893 | return file->private_data ? 0 : -ENOMEM; | ||
894 | } | ||
895 | |||
896 | static int debug_periodic_open(struct inode *inode, struct file *file) | ||
897 | { | ||
898 | file->private_data = alloc_buffer(inode->i_private, | ||
899 | fill_periodic_buffer); | ||
900 | |||
901 | return file->private_data ? 0 : -ENOMEM; | ||
902 | } | ||
903 | |||
904 | static int debug_registers_open(struct inode *inode, struct file *file) | ||
905 | { | ||
906 | file->private_data = alloc_buffer(inode->i_private, | ||
907 | fill_registers_buffer); | ||
908 | |||
909 | return file->private_data ? 0 : -ENOMEM; | ||
910 | } | ||
911 | |||
912 | static inline void create_debug_files (struct ehci_hcd *ehci) | ||
913 | { | ||
914 | struct usb_bus *bus = &ehci_to_hcd(ehci)->self; | ||
915 | |||
916 | ehci->debug_dir = debugfs_create_dir(bus->bus_name, ehci_debug_root); | ||
917 | if (!ehci->debug_dir) | ||
918 | goto dir_error; | ||
919 | |||
920 | ehci->debug_async = debugfs_create_file("async", S_IRUGO, | ||
921 | ehci->debug_dir, bus, | ||
922 | &debug_async_fops); | ||
923 | if (!ehci->debug_async) | ||
924 | goto async_error; | ||
925 | |||
926 | ehci->debug_periodic = debugfs_create_file("periodic", S_IRUGO, | ||
927 | ehci->debug_dir, bus, | ||
928 | &debug_periodic_fops); | ||
929 | if (!ehci->debug_periodic) | ||
930 | goto periodic_error; | ||
931 | |||
932 | ehci->debug_registers = debugfs_create_file("registers", S_IRUGO, | ||
933 | ehci->debug_dir, bus, | ||
934 | &debug_registers_fops); | ||
935 | if (!ehci->debug_registers) | ||
936 | goto registers_error; | ||
937 | return; | ||
938 | |||
939 | registers_error: | ||
940 | debugfs_remove(ehci->debug_periodic); | ||
941 | periodic_error: | ||
942 | debugfs_remove(ehci->debug_async); | ||
943 | async_error: | ||
944 | debugfs_remove(ehci->debug_dir); | ||
945 | dir_error: | ||
946 | ehci->debug_periodic = NULL; | ||
947 | ehci->debug_async = NULL; | ||
948 | ehci->debug_dir = NULL; | ||
949 | } | ||
950 | |||
951 | static inline void remove_debug_files (struct ehci_hcd *ehci) | ||
952 | { | ||
953 | debugfs_remove(ehci->debug_registers); | ||
954 | debugfs_remove(ehci->debug_periodic); | ||
955 | debugfs_remove(ehci->debug_async); | ||
956 | debugfs_remove(ehci->debug_dir); | ||
957 | } | ||
958 | |||
959 | #endif /* STUB_DEBUG_FILES */ | ||
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index 430821cb95c8..adb0defa1631 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c | |||
@@ -25,7 +25,7 @@ | |||
25 | 25 | ||
26 | #include "ehci-fsl.h" | 26 | #include "ehci-fsl.h" |
27 | 27 | ||
28 | /* FIXME: Power Managment is un-ported so temporarily disable it */ | 28 | /* FIXME: Power Management is un-ported so temporarily disable it */ |
29 | #undef CONFIG_PM | 29 | #undef CONFIG_PM |
30 | 30 | ||
31 | /* PCI-based HCs are common, but plenty of non-PCI HCs are used too */ | 31 | /* PCI-based HCs are common, but plenty of non-PCI HCs are used too */ |
@@ -323,6 +323,7 @@ static const struct hc_driver ehci_fsl_hc_driver = { | |||
323 | .hub_control = ehci_hub_control, | 323 | .hub_control = ehci_hub_control, |
324 | .bus_suspend = ehci_bus_suspend, | 324 | .bus_suspend = ehci_bus_suspend, |
325 | .bus_resume = ehci_bus_resume, | 325 | .bus_resume = ehci_bus_resume, |
326 | .relinquish_port = ehci_relinquish_port, | ||
326 | }; | 327 | }; |
327 | 328 | ||
328 | static int ehci_fsl_drv_probe(struct platform_device *pdev) | 329 | static int ehci_fsl_drv_probe(struct platform_device *pdev) |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 5f2d74ed5ad7..4caa6a8b9a37 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/usb.h> | 33 | #include <linux/usb.h> |
34 | #include <linux/moduleparam.h> | 34 | #include <linux/moduleparam.h> |
35 | #include <linux/dma-mapping.h> | 35 | #include <linux/dma-mapping.h> |
36 | #include <linux/debugfs.h> | ||
36 | 37 | ||
37 | #include "../core/hcd.h" | 38 | #include "../core/hcd.h" |
38 | 39 | ||
@@ -109,7 +110,7 @@ static const char hcd_name [] = "ehci_hcd"; | |||
109 | #define EHCI_TUNE_MULT_TT 1 | 110 | #define EHCI_TUNE_MULT_TT 1 |
110 | #define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */ | 111 | #define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */ |
111 | 112 | ||
112 | #define EHCI_IAA_JIFFIES (HZ/100) /* arbitrary; ~10 msec */ | 113 | #define EHCI_IAA_MSECS 10 /* arbitrary */ |
113 | #define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ | 114 | #define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ |
114 | #define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */ | 115 | #define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */ |
115 | #define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */ | 116 | #define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */ |
@@ -266,6 +267,7 @@ static void ehci_quiesce (struct ehci_hcd *ehci) | |||
266 | 267 | ||
267 | /*-------------------------------------------------------------------------*/ | 268 | /*-------------------------------------------------------------------------*/ |
268 | 269 | ||
270 | static void end_unlink_async(struct ehci_hcd *ehci); | ||
269 | static void ehci_work(struct ehci_hcd *ehci); | 271 | static void ehci_work(struct ehci_hcd *ehci); |
270 | 272 | ||
271 | #include "ehci-hub.c" | 273 | #include "ehci-hub.c" |
@@ -275,25 +277,41 @@ static void ehci_work(struct ehci_hcd *ehci); | |||
275 | 277 | ||
276 | /*-------------------------------------------------------------------------*/ | 278 | /*-------------------------------------------------------------------------*/ |
277 | 279 | ||
278 | static void ehci_watchdog (unsigned long param) | 280 | static void ehci_iaa_watchdog(unsigned long param) |
279 | { | 281 | { |
280 | struct ehci_hcd *ehci = (struct ehci_hcd *) param; | 282 | struct ehci_hcd *ehci = (struct ehci_hcd *) param; |
281 | unsigned long flags; | 283 | unsigned long flags; |
284 | u32 status, cmd; | ||
282 | 285 | ||
283 | spin_lock_irqsave (&ehci->lock, flags); | 286 | spin_lock_irqsave (&ehci->lock, flags); |
287 | WARN_ON(!ehci->reclaim); | ||
284 | 288 | ||
285 | /* lost IAA irqs wedge things badly; seen with a vt8235 */ | 289 | status = ehci_readl(ehci, &ehci->regs->status); |
290 | cmd = ehci_readl(ehci, &ehci->regs->command); | ||
291 | ehci_dbg(ehci, "IAA watchdog: status %x cmd %x\n", status, cmd); | ||
292 | |||
293 | /* lost IAA irqs wedge things badly; seen first with a vt8235 */ | ||
286 | if (ehci->reclaim) { | 294 | if (ehci->reclaim) { |
287 | u32 status = ehci_readl(ehci, &ehci->regs->status); | ||
288 | if (status & STS_IAA) { | 295 | if (status & STS_IAA) { |
289 | ehci_vdbg (ehci, "lost IAA\n"); | 296 | ehci_vdbg (ehci, "lost IAA\n"); |
290 | COUNT (ehci->stats.lost_iaa); | 297 | COUNT (ehci->stats.lost_iaa); |
291 | ehci_writel(ehci, STS_IAA, &ehci->regs->status); | 298 | ehci_writel(ehci, STS_IAA, &ehci->regs->status); |
292 | ehci->reclaim_ready = 1; | ||
293 | } | 299 | } |
300 | ehci_writel(ehci, cmd & ~CMD_IAAD, &ehci->regs->command); | ||
301 | end_unlink_async(ehci); | ||
294 | } | 302 | } |
295 | 303 | ||
296 | /* stop async processing after it's idled a bit */ | 304 | spin_unlock_irqrestore(&ehci->lock, flags); |
305 | } | ||
306 | |||
307 | static void ehci_watchdog(unsigned long param) | ||
308 | { | ||
309 | struct ehci_hcd *ehci = (struct ehci_hcd *) param; | ||
310 | unsigned long flags; | ||
311 | |||
312 | spin_lock_irqsave(&ehci->lock, flags); | ||
313 | |||
314 | /* stop async processing after it's idled a bit */ | ||
297 | if (test_bit (TIMER_ASYNC_OFF, &ehci->actions)) | 315 | if (test_bit (TIMER_ASYNC_OFF, &ehci->actions)) |
298 | start_unlink_async (ehci, ehci->async); | 316 | start_unlink_async (ehci, ehci->async); |
299 | 317 | ||
@@ -363,8 +381,6 @@ static void ehci_port_power (struct ehci_hcd *ehci, int is_on) | |||
363 | static void ehci_work (struct ehci_hcd *ehci) | 381 | static void ehci_work (struct ehci_hcd *ehci) |
364 | { | 382 | { |
365 | timer_action_done (ehci, TIMER_IO_WATCHDOG); | 383 | timer_action_done (ehci, TIMER_IO_WATCHDOG); |
366 | if (ehci->reclaim_ready) | ||
367 | end_unlink_async (ehci); | ||
368 | 384 | ||
369 | /* another CPU may drop ehci->lock during a schedule scan while | 385 | /* another CPU may drop ehci->lock during a schedule scan while |
370 | * it reports urb completions. this flag guards against bogus | 386 | * it reports urb completions. this flag guards against bogus |
@@ -399,6 +415,7 @@ static void ehci_stop (struct usb_hcd *hcd) | |||
399 | 415 | ||
400 | /* no more interrupts ... */ | 416 | /* no more interrupts ... */ |
401 | del_timer_sync (&ehci->watchdog); | 417 | del_timer_sync (&ehci->watchdog); |
418 | del_timer_sync(&ehci->iaa_watchdog); | ||
402 | 419 | ||
403 | spin_lock_irq(&ehci->lock); | 420 | spin_lock_irq(&ehci->lock); |
404 | if (HC_IS_RUNNING (hcd->state)) | 421 | if (HC_IS_RUNNING (hcd->state)) |
@@ -447,6 +464,10 @@ static int ehci_init(struct usb_hcd *hcd) | |||
447 | ehci->watchdog.function = ehci_watchdog; | 464 | ehci->watchdog.function = ehci_watchdog; |
448 | ehci->watchdog.data = (unsigned long) ehci; | 465 | ehci->watchdog.data = (unsigned long) ehci; |
449 | 466 | ||
467 | init_timer(&ehci->iaa_watchdog); | ||
468 | ehci->iaa_watchdog.function = ehci_iaa_watchdog; | ||
469 | ehci->iaa_watchdog.data = (unsigned long) ehci; | ||
470 | |||
450 | /* | 471 | /* |
451 | * hw default: 1K periodic list heads, one per frame. | 472 | * hw default: 1K periodic list heads, one per frame. |
452 | * periodic_size can shrink by USBCMD update if hcc_params allows. | 473 | * periodic_size can shrink by USBCMD update if hcc_params allows. |
@@ -463,7 +484,6 @@ static int ehci_init(struct usb_hcd *hcd) | |||
463 | ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); | 484 | ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); |
464 | 485 | ||
465 | ehci->reclaim = NULL; | 486 | ehci->reclaim = NULL; |
466 | ehci->reclaim_ready = 0; | ||
467 | ehci->next_uframe = -1; | 487 | ehci->next_uframe = -1; |
468 | 488 | ||
469 | /* | 489 | /* |
@@ -654,8 +674,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
654 | /* complete the unlinking of some qh [4.15.2.3] */ | 674 | /* complete the unlinking of some qh [4.15.2.3] */ |
655 | if (status & STS_IAA) { | 675 | if (status & STS_IAA) { |
656 | COUNT (ehci->stats.reclaim); | 676 | COUNT (ehci->stats.reclaim); |
657 | ehci->reclaim_ready = 1; | 677 | end_unlink_async(ehci); |
658 | bh = 1; | ||
659 | } | 678 | } |
660 | 679 | ||
661 | /* remote wakeup [4.3.1] */ | 680 | /* remote wakeup [4.3.1] */ |
@@ -761,10 +780,16 @@ static int ehci_urb_enqueue ( | |||
761 | 780 | ||
762 | static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) | 781 | static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) |
763 | { | 782 | { |
764 | /* if we need to use IAA and it's busy, defer */ | 783 | /* failfast */ |
765 | if (qh->qh_state == QH_STATE_LINKED | 784 | if (!HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) |
766 | && ehci->reclaim | 785 | end_unlink_async(ehci); |
767 | && HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) { | 786 | |
787 | /* if it's not linked then there's nothing to do */ | ||
788 | if (qh->qh_state != QH_STATE_LINKED) | ||
789 | ; | ||
790 | |||
791 | /* defer till later if busy */ | ||
792 | else if (ehci->reclaim) { | ||
768 | struct ehci_qh *last; | 793 | struct ehci_qh *last; |
769 | 794 | ||
770 | for (last = ehci->reclaim; | 795 | for (last = ehci->reclaim; |
@@ -774,12 +799,8 @@ static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
774 | qh->qh_state = QH_STATE_UNLINK_WAIT; | 799 | qh->qh_state = QH_STATE_UNLINK_WAIT; |
775 | last->reclaim = qh; | 800 | last->reclaim = qh; |
776 | 801 | ||
777 | /* bypass IAA if the hc can't care */ | 802 | /* start IAA cycle */ |
778 | } else if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state) && ehci->reclaim) | 803 | } else |
779 | end_unlink_async (ehci); | ||
780 | |||
781 | /* something else might have unlinked the qh by now */ | ||
782 | if (qh->qh_state == QH_STATE_LINKED) | ||
783 | start_unlink_async (ehci, qh); | 804 | start_unlink_async (ehci, qh); |
784 | } | 805 | } |
785 | 806 | ||
@@ -806,7 +827,19 @@ static int ehci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
806 | qh = (struct ehci_qh *) urb->hcpriv; | 827 | qh = (struct ehci_qh *) urb->hcpriv; |
807 | if (!qh) | 828 | if (!qh) |
808 | break; | 829 | break; |
809 | unlink_async (ehci, qh); | 830 | switch (qh->qh_state) { |
831 | case QH_STATE_LINKED: | ||
832 | case QH_STATE_COMPLETING: | ||
833 | unlink_async(ehci, qh); | ||
834 | break; | ||
835 | case QH_STATE_UNLINK: | ||
836 | case QH_STATE_UNLINK_WAIT: | ||
837 | /* already started */ | ||
838 | break; | ||
839 | case QH_STATE_IDLE: | ||
840 | WARN_ON(1); | ||
841 | break; | ||
842 | } | ||
810 | break; | 843 | break; |
811 | 844 | ||
812 | case PIPE_INTERRUPT: | 845 | case PIPE_INTERRUPT: |
@@ -829,16 +862,16 @@ static int ehci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
829 | /* reschedule QH iff another request is queued */ | 862 | /* reschedule QH iff another request is queued */ |
830 | if (!list_empty (&qh->qtd_list) | 863 | if (!list_empty (&qh->qtd_list) |
831 | && HC_IS_RUNNING (hcd->state)) { | 864 | && HC_IS_RUNNING (hcd->state)) { |
832 | int status; | 865 | int schedule_status; |
833 | 866 | ||
834 | status = qh_schedule (ehci, qh); | 867 | schedule_status = qh_schedule (ehci, qh); |
835 | spin_unlock_irqrestore (&ehci->lock, flags); | 868 | spin_unlock_irqrestore (&ehci->lock, flags); |
836 | 869 | ||
837 | if (status != 0) { | 870 | if (schedule_status != 0) { |
838 | // shouldn't happen often, but ... | 871 | // shouldn't happen often, but ... |
839 | // FIXME kill those tds' urbs | 872 | // FIXME kill those tds' urbs |
840 | err ("can't reschedule qh %p, err %d", | 873 | err ("can't reschedule qh %p, err %d", |
841 | qh, status); | 874 | qh, schedule_status); |
842 | } | 875 | } |
843 | return status; | 876 | return status; |
844 | } | 877 | } |
@@ -898,6 +931,7 @@ rescan: | |||
898 | unlink_async (ehci, qh); | 931 | unlink_async (ehci, qh); |
899 | /* FALL THROUGH */ | 932 | /* FALL THROUGH */ |
900 | case QH_STATE_UNLINK: /* wait for hw to finish? */ | 933 | case QH_STATE_UNLINK: /* wait for hw to finish? */ |
934 | case QH_STATE_UNLINK_WAIT: | ||
901 | idle_timeout: | 935 | idle_timeout: |
902 | spin_unlock_irqrestore (&ehci->lock, flags); | 936 | spin_unlock_irqrestore (&ehci->lock, flags); |
903 | schedule_timeout_uninterruptible(1); | 937 | schedule_timeout_uninterruptible(1); |
@@ -959,11 +993,26 @@ MODULE_LICENSE ("GPL"); | |||
959 | #define PS3_SYSTEM_BUS_DRIVER ps3_ehci_driver | 993 | #define PS3_SYSTEM_BUS_DRIVER ps3_ehci_driver |
960 | #endif | 994 | #endif |
961 | 995 | ||
962 | #ifdef CONFIG_440EPX | 996 | #if defined(CONFIG_440EPX) && !defined(CONFIG_PPC_MERGE) |
963 | #include "ehci-ppc-soc.c" | 997 | #include "ehci-ppc-soc.c" |
964 | #define PLATFORM_DRIVER ehci_ppc_soc_driver | 998 | #define PLATFORM_DRIVER ehci_ppc_soc_driver |
965 | #endif | 999 | #endif |
966 | 1000 | ||
1001 | #ifdef CONFIG_USB_EHCI_HCD_PPC_OF | ||
1002 | #include "ehci-ppc-of.c" | ||
1003 | #define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver | ||
1004 | #endif | ||
1005 | |||
1006 | #ifdef CONFIG_ARCH_ORION | ||
1007 | #include "ehci-orion.c" | ||
1008 | #define PLATFORM_DRIVER ehci_orion_driver | ||
1009 | #endif | ||
1010 | |||
1011 | #ifdef CONFIG_ARCH_IXP4XX | ||
1012 | #include "ehci-ixp4xx.c" | ||
1013 | #define PLATFORM_DRIVER ixp4xx_ehci_driver | ||
1014 | #endif | ||
1015 | |||
967 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ | 1016 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ |
968 | !defined(PS3_SYSTEM_BUS_DRIVER) | 1017 | !defined(PS3_SYSTEM_BUS_DRIVER) |
969 | #error "missing bus glue for ehci-hcd" | 1018 | #error "missing bus glue for ehci-hcd" |
@@ -978,41 +1027,66 @@ static int __init ehci_hcd_init(void) | |||
978 | sizeof(struct ehci_qh), sizeof(struct ehci_qtd), | 1027 | sizeof(struct ehci_qh), sizeof(struct ehci_qtd), |
979 | sizeof(struct ehci_itd), sizeof(struct ehci_sitd)); | 1028 | sizeof(struct ehci_itd), sizeof(struct ehci_sitd)); |
980 | 1029 | ||
1030 | #ifdef DEBUG | ||
1031 | ehci_debug_root = debugfs_create_dir("ehci", NULL); | ||
1032 | if (!ehci_debug_root) | ||
1033 | return -ENOENT; | ||
1034 | #endif | ||
1035 | |||
981 | #ifdef PLATFORM_DRIVER | 1036 | #ifdef PLATFORM_DRIVER |
982 | retval = platform_driver_register(&PLATFORM_DRIVER); | 1037 | retval = platform_driver_register(&PLATFORM_DRIVER); |
983 | if (retval < 0) | 1038 | if (retval < 0) |
984 | return retval; | 1039 | goto clean0; |
985 | #endif | 1040 | #endif |
986 | 1041 | ||
987 | #ifdef PCI_DRIVER | 1042 | #ifdef PCI_DRIVER |
988 | retval = pci_register_driver(&PCI_DRIVER); | 1043 | retval = pci_register_driver(&PCI_DRIVER); |
989 | if (retval < 0) { | 1044 | if (retval < 0) |
990 | #ifdef PLATFORM_DRIVER | 1045 | goto clean1; |
991 | platform_driver_unregister(&PLATFORM_DRIVER); | ||
992 | #endif | ||
993 | return retval; | ||
994 | } | ||
995 | #endif | 1046 | #endif |
996 | 1047 | ||
997 | #ifdef PS3_SYSTEM_BUS_DRIVER | 1048 | #ifdef PS3_SYSTEM_BUS_DRIVER |
998 | retval = ps3_ehci_driver_register(&PS3_SYSTEM_BUS_DRIVER); | 1049 | retval = ps3_ehci_driver_register(&PS3_SYSTEM_BUS_DRIVER); |
999 | if (retval < 0) { | 1050 | if (retval < 0) |
1000 | #ifdef PLATFORM_DRIVER | 1051 | goto clean2; |
1001 | platform_driver_unregister(&PLATFORM_DRIVER); | 1052 | #endif |
1053 | |||
1054 | #ifdef OF_PLATFORM_DRIVER | ||
1055 | retval = of_register_platform_driver(&OF_PLATFORM_DRIVER); | ||
1056 | if (retval < 0) | ||
1057 | goto clean3; | ||
1058 | #endif | ||
1059 | return retval; | ||
1060 | |||
1061 | #ifdef OF_PLATFORM_DRIVER | ||
1062 | /* of_unregister_platform_driver(&OF_PLATFORM_DRIVER); */ | ||
1063 | clean3: | ||
1064 | #endif | ||
1065 | #ifdef PS3_SYSTEM_BUS_DRIVER | ||
1066 | ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); | ||
1067 | clean2: | ||
1002 | #endif | 1068 | #endif |
1003 | #ifdef PCI_DRIVER | 1069 | #ifdef PCI_DRIVER |
1004 | pci_unregister_driver(&PCI_DRIVER); | 1070 | pci_unregister_driver(&PCI_DRIVER); |
1071 | clean1: | ||
1005 | #endif | 1072 | #endif |
1006 | return retval; | 1073 | #ifdef PLATFORM_DRIVER |
1007 | } | 1074 | platform_driver_unregister(&PLATFORM_DRIVER); |
1075 | clean0: | ||
1076 | #endif | ||
1077 | #ifdef DEBUG | ||
1078 | debugfs_remove(ehci_debug_root); | ||
1079 | ehci_debug_root = NULL; | ||
1008 | #endif | 1080 | #endif |
1009 | |||
1010 | return retval; | 1081 | return retval; |
1011 | } | 1082 | } |
1012 | module_init(ehci_hcd_init); | 1083 | module_init(ehci_hcd_init); |
1013 | 1084 | ||
1014 | static void __exit ehci_hcd_cleanup(void) | 1085 | static void __exit ehci_hcd_cleanup(void) |
1015 | { | 1086 | { |
1087 | #ifdef OF_PLATFORM_DRIVER | ||
1088 | of_unregister_platform_driver(&OF_PLATFORM_DRIVER); | ||
1089 | #endif | ||
1016 | #ifdef PLATFORM_DRIVER | 1090 | #ifdef PLATFORM_DRIVER |
1017 | platform_driver_unregister(&PLATFORM_DRIVER); | 1091 | platform_driver_unregister(&PLATFORM_DRIVER); |
1018 | #endif | 1092 | #endif |
@@ -1022,6 +1096,9 @@ static void __exit ehci_hcd_cleanup(void) | |||
1022 | #ifdef PS3_SYSTEM_BUS_DRIVER | 1096 | #ifdef PS3_SYSTEM_BUS_DRIVER |
1023 | ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); | 1097 | ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); |
1024 | #endif | 1098 | #endif |
1099 | #ifdef DEBUG | ||
1100 | debugfs_remove(ehci_debug_root); | ||
1101 | #endif | ||
1025 | } | 1102 | } |
1026 | module_exit(ehci_hcd_cleanup); | 1103 | module_exit(ehci_hcd_cleanup); |
1027 | 1104 | ||
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 735db4aec831..40e8240b7851 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -123,6 +123,8 @@ static int ehci_bus_suspend (struct usb_hcd *hcd) | |||
123 | 123 | ||
124 | if (time_before (jiffies, ehci->next_statechange)) | 124 | if (time_before (jiffies, ehci->next_statechange)) |
125 | msleep(5); | 125 | msleep(5); |
126 | del_timer_sync(&ehci->watchdog); | ||
127 | del_timer_sync(&ehci->iaa_watchdog); | ||
126 | 128 | ||
127 | port = HCS_N_PORTS (ehci->hcs_params); | 129 | port = HCS_N_PORTS (ehci->hcs_params); |
128 | spin_lock_irq (&ehci->lock); | 130 | spin_lock_irq (&ehci->lock); |
@@ -134,7 +136,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd) | |||
134 | } | 136 | } |
135 | ehci->command = ehci_readl(ehci, &ehci->regs->command); | 137 | ehci->command = ehci_readl(ehci, &ehci->regs->command); |
136 | if (ehci->reclaim) | 138 | if (ehci->reclaim) |
137 | ehci->reclaim_ready = 1; | 139 | end_unlink_async(ehci); |
138 | ehci_work(ehci); | 140 | ehci_work(ehci); |
139 | 141 | ||
140 | /* Unlike other USB host controller types, EHCI doesn't have | 142 | /* Unlike other USB host controller types, EHCI doesn't have |
@@ -170,8 +172,11 @@ static int ehci_bus_suspend (struct usb_hcd *hcd) | |||
170 | } | 172 | } |
171 | } | 173 | } |
172 | 174 | ||
175 | /* Apparently some devices need a >= 1-uframe delay here */ | ||
176 | if (ehci->bus_suspended) | ||
177 | udelay(150); | ||
178 | |||
173 | /* turn off now-idle HC */ | 179 | /* turn off now-idle HC */ |
174 | del_timer_sync (&ehci->watchdog); | ||
175 | ehci_halt (ehci); | 180 | ehci_halt (ehci); |
176 | hcd->state = HC_STATE_SUSPENDED; | 181 | hcd->state = HC_STATE_SUSPENDED; |
177 | 182 | ||
@@ -291,14 +296,16 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
291 | /*-------------------------------------------------------------------------*/ | 296 | /*-------------------------------------------------------------------------*/ |
292 | 297 | ||
293 | /* Display the ports dedicated to the companion controller */ | 298 | /* Display the ports dedicated to the companion controller */ |
294 | static ssize_t show_companion(struct class_device *class_dev, char *buf) | 299 | static ssize_t show_companion(struct device *dev, |
300 | struct device_attribute *attr, | ||
301 | char *buf) | ||
295 | { | 302 | { |
296 | struct ehci_hcd *ehci; | 303 | struct ehci_hcd *ehci; |
297 | int nports, index, n; | 304 | int nports, index, n; |
298 | int count = PAGE_SIZE; | 305 | int count = PAGE_SIZE; |
299 | char *ptr = buf; | 306 | char *ptr = buf; |
300 | 307 | ||
301 | ehci = hcd_to_ehci(bus_to_hcd(class_get_devdata(class_dev))); | 308 | ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev))); |
302 | nports = HCS_N_PORTS(ehci->hcs_params); | 309 | nports = HCS_N_PORTS(ehci->hcs_params); |
303 | 310 | ||
304 | for (index = 0; index < nports; ++index) { | 311 | for (index = 0; index < nports; ++index) { |
@@ -312,40 +319,21 @@ static ssize_t show_companion(struct class_device *class_dev, char *buf) | |||
312 | } | 319 | } |
313 | 320 | ||
314 | /* | 321 | /* |
315 | * Dedicate or undedicate a port to the companion controller. | 322 | * Sets the owner of a port |
316 | * Syntax is "[-]portnum", where a leading '-' sign means | ||
317 | * return control of the port to the EHCI controller. | ||
318 | */ | 323 | */ |
319 | static ssize_t store_companion(struct class_device *class_dev, | 324 | static void set_owner(struct ehci_hcd *ehci, int portnum, int new_owner) |
320 | const char *buf, size_t count) | ||
321 | { | 325 | { |
322 | struct ehci_hcd *ehci; | ||
323 | int portnum, new_owner, try; | ||
324 | u32 __iomem *status_reg; | 326 | u32 __iomem *status_reg; |
325 | u32 port_status; | 327 | u32 port_status; |
328 | int try; | ||
326 | 329 | ||
327 | ehci = hcd_to_ehci(bus_to_hcd(class_get_devdata(class_dev))); | 330 | status_reg = &ehci->regs->port_status[portnum]; |
328 | new_owner = PORT_OWNER; /* Owned by companion */ | ||
329 | if (sscanf(buf, "%d", &portnum) != 1) | ||
330 | return -EINVAL; | ||
331 | if (portnum < 0) { | ||
332 | portnum = - portnum; | ||
333 | new_owner = 0; /* Owned by EHCI */ | ||
334 | } | ||
335 | if (portnum <= 0 || portnum > HCS_N_PORTS(ehci->hcs_params)) | ||
336 | return -ENOENT; | ||
337 | status_reg = &ehci->regs->port_status[--portnum]; | ||
338 | if (new_owner) | ||
339 | set_bit(portnum, &ehci->companion_ports); | ||
340 | else | ||
341 | clear_bit(portnum, &ehci->companion_ports); | ||
342 | 331 | ||
343 | /* | 332 | /* |
344 | * The controller won't set the OWNER bit if the port is | 333 | * The controller won't set the OWNER bit if the port is |
345 | * enabled, so this loop will sometimes require at least two | 334 | * enabled, so this loop will sometimes require at least two |
346 | * iterations: one to disable the port and one to set OWNER. | 335 | * iterations: one to disable the port and one to set OWNER. |
347 | */ | 336 | */ |
348 | |||
349 | for (try = 4; try > 0; --try) { | 337 | for (try = 4; try > 0; --try) { |
350 | spin_lock_irq(&ehci->lock); | 338 | spin_lock_irq(&ehci->lock); |
351 | port_status = ehci_readl(ehci, status_reg); | 339 | port_status = ehci_readl(ehci, status_reg); |
@@ -362,9 +350,39 @@ static ssize_t store_companion(struct class_device *class_dev, | |||
362 | if (try > 1) | 350 | if (try > 1) |
363 | msleep(5); | 351 | msleep(5); |
364 | } | 352 | } |
353 | } | ||
354 | |||
355 | /* | ||
356 | * Dedicate or undedicate a port to the companion controller. | ||
357 | * Syntax is "[-]portnum", where a leading '-' sign means | ||
358 | * return control of the port to the EHCI controller. | ||
359 | */ | ||
360 | static ssize_t store_companion(struct device *dev, | ||
361 | struct device_attribute *attr, | ||
362 | const char *buf, size_t count) | ||
363 | { | ||
364 | struct ehci_hcd *ehci; | ||
365 | int portnum, new_owner; | ||
366 | |||
367 | ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev))); | ||
368 | new_owner = PORT_OWNER; /* Owned by companion */ | ||
369 | if (sscanf(buf, "%d", &portnum) != 1) | ||
370 | return -EINVAL; | ||
371 | if (portnum < 0) { | ||
372 | portnum = - portnum; | ||
373 | new_owner = 0; /* Owned by EHCI */ | ||
374 | } | ||
375 | if (portnum <= 0 || portnum > HCS_N_PORTS(ehci->hcs_params)) | ||
376 | return -ENOENT; | ||
377 | portnum--; | ||
378 | if (new_owner) | ||
379 | set_bit(portnum, &ehci->companion_ports); | ||
380 | else | ||
381 | clear_bit(portnum, &ehci->companion_ports); | ||
382 | set_owner(ehci, portnum, new_owner); | ||
365 | return count; | 383 | return count; |
366 | } | 384 | } |
367 | static CLASS_DEVICE_ATTR(companion, 0644, show_companion, store_companion); | 385 | static DEVICE_ATTR(companion, 0644, show_companion, store_companion); |
368 | 386 | ||
369 | static inline void create_companion_file(struct ehci_hcd *ehci) | 387 | static inline void create_companion_file(struct ehci_hcd *ehci) |
370 | { | 388 | { |
@@ -372,16 +390,16 @@ static inline void create_companion_file(struct ehci_hcd *ehci) | |||
372 | 390 | ||
373 | /* with integrated TT there is no companion! */ | 391 | /* with integrated TT there is no companion! */ |
374 | if (!ehci_is_TDI(ehci)) | 392 | if (!ehci_is_TDI(ehci)) |
375 | i = class_device_create_file(ehci_to_hcd(ehci)->self.class_dev, | 393 | i = device_create_file(ehci_to_hcd(ehci)->self.dev, |
376 | &class_device_attr_companion); | 394 | &dev_attr_companion); |
377 | } | 395 | } |
378 | 396 | ||
379 | static inline void remove_companion_file(struct ehci_hcd *ehci) | 397 | static inline void remove_companion_file(struct ehci_hcd *ehci) |
380 | { | 398 | { |
381 | /* with integrated TT there is no companion! */ | 399 | /* with integrated TT there is no companion! */ |
382 | if (!ehci_is_TDI(ehci)) | 400 | if (!ehci_is_TDI(ehci)) |
383 | class_device_remove_file(ehci_to_hcd(ehci)->self.class_dev, | 401 | device_remove_file(ehci_to_hcd(ehci)->self.dev, |
384 | &class_device_attr_companion); | 402 | &dev_attr_companion); |
385 | } | 403 | } |
386 | 404 | ||
387 | 405 | ||
@@ -393,10 +411,8 @@ static int check_reset_complete ( | |||
393 | u32 __iomem *status_reg, | 411 | u32 __iomem *status_reg, |
394 | int port_status | 412 | int port_status |
395 | ) { | 413 | ) { |
396 | if (!(port_status & PORT_CONNECT)) { | 414 | if (!(port_status & PORT_CONNECT)) |
397 | ehci->reset_done [index] = 0; | ||
398 | return port_status; | 415 | return port_status; |
399 | } | ||
400 | 416 | ||
401 | /* if reset finished and it's still not enabled -- handoff */ | 417 | /* if reset finished and it's still not enabled -- handoff */ |
402 | if (!(port_status & PORT_PE)) { | 418 | if (!(port_status & PORT_PE)) { |
@@ -475,8 +491,6 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
475 | * controller by the user. | 491 | * controller by the user. |
476 | */ | 492 | */ |
477 | 493 | ||
478 | if (!(temp & PORT_CONNECT)) | ||
479 | ehci->reset_done [i] = 0; | ||
480 | if ((temp & mask) != 0 | 494 | if ((temp & mask) != 0 |
481 | || ((temp & PORT_RESUME) != 0 | 495 | || ((temp & PORT_RESUME) != 0 |
482 | && time_after_eq(jiffies, | 496 | && time_after_eq(jiffies, |
@@ -864,3 +878,13 @@ error: | |||
864 | spin_unlock_irqrestore (&ehci->lock, flags); | 878 | spin_unlock_irqrestore (&ehci->lock, flags); |
865 | return retval; | 879 | return retval; |
866 | } | 880 | } |
881 | |||
882 | static void ehci_relinquish_port(struct usb_hcd *hcd, int portnum) | ||
883 | { | ||
884 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
885 | |||
886 | if (ehci_is_TDI(ehci)) | ||
887 | return; | ||
888 | set_owner(ehci, --portnum, PORT_OWNER); | ||
889 | } | ||
890 | |||
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c new file mode 100644 index 000000000000..3041d8f055f4 --- /dev/null +++ b/drivers/usb/host/ehci-ixp4xx.c | |||
@@ -0,0 +1,152 @@ | |||
1 | /* | ||
2 | * IXP4XX EHCI Host Controller Driver | ||
3 | * | ||
4 | * Author: Vladimir Barinov <vbarinov@ru.mvista.com> | ||
5 | * | ||
6 | * Based on "ehci-fsl.c" by Randy Vinson <rvinson@mvista.com> | ||
7 | * | ||
8 | * 2007 (c) MontaVista Software, Inc. This file is licensed under | ||
9 | * the terms of the GNU General Public License version 2. This program | ||
10 | * is licensed "as is" without any warranty of any kind, whether express | ||
11 | * or implied. | ||
12 | */ | ||
13 | |||
14 | #include <linux/platform_device.h> | ||
15 | |||
16 | static int ixp4xx_ehci_init(struct usb_hcd *hcd) | ||
17 | { | ||
18 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
19 | int retval = 0; | ||
20 | |||
21 | ehci->big_endian_desc = 1; | ||
22 | ehci->big_endian_mmio = 1; | ||
23 | |||
24 | ehci->caps = hcd->regs + 0x100; | ||
25 | ehci->regs = hcd->regs + 0x100 | ||
26 | + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); | ||
27 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
28 | |||
29 | ehci->is_tdi_rh_tt = 1; | ||
30 | ehci_reset(ehci); | ||
31 | |||
32 | retval = ehci_init(hcd); | ||
33 | if (retval) | ||
34 | return retval; | ||
35 | |||
36 | ehci_port_power(ehci, 0); | ||
37 | |||
38 | return retval; | ||
39 | } | ||
40 | |||
41 | static const struct hc_driver ixp4xx_ehci_hc_driver = { | ||
42 | .description = hcd_name, | ||
43 | .product_desc = "IXP4XX EHCI Host Controller", | ||
44 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
45 | .irq = ehci_irq, | ||
46 | .flags = HCD_MEMORY | HCD_USB2, | ||
47 | .reset = ixp4xx_ehci_init, | ||
48 | .start = ehci_run, | ||
49 | .stop = ehci_stop, | ||
50 | .shutdown = ehci_shutdown, | ||
51 | .urb_enqueue = ehci_urb_enqueue, | ||
52 | .urb_dequeue = ehci_urb_dequeue, | ||
53 | .endpoint_disable = ehci_endpoint_disable, | ||
54 | .get_frame_number = ehci_get_frame, | ||
55 | .hub_status_data = ehci_hub_status_data, | ||
56 | .hub_control = ehci_hub_control, | ||
57 | #if defined(CONFIG_PM) | ||
58 | .bus_suspend = ehci_bus_suspend, | ||
59 | .bus_resume = ehci_bus_resume, | ||
60 | #endif | ||
61 | }; | ||
62 | |||
63 | static int ixp4xx_ehci_probe(struct platform_device *pdev) | ||
64 | { | ||
65 | struct usb_hcd *hcd; | ||
66 | const struct hc_driver *driver = &ixp4xx_ehci_hc_driver; | ||
67 | struct resource *res; | ||
68 | int irq; | ||
69 | int retval; | ||
70 | |||
71 | if (usb_disabled()) | ||
72 | return -ENODEV; | ||
73 | |||
74 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
75 | if (!res) { | ||
76 | dev_err(&pdev->dev, | ||
77 | "Found HC with no IRQ. Check %s setup!\n", | ||
78 | pdev->dev.bus_id); | ||
79 | return -ENODEV; | ||
80 | } | ||
81 | irq = res->start; | ||
82 | |||
83 | hcd = usb_create_hcd(driver, &pdev->dev, pdev->dev.bus_id); | ||
84 | if (!hcd) { | ||
85 | retval = -ENOMEM; | ||
86 | goto fail_create_hcd; | ||
87 | } | ||
88 | |||
89 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
90 | if (!res) { | ||
91 | dev_err(&pdev->dev, | ||
92 | "Found HC with no register addr. Check %s setup!\n", | ||
93 | pdev->dev.bus_id); | ||
94 | retval = -ENODEV; | ||
95 | goto fail_request_resource; | ||
96 | } | ||
97 | hcd->rsrc_start = res->start; | ||
98 | hcd->rsrc_len = res->end - res->start + 1; | ||
99 | |||
100 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | ||
101 | driver->description)) { | ||
102 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
103 | retval = -EBUSY; | ||
104 | goto fail_request_resource; | ||
105 | } | ||
106 | |||
107 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | ||
108 | if (hcd->regs == NULL) { | ||
109 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
110 | retval = -EFAULT; | ||
111 | goto fail_ioremap; | ||
112 | } | ||
113 | |||
114 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
115 | if (retval) | ||
116 | goto fail_add_hcd; | ||
117 | |||
118 | return retval; | ||
119 | |||
120 | fail_add_hcd: | ||
121 | iounmap(hcd->regs); | ||
122 | fail_ioremap: | ||
123 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
124 | fail_request_resource: | ||
125 | usb_put_hcd(hcd); | ||
126 | fail_create_hcd: | ||
127 | dev_err(&pdev->dev, "init %s fail, %d\n", pdev->dev.bus_id, retval); | ||
128 | return retval; | ||
129 | } | ||
130 | |||
131 | static int ixp4xx_ehci_remove(struct platform_device *pdev) | ||
132 | { | ||
133 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
134 | |||
135 | usb_remove_hcd(hcd); | ||
136 | iounmap(hcd->regs); | ||
137 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
138 | usb_put_hcd(hcd); | ||
139 | |||
140 | return 0; | ||
141 | } | ||
142 | |||
143 | MODULE_ALIAS("ixp4xx-ehci"); | ||
144 | |||
145 | static struct platform_driver ixp4xx_ehci_driver = { | ||
146 | .probe = ixp4xx_ehci_probe, | ||
147 | .remove = ixp4xx_ehci_remove, | ||
148 | .driver = { | ||
149 | .name = "ixp4xx-ehci", | ||
150 | .bus = &platform_bus_type | ||
151 | }, | ||
152 | }; | ||
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c new file mode 100644 index 000000000000..e129981f139f --- /dev/null +++ b/drivers/usb/host/ehci-orion.c | |||
@@ -0,0 +1,272 @@ | |||
1 | /* | ||
2 | * drivers/usb/host/ehci-orion.c | ||
3 | * | ||
4 | * Tzachi Perelstein <tzachi@marvell.com> | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public | ||
7 | * License version 2. This program is licensed "as is" without any | ||
8 | * warranty of any kind, whether express or implied. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <asm/arch/orion.h> | ||
15 | |||
16 | #define rdl(off) __raw_readl(hcd->regs + (off)) | ||
17 | #define wrl(off, val) __raw_writel((val), hcd->regs + (off)) | ||
18 | |||
19 | #define USB_CAUSE 0x310 | ||
20 | #define USB_MASK 0x314 | ||
21 | #define USB_CMD 0x140 | ||
22 | #define USB_MODE 0x1a8 | ||
23 | #define USB_IPG 0x360 | ||
24 | #define USB_PHY_PWR_CTRL 0x400 | ||
25 | #define USB_PHY_TX_CTRL 0x420 | ||
26 | #define USB_PHY_RX_CTRL 0x430 | ||
27 | #define USB_PHY_IVREF_CTRL 0x440 | ||
28 | #define USB_PHY_TST_GRP_CTRL 0x450 | ||
29 | |||
30 | /* | ||
31 | * Implement Orion USB controller specification guidelines | ||
32 | */ | ||
33 | static void orion_usb_setup(struct usb_hcd *hcd) | ||
34 | { | ||
35 | /* | ||
36 | * Clear interrupt cause and mask | ||
37 | */ | ||
38 | wrl(USB_CAUSE, 0); | ||
39 | wrl(USB_MASK, 0); | ||
40 | |||
41 | /* | ||
42 | * Reset controller | ||
43 | */ | ||
44 | wrl(USB_CMD, rdl(USB_CMD) | 0x2); | ||
45 | while (rdl(USB_CMD) & 0x2); | ||
46 | |||
47 | /* | ||
48 | * GL# USB-10: Set IPG for non start of frame packets | ||
49 | * Bits[14:8]=0xc | ||
50 | */ | ||
51 | wrl(USB_IPG, (rdl(USB_IPG) & ~0x7f00) | 0xc00); | ||
52 | |||
53 | /* | ||
54 | * GL# USB-9: USB 2.0 Power Control | ||
55 | * BG_VSEL[7:6]=0x1 | ||
56 | */ | ||
57 | wrl(USB_PHY_PWR_CTRL, (rdl(USB_PHY_PWR_CTRL) & ~0xc0)| 0x40); | ||
58 | |||
59 | /* | ||
60 | * GL# USB-1: USB PHY Tx Control - force calibration to '8' | ||
61 | * TXDATA_BLOCK_EN[21]=0x1, EXT_RCAL_EN[13]=0x1, IMP_CAL[6:3]=0x8 | ||
62 | */ | ||
63 | wrl(USB_PHY_TX_CTRL, (rdl(USB_PHY_TX_CTRL) & ~0x78) | 0x202040); | ||
64 | |||
65 | /* | ||
66 | * GL# USB-3 GL# USB-9: USB PHY Rx Control | ||
67 | * RXDATA_BLOCK_LENGHT[31:30]=0x3, EDGE_DET_SEL[27:26]=0, | ||
68 | * CDR_FASTLOCK_EN[21]=0, DISCON_THRESHOLD[9:8]=0, SQ_THRESH[7:4]=0x1 | ||
69 | */ | ||
70 | wrl(USB_PHY_RX_CTRL, (rdl(USB_PHY_RX_CTRL) & ~0xc2003f0) | 0xc0000010); | ||
71 | |||
72 | /* | ||
73 | * GL# USB-3 GL# USB-9: USB PHY IVREF Control | ||
74 | * PLLVDD12[1:0]=0x2, RXVDD[5:4]=0x3, Reserved[19]=0 | ||
75 | */ | ||
76 | wrl(USB_PHY_IVREF_CTRL, (rdl(USB_PHY_IVREF_CTRL) & ~0x80003 ) | 0x32); | ||
77 | |||
78 | /* | ||
79 | * GL# USB-3 GL# USB-9: USB PHY Test Group Control | ||
80 | * REG_FIFO_SQ_RST[15]=0 | ||
81 | */ | ||
82 | wrl(USB_PHY_TST_GRP_CTRL, rdl(USB_PHY_TST_GRP_CTRL) & ~0x8000); | ||
83 | |||
84 | /* | ||
85 | * Stop and reset controller | ||
86 | */ | ||
87 | wrl(USB_CMD, rdl(USB_CMD) & ~0x1); | ||
88 | wrl(USB_CMD, rdl(USB_CMD) | 0x2); | ||
89 | while (rdl(USB_CMD) & 0x2); | ||
90 | |||
91 | /* | ||
92 | * GL# USB-5 Streaming disable REG_USB_MODE[4]=1 | ||
93 | * TBD: This need to be done after each reset! | ||
94 | * GL# USB-4 Setup USB Host mode | ||
95 | */ | ||
96 | wrl(USB_MODE, 0x13); | ||
97 | } | ||
98 | |||
99 | static int ehci_orion_setup(struct usb_hcd *hcd) | ||
100 | { | ||
101 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
102 | int retval; | ||
103 | |||
104 | retval = ehci_halt(ehci); | ||
105 | if (retval) | ||
106 | return retval; | ||
107 | |||
108 | /* | ||
109 | * data structure init | ||
110 | */ | ||
111 | retval = ehci_init(hcd); | ||
112 | if (retval) | ||
113 | return retval; | ||
114 | |||
115 | ehci_reset(ehci); | ||
116 | ehci_port_power(ehci, 0); | ||
117 | |||
118 | return retval; | ||
119 | } | ||
120 | |||
121 | static const struct hc_driver ehci_orion_hc_driver = { | ||
122 | .description = hcd_name, | ||
123 | .product_desc = "Marvell Orion EHCI", | ||
124 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
125 | |||
126 | /* | ||
127 | * generic hardware linkage | ||
128 | */ | ||
129 | .irq = ehci_irq, | ||
130 | .flags = HCD_MEMORY | HCD_USB2, | ||
131 | |||
132 | /* | ||
133 | * basic lifecycle operations | ||
134 | */ | ||
135 | .reset = ehci_orion_setup, | ||
136 | .start = ehci_run, | ||
137 | #ifdef CONFIG_PM | ||
138 | .suspend = ehci_bus_suspend, | ||
139 | .resume = ehci_bus_resume, | ||
140 | #endif | ||
141 | .stop = ehci_stop, | ||
142 | .shutdown = ehci_shutdown, | ||
143 | |||
144 | /* | ||
145 | * managing i/o requests and associated device resources | ||
146 | */ | ||
147 | .urb_enqueue = ehci_urb_enqueue, | ||
148 | .urb_dequeue = ehci_urb_dequeue, | ||
149 | .endpoint_disable = ehci_endpoint_disable, | ||
150 | |||
151 | /* | ||
152 | * scheduling support | ||
153 | */ | ||
154 | .get_frame_number = ehci_get_frame, | ||
155 | |||
156 | /* | ||
157 | * root hub support | ||
158 | */ | ||
159 | .hub_status_data = ehci_hub_status_data, | ||
160 | .hub_control = ehci_hub_control, | ||
161 | .bus_suspend = ehci_bus_suspend, | ||
162 | .bus_resume = ehci_bus_resume, | ||
163 | }; | ||
164 | |||
165 | static int __init ehci_orion_drv_probe(struct platform_device *pdev) | ||
166 | { | ||
167 | struct resource *res; | ||
168 | struct usb_hcd *hcd; | ||
169 | struct ehci_hcd *ehci; | ||
170 | void __iomem *regs; | ||
171 | int irq, err; | ||
172 | |||
173 | if (usb_disabled()) | ||
174 | return -ENODEV; | ||
175 | |||
176 | pr_debug("Initializing Orion-SoC USB Host Controller\n"); | ||
177 | |||
178 | irq = platform_get_irq(pdev, 0); | ||
179 | if (irq <= 0) { | ||
180 | dev_err(&pdev->dev, | ||
181 | "Found HC with no IRQ. Check %s setup!\n", | ||
182 | pdev->dev.bus_id); | ||
183 | err = -ENODEV; | ||
184 | goto err1; | ||
185 | } | ||
186 | |||
187 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
188 | if (!res) { | ||
189 | dev_err(&pdev->dev, | ||
190 | "Found HC with no register addr. Check %s setup!\n", | ||
191 | pdev->dev.bus_id); | ||
192 | err = -ENODEV; | ||
193 | goto err1; | ||
194 | } | ||
195 | |||
196 | if (!request_mem_region(res->start, res->end - res->start + 1, | ||
197 | ehci_orion_hc_driver.description)) { | ||
198 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
199 | err = -EBUSY; | ||
200 | goto err1; | ||
201 | } | ||
202 | |||
203 | regs = ioremap(res->start, res->end - res->start + 1); | ||
204 | if (regs == NULL) { | ||
205 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
206 | err = -EFAULT; | ||
207 | goto err2; | ||
208 | } | ||
209 | |||
210 | hcd = usb_create_hcd(&ehci_orion_hc_driver, | ||
211 | &pdev->dev, pdev->dev.bus_id); | ||
212 | if (!hcd) { | ||
213 | err = -ENOMEM; | ||
214 | goto err3; | ||
215 | } | ||
216 | |||
217 | hcd->rsrc_start = res->start; | ||
218 | hcd->rsrc_len = res->end - res->start + 1; | ||
219 | hcd->regs = regs; | ||
220 | |||
221 | ehci = hcd_to_ehci(hcd); | ||
222 | ehci->caps = hcd->regs + 0x100; | ||
223 | ehci->regs = hcd->regs + 0x100 + | ||
224 | HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); | ||
225 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
226 | ehci->is_tdi_rh_tt = 1; | ||
227 | ehci->sbrn = 0x20; | ||
228 | |||
229 | /* | ||
230 | * setup Orion USB controller | ||
231 | */ | ||
232 | orion_usb_setup(hcd); | ||
233 | |||
234 | err = usb_add_hcd(hcd, irq, IRQF_SHARED | IRQF_DISABLED); | ||
235 | if (err) | ||
236 | goto err4; | ||
237 | |||
238 | return 0; | ||
239 | |||
240 | err4: | ||
241 | usb_put_hcd(hcd); | ||
242 | err3: | ||
243 | iounmap(regs); | ||
244 | err2: | ||
245 | release_mem_region(res->start, res->end - res->start + 1); | ||
246 | err1: | ||
247 | dev_err(&pdev->dev, "init %s fail, %d\n", | ||
248 | pdev->dev.bus_id, err); | ||
249 | |||
250 | return err; | ||
251 | } | ||
252 | |||
253 | static int __exit ehci_orion_drv_remove(struct platform_device *pdev) | ||
254 | { | ||
255 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
256 | |||
257 | usb_remove_hcd(hcd); | ||
258 | iounmap(hcd->regs); | ||
259 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
260 | usb_put_hcd(hcd); | ||
261 | |||
262 | return 0; | ||
263 | } | ||
264 | |||
265 | MODULE_ALIAS("platform:orion-ehci"); | ||
266 | |||
267 | static struct platform_driver ehci_orion_driver = { | ||
268 | .probe = ehci_orion_drv_probe, | ||
269 | .remove = __exit_p(ehci_orion_drv_remove), | ||
270 | .shutdown = usb_hcd_platform_shutdown, | ||
271 | .driver.name = "orion-ehci", | ||
272 | }; | ||
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index ad0d4965f2fb..3ba01664f821 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c | |||
@@ -305,7 +305,7 @@ static int ehci_pci_resume(struct usb_hcd *hcd) | |||
305 | /* emptying the schedule aborts any urbs */ | 305 | /* emptying the schedule aborts any urbs */ |
306 | spin_lock_irq(&ehci->lock); | 306 | spin_lock_irq(&ehci->lock); |
307 | if (ehci->reclaim) | 307 | if (ehci->reclaim) |
308 | ehci->reclaim_ready = 1; | 308 | end_unlink_async(ehci); |
309 | ehci_work(ehci); | 309 | ehci_work(ehci); |
310 | spin_unlock_irq(&ehci->lock); | 310 | spin_unlock_irq(&ehci->lock); |
311 | 311 | ||
@@ -364,6 +364,7 @@ static const struct hc_driver ehci_pci_hc_driver = { | |||
364 | .hub_control = ehci_hub_control, | 364 | .hub_control = ehci_hub_control, |
365 | .bus_suspend = ehci_bus_suspend, | 365 | .bus_suspend = ehci_bus_suspend, |
366 | .bus_resume = ehci_bus_resume, | 366 | .bus_resume = ehci_bus_resume, |
367 | .relinquish_port = ehci_relinquish_port, | ||
367 | }; | 368 | }; |
368 | 369 | ||
369 | /*-------------------------------------------------------------------------*/ | 370 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c new file mode 100644 index 000000000000..ee305b1f99ff --- /dev/null +++ b/drivers/usb/host/ehci-ppc-of.c | |||
@@ -0,0 +1,238 @@ | |||
1 | /* | ||
2 | * EHCI HCD (Host Controller Driver) for USB. | ||
3 | * | ||
4 | * Bus Glue for PPC On-Chip EHCI driver on the of_platform bus | ||
5 | * Tested on AMCC PPC 440EPx | ||
6 | * | ||
7 | * Valentine Barshak <vbarshak@ru.mvista.com> | ||
8 | * | ||
9 | * Based on "ehci-ppc-soc.c" by Stefan Roese <sr@denx.de> | ||
10 | * and "ohci-ppc-of.c" by Sylvain Munaut <tnt@246tNt.com> | ||
11 | * | ||
12 | * This file is licenced under the GPL. | ||
13 | */ | ||
14 | |||
15 | #include <linux/signal.h> | ||
16 | |||
17 | #include <linux/of.h> | ||
18 | #include <linux/of_platform.h> | ||
19 | |||
20 | /* called during probe() after chip reset completes */ | ||
21 | static int ehci_ppc_of_setup(struct usb_hcd *hcd) | ||
22 | { | ||
23 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
24 | int retval; | ||
25 | |||
26 | retval = ehci_halt(ehci); | ||
27 | if (retval) | ||
28 | return retval; | ||
29 | |||
30 | retval = ehci_init(hcd); | ||
31 | if (retval) | ||
32 | return retval; | ||
33 | |||
34 | ehci->sbrn = 0x20; | ||
35 | return ehci_reset(ehci); | ||
36 | } | ||
37 | |||
38 | |||
39 | static const struct hc_driver ehci_ppc_of_hc_driver = { | ||
40 | .description = hcd_name, | ||
41 | .product_desc = "OF EHCI", | ||
42 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
43 | |||
44 | /* | ||
45 | * generic hardware linkage | ||
46 | */ | ||
47 | .irq = ehci_irq, | ||
48 | .flags = HCD_MEMORY | HCD_USB2, | ||
49 | |||
50 | /* | ||
51 | * basic lifecycle operations | ||
52 | */ | ||
53 | .reset = ehci_ppc_of_setup, | ||
54 | .start = ehci_run, | ||
55 | .stop = ehci_stop, | ||
56 | .shutdown = ehci_shutdown, | ||
57 | |||
58 | /* | ||
59 | * managing i/o requests and associated device resources | ||
60 | */ | ||
61 | .urb_enqueue = ehci_urb_enqueue, | ||
62 | .urb_dequeue = ehci_urb_dequeue, | ||
63 | .endpoint_disable = ehci_endpoint_disable, | ||
64 | |||
65 | /* | ||
66 | * scheduling support | ||
67 | */ | ||
68 | .get_frame_number = ehci_get_frame, | ||
69 | |||
70 | /* | ||
71 | * root hub support | ||
72 | */ | ||
73 | .hub_status_data = ehci_hub_status_data, | ||
74 | .hub_control = ehci_hub_control, | ||
75 | #ifdef CONFIG_PM | ||
76 | .bus_suspend = ehci_bus_suspend, | ||
77 | .bus_resume = ehci_bus_resume, | ||
78 | #endif | ||
79 | }; | ||
80 | |||
81 | |||
82 | /* | ||
83 | * 440EPx Errata USBH_3 | ||
84 | * Fix: Enable Break Memory Transfer (BMT) in INSNREG3 | ||
85 | */ | ||
86 | #define PPC440EPX_EHCI0_INSREG_BMT (0x1 << 0) | ||
87 | static int __devinit | ||
88 | ppc44x_enable_bmt(struct device_node *dn) | ||
89 | { | ||
90 | __iomem u32 *insreg_virt; | ||
91 | |||
92 | insreg_virt = of_iomap(dn, 1); | ||
93 | if (!insreg_virt) | ||
94 | return -EINVAL; | ||
95 | |||
96 | out_be32(insreg_virt + 3, PPC440EPX_EHCI0_INSREG_BMT); | ||
97 | |||
98 | iounmap(insreg_virt); | ||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | |||
103 | static int __devinit | ||
104 | ehci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match) | ||
105 | { | ||
106 | struct device_node *dn = op->node; | ||
107 | struct usb_hcd *hcd; | ||
108 | struct ehci_hcd *ehci; | ||
109 | struct resource res; | ||
110 | int irq; | ||
111 | int rv; | ||
112 | |||
113 | if (usb_disabled()) | ||
114 | return -ENODEV; | ||
115 | |||
116 | dev_dbg(&op->dev, "initializing PPC-OF USB Controller\n"); | ||
117 | |||
118 | rv = of_address_to_resource(dn, 0, &res); | ||
119 | if (rv) | ||
120 | return rv; | ||
121 | |||
122 | hcd = usb_create_hcd(&ehci_ppc_of_hc_driver, &op->dev, "PPC-OF USB"); | ||
123 | if (!hcd) | ||
124 | return -ENOMEM; | ||
125 | |||
126 | hcd->rsrc_start = res.start; | ||
127 | hcd->rsrc_len = res.end - res.start + 1; | ||
128 | |||
129 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
130 | printk(KERN_ERR __FILE__ ": request_mem_region failed\n"); | ||
131 | rv = -EBUSY; | ||
132 | goto err_rmr; | ||
133 | } | ||
134 | |||
135 | irq = irq_of_parse_and_map(dn, 0); | ||
136 | if (irq == NO_IRQ) { | ||
137 | printk(KERN_ERR __FILE__ ": irq_of_parse_and_map failed\n"); | ||
138 | rv = -EBUSY; | ||
139 | goto err_irq; | ||
140 | } | ||
141 | |||
142 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
143 | if (!hcd->regs) { | ||
144 | printk(KERN_ERR __FILE__ ": ioremap failed\n"); | ||
145 | rv = -ENOMEM; | ||
146 | goto err_ioremap; | ||
147 | } | ||
148 | |||
149 | ehci = hcd_to_ehci(hcd); | ||
150 | |||
151 | if (of_get_property(dn, "big-endian", NULL)) { | ||
152 | ehci->big_endian_mmio = 1; | ||
153 | ehci->big_endian_desc = 1; | ||
154 | } | ||
155 | if (of_get_property(dn, "big-endian-regs", NULL)) | ||
156 | ehci->big_endian_mmio = 1; | ||
157 | if (of_get_property(dn, "big-endian-desc", NULL)) | ||
158 | ehci->big_endian_desc = 1; | ||
159 | |||
160 | ehci->caps = hcd->regs; | ||
161 | ehci->regs = hcd->regs + | ||
162 | HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); | ||
163 | |||
164 | /* cache this readonly data; minimize chip reads */ | ||
165 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
166 | |||
167 | if (of_device_is_compatible(dn, "ibm,usb-ehci-440epx")) { | ||
168 | rv = ppc44x_enable_bmt(dn); | ||
169 | ehci_dbg(ehci, "Break Memory Transfer (BMT) is %senabled!\n", | ||
170 | rv ? "NOT ": ""); | ||
171 | } | ||
172 | |||
173 | rv = usb_add_hcd(hcd, irq, 0); | ||
174 | if (rv == 0) | ||
175 | return 0; | ||
176 | |||
177 | iounmap(hcd->regs); | ||
178 | err_ioremap: | ||
179 | irq_dispose_mapping(irq); | ||
180 | err_irq: | ||
181 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
182 | err_rmr: | ||
183 | usb_put_hcd(hcd); | ||
184 | |||
185 | return rv; | ||
186 | } | ||
187 | |||
188 | |||
189 | static int ehci_hcd_ppc_of_remove(struct of_device *op) | ||
190 | { | ||
191 | struct usb_hcd *hcd = dev_get_drvdata(&op->dev); | ||
192 | dev_set_drvdata(&op->dev, NULL); | ||
193 | |||
194 | dev_dbg(&op->dev, "stopping PPC-OF USB Controller\n"); | ||
195 | |||
196 | usb_remove_hcd(hcd); | ||
197 | |||
198 | iounmap(hcd->regs); | ||
199 | irq_dispose_mapping(hcd->irq); | ||
200 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
201 | |||
202 | usb_put_hcd(hcd); | ||
203 | |||
204 | return 0; | ||
205 | } | ||
206 | |||
207 | |||
208 | static int ehci_hcd_ppc_of_shutdown(struct of_device *op) | ||
209 | { | ||
210 | struct usb_hcd *hcd = dev_get_drvdata(&op->dev); | ||
211 | |||
212 | if (hcd->driver->shutdown) | ||
213 | hcd->driver->shutdown(hcd); | ||
214 | |||
215 | return 0; | ||
216 | } | ||
217 | |||
218 | |||
219 | static struct of_device_id ehci_hcd_ppc_of_match[] = { | ||
220 | { | ||
221 | .compatible = "usb-ehci", | ||
222 | }, | ||
223 | {}, | ||
224 | }; | ||
225 | MODULE_DEVICE_TABLE(of, ehci_hcd_ppc_of_match); | ||
226 | |||
227 | |||
228 | static struct of_platform_driver ehci_hcd_ppc_of_driver = { | ||
229 | .name = "ppc-of-ehci", | ||
230 | .match_table = ehci_hcd_ppc_of_match, | ||
231 | .probe = ehci_hcd_ppc_of_probe, | ||
232 | .remove = ehci_hcd_ppc_of_remove, | ||
233 | .shutdown = ehci_hcd_ppc_of_shutdown, | ||
234 | .driver = { | ||
235 | .name = "ppc-of-ehci", | ||
236 | .owner = THIS_MODULE, | ||
237 | }, | ||
238 | }; | ||
diff --git a/drivers/usb/host/ehci-ppc-soc.c b/drivers/usb/host/ehci-ppc-soc.c index 452d4b1bc859..a3249078c808 100644 --- a/drivers/usb/host/ehci-ppc-soc.c +++ b/drivers/usb/host/ehci-ppc-soc.c | |||
@@ -162,6 +162,7 @@ static const struct hc_driver ehci_ppc_soc_hc_driver = { | |||
162 | .hub_control = ehci_hub_control, | 162 | .hub_control = ehci_hub_control, |
163 | .bus_suspend = ehci_bus_suspend, | 163 | .bus_suspend = ehci_bus_suspend, |
164 | .bus_resume = ehci_bus_resume, | 164 | .bus_resume = ehci_bus_resume, |
165 | .relinquish_port = ehci_relinquish_port, | ||
165 | }; | 166 | }; |
166 | 167 | ||
167 | static int ehci_hcd_ppc_soc_drv_probe(struct platform_device *pdev) | 168 | static int ehci_hcd_ppc_soc_drv_probe(struct platform_device *pdev) |
diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c index 03a6b2f4e6ed..bbda58eb8813 100644 --- a/drivers/usb/host/ehci-ps3.c +++ b/drivers/usb/host/ehci-ps3.c | |||
@@ -72,6 +72,7 @@ static const struct hc_driver ps3_ehci_hc_driver = { | |||
72 | .bus_suspend = ehci_bus_suspend, | 72 | .bus_suspend = ehci_bus_suspend, |
73 | .bus_resume = ehci_bus_resume, | 73 | .bus_resume = ehci_bus_resume, |
74 | #endif | 74 | #endif |
75 | .relinquish_port = ehci_relinquish_port, | ||
75 | }; | 76 | }; |
76 | 77 | ||
77 | static int ps3_ehci_probe(struct ps3_system_bus_device *dev) | 78 | static int ps3_ehci_probe(struct ps3_system_bus_device *dev) |
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index b10f39c047e9..776a97f33914 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c | |||
@@ -198,7 +198,8 @@ static int qtd_copy_status ( | |||
198 | 198 | ||
199 | /* if async CSPLIT failed, try cleaning out the TT buffer */ | 199 | /* if async CSPLIT failed, try cleaning out the TT buffer */ |
200 | if (status != -EPIPE | 200 | if (status != -EPIPE |
201 | && urb->dev->tt && !usb_pipeint (urb->pipe) | 201 | && urb->dev->tt |
202 | && !usb_pipeint(urb->pipe) | ||
202 | && ((token & QTD_STS_MMF) != 0 | 203 | && ((token & QTD_STS_MMF) != 0 |
203 | || QTD_CERR(token) == 0) | 204 | || QTD_CERR(token) == 0) |
204 | && (!ehci_is_TDI(ehci) | 205 | && (!ehci_is_TDI(ehci) |
@@ -211,6 +212,9 @@ static int qtd_copy_status ( | |||
211 | urb->dev->ttport, urb->dev->devnum, | 212 | urb->dev->ttport, urb->dev->devnum, |
212 | usb_pipeendpoint (urb->pipe), token); | 213 | usb_pipeendpoint (urb->pipe), token); |
213 | #endif /* DEBUG */ | 214 | #endif /* DEBUG */ |
215 | /* REVISIT ARC-derived cores don't clear the root | ||
216 | * hub TT buffer in this way... | ||
217 | */ | ||
214 | usb_hub_tt_clear_buffer (urb->dev, urb->pipe); | 218 | usb_hub_tt_clear_buffer (urb->dev, urb->pipe); |
215 | } | 219 | } |
216 | } | 220 | } |
@@ -638,6 +642,7 @@ qh_make ( | |||
638 | u32 info1 = 0, info2 = 0; | 642 | u32 info1 = 0, info2 = 0; |
639 | int is_input, type; | 643 | int is_input, type; |
640 | int maxp = 0; | 644 | int maxp = 0; |
645 | struct usb_tt *tt = urb->dev->tt; | ||
641 | 646 | ||
642 | if (!qh) | 647 | if (!qh) |
643 | return qh; | 648 | return qh; |
@@ -661,8 +666,9 @@ qh_make ( | |||
661 | * For control/bulk requests, the HC or TT handles these. | 666 | * For control/bulk requests, the HC or TT handles these. |
662 | */ | 667 | */ |
663 | if (type == PIPE_INTERRUPT) { | 668 | if (type == PIPE_INTERRUPT) { |
664 | qh->usecs = NS_TO_US (usb_calc_bus_time (USB_SPEED_HIGH, is_input, 0, | 669 | qh->usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH, |
665 | hb_mult (maxp) * max_packet (maxp))); | 670 | is_input, 0, |
671 | hb_mult(maxp) * max_packet(maxp))); | ||
666 | qh->start = NO_FRAME; | 672 | qh->start = NO_FRAME; |
667 | 673 | ||
668 | if (urb->dev->speed == USB_SPEED_HIGH) { | 674 | if (urb->dev->speed == USB_SPEED_HIGH) { |
@@ -680,7 +686,6 @@ qh_make ( | |||
680 | goto done; | 686 | goto done; |
681 | } | 687 | } |
682 | } else { | 688 | } else { |
683 | struct usb_tt *tt = urb->dev->tt; | ||
684 | int think_time; | 689 | int think_time; |
685 | 690 | ||
686 | /* gap is f(FS/LS transfer times) */ | 691 | /* gap is f(FS/LS transfer times) */ |
@@ -736,10 +741,8 @@ qh_make ( | |||
736 | /* set the address of the TT; for TDI's integrated | 741 | /* set the address of the TT; for TDI's integrated |
737 | * root hub tt, leave it zeroed. | 742 | * root hub tt, leave it zeroed. |
738 | */ | 743 | */ |
739 | if (!ehci_is_TDI(ehci) | 744 | if (tt && tt->hub != ehci_to_hcd(ehci)->self.root_hub) |
740 | || urb->dev->tt->hub != | 745 | info2 |= tt->hub->devnum << 16; |
741 | ehci_to_hcd(ehci)->self.root_hub) | ||
742 | info2 |= urb->dev->tt->hub->devnum << 16; | ||
743 | 746 | ||
744 | /* NOTE: if (PIPE_INTERRUPT) { scheduler sets c-mask } */ | 747 | /* NOTE: if (PIPE_INTERRUPT) { scheduler sets c-mask } */ |
745 | 748 | ||
@@ -973,7 +976,7 @@ static void end_unlink_async (struct ehci_hcd *ehci) | |||
973 | struct ehci_qh *qh = ehci->reclaim; | 976 | struct ehci_qh *qh = ehci->reclaim; |
974 | struct ehci_qh *next; | 977 | struct ehci_qh *next; |
975 | 978 | ||
976 | timer_action_done (ehci, TIMER_IAA_WATCHDOG); | 979 | iaa_watchdog_done(ehci); |
977 | 980 | ||
978 | // qh->hw_next = cpu_to_hc32(qh->qh_dma); | 981 | // qh->hw_next = cpu_to_hc32(qh->qh_dma); |
979 | qh->qh_state = QH_STATE_IDLE; | 982 | qh->qh_state = QH_STATE_IDLE; |
@@ -983,7 +986,6 @@ static void end_unlink_async (struct ehci_hcd *ehci) | |||
983 | /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */ | 986 | /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */ |
984 | next = qh->reclaim; | 987 | next = qh->reclaim; |
985 | ehci->reclaim = next; | 988 | ehci->reclaim = next; |
986 | ehci->reclaim_ready = 0; | ||
987 | qh->reclaim = NULL; | 989 | qh->reclaim = NULL; |
988 | 990 | ||
989 | qh_completions (ehci, qh); | 991 | qh_completions (ehci, qh); |
@@ -1059,11 +1061,10 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
1059 | return; | 1061 | return; |
1060 | } | 1062 | } |
1061 | 1063 | ||
1062 | ehci->reclaim_ready = 0; | ||
1063 | cmd |= CMD_IAAD; | 1064 | cmd |= CMD_IAAD; |
1064 | ehci_writel(ehci, cmd, &ehci->regs->command); | 1065 | ehci_writel(ehci, cmd, &ehci->regs->command); |
1065 | (void)ehci_readl(ehci, &ehci->regs->command); | 1066 | (void)ehci_readl(ehci, &ehci->regs->command); |
1066 | timer_action (ehci, TIMER_IAA_WATCHDOG); | 1067 | iaa_watchdog_start(ehci); |
1067 | } | 1068 | } |
1068 | 1069 | ||
1069 | /*-------------------------------------------------------------------------*/ | 1070 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index 80d99bce2b38..8a8e08a51ba3 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
@@ -119,7 +119,8 @@ periodic_usecs (struct ehci_hcd *ehci, unsigned frame, unsigned uframe) | |||
119 | q = &q->fstn->fstn_next; | 119 | q = &q->fstn->fstn_next; |
120 | break; | 120 | break; |
121 | case Q_TYPE_ITD: | 121 | case Q_TYPE_ITD: |
122 | usecs += q->itd->usecs [uframe]; | 122 | if (q->itd->hw_transaction[uframe]) |
123 | usecs += q->itd->stream->usecs; | ||
123 | hw_p = &q->itd->hw_next; | 124 | hw_p = &q->itd->hw_next; |
124 | q = &q->itd->itd_next; | 125 | q = &q->itd->itd_next; |
125 | break; | 126 | break; |
@@ -211,7 +212,7 @@ static inline void carryover_tt_bandwidth(unsigned short tt_usecs[8]) | |||
211 | * low/fullspeed transfer can "carry over" from one uframe to the next, | 212 | * low/fullspeed transfer can "carry over" from one uframe to the next, |
212 | * since the TT just performs downstream transfers in sequence. | 213 | * since the TT just performs downstream transfers in sequence. |
213 | * | 214 | * |
214 | * For example two seperate 100 usec transfers can start in the same uframe, | 215 | * For example two separate 100 usec transfers can start in the same uframe, |
215 | * and the second one would "carry over" 75 usecs into the next uframe. | 216 | * and the second one would "carry over" 75 usecs into the next uframe. |
216 | */ | 217 | */ |
217 | static void | 218 | static void |
@@ -1536,7 +1537,6 @@ itd_link_urb ( | |||
1536 | uframe = next_uframe & 0x07; | 1537 | uframe = next_uframe & 0x07; |
1537 | frame = next_uframe >> 3; | 1538 | frame = next_uframe >> 3; |
1538 | 1539 | ||
1539 | itd->usecs [uframe] = stream->usecs; | ||
1540 | itd_patch(ehci, itd, iso_sched, packet, uframe); | 1540 | itd_patch(ehci, itd, iso_sched, packet, uframe); |
1541 | 1541 | ||
1542 | next_uframe += stream->interval; | 1542 | next_uframe += stream->interval; |
@@ -1565,6 +1565,16 @@ itd_link_urb ( | |||
1565 | 1565 | ||
1566 | #define ISO_ERRS (EHCI_ISOC_BUF_ERR | EHCI_ISOC_BABBLE | EHCI_ISOC_XACTERR) | 1566 | #define ISO_ERRS (EHCI_ISOC_BUF_ERR | EHCI_ISOC_BABBLE | EHCI_ISOC_XACTERR) |
1567 | 1567 | ||
1568 | /* Process and recycle a completed ITD. Return true iff its urb completed, | ||
1569 | * and hence its completion callback probably added things to the hardware | ||
1570 | * schedule. | ||
1571 | * | ||
1572 | * Note that we carefully avoid recycling this descriptor until after any | ||
1573 | * completion callback runs, so that it won't be reused quickly. That is, | ||
1574 | * assuming (a) no more than two urbs per frame on this endpoint, and also | ||
1575 | * (b) only this endpoint's completions submit URBs. It seems some silicon | ||
1576 | * corrupts things if you reuse completed descriptors very quickly... | ||
1577 | */ | ||
1568 | static unsigned | 1578 | static unsigned |
1569 | itd_complete ( | 1579 | itd_complete ( |
1570 | struct ehci_hcd *ehci, | 1580 | struct ehci_hcd *ehci, |
@@ -1577,6 +1587,7 @@ itd_complete ( | |||
1577 | int urb_index = -1; | 1587 | int urb_index = -1; |
1578 | struct ehci_iso_stream *stream = itd->stream; | 1588 | struct ehci_iso_stream *stream = itd->stream; |
1579 | struct usb_device *dev; | 1589 | struct usb_device *dev; |
1590 | unsigned retval = false; | ||
1580 | 1591 | ||
1581 | /* for each uframe with a packet */ | 1592 | /* for each uframe with a packet */ |
1582 | for (uframe = 0; uframe < 8; uframe++) { | 1593 | for (uframe = 0; uframe < 8; uframe++) { |
@@ -1610,30 +1621,21 @@ itd_complete ( | |||
1610 | } | 1621 | } |
1611 | } | 1622 | } |
1612 | 1623 | ||
1613 | usb_put_urb (urb); | ||
1614 | itd->urb = NULL; | ||
1615 | itd->stream = NULL; | ||
1616 | list_move (&itd->itd_list, &stream->free_list); | ||
1617 | iso_stream_put (ehci, stream); | ||
1618 | |||
1619 | /* handle completion now? */ | 1624 | /* handle completion now? */ |
1620 | if (likely ((urb_index + 1) != urb->number_of_packets)) | 1625 | if (likely ((urb_index + 1) != urb->number_of_packets)) |
1621 | return 0; | 1626 | goto done; |
1622 | 1627 | ||
1623 | /* ASSERT: it's really the last itd for this urb | 1628 | /* ASSERT: it's really the last itd for this urb |
1624 | list_for_each_entry (itd, &stream->td_list, itd_list) | 1629 | list_for_each_entry (itd, &stream->td_list, itd_list) |
1625 | BUG_ON (itd->urb == urb); | 1630 | BUG_ON (itd->urb == urb); |
1626 | */ | 1631 | */ |
1627 | 1632 | ||
1628 | /* give urb back to the driver ... can be out-of-order */ | 1633 | /* give urb back to the driver; completion often (re)submits */ |
1629 | dev = urb->dev; | 1634 | dev = urb->dev; |
1630 | ehci_urb_done(ehci, urb, 0); | 1635 | ehci_urb_done(ehci, urb, 0); |
1636 | retval = true; | ||
1631 | urb = NULL; | 1637 | urb = NULL; |
1632 | |||
1633 | /* defer stopping schedule; completion can submit */ | ||
1634 | ehci->periodic_sched--; | 1638 | ehci->periodic_sched--; |
1635 | if (unlikely (!ehci->periodic_sched)) | ||
1636 | (void) disable_periodic (ehci); | ||
1637 | ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; | 1639 | ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; |
1638 | 1640 | ||
1639 | if (unlikely (list_empty (&stream->td_list))) { | 1641 | if (unlikely (list_empty (&stream->td_list))) { |
@@ -1645,8 +1647,15 @@ itd_complete ( | |||
1645 | (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out"); | 1647 | (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out"); |
1646 | } | 1648 | } |
1647 | iso_stream_put (ehci, stream); | 1649 | iso_stream_put (ehci, stream); |
1650 | /* OK to recycle this ITD now that its completion callback ran. */ | ||
1651 | done: | ||
1652 | usb_put_urb(urb); | ||
1653 | itd->urb = NULL; | ||
1654 | itd->stream = NULL; | ||
1655 | list_move(&itd->itd_list, &stream->free_list); | ||
1656 | iso_stream_put(ehci, stream); | ||
1648 | 1657 | ||
1649 | return 1; | 1658 | return retval; |
1650 | } | 1659 | } |
1651 | 1660 | ||
1652 | /*-------------------------------------------------------------------------*/ | 1661 | /*-------------------------------------------------------------------------*/ |
@@ -1712,8 +1721,6 @@ done: | |||
1712 | return status; | 1721 | return status; |
1713 | } | 1722 | } |
1714 | 1723 | ||
1715 | #ifdef CONFIG_USB_EHCI_SPLIT_ISO | ||
1716 | |||
1717 | /*-------------------------------------------------------------------------*/ | 1724 | /*-------------------------------------------------------------------------*/ |
1718 | 1725 | ||
1719 | /* | 1726 | /* |
@@ -1950,6 +1957,16 @@ sitd_link_urb ( | |||
1950 | #define SITD_ERRS (SITD_STS_ERR | SITD_STS_DBE | SITD_STS_BABBLE \ | 1957 | #define SITD_ERRS (SITD_STS_ERR | SITD_STS_DBE | SITD_STS_BABBLE \ |
1951 | | SITD_STS_XACT | SITD_STS_MMF) | 1958 | | SITD_STS_XACT | SITD_STS_MMF) |
1952 | 1959 | ||
1960 | /* Process and recycle a completed SITD. Return true iff its urb completed, | ||
1961 | * and hence its completion callback probably added things to the hardware | ||
1962 | * schedule. | ||
1963 | * | ||
1964 | * Note that we carefully avoid recycling this descriptor until after any | ||
1965 | * completion callback runs, so that it won't be reused quickly. That is, | ||
1966 | * assuming (a) no more than two urbs per frame on this endpoint, and also | ||
1967 | * (b) only this endpoint's completions submit URBs. It seems some silicon | ||
1968 | * corrupts things if you reuse completed descriptors very quickly... | ||
1969 | */ | ||
1953 | static unsigned | 1970 | static unsigned |
1954 | sitd_complete ( | 1971 | sitd_complete ( |
1955 | struct ehci_hcd *ehci, | 1972 | struct ehci_hcd *ehci, |
@@ -1961,6 +1978,7 @@ sitd_complete ( | |||
1961 | int urb_index = -1; | 1978 | int urb_index = -1; |
1962 | struct ehci_iso_stream *stream = sitd->stream; | 1979 | struct ehci_iso_stream *stream = sitd->stream; |
1963 | struct usb_device *dev; | 1980 | struct usb_device *dev; |
1981 | unsigned retval = false; | ||
1964 | 1982 | ||
1965 | urb_index = sitd->index; | 1983 | urb_index = sitd->index; |
1966 | desc = &urb->iso_frame_desc [urb_index]; | 1984 | desc = &urb->iso_frame_desc [urb_index]; |
@@ -1981,32 +1999,23 @@ sitd_complete ( | |||
1981 | desc->status = 0; | 1999 | desc->status = 0; |
1982 | desc->actual_length = desc->length - SITD_LENGTH (t); | 2000 | desc->actual_length = desc->length - SITD_LENGTH (t); |
1983 | } | 2001 | } |
1984 | |||
1985 | usb_put_urb (urb); | ||
1986 | sitd->urb = NULL; | ||
1987 | sitd->stream = NULL; | ||
1988 | list_move (&sitd->sitd_list, &stream->free_list); | ||
1989 | stream->depth -= stream->interval << 3; | 2002 | stream->depth -= stream->interval << 3; |
1990 | iso_stream_put (ehci, stream); | ||
1991 | 2003 | ||
1992 | /* handle completion now? */ | 2004 | /* handle completion now? */ |
1993 | if ((urb_index + 1) != urb->number_of_packets) | 2005 | if ((urb_index + 1) != urb->number_of_packets) |
1994 | return 0; | 2006 | goto done; |
1995 | 2007 | ||
1996 | /* ASSERT: it's really the last sitd for this urb | 2008 | /* ASSERT: it's really the last sitd for this urb |
1997 | list_for_each_entry (sitd, &stream->td_list, sitd_list) | 2009 | list_for_each_entry (sitd, &stream->td_list, sitd_list) |
1998 | BUG_ON (sitd->urb == urb); | 2010 | BUG_ON (sitd->urb == urb); |
1999 | */ | 2011 | */ |
2000 | 2012 | ||
2001 | /* give urb back to the driver */ | 2013 | /* give urb back to the driver; completion often (re)submits */ |
2002 | dev = urb->dev; | 2014 | dev = urb->dev; |
2003 | ehci_urb_done(ehci, urb, 0); | 2015 | ehci_urb_done(ehci, urb, 0); |
2016 | retval = true; | ||
2004 | urb = NULL; | 2017 | urb = NULL; |
2005 | |||
2006 | /* defer stopping schedule; completion can submit */ | ||
2007 | ehci->periodic_sched--; | 2018 | ehci->periodic_sched--; |
2008 | if (!ehci->periodic_sched) | ||
2009 | (void) disable_periodic (ehci); | ||
2010 | ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; | 2019 | ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; |
2011 | 2020 | ||
2012 | if (list_empty (&stream->td_list)) { | 2021 | if (list_empty (&stream->td_list)) { |
@@ -2018,8 +2027,15 @@ sitd_complete ( | |||
2018 | (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out"); | 2027 | (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out"); |
2019 | } | 2028 | } |
2020 | iso_stream_put (ehci, stream); | 2029 | iso_stream_put (ehci, stream); |
2030 | /* OK to recycle this SITD now that its completion callback ran. */ | ||
2031 | done: | ||
2032 | usb_put_urb(urb); | ||
2033 | sitd->urb = NULL; | ||
2034 | sitd->stream = NULL; | ||
2035 | list_move(&sitd->sitd_list, &stream->free_list); | ||
2036 | iso_stream_put(ehci, stream); | ||
2021 | 2037 | ||
2022 | return 1; | 2038 | return retval; |
2023 | } | 2039 | } |
2024 | 2040 | ||
2025 | 2041 | ||
@@ -2082,26 +2098,6 @@ done: | |||
2082 | return status; | 2098 | return status; |
2083 | } | 2099 | } |
2084 | 2100 | ||
2085 | #else | ||
2086 | |||
2087 | static inline int | ||
2088 | sitd_submit (struct ehci_hcd *ehci, struct urb *urb, gfp_t mem_flags) | ||
2089 | { | ||
2090 | ehci_dbg (ehci, "split iso support is disabled\n"); | ||
2091 | return -ENOSYS; | ||
2092 | } | ||
2093 | |||
2094 | static inline unsigned | ||
2095 | sitd_complete ( | ||
2096 | struct ehci_hcd *ehci, | ||
2097 | struct ehci_sitd *sitd | ||
2098 | ) { | ||
2099 | ehci_err (ehci, "sitd_complete %p?\n", sitd); | ||
2100 | return 0; | ||
2101 | } | ||
2102 | |||
2103 | #endif /* USB_EHCI_SPLIT_ISO */ | ||
2104 | |||
2105 | /*-------------------------------------------------------------------------*/ | 2101 | /*-------------------------------------------------------------------------*/ |
2106 | 2102 | ||
2107 | static void | 2103 | static void |
@@ -2127,17 +2123,9 @@ scan_periodic (struct ehci_hcd *ehci) | |||
2127 | for (;;) { | 2123 | for (;;) { |
2128 | union ehci_shadow q, *q_p; | 2124 | union ehci_shadow q, *q_p; |
2129 | __hc32 type, *hw_p; | 2125 | __hc32 type, *hw_p; |
2130 | unsigned uframes; | 2126 | unsigned incomplete = false; |
2131 | 2127 | ||
2132 | /* don't scan past the live uframe */ | ||
2133 | frame = now_uframe >> 3; | 2128 | frame = now_uframe >> 3; |
2134 | if (frame == (clock >> 3)) | ||
2135 | uframes = now_uframe & 0x07; | ||
2136 | else { | ||
2137 | /* safe to scan the whole frame at once */ | ||
2138 | now_uframe |= 0x07; | ||
2139 | uframes = 8; | ||
2140 | } | ||
2141 | 2129 | ||
2142 | restart: | 2130 | restart: |
2143 | /* scan each element in frame's queue for completions */ | 2131 | /* scan each element in frame's queue for completions */ |
@@ -2175,12 +2163,15 @@ restart: | |||
2175 | q = q.fstn->fstn_next; | 2163 | q = q.fstn->fstn_next; |
2176 | break; | 2164 | break; |
2177 | case Q_TYPE_ITD: | 2165 | case Q_TYPE_ITD: |
2178 | /* skip itds for later in the frame */ | 2166 | /* If this ITD is still active, leave it for |
2167 | * later processing ... check the next entry. | ||
2168 | */ | ||
2179 | rmb (); | 2169 | rmb (); |
2180 | for (uf = live ? uframes : 8; uf < 8; uf++) { | 2170 | for (uf = 0; uf < 8 && live; uf++) { |
2181 | if (0 == (q.itd->hw_transaction [uf] | 2171 | if (0 == (q.itd->hw_transaction [uf] |
2182 | & ITD_ACTIVE(ehci))) | 2172 | & ITD_ACTIVE(ehci))) |
2183 | continue; | 2173 | continue; |
2174 | incomplete = true; | ||
2184 | q_p = &q.itd->itd_next; | 2175 | q_p = &q.itd->itd_next; |
2185 | hw_p = &q.itd->hw_next; | 2176 | hw_p = &q.itd->hw_next; |
2186 | type = Q_NEXT_TYPE(ehci, | 2177 | type = Q_NEXT_TYPE(ehci, |
@@ -2188,10 +2179,12 @@ restart: | |||
2188 | q = *q_p; | 2179 | q = *q_p; |
2189 | break; | 2180 | break; |
2190 | } | 2181 | } |
2191 | if (uf != 8) | 2182 | if (uf < 8 && live) |
2192 | break; | 2183 | break; |
2193 | 2184 | ||
2194 | /* this one's ready ... HC won't cache the | 2185 | /* Take finished ITDs out of the schedule |
2186 | * and process them: recycle, maybe report | ||
2187 | * URB completion. HC won't cache the | ||
2195 | * pointer for much longer, if at all. | 2188 | * pointer for much longer, if at all. |
2196 | */ | 2189 | */ |
2197 | *q_p = q.itd->itd_next; | 2190 | *q_p = q.itd->itd_next; |
@@ -2202,8 +2195,12 @@ restart: | |||
2202 | q = *q_p; | 2195 | q = *q_p; |
2203 | break; | 2196 | break; |
2204 | case Q_TYPE_SITD: | 2197 | case Q_TYPE_SITD: |
2198 | /* If this SITD is still active, leave it for | ||
2199 | * later processing ... check the next entry. | ||
2200 | */ | ||
2205 | if ((q.sitd->hw_results & SITD_ACTIVE(ehci)) | 2201 | if ((q.sitd->hw_results & SITD_ACTIVE(ehci)) |
2206 | && live) { | 2202 | && live) { |
2203 | incomplete = true; | ||
2207 | q_p = &q.sitd->sitd_next; | 2204 | q_p = &q.sitd->sitd_next; |
2208 | hw_p = &q.sitd->hw_next; | 2205 | hw_p = &q.sitd->hw_next; |
2209 | type = Q_NEXT_TYPE(ehci, | 2206 | type = Q_NEXT_TYPE(ehci, |
@@ -2211,6 +2208,11 @@ restart: | |||
2211 | q = *q_p; | 2208 | q = *q_p; |
2212 | break; | 2209 | break; |
2213 | } | 2210 | } |
2211 | |||
2212 | /* Take finished SITDs out of the schedule | ||
2213 | * and process them: recycle, maybe report | ||
2214 | * URB completion. | ||
2215 | */ | ||
2214 | *q_p = q.sitd->sitd_next; | 2216 | *q_p = q.sitd->sitd_next; |
2215 | *hw_p = q.sitd->hw_next; | 2217 | *hw_p = q.sitd->hw_next; |
2216 | type = Q_NEXT_TYPE(ehci, q.sitd->hw_next); | 2218 | type = Q_NEXT_TYPE(ehci, q.sitd->hw_next); |
@@ -2226,11 +2228,24 @@ restart: | |||
2226 | } | 2228 | } |
2227 | 2229 | ||
2228 | /* assume completion callbacks modify the queue */ | 2230 | /* assume completion callbacks modify the queue */ |
2229 | if (unlikely (modified)) | 2231 | if (unlikely (modified)) { |
2230 | goto restart; | 2232 | if (likely(ehci->periodic_sched > 0)) |
2233 | goto restart; | ||
2234 | /* maybe we can short-circuit this scan! */ | ||
2235 | disable_periodic(ehci); | ||
2236 | now_uframe = clock; | ||
2237 | break; | ||
2238 | } | ||
2231 | } | 2239 | } |
2232 | 2240 | ||
2233 | /* stop when we catch up to the HC */ | 2241 | /* If we can tell we caught up to the hardware, stop now. |
2242 | * We can't advance our scan without collecting the ISO | ||
2243 | * transfers that are still pending in this frame. | ||
2244 | */ | ||
2245 | if (incomplete && HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) { | ||
2246 | ehci->next_uframe = now_uframe; | ||
2247 | break; | ||
2248 | } | ||
2234 | 2249 | ||
2235 | // FIXME: this assumes we won't get lapped when | 2250 | // FIXME: this assumes we won't get lapped when |
2236 | // latencies climb; that should be rare, but... | 2251 | // latencies climb; that should be rare, but... |
@@ -2243,7 +2258,8 @@ restart: | |||
2243 | if (now_uframe == clock) { | 2258 | if (now_uframe == clock) { |
2244 | unsigned now; | 2259 | unsigned now; |
2245 | 2260 | ||
2246 | if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) | 2261 | if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state) |
2262 | || ehci->periodic_sched == 0) | ||
2247 | break; | 2263 | break; |
2248 | ehci->next_uframe = now_uframe; | 2264 | ehci->next_uframe = now_uframe; |
2249 | now = ehci_readl(ehci, &ehci->regs->frame_index) % mod; | 2265 | now = ehci_readl(ehci, &ehci->regs->frame_index) % mod; |
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 951d69fec513..bf92d209a1a9 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
@@ -74,7 +74,6 @@ struct ehci_hcd { /* one per controller */ | |||
74 | /* async schedule support */ | 74 | /* async schedule support */ |
75 | struct ehci_qh *async; | 75 | struct ehci_qh *async; |
76 | struct ehci_qh *reclaim; | 76 | struct ehci_qh *reclaim; |
77 | unsigned reclaim_ready : 1; | ||
78 | unsigned scanning : 1; | 77 | unsigned scanning : 1; |
79 | 78 | ||
80 | /* periodic schedule support */ | 79 | /* periodic schedule support */ |
@@ -105,6 +104,7 @@ struct ehci_hcd { /* one per controller */ | |||
105 | struct dma_pool *itd_pool; /* itd per iso urb */ | 104 | struct dma_pool *itd_pool; /* itd per iso urb */ |
106 | struct dma_pool *sitd_pool; /* sitd per split iso urb */ | 105 | struct dma_pool *sitd_pool; /* sitd per split iso urb */ |
107 | 106 | ||
107 | struct timer_list iaa_watchdog; | ||
108 | struct timer_list watchdog; | 108 | struct timer_list watchdog; |
109 | unsigned long actions; | 109 | unsigned long actions; |
110 | unsigned stamp; | 110 | unsigned stamp; |
@@ -127,6 +127,14 @@ struct ehci_hcd { /* one per controller */ | |||
127 | #else | 127 | #else |
128 | # define COUNT(x) do {} while (0) | 128 | # define COUNT(x) do {} while (0) |
129 | #endif | 129 | #endif |
130 | |||
131 | /* debug files */ | ||
132 | #ifdef DEBUG | ||
133 | struct dentry *debug_dir; | ||
134 | struct dentry *debug_async; | ||
135 | struct dentry *debug_periodic; | ||
136 | struct dentry *debug_registers; | ||
137 | #endif | ||
130 | }; | 138 | }; |
131 | 139 | ||
132 | /* convert between an HCD pointer and the corresponding EHCI_HCD */ | 140 | /* convert between an HCD pointer and the corresponding EHCI_HCD */ |
@@ -140,9 +148,21 @@ static inline struct usb_hcd *ehci_to_hcd (struct ehci_hcd *ehci) | |||
140 | } | 148 | } |
141 | 149 | ||
142 | 150 | ||
151 | static inline void | ||
152 | iaa_watchdog_start(struct ehci_hcd *ehci) | ||
153 | { | ||
154 | WARN_ON(timer_pending(&ehci->iaa_watchdog)); | ||
155 | mod_timer(&ehci->iaa_watchdog, | ||
156 | jiffies + msecs_to_jiffies(EHCI_IAA_MSECS)); | ||
157 | } | ||
158 | |||
159 | static inline void iaa_watchdog_done(struct ehci_hcd *ehci) | ||
160 | { | ||
161 | del_timer(&ehci->iaa_watchdog); | ||
162 | } | ||
163 | |||
143 | enum ehci_timer_action { | 164 | enum ehci_timer_action { |
144 | TIMER_IO_WATCHDOG, | 165 | TIMER_IO_WATCHDOG, |
145 | TIMER_IAA_WATCHDOG, | ||
146 | TIMER_ASYNC_SHRINK, | 166 | TIMER_ASYNC_SHRINK, |
147 | TIMER_ASYNC_OFF, | 167 | TIMER_ASYNC_OFF, |
148 | }; | 168 | }; |
@@ -160,9 +180,6 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action) | |||
160 | unsigned long t; | 180 | unsigned long t; |
161 | 181 | ||
162 | switch (action) { | 182 | switch (action) { |
163 | case TIMER_IAA_WATCHDOG: | ||
164 | t = EHCI_IAA_JIFFIES; | ||
165 | break; | ||
166 | case TIMER_IO_WATCHDOG: | 183 | case TIMER_IO_WATCHDOG: |
167 | t = EHCI_IO_JIFFIES; | 184 | t = EHCI_IO_JIFFIES; |
168 | break; | 185 | break; |
@@ -179,8 +196,7 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action) | |||
179 | // async queue SHRINK often precedes IAA. while it's ready | 196 | // async queue SHRINK often precedes IAA. while it's ready |
180 | // to go OFF neither can matter, and afterwards the IO | 197 | // to go OFF neither can matter, and afterwards the IO |
181 | // watchdog stops unless there's still periodic traffic. | 198 | // watchdog stops unless there's still periodic traffic. |
182 | if (action != TIMER_IAA_WATCHDOG | 199 | if (time_before_eq(t, ehci->watchdog.expires) |
183 | && t > ehci->watchdog.expires | ||
184 | && timer_pending (&ehci->watchdog)) | 200 | && timer_pending (&ehci->watchdog)) |
185 | return; | 201 | return; |
186 | mod_timer (&ehci->watchdog, t); | 202 | mod_timer (&ehci->watchdog, t); |
@@ -534,8 +550,8 @@ struct ehci_iso_stream { | |||
534 | * trusting urb->interval == f(epdesc->bInterval) and | 550 | * trusting urb->interval == f(epdesc->bInterval) and |
535 | * including the extra info for hw_bufp[0..2] | 551 | * including the extra info for hw_bufp[0..2] |
536 | */ | 552 | */ |
537 | u8 interval; | ||
538 | u8 usecs, c_usecs; | 553 | u8 usecs, c_usecs; |
554 | u16 interval; | ||
539 | u16 tt_usecs; | 555 | u16 tt_usecs; |
540 | u16 maxp; | 556 | u16 maxp; |
541 | u16 raw_mask; | 557 | u16 raw_mask; |
@@ -586,7 +602,6 @@ struct ehci_itd { | |||
586 | unsigned frame; /* where scheduled */ | 602 | unsigned frame; /* where scheduled */ |
587 | unsigned pg; | 603 | unsigned pg; |
588 | unsigned index[8]; /* in urb->iso_frame_desc */ | 604 | unsigned index[8]; /* in urb->iso_frame_desc */ |
589 | u8 usecs[8]; | ||
590 | } __attribute__ ((aligned (32))); | 605 | } __attribute__ ((aligned (32))); |
591 | 606 | ||
592 | /*-------------------------------------------------------------------------*/ | 607 | /*-------------------------------------------------------------------------*/ |
@@ -725,11 +740,16 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc) | |||
725 | * definition below can die once the 4xx support is | 740 | * definition below can die once the 4xx support is |
726 | * finally ported over. | 741 | * finally ported over. |
727 | */ | 742 | */ |
728 | #if defined(CONFIG_PPC) | 743 | #if defined(CONFIG_PPC) && !defined(CONFIG_PPC_MERGE) |
729 | #define readl_be(addr) in_be32((__force unsigned *)addr) | 744 | #define readl_be(addr) in_be32((__force unsigned *)addr) |
730 | #define writel_be(val, addr) out_be32((__force unsigned *)addr, val) | 745 | #define writel_be(val, addr) out_be32((__force unsigned *)addr, val) |
731 | #endif | 746 | #endif |
732 | 747 | ||
748 | #if defined(CONFIG_ARM) && defined(CONFIG_ARCH_IXP4XX) | ||
749 | #define readl_be(addr) __raw_readl((__force unsigned *)addr) | ||
750 | #define writel_be(val, addr) __raw_writel(val, (__force unsigned *)addr) | ||
751 | #endif | ||
752 | |||
733 | static inline unsigned int ehci_readl(const struct ehci_hcd *ehci, | 753 | static inline unsigned int ehci_readl(const struct ehci_hcd *ehci, |
734 | __u32 __iomem * regs) | 754 | __u32 __iomem * regs) |
735 | { | 755 | { |
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index c27417f5b9d8..0130fd8571e4 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c | |||
@@ -918,7 +918,6 @@ static int isp116x_hub_status_data(struct usb_hcd *hcd, char *buf) | |||
918 | | RH_PS_OCIC | RH_PS_PRSC)) { | 918 | | RH_PS_OCIC | RH_PS_PRSC)) { |
919 | changed = 1; | 919 | changed = 1; |
920 | buf[0] |= 1 << (i + 1); | 920 | buf[0] |= 1 << (i + 1); |
921 | continue; | ||
922 | } | 921 | } |
923 | } | 922 | } |
924 | spin_unlock_irqrestore(&isp116x->lock, flags); | 923 | spin_unlock_irqrestore(&isp116x->lock, flags); |
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index d849c809acbd..126fcbdd6408 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c | |||
@@ -17,6 +17,8 @@ | |||
17 | 17 | ||
18 | #include <asm/mach-types.h> | 18 | #include <asm/mach-types.h> |
19 | #include <asm/hardware.h> | 19 | #include <asm/hardware.h> |
20 | #include <asm/gpio.h> | ||
21 | |||
20 | #include <asm/arch/board.h> | 22 | #include <asm/arch/board.h> |
21 | #include <asm/arch/cpu.h> | 23 | #include <asm/arch/cpu.h> |
22 | 24 | ||
@@ -271,12 +273,41 @@ static const struct hc_driver ohci_at91_hc_driver = { | |||
271 | 273 | ||
272 | static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) | 274 | static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) |
273 | { | 275 | { |
276 | struct at91_usbh_data *pdata = pdev->dev.platform_data; | ||
277 | int i; | ||
278 | |||
279 | if (pdata) { | ||
280 | /* REVISIT make the driver support per-port power switching, | ||
281 | * and also overcurrent detection. Here we assume the ports | ||
282 | * are always powered while this driver is active, and use | ||
283 | * active-low power switches. | ||
284 | */ | ||
285 | for (i = 0; i < pdata->ports; i++) { | ||
286 | if (pdata->vbus_pin[i] <= 0) | ||
287 | continue; | ||
288 | gpio_request(pdata->vbus_pin[i], "ohci_vbus"); | ||
289 | gpio_direction_output(pdata->vbus_pin[i], 0); | ||
290 | } | ||
291 | } | ||
292 | |||
274 | device_init_wakeup(&pdev->dev, 1); | 293 | device_init_wakeup(&pdev->dev, 1); |
275 | return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev); | 294 | return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev); |
276 | } | 295 | } |
277 | 296 | ||
278 | static int ohci_hcd_at91_drv_remove(struct platform_device *pdev) | 297 | static int ohci_hcd_at91_drv_remove(struct platform_device *pdev) |
279 | { | 298 | { |
299 | struct at91_usbh_data *pdata = pdev->dev.platform_data; | ||
300 | int i; | ||
301 | |||
302 | if (pdata) { | ||
303 | for (i = 0; i < pdata->ports; i++) { | ||
304 | if (pdata->vbus_pin[i] <= 0) | ||
305 | continue; | ||
306 | gpio_direction_output(pdata->vbus_pin[i], 1); | ||
307 | gpio_free(pdata->vbus_pin[i]); | ||
308 | } | ||
309 | } | ||
310 | |||
280 | device_init_wakeup(&pdev->dev, 0); | 311 | device_init_wakeup(&pdev->dev, 0); |
281 | return usb_hcd_at91_remove(platform_get_drvdata(pdev), pdev); | 312 | return usb_hcd_at91_remove(platform_get_drvdata(pdev), pdev); |
282 | } | 313 | } |
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c index ebab5ce8f5ce..a22c30aa745d 100644 --- a/drivers/usb/host/ohci-dbg.c +++ b/drivers/usb/host/ohci-dbg.c | |||
@@ -401,6 +401,42 @@ static inline void remove_debug_files (struct ohci_hcd *bus) { } | |||
401 | 401 | ||
402 | #else | 402 | #else |
403 | 403 | ||
404 | static int debug_async_open(struct inode *, struct file *); | ||
405 | static int debug_periodic_open(struct inode *, struct file *); | ||
406 | static int debug_registers_open(struct inode *, struct file *); | ||
407 | static int debug_async_open(struct inode *, struct file *); | ||
408 | static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*); | ||
409 | static int debug_close(struct inode *, struct file *); | ||
410 | |||
411 | static const struct file_operations debug_async_fops = { | ||
412 | .owner = THIS_MODULE, | ||
413 | .open = debug_async_open, | ||
414 | .read = debug_output, | ||
415 | .release = debug_close, | ||
416 | }; | ||
417 | static const struct file_operations debug_periodic_fops = { | ||
418 | .owner = THIS_MODULE, | ||
419 | .open = debug_periodic_open, | ||
420 | .read = debug_output, | ||
421 | .release = debug_close, | ||
422 | }; | ||
423 | static const struct file_operations debug_registers_fops = { | ||
424 | .owner = THIS_MODULE, | ||
425 | .open = debug_registers_open, | ||
426 | .read = debug_output, | ||
427 | .release = debug_close, | ||
428 | }; | ||
429 | |||
430 | static struct dentry *ohci_debug_root; | ||
431 | |||
432 | struct debug_buffer { | ||
433 | ssize_t (*fill_func)(struct debug_buffer *); /* fill method */ | ||
434 | struct device *dev; | ||
435 | struct mutex mutex; /* protect filling of buffer */ | ||
436 | size_t count; /* number of characters filled into buffer */ | ||
437 | char *page; | ||
438 | }; | ||
439 | |||
404 | static ssize_t | 440 | static ssize_t |
405 | show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed) | 441 | show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed) |
406 | { | 442 | { |
@@ -467,8 +503,7 @@ show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed) | |||
467 | return count - size; | 503 | return count - size; |
468 | } | 504 | } |
469 | 505 | ||
470 | static ssize_t | 506 | static ssize_t fill_async_buffer(struct debug_buffer *buf) |
471 | show_async (struct class_device *class_dev, char *buf) | ||
472 | { | 507 | { |
473 | struct usb_bus *bus; | 508 | struct usb_bus *bus; |
474 | struct usb_hcd *hcd; | 509 | struct usb_hcd *hcd; |
@@ -476,25 +511,23 @@ show_async (struct class_device *class_dev, char *buf) | |||
476 | size_t temp; | 511 | size_t temp; |
477 | unsigned long flags; | 512 | unsigned long flags; |
478 | 513 | ||
479 | bus = class_get_devdata(class_dev); | 514 | bus = dev_get_drvdata(buf->dev); |
480 | hcd = bus_to_hcd(bus); | 515 | hcd = bus_to_hcd(bus); |
481 | ohci = hcd_to_ohci(hcd); | 516 | ohci = hcd_to_ohci(hcd); |
482 | 517 | ||
483 | /* display control and bulk lists together, for simplicity */ | 518 | /* display control and bulk lists together, for simplicity */ |
484 | spin_lock_irqsave (&ohci->lock, flags); | 519 | spin_lock_irqsave (&ohci->lock, flags); |
485 | temp = show_list (ohci, buf, PAGE_SIZE, ohci->ed_controltail); | 520 | temp = show_list(ohci, buf->page, buf->count, ohci->ed_controltail); |
486 | temp += show_list (ohci, buf + temp, PAGE_SIZE - temp, ohci->ed_bulktail); | 521 | temp += show_list(ohci, buf->page + temp, buf->count - temp, |
522 | ohci->ed_bulktail); | ||
487 | spin_unlock_irqrestore (&ohci->lock, flags); | 523 | spin_unlock_irqrestore (&ohci->lock, flags); |
488 | 524 | ||
489 | return temp; | 525 | return temp; |
490 | } | 526 | } |
491 | static CLASS_DEVICE_ATTR (async, S_IRUGO, show_async, NULL); | ||
492 | |||
493 | 527 | ||
494 | #define DBG_SCHED_LIMIT 64 | 528 | #define DBG_SCHED_LIMIT 64 |
495 | 529 | ||
496 | static ssize_t | 530 | static ssize_t fill_periodic_buffer(struct debug_buffer *buf) |
497 | show_periodic (struct class_device *class_dev, char *buf) | ||
498 | { | 531 | { |
499 | struct usb_bus *bus; | 532 | struct usb_bus *bus; |
500 | struct usb_hcd *hcd; | 533 | struct usb_hcd *hcd; |
@@ -509,10 +542,10 @@ show_periodic (struct class_device *class_dev, char *buf) | |||
509 | return 0; | 542 | return 0; |
510 | seen_count = 0; | 543 | seen_count = 0; |
511 | 544 | ||
512 | bus = class_get_devdata(class_dev); | 545 | bus = (struct usb_bus *)dev_get_drvdata(buf->dev); |
513 | hcd = bus_to_hcd(bus); | 546 | hcd = bus_to_hcd(bus); |
514 | ohci = hcd_to_ohci(hcd); | 547 | ohci = hcd_to_ohci(hcd); |
515 | next = buf; | 548 | next = buf->page; |
516 | size = PAGE_SIZE; | 549 | size = PAGE_SIZE; |
517 | 550 | ||
518 | temp = scnprintf (next, size, "size = %d\n", NUM_INTS); | 551 | temp = scnprintf (next, size, "size = %d\n", NUM_INTS); |
@@ -589,13 +622,9 @@ show_periodic (struct class_device *class_dev, char *buf) | |||
589 | 622 | ||
590 | return PAGE_SIZE - size; | 623 | return PAGE_SIZE - size; |
591 | } | 624 | } |
592 | static CLASS_DEVICE_ATTR (periodic, S_IRUGO, show_periodic, NULL); | ||
593 | |||
594 | |||
595 | #undef DBG_SCHED_LIMIT | 625 | #undef DBG_SCHED_LIMIT |
596 | 626 | ||
597 | static ssize_t | 627 | static ssize_t fill_registers_buffer(struct debug_buffer *buf) |
598 | show_registers (struct class_device *class_dev, char *buf) | ||
599 | { | 628 | { |
600 | struct usb_bus *bus; | 629 | struct usb_bus *bus; |
601 | struct usb_hcd *hcd; | 630 | struct usb_hcd *hcd; |
@@ -606,11 +635,11 @@ show_registers (struct class_device *class_dev, char *buf) | |||
606 | char *next; | 635 | char *next; |
607 | u32 rdata; | 636 | u32 rdata; |
608 | 637 | ||
609 | bus = class_get_devdata(class_dev); | 638 | bus = (struct usb_bus *)dev_get_drvdata(buf->dev); |
610 | hcd = bus_to_hcd(bus); | 639 | hcd = bus_to_hcd(bus); |
611 | ohci = hcd_to_ohci(hcd); | 640 | ohci = hcd_to_ohci(hcd); |
612 | regs = ohci->regs; | 641 | regs = ohci->regs; |
613 | next = buf; | 642 | next = buf->page; |
614 | size = PAGE_SIZE; | 643 | size = PAGE_SIZE; |
615 | 644 | ||
616 | spin_lock_irqsave (&ohci->lock, flags); | 645 | spin_lock_irqsave (&ohci->lock, flags); |
@@ -677,29 +706,155 @@ show_registers (struct class_device *class_dev, char *buf) | |||
677 | 706 | ||
678 | done: | 707 | done: |
679 | spin_unlock_irqrestore (&ohci->lock, flags); | 708 | spin_unlock_irqrestore (&ohci->lock, flags); |
709 | |||
680 | return PAGE_SIZE - size; | 710 | return PAGE_SIZE - size; |
681 | } | 711 | } |
682 | static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL); | ||
683 | 712 | ||
713 | static struct debug_buffer *alloc_buffer(struct device *dev, | ||
714 | ssize_t (*fill_func)(struct debug_buffer *)) | ||
715 | { | ||
716 | struct debug_buffer *buf; | ||
717 | |||
718 | buf = kzalloc(sizeof(struct debug_buffer), GFP_KERNEL); | ||
684 | 719 | ||
720 | if (buf) { | ||
721 | buf->dev = dev; | ||
722 | buf->fill_func = fill_func; | ||
723 | mutex_init(&buf->mutex); | ||
724 | } | ||
725 | |||
726 | return buf; | ||
727 | } | ||
728 | |||
729 | static int fill_buffer(struct debug_buffer *buf) | ||
730 | { | ||
731 | int ret = 0; | ||
732 | |||
733 | if (!buf->page) | ||
734 | buf->page = (char *)get_zeroed_page(GFP_KERNEL); | ||
735 | |||
736 | if (!buf->page) { | ||
737 | ret = -ENOMEM; | ||
738 | goto out; | ||
739 | } | ||
740 | |||
741 | ret = buf->fill_func(buf); | ||
742 | |||
743 | if (ret >= 0) { | ||
744 | buf->count = ret; | ||
745 | ret = 0; | ||
746 | } | ||
747 | |||
748 | out: | ||
749 | return ret; | ||
750 | } | ||
751 | |||
752 | static ssize_t debug_output(struct file *file, char __user *user_buf, | ||
753 | size_t len, loff_t *offset) | ||
754 | { | ||
755 | struct debug_buffer *buf = file->private_data; | ||
756 | int ret = 0; | ||
757 | |||
758 | mutex_lock(&buf->mutex); | ||
759 | if (buf->count == 0) { | ||
760 | ret = fill_buffer(buf); | ||
761 | if (ret != 0) { | ||
762 | mutex_unlock(&buf->mutex); | ||
763 | goto out; | ||
764 | } | ||
765 | } | ||
766 | mutex_unlock(&buf->mutex); | ||
767 | |||
768 | ret = simple_read_from_buffer(user_buf, len, offset, | ||
769 | buf->page, buf->count); | ||
770 | |||
771 | out: | ||
772 | return ret; | ||
773 | |||
774 | } | ||
775 | |||
776 | static int debug_close(struct inode *inode, struct file *file) | ||
777 | { | ||
778 | struct debug_buffer *buf = file->private_data; | ||
779 | |||
780 | if (buf) { | ||
781 | if (buf->page) | ||
782 | free_page((unsigned long)buf->page); | ||
783 | kfree(buf); | ||
784 | } | ||
785 | |||
786 | return 0; | ||
787 | } | ||
788 | static int debug_async_open(struct inode *inode, struct file *file) | ||
789 | { | ||
790 | file->private_data = alloc_buffer(inode->i_private, fill_async_buffer); | ||
791 | |||
792 | return file->private_data ? 0 : -ENOMEM; | ||
793 | } | ||
794 | |||
795 | static int debug_periodic_open(struct inode *inode, struct file *file) | ||
796 | { | ||
797 | file->private_data = alloc_buffer(inode->i_private, | ||
798 | fill_periodic_buffer); | ||
799 | |||
800 | return file->private_data ? 0 : -ENOMEM; | ||
801 | } | ||
802 | |||
803 | static int debug_registers_open(struct inode *inode, struct file *file) | ||
804 | { | ||
805 | file->private_data = alloc_buffer(inode->i_private, | ||
806 | fill_registers_buffer); | ||
807 | |||
808 | return file->private_data ? 0 : -ENOMEM; | ||
809 | } | ||
685 | static inline void create_debug_files (struct ohci_hcd *ohci) | 810 | static inline void create_debug_files (struct ohci_hcd *ohci) |
686 | { | 811 | { |
687 | struct class_device *cldev = ohci_to_hcd(ohci)->self.class_dev; | 812 | struct usb_bus *bus = &ohci_to_hcd(ohci)->self; |
688 | int retval; | 813 | struct device *dev = bus->dev; |
814 | |||
815 | ohci->debug_dir = debugfs_create_dir(bus->bus_name, ohci_debug_root); | ||
816 | if (!ohci->debug_dir) | ||
817 | goto dir_error; | ||
818 | |||
819 | ohci->debug_async = debugfs_create_file("async", S_IRUGO, | ||
820 | ohci->debug_dir, dev, | ||
821 | &debug_async_fops); | ||
822 | if (!ohci->debug_async) | ||
823 | goto async_error; | ||
824 | |||
825 | ohci->debug_periodic = debugfs_create_file("periodic", S_IRUGO, | ||
826 | ohci->debug_dir, dev, | ||
827 | &debug_periodic_fops); | ||
828 | if (!ohci->debug_periodic) | ||
829 | goto periodic_error; | ||
830 | |||
831 | ohci->debug_registers = debugfs_create_file("registers", S_IRUGO, | ||
832 | ohci->debug_dir, dev, | ||
833 | &debug_registers_fops); | ||
834 | if (!ohci->debug_registers) | ||
835 | goto registers_error; | ||
689 | 836 | ||
690 | retval = class_device_create_file(cldev, &class_device_attr_async); | ||
691 | retval = class_device_create_file(cldev, &class_device_attr_periodic); | ||
692 | retval = class_device_create_file(cldev, &class_device_attr_registers); | ||
693 | ohci_dbg (ohci, "created debug files\n"); | 837 | ohci_dbg (ohci, "created debug files\n"); |
838 | return; | ||
839 | |||
840 | registers_error: | ||
841 | debugfs_remove(ohci->debug_periodic); | ||
842 | periodic_error: | ||
843 | debugfs_remove(ohci->debug_async); | ||
844 | async_error: | ||
845 | debugfs_remove(ohci->debug_dir); | ||
846 | dir_error: | ||
847 | ohci->debug_periodic = NULL; | ||
848 | ohci->debug_async = NULL; | ||
849 | ohci->debug_dir = NULL; | ||
694 | } | 850 | } |
695 | 851 | ||
696 | static inline void remove_debug_files (struct ohci_hcd *ohci) | 852 | static inline void remove_debug_files (struct ohci_hcd *ohci) |
697 | { | 853 | { |
698 | struct class_device *cldev = ohci_to_hcd(ohci)->self.class_dev; | 854 | debugfs_remove(ohci->debug_registers); |
699 | 855 | debugfs_remove(ohci->debug_periodic); | |
700 | class_device_remove_file(cldev, &class_device_attr_async); | 856 | debugfs_remove(ohci->debug_async); |
701 | class_device_remove_file(cldev, &class_device_attr_periodic); | 857 | debugfs_remove(ohci->debug_dir); |
702 | class_device_remove_file(cldev, &class_device_attr_registers); | ||
703 | } | 858 | } |
704 | 859 | ||
705 | #endif | 860 | #endif |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index ddd4ee1f2413..dd4798ee028e 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/dmapool.h> | 36 | #include <linux/dmapool.h> |
37 | #include <linux/reboot.h> | 37 | #include <linux/reboot.h> |
38 | #include <linux/workqueue.h> | 38 | #include <linux/workqueue.h> |
39 | #include <linux/debugfs.h> | ||
39 | 40 | ||
40 | #include <asm/io.h> | 41 | #include <asm/io.h> |
41 | #include <asm/irq.h> | 42 | #include <asm/irq.h> |
@@ -809,13 +810,9 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) | |||
809 | } | 810 | } |
810 | 811 | ||
811 | if (ints & OHCI_INTR_WDH) { | 812 | if (ints & OHCI_INTR_WDH) { |
812 | if (HC_IS_RUNNING(hcd->state)) | ||
813 | ohci_writel (ohci, OHCI_INTR_WDH, ®s->intrdisable); | ||
814 | spin_lock (&ohci->lock); | 813 | spin_lock (&ohci->lock); |
815 | dl_done_list (ohci); | 814 | dl_done_list (ohci); |
816 | spin_unlock (&ohci->lock); | 815 | spin_unlock (&ohci->lock); |
817 | if (HC_IS_RUNNING(hcd->state)) | ||
818 | ohci_writel (ohci, OHCI_INTR_WDH, ®s->intrenable); | ||
819 | } | 816 | } |
820 | 817 | ||
821 | if (quirk_zfmicro(ohci) && (ints & OHCI_INTR_SF)) { | 818 | if (quirk_zfmicro(ohci) && (ints & OHCI_INTR_SF)) { |
@@ -1032,6 +1029,13 @@ MODULE_LICENSE ("GPL"); | |||
1032 | #define PLATFORM_DRIVER usb_hcd_pnx4008_driver | 1029 | #define PLATFORM_DRIVER usb_hcd_pnx4008_driver |
1033 | #endif | 1030 | #endif |
1034 | 1031 | ||
1032 | #if defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | ||
1033 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ | ||
1034 | defined(CONFIG_CPU_SUBTYPE_SH7763) | ||
1035 | #include "ohci-sh.c" | ||
1036 | #define PLATFORM_DRIVER ohci_hcd_sh_driver | ||
1037 | #endif | ||
1038 | |||
1035 | 1039 | ||
1036 | #ifdef CONFIG_USB_OHCI_HCD_PPC_OF | 1040 | #ifdef CONFIG_USB_OHCI_HCD_PPC_OF |
1037 | #include "ohci-ppc-of.c" | 1041 | #include "ohci-ppc-of.c" |
@@ -1048,6 +1052,11 @@ MODULE_LICENSE ("GPL"); | |||
1048 | #define SSB_OHCI_DRIVER ssb_ohci_driver | 1052 | #define SSB_OHCI_DRIVER ssb_ohci_driver |
1049 | #endif | 1053 | #endif |
1050 | 1054 | ||
1055 | #ifdef CONFIG_MFD_SM501 | ||
1056 | #include "ohci-sm501.c" | ||
1057 | #define PLATFORM_DRIVER ohci_hcd_sm501_driver | ||
1058 | #endif | ||
1059 | |||
1051 | #if !defined(PCI_DRIVER) && \ | 1060 | #if !defined(PCI_DRIVER) && \ |
1052 | !defined(PLATFORM_DRIVER) && \ | 1061 | !defined(PLATFORM_DRIVER) && \ |
1053 | !defined(OF_PLATFORM_DRIVER) && \ | 1062 | !defined(OF_PLATFORM_DRIVER) && \ |
@@ -1068,6 +1077,14 @@ static int __init ohci_hcd_mod_init(void) | |||
1068 | pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name, | 1077 | pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name, |
1069 | sizeof (struct ed), sizeof (struct td)); | 1078 | sizeof (struct ed), sizeof (struct td)); |
1070 | 1079 | ||
1080 | #ifdef DEBUG | ||
1081 | ohci_debug_root = debugfs_create_dir("ohci", NULL); | ||
1082 | if (!ohci_debug_root) { | ||
1083 | retval = -ENOENT; | ||
1084 | goto error_debug; | ||
1085 | } | ||
1086 | #endif | ||
1087 | |||
1071 | #ifdef PS3_SYSTEM_BUS_DRIVER | 1088 | #ifdef PS3_SYSTEM_BUS_DRIVER |
1072 | retval = ps3_ohci_driver_register(&PS3_SYSTEM_BUS_DRIVER); | 1089 | retval = ps3_ohci_driver_register(&PS3_SYSTEM_BUS_DRIVER); |
1073 | if (retval < 0) | 1090 | if (retval < 0) |
@@ -1130,6 +1147,12 @@ static int __init ohci_hcd_mod_init(void) | |||
1130 | ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); | 1147 | ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); |
1131 | error_ps3: | 1148 | error_ps3: |
1132 | #endif | 1149 | #endif |
1150 | #ifdef DEBUG | ||
1151 | debugfs_remove(ohci_debug_root); | ||
1152 | ohci_debug_root = NULL; | ||
1153 | error_debug: | ||
1154 | #endif | ||
1155 | |||
1133 | return retval; | 1156 | return retval; |
1134 | } | 1157 | } |
1135 | module_init(ohci_hcd_mod_init); | 1158 | module_init(ohci_hcd_mod_init); |
@@ -1154,6 +1177,9 @@ static void __exit ohci_hcd_mod_exit(void) | |||
1154 | #ifdef PS3_SYSTEM_BUS_DRIVER | 1177 | #ifdef PS3_SYSTEM_BUS_DRIVER |
1155 | ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); | 1178 | ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); |
1156 | #endif | 1179 | #endif |
1180 | #ifdef DEBUG | ||
1181 | debugfs_remove(ohci_debug_root); | ||
1182 | #endif | ||
1157 | } | 1183 | } |
1158 | module_exit(ohci_hcd_mod_exit); | 1184 | module_exit(ohci_hcd_mod_exit); |
1159 | 1185 | ||
diff --git a/drivers/usb/host/ohci-sh.c b/drivers/usb/host/ohci-sh.c new file mode 100644 index 000000000000..5309ac039e15 --- /dev/null +++ b/drivers/usb/host/ohci-sh.c | |||
@@ -0,0 +1,143 @@ | |||
1 | /* | ||
2 | * OHCI HCD (Host Controller Driver) for USB. | ||
3 | * | ||
4 | * Copyright (C) 2008 Renesas Solutions Corp. | ||
5 | * | ||
6 | * Author : Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; version 2 of the License. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <linux/platform_device.h> | ||
24 | |||
25 | static int ohci_sh_start(struct usb_hcd *hcd) | ||
26 | { | ||
27 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
28 | |||
29 | ohci_hcd_init(ohci); | ||
30 | ohci_init(ohci); | ||
31 | ohci_run(ohci); | ||
32 | hcd->state = HC_STATE_RUNNING; | ||
33 | return 0; | ||
34 | } | ||
35 | |||
36 | static const struct hc_driver ohci_sh_hc_driver = { | ||
37 | .description = hcd_name, | ||
38 | .product_desc = "SuperH OHCI", | ||
39 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
40 | |||
41 | /* | ||
42 | * generic hardware linkage | ||
43 | */ | ||
44 | .irq = ohci_irq, | ||
45 | .flags = HCD_USB11 | HCD_MEMORY, | ||
46 | |||
47 | /* | ||
48 | * basic lifecycle operations | ||
49 | */ | ||
50 | .start = ohci_sh_start, | ||
51 | .stop = ohci_stop, | ||
52 | .shutdown = ohci_shutdown, | ||
53 | |||
54 | /* | ||
55 | * managing i/o requests and associated device resources | ||
56 | */ | ||
57 | .urb_enqueue = ohci_urb_enqueue, | ||
58 | .urb_dequeue = ohci_urb_dequeue, | ||
59 | .endpoint_disable = ohci_endpoint_disable, | ||
60 | |||
61 | /* | ||
62 | * scheduling support | ||
63 | */ | ||
64 | .get_frame_number = ohci_get_frame, | ||
65 | |||
66 | /* | ||
67 | * root hub support | ||
68 | */ | ||
69 | .hub_status_data = ohci_hub_status_data, | ||
70 | .hub_control = ohci_hub_control, | ||
71 | .hub_irq_enable = ohci_rhsc_enable, | ||
72 | #ifdef CONFIG_PM | ||
73 | .bus_suspend = ohci_bus_suspend, | ||
74 | .bus_resume = ohci_bus_resume, | ||
75 | #endif | ||
76 | .start_port_reset = ohci_start_port_reset, | ||
77 | }; | ||
78 | |||
79 | /*-------------------------------------------------------------------------*/ | ||
80 | |||
81 | #define resource_len(r) (((r)->end - (r)->start) + 1) | ||
82 | static int ohci_hcd_sh_probe(struct platform_device *pdev) | ||
83 | { | ||
84 | struct resource *res = NULL; | ||
85 | struct usb_hcd *hcd = NULL; | ||
86 | int irq = -1; | ||
87 | int ret; | ||
88 | |||
89 | if (usb_disabled()) | ||
90 | return -ENODEV; | ||
91 | |||
92 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
93 | if (!res) { | ||
94 | err("platform_get_resource error."); | ||
95 | return -ENODEV; | ||
96 | } | ||
97 | |||
98 | irq = platform_get_irq(pdev, 0); | ||
99 | if (irq < 0) { | ||
100 | err("platform_get_irq error."); | ||
101 | return -ENODEV; | ||
102 | } | ||
103 | |||
104 | /* initialize hcd */ | ||
105 | hcd = usb_create_hcd(&ohci_sh_hc_driver, &pdev->dev, (char *)hcd_name); | ||
106 | if (!hcd) { | ||
107 | err("Failed to create hcd"); | ||
108 | return -ENOMEM; | ||
109 | } | ||
110 | |||
111 | hcd->regs = (void __iomem *)res->start; | ||
112 | hcd->rsrc_start = res->start; | ||
113 | hcd->rsrc_len = resource_len(res); | ||
114 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED); | ||
115 | if (ret != 0) { | ||
116 | err("Failed to add hcd"); | ||
117 | usb_put_hcd(hcd); | ||
118 | return ret; | ||
119 | } | ||
120 | |||
121 | return ret; | ||
122 | } | ||
123 | |||
124 | static int ohci_hcd_sh_remove(struct platform_device *pdev) | ||
125 | { | ||
126 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
127 | |||
128 | usb_remove_hcd(hcd); | ||
129 | usb_put_hcd(hcd); | ||
130 | |||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | static struct platform_driver ohci_hcd_sh_driver = { | ||
135 | .probe = ohci_hcd_sh_probe, | ||
136 | .remove = ohci_hcd_sh_remove, | ||
137 | .shutdown = usb_hcd_platform_shutdown, | ||
138 | .driver = { | ||
139 | .name = "sh_ohci", | ||
140 | .owner = THIS_MODULE, | ||
141 | }, | ||
142 | }; | ||
143 | |||
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c new file mode 100644 index 000000000000..a97070142869 --- /dev/null +++ b/drivers/usb/host/ohci-sm501.c | |||
@@ -0,0 +1,264 @@ | |||
1 | /* | ||
2 | * OHCI HCD (Host Controller Driver) for USB. | ||
3 | * | ||
4 | * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> | ||
5 | * (C) Copyright 2000-2005 David Brownell | ||
6 | * (C) Copyright 2002 Hewlett-Packard Company | ||
7 | * (C) Copyright 2008 Magnus Damm | ||
8 | * | ||
9 | * SM501 Bus Glue - based on ohci-omap.c | ||
10 | * | ||
11 | * This file is licenced under the GPL. | ||
12 | */ | ||
13 | |||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/jiffies.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/dma-mapping.h> | ||
18 | #include <linux/sm501.h> | ||
19 | #include <linux/sm501-regs.h> | ||
20 | |||
21 | static int ohci_sm501_init(struct usb_hcd *hcd) | ||
22 | { | ||
23 | return ohci_init(hcd_to_ohci(hcd)); | ||
24 | } | ||
25 | |||
26 | static int ohci_sm501_start(struct usb_hcd *hcd) | ||
27 | { | ||
28 | struct device *dev = hcd->self.controller; | ||
29 | int ret; | ||
30 | |||
31 | ret = ohci_run(hcd_to_ohci(hcd)); | ||
32 | if (ret < 0) { | ||
33 | dev_err(dev, "can't start %s", hcd->self.bus_name); | ||
34 | ohci_stop(hcd); | ||
35 | } | ||
36 | |||
37 | return ret; | ||
38 | } | ||
39 | |||
40 | /*-------------------------------------------------------------------------*/ | ||
41 | |||
42 | static const struct hc_driver ohci_sm501_hc_driver = { | ||
43 | .description = hcd_name, | ||
44 | .product_desc = "SM501 OHCI", | ||
45 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
46 | |||
47 | /* | ||
48 | * generic hardware linkage | ||
49 | */ | ||
50 | .irq = ohci_irq, | ||
51 | .flags = HCD_USB11 | HCD_MEMORY | HCD_LOCAL_MEM, | ||
52 | |||
53 | /* | ||
54 | * basic lifecycle operations | ||
55 | */ | ||
56 | .reset = ohci_sm501_init, | ||
57 | .start = ohci_sm501_start, | ||
58 | .stop = ohci_stop, | ||
59 | .shutdown = ohci_shutdown, | ||
60 | |||
61 | /* | ||
62 | * managing i/o requests and associated device resources | ||
63 | */ | ||
64 | .urb_enqueue = ohci_urb_enqueue, | ||
65 | .urb_dequeue = ohci_urb_dequeue, | ||
66 | .endpoint_disable = ohci_endpoint_disable, | ||
67 | |||
68 | /* | ||
69 | * scheduling support | ||
70 | */ | ||
71 | .get_frame_number = ohci_get_frame, | ||
72 | |||
73 | /* | ||
74 | * root hub support | ||
75 | */ | ||
76 | .hub_status_data = ohci_hub_status_data, | ||
77 | .hub_control = ohci_hub_control, | ||
78 | .hub_irq_enable = ohci_rhsc_enable, | ||
79 | #ifdef CONFIG_PM | ||
80 | .bus_suspend = ohci_bus_suspend, | ||
81 | .bus_resume = ohci_bus_resume, | ||
82 | #endif | ||
83 | .start_port_reset = ohci_start_port_reset, | ||
84 | }; | ||
85 | |||
86 | /*-------------------------------------------------------------------------*/ | ||
87 | |||
88 | static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev) | ||
89 | { | ||
90 | const struct hc_driver *driver = &ohci_sm501_hc_driver; | ||
91 | struct device *dev = &pdev->dev; | ||
92 | struct resource *res, *mem; | ||
93 | int retval, irq; | ||
94 | struct usb_hcd *hcd = 0; | ||
95 | |||
96 | irq = retval = platform_get_irq(pdev, 0); | ||
97 | if (retval < 0) | ||
98 | goto err0; | ||
99 | |||
100 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
101 | if (mem == NULL) { | ||
102 | dev_err(dev, "no resource definition for memory\n"); | ||
103 | retval = -ENOENT; | ||
104 | goto err0; | ||
105 | } | ||
106 | |||
107 | if (!request_mem_region(mem->start, mem->end - mem->start + 1, | ||
108 | pdev->name)) { | ||
109 | dev_err(dev, "request_mem_region failed\n"); | ||
110 | retval = -EBUSY; | ||
111 | goto err0; | ||
112 | } | ||
113 | |||
114 | /* The sm501 chip is equipped with local memory that may be used | ||
115 | * by on-chip devices such as the video controller and the usb host. | ||
116 | * This driver uses dma_declare_coherent_memory() to make sure | ||
117 | * usb allocations with dma_alloc_coherent() allocate from | ||
118 | * this local memory. The dma_handle returned by dma_alloc_coherent() | ||
119 | * will be an offset starting from 0 for the first local memory byte. | ||
120 | * | ||
121 | * So as long as data is allocated using dma_alloc_coherent() all is | ||
122 | * fine. This is however not always the case - buffers may be allocated | ||
123 | * using kmalloc() - so the usb core needs to be told that it must copy | ||
124 | * data into our local memory if the buffers happen to be placed in | ||
125 | * regular memory. The HCD_LOCAL_MEM flag does just that. | ||
126 | */ | ||
127 | |||
128 | if (!dma_declare_coherent_memory(dev, mem->start, | ||
129 | mem->start - mem->parent->start, | ||
130 | (mem->end - mem->start) + 1, | ||
131 | DMA_MEMORY_MAP | | ||
132 | DMA_MEMORY_EXCLUSIVE)) { | ||
133 | dev_err(dev, "cannot declare coherent memory\n"); | ||
134 | retval = -ENXIO; | ||
135 | goto err1; | ||
136 | } | ||
137 | |||
138 | /* allocate, reserve and remap resources for registers */ | ||
139 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
140 | if (res == NULL) { | ||
141 | dev_err(dev, "no resource definition for registers\n"); | ||
142 | retval = -ENOENT; | ||
143 | goto err2; | ||
144 | } | ||
145 | |||
146 | hcd = usb_create_hcd(driver, &pdev->dev, pdev->dev.bus_id); | ||
147 | if (!hcd) { | ||
148 | retval = -ENOMEM; | ||
149 | goto err2; | ||
150 | } | ||
151 | |||
152 | hcd->rsrc_start = res->start; | ||
153 | hcd->rsrc_len = res->end - res->start + 1; | ||
154 | |||
155 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, pdev->name)) { | ||
156 | dev_err(dev, "request_mem_region failed\n"); | ||
157 | retval = -EBUSY; | ||
158 | goto err3; | ||
159 | } | ||
160 | |||
161 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
162 | if (hcd->regs == NULL) { | ||
163 | dev_err(dev, "cannot remap registers\n"); | ||
164 | retval = -ENXIO; | ||
165 | goto err4; | ||
166 | } | ||
167 | |||
168 | ohci_hcd_init(hcd_to_ohci(hcd)); | ||
169 | |||
170 | retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); | ||
171 | if (retval) | ||
172 | goto err4; | ||
173 | |||
174 | /* enable power and unmask interrupts */ | ||
175 | |||
176 | sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1); | ||
177 | sm501_modify_reg(dev->parent, SM501_IRQ_MASK, 1 << 6, 0); | ||
178 | |||
179 | return 0; | ||
180 | err4: | ||
181 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
182 | err3: | ||
183 | usb_put_hcd(hcd); | ||
184 | err2: | ||
185 | dma_release_declared_memory(dev); | ||
186 | err1: | ||
187 | release_mem_region(mem->start, mem->end - mem->start + 1); | ||
188 | err0: | ||
189 | return retval; | ||
190 | } | ||
191 | |||
192 | static int ohci_hcd_sm501_drv_remove(struct platform_device *pdev) | ||
193 | { | ||
194 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
195 | struct resource *mem; | ||
196 | |||
197 | usb_remove_hcd(hcd); | ||
198 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
199 | usb_put_hcd(hcd); | ||
200 | dma_release_declared_memory(&pdev->dev); | ||
201 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
202 | release_mem_region(mem->start, mem->end - mem->start + 1); | ||
203 | |||
204 | /* mask interrupts and disable power */ | ||
205 | |||
206 | sm501_modify_reg(pdev->dev.parent, SM501_IRQ_MASK, 0, 1 << 6); | ||
207 | sm501_unit_power(pdev->dev.parent, SM501_GATE_USB_HOST, 0); | ||
208 | |||
209 | platform_set_drvdata(pdev, NULL); | ||
210 | return 0; | ||
211 | } | ||
212 | |||
213 | /*-------------------------------------------------------------------------*/ | ||
214 | |||
215 | #ifdef CONFIG_PM | ||
216 | static int ohci_sm501_suspend(struct platform_device *pdev, pm_message_t msg) | ||
217 | { | ||
218 | struct device *dev = &pdev->dev; | ||
219 | struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(pdev)); | ||
220 | |||
221 | if (time_before(jiffies, ohci->next_statechange)) | ||
222 | msleep(5); | ||
223 | ohci->next_statechange = jiffies; | ||
224 | |||
225 | sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 0); | ||
226 | ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; | ||
227 | dev->power.power_state = PMSG_SUSPEND; | ||
228 | return 0; | ||
229 | } | ||
230 | |||
231 | static int ohci_sm501_resume(struct platform_device *pdev) | ||
232 | { | ||
233 | struct device *dev = &pdev->dev; | ||
234 | struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(pdev)); | ||
235 | |||
236 | if (time_before(jiffies, ohci->next_statechange)) | ||
237 | msleep(5); | ||
238 | ohci->next_statechange = jiffies; | ||
239 | |||
240 | sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1); | ||
241 | dev->power.power_state = PMSG_ON; | ||
242 | usb_hcd_resume_root_hub(platform_get_drvdata(pdev)); | ||
243 | return 0; | ||
244 | } | ||
245 | #endif | ||
246 | |||
247 | /*-------------------------------------------------------------------------*/ | ||
248 | |||
249 | /* | ||
250 | * Driver definition to register with the SM501 bus | ||
251 | */ | ||
252 | static struct platform_driver ohci_hcd_sm501_driver = { | ||
253 | .probe = ohci_hcd_sm501_drv_probe, | ||
254 | .remove = ohci_hcd_sm501_drv_remove, | ||
255 | .shutdown = usb_hcd_platform_shutdown, | ||
256 | #ifdef CONFIG_PM | ||
257 | .suspend = ohci_sm501_suspend, | ||
258 | .resume = ohci_sm501_resume, | ||
259 | #endif | ||
260 | .driver = { | ||
261 | .owner = THIS_MODULE, | ||
262 | .name = "sm501-usb", | ||
263 | }, | ||
264 | }; | ||
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index 47c5c66a282c..dc544ddc7849 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h | |||
@@ -408,6 +408,13 @@ struct ohci_hcd { | |||
408 | unsigned eds_scheduled; | 408 | unsigned eds_scheduled; |
409 | struct ed *ed_to_check; | 409 | struct ed *ed_to_check; |
410 | unsigned zf_delay; | 410 | unsigned zf_delay; |
411 | |||
412 | #ifdef DEBUG | ||
413 | struct dentry *debug_dir; | ||
414 | struct dentry *debug_async; | ||
415 | struct dentry *debug_periodic; | ||
416 | struct dentry *debug_registers; | ||
417 | #endif | ||
411 | }; | 418 | }; |
412 | 419 | ||
413 | #ifdef CONFIG_PCI | 420 | #ifdef CONFIG_PCI |
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h index fe9ceb077d9b..57388252b693 100644 --- a/drivers/usb/host/r8a66597.h +++ b/drivers/usb/host/r8a66597.h | |||
@@ -405,7 +405,7 @@ | |||
405 | 405 | ||
406 | struct r8a66597_pipe_info { | 406 | struct r8a66597_pipe_info { |
407 | u16 pipenum; | 407 | u16 pipenum; |
408 | u16 address; /* R8A66597 HCD usb addres */ | 408 | u16 address; /* R8A66597 HCD usb address */ |
409 | u16 epnum; | 409 | u16 epnum; |
410 | u16 maxpacket; | 410 | u16 maxpacket; |
411 | u16 type; | 411 | u16 type; |
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c index d1131a87a5b1..0fb114ca1eba 100644 --- a/drivers/usb/image/mdc800.c +++ b/drivers/usb/image/mdc800.c | |||
@@ -478,8 +478,6 @@ static int mdc800_usb_probe (struct usb_interface *intf, | |||
478 | { | 478 | { |
479 | irq_interval=intf_desc->endpoint [j].desc.bInterval; | 479 | irq_interval=intf_desc->endpoint [j].desc.bInterval; |
480 | } | 480 | } |
481 | |||
482 | continue; | ||
483 | } | 481 | } |
484 | } | 482 | } |
485 | if (mdc800->endpoint[i] == -1) | 483 | if (mdc800->endpoint[i] == -1) |
diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c index d721380b242d..937940404b7a 100644 --- a/drivers/usb/misc/cypress_cy7c63.c +++ b/drivers/usb/misc/cypress_cy7c63.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * cypress_cy7c63.c | 2 | * cypress_cy7c63.c |
3 | * | 3 | * |
4 | * Copyright (c) 2006 Oliver Bock (o.bock@fh-wolfenbuettel.de) | 4 | * Copyright (c) 2006-2007 Oliver Bock (bock@tfh-berlin.de) |
5 | * | 5 | * |
6 | * This driver is based on the Cypress USB Driver by Marcus Maul | 6 | * This driver is based on the Cypress USB Driver by Marcus Maul |
7 | * (cyport) and the 2.0 version of Greg Kroah-Hartman's | 7 | * (cyport) and the 2.0 version of Greg Kroah-Hartman's |
@@ -21,6 +21,9 @@ | |||
21 | * Supported functions: Read/Write Ports | 21 | * Supported functions: Read/Write Ports |
22 | * | 22 | * |
23 | * | 23 | * |
24 | * For up-to-date information please visit: | ||
25 | * http://www.obock.de/kernel/cypress | ||
26 | * | ||
24 | * This program is free software; you can redistribute it and/or | 27 | * This program is free software; you can redistribute it and/or |
25 | * modify it under the terms of the GNU General Public License as | 28 | * modify it under the terms of the GNU General Public License as |
26 | * published by the Free Software Foundation, version 2. | 29 | * published by the Free Software Foundation, version 2. |
@@ -31,7 +34,7 @@ | |||
31 | #include <linux/kernel.h> | 34 | #include <linux/kernel.h> |
32 | #include <linux/usb.h> | 35 | #include <linux/usb.h> |
33 | 36 | ||
34 | #define DRIVER_AUTHOR "Oliver Bock (o.bock@fh-wolfenbuettel.de)" | 37 | #define DRIVER_AUTHOR "Oliver Bock (bock@tfh-berlin.de)" |
35 | #define DRIVER_DESC "Cypress CY7C63xxx USB driver" | 38 | #define DRIVER_DESC "Cypress CY7C63xxx USB driver" |
36 | 39 | ||
37 | #define CYPRESS_VENDOR_ID 0xa2c | 40 | #define CYPRESS_VENDOR_ID 0xa2c |
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index 764696ff1e8e..801070502cc1 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c | |||
@@ -715,7 +715,7 @@ static unsigned iowarrior_poll(struct file *file, poll_table * wait) | |||
715 | * would use "struct net_driver" instead, and a serial | 715 | * would use "struct net_driver" instead, and a serial |
716 | * device would use "struct tty_driver". | 716 | * device would use "struct tty_driver". |
717 | */ | 717 | */ |
718 | static struct file_operations iowarrior_fops = { | 718 | static const struct file_operations iowarrior_fops = { |
719 | .owner = THIS_MODULE, | 719 | .owner = THIS_MODULE, |
720 | .write = iowarrior_write, | 720 | .write = iowarrior_write, |
721 | .read = iowarrior_read, | 721 | .read = iowarrior_read, |
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index aab320085ebf..6664043f4645 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c | |||
@@ -205,7 +205,7 @@ static DEFINE_MUTEX(open_disc_mutex); | |||
205 | 205 | ||
206 | /* Structure to hold all of our device specific stuff */ | 206 | /* Structure to hold all of our device specific stuff */ |
207 | struct lego_usb_tower { | 207 | struct lego_usb_tower { |
208 | struct semaphore sem; /* locks this structure */ | 208 | struct mutex lock; /* locks this structure */ |
209 | struct usb_device* udev; /* save off the usb device pointer */ | 209 | struct usb_device* udev; /* save off the usb device pointer */ |
210 | unsigned char minor; /* the starting minor number for this device */ | 210 | unsigned char minor; /* the starting minor number for this device */ |
211 | 211 | ||
@@ -361,7 +361,7 @@ static int tower_open (struct inode *inode, struct file *file) | |||
361 | } | 361 | } |
362 | 362 | ||
363 | /* lock this device */ | 363 | /* lock this device */ |
364 | if (down_interruptible (&dev->sem)) { | 364 | if (mutex_lock_interruptible(&dev->lock)) { |
365 | mutex_unlock(&open_disc_mutex); | 365 | mutex_unlock(&open_disc_mutex); |
366 | retval = -ERESTARTSYS; | 366 | retval = -ERESTARTSYS; |
367 | goto exit; | 367 | goto exit; |
@@ -421,7 +421,7 @@ static int tower_open (struct inode *inode, struct file *file) | |||
421 | file->private_data = dev; | 421 | file->private_data = dev; |
422 | 422 | ||
423 | unlock_exit: | 423 | unlock_exit: |
424 | up (&dev->sem); | 424 | mutex_unlock(&dev->lock); |
425 | 425 | ||
426 | exit: | 426 | exit: |
427 | dbg(2, "%s: leave, return value %d ", __FUNCTION__, retval); | 427 | dbg(2, "%s: leave, return value %d ", __FUNCTION__, retval); |
@@ -448,7 +448,7 @@ static int tower_release (struct inode *inode, struct file *file) | |||
448 | } | 448 | } |
449 | 449 | ||
450 | mutex_lock(&open_disc_mutex); | 450 | mutex_lock(&open_disc_mutex); |
451 | if (down_interruptible (&dev->sem)) { | 451 | if (mutex_lock_interruptible(&dev->lock)) { |
452 | retval = -ERESTARTSYS; | 452 | retval = -ERESTARTSYS; |
453 | goto exit; | 453 | goto exit; |
454 | } | 454 | } |
@@ -460,7 +460,9 @@ static int tower_release (struct inode *inode, struct file *file) | |||
460 | } | 460 | } |
461 | if (dev->udev == NULL) { | 461 | if (dev->udev == NULL) { |
462 | /* the device was unplugged before the file was released */ | 462 | /* the device was unplugged before the file was released */ |
463 | up (&dev->sem); /* unlock here as tower_delete frees dev */ | 463 | |
464 | /* unlock here as tower_delete frees dev */ | ||
465 | mutex_unlock(&dev->lock); | ||
464 | tower_delete (dev); | 466 | tower_delete (dev); |
465 | goto exit; | 467 | goto exit; |
466 | } | 468 | } |
@@ -473,7 +475,7 @@ static int tower_release (struct inode *inode, struct file *file) | |||
473 | dev->open_count = 0; | 475 | dev->open_count = 0; |
474 | 476 | ||
475 | unlock_exit: | 477 | unlock_exit: |
476 | up (&dev->sem); | 478 | mutex_unlock(&dev->lock); |
477 | 479 | ||
478 | exit: | 480 | exit: |
479 | mutex_unlock(&open_disc_mutex); | 481 | mutex_unlock(&open_disc_mutex); |
@@ -586,7 +588,7 @@ static ssize_t tower_read (struct file *file, char __user *buffer, size_t count, | |||
586 | dev = (struct lego_usb_tower *)file->private_data; | 588 | dev = (struct lego_usb_tower *)file->private_data; |
587 | 589 | ||
588 | /* lock this object */ | 590 | /* lock this object */ |
589 | if (down_interruptible (&dev->sem)) { | 591 | if (mutex_lock_interruptible(&dev->lock)) { |
590 | retval = -ERESTARTSYS; | 592 | retval = -ERESTARTSYS; |
591 | goto exit; | 593 | goto exit; |
592 | } | 594 | } |
@@ -653,7 +655,7 @@ static ssize_t tower_read (struct file *file, char __user *buffer, size_t count, | |||
653 | 655 | ||
654 | unlock_exit: | 656 | unlock_exit: |
655 | /* unlock the device */ | 657 | /* unlock the device */ |
656 | up (&dev->sem); | 658 | mutex_unlock(&dev->lock); |
657 | 659 | ||
658 | exit: | 660 | exit: |
659 | dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); | 661 | dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); |
@@ -675,7 +677,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t | |||
675 | dev = (struct lego_usb_tower *)file->private_data; | 677 | dev = (struct lego_usb_tower *)file->private_data; |
676 | 678 | ||
677 | /* lock this object */ | 679 | /* lock this object */ |
678 | if (down_interruptible (&dev->sem)) { | 680 | if (mutex_lock_interruptible(&dev->lock)) { |
679 | retval = -ERESTARTSYS; | 681 | retval = -ERESTARTSYS; |
680 | goto exit; | 682 | goto exit; |
681 | } | 683 | } |
@@ -737,7 +739,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t | |||
737 | 739 | ||
738 | unlock_exit: | 740 | unlock_exit: |
739 | /* unlock the device */ | 741 | /* unlock the device */ |
740 | up (&dev->sem); | 742 | mutex_unlock(&dev->lock); |
741 | 743 | ||
742 | exit: | 744 | exit: |
743 | dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); | 745 | dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); |
@@ -862,7 +864,7 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device | |||
862 | goto exit; | 864 | goto exit; |
863 | } | 865 | } |
864 | 866 | ||
865 | init_MUTEX (&dev->sem); | 867 | mutex_init(&dev->lock); |
866 | 868 | ||
867 | dev->udev = udev; | 869 | dev->udev = udev; |
868 | dev->open_count = 0; | 870 | dev->open_count = 0; |
@@ -1007,16 +1009,16 @@ static void tower_disconnect (struct usb_interface *interface) | |||
1007 | /* give back our minor */ | 1009 | /* give back our minor */ |
1008 | usb_deregister_dev (interface, &tower_class); | 1010 | usb_deregister_dev (interface, &tower_class); |
1009 | 1011 | ||
1010 | down (&dev->sem); | 1012 | mutex_lock(&dev->lock); |
1011 | mutex_unlock(&open_disc_mutex); | 1013 | mutex_unlock(&open_disc_mutex); |
1012 | 1014 | ||
1013 | /* if the device is not opened, then we clean up right now */ | 1015 | /* if the device is not opened, then we clean up right now */ |
1014 | if (!dev->open_count) { | 1016 | if (!dev->open_count) { |
1015 | up (&dev->sem); | 1017 | mutex_unlock(&dev->lock); |
1016 | tower_delete (dev); | 1018 | tower_delete (dev); |
1017 | } else { | 1019 | } else { |
1018 | dev->udev = NULL; | 1020 | dev->udev = NULL; |
1019 | up (&dev->sem); | 1021 | mutex_unlock(&dev->lock); |
1020 | } | 1022 | } |
1021 | 1023 | ||
1022 | info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE)); | 1024 | info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE)); |
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index 9244d067cec1..cb7fa0eaf3ae 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c | |||
@@ -323,7 +323,7 @@ sisusb_bulkin_msg(struct sisusb_usb_data *sisusb, unsigned int pipe, void *data, | |||
323 | usb_kill_urb(urb); | 323 | usb_kill_urb(urb); |
324 | retval = -ETIMEDOUT; | 324 | retval = -ETIMEDOUT; |
325 | } else { | 325 | } else { |
326 | /* URB completed within timout */ | 326 | /* URB completed within timeout */ |
327 | retval = urb->status; | 327 | retval = urb->status; |
328 | readbytes = urb->actual_length; | 328 | readbytes = urb->actual_length; |
329 | } | 329 | } |
@@ -3195,20 +3195,6 @@ static int sisusb_probe(struct usb_interface *intf, | |||
3195 | 3195 | ||
3196 | sisusb->present = 1; | 3196 | sisusb->present = 1; |
3197 | 3197 | ||
3198 | #ifdef SISUSB_OLD_CONFIG_COMPAT | ||
3199 | { | ||
3200 | int ret; | ||
3201 | /* Our ioctls are all "32/64bit compatible" */ | ||
3202 | ret = register_ioctl32_conversion(SISUSB_GET_CONFIG_SIZE, NULL); | ||
3203 | ret |= register_ioctl32_conversion(SISUSB_GET_CONFIG, NULL); | ||
3204 | ret |= register_ioctl32_conversion(SISUSB_COMMAND, NULL); | ||
3205 | if (ret) | ||
3206 | dev_err(&sisusb->sisusb_dev->dev, "Error registering ioctl32 translations\n"); | ||
3207 | else | ||
3208 | sisusb->ioctl32registered = 1; | ||
3209 | } | ||
3210 | #endif | ||
3211 | |||
3212 | if (dev->speed == USB_SPEED_HIGH) { | 3198 | if (dev->speed == USB_SPEED_HIGH) { |
3213 | int initscreen = 1; | 3199 | int initscreen = 1; |
3214 | #ifdef INCL_SISUSB_CON | 3200 | #ifdef INCL_SISUSB_CON |
@@ -3271,19 +3257,6 @@ static void sisusb_disconnect(struct usb_interface *intf) | |||
3271 | 3257 | ||
3272 | usb_set_intfdata(intf, NULL); | 3258 | usb_set_intfdata(intf, NULL); |
3273 | 3259 | ||
3274 | #ifdef SISUSB_OLD_CONFIG_COMPAT | ||
3275 | if (sisusb->ioctl32registered) { | ||
3276 | int ret; | ||
3277 | sisusb->ioctl32registered = 0; | ||
3278 | ret = unregister_ioctl32_conversion(SISUSB_GET_CONFIG_SIZE); | ||
3279 | ret |= unregister_ioctl32_conversion(SISUSB_GET_CONFIG); | ||
3280 | ret |= unregister_ioctl32_conversion(SISUSB_COMMAND); | ||
3281 | if (ret) { | ||
3282 | dev_err(&sisusb->sisusb_dev->dev, "Error unregistering ioctl32 translations\n"); | ||
3283 | } | ||
3284 | } | ||
3285 | #endif | ||
3286 | |||
3287 | sisusb->present = 0; | 3260 | sisusb->present = 0; |
3288 | sisusb->ready = 0; | 3261 | sisusb->ready = 0; |
3289 | 3262 | ||
diff --git a/drivers/usb/misc/sisusbvga/sisusb.h b/drivers/usb/misc/sisusbvga/sisusb.h index d2d7872cd022..cf0b4a5883f6 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.h +++ b/drivers/usb/misc/sisusbvga/sisusb.h | |||
@@ -120,9 +120,6 @@ struct sisusb_usb_data { | |||
120 | int isopen; /* !=0 if open */ | 120 | int isopen; /* !=0 if open */ |
121 | int present; /* !=0 if device is present on the bus */ | 121 | int present; /* !=0 if device is present on the bus */ |
122 | int ready; /* !=0 if device is ready for userland */ | 122 | int ready; /* !=0 if device is ready for userland */ |
123 | #ifdef SISUSB_OLD_CONFIG_COMPAT | ||
124 | int ioctl32registered; | ||
125 | #endif | ||
126 | int numobufs; /* number of obufs = number of out urbs */ | 123 | int numobufs; /* number of obufs = number of out urbs */ |
127 | char *obuf[NUMOBUFS], *ibuf; /* transfer buffers */ | 124 | char *obuf[NUMOBUFS], *ibuf; /* transfer buffers */ |
128 | int obufsize, ibufsize; | 125 | int obufsize, ibufsize; |
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index ea3162146481..da922dfc0dcc 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
7 | #include <linux/moduleparam.h> | 7 | #include <linux/moduleparam.h> |
8 | #include <linux/scatterlist.h> | 8 | #include <linux/scatterlist.h> |
9 | #include <linux/mutex.h> | ||
9 | 10 | ||
10 | #include <linux/usb.h> | 11 | #include <linux/usb.h> |
11 | 12 | ||
@@ -64,7 +65,7 @@ struct usbtest_dev { | |||
64 | int in_iso_pipe; | 65 | int in_iso_pipe; |
65 | int out_iso_pipe; | 66 | int out_iso_pipe; |
66 | struct usb_endpoint_descriptor *iso_in, *iso_out; | 67 | struct usb_endpoint_descriptor *iso_in, *iso_out; |
67 | struct semaphore sem; | 68 | struct mutex lock; |
68 | 69 | ||
69 | #define TBUF_SIZE 256 | 70 | #define TBUF_SIZE 256 |
70 | u8 *buf; | 71 | u8 *buf; |
@@ -1151,6 +1152,7 @@ static int verify_halted (int ep, struct urb *urb) | |||
1151 | dbg ("ep %02x couldn't get halt status, %d", ep, retval); | 1152 | dbg ("ep %02x couldn't get halt status, %d", ep, retval); |
1152 | return retval; | 1153 | return retval; |
1153 | } | 1154 | } |
1155 | le16_to_cpus(&status); | ||
1154 | if (status != 1) { | 1156 | if (status != 1) { |
1155 | dbg ("ep %02x bogus status: %04x != 1", ep, status); | 1157 | dbg ("ep %02x bogus status: %04x != 1", ep, status); |
1156 | return -EINVAL; | 1158 | return -EINVAL; |
@@ -1310,7 +1312,7 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
1310 | len += vary; | 1312 | len += vary; |
1311 | 1313 | ||
1312 | /* [real world] the "zero bytes IN" case isn't really used. | 1314 | /* [real world] the "zero bytes IN" case isn't really used. |
1313 | * hardware can easily trip up in this wierd case, since its | 1315 | * hardware can easily trip up in this weird case, since its |
1314 | * status stage is IN, not OUT like other ep0in transfers. | 1316 | * status stage is IN, not OUT like other ep0in transfers. |
1315 | */ | 1317 | */ |
1316 | if (len > length) | 1318 | if (len > length) |
@@ -1558,11 +1560,11 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1558 | || param->sglen < 0 || param->vary < 0) | 1560 | || param->sglen < 0 || param->vary < 0) |
1559 | return -EINVAL; | 1561 | return -EINVAL; |
1560 | 1562 | ||
1561 | if (down_interruptible (&dev->sem)) | 1563 | if (mutex_lock_interruptible(&dev->lock)) |
1562 | return -ERESTARTSYS; | 1564 | return -ERESTARTSYS; |
1563 | 1565 | ||
1564 | if (intf->dev.power.power_state.event != PM_EVENT_ON) { | 1566 | if (intf->dev.power.power_state.event != PM_EVENT_ON) { |
1565 | up (&dev->sem); | 1567 | mutex_unlock(&dev->lock); |
1566 | return -EHOSTUNREACH; | 1568 | return -EHOSTUNREACH; |
1567 | } | 1569 | } |
1568 | 1570 | ||
@@ -1574,7 +1576,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1574 | int res; | 1576 | int res; |
1575 | 1577 | ||
1576 | if (intf->altsetting->desc.bInterfaceNumber) { | 1578 | if (intf->altsetting->desc.bInterfaceNumber) { |
1577 | up (&dev->sem); | 1579 | mutex_unlock(&dev->lock); |
1578 | return -ENODEV; | 1580 | return -ENODEV; |
1579 | } | 1581 | } |
1580 | res = set_altsetting (dev, dev->info->alt); | 1582 | res = set_altsetting (dev, dev->info->alt); |
@@ -1582,7 +1584,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1582 | dev_err (&intf->dev, | 1584 | dev_err (&intf->dev, |
1583 | "set altsetting to %d failed, %d\n", | 1585 | "set altsetting to %d failed, %d\n", |
1584 | dev->info->alt, res); | 1586 | dev->info->alt, res); |
1585 | up (&dev->sem); | 1587 | mutex_unlock(&dev->lock); |
1586 | return res; | 1588 | return res; |
1587 | } | 1589 | } |
1588 | } | 1590 | } |
@@ -1855,7 +1857,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1855 | param->duration.tv_usec += 1000 * 1000; | 1857 | param->duration.tv_usec += 1000 * 1000; |
1856 | param->duration.tv_sec -= 1; | 1858 | param->duration.tv_sec -= 1; |
1857 | } | 1859 | } |
1858 | up (&dev->sem); | 1860 | mutex_unlock(&dev->lock); |
1859 | return retval; | 1861 | return retval; |
1860 | } | 1862 | } |
1861 | 1863 | ||
@@ -1905,7 +1907,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1905 | return -ENOMEM; | 1907 | return -ENOMEM; |
1906 | info = (struct usbtest_info *) id->driver_info; | 1908 | info = (struct usbtest_info *) id->driver_info; |
1907 | dev->info = info; | 1909 | dev->info = info; |
1908 | init_MUTEX (&dev->sem); | 1910 | mutex_init(&dev->lock); |
1909 | 1911 | ||
1910 | dev->intf = intf; | 1912 | dev->intf = intf; |
1911 | 1913 | ||
@@ -1990,8 +1992,6 @@ static void usbtest_disconnect (struct usb_interface *intf) | |||
1990 | { | 1992 | { |
1991 | struct usbtest_dev *dev = usb_get_intfdata (intf); | 1993 | struct usbtest_dev *dev = usb_get_intfdata (intf); |
1992 | 1994 | ||
1993 | down (&dev->sem); | ||
1994 | |||
1995 | usb_set_intfdata (intf, NULL); | 1995 | usb_set_intfdata (intf, NULL); |
1996 | dev_dbg (&intf->dev, "disconnect\n"); | 1996 | dev_dbg (&intf->dev, "disconnect\n"); |
1997 | kfree (dev); | 1997 | kfree (dev); |
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c index f06e4e2b49d3..1774ba5c4c3b 100644 --- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c | |||
@@ -1026,6 +1026,8 @@ mon_bin_poll(struct file *file, struct poll_table_struct *wait) | |||
1026 | return mask; | 1026 | return mask; |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | #if 0 | ||
1030 | |||
1029 | /* | 1031 | /* |
1030 | * open and close: just keep track of how many times the device is | 1032 | * open and close: just keep track of how many times the device is |
1031 | * mapped, to use the proper memory allocation function. | 1033 | * mapped, to use the proper memory allocation function. |
@@ -1045,33 +1047,31 @@ static void mon_bin_vma_close(struct vm_area_struct *vma) | |||
1045 | /* | 1047 | /* |
1046 | * Map ring pages to user space. | 1048 | * Map ring pages to user space. |
1047 | */ | 1049 | */ |
1048 | struct page *mon_bin_vma_nopage(struct vm_area_struct *vma, | 1050 | static int mon_bin_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) |
1049 | unsigned long address, int *type) | ||
1050 | { | 1051 | { |
1051 | struct mon_reader_bin *rp = vma->vm_private_data; | 1052 | struct mon_reader_bin *rp = vma->vm_private_data; |
1052 | unsigned long offset, chunk_idx; | 1053 | unsigned long offset, chunk_idx; |
1053 | struct page *pageptr; | 1054 | struct page *pageptr; |
1054 | 1055 | ||
1055 | offset = (address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); | 1056 | offset = vmf->pgoff << PAGE_SHIFT; |
1056 | if (offset >= rp->b_size) | 1057 | if (offset >= rp->b_size) |
1057 | return NOPAGE_SIGBUS; | 1058 | return VM_FAULT_SIGBUS; |
1058 | chunk_idx = offset / CHUNK_SIZE; | 1059 | chunk_idx = offset / CHUNK_SIZE; |
1059 | pageptr = rp->b_vec[chunk_idx].pg; | 1060 | pageptr = rp->b_vec[chunk_idx].pg; |
1060 | get_page(pageptr); | 1061 | get_page(pageptr); |
1061 | if (type) | 1062 | vmf->page = pageptr; |
1062 | *type = VM_FAULT_MINOR; | 1063 | return 0; |
1063 | return pageptr; | ||
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | struct vm_operations_struct mon_bin_vm_ops = { | 1066 | struct vm_operations_struct mon_bin_vm_ops = { |
1067 | .open = mon_bin_vma_open, | 1067 | .open = mon_bin_vma_open, |
1068 | .close = mon_bin_vma_close, | 1068 | .close = mon_bin_vma_close, |
1069 | .nopage = mon_bin_vma_nopage, | 1069 | .fault = mon_bin_vma_fault, |
1070 | }; | 1070 | }; |
1071 | 1071 | ||
1072 | int mon_bin_mmap(struct file *filp, struct vm_area_struct *vma) | 1072 | int mon_bin_mmap(struct file *filp, struct vm_area_struct *vma) |
1073 | { | 1073 | { |
1074 | /* don't do anything here: "nopage" will set up page table entries */ | 1074 | /* don't do anything here: "fault" will set up page table entries */ |
1075 | vma->vm_ops = &mon_bin_vm_ops; | 1075 | vma->vm_ops = &mon_bin_vm_ops; |
1076 | vma->vm_flags |= VM_RESERVED; | 1076 | vma->vm_flags |= VM_RESERVED; |
1077 | vma->vm_private_data = filp->private_data; | 1077 | vma->vm_private_data = filp->private_data; |
@@ -1079,7 +1079,9 @@ int mon_bin_mmap(struct file *filp, struct vm_area_struct *vma) | |||
1079 | return 0; | 1079 | return 0; |
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | struct file_operations mon_fops_binary = { | 1082 | #endif /* 0 */ |
1083 | |||
1084 | static const struct file_operations mon_fops_binary = { | ||
1083 | .owner = THIS_MODULE, | 1085 | .owner = THIS_MODULE, |
1084 | .open = mon_bin_open, | 1086 | .open = mon_bin_open, |
1085 | .llseek = no_llseek, | 1087 | .llseek = no_llseek, |
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index 4a86696e6c7d..c1e65dfd9353 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig | |||
@@ -2,10 +2,7 @@ | |||
2 | # USB Serial device configuration | 2 | # USB Serial device configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "USB Serial Converter support" | 5 | menuconfig USB_SERIAL |
6 | depends on USB!=n | ||
7 | |||
8 | config USB_SERIAL | ||
9 | tristate "USB Serial Converter support" | 6 | tristate "USB Serial Converter support" |
10 | depends on USB | 7 | depends on USB |
11 | ---help--- | 8 | ---help--- |
@@ -20,6 +17,8 @@ config USB_SERIAL | |||
20 | To compile this driver as a module, choose M here: the | 17 | To compile this driver as a module, choose M here: the |
21 | module will be called usbserial. | 18 | module will be called usbserial. |
22 | 19 | ||
20 | if USB_SERIAL | ||
21 | |||
23 | config USB_SERIAL_CONSOLE | 22 | config USB_SERIAL_CONSOLE |
24 | bool "USB Serial Console device support (EXPERIMENTAL)" | 23 | bool "USB Serial Console device support (EXPERIMENTAL)" |
25 | depends on USB_SERIAL=y && EXPERIMENTAL | 24 | depends on USB_SERIAL=y && EXPERIMENTAL |
@@ -43,6 +42,12 @@ config USB_SERIAL_CONSOLE | |||
43 | 42 | ||
44 | If unsure, say N. | 43 | If unsure, say N. |
45 | 44 | ||
45 | config USB_EZUSB | ||
46 | bool "Functions for loading firmware on EZUSB chips" | ||
47 | depends on USB_SERIAL | ||
48 | help | ||
49 | Say Y here if you need EZUSB device support. | ||
50 | |||
46 | config USB_SERIAL_GENERIC | 51 | config USB_SERIAL_GENERIC |
47 | bool "USB Generic Serial Driver" | 52 | bool "USB Generic Serial Driver" |
48 | depends on USB_SERIAL | 53 | depends on USB_SERIAL |
@@ -105,6 +110,7 @@ config USB_SERIAL_CH341 | |||
105 | config USB_SERIAL_WHITEHEAT | 110 | config USB_SERIAL_WHITEHEAT |
106 | tristate "USB ConnectTech WhiteHEAT Serial Driver" | 111 | tristate "USB ConnectTech WhiteHEAT Serial Driver" |
107 | depends on USB_SERIAL | 112 | depends on USB_SERIAL |
113 | select USB_EZUSB | ||
108 | help | 114 | help |
109 | Say Y here if you want to use a ConnectTech WhiteHEAT 4 port | 115 | Say Y here if you want to use a ConnectTech WhiteHEAT 4 port |
110 | USB to serial converter device. | 116 | USB to serial converter device. |
@@ -282,9 +288,21 @@ config USB_SERIAL_IPW | |||
282 | To compile this driver as a module, choose M here: the | 288 | To compile this driver as a module, choose M here: the |
283 | module will be called ipw. | 289 | module will be called ipw. |
284 | 290 | ||
291 | config USB_SERIAL_IUU | ||
292 | tristate "USB Infinity USB Unlimited Phoenix Driver (Experimental)" | ||
293 | depends on USB_SERIAL && EXPERIMENTAL | ||
294 | help | ||
295 | Say Y here if you want to use a IUU in phoenix mode and get | ||
296 | an extra ttyUSBx device. More information available on | ||
297 | http://eczema.ecze.com/iuu_phoenix.html | ||
298 | |||
299 | To compile this driver as a module, choose M here: the | ||
300 | module will be called iuu_phoenix.o | ||
301 | |||
285 | config USB_SERIAL_KEYSPAN_PDA | 302 | config USB_SERIAL_KEYSPAN_PDA |
286 | tristate "USB Keyspan PDA Single Port Serial Driver" | 303 | tristate "USB Keyspan PDA Single Port Serial Driver" |
287 | depends on USB_SERIAL | 304 | depends on USB_SERIAL |
305 | select USB_EZUSB | ||
288 | help | 306 | help |
289 | Say Y here if you want to use a Keyspan PDA single port USB to | 307 | Say Y here if you want to use a Keyspan PDA single port USB to |
290 | serial converter device. This driver makes use of firmware | 308 | serial converter device. This driver makes use of firmware |
@@ -296,6 +314,7 @@ config USB_SERIAL_KEYSPAN_PDA | |||
296 | config USB_SERIAL_KEYSPAN | 314 | config USB_SERIAL_KEYSPAN |
297 | tristate "USB Keyspan USA-xxx Serial Driver" | 315 | tristate "USB Keyspan USA-xxx Serial Driver" |
298 | depends on USB_SERIAL | 316 | depends on USB_SERIAL |
317 | select USB_EZUSB | ||
299 | ---help--- | 318 | ---help--- |
300 | Say Y here if you want to use Keyspan USB to serial converter | 319 | Say Y here if you want to use Keyspan USB to serial converter |
301 | devices. This driver makes use of Keyspan's official firmware | 320 | devices. This driver makes use of Keyspan's official firmware |
@@ -538,6 +557,7 @@ config USB_SERIAL_CYBERJACK | |||
538 | config USB_SERIAL_XIRCOM | 557 | config USB_SERIAL_XIRCOM |
539 | tristate "USB Xircom / Entregra Single Port Serial Driver" | 558 | tristate "USB Xircom / Entregra Single Port Serial Driver" |
540 | depends on USB_SERIAL | 559 | depends on USB_SERIAL |
560 | select USB_EZUSB | ||
541 | help | 561 | help |
542 | Say Y here if you want to use a Xircom or Entregra single port USB to | 562 | Say Y here if you want to use a Xircom or Entregra single port USB to |
543 | serial converter device. This driver makes use of firmware | 563 | serial converter device. This driver makes use of firmware |
@@ -585,11 +605,4 @@ config USB_SERIAL_DEBUG | |||
585 | To compile this driver as a module, choose M here: the | 605 | To compile this driver as a module, choose M here: the |
586 | module will be called usb-debug. | 606 | module will be called usb-debug. |
587 | 607 | ||
588 | config USB_EZUSB | 608 | endif # USB_SERIAL |
589 | bool | ||
590 | depends on USB_SERIAL_KEYSPAN_PDA || USB_SERIAL_XIRCOM || USB_SERIAL_KEYSPAN || USB_SERIAL_WHITEHEAT | ||
591 | default y | ||
592 | |||
593 | |||
594 | endmenu | ||
595 | |||
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index d6fb384e52b2..0db109a54d10 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile | |||
@@ -30,6 +30,7 @@ obj-$(CONFIG_USB_SERIAL_GARMIN) += garmin_gps.o | |||
30 | obj-$(CONFIG_USB_SERIAL_HP4X) += hp4x.o | 30 | obj-$(CONFIG_USB_SERIAL_HP4X) += hp4x.o |
31 | obj-$(CONFIG_USB_SERIAL_IPAQ) += ipaq.o | 31 | obj-$(CONFIG_USB_SERIAL_IPAQ) += ipaq.o |
32 | obj-$(CONFIG_USB_SERIAL_IPW) += ipw.o | 32 | obj-$(CONFIG_USB_SERIAL_IPW) += ipw.o |
33 | obj-$(CONFIG_USB_SERIAL_IUU) += iuu_phoenix.o | ||
33 | obj-$(CONFIG_USB_SERIAL_IR) += ir-usb.o | 34 | obj-$(CONFIG_USB_SERIAL_IR) += ir-usb.o |
34 | obj-$(CONFIG_USB_SERIAL_KEYSPAN) += keyspan.o | 35 | obj-$(CONFIG_USB_SERIAL_KEYSPAN) += keyspan.o |
35 | obj-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda.o | 36 | obj-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda.o |
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c index 77bb893bf2e9..f156dba0300f 100644 --- a/drivers/usb/serial/airprime.c +++ b/drivers/usb/serial/airprime.c | |||
@@ -217,7 +217,10 @@ static void airprime_close(struct usb_serial_port *port, struct file * filp) | |||
217 | priv->rts_state = 0; | 217 | priv->rts_state = 0; |
218 | priv->dtr_state = 0; | 218 | priv->dtr_state = 0; |
219 | 219 | ||
220 | airprime_send_setup(port); | 220 | mutex_lock(&port->serial->disc_mutex); |
221 | if (!port->serial->disconnected) | ||
222 | airprime_send_setup(port); | ||
223 | mutex_lock(&port->serial->disc_mutex); | ||
221 | 224 | ||
222 | for (i = 0; i < NUM_READ_URBS; ++i) { | 225 | for (i = 0; i < NUM_READ_URBS; ++i) { |
223 | usb_kill_urb (priv->read_urbp[i]); | 226 | usb_kill_urb (priv->read_urbp[i]); |
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index ddfee918000d..fe2bfd67ba8e 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c | |||
@@ -151,8 +151,10 @@ static int ark3116_attach(struct usb_serial *serial) | |||
151 | return 0; | 151 | return 0; |
152 | 152 | ||
153 | cleanup: | 153 | cleanup: |
154 | for (--i; i >= 0; --i) | 154 | for (--i; i >= 0; --i) { |
155 | kfree(usb_get_serial_port_data(serial->port[i])); | ||
155 | usb_set_serial_port_data(serial->port[i], NULL); | 156 | usb_set_serial_port_data(serial->port[i], NULL); |
157 | } | ||
156 | return -ENOMEM; | 158 | return -ENOMEM; |
157 | } | 159 | } |
158 | 160 | ||
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 86724e885704..df0a2b3b0294 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c | |||
@@ -350,14 +350,12 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios | |||
350 | unsigned long control_state; | 350 | unsigned long control_state; |
351 | int bad_flow_control; | 351 | int bad_flow_control; |
352 | speed_t baud; | 352 | speed_t baud; |
353 | struct ktermios *termios = port->tty->termios; | ||
353 | 354 | ||
354 | if ((!port->tty) || (!port->tty->termios)) { | 355 | iflag = termios->c_iflag; |
355 | dbg ("%s - no tty or termios structure", __FUNCTION__); | 356 | cflag = termios->c_cflag; |
356 | return; | ||
357 | } | ||
358 | 357 | ||
359 | iflag = port->tty->termios->c_iflag; | 358 | termios->c_cflag &= ~CMSPAR; |
360 | cflag = port->tty->termios->c_cflag; | ||
361 | 359 | ||
362 | /* get a local copy of the current port settings */ | 360 | /* get a local copy of the current port settings */ |
363 | spin_lock_irqsave(&priv->lock, flags); | 361 | spin_lock_irqsave(&priv->lock, flags); |
@@ -369,33 +367,30 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios | |||
369 | old_cflag = old_termios->c_cflag; | 367 | old_cflag = old_termios->c_cflag; |
370 | 368 | ||
371 | /* Set the baud rate */ | 369 | /* Set the baud rate */ |
372 | if( (cflag&CBAUD) != (old_cflag&CBAUD) ) { | 370 | if ((cflag & CBAUD) != (old_cflag & CBAUD)) { |
373 | /* reassert DTR and (maybe) RTS on transition from B0 */ | 371 | /* reassert DTR and (maybe) RTS on transition from B0 */ |
374 | if( (old_cflag&CBAUD) == B0 ) { | 372 | if( (old_cflag&CBAUD) == B0 ) { |
375 | control_state |= (TIOCM_DTR|TIOCM_RTS); | 373 | control_state |= (TIOCM_DTR|TIOCM_RTS); |
376 | if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0) | 374 | if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0) |
377 | err("Set DTR error"); | 375 | err("Set DTR error"); |
378 | /* don't set RTS if using hardware flow control */ | 376 | /* don't set RTS if using hardware flow control */ |
379 | if (!(old_cflag&CRTSCTS) ) | 377 | if (!(old_cflag & CRTSCTS)) |
380 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0) | 378 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0) |
381 | err("Set RTS error"); | 379 | err("Set RTS error"); |
382 | } | 380 | } |
383 | } | 381 | } |
384 | 382 | ||
385 | baud = tty_get_baud_rate(port->tty); | 383 | baud = tty_get_baud_rate(port->tty); |
386 | if (baud == 0) { | 384 | if (baud) { |
387 | dbg("%s - tty_get_baud_rate says 0 baud", __FUNCTION__); | 385 | urb_value = BELKIN_SA_BAUD(baud); |
388 | return; | 386 | /* Clip to maximum speed */ |
389 | } | 387 | if (urb_value == 0) |
390 | urb_value = BELKIN_SA_BAUD(baud); | 388 | urb_value = 1; |
391 | /* Clip to maximum speed */ | 389 | /* Turn it back into a resulting real baud rate */ |
392 | if (urb_value == 0) | 390 | baud = BELKIN_SA_BAUD(urb_value); |
393 | urb_value = 1; | 391 | |
394 | /* Turn it back into a resulting real baud rate */ | 392 | /* Report the actual baud rate back to the caller */ |
395 | baud = BELKIN_SA_BAUD(urb_value); | 393 | tty_encode_baud_rate(port->tty, baud, baud); |
396 | /* FIXME: Once the tty updates are done then push this back to the tty */ | ||
397 | |||
398 | if ((cflag & CBAUD) != B0 ) { | ||
399 | if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) | 394 | if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) |
400 | err("Set baudrate error"); | 395 | err("Set baudrate error"); |
401 | } else { | 396 | } else { |
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 0362654d3b52..66ce30c1b75b 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c | |||
@@ -64,8 +64,8 @@ static int usb_console_setup(struct console *co, char *options) | |||
64 | struct usb_serial *serial; | 64 | struct usb_serial *serial; |
65 | struct usb_serial_port *port; | 65 | struct usb_serial_port *port; |
66 | int retval = 0; | 66 | int retval = 0; |
67 | struct tty_struct *tty; | 67 | struct tty_struct *tty = NULL; |
68 | struct ktermios *termios; | 68 | struct ktermios *termios = NULL, dummy; |
69 | 69 | ||
70 | dbg ("%s", __FUNCTION__); | 70 | dbg ("%s", __FUNCTION__); |
71 | 71 | ||
@@ -133,11 +133,14 @@ static int usb_console_setup(struct console *co, char *options) | |||
133 | } | 133 | } |
134 | co->cflag = cflag; | 134 | co->cflag = cflag; |
135 | 135 | ||
136 | /* grab the first serial port that happens to be connected */ | 136 | /* |
137 | serial = usb_serial_get_by_index(0); | 137 | * no need to check the index here: if the index is wrong, console |
138 | * code won't call us | ||
139 | */ | ||
140 | serial = usb_serial_get_by_index(co->index); | ||
138 | if (serial == NULL) { | 141 | if (serial == NULL) { |
139 | /* no device is connected yet, sorry :( */ | 142 | /* no device is connected yet, sorry :( */ |
140 | err ("No USB device connected to ttyUSB0"); | 143 | err ("No USB device connected to ttyUSB%i", co->index); |
141 | return -ENODEV; | 144 | return -ENODEV; |
142 | } | 145 | } |
143 | 146 | ||
@@ -148,49 +151,64 @@ static int usb_console_setup(struct console *co, char *options) | |||
148 | 151 | ||
149 | ++port->open_count; | 152 | ++port->open_count; |
150 | if (port->open_count == 1) { | 153 | if (port->open_count == 1) { |
154 | if (serial->type->set_termios) { | ||
155 | /* | ||
156 | * allocate a fake tty so the driver can initialize | ||
157 | * the termios structure, then later call set_termios to | ||
158 | * configure according to command line arguments | ||
159 | */ | ||
160 | tty = kzalloc(sizeof(*tty), GFP_KERNEL); | ||
161 | if (!tty) { | ||
162 | retval = -ENOMEM; | ||
163 | err("no more memory"); | ||
164 | goto reset_open_count; | ||
165 | } | ||
166 | termios = kzalloc(sizeof(*termios), GFP_KERNEL); | ||
167 | if (!termios) { | ||
168 | retval = -ENOMEM; | ||
169 | err("no more memory"); | ||
170 | goto free_tty; | ||
171 | } | ||
172 | memset(&dummy, 0, sizeof(struct ktermios)); | ||
173 | tty->termios = termios; | ||
174 | port->tty = tty; | ||
175 | } | ||
176 | |||
151 | /* only call the device specific open if this | 177 | /* only call the device specific open if this |
152 | * is the first time the port is opened */ | 178 | * is the first time the port is opened */ |
153 | if (serial->type->open) | 179 | if (serial->type->open) |
154 | retval = serial->type->open(port, NULL); | 180 | retval = serial->type->open(port, NULL); |
155 | else | 181 | else |
156 | retval = usb_serial_generic_open(port, NULL); | 182 | retval = usb_serial_generic_open(port, NULL); |
157 | if (retval) | ||
158 | port->open_count = 0; | ||
159 | } | ||
160 | 183 | ||
161 | if (retval) { | 184 | if (retval) { |
162 | err ("could not open USB console port"); | 185 | err("could not open USB console port"); |
163 | return retval; | 186 | goto free_termios; |
164 | } | ||
165 | |||
166 | if (serial->type->set_termios) { | ||
167 | struct ktermios dummy; | ||
168 | /* build up a fake tty structure so that the open call has something | ||
169 | * to look at to get the cflag value */ | ||
170 | tty = kzalloc(sizeof(*tty), GFP_KERNEL); | ||
171 | if (!tty) { | ||
172 | err ("no more memory"); | ||
173 | return -ENOMEM; | ||
174 | } | 187 | } |
175 | termios = kzalloc(sizeof(*termios), GFP_KERNEL); | ||
176 | if (!termios) { | ||
177 | err ("no more memory"); | ||
178 | kfree (tty); | ||
179 | return -ENOMEM; | ||
180 | } | ||
181 | memset(&dummy, 0, sizeof(struct ktermios)); | ||
182 | termios->c_cflag = cflag; | ||
183 | tty->termios = termios; | ||
184 | port->tty = tty; | ||
185 | 188 | ||
186 | /* set up the initial termios settings */ | 189 | if (serial->type->set_termios) { |
187 | serial->type->set_termios(port, &dummy); | 190 | termios->c_cflag = cflag; |
188 | port->tty = NULL; | 191 | serial->type->set_termios(port, &dummy); |
189 | kfree (termios); | 192 | |
190 | kfree (tty); | 193 | port->tty = NULL; |
194 | kfree(termios); | ||
195 | kfree(tty); | ||
196 | } | ||
191 | } | 197 | } |
192 | 198 | ||
199 | port->console = 1; | ||
200 | retval = 0; | ||
201 | |||
202 | out: | ||
193 | return retval; | 203 | return retval; |
204 | free_termios: | ||
205 | kfree(termios); | ||
206 | port->tty = NULL; | ||
207 | free_tty: | ||
208 | kfree(tty); | ||
209 | reset_open_count: | ||
210 | port->open_count = 0; | ||
211 | goto out; | ||
194 | } | 212 | } |
195 | 213 | ||
196 | static void usb_console_write(struct console *co, const char *buf, unsigned count) | 214 | static void usb_console_write(struct console *co, const char *buf, unsigned count) |
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index 22833589c4be..f3ca66017a03 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c | |||
@@ -59,6 +59,7 @@ static struct usb_device_id id_table [] = { | |||
59 | { USB_DEVICE(0x10A6, 0xAA26) }, /* Knock-off DCU-11 cable */ | 59 | { USB_DEVICE(0x10A6, 0xAA26) }, /* Knock-off DCU-11 cable */ |
60 | { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */ | 60 | { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */ |
61 | { USB_DEVICE(0x10B5, 0xAC70) }, /* Nokia CA-42 USB */ | 61 | { USB_DEVICE(0x10B5, 0xAC70) }, /* Nokia CA-42 USB */ |
62 | { USB_DEVICE(0x10C4, 0x800A) }, /* SPORTident BSM7-D-USB main station */ | ||
62 | { USB_DEVICE(0x10C4, 0x803B) }, /* Pololu USB-serial converter */ | 63 | { USB_DEVICE(0x10C4, 0x803B) }, /* Pololu USB-serial converter */ |
63 | { USB_DEVICE(0x10C4, 0x8053) }, /* Enfora EDG1228 */ | 64 | { USB_DEVICE(0x10C4, 0x8053) }, /* Enfora EDG1228 */ |
64 | { USB_DEVICE(0x10C4, 0x8066) }, /* Argussoft In-System Programmer */ | 65 | { USB_DEVICE(0x10C4, 0x8066) }, /* Argussoft In-System Programmer */ |
@@ -76,8 +77,13 @@ static struct usb_device_id id_table [] = { | |||
76 | { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ | 77 | { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ |
77 | { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ | 78 | { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ |
78 | { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ | 79 | { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ |
80 | { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ | ||
81 | { USB_DEVICE(0x10C4, 0xF002) }, /* Elan Digital Systems USBwave12 */ | ||
82 | { USB_DEVICE(0x10C4, 0xF003) }, /* Elan Digital Systems USBpulse100 */ | ||
83 | { USB_DEVICE(0x10C4, 0xF004) }, /* Elan Digital Systems USBcount50 */ | ||
79 | { USB_DEVICE(0x10C5, 0xEA61) }, /* Silicon Labs MobiData GPRS USB Modem */ | 84 | { USB_DEVICE(0x10C5, 0xEA61) }, /* Silicon Labs MobiData GPRS USB Modem */ |
80 | { USB_DEVICE(0x13AD, 0x9999) }, /* Baltech card reader */ | 85 | { USB_DEVICE(0x13AD, 0x9999) }, /* Baltech card reader */ |
86 | { USB_DEVICE(0x166A, 0x0303) }, /* Clipsal 5500PCU C-Bus USB interface */ | ||
81 | { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ | 87 | { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ |
82 | { } /* Terminating Entry */ | 88 | { } /* Terminating Entry */ |
83 | }; | 89 | }; |
@@ -342,7 +348,10 @@ static void cp2101_close (struct usb_serial_port *port, struct file * filp) | |||
342 | usb_kill_urb(port->write_urb); | 348 | usb_kill_urb(port->write_urb); |
343 | usb_kill_urb(port->read_urb); | 349 | usb_kill_urb(port->read_urb); |
344 | 350 | ||
345 | cp2101_set_config_single(port, CP2101_UART, UART_DISABLE); | 351 | mutex_lock(&port->serial->disc_mutex); |
352 | if (!port->serial->disconnected) | ||
353 | cp2101_set_config_single(port, CP2101_UART, UART_DISABLE); | ||
354 | mutex_unlock(&port->serial->disc_mutex); | ||
346 | } | 355 | } |
347 | 356 | ||
348 | /* | 357 | /* |
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 4353df92487f..8d9b045aa7e8 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c | |||
@@ -319,7 +319,6 @@ static void cyberjack_read_int_callback( struct urb *urb ) | |||
319 | /* React only to interrupts signaling a bulk_in transfer */ | 319 | /* React only to interrupts signaling a bulk_in transfer */ |
320 | if( (urb->actual_length==4) && (data[0]==0x01) ) { | 320 | if( (urb->actual_length==4) && (data[0]==0x01) ) { |
321 | short old_rdtodo; | 321 | short old_rdtodo; |
322 | int result; | ||
323 | 322 | ||
324 | /* This is a announcement of coming bulk_ins. */ | 323 | /* This is a announcement of coming bulk_ins. */ |
325 | unsigned short size = ((unsigned short)data[3]<<8)+data[2]+3; | 324 | unsigned short size = ((unsigned short)data[3]<<8)+data[2]+3; |
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index 163386336a5d..08c65c1a3771 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c | |||
@@ -682,7 +682,6 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) | |||
682 | { | 682 | { |
683 | struct cypress_private *priv = usb_get_serial_port_data(port); | 683 | struct cypress_private *priv = usb_get_serial_port_data(port); |
684 | unsigned int c_cflag; | 684 | unsigned int c_cflag; |
685 | unsigned long flags; | ||
686 | int bps; | 685 | int bps; |
687 | long timeout; | 686 | long timeout; |
688 | wait_queue_t wait; | 687 | wait_queue_t wait; |
@@ -690,7 +689,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) | |||
690 | dbg("%s - port %d", __FUNCTION__, port->number); | 689 | dbg("%s - port %d", __FUNCTION__, port->number); |
691 | 690 | ||
692 | /* wait for data to drain from buffer */ | 691 | /* wait for data to drain from buffer */ |
693 | spin_lock_irqsave(&priv->lock, flags); | 692 | spin_lock_irq(&priv->lock); |
694 | timeout = CYPRESS_CLOSING_WAIT; | 693 | timeout = CYPRESS_CLOSING_WAIT; |
695 | init_waitqueue_entry(&wait, current); | 694 | init_waitqueue_entry(&wait, current); |
696 | add_wait_queue(&port->tty->write_wait, &wait); | 695 | add_wait_queue(&port->tty->write_wait, &wait); |
@@ -698,18 +697,25 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) | |||
698 | set_current_state(TASK_INTERRUPTIBLE); | 697 | set_current_state(TASK_INTERRUPTIBLE); |
699 | if (cypress_buf_data_avail(priv->buf) == 0 | 698 | if (cypress_buf_data_avail(priv->buf) == 0 |
700 | || timeout == 0 || signal_pending(current) | 699 | || timeout == 0 || signal_pending(current) |
701 | || !usb_get_intfdata(port->serial->interface)) | 700 | /* without mutex, allowed due to harmless failure mode */ |
701 | || port->serial->disconnected) | ||
702 | break; | 702 | break; |
703 | spin_unlock_irqrestore(&priv->lock, flags); | 703 | spin_unlock_irq(&priv->lock); |
704 | timeout = schedule_timeout(timeout); | 704 | timeout = schedule_timeout(timeout); |
705 | spin_lock_irqsave(&priv->lock, flags); | 705 | spin_lock_irq(&priv->lock); |
706 | } | 706 | } |
707 | set_current_state(TASK_RUNNING); | 707 | set_current_state(TASK_RUNNING); |
708 | remove_wait_queue(&port->tty->write_wait, &wait); | 708 | remove_wait_queue(&port->tty->write_wait, &wait); |
709 | /* clear out any remaining data in the buffer */ | 709 | /* clear out any remaining data in the buffer */ |
710 | cypress_buf_clear(priv->buf); | 710 | cypress_buf_clear(priv->buf); |
711 | spin_unlock_irqrestore(&priv->lock, flags); | 711 | spin_unlock_irq(&priv->lock); |
712 | 712 | ||
713 | /* writing is potentially harmful, lock must be taken */ | ||
714 | mutex_lock(&port->serial->disc_mutex); | ||
715 | if (port->serial->disconnected) { | ||
716 | mutex_unlock(&port->serial->disc_mutex); | ||
717 | return; | ||
718 | } | ||
713 | /* wait for characters to drain from device */ | 719 | /* wait for characters to drain from device */ |
714 | bps = tty_get_baud_rate(port->tty); | 720 | bps = tty_get_baud_rate(port->tty); |
715 | if (bps > 1200) | 721 | if (bps > 1200) |
@@ -727,10 +733,10 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) | |||
727 | if (c_cflag & HUPCL) { | 733 | if (c_cflag & HUPCL) { |
728 | /* drop dtr and rts */ | 734 | /* drop dtr and rts */ |
729 | priv = usb_get_serial_port_data(port); | 735 | priv = usb_get_serial_port_data(port); |
730 | spin_lock_irqsave(&priv->lock, flags); | 736 | spin_lock_irq(&priv->lock); |
731 | priv->line_control = 0; | 737 | priv->line_control = 0; |
732 | priv->cmd_ctrl = 1; | 738 | priv->cmd_ctrl = 1; |
733 | spin_unlock_irqrestore(&priv->lock, flags); | 739 | spin_unlock_irq(&priv->lock); |
734 | cypress_write(port, NULL, 0); | 740 | cypress_write(port, NULL, 0); |
735 | } | 741 | } |
736 | } | 742 | } |
@@ -738,6 +744,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) | |||
738 | if (stats) | 744 | if (stats) |
739 | dev_info (&port->dev, "Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n", | 745 | dev_info (&port->dev, "Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n", |
740 | priv->bytes_in, priv->bytes_out, priv->cmd_count); | 746 | priv->bytes_in, priv->bytes_out, priv->cmd_count); |
747 | mutex_unlock(&port->serial->disc_mutex); | ||
741 | } /* cypress_close */ | 748 | } /* cypress_close */ |
742 | 749 | ||
743 | 750 | ||
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index ae410c4678ea..5f9c6e46bee5 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -1405,19 +1405,19 @@ static void digi_close(struct usb_serial_port *port, struct file *filp) | |||
1405 | unsigned char buf[32]; | 1405 | unsigned char buf[32]; |
1406 | struct tty_struct *tty = port->tty; | 1406 | struct tty_struct *tty = port->tty; |
1407 | struct digi_port *priv = usb_get_serial_port_data(port); | 1407 | struct digi_port *priv = usb_get_serial_port_data(port); |
1408 | unsigned long flags = 0; | ||
1409 | 1408 | ||
1410 | dbg("digi_close: TOP: port=%d, open_count=%d", | 1409 | dbg("digi_close: TOP: port=%d, open_count=%d", |
1411 | priv->dp_port_num, port->open_count); | 1410 | priv->dp_port_num, port->open_count); |
1412 | 1411 | ||
1412 | mutex_lock(&port->serial->disc_mutex); | ||
1413 | /* if disconnected, just clear flags */ | 1413 | /* if disconnected, just clear flags */ |
1414 | if (!usb_get_intfdata(port->serial->interface)) | 1414 | if (port->serial->disconnected) |
1415 | goto exit; | 1415 | goto exit; |
1416 | 1416 | ||
1417 | /* do cleanup only after final close on this port */ | 1417 | /* do cleanup only after final close on this port */ |
1418 | spin_lock_irqsave(&priv->dp_port_lock, flags); | 1418 | spin_lock_irq(&priv->dp_port_lock); |
1419 | priv->dp_in_close = 1; | 1419 | priv->dp_in_close = 1; |
1420 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); | 1420 | spin_unlock_irq(&priv->dp_port_lock); |
1421 | 1421 | ||
1422 | /* tell line discipline to process only XON/XOFF */ | 1422 | /* tell line discipline to process only XON/XOFF */ |
1423 | tty->closing = 1; | 1423 | tty->closing = 1; |
@@ -1482,11 +1482,12 @@ static void digi_close(struct usb_serial_port *port, struct file *filp) | |||
1482 | } | 1482 | } |
1483 | tty->closing = 0; | 1483 | tty->closing = 0; |
1484 | exit: | 1484 | exit: |
1485 | spin_lock_irqsave(&priv->dp_port_lock, flags); | 1485 | spin_lock_irq(&priv->dp_port_lock); |
1486 | priv->dp_write_urb_in_use = 0; | 1486 | priv->dp_write_urb_in_use = 0; |
1487 | priv->dp_in_close = 0; | 1487 | priv->dp_in_close = 0; |
1488 | wake_up_interruptible(&priv->dp_close_wait); | 1488 | wake_up_interruptible(&priv->dp_close_wait); |
1489 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); | 1489 | spin_unlock_irq(&priv->dp_port_lock); |
1490 | mutex_unlock(&port->serial->disc_mutex); | ||
1490 | dbg("digi_close: done"); | 1491 | dbg("digi_close: done"); |
1491 | } | 1492 | } |
1492 | 1493 | ||
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c index 97ee718b1da2..3f698baa0abb 100644 --- a/drivers/usb/serial/ezusb.c +++ b/drivers/usb/serial/ezusb.c | |||
@@ -53,6 +53,6 @@ int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit) | |||
53 | } | 53 | } |
54 | 54 | ||
55 | 55 | ||
56 | EXPORT_SYMBOL(ezusb_writememory); | 56 | EXPORT_SYMBOL_GPL(ezusb_writememory); |
57 | EXPORT_SYMBOL(ezusb_set_reset); | 57 | EXPORT_SYMBOL_GPL(ezusb_set_reset); |
58 | 58 | ||
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index c40e77dccf8e..90dcc625f70d 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -17,226 +17,8 @@ | |||
17 | * See http://ftdi-usb-sio.sourceforge.net for upto date testing info | 17 | * See http://ftdi-usb-sio.sourceforge.net for upto date testing info |
18 | * and extra documentation | 18 | * and extra documentation |
19 | * | 19 | * |
20 | * (21/Jul/2004) Ian Abbott | 20 | * Change entries from 2004 and earlier can be found in versions of this |
21 | * Incorporated Steven Turner's code to add support for the FT2232C chip. | 21 | * file in kernel versions prior to the 2.6.24 release. |
22 | * The prelimilary port to the 2.6 kernel was by Rus V. Brushkoff. I have | ||
23 | * fixed a couple of things. | ||
24 | * | ||
25 | * (27/May/2004) Ian Abbott | ||
26 | * Improved throttling code, mostly stolen from the WhiteHEAT driver. | ||
27 | * | ||
28 | * (26/Mar/2004) Jan Capek | ||
29 | * Added PID's for ICD-U20/ICD-U40 - incircuit PIC debuggers from CCS Inc. | ||
30 | * | ||
31 | * (09/Feb/2004) Ian Abbott | ||
32 | * Changed full name of USB-UIRT device to avoid "/" character. | ||
33 | * Added FTDI's alternate PID (0x6006) for FT232/245 devices. | ||
34 | * Added PID for "ELV USB Module UO100" from Stefan Frings. | ||
35 | * | ||
36 | * (21/Oct/2003) Ian Abbott | ||
37 | * Renamed some VID/PID macros for Matrix Orbital and Perle Systems | ||
38 | * devices. Removed Matrix Orbital and Perle Systems devices from the | ||
39 | * 8U232AM device table, but left them in the FT232BM table, as they are | ||
40 | * known to use only FT232BM. | ||
41 | * | ||
42 | * (17/Oct/2003) Scott Allen | ||
43 | * Added vid/pid for Perle Systems UltraPort USB serial converters | ||
44 | * | ||
45 | * (21/Sep/2003) Ian Abbott | ||
46 | * Added VID/PID for Omnidirectional Control Technology US101 USB to | ||
47 | * RS-232 adapter (also rebadged as Dick Smith Electronics XH6381). | ||
48 | * VID/PID supplied by Donald Gordon. | ||
49 | * | ||
50 | * (19/Aug/2003) Ian Abbott | ||
51 | * Freed urb's transfer buffer in write bulk callback. | ||
52 | * Omitted some paranoid checks in write bulk callback that don't matter. | ||
53 | * Scheduled work in write bulk callback regardless of port's open count. | ||
54 | * | ||
55 | * (05/Aug/2003) Ian Abbott | ||
56 | * Added VID/PID for ID TECH IDT1221U USB to RS-232 adapter. | ||
57 | * VID/PID provided by Steve Briggs. | ||
58 | * | ||
59 | * (23/Jul/2003) Ian Abbott | ||
60 | * Added PIDs for CrystalFontz 547, 633, 631, 635, 640 and 640 from | ||
61 | * Wayne Wylupski. | ||
62 | * | ||
63 | * (10/Jul/2003) David Glance | ||
64 | * Added PID for DSS-20 SyncStation cradle for Sony-Ericsson P800. | ||
65 | * | ||
66 | * (27/Jun/2003) Ian Abbott | ||
67 | * Reworked the urb handling logic. We have no more pool, but dynamically | ||
68 | * allocate the urb and the transfer buffer on the fly. In testing this | ||
69 | * does not incure any measurable overhead. This also relies on the fact | ||
70 | * that we have proper reference counting logic for urbs. I nicked this | ||
71 | * from Greg KH's Visor driver. | ||
72 | * | ||
73 | * (23/Jun/2003) Ian Abbott | ||
74 | * Reduced flip buffer pushes and corrected a data length test in | ||
75 | * ftdi_read_bulk_callback. | ||
76 | * Defererence pointers after any paranoid checks, not before. | ||
77 | * | ||
78 | * (21/Jun/2003) Erik Nygren | ||
79 | * Added support for Home Electronics Tira-1 IR transceiver using FT232BM chip. | ||
80 | * See <http://www.home-electro.com/tira1.htm>. Only operates properly | ||
81 | * at 100000 and RTS-CTS, so set custom divisor mode on startup. | ||
82 | * Also force the Tira-1 and USB-UIRT to only use their custom baud rates. | ||
83 | * | ||
84 | * (18/Jun/2003) Ian Abbott | ||
85 | * Added Device ID of the USB relais from Rudolf Gugler (backported from | ||
86 | * Philipp Gühring's patch for 2.5.x kernel). | ||
87 | * Moved read transfer buffer reallocation into startup function. | ||
88 | * Free existing write urb and transfer buffer in startup function. | ||
89 | * Only use urbs in write urb pool that were successfully allocated. | ||
90 | * Moved some constant macros out of functions. | ||
91 | * Minor whitespace and comment changes. | ||
92 | * | ||
93 | * (12/Jun/2003) David Norwood | ||
94 | * Added support for USB-UIRT IR transceiver using 8U232AM chip. | ||
95 | * See <http://home.earthlink.net/~jrhees/USBUIRT/index.htm>. Only | ||
96 | * operates properly at 312500, so set custom divisor mode on startup. | ||
97 | * | ||
98 | * (12/Jun/2003) Ian Abbott | ||
99 | * Added Sealevel SeaLINK+ 210x, 220x, 240x, 280x vid/pids from Tuan Hoang | ||
100 | * - I've eliminated some that don't seem to exist! | ||
101 | * Added Home Electronics Tira-1 IR transceiver pid from Chris Horn | ||
102 | * Some whitespace/coding-style cleanups | ||
103 | * | ||
104 | * (11/Jun/2003) Ian Abbott | ||
105 | * Fixed unsafe spinlock usage in ftdi_write | ||
106 | * | ||
107 | * (24/Feb/2003) Richard Shooter | ||
108 | * Increase read buffer size to improve read speeds at higher baud rates | ||
109 | * (specifically tested with up to 1Mb/sec at 1.5M baud) | ||
110 | * | ||
111 | * (23/Feb/2003) John Wilkins | ||
112 | * Added Xon/xoff flow control (activating support in the ftdi device) | ||
113 | * Added vid/pid for Videonetworks/Homechoice (UK ISP) | ||
114 | * | ||
115 | * (23/Feb/2003) Bill Ryder | ||
116 | * Added matrix orb device vid/pids from Wayne Wylupski | ||
117 | * | ||
118 | * (19/Feb/2003) Ian Abbott | ||
119 | * For TIOCSSERIAL, set alt_speed to 0 when ASYNC_SPD_MASK value has | ||
120 | * changed to something other than ASYNC_SPD_HI, ASYNC_SPD_VHI, | ||
121 | * ASYNC_SPD_SHI or ASYNC_SPD_WARP. Also, unless ASYNC_SPD_CUST is in | ||
122 | * force, don't bother changing baud rate when custom_divisor has changed. | ||
123 | * | ||
124 | * (18/Feb/2003) Ian Abbott | ||
125 | * Fixed TIOCMGET handling to include state of DTR and RTS, the state | ||
126 | * of which are now saved by set_dtr() and set_rts(). | ||
127 | * Fixed improper storage class for buf in set_dtr() and set_rts(). | ||
128 | * Added FT232BM chip type and support for its extra baud rates (compared | ||
129 | * to FT8U232AM). | ||
130 | * Took account of special case divisor values for highest baud rates of | ||
131 | * FT8U232AM and FT232BM. | ||
132 | * For TIOCSSERIAL, forced alt_speed to 0 when ASYNC_SPD_CUST kludge used, | ||
133 | * as previous alt_speed setting is now stale. | ||
134 | * Moved startup code common between the startup routines for the | ||
135 | * different chip types into a common subroutine. | ||
136 | * | ||
137 | * (17/Feb/2003) Bill Ryder | ||
138 | * Added write urb buffer pool on a per device basis | ||
139 | * Added more checking for open file on callbacks (fixed OOPS) | ||
140 | * Added CrystalFontz 632 and 634 PIDs | ||
141 | * (thanx to CrystalFontz for the sample devices - they flushed out | ||
142 | * some driver bugs) | ||
143 | * Minor debugging message changes | ||
144 | * Added throttle, unthrottle and chars_in_buffer functions | ||
145 | * Fixed FTDI_SIO (the original device) bug | ||
146 | * Fixed some shutdown handling | ||
147 | * | ||
148 | * | ||
149 | * | ||
150 | * | ||
151 | * (07/Jun/2002) Kuba Ober | ||
152 | * Changed FTDI_SIO_BASE_BAUD_TO_DIVISOR macro into ftdi_baud_to_divisor | ||
153 | * function. It was getting too complex. | ||
154 | * Fix the divisor calculation logic which was setting divisor of 0.125 | ||
155 | * instead of 0.5 for fractional parts of divisor equal to 5/8, 6/8, 7/8. | ||
156 | * Also make it bump up the divisor to next integer in case of 7/8 - it's | ||
157 | * a better approximation. | ||
158 | * | ||
159 | * (25/Jul/2002) Bill Ryder inserted Dmitri's TIOCMIWAIT patch | ||
160 | * Not tested by me but it doesn't break anything I use. | ||
161 | * | ||
162 | * (04/Jan/2002) Kuba Ober | ||
163 | * Implemented 38400 baudrate kludge, where it can be substituted with other | ||
164 | * values. That's the only way to set custom baudrates. | ||
165 | * Implemented TIOCSSERIAL, TIOCGSERIAL ioctl's so that setserial is happy. | ||
166 | * FIXME: both baudrate things should eventually go to usbserial.c as other | ||
167 | * devices may need that functionality too. Actually, it can probably be | ||
168 | * merged in serial.c somehow - too many drivers repeat this code over | ||
169 | * and over. | ||
170 | * Fixed baudrate forgetfulness - open() used to reset baudrate to 9600 every time. | ||
171 | * Divisors for baudrates are calculated by a macro. | ||
172 | * Small code cleanups. Ugly whitespace changes for Plato's sake only ;-]. | ||
173 | * | ||
174 | * (04/Nov/2001) Bill Ryder | ||
175 | * Fixed bug in read_bulk_callback where incorrect urb buffer was used. | ||
176 | * Cleaned up write offset calculation | ||
177 | * Added write_room since default values can be incorrect for sio | ||
178 | * Changed write_bulk_callback to use same queue_task as other drivers | ||
179 | * (the previous version caused panics) | ||
180 | * Removed port iteration code since the device only has one I/O port and it | ||
181 | * was wrong anyway. | ||
182 | * | ||
183 | * (31/May/2001) gkh | ||
184 | * Switched from using spinlock to a semaphore, which fixes lots of problems. | ||
185 | * | ||
186 | * (23/May/2001) Bill Ryder | ||
187 | * Added runtime debug patch (thanx Tyson D Sawyer). | ||
188 | * Cleaned up comments for 8U232 | ||
189 | * Added parity, framing and overrun error handling | ||
190 | * Added receive break handling. | ||
191 | * | ||
192 | * (04/08/2001) gb | ||
193 | * Identify version on module load. | ||
194 | * | ||
195 | * (18/March/2001) Bill Ryder | ||
196 | * (Not released) | ||
197 | * Added send break handling. (requires kernel patch too) | ||
198 | * Fixed 8U232AM hardware RTS/CTS etc status reporting. | ||
199 | * Added flipbuf fix copied from generic device | ||
200 | * | ||
201 | * (12/3/2000) Bill Ryder | ||
202 | * Added support for 8U232AM device. | ||
203 | * Moved PID and VIDs into header file only. | ||
204 | * Turned on low-latency for the tty (device will do high baudrates) | ||
205 | * Added shutdown routine to close files when device removed. | ||
206 | * More debug and error message cleanups. | ||
207 | * | ||
208 | * (11/13/2000) Bill Ryder | ||
209 | * Added spinlock protected open code and close code. | ||
210 | * Multiple opens work (sort of - see webpage mentioned above). | ||
211 | * Cleaned up comments. Removed multiple PID/VID definitions. | ||
212 | * Factorised cts/dtr code | ||
213 | * Made use of __FUNCTION__ in dbg's | ||
214 | * | ||
215 | * (11/01/2000) Adam J. Richter | ||
216 | * usb_device_id table support | ||
217 | * | ||
218 | * (10/05/2000) gkh | ||
219 | * Fixed bug with urb->dev not being set properly, now that the usb | ||
220 | * core needs it. | ||
221 | * | ||
222 | * (09/11/2000) gkh | ||
223 | * Removed DEBUG #ifdefs with call to usb_serial_debug_data | ||
224 | * | ||
225 | * (07/19/2000) gkh | ||
226 | * Added module_init and module_exit functions to handle the fact that this | ||
227 | * driver is a loadable module now. | ||
228 | * | ||
229 | * (04/04/2000) Bill Ryder | ||
230 | * Fixed bugs in TCGET/TCSET ioctls (by removing them - they are | ||
231 | * handled elsewhere in the tty io driver chain). | ||
232 | * | ||
233 | * (03/30/2000) Bill Ryder | ||
234 | * Implemented lots of ioctls | ||
235 | * Fixed a race condition in write | ||
236 | * Changed some dbg's to errs | ||
237 | * | ||
238 | * (03/26/2000) gkh | ||
239 | * Split driver up into device specific pieces. | ||
240 | * | 22 | * |
241 | */ | 23 | */ |
242 | 24 | ||
@@ -309,12 +91,12 @@ struct ftdi_sio_quirk { | |||
309 | void (*port_probe)(struct ftdi_private *); /* Special settings for probed ports. */ | 91 | void (*port_probe)(struct ftdi_private *); /* Special settings for probed ports. */ |
310 | }; | 92 | }; |
311 | 93 | ||
312 | static int ftdi_olimex_probe (struct usb_serial *serial); | 94 | static int ftdi_jtag_probe (struct usb_serial *serial); |
313 | static void ftdi_USB_UIRT_setup (struct ftdi_private *priv); | 95 | static void ftdi_USB_UIRT_setup (struct ftdi_private *priv); |
314 | static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv); | 96 | static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv); |
315 | 97 | ||
316 | static struct ftdi_sio_quirk ftdi_olimex_quirk = { | 98 | static struct ftdi_sio_quirk ftdi_jtag_quirk = { |
317 | .probe = ftdi_olimex_probe, | 99 | .probe = ftdi_jtag_probe, |
318 | }; | 100 | }; |
319 | 101 | ||
320 | static struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = { | 102 | static struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = { |
@@ -471,30 +253,28 @@ static struct usb_device_id id_table_combined [] = { | |||
471 | { USB_DEVICE(FTDI_VID, FTDI_IBS_PEDO_PID) }, | 253 | { USB_DEVICE(FTDI_VID, FTDI_IBS_PEDO_PID) }, |
472 | { USB_DEVICE(FTDI_VID, FTDI_IBS_PROD_PID) }, | 254 | { USB_DEVICE(FTDI_VID, FTDI_IBS_PROD_PID) }, |
473 | /* | 255 | /* |
474 | * These will probably use user-space drivers. Uncomment them if | 256 | * Due to many user requests for multiple ELV devices we enable |
475 | * you need them or use the user-specified vendor/product module | 257 | * them by default. |
476 | * parameters (see ftdi_sio.h for the numbers). Make a fuss if | ||
477 | * you think the driver should recognize any of them by default. | ||
478 | */ | 258 | */ |
479 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_CLI7000_PID) }, */ | 259 | { USB_DEVICE(FTDI_VID, FTDI_ELV_CLI7000_PID) }, |
480 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PPS7330_PID) }, */ | 260 | { USB_DEVICE(FTDI_VID, FTDI_ELV_PPS7330_PID) }, |
481 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_TFM100_PID) }, */ | 261 | { USB_DEVICE(FTDI_VID, FTDI_ELV_TFM100_PID) }, |
482 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_UDF77_PID) }, */ | 262 | { USB_DEVICE(FTDI_VID, FTDI_ELV_UDF77_PID) }, |
483 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_UIO88_PID) }, */ | 263 | { USB_DEVICE(FTDI_VID, FTDI_ELV_UIO88_PID) }, |
484 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_UAD8_PID) }, */ | 264 | { USB_DEVICE(FTDI_VID, FTDI_ELV_UAD8_PID) }, |
485 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_UDA7_PID) }, */ | 265 | { USB_DEVICE(FTDI_VID, FTDI_ELV_UDA7_PID) }, |
486 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_USI2_PID) }, */ | 266 | { USB_DEVICE(FTDI_VID, FTDI_ELV_USI2_PID) }, |
487 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_T1100_PID) }, */ | 267 | { USB_DEVICE(FTDI_VID, FTDI_ELV_T1100_PID) }, |
488 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PCD200_PID) }, */ | 268 | { USB_DEVICE(FTDI_VID, FTDI_ELV_PCD200_PID) }, |
489 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_ULA200_PID) }, */ | 269 | { USB_DEVICE(FTDI_VID, FTDI_ELV_ULA200_PID) }, |
490 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_CSI8_PID) }, */ | 270 | { USB_DEVICE(FTDI_VID, FTDI_ELV_CSI8_PID) }, |
491 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1000DL_PID) }, */ | 271 | { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1000DL_PID) }, |
492 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PCK100_PID) }, */ | 272 | { USB_DEVICE(FTDI_VID, FTDI_ELV_PCK100_PID) }, |
493 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_RFP500_PID) }, */ | 273 | { USB_DEVICE(FTDI_VID, FTDI_ELV_RFP500_PID) }, |
494 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FS20SIG_PID) }, */ | 274 | { USB_DEVICE(FTDI_VID, FTDI_ELV_FS20SIG_PID) }, |
495 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, */ | 275 | { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, |
496 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, */ | 276 | { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, |
497 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, */ | 277 | { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, |
498 | { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) }, | 278 | { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) }, |
499 | { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) }, | 279 | { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) }, |
500 | { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) }, | 280 | { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) }, |
@@ -545,6 +325,7 @@ static struct usb_device_id id_table_combined [] = { | |||
545 | { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) }, | 325 | { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) }, |
546 | { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) }, | 326 | { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) }, |
547 | { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HRC_PID) }, | 327 | { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HRC_PID) }, |
328 | { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16IC_PID) }, | ||
548 | { USB_DEVICE(KOBIL_VID, KOBIL_CONV_B1_PID) }, | 329 | { USB_DEVICE(KOBIL_VID, KOBIL_CONV_B1_PID) }, |
549 | { USB_DEVICE(KOBIL_VID, KOBIL_CONV_KAAN_PID) }, | 330 | { USB_DEVICE(KOBIL_VID, KOBIL_CONV_KAAN_PID) }, |
550 | { USB_DEVICE(POSIFLEX_VID, POSIFLEX_PP7000_PID) }, | 331 | { USB_DEVICE(POSIFLEX_VID, POSIFLEX_PP7000_PID) }, |
@@ -569,8 +350,13 @@ static struct usb_device_id id_table_combined [] = { | |||
569 | { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) }, | 350 | { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) }, |
570 | { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) }, | 351 | { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) }, |
571 | { USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) }, | 352 | { USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) }, |
353 | { USB_DEVICE(FTDI_VID, FTDI_ELSTER_UNICOM_PID) }, | ||
572 | { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_PID), | 354 | { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_PID), |
573 | .driver_info = (kernel_ulong_t)&ftdi_olimex_quirk }, | 355 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
356 | { USB_DEVICE(FIC_VID, FIC_NEO1973_DEBUG_PID), | ||
357 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | ||
358 | { USB_DEVICE(FTDI_VID, FTDI_OOCDLINK_PID), | ||
359 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | ||
574 | { }, /* Optional parameter entry */ | 360 | { }, /* Optional parameter entry */ |
575 | { } /* Terminating entry */ | 361 | { } /* Terminating entry */ |
576 | }; | 362 | }; |
@@ -1283,10 +1069,11 @@ static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv) | |||
1283 | } /* ftdi_HE_TIRA1_setup */ | 1069 | } /* ftdi_HE_TIRA1_setup */ |
1284 | 1070 | ||
1285 | /* | 1071 | /* |
1286 | * First port on Olimex arm-usb-ocd is reserved for JTAG interface | 1072 | * First port on JTAG adaptors such as Olimex arm-usb-ocd or the FIC/OpenMoko |
1287 | * and can be accessed from userspace using openocd. | 1073 | * Neo1973 Debug Board is reserved for JTAG interface and can be accessed from |
1074 | * userspace using openocd. | ||
1288 | */ | 1075 | */ |
1289 | static int ftdi_olimex_probe(struct usb_serial *serial) | 1076 | static int ftdi_jtag_probe(struct usb_serial *serial) |
1290 | { | 1077 | { |
1291 | struct usb_device *udev = serial->dev; | 1078 | struct usb_device *udev = serial->dev; |
1292 | struct usb_interface *interface = serial->interface; | 1079 | struct usb_interface *interface = serial->interface; |
@@ -1294,7 +1081,7 @@ static int ftdi_olimex_probe(struct usb_serial *serial) | |||
1294 | dbg("%s",__FUNCTION__); | 1081 | dbg("%s",__FUNCTION__); |
1295 | 1082 | ||
1296 | if (interface == udev->actconfig->interface[0]) { | 1083 | if (interface == udev->actconfig->interface[0]) { |
1297 | info("Ignoring reserved serial port on Olimex arm-usb-ocd\n"); | 1084 | info("Ignoring serial port reserved for JTAG"); |
1298 | return -ENODEV; | 1085 | return -ENODEV; |
1299 | } | 1086 | } |
1300 | 1087 | ||
@@ -1411,7 +1198,8 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp) | |||
1411 | 1198 | ||
1412 | dbg("%s", __FUNCTION__); | 1199 | dbg("%s", __FUNCTION__); |
1413 | 1200 | ||
1414 | if (c_cflag & HUPCL){ | 1201 | mutex_lock(&port->serial->disc_mutex); |
1202 | if (c_cflag & HUPCL && !port->serial->disconnected){ | ||
1415 | /* Disable flow control */ | 1203 | /* Disable flow control */ |
1416 | if (usb_control_msg(port->serial->dev, | 1204 | if (usb_control_msg(port->serial->dev, |
1417 | usb_sndctrlpipe(port->serial->dev, 0), | 1205 | usb_sndctrlpipe(port->serial->dev, 0), |
@@ -1425,6 +1213,7 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp) | |||
1425 | /* drop RTS and DTR */ | 1213 | /* drop RTS and DTR */ |
1426 | clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); | 1214 | clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); |
1427 | } /* Note change no line if hupcl is off */ | 1215 | } /* Note change no line if hupcl is off */ |
1216 | mutex_unlock(&port->serial->disc_mutex); | ||
1428 | 1217 | ||
1429 | /* cancel any scheduled reading */ | 1218 | /* cancel any scheduled reading */ |
1430 | cancel_delayed_work(&priv->rx_work); | 1219 | cancel_delayed_work(&priv->rx_work); |
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index b51cbb0eaa05..6eee2ab914ec 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h | |||
@@ -98,6 +98,10 @@ | |||
98 | #define FTDI_MTXORB_5_PID 0xFA05 /* Matrix Orbital Product Id */ | 98 | #define FTDI_MTXORB_5_PID 0xFA05 /* Matrix Orbital Product Id */ |
99 | #define FTDI_MTXORB_6_PID 0xFA06 /* Matrix Orbital Product Id */ | 99 | #define FTDI_MTXORB_6_PID 0xFA06 /* Matrix Orbital Product Id */ |
100 | 100 | ||
101 | /* OOCDlink by Joern Kaipf <joernk@web.de> | ||
102 | * (http://www.joernonline.de/dw/doku.php?id=start&idx=projects:oocdlink) */ | ||
103 | #define FTDI_OOCDLINK_PID 0xbaf8 /* Amontec JTAGkey */ | ||
104 | |||
101 | /* Interbiometrics USB I/O Board */ | 105 | /* Interbiometrics USB I/O Board */ |
102 | /* Developed for Interbiometrics by Rudolf Gugler */ | 106 | /* Developed for Interbiometrics by Rudolf Gugler */ |
103 | #define INTERBIOMETRICS_VID 0x1209 | 107 | #define INTERBIOMETRICS_VID 0x1209 |
@@ -245,6 +249,7 @@ | |||
245 | #define FTDI_ELV_WS300PC_PID 0xE0F6 /* PC-Wetterstation (WS 300 PC) */ | 249 | #define FTDI_ELV_WS300PC_PID 0xE0F6 /* PC-Wetterstation (WS 300 PC) */ |
246 | #define FTDI_ELV_FHZ1300PC_PID 0xE0E8 /* FHZ 1300 PC */ | 250 | #define FTDI_ELV_FHZ1300PC_PID 0xE0E8 /* FHZ 1300 PC */ |
247 | #define FTDI_ELV_WS500_PID 0xE0E9 /* PC-Wetterstation (WS 500) */ | 251 | #define FTDI_ELV_WS500_PID 0xE0E9 /* PC-Wetterstation (WS 500) */ |
252 | #define FTDI_ELV_EM1010PC_PID 0xE0EF /* Engery monitor EM 1010 PC */ | ||
248 | 253 | ||
249 | /* | 254 | /* |
250 | * Definitions for ID TECH (www.idt-net.com) devices | 255 | * Definitions for ID TECH (www.idt-net.com) devices |
@@ -278,6 +283,7 @@ | |||
278 | #define FTDI_ATIK_ATK16C_PID 0xDF32 /* ATIK ATK-16C Colour Camera */ | 283 | #define FTDI_ATIK_ATK16C_PID 0xDF32 /* ATIK ATK-16C Colour Camera */ |
279 | #define FTDI_ATIK_ATK16HR_PID 0xDF31 /* ATIK ATK-16HR Grayscale Camera */ | 284 | #define FTDI_ATIK_ATK16HR_PID 0xDF31 /* ATIK ATK-16HR Grayscale Camera */ |
280 | #define FTDI_ATIK_ATK16HRC_PID 0xDF33 /* ATIK ATK-16HRC Colour Camera */ | 285 | #define FTDI_ATIK_ATK16HRC_PID 0xDF33 /* ATIK ATK-16HRC Colour Camera */ |
286 | #define FTDI_ATIK_ATK16IC_PID 0xDF35 /* ATIK ATK-16IC Grayscale Camera */ | ||
281 | 287 | ||
282 | /* | 288 | /* |
283 | * Protego product ids | 289 | * Protego product ids |
@@ -534,6 +540,8 @@ | |||
534 | #define OLIMEX_VID 0x15BA | 540 | #define OLIMEX_VID 0x15BA |
535 | #define OLIMEX_ARM_USB_OCD_PID 0x0003 | 541 | #define OLIMEX_ARM_USB_OCD_PID 0x0003 |
536 | 542 | ||
543 | /* www.elsterelectricity.com Elster Unicom III Optical Probe */ | ||
544 | #define FTDI_ELSTER_UNICOM_PID 0xE700 /* Product Id */ | ||
537 | 545 | ||
538 | /* | 546 | /* |
539 | * The Mobility Lab (TML) | 547 | * The Mobility Lab (TML) |
@@ -556,6 +564,13 @@ | |||
556 | 564 | ||
557 | 565 | ||
558 | /* | 566 | /* |
567 | * FIC / OpenMoko, Inc. http://wiki.openmoko.org/wiki/Neo1973_Debug_Board_v3 | ||
568 | * Submitted by Harald Welte <laforge@openmoko.org> | ||
569 | */ | ||
570 | #define FIC_VID 0x1457 | ||
571 | #define FIC_NEO1973_DEBUG_PID 0x5118 | ||
572 | |||
573 | /* | ||
559 | * BmRequestType: 1100 0000b | 574 | * BmRequestType: 1100 0000b |
560 | * bRequest: FTDI_E2_READ | 575 | * bRequest: FTDI_E2_READ |
561 | * wValue: 0 | 576 | * wValue: 0 |
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index f1c90cfe7251..d74e43d69230 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c | |||
@@ -1020,19 +1020,26 @@ static void garmin_close (struct usb_serial_port *port, struct file * filp) | |||
1020 | if (!serial) | 1020 | if (!serial) |
1021 | return; | 1021 | return; |
1022 | 1022 | ||
1023 | garmin_clear(garmin_data_p); | 1023 | mutex_lock(&port->serial->disc_mutex); |
1024 | if (!port->serial->disconnected) | ||
1025 | garmin_clear(garmin_data_p); | ||
1024 | 1026 | ||
1025 | /* shutdown our urbs */ | 1027 | /* shutdown our urbs */ |
1026 | usb_kill_urb (port->read_urb); | 1028 | usb_kill_urb (port->read_urb); |
1027 | usb_kill_urb (port->write_urb); | 1029 | usb_kill_urb (port->write_urb); |
1028 | 1030 | ||
1029 | if (noResponseFromAppLayer(garmin_data_p) || | 1031 | if (!port->serial->disconnected) { |
1030 | ((garmin_data_p->flags & CLEAR_HALT_REQUIRED) != 0)) { | 1032 | if (noResponseFromAppLayer(garmin_data_p) || |
1031 | process_resetdev_request(port); | 1033 | ((garmin_data_p->flags & CLEAR_HALT_REQUIRED) != 0)) { |
1032 | garmin_data_p->state = STATE_RESET; | 1034 | process_resetdev_request(port); |
1035 | garmin_data_p->state = STATE_RESET; | ||
1036 | } else { | ||
1037 | garmin_data_p->state = STATE_DISCONNECTED; | ||
1038 | } | ||
1033 | } else { | 1039 | } else { |
1034 | garmin_data_p->state = STATE_DISCONNECTED; | 1040 | garmin_data_p->state = STATE_DISCONNECTED; |
1035 | } | 1041 | } |
1042 | mutex_unlock(&port->serial->disc_mutex); | ||
1036 | } | 1043 | } |
1037 | 1044 | ||
1038 | 1045 | ||
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index d41531139c55..97fa3c428435 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -175,6 +175,14 @@ int usb_serial_generic_resume(struct usb_serial *serial) | |||
175 | struct usb_serial_port *port; | 175 | struct usb_serial_port *port; |
176 | int i, c = 0, r; | 176 | int i, c = 0, r; |
177 | 177 | ||
178 | #ifdef CONFIG_PM | ||
179 | /* | ||
180 | * If this is an autoresume, don't submit URBs. | ||
181 | * They will be submitted in the open function instead. | ||
182 | */ | ||
183 | if (serial->dev->auto_pm) | ||
184 | return 0; | ||
185 | #endif | ||
178 | for (i = 0; i < serial->num_ports; i++) { | 186 | for (i = 0; i < serial->num_ports; i++) { |
179 | port = serial->port[i]; | 187 | port = serial->port[i]; |
180 | if (port->open_count && port->read_urb) { | 188 | if (port->open_count && port->read_urb) { |
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index a5d2e115e167..3428ccc28da7 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -959,7 +959,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) | |||
959 | * | 959 | * |
960 | * This function will block the close until one of the following: | 960 | * This function will block the close until one of the following: |
961 | * 1. Response to our Chase comes from Edgeport | 961 | * 1. Response to our Chase comes from Edgeport |
962 | * 2. A timout of 10 seconds without activity has expired | 962 | * 2. A timeout of 10 seconds without activity has expired |
963 | * (1K of Edgeport data @ 2400 baud ==> 4 sec to empty) | 963 | * (1K of Edgeport data @ 2400 baud ==> 4 sec to empty) |
964 | * | 964 | * |
965 | ************************************************************************/ | 965 | ************************************************************************/ |
@@ -999,7 +999,7 @@ static void block_until_chase_response(struct edgeport_port *edge_port) | |||
999 | return; | 999 | return; |
1000 | } | 1000 | } |
1001 | } else { | 1001 | } else { |
1002 | // Reset timout value back to 10 seconds | 1002 | // Reset timeout value back to 10 seconds |
1003 | dbg("%s - Last %d, Current %d", __FUNCTION__, lastCredits, edge_port->txCredits); | 1003 | dbg("%s - Last %d, Current %d", __FUNCTION__, lastCredits, edge_port->txCredits); |
1004 | loop = 10; | 1004 | loop = 10; |
1005 | } | 1005 | } |
@@ -1014,7 +1014,7 @@ static void block_until_chase_response(struct edgeport_port *edge_port) | |||
1014 | * This function will block the close until one of the following: | 1014 | * This function will block the close until one of the following: |
1015 | * 1. TX count are 0 | 1015 | * 1. TX count are 0 |
1016 | * 2. The edgeport has stopped | 1016 | * 2. The edgeport has stopped |
1017 | * 3. A timout of 3 seconds without activity has expired | 1017 | * 3. A timeout of 3 seconds without activity has expired |
1018 | * | 1018 | * |
1019 | ************************************************************************/ | 1019 | ************************************************************************/ |
1020 | static void block_until_tx_empty (struct edgeport_port *edge_port) | 1020 | static void block_until_tx_empty (struct edgeport_port *edge_port) |
@@ -1050,7 +1050,7 @@ static void block_until_tx_empty (struct edgeport_port *edge_port) | |||
1050 | return; | 1050 | return; |
1051 | } | 1051 | } |
1052 | } else { | 1052 | } else { |
1053 | // Reset timout value back to seconds | 1053 | // Reset timeout value back to seconds |
1054 | loop = 30; | 1054 | loop = 30; |
1055 | } | 1055 | } |
1056 | } | 1056 | } |
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index b8670905bc3a..cd3405953f74 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/tty_flip.h> | 34 | #include <linux/tty_flip.h> |
35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
36 | #include <linux/spinlock.h> | 36 | #include <linux/spinlock.h> |
37 | #include <linux/mutex.h> | ||
37 | #include <linux/serial.h> | 38 | #include <linux/serial.h> |
38 | #include <linux/ioctl.h> | 39 | #include <linux/ioctl.h> |
39 | #include <asm/uaccess.h> | 40 | #include <asm/uaccess.h> |
@@ -133,7 +134,7 @@ struct edgeport_serial { | |||
133 | struct product_info product_info; | 134 | struct product_info product_info; |
134 | u8 TI_I2C_Type; // Type of I2C in UMP | 135 | u8 TI_I2C_Type; // Type of I2C in UMP |
135 | u8 TiReadI2C; // Set to TRUE if we have read the I2c in Boot Mode | 136 | u8 TiReadI2C; // Set to TRUE if we have read the I2c in Boot Mode |
136 | struct semaphore es_sem; | 137 | struct mutex es_lock; |
137 | int num_ports_open; | 138 | int num_ports_open; |
138 | struct usb_serial *serial; | 139 | struct usb_serial *serial; |
139 | }; | 140 | }; |
@@ -1978,7 +1979,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) | |||
1978 | } | 1979 | } |
1979 | 1980 | ||
1980 | /* set up the port settings */ | 1981 | /* set up the port settings */ |
1981 | edge_set_termios (port, NULL); | 1982 | edge_set_termios (port, port->tty->termios); |
1982 | 1983 | ||
1983 | /* open up the port */ | 1984 | /* open up the port */ |
1984 | 1985 | ||
@@ -2044,7 +2045,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) | |||
2044 | dbg ("ShadowMCR 0x%X", edge_port->shadow_mcr); | 2045 | dbg ("ShadowMCR 0x%X", edge_port->shadow_mcr); |
2045 | 2046 | ||
2046 | edge_serial = edge_port->edge_serial; | 2047 | edge_serial = edge_port->edge_serial; |
2047 | if (down_interruptible(&edge_serial->es_sem)) | 2048 | if (mutex_lock_interruptible(&edge_serial->es_lock)) |
2048 | return -ERESTARTSYS; | 2049 | return -ERESTARTSYS; |
2049 | if (edge_serial->num_ports_open == 0) { | 2050 | if (edge_serial->num_ports_open == 0) { |
2050 | /* we are the first port to be opened, let's post the interrupt urb */ | 2051 | /* we are the first port to be opened, let's post the interrupt urb */ |
@@ -2052,7 +2053,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) | |||
2052 | if (!urb) { | 2053 | if (!urb) { |
2053 | dev_err (&port->dev, "%s - no interrupt urb present, exiting\n", __FUNCTION__); | 2054 | dev_err (&port->dev, "%s - no interrupt urb present, exiting\n", __FUNCTION__); |
2054 | status = -EINVAL; | 2055 | status = -EINVAL; |
2055 | goto up_es_sem; | 2056 | goto release_es_lock; |
2056 | } | 2057 | } |
2057 | urb->complete = edge_interrupt_callback; | 2058 | urb->complete = edge_interrupt_callback; |
2058 | urb->context = edge_serial; | 2059 | urb->context = edge_serial; |
@@ -2060,7 +2061,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) | |||
2060 | status = usb_submit_urb (urb, GFP_KERNEL); | 2061 | status = usb_submit_urb (urb, GFP_KERNEL); |
2061 | if (status) { | 2062 | if (status) { |
2062 | dev_err (&port->dev, "%s - usb_submit_urb failed with value %d\n", __FUNCTION__, status); | 2063 | dev_err (&port->dev, "%s - usb_submit_urb failed with value %d\n", __FUNCTION__, status); |
2063 | goto up_es_sem; | 2064 | goto release_es_lock; |
2064 | } | 2065 | } |
2065 | } | 2066 | } |
2066 | 2067 | ||
@@ -2092,13 +2093,13 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) | |||
2092 | 2093 | ||
2093 | dbg("%s - exited", __FUNCTION__); | 2094 | dbg("%s - exited", __FUNCTION__); |
2094 | 2095 | ||
2095 | goto up_es_sem; | 2096 | goto release_es_lock; |
2096 | 2097 | ||
2097 | unlink_int_urb: | 2098 | unlink_int_urb: |
2098 | if (edge_port->edge_serial->num_ports_open == 0) | 2099 | if (edge_port->edge_serial->num_ports_open == 0) |
2099 | usb_kill_urb(port->serial->port[0]->interrupt_in_urb); | 2100 | usb_kill_urb(port->serial->port[0]->interrupt_in_urb); |
2100 | up_es_sem: | 2101 | release_es_lock: |
2101 | up(&edge_serial->es_sem); | 2102 | mutex_unlock(&edge_serial->es_lock); |
2102 | return status; | 2103 | return status; |
2103 | } | 2104 | } |
2104 | 2105 | ||
@@ -2137,14 +2138,14 @@ static void edge_close (struct usb_serial_port *port, struct file *filp) | |||
2137 | 0, | 2138 | 0, |
2138 | NULL, | 2139 | NULL, |
2139 | 0); | 2140 | 0); |
2140 | down(&edge_serial->es_sem); | 2141 | mutex_lock(&edge_serial->es_lock); |
2141 | --edge_port->edge_serial->num_ports_open; | 2142 | --edge_port->edge_serial->num_ports_open; |
2142 | if (edge_port->edge_serial->num_ports_open <= 0) { | 2143 | if (edge_port->edge_serial->num_ports_open <= 0) { |
2143 | /* last port is now closed, let's shut down our interrupt urb */ | 2144 | /* last port is now closed, let's shut down our interrupt urb */ |
2144 | usb_kill_urb(port->serial->port[0]->interrupt_in_urb); | 2145 | usb_kill_urb(port->serial->port[0]->interrupt_in_urb); |
2145 | edge_port->edge_serial->num_ports_open = 0; | 2146 | edge_port->edge_serial->num_ports_open = 0; |
2146 | } | 2147 | } |
2147 | up(&edge_serial->es_sem); | 2148 | mutex_unlock(&edge_serial->es_lock); |
2148 | edge_port->close_pending = 0; | 2149 | edge_port->close_pending = 0; |
2149 | 2150 | ||
2150 | dbg("%s - exited", __FUNCTION__); | 2151 | dbg("%s - exited", __FUNCTION__); |
@@ -2393,11 +2394,6 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi | |||
2393 | dbg("%s - port %d", __FUNCTION__, edge_port->port->number); | 2394 | dbg("%s - port %d", __FUNCTION__, edge_port->port->number); |
2394 | 2395 | ||
2395 | tty = edge_port->port->tty; | 2396 | tty = edge_port->port->tty; |
2396 | if ((!tty) || | ||
2397 | (!tty->termios)) { | ||
2398 | dbg("%s - no tty structures", __FUNCTION__); | ||
2399 | return; | ||
2400 | } | ||
2401 | 2397 | ||
2402 | config = kmalloc (sizeof (*config), GFP_KERNEL); | 2398 | config = kmalloc (sizeof (*config), GFP_KERNEL); |
2403 | if (!config) { | 2399 | if (!config) { |
@@ -2492,15 +2488,21 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi | |||
2492 | } | 2488 | } |
2493 | } | 2489 | } |
2494 | 2490 | ||
2491 | tty->termios->c_cflag &= ~CMSPAR; | ||
2492 | |||
2495 | /* Round the baud rate */ | 2493 | /* Round the baud rate */ |
2496 | baud = tty_get_baud_rate(tty); | 2494 | baud = tty_get_baud_rate(tty); |
2497 | if (!baud) { | 2495 | if (!baud) { |
2498 | /* pick a default, any default... */ | 2496 | /* pick a default, any default... */ |
2499 | baud = 9600; | 2497 | baud = 9600; |
2500 | } | 2498 | } else |
2499 | tty_encode_baud_rate(tty, baud, baud); | ||
2500 | |||
2501 | edge_port->baud_rate = baud; | 2501 | edge_port->baud_rate = baud; |
2502 | config->wBaudRate = (__u16)((461550L + baud/2) / baud); | 2502 | config->wBaudRate = (__u16)((461550L + baud/2) / baud); |
2503 | 2503 | ||
2504 | /* FIXME: Recompute actual baud from divisor here */ | ||
2505 | |||
2504 | dbg ("%s - baud rate = %d, wBaudRate = %d", __FUNCTION__, baud, config->wBaudRate); | 2506 | dbg ("%s - baud rate = %d, wBaudRate = %d", __FUNCTION__, baud, config->wBaudRate); |
2505 | 2507 | ||
2506 | dbg ("wBaudRate: %d", (int)(461550L / config->wBaudRate)); | 2508 | dbg ("wBaudRate: %d", (int)(461550L / config->wBaudRate)); |
@@ -2538,19 +2540,12 @@ static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old | |||
2538 | struct tty_struct *tty = port->tty; | 2540 | struct tty_struct *tty = port->tty; |
2539 | unsigned int cflag; | 2541 | unsigned int cflag; |
2540 | 2542 | ||
2541 | if (!port->tty || !port->tty->termios) { | ||
2542 | dbg ("%s - no tty or termios", __FUNCTION__); | ||
2543 | return; | ||
2544 | } | ||
2545 | |||
2546 | cflag = tty->termios->c_cflag; | 2543 | cflag = tty->termios->c_cflag; |
2547 | 2544 | ||
2548 | dbg("%s - clfag %08x iflag %08x", __FUNCTION__, | 2545 | dbg("%s - clfag %08x iflag %08x", __FUNCTION__, |
2549 | tty->termios->c_cflag, tty->termios->c_iflag); | 2546 | tty->termios->c_cflag, tty->termios->c_iflag); |
2550 | if (old_termios) { | 2547 | dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, |
2551 | dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, | 2548 | old_termios->c_cflag, old_termios->c_iflag); |
2552 | old_termios->c_cflag, old_termios->c_iflag); | ||
2553 | } | ||
2554 | 2549 | ||
2555 | dbg("%s - port %d", __FUNCTION__, port->number); | 2550 | dbg("%s - port %d", __FUNCTION__, port->number); |
2556 | 2551 | ||
@@ -2743,7 +2738,7 @@ static int edge_startup (struct usb_serial *serial) | |||
2743 | dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); | 2738 | dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); |
2744 | return -ENOMEM; | 2739 | return -ENOMEM; |
2745 | } | 2740 | } |
2746 | sema_init(&edge_serial->es_sem, 1); | 2741 | mutex_init(&edge_serial->es_lock); |
2747 | edge_serial->serial = serial; | 2742 | edge_serial->serial = serial; |
2748 | usb_set_serial_data(serial, edge_serial); | 2743 | usb_set_serial_data(serial, edge_serial); |
2749 | 2744 | ||
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c new file mode 100644 index 000000000000..fde188e23ce1 --- /dev/null +++ b/drivers/usb/serial/iuu_phoenix.c | |||
@@ -0,0 +1,1217 @@ | |||
1 | /* | ||
2 | * Infinity Unlimited USB Phoenix driver | ||
3 | * | ||
4 | * Copyright (C) 2007 Alain Degreffe (eczema@ecze.com) | ||
5 | * | ||
6 | * Original code taken from iuutool (Copyright (C) 2006 Juan Carlos Borrás) | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * And tested with help of WB Electronics | ||
14 | * | ||
15 | */ | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/errno.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/tty.h> | ||
21 | #include <linux/tty_driver.h> | ||
22 | #include <linux/tty_flip.h> | ||
23 | #include <linux/serial.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/moduleparam.h> | ||
26 | #include <linux/spinlock.h> | ||
27 | #include <linux/uaccess.h> | ||
28 | #include <linux/usb.h> | ||
29 | #include <linux/usb/serial.h> | ||
30 | #include "iuu_phoenix.h" | ||
31 | #include <linux/random.h> | ||
32 | |||
33 | |||
34 | #ifdef CONFIG_USB_SERIAL_DEBUG | ||
35 | static int debug = 1; | ||
36 | #else | ||
37 | static int debug; | ||
38 | #endif | ||
39 | |||
40 | /* | ||
41 | * Version Information | ||
42 | */ | ||
43 | #define DRIVER_VERSION "v0.5" | ||
44 | #define DRIVER_DESC "Infinity USB Unlimited Phoenix driver" | ||
45 | |||
46 | static struct usb_device_id id_table[] = { | ||
47 | {USB_DEVICE(IUU_USB_VENDOR_ID, IUU_USB_PRODUCT_ID)}, | ||
48 | {} /* Terminating entry */ | ||
49 | }; | ||
50 | MODULE_DEVICE_TABLE(usb, id_table); | ||
51 | |||
52 | static struct usb_driver iuu_driver = { | ||
53 | .name = "iuu_phoenix", | ||
54 | .probe = usb_serial_probe, | ||
55 | .disconnect = usb_serial_disconnect, | ||
56 | .id_table = id_table, | ||
57 | .no_dynamic_id = 1, | ||
58 | }; | ||
59 | |||
60 | /* turbo parameter */ | ||
61 | static int boost = 100; | ||
62 | static int clockmode = 1; | ||
63 | static int cdmode = 1; | ||
64 | static int iuu_cardin; | ||
65 | static int iuu_cardout; | ||
66 | static int xmas; | ||
67 | |||
68 | static void read_rxcmd_callback(struct urb *urb); | ||
69 | |||
70 | struct iuu_private { | ||
71 | spinlock_t lock; /* store irq state */ | ||
72 | wait_queue_head_t delta_msr_wait; | ||
73 | u8 line_control; | ||
74 | u8 line_status; | ||
75 | u8 termios_initialized; | ||
76 | int tiostatus; /* store IUART SIGNAL for tiocmget call */ | ||
77 | u8 reset; /* if 1 reset is needed */ | ||
78 | int poll; /* number of poll */ | ||
79 | u8 *writebuf; /* buffer for writing to device */ | ||
80 | int writelen; /* num of byte to write to device */ | ||
81 | u8 *buf; /* used for initialize speed */ | ||
82 | u8 *dbgbuf; /* debug buffer */ | ||
83 | u8 len; | ||
84 | }; | ||
85 | |||
86 | |||
87 | static void iuu_free_buf(struct iuu_private *priv) | ||
88 | { | ||
89 | kfree(priv->buf); | ||
90 | kfree(priv->dbgbuf); | ||
91 | kfree(priv->writebuf); | ||
92 | } | ||
93 | |||
94 | static int iuu_alloc_buf(struct iuu_private *priv) | ||
95 | { | ||
96 | priv->buf = kzalloc(256, GFP_KERNEL); | ||
97 | priv->dbgbuf = kzalloc(256, GFP_KERNEL); | ||
98 | priv->writebuf = kzalloc(256, GFP_KERNEL); | ||
99 | if (!priv->buf || !priv->dbgbuf || !priv->writebuf) { | ||
100 | iuu_free_buf(priv); | ||
101 | dbg("%s problem allocation buffer", __FUNCTION__); | ||
102 | return -ENOMEM; | ||
103 | } | ||
104 | dbg("%s - Privates buffers allocation success", __FUNCTION__); | ||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | static int iuu_startup(struct usb_serial *serial) | ||
109 | { | ||
110 | struct iuu_private *priv; | ||
111 | priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL); | ||
112 | dbg("%s- priv allocation success", __FUNCTION__); | ||
113 | if (!priv) | ||
114 | return -ENOMEM; | ||
115 | if (iuu_alloc_buf(priv)) { | ||
116 | kfree(priv); | ||
117 | return -ENOMEM; | ||
118 | } | ||
119 | spin_lock_init(&priv->lock); | ||
120 | init_waitqueue_head(&priv->delta_msr_wait); | ||
121 | usb_set_serial_port_data(serial->port[0], priv); | ||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | /* Shutdown function */ | ||
126 | static void iuu_shutdown(struct usb_serial *serial) | ||
127 | { | ||
128 | struct usb_serial_port *port = serial->port[0]; | ||
129 | struct iuu_private *priv = usb_get_serial_port_data(port); | ||
130 | if (!port) | ||
131 | return; | ||
132 | |||
133 | dbg("%s", __FUNCTION__); | ||
134 | |||
135 | if (priv) { | ||
136 | iuu_free_buf(priv); | ||
137 | dbg("%s - I will free all", __FUNCTION__); | ||
138 | usb_set_serial_port_data(port, NULL); | ||
139 | |||
140 | dbg("%s - priv is not anymore in port structure", __FUNCTION__); | ||
141 | kfree(priv); | ||
142 | |||
143 | dbg("%s priv is now kfree", __FUNCTION__); | ||
144 | } | ||
145 | } | ||
146 | |||
147 | static int iuu_tiocmset(struct usb_serial_port *port, struct file *file, | ||
148 | unsigned int set, unsigned int clear) | ||
149 | { | ||
150 | struct iuu_private *priv = usb_get_serial_port_data(port); | ||
151 | struct tty_struct *tty; | ||
152 | tty = port->tty; | ||
153 | |||
154 | dbg("%s (%d) msg : SET = 0x%04x, CLEAR = 0x%04x ", __FUNCTION__, | ||
155 | port->number, set, clear); | ||
156 | if (set & TIOCM_RTS) | ||
157 | priv->tiostatus = TIOCM_RTS; | ||
158 | |||
159 | if (!(set & TIOCM_RTS) && priv->tiostatus == TIOCM_RTS) { | ||
160 | dbg("%s TIOCMSET RESET called !!!", __FUNCTION__); | ||
161 | priv->reset = 1; | ||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | /* This is used to provide a carrier detect mechanism | ||
169 | * When a card is present, the response is 0x00 | ||
170 | * When no card , the reader respond with TIOCM_CD | ||
171 | * This is known as CD autodetect mechanism | ||
172 | */ | ||
173 | static int iuu_tiocmget(struct usb_serial_port *port, struct file *file) | ||
174 | { | ||
175 | struct iuu_private *priv = usb_get_serial_port_data(port); | ||
176 | return priv->tiostatus; | ||
177 | } | ||
178 | |||
179 | static void iuu_rxcmd(struct urb *urb) | ||
180 | { | ||
181 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | ||
182 | int result; | ||
183 | dbg("%s - enter", __FUNCTION__); | ||
184 | |||
185 | if (urb->status) { | ||
186 | dbg("%s - urb->status = %d", __FUNCTION__, urb->status); | ||
187 | /* error stop all */ | ||
188 | return; | ||
189 | } | ||
190 | |||
191 | |||
192 | memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1); | ||
193 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, | ||
194 | usb_sndbulkpipe(port->serial->dev, | ||
195 | port->bulk_out_endpointAddress), | ||
196 | port->write_urb->transfer_buffer, 1, | ||
197 | read_rxcmd_callback, port); | ||
198 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | ||
199 | } | ||
200 | |||
201 | static int iuu_reset(struct usb_serial_port *port, u8 wt) | ||
202 | { | ||
203 | struct iuu_private *priv = usb_get_serial_port_data(port); | ||
204 | int result; | ||
205 | char *buf_ptr = port->write_urb->transfer_buffer; | ||
206 | dbg("%s - enter", __FUNCTION__); | ||
207 | |||
208 | /* Prepare the reset sequence */ | ||
209 | |||
210 | *buf_ptr++ = IUU_RST_SET; | ||
211 | *buf_ptr++ = IUU_DELAY_MS; | ||
212 | *buf_ptr++ = wt; | ||
213 | *buf_ptr = IUU_RST_CLEAR; | ||
214 | |||
215 | /* send the sequence */ | ||
216 | |||
217 | usb_fill_bulk_urb(port->write_urb, | ||
218 | port->serial->dev, | ||
219 | usb_sndbulkpipe(port->serial->dev, | ||
220 | port->bulk_out_endpointAddress), | ||
221 | port->write_urb->transfer_buffer, 4, iuu_rxcmd, port); | ||
222 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | ||
223 | priv->reset = 0; | ||
224 | return result; | ||
225 | } | ||
226 | |||
227 | /* Status Function | ||
228 | * Return value is | ||
229 | * 0x00 = no card | ||
230 | * 0x01 = smartcard | ||
231 | * 0x02 = sim card | ||
232 | */ | ||
233 | static void iuu_update_status_callback(struct urb *urb) | ||
234 | { | ||
235 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | ||
236 | struct iuu_private *priv = usb_get_serial_port_data(port); | ||
237 | u8 *st; | ||
238 | dbg("%s - enter", __FUNCTION__); | ||
239 | |||
240 | if (urb->status) { | ||
241 | dbg("%s - urb->status = %d", __FUNCTION__, urb->status); | ||
242 | /* error stop all */ | ||
243 | return; | ||
244 | } | ||
245 | |||
246 | st = urb->transfer_buffer; | ||
247 | dbg("%s - enter", __FUNCTION__); | ||
248 | if (urb->actual_length == 1) { | ||
249 | switch (st[0]) { | ||
250 | case 0x1: | ||
251 | priv->tiostatus = iuu_cardout; | ||
252 | break; | ||
253 | case 0x0: | ||
254 | priv->tiostatus = iuu_cardin; | ||
255 | break; | ||
256 | default: | ||
257 | priv->tiostatus = iuu_cardin; | ||
258 | } | ||
259 | } | ||
260 | iuu_rxcmd(urb); | ||
261 | } | ||
262 | |||
263 | static void iuu_status_callback(struct urb *urb) | ||
264 | { | ||
265 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | ||
266 | int result; | ||
267 | dbg("%s - enter", __FUNCTION__); | ||
268 | |||
269 | dbg("%s - urb->status = %d", __FUNCTION__, urb->status); | ||
270 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | ||
271 | usb_rcvbulkpipe(port->serial->dev, | ||
272 | port->bulk_in_endpointAddress), | ||
273 | port->read_urb->transfer_buffer, 256, | ||
274 | iuu_update_status_callback, port); | ||
275 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | ||
276 | } | ||
277 | |||
278 | static int iuu_status(struct usb_serial_port *port) | ||
279 | { | ||
280 | int result; | ||
281 | |||
282 | dbg("%s - enter", __FUNCTION__); | ||
283 | |||
284 | memset(port->write_urb->transfer_buffer, IUU_GET_STATE_REGISTER, 1); | ||
285 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, | ||
286 | usb_sndbulkpipe(port->serial->dev, | ||
287 | port->bulk_out_endpointAddress), | ||
288 | port->write_urb->transfer_buffer, 1, | ||
289 | iuu_status_callback, port); | ||
290 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | ||
291 | return result; | ||
292 | |||
293 | } | ||
294 | |||
295 | static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count) | ||
296 | { | ||
297 | int status; | ||
298 | struct usb_serial *serial = port->serial; | ||
299 | int actual = 0; | ||
300 | |||
301 | dbg("%s - enter", __FUNCTION__); | ||
302 | |||
303 | /* send the data out the bulk port */ | ||
304 | |||
305 | status = | ||
306 | usb_bulk_msg(serial->dev, | ||
307 | usb_sndbulkpipe(serial->dev, | ||
308 | port->bulk_out_endpointAddress), buf, | ||
309 | count, &actual, HZ * 1); | ||
310 | |||
311 | if (status != IUU_OPERATION_OK) { | ||
312 | dbg("%s - error = %2x", __FUNCTION__, status); | ||
313 | } else { | ||
314 | dbg("%s - write OK !", __FUNCTION__); | ||
315 | } | ||
316 | return status; | ||
317 | } | ||
318 | |||
319 | static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count) | ||
320 | { | ||
321 | int status; | ||
322 | struct usb_serial *serial = port->serial; | ||
323 | int actual = 0; | ||
324 | |||
325 | dbg("%s - enter", __FUNCTION__); | ||
326 | |||
327 | /* send the data out the bulk port */ | ||
328 | |||
329 | status = | ||
330 | usb_bulk_msg(serial->dev, | ||
331 | usb_rcvbulkpipe(serial->dev, | ||
332 | port->bulk_in_endpointAddress), buf, | ||
333 | count, &actual, HZ * 1); | ||
334 | |||
335 | if (status != IUU_OPERATION_OK) { | ||
336 | dbg("%s - error = %2x", __FUNCTION__, status); | ||
337 | } else { | ||
338 | dbg("%s - read OK !", __FUNCTION__); | ||
339 | } | ||
340 | |||
341 | return status; | ||
342 | } | ||
343 | |||
344 | static int iuu_led(struct usb_serial_port *port, unsigned int R, | ||
345 | unsigned int G, unsigned int B, u8 f) | ||
346 | { | ||
347 | int status; | ||
348 | u8 *buf; | ||
349 | buf = kmalloc(8, GFP_KERNEL); | ||
350 | if (!buf) | ||
351 | return -ENOMEM; | ||
352 | |||
353 | dbg("%s - enter", __FUNCTION__); | ||
354 | |||
355 | buf[0] = IUU_SET_LED; | ||
356 | buf[1] = R & 0xFF; | ||
357 | buf[2] = (R >> 8) & 0xFF; | ||
358 | buf[3] = G & 0xFF; | ||
359 | buf[4] = (G >> 8) & 0xFF; | ||
360 | buf[5] = B & 0xFF; | ||
361 | buf[6] = (B >> 8) & 0xFF; | ||
362 | buf[7] = f; | ||
363 | status = bulk_immediate(port, buf, 8); | ||
364 | kfree(buf); | ||
365 | if (status != IUU_OPERATION_OK) | ||
366 | dbg("%s - led error status = %2x", __FUNCTION__, status); | ||
367 | else | ||
368 | dbg("%s - led OK !", __FUNCTION__); | ||
369 | return IUU_OPERATION_OK; | ||
370 | } | ||
371 | |||
372 | static void iuu_rgbf_fill_buffer(u8 *buf, u8 r1, u8 r2, u8 g1, u8 g2, u8 b1, | ||
373 | u8 b2, u8 freq) | ||
374 | { | ||
375 | *buf++ = IUU_SET_LED; | ||
376 | *buf++ = r1; | ||
377 | *buf++ = r2; | ||
378 | *buf++ = g1; | ||
379 | *buf++ = g2; | ||
380 | *buf++ = b1; | ||
381 | *buf++ = b2; | ||
382 | *buf = freq; | ||
383 | } | ||
384 | |||
385 | static void iuu_led_activity_on(struct urb *urb) | ||
386 | { | ||
387 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | ||
388 | int result; | ||
389 | char *buf_ptr = port->write_urb->transfer_buffer; | ||
390 | *buf_ptr++ = IUU_SET_LED; | ||
391 | if (xmas == 1) { | ||
392 | get_random_bytes(buf_ptr, 6); | ||
393 | *(buf_ptr+7) = 1; | ||
394 | } else { | ||
395 | iuu_rgbf_fill_buffer(buf_ptr, 255, 255, 0, 0, 0, 0, 255); | ||
396 | } | ||
397 | |||
398 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, | ||
399 | usb_sndbulkpipe(port->serial->dev, | ||
400 | port->bulk_out_endpointAddress), | ||
401 | port->write_urb->transfer_buffer, 8 , | ||
402 | iuu_rxcmd, port); | ||
403 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | ||
404 | } | ||
405 | |||
406 | static void iuu_led_activity_off(struct urb *urb) | ||
407 | { | ||
408 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | ||
409 | int result; | ||
410 | char *buf_ptr = port->write_urb->transfer_buffer; | ||
411 | if (xmas == 1) { | ||
412 | iuu_rxcmd(urb); | ||
413 | return; | ||
414 | } else { | ||
415 | *buf_ptr++ = IUU_SET_LED; | ||
416 | iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255); | ||
417 | } | ||
418 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, | ||
419 | usb_sndbulkpipe(port->serial->dev, | ||
420 | port->bulk_out_endpointAddress), | ||
421 | port->write_urb->transfer_buffer, 8 , | ||
422 | iuu_rxcmd, port); | ||
423 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | ||
424 | } | ||
425 | |||
426 | |||
427 | |||
428 | static int iuu_clk(struct usb_serial_port *port, int dwFrq) | ||
429 | { | ||
430 | int status; | ||
431 | struct iuu_private *priv = usb_get_serial_port_data(port); | ||
432 | int Count = 0; | ||
433 | u8 FrqGenAdr = 0x69; | ||
434 | u8 DIV = 0; /* 8bit */ | ||
435 | u8 XDRV = 0; /* 8bit */ | ||
436 | u8 PUMP = 0; /* 3bit */ | ||
437 | u8 PBmsb = 0; /* 2bit */ | ||
438 | u8 PBlsb = 0; /* 8bit */ | ||
439 | u8 PO = 0; /* 1bit */ | ||
440 | u8 Q = 0; /* 7bit */ | ||
441 | /* 24bit = 3bytes */ | ||
442 | unsigned int P = 0; | ||
443 | unsigned int P2 = 0; | ||
444 | int frq = (int)dwFrq; | ||
445 | |||
446 | dbg("%s - enter", __FUNCTION__); | ||
447 | |||
448 | if (frq == 0) { | ||
449 | priv->buf[Count++] = IUU_UART_WRITE_I2C; | ||
450 | priv->buf[Count++] = FrqGenAdr << 1; | ||
451 | priv->buf[Count++] = 0x09; | ||
452 | priv->buf[Count++] = 0x00; | ||
453 | |||
454 | status = bulk_immediate(port, (u8 *) priv->buf, Count); | ||
455 | if (status != 0) { | ||
456 | dbg("%s - write error ", __FUNCTION__); | ||
457 | return status; | ||
458 | } | ||
459 | } else if (frq == 3579000) { | ||
460 | DIV = 100; | ||
461 | P = 1193; | ||
462 | Q = 40; | ||
463 | XDRV = 0; | ||
464 | } else if (frq == 3680000) { | ||
465 | DIV = 105; | ||
466 | P = 161; | ||
467 | Q = 5; | ||
468 | XDRV = 0; | ||
469 | } else if (frq == 6000000) { | ||
470 | DIV = 66; | ||
471 | P = 66; | ||
472 | Q = 2; | ||
473 | XDRV = 0x28; | ||
474 | } else { | ||
475 | unsigned int result = 0; | ||
476 | unsigned int tmp = 0; | ||
477 | unsigned int check; | ||
478 | unsigned int check2; | ||
479 | char found = 0x00; | ||
480 | unsigned int lQ = 2; | ||
481 | unsigned int lP = 2055; | ||
482 | unsigned int lDiv = 4; | ||
483 | |||
484 | for (lQ = 2; lQ <= 47 && !found; lQ++) | ||
485 | for (lP = 2055; lP >= 8 && !found; lP--) | ||
486 | for (lDiv = 4; lDiv <= 127 && !found; lDiv++) { | ||
487 | tmp = (12000000 / lDiv) * (lP / lQ); | ||
488 | if (abs((int)(tmp - frq)) < | ||
489 | abs((int)(frq - result))) { | ||
490 | check2 = (12000000 / lQ); | ||
491 | if (check2 < 250000) | ||
492 | continue; | ||
493 | check = (12000000 / lQ) * lP; | ||
494 | if (check > 400000000) | ||
495 | continue; | ||
496 | if (check < 100000000) | ||
497 | continue; | ||
498 | if (lDiv < 4 || lDiv > 127) | ||
499 | continue; | ||
500 | result = tmp; | ||
501 | P = lP; | ||
502 | DIV = lDiv; | ||
503 | Q = lQ; | ||
504 | if (result == frq) | ||
505 | found = 0x01; | ||
506 | } | ||
507 | } | ||
508 | } | ||
509 | P2 = ((P - PO) / 2) - 4; | ||
510 | DIV = DIV; | ||
511 | PUMP = 0x04; | ||
512 | PBmsb = (P2 >> 8 & 0x03); | ||
513 | PBlsb = P2 & 0xFF; | ||
514 | PO = (P >> 10) & 0x01; | ||
515 | Q = Q - 2; | ||
516 | |||
517 | priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ | ||
518 | priv->buf[Count++] = FrqGenAdr << 1; | ||
519 | priv->buf[Count++] = 0x09; | ||
520 | priv->buf[Count++] = 0x20; /* Adr = 0x09 */ | ||
521 | priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ | ||
522 | priv->buf[Count++] = FrqGenAdr << 1; | ||
523 | priv->buf[Count++] = 0x0C; | ||
524 | priv->buf[Count++] = DIV; /* Adr = 0x0C */ | ||
525 | priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ | ||
526 | priv->buf[Count++] = FrqGenAdr << 1; | ||
527 | priv->buf[Count++] = 0x12; | ||
528 | priv->buf[Count++] = XDRV; /* Adr = 0x12 */ | ||
529 | priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ | ||
530 | priv->buf[Count++] = FrqGenAdr << 1; | ||
531 | priv->buf[Count++] = 0x13; | ||
532 | priv->buf[Count++] = 0x6B; /* Adr = 0x13 */ | ||
533 | priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ | ||
534 | priv->buf[Count++] = FrqGenAdr << 1; | ||
535 | priv->buf[Count++] = 0x40; | ||
536 | priv->buf[Count++] = (0xC0 | ((PUMP & 0x07) << 2)) | | ||
537 | (PBmsb & 0x03); /* Adr = 0x40 */ | ||
538 | priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ | ||
539 | priv->buf[Count++] = FrqGenAdr << 1; | ||
540 | priv->buf[Count++] = 0x41; | ||
541 | priv->buf[Count++] = PBlsb; /* Adr = 0x41 */ | ||
542 | priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ | ||
543 | priv->buf[Count++] = FrqGenAdr << 1; | ||
544 | priv->buf[Count++] = 0x42; | ||
545 | priv->buf[Count++] = Q | (((PO & 0x01) << 7)); /* Adr = 0x42 */ | ||
546 | priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ | ||
547 | priv->buf[Count++] = FrqGenAdr << 1; | ||
548 | priv->buf[Count++] = 0x44; | ||
549 | priv->buf[Count++] = (char)0xFF; /* Adr = 0x44 */ | ||
550 | priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ | ||
551 | priv->buf[Count++] = FrqGenAdr << 1; | ||
552 | priv->buf[Count++] = 0x45; | ||
553 | priv->buf[Count++] = (char)0xFE; /* Adr = 0x45 */ | ||
554 | priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ | ||
555 | priv->buf[Count++] = FrqGenAdr << 1; | ||
556 | priv->buf[Count++] = 0x46; | ||
557 | priv->buf[Count++] = 0x7F; /* Adr = 0x46 */ | ||
558 | priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ | ||
559 | priv->buf[Count++] = FrqGenAdr << 1; | ||
560 | priv->buf[Count++] = 0x47; | ||
561 | priv->buf[Count++] = (char)0x84; /* Adr = 0x47 */ | ||
562 | |||
563 | status = bulk_immediate(port, (u8 *) priv->buf, Count); | ||
564 | if (status != IUU_OPERATION_OK) | ||
565 | dbg("%s - write error ", __FUNCTION__); | ||
566 | return status; | ||
567 | } | ||
568 | |||
569 | static int iuu_uart_flush(struct usb_serial_port *port) | ||
570 | { | ||
571 | int i; | ||
572 | int status; | ||
573 | u8 rxcmd = IUU_UART_RX; | ||
574 | struct iuu_private *priv = usb_get_serial_port_data(port); | ||
575 | |||
576 | dbg("%s - enter", __FUNCTION__); | ||
577 | |||
578 | if (iuu_led(port, 0xF000, 0, 0, 0xFF) < 0) | ||
579 | return -EIO; | ||
580 | |||
581 | for (i = 0; i < 2; i++) { | ||
582 | status = bulk_immediate(port, &rxcmd, 1); | ||
583 | if (status != IUU_OPERATION_OK) { | ||
584 | dbg("%s - uart_flush_write error", __FUNCTION__); | ||
585 | return status; | ||
586 | } | ||
587 | |||
588 | status = read_immediate(port, &priv->len, 1); | ||
589 | if (status != IUU_OPERATION_OK) { | ||
590 | dbg("%s - uart_flush_read error", __FUNCTION__); | ||
591 | return status; | ||
592 | } | ||
593 | |||
594 | if (priv->len > 0) { | ||
595 | dbg("%s - uart_flush datalen is : %i ", __FUNCTION__, | ||
596 | priv->len); | ||
597 | status = read_immediate(port, priv->buf, priv->len); | ||
598 | if (status != IUU_OPERATION_OK) { | ||
599 | dbg("%s - uart_flush_read error", __FUNCTION__); | ||
600 | return status; | ||
601 | } | ||
602 | } | ||
603 | } | ||
604 | dbg("%s - uart_flush_read OK!", __FUNCTION__); | ||
605 | iuu_led(port, 0, 0xF000, 0, 0xFF); | ||
606 | return status; | ||
607 | } | ||
608 | |||
609 | static void read_buf_callback(struct urb *urb) | ||
610 | { | ||
611 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | ||
612 | unsigned char *data = urb->transfer_buffer; | ||
613 | struct tty_struct *tty; | ||
614 | dbg("%s - urb->status = %d", __FUNCTION__, urb->status); | ||
615 | |||
616 | if (urb->status) { | ||
617 | dbg("%s - urb->status = %d", __FUNCTION__, urb->status); | ||
618 | if (urb->status == -EPROTO) { | ||
619 | /* reschedule needed */ | ||
620 | } | ||
621 | return; | ||
622 | } | ||
623 | |||
624 | dbg("%s - %i chars to write", __FUNCTION__, urb->actual_length); | ||
625 | tty = port->tty; | ||
626 | if (data == NULL) | ||
627 | dbg("%s - data is NULL !!!", __FUNCTION__); | ||
628 | if (tty && urb->actual_length && data) { | ||
629 | tty_insert_flip_string(tty, data, urb->actual_length); | ||
630 | tty_flip_buffer_push(tty); | ||
631 | } | ||
632 | iuu_led_activity_on(urb); | ||
633 | } | ||
634 | |||
635 | static int iuu_bulk_write(struct usb_serial_port *port) | ||
636 | { | ||
637 | struct iuu_private *priv = usb_get_serial_port_data(port); | ||
638 | unsigned int flags; | ||
639 | int result; | ||
640 | int i; | ||
641 | char *buf_ptr = port->write_urb->transfer_buffer; | ||
642 | dbg("%s - enter", __FUNCTION__); | ||
643 | |||
644 | *buf_ptr++ = IUU_UART_ESC; | ||
645 | *buf_ptr++ = IUU_UART_TX; | ||
646 | *buf_ptr++ = priv->writelen; | ||
647 | |||
648 | memcpy(buf_ptr, priv->writebuf, | ||
649 | priv->writelen); | ||
650 | if (debug == 1) { | ||
651 | for (i = 0; i < priv->writelen; i++) | ||
652 | sprintf(priv->dbgbuf + i*2 , | ||
653 | "%02X", priv->writebuf[i]); | ||
654 | priv->dbgbuf[priv->writelen+i*2] = 0; | ||
655 | dbg("%s - writing %i chars : %s", __FUNCTION__, | ||
656 | priv->writelen, priv->dbgbuf); | ||
657 | } | ||
658 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, | ||
659 | usb_sndbulkpipe(port->serial->dev, | ||
660 | port->bulk_out_endpointAddress), | ||
661 | port->write_urb->transfer_buffer, priv->writelen + 3, | ||
662 | iuu_rxcmd, port); | ||
663 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | ||
664 | spin_lock_irqsave(&priv->lock, flags); | ||
665 | priv->writelen = 0; | ||
666 | spin_unlock_irqrestore(&priv->lock, flags); | ||
667 | usb_serial_port_softint(port); | ||
668 | return result; | ||
669 | } | ||
670 | |||
671 | static int iuu_read_buf(struct usb_serial_port *port, int len) | ||
672 | { | ||
673 | int result; | ||
674 | dbg("%s - enter", __FUNCTION__); | ||
675 | |||
676 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | ||
677 | usb_rcvbulkpipe(port->serial->dev, | ||
678 | port->bulk_in_endpointAddress), | ||
679 | port->read_urb->transfer_buffer, len, | ||
680 | read_buf_callback, port); | ||
681 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | ||
682 | return result; | ||
683 | } | ||
684 | |||
685 | static void iuu_uart_read_callback(struct urb *urb) | ||
686 | { | ||
687 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | ||
688 | struct iuu_private *priv = usb_get_serial_port_data(port); | ||
689 | unsigned int flags; | ||
690 | int status; | ||
691 | int error = 0; | ||
692 | int len = 0; | ||
693 | unsigned char *data = urb->transfer_buffer; | ||
694 | priv->poll++; | ||
695 | |||
696 | dbg("%s - enter", __FUNCTION__); | ||
697 | |||
698 | if (urb->status) { | ||
699 | dbg("%s - urb->status = %d", __FUNCTION__, urb->status); | ||
700 | /* error stop all */ | ||
701 | return; | ||
702 | } | ||
703 | if (data == NULL) | ||
704 | dbg("%s - data is NULL !!!", __FUNCTION__); | ||
705 | |||
706 | if (urb->actual_length == 1 && data != NULL) | ||
707 | len = (int) data[0]; | ||
708 | |||
709 | if (urb->actual_length > 1) { | ||
710 | dbg("%s - urb->actual_length = %i", __FUNCTION__, | ||
711 | urb->actual_length); | ||
712 | error = 1; | ||
713 | return; | ||
714 | } | ||
715 | /* if len > 0 call readbuf */ | ||
716 | |||
717 | if (len > 0 && error == 0) { | ||
718 | dbg("%s - call read buf - len to read is %i ", | ||
719 | __FUNCTION__, len); | ||
720 | status = iuu_read_buf(port, len); | ||
721 | return; | ||
722 | } | ||
723 | /* need to update status ? */ | ||
724 | if (priv->poll > 99) { | ||
725 | status = iuu_status(port); | ||
726 | priv->poll = 0; | ||
727 | return; | ||
728 | } | ||
729 | |||
730 | /* reset waiting ? */ | ||
731 | |||
732 | if (priv->reset == 1) { | ||
733 | status = iuu_reset(port, 0xC); | ||
734 | return; | ||
735 | } | ||
736 | /* Writebuf is waiting */ | ||
737 | spin_lock_irqsave(&priv->lock, flags); | ||
738 | if (priv->writelen > 0) { | ||
739 | spin_unlock_irqrestore(&priv->lock, flags); | ||
740 | status = iuu_bulk_write(port); | ||
741 | return; | ||
742 | } | ||
743 | spin_unlock_irqrestore(&priv->lock, flags); | ||
744 | /* if nothing to write call again rxcmd */ | ||
745 | dbg("%s - rxcmd recall", __FUNCTION__); | ||
746 | iuu_led_activity_off(urb); | ||
747 | return; | ||
748 | } | ||
749 | |||
750 | static int iuu_uart_write(struct usb_serial_port *port, const u8 *buf, | ||
751 | int count) | ||
752 | { | ||
753 | struct iuu_private *priv = usb_get_serial_port_data(port); | ||
754 | unsigned int flags; | ||
755 | dbg("%s - enter", __FUNCTION__); | ||
756 | |||
757 | if (count > 256) | ||
758 | return -ENOMEM; | ||
759 | |||
760 | spin_lock_irqsave(&priv->lock, flags); | ||
761 | if (priv->writelen > 0) { | ||
762 | /* buffer already filled but not commited */ | ||
763 | spin_unlock_irqrestore(&priv->lock, flags); | ||
764 | return (0); | ||
765 | } | ||
766 | /* fill the buffer */ | ||
767 | memcpy(priv->writebuf, buf, count); | ||
768 | priv->writelen = count; | ||
769 | spin_unlock_irqrestore(&priv->lock, flags); | ||
770 | |||
771 | return (count); | ||
772 | } | ||
773 | |||
774 | static void read_rxcmd_callback(struct urb *urb) | ||
775 | { | ||
776 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | ||
777 | int result; | ||
778 | dbg("%s - enter", __FUNCTION__); | ||
779 | |||
780 | dbg("%s - urb->status = %d", __FUNCTION__, urb->status); | ||
781 | |||
782 | if (urb->status) { | ||
783 | dbg("%s - urb->status = %d", __FUNCTION__, urb->status); | ||
784 | /* error stop all */ | ||
785 | return; | ||
786 | } | ||
787 | |||
788 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | ||
789 | usb_rcvbulkpipe(port->serial->dev, | ||
790 | port->bulk_in_endpointAddress), | ||
791 | port->read_urb->transfer_buffer, 256, | ||
792 | iuu_uart_read_callback, port); | ||
793 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | ||
794 | dbg("%s - submit result = %d", __FUNCTION__, result); | ||
795 | return; | ||
796 | } | ||
797 | |||
798 | static int iuu_uart_on(struct usb_serial_port *port) | ||
799 | { | ||
800 | int status; | ||
801 | u8 *buf; | ||
802 | |||
803 | buf = kmalloc(sizeof(u8) * 4, GFP_KERNEL); | ||
804 | |||
805 | if (!buf) | ||
806 | return -ENOMEM; | ||
807 | |||
808 | buf[0] = IUU_UART_ENABLE; | ||
809 | buf[1] = (u8) ((IUU_BAUD_9600 >> 8) & 0x00FF); | ||
810 | buf[2] = (u8) (0x00FF & IUU_BAUD_9600); | ||
811 | buf[3] = (u8) (0x0F0 & IUU_TWO_STOP_BITS) | (0x07 & IUU_PARITY_EVEN); | ||
812 | |||
813 | status = bulk_immediate(port, buf, 4); | ||
814 | if (status != IUU_OPERATION_OK) { | ||
815 | dbg("%s - uart_on error", __FUNCTION__); | ||
816 | goto uart_enable_failed; | ||
817 | } | ||
818 | /* iuu_reset() the card after iuu_uart_on() */ | ||
819 | status = iuu_uart_flush(port); | ||
820 | if (status != IUU_OPERATION_OK) | ||
821 | dbg("%s - uart_flush error", __FUNCTION__); | ||
822 | uart_enable_failed: | ||
823 | kfree(buf); | ||
824 | return status; | ||
825 | } | ||
826 | |||
827 | /* Diables the IUU UART (a.k.a. the Phoenix voiderface) */ | ||
828 | static int iuu_uart_off(struct usb_serial_port *port) | ||
829 | { | ||
830 | int status; | ||
831 | u8 *buf; | ||
832 | buf = kmalloc(1, GFP_KERNEL); | ||
833 | if (!buf) | ||
834 | return -ENOMEM; | ||
835 | buf[0] = IUU_UART_DISABLE; | ||
836 | |||
837 | status = bulk_immediate(port, buf, 1); | ||
838 | if (status != IUU_OPERATION_OK) | ||
839 | dbg("%s - uart_off error", __FUNCTION__); | ||
840 | |||
841 | kfree(buf); | ||
842 | return status; | ||
843 | } | ||
844 | |||
845 | static int iuu_uart_baud(struct usb_serial_port *port, u32 baud, | ||
846 | u32 *actual, u8 parity) | ||
847 | { | ||
848 | int status; | ||
849 | u8 *dataout; | ||
850 | u8 DataCount = 0; | ||
851 | u8 T1Frekvens = 0; | ||
852 | u8 T1reload = 0; | ||
853 | unsigned int T1FrekvensHZ = 0; | ||
854 | |||
855 | dataout = kmalloc(sizeof(u8) * 5, GFP_KERNEL); | ||
856 | |||
857 | if (!dataout) | ||
858 | return -ENOMEM; | ||
859 | |||
860 | if (baud < 1200 || baud > 230400) { | ||
861 | kfree(dataout); | ||
862 | return IUU_INVALID_PARAMETER; | ||
863 | } | ||
864 | if (baud > 977) { | ||
865 | T1Frekvens = 3; | ||
866 | T1FrekvensHZ = 500000; | ||
867 | } | ||
868 | |||
869 | if (baud > 3906) { | ||
870 | T1Frekvens = 2; | ||
871 | T1FrekvensHZ = 2000000; | ||
872 | } | ||
873 | |||
874 | if (baud > 11718) { | ||
875 | T1Frekvens = 1; | ||
876 | T1FrekvensHZ = 6000000; | ||
877 | } | ||
878 | |||
879 | if (baud > 46875) { | ||
880 | T1Frekvens = 0; | ||
881 | T1FrekvensHZ = 24000000; | ||
882 | } | ||
883 | |||
884 | T1reload = 256 - (u8) (T1FrekvensHZ / (baud * 2)); | ||
885 | |||
886 | /* magic number here: ENTER_FIRMWARE_UPDATE; */ | ||
887 | dataout[DataCount++] = IUU_UART_ESC; | ||
888 | /* magic number here: CHANGE_BAUD; */ | ||
889 | dataout[DataCount++] = IUU_UART_CHANGE; | ||
890 | dataout[DataCount++] = T1Frekvens; | ||
891 | dataout[DataCount++] = T1reload; | ||
892 | |||
893 | *actual = (T1FrekvensHZ / (256 - T1reload)) / 2; | ||
894 | |||
895 | switch (parity & 0x0F) { | ||
896 | case IUU_PARITY_NONE: | ||
897 | dataout[DataCount++] = 0x00; | ||
898 | break; | ||
899 | case IUU_PARITY_EVEN: | ||
900 | dataout[DataCount++] = 0x01; | ||
901 | break; | ||
902 | case IUU_PARITY_ODD: | ||
903 | dataout[DataCount++] = 0x02; | ||
904 | break; | ||
905 | case IUU_PARITY_MARK: | ||
906 | dataout[DataCount++] = 0x03; | ||
907 | break; | ||
908 | case IUU_PARITY_SPACE: | ||
909 | dataout[DataCount++] = 0x04; | ||
910 | break; | ||
911 | default: | ||
912 | kfree(dataout); | ||
913 | return IUU_INVALID_PARAMETER; | ||
914 | break; | ||
915 | } | ||
916 | |||
917 | switch (parity & 0xF0) { | ||
918 | case IUU_ONE_STOP_BIT: | ||
919 | dataout[DataCount - 1] |= IUU_ONE_STOP_BIT; | ||
920 | break; | ||
921 | |||
922 | case IUU_TWO_STOP_BITS: | ||
923 | dataout[DataCount - 1] |= IUU_TWO_STOP_BITS; | ||
924 | break; | ||
925 | default: | ||
926 | kfree(dataout); | ||
927 | return IUU_INVALID_PARAMETER; | ||
928 | break; | ||
929 | } | ||
930 | |||
931 | status = bulk_immediate(port, dataout, DataCount); | ||
932 | if (status != IUU_OPERATION_OK) | ||
933 | dbg("%s - uart_off error", __FUNCTION__); | ||
934 | kfree(dataout); | ||
935 | return status; | ||
936 | } | ||
937 | |||
938 | static int set_control_lines(struct usb_device *dev, u8 value) | ||
939 | { | ||
940 | return 0; | ||
941 | } | ||
942 | |||
943 | static void iuu_close(struct usb_serial_port *port, struct file *filp) | ||
944 | { | ||
945 | /* iuu_led (port,255,0,0,0); */ | ||
946 | struct usb_serial *serial; | ||
947 | struct iuu_private *priv = usb_get_serial_port_data(port); | ||
948 | unsigned long flags; | ||
949 | unsigned int c_cflag; | ||
950 | |||
951 | serial = port->serial; | ||
952 | if (!serial) | ||
953 | return; | ||
954 | |||
955 | dbg("%s - port %d", __FUNCTION__, port->number); | ||
956 | |||
957 | iuu_uart_off(port); | ||
958 | if (serial->dev) { | ||
959 | if (port->tty) { | ||
960 | c_cflag = port->tty->termios->c_cflag; | ||
961 | if (c_cflag & HUPCL) { | ||
962 | /* drop DTR and RTS */ | ||
963 | priv = usb_get_serial_port_data(port); | ||
964 | spin_lock_irqsave(&priv->lock, flags); | ||
965 | priv->line_control = 0; | ||
966 | spin_unlock_irqrestore(&priv->lock, flags); | ||
967 | set_control_lines(port->serial->dev, 0); | ||
968 | } | ||
969 | } | ||
970 | /* free writebuf */ | ||
971 | /* shutdown our urbs */ | ||
972 | dbg("%s - shutting down urbs", __FUNCTION__); | ||
973 | usb_kill_urb(port->write_urb); | ||
974 | usb_kill_urb(port->read_urb); | ||
975 | usb_kill_urb(port->interrupt_in_urb); | ||
976 | msleep(1000); | ||
977 | /* wait one second to free all buffers */ | ||
978 | iuu_led(port, 0, 0, 0xF000, 0xFF); | ||
979 | msleep(1000); | ||
980 | usb_reset_device(port->serial->dev); | ||
981 | } | ||
982 | } | ||
983 | |||
984 | static int iuu_open(struct usb_serial_port *port, struct file *filp) | ||
985 | { | ||
986 | struct usb_serial *serial = port->serial; | ||
987 | u8 *buf; | ||
988 | int result; | ||
989 | u32 actual; | ||
990 | unsigned long flags; | ||
991 | struct iuu_private *priv = usb_get_serial_port_data(port); | ||
992 | |||
993 | dbg("%s - port %d", __FUNCTION__, port->number); | ||
994 | usb_clear_halt(serial->dev, port->write_urb->pipe); | ||
995 | usb_clear_halt(serial->dev, port->read_urb->pipe); | ||
996 | |||
997 | buf = kmalloc(10, GFP_KERNEL); | ||
998 | if (buf == NULL) | ||
999 | return -ENOMEM; | ||
1000 | |||
1001 | /* fixup the endpoint buffer size */ | ||
1002 | kfree(port->bulk_out_buffer); | ||
1003 | port->bulk_out_buffer = kmalloc(512, GFP_KERNEL); | ||
1004 | port->bulk_out_size = 512; | ||
1005 | kfree(port->bulk_in_buffer); | ||
1006 | port->bulk_in_buffer = kmalloc(512, GFP_KERNEL); | ||
1007 | port->bulk_in_size = 512; | ||
1008 | |||
1009 | if (!port->bulk_out_buffer || !port->bulk_in_buffer) { | ||
1010 | kfree(port->bulk_out_buffer); | ||
1011 | kfree(port->bulk_in_buffer); | ||
1012 | kfree(buf); | ||
1013 | return -ENOMEM; | ||
1014 | } | ||
1015 | |||
1016 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, | ||
1017 | usb_sndbulkpipe(port->serial->dev, | ||
1018 | port->bulk_out_endpointAddress), | ||
1019 | port->bulk_out_buffer, 512, | ||
1020 | NULL, NULL); | ||
1021 | |||
1022 | |||
1023 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | ||
1024 | usb_rcvbulkpipe(port->serial->dev, | ||
1025 | port->bulk_in_endpointAddress), | ||
1026 | port->bulk_in_buffer, 512, | ||
1027 | NULL, NULL); | ||
1028 | |||
1029 | /* set the termios structure */ | ||
1030 | spin_lock_irqsave(&priv->lock, flags); | ||
1031 | if (!priv->termios_initialized) { | ||
1032 | *(port->tty->termios) = tty_std_termios; | ||
1033 | port->tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600 | ||
1034 | | TIOCM_CTS | CSTOPB | PARENB; | ||
1035 | port->tty->termios->c_lflag = 0; | ||
1036 | port->tty->termios->c_oflag = 0; | ||
1037 | port->tty->termios->c_iflag = 0; | ||
1038 | priv->termios_initialized = 1; | ||
1039 | port->tty->low_latency = 1; | ||
1040 | priv->poll = 0; | ||
1041 | } | ||
1042 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1043 | |||
1044 | /* initialize writebuf */ | ||
1045 | #define FISH(a, b, c, d) do { \ | ||
1046 | result = usb_control_msg(port->serial->dev, \ | ||
1047 | usb_rcvctrlpipe(port->serial->dev, 0), \ | ||
1048 | b, a, c, d, buf, 1, 1000); \ | ||
1049 | dbg("0x%x:0x%x:0x%x:0x%x %d - %x", a, b, c, d, result, \ | ||
1050 | buf[0]); } while (0); | ||
1051 | |||
1052 | #define SOUP(a, b, c, d) do { \ | ||
1053 | result = usb_control_msg(port->serial->dev, \ | ||
1054 | usb_sndctrlpipe(port->serial->dev, 0), \ | ||
1055 | b, a, c, d, NULL, 0, 1000); \ | ||
1056 | dbg("0x%x:0x%x:0x%x:0x%x %d", a, b, c, d, result); } while (0) | ||
1057 | |||
1058 | /* This is not UART related but IUU USB driver related or something */ | ||
1059 | /* like that. Basically no IUU will accept any commands from the USB */ | ||
1060 | /* host unless it has received the following message */ | ||
1061 | /* sprintf(buf ,"%c%c%c%c",0x03,0x02,0x02,0x0); */ | ||
1062 | |||
1063 | SOUP(0x03, 0x02, 0x02, 0x0); | ||
1064 | kfree(buf); | ||
1065 | iuu_led(port, 0xF000, 0xF000, 0, 0xFF); | ||
1066 | iuu_uart_on(port); | ||
1067 | if (boost < 100) | ||
1068 | boost = 100; | ||
1069 | switch (clockmode) { | ||
1070 | case 2: /* 3.680 Mhz */ | ||
1071 | iuu_clk(port, IUU_CLK_3680000 * boost / 100); | ||
1072 | result = | ||
1073 | iuu_uart_baud(port, 9600 * boost / 100, &actual, | ||
1074 | IUU_PARITY_EVEN); | ||
1075 | break; | ||
1076 | case 3: /* 6.00 Mhz */ | ||
1077 | iuu_clk(port, IUU_CLK_6000000 * boost / 100); | ||
1078 | result = | ||
1079 | iuu_uart_baud(port, 16457 * boost / 100, &actual, | ||
1080 | IUU_PARITY_EVEN); | ||
1081 | break; | ||
1082 | default: /* 3.579 Mhz */ | ||
1083 | iuu_clk(port, IUU_CLK_3579000 * boost / 100); | ||
1084 | result = | ||
1085 | iuu_uart_baud(port, 9600 * boost / 100, &actual, | ||
1086 | IUU_PARITY_EVEN); | ||
1087 | } | ||
1088 | |||
1089 | /* set the cardin cardout signals */ | ||
1090 | switch (cdmode) { | ||
1091 | case 0: | ||
1092 | iuu_cardin = 0; | ||
1093 | iuu_cardout = 0; | ||
1094 | break; | ||
1095 | case 1: | ||
1096 | iuu_cardin = TIOCM_CD; | ||
1097 | iuu_cardout = 0; | ||
1098 | break; | ||
1099 | case 2: | ||
1100 | iuu_cardin = 0; | ||
1101 | iuu_cardout = TIOCM_CD; | ||
1102 | break; | ||
1103 | case 3: | ||
1104 | iuu_cardin = TIOCM_DSR; | ||
1105 | iuu_cardout = 0; | ||
1106 | break; | ||
1107 | case 4: | ||
1108 | iuu_cardin = 0; | ||
1109 | iuu_cardout = TIOCM_DSR; | ||
1110 | break; | ||
1111 | case 5: | ||
1112 | iuu_cardin = TIOCM_CTS; | ||
1113 | iuu_cardout = 0; | ||
1114 | break; | ||
1115 | case 6: | ||
1116 | iuu_cardin = 0; | ||
1117 | iuu_cardout = TIOCM_CTS; | ||
1118 | break; | ||
1119 | case 7: | ||
1120 | iuu_cardin = TIOCM_RNG; | ||
1121 | iuu_cardout = 0; | ||
1122 | break; | ||
1123 | case 8: | ||
1124 | iuu_cardin = 0; | ||
1125 | iuu_cardout = TIOCM_RNG; | ||
1126 | } | ||
1127 | |||
1128 | iuu_uart_flush(port); | ||
1129 | |||
1130 | dbg("%s - initialization done", __FUNCTION__); | ||
1131 | |||
1132 | memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1); | ||
1133 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, | ||
1134 | usb_sndbulkpipe(port->serial->dev, | ||
1135 | port->bulk_out_endpointAddress), | ||
1136 | port->write_urb->transfer_buffer, 1, | ||
1137 | read_rxcmd_callback, port); | ||
1138 | result = usb_submit_urb(port->write_urb, GFP_KERNEL); | ||
1139 | |||
1140 | if (result) { | ||
1141 | dev_err(&port->dev, "%s - failed submitting read urb," | ||
1142 | " error %d\n", __FUNCTION__, result); | ||
1143 | iuu_close(port, NULL); | ||
1144 | return -EPROTO; | ||
1145 | } else { | ||
1146 | dbg("%s - rxcmd OK", __FUNCTION__); | ||
1147 | } | ||
1148 | return result; | ||
1149 | } | ||
1150 | |||
1151 | static struct usb_serial_driver iuu_device = { | ||
1152 | .driver = { | ||
1153 | .owner = THIS_MODULE, | ||
1154 | .name = "iuu_phoenix", | ||
1155 | }, | ||
1156 | .id_table = id_table, | ||
1157 | .num_interrupt_in = NUM_DONT_CARE, | ||
1158 | .num_bulk_in = 1, | ||
1159 | .num_bulk_out = 1, | ||
1160 | .num_ports = 1, | ||
1161 | .open = iuu_open, | ||
1162 | .close = iuu_close, | ||
1163 | .write = iuu_uart_write, | ||
1164 | .read_bulk_callback = iuu_uart_read_callback, | ||
1165 | .tiocmget = iuu_tiocmget, | ||
1166 | .tiocmset = iuu_tiocmset, | ||
1167 | .attach = iuu_startup, | ||
1168 | .shutdown = iuu_shutdown, | ||
1169 | }; | ||
1170 | |||
1171 | static int __init iuu_init(void) | ||
1172 | { | ||
1173 | int retval; | ||
1174 | retval = usb_serial_register(&iuu_device); | ||
1175 | if (retval) | ||
1176 | goto failed_usb_serial_register; | ||
1177 | retval = usb_register(&iuu_driver); | ||
1178 | if (retval) | ||
1179 | goto failed_usb_register; | ||
1180 | info(DRIVER_DESC " " DRIVER_VERSION); | ||
1181 | return 0; | ||
1182 | failed_usb_register: | ||
1183 | usb_serial_deregister(&iuu_device); | ||
1184 | failed_usb_serial_register: | ||
1185 | return retval; | ||
1186 | } | ||
1187 | |||
1188 | static void __exit iuu_exit(void) | ||
1189 | { | ||
1190 | usb_deregister(&iuu_driver); | ||
1191 | usb_serial_deregister(&iuu_device); | ||
1192 | } | ||
1193 | |||
1194 | module_init(iuu_init); | ||
1195 | module_exit(iuu_exit); | ||
1196 | |||
1197 | MODULE_AUTHOR("Alain Degreffe eczema@ecze.com"); | ||
1198 | |||
1199 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
1200 | MODULE_LICENSE("GPL"); | ||
1201 | |||
1202 | MODULE_VERSION(DRIVER_VERSION); | ||
1203 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
1204 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
1205 | |||
1206 | module_param(xmas, bool, S_IRUGO | S_IWUSR); | ||
1207 | MODULE_PARM_DESC(xmas, "xmas color enabled or not"); | ||
1208 | |||
1209 | module_param(boost, int, S_IRUGO | S_IWUSR); | ||
1210 | MODULE_PARM_DESC(boost, "overclock boost percent 100 to 500"); | ||
1211 | |||
1212 | module_param(clockmode, int, S_IRUGO | S_IWUSR); | ||
1213 | MODULE_PARM_DESC(clockmode, "1=3Mhz579,2=3Mhz680,3=6Mhz"); | ||
1214 | |||
1215 | module_param(cdmode, int, S_IRUGO | S_IWUSR); | ||
1216 | MODULE_PARM_DESC(cdmode, "Card detect mode 0=none, 1=CD, 2=!CD, 3=DSR, " | ||
1217 | "4=!DSR, 5=CTS, 6=!CTS, 7=RING, 8=!RING"); | ||
diff --git a/drivers/usb/serial/iuu_phoenix.h b/drivers/usb/serial/iuu_phoenix.h new file mode 100644 index 000000000000..b82630a3b8fd --- /dev/null +++ b/drivers/usb/serial/iuu_phoenix.h | |||
@@ -0,0 +1,122 @@ | |||
1 | /* | ||
2 | * Infinity Unlimited USB Phoenix driver | ||
3 | * | ||
4 | * Copyright (C) 2007 Alain Degreffe (eczema@ecze.com) | ||
5 | * | ||
6 | * | ||
7 | * Original code taken from iuutool ( Copyright (C) 2006 Juan Carlos Borrás ) | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * And tested with help of WB Electronics | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | #define IUU_USB_VENDOR_ID 0x104f | ||
19 | #define IUU_USB_PRODUCT_ID 0x0004 | ||
20 | #define IUU_USB_OP_TIMEOUT 0x0200 | ||
21 | |||
22 | /* Programmer commands */ | ||
23 | |||
24 | #define IUU_NO_OPERATION 0x00 | ||
25 | #define IUU_GET_FIRMWARE_VERSION 0x01 | ||
26 | #define IUU_GET_PRODUCT_NAME 0x02 | ||
27 | #define IUU_GET_STATE_REGISTER 0x03 | ||
28 | #define IUU_SET_LED 0x04 | ||
29 | #define IUU_WAIT_MUS 0x05 | ||
30 | #define IUU_WAIT_MS 0x06 | ||
31 | #define IUU_GET_LOADER_VERSION 0x50 | ||
32 | #define IUU_RST_SET 0x52 | ||
33 | #define IUU_RST_CLEAR 0x53 | ||
34 | #define IUU_SET_VCC 0x59 | ||
35 | #define IUU_UART_ENABLE 0x49 | ||
36 | #define IUU_UART_DISABLE 0x4A | ||
37 | #define IUU_UART_WRITE_I2C 0x4C | ||
38 | #define IUU_UART_ESC 0x5E | ||
39 | #define IUU_UART_TRAP 0x54 | ||
40 | #define IUU_UART_TRAP_BREAK 0x5B | ||
41 | #define IUU_UART_RX 0x56 | ||
42 | #define IUU_AVR_ON 0x21 | ||
43 | #define IUU_AVR_OFF 0x22 | ||
44 | #define IUU_AVR_1CLK 0x23 | ||
45 | #define IUU_AVR_RESET 0x24 | ||
46 | #define IUU_AVR_RESET_PC 0x25 | ||
47 | #define IUU_AVR_INC_PC 0x26 | ||
48 | #define IUU_AVR_INCN_PC 0x27 | ||
49 | #define IUU_AVR_PREAD 0x29 | ||
50 | #define IUU_AVR_PREADN 0x2A | ||
51 | #define IUU_AVR_PWRITE 0x28 | ||
52 | #define IUU_AVR_DREAD 0x2C | ||
53 | #define IUU_AVR_DREADN 0x2D | ||
54 | #define IUU_AVR_DWRITE 0x2B | ||
55 | #define IUU_AVR_PWRITEN 0x2E | ||
56 | #define IUU_EEPROM_ON 0x37 | ||
57 | #define IUU_EEPROM_OFF 0x38 | ||
58 | #define IUU_EEPROM_WRITE 0x39 | ||
59 | #define IUU_EEPROM_WRITEX 0x3A | ||
60 | #define IUU_EEPROM_WRITE8 0x3B | ||
61 | #define IUU_EEPROM_WRITE16 0x3C | ||
62 | #define IUU_EEPROM_WRITEX32 0x3D | ||
63 | #define IUU_EEPROM_WRITEX64 0x3E | ||
64 | #define IUU_EEPROM_READ 0x3F | ||
65 | #define IUU_EEPROM_READX 0x40 | ||
66 | #define IUU_EEPROM_BREAD 0x41 | ||
67 | #define IUU_EEPROM_BREADX 0x42 | ||
68 | #define IUU_PIC_CMD 0x0A | ||
69 | #define IUU_PIC_CMD_LOAD 0x0B | ||
70 | #define IUU_PIC_CMD_READ 0x0C | ||
71 | #define IUU_PIC_ON 0x0D | ||
72 | #define IUU_PIC_OFF 0x0E | ||
73 | #define IUU_PIC_RESET 0x16 | ||
74 | #define IUU_PIC_INC_PC 0x0F | ||
75 | #define IUU_PIC_INCN_PC 0x10 | ||
76 | #define IUU_PIC_PWRITE 0x11 | ||
77 | #define IUU_PIC_PREAD 0x12 | ||
78 | #define IUU_PIC_PREADN 0x13 | ||
79 | #define IUU_PIC_DWRITE 0x14 | ||
80 | #define IUU_PIC_DREAD 0x15 | ||
81 | #define IUU_UART_NOP 0x00 | ||
82 | #define IUU_UART_CHANGE 0x02 | ||
83 | #define IUU_UART_TX 0x04 | ||
84 | #define IUU_DELAY_MS 0x06 | ||
85 | |||
86 | #define IUU_OPERATION_OK 0x00 | ||
87 | #define IUU_DEVICE_NOT_FOUND 0x01 | ||
88 | #define IUU_INVALID_HANDLE 0x02 | ||
89 | #define IUU_INVALID_PARAMETER 0x03 | ||
90 | #define IUU_INVALID_voidERFACE 0x04 | ||
91 | #define IUU_INVALID_REQUEST_LENGTH 0x05 | ||
92 | #define IUU_UART_NOT_ENABLED 0x06 | ||
93 | #define IUU_WRITE_ERROR 0x07 | ||
94 | #define IUU_READ_ERROR 0x08 | ||
95 | #define IUU_TX_ERROR 0x09 | ||
96 | #define IUU_RX_ERROR 0x0A | ||
97 | |||
98 | #define IUU_PARITY_NONE 0x00 | ||
99 | #define IUU_PARITY_EVEN 0x01 | ||
100 | #define IUU_PARITY_ODD 0x02 | ||
101 | #define IUU_PARITY_MARK 0x03 | ||
102 | #define IUU_PARITY_SPACE 0x04 | ||
103 | #define IUU_SC_INSERTED 0x01 | ||
104 | #define IUU_VERIFY_ERROR 0x02 | ||
105 | #define IUU_SIM_INSERTED 0x04 | ||
106 | #define IUU_TWO_STOP_BITS 0x00 | ||
107 | #define IUU_ONE_STOP_BIT 0x20 | ||
108 | #define IUU_BAUD_2400 0x0398 | ||
109 | #define IUU_BAUD_9600 0x0298 | ||
110 | #define IUU_BAUD_19200 0x0164 | ||
111 | #define IUU_BAUD_28800 0x0198 | ||
112 | #define IUU_BAUD_38400 0x01B2 | ||
113 | #define IUU_BAUD_57600 0x0030 | ||
114 | #define IUU_BAUD_115200 0x0098 | ||
115 | #define IUU_CLK_3579000 3579000 | ||
116 | #define IUU_CLK_3680000 3680000 | ||
117 | #define IUU_CLK_6000000 6000000 | ||
118 | #define IUU_FULLCARD_IN 0x01 | ||
119 | #define IUU_DEV_ERROR 0x02 | ||
120 | #define IUU_MINICARD_IN 0x04 | ||
121 | #define IUU_VCC_5V 0x00 | ||
122 | #define IUU_VCC_3V 0x01 | ||
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 7c069a02c1dd..ea7bba69f4da 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c | |||
@@ -838,7 +838,7 @@ static void usa49_indat_callback(struct urb *urb) | |||
838 | 838 | ||
839 | port = (struct usb_serial_port *) urb->context; | 839 | port = (struct usb_serial_port *) urb->context; |
840 | tty = port->tty; | 840 | tty = port->tty; |
841 | if (urb->actual_length) { | 841 | if (tty && urb->actual_length) { |
842 | /* 0x80 bit is error flag */ | 842 | /* 0x80 bit is error flag */ |
843 | if ((data[0] & 0x80) == 0) { | 843 | if ((data[0] & 0x80) == 0) { |
844 | /* no error on any byte */ | 844 | /* no error on any byte */ |
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index be9ac20a8f10..b1fa5a376e96 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
@@ -303,7 +303,7 @@ static void keyspan_pda_rx_unthrottle (struct usb_serial_port *port) | |||
303 | } | 303 | } |
304 | 304 | ||
305 | 305 | ||
306 | static int keyspan_pda_setbaud (struct usb_serial *serial, int baud) | 306 | static speed_t keyspan_pda_setbaud (struct usb_serial *serial, speed_t baud) |
307 | { | 307 | { |
308 | int rc; | 308 | int rc; |
309 | int bindex; | 309 | int bindex; |
@@ -319,7 +319,9 @@ static int keyspan_pda_setbaud (struct usb_serial *serial, int baud) | |||
319 | case 38400: bindex = 7; break; | 319 | case 38400: bindex = 7; break; |
320 | case 57600: bindex = 8; break; | 320 | case 57600: bindex = 8; break; |
321 | case 115200: bindex = 9; break; | 321 | case 115200: bindex = 9; break; |
322 | default: return -EINVAL; | 322 | default: |
323 | bindex = 5; /* Default to 9600 */ | ||
324 | baud = 9600; | ||
323 | } | 325 | } |
324 | 326 | ||
325 | /* rather than figure out how to sleep while waiting for this | 327 | /* rather than figure out how to sleep while waiting for this |
@@ -334,7 +336,9 @@ static int keyspan_pda_setbaud (struct usb_serial *serial, int baud) | |||
334 | NULL, /* &data */ | 336 | NULL, /* &data */ |
335 | 0, /* size */ | 337 | 0, /* size */ |
336 | 2000); /* timeout */ | 338 | 2000); /* timeout */ |
337 | return(rc); | 339 | if (rc < 0) |
340 | return 0; | ||
341 | return baud; | ||
338 | } | 342 | } |
339 | 343 | ||
340 | 344 | ||
@@ -366,7 +370,7 @@ static void keyspan_pda_set_termios (struct usb_serial_port *port, | |||
366 | struct ktermios *old_termios) | 370 | struct ktermios *old_termios) |
367 | { | 371 | { |
368 | struct usb_serial *serial = port->serial; | 372 | struct usb_serial *serial = port->serial; |
369 | unsigned int cflag = port->tty->termios->c_cflag; | 373 | speed_t speed; |
370 | 374 | ||
371 | /* cflag specifies lots of stuff: number of stop bits, parity, number | 375 | /* cflag specifies lots of stuff: number of stop bits, parity, number |
372 | of data bits, baud. What can the device actually handle?: | 376 | of data bits, baud. What can the device actually handle?: |
@@ -388,22 +392,18 @@ static void keyspan_pda_set_termios (struct usb_serial_port *port, | |||
388 | 392 | ||
389 | For now, just do baud. */ | 393 | For now, just do baud. */ |
390 | 394 | ||
391 | switch (cflag & CBAUD) { | 395 | speed = tty_get_baud_rate(port->tty); |
392 | /* we could support more values here, just need to calculate | 396 | speed = keyspan_pda_setbaud(serial, speed); |
393 | the necessary divisors in the firmware. <asm/termbits.h> | 397 | |
394 | has the Bnnn constants. */ | 398 | if (speed == 0) { |
395 | case B110: keyspan_pda_setbaud(serial, 110); break; | 399 | dbg("can't handle requested baud rate"); |
396 | case B300: keyspan_pda_setbaud(serial, 300); break; | 400 | /* It hasn't changed so.. */ |
397 | case B1200: keyspan_pda_setbaud(serial, 1200); break; | 401 | speed = tty_termios_baud_rate(old_termios); |
398 | case B2400: keyspan_pda_setbaud(serial, 2400); break; | ||
399 | case B4800: keyspan_pda_setbaud(serial, 4800); break; | ||
400 | case B9600: keyspan_pda_setbaud(serial, 9600); break; | ||
401 | case B19200: keyspan_pda_setbaud(serial, 19200); break; | ||
402 | case B38400: keyspan_pda_setbaud(serial, 38400); break; | ||
403 | case B57600: keyspan_pda_setbaud(serial, 57600); break; | ||
404 | case B115200: keyspan_pda_setbaud(serial, 115200); break; | ||
405 | default: dbg("can't handle requested baud rate"); break; | ||
406 | } | 402 | } |
403 | /* Only speed can change so copy the old h/w parameters | ||
404 | then encode the new speed */ | ||
405 | tty_termios_copy_hw(port->tty->termios, old_termios); | ||
406 | tty_encode_baud_rate(port->tty, speed, speed); | ||
407 | } | 407 | } |
408 | 408 | ||
409 | 409 | ||
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 90e3216abd1f..55736df7d2f4 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -461,17 +461,21 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp) | |||
461 | 461 | ||
462 | dbg("%s port %d", __FUNCTION__, port->number); | 462 | dbg("%s port %d", __FUNCTION__, port->number); |
463 | 463 | ||
464 | /* send READ_OFF */ | 464 | mutex_lock(&port->serial->disc_mutex); |
465 | rc = usb_control_msg (port->serial->dev, | 465 | if (!port->serial->disconnected) { |
466 | usb_sndctrlpipe(port->serial->dev, 0), | 466 | /* send READ_OFF */ |
467 | KL5KUSB105A_SIO_CONFIGURE, | 467 | rc = usb_control_msg (port->serial->dev, |
468 | USB_TYPE_VENDOR | USB_DIR_OUT, | 468 | usb_sndctrlpipe(port->serial->dev, 0), |
469 | KL5KUSB105A_SIO_CONFIGURE_READ_OFF, | 469 | KL5KUSB105A_SIO_CONFIGURE, |
470 | 0, /* index */ | 470 | USB_TYPE_VENDOR | USB_DIR_OUT, |
471 | NULL, 0, | 471 | KL5KUSB105A_SIO_CONFIGURE_READ_OFF, |
472 | KLSI_TIMEOUT); | 472 | 0, /* index */ |
473 | if (rc < 0) | 473 | NULL, 0, |
474 | err("Disabling read failed (error = %d)", rc); | 474 | KLSI_TIMEOUT); |
475 | if (rc < 0) | ||
476 | err("Disabling read failed (error = %d)", rc); | ||
477 | } | ||
478 | mutex_unlock(&port->serial->disc_mutex); | ||
475 | 479 | ||
476 | /* shutdown our bulk reads and writes */ | 480 | /* shutdown our bulk reads and writes */ |
477 | usb_kill_urb(port->write_urb); | 481 | usb_kill_urb(port->write_urb); |
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index aee450246bfd..17b3baead4ad 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -114,6 +114,7 @@ static struct usb_serial_driver kobil_device = { | |||
114 | .usb_driver = &kobil_driver, | 114 | .usb_driver = &kobil_driver, |
115 | .id_table = id_table, | 115 | .id_table = id_table, |
116 | .num_interrupt_in = NUM_DONT_CARE, | 116 | .num_interrupt_in = NUM_DONT_CARE, |
117 | .num_interrupt_out = NUM_DONT_CARE, | ||
117 | .num_bulk_in = 0, | 118 | .num_bulk_in = 0, |
118 | .num_bulk_out = 0, | 119 | .num_bulk_out = 0, |
119 | .num_ports = 1, | 120 | .num_ports = 1, |
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index 0dc99f75bb09..fc1cea4aba13 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c | |||
@@ -182,10 +182,11 @@ struct mct_u232_private { | |||
182 | /* | 182 | /* |
183 | * Later day 2.6.0-test kernels have new baud rates like B230400 which | 183 | * Later day 2.6.0-test kernels have new baud rates like B230400 which |
184 | * we do not know how to support. We ignore them for the moment. | 184 | * we do not know how to support. We ignore them for the moment. |
185 | * XXX Rate-limit the error message, it's user triggerable. | ||
186 | */ | 185 | */ |
187 | static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value) | 186 | static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value, speed_t *result) |
188 | { | 187 | { |
188 | *result = value; | ||
189 | |||
189 | if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID | 190 | if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID |
190 | || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) { | 191 | || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) { |
191 | switch (value) { | 192 | switch (value) { |
@@ -200,11 +201,13 @@ static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value | |||
200 | case 57600: return 0x0b; | 201 | case 57600: return 0x0b; |
201 | case 115200: return 0x0c; | 202 | case 115200: return 0x0c; |
202 | default: | 203 | default: |
203 | err("MCT USB-RS232: unsupported baudrate request 0x%x," | 204 | *result = 9600; |
204 | " using default of B9600", value); | ||
205 | return 0x08; | 205 | return 0x08; |
206 | } | 206 | } |
207 | } else { | 207 | } else { |
208 | /* FIXME: Can we use any divider - should we do | ||
209 | divider = 115200/value; | ||
210 | real baud = 115200/divider */ | ||
208 | switch (value) { | 211 | switch (value) { |
209 | case 300: break; | 212 | case 300: break; |
210 | case 600: break; | 213 | case 600: break; |
@@ -217,9 +220,8 @@ static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value | |||
217 | case 57600: break; | 220 | case 57600: break; |
218 | case 115200: break; | 221 | case 115200: break; |
219 | default: | 222 | default: |
220 | err("MCT USB-RS232: unsupported baudrate request 0x%x," | ||
221 | " using default of B9600", value); | ||
222 | value = 9600; | 223 | value = 9600; |
224 | *result = 9600; | ||
223 | } | 225 | } |
224 | return 115200/value; | 226 | return 115200/value; |
225 | } | 227 | } |
@@ -232,16 +234,19 @@ static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_p | |||
232 | int rc; | 234 | int rc; |
233 | unsigned char zero_byte = 0; | 235 | unsigned char zero_byte = 0; |
234 | unsigned char cts_enable_byte = 0; | 236 | unsigned char cts_enable_byte = 0; |
237 | speed_t speed; | ||
235 | 238 | ||
236 | divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value)); | 239 | divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value, &speed)); |
237 | 240 | ||
238 | rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 241 | rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), |
239 | MCT_U232_SET_BAUD_RATE_REQUEST, | 242 | MCT_U232_SET_BAUD_RATE_REQUEST, |
240 | MCT_U232_SET_REQUEST_TYPE, | 243 | MCT_U232_SET_REQUEST_TYPE, |
241 | 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE, | 244 | 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE, |
242 | WDR_TIMEOUT); | 245 | WDR_TIMEOUT); |
243 | if (rc < 0) | 246 | if (rc < 0) /*FIXME: What value speed results */ |
244 | err("Set BAUD RATE %d failed (error = %d)", value, rc); | 247 | err("Set BAUD RATE %d failed (error = %d)", value, rc); |
248 | else | ||
249 | tty_encode_baud_rate(port->tty, speed, speed); | ||
245 | dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); | 250 | dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); |
246 | 251 | ||
247 | /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which | 252 | /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which |
@@ -482,21 +487,22 @@ error: | |||
482 | static void mct_u232_close (struct usb_serial_port *port, struct file *filp) | 487 | static void mct_u232_close (struct usb_serial_port *port, struct file *filp) |
483 | { | 488 | { |
484 | unsigned int c_cflag; | 489 | unsigned int c_cflag; |
485 | unsigned long flags; | ||
486 | unsigned int control_state; | 490 | unsigned int control_state; |
487 | struct mct_u232_private *priv = usb_get_serial_port_data(port); | 491 | struct mct_u232_private *priv = usb_get_serial_port_data(port); |
488 | dbg("%s port %d", __FUNCTION__, port->number); | 492 | dbg("%s port %d", __FUNCTION__, port->number); |
489 | 493 | ||
490 | if (port->tty) { | 494 | if (port->tty) { |
491 | c_cflag = port->tty->termios->c_cflag; | 495 | c_cflag = port->tty->termios->c_cflag; |
492 | if (c_cflag & HUPCL) { | 496 | mutex_lock(&port->serial->disc_mutex); |
493 | /* drop DTR and RTS */ | 497 | if (c_cflag & HUPCL && !port->serial->disconnected) { |
494 | spin_lock_irqsave(&priv->lock, flags); | 498 | /* drop DTR and RTS */ |
495 | priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); | 499 | spin_lock_irq(&priv->lock); |
496 | control_state = priv->control_state; | 500 | priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); |
497 | spin_unlock_irqrestore(&priv->lock, flags); | 501 | control_state = priv->control_state; |
498 | mct_u232_set_modem_ctrl(port->serial, control_state); | 502 | spin_unlock_irq(&priv->lock); |
503 | mct_u232_set_modem_ctrl(port->serial, control_state); | ||
499 | } | 504 | } |
505 | mutex_unlock(&port->serial->disc_mutex); | ||
500 | } | 506 | } |
501 | 507 | ||
502 | 508 | ||
@@ -608,7 +614,8 @@ static void mct_u232_set_termios (struct usb_serial_port *port, | |||
608 | { | 614 | { |
609 | struct usb_serial *serial = port->serial; | 615 | struct usb_serial *serial = port->serial; |
610 | struct mct_u232_private *priv = usb_get_serial_port_data(port); | 616 | struct mct_u232_private *priv = usb_get_serial_port_data(port); |
611 | unsigned int cflag = port->tty->termios->c_cflag; | 617 | struct ktermios *termios = port->tty->termios; |
618 | unsigned int cflag = termios->c_cflag; | ||
612 | unsigned int old_cflag = old_termios->c_cflag; | 619 | unsigned int old_cflag = old_termios->c_cflag; |
613 | unsigned long flags; | 620 | unsigned long flags; |
614 | unsigned int control_state; | 621 | unsigned int control_state; |
@@ -670,6 +677,8 @@ static void mct_u232_set_termios (struct usb_serial_port *port, | |||
670 | break; | 677 | break; |
671 | } | 678 | } |
672 | 679 | ||
680 | termios->c_cflag &= ~CMSPAR; | ||
681 | |||
673 | /* set the number of stop bits */ | 682 | /* set the number of stop bits */ |
674 | last_lcr |= (cflag & CSTOPB) ? | 683 | last_lcr |= (cflag & CSTOPB) ? |
675 | MCT_U232_STOP_BITS_2 : MCT_U232_STOP_BITS_1; | 684 | MCT_U232_STOP_BITS_2 : MCT_U232_STOP_BITS_1; |
diff --git a/drivers/usb/serial/mct_u232.h b/drivers/usb/serial/mct_u232.h index aae10c8174d6..07b6bec31dc8 100644 --- a/drivers/usb/serial/mct_u232.h +++ b/drivers/usb/serial/mct_u232.h | |||
@@ -79,7 +79,7 @@ | |||
79 | * and "Intel solution". They are the regular MCT and "Sitecom" for us. | 79 | * and "Intel solution". They are the regular MCT and "Sitecom" for us. |
80 | * This is pointless to document in the header, see the code for the bits. | 80 | * This is pointless to document in the header, see the code for the bits. |
81 | */ | 81 | */ |
82 | static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value); | 82 | static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value, speed_t *result); |
83 | 83 | ||
84 | /* | 84 | /* |
85 | * Line Control Register (LCR) | 85 | * Line Control Register (LCR) |
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index e02c198016b0..40f3a0188807 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
@@ -564,22 +564,25 @@ static void mos7720_close(struct usb_serial_port *port, struct file *filp) | |||
564 | } | 564 | } |
565 | 565 | ||
566 | /* While closing port, shutdown all bulk read, write * | 566 | /* While closing port, shutdown all bulk read, write * |
567 | * and interrupt read if they exists */ | 567 | * and interrupt read if they exists, otherwise nop */ |
568 | if (serial->dev) { | 568 | dbg("Shutdown bulk write"); |
569 | dbg("Shutdown bulk write"); | 569 | usb_kill_urb(port->write_urb); |
570 | usb_kill_urb(port->write_urb); | 570 | dbg("Shutdown bulk read"); |
571 | dbg("Shutdown bulk read"); | 571 | usb_kill_urb(port->read_urb); |
572 | usb_kill_urb(port->read_urb); | 572 | |
573 | mutex_lock(&serial->disc_mutex); | ||
574 | /* these commands must not be issued if the device has | ||
575 | * been disconnected */ | ||
576 | if (!serial->disconnected) { | ||
577 | data = 0x00; | ||
578 | send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, | ||
579 | 0x04, &data); | ||
580 | |||
581 | data = 0x00; | ||
582 | send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, | ||
583 | 0x01, &data); | ||
573 | } | 584 | } |
574 | 585 | mutex_unlock(&serial->disc_mutex); | |
575 | data = 0x00; | ||
576 | send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, | ||
577 | 0x04, &data); | ||
578 | |||
579 | data = 0x00; | ||
580 | send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, | ||
581 | 0x01, &data); | ||
582 | |||
583 | mos7720_port->open = 0; | 586 | mos7720_port->open = 0; |
584 | 587 | ||
585 | dbg("Leaving %s", __FUNCTION__); | 588 | dbg("Leaving %s", __FUNCTION__); |
@@ -1040,11 +1043,6 @@ static void change_port_settings(struct moschip_port *mos7720_port, | |||
1040 | 1043 | ||
1041 | tty = mos7720_port->port->tty; | 1044 | tty = mos7720_port->port->tty; |
1042 | 1045 | ||
1043 | if ((!tty) || (!tty->termios)) { | ||
1044 | dbg("%s - no tty structures", __FUNCTION__); | ||
1045 | return; | ||
1046 | } | ||
1047 | |||
1048 | dbg("%s: Entering ..........", __FUNCTION__); | 1046 | dbg("%s: Entering ..........", __FUNCTION__); |
1049 | 1047 | ||
1050 | lData = UART_LCR_WLEN8; | 1048 | lData = UART_LCR_WLEN8; |
@@ -1175,7 +1173,10 @@ static void change_port_settings(struct moschip_port *mos7720_port, | |||
1175 | 1173 | ||
1176 | dbg("%s - baud rate = %d", __FUNCTION__, baud); | 1174 | dbg("%s - baud rate = %d", __FUNCTION__, baud); |
1177 | status = send_cmd_write_baud_rate(mos7720_port, baud); | 1175 | status = send_cmd_write_baud_rate(mos7720_port, baud); |
1178 | 1176 | /* FIXME: needs to write actual resulting baud back not just | |
1177 | blindly do so */ | ||
1178 | if (cflag & CBAUD) | ||
1179 | tty_encode_baud_rate(tty, baud, baud); | ||
1179 | /* Enable Interrupts */ | 1180 | /* Enable Interrupts */ |
1180 | data = 0x0c; | 1181 | data = 0x0c; |
1181 | send_mos_cmd(serial, MOS_WRITE, port_number, UART_IER, &data); | 1182 | send_mos_cmd(serial, MOS_WRITE, port_number, UART_IER, &data); |
@@ -1214,10 +1215,6 @@ static void mos7720_set_termios(struct usb_serial_port *port, | |||
1214 | 1215 | ||
1215 | tty = port->tty; | 1216 | tty = port->tty; |
1216 | 1217 | ||
1217 | if (!port->tty || !port->tty->termios) { | ||
1218 | dbg("%s - no tty or termios", __FUNCTION__); | ||
1219 | return; | ||
1220 | } | ||
1221 | 1218 | ||
1222 | if (!mos7720_port->open) { | 1219 | if (!mos7720_port->open) { |
1223 | dbg("%s - port not opened", __FUNCTION__); | 1220 | dbg("%s - port not opened", __FUNCTION__); |
@@ -1228,19 +1225,13 @@ static void mos7720_set_termios(struct usb_serial_port *port, | |||
1228 | 1225 | ||
1229 | cflag = tty->termios->c_cflag; | 1226 | cflag = tty->termios->c_cflag; |
1230 | 1227 | ||
1231 | if (!cflag) { | 1228 | dbg("%s - cflag %08x iflag %08x", __FUNCTION__, |
1232 | printk("%s %s\n",__FUNCTION__,"cflag is NULL"); | ||
1233 | return; | ||
1234 | } | ||
1235 | |||
1236 | dbg("%s - clfag %08x iflag %08x", __FUNCTION__, | ||
1237 | tty->termios->c_cflag, | 1229 | tty->termios->c_cflag, |
1238 | RELEVANT_IFLAG(tty->termios->c_iflag)); | 1230 | RELEVANT_IFLAG(tty->termios->c_iflag)); |
1239 | 1231 | ||
1240 | if (old_termios) | 1232 | dbg("%s - old cflag %08x old iflag %08x", __FUNCTION__, |
1241 | dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, | 1233 | old_termios->c_cflag, |
1242 | old_termios->c_cflag, | 1234 | RELEVANT_IFLAG(old_termios->c_iflag)); |
1243 | RELEVANT_IFLAG(old_termios->c_iflag)); | ||
1244 | 1235 | ||
1245 | dbg("%s - port %d", __FUNCTION__, port->number); | 1236 | dbg("%s - port %d", __FUNCTION__, port->number); |
1246 | 1237 | ||
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index c29c91271133..869ecd374cb4 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -1133,7 +1133,7 @@ static int mos7840_chars_in_buffer(struct usb_serial_port *port) | |||
1133 | * This function will block the close until one of the following: | 1133 | * This function will block the close until one of the following: |
1134 | * 1. TX count are 0 | 1134 | * 1. TX count are 0 |
1135 | * 2. The mos7840 has stopped | 1135 | * 2. The mos7840 has stopped |
1136 | * 3. A timout of 3 seconds without activity has expired | 1136 | * 3. A timeout of 3 seconds without activity has expired |
1137 | * | 1137 | * |
1138 | ************************************************************************/ | 1138 | ************************************************************************/ |
1139 | static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port) | 1139 | static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port) |
@@ -1161,7 +1161,7 @@ static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port) | |||
1161 | dbg("%s - TIMEOUT", __FUNCTION__); | 1161 | dbg("%s - TIMEOUT", __FUNCTION__); |
1162 | return; | 1162 | return; |
1163 | } else { | 1163 | } else { |
1164 | /* Reset timout value back to seconds */ | 1164 | /* Reset timeout value back to seconds */ |
1165 | wait = 30; | 1165 | wait = 30; |
1166 | } | 1166 | } |
1167 | } | 1167 | } |
@@ -1275,7 +1275,7 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp) | |||
1275 | * | 1275 | * |
1276 | * This function will block the close until one of the following: | 1276 | * This function will block the close until one of the following: |
1277 | * 1. Response to our Chase comes from mos7840 | 1277 | * 1. Response to our Chase comes from mos7840 |
1278 | * 2. A timout of 10 seconds without activity has expired | 1278 | * 2. A timeout of 10 seconds without activity has expired |
1279 | * (1K of mos7840 data @ 2400 baud ==> 4 sec to empty) | 1279 | * (1K of mos7840 data @ 2400 baud ==> 4 sec to empty) |
1280 | * | 1280 | * |
1281 | ************************************************************************/ | 1281 | ************************************************************************/ |
@@ -1304,7 +1304,7 @@ static void mos7840_block_until_chase_response(struct moschip_port | |||
1304 | dbg("%s - TIMEOUT", __FUNCTION__); | 1304 | dbg("%s - TIMEOUT", __FUNCTION__); |
1305 | return; | 1305 | return; |
1306 | } else { | 1306 | } else { |
1307 | /* Reset timout value back to seconds */ | 1307 | /* Reset timeout value back to seconds */ |
1308 | wait = 10; | 1308 | wait = 10; |
1309 | } | 1309 | } |
1310 | } | 1310 | } |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index d1185f53447b..5e8bf1bc1e50 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -180,6 +180,7 @@ static struct usb_device_id option_ids[] = { | |||
180 | { USB_DEVICE(DELL_VENDOR_ID, 0x8117) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO ExpressCard == Novatel Merlin XV620 CDMA/EV-DO */ | 180 | { USB_DEVICE(DELL_VENDOR_ID, 0x8117) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO ExpressCard == Novatel Merlin XV620 CDMA/EV-DO */ |
181 | { USB_DEVICE(DELL_VENDOR_ID, 0x8118) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard == Novatel Merlin XU870 HSDPA/3G */ | 181 | { USB_DEVICE(DELL_VENDOR_ID, 0x8118) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard == Novatel Merlin XU870 HSDPA/3G */ |
182 | { USB_DEVICE(DELL_VENDOR_ID, 0x8128) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite E720 CDMA/EV-DO */ | 182 | { USB_DEVICE(DELL_VENDOR_ID, 0x8128) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite E720 CDMA/EV-DO */ |
183 | { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ | ||
183 | { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ | 184 | { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ |
184 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, | 185 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, |
185 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, | 186 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, |
@@ -640,7 +641,10 @@ static void option_close(struct usb_serial_port *port, struct file *filp) | |||
640 | portdata->dtr_state = 0; | 641 | portdata->dtr_state = 0; |
641 | 642 | ||
642 | if (serial->dev) { | 643 | if (serial->dev) { |
643 | option_send_setup(port); | 644 | mutex_lock(&serial->disc_mutex); |
645 | if (!serial->disconnected) | ||
646 | option_send_setup(port); | ||
647 | mutex_unlock(&serial->disc_mutex); | ||
644 | 648 | ||
645 | /* Stop reading/writing urbs */ | 649 | /* Stop reading/writing urbs */ |
646 | for (i = 0; i < N_IN_URB; i++) | 650 | for (i = 0; i < N_IN_URB; i++) |
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index eea226ae37bd..a3847d6c946e 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c | |||
@@ -79,7 +79,7 @@ static int debug; | |||
79 | #define PL2303_BUF_SIZE 1024 | 79 | #define PL2303_BUF_SIZE 1024 |
80 | #define PL2303_TMP_BUF_SIZE 1024 | 80 | #define PL2303_TMP_BUF_SIZE 1024 |
81 | 81 | ||
82 | struct pl2303_buf { | 82 | struct oti6858_buf { |
83 | unsigned int buf_size; | 83 | unsigned int buf_size; |
84 | char *buf_buf; | 84 | char *buf_buf; |
85 | char *buf_get; | 85 | char *buf_get; |
@@ -161,14 +161,14 @@ static int oti6858_startup(struct usb_serial *serial); | |||
161 | static void oti6858_shutdown(struct usb_serial *serial); | 161 | static void oti6858_shutdown(struct usb_serial *serial); |
162 | 162 | ||
163 | /* functions operating on buffers */ | 163 | /* functions operating on buffers */ |
164 | static struct pl2303_buf *pl2303_buf_alloc(unsigned int size); | 164 | static struct oti6858_buf *oti6858_buf_alloc(unsigned int size); |
165 | static void pl2303_buf_free(struct pl2303_buf *pb); | 165 | static void oti6858_buf_free(struct oti6858_buf *pb); |
166 | static void pl2303_buf_clear(struct pl2303_buf *pb); | 166 | static void oti6858_buf_clear(struct oti6858_buf *pb); |
167 | static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb); | 167 | static unsigned int oti6858_buf_data_avail(struct oti6858_buf *pb); |
168 | static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb); | 168 | static unsigned int oti6858_buf_space_avail(struct oti6858_buf *pb); |
169 | static unsigned int pl2303_buf_put(struct pl2303_buf *pb, const char *buf, | 169 | static unsigned int oti6858_buf_put(struct oti6858_buf *pb, const char *buf, |
170 | unsigned int count); | 170 | unsigned int count); |
171 | static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf, | 171 | static unsigned int oti6858_buf_get(struct oti6858_buf *pb, char *buf, |
172 | unsigned int count); | 172 | unsigned int count); |
173 | 173 | ||
174 | 174 | ||
@@ -203,7 +203,7 @@ static struct usb_serial_driver oti6858_device = { | |||
203 | struct oti6858_private { | 203 | struct oti6858_private { |
204 | spinlock_t lock; | 204 | spinlock_t lock; |
205 | 205 | ||
206 | struct pl2303_buf *buf; | 206 | struct oti6858_buf *buf; |
207 | struct oti6858_control_pkt status; | 207 | struct oti6858_control_pkt status; |
208 | 208 | ||
209 | struct { | 209 | struct { |
@@ -316,7 +316,7 @@ void send_data(struct work_struct *work) | |||
316 | } | 316 | } |
317 | priv->flags.write_urb_in_use = 1; | 317 | priv->flags.write_urb_in_use = 1; |
318 | 318 | ||
319 | count = pl2303_buf_data_avail(priv->buf); | 319 | count = oti6858_buf_data_avail(priv->buf); |
320 | spin_unlock_irqrestore(&priv->lock, flags); | 320 | spin_unlock_irqrestore(&priv->lock, flags); |
321 | if (count > port->bulk_out_size) | 321 | if (count > port->bulk_out_size) |
322 | count = port->bulk_out_size; | 322 | count = port->bulk_out_size; |
@@ -345,7 +345,7 @@ void send_data(struct work_struct *work) | |||
345 | } | 345 | } |
346 | 346 | ||
347 | spin_lock_irqsave(&priv->lock, flags); | 347 | spin_lock_irqsave(&priv->lock, flags); |
348 | pl2303_buf_get(priv->buf, port->write_urb->transfer_buffer, count); | 348 | oti6858_buf_get(priv->buf, port->write_urb->transfer_buffer, count); |
349 | spin_unlock_irqrestore(&priv->lock, flags); | 349 | spin_unlock_irqrestore(&priv->lock, flags); |
350 | 350 | ||
351 | port->write_urb->transfer_buffer_length = count; | 351 | port->write_urb->transfer_buffer_length = count; |
@@ -370,7 +370,7 @@ static int oti6858_startup(struct usb_serial *serial) | |||
370 | priv = kzalloc(sizeof(struct oti6858_private), GFP_KERNEL); | 370 | priv = kzalloc(sizeof(struct oti6858_private), GFP_KERNEL); |
371 | if (!priv) | 371 | if (!priv) |
372 | break; | 372 | break; |
373 | priv->buf = pl2303_buf_alloc(PL2303_BUF_SIZE); | 373 | priv->buf = oti6858_buf_alloc(PL2303_BUF_SIZE); |
374 | if (priv->buf == NULL) { | 374 | if (priv->buf == NULL) { |
375 | kfree(priv); | 375 | kfree(priv); |
376 | break; | 376 | break; |
@@ -391,7 +391,7 @@ static int oti6858_startup(struct usb_serial *serial) | |||
391 | 391 | ||
392 | for (--i; i >= 0; --i) { | 392 | for (--i; i >= 0; --i) { |
393 | priv = usb_get_serial_port_data(serial->port[i]); | 393 | priv = usb_get_serial_port_data(serial->port[i]); |
394 | pl2303_buf_free(priv->buf); | 394 | oti6858_buf_free(priv->buf); |
395 | kfree(priv); | 395 | kfree(priv); |
396 | usb_set_serial_port_data(serial->port[i], NULL); | 396 | usb_set_serial_port_data(serial->port[i], NULL); |
397 | } | 397 | } |
@@ -410,7 +410,7 @@ static int oti6858_write(struct usb_serial_port *port, | |||
410 | return count; | 410 | return count; |
411 | 411 | ||
412 | spin_lock_irqsave(&priv->lock, flags); | 412 | spin_lock_irqsave(&priv->lock, flags); |
413 | count = pl2303_buf_put(priv->buf, buf, count); | 413 | count = oti6858_buf_put(priv->buf, buf, count); |
414 | spin_unlock_irqrestore(&priv->lock, flags); | 414 | spin_unlock_irqrestore(&priv->lock, flags); |
415 | 415 | ||
416 | return count; | 416 | return count; |
@@ -425,7 +425,7 @@ static int oti6858_write_room(struct usb_serial_port *port) | |||
425 | dbg("%s(port = %d)", __FUNCTION__, port->number); | 425 | dbg("%s(port = %d)", __FUNCTION__, port->number); |
426 | 426 | ||
427 | spin_lock_irqsave(&priv->lock, flags); | 427 | spin_lock_irqsave(&priv->lock, flags); |
428 | room = pl2303_buf_space_avail(priv->buf); | 428 | room = oti6858_buf_space_avail(priv->buf); |
429 | spin_unlock_irqrestore(&priv->lock, flags); | 429 | spin_unlock_irqrestore(&priv->lock, flags); |
430 | 430 | ||
431 | return room; | 431 | return room; |
@@ -440,7 +440,7 @@ static int oti6858_chars_in_buffer(struct usb_serial_port *port) | |||
440 | dbg("%s(port = %d)", __FUNCTION__, port->number); | 440 | dbg("%s(port = %d)", __FUNCTION__, port->number); |
441 | 441 | ||
442 | spin_lock_irqsave(&priv->lock, flags); | 442 | spin_lock_irqsave(&priv->lock, flags); |
443 | chars = pl2303_buf_data_avail(priv->buf); | 443 | chars = oti6858_buf_data_avail(priv->buf); |
444 | spin_unlock_irqrestore(&priv->lock, flags); | 444 | spin_unlock_irqrestore(&priv->lock, flags); |
445 | 445 | ||
446 | return chars; | 446 | return chars; |
@@ -458,7 +458,7 @@ static void oti6858_set_termios(struct usb_serial_port *port, | |||
458 | 458 | ||
459 | dbg("%s(port = %d)", __FUNCTION__, port->number); | 459 | dbg("%s(port = %d)", __FUNCTION__, port->number); |
460 | 460 | ||
461 | if ((!port->tty) || (!port->tty->termios)) { | 461 | if (!port->tty || !port->tty->termios) { |
462 | dbg("%s(): no tty structures", __FUNCTION__); | 462 | dbg("%s(): no tty structures", __FUNCTION__); |
463 | return; | 463 | return; |
464 | } | 464 | } |
@@ -468,6 +468,8 @@ static void oti6858_set_termios(struct usb_serial_port *port, | |||
468 | *(port->tty->termios) = tty_std_termios; | 468 | *(port->tty->termios) = tty_std_termios; |
469 | port->tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL; | 469 | port->tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL; |
470 | priv->flags.termios_initialized = 1; | 470 | priv->flags.termios_initialized = 1; |
471 | port->tty->termios->c_ispeed = 38400; | ||
472 | port->tty->termios->c_ospeed = 38400; | ||
471 | } | 473 | } |
472 | spin_unlock_irqrestore(&priv->lock, flags); | 474 | spin_unlock_irqrestore(&priv->lock, flags); |
473 | 475 | ||
@@ -504,19 +506,14 @@ static void oti6858_set_termios(struct usb_serial_port *port, | |||
504 | br = tty_get_baud_rate(port->tty); | 506 | br = tty_get_baud_rate(port->tty); |
505 | if (br == 0) { | 507 | if (br == 0) { |
506 | divisor = 0; | 508 | divisor = 0; |
507 | } else if (br <= OTI6858_MAX_BAUD_RATE) { | 509 | } else { |
508 | int real_br; | 510 | int real_br; |
511 | br = min(br, OTI6858_MAX_BAUD_RATE); | ||
509 | 512 | ||
510 | divisor = (96000000 + 8 * br) / (16 * br); | 513 | divisor = (96000000 + 8 * br) / (16 * br); |
511 | real_br = 96000000 / (16 * divisor); | 514 | real_br = 96000000 / (16 * divisor); |
512 | if ((((real_br - br) * 100 + br - 1) / br) > 2) { | ||
513 | dbg("%s(): baud rate %d is invalid", __FUNCTION__, br); | ||
514 | return; | ||
515 | } | ||
516 | divisor = cpu_to_le16(divisor); | 515 | divisor = cpu_to_le16(divisor); |
517 | } else { | 516 | tty_encode_baud_rate(port->tty, real_br, real_br); |
518 | dbg("%s(): baud rate %d is too high", __FUNCTION__, br); | ||
519 | return; | ||
520 | } | 517 | } |
521 | 518 | ||
522 | frame_fmt &= ~FMT_STOP_BITS_MASK; | 519 | frame_fmt &= ~FMT_STOP_BITS_MASK; |
@@ -650,9 +647,9 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp) | |||
650 | dbg("%s(): entering wait loop", __FUNCTION__); | 647 | dbg("%s(): entering wait loop", __FUNCTION__); |
651 | for (;;) { | 648 | for (;;) { |
652 | set_current_state(TASK_INTERRUPTIBLE); | 649 | set_current_state(TASK_INTERRUPTIBLE); |
653 | if (pl2303_buf_data_avail(priv->buf) == 0 | 650 | if (oti6858_buf_data_avail(priv->buf) == 0 |
654 | || timeout == 0 || signal_pending(current) | 651 | || timeout == 0 || signal_pending(current) |
655 | || !usb_get_intfdata(port->serial->interface)) /* disconnect */ | 652 | || port->serial->disconnected) |
656 | break; | 653 | break; |
657 | spin_unlock_irqrestore(&priv->lock, flags); | 654 | spin_unlock_irqrestore(&priv->lock, flags); |
658 | timeout = schedule_timeout(timeout); | 655 | timeout = schedule_timeout(timeout); |
@@ -663,7 +660,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp) | |||
663 | dbg("%s(): after wait loop", __FUNCTION__); | 660 | dbg("%s(): after wait loop", __FUNCTION__); |
664 | 661 | ||
665 | /* clear out any remaining data in the buffer */ | 662 | /* clear out any remaining data in the buffer */ |
666 | pl2303_buf_clear(priv->buf); | 663 | oti6858_buf_clear(priv->buf); |
667 | spin_unlock_irqrestore(&priv->lock, flags); | 664 | spin_unlock_irqrestore(&priv->lock, flags); |
668 | 665 | ||
669 | /* wait for characters to drain from the device */ | 666 | /* wait for characters to drain from the device */ |
@@ -831,21 +828,6 @@ static int oti6858_ioctl(struct usb_serial_port *port, struct file *file, | |||
831 | return -EFAULT; | 828 | return -EFAULT; |
832 | return oti6858_tiocmset(port, NULL, 0, x); | 829 | return oti6858_tiocmset(port, NULL, 0, x); |
833 | 830 | ||
834 | case TIOCGSERIAL: | ||
835 | if (copy_to_user(user_arg, port->tty->termios, | ||
836 | sizeof(struct ktermios))) { | ||
837 | return -EFAULT; | ||
838 | } | ||
839 | return 0; | ||
840 | |||
841 | case TIOCSSERIAL: | ||
842 | if (copy_from_user(port->tty->termios, user_arg, | ||
843 | sizeof(struct ktermios))) { | ||
844 | return -EFAULT; | ||
845 | } | ||
846 | oti6858_set_termios(port, NULL); | ||
847 | return 0; | ||
848 | |||
849 | case TIOCMIWAIT: | 831 | case TIOCMIWAIT: |
850 | dbg("%s(): TIOCMIWAIT", __FUNCTION__); | 832 | dbg("%s(): TIOCMIWAIT", __FUNCTION__); |
851 | return wait_modem_info(port, arg); | 833 | return wait_modem_info(port, arg); |
@@ -887,7 +869,7 @@ static void oti6858_shutdown(struct usb_serial *serial) | |||
887 | for (i = 0; i < serial->num_ports; ++i) { | 869 | for (i = 0; i < serial->num_ports; ++i) { |
888 | priv = usb_get_serial_port_data(serial->port[i]); | 870 | priv = usb_get_serial_port_data(serial->port[i]); |
889 | if (priv) { | 871 | if (priv) { |
890 | pl2303_buf_free(priv->buf); | 872 | oti6858_buf_free(priv->buf); |
891 | kfree(priv); | 873 | kfree(priv); |
892 | usb_set_serial_port_data(serial->port[i], NULL); | 874 | usb_set_serial_port_data(serial->port[i], NULL); |
893 | } | 875 | } |
@@ -987,7 +969,7 @@ static void oti6858_read_int_callback(struct urb *urb) | |||
987 | 969 | ||
988 | spin_lock_irqsave(&priv->lock, flags); | 970 | spin_lock_irqsave(&priv->lock, flags); |
989 | if (priv->flags.write_urb_in_use == 0 | 971 | if (priv->flags.write_urb_in_use == 0 |
990 | && pl2303_buf_data_avail(priv->buf) != 0) { | 972 | && oti6858_buf_data_avail(priv->buf) != 0) { |
991 | schedule_delayed_work(&priv->delayed_write_work,0); | 973 | schedule_delayed_work(&priv->delayed_write_work,0); |
992 | resubmit = 0; | 974 | resubmit = 0; |
993 | } | 975 | } |
@@ -1015,9 +997,8 @@ static void oti6858_read_bulk_callback(struct urb *urb) | |||
1015 | struct tty_struct *tty; | 997 | struct tty_struct *tty; |
1016 | unsigned char *data = urb->transfer_buffer; | 998 | unsigned char *data = urb->transfer_buffer; |
1017 | unsigned long flags; | 999 | unsigned long flags; |
1018 | int i, result; | ||
1019 | int status = urb->status; | 1000 | int status = urb->status; |
1020 | char tty_flag; | 1001 | int result; |
1021 | 1002 | ||
1022 | dbg("%s(port = %d, status = %d)", | 1003 | dbg("%s(port = %d, status = %d)", |
1023 | __FUNCTION__, port->number, status); | 1004 | __FUNCTION__, port->number, status); |
@@ -1045,27 +1026,9 @@ static void oti6858_read_bulk_callback(struct urb *urb) | |||
1045 | return; | 1026 | return; |
1046 | } | 1027 | } |
1047 | 1028 | ||
1048 | // get tty_flag from status | ||
1049 | tty_flag = TTY_NORMAL; | ||
1050 | |||
1051 | /* FIXME: probably, errors will be signalled using interrupt pipe! */ | ||
1052 | /* | ||
1053 | // break takes precedence over parity, | ||
1054 | // which takes precedence over framing errors | ||
1055 | if (status & UART_BREAK_ERROR ) | ||
1056 | tty_flag = TTY_BREAK; | ||
1057 | else if (status & UART_PARITY_ERROR) | ||
1058 | tty_flag = TTY_PARITY; | ||
1059 | else if (status & UART_FRAME_ERROR) | ||
1060 | tty_flag = TTY_FRAME; | ||
1061 | dbg("%s - tty_flag = %d", __FUNCTION__, tty_flag); | ||
1062 | */ | ||
1063 | |||
1064 | tty = port->tty; | 1029 | tty = port->tty; |
1065 | if (tty != NULL && urb->actual_length > 0) { | 1030 | if (tty != NULL && urb->actual_length > 0) { |
1066 | tty_buffer_request_room(tty, urb->actual_length); | 1031 | tty_insert_flip_string(tty, data, urb->actual_length); |
1067 | for (i = 0; i < urb->actual_length; ++i) | ||
1068 | tty_insert_flip_char(tty, data[i], tty_flag); | ||
1069 | tty_flip_buffer_push(tty); | 1032 | tty_flip_buffer_push(tty); |
1070 | } | 1033 | } |
1071 | 1034 | ||
@@ -1133,18 +1096,18 @@ static void oti6858_write_bulk_callback(struct urb *urb) | |||
1133 | 1096 | ||
1134 | 1097 | ||
1135 | /* | 1098 | /* |
1136 | * pl2303_buf_alloc | 1099 | * oti6858_buf_alloc |
1137 | * | 1100 | * |
1138 | * Allocate a circular buffer and all associated memory. | 1101 | * Allocate a circular buffer and all associated memory. |
1139 | */ | 1102 | */ |
1140 | static struct pl2303_buf *pl2303_buf_alloc(unsigned int size) | 1103 | static struct oti6858_buf *oti6858_buf_alloc(unsigned int size) |
1141 | { | 1104 | { |
1142 | struct pl2303_buf *pb; | 1105 | struct oti6858_buf *pb; |
1143 | 1106 | ||
1144 | if (size == 0) | 1107 | if (size == 0) |
1145 | return NULL; | 1108 | return NULL; |
1146 | 1109 | ||
1147 | pb = kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL); | 1110 | pb = kmalloc(sizeof(struct oti6858_buf), GFP_KERNEL); |
1148 | if (pb == NULL) | 1111 | if (pb == NULL) |
1149 | return NULL; | 1112 | return NULL; |
1150 | 1113 | ||
@@ -1161,11 +1124,11 @@ static struct pl2303_buf *pl2303_buf_alloc(unsigned int size) | |||
1161 | } | 1124 | } |
1162 | 1125 | ||
1163 | /* | 1126 | /* |
1164 | * pl2303_buf_free | 1127 | * oti6858_buf_free |
1165 | * | 1128 | * |
1166 | * Free the buffer and all associated memory. | 1129 | * Free the buffer and all associated memory. |
1167 | */ | 1130 | */ |
1168 | static void pl2303_buf_free(struct pl2303_buf *pb) | 1131 | static void oti6858_buf_free(struct oti6858_buf *pb) |
1169 | { | 1132 | { |
1170 | if (pb) { | 1133 | if (pb) { |
1171 | kfree(pb->buf_buf); | 1134 | kfree(pb->buf_buf); |
@@ -1174,11 +1137,11 @@ static void pl2303_buf_free(struct pl2303_buf *pb) | |||
1174 | } | 1137 | } |
1175 | 1138 | ||
1176 | /* | 1139 | /* |
1177 | * pl2303_buf_clear | 1140 | * oti6858_buf_clear |
1178 | * | 1141 | * |
1179 | * Clear out all data in the circular buffer. | 1142 | * Clear out all data in the circular buffer. |
1180 | */ | 1143 | */ |
1181 | static void pl2303_buf_clear(struct pl2303_buf *pb) | 1144 | static void oti6858_buf_clear(struct oti6858_buf *pb) |
1182 | { | 1145 | { |
1183 | if (pb != NULL) { | 1146 | if (pb != NULL) { |
1184 | /* equivalent to a get of all data available */ | 1147 | /* equivalent to a get of all data available */ |
@@ -1187,12 +1150,12 @@ static void pl2303_buf_clear(struct pl2303_buf *pb) | |||
1187 | } | 1150 | } |
1188 | 1151 | ||
1189 | /* | 1152 | /* |
1190 | * pl2303_buf_data_avail | 1153 | * oti6858_buf_data_avail |
1191 | * | 1154 | * |
1192 | * Return the number of bytes of data available in the circular | 1155 | * Return the number of bytes of data available in the circular |
1193 | * buffer. | 1156 | * buffer. |
1194 | */ | 1157 | */ |
1195 | static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb) | 1158 | static unsigned int oti6858_buf_data_avail(struct oti6858_buf *pb) |
1196 | { | 1159 | { |
1197 | if (pb == NULL) | 1160 | if (pb == NULL) |
1198 | return 0; | 1161 | return 0; |
@@ -1200,12 +1163,12 @@ static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb) | |||
1200 | } | 1163 | } |
1201 | 1164 | ||
1202 | /* | 1165 | /* |
1203 | * pl2303_buf_space_avail | 1166 | * oti6858_buf_space_avail |
1204 | * | 1167 | * |
1205 | * Return the number of bytes of space available in the circular | 1168 | * Return the number of bytes of space available in the circular |
1206 | * buffer. | 1169 | * buffer. |
1207 | */ | 1170 | */ |
1208 | static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb) | 1171 | static unsigned int oti6858_buf_space_avail(struct oti6858_buf *pb) |
1209 | { | 1172 | { |
1210 | if (pb == NULL) | 1173 | if (pb == NULL) |
1211 | return 0; | 1174 | return 0; |
@@ -1213,14 +1176,14 @@ static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb) | |||
1213 | } | 1176 | } |
1214 | 1177 | ||
1215 | /* | 1178 | /* |
1216 | * pl2303_buf_put | 1179 | * oti6858_buf_put |
1217 | * | 1180 | * |
1218 | * Copy data data from a user buffer and put it into the circular buffer. | 1181 | * Copy data data from a user buffer and put it into the circular buffer. |
1219 | * Restrict to the amount of space available. | 1182 | * Restrict to the amount of space available. |
1220 | * | 1183 | * |
1221 | * Return the number of bytes copied. | 1184 | * Return the number of bytes copied. |
1222 | */ | 1185 | */ |
1223 | static unsigned int pl2303_buf_put(struct pl2303_buf *pb, const char *buf, | 1186 | static unsigned int oti6858_buf_put(struct oti6858_buf *pb, const char *buf, |
1224 | unsigned int count) | 1187 | unsigned int count) |
1225 | { | 1188 | { |
1226 | unsigned int len; | 1189 | unsigned int len; |
@@ -1228,7 +1191,7 @@ static unsigned int pl2303_buf_put(struct pl2303_buf *pb, const char *buf, | |||
1228 | if (pb == NULL) | 1191 | if (pb == NULL) |
1229 | return 0; | 1192 | return 0; |
1230 | 1193 | ||
1231 | len = pl2303_buf_space_avail(pb); | 1194 | len = oti6858_buf_space_avail(pb); |
1232 | if (count > len) | 1195 | if (count > len) |
1233 | count = len; | 1196 | count = len; |
1234 | 1197 | ||
@@ -1252,14 +1215,14 @@ static unsigned int pl2303_buf_put(struct pl2303_buf *pb, const char *buf, | |||
1252 | } | 1215 | } |
1253 | 1216 | ||
1254 | /* | 1217 | /* |
1255 | * pl2303_buf_get | 1218 | * oti6858_buf_get |
1256 | * | 1219 | * |
1257 | * Get data from the circular buffer and copy to the given buffer. | 1220 | * Get data from the circular buffer and copy to the given buffer. |
1258 | * Restrict to the amount of data available. | 1221 | * Restrict to the amount of data available. |
1259 | * | 1222 | * |
1260 | * Return the number of bytes copied. | 1223 | * Return the number of bytes copied. |
1261 | */ | 1224 | */ |
1262 | static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf, | 1225 | static unsigned int oti6858_buf_get(struct oti6858_buf *pb, char *buf, |
1263 | unsigned int count) | 1226 | unsigned int count) |
1264 | { | 1227 | { |
1265 | unsigned int len; | 1228 | unsigned int len; |
@@ -1267,7 +1230,7 @@ static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf, | |||
1267 | if (pb == NULL) | 1230 | if (pb == NULL) |
1268 | return 0; | 1231 | return 0; |
1269 | 1232 | ||
1270 | len = pl2303_buf_data_avail(pb); | 1233 | len = oti6858_buf_data_avail(pb); |
1271 | if (count > len) | 1234 | if (count > len) |
1272 | count = len; | 1235 | count = len; |
1273 | 1236 | ||
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 0da1df9c79bf..ae3ec1a64008 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -65,6 +65,7 @@ static struct usb_device_id id_table [] = { | |||
65 | { USB_DEVICE(ITEGNO_VENDOR_ID, ITEGNO_PRODUCT_ID_2080) }, | 65 | { USB_DEVICE(ITEGNO_VENDOR_ID, ITEGNO_PRODUCT_ID_2080) }, |
66 | { USB_DEVICE(MA620_VENDOR_ID, MA620_PRODUCT_ID) }, | 66 | { USB_DEVICE(MA620_VENDOR_ID, MA620_PRODUCT_ID) }, |
67 | { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID) }, | 67 | { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID) }, |
68 | { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, | ||
68 | { USB_DEVICE(TRIPP_VENDOR_ID, TRIPP_PRODUCT_ID) }, | 69 | { USB_DEVICE(TRIPP_VENDOR_ID, TRIPP_PRODUCT_ID) }, |
69 | { USB_DEVICE(RADIOSHACK_VENDOR_ID, RADIOSHACK_PRODUCT_ID) }, | 70 | { USB_DEVICE(RADIOSHACK_VENDOR_ID, RADIOSHACK_PRODUCT_ID) }, |
70 | { USB_DEVICE(DCU10_VENDOR_ID, DCU10_PRODUCT_ID) }, | 71 | { USB_DEVICE(DCU10_VENDOR_ID, DCU10_PRODUCT_ID) }, |
@@ -84,9 +85,10 @@ static struct usb_device_id id_table [] = { | |||
84 | { USB_DEVICE(DATAPILOT_U2_VENDOR_ID, DATAPILOT_U2_PRODUCT_ID) }, | 85 | { USB_DEVICE(DATAPILOT_U2_VENDOR_ID, DATAPILOT_U2_PRODUCT_ID) }, |
85 | { USB_DEVICE(BELKIN_VENDOR_ID, BELKIN_PRODUCT_ID) }, | 86 | { USB_DEVICE(BELKIN_VENDOR_ID, BELKIN_PRODUCT_ID) }, |
86 | { USB_DEVICE(ALCOR_VENDOR_ID, ALCOR_PRODUCT_ID) }, | 87 | { USB_DEVICE(ALCOR_VENDOR_ID, ALCOR_PRODUCT_ID) }, |
87 | { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_ID) }, | ||
88 | { USB_DEVICE(WS002IN_VENDOR_ID, WS002IN_PRODUCT_ID) }, | 88 | { USB_DEVICE(WS002IN_VENDOR_ID, WS002IN_PRODUCT_ID) }, |
89 | { USB_DEVICE(COREGA_VENDOR_ID, COREGA_PRODUCT_ID) }, | 89 | { USB_DEVICE(COREGA_VENDOR_ID, COREGA_PRODUCT_ID) }, |
90 | { USB_DEVICE(HL340_VENDOR_ID, HL340_PRODUCT_ID) }, | ||
91 | { USB_DEVICE(YCCABLE_VENDOR_ID, YCCABLE_PRODUCT_ID) }, | ||
90 | { } /* Terminating entry */ | 92 | { } /* Terminating entry */ |
91 | }; | 93 | }; |
92 | 94 | ||
@@ -97,7 +99,10 @@ static struct usb_driver pl2303_driver = { | |||
97 | .probe = usb_serial_probe, | 99 | .probe = usb_serial_probe, |
98 | .disconnect = usb_serial_disconnect, | 100 | .disconnect = usb_serial_disconnect, |
99 | .id_table = id_table, | 101 | .id_table = id_table, |
102 | .suspend = usb_serial_suspend, | ||
103 | .resume = usb_serial_resume, | ||
100 | .no_dynamic_id = 1, | 104 | .no_dynamic_id = 1, |
105 | .supports_autosuspend = 1, | ||
101 | }; | 106 | }; |
102 | 107 | ||
103 | #define SET_LINE_REQUEST_TYPE 0x21 | 108 | #define SET_LINE_REQUEST_TYPE 0x21 |
@@ -310,12 +315,39 @@ static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf, | |||
310 | return count; | 315 | return count; |
311 | } | 316 | } |
312 | 317 | ||
318 | static int pl2303_vendor_read(__u16 value, __u16 index, | ||
319 | struct usb_serial *serial, unsigned char *buf) | ||
320 | { | ||
321 | int res = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | ||
322 | VENDOR_READ_REQUEST, VENDOR_READ_REQUEST_TYPE, | ||
323 | value, index, buf, 1, 100); | ||
324 | dbg("0x%x:0x%x:0x%x:0x%x %d - %x", VENDOR_READ_REQUEST_TYPE, | ||
325 | VENDOR_READ_REQUEST, value, index, res, buf[0]); | ||
326 | return res; | ||
327 | } | ||
328 | |||
329 | static int pl2303_vendor_write(__u16 value, __u16 index, | ||
330 | struct usb_serial *serial) | ||
331 | { | ||
332 | int res = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | ||
333 | VENDOR_WRITE_REQUEST, VENDOR_WRITE_REQUEST_TYPE, | ||
334 | value, index, NULL, 0, 100); | ||
335 | dbg("0x%x:0x%x:0x%x:0x%x %d", VENDOR_WRITE_REQUEST_TYPE, | ||
336 | VENDOR_WRITE_REQUEST, value, index, res); | ||
337 | return res; | ||
338 | } | ||
339 | |||
313 | static int pl2303_startup(struct usb_serial *serial) | 340 | static int pl2303_startup(struct usb_serial *serial) |
314 | { | 341 | { |
315 | struct pl2303_private *priv; | 342 | struct pl2303_private *priv; |
316 | enum pl2303_type type = type_0; | 343 | enum pl2303_type type = type_0; |
344 | unsigned char *buf; | ||
317 | int i; | 345 | int i; |
318 | 346 | ||
347 | buf = kmalloc(10, GFP_KERNEL); | ||
348 | if (buf == NULL) | ||
349 | return -ENOMEM; | ||
350 | |||
319 | if (serial->dev->descriptor.bDeviceClass == 0x02) | 351 | if (serial->dev->descriptor.bDeviceClass == 0x02) |
320 | type = type_0; | 352 | type = type_0; |
321 | else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40) | 353 | else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40) |
@@ -340,9 +372,27 @@ static int pl2303_startup(struct usb_serial *serial) | |||
340 | priv->type = type; | 372 | priv->type = type; |
341 | usb_set_serial_port_data(serial->port[i], priv); | 373 | usb_set_serial_port_data(serial->port[i], priv); |
342 | } | 374 | } |
375 | |||
376 | pl2303_vendor_read(0x8484, 0, serial, buf); | ||
377 | pl2303_vendor_write(0x0404, 0, serial); | ||
378 | pl2303_vendor_read(0x8484, 0, serial, buf); | ||
379 | pl2303_vendor_read(0x8383, 0, serial, buf); | ||
380 | pl2303_vendor_read(0x8484, 0, serial, buf); | ||
381 | pl2303_vendor_write(0x0404, 1, serial); | ||
382 | pl2303_vendor_read(0x8484, 0, serial, buf); | ||
383 | pl2303_vendor_read(0x8383, 0, serial, buf); | ||
384 | pl2303_vendor_write(0, 1, serial); | ||
385 | pl2303_vendor_write(1, 0, serial); | ||
386 | if (type == HX) | ||
387 | pl2303_vendor_write(2, 0x44, serial); | ||
388 | else | ||
389 | pl2303_vendor_write(2, 0x24, serial); | ||
390 | |||
391 | kfree(buf); | ||
343 | return 0; | 392 | return 0; |
344 | 393 | ||
345 | cleanup: | 394 | cleanup: |
395 | kfree(buf); | ||
346 | for (--i; i>=0; --i) { | 396 | for (--i; i>=0; --i) { |
347 | priv = usb_get_serial_port_data(serial->port[i]); | 397 | priv = usb_get_serial_port_data(serial->port[i]); |
348 | pl2303_buf_free(priv->buf); | 398 | pl2303_buf_free(priv->buf); |
@@ -582,24 +632,12 @@ static void pl2303_set_termios(struct usb_serial_port *port, | |||
582 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); | 632 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); |
583 | 633 | ||
584 | if (cflag & CRTSCTS) { | 634 | if (cflag & CRTSCTS) { |
585 | __u16 index; | ||
586 | if (priv->type == HX) | 635 | if (priv->type == HX) |
587 | index = 0x61; | 636 | pl2303_vendor_write(0x0, 0x61, serial); |
588 | else | 637 | else |
589 | index = 0x41; | 638 | pl2303_vendor_write(0x0, 0x41, serial); |
590 | i = usb_control_msg(serial->dev, | ||
591 | usb_sndctrlpipe(serial->dev, 0), | ||
592 | VENDOR_WRITE_REQUEST, | ||
593 | VENDOR_WRITE_REQUEST_TYPE, | ||
594 | 0x0, index, NULL, 0, 100); | ||
595 | dbg("0x40:0x1:0x0:0x%x %d", index, i); | ||
596 | } else { | 639 | } else { |
597 | i = usb_control_msg(serial->dev, | 640 | pl2303_vendor_write(0x0, 0x0, serial); |
598 | usb_sndctrlpipe(serial->dev, 0), | ||
599 | VENDOR_WRITE_REQUEST, | ||
600 | VENDOR_WRITE_REQUEST_TYPE, | ||
601 | 0x0, 0x0, NULL, 0, 100); | ||
602 | dbg ("0x40:0x1:0x0:0x0 %d", i); | ||
603 | } | 641 | } |
604 | 642 | ||
605 | /* FIXME: Need to read back resulting baud rate */ | 643 | /* FIXME: Need to read back resulting baud rate */ |
@@ -629,7 +667,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp) | |||
629 | set_current_state(TASK_INTERRUPTIBLE); | 667 | set_current_state(TASK_INTERRUPTIBLE); |
630 | if (pl2303_buf_data_avail(priv->buf) == 0 || | 668 | if (pl2303_buf_data_avail(priv->buf) == 0 || |
631 | timeout == 0 || signal_pending(current) || | 669 | timeout == 0 || signal_pending(current) || |
632 | !usb_get_intfdata(port->serial->interface)) /* disconnect */ | 670 | port->serial->disconnected) |
633 | break; | 671 | break; |
634 | spin_unlock_irqrestore(&priv->lock, flags); | 672 | spin_unlock_irqrestore(&priv->lock, flags); |
635 | timeout = schedule_timeout(timeout); | 673 | timeout = schedule_timeout(timeout); |
@@ -678,7 +716,6 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp) | |||
678 | struct ktermios tmp_termios; | 716 | struct ktermios tmp_termios; |
679 | struct usb_serial *serial = port->serial; | 717 | struct usb_serial *serial = port->serial; |
680 | struct pl2303_private *priv = usb_get_serial_port_data(port); | 718 | struct pl2303_private *priv = usb_get_serial_port_data(port); |
681 | unsigned char *buf; | ||
682 | int result; | 719 | int result; |
683 | 720 | ||
684 | dbg("%s - port %d", __FUNCTION__, port->number); | 721 | dbg("%s - port %d", __FUNCTION__, port->number); |
@@ -686,45 +723,12 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp) | |||
686 | if (priv->type != HX) { | 723 | if (priv->type != HX) { |
687 | usb_clear_halt(serial->dev, port->write_urb->pipe); | 724 | usb_clear_halt(serial->dev, port->write_urb->pipe); |
688 | usb_clear_halt(serial->dev, port->read_urb->pipe); | 725 | usb_clear_halt(serial->dev, port->read_urb->pipe); |
689 | } | ||
690 | |||
691 | buf = kmalloc(10, GFP_KERNEL); | ||
692 | if (buf==NULL) | ||
693 | return -ENOMEM; | ||
694 | |||
695 | #define FISH(a,b,c,d) \ | ||
696 | result=usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev,0), \ | ||
697 | b, a, c, d, buf, 1, 100); \ | ||
698 | dbg("0x%x:0x%x:0x%x:0x%x %d - %x",a,b,c,d,result,buf[0]); | ||
699 | |||
700 | #define SOUP(a,b,c,d) \ | ||
701 | result=usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev,0), \ | ||
702 | b, a, c, d, NULL, 0, 100); \ | ||
703 | dbg("0x%x:0x%x:0x%x:0x%x %d",a,b,c,d,result); | ||
704 | |||
705 | FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0); | ||
706 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0x0404, 0); | ||
707 | FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0); | ||
708 | FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8383, 0); | ||
709 | FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0); | ||
710 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0x0404, 1); | ||
711 | FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0); | ||
712 | FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8383, 0); | ||
713 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0, 1); | ||
714 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 1, 0); | ||
715 | |||
716 | if (priv->type == HX) { | ||
717 | /* HX chip */ | ||
718 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 2, 0x44); | ||
719 | /* reset upstream data pipes */ | ||
720 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 8, 0); | ||
721 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 9, 0); | ||
722 | } else { | 726 | } else { |
723 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 2, 0x24); | 727 | /* reset upstream data pipes */ |
728 | pl2303_vendor_write(8, 0, serial); | ||
729 | pl2303_vendor_write(9, 0, serial); | ||
724 | } | 730 | } |
725 | 731 | ||
726 | kfree(buf); | ||
727 | |||
728 | /* Setup termios */ | 732 | /* Setup termios */ |
729 | if (port->tty) { | 733 | if (port->tty) { |
730 | pl2303_set_termios(port, &tmp_termios); | 734 | pl2303_set_termios(port, &tmp_termios); |
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h index d31f5d299989..237a41f6638a 100644 --- a/drivers/usb/serial/pl2303.h +++ b/drivers/usb/serial/pl2303.h | |||
@@ -35,6 +35,7 @@ | |||
35 | 35 | ||
36 | #define RATOC_VENDOR_ID 0x0584 | 36 | #define RATOC_VENDOR_ID 0x0584 |
37 | #define RATOC_PRODUCT_ID 0xb000 | 37 | #define RATOC_PRODUCT_ID 0xb000 |
38 | #define RATOC_PRODUCT_ID_USB60F 0xb020 | ||
38 | 39 | ||
39 | #define TRIPP_VENDOR_ID 0x2478 | 40 | #define TRIPP_VENDOR_ID 0x2478 |
40 | #define TRIPP_PRODUCT_ID 0x2008 | 41 | #define TRIPP_PRODUCT_ID 0x2008 |
@@ -96,10 +97,6 @@ | |||
96 | #define ALCOR_VENDOR_ID 0x058F | 97 | #define ALCOR_VENDOR_ID 0x058F |
97 | #define ALCOR_PRODUCT_ID 0x9720 | 98 | #define ALCOR_PRODUCT_ID 0x9720 |
98 | 99 | ||
99 | /* Huawei E620 UMTS/HSDPA card (ID: 12d1:1001) */ | ||
100 | #define HUAWEI_VENDOR_ID 0x12d1 | ||
101 | #define HUAWEI_PRODUCT_ID 0x1001 | ||
102 | |||
103 | /* Willcom WS002IN Data Driver (by NetIndex Inc.) */ | 100 | /* Willcom WS002IN Data Driver (by NetIndex Inc.) */ |
104 | #define WS002IN_VENDOR_ID 0x11f6 | 101 | #define WS002IN_VENDOR_ID 0x11f6 |
105 | #define WS002IN_PRODUCT_ID 0x2001 | 102 | #define WS002IN_PRODUCT_ID 0x2001 |
@@ -107,3 +104,11 @@ | |||
107 | /* Corega CG-USBRS232R Serial Adapter */ | 104 | /* Corega CG-USBRS232R Serial Adapter */ |
108 | #define COREGA_VENDOR_ID 0x07aa | 105 | #define COREGA_VENDOR_ID 0x07aa |
109 | #define COREGA_PRODUCT_ID 0x002a | 106 | #define COREGA_PRODUCT_ID 0x002a |
107 | |||
108 | /* HL HL-340 (ID: 4348:5523) */ | ||
109 | #define HL340_VENDOR_ID 0x4348 | ||
110 | #define HL340_PRODUCT_ID 0x5523 | ||
111 | |||
112 | /* Y.C. Cable U.S.A., Inc - USB to RS-232 */ | ||
113 | #define YCCABLE_VENDOR_ID 0x05ad | ||
114 | #define YCCABLE_PRODUCT_ID 0x0fba | ||
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index c295d0495f96..4c925e3e8a63 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | USB Driver for Sierra Wireless | 2 | USB Driver for Sierra Wireless |
3 | 3 | ||
4 | Copyright (C) 2006, 2007 Kevin Lloyd <linux@sierrawireless.com> | 4 | Copyright (C) 2006, 2007, 2008 Kevin Lloyd <linux@sierrawireless.com> |
5 | 5 | ||
6 | IMPORTANT DISCLAIMER: This driver is not commercially supported by | 6 | IMPORTANT DISCLAIMER: This driver is not commercially supported by |
7 | Sierra Wireless. Use at your own risk. | 7 | Sierra Wireless. Use at your own risk. |
@@ -14,7 +14,7 @@ | |||
14 | Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> | 14 | Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #define DRIVER_VERSION "v.1.2.5b" | 17 | #define DRIVER_VERSION "v.1.2.7" |
18 | #define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>" | 18 | #define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>" |
19 | #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" | 19 | #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" |
20 | 20 | ||
@@ -26,10 +26,12 @@ | |||
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/usb.h> | 27 | #include <linux/usb.h> |
28 | #include <linux/usb/serial.h> | 28 | #include <linux/usb/serial.h> |
29 | #include <linux/usb/ch9.h> | ||
29 | 30 | ||
31 | #define SWIMS_USB_REQUEST_SetPower 0x00 | ||
32 | #define SWIMS_USB_REQUEST_SetNmea 0x07 | ||
30 | #define SWIMS_USB_REQUEST_SetMode 0x0B | 33 | #define SWIMS_USB_REQUEST_SetMode 0x0B |
31 | #define SWIMS_USB_REQUEST_TYPE_SetMode 0x40 | 34 | #define SWIMS_USB_REQUEST_TYPE_VSC_SET 0x40 |
32 | #define SWIMS_USB_INDEX_SetMode 0x0000 | ||
33 | #define SWIMS_SET_MODE_Modem 0x0001 | 35 | #define SWIMS_SET_MODE_Modem 0x0001 |
34 | 36 | ||
35 | /* per port private data */ | 37 | /* per port private data */ |
@@ -38,6 +40,8 @@ | |||
38 | #define IN_BUFLEN 4096 | 40 | #define IN_BUFLEN 4096 |
39 | 41 | ||
40 | static int debug; | 42 | static int debug; |
43 | static int nmea; | ||
44 | static int truinstall = 1; | ||
41 | 45 | ||
42 | enum devicetype { | 46 | enum devicetype { |
43 | DEVICE_3_PORT = 0, | 47 | DEVICE_3_PORT = 0, |
@@ -50,48 +54,96 @@ static int sierra_set_power_state(struct usb_device *udev, __u16 swiState) | |||
50 | int result; | 54 | int result; |
51 | dev_dbg(&udev->dev, "%s", "SET POWER STATE\n"); | 55 | dev_dbg(&udev->dev, "%s", "SET POWER STATE\n"); |
52 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | 56 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
53 | 0x00, /* __u8 request */ | 57 | SWIMS_USB_REQUEST_SetPower, /* __u8 request */ |
54 | 0x40, /* __u8 request type */ | 58 | SWIMS_USB_REQUEST_TYPE_VSC_SET, /* __u8 request type */ |
55 | swiState, /* __u16 value */ | 59 | swiState, /* __u16 value */ |
56 | 0, /* __u16 index */ | 60 | 0, /* __u16 index */ |
57 | NULL, /* void *data */ | 61 | NULL, /* void *data */ |
58 | 0, /* __u16 size */ | 62 | 0, /* __u16 size */ |
59 | USB_CTRL_SET_TIMEOUT); /* int timeout */ | 63 | USB_CTRL_SET_TIMEOUT); /* int timeout */ |
60 | return result; | 64 | return result; |
61 | } | 65 | } |
62 | 66 | ||
63 | static int sierra_set_ms_mode(struct usb_device *udev, __u16 eSocMode) | 67 | static int sierra_set_ms_mode(struct usb_device *udev, __u16 eSWocMode) |
64 | { | 68 | { |
65 | int result; | 69 | int result; |
66 | dev_dbg(&udev->dev, "%s", "DEVICE MODE SWITCH\n"); | 70 | dev_dbg(&udev->dev, "%s", "DEVICE MODE SWITCH\n"); |
67 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | 71 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
68 | SWIMS_USB_REQUEST_SetMode, /* __u8 request */ | 72 | SWIMS_USB_REQUEST_SetMode, /* __u8 request */ |
69 | SWIMS_USB_REQUEST_TYPE_SetMode, /* __u8 request type */ | 73 | SWIMS_USB_REQUEST_TYPE_VSC_SET, /* __u8 request type */ |
70 | eSocMode, /* __u16 value */ | 74 | eSWocMode, /* __u16 value */ |
71 | SWIMS_USB_INDEX_SetMode, /* __u16 index */ | 75 | 0x0000, /* __u16 index */ |
72 | NULL, /* void *data */ | 76 | NULL, /* void *data */ |
73 | 0, /* __u16 size */ | 77 | 0, /* __u16 size */ |
74 | USB_CTRL_SET_TIMEOUT); /* int timeout */ | 78 | USB_CTRL_SET_TIMEOUT); /* int timeout */ |
75 | return result; | 79 | return result; |
76 | } | 80 | } |
77 | 81 | ||
78 | static int sierra_probe(struct usb_interface *iface, | 82 | static int sierra_vsc_set_nmea(struct usb_device *udev, __u16 enable) |
79 | const struct usb_device_id *id) | 83 | { |
84 | int result; | ||
85 | dev_dbg(&udev->dev, "%s", "NMEA Enable sent\n"); | ||
86 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
87 | SWIMS_USB_REQUEST_SetNmea, /* __u8 request */ | ||
88 | SWIMS_USB_REQUEST_TYPE_VSC_SET, /* __u8 request type */ | ||
89 | enable, /* __u16 value */ | ||
90 | 0x0000, /* __u16 index */ | ||
91 | NULL, /* void *data */ | ||
92 | 0, /* __u16 size */ | ||
93 | USB_CTRL_SET_TIMEOUT); /* int timeout */ | ||
94 | return result; | ||
95 | } | ||
96 | |||
97 | static int sierra_calc_num_ports(struct usb_serial *serial) | ||
80 | { | 98 | { |
81 | int result; | 99 | int result; |
100 | int *num_ports = usb_get_serial_data(serial); | ||
101 | |||
102 | result = *num_ports; | ||
103 | |||
104 | if (result) { | ||
105 | kfree(num_ports); | ||
106 | usb_set_serial_data(serial, NULL); | ||
107 | } | ||
108 | |||
109 | return result; | ||
110 | } | ||
111 | |||
112 | static int sierra_probe(struct usb_serial *serial, | ||
113 | const struct usb_device_id *id) | ||
114 | { | ||
115 | int result = 0; | ||
82 | struct usb_device *udev; | 116 | struct usb_device *udev; |
117 | int *num_ports; | ||
118 | u8 ifnum; | ||
119 | |||
120 | num_ports = kmalloc(sizeof(*num_ports), GFP_KERNEL); | ||
121 | if (!num_ports) | ||
122 | return -ENOMEM; | ||
83 | 123 | ||
84 | udev = usb_get_dev(interface_to_usbdev(iface)); | 124 | ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber; |
125 | udev = serial->dev; | ||
85 | 126 | ||
86 | /* Check if in installer mode */ | 127 | /* Check if in installer mode */ |
87 | if (id->driver_info == DEVICE_INSTALLER) { | 128 | if (truinstall && id->driver_info == DEVICE_INSTALLER) { |
88 | dev_dbg(&udev->dev, "%s", "FOUND DEVICE(SW)\n"); | 129 | dev_dbg(&udev->dev, "%s", "FOUND TRU-INSTALL DEVICE(SW)\n"); |
89 | result = sierra_set_ms_mode(udev, SWIMS_SET_MODE_Modem); | 130 | result = sierra_set_ms_mode(udev, SWIMS_SET_MODE_Modem); |
90 | /*We do not want to bind to the device when in installer mode*/ | 131 | /* Don't bind to the device when in installer mode */ |
132 | kfree(num_ports); | ||
91 | return -EIO; | 133 | return -EIO; |
92 | } | 134 | } else if (id->driver_info == DEVICE_1_PORT) |
135 | *num_ports = 1; | ||
136 | else if (ifnum == 0x99) | ||
137 | *num_ports = 0; | ||
138 | else | ||
139 | *num_ports = 3; | ||
140 | /* | ||
141 | * save off our num_ports info so that we can use it in the | ||
142 | * calc_num_ports callback | ||
143 | */ | ||
144 | usb_set_serial_data(serial, (void *)num_ports); | ||
93 | 145 | ||
94 | return usb_serial_probe(iface, id); | 146 | return result; |
95 | } | 147 | } |
96 | 148 | ||
97 | static struct usb_device_id id_table [] = { | 149 | static struct usb_device_id id_table [] = { |
@@ -104,6 +156,7 @@ static struct usb_device_id id_table [] = { | |||
104 | { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ | 156 | { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ |
105 | { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ | 157 | { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ |
106 | { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */ | 158 | { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */ |
159 | { USB_DEVICE(0x1199, 0x0023) }, /* Sierra Wireless AirCard */ | ||
107 | 160 | ||
108 | { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ | 161 | { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ |
109 | { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ | 162 | { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ |
@@ -117,56 +170,29 @@ static struct usb_device_id id_table [] = { | |||
117 | { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */ | 170 | { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */ |
118 | { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */ | 171 | { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */ |
119 | { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881 E */ | 172 | { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881 E */ |
173 | { USB_DEVICE(0x1199, 0x6855) }, /* Sierra Wireless AirCard 880 U */ | ||
174 | { USB_DEVICE(0x1199, 0x6856) }, /* Sierra Wireless AirCard 881 U */ | ||
175 | |||
176 | { USB_DEVICE(0x1199, 0x6468) }, /* Sierra Wireless MP3G - EVDO */ | ||
177 | { USB_DEVICE(0x1199, 0x6469) }, /* Sierra Wireless MP3G - UMTS/HSPA */ | ||
120 | 178 | ||
121 | { USB_DEVICE(0x1199, 0x0112), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 580 */ | 179 | { USB_DEVICE(0x1199, 0x0112), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 580 */ |
122 | { USB_DEVICE(0x0F3D, 0x0112), .driver_info = DEVICE_1_PORT }, /* Airprime/Sierra PC 5220 */ | 180 | { USB_DEVICE(0x0F3D, 0x0112), .driver_info = DEVICE_1_PORT }, /* Airprime/Sierra PC 5220 */ |
181 | { USB_DEVICE(0x05C6, 0x6613), .driver_info = DEVICE_1_PORT }, /* Onda H600/ZTE MF330 */ | ||
123 | 182 | ||
124 | { USB_DEVICE(0x1199, 0x0FFF), .driver_info = DEVICE_INSTALLER}, | 183 | { USB_DEVICE(0x1199, 0x0FFF), .driver_info = DEVICE_INSTALLER}, |
125 | { } | 184 | { } |
126 | }; | 185 | }; |
127 | MODULE_DEVICE_TABLE(usb, id_table); | 186 | MODULE_DEVICE_TABLE(usb, id_table); |
128 | 187 | ||
129 | static struct usb_device_id id_table_1port [] = { | ||
130 | { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */ | ||
131 | { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */ | ||
132 | { } | ||
133 | }; | ||
134 | |||
135 | static struct usb_device_id id_table_3port [] = { | ||
136 | { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ | ||
137 | { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ | ||
138 | { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */ | ||
139 | { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ | ||
140 | { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ | ||
141 | { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */ | ||
142 | { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ | ||
143 | { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ | ||
144 | { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U*/ | ||
145 | |||
146 | { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ | ||
147 | { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ | ||
148 | { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ | ||
149 | { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */ | ||
150 | { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 (Thinkpad internal) */ | ||
151 | { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ | ||
152 | { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780*/ | ||
153 | { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781*/ | ||
154 | { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */ | ||
155 | { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */ | ||
156 | { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880E */ | ||
157 | { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881E */ | ||
158 | { } | ||
159 | }; | ||
160 | |||
161 | static struct usb_driver sierra_driver = { | 188 | static struct usb_driver sierra_driver = { |
162 | .name = "sierra", | 189 | .name = "sierra", |
163 | .probe = sierra_probe, | 190 | .probe = usb_serial_probe, |
164 | .disconnect = usb_serial_disconnect, | 191 | .disconnect = usb_serial_disconnect, |
165 | .id_table = id_table, | 192 | .id_table = id_table, |
166 | .no_dynamic_id = 1, | 193 | .no_dynamic_id = 1, |
167 | }; | 194 | }; |
168 | 195 | ||
169 | |||
170 | struct sierra_port_private { | 196 | struct sierra_port_private { |
171 | spinlock_t lock; /* lock the structure */ | 197 | spinlock_t lock; /* lock the structure */ |
172 | int outstanding_urbs; /* number of out urbs in flight */ | 198 | int outstanding_urbs; /* number of out urbs in flight */ |
@@ -188,6 +214,7 @@ static int sierra_send_setup(struct usb_serial_port *port) | |||
188 | { | 214 | { |
189 | struct usb_serial *serial = port->serial; | 215 | struct usb_serial *serial = port->serial; |
190 | struct sierra_port_private *portdata; | 216 | struct sierra_port_private *portdata; |
217 | __u16 interface = 0; | ||
191 | 218 | ||
192 | dbg("%s", __FUNCTION__); | 219 | dbg("%s", __FUNCTION__); |
193 | 220 | ||
@@ -200,9 +227,18 @@ static int sierra_send_setup(struct usb_serial_port *port) | |||
200 | if (portdata->rts_state) | 227 | if (portdata->rts_state) |
201 | val |= 0x02; | 228 | val |= 0x02; |
202 | 229 | ||
230 | /* Determine which port is targeted */ | ||
231 | if (port->bulk_out_endpointAddress == 2) | ||
232 | interface = 0; | ||
233 | else if (port->bulk_out_endpointAddress == 4) | ||
234 | interface = 1; | ||
235 | else if (port->bulk_out_endpointAddress == 5) | ||
236 | interface = 2; | ||
237 | |||
203 | return usb_control_msg(serial->dev, | 238 | return usb_control_msg(serial->dev, |
204 | usb_rcvctrlpipe(serial->dev, 0), | 239 | usb_rcvctrlpipe(serial->dev, 0), |
205 | 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT); | 240 | 0x22, 0x21, val, interface, |
241 | NULL, 0, USB_CTRL_SET_TIMEOUT); | ||
206 | } | 242 | } |
207 | 243 | ||
208 | return 0; | 244 | return 0; |
@@ -561,7 +597,10 @@ static void sierra_close(struct usb_serial_port *port, struct file *filp) | |||
561 | portdata->dtr_state = 0; | 597 | portdata->dtr_state = 0; |
562 | 598 | ||
563 | if (serial->dev) { | 599 | if (serial->dev) { |
564 | sierra_send_setup(port); | 600 | mutex_lock(&serial->disc_mutex); |
601 | if (!serial->disconnected) | ||
602 | sierra_send_setup(port); | ||
603 | mutex_unlock(&serial->disc_mutex); | ||
565 | 604 | ||
566 | /* Stop reading/writing urbs */ | 605 | /* Stop reading/writing urbs */ |
567 | for (i = 0; i < N_IN_URB; i++) | 606 | for (i = 0; i < N_IN_URB; i++) |
@@ -583,9 +622,13 @@ static int sierra_startup(struct usb_serial *serial) | |||
583 | 622 | ||
584 | dbg("%s", __FUNCTION__); | 623 | dbg("%s", __FUNCTION__); |
585 | 624 | ||
586 | /*Set Device mode to D0 */ | 625 | /* Set Device mode to D0 */ |
587 | sierra_set_power_state(serial->dev, 0x0000); | 626 | sierra_set_power_state(serial->dev, 0x0000); |
588 | 627 | ||
628 | /* Check NMEA and set */ | ||
629 | if (nmea) | ||
630 | sierra_vsc_set_nmea(serial->dev, 1); | ||
631 | |||
589 | /* Now setup per port private data */ | 632 | /* Now setup per port private data */ |
590 | for (i = 0; i < serial->num_ports; i++) { | 633 | for (i = 0; i < serial->num_ports; i++) { |
591 | port = serial->port[i]; | 634 | port = serial->port[i]; |
@@ -646,47 +689,19 @@ static void sierra_shutdown(struct usb_serial *serial) | |||
646 | } | 689 | } |
647 | } | 690 | } |
648 | 691 | ||
649 | static struct usb_serial_driver sierra_1port_device = { | 692 | static struct usb_serial_driver sierra_device = { |
650 | .driver = { | 693 | .driver = { |
651 | .owner = THIS_MODULE, | 694 | .owner = THIS_MODULE, |
652 | .name = "sierra1", | 695 | .name = "sierra1", |
653 | }, | 696 | }, |
654 | .description = "Sierra USB modem (1 port)", | 697 | .description = "Sierra USB modem", |
655 | .id_table = id_table_1port, | 698 | .id_table = id_table, |
656 | .usb_driver = &sierra_driver, | ||
657 | .num_interrupt_in = NUM_DONT_CARE, | ||
658 | .num_bulk_in = 1, | ||
659 | .num_bulk_out = 1, | ||
660 | .num_ports = 1, | ||
661 | .open = sierra_open, | ||
662 | .close = sierra_close, | ||
663 | .write = sierra_write, | ||
664 | .write_room = sierra_write_room, | ||
665 | .chars_in_buffer = sierra_chars_in_buffer, | ||
666 | .throttle = sierra_rx_throttle, | ||
667 | .unthrottle = sierra_rx_unthrottle, | ||
668 | .ioctl = sierra_ioctl, | ||
669 | .set_termios = sierra_set_termios, | ||
670 | .break_ctl = sierra_break_ctl, | ||
671 | .tiocmget = sierra_tiocmget, | ||
672 | .tiocmset = sierra_tiocmset, | ||
673 | .attach = sierra_startup, | ||
674 | .shutdown = sierra_shutdown, | ||
675 | .read_int_callback = sierra_instat_callback, | ||
676 | }; | ||
677 | |||
678 | static struct usb_serial_driver sierra_3port_device = { | ||
679 | .driver = { | ||
680 | .owner = THIS_MODULE, | ||
681 | .name = "sierra3", | ||
682 | }, | ||
683 | .description = "Sierra USB modem (3 port)", | ||
684 | .id_table = id_table_3port, | ||
685 | .usb_driver = &sierra_driver, | 699 | .usb_driver = &sierra_driver, |
686 | .num_interrupt_in = NUM_DONT_CARE, | 700 | .num_interrupt_in = NUM_DONT_CARE, |
687 | .num_bulk_in = 3, | 701 | .num_bulk_in = NUM_DONT_CARE, |
688 | .num_bulk_out = 3, | 702 | .num_bulk_out = NUM_DONT_CARE, |
689 | .num_ports = 3, | 703 | .calc_num_ports = sierra_calc_num_ports, |
704 | .probe = sierra_probe, | ||
690 | .open = sierra_open, | 705 | .open = sierra_open, |
691 | .close = sierra_close, | 706 | .close = sierra_close, |
692 | .write = sierra_write, | 707 | .write = sierra_write, |
@@ -708,12 +723,9 @@ static struct usb_serial_driver sierra_3port_device = { | |||
708 | static int __init sierra_init(void) | 723 | static int __init sierra_init(void) |
709 | { | 724 | { |
710 | int retval; | 725 | int retval; |
711 | retval = usb_serial_register(&sierra_1port_device); | 726 | retval = usb_serial_register(&sierra_device); |
712 | if (retval) | ||
713 | goto failed_1port_device_register; | ||
714 | retval = usb_serial_register(&sierra_3port_device); | ||
715 | if (retval) | 727 | if (retval) |
716 | goto failed_3port_device_register; | 728 | goto failed_device_register; |
717 | 729 | ||
718 | 730 | ||
719 | retval = usb_register(&sierra_driver); | 731 | retval = usb_register(&sierra_driver); |
@@ -725,18 +737,15 @@ static int __init sierra_init(void) | |||
725 | return 0; | 737 | return 0; |
726 | 738 | ||
727 | failed_driver_register: | 739 | failed_driver_register: |
728 | usb_serial_deregister(&sierra_3port_device); | 740 | usb_serial_deregister(&sierra_device); |
729 | failed_3port_device_register: | 741 | failed_device_register: |
730 | usb_serial_deregister(&sierra_1port_device); | ||
731 | failed_1port_device_register: | ||
732 | return retval; | 742 | return retval; |
733 | } | 743 | } |
734 | 744 | ||
735 | static void __exit sierra_exit(void) | 745 | static void __exit sierra_exit(void) |
736 | { | 746 | { |
737 | usb_deregister (&sierra_driver); | 747 | usb_deregister (&sierra_driver); |
738 | usb_serial_deregister(&sierra_1port_device); | 748 | usb_serial_deregister(&sierra_device); |
739 | usb_serial_deregister(&sierra_3port_device); | ||
740 | } | 749 | } |
741 | 750 | ||
742 | module_init(sierra_init); | 751 | module_init(sierra_init); |
@@ -747,6 +756,12 @@ MODULE_DESCRIPTION(DRIVER_DESC); | |||
747 | MODULE_VERSION(DRIVER_VERSION); | 756 | MODULE_VERSION(DRIVER_VERSION); |
748 | MODULE_LICENSE("GPL"); | 757 | MODULE_LICENSE("GPL"); |
749 | 758 | ||
759 | module_param(truinstall, bool, 0); | ||
760 | MODULE_PARM_DESC(truinstall, "TRU-Install support"); | ||
761 | |||
762 | module_param(nmea, bool, 0); | ||
763 | MODULE_PARM_DESC(nmea, "NMEA streaming"); | ||
764 | |||
750 | #ifdef CONFIG_USB_DEBUG | 765 | #ifdef CONFIG_USB_DEBUG |
751 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 766 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
752 | MODULE_PARM_DESC(debug, "Debug messages"); | 767 | MODULE_PARM_DESC(debug, "Debug messages"); |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 1f0149495fb4..b517f93352ec 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -80,6 +80,7 @@ | |||
80 | #include <linux/ioctl.h> | 80 | #include <linux/ioctl.h> |
81 | #include <linux/serial.h> | 81 | #include <linux/serial.h> |
82 | #include <linux/circ_buf.h> | 82 | #include <linux/circ_buf.h> |
83 | #include <linux/mutex.h> | ||
83 | #include <asm/uaccess.h> | 84 | #include <asm/uaccess.h> |
84 | #include <asm/semaphore.h> | 85 | #include <asm/semaphore.h> |
85 | #include <linux/usb.h> | 86 | #include <linux/usb.h> |
@@ -139,7 +140,7 @@ struct ti_port { | |||
139 | }; | 140 | }; |
140 | 141 | ||
141 | struct ti_device { | 142 | struct ti_device { |
142 | struct semaphore td_open_close_sem; | 143 | struct mutex td_open_close_lock; |
143 | int td_open_port_count; | 144 | int td_open_port_count; |
144 | struct usb_serial *td_serial; | 145 | struct usb_serial *td_serial; |
145 | int td_is_3410; | 146 | int td_is_3410; |
@@ -424,7 +425,7 @@ static int ti_startup(struct usb_serial *serial) | |||
424 | dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); | 425 | dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); |
425 | return -ENOMEM; | 426 | return -ENOMEM; |
426 | } | 427 | } |
427 | sema_init(&tdev->td_open_close_sem, 1); | 428 | mutex_init(&tdev->td_open_close_lock); |
428 | tdev->td_serial = serial; | 429 | tdev->td_serial = serial; |
429 | usb_set_serial_data(serial, tdev); | 430 | usb_set_serial_data(serial, tdev); |
430 | 431 | ||
@@ -547,7 +548,7 @@ static int ti_open(struct usb_serial_port *port, struct file *file) | |||
547 | tdev = tport->tp_tdev; | 548 | tdev = tport->tp_tdev; |
548 | 549 | ||
549 | /* only one open on any port on a device at a time */ | 550 | /* only one open on any port on a device at a time */ |
550 | if (down_interruptible(&tdev->td_open_close_sem)) | 551 | if (mutex_lock_interruptible(&tdev->td_open_close_lock)) |
551 | return -ERESTARTSYS; | 552 | return -ERESTARTSYS; |
552 | 553 | ||
553 | if (port->tty) | 554 | if (port->tty) |
@@ -568,7 +569,7 @@ static int ti_open(struct usb_serial_port *port, struct file *file) | |||
568 | if (!urb) { | 569 | if (!urb) { |
569 | dev_err(&port->dev, "%s - no interrupt urb\n", __FUNCTION__); | 570 | dev_err(&port->dev, "%s - no interrupt urb\n", __FUNCTION__); |
570 | status = -EINVAL; | 571 | status = -EINVAL; |
571 | goto up_sem; | 572 | goto release_lock; |
572 | } | 573 | } |
573 | urb->complete = ti_interrupt_callback; | 574 | urb->complete = ti_interrupt_callback; |
574 | urb->context = tdev; | 575 | urb->context = tdev; |
@@ -576,11 +577,11 @@ static int ti_open(struct usb_serial_port *port, struct file *file) | |||
576 | status = usb_submit_urb(urb, GFP_KERNEL); | 577 | status = usb_submit_urb(urb, GFP_KERNEL); |
577 | if (status) { | 578 | if (status) { |
578 | dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __FUNCTION__, status); | 579 | dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __FUNCTION__, status); |
579 | goto up_sem; | 580 | goto release_lock; |
580 | } | 581 | } |
581 | } | 582 | } |
582 | 583 | ||
583 | ti_set_termios(port, NULL); | 584 | ti_set_termios(port, port->tty->termios); |
584 | 585 | ||
585 | dbg("%s - sending TI_OPEN_PORT", __FUNCTION__); | 586 | dbg("%s - sending TI_OPEN_PORT", __FUNCTION__); |
586 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, | 587 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, |
@@ -617,7 +618,7 @@ static int ti_open(struct usb_serial_port *port, struct file *file) | |||
617 | usb_clear_halt(dev, port->write_urb->pipe); | 618 | usb_clear_halt(dev, port->write_urb->pipe); |
618 | usb_clear_halt(dev, port->read_urb->pipe); | 619 | usb_clear_halt(dev, port->read_urb->pipe); |
619 | 620 | ||
620 | ti_set_termios(port, NULL); | 621 | ti_set_termios(port, port->tty->termios); |
621 | 622 | ||
622 | dbg("%s - sending TI_OPEN_PORT (2)", __FUNCTION__); | 623 | dbg("%s - sending TI_OPEN_PORT (2)", __FUNCTION__); |
623 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, | 624 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, |
@@ -656,13 +657,13 @@ static int ti_open(struct usb_serial_port *port, struct file *file) | |||
656 | tport->tp_is_open = 1; | 657 | tport->tp_is_open = 1; |
657 | ++tdev->td_open_port_count; | 658 | ++tdev->td_open_port_count; |
658 | 659 | ||
659 | goto up_sem; | 660 | goto release_lock; |
660 | 661 | ||
661 | unlink_int_urb: | 662 | unlink_int_urb: |
662 | if (tdev->td_open_port_count == 0) | 663 | if (tdev->td_open_port_count == 0) |
663 | usb_kill_urb(port->serial->port[0]->interrupt_in_urb); | 664 | usb_kill_urb(port->serial->port[0]->interrupt_in_urb); |
664 | up_sem: | 665 | release_lock: |
665 | up(&tdev->td_open_close_sem); | 666 | mutex_unlock(&tdev->td_open_close_lock); |
666 | dbg("%s - exit %d", __FUNCTION__, status); | 667 | dbg("%s - exit %d", __FUNCTION__, status); |
667 | return status; | 668 | return status; |
668 | } | 669 | } |
@@ -674,7 +675,7 @@ static void ti_close(struct usb_serial_port *port, struct file *file) | |||
674 | struct ti_port *tport; | 675 | struct ti_port *tport; |
675 | int port_number; | 676 | int port_number; |
676 | int status; | 677 | int status; |
677 | int do_up; | 678 | int do_unlock; |
678 | 679 | ||
679 | dbg("%s - port %d", __FUNCTION__, port->number); | 680 | dbg("%s - port %d", __FUNCTION__, port->number); |
680 | 681 | ||
@@ -699,16 +700,16 @@ static void ti_close(struct usb_serial_port *port, struct file *file) | |||
699 | if (status) | 700 | if (status) |
700 | dev_err(&port->dev, "%s - cannot send close port command, %d\n" , __FUNCTION__, status); | 701 | dev_err(&port->dev, "%s - cannot send close port command, %d\n" , __FUNCTION__, status); |
701 | 702 | ||
702 | /* if down is interrupted, continue anyway */ | 703 | /* if mutex_lock is interrupted, continue anyway */ |
703 | do_up = !down_interruptible(&tdev->td_open_close_sem); | 704 | do_unlock = !mutex_lock_interruptible(&tdev->td_open_close_lock); |
704 | --tport->tp_tdev->td_open_port_count; | 705 | --tport->tp_tdev->td_open_port_count; |
705 | if (tport->tp_tdev->td_open_port_count <= 0) { | 706 | if (tport->tp_tdev->td_open_port_count <= 0) { |
706 | /* last port is closed, shut down interrupt urb */ | 707 | /* last port is closed, shut down interrupt urb */ |
707 | usb_kill_urb(port->serial->port[0]->interrupt_in_urb); | 708 | usb_kill_urb(port->serial->port[0]->interrupt_in_urb); |
708 | tport->tp_tdev->td_open_port_count = 0; | 709 | tport->tp_tdev->td_open_port_count = 0; |
709 | } | 710 | } |
710 | if (do_up) | 711 | if (do_unlock) |
711 | up(&tdev->td_open_close_sem); | 712 | mutex_unlock(&tdev->td_open_close_lock); |
712 | 713 | ||
713 | dbg("%s - exit", __FUNCTION__); | 714 | dbg("%s - exit", __FUNCTION__); |
714 | } | 715 | } |
@@ -896,24 +897,11 @@ static void ti_set_termios(struct usb_serial_port *port, | |||
896 | 897 | ||
897 | dbg("%s - port %d", __FUNCTION__, port->number); | 898 | dbg("%s - port %d", __FUNCTION__, port->number); |
898 | 899 | ||
899 | if (!tty || !tty->termios) { | ||
900 | dbg("%s - no tty or termios", __FUNCTION__); | ||
901 | return; | ||
902 | } | ||
903 | |||
904 | cflag = tty->termios->c_cflag; | 900 | cflag = tty->termios->c_cflag; |
905 | iflag = tty->termios->c_iflag; | 901 | iflag = tty->termios->c_iflag; |
906 | 902 | ||
907 | if (old_termios && cflag == old_termios->c_cflag | 903 | dbg("%s - cflag %08x, iflag %08x", __FUNCTION__, cflag, iflag); |
908 | && iflag == old_termios->c_iflag) { | 904 | dbg("%s - old clfag %08x, old iflag %08x", __FUNCTION__, old_termios->c_cflag, old_termios->c_iflag); |
909 | dbg("%s - nothing to change", __FUNCTION__); | ||
910 | return; | ||
911 | } | ||
912 | |||
913 | dbg("%s - clfag %08x, iflag %08x", __FUNCTION__, cflag, iflag); | ||
914 | |||
915 | if (old_termios) | ||
916 | dbg("%s - old clfag %08x, old iflag %08x", __FUNCTION__, old_termios->c_cflag, old_termios->c_iflag); | ||
917 | 905 | ||
918 | if (tport == NULL) | 906 | if (tport == NULL) |
919 | return; | 907 | return; |
@@ -947,6 +935,9 @@ static void ti_set_termios(struct usb_serial_port *port, | |||
947 | break; | 935 | break; |
948 | } | 936 | } |
949 | 937 | ||
938 | /* CMSPAR isn't supported by this driver */ | ||
939 | tty->termios->c_cflag &= ~CMSPAR; | ||
940 | |||
950 | if (cflag & PARENB) { | 941 | if (cflag & PARENB) { |
951 | if (cflag & PARODD) { | 942 | if (cflag & PARODD) { |
952 | config->wFlags |= TI_UART_ENABLE_PARITY_CHECKING; | 943 | config->wFlags |= TI_UART_ENABLE_PARITY_CHECKING; |
@@ -989,12 +980,17 @@ static void ti_set_termios(struct usb_serial_port *port, | |||
989 | } | 980 | } |
990 | 981 | ||
991 | baud = tty_get_baud_rate(tty); | 982 | baud = tty_get_baud_rate(tty); |
992 | if (!baud) baud = 9600; | 983 | if (!baud) |
984 | baud = 9600; | ||
993 | if (tport->tp_tdev->td_is_3410) | 985 | if (tport->tp_tdev->td_is_3410) |
994 | config->wBaudRate = (__u16)((923077 + baud/2) / baud); | 986 | config->wBaudRate = (__u16)((923077 + baud/2) / baud); |
995 | else | 987 | else |
996 | config->wBaudRate = (__u16)((461538 + baud/2) / baud); | 988 | config->wBaudRate = (__u16)((461538 + baud/2) / baud); |
997 | 989 | ||
990 | /* FIXME: Should calculate resulting baud here and report it back */ | ||
991 | if ((cflag & CBAUD) != B0) | ||
992 | tty_encode_baud_rate(tty, baud, baud); | ||
993 | |||
998 | dbg("%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d", | 994 | dbg("%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d", |
999 | __FUNCTION__, baud, config->wBaudRate, config->wFlags, config->bDataBits, config->bParity, config->bStopBits, config->cXon, config->cXoff, config->bUartMode); | 995 | __FUNCTION__, baud, config->wBaudRate, config->wFlags, config->bDataBits, config->bParity, config->bStopBits, config->cXon, config->cXoff, config->bUartMode); |
1000 | 996 | ||
@@ -1497,11 +1493,10 @@ static void ti_drain(struct ti_port *tport, unsigned long timeout, int flush) | |||
1497 | struct ti_device *tdev = tport->tp_tdev; | 1493 | struct ti_device *tdev = tport->tp_tdev; |
1498 | struct usb_serial_port *port = tport->tp_port; | 1494 | struct usb_serial_port *port = tport->tp_port; |
1499 | wait_queue_t wait; | 1495 | wait_queue_t wait; |
1500 | unsigned long flags; | ||
1501 | 1496 | ||
1502 | dbg("%s - port %d", __FUNCTION__, port->number); | 1497 | dbg("%s - port %d", __FUNCTION__, port->number); |
1503 | 1498 | ||
1504 | spin_lock_irqsave(&tport->tp_lock, flags); | 1499 | spin_lock_irq(&tport->tp_lock); |
1505 | 1500 | ||
1506 | /* wait for data to drain from the buffer */ | 1501 | /* wait for data to drain from the buffer */ |
1507 | tdev->td_urb_error = 0; | 1502 | tdev->td_urb_error = 0; |
@@ -1512,11 +1507,11 @@ static void ti_drain(struct ti_port *tport, unsigned long timeout, int flush) | |||
1512 | if (ti_buf_data_avail(tport->tp_write_buf) == 0 | 1507 | if (ti_buf_data_avail(tport->tp_write_buf) == 0 |
1513 | || timeout == 0 || signal_pending(current) | 1508 | || timeout == 0 || signal_pending(current) |
1514 | || tdev->td_urb_error | 1509 | || tdev->td_urb_error |
1515 | || !usb_get_intfdata(port->serial->interface)) /* disconnect */ | 1510 | || port->serial->disconnected) /* disconnect */ |
1516 | break; | 1511 | break; |
1517 | spin_unlock_irqrestore(&tport->tp_lock, flags); | 1512 | spin_unlock_irq(&tport->tp_lock); |
1518 | timeout = schedule_timeout(timeout); | 1513 | timeout = schedule_timeout(timeout); |
1519 | spin_lock_irqsave(&tport->tp_lock, flags); | 1514 | spin_lock_irq(&tport->tp_lock); |
1520 | } | 1515 | } |
1521 | set_current_state(TASK_RUNNING); | 1516 | set_current_state(TASK_RUNNING); |
1522 | remove_wait_queue(&tport->tp_write_wait, &wait); | 1517 | remove_wait_queue(&tport->tp_write_wait, &wait); |
@@ -1525,19 +1520,23 @@ static void ti_drain(struct ti_port *tport, unsigned long timeout, int flush) | |||
1525 | if (flush) | 1520 | if (flush) |
1526 | ti_buf_clear(tport->tp_write_buf); | 1521 | ti_buf_clear(tport->tp_write_buf); |
1527 | 1522 | ||
1528 | spin_unlock_irqrestore(&tport->tp_lock, flags); | 1523 | spin_unlock_irq(&tport->tp_lock); |
1529 | 1524 | ||
1525 | mutex_lock(&port->serial->disc_mutex); | ||
1530 | /* wait for data to drain from the device */ | 1526 | /* wait for data to drain from the device */ |
1531 | /* wait for empty tx register, plus 20 ms */ | 1527 | /* wait for empty tx register, plus 20 ms */ |
1532 | timeout += jiffies; | 1528 | timeout += jiffies; |
1533 | tport->tp_lsr &= ~TI_LSR_TX_EMPTY; | 1529 | tport->tp_lsr &= ~TI_LSR_TX_EMPTY; |
1534 | while ((long)(jiffies - timeout) < 0 && !signal_pending(current) | 1530 | while ((long)(jiffies - timeout) < 0 && !signal_pending(current) |
1535 | && !(tport->tp_lsr&TI_LSR_TX_EMPTY) && !tdev->td_urb_error | 1531 | && !(tport->tp_lsr&TI_LSR_TX_EMPTY) && !tdev->td_urb_error |
1536 | && usb_get_intfdata(port->serial->interface)) { /* not disconnected */ | 1532 | && !port->serial->disconnected) { |
1537 | if (ti_get_lsr(tport)) | 1533 | if (ti_get_lsr(tport)) |
1538 | break; | 1534 | break; |
1535 | mutex_unlock(&port->serial->disc_mutex); | ||
1539 | msleep_interruptible(20); | 1536 | msleep_interruptible(20); |
1537 | mutex_lock(&port->serial->disc_mutex); | ||
1540 | } | 1538 | } |
1539 | mutex_unlock(&port->serial->disc_mutex); | ||
1541 | } | 1540 | } |
1542 | 1541 | ||
1543 | 1542 | ||
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 497e29a700ca..3ce98e8d7bce 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -225,16 +225,21 @@ static int serial_open (struct tty_struct *tty, struct file * filp) | |||
225 | goto bailout_mutex_unlock; | 225 | goto bailout_mutex_unlock; |
226 | } | 226 | } |
227 | 227 | ||
228 | retval = usb_autopm_get_interface(serial->interface); | ||
229 | if (retval) | ||
230 | goto bailout_module_put; | ||
228 | /* only call the device specific open if this | 231 | /* only call the device specific open if this |
229 | * is the first time the port is opened */ | 232 | * is the first time the port is opened */ |
230 | retval = serial->type->open(port, filp); | 233 | retval = serial->type->open(port, filp); |
231 | if (retval) | 234 | if (retval) |
232 | goto bailout_module_put; | 235 | goto bailout_interface_put; |
233 | } | 236 | } |
234 | 237 | ||
235 | mutex_unlock(&port->mutex); | 238 | mutex_unlock(&port->mutex); |
236 | return 0; | 239 | return 0; |
237 | 240 | ||
241 | bailout_interface_put: | ||
242 | usb_autopm_put_interface(serial->interface); | ||
238 | bailout_module_put: | 243 | bailout_module_put: |
239 | module_put(serial->type->driver.owner); | 244 | module_put(serial->type->driver.owner); |
240 | bailout_mutex_unlock: | 245 | bailout_mutex_unlock: |
@@ -264,17 +269,21 @@ static void serial_close(struct tty_struct *tty, struct file * filp) | |||
264 | } | 269 | } |
265 | 270 | ||
266 | --port->open_count; | 271 | --port->open_count; |
267 | if (port->open_count == 0) { | 272 | if (port->open_count == 0) |
268 | /* only call the device specific close if this | 273 | /* only call the device specific close if this |
269 | * port is being closed by the last owner */ | 274 | * port is being closed by the last owner */ |
270 | port->serial->type->close(port, filp); | 275 | port->serial->type->close(port, filp); |
271 | 276 | ||
277 | if (port->open_count == (port->console? 1 : 0)) { | ||
272 | if (port->tty) { | 278 | if (port->tty) { |
273 | if (port->tty->driver_data) | 279 | if (port->tty->driver_data) |
274 | port->tty->driver_data = NULL; | 280 | port->tty->driver_data = NULL; |
275 | port->tty = NULL; | 281 | port->tty = NULL; |
276 | } | 282 | } |
283 | } | ||
277 | 284 | ||
285 | if (port->open_count == 0) { | ||
286 | usb_autopm_put_interface(port->serial->interface); | ||
278 | module_put(port->serial->type->driver.owner); | 287 | module_put(port->serial->type->driver.owner); |
279 | } | 288 | } |
280 | 289 | ||
@@ -625,6 +634,7 @@ static struct usb_serial * create_serial (struct usb_device *dev, | |||
625 | serial->type = driver; | 634 | serial->type = driver; |
626 | serial->interface = interface; | 635 | serial->interface = interface; |
627 | kref_init(&serial->kref); | 636 | kref_init(&serial->kref); |
637 | mutex_init(&serial->disc_mutex); | ||
628 | 638 | ||
629 | return serial; | 639 | return serial; |
630 | } | 640 | } |
@@ -1080,20 +1090,22 @@ void usb_serial_disconnect(struct usb_interface *interface) | |||
1080 | usb_serial_console_disconnect(serial); | 1090 | usb_serial_console_disconnect(serial); |
1081 | dbg ("%s", __FUNCTION__); | 1091 | dbg ("%s", __FUNCTION__); |
1082 | 1092 | ||
1093 | mutex_lock(&serial->disc_mutex); | ||
1083 | usb_set_intfdata (interface, NULL); | 1094 | usb_set_intfdata (interface, NULL); |
1084 | if (serial) { | 1095 | /* must set a flag, to signal subdrivers */ |
1085 | for (i = 0; i < serial->num_ports; ++i) { | 1096 | serial->disconnected = 1; |
1086 | port = serial->port[i]; | 1097 | for (i = 0; i < serial->num_ports; ++i) { |
1087 | if (port) { | 1098 | port = serial->port[i]; |
1088 | if (port->tty) | 1099 | if (port) { |
1089 | tty_hangup(port->tty); | 1100 | if (port->tty) |
1090 | kill_traffic(port); | 1101 | tty_hangup(port->tty); |
1091 | } | 1102 | kill_traffic(port); |
1092 | } | 1103 | } |
1093 | /* let the last holder of this object | ||
1094 | * cause it to be cleaned up */ | ||
1095 | usb_serial_put(serial); | ||
1096 | } | 1104 | } |
1105 | /* let the last holder of this object | ||
1106 | * cause it to be cleaned up */ | ||
1107 | mutex_unlock(&serial->disc_mutex); | ||
1108 | usb_serial_put(serial); | ||
1097 | dev_info(dev, "device disconnected\n"); | 1109 | dev_info(dev, "device disconnected\n"); |
1098 | } | 1110 | } |
1099 | 1111 | ||
@@ -1103,9 +1115,6 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message) | |||
1103 | struct usb_serial_port *port; | 1115 | struct usb_serial_port *port; |
1104 | int i, r = 0; | 1116 | int i, r = 0; |
1105 | 1117 | ||
1106 | if (!serial) /* device has been disconnected */ | ||
1107 | return 0; | ||
1108 | |||
1109 | for (i = 0; i < serial->num_ports; ++i) { | 1118 | for (i = 0; i < serial->num_ports; ++i) { |
1110 | port = serial->port[i]; | 1119 | port = serial->port[i]; |
1111 | if (port) | 1120 | if (port) |
@@ -1253,6 +1262,7 @@ static void fixup_generic(struct usb_serial_driver *device) | |||
1253 | set_to_generic_if_null(device, read_bulk_callback); | 1262 | set_to_generic_if_null(device, read_bulk_callback); |
1254 | set_to_generic_if_null(device, write_bulk_callback); | 1263 | set_to_generic_if_null(device, write_bulk_callback); |
1255 | set_to_generic_if_null(device, shutdown); | 1264 | set_to_generic_if_null(device, shutdown); |
1265 | set_to_generic_if_null(device, resume); | ||
1256 | } | 1266 | } |
1257 | 1267 | ||
1258 | int usb_serial_register(struct usb_serial_driver *driver) /* must be called with BKL held */ | 1268 | int usb_serial_register(struct usb_serial_driver *driver) /* must be called with BKL held */ |
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index 7ee087fed913..22b3f78a388c 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c | |||
@@ -349,16 +349,20 @@ static void visor_close (struct usb_serial_port *port, struct file * filp) | |||
349 | usb_kill_urb(port->read_urb); | 349 | usb_kill_urb(port->read_urb); |
350 | usb_kill_urb(port->interrupt_in_urb); | 350 | usb_kill_urb(port->interrupt_in_urb); |
351 | 351 | ||
352 | /* Try to send shutdown message, if the device is gone, this will just fail. */ | 352 | mutex_lock(&port->serial->disc_mutex); |
353 | transfer_buffer = kmalloc (0x12, GFP_KERNEL); | 353 | if (!port->serial->disconnected) { |
354 | if (transfer_buffer) { | 354 | /* Try to send shutdown message, unless the device is gone */ |
355 | usb_control_msg (port->serial->dev, | 355 | transfer_buffer = kmalloc (0x12, GFP_KERNEL); |
356 | usb_rcvctrlpipe(port->serial->dev, 0), | 356 | if (transfer_buffer) { |
357 | VISOR_CLOSE_NOTIFICATION, 0xc2, | 357 | usb_control_msg (port->serial->dev, |
358 | 0x0000, 0x0000, | 358 | usb_rcvctrlpipe(port->serial->dev, 0), |
359 | transfer_buffer, 0x12, 300); | 359 | VISOR_CLOSE_NOTIFICATION, 0xc2, |
360 | kfree (transfer_buffer); | 360 | 0x0000, 0x0000, |
361 | transfer_buffer, 0x12, 300); | ||
362 | kfree (transfer_buffer); | ||
363 | } | ||
361 | } | 364 | } |
365 | mutex_unlock(&port->serial->disc_mutex); | ||
362 | 366 | ||
363 | if (stats) | 367 | if (stats) |
364 | dev_info(&port->dev, "Bytes In = %d Bytes Out = %d\n", | 368 | dev_info(&port->dev, "Bytes In = %d Bytes Out = %d\n", |
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index ee5dd8b5a713..38726ef3132b 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c | |||
@@ -610,8 +610,7 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp) | |||
610 | if (retval) | 610 | if (retval) |
611 | goto exit; | 611 | goto exit; |
612 | 612 | ||
613 | if (port->tty) | 613 | port->tty->low_latency = 1; |
614 | port->tty->low_latency = 1; | ||
615 | 614 | ||
616 | /* send an open port command */ | 615 | /* send an open port command */ |
617 | retval = firm_open(port); | 616 | retval = firm_open(port); |
@@ -659,11 +658,14 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp) | |||
659 | struct list_head *tmp2; | 658 | struct list_head *tmp2; |
660 | 659 | ||
661 | dbg("%s - port %d", __FUNCTION__, port->number); | 660 | dbg("%s - port %d", __FUNCTION__, port->number); |
662 | 661 | ||
662 | mutex_lock(&port->serial->disc_mutex); | ||
663 | /* filp is NULL when called from usb_serial_disconnect */ | 663 | /* filp is NULL when called from usb_serial_disconnect */ |
664 | if (filp && (tty_hung_up_p(filp))) { | 664 | if ((filp && (tty_hung_up_p(filp))) || port->serial->disconnected) { |
665 | mutex_unlock(&port->serial->disc_mutex); | ||
665 | return; | 666 | return; |
666 | } | 667 | } |
668 | mutex_unlock(&port->serial->disc_mutex); | ||
667 | 669 | ||
668 | port->tty->closing = 1; | 670 | port->tty->closing = 1; |
669 | 671 | ||
diff --git a/drivers/usb/storage/initializers.c b/drivers/usb/storage/initializers.c index ee5b42aa5363..187dd1e01093 100644 --- a/drivers/usb/storage/initializers.c +++ b/drivers/usb/storage/initializers.c | |||
@@ -66,7 +66,8 @@ int usb_stor_ucr61s2b_init(struct us_data *us) | |||
66 | { | 66 | { |
67 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap*) us->iobuf; | 67 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap*) us->iobuf; |
68 | struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap*) us->iobuf; | 68 | struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap*) us->iobuf; |
69 | int res, partial; | 69 | int res; |
70 | unsigned int partial; | ||
70 | static char init_string[] = "\xec\x0a\x06\x00$PCCHIPS"; | 71 | static char init_string[] = "\xec\x0a\x06\x00$PCCHIPS"; |
71 | 72 | ||
72 | US_DEBUGP("Sending UCR-61S2B initialization packet...\n"); | 73 | US_DEBUGP("Sending UCR-61S2B initialization packet...\n"); |
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index 0db488624ab1..2ae1e8673b19 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c | |||
@@ -48,7 +48,6 @@ | |||
48 | #include <linux/errno.h> | 48 | #include <linux/errno.h> |
49 | #include <linux/slab.h> | 49 | #include <linux/slab.h> |
50 | #include <linux/hdreg.h> | 50 | #include <linux/hdreg.h> |
51 | #include <linux/ide.h> | ||
52 | #include <linux/scatterlist.h> | 51 | #include <linux/scatterlist.h> |
53 | 52 | ||
54 | #include <scsi/scsi.h> | 53 | #include <scsi/scsi.h> |
@@ -110,6 +109,12 @@ | |||
110 | #define REG_STATUS 0x80 | 109 | #define REG_STATUS 0x80 |
111 | #define REG_COMMAND 0x80 | 110 | #define REG_COMMAND 0x80 |
112 | 111 | ||
112 | /* ATA registers offset definitions */ | ||
113 | #define ATA_REG_ERROR_OFFSET 1 | ||
114 | #define ATA_REG_LCYL_OFFSET 4 | ||
115 | #define ATA_REG_HCYL_OFFSET 5 | ||
116 | #define ATA_REG_STATUS_OFFSET 7 | ||
117 | |||
113 | /* ATA error definitions not in <linux/hdreg.h> */ | 118 | /* ATA error definitions not in <linux/hdreg.h> */ |
114 | #define ATA_ERROR_MEDIA_CHANGE 0x20 | 119 | #define ATA_ERROR_MEDIA_CHANGE 0x20 |
115 | 120 | ||
@@ -360,7 +365,7 @@ static void isd200_build_sense(struct us_data *us, struct scsi_cmnd *srb) | |||
360 | { | 365 | { |
361 | struct isd200_info *info = (struct isd200_info *)us->extra; | 366 | struct isd200_info *info = (struct isd200_info *)us->extra; |
362 | struct sense_data *buf = (struct sense_data *) &srb->sense_buffer[0]; | 367 | struct sense_data *buf = (struct sense_data *) &srb->sense_buffer[0]; |
363 | unsigned char error = info->ATARegs[IDE_ERROR_OFFSET]; | 368 | unsigned char error = info->ATARegs[ATA_REG_ERROR_OFFSET]; |
364 | 369 | ||
365 | if(error & ATA_ERROR_MEDIA_CHANGE) { | 370 | if(error & ATA_ERROR_MEDIA_CHANGE) { |
366 | buf->ErrorCode = 0x70 | SENSE_ERRCODE_VALID; | 371 | buf->ErrorCode = 0x70 | SENSE_ERRCODE_VALID; |
@@ -549,8 +554,8 @@ static int isd200_read_regs( struct us_data *us ) | |||
549 | retStatus = ISD200_ERROR; | 554 | retStatus = ISD200_ERROR; |
550 | } else { | 555 | } else { |
551 | memcpy(info->ATARegs, info->RegsBuf, sizeof(info->ATARegs)); | 556 | memcpy(info->ATARegs, info->RegsBuf, sizeof(info->ATARegs)); |
552 | US_DEBUGP(" Got ATA Register[IDE_ERROR_OFFSET] = 0x%x\n", | 557 | US_DEBUGP(" Got ATA Register[ATA_REG_ERROR_OFFSET] = 0x%x\n", |
553 | info->ATARegs[IDE_ERROR_OFFSET]); | 558 | info->ATARegs[ATA_REG_ERROR_OFFSET]); |
554 | } | 559 | } |
555 | 560 | ||
556 | return retStatus; | 561 | return retStatus; |
@@ -892,7 +897,7 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave, | |||
892 | break; | 897 | break; |
893 | 898 | ||
894 | if (!detect) { | 899 | if (!detect) { |
895 | if (regs[IDE_STATUS_OFFSET] & BUSY_STAT ) { | 900 | if (regs[ATA_REG_STATUS_OFFSET] & BUSY_STAT) { |
896 | US_DEBUGP(" %s status is still BSY, try again...\n",mstr); | 901 | US_DEBUGP(" %s status is still BSY, try again...\n",mstr); |
897 | } else { | 902 | } else { |
898 | US_DEBUGP(" %s status !BSY, continue with next operation\n",mstr); | 903 | US_DEBUGP(" %s status !BSY, continue with next operation\n",mstr); |
@@ -902,12 +907,12 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave, | |||
902 | /* check for BUSY_STAT and */ | 907 | /* check for BUSY_STAT and */ |
903 | /* WRERR_STAT (workaround ATA Zip drive) and */ | 908 | /* WRERR_STAT (workaround ATA Zip drive) and */ |
904 | /* ERR_STAT (workaround for Archos CD-ROM) */ | 909 | /* ERR_STAT (workaround for Archos CD-ROM) */ |
905 | else if (regs[IDE_STATUS_OFFSET] & | 910 | else if (regs[ATA_REG_STATUS_OFFSET] & |
906 | (BUSY_STAT | WRERR_STAT | ERR_STAT )) { | 911 | (BUSY_STAT | WRERR_STAT | ERR_STAT )) { |
907 | US_DEBUGP(" Status indicates it is not ready, try again...\n"); | 912 | US_DEBUGP(" Status indicates it is not ready, try again...\n"); |
908 | } | 913 | } |
909 | /* check for DRDY, ATA devices set DRDY after SRST */ | 914 | /* check for DRDY, ATA devices set DRDY after SRST */ |
910 | else if (regs[IDE_STATUS_OFFSET] & READY_STAT) { | 915 | else if (regs[ATA_REG_STATUS_OFFSET] & READY_STAT) { |
911 | US_DEBUGP(" Identified ATA device\n"); | 916 | US_DEBUGP(" Identified ATA device\n"); |
912 | info->DeviceFlags |= DF_ATA_DEVICE; | 917 | info->DeviceFlags |= DF_ATA_DEVICE; |
913 | info->DeviceHead = master_slave; | 918 | info->DeviceHead = master_slave; |
@@ -916,8 +921,8 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave, | |||
916 | /* check Cylinder High/Low to | 921 | /* check Cylinder High/Low to |
917 | determine if it is an ATAPI device | 922 | determine if it is an ATAPI device |
918 | */ | 923 | */ |
919 | else if ((regs[IDE_HCYL_OFFSET] == 0xEB) && | 924 | else if (regs[ATA_REG_HCYL_OFFSET] == 0xEB && |
920 | (regs[IDE_LCYL_OFFSET] == 0x14)) { | 925 | regs[ATA_REG_LCYL_OFFSET] == 0x14) { |
921 | /* It seems that the RICOH | 926 | /* It seems that the RICOH |
922 | MP6200A CD/RW drive will | 927 | MP6200A CD/RW drive will |
923 | report itself okay as a | 928 | report itself okay as a |
@@ -1001,12 +1006,6 @@ static int isd200_manual_enum(struct us_data *us) | |||
1001 | return(retStatus); | 1006 | return(retStatus); |
1002 | } | 1007 | } |
1003 | 1008 | ||
1004 | /* | ||
1005 | * We are the last non IDE user of the legacy IDE ident structures | ||
1006 | * and we thus want to keep a private copy of this function so the | ||
1007 | * driver can be used without the obsolete drivers/ide layer | ||
1008 | */ | ||
1009 | |||
1010 | static void isd200_fix_driveid (struct hd_driveid *id) | 1009 | static void isd200_fix_driveid (struct hd_driveid *id) |
1011 | { | 1010 | { |
1012 | #ifndef __LITTLE_ENDIAN | 1011 | #ifndef __LITTLE_ENDIAN |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 6d6108b3993b..fe12737e0e2b 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -86,6 +86,14 @@ UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001, | |||
86 | US_SC_8070, US_PR_USBAT, init_usbat_cd, 0), | 86 | US_SC_8070, US_PR_USBAT, init_usbat_cd, 0), |
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | /* Reported by Grant Grundler <grundler@parisc-linux.org> | ||
90 | * HP r707 camera in "Disk" mode with 2.00.23 or 2.00.24 firmware. | ||
91 | */ | ||
92 | UNUSUAL_DEV( 0x03f0, 0x4002, 0x0001, 0x0001, | ||
93 | "HP", | ||
94 | "PhotoSmart R707", | ||
95 | US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_FIX_CAPACITY), | ||
96 | |||
89 | /* Reported by Sebastian Kapfer <sebastian_kapfer@gmx.net> | 97 | /* Reported by Sebastian Kapfer <sebastian_kapfer@gmx.net> |
90 | * and Olaf Hering <olh@suse.de> (different bcd's, same vendor/product) | 98 | * and Olaf Hering <olh@suse.de> (different bcd's, same vendor/product) |
91 | * for USB floppies that need the SINGLE_LUN enforcement. | 99 | * for USB floppies that need the SINGLE_LUN enforcement. |
diff --git a/drivers/video/sis/sis.h b/drivers/video/sis/sis.h index d53bf6945f0c..9b05da6268f7 100644 --- a/drivers/video/sis/sis.h +++ b/drivers/video/sis/sis.h | |||
@@ -39,12 +39,7 @@ | |||
39 | #include <linux/spinlock.h> | 39 | #include <linux/spinlock.h> |
40 | 40 | ||
41 | #ifdef CONFIG_COMPAT | 41 | #ifdef CONFIG_COMPAT |
42 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,10) | ||
43 | #include <linux/ioctl32.h> | ||
44 | #define SIS_OLD_CONFIG_COMPAT | ||
45 | #else | ||
46 | #define SIS_NEW_CONFIG_COMPAT | 42 | #define SIS_NEW_CONFIG_COMPAT |
47 | #endif | ||
48 | #endif /* CONFIG_COMPAT */ | 43 | #endif /* CONFIG_COMPAT */ |
49 | 44 | ||
50 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8) | 45 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8) |
@@ -607,9 +602,6 @@ struct sis_video_info { | |||
607 | int haveXGIROM; | 602 | int haveXGIROM; |
608 | int registered; | 603 | int registered; |
609 | int warncount; | 604 | int warncount; |
610 | #ifdef SIS_OLD_CONFIG_COMPAT | ||
611 | int ioctl32registered; | ||
612 | #endif | ||
613 | 605 | ||
614 | int sisvga_engine; | 606 | int sisvga_engine; |
615 | int hwcursor_size; | 607 | int hwcursor_size; |
diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c index 37bd24b8d83b..93ae747440cb 100644 --- a/drivers/video/sis/sis_main.c +++ b/drivers/video/sis/sis_main.c | |||
@@ -5805,9 +5805,6 @@ sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
5805 | ivideo->pcifunc = PCI_FUNC(pdev->devfn); | 5805 | ivideo->pcifunc = PCI_FUNC(pdev->devfn); |
5806 | ivideo->subsysvendor = pdev->subsystem_vendor; | 5806 | ivideo->subsysvendor = pdev->subsystem_vendor; |
5807 | ivideo->subsysdevice = pdev->subsystem_device; | 5807 | ivideo->subsysdevice = pdev->subsystem_device; |
5808 | #ifdef SIS_OLD_CONFIG_COMPAT | ||
5809 | ivideo->ioctl32registered = 0; | ||
5810 | #endif | ||
5811 | 5808 | ||
5812 | #ifndef MODULE | 5809 | #ifndef MODULE |
5813 | if(sisfb_mode_idx == -1) { | 5810 | if(sisfb_mode_idx == -1) { |
@@ -6420,30 +6417,6 @@ error_3: vfree(ivideo->bios_abase); | |||
6420 | ivideo->next = card_list; | 6417 | ivideo->next = card_list; |
6421 | card_list = ivideo; | 6418 | card_list = ivideo; |
6422 | 6419 | ||
6423 | #ifdef SIS_OLD_CONFIG_COMPAT | ||
6424 | { | ||
6425 | int ret; | ||
6426 | /* Our ioctls are all "32/64bit compatible" */ | ||
6427 | ret = register_ioctl32_conversion(FBIO_ALLOC, NULL); | ||
6428 | ret |= register_ioctl32_conversion(FBIO_FREE, NULL); | ||
6429 | ret |= register_ioctl32_conversion(FBIOGET_VBLANK, NULL); | ||
6430 | ret |= register_ioctl32_conversion(SISFB_GET_INFO_SIZE, NULL); | ||
6431 | ret |= register_ioctl32_conversion(SISFB_GET_INFO, NULL); | ||
6432 | ret |= register_ioctl32_conversion(SISFB_GET_TVPOSOFFSET, NULL); | ||
6433 | ret |= register_ioctl32_conversion(SISFB_SET_TVPOSOFFSET, NULL); | ||
6434 | ret |= register_ioctl32_conversion(SISFB_SET_LOCK, NULL); | ||
6435 | ret |= register_ioctl32_conversion(SISFB_GET_VBRSTATUS, NULL); | ||
6436 | ret |= register_ioctl32_conversion(SISFB_GET_AUTOMAXIMIZE, NULL); | ||
6437 | ret |= register_ioctl32_conversion(SISFB_SET_AUTOMAXIMIZE, NULL); | ||
6438 | ret |= register_ioctl32_conversion(SISFB_COMMAND, NULL); | ||
6439 | if(ret) | ||
6440 | printk(KERN_ERR | ||
6441 | "sisfb: Error registering ioctl32 translations\n"); | ||
6442 | else | ||
6443 | ivideo->ioctl32registered = 1; | ||
6444 | } | ||
6445 | #endif | ||
6446 | |||
6447 | printk(KERN_INFO "sisfb: 2D acceleration is %s, y-panning %s\n", | 6420 | printk(KERN_INFO "sisfb: 2D acceleration is %s, y-panning %s\n", |
6448 | ivideo->sisfb_accel ? "enabled" : "disabled", | 6421 | ivideo->sisfb_accel ? "enabled" : "disabled", |
6449 | ivideo->sisfb_ypan ? | 6422 | ivideo->sisfb_ypan ? |
@@ -6473,27 +6446,6 @@ static void __devexit sisfb_remove(struct pci_dev *pdev) | |||
6473 | int registered = ivideo->registered; | 6446 | int registered = ivideo->registered; |
6474 | int modechanged = ivideo->modechanged; | 6447 | int modechanged = ivideo->modechanged; |
6475 | 6448 | ||
6476 | #ifdef SIS_OLD_CONFIG_COMPAT | ||
6477 | if(ivideo->ioctl32registered) { | ||
6478 | int ret; | ||
6479 | ret = unregister_ioctl32_conversion(FBIO_ALLOC); | ||
6480 | ret |= unregister_ioctl32_conversion(FBIO_FREE); | ||
6481 | ret |= unregister_ioctl32_conversion(FBIOGET_VBLANK); | ||
6482 | ret |= unregister_ioctl32_conversion(SISFB_GET_INFO_SIZE); | ||
6483 | ret |= unregister_ioctl32_conversion(SISFB_GET_INFO); | ||
6484 | ret |= unregister_ioctl32_conversion(SISFB_GET_TVPOSOFFSET); | ||
6485 | ret |= unregister_ioctl32_conversion(SISFB_SET_TVPOSOFFSET); | ||
6486 | ret |= unregister_ioctl32_conversion(SISFB_SET_LOCK); | ||
6487 | ret |= unregister_ioctl32_conversion(SISFB_GET_VBRSTATUS); | ||
6488 | ret |= unregister_ioctl32_conversion(SISFB_GET_AUTOMAXIMIZE); | ||
6489 | ret |= unregister_ioctl32_conversion(SISFB_SET_AUTOMAXIMIZE); | ||
6490 | ret |= unregister_ioctl32_conversion(SISFB_COMMAND); | ||
6491 | if(ret) | ||
6492 | printk(KERN_ERR | ||
6493 | "sisfb: Error unregistering ioctl32 translations\n"); | ||
6494 | } | ||
6495 | #endif | ||
6496 | |||
6497 | /* Unmap */ | 6449 | /* Unmap */ |
6498 | iounmap(ivideo->mmio_vbase); | 6450 | iounmap(ivideo->mmio_vbase); |
6499 | iounmap(ivideo->video_vbase); | 6451 | iounmap(ivideo->video_vbase); |