diff options
Diffstat (limited to 'drivers')
213 files changed, 5158 insertions, 2215 deletions
diff --git a/drivers/acorn/block/fd1772.c b/drivers/acorn/block/fd1772.c index 048542341204..674bf81c6e66 100644 --- a/drivers/acorn/block/fd1772.c +++ b/drivers/acorn/block/fd1772.c | |||
@@ -1549,12 +1549,12 @@ int fd1772_init(void) | |||
1549 | #ifdef TRACKBUFFER | 1549 | #ifdef TRACKBUFFER |
1550 | BufferDrive = BufferSide = BufferTrack = -1; | 1550 | BufferDrive = BufferSide = BufferTrack = -1; |
1551 | /* Atari uses 512 - I want to eventually cope with 1K sectors */ | 1551 | /* Atari uses 512 - I want to eventually cope with 1K sectors */ |
1552 | DMABuffer = (char *)kmalloc((FD1772_MAX_SECTORS+1)*512,GFP_KERNEL); | 1552 | DMABuffer = kmalloc((FD1772_MAX_SECTORS+1)*512,GFP_KERNEL); |
1553 | TrackBuffer = DMABuffer + 512; | 1553 | TrackBuffer = DMABuffer + 512; |
1554 | #else | 1554 | #else |
1555 | /* Allocate memory for the DMAbuffer - on the Atari this takes it | 1555 | /* Allocate memory for the DMAbuffer - on the Atari this takes it |
1556 | out of some special memory... */ | 1556 | out of some special memory... */ |
1557 | DMABuffer = (char *) kmalloc(2048); /* Copes with pretty large sectors */ | 1557 | DMABuffer = kmalloc(2048); /* Copes with pretty large sectors */ |
1558 | #endif | 1558 | #endif |
1559 | err = -ENOMEM; | 1559 | err = -ENOMEM; |
1560 | if (!DMAbuffer) | 1560 | if (!DMAbuffer) |
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 984ab284382a..b34e0a958d0f 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
@@ -40,9 +40,9 @@ config ATA_PIIX | |||
40 | tristate "Intel PIIX/ICH SATA support" | 40 | tristate "Intel PIIX/ICH SATA support" |
41 | depends on PCI | 41 | depends on PCI |
42 | help | 42 | help |
43 | This option enables support for ICH5/6/7/8 Serial ATA. | 43 | This option enables support for ICH5/6/7/8 Serial ATA |
44 | If PATA support was enabled previously, this enables | 44 | and support for PATA on the Intel PIIX3/PIIX4/ICH series |
45 | support for select Intel PIIX/ICH PATA host controllers. | 45 | PATA host controllers. |
46 | 46 | ||
47 | If unsure, say N. | 47 | If unsure, say N. |
48 | 48 | ||
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index f36da488a2c1..dbae6d971041 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -645,8 +645,6 @@ static int ahci_reset_controller(void __iomem *mmio, struct pci_dev *pdev) | |||
645 | u32 cap_save, impl_save, tmp; | 645 | u32 cap_save, impl_save, tmp; |
646 | 646 | ||
647 | cap_save = readl(mmio + HOST_CAP); | 647 | cap_save = readl(mmio + HOST_CAP); |
648 | cap_save &= ( (1<<28) | (1<<17) ); | ||
649 | cap_save |= (1 << 27); | ||
650 | impl_save = readl(mmio + HOST_PORTS_IMPL); | 648 | impl_save = readl(mmio + HOST_PORTS_IMPL); |
651 | 649 | ||
652 | /* global controller reset */ | 650 | /* global controller reset */ |
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index c7de0bb1591f..47701b286f8b 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c | |||
@@ -226,14 +226,26 @@ static const struct pci_device_id piix_pci_tbl[] = { | |||
226 | { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, | 226 | { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, |
227 | /* 2801GBM/GHM (ICH7M, identical to ICH6M) */ | 227 | /* 2801GBM/GHM (ICH7M, identical to ICH6M) */ |
228 | { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6m_sata_ahci }, | 228 | { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6m_sata_ahci }, |
229 | /* Enterprise Southbridge 2 (where's the datasheet?) */ | 229 | /* Enterprise Southbridge 2 (631xESB/632xESB) */ |
230 | { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, | 230 | { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, |
231 | /* SATA Controller 1 IDE (ICH8, no datasheet yet) */ | 231 | /* SATA Controller 1 IDE (ICH8) */ |
232 | { 0x8086, 0x2820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | 232 | { 0x8086, 0x2820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, |
233 | /* SATA Controller 2 IDE (ICH8, ditto) */ | 233 | /* SATA Controller 2 IDE (ICH8) */ |
234 | { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | 234 | { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, |
235 | /* Mobile SATA Controller IDE (ICH8M, ditto) */ | 235 | /* Mobile SATA Controller IDE (ICH8M) */ |
236 | { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | 236 | { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, |
237 | /* SATA Controller IDE (ICH9) */ | ||
238 | { 0x8086, 0x2920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | ||
239 | /* SATA Controller IDE (ICH9) */ | ||
240 | { 0x8086, 0x2921, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | ||
241 | /* SATA Controller IDE (ICH9) */ | ||
242 | { 0x8086, 0x2926, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | ||
243 | /* SATA Controller IDE (ICH9M) */ | ||
244 | { 0x8086, 0x2928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | ||
245 | /* SATA Controller IDE (ICH9M) */ | ||
246 | { 0x8086, 0x292d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | ||
247 | /* SATA Controller IDE (ICH9M) */ | ||
248 | { 0x8086, 0x292e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | ||
237 | 249 | ||
238 | { } /* terminate list */ | 250 | { } /* terminate list */ |
239 | }; | 251 | }; |
@@ -330,7 +342,7 @@ static const struct ata_port_operations ich_pata_ops = { | |||
330 | 342 | ||
331 | .port_start = ata_port_start, | 343 | .port_start = ata_port_start, |
332 | .port_stop = ata_port_stop, | 344 | .port_stop = ata_port_stop, |
333 | .host_stop = ata_host_stop, | 345 | .host_stop = piix_host_stop, |
334 | }; | 346 | }; |
335 | 347 | ||
336 | static const struct ata_port_operations piix_sata_ops = { | 348 | static const struct ata_port_operations piix_sata_ops = { |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 011c0a8a2dcc..0d51d13b16bf 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -1332,7 +1332,7 @@ unsigned ata_exec_internal_sg(struct ata_device *dev, | |||
1332 | } | 1332 | } |
1333 | 1333 | ||
1334 | /** | 1334 | /** |
1335 | * ata_exec_internal_sg - execute libata internal command | 1335 | * ata_exec_internal - execute libata internal command |
1336 | * @dev: Device to which the command is sent | 1336 | * @dev: Device to which the command is sent |
1337 | * @tf: Taskfile registers for the command and the result | 1337 | * @tf: Taskfile registers for the command and the result |
1338 | * @cdb: CDB for packet command | 1338 | * @cdb: CDB for packet command |
@@ -1353,11 +1353,17 @@ unsigned ata_exec_internal(struct ata_device *dev, | |||
1353 | struct ata_taskfile *tf, const u8 *cdb, | 1353 | struct ata_taskfile *tf, const u8 *cdb, |
1354 | int dma_dir, void *buf, unsigned int buflen) | 1354 | int dma_dir, void *buf, unsigned int buflen) |
1355 | { | 1355 | { |
1356 | struct scatterlist sg; | 1356 | struct scatterlist *psg = NULL, sg; |
1357 | unsigned int n_elem = 0; | ||
1357 | 1358 | ||
1358 | sg_init_one(&sg, buf, buflen); | 1359 | if (dma_dir != DMA_NONE) { |
1360 | WARN_ON(!buf); | ||
1361 | sg_init_one(&sg, buf, buflen); | ||
1362 | psg = &sg; | ||
1363 | n_elem++; | ||
1364 | } | ||
1359 | 1365 | ||
1360 | return ata_exec_internal_sg(dev, tf, cdb, dma_dir, &sg, 1); | 1366 | return ata_exec_internal_sg(dev, tf, cdb, dma_dir, psg, n_elem); |
1361 | } | 1367 | } |
1362 | 1368 | ||
1363 | /** | 1369 | /** |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 664e1377b54c..a4790be41d1c 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -1539,7 +1539,7 @@ static unsigned int ata_scsi_rbuf_get(struct scsi_cmnd *cmd, u8 **buf_out) | |||
1539 | struct scatterlist *sg; | 1539 | struct scatterlist *sg; |
1540 | 1540 | ||
1541 | sg = (struct scatterlist *) cmd->request_buffer; | 1541 | sg = (struct scatterlist *) cmd->request_buffer; |
1542 | buf = kmap_atomic(sg->page, KM_USER0) + sg->offset; | 1542 | buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; |
1543 | buflen = sg->length; | 1543 | buflen = sg->length; |
1544 | } else { | 1544 | } else { |
1545 | buf = cmd->request_buffer; | 1545 | buf = cmd->request_buffer; |
@@ -1567,7 +1567,7 @@ static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, u8 *buf) | |||
1567 | struct scatterlist *sg; | 1567 | struct scatterlist *sg; |
1568 | 1568 | ||
1569 | sg = (struct scatterlist *) cmd->request_buffer; | 1569 | sg = (struct scatterlist *) cmd->request_buffer; |
1570 | kunmap_atomic(buf - sg->offset, KM_USER0); | 1570 | kunmap_atomic(buf - sg->offset, KM_IRQ0); |
1571 | } | 1571 | } |
1572 | } | 1572 | } |
1573 | 1573 | ||
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c index c7d1738e4e69..e7bf9d89c8ee 100644 --- a/drivers/ata/pata_legacy.c +++ b/drivers/ata/pata_legacy.c | |||
@@ -698,8 +698,10 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl | |||
698 | goto fail_io; | 698 | goto fail_io; |
699 | 699 | ||
700 | pdev = platform_device_register_simple(DRV_NAME, nr_legacy_host, NULL, 0); | 700 | pdev = platform_device_register_simple(DRV_NAME, nr_legacy_host, NULL, 0); |
701 | if (pdev == NULL) | 701 | if (IS_ERR(pdev)) { |
702 | ret = PTR_ERR(pdev); | ||
702 | goto fail_dev; | 703 | goto fail_dev; |
704 | } | ||
703 | 705 | ||
704 | if (ht6560a & mask) { | 706 | if (ht6560a & mask) { |
705 | ops = &ht6560a_port_ops; | 707 | ops = &ht6560a_port_ops; |
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c index 36f621abc390..afc0d990e7d6 100644 --- a/drivers/ata/pata_qdi.c +++ b/drivers/ata/pata_qdi.c | |||
@@ -247,8 +247,8 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i | |||
247 | */ | 247 | */ |
248 | 248 | ||
249 | pdev = platform_device_register_simple(DRV_NAME, nr_qdi_host, NULL, 0); | 249 | pdev = platform_device_register_simple(DRV_NAME, nr_qdi_host, NULL, 0); |
250 | if (pdev == NULL) | 250 | if (IS_ERR(pdev)) |
251 | return -ENOMEM; | 251 | return PTR_ERR(pdev); |
252 | 252 | ||
253 | memset(&ae, 0, sizeof(struct ata_probe_ent)); | 253 | memset(&ae, 0, sizeof(struct ata_probe_ent)); |
254 | INIT_LIST_HEAD(&ae.node); | 254 | INIT_LIST_HEAD(&ae.node); |
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c index 3677c642c9f9..adf4cc134f25 100644 --- a/drivers/ata/pata_rz1000.c +++ b/drivers/ata/pata_rz1000.c | |||
@@ -105,8 +105,6 @@ static struct ata_port_operations rz1000_port_ops = { | |||
105 | .exec_command = ata_exec_command, | 105 | .exec_command = ata_exec_command, |
106 | .dev_select = ata_std_dev_select, | 106 | .dev_select = ata_std_dev_select, |
107 | 107 | ||
108 | .error_handler = rz1000_error_handler, | ||
109 | |||
110 | .bmdma_setup = ata_bmdma_setup, | 108 | .bmdma_setup = ata_bmdma_setup, |
111 | .bmdma_start = ata_bmdma_start, | 109 | .bmdma_start = ata_bmdma_start, |
112 | .bmdma_stop = ata_bmdma_stop, | 110 | .bmdma_stop = ata_bmdma_stop, |
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c index cc09d47fb927..ff93e8f71cf8 100644 --- a/drivers/ata/pata_via.c +++ b/drivers/ata/pata_via.c | |||
@@ -161,10 +161,15 @@ static int via_pre_reset(struct ata_port *ap) | |||
161 | return -ENOENT; | 161 | return -ENOENT; |
162 | } | 162 | } |
163 | 163 | ||
164 | if ((config->flags & VIA_UDMA) >= VIA_UDMA_66) | 164 | if ((config->flags & VIA_UDMA) >= VIA_UDMA_100) |
165 | ap->cbl = via_cable_detect(ap); | 165 | ap->cbl = via_cable_detect(ap); |
166 | else | 166 | /* The UDMA66 series has no cable detect so do drive side detect */ |
167 | else if ((config->flags & VIA_UDMA) < VIA_UDMA_66) | ||
167 | ap->cbl = ATA_CBL_PATA40; | 168 | ap->cbl = ATA_CBL_PATA40; |
169 | else | ||
170 | ap->cbl = ATA_CBL_PATA_UNK; | ||
171 | |||
172 | |||
168 | return ata_std_prereset(ap); | 173 | return ata_std_prereset(ap); |
169 | } | 174 | } |
170 | 175 | ||
diff --git a/drivers/ata/pata_winbond.c b/drivers/ata/pata_winbond.c index 3ea345cde52e..5d1f518e1cc7 100644 --- a/drivers/ata/pata_winbond.c +++ b/drivers/ata/pata_winbond.c | |||
@@ -206,8 +206,8 @@ static __init int winbond_init_one(unsigned long port) | |||
206 | */ | 206 | */ |
207 | 207 | ||
208 | pdev = platform_device_register_simple(DRV_NAME, nr_winbond_host, NULL, 0); | 208 | pdev = platform_device_register_simple(DRV_NAME, nr_winbond_host, NULL, 0); |
209 | if (pdev == NULL) | 209 | if (IS_ERR(pdev)) |
210 | return -ENOMEM; | 210 | return PTR_ERR(pdev); |
211 | 211 | ||
212 | memset(&ae, 0, sizeof(struct ata_probe_ent)); | 212 | memset(&ae, 0, sizeof(struct ata_probe_ent)); |
213 | INIT_LIST_HEAD(&ae.node); | 213 | INIT_LIST_HEAD(&ae.node); |
diff --git a/drivers/ata/pdc_adma.c b/drivers/ata/pdc_adma.c index 9021e34d2096..90786d7a20bb 100644 --- a/drivers/ata/pdc_adma.c +++ b/drivers/ata/pdc_adma.c | |||
@@ -551,7 +551,7 @@ static int adma_port_start(struct ata_port *ap) | |||
551 | return rc; | 551 | return rc; |
552 | adma_enter_reg_mode(ap); | 552 | adma_enter_reg_mode(ap); |
553 | rc = -ENOMEM; | 553 | rc = -ENOMEM; |
554 | pp = kcalloc(1, sizeof(*pp), GFP_KERNEL); | 554 | pp = kzalloc(sizeof(*pp), GFP_KERNEL); |
555 | if (!pp) | 555 | if (!pp) |
556 | goto err_out; | 556 | goto err_out; |
557 | pp->pkt = dma_alloc_coherent(dev, ADMA_PKT_BYTES, &pp->pkt_dma, | 557 | pp->pkt = dma_alloc_coherent(dev, ADMA_PKT_BYTES, &pp->pkt_dma, |
@@ -672,7 +672,7 @@ static int adma_ata_init_one(struct pci_dev *pdev, | |||
672 | if (rc) | 672 | if (rc) |
673 | goto err_out_iounmap; | 673 | goto err_out_iounmap; |
674 | 674 | ||
675 | probe_ent = kcalloc(1, sizeof(*probe_ent), GFP_KERNEL); | 675 | probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); |
676 | if (probe_ent == NULL) { | 676 | if (probe_ent == NULL) { |
677 | rc = -ENOMEM; | 677 | rc = -ENOMEM; |
678 | goto err_out_iounmap; | 678 | goto err_out_iounmap; |
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c index db32d15b7fa1..d89c9590b845 100644 --- a/drivers/ata/sata_svw.c +++ b/drivers/ata/sata_svw.c | |||
@@ -56,6 +56,8 @@ | |||
56 | #define DRV_VERSION "2.0" | 56 | #define DRV_VERSION "2.0" |
57 | 57 | ||
58 | enum { | 58 | enum { |
59 | K2_FLAG_NO_ATAPI_DMA = (1 << 29), | ||
60 | |||
59 | /* Taskfile registers offsets */ | 61 | /* Taskfile registers offsets */ |
60 | K2_SATA_TF_CMD_OFFSET = 0x00, | 62 | K2_SATA_TF_CMD_OFFSET = 0x00, |
61 | K2_SATA_TF_DATA_OFFSET = 0x00, | 63 | K2_SATA_TF_DATA_OFFSET = 0x00, |
@@ -83,11 +85,33 @@ enum { | |||
83 | 85 | ||
84 | /* Port stride */ | 86 | /* Port stride */ |
85 | K2_SATA_PORT_OFFSET = 0x100, | 87 | K2_SATA_PORT_OFFSET = 0x100, |
88 | |||
89 | board_svw4 = 0, | ||
90 | board_svw8 = 1, | ||
91 | }; | ||
92 | |||
93 | static const struct k2_board_info { | ||
94 | unsigned int n_ports; | ||
95 | unsigned long port_flags; | ||
96 | } k2_board_info[] = { | ||
97 | /* board_svw4 */ | ||
98 | { 4, K2_FLAG_NO_ATAPI_DMA }, | ||
99 | |||
100 | /* board_svw8 */ | ||
101 | { 8, K2_FLAG_NO_ATAPI_DMA }, | ||
86 | }; | 102 | }; |
87 | 103 | ||
88 | static u8 k2_stat_check_status(struct ata_port *ap); | 104 | static u8 k2_stat_check_status(struct ata_port *ap); |
89 | 105 | ||
90 | 106 | ||
107 | static int k2_sata_check_atapi_dma(struct ata_queued_cmd *qc) | ||
108 | { | ||
109 | if (qc->ap->flags & K2_FLAG_NO_ATAPI_DMA) | ||
110 | return -1; /* ATAPI DMA not supported */ | ||
111 | |||
112 | return 0; | ||
113 | } | ||
114 | |||
91 | static u32 k2_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) | 115 | static u32 k2_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) |
92 | { | 116 | { |
93 | if (sc_reg > SCR_CONTROL) | 117 | if (sc_reg > SCR_CONTROL) |
@@ -313,6 +337,7 @@ static const struct ata_port_operations k2_sata_ops = { | |||
313 | .check_status = k2_stat_check_status, | 337 | .check_status = k2_stat_check_status, |
314 | .exec_command = ata_exec_command, | 338 | .exec_command = ata_exec_command, |
315 | .dev_select = ata_std_dev_select, | 339 | .dev_select = ata_std_dev_select, |
340 | .check_atapi_dma = k2_sata_check_atapi_dma, | ||
316 | .bmdma_setup = k2_bmdma_setup_mmio, | 341 | .bmdma_setup = k2_bmdma_setup_mmio, |
317 | .bmdma_start = k2_bmdma_start_mmio, | 342 | .bmdma_start = k2_bmdma_start_mmio, |
318 | .bmdma_stop = ata_bmdma_stop, | 343 | .bmdma_stop = ata_bmdma_stop, |
@@ -359,6 +384,8 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
359 | struct ata_probe_ent *probe_ent = NULL; | 384 | struct ata_probe_ent *probe_ent = NULL; |
360 | unsigned long base; | 385 | unsigned long base; |
361 | void __iomem *mmio_base; | 386 | void __iomem *mmio_base; |
387 | const struct k2_board_info *board_info = | ||
388 | &k2_board_info[ent->driver_data]; | ||
362 | int pci_dev_busy = 0; | 389 | int pci_dev_busy = 0; |
363 | int rc; | 390 | int rc; |
364 | int i; | 391 | int i; |
@@ -424,7 +451,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
424 | 451 | ||
425 | probe_ent->sht = &k2_sata_sht; | 452 | probe_ent->sht = &k2_sata_sht; |
426 | probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 453 | probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
427 | ATA_FLAG_MMIO; | 454 | ATA_FLAG_MMIO | board_info->port_flags; |
428 | probe_ent->port_ops = &k2_sata_ops; | 455 | probe_ent->port_ops = &k2_sata_ops; |
429 | probe_ent->n_ports = 4; | 456 | probe_ent->n_ports = 4; |
430 | probe_ent->irq = pdev->irq; | 457 | probe_ent->irq = pdev->irq; |
@@ -441,7 +468,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
441 | /* different controllers have different number of ports - currently 4 or 8 */ | 468 | /* different controllers have different number of ports - currently 4 or 8 */ |
442 | /* All ports are on the same function. Multi-function device is no | 469 | /* All ports are on the same function. Multi-function device is no |
443 | * longer available. This should not be seen in any system. */ | 470 | * longer available. This should not be seen in any system. */ |
444 | for (i = 0; i < ent->driver_data; i++) | 471 | for (i = 0; i < board_info->n_ports; i++) |
445 | k2_sata_setup_port(&probe_ent->port[i], base + i * K2_SATA_PORT_OFFSET); | 472 | k2_sata_setup_port(&probe_ent->port[i], base + i * K2_SATA_PORT_OFFSET); |
446 | 473 | ||
447 | pci_set_master(pdev); | 474 | pci_set_master(pdev); |
@@ -469,11 +496,11 @@ err_out: | |||
469 | * controller | 496 | * controller |
470 | * */ | 497 | * */ |
471 | static const struct pci_device_id k2_sata_pci_tbl[] = { | 498 | static const struct pci_device_id k2_sata_pci_tbl[] = { |
472 | { PCI_VDEVICE(SERVERWORKS, 0x0240), 4 }, | 499 | { PCI_VDEVICE(SERVERWORKS, 0x0240), board_svw4 }, |
473 | { PCI_VDEVICE(SERVERWORKS, 0x0241), 4 }, | 500 | { PCI_VDEVICE(SERVERWORKS, 0x0241), board_svw4 }, |
474 | { PCI_VDEVICE(SERVERWORKS, 0x0242), 8 }, | 501 | { PCI_VDEVICE(SERVERWORKS, 0x0242), board_svw8 }, |
475 | { PCI_VDEVICE(SERVERWORKS, 0x024a), 4 }, | 502 | { PCI_VDEVICE(SERVERWORKS, 0x024a), board_svw4 }, |
476 | { PCI_VDEVICE(SERVERWORKS, 0x024b), 4 }, | 503 | { PCI_VDEVICE(SERVERWORKS, 0x024b), board_svw4 }, |
477 | 504 | ||
478 | { } | 505 | { } |
479 | }; | 506 | }; |
diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c index bc1b13c8f5d7..5aab7bd473ac 100644 --- a/drivers/atm/eni.c +++ b/drivers/atm/eni.c | |||
@@ -1832,7 +1832,7 @@ static int __devinit eni_start(struct atm_dev *dev) | |||
1832 | /* initialize memory management */ | 1832 | /* initialize memory management */ |
1833 | buffer_mem = eni_dev->mem - (buf - eni_dev->ram); | 1833 | buffer_mem = eni_dev->mem - (buf - eni_dev->ram); |
1834 | eni_dev->free_list_size = buffer_mem/MID_MIN_BUF_SIZE/2; | 1834 | eni_dev->free_list_size = buffer_mem/MID_MIN_BUF_SIZE/2; |
1835 | eni_dev->free_list = (struct eni_free *) kmalloc( | 1835 | eni_dev->free_list = kmalloc( |
1836 | sizeof(struct eni_free)*(eni_dev->free_list_size+1),GFP_KERNEL); | 1836 | sizeof(struct eni_free)*(eni_dev->free_list_size+1),GFP_KERNEL); |
1837 | if (!eni_dev->free_list) { | 1837 | if (!eni_dev->free_list) { |
1838 | printk(KERN_ERR DEV_LABEL "(itf %d): couldn't get free page\n", | 1838 | printk(KERN_ERR DEV_LABEL "(itf %d): couldn't get free page\n", |
@@ -2232,7 +2232,7 @@ static int __devinit eni_init_one(struct pci_dev *pci_dev, | |||
2232 | goto out0; | 2232 | goto out0; |
2233 | } | 2233 | } |
2234 | 2234 | ||
2235 | eni_dev = (struct eni_dev *) kmalloc(sizeof(struct eni_dev),GFP_KERNEL); | 2235 | eni_dev = kmalloc(sizeof(struct eni_dev),GFP_KERNEL); |
2236 | if (!eni_dev) goto out0; | 2236 | if (!eni_dev) goto out0; |
2237 | if (!cpu_zeroes) { | 2237 | if (!cpu_zeroes) { |
2238 | cpu_zeroes = pci_alloc_consistent(pci_dev,ENI_ZEROES_SIZE, | 2238 | cpu_zeroes = pci_alloc_consistent(pci_dev,ENI_ZEROES_SIZE, |
diff --git a/drivers/atm/he.c b/drivers/atm/he.c index 7d9b4e52f0bf..db33f6f4dd2a 100644 --- a/drivers/atm/he.c +++ b/drivers/atm/he.c | |||
@@ -2351,7 +2351,7 @@ he_open(struct atm_vcc *vcc) | |||
2351 | 2351 | ||
2352 | cid = he_mkcid(he_dev, vpi, vci); | 2352 | cid = he_mkcid(he_dev, vpi, vci); |
2353 | 2353 | ||
2354 | he_vcc = (struct he_vcc *) kmalloc(sizeof(struct he_vcc), GFP_ATOMIC); | 2354 | he_vcc = kmalloc(sizeof(struct he_vcc), GFP_ATOMIC); |
2355 | if (he_vcc == NULL) { | 2355 | if (he_vcc == NULL) { |
2356 | hprintk("unable to allocate he_vcc during open\n"); | 2356 | hprintk("unable to allocate he_vcc during open\n"); |
2357 | return -ENOMEM; | 2357 | return -ENOMEM; |
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c index 267825501dfe..09f477d4237a 100644 --- a/drivers/atm/lanai.c +++ b/drivers/atm/lanai.c | |||
@@ -2602,7 +2602,7 @@ static int __devinit lanai_init_one(struct pci_dev *pci, | |||
2602 | struct atm_dev *atmdev; | 2602 | struct atm_dev *atmdev; |
2603 | int result; | 2603 | int result; |
2604 | 2604 | ||
2605 | lanai = (struct lanai_dev *) kmalloc(sizeof(*lanai), GFP_KERNEL); | 2605 | lanai = kmalloc(sizeof(*lanai), GFP_KERNEL); |
2606 | if (lanai == NULL) { | 2606 | if (lanai == NULL) { |
2607 | printk(KERN_ERR DEV_LABEL | 2607 | printk(KERN_ERR DEV_LABEL |
2608 | ": couldn't allocate dev_data structure!\n"); | 2608 | ": couldn't allocate dev_data structure!\n"); |
diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c index bd0904594805..aab9b3733d52 100644 --- a/drivers/atm/nicstar.c +++ b/drivers/atm/nicstar.c | |||
@@ -997,7 +997,7 @@ static scq_info *get_scq(int size, u32 scd) | |||
997 | if (size != VBR_SCQSIZE && size != CBR_SCQSIZE) | 997 | if (size != VBR_SCQSIZE && size != CBR_SCQSIZE) |
998 | return NULL; | 998 | return NULL; |
999 | 999 | ||
1000 | scq = (scq_info *) kmalloc(sizeof(scq_info), GFP_KERNEL); | 1000 | scq = kmalloc(sizeof(scq_info), GFP_KERNEL); |
1001 | if (scq == NULL) | 1001 | if (scq == NULL) |
1002 | return NULL; | 1002 | return NULL; |
1003 | scq->org = kmalloc(2 * size, GFP_KERNEL); | 1003 | scq->org = kmalloc(2 * size, GFP_KERNEL); |
@@ -1006,7 +1006,7 @@ static scq_info *get_scq(int size, u32 scd) | |||
1006 | kfree(scq); | 1006 | kfree(scq); |
1007 | return NULL; | 1007 | return NULL; |
1008 | } | 1008 | } |
1009 | scq->skb = (struct sk_buff **) kmalloc(sizeof(struct sk_buff *) * | 1009 | scq->skb = kmalloc(sizeof(struct sk_buff *) * |
1010 | (size / NS_SCQE_SIZE), GFP_KERNEL); | 1010 | (size / NS_SCQE_SIZE), GFP_KERNEL); |
1011 | if (scq->skb == NULL) | 1011 | if (scq->skb == NULL) |
1012 | { | 1012 | { |
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c index 7df0f373188e..756d4f760da3 100644 --- a/drivers/atm/zatm.c +++ b/drivers/atm/zatm.c | |||
@@ -996,7 +996,7 @@ static int start_tx(struct atm_dev *dev) | |||
996 | 996 | ||
997 | DPRINTK("start_tx\n"); | 997 | DPRINTK("start_tx\n"); |
998 | zatm_dev = ZATM_DEV(dev); | 998 | zatm_dev = ZATM_DEV(dev); |
999 | zatm_dev->tx_map = (struct atm_vcc **) kmalloc(sizeof(struct atm_vcc *)* | 999 | zatm_dev->tx_map = kmalloc(sizeof(struct atm_vcc *)* |
1000 | zatm_dev->chans,GFP_KERNEL); | 1000 | zatm_dev->chans,GFP_KERNEL); |
1001 | if (!zatm_dev->tx_map) return -ENOMEM; | 1001 | if (!zatm_dev->tx_map) return -ENOMEM; |
1002 | zatm_dev->tx_bw = ATM_OC3_PCR; | 1002 | zatm_dev->tx_bw = ATM_OC3_PCR; |
@@ -1591,7 +1591,7 @@ static int __devinit zatm_init_one(struct pci_dev *pci_dev, | |||
1591 | struct zatm_dev *zatm_dev; | 1591 | struct zatm_dev *zatm_dev; |
1592 | int ret = -ENOMEM; | 1592 | int ret = -ENOMEM; |
1593 | 1593 | ||
1594 | zatm_dev = (struct zatm_dev *) kmalloc(sizeof(*zatm_dev), GFP_KERNEL); | 1594 | zatm_dev = kmalloc(sizeof(*zatm_dev), GFP_KERNEL); |
1595 | if (!zatm_dev) { | 1595 | if (!zatm_dev) { |
1596 | printk(KERN_EMERG "%s: memory shortage\n", DEV_LABEL); | 1596 | printk(KERN_EMERG "%s: memory shortage\n", DEV_LABEL); |
1597 | goto out; | 1597 | goto out; |
diff --git a/drivers/base/class.c b/drivers/base/class.c index f098881f45b2..8bf2ca2e56b5 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -163,6 +163,8 @@ int class_register(struct class * cls) | |||
163 | void class_unregister(struct class * cls) | 163 | void class_unregister(struct class * cls) |
164 | { | 164 | { |
165 | pr_debug("device class '%s': unregistering\n", cls->name); | 165 | pr_debug("device class '%s': unregistering\n", cls->name); |
166 | if (cls->virtual_dir) | ||
167 | kobject_unregister(cls->virtual_dir); | ||
166 | remove_class_attrs(cls); | 168 | remove_class_attrs(cls); |
167 | subsystem_unregister(&cls->subsys); | 169 | subsystem_unregister(&cls->subsys); |
168 | } | 170 | } |
diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c index dbe0735f8c9e..f95d50277274 100644 --- a/drivers/base/dmapool.c +++ b/drivers/base/dmapool.c | |||
@@ -173,7 +173,7 @@ pool_alloc_page (struct dma_pool *pool, gfp_t mem_flags) | |||
173 | mapsize = (mapsize + BITS_PER_LONG - 1) / BITS_PER_LONG; | 173 | mapsize = (mapsize + BITS_PER_LONG - 1) / BITS_PER_LONG; |
174 | mapsize *= sizeof (long); | 174 | mapsize *= sizeof (long); |
175 | 175 | ||
176 | page = (struct dma_page *) kmalloc (mapsize + sizeof *page, mem_flags); | 176 | page = kmalloc(mapsize + sizeof *page, mem_flags); |
177 | if (!page) | 177 | if (!page) |
178 | return NULL; | 178 | return NULL; |
179 | page->vaddr = dma_alloc_coherent (pool->dev, | 179 | page->vaddr = dma_alloc_coherent (pool->dev, |
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index d1df4a087924..f9c903ba9fcd 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -212,7 +212,7 @@ EXPORT_SYMBOL_GPL(platform_device_add_resources); | |||
212 | * pointer. The memory associated with the platform data will be freed | 212 | * pointer. The memory associated with the platform data will be freed |
213 | * when the platform device is released. | 213 | * when the platform device is released. |
214 | */ | 214 | */ |
215 | int platform_device_add_data(struct platform_device *pdev, void *data, size_t size) | 215 | int platform_device_add_data(struct platform_device *pdev, const void *data, size_t size) |
216 | { | 216 | { |
217 | void *d; | 217 | void *d; |
218 | 218 | ||
@@ -473,7 +473,7 @@ EXPORT_SYMBOL_GPL(platform_driver_unregister); | |||
473 | * Returns zero if the driver registered and bound to a device, else returns | 473 | * Returns zero if the driver registered and bound to a device, else returns |
474 | * a negative error code and with the driver not registered. | 474 | * a negative error code and with the driver not registered. |
475 | */ | 475 | */ |
476 | int platform_driver_probe(struct platform_driver *drv, | 476 | int __init_or_module platform_driver_probe(struct platform_driver *drv, |
477 | int (*probe)(struct platform_device *)) | 477 | int (*probe)(struct platform_device *)) |
478 | { | 478 | { |
479 | int retval, code; | 479 | int retval, code; |
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index ce9cfcb6071c..58c1debf86f1 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig | |||
@@ -28,13 +28,6 @@ config ATARI_FLOPPY | |||
28 | tristate "Atari floppy support" | 28 | tristate "Atari floppy support" |
29 | depends on ATARI | 29 | depends on ATARI |
30 | 30 | ||
31 | config BLK_DEV_SWIM_IOP | ||
32 | bool "Macintosh IIfx/Quadra 900/Quadra 950 floppy support (EXPERIMENTAL)" | ||
33 | depends on MAC && EXPERIMENTAL && BROKEN | ||
34 | help | ||
35 | Say Y here to support the SWIM (Super Woz Integrated Machine) IOP | ||
36 | floppy controller on the Macintosh IIfx and Quadra 900/950. | ||
37 | |||
38 | config MAC_FLOPPY | 31 | config MAC_FLOPPY |
39 | tristate "Support for PowerMac floppy" | 32 | tristate "Support for PowerMac floppy" |
40 | depends on PPC_PMAC && !PPC_PMAC64 | 33 | depends on PPC_PMAC && !PPC_PMAC64 |
diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 410f259a8031..dd88e33c1eb1 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile | |||
@@ -9,7 +9,6 @@ obj-$(CONFIG_MAC_FLOPPY) += swim3.o | |||
9 | obj-$(CONFIG_BLK_DEV_FD) += floppy.o | 9 | obj-$(CONFIG_BLK_DEV_FD) += floppy.o |
10 | obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o | 10 | obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o |
11 | obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o | 11 | obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o |
12 | obj-$(CONFIG_BLK_DEV_SWIM_IOP) += swim_iop.o | ||
13 | obj-$(CONFIG_ATARI_ACSI) += acsi.o | 12 | obj-$(CONFIG_ATARI_ACSI) += acsi.o |
14 | obj-$(CONFIG_ATARI_SLM) += acsi_slm.o | 13 | obj-$(CONFIG_ATARI_SLM) += acsi_slm.o |
15 | obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o | 14 | obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o |
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index ee159edb6b88..d719a5d8f435 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -1039,7 +1039,7 @@ static int cciss_ioctl(struct inode *inode, struct file *filep, | |||
1039 | status = -ENOMEM; | 1039 | status = -ENOMEM; |
1040 | goto cleanup1; | 1040 | goto cleanup1; |
1041 | } | 1041 | } |
1042 | buff_size = (int *)kmalloc(MAXSGENTRIES * sizeof(int), | 1042 | buff_size = kmalloc(MAXSGENTRIES * sizeof(int), |
1043 | GFP_KERNEL); | 1043 | GFP_KERNEL); |
1044 | if (!buff_size) { | 1044 | if (!buff_size) { |
1045 | status = -ENOMEM; | 1045 | status = -ENOMEM; |
@@ -2837,7 +2837,7 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) | |||
2837 | if (err) { | 2837 | if (err) { |
2838 | printk(KERN_ERR "cciss: Cannot obtain PCI resources, " | 2838 | printk(KERN_ERR "cciss: Cannot obtain PCI resources, " |
2839 | "aborting\n"); | 2839 | "aborting\n"); |
2840 | goto err_out_disable_pdev; | 2840 | return err; |
2841 | } | 2841 | } |
2842 | 2842 | ||
2843 | subsystem_vendor_id = pdev->subsystem_vendor; | 2843 | subsystem_vendor_id = pdev->subsystem_vendor; |
@@ -2865,7 +2865,7 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) | |||
2865 | #ifdef CCISS_DEBUG | 2865 | #ifdef CCISS_DEBUG |
2866 | printk("address 0 = %x\n", c->paddr); | 2866 | printk("address 0 = %x\n", c->paddr); |
2867 | #endif /* CCISS_DEBUG */ | 2867 | #endif /* CCISS_DEBUG */ |
2868 | c->vaddr = remap_pci_mem(c->paddr, 200); | 2868 | c->vaddr = remap_pci_mem(c->paddr, 0x250); |
2869 | 2869 | ||
2870 | /* Wait for the board to become ready. (PCI hotplug needs this.) | 2870 | /* Wait for the board to become ready. (PCI hotplug needs this.) |
2871 | * We poll for up to 120 secs, once per 100ms. */ | 2871 | * We poll for up to 120 secs, once per 100ms. */ |
@@ -3004,11 +3004,12 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) | |||
3004 | } | 3004 | } |
3005 | return 0; | 3005 | return 0; |
3006 | 3006 | ||
3007 | err_out_free_res: | 3007 | err_out_free_res: |
3008 | /* | ||
3009 | * Deliberately omit pci_disable_device(): it does something nasty to | ||
3010 | * Smart Array controllers that pci_enable_device does not undo | ||
3011 | */ | ||
3008 | pci_release_regions(pdev); | 3012 | pci_release_regions(pdev); |
3009 | |||
3010 | err_out_disable_pdev: | ||
3011 | pci_disable_device(pdev); | ||
3012 | return err; | 3013 | return err; |
3013 | } | 3014 | } |
3014 | 3015 | ||
@@ -3382,8 +3383,11 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, | |||
3382 | if (drv->queue) | 3383 | if (drv->queue) |
3383 | blk_cleanup_queue(drv->queue); | 3384 | blk_cleanup_queue(drv->queue); |
3384 | } | 3385 | } |
3386 | /* | ||
3387 | * Deliberately omit pci_disable_device(): it does something nasty to | ||
3388 | * Smart Array controllers that pci_enable_device does not undo | ||
3389 | */ | ||
3385 | pci_release_regions(pdev); | 3390 | pci_release_regions(pdev); |
3386 | pci_disable_device(pdev); | ||
3387 | pci_set_drvdata(pdev, NULL); | 3391 | pci_set_drvdata(pdev, NULL); |
3388 | free_hba(i); | 3392 | free_hba(i); |
3389 | return -1; | 3393 | return -1; |
@@ -3452,8 +3456,11 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev) | |||
3452 | #ifdef CONFIG_CISS_SCSI_TAPE | 3456 | #ifdef CONFIG_CISS_SCSI_TAPE |
3453 | kfree(hba[i]->scsi_rejects.complete); | 3457 | kfree(hba[i]->scsi_rejects.complete); |
3454 | #endif | 3458 | #endif |
3459 | /* | ||
3460 | * Deliberately omit pci_disable_device(): it does something nasty to | ||
3461 | * Smart Array controllers that pci_enable_device does not undo | ||
3462 | */ | ||
3455 | pci_release_regions(pdev); | 3463 | pci_release_regions(pdev); |
3456 | pci_disable_device(pdev); | ||
3457 | pci_set_drvdata(pdev, NULL); | 3464 | pci_set_drvdata(pdev, NULL); |
3458 | free_hba(i); | 3465 | free_hba(i); |
3459 | } | 3466 | } |
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index d5f519ebbc08..b94cd1c32131 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c | |||
@@ -1625,7 +1625,7 @@ static void start_fwbk(int ctlr) | |||
1625 | " processing\n"); | 1625 | " processing\n"); |
1626 | /* Command does not return anything, but idasend command needs a | 1626 | /* Command does not return anything, but idasend command needs a |
1627 | buffer */ | 1627 | buffer */ |
1628 | id_ctlr_buf = (id_ctlr_t *)kmalloc(sizeof(id_ctlr_t), GFP_KERNEL); | 1628 | id_ctlr_buf = kmalloc(sizeof(id_ctlr_t), GFP_KERNEL); |
1629 | if(id_ctlr_buf==NULL) | 1629 | if(id_ctlr_buf==NULL) |
1630 | { | 1630 | { |
1631 | printk(KERN_WARNING "cpqarray: Out of memory. " | 1631 | printk(KERN_WARNING "cpqarray: Out of memory. " |
@@ -1660,14 +1660,14 @@ static void getgeometry(int ctlr) | |||
1660 | 1660 | ||
1661 | info_p->log_drv_map = 0; | 1661 | info_p->log_drv_map = 0; |
1662 | 1662 | ||
1663 | id_ldrive = (id_log_drv_t *)kmalloc(sizeof(id_log_drv_t), GFP_KERNEL); | 1663 | id_ldrive = kmalloc(sizeof(id_log_drv_t), GFP_KERNEL); |
1664 | if(id_ldrive == NULL) | 1664 | if(id_ldrive == NULL) |
1665 | { | 1665 | { |
1666 | printk( KERN_ERR "cpqarray: out of memory.\n"); | 1666 | printk( KERN_ERR "cpqarray: out of memory.\n"); |
1667 | return; | 1667 | return; |
1668 | } | 1668 | } |
1669 | 1669 | ||
1670 | id_ctlr_buf = (id_ctlr_t *)kmalloc(sizeof(id_ctlr_t), GFP_KERNEL); | 1670 | id_ctlr_buf = kmalloc(sizeof(id_ctlr_t), GFP_KERNEL); |
1671 | if(id_ctlr_buf == NULL) | 1671 | if(id_ctlr_buf == NULL) |
1672 | { | 1672 | { |
1673 | kfree(id_ldrive); | 1673 | kfree(id_ldrive); |
@@ -1675,7 +1675,7 @@ static void getgeometry(int ctlr) | |||
1675 | return; | 1675 | return; |
1676 | } | 1676 | } |
1677 | 1677 | ||
1678 | id_lstatus_buf = (sense_log_drv_stat_t *)kmalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL); | 1678 | id_lstatus_buf = kmalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL); |
1679 | if(id_lstatus_buf == NULL) | 1679 | if(id_lstatus_buf == NULL) |
1680 | { | 1680 | { |
1681 | kfree(id_ctlr_buf); | 1681 | kfree(id_ctlr_buf); |
@@ -1684,7 +1684,7 @@ static void getgeometry(int ctlr) | |||
1684 | return; | 1684 | return; |
1685 | } | 1685 | } |
1686 | 1686 | ||
1687 | sense_config_buf = (config_t *)kmalloc(sizeof(config_t), GFP_KERNEL); | 1687 | sense_config_buf = kmalloc(sizeof(config_t), GFP_KERNEL); |
1688 | if(sense_config_buf == NULL) | 1688 | if(sense_config_buf == NULL) |
1689 | { | 1689 | { |
1690 | kfree(id_lstatus_buf); | 1690 | kfree(id_lstatus_buf); |
diff --git a/drivers/block/swim_iop.c b/drivers/block/swim_iop.c deleted file mode 100644 index ed7b06cf3e68..000000000000 --- a/drivers/block/swim_iop.c +++ /dev/null | |||
@@ -1,578 +0,0 @@ | |||
1 | /* | ||
2 | * Driver for the SWIM (Super Woz Integrated Machine) IOP | ||
3 | * floppy controller on the Macintosh IIfx and Quadra 900/950 | ||
4 | * | ||
5 | * Written by Joshua M. Thompson (funaho@jurai.org) | ||
6 | * based on the SWIM3 driver (c) 1996 by Paul Mackerras. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version | ||
11 | * 2 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * 1999-06-12 (jmt) - Initial implementation. | ||
14 | */ | ||
15 | |||
16 | /* | ||
17 | * ------------------- | ||
18 | * Theory of Operation | ||
19 | * ------------------- | ||
20 | * | ||
21 | * Since the SWIM IOP is message-driven we implement a simple request queue | ||
22 | * system. One outstanding request may be queued at any given time (this is | ||
23 | * an IOP limitation); only when that request has completed can a new request | ||
24 | * be sent. | ||
25 | */ | ||
26 | |||
27 | #include <linux/stddef.h> | ||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/sched.h> | ||
30 | #include <linux/timer.h> | ||
31 | #include <linux/delay.h> | ||
32 | #include <linux/fd.h> | ||
33 | #include <linux/ioctl.h> | ||
34 | #include <linux/blkdev.h> | ||
35 | #include <asm/io.h> | ||
36 | #include <asm/uaccess.h> | ||
37 | #include <asm/mac_iop.h> | ||
38 | #include <asm/swim_iop.h> | ||
39 | |||
40 | #define DRIVER_VERSION "Version 0.1 (1999-06-12)" | ||
41 | |||
42 | #define MAX_FLOPPIES 4 | ||
43 | |||
44 | enum swim_state { | ||
45 | idle, | ||
46 | available, | ||
47 | revalidating, | ||
48 | transferring, | ||
49 | ejecting | ||
50 | }; | ||
51 | |||
52 | struct floppy_state { | ||
53 | enum swim_state state; | ||
54 | int drive_num; /* device number */ | ||
55 | int secpercyl; /* disk geometry information */ | ||
56 | int secpertrack; | ||
57 | int total_secs; | ||
58 | int write_prot; /* 1 if write-protected, 0 if not, -1 dunno */ | ||
59 | int ref_count; | ||
60 | struct timer_list timeout; | ||
61 | int ejected; | ||
62 | struct wait_queue *wait; | ||
63 | int wanted; | ||
64 | int timeout_pending; | ||
65 | }; | ||
66 | |||
67 | struct swim_iop_req { | ||
68 | int sent; | ||
69 | int complete; | ||
70 | __u8 command[32]; | ||
71 | struct floppy_state *fs; | ||
72 | void (*done)(struct swim_iop_req *); | ||
73 | }; | ||
74 | |||
75 | static struct swim_iop_req *current_req; | ||
76 | static int floppy_count; | ||
77 | |||
78 | static struct floppy_state floppy_states[MAX_FLOPPIES]; | ||
79 | static DEFINE_SPINLOCK(swim_iop_lock); | ||
80 | |||
81 | #define CURRENT elv_next_request(swim_queue) | ||
82 | |||
83 | static char *drive_names[7] = { | ||
84 | "not installed", /* DRV_NONE */ | ||
85 | "unknown (1)", /* DRV_UNKNOWN */ | ||
86 | "a 400K drive", /* DRV_400K */ | ||
87 | "an 800K drive" /* DRV_800K */ | ||
88 | "unknown (4)", /* ???? */ | ||
89 | "an FDHD", /* DRV_FDHD */ | ||
90 | "unknown (6)", /* ???? */ | ||
91 | "an Apple HD20" /* DRV_HD20 */ | ||
92 | }; | ||
93 | |||
94 | int swimiop_init(void); | ||
95 | static void swimiop_init_request(struct swim_iop_req *); | ||
96 | static int swimiop_send_request(struct swim_iop_req *); | ||
97 | static void swimiop_receive(struct iop_msg *); | ||
98 | static void swimiop_status_update(int, struct swim_drvstatus *); | ||
99 | static int swimiop_eject(struct floppy_state *fs); | ||
100 | |||
101 | static int floppy_ioctl(struct inode *inode, struct file *filp, | ||
102 | unsigned int cmd, unsigned long param); | ||
103 | static int floppy_open(struct inode *inode, struct file *filp); | ||
104 | static int floppy_release(struct inode *inode, struct file *filp); | ||
105 | static int floppy_check_change(struct gendisk *disk); | ||
106 | static int floppy_revalidate(struct gendisk *disk); | ||
107 | static int grab_drive(struct floppy_state *fs, enum swim_state state, | ||
108 | int interruptible); | ||
109 | static void release_drive(struct floppy_state *fs); | ||
110 | static void set_timeout(struct floppy_state *fs, int nticks, | ||
111 | void (*proc)(unsigned long)); | ||
112 | static void fd_request_timeout(unsigned long); | ||
113 | static void do_fd_request(request_queue_t * q); | ||
114 | static void start_request(struct floppy_state *fs); | ||
115 | |||
116 | static struct block_device_operations floppy_fops = { | ||
117 | .open = floppy_open, | ||
118 | .release = floppy_release, | ||
119 | .ioctl = floppy_ioctl, | ||
120 | .media_changed = floppy_check_change, | ||
121 | .revalidate_disk= floppy_revalidate, | ||
122 | }; | ||
123 | |||
124 | static struct request_queue *swim_queue; | ||
125 | /* | ||
126 | * SWIM IOP initialization | ||
127 | */ | ||
128 | |||
129 | int swimiop_init(void) | ||
130 | { | ||
131 | volatile struct swim_iop_req req; | ||
132 | struct swimcmd_status *cmd = (struct swimcmd_status *) &req.command[0]; | ||
133 | struct swim_drvstatus *ds = &cmd->status; | ||
134 | struct floppy_state *fs; | ||
135 | int i; | ||
136 | |||
137 | current_req = NULL; | ||
138 | floppy_count = 0; | ||
139 | |||
140 | if (!iop_ism_present) | ||
141 | return -ENODEV; | ||
142 | |||
143 | if (register_blkdev(FLOPPY_MAJOR, "fd")) | ||
144 | return -EBUSY; | ||
145 | |||
146 | swim_queue = blk_init_queue(do_fd_request, &swim_iop_lock); | ||
147 | if (!swim_queue) { | ||
148 | unregister_blkdev(FLOPPY_MAJOR, "fd"); | ||
149 | return -ENOMEM; | ||
150 | } | ||
151 | |||
152 | printk("SWIM-IOP: %s by Joshua M. Thompson (funaho@jurai.org)\n", | ||
153 | DRIVER_VERSION); | ||
154 | |||
155 | if (iop_listen(SWIM_IOP, SWIM_CHAN, swimiop_receive, "SWIM") != 0) { | ||
156 | printk(KERN_ERR "SWIM-IOP: IOP channel already in use; can't initialize.\n"); | ||
157 | unregister_blkdev(FLOPPY_MAJOR, "fd"); | ||
158 | blk_cleanup_queue(swim_queue); | ||
159 | return -EBUSY; | ||
160 | } | ||
161 | |||
162 | printk(KERN_ERR "SWIM_IOP: probing for installed drives.\n"); | ||
163 | |||
164 | for (i = 0 ; i < MAX_FLOPPIES ; i++) { | ||
165 | memset(&floppy_states[i], 0, sizeof(struct floppy_state)); | ||
166 | fs = &floppy_states[floppy_count]; | ||
167 | |||
168 | swimiop_init_request(&req); | ||
169 | cmd->code = CMD_STATUS; | ||
170 | cmd->drive_num = i + 1; | ||
171 | if (swimiop_send_request(&req) != 0) continue; | ||
172 | while (!req.complete); | ||
173 | if (cmd->error != 0) { | ||
174 | printk(KERN_ERR "SWIM-IOP: probe on drive %d returned error %d\n", i, (uint) cmd->error); | ||
175 | continue; | ||
176 | } | ||
177 | if (ds->installed != 0x01) continue; | ||
178 | printk("SWIM-IOP: drive %d is %s (%s, %s, %s, %s)\n", i, | ||
179 | drive_names[ds->info.type], | ||
180 | ds->info.external? "ext" : "int", | ||
181 | ds->info.scsi? "scsi" : "floppy", | ||
182 | ds->info.fixed? "fixed" : "removable", | ||
183 | ds->info.secondary? "secondary" : "primary"); | ||
184 | swimiop_status_update(floppy_count, ds); | ||
185 | fs->state = idle; | ||
186 | |||
187 | init_timer(&fs->timeout); | ||
188 | floppy_count++; | ||
189 | } | ||
190 | printk("SWIM-IOP: detected %d installed drives.\n", floppy_count); | ||
191 | |||
192 | for (i = 0; i < floppy_count; i++) { | ||
193 | struct gendisk *disk = alloc_disk(1); | ||
194 | if (!disk) | ||
195 | continue; | ||
196 | disk->major = FLOPPY_MAJOR; | ||
197 | disk->first_minor = i; | ||
198 | disk->fops = &floppy_fops; | ||
199 | sprintf(disk->disk_name, "fd%d", i); | ||
200 | disk->private_data = &floppy_states[i]; | ||
201 | disk->queue = swim_queue; | ||
202 | set_capacity(disk, 2880 * 2); | ||
203 | add_disk(disk); | ||
204 | } | ||
205 | |||
206 | return 0; | ||
207 | } | ||
208 | |||
209 | static void swimiop_init_request(struct swim_iop_req *req) | ||
210 | { | ||
211 | req->sent = 0; | ||
212 | req->complete = 0; | ||
213 | req->done = NULL; | ||
214 | } | ||
215 | |||
216 | static int swimiop_send_request(struct swim_iop_req *req) | ||
217 | { | ||
218 | unsigned long flags; | ||
219 | int err; | ||
220 | |||
221 | /* It's doubtful an interrupt routine would try to send */ | ||
222 | /* a SWIM request, but I'd rather play it safe here. */ | ||
223 | |||
224 | local_irq_save(flags); | ||
225 | |||
226 | if (current_req != NULL) { | ||
227 | local_irq_restore(flags); | ||
228 | return -ENOMEM; | ||
229 | } | ||
230 | |||
231 | current_req = req; | ||
232 | |||
233 | /* Interrupts should be back on for iop_send_message() */ | ||
234 | |||
235 | local_irq_restore(flags); | ||
236 | |||
237 | err = iop_send_message(SWIM_IOP, SWIM_CHAN, (void *) req, | ||
238 | sizeof(req->command), (__u8 *) &req->command[0], | ||
239 | swimiop_receive); | ||
240 | |||
241 | /* No race condition here; we own current_req at this point */ | ||
242 | |||
243 | if (err) { | ||
244 | current_req = NULL; | ||
245 | } else { | ||
246 | req->sent = 1; | ||
247 | } | ||
248 | return err; | ||
249 | } | ||
250 | |||
251 | /* | ||
252 | * Receive a SWIM message from the IOP. | ||
253 | * | ||
254 | * This will be called in two cases: | ||
255 | * | ||
256 | * 1. A message has been successfully sent to the IOP. | ||
257 | * 2. An unsolicited message was received from the IOP. | ||
258 | */ | ||
259 | |||
260 | void swimiop_receive(struct iop_msg *msg) | ||
261 | { | ||
262 | struct swim_iop_req *req; | ||
263 | struct swimmsg_status *sm; | ||
264 | struct swim_drvstatus *ds; | ||
265 | |||
266 | req = current_req; | ||
267 | |||
268 | switch(msg->status) { | ||
269 | case IOP_MSGSTATUS_COMPLETE: | ||
270 | memcpy(&req->command[0], &msg->reply[0], sizeof(req->command)); | ||
271 | req->complete = 1; | ||
272 | if (req->done) (*req->done)(req); | ||
273 | current_req = NULL; | ||
274 | break; | ||
275 | case IOP_MSGSTATUS_UNSOL: | ||
276 | sm = (struct swimmsg_status *) &msg->message[0]; | ||
277 | ds = &sm->status; | ||
278 | swimiop_status_update(sm->drive_num, ds); | ||
279 | iop_complete_message(msg); | ||
280 | break; | ||
281 | } | ||
282 | } | ||
283 | |||
284 | static void swimiop_status_update(int drive_num, struct swim_drvstatus *ds) | ||
285 | { | ||
286 | struct floppy_state *fs = &floppy_states[drive_num]; | ||
287 | |||
288 | fs->write_prot = (ds->write_prot == 0x80); | ||
289 | if ((ds->disk_in_drive != 0x01) && (ds->disk_in_drive != 0x02)) { | ||
290 | fs->ejected = 1; | ||
291 | } else { | ||
292 | fs->ejected = 0; | ||
293 | } | ||
294 | switch(ds->info.type) { | ||
295 | case DRV_400K: | ||
296 | fs->secpercyl = 10; | ||
297 | fs->secpertrack = 10; | ||
298 | fs->total_secs = 800; | ||
299 | break; | ||
300 | case DRV_800K: | ||
301 | fs->secpercyl = 20; | ||
302 | fs->secpertrack = 10; | ||
303 | fs->total_secs = 1600; | ||
304 | break; | ||
305 | case DRV_FDHD: | ||
306 | fs->secpercyl = 36; | ||
307 | fs->secpertrack = 18; | ||
308 | fs->total_secs = 2880; | ||
309 | break; | ||
310 | default: | ||
311 | fs->secpercyl = 0; | ||
312 | fs->secpertrack = 0; | ||
313 | fs->total_secs = 0; | ||
314 | break; | ||
315 | } | ||
316 | } | ||
317 | |||
318 | static int swimiop_eject(struct floppy_state *fs) | ||
319 | { | ||
320 | int err, n; | ||
321 | struct swim_iop_req req; | ||
322 | struct swimcmd_eject *cmd = (struct swimcmd_eject *) &req.command[0]; | ||
323 | |||
324 | err = grab_drive(fs, ejecting, 1); | ||
325 | if (err) return err; | ||
326 | |||
327 | swimiop_init_request(&req); | ||
328 | cmd->code = CMD_EJECT; | ||
329 | cmd->drive_num = fs->drive_num; | ||
330 | err = swimiop_send_request(&req); | ||
331 | if (err) { | ||
332 | release_drive(fs); | ||
333 | return err; | ||
334 | } | ||
335 | for (n = 2*HZ; n > 0; --n) { | ||
336 | if (req.complete) break; | ||
337 | if (signal_pending(current)) { | ||
338 | err = -EINTR; | ||
339 | break; | ||
340 | } | ||
341 | schedule_timeout_interruptible(1); | ||
342 | } | ||
343 | release_drive(fs); | ||
344 | return cmd->error; | ||
345 | } | ||
346 | |||
347 | static struct floppy_struct floppy_type = | ||
348 | { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,NULL }; /* 7 1.44MB 3.5" */ | ||
349 | |||
350 | static int floppy_ioctl(struct inode *inode, struct file *filp, | ||
351 | unsigned int cmd, unsigned long param) | ||
352 | { | ||
353 | struct floppy_state *fs = inode->i_bdev->bd_disk->private_data; | ||
354 | int err; | ||
355 | |||
356 | if ((cmd & 0x80) && !capable(CAP_SYS_ADMIN)) | ||
357 | return -EPERM; | ||
358 | |||
359 | switch (cmd) { | ||
360 | case FDEJECT: | ||
361 | if (fs->ref_count != 1) | ||
362 | return -EBUSY; | ||
363 | err = swimiop_eject(fs); | ||
364 | return err; | ||
365 | case FDGETPRM: | ||
366 | if (copy_to_user((void *) param, (void *) &floppy_type, | ||
367 | sizeof(struct floppy_struct))) | ||
368 | return -EFAULT; | ||
369 | return 0; | ||
370 | } | ||
371 | return -ENOTTY; | ||
372 | } | ||
373 | |||
374 | static int floppy_open(struct inode *inode, struct file *filp) | ||
375 | { | ||
376 | struct floppy_state *fs = inode->i_bdev->bd_disk->private_data; | ||
377 | |||
378 | if (fs->ref_count == -1 || filp->f_flags & O_EXCL) | ||
379 | return -EBUSY; | ||
380 | |||
381 | if ((filp->f_flags & O_NDELAY) == 0 && (filp->f_mode & 3)) { | ||
382 | check_disk_change(inode->i_bdev); | ||
383 | if (fs->ejected) | ||
384 | return -ENXIO; | ||
385 | } | ||
386 | |||
387 | if ((filp->f_mode & 2) && fs->write_prot) | ||
388 | return -EROFS; | ||
389 | |||
390 | if (filp->f_flags & O_EXCL) | ||
391 | fs->ref_count = -1; | ||
392 | else | ||
393 | ++fs->ref_count; | ||
394 | |||
395 | return 0; | ||
396 | } | ||
397 | |||
398 | static int floppy_release(struct inode *inode, struct file *filp) | ||
399 | { | ||
400 | struct floppy_state *fs = inode->i_bdev->bd_disk->private_data; | ||
401 | if (fs->ref_count > 0) | ||
402 | fs->ref_count--; | ||
403 | return 0; | ||
404 | } | ||
405 | |||
406 | static int floppy_check_change(struct gendisk *disk) | ||
407 | { | ||
408 | struct floppy_state *fs = disk->private_data; | ||
409 | return fs->ejected; | ||
410 | } | ||
411 | |||
412 | static int floppy_revalidate(struct gendisk *disk) | ||
413 | { | ||
414 | struct floppy_state *fs = disk->private_data; | ||
415 | grab_drive(fs, revalidating, 0); | ||
416 | /* yadda, yadda */ | ||
417 | release_drive(fs); | ||
418 | return 0; | ||
419 | } | ||
420 | |||
421 | static void floppy_off(unsigned int nr) | ||
422 | { | ||
423 | } | ||
424 | |||
425 | static int grab_drive(struct floppy_state *fs, enum swim_state state, | ||
426 | int interruptible) | ||
427 | { | ||
428 | unsigned long flags; | ||
429 | |||
430 | local_irq_save(flags); | ||
431 | if (fs->state != idle) { | ||
432 | ++fs->wanted; | ||
433 | while (fs->state != available) { | ||
434 | if (interruptible && signal_pending(current)) { | ||
435 | --fs->wanted; | ||
436 | local_irq_restore(flags); | ||
437 | return -EINTR; | ||
438 | } | ||
439 | interruptible_sleep_on(&fs->wait); | ||
440 | } | ||
441 | --fs->wanted; | ||
442 | } | ||
443 | fs->state = state; | ||
444 | local_irq_restore(flags); | ||
445 | return 0; | ||
446 | } | ||
447 | |||
448 | static void release_drive(struct floppy_state *fs) | ||
449 | { | ||
450 | unsigned long flags; | ||
451 | |||
452 | local_irq_save(flags); | ||
453 | fs->state = idle; | ||
454 | start_request(fs); | ||
455 | local_irq_restore(flags); | ||
456 | } | ||
457 | |||
458 | static void set_timeout(struct floppy_state *fs, int nticks, | ||
459 | void (*proc)(unsigned long)) | ||
460 | { | ||
461 | unsigned long flags; | ||
462 | |||
463 | local_irq_save(flags); | ||
464 | if (fs->timeout_pending) | ||
465 | del_timer(&fs->timeout); | ||
466 | init_timer(&fs->timeout); | ||
467 | fs->timeout.expires = jiffies + nticks; | ||
468 | fs->timeout.function = proc; | ||
469 | fs->timeout.data = (unsigned long) fs; | ||
470 | add_timer(&fs->timeout); | ||
471 | fs->timeout_pending = 1; | ||
472 | local_irq_restore(flags); | ||
473 | } | ||
474 | |||
475 | static void do_fd_request(request_queue_t * q) | ||
476 | { | ||
477 | int i; | ||
478 | |||
479 | for (i = 0 ; i < floppy_count ; i++) { | ||
480 | start_request(&floppy_states[i]); | ||
481 | } | ||
482 | } | ||
483 | |||
484 | static void fd_request_complete(struct swim_iop_req *req) | ||
485 | { | ||
486 | struct floppy_state *fs = req->fs; | ||
487 | struct swimcmd_rw *cmd = (struct swimcmd_rw *) &req->command[0]; | ||
488 | |||
489 | del_timer(&fs->timeout); | ||
490 | fs->timeout_pending = 0; | ||
491 | fs->state = idle; | ||
492 | if (cmd->error) { | ||
493 | printk(KERN_ERR "SWIM-IOP: error %d on read/write request.\n", cmd->error); | ||
494 | end_request(CURRENT, 0); | ||
495 | } else { | ||
496 | CURRENT->sector += cmd->num_blocks; | ||
497 | CURRENT->current_nr_sectors -= cmd->num_blocks; | ||
498 | if (CURRENT->current_nr_sectors <= 0) { | ||
499 | end_request(CURRENT, 1); | ||
500 | return; | ||
501 | } | ||
502 | } | ||
503 | start_request(fs); | ||
504 | } | ||
505 | |||
506 | static void fd_request_timeout(unsigned long data) | ||
507 | { | ||
508 | struct floppy_state *fs = (struct floppy_state *) data; | ||
509 | |||
510 | fs->timeout_pending = 0; | ||
511 | end_request(CURRENT, 0); | ||
512 | fs->state = idle; | ||
513 | } | ||
514 | |||
515 | static void start_request(struct floppy_state *fs) | ||
516 | { | ||
517 | volatile struct swim_iop_req req; | ||
518 | struct swimcmd_rw *cmd = (struct swimcmd_rw *) &req.command[0]; | ||
519 | |||
520 | if (fs->state == idle && fs->wanted) { | ||
521 | fs->state = available; | ||
522 | wake_up(&fs->wait); | ||
523 | return; | ||
524 | } | ||
525 | while (CURRENT && fs->state == idle) { | ||
526 | if (CURRENT->bh && !buffer_locked(CURRENT->bh)) | ||
527 | panic("floppy: block not locked"); | ||
528 | #if 0 | ||
529 | printk("do_fd_req: dev=%s cmd=%d sec=%ld nr_sec=%ld buf=%p\n", | ||
530 | CURRENT->rq_disk->disk_name, CURRENT->cmd, | ||
531 | CURRENT->sector, CURRENT->nr_sectors, CURRENT->buffer); | ||
532 | printk(" errors=%d current_nr_sectors=%ld\n", | ||
533 | CURRENT->errors, CURRENT->current_nr_sectors); | ||
534 | #endif | ||
535 | |||
536 | if (CURRENT->sector < 0 || CURRENT->sector >= fs->total_secs) { | ||
537 | end_request(CURRENT, 0); | ||
538 | continue; | ||
539 | } | ||
540 | if (CURRENT->current_nr_sectors == 0) { | ||
541 | end_request(CURRENT, 1); | ||
542 | continue; | ||
543 | } | ||
544 | if (fs->ejected) { | ||
545 | end_request(CURRENT, 0); | ||
546 | continue; | ||
547 | } | ||
548 | |||
549 | swimiop_init_request(&req); | ||
550 | req.fs = fs; | ||
551 | req.done = fd_request_complete; | ||
552 | |||
553 | if (CURRENT->cmd == WRITE) { | ||
554 | if (fs->write_prot) { | ||
555 | end_request(CURRENT, 0); | ||
556 | continue; | ||
557 | } | ||
558 | cmd->code = CMD_WRITE; | ||
559 | } else { | ||
560 | cmd->code = CMD_READ; | ||
561 | |||
562 | } | ||
563 | cmd->drive_num = fs->drive_num; | ||
564 | cmd->buffer = CURRENT->buffer; | ||
565 | cmd->first_block = CURRENT->sector; | ||
566 | cmd->num_blocks = CURRENT->current_nr_sectors; | ||
567 | |||
568 | if (swimiop_send_request(&req)) { | ||
569 | end_request(CURRENT, 0); | ||
570 | continue; | ||
571 | } | ||
572 | |||
573 | set_timeout(fs, HZ*CURRENT->current_nr_sectors, | ||
574 | fd_request_timeout); | ||
575 | |||
576 | fs->state = transferring; | ||
577 | } | ||
578 | } | ||
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 2df5cf4ec743..e4a2f8f3a1d7 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
@@ -1810,7 +1810,7 @@ static int dvd_read_disckey(struct cdrom_device_info *cdi, dvd_struct *s) | |||
1810 | 1810 | ||
1811 | size = sizeof(s->disckey.value) + 4; | 1811 | size = sizeof(s->disckey.value) + 4; |
1812 | 1812 | ||
1813 | if ((buf = (u_char *) kmalloc(size, GFP_KERNEL)) == NULL) | 1813 | if ((buf = kmalloc(size, GFP_KERNEL)) == NULL) |
1814 | return -ENOMEM; | 1814 | return -ENOMEM; |
1815 | 1815 | ||
1816 | init_cdrom_command(&cgc, buf, size, CGC_DATA_READ); | 1816 | init_cdrom_command(&cgc, buf, size, CGC_DATA_READ); |
@@ -1861,7 +1861,7 @@ static int dvd_read_manufact(struct cdrom_device_info *cdi, dvd_struct *s) | |||
1861 | 1861 | ||
1862 | size = sizeof(s->manufact.value) + 4; | 1862 | size = sizeof(s->manufact.value) + 4; |
1863 | 1863 | ||
1864 | if ((buf = (u_char *) kmalloc(size, GFP_KERNEL)) == NULL) | 1864 | if ((buf = kmalloc(size, GFP_KERNEL)) == NULL) |
1865 | return -ENOMEM; | 1865 | return -ENOMEM; |
1866 | 1866 | ||
1867 | init_cdrom_command(&cgc, buf, size, CGC_DATA_READ); | 1867 | init_cdrom_command(&cgc, buf, size, CGC_DATA_READ); |
@@ -2849,7 +2849,7 @@ static int mmc_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, | |||
2849 | /* FIXME: we need upper bound checking, too!! */ | 2849 | /* FIXME: we need upper bound checking, too!! */ |
2850 | if (lba < 0) | 2850 | if (lba < 0) |
2851 | return -EINVAL; | 2851 | return -EINVAL; |
2852 | cgc.buffer = (char *) kmalloc(blocksize, GFP_KERNEL); | 2852 | cgc.buffer = kmalloc(blocksize, GFP_KERNEL); |
2853 | if (cgc.buffer == NULL) | 2853 | if (cgc.buffer == NULL) |
2854 | return -ENOMEM; | 2854 | return -ENOMEM; |
2855 | memset(&sense, 0, sizeof(sense)); | 2855 | memset(&sense, 0, sizeof(sense)); |
@@ -3031,7 +3031,7 @@ static int mmc_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, | |||
3031 | int size = sizeof(dvd_struct); | 3031 | int size = sizeof(dvd_struct); |
3032 | if (!CDROM_CAN(CDC_DVD)) | 3032 | if (!CDROM_CAN(CDC_DVD)) |
3033 | return -ENOSYS; | 3033 | return -ENOSYS; |
3034 | if ((s = (dvd_struct *) kmalloc(size, GFP_KERNEL)) == NULL) | 3034 | if ((s = kmalloc(size, GFP_KERNEL)) == NULL) |
3035 | return -ENOMEM; | 3035 | return -ENOMEM; |
3036 | cdinfo(CD_DO_IOCTL, "entering DVD_READ_STRUCT\n"); | 3036 | cdinfo(CD_DO_IOCTL, "entering DVD_READ_STRUCT\n"); |
3037 | if (copy_from_user(s, (dvd_struct __user *)arg, size)) { | 3037 | if (copy_from_user(s, (dvd_struct __user *)arg, size)) { |
diff --git a/drivers/cdrom/cm206.c b/drivers/cdrom/cm206.c index e6d8e9ededea..b6c61bbb20e1 100644 --- a/drivers/cdrom/cm206.c +++ b/drivers/cdrom/cm206.c | |||
@@ -1420,7 +1420,7 @@ int __init cm206_init(void) | |||
1420 | return -EIO; | 1420 | return -EIO; |
1421 | } | 1421 | } |
1422 | printk(" adapter at 0x%x", cm206_base); | 1422 | printk(" adapter at 0x%x", cm206_base); |
1423 | cd = (struct cm206_struct *) kmalloc(size, GFP_KERNEL); | 1423 | cd = kmalloc(size, GFP_KERNEL); |
1424 | if (!cd) | 1424 | if (!cd) |
1425 | goto out_base; | 1425 | goto out_base; |
1426 | /* Now we have found the adaptor card, try to reset it. As we have | 1426 | /* Now we have found the adaptor card, try to reset it. As we have |
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 0a3aee29e067..9e43e39dc35c 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -97,7 +97,7 @@ config SERIAL_NONSTANDARD | |||
97 | 97 | ||
98 | config COMPUTONE | 98 | config COMPUTONE |
99 | tristate "Computone IntelliPort Plus serial support" | 99 | tristate "Computone IntelliPort Plus serial support" |
100 | depends on SERIAL_NONSTANDARD | 100 | depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI) |
101 | ---help--- | 101 | ---help--- |
102 | This driver supports the entire family of Intelliport II/Plus | 102 | This driver supports the entire family of Intelliport II/Plus |
103 | controllers with the exception of the MicroChannel controllers and | 103 | controllers with the exception of the MicroChannel controllers and |
@@ -203,7 +203,7 @@ config MOXA_SMARTIO | |||
203 | 203 | ||
204 | config MOXA_SMARTIO_NEW | 204 | config MOXA_SMARTIO_NEW |
205 | tristate "Moxa SmartIO support v. 2.0 (EXPERIMENTAL)" | 205 | tristate "Moxa SmartIO support v. 2.0 (EXPERIMENTAL)" |
206 | depends on SERIAL_NONSTANDARD | 206 | depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA) |
207 | help | 207 | help |
208 | Say Y here if you have a Moxa SmartIO multiport serial card and/or | 208 | Say Y here if you have a Moxa SmartIO multiport serial card and/or |
209 | want to help develop a new version of this driver. | 209 | want to help develop a new version of this driver. |
@@ -218,7 +218,7 @@ config MOXA_SMARTIO_NEW | |||
218 | 218 | ||
219 | config ISI | 219 | config ISI |
220 | tristate "Multi-Tech multiport card support (EXPERIMENTAL)" | 220 | tristate "Multi-Tech multiport card support (EXPERIMENTAL)" |
221 | depends on SERIAL_NONSTANDARD | 221 | depends on SERIAL_NONSTANDARD && PCI |
222 | select FW_LOADER | 222 | select FW_LOADER |
223 | help | 223 | help |
224 | This is a driver for the Multi-Tech cards which provide several | 224 | This is a driver for the Multi-Tech cards which provide several |
@@ -312,7 +312,7 @@ config SPECIALIX_RTSCTS | |||
312 | 312 | ||
313 | config SX | 313 | config SX |
314 | tristate "Specialix SX (and SI) card support" | 314 | tristate "Specialix SX (and SI) card support" |
315 | depends on SERIAL_NONSTANDARD | 315 | depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA) |
316 | help | 316 | help |
317 | This is a driver for the SX and SI multiport serial cards. | 317 | This is a driver for the SX and SI multiport serial cards. |
318 | Please read the file <file:Documentation/sx.txt> for details. | 318 | Please read the file <file:Documentation/sx.txt> for details. |
diff --git a/drivers/char/consolemap.c b/drivers/char/consolemap.c index 04a12027a740..b99b7561260d 100644 --- a/drivers/char/consolemap.c +++ b/drivers/char/consolemap.c | |||
@@ -443,7 +443,7 @@ int con_clear_unimap(struct vc_data *vc, struct unimapinit *ui) | |||
443 | p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc; | 443 | p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc; |
444 | if (p && p->readonly) return -EIO; | 444 | if (p && p->readonly) return -EIO; |
445 | if (!p || --p->refcount) { | 445 | if (!p || --p->refcount) { |
446 | q = (struct uni_pagedir *)kmalloc(sizeof(*p), GFP_KERNEL); | 446 | q = kmalloc(sizeof(*p), GFP_KERNEL); |
447 | if (!q) { | 447 | if (!q) { |
448 | if (p) p->refcount++; | 448 | if (p) p->refcount++; |
449 | return -ENOMEM; | 449 | return -ENOMEM; |
diff --git a/drivers/char/lcd.c b/drivers/char/lcd.c index da601fd6c07a..d649abbf0857 100644 --- a/drivers/char/lcd.c +++ b/drivers/char/lcd.c | |||
@@ -459,7 +459,7 @@ static int lcd_ioctl(struct inode *inode, struct file *file, | |||
459 | (&display, (struct lcd_display *) arg, | 459 | (&display, (struct lcd_display *) arg, |
460 | sizeof(struct lcd_display))) | 460 | sizeof(struct lcd_display))) |
461 | return -EFAULT; | 461 | return -EFAULT; |
462 | rom = (unsigned char *) kmalloc((128), GFP_ATOMIC); | 462 | rom = kmalloc((128), GFP_ATOMIC); |
463 | if (rom == NULL) { | 463 | if (rom == NULL) { |
464 | printk(KERN_ERR LCD "kmalloc() failed in %s\n", | 464 | printk(KERN_ERR LCD "kmalloc() failed in %s\n", |
465 | __FUNCTION__); | 465 | __FUNCTION__); |
diff --git a/drivers/char/lp.c b/drivers/char/lp.c index b70b5388b5a8..b51d08be0bcf 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c | |||
@@ -525,7 +525,7 @@ static int lp_open(struct inode * inode, struct file * file) | |||
525 | return -EIO; | 525 | return -EIO; |
526 | } | 526 | } |
527 | } | 527 | } |
528 | lp_table[minor].lp_buffer = (char *) kmalloc(LP_BUFFER_SIZE, GFP_KERNEL); | 528 | lp_table[minor].lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL); |
529 | if (!lp_table[minor].lp_buffer) { | 529 | if (!lp_table[minor].lp_buffer) { |
530 | LP_F(minor) &= ~LP_BUSY; | 530 | LP_F(minor) &= ~LP_BUSY; |
531 | return -ENOMEM; | 531 | return -ENOMEM; |
diff --git a/drivers/char/mxser_new.c b/drivers/char/mxser_new.c index efa8076c33e0..cd989dce7c53 100644 --- a/drivers/char/mxser_new.c +++ b/drivers/char/mxser_new.c | |||
@@ -315,6 +315,7 @@ static struct mxser_mon_ext mon_data_ext; | |||
315 | static int mxser_set_baud_method[MXSER_PORTS + 1]; | 315 | static int mxser_set_baud_method[MXSER_PORTS + 1]; |
316 | static spinlock_t gm_lock; | 316 | static spinlock_t gm_lock; |
317 | 317 | ||
318 | #ifdef CONFIG_PCI | ||
318 | static int CheckIsMoxaMust(int io) | 319 | static int CheckIsMoxaMust(int io) |
319 | { | 320 | { |
320 | u8 oldmcr, hwid; | 321 | u8 oldmcr, hwid; |
@@ -337,6 +338,7 @@ static int CheckIsMoxaMust(int io) | |||
337 | } | 338 | } |
338 | return MOXA_OTHER_UART; | 339 | return MOXA_OTHER_UART; |
339 | } | 340 | } |
341 | #endif | ||
340 | 342 | ||
341 | static void process_txrx_fifo(struct mxser_port *info) | 343 | static void process_txrx_fifo(struct mxser_port *info) |
342 | { | 344 | { |
@@ -2380,9 +2382,11 @@ static void mxser_release_res(struct mxser_board *brd, struct pci_dev *pdev, | |||
2380 | if (irq) | 2382 | if (irq) |
2381 | free_irq(brd->irq, brd); | 2383 | free_irq(brd->irq, brd); |
2382 | if (pdev != NULL) { /* PCI */ | 2384 | if (pdev != NULL) { /* PCI */ |
2385 | #ifdef CONFIG_PCI | ||
2383 | pci_release_region(pdev, 2); | 2386 | pci_release_region(pdev, 2); |
2384 | pci_release_region(pdev, 3); | 2387 | pci_release_region(pdev, 3); |
2385 | pci_dev_put(pdev); | 2388 | pci_dev_put(pdev); |
2389 | #endif | ||
2386 | } else { | 2390 | } else { |
2387 | release_region(brd->ports[0].ioaddr, 8 * brd->info->nports); | 2391 | release_region(brd->ports[0].ioaddr, 8 * brd->info->nports); |
2388 | release_region(brd->vector, 1); | 2392 | release_region(brd->vector, 1); |
@@ -2546,6 +2550,7 @@ static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd) | |||
2546 | static int __devinit mxser_probe(struct pci_dev *pdev, | 2550 | static int __devinit mxser_probe(struct pci_dev *pdev, |
2547 | const struct pci_device_id *ent) | 2551 | const struct pci_device_id *ent) |
2548 | { | 2552 | { |
2553 | #ifdef CONFIG_PCI | ||
2549 | struct mxser_board *brd; | 2554 | struct mxser_board *brd; |
2550 | unsigned int i, j; | 2555 | unsigned int i, j; |
2551 | unsigned long ioaddress; | 2556 | unsigned long ioaddress; |
@@ -2644,6 +2649,9 @@ err_relio: | |||
2644 | brd->info = NULL; | 2649 | brd->info = NULL; |
2645 | err: | 2650 | err: |
2646 | return retval; | 2651 | return retval; |
2652 | #else | ||
2653 | return -ENODEV; | ||
2654 | #endif | ||
2647 | } | 2655 | } |
2648 | 2656 | ||
2649 | static void __devexit mxser_remove(struct pci_dev *pdev) | 2657 | static void __devexit mxser_remove(struct pci_dev *pdev) |
diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c index 103d338f21e2..dc6d41841457 100644 --- a/drivers/char/n_r3964.c +++ b/drivers/char/n_r3964.c | |||
@@ -125,8 +125,8 @@ static void transmit_block(struct r3964_info *pInfo); | |||
125 | static void receive_char(struct r3964_info *pInfo, const unsigned char c); | 125 | static void receive_char(struct r3964_info *pInfo, const unsigned char c); |
126 | static void receive_error(struct r3964_info *pInfo, const char flag); | 126 | static void receive_error(struct r3964_info *pInfo, const char flag); |
127 | static void on_timeout(unsigned long priv); | 127 | static void on_timeout(unsigned long priv); |
128 | static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg); | 128 | static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg); |
129 | static int read_telegram(struct r3964_info *pInfo, pid_t pid, unsigned char __user *buf); | 129 | static int read_telegram(struct r3964_info *pInfo, struct pid *pid, unsigned char __user *buf); |
130 | static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg, | 130 | static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg, |
131 | int error_code, struct r3964_block_header *pBlock); | 131 | int error_code, struct r3964_block_header *pBlock); |
132 | static struct r3964_message* remove_msg(struct r3964_info *pInfo, | 132 | static struct r3964_message* remove_msg(struct r3964_info *pInfo, |
@@ -829,7 +829,7 @@ static void on_timeout(unsigned long priv) | |||
829 | } | 829 | } |
830 | 830 | ||
831 | static struct r3964_client_info *findClient( | 831 | static struct r3964_client_info *findClient( |
832 | struct r3964_info *pInfo, pid_t pid) | 832 | struct r3964_info *pInfo, struct pid *pid) |
833 | { | 833 | { |
834 | struct r3964_client_info *pClient; | 834 | struct r3964_client_info *pClient; |
835 | 835 | ||
@@ -843,7 +843,7 @@ static struct r3964_client_info *findClient( | |||
843 | return NULL; | 843 | return NULL; |
844 | } | 844 | } |
845 | 845 | ||
846 | static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg) | 846 | static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg) |
847 | { | 847 | { |
848 | struct r3964_client_info *pClient; | 848 | struct r3964_client_info *pClient; |
849 | struct r3964_client_info **ppClient; | 849 | struct r3964_client_info **ppClient; |
@@ -858,7 +858,7 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg) | |||
858 | 858 | ||
859 | if(pClient->pid == pid) | 859 | if(pClient->pid == pid) |
860 | { | 860 | { |
861 | TRACE_PS("removing client %d from client list", pid); | 861 | TRACE_PS("removing client %d from client list", pid_nr(pid)); |
862 | *ppClient = pClient->next; | 862 | *ppClient = pClient->next; |
863 | while(pClient->msg_count) | 863 | while(pClient->msg_count) |
864 | { | 864 | { |
@@ -869,6 +869,7 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg) | |||
869 | TRACE_M("enable_signals - msg kfree %p",pMsg); | 869 | TRACE_M("enable_signals - msg kfree %p",pMsg); |
870 | } | 870 | } |
871 | } | 871 | } |
872 | put_pid(pClient->pid); | ||
872 | kfree(pClient); | 873 | kfree(pClient); |
873 | TRACE_M("enable_signals - kfree %p",pClient); | 874 | TRACE_M("enable_signals - kfree %p",pClient); |
874 | return 0; | 875 | return 0; |
@@ -892,10 +893,10 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg) | |||
892 | if(pClient==NULL) | 893 | if(pClient==NULL) |
893 | return -ENOMEM; | 894 | return -ENOMEM; |
894 | 895 | ||
895 | TRACE_PS("add client %d to client list", pid); | 896 | TRACE_PS("add client %d to client list", pid_nr(pid)); |
896 | spin_lock_init(&pClient->lock); | 897 | spin_lock_init(&pClient->lock); |
897 | pClient->sig_flags=arg; | 898 | pClient->sig_flags=arg; |
898 | pClient->pid = pid; | 899 | pClient->pid = get_pid(pid); |
899 | pClient->next=pInfo->firstClient; | 900 | pClient->next=pInfo->firstClient; |
900 | pClient->first_msg = NULL; | 901 | pClient->first_msg = NULL; |
901 | pClient->last_msg = NULL; | 902 | pClient->last_msg = NULL; |
@@ -908,7 +909,7 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg) | |||
908 | return 0; | 909 | return 0; |
909 | } | 910 | } |
910 | 911 | ||
911 | static int read_telegram(struct r3964_info *pInfo, pid_t pid, unsigned char __user *buf) | 912 | static int read_telegram(struct r3964_info *pInfo, struct pid *pid, unsigned char __user *buf) |
912 | { | 913 | { |
913 | struct r3964_client_info *pClient; | 914 | struct r3964_client_info *pClient; |
914 | struct r3964_block_header *block; | 915 | struct r3964_block_header *block; |
@@ -1005,7 +1006,7 @@ queue_the_message: | |||
1005 | /* Send SIGIO signal to client process: */ | 1006 | /* Send SIGIO signal to client process: */ |
1006 | if(pClient->sig_flags & R3964_USE_SIGIO) | 1007 | if(pClient->sig_flags & R3964_USE_SIGIO) |
1007 | { | 1008 | { |
1008 | kill_proc(pClient->pid, SIGIO, 1); | 1009 | kill_pid(pClient->pid, SIGIO, 1); |
1009 | } | 1010 | } |
1010 | } | 1011 | } |
1011 | 1012 | ||
@@ -1042,7 +1043,7 @@ static void remove_client_block(struct r3964_info *pInfo, | |||
1042 | { | 1043 | { |
1043 | struct r3964_block_header *block; | 1044 | struct r3964_block_header *block; |
1044 | 1045 | ||
1045 | TRACE_PS("remove_client_block PID %d", pClient->pid); | 1046 | TRACE_PS("remove_client_block PID %d", pid_nr(pClient->pid)); |
1046 | 1047 | ||
1047 | block=pClient->next_block_to_read; | 1048 | block=pClient->next_block_to_read; |
1048 | if(block) | 1049 | if(block) |
@@ -1157,6 +1158,7 @@ static void r3964_close(struct tty_struct *tty) | |||
1157 | TRACE_M("r3964_close - msg kfree %p",pMsg); | 1158 | TRACE_M("r3964_close - msg kfree %p",pMsg); |
1158 | } | 1159 | } |
1159 | } | 1160 | } |
1161 | put_pid(pClient->pid); | ||
1160 | kfree(pClient); | 1162 | kfree(pClient); |
1161 | TRACE_M("r3964_close - client kfree %p",pClient); | 1163 | TRACE_M("r3964_close - client kfree %p",pClient); |
1162 | pClient=pNext; | 1164 | pClient=pNext; |
@@ -1193,12 +1195,11 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file, | |||
1193 | struct r3964_client_message theMsg; | 1195 | struct r3964_client_message theMsg; |
1194 | DECLARE_WAITQUEUE (wait, current); | 1196 | DECLARE_WAITQUEUE (wait, current); |
1195 | 1197 | ||
1196 | int pid = current->pid; | ||
1197 | int count; | 1198 | int count; |
1198 | 1199 | ||
1199 | TRACE_L("read()"); | 1200 | TRACE_L("read()"); |
1200 | 1201 | ||
1201 | pClient=findClient(pInfo, pid); | 1202 | pClient=findClient(pInfo, task_pid(current)); |
1202 | if(pClient) | 1203 | if(pClient) |
1203 | { | 1204 | { |
1204 | pMsg = remove_msg(pInfo, pClient); | 1205 | pMsg = remove_msg(pInfo, pClient); |
@@ -1252,7 +1253,6 @@ static ssize_t r3964_write(struct tty_struct * tty, struct file * file, | |||
1252 | struct r3964_block_header *pHeader; | 1253 | struct r3964_block_header *pHeader; |
1253 | struct r3964_client_info *pClient; | 1254 | struct r3964_client_info *pClient; |
1254 | unsigned char *new_data; | 1255 | unsigned char *new_data; |
1255 | int pid; | ||
1256 | 1256 | ||
1257 | TRACE_L("write request, %d characters", count); | 1257 | TRACE_L("write request, %d characters", count); |
1258 | /* | 1258 | /* |
@@ -1295,9 +1295,7 @@ static ssize_t r3964_write(struct tty_struct * tty, struct file * file, | |||
1295 | pHeader->locks = 0; | 1295 | pHeader->locks = 0; |
1296 | pHeader->owner = NULL; | 1296 | pHeader->owner = NULL; |
1297 | 1297 | ||
1298 | pid=current->pid; | 1298 | pClient=findClient(pInfo, task_pid(current)); |
1299 | |||
1300 | pClient=findClient(pInfo, pid); | ||
1301 | if(pClient) | 1299 | if(pClient) |
1302 | { | 1300 | { |
1303 | pHeader->owner = pClient; | 1301 | pHeader->owner = pClient; |
@@ -1328,7 +1326,7 @@ static int r3964_ioctl(struct tty_struct * tty, struct file * file, | |||
1328 | switch(cmd) | 1326 | switch(cmd) |
1329 | { | 1327 | { |
1330 | case R3964_ENABLE_SIGNALS: | 1328 | case R3964_ENABLE_SIGNALS: |
1331 | return enable_signals(pInfo, current->pid, arg); | 1329 | return enable_signals(pInfo, task_pid(current), arg); |
1332 | case R3964_SETPRIORITY: | 1330 | case R3964_SETPRIORITY: |
1333 | if(arg<R3964_MASTER || arg>R3964_SLAVE) | 1331 | if(arg<R3964_MASTER || arg>R3964_SLAVE) |
1334 | return -EINVAL; | 1332 | return -EINVAL; |
@@ -1341,7 +1339,7 @@ static int r3964_ioctl(struct tty_struct * tty, struct file * file, | |||
1341 | pInfo->flags &= ~R3964_BCC; | 1339 | pInfo->flags &= ~R3964_BCC; |
1342 | return 0; | 1340 | return 0; |
1343 | case R3964_READ_TELEGRAM: | 1341 | case R3964_READ_TELEGRAM: |
1344 | return read_telegram(pInfo, current->pid, (unsigned char __user *)arg); | 1342 | return read_telegram(pInfo, task_pid(current), (unsigned char __user *)arg); |
1345 | default: | 1343 | default: |
1346 | return -ENOIOCTLCMD; | 1344 | return -ENOIOCTLCMD; |
1347 | } | 1345 | } |
@@ -1357,7 +1355,6 @@ static unsigned int r3964_poll(struct tty_struct * tty, struct file * file, | |||
1357 | struct poll_table_struct *wait) | 1355 | struct poll_table_struct *wait) |
1358 | { | 1356 | { |
1359 | struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data; | 1357 | struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data; |
1360 | int pid=current->pid; | ||
1361 | struct r3964_client_info *pClient; | 1358 | struct r3964_client_info *pClient; |
1362 | struct r3964_message *pMsg=NULL; | 1359 | struct r3964_message *pMsg=NULL; |
1363 | unsigned long flags; | 1360 | unsigned long flags; |
@@ -1365,7 +1362,7 @@ static unsigned int r3964_poll(struct tty_struct * tty, struct file * file, | |||
1365 | 1362 | ||
1366 | TRACE_L("POLL"); | 1363 | TRACE_L("POLL"); |
1367 | 1364 | ||
1368 | pClient=findClient(pInfo,pid); | 1365 | pClient=findClient(pInfo, task_pid(current)); |
1369 | if(pClient) | 1366 | if(pClient) |
1370 | { | 1367 | { |
1371 | poll_wait(file, &pInfo->read_wait, wait); | 1368 | poll_wait(file, &pInfo->read_wait, wait); |
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index e96a00fe1389..2bdb0144a22e 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c | |||
@@ -1151,7 +1151,6 @@ static int copy_from_read_buf(struct tty_struct *tty, | |||
1151 | n = min(*nr, n); | 1151 | n = min(*nr, n); |
1152 | spin_unlock_irqrestore(&tty->read_lock, flags); | 1152 | spin_unlock_irqrestore(&tty->read_lock, flags); |
1153 | if (n) { | 1153 | if (n) { |
1154 | mb(); | ||
1155 | retval = copy_to_user(*b, &tty->read_buf[tty->read_tail], n); | 1154 | retval = copy_to_user(*b, &tty->read_buf[tty->read_tail], n); |
1156 | n -= retval; | 1155 | n -= retval; |
1157 | spin_lock_irqsave(&tty->read_lock, flags); | 1156 | spin_lock_irqsave(&tty->read_lock, flags); |
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 5152cedd8878..f108c136800a 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -541,7 +541,7 @@ static int mgslpc_probe(struct pcmcia_device *link) | |||
541 | if (debug_level >= DEBUG_LEVEL_INFO) | 541 | if (debug_level >= DEBUG_LEVEL_INFO) |
542 | printk("mgslpc_attach\n"); | 542 | printk("mgslpc_attach\n"); |
543 | 543 | ||
544 | info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL); | 544 | info = kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL); |
545 | if (!info) { | 545 | if (!info) { |
546 | printk("Error can't allocate device instance data\n"); | 546 | printk("Error can't allocate device instance data\n"); |
547 | return -ENOMEM; | 547 | return -ENOMEM; |
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c index 167ebc84e8d7..245f03195b7c 100644 --- a/drivers/char/rio/riocmd.c +++ b/drivers/char/rio/riocmd.c | |||
@@ -556,7 +556,7 @@ struct CmdBlk *RIOGetCmdBlk(void) | |||
556 | { | 556 | { |
557 | struct CmdBlk *CmdBlkP; | 557 | struct CmdBlk *CmdBlkP; |
558 | 558 | ||
559 | CmdBlkP = (struct CmdBlk *)kmalloc(sizeof(struct CmdBlk), GFP_ATOMIC); | 559 | CmdBlkP = kmalloc(sizeof(struct CmdBlk), GFP_ATOMIC); |
560 | if (CmdBlkP) | 560 | if (CmdBlkP) |
561 | memset(CmdBlkP, 0, sizeof(struct CmdBlk)); | 561 | memset(CmdBlkP, 0, sizeof(struct CmdBlk)); |
562 | return CmdBlkP; | 562 | return CmdBlkP; |
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index 66a7385bc34a..e1d70e8b6268 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c | |||
@@ -113,7 +113,7 @@ static int rtc_has_irq = 1; | |||
113 | #define hpet_set_rtc_irq_bit(arg) 0 | 113 | #define hpet_set_rtc_irq_bit(arg) 0 |
114 | #define hpet_rtc_timer_init() do { } while (0) | 114 | #define hpet_rtc_timer_init() do { } while (0) |
115 | #define hpet_rtc_dropped_irq() 0 | 115 | #define hpet_rtc_dropped_irq() 0 |
116 | static inline irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) {return 0;} | 116 | static irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) {return 0;} |
117 | #else | 117 | #else |
118 | extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id); | 118 | extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id); |
119 | #endif | 119 | #endif |
@@ -165,7 +165,9 @@ static void mask_rtc_irq_bit(unsigned char bit) | |||
165 | } | 165 | } |
166 | #endif | 166 | #endif |
167 | 167 | ||
168 | #ifdef CONFIG_PROC_FS | ||
168 | static int rtc_proc_open(struct inode *inode, struct file *file); | 169 | static int rtc_proc_open(struct inode *inode, struct file *file); |
170 | #endif | ||
169 | 171 | ||
170 | /* | 172 | /* |
171 | * Bits in rtc_status. (6 bits of room for future expansion) | 173 | * Bits in rtc_status. (6 bits of room for future expansion) |
@@ -906,6 +908,7 @@ static struct miscdevice rtc_dev = { | |||
906 | .fops = &rtc_fops, | 908 | .fops = &rtc_fops, |
907 | }; | 909 | }; |
908 | 910 | ||
911 | #ifdef CONFIG_PROC_FS | ||
909 | static const struct file_operations rtc_proc_fops = { | 912 | static const struct file_operations rtc_proc_fops = { |
910 | .owner = THIS_MODULE, | 913 | .owner = THIS_MODULE, |
911 | .open = rtc_proc_open, | 914 | .open = rtc_proc_open, |
@@ -913,14 +916,13 @@ static const struct file_operations rtc_proc_fops = { | |||
913 | .llseek = seq_lseek, | 916 | .llseek = seq_lseek, |
914 | .release = single_release, | 917 | .release = single_release, |
915 | }; | 918 | }; |
916 | |||
917 | #if defined(RTC_IRQ) && !defined(__sparc__) | ||
918 | static irq_handler_t rtc_int_handler_ptr; | ||
919 | #endif | 919 | #endif |
920 | 920 | ||
921 | static int __init rtc_init(void) | 921 | static int __init rtc_init(void) |
922 | { | 922 | { |
923 | #ifdef CONFIG_PROC_FS | ||
923 | struct proc_dir_entry *ent; | 924 | struct proc_dir_entry *ent; |
925 | #endif | ||
924 | #if defined(__alpha__) || defined(__mips__) | 926 | #if defined(__alpha__) || defined(__mips__) |
925 | unsigned int year, ctrl; | 927 | unsigned int year, ctrl; |
926 | char *guess = NULL; | 928 | char *guess = NULL; |
@@ -932,9 +934,11 @@ static int __init rtc_init(void) | |||
932 | struct sparc_isa_bridge *isa_br; | 934 | struct sparc_isa_bridge *isa_br; |
933 | struct sparc_isa_device *isa_dev; | 935 | struct sparc_isa_device *isa_dev; |
934 | #endif | 936 | #endif |
935 | #endif | 937 | #else |
936 | #ifndef __sparc__ | ||
937 | void *r; | 938 | void *r; |
939 | #ifdef RTC_IRQ | ||
940 | irq_handler_t rtc_int_handler_ptr; | ||
941 | #endif | ||
938 | #endif | 942 | #endif |
939 | 943 | ||
940 | #ifdef __sparc__ | 944 | #ifdef __sparc__ |
@@ -958,6 +962,7 @@ static int __init rtc_init(void) | |||
958 | } | 962 | } |
959 | } | 963 | } |
960 | #endif | 964 | #endif |
965 | rtc_has_irq = 0; | ||
961 | printk(KERN_ERR "rtc_init: no PC rtc found\n"); | 966 | printk(KERN_ERR "rtc_init: no PC rtc found\n"); |
962 | return -EIO; | 967 | return -EIO; |
963 | 968 | ||
@@ -972,6 +977,7 @@ found: | |||
972 | * PCI Slot 2 INTA# (and some INTx# in Slot 1). | 977 | * PCI Slot 2 INTA# (and some INTx# in Slot 1). |
973 | */ | 978 | */ |
974 | if (request_irq(rtc_irq, rtc_interrupt, IRQF_SHARED, "rtc", (void *)&rtc_port)) { | 979 | if (request_irq(rtc_irq, rtc_interrupt, IRQF_SHARED, "rtc", (void *)&rtc_port)) { |
980 | rtc_has_irq = 0; | ||
975 | printk(KERN_ERR "rtc: cannot register IRQ %d\n", rtc_irq); | 981 | printk(KERN_ERR "rtc: cannot register IRQ %d\n", rtc_irq); |
976 | return -EIO; | 982 | return -EIO; |
977 | } | 983 | } |
@@ -982,6 +988,9 @@ no_irq: | |||
982 | else | 988 | else |
983 | r = request_mem_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc"); | 989 | r = request_mem_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc"); |
984 | if (!r) { | 990 | if (!r) { |
991 | #ifdef RTC_IRQ | ||
992 | rtc_has_irq = 0; | ||
993 | #endif | ||
985 | printk(KERN_ERR "rtc: I/O resource %lx is not free.\n", | 994 | printk(KERN_ERR "rtc: I/O resource %lx is not free.\n", |
986 | (long)(RTC_PORT(0))); | 995 | (long)(RTC_PORT(0))); |
987 | return -EIO; | 996 | return -EIO; |
@@ -996,6 +1005,7 @@ no_irq: | |||
996 | 1005 | ||
997 | if(request_irq(RTC_IRQ, rtc_int_handler_ptr, IRQF_DISABLED, "rtc", NULL)) { | 1006 | if(request_irq(RTC_IRQ, rtc_int_handler_ptr, IRQF_DISABLED, "rtc", NULL)) { |
998 | /* Yeah right, seeing as irq 8 doesn't even hit the bus. */ | 1007 | /* Yeah right, seeing as irq 8 doesn't even hit the bus. */ |
1008 | rtc_has_irq = 0; | ||
999 | printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ); | 1009 | printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ); |
1000 | if (RTC_IOMAPPED) | 1010 | if (RTC_IOMAPPED) |
1001 | release_region(RTC_PORT(0), RTC_IO_EXTENT); | 1011 | release_region(RTC_PORT(0), RTC_IO_EXTENT); |
@@ -1012,21 +1022,19 @@ no_irq: | |||
1012 | if (misc_register(&rtc_dev)) { | 1022 | if (misc_register(&rtc_dev)) { |
1013 | #ifdef RTC_IRQ | 1023 | #ifdef RTC_IRQ |
1014 | free_irq(RTC_IRQ, NULL); | 1024 | free_irq(RTC_IRQ, NULL); |
1025 | rtc_has_irq = 0; | ||
1015 | #endif | 1026 | #endif |
1016 | release_region(RTC_PORT(0), RTC_IO_EXTENT); | 1027 | release_region(RTC_PORT(0), RTC_IO_EXTENT); |
1017 | return -ENODEV; | 1028 | return -ENODEV; |
1018 | } | 1029 | } |
1019 | 1030 | ||
1031 | #ifdef CONFIG_PROC_FS | ||
1020 | ent = create_proc_entry("driver/rtc", 0, NULL); | 1032 | ent = create_proc_entry("driver/rtc", 0, NULL); |
1021 | if (!ent) { | 1033 | if (ent) |
1022 | #ifdef RTC_IRQ | 1034 | ent->proc_fops = &rtc_proc_fops; |
1023 | free_irq(RTC_IRQ, NULL); | 1035 | else |
1036 | printk(KERN_WARNING "rtc: Failed to register with procfs.\n"); | ||
1024 | #endif | 1037 | #endif |
1025 | release_region(RTC_PORT(0), RTC_IO_EXTENT); | ||
1026 | misc_deregister(&rtc_dev); | ||
1027 | return -ENOMEM; | ||
1028 | } | ||
1029 | ent->proc_fops = &rtc_proc_fops; | ||
1030 | 1038 | ||
1031 | #if defined(__alpha__) || defined(__mips__) | 1039 | #if defined(__alpha__) || defined(__mips__) |
1032 | rtc_freq = HZ; | 1040 | rtc_freq = HZ; |
@@ -1159,6 +1167,7 @@ static void rtc_dropped_irq(unsigned long data) | |||
1159 | } | 1167 | } |
1160 | #endif | 1168 | #endif |
1161 | 1169 | ||
1170 | #ifdef CONFIG_PROC_FS | ||
1162 | /* | 1171 | /* |
1163 | * Info exported via "/proc/driver/rtc". | 1172 | * Info exported via "/proc/driver/rtc". |
1164 | */ | 1173 | */ |
@@ -1243,6 +1252,7 @@ static int rtc_proc_open(struct inode *inode, struct file *file) | |||
1243 | { | 1252 | { |
1244 | return single_open(file, rtc_proc_show, NULL); | 1253 | return single_open(file, rtc_proc_show, NULL); |
1245 | } | 1254 | } |
1255 | #endif | ||
1246 | 1256 | ||
1247 | void rtc_get_rtc_time(struct rtc_time *rtc_tm) | 1257 | void rtc_get_rtc_time(struct rtc_time *rtc_tm) |
1248 | { | 1258 | { |
diff --git a/drivers/char/sx.c b/drivers/char/sx.c index a3008ce13015..1da92a689ae4 100644 --- a/drivers/char/sx.c +++ b/drivers/char/sx.c | |||
@@ -2498,8 +2498,10 @@ static void __devexit sx_remove_card(struct sx_board *board, | |||
2498 | /* It is safe/allowed to del_timer a non-active timer */ | 2498 | /* It is safe/allowed to del_timer a non-active timer */ |
2499 | del_timer(&board->timer); | 2499 | del_timer(&board->timer); |
2500 | if (pdev) { | 2500 | if (pdev) { |
2501 | #ifdef CONFIG_PCI | ||
2501 | pci_iounmap(pdev, board->base); | 2502 | pci_iounmap(pdev, board->base); |
2502 | pci_release_region(pdev, IS_CF_BOARD(board) ? 3 : 2); | 2503 | pci_release_region(pdev, IS_CF_BOARD(board) ? 3 : 2); |
2504 | #endif | ||
2503 | } else { | 2505 | } else { |
2504 | iounmap(board->base); | 2506 | iounmap(board->base); |
2505 | release_region(board->hw_base, board->hw_len); | 2507 | release_region(board->hw_base, board->hw_len); |
@@ -2601,6 +2603,7 @@ static struct eisa_driver sx_eisadriver = { | |||
2601 | 2603 | ||
2602 | #endif | 2604 | #endif |
2603 | 2605 | ||
2606 | #ifdef CONFIG_PCI | ||
2604 | /******************************************************** | 2607 | /******************************************************** |
2605 | * Setting bit 17 in the CNTRL register of the PLX 9050 * | 2608 | * Setting bit 17 in the CNTRL register of the PLX 9050 * |
2606 | * chip forces a retry on writes while a read is pending.* | 2609 | * chip forces a retry on writes while a read is pending.* |
@@ -2632,10 +2635,12 @@ static void __devinit fix_sx_pci(struct pci_dev *pdev, struct sx_board *board) | |||
2632 | } | 2635 | } |
2633 | iounmap(rebase); | 2636 | iounmap(rebase); |
2634 | } | 2637 | } |
2638 | #endif | ||
2635 | 2639 | ||
2636 | static int __devinit sx_pci_probe(struct pci_dev *pdev, | 2640 | static int __devinit sx_pci_probe(struct pci_dev *pdev, |
2637 | const struct pci_device_id *ent) | 2641 | const struct pci_device_id *ent) |
2638 | { | 2642 | { |
2643 | #ifdef CONFIG_PCI | ||
2639 | struct sx_board *board; | 2644 | struct sx_board *board; |
2640 | unsigned int i, reg; | 2645 | unsigned int i, reg; |
2641 | int retval = -EIO; | 2646 | int retval = -EIO; |
@@ -2700,6 +2705,9 @@ err_flag: | |||
2700 | board->flags &= ~SX_BOARD_PRESENT; | 2705 | board->flags &= ~SX_BOARD_PRESENT; |
2701 | err: | 2706 | err: |
2702 | return retval; | 2707 | return retval; |
2708 | #else | ||
2709 | return -ENODEV; | ||
2710 | #endif | ||
2703 | } | 2711 | } |
2704 | 2712 | ||
2705 | static void __devexit sx_pci_remove(struct pci_dev *pdev) | 2713 | static void __devexit sx_pci_remove(struct pci_dev *pdev) |
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index acc6fab601cc..3fa625db9e4b 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c | |||
@@ -4332,7 +4332,7 @@ static struct mgsl_struct* mgsl_allocate_device(void) | |||
4332 | { | 4332 | { |
4333 | struct mgsl_struct *info; | 4333 | struct mgsl_struct *info; |
4334 | 4334 | ||
4335 | info = (struct mgsl_struct *)kmalloc(sizeof(struct mgsl_struct), | 4335 | info = kmalloc(sizeof(struct mgsl_struct), |
4336 | GFP_KERNEL); | 4336 | GFP_KERNEL); |
4337 | 4337 | ||
4338 | if (!info) { | 4338 | if (!info) { |
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index 53e8ccf94fe3..8f4d67afe5bf 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c | |||
@@ -2730,7 +2730,7 @@ static int startup(SLMP_INFO * info) | |||
2730 | return 0; | 2730 | return 0; |
2731 | 2731 | ||
2732 | if (!info->tx_buf) { | 2732 | if (!info->tx_buf) { |
2733 | info->tx_buf = (unsigned char *)kmalloc(info->max_frame_size, GFP_KERNEL); | 2733 | info->tx_buf = kmalloc(info->max_frame_size, GFP_KERNEL); |
2734 | if (!info->tx_buf) { | 2734 | if (!info->tx_buf) { |
2735 | printk(KERN_ERR"%s(%d):%s can't allocate transmit buffer\n", | 2735 | printk(KERN_ERR"%s(%d):%s can't allocate transmit buffer\n", |
2736 | __FILE__,__LINE__,info->device_name); | 2736 | __FILE__,__LINE__,info->device_name); |
@@ -3798,7 +3798,7 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev) | |||
3798 | { | 3798 | { |
3799 | SLMP_INFO *info; | 3799 | SLMP_INFO *info; |
3800 | 3800 | ||
3801 | info = (SLMP_INFO *)kmalloc(sizeof(SLMP_INFO), | 3801 | info = kmalloc(sizeof(SLMP_INFO), |
3802 | GFP_KERNEL); | 3802 | GFP_KERNEL); |
3803 | 3803 | ||
3804 | if (!info) { | 3804 | if (!info) { |
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c index 05810c8d20bc..13935235e066 100644 --- a/drivers/char/sysrq.c +++ b/drivers/char/sysrq.c | |||
@@ -41,7 +41,34 @@ | |||
41 | #include <asm/irq_regs.h> | 41 | #include <asm/irq_regs.h> |
42 | 42 | ||
43 | /* Whether we react on sysrq keys or just ignore them */ | 43 | /* Whether we react on sysrq keys or just ignore them */ |
44 | int sysrq_enabled = 1; | 44 | int __read_mostly __sysrq_enabled = 1; |
45 | |||
46 | static int __read_mostly sysrq_always_enabled; | ||
47 | |||
48 | int sysrq_on(void) | ||
49 | { | ||
50 | return __sysrq_enabled || sysrq_always_enabled; | ||
51 | } | ||
52 | |||
53 | /* | ||
54 | * A value of 1 means 'all', other nonzero values are an op mask: | ||
55 | */ | ||
56 | static inline int sysrq_on_mask(int mask) | ||
57 | { | ||
58 | return sysrq_always_enabled || __sysrq_enabled == 1 || | ||
59 | (__sysrq_enabled & mask); | ||
60 | } | ||
61 | |||
62 | static int __init sysrq_always_enabled_setup(char *str) | ||
63 | { | ||
64 | sysrq_always_enabled = 1; | ||
65 | printk(KERN_INFO "debug: sysrq always enabled.\n"); | ||
66 | |||
67 | return 1; | ||
68 | } | ||
69 | |||
70 | __setup("sysrq_always_enabled", sysrq_always_enabled_setup); | ||
71 | |||
45 | 72 | ||
46 | static void sysrq_handle_loglevel(int key, struct tty_struct *tty) | 73 | static void sysrq_handle_loglevel(int key, struct tty_struct *tty) |
47 | { | 74 | { |
@@ -379,8 +406,7 @@ void __handle_sysrq(int key, struct tty_struct *tty, int check_mask) | |||
379 | * Should we check for enabled operations (/proc/sysrq-trigger | 406 | * Should we check for enabled operations (/proc/sysrq-trigger |
380 | * should not) and is the invoked operation enabled? | 407 | * should not) and is the invoked operation enabled? |
381 | */ | 408 | */ |
382 | if (!check_mask || sysrq_enabled == 1 || | 409 | if (!check_mask || sysrq_on_mask(op_p->enable_mask)) { |
383 | (sysrq_enabled & op_p->enable_mask)) { | ||
384 | printk("%s\n", op_p->action_msg); | 410 | printk("%s\n", op_p->action_msg); |
385 | console_loglevel = orig_log_level; | 411 | console_loglevel = orig_log_level; |
386 | op_p->handler(key, tty); | 412 | op_p->handler(key, tty); |
@@ -414,9 +440,8 @@ void __handle_sysrq(int key, struct tty_struct *tty, int check_mask) | |||
414 | */ | 440 | */ |
415 | void handle_sysrq(int key, struct tty_struct *tty) | 441 | void handle_sysrq(int key, struct tty_struct *tty) |
416 | { | 442 | { |
417 | if (!sysrq_enabled) | 443 | if (sysrq_on()) |
418 | return; | 444 | __handle_sysrq(key, tty, 1); |
419 | __handle_sysrq(key, tty, 1); | ||
420 | } | 445 | } |
421 | EXPORT_SYMBOL(handle_sysrq); | 446 | EXPORT_SYMBOL(handle_sysrq); |
422 | 447 | ||
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 4044c864fdd4..47a6eacb10bc 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -3335,18 +3335,13 @@ static void __do_SAK(struct work_struct *work) | |||
3335 | int session; | 3335 | int session; |
3336 | int i; | 3336 | int i; |
3337 | struct file *filp; | 3337 | struct file *filp; |
3338 | struct tty_ldisc *disc; | ||
3339 | struct fdtable *fdt; | 3338 | struct fdtable *fdt; |
3340 | 3339 | ||
3341 | if (!tty) | 3340 | if (!tty) |
3342 | return; | 3341 | return; |
3343 | session = tty->session; | 3342 | session = tty->session; |
3344 | 3343 | ||
3345 | /* We don't want an ldisc switch during this */ | 3344 | tty_ldisc_flush(tty); |
3346 | disc = tty_ldisc_ref(tty); | ||
3347 | if (disc && disc->flush_buffer) | ||
3348 | disc->flush_buffer(tty); | ||
3349 | tty_ldisc_deref(disc); | ||
3350 | 3345 | ||
3351 | if (tty->driver->flush_buffer) | 3346 | if (tty->driver->flush_buffer) |
3352 | tty->driver->flush_buffer(tty); | 3347 | tty->driver->flush_buffer(tty); |
@@ -3821,6 +3816,7 @@ struct tty_struct *get_current_tty(void) | |||
3821 | barrier(); | 3816 | barrier(); |
3822 | return tty; | 3817 | return tty; |
3823 | } | 3818 | } |
3819 | EXPORT_SYMBOL_GPL(get_current_tty); | ||
3824 | 3820 | ||
3825 | /* | 3821 | /* |
3826 | * Initialize the console device. This is called *early*, so | 3822 | * Initialize the console device. This is called *early*, so |
diff --git a/drivers/char/viocons.c b/drivers/char/viocons.c index 6d2e314860df..0e0da443cbd5 100644 --- a/drivers/char/viocons.c +++ b/drivers/char/viocons.c | |||
@@ -61,10 +61,7 @@ | |||
61 | static DEFINE_SPINLOCK(consolelock); | 61 | static DEFINE_SPINLOCK(consolelock); |
62 | static DEFINE_SPINLOCK(consoleloglock); | 62 | static DEFINE_SPINLOCK(consoleloglock); |
63 | 63 | ||
64 | #ifdef CONFIG_MAGIC_SYSRQ | ||
65 | static int vio_sysrq_pressed; | 64 | static int vio_sysrq_pressed; |
66 | extern int sysrq_enabled; | ||
67 | #endif | ||
68 | 65 | ||
69 | #define VIOCHAR_NUM_BUF 16 | 66 | #define VIOCHAR_NUM_BUF 16 |
70 | 67 | ||
@@ -936,8 +933,10 @@ static void vioHandleData(struct HvLpEvent *event) | |||
936 | */ | 933 | */ |
937 | num_pushed = 0; | 934 | num_pushed = 0; |
938 | for (index = 0; index < cevent->len; index++) { | 935 | for (index = 0; index < cevent->len; index++) { |
939 | #ifdef CONFIG_MAGIC_SYSRQ | 936 | /* |
940 | if (sysrq_enabled) { | 937 | * Will be optimized away if !CONFIG_MAGIC_SYSRQ: |
938 | */ | ||
939 | if (sysrq_on()) { | ||
941 | /* 0x0f is the ascii character for ^O */ | 940 | /* 0x0f is the ascii character for ^O */ |
942 | if (cevent->data[index] == '\x0f') { | 941 | if (cevent->data[index] == '\x0f') { |
943 | vio_sysrq_pressed = 1; | 942 | vio_sysrq_pressed = 1; |
@@ -956,7 +955,6 @@ static void vioHandleData(struct HvLpEvent *event) | |||
956 | continue; | 955 | continue; |
957 | } | 956 | } |
958 | } | 957 | } |
959 | #endif | ||
960 | /* | 958 | /* |
961 | * The sysrq sequence isn't included in this check if | 959 | * The sysrq sequence isn't included in this check if |
962 | * sysrq is enabled and compiled into the kernel because | 960 | * sysrq is enabled and compiled into the kernel because |
diff --git a/drivers/char/vt.c b/drivers/char/vt.c index a8239dac994f..06c32a3e3ca4 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c | |||
@@ -784,7 +784,7 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) | |||
784 | if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) | 784 | if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) |
785 | return 0; | 785 | return 0; |
786 | 786 | ||
787 | newscreen = (unsigned short *) kmalloc(new_screen_size, GFP_USER); | 787 | newscreen = kmalloc(new_screen_size, GFP_USER); |
788 | if (!newscreen) | 788 | if (!newscreen) |
789 | return -ENOMEM; | 789 | return -ENOMEM; |
790 | 790 | ||
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c index ac5d60edbafa..dc8368ebb1ac 100644 --- a/drivers/char/vt_ioctl.c +++ b/drivers/char/vt_ioctl.c | |||
@@ -129,7 +129,7 @@ do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm, struct kbd_str | |||
129 | !capable(CAP_SYS_RESOURCE)) | 129 | !capable(CAP_SYS_RESOURCE)) |
130 | return -EPERM; | 130 | return -EPERM; |
131 | 131 | ||
132 | key_map = (ushort *) kmalloc(sizeof(plain_map), | 132 | key_map = kmalloc(sizeof(plain_map), |
133 | GFP_KERNEL); | 133 | GFP_KERNEL); |
134 | if (!key_map) | 134 | if (!key_map) |
135 | return -ENOMEM; | 135 | return -ENOMEM; |
@@ -259,7 +259,7 @@ do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) | |||
259 | sz = 256; | 259 | sz = 256; |
260 | while (sz < funcbufsize - funcbufleft + delta) | 260 | while (sz < funcbufsize - funcbufleft + delta) |
261 | sz <<= 1; | 261 | sz <<= 1; |
262 | fnw = (char *) kmalloc(sz, GFP_KERNEL); | 262 | fnw = kmalloc(sz, GFP_KERNEL); |
263 | if(!fnw) { | 263 | if(!fnw) { |
264 | ret = -ENOMEM; | 264 | ret = -ENOMEM; |
265 | goto reterr; | 265 | goto reterr; |
@@ -1087,7 +1087,7 @@ static void complete_change_console(struct vc_data *vc) | |||
1087 | switch_screen(vc); | 1087 | switch_screen(vc); |
1088 | 1088 | ||
1089 | /* | 1089 | /* |
1090 | * This can't appear below a successful kill_proc(). If it did, | 1090 | * This can't appear below a successful kill_pid(). If it did, |
1091 | * then the *blank_screen operation could occur while X, having | 1091 | * then the *blank_screen operation could occur while X, having |
1092 | * received acqsig, is waking up on another processor. This | 1092 | * received acqsig, is waking up on another processor. This |
1093 | * condition can lead to overlapping accesses to the VGA range | 1093 | * condition can lead to overlapping accesses to the VGA range |
@@ -1110,7 +1110,7 @@ static void complete_change_console(struct vc_data *vc) | |||
1110 | */ | 1110 | */ |
1111 | if (vc->vt_mode.mode == VT_PROCESS) { | 1111 | if (vc->vt_mode.mode == VT_PROCESS) { |
1112 | /* | 1112 | /* |
1113 | * Send the signal as privileged - kill_proc() will | 1113 | * Send the signal as privileged - kill_pid() will |
1114 | * tell us if the process has gone or something else | 1114 | * tell us if the process has gone or something else |
1115 | * is awry | 1115 | * is awry |
1116 | */ | 1116 | */ |
@@ -1170,7 +1170,7 @@ void change_console(struct vc_data *new_vc) | |||
1170 | vc = vc_cons[fg_console].d; | 1170 | vc = vc_cons[fg_console].d; |
1171 | if (vc->vt_mode.mode == VT_PROCESS) { | 1171 | if (vc->vt_mode.mode == VT_PROCESS) { |
1172 | /* | 1172 | /* |
1173 | * Send the signal as privileged - kill_proc() will | 1173 | * Send the signal as privileged - kill_pid() will |
1174 | * tell us if the process has gone or something else | 1174 | * tell us if the process has gone or something else |
1175 | * is awry | 1175 | * is awry |
1176 | */ | 1176 | */ |
diff --git a/drivers/fc4/fc.c b/drivers/fc4/fc.c index ca4e67a022d0..22b62b3cd14e 100644 --- a/drivers/fc4/fc.c +++ b/drivers/fc4/fc.c | |||
@@ -266,7 +266,7 @@ static void fcp_report_map_done(fc_channel *fc, int i, int status) | |||
266 | printk ("FC: Bad magic from REPORT_AL_MAP on %s - %08x\n", fc->name, p->magic); | 266 | printk ("FC: Bad magic from REPORT_AL_MAP on %s - %08x\n", fc->name, p->magic); |
267 | fc->state = FC_STATE_OFFLINE; | 267 | fc->state = FC_STATE_OFFLINE; |
268 | } else { | 268 | } else { |
269 | fc->posmap = (fcp_posmap *)kzalloc(sizeof(fcp_posmap)+p->len, GFP_KERNEL); | 269 | fc->posmap = kzalloc(sizeof(fcp_posmap)+p->len, GFP_KERNEL); |
270 | if (!fc->posmap) { | 270 | if (!fc->posmap) { |
271 | printk("FC: Not enough memory, offlining channel\n"); | 271 | printk("FC: Not enough memory, offlining channel\n"); |
272 | fc->state = FC_STATE_OFFLINE; | 272 | fc->state = FC_STATE_OFFLINE; |
@@ -355,7 +355,7 @@ void fcp_register(fc_channel *fc, u8 type, int unregister) | |||
355 | for (i = fc->can_queue; i < fc->scsi_bitmap_end; i++) | 355 | for (i = fc->can_queue; i < fc->scsi_bitmap_end; i++) |
356 | set_bit (i, fc->scsi_bitmap); | 356 | set_bit (i, fc->scsi_bitmap); |
357 | fc->scsi_free = fc->can_queue; | 357 | fc->scsi_free = fc->can_queue; |
358 | fc->cmd_slots = (fcp_cmnd **)kzalloc(slots * sizeof(fcp_cmnd*), GFP_KERNEL); | 358 | fc->cmd_slots = kzalloc(slots * sizeof(fcp_cmnd*), GFP_KERNEL); |
359 | fc->abort_count = 0; | 359 | fc->abort_count = 0; |
360 | } else { | 360 | } else { |
361 | fc->scsi_name[0] = 0; | 361 | fc->scsi_name[0] = 0; |
@@ -933,7 +933,7 @@ int fcp_scsi_dev_reset(struct scsi_cmnd *SCpnt) | |||
933 | DECLARE_MUTEX_LOCKED(sem); | 933 | DECLARE_MUTEX_LOCKED(sem); |
934 | 934 | ||
935 | if (!fc->rst_pkt) { | 935 | if (!fc->rst_pkt) { |
936 | fc->rst_pkt = (struct scsi_cmnd *) kmalloc(sizeof(SCpnt), GFP_KERNEL); | 936 | fc->rst_pkt = kmalloc(sizeof(SCpnt), GFP_KERNEL); |
937 | if (!fc->rst_pkt) return FAILED; | 937 | if (!fc->rst_pkt) return FAILED; |
938 | 938 | ||
939 | fcmd = FCP_CMND(fc->rst_pkt); | 939 | fcmd = FCP_CMND(fc->rst_pkt); |
@@ -1107,7 +1107,7 @@ int fc_do_plogi(fc_channel *fc, unsigned char alpa, fc_wwn *node, fc_wwn *nport) | |||
1107 | logi *l; | 1107 | logi *l; |
1108 | int status; | 1108 | int status; |
1109 | 1109 | ||
1110 | l = (logi *)kzalloc(2 * sizeof(logi), GFP_KERNEL); | 1110 | l = kzalloc(2 * sizeof(logi), GFP_KERNEL); |
1111 | if (!l) return -ENOMEM; | 1111 | if (!l) return -ENOMEM; |
1112 | l->code = LS_PLOGI; | 1112 | l->code = LS_PLOGI; |
1113 | memcpy (&l->nport_wwn, &fc->wwn_nport, sizeof(fc_wwn)); | 1113 | memcpy (&l->nport_wwn, &fc->wwn_nport, sizeof(fc_wwn)); |
@@ -1141,7 +1141,7 @@ int fc_do_prli(fc_channel *fc, unsigned char alpa) | |||
1141 | prli *p; | 1141 | prli *p; |
1142 | int status; | 1142 | int status; |
1143 | 1143 | ||
1144 | p = (prli *)kzalloc(2 * sizeof(prli), GFP_KERNEL); | 1144 | p = kzalloc(2 * sizeof(prli), GFP_KERNEL); |
1145 | if (!p) return -ENOMEM; | 1145 | if (!p) return -ENOMEM; |
1146 | p->code = LS_PRLI; | 1146 | p->code = LS_PRLI; |
1147 | p->params[0] = 0x08002000; | 1147 | p->params[0] = 0x08002000; |
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index e76d91906c99..891ef6d0b1bf 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -106,6 +106,31 @@ config SENSORS_K8TEMP | |||
106 | This driver can also be built as a module. If so, the module | 106 | This driver can also be built as a module. If so, the module |
107 | will be called k8temp. | 107 | will be called k8temp. |
108 | 108 | ||
109 | config SENSORS_AMS | ||
110 | tristate "Apple Motion Sensor driver" | ||
111 | depends on HWMON && PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) && EXPERIMENTAL | ||
112 | help | ||
113 | Support for the motion sensor included in PowerBooks. Includes | ||
114 | implementations for PMU and I2C. | ||
115 | |||
116 | This driver can also be built as a module. If so, the module | ||
117 | will be called ams. | ||
118 | |||
119 | config SENSORS_AMS_PMU | ||
120 | bool "PMU variant" | ||
121 | depends on SENSORS_AMS && ADB_PMU | ||
122 | default y | ||
123 | help | ||
124 | PMU variant of motion sensor, found in late 2005 PowerBooks. | ||
125 | |||
126 | config SENSORS_AMS_I2C | ||
127 | bool "I2C variant" | ||
128 | depends on SENSORS_AMS && I2C | ||
129 | default y | ||
130 | help | ||
131 | I2C variant of motion sensor, found in early 2005 PowerBooks and | ||
132 | iBooks. | ||
133 | |||
109 | config SENSORS_ASB100 | 134 | config SENSORS_ASB100 |
110 | tristate "Asus ASB100 Bach" | 135 | tristate "Asus ASB100 Bach" |
111 | depends on HWMON && I2C && EXPERIMENTAL | 136 | depends on HWMON && I2C && EXPERIMENTAL |
@@ -142,11 +167,12 @@ config SENSORS_DS1621 | |||
142 | will be called ds1621. | 167 | will be called ds1621. |
143 | 168 | ||
144 | config SENSORS_F71805F | 169 | config SENSORS_F71805F |
145 | tristate "Fintek F71805F/FG" | 170 | tristate "Fintek F71805F/FG and F71872F/FG" |
146 | depends on HWMON && EXPERIMENTAL | 171 | depends on HWMON && EXPERIMENTAL |
147 | help | 172 | help |
148 | If you say yes here you get support for hardware monitoring | 173 | If you say yes here you get support for hardware monitoring |
149 | features of the Fintek F71805F/FG chips. | 174 | features of the Fintek F71805F/FG and F71872F/FG Super-I/O |
175 | chips. | ||
150 | 176 | ||
151 | This driver can also be built as a module. If so, the module | 177 | This driver can also be built as a module. If so, the module |
152 | will be called f71805f. | 178 | will be called f71805f. |
@@ -353,6 +379,19 @@ config SENSORS_PC87360 | |||
353 | This driver can also be built as a module. If so, the module | 379 | This driver can also be built as a module. If so, the module |
354 | will be called pc87360. | 380 | will be called pc87360. |
355 | 381 | ||
382 | config SENSORS_PC87427 | ||
383 | tristate "National Semiconductor PC87427" | ||
384 | depends on HWMON && EXPERIMENTAL | ||
385 | help | ||
386 | If you say yes here you get access to the hardware monitoring | ||
387 | functions of the National Semiconductor PC87427 Super-I/O chip. | ||
388 | The chip has two distinct logical devices, one for fan speed | ||
389 | monitoring and control, and one for voltage and temperature | ||
390 | monitoring. Only fan speed monitoring is supported right now. | ||
391 | |||
392 | This driver can also be built as a module. If so, the module | ||
393 | will be called pc87427. | ||
394 | |||
356 | config SENSORS_SIS5595 | 395 | config SENSORS_SIS5595 |
357 | tristate "Silicon Integrated Systems Corp. SiS5595" | 396 | tristate "Silicon Integrated Systems Corp. SiS5595" |
358 | depends on HWMON && I2C && PCI && EXPERIMENTAL | 397 | depends on HWMON && I2C && PCI && EXPERIMENTAL |
@@ -474,6 +513,16 @@ config SENSORS_W83792D | |||
474 | This driver can also be built as a module. If so, the module | 513 | This driver can also be built as a module. If so, the module |
475 | will be called w83792d. | 514 | will be called w83792d. |
476 | 515 | ||
516 | config SENSORS_W83793 | ||
517 | tristate "Winbond W83793" | ||
518 | depends on HWMON && I2C && EXPERIMENTAL | ||
519 | help | ||
520 | If you say yes here you get support for the Winbond W83793 | ||
521 | hardware monitoring chip. | ||
522 | |||
523 | This driver can also be built as a module. If so, the module | ||
524 | will be called w83793. | ||
525 | |||
477 | config SENSORS_W83L785TS | 526 | config SENSORS_W83L785TS |
478 | tristate "Winbond W83L785TS-S" | 527 | tristate "Winbond W83L785TS-S" |
479 | depends on HWMON && I2C && EXPERIMENTAL | 528 | depends on HWMON && I2C && EXPERIMENTAL |
@@ -527,6 +576,9 @@ config SENSORS_HDAPS | |||
527 | This driver also provides an absolute input class device, allowing | 576 | This driver also provides an absolute input class device, allowing |
528 | the laptop to act as a pinball machine-esque joystick. | 577 | the laptop to act as a pinball machine-esque joystick. |
529 | 578 | ||
579 | If your ThinkPad is not recognized by the driver, please update to latest | ||
580 | BIOS. This is especially the case for some R52 ThinkPads. | ||
581 | |||
530 | Say Y here if you have an applicable laptop and want to experience | 582 | Say Y here if you have an applicable laptop and want to experience |
531 | the awesome power of hdaps. | 583 | the awesome power of hdaps. |
532 | 584 | ||
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index af01cc64f7d2..31661124271e 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile | |||
@@ -9,6 +9,7 @@ obj-$(CONFIG_HWMON_VID) += hwmon-vid.o | |||
9 | obj-$(CONFIG_SENSORS_ASB100) += asb100.o | 9 | obj-$(CONFIG_SENSORS_ASB100) += asb100.o |
10 | obj-$(CONFIG_SENSORS_W83627HF) += w83627hf.o | 10 | obj-$(CONFIG_SENSORS_W83627HF) += w83627hf.o |
11 | obj-$(CONFIG_SENSORS_W83792D) += w83792d.o | 11 | obj-$(CONFIG_SENSORS_W83792D) += w83792d.o |
12 | obj-$(CONFIG_SENSORS_W83793) += w83793.o | ||
12 | obj-$(CONFIG_SENSORS_W83781D) += w83781d.o | 13 | obj-$(CONFIG_SENSORS_W83781D) += w83781d.o |
13 | obj-$(CONFIG_SENSORS_W83791D) += w83791d.o | 14 | obj-$(CONFIG_SENSORS_W83791D) += w83791d.o |
14 | 15 | ||
@@ -18,6 +19,7 @@ obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o | |||
18 | obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o | 19 | obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o |
19 | obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o | 20 | obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o |
20 | obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o | 21 | obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o |
22 | obj-$(CONFIG_SENSORS_AMS) += ams/ | ||
21 | obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o | 23 | obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o |
22 | obj-$(CONFIG_SENSORS_DS1621) += ds1621.o | 24 | obj-$(CONFIG_SENSORS_DS1621) += ds1621.o |
23 | obj-$(CONFIG_SENSORS_F71805F) += f71805f.o | 25 | obj-$(CONFIG_SENSORS_F71805F) += f71805f.o |
@@ -41,6 +43,7 @@ obj-$(CONFIG_SENSORS_LM90) += lm90.o | |||
41 | obj-$(CONFIG_SENSORS_LM92) += lm92.o | 43 | obj-$(CONFIG_SENSORS_LM92) += lm92.o |
42 | obj-$(CONFIG_SENSORS_MAX1619) += max1619.o | 44 | obj-$(CONFIG_SENSORS_MAX1619) += max1619.o |
43 | obj-$(CONFIG_SENSORS_PC87360) += pc87360.o | 45 | obj-$(CONFIG_SENSORS_PC87360) += pc87360.o |
46 | obj-$(CONFIG_SENSORS_PC87427) += pc87427.o | ||
44 | obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o | 47 | obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o |
45 | obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o | 48 | obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o |
46 | obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o | 49 | obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o |
diff --git a/drivers/hwmon/ams/Makefile b/drivers/hwmon/ams/Makefile new file mode 100644 index 000000000000..41c95b2089dc --- /dev/null +++ b/drivers/hwmon/ams/Makefile | |||
@@ -0,0 +1,8 @@ | |||
1 | # | ||
2 | # Makefile for Apple Motion Sensor driver | ||
3 | # | ||
4 | |||
5 | ams-y := ams-core.o ams-input.o | ||
6 | ams-$(CONFIG_SENSORS_AMS_PMU) += ams-pmu.o | ||
7 | ams-$(CONFIG_SENSORS_AMS_I2C) += ams-i2c.o | ||
8 | obj-$(CONFIG_SENSORS_AMS) += ams.o | ||
diff --git a/drivers/hwmon/ams/ams-core.c b/drivers/hwmon/ams/ams-core.c new file mode 100644 index 000000000000..f1f0f5d0442c --- /dev/null +++ b/drivers/hwmon/ams/ams-core.c | |||
@@ -0,0 +1,265 @@ | |||
1 | /* | ||
2 | * Apple Motion Sensor driver | ||
3 | * | ||
4 | * Copyright (C) 2005 Stelian Pop (stelian@popies.net) | ||
5 | * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch) | ||
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/types.h> | ||
24 | #include <linux/errno.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/module.h> | ||
27 | #include <asm/pmac_pfunc.h> | ||
28 | #include <asm/of_platform.h> | ||
29 | |||
30 | #include "ams.h" | ||
31 | |||
32 | /* There is only one motion sensor per machine */ | ||
33 | struct ams ams_info; | ||
34 | |||
35 | static unsigned int verbose; | ||
36 | module_param(verbose, bool, 0644); | ||
37 | MODULE_PARM_DESC(verbose, "Show free falls and shocks in kernel output"); | ||
38 | |||
39 | /* Call with ams_info.lock held! */ | ||
40 | void ams_sensors(s8 *x, s8 *y, s8 *z) | ||
41 | { | ||
42 | u32 orient = ams_info.vflag? ams_info.orient1 : ams_info.orient2; | ||
43 | |||
44 | if (orient & 0x80) | ||
45 | /* X and Y swapped */ | ||
46 | ams_info.get_xyz(y, x, z); | ||
47 | else | ||
48 | ams_info.get_xyz(x, y, z); | ||
49 | |||
50 | if (orient & 0x04) | ||
51 | *z = ~(*z); | ||
52 | if (orient & 0x02) | ||
53 | *y = ~(*y); | ||
54 | if (orient & 0x01) | ||
55 | *x = ~(*x); | ||
56 | } | ||
57 | |||
58 | static ssize_t ams_show_current(struct device *dev, | ||
59 | struct device_attribute *attr, char *buf) | ||
60 | { | ||
61 | s8 x, y, z; | ||
62 | |||
63 | mutex_lock(&ams_info.lock); | ||
64 | ams_sensors(&x, &y, &z); | ||
65 | mutex_unlock(&ams_info.lock); | ||
66 | |||
67 | return snprintf(buf, PAGE_SIZE, "%d %d %d\n", x, y, z); | ||
68 | } | ||
69 | |||
70 | static DEVICE_ATTR(current, S_IRUGO, ams_show_current, NULL); | ||
71 | |||
72 | static void ams_handle_irq(void *data) | ||
73 | { | ||
74 | enum ams_irq irq = *((enum ams_irq *)data); | ||
75 | |||
76 | spin_lock(&ams_info.irq_lock); | ||
77 | |||
78 | ams_info.worker_irqs |= irq; | ||
79 | schedule_work(&ams_info.worker); | ||
80 | |||
81 | spin_unlock(&ams_info.irq_lock); | ||
82 | } | ||
83 | |||
84 | static enum ams_irq ams_freefall_irq_data = AMS_IRQ_FREEFALL; | ||
85 | static struct pmf_irq_client ams_freefall_client = { | ||
86 | .owner = THIS_MODULE, | ||
87 | .handler = ams_handle_irq, | ||
88 | .data = &ams_freefall_irq_data, | ||
89 | }; | ||
90 | |||
91 | static enum ams_irq ams_shock_irq_data = AMS_IRQ_SHOCK; | ||
92 | static struct pmf_irq_client ams_shock_client = { | ||
93 | .owner = THIS_MODULE, | ||
94 | .handler = ams_handle_irq, | ||
95 | .data = &ams_shock_irq_data, | ||
96 | }; | ||
97 | |||
98 | /* Once hard disk parking is implemented in the kernel, this function can | ||
99 | * trigger it. | ||
100 | */ | ||
101 | static void ams_worker(struct work_struct *work) | ||
102 | { | ||
103 | mutex_lock(&ams_info.lock); | ||
104 | |||
105 | if (ams_info.has_device) { | ||
106 | unsigned long flags; | ||
107 | |||
108 | spin_lock_irqsave(&ams_info.irq_lock, flags); | ||
109 | |||
110 | if (ams_info.worker_irqs & AMS_IRQ_FREEFALL) { | ||
111 | if (verbose) | ||
112 | printk(KERN_INFO "ams: freefall detected!\n"); | ||
113 | |||
114 | ams_info.worker_irqs &= ~AMS_IRQ_FREEFALL; | ||
115 | |||
116 | /* we must call this with interrupts enabled */ | ||
117 | spin_unlock_irqrestore(&ams_info.irq_lock, flags); | ||
118 | ams_info.clear_irq(AMS_IRQ_FREEFALL); | ||
119 | spin_lock_irqsave(&ams_info.irq_lock, flags); | ||
120 | } | ||
121 | |||
122 | if (ams_info.worker_irqs & AMS_IRQ_SHOCK) { | ||
123 | if (verbose) | ||
124 | printk(KERN_INFO "ams: shock detected!\n"); | ||
125 | |||
126 | ams_info.worker_irqs &= ~AMS_IRQ_SHOCK; | ||
127 | |||
128 | /* we must call this with interrupts enabled */ | ||
129 | spin_unlock_irqrestore(&ams_info.irq_lock, flags); | ||
130 | ams_info.clear_irq(AMS_IRQ_SHOCK); | ||
131 | spin_lock_irqsave(&ams_info.irq_lock, flags); | ||
132 | } | ||
133 | |||
134 | spin_unlock_irqrestore(&ams_info.irq_lock, flags); | ||
135 | } | ||
136 | |||
137 | mutex_unlock(&ams_info.lock); | ||
138 | } | ||
139 | |||
140 | /* Call with ams_info.lock held! */ | ||
141 | int ams_sensor_attach(void) | ||
142 | { | ||
143 | int result; | ||
144 | u32 *prop; | ||
145 | |||
146 | /* Get orientation */ | ||
147 | prop = (u32*)get_property(ams_info.of_node, "orientation", NULL); | ||
148 | if (!prop) | ||
149 | return -ENODEV; | ||
150 | ams_info.orient1 = *prop; | ||
151 | ams_info.orient2 = *(prop + 1); | ||
152 | |||
153 | /* Register freefall interrupt handler */ | ||
154 | result = pmf_register_irq_client(ams_info.of_node, | ||
155 | "accel-int-1", | ||
156 | &ams_freefall_client); | ||
157 | if (result < 0) | ||
158 | return -ENODEV; | ||
159 | |||
160 | /* Reset saved irqs */ | ||
161 | ams_info.worker_irqs = 0; | ||
162 | |||
163 | /* Register shock interrupt handler */ | ||
164 | result = pmf_register_irq_client(ams_info.of_node, | ||
165 | "accel-int-2", | ||
166 | &ams_shock_client); | ||
167 | if (result < 0) | ||
168 | goto release_freefall; | ||
169 | |||
170 | /* Create device */ | ||
171 | ams_info.of_dev = of_platform_device_create(ams_info.of_node, "ams", NULL); | ||
172 | if (!ams_info.of_dev) { | ||
173 | result = -ENODEV; | ||
174 | goto release_shock; | ||
175 | } | ||
176 | |||
177 | /* Create attributes */ | ||
178 | result = device_create_file(&ams_info.of_dev->dev, &dev_attr_current); | ||
179 | if (result) | ||
180 | goto release_of; | ||
181 | |||
182 | ams_info.vflag = !!(ams_info.get_vendor() & 0x10); | ||
183 | |||
184 | /* Init input device */ | ||
185 | result = ams_input_init(); | ||
186 | if (result) | ||
187 | goto release_device_file; | ||
188 | |||
189 | return result; | ||
190 | release_device_file: | ||
191 | device_remove_file(&ams_info.of_dev->dev, &dev_attr_current); | ||
192 | release_of: | ||
193 | of_device_unregister(ams_info.of_dev); | ||
194 | release_shock: | ||
195 | pmf_unregister_irq_client(&ams_shock_client); | ||
196 | release_freefall: | ||
197 | pmf_unregister_irq_client(&ams_freefall_client); | ||
198 | return result; | ||
199 | } | ||
200 | |||
201 | int __init ams_init(void) | ||
202 | { | ||
203 | struct device_node *np; | ||
204 | |||
205 | spin_lock_init(&ams_info.irq_lock); | ||
206 | mutex_init(&ams_info.lock); | ||
207 | INIT_WORK(&ams_info.worker, ams_worker); | ||
208 | |||
209 | #ifdef CONFIG_SENSORS_AMS_I2C | ||
210 | np = of_find_node_by_name(NULL, "accelerometer"); | ||
211 | if (np && device_is_compatible(np, "AAPL,accelerometer_1")) | ||
212 | /* Found I2C motion sensor */ | ||
213 | return ams_i2c_init(np); | ||
214 | #endif | ||
215 | |||
216 | #ifdef CONFIG_SENSORS_AMS_PMU | ||
217 | np = of_find_node_by_name(NULL, "sms"); | ||
218 | if (np && device_is_compatible(np, "sms")) | ||
219 | /* Found PMU motion sensor */ | ||
220 | return ams_pmu_init(np); | ||
221 | #endif | ||
222 | |||
223 | printk(KERN_ERR "ams: No motion sensor found.\n"); | ||
224 | |||
225 | return -ENODEV; | ||
226 | } | ||
227 | |||
228 | void ams_exit(void) | ||
229 | { | ||
230 | mutex_lock(&ams_info.lock); | ||
231 | |||
232 | if (ams_info.has_device) { | ||
233 | /* Remove input device */ | ||
234 | ams_input_exit(); | ||
235 | |||
236 | /* Shut down implementation */ | ||
237 | ams_info.exit(); | ||
238 | |||
239 | /* Flush interrupt worker | ||
240 | * | ||
241 | * We do this after ams_info.exit(), because an interrupt might | ||
242 | * have arrived before disabling them. | ||
243 | */ | ||
244 | flush_scheduled_work(); | ||
245 | |||
246 | /* Remove attributes */ | ||
247 | device_remove_file(&ams_info.of_dev->dev, &dev_attr_current); | ||
248 | |||
249 | /* Remove device */ | ||
250 | of_device_unregister(ams_info.of_dev); | ||
251 | |||
252 | /* Remove handler */ | ||
253 | pmf_unregister_irq_client(&ams_shock_client); | ||
254 | pmf_unregister_irq_client(&ams_freefall_client); | ||
255 | } | ||
256 | |||
257 | mutex_unlock(&ams_info.lock); | ||
258 | } | ||
259 | |||
260 | MODULE_AUTHOR("Stelian Pop, Michael Hanselmann"); | ||
261 | MODULE_DESCRIPTION("Apple Motion Sensor driver"); | ||
262 | MODULE_LICENSE("GPL"); | ||
263 | |||
264 | module_init(ams_init); | ||
265 | module_exit(ams_exit); | ||
diff --git a/drivers/hwmon/ams/ams-i2c.c b/drivers/hwmon/ams/ams-i2c.c new file mode 100644 index 000000000000..0d24bdfea53e --- /dev/null +++ b/drivers/hwmon/ams/ams-i2c.c | |||
@@ -0,0 +1,299 @@ | |||
1 | /* | ||
2 | * Apple Motion Sensor driver (I2C variant) | ||
3 | * | ||
4 | * Copyright (C) 2005 Stelian Pop (stelian@popies.net) | ||
5 | * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch) | ||
6 | * | ||
7 | * Clean room implementation based on the reverse engineered Mac OS X driver by | ||
8 | * Johannes Berg <johannes@sipsolutions.net>, documentation available at | ||
9 | * http://johannes.sipsolutions.net/PowerBook/Apple_Motion_Sensor_Specification | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | */ | ||
16 | |||
17 | #include <linux/module.h> | ||
18 | #include <linux/types.h> | ||
19 | #include <linux/errno.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/delay.h> | ||
22 | |||
23 | #include "ams.h" | ||
24 | |||
25 | /* AMS registers */ | ||
26 | #define AMS_COMMAND 0x00 /* command register */ | ||
27 | #define AMS_STATUS 0x01 /* status register */ | ||
28 | #define AMS_CTRL1 0x02 /* read control 1 (number of values) */ | ||
29 | #define AMS_CTRL2 0x03 /* read control 2 (offset?) */ | ||
30 | #define AMS_CTRL3 0x04 /* read control 3 (size of each value?) */ | ||
31 | #define AMS_DATA1 0x05 /* read data 1 */ | ||
32 | #define AMS_DATA2 0x06 /* read data 2 */ | ||
33 | #define AMS_DATA3 0x07 /* read data 3 */ | ||
34 | #define AMS_DATA4 0x08 /* read data 4 */ | ||
35 | #define AMS_DATAX 0x20 /* data X */ | ||
36 | #define AMS_DATAY 0x21 /* data Y */ | ||
37 | #define AMS_DATAZ 0x22 /* data Z */ | ||
38 | #define AMS_FREEFALL 0x24 /* freefall int control */ | ||
39 | #define AMS_SHOCK 0x25 /* shock int control */ | ||
40 | #define AMS_SENSLOW 0x26 /* sensitivity low limit */ | ||
41 | #define AMS_SENSHIGH 0x27 /* sensitivity high limit */ | ||
42 | #define AMS_CTRLX 0x28 /* control X */ | ||
43 | #define AMS_CTRLY 0x29 /* control Y */ | ||
44 | #define AMS_CTRLZ 0x2A /* control Z */ | ||
45 | #define AMS_UNKNOWN1 0x2B /* unknown 1 */ | ||
46 | #define AMS_UNKNOWN2 0x2C /* unknown 2 */ | ||
47 | #define AMS_UNKNOWN3 0x2D /* unknown 3 */ | ||
48 | #define AMS_VENDOR 0x2E /* vendor */ | ||
49 | |||
50 | /* AMS commands - use with the AMS_COMMAND register */ | ||
51 | enum ams_i2c_cmd { | ||
52 | AMS_CMD_NOOP = 0, | ||
53 | AMS_CMD_VERSION, | ||
54 | AMS_CMD_READMEM, | ||
55 | AMS_CMD_WRITEMEM, | ||
56 | AMS_CMD_ERASEMEM, | ||
57 | AMS_CMD_READEE, | ||
58 | AMS_CMD_WRITEEE, | ||
59 | AMS_CMD_RESET, | ||
60 | AMS_CMD_START, | ||
61 | }; | ||
62 | |||
63 | static int ams_i2c_attach(struct i2c_adapter *adapter); | ||
64 | static int ams_i2c_detach(struct i2c_adapter *adapter); | ||
65 | |||
66 | static struct i2c_driver ams_i2c_driver = { | ||
67 | .driver = { | ||
68 | .name = "ams", | ||
69 | .owner = THIS_MODULE, | ||
70 | }, | ||
71 | .attach_adapter = ams_i2c_attach, | ||
72 | .detach_adapter = ams_i2c_detach, | ||
73 | }; | ||
74 | |||
75 | static s32 ams_i2c_read(u8 reg) | ||
76 | { | ||
77 | return i2c_smbus_read_byte_data(&ams_info.i2c_client, reg); | ||
78 | } | ||
79 | |||
80 | static int ams_i2c_write(u8 reg, u8 value) | ||
81 | { | ||
82 | return i2c_smbus_write_byte_data(&ams_info.i2c_client, reg, value); | ||
83 | } | ||
84 | |||
85 | static int ams_i2c_cmd(enum ams_i2c_cmd cmd) | ||
86 | { | ||
87 | s32 result; | ||
88 | int remaining = HZ / 20; | ||
89 | |||
90 | ams_i2c_write(AMS_COMMAND, cmd); | ||
91 | mdelay(5); | ||
92 | |||
93 | while (remaining) { | ||
94 | result = ams_i2c_read(AMS_COMMAND); | ||
95 | if (result == 0 || result & 0x80) | ||
96 | return 0; | ||
97 | |||
98 | remaining = schedule_timeout(remaining); | ||
99 | } | ||
100 | |||
101 | return -1; | ||
102 | } | ||
103 | |||
104 | static void ams_i2c_set_irq(enum ams_irq reg, char enable) | ||
105 | { | ||
106 | if (reg & AMS_IRQ_FREEFALL) { | ||
107 | u8 val = ams_i2c_read(AMS_CTRLX); | ||
108 | if (enable) | ||
109 | val |= 0x80; | ||
110 | else | ||
111 | val &= ~0x80; | ||
112 | ams_i2c_write(AMS_CTRLX, val); | ||
113 | } | ||
114 | |||
115 | if (reg & AMS_IRQ_SHOCK) { | ||
116 | u8 val = ams_i2c_read(AMS_CTRLY); | ||
117 | if (enable) | ||
118 | val |= 0x80; | ||
119 | else | ||
120 | val &= ~0x80; | ||
121 | ams_i2c_write(AMS_CTRLY, val); | ||
122 | } | ||
123 | |||
124 | if (reg & AMS_IRQ_GLOBAL) { | ||
125 | u8 val = ams_i2c_read(AMS_CTRLZ); | ||
126 | if (enable) | ||
127 | val |= 0x80; | ||
128 | else | ||
129 | val &= ~0x80; | ||
130 | ams_i2c_write(AMS_CTRLZ, val); | ||
131 | } | ||
132 | } | ||
133 | |||
134 | static void ams_i2c_clear_irq(enum ams_irq reg) | ||
135 | { | ||
136 | if (reg & AMS_IRQ_FREEFALL) | ||
137 | ams_i2c_write(AMS_FREEFALL, 0); | ||
138 | |||
139 | if (reg & AMS_IRQ_SHOCK) | ||
140 | ams_i2c_write(AMS_SHOCK, 0); | ||
141 | } | ||
142 | |||
143 | static u8 ams_i2c_get_vendor(void) | ||
144 | { | ||
145 | return ams_i2c_read(AMS_VENDOR); | ||
146 | } | ||
147 | |||
148 | static void ams_i2c_get_xyz(s8 *x, s8 *y, s8 *z) | ||
149 | { | ||
150 | *x = ams_i2c_read(AMS_DATAX); | ||
151 | *y = ams_i2c_read(AMS_DATAY); | ||
152 | *z = ams_i2c_read(AMS_DATAZ); | ||
153 | } | ||
154 | |||
155 | static int ams_i2c_attach(struct i2c_adapter *adapter) | ||
156 | { | ||
157 | unsigned long bus; | ||
158 | int vmaj, vmin; | ||
159 | int result; | ||
160 | |||
161 | /* There can be only one */ | ||
162 | if (unlikely(ams_info.has_device)) | ||
163 | return -ENODEV; | ||
164 | |||
165 | if (strncmp(adapter->name, "uni-n", 5)) | ||
166 | return -ENODEV; | ||
167 | |||
168 | bus = simple_strtoul(adapter->name + 6, NULL, 10); | ||
169 | if (bus != ams_info.i2c_bus) | ||
170 | return -ENODEV; | ||
171 | |||
172 | ams_info.i2c_client.addr = ams_info.i2c_address; | ||
173 | ams_info.i2c_client.adapter = adapter; | ||
174 | ams_info.i2c_client.driver = &ams_i2c_driver; | ||
175 | strcpy(ams_info.i2c_client.name, "Apple Motion Sensor"); | ||
176 | |||
177 | if (ams_i2c_cmd(AMS_CMD_RESET)) { | ||
178 | printk(KERN_INFO "ams: Failed to reset the device\n"); | ||
179 | return -ENODEV; | ||
180 | } | ||
181 | |||
182 | if (ams_i2c_cmd(AMS_CMD_START)) { | ||
183 | printk(KERN_INFO "ams: Failed to start the device\n"); | ||
184 | return -ENODEV; | ||
185 | } | ||
186 | |||
187 | /* get version/vendor information */ | ||
188 | ams_i2c_write(AMS_CTRL1, 0x02); | ||
189 | ams_i2c_write(AMS_CTRL2, 0x85); | ||
190 | ams_i2c_write(AMS_CTRL3, 0x01); | ||
191 | |||
192 | ams_i2c_cmd(AMS_CMD_READMEM); | ||
193 | |||
194 | vmaj = ams_i2c_read(AMS_DATA1); | ||
195 | vmin = ams_i2c_read(AMS_DATA2); | ||
196 | if (vmaj != 1 || vmin != 52) { | ||
197 | printk(KERN_INFO "ams: Incorrect device version (%d.%d)\n", | ||
198 | vmaj, vmin); | ||
199 | return -ENODEV; | ||
200 | } | ||
201 | |||
202 | ams_i2c_cmd(AMS_CMD_VERSION); | ||
203 | |||
204 | vmaj = ams_i2c_read(AMS_DATA1); | ||
205 | vmin = ams_i2c_read(AMS_DATA2); | ||
206 | if (vmaj != 0 || vmin != 1) { | ||
207 | printk(KERN_INFO "ams: Incorrect firmware version (%d.%d)\n", | ||
208 | vmaj, vmin); | ||
209 | return -ENODEV; | ||
210 | } | ||
211 | |||
212 | /* Disable interrupts */ | ||
213 | ams_i2c_set_irq(AMS_IRQ_ALL, 0); | ||
214 | |||
215 | result = ams_sensor_attach(); | ||
216 | if (result < 0) | ||
217 | return result; | ||
218 | |||
219 | /* Set default values */ | ||
220 | ams_i2c_write(AMS_SENSLOW, 0x15); | ||
221 | ams_i2c_write(AMS_SENSHIGH, 0x60); | ||
222 | ams_i2c_write(AMS_CTRLX, 0x08); | ||
223 | ams_i2c_write(AMS_CTRLY, 0x0F); | ||
224 | ams_i2c_write(AMS_CTRLZ, 0x4F); | ||
225 | ams_i2c_write(AMS_UNKNOWN1, 0x14); | ||
226 | |||
227 | /* Clear interrupts */ | ||
228 | ams_i2c_clear_irq(AMS_IRQ_ALL); | ||
229 | |||
230 | ams_info.has_device = 1; | ||
231 | |||
232 | /* Enable interrupts */ | ||
233 | ams_i2c_set_irq(AMS_IRQ_ALL, 1); | ||
234 | |||
235 | printk(KERN_INFO "ams: Found I2C based motion sensor\n"); | ||
236 | |||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static int ams_i2c_detach(struct i2c_adapter *adapter) | ||
241 | { | ||
242 | if (ams_info.has_device) { | ||
243 | /* Disable interrupts */ | ||
244 | ams_i2c_set_irq(AMS_IRQ_ALL, 0); | ||
245 | |||
246 | /* Clear interrupts */ | ||
247 | ams_i2c_clear_irq(AMS_IRQ_ALL); | ||
248 | |||
249 | printk(KERN_INFO "ams: Unloading\n"); | ||
250 | |||
251 | ams_info.has_device = 0; | ||
252 | } | ||
253 | |||
254 | return 0; | ||
255 | } | ||
256 | |||
257 | static void ams_i2c_exit(void) | ||
258 | { | ||
259 | i2c_del_driver(&ams_i2c_driver); | ||
260 | } | ||
261 | |||
262 | int __init ams_i2c_init(struct device_node *np) | ||
263 | { | ||
264 | char *tmp_bus; | ||
265 | int result; | ||
266 | u32 *prop; | ||
267 | |||
268 | mutex_lock(&ams_info.lock); | ||
269 | |||
270 | /* Set implementation stuff */ | ||
271 | ams_info.of_node = np; | ||
272 | ams_info.exit = ams_i2c_exit; | ||
273 | ams_info.get_vendor = ams_i2c_get_vendor; | ||
274 | ams_info.get_xyz = ams_i2c_get_xyz; | ||
275 | ams_info.clear_irq = ams_i2c_clear_irq; | ||
276 | ams_info.bustype = BUS_I2C; | ||
277 | |||
278 | /* look for bus either using "reg" or by path */ | ||
279 | prop = (u32*)get_property(ams_info.of_node, "reg", NULL); | ||
280 | if (!prop) { | ||
281 | result = -ENODEV; | ||
282 | |||
283 | goto exit; | ||
284 | } | ||
285 | |||
286 | tmp_bus = strstr(ams_info.of_node->full_name, "/i2c-bus@"); | ||
287 | if (tmp_bus) | ||
288 | ams_info.i2c_bus = *(tmp_bus + 9) - '0'; | ||
289 | else | ||
290 | ams_info.i2c_bus = ((*prop) >> 8) & 0x0f; | ||
291 | ams_info.i2c_address = ((*prop) & 0xff) >> 1; | ||
292 | |||
293 | result = i2c_add_driver(&ams_i2c_driver); | ||
294 | |||
295 | exit: | ||
296 | mutex_unlock(&ams_info.lock); | ||
297 | |||
298 | return result; | ||
299 | } | ||
diff --git a/drivers/hwmon/ams/ams-input.c b/drivers/hwmon/ams/ams-input.c new file mode 100644 index 000000000000..f126aa485134 --- /dev/null +++ b/drivers/hwmon/ams/ams-input.c | |||
@@ -0,0 +1,160 @@ | |||
1 | /* | ||
2 | * Apple Motion Sensor driver (joystick emulation) | ||
3 | * | ||
4 | * Copyright (C) 2005 Stelian Pop (stelian@popies.net) | ||
5 | * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch) | ||
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 | |||
13 | #include <linux/module.h> | ||
14 | |||
15 | #include <linux/types.h> | ||
16 | #include <linux/errno.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/delay.h> | ||
19 | |||
20 | #include "ams.h" | ||
21 | |||
22 | static unsigned int joystick; | ||
23 | module_param(joystick, bool, 0644); | ||
24 | MODULE_PARM_DESC(joystick, "Enable the input class device on module load"); | ||
25 | |||
26 | static unsigned int invert; | ||
27 | module_param(invert, bool, 0644); | ||
28 | MODULE_PARM_DESC(invert, "Invert input data on X and Y axis"); | ||
29 | |||
30 | static int ams_input_kthread(void *data) | ||
31 | { | ||
32 | s8 x, y, z; | ||
33 | |||
34 | while (!kthread_should_stop()) { | ||
35 | mutex_lock(&ams_info.lock); | ||
36 | |||
37 | ams_sensors(&x, &y, &z); | ||
38 | |||
39 | x -= ams_info.xcalib; | ||
40 | y -= ams_info.ycalib; | ||
41 | z -= ams_info.zcalib; | ||
42 | |||
43 | input_report_abs(ams_info.idev, ABS_X, invert ? -x : x); | ||
44 | input_report_abs(ams_info.idev, ABS_Y, invert ? -y : y); | ||
45 | input_report_abs(ams_info.idev, ABS_Z, z); | ||
46 | |||
47 | input_sync(ams_info.idev); | ||
48 | |||
49 | mutex_unlock(&ams_info.lock); | ||
50 | |||
51 | msleep(25); | ||
52 | } | ||
53 | |||
54 | return 0; | ||
55 | } | ||
56 | |||
57 | static int ams_input_open(struct input_dev *dev) | ||
58 | { | ||
59 | ams_info.kthread = kthread_run(ams_input_kthread, NULL, "kams"); | ||
60 | return IS_ERR(ams_info.kthread) ? PTR_ERR(ams_info.kthread) : 0; | ||
61 | } | ||
62 | |||
63 | static void ams_input_close(struct input_dev *dev) | ||
64 | { | ||
65 | kthread_stop(ams_info.kthread); | ||
66 | } | ||
67 | |||
68 | /* Call with ams_info.lock held! */ | ||
69 | static void ams_input_enable(void) | ||
70 | { | ||
71 | s8 x, y, z; | ||
72 | |||
73 | if (ams_info.idev) | ||
74 | return; | ||
75 | |||
76 | ams_sensors(&x, &y, &z); | ||
77 | ams_info.xcalib = x; | ||
78 | ams_info.ycalib = y; | ||
79 | ams_info.zcalib = z; | ||
80 | |||
81 | ams_info.idev = input_allocate_device(); | ||
82 | if (!ams_info.idev) | ||
83 | return; | ||
84 | |||
85 | ams_info.idev->name = "Apple Motion Sensor"; | ||
86 | ams_info.idev->id.bustype = ams_info.bustype; | ||
87 | ams_info.idev->id.vendor = 0; | ||
88 | ams_info.idev->open = ams_input_open; | ||
89 | ams_info.idev->close = ams_input_close; | ||
90 | ams_info.idev->cdev.dev = &ams_info.of_dev->dev; | ||
91 | |||
92 | input_set_abs_params(ams_info.idev, ABS_X, -50, 50, 3, 0); | ||
93 | input_set_abs_params(ams_info.idev, ABS_Y, -50, 50, 3, 0); | ||
94 | input_set_abs_params(ams_info.idev, ABS_Z, -50, 50, 3, 0); | ||
95 | |||
96 | set_bit(EV_ABS, ams_info.idev->evbit); | ||
97 | set_bit(EV_KEY, ams_info.idev->evbit); | ||
98 | set_bit(BTN_TOUCH, ams_info.idev->keybit); | ||
99 | |||
100 | if (input_register_device(ams_info.idev)) { | ||
101 | input_free_device(ams_info.idev); | ||
102 | ams_info.idev = NULL; | ||
103 | return; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | /* Call with ams_info.lock held! */ | ||
108 | static void ams_input_disable(void) | ||
109 | { | ||
110 | if (ams_info.idev) { | ||
111 | input_unregister_device(ams_info.idev); | ||
112 | ams_info.idev = NULL; | ||
113 | } | ||
114 | } | ||
115 | |||
116 | static ssize_t ams_input_show_joystick(struct device *dev, | ||
117 | struct device_attribute *attr, char *buf) | ||
118 | { | ||
119 | return sprintf(buf, "%d\n", joystick); | ||
120 | } | ||
121 | |||
122 | static ssize_t ams_input_store_joystick(struct device *dev, | ||
123 | struct device_attribute *attr, const char *buf, size_t count) | ||
124 | { | ||
125 | if (sscanf(buf, "%d\n", &joystick) != 1) | ||
126 | return -EINVAL; | ||
127 | |||
128 | mutex_lock(&ams_info.lock); | ||
129 | |||
130 | if (joystick) | ||
131 | ams_input_enable(); | ||
132 | else | ||
133 | ams_input_disable(); | ||
134 | |||
135 | mutex_unlock(&ams_info.lock); | ||
136 | |||
137 | return count; | ||
138 | } | ||
139 | |||
140 | static DEVICE_ATTR(joystick, S_IRUGO | S_IWUSR, | ||
141 | ams_input_show_joystick, ams_input_store_joystick); | ||
142 | |||
143 | /* Call with ams_info.lock held! */ | ||
144 | int ams_input_init(void) | ||
145 | { | ||
146 | int result; | ||
147 | |||
148 | result = device_create_file(&ams_info.of_dev->dev, &dev_attr_joystick); | ||
149 | |||
150 | if (!result && joystick) | ||
151 | ams_input_enable(); | ||
152 | return result; | ||
153 | } | ||
154 | |||
155 | /* Call with ams_info.lock held! */ | ||
156 | void ams_input_exit() | ||
157 | { | ||
158 | ams_input_disable(); | ||
159 | device_remove_file(&ams_info.of_dev->dev, &dev_attr_joystick); | ||
160 | } | ||
diff --git a/drivers/hwmon/ams/ams-pmu.c b/drivers/hwmon/ams/ams-pmu.c new file mode 100644 index 000000000000..4636ae031a53 --- /dev/null +++ b/drivers/hwmon/ams/ams-pmu.c | |||
@@ -0,0 +1,207 @@ | |||
1 | /* | ||
2 | * Apple Motion Sensor driver (PMU variant) | ||
3 | * | ||
4 | * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/types.h> | ||
14 | #include <linux/errno.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/adb.h> | ||
17 | #include <linux/pmu.h> | ||
18 | |||
19 | #include "ams.h" | ||
20 | |||
21 | /* Attitude */ | ||
22 | #define AMS_X 0x00 | ||
23 | #define AMS_Y 0x01 | ||
24 | #define AMS_Z 0x02 | ||
25 | |||
26 | /* Not exactly known, maybe chip vendor */ | ||
27 | #define AMS_VENDOR 0x03 | ||
28 | |||
29 | /* Freefall registers */ | ||
30 | #define AMS_FF_CLEAR 0x04 | ||
31 | #define AMS_FF_ENABLE 0x05 | ||
32 | #define AMS_FF_LOW_LIMIT 0x06 | ||
33 | #define AMS_FF_DEBOUNCE 0x07 | ||
34 | |||
35 | /* Shock registers */ | ||
36 | #define AMS_SHOCK_CLEAR 0x08 | ||
37 | #define AMS_SHOCK_ENABLE 0x09 | ||
38 | #define AMS_SHOCK_HIGH_LIMIT 0x0a | ||
39 | #define AMS_SHOCK_DEBOUNCE 0x0b | ||
40 | |||
41 | /* Global interrupt and power control register */ | ||
42 | #define AMS_CONTROL 0x0c | ||
43 | |||
44 | static u8 ams_pmu_cmd; | ||
45 | |||
46 | static void ams_pmu_req_complete(struct adb_request *req) | ||
47 | { | ||
48 | complete((struct completion *)req->arg); | ||
49 | } | ||
50 | |||
51 | /* Only call this function from task context */ | ||
52 | static void ams_pmu_set_register(u8 reg, u8 value) | ||
53 | { | ||
54 | static struct adb_request req; | ||
55 | DECLARE_COMPLETION(req_complete); | ||
56 | |||
57 | req.arg = &req_complete; | ||
58 | if (pmu_request(&req, ams_pmu_req_complete, 4, ams_pmu_cmd, 0x00, reg, value)) | ||
59 | return; | ||
60 | |||
61 | wait_for_completion(&req_complete); | ||
62 | } | ||
63 | |||
64 | /* Only call this function from task context */ | ||
65 | static u8 ams_pmu_get_register(u8 reg) | ||
66 | { | ||
67 | static struct adb_request req; | ||
68 | DECLARE_COMPLETION(req_complete); | ||
69 | |||
70 | req.arg = &req_complete; | ||
71 | if (pmu_request(&req, ams_pmu_req_complete, 3, ams_pmu_cmd, 0x01, reg)) | ||
72 | return 0; | ||
73 | |||
74 | wait_for_completion(&req_complete); | ||
75 | |||
76 | if (req.reply_len > 0) | ||
77 | return req.reply[0]; | ||
78 | else | ||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | /* Enables or disables the specified interrupts */ | ||
83 | static void ams_pmu_set_irq(enum ams_irq reg, char enable) | ||
84 | { | ||
85 | if (reg & AMS_IRQ_FREEFALL) { | ||
86 | u8 val = ams_pmu_get_register(AMS_FF_ENABLE); | ||
87 | if (enable) | ||
88 | val |= 0x80; | ||
89 | else | ||
90 | val &= ~0x80; | ||
91 | ams_pmu_set_register(AMS_FF_ENABLE, val); | ||
92 | } | ||
93 | |||
94 | if (reg & AMS_IRQ_SHOCK) { | ||
95 | u8 val = ams_pmu_get_register(AMS_SHOCK_ENABLE); | ||
96 | if (enable) | ||
97 | val |= 0x80; | ||
98 | else | ||
99 | val &= ~0x80; | ||
100 | ams_pmu_set_register(AMS_SHOCK_ENABLE, val); | ||
101 | } | ||
102 | |||
103 | if (reg & AMS_IRQ_GLOBAL) { | ||
104 | u8 val = ams_pmu_get_register(AMS_CONTROL); | ||
105 | if (enable) | ||
106 | val |= 0x80; | ||
107 | else | ||
108 | val &= ~0x80; | ||
109 | ams_pmu_set_register(AMS_CONTROL, val); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | static void ams_pmu_clear_irq(enum ams_irq reg) | ||
114 | { | ||
115 | if (reg & AMS_IRQ_FREEFALL) | ||
116 | ams_pmu_set_register(AMS_FF_CLEAR, 0x00); | ||
117 | |||
118 | if (reg & AMS_IRQ_SHOCK) | ||
119 | ams_pmu_set_register(AMS_SHOCK_CLEAR, 0x00); | ||
120 | } | ||
121 | |||
122 | static u8 ams_pmu_get_vendor(void) | ||
123 | { | ||
124 | return ams_pmu_get_register(AMS_VENDOR); | ||
125 | } | ||
126 | |||
127 | static void ams_pmu_get_xyz(s8 *x, s8 *y, s8 *z) | ||
128 | { | ||
129 | *x = ams_pmu_get_register(AMS_X); | ||
130 | *y = ams_pmu_get_register(AMS_Y); | ||
131 | *z = ams_pmu_get_register(AMS_Z); | ||
132 | } | ||
133 | |||
134 | static void ams_pmu_exit(void) | ||
135 | { | ||
136 | /* Disable interrupts */ | ||
137 | ams_pmu_set_irq(AMS_IRQ_ALL, 0); | ||
138 | |||
139 | /* Clear interrupts */ | ||
140 | ams_pmu_clear_irq(AMS_IRQ_ALL); | ||
141 | |||
142 | ams_info.has_device = 0; | ||
143 | |||
144 | printk(KERN_INFO "ams: Unloading\n"); | ||
145 | } | ||
146 | |||
147 | int __init ams_pmu_init(struct device_node *np) | ||
148 | { | ||
149 | u32 *prop; | ||
150 | int result; | ||
151 | |||
152 | mutex_lock(&ams_info.lock); | ||
153 | |||
154 | /* Set implementation stuff */ | ||
155 | ams_info.of_node = np; | ||
156 | ams_info.exit = ams_pmu_exit; | ||
157 | ams_info.get_vendor = ams_pmu_get_vendor; | ||
158 | ams_info.get_xyz = ams_pmu_get_xyz; | ||
159 | ams_info.clear_irq = ams_pmu_clear_irq; | ||
160 | ams_info.bustype = BUS_HOST; | ||
161 | |||
162 | /* Get PMU command, should be 0x4e, but we can never know */ | ||
163 | prop = (u32*)get_property(ams_info.of_node, "reg", NULL); | ||
164 | if (!prop) { | ||
165 | result = -ENODEV; | ||
166 | goto exit; | ||
167 | } | ||
168 | ams_pmu_cmd = ((*prop) >> 8) & 0xff; | ||
169 | |||
170 | /* Disable interrupts */ | ||
171 | ams_pmu_set_irq(AMS_IRQ_ALL, 0); | ||
172 | |||
173 | /* Clear interrupts */ | ||
174 | ams_pmu_clear_irq(AMS_IRQ_ALL); | ||
175 | |||
176 | result = ams_sensor_attach(); | ||
177 | if (result < 0) | ||
178 | goto exit; | ||
179 | |||
180 | /* Set default values */ | ||
181 | ams_pmu_set_register(AMS_FF_LOW_LIMIT, 0x15); | ||
182 | ams_pmu_set_register(AMS_FF_ENABLE, 0x08); | ||
183 | ams_pmu_set_register(AMS_FF_DEBOUNCE, 0x14); | ||
184 | |||
185 | ams_pmu_set_register(AMS_SHOCK_HIGH_LIMIT, 0x60); | ||
186 | ams_pmu_set_register(AMS_SHOCK_ENABLE, 0x0f); | ||
187 | ams_pmu_set_register(AMS_SHOCK_DEBOUNCE, 0x14); | ||
188 | |||
189 | ams_pmu_set_register(AMS_CONTROL, 0x4f); | ||
190 | |||
191 | /* Clear interrupts */ | ||
192 | ams_pmu_clear_irq(AMS_IRQ_ALL); | ||
193 | |||
194 | ams_info.has_device = 1; | ||
195 | |||
196 | /* Enable interrupts */ | ||
197 | ams_pmu_set_irq(AMS_IRQ_ALL, 1); | ||
198 | |||
199 | printk(KERN_INFO "ams: Found PMU based motion sensor\n"); | ||
200 | |||
201 | result = 0; | ||
202 | |||
203 | exit: | ||
204 | mutex_unlock(&ams_info.lock); | ||
205 | |||
206 | return result; | ||
207 | } | ||
diff --git a/drivers/hwmon/ams/ams.h b/drivers/hwmon/ams/ams.h new file mode 100644 index 000000000000..240730e6bcde --- /dev/null +++ b/drivers/hwmon/ams/ams.h | |||
@@ -0,0 +1,72 @@ | |||
1 | #include <linux/i2c.h> | ||
2 | #include <linux/input.h> | ||
3 | #include <linux/kthread.h> | ||
4 | #include <linux/mutex.h> | ||
5 | #include <linux/spinlock.h> | ||
6 | #include <linux/types.h> | ||
7 | #include <asm/of_device.h> | ||
8 | |||
9 | enum ams_irq { | ||
10 | AMS_IRQ_FREEFALL = 0x01, | ||
11 | AMS_IRQ_SHOCK = 0x02, | ||
12 | AMS_IRQ_GLOBAL = 0x04, | ||
13 | AMS_IRQ_ALL = | ||
14 | AMS_IRQ_FREEFALL | | ||
15 | AMS_IRQ_SHOCK | | ||
16 | AMS_IRQ_GLOBAL, | ||
17 | }; | ||
18 | |||
19 | struct ams { | ||
20 | /* Locks */ | ||
21 | spinlock_t irq_lock; | ||
22 | struct mutex lock; | ||
23 | |||
24 | /* General properties */ | ||
25 | struct device_node *of_node; | ||
26 | struct of_device *of_dev; | ||
27 | char has_device; | ||
28 | char vflag; | ||
29 | u32 orient1; | ||
30 | u32 orient2; | ||
31 | |||
32 | /* Interrupt worker */ | ||
33 | struct work_struct worker; | ||
34 | u8 worker_irqs; | ||
35 | |||
36 | /* Implementation | ||
37 | * | ||
38 | * Only call these functions with the main lock held. | ||
39 | */ | ||
40 | void (*exit)(void); | ||
41 | |||
42 | void (*get_xyz)(s8 *x, s8 *y, s8 *z); | ||
43 | u8 (*get_vendor)(void); | ||
44 | |||
45 | void (*clear_irq)(enum ams_irq reg); | ||
46 | |||
47 | #ifdef CONFIG_SENSORS_AMS_I2C | ||
48 | /* I2C properties */ | ||
49 | int i2c_bus; | ||
50 | int i2c_address; | ||
51 | struct i2c_client i2c_client; | ||
52 | #endif | ||
53 | |||
54 | /* Joystick emulation */ | ||
55 | struct task_struct *kthread; | ||
56 | struct input_dev *idev; | ||
57 | __u16 bustype; | ||
58 | |||
59 | /* calibrated null values */ | ||
60 | int xcalib, ycalib, zcalib; | ||
61 | }; | ||
62 | |||
63 | extern struct ams ams_info; | ||
64 | |||
65 | extern void ams_sensors(s8 *x, s8 *y, s8 *z); | ||
66 | extern int ams_sensor_attach(void); | ||
67 | |||
68 | extern int ams_pmu_init(struct device_node *np); | ||
69 | extern int ams_i2c_init(struct device_node *np); | ||
70 | |||
71 | extern int ams_input_init(void); | ||
72 | extern void ams_input_exit(void); | ||
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c index de17a72149d9..a272cae8f60e 100644 --- a/drivers/hwmon/f71805f.c +++ b/drivers/hwmon/f71805f.c | |||
@@ -1,12 +1,15 @@ | |||
1 | /* | 1 | /* |
2 | * f71805f.c - driver for the Fintek F71805F/FG Super-I/O chip integrated | 2 | * f71805f.c - driver for the Fintek F71805F/FG and F71872F/FG Super-I/O |
3 | * hardware monitoring features | 3 | * chips integrated hardware monitoring features |
4 | * Copyright (C) 2005-2006 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2005-2006 Jean Delvare <khali@linux-fr.org> |
5 | * | 5 | * |
6 | * The F71805F/FG is a LPC Super-I/O chip made by Fintek. It integrates | 6 | * The F71805F/FG is a LPC Super-I/O chip made by Fintek. It integrates |
7 | * complete hardware monitoring features: voltage, fan and temperature | 7 | * complete hardware monitoring features: voltage, fan and temperature |
8 | * sensors, and manual and automatic fan speed control. | 8 | * sensors, and manual and automatic fan speed control. |
9 | * | 9 | * |
10 | * The F71872F/FG is almost the same, with two more voltages monitored, | ||
11 | * and 6 VID inputs. | ||
12 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | 13 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 14 | * it under the terms of the GNU General Public License as published by |
12 | * the Free Software Foundation; either version 2 of the License, or | 15 | * the Free Software Foundation; either version 2 of the License, or |
@@ -37,6 +40,7 @@ | |||
37 | static struct platform_device *pdev; | 40 | static struct platform_device *pdev; |
38 | 41 | ||
39 | #define DRVNAME "f71805f" | 42 | #define DRVNAME "f71805f" |
43 | enum kinds { f71805f, f71872f }; | ||
40 | 44 | ||
41 | /* | 45 | /* |
42 | * Super-I/O constants and functions | 46 | * Super-I/O constants and functions |
@@ -48,11 +52,13 @@ static struct platform_device *pdev; | |||
48 | #define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */ | 52 | #define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */ |
49 | #define SIO_REG_DEVREV 0x22 /* Device revision */ | 53 | #define SIO_REG_DEVREV 0x22 /* Device revision */ |
50 | #define SIO_REG_MANID 0x23 /* Fintek ID (2 bytes) */ | 54 | #define SIO_REG_MANID 0x23 /* Fintek ID (2 bytes) */ |
55 | #define SIO_REG_FNSEL1 0x29 /* Multi Function Select 1 (F71872F) */ | ||
51 | #define SIO_REG_ENABLE 0x30 /* Logical device enable */ | 56 | #define SIO_REG_ENABLE 0x30 /* Logical device enable */ |
52 | #define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */ | 57 | #define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */ |
53 | 58 | ||
54 | #define SIO_FINTEK_ID 0x1934 | 59 | #define SIO_FINTEK_ID 0x1934 |
55 | #define SIO_F71805F_ID 0x0406 | 60 | #define SIO_F71805F_ID 0x0406 |
61 | #define SIO_F71872F_ID 0x0341 | ||
56 | 62 | ||
57 | static inline int | 63 | static inline int |
58 | superio_inb(int base, int reg) | 64 | superio_inb(int base, int reg) |
@@ -96,22 +102,25 @@ superio_exit(int base) | |||
96 | * ISA constants | 102 | * ISA constants |
97 | */ | 103 | */ |
98 | 104 | ||
99 | #define REGION_LENGTH 2 | 105 | #define REGION_LENGTH 8 |
100 | #define ADDR_REG_OFFSET 0 | 106 | #define ADDR_REG_OFFSET 5 |
101 | #define DATA_REG_OFFSET 1 | 107 | #define DATA_REG_OFFSET 6 |
102 | 108 | ||
103 | /* | 109 | /* |
104 | * Registers | 110 | * Registers |
105 | */ | 111 | */ |
106 | 112 | ||
107 | /* in nr from 0 to 8 (8-bit values) */ | 113 | /* in nr from 0 to 10 (8-bit values) */ |
108 | #define F71805F_REG_IN(nr) (0x10 + (nr)) | 114 | #define F71805F_REG_IN(nr) (0x10 + (nr)) |
109 | #define F71805F_REG_IN_HIGH(nr) (0x40 + 2 * (nr)) | 115 | #define F71805F_REG_IN_HIGH(nr) ((nr) < 10 ? 0x40 + 2 * (nr) : 0x2E) |
110 | #define F71805F_REG_IN_LOW(nr) (0x41 + 2 * (nr)) | 116 | #define F71805F_REG_IN_LOW(nr) ((nr) < 10 ? 0x41 + 2 * (nr) : 0x2F) |
111 | /* fan nr from 0 to 2 (12-bit values, two registers) */ | 117 | /* fan nr from 0 to 2 (12-bit values, two registers) */ |
112 | #define F71805F_REG_FAN(nr) (0x20 + 2 * (nr)) | 118 | #define F71805F_REG_FAN(nr) (0x20 + 2 * (nr)) |
113 | #define F71805F_REG_FAN_LOW(nr) (0x28 + 2 * (nr)) | 119 | #define F71805F_REG_FAN_LOW(nr) (0x28 + 2 * (nr)) |
120 | #define F71805F_REG_FAN_TARGET(nr) (0x69 + 16 * (nr)) | ||
114 | #define F71805F_REG_FAN_CTRL(nr) (0x60 + 16 * (nr)) | 121 | #define F71805F_REG_FAN_CTRL(nr) (0x60 + 16 * (nr)) |
122 | #define F71805F_REG_PWM_FREQ(nr) (0x63 + 16 * (nr)) | ||
123 | #define F71805F_REG_PWM_DUTY(nr) (0x6B + 16 * (nr)) | ||
115 | /* temp nr from 0 to 2 (8-bit values) */ | 124 | /* temp nr from 0 to 2 (8-bit values) */ |
116 | #define F71805F_REG_TEMP(nr) (0x1B + (nr)) | 125 | #define F71805F_REG_TEMP(nr) (0x1B + (nr)) |
117 | #define F71805F_REG_TEMP_HIGH(nr) (0x54 + 2 * (nr)) | 126 | #define F71805F_REG_TEMP_HIGH(nr) (0x54 + 2 * (nr)) |
@@ -122,6 +131,14 @@ superio_exit(int base) | |||
122 | /* status nr from 0 to 2 */ | 131 | /* status nr from 0 to 2 */ |
123 | #define F71805F_REG_STATUS(nr) (0x36 + (nr)) | 132 | #define F71805F_REG_STATUS(nr) (0x36 + (nr)) |
124 | 133 | ||
134 | /* individual register bits */ | ||
135 | #define FAN_CTRL_DC_MODE 0x10 | ||
136 | #define FAN_CTRL_LATCH_FULL 0x08 | ||
137 | #define FAN_CTRL_MODE_MASK 0x03 | ||
138 | #define FAN_CTRL_MODE_SPEED 0x00 | ||
139 | #define FAN_CTRL_MODE_TEMPERATURE 0x01 | ||
140 | #define FAN_CTRL_MODE_MANUAL 0x02 | ||
141 | |||
125 | /* | 142 | /* |
126 | * Data structures and manipulation thereof | 143 | * Data structures and manipulation thereof |
127 | */ | 144 | */ |
@@ -138,12 +155,16 @@ struct f71805f_data { | |||
138 | unsigned long last_limits; /* In jiffies */ | 155 | unsigned long last_limits; /* In jiffies */ |
139 | 156 | ||
140 | /* Register values */ | 157 | /* Register values */ |
141 | u8 in[9]; | 158 | u8 in[11]; |
142 | u8 in_high[9]; | 159 | u8 in_high[11]; |
143 | u8 in_low[9]; | 160 | u8 in_low[11]; |
161 | u16 has_in; | ||
144 | u16 fan[3]; | 162 | u16 fan[3]; |
145 | u16 fan_low[3]; | 163 | u16 fan_low[3]; |
146 | u8 fan_enabled; /* Read once at init time */ | 164 | u16 fan_target[3]; |
165 | u8 fan_ctrl[3]; | ||
166 | u8 pwm[3]; | ||
167 | u8 pwm_freq[3]; | ||
147 | u8 temp[3]; | 168 | u8 temp[3]; |
148 | u8 temp_high[3]; | 169 | u8 temp_high[3]; |
149 | u8 temp_hyst[3]; | 170 | u8 temp_hyst[3]; |
@@ -151,6 +172,11 @@ struct f71805f_data { | |||
151 | unsigned long alarms; | 172 | unsigned long alarms; |
152 | }; | 173 | }; |
153 | 174 | ||
175 | struct f71805f_sio_data { | ||
176 | enum kinds kind; | ||
177 | u8 fnsel1; | ||
178 | }; | ||
179 | |||
154 | static inline long in_from_reg(u8 reg) | 180 | static inline long in_from_reg(u8 reg) |
155 | { | 181 | { |
156 | return (reg * 8); | 182 | return (reg * 8); |
@@ -200,6 +226,33 @@ static inline u16 fan_to_reg(long rpm) | |||
200 | return (1500000 / rpm); | 226 | return (1500000 / rpm); |
201 | } | 227 | } |
202 | 228 | ||
229 | static inline unsigned long pwm_freq_from_reg(u8 reg) | ||
230 | { | ||
231 | unsigned long clock = (reg & 0x80) ? 48000000UL : 1000000UL; | ||
232 | |||
233 | reg &= 0x7f; | ||
234 | if (reg == 0) | ||
235 | reg++; | ||
236 | return clock / (reg << 8); | ||
237 | } | ||
238 | |||
239 | static inline u8 pwm_freq_to_reg(unsigned long val) | ||
240 | { | ||
241 | if (val >= 187500) /* The highest we can do */ | ||
242 | return 0x80; | ||
243 | if (val >= 1475) /* Use 48 MHz clock */ | ||
244 | return 0x80 | (48000000UL / (val << 8)); | ||
245 | if (val < 31) /* The lowest we can do */ | ||
246 | return 0x7f; | ||
247 | else /* Use 1 MHz clock */ | ||
248 | return 1000000UL / (val << 8); | ||
249 | } | ||
250 | |||
251 | static inline int pwm_mode_from_reg(u8 reg) | ||
252 | { | ||
253 | return !(reg & FAN_CTRL_DC_MODE); | ||
254 | } | ||
255 | |||
203 | static inline long temp_from_reg(u8 reg) | 256 | static inline long temp_from_reg(u8 reg) |
204 | { | 257 | { |
205 | return (reg * 1000); | 258 | return (reg * 1000); |
@@ -274,16 +327,21 @@ static struct f71805f_data *f71805f_update_device(struct device *dev) | |||
274 | /* Limit registers cache is refreshed after 60 seconds */ | 327 | /* Limit registers cache is refreshed after 60 seconds */ |
275 | if (time_after(jiffies, data->last_updated + 60 * HZ) | 328 | if (time_after(jiffies, data->last_updated + 60 * HZ) |
276 | || !data->valid) { | 329 | || !data->valid) { |
277 | for (nr = 0; nr < 9; nr++) { | 330 | for (nr = 0; nr < 11; nr++) { |
331 | if (!(data->has_in & (1 << nr))) | ||
332 | continue; | ||
278 | data->in_high[nr] = f71805f_read8(data, | 333 | data->in_high[nr] = f71805f_read8(data, |
279 | F71805F_REG_IN_HIGH(nr)); | 334 | F71805F_REG_IN_HIGH(nr)); |
280 | data->in_low[nr] = f71805f_read8(data, | 335 | data->in_low[nr] = f71805f_read8(data, |
281 | F71805F_REG_IN_LOW(nr)); | 336 | F71805F_REG_IN_LOW(nr)); |
282 | } | 337 | } |
283 | for (nr = 0; nr < 3; nr++) { | 338 | for (nr = 0; nr < 3; nr++) { |
284 | if (data->fan_enabled & (1 << nr)) | 339 | data->fan_low[nr] = f71805f_read16(data, |
285 | data->fan_low[nr] = f71805f_read16(data, | 340 | F71805F_REG_FAN_LOW(nr)); |
286 | F71805F_REG_FAN_LOW(nr)); | 341 | data->fan_target[nr] = f71805f_read16(data, |
342 | F71805F_REG_FAN_TARGET(nr)); | ||
343 | data->pwm_freq[nr] = f71805f_read8(data, | ||
344 | F71805F_REG_PWM_FREQ(nr)); | ||
287 | } | 345 | } |
288 | for (nr = 0; nr < 3; nr++) { | 346 | for (nr = 0; nr < 3; nr++) { |
289 | data->temp_high[nr] = f71805f_read8(data, | 347 | data->temp_high[nr] = f71805f_read8(data, |
@@ -299,14 +357,19 @@ static struct f71805f_data *f71805f_update_device(struct device *dev) | |||
299 | /* Measurement registers cache is refreshed after 1 second */ | 357 | /* Measurement registers cache is refreshed after 1 second */ |
300 | if (time_after(jiffies, data->last_updated + HZ) | 358 | if (time_after(jiffies, data->last_updated + HZ) |
301 | || !data->valid) { | 359 | || !data->valid) { |
302 | for (nr = 0; nr < 9; nr++) { | 360 | for (nr = 0; nr < 11; nr++) { |
361 | if (!(data->has_in & (1 << nr))) | ||
362 | continue; | ||
303 | data->in[nr] = f71805f_read8(data, | 363 | data->in[nr] = f71805f_read8(data, |
304 | F71805F_REG_IN(nr)); | 364 | F71805F_REG_IN(nr)); |
305 | } | 365 | } |
306 | for (nr = 0; nr < 3; nr++) { | 366 | for (nr = 0; nr < 3; nr++) { |
307 | if (data->fan_enabled & (1 << nr)) | 367 | data->fan[nr] = f71805f_read16(data, |
308 | data->fan[nr] = f71805f_read16(data, | 368 | F71805F_REG_FAN(nr)); |
309 | F71805F_REG_FAN(nr)); | 369 | data->fan_ctrl[nr] = f71805f_read8(data, |
370 | F71805F_REG_FAN_CTRL(nr)); | ||
371 | data->pwm[nr] = f71805f_read8(data, | ||
372 | F71805F_REG_PWM_DUTY(nr)); | ||
310 | } | 373 | } |
311 | for (nr = 0; nr < 3; nr++) { | 374 | for (nr = 0; nr < 3; nr++) { |
312 | data->temp[nr] = f71805f_read8(data, | 375 | data->temp[nr] = f71805f_read8(data, |
@@ -333,35 +396,43 @@ static ssize_t show_in0(struct device *dev, struct device_attribute *devattr, | |||
333 | char *buf) | 396 | char *buf) |
334 | { | 397 | { |
335 | struct f71805f_data *data = f71805f_update_device(dev); | 398 | struct f71805f_data *data = f71805f_update_device(dev); |
399 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
400 | int nr = attr->index; | ||
336 | 401 | ||
337 | return sprintf(buf, "%ld\n", in0_from_reg(data->in[0])); | 402 | return sprintf(buf, "%ld\n", in0_from_reg(data->in[nr])); |
338 | } | 403 | } |
339 | 404 | ||
340 | static ssize_t show_in0_max(struct device *dev, struct device_attribute | 405 | static ssize_t show_in0_max(struct device *dev, struct device_attribute |
341 | *devattr, char *buf) | 406 | *devattr, char *buf) |
342 | { | 407 | { |
343 | struct f71805f_data *data = f71805f_update_device(dev); | 408 | struct f71805f_data *data = f71805f_update_device(dev); |
409 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
410 | int nr = attr->index; | ||
344 | 411 | ||
345 | return sprintf(buf, "%ld\n", in0_from_reg(data->in_high[0])); | 412 | return sprintf(buf, "%ld\n", in0_from_reg(data->in_high[nr])); |
346 | } | 413 | } |
347 | 414 | ||
348 | static ssize_t show_in0_min(struct device *dev, struct device_attribute | 415 | static ssize_t show_in0_min(struct device *dev, struct device_attribute |
349 | *devattr, char *buf) | 416 | *devattr, char *buf) |
350 | { | 417 | { |
351 | struct f71805f_data *data = f71805f_update_device(dev); | 418 | struct f71805f_data *data = f71805f_update_device(dev); |
419 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
420 | int nr = attr->index; | ||
352 | 421 | ||
353 | return sprintf(buf, "%ld\n", in0_from_reg(data->in_low[0])); | 422 | return sprintf(buf, "%ld\n", in0_from_reg(data->in_low[nr])); |
354 | } | 423 | } |
355 | 424 | ||
356 | static ssize_t set_in0_max(struct device *dev, struct device_attribute | 425 | static ssize_t set_in0_max(struct device *dev, struct device_attribute |
357 | *devattr, const char *buf, size_t count) | 426 | *devattr, const char *buf, size_t count) |
358 | { | 427 | { |
359 | struct f71805f_data *data = dev_get_drvdata(dev); | 428 | struct f71805f_data *data = dev_get_drvdata(dev); |
429 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
430 | int nr = attr->index; | ||
360 | long val = simple_strtol(buf, NULL, 10); | 431 | long val = simple_strtol(buf, NULL, 10); |
361 | 432 | ||
362 | mutex_lock(&data->update_lock); | 433 | mutex_lock(&data->update_lock); |
363 | data->in_high[0] = in0_to_reg(val); | 434 | data->in_high[nr] = in0_to_reg(val); |
364 | f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]); | 435 | f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]); |
365 | mutex_unlock(&data->update_lock); | 436 | mutex_unlock(&data->update_lock); |
366 | 437 | ||
367 | return count; | 438 | return count; |
@@ -371,11 +442,13 @@ static ssize_t set_in0_min(struct device *dev, struct device_attribute | |||
371 | *devattr, const char *buf, size_t count) | 442 | *devattr, const char *buf, size_t count) |
372 | { | 443 | { |
373 | struct f71805f_data *data = dev_get_drvdata(dev); | 444 | struct f71805f_data *data = dev_get_drvdata(dev); |
445 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
446 | int nr = attr->index; | ||
374 | long val = simple_strtol(buf, NULL, 10); | 447 | long val = simple_strtol(buf, NULL, 10); |
375 | 448 | ||
376 | mutex_lock(&data->update_lock); | 449 | mutex_lock(&data->update_lock); |
377 | data->in_low[0] = in0_to_reg(val); | 450 | data->in_low[nr] = in0_to_reg(val); |
378 | f71805f_write8(data, F71805F_REG_IN_LOW(0), data->in_low[0]); | 451 | f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]); |
379 | mutex_unlock(&data->update_lock); | 452 | mutex_unlock(&data->update_lock); |
380 | 453 | ||
381 | return count; | 454 | return count; |
@@ -463,6 +536,16 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute | |||
463 | return sprintf(buf, "%ld\n", fan_from_reg(data->fan_low[nr])); | 536 | return sprintf(buf, "%ld\n", fan_from_reg(data->fan_low[nr])); |
464 | } | 537 | } |
465 | 538 | ||
539 | static ssize_t show_fan_target(struct device *dev, struct device_attribute | ||
540 | *devattr, char *buf) | ||
541 | { | ||
542 | struct f71805f_data *data = f71805f_update_device(dev); | ||
543 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
544 | int nr = attr->index; | ||
545 | |||
546 | return sprintf(buf, "%ld\n", fan_from_reg(data->fan_target[nr])); | ||
547 | } | ||
548 | |||
466 | static ssize_t set_fan_min(struct device *dev, struct device_attribute | 549 | static ssize_t set_fan_min(struct device *dev, struct device_attribute |
467 | *devattr, const char *buf, size_t count) | 550 | *devattr, const char *buf, size_t count) |
468 | { | 551 | { |
@@ -479,6 +562,157 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute | |||
479 | return count; | 562 | return count; |
480 | } | 563 | } |
481 | 564 | ||
565 | static ssize_t set_fan_target(struct device *dev, struct device_attribute | ||
566 | *devattr, const char *buf, size_t count) | ||
567 | { | ||
568 | struct f71805f_data *data = dev_get_drvdata(dev); | ||
569 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
570 | int nr = attr->index; | ||
571 | long val = simple_strtol(buf, NULL, 10); | ||
572 | |||
573 | mutex_lock(&data->update_lock); | ||
574 | data->fan_target[nr] = fan_to_reg(val); | ||
575 | f71805f_write16(data, F71805F_REG_FAN_TARGET(nr), | ||
576 | data->fan_target[nr]); | ||
577 | mutex_unlock(&data->update_lock); | ||
578 | |||
579 | return count; | ||
580 | } | ||
581 | |||
582 | static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, | ||
583 | char *buf) | ||
584 | { | ||
585 | struct f71805f_data *data = f71805f_update_device(dev); | ||
586 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
587 | int nr = attr->index; | ||
588 | |||
589 | return sprintf(buf, "%d\n", (int)data->pwm[nr]); | ||
590 | } | ||
591 | |||
592 | static ssize_t show_pwm_enable(struct device *dev, struct device_attribute | ||
593 | *devattr, char *buf) | ||
594 | { | ||
595 | struct f71805f_data *data = f71805f_update_device(dev); | ||
596 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
597 | int nr = attr->index; | ||
598 | int mode; | ||
599 | |||
600 | switch (data->fan_ctrl[nr] & FAN_CTRL_MODE_MASK) { | ||
601 | case FAN_CTRL_MODE_SPEED: | ||
602 | mode = 3; | ||
603 | break; | ||
604 | case FAN_CTRL_MODE_TEMPERATURE: | ||
605 | mode = 2; | ||
606 | break; | ||
607 | default: /* MANUAL */ | ||
608 | mode = 1; | ||
609 | } | ||
610 | |||
611 | return sprintf(buf, "%d\n", mode); | ||
612 | } | ||
613 | |||
614 | static ssize_t show_pwm_freq(struct device *dev, struct device_attribute | ||
615 | *devattr, char *buf) | ||
616 | { | ||
617 | struct f71805f_data *data = f71805f_update_device(dev); | ||
618 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
619 | int nr = attr->index; | ||
620 | |||
621 | return sprintf(buf, "%lu\n", pwm_freq_from_reg(data->pwm_freq[nr])); | ||
622 | } | ||
623 | |||
624 | static ssize_t show_pwm_mode(struct device *dev, struct device_attribute | ||
625 | *devattr, char *buf) | ||
626 | { | ||
627 | struct f71805f_data *data = f71805f_update_device(dev); | ||
628 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
629 | int nr = attr->index; | ||
630 | |||
631 | return sprintf(buf, "%d\n", pwm_mode_from_reg(data->fan_ctrl[nr])); | ||
632 | } | ||
633 | |||
634 | static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, | ||
635 | const char *buf, size_t count) | ||
636 | { | ||
637 | struct f71805f_data *data = dev_get_drvdata(dev); | ||
638 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
639 | int nr = attr->index; | ||
640 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
641 | |||
642 | if (val > 255) | ||
643 | return -EINVAL; | ||
644 | |||
645 | mutex_lock(&data->update_lock); | ||
646 | data->pwm[nr] = val; | ||
647 | f71805f_write8(data, F71805F_REG_PWM_DUTY(nr), data->pwm[nr]); | ||
648 | mutex_unlock(&data->update_lock); | ||
649 | |||
650 | return count; | ||
651 | } | ||
652 | |||
653 | static struct attribute *f71805f_attr_pwm[]; | ||
654 | |||
655 | static ssize_t set_pwm_enable(struct device *dev, struct device_attribute | ||
656 | *devattr, const char *buf, size_t count) | ||
657 | { | ||
658 | struct f71805f_data *data = dev_get_drvdata(dev); | ||
659 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
660 | int nr = attr->index; | ||
661 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
662 | u8 reg; | ||
663 | |||
664 | if (val < 1 || val > 3) | ||
665 | return -EINVAL; | ||
666 | |||
667 | if (val > 1) { /* Automatic mode, user can't set PWM value */ | ||
668 | if (sysfs_chmod_file(&dev->kobj, f71805f_attr_pwm[nr], | ||
669 | S_IRUGO)) | ||
670 | dev_dbg(dev, "chmod -w pwm%d failed\n", nr + 1); | ||
671 | } | ||
672 | |||
673 | mutex_lock(&data->update_lock); | ||
674 | reg = f71805f_read8(data, F71805F_REG_FAN_CTRL(nr)) | ||
675 | & ~FAN_CTRL_MODE_MASK; | ||
676 | switch (val) { | ||
677 | case 1: | ||
678 | reg |= FAN_CTRL_MODE_MANUAL; | ||
679 | break; | ||
680 | case 2: | ||
681 | reg |= FAN_CTRL_MODE_TEMPERATURE; | ||
682 | break; | ||
683 | case 3: | ||
684 | reg |= FAN_CTRL_MODE_SPEED; | ||
685 | break; | ||
686 | } | ||
687 | data->fan_ctrl[nr] = reg; | ||
688 | f71805f_write8(data, F71805F_REG_FAN_CTRL(nr), reg); | ||
689 | mutex_unlock(&data->update_lock); | ||
690 | |||
691 | if (val == 1) { /* Manual mode, user can set PWM value */ | ||
692 | if (sysfs_chmod_file(&dev->kobj, f71805f_attr_pwm[nr], | ||
693 | S_IRUGO | S_IWUSR)) | ||
694 | dev_dbg(dev, "chmod +w pwm%d failed\n", nr + 1); | ||
695 | } | ||
696 | |||
697 | return count; | ||
698 | } | ||
699 | |||
700 | static ssize_t set_pwm_freq(struct device *dev, struct device_attribute | ||
701 | *devattr, const char *buf, size_t count) | ||
702 | { | ||
703 | struct f71805f_data *data = dev_get_drvdata(dev); | ||
704 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
705 | int nr = attr->index; | ||
706 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
707 | |||
708 | mutex_lock(&data->update_lock); | ||
709 | data->pwm_freq[nr] = pwm_freq_to_reg(val); | ||
710 | f71805f_write8(data, F71805F_REG_PWM_FREQ(nr), data->pwm_freq[nr]); | ||
711 | mutex_unlock(&data->update_lock); | ||
712 | |||
713 | return count; | ||
714 | } | ||
715 | |||
482 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, | 716 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
483 | char *buf) | 717 | char *buf) |
484 | { | 718 | { |
@@ -557,7 +791,7 @@ static ssize_t show_alarms_in(struct device *dev, struct device_attribute | |||
557 | { | 791 | { |
558 | struct f71805f_data *data = f71805f_update_device(dev); | 792 | struct f71805f_data *data = f71805f_update_device(dev); |
559 | 793 | ||
560 | return sprintf(buf, "%lu\n", data->alarms & 0x1ff); | 794 | return sprintf(buf, "%lu\n", data->alarms & 0x7ff); |
561 | } | 795 | } |
562 | 796 | ||
563 | static ssize_t show_alarms_fan(struct device *dev, struct device_attribute | 797 | static ssize_t show_alarms_fan(struct device *dev, struct device_attribute |
@@ -594,9 +828,11 @@ static ssize_t show_name(struct device *dev, struct device_attribute | |||
594 | return sprintf(buf, "%s\n", data->name); | 828 | return sprintf(buf, "%s\n", data->name); |
595 | } | 829 | } |
596 | 830 | ||
597 | static DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL); | 831 | static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL, 0); |
598 | static DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max); | 832 | static SENSOR_DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR, |
599 | static DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min); | 833 | show_in0_max, set_in0_max, 0); |
834 | static SENSOR_DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR, | ||
835 | show_in0_min, set_in0_min, 0); | ||
600 | static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in, NULL, 1); | 836 | static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in, NULL, 1); |
601 | static SENSOR_DEVICE_ATTR(in1_max, S_IRUGO | S_IWUSR, | 837 | static SENSOR_DEVICE_ATTR(in1_max, S_IRUGO | S_IWUSR, |
602 | show_in_max, set_in_max, 1); | 838 | show_in_max, set_in_max, 1); |
@@ -637,16 +873,32 @@ static SENSOR_DEVICE_ATTR(in8_max, S_IRUGO | S_IWUSR, | |||
637 | show_in_max, set_in_max, 8); | 873 | show_in_max, set_in_max, 8); |
638 | static SENSOR_DEVICE_ATTR(in8_min, S_IRUGO | S_IWUSR, | 874 | static SENSOR_DEVICE_ATTR(in8_min, S_IRUGO | S_IWUSR, |
639 | show_in_min, set_in_min, 8); | 875 | show_in_min, set_in_min, 8); |
876 | static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, show_in0, NULL, 9); | ||
877 | static SENSOR_DEVICE_ATTR(in9_max, S_IRUGO | S_IWUSR, | ||
878 | show_in0_max, set_in0_max, 9); | ||
879 | static SENSOR_DEVICE_ATTR(in9_min, S_IRUGO | S_IWUSR, | ||
880 | show_in0_min, set_in0_min, 9); | ||
881 | static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, show_in0, NULL, 10); | ||
882 | static SENSOR_DEVICE_ATTR(in10_max, S_IRUGO | S_IWUSR, | ||
883 | show_in0_max, set_in0_max, 10); | ||
884 | static SENSOR_DEVICE_ATTR(in10_min, S_IRUGO | S_IWUSR, | ||
885 | show_in0_min, set_in0_min, 10); | ||
640 | 886 | ||
641 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); | 887 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); |
642 | static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO | S_IWUSR, | 888 | static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO | S_IWUSR, |
643 | show_fan_min, set_fan_min, 0); | 889 | show_fan_min, set_fan_min, 0); |
890 | static SENSOR_DEVICE_ATTR(fan1_target, S_IRUGO | S_IWUSR, | ||
891 | show_fan_target, set_fan_target, 0); | ||
644 | static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); | 892 | static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); |
645 | static SENSOR_DEVICE_ATTR(fan2_min, S_IRUGO | S_IWUSR, | 893 | static SENSOR_DEVICE_ATTR(fan2_min, S_IRUGO | S_IWUSR, |
646 | show_fan_min, set_fan_min, 1); | 894 | show_fan_min, set_fan_min, 1); |
895 | static SENSOR_DEVICE_ATTR(fan2_target, S_IRUGO | S_IWUSR, | ||
896 | show_fan_target, set_fan_target, 1); | ||
647 | static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); | 897 | static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); |
648 | static SENSOR_DEVICE_ATTR(fan3_min, S_IRUGO | S_IWUSR, | 898 | static SENSOR_DEVICE_ATTR(fan3_min, S_IRUGO | S_IWUSR, |
649 | show_fan_min, set_fan_min, 2); | 899 | show_fan_min, set_fan_min, 2); |
900 | static SENSOR_DEVICE_ATTR(fan3_target, S_IRUGO | S_IWUSR, | ||
901 | show_fan_target, set_fan_target, 2); | ||
650 | 902 | ||
651 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); | 903 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
652 | static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, | 904 | static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, |
@@ -667,6 +919,27 @@ static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, | |||
667 | show_temp_hyst, set_temp_hyst, 2); | 919 | show_temp_hyst, set_temp_hyst, 2); |
668 | static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2); | 920 | static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2); |
669 | 921 | ||
922 | /* pwm (value) files are created read-only, write permission is | ||
923 | then added or removed dynamically as needed */ | ||
924 | static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO, show_pwm, set_pwm, 0); | ||
925 | static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, | ||
926 | show_pwm_enable, set_pwm_enable, 0); | ||
927 | static SENSOR_DEVICE_ATTR(pwm1_freq, S_IRUGO | S_IWUSR, | ||
928 | show_pwm_freq, set_pwm_freq, 0); | ||
929 | static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0); | ||
930 | static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO, show_pwm, set_pwm, 1); | ||
931 | static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, | ||
932 | show_pwm_enable, set_pwm_enable, 1); | ||
933 | static SENSOR_DEVICE_ATTR(pwm2_freq, S_IRUGO | S_IWUSR, | ||
934 | show_pwm_freq, set_pwm_freq, 1); | ||
935 | static SENSOR_DEVICE_ATTR(pwm2_mode, S_IRUGO, show_pwm_mode, NULL, 1); | ||
936 | static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO, show_pwm, set_pwm, 2); | ||
937 | static SENSOR_DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR, | ||
938 | show_pwm_enable, set_pwm_enable, 2); | ||
939 | static SENSOR_DEVICE_ATTR(pwm3_freq, S_IRUGO | S_IWUSR, | ||
940 | show_pwm_freq, set_pwm_freq, 2); | ||
941 | static SENSOR_DEVICE_ATTR(pwm3_mode, S_IRUGO, show_pwm_mode, NULL, 2); | ||
942 | |||
670 | static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); | 943 | static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); |
671 | static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); | 944 | static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); |
672 | static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); | 945 | static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); |
@@ -676,6 +949,8 @@ static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 5); | |||
676 | static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 6); | 949 | static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 6); |
677 | static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 7); | 950 | static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 7); |
678 | static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 8); | 951 | static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 8); |
952 | static SENSOR_DEVICE_ATTR(in9_alarm, S_IRUGO, show_alarm, NULL, 9); | ||
953 | static SENSOR_DEVICE_ATTR(in10_alarm, S_IRUGO, show_alarm, NULL, 10); | ||
679 | static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 11); | 954 | static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 11); |
680 | static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 12); | 955 | static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 12); |
681 | static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13); | 956 | static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13); |
@@ -689,9 +964,9 @@ static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL); | |||
689 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | 964 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); |
690 | 965 | ||
691 | static struct attribute *f71805f_attributes[] = { | 966 | static struct attribute *f71805f_attributes[] = { |
692 | &dev_attr_in0_input.attr, | 967 | &sensor_dev_attr_in0_input.dev_attr.attr, |
693 | &dev_attr_in0_max.attr, | 968 | &sensor_dev_attr_in0_max.dev_attr.attr, |
694 | &dev_attr_in0_min.attr, | 969 | &sensor_dev_attr_in0_min.dev_attr.attr, |
695 | &sensor_dev_attr_in1_input.dev_attr.attr, | 970 | &sensor_dev_attr_in1_input.dev_attr.attr, |
696 | &sensor_dev_attr_in1_max.dev_attr.attr, | 971 | &sensor_dev_attr_in1_max.dev_attr.attr, |
697 | &sensor_dev_attr_in1_min.dev_attr.attr, | 972 | &sensor_dev_attr_in1_min.dev_attr.attr, |
@@ -701,9 +976,6 @@ static struct attribute *f71805f_attributes[] = { | |||
701 | &sensor_dev_attr_in3_input.dev_attr.attr, | 976 | &sensor_dev_attr_in3_input.dev_attr.attr, |
702 | &sensor_dev_attr_in3_max.dev_attr.attr, | 977 | &sensor_dev_attr_in3_max.dev_attr.attr, |
703 | &sensor_dev_attr_in3_min.dev_attr.attr, | 978 | &sensor_dev_attr_in3_min.dev_attr.attr, |
704 | &sensor_dev_attr_in4_input.dev_attr.attr, | ||
705 | &sensor_dev_attr_in4_max.dev_attr.attr, | ||
706 | &sensor_dev_attr_in4_min.dev_attr.attr, | ||
707 | &sensor_dev_attr_in5_input.dev_attr.attr, | 979 | &sensor_dev_attr_in5_input.dev_attr.attr, |
708 | &sensor_dev_attr_in5_max.dev_attr.attr, | 980 | &sensor_dev_attr_in5_max.dev_attr.attr, |
709 | &sensor_dev_attr_in5_min.dev_attr.attr, | 981 | &sensor_dev_attr_in5_min.dev_attr.attr, |
@@ -713,9 +985,29 @@ static struct attribute *f71805f_attributes[] = { | |||
713 | &sensor_dev_attr_in7_input.dev_attr.attr, | 985 | &sensor_dev_attr_in7_input.dev_attr.attr, |
714 | &sensor_dev_attr_in7_max.dev_attr.attr, | 986 | &sensor_dev_attr_in7_max.dev_attr.attr, |
715 | &sensor_dev_attr_in7_min.dev_attr.attr, | 987 | &sensor_dev_attr_in7_min.dev_attr.attr, |
716 | &sensor_dev_attr_in8_input.dev_attr.attr, | 988 | |
717 | &sensor_dev_attr_in8_max.dev_attr.attr, | 989 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
718 | &sensor_dev_attr_in8_min.dev_attr.attr, | 990 | &sensor_dev_attr_fan1_min.dev_attr.attr, |
991 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, | ||
992 | &sensor_dev_attr_fan1_target.dev_attr.attr, | ||
993 | &sensor_dev_attr_fan2_input.dev_attr.attr, | ||
994 | &sensor_dev_attr_fan2_min.dev_attr.attr, | ||
995 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, | ||
996 | &sensor_dev_attr_fan2_target.dev_attr.attr, | ||
997 | &sensor_dev_attr_fan3_input.dev_attr.attr, | ||
998 | &sensor_dev_attr_fan3_min.dev_attr.attr, | ||
999 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, | ||
1000 | &sensor_dev_attr_fan3_target.dev_attr.attr, | ||
1001 | |||
1002 | &sensor_dev_attr_pwm1.dev_attr.attr, | ||
1003 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, | ||
1004 | &sensor_dev_attr_pwm1_mode.dev_attr.attr, | ||
1005 | &sensor_dev_attr_pwm2.dev_attr.attr, | ||
1006 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, | ||
1007 | &sensor_dev_attr_pwm2_mode.dev_attr.attr, | ||
1008 | &sensor_dev_attr_pwm3.dev_attr.attr, | ||
1009 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, | ||
1010 | &sensor_dev_attr_pwm3_mode.dev_attr.attr, | ||
719 | 1011 | ||
720 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 1012 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
721 | &sensor_dev_attr_temp1_max.dev_attr.attr, | 1013 | &sensor_dev_attr_temp1_max.dev_attr.attr, |
@@ -734,11 +1026,9 @@ static struct attribute *f71805f_attributes[] = { | |||
734 | &sensor_dev_attr_in1_alarm.dev_attr.attr, | 1026 | &sensor_dev_attr_in1_alarm.dev_attr.attr, |
735 | &sensor_dev_attr_in2_alarm.dev_attr.attr, | 1027 | &sensor_dev_attr_in2_alarm.dev_attr.attr, |
736 | &sensor_dev_attr_in3_alarm.dev_attr.attr, | 1028 | &sensor_dev_attr_in3_alarm.dev_attr.attr, |
737 | &sensor_dev_attr_in4_alarm.dev_attr.attr, | ||
738 | &sensor_dev_attr_in5_alarm.dev_attr.attr, | 1029 | &sensor_dev_attr_in5_alarm.dev_attr.attr, |
739 | &sensor_dev_attr_in6_alarm.dev_attr.attr, | 1030 | &sensor_dev_attr_in6_alarm.dev_attr.attr, |
740 | &sensor_dev_attr_in7_alarm.dev_attr.attr, | 1031 | &sensor_dev_attr_in7_alarm.dev_attr.attr, |
741 | &sensor_dev_attr_in8_alarm.dev_attr.attr, | ||
742 | &dev_attr_alarms_in.attr, | 1032 | &dev_attr_alarms_in.attr, |
743 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, | 1033 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, |
744 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, | 1034 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, |
@@ -754,29 +1044,59 @@ static const struct attribute_group f71805f_group = { | |||
754 | .attrs = f71805f_attributes, | 1044 | .attrs = f71805f_attributes, |
755 | }; | 1045 | }; |
756 | 1046 | ||
757 | static struct attribute *f71805f_attributes_fan[3][4] = { | 1047 | static struct attribute *f71805f_attributes_optin[4][5] = { |
758 | { | 1048 | { |
759 | &sensor_dev_attr_fan1_input.dev_attr.attr, | 1049 | &sensor_dev_attr_in4_input.dev_attr.attr, |
760 | &sensor_dev_attr_fan1_min.dev_attr.attr, | 1050 | &sensor_dev_attr_in4_max.dev_attr.attr, |
761 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, | 1051 | &sensor_dev_attr_in4_min.dev_attr.attr, |
1052 | &sensor_dev_attr_in4_alarm.dev_attr.attr, | ||
1053 | NULL | ||
1054 | }, { | ||
1055 | &sensor_dev_attr_in8_input.dev_attr.attr, | ||
1056 | &sensor_dev_attr_in8_max.dev_attr.attr, | ||
1057 | &sensor_dev_attr_in8_min.dev_attr.attr, | ||
1058 | &sensor_dev_attr_in8_alarm.dev_attr.attr, | ||
762 | NULL | 1059 | NULL |
763 | }, { | 1060 | }, { |
764 | &sensor_dev_attr_fan2_input.dev_attr.attr, | 1061 | &sensor_dev_attr_in9_input.dev_attr.attr, |
765 | &sensor_dev_attr_fan2_min.dev_attr.attr, | 1062 | &sensor_dev_attr_in9_max.dev_attr.attr, |
766 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, | 1063 | &sensor_dev_attr_in9_min.dev_attr.attr, |
1064 | &sensor_dev_attr_in9_alarm.dev_attr.attr, | ||
767 | NULL | 1065 | NULL |
768 | }, { | 1066 | }, { |
769 | &sensor_dev_attr_fan3_input.dev_attr.attr, | 1067 | &sensor_dev_attr_in10_input.dev_attr.attr, |
770 | &sensor_dev_attr_fan3_min.dev_attr.attr, | 1068 | &sensor_dev_attr_in10_max.dev_attr.attr, |
771 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, | 1069 | &sensor_dev_attr_in10_min.dev_attr.attr, |
1070 | &sensor_dev_attr_in10_alarm.dev_attr.attr, | ||
772 | NULL | 1071 | NULL |
773 | } | 1072 | } |
774 | }; | 1073 | }; |
775 | 1074 | ||
776 | static const struct attribute_group f71805f_group_fan[3] = { | 1075 | static const struct attribute_group f71805f_group_optin[4] = { |
777 | { .attrs = f71805f_attributes_fan[0] }, | 1076 | { .attrs = f71805f_attributes_optin[0] }, |
778 | { .attrs = f71805f_attributes_fan[1] }, | 1077 | { .attrs = f71805f_attributes_optin[1] }, |
779 | { .attrs = f71805f_attributes_fan[2] }, | 1078 | { .attrs = f71805f_attributes_optin[2] }, |
1079 | { .attrs = f71805f_attributes_optin[3] }, | ||
1080 | }; | ||
1081 | |||
1082 | /* We don't include pwm_freq files in the arrays above, because they must be | ||
1083 | created conditionally (only if pwm_mode is 1 == PWM) */ | ||
1084 | static struct attribute *f71805f_attributes_pwm_freq[] = { | ||
1085 | &sensor_dev_attr_pwm1_freq.dev_attr.attr, | ||
1086 | &sensor_dev_attr_pwm2_freq.dev_attr.attr, | ||
1087 | &sensor_dev_attr_pwm3_freq.dev_attr.attr, | ||
1088 | NULL | ||
1089 | }; | ||
1090 | |||
1091 | static const struct attribute_group f71805f_group_pwm_freq = { | ||
1092 | .attrs = f71805f_attributes_pwm_freq, | ||
1093 | }; | ||
1094 | |||
1095 | /* We also need an indexed access to pwmN files to toggle writability */ | ||
1096 | static struct attribute *f71805f_attr_pwm[] = { | ||
1097 | &sensor_dev_attr_pwm1.dev_attr.attr, | ||
1098 | &sensor_dev_attr_pwm2.dev_attr.attr, | ||
1099 | &sensor_dev_attr_pwm3.dev_attr.attr, | ||
780 | }; | 1100 | }; |
781 | 1101 | ||
782 | /* | 1102 | /* |
@@ -798,18 +1118,30 @@ static void __devinit f71805f_init_device(struct f71805f_data *data) | |||
798 | /* Fan monitoring can be disabled. If it is, we won't be polling | 1118 | /* Fan monitoring can be disabled. If it is, we won't be polling |
799 | the register values, and won't create the related sysfs files. */ | 1119 | the register values, and won't create the related sysfs files. */ |
800 | for (i = 0; i < 3; i++) { | 1120 | for (i = 0; i < 3; i++) { |
801 | reg = f71805f_read8(data, F71805F_REG_FAN_CTRL(i)); | 1121 | data->fan_ctrl[i] = f71805f_read8(data, |
802 | if (!(reg & 0x80)) | 1122 | F71805F_REG_FAN_CTRL(i)); |
803 | data->fan_enabled |= (1 << i); | 1123 | /* Clear latch full bit, else "speed mode" fan speed control |
1124 | doesn't work */ | ||
1125 | if (data->fan_ctrl[i] & FAN_CTRL_LATCH_FULL) { | ||
1126 | data->fan_ctrl[i] &= ~FAN_CTRL_LATCH_FULL; | ||
1127 | f71805f_write8(data, F71805F_REG_FAN_CTRL(i), | ||
1128 | data->fan_ctrl[i]); | ||
1129 | } | ||
804 | } | 1130 | } |
805 | } | 1131 | } |
806 | 1132 | ||
807 | static int __devinit f71805f_probe(struct platform_device *pdev) | 1133 | static int __devinit f71805f_probe(struct platform_device *pdev) |
808 | { | 1134 | { |
1135 | struct f71805f_sio_data *sio_data = pdev->dev.platform_data; | ||
809 | struct f71805f_data *data; | 1136 | struct f71805f_data *data; |
810 | struct resource *res; | 1137 | struct resource *res; |
811 | int i, err; | 1138 | int i, err; |
812 | 1139 | ||
1140 | static const char *names[] = { | ||
1141 | "f71805f", | ||
1142 | "f71872f", | ||
1143 | }; | ||
1144 | |||
813 | if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) { | 1145 | if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) { |
814 | err = -ENOMEM; | 1146 | err = -ENOMEM; |
815 | printk(KERN_ERR DRVNAME ": Out of memory\n"); | 1147 | printk(KERN_ERR DRVNAME ": Out of memory\n"); |
@@ -819,24 +1151,69 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
819 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 1151 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
820 | data->addr = res->start; | 1152 | data->addr = res->start; |
821 | mutex_init(&data->lock); | 1153 | mutex_init(&data->lock); |
822 | data->name = "f71805f"; | 1154 | data->name = names[sio_data->kind]; |
823 | mutex_init(&data->update_lock); | 1155 | mutex_init(&data->update_lock); |
824 | 1156 | ||
825 | platform_set_drvdata(pdev, data); | 1157 | platform_set_drvdata(pdev, data); |
826 | 1158 | ||
1159 | /* Some voltage inputs depend on chip model and configuration */ | ||
1160 | switch (sio_data->kind) { | ||
1161 | case f71805f: | ||
1162 | data->has_in = 0x1ff; | ||
1163 | break; | ||
1164 | case f71872f: | ||
1165 | data->has_in = 0x6ef; | ||
1166 | if (sio_data->fnsel1 & 0x01) | ||
1167 | data->has_in |= (1 << 4); /* in4 */ | ||
1168 | if (sio_data->fnsel1 & 0x02) | ||
1169 | data->has_in |= (1 << 8); /* in8 */ | ||
1170 | break; | ||
1171 | } | ||
1172 | |||
827 | /* Initialize the F71805F chip */ | 1173 | /* Initialize the F71805F chip */ |
828 | f71805f_init_device(data); | 1174 | f71805f_init_device(data); |
829 | 1175 | ||
830 | /* Register sysfs interface files */ | 1176 | /* Register sysfs interface files */ |
831 | if ((err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group))) | 1177 | if ((err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group))) |
832 | goto exit_free; | 1178 | goto exit_free; |
833 | for (i = 0; i < 3; i++) { | 1179 | if (data->has_in & (1 << 4)) { /* in4 */ |
834 | if (!(data->fan_enabled & (1 << i))) | 1180 | if ((err = sysfs_create_group(&pdev->dev.kobj, |
835 | continue; | 1181 | &f71805f_group_optin[0]))) |
1182 | goto exit_remove_files; | ||
1183 | } | ||
1184 | if (data->has_in & (1 << 8)) { /* in8 */ | ||
1185 | if ((err = sysfs_create_group(&pdev->dev.kobj, | ||
1186 | &f71805f_group_optin[1]))) | ||
1187 | goto exit_remove_files; | ||
1188 | } | ||
1189 | if (data->has_in & (1 << 9)) { /* in9 (F71872F/FG only) */ | ||
836 | if ((err = sysfs_create_group(&pdev->dev.kobj, | 1190 | if ((err = sysfs_create_group(&pdev->dev.kobj, |
837 | &f71805f_group_fan[i]))) | 1191 | &f71805f_group_optin[2]))) |
838 | goto exit_remove_files; | 1192 | goto exit_remove_files; |
839 | } | 1193 | } |
1194 | if (data->has_in & (1 << 10)) { /* in9 (F71872F/FG only) */ | ||
1195 | if ((err = sysfs_create_group(&pdev->dev.kobj, | ||
1196 | &f71805f_group_optin[3]))) | ||
1197 | goto exit_remove_files; | ||
1198 | } | ||
1199 | for (i = 0; i < 3; i++) { | ||
1200 | /* If control mode is PWM, create pwm_freq file */ | ||
1201 | if (!(data->fan_ctrl[i] & FAN_CTRL_DC_MODE)) { | ||
1202 | if ((err = sysfs_create_file(&pdev->dev.kobj, | ||
1203 | f71805f_attributes_pwm_freq[i]))) | ||
1204 | goto exit_remove_files; | ||
1205 | } | ||
1206 | /* If PWM is in manual mode, add write permission */ | ||
1207 | if (data->fan_ctrl[i] & FAN_CTRL_MODE_MANUAL) { | ||
1208 | if ((err = sysfs_chmod_file(&pdev->dev.kobj, | ||
1209 | f71805f_attr_pwm[i], | ||
1210 | S_IRUGO | S_IWUSR))) { | ||
1211 | dev_err(&pdev->dev, "chmod +w pwm%d failed\n", | ||
1212 | i + 1); | ||
1213 | goto exit_remove_files; | ||
1214 | } | ||
1215 | } | ||
1216 | } | ||
840 | 1217 | ||
841 | data->class_dev = hwmon_device_register(&pdev->dev); | 1218 | data->class_dev = hwmon_device_register(&pdev->dev); |
842 | if (IS_ERR(data->class_dev)) { | 1219 | if (IS_ERR(data->class_dev)) { |
@@ -849,8 +1226,9 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
849 | 1226 | ||
850 | exit_remove_files: | 1227 | exit_remove_files: |
851 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group); | 1228 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group); |
852 | for (i = 0; i < 3; i++) | 1229 | for (i = 0; i < 4; i++) |
853 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_fan[i]); | 1230 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]); |
1231 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq); | ||
854 | exit_free: | 1232 | exit_free: |
855 | platform_set_drvdata(pdev, NULL); | 1233 | platform_set_drvdata(pdev, NULL); |
856 | kfree(data); | 1234 | kfree(data); |
@@ -866,8 +1244,9 @@ static int __devexit f71805f_remove(struct platform_device *pdev) | |||
866 | platform_set_drvdata(pdev, NULL); | 1244 | platform_set_drvdata(pdev, NULL); |
867 | hwmon_device_unregister(data->class_dev); | 1245 | hwmon_device_unregister(data->class_dev); |
868 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group); | 1246 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group); |
869 | for (i = 0; i < 3; i++) | 1247 | for (i = 0; i < 4; i++) |
870 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_fan[i]); | 1248 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]); |
1249 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq); | ||
871 | kfree(data); | 1250 | kfree(data); |
872 | 1251 | ||
873 | return 0; | 1252 | return 0; |
@@ -882,7 +1261,8 @@ static struct platform_driver f71805f_driver = { | |||
882 | .remove = __devexit_p(f71805f_remove), | 1261 | .remove = __devexit_p(f71805f_remove), |
883 | }; | 1262 | }; |
884 | 1263 | ||
885 | static int __init f71805f_device_add(unsigned short address) | 1264 | static int __init f71805f_device_add(unsigned short address, |
1265 | const struct f71805f_sio_data *sio_data) | ||
886 | { | 1266 | { |
887 | struct resource res = { | 1267 | struct resource res = { |
888 | .start = address, | 1268 | .start = address, |
@@ -906,26 +1286,45 @@ static int __init f71805f_device_add(unsigned short address) | |||
906 | goto exit_device_put; | 1286 | goto exit_device_put; |
907 | } | 1287 | } |
908 | 1288 | ||
1289 | pdev->dev.platform_data = kmalloc(sizeof(struct f71805f_sio_data), | ||
1290 | GFP_KERNEL); | ||
1291 | if (!pdev->dev.platform_data) { | ||
1292 | err = -ENOMEM; | ||
1293 | printk(KERN_ERR DRVNAME ": Platform data allocation failed\n"); | ||
1294 | goto exit_device_put; | ||
1295 | } | ||
1296 | memcpy(pdev->dev.platform_data, sio_data, | ||
1297 | sizeof(struct f71805f_sio_data)); | ||
1298 | |||
909 | err = platform_device_add(pdev); | 1299 | err = platform_device_add(pdev); |
910 | if (err) { | 1300 | if (err) { |
911 | printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n", | 1301 | printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n", |
912 | err); | 1302 | err); |
913 | goto exit_device_put; | 1303 | goto exit_kfree_data; |
914 | } | 1304 | } |
915 | 1305 | ||
916 | return 0; | 1306 | return 0; |
917 | 1307 | ||
1308 | exit_kfree_data: | ||
1309 | kfree(pdev->dev.platform_data); | ||
1310 | pdev->dev.platform_data = NULL; | ||
918 | exit_device_put: | 1311 | exit_device_put: |
919 | platform_device_put(pdev); | 1312 | platform_device_put(pdev); |
920 | exit: | 1313 | exit: |
921 | return err; | 1314 | return err; |
922 | } | 1315 | } |
923 | 1316 | ||
924 | static int __init f71805f_find(int sioaddr, unsigned short *address) | 1317 | static int __init f71805f_find(int sioaddr, unsigned short *address, |
1318 | struct f71805f_sio_data *sio_data) | ||
925 | { | 1319 | { |
926 | int err = -ENODEV; | 1320 | int err = -ENODEV; |
927 | u16 devid; | 1321 | u16 devid; |
928 | 1322 | ||
1323 | static const char *names[] = { | ||
1324 | "F71805F/FG", | ||
1325 | "F71872F/FG", | ||
1326 | }; | ||
1327 | |||
929 | superio_enter(sioaddr); | 1328 | superio_enter(sioaddr); |
930 | 1329 | ||
931 | devid = superio_inw(sioaddr, SIO_REG_MANID); | 1330 | devid = superio_inw(sioaddr, SIO_REG_MANID); |
@@ -933,7 +1332,15 @@ static int __init f71805f_find(int sioaddr, unsigned short *address) | |||
933 | goto exit; | 1332 | goto exit; |
934 | 1333 | ||
935 | devid = superio_inw(sioaddr, SIO_REG_DEVID); | 1334 | devid = superio_inw(sioaddr, SIO_REG_DEVID); |
936 | if (devid != SIO_F71805F_ID) { | 1335 | switch (devid) { |
1336 | case SIO_F71805F_ID: | ||
1337 | sio_data->kind = f71805f; | ||
1338 | break; | ||
1339 | case SIO_F71872F_ID: | ||
1340 | sio_data->kind = f71872f; | ||
1341 | sio_data->fnsel1 = superio_inb(sioaddr, SIO_REG_FNSEL1); | ||
1342 | break; | ||
1343 | default: | ||
937 | printk(KERN_INFO DRVNAME ": Unsupported Fintek device, " | 1344 | printk(KERN_INFO DRVNAME ": Unsupported Fintek device, " |
938 | "skipping\n"); | 1345 | "skipping\n"); |
939 | goto exit; | 1346 | goto exit; |
@@ -952,10 +1359,12 @@ static int __init f71805f_find(int sioaddr, unsigned short *address) | |||
952 | "skipping\n"); | 1359 | "skipping\n"); |
953 | goto exit; | 1360 | goto exit; |
954 | } | 1361 | } |
1362 | *address &= ~(REGION_LENGTH - 1); /* Ignore 3 LSB */ | ||
955 | 1363 | ||
956 | err = 0; | 1364 | err = 0; |
957 | printk(KERN_INFO DRVNAME ": Found F71805F chip at %#x, revision %u\n", | 1365 | printk(KERN_INFO DRVNAME ": Found %s chip at %#x, revision %u\n", |
958 | *address, superio_inb(sioaddr, SIO_REG_DEVREV)); | 1366 | names[sio_data->kind], *address, |
1367 | superio_inb(sioaddr, SIO_REG_DEVREV)); | ||
959 | 1368 | ||
960 | exit: | 1369 | exit: |
961 | superio_exit(sioaddr); | 1370 | superio_exit(sioaddr); |
@@ -966,9 +1375,10 @@ static int __init f71805f_init(void) | |||
966 | { | 1375 | { |
967 | int err; | 1376 | int err; |
968 | unsigned short address; | 1377 | unsigned short address; |
1378 | struct f71805f_sio_data sio_data; | ||
969 | 1379 | ||
970 | if (f71805f_find(0x2e, &address) | 1380 | if (f71805f_find(0x2e, &address, &sio_data) |
971 | && f71805f_find(0x4e, &address)) | 1381 | && f71805f_find(0x4e, &address, &sio_data)) |
972 | return -ENODEV; | 1382 | return -ENODEV; |
973 | 1383 | ||
974 | err = platform_driver_register(&f71805f_driver); | 1384 | err = platform_driver_register(&f71805f_driver); |
@@ -976,7 +1386,7 @@ static int __init f71805f_init(void) | |||
976 | goto exit; | 1386 | goto exit; |
977 | 1387 | ||
978 | /* Sets global pdev as a side effect */ | 1388 | /* Sets global pdev as a side effect */ |
979 | err = f71805f_device_add(address); | 1389 | err = f71805f_device_add(address, &sio_data); |
980 | if (err) | 1390 | if (err) |
981 | goto exit_driver; | 1391 | goto exit_driver; |
982 | 1392 | ||
@@ -990,13 +1400,16 @@ exit: | |||
990 | 1400 | ||
991 | static void __exit f71805f_exit(void) | 1401 | static void __exit f71805f_exit(void) |
992 | { | 1402 | { |
1403 | kfree(pdev->dev.platform_data); | ||
1404 | pdev->dev.platform_data = NULL; | ||
993 | platform_device_unregister(pdev); | 1405 | platform_device_unregister(pdev); |
1406 | |||
994 | platform_driver_unregister(&f71805f_driver); | 1407 | platform_driver_unregister(&f71805f_driver); |
995 | } | 1408 | } |
996 | 1409 | ||
997 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr>"); | 1410 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr>"); |
998 | MODULE_LICENSE("GPL"); | 1411 | MODULE_LICENSE("GPL"); |
999 | MODULE_DESCRIPTION("F71805F hardware monitoring driver"); | 1412 | MODULE_DESCRIPTION("F71805F/F71872F hardware monitoring driver"); |
1000 | 1413 | ||
1001 | module_init(f71805f_init); | 1414 | module_init(f71805f_init); |
1002 | module_exit(f71805f_exit); | 1415 | module_exit(f71805f_exit); |
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c index e8ef62b83d6b..bf759ea545ac 100644 --- a/drivers/hwmon/hdaps.c +++ b/drivers/hwmon/hdaps.c | |||
@@ -478,74 +478,64 @@ static struct attribute_group hdaps_attribute_group = { | |||
478 | /* Module stuff */ | 478 | /* Module stuff */ |
479 | 479 | ||
480 | /* hdaps_dmi_match - found a match. return one, short-circuiting the hunt. */ | 480 | /* hdaps_dmi_match - found a match. return one, short-circuiting the hunt. */ |
481 | static int hdaps_dmi_match(struct dmi_system_id *id) | 481 | static int __init hdaps_dmi_match(struct dmi_system_id *id) |
482 | { | 482 | { |
483 | printk(KERN_INFO "hdaps: %s detected.\n", id->ident); | 483 | printk(KERN_INFO "hdaps: %s detected.\n", id->ident); |
484 | return 1; | 484 | return 1; |
485 | } | 485 | } |
486 | 486 | ||
487 | /* hdaps_dmi_match_invert - found an inverted match. */ | 487 | /* hdaps_dmi_match_invert - found an inverted match. */ |
488 | static int hdaps_dmi_match_invert(struct dmi_system_id *id) | 488 | static int __init hdaps_dmi_match_invert(struct dmi_system_id *id) |
489 | { | 489 | { |
490 | hdaps_invert = 1; | 490 | hdaps_invert = 1; |
491 | printk(KERN_INFO "hdaps: inverting axis readings.\n"); | 491 | printk(KERN_INFO "hdaps: inverting axis readings.\n"); |
492 | return hdaps_dmi_match(id); | 492 | return hdaps_dmi_match(id); |
493 | } | 493 | } |
494 | 494 | ||
495 | #define HDAPS_DMI_MATCH_NORMAL(model) { \ | 495 | #define HDAPS_DMI_MATCH_NORMAL(vendor, model) { \ |
496 | .ident = "IBM " model, \ | 496 | .ident = vendor " " model, \ |
497 | .callback = hdaps_dmi_match, \ | 497 | .callback = hdaps_dmi_match, \ |
498 | .matches = { \ | 498 | .matches = { \ |
499 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), \ | 499 | DMI_MATCH(DMI_BOARD_VENDOR, vendor), \ |
500 | DMI_MATCH(DMI_PRODUCT_VERSION, model) \ | 500 | DMI_MATCH(DMI_PRODUCT_VERSION, model) \ |
501 | } \ | 501 | } \ |
502 | } | 502 | } |
503 | 503 | ||
504 | #define HDAPS_DMI_MATCH_INVERT(model) { \ | 504 | #define HDAPS_DMI_MATCH_INVERT(vendor, model) { \ |
505 | .ident = "IBM " model, \ | 505 | .ident = vendor " " model, \ |
506 | .callback = hdaps_dmi_match_invert, \ | 506 | .callback = hdaps_dmi_match_invert, \ |
507 | .matches = { \ | 507 | .matches = { \ |
508 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), \ | 508 | DMI_MATCH(DMI_BOARD_VENDOR, vendor), \ |
509 | DMI_MATCH(DMI_PRODUCT_VERSION, model) \ | 509 | DMI_MATCH(DMI_PRODUCT_VERSION, model) \ |
510 | } \ | 510 | } \ |
511 | } | 511 | } |
512 | 512 | ||
513 | #define HDAPS_DMI_MATCH_LENOVO(model) { \ | 513 | /* Note that HDAPS_DMI_MATCH_NORMAL("ThinkPad T42") would match |
514 | .ident = "Lenovo " model, \ | 514 | "ThinkPad T42p", so the order of the entries matters. |
515 | .callback = hdaps_dmi_match_invert, \ | 515 | If your ThinkPad is not recognized, please update to latest |
516 | .matches = { \ | 516 | BIOS. This is especially the case for some R52 ThinkPads. */ |
517 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), \ | 517 | static struct dmi_system_id __initdata hdaps_whitelist[] = { |
518 | DMI_MATCH(DMI_PRODUCT_VERSION, model) \ | 518 | HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad R50p"), |
519 | } \ | 519 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R50"), |
520 | } | 520 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R51"), |
521 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R52"), | ||
522 | HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad T41p"), | ||
523 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T41"), | ||
524 | HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad T42p"), | ||
525 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T42"), | ||
526 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T43"), | ||
527 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad T60"), | ||
528 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad X40"), | ||
529 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad X41"), | ||
530 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad X60"), | ||
531 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad Z60m"), | ||
532 | { .ident = NULL } | ||
533 | }; | ||
521 | 534 | ||
522 | static int __init hdaps_init(void) | 535 | static int __init hdaps_init(void) |
523 | { | 536 | { |
524 | int ret; | 537 | int ret; |
525 | 538 | ||
526 | /* Note that HDAPS_DMI_MATCH_NORMAL("ThinkPad T42") would match | ||
527 | "ThinkPad T42p", so the order of the entries matters */ | ||
528 | struct dmi_system_id hdaps_whitelist[] = { | ||
529 | HDAPS_DMI_MATCH_NORMAL("ThinkPad H"), | ||
530 | HDAPS_DMI_MATCH_INVERT("ThinkPad R50p"), | ||
531 | HDAPS_DMI_MATCH_NORMAL("ThinkPad R50"), | ||
532 | HDAPS_DMI_MATCH_NORMAL("ThinkPad R51"), | ||
533 | HDAPS_DMI_MATCH_NORMAL("ThinkPad R52"), | ||
534 | HDAPS_DMI_MATCH_NORMAL("ThinkPad H"), /* R52 (1846AQG) */ | ||
535 | HDAPS_DMI_MATCH_INVERT("ThinkPad T41p"), | ||
536 | HDAPS_DMI_MATCH_NORMAL("ThinkPad T41"), | ||
537 | HDAPS_DMI_MATCH_INVERT("ThinkPad T42p"), | ||
538 | HDAPS_DMI_MATCH_NORMAL("ThinkPad T42"), | ||
539 | HDAPS_DMI_MATCH_NORMAL("ThinkPad T43"), | ||
540 | HDAPS_DMI_MATCH_LENOVO("ThinkPad T60p"), | ||
541 | HDAPS_DMI_MATCH_LENOVO("ThinkPad T60"), | ||
542 | HDAPS_DMI_MATCH_NORMAL("ThinkPad X40"), | ||
543 | HDAPS_DMI_MATCH_NORMAL("ThinkPad X41"), | ||
544 | HDAPS_DMI_MATCH_LENOVO("ThinkPad X60"), | ||
545 | HDAPS_DMI_MATCH_NORMAL("ThinkPad Z60m"), | ||
546 | { .ident = NULL } | ||
547 | }; | ||
548 | |||
549 | if (!dmi_check_system(hdaps_whitelist)) { | 539 | if (!dmi_check_system(hdaps_whitelist)) { |
550 | printk(KERN_WARNING "hdaps: supported laptop not found!\n"); | 540 | printk(KERN_WARNING "hdaps: supported laptop not found!\n"); |
551 | ret = -ENODEV; | 541 | ret = -ENODEV; |
diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c index 9d67320e6840..31c42002708f 100644 --- a/drivers/hwmon/hwmon-vid.c +++ b/drivers/hwmon/hwmon-vid.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | hwmon-vid.c - VID/VRM/VRD voltage conversions | 2 | hwmon-vid.c - VID/VRM/VRD voltage conversions |
3 | 3 | ||
4 | Copyright (c) 2004 Rudolf Marek <r.marek@sh.cvut.cz> | 4 | Copyright (c) 2004 Rudolf Marek <r.marek@assembler.cz> |
5 | 5 | ||
6 | Partly imported from i2c-vid.h of the lm_sensors project | 6 | Partly imported from i2c-vid.h of the lm_sensors project |
7 | Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> | 7 | Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> |
@@ -232,7 +232,7 @@ u8 vid_which_vrm(void) | |||
232 | EXPORT_SYMBOL(vid_from_reg); | 232 | EXPORT_SYMBOL(vid_from_reg); |
233 | EXPORT_SYMBOL(vid_which_vrm); | 233 | EXPORT_SYMBOL(vid_which_vrm); |
234 | 234 | ||
235 | MODULE_AUTHOR("Rudolf Marek <r.marek@sh.cvut.cz>"); | 235 | MODULE_AUTHOR("Rudolf Marek <r.marek@assembler.cz>"); |
236 | 236 | ||
237 | MODULE_DESCRIPTION("hwmon-vid driver"); | 237 | MODULE_DESCRIPTION("hwmon-vid driver"); |
238 | MODULE_LICENSE("GPL"); | 238 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 323ef06719c1..1ed8b7e2c35d 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -3,7 +3,7 @@ | |||
3 | monitoring. | 3 | monitoring. |
4 | 4 | ||
5 | Supports: IT8705F Super I/O chip w/LPC interface | 5 | Supports: IT8705F Super I/O chip w/LPC interface |
6 | IT8712F Super I/O chip w/LPC interface & SMBus | 6 | IT8712F Super I/O chip w/LPC interface |
7 | IT8716F Super I/O chip w/LPC interface | 7 | IT8716F Super I/O chip w/LPC interface |
8 | IT8718F Super I/O chip w/LPC interface | 8 | IT8718F Super I/O chip w/LPC interface |
9 | Sis950 A clone of the IT8705F | 9 | Sis950 A clone of the IT8705F |
@@ -41,12 +41,8 @@ | |||
41 | #include <asm/io.h> | 41 | #include <asm/io.h> |
42 | 42 | ||
43 | 43 | ||
44 | /* Addresses to scan */ | ||
45 | static unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END }; | ||
46 | static unsigned short isa_address; | 44 | static unsigned short isa_address; |
47 | 45 | enum chips { it87, it8712, it8716, it8718 }; | |
48 | /* Insmod parameters */ | ||
49 | I2C_CLIENT_INSMOD_4(it87, it8712, it8716, it8718); | ||
50 | 46 | ||
51 | #define REG 0x2e /* The register to read/write */ | 47 | #define REG 0x2e /* The register to read/write */ |
52 | #define DEV 0x07 /* Register: Logical device select */ | 48 | #define DEV 0x07 /* Register: Logical device select */ |
@@ -162,8 +158,6 @@ static u8 vid_value; | |||
162 | #define IT87_REG_TEMP_HIGH(nr) (0x40 + (nr) * 2) | 158 | #define IT87_REG_TEMP_HIGH(nr) (0x40 + (nr) * 2) |
163 | #define IT87_REG_TEMP_LOW(nr) (0x41 + (nr) * 2) | 159 | #define IT87_REG_TEMP_LOW(nr) (0x41 + (nr) * 2) |
164 | 160 | ||
165 | #define IT87_REG_I2C_ADDR 0x48 | ||
166 | |||
167 | #define IT87_REG_VIN_ENABLE 0x50 | 161 | #define IT87_REG_VIN_ENABLE 0x50 |
168 | #define IT87_REG_TEMP_ENABLE 0x51 | 162 | #define IT87_REG_TEMP_ENABLE 0x51 |
169 | 163 | ||
@@ -242,33 +236,22 @@ struct it87_data { | |||
242 | }; | 236 | }; |
243 | 237 | ||
244 | 238 | ||
245 | static int it87_attach_adapter(struct i2c_adapter *adapter); | 239 | static int it87_detect(struct i2c_adapter *adapter); |
246 | static int it87_isa_attach_adapter(struct i2c_adapter *adapter); | ||
247 | static int it87_detect(struct i2c_adapter *adapter, int address, int kind); | ||
248 | static int it87_detach_client(struct i2c_client *client); | 240 | static int it87_detach_client(struct i2c_client *client); |
249 | 241 | ||
250 | static int it87_read_value(struct i2c_client *client, u8 reg); | 242 | static int it87_read_value(struct i2c_client *client, u8 reg); |
251 | static int it87_write_value(struct i2c_client *client, u8 reg, u8 value); | 243 | static void it87_write_value(struct i2c_client *client, u8 reg, u8 value); |
252 | static struct it87_data *it87_update_device(struct device *dev); | 244 | static struct it87_data *it87_update_device(struct device *dev); |
253 | static int it87_check_pwm(struct i2c_client *client); | 245 | static int it87_check_pwm(struct i2c_client *client); |
254 | static void it87_init_client(struct i2c_client *client, struct it87_data *data); | 246 | static void it87_init_client(struct i2c_client *client, struct it87_data *data); |
255 | 247 | ||
256 | 248 | ||
257 | static struct i2c_driver it87_driver = { | ||
258 | .driver = { | ||
259 | .name = "it87", | ||
260 | }, | ||
261 | .id = I2C_DRIVERID_IT87, | ||
262 | .attach_adapter = it87_attach_adapter, | ||
263 | .detach_client = it87_detach_client, | ||
264 | }; | ||
265 | |||
266 | static struct i2c_driver it87_isa_driver = { | 249 | static struct i2c_driver it87_isa_driver = { |
267 | .driver = { | 250 | .driver = { |
268 | .owner = THIS_MODULE, | 251 | .owner = THIS_MODULE, |
269 | .name = "it87-isa", | 252 | .name = "it87-isa", |
270 | }, | 253 | }, |
271 | .attach_adapter = it87_isa_attach_adapter, | 254 | .attach_adapter = it87_detect, |
272 | .detach_client = it87_detach_client, | 255 | .detach_client = it87_detach_client, |
273 | }; | 256 | }; |
274 | 257 | ||
@@ -850,22 +833,6 @@ static const struct attribute_group it87_group_opt = { | |||
850 | .attrs = it87_attributes_opt, | 833 | .attrs = it87_attributes_opt, |
851 | }; | 834 | }; |
852 | 835 | ||
853 | /* This function is called when: | ||
854 | * it87_driver is inserted (when this module is loaded), for each | ||
855 | available adapter | ||
856 | * when a new adapter is inserted (and it87_driver is still present) */ | ||
857 | static int it87_attach_adapter(struct i2c_adapter *adapter) | ||
858 | { | ||
859 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
860 | return 0; | ||
861 | return i2c_probe(adapter, &addr_data, it87_detect); | ||
862 | } | ||
863 | |||
864 | static int it87_isa_attach_adapter(struct i2c_adapter *adapter) | ||
865 | { | ||
866 | return it87_detect(adapter, isa_address, -1); | ||
867 | } | ||
868 | |||
869 | /* SuperIO detection - will change isa_address if a chip is found */ | 836 | /* SuperIO detection - will change isa_address if a chip is found */ |
870 | static int __init it87_find(unsigned short *address) | 837 | static int __init it87_find(unsigned short *address) |
871 | { | 838 | { |
@@ -916,29 +883,20 @@ exit: | |||
916 | } | 883 | } |
917 | 884 | ||
918 | /* This function is called by i2c_probe */ | 885 | /* This function is called by i2c_probe */ |
919 | static int it87_detect(struct i2c_adapter *adapter, int address, int kind) | 886 | static int it87_detect(struct i2c_adapter *adapter) |
920 | { | 887 | { |
921 | int i; | ||
922 | struct i2c_client *new_client; | 888 | struct i2c_client *new_client; |
923 | struct it87_data *data; | 889 | struct it87_data *data; |
924 | int err = 0; | 890 | int err = 0; |
925 | const char *name = ""; | 891 | const char *name; |
926 | int is_isa = i2c_is_isa_adapter(adapter); | ||
927 | int enable_pwm_interface; | 892 | int enable_pwm_interface; |
928 | 893 | ||
929 | if (!is_isa && | ||
930 | !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
931 | goto ERROR0; | ||
932 | |||
933 | /* Reserve the ISA region */ | 894 | /* Reserve the ISA region */ |
934 | if (is_isa) | 895 | if (!request_region(isa_address, IT87_EXTENT, |
935 | if (!request_region(address, IT87_EXTENT, | 896 | it87_isa_driver.driver.name)){ |
936 | it87_isa_driver.driver.name)) | 897 | err = -EBUSY; |
937 | goto ERROR0; | 898 | goto ERROR0; |
938 | 899 | } | |
939 | /* For now, we presume we have a valid client. We create the | ||
940 | client structure, even though we cannot fill it completely yet. | ||
941 | But it allows us to access it87_{read,write}_value. */ | ||
942 | 900 | ||
943 | if (!(data = kzalloc(sizeof(struct it87_data), GFP_KERNEL))) { | 901 | if (!(data = kzalloc(sizeof(struct it87_data), GFP_KERNEL))) { |
944 | err = -ENOMEM; | 902 | err = -ENOMEM; |
@@ -946,80 +904,46 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
946 | } | 904 | } |
947 | 905 | ||
948 | new_client = &data->client; | 906 | new_client = &data->client; |
949 | if (is_isa) | 907 | mutex_init(&data->lock); |
950 | mutex_init(&data->lock); | ||
951 | i2c_set_clientdata(new_client, data); | 908 | i2c_set_clientdata(new_client, data); |
952 | new_client->addr = address; | 909 | new_client->addr = isa_address; |
953 | new_client->adapter = adapter; | 910 | new_client->adapter = adapter; |
954 | new_client->driver = is_isa ? &it87_isa_driver : &it87_driver; | 911 | new_client->driver = &it87_isa_driver; |
955 | new_client->flags = 0; | ||
956 | 912 | ||
957 | /* Now, we do the remaining detection. */ | 913 | /* Now, we do the remaining detection. */ |
958 | 914 | if ((it87_read_value(new_client, IT87_REG_CONFIG) & 0x80) | |
959 | if (kind < 0) { | 915 | || it87_read_value(new_client, IT87_REG_CHIPID) != 0x90) { |
960 | if ((it87_read_value(new_client, IT87_REG_CONFIG) & 0x80) | 916 | err = -ENODEV; |
961 | || (!is_isa | 917 | goto ERROR2; |
962 | && it87_read_value(new_client, IT87_REG_I2C_ADDR) != address)) { | ||
963 | err = -ENODEV; | ||
964 | goto ERROR2; | ||
965 | } | ||
966 | } | 918 | } |
967 | 919 | ||
968 | /* Determine the chip type. */ | 920 | /* Determine the chip type. */ |
969 | if (kind <= 0) { | 921 | switch (chip_type) { |
970 | i = it87_read_value(new_client, IT87_REG_CHIPID); | 922 | case IT8712F_DEVID: |
971 | if (i == 0x90) { | 923 | data->type = it8712; |
972 | kind = it87; | ||
973 | if (is_isa) { | ||
974 | switch (chip_type) { | ||
975 | case IT8712F_DEVID: | ||
976 | kind = it8712; | ||
977 | break; | ||
978 | case IT8716F_DEVID: | ||
979 | kind = it8716; | ||
980 | break; | ||
981 | case IT8718F_DEVID: | ||
982 | kind = it8718; | ||
983 | break; | ||
984 | } | ||
985 | } | ||
986 | } | ||
987 | else { | ||
988 | if (kind == 0) | ||
989 | dev_info(&adapter->dev, | ||
990 | "Ignoring 'force' parameter for unknown chip at " | ||
991 | "adapter %d, address 0x%02x\n", | ||
992 | i2c_adapter_id(adapter), address); | ||
993 | err = -ENODEV; | ||
994 | goto ERROR2; | ||
995 | } | ||
996 | } | ||
997 | |||
998 | if (kind == it87) { | ||
999 | name = "it87"; | ||
1000 | } else if (kind == it8712) { | ||
1001 | name = "it8712"; | 924 | name = "it8712"; |
1002 | } else if (kind == it8716) { | 925 | break; |
926 | case IT8716F_DEVID: | ||
927 | data->type = it8716; | ||
1003 | name = "it8716"; | 928 | name = "it8716"; |
1004 | } else if (kind == it8718) { | 929 | break; |
930 | case IT8718F_DEVID: | ||
931 | data->type = it8718; | ||
1005 | name = "it8718"; | 932 | name = "it8718"; |
933 | break; | ||
934 | default: | ||
935 | data->type = it87; | ||
936 | name = "it87"; | ||
1006 | } | 937 | } |
1007 | 938 | ||
1008 | /* Fill in the remaining client fields and put it into the global list */ | 939 | /* Fill in the remaining client fields and put it into the global list */ |
1009 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 940 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
1010 | data->type = kind; | ||
1011 | data->valid = 0; | ||
1012 | mutex_init(&data->update_lock); | 941 | mutex_init(&data->update_lock); |
1013 | 942 | ||
1014 | /* Tell the I2C layer a new client has arrived */ | 943 | /* Tell the I2C layer a new client has arrived */ |
1015 | if ((err = i2c_attach_client(new_client))) | 944 | if ((err = i2c_attach_client(new_client))) |
1016 | goto ERROR2; | 945 | goto ERROR2; |
1017 | 946 | ||
1018 | if (!is_isa) | ||
1019 | dev_info(&new_client->dev, "The I2C interface to IT87xxF " | ||
1020 | "hardware monitoring chips is deprecated. Please " | ||
1021 | "report if you still rely on it.\n"); | ||
1022 | |||
1023 | /* Check PWM configuration */ | 947 | /* Check PWM configuration */ |
1024 | enable_pwm_interface = it87_check_pwm(new_client); | 948 | enable_pwm_interface = it87_check_pwm(new_client); |
1025 | 949 | ||
@@ -1129,8 +1053,7 @@ ERROR3: | |||
1129 | ERROR2: | 1053 | ERROR2: |
1130 | kfree(data); | 1054 | kfree(data); |
1131 | ERROR1: | 1055 | ERROR1: |
1132 | if (is_isa) | 1056 | release_region(isa_address, IT87_EXTENT); |
1133 | release_region(address, IT87_EXTENT); | ||
1134 | ERROR0: | 1057 | ERROR0: |
1135 | return err; | 1058 | return err; |
1136 | } | 1059 | } |
@@ -1147,50 +1070,39 @@ static int it87_detach_client(struct i2c_client *client) | |||
1147 | if ((err = i2c_detach_client(client))) | 1070 | if ((err = i2c_detach_client(client))) |
1148 | return err; | 1071 | return err; |
1149 | 1072 | ||
1150 | if(i2c_is_isa_client(client)) | 1073 | release_region(client->addr, IT87_EXTENT); |
1151 | release_region(client->addr, IT87_EXTENT); | ||
1152 | kfree(data); | 1074 | kfree(data); |
1153 | 1075 | ||
1154 | return 0; | 1076 | return 0; |
1155 | } | 1077 | } |
1156 | 1078 | ||
1157 | /* The SMBus locks itself, but ISA access must be locked explicitly! | 1079 | /* ISA access must be locked explicitly! |
1158 | We don't want to lock the whole ISA bus, so we lock each client | ||
1159 | separately. | ||
1160 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, | 1080 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, |
1161 | would slow down the IT87 access and should not be necessary. */ | 1081 | would slow down the IT87 access and should not be necessary. */ |
1162 | static int it87_read_value(struct i2c_client *client, u8 reg) | 1082 | static int it87_read_value(struct i2c_client *client, u8 reg) |
1163 | { | 1083 | { |
1164 | struct it87_data *data = i2c_get_clientdata(client); | 1084 | struct it87_data *data = i2c_get_clientdata(client); |
1165 | |||
1166 | int res; | 1085 | int res; |
1167 | if (i2c_is_isa_client(client)) { | 1086 | |
1168 | mutex_lock(&data->lock); | 1087 | mutex_lock(&data->lock); |
1169 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); | 1088 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); |
1170 | res = inb_p(client->addr + IT87_DATA_REG_OFFSET); | 1089 | res = inb_p(client->addr + IT87_DATA_REG_OFFSET); |
1171 | mutex_unlock(&data->lock); | 1090 | mutex_unlock(&data->lock); |
1172 | return res; | 1091 | |
1173 | } else | 1092 | return res; |
1174 | return i2c_smbus_read_byte_data(client, reg); | ||
1175 | } | 1093 | } |
1176 | 1094 | ||
1177 | /* The SMBus locks itself, but ISA access muse be locked explicitly! | 1095 | /* ISA access must be locked explicitly! |
1178 | We don't want to lock the whole ISA bus, so we lock each client | ||
1179 | separately. | ||
1180 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, | 1096 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, |
1181 | would slow down the IT87 access and should not be necessary. */ | 1097 | would slow down the IT87 access and should not be necessary. */ |
1182 | static int it87_write_value(struct i2c_client *client, u8 reg, u8 value) | 1098 | static void it87_write_value(struct i2c_client *client, u8 reg, u8 value) |
1183 | { | 1099 | { |
1184 | struct it87_data *data = i2c_get_clientdata(client); | 1100 | struct it87_data *data = i2c_get_clientdata(client); |
1185 | 1101 | ||
1186 | if (i2c_is_isa_client(client)) { | 1102 | mutex_lock(&data->lock); |
1187 | mutex_lock(&data->lock); | 1103 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); |
1188 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); | 1104 | outb_p(value, client->addr + IT87_DATA_REG_OFFSET); |
1189 | outb_p(value, client->addr + IT87_DATA_REG_OFFSET); | 1105 | mutex_unlock(&data->lock); |
1190 | mutex_unlock(&data->lock); | ||
1191 | return 0; | ||
1192 | } else | ||
1193 | return i2c_smbus_write_byte_data(client, reg, value); | ||
1194 | } | 1106 | } |
1195 | 1107 | ||
1196 | /* Return 1 if and only if the PWM interface is safe to use */ | 1108 | /* Return 1 if and only if the PWM interface is safe to use */ |
@@ -1426,26 +1338,14 @@ static int __init sm_it87_init(void) | |||
1426 | { | 1338 | { |
1427 | int res; | 1339 | int res; |
1428 | 1340 | ||
1429 | res = i2c_add_driver(&it87_driver); | 1341 | if ((res = it87_find(&isa_address))) |
1430 | if (res) | ||
1431 | return res; | 1342 | return res; |
1432 | 1343 | return i2c_isa_add_driver(&it87_isa_driver); | |
1433 | if (!it87_find(&isa_address)) { | ||
1434 | res = i2c_isa_add_driver(&it87_isa_driver); | ||
1435 | if (res) { | ||
1436 | i2c_del_driver(&it87_driver); | ||
1437 | return res; | ||
1438 | } | ||
1439 | } | ||
1440 | |||
1441 | return 0; | ||
1442 | } | 1344 | } |
1443 | 1345 | ||
1444 | static void __exit sm_it87_exit(void) | 1346 | static void __exit sm_it87_exit(void) |
1445 | { | 1347 | { |
1446 | if (isa_address) | 1348 | i2c_isa_del_driver(&it87_isa_driver); |
1447 | i2c_isa_del_driver(&it87_isa_driver); | ||
1448 | i2c_del_driver(&it87_driver); | ||
1449 | } | 1349 | } |
1450 | 1350 | ||
1451 | 1351 | ||
diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c index f58b64ed09e3..5d8d0ca08fa9 100644 --- a/drivers/hwmon/k8temp.c +++ b/drivers/hwmon/k8temp.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * k8temp.c - Linux kernel module for hardware monitoring | 2 | * k8temp.c - Linux kernel module for hardware monitoring |
3 | * | 3 | * |
4 | * Copyright (C) 2006 Rudolf Marek <r.marek@sh.cvut.cz> | 4 | * Copyright (C) 2006 Rudolf Marek <r.marek@assembler.cz> |
5 | * | 5 | * |
6 | * Inspired from the w83785 and amd756 drivers. | 6 | * Inspired from the w83785 and amd756 drivers. |
7 | * | 7 | * |
@@ -286,7 +286,7 @@ static void __exit k8temp_exit(void) | |||
286 | pci_unregister_driver(&k8temp_driver); | 286 | pci_unregister_driver(&k8temp_driver); |
287 | } | 287 | } |
288 | 288 | ||
289 | MODULE_AUTHOR("Rudolf Marek <r.marek@sh.cvut.cz>"); | 289 | MODULE_AUTHOR("Rudolf Marek <r.marek@assembler.cz>"); |
290 | MODULE_DESCRIPTION("AMD K8 core temperature monitor"); | 290 | MODULE_DESCRIPTION("AMD K8 core temperature monitor"); |
291 | MODULE_LICENSE("GPL"); | 291 | MODULE_LICENSE("GPL"); |
292 | 292 | ||
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 3b8b81984ad4..c8a21be09d87 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c | |||
@@ -1000,7 +1000,7 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
1000 | (i&0x02) ? "external" : "internal"); | 1000 | (i&0x02) ? "external" : "internal"); |
1001 | 1001 | ||
1002 | data->vid_conf = confreg[3]; | 1002 | data->vid_conf = confreg[3]; |
1003 | data->vrm = 90; | 1003 | data->vrm = vid_which_vrm(); |
1004 | } | 1004 | } |
1005 | 1005 | ||
1006 | /* Fan clock dividers may be needed before any data is read */ | 1006 | /* Fan clock dividers may be needed before any data is read */ |
diff --git a/drivers/hwmon/pc87427.c b/drivers/hwmon/pc87427.c new file mode 100644 index 000000000000..affa21a5ccfd --- /dev/null +++ b/drivers/hwmon/pc87427.c | |||
@@ -0,0 +1,627 @@ | |||
1 | /* | ||
2 | * pc87427.c - hardware monitoring driver for the | ||
3 | * National Semiconductor PC87427 Super-I/O chip | ||
4 | * Copyright (C) 2006 Jean Delvare <khali@linux-fr.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * Supports the following chips: | ||
16 | * | ||
17 | * Chip #vin #fan #pwm #temp devid | ||
18 | * PC87427 - 8 - - 0xF2 | ||
19 | * | ||
20 | * This driver assumes that no more than one chip is present. | ||
21 | * Only fan inputs are supported so far, although the chip can do much more. | ||
22 | */ | ||
23 | |||
24 | #include <linux/module.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/slab.h> | ||
27 | #include <linux/jiffies.h> | ||
28 | #include <linux/platform_device.h> | ||
29 | #include <linux/hwmon.h> | ||
30 | #include <linux/hwmon-sysfs.h> | ||
31 | #include <linux/err.h> | ||
32 | #include <linux/mutex.h> | ||
33 | #include <linux/sysfs.h> | ||
34 | #include <asm/io.h> | ||
35 | |||
36 | static struct platform_device *pdev; | ||
37 | |||
38 | #define DRVNAME "pc87427" | ||
39 | |||
40 | /* The lock mutex protects both the I/O accesses (needed because the | ||
41 | device is using banked registers) and the register cache (needed to keep | ||
42 | the data in the registers and the cache in sync at any time). */ | ||
43 | struct pc87427_data { | ||
44 | struct class_device *class_dev; | ||
45 | struct mutex lock; | ||
46 | int address[2]; | ||
47 | const char *name; | ||
48 | |||
49 | unsigned long last_updated; /* in jiffies */ | ||
50 | u8 fan_enabled; /* bit vector */ | ||
51 | u16 fan[8]; /* register values */ | ||
52 | u16 fan_min[8]; /* register values */ | ||
53 | u8 fan_status[8]; /* register values */ | ||
54 | }; | ||
55 | |||
56 | /* | ||
57 | * Super-I/O registers and operations | ||
58 | */ | ||
59 | |||
60 | #define SIOREG_LDSEL 0x07 /* Logical device select */ | ||
61 | #define SIOREG_DEVID 0x20 /* Device ID */ | ||
62 | #define SIOREG_ACT 0x30 /* Device activation */ | ||
63 | #define SIOREG_MAP 0x50 /* I/O or memory mapping */ | ||
64 | #define SIOREG_IOBASE 0x60 /* I/O base address */ | ||
65 | |||
66 | static const u8 logdev[2] = { 0x09, 0x14 }; | ||
67 | static const char *logdev_str[2] = { DRVNAME " FMC", DRVNAME " HMC" }; | ||
68 | #define LD_FAN 0 | ||
69 | #define LD_IN 1 | ||
70 | #define LD_TEMP 1 | ||
71 | |||
72 | static inline void superio_outb(int sioaddr, int reg, int val) | ||
73 | { | ||
74 | outb(reg, sioaddr); | ||
75 | outb(val, sioaddr + 1); | ||
76 | } | ||
77 | |||
78 | static inline int superio_inb(int sioaddr, int reg) | ||
79 | { | ||
80 | outb(reg, sioaddr); | ||
81 | return inb(sioaddr + 1); | ||
82 | } | ||
83 | |||
84 | static inline void superio_exit(int sioaddr) | ||
85 | { | ||
86 | outb(0x02, sioaddr); | ||
87 | outb(0x02, sioaddr + 1); | ||
88 | } | ||
89 | |||
90 | /* | ||
91 | * Logical devices | ||
92 | */ | ||
93 | |||
94 | #define REGION_LENGTH 32 | ||
95 | #define PC87427_REG_BANK 0x0f | ||
96 | #define BANK_FM(nr) (nr) | ||
97 | #define BANK_FT(nr) (0x08 + (nr)) | ||
98 | #define BANK_FC(nr) (0x10 + (nr) * 2) | ||
99 | |||
100 | /* | ||
101 | * I/O access functions | ||
102 | */ | ||
103 | |||
104 | /* ldi is the logical device index */ | ||
105 | static inline int pc87427_read8(struct pc87427_data *data, u8 ldi, u8 reg) | ||
106 | { | ||
107 | return inb(data->address[ldi] + reg); | ||
108 | } | ||
109 | |||
110 | /* Must be called with data->lock held, except during init */ | ||
111 | static inline int pc87427_read8_bank(struct pc87427_data *data, u8 ldi, | ||
112 | u8 bank, u8 reg) | ||
113 | { | ||
114 | outb(bank, data->address[ldi] + PC87427_REG_BANK); | ||
115 | return inb(data->address[ldi] + reg); | ||
116 | } | ||
117 | |||
118 | /* Must be called with data->lock held, except during init */ | ||
119 | static inline void pc87427_write8_bank(struct pc87427_data *data, u8 ldi, | ||
120 | u8 bank, u8 reg, u8 value) | ||
121 | { | ||
122 | outb(bank, data->address[ldi] + PC87427_REG_BANK); | ||
123 | outb(value, data->address[ldi] + reg); | ||
124 | } | ||
125 | |||
126 | /* | ||
127 | * Fan registers and conversions | ||
128 | */ | ||
129 | |||
130 | /* fan data registers are 16-bit wide */ | ||
131 | #define PC87427_REG_FAN 0x12 | ||
132 | #define PC87427_REG_FAN_MIN 0x14 | ||
133 | #define PC87427_REG_FAN_STATUS 0x10 | ||
134 | |||
135 | #define FAN_STATUS_STALL (1 << 3) | ||
136 | #define FAN_STATUS_LOSPD (1 << 1) | ||
137 | #define FAN_STATUS_MONEN (1 << 0) | ||
138 | |||
139 | /* Dedicated function to read all registers related to a given fan input. | ||
140 | This saves us quite a few locks and bank selections. | ||
141 | Must be called with data->lock held. | ||
142 | nr is from 0 to 7 */ | ||
143 | static void pc87427_readall_fan(struct pc87427_data *data, u8 nr) | ||
144 | { | ||
145 | int iobase = data->address[LD_FAN]; | ||
146 | |||
147 | outb(BANK_FM(nr), iobase + PC87427_REG_BANK); | ||
148 | data->fan[nr] = inw(iobase + PC87427_REG_FAN); | ||
149 | data->fan_min[nr] = inw(iobase + PC87427_REG_FAN_MIN); | ||
150 | data->fan_status[nr] = inb(iobase + PC87427_REG_FAN_STATUS); | ||
151 | /* Clear fan alarm bits */ | ||
152 | outb(data->fan_status[nr], iobase + PC87427_REG_FAN_STATUS); | ||
153 | } | ||
154 | |||
155 | /* The 2 LSB of fan speed registers are used for something different. | ||
156 | The actual 2 LSB of the measurements are not available. */ | ||
157 | static inline unsigned long fan_from_reg(u16 reg) | ||
158 | { | ||
159 | reg &= 0xfffc; | ||
160 | if (reg == 0x0000 || reg == 0xfffc) | ||
161 | return 0; | ||
162 | return 5400000UL / reg; | ||
163 | } | ||
164 | |||
165 | /* The 2 LSB of the fan speed limit registers are not significant. */ | ||
166 | static inline u16 fan_to_reg(unsigned long val) | ||
167 | { | ||
168 | if (val < 83UL) | ||
169 | return 0xffff; | ||
170 | if (val >= 1350000UL) | ||
171 | return 0x0004; | ||
172 | return ((1350000UL + val / 2) / val) << 2; | ||
173 | } | ||
174 | |||
175 | /* | ||
176 | * Data interface | ||
177 | */ | ||
178 | |||
179 | static struct pc87427_data *pc87427_update_device(struct device *dev) | ||
180 | { | ||
181 | struct pc87427_data *data = dev_get_drvdata(dev); | ||
182 | int i; | ||
183 | |||
184 | mutex_lock(&data->lock); | ||
185 | if (!time_after(jiffies, data->last_updated + HZ) | ||
186 | && data->last_updated) | ||
187 | goto done; | ||
188 | |||
189 | /* Fans */ | ||
190 | for (i = 0; i < 8; i++) { | ||
191 | if (!(data->fan_enabled & (1 << i))) | ||
192 | continue; | ||
193 | pc87427_readall_fan(data, i); | ||
194 | } | ||
195 | data->last_updated = jiffies; | ||
196 | |||
197 | done: | ||
198 | mutex_unlock(&data->lock); | ||
199 | return data; | ||
200 | } | ||
201 | |||
202 | static ssize_t show_fan_input(struct device *dev, struct device_attribute | ||
203 | *devattr, char *buf) | ||
204 | { | ||
205 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
206 | struct pc87427_data *data = pc87427_update_device(dev); | ||
207 | int nr = attr->index; | ||
208 | |||
209 | return sprintf(buf, "%lu\n", fan_from_reg(data->fan[nr])); | ||
210 | } | ||
211 | |||
212 | static ssize_t show_fan_min(struct device *dev, struct device_attribute | ||
213 | *devattr, char *buf) | ||
214 | { | ||
215 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
216 | struct pc87427_data *data = pc87427_update_device(dev); | ||
217 | int nr = attr->index; | ||
218 | |||
219 | return sprintf(buf, "%lu\n", fan_from_reg(data->fan_min[nr])); | ||
220 | } | ||
221 | |||
222 | static ssize_t show_fan_alarm(struct device *dev, struct device_attribute | ||
223 | *devattr, char *buf) | ||
224 | { | ||
225 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
226 | struct pc87427_data *data = pc87427_update_device(dev); | ||
227 | int nr = attr->index; | ||
228 | |||
229 | return sprintf(buf, "%d\n", !!(data->fan_status[nr] | ||
230 | & FAN_STATUS_LOSPD)); | ||
231 | } | ||
232 | |||
233 | static ssize_t show_fan_fault(struct device *dev, struct device_attribute | ||
234 | *devattr, char *buf) | ||
235 | { | ||
236 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
237 | struct pc87427_data *data = pc87427_update_device(dev); | ||
238 | int nr = attr->index; | ||
239 | |||
240 | return sprintf(buf, "%d\n", !!(data->fan_status[nr] | ||
241 | & FAN_STATUS_STALL)); | ||
242 | } | ||
243 | |||
244 | static ssize_t set_fan_min(struct device *dev, struct device_attribute | ||
245 | *devattr, const char *buf, size_t count) | ||
246 | { | ||
247 | struct pc87427_data *data = dev_get_drvdata(dev); | ||
248 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
249 | int nr = attr->index; | ||
250 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
251 | int iobase = data->address[LD_FAN]; | ||
252 | |||
253 | mutex_lock(&data->lock); | ||
254 | outb(BANK_FM(nr), iobase + PC87427_REG_BANK); | ||
255 | /* The low speed limit registers are read-only while monitoring | ||
256 | is enabled, so we have to disable monitoring, then change the | ||
257 | limit, and finally enable monitoring again. */ | ||
258 | outb(0, iobase + PC87427_REG_FAN_STATUS); | ||
259 | data->fan_min[nr] = fan_to_reg(val); | ||
260 | outw(data->fan_min[nr], iobase + PC87427_REG_FAN_MIN); | ||
261 | outb(FAN_STATUS_MONEN, iobase + PC87427_REG_FAN_STATUS); | ||
262 | mutex_unlock(&data->lock); | ||
263 | |||
264 | return count; | ||
265 | } | ||
266 | |||
267 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0); | ||
268 | static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1); | ||
269 | static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan_input, NULL, 2); | ||
270 | static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan_input, NULL, 3); | ||
271 | static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_fan_input, NULL, 4); | ||
272 | static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_fan_input, NULL, 5); | ||
273 | static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_fan_input, NULL, 6); | ||
274 | static SENSOR_DEVICE_ATTR(fan8_input, S_IRUGO, show_fan_input, NULL, 7); | ||
275 | |||
276 | static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, | ||
277 | show_fan_min, set_fan_min, 0); | ||
278 | static SENSOR_DEVICE_ATTR(fan2_min, S_IWUSR | S_IRUGO, | ||
279 | show_fan_min, set_fan_min, 1); | ||
280 | static SENSOR_DEVICE_ATTR(fan3_min, S_IWUSR | S_IRUGO, | ||
281 | show_fan_min, set_fan_min, 2); | ||
282 | static SENSOR_DEVICE_ATTR(fan4_min, S_IWUSR | S_IRUGO, | ||
283 | show_fan_min, set_fan_min, 3); | ||
284 | static SENSOR_DEVICE_ATTR(fan5_min, S_IWUSR | S_IRUGO, | ||
285 | show_fan_min, set_fan_min, 4); | ||
286 | static SENSOR_DEVICE_ATTR(fan6_min, S_IWUSR | S_IRUGO, | ||
287 | show_fan_min, set_fan_min, 5); | ||
288 | static SENSOR_DEVICE_ATTR(fan7_min, S_IWUSR | S_IRUGO, | ||
289 | show_fan_min, set_fan_min, 6); | ||
290 | static SENSOR_DEVICE_ATTR(fan8_min, S_IWUSR | S_IRUGO, | ||
291 | show_fan_min, set_fan_min, 7); | ||
292 | |||
293 | static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_fan_alarm, NULL, 0); | ||
294 | static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_fan_alarm, NULL, 1); | ||
295 | static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_fan_alarm, NULL, 2); | ||
296 | static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_fan_alarm, NULL, 3); | ||
297 | static SENSOR_DEVICE_ATTR(fan5_alarm, S_IRUGO, show_fan_alarm, NULL, 4); | ||
298 | static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_fan_alarm, NULL, 5); | ||
299 | static SENSOR_DEVICE_ATTR(fan7_alarm, S_IRUGO, show_fan_alarm, NULL, 6); | ||
300 | static SENSOR_DEVICE_ATTR(fan8_alarm, S_IRUGO, show_fan_alarm, NULL, 7); | ||
301 | |||
302 | static SENSOR_DEVICE_ATTR(fan1_fault, S_IRUGO, show_fan_fault, NULL, 0); | ||
303 | static SENSOR_DEVICE_ATTR(fan2_fault, S_IRUGO, show_fan_fault, NULL, 1); | ||
304 | static SENSOR_DEVICE_ATTR(fan3_fault, S_IRUGO, show_fan_fault, NULL, 2); | ||
305 | static SENSOR_DEVICE_ATTR(fan4_fault, S_IRUGO, show_fan_fault, NULL, 3); | ||
306 | static SENSOR_DEVICE_ATTR(fan5_fault, S_IRUGO, show_fan_fault, NULL, 4); | ||
307 | static SENSOR_DEVICE_ATTR(fan6_fault, S_IRUGO, show_fan_fault, NULL, 5); | ||
308 | static SENSOR_DEVICE_ATTR(fan7_fault, S_IRUGO, show_fan_fault, NULL, 6); | ||
309 | static SENSOR_DEVICE_ATTR(fan8_fault, S_IRUGO, show_fan_fault, NULL, 7); | ||
310 | |||
311 | static struct attribute *pc87427_attributes_fan[8][5] = { | ||
312 | { | ||
313 | &sensor_dev_attr_fan1_input.dev_attr.attr, | ||
314 | &sensor_dev_attr_fan1_min.dev_attr.attr, | ||
315 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, | ||
316 | &sensor_dev_attr_fan1_fault.dev_attr.attr, | ||
317 | NULL | ||
318 | }, { | ||
319 | &sensor_dev_attr_fan2_input.dev_attr.attr, | ||
320 | &sensor_dev_attr_fan2_min.dev_attr.attr, | ||
321 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, | ||
322 | &sensor_dev_attr_fan2_fault.dev_attr.attr, | ||
323 | NULL | ||
324 | }, { | ||
325 | &sensor_dev_attr_fan3_input.dev_attr.attr, | ||
326 | &sensor_dev_attr_fan3_min.dev_attr.attr, | ||
327 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, | ||
328 | &sensor_dev_attr_fan3_fault.dev_attr.attr, | ||
329 | NULL | ||
330 | }, { | ||
331 | &sensor_dev_attr_fan4_input.dev_attr.attr, | ||
332 | &sensor_dev_attr_fan4_min.dev_attr.attr, | ||
333 | &sensor_dev_attr_fan4_alarm.dev_attr.attr, | ||
334 | &sensor_dev_attr_fan4_fault.dev_attr.attr, | ||
335 | NULL | ||
336 | }, { | ||
337 | &sensor_dev_attr_fan5_input.dev_attr.attr, | ||
338 | &sensor_dev_attr_fan5_min.dev_attr.attr, | ||
339 | &sensor_dev_attr_fan5_alarm.dev_attr.attr, | ||
340 | &sensor_dev_attr_fan5_fault.dev_attr.attr, | ||
341 | NULL | ||
342 | }, { | ||
343 | &sensor_dev_attr_fan6_input.dev_attr.attr, | ||
344 | &sensor_dev_attr_fan6_min.dev_attr.attr, | ||
345 | &sensor_dev_attr_fan6_alarm.dev_attr.attr, | ||
346 | &sensor_dev_attr_fan6_fault.dev_attr.attr, | ||
347 | NULL | ||
348 | }, { | ||
349 | &sensor_dev_attr_fan7_input.dev_attr.attr, | ||
350 | &sensor_dev_attr_fan7_min.dev_attr.attr, | ||
351 | &sensor_dev_attr_fan7_alarm.dev_attr.attr, | ||
352 | &sensor_dev_attr_fan7_fault.dev_attr.attr, | ||
353 | NULL | ||
354 | }, { | ||
355 | &sensor_dev_attr_fan8_input.dev_attr.attr, | ||
356 | &sensor_dev_attr_fan8_min.dev_attr.attr, | ||
357 | &sensor_dev_attr_fan8_alarm.dev_attr.attr, | ||
358 | &sensor_dev_attr_fan8_fault.dev_attr.attr, | ||
359 | NULL | ||
360 | } | ||
361 | }; | ||
362 | |||
363 | static const struct attribute_group pc87427_group_fan[8] = { | ||
364 | { .attrs = pc87427_attributes_fan[0] }, | ||
365 | { .attrs = pc87427_attributes_fan[1] }, | ||
366 | { .attrs = pc87427_attributes_fan[2] }, | ||
367 | { .attrs = pc87427_attributes_fan[3] }, | ||
368 | { .attrs = pc87427_attributes_fan[4] }, | ||
369 | { .attrs = pc87427_attributes_fan[5] }, | ||
370 | { .attrs = pc87427_attributes_fan[6] }, | ||
371 | { .attrs = pc87427_attributes_fan[7] }, | ||
372 | }; | ||
373 | |||
374 | static ssize_t show_name(struct device *dev, struct device_attribute | ||
375 | *devattr, char *buf) | ||
376 | { | ||
377 | struct pc87427_data *data = dev_get_drvdata(dev); | ||
378 | |||
379 | return sprintf(buf, "%s\n", data->name); | ||
380 | } | ||
381 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | ||
382 | |||
383 | |||
384 | /* | ||
385 | * Device detection, attach and detach | ||
386 | */ | ||
387 | |||
388 | static void __devinit pc87427_init_device(struct device *dev) | ||
389 | { | ||
390 | struct pc87427_data *data = dev_get_drvdata(dev); | ||
391 | int i; | ||
392 | u8 reg; | ||
393 | |||
394 | /* The FMC module should be ready */ | ||
395 | reg = pc87427_read8(data, LD_FAN, PC87427_REG_BANK); | ||
396 | if (!(reg & 0x80)) | ||
397 | dev_warn(dev, "FMC module not ready!\n"); | ||
398 | |||
399 | /* Check which fans are enabled */ | ||
400 | for (i = 0; i < 8; i++) { | ||
401 | reg = pc87427_read8_bank(data, LD_FAN, BANK_FM(i), | ||
402 | PC87427_REG_FAN_STATUS); | ||
403 | if (reg & FAN_STATUS_MONEN) | ||
404 | data->fan_enabled |= (1 << i); | ||
405 | } | ||
406 | |||
407 | if (!data->fan_enabled) { | ||
408 | dev_dbg(dev, "Enabling all fan inputs\n"); | ||
409 | for (i = 0; i < 8; i++) | ||
410 | pc87427_write8_bank(data, LD_FAN, BANK_FM(i), | ||
411 | PC87427_REG_FAN_STATUS, | ||
412 | FAN_STATUS_MONEN); | ||
413 | data->fan_enabled = 0xff; | ||
414 | } | ||
415 | } | ||
416 | |||
417 | static int __devinit pc87427_probe(struct platform_device *pdev) | ||
418 | { | ||
419 | struct pc87427_data *data; | ||
420 | struct resource *res; | ||
421 | int i, err; | ||
422 | |||
423 | if (!(data = kzalloc(sizeof(struct pc87427_data), GFP_KERNEL))) { | ||
424 | err = -ENOMEM; | ||
425 | printk(KERN_ERR DRVNAME ": Out of memory\n"); | ||
426 | goto exit; | ||
427 | } | ||
428 | |||
429 | /* This will need to be revisited when we add support for | ||
430 | temperature and voltage monitoring. */ | ||
431 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
432 | data->address[0] = res->start; | ||
433 | |||
434 | mutex_init(&data->lock); | ||
435 | data->name = "pc87427"; | ||
436 | platform_set_drvdata(pdev, data); | ||
437 | pc87427_init_device(&pdev->dev); | ||
438 | |||
439 | /* Register sysfs hooks */ | ||
440 | if ((err = device_create_file(&pdev->dev, &dev_attr_name))) | ||
441 | goto exit_kfree; | ||
442 | for (i = 0; i < 8; i++) { | ||
443 | if (!(data->fan_enabled & (1 << i))) | ||
444 | continue; | ||
445 | if ((err = sysfs_create_group(&pdev->dev.kobj, | ||
446 | &pc87427_group_fan[i]))) | ||
447 | goto exit_remove_files; | ||
448 | } | ||
449 | |||
450 | data->class_dev = hwmon_device_register(&pdev->dev); | ||
451 | if (IS_ERR(data->class_dev)) { | ||
452 | err = PTR_ERR(data->class_dev); | ||
453 | dev_err(&pdev->dev, "Class registration failed (%d)\n", err); | ||
454 | goto exit_remove_files; | ||
455 | } | ||
456 | |||
457 | return 0; | ||
458 | |||
459 | exit_remove_files: | ||
460 | for (i = 0; i < 8; i++) { | ||
461 | if (!(data->fan_enabled & (1 << i))) | ||
462 | continue; | ||
463 | sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_fan[i]); | ||
464 | } | ||
465 | exit_kfree: | ||
466 | platform_set_drvdata(pdev, NULL); | ||
467 | kfree(data); | ||
468 | exit: | ||
469 | return err; | ||
470 | } | ||
471 | |||
472 | static int __devexit pc87427_remove(struct platform_device *pdev) | ||
473 | { | ||
474 | struct pc87427_data *data = platform_get_drvdata(pdev); | ||
475 | int i; | ||
476 | |||
477 | platform_set_drvdata(pdev, NULL); | ||
478 | hwmon_device_unregister(data->class_dev); | ||
479 | device_remove_file(&pdev->dev, &dev_attr_name); | ||
480 | for (i = 0; i < 8; i++) { | ||
481 | if (!(data->fan_enabled & (1 << i))) | ||
482 | continue; | ||
483 | sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_fan[i]); | ||
484 | } | ||
485 | kfree(data); | ||
486 | |||
487 | return 0; | ||
488 | } | ||
489 | |||
490 | |||
491 | static struct platform_driver pc87427_driver = { | ||
492 | .driver = { | ||
493 | .owner = THIS_MODULE, | ||
494 | .name = DRVNAME, | ||
495 | }, | ||
496 | .probe = pc87427_probe, | ||
497 | .remove = __devexit_p(pc87427_remove), | ||
498 | }; | ||
499 | |||
500 | static int __init pc87427_device_add(unsigned short address) | ||
501 | { | ||
502 | struct resource res = { | ||
503 | .start = address, | ||
504 | .end = address + REGION_LENGTH - 1, | ||
505 | .name = logdev_str[0], | ||
506 | .flags = IORESOURCE_IO, | ||
507 | }; | ||
508 | int err; | ||
509 | |||
510 | pdev = platform_device_alloc(DRVNAME, address); | ||
511 | if (!pdev) { | ||
512 | err = -ENOMEM; | ||
513 | printk(KERN_ERR DRVNAME ": Device allocation failed\n"); | ||
514 | goto exit; | ||
515 | } | ||
516 | |||
517 | err = platform_device_add_resources(pdev, &res, 1); | ||
518 | if (err) { | ||
519 | printk(KERN_ERR DRVNAME ": Device resource addition failed " | ||
520 | "(%d)\n", err); | ||
521 | goto exit_device_put; | ||
522 | } | ||
523 | |||
524 | err = platform_device_add(pdev); | ||
525 | if (err) { | ||
526 | printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n", | ||
527 | err); | ||
528 | goto exit_device_put; | ||
529 | } | ||
530 | |||
531 | return 0; | ||
532 | |||
533 | exit_device_put: | ||
534 | platform_device_put(pdev); | ||
535 | exit: | ||
536 | return err; | ||
537 | } | ||
538 | |||
539 | static int __init pc87427_find(int sioaddr, unsigned short *address) | ||
540 | { | ||
541 | u16 val; | ||
542 | int i, err = 0; | ||
543 | |||
544 | /* Identify device */ | ||
545 | val = superio_inb(sioaddr, SIOREG_DEVID); | ||
546 | if (val != 0xf2) { /* PC87427 */ | ||
547 | err = -ENODEV; | ||
548 | goto exit; | ||
549 | } | ||
550 | |||
551 | for (i = 0; i < 2; i++) { | ||
552 | address[i] = 0; | ||
553 | /* Select logical device */ | ||
554 | superio_outb(sioaddr, SIOREG_LDSEL, logdev[i]); | ||
555 | |||
556 | val = superio_inb(sioaddr, SIOREG_ACT); | ||
557 | if (!(val & 0x01)) { | ||
558 | printk(KERN_INFO DRVNAME ": Logical device 0x%02x " | ||
559 | "not activated\n", logdev[i]); | ||
560 | continue; | ||
561 | } | ||
562 | |||
563 | val = superio_inb(sioaddr, SIOREG_MAP); | ||
564 | if (val & 0x01) { | ||
565 | printk(KERN_WARNING DRVNAME ": Logical device 0x%02x " | ||
566 | "is memory-mapped, can't use\n", logdev[i]); | ||
567 | continue; | ||
568 | } | ||
569 | |||
570 | val = (superio_inb(sioaddr, SIOREG_IOBASE) << 8) | ||
571 | | superio_inb(sioaddr, SIOREG_IOBASE + 1); | ||
572 | if (!val) { | ||
573 | printk(KERN_INFO DRVNAME ": I/O base address not set " | ||
574 | "for logical device 0x%02x\n", logdev[i]); | ||
575 | continue; | ||
576 | } | ||
577 | address[i] = val; | ||
578 | } | ||
579 | |||
580 | exit: | ||
581 | superio_exit(sioaddr); | ||
582 | return err; | ||
583 | } | ||
584 | |||
585 | static int __init pc87427_init(void) | ||
586 | { | ||
587 | int err; | ||
588 | unsigned short address[2]; | ||
589 | |||
590 | if (pc87427_find(0x2e, address) | ||
591 | && pc87427_find(0x4e, address)) | ||
592 | return -ENODEV; | ||
593 | |||
594 | /* For now the driver only handles fans so we only care about the | ||
595 | first address. */ | ||
596 | if (!address[0]) | ||
597 | return -ENODEV; | ||
598 | |||
599 | err = platform_driver_register(&pc87427_driver); | ||
600 | if (err) | ||
601 | goto exit; | ||
602 | |||
603 | /* Sets global pdev as a side effect */ | ||
604 | err = pc87427_device_add(address[0]); | ||
605 | if (err) | ||
606 | goto exit_driver; | ||
607 | |||
608 | return 0; | ||
609 | |||
610 | exit_driver: | ||
611 | platform_driver_unregister(&pc87427_driver); | ||
612 | exit: | ||
613 | return err; | ||
614 | } | ||
615 | |||
616 | static void __exit pc87427_exit(void) | ||
617 | { | ||
618 | platform_device_unregister(pdev); | ||
619 | platform_driver_unregister(&pc87427_driver); | ||
620 | } | ||
621 | |||
622 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); | ||
623 | MODULE_DESCRIPTION("PC87427 hardware monitoring driver"); | ||
624 | MODULE_LICENSE("GPL"); | ||
625 | |||
626 | module_init(pc87427_init); | ||
627 | module_exit(pc87427_exit); | ||
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 2257806d0102..212a1558c63b 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c | |||
@@ -3,7 +3,7 @@ | |||
3 | the Winbond W83627EHF Super-I/O chip | 3 | the Winbond W83627EHF Super-I/O chip |
4 | Copyright (C) 2005 Jean Delvare <khali@linux-fr.org> | 4 | Copyright (C) 2005 Jean Delvare <khali@linux-fr.org> |
5 | Copyright (C) 2006 Yuan Mu (Winbond), | 5 | Copyright (C) 2006 Yuan Mu (Winbond), |
6 | Rudolf Marek <r.marek@sh.cvut.cz> | 6 | Rudolf Marek <r.marek@assembler.cz> |
7 | David Hubbard <david.c.hubbard@gmail.com> | 7 | David Hubbard <david.c.hubbard@gmail.com> |
8 | 8 | ||
9 | Shamelessly ripped from the w83627hf driver | 9 | Shamelessly ripped from the w83627hf driver |
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 4e108262576f..b0fa296740d1 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -3,7 +3,7 @@ | |||
3 | monitoring | 3 | monitoring |
4 | Copyright (C) 2004, 2005 Winbond Electronics Corp. | 4 | Copyright (C) 2004, 2005 Winbond Electronics Corp. |
5 | Chunhao Huang <DZShen@Winbond.com.tw>, | 5 | Chunhao Huang <DZShen@Winbond.com.tw>, |
6 | Rudolf Marek <r.marek@sh.cvut.cz> | 6 | Rudolf Marek <r.marek@assembler.cz> |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 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 | 9 | it under the terms of the GNU General Public License as published by |
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c new file mode 100644 index 000000000000..c12ac5abc2bb --- /dev/null +++ b/drivers/hwmon/w83793.c | |||
@@ -0,0 +1,1609 @@ | |||
1 | /* | ||
2 | w83793.c - Linux kernel driver for hardware monitoring | ||
3 | Copyright (C) 2006 Winbond Electronics Corp. | ||
4 | Yuan Mu | ||
5 | Rudolf Marek <r.marek@assembler.cz> | ||
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 - version 2. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program; if not, write to the Free Software | ||
18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
19 | 02110-1301 USA. | ||
20 | */ | ||
21 | |||
22 | /* | ||
23 | Supports following chips: | ||
24 | |||
25 | Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA | ||
26 | w83793 10 12 8 6 0x7b 0x5ca3 yes no | ||
27 | */ | ||
28 | |||
29 | #include <linux/module.h> | ||
30 | #include <linux/init.h> | ||
31 | #include <linux/slab.h> | ||
32 | #include <linux/i2c.h> | ||
33 | #include <linux/hwmon.h> | ||
34 | #include <linux/hwmon-vid.h> | ||
35 | #include <linux/hwmon-sysfs.h> | ||
36 | #include <linux/err.h> | ||
37 | #include <linux/mutex.h> | ||
38 | |||
39 | /* Addresses to scan */ | ||
40 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; | ||
41 | |||
42 | /* Insmod parameters */ | ||
43 | I2C_CLIENT_INSMOD_1(w83793); | ||
44 | I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " | ||
45 | "{bus, clientaddr, subclientaddr1, subclientaddr2}"); | ||
46 | |||
47 | static int reset; | ||
48 | module_param(reset, bool, 0); | ||
49 | MODULE_PARM_DESC(reset, "Set to 1 to reset chip, not recommended"); | ||
50 | |||
51 | /* | ||
52 | Address 0x00, 0x0d, 0x0e, 0x0f in all three banks are reserved | ||
53 | as ID, Bank Select registers | ||
54 | */ | ||
55 | #define W83793_REG_BANKSEL 0x00 | ||
56 | #define W83793_REG_VENDORID 0x0d | ||
57 | #define W83793_REG_CHIPID 0x0e | ||
58 | #define W83793_REG_DEVICEID 0x0f | ||
59 | |||
60 | #define W83793_REG_CONFIG 0x40 | ||
61 | #define W83793_REG_MFC 0x58 | ||
62 | #define W83793_REG_FANIN_CTRL 0x5c | ||
63 | #define W83793_REG_FANIN_SEL 0x5d | ||
64 | #define W83793_REG_I2C_ADDR 0x0b | ||
65 | #define W83793_REG_I2C_SUBADDR 0x0c | ||
66 | #define W83793_REG_VID_INA 0x05 | ||
67 | #define W83793_REG_VID_INB 0x06 | ||
68 | #define W83793_REG_VID_LATCHA 0x07 | ||
69 | #define W83793_REG_VID_LATCHB 0x08 | ||
70 | #define W83793_REG_VID_CTRL 0x59 | ||
71 | |||
72 | static u16 W83793_REG_TEMP_MODE[2] = { 0x5e, 0x5f }; | ||
73 | |||
74 | #define TEMP_READ 0 | ||
75 | #define TEMP_CRIT 1 | ||
76 | #define TEMP_CRIT_HYST 2 | ||
77 | #define TEMP_WARN 3 | ||
78 | #define TEMP_WARN_HYST 4 | ||
79 | /* only crit and crit_hyst affect real-time alarm status | ||
80 | current crit crit_hyst warn warn_hyst */ | ||
81 | static u16 W83793_REG_TEMP[][5] = { | ||
82 | {0x1c, 0x78, 0x79, 0x7a, 0x7b}, | ||
83 | {0x1d, 0x7c, 0x7d, 0x7e, 0x7f}, | ||
84 | {0x1e, 0x80, 0x81, 0x82, 0x83}, | ||
85 | {0x1f, 0x84, 0x85, 0x86, 0x87}, | ||
86 | {0x20, 0x88, 0x89, 0x8a, 0x8b}, | ||
87 | {0x21, 0x8c, 0x8d, 0x8e, 0x8f}, | ||
88 | }; | ||
89 | |||
90 | #define W83793_REG_TEMP_LOW_BITS 0x22 | ||
91 | |||
92 | #define W83793_REG_BEEP(index) (0x53 + (index)) | ||
93 | #define W83793_REG_ALARM(index) (0x4b + (index)) | ||
94 | |||
95 | #define W83793_REG_CLR_CHASSIS 0x4a /* SMI MASK4 */ | ||
96 | #define W83793_REG_IRQ_CTRL 0x50 | ||
97 | #define W83793_REG_OVT_CTRL 0x51 | ||
98 | #define W83793_REG_OVT_BEEP 0x52 | ||
99 | |||
100 | #define IN_READ 0 | ||
101 | #define IN_MAX 1 | ||
102 | #define IN_LOW 2 | ||
103 | static const u16 W83793_REG_IN[][3] = { | ||
104 | /* Current, High, Low */ | ||
105 | {0x10, 0x60, 0x61}, /* Vcore A */ | ||
106 | {0x11, 0x62, 0x63}, /* Vcore B */ | ||
107 | {0x12, 0x64, 0x65}, /* Vtt */ | ||
108 | {0x14, 0x6a, 0x6b}, /* VSEN1 */ | ||
109 | {0x15, 0x6c, 0x6d}, /* VSEN2 */ | ||
110 | {0x16, 0x6e, 0x6f}, /* +3VSEN */ | ||
111 | {0x17, 0x70, 0x71}, /* +12VSEN */ | ||
112 | {0x18, 0x72, 0x73}, /* 5VDD */ | ||
113 | {0x19, 0x74, 0x75}, /* 5VSB */ | ||
114 | {0x1a, 0x76, 0x77}, /* VBAT */ | ||
115 | }; | ||
116 | |||
117 | /* Low Bits of Vcore A/B Vtt Read/High/Low */ | ||
118 | static const u16 W83793_REG_IN_LOW_BITS[] = { 0x1b, 0x68, 0x69 }; | ||
119 | static u8 scale_in[] = { 2, 2, 2, 16, 16, 16, 8, 24, 24, 16 }; | ||
120 | |||
121 | #define W83793_REG_FAN(index) (0x23 + 2 * (index)) /* High byte */ | ||
122 | #define W83793_REG_FAN_MIN(index) (0x90 + 2 * (index)) /* High byte */ | ||
123 | |||
124 | #define W83793_REG_PWM_DEFAULT 0xb2 | ||
125 | #define W83793_REG_PWM_ENABLE 0x207 | ||
126 | #define W83793_REG_PWM_UPTIME 0xc3 /* Unit in 0.1 second */ | ||
127 | #define W83793_REG_PWM_DOWNTIME 0xc4 /* Unit in 0.1 second */ | ||
128 | #define W83793_REG_TEMP_CRITICAL 0xc5 | ||
129 | |||
130 | #define PWM_DUTY 0 | ||
131 | #define PWM_START 1 | ||
132 | #define PWM_NONSTOP 2 | ||
133 | #define W83793_REG_PWM(index, nr) (((nr) == 0 ? 0xb3 : \ | ||
134 | (nr) == 1 ? 0x220 : 0x218) + (index)) | ||
135 | |||
136 | /* bit field, fan1 is bit0, fan2 is bit1 ... */ | ||
137 | #define W83793_REG_TEMP_FAN_MAP(index) (0x201 + (index)) | ||
138 | #define W83793_REG_TEMP_TOL(index) (0x208 + (index)) | ||
139 | #define W83793_REG_TEMP_CRUISE(index) (0x210 + (index)) | ||
140 | #define W83793_REG_PWM_STOP_TIME(index) (0x228 + (index)) | ||
141 | #define W83793_REG_SF2_TEMP(index, nr) (0x230 + ((index) << 4) + (nr)) | ||
142 | #define W83793_REG_SF2_PWM(index, nr) (0x238 + ((index) << 4) + (nr)) | ||
143 | |||
144 | static inline unsigned long FAN_FROM_REG(u16 val) | ||
145 | { | ||
146 | if ((val >= 0xfff) || (val == 0)) | ||
147 | return 0; | ||
148 | return (1350000UL / val); | ||
149 | } | ||
150 | |||
151 | static inline u16 FAN_TO_REG(long rpm) | ||
152 | { | ||
153 | if (rpm <= 0) | ||
154 | return 0x0fff; | ||
155 | return SENSORS_LIMIT((1350000 + (rpm >> 1)) / rpm, 1, 0xffe); | ||
156 | } | ||
157 | |||
158 | static inline unsigned long TIME_FROM_REG(u8 reg) | ||
159 | { | ||
160 | return (reg * 100); | ||
161 | } | ||
162 | |||
163 | static inline u8 TIME_TO_REG(unsigned long val) | ||
164 | { | ||
165 | return SENSORS_LIMIT((val + 50) / 100, 0, 0xff); | ||
166 | } | ||
167 | |||
168 | static inline long TEMP_FROM_REG(s8 reg) | ||
169 | { | ||
170 | return (reg * 1000); | ||
171 | } | ||
172 | |||
173 | static inline s8 TEMP_TO_REG(long val, s8 min, s8 max) | ||
174 | { | ||
175 | return SENSORS_LIMIT((val + (val < 0 ? -500 : 500)) / 1000, min, max); | ||
176 | } | ||
177 | |||
178 | struct w83793_data { | ||
179 | struct i2c_client client; | ||
180 | struct i2c_client *lm75[2]; | ||
181 | struct class_device *class_dev; | ||
182 | struct mutex update_lock; | ||
183 | char valid; /* !=0 if following fields are valid */ | ||
184 | unsigned long last_updated; /* In jiffies */ | ||
185 | unsigned long last_nonvolatile; /* In jiffies, last time we update the | ||
186 | nonvolatile registers */ | ||
187 | |||
188 | u8 bank; | ||
189 | u8 vrm; | ||
190 | u8 vid[2]; | ||
191 | u8 in[10][3]; /* Register value, read/high/low */ | ||
192 | u8 in_low_bits[3]; /* Additional resolution for VCore A/B Vtt */ | ||
193 | |||
194 | u16 has_fan; /* Only fan1- fan5 has own pins */ | ||
195 | u16 fan[12]; /* Register value combine */ | ||
196 | u16 fan_min[12]; /* Register value combine */ | ||
197 | |||
198 | s8 temp[6][5]; /* current, crit, crit_hyst,warn, warn_hyst */ | ||
199 | u8 temp_low_bits; /* Additional resolution TD1-TD4 */ | ||
200 | u8 temp_mode[2]; /* byte 0: Temp D1-D4 mode each has 2 bits | ||
201 | byte 1: Temp R1,R2 mode, each has 1 bit */ | ||
202 | u8 temp_critical; /* If reached all fan will be at full speed */ | ||
203 | u8 temp_fan_map[6]; /* Temp controls which pwm fan, bit field */ | ||
204 | |||
205 | u8 has_pwm; | ||
206 | u8 pwm_enable; /* Register value, each Temp has 1 bit */ | ||
207 | u8 pwm_uptime; /* Register value */ | ||
208 | u8 pwm_downtime; /* Register value */ | ||
209 | u8 pwm_default; /* All fan default pwm, next poweron valid */ | ||
210 | u8 pwm[8][3]; /* Register value */ | ||
211 | u8 pwm_stop_time[8]; | ||
212 | u8 temp_cruise[6]; | ||
213 | |||
214 | u8 alarms[5]; /* realtime status registers */ | ||
215 | u8 beeps[5]; | ||
216 | u8 beep_enable; | ||
217 | u8 tolerance[3]; /* Temp tolerance(Smart Fan I/II) */ | ||
218 | u8 sf2_pwm[6][7]; /* Smart FanII: Fan duty cycle */ | ||
219 | u8 sf2_temp[6][7]; /* Smart FanII: Temp level point */ | ||
220 | }; | ||
221 | |||
222 | static u8 w83793_read_value(struct i2c_client *client, u16 reg); | ||
223 | static int w83793_write_value(struct i2c_client *client, u16 reg, u8 value); | ||
224 | static int w83793_attach_adapter(struct i2c_adapter *adapter); | ||
225 | static int w83793_detect(struct i2c_adapter *adapter, int address, int kind); | ||
226 | static int w83793_detach_client(struct i2c_client *client); | ||
227 | static void w83793_init_client(struct i2c_client *client); | ||
228 | static void w83793_update_nonvolatile(struct device *dev); | ||
229 | static struct w83793_data *w83793_update_device(struct device *dev); | ||
230 | |||
231 | static struct i2c_driver w83793_driver = { | ||
232 | .driver = { | ||
233 | .name = "w83793", | ||
234 | }, | ||
235 | .attach_adapter = w83793_attach_adapter, | ||
236 | .detach_client = w83793_detach_client, | ||
237 | }; | ||
238 | |||
239 | static ssize_t | ||
240 | show_vrm(struct device *dev, struct device_attribute *attr, char *buf) | ||
241 | { | ||
242 | struct i2c_client *client = to_i2c_client(dev); | ||
243 | struct w83793_data *data = i2c_get_clientdata(client); | ||
244 | |||
245 | return sprintf(buf, "%d\n", data->vrm); | ||
246 | } | ||
247 | |||
248 | static ssize_t | ||
249 | show_vid(struct device *dev, struct device_attribute *attr, char *buf) | ||
250 | { | ||
251 | struct w83793_data *data = w83793_update_device(dev); | ||
252 | struct sensor_device_attribute_2 *sensor_attr = | ||
253 | to_sensor_dev_attr_2(attr); | ||
254 | int index = sensor_attr->index; | ||
255 | |||
256 | return sprintf(buf, "%d\n", vid_from_reg(data->vid[index], data->vrm)); | ||
257 | } | ||
258 | |||
259 | static ssize_t | ||
260 | store_vrm(struct device *dev, struct device_attribute *attr, | ||
261 | const char *buf, size_t count) | ||
262 | { | ||
263 | struct i2c_client *client = to_i2c_client(dev); | ||
264 | struct w83793_data *data = i2c_get_clientdata(client); | ||
265 | |||
266 | data->vrm = simple_strtoul(buf, NULL, 10); | ||
267 | return count; | ||
268 | } | ||
269 | |||
270 | #define ALARM_STATUS 0 | ||
271 | #define BEEP_ENABLE 1 | ||
272 | static ssize_t | ||
273 | show_alarm_beep(struct device *dev, struct device_attribute *attr, char *buf) | ||
274 | { | ||
275 | struct w83793_data *data = w83793_update_device(dev); | ||
276 | struct sensor_device_attribute_2 *sensor_attr = | ||
277 | to_sensor_dev_attr_2(attr); | ||
278 | int nr = sensor_attr->nr; | ||
279 | int index = sensor_attr->index >> 3; | ||
280 | int bit = sensor_attr->index & 0x07; | ||
281 | u8 val; | ||
282 | |||
283 | if (ALARM_STATUS == nr) { | ||
284 | val = (data->alarms[index] >> (bit)) & 1; | ||
285 | } else { /* BEEP_ENABLE */ | ||
286 | val = (data->beeps[index] >> (bit)) & 1; | ||
287 | } | ||
288 | |||
289 | return sprintf(buf, "%u\n", val); | ||
290 | } | ||
291 | |||
292 | static ssize_t | ||
293 | store_beep(struct device *dev, struct device_attribute *attr, | ||
294 | const char *buf, size_t count) | ||
295 | { | ||
296 | struct i2c_client *client = to_i2c_client(dev); | ||
297 | struct w83793_data *data = i2c_get_clientdata(client); | ||
298 | struct sensor_device_attribute_2 *sensor_attr = | ||
299 | to_sensor_dev_attr_2(attr); | ||
300 | int index = sensor_attr->index >> 3; | ||
301 | int shift = sensor_attr->index & 0x07; | ||
302 | u8 beep_bit = 1 << shift; | ||
303 | u8 val; | ||
304 | |||
305 | val = simple_strtoul(buf, NULL, 10); | ||
306 | if (val != 0 && val != 1) | ||
307 | return -EINVAL; | ||
308 | |||
309 | mutex_lock(&data->update_lock); | ||
310 | data->beeps[index] = w83793_read_value(client, W83793_REG_BEEP(index)); | ||
311 | data->beeps[index] &= ~beep_bit; | ||
312 | data->beeps[index] |= val << shift; | ||
313 | w83793_write_value(client, W83793_REG_BEEP(index), data->beeps[index]); | ||
314 | mutex_unlock(&data->update_lock); | ||
315 | |||
316 | return count; | ||
317 | } | ||
318 | |||
319 | static ssize_t | ||
320 | show_beep_enable(struct device *dev, struct device_attribute *attr, char *buf) | ||
321 | { | ||
322 | struct w83793_data *data = w83793_update_device(dev); | ||
323 | return sprintf(buf, "%u\n", (data->beep_enable >> 1) & 0x01); | ||
324 | } | ||
325 | |||
326 | static ssize_t | ||
327 | store_beep_enable(struct device *dev, struct device_attribute *attr, | ||
328 | const char *buf, size_t count) | ||
329 | { | ||
330 | struct i2c_client *client = to_i2c_client(dev); | ||
331 | struct w83793_data *data = i2c_get_clientdata(client); | ||
332 | u8 val = simple_strtoul(buf, NULL, 10); | ||
333 | |||
334 | if (val != 0 && val != 1) | ||
335 | return -EINVAL; | ||
336 | |||
337 | mutex_lock(&data->update_lock); | ||
338 | data->beep_enable = w83793_read_value(client, W83793_REG_OVT_BEEP) | ||
339 | & 0xfd; | ||
340 | data->beep_enable |= val << 1; | ||
341 | w83793_write_value(client, W83793_REG_OVT_BEEP, data->beep_enable); | ||
342 | mutex_unlock(&data->update_lock); | ||
343 | |||
344 | return count; | ||
345 | } | ||
346 | |||
347 | /* Write any value to clear chassis alarm */ | ||
348 | static ssize_t | ||
349 | store_chassis_clear(struct device *dev, | ||
350 | struct device_attribute *attr, const char *buf, | ||
351 | size_t count) | ||
352 | { | ||
353 | struct i2c_client *client = to_i2c_client(dev); | ||
354 | struct w83793_data *data = i2c_get_clientdata(client); | ||
355 | u8 val; | ||
356 | |||
357 | mutex_lock(&data->update_lock); | ||
358 | val = w83793_read_value(client, W83793_REG_CLR_CHASSIS); | ||
359 | val |= 0x80; | ||
360 | w83793_write_value(client, W83793_REG_CLR_CHASSIS, val); | ||
361 | mutex_unlock(&data->update_lock); | ||
362 | return count; | ||
363 | } | ||
364 | |||
365 | #define FAN_INPUT 0 | ||
366 | #define FAN_MIN 1 | ||
367 | static ssize_t | ||
368 | show_fan(struct device *dev, struct device_attribute *attr, char *buf) | ||
369 | { | ||
370 | struct sensor_device_attribute_2 *sensor_attr = | ||
371 | to_sensor_dev_attr_2(attr); | ||
372 | int nr = sensor_attr->nr; | ||
373 | int index = sensor_attr->index; | ||
374 | struct w83793_data *data = w83793_update_device(dev); | ||
375 | u16 val; | ||
376 | |||
377 | if (FAN_INPUT == nr) { | ||
378 | val = data->fan[index] & 0x0fff; | ||
379 | } else { | ||
380 | val = data->fan_min[index] & 0x0fff; | ||
381 | } | ||
382 | |||
383 | return sprintf(buf, "%lu\n", FAN_FROM_REG(val)); | ||
384 | } | ||
385 | |||
386 | static ssize_t | ||
387 | store_fan_min(struct device *dev, struct device_attribute *attr, | ||
388 | const char *buf, size_t count) | ||
389 | { | ||
390 | struct sensor_device_attribute_2 *sensor_attr = | ||
391 | to_sensor_dev_attr_2(attr); | ||
392 | int index = sensor_attr->index; | ||
393 | struct i2c_client *client = to_i2c_client(dev); | ||
394 | struct w83793_data *data = i2c_get_clientdata(client); | ||
395 | u16 val = FAN_TO_REG(simple_strtoul(buf, NULL, 10)); | ||
396 | |||
397 | mutex_lock(&data->update_lock); | ||
398 | data->fan_min[index] = val; | ||
399 | w83793_write_value(client, W83793_REG_FAN_MIN(index), | ||
400 | (val >> 8) & 0xff); | ||
401 | w83793_write_value(client, W83793_REG_FAN_MIN(index) + 1, val & 0xff); | ||
402 | mutex_unlock(&data->update_lock); | ||
403 | |||
404 | return count; | ||
405 | } | ||
406 | |||
407 | #define PWM_DUTY 0 | ||
408 | #define PWM_START 1 | ||
409 | #define PWM_NONSTOP 2 | ||
410 | #define PWM_STOP_TIME 3 | ||
411 | static ssize_t | ||
412 | show_pwm(struct device *dev, struct device_attribute *attr, char *buf) | ||
413 | { | ||
414 | struct sensor_device_attribute_2 *sensor_attr = | ||
415 | to_sensor_dev_attr_2(attr); | ||
416 | struct w83793_data *data = w83793_update_device(dev); | ||
417 | u16 val; | ||
418 | int nr = sensor_attr->nr; | ||
419 | int index = sensor_attr->index; | ||
420 | |||
421 | if (PWM_STOP_TIME == nr) | ||
422 | val = TIME_FROM_REG(data->pwm_stop_time[index]); | ||
423 | else | ||
424 | val = (data->pwm[index][nr] & 0x3f) << 2; | ||
425 | |||
426 | return sprintf(buf, "%d\n", val); | ||
427 | } | ||
428 | |||
429 | static ssize_t | ||
430 | store_pwm(struct device *dev, struct device_attribute *attr, | ||
431 | const char *buf, size_t count) | ||
432 | { | ||
433 | struct i2c_client *client = to_i2c_client(dev); | ||
434 | struct w83793_data *data = i2c_get_clientdata(client); | ||
435 | struct sensor_device_attribute_2 *sensor_attr = | ||
436 | to_sensor_dev_attr_2(attr); | ||
437 | int nr = sensor_attr->nr; | ||
438 | int index = sensor_attr->index; | ||
439 | u8 val; | ||
440 | |||
441 | mutex_lock(&data->update_lock); | ||
442 | if (PWM_STOP_TIME == nr) { | ||
443 | val = TIME_TO_REG(simple_strtoul(buf, NULL, 10)); | ||
444 | data->pwm_stop_time[index] = val; | ||
445 | w83793_write_value(client, W83793_REG_PWM_STOP_TIME(index), | ||
446 | val); | ||
447 | } else { | ||
448 | val = SENSORS_LIMIT(simple_strtoul(buf, NULL, 10), 0, 0xff) | ||
449 | >> 2; | ||
450 | data->pwm[index][nr] = | ||
451 | w83793_read_value(client, W83793_REG_PWM(index, nr)) & 0xc0; | ||
452 | data->pwm[index][nr] |= val; | ||
453 | w83793_write_value(client, W83793_REG_PWM(index, nr), | ||
454 | data->pwm[index][nr]); | ||
455 | } | ||
456 | |||
457 | mutex_unlock(&data->update_lock); | ||
458 | return count; | ||
459 | } | ||
460 | |||
461 | static ssize_t | ||
462 | show_temp(struct device *dev, struct device_attribute *attr, char *buf) | ||
463 | { | ||
464 | struct sensor_device_attribute_2 *sensor_attr = | ||
465 | to_sensor_dev_attr_2(attr); | ||
466 | int nr = sensor_attr->nr; | ||
467 | int index = sensor_attr->index; | ||
468 | struct w83793_data *data = w83793_update_device(dev); | ||
469 | long temp = TEMP_FROM_REG(data->temp[index][nr]); | ||
470 | |||
471 | if (TEMP_READ == nr && index < 4) { /* Only TD1-TD4 have low bits */ | ||
472 | int low = ((data->temp_low_bits >> (index * 2)) & 0x03) * 250; | ||
473 | temp += temp > 0 ? low : -low; | ||
474 | } | ||
475 | return sprintf(buf, "%ld\n", temp); | ||
476 | } | ||
477 | |||
478 | static ssize_t | ||
479 | store_temp(struct device *dev, struct device_attribute *attr, | ||
480 | const char *buf, size_t count) | ||
481 | { | ||
482 | struct sensor_device_attribute_2 *sensor_attr = | ||
483 | to_sensor_dev_attr_2(attr); | ||
484 | int nr = sensor_attr->nr; | ||
485 | int index = sensor_attr->index; | ||
486 | struct i2c_client *client = to_i2c_client(dev); | ||
487 | struct w83793_data *data = i2c_get_clientdata(client); | ||
488 | long tmp = simple_strtol(buf, NULL, 10); | ||
489 | |||
490 | mutex_lock(&data->update_lock); | ||
491 | data->temp[index][nr] = TEMP_TO_REG(tmp, -128, 127); | ||
492 | w83793_write_value(client, W83793_REG_TEMP[index][nr], | ||
493 | data->temp[index][nr]); | ||
494 | mutex_unlock(&data->update_lock); | ||
495 | return count; | ||
496 | } | ||
497 | |||
498 | /* | ||
499 | TD1-TD4 | ||
500 | each has 4 mode:(2 bits) | ||
501 | 0: Stop monitor | ||
502 | 1: Use internal temp sensor(default) | ||
503 | 2: Use sensor in AMD CPU and get result by AMDSI | ||
504 | 3: Use sensor in Intel CPU and get result by PECI | ||
505 | |||
506 | TR1-TR2 | ||
507 | each has 2 mode:(1 bit) | ||
508 | 0: Disable temp sensor monitor | ||
509 | 1: To enable temp sensors monitor | ||
510 | */ | ||
511 | |||
512 | /* 0 disable, 5 AMDSI, 6 PECI */ | ||
513 | static u8 TO_TEMP_MODE[] = { 0, 0, 5, 6 }; | ||
514 | |||
515 | static ssize_t | ||
516 | show_temp_mode(struct device *dev, struct device_attribute *attr, char *buf) | ||
517 | { | ||
518 | struct w83793_data *data = w83793_update_device(dev); | ||
519 | struct sensor_device_attribute_2 *sensor_attr = | ||
520 | to_sensor_dev_attr_2(attr); | ||
521 | int index = sensor_attr->index; | ||
522 | u8 mask = (index < 4) ? 0x03 : 0x01; | ||
523 | u8 shift = (index < 4) ? (2 * index) : (index - 4); | ||
524 | u8 tmp; | ||
525 | index = (index < 4) ? 0 : 1; | ||
526 | |||
527 | tmp = (data->temp_mode[index] >> shift) & mask; | ||
528 | |||
529 | /* for the internal sensor, found out if diode or thermistor */ | ||
530 | if (tmp == 1) { | ||
531 | tmp = index == 0 ? 3 : 4; | ||
532 | } else { | ||
533 | tmp = TO_TEMP_MODE[tmp]; | ||
534 | } | ||
535 | |||
536 | return sprintf(buf, "%d\n", tmp); | ||
537 | } | ||
538 | |||
539 | static ssize_t | ||
540 | store_temp_mode(struct device *dev, struct device_attribute *attr, | ||
541 | const char *buf, size_t count) | ||
542 | { | ||
543 | struct i2c_client *client = to_i2c_client(dev); | ||
544 | struct w83793_data *data = i2c_get_clientdata(client); | ||
545 | struct sensor_device_attribute_2 *sensor_attr = | ||
546 | to_sensor_dev_attr_2(attr); | ||
547 | int index = sensor_attr->index; | ||
548 | u8 mask = (index < 4) ? 0x03 : 0x01; | ||
549 | u8 shift = (index < 4) ? (2 * index) : (index - 4); | ||
550 | u8 val = simple_strtoul(buf, NULL, 10); | ||
551 | |||
552 | /* transform the sysfs interface values into table above */ | ||
553 | if ((val == 5 || val == 6) && (index < 4)) { | ||
554 | val -= 3; | ||
555 | } else if ((val == 3 && index < 4) | ||
556 | || (val == 4 && index >= 4) | ||
557 | || val == 0) { | ||
558 | /* transform diode or thermistor into internal enable */ | ||
559 | val = !!val; | ||
560 | } else { | ||
561 | return -EINVAL; | ||
562 | } | ||
563 | |||
564 | index = (index < 4) ? 0 : 1; | ||
565 | mutex_lock(&data->update_lock); | ||
566 | data->temp_mode[index] = | ||
567 | w83793_read_value(client, W83793_REG_TEMP_MODE[index]); | ||
568 | data->temp_mode[index] &= ~(mask << shift); | ||
569 | data->temp_mode[index] |= val << shift; | ||
570 | w83793_write_value(client, W83793_REG_TEMP_MODE[index], | ||
571 | data->temp_mode[index]); | ||
572 | mutex_unlock(&data->update_lock); | ||
573 | |||
574 | return count; | ||
575 | } | ||
576 | |||
577 | #define SETUP_PWM_DEFAULT 0 | ||
578 | #define SETUP_PWM_UPTIME 1 /* Unit in 0.1s */ | ||
579 | #define SETUP_PWM_DOWNTIME 2 /* Unit in 0.1s */ | ||
580 | #define SETUP_TEMP_CRITICAL 3 | ||
581 | static ssize_t | ||
582 | show_sf_setup(struct device *dev, struct device_attribute *attr, char *buf) | ||
583 | { | ||
584 | struct sensor_device_attribute_2 *sensor_attr = | ||
585 | to_sensor_dev_attr_2(attr); | ||
586 | int nr = sensor_attr->nr; | ||
587 | struct w83793_data *data = w83793_update_device(dev); | ||
588 | u32 val = 0; | ||
589 | |||
590 | if (SETUP_PWM_DEFAULT == nr) { | ||
591 | val = (data->pwm_default & 0x3f) << 2; | ||
592 | } else if (SETUP_PWM_UPTIME == nr) { | ||
593 | val = TIME_FROM_REG(data->pwm_uptime); | ||
594 | } else if (SETUP_PWM_DOWNTIME == nr) { | ||
595 | val = TIME_FROM_REG(data->pwm_downtime); | ||
596 | } else if (SETUP_TEMP_CRITICAL == nr) { | ||
597 | val = TEMP_FROM_REG(data->temp_critical & 0x7f); | ||
598 | } | ||
599 | |||
600 | return sprintf(buf, "%d\n", val); | ||
601 | } | ||
602 | |||
603 | static ssize_t | ||
604 | store_sf_setup(struct device *dev, struct device_attribute *attr, | ||
605 | const char *buf, size_t count) | ||
606 | { | ||
607 | struct sensor_device_attribute_2 *sensor_attr = | ||
608 | to_sensor_dev_attr_2(attr); | ||
609 | int nr = sensor_attr->nr; | ||
610 | struct i2c_client *client = to_i2c_client(dev); | ||
611 | struct w83793_data *data = i2c_get_clientdata(client); | ||
612 | |||
613 | mutex_lock(&data->update_lock); | ||
614 | if (SETUP_PWM_DEFAULT == nr) { | ||
615 | data->pwm_default = | ||
616 | w83793_read_value(client, W83793_REG_PWM_DEFAULT) & 0xc0; | ||
617 | data->pwm_default |= SENSORS_LIMIT(simple_strtoul(buf, NULL, | ||
618 | 10), | ||
619 | 0, 0xff) >> 2; | ||
620 | w83793_write_value(client, W83793_REG_PWM_DEFAULT, | ||
621 | data->pwm_default); | ||
622 | } else if (SETUP_PWM_UPTIME == nr) { | ||
623 | data->pwm_uptime = TIME_TO_REG(simple_strtoul(buf, NULL, 10)); | ||
624 | data->pwm_uptime += data->pwm_uptime == 0 ? 1 : 0; | ||
625 | w83793_write_value(client, W83793_REG_PWM_UPTIME, | ||
626 | data->pwm_uptime); | ||
627 | } else if (SETUP_PWM_DOWNTIME == nr) { | ||
628 | data->pwm_downtime = TIME_TO_REG(simple_strtoul(buf, NULL, 10)); | ||
629 | data->pwm_downtime += data->pwm_downtime == 0 ? 1 : 0; | ||
630 | w83793_write_value(client, W83793_REG_PWM_DOWNTIME, | ||
631 | data->pwm_downtime); | ||
632 | } else { /* SETUP_TEMP_CRITICAL */ | ||
633 | data->temp_critical = | ||
634 | w83793_read_value(client, W83793_REG_TEMP_CRITICAL) & 0x80; | ||
635 | data->temp_critical |= TEMP_TO_REG(simple_strtol(buf, NULL, 10), | ||
636 | 0, 0x7f); | ||
637 | w83793_write_value(client, W83793_REG_TEMP_CRITICAL, | ||
638 | data->temp_critical); | ||
639 | } | ||
640 | |||
641 | mutex_unlock(&data->update_lock); | ||
642 | return count; | ||
643 | } | ||
644 | |||
645 | /* | ||
646 | Temp SmartFan control | ||
647 | TEMP_FAN_MAP | ||
648 | Temp channel control which pwm fan, bitfield, bit 0 indicate pwm1... | ||
649 | It's possible two or more temp channels control the same fan, w83793 | ||
650 | always prefers to pick the most critical request and applies it to | ||
651 | the related Fan. | ||
652 | It's possible one fan is not in any mapping of 6 temp channels, this | ||
653 | means the fan is manual mode | ||
654 | |||
655 | TEMP_PWM_ENABLE | ||
656 | Each temp channel has its own SmartFan mode, and temp channel | ||
657 | control fans that are set by TEMP_FAN_MAP | ||
658 | 0: SmartFanII mode | ||
659 | 1: Thermal Cruise Mode | ||
660 | |||
661 | TEMP_CRUISE | ||
662 | Target temperature in thermal cruise mode, w83793 will try to turn | ||
663 | fan speed to keep the temperature of target device around this | ||
664 | temperature. | ||
665 | |||
666 | TEMP_TOLERANCE | ||
667 | If Temp higher or lower than target with this tolerance, w83793 | ||
668 | will take actions to speed up or slow down the fan to keep the | ||
669 | temperature within the tolerance range. | ||
670 | */ | ||
671 | |||
672 | #define TEMP_FAN_MAP 0 | ||
673 | #define TEMP_PWM_ENABLE 1 | ||
674 | #define TEMP_CRUISE 2 | ||
675 | #define TEMP_TOLERANCE 3 | ||
676 | static ssize_t | ||
677 | show_sf_ctrl(struct device *dev, struct device_attribute *attr, char *buf) | ||
678 | { | ||
679 | struct sensor_device_attribute_2 *sensor_attr = | ||
680 | to_sensor_dev_attr_2(attr); | ||
681 | int nr = sensor_attr->nr; | ||
682 | int index = sensor_attr->index; | ||
683 | struct w83793_data *data = w83793_update_device(dev); | ||
684 | u32 val; | ||
685 | |||
686 | if (TEMP_FAN_MAP == nr) { | ||
687 | val = data->temp_fan_map[index]; | ||
688 | } else if (TEMP_PWM_ENABLE == nr) { | ||
689 | /* +2 to transfrom into 2 and 3 to conform with sysfs intf */ | ||
690 | val = ((data->pwm_enable >> index) & 0x01) + 2; | ||
691 | } else if (TEMP_CRUISE == nr) { | ||
692 | val = TEMP_FROM_REG(data->temp_cruise[index] & 0x7f); | ||
693 | } else { /* TEMP_TOLERANCE */ | ||
694 | val = data->tolerance[index >> 1] >> ((index & 0x01) ? 4 : 0); | ||
695 | val = TEMP_FROM_REG(val & 0x0f); | ||
696 | } | ||
697 | return sprintf(buf, "%d\n", val); | ||
698 | } | ||
699 | |||
700 | static ssize_t | ||
701 | store_sf_ctrl(struct device *dev, struct device_attribute *attr, | ||
702 | const char *buf, size_t count) | ||
703 | { | ||
704 | struct sensor_device_attribute_2 *sensor_attr = | ||
705 | to_sensor_dev_attr_2(attr); | ||
706 | int nr = sensor_attr->nr; | ||
707 | int index = sensor_attr->index; | ||
708 | struct i2c_client *client = to_i2c_client(dev); | ||
709 | struct w83793_data *data = i2c_get_clientdata(client); | ||
710 | u32 val; | ||
711 | |||
712 | mutex_lock(&data->update_lock); | ||
713 | if (TEMP_FAN_MAP == nr) { | ||
714 | val = simple_strtoul(buf, NULL, 10) & 0xff; | ||
715 | w83793_write_value(client, W83793_REG_TEMP_FAN_MAP(index), val); | ||
716 | data->temp_fan_map[index] = val; | ||
717 | } else if (TEMP_PWM_ENABLE == nr) { | ||
718 | val = simple_strtoul(buf, NULL, 10); | ||
719 | if (2 == val || 3 == val) { | ||
720 | data->pwm_enable = | ||
721 | w83793_read_value(client, W83793_REG_PWM_ENABLE); | ||
722 | if (val - 2) | ||
723 | data->pwm_enable |= 1 << index; | ||
724 | else | ||
725 | data->pwm_enable &= ~(1 << index); | ||
726 | w83793_write_value(client, W83793_REG_PWM_ENABLE, | ||
727 | data->pwm_enable); | ||
728 | } else { | ||
729 | mutex_unlock(&data->update_lock); | ||
730 | return -EINVAL; | ||
731 | } | ||
732 | } else if (TEMP_CRUISE == nr) { | ||
733 | data->temp_cruise[index] = | ||
734 | w83793_read_value(client, W83793_REG_TEMP_CRUISE(index)); | ||
735 | val = TEMP_TO_REG(simple_strtol(buf, NULL, 10), 0, 0x7f); | ||
736 | data->temp_cruise[index] &= 0x80; | ||
737 | data->temp_cruise[index] |= val; | ||
738 | |||
739 | w83793_write_value(client, W83793_REG_TEMP_CRUISE(index), | ||
740 | data->temp_cruise[index]); | ||
741 | } else { /* TEMP_TOLERANCE */ | ||
742 | int i = index >> 1; | ||
743 | u8 shift = (index & 0x01) ? 4 : 0; | ||
744 | data->tolerance[i] = | ||
745 | w83793_read_value(client, W83793_REG_TEMP_TOL(i)); | ||
746 | |||
747 | val = TEMP_TO_REG(simple_strtol(buf, NULL, 10), 0, 0x0f); | ||
748 | data->tolerance[i] &= ~(0x0f << shift); | ||
749 | data->tolerance[i] |= val << shift; | ||
750 | w83793_write_value(client, W83793_REG_TEMP_TOL(i), | ||
751 | data->tolerance[i]); | ||
752 | } | ||
753 | |||
754 | mutex_unlock(&data->update_lock); | ||
755 | return count; | ||
756 | } | ||
757 | |||
758 | static ssize_t | ||
759 | show_sf2_pwm(struct device *dev, struct device_attribute *attr, char *buf) | ||
760 | { | ||
761 | struct sensor_device_attribute_2 *sensor_attr = | ||
762 | to_sensor_dev_attr_2(attr); | ||
763 | int nr = sensor_attr->nr; | ||
764 | int index = sensor_attr->index; | ||
765 | struct w83793_data *data = w83793_update_device(dev); | ||
766 | |||
767 | return sprintf(buf, "%d\n", (data->sf2_pwm[index][nr] & 0x3f) << 2); | ||
768 | } | ||
769 | |||
770 | static ssize_t | ||
771 | store_sf2_pwm(struct device *dev, struct device_attribute *attr, | ||
772 | const char *buf, size_t count) | ||
773 | { | ||
774 | struct i2c_client *client = to_i2c_client(dev); | ||
775 | struct w83793_data *data = i2c_get_clientdata(client); | ||
776 | struct sensor_device_attribute_2 *sensor_attr = | ||
777 | to_sensor_dev_attr_2(attr); | ||
778 | int nr = sensor_attr->nr; | ||
779 | int index = sensor_attr->index; | ||
780 | u8 val = SENSORS_LIMIT(simple_strtoul(buf, NULL, 10), 0, 0xff) >> 2; | ||
781 | |||
782 | mutex_lock(&data->update_lock); | ||
783 | data->sf2_pwm[index][nr] = | ||
784 | w83793_read_value(client, W83793_REG_SF2_PWM(index, nr)) & 0xc0; | ||
785 | data->sf2_pwm[index][nr] |= val; | ||
786 | w83793_write_value(client, W83793_REG_SF2_PWM(index, nr), | ||
787 | data->sf2_pwm[index][nr]); | ||
788 | mutex_unlock(&data->update_lock); | ||
789 | return count; | ||
790 | } | ||
791 | |||
792 | static ssize_t | ||
793 | show_sf2_temp(struct device *dev, struct device_attribute *attr, char *buf) | ||
794 | { | ||
795 | struct sensor_device_attribute_2 *sensor_attr = | ||
796 | to_sensor_dev_attr_2(attr); | ||
797 | int nr = sensor_attr->nr; | ||
798 | int index = sensor_attr->index; | ||
799 | struct w83793_data *data = w83793_update_device(dev); | ||
800 | |||
801 | return sprintf(buf, "%ld\n", | ||
802 | TEMP_FROM_REG(data->sf2_temp[index][nr] & 0x7f)); | ||
803 | } | ||
804 | |||
805 | static ssize_t | ||
806 | store_sf2_temp(struct device *dev, struct device_attribute *attr, | ||
807 | const char *buf, size_t count) | ||
808 | { | ||
809 | struct i2c_client *client = to_i2c_client(dev); | ||
810 | struct w83793_data *data = i2c_get_clientdata(client); | ||
811 | struct sensor_device_attribute_2 *sensor_attr = | ||
812 | to_sensor_dev_attr_2(attr); | ||
813 | int nr = sensor_attr->nr; | ||
814 | int index = sensor_attr->index; | ||
815 | u8 val = TEMP_TO_REG(simple_strtol(buf, NULL, 10), 0, 0x7f); | ||
816 | |||
817 | mutex_lock(&data->update_lock); | ||
818 | data->sf2_temp[index][nr] = | ||
819 | w83793_read_value(client, W83793_REG_SF2_TEMP(index, nr)) & 0x80; | ||
820 | data->sf2_temp[index][nr] |= val; | ||
821 | w83793_write_value(client, W83793_REG_SF2_TEMP(index, nr), | ||
822 | data->sf2_temp[index][nr]); | ||
823 | mutex_unlock(&data->update_lock); | ||
824 | return count; | ||
825 | } | ||
826 | |||
827 | /* only Vcore A/B and Vtt have additional 2 bits precision */ | ||
828 | static ssize_t | ||
829 | show_in(struct device *dev, struct device_attribute *attr, char *buf) | ||
830 | { | ||
831 | struct sensor_device_attribute_2 *sensor_attr = | ||
832 | to_sensor_dev_attr_2(attr); | ||
833 | int nr = sensor_attr->nr; | ||
834 | int index = sensor_attr->index; | ||
835 | struct w83793_data *data = w83793_update_device(dev); | ||
836 | u16 val = data->in[index][nr]; | ||
837 | |||
838 | if (index < 3) { | ||
839 | val <<= 2; | ||
840 | val += (data->in_low_bits[nr] >> (index * 2)) & 0x3; | ||
841 | } | ||
842 | return sprintf(buf, "%d\n", val * scale_in[index]); | ||
843 | } | ||
844 | |||
845 | static ssize_t | ||
846 | store_in(struct device *dev, struct device_attribute *attr, | ||
847 | const char *buf, size_t count) | ||
848 | { | ||
849 | struct sensor_device_attribute_2 *sensor_attr = | ||
850 | to_sensor_dev_attr_2(attr); | ||
851 | int nr = sensor_attr->nr; | ||
852 | int index = sensor_attr->index; | ||
853 | struct i2c_client *client = to_i2c_client(dev); | ||
854 | struct w83793_data *data = i2c_get_clientdata(client); | ||
855 | u32 val; | ||
856 | |||
857 | val = | ||
858 | (simple_strtoul(buf, NULL, 10) + | ||
859 | scale_in[index] / 2) / scale_in[index]; | ||
860 | mutex_lock(&data->update_lock); | ||
861 | if (index > 2) { | ||
862 | val = SENSORS_LIMIT(val, 0, 255); | ||
863 | } else { | ||
864 | val = SENSORS_LIMIT(val, 0, 0x3FF); | ||
865 | data->in_low_bits[nr] = | ||
866 | w83793_read_value(client, W83793_REG_IN_LOW_BITS[nr]); | ||
867 | data->in_low_bits[nr] &= ~(0x03 << (2 * index)); | ||
868 | data->in_low_bits[nr] |= (val & 0x03) << (2 * index); | ||
869 | w83793_write_value(client, W83793_REG_IN_LOW_BITS[nr], | ||
870 | data->in_low_bits[nr]); | ||
871 | val >>= 2; | ||
872 | } | ||
873 | data->in[index][nr] = val; | ||
874 | w83793_write_value(client, W83793_REG_IN[index][nr], | ||
875 | data->in[index][nr]); | ||
876 | mutex_unlock(&data->update_lock); | ||
877 | return count; | ||
878 | } | ||
879 | |||
880 | #define NOT_USED -1 | ||
881 | |||
882 | #define SENSOR_ATTR_IN(index) \ | ||
883 | SENSOR_ATTR_2(in##index##_input, S_IRUGO, show_in, NULL, \ | ||
884 | IN_READ, index), \ | ||
885 | SENSOR_ATTR_2(in##index##_max, S_IRUGO | S_IWUSR, show_in, \ | ||
886 | store_in, IN_MAX, index), \ | ||
887 | SENSOR_ATTR_2(in##index##_min, S_IRUGO | S_IWUSR, show_in, \ | ||
888 | store_in, IN_LOW, index), \ | ||
889 | SENSOR_ATTR_2(in##index##_alarm, S_IRUGO, show_alarm_beep, \ | ||
890 | NULL, ALARM_STATUS, index + ((index > 2) ? 1 : 0)), \ | ||
891 | SENSOR_ATTR_2(in##index##_beep, S_IWUSR | S_IRUGO, \ | ||
892 | show_alarm_beep, store_beep, BEEP_ENABLE, \ | ||
893 | index + ((index > 2) ? 1 : 0)) | ||
894 | |||
895 | #define SENSOR_ATTR_FAN(index) \ | ||
896 | SENSOR_ATTR_2(fan##index##_alarm, S_IRUGO, show_alarm_beep, \ | ||
897 | NULL, ALARM_STATUS, index + 17), \ | ||
898 | SENSOR_ATTR_2(fan##index##_beep, S_IWUSR | S_IRUGO, \ | ||
899 | show_alarm_beep, store_beep, BEEP_ENABLE, index + 17), \ | ||
900 | SENSOR_ATTR_2(fan##index##_input, S_IRUGO, show_fan, \ | ||
901 | NULL, FAN_INPUT, index - 1), \ | ||
902 | SENSOR_ATTR_2(fan##index##_min, S_IWUSR | S_IRUGO, \ | ||
903 | show_fan, store_fan_min, FAN_MIN, index - 1) | ||
904 | |||
905 | #define SENSOR_ATTR_PWM(index) \ | ||
906 | SENSOR_ATTR_2(pwm##index, S_IWUSR | S_IRUGO, show_pwm, \ | ||
907 | store_pwm, PWM_DUTY, index - 1), \ | ||
908 | SENSOR_ATTR_2(pwm##index##_nonstop, S_IWUSR | S_IRUGO, \ | ||
909 | show_pwm, store_pwm, PWM_NONSTOP, index - 1), \ | ||
910 | SENSOR_ATTR_2(pwm##index##_start, S_IWUSR | S_IRUGO, \ | ||
911 | show_pwm, store_pwm, PWM_START, index - 1), \ | ||
912 | SENSOR_ATTR_2(pwm##index##_stop_time, S_IWUSR | S_IRUGO, \ | ||
913 | show_pwm, store_pwm, PWM_STOP_TIME, index - 1) | ||
914 | |||
915 | #define SENSOR_ATTR_TEMP(index) \ | ||
916 | SENSOR_ATTR_2(temp##index##_type, S_IRUGO | S_IWUSR, \ | ||
917 | show_temp_mode, store_temp_mode, NOT_USED, index - 1), \ | ||
918 | SENSOR_ATTR_2(temp##index##_input, S_IRUGO, show_temp, \ | ||
919 | NULL, TEMP_READ, index - 1), \ | ||
920 | SENSOR_ATTR_2(temp##index##_max, S_IRUGO | S_IWUSR, show_temp, \ | ||
921 | store_temp, TEMP_CRIT, index - 1), \ | ||
922 | SENSOR_ATTR_2(temp##index##_max_hyst, S_IRUGO | S_IWUSR, \ | ||
923 | show_temp, store_temp, TEMP_CRIT_HYST, index - 1), \ | ||
924 | SENSOR_ATTR_2(temp##index##_warn, S_IRUGO | S_IWUSR, show_temp, \ | ||
925 | store_temp, TEMP_WARN, index - 1), \ | ||
926 | SENSOR_ATTR_2(temp##index##_warn_hyst, S_IRUGO | S_IWUSR, \ | ||
927 | show_temp, store_temp, TEMP_WARN_HYST, index - 1), \ | ||
928 | SENSOR_ATTR_2(temp##index##_alarm, S_IRUGO, \ | ||
929 | show_alarm_beep, NULL, ALARM_STATUS, index + 11), \ | ||
930 | SENSOR_ATTR_2(temp##index##_beep, S_IWUSR | S_IRUGO, \ | ||
931 | show_alarm_beep, store_beep, BEEP_ENABLE, index + 11), \ | ||
932 | SENSOR_ATTR_2(temp##index##_auto_channels_pwm, \ | ||
933 | S_IRUGO | S_IWUSR, show_sf_ctrl, store_sf_ctrl, \ | ||
934 | TEMP_FAN_MAP, index - 1), \ | ||
935 | SENSOR_ATTR_2(temp##index##_pwm_enable, S_IWUSR | S_IRUGO, \ | ||
936 | show_sf_ctrl, store_sf_ctrl, TEMP_PWM_ENABLE, \ | ||
937 | index - 1), \ | ||
938 | SENSOR_ATTR_2(thermal_cruise##index, S_IRUGO | S_IWUSR, \ | ||
939 | show_sf_ctrl, store_sf_ctrl, TEMP_CRUISE, index - 1), \ | ||
940 | SENSOR_ATTR_2(tolerance##index, S_IRUGO | S_IWUSR, show_sf_ctrl,\ | ||
941 | store_sf_ctrl, TEMP_TOLERANCE, index - 1), \ | ||
942 | SENSOR_ATTR_2(temp##index##_auto_point1_pwm, S_IRUGO | S_IWUSR, \ | ||
943 | show_sf2_pwm, store_sf2_pwm, 0, index - 1), \ | ||
944 | SENSOR_ATTR_2(temp##index##_auto_point2_pwm, S_IRUGO | S_IWUSR, \ | ||
945 | show_sf2_pwm, store_sf2_pwm, 1, index - 1), \ | ||
946 | SENSOR_ATTR_2(temp##index##_auto_point3_pwm, S_IRUGO | S_IWUSR, \ | ||
947 | show_sf2_pwm, store_sf2_pwm, 2, index - 1), \ | ||
948 | SENSOR_ATTR_2(temp##index##_auto_point4_pwm, S_IRUGO | S_IWUSR, \ | ||
949 | show_sf2_pwm, store_sf2_pwm, 3, index - 1), \ | ||
950 | SENSOR_ATTR_2(temp##index##_auto_point5_pwm, S_IRUGO | S_IWUSR, \ | ||
951 | show_sf2_pwm, store_sf2_pwm, 4, index - 1), \ | ||
952 | SENSOR_ATTR_2(temp##index##_auto_point6_pwm, S_IRUGO | S_IWUSR, \ | ||
953 | show_sf2_pwm, store_sf2_pwm, 5, index - 1), \ | ||
954 | SENSOR_ATTR_2(temp##index##_auto_point7_pwm, S_IRUGO | S_IWUSR, \ | ||
955 | show_sf2_pwm, store_sf2_pwm, 6, index - 1), \ | ||
956 | SENSOR_ATTR_2(temp##index##_auto_point1_temp, S_IRUGO | S_IWUSR,\ | ||
957 | show_sf2_temp, store_sf2_temp, 0, index - 1), \ | ||
958 | SENSOR_ATTR_2(temp##index##_auto_point2_temp, S_IRUGO | S_IWUSR,\ | ||
959 | show_sf2_temp, store_sf2_temp, 1, index - 1), \ | ||
960 | SENSOR_ATTR_2(temp##index##_auto_point3_temp, S_IRUGO | S_IWUSR,\ | ||
961 | show_sf2_temp, store_sf2_temp, 2, index - 1), \ | ||
962 | SENSOR_ATTR_2(temp##index##_auto_point4_temp, S_IRUGO | S_IWUSR,\ | ||
963 | show_sf2_temp, store_sf2_temp, 3, index - 1), \ | ||
964 | SENSOR_ATTR_2(temp##index##_auto_point5_temp, S_IRUGO | S_IWUSR,\ | ||
965 | show_sf2_temp, store_sf2_temp, 4, index - 1), \ | ||
966 | SENSOR_ATTR_2(temp##index##_auto_point6_temp, S_IRUGO | S_IWUSR,\ | ||
967 | show_sf2_temp, store_sf2_temp, 5, index - 1), \ | ||
968 | SENSOR_ATTR_2(temp##index##_auto_point7_temp, S_IRUGO | S_IWUSR,\ | ||
969 | show_sf2_temp, store_sf2_temp, 6, index - 1) | ||
970 | |||
971 | static struct sensor_device_attribute_2 w83793_sensor_attr_2[] = { | ||
972 | SENSOR_ATTR_IN(0), | ||
973 | SENSOR_ATTR_IN(1), | ||
974 | SENSOR_ATTR_IN(2), | ||
975 | SENSOR_ATTR_IN(3), | ||
976 | SENSOR_ATTR_IN(4), | ||
977 | SENSOR_ATTR_IN(5), | ||
978 | SENSOR_ATTR_IN(6), | ||
979 | SENSOR_ATTR_IN(7), | ||
980 | SENSOR_ATTR_IN(8), | ||
981 | SENSOR_ATTR_IN(9), | ||
982 | SENSOR_ATTR_TEMP(1), | ||
983 | SENSOR_ATTR_TEMP(2), | ||
984 | SENSOR_ATTR_TEMP(3), | ||
985 | SENSOR_ATTR_TEMP(4), | ||
986 | SENSOR_ATTR_TEMP(5), | ||
987 | SENSOR_ATTR_TEMP(6), | ||
988 | SENSOR_ATTR_FAN(1), | ||
989 | SENSOR_ATTR_FAN(2), | ||
990 | SENSOR_ATTR_FAN(3), | ||
991 | SENSOR_ATTR_FAN(4), | ||
992 | SENSOR_ATTR_FAN(5), | ||
993 | SENSOR_ATTR_PWM(1), | ||
994 | SENSOR_ATTR_PWM(2), | ||
995 | SENSOR_ATTR_PWM(3), | ||
996 | }; | ||
997 | |||
998 | /* Fan6-Fan12 */ | ||
999 | static struct sensor_device_attribute_2 w83793_left_fan[] = { | ||
1000 | SENSOR_ATTR_FAN(6), | ||
1001 | SENSOR_ATTR_FAN(7), | ||
1002 | SENSOR_ATTR_FAN(8), | ||
1003 | SENSOR_ATTR_FAN(9), | ||
1004 | SENSOR_ATTR_FAN(10), | ||
1005 | SENSOR_ATTR_FAN(11), | ||
1006 | SENSOR_ATTR_FAN(12), | ||
1007 | }; | ||
1008 | |||
1009 | /* Pwm4-Pwm8 */ | ||
1010 | static struct sensor_device_attribute_2 w83793_left_pwm[] = { | ||
1011 | SENSOR_ATTR_PWM(4), | ||
1012 | SENSOR_ATTR_PWM(5), | ||
1013 | SENSOR_ATTR_PWM(6), | ||
1014 | SENSOR_ATTR_PWM(7), | ||
1015 | SENSOR_ATTR_PWM(8), | ||
1016 | }; | ||
1017 | |||
1018 | static struct sensor_device_attribute_2 sda_single_files[] = { | ||
1019 | SENSOR_ATTR_2(cpu0_vid, S_IRUGO, show_vid, NULL, NOT_USED, 0), | ||
1020 | SENSOR_ATTR_2(cpu1_vid, S_IRUGO, show_vid, NULL, NOT_USED, 1), | ||
1021 | SENSOR_ATTR_2(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm, | ||
1022 | NOT_USED, NOT_USED), | ||
1023 | SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep, | ||
1024 | store_chassis_clear, ALARM_STATUS, 30), | ||
1025 | SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable, | ||
1026 | store_beep_enable, NOT_USED, NOT_USED), | ||
1027 | SENSOR_ATTR_2(pwm_default, S_IWUSR | S_IRUGO, show_sf_setup, | ||
1028 | store_sf_setup, SETUP_PWM_DEFAULT, NOT_USED), | ||
1029 | SENSOR_ATTR_2(pwm_uptime, S_IWUSR | S_IRUGO, show_sf_setup, | ||
1030 | store_sf_setup, SETUP_PWM_UPTIME, NOT_USED), | ||
1031 | SENSOR_ATTR_2(pwm_downtime, S_IWUSR | S_IRUGO, show_sf_setup, | ||
1032 | store_sf_setup, SETUP_PWM_DOWNTIME, NOT_USED), | ||
1033 | SENSOR_ATTR_2(temp_critical, S_IWUSR | S_IRUGO, show_sf_setup, | ||
1034 | store_sf_setup, SETUP_TEMP_CRITICAL, NOT_USED), | ||
1035 | }; | ||
1036 | |||
1037 | static void w83793_init_client(struct i2c_client *client) | ||
1038 | { | ||
1039 | if (reset) { | ||
1040 | w83793_write_value(client, W83793_REG_CONFIG, 0x80); | ||
1041 | } | ||
1042 | |||
1043 | /* Start monitoring */ | ||
1044 | w83793_write_value(client, W83793_REG_CONFIG, | ||
1045 | w83793_read_value(client, W83793_REG_CONFIG) | 0x01); | ||
1046 | |||
1047 | } | ||
1048 | |||
1049 | static int w83793_attach_adapter(struct i2c_adapter *adapter) | ||
1050 | { | ||
1051 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
1052 | return 0; | ||
1053 | return i2c_probe(adapter, &addr_data, w83793_detect); | ||
1054 | } | ||
1055 | |||
1056 | static int w83793_detach_client(struct i2c_client *client) | ||
1057 | { | ||
1058 | struct w83793_data *data = i2c_get_clientdata(client); | ||
1059 | struct device *dev = &client->dev; | ||
1060 | int err, i; | ||
1061 | |||
1062 | /* main client */ | ||
1063 | if (data) { | ||
1064 | hwmon_device_unregister(data->class_dev); | ||
1065 | |||
1066 | for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) | ||
1067 | device_remove_file(dev, | ||
1068 | &w83793_sensor_attr_2[i].dev_attr); | ||
1069 | |||
1070 | for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) | ||
1071 | device_remove_file(dev, &sda_single_files[i].dev_attr); | ||
1072 | |||
1073 | for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++) | ||
1074 | device_remove_file(dev, &w83793_left_fan[i].dev_attr); | ||
1075 | |||
1076 | for (i = 0; i < ARRAY_SIZE(w83793_left_pwm); i++) | ||
1077 | device_remove_file(dev, &w83793_left_pwm[i].dev_attr); | ||
1078 | } | ||
1079 | |||
1080 | if ((err = i2c_detach_client(client))) | ||
1081 | return err; | ||
1082 | |||
1083 | /* main client */ | ||
1084 | if (data) | ||
1085 | kfree(data); | ||
1086 | /* subclient */ | ||
1087 | else | ||
1088 | kfree(client); | ||
1089 | |||
1090 | return 0; | ||
1091 | } | ||
1092 | |||
1093 | static int | ||
1094 | w83793_create_subclient(struct i2c_adapter *adapter, | ||
1095 | struct i2c_client *client, int addr, | ||
1096 | struct i2c_client **sub_cli) | ||
1097 | { | ||
1098 | int err = 0; | ||
1099 | struct i2c_client *sub_client; | ||
1100 | |||
1101 | (*sub_cli) = sub_client = | ||
1102 | kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | ||
1103 | if (!(sub_client)) { | ||
1104 | return -ENOMEM; | ||
1105 | } | ||
1106 | sub_client->addr = 0x48 + addr; | ||
1107 | i2c_set_clientdata(sub_client, NULL); | ||
1108 | sub_client->adapter = adapter; | ||
1109 | sub_client->driver = &w83793_driver; | ||
1110 | strlcpy(sub_client->name, "w83793 subclient", I2C_NAME_SIZE); | ||
1111 | if ((err = i2c_attach_client(sub_client))) { | ||
1112 | dev_err(&client->dev, "subclient registration " | ||
1113 | "at address 0x%x failed\n", sub_client->addr); | ||
1114 | kfree(sub_client); | ||
1115 | } | ||
1116 | return err; | ||
1117 | } | ||
1118 | |||
1119 | static int | ||
1120 | w83793_detect_subclients(struct i2c_adapter *adapter, int address, | ||
1121 | int kind, struct i2c_client *client) | ||
1122 | { | ||
1123 | int i, id, err; | ||
1124 | u8 tmp; | ||
1125 | struct w83793_data *data = i2c_get_clientdata(client); | ||
1126 | |||
1127 | id = i2c_adapter_id(adapter); | ||
1128 | if (force_subclients[0] == id && force_subclients[1] == address) { | ||
1129 | for (i = 2; i <= 3; i++) { | ||
1130 | if (force_subclients[i] < 0x48 | ||
1131 | || force_subclients[i] > 0x4f) { | ||
1132 | dev_err(&client->dev, | ||
1133 | "invalid subclient " | ||
1134 | "address %d; must be 0x48-0x4f\n", | ||
1135 | force_subclients[i]); | ||
1136 | err = -EINVAL; | ||
1137 | goto ERROR_SC_0; | ||
1138 | } | ||
1139 | } | ||
1140 | w83793_write_value(client, W83793_REG_I2C_SUBADDR, | ||
1141 | (force_subclients[2] & 0x07) | | ||
1142 | ((force_subclients[3] & 0x07) << 4)); | ||
1143 | } | ||
1144 | |||
1145 | tmp = w83793_read_value(client, W83793_REG_I2C_SUBADDR); | ||
1146 | if (!(tmp & 0x08)) { | ||
1147 | err = | ||
1148 | w83793_create_subclient(adapter, client, tmp & 0x7, | ||
1149 | &data->lm75[0]); | ||
1150 | if (err < 0) | ||
1151 | goto ERROR_SC_0; | ||
1152 | } | ||
1153 | if (!(tmp & 0x80)) { | ||
1154 | if ((data->lm75[0] != NULL) | ||
1155 | && ((tmp & 0x7) == ((tmp >> 4) & 0x7))) { | ||
1156 | dev_err(&client->dev, | ||
1157 | "duplicate addresses 0x%x, " | ||
1158 | "use force_subclients\n", data->lm75[0]->addr); | ||
1159 | err = -ENODEV; | ||
1160 | goto ERROR_SC_1; | ||
1161 | } | ||
1162 | err = w83793_create_subclient(adapter, client, | ||
1163 | (tmp >> 4) & 0x7, &data->lm75[1]); | ||
1164 | if (err < 0) | ||
1165 | goto ERROR_SC_1; | ||
1166 | } | ||
1167 | |||
1168 | return 0; | ||
1169 | |||
1170 | /* Undo inits in case of errors */ | ||
1171 | |||
1172 | ERROR_SC_1: | ||
1173 | if (data->lm75[0] != NULL) { | ||
1174 | i2c_detach_client(data->lm75[0]); | ||
1175 | kfree(data->lm75[0]); | ||
1176 | } | ||
1177 | ERROR_SC_0: | ||
1178 | return err; | ||
1179 | } | ||
1180 | |||
1181 | static int w83793_detect(struct i2c_adapter *adapter, int address, int kind) | ||
1182 | { | ||
1183 | int i; | ||
1184 | u8 tmp, val; | ||
1185 | struct i2c_client *client; | ||
1186 | struct device *dev; | ||
1187 | struct w83793_data *data; | ||
1188 | int files_fan = ARRAY_SIZE(w83793_left_fan) / 7; | ||
1189 | int files_pwm = ARRAY_SIZE(w83793_left_pwm) / 5; | ||
1190 | int err = 0; | ||
1191 | |||
1192 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { | ||
1193 | goto exit; | ||
1194 | } | ||
1195 | |||
1196 | /* OK. For now, we presume we have a valid client. We now create the | ||
1197 | client structure, even though we cannot fill it completely yet. | ||
1198 | But it allows us to access w83793_{read,write}_value. */ | ||
1199 | |||
1200 | if (!(data = kzalloc(sizeof(struct w83793_data), GFP_KERNEL))) { | ||
1201 | err = -ENOMEM; | ||
1202 | goto exit; | ||
1203 | } | ||
1204 | |||
1205 | client = &data->client; | ||
1206 | dev = &client->dev; | ||
1207 | i2c_set_clientdata(client, data); | ||
1208 | client->addr = address; | ||
1209 | client->adapter = adapter; | ||
1210 | client->driver = &w83793_driver; | ||
1211 | |||
1212 | data->bank = i2c_smbus_read_byte_data(client, W83793_REG_BANKSEL); | ||
1213 | |||
1214 | /* Now, we do the remaining detection. */ | ||
1215 | if (kind < 0) { | ||
1216 | tmp = data->bank & 0x80 ? 0x5c : 0xa3; | ||
1217 | /* Check Winbond vendor ID */ | ||
1218 | if (tmp != i2c_smbus_read_byte_data(client, | ||
1219 | W83793_REG_VENDORID)) { | ||
1220 | pr_debug("w83793: Detection failed at check " | ||
1221 | "vendor id\n"); | ||
1222 | err = -ENODEV; | ||
1223 | goto free_mem; | ||
1224 | } | ||
1225 | |||
1226 | /* If Winbond chip, address of chip and W83793_REG_I2C_ADDR | ||
1227 | should match */ | ||
1228 | if ((data->bank & 0x07) == 0 | ||
1229 | && i2c_smbus_read_byte_data(client, W83793_REG_I2C_ADDR) != | ||
1230 | (address << 1)) { | ||
1231 | pr_debug("w83793: Detection failed at check " | ||
1232 | "i2c addr\n"); | ||
1233 | err = -ENODEV; | ||
1234 | goto free_mem; | ||
1235 | } | ||
1236 | |||
1237 | } | ||
1238 | |||
1239 | /* We have either had a force parameter, or we have already detected the | ||
1240 | Winbond. Determine the chip type now */ | ||
1241 | |||
1242 | if (kind <= 0) { | ||
1243 | if (0x7b == w83793_read_value(client, W83793_REG_CHIPID)) { | ||
1244 | kind = w83793; | ||
1245 | } else { | ||
1246 | if (kind == 0) | ||
1247 | dev_warn(&adapter->dev, "w83793: Ignoring " | ||
1248 | "'force' parameter for unknown chip " | ||
1249 | "at address 0x%02x\n", address); | ||
1250 | err = -ENODEV; | ||
1251 | goto free_mem; | ||
1252 | } | ||
1253 | } | ||
1254 | |||
1255 | /* Fill in the remaining client fields and put into the global list */ | ||
1256 | strlcpy(client->name, "w83793", I2C_NAME_SIZE); | ||
1257 | |||
1258 | mutex_init(&data->update_lock); | ||
1259 | |||
1260 | /* Tell the I2C layer a new client has arrived */ | ||
1261 | if ((err = i2c_attach_client(client))) | ||
1262 | goto free_mem; | ||
1263 | |||
1264 | if ((err = w83793_detect_subclients(adapter, address, kind, client))) | ||
1265 | goto detach_client; | ||
1266 | |||
1267 | /* Initialize the chip */ | ||
1268 | w83793_init_client(client); | ||
1269 | |||
1270 | data->vrm = vid_which_vrm(); | ||
1271 | /* | ||
1272 | Only fan 1-5 has their own input pins, | ||
1273 | Pwm 1-3 has their own pins | ||
1274 | */ | ||
1275 | data->has_fan = 0x1f; | ||
1276 | data->has_pwm = 0x07; | ||
1277 | tmp = w83793_read_value(client, W83793_REG_MFC); | ||
1278 | val = w83793_read_value(client, W83793_REG_FANIN_CTRL); | ||
1279 | |||
1280 | /* check the function of pins 49-56 */ | ||
1281 | if (!(tmp & 0x80)) { | ||
1282 | data->has_pwm |= 0x18; /* pwm 4,5 */ | ||
1283 | if (val & 0x01) { /* fan 6 */ | ||
1284 | data->has_fan |= 0x20; | ||
1285 | data->has_pwm |= 0x20; | ||
1286 | } | ||
1287 | if (val & 0x02) { /* fan 7 */ | ||
1288 | data->has_fan |= 0x40; | ||
1289 | data->has_pwm |= 0x40; | ||
1290 | } | ||
1291 | if (!(tmp & 0x40) && (val & 0x04)) { /* fan 8 */ | ||
1292 | data->has_fan |= 0x80; | ||
1293 | data->has_pwm |= 0x80; | ||
1294 | } | ||
1295 | } | ||
1296 | |||
1297 | if (0x08 == (tmp & 0x0c)) { | ||
1298 | if (val & 0x08) /* fan 9 */ | ||
1299 | data->has_fan |= 0x100; | ||
1300 | if (val & 0x10) /* fan 10 */ | ||
1301 | data->has_fan |= 0x200; | ||
1302 | } | ||
1303 | |||
1304 | if (0x20 == (tmp & 0x30)) { | ||
1305 | if (val & 0x20) /* fan 11 */ | ||
1306 | data->has_fan |= 0x400; | ||
1307 | if (val & 0x40) /* fan 12 */ | ||
1308 | data->has_fan |= 0x800; | ||
1309 | } | ||
1310 | |||
1311 | if ((tmp & 0x01) && (val & 0x04)) { /* fan 8, second location */ | ||
1312 | data->has_fan |= 0x80; | ||
1313 | data->has_pwm |= 0x80; | ||
1314 | } | ||
1315 | |||
1316 | /* Register sysfs hooks */ | ||
1317 | for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) { | ||
1318 | err = device_create_file(dev, | ||
1319 | &w83793_sensor_attr_2[i].dev_attr); | ||
1320 | if (err) | ||
1321 | goto exit_remove; | ||
1322 | } | ||
1323 | |||
1324 | for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) { | ||
1325 | err = device_create_file(dev, &sda_single_files[i].dev_attr); | ||
1326 | if (err) | ||
1327 | goto exit_remove; | ||
1328 | |||
1329 | } | ||
1330 | |||
1331 | for (i = 5; i < 12; i++) { | ||
1332 | int j; | ||
1333 | if (!(data->has_fan & (1 << i))) | ||
1334 | continue; | ||
1335 | for (j = 0; j < files_fan; j++) { | ||
1336 | err = device_create_file(dev, | ||
1337 | &w83793_left_fan[(i - 5) * files_fan | ||
1338 | + j].dev_attr); | ||
1339 | if (err) | ||
1340 | goto exit_remove; | ||
1341 | } | ||
1342 | } | ||
1343 | |||
1344 | for (i = 3; i < 8; i++) { | ||
1345 | int j; | ||
1346 | if (!(data->has_pwm & (1 << i))) | ||
1347 | continue; | ||
1348 | for (j = 0; j < files_pwm; j++) { | ||
1349 | err = device_create_file(dev, | ||
1350 | &w83793_left_pwm[(i - 3) * files_pwm | ||
1351 | + j].dev_attr); | ||
1352 | if (err) | ||
1353 | goto exit_remove; | ||
1354 | } | ||
1355 | } | ||
1356 | |||
1357 | data->class_dev = hwmon_device_register(dev); | ||
1358 | if (IS_ERR(data->class_dev)) { | ||
1359 | err = PTR_ERR(data->class_dev); | ||
1360 | goto exit_remove; | ||
1361 | } | ||
1362 | |||
1363 | return 0; | ||
1364 | |||
1365 | /* Unregister sysfs hooks */ | ||
1366 | |||
1367 | exit_remove: | ||
1368 | for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) | ||
1369 | device_remove_file(dev, &w83793_sensor_attr_2[i].dev_attr); | ||
1370 | |||
1371 | for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) | ||
1372 | device_remove_file(dev, &sda_single_files[i].dev_attr); | ||
1373 | |||
1374 | for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++) | ||
1375 | device_remove_file(dev, &w83793_left_fan[i].dev_attr); | ||
1376 | |||
1377 | for (i = 0; i < ARRAY_SIZE(w83793_left_pwm); i++) | ||
1378 | device_remove_file(dev, &w83793_left_pwm[i].dev_attr); | ||
1379 | |||
1380 | if (data->lm75[0] != NULL) { | ||
1381 | i2c_detach_client(data->lm75[0]); | ||
1382 | kfree(data->lm75[0]); | ||
1383 | } | ||
1384 | if (data->lm75[1] != NULL) { | ||
1385 | i2c_detach_client(data->lm75[1]); | ||
1386 | kfree(data->lm75[1]); | ||
1387 | } | ||
1388 | detach_client: | ||
1389 | i2c_detach_client(client); | ||
1390 | free_mem: | ||
1391 | kfree(data); | ||
1392 | exit: | ||
1393 | return err; | ||
1394 | } | ||
1395 | |||
1396 | static void w83793_update_nonvolatile(struct device *dev) | ||
1397 | { | ||
1398 | struct i2c_client *client = to_i2c_client(dev); | ||
1399 | struct w83793_data *data = i2c_get_clientdata(client); | ||
1400 | int i, j; | ||
1401 | /* | ||
1402 | They are somewhat "stable" registers, and to update them everytime | ||
1403 | takes so much time, it's just not worthy. Update them in a long | ||
1404 | interval to avoid exception. | ||
1405 | */ | ||
1406 | if (!(time_after(jiffies, data->last_nonvolatile + HZ * 300) | ||
1407 | || !data->valid)) | ||
1408 | return; | ||
1409 | /* update voltage limits */ | ||
1410 | for (i = 1; i < 3; i++) { | ||
1411 | for (j = 0; j < ARRAY_SIZE(data->in); j++) { | ||
1412 | data->in[j][i] = | ||
1413 | w83793_read_value(client, W83793_REG_IN[j][i]); | ||
1414 | } | ||
1415 | data->in_low_bits[i] = | ||
1416 | w83793_read_value(client, W83793_REG_IN_LOW_BITS[i]); | ||
1417 | } | ||
1418 | |||
1419 | for (i = 0; i < ARRAY_SIZE(data->fan_min); i++) { | ||
1420 | /* Update the Fan measured value and limits */ | ||
1421 | if (!(data->has_fan & (1 << i))) { | ||
1422 | continue; | ||
1423 | } | ||
1424 | data->fan_min[i] = | ||
1425 | w83793_read_value(client, W83793_REG_FAN_MIN(i)) << 8; | ||
1426 | data->fan_min[i] |= | ||
1427 | w83793_read_value(client, W83793_REG_FAN_MIN(i) + 1); | ||
1428 | } | ||
1429 | |||
1430 | for (i = 0; i < ARRAY_SIZE(data->temp_fan_map); i++) { | ||
1431 | data->temp_fan_map[i] = | ||
1432 | w83793_read_value(client, W83793_REG_TEMP_FAN_MAP(i)); | ||
1433 | for (j = 1; j < 5; j++) { | ||
1434 | data->temp[i][j] = | ||
1435 | w83793_read_value(client, W83793_REG_TEMP[i][j]); | ||
1436 | } | ||
1437 | data->temp_cruise[i] = | ||
1438 | w83793_read_value(client, W83793_REG_TEMP_CRUISE(i)); | ||
1439 | for (j = 0; j < 7; j++) { | ||
1440 | data->sf2_pwm[i][j] = | ||
1441 | w83793_read_value(client, W83793_REG_SF2_PWM(i, j)); | ||
1442 | data->sf2_temp[i][j] = | ||
1443 | w83793_read_value(client, | ||
1444 | W83793_REG_SF2_TEMP(i, j)); | ||
1445 | } | ||
1446 | } | ||
1447 | |||
1448 | for (i = 0; i < ARRAY_SIZE(data->temp_mode); i++) | ||
1449 | data->temp_mode[i] = | ||
1450 | w83793_read_value(client, W83793_REG_TEMP_MODE[i]); | ||
1451 | |||
1452 | for (i = 0; i < ARRAY_SIZE(data->tolerance); i++) { | ||
1453 | data->tolerance[i] = | ||
1454 | w83793_read_value(client, W83793_REG_TEMP_TOL(i)); | ||
1455 | } | ||
1456 | |||
1457 | for (i = 0; i < ARRAY_SIZE(data->pwm); i++) { | ||
1458 | if (!(data->has_pwm & (1 << i))) | ||
1459 | continue; | ||
1460 | data->pwm[i][PWM_NONSTOP] = | ||
1461 | w83793_read_value(client, W83793_REG_PWM(i, PWM_NONSTOP)); | ||
1462 | data->pwm[i][PWM_START] = | ||
1463 | w83793_read_value(client, W83793_REG_PWM(i, PWM_START)); | ||
1464 | data->pwm_stop_time[i] = | ||
1465 | w83793_read_value(client, W83793_REG_PWM_STOP_TIME(i)); | ||
1466 | } | ||
1467 | |||
1468 | data->pwm_default = w83793_read_value(client, W83793_REG_PWM_DEFAULT); | ||
1469 | data->pwm_enable = w83793_read_value(client, W83793_REG_PWM_ENABLE); | ||
1470 | data->pwm_uptime = w83793_read_value(client, W83793_REG_PWM_UPTIME); | ||
1471 | data->pwm_downtime = w83793_read_value(client, W83793_REG_PWM_DOWNTIME); | ||
1472 | data->temp_critical = | ||
1473 | w83793_read_value(client, W83793_REG_TEMP_CRITICAL); | ||
1474 | data->beep_enable = w83793_read_value(client, W83793_REG_OVT_BEEP); | ||
1475 | |||
1476 | for (i = 0; i < ARRAY_SIZE(data->beeps); i++) { | ||
1477 | data->beeps[i] = w83793_read_value(client, W83793_REG_BEEP(i)); | ||
1478 | } | ||
1479 | |||
1480 | data->last_nonvolatile = jiffies; | ||
1481 | } | ||
1482 | |||
1483 | static struct w83793_data *w83793_update_device(struct device *dev) | ||
1484 | { | ||
1485 | struct i2c_client *client = to_i2c_client(dev); | ||
1486 | struct w83793_data *data = i2c_get_clientdata(client); | ||
1487 | int i; | ||
1488 | |||
1489 | mutex_lock(&data->update_lock); | ||
1490 | |||
1491 | if (!(time_after(jiffies, data->last_updated + HZ * 2) | ||
1492 | || !data->valid)) | ||
1493 | goto END; | ||
1494 | |||
1495 | /* Update the voltages measured value and limits */ | ||
1496 | for (i = 0; i < ARRAY_SIZE(data->in); i++) | ||
1497 | data->in[i][IN_READ] = | ||
1498 | w83793_read_value(client, W83793_REG_IN[i][IN_READ]); | ||
1499 | |||
1500 | data->in_low_bits[IN_READ] = | ||
1501 | w83793_read_value(client, W83793_REG_IN_LOW_BITS[IN_READ]); | ||
1502 | |||
1503 | for (i = 0; i < ARRAY_SIZE(data->fan); i++) { | ||
1504 | if (!(data->has_fan & (1 << i))) { | ||
1505 | continue; | ||
1506 | } | ||
1507 | data->fan[i] = | ||
1508 | w83793_read_value(client, W83793_REG_FAN(i)) << 8; | ||
1509 | data->fan[i] |= | ||
1510 | w83793_read_value(client, W83793_REG_FAN(i) + 1); | ||
1511 | } | ||
1512 | |||
1513 | for (i = 0; i < ARRAY_SIZE(data->temp); i++) | ||
1514 | data->temp[i][TEMP_READ] = | ||
1515 | w83793_read_value(client, W83793_REG_TEMP[i][TEMP_READ]); | ||
1516 | |||
1517 | data->temp_low_bits = | ||
1518 | w83793_read_value(client, W83793_REG_TEMP_LOW_BITS); | ||
1519 | |||
1520 | for (i = 0; i < ARRAY_SIZE(data->pwm); i++) { | ||
1521 | if (data->has_pwm & (1 << i)) | ||
1522 | data->pwm[i][PWM_DUTY] = | ||
1523 | w83793_read_value(client, | ||
1524 | W83793_REG_PWM(i, PWM_DUTY)); | ||
1525 | } | ||
1526 | |||
1527 | for (i = 0; i < ARRAY_SIZE(data->alarms); i++) | ||
1528 | data->alarms[i] = | ||
1529 | w83793_read_value(client, W83793_REG_ALARM(i)); | ||
1530 | data->vid[0] = w83793_read_value(client, W83793_REG_VID_INA); | ||
1531 | data->vid[1] = w83793_read_value(client, W83793_REG_VID_INB); | ||
1532 | w83793_update_nonvolatile(dev); | ||
1533 | data->last_updated = jiffies; | ||
1534 | data->valid = 1; | ||
1535 | |||
1536 | END: | ||
1537 | mutex_unlock(&data->update_lock); | ||
1538 | return data; | ||
1539 | } | ||
1540 | |||
1541 | /* Ignore the possibility that somebody change bank outside the driver | ||
1542 | Must be called with data->update_lock held, except during initialization */ | ||
1543 | static u8 w83793_read_value(struct i2c_client *client, u16 reg) | ||
1544 | { | ||
1545 | struct w83793_data *data = i2c_get_clientdata(client); | ||
1546 | u8 res = 0xff; | ||
1547 | u8 new_bank = reg >> 8; | ||
1548 | |||
1549 | new_bank |= data->bank & 0xfc; | ||
1550 | if (data->bank != new_bank) { | ||
1551 | if (i2c_smbus_write_byte_data | ||
1552 | (client, W83793_REG_BANKSEL, new_bank) >= 0) | ||
1553 | data->bank = new_bank; | ||
1554 | else { | ||
1555 | dev_err(&client->dev, | ||
1556 | "set bank to %d failed, fall back " | ||
1557 | "to bank %d, read reg 0x%x error\n", | ||
1558 | new_bank, data->bank, reg); | ||
1559 | res = 0x0; /* read 0x0 from the chip */ | ||
1560 | goto END; | ||
1561 | } | ||
1562 | } | ||
1563 | res = i2c_smbus_read_byte_data(client, reg & 0xff); | ||
1564 | END: | ||
1565 | return res; | ||
1566 | } | ||
1567 | |||
1568 | /* Must be called with data->update_lock held, except during initialization */ | ||
1569 | static int w83793_write_value(struct i2c_client *client, u16 reg, u8 value) | ||
1570 | { | ||
1571 | struct w83793_data *data = i2c_get_clientdata(client); | ||
1572 | int res; | ||
1573 | u8 new_bank = reg >> 8; | ||
1574 | |||
1575 | new_bank |= data->bank & 0xfc; | ||
1576 | if (data->bank != new_bank) { | ||
1577 | if ((res = i2c_smbus_write_byte_data | ||
1578 | (client, W83793_REG_BANKSEL, new_bank)) >= 0) | ||
1579 | data->bank = new_bank; | ||
1580 | else { | ||
1581 | dev_err(&client->dev, | ||
1582 | "set bank to %d failed, fall back " | ||
1583 | "to bank %d, write reg 0x%x error\n", | ||
1584 | new_bank, data->bank, reg); | ||
1585 | goto END; | ||
1586 | } | ||
1587 | } | ||
1588 | |||
1589 | res = i2c_smbus_write_byte_data(client, reg & 0xff, value); | ||
1590 | END: | ||
1591 | return res; | ||
1592 | } | ||
1593 | |||
1594 | static int __init sensors_w83793_init(void) | ||
1595 | { | ||
1596 | return i2c_add_driver(&w83793_driver); | ||
1597 | } | ||
1598 | |||
1599 | static void __exit sensors_w83793_exit(void) | ||
1600 | { | ||
1601 | i2c_del_driver(&w83793_driver); | ||
1602 | } | ||
1603 | |||
1604 | MODULE_AUTHOR("Yuan Mu"); | ||
1605 | MODULE_DESCRIPTION("w83793 driver"); | ||
1606 | MODULE_LICENSE("GPL"); | ||
1607 | |||
1608 | module_init(sensors_w83793_init); | ||
1609 | module_exit(sensors_w83793_exit); | ||
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c index 33fbb47100a3..8e1e3f8e40a4 100644 --- a/drivers/i2c/busses/i2c-ali1563.c +++ b/drivers/i2c/busses/i2c-ali1563.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge | 2 | * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge |
3 | * | 3 | * |
4 | * Copyright (C) 2004 Patrick Mochel | 4 | * Copyright (C) 2004 Patrick Mochel |
5 | * 2005 Rudolf Marek <r.marek@sh.cvut.cz> | 5 | * 2005 Rudolf Marek <r.marek@assembler.cz> |
6 | * | 6 | * |
7 | * The 1563 southbridge is deceptively similar to the 1533, with a | 7 | * The 1563 southbridge is deceptively similar to the 1533, with a |
8 | * few notable exceptions. One of those happens to be the fact they | 8 | * few notable exceptions. One of those happens to be the fact they |
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index 60bef94cd25f..4ee56def61f2 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c | |||
@@ -82,7 +82,7 @@ struct tps65010 { | |||
82 | struct i2c_client client; | 82 | struct i2c_client client; |
83 | struct mutex lock; | 83 | struct mutex lock; |
84 | int irq; | 84 | int irq; |
85 | struct work_struct work; | 85 | struct delayed_work work; |
86 | struct dentry *file; | 86 | struct dentry *file; |
87 | unsigned charging:1; | 87 | unsigned charging:1; |
88 | unsigned por:1; | 88 | unsigned por:1; |
@@ -328,7 +328,7 @@ static void tps65010_interrupt(struct tps65010 *tps) | |||
328 | { | 328 | { |
329 | u8 tmp = 0, mask, poll; | 329 | u8 tmp = 0, mask, poll; |
330 | 330 | ||
331 | /* IRQs won't trigger irqs for certain events, but we can get | 331 | /* IRQs won't trigger for certain events, but we can get |
332 | * others by polling (normally, with external power applied). | 332 | * others by polling (normally, with external power applied). |
333 | */ | 333 | */ |
334 | poll = 0; | 334 | poll = 0; |
@@ -411,10 +411,11 @@ static void tps65010_interrupt(struct tps65010 *tps) | |||
411 | } | 411 | } |
412 | 412 | ||
413 | /* handle IRQs and polling using keventd for now */ | 413 | /* handle IRQs and polling using keventd for now */ |
414 | static void tps65010_work(void *_tps) | 414 | static void tps65010_work(struct work_struct *work) |
415 | { | 415 | { |
416 | struct tps65010 *tps = _tps; | 416 | struct tps65010 *tps; |
417 | 417 | ||
418 | tps = container_of(work, struct tps65010, work.work); | ||
418 | mutex_lock(&tps->lock); | 419 | mutex_lock(&tps->lock); |
419 | 420 | ||
420 | tps65010_interrupt(tps); | 421 | tps65010_interrupt(tps); |
@@ -452,7 +453,7 @@ static irqreturn_t tps65010_irq(int irq, void *_tps) | |||
452 | 453 | ||
453 | disable_irq_nosync(irq); | 454 | disable_irq_nosync(irq); |
454 | set_bit(FLAG_IRQ_ENABLE, &tps->flags); | 455 | set_bit(FLAG_IRQ_ENABLE, &tps->flags); |
455 | (void) schedule_work(&tps->work); | 456 | (void) schedule_work(&tps->work.work); |
456 | return IRQ_HANDLED; | 457 | return IRQ_HANDLED; |
457 | } | 458 | } |
458 | 459 | ||
@@ -465,13 +466,15 @@ static int __exit tps65010_detach_client(struct i2c_client *client) | |||
465 | struct tps65010 *tps; | 466 | struct tps65010 *tps; |
466 | 467 | ||
467 | tps = container_of(client, struct tps65010, client); | 468 | tps = container_of(client, struct tps65010, client); |
469 | free_irq(tps->irq, tps); | ||
468 | #ifdef CONFIG_ARM | 470 | #ifdef CONFIG_ARM |
469 | if (machine_is_omap_h2()) | 471 | if (machine_is_omap_h2()) |
470 | omap_free_gpio(58); | 472 | omap_free_gpio(58); |
471 | if (machine_is_omap_osk()) | 473 | if (machine_is_omap_osk()) |
472 | omap_free_gpio(OMAP_MPUIO(1)); | 474 | omap_free_gpio(OMAP_MPUIO(1)); |
473 | #endif | 475 | #endif |
474 | free_irq(tps->irq, tps); | 476 | cancel_delayed_work(&tps->work); |
477 | flush_scheduled_work(); | ||
475 | debugfs_remove(tps->file); | 478 | debugfs_remove(tps->file); |
476 | if (i2c_detach_client(client) == 0) | 479 | if (i2c_detach_client(client) == 0) |
477 | kfree(tps); | 480 | kfree(tps); |
@@ -505,7 +508,7 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind) | |||
505 | return 0; | 508 | return 0; |
506 | 509 | ||
507 | mutex_init(&tps->lock); | 510 | mutex_init(&tps->lock); |
508 | INIT_WORK(&tps->work, tps65010_work, tps); | 511 | INIT_DELAYED_WORK(&tps->work, tps65010_work); |
509 | tps->irq = -1; | 512 | tps->irq = -1; |
510 | tps->client.addr = address; | 513 | tps->client.addr = address; |
511 | tps->client.adapter = bus; | 514 | tps->client.adapter = bus; |
@@ -620,7 +623,7 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind) | |||
620 | (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK3, 0x0f | 623 | (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK3, 0x0f |
621 | | i2c_smbus_read_byte_data(&tps->client, TPS_MASK3)); | 624 | | i2c_smbus_read_byte_data(&tps->client, TPS_MASK3)); |
622 | 625 | ||
623 | tps65010_work(tps); | 626 | tps65010_work(&tps->work.work); |
624 | 627 | ||
625 | tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL, | 628 | tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL, |
626 | tps, DEBUG_FOPS); | 629 | tps, DEBUG_FOPS); |
@@ -672,7 +675,7 @@ int tps65010_set_vbus_draw(unsigned mA) | |||
672 | && test_and_set_bit( | 675 | && test_and_set_bit( |
673 | FLAG_VBUS_CHANGED, &the_tps->flags)) { | 676 | FLAG_VBUS_CHANGED, &the_tps->flags)) { |
674 | /* gadget drivers call this in_irq() */ | 677 | /* gadget drivers call this in_irq() */ |
675 | (void) schedule_work(&the_tps->work); | 678 | (void) schedule_work(&the_tps->work.work); |
676 | } | 679 | } |
677 | local_irq_restore(flags); | 680 | local_irq_restore(flags); |
678 | 681 | ||
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index e3a267622bb6..d33717c8afd4 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -2147,7 +2147,7 @@ static int ide_floppy_probe(ide_drive_t *drive) | |||
2147 | printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name); | 2147 | printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name); |
2148 | goto failed; | 2148 | goto failed; |
2149 | } | 2149 | } |
2150 | if ((floppy = (idefloppy_floppy_t *) kzalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) { | 2150 | if ((floppy = kzalloc(sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) { |
2151 | printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name); | 2151 | printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name); |
2152 | goto failed; | 2152 | goto failed; |
2153 | } | 2153 | } |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index e2f4bb549063..b3bcd1d7315e 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -2573,11 +2573,11 @@ static idetape_stage_t *__idetape_kmalloc_stage (idetape_tape_t *tape, int full, | |||
2573 | int pages = tape->pages_per_stage; | 2573 | int pages = tape->pages_per_stage; |
2574 | char *b_data = NULL; | 2574 | char *b_data = NULL; |
2575 | 2575 | ||
2576 | if ((stage = (idetape_stage_t *) kmalloc (sizeof (idetape_stage_t),GFP_KERNEL)) == NULL) | 2576 | if ((stage = kmalloc(sizeof (idetape_stage_t),GFP_KERNEL)) == NULL) |
2577 | return NULL; | 2577 | return NULL; |
2578 | stage->next = NULL; | 2578 | stage->next = NULL; |
2579 | 2579 | ||
2580 | bh = stage->bh = (struct idetape_bh *)kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); | 2580 | bh = stage->bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); |
2581 | if (bh == NULL) | 2581 | if (bh == NULL) |
2582 | goto abort; | 2582 | goto abort; |
2583 | bh->b_reqnext = NULL; | 2583 | bh->b_reqnext = NULL; |
@@ -2607,7 +2607,7 @@ static idetape_stage_t *__idetape_kmalloc_stage (idetape_tape_t *tape, int full, | |||
2607 | continue; | 2607 | continue; |
2608 | } | 2608 | } |
2609 | prev_bh = bh; | 2609 | prev_bh = bh; |
2610 | if ((bh = (struct idetape_bh *)kmalloc(sizeof(struct idetape_bh), GFP_KERNEL)) == NULL) { | 2610 | if ((bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL)) == NULL) { |
2611 | free_page((unsigned long) b_data); | 2611 | free_page((unsigned long) b_data); |
2612 | goto abort; | 2612 | goto abort; |
2613 | } | 2613 | } |
@@ -4860,7 +4860,7 @@ static int ide_tape_probe(ide_drive_t *drive) | |||
4860 | printk(KERN_WARNING "ide-tape: Use drive %s with ide-scsi emulation and osst.\n", drive->name); | 4860 | printk(KERN_WARNING "ide-tape: Use drive %s with ide-scsi emulation and osst.\n", drive->name); |
4861 | printk(KERN_WARNING "ide-tape: OnStream support will be removed soon from ide-tape!\n"); | 4861 | printk(KERN_WARNING "ide-tape: OnStream support will be removed soon from ide-tape!\n"); |
4862 | } | 4862 | } |
4863 | tape = (idetape_tape_t *) kzalloc (sizeof (idetape_tape_t), GFP_KERNEL); | 4863 | tape = kzalloc(sizeof (idetape_tape_t), GFP_KERNEL); |
4864 | if (tape == NULL) { | 4864 | if (tape == NULL) { |
4865 | printk(KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name); | 4865 | printk(KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name); |
4866 | goto failed; | 4866 | goto failed; |
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index e993a51f250e..08119da06d54 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
@@ -4,6 +4,7 @@ | |||
4 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> | 4 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> |
5 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. | 5 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. |
6 | * Portions Copyright (C) 2003 Red Hat Inc | 6 | * Portions Copyright (C) 2003 Red Hat Inc |
7 | * Portions Copyright (C) 2005-2006 MontaVista Software, Inc. | ||
7 | * | 8 | * |
8 | * Thanks to HighPoint Technologies for their assistance, and hardware. | 9 | * Thanks to HighPoint Technologies for their assistance, and hardware. |
9 | * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his | 10 | * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his |
@@ -11,9 +12,11 @@ | |||
11 | * development and support. | 12 | * development and support. |
12 | * | 13 | * |
13 | * | 14 | * |
14 | * Highpoint have their own driver (source except for the raid part) | 15 | * HighPoint has its own drivers (open source except for the RAID part) |
15 | * available from http://www.highpoint-tech.com/hpt3xx-opensource-v131.tgz | 16 | * available from http://www.highpoint-tech.com/BIOS%20+%20Driver/. |
16 | * This may be useful to anyone wanting to work on the mainstream hpt IDE. | 17 | * This may be useful to anyone wanting to work on this driver, however do not |
18 | * trust them too much since the code tends to become less and less meaningful | ||
19 | * as the time passes... :-/ | ||
17 | * | 20 | * |
18 | * Note that final HPT370 support was done by force extraction of GPL. | 21 | * Note that final HPT370 support was done by force extraction of GPL. |
19 | * | 22 | * |
@@ -52,6 +55,29 @@ | |||
52 | * keeping me sane. | 55 | * keeping me sane. |
53 | * Alan Cox <alan@redhat.com> | 56 | * Alan Cox <alan@redhat.com> |
54 | * | 57 | * |
58 | * - fix the clock turnaround code: it was writing to the wrong ports when | ||
59 | * called for the secondary channel, caching the current clock mode per- | ||
60 | * channel caused the cached register value to get out of sync with the | ||
61 | * actual one, the channels weren't serialized, the turnaround shouldn't | ||
62 | * be done on 66 MHz PCI bus | ||
63 | * - avoid calibrating PLL twice as the second time results in a wrong PCI | ||
64 | * frequency and thus in the wrong timings for the secondary channel | ||
65 | * - disable UltraATA/133 for HPT372 by default (50 MHz DPLL clock do not | ||
66 | * allow for this speed anyway) | ||
67 | * - add support for HPT302N and HPT371N clocking (the same as for HPT372N) | ||
68 | * - HPT371/N are single channel chips, so avoid touching the primary channel | ||
69 | * which exists only virtually (there's no pins for it) | ||
70 | * - fix/remove bad/unused timing tables and use one set of tables for the whole | ||
71 | * HPT37x chip family; save space by introducing the separate transfer mode | ||
72 | * table in which the mode lookup is done | ||
73 | * - use f_CNT value saved by the HighPoint BIOS as reading it directly gives | ||
74 | * the wrong PCI frequency since DPLL has already been calibrated by BIOS | ||
75 | * - fix the hotswap code: it caused RESET- to glitch when tristating the bus, | ||
76 | * and for HPT36x the obsolete HDIO_TRISTATE_HWIF handler was called instead | ||
77 | * - pass to init_chipset() handlers a copy of the IDE PCI device structure as | ||
78 | * they tamper with its fields | ||
79 | * <source@mvista.com> | ||
80 | * | ||
55 | */ | 81 | */ |
56 | 82 | ||
57 | 83 | ||
@@ -76,8 +102,8 @@ | |||
76 | 102 | ||
77 | /* various tuning parameters */ | 103 | /* various tuning parameters */ |
78 | #define HPT_RESET_STATE_ENGINE | 104 | #define HPT_RESET_STATE_ENGINE |
79 | #undef HPT_DELAY_INTERRUPT | 105 | #undef HPT_DELAY_INTERRUPT |
80 | #undef HPT_SERIALIZE_IO | 106 | #define HPT_SERIALIZE_IO 0 |
81 | 107 | ||
82 | static const char *quirk_drives[] = { | 108 | static const char *quirk_drives[] = { |
83 | "QUANTUM FIREBALLlct08 08", | 109 | "QUANTUM FIREBALLlct08 08", |
@@ -141,305 +167,175 @@ static const char *bad_ata33[] = { | |||
141 | NULL | 167 | NULL |
142 | }; | 168 | }; |
143 | 169 | ||
144 | struct chipset_bus_clock_list_entry { | 170 | static u8 xfer_speeds[] = { |
145 | u8 xfer_speed; | 171 | XFER_UDMA_6, |
146 | unsigned int chipset_settings; | 172 | XFER_UDMA_5, |
173 | XFER_UDMA_4, | ||
174 | XFER_UDMA_3, | ||
175 | XFER_UDMA_2, | ||
176 | XFER_UDMA_1, | ||
177 | XFER_UDMA_0, | ||
178 | |||
179 | XFER_MW_DMA_2, | ||
180 | XFER_MW_DMA_1, | ||
181 | XFER_MW_DMA_0, | ||
182 | |||
183 | XFER_PIO_4, | ||
184 | XFER_PIO_3, | ||
185 | XFER_PIO_2, | ||
186 | XFER_PIO_1, | ||
187 | XFER_PIO_0 | ||
147 | }; | 188 | }; |
148 | 189 | ||
149 | /* key for bus clock timings | 190 | /* Key for bus clock timings |
150 | * bit | 191 | * 36x 37x |
151 | * 0:3 data_high_time. inactive time of DIOW_/DIOR_ for PIO and MW | 192 | * bits bits |
152 | * DMA. cycles = value + 1 | 193 | * 0:3 0:3 data_high_time. Inactive time of DIOW_/DIOR_ for PIO and MW DMA. |
153 | * 4:8 data_low_time. active time of DIOW_/DIOR_ for PIO and MW | 194 | * cycles = value + 1 |
154 | * DMA. cycles = value + 1 | 195 | * 4:7 4:8 data_low_time. Active time of DIOW_/DIOR_ for PIO and MW DMA. |
155 | * 9:12 cmd_high_time. inactive time of DIOW_/DIOR_ during task file | 196 | * cycles = value + 1 |
156 | * register access. | 197 | * 8:11 9:12 cmd_high_time. Inactive time of DIOW_/DIOR_ during task file |
157 | * 13:17 cmd_low_time. active time of DIOW_/DIOR_ during task file | 198 | * register access. |
158 | * register access. | 199 | * 12:15 13:17 cmd_low_time. Active time of DIOW_/DIOR_ during task file |
159 | * 18:21 udma_cycle_time. clock freq and clock cycles for UDMA xfer. | 200 | * register access. |
160 | * during task file register access. | 201 | * 16:18 18:20 udma_cycle_time. Clock cycles for UDMA xfer. |
161 | * 22:24 pre_high_time. time to initialize 1st cycle for PIO and MW DMA | 202 | * - 21 CLK frequency: 0=ATA clock, 1=dual ATA clock. |
162 | * xfer. | 203 | * 19:21 22:24 pre_high_time. Time to initialize the 1st cycle for PIO and |
163 | * 25:27 cmd_pre_high_time. time to initialize 1st PIO cycle for task | 204 | * MW DMA xfer. |
164 | * register access. | 205 | * 22:24 25:27 cmd_pre_high_time. Time to initialize the 1st PIO cycle for |
165 | * 28 UDMA enable | 206 | * task file register access. |
166 | * 29 DMA enable | 207 | * 28 28 UDMA enable. |
167 | * 30 PIO_MST enable. if set, the chip is in bus master mode during | 208 | * 29 29 DMA enable. |
168 | * PIO. | 209 | * 30 30 PIO MST enable. If set, the chip is in bus master mode during |
169 | * 31 FIFO enable. | 210 | * PIO xfer. |
211 | * 31 31 FIFO enable. | ||
170 | */ | 212 | */ |
171 | static struct chipset_bus_clock_list_entry forty_base_hpt366[] = { | ||
172 | { XFER_UDMA_4, 0x900fd943 }, | ||
173 | { XFER_UDMA_3, 0x900ad943 }, | ||
174 | { XFER_UDMA_2, 0x900bd943 }, | ||
175 | { XFER_UDMA_1, 0x9008d943 }, | ||
176 | { XFER_UDMA_0, 0x9008d943 }, | ||
177 | |||
178 | { XFER_MW_DMA_2, 0xa008d943 }, | ||
179 | { XFER_MW_DMA_1, 0xa010d955 }, | ||
180 | { XFER_MW_DMA_0, 0xa010d9fc }, | ||
181 | |||
182 | { XFER_PIO_4, 0xc008d963 }, | ||
183 | { XFER_PIO_3, 0xc010d974 }, | ||
184 | { XFER_PIO_2, 0xc010d997 }, | ||
185 | { XFER_PIO_1, 0xc010d9c7 }, | ||
186 | { XFER_PIO_0, 0xc018d9d9 }, | ||
187 | { 0, 0x0120d9d9 } | ||
188 | }; | ||
189 | |||
190 | static struct chipset_bus_clock_list_entry thirty_three_base_hpt366[] = { | ||
191 | { XFER_UDMA_4, 0x90c9a731 }, | ||
192 | { XFER_UDMA_3, 0x90cfa731 }, | ||
193 | { XFER_UDMA_2, 0x90caa731 }, | ||
194 | { XFER_UDMA_1, 0x90cba731 }, | ||
195 | { XFER_UDMA_0, 0x90c8a731 }, | ||
196 | |||
197 | { XFER_MW_DMA_2, 0xa0c8a731 }, | ||
198 | { XFER_MW_DMA_1, 0xa0c8a732 }, /* 0xa0c8a733 */ | ||
199 | { XFER_MW_DMA_0, 0xa0c8a797 }, | ||
200 | |||
201 | { XFER_PIO_4, 0xc0c8a731 }, | ||
202 | { XFER_PIO_3, 0xc0c8a742 }, | ||
203 | { XFER_PIO_2, 0xc0d0a753 }, | ||
204 | { XFER_PIO_1, 0xc0d0a7a3 }, /* 0xc0d0a793 */ | ||
205 | { XFER_PIO_0, 0xc0d0a7aa }, /* 0xc0d0a7a7 */ | ||
206 | { 0, 0x0120a7a7 } | ||
207 | }; | ||
208 | |||
209 | static struct chipset_bus_clock_list_entry twenty_five_base_hpt366[] = { | ||
210 | { XFER_UDMA_4, 0x90c98521 }, | ||
211 | { XFER_UDMA_3, 0x90cf8521 }, | ||
212 | { XFER_UDMA_2, 0x90cf8521 }, | ||
213 | { XFER_UDMA_1, 0x90cb8521 }, | ||
214 | { XFER_UDMA_0, 0x90cb8521 }, | ||
215 | |||
216 | { XFER_MW_DMA_2, 0xa0ca8521 }, | ||
217 | { XFER_MW_DMA_1, 0xa0ca8532 }, | ||
218 | { XFER_MW_DMA_0, 0xa0ca8575 }, | ||
219 | |||
220 | { XFER_PIO_4, 0xc0ca8521 }, | ||
221 | { XFER_PIO_3, 0xc0ca8532 }, | ||
222 | { XFER_PIO_2, 0xc0ca8542 }, | ||
223 | { XFER_PIO_1, 0xc0d08572 }, | ||
224 | { XFER_PIO_0, 0xc0d08585 }, | ||
225 | { 0, 0x01208585 } | ||
226 | }; | ||
227 | |||
228 | /* from highpoint documentation. these are old values */ | ||
229 | static struct chipset_bus_clock_list_entry thirty_three_base_hpt370[] = { | ||
230 | /* { XFER_UDMA_5, 0x1A85F442, 0x16454e31 }, */ | ||
231 | { XFER_UDMA_5, 0x16454e31 }, | ||
232 | { XFER_UDMA_4, 0x16454e31 }, | ||
233 | { XFER_UDMA_3, 0x166d4e31 }, | ||
234 | { XFER_UDMA_2, 0x16494e31 }, | ||
235 | { XFER_UDMA_1, 0x164d4e31 }, | ||
236 | { XFER_UDMA_0, 0x16514e31 }, | ||
237 | |||
238 | { XFER_MW_DMA_2, 0x26514e21 }, | ||
239 | { XFER_MW_DMA_1, 0x26514e33 }, | ||
240 | { XFER_MW_DMA_0, 0x26514e97 }, | ||
241 | |||
242 | { XFER_PIO_4, 0x06514e21 }, | ||
243 | { XFER_PIO_3, 0x06514e22 }, | ||
244 | { XFER_PIO_2, 0x06514e33 }, | ||
245 | { XFER_PIO_1, 0x06914e43 }, | ||
246 | { XFER_PIO_0, 0x06914e57 }, | ||
247 | { 0, 0x06514e57 } | ||
248 | }; | ||
249 | |||
250 | static struct chipset_bus_clock_list_entry sixty_six_base_hpt370[] = { | ||
251 | { XFER_UDMA_5, 0x14846231 }, | ||
252 | { XFER_UDMA_4, 0x14886231 }, | ||
253 | { XFER_UDMA_3, 0x148c6231 }, | ||
254 | { XFER_UDMA_2, 0x148c6231 }, | ||
255 | { XFER_UDMA_1, 0x14906231 }, | ||
256 | { XFER_UDMA_0, 0x14986231 }, | ||
257 | |||
258 | { XFER_MW_DMA_2, 0x26514e21 }, | ||
259 | { XFER_MW_DMA_1, 0x26514e33 }, | ||
260 | { XFER_MW_DMA_0, 0x26514e97 }, | ||
261 | |||
262 | { XFER_PIO_4, 0x06514e21 }, | ||
263 | { XFER_PIO_3, 0x06514e22 }, | ||
264 | { XFER_PIO_2, 0x06514e33 }, | ||
265 | { XFER_PIO_1, 0x06914e43 }, | ||
266 | { XFER_PIO_0, 0x06914e57 }, | ||
267 | { 0, 0x06514e57 } | ||
268 | }; | ||
269 | |||
270 | /* these are the current (4 sep 2001) timings from highpoint */ | ||
271 | static struct chipset_bus_clock_list_entry thirty_three_base_hpt370a[] = { | ||
272 | { XFER_UDMA_5, 0x12446231 }, | ||
273 | { XFER_UDMA_4, 0x12446231 }, | ||
274 | { XFER_UDMA_3, 0x126c6231 }, | ||
275 | { XFER_UDMA_2, 0x12486231 }, | ||
276 | { XFER_UDMA_1, 0x124c6233 }, | ||
277 | { XFER_UDMA_0, 0x12506297 }, | ||
278 | |||
279 | { XFER_MW_DMA_2, 0x22406c31 }, | ||
280 | { XFER_MW_DMA_1, 0x22406c33 }, | ||
281 | { XFER_MW_DMA_0, 0x22406c97 }, | ||
282 | |||
283 | { XFER_PIO_4, 0x06414e31 }, | ||
284 | { XFER_PIO_3, 0x06414e42 }, | ||
285 | { XFER_PIO_2, 0x06414e53 }, | ||
286 | { XFER_PIO_1, 0x06814e93 }, | ||
287 | { XFER_PIO_0, 0x06814ea7 }, | ||
288 | { 0, 0x06814ea7 } | ||
289 | }; | ||
290 | |||
291 | /* 2x 33MHz timings */ | ||
292 | static struct chipset_bus_clock_list_entry sixty_six_base_hpt370a[] = { | ||
293 | { XFER_UDMA_5, 0x1488e673 }, | ||
294 | { XFER_UDMA_4, 0x1488e673 }, | ||
295 | { XFER_UDMA_3, 0x1498e673 }, | ||
296 | { XFER_UDMA_2, 0x1490e673 }, | ||
297 | { XFER_UDMA_1, 0x1498e677 }, | ||
298 | { XFER_UDMA_0, 0x14a0e73f }, | ||
299 | |||
300 | { XFER_MW_DMA_2, 0x2480fa73 }, | ||
301 | { XFER_MW_DMA_1, 0x2480fa77 }, | ||
302 | { XFER_MW_DMA_0, 0x2480fb3f }, | ||
303 | |||
304 | { XFER_PIO_4, 0x0c82be73 }, | ||
305 | { XFER_PIO_3, 0x0c82be95 }, | ||
306 | { XFER_PIO_2, 0x0c82beb7 }, | ||
307 | { XFER_PIO_1, 0x0d02bf37 }, | ||
308 | { XFER_PIO_0, 0x0d02bf5f }, | ||
309 | { 0, 0x0d02bf5f } | ||
310 | }; | ||
311 | 213 | ||
312 | static struct chipset_bus_clock_list_entry fifty_base_hpt370a[] = { | 214 | static u32 forty_base_hpt36x[] = { |
313 | { XFER_UDMA_5, 0x12848242 }, | 215 | /* XFER_UDMA_6 */ 0x900fd943, |
314 | { XFER_UDMA_4, 0x12ac8242 }, | 216 | /* XFER_UDMA_5 */ 0x900fd943, |
315 | { XFER_UDMA_3, 0x128c8242 }, | 217 | /* XFER_UDMA_4 */ 0x900fd943, |
316 | { XFER_UDMA_2, 0x120c8242 }, | 218 | /* XFER_UDMA_3 */ 0x900ad943, |
317 | { XFER_UDMA_1, 0x12148254 }, | 219 | /* XFER_UDMA_2 */ 0x900bd943, |
318 | { XFER_UDMA_0, 0x121882ea }, | 220 | /* XFER_UDMA_1 */ 0x9008d943, |
319 | 221 | /* XFER_UDMA_0 */ 0x9008d943, | |
320 | { XFER_MW_DMA_2, 0x22808242 }, | 222 | |
321 | { XFER_MW_DMA_1, 0x22808254 }, | 223 | /* XFER_MW_DMA_2 */ 0xa008d943, |
322 | { XFER_MW_DMA_0, 0x228082ea }, | 224 | /* XFER_MW_DMA_1 */ 0xa010d955, |
323 | 225 | /* XFER_MW_DMA_0 */ 0xa010d9fc, | |
324 | { XFER_PIO_4, 0x0a81f442 }, | 226 | |
325 | { XFER_PIO_3, 0x0a81f443 }, | 227 | /* XFER_PIO_4 */ 0xc008d963, |
326 | { XFER_PIO_2, 0x0a81f454 }, | 228 | /* XFER_PIO_3 */ 0xc010d974, |
327 | { XFER_PIO_1, 0x0ac1f465 }, | 229 | /* XFER_PIO_2 */ 0xc010d997, |
328 | { XFER_PIO_0, 0x0ac1f48a }, | 230 | /* XFER_PIO_1 */ 0xc010d9c7, |
329 | { 0, 0x0ac1f48a } | 231 | /* XFER_PIO_0 */ 0xc018d9d9 |
330 | }; | 232 | }; |
331 | 233 | ||
332 | static struct chipset_bus_clock_list_entry thirty_three_base_hpt372[] = { | 234 | static u32 thirty_three_base_hpt36x[] = { |
333 | { XFER_UDMA_6, 0x1c81dc62 }, | 235 | /* XFER_UDMA_6 */ 0x90c9a731, |
334 | { XFER_UDMA_5, 0x1c6ddc62 }, | 236 | /* XFER_UDMA_5 */ 0x90c9a731, |
335 | { XFER_UDMA_4, 0x1c8ddc62 }, | 237 | /* XFER_UDMA_4 */ 0x90c9a731, |
336 | { XFER_UDMA_3, 0x1c8edc62 }, /* checkme */ | 238 | /* XFER_UDMA_3 */ 0x90cfa731, |
337 | { XFER_UDMA_2, 0x1c91dc62 }, | 239 | /* XFER_UDMA_2 */ 0x90caa731, |
338 | { XFER_UDMA_1, 0x1c9adc62 }, /* checkme */ | 240 | /* XFER_UDMA_1 */ 0x90cba731, |
339 | { XFER_UDMA_0, 0x1c82dc62 }, /* checkme */ | 241 | /* XFER_UDMA_0 */ 0x90c8a731, |
340 | 242 | ||
341 | { XFER_MW_DMA_2, 0x2c829262 }, | 243 | /* XFER_MW_DMA_2 */ 0xa0c8a731, |
342 | { XFER_MW_DMA_1, 0x2c829266 }, /* checkme */ | 244 | /* XFER_MW_DMA_1 */ 0xa0c8a732, /* 0xa0c8a733 */ |
343 | { XFER_MW_DMA_0, 0x2c82922e }, /* checkme */ | 245 | /* XFER_MW_DMA_0 */ 0xa0c8a797, |
344 | 246 | ||
345 | { XFER_PIO_4, 0x0c829c62 }, | 247 | /* XFER_PIO_4 */ 0xc0c8a731, |
346 | { XFER_PIO_3, 0x0c829c84 }, | 248 | /* XFER_PIO_3 */ 0xc0c8a742, |
347 | { XFER_PIO_2, 0x0c829ca6 }, | 249 | /* XFER_PIO_2 */ 0xc0d0a753, |
348 | { XFER_PIO_1, 0x0d029d26 }, | 250 | /* XFER_PIO_1 */ 0xc0d0a7a3, /* 0xc0d0a793 */ |
349 | { XFER_PIO_0, 0x0d029d5e }, | 251 | /* XFER_PIO_0 */ 0xc0d0a7aa /* 0xc0d0a7a7 */ |
350 | { 0, 0x0d029d5e } | ||
351 | }; | 252 | }; |
352 | 253 | ||
353 | static struct chipset_bus_clock_list_entry fifty_base_hpt372[] = { | 254 | static u32 twenty_five_base_hpt36x[] = { |
354 | { XFER_UDMA_5, 0x12848242 }, | 255 | /* XFER_UDMA_6 */ 0x90c98521, |
355 | { XFER_UDMA_4, 0x12ac8242 }, | 256 | /* XFER_UDMA_5 */ 0x90c98521, |
356 | { XFER_UDMA_3, 0x128c8242 }, | 257 | /* XFER_UDMA_4 */ 0x90c98521, |
357 | { XFER_UDMA_2, 0x120c8242 }, | 258 | /* XFER_UDMA_3 */ 0x90cf8521, |
358 | { XFER_UDMA_1, 0x12148254 }, | 259 | /* XFER_UDMA_2 */ 0x90cf8521, |
359 | { XFER_UDMA_0, 0x121882ea }, | 260 | /* XFER_UDMA_1 */ 0x90cb8521, |
360 | 261 | /* XFER_UDMA_0 */ 0x90cb8521, | |
361 | { XFER_MW_DMA_2, 0x22808242 }, | 262 | |
362 | { XFER_MW_DMA_1, 0x22808254 }, | 263 | /* XFER_MW_DMA_2 */ 0xa0ca8521, |
363 | { XFER_MW_DMA_0, 0x228082ea }, | 264 | /* XFER_MW_DMA_1 */ 0xa0ca8532, |
364 | 265 | /* XFER_MW_DMA_0 */ 0xa0ca8575, | |
365 | { XFER_PIO_4, 0x0a81f442 }, | 266 | |
366 | { XFER_PIO_3, 0x0a81f443 }, | 267 | /* XFER_PIO_4 */ 0xc0ca8521, |
367 | { XFER_PIO_2, 0x0a81f454 }, | 268 | /* XFER_PIO_3 */ 0xc0ca8532, |
368 | { XFER_PIO_1, 0x0ac1f465 }, | 269 | /* XFER_PIO_2 */ 0xc0ca8542, |
369 | { XFER_PIO_0, 0x0ac1f48a }, | 270 | /* XFER_PIO_1 */ 0xc0d08572, |
370 | { 0, 0x0a81f443 } | 271 | /* XFER_PIO_0 */ 0xc0d08585 |
371 | }; | 272 | }; |
372 | 273 | ||
373 | static struct chipset_bus_clock_list_entry sixty_six_base_hpt372[] = { | 274 | static u32 thirty_three_base_hpt37x[] = { |
374 | { XFER_UDMA_6, 0x1c869c62 }, | 275 | /* XFER_UDMA_6 */ 0x12446231, /* 0x12646231 ?? */ |
375 | { XFER_UDMA_5, 0x1cae9c62 }, | 276 | /* XFER_UDMA_5 */ 0x12446231, |
376 | { XFER_UDMA_4, 0x1c8a9c62 }, | 277 | /* XFER_UDMA_4 */ 0x12446231, |
377 | { XFER_UDMA_3, 0x1c8e9c62 }, | 278 | /* XFER_UDMA_3 */ 0x126c6231, |
378 | { XFER_UDMA_2, 0x1c929c62 }, | 279 | /* XFER_UDMA_2 */ 0x12486231, |
379 | { XFER_UDMA_1, 0x1c9a9c62 }, | 280 | /* XFER_UDMA_1 */ 0x124c6233, |
380 | { XFER_UDMA_0, 0x1c829c62 }, | 281 | /* XFER_UDMA_0 */ 0x12506297, |
381 | 282 | ||
382 | { XFER_MW_DMA_2, 0x2c829c62 }, | 283 | /* XFER_MW_DMA_2 */ 0x22406c31, |
383 | { XFER_MW_DMA_1, 0x2c829c66 }, | 284 | /* XFER_MW_DMA_1 */ 0x22406c33, |
384 | { XFER_MW_DMA_0, 0x2c829d2e }, | 285 | /* XFER_MW_DMA_0 */ 0x22406c97, |
385 | 286 | ||
386 | { XFER_PIO_4, 0x0c829c62 }, | 287 | /* XFER_PIO_4 */ 0x06414e31, |
387 | { XFER_PIO_3, 0x0c829c84 }, | 288 | /* XFER_PIO_3 */ 0x06414e42, |
388 | { XFER_PIO_2, 0x0c829ca6 }, | 289 | /* XFER_PIO_2 */ 0x06414e53, |
389 | { XFER_PIO_1, 0x0d029d26 }, | 290 | /* XFER_PIO_1 */ 0x06814e93, |
390 | { XFER_PIO_0, 0x0d029d5e }, | 291 | /* XFER_PIO_0 */ 0x06814ea7 |
391 | { 0, 0x0d029d26 } | ||
392 | }; | 292 | }; |
393 | 293 | ||
394 | static struct chipset_bus_clock_list_entry thirty_three_base_hpt374[] = { | 294 | static u32 fifty_base_hpt37x[] = { |
395 | { XFER_UDMA_6, 0x12808242 }, | 295 | /* XFER_UDMA_6 */ 0x12848242, |
396 | { XFER_UDMA_5, 0x12848242 }, | 296 | /* XFER_UDMA_5 */ 0x12848242, |
397 | { XFER_UDMA_4, 0x12ac8242 }, | 297 | /* XFER_UDMA_4 */ 0x12ac8242, |
398 | { XFER_UDMA_3, 0x128c8242 }, | 298 | /* XFER_UDMA_3 */ 0x128c8242, |
399 | { XFER_UDMA_2, 0x120c8242 }, | 299 | /* XFER_UDMA_2 */ 0x120c8242, |
400 | { XFER_UDMA_1, 0x12148254 }, | 300 | /* XFER_UDMA_1 */ 0x12148254, |
401 | { XFER_UDMA_0, 0x121882ea }, | 301 | /* XFER_UDMA_0 */ 0x121882ea, |
402 | 302 | ||
403 | { XFER_MW_DMA_2, 0x22808242 }, | 303 | /* XFER_MW_DMA_2 */ 0x22808242, |
404 | { XFER_MW_DMA_1, 0x22808254 }, | 304 | /* XFER_MW_DMA_1 */ 0x22808254, |
405 | { XFER_MW_DMA_0, 0x228082ea }, | 305 | /* XFER_MW_DMA_0 */ 0x228082ea, |
406 | 306 | ||
407 | { XFER_PIO_4, 0x0a81f442 }, | 307 | /* XFER_PIO_4 */ 0x0a81f442, |
408 | { XFER_PIO_3, 0x0a81f443 }, | 308 | /* XFER_PIO_3 */ 0x0a81f443, |
409 | { XFER_PIO_2, 0x0a81f454 }, | 309 | /* XFER_PIO_2 */ 0x0a81f454, |
410 | { XFER_PIO_1, 0x0ac1f465 }, | 310 | /* XFER_PIO_1 */ 0x0ac1f465, |
411 | { XFER_PIO_0, 0x0ac1f48a }, | 311 | /* XFER_PIO_0 */ 0x0ac1f48a |
412 | { 0, 0x06814e93 } | ||
413 | }; | 312 | }; |
414 | 313 | ||
415 | /* FIXME: 50MHz timings for HPT374 */ | 314 | static u32 sixty_six_base_hpt37x[] = { |
416 | 315 | /* XFER_UDMA_6 */ 0x1c869c62, | |
417 | #if 0 | 316 | /* XFER_UDMA_5 */ 0x1cae9c62, /* 0x1c8a9c62 */ |
418 | static struct chipset_bus_clock_list_entry sixty_six_base_hpt374[] = { | 317 | /* XFER_UDMA_4 */ 0x1c8a9c62, |
419 | { XFER_UDMA_6, 0x12406231 }, /* checkme */ | 318 | /* XFER_UDMA_3 */ 0x1c8e9c62, |
420 | { XFER_UDMA_5, 0x12446231 }, /* 0x14846231 */ | 319 | /* XFER_UDMA_2 */ 0x1c929c62, |
421 | { XFER_UDMA_4, 0x16814ea7 }, /* 0x14886231 */ | 320 | /* XFER_UDMA_1 */ 0x1c9a9c62, |
422 | { XFER_UDMA_3, 0x16814ea7 }, /* 0x148c6231 */ | 321 | /* XFER_UDMA_0 */ 0x1c829c62, |
423 | { XFER_UDMA_2, 0x16814ea7 }, /* 0x148c6231 */ | 322 | |
424 | { XFER_UDMA_1, 0x16814ea7 }, /* 0x14906231 */ | 323 | /* XFER_MW_DMA_2 */ 0x2c829c62, |
425 | { XFER_UDMA_0, 0x16814ea7 }, /* 0x14986231 */ | 324 | /* XFER_MW_DMA_1 */ 0x2c829c66, |
426 | { XFER_MW_DMA_2, 0x16814ea7 }, /* 0x26514e21 */ | 325 | /* XFER_MW_DMA_0 */ 0x2c829d2e, |
427 | { XFER_MW_DMA_1, 0x16814ea7 }, /* 0x26514e97 */ | 326 | |
428 | { XFER_MW_DMA_0, 0x16814ea7 }, /* 0x26514e97 */ | 327 | /* XFER_PIO_4 */ 0x0c829c62, |
429 | { XFER_PIO_4, 0x06814ea7 }, /* 0x06514e21 */ | 328 | /* XFER_PIO_3 */ 0x0c829c84, |
430 | { XFER_PIO_3, 0x06814ea7 }, /* 0x06514e22 */ | 329 | /* XFER_PIO_2 */ 0x0c829ca6, |
431 | { XFER_PIO_2, 0x06814ea7 }, /* 0x06514e33 */ | 330 | /* XFER_PIO_1 */ 0x0d029d26, |
432 | { XFER_PIO_1, 0x06814ea7 }, /* 0x06914e43 */ | 331 | /* XFER_PIO_0 */ 0x0d029d5e |
433 | { XFER_PIO_0, 0x06814ea7 }, /* 0x06914e57 */ | ||
434 | { 0, 0x06814ea7 } | ||
435 | }; | 332 | }; |
436 | #endif | ||
437 | 333 | ||
438 | #define HPT366_DEBUG_DRIVE_INFO 0 | 334 | #define HPT366_DEBUG_DRIVE_INFO 0 |
439 | #define HPT374_ALLOW_ATA133_6 0 | 335 | #define HPT374_ALLOW_ATA133_6 0 |
440 | #define HPT371_ALLOW_ATA133_6 0 | 336 | #define HPT371_ALLOW_ATA133_6 0 |
441 | #define HPT302_ALLOW_ATA133_6 0 | 337 | #define HPT302_ALLOW_ATA133_6 0 |
442 | #define HPT372_ALLOW_ATA133_6 1 | 338 | #define HPT372_ALLOW_ATA133_6 0 |
443 | #define HPT370_ALLOW_ATA100_5 1 | 339 | #define HPT370_ALLOW_ATA100_5 1 |
444 | #define HPT366_ALLOW_ATA66_4 1 | 340 | #define HPT366_ALLOW_ATA66_4 1 |
445 | #define HPT366_ALLOW_ATA66_3 1 | 341 | #define HPT366_ALLOW_ATA66_3 1 |
@@ -461,9 +357,10 @@ struct hpt_info | |||
461 | int revision; /* Chipset revision */ | 357 | int revision; /* Chipset revision */ |
462 | int flags; /* Chipset properties */ | 358 | int flags; /* Chipset properties */ |
463 | #define PLL_MODE 1 | 359 | #define PLL_MODE 1 |
464 | #define IS_372N 2 | 360 | #define IS_3xxN 2 |
361 | #define PCI_66MHZ 4 | ||
465 | /* Speed table */ | 362 | /* Speed table */ |
466 | struct chipset_bus_clock_list_entry *speed; | 363 | u32 *speed; |
467 | }; | 364 | }; |
468 | 365 | ||
469 | /* | 366 | /* |
@@ -600,12 +497,20 @@ static int check_in_drive_lists (ide_drive_t *drive, const char **list) | |||
600 | return 0; | 497 | return 0; |
601 | } | 498 | } |
602 | 499 | ||
603 | static unsigned int pci_bus_clock_list (u8 speed, struct chipset_bus_clock_list_entry * chipset_table) | 500 | static u32 pci_bus_clock_list(u8 speed, u32 *chipset_table) |
604 | { | 501 | { |
605 | for ( ; chipset_table->xfer_speed ; chipset_table++) | 502 | int i; |
606 | if (chipset_table->xfer_speed == speed) | 503 | |
607 | return chipset_table->chipset_settings; | 504 | /* |
608 | return chipset_table->chipset_settings; | 505 | * Lookup the transfer mode table to get the index into |
506 | * the timing table. | ||
507 | * | ||
508 | * NOTE: For XFER_PIO_SLOW, PIO mode 0 timings will be used. | ||
509 | */ | ||
510 | for (i = 0; i < ARRAY_SIZE(xfer_speeds) - 1; i++) | ||
511 | if (xfer_speeds[i] == speed) | ||
512 | break; | ||
513 | return chipset_table[i]; | ||
609 | } | 514 | } |
610 | 515 | ||
611 | static int hpt36x_tune_chipset(ide_drive_t *drive, u8 xferspeed) | 516 | static int hpt36x_tune_chipset(ide_drive_t *drive, u8 xferspeed) |
@@ -956,156 +861,127 @@ static int hpt374_ide_dma_end (ide_drive_t *drive) | |||
956 | } | 861 | } |
957 | 862 | ||
958 | /** | 863 | /** |
959 | * hpt372n_set_clock - perform clock switching dance | 864 | * hpt3xxn_set_clock - perform clock switching dance |
960 | * @drive: Drive to switch | 865 | * @hwif: hwif to switch |
961 | * @mode: Switching mode (0x21 for write, 0x23 otherwise) | 866 | * @mode: clocking mode (0x21 for write, 0x23 otherwise) |
962 | * | 867 | * |
963 | * Switch the DPLL clock on the HPT372N devices. This is a | 868 | * Switch the DPLL clock on the HPT3xxN devices. This is a right mess. |
964 | * right mess. | 869 | * NOTE: avoid touching the disabled primary channel on HPT371N -- it |
870 | * doesn't physically exist anyway... | ||
965 | */ | 871 | */ |
966 | 872 | ||
967 | static void hpt372n_set_clock(ide_drive_t *drive, int mode) | 873 | static void hpt3xxn_set_clock(ide_hwif_t *hwif, u8 mode) |
968 | { | 874 | { |
969 | ide_hwif_t *hwif = HWIF(drive); | 875 | u8 mcr1, scr2 = hwif->INB(hwif->dma_master + 0x7b); |
970 | 876 | ||
971 | /* FIXME: should we check for DMA active and BUG() */ | 877 | if ((scr2 & 0x7f) == mode) |
878 | return; | ||
879 | |||
880 | /* MISC. control register 1 has the channel enable bit... */ | ||
881 | mcr1 = hwif->INB(hwif->dma_master + 0x70); | ||
882 | |||
972 | /* Tristate the bus */ | 883 | /* Tristate the bus */ |
973 | outb(0x80, hwif->dma_base+0x73); | 884 | if (mcr1 & 0x04) |
974 | outb(0x80, hwif->dma_base+0x77); | 885 | hwif->OUTB(0x80, hwif->dma_master + 0x73); |
975 | 886 | hwif->OUTB(0x80, hwif->dma_master + 0x77); | |
887 | |||
976 | /* Switch clock and reset channels */ | 888 | /* Switch clock and reset channels */ |
977 | outb(mode, hwif->dma_base+0x7B); | 889 | hwif->OUTB(mode, hwif->dma_master + 0x7b); |
978 | outb(0xC0, hwif->dma_base+0x79); | 890 | hwif->OUTB(0xc0, hwif->dma_master + 0x79); |
979 | 891 | ||
980 | /* Reset state machines */ | 892 | /* Reset state machines */ |
981 | outb(0x37, hwif->dma_base+0x70); | 893 | if (mcr1 & 0x04) |
982 | outb(0x37, hwif->dma_base+0x74); | 894 | hwif->OUTB(0x37, hwif->dma_master + 0x70); |
983 | 895 | hwif->OUTB(0x37, hwif->dma_master + 0x74); | |
896 | |||
984 | /* Complete reset */ | 897 | /* Complete reset */ |
985 | outb(0x00, hwif->dma_base+0x79); | 898 | hwif->OUTB(0x00, hwif->dma_master + 0x79); |
986 | 899 | ||
987 | /* Reconnect channels to bus */ | 900 | /* Reconnect channels to bus */ |
988 | outb(0x00, hwif->dma_base+0x73); | 901 | if (mcr1 & 0x04) |
989 | outb(0x00, hwif->dma_base+0x77); | 902 | hwif->OUTB(0x00, hwif->dma_master + 0x73); |
903 | hwif->OUTB(0x00, hwif->dma_master + 0x77); | ||
990 | } | 904 | } |
991 | 905 | ||
992 | /** | 906 | /** |
993 | * hpt372n_rw_disk - prepare for I/O | 907 | * hpt3xxn_rw_disk - prepare for I/O |
994 | * @drive: drive for command | 908 | * @drive: drive for command |
995 | * @rq: block request structure | 909 | * @rq: block request structure |
996 | * | 910 | * |
997 | * This is called when a disk I/O is issued to the 372N. | 911 | * This is called when a disk I/O is issued to HPT3xxN. |
998 | * We need it because of the clock switching. | 912 | * We need it because of the clock switching. |
999 | */ | 913 | */ |
1000 | 914 | ||
1001 | static void hpt372n_rw_disk(ide_drive_t *drive, struct request *rq) | 915 | static void hpt3xxn_rw_disk(ide_drive_t *drive, struct request *rq) |
1002 | { | ||
1003 | ide_hwif_t *hwif = drive->hwif; | ||
1004 | int wantclock; | ||
1005 | |||
1006 | wantclock = rq_data_dir(rq) ? 0x23 : 0x21; | ||
1007 | |||
1008 | if (hwif->config_data != wantclock) { | ||
1009 | hpt372n_set_clock(drive, wantclock); | ||
1010 | hwif->config_data = wantclock; | ||
1011 | } | ||
1012 | } | ||
1013 | |||
1014 | /* | ||
1015 | * Since SUN Cobalt is attempting to do this operation, I should disclose | ||
1016 | * this has been a long time ago Thu Jul 27 16:40:57 2000 was the patch date | ||
1017 | * HOTSWAP ATA Infrastructure. | ||
1018 | */ | ||
1019 | |||
1020 | static void hpt3xx_reset (ide_drive_t *drive) | ||
1021 | { | ||
1022 | } | ||
1023 | |||
1024 | static int hpt3xx_tristate (ide_drive_t * drive, int state) | ||
1025 | { | 916 | { |
1026 | ide_hwif_t *hwif = HWIF(drive); | 917 | ide_hwif_t *hwif = HWIF(drive); |
1027 | struct pci_dev *dev = hwif->pci_dev; | 918 | u8 wantclock = rq_data_dir(rq) ? 0x23 : 0x21; |
1028 | u8 reg59h = 0, reset = (hwif->channel) ? 0x80 : 0x40; | ||
1029 | u8 regXXh = 0, state_reg= (hwif->channel) ? 0x57 : 0x53; | ||
1030 | |||
1031 | pci_read_config_byte(dev, 0x59, ®59h); | ||
1032 | pci_read_config_byte(dev, state_reg, ®XXh); | ||
1033 | 919 | ||
1034 | if (state) { | 920 | hpt3xxn_set_clock(hwif, wantclock); |
1035 | (void) ide_do_reset(drive); | ||
1036 | pci_write_config_byte(dev, state_reg, regXXh|0x80); | ||
1037 | pci_write_config_byte(dev, 0x59, reg59h|reset); | ||
1038 | } else { | ||
1039 | pci_write_config_byte(dev, 0x59, reg59h & ~(reset)); | ||
1040 | pci_write_config_byte(dev, state_reg, regXXh & ~(0x80)); | ||
1041 | (void) ide_do_reset(drive); | ||
1042 | } | ||
1043 | return 0; | ||
1044 | } | 921 | } |
1045 | 922 | ||
1046 | /* | 923 | /* |
1047 | * set/get power state for a drive. | 924 | * Set/get power state for a drive. |
1048 | * turning the power off does the following things: | ||
1049 | * 1) soft-reset the drive | ||
1050 | * 2) tri-states the ide bus | ||
1051 | * | 925 | * |
1052 | * when we turn things back on, we need to re-initialize things. | 926 | * When we turn the power back on, we need to re-initialize things. |
1053 | */ | 927 | */ |
1054 | #define TRISTATE_BIT 0x8000 | 928 | #define TRISTATE_BIT 0x8000 |
1055 | static int hpt370_busproc(ide_drive_t * drive, int state) | 929 | |
930 | static int hpt3xx_busproc(ide_drive_t *drive, int state) | ||
1056 | { | 931 | { |
1057 | ide_hwif_t *hwif = drive->hwif; | 932 | ide_hwif_t *hwif = drive->hwif; |
1058 | struct pci_dev *dev = hwif->pci_dev; | 933 | struct pci_dev *dev = hwif->pci_dev; |
1059 | u8 tristate = 0, resetmask = 0, bus_reg = 0; | 934 | u8 tristate, resetmask, bus_reg = 0; |
1060 | u16 tri_reg; | 935 | u16 tri_reg = 0; |
1061 | 936 | ||
1062 | hwif->bus_state = state; | 937 | hwif->bus_state = state; |
1063 | 938 | ||
1064 | if (hwif->channel) { | 939 | if (hwif->channel) { |
1065 | /* secondary channel */ | 940 | /* secondary channel */ |
1066 | tristate = 0x56; | 941 | tristate = 0x56; |
1067 | resetmask = 0x80; | 942 | resetmask = 0x80; |
1068 | } else { | 943 | } else { |
1069 | /* primary channel */ | 944 | /* primary channel */ |
1070 | tristate = 0x52; | 945 | tristate = 0x52; |
1071 | resetmask = 0x40; | 946 | resetmask = 0x40; |
1072 | } | 947 | } |
1073 | 948 | ||
1074 | /* grab status */ | 949 | /* Grab the status. */ |
1075 | pci_read_config_word(dev, tristate, &tri_reg); | 950 | pci_read_config_word(dev, tristate, &tri_reg); |
1076 | pci_read_config_byte(dev, 0x59, &bus_reg); | 951 | pci_read_config_byte(dev, 0x59, &bus_reg); |
1077 | 952 | ||
1078 | /* set the state. we don't set it if we don't need to do so. | 953 | /* |
1079 | * make sure that the drive knows that it has failed if it's off */ | 954 | * Set the state. We don't set it if we don't need to do so. |
955 | * Make sure that the drive knows that it has failed if it's off. | ||
956 | */ | ||
1080 | switch (state) { | 957 | switch (state) { |
1081 | case BUSSTATE_ON: | 958 | case BUSSTATE_ON: |
1082 | hwif->drives[0].failures = 0; | 959 | if (!(bus_reg & resetmask)) |
1083 | hwif->drives[1].failures = 0; | ||
1084 | if ((bus_reg & resetmask) == 0) | ||
1085 | return 0; | 960 | return 0; |
1086 | tri_reg &= ~TRISTATE_BIT; | 961 | hwif->drives[0].failures = hwif->drives[1].failures = 0; |
1087 | bus_reg &= ~resetmask; | 962 | |
1088 | break; | 963 | pci_write_config_byte(dev, 0x59, bus_reg & ~resetmask); |
964 | pci_write_config_word(dev, tristate, tri_reg & ~TRISTATE_BIT); | ||
965 | return 0; | ||
1089 | case BUSSTATE_OFF: | 966 | case BUSSTATE_OFF: |
1090 | hwif->drives[0].failures = hwif->drives[0].max_failures + 1; | 967 | if ((bus_reg & resetmask) && !(tri_reg & TRISTATE_BIT)) |
1091 | hwif->drives[1].failures = hwif->drives[1].max_failures + 1; | ||
1092 | if ((tri_reg & TRISTATE_BIT) == 0 && (bus_reg & resetmask)) | ||
1093 | return 0; | 968 | return 0; |
1094 | tri_reg &= ~TRISTATE_BIT; | 969 | tri_reg &= ~TRISTATE_BIT; |
1095 | bus_reg |= resetmask; | ||
1096 | break; | 970 | break; |
1097 | case BUSSTATE_TRISTATE: | 971 | case BUSSTATE_TRISTATE: |
1098 | hwif->drives[0].failures = hwif->drives[0].max_failures + 1; | 972 | if ((bus_reg & resetmask) && (tri_reg & TRISTATE_BIT)) |
1099 | hwif->drives[1].failures = hwif->drives[1].max_failures + 1; | ||
1100 | if ((tri_reg & TRISTATE_BIT) && (bus_reg & resetmask)) | ||
1101 | return 0; | 973 | return 0; |
1102 | tri_reg |= TRISTATE_BIT; | 974 | tri_reg |= TRISTATE_BIT; |
1103 | bus_reg |= resetmask; | ||
1104 | break; | 975 | break; |
976 | default: | ||
977 | return -EINVAL; | ||
1105 | } | 978 | } |
1106 | pci_write_config_byte(dev, 0x59, bus_reg); | ||
1107 | pci_write_config_word(dev, tristate, tri_reg); | ||
1108 | 979 | ||
980 | hwif->drives[0].failures = hwif->drives[0].max_failures + 1; | ||
981 | hwif->drives[1].failures = hwif->drives[1].max_failures + 1; | ||
982 | |||
983 | pci_write_config_word(dev, tristate, tri_reg); | ||
984 | pci_write_config_byte(dev, 0x59, bus_reg | resetmask); | ||
1109 | return 0; | 985 | return 0; |
1110 | } | 986 | } |
1111 | 987 | ||
@@ -1119,14 +995,14 @@ static void __devinit hpt366_clocking(ide_hwif_t *hwif) | |||
1119 | /* detect bus speed by looking at control reg timing: */ | 995 | /* detect bus speed by looking at control reg timing: */ |
1120 | switch((reg1 >> 8) & 7) { | 996 | switch((reg1 >> 8) & 7) { |
1121 | case 5: | 997 | case 5: |
1122 | info->speed = forty_base_hpt366; | 998 | info->speed = forty_base_hpt36x; |
1123 | break; | 999 | break; |
1124 | case 9: | 1000 | case 9: |
1125 | info->speed = twenty_five_base_hpt366; | 1001 | info->speed = twenty_five_base_hpt36x; |
1126 | break; | 1002 | break; |
1127 | case 7: | 1003 | case 7: |
1128 | default: | 1004 | default: |
1129 | info->speed = thirty_three_base_hpt366; | 1005 | info->speed = thirty_three_base_hpt36x; |
1130 | break; | 1006 | break; |
1131 | } | 1007 | } |
1132 | } | 1008 | } |
@@ -1136,9 +1012,9 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif) | |||
1136 | struct hpt_info *info = ide_get_hwifdata(hwif); | 1012 | struct hpt_info *info = ide_get_hwifdata(hwif); |
1137 | struct pci_dev *dev = hwif->pci_dev; | 1013 | struct pci_dev *dev = hwif->pci_dev; |
1138 | int adjust, i; | 1014 | int adjust, i; |
1139 | u16 freq; | 1015 | u16 freq = 0; |
1140 | u32 pll; | 1016 | u32 pll, temp = 0; |
1141 | u8 reg5bh; | 1017 | u8 reg5bh = 0, mcr1 = 0; |
1142 | 1018 | ||
1143 | /* | 1019 | /* |
1144 | * default to pci clock. make sure MA15/16 are set to output | 1020 | * default to pci clock. make sure MA15/16 are set to output |
@@ -1151,27 +1027,40 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif) | |||
1151 | pci_write_config_byte(dev, 0x5b, 0x23); | 1027 | pci_write_config_byte(dev, 0x5b, 0x23); |
1152 | 1028 | ||
1153 | /* | 1029 | /* |
1154 | * set up the PLL. we need to adjust it so that it's stable. | 1030 | * We'll have to read f_CNT value in order to determine |
1155 | * freq = Tpll * 192 / Tpci | 1031 | * the PCI clock frequency according to the following ratio: |
1032 | * | ||
1033 | * f_CNT = Fpci * 192 / Fdpll | ||
1034 | * | ||
1035 | * First try reading the register in which the HighPoint BIOS | ||
1036 | * saves f_CNT value before reprogramming the DPLL from its | ||
1037 | * default setting (which differs for the various chips). | ||
1038 | * NOTE: This register is only accessible via I/O space. | ||
1156 | * | 1039 | * |
1157 | * Todo. For non x86 should probably check the dword is | 1040 | * In case the signature check fails, we'll have to resort to |
1158 | * set to 0xABCDExxx indicating the BIOS saved f_CNT | 1041 | * reading the f_CNT register itself in hopes that nobody has |
1042 | * touched the DPLL yet... | ||
1159 | */ | 1043 | */ |
1160 | pci_read_config_word(dev, 0x78, &freq); | 1044 | temp = inl(pci_resource_start(dev, 4) + 0x90); |
1161 | freq &= 0x1FF; | 1045 | if ((temp & 0xFFFFF000) != 0xABCDE000) { |
1162 | 1046 | printk(KERN_WARNING "HPT37X: no clock data saved by BIOS\n"); | |
1047 | |||
1048 | /* Calculate the average value of f_CNT */ | ||
1049 | for (temp = i = 0; i < 128; i++) { | ||
1050 | pci_read_config_word(dev, 0x78, &freq); | ||
1051 | temp += freq & 0x1ff; | ||
1052 | mdelay(1); | ||
1053 | } | ||
1054 | freq = temp / 128; | ||
1055 | } else | ||
1056 | freq = temp & 0x1ff; | ||
1057 | |||
1163 | /* | 1058 | /* |
1164 | * The 372N uses different PCI clock information and has | 1059 | * HPT3xxN chips use different PCI clock information. |
1165 | * some other complications | 1060 | * Currently we always set up the PLL for them. |
1166 | * On PCI33 timing we must clock switch | ||
1167 | * On PCI66 timing we must NOT use the PCI clock | ||
1168 | * | ||
1169 | * Currently we always set up the PLL for the 372N | ||
1170 | */ | 1061 | */ |
1171 | 1062 | ||
1172 | if(info->flags & IS_372N) | 1063 | if (info->flags & IS_3xxN) { |
1173 | { | ||
1174 | printk(KERN_INFO "hpt: HPT372N detected, using 372N timing.\n"); | ||
1175 | if(freq < 0x55) | 1064 | if(freq < 0x55) |
1176 | pll = F_LOW_PCI_33; | 1065 | pll = F_LOW_PCI_33; |
1177 | else if(freq < 0x70) | 1066 | else if(freq < 0x70) |
@@ -1180,10 +1069,8 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif) | |||
1180 | pll = F_LOW_PCI_50; | 1069 | pll = F_LOW_PCI_50; |
1181 | else | 1070 | else |
1182 | pll = F_LOW_PCI_66; | 1071 | pll = F_LOW_PCI_66; |
1183 | 1072 | ||
1184 | printk(KERN_INFO "FREQ: %d PLL: %d\n", freq, pll); | 1073 | printk(KERN_INFO "HPT3xxN detected, FREQ: %d, PLL: %d\n", freq, pll); |
1185 | |||
1186 | /* We always use the pll not the PCI clock on 372N */ | ||
1187 | } | 1074 | } |
1188 | else | 1075 | else |
1189 | { | 1076 | { |
@@ -1197,41 +1084,22 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif) | |||
1197 | pll = F_LOW_PCI_66; | 1084 | pll = F_LOW_PCI_66; |
1198 | 1085 | ||
1199 | if (pll == F_LOW_PCI_33) { | 1086 | if (pll == F_LOW_PCI_33) { |
1200 | if (info->revision >= 8) | 1087 | info->speed = thirty_three_base_hpt37x; |
1201 | info->speed = thirty_three_base_hpt374; | ||
1202 | else if (info->revision >= 5) | ||
1203 | info->speed = thirty_three_base_hpt372; | ||
1204 | else if (info->revision >= 4) | ||
1205 | info->speed = thirty_three_base_hpt370a; | ||
1206 | else | ||
1207 | info->speed = thirty_three_base_hpt370; | ||
1208 | printk(KERN_DEBUG "HPT37X: using 33MHz PCI clock\n"); | 1088 | printk(KERN_DEBUG "HPT37X: using 33MHz PCI clock\n"); |
1209 | } else if (pll == F_LOW_PCI_40) { | 1089 | } else if (pll == F_LOW_PCI_40) { |
1210 | /* Unsupported */ | 1090 | /* Unsupported */ |
1211 | } else if (pll == F_LOW_PCI_50) { | 1091 | } else if (pll == F_LOW_PCI_50) { |
1212 | if (info->revision >= 8) | 1092 | info->speed = fifty_base_hpt37x; |
1213 | info->speed = fifty_base_hpt370a; | ||
1214 | else if (info->revision >= 5) | ||
1215 | info->speed = fifty_base_hpt372; | ||
1216 | else if (info->revision >= 4) | ||
1217 | info->speed = fifty_base_hpt370a; | ||
1218 | else | ||
1219 | info->speed = fifty_base_hpt370a; | ||
1220 | printk(KERN_DEBUG "HPT37X: using 50MHz PCI clock\n"); | 1093 | printk(KERN_DEBUG "HPT37X: using 50MHz PCI clock\n"); |
1221 | } else { | 1094 | } else { |
1222 | if (info->revision >= 8) { | 1095 | info->speed = sixty_six_base_hpt37x; |
1223 | printk(KERN_ERR "HPT37x: 66MHz timings are not supported.\n"); | ||
1224 | } | ||
1225 | else if (info->revision >= 5) | ||
1226 | info->speed = sixty_six_base_hpt372; | ||
1227 | else if (info->revision >= 4) | ||
1228 | info->speed = sixty_six_base_hpt370a; | ||
1229 | else | ||
1230 | info->speed = sixty_six_base_hpt370; | ||
1231 | printk(KERN_DEBUG "HPT37X: using 66MHz PCI clock\n"); | 1096 | printk(KERN_DEBUG "HPT37X: using 66MHz PCI clock\n"); |
1232 | } | 1097 | } |
1233 | } | 1098 | } |
1234 | 1099 | ||
1100 | if (pll == F_LOW_PCI_66) | ||
1101 | info->flags |= PCI_66MHZ; | ||
1102 | |||
1235 | /* | 1103 | /* |
1236 | * only try the pll if we don't have a table for the clock | 1104 | * only try the pll if we don't have a table for the clock |
1237 | * speed that we're running at. NOTE: the internal PLL will | 1105 | * speed that we're running at. NOTE: the internal PLL will |
@@ -1248,11 +1116,8 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif) | |||
1248 | info->flags |= PLL_MODE; | 1116 | info->flags |= PLL_MODE; |
1249 | 1117 | ||
1250 | /* | 1118 | /* |
1251 | * FIXME: make this work correctly, esp with 372N as per | 1119 | * Adjust the PLL based upon the PCI clock, enable it, and |
1252 | * reference driver code. | 1120 | * wait for stabilization... |
1253 | * | ||
1254 | * adjust PLL based upon PCI clock, enable it, and wait for | ||
1255 | * stabilization. | ||
1256 | */ | 1121 | */ |
1257 | adjust = 0; | 1122 | adjust = 0; |
1258 | freq = (pll < F_LOW_PCI_50) ? 2 : 4; | 1123 | freq = (pll < F_LOW_PCI_50) ? 2 : 4; |
@@ -1275,22 +1140,12 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif) | |||
1275 | pci_write_config_dword(dev, 0x5c, | 1140 | pci_write_config_dword(dev, 0x5c, |
1276 | pll & ~0x100); | 1141 | pll & ~0x100); |
1277 | pci_write_config_byte(dev, 0x5b, 0x21); | 1142 | pci_write_config_byte(dev, 0x5b, 0x21); |
1278 | if (info->revision >= 8) | 1143 | |
1279 | info->speed = fifty_base_hpt370a; | 1144 | info->speed = fifty_base_hpt37x; |
1280 | else if (info->revision >= 5) | ||
1281 | info->speed = fifty_base_hpt372; | ||
1282 | else if (info->revision >= 4) | ||
1283 | info->speed = fifty_base_hpt370a; | ||
1284 | else | ||
1285 | info->speed = fifty_base_hpt370a; | ||
1286 | printk("HPT37X: using 50MHz internal PLL\n"); | 1145 | printk("HPT37X: using 50MHz internal PLL\n"); |
1287 | goto init_hpt37X_done; | 1146 | goto init_hpt37X_done; |
1288 | } | 1147 | } |
1289 | } | 1148 | } |
1290 | if (!pci_get_drvdata(dev)) { | ||
1291 | printk("No Clock Stabilization!!!\n"); | ||
1292 | return; | ||
1293 | } | ||
1294 | pll_recal: | 1149 | pll_recal: |
1295 | if (adjust & 1) | 1150 | if (adjust & 1) |
1296 | pll -= (adjust >> 1); | 1151 | pll -= (adjust >> 1); |
@@ -1300,11 +1155,16 @@ pll_recal: | |||
1300 | 1155 | ||
1301 | init_hpt37X_done: | 1156 | init_hpt37X_done: |
1302 | if (!info->speed) | 1157 | if (!info->speed) |
1303 | printk(KERN_ERR "HPT37X%s: unknown bus timing [%d %d].\n", | 1158 | printk(KERN_ERR "HPT37x%s: unknown bus timing [%d %d].\n", |
1304 | (info->flags & IS_372N)?"N":"", pll, freq); | 1159 | (info->flags & IS_3xxN) ? "N" : "", pll, freq); |
1305 | /* reset state engine */ | 1160 | /* |
1306 | pci_write_config_byte(dev, 0x50, 0x37); | 1161 | * Reset the state engines. |
1307 | pci_write_config_byte(dev, 0x54, 0x37); | 1162 | * NOTE: avoid accidentally enabling the primary channel on HPT371N. |
1163 | */ | ||
1164 | pci_read_config_byte(dev, 0x50, &mcr1); | ||
1165 | if (mcr1 & 0x04) | ||
1166 | pci_write_config_byte(dev, 0x50, 0x37); | ||
1167 | pci_write_config_byte(dev, 0x54, 0x37); | ||
1308 | udelay(100); | 1168 | udelay(100); |
1309 | } | 1169 | } |
1310 | 1170 | ||
@@ -1367,6 +1227,7 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | |||
1367 | struct pci_dev *dev = hwif->pci_dev; | 1227 | struct pci_dev *dev = hwif->pci_dev; |
1368 | struct hpt_info *info = ide_get_hwifdata(hwif); | 1228 | struct hpt_info *info = ide_get_hwifdata(hwif); |
1369 | u8 ata66 = 0, regmask = (hwif->channel) ? 0x01 : 0x02; | 1229 | u8 ata66 = 0, regmask = (hwif->channel) ? 0x01 : 0x02; |
1230 | int serialize = HPT_SERIALIZE_IO; | ||
1370 | 1231 | ||
1371 | hwif->tuneproc = &hpt3xx_tune_drive; | 1232 | hwif->tuneproc = &hpt3xx_tune_drive; |
1372 | hwif->speedproc = &hpt3xx_tune_chipset; | 1233 | hwif->speedproc = &hpt3xx_tune_chipset; |
@@ -1374,8 +1235,20 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | |||
1374 | hwif->intrproc = &hpt3xx_intrproc; | 1235 | hwif->intrproc = &hpt3xx_intrproc; |
1375 | hwif->maskproc = &hpt3xx_maskproc; | 1236 | hwif->maskproc = &hpt3xx_maskproc; |
1376 | 1237 | ||
1377 | if(info->flags & IS_372N) | 1238 | /* |
1378 | hwif->rw_disk = &hpt372n_rw_disk; | 1239 | * HPT3xxN chips have some complications: |
1240 | * | ||
1241 | * - on 33 MHz PCI we must clock switch | ||
1242 | * - on 66 MHz PCI we must NOT use the PCI clock | ||
1243 | */ | ||
1244 | if ((info->flags & (IS_3xxN | PCI_66MHZ)) == IS_3xxN) { | ||
1245 | /* | ||
1246 | * Clock is shared between the channels, | ||
1247 | * so we'll have to serialize them... :-( | ||
1248 | */ | ||
1249 | serialize = 1; | ||
1250 | hwif->rw_disk = &hpt3xxn_rw_disk; | ||
1251 | } | ||
1379 | 1252 | ||
1380 | /* | 1253 | /* |
1381 | * The HPT37x uses the CBLID pins as outputs for MA15/MA16 | 1254 | * The HPT37x uses the CBLID pins as outputs for MA15/MA16 |
@@ -1418,29 +1291,15 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | |||
1418 | PCI_FUNC(hwif->pci_dev->devfn)); | 1291 | PCI_FUNC(hwif->pci_dev->devfn)); |
1419 | #endif /* DEBUG */ | 1292 | #endif /* DEBUG */ |
1420 | 1293 | ||
1421 | #ifdef HPT_SERIALIZE_IO | 1294 | /* Serialize access to this device */ |
1422 | /* serialize access to this device */ | 1295 | if (serialize && hwif->mate) |
1423 | if (hwif->mate) | ||
1424 | hwif->serialized = hwif->mate->serialized = 1; | 1296 | hwif->serialized = hwif->mate->serialized = 1; |
1425 | #endif | ||
1426 | 1297 | ||
1427 | if (info->revision >= 3) { | 1298 | /* |
1428 | u8 reg5ah = 0; | 1299 | * Set up ioctl for power status. |
1429 | pci_write_config_byte(dev, 0x5a, reg5ah & ~0x10); | 1300 | * NOTE: power affects both drives on each channel. |
1430 | /* | 1301 | */ |
1431 | * set up ioctl for power status. | 1302 | hwif->busproc = &hpt3xx_busproc; |
1432 | * note: power affects both | ||
1433 | * drives on each channel | ||
1434 | */ | ||
1435 | hwif->resetproc = &hpt3xx_reset; | ||
1436 | hwif->busproc = &hpt370_busproc; | ||
1437 | } else if (info->revision >= 2) { | ||
1438 | hwif->resetproc = &hpt3xx_reset; | ||
1439 | hwif->busproc = &hpt3xx_tristate; | ||
1440 | } else { | ||
1441 | hwif->resetproc = &hpt3xx_reset; | ||
1442 | hwif->busproc = &hpt3xx_tristate; | ||
1443 | } | ||
1444 | 1303 | ||
1445 | if (!hwif->dma_base) { | 1304 | if (!hwif->dma_base) { |
1446 | hwif->drives[0].autotune = 1; | 1305 | hwif->drives[0].autotune = 1; |
@@ -1490,7 +1349,7 @@ static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) | |||
1490 | return; | 1349 | return; |
1491 | 1350 | ||
1492 | if(info->speed == NULL) { | 1351 | if(info->speed == NULL) { |
1493 | printk(KERN_WARNING "hpt: no known IDE timings, disabling DMA.\n"); | 1352 | printk(KERN_WARNING "hpt366: no known IDE timings, disabling DMA.\n"); |
1494 | return; | 1353 | return; |
1495 | } | 1354 | } |
1496 | 1355 | ||
@@ -1519,9 +1378,10 @@ static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) | |||
1519 | 1378 | ||
1520 | static void __devinit init_iops_hpt366(ide_hwif_t *hwif) | 1379 | static void __devinit init_iops_hpt366(ide_hwif_t *hwif) |
1521 | { | 1380 | { |
1522 | struct hpt_info *info = kzalloc(sizeof(struct hpt_info), GFP_KERNEL); | 1381 | struct hpt_info *info = kzalloc(sizeof(struct hpt_info), GFP_KERNEL); |
1523 | unsigned long dmabase = pci_resource_start(hwif->pci_dev, 4); | 1382 | struct pci_dev *dev = hwif->pci_dev; |
1524 | u8 did, rid; | 1383 | u16 did = dev->device; |
1384 | u8 rid = 0; | ||
1525 | 1385 | ||
1526 | if(info == NULL) { | 1386 | if(info == NULL) { |
1527 | printk(KERN_WARNING "hpt366: out of memory.\n"); | 1387 | printk(KERN_WARNING "hpt366: out of memory.\n"); |
@@ -1529,15 +1389,22 @@ static void __devinit init_iops_hpt366(ide_hwif_t *hwif) | |||
1529 | } | 1389 | } |
1530 | ide_set_hwifdata(hwif, info); | 1390 | ide_set_hwifdata(hwif, info); |
1531 | 1391 | ||
1532 | if(dmabase) { | 1392 | /* Avoid doing the same thing twice. */ |
1533 | did = inb(dmabase + 0x22); | 1393 | if (hwif->channel && hwif->mate) { |
1534 | rid = inb(dmabase + 0x28); | 1394 | memcpy(info, ide_get_hwifdata(hwif->mate), sizeof(struct hpt_info)); |
1535 | 1395 | return; | |
1536 | if((did == 4 && rid == 6) || (did == 5 && rid > 1)) | ||
1537 | info->flags |= IS_372N; | ||
1538 | } | 1396 | } |
1539 | 1397 | ||
1540 | info->revision = hpt_revision(hwif->pci_dev); | 1398 | pci_read_config_byte(dev, PCI_CLASS_REVISION, &rid); |
1399 | |||
1400 | if (( did == PCI_DEVICE_ID_TTI_HPT366 && rid == 6) || | ||
1401 | ((did == PCI_DEVICE_ID_TTI_HPT372 || | ||
1402 | did == PCI_DEVICE_ID_TTI_HPT302 || | ||
1403 | did == PCI_DEVICE_ID_TTI_HPT371) && rid > 1) || | ||
1404 | did == PCI_DEVICE_ID_TTI_HPT372N) | ||
1405 | info->flags |= IS_3xxN; | ||
1406 | |||
1407 | info->revision = hpt_revision(dev); | ||
1541 | 1408 | ||
1542 | if (info->revision >= 3) | 1409 | if (info->revision >= 3) |
1543 | hpt37x_clocking(hwif); | 1410 | hpt37x_clocking(hwif); |
@@ -1574,6 +1441,23 @@ static int __devinit init_setup_hpt37x(struct pci_dev *dev, ide_pci_device_t *d) | |||
1574 | return ide_setup_pci_device(dev, d); | 1441 | return ide_setup_pci_device(dev, d); |
1575 | } | 1442 | } |
1576 | 1443 | ||
1444 | static int __devinit init_setup_hpt371(struct pci_dev *dev, ide_pci_device_t *d) | ||
1445 | { | ||
1446 | u8 mcr1 = 0; | ||
1447 | |||
1448 | /* | ||
1449 | * HPT371 chips physically have only one channel, the secondary one, | ||
1450 | * but the primary channel registers do exist! Go figure... | ||
1451 | * So, we manually disable the non-existing channel here | ||
1452 | * (if the BIOS hasn't done this already). | ||
1453 | */ | ||
1454 | pci_read_config_byte(dev, 0x50, &mcr1); | ||
1455 | if (mcr1 & 0x04) | ||
1456 | pci_write_config_byte(dev, 0x50, (mcr1 & ~0x04)); | ||
1457 | |||
1458 | return ide_setup_pci_device(dev, d); | ||
1459 | } | ||
1460 | |||
1577 | static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d) | 1461 | static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d) |
1578 | { | 1462 | { |
1579 | struct pci_dev *findev = NULL; | 1463 | struct pci_dev *findev = NULL; |
@@ -1661,13 +1545,14 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { | |||
1661 | .bootable = OFF_BOARD, | 1545 | .bootable = OFF_BOARD, |
1662 | },{ /* 3 */ | 1546 | },{ /* 3 */ |
1663 | .name = "HPT371", | 1547 | .name = "HPT371", |
1664 | .init_setup = init_setup_hpt37x, | 1548 | .init_setup = init_setup_hpt371, |
1665 | .init_chipset = init_chipset_hpt366, | 1549 | .init_chipset = init_chipset_hpt366, |
1666 | .init_iops = init_iops_hpt366, | 1550 | .init_iops = init_iops_hpt366, |
1667 | .init_hwif = init_hwif_hpt366, | 1551 | .init_hwif = init_hwif_hpt366, |
1668 | .init_dma = init_dma_hpt366, | 1552 | .init_dma = init_dma_hpt366, |
1669 | .channels = 2, | 1553 | .channels = 2, |
1670 | .autodma = AUTODMA, | 1554 | .autodma = AUTODMA, |
1555 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | ||
1671 | .bootable = OFF_BOARD, | 1556 | .bootable = OFF_BOARD, |
1672 | },{ /* 4 */ | 1557 | },{ /* 4 */ |
1673 | .name = "HPT374", | 1558 | .name = "HPT374", |
@@ -1699,13 +1584,16 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { | |||
1699 | * | 1584 | * |
1700 | * Called when the PCI registration layer (or the IDE initialization) | 1585 | * Called when the PCI registration layer (or the IDE initialization) |
1701 | * finds a device matching our IDE device tables. | 1586 | * finds a device matching our IDE device tables. |
1587 | * | ||
1588 | * NOTE: since we'll have to modify some fields of the ide_pci_device_t | ||
1589 | * structure depending on the chip's revision, we'd better pass a local | ||
1590 | * copy down the call chain... | ||
1702 | */ | 1591 | */ |
1703 | |||
1704 | static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 1592 | static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
1705 | { | 1593 | { |
1706 | ide_pci_device_t *d = &hpt366_chipsets[id->driver_data]; | 1594 | ide_pci_device_t d = hpt366_chipsets[id->driver_data]; |
1707 | 1595 | ||
1708 | return d->init_setup(dev, d); | 1596 | return d.init_setup(dev, &d); |
1709 | } | 1597 | } |
1710 | 1598 | ||
1711 | static struct pci_device_id hpt366_pci_tbl[] = { | 1599 | static struct pci_device_id hpt366_pci_tbl[] = { |
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c index 0491ec7a7c0a..44bc6cc734ab 100644 --- a/drivers/infiniband/hw/mthca/mthca_main.c +++ b/drivers/infiniband/hw/mthca/mthca_main.c | |||
@@ -80,24 +80,61 @@ static int tune_pci = 0; | |||
80 | module_param(tune_pci, int, 0444); | 80 | module_param(tune_pci, int, 0444); |
81 | MODULE_PARM_DESC(tune_pci, "increase PCI burst from the default set by BIOS if nonzero"); | 81 | MODULE_PARM_DESC(tune_pci, "increase PCI burst from the default set by BIOS if nonzero"); |
82 | 82 | ||
83 | struct mutex mthca_device_mutex; | 83 | DEFINE_MUTEX(mthca_device_mutex); |
84 | |||
85 | #define MTHCA_DEFAULT_NUM_QP (1 << 16) | ||
86 | #define MTHCA_DEFAULT_RDB_PER_QP (1 << 2) | ||
87 | #define MTHCA_DEFAULT_NUM_CQ (1 << 16) | ||
88 | #define MTHCA_DEFAULT_NUM_MCG (1 << 13) | ||
89 | #define MTHCA_DEFAULT_NUM_MPT (1 << 17) | ||
90 | #define MTHCA_DEFAULT_NUM_MTT (1 << 20) | ||
91 | #define MTHCA_DEFAULT_NUM_UDAV (1 << 15) | ||
92 | #define MTHCA_DEFAULT_NUM_RESERVED_MTTS (1 << 18) | ||
93 | #define MTHCA_DEFAULT_NUM_UARC_SIZE (1 << 18) | ||
94 | |||
95 | static struct mthca_profile hca_profile = { | ||
96 | .num_qp = MTHCA_DEFAULT_NUM_QP, | ||
97 | .rdb_per_qp = MTHCA_DEFAULT_RDB_PER_QP, | ||
98 | .num_cq = MTHCA_DEFAULT_NUM_CQ, | ||
99 | .num_mcg = MTHCA_DEFAULT_NUM_MCG, | ||
100 | .num_mpt = MTHCA_DEFAULT_NUM_MPT, | ||
101 | .num_mtt = MTHCA_DEFAULT_NUM_MTT, | ||
102 | .num_udav = MTHCA_DEFAULT_NUM_UDAV, /* Tavor only */ | ||
103 | .fmr_reserved_mtts = MTHCA_DEFAULT_NUM_RESERVED_MTTS, /* Tavor only */ | ||
104 | .uarc_size = MTHCA_DEFAULT_NUM_UARC_SIZE, /* Arbel only */ | ||
105 | }; | ||
106 | |||
107 | module_param_named(num_qp, hca_profile.num_qp, int, 0444); | ||
108 | MODULE_PARM_DESC(num_qp, "maximum number of QPs per HCA"); | ||
109 | |||
110 | module_param_named(rdb_per_qp, hca_profile.rdb_per_qp, int, 0444); | ||
111 | MODULE_PARM_DESC(rdb_per_qp, "number of RDB buffers per QP"); | ||
112 | |||
113 | module_param_named(num_cq, hca_profile.num_cq, int, 0444); | ||
114 | MODULE_PARM_DESC(num_cq, "maximum number of CQs per HCA"); | ||
115 | |||
116 | module_param_named(num_mcg, hca_profile.num_mcg, int, 0444); | ||
117 | MODULE_PARM_DESC(num_mcg, "maximum number of multicast groups per HCA"); | ||
118 | |||
119 | module_param_named(num_mpt, hca_profile.num_mpt, int, 0444); | ||
120 | MODULE_PARM_DESC(num_mpt, | ||
121 | "maximum number of memory protection table entries per HCA"); | ||
122 | |||
123 | module_param_named(num_mtt, hca_profile.num_mtt, int, 0444); | ||
124 | MODULE_PARM_DESC(num_mtt, | ||
125 | "maximum number of memory translation table segments per HCA"); | ||
126 | |||
127 | module_param_named(num_udav, hca_profile.num_udav, int, 0444); | ||
128 | MODULE_PARM_DESC(num_udav, "maximum number of UD address vectors per HCA"); | ||
129 | |||
130 | module_param_named(fmr_reserved_mtts, hca_profile.fmr_reserved_mtts, int, 0444); | ||
131 | MODULE_PARM_DESC(fmr_reserved_mtts, | ||
132 | "number of memory translation table segments reserved for FMR"); | ||
84 | 133 | ||
85 | static const char mthca_version[] __devinitdata = | 134 | static const char mthca_version[] __devinitdata = |
86 | DRV_NAME ": Mellanox InfiniBand HCA driver v" | 135 | DRV_NAME ": Mellanox InfiniBand HCA driver v" |
87 | DRV_VERSION " (" DRV_RELDATE ")\n"; | 136 | DRV_VERSION " (" DRV_RELDATE ")\n"; |
88 | 137 | ||
89 | static struct mthca_profile default_profile = { | ||
90 | .num_qp = 1 << 16, | ||
91 | .rdb_per_qp = 4, | ||
92 | .num_cq = 1 << 16, | ||
93 | .num_mcg = 1 << 13, | ||
94 | .num_mpt = 1 << 17, | ||
95 | .num_mtt = 1 << 20, | ||
96 | .num_udav = 1 << 15, /* Tavor only */ | ||
97 | .fmr_reserved_mtts = 1 << 18, /* Tavor only */ | ||
98 | .uarc_size = 1 << 18, /* Arbel only */ | ||
99 | }; | ||
100 | |||
101 | static int mthca_tune_pci(struct mthca_dev *mdev) | 138 | static int mthca_tune_pci(struct mthca_dev *mdev) |
102 | { | 139 | { |
103 | int cap; | 140 | int cap; |
@@ -303,7 +340,7 @@ static int mthca_init_tavor(struct mthca_dev *mdev) | |||
303 | goto err_disable; | 340 | goto err_disable; |
304 | } | 341 | } |
305 | 342 | ||
306 | profile = default_profile; | 343 | profile = hca_profile; |
307 | profile.num_uar = dev_lim.uar_size / PAGE_SIZE; | 344 | profile.num_uar = dev_lim.uar_size / PAGE_SIZE; |
308 | profile.uarc_size = 0; | 345 | profile.uarc_size = 0; |
309 | if (mdev->mthca_flags & MTHCA_FLAG_SRQ) | 346 | if (mdev->mthca_flags & MTHCA_FLAG_SRQ) |
@@ -621,7 +658,7 @@ static int mthca_init_arbel(struct mthca_dev *mdev) | |||
621 | goto err_stop_fw; | 658 | goto err_stop_fw; |
622 | } | 659 | } |
623 | 660 | ||
624 | profile = default_profile; | 661 | profile = hca_profile; |
625 | profile.num_uar = dev_lim.uar_size / PAGE_SIZE; | 662 | profile.num_uar = dev_lim.uar_size / PAGE_SIZE; |
626 | profile.num_udav = 0; | 663 | profile.num_udav = 0; |
627 | if (mdev->mthca_flags & MTHCA_FLAG_SRQ) | 664 | if (mdev->mthca_flags & MTHCA_FLAG_SRQ) |
@@ -1278,11 +1315,55 @@ static struct pci_driver mthca_driver = { | |||
1278 | .remove = __devexit_p(mthca_remove_one) | 1315 | .remove = __devexit_p(mthca_remove_one) |
1279 | }; | 1316 | }; |
1280 | 1317 | ||
1318 | static void __init __mthca_check_profile_val(const char *name, int *pval, | ||
1319 | int pval_default) | ||
1320 | { | ||
1321 | /* value must be positive and power of 2 */ | ||
1322 | int old_pval = *pval; | ||
1323 | |||
1324 | if (old_pval <= 0) | ||
1325 | *pval = pval_default; | ||
1326 | else | ||
1327 | *pval = roundup_pow_of_two(old_pval); | ||
1328 | |||
1329 | if (old_pval != *pval) { | ||
1330 | printk(KERN_WARNING PFX "Invalid value %d for %s in module parameter.\n", | ||
1331 | old_pval, name); | ||
1332 | printk(KERN_WARNING PFX "Corrected %s to %d.\n", name, *pval); | ||
1333 | } | ||
1334 | } | ||
1335 | |||
1336 | #define mthca_check_profile_val(name, default) \ | ||
1337 | __mthca_check_profile_val(#name, &hca_profile.name, default) | ||
1338 | |||
1339 | static void __init mthca_validate_profile(void) | ||
1340 | { | ||
1341 | mthca_check_profile_val(num_qp, MTHCA_DEFAULT_NUM_QP); | ||
1342 | mthca_check_profile_val(rdb_per_qp, MTHCA_DEFAULT_RDB_PER_QP); | ||
1343 | mthca_check_profile_val(num_cq, MTHCA_DEFAULT_NUM_CQ); | ||
1344 | mthca_check_profile_val(num_mcg, MTHCA_DEFAULT_NUM_MCG); | ||
1345 | mthca_check_profile_val(num_mpt, MTHCA_DEFAULT_NUM_MPT); | ||
1346 | mthca_check_profile_val(num_mtt, MTHCA_DEFAULT_NUM_MTT); | ||
1347 | mthca_check_profile_val(num_udav, MTHCA_DEFAULT_NUM_UDAV); | ||
1348 | mthca_check_profile_val(fmr_reserved_mtts, MTHCA_DEFAULT_NUM_RESERVED_MTTS); | ||
1349 | |||
1350 | if (hca_profile.fmr_reserved_mtts >= hca_profile.num_mtt) { | ||
1351 | printk(KERN_WARNING PFX "Invalid fmr_reserved_mtts module parameter %d.\n", | ||
1352 | hca_profile.fmr_reserved_mtts); | ||
1353 | printk(KERN_WARNING PFX "(Must be smaller than num_mtt %d)\n", | ||
1354 | hca_profile.num_mtt); | ||
1355 | hca_profile.fmr_reserved_mtts = hca_profile.num_mtt / 2; | ||
1356 | printk(KERN_WARNING PFX "Corrected fmr_reserved_mtts to %d.\n", | ||
1357 | hca_profile.fmr_reserved_mtts); | ||
1358 | } | ||
1359 | } | ||
1360 | |||
1281 | static int __init mthca_init(void) | 1361 | static int __init mthca_init(void) |
1282 | { | 1362 | { |
1283 | int ret; | 1363 | int ret; |
1284 | 1364 | ||
1285 | mutex_init(&mthca_device_mutex); | 1365 | mthca_validate_profile(); |
1366 | |||
1286 | ret = mthca_catas_init(); | 1367 | ret = mthca_catas_init(); |
1287 | if (ret) | 1368 | if (ret) |
1288 | return ret; | 1369 | return ret; |
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index e9b6a6f07dd7..cdecbf5911c8 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
@@ -1898,7 +1898,7 @@ static void srp_add_one(struct ib_device *device) | |||
1898 | */ | 1898 | */ |
1899 | srp_dev->fmr_page_shift = max(9, ffs(dev_attr->page_size_cap) - 1); | 1899 | srp_dev->fmr_page_shift = max(9, ffs(dev_attr->page_size_cap) - 1); |
1900 | srp_dev->fmr_page_size = 1 << srp_dev->fmr_page_shift; | 1900 | srp_dev->fmr_page_size = 1 << srp_dev->fmr_page_shift; |
1901 | srp_dev->fmr_page_mask = ~((unsigned long) srp_dev->fmr_page_size - 1); | 1901 | srp_dev->fmr_page_mask = ~((u64) srp_dev->fmr_page_size - 1); |
1902 | 1902 | ||
1903 | INIT_LIST_HEAD(&srp_dev->dev_list); | 1903 | INIT_LIST_HEAD(&srp_dev->dev_list); |
1904 | 1904 | ||
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h index 868a540ef7cd..c21772317b86 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.h +++ b/drivers/infiniband/ulp/srp/ib_srp.h | |||
@@ -87,7 +87,7 @@ struct srp_device { | |||
87 | struct ib_fmr_pool *fmr_pool; | 87 | struct ib_fmr_pool *fmr_pool; |
88 | int fmr_page_shift; | 88 | int fmr_page_shift; |
89 | int fmr_page_size; | 89 | int fmr_page_size; |
90 | unsigned long fmr_page_mask; | 90 | u64 fmr_page_mask; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | struct srp_host { | 93 | struct srp_host { |
diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c index 16583d71753b..c67e84ec2d6a 100644 --- a/drivers/input/keyboard/amikbd.c +++ b/drivers/input/keyboard/amikbd.c | |||
@@ -187,7 +187,7 @@ static irqreturn_t amikbd_interrupt(int irq, void *dummy) | |||
187 | 187 | ||
188 | static int __init amikbd_init(void) | 188 | static int __init amikbd_init(void) |
189 | { | 189 | { |
190 | int i, j; | 190 | int i, j, err; |
191 | 191 | ||
192 | if (!AMIGAHW_PRESENT(AMI_KEYBOARD)) | 192 | if (!AMIGAHW_PRESENT(AMI_KEYBOARD)) |
193 | return -ENODEV; | 193 | return -ENODEV; |
diff --git a/drivers/input/keyboard/hilkbd.c b/drivers/input/keyboard/hilkbd.c index 54bc569db4b0..35461eab2faf 100644 --- a/drivers/input/keyboard/hilkbd.c +++ b/drivers/input/keyboard/hilkbd.c | |||
@@ -23,7 +23,12 @@ | |||
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
25 | #include <linux/hil.h> | 25 | #include <linux/hil.h> |
26 | #include <linux/io.h> | ||
26 | #include <linux/spinlock.h> | 27 | #include <linux/spinlock.h> |
28 | #include <asm/irq.h> | ||
29 | #ifdef CONFIG_HP300 | ||
30 | #include <asm/hwtest.h> | ||
31 | #endif | ||
27 | 32 | ||
28 | 33 | ||
29 | MODULE_AUTHOR("Philip Blundell, Matthew Wilcox, Helge Deller"); | 34 | MODULE_AUTHOR("Philip Blundell, Matthew Wilcox, Helge Deller"); |
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index 3826db9403e6..cc0238366414 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c | |||
@@ -225,7 +225,7 @@ static void sunkbd_reinit(struct work_struct *work) | |||
225 | static void sunkbd_enable(struct sunkbd *sunkbd, int enable) | 225 | static void sunkbd_enable(struct sunkbd *sunkbd, int enable) |
226 | { | 226 | { |
227 | serio_pause_rx(sunkbd->serio); | 227 | serio_pause_rx(sunkbd->serio); |
228 | sunkbd->enabled = 1; | 228 | sunkbd->enabled = enable; |
229 | serio_continue_rx(sunkbd->serio); | 229 | serio_continue_rx(sunkbd->serio); |
230 | } | 230 | } |
231 | 231 | ||
diff --git a/drivers/isdn/act2000/act2000_isa.c b/drivers/isdn/act2000/act2000_isa.c index 3cac23739344..09ea50dd3459 100644 --- a/drivers/isdn/act2000/act2000_isa.c +++ b/drivers/isdn/act2000/act2000_isa.c | |||
@@ -408,7 +408,7 @@ act2000_isa_download(act2000_card * card, act2000_ddef __user * cb) | |||
408 | p = cblock.buffer; | 408 | p = cblock.buffer; |
409 | if (!access_ok(VERIFY_READ, p, length)) | 409 | if (!access_ok(VERIFY_READ, p, length)) |
410 | return -EFAULT; | 410 | return -EFAULT; |
411 | buf = (u_char *) kmalloc(1024, GFP_KERNEL); | 411 | buf = kmalloc(1024, GFP_KERNEL); |
412 | if (!buf) | 412 | if (!buf) |
413 | return -ENOMEM; | 413 | return -ENOMEM; |
414 | timeout = 0; | 414 | timeout = 0; |
diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c index 097bfa7bc323..c4d438c17dab 100644 --- a/drivers/isdn/capi/capidrv.c +++ b/drivers/isdn/capi/capidrv.c | |||
@@ -2013,7 +2013,7 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp) | |||
2013 | strcpy(card->name, id); | 2013 | strcpy(card->name, id); |
2014 | card->contrnr = contr; | 2014 | card->contrnr = contr; |
2015 | card->nbchan = profp->nbchannel; | 2015 | card->nbchan = profp->nbchannel; |
2016 | card->bchans = (capidrv_bchan *) kmalloc(sizeof(capidrv_bchan) * card->nbchan, GFP_ATOMIC); | 2016 | card->bchans = kmalloc(sizeof(capidrv_bchan) * card->nbchan, GFP_ATOMIC); |
2017 | if (!card->bchans) { | 2017 | if (!card->bchans) { |
2018 | printk(KERN_WARNING | 2018 | printk(KERN_WARNING |
2019 | "capidrv: (%s) Could not allocate bchan-structs.\n", id); | 2019 | "capidrv: (%s) Could not allocate bchan-structs.\n", id); |
diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c index 399b316111f7..06967da7c4a8 100644 --- a/drivers/isdn/divert/divert_procfs.c +++ b/drivers/isdn/divert/divert_procfs.c | |||
@@ -45,7 +45,7 @@ put_info_buffer(char *cp) | |||
45 | return; | 45 | return; |
46 | if (!*cp) | 46 | if (!*cp) |
47 | return; | 47 | return; |
48 | if (!(ib = (struct divert_info *) kmalloc(sizeof(struct divert_info) + strlen(cp), GFP_ATOMIC))) | 48 | if (!(ib = kmalloc(sizeof(struct divert_info) + strlen(cp), GFP_ATOMIC))) |
49 | return; /* no memory */ | 49 | return; /* no memory */ |
50 | strcpy(ib->info_start, cp); /* set output string */ | 50 | strcpy(ib->info_start, cp); /* set output string */ |
51 | ib->next = NULL; | 51 | ib->next = NULL; |
diff --git a/drivers/isdn/divert/isdn_divert.c b/drivers/isdn/divert/isdn_divert.c index 03319ea5aa0c..7d97d54588d9 100644 --- a/drivers/isdn/divert/isdn_divert.c +++ b/drivers/isdn/divert/isdn_divert.c | |||
@@ -153,7 +153,7 @@ int cf_command(int drvid, int mode, | |||
153 | *ielenp = p - ielenp - 1; /* set total IE length */ | 153 | *ielenp = p - ielenp - 1; /* set total IE length */ |
154 | 154 | ||
155 | /* allocate mem for information struct */ | 155 | /* allocate mem for information struct */ |
156 | if (!(cs = (struct call_struc *) kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) | 156 | if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) |
157 | return(-ENOMEM); /* no memory */ | 157 | return(-ENOMEM); /* no memory */ |
158 | init_timer(&cs->timer); | 158 | init_timer(&cs->timer); |
159 | cs->info[0] = '\0'; | 159 | cs->info[0] = '\0'; |
@@ -276,7 +276,7 @@ int insertrule(int idx, divert_rule *newrule) | |||
276 | { struct deflect_struc *ds,*ds1=NULL; | 276 | { struct deflect_struc *ds,*ds1=NULL; |
277 | unsigned long flags; | 277 | unsigned long flags; |
278 | 278 | ||
279 | if (!(ds = (struct deflect_struc *) kmalloc(sizeof(struct deflect_struc), | 279 | if (!(ds = kmalloc(sizeof(struct deflect_struc), |
280 | GFP_KERNEL))) | 280 | GFP_KERNEL))) |
281 | return(-ENOMEM); /* no memory */ | 281 | return(-ENOMEM); /* no memory */ |
282 | 282 | ||
@@ -451,7 +451,7 @@ static int isdn_divert_icall(isdn_ctrl *ic) | |||
451 | if (dv->rule.action == DEFLECT_PROCEED) | 451 | if (dv->rule.action == DEFLECT_PROCEED) |
452 | if ((!if_used) || ((!extern_wait_max) && (!dv->rule.waittime))) | 452 | if ((!if_used) || ((!extern_wait_max) && (!dv->rule.waittime))) |
453 | return(0); /* no external deflection needed */ | 453 | return(0); /* no external deflection needed */ |
454 | if (!(cs = (struct call_struc *) kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) | 454 | if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) |
455 | return(0); /* no memory */ | 455 | return(0); /* no memory */ |
456 | init_timer(&cs->timer); | 456 | init_timer(&cs->timer); |
457 | cs->info[0] = '\0'; | 457 | cs->info[0] = '\0'; |
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c index 63b629b1cdb2..b5e7f9c7d74e 100644 --- a/drivers/isdn/gigaset/bas-gigaset.c +++ b/drivers/isdn/gigaset/bas-gigaset.c | |||
@@ -1853,20 +1853,24 @@ static int gigaset_write_cmd(struct cardstate *cs, | |||
1853 | { | 1853 | { |
1854 | struct cmdbuf_t *cb; | 1854 | struct cmdbuf_t *cb; |
1855 | unsigned long flags; | 1855 | unsigned long flags; |
1856 | int status; | 1856 | int rc; |
1857 | 1857 | ||
1858 | gigaset_dbg_buffer(atomic_read(&cs->mstate) != MS_LOCKED ? | 1858 | gigaset_dbg_buffer(atomic_read(&cs->mstate) != MS_LOCKED ? |
1859 | DEBUG_TRANSCMD : DEBUG_LOCKCMD, | 1859 | DEBUG_TRANSCMD : DEBUG_LOCKCMD, |
1860 | "CMD Transmit", len, buf); | 1860 | "CMD Transmit", len, buf); |
1861 | 1861 | ||
1862 | if (len <= 0) | 1862 | if (len <= 0) { |
1863 | return 0; /* nothing to do */ | 1863 | /* nothing to do */ |
1864 | rc = 0; | ||
1865 | goto notqueued; | ||
1866 | } | ||
1864 | 1867 | ||
1865 | if (len > IF_WRITEBUF) | 1868 | if (len > IF_WRITEBUF) |
1866 | len = IF_WRITEBUF; | 1869 | len = IF_WRITEBUF; |
1867 | if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) { | 1870 | if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) { |
1868 | dev_err(cs->dev, "%s: out of memory\n", __func__); | 1871 | dev_err(cs->dev, "%s: out of memory\n", __func__); |
1869 | return -ENOMEM; | 1872 | rc = -ENOMEM; |
1873 | goto notqueued; | ||
1870 | } | 1874 | } |
1871 | 1875 | ||
1872 | memcpy(cb->buf, buf, len); | 1876 | memcpy(cb->buf, buf, len); |
@@ -1891,11 +1895,21 @@ static int gigaset_write_cmd(struct cardstate *cs, | |||
1891 | if (unlikely(!cs->connected)) { | 1895 | if (unlikely(!cs->connected)) { |
1892 | spin_unlock_irqrestore(&cs->lock, flags); | 1896 | spin_unlock_irqrestore(&cs->lock, flags); |
1893 | gig_dbg(DEBUG_USBREQ, "%s: not connected", __func__); | 1897 | gig_dbg(DEBUG_USBREQ, "%s: not connected", __func__); |
1898 | /* flush command queue */ | ||
1899 | spin_lock_irqsave(&cs->cmdlock, flags); | ||
1900 | while (cs->cmdbuf != NULL) | ||
1901 | complete_cb(cs); | ||
1902 | spin_unlock_irqrestore(&cs->cmdlock, flags); | ||
1894 | return -ENODEV; | 1903 | return -ENODEV; |
1895 | } | 1904 | } |
1896 | status = start_cbsend(cs); | 1905 | rc = start_cbsend(cs); |
1897 | spin_unlock_irqrestore(&cs->lock, flags); | 1906 | spin_unlock_irqrestore(&cs->lock, flags); |
1898 | return status < 0 ? status : len; | 1907 | return rc < 0 ? rc : len; |
1908 | |||
1909 | notqueued: /* request handled without queuing */ | ||
1910 | if (wake_tasklet) | ||
1911 | tasklet_schedule(wake_tasklet); | ||
1912 | return rc; | ||
1899 | } | 1913 | } |
1900 | 1914 | ||
1901 | /* gigaset_write_room | 1915 | /* gigaset_write_room |
@@ -1964,20 +1978,15 @@ static int gigaset_freebcshw(struct bc_state *bcs) | |||
1964 | 1978 | ||
1965 | /* kill URBs and tasklets before freeing - better safe than sorry */ | 1979 | /* kill URBs and tasklets before freeing - better safe than sorry */ |
1966 | atomic_set(&ubc->running, 0); | 1980 | atomic_set(&ubc->running, 0); |
1967 | for (i = 0; i < BAS_OUTURBS; ++i) | 1981 | gig_dbg(DEBUG_INIT, "%s: killing iso URBs", __func__); |
1968 | if (ubc->isoouturbs[i].urb) { | 1982 | for (i = 0; i < BAS_OUTURBS; ++i) { |
1969 | gig_dbg(DEBUG_INIT, "%s: killing iso out URB %d", | 1983 | usb_kill_urb(ubc->isoouturbs[i].urb); |
1970 | __func__, i); | 1984 | usb_free_urb(ubc->isoouturbs[i].urb); |
1971 | usb_kill_urb(ubc->isoouturbs[i].urb); | 1985 | } |
1972 | usb_free_urb(ubc->isoouturbs[i].urb); | 1986 | for (i = 0; i < BAS_INURBS; ++i) { |
1973 | } | 1987 | usb_kill_urb(ubc->isoinurbs[i]); |
1974 | for (i = 0; i < BAS_INURBS; ++i) | 1988 | usb_free_urb(ubc->isoinurbs[i]); |
1975 | if (ubc->isoinurbs[i]) { | 1989 | } |
1976 | gig_dbg(DEBUG_INIT, "%s: killing iso in URB %d", | ||
1977 | __func__, i); | ||
1978 | usb_kill_urb(ubc->isoinurbs[i]); | ||
1979 | usb_free_urb(ubc->isoinurbs[i]); | ||
1980 | } | ||
1981 | tasklet_kill(&ubc->sent_tasklet); | 1990 | tasklet_kill(&ubc->sent_tasklet); |
1982 | tasklet_kill(&ubc->rcvd_tasklet); | 1991 | tasklet_kill(&ubc->rcvd_tasklet); |
1983 | kfree(ubc->isooutbuf); | 1992 | kfree(ubc->isooutbuf); |
@@ -2099,55 +2108,32 @@ static void freeurbs(struct cardstate *cs) | |||
2099 | struct bas_bc_state *ubc; | 2108 | struct bas_bc_state *ubc; |
2100 | int i, j; | 2109 | int i, j; |
2101 | 2110 | ||
2111 | gig_dbg(DEBUG_INIT, "%s: killing URBs", __func__); | ||
2102 | for (j = 0; j < 2; ++j) { | 2112 | for (j = 0; j < 2; ++j) { |
2103 | ubc = cs->bcs[j].hw.bas; | 2113 | ubc = cs->bcs[j].hw.bas; |
2104 | for (i = 0; i < BAS_OUTURBS; ++i) | 2114 | for (i = 0; i < BAS_OUTURBS; ++i) { |
2105 | if (ubc->isoouturbs[i].urb) { | 2115 | usb_kill_urb(ubc->isoouturbs[i].urb); |
2106 | usb_kill_urb(ubc->isoouturbs[i].urb); | 2116 | usb_free_urb(ubc->isoouturbs[i].urb); |
2107 | gig_dbg(DEBUG_INIT, | 2117 | ubc->isoouturbs[i].urb = NULL; |
2108 | "%s: isoc output URB %d/%d unlinked", | 2118 | } |
2109 | __func__, j, i); | 2119 | for (i = 0; i < BAS_INURBS; ++i) { |
2110 | usb_free_urb(ubc->isoouturbs[i].urb); | 2120 | usb_kill_urb(ubc->isoinurbs[i]); |
2111 | ubc->isoouturbs[i].urb = NULL; | 2121 | usb_free_urb(ubc->isoinurbs[i]); |
2112 | } | 2122 | ubc->isoinurbs[i] = NULL; |
2113 | for (i = 0; i < BAS_INURBS; ++i) | 2123 | } |
2114 | if (ubc->isoinurbs[i]) { | ||
2115 | usb_kill_urb(ubc->isoinurbs[i]); | ||
2116 | gig_dbg(DEBUG_INIT, | ||
2117 | "%s: isoc input URB %d/%d unlinked", | ||
2118 | __func__, j, i); | ||
2119 | usb_free_urb(ubc->isoinurbs[i]); | ||
2120 | ubc->isoinurbs[i] = NULL; | ||
2121 | } | ||
2122 | } | ||
2123 | if (ucs->urb_int_in) { | ||
2124 | usb_kill_urb(ucs->urb_int_in); | ||
2125 | gig_dbg(DEBUG_INIT, "%s: interrupt input URB unlinked", | ||
2126 | __func__); | ||
2127 | usb_free_urb(ucs->urb_int_in); | ||
2128 | ucs->urb_int_in = NULL; | ||
2129 | } | ||
2130 | if (ucs->urb_cmd_out) { | ||
2131 | usb_kill_urb(ucs->urb_cmd_out); | ||
2132 | gig_dbg(DEBUG_INIT, "%s: command output URB unlinked", | ||
2133 | __func__); | ||
2134 | usb_free_urb(ucs->urb_cmd_out); | ||
2135 | ucs->urb_cmd_out = NULL; | ||
2136 | } | ||
2137 | if (ucs->urb_cmd_in) { | ||
2138 | usb_kill_urb(ucs->urb_cmd_in); | ||
2139 | gig_dbg(DEBUG_INIT, "%s: command input URB unlinked", | ||
2140 | __func__); | ||
2141 | usb_free_urb(ucs->urb_cmd_in); | ||
2142 | ucs->urb_cmd_in = NULL; | ||
2143 | } | ||
2144 | if (ucs->urb_ctrl) { | ||
2145 | usb_kill_urb(ucs->urb_ctrl); | ||
2146 | gig_dbg(DEBUG_INIT, "%s: control output URB unlinked", | ||
2147 | __func__); | ||
2148 | usb_free_urb(ucs->urb_ctrl); | ||
2149 | ucs->urb_ctrl = NULL; | ||
2150 | } | 2124 | } |
2125 | usb_kill_urb(ucs->urb_int_in); | ||
2126 | usb_free_urb(ucs->urb_int_in); | ||
2127 | ucs->urb_int_in = NULL; | ||
2128 | usb_kill_urb(ucs->urb_cmd_out); | ||
2129 | usb_free_urb(ucs->urb_cmd_out); | ||
2130 | ucs->urb_cmd_out = NULL; | ||
2131 | usb_kill_urb(ucs->urb_cmd_in); | ||
2132 | usb_free_urb(ucs->urb_cmd_in); | ||
2133 | ucs->urb_cmd_in = NULL; | ||
2134 | usb_kill_urb(ucs->urb_ctrl); | ||
2135 | usb_free_urb(ucs->urb_ctrl); | ||
2136 | ucs->urb_ctrl = NULL; | ||
2151 | } | 2137 | } |
2152 | 2138 | ||
2153 | /* gigaset_probe | 2139 | /* gigaset_probe |
diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c index 8e2b03889f3c..94a935089119 100644 --- a/drivers/isdn/hysdn/hysdn_procconf.c +++ b/drivers/isdn/hysdn/hysdn_procconf.c | |||
@@ -275,7 +275,7 @@ hysdn_conf_open(struct inode *ino, struct file *filep) | |||
275 | } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) { | 275 | } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) { |
276 | /* read access -> output card info data */ | 276 | /* read access -> output card info data */ |
277 | 277 | ||
278 | if (!(tmp = (char *) kmalloc(INFO_OUT_LEN * 2 + 2, GFP_KERNEL))) { | 278 | if (!(tmp = kmalloc(INFO_OUT_LEN * 2 + 2, GFP_KERNEL))) { |
279 | unlock_kernel(); | 279 | unlock_kernel(); |
280 | return (-EFAULT); /* out of memory */ | 280 | return (-EFAULT); /* out of memory */ |
281 | } | 281 | } |
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c index f241f5e551cb..375d956884d7 100644 --- a/drivers/isdn/hysdn/hysdn_proclog.c +++ b/drivers/isdn/hysdn/hysdn_proclog.c | |||
@@ -111,7 +111,7 @@ put_log_buffer(hysdn_card * card, char *cp) | |||
111 | if (pd->if_used <= 0) | 111 | if (pd->if_used <= 0) |
112 | return; /* no open file for read */ | 112 | return; /* no open file for read */ |
113 | 113 | ||
114 | if (!(ib = (struct log_data *) kmalloc(sizeof(struct log_data) + strlen(cp), GFP_ATOMIC))) | 114 | if (!(ib = kmalloc(sizeof(struct log_data) + strlen(cp), GFP_ATOMIC))) |
115 | return; /* no memory */ | 115 | return; /* no memory */ |
116 | strcpy(ib->log_start, cp); /* set output string */ | 116 | strcpy(ib->log_start, cp); /* set output string */ |
117 | ib->next = NULL; | 117 | ib->next = NULL; |
diff --git a/drivers/isdn/i4l/isdn_audio.c b/drivers/isdn/i4l/isdn_audio.c index 2cc56d6a9fae..fb350c567c6b 100644 --- a/drivers/isdn/i4l/isdn_audio.c +++ b/drivers/isdn/i4l/isdn_audio.c | |||
@@ -328,7 +328,7 @@ adpcm_state * | |||
328 | isdn_audio_adpcm_init(adpcm_state * s, int nbits) | 328 | isdn_audio_adpcm_init(adpcm_state * s, int nbits) |
329 | { | 329 | { |
330 | if (!s) | 330 | if (!s) |
331 | s = (adpcm_state *) kmalloc(sizeof(adpcm_state), GFP_ATOMIC); | 331 | s = kmalloc(sizeof(adpcm_state), GFP_ATOMIC); |
332 | if (s) { | 332 | if (s) { |
333 | s->a = 0; | 333 | s->a = 0; |
334 | s->d = 5; | 334 | s->d = 5; |
@@ -343,7 +343,7 @@ dtmf_state * | |||
343 | isdn_audio_dtmf_init(dtmf_state * s) | 343 | isdn_audio_dtmf_init(dtmf_state * s) |
344 | { | 344 | { |
345 | if (!s) | 345 | if (!s) |
346 | s = (dtmf_state *) kmalloc(sizeof(dtmf_state), GFP_ATOMIC); | 346 | s = kmalloc(sizeof(dtmf_state), GFP_ATOMIC); |
347 | if (s) { | 347 | if (s) { |
348 | s->idx = 0; | 348 | s->idx = 0; |
349 | s->last = ' '; | 349 | s->last = ' '; |
@@ -621,7 +621,7 @@ silence_state * | |||
621 | isdn_audio_silence_init(silence_state * s) | 621 | isdn_audio_silence_init(silence_state * s) |
622 | { | 622 | { |
623 | if (!s) | 623 | if (!s) |
624 | s = (silence_state *) kmalloc(sizeof(silence_state), GFP_ATOMIC); | 624 | s = kmalloc(sizeof(silence_state), GFP_ATOMIC); |
625 | if (s) { | 625 | if (s) { |
626 | s->idx = 0; | 626 | s->idx = 0; |
627 | s->state = 0; | 627 | s->state = 0; |
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c index c36c817578cb..838b3734e2b6 100644 --- a/drivers/isdn/i4l/isdn_net.c +++ b/drivers/isdn/i4l/isdn_net.c | |||
@@ -2948,7 +2948,7 @@ isdn_net_addphone(isdn_net_ioctl_phone * phone) | |||
2948 | isdn_net_phone *n; | 2948 | isdn_net_phone *n; |
2949 | 2949 | ||
2950 | if (p) { | 2950 | if (p) { |
2951 | if (!(n = (isdn_net_phone *) kmalloc(sizeof(isdn_net_phone), GFP_KERNEL))) | 2951 | if (!(n = kmalloc(sizeof(isdn_net_phone), GFP_KERNEL))) |
2952 | return -ENOMEM; | 2952 | return -ENOMEM; |
2953 | strcpy(n->num, phone->phone); | 2953 | strcpy(n->num, phone->phone); |
2954 | n->next = p->local->phone[phone->outgoing & 1]; | 2954 | n->next = p->local->phone[phone->outgoing & 1]; |
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c index 43811795b46b..1726131b20be 100644 --- a/drivers/isdn/i4l/isdn_ppp.c +++ b/drivers/isdn/i4l/isdn_ppp.c | |||
@@ -717,7 +717,7 @@ isdn_ppp_fill_rq(unsigned char *buf, int len, int proto, int slot) | |||
717 | printk(KERN_DEBUG "ippp: device not activated.\n"); | 717 | printk(KERN_DEBUG "ippp: device not activated.\n"); |
718 | return 0; | 718 | return 0; |
719 | } | 719 | } |
720 | nbuf = (unsigned char *) kmalloc(len + 4, GFP_ATOMIC); | 720 | nbuf = kmalloc(len + 4, GFP_ATOMIC); |
721 | if (!nbuf) { | 721 | if (!nbuf) { |
722 | printk(KERN_WARNING "ippp: Can't alloc buf\n"); | 722 | printk(KERN_WARNING "ippp: Can't alloc buf\n"); |
723 | return 0; | 723 | return 0; |
diff --git a/drivers/isdn/pcbit/layer2.c b/drivers/isdn/pcbit/layer2.c index 6ff85574e941..eafcce5e656a 100644 --- a/drivers/isdn/pcbit/layer2.c +++ b/drivers/isdn/pcbit/layer2.c | |||
@@ -100,7 +100,7 @@ pcbit_l2_write(struct pcbit_dev *dev, ulong msg, ushort refnum, | |||
100 | dev_kfree_skb(skb); | 100 | dev_kfree_skb(skb); |
101 | return -1; | 101 | return -1; |
102 | } | 102 | } |
103 | if ((frame = (struct frame_buf *) kmalloc(sizeof(struct frame_buf), | 103 | if ((frame = kmalloc(sizeof(struct frame_buf), |
104 | GFP_ATOMIC)) == NULL) { | 104 | GFP_ATOMIC)) == NULL) { |
105 | printk(KERN_WARNING "pcbit_2_write: kmalloc failed\n"); | 105 | printk(KERN_WARNING "pcbit_2_write: kmalloc failed\n"); |
106 | dev_kfree_skb(skb); | 106 | dev_kfree_skb(skb); |
diff --git a/drivers/kvm/Kconfig b/drivers/kvm/Kconfig index 36412e90f09b..703cc88d1ef9 100644 --- a/drivers/kvm/Kconfig +++ b/drivers/kvm/Kconfig | |||
@@ -1,6 +1,8 @@ | |||
1 | # | 1 | # |
2 | # KVM configuration | 2 | # KVM configuration |
3 | # | 3 | # |
4 | menu "Virtualization" | ||
5 | |||
4 | config KVM | 6 | config KVM |
5 | tristate "Kernel-based Virtual Machine (KVM) support" | 7 | tristate "Kernel-based Virtual Machine (KVM) support" |
6 | depends on X86 && EXPERIMENTAL | 8 | depends on X86 && EXPERIMENTAL |
@@ -31,3 +33,5 @@ config KVM_AMD | |||
31 | ---help--- | 33 | ---help--- |
32 | Provides support for KVM on AMD processors equipped with the AMD-V | 34 | Provides support for KVM on AMD processors equipped with the AMD-V |
33 | (SVM) extensions. | 35 | (SVM) extensions. |
36 | |||
37 | endmenu | ||
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h index 5785d0870ab6..930e04ce1af6 100644 --- a/drivers/kvm/kvm.h +++ b/drivers/kvm/kvm.h | |||
@@ -140,7 +140,7 @@ enum { | |||
140 | VCPU_REGS_RBP = 5, | 140 | VCPU_REGS_RBP = 5, |
141 | VCPU_REGS_RSI = 6, | 141 | VCPU_REGS_RSI = 6, |
142 | VCPU_REGS_RDI = 7, | 142 | VCPU_REGS_RDI = 7, |
143 | #ifdef __x86_64__ | 143 | #ifdef CONFIG_X86_64 |
144 | VCPU_REGS_R8 = 8, | 144 | VCPU_REGS_R8 = 8, |
145 | VCPU_REGS_R9 = 9, | 145 | VCPU_REGS_R9 = 9, |
146 | VCPU_REGS_R10 = 10, | 146 | VCPU_REGS_R10 = 10, |
@@ -375,7 +375,7 @@ void set_cr4(struct kvm_vcpu *vcpu, unsigned long cr0); | |||
375 | void set_cr8(struct kvm_vcpu *vcpu, unsigned long cr0); | 375 | void set_cr8(struct kvm_vcpu *vcpu, unsigned long cr0); |
376 | void lmsw(struct kvm_vcpu *vcpu, unsigned long msw); | 376 | void lmsw(struct kvm_vcpu *vcpu, unsigned long msw); |
377 | 377 | ||
378 | #ifdef __x86_64__ | 378 | #ifdef CONFIG_X86_64 |
379 | void set_efer(struct kvm_vcpu *vcpu, u64 efer); | 379 | void set_efer(struct kvm_vcpu *vcpu, u64 efer); |
380 | #endif | 380 | #endif |
381 | 381 | ||
@@ -485,7 +485,7 @@ static inline unsigned long read_tr_base(void) | |||
485 | return segment_base(tr); | 485 | return segment_base(tr); |
486 | } | 486 | } |
487 | 487 | ||
488 | #ifdef __x86_64__ | 488 | #ifdef CONFIG_X86_64 |
489 | static inline unsigned long read_msr(unsigned long msr) | 489 | static inline unsigned long read_msr(unsigned long msr) |
490 | { | 490 | { |
491 | u64 value; | 491 | u64 value; |
@@ -533,7 +533,7 @@ static inline u32 get_rdx_init_val(void) | |||
533 | #define TSS_REDIRECTION_SIZE (256 / 8) | 533 | #define TSS_REDIRECTION_SIZE (256 / 8) |
534 | #define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1) | 534 | #define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1) |
535 | 535 | ||
536 | #ifdef __x86_64__ | 536 | #ifdef CONFIG_X86_64 |
537 | 537 | ||
538 | /* | 538 | /* |
539 | * When emulating 32-bit mode, cr3 is only 32 bits even on x86_64. Therefore | 539 | * When emulating 32-bit mode, cr3 is only 32 bits even on x86_64. Therefore |
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index b6b8a41b5ec8..fd1bb870545c 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c | |||
@@ -72,18 +72,7 @@ static struct dentry *debugfs_dir; | |||
72 | #define CR8_RESEVED_BITS (~0x0fULL) | 72 | #define CR8_RESEVED_BITS (~0x0fULL) |
73 | #define EFER_RESERVED_BITS 0xfffffffffffff2fe | 73 | #define EFER_RESERVED_BITS 0xfffffffffffff2fe |
74 | 74 | ||
75 | struct vmx_msr_entry *find_msr_entry(struct kvm_vcpu *vcpu, u32 msr) | 75 | #ifdef CONFIG_X86_64 |
76 | { | ||
77 | int i; | ||
78 | |||
79 | for (i = 0; i < vcpu->nmsrs; ++i) | ||
80 | if (vcpu->guest_msrs[i].index == msr) | ||
81 | return &vcpu->guest_msrs[i]; | ||
82 | return 0; | ||
83 | } | ||
84 | EXPORT_SYMBOL_GPL(find_msr_entry); | ||
85 | |||
86 | #ifdef __x86_64__ | ||
87 | // LDT or TSS descriptor in the GDT. 16 bytes. | 76 | // LDT or TSS descriptor in the GDT. 16 bytes. |
88 | struct segment_descriptor_64 { | 77 | struct segment_descriptor_64 { |
89 | struct segment_descriptor s; | 78 | struct segment_descriptor s; |
@@ -115,7 +104,7 @@ unsigned long segment_base(u16 selector) | |||
115 | } | 104 | } |
116 | d = (struct segment_descriptor *)(table_base + (selector & ~7)); | 105 | d = (struct segment_descriptor *)(table_base + (selector & ~7)); |
117 | v = d->base_low | ((ul)d->base_mid << 16) | ((ul)d->base_high << 24); | 106 | v = d->base_low | ((ul)d->base_mid << 16) | ((ul)d->base_high << 24); |
118 | #ifdef __x86_64__ | 107 | #ifdef CONFIG_X86_64 |
119 | if (d->system == 0 | 108 | if (d->system == 0 |
120 | && (d->type == 2 || d->type == 9 || d->type == 11)) | 109 | && (d->type == 2 || d->type == 9 || d->type == 11)) |
121 | v |= ((ul)((struct segment_descriptor_64 *)d)->base_higher) << 32; | 110 | v |= ((ul)((struct segment_descriptor_64 *)d)->base_higher) << 32; |
@@ -216,7 +205,6 @@ static struct kvm_vcpu *vcpu_load(struct kvm *kvm, int vcpu_slot) | |||
216 | static void vcpu_put(struct kvm_vcpu *vcpu) | 205 | static void vcpu_put(struct kvm_vcpu *vcpu) |
217 | { | 206 | { |
218 | kvm_arch_ops->vcpu_put(vcpu); | 207 | kvm_arch_ops->vcpu_put(vcpu); |
219 | put_cpu(); | ||
220 | mutex_unlock(&vcpu->mutex); | 208 | mutex_unlock(&vcpu->mutex); |
221 | } | 209 | } |
222 | 210 | ||
@@ -351,7 +339,7 @@ void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) | |||
351 | } | 339 | } |
352 | 340 | ||
353 | if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK)) { | 341 | if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK)) { |
354 | #ifdef __x86_64__ | 342 | #ifdef CONFIG_X86_64 |
355 | if ((vcpu->shadow_efer & EFER_LME)) { | 343 | if ((vcpu->shadow_efer & EFER_LME)) { |
356 | int cs_db, cs_l; | 344 | int cs_db, cs_l; |
357 | 345 | ||
@@ -1120,12 +1108,10 @@ static int get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata) | |||
1120 | return kvm_arch_ops->get_msr(vcpu, msr_index, pdata); | 1108 | return kvm_arch_ops->get_msr(vcpu, msr_index, pdata); |
1121 | } | 1109 | } |
1122 | 1110 | ||
1123 | #ifdef __x86_64__ | 1111 | #ifdef CONFIG_X86_64 |
1124 | 1112 | ||
1125 | void set_efer(struct kvm_vcpu *vcpu, u64 efer) | 1113 | void set_efer(struct kvm_vcpu *vcpu, u64 efer) |
1126 | { | 1114 | { |
1127 | struct vmx_msr_entry *msr; | ||
1128 | |||
1129 | if (efer & EFER_RESERVED_BITS) { | 1115 | if (efer & EFER_RESERVED_BITS) { |
1130 | printk(KERN_DEBUG "set_efer: 0x%llx #GP, reserved bits\n", | 1116 | printk(KERN_DEBUG "set_efer: 0x%llx #GP, reserved bits\n", |
1131 | efer); | 1117 | efer); |
@@ -1140,16 +1126,12 @@ void set_efer(struct kvm_vcpu *vcpu, u64 efer) | |||
1140 | return; | 1126 | return; |
1141 | } | 1127 | } |
1142 | 1128 | ||
1129 | kvm_arch_ops->set_efer(vcpu, efer); | ||
1130 | |||
1143 | efer &= ~EFER_LMA; | 1131 | efer &= ~EFER_LMA; |
1144 | efer |= vcpu->shadow_efer & EFER_LMA; | 1132 | efer |= vcpu->shadow_efer & EFER_LMA; |
1145 | 1133 | ||
1146 | vcpu->shadow_efer = efer; | 1134 | vcpu->shadow_efer = efer; |
1147 | |||
1148 | msr = find_msr_entry(vcpu, MSR_EFER); | ||
1149 | |||
1150 | if (!(efer & EFER_LMA)) | ||
1151 | efer &= ~EFER_LME; | ||
1152 | msr->data = efer; | ||
1153 | } | 1135 | } |
1154 | EXPORT_SYMBOL_GPL(set_efer); | 1136 | EXPORT_SYMBOL_GPL(set_efer); |
1155 | 1137 | ||
@@ -1243,7 +1225,7 @@ static int kvm_dev_ioctl_get_regs(struct kvm *kvm, struct kvm_regs *regs) | |||
1243 | regs->rdi = vcpu->regs[VCPU_REGS_RDI]; | 1225 | regs->rdi = vcpu->regs[VCPU_REGS_RDI]; |
1244 | regs->rsp = vcpu->regs[VCPU_REGS_RSP]; | 1226 | regs->rsp = vcpu->regs[VCPU_REGS_RSP]; |
1245 | regs->rbp = vcpu->regs[VCPU_REGS_RBP]; | 1227 | regs->rbp = vcpu->regs[VCPU_REGS_RBP]; |
1246 | #ifdef __x86_64__ | 1228 | #ifdef CONFIG_X86_64 |
1247 | regs->r8 = vcpu->regs[VCPU_REGS_R8]; | 1229 | regs->r8 = vcpu->regs[VCPU_REGS_R8]; |
1248 | regs->r9 = vcpu->regs[VCPU_REGS_R9]; | 1230 | regs->r9 = vcpu->regs[VCPU_REGS_R9]; |
1249 | regs->r10 = vcpu->regs[VCPU_REGS_R10]; | 1231 | regs->r10 = vcpu->regs[VCPU_REGS_R10]; |
@@ -1287,7 +1269,7 @@ static int kvm_dev_ioctl_set_regs(struct kvm *kvm, struct kvm_regs *regs) | |||
1287 | vcpu->regs[VCPU_REGS_RDI] = regs->rdi; | 1269 | vcpu->regs[VCPU_REGS_RDI] = regs->rdi; |
1288 | vcpu->regs[VCPU_REGS_RSP] = regs->rsp; | 1270 | vcpu->regs[VCPU_REGS_RSP] = regs->rsp; |
1289 | vcpu->regs[VCPU_REGS_RBP] = regs->rbp; | 1271 | vcpu->regs[VCPU_REGS_RBP] = regs->rbp; |
1290 | #ifdef __x86_64__ | 1272 | #ifdef CONFIG_X86_64 |
1291 | vcpu->regs[VCPU_REGS_R8] = regs->r8; | 1273 | vcpu->regs[VCPU_REGS_R8] = regs->r8; |
1292 | vcpu->regs[VCPU_REGS_R9] = regs->r9; | 1274 | vcpu->regs[VCPU_REGS_R9] = regs->r9; |
1293 | vcpu->regs[VCPU_REGS_R10] = regs->r10; | 1275 | vcpu->regs[VCPU_REGS_R10] = regs->r10; |
@@ -1401,7 +1383,7 @@ static int kvm_dev_ioctl_set_sregs(struct kvm *kvm, struct kvm_sregs *sregs) | |||
1401 | vcpu->cr8 = sregs->cr8; | 1383 | vcpu->cr8 = sregs->cr8; |
1402 | 1384 | ||
1403 | mmu_reset_needed |= vcpu->shadow_efer != sregs->efer; | 1385 | mmu_reset_needed |= vcpu->shadow_efer != sregs->efer; |
1404 | #ifdef __x86_64__ | 1386 | #ifdef CONFIG_X86_64 |
1405 | kvm_arch_ops->set_efer(vcpu, sregs->efer); | 1387 | kvm_arch_ops->set_efer(vcpu, sregs->efer); |
1406 | #endif | 1388 | #endif |
1407 | vcpu->apic_base = sregs->apic_base; | 1389 | vcpu->apic_base = sregs->apic_base; |
@@ -1434,7 +1416,7 @@ static int kvm_dev_ioctl_set_sregs(struct kvm *kvm, struct kvm_sregs *sregs) | |||
1434 | static u32 msrs_to_save[] = { | 1416 | static u32 msrs_to_save[] = { |
1435 | MSR_IA32_SYSENTER_CS, MSR_IA32_SYSENTER_ESP, MSR_IA32_SYSENTER_EIP, | 1417 | MSR_IA32_SYSENTER_CS, MSR_IA32_SYSENTER_ESP, MSR_IA32_SYSENTER_EIP, |
1436 | MSR_K6_STAR, | 1418 | MSR_K6_STAR, |
1437 | #ifdef __x86_64__ | 1419 | #ifdef CONFIG_X86_64 |
1438 | MSR_CSTAR, MSR_KERNEL_GS_BASE, MSR_SYSCALL_MASK, MSR_LSTAR, | 1420 | MSR_CSTAR, MSR_KERNEL_GS_BASE, MSR_SYSCALL_MASK, MSR_LSTAR, |
1439 | #endif | 1421 | #endif |
1440 | MSR_IA32_TIME_STAMP_COUNTER, | 1422 | MSR_IA32_TIME_STAMP_COUNTER, |
diff --git a/drivers/kvm/kvm_svm.h b/drivers/kvm/kvm_svm.h index 7d7f2aa10960..74cc862f4935 100644 --- a/drivers/kvm/kvm_svm.h +++ b/drivers/kvm/kvm_svm.h | |||
@@ -9,7 +9,7 @@ | |||
9 | #include "kvm.h" | 9 | #include "kvm.h" |
10 | 10 | ||
11 | static const u32 host_save_msrs[] = { | 11 | static const u32 host_save_msrs[] = { |
12 | #ifdef __x86_64__ | 12 | #ifdef CONFIG_X86_64 |
13 | MSR_STAR, MSR_LSTAR, MSR_CSTAR, MSR_SYSCALL_MASK, MSR_KERNEL_GS_BASE, | 13 | MSR_STAR, MSR_LSTAR, MSR_CSTAR, MSR_SYSCALL_MASK, MSR_KERNEL_GS_BASE, |
14 | MSR_FS_BASE, MSR_GS_BASE, | 14 | MSR_FS_BASE, MSR_GS_BASE, |
15 | #endif | 15 | #endif |
diff --git a/drivers/kvm/kvm_vmx.h b/drivers/kvm/kvm_vmx.h index 87e12d2bfa16..d139f73fb6e1 100644 --- a/drivers/kvm/kvm_vmx.h +++ b/drivers/kvm/kvm_vmx.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef __KVM_VMX_H | 1 | #ifndef __KVM_VMX_H |
2 | #define __KVM_VMX_H | 2 | #define __KVM_VMX_H |
3 | 3 | ||
4 | #ifdef __x86_64__ | 4 | #ifdef CONFIG_X86_64 |
5 | /* | 5 | /* |
6 | * avoid save/load MSR_SYSCALL_MASK and MSR_LSTAR by std vt | 6 | * avoid save/load MSR_SYSCALL_MASK and MSR_LSTAR by std vt |
7 | * mechanism (cpu bug AA24) | 7 | * mechanism (cpu bug AA24) |
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c index 4e29d9b7211c..3d367cbfe1f9 100644 --- a/drivers/kvm/mmu.c +++ b/drivers/kvm/mmu.c | |||
@@ -61,22 +61,9 @@ | |||
61 | 61 | ||
62 | 62 | ||
63 | #define PT32_PTE_COPY_MASK \ | 63 | #define PT32_PTE_COPY_MASK \ |
64 | (PT_PRESENT_MASK | PT_PWT_MASK | PT_PCD_MASK | \ | 64 | (PT_PRESENT_MASK | PT_ACCESSED_MASK | PT_DIRTY_MASK | PT_GLOBAL_MASK) |
65 | PT_ACCESSED_MASK | PT_DIRTY_MASK | PT_PAT_MASK | \ | ||
66 | PT_GLOBAL_MASK ) | ||
67 | |||
68 | #define PT32_NON_PTE_COPY_MASK \ | ||
69 | (PT_PRESENT_MASK | PT_PWT_MASK | PT_PCD_MASK | \ | ||
70 | PT_ACCESSED_MASK | PT_DIRTY_MASK) | ||
71 | |||
72 | |||
73 | #define PT64_PTE_COPY_MASK \ | ||
74 | (PT64_NX_MASK | PT32_PTE_COPY_MASK) | ||
75 | |||
76 | #define PT64_NON_PTE_COPY_MASK \ | ||
77 | (PT64_NX_MASK | PT32_NON_PTE_COPY_MASK) | ||
78 | |||
79 | 65 | ||
66 | #define PT64_PTE_COPY_MASK (PT64_NX_MASK | PT32_PTE_COPY_MASK) | ||
80 | 67 | ||
81 | #define PT_FIRST_AVAIL_BITS_SHIFT 9 | 68 | #define PT_FIRST_AVAIL_BITS_SHIFT 9 |
82 | #define PT64_SECOND_AVAIL_BITS_SHIFT 52 | 69 | #define PT64_SECOND_AVAIL_BITS_SHIFT 52 |
diff --git a/drivers/kvm/paging_tmpl.h b/drivers/kvm/paging_tmpl.h index 765c2e1a048e..a9771b4c5bb8 100644 --- a/drivers/kvm/paging_tmpl.h +++ b/drivers/kvm/paging_tmpl.h | |||
@@ -32,7 +32,6 @@ | |||
32 | #define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level) | 32 | #define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level) |
33 | #define PT_LEVEL_MASK(level) PT64_LEVEL_MASK(level) | 33 | #define PT_LEVEL_MASK(level) PT64_LEVEL_MASK(level) |
34 | #define PT_PTE_COPY_MASK PT64_PTE_COPY_MASK | 34 | #define PT_PTE_COPY_MASK PT64_PTE_COPY_MASK |
35 | #define PT_NON_PTE_COPY_MASK PT64_NON_PTE_COPY_MASK | ||
36 | #elif PTTYPE == 32 | 35 | #elif PTTYPE == 32 |
37 | #define pt_element_t u32 | 36 | #define pt_element_t u32 |
38 | #define guest_walker guest_walker32 | 37 | #define guest_walker guest_walker32 |
@@ -43,7 +42,6 @@ | |||
43 | #define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level) | 42 | #define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level) |
44 | #define PT_LEVEL_MASK(level) PT32_LEVEL_MASK(level) | 43 | #define PT_LEVEL_MASK(level) PT32_LEVEL_MASK(level) |
45 | #define PT_PTE_COPY_MASK PT32_PTE_COPY_MASK | 44 | #define PT_PTE_COPY_MASK PT32_PTE_COPY_MASK |
46 | #define PT_NON_PTE_COPY_MASK PT32_NON_PTE_COPY_MASK | ||
47 | #else | 45 | #else |
48 | #error Invalid PTTYPE value | 46 | #error Invalid PTTYPE value |
49 | #endif | 47 | #endif |
@@ -105,9 +103,7 @@ static void FNAME(set_pde)(struct kvm_vcpu *vcpu, u64 guest_pde, | |||
105 | if (PTTYPE == 32 && is_cpuid_PSE36()) | 103 | if (PTTYPE == 32 && is_cpuid_PSE36()) |
106 | gaddr |= (guest_pde & PT32_DIR_PSE36_MASK) << | 104 | gaddr |= (guest_pde & PT32_DIR_PSE36_MASK) << |
107 | (32 - PT32_DIR_PSE36_SHIFT); | 105 | (32 - PT32_DIR_PSE36_SHIFT); |
108 | *shadow_pte = (guest_pde & (PT_NON_PTE_COPY_MASK | PT_GLOBAL_MASK)) | | 106 | *shadow_pte = guest_pde & PT_PTE_COPY_MASK; |
109 | ((guest_pde & PT_DIR_PAT_MASK) >> | ||
110 | (PT_DIR_PAT_SHIFT - PT_PAT_SHIFT)); | ||
111 | set_pte_common(vcpu, shadow_pte, gaddr, | 107 | set_pte_common(vcpu, shadow_pte, gaddr, |
112 | guest_pde & PT_DIRTY_MASK, access_bits); | 108 | guest_pde & PT_DIRTY_MASK, access_bits); |
113 | } | 109 | } |
@@ -162,6 +158,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, | |||
162 | u32 index = SHADOW_PT_INDEX(addr, level); | 158 | u32 index = SHADOW_PT_INDEX(addr, level); |
163 | u64 *shadow_ent = ((u64 *)__va(shadow_addr)) + index; | 159 | u64 *shadow_ent = ((u64 *)__va(shadow_addr)) + index; |
164 | pt_element_t *guest_ent; | 160 | pt_element_t *guest_ent; |
161 | u64 shadow_pte; | ||
165 | 162 | ||
166 | if (is_present_pte(*shadow_ent) || is_io_pte(*shadow_ent)) { | 163 | if (is_present_pte(*shadow_ent) || is_io_pte(*shadow_ent)) { |
167 | if (level == PT_PAGE_TABLE_LEVEL) | 164 | if (level == PT_PAGE_TABLE_LEVEL) |
@@ -204,14 +201,11 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, | |||
204 | shadow_addr = kvm_mmu_alloc_page(vcpu, shadow_ent); | 201 | shadow_addr = kvm_mmu_alloc_page(vcpu, shadow_ent); |
205 | if (!VALID_PAGE(shadow_addr)) | 202 | if (!VALID_PAGE(shadow_addr)) |
206 | return ERR_PTR(-ENOMEM); | 203 | return ERR_PTR(-ENOMEM); |
207 | if (!kvm_arch_ops->is_long_mode(vcpu) && level == 3) | 204 | shadow_pte = shadow_addr | PT_PRESENT_MASK; |
208 | *shadow_ent = shadow_addr | | 205 | if (vcpu->mmu.root_level > 3 || level != 3) |
209 | (*guest_ent & (PT_PRESENT_MASK | PT_PWT_MASK | PT_PCD_MASK)); | 206 | shadow_pte |= PT_ACCESSED_MASK |
210 | else { | 207 | | PT_WRITABLE_MASK | PT_USER_MASK; |
211 | *shadow_ent = shadow_addr | | 208 | *shadow_ent = shadow_pte; |
212 | (*guest_ent & PT_NON_PTE_COPY_MASK); | ||
213 | *shadow_ent |= (PT_WRITABLE_MASK | PT_USER_MASK); | ||
214 | } | ||
215 | prev_shadow_ent = shadow_ent; | 209 | prev_shadow_ent = shadow_ent; |
216 | } | 210 | } |
217 | } | 211 | } |
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c index a33a89c68138..0e6bc8c649ce 100644 --- a/drivers/kvm/svm.c +++ b/drivers/kvm/svm.c | |||
@@ -287,7 +287,7 @@ static void svm_hardware_enable(void *garbage) | |||
287 | 287 | ||
288 | struct svm_cpu_data *svm_data; | 288 | struct svm_cpu_data *svm_data; |
289 | uint64_t efer; | 289 | uint64_t efer; |
290 | #ifdef __x86_64__ | 290 | #ifdef CONFIG_X86_64 |
291 | struct desc_ptr gdt_descr; | 291 | struct desc_ptr gdt_descr; |
292 | #else | 292 | #else |
293 | struct Xgt_desc_struct gdt_descr; | 293 | struct Xgt_desc_struct gdt_descr; |
@@ -377,6 +377,7 @@ static __init int svm_hardware_setup(void) | |||
377 | void *msrpm_va; | 377 | void *msrpm_va; |
378 | int r; | 378 | int r; |
379 | 379 | ||
380 | kvm_emulator_want_group7_invlpg(); | ||
380 | 381 | ||
381 | iopm_pages = alloc_pages(GFP_KERNEL, IOPM_ALLOC_ORDER); | 382 | iopm_pages = alloc_pages(GFP_KERNEL, IOPM_ALLOC_ORDER); |
382 | 383 | ||
@@ -397,7 +398,7 @@ static __init int svm_hardware_setup(void) | |||
397 | memset(msrpm_va, 0xff, PAGE_SIZE * (1 << MSRPM_ALLOC_ORDER)); | 398 | memset(msrpm_va, 0xff, PAGE_SIZE * (1 << MSRPM_ALLOC_ORDER)); |
398 | msrpm_base = page_to_pfn(msrpm_pages) << PAGE_SHIFT; | 399 | msrpm_base = page_to_pfn(msrpm_pages) << PAGE_SHIFT; |
399 | 400 | ||
400 | #ifdef __x86_64__ | 401 | #ifdef CONFIG_X86_64 |
401 | set_msr_interception(msrpm_va, MSR_GS_BASE, 1, 1); | 402 | set_msr_interception(msrpm_va, MSR_GS_BASE, 1, 1); |
402 | set_msr_interception(msrpm_va, MSR_FS_BASE, 1, 1); | 403 | set_msr_interception(msrpm_va, MSR_FS_BASE, 1, 1); |
403 | set_msr_interception(msrpm_va, MSR_KERNEL_GS_BASE, 1, 1); | 404 | set_msr_interception(msrpm_va, MSR_KERNEL_GS_BASE, 1, 1); |
@@ -704,7 +705,7 @@ static void svm_set_gdt(struct kvm_vcpu *vcpu, struct descriptor_table *dt) | |||
704 | 705 | ||
705 | static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) | 706 | static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) |
706 | { | 707 | { |
707 | #ifdef __x86_64__ | 708 | #ifdef CONFIG_X86_64 |
708 | if (vcpu->shadow_efer & KVM_EFER_LME) { | 709 | if (vcpu->shadow_efer & KVM_EFER_LME) { |
709 | if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK)) { | 710 | if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK)) { |
710 | vcpu->shadow_efer |= KVM_EFER_LMA; | 711 | vcpu->shadow_efer |= KVM_EFER_LMA; |
@@ -1097,7 +1098,7 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 *data) | |||
1097 | case MSR_IA32_APICBASE: | 1098 | case MSR_IA32_APICBASE: |
1098 | *data = vcpu->apic_base; | 1099 | *data = vcpu->apic_base; |
1099 | break; | 1100 | break; |
1100 | #ifdef __x86_64__ | 1101 | #ifdef CONFIG_X86_64 |
1101 | case MSR_STAR: | 1102 | case MSR_STAR: |
1102 | *data = vcpu->svm->vmcb->save.star; | 1103 | *data = vcpu->svm->vmcb->save.star; |
1103 | break; | 1104 | break; |
@@ -1149,7 +1150,7 @@ static int rdmsr_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
1149 | static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data) | 1150 | static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data) |
1150 | { | 1151 | { |
1151 | switch (ecx) { | 1152 | switch (ecx) { |
1152 | #ifdef __x86_64__ | 1153 | #ifdef CONFIG_X86_64 |
1153 | case MSR_EFER: | 1154 | case MSR_EFER: |
1154 | set_efer(vcpu, data); | 1155 | set_efer(vcpu, data); |
1155 | break; | 1156 | break; |
@@ -1172,7 +1173,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data) | |||
1172 | case MSR_IA32_APICBASE: | 1173 | case MSR_IA32_APICBASE: |
1173 | vcpu->apic_base = data; | 1174 | vcpu->apic_base = data; |
1174 | break; | 1175 | break; |
1175 | #ifdef __x86_64___ | 1176 | #ifdef CONFIG_X86_64_ |
1176 | case MSR_STAR: | 1177 | case MSR_STAR: |
1177 | vcpu->svm->vmcb->save.star = data; | 1178 | vcpu->svm->vmcb->save.star = data; |
1178 | break; | 1179 | break; |
@@ -1345,53 +1346,18 @@ static void kvm_reput_irq(struct kvm_vcpu *vcpu) | |||
1345 | 1346 | ||
1346 | static void save_db_regs(unsigned long *db_regs) | 1347 | static void save_db_regs(unsigned long *db_regs) |
1347 | { | 1348 | { |
1348 | #ifdef __x86_64__ | 1349 | asm volatile ("mov %%dr0, %0" : "=r"(db_regs[0])); |
1349 | asm ("mov %%dr0, %%rax \n\t" | 1350 | asm volatile ("mov %%dr1, %0" : "=r"(db_regs[1])); |
1350 | "mov %%rax, %[dr0] \n\t" | 1351 | asm volatile ("mov %%dr2, %0" : "=r"(db_regs[2])); |
1351 | "mov %%dr1, %%rax \n\t" | 1352 | asm volatile ("mov %%dr3, %0" : "=r"(db_regs[3])); |
1352 | "mov %%rax, %[dr1] \n\t" | ||
1353 | "mov %%dr2, %%rax \n\t" | ||
1354 | "mov %%rax, %[dr2] \n\t" | ||
1355 | "mov %%dr3, %%rax \n\t" | ||
1356 | "mov %%rax, %[dr3] \n\t" | ||
1357 | : [dr0] "=m"(db_regs[0]), | ||
1358 | [dr1] "=m"(db_regs[1]), | ||
1359 | [dr2] "=m"(db_regs[2]), | ||
1360 | [dr3] "=m"(db_regs[3]) | ||
1361 | : : "rax"); | ||
1362 | #else | ||
1363 | asm ("mov %%dr0, %%eax \n\t" | ||
1364 | "mov %%eax, %[dr0] \n\t" | ||
1365 | "mov %%dr1, %%eax \n\t" | ||
1366 | "mov %%eax, %[dr1] \n\t" | ||
1367 | "mov %%dr2, %%eax \n\t" | ||
1368 | "mov %%eax, %[dr2] \n\t" | ||
1369 | "mov %%dr3, %%eax \n\t" | ||
1370 | "mov %%eax, %[dr3] \n\t" | ||
1371 | : [dr0] "=m"(db_regs[0]), | ||
1372 | [dr1] "=m"(db_regs[1]), | ||
1373 | [dr2] "=m"(db_regs[2]), | ||
1374 | [dr3] "=m"(db_regs[3]) | ||
1375 | : : "eax"); | ||
1376 | #endif | ||
1377 | } | 1353 | } |
1378 | 1354 | ||
1379 | static void load_db_regs(unsigned long *db_regs) | 1355 | static void load_db_regs(unsigned long *db_regs) |
1380 | { | 1356 | { |
1381 | asm volatile ("mov %[dr0], %%dr0 \n\t" | 1357 | asm volatile ("mov %0, %%dr0" : : "r"(db_regs[0])); |
1382 | "mov %[dr1], %%dr1 \n\t" | 1358 | asm volatile ("mov %0, %%dr1" : : "r"(db_regs[1])); |
1383 | "mov %[dr2], %%dr2 \n\t" | 1359 | asm volatile ("mov %0, %%dr2" : : "r"(db_regs[2])); |
1384 | "mov %[dr3], %%dr3 \n\t" | 1360 | asm volatile ("mov %0, %%dr3" : : "r"(db_regs[3])); |
1385 | : | ||
1386 | : [dr0] "r"(db_regs[0]), | ||
1387 | [dr1] "r"(db_regs[1]), | ||
1388 | [dr2] "r"(db_regs[2]), | ||
1389 | [dr3] "r"(db_regs[3]) | ||
1390 | #ifdef __x86_64__ | ||
1391 | : "rax"); | ||
1392 | #else | ||
1393 | : "eax"); | ||
1394 | #endif | ||
1395 | } | 1361 | } |
1396 | 1362 | ||
1397 | static int svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | 1363 | static int svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) |
@@ -1422,7 +1388,7 @@ again: | |||
1422 | load_db_regs(vcpu->svm->db_regs); | 1388 | load_db_regs(vcpu->svm->db_regs); |
1423 | } | 1389 | } |
1424 | asm volatile ( | 1390 | asm volatile ( |
1425 | #ifdef __x86_64__ | 1391 | #ifdef CONFIG_X86_64 |
1426 | "push %%rbx; push %%rcx; push %%rdx;" | 1392 | "push %%rbx; push %%rcx; push %%rdx;" |
1427 | "push %%rsi; push %%rdi; push %%rbp;" | 1393 | "push %%rsi; push %%rdi; push %%rbp;" |
1428 | "push %%r8; push %%r9; push %%r10; push %%r11;" | 1394 | "push %%r8; push %%r9; push %%r10; push %%r11;" |
@@ -1432,7 +1398,7 @@ again: | |||
1432 | "push %%esi; push %%edi; push %%ebp;" | 1398 | "push %%esi; push %%edi; push %%ebp;" |
1433 | #endif | 1399 | #endif |
1434 | 1400 | ||
1435 | #ifdef __x86_64__ | 1401 | #ifdef CONFIG_X86_64 |
1436 | "mov %c[rbx](%[vcpu]), %%rbx \n\t" | 1402 | "mov %c[rbx](%[vcpu]), %%rbx \n\t" |
1437 | "mov %c[rcx](%[vcpu]), %%rcx \n\t" | 1403 | "mov %c[rcx](%[vcpu]), %%rcx \n\t" |
1438 | "mov %c[rdx](%[vcpu]), %%rdx \n\t" | 1404 | "mov %c[rdx](%[vcpu]), %%rdx \n\t" |
@@ -1456,7 +1422,7 @@ again: | |||
1456 | "mov %c[rbp](%[vcpu]), %%ebp \n\t" | 1422 | "mov %c[rbp](%[vcpu]), %%ebp \n\t" |
1457 | #endif | 1423 | #endif |
1458 | 1424 | ||
1459 | #ifdef __x86_64__ | 1425 | #ifdef CONFIG_X86_64 |
1460 | /* Enter guest mode */ | 1426 | /* Enter guest mode */ |
1461 | "push %%rax \n\t" | 1427 | "push %%rax \n\t" |
1462 | "mov %c[svm](%[vcpu]), %%rax \n\t" | 1428 | "mov %c[svm](%[vcpu]), %%rax \n\t" |
@@ -1477,7 +1443,7 @@ again: | |||
1477 | #endif | 1443 | #endif |
1478 | 1444 | ||
1479 | /* Save guest registers, load host registers */ | 1445 | /* Save guest registers, load host registers */ |
1480 | #ifdef __x86_64__ | 1446 | #ifdef CONFIG_X86_64 |
1481 | "mov %%rbx, %c[rbx](%[vcpu]) \n\t" | 1447 | "mov %%rbx, %c[rbx](%[vcpu]) \n\t" |
1482 | "mov %%rcx, %c[rcx](%[vcpu]) \n\t" | 1448 | "mov %%rcx, %c[rcx](%[vcpu]) \n\t" |
1483 | "mov %%rdx, %c[rdx](%[vcpu]) \n\t" | 1449 | "mov %%rdx, %c[rdx](%[vcpu]) \n\t" |
@@ -1518,7 +1484,7 @@ again: | |||
1518 | [rsi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RSI])), | 1484 | [rsi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RSI])), |
1519 | [rdi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RDI])), | 1485 | [rdi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RDI])), |
1520 | [rbp]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RBP])) | 1486 | [rbp]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RBP])) |
1521 | #ifdef __x86_64__ | 1487 | #ifdef CONFIG_X86_64 |
1522 | ,[r8 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R8 ])), | 1488 | ,[r8 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R8 ])), |
1523 | [r9 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R9 ])), | 1489 | [r9 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R9 ])), |
1524 | [r10]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R10])), | 1490 | [r10]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R10])), |
@@ -1663,9 +1629,7 @@ static struct kvm_arch_ops svm_arch_ops = { | |||
1663 | 1629 | ||
1664 | static int __init svm_init(void) | 1630 | static int __init svm_init(void) |
1665 | { | 1631 | { |
1666 | kvm_emulator_want_group7_invlpg(); | 1632 | return kvm_init_arch(&svm_arch_ops, THIS_MODULE); |
1667 | kvm_init_arch(&svm_arch_ops, THIS_MODULE); | ||
1668 | return 0; | ||
1669 | } | 1633 | } |
1670 | 1634 | ||
1671 | static void __exit svm_exit(void) | 1635 | static void __exit svm_exit(void) |
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c index bda7a7ae2167..f0f0b1a781f8 100644 --- a/drivers/kvm/vmx.c +++ b/drivers/kvm/vmx.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
23 | #include <linux/highmem.h> | 23 | #include <linux/highmem.h> |
24 | #include <asm/io.h> | 24 | #include <asm/io.h> |
25 | #include <asm/desc.h> | ||
25 | 26 | ||
26 | #include "segment_descriptor.h" | 27 | #include "segment_descriptor.h" |
27 | 28 | ||
@@ -33,7 +34,7 @@ MODULE_LICENSE("GPL"); | |||
33 | static DEFINE_PER_CPU(struct vmcs *, vmxarea); | 34 | static DEFINE_PER_CPU(struct vmcs *, vmxarea); |
34 | static DEFINE_PER_CPU(struct vmcs *, current_vmcs); | 35 | static DEFINE_PER_CPU(struct vmcs *, current_vmcs); |
35 | 36 | ||
36 | #ifdef __x86_64__ | 37 | #ifdef CONFIG_X86_64 |
37 | #define HOST_IS_64 1 | 38 | #define HOST_IS_64 1 |
38 | #else | 39 | #else |
39 | #define HOST_IS_64 0 | 40 | #define HOST_IS_64 0 |
@@ -70,15 +71,13 @@ static struct kvm_vmx_segment_field { | |||
70 | }; | 71 | }; |
71 | 72 | ||
72 | static const u32 vmx_msr_index[] = { | 73 | static const u32 vmx_msr_index[] = { |
73 | #ifdef __x86_64__ | 74 | #ifdef CONFIG_X86_64 |
74 | MSR_SYSCALL_MASK, MSR_LSTAR, MSR_CSTAR, MSR_KERNEL_GS_BASE, | 75 | MSR_SYSCALL_MASK, MSR_LSTAR, MSR_CSTAR, MSR_KERNEL_GS_BASE, |
75 | #endif | 76 | #endif |
76 | MSR_EFER, MSR_K6_STAR, | 77 | MSR_EFER, MSR_K6_STAR, |
77 | }; | 78 | }; |
78 | #define NR_VMX_MSR (sizeof(vmx_msr_index) / sizeof(*vmx_msr_index)) | 79 | #define NR_VMX_MSR (sizeof(vmx_msr_index) / sizeof(*vmx_msr_index)) |
79 | 80 | ||
80 | struct vmx_msr_entry *find_msr_entry(struct kvm_vcpu *vcpu, u32 msr); | ||
81 | |||
82 | static inline int is_page_fault(u32 intr_info) | 81 | static inline int is_page_fault(u32 intr_info) |
83 | { | 82 | { |
84 | return (intr_info & (INTR_INFO_INTR_TYPE_MASK | INTR_INFO_VECTOR_MASK | | 83 | return (intr_info & (INTR_INFO_INTR_TYPE_MASK | INTR_INFO_VECTOR_MASK | |
@@ -92,6 +91,16 @@ static inline int is_external_interrupt(u32 intr_info) | |||
92 | == (INTR_TYPE_EXT_INTR | INTR_INFO_VALID_MASK); | 91 | == (INTR_TYPE_EXT_INTR | INTR_INFO_VALID_MASK); |
93 | } | 92 | } |
94 | 93 | ||
94 | static struct vmx_msr_entry *find_msr_entry(struct kvm_vcpu *vcpu, u32 msr) | ||
95 | { | ||
96 | int i; | ||
97 | |||
98 | for (i = 0; i < vcpu->nmsrs; ++i) | ||
99 | if (vcpu->guest_msrs[i].index == msr) | ||
100 | return &vcpu->guest_msrs[i]; | ||
101 | return 0; | ||
102 | } | ||
103 | |||
95 | static void vmcs_clear(struct vmcs *vmcs) | 104 | static void vmcs_clear(struct vmcs *vmcs) |
96 | { | 105 | { |
97 | u64 phys_addr = __pa(vmcs); | 106 | u64 phys_addr = __pa(vmcs); |
@@ -137,7 +146,7 @@ static u32 vmcs_read32(unsigned long field) | |||
137 | 146 | ||
138 | static u64 vmcs_read64(unsigned long field) | 147 | static u64 vmcs_read64(unsigned long field) |
139 | { | 148 | { |
140 | #ifdef __x86_64__ | 149 | #ifdef CONFIG_X86_64 |
141 | return vmcs_readl(field); | 150 | return vmcs_readl(field); |
142 | #else | 151 | #else |
143 | return vmcs_readl(field) | ((u64)vmcs_readl(field+1) << 32); | 152 | return vmcs_readl(field) | ((u64)vmcs_readl(field+1) << 32); |
@@ -167,7 +176,7 @@ static void vmcs_write32(unsigned long field, u32 value) | |||
167 | 176 | ||
168 | static void vmcs_write64(unsigned long field, u64 value) | 177 | static void vmcs_write64(unsigned long field, u64 value) |
169 | { | 178 | { |
170 | #ifdef __x86_64__ | 179 | #ifdef CONFIG_X86_64 |
171 | vmcs_writel(field, value); | 180 | vmcs_writel(field, value); |
172 | #else | 181 | #else |
173 | vmcs_writel(field, value); | 182 | vmcs_writel(field, value); |
@@ -296,7 +305,7 @@ static void guest_write_tsc(u64 guest_tsc) | |||
296 | 305 | ||
297 | static void reload_tss(void) | 306 | static void reload_tss(void) |
298 | { | 307 | { |
299 | #ifndef __x86_64__ | 308 | #ifndef CONFIG_X86_64 |
300 | 309 | ||
301 | /* | 310 | /* |
302 | * VT restores TR but not its size. Useless. | 311 | * VT restores TR but not its size. Useless. |
@@ -327,7 +336,7 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata) | |||
327 | } | 336 | } |
328 | 337 | ||
329 | switch (msr_index) { | 338 | switch (msr_index) { |
330 | #ifdef __x86_64__ | 339 | #ifdef CONFIG_X86_64 |
331 | case MSR_FS_BASE: | 340 | case MSR_FS_BASE: |
332 | data = vmcs_readl(GUEST_FS_BASE); | 341 | data = vmcs_readl(GUEST_FS_BASE); |
333 | break; | 342 | break; |
@@ -390,7 +399,7 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data) | |||
390 | { | 399 | { |
391 | struct vmx_msr_entry *msr; | 400 | struct vmx_msr_entry *msr; |
392 | switch (msr_index) { | 401 | switch (msr_index) { |
393 | #ifdef __x86_64__ | 402 | #ifdef CONFIG_X86_64 |
394 | case MSR_FS_BASE: | 403 | case MSR_FS_BASE: |
395 | vmcs_writel(GUEST_FS_BASE, data); | 404 | vmcs_writel(GUEST_FS_BASE, data); |
396 | break; | 405 | break; |
@@ -525,7 +534,7 @@ static __init void hardware_enable(void *garbage) | |||
525 | u64 old; | 534 | u64 old; |
526 | 535 | ||
527 | rdmsrl(MSR_IA32_FEATURE_CONTROL, old); | 536 | rdmsrl(MSR_IA32_FEATURE_CONTROL, old); |
528 | if ((old & 5) == 0) | 537 | if ((old & 5) != 5) |
529 | /* enable and lock */ | 538 | /* enable and lock */ |
530 | wrmsrl(MSR_IA32_FEATURE_CONTROL, old | 5); | 539 | wrmsrl(MSR_IA32_FEATURE_CONTROL, old | 5); |
531 | write_cr4(read_cr4() | CR4_VMXE); /* FIXME: not cpu hotplug safe */ | 540 | write_cr4(read_cr4() | CR4_VMXE); /* FIXME: not cpu hotplug safe */ |
@@ -725,7 +734,7 @@ static void enter_rmode(struct kvm_vcpu *vcpu) | |||
725 | fix_rmode_seg(VCPU_SREG_FS, &vcpu->rmode.fs); | 734 | fix_rmode_seg(VCPU_SREG_FS, &vcpu->rmode.fs); |
726 | } | 735 | } |
727 | 736 | ||
728 | #ifdef __x86_64__ | 737 | #ifdef CONFIG_X86_64 |
729 | 738 | ||
730 | static void enter_lmode(struct kvm_vcpu *vcpu) | 739 | static void enter_lmode(struct kvm_vcpu *vcpu) |
731 | { | 740 | { |
@@ -767,7 +776,7 @@ static void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) | |||
767 | if (!vcpu->rmode.active && !(cr0 & CR0_PE_MASK)) | 776 | if (!vcpu->rmode.active && !(cr0 & CR0_PE_MASK)) |
768 | enter_rmode(vcpu); | 777 | enter_rmode(vcpu); |
769 | 778 | ||
770 | #ifdef __x86_64__ | 779 | #ifdef CONFIG_X86_64 |
771 | if (vcpu->shadow_efer & EFER_LME) { | 780 | if (vcpu->shadow_efer & EFER_LME) { |
772 | if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK)) | 781 | if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK)) |
773 | enter_lmode(vcpu); | 782 | enter_lmode(vcpu); |
@@ -808,7 +817,7 @@ static void vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) | |||
808 | vcpu->cr4 = cr4; | 817 | vcpu->cr4 = cr4; |
809 | } | 818 | } |
810 | 819 | ||
811 | #ifdef __x86_64__ | 820 | #ifdef CONFIG_X86_64 |
812 | 821 | ||
813 | static void vmx_set_efer(struct kvm_vcpu *vcpu, u64 efer) | 822 | static void vmx_set_efer(struct kvm_vcpu *vcpu, u64 efer) |
814 | { | 823 | { |
@@ -883,6 +892,8 @@ static void vmx_set_segment(struct kvm_vcpu *vcpu, | |||
883 | ar |= (var->db & 1) << 14; | 892 | ar |= (var->db & 1) << 14; |
884 | ar |= (var->g & 1) << 15; | 893 | ar |= (var->g & 1) << 15; |
885 | } | 894 | } |
895 | if (ar == 0) /* a 0 value means unusable */ | ||
896 | ar = AR_UNUSABLE_MASK; | ||
886 | vmcs_write32(sf->ar_bytes, ar); | 897 | vmcs_write32(sf->ar_bytes, ar); |
887 | } | 898 | } |
888 | 899 | ||
@@ -1095,7 +1106,7 @@ static int vmx_vcpu_setup(struct kvm_vcpu *vcpu) | |||
1095 | vmcs_write16(HOST_FS_SELECTOR, read_fs()); /* 22.2.4 */ | 1106 | vmcs_write16(HOST_FS_SELECTOR, read_fs()); /* 22.2.4 */ |
1096 | vmcs_write16(HOST_GS_SELECTOR, read_gs()); /* 22.2.4 */ | 1107 | vmcs_write16(HOST_GS_SELECTOR, read_gs()); /* 22.2.4 */ |
1097 | vmcs_write16(HOST_SS_SELECTOR, __KERNEL_DS); /* 22.2.4 */ | 1108 | vmcs_write16(HOST_SS_SELECTOR, __KERNEL_DS); /* 22.2.4 */ |
1098 | #ifdef __x86_64__ | 1109 | #ifdef CONFIG_X86_64 |
1099 | rdmsrl(MSR_FS_BASE, a); | 1110 | rdmsrl(MSR_FS_BASE, a); |
1100 | vmcs_writel(HOST_FS_BASE, a); /* 22.2.4 */ | 1111 | vmcs_writel(HOST_FS_BASE, a); /* 22.2.4 */ |
1101 | rdmsrl(MSR_GS_BASE, a); | 1112 | rdmsrl(MSR_GS_BASE, a); |
@@ -1164,8 +1175,10 @@ static int vmx_vcpu_setup(struct kvm_vcpu *vcpu) | |||
1164 | VM_ENTRY_CONTROLS, 0); | 1175 | VM_ENTRY_CONTROLS, 0); |
1165 | vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 0); /* 22.2.1 */ | 1176 | vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 0); /* 22.2.1 */ |
1166 | 1177 | ||
1178 | #ifdef CONFIG_X86_64 | ||
1167 | vmcs_writel(VIRTUAL_APIC_PAGE_ADDR, 0); | 1179 | vmcs_writel(VIRTUAL_APIC_PAGE_ADDR, 0); |
1168 | vmcs_writel(TPR_THRESHOLD, 0); | 1180 | vmcs_writel(TPR_THRESHOLD, 0); |
1181 | #endif | ||
1169 | 1182 | ||
1170 | vmcs_writel(CR0_GUEST_HOST_MASK, KVM_GUEST_CR0_MASK); | 1183 | vmcs_writel(CR0_GUEST_HOST_MASK, KVM_GUEST_CR0_MASK); |
1171 | vmcs_writel(CR4_GUEST_HOST_MASK, KVM_GUEST_CR4_MASK); | 1184 | vmcs_writel(CR4_GUEST_HOST_MASK, KVM_GUEST_CR4_MASK); |
@@ -1173,7 +1186,7 @@ static int vmx_vcpu_setup(struct kvm_vcpu *vcpu) | |||
1173 | vcpu->cr0 = 0x60000010; | 1186 | vcpu->cr0 = 0x60000010; |
1174 | vmx_set_cr0(vcpu, vcpu->cr0); // enter rmode | 1187 | vmx_set_cr0(vcpu, vcpu->cr0); // enter rmode |
1175 | vmx_set_cr4(vcpu, 0); | 1188 | vmx_set_cr4(vcpu, 0); |
1176 | #ifdef __x86_64__ | 1189 | #ifdef CONFIG_X86_64 |
1177 | vmx_set_efer(vcpu, 0); | 1190 | vmx_set_efer(vcpu, 0); |
1178 | #endif | 1191 | #endif |
1179 | 1192 | ||
@@ -1689,7 +1702,7 @@ again: | |||
1689 | vmcs_write16(HOST_GS_SELECTOR, 0); | 1702 | vmcs_write16(HOST_GS_SELECTOR, 0); |
1690 | } | 1703 | } |
1691 | 1704 | ||
1692 | #ifdef __x86_64__ | 1705 | #ifdef CONFIG_X86_64 |
1693 | vmcs_writel(HOST_FS_BASE, read_msr(MSR_FS_BASE)); | 1706 | vmcs_writel(HOST_FS_BASE, read_msr(MSR_FS_BASE)); |
1694 | vmcs_writel(HOST_GS_BASE, read_msr(MSR_GS_BASE)); | 1707 | vmcs_writel(HOST_GS_BASE, read_msr(MSR_GS_BASE)); |
1695 | #else | 1708 | #else |
@@ -1713,7 +1726,7 @@ again: | |||
1713 | asm ( | 1726 | asm ( |
1714 | /* Store host registers */ | 1727 | /* Store host registers */ |
1715 | "pushf \n\t" | 1728 | "pushf \n\t" |
1716 | #ifdef __x86_64__ | 1729 | #ifdef CONFIG_X86_64 |
1717 | "push %%rax; push %%rbx; push %%rdx;" | 1730 | "push %%rax; push %%rbx; push %%rdx;" |
1718 | "push %%rsi; push %%rdi; push %%rbp;" | 1731 | "push %%rsi; push %%rdi; push %%rbp;" |
1719 | "push %%r8; push %%r9; push %%r10; push %%r11;" | 1732 | "push %%r8; push %%r9; push %%r10; push %%r11;" |
@@ -1727,7 +1740,7 @@ again: | |||
1727 | /* Check if vmlaunch of vmresume is needed */ | 1740 | /* Check if vmlaunch of vmresume is needed */ |
1728 | "cmp $0, %1 \n\t" | 1741 | "cmp $0, %1 \n\t" |
1729 | /* Load guest registers. Don't clobber flags. */ | 1742 | /* Load guest registers. Don't clobber flags. */ |
1730 | #ifdef __x86_64__ | 1743 | #ifdef CONFIG_X86_64 |
1731 | "mov %c[cr2](%3), %%rax \n\t" | 1744 | "mov %c[cr2](%3), %%rax \n\t" |
1732 | "mov %%rax, %%cr2 \n\t" | 1745 | "mov %%rax, %%cr2 \n\t" |
1733 | "mov %c[rax](%3), %%rax \n\t" | 1746 | "mov %c[rax](%3), %%rax \n\t" |
@@ -1764,7 +1777,7 @@ again: | |||
1764 | ".globl kvm_vmx_return \n\t" | 1777 | ".globl kvm_vmx_return \n\t" |
1765 | "kvm_vmx_return: " | 1778 | "kvm_vmx_return: " |
1766 | /* Save guest registers, load host registers, keep flags */ | 1779 | /* Save guest registers, load host registers, keep flags */ |
1767 | #ifdef __x86_64__ | 1780 | #ifdef CONFIG_X86_64 |
1768 | "xchg %3, 0(%%rsp) \n\t" | 1781 | "xchg %3, 0(%%rsp) \n\t" |
1769 | "mov %%rax, %c[rax](%3) \n\t" | 1782 | "mov %%rax, %c[rax](%3) \n\t" |
1770 | "mov %%rbx, %c[rbx](%3) \n\t" | 1783 | "mov %%rbx, %c[rbx](%3) \n\t" |
@@ -1816,7 +1829,7 @@ again: | |||
1816 | [rsi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RSI])), | 1829 | [rsi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RSI])), |
1817 | [rdi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RDI])), | 1830 | [rdi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RDI])), |
1818 | [rbp]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RBP])), | 1831 | [rbp]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RBP])), |
1819 | #ifdef __x86_64__ | 1832 | #ifdef CONFIG_X86_64 |
1820 | [r8 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R8 ])), | 1833 | [r8 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R8 ])), |
1821 | [r9 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R9 ])), | 1834 | [r9 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R9 ])), |
1822 | [r10]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R10])), | 1835 | [r10]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R10])), |
@@ -1837,7 +1850,7 @@ again: | |||
1837 | fx_save(vcpu->guest_fx_image); | 1850 | fx_save(vcpu->guest_fx_image); |
1838 | fx_restore(vcpu->host_fx_image); | 1851 | fx_restore(vcpu->host_fx_image); |
1839 | 1852 | ||
1840 | #ifndef __x86_64__ | 1853 | #ifndef CONFIG_X86_64 |
1841 | asm ("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS)); | 1854 | asm ("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS)); |
1842 | #endif | 1855 | #endif |
1843 | 1856 | ||
@@ -1855,7 +1868,7 @@ again: | |||
1855 | */ | 1868 | */ |
1856 | local_irq_disable(); | 1869 | local_irq_disable(); |
1857 | load_gs(gs_sel); | 1870 | load_gs(gs_sel); |
1858 | #ifdef __x86_64__ | 1871 | #ifdef CONFIG_X86_64 |
1859 | wrmsrl(MSR_GS_BASE, vmcs_readl(HOST_GS_BASE)); | 1872 | wrmsrl(MSR_GS_BASE, vmcs_readl(HOST_GS_BASE)); |
1860 | #endif | 1873 | #endif |
1861 | local_irq_enable(); | 1874 | local_irq_enable(); |
@@ -1965,7 +1978,7 @@ static struct kvm_arch_ops vmx_arch_ops = { | |||
1965 | .set_cr0_no_modeswitch = vmx_set_cr0_no_modeswitch, | 1978 | .set_cr0_no_modeswitch = vmx_set_cr0_no_modeswitch, |
1966 | .set_cr3 = vmx_set_cr3, | 1979 | .set_cr3 = vmx_set_cr3, |
1967 | .set_cr4 = vmx_set_cr4, | 1980 | .set_cr4 = vmx_set_cr4, |
1968 | #ifdef __x86_64__ | 1981 | #ifdef CONFIG_X86_64 |
1969 | .set_efer = vmx_set_efer, | 1982 | .set_efer = vmx_set_efer, |
1970 | #endif | 1983 | #endif |
1971 | .get_idt = vmx_get_idt, | 1984 | .get_idt = vmx_get_idt, |
@@ -1989,8 +2002,7 @@ static struct kvm_arch_ops vmx_arch_ops = { | |||
1989 | 2002 | ||
1990 | static int __init vmx_init(void) | 2003 | static int __init vmx_init(void) |
1991 | { | 2004 | { |
1992 | kvm_init_arch(&vmx_arch_ops, THIS_MODULE); | 2005 | return kvm_init_arch(&vmx_arch_ops, THIS_MODULE); |
1993 | return 0; | ||
1994 | } | 2006 | } |
1995 | 2007 | ||
1996 | static void __exit vmx_exit(void) | 2008 | static void __exit vmx_exit(void) |
diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c index 7e838bf0592d..1bff3e925fda 100644 --- a/drivers/kvm/x86_emulate.c +++ b/drivers/kvm/x86_emulate.c | |||
@@ -238,7 +238,7 @@ struct operand { | |||
238 | * any modified flags. | 238 | * any modified flags. |
239 | */ | 239 | */ |
240 | 240 | ||
241 | #if defined(__x86_64__) | 241 | #if defined(CONFIG_X86_64) |
242 | #define _LO32 "k" /* force 32-bit operand */ | 242 | #define _LO32 "k" /* force 32-bit operand */ |
243 | #define _STK "%%rsp" /* stack pointer */ | 243 | #define _STK "%%rsp" /* stack pointer */ |
244 | #elif defined(__i386__) | 244 | #elif defined(__i386__) |
@@ -385,7 +385,7 @@ struct operand { | |||
385 | } while (0) | 385 | } while (0) |
386 | 386 | ||
387 | /* Emulate an instruction with quadword operands (x86/64 only). */ | 387 | /* Emulate an instruction with quadword operands (x86/64 only). */ |
388 | #if defined(__x86_64__) | 388 | #if defined(CONFIG_X86_64) |
389 | #define __emulate_2op_8byte(_op, _src, _dst, _eflags, _qx, _qy) \ | 389 | #define __emulate_2op_8byte(_op, _src, _dst, _eflags, _qx, _qy) \ |
390 | do { \ | 390 | do { \ |
391 | __asm__ __volatile__ ( \ | 391 | __asm__ __volatile__ ( \ |
@@ -495,7 +495,7 @@ x86_emulate_memop(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) | |||
495 | case X86EMUL_MODE_PROT32: | 495 | case X86EMUL_MODE_PROT32: |
496 | op_bytes = ad_bytes = 4; | 496 | op_bytes = ad_bytes = 4; |
497 | break; | 497 | break; |
498 | #ifdef __x86_64__ | 498 | #ifdef CONFIG_X86_64 |
499 | case X86EMUL_MODE_PROT64: | 499 | case X86EMUL_MODE_PROT64: |
500 | op_bytes = 4; | 500 | op_bytes = 4; |
501 | ad_bytes = 8; | 501 | ad_bytes = 8; |
@@ -1341,7 +1341,7 @@ twobyte_special_insn: | |||
1341 | } | 1341 | } |
1342 | break; | 1342 | break; |
1343 | } | 1343 | } |
1344 | #elif defined(__x86_64__) | 1344 | #elif defined(CONFIG_X86_64) |
1345 | { | 1345 | { |
1346 | unsigned long old, new; | 1346 | unsigned long old, new; |
1347 | if ((rc = ops->read_emulated(cr2, &old, 8, ctxt)) != 0) | 1347 | if ((rc = ops->read_emulated(cr2, &old, 8, ctxt)) != 0) |
diff --git a/drivers/kvm/x86_emulate.h b/drivers/kvm/x86_emulate.h index 658b58de30fc..5d41bd55125e 100644 --- a/drivers/kvm/x86_emulate.h +++ b/drivers/kvm/x86_emulate.h | |||
@@ -162,7 +162,7 @@ struct x86_emulate_ctxt { | |||
162 | /* Host execution mode. */ | 162 | /* Host execution mode. */ |
163 | #if defined(__i386__) | 163 | #if defined(__i386__) |
164 | #define X86EMUL_MODE_HOST X86EMUL_MODE_PROT32 | 164 | #define X86EMUL_MODE_HOST X86EMUL_MODE_PROT32 |
165 | #elif defined(__x86_64__) | 165 | #elif defined(CONFIG_X86_64) |
166 | #define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64 | 166 | #define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64 |
167 | #endif | 167 | #endif |
168 | 168 | ||
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index d43ea81d6df9..7cec6de5e2b0 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c | |||
@@ -828,7 +828,7 @@ static ssize_t adb_write(struct file *file, const char __user *buf, | |||
828 | if (!access_ok(VERIFY_READ, buf, count)) | 828 | if (!access_ok(VERIFY_READ, buf, count)) |
829 | return -EFAULT; | 829 | return -EFAULT; |
830 | 830 | ||
831 | req = (struct adb_request *) kmalloc(sizeof(struct adb_request), | 831 | req = kmalloc(sizeof(struct adb_request), |
832 | GFP_KERNEL); | 832 | GFP_KERNEL); |
833 | if (req == NULL) | 833 | if (req == NULL) |
834 | return -ENOMEM; | 834 | return -ENOMEM; |
diff --git a/drivers/macintosh/apm_emu.c b/drivers/macintosh/apm_emu.c index 8862a83b8d84..4300c628f8af 100644 --- a/drivers/macintosh/apm_emu.c +++ b/drivers/macintosh/apm_emu.c | |||
@@ -321,7 +321,7 @@ static int do_open(struct inode * inode, struct file * filp) | |||
321 | { | 321 | { |
322 | struct apm_user * as; | 322 | struct apm_user * as; |
323 | 323 | ||
324 | as = (struct apm_user *)kmalloc(sizeof(*as), GFP_KERNEL); | 324 | as = kmalloc(sizeof(*as), GFP_KERNEL); |
325 | if (as == NULL) { | 325 | if (as == NULL) { |
326 | printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n", | 326 | printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n", |
327 | sizeof(*as)); | 327 | sizeof(*as)); |
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c index 6dde27ab79a8..6f30459b9385 100644 --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c | |||
@@ -945,7 +945,7 @@ static struct smu_sdbp_header *smu_create_sdb_partition(int id) | |||
945 | */ | 945 | */ |
946 | tlen = sizeof(struct property) + len + 18; | 946 | tlen = sizeof(struct property) + len + 18; |
947 | 947 | ||
948 | prop = kcalloc(tlen, 1, GFP_KERNEL); | 948 | prop = kzalloc(tlen, GFP_KERNEL); |
949 | if (prop == NULL) | 949 | if (prop == NULL) |
950 | return NULL; | 950 | return NULL; |
951 | hdr = (struct smu_sdbp_header *)(prop + 1); | 951 | hdr = (struct smu_sdbp_header *)(prop + 1); |
diff --git a/drivers/macintosh/via-pmu68k.c b/drivers/macintosh/via-pmu68k.c index d9986f3a3fbf..93e6ef9233f9 100644 --- a/drivers/macintosh/via-pmu68k.c +++ b/drivers/macintosh/via-pmu68k.c | |||
@@ -847,7 +847,7 @@ pbook_pci_save(void) | |||
847 | n_pbook_pci_saves = npci; | 847 | n_pbook_pci_saves = npci; |
848 | if (npci == 0) | 848 | if (npci == 0) |
849 | return; | 849 | return; |
850 | ps = (struct pci_save *) kmalloc(npci * sizeof(*ps), GFP_KERNEL); | 850 | ps = kmalloc(npci * sizeof(*ps), GFP_KERNEL); |
851 | pbook_pci_saves = ps; | 851 | pbook_pci_saves = ps; |
852 | if (ps == NULL) | 852 | if (ps == NULL) |
853 | return; | 853 | return; |
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c index a7a5ab554338..4ebd0f2a75ec 100644 --- a/drivers/md/faulty.c +++ b/drivers/md/faulty.c | |||
@@ -173,7 +173,7 @@ static int make_request(request_queue_t *q, struct bio *bio) | |||
173 | conf_t *conf = (conf_t*)mddev->private; | 173 | conf_t *conf = (conf_t*)mddev->private; |
174 | int failit = 0; | 174 | int failit = 0; |
175 | 175 | ||
176 | if (bio->bi_rw & 1) { | 176 | if (bio_data_dir(bio) == WRITE) { |
177 | /* write request */ | 177 | /* write request */ |
178 | if (atomic_read(&conf->counters[WriteAll])) { | 178 | if (atomic_read(&conf->counters[WriteAll])) { |
179 | /* special case - don't decrement, don't generic_make_request, | 179 | /* special case - don't decrement, don't generic_make_request, |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index b3c5e12f081d..b30f74be3982 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -1736,7 +1736,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i | |||
1736 | /* take from bio_init */ | 1736 | /* take from bio_init */ |
1737 | bio->bi_next = NULL; | 1737 | bio->bi_next = NULL; |
1738 | bio->bi_flags |= 1 << BIO_UPTODATE; | 1738 | bio->bi_flags |= 1 << BIO_UPTODATE; |
1739 | bio->bi_rw = 0; | 1739 | bio->bi_rw = READ; |
1740 | bio->bi_vcnt = 0; | 1740 | bio->bi_vcnt = 0; |
1741 | bio->bi_idx = 0; | 1741 | bio->bi_idx = 0; |
1742 | bio->bi_phys_segments = 0; | 1742 | bio->bi_phys_segments = 0; |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 7492d6033ac6..f0141910bb8d 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -1785,7 +1785,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i | |||
1785 | biolist = bio; | 1785 | biolist = bio; |
1786 | bio->bi_private = r10_bio; | 1786 | bio->bi_private = r10_bio; |
1787 | bio->bi_end_io = end_sync_read; | 1787 | bio->bi_end_io = end_sync_read; |
1788 | bio->bi_rw = 0; | 1788 | bio->bi_rw = READ; |
1789 | bio->bi_sector = r10_bio->devs[j].addr + | 1789 | bio->bi_sector = r10_bio->devs[j].addr + |
1790 | conf->mirrors[d].rdev->data_offset; | 1790 | conf->mirrors[d].rdev->data_offset; |
1791 | bio->bi_bdev = conf->mirrors[d].rdev->bdev; | 1791 | bio->bi_bdev = conf->mirrors[d].rdev->bdev; |
@@ -1801,7 +1801,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i | |||
1801 | biolist = bio; | 1801 | biolist = bio; |
1802 | bio->bi_private = r10_bio; | 1802 | bio->bi_private = r10_bio; |
1803 | bio->bi_end_io = end_sync_write; | 1803 | bio->bi_end_io = end_sync_write; |
1804 | bio->bi_rw = 1; | 1804 | bio->bi_rw = WRITE; |
1805 | bio->bi_sector = r10_bio->devs[k].addr + | 1805 | bio->bi_sector = r10_bio->devs[k].addr + |
1806 | conf->mirrors[i].rdev->data_offset; | 1806 | conf->mirrors[i].rdev->data_offset; |
1807 | bio->bi_bdev = conf->mirrors[i].rdev->bdev; | 1807 | bio->bi_bdev = conf->mirrors[i].rdev->bdev; |
@@ -1870,7 +1870,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i | |||
1870 | biolist = bio; | 1870 | biolist = bio; |
1871 | bio->bi_private = r10_bio; | 1871 | bio->bi_private = r10_bio; |
1872 | bio->bi_end_io = end_sync_read; | 1872 | bio->bi_end_io = end_sync_read; |
1873 | bio->bi_rw = 0; | 1873 | bio->bi_rw = READ; |
1874 | bio->bi_sector = r10_bio->devs[i].addr + | 1874 | bio->bi_sector = r10_bio->devs[i].addr + |
1875 | conf->mirrors[d].rdev->data_offset; | 1875 | conf->mirrors[d].rdev->data_offset; |
1876 | bio->bi_bdev = conf->mirrors[d].rdev->bdev; | 1876 | bio->bi_bdev = conf->mirrors[d].rdev->bdev; |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 377f8bc9b78b..be008f034ada 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -1827,16 +1827,16 @@ static void handle_stripe5(struct stripe_head *sh) | |||
1827 | struct bio *bi; | 1827 | struct bio *bi; |
1828 | mdk_rdev_t *rdev; | 1828 | mdk_rdev_t *rdev; |
1829 | if (test_and_clear_bit(R5_Wantwrite, &sh->dev[i].flags)) | 1829 | if (test_and_clear_bit(R5_Wantwrite, &sh->dev[i].flags)) |
1830 | rw = 1; | 1830 | rw = WRITE; |
1831 | else if (test_and_clear_bit(R5_Wantread, &sh->dev[i].flags)) | 1831 | else if (test_and_clear_bit(R5_Wantread, &sh->dev[i].flags)) |
1832 | rw = 0; | 1832 | rw = READ; |
1833 | else | 1833 | else |
1834 | continue; | 1834 | continue; |
1835 | 1835 | ||
1836 | bi = &sh->dev[i].req; | 1836 | bi = &sh->dev[i].req; |
1837 | 1837 | ||
1838 | bi->bi_rw = rw; | 1838 | bi->bi_rw = rw; |
1839 | if (rw) | 1839 | if (rw == WRITE) |
1840 | bi->bi_end_io = raid5_end_write_request; | 1840 | bi->bi_end_io = raid5_end_write_request; |
1841 | else | 1841 | else |
1842 | bi->bi_end_io = raid5_end_read_request; | 1842 | bi->bi_end_io = raid5_end_read_request; |
@@ -1872,7 +1872,7 @@ static void handle_stripe5(struct stripe_head *sh) | |||
1872 | atomic_add(STRIPE_SECTORS, &rdev->corrected_errors); | 1872 | atomic_add(STRIPE_SECTORS, &rdev->corrected_errors); |
1873 | generic_make_request(bi); | 1873 | generic_make_request(bi); |
1874 | } else { | 1874 | } else { |
1875 | if (rw == 1) | 1875 | if (rw == WRITE) |
1876 | set_bit(STRIPE_DEGRADED, &sh->state); | 1876 | set_bit(STRIPE_DEGRADED, &sh->state); |
1877 | PRINTK("skip op %ld on disc %d for sector %llu\n", | 1877 | PRINTK("skip op %ld on disc %d for sector %llu\n", |
1878 | bi->bi_rw, i, (unsigned long long)sh->sector); | 1878 | bi->bi_rw, i, (unsigned long long)sh->sector); |
@@ -2370,16 +2370,16 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page) | |||
2370 | struct bio *bi; | 2370 | struct bio *bi; |
2371 | mdk_rdev_t *rdev; | 2371 | mdk_rdev_t *rdev; |
2372 | if (test_and_clear_bit(R5_Wantwrite, &sh->dev[i].flags)) | 2372 | if (test_and_clear_bit(R5_Wantwrite, &sh->dev[i].flags)) |
2373 | rw = 1; | 2373 | rw = WRITE; |
2374 | else if (test_and_clear_bit(R5_Wantread, &sh->dev[i].flags)) | 2374 | else if (test_and_clear_bit(R5_Wantread, &sh->dev[i].flags)) |
2375 | rw = 0; | 2375 | rw = READ; |
2376 | else | 2376 | else |
2377 | continue; | 2377 | continue; |
2378 | 2378 | ||
2379 | bi = &sh->dev[i].req; | 2379 | bi = &sh->dev[i].req; |
2380 | 2380 | ||
2381 | bi->bi_rw = rw; | 2381 | bi->bi_rw = rw; |
2382 | if (rw) | 2382 | if (rw == WRITE) |
2383 | bi->bi_end_io = raid5_end_write_request; | 2383 | bi->bi_end_io = raid5_end_write_request; |
2384 | else | 2384 | else |
2385 | bi->bi_end_io = raid5_end_read_request; | 2385 | bi->bi_end_io = raid5_end_read_request; |
@@ -2415,7 +2415,7 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page) | |||
2415 | atomic_add(STRIPE_SECTORS, &rdev->corrected_errors); | 2415 | atomic_add(STRIPE_SECTORS, &rdev->corrected_errors); |
2416 | generic_make_request(bi); | 2416 | generic_make_request(bi); |
2417 | } else { | 2417 | } else { |
2418 | if (rw == 1) | 2418 | if (rw == WRITE) |
2419 | set_bit(STRIPE_DEGRADED, &sh->state); | 2419 | set_bit(STRIPE_DEGRADED, &sh->state); |
2420 | PRINTK("skip op %ld on disc %d for sector %llu\n", | 2420 | PRINTK("skip op %ld on disc %d for sector %llu\n", |
2421 | bi->bi_rw, i, (unsigned long long)sh->sector); | 2421 | bi->bi_rw, i, (unsigned long long)sh->sector); |
@@ -2567,7 +2567,7 @@ static int raid5_mergeable_bvec(request_queue_t *q, struct bio *bio, struct bio_ | |||
2567 | unsigned int chunk_sectors = mddev->chunk_size >> 9; | 2567 | unsigned int chunk_sectors = mddev->chunk_size >> 9; |
2568 | unsigned int bio_sectors = bio->bi_size >> 9; | 2568 | unsigned int bio_sectors = bio->bi_size >> 9; |
2569 | 2569 | ||
2570 | if (bio_data_dir(bio)) | 2570 | if (bio_data_dir(bio) == WRITE) |
2571 | return biovec->bv_len; /* always allow writes to be mergeable */ | 2571 | return biovec->bv_len; /* always allow writes to be mergeable */ |
2572 | 2572 | ||
2573 | max = (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) << 9; | 2573 | max = (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) << 9; |
@@ -2751,7 +2751,7 @@ static int make_request(request_queue_t *q, struct bio * bi) | |||
2751 | disk_stat_inc(mddev->gendisk, ios[rw]); | 2751 | disk_stat_inc(mddev->gendisk, ios[rw]); |
2752 | disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bi)); | 2752 | disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bi)); |
2753 | 2753 | ||
2754 | if (bio_data_dir(bi) == READ && | 2754 | if (rw == READ && |
2755 | mddev->reshape_position == MaxSector && | 2755 | mddev->reshape_position == MaxSector && |
2756 | chunk_aligned_read(q,bi)) | 2756 | chunk_aligned_read(q,bi)) |
2757 | return 0; | 2757 | return 0; |
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c index 240ad084fa78..50bc32a8bd55 100644 --- a/drivers/media/dvb/bt8xx/dst_ca.c +++ b/drivers/media/dvb/bt8xx/dst_ca.c | |||
@@ -480,7 +480,7 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, | |||
480 | struct ca_msg *hw_buffer; | 480 | struct ca_msg *hw_buffer; |
481 | int result = 0; | 481 | int result = 0; |
482 | 482 | ||
483 | if ((hw_buffer = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { | 483 | if ((hw_buffer = kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { |
484 | dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); | 484 | dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); |
485 | return -ENOMEM; | 485 | return -ENOMEM; |
486 | } | 486 | } |
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index 80a85cb4975f..3e35931af35d 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c | |||
@@ -657,7 +657,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) | |||
657 | 657 | ||
658 | case BTTV_BOARD_TWINHAN_DST: | 658 | case BTTV_BOARD_TWINHAN_DST: |
659 | /* DST is not a frontend driver !!! */ | 659 | /* DST is not a frontend driver !!! */ |
660 | state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL); | 660 | state = kmalloc(sizeof (struct dst_state), GFP_KERNEL); |
661 | if (!state) { | 661 | if (!state) { |
662 | printk("dvb_bt8xx: No memory\n"); | 662 | printk("dvb_bt8xx: No memory\n"); |
663 | break; | 663 | break; |
diff --git a/drivers/media/dvb/ttusb-dec/ttusbdecfe.c b/drivers/media/dvb/ttusb-dec/ttusbdecfe.c index 42f39a89bc4d..a6fb1d6a7b5d 100644 --- a/drivers/media/dvb/ttusb-dec/ttusbdecfe.c +++ b/drivers/media/dvb/ttusb-dec/ttusbdecfe.c | |||
@@ -195,7 +195,7 @@ struct dvb_frontend* ttusbdecfe_dvbt_attach(const struct ttusbdecfe_config* conf | |||
195 | struct ttusbdecfe_state* state = NULL; | 195 | struct ttusbdecfe_state* state = NULL; |
196 | 196 | ||
197 | /* allocate memory for the internal state */ | 197 | /* allocate memory for the internal state */ |
198 | state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL); | 198 | state = kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL); |
199 | if (state == NULL) | 199 | if (state == NULL) |
200 | return NULL; | 200 | return NULL; |
201 | 201 | ||
@@ -215,7 +215,7 @@ struct dvb_frontend* ttusbdecfe_dvbs_attach(const struct ttusbdecfe_config* conf | |||
215 | struct ttusbdecfe_state* state = NULL; | 215 | struct ttusbdecfe_state* state = NULL; |
216 | 216 | ||
217 | /* allocate memory for the internal state */ | 217 | /* allocate memory for the internal state */ |
218 | state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL); | 218 | state = kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL); |
219 | if (state == NULL) | 219 | if (state == NULL) |
220 | return NULL; | 220 | return NULL; |
221 | 221 | ||
diff --git a/drivers/media/video/dabusb.c b/drivers/media/video/dabusb.c index b1012e92ee04..917021fc2993 100644 --- a/drivers/media/video/dabusb.c +++ b/drivers/media/video/dabusb.c | |||
@@ -218,7 +218,7 @@ static int dabusb_alloc_buffers (pdabusb_t s) | |||
218 | pipesize, packets, transfer_buffer_length); | 218 | pipesize, packets, transfer_buffer_length); |
219 | 219 | ||
220 | while (buffers < (s->total_buffer_size << 10)) { | 220 | while (buffers < (s->total_buffer_size << 10)) { |
221 | b = (pbuff_t) kzalloc (sizeof (buff_t), GFP_KERNEL); | 221 | b = kzalloc(sizeof (buff_t), GFP_KERNEL); |
222 | if (!b) { | 222 | if (!b) { |
223 | err("kzalloc(sizeof(buff_t))==NULL"); | 223 | err("kzalloc(sizeof(buff_t))==NULL"); |
224 | goto err; | 224 | goto err; |
@@ -659,7 +659,7 @@ static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cm | |||
659 | switch (cmd) { | 659 | switch (cmd) { |
660 | 660 | ||
661 | case IOCTL_DAB_BULK: | 661 | case IOCTL_DAB_BULK: |
662 | pbulk = (pbulk_transfer_t) kmalloc (sizeof (bulk_transfer_t), GFP_KERNEL); | 662 | pbulk = kmalloc(sizeof (bulk_transfer_t), GFP_KERNEL); |
663 | 663 | ||
664 | if (!pbulk) { | 664 | if (!pbulk) { |
665 | ret = -ENOMEM; | 665 | ret = -ENOMEM; |
diff --git a/drivers/media/video/planb.c b/drivers/media/video/planb.c index 368d6e219fa4..86d2884e16c6 100644 --- a/drivers/media/video/planb.c +++ b/drivers/media/video/planb.c | |||
@@ -138,7 +138,7 @@ static int grabbuf_alloc(struct planb *pb) | |||
138 | + MAX_LNUM | 138 | + MAX_LNUM |
139 | #endif /* PLANB_GSCANLINE */ | 139 | #endif /* PLANB_GSCANLINE */ |
140 | ); | 140 | ); |
141 | if ((pb->rawbuf = (unsigned char**) kmalloc (npage | 141 | if ((pb->rawbuf = kmalloc(npage |
142 | * sizeof(unsigned long), GFP_KERNEL)) == 0) | 142 | * sizeof(unsigned long), GFP_KERNEL)) == 0) |
143 | return -ENOMEM; | 143 | return -ENOMEM; |
144 | for (i = 0; i < npage; i++) { | 144 | for (i = 0; i < npage; i++) { |
diff --git a/drivers/media/video/usbvideo/usbvideo.c b/drivers/media/video/usbvideo/usbvideo.c index d8b88024bc2f..b560c9d7c516 100644 --- a/drivers/media/video/usbvideo/usbvideo.c +++ b/drivers/media/video/usbvideo/usbvideo.c | |||
@@ -690,7 +690,7 @@ int usbvideo_register( | |||
690 | } | 690 | } |
691 | 691 | ||
692 | base_size = num_cams * sizeof(struct uvd) + sizeof(struct usbvideo); | 692 | base_size = num_cams * sizeof(struct uvd) + sizeof(struct usbvideo); |
693 | cams = (struct usbvideo *) kzalloc(base_size, GFP_KERNEL); | 693 | cams = kzalloc(base_size, GFP_KERNEL); |
694 | if (cams == NULL) { | 694 | if (cams == NULL) { |
695 | err("Failed to allocate %d. bytes for usbvideo struct", base_size); | 695 | err("Failed to allocate %d. bytes for usbvideo struct", base_size); |
696 | return -ENOMEM; | 696 | return -ENOMEM; |
diff --git a/drivers/media/video/videocodec.c b/drivers/media/video/videocodec.c index 2ae3fb250630..290e64135650 100644 --- a/drivers/media/video/videocodec.c +++ b/drivers/media/video/videocodec.c | |||
@@ -346,7 +346,7 @@ videocodec_build_table (void) | |||
346 | size); | 346 | size); |
347 | 347 | ||
348 | kfree(videocodec_buf); | 348 | kfree(videocodec_buf); |
349 | videocodec_buf = (char *) kmalloc(size, GFP_KERNEL); | 349 | videocodec_buf = kmalloc(size, GFP_KERNEL); |
350 | 350 | ||
351 | i = 0; | 351 | i = 0; |
352 | i += scnprintf(videocodec_buf + i, size - 1, | 352 | i += scnprintf(videocodec_buf + i, size - 1, |
diff --git a/drivers/message/i2o/core.h b/drivers/message/i2o/core.h index dc388a3ff5e0..cbe384fb848c 100644 --- a/drivers/message/i2o/core.h +++ b/drivers/message/i2o/core.h | |||
@@ -18,7 +18,7 @@ extern struct i2o_driver i2o_exec_driver; | |||
18 | extern int i2o_exec_lct_get(struct i2o_controller *); | 18 | extern int i2o_exec_lct_get(struct i2o_controller *); |
19 | 19 | ||
20 | extern int __init i2o_exec_init(void); | 20 | extern int __init i2o_exec_init(void); |
21 | extern void __exit i2o_exec_exit(void); | 21 | extern void i2o_exec_exit(void); |
22 | 22 | ||
23 | /* driver */ | 23 | /* driver */ |
24 | extern struct bus_type i2o_bus_type; | 24 | extern struct bus_type i2o_bus_type; |
@@ -26,7 +26,7 @@ extern struct bus_type i2o_bus_type; | |||
26 | extern int i2o_driver_dispatch(struct i2o_controller *, u32); | 26 | extern int i2o_driver_dispatch(struct i2o_controller *, u32); |
27 | 27 | ||
28 | extern int __init i2o_driver_init(void); | 28 | extern int __init i2o_driver_init(void); |
29 | extern void __exit i2o_driver_exit(void); | 29 | extern void i2o_driver_exit(void); |
30 | 30 | ||
31 | /* PCI */ | 31 | /* PCI */ |
32 | extern int __init i2o_pci_init(void); | 32 | extern int __init i2o_pci_init(void); |
diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c index 9104b65ff70f..d3235f213c89 100644 --- a/drivers/message/i2o/driver.c +++ b/drivers/message/i2o/driver.c | |||
@@ -362,7 +362,7 @@ int __init i2o_driver_init(void) | |||
362 | * | 362 | * |
363 | * Unregisters the I2O bus and frees driver array. | 363 | * Unregisters the I2O bus and frees driver array. |
364 | */ | 364 | */ |
365 | void __exit i2o_driver_exit(void) | 365 | void i2o_driver_exit(void) |
366 | { | 366 | { |
367 | bus_unregister(&i2o_bus_type); | 367 | bus_unregister(&i2o_bus_type); |
368 | kfree(i2o_drivers); | 368 | kfree(i2o_drivers); |
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c index 902753b2c661..a539d3b61e76 100644 --- a/drivers/message/i2o/exec-osm.c +++ b/drivers/message/i2o/exec-osm.c | |||
@@ -595,7 +595,7 @@ int __init i2o_exec_init(void) | |||
595 | * | 595 | * |
596 | * Unregisters the Exec OSM from the I2O core. | 596 | * Unregisters the Exec OSM from the I2O core. |
597 | */ | 597 | */ |
598 | void __exit i2o_exec_exit(void) | 598 | void i2o_exec_exit(void) |
599 | { | 599 | { |
600 | i2o_driver_unregister(&i2o_exec_driver); | 600 | i2o_driver_unregister(&i2o_exec_driver); |
601 | }; | 601 | }; |
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c index 1de30d711671..e33d446e7493 100644 --- a/drivers/message/i2o/i2o_config.c +++ b/drivers/message/i2o/i2o_config.c | |||
@@ -186,7 +186,7 @@ static int i2o_cfg_parms(unsigned long arg, unsigned int type) | |||
186 | if (!dev) | 186 | if (!dev) |
187 | return -ENXIO; | 187 | return -ENXIO; |
188 | 188 | ||
189 | ops = (u8 *) kmalloc(kcmd.oplen, GFP_KERNEL); | 189 | ops = kmalloc(kcmd.oplen, GFP_KERNEL); |
190 | if (!ops) | 190 | if (!ops) |
191 | return -ENOMEM; | 191 | return -ENOMEM; |
192 | 192 | ||
@@ -199,7 +199,7 @@ static int i2o_cfg_parms(unsigned long arg, unsigned int type) | |||
199 | * It's possible to have a _very_ large table | 199 | * It's possible to have a _very_ large table |
200 | * and that the user asks for all of it at once... | 200 | * and that the user asks for all of it at once... |
201 | */ | 201 | */ |
202 | res = (u8 *) kmalloc(65536, GFP_KERNEL); | 202 | res = kmalloc(65536, GFP_KERNEL); |
203 | if (!res) { | 203 | if (!res) { |
204 | kfree(ops); | 204 | kfree(ops); |
205 | return -ENOMEM; | 205 | return -ENOMEM; |
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c index 5db716045927..0a7e86859bf1 100644 --- a/drivers/mtd/devices/mtd_dataflash.c +++ b/drivers/mtd/devices/mtd_dataflash.c | |||
@@ -459,7 +459,7 @@ add_dataflash(struct spi_device *spi, char *name, | |||
459 | struct mtd_info *device; | 459 | struct mtd_info *device; |
460 | struct flash_platform_data *pdata = spi->dev.platform_data; | 460 | struct flash_platform_data *pdata = spi->dev.platform_data; |
461 | 461 | ||
462 | priv = (struct dataflash *) kzalloc(sizeof *priv, GFP_KERNEL); | 462 | priv = kzalloc(sizeof *priv, GFP_KERNEL); |
463 | if (!priv) | 463 | if (!priv) |
464 | return -ENOMEM; | 464 | return -ENOMEM; |
465 | 465 | ||
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c index fa4362fb4dd8..0f3baa5d9c2a 100644 --- a/drivers/mtd/rfd_ftl.c +++ b/drivers/mtd/rfd_ftl.c | |||
@@ -768,7 +768,7 @@ static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
768 | if (mtd->type != MTD_NORFLASH) | 768 | if (mtd->type != MTD_NORFLASH) |
769 | return; | 769 | return; |
770 | 770 | ||
771 | part = kcalloc(1, sizeof(struct partition), GFP_KERNEL); | 771 | part = kzalloc(sizeof(struct partition), GFP_KERNEL); |
772 | if (!part) | 772 | if (!part) |
773 | return; | 773 | return; |
774 | 774 | ||
diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c index b98592a8bac8..f22e46dfd770 100644 --- a/drivers/net/appletalk/ipddp.c +++ b/drivers/net/appletalk/ipddp.c | |||
@@ -186,7 +186,7 @@ static int ipddp_xmit(struct sk_buff *skb, struct net_device *dev) | |||
186 | */ | 186 | */ |
187 | static int ipddp_create(struct ipddp_route *new_rt) | 187 | static int ipddp_create(struct ipddp_route *new_rt) |
188 | { | 188 | { |
189 | struct ipddp_route *rt =(struct ipddp_route*) kmalloc(sizeof(*rt), GFP_KERNEL); | 189 | struct ipddp_route *rt = kmalloc(sizeof(*rt), GFP_KERNEL); |
190 | 190 | ||
191 | if (rt == NULL) | 191 | if (rt == NULL) |
192 | return -ENOMEM; | 192 | return -ENOMEM; |
diff --git a/drivers/net/bsd_comp.c b/drivers/net/bsd_comp.c index bae1de1e7802..7845eaf6f29f 100644 --- a/drivers/net/bsd_comp.c +++ b/drivers/net/bsd_comp.c | |||
@@ -395,7 +395,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp) | |||
395 | * Allocate the main control structure for this instance. | 395 | * Allocate the main control structure for this instance. |
396 | */ | 396 | */ |
397 | maxmaxcode = MAXCODE(bits); | 397 | maxmaxcode = MAXCODE(bits); |
398 | db = (struct bsd_db *) kmalloc (sizeof (struct bsd_db), | 398 | db = kmalloc(sizeof (struct bsd_db), |
399 | GFP_KERNEL); | 399 | GFP_KERNEL); |
400 | if (!db) | 400 | if (!db) |
401 | { | 401 | { |
diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c index 16620bd97fbf..11af0ae7510e 100644 --- a/drivers/net/irda/donauboe.c +++ b/drivers/net/irda/donauboe.c | |||
@@ -1603,7 +1603,7 @@ toshoboe_open (struct pci_dev *pci_dev, const struct pci_device_id *pdid) | |||
1603 | irda_qos_bits_to_value (&self->qos); | 1603 | irda_qos_bits_to_value (&self->qos); |
1604 | 1604 | ||
1605 | /* Allocate twice the size to guarantee alignment */ | 1605 | /* Allocate twice the size to guarantee alignment */ |
1606 | self->ringbuf = (void *) kmalloc (OBOE_RING_LEN << 1, GFP_KERNEL); | 1606 | self->ringbuf = kmalloc(OBOE_RING_LEN << 1, GFP_KERNEL); |
1607 | if (!self->ringbuf) | 1607 | if (!self->ringbuf) |
1608 | { | 1608 | { |
1609 | printk (KERN_ERR DRIVER_NAME ": can't allocate DMA buffers\n"); | 1609 | printk (KERN_ERR DRIVER_NAME ": can't allocate DMA buffers\n"); |
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c index 6e95645e7245..3ca1082ec776 100644 --- a/drivers/net/irda/irda-usb.c +++ b/drivers/net/irda/irda-usb.c | |||
@@ -1747,7 +1747,7 @@ static int irda_usb_probe(struct usb_interface *intf, | |||
1747 | /* Don't change this buffer size and allocation without doing | 1747 | /* Don't change this buffer size and allocation without doing |
1748 | * some heavy and complete testing. Don't ask why :-( | 1748 | * some heavy and complete testing. Don't ask why :-( |
1749 | * Jean II */ | 1749 | * Jean II */ |
1750 | self->speed_buff = (char *) kmalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL); | 1750 | self->speed_buff = kmalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL); |
1751 | if (self->speed_buff == NULL) | 1751 | if (self->speed_buff == NULL) |
1752 | goto err_out_3; | 1752 | goto err_out_3; |
1753 | 1753 | ||
diff --git a/drivers/net/irda/irport.c b/drivers/net/irda/irport.c index 654a68b490ae..3098960dc2a1 100644 --- a/drivers/net/irda/irport.c +++ b/drivers/net/irda/irport.c | |||
@@ -164,7 +164,7 @@ irport_open(int i, unsigned int iobase, unsigned int irq) | |||
164 | 164 | ||
165 | /* Allocate memory if needed */ | 165 | /* Allocate memory if needed */ |
166 | if (self->tx_buff.truesize > 0) { | 166 | if (self->tx_buff.truesize > 0) { |
167 | self->tx_buff.head = (__u8 *) kmalloc(self->tx_buff.truesize, | 167 | self->tx_buff.head = kmalloc(self->tx_buff.truesize, |
168 | GFP_KERNEL); | 168 | GFP_KERNEL); |
169 | if (self->tx_buff.head == NULL) { | 169 | if (self->tx_buff.head == NULL) { |
170 | IRDA_ERROR("%s(), can't allocate memory for " | 170 | IRDA_ERROR("%s(), can't allocate memory for " |
diff --git a/drivers/net/lp486e.c b/drivers/net/lp486e.c index b833016f1825..177c502f7385 100644 --- a/drivers/net/lp486e.c +++ b/drivers/net/lp486e.c | |||
@@ -884,7 +884,7 @@ static int i596_start_xmit (struct sk_buff *skb, struct net_device *dev) { | |||
884 | 884 | ||
885 | dev->trans_start = jiffies; | 885 | dev->trans_start = jiffies; |
886 | 886 | ||
887 | tx_cmd = (struct tx_cmd *) kmalloc ((sizeof (struct tx_cmd) + sizeof (struct i596_tbd)), GFP_ATOMIC); | 887 | tx_cmd = kmalloc((sizeof (struct tx_cmd) + sizeof (struct i596_tbd)), GFP_ATOMIC); |
888 | if (tx_cmd == NULL) { | 888 | if (tx_cmd == NULL) { |
889 | printk(KERN_WARNING "%s: i596_xmit Memory squeeze, dropping packet.\n", dev->name); | 889 | printk(KERN_WARNING "%s: i596_xmit Memory squeeze, dropping packet.\n", dev->name); |
890 | lp->stats.tx_dropped++; | 890 | lp->stats.tx_dropped++; |
@@ -1266,7 +1266,7 @@ static void set_multicast_list(struct net_device *dev) { | |||
1266 | if (dev->mc_count > 0) { | 1266 | if (dev->mc_count > 0) { |
1267 | struct dev_mc_list *dmi; | 1267 | struct dev_mc_list *dmi; |
1268 | char *cp; | 1268 | char *cp; |
1269 | cmd = (struct i596_cmd *)kmalloc(sizeof(struct i596_cmd)+2+dev->mc_count*6, GFP_ATOMIC); | 1269 | cmd = kmalloc(sizeof(struct i596_cmd)+2+dev->mc_count*6, GFP_ATOMIC); |
1270 | if (cmd == NULL) { | 1270 | if (cmd == NULL) { |
1271 | printk (KERN_ERR "%s: set_multicast Memory squeeze.\n", dev->name); | 1271 | printk (KERN_ERR "%s: set_multicast Memory squeeze.\n", dev->name); |
1272 | return; | 1272 | return; |
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index b01fc70a57db..a4d7529ef415 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c | |||
@@ -50,7 +50,7 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id) | |||
50 | struct phy_device *dev; | 50 | struct phy_device *dev; |
51 | /* We allocate the device, and initialize the | 51 | /* We allocate the device, and initialize the |
52 | * default values */ | 52 | * default values */ |
53 | dev = kcalloc(1, sizeof(*dev), GFP_KERNEL); | 53 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
54 | 54 | ||
55 | if (NULL == dev) | 55 | if (NULL == dev) |
56 | return (struct phy_device*) PTR_ERR((void*)-ENOMEM); | 56 | return (struct phy_device*) PTR_ERR((void*)-ENOMEM); |
diff --git a/drivers/net/ppp_deflate.c b/drivers/net/ppp_deflate.c index f54c55242f4a..72c8d6628f58 100644 --- a/drivers/net/ppp_deflate.c +++ b/drivers/net/ppp_deflate.c | |||
@@ -121,7 +121,7 @@ static void *z_comp_alloc(unsigned char *options, int opt_len) | |||
121 | if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) | 121 | if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) |
122 | return NULL; | 122 | return NULL; |
123 | 123 | ||
124 | state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), | 124 | state = kmalloc(sizeof(*state), |
125 | GFP_KERNEL); | 125 | GFP_KERNEL); |
126 | if (state == NULL) | 126 | if (state == NULL) |
127 | return NULL; | 127 | return NULL; |
@@ -341,7 +341,7 @@ static void *z_decomp_alloc(unsigned char *options, int opt_len) | |||
341 | if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) | 341 | if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) |
342 | return NULL; | 342 | return NULL; |
343 | 343 | ||
344 | state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), GFP_KERNEL); | 344 | state = kmalloc(sizeof(*state), GFP_KERNEL); |
345 | if (state == NULL) | 345 | if (state == NULL) |
346 | return NULL; | 346 | return NULL; |
347 | 347 | ||
diff --git a/drivers/net/ppp_mppe.c b/drivers/net/ppp_mppe.c index f3655fd772f5..d5bdd2574659 100644 --- a/drivers/net/ppp_mppe.c +++ b/drivers/net/ppp_mppe.c | |||
@@ -200,7 +200,7 @@ static void *mppe_alloc(unsigned char *options, int optlen) | |||
200 | || options[0] != CI_MPPE || options[1] != CILEN_MPPE) | 200 | || options[0] != CI_MPPE || options[1] != CILEN_MPPE) |
201 | goto out; | 201 | goto out; |
202 | 202 | ||
203 | state = (struct ppp_mppe_state *) kmalloc(sizeof(*state), GFP_KERNEL); | 203 | state = kmalloc(sizeof(*state), GFP_KERNEL); |
204 | if (state == NULL) | 204 | if (state == NULL) |
205 | goto out; | 205 | goto out; |
206 | 206 | ||
diff --git a/drivers/net/skge.c b/drivers/net/skge.c index b60f0451f6cd..8a39376f87dc 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c | |||
@@ -749,7 +749,7 @@ static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u32 base) | |||
749 | struct skge_element *e; | 749 | struct skge_element *e; |
750 | int i; | 750 | int i; |
751 | 751 | ||
752 | ring->start = kcalloc(sizeof(*e), ring->count, GFP_KERNEL); | 752 | ring->start = kcalloc(ring->count, sizeof(*e), GFP_KERNEL); |
753 | if (!ring->start) | 753 | if (!ring->start) |
754 | return -ENOMEM; | 754 | return -ENOMEM; |
755 | 755 | ||
diff --git a/drivers/net/slip.c b/drivers/net/slip.c index 39c2152a07f4..a0806d262fc6 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c | |||
@@ -229,10 +229,10 @@ static int sl_realloc_bufs(struct slip *sl, int mtu) | |||
229 | if (len < 576 * 2) | 229 | if (len < 576 * 2) |
230 | len = 576 * 2; | 230 | len = 576 * 2; |
231 | 231 | ||
232 | xbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); | 232 | xbuff = kmalloc(len + 4, GFP_ATOMIC); |
233 | rbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); | 233 | rbuff = kmalloc(len + 4, GFP_ATOMIC); |
234 | #ifdef SL_INCLUDE_CSLIP | 234 | #ifdef SL_INCLUDE_CSLIP |
235 | cbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); | 235 | cbuff = kmalloc(len + 4, GFP_ATOMIC); |
236 | #endif | 236 | #endif |
237 | 237 | ||
238 | 238 | ||
diff --git a/drivers/net/wan/hostess_sv11.c b/drivers/net/wan/hostess_sv11.c index a4f735723c41..a02c5fb40567 100644 --- a/drivers/net/wan/hostess_sv11.c +++ b/drivers/net/wan/hostess_sv11.c | |||
@@ -231,7 +231,7 @@ static struct sv11_device *sv11_init(int iobase, int irq) | |||
231 | return NULL; | 231 | return NULL; |
232 | } | 232 | } |
233 | 233 | ||
234 | sv=(struct sv11_device *)kmalloc(sizeof(struct sv11_device), GFP_KERNEL); | 234 | sv = kmalloc(sizeof(struct sv11_device), GFP_KERNEL); |
235 | if(!sv) | 235 | if(!sv) |
236 | goto fail3; | 236 | goto fail3; |
237 | 237 | ||
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c index 36d1c3ff7078..62184dee377c 100644 --- a/drivers/net/wan/pc300_drv.c +++ b/drivers/net/wan/pc300_drv.c | |||
@@ -3455,7 +3455,7 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3455 | if ((err = pci_enable_device(pdev)) < 0) | 3455 | if ((err = pci_enable_device(pdev)) < 0) |
3456 | return err; | 3456 | return err; |
3457 | 3457 | ||
3458 | card = (pc300_t *) kmalloc(sizeof(pc300_t), GFP_KERNEL); | 3458 | card = kmalloc(sizeof(pc300_t), GFP_KERNEL); |
3459 | if (card == NULL) { | 3459 | if (card == NULL) { |
3460 | printk("PC300 found at RAM 0x%016llx, " | 3460 | printk("PC300 found at RAM 0x%016llx, " |
3461 | "but could not allocate card structure.\n", | 3461 | "but could not allocate card structure.\n", |
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c index b2a23aed4428..5873c346e7e9 100644 --- a/drivers/net/wan/pc300_tty.c +++ b/drivers/net/wan/pc300_tty.c | |||
@@ -784,7 +784,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev) | |||
784 | continue; | 784 | continue; |
785 | } | 785 | } |
786 | 786 | ||
787 | new = (st_cpc_rx_buf *)kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC); | 787 | new = kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC); |
788 | if (new == 0) { | 788 | if (new == 0) { |
789 | cpc_tty_rx_disc_frame(pc300chan); | 789 | cpc_tty_rx_disc_frame(pc300chan); |
790 | continue; | 790 | continue; |
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c index 9c3ccc669143..1c9edd97accd 100644 --- a/drivers/net/wan/x25_asy.c +++ b/drivers/net/wan/x25_asy.c | |||
@@ -123,8 +123,8 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu) | |||
123 | unsigned char *xbuff, *rbuff; | 123 | unsigned char *xbuff, *rbuff; |
124 | int len = 2* newmtu; | 124 | int len = 2* newmtu; |
125 | 125 | ||
126 | xbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); | 126 | xbuff = kmalloc(len + 4, GFP_ATOMIC); |
127 | rbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); | 127 | rbuff = kmalloc(len + 4, GFP_ATOMIC); |
128 | 128 | ||
129 | if (xbuff == NULL || rbuff == NULL) | 129 | if (xbuff == NULL || rbuff == NULL) |
130 | { | 130 | { |
@@ -465,11 +465,11 @@ static int x25_asy_open(struct net_device *dev) | |||
465 | 465 | ||
466 | len = dev->mtu * 2; | 466 | len = dev->mtu * 2; |
467 | 467 | ||
468 | sl->rbuff = (unsigned char *) kmalloc(len + 4, GFP_KERNEL); | 468 | sl->rbuff = kmalloc(len + 4, GFP_KERNEL); |
469 | if (sl->rbuff == NULL) { | 469 | if (sl->rbuff == NULL) { |
470 | goto norbuff; | 470 | goto norbuff; |
471 | } | 471 | } |
472 | sl->xbuff = (unsigned char *) kmalloc(len + 4, GFP_KERNEL); | 472 | sl->xbuff = kmalloc(len + 4, GFP_KERNEL); |
473 | if (sl->xbuff == NULL) { | 473 | if (sl->xbuff == NULL) { |
474 | goto noxbuff; | 474 | goto noxbuff; |
475 | } | 475 | } |
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c index 974a8e5bec8b..efb8cf3bd8ad 100644 --- a/drivers/net/wireless/hostap/hostap_ap.c +++ b/drivers/net/wireless/hostap/hostap_ap.c | |||
@@ -1253,7 +1253,7 @@ static char * ap_auth_make_challenge(struct ap_data *ap) | |||
1253 | return NULL; | 1253 | return NULL; |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | tmpbuf = (char *) kmalloc(WLAN_AUTH_CHALLENGE_LEN, GFP_ATOMIC); | 1256 | tmpbuf = kmalloc(WLAN_AUTH_CHALLENGE_LEN, GFP_ATOMIC); |
1257 | if (tmpbuf == NULL) { | 1257 | if (tmpbuf == NULL) { |
1258 | PDEBUG(DEBUG_AP, "AP: kmalloc failed for challenge\n"); | 1258 | PDEBUG(DEBUG_AP, "AP: kmalloc failed for challenge\n"); |
1259 | return NULL; | 1259 | return NULL; |
diff --git a/drivers/net/wireless/hostap/hostap_download.c b/drivers/net/wireless/hostap/hostap_download.c index 24fc387bba67..c7678e67697d 100644 --- a/drivers/net/wireless/hostap/hostap_download.c +++ b/drivers/net/wireless/hostap/hostap_download.c | |||
@@ -201,7 +201,7 @@ static u8 * prism2_read_pda(struct net_device *dev) | |||
201 | 0x7f0002 /* Intel PRO/Wireless 2011B (PCI) */, | 201 | 0x7f0002 /* Intel PRO/Wireless 2011B (PCI) */, |
202 | }; | 202 | }; |
203 | 203 | ||
204 | buf = (u8 *) kmalloc(PRISM2_PDA_SIZE, GFP_KERNEL); | 204 | buf = kmalloc(PRISM2_PDA_SIZE, GFP_KERNEL); |
205 | if (buf == NULL) | 205 | if (buf == NULL) |
206 | return NULL; | 206 | return NULL; |
207 | 207 | ||
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c index a394a23b9a20..3079378fb8cd 100644 --- a/drivers/net/wireless/hostap/hostap_hw.c +++ b/drivers/net/wireless/hostap/hostap_hw.c | |||
@@ -2252,7 +2252,7 @@ static int hostap_tx_compl_read(local_info_t *local, int error, | |||
2252 | if (txdesc->sw_support) { | 2252 | if (txdesc->sw_support) { |
2253 | len = le16_to_cpu(txdesc->data_len); | 2253 | len = le16_to_cpu(txdesc->data_len); |
2254 | if (len < PRISM2_DATA_MAXLEN) { | 2254 | if (len < PRISM2_DATA_MAXLEN) { |
2255 | *payload = (char *) kmalloc(len, GFP_ATOMIC); | 2255 | *payload = kmalloc(len, GFP_ATOMIC); |
2256 | if (*payload == NULL || | 2256 | if (*payload == NULL || |
2257 | hfa384x_from_bap(dev, BAP0, *payload, len)) { | 2257 | hfa384x_from_bap(dev, BAP0, *payload, len)) { |
2258 | PDEBUG(DEBUG_EXTRA, "%s: could not read TX " | 2258 | PDEBUG(DEBUG_EXTRA, "%s: could not read TX " |
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c index 3b7b8063ff1c..cb08bc5db2bd 100644 --- a/drivers/net/wireless/hostap/hostap_ioctl.c +++ b/drivers/net/wireless/hostap/hostap_ioctl.c | |||
@@ -3829,7 +3829,7 @@ static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p) | |||
3829 | p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer) | 3829 | p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer) |
3830 | return -EINVAL; | 3830 | return -EINVAL; |
3831 | 3831 | ||
3832 | param = (struct prism2_hostapd_param *) kmalloc(p->length, GFP_KERNEL); | 3832 | param = kmalloc(p->length, GFP_KERNEL); |
3833 | if (param == NULL) | 3833 | if (param == NULL) |
3834 | return -ENOMEM; | 3834 | return -ENOMEM; |
3835 | 3835 | ||
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c index 0796be9d9e77..04c19cefa1da 100644 --- a/drivers/net/wireless/hostap/hostap_main.c +++ b/drivers/net/wireless/hostap/hostap_main.c | |||
@@ -250,7 +250,7 @@ u16 hostap_tx_callback_register(local_info_t *local, | |||
250 | unsigned long flags; | 250 | unsigned long flags; |
251 | struct hostap_tx_callback_info *entry; | 251 | struct hostap_tx_callback_info *entry; |
252 | 252 | ||
253 | entry = (struct hostap_tx_callback_info *) kmalloc(sizeof(*entry), | 253 | entry = kmalloc(sizeof(*entry), |
254 | GFP_ATOMIC); | 254 | GFP_ATOMIC); |
255 | if (entry == NULL) | 255 | if (entry == NULL) |
256 | return 0; | 256 | return 0; |
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c index dd9ba4aad7bb..0e94fbbf7a94 100644 --- a/drivers/net/wireless/ipw2100.c +++ b/drivers/net/wireless/ipw2100.c | |||
@@ -2246,7 +2246,7 @@ static int ipw2100_snapshot_alloc(struct ipw2100_priv *priv) | |||
2246 | if (priv->snapshot[0]) | 2246 | if (priv->snapshot[0]) |
2247 | return 1; | 2247 | return 1; |
2248 | for (i = 0; i < 0x30; i++) { | 2248 | for (i = 0; i < 0x30; i++) { |
2249 | priv->snapshot[i] = (u8 *) kmalloc(0x1000, GFP_ATOMIC); | 2249 | priv->snapshot[i] = kmalloc(0x1000, GFP_ATOMIC); |
2250 | if (!priv->snapshot[i]) { | 2250 | if (!priv->snapshot[i]) { |
2251 | IPW_DEBUG_INFO("%s: Error allocating snapshot " | 2251 | IPW_DEBUG_INFO("%s: Error allocating snapshot " |
2252 | "buffer %d\n", priv->net_dev->name, i); | 2252 | "buffer %d\n", priv->net_dev->name, i); |
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c index 96606ed10076..838d510213c6 100644 --- a/drivers/net/wireless/prism54/isl_ioctl.c +++ b/drivers/net/wireless/prism54/isl_ioctl.c | |||
@@ -2775,7 +2775,7 @@ prism54_hostapd(struct net_device *ndev, struct iw_point *p) | |||
2775 | p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer) | 2775 | p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer) |
2776 | return -EINVAL; | 2776 | return -EINVAL; |
2777 | 2777 | ||
2778 | param = (struct prism2_hostapd_param *) kmalloc(p->length, GFP_KERNEL); | 2778 | param = kmalloc(p->length, GFP_KERNEL); |
2779 | if (param == NULL) | 2779 | if (param == NULL) |
2780 | return -ENOMEM; | 2780 | return -ENOMEM; |
2781 | 2781 | ||
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index 233d906c08f0..5eb81638e846 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c | |||
@@ -603,7 +603,7 @@ static wavepoint_history *wl_new_wavepoint(unsigned short nwid, unsigned char se | |||
603 | if(lp->wavepoint_table.num_wavepoints==MAX_WAVEPOINTS) | 603 | if(lp->wavepoint_table.num_wavepoints==MAX_WAVEPOINTS) |
604 | return NULL; | 604 | return NULL; |
605 | 605 | ||
606 | new_wavepoint=(wavepoint_history *) kmalloc(sizeof(wavepoint_history),GFP_ATOMIC); | 606 | new_wavepoint = kmalloc(sizeof(wavepoint_history),GFP_ATOMIC); |
607 | if(new_wavepoint==NULL) | 607 | if(new_wavepoint==NULL) |
608 | return NULL; | 608 | return NULL; |
609 | 609 | ||
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c index 77e11ddad836..78ea72fb8f0c 100644 --- a/drivers/net/wireless/zd1211rw/zd_chip.c +++ b/drivers/net/wireless/zd1211rw/zd_chip.c | |||
@@ -101,7 +101,7 @@ int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr | |||
101 | 101 | ||
102 | /* Allocate a single memory block for values and addresses. */ | 102 | /* Allocate a single memory block for values and addresses. */ |
103 | count16 = 2*count; | 103 | count16 = 2*count; |
104 | a16 = (zd_addr_t *)kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)), | 104 | a16 = kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)), |
105 | GFP_NOFS); | 105 | GFP_NOFS); |
106 | if (!a16) { | 106 | if (!a16) { |
107 | dev_dbg_f(zd_chip_dev(chip), | 107 | dev_dbg_f(zd_chip_dev(chip), |
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c index 12bab64a62a1..6fb3f7979f21 100644 --- a/drivers/parisc/iosapic.c +++ b/drivers/parisc/iosapic.c | |||
@@ -874,7 +874,7 @@ void *iosapic_register(unsigned long hpa) | |||
874 | return NULL; | 874 | return NULL; |
875 | } | 875 | } |
876 | 876 | ||
877 | isi = (struct iosapic_info *)kzalloc(sizeof(struct iosapic_info), GFP_KERNEL); | 877 | isi = kzalloc(sizeof(struct iosapic_info), GFP_KERNEL); |
878 | if (!isi) { | 878 | if (!isi) { |
879 | BUG(); | 879 | BUG(); |
880 | return NULL; | 880 | return NULL; |
diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c index 298a6cfd8406..ae5e974c45a7 100644 --- a/drivers/pci/hotplug/cpqphp_nvram.c +++ b/drivers/pci/hotplug/cpqphp_nvram.c | |||
@@ -520,7 +520,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
520 | return 2; | 520 | return 2; |
521 | 521 | ||
522 | while (nummem--) { | 522 | while (nummem--) { |
523 | mem_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); | 523 | mem_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL); |
524 | 524 | ||
525 | if (!mem_node) | 525 | if (!mem_node) |
526 | break; | 526 | break; |
@@ -548,7 +548,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
548 | } | 548 | } |
549 | 549 | ||
550 | while (numpmem--) { | 550 | while (numpmem--) { |
551 | p_mem_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); | 551 | p_mem_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL); |
552 | 552 | ||
553 | if (!p_mem_node) | 553 | if (!p_mem_node) |
554 | break; | 554 | break; |
@@ -576,7 +576,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
576 | } | 576 | } |
577 | 577 | ||
578 | while (numio--) { | 578 | while (numio--) { |
579 | io_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); | 579 | io_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL); |
580 | 580 | ||
581 | if (!io_node) | 581 | if (!io_node) |
582 | break; | 582 | break; |
@@ -604,7 +604,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
604 | } | 604 | } |
605 | 605 | ||
606 | while (numbus--) { | 606 | while (numbus--) { |
607 | bus_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); | 607 | bus_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL); |
608 | 608 | ||
609 | if (!bus_node) | 609 | if (!bus_node) |
610 | break; | 610 | break; |
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 6d3f580f2666..25d3aadfddbf 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c | |||
@@ -1320,7 +1320,7 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev) | |||
1320 | DBG_ENTER_ROUTINE | 1320 | DBG_ENTER_ROUTINE |
1321 | 1321 | ||
1322 | spin_lock_init(&list_lock); | 1322 | spin_lock_init(&list_lock); |
1323 | php_ctlr = (struct php_ctlr_state_s *) kmalloc(sizeof(struct php_ctlr_state_s), GFP_KERNEL); | 1323 | php_ctlr = kmalloc(sizeof(struct php_ctlr_state_s), GFP_KERNEL); |
1324 | 1324 | ||
1325 | if (!php_ctlr) { /* allocate controller state data */ | 1325 | if (!php_ctlr) { /* allocate controller state data */ |
1326 | err("%s: HPC controller memory allocation error!\n", __FUNCTION__); | 1326 | err("%s: HPC controller memory allocation error!\n", __FUNCTION__); |
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c index 55866b6b26fa..6f5fabbd14e5 100644 --- a/drivers/pci/pcie/aer/aerdrv.c +++ b/drivers/pci/pcie/aer/aerdrv.c | |||
@@ -148,7 +148,7 @@ static struct aer_rpc* aer_alloc_rpc(struct pcie_device *dev) | |||
148 | { | 148 | { |
149 | struct aer_rpc *rpc; | 149 | struct aer_rpc *rpc; |
150 | 150 | ||
151 | if (!(rpc = (struct aer_rpc *)kmalloc(sizeof(struct aer_rpc), | 151 | if (!(rpc = kmalloc(sizeof(struct aer_rpc), |
152 | GFP_KERNEL))) | 152 | GFP_KERNEL))) |
153 | return NULL; | 153 | return NULL; |
154 | 154 | ||
diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c index 52d4a38b3667..3334f22a86c0 100644 --- a/drivers/pcmcia/at91_cf.c +++ b/drivers/pcmcia/at91_cf.c | |||
@@ -230,7 +230,7 @@ static int __init at91_cf_probe(struct platform_device *pdev) | |||
230 | if (!io) | 230 | if (!io) |
231 | return -ENODEV; | 231 | return -ENODEV; |
232 | 232 | ||
233 | cf = kcalloc(1, sizeof *cf, GFP_KERNEL); | 233 | cf = kzalloc(sizeof *cf, GFP_KERNEL); |
234 | if (!cf) | 234 | if (!cf) |
235 | return -ENOMEM; | 235 | return -ENOMEM; |
236 | 236 | ||
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c index 06bf7f48836e..e65a6b8188f6 100644 --- a/drivers/pcmcia/omap_cf.c +++ b/drivers/pcmcia/omap_cf.c | |||
@@ -220,7 +220,7 @@ static int __devinit omap_cf_probe(struct device *dev) | |||
220 | if (irq < 0) | 220 | if (irq < 0) |
221 | return -EINVAL; | 221 | return -EINVAL; |
222 | 222 | ||
223 | cf = kcalloc(1, sizeof *cf, GFP_KERNEL); | 223 | cf = kzalloc(sizeof *cf, GFP_KERNEL); |
224 | if (!cf) | 224 | if (!cf) |
225 | return -ENOMEM; | 225 | return -ENOMEM; |
226 | init_timer(&cf->timer); | 226 | init_timer(&cf->timer); |
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 3ac5b123215a..a0b158704ca1 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c | |||
@@ -395,7 +395,7 @@ static void isapnp_parse_id(struct pnp_dev * dev, unsigned short vendor, unsigne | |||
395 | struct pnp_id * id; | 395 | struct pnp_id * id; |
396 | if (!dev) | 396 | if (!dev) |
397 | return; | 397 | return; |
398 | id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); | 398 | id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); |
399 | if (!id) | 399 | if (!id) |
400 | return; | 400 | return; |
401 | sprintf(id->id, "%c%c%c%x%x%x%x", | 401 | sprintf(id->id, "%c%c%c%x%x%x%x", |
@@ -419,7 +419,7 @@ static struct pnp_dev * __init isapnp_parse_device(struct pnp_card *card, int si | |||
419 | struct pnp_dev *dev; | 419 | struct pnp_dev *dev; |
420 | 420 | ||
421 | isapnp_peek(tmp, size); | 421 | isapnp_peek(tmp, size); |
422 | dev = kcalloc(1, sizeof(struct pnp_dev), GFP_KERNEL); | 422 | dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); |
423 | if (!dev) | 423 | if (!dev) |
424 | return NULL; | 424 | return NULL; |
425 | dev->number = number; | 425 | dev->number = number; |
@@ -450,7 +450,7 @@ static void __init isapnp_parse_irq_resource(struct pnp_option *option, | |||
450 | unsigned long bits; | 450 | unsigned long bits; |
451 | 451 | ||
452 | isapnp_peek(tmp, size); | 452 | isapnp_peek(tmp, size); |
453 | irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); | 453 | irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL); |
454 | if (!irq) | 454 | if (!irq) |
455 | return; | 455 | return; |
456 | bits = (tmp[1] << 8) | tmp[0]; | 456 | bits = (tmp[1] << 8) | tmp[0]; |
@@ -474,7 +474,7 @@ static void __init isapnp_parse_dma_resource(struct pnp_option *option, | |||
474 | struct pnp_dma *dma; | 474 | struct pnp_dma *dma; |
475 | 475 | ||
476 | isapnp_peek(tmp, size); | 476 | isapnp_peek(tmp, size); |
477 | dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); | 477 | dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL); |
478 | if (!dma) | 478 | if (!dma) |
479 | return; | 479 | return; |
480 | dma->map = tmp[0]; | 480 | dma->map = tmp[0]; |
@@ -494,7 +494,7 @@ static void __init isapnp_parse_port_resource(struct pnp_option *option, | |||
494 | struct pnp_port *port; | 494 | struct pnp_port *port; |
495 | 495 | ||
496 | isapnp_peek(tmp, size); | 496 | isapnp_peek(tmp, size); |
497 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); | 497 | port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); |
498 | if (!port) | 498 | if (!port) |
499 | return; | 499 | return; |
500 | port->min = (tmp[2] << 8) | tmp[1]; | 500 | port->min = (tmp[2] << 8) | tmp[1]; |
@@ -517,7 +517,7 @@ static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option, | |||
517 | struct pnp_port *port; | 517 | struct pnp_port *port; |
518 | 518 | ||
519 | isapnp_peek(tmp, size); | 519 | isapnp_peek(tmp, size); |
520 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); | 520 | port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); |
521 | if (!port) | 521 | if (!port) |
522 | return; | 522 | return; |
523 | port->min = port->max = (tmp[1] << 8) | tmp[0]; | 523 | port->min = port->max = (tmp[1] << 8) | tmp[0]; |
@@ -539,7 +539,7 @@ static void __init isapnp_parse_mem_resource(struct pnp_option *option, | |||
539 | struct pnp_mem *mem; | 539 | struct pnp_mem *mem; |
540 | 540 | ||
541 | isapnp_peek(tmp, size); | 541 | isapnp_peek(tmp, size); |
542 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); | 542 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); |
543 | if (!mem) | 543 | if (!mem) |
544 | return; | 544 | return; |
545 | mem->min = ((tmp[2] << 8) | tmp[1]) << 8; | 545 | mem->min = ((tmp[2] << 8) | tmp[1]) << 8; |
@@ -562,7 +562,7 @@ static void __init isapnp_parse_mem32_resource(struct pnp_option *option, | |||
562 | struct pnp_mem *mem; | 562 | struct pnp_mem *mem; |
563 | 563 | ||
564 | isapnp_peek(tmp, size); | 564 | isapnp_peek(tmp, size); |
565 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); | 565 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); |
566 | if (!mem) | 566 | if (!mem) |
567 | return; | 567 | return; |
568 | mem->min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; | 568 | mem->min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; |
@@ -584,7 +584,7 @@ static void __init isapnp_parse_fixed_mem32_resource(struct pnp_option *option, | |||
584 | struct pnp_mem *mem; | 584 | struct pnp_mem *mem; |
585 | 585 | ||
586 | isapnp_peek(tmp, size); | 586 | isapnp_peek(tmp, size); |
587 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); | 587 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); |
588 | if (!mem) | 588 | if (!mem) |
589 | return; | 589 | return; |
590 | mem->min = mem->max = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; | 590 | mem->min = mem->max = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; |
@@ -829,7 +829,7 @@ static unsigned char __init isapnp_checksum(unsigned char *data) | |||
829 | 829 | ||
830 | static void isapnp_parse_card_id(struct pnp_card * card, unsigned short vendor, unsigned short device) | 830 | static void isapnp_parse_card_id(struct pnp_card * card, unsigned short vendor, unsigned short device) |
831 | { | 831 | { |
832 | struct pnp_id * id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); | 832 | struct pnp_id * id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); |
833 | if (!id) | 833 | if (!id) |
834 | return; | 834 | return; |
835 | sprintf(id->id, "%c%c%c%x%x%x%x", | 835 | sprintf(id->id, "%c%c%c%x%x%x%x", |
@@ -865,7 +865,7 @@ static int __init isapnp_build_device_list(void) | |||
865 | header[4], header[5], header[6], header[7], header[8]); | 865 | header[4], header[5], header[6], header[7], header[8]); |
866 | printk(KERN_DEBUG "checksum = 0x%x\n", checksum); | 866 | printk(KERN_DEBUG "checksum = 0x%x\n", checksum); |
867 | #endif | 867 | #endif |
868 | if ((card = kcalloc(1, sizeof(struct pnp_card), GFP_KERNEL)) == NULL) | 868 | if ((card = kzalloc(sizeof(struct pnp_card), GFP_KERNEL)) == NULL) |
869 | continue; | 869 | continue; |
870 | 870 | ||
871 | card->number = csn; | 871 | card->number = csn; |
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 6cf34a63c790..62eda5d59024 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c | |||
@@ -139,7 +139,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) | |||
139 | return 0; | 139 | return 0; |
140 | 140 | ||
141 | pnp_dbg("ACPI device : hid %s", acpi_device_hid(device)); | 141 | pnp_dbg("ACPI device : hid %s", acpi_device_hid(device)); |
142 | dev = kcalloc(1, sizeof(struct pnp_dev), GFP_KERNEL); | 142 | dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); |
143 | if (!dev) { | 143 | if (!dev) { |
144 | pnp_err("Out of memory"); | 144 | pnp_err("Out of memory"); |
145 | return -ENOMEM; | 145 | return -ENOMEM; |
@@ -169,7 +169,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) | |||
169 | dev->number = num; | 169 | dev->number = num; |
170 | 170 | ||
171 | /* set the initial values for the PnP device */ | 171 | /* set the initial values for the PnP device */ |
172 | dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); | 172 | dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); |
173 | if (!dev_id) | 173 | if (!dev_id) |
174 | goto err; | 174 | goto err; |
175 | pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id); | 175 | pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id); |
@@ -201,7 +201,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) | |||
201 | for (i = 0; i < cid_list->count; i++) { | 201 | for (i = 0; i < cid_list->count; i++) { |
202 | if (!ispnpidacpi(cid_list->id[i].value)) | 202 | if (!ispnpidacpi(cid_list->id[i].value)) |
203 | continue; | 203 | continue; |
204 | dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); | 204 | dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); |
205 | if (!dev_id) | 205 | if (!dev_id) |
206 | continue; | 206 | continue; |
207 | 207 | ||
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 379048fdf05d..7a535542fe92 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c | |||
@@ -298,7 +298,7 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso | |||
298 | 298 | ||
299 | if (p->channel_count == 0) | 299 | if (p->channel_count == 0) |
300 | return; | 300 | return; |
301 | dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); | 301 | dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL); |
302 | if (!dma) | 302 | if (!dma) |
303 | return; | 303 | return; |
304 | 304 | ||
@@ -354,7 +354,7 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option, | |||
354 | 354 | ||
355 | if (p->interrupt_count == 0) | 355 | if (p->interrupt_count == 0) |
356 | return; | 356 | return; |
357 | irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); | 357 | irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL); |
358 | if (!irq) | 358 | if (!irq) |
359 | return; | 359 | return; |
360 | 360 | ||
@@ -375,7 +375,7 @@ static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, | |||
375 | 375 | ||
376 | if (p->interrupt_count == 0) | 376 | if (p->interrupt_count == 0) |
377 | return; | 377 | return; |
378 | irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); | 378 | irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL); |
379 | if (!irq) | 379 | if (!irq) |
380 | return; | 380 | return; |
381 | 381 | ||
@@ -396,7 +396,7 @@ pnpacpi_parse_port_option(struct pnp_option *option, | |||
396 | 396 | ||
397 | if (io->address_length == 0) | 397 | if (io->address_length == 0) |
398 | return; | 398 | return; |
399 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); | 399 | port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); |
400 | if (!port) | 400 | if (!port) |
401 | return; | 401 | return; |
402 | port->min = io->minimum; | 402 | port->min = io->minimum; |
@@ -417,7 +417,7 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option, | |||
417 | 417 | ||
418 | if (io->address_length == 0) | 418 | if (io->address_length == 0) |
419 | return; | 419 | return; |
420 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); | 420 | port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); |
421 | if (!port) | 421 | if (!port) |
422 | return; | 422 | return; |
423 | port->min = port->max = io->address; | 423 | port->min = port->max = io->address; |
@@ -436,7 +436,7 @@ pnpacpi_parse_mem24_option(struct pnp_option *option, | |||
436 | 436 | ||
437 | if (p->address_length == 0) | 437 | if (p->address_length == 0) |
438 | return; | 438 | return; |
439 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); | 439 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); |
440 | if (!mem) | 440 | if (!mem) |
441 | return; | 441 | return; |
442 | mem->min = p->minimum; | 442 | mem->min = p->minimum; |
@@ -459,7 +459,7 @@ pnpacpi_parse_mem32_option(struct pnp_option *option, | |||
459 | 459 | ||
460 | if (p->address_length == 0) | 460 | if (p->address_length == 0) |
461 | return; | 461 | return; |
462 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); | 462 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); |
463 | if (!mem) | 463 | if (!mem) |
464 | return; | 464 | return; |
465 | mem->min = p->minimum; | 465 | mem->min = p->minimum; |
@@ -482,7 +482,7 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, | |||
482 | 482 | ||
483 | if (p->address_length == 0) | 483 | if (p->address_length == 0) |
484 | return; | 484 | return; |
485 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); | 485 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); |
486 | if (!mem) | 486 | if (!mem) |
487 | return; | 487 | return; |
488 | mem->min = mem->max = p->address; | 488 | mem->min = mem->max = p->address; |
@@ -514,7 +514,7 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r) | |||
514 | return; | 514 | return; |
515 | 515 | ||
516 | if (p->resource_type == ACPI_MEMORY_RANGE) { | 516 | if (p->resource_type == ACPI_MEMORY_RANGE) { |
517 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); | 517 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); |
518 | if (!mem) | 518 | if (!mem) |
519 | return; | 519 | return; |
520 | mem->min = mem->max = p->minimum; | 520 | mem->min = mem->max = p->minimum; |
@@ -524,7 +524,7 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r) | |||
524 | ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0; | 524 | ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0; |
525 | pnp_register_mem_resource(option, mem); | 525 | pnp_register_mem_resource(option, mem); |
526 | } else if (p->resource_type == ACPI_IO_RANGE) { | 526 | } else if (p->resource_type == ACPI_IO_RANGE) { |
527 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); | 527 | port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); |
528 | if (!port) | 528 | if (!port) |
529 | return; | 529 | return; |
530 | port->min = port->max = p->minimum; | 530 | port->min = port->max = p->minimum; |
@@ -721,7 +721,7 @@ int pnpacpi_build_resource_template(acpi_handle handle, | |||
721 | if (!res_cnt) | 721 | if (!res_cnt) |
722 | return -EINVAL; | 722 | return -EINVAL; |
723 | buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1; | 723 | buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1; |
724 | buffer->pointer = kcalloc(1, buffer->length - 1, GFP_KERNEL); | 724 | buffer->pointer = kzalloc(buffer->length - 1, GFP_KERNEL); |
725 | if (!buffer->pointer) | 725 | if (!buffer->pointer) |
726 | return -ENOMEM; | 726 | return -ENOMEM; |
727 | pnp_dbg("Res cnt %d", res_cnt); | 727 | pnp_dbg("Res cnt %d", res_cnt); |
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c index 33adeba1a31f..95738dbd5d45 100644 --- a/drivers/pnp/pnpbios/core.c +++ b/drivers/pnp/pnpbios/core.c | |||
@@ -109,10 +109,10 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) | |||
109 | if (!current->fs->root) { | 109 | if (!current->fs->root) { |
110 | return -EAGAIN; | 110 | return -EAGAIN; |
111 | } | 111 | } |
112 | if (!(envp = (char **) kcalloc (20, sizeof (char *), GFP_KERNEL))) { | 112 | if (!(envp = kcalloc(20, sizeof (char *), GFP_KERNEL))) { |
113 | return -ENOMEM; | 113 | return -ENOMEM; |
114 | } | 114 | } |
115 | if (!(buf = kcalloc (1, 256, GFP_KERNEL))) { | 115 | if (!(buf = kzalloc(256, GFP_KERNEL))) { |
116 | kfree (envp); | 116 | kfree (envp); |
117 | return -ENOMEM; | 117 | return -ENOMEM; |
118 | } | 118 | } |
@@ -220,7 +220,7 @@ static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table | |||
220 | if(!pnpbios_is_dynamic(dev)) | 220 | if(!pnpbios_is_dynamic(dev)) |
221 | return -EPERM; | 221 | return -EPERM; |
222 | 222 | ||
223 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); | 223 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); |
224 | if (!node) | 224 | if (!node) |
225 | return -1; | 225 | return -1; |
226 | if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { | 226 | if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { |
@@ -243,7 +243,7 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table | |||
243 | if (!pnpbios_is_dynamic(dev)) | 243 | if (!pnpbios_is_dynamic(dev)) |
244 | return -EPERM; | 244 | return -EPERM; |
245 | 245 | ||
246 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); | 246 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); |
247 | if (!node) | 247 | if (!node) |
248 | return -1; | 248 | return -1; |
249 | if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { | 249 | if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { |
@@ -294,7 +294,7 @@ static int pnpbios_disable_resources(struct pnp_dev *dev) | |||
294 | if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev)) | 294 | if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev)) |
295 | return -EPERM; | 295 | return -EPERM; |
296 | 296 | ||
297 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); | 297 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); |
298 | if (!node) | 298 | if (!node) |
299 | return -ENOMEM; | 299 | return -ENOMEM; |
300 | 300 | ||
@@ -336,7 +336,7 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node) | |||
336 | } | 336 | } |
337 | 337 | ||
338 | /* set the initial values for the PnP device */ | 338 | /* set the initial values for the PnP device */ |
339 | dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); | 339 | dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); |
340 | if (!dev_id) | 340 | if (!dev_id) |
341 | return -1; | 341 | return -1; |
342 | pnpid32_to_pnpid(node->eisa_id,id); | 342 | pnpid32_to_pnpid(node->eisa_id,id); |
@@ -374,7 +374,7 @@ static void __init build_devlist(void) | |||
374 | struct pnp_bios_node *node; | 374 | struct pnp_bios_node *node; |
375 | struct pnp_dev *dev; | 375 | struct pnp_dev *dev; |
376 | 376 | ||
377 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); | 377 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); |
378 | if (!node) | 378 | if (!node) |
379 | return; | 379 | return; |
380 | 380 | ||
@@ -391,7 +391,7 @@ static void __init build_devlist(void) | |||
391 | break; | 391 | break; |
392 | } | 392 | } |
393 | nodes_got++; | 393 | nodes_got++; |
394 | dev = kcalloc(1, sizeof (struct pnp_dev), GFP_KERNEL); | 394 | dev = kzalloc(sizeof (struct pnp_dev), GFP_KERNEL); |
395 | if (!dev) | 395 | if (!dev) |
396 | break; | 396 | break; |
397 | if(insert_device(dev,node)<0) | 397 | if(insert_device(dev,node)<0) |
diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c index 5a3dfc97f5e9..8027073f7919 100644 --- a/drivers/pnp/pnpbios/proc.c +++ b/drivers/pnp/pnpbios/proc.c | |||
@@ -87,7 +87,7 @@ static int proc_read_escd(char *buf, char **start, off_t pos, | |||
87 | return -EFBIG; | 87 | return -EFBIG; |
88 | } | 88 | } |
89 | 89 | ||
90 | tmpbuf = kcalloc(1, escd.escd_size, GFP_KERNEL); | 90 | tmpbuf = kzalloc(escd.escd_size, GFP_KERNEL); |
91 | if (!tmpbuf) return -ENOMEM; | 91 | if (!tmpbuf) return -ENOMEM; |
92 | 92 | ||
93 | if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) { | 93 | if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) { |
@@ -133,7 +133,7 @@ static int proc_read_devices(char *buf, char **start, off_t pos, | |||
133 | if (pos >= 0xff) | 133 | if (pos >= 0xff) |
134 | return 0; | 134 | return 0; |
135 | 135 | ||
136 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); | 136 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); |
137 | if (!node) return -ENOMEM; | 137 | if (!node) return -ENOMEM; |
138 | 138 | ||
139 | for (nodenum=pos; nodenum<0xff; ) { | 139 | for (nodenum=pos; nodenum<0xff; ) { |
@@ -168,7 +168,7 @@ static int proc_read_node(char *buf, char **start, off_t pos, | |||
168 | u8 nodenum = (long)data; | 168 | u8 nodenum = (long)data; |
169 | int len; | 169 | int len; |
170 | 170 | ||
171 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); | 171 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); |
172 | if (!node) return -ENOMEM; | 172 | if (!node) return -ENOMEM; |
173 | if (pnp_bios_get_dev_node(&nodenum, boot, node)) { | 173 | if (pnp_bios_get_dev_node(&nodenum, boot, node)) { |
174 | kfree(node); | 174 | kfree(node); |
@@ -188,7 +188,7 @@ static int proc_write_node(struct file *file, const char __user *buf, | |||
188 | u8 nodenum = (long)data; | 188 | u8 nodenum = (long)data; |
189 | int ret = count; | 189 | int ret = count; |
190 | 190 | ||
191 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); | 191 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); |
192 | if (!node) | 192 | if (!node) |
193 | return -ENOMEM; | 193 | return -ENOMEM; |
194 | if (pnp_bios_get_dev_node(&nodenum, boot, node)) { | 194 | if (pnp_bios_get_dev_node(&nodenum, boot, node)) { |
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index ef508a4de557..95b79685a9d1 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c | |||
@@ -248,7 +248,7 @@ static void | |||
248 | pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) | 248 | pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) |
249 | { | 249 | { |
250 | struct pnp_mem * mem; | 250 | struct pnp_mem * mem; |
251 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); | 251 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); |
252 | if (!mem) | 252 | if (!mem) |
253 | return; | 253 | return; |
254 | mem->min = ((p[5] << 8) | p[4]) << 8; | 254 | mem->min = ((p[5] << 8) | p[4]) << 8; |
@@ -264,7 +264,7 @@ static void | |||
264 | pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option) | 264 | pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option) |
265 | { | 265 | { |
266 | struct pnp_mem * mem; | 266 | struct pnp_mem * mem; |
267 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); | 267 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); |
268 | if (!mem) | 268 | if (!mem) |
269 | return; | 269 | return; |
270 | mem->min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; | 270 | mem->min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; |
@@ -280,7 +280,7 @@ static void | |||
280 | pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *option) | 280 | pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *option) |
281 | { | 281 | { |
282 | struct pnp_mem * mem; | 282 | struct pnp_mem * mem; |
283 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); | 283 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); |
284 | if (!mem) | 284 | if (!mem) |
285 | return; | 285 | return; |
286 | mem->min = mem->max = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; | 286 | mem->min = mem->max = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; |
@@ -297,7 +297,7 @@ pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option) | |||
297 | struct pnp_irq * irq; | 297 | struct pnp_irq * irq; |
298 | unsigned long bits; | 298 | unsigned long bits; |
299 | 299 | ||
300 | irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); | 300 | irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL); |
301 | if (!irq) | 301 | if (!irq) |
302 | return; | 302 | return; |
303 | bits = (p[2] << 8) | p[1]; | 303 | bits = (p[2] << 8) | p[1]; |
@@ -314,7 +314,7 @@ static void | |||
314 | pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) | 314 | pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) |
315 | { | 315 | { |
316 | struct pnp_dma * dma; | 316 | struct pnp_dma * dma; |
317 | dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); | 317 | dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL); |
318 | if (!dma) | 318 | if (!dma) |
319 | return; | 319 | return; |
320 | dma->map = p[1]; | 320 | dma->map = p[1]; |
@@ -327,7 +327,7 @@ static void | |||
327 | pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) | 327 | pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) |
328 | { | 328 | { |
329 | struct pnp_port * port; | 329 | struct pnp_port * port; |
330 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); | 330 | port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); |
331 | if (!port) | 331 | if (!port) |
332 | return; | 332 | return; |
333 | port->min = (p[3] << 8) | p[2]; | 333 | port->min = (p[3] << 8) | p[2]; |
@@ -343,7 +343,7 @@ static void | |||
343 | pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *option) | 343 | pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *option) |
344 | { | 344 | { |
345 | struct pnp_port * port; | 345 | struct pnp_port * port; |
346 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); | 346 | port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); |
347 | if (!port) | 347 | if (!port) |
348 | return; | 348 | return; |
349 | port->min = port->max = (p[2] << 8) | p[1]; | 349 | port->min = port->max = (p[2] << 8) | p[1]; |
@@ -527,7 +527,7 @@ pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_de | |||
527 | case SMALL_TAG_COMPATDEVID: /* compatible ID */ | 527 | case SMALL_TAG_COMPATDEVID: /* compatible ID */ |
528 | if (len != 4) | 528 | if (len != 4) |
529 | goto len_err; | 529 | goto len_err; |
530 | dev_id = kcalloc(1, sizeof (struct pnp_id), GFP_KERNEL); | 530 | dev_id = kzalloc(sizeof (struct pnp_id), GFP_KERNEL); |
531 | if (!dev_id) | 531 | if (!dev_id) |
532 | return NULL; | 532 | return NULL; |
533 | memset(dev_id, 0, sizeof(struct pnp_id)); | 533 | memset(dev_id, 0, sizeof(struct pnp_id)); |
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index 5c8addcaf1fb..4f654c901c64 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c | |||
@@ -137,6 +137,9 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
137 | tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year); | 137 | tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year); |
138 | tm->tm_year = at91_alarm_year - 1900; | 138 | tm->tm_year = at91_alarm_year - 1900; |
139 | 139 | ||
140 | alrm->enabled = (at91_sys_read(AT91_RTC_IMR) & AT91_RTC_ALARM) | ||
141 | ? 1 : 0; | ||
142 | |||
140 | pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, | 143 | pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, |
141 | 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, | 144 | 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, |
142 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 145 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
@@ -223,8 +226,6 @@ static int at91_rtc_proc(struct device *dev, struct seq_file *seq) | |||
223 | { | 226 | { |
224 | unsigned long imr = at91_sys_read(AT91_RTC_IMR); | 227 | unsigned long imr = at91_sys_read(AT91_RTC_IMR); |
225 | 228 | ||
226 | seq_printf(seq, "alarm_IRQ\t: %s\n", | ||
227 | (imr & AT91_RTC_ALARM) ? "yes" : "no"); | ||
228 | seq_printf(seq, "update_IRQ\t: %s\n", | 229 | seq_printf(seq, "update_IRQ\t: %s\n", |
229 | (imr & AT91_RTC_ACKUPD) ? "yes" : "no"); | 230 | (imr & AT91_RTC_ACKUPD) ? "yes" : "no"); |
230 | seq_printf(seq, "periodic_IRQ\t: %s\n", | 231 | seq_printf(seq, "periodic_IRQ\t: %s\n", |
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index 828b329e08e0..94d3df62a5fa 100644 --- a/drivers/rtc/rtc-dev.c +++ b/drivers/rtc/rtc-dev.c | |||
@@ -435,7 +435,7 @@ static int rtc_dev_add_device(struct class_device *class_dev, | |||
435 | goto err_cdev_del; | 435 | goto err_cdev_del; |
436 | } | 436 | } |
437 | 437 | ||
438 | dev_info(class_dev->dev, "rtc intf: dev (%d:%d)\n", | 438 | dev_dbg(class_dev->dev, "rtc intf: dev (%d:%d)\n", |
439 | MAJOR(rtc->rtc_dev->devt), | 439 | MAJOR(rtc->rtc_dev->devt), |
440 | MINOR(rtc->rtc_dev->devt)); | 440 | MINOR(rtc->rtc_dev->devt)); |
441 | 441 | ||
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index eac5fb1fc02f..d59880d44fba 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -279,9 +279,8 @@ static int omap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
279 | local_irq_enable(); | 279 | local_irq_enable(); |
280 | 280 | ||
281 | bcd2tm(&alm->time); | 281 | bcd2tm(&alm->time); |
282 | alm->pending = !!(rtc_read(OMAP_RTC_INTERRUPTS_REG) | 282 | alm->enabled = !!(rtc_read(OMAP_RTC_INTERRUPTS_REG) |
283 | & OMAP_RTC_INTERRUPTS_IT_ALARM); | 283 | & OMAP_RTC_INTERRUPTS_IT_ALARM); |
284 | alm->enabled = alm->pending && device_may_wakeup(dev); | ||
285 | 284 | ||
286 | return 0; | 285 | return 0; |
287 | } | 286 | } |
diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c index d51d8f20e634..c272afd62173 100644 --- a/drivers/rtc/rtc-proc.c +++ b/drivers/rtc/rtc-proc.c | |||
@@ -65,7 +65,7 @@ static int rtc_proc_show(struct seq_file *seq, void *offset) | |||
65 | seq_printf(seq, "%02d\n", alrm.time.tm_mday); | 65 | seq_printf(seq, "%02d\n", alrm.time.tm_mday); |
66 | else | 66 | else |
67 | seq_printf(seq, "**\n"); | 67 | seq_printf(seq, "**\n"); |
68 | seq_printf(seq, "alrm_wakeup\t: %s\n", | 68 | seq_printf(seq, "alarm_IRQ\t: %s\n", |
69 | alrm.enabled ? "yes" : "no"); | 69 | alrm.enabled ? "yes" : "no"); |
70 | seq_printf(seq, "alrm_pending\t: %s\n", | 70 | seq_printf(seq, "alrm_pending\t: %s\n", |
71 | alrm.pending ? "yes" : "no"); | 71 | alrm.pending ? "yes" : "no"); |
@@ -120,7 +120,7 @@ static int rtc_proc_add_device(struct class_device *class_dev, | |||
120 | ent->owner = rtc->owner; | 120 | ent->owner = rtc->owner; |
121 | ent->data = class_dev; | 121 | ent->data = class_dev; |
122 | 122 | ||
123 | dev_info(class_dev->dev, "rtc intf: proc\n"); | 123 | dev_dbg(class_dev->dev, "rtc intf: proc\n"); |
124 | } | 124 | } |
125 | else | 125 | else |
126 | rtc_dev = NULL; | 126 | rtc_dev = NULL; |
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index e301dea57bb3..f406a2b55aea 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -191,6 +191,8 @@ static int s3c_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
191 | 191 | ||
192 | alm_en = readb(base + S3C2410_RTCALM); | 192 | alm_en = readb(base + S3C2410_RTCALM); |
193 | 193 | ||
194 | alrm->enabled = (alm_en & S3C2410_RTCALM_ALMEN) ? 1 : 0; | ||
195 | |||
194 | pr_debug("read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n", | 196 | pr_debug("read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n", |
195 | alm_en, | 197 | alm_en, |
196 | alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday, | 198 | alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday, |
@@ -331,12 +333,8 @@ static int s3c_rtc_ioctl(struct device *dev, | |||
331 | 333 | ||
332 | static int s3c_rtc_proc(struct device *dev, struct seq_file *seq) | 334 | static int s3c_rtc_proc(struct device *dev, struct seq_file *seq) |
333 | { | 335 | { |
334 | unsigned int rtcalm = readb(s3c_rtc_base + S3C2410_RTCALM); | ||
335 | unsigned int ticnt = readb(s3c_rtc_base + S3C2410_TICNT); | 336 | unsigned int ticnt = readb(s3c_rtc_base + S3C2410_TICNT); |
336 | 337 | ||
337 | seq_printf(seq, "alarm_IRQ\t: %s\n", | ||
338 | (rtcalm & S3C2410_RTCALM_ALMEN) ? "yes" : "no" ); | ||
339 | |||
340 | seq_printf(seq, "periodic_IRQ\t: %s\n", | 338 | seq_printf(seq, "periodic_IRQ\t: %s\n", |
341 | (ticnt & S3C2410_TICNT_ENABLE) ? "yes" : "no" ); | 339 | (ticnt & S3C2410_TICNT_ENABLE) ? "yes" : "no" ); |
342 | 340 | ||
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index bd4d7d174ef4..9c8ead43a59c 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -289,9 +289,7 @@ static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
289 | 289 | ||
290 | static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) | 290 | static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) |
291 | { | 291 | { |
292 | seq_printf(seq, "trim/divider\t: 0x%08lx\n", RTTR); | 292 | seq_printf(seq, "trim/divider\t: 0x%08x\n", (u32) RTTR); |
293 | seq_printf(seq, "alarm_IRQ\t: %s\n", | ||
294 | (RTSR & RTSR_ALE) ? "yes" : "no" ); | ||
295 | seq_printf(seq, "update_IRQ\t: %s\n", | 293 | seq_printf(seq, "update_IRQ\t: %s\n", |
296 | (RTSR & RTSR_HZE) ? "yes" : "no"); | 294 | (RTSR & RTSR_HZE) ? "yes" : "no"); |
297 | seq_printf(seq, "periodic_IRQ\t: %s\n", | 295 | seq_printf(seq, "periodic_IRQ\t: %s\n", |
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c index 625637b84d33..9418a59fb368 100644 --- a/drivers/rtc/rtc-sysfs.c +++ b/drivers/rtc/rtc-sysfs.c | |||
@@ -83,7 +83,7 @@ static int __devinit rtc_sysfs_add_device(struct class_device *class_dev, | |||
83 | { | 83 | { |
84 | int err; | 84 | int err; |
85 | 85 | ||
86 | dev_info(class_dev->dev, "rtc intf: sysfs\n"); | 86 | dev_dbg(class_dev->dev, "rtc intf: sysfs\n"); |
87 | 87 | ||
88 | err = sysfs_create_group(&class_dev->kobj, &rtc_attr_group); | 88 | err = sysfs_create_group(&class_dev->kobj, &rtc_attr_group); |
89 | if (err) | 89 | if (err) |
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index c9321b920e90..25b5d7a66417 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c | |||
@@ -688,7 +688,7 @@ raw3215_probe (struct ccw_device *cdev) | |||
688 | raw->cdev = cdev; | 688 | raw->cdev = cdev; |
689 | raw->inbuf = (char *) raw + sizeof(struct raw3215_info); | 689 | raw->inbuf = (char *) raw + sizeof(struct raw3215_info); |
690 | memset(raw, 0, sizeof(struct raw3215_info)); | 690 | memset(raw, 0, sizeof(struct raw3215_info)); |
691 | raw->buffer = (char *) kmalloc(RAW3215_BUFFER_SIZE, | 691 | raw->buffer = kmalloc(RAW3215_BUFFER_SIZE, |
692 | GFP_KERNEL|GFP_DMA); | 692 | GFP_KERNEL|GFP_DMA); |
693 | if (raw->buffer == NULL) { | 693 | if (raw->buffer == NULL) { |
694 | spin_lock(&raw3215_device_lock); | 694 | spin_lock(&raw3215_device_lock); |
diff --git a/drivers/s390/char/keyboard.c b/drivers/s390/char/keyboard.c index e3491a5f5219..3e86fd1756e5 100644 --- a/drivers/s390/char/keyboard.c +++ b/drivers/s390/char/keyboard.c | |||
@@ -377,7 +377,7 @@ do_kdsk_ioctl(struct kbd_data *kbd, struct kbentry __user *user_kbe, | |||
377 | if (!(key_map = kbd->key_maps[tmp.kb_table])) { | 377 | if (!(key_map = kbd->key_maps[tmp.kb_table])) { |
378 | int j; | 378 | int j; |
379 | 379 | ||
380 | key_map = (ushort *) kmalloc(sizeof(plain_map), | 380 | key_map = kmalloc(sizeof(plain_map), |
381 | GFP_KERNEL); | 381 | GFP_KERNEL); |
382 | if (!key_map) | 382 | if (!key_map) |
383 | return -ENOMEM; | 383 | return -ENOMEM; |
diff --git a/drivers/s390/char/sclp_cpi.c b/drivers/s390/char/sclp_cpi.c index 732dfbdb85c4..4f873ae148b7 100644 --- a/drivers/s390/char/sclp_cpi.c +++ b/drivers/s390/char/sclp_cpi.c | |||
@@ -49,6 +49,8 @@ static struct sclp_register sclp_cpi_event = | |||
49 | .send_mask = EvTyp_CtlProgIdent_Mask | 49 | .send_mask = EvTyp_CtlProgIdent_Mask |
50 | }; | 50 | }; |
51 | 51 | ||
52 | MODULE_LICENSE("GPL"); | ||
53 | |||
52 | MODULE_AUTHOR( | 54 | MODULE_AUTHOR( |
53 | "Martin Peschke, IBM Deutschland Entwicklung GmbH " | 55 | "Martin Peschke, IBM Deutschland Entwicklung GmbH " |
54 | "<mpeschke@de.ibm.com>"); | 56 | "<mpeschke@de.ibm.com>"); |
@@ -127,7 +129,7 @@ cpi_prepare_req(void) | |||
127 | struct cpi_sccb *sccb; | 129 | struct cpi_sccb *sccb; |
128 | struct cpi_evbuf *evb; | 130 | struct cpi_evbuf *evb; |
129 | 131 | ||
130 | req = (struct sclp_req *) kmalloc(sizeof(struct sclp_req), GFP_KERNEL); | 132 | req = kmalloc(sizeof(struct sclp_req), GFP_KERNEL); |
131 | if (req == NULL) | 133 | if (req == NULL) |
132 | return ERR_PTR(-ENOMEM); | 134 | return ERR_PTR(-ENOMEM); |
133 | sccb = (struct cpi_sccb *) __get_free_page(GFP_KERNEL | GFP_DMA); | 135 | sccb = (struct cpi_sccb *) __get_free_page(GFP_KERNEL | GFP_DMA); |
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c index 7835a714a405..3a403f195cf8 100644 --- a/drivers/s390/cio/cio.c +++ b/drivers/s390/cio/cio.c | |||
@@ -871,11 +871,32 @@ __clear_subchannel_easy(struct subchannel_id schid) | |||
871 | return -EBUSY; | 871 | return -EBUSY; |
872 | } | 872 | } |
873 | 873 | ||
874 | static int pgm_check_occured; | ||
875 | |||
876 | static void cio_reset_pgm_check_handler(void) | ||
877 | { | ||
878 | pgm_check_occured = 1; | ||
879 | } | ||
880 | |||
881 | static int stsch_reset(struct subchannel_id schid, volatile struct schib *addr) | ||
882 | { | ||
883 | int rc; | ||
884 | |||
885 | pgm_check_occured = 0; | ||
886 | s390_reset_pgm_handler = cio_reset_pgm_check_handler; | ||
887 | rc = stsch(schid, addr); | ||
888 | s390_reset_pgm_handler = NULL; | ||
889 | if (pgm_check_occured) | ||
890 | return -EIO; | ||
891 | else | ||
892 | return rc; | ||
893 | } | ||
894 | |||
874 | static int __shutdown_subchannel_easy(struct subchannel_id schid, void *data) | 895 | static int __shutdown_subchannel_easy(struct subchannel_id schid, void *data) |
875 | { | 896 | { |
876 | struct schib schib; | 897 | struct schib schib; |
877 | 898 | ||
878 | if (stsch_err(schid, &schib)) | 899 | if (stsch_reset(schid, &schib)) |
879 | return -ENXIO; | 900 | return -ENXIO; |
880 | if (!schib.pmcw.ena) | 901 | if (!schib.pmcw.ena) |
881 | return 0; | 902 | return 0; |
@@ -972,7 +993,7 @@ static int __reipl_subchannel_match(struct subchannel_id schid, void *data) | |||
972 | struct schib schib; | 993 | struct schib schib; |
973 | struct sch_match_id *match_id = data; | 994 | struct sch_match_id *match_id = data; |
974 | 995 | ||
975 | if (stsch_err(schid, &schib)) | 996 | if (stsch_reset(schid, &schib)) |
976 | return -ENXIO; | 997 | return -ENXIO; |
977 | if (schib.pmcw.dnv && | 998 | if (schib.pmcw.dnv && |
978 | (schib.pmcw.dev == match_id->devid.devno) && | 999 | (schib.pmcw.dev == match_id->devid.devno) && |
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index 4c81d890791e..9d6c02446863 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c | |||
@@ -139,6 +139,8 @@ css_register_subchannel(struct subchannel *sch) | |||
139 | sch->dev.release = &css_subchannel_release; | 139 | sch->dev.release = &css_subchannel_release; |
140 | sch->dev.groups = subch_attr_groups; | 140 | sch->dev.groups = subch_attr_groups; |
141 | 141 | ||
142 | css_get_ssd_info(sch); | ||
143 | |||
142 | /* make it known to the system */ | 144 | /* make it known to the system */ |
143 | ret = css_sch_device_register(sch); | 145 | ret = css_sch_device_register(sch); |
144 | if (ret) { | 146 | if (ret) { |
@@ -146,7 +148,6 @@ css_register_subchannel(struct subchannel *sch) | |||
146 | __func__, sch->dev.bus_id); | 148 | __func__, sch->dev.bus_id); |
147 | return ret; | 149 | return ret; |
148 | } | 150 | } |
149 | css_get_ssd_info(sch); | ||
150 | return ret; | 151 | return ret; |
151 | } | 152 | } |
152 | 153 | ||
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c index 9d4ea449a608..6fd1940842eb 100644 --- a/drivers/s390/cio/qdio.c +++ b/drivers/s390/cio/qdio.c | |||
@@ -979,12 +979,11 @@ __qdio_outbound_processing(struct qdio_q *q) | |||
979 | 979 | ||
980 | if (q->is_iqdio_q) { | 980 | if (q->is_iqdio_q) { |
981 | /* | 981 | /* |
982 | * for asynchronous queues, we better check, if the fill | 982 | * for asynchronous queues, we better check, if the sent |
983 | * level is too high. for synchronous queues, the fill | 983 | * buffer is already switched from PRIMED to EMPTY. |
984 | * level will never be that high. | ||
985 | */ | 984 | */ |
986 | if (atomic_read(&q->number_of_buffers_used)> | 985 | if ((q->queue_type == QDIO_IQDIO_QFMT_ASYNCH) && |
987 | IQDIO_FILL_LEVEL_TO_POLL) | 986 | !qdio_is_outbound_q_done(q)) |
988 | qdio_mark_q(q); | 987 | qdio_mark_q(q); |
989 | 988 | ||
990 | } else if (!q->hydra_gives_outbound_pcis) | 989 | } else if (!q->hydra_gives_outbound_pcis) |
@@ -1825,6 +1824,10 @@ qdio_fill_qs(struct qdio_irq *irq_ptr, struct ccw_device *cdev, | |||
1825 | q->sbal[j]=*(outbound_sbals_array++); | 1824 | q->sbal[j]=*(outbound_sbals_array++); |
1826 | 1825 | ||
1827 | q->queue_type=q_format; | 1826 | q->queue_type=q_format; |
1827 | if ((q->queue_type == QDIO_IQDIO_QFMT) && | ||
1828 | (no_output_qs > 1) && | ||
1829 | (i == no_output_qs-1)) | ||
1830 | q->queue_type = QDIO_IQDIO_QFMT_ASYNCH; | ||
1828 | q->int_parm=int_parm; | 1831 | q->int_parm=int_parm; |
1829 | q->is_input_q=0; | 1832 | q->is_input_q=0; |
1830 | q->schid = irq_ptr->schid; | 1833 | q->schid = irq_ptr->schid; |
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index ad60afe5dd11..81b5899f4010 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c | |||
@@ -1129,7 +1129,15 @@ static void ap_poll_thread_stop(void) | |||
1129 | mutex_unlock(&ap_poll_thread_mutex); | 1129 | mutex_unlock(&ap_poll_thread_mutex); |
1130 | } | 1130 | } |
1131 | 1131 | ||
1132 | static void ap_reset(void) | 1132 | static void ap_reset_domain(void) |
1133 | { | ||
1134 | int i; | ||
1135 | |||
1136 | for (i = 0; i < AP_DEVICES; i++) | ||
1137 | ap_reset_queue(AP_MKQID(i, ap_domain_index)); | ||
1138 | } | ||
1139 | |||
1140 | static void ap_reset_all(void) | ||
1133 | { | 1141 | { |
1134 | int i, j; | 1142 | int i, j; |
1135 | 1143 | ||
@@ -1139,7 +1147,7 @@ static void ap_reset(void) | |||
1139 | } | 1147 | } |
1140 | 1148 | ||
1141 | static struct reset_call ap_reset_call = { | 1149 | static struct reset_call ap_reset_call = { |
1142 | .fn = ap_reset, | 1150 | .fn = ap_reset_all, |
1143 | }; | 1151 | }; |
1144 | 1152 | ||
1145 | /** | 1153 | /** |
@@ -1229,10 +1237,12 @@ void ap_module_exit(void) | |||
1229 | int i; | 1237 | int i; |
1230 | struct device *dev; | 1238 | struct device *dev; |
1231 | 1239 | ||
1240 | ap_reset_domain(); | ||
1232 | ap_poll_thread_stop(); | 1241 | ap_poll_thread_stop(); |
1233 | del_timer_sync(&ap_config_timer); | 1242 | del_timer_sync(&ap_config_timer); |
1234 | del_timer_sync(&ap_poll_timer); | 1243 | del_timer_sync(&ap_poll_timer); |
1235 | destroy_workqueue(ap_work_queue); | 1244 | destroy_workqueue(ap_work_queue); |
1245 | tasklet_kill(&ap_tasklet); | ||
1236 | s390_root_dev_unregister(ap_root_device); | 1246 | s390_root_dev_unregister(ap_root_device); |
1237 | while ((dev = bus_find_device(&ap_bus_type, NULL, NULL, | 1247 | while ((dev = bus_find_device(&ap_bus_type, NULL, NULL, |
1238 | __ap_match_all))) | 1248 | __ap_match_all))) |
diff --git a/drivers/s390/crypto/zcrypt_cex2a.c b/drivers/s390/crypto/zcrypt_cex2a.c index a62b00083d0c..5bb13a9d0898 100644 --- a/drivers/s390/crypto/zcrypt_cex2a.c +++ b/drivers/s390/crypto/zcrypt_cex2a.c | |||
@@ -295,7 +295,7 @@ static long zcrypt_cex2a_modexpo(struct zcrypt_device *zdev, | |||
295 | struct completion work; | 295 | struct completion work; |
296 | int rc; | 296 | int rc; |
297 | 297 | ||
298 | ap_msg.message = (void *) kmalloc(CEX2A_MAX_MESSAGE_SIZE, GFP_KERNEL); | 298 | ap_msg.message = kmalloc(CEX2A_MAX_MESSAGE_SIZE, GFP_KERNEL); |
299 | if (!ap_msg.message) | 299 | if (!ap_msg.message) |
300 | return -ENOMEM; | 300 | return -ENOMEM; |
301 | ap_msg.psmid = (((unsigned long long) current->pid) << 32) + | 301 | ap_msg.psmid = (((unsigned long long) current->pid) << 32) + |
@@ -337,7 +337,7 @@ static long zcrypt_cex2a_modexpo_crt(struct zcrypt_device *zdev, | |||
337 | struct completion work; | 337 | struct completion work; |
338 | int rc; | 338 | int rc; |
339 | 339 | ||
340 | ap_msg.message = (void *) kmalloc(CEX2A_MAX_MESSAGE_SIZE, GFP_KERNEL); | 340 | ap_msg.message = kmalloc(CEX2A_MAX_MESSAGE_SIZE, GFP_KERNEL); |
341 | if (!ap_msg.message) | 341 | if (!ap_msg.message) |
342 | return -ENOMEM; | 342 | return -ENOMEM; |
343 | ap_msg.psmid = (((unsigned long long) current->pid) << 32) + | 343 | ap_msg.psmid = (((unsigned long long) current->pid) << 32) + |
diff --git a/drivers/s390/crypto/zcrypt_pcica.c b/drivers/s390/crypto/zcrypt_pcica.c index b6a4ecdc8025..32e37014345c 100644 --- a/drivers/s390/crypto/zcrypt_pcica.c +++ b/drivers/s390/crypto/zcrypt_pcica.c | |||
@@ -279,7 +279,7 @@ static long zcrypt_pcica_modexpo(struct zcrypt_device *zdev, | |||
279 | struct completion work; | 279 | struct completion work; |
280 | int rc; | 280 | int rc; |
281 | 281 | ||
282 | ap_msg.message = (void *) kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL); | 282 | ap_msg.message = kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL); |
283 | if (!ap_msg.message) | 283 | if (!ap_msg.message) |
284 | return -ENOMEM; | 284 | return -ENOMEM; |
285 | ap_msg.psmid = (((unsigned long long) current->pid) << 32) + | 285 | ap_msg.psmid = (((unsigned long long) current->pid) << 32) + |
@@ -321,7 +321,7 @@ static long zcrypt_pcica_modexpo_crt(struct zcrypt_device *zdev, | |||
321 | struct completion work; | 321 | struct completion work; |
322 | int rc; | 322 | int rc; |
323 | 323 | ||
324 | ap_msg.message = (void *) kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL); | 324 | ap_msg.message = kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL); |
325 | if (!ap_msg.message) | 325 | if (!ap_msg.message) |
326 | return -ENOMEM; | 326 | return -ENOMEM; |
327 | ap_msg.psmid = (((unsigned long long) current->pid) << 32) + | 327 | ap_msg.psmid = (((unsigned long long) current->pid) << 32) + |
diff --git a/drivers/s390/crypto/zcrypt_pcixcc.c b/drivers/s390/crypto/zcrypt_pcixcc.c index 2da8b9381407..b7153c1e15cd 100644 --- a/drivers/s390/crypto/zcrypt_pcixcc.c +++ b/drivers/s390/crypto/zcrypt_pcixcc.c | |||
@@ -717,7 +717,7 @@ long zcrypt_pcixcc_send_cprb(struct zcrypt_device *zdev, struct ica_xcRB *xcRB) | |||
717 | }; | 717 | }; |
718 | int rc; | 718 | int rc; |
719 | 719 | ||
720 | ap_msg.message = (void *) kmalloc(PCIXCC_MAX_XCRB_MESSAGE_SIZE, GFP_KERNEL); | 720 | ap_msg.message = kmalloc(PCIXCC_MAX_XCRB_MESSAGE_SIZE, GFP_KERNEL); |
721 | if (!ap_msg.message) | 721 | if (!ap_msg.message) |
722 | return -ENOMEM; | 722 | return -ENOMEM; |
723 | ap_msg.psmid = (((unsigned long long) current->pid) << 32) + | 723 | ap_msg.psmid = (((unsigned long long) current->pid) << 32) + |
diff --git a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c index 3257c22dd79c..03cc263fe0da 100644 --- a/drivers/s390/net/ctcmain.c +++ b/drivers/s390/net/ctcmain.c | |||
@@ -1646,7 +1646,7 @@ add_channel(struct ccw_device *cdev, enum channel_types type) | |||
1646 | return -1; | 1646 | return -1; |
1647 | } | 1647 | } |
1648 | memset(ch, 0, sizeof (struct channel)); | 1648 | memset(ch, 0, sizeof (struct channel)); |
1649 | if ((ch->ccw = (struct ccw1 *) kmalloc(8*sizeof(struct ccw1), | 1649 | if ((ch->ccw = kmalloc(8*sizeof(struct ccw1), |
1650 | GFP_KERNEL | GFP_DMA)) == NULL) { | 1650 | GFP_KERNEL | GFP_DMA)) == NULL) { |
1651 | kfree(ch); | 1651 | kfree(ch); |
1652 | ctc_pr_warn("ctc: Out of memory in add_channel\n"); | 1652 | ctc_pr_warn("ctc: Out of memory in add_channel\n"); |
@@ -1693,7 +1693,7 @@ add_channel(struct ccw_device *cdev, enum channel_types type) | |||
1693 | return -1; | 1693 | return -1; |
1694 | } | 1694 | } |
1695 | fsm_newstate(ch->fsm, CH_STATE_IDLE); | 1695 | fsm_newstate(ch->fsm, CH_STATE_IDLE); |
1696 | if ((ch->irb = (struct irb *) kmalloc(sizeof (struct irb), | 1696 | if ((ch->irb = kmalloc(sizeof (struct irb), |
1697 | GFP_KERNEL)) == NULL) { | 1697 | GFP_KERNEL)) == NULL) { |
1698 | ctc_pr_warn("ctc: Out of memory in add_channel\n"); | 1698 | ctc_pr_warn("ctc: Out of memory in add_channel\n"); |
1699 | kfree_fsm(ch->fsm); | 1699 | kfree_fsm(ch->fsm); |
@@ -2535,7 +2535,7 @@ ctc_print_statistics(struct ctc_priv *priv) | |||
2535 | DBF_TEXT(trace, 4, __FUNCTION__); | 2535 | DBF_TEXT(trace, 4, __FUNCTION__); |
2536 | if (!priv) | 2536 | if (!priv) |
2537 | return; | 2537 | return; |
2538 | sbuf = (char *)kmalloc(2048, GFP_KERNEL); | 2538 | sbuf = kmalloc(2048, GFP_KERNEL); |
2539 | if (sbuf == NULL) | 2539 | if (sbuf == NULL) |
2540 | return; | 2540 | return; |
2541 | p = sbuf; | 2541 | p = sbuf; |
diff --git a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c index 1476ce2b437c..229aeb5fc399 100644 --- a/drivers/s390/net/iucv.c +++ b/drivers/s390/net/iucv.c | |||
@@ -772,7 +772,7 @@ iucv_register_program (__u8 pgmname[16], | |||
772 | } | 772 | } |
773 | 773 | ||
774 | /* Allocate handler entry */ | 774 | /* Allocate handler entry */ |
775 | new_handler = (handler *)kmalloc(sizeof(handler), GFP_ATOMIC); | 775 | new_handler = kmalloc(sizeof(handler), GFP_ATOMIC); |
776 | if (new_handler == NULL) { | 776 | if (new_handler == NULL) { |
777 | printk(KERN_WARNING "%s: storage allocation for new handler " | 777 | printk(KERN_WARNING "%s: storage allocation for new handler " |
778 | "failed.\n", __FUNCTION__); | 778 | "failed.\n", __FUNCTION__); |
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c index 5d39b2df0cc4..85093b71f9fa 100644 --- a/drivers/s390/scsi/zfcp_aux.c +++ b/drivers/s390/scsi/zfcp_aux.c | |||
@@ -237,7 +237,7 @@ zfcp_device_setup(char *devstr) | |||
237 | return 0; | 237 | return 0; |
238 | 238 | ||
239 | len = strlen(devstr) + 1; | 239 | len = strlen(devstr) + 1; |
240 | str = (char *) kmalloc(len, GFP_KERNEL); | 240 | str = kmalloc(len, GFP_KERNEL); |
241 | if (!str) | 241 | if (!str) |
242 | goto err_out; | 242 | goto err_out; |
243 | memcpy(str, devstr, len); | 243 | memcpy(str, devstr, len); |
diff --git a/drivers/sbus/char/vfc_dev.c b/drivers/sbus/char/vfc_dev.c index 2722af5d3404..386e7de0b7e3 100644 --- a/drivers/sbus/char/vfc_dev.c +++ b/drivers/sbus/char/vfc_dev.c | |||
@@ -659,7 +659,7 @@ static int vfc_probe(void) | |||
659 | if (!cards) | 659 | if (!cards) |
660 | return -ENODEV; | 660 | return -ENODEV; |
661 | 661 | ||
662 | vfc_dev_lst = (struct vfc_dev **)kmalloc(sizeof(struct vfc_dev *) * | 662 | vfc_dev_lst = kmalloc(sizeof(struct vfc_dev *) * |
663 | (cards+1), | 663 | (cards+1), |
664 | GFP_KERNEL); | 664 | GFP_KERNEL); |
665 | if (vfc_dev_lst == NULL) | 665 | if (vfc_dev_lst == NULL) |
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index ac108f9e2674..426cd6f49f5d 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c | |||
@@ -288,7 +288,7 @@ int aac_get_containers(struct aac_dev *dev) | |||
288 | 288 | ||
289 | if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS) | 289 | if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS) |
290 | maximum_num_containers = MAXIMUM_NUM_CONTAINERS; | 290 | maximum_num_containers = MAXIMUM_NUM_CONTAINERS; |
291 | fsa_dev_ptr = (struct fsa_dev_info *) kmalloc( | 291 | fsa_dev_ptr = kmalloc( |
292 | sizeof(*fsa_dev_ptr) * maximum_num_containers, GFP_KERNEL); | 292 | sizeof(*fsa_dev_ptr) * maximum_num_containers, GFP_KERNEL); |
293 | if (!fsa_dev_ptr) { | 293 | if (!fsa_dev_ptr) { |
294 | aac_fib_free(fibptr); | 294 | aac_fib_free(fibptr); |
diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index d5cf8b91a0e7..6d305b2f854e 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c | |||
@@ -386,7 +386,7 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev) | |||
386 | * Ok now init the communication subsystem | 386 | * Ok now init the communication subsystem |
387 | */ | 387 | */ |
388 | 388 | ||
389 | dev->queues = (struct aac_queue_block *) kmalloc(sizeof(struct aac_queue_block), GFP_KERNEL); | 389 | dev->queues = kmalloc(sizeof(struct aac_queue_block), GFP_KERNEL); |
390 | if (dev->queues == NULL) { | 390 | if (dev->queues == NULL) { |
391 | printk(KERN_ERR "Error could not allocate comm region.\n"); | 391 | printk(KERN_ERR "Error could not allocate comm region.\n"); |
392 | return NULL; | 392 | return NULL; |
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index d7a61a6bdaae..1d239f6c0103 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c | |||
@@ -699,7 +699,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) | |||
699 | #endif | 699 | #endif |
700 | int i; | 700 | int i; |
701 | ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */ | 701 | ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */ |
702 | SCpnt->host_scribble = (unsigned char *) kmalloc(512, GFP_KERNEL | GFP_DMA); | 702 | SCpnt->host_scribble = kmalloc(512, GFP_KERNEL | GFP_DMA); |
703 | sgpnt = (struct scatterlist *) SCpnt->request_buffer; | 703 | sgpnt = (struct scatterlist *) SCpnt->request_buffer; |
704 | cptr = (struct chain *) SCpnt->host_scribble; | 704 | cptr = (struct chain *) SCpnt->host_scribble; |
705 | if (cptr == NULL) { | 705 | if (cptr == NULL) { |
diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c index 46eed10b25d9..7d1fec620948 100644 --- a/drivers/scsi/aic7xxx_old.c +++ b/drivers/scsi/aic7xxx_old.c | |||
@@ -2565,7 +2565,7 @@ aic7xxx_allocate_scb(struct aic7xxx_host *p) | |||
2565 | } | 2565 | } |
2566 | } | 2566 | } |
2567 | scb_count = min( (i-1), p->scb_data->maxscbs - p->scb_data->numscbs); | 2567 | scb_count = min( (i-1), p->scb_data->maxscbs - p->scb_data->numscbs); |
2568 | scb_ap = (struct aic7xxx_scb *)kmalloc(sizeof (struct aic7xxx_scb) * scb_count | 2568 | scb_ap = kmalloc(sizeof (struct aic7xxx_scb) * scb_count |
2569 | + sizeof(struct aic7xxx_scb_dma), GFP_ATOMIC); | 2569 | + sizeof(struct aic7xxx_scb_dma), GFP_ATOMIC); |
2570 | if (scb_ap == NULL) | 2570 | if (scb_ap == NULL) |
2571 | return(0); | 2571 | return(0); |
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index e95b367d09ed..a965ed3548d5 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c | |||
@@ -4319,7 +4319,7 @@ static int __devinit adapter_sg_tables_alloc(struct AdapterCtlBlk *acb) | |||
4319 | 4319 | ||
4320 | dprintkdbg(DBG_1, "Allocate %i pages for SG tables\n", pages); | 4320 | dprintkdbg(DBG_1, "Allocate %i pages for SG tables\n", pages); |
4321 | while (pages--) { | 4321 | while (pages--) { |
4322 | ptr = (struct SGentry *)kmalloc(PAGE_SIZE, GFP_KERNEL); | 4322 | ptr = kmalloc(PAGE_SIZE, GFP_KERNEL); |
4323 | if (!ptr) { | 4323 | if (!ptr) { |
4324 | adapter_sg_tables_free(acb); | 4324 | adapter_sg_tables_free(acb); |
4325 | return 1; | 4325 | return 1; |
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 60b1b434eba7..365db537a28d 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c | |||
@@ -297,7 +297,7 @@ static void adpt_inquiry(adpt_hba* pHba) | |||
297 | s32 rcode; | 297 | s32 rcode; |
298 | 298 | ||
299 | memset(msg, 0, sizeof(msg)); | 299 | memset(msg, 0, sizeof(msg)); |
300 | buf = (u8*)kmalloc(80,GFP_KERNEL|ADDR32); | 300 | buf = kmalloc(80,GFP_KERNEL|ADDR32); |
301 | if(!buf){ | 301 | if(!buf){ |
302 | printk(KERN_ERR"%s: Could not allocate buffer\n",pHba->name); | 302 | printk(KERN_ERR"%s: Could not allocate buffer\n",pHba->name); |
303 | return; | 303 | return; |
@@ -1311,7 +1311,7 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba) | |||
1311 | schedule_timeout_uninterruptible(1); | 1311 | schedule_timeout_uninterruptible(1); |
1312 | } while (m == EMPTY_QUEUE); | 1312 | } while (m == EMPTY_QUEUE); |
1313 | 1313 | ||
1314 | status = (u8*)kmalloc(4, GFP_KERNEL|ADDR32); | 1314 | status = kmalloc(4, GFP_KERNEL|ADDR32); |
1315 | if(status == NULL) { | 1315 | if(status == NULL) { |
1316 | adpt_send_nop(pHba, m); | 1316 | adpt_send_nop(pHba, m); |
1317 | printk(KERN_ERR"IOP reset failed - no free memory.\n"); | 1317 | printk(KERN_ERR"IOP reset failed - no free memory.\n"); |
@@ -1444,7 +1444,7 @@ static int adpt_i2o_parse_lct(adpt_hba* pHba) | |||
1444 | } | 1444 | } |
1445 | continue; | 1445 | continue; |
1446 | } | 1446 | } |
1447 | d = (struct i2o_device *)kmalloc(sizeof(struct i2o_device), GFP_KERNEL); | 1447 | d = kmalloc(sizeof(struct i2o_device), GFP_KERNEL); |
1448 | if(d==NULL) | 1448 | if(d==NULL) |
1449 | { | 1449 | { |
1450 | printk(KERN_CRIT"%s: Out of memory for I2O device data.\n",pHba->name); | 1450 | printk(KERN_CRIT"%s: Out of memory for I2O device data.\n",pHba->name); |
@@ -2425,7 +2425,7 @@ static s32 adpt_i2o_reparse_lct(adpt_hba* pHba) | |||
2425 | pDev = pDev->next_lun; | 2425 | pDev = pDev->next_lun; |
2426 | } | 2426 | } |
2427 | if(!pDev ) { // Something new add it | 2427 | if(!pDev ) { // Something new add it |
2428 | d = (struct i2o_device *)kmalloc(sizeof(struct i2o_device), GFP_KERNEL); | 2428 | d = kmalloc(sizeof(struct i2o_device), GFP_KERNEL); |
2429 | if(d==NULL) | 2429 | if(d==NULL) |
2430 | { | 2430 | { |
2431 | printk(KERN_CRIT "Out of memory for I2O device data.\n"); | 2431 | printk(KERN_CRIT "Out of memory for I2O device data.\n"); |
@@ -2728,7 +2728,7 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba) | |||
2728 | 2728 | ||
2729 | kfree(pHba->reply_pool); | 2729 | kfree(pHba->reply_pool); |
2730 | 2730 | ||
2731 | pHba->reply_pool = (u32*)kmalloc(pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, GFP_KERNEL|ADDR32); | 2731 | pHba->reply_pool = kmalloc(pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, GFP_KERNEL|ADDR32); |
2732 | if(!pHba->reply_pool){ | 2732 | if(!pHba->reply_pool){ |
2733 | printk(KERN_ERR"%s: Could not allocate reply pool\n",pHba->name); | 2733 | printk(KERN_ERR"%s: Could not allocate reply pool\n",pHba->name); |
2734 | return -1; | 2734 | return -1; |
diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c index f160357e37a6..d561663fb4e4 100644 --- a/drivers/scsi/initio.c +++ b/drivers/scsi/initio.c | |||
@@ -2828,7 +2828,7 @@ static int i91u_detect(struct scsi_host_template * tpnt) | |||
2828 | 2828 | ||
2829 | for (; tul_num_scb >= MAX_TARGETS + 3; tul_num_scb--) { | 2829 | for (; tul_num_scb >= MAX_TARGETS + 3; tul_num_scb--) { |
2830 | i = tul_num_ch * tul_num_scb * sizeof(SCB); | 2830 | i = tul_num_ch * tul_num_scb * sizeof(SCB); |
2831 | if ((tul_scb = (SCB *) kmalloc(i, GFP_ATOMIC | GFP_DMA)) != NULL) | 2831 | if ((tul_scb = kmalloc(i, GFP_ATOMIC | GFP_DMA)) != NULL) |
2832 | break; | 2832 | break; |
2833 | } | 2833 | } |
2834 | if (tul_scb == NULL) { | 2834 | if (tul_scb == NULL) { |
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 824fe080d1dc..7d2311067903 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
@@ -5777,7 +5777,7 @@ static int osst_probe(struct device *dev) | |||
5777 | dev_num = i; | 5777 | dev_num = i; |
5778 | 5778 | ||
5779 | /* allocate a struct osst_tape for this device */ | 5779 | /* allocate a struct osst_tape for this device */ |
5780 | tpnt = (struct osst_tape *)kmalloc(sizeof(struct osst_tape), GFP_ATOMIC); | 5780 | tpnt = kmalloc(sizeof(struct osst_tape), GFP_ATOMIC); |
5781 | if (tpnt == NULL) { | 5781 | if (tpnt == NULL) { |
5782 | write_unlock(&os_scsi_tapes_lock); | 5782 | write_unlock(&os_scsi_tapes_lock); |
5783 | printk(KERN_ERR "osst :E: Can't allocate device descriptor, device not attached.\n"); | 5783 | printk(KERN_ERR "osst :E: Can't allocate device descriptor, device not attached.\n"); |
diff --git a/drivers/scsi/pluto.c b/drivers/scsi/pluto.c index aa60a5f1fbc3..3b2e1a53e6e2 100644 --- a/drivers/scsi/pluto.c +++ b/drivers/scsi/pluto.c | |||
@@ -117,7 +117,7 @@ int __init pluto_detect(struct scsi_host_template *tpnt) | |||
117 | #endif | 117 | #endif |
118 | return 0; | 118 | return 0; |
119 | } | 119 | } |
120 | fcs = (struct ctrl_inquiry *) kmalloc (sizeof (struct ctrl_inquiry) * fcscount, GFP_DMA); | 120 | fcs = kmalloc(sizeof (struct ctrl_inquiry) * fcscount, GFP_DMA); |
121 | if (!fcs) { | 121 | if (!fcs) { |
122 | printk ("PLUTO: Not enough memory to probe\n"); | 122 | printk ("PLUTO: Not enough memory to probe\n"); |
123 | return 0; | 123 | return 0; |
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index d1268cb46837..0578ba42718b 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c | |||
@@ -546,7 +546,7 @@ int sr_is_xa(Scsi_CD *cd) | |||
546 | if (!xa_test) | 546 | if (!xa_test) |
547 | return 0; | 547 | return 0; |
548 | 548 | ||
549 | raw_sector = (unsigned char *) kmalloc(2048, GFP_KERNEL | SR_GFP_DMA(cd)); | 549 | raw_sector = kmalloc(2048, GFP_KERNEL | SR_GFP_DMA(cd)); |
550 | if (!raw_sector) | 550 | if (!raw_sector) |
551 | return -ENOMEM; | 551 | return -ENOMEM; |
552 | if (0 == sr_read_sector(cd, cd->ms_offset + 16, | 552 | if (0 == sr_read_sector(cd, cd->ms_offset + 16, |
diff --git a/drivers/scsi/sr_vendor.c b/drivers/scsi/sr_vendor.c index a3e9d0f2eb5b..4eb3da996b36 100644 --- a/drivers/scsi/sr_vendor.c +++ b/drivers/scsi/sr_vendor.c | |||
@@ -117,7 +117,7 @@ int sr_set_blocklength(Scsi_CD *cd, int blocklength) | |||
117 | density = (blocklength > 2048) ? 0x81 : 0x83; | 117 | density = (blocklength > 2048) ? 0x81 : 0x83; |
118 | #endif | 118 | #endif |
119 | 119 | ||
120 | buffer = (unsigned char *) kmalloc(512, GFP_KERNEL | GFP_DMA); | 120 | buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); |
121 | if (!buffer) | 121 | if (!buffer) |
122 | return -ENOMEM; | 122 | return -ENOMEM; |
123 | 123 | ||
@@ -164,7 +164,7 @@ int sr_cd_check(struct cdrom_device_info *cdi) | |||
164 | if (cd->cdi.mask & CDC_MULTI_SESSION) | 164 | if (cd->cdi.mask & CDC_MULTI_SESSION) |
165 | return 0; | 165 | return 0; |
166 | 166 | ||
167 | buffer = (unsigned char *) kmalloc(512, GFP_KERNEL | GFP_DMA); | 167 | buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); |
168 | if (!buffer) | 168 | if (!buffer) |
169 | return -ENOMEM; | 169 | return -ENOMEM; |
170 | 170 | ||
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c index 43f5b6aa7dc4..98e3fe10c1dc 100644 --- a/drivers/scsi/sun3_NCR5380.c +++ b/drivers/scsi/sun3_NCR5380.c | |||
@@ -266,7 +266,7 @@ static struct scsi_host_template *the_template = NULL; | |||
266 | (struct NCR5380_hostdata *)(in)->hostdata | 266 | (struct NCR5380_hostdata *)(in)->hostdata |
267 | #define HOSTDATA(in) ((struct NCR5380_hostdata *)(in)->hostdata) | 267 | #define HOSTDATA(in) ((struct NCR5380_hostdata *)(in)->hostdata) |
268 | 268 | ||
269 | #define NEXT(cmd) ((struct scsi_cmnd *)((cmd)->host_scribble)) | 269 | #define NEXT(cmd) (*(struct scsi_cmnd **)&((cmd)->host_scribble)) |
270 | #define NEXTADDR(cmd) ((struct scsi_cmnd **)&((cmd)->host_scribble)) | 270 | #define NEXTADDR(cmd) ((struct scsi_cmnd **)&((cmd)->host_scribble)) |
271 | 271 | ||
272 | #define HOSTNO instance->host_no | 272 | #define HOSTNO instance->host_no |
@@ -650,7 +650,7 @@ __inline__ void NCR5380_print_phase(struct Scsi_Host *instance) { }; | |||
650 | #include <linux/interrupt.h> | 650 | #include <linux/interrupt.h> |
651 | 651 | ||
652 | static volatile int main_running = 0; | 652 | static volatile int main_running = 0; |
653 | static DECLARE_WORK(NCR5380_tqueue, (void (*)(void*))NCR5380_main, NULL); | 653 | static DECLARE_WORK(NCR5380_tqueue, NCR5380_main); |
654 | 654 | ||
655 | static __inline__ void queue_main(void) | 655 | static __inline__ void queue_main(void) |
656 | { | 656 | { |
@@ -1031,7 +1031,7 @@ static int NCR5380_queue_command(struct scsi_cmnd *cmd, | |||
1031 | * reenable them. This prevents reentrancy and kernel stack overflow. | 1031 | * reenable them. This prevents reentrancy and kernel stack overflow. |
1032 | */ | 1032 | */ |
1033 | 1033 | ||
1034 | static void NCR5380_main (void *bl) | 1034 | static void NCR5380_main (struct work_struct *bl) |
1035 | { | 1035 | { |
1036 | struct scsi_cmnd *tmp, *prev; | 1036 | struct scsi_cmnd *tmp, *prev; |
1037 | struct Scsi_Host *instance = first_instance; | 1037 | struct Scsi_Host *instance = first_instance; |
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 940fa1e6f994..21cd4c7f5289 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c | |||
@@ -5545,7 +5545,7 @@ int sym_hcb_attach(struct Scsi_Host *shost, struct sym_fw *fw, struct sym_nvram | |||
5545 | /* | 5545 | /* |
5546 | * Allocate the array of lists of CCBs hashed by DSA. | 5546 | * Allocate the array of lists of CCBs hashed by DSA. |
5547 | */ | 5547 | */ |
5548 | np->ccbh = kcalloc(sizeof(struct sym_ccb **), CCB_HASH_SIZE, GFP_KERNEL); | 5548 | np->ccbh = kcalloc(CCB_HASH_SIZE, sizeof(struct sym_ccb **), GFP_KERNEL); |
5549 | if (!np->ccbh) | 5549 | if (!np->ccbh) |
5550 | goto attach_failed; | 5550 | goto attach_failed; |
5551 | 5551 | ||
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c index 4d0ff8f4a01b..52e2e64c6649 100644 --- a/drivers/serial/8250_pci.c +++ b/drivers/serial/8250_pci.c | |||
@@ -2239,6 +2239,30 @@ static struct pci_device_id serial_pci_tbl[] = { | |||
2239 | pbn_b0_bt_1_460800 }, | 2239 | pbn_b0_bt_1_460800 }, |
2240 | 2240 | ||
2241 | /* | 2241 | /* |
2242 | * Korenix Jetcard F0/F1 cards (JC1204, JC1208, JC1404, JC1408). | ||
2243 | * Cards are identified by their subsystem vendor IDs, which | ||
2244 | * (in hex) match the model number. | ||
2245 | * | ||
2246 | * Note that JC140x are RS422/485 cards which require ox950 | ||
2247 | * ACR = 0x10, and as such are not currently fully supported. | ||
2248 | */ | ||
2249 | { PCI_VENDOR_ID_KORENIX, PCI_DEVICE_ID_KORENIX_JETCARDF0, | ||
2250 | 0x1204, 0x0004, 0, 0, | ||
2251 | pbn_b0_4_921600 }, | ||
2252 | { PCI_VENDOR_ID_KORENIX, PCI_DEVICE_ID_KORENIX_JETCARDF0, | ||
2253 | 0x1208, 0x0004, 0, 0, | ||
2254 | pbn_b0_4_921600 }, | ||
2255 | /* { PCI_VENDOR_ID_KORENIX, PCI_DEVICE_ID_KORENIX_JETCARDF0, | ||
2256 | 0x1402, 0x0002, 0, 0, | ||
2257 | pbn_b0_2_921600 }, */ | ||
2258 | /* { PCI_VENDOR_ID_KORENIX, PCI_DEVICE_ID_KORENIX_JETCARDF0, | ||
2259 | 0x1404, 0x0004, 0, 0, | ||
2260 | pbn_b0_4_921600 }, */ | ||
2261 | { PCI_VENDOR_ID_KORENIX, PCI_DEVICE_ID_KORENIX_JETCARDF1, | ||
2262 | 0x1208, 0x0004, 0, 0, | ||
2263 | pbn_b0_4_921600 }, | ||
2264 | |||
2265 | /* | ||
2242 | * Dell Remote Access Card 4 - Tim_T_Murphy@Dell.com | 2266 | * Dell Remote Access Card 4 - Tim_T_Murphy@Dell.com |
2243 | */ | 2267 | */ |
2244 | { PCI_VENDOR_ID_DELL, PCI_DEVICE_ID_DELL_RAC4, | 2268 | { PCI_VENDOR_ID_DELL, PCI_DEVICE_ID_DELL_RAC4, |
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 72f3db99ff94..3e0abbb49fe1 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c | |||
@@ -598,7 +598,7 @@ at91_ep_alloc_request(struct usb_ep *_ep, unsigned int gfp_flags) | |||
598 | { | 598 | { |
599 | struct at91_request *req; | 599 | struct at91_request *req; |
600 | 600 | ||
601 | req = kcalloc(1, sizeof (struct at91_request), gfp_flags); | 601 | req = kzalloc(sizeof (struct at91_request), gfp_flags); |
602 | if (!req) | 602 | if (!req) |
603 | return NULL; | 603 | return NULL; |
604 | 604 | ||
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 5516c59ed5ec..2d12bf9f19d6 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -2195,7 +2195,7 @@ static struct gs_buf *gs_buf_alloc(unsigned int size, gfp_t kmalloc_flags) | |||
2195 | if (size == 0) | 2195 | if (size == 0) |
2196 | return NULL; | 2196 | return NULL; |
2197 | 2197 | ||
2198 | gb = (struct gs_buf *)kmalloc(sizeof(struct gs_buf), kmalloc_flags); | 2198 | gb = kmalloc(sizeof(struct gs_buf), kmalloc_flags); |
2199 | if (gb == NULL) | 2199 | if (gb == NULL) |
2200 | return NULL; | 2200 | return NULL; |
2201 | 2201 | ||
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c index 9325e46a68c0..282d82efc0b0 100644 --- a/drivers/usb/host/hc_crisv10.c +++ b/drivers/usb/host/hc_crisv10.c | |||
@@ -365,7 +365,7 @@ static inline struct urb *urb_list_first(int epid) | |||
365 | /* Adds an urb_entry last in the list for this epid. */ | 365 | /* Adds an urb_entry last in the list for this epid. */ |
366 | static inline void urb_list_add(struct urb *urb, int epid) | 366 | static inline void urb_list_add(struct urb *urb, int epid) |
367 | { | 367 | { |
368 | urb_entry_t *urb_entry = (urb_entry_t *)kmalloc(sizeof(urb_entry_t), KMALLOC_FLAG); | 368 | urb_entry_t *urb_entry = kmalloc(sizeof(urb_entry_t), KMALLOC_FLAG); |
369 | assert(urb_entry); | 369 | assert(urb_entry); |
370 | 370 | ||
371 | urb_entry->urb = urb; | 371 | urb_entry->urb = urb; |
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c index c703f73e1655..6c7f3efb1d40 100644 --- a/drivers/usb/misc/auerswald.c +++ b/drivers/usb/misc/auerswald.c | |||
@@ -766,7 +766,7 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned | |||
766 | bep->bufp = kmalloc (bufsize, GFP_KERNEL); | 766 | bep->bufp = kmalloc (bufsize, GFP_KERNEL); |
767 | if (!bep->bufp) | 767 | if (!bep->bufp) |
768 | goto bl_fail; | 768 | goto bl_fail; |
769 | bep->dr = (struct usb_ctrlrequest *) kmalloc (sizeof (struct usb_ctrlrequest), GFP_KERNEL); | 769 | bep->dr = kmalloc(sizeof (struct usb_ctrlrequest), GFP_KERNEL); |
770 | if (!bep->dr) | 770 | if (!bep->dr) |
771 | goto bl_fail; | 771 | goto bl_fail; |
772 | bep->urbp = usb_alloc_urb (0, GFP_KERNEL); | 772 | bep->urbp = usb_alloc_urb (0, GFP_KERNEL); |
@@ -1969,7 +1969,7 @@ static int auerswald_probe (struct usb_interface *intf, | |||
1969 | info("device is a %s", cp->dev_desc); | 1969 | info("device is a %s", cp->dev_desc); |
1970 | 1970 | ||
1971 | /* get the maximum allowed control transfer length */ | 1971 | /* get the maximum allowed control transfer length */ |
1972 | pbuf = (__le16 *) kmalloc (2, GFP_KERNEL); /* use an allocated buffer because of urb target */ | 1972 | pbuf = kmalloc(2, GFP_KERNEL); /* use an allocated buffer because of urb target */ |
1973 | if (!pbuf) { | 1973 | if (!pbuf) { |
1974 | err( "out of memory"); | 1974 | err( "out of memory"); |
1975 | goto pfail; | 1975 | goto pfail; |
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c index 7e8a0acd52ee..70250252ae2a 100644 --- a/drivers/usb/misc/uss720.c +++ b/drivers/usb/misc/uss720.c | |||
@@ -705,7 +705,7 @@ static int uss720_probe(struct usb_interface *intf, | |||
705 | /* | 705 | /* |
706 | * Allocate parport interface | 706 | * Allocate parport interface |
707 | */ | 707 | */ |
708 | if (!(priv = kcalloc(sizeof(struct parport_uss720_private), 1, GFP_KERNEL))) { | 708 | if (!(priv = kzalloc(sizeof(struct parport_uss720_private), GFP_KERNEL))) { |
709 | usb_put_dev(usbdev); | 709 | usb_put_dev(usbdev); |
710 | return -ENOMEM; | 710 | return -ENOMEM; |
711 | } | 711 | } |
diff --git a/drivers/usb/net/rndis_host.c b/drivers/usb/net/rndis_host.c index 99f26b3e502f..ea5f44de3de2 100644 --- a/drivers/usb/net/rndis_host.c +++ b/drivers/usb/net/rndis_host.c | |||
@@ -469,7 +469,7 @@ static void rndis_unbind(struct usbnet *dev, struct usb_interface *intf) | |||
469 | struct rndis_halt *halt; | 469 | struct rndis_halt *halt; |
470 | 470 | ||
471 | /* try to clear any rndis state/activity (no i/o from stack!) */ | 471 | /* try to clear any rndis state/activity (no i/o from stack!) */ |
472 | halt = kcalloc(1, sizeof *halt, GFP_KERNEL); | 472 | halt = kzalloc(sizeof *halt, GFP_KERNEL); |
473 | if (halt) { | 473 | if (halt) { |
474 | halt->msg_type = RNDIS_MSG_HALT; | 474 | halt->msg_type = RNDIS_MSG_HALT; |
475 | halt->msg_len = ccpu2(sizeof *halt); | 475 | halt->msg_len = ccpu2(sizeof *halt); |
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index a1fdb85b8c0a..45cdf9bc43b2 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c | |||
@@ -1493,7 +1493,7 @@ static struct cypress_buf *cypress_buf_alloc(unsigned int size) | |||
1493 | if (size == 0) | 1493 | if (size == 0) |
1494 | return NULL; | 1494 | return NULL; |
1495 | 1495 | ||
1496 | cb = (struct cypress_buf *)kmalloc(sizeof(struct cypress_buf), GFP_KERNEL); | 1496 | cb = kmalloc(sizeof(struct cypress_buf), GFP_KERNEL); |
1497 | if (cb == NULL) | 1497 | if (cb == NULL) |
1498 | return NULL; | 1498 | return NULL; |
1499 | 1499 | ||
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index 9d9ea874639c..efd9ce3f931f 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -1681,7 +1681,7 @@ dbg( "digi_startup: TOP" ); | |||
1681 | for( i=0; i<serial->type->num_ports+1; i++ ) { | 1681 | for( i=0; i<serial->type->num_ports+1; i++ ) { |
1682 | 1682 | ||
1683 | /* allocate port private structure */ | 1683 | /* allocate port private structure */ |
1684 | priv = (struct digi_port *)kmalloc( sizeof(struct digi_port), | 1684 | priv = kmalloc( sizeof(struct digi_port), |
1685 | GFP_KERNEL ); | 1685 | GFP_KERNEL ); |
1686 | if( priv == (struct digi_port *)0 ) { | 1686 | if( priv == (struct digi_port *)0 ) { |
1687 | while( --i >= 0 ) | 1687 | while( --i >= 0 ) |
@@ -1714,7 +1714,7 @@ dbg( "digi_startup: TOP" ); | |||
1714 | } | 1714 | } |
1715 | 1715 | ||
1716 | /* allocate serial private structure */ | 1716 | /* allocate serial private structure */ |
1717 | serial_priv = (struct digi_serial *)kmalloc( sizeof(struct digi_serial), | 1717 | serial_priv = kmalloc( sizeof(struct digi_serial), |
1718 | GFP_KERNEL ); | 1718 | GFP_KERNEL ); |
1719 | if( serial_priv == (struct digi_serial *)0 ) { | 1719 | if( serial_priv == (struct digi_serial *)0 ) { |
1720 | for( i=0; i<serial->type->num_ports+1; i++ ) | 1720 | for( i=0; i<serial->type->num_ports+1; i++ ) |
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 2da2684e0809..980285c0233a 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -2811,7 +2811,7 @@ static struct edge_buf *edge_buf_alloc(unsigned int size) | |||
2811 | if (size == 0) | 2811 | if (size == 0) |
2812 | return NULL; | 2812 | return NULL; |
2813 | 2813 | ||
2814 | eb = (struct edge_buf *)kmalloc(sizeof(struct edge_buf), GFP_KERNEL); | 2814 | eb = kmalloc(sizeof(struct edge_buf), GFP_KERNEL); |
2815 | if (eb == NULL) | 2815 | if (eb == NULL) |
2816 | return NULL; | 2816 | return NULL; |
2817 | 2817 | ||
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index d72cf8bc7f76..42f757a5b876 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c | |||
@@ -595,7 +595,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) | |||
595 | 595 | ||
596 | bytes_in = 0; | 596 | bytes_in = 0; |
597 | bytes_out = 0; | 597 | bytes_out = 0; |
598 | priv = (struct ipaq_private *)kmalloc(sizeof(struct ipaq_private), GFP_KERNEL); | 598 | priv = kmalloc(sizeof(struct ipaq_private), GFP_KERNEL); |
599 | if (priv == NULL) { | 599 | if (priv == NULL) { |
600 | err("%s - Out of memory", __FUNCTION__); | 600 | err("%s - Out of memory", __FUNCTION__); |
601 | return -ENOMEM; | 601 | return -ENOMEM; |
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index e284d6c0fd35..62bea0c923bd 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -269,7 +269,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) | |||
269 | } | 269 | } |
270 | 270 | ||
271 | // allocate memory for write_urb transfer buffer | 271 | // allocate memory for write_urb transfer buffer |
272 | port->write_urb->transfer_buffer = (unsigned char *) kmalloc(write_urb_transfer_buffer_length, GFP_KERNEL); | 272 | port->write_urb->transfer_buffer = kmalloc(write_urb_transfer_buffer_length, GFP_KERNEL); |
273 | if (! port->write_urb->transfer_buffer) { | 273 | if (! port->write_urb->transfer_buffer) { |
274 | kfree(transfer_buffer); | 274 | kfree(transfer_buffer); |
275 | usb_free_urb(port->write_urb); | 275 | usb_free_urb(port->write_urb); |
@@ -696,7 +696,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file *file, | |||
696 | return 0; | 696 | return 0; |
697 | 697 | ||
698 | case TCFLSH: // 0x540B | 698 | case TCFLSH: // 0x540B |
699 | transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL); | 699 | transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL); |
700 | if (! transfer_buffer) { | 700 | if (! transfer_buffer) { |
701 | return -ENOBUFS; | 701 | return -ENOBUFS; |
702 | } | 702 | } |
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index d124d780e42e..5dc2ac9afa90 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -159,7 +159,7 @@ static struct pl2303_buf *pl2303_buf_alloc(unsigned int size) | |||
159 | if (size == 0) | 159 | if (size == 0) |
160 | return NULL; | 160 | return NULL; |
161 | 161 | ||
162 | pb = (struct pl2303_buf *)kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL); | 162 | pb = kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL); |
163 | if (pb == NULL) | 163 | if (pb == NULL) |
164 | return NULL; | 164 | return NULL; |
165 | 165 | ||
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index f42eb9ea6405..83189005c6fb 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -1710,7 +1710,7 @@ static struct circ_buf *ti_buf_alloc(void) | |||
1710 | { | 1710 | { |
1711 | struct circ_buf *cb; | 1711 | struct circ_buf *cb; |
1712 | 1712 | ||
1713 | cb = (struct circ_buf *)kmalloc(sizeof(struct circ_buf), GFP_KERNEL); | 1713 | cb = kmalloc(sizeof(struct circ_buf), GFP_KERNEL); |
1714 | if (cb == NULL) | 1714 | if (cb == NULL) |
1715 | return NULL; | 1715 | return NULL; |
1716 | 1716 | ||
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index dc45e58e2b8c..5483d8564c1b 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c | |||
@@ -416,7 +416,7 @@ static int whiteheat_attach (struct usb_serial *serial) | |||
416 | for (i = 0; i < serial->num_ports; i++) { | 416 | for (i = 0; i < serial->num_ports; i++) { |
417 | port = serial->port[i]; | 417 | port = serial->port[i]; |
418 | 418 | ||
419 | info = (struct whiteheat_private *)kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); | 419 | info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); |
420 | if (info == NULL) { | 420 | if (info == NULL) { |
421 | err("%s: Out of memory for port structures\n", serial->type->description); | 421 | err("%s: Out of memory for port structures\n", serial->type->description); |
422 | goto no_private; | 422 | goto no_private; |
@@ -487,7 +487,7 @@ static int whiteheat_attach (struct usb_serial *serial) | |||
487 | usb_set_serial_port_data(port, info); | 487 | usb_set_serial_port_data(port, info); |
488 | } | 488 | } |
489 | 489 | ||
490 | command_info = (struct whiteheat_command_private *)kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL); | 490 | command_info = kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL); |
491 | if (command_info == NULL) { | 491 | if (command_info == NULL) { |
492 | err("%s: Out of memory for port structures\n", serial->type->description); | 492 | err("%s: Out of memory for port structures\n", serial->type->description); |
493 | goto no_command_private; | 493 | goto no_command_private; |
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index fb8bacaae27c..e3528eca29a5 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c | |||
@@ -646,7 +646,7 @@ sddr09_read_sg_test_only(struct us_data *us) { | |||
646 | return result; | 646 | return result; |
647 | } | 647 | } |
648 | 648 | ||
649 | buf = (unsigned char *) kmalloc(bulklen, GFP_NOIO); | 649 | buf = kmalloc(bulklen, GFP_NOIO); |
650 | if (!buf) | 650 | if (!buf) |
651 | return -ENOMEM; | 651 | return -ENOMEM; |
652 | 652 | ||
diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c index 6761b68c35e9..6c9dc2e69c82 100644 --- a/drivers/video/amba-clcd.c +++ b/drivers/video/amba-clcd.c | |||
@@ -447,7 +447,7 @@ static int clcdfb_probe(struct amba_device *dev, void *id) | |||
447 | goto out; | 447 | goto out; |
448 | } | 448 | } |
449 | 449 | ||
450 | fb = (struct clcd_fb *) kmalloc(sizeof(struct clcd_fb), GFP_KERNEL); | 450 | fb = kmalloc(sizeof(struct clcd_fb), GFP_KERNEL); |
451 | if (!fb) { | 451 | if (!fb) { |
452 | printk(KERN_INFO "CLCD: could not allocate new clcd_fb struct\n"); | 452 | printk(KERN_INFO "CLCD: could not allocate new clcd_fb struct\n"); |
453 | ret = -ENOMEM; | 453 | ret = -ENOMEM; |
diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c index 88a47845c4f7..1a849b870bcc 100644 --- a/drivers/video/amifb.c +++ b/drivers/video/amifb.c | |||
@@ -2906,14 +2906,6 @@ static int ami_decode_var(struct fb_var_screeninfo *var, | |||
2906 | par->crsr.spot_x = par->crsr.spot_y = 0; | 2906 | par->crsr.spot_x = par->crsr.spot_y = 0; |
2907 | par->crsr.height = par->crsr.width = 0; | 2907 | par->crsr.height = par->crsr.width = 0; |
2908 | 2908 | ||
2909 | #if 0 /* fbmon not done. uncomment for 2.5.x -brad */ | ||
2910 | if (!fbmon_valid_timings(pixclock[clk_shift], htotal, vtotal, | ||
2911 | &fb_info)) { | ||
2912 | DPRINTK("mode doesn't fit for monitor\n"); | ||
2913 | return -EINVAL; | ||
2914 | } | ||
2915 | #endif | ||
2916 | |||
2917 | return 0; | 2909 | return 0; |
2918 | } | 2910 | } |
2919 | 2911 | ||
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c index 176f9b85cdbe..09684d7a7ce9 100644 --- a/drivers/video/aty/atyfb_base.c +++ b/drivers/video/aty/atyfb_base.c | |||
@@ -1488,10 +1488,6 @@ static int atyfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | |||
1488 | else | 1488 | else |
1489 | info->var.accel_flags = 0; | 1489 | info->var.accel_flags = 0; |
1490 | 1490 | ||
1491 | #if 0 /* fbmon is not done. uncomment for 2.5.x -brad */ | ||
1492 | if (!fbmon_valid_timings(pixclock, htotal, vtotal, info)) | ||
1493 | return -EINVAL; | ||
1494 | #endif | ||
1495 | aty_crtc_to_var(&crtc, var); | 1491 | aty_crtc_to_var(&crtc, var); |
1496 | var->pixclock = par->pll_ops->pll_to_var(info, &pll); | 1492 | var->pixclock = par->pll_ops->pll_to_var(info, &pll); |
1497 | return 0; | 1493 | return 0; |
diff --git a/drivers/video/matrox/i2c-matroxfb.c b/drivers/video/matrox/i2c-matroxfb.c index 797b42305b0f..fe28848e7b52 100644 --- a/drivers/video/matrox/i2c-matroxfb.c +++ b/drivers/video/matrox/i2c-matroxfb.c | |||
@@ -146,7 +146,7 @@ static void* i2c_matroxfb_probe(struct matrox_fb_info* minfo) { | |||
146 | unsigned long flags; | 146 | unsigned long flags; |
147 | struct matroxfb_dh_maven_info* m2info; | 147 | struct matroxfb_dh_maven_info* m2info; |
148 | 148 | ||
149 | m2info = (struct matroxfb_dh_maven_info*)kmalloc(sizeof(*m2info), GFP_KERNEL); | 149 | m2info = kmalloc(sizeof(*m2info), GFP_KERNEL); |
150 | if (!m2info) | 150 | if (!m2info) |
151 | return NULL; | 151 | return NULL; |
152 | 152 | ||
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c index e9b4115fcad0..cb2aa402ddfd 100644 --- a/drivers/video/matrox/matroxfb_base.c +++ b/drivers/video/matrox/matroxfb_base.c | |||
@@ -2028,7 +2028,7 @@ static int matroxfb_probe(struct pci_dev* pdev, const struct pci_device_id* dumm | |||
2028 | } | 2028 | } |
2029 | 2029 | ||
2030 | #ifdef CONFIG_FB_MATROX_MULTIHEAD | 2030 | #ifdef CONFIG_FB_MATROX_MULTIHEAD |
2031 | minfo = (struct matrox_fb_info*)kmalloc(sizeof(*minfo), GFP_KERNEL); | 2031 | minfo = kmalloc(sizeof(*minfo), GFP_KERNEL); |
2032 | if (!minfo) | 2032 | if (!minfo) |
2033 | return -1; | 2033 | return -1; |
2034 | #else | 2034 | #else |
diff --git a/drivers/video/matrox/matroxfb_crtc2.c b/drivers/video/matrox/matroxfb_crtc2.c index 27eb4bb4f89f..2c9801090fae 100644 --- a/drivers/video/matrox/matroxfb_crtc2.c +++ b/drivers/video/matrox/matroxfb_crtc2.c | |||
@@ -694,7 +694,7 @@ static void* matroxfb_crtc2_probe(struct matrox_fb_info* minfo) { | |||
694 | /* hardware is CRTC2 incapable... */ | 694 | /* hardware is CRTC2 incapable... */ |
695 | if (!ACCESS_FBINFO(devflags.crtc2)) | 695 | if (!ACCESS_FBINFO(devflags.crtc2)) |
696 | return NULL; | 696 | return NULL; |
697 | m2info = (struct matroxfb_dh_fb_info*)kmalloc(sizeof(*m2info), GFP_KERNEL); | 697 | m2info = kmalloc(sizeof(*m2info), GFP_KERNEL); |
698 | if (!m2info) { | 698 | if (!m2info) { |
699 | printk(KERN_ERR "matroxfb_crtc2: Not enough memory for CRTC2 control structs\n"); | 699 | printk(KERN_ERR "matroxfb_crtc2: Not enough memory for CRTC2 control structs\n"); |
700 | return NULL; | 700 | return NULL; |
diff --git a/drivers/video/sstfb.c b/drivers/video/sstfb.c index 711cb11d6eb3..59cd1e750f30 100644 --- a/drivers/video/sstfb.c +++ b/drivers/video/sstfb.c | |||
@@ -21,6 +21,11 @@ | |||
21 | * Remove never finished and bogus 24/32bit support | 21 | * Remove never finished and bogus 24/32bit support |
22 | * Clean up macro abuse | 22 | * Clean up macro abuse |
23 | * Minor tidying for format. | 23 | * Minor tidying for format. |
24 | * 12/2006 Helge Deller <deller@gmx.de> | ||
25 | * add /sys/class/graphics/fbX/vgapass sysfs-interface | ||
26 | * add module option "mode_option" to set initial screen mode | ||
27 | * use fbdev default videomode database | ||
28 | * remove debug functions from ioctl | ||
24 | */ | 29 | */ |
25 | 30 | ||
26 | /* | 31 | /* |
@@ -65,19 +70,10 @@ | |||
65 | * | 70 | * |
66 | * sstfb specific ioctls: | 71 | * sstfb specific ioctls: |
67 | * toggle vga (0x46db) : toggle vga_pass_through | 72 | * toggle vga (0x46db) : toggle vga_pass_through |
68 | * fill fb (0x46dc) : fills fb | ||
69 | * test disp (0x46de) : draws a test image | ||
70 | */ | 73 | */ |
71 | 74 | ||
72 | #undef SST_DEBUG | 75 | #undef SST_DEBUG |
73 | 76 | ||
74 | /* | ||
75 | Default video mode . | ||
76 | 0 800x600@60 took from glide | ||
77 | 1 640x480@75 took from glide | ||
78 | 2 1024x768@76 std fb.mode | ||
79 | 3 640x480@60 glide default */ | ||
80 | #define DEFAULT_MODE 3 | ||
81 | 77 | ||
82 | /* | 78 | /* |
83 | * Includes | 79 | * Includes |
@@ -92,20 +88,24 @@ | |||
92 | #include <linux/init.h> | 88 | #include <linux/init.h> |
93 | #include <linux/slab.h> | 89 | #include <linux/slab.h> |
94 | #include <asm/io.h> | 90 | #include <asm/io.h> |
95 | #include <asm/ioctl.h> | ||
96 | #include <asm/uaccess.h> | 91 | #include <asm/uaccess.h> |
97 | #include <video/sstfb.h> | 92 | #include <video/sstfb.h> |
98 | 93 | ||
99 | 94 | ||
100 | /* initialized by setup */ | 95 | /* initialized by setup */ |
101 | 96 | ||
102 | static int vgapass; /* enable Vga passthrough cable */ | 97 | static int vgapass; /* enable VGA passthrough cable */ |
103 | static int mem; /* mem size in MB, 0 = autodetect */ | 98 | static int mem; /* mem size in MB, 0 = autodetect */ |
104 | static int clipping = 1; /* use clipping (slower, safer) */ | 99 | static int clipping = 1; /* use clipping (slower, safer) */ |
105 | static int gfxclk; /* force FBI freq in Mhz . Dangerous */ | 100 | static int gfxclk; /* force FBI freq in Mhz . Dangerous */ |
106 | static int slowpci; /* slow PCI settings */ | 101 | static int slowpci; /* slow PCI settings */ |
107 | 102 | ||
108 | static char *mode_option __devinitdata; | 103 | /* |
104 | Possible default video modes: 800x600@60, 640x480@75, 1024x768@76, 640x480@60 | ||
105 | */ | ||
106 | #define DEFAULT_VIDEO_MODE "640x480@60" | ||
107 | |||
108 | static char *mode_option __devinitdata = DEFAULT_VIDEO_MODE; | ||
109 | 109 | ||
110 | enum { | 110 | enum { |
111 | ID_VOODOO1 = 0, | 111 | ID_VOODOO1 = 0, |
@@ -119,48 +119,11 @@ static struct sst_spec voodoo_spec[] __devinitdata = { | |||
119 | { .name = "Voodoo2", .default_gfx_clock = 75000, .max_gfxclk = 85 }, | 119 | { .name = "Voodoo2", .default_gfx_clock = 75000, .max_gfxclk = 85 }, |
120 | }; | 120 | }; |
121 | 121 | ||
122 | static struct fb_var_screeninfo sstfb_default = | ||
123 | #if ( DEFAULT_MODE == 0 ) | ||
124 | { /* 800x600@60, 16 bpp .borowed from glide/sst1/include/sst1init.h */ | ||
125 | 800, 600, 800, 600, 0, 0, 16, 0, | ||
126 | {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0}, | ||
127 | 0, 0, -1, -1, 0, | ||
128 | 25000, 86, 41, 23, 1, 127, 4, | ||
129 | 0, FB_VMODE_NONINTERLACED }; | ||
130 | #elif ( DEFAULT_MODE == 1 ) | ||
131 | {/* 640x480@75, 16 bpp .borowed from glide/sst1/include/sst1init.h */ | ||
132 | 640, 480, 640, 480, 0, 0, 16, 0, | ||
133 | {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0}, | ||
134 | 0, 0, -1, -1, 0, | ||
135 | 31746, 118, 17, 16, 1, 63, 3, | ||
136 | 0, FB_VMODE_NONINTERLACED }; | ||
137 | #elif ( DEFAULT_MODE == 2 ) | ||
138 | { /* 1024x768@76 took from my /etc/fb.modes */ | ||
139 | 1024, 768, 1024, 768,0, 0, 16,0, | ||
140 | {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0}, | ||
141 | 0, 0, -1, -1, 0, | ||
142 | 11764, 208, 8, 36, 16, 120, 3 , | ||
143 | 0, FB_VMODE_NONINTERLACED }; | ||
144 | #elif ( DEFAULT_MODE == 3 ) | ||
145 | { /* 640x480@60 , 16bpp glide default ?*/ | ||
146 | 640, 480, 640, 480, 0, 0, 16, 0, | ||
147 | {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0}, | ||
148 | 0, 0, -1, -1, 0, | ||
149 | 39721 , 38, 26 , 25 ,18 , 96 ,2, | ||
150 | 0, FB_VMODE_NONINTERLACED }; | ||
151 | #elif | ||
152 | #error "Invalid DEFAULT_MODE value !" | ||
153 | #endif | ||
154 | |||
155 | 122 | ||
156 | /* | 123 | /* |
157 | * debug functions | 124 | * debug functions |
158 | */ | 125 | */ |
159 | 126 | ||
160 | static void sstfb_drawdebugimage(struct fb_info *info); | ||
161 | static int sstfb_dump_regs(struct fb_info *info); | ||
162 | |||
163 | |||
164 | #if (SST_DEBUG_REG > 0) | 127 | #if (SST_DEBUG_REG > 0) |
165 | static void sst_dbg_print_read_reg(u32 reg, u32 val) { | 128 | static void sst_dbg_print_read_reg(u32 reg, u32 val) { |
166 | const char *regname; | 129 | const char *regname; |
@@ -726,51 +689,77 @@ static int sstfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | |||
726 | return 0; | 689 | return 0; |
727 | } | 690 | } |
728 | 691 | ||
729 | static int sstfb_ioctl(struct fb_info *info, u_int cmd, u_long arg) | 692 | static void sstfb_setvgapass( struct fb_info *info, int enable ) |
730 | { | 693 | { |
731 | struct sstfb_par *par = info->par; | 694 | struct sstfb_par *par = info->par; |
732 | struct pci_dev *sst_dev = par->dev; | 695 | struct pci_dev *sst_dev = par->dev; |
733 | u32 fbiinit0, tmp, val; | 696 | u32 fbiinit0, tmp; |
734 | u_long p; | 697 | |
698 | enable = enable ? 1:0; | ||
699 | if (par->vgapass == enable) | ||
700 | return; | ||
701 | par->vgapass = enable; | ||
702 | |||
703 | pci_read_config_dword(sst_dev, PCI_INIT_ENABLE, &tmp); | ||
704 | pci_write_config_dword(sst_dev, PCI_INIT_ENABLE, | ||
705 | tmp | PCI_EN_INIT_WR ); | ||
706 | fbiinit0 = sst_read (FBIINIT0); | ||
707 | if (par->vgapass) { | ||
708 | sst_write(FBIINIT0, fbiinit0 & ~DIS_VGA_PASSTHROUGH); | ||
709 | printk(KERN_INFO "fb%d: Enabling VGA pass-through\n", info->node ); | ||
710 | } else { | ||
711 | sst_write(FBIINIT0, fbiinit0 | DIS_VGA_PASSTHROUGH); | ||
712 | printk(KERN_INFO "fb%d: Disabling VGA pass-through\n", info->node ); | ||
713 | } | ||
714 | pci_write_config_dword(sst_dev, PCI_INIT_ENABLE, tmp); | ||
715 | } | ||
716 | |||
717 | static ssize_t store_vgapass(struct device *device, struct device_attribute *attr, | ||
718 | const char *buf, size_t count) | ||
719 | { | ||
720 | struct fb_info *info = dev_get_drvdata(device); | ||
721 | char ** last = NULL; | ||
722 | int val; | ||
723 | |||
724 | val = simple_strtoul(buf, last, 0); | ||
725 | sstfb_setvgapass(info, val); | ||
726 | |||
727 | return count; | ||
728 | } | ||
729 | |||
730 | static ssize_t show_vgapass(struct device *device, struct device_attribute *attr, | ||
731 | char *buf) | ||
732 | { | ||
733 | struct fb_info *info = dev_get_drvdata(device); | ||
734 | struct sstfb_par *par = info->par; | ||
735 | return snprintf(buf, PAGE_SIZE, "%d\n", par->vgapass); | ||
736 | } | ||
737 | |||
738 | static struct device_attribute device_attrs[] = { | ||
739 | __ATTR(vgapass, S_IRUGO|S_IWUSR, show_vgapass, store_vgapass) | ||
740 | }; | ||
741 | |||
742 | static int sstfb_ioctl(struct fb_info *info, unsigned int cmd, | ||
743 | unsigned long arg) | ||
744 | { | ||
745 | struct sstfb_par *par; | ||
746 | u32 val; | ||
735 | 747 | ||
736 | switch (cmd) { | 748 | switch (cmd) { |
737 | 749 | /* set/get VGA pass_through mode */ | |
738 | /* dump current FBIINIT values to system log */ | 750 | case SSTFB_SET_VGAPASS: |
739 | case _IO('F', 0xdb): /* 0x46db */ | ||
740 | return sstfb_dump_regs(info); | ||
741 | |||
742 | /* fills lfb with #arg pixels */ | ||
743 | case _IOW('F', 0xdc, u32): /* 0x46dc */ | ||
744 | if (copy_from_user(&val, (void __user *)arg, sizeof(val))) | 751 | if (copy_from_user(&val, (void __user *)arg, sizeof(val))) |
745 | return -EFAULT; | 752 | return -EFAULT; |
746 | if (val > info->fix.smem_len) | 753 | sstfb_setvgapass(info, val); |
747 | val = info->fix.smem_len; | ||
748 | for (p = 0 ; p < val; p += 2) | ||
749 | writew(p >> 6, info->screen_base + p); | ||
750 | return 0; | 754 | return 0; |
751 | 755 | case SSTFB_GET_VGAPASS: | |
752 | /* change VGA pass_through mode */ | 756 | par = info->par; |
753 | case _IOW('F', 0xdd, u32): /* 0x46dd */ | 757 | val = par->vgapass; |
754 | if (copy_from_user(&val, (void __user *)arg, sizeof(val))) | 758 | if (copy_to_user((void __user *)arg, &val, sizeof(val))) |
755 | return -EFAULT; | 759 | return -EFAULT; |
756 | pci_read_config_dword(sst_dev, PCI_INIT_ENABLE, &tmp); | ||
757 | pci_write_config_dword(sst_dev, PCI_INIT_ENABLE, | ||
758 | tmp | PCI_EN_INIT_WR ); | ||
759 | fbiinit0 = sst_read (FBIINIT0); | ||
760 | if (val) | ||
761 | sst_write(FBIINIT0, fbiinit0 & ~EN_VGA_PASSTHROUGH); | ||
762 | else | ||
763 | sst_write(FBIINIT0, fbiinit0 | EN_VGA_PASSTHROUGH); | ||
764 | pci_write_config_dword(sst_dev, PCI_INIT_ENABLE, tmp); | ||
765 | return 0; | ||
766 | |||
767 | /* draw test image */ | ||
768 | case _IO('F', 0xde): /* 0x46de */ | ||
769 | f_dprintk("test color display at %d bpp\n", | ||
770 | info->var.bits_per_pixel); | ||
771 | sstfb_drawdebugimage(info); | ||
772 | return 0; | 760 | return 0; |
773 | } | 761 | } |
762 | |||
774 | return -EINVAL; | 763 | return -EINVAL; |
775 | } | 764 | } |
776 | 765 | ||
@@ -804,6 +793,7 @@ static void sstfb_copyarea(struct fb_info *info, const struct fb_copyarea *area) | |||
804 | /* | 793 | /* |
805 | * FillRect 2D command (solidfill or invert (via ROP_XOR)) - Voodoo2 only | 794 | * FillRect 2D command (solidfill or invert (via ROP_XOR)) - Voodoo2 only |
806 | */ | 795 | */ |
796 | #if 0 | ||
807 | static void sstfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) | 797 | static void sstfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) |
808 | { | 798 | { |
809 | struct sstfb_par *par = info->par; | 799 | struct sstfb_par *par = info->par; |
@@ -825,6 +815,7 @@ static void sstfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) | |||
825 | | (BLT_16BPP_FMT << 3) /* | BIT(14) */ | BIT(15) | BIT(16) ); | 815 | | (BLT_16BPP_FMT << 3) /* | BIT(14) */ | BIT(15) | BIT(16) ); |
826 | sst_wait_idle(); | 816 | sst_wait_idle(); |
827 | } | 817 | } |
818 | #endif | ||
828 | 819 | ||
829 | 820 | ||
830 | 821 | ||
@@ -1156,6 +1147,7 @@ static int __devinit sst_init(struct fb_info *info, struct sstfb_par *par) | |||
1156 | struct pll_timing gfx_timings; | 1147 | struct pll_timing gfx_timings; |
1157 | struct sst_spec *spec; | 1148 | struct sst_spec *spec; |
1158 | int Fout; | 1149 | int Fout; |
1150 | int gfx_clock; | ||
1159 | 1151 | ||
1160 | spec = &voodoo_spec[par->type]; | 1152 | spec = &voodoo_spec[par->type]; |
1161 | f_ddprintk(" fbiinit0 fbiinit1 fbiinit2 fbiinit3 fbiinit4 " | 1153 | f_ddprintk(" fbiinit0 fbiinit1 fbiinit2 fbiinit3 fbiinit4 " |
@@ -1196,15 +1188,15 @@ static int __devinit sst_init(struct fb_info *info, struct sstfb_par *par) | |||
1196 | } | 1188 | } |
1197 | 1189 | ||
1198 | /* set graphic clock */ | 1190 | /* set graphic clock */ |
1199 | par->gfx_clock = spec->default_gfx_clock; | 1191 | gfx_clock = spec->default_gfx_clock; |
1200 | if ((gfxclk >10 ) && (gfxclk < spec->max_gfxclk)) { | 1192 | if ((gfxclk >10 ) && (gfxclk < spec->max_gfxclk)) { |
1201 | printk(KERN_INFO "sstfb: Using supplied graphic freq : %dMHz\n", gfxclk); | 1193 | printk(KERN_INFO "sstfb: Using supplied graphic freq : %dMHz\n", gfxclk); |
1202 | par->gfx_clock = gfxclk *1000; | 1194 | gfx_clock = gfxclk *1000; |
1203 | } else if (gfxclk) { | 1195 | } else if (gfxclk) { |
1204 | printk(KERN_WARNING "sstfb: %dMhz is way out of spec! Using default\n", gfxclk); | 1196 | printk(KERN_WARNING "sstfb: %dMhz is way out of spec! Using default\n", gfxclk); |
1205 | } | 1197 | } |
1206 | 1198 | ||
1207 | sst_calc_pll(par->gfx_clock, &Fout, &gfx_timings); | 1199 | sst_calc_pll(gfx_clock, &Fout, &gfx_timings); |
1208 | par->dac_sw.set_pll(info, &gfx_timings, GFX_CLOCK); | 1200 | par->dac_sw.set_pll(info, &gfx_timings, GFX_CLOCK); |
1209 | 1201 | ||
1210 | /* disable fbiinit remap */ | 1202 | /* disable fbiinit remap */ |
@@ -1215,10 +1207,11 @@ static int __devinit sst_init(struct fb_info *info, struct sstfb_par *par) | |||
1215 | fbiinit0 = FBIINIT0_DEFAULT; | 1207 | fbiinit0 = FBIINIT0_DEFAULT; |
1216 | fbiinit1 = FBIINIT1_DEFAULT; | 1208 | fbiinit1 = FBIINIT1_DEFAULT; |
1217 | fbiinit4 = FBIINIT4_DEFAULT; | 1209 | fbiinit4 = FBIINIT4_DEFAULT; |
1218 | if (vgapass) | 1210 | par->vgapass = vgapass; |
1219 | fbiinit0 &= ~EN_VGA_PASSTHROUGH; | 1211 | if (par->vgapass) |
1212 | fbiinit0 &= ~DIS_VGA_PASSTHROUGH; | ||
1220 | else | 1213 | else |
1221 | fbiinit0 |= EN_VGA_PASSTHROUGH; | 1214 | fbiinit0 |= DIS_VGA_PASSTHROUGH; |
1222 | if (slowpci) { | 1215 | if (slowpci) { |
1223 | fbiinit1 |= SLOW_PCI_WRITES; | 1216 | fbiinit1 |= SLOW_PCI_WRITES; |
1224 | fbiinit4 |= SLOW_PCI_READS; | 1217 | fbiinit4 |= SLOW_PCI_READS; |
@@ -1267,7 +1260,7 @@ static void __devexit sst_shutdown(struct fb_info *info) | |||
1267 | /* TODO maybe shutdown the dac, vrefresh and so on... */ | 1260 | /* TODO maybe shutdown the dac, vrefresh and so on... */ |
1268 | pci_write_config_dword(dev, PCI_INIT_ENABLE, | 1261 | pci_write_config_dword(dev, PCI_INIT_ENABLE, |
1269 | PCI_EN_INIT_WR); | 1262 | PCI_EN_INIT_WR); |
1270 | sst_unset_bits(FBIINIT0, FBI_RESET | FIFO_RESET | EN_VGA_PASSTHROUGH); | 1263 | sst_unset_bits(FBIINIT0, FBI_RESET | FIFO_RESET | DIS_VGA_PASSTHROUGH); |
1271 | pci_write_config_dword(dev, PCI_VCLK_DISABLE,0); | 1264 | pci_write_config_dword(dev, PCI_VCLK_DISABLE,0); |
1272 | /* maybe keep fbiinit* and PCI_INIT_enable in the fb_info struct | 1265 | /* maybe keep fbiinit* and PCI_INIT_enable in the fb_info struct |
1273 | * from start ? */ | 1266 | * from start ? */ |
@@ -1278,8 +1271,7 @@ static void __devexit sst_shutdown(struct fb_info *info) | |||
1278 | /* | 1271 | /* |
1279 | * Interface to the world | 1272 | * Interface to the world |
1280 | */ | 1273 | */ |
1281 | #ifndef MODULE | 1274 | static int __devinit sstfb_setup(char *options) |
1282 | static int __init sstfb_setup(char *options) | ||
1283 | { | 1275 | { |
1284 | char *this_opt; | 1276 | char *this_opt; |
1285 | 1277 | ||
@@ -1312,7 +1304,7 @@ static int __init sstfb_setup(char *options) | |||
1312 | } | 1304 | } |
1313 | return 0; | 1305 | return 0; |
1314 | } | 1306 | } |
1315 | #endif | 1307 | |
1316 | 1308 | ||
1317 | static struct fb_ops sstfb_ops = { | 1309 | static struct fb_ops sstfb_ops = { |
1318 | .owner = THIS_MODULE, | 1310 | .owner = THIS_MODULE, |
@@ -1416,15 +1408,10 @@ static int __devinit sstfb_probe(struct pci_dev *pdev, | |||
1416 | */ | 1408 | */ |
1417 | fix->line_length = 2048; /* default value, for 24 or 32bit: 4096 */ | 1409 | fix->line_length = 2048; /* default value, for 24 or 32bit: 4096 */ |
1418 | 1410 | ||
1419 | if ( mode_option && | 1411 | fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 16); |
1420 | fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 16)) { | ||
1421 | printk(KERN_ERR "sstfb: can't set supplied video mode. Using default\n"); | ||
1422 | info->var = sstfb_default; | ||
1423 | } else | ||
1424 | info->var = sstfb_default; | ||
1425 | 1412 | ||
1426 | if (sstfb_check_var(&info->var, info)) { | 1413 | if (sstfb_check_var(&info->var, info)) { |
1427 | printk(KERN_ERR "sstfb: invalid default video mode.\n"); | 1414 | printk(KERN_ERR "sstfb: invalid video mode.\n"); |
1428 | goto fail; | 1415 | goto fail; |
1429 | } | 1416 | } |
1430 | 1417 | ||
@@ -1442,10 +1429,11 @@ static int __devinit sstfb_probe(struct pci_dev *pdev, | |||
1442 | goto fail; | 1429 | goto fail; |
1443 | } | 1430 | } |
1444 | 1431 | ||
1445 | if (1) /* set to 0 to see an initial bitmap instead */ | 1432 | sstfb_clear_screen(info); |
1446 | sstfb_clear_screen(info); | 1433 | |
1447 | else | 1434 | if (device_create_file(info->dev, &device_attrs[0])) |
1448 | sstfb_drawdebugimage(info); | 1435 | printk(KERN_WARNING "sstfb: can't create sysfs entry.\n"); |
1436 | |||
1449 | 1437 | ||
1450 | printk(KERN_INFO "fb%d: %s frame buffer device at 0x%p\n", | 1438 | printk(KERN_INFO "fb%d: %s frame buffer device at 0x%p\n", |
1451 | info->node, fix->id, info->screen_base); | 1439 | info->node, fix->id, info->screen_base); |
@@ -1453,6 +1441,7 @@ static int __devinit sstfb_probe(struct pci_dev *pdev, | |||
1453 | return 0; | 1441 | return 0; |
1454 | 1442 | ||
1455 | fail: | 1443 | fail: |
1444 | fb_dealloc_cmap(&info->cmap); | ||
1456 | iounmap(info->screen_base); | 1445 | iounmap(info->screen_base); |
1457 | fail_fb_remap: | 1446 | fail_fb_remap: |
1458 | iounmap(par->mmio_vbase); | 1447 | iounmap(par->mmio_vbase); |
@@ -1473,21 +1462,23 @@ static void __devexit sstfb_remove(struct pci_dev *pdev) | |||
1473 | info = pci_get_drvdata(pdev); | 1462 | info = pci_get_drvdata(pdev); |
1474 | par = info->par; | 1463 | par = info->par; |
1475 | 1464 | ||
1465 | device_remove_file(info->dev, &device_attrs[0]); | ||
1476 | sst_shutdown(info); | 1466 | sst_shutdown(info); |
1477 | unregister_framebuffer(info); | ||
1478 | iounmap(info->screen_base); | 1467 | iounmap(info->screen_base); |
1479 | iounmap(par->mmio_vbase); | 1468 | iounmap(par->mmio_vbase); |
1480 | release_mem_region(info->fix.smem_start, 0x400000); | 1469 | release_mem_region(info->fix.smem_start, 0x400000); |
1481 | release_mem_region(info->fix.mmio_start, info->fix.mmio_len); | 1470 | release_mem_region(info->fix.mmio_start, info->fix.mmio_len); |
1471 | fb_dealloc_cmap(&info->cmap); | ||
1472 | unregister_framebuffer(info); | ||
1482 | framebuffer_release(info); | 1473 | framebuffer_release(info); |
1483 | } | 1474 | } |
1484 | 1475 | ||
1485 | 1476 | ||
1486 | static struct pci_device_id sstfb_id_tbl[] = { | 1477 | static const struct pci_device_id sstfb_id_tbl[] = { |
1487 | { PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO, | 1478 | { PCI_DEVICE(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO ), |
1488 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_VOODOO1 }, | 1479 | .driver_data = ID_VOODOO1, }, |
1489 | { PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO2, | 1480 | { PCI_DEVICE(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO2), |
1490 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_VOODOO2 }, | 1481 | .driver_data = ID_VOODOO2, }, |
1491 | { 0 }, | 1482 | { 0 }, |
1492 | }; | 1483 | }; |
1493 | 1484 | ||
@@ -1501,142 +1492,23 @@ static struct pci_driver sstfb_driver = { | |||
1501 | 1492 | ||
1502 | static int __devinit sstfb_init(void) | 1493 | static int __devinit sstfb_init(void) |
1503 | { | 1494 | { |
1504 | #ifndef MODULE | ||
1505 | char *option = NULL; | 1495 | char *option = NULL; |
1506 | 1496 | ||
1507 | if (fb_get_options("sstfb", &option)) | 1497 | if (fb_get_options("sstfb", &option)) |
1508 | return -ENODEV; | 1498 | return -ENODEV; |
1509 | sstfb_setup(option); | 1499 | sstfb_setup(option); |
1510 | #endif | 1500 | |
1511 | return pci_register_driver(&sstfb_driver); | 1501 | return pci_register_driver(&sstfb_driver); |
1512 | } | 1502 | } |
1513 | 1503 | ||
1514 | #ifdef MODULE | ||
1515 | static void __devexit sstfb_exit(void) | 1504 | static void __devexit sstfb_exit(void) |
1516 | { | 1505 | { |
1517 | pci_unregister_driver(&sstfb_driver); | 1506 | pci_unregister_driver(&sstfb_driver); |
1518 | } | 1507 | } |
1519 | #endif | ||
1520 | 1508 | ||
1521 | 1509 | ||
1522 | /* | ||
1523 | * testing and debugging functions | ||
1524 | */ | ||
1525 | |||
1526 | static int sstfb_dump_regs(struct fb_info *info) | ||
1527 | { | ||
1528 | #ifdef SST_DEBUG | ||
1529 | static struct { u32 reg ; const char *reg_name;} pci_regs[] = { | ||
1530 | { PCI_INIT_ENABLE, "initenable"}, | ||
1531 | { PCI_VCLK_ENABLE, "enable vclk"}, | ||
1532 | { PCI_VCLK_DISABLE, "disable vclk"}, | ||
1533 | }; | ||
1534 | |||
1535 | static struct { u32 reg ; const char *reg_name;} sst_regs[] = { | ||
1536 | {FBIINIT0,"fbiinit0"}, | ||
1537 | {FBIINIT1,"fbiinit1"}, | ||
1538 | {FBIINIT2,"fbiinit2"}, | ||
1539 | {FBIINIT3,"fbiinit3"}, | ||
1540 | {FBIINIT4,"fbiinit4"}, | ||
1541 | {FBIINIT5,"fbiinit5"}, | ||
1542 | {FBIINIT6,"fbiinit6"}, | ||
1543 | {FBIINIT7,"fbiinit7"}, | ||
1544 | {LFBMODE,"lfbmode"}, | ||
1545 | {FBZMODE,"fbzmode"}, | ||
1546 | }; | ||
1547 | |||
1548 | const int pci_s = ARRAY_SIZE(pci_regs); | ||
1549 | const int sst_s = ARRAY_SIZE(sst_regs); | ||
1550 | struct sstfb_par *par = info->par; | ||
1551 | struct pci_dev *dev = par->dev; | ||
1552 | u32 pci_res[pci_s]; | ||
1553 | u32 sst_res[sst_s]; | ||
1554 | int i; | ||
1555 | |||
1556 | for (i=0; i<pci_s; i++) { | ||
1557 | pci_read_config_dword(dev, pci_regs[i].reg, &pci_res[i]); | ||
1558 | } | ||
1559 | for (i=0; i<sst_s; i++) { | ||
1560 | sst_res[i] = sst_read(sst_regs[i].reg); | ||
1561 | } | ||
1562 | |||
1563 | dprintk("hardware register dump:\n"); | ||
1564 | for (i=0; i<pci_s; i++) { | ||
1565 | dprintk("%s %0#10x\n", pci_regs[i].reg_name, pci_res[i]); | ||
1566 | } | ||
1567 | for (i=0; i<sst_s; i++) { | ||
1568 | dprintk("%s %0#10x\n", sst_regs[i].reg_name, sst_res[i]); | ||
1569 | } | ||
1570 | return 0; | ||
1571 | #else | ||
1572 | return -EINVAL; | ||
1573 | #endif | ||
1574 | } | ||
1575 | |||
1576 | static void sstfb_fillrect_softw( struct fb_info *info, const struct fb_fillrect *rect) | ||
1577 | { | ||
1578 | u8 __iomem *fbbase_virt = info->screen_base; | ||
1579 | int x, y, w = info->var.bits_per_pixel == 16 ? 2 : 4; | ||
1580 | u32 color = rect->color, height = rect->height; | ||
1581 | u8 __iomem *p; | ||
1582 | |||
1583 | if (w==2) color |= color<<16; | ||
1584 | for (y=rect->dy; height; y++, height--) { | ||
1585 | p = fbbase_virt + y*info->fix.line_length + rect->dx*w; | ||
1586 | x = rect->width; | ||
1587 | if (w==2) x>>=1; | ||
1588 | while (x) { | ||
1589 | writel(color, p); | ||
1590 | p += 4; | ||
1591 | x--; | ||
1592 | } | ||
1593 | } | ||
1594 | } | ||
1595 | |||
1596 | static void sstfb_drawrect_XY( struct fb_info *info, int x, int y, | ||
1597 | int w, int h, int color, int hwfunc) | ||
1598 | { | ||
1599 | struct fb_fillrect rect; | ||
1600 | rect.dx = x; | ||
1601 | rect.dy = y; | ||
1602 | rect.height = h; | ||
1603 | rect.width = w; | ||
1604 | rect.color = color; | ||
1605 | rect.rop = ROP_COPY; | ||
1606 | if (hwfunc) | ||
1607 | sstfb_fillrect(info, &rect); | ||
1608 | else | ||
1609 | sstfb_fillrect_softw(info, &rect); | ||
1610 | } | ||
1611 | |||
1612 | /* print some squares on the fb */ | ||
1613 | static void sstfb_drawdebugimage(struct fb_info *info) | ||
1614 | { | ||
1615 | static int idx; | ||
1616 | |||
1617 | /* clear screen */ | ||
1618 | sstfb_clear_screen(info); | ||
1619 | |||
1620 | idx = (idx+1) & 1; | ||
1621 | |||
1622 | /* white rect */ | ||
1623 | sstfb_drawrect_XY(info, 0, 0, 50, 50, 0xffff, idx); | ||
1624 | |||
1625 | /* blue rect */ | ||
1626 | sstfb_drawrect_XY(info, 50, 50, 50, 50, 0x001f, idx); | ||
1627 | |||
1628 | /* green rect */ | ||
1629 | sstfb_drawrect_XY(info, 100, 100, 80, 80, 0x07e0, idx); | ||
1630 | |||
1631 | /* red rect */ | ||
1632 | sstfb_drawrect_XY(info, 250, 250, 120, 100, 0xf800, idx); | ||
1633 | } | ||
1634 | |||
1635 | module_init(sstfb_init); | 1510 | module_init(sstfb_init); |
1636 | |||
1637 | #ifdef MODULE | ||
1638 | module_exit(sstfb_exit); | 1511 | module_exit(sstfb_exit); |
1639 | #endif | ||
1640 | 1512 | ||
1641 | MODULE_AUTHOR("(c) 2000,2002 Ghozlane Toumi <gtoumi@laposte.net>"); | 1513 | MODULE_AUTHOR("(c) 2000,2002 Ghozlane Toumi <gtoumi@laposte.net>"); |
1642 | MODULE_DESCRIPTION("FBDev driver for 3dfx Voodoo Graphics and Voodoo2 based video boards"); | 1514 | MODULE_DESCRIPTION("FBDev driver for 3dfx Voodoo Graphics and Voodoo2 based video boards"); |
@@ -1652,3 +1524,6 @@ module_param(gfxclk, int, 0); | |||
1652 | MODULE_PARM_DESC(gfxclk, "Force graphic chip frequency in MHz. DANGEROUS. (default=auto)"); | 1524 | MODULE_PARM_DESC(gfxclk, "Force graphic chip frequency in MHz. DANGEROUS. (default=auto)"); |
1653 | module_param(slowpci, bool, 0); | 1525 | module_param(slowpci, bool, 0); |
1654 | MODULE_PARM_DESC(slowpci, "Uses slow PCI settings (0 or 1) (default=0)"); | 1526 | MODULE_PARM_DESC(slowpci, "Uses slow PCI settings (0 or 1) (default=0)"); |
1527 | module_param(mode_option, charp, 0); | ||
1528 | MODULE_PARM_DESC(mode_option, "Initial video mode (default=" DEFAULT_VIDEO_MODE ")"); | ||
1529 | |||
diff --git a/drivers/w1/slaves/Kconfig b/drivers/w1/slaves/Kconfig index d18d6424cd21..904e5aeb696c 100644 --- a/drivers/w1/slaves/Kconfig +++ b/drivers/w1/slaves/Kconfig | |||
@@ -9,7 +9,7 @@ config W1_SLAVE_THERM | |||
9 | tristate "Thermal family implementation" | 9 | tristate "Thermal family implementation" |
10 | depends on W1 | 10 | depends on W1 |
11 | help | 11 | help |
12 | Say Y here if you want to connect 1-wire thermal sensors to you | 12 | Say Y here if you want to connect 1-wire thermal sensors to your |
13 | wire. | 13 | wire. |
14 | 14 | ||
15 | config W1_SLAVE_SMEM | 15 | config W1_SLAVE_SMEM |
@@ -17,7 +17,7 @@ config W1_SLAVE_SMEM | |||
17 | depends on W1 | 17 | depends on W1 |
18 | help | 18 | help |
19 | Say Y here if you want to connect 1-wire | 19 | Say Y here if you want to connect 1-wire |
20 | simple 64bit memory rom(ds2401/ds2411/ds1990*) to you wire. | 20 | simple 64bit memory rom(ds2401/ds2411/ds1990*) to your wire. |
21 | 21 | ||
22 | config W1_SLAVE_DS2433 | 22 | config W1_SLAVE_DS2433 |
23 | tristate "4kb EEPROM family support (DS2433)" | 23 | tristate "4kb EEPROM family support (DS2433)" |