aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2006-02-09 04:29:00 -0500
committerJeff Garzik <jgarzik@pobox.com>2006-02-09 04:29:00 -0500
commit9caafa6c8686e319cf4d5f3757b3972c6c522b7c (patch)
treeb38979b835b5d22e681b175d0b98a3c7560d9c59 /drivers/char
parent51e9f2ff83df6b1c81c5c44f4486c68ed87aa20e (diff)
parentcac0e8e8bb2e7a086643bdd00c41d900a79bb4fa (diff)
Merge branch 'upstream-fixes'
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/Kconfig4
-rw-r--r--drivers/char/agp/amd64-agp.c24
-rw-r--r--drivers/char/agp/ati-agp.c20
-rw-r--r--drivers/char/agp/frontend.c28
-rw-r--r--drivers/char/agp/intel-agp.c15
-rw-r--r--drivers/char/agp/isoch.c4
-rw-r--r--drivers/char/cyclades.c6
-rw-r--r--drivers/char/drm/ati_pcigart.c17
-rw-r--r--drivers/char/drm/drmP.h15
-rw-r--r--drivers/char/drm/drm_auth.c20
-rw-r--r--drivers/char/drm/drm_bufs.c80
-rw-r--r--drivers/char/drm/drm_context.c52
-rw-r--r--drivers/char/drm/drm_drv.c4
-rw-r--r--drivers/char/drm/drm_fops.c12
-rw-r--r--drivers/char/drm/drm_ioctl.c18
-rw-r--r--drivers/char/drm/drm_irq.c16
-rw-r--r--drivers/char/drm/drm_pciids.h2
-rw-r--r--drivers/char/drm/drm_proc.c28
-rw-r--r--drivers/char/drm/drm_stub.c6
-rw-r--r--drivers/char/drm/drm_sysfs.c131
-rw-r--r--drivers/char/drm/drm_vm.c12
-rw-r--r--drivers/char/drm/i810_dma.c2
-rw-r--r--drivers/char/drm/i810_drv.h2
-rw-r--r--drivers/char/drm/i830_dma.c2
-rw-r--r--drivers/char/drm/i830_drv.h3
-rw-r--r--drivers/char/drm/i915_dma.c42
-rw-r--r--drivers/char/drm/i915_drm.h33
-rw-r--r--drivers/char/drm/i915_drv.h6
-rw-r--r--drivers/char/drm/i915_mem.c31
-rw-r--r--drivers/char/drm/radeon_cp.c2
-rw-r--r--drivers/char/drm/savage_bci.c4
-rw-r--r--drivers/char/drm/savage_drv.h1
-rw-r--r--drivers/char/drm/via_dma.c10
-rw-r--r--drivers/char/drm/via_dmablit.c6
-rw-r--r--drivers/char/drm/via_drv.h7
-rw-r--r--drivers/char/drm/via_irq.c2
-rw-r--r--drivers/char/esp.c4
-rw-r--r--drivers/char/hangcheck-timer.c12
-rw-r--r--drivers/char/hpet.c26
-rw-r--r--drivers/char/ip2/i2cmd.c1
-rw-r--r--drivers/char/ip2main.c67
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c4
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c32
-rw-r--r--drivers/char/rio/cirrus.h142
-rw-r--r--drivers/char/rio/defaults.h7
-rw-r--r--drivers/char/rio/link.h34
-rw-r--r--drivers/char/rio/list.h140
-rw-r--r--drivers/char/rio/parmmap.h5
-rw-r--r--drivers/char/rio/phb.h133
-rw-r--r--drivers/char/rio/pkt.h27
-rw-r--r--drivers/char/rio/qbuf.h4
-rw-r--r--drivers/char/rio/riotypes.h66
-rw-r--r--drivers/char/rio/rup.h5
-rw-r--r--drivers/char/rio/sam.h4
-rw-r--r--drivers/char/rocket.c2
-rw-r--r--drivers/char/ser_a2232.c1
-rw-r--r--drivers/char/sx.c6
-rw-r--r--drivers/char/tpm/tpm_bios.c25
-rw-r--r--drivers/char/tpm/tpm_infineon.c2
-rw-r--r--drivers/char/tty_io.c77
-rw-r--r--drivers/char/vt.c1
-rw-r--r--drivers/char/watchdog/sbc_epx_c3.c28
62 files changed, 491 insertions, 1031 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 4135d8c5bcae..05ba410682a3 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -222,7 +222,7 @@ config SYNCLINKMP
222 222
223config SYNCLINK_GT 223config SYNCLINK_GT
224 tristate "SyncLink GT/AC support" 224 tristate "SyncLink GT/AC support"
225 depends on SERIAL_NONSTANDARD 225 depends on SERIAL_NONSTANDARD && PCI
226 help 226 help
227 Support for SyncLink GT and SyncLink AC families of 227 Support for SyncLink GT and SyncLink AC families of
228 synchronous and asynchronous serial adapters 228 synchronous and asynchronous serial adapters
@@ -992,7 +992,7 @@ config HPET_MMAP
992 992
993config HANGCHECK_TIMER 993config HANGCHECK_TIMER
994 tristate "Hangcheck timer" 994 tristate "Hangcheck timer"
995 depends on X86 || IA64 || PPC64 || S390 995 depends on X86 || IA64 || PPC64
996 help 996 help
997 The hangcheck-timer module detects when the system has gone 997 The hangcheck-timer module detects when the system has gone
998 out to lunch past a certain margin. It can reboot the system 998 out to lunch past a certain margin. It can reboot the system
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 810679dcbbb0..9964c508c111 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -600,6 +600,26 @@ static void __devexit agp_amd64_remove(struct pci_dev *pdev)
600 agp_put_bridge(bridge); 600 agp_put_bridge(bridge);
601} 601}
602 602
603#ifdef CONFIG_PM
604
605static int agp_amd64_suspend(struct pci_dev *pdev, pm_message_t state)
606{
607 pci_save_state(pdev);
608 pci_set_power_state(pdev, pci_choose_state(pdev, state));
609
610 return 0;
611}
612
613static int agp_amd64_resume(struct pci_dev *pdev)
614{
615 pci_set_power_state(pdev, PCI_D0);
616 pci_restore_state(pdev);
617
618 return amd_8151_configure();
619}
620
621#endif /* CONFIG_PM */
622
603static struct pci_device_id agp_amd64_pci_table[] = { 623static struct pci_device_id agp_amd64_pci_table[] = {
604 { 624 {
605 .class = (PCI_CLASS_BRIDGE_HOST << 8), 625 .class = (PCI_CLASS_BRIDGE_HOST << 8),
@@ -718,6 +738,10 @@ static struct pci_driver agp_amd64_pci_driver = {
718 .id_table = agp_amd64_pci_table, 738 .id_table = agp_amd64_pci_table,
719 .probe = agp_amd64_probe, 739 .probe = agp_amd64_probe,
720 .remove = agp_amd64_remove, 740 .remove = agp_amd64_remove,
741#ifdef CONFIG_PM
742 .suspend = agp_amd64_suspend,
743 .resume = agp_amd64_resume,
744#endif
721}; 745};
722 746
723 747
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index 53372a83b675..5b74c36c116c 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -244,6 +244,22 @@ static int ati_configure(void)
244} 244}
245 245
246 246
247#ifdef CONFIG_PM
248static int agp_ati_resume(struct pci_dev *dev)
249{
250 pci_restore_state(dev);
251
252 return ati_configure();
253}
254
255static int agp_ati_suspend(struct pci_dev *dev, pm_message_t state)
256{
257 pci_save_state(dev);
258
259 return 0;
260}
261#endif
262
247/* 263/*
248 *Since we don't need contigious memory we just try 264 *Since we don't need contigious memory we just try
249 * to get the gatt table once 265 * to get the gatt table once
@@ -525,6 +541,10 @@ static struct pci_driver agp_ati_pci_driver = {
525 .id_table = agp_ati_pci_table, 541 .id_table = agp_ati_pci_table,
526 .probe = agp_ati_probe, 542 .probe = agp_ati_probe,
527 .remove = agp_ati_remove, 543 .remove = agp_ati_remove,
544#ifdef CONFIG_PM
545 .resume = agp_ati_resume,
546 .suspend = agp_ati_suspend,
547#endif
528}; 548};
529 549
530static int __init agp_ati_init(void) 550static int __init agp_ati_init(void)
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
index 17f520c9d471..97eeb2345b18 100644
--- a/drivers/char/agp/frontend.c
+++ b/drivers/char/agp/frontend.c
@@ -592,7 +592,7 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma)
592 struct agp_file_private *priv = file->private_data; 592 struct agp_file_private *priv = file->private_data;
593 struct agp_kern_info kerninfo; 593 struct agp_kern_info kerninfo;
594 594
595 down(&(agp_fe.agp_mutex)); 595 mutex_lock(&(agp_fe.agp_mutex));
596 596
597 if (agp_fe.backend_acquired != TRUE) 597 if (agp_fe.backend_acquired != TRUE)
598 goto out_eperm; 598 goto out_eperm;
@@ -627,7 +627,7 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma)
627 size, vma->vm_page_prot)) { 627 size, vma->vm_page_prot)) {
628 goto out_again; 628 goto out_again;
629 } 629 }
630 up(&(agp_fe.agp_mutex)); 630 mutex_unlock(&(agp_fe.agp_mutex));
631 return 0; 631 return 0;
632 } 632 }
633 633
@@ -643,20 +643,20 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma)
643 size, vma->vm_page_prot)) { 643 size, vma->vm_page_prot)) {
644 goto out_again; 644 goto out_again;
645 } 645 }
646 up(&(agp_fe.agp_mutex)); 646 mutex_unlock(&(agp_fe.agp_mutex));
647 return 0; 647 return 0;
648 } 648 }
649 649
650out_eperm: 650out_eperm:
651 up(&(agp_fe.agp_mutex)); 651 mutex_unlock(&(agp_fe.agp_mutex));
652 return -EPERM; 652 return -EPERM;
653 653
654out_inval: 654out_inval:
655 up(&(agp_fe.agp_mutex)); 655 mutex_unlock(&(agp_fe.agp_mutex));
656 return -EINVAL; 656 return -EINVAL;
657 657
658out_again: 658out_again:
659 up(&(agp_fe.agp_mutex)); 659 mutex_unlock(&(agp_fe.agp_mutex));
660 return -EAGAIN; 660 return -EAGAIN;
661} 661}
662 662
@@ -664,7 +664,7 @@ static int agp_release(struct inode *inode, struct file *file)
664{ 664{
665 struct agp_file_private *priv = file->private_data; 665 struct agp_file_private *priv = file->private_data;
666 666
667 down(&(agp_fe.agp_mutex)); 667 mutex_lock(&(agp_fe.agp_mutex));
668 668
669 DBG("priv=%p", priv); 669 DBG("priv=%p", priv);
670 670
@@ -687,7 +687,7 @@ static int agp_release(struct inode *inode, struct file *file)
687 agp_remove_file_private(priv); 687 agp_remove_file_private(priv);
688 kfree(priv); 688 kfree(priv);
689 file->private_data = NULL; 689 file->private_data = NULL;
690 up(&(agp_fe.agp_mutex)); 690 mutex_unlock(&(agp_fe.agp_mutex));
691 return 0; 691 return 0;
692} 692}
693 693
@@ -698,7 +698,7 @@ static int agp_open(struct inode *inode, struct file *file)
698 struct agp_client *client; 698 struct agp_client *client;
699 int rc = -ENXIO; 699 int rc = -ENXIO;
700 700
701 down(&(agp_fe.agp_mutex)); 701 mutex_lock(&(agp_fe.agp_mutex));
702 702
703 if (minor != AGPGART_MINOR) 703 if (minor != AGPGART_MINOR)
704 goto err_out; 704 goto err_out;
@@ -723,13 +723,13 @@ static int agp_open(struct inode *inode, struct file *file)
723 file->private_data = (void *) priv; 723 file->private_data = (void *) priv;
724 agp_insert_file_private(priv); 724 agp_insert_file_private(priv);
725 DBG("private=%p, client=%p", priv, client); 725 DBG("private=%p, client=%p", priv, client);
726 up(&(agp_fe.agp_mutex)); 726 mutex_unlock(&(agp_fe.agp_mutex));
727 return 0; 727 return 0;
728 728
729err_out_nomem: 729err_out_nomem:
730 rc = -ENOMEM; 730 rc = -ENOMEM;
731err_out: 731err_out:
732 up(&(agp_fe.agp_mutex)); 732 mutex_unlock(&(agp_fe.agp_mutex));
733 return rc; 733 return rc;
734} 734}
735 735
@@ -985,7 +985,7 @@ static int agp_ioctl(struct inode *inode, struct file *file,
985 int ret_val = -ENOTTY; 985 int ret_val = -ENOTTY;
986 986
987 DBG("priv=%p, cmd=%x", curr_priv, cmd); 987 DBG("priv=%p, cmd=%x", curr_priv, cmd);
988 down(&(agp_fe.agp_mutex)); 988 mutex_lock(&(agp_fe.agp_mutex));
989 989
990 if ((agp_fe.current_controller == NULL) && 990 if ((agp_fe.current_controller == NULL) &&
991 (cmd != AGPIOC_ACQUIRE)) { 991 (cmd != AGPIOC_ACQUIRE)) {
@@ -1055,7 +1055,7 @@ static int agp_ioctl(struct inode *inode, struct file *file,
1055 1055
1056ioctl_out: 1056ioctl_out:
1057 DBG("ioctl returns %d\n", ret_val); 1057 DBG("ioctl returns %d\n", ret_val);
1058 up(&(agp_fe.agp_mutex)); 1058 mutex_unlock(&(agp_fe.agp_mutex));
1059 return ret_val; 1059 return ret_val;
1060} 1060}
1061 1061
@@ -1081,7 +1081,7 @@ static struct miscdevice agp_miscdev =
1081int agp_frontend_initialize(void) 1081int agp_frontend_initialize(void)
1082{ 1082{
1083 memset(&agp_fe, 0, sizeof(struct agp_front_data)); 1083 memset(&agp_fe, 0, sizeof(struct agp_front_data));
1084 sema_init(&(agp_fe.agp_mutex), 1); 1084 mutex_init(&(agp_fe.agp_mutex));
1085 1085
1086 if (misc_register(&agp_miscdev)) { 1086 if (misc_register(&agp_miscdev)) {
1087 printk(KERN_ERR PFX "unable to get minor: %d\n", AGPGART_MINOR); 1087 printk(KERN_ERR PFX "unable to get minor: %d\n", AGPGART_MINOR);
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index e7bed5047dcc..631531fd97a5 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -422,7 +422,8 @@ static void intel_i830_init_gtt_entries(void)
422 /* Check it's really I915G */ 422 /* Check it's really I915G */
423 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || 423 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
424 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 424 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
425 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB) 425 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
426 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB)
426 gtt_entries = MB(48) - KB(size); 427 gtt_entries = MB(48) - KB(size);
427 else 428 else
428 gtt_entries = 0; 429 gtt_entries = 0;
@@ -431,7 +432,8 @@ static void intel_i830_init_gtt_entries(void)
431 /* Check it's really I915G */ 432 /* Check it's really I915G */
432 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || 433 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
433 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 434 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
434 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB) 435 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
436 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB)
435 gtt_entries = MB(64) - KB(size); 437 gtt_entries = MB(64) - KB(size);
436 else 438 else
437 gtt_entries = 0; 439 gtt_entries = 0;
@@ -1681,6 +1683,14 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1681 } 1683 }
1682 name = "945G"; 1684 name = "945G";
1683 break; 1685 break;
1686 case PCI_DEVICE_ID_INTEL_82945GM_HB:
1687 if (find_i830(PCI_DEVICE_ID_INTEL_82945GM_IG)) {
1688 bridge->driver = &intel_915_driver;
1689 } else {
1690 bridge->driver = &intel_845_driver;
1691 }
1692 name = "945GM";
1693 break;
1684 case PCI_DEVICE_ID_INTEL_7505_0: 1694 case PCI_DEVICE_ID_INTEL_7505_0:
1685 bridge->driver = &intel_7505_driver; 1695 bridge->driver = &intel_7505_driver;
1686 name = "E7505"; 1696 name = "E7505";
@@ -1821,6 +1831,7 @@ static struct pci_device_id agp_intel_pci_table[] = {
1821 ID(PCI_DEVICE_ID_INTEL_82915G_HB), 1831 ID(PCI_DEVICE_ID_INTEL_82915G_HB),
1822 ID(PCI_DEVICE_ID_INTEL_82915GM_HB), 1832 ID(PCI_DEVICE_ID_INTEL_82915GM_HB),
1823 ID(PCI_DEVICE_ID_INTEL_82945G_HB), 1833 ID(PCI_DEVICE_ID_INTEL_82945G_HB),
1834 ID(PCI_DEVICE_ID_INTEL_82945GM_HB),
1824 { } 1835 { }
1825}; 1836};
1826 1837
diff --git a/drivers/char/agp/isoch.c b/drivers/char/agp/isoch.c
index 40083241804e..7c14a096b85e 100644
--- a/drivers/char/agp/isoch.c
+++ b/drivers/char/agp/isoch.c
@@ -218,10 +218,8 @@ static int agp_3_5_isochronous_node_enable(struct agp_bridge_data *bridge,
218 master[cdev].rq *= (1 << (master[cdev].y - 1)); 218 master[cdev].rq *= (1 << (master[cdev].y - 1));
219 219
220 tot_rq += master[cdev].rq; 220 tot_rq += master[cdev].rq;
221
222 if (cdev == ndevs-1)
223 master[cdev].n += rem;
224 } 221 }
222 master[ndevs-1].n += rem;
225 223
226 /* Figure the number of isochronous and asynchronous RQ slots the 224 /* Figure the number of isochronous and asynchronous RQ slots the
227 * target is providing. */ 225 * target is providing. */
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 39c61a71176e..cc7acf877dc0 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -1233,7 +1233,7 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1233 } 1233 }
1234 info->idle_stats.recv_idle = jiffies; 1234 info->idle_stats.recv_idle = jiffies;
1235 } 1235 }
1236 schedule_delayed_work(&tty->buf.work, 1); 1236 tty_schedule_flip(tty);
1237 } 1237 }
1238 /* end of service */ 1238 /* end of service */
1239 cy_writeb(base_addr+(CyRIR<<index), (save_xir & 0x3f)); 1239 cy_writeb(base_addr+(CyRIR<<index), (save_xir & 0x3f));
@@ -1606,7 +1606,7 @@ cyz_handle_rx(struct cyclades_port *info,
1606 } 1606 }
1607#endif 1607#endif
1608 info->idle_stats.recv_idle = jiffies; 1608 info->idle_stats.recv_idle = jiffies;
1609 schedule_delayed_work(&tty->buf.work, 1); 1609 tty_schedule_flip(tty);
1610 } 1610 }
1611 /* Update rx_get */ 1611 /* Update rx_get */
1612 cy_writel(&buf_ctrl->rx_get, new_rx_get); 1612 cy_writel(&buf_ctrl->rx_get, new_rx_get);
@@ -1809,7 +1809,7 @@ cyz_handle_cmd(struct cyclades_card *cinfo)
1809 if(delta_count) 1809 if(delta_count)
1810 cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP); 1810 cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP);
1811 if(special_count) 1811 if(special_count)
1812 schedule_delayed_work(&tty->buf.work, 1); 1812 tty_schedule_flip(tty);
1813 } 1813 }
1814} 1814}
1815 1815
diff --git a/drivers/char/drm/ati_pcigart.c b/drivers/char/drm/ati_pcigart.c
index 5485382cadec..bd7be09ea53d 100644
--- a/drivers/char/drm/ati_pcigart.c
+++ b/drivers/char/drm/ati_pcigart.c
@@ -59,17 +59,16 @@ static void *drm_ati_alloc_pcigart_table(void)
59 int i; 59 int i;
60 DRM_DEBUG("%s\n", __FUNCTION__); 60 DRM_DEBUG("%s\n", __FUNCTION__);
61 61
62 address = __get_free_pages(GFP_KERNEL, ATI_PCIGART_TABLE_ORDER); 62 address = __get_free_pages(GFP_KERNEL | __GFP_COMP,
63 ATI_PCIGART_TABLE_ORDER);
63 if (address == 0UL) { 64 if (address == 0UL) {
64 return 0; 65 return NULL;
65 } 66 }
66 67
67 page = virt_to_page(address); 68 page = virt_to_page(address);
68 69
69 for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++) { 70 for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++)
70 get_page(page);
71 SetPageReserved(page); 71 SetPageReserved(page);
72 }
73 72
74 DRM_DEBUG("%s: returning 0x%08lx\n", __FUNCTION__, address); 73 DRM_DEBUG("%s: returning 0x%08lx\n", __FUNCTION__, address);
75 return (void *)address; 74 return (void *)address;
@@ -83,10 +82,8 @@ static void drm_ati_free_pcigart_table(void *address)
83 82
84 page = virt_to_page((unsigned long)address); 83 page = virt_to_page((unsigned long)address);
85 84
86 for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++) { 85 for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++)
87 __put_page(page);
88 ClearPageReserved(page); 86 ClearPageReserved(page);
89 }
90 87
91 free_pages((unsigned long)address, ATI_PCIGART_TABLE_ORDER); 88 free_pages((unsigned long)address, ATI_PCIGART_TABLE_ORDER);
92} 89}
@@ -127,7 +124,7 @@ int drm_ati_pcigart_cleanup(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
127 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN 124 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN
128 && gart_info->addr) { 125 && gart_info->addr) {
129 drm_ati_free_pcigart_table(gart_info->addr); 126 drm_ati_free_pcigart_table(gart_info->addr);
130 gart_info->addr = 0; 127 gart_info->addr = NULL;
131 } 128 }
132 129
133 return 1; 130 return 1;
@@ -168,7 +165,7 @@ int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
168 if (bus_address == 0) { 165 if (bus_address == 0) {
169 DRM_ERROR("unable to map PCIGART pages!\n"); 166 DRM_ERROR("unable to map PCIGART pages!\n");
170 drm_ati_free_pcigart_table(address); 167 drm_ati_free_pcigart_table(address);
171 address = 0; 168 address = NULL;
172 goto done; 169 goto done;
173 } 170 }
174 } else { 171 } else {
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h
index 54b561e69486..107df9fdba4e 100644
--- a/drivers/char/drm/drmP.h
+++ b/drivers/char/drm/drmP.h
@@ -57,6 +57,7 @@
57#include <linux/smp_lock.h> /* For (un)lock_kernel */ 57#include <linux/smp_lock.h> /* For (un)lock_kernel */
58#include <linux/mm.h> 58#include <linux/mm.h>
59#include <linux/cdev.h> 59#include <linux/cdev.h>
60#include <linux/mutex.h>
60#if defined(__alpha__) || defined(__powerpc__) 61#if defined(__alpha__) || defined(__powerpc__)
61#include <asm/pgtable.h> /* For pte_wrprotect */ 62#include <asm/pgtable.h> /* For pte_wrprotect */
62#endif 63#endif
@@ -623,7 +624,7 @@ typedef struct drm_device {
623 /** \name Locks */ 624 /** \name Locks */
624 /*@{ */ 625 /*@{ */
625 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */ 626 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */
626 struct semaphore struct_sem; /**< For others */ 627 struct mutex struct_mutex; /**< For others */
627 /*@} */ 628 /*@} */
628 629
629 /** \name Usage Counters */ 630 /** \name Usage Counters */
@@ -658,7 +659,7 @@ typedef struct drm_device {
658 /*@{ */ 659 /*@{ */
659 drm_ctx_list_t *ctxlist; /**< Linked list of context handles */ 660 drm_ctx_list_t *ctxlist; /**< Linked list of context handles */
660 int ctx_count; /**< Number of context handles */ 661 int ctx_count; /**< Number of context handles */
661 struct semaphore ctxlist_sem; /**< For ctxlist */ 662 struct mutex ctxlist_mutex; /**< For ctxlist */
662 663
663 drm_map_t **context_sareas; /**< per-context SAREA's */ 664 drm_map_t **context_sareas; /**< per-context SAREA's */
664 int max_context; 665 int max_context;
@@ -979,7 +980,7 @@ extern int drm_put_head(drm_head_t * head);
979extern unsigned int drm_debug; 980extern unsigned int drm_debug;
980extern unsigned int drm_cards_limit; 981extern unsigned int drm_cards_limit;
981extern drm_head_t **drm_heads; 982extern drm_head_t **drm_heads;
982extern struct drm_sysfs_class *drm_class; 983extern struct class *drm_class;
983extern struct proc_dir_entry *drm_proc_root; 984extern struct proc_dir_entry *drm_proc_root;
984 985
985 /* Proc support (drm_proc.h) */ 986 /* Proc support (drm_proc.h) */
@@ -1010,11 +1011,9 @@ extern void __drm_pci_free(drm_device_t * dev, drm_dma_handle_t * dmah);
1010extern void drm_pci_free(drm_device_t * dev, drm_dma_handle_t * dmah); 1011extern void drm_pci_free(drm_device_t * dev, drm_dma_handle_t * dmah);
1011 1012
1012 /* sysfs support (drm_sysfs.c) */ 1013 /* sysfs support (drm_sysfs.c) */
1013struct drm_sysfs_class; 1014extern struct class *drm_sysfs_create(struct module *owner, char *name);
1014extern struct drm_sysfs_class *drm_sysfs_create(struct module *owner, 1015extern void drm_sysfs_destroy(struct class *cs);
1015 char *name); 1016extern struct class_device *drm_sysfs_device_add(struct class *cs,
1016extern void drm_sysfs_destroy(struct drm_sysfs_class *cs);
1017extern struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs,
1018 drm_head_t *head); 1017 drm_head_t *head);
1019extern void drm_sysfs_device_remove(struct class_device *class_dev); 1018extern void drm_sysfs_device_remove(struct class_device *class_dev);
1020 1019
diff --git a/drivers/char/drm/drm_auth.c b/drivers/char/drm/drm_auth.c
index a47b502bc7cc..2a37586a7ee8 100644
--- a/drivers/char/drm/drm_auth.c
+++ b/drivers/char/drm/drm_auth.c
@@ -56,7 +56,7 @@ static int drm_hash_magic(drm_magic_t magic)
56 * \param magic magic number. 56 * \param magic magic number.
57 * 57 *
58 * Searches in drm_device::magiclist within all files with the same hash key 58 * Searches in drm_device::magiclist within all files with the same hash key
59 * the one with matching magic number, while holding the drm_device::struct_sem 59 * the one with matching magic number, while holding the drm_device::struct_mutex
60 * lock. 60 * lock.
61 */ 61 */
62static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic) 62static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
@@ -65,14 +65,14 @@ static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
65 drm_magic_entry_t *pt; 65 drm_magic_entry_t *pt;
66 int hash = drm_hash_magic(magic); 66 int hash = drm_hash_magic(magic);
67 67
68 down(&dev->struct_sem); 68 mutex_lock(&dev->struct_mutex);
69 for (pt = dev->magiclist[hash].head; pt; pt = pt->next) { 69 for (pt = dev->magiclist[hash].head; pt; pt = pt->next) {
70 if (pt->magic == magic) { 70 if (pt->magic == magic) {
71 retval = pt->priv; 71 retval = pt->priv;
72 break; 72 break;
73 } 73 }
74 } 74 }
75 up(&dev->struct_sem); 75 mutex_unlock(&dev->struct_mutex);
76 return retval; 76 return retval;
77} 77}
78 78
@@ -85,7 +85,7 @@ static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
85 * 85 *
86 * Creates a drm_magic_entry structure and appends to the linked list 86 * Creates a drm_magic_entry structure and appends to the linked list
87 * associated the magic number hash key in drm_device::magiclist, while holding 87 * associated the magic number hash key in drm_device::magiclist, while holding
88 * the drm_device::struct_sem lock. 88 * the drm_device::struct_mutex lock.
89 */ 89 */
90static int drm_add_magic(drm_device_t * dev, drm_file_t * priv, 90static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
91 drm_magic_t magic) 91 drm_magic_t magic)
@@ -104,7 +104,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
104 entry->priv = priv; 104 entry->priv = priv;
105 entry->next = NULL; 105 entry->next = NULL;
106 106
107 down(&dev->struct_sem); 107 mutex_lock(&dev->struct_mutex);
108 if (dev->magiclist[hash].tail) { 108 if (dev->magiclist[hash].tail) {
109 dev->magiclist[hash].tail->next = entry; 109 dev->magiclist[hash].tail->next = entry;
110 dev->magiclist[hash].tail = entry; 110 dev->magiclist[hash].tail = entry;
@@ -112,7 +112,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
112 dev->magiclist[hash].head = entry; 112 dev->magiclist[hash].head = entry;
113 dev->magiclist[hash].tail = entry; 113 dev->magiclist[hash].tail = entry;
114 } 114 }
115 up(&dev->struct_sem); 115 mutex_unlock(&dev->struct_mutex);
116 116
117 return 0; 117 return 0;
118} 118}
@@ -124,7 +124,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
124 * \param magic magic number. 124 * \param magic magic number.
125 * 125 *
126 * Searches and unlinks the entry in drm_device::magiclist with the magic 126 * Searches and unlinks the entry in drm_device::magiclist with the magic
127 * number hash key, while holding the drm_device::struct_sem lock. 127 * number hash key, while holding the drm_device::struct_mutex lock.
128 */ 128 */
129static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic) 129static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
130{ 130{
@@ -135,7 +135,7 @@ static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
135 DRM_DEBUG("%d\n", magic); 135 DRM_DEBUG("%d\n", magic);
136 hash = drm_hash_magic(magic); 136 hash = drm_hash_magic(magic);
137 137
138 down(&dev->struct_sem); 138 mutex_lock(&dev->struct_mutex);
139 for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) { 139 for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) {
140 if (pt->magic == magic) { 140 if (pt->magic == magic) {
141 if (dev->magiclist[hash].head == pt) { 141 if (dev->magiclist[hash].head == pt) {
@@ -147,11 +147,11 @@ static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
147 if (prev) { 147 if (prev) {
148 prev->next = pt->next; 148 prev->next = pt->next;
149 } 149 }
150 up(&dev->struct_sem); 150 mutex_unlock(&dev->struct_mutex);
151 return 0; 151 return 0;
152 } 152 }
153 } 153 }
154 up(&dev->struct_sem); 154 mutex_unlock(&dev->struct_mutex);
155 155
156 drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC); 156 drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
157 157
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c
index 1db12dcb6802..e2637b4d51de 100644
--- a/drivers/char/drm/drm_bufs.c
+++ b/drivers/char/drm/drm_bufs.c
@@ -255,14 +255,14 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
255 memset(list, 0, sizeof(*list)); 255 memset(list, 0, sizeof(*list));
256 list->map = map; 256 list->map = map;
257 257
258 down(&dev->struct_sem); 258 mutex_lock(&dev->struct_mutex);
259 list_add(&list->head, &dev->maplist->head); 259 list_add(&list->head, &dev->maplist->head);
260 /* Assign a 32-bit handle */ 260 /* Assign a 32-bit handle */
261 /* We do it here so that dev->struct_sem protects the increment */ 261 /* We do it here so that dev->struct_mutex protects the increment */
262 list->user_token = HandleID(map->type == _DRM_SHM 262 list->user_token = HandleID(map->type == _DRM_SHM
263 ? (unsigned long)map->handle 263 ? (unsigned long)map->handle
264 : map->offset, dev); 264 : map->offset, dev);
265 up(&dev->struct_sem); 265 mutex_unlock(&dev->struct_mutex);
266 266
267 *maplist = list; 267 *maplist = list;
268 return 0; 268 return 0;
@@ -392,9 +392,9 @@ int drm_rmmap(drm_device_t *dev, drm_local_map_t *map)
392{ 392{
393 int ret; 393 int ret;
394 394
395 down(&dev->struct_sem); 395 mutex_lock(&dev->struct_mutex);
396 ret = drm_rmmap_locked(dev, map); 396 ret = drm_rmmap_locked(dev, map);
397 up(&dev->struct_sem); 397 mutex_unlock(&dev->struct_mutex);
398 398
399 return ret; 399 return ret;
400} 400}
@@ -423,7 +423,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
423 return -EFAULT; 423 return -EFAULT;
424 } 424 }
425 425
426 down(&dev->struct_sem); 426 mutex_lock(&dev->struct_mutex);
427 list_for_each(list, &dev->maplist->head) { 427 list_for_each(list, &dev->maplist->head) {
428 drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head); 428 drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head);
429 429
@@ -439,7 +439,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
439 * find anything. 439 * find anything.
440 */ 440 */
441 if (list == (&dev->maplist->head)) { 441 if (list == (&dev->maplist->head)) {
442 up(&dev->struct_sem); 442 mutex_unlock(&dev->struct_mutex);
443 return -EINVAL; 443 return -EINVAL;
444 } 444 }
445 445
@@ -448,13 +448,13 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
448 448
449 /* Register and framebuffer maps are permanent */ 449 /* Register and framebuffer maps are permanent */
450 if ((map->type == _DRM_REGISTERS) || (map->type == _DRM_FRAME_BUFFER)) { 450 if ((map->type == _DRM_REGISTERS) || (map->type == _DRM_FRAME_BUFFER)) {
451 up(&dev->struct_sem); 451 mutex_unlock(&dev->struct_mutex);
452 return 0; 452 return 0;
453 } 453 }
454 454
455 ret = drm_rmmap_locked(dev, map); 455 ret = drm_rmmap_locked(dev, map);
456 456
457 up(&dev->struct_sem); 457 mutex_unlock(&dev->struct_mutex);
458 458
459 return ret; 459 return ret;
460} 460}
@@ -566,16 +566,16 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
566 atomic_inc(&dev->buf_alloc); 566 atomic_inc(&dev->buf_alloc);
567 spin_unlock(&dev->count_lock); 567 spin_unlock(&dev->count_lock);
568 568
569 down(&dev->struct_sem); 569 mutex_lock(&dev->struct_mutex);
570 entry = &dma->bufs[order]; 570 entry = &dma->bufs[order];
571 if (entry->buf_count) { 571 if (entry->buf_count) {
572 up(&dev->struct_sem); 572 mutex_unlock(&dev->struct_mutex);
573 atomic_dec(&dev->buf_alloc); 573 atomic_dec(&dev->buf_alloc);
574 return -ENOMEM; /* May only call once for each order */ 574 return -ENOMEM; /* May only call once for each order */
575 } 575 }
576 576
577 if (count < 0 || count > 4096) { 577 if (count < 0 || count > 4096) {
578 up(&dev->struct_sem); 578 mutex_unlock(&dev->struct_mutex);
579 atomic_dec(&dev->buf_alloc); 579 atomic_dec(&dev->buf_alloc);
580 return -EINVAL; 580 return -EINVAL;
581 } 581 }
@@ -583,7 +583,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
583 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 583 entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
584 DRM_MEM_BUFS); 584 DRM_MEM_BUFS);
585 if (!entry->buflist) { 585 if (!entry->buflist) {
586 up(&dev->struct_sem); 586 mutex_unlock(&dev->struct_mutex);
587 atomic_dec(&dev->buf_alloc); 587 atomic_dec(&dev->buf_alloc);
588 return -ENOMEM; 588 return -ENOMEM;
589 } 589 }
@@ -616,7 +616,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
616 /* Set count correctly so we free the proper amount. */ 616 /* Set count correctly so we free the proper amount. */
617 entry->buf_count = count; 617 entry->buf_count = count;
618 drm_cleanup_buf_error(dev, entry); 618 drm_cleanup_buf_error(dev, entry);
619 up(&dev->struct_sem); 619 mutex_unlock(&dev->struct_mutex);
620 atomic_dec(&dev->buf_alloc); 620 atomic_dec(&dev->buf_alloc);
621 return -ENOMEM; 621 return -ENOMEM;
622 } 622 }
@@ -638,7 +638,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
638 if (!temp_buflist) { 638 if (!temp_buflist) {
639 /* Free the entry because it isn't valid */ 639 /* Free the entry because it isn't valid */
640 drm_cleanup_buf_error(dev, entry); 640 drm_cleanup_buf_error(dev, entry);
641 up(&dev->struct_sem); 641 mutex_unlock(&dev->struct_mutex);
642 atomic_dec(&dev->buf_alloc); 642 atomic_dec(&dev->buf_alloc);
643 return -ENOMEM; 643 return -ENOMEM;
644 } 644 }
@@ -656,7 +656,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
656 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); 656 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
657 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count); 657 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
658 658
659 up(&dev->struct_sem); 659 mutex_unlock(&dev->struct_mutex);
660 660
661 request->count = entry->buf_count; 661 request->count = entry->buf_count;
662 request->size = size; 662 request->size = size;
@@ -722,16 +722,16 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
722 atomic_inc(&dev->buf_alloc); 722 atomic_inc(&dev->buf_alloc);
723 spin_unlock(&dev->count_lock); 723 spin_unlock(&dev->count_lock);
724 724
725 down(&dev->struct_sem); 725 mutex_lock(&dev->struct_mutex);
726 entry = &dma->bufs[order]; 726 entry = &dma->bufs[order];
727 if (entry->buf_count) { 727 if (entry->buf_count) {
728 up(&dev->struct_sem); 728 mutex_unlock(&dev->struct_mutex);
729 atomic_dec(&dev->buf_alloc); 729 atomic_dec(&dev->buf_alloc);
730 return -ENOMEM; /* May only call once for each order */ 730 return -ENOMEM; /* May only call once for each order */
731 } 731 }
732 732
733 if (count < 0 || count > 4096) { 733 if (count < 0 || count > 4096) {
734 up(&dev->struct_sem); 734 mutex_unlock(&dev->struct_mutex);
735 atomic_dec(&dev->buf_alloc); 735 atomic_dec(&dev->buf_alloc);
736 return -EINVAL; 736 return -EINVAL;
737 } 737 }
@@ -739,7 +739,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
739 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 739 entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
740 DRM_MEM_BUFS); 740 DRM_MEM_BUFS);
741 if (!entry->buflist) { 741 if (!entry->buflist) {
742 up(&dev->struct_sem); 742 mutex_unlock(&dev->struct_mutex);
743 atomic_dec(&dev->buf_alloc); 743 atomic_dec(&dev->buf_alloc);
744 return -ENOMEM; 744 return -ENOMEM;
745 } 745 }
@@ -750,7 +750,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
750 if (!entry->seglist) { 750 if (!entry->seglist) {
751 drm_free(entry->buflist, 751 drm_free(entry->buflist,
752 count * sizeof(*entry->buflist), DRM_MEM_BUFS); 752 count * sizeof(*entry->buflist), DRM_MEM_BUFS);
753 up(&dev->struct_sem); 753 mutex_unlock(&dev->struct_mutex);
754 atomic_dec(&dev->buf_alloc); 754 atomic_dec(&dev->buf_alloc);
755 return -ENOMEM; 755 return -ENOMEM;
756 } 756 }
@@ -766,7 +766,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
766 count * sizeof(*entry->buflist), DRM_MEM_BUFS); 766 count * sizeof(*entry->buflist), DRM_MEM_BUFS);
767 drm_free(entry->seglist, 767 drm_free(entry->seglist,
768 count * sizeof(*entry->seglist), DRM_MEM_SEGS); 768 count * sizeof(*entry->seglist), DRM_MEM_SEGS);
769 up(&dev->struct_sem); 769 mutex_unlock(&dev->struct_mutex);
770 atomic_dec(&dev->buf_alloc); 770 atomic_dec(&dev->buf_alloc);
771 return -ENOMEM; 771 return -ENOMEM;
772 } 772 }
@@ -790,7 +790,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
790 drm_free(temp_pagelist, 790 drm_free(temp_pagelist,
791 (dma->page_count + (count << page_order)) 791 (dma->page_count + (count << page_order))
792 * sizeof(*dma->pagelist), DRM_MEM_PAGES); 792 * sizeof(*dma->pagelist), DRM_MEM_PAGES);
793 up(&dev->struct_sem); 793 mutex_unlock(&dev->struct_mutex);
794 atomic_dec(&dev->buf_alloc); 794 atomic_dec(&dev->buf_alloc);
795 return -ENOMEM; 795 return -ENOMEM;
796 } 796 }
@@ -831,7 +831,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
831 (count << page_order)) 831 (count << page_order))
832 * sizeof(*dma->pagelist), 832 * sizeof(*dma->pagelist),
833 DRM_MEM_PAGES); 833 DRM_MEM_PAGES);
834 up(&dev->struct_sem); 834 mutex_unlock(&dev->struct_mutex);
835 atomic_dec(&dev->buf_alloc); 835 atomic_dec(&dev->buf_alloc);
836 return -ENOMEM; 836 return -ENOMEM;
837 } 837 }
@@ -853,7 +853,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
853 drm_free(temp_pagelist, 853 drm_free(temp_pagelist,
854 (dma->page_count + (count << page_order)) 854 (dma->page_count + (count << page_order))
855 * sizeof(*dma->pagelist), DRM_MEM_PAGES); 855 * sizeof(*dma->pagelist), DRM_MEM_PAGES);
856 up(&dev->struct_sem); 856 mutex_unlock(&dev->struct_mutex);
857 atomic_dec(&dev->buf_alloc); 857 atomic_dec(&dev->buf_alloc);
858 return -ENOMEM; 858 return -ENOMEM;
859 } 859 }
@@ -878,7 +878,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
878 dma->page_count += entry->seg_count << page_order; 878 dma->page_count += entry->seg_count << page_order;
879 dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order); 879 dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order);
880 880
881 up(&dev->struct_sem); 881 mutex_unlock(&dev->struct_mutex);
882 882
883 request->count = entry->buf_count; 883 request->count = entry->buf_count;
884 request->size = size; 884 request->size = size;
@@ -948,16 +948,16 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
948 atomic_inc(&dev->buf_alloc); 948 atomic_inc(&dev->buf_alloc);
949 spin_unlock(&dev->count_lock); 949 spin_unlock(&dev->count_lock);
950 950
951 down(&dev->struct_sem); 951 mutex_lock(&dev->struct_mutex);
952 entry = &dma->bufs[order]; 952 entry = &dma->bufs[order];
953 if (entry->buf_count) { 953 if (entry->buf_count) {
954 up(&dev->struct_sem); 954 mutex_unlock(&dev->struct_mutex);
955 atomic_dec(&dev->buf_alloc); 955 atomic_dec(&dev->buf_alloc);
956 return -ENOMEM; /* May only call once for each order */ 956 return -ENOMEM; /* May only call once for each order */
957 } 957 }
958 958
959 if (count < 0 || count > 4096) { 959 if (count < 0 || count > 4096) {
960 up(&dev->struct_sem); 960 mutex_unlock(&dev->struct_mutex);
961 atomic_dec(&dev->buf_alloc); 961 atomic_dec(&dev->buf_alloc);
962 return -EINVAL; 962 return -EINVAL;
963 } 963 }
@@ -965,7 +965,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
965 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 965 entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
966 DRM_MEM_BUFS); 966 DRM_MEM_BUFS);
967 if (!entry->buflist) { 967 if (!entry->buflist) {
968 up(&dev->struct_sem); 968 mutex_unlock(&dev->struct_mutex);
969 atomic_dec(&dev->buf_alloc); 969 atomic_dec(&dev->buf_alloc);
970 return -ENOMEM; 970 return -ENOMEM;
971 } 971 }
@@ -999,7 +999,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
999 /* Set count correctly so we free the proper amount. */ 999 /* Set count correctly so we free the proper amount. */
1000 entry->buf_count = count; 1000 entry->buf_count = count;
1001 drm_cleanup_buf_error(dev, entry); 1001 drm_cleanup_buf_error(dev, entry);
1002 up(&dev->struct_sem); 1002 mutex_unlock(&dev->struct_mutex);
1003 atomic_dec(&dev->buf_alloc); 1003 atomic_dec(&dev->buf_alloc);
1004 return -ENOMEM; 1004 return -ENOMEM;
1005 } 1005 }
@@ -1022,7 +1022,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
1022 if (!temp_buflist) { 1022 if (!temp_buflist) {
1023 /* Free the entry because it isn't valid */ 1023 /* Free the entry because it isn't valid */
1024 drm_cleanup_buf_error(dev, entry); 1024 drm_cleanup_buf_error(dev, entry);
1025 up(&dev->struct_sem); 1025 mutex_unlock(&dev->struct_mutex);
1026 atomic_dec(&dev->buf_alloc); 1026 atomic_dec(&dev->buf_alloc);
1027 return -ENOMEM; 1027 return -ENOMEM;
1028 } 1028 }
@@ -1040,7 +1040,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
1040 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); 1040 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
1041 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count); 1041 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
1042 1042
1043 up(&dev->struct_sem); 1043 mutex_unlock(&dev->struct_mutex);
1044 1044
1045 request->count = entry->buf_count; 1045 request->count = entry->buf_count;
1046 request->size = size; 1046 request->size = size;
@@ -1110,16 +1110,16 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
1110 atomic_inc(&dev->buf_alloc); 1110 atomic_inc(&dev->buf_alloc);
1111 spin_unlock(&dev->count_lock); 1111 spin_unlock(&dev->count_lock);
1112 1112
1113 down(&dev->struct_sem); 1113 mutex_lock(&dev->struct_mutex);
1114 entry = &dma->bufs[order]; 1114 entry = &dma->bufs[order];
1115 if (entry->buf_count) { 1115 if (entry->buf_count) {
1116 up(&dev->struct_sem); 1116 mutex_unlock(&dev->struct_mutex);
1117 atomic_dec(&dev->buf_alloc); 1117 atomic_dec(&dev->buf_alloc);
1118 return -ENOMEM; /* May only call once for each order */ 1118 return -ENOMEM; /* May only call once for each order */
1119 } 1119 }
1120 1120
1121 if (count < 0 || count > 4096) { 1121 if (count < 0 || count > 4096) {
1122 up(&dev->struct_sem); 1122 mutex_unlock(&dev->struct_mutex);
1123 atomic_dec(&dev->buf_alloc); 1123 atomic_dec(&dev->buf_alloc);
1124 return -EINVAL; 1124 return -EINVAL;
1125 } 1125 }
@@ -1127,7 +1127,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
1127 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 1127 entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
1128 DRM_MEM_BUFS); 1128 DRM_MEM_BUFS);
1129 if (!entry->buflist) { 1129 if (!entry->buflist) {
1130 up(&dev->struct_sem); 1130 mutex_unlock(&dev->struct_mutex);
1131 atomic_dec(&dev->buf_alloc); 1131 atomic_dec(&dev->buf_alloc);
1132 return -ENOMEM; 1132 return -ENOMEM;
1133 } 1133 }
@@ -1160,7 +1160,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
1160 /* Set count correctly so we free the proper amount. */ 1160 /* Set count correctly so we free the proper amount. */
1161 entry->buf_count = count; 1161 entry->buf_count = count;
1162 drm_cleanup_buf_error(dev, entry); 1162 drm_cleanup_buf_error(dev, entry);
1163 up(&dev->struct_sem); 1163 mutex_unlock(&dev->struct_mutex);
1164 atomic_dec(&dev->buf_alloc); 1164 atomic_dec(&dev->buf_alloc);
1165 return -ENOMEM; 1165 return -ENOMEM;
1166 } 1166 }
@@ -1182,7 +1182,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
1182 if (!temp_buflist) { 1182 if (!temp_buflist) {
1183 /* Free the entry because it isn't valid */ 1183 /* Free the entry because it isn't valid */
1184 drm_cleanup_buf_error(dev, entry); 1184 drm_cleanup_buf_error(dev, entry);
1185 up(&dev->struct_sem); 1185 mutex_unlock(&dev->struct_mutex);
1186 atomic_dec(&dev->buf_alloc); 1186 atomic_dec(&dev->buf_alloc);
1187 return -ENOMEM; 1187 return -ENOMEM;
1188 } 1188 }
@@ -1200,7 +1200,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
1200 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); 1200 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
1201 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count); 1201 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
1202 1202
1203 up(&dev->struct_sem); 1203 mutex_unlock(&dev->struct_mutex);
1204 1204
1205 request->count = entry->buf_count; 1205 request->count = entry->buf_count;
1206 request->size = size; 1206 request->size = size;
diff --git a/drivers/char/drm/drm_context.c b/drivers/char/drm/drm_context.c
index f84254526949..83094c73da67 100644
--- a/drivers/char/drm/drm_context.c
+++ b/drivers/char/drm/drm_context.c
@@ -53,7 +53,7 @@
53 * \param ctx_handle context handle. 53 * \param ctx_handle context handle.
54 * 54 *
55 * Clears the bit specified by \p ctx_handle in drm_device::ctx_bitmap and the entry 55 * Clears the bit specified by \p ctx_handle in drm_device::ctx_bitmap and the entry
56 * in drm_device::context_sareas, while holding the drm_device::struct_sem 56 * in drm_device::context_sareas, while holding the drm_device::struct_mutex
57 * lock. 57 * lock.
58 */ 58 */
59void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle) 59void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
@@ -64,10 +64,10 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
64 goto failed; 64 goto failed;
65 65
66 if (ctx_handle < DRM_MAX_CTXBITMAP) { 66 if (ctx_handle < DRM_MAX_CTXBITMAP) {
67 down(&dev->struct_sem); 67 mutex_lock(&dev->struct_mutex);
68 clear_bit(ctx_handle, dev->ctx_bitmap); 68 clear_bit(ctx_handle, dev->ctx_bitmap);
69 dev->context_sareas[ctx_handle] = NULL; 69 dev->context_sareas[ctx_handle] = NULL;
70 up(&dev->struct_sem); 70 mutex_unlock(&dev->struct_mutex);
71 return; 71 return;
72 } 72 }
73 failed: 73 failed:
@@ -83,7 +83,7 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
83 * 83 *
84 * Find the first zero bit in drm_device::ctx_bitmap and (re)allocates 84 * Find the first zero bit in drm_device::ctx_bitmap and (re)allocates
85 * drm_device::context_sareas to accommodate the new entry while holding the 85 * drm_device::context_sareas to accommodate the new entry while holding the
86 * drm_device::struct_sem lock. 86 * drm_device::struct_mutex lock.
87 */ 87 */
88static int drm_ctxbitmap_next(drm_device_t * dev) 88static int drm_ctxbitmap_next(drm_device_t * dev)
89{ 89{
@@ -92,7 +92,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
92 if (!dev->ctx_bitmap) 92 if (!dev->ctx_bitmap)
93 return -1; 93 return -1;
94 94
95 down(&dev->struct_sem); 95 mutex_lock(&dev->struct_mutex);
96 bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP); 96 bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP);
97 if (bit < DRM_MAX_CTXBITMAP) { 97 if (bit < DRM_MAX_CTXBITMAP) {
98 set_bit(bit, dev->ctx_bitmap); 98 set_bit(bit, dev->ctx_bitmap);
@@ -113,7 +113,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
113 DRM_MEM_MAPS); 113 DRM_MEM_MAPS);
114 if (!ctx_sareas) { 114 if (!ctx_sareas) {
115 clear_bit(bit, dev->ctx_bitmap); 115 clear_bit(bit, dev->ctx_bitmap);
116 up(&dev->struct_sem); 116 mutex_unlock(&dev->struct_mutex);
117 return -1; 117 return -1;
118 } 118 }
119 dev->context_sareas = ctx_sareas; 119 dev->context_sareas = ctx_sareas;
@@ -126,16 +126,16 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
126 DRM_MEM_MAPS); 126 DRM_MEM_MAPS);
127 if (!dev->context_sareas) { 127 if (!dev->context_sareas) {
128 clear_bit(bit, dev->ctx_bitmap); 128 clear_bit(bit, dev->ctx_bitmap);
129 up(&dev->struct_sem); 129 mutex_unlock(&dev->struct_mutex);
130 return -1; 130 return -1;
131 } 131 }
132 dev->context_sareas[bit] = NULL; 132 dev->context_sareas[bit] = NULL;
133 } 133 }
134 } 134 }
135 up(&dev->struct_sem); 135 mutex_unlock(&dev->struct_mutex);
136 return bit; 136 return bit;
137 } 137 }
138 up(&dev->struct_sem); 138 mutex_unlock(&dev->struct_mutex);
139 return -1; 139 return -1;
140} 140}
141 141
@@ -145,24 +145,24 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
145 * \param dev DRM device. 145 * \param dev DRM device.
146 * 146 *
147 * Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding 147 * Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding
148 * the drm_device::struct_sem lock. 148 * the drm_device::struct_mutex lock.
149 */ 149 */
150int drm_ctxbitmap_init(drm_device_t * dev) 150int drm_ctxbitmap_init(drm_device_t * dev)
151{ 151{
152 int i; 152 int i;
153 int temp; 153 int temp;
154 154
155 down(&dev->struct_sem); 155 mutex_lock(&dev->struct_mutex);
156 dev->ctx_bitmap = (unsigned long *)drm_alloc(PAGE_SIZE, 156 dev->ctx_bitmap = (unsigned long *)drm_alloc(PAGE_SIZE,
157 DRM_MEM_CTXBITMAP); 157 DRM_MEM_CTXBITMAP);
158 if (dev->ctx_bitmap == NULL) { 158 if (dev->ctx_bitmap == NULL) {
159 up(&dev->struct_sem); 159 mutex_unlock(&dev->struct_mutex);
160 return -ENOMEM; 160 return -ENOMEM;
161 } 161 }
162 memset((void *)dev->ctx_bitmap, 0, PAGE_SIZE); 162 memset((void *)dev->ctx_bitmap, 0, PAGE_SIZE);
163 dev->context_sareas = NULL; 163 dev->context_sareas = NULL;
164 dev->max_context = -1; 164 dev->max_context = -1;
165 up(&dev->struct_sem); 165 mutex_unlock(&dev->struct_mutex);
166 166
167 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { 167 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
168 temp = drm_ctxbitmap_next(dev); 168 temp = drm_ctxbitmap_next(dev);
@@ -178,17 +178,17 @@ int drm_ctxbitmap_init(drm_device_t * dev)
178 * \param dev DRM device. 178 * \param dev DRM device.
179 * 179 *
180 * Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding 180 * Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding
181 * the drm_device::struct_sem lock. 181 * the drm_device::struct_mutex lock.
182 */ 182 */
183void drm_ctxbitmap_cleanup(drm_device_t * dev) 183void drm_ctxbitmap_cleanup(drm_device_t * dev)
184{ 184{
185 down(&dev->struct_sem); 185 mutex_lock(&dev->struct_mutex);
186 if (dev->context_sareas) 186 if (dev->context_sareas)
187 drm_free(dev->context_sareas, 187 drm_free(dev->context_sareas,
188 sizeof(*dev->context_sareas) * 188 sizeof(*dev->context_sareas) *
189 dev->max_context, DRM_MEM_MAPS); 189 dev->max_context, DRM_MEM_MAPS);
190 drm_free((void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP); 190 drm_free((void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP);
191 up(&dev->struct_sem); 191 mutex_unlock(&dev->struct_mutex);
192} 192}
193 193
194/*@}*/ 194/*@}*/
@@ -222,15 +222,15 @@ int drm_getsareactx(struct inode *inode, struct file *filp,
222 if (copy_from_user(&request, argp, sizeof(request))) 222 if (copy_from_user(&request, argp, sizeof(request)))
223 return -EFAULT; 223 return -EFAULT;
224 224
225 down(&dev->struct_sem); 225 mutex_lock(&dev->struct_mutex);
226 if (dev->max_context < 0 226 if (dev->max_context < 0
227 || request.ctx_id >= (unsigned)dev->max_context) { 227 || request.ctx_id >= (unsigned)dev->max_context) {
228 up(&dev->struct_sem); 228 mutex_unlock(&dev->struct_mutex);
229 return -EINVAL; 229 return -EINVAL;
230 } 230 }
231 231
232 map = dev->context_sareas[request.ctx_id]; 232 map = dev->context_sareas[request.ctx_id];
233 up(&dev->struct_sem); 233 mutex_unlock(&dev->struct_mutex);
234 234
235 request.handle = NULL; 235 request.handle = NULL;
236 list_for_each_entry(_entry, &dev->maplist->head, head) { 236 list_for_each_entry(_entry, &dev->maplist->head, head) {
@@ -274,7 +274,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
274 (drm_ctx_priv_map_t __user *) arg, sizeof(request))) 274 (drm_ctx_priv_map_t __user *) arg, sizeof(request)))
275 return -EFAULT; 275 return -EFAULT;
276 276
277 down(&dev->struct_sem); 277 mutex_lock(&dev->struct_mutex);
278 list_for_each(list, &dev->maplist->head) { 278 list_for_each(list, &dev->maplist->head) {
279 r_list = list_entry(list, drm_map_list_t, head); 279 r_list = list_entry(list, drm_map_list_t, head);
280 if (r_list->map 280 if (r_list->map
@@ -282,7 +282,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
282 goto found; 282 goto found;
283 } 283 }
284 bad: 284 bad:
285 up(&dev->struct_sem); 285 mutex_unlock(&dev->struct_mutex);
286 return -EINVAL; 286 return -EINVAL;
287 287
288 found: 288 found:
@@ -294,7 +294,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
294 if (request.ctx_id >= (unsigned)dev->max_context) 294 if (request.ctx_id >= (unsigned)dev->max_context)
295 goto bad; 295 goto bad;
296 dev->context_sareas[request.ctx_id] = map; 296 dev->context_sareas[request.ctx_id] = map;
297 up(&dev->struct_sem); 297 mutex_unlock(&dev->struct_mutex);
298 return 0; 298 return 0;
299} 299}
300 300
@@ -448,10 +448,10 @@ int drm_addctx(struct inode *inode, struct file *filp,
448 ctx_entry->handle = ctx.handle; 448 ctx_entry->handle = ctx.handle;
449 ctx_entry->tag = priv; 449 ctx_entry->tag = priv;
450 450
451 down(&dev->ctxlist_sem); 451 mutex_lock(&dev->ctxlist_mutex);
452 list_add(&ctx_entry->head, &dev->ctxlist->head); 452 list_add(&ctx_entry->head, &dev->ctxlist->head);
453 ++dev->ctx_count; 453 ++dev->ctx_count;
454 up(&dev->ctxlist_sem); 454 mutex_unlock(&dev->ctxlist_mutex);
455 455
456 if (copy_to_user(argp, &ctx, sizeof(ctx))) 456 if (copy_to_user(argp, &ctx, sizeof(ctx)))
457 return -EFAULT; 457 return -EFAULT;
@@ -574,7 +574,7 @@ int drm_rmctx(struct inode *inode, struct file *filp,
574 drm_ctxbitmap_free(dev, ctx.handle); 574 drm_ctxbitmap_free(dev, ctx.handle);
575 } 575 }
576 576
577 down(&dev->ctxlist_sem); 577 mutex_lock(&dev->ctxlist_mutex);
578 if (!list_empty(&dev->ctxlist->head)) { 578 if (!list_empty(&dev->ctxlist->head)) {
579 drm_ctx_list_t *pos, *n; 579 drm_ctx_list_t *pos, *n;
580 580
@@ -586,7 +586,7 @@ int drm_rmctx(struct inode *inode, struct file *filp,
586 } 586 }
587 } 587 }
588 } 588 }
589 up(&dev->ctxlist_sem); 589 mutex_unlock(&dev->ctxlist_mutex);
590 590
591 return 0; 591 return 0;
592} 592}
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c
index c4fa5a29582b..dc6bbe8a18dc 100644
--- a/drivers/char/drm/drm_drv.c
+++ b/drivers/char/drm/drm_drv.c
@@ -151,7 +151,7 @@ int drm_lastclose(drm_device_t * dev)
151 if (dev->irq_enabled) 151 if (dev->irq_enabled)
152 drm_irq_uninstall(dev); 152 drm_irq_uninstall(dev);
153 153
154 down(&dev->struct_sem); 154 mutex_lock(&dev->struct_mutex);
155 del_timer(&dev->timer); 155 del_timer(&dev->timer);
156 156
157 /* Clear pid list */ 157 /* Clear pid list */
@@ -231,7 +231,7 @@ int drm_lastclose(drm_device_t * dev)
231 dev->lock.filp = NULL; 231 dev->lock.filp = NULL;
232 wake_up_interruptible(&dev->lock.lock_queue); 232 wake_up_interruptible(&dev->lock.lock_queue);
233 } 233 }
234 up(&dev->struct_sem); 234 mutex_unlock(&dev->struct_mutex);
235 235
236 DRM_DEBUG("lastclose completed\n"); 236 DRM_DEBUG("lastclose completed\n");
237 return 0; 237 return 0;
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c
index 403f44a1bf01..641f7633878c 100644
--- a/drivers/char/drm/drm_fops.c
+++ b/drivers/char/drm/drm_fops.c
@@ -262,7 +262,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
262 goto out_free; 262 goto out_free;
263 } 263 }
264 264
265 down(&dev->struct_sem); 265 mutex_lock(&dev->struct_mutex);
266 if (!dev->file_last) { 266 if (!dev->file_last) {
267 priv->next = NULL; 267 priv->next = NULL;
268 priv->prev = NULL; 268 priv->prev = NULL;
@@ -276,7 +276,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
276 dev->file_last->next = priv; 276 dev->file_last->next = priv;
277 dev->file_last = priv; 277 dev->file_last = priv;
278 } 278 }
279 up(&dev->struct_sem); 279 mutex_unlock(&dev->struct_mutex);
280 280
281#ifdef __alpha__ 281#ifdef __alpha__
282 /* 282 /*
@@ -413,7 +413,7 @@ int drm_release(struct inode *inode, struct file *filp)
413 413
414 drm_fasync(-1, filp, 0); 414 drm_fasync(-1, filp, 0);
415 415
416 down(&dev->ctxlist_sem); 416 mutex_lock(&dev->ctxlist_mutex);
417 if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) { 417 if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) {
418 drm_ctx_list_t *pos, *n; 418 drm_ctx_list_t *pos, *n;
419 419
@@ -432,9 +432,9 @@ int drm_release(struct inode *inode, struct file *filp)
432 } 432 }
433 } 433 }
434 } 434 }
435 up(&dev->ctxlist_sem); 435 mutex_unlock(&dev->ctxlist_mutex);
436 436
437 down(&dev->struct_sem); 437 mutex_lock(&dev->struct_mutex);
438 if (priv->remove_auth_on_close == 1) { 438 if (priv->remove_auth_on_close == 1) {
439 drm_file_t *temp = dev->file_first; 439 drm_file_t *temp = dev->file_first;
440 while (temp) { 440 while (temp) {
@@ -452,7 +452,7 @@ int drm_release(struct inode *inode, struct file *filp)
452 } else { 452 } else {
453 dev->file_last = priv->prev; 453 dev->file_last = priv->prev;
454 } 454 }
455 up(&dev->struct_sem); 455 mutex_unlock(&dev->struct_mutex);
456 456
457 if (dev->driver->postclose) 457 if (dev->driver->postclose)
458 dev->driver->postclose(dev, priv); 458 dev->driver->postclose(dev, priv);
diff --git a/drivers/char/drm/drm_ioctl.c b/drivers/char/drm/drm_ioctl.c
index bcd4e604d3ec..555f323b8a32 100644
--- a/drivers/char/drm/drm_ioctl.c
+++ b/drivers/char/drm/drm_ioctl.c
@@ -194,9 +194,9 @@ int drm_getmap(struct inode *inode, struct file *filp,
194 return -EFAULT; 194 return -EFAULT;
195 idx = map.offset; 195 idx = map.offset;
196 196
197 down(&dev->struct_sem); 197 mutex_lock(&dev->struct_mutex);
198 if (idx < 0) { 198 if (idx < 0) {
199 up(&dev->struct_sem); 199 mutex_unlock(&dev->struct_mutex);
200 return -EINVAL; 200 return -EINVAL;
201 } 201 }
202 202
@@ -209,7 +209,7 @@ int drm_getmap(struct inode *inode, struct file *filp,
209 i++; 209 i++;
210 } 210 }
211 if (!r_list || !r_list->map) { 211 if (!r_list || !r_list->map) {
212 up(&dev->struct_sem); 212 mutex_unlock(&dev->struct_mutex);
213 return -EINVAL; 213 return -EINVAL;
214 } 214 }
215 215
@@ -219,7 +219,7 @@ int drm_getmap(struct inode *inode, struct file *filp,
219 map.flags = r_list->map->flags; 219 map.flags = r_list->map->flags;
220 map.handle = (void *)(unsigned long)r_list->user_token; 220 map.handle = (void *)(unsigned long)r_list->user_token;
221 map.mtrr = r_list->map->mtrr; 221 map.mtrr = r_list->map->mtrr;
222 up(&dev->struct_sem); 222 mutex_unlock(&dev->struct_mutex);
223 223
224 if (copy_to_user(argp, &map, sizeof(map))) 224 if (copy_to_user(argp, &map, sizeof(map)))
225 return -EFAULT; 225 return -EFAULT;
@@ -253,11 +253,11 @@ int drm_getclient(struct inode *inode, struct file *filp,
253 if (copy_from_user(&client, argp, sizeof(client))) 253 if (copy_from_user(&client, argp, sizeof(client)))
254 return -EFAULT; 254 return -EFAULT;
255 idx = client.idx; 255 idx = client.idx;
256 down(&dev->struct_sem); 256 mutex_lock(&dev->struct_mutex);
257 for (i = 0, pt = dev->file_first; i < idx && pt; i++, pt = pt->next) ; 257 for (i = 0, pt = dev->file_first; i < idx && pt; i++, pt = pt->next) ;
258 258
259 if (!pt) { 259 if (!pt) {
260 up(&dev->struct_sem); 260 mutex_unlock(&dev->struct_mutex);
261 return -EINVAL; 261 return -EINVAL;
262 } 262 }
263 client.auth = pt->authenticated; 263 client.auth = pt->authenticated;
@@ -265,7 +265,7 @@ int drm_getclient(struct inode *inode, struct file *filp,
265 client.uid = pt->uid; 265 client.uid = pt->uid;
266 client.magic = pt->magic; 266 client.magic = pt->magic;
267 client.iocs = pt->ioctl_count; 267 client.iocs = pt->ioctl_count;
268 up(&dev->struct_sem); 268 mutex_unlock(&dev->struct_mutex);
269 269
270 if (copy_to_user(argp, &client, sizeof(client))) 270 if (copy_to_user(argp, &client, sizeof(client)))
271 return -EFAULT; 271 return -EFAULT;
@@ -292,7 +292,7 @@ int drm_getstats(struct inode *inode, struct file *filp,
292 292
293 memset(&stats, 0, sizeof(stats)); 293 memset(&stats, 0, sizeof(stats));
294 294
295 down(&dev->struct_sem); 295 mutex_lock(&dev->struct_mutex);
296 296
297 for (i = 0; i < dev->counters; i++) { 297 for (i = 0; i < dev->counters; i++) {
298 if (dev->types[i] == _DRM_STAT_LOCK) 298 if (dev->types[i] == _DRM_STAT_LOCK)
@@ -305,7 +305,7 @@ int drm_getstats(struct inode *inode, struct file *filp,
305 305
306 stats.count = dev->counters; 306 stats.count = dev->counters;
307 307
308 up(&dev->struct_sem); 308 mutex_unlock(&dev->struct_mutex);
309 309
310 if (copy_to_user((drm_stats_t __user *) arg, &stats, sizeof(stats))) 310 if (copy_to_user((drm_stats_t __user *) arg, &stats, sizeof(stats)))
311 return -EFAULT; 311 return -EFAULT;
diff --git a/drivers/char/drm/drm_irq.c b/drivers/char/drm/drm_irq.c
index b0d4b236e837..611a1173091d 100644
--- a/drivers/char/drm/drm_irq.c
+++ b/drivers/char/drm/drm_irq.c
@@ -98,20 +98,20 @@ static int drm_irq_install(drm_device_t * dev)
98 if (dev->irq == 0) 98 if (dev->irq == 0)
99 return -EINVAL; 99 return -EINVAL;
100 100
101 down(&dev->struct_sem); 101 mutex_lock(&dev->struct_mutex);
102 102
103 /* Driver must have been initialized */ 103 /* Driver must have been initialized */
104 if (!dev->dev_private) { 104 if (!dev->dev_private) {
105 up(&dev->struct_sem); 105 mutex_unlock(&dev->struct_mutex);
106 return -EINVAL; 106 return -EINVAL;
107 } 107 }
108 108
109 if (dev->irq_enabled) { 109 if (dev->irq_enabled) {
110 up(&dev->struct_sem); 110 mutex_unlock(&dev->struct_mutex);
111 return -EBUSY; 111 return -EBUSY;
112 } 112 }
113 dev->irq_enabled = 1; 113 dev->irq_enabled = 1;
114 up(&dev->struct_sem); 114 mutex_unlock(&dev->struct_mutex);
115 115
116 DRM_DEBUG("%s: irq=%d\n", __FUNCTION__, dev->irq); 116 DRM_DEBUG("%s: irq=%d\n", __FUNCTION__, dev->irq);
117 117
@@ -135,9 +135,9 @@ static int drm_irq_install(drm_device_t * dev)
135 ret = request_irq(dev->irq, dev->driver->irq_handler, 135 ret = request_irq(dev->irq, dev->driver->irq_handler,
136 sh_flags, dev->devname, dev); 136 sh_flags, dev->devname, dev);
137 if (ret < 0) { 137 if (ret < 0) {
138 down(&dev->struct_sem); 138 mutex_lock(&dev->struct_mutex);
139 dev->irq_enabled = 0; 139 dev->irq_enabled = 0;
140 up(&dev->struct_sem); 140 mutex_unlock(&dev->struct_mutex);
141 return ret; 141 return ret;
142 } 142 }
143 143
@@ -161,10 +161,10 @@ int drm_irq_uninstall(drm_device_t * dev)
161 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 161 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
162 return -EINVAL; 162 return -EINVAL;
163 163
164 down(&dev->struct_sem); 164 mutex_lock(&dev->struct_mutex);
165 irq_enabled = dev->irq_enabled; 165 irq_enabled = dev->irq_enabled;
166 dev->irq_enabled = 0; 166 dev->irq_enabled = 0;
167 up(&dev->struct_sem); 167 mutex_unlock(&dev->struct_mutex);
168 168
169 if (!irq_enabled) 169 if (!irq_enabled)
170 return -EINVAL; 170 return -EINVAL;
diff --git a/drivers/char/drm/drm_pciids.h b/drivers/char/drm/drm_pciids.h
index 5b1d3a04458d..8fd6357a48da 100644
--- a/drivers/char/drm/drm_pciids.h
+++ b/drivers/char/drm/drm_pciids.h
@@ -3,6 +3,7 @@
3 Please contact dri-devel@lists.sf.net to add new cards to this list 3 Please contact dri-devel@lists.sf.net to add new cards to this list
4*/ 4*/
5#define radeon_PCI_IDS \ 5#define radeon_PCI_IDS \
6 {0x1002, 0x3150, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350},\
6 {0x1002, 0x4136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS100|CHIP_IS_IGP}, \ 7 {0x1002, 0x4136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS100|CHIP_IS_IGP}, \
7 {0x1002, 0x4137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|CHIP_IS_IGP}, \ 8 {0x1002, 0x4137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|CHIP_IS_IGP}, \
8 {0x1002, 0x4144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ 9 {0x1002, 0x4144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
@@ -242,5 +243,6 @@
242 {0x8086, 0x2582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 243 {0x8086, 0x2582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
243 {0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 244 {0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
244 {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 245 {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
246 {0x8086, 0x27a2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
245 {0, 0, 0} 247 {0, 0, 0}
246 248
diff --git a/drivers/char/drm/drm_proc.c b/drivers/char/drm/drm_proc.c
index 6f943e3309ef..362a270af0f1 100644
--- a/drivers/char/drm/drm_proc.c
+++ b/drivers/char/drm/drm_proc.c
@@ -258,7 +258,7 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request,
258} 258}
259 259
260/** 260/**
261 * Simply calls _vm_info() while holding the drm_device::struct_sem lock. 261 * Simply calls _vm_info() while holding the drm_device::struct_mutex lock.
262 */ 262 */
263static int drm_vm_info(char *buf, char **start, off_t offset, int request, 263static int drm_vm_info(char *buf, char **start, off_t offset, int request,
264 int *eof, void *data) 264 int *eof, void *data)
@@ -266,9 +266,9 @@ static int drm_vm_info(char *buf, char **start, off_t offset, int request,
266 drm_device_t *dev = (drm_device_t *) data; 266 drm_device_t *dev = (drm_device_t *) data;
267 int ret; 267 int ret;
268 268
269 down(&dev->struct_sem); 269 mutex_lock(&dev->struct_mutex);
270 ret = drm__vm_info(buf, start, offset, request, eof, data); 270 ret = drm__vm_info(buf, start, offset, request, eof, data);
271 up(&dev->struct_sem); 271 mutex_unlock(&dev->struct_mutex);
272 return ret; 272 return ret;
273} 273}
274 274
@@ -331,7 +331,7 @@ static int drm__queues_info(char *buf, char **start, off_t offset,
331} 331}
332 332
333/** 333/**
334 * Simply calls _queues_info() while holding the drm_device::struct_sem lock. 334 * Simply calls _queues_info() while holding the drm_device::struct_mutex lock.
335 */ 335 */
336static int drm_queues_info(char *buf, char **start, off_t offset, int request, 336static int drm_queues_info(char *buf, char **start, off_t offset, int request,
337 int *eof, void *data) 337 int *eof, void *data)
@@ -339,9 +339,9 @@ static int drm_queues_info(char *buf, char **start, off_t offset, int request,
339 drm_device_t *dev = (drm_device_t *) data; 339 drm_device_t *dev = (drm_device_t *) data;
340 int ret; 340 int ret;
341 341
342 down(&dev->struct_sem); 342 mutex_lock(&dev->struct_mutex);
343 ret = drm__queues_info(buf, start, offset, request, eof, data); 343 ret = drm__queues_info(buf, start, offset, request, eof, data);
344 up(&dev->struct_sem); 344 mutex_unlock(&dev->struct_mutex);
345 return ret; 345 return ret;
346} 346}
347 347
@@ -403,7 +403,7 @@ static int drm__bufs_info(char *buf, char **start, off_t offset, int request,
403} 403}
404 404
405/** 405/**
406 * Simply calls _bufs_info() while holding the drm_device::struct_sem lock. 406 * Simply calls _bufs_info() while holding the drm_device::struct_mutex lock.
407 */ 407 */
408static int drm_bufs_info(char *buf, char **start, off_t offset, int request, 408static int drm_bufs_info(char *buf, char **start, off_t offset, int request,
409 int *eof, void *data) 409 int *eof, void *data)
@@ -411,9 +411,9 @@ static int drm_bufs_info(char *buf, char **start, off_t offset, int request,
411 drm_device_t *dev = (drm_device_t *) data; 411 drm_device_t *dev = (drm_device_t *) data;
412 int ret; 412 int ret;
413 413
414 down(&dev->struct_sem); 414 mutex_lock(&dev->struct_mutex);
415 ret = drm__bufs_info(buf, start, offset, request, eof, data); 415 ret = drm__bufs_info(buf, start, offset, request, eof, data);
416 up(&dev->struct_sem); 416 mutex_unlock(&dev->struct_mutex);
417 return ret; 417 return ret;
418} 418}
419 419
@@ -459,7 +459,7 @@ static int drm__clients_info(char *buf, char **start, off_t offset,
459} 459}
460 460
461/** 461/**
462 * Simply calls _clients_info() while holding the drm_device::struct_sem lock. 462 * Simply calls _clients_info() while holding the drm_device::struct_mutex lock.
463 */ 463 */
464static int drm_clients_info(char *buf, char **start, off_t offset, 464static int drm_clients_info(char *buf, char **start, off_t offset,
465 int request, int *eof, void *data) 465 int request, int *eof, void *data)
@@ -467,9 +467,9 @@ static int drm_clients_info(char *buf, char **start, off_t offset,
467 drm_device_t *dev = (drm_device_t *) data; 467 drm_device_t *dev = (drm_device_t *) data;
468 int ret; 468 int ret;
469 469
470 down(&dev->struct_sem); 470 mutex_lock(&dev->struct_mutex);
471 ret = drm__clients_info(buf, start, offset, request, eof, data); 471 ret = drm__clients_info(buf, start, offset, request, eof, data);
472 up(&dev->struct_sem); 472 mutex_unlock(&dev->struct_mutex);
473 return ret; 473 return ret;
474} 474}
475 475
@@ -540,9 +540,9 @@ static int drm_vma_info(char *buf, char **start, off_t offset, int request,
540 drm_device_t *dev = (drm_device_t *) data; 540 drm_device_t *dev = (drm_device_t *) data;
541 int ret; 541 int ret;
542 542
543 down(&dev->struct_sem); 543 mutex_lock(&dev->struct_mutex);
544 ret = drm__vma_info(buf, start, offset, request, eof, data); 544 ret = drm__vma_info(buf, start, offset, request, eof, data);
545 up(&dev->struct_sem); 545 mutex_unlock(&dev->struct_mutex);
546 return ret; 546 return ret;
547} 547}
548#endif 548#endif
diff --git a/drivers/char/drm/drm_stub.c b/drivers/char/drm/drm_stub.c
index 42d766359caa..68073e14fdec 100644
--- a/drivers/char/drm/drm_stub.c
+++ b/drivers/char/drm/drm_stub.c
@@ -50,7 +50,7 @@ module_param_named(cards_limit, drm_cards_limit, int, 0444);
50module_param_named(debug, drm_debug, int, 0600); 50module_param_named(debug, drm_debug, int, 0600);
51 51
52drm_head_t **drm_heads; 52drm_head_t **drm_heads;
53struct drm_sysfs_class *drm_class; 53struct class *drm_class;
54struct proc_dir_entry *drm_proc_root; 54struct proc_dir_entry *drm_proc_root;
55 55
56static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev, 56static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
@@ -61,8 +61,8 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
61 61
62 spin_lock_init(&dev->count_lock); 62 spin_lock_init(&dev->count_lock);
63 init_timer(&dev->timer); 63 init_timer(&dev->timer);
64 sema_init(&dev->struct_sem, 1); 64 mutex_init(&dev->struct_mutex);
65 sema_init(&dev->ctxlist_sem, 1); 65 mutex_init(&dev->ctxlist_mutex);
66 66
67 dev->pdev = pdev; 67 dev->pdev = pdev;
68 68
diff --git a/drivers/char/drm/drm_sysfs.c b/drivers/char/drm/drm_sysfs.c
index 68e43ddc16ae..0b9f98a7eb10 100644
--- a/drivers/char/drm/drm_sysfs.c
+++ b/drivers/char/drm/drm_sysfs.c
@@ -1,3 +1,4 @@
1
1/* 2/*
2 * drm_sysfs.c - Modifications to drm_sysfs_class.c to support 3 * drm_sysfs.c - Modifications to drm_sysfs_class.c to support
3 * extra sysfs attribute from DRM. Normal drm_sysfs_class 4 * extra sysfs attribute from DRM. Normal drm_sysfs_class
@@ -19,36 +20,6 @@
19#include "drm_core.h" 20#include "drm_core.h"
20#include "drmP.h" 21#include "drmP.h"
21 22
22struct drm_sysfs_class {
23 struct class_device_attribute attr;
24 struct class class;
25};
26#define to_drm_sysfs_class(d) container_of(d, struct drm_sysfs_class, class)
27
28struct simple_dev {
29 dev_t dev;
30 struct class_device class_dev;
31};
32#define to_simple_dev(d) container_of(d, struct simple_dev, class_dev)
33
34static void release_simple_dev(struct class_device *class_dev)
35{
36 struct simple_dev *s_dev = to_simple_dev(class_dev);
37 kfree(s_dev);
38}
39
40static ssize_t show_dev(struct class_device *class_dev, char *buf)
41{
42 struct simple_dev *s_dev = to_simple_dev(class_dev);
43 return print_dev_t(buf, s_dev->dev);
44}
45
46static void drm_sysfs_class_release(struct class *class)
47{
48 struct drm_sysfs_class *cs = to_drm_sysfs_class(class);
49 kfree(cs);
50}
51
52/* Display the version of drm_core. This doesn't work right in current design */ 23/* Display the version of drm_core. This doesn't work right in current design */
53static ssize_t version_show(struct class *dev, char *buf) 24static ssize_t version_show(struct class *dev, char *buf)
54{ 25{
@@ -69,38 +40,16 @@ static CLASS_ATTR(version, S_IRUGO, version_show, NULL);
69 * Note, the pointer created here is to be destroyed when finished by making a 40 * Note, the pointer created here is to be destroyed when finished by making a
70 * call to drm_sysfs_destroy(). 41 * call to drm_sysfs_destroy().
71 */ 42 */
72struct drm_sysfs_class *drm_sysfs_create(struct module *owner, char *name) 43struct class *drm_sysfs_create(struct module *owner, char *name)
73{ 44{
74 struct drm_sysfs_class *cs; 45 struct class *class;
75 int retval; 46
76 47 class = class_create(owner, name);
77 cs = kmalloc(sizeof(*cs), GFP_KERNEL); 48 if (!class)
78 if (!cs) { 49 return class;
79 retval = -ENOMEM; 50
80 goto error; 51 class_create_file(class, &class_attr_version);
81 } 52 return class;
82 memset(cs, 0x00, sizeof(*cs));
83
84 cs->class.name = name;
85 cs->class.class_release = drm_sysfs_class_release;
86 cs->class.release = release_simple_dev;
87
88 cs->attr.attr.name = "dev";
89 cs->attr.attr.mode = S_IRUGO;
90 cs->attr.attr.owner = owner;
91 cs->attr.show = show_dev;
92 cs->attr.store = NULL;
93
94 retval = class_register(&cs->class);
95 if (retval)
96 goto error;
97 class_create_file(&cs->class, &class_attr_version);
98
99 return cs;
100
101 error:
102 kfree(cs);
103 return ERR_PTR(retval);
104} 53}
105 54
106/** 55/**
@@ -110,12 +59,13 @@ struct drm_sysfs_class *drm_sysfs_create(struct module *owner, char *name)
110 * Note, the pointer to be destroyed must have been created with a call to 59 * Note, the pointer to be destroyed must have been created with a call to
111 * drm_sysfs_create(). 60 * drm_sysfs_create().
112 */ 61 */
113void drm_sysfs_destroy(struct drm_sysfs_class *cs) 62void drm_sysfs_destroy(struct class *class)
114{ 63{
115 if ((cs == NULL) || (IS_ERR(cs))) 64 if ((class == NULL) || (IS_ERR(class)))
116 return; 65 return;
117 66
118 class_unregister(&cs->class); 67 class_remove_file(class, &class_attr_version);
68 class_destroy(class);
119} 69}
120 70
121static ssize_t show_dri(struct class_device *class_device, char *buf) 71static ssize_t show_dri(struct class_device *class_device, char *buf)
@@ -132,7 +82,7 @@ static struct class_device_attribute class_device_attrs[] = {
132 82
133/** 83/**
134 * drm_sysfs_device_add - adds a class device to sysfs for a character driver 84 * drm_sysfs_device_add - adds a class device to sysfs for a character driver
135 * @cs: pointer to the struct drm_sysfs_class that this device should be registered to. 85 * @cs: pointer to the struct class that this device should be registered to.
136 * @dev: the dev_t for the device to be added. 86 * @dev: the dev_t for the device to be added.
137 * @device: a pointer to a struct device that is assiociated with this class device. 87 * @device: a pointer to a struct device that is assiociated with this class device.
138 * @fmt: string for the class device's name 88 * @fmt: string for the class device's name
@@ -141,46 +91,26 @@ static struct class_device_attribute class_device_attrs[] = {
141 * class. A "dev" file will be created, showing the dev_t for the device. The 91 * class. A "dev" file will be created, showing the dev_t for the device. The
142 * pointer to the struct class_device will be returned from the call. Any further 92 * pointer to the struct class_device will be returned from the call. Any further
143 * sysfs files that might be required can be created using this pointer. 93 * sysfs files that might be required can be created using this pointer.
144 * Note: the struct drm_sysfs_class passed to this function must have previously been 94 * Note: the struct class passed to this function must have previously been
145 * created with a call to drm_sysfs_create(). 95 * created with a call to drm_sysfs_create().
146 */ 96 */
147struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs, 97struct class_device *drm_sysfs_device_add(struct class *cs, drm_head_t *head)
148 drm_head_t *head)
149{ 98{
150 struct simple_dev *s_dev = NULL; 99 struct class_device *class_dev;
151 int i, retval; 100 int i;
152
153 if ((cs == NULL) || (IS_ERR(cs))) {
154 retval = -ENODEV;
155 goto error;
156 }
157
158 s_dev = kmalloc(sizeof(*s_dev), GFP_KERNEL);
159 if (!s_dev) {
160 retval = -ENOMEM;
161 goto error;
162 }
163 memset(s_dev, 0x00, sizeof(*s_dev));
164
165 s_dev->dev = MKDEV(DRM_MAJOR, head->minor);
166 s_dev->class_dev.dev = &(head->dev->pdev)->dev;
167 s_dev->class_dev.class = &cs->class;
168 101
169 snprintf(s_dev->class_dev.class_id, BUS_ID_SIZE, "card%d", head->minor); 102 class_dev = class_device_create(cs, NULL,
170 retval = class_device_register(&s_dev->class_dev); 103 MKDEV(DRM_MAJOR, head->minor),
171 if (retval) 104 &(head->dev->pdev)->dev,
172 goto error; 105 "card%d", head->minor);
106 if (!class_dev)
107 return NULL;
173 108
174 class_device_create_file(&s_dev->class_dev, &cs->attr); 109 class_set_devdata(class_dev, head);
175 class_set_devdata(&s_dev->class_dev, head);
176 110
177 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) 111 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
178 class_device_create_file(&s_dev->class_dev, &class_device_attrs[i]); 112 class_device_create_file(class_dev, &class_device_attrs[i]);
179 return &s_dev->class_dev; 113 return class_dev;
180
181error:
182 kfree(s_dev);
183 return ERR_PTR(retval);
184} 114}
185 115
186/** 116/**
@@ -192,10 +122,9 @@ error:
192 */ 122 */
193void drm_sysfs_device_remove(struct class_device *class_dev) 123void drm_sysfs_device_remove(struct class_device *class_dev)
194{ 124{
195 struct simple_dev *s_dev = to_simple_dev(class_dev);
196 int i; 125 int i;
197 126
198 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) 127 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
199 class_device_remove_file(&s_dev->class_dev, &class_device_attrs[i]); 128 class_device_remove_file(class_dev, &class_device_attrs[i]);
200 class_device_unregister(&s_dev->class_dev); 129 class_device_unregister(class_dev);
201} 130}
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index 3f73aa774c80..0291cd62c69f 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -188,7 +188,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
188 188
189 map = vma->vm_private_data; 189 map = vma->vm_private_data;
190 190
191 down(&dev->struct_sem); 191 mutex_lock(&dev->struct_mutex);
192 for (pt = dev->vmalist, prev = NULL; pt; pt = next) { 192 for (pt = dev->vmalist, prev = NULL; pt; pt = next) {
193 next = pt->next; 193 next = pt->next;
194 if (pt->vma->vm_private_data == map) 194 if (pt->vma->vm_private_data == map)
@@ -248,7 +248,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
248 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 248 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
249 } 249 }
250 } 250 }
251 up(&dev->struct_sem); 251 mutex_unlock(&dev->struct_mutex);
252} 252}
253 253
254/** 254/**
@@ -404,12 +404,12 @@ static void drm_vm_open(struct vm_area_struct *vma)
404 404
405 vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS); 405 vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS);
406 if (vma_entry) { 406 if (vma_entry) {
407 down(&dev->struct_sem); 407 mutex_lock(&dev->struct_mutex);
408 vma_entry->vma = vma; 408 vma_entry->vma = vma;
409 vma_entry->next = dev->vmalist; 409 vma_entry->next = dev->vmalist;
410 vma_entry->pid = current->pid; 410 vma_entry->pid = current->pid;
411 dev->vmalist = vma_entry; 411 dev->vmalist = vma_entry;
412 up(&dev->struct_sem); 412 mutex_unlock(&dev->struct_mutex);
413 } 413 }
414} 414}
415 415
@@ -431,7 +431,7 @@ static void drm_vm_close(struct vm_area_struct *vma)
431 vma->vm_start, vma->vm_end - vma->vm_start); 431 vma->vm_start, vma->vm_end - vma->vm_start);
432 atomic_dec(&dev->vma_count); 432 atomic_dec(&dev->vma_count);
433 433
434 down(&dev->struct_sem); 434 mutex_lock(&dev->struct_mutex);
435 for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) { 435 for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) {
436 if (pt->vma == vma) { 436 if (pt->vma == vma) {
437 if (prev) { 437 if (prev) {
@@ -443,7 +443,7 @@ static void drm_vm_close(struct vm_area_struct *vma)
443 break; 443 break;
444 } 444 }
445 } 445 }
446 up(&dev->struct_sem); 446 mutex_unlock(&dev->struct_mutex);
447} 447}
448 448
449/** 449/**
diff --git a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c
index cc1b89086876..ae0aa6d7e0bb 100644
--- a/drivers/char/drm/i810_dma.c
+++ b/drivers/char/drm/i810_dma.c
@@ -958,7 +958,7 @@ static int i810_flush_queue(drm_device_t * dev)
958} 958}
959 959
960/* Must be called with the lock held */ 960/* Must be called with the lock held */
961void i810_reclaim_buffers(drm_device_t * dev, struct file *filp) 961static void i810_reclaim_buffers(drm_device_t * dev, struct file *filp)
962{ 962{
963 drm_device_dma_t *dma = dev->dma; 963 drm_device_dma_t *dma = dev->dma;
964 int i; 964 int i;
diff --git a/drivers/char/drm/i810_drv.h b/drivers/char/drm/i810_drv.h
index a18b80d91920..e8cf3ff606f0 100644
--- a/drivers/char/drm/i810_drv.h
+++ b/drivers/char/drm/i810_drv.h
@@ -113,8 +113,6 @@ typedef struct drm_i810_private {
113} drm_i810_private_t; 113} drm_i810_private_t;
114 114
115 /* i810_dma.c */ 115 /* i810_dma.c */
116extern void i810_reclaim_buffers(drm_device_t * dev, struct file *filp);
117
118extern int i810_driver_dma_quiescent(drm_device_t * dev); 116extern int i810_driver_dma_quiescent(drm_device_t * dev);
119extern void i810_driver_reclaim_buffers_locked(drm_device_t * dev, 117extern void i810_driver_reclaim_buffers_locked(drm_device_t * dev,
120 struct file *filp); 118 struct file *filp);
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c
index 4fea32aed6d2..163f2cbfe60d 100644
--- a/drivers/char/drm/i830_dma.c
+++ b/drivers/char/drm/i830_dma.c
@@ -1239,7 +1239,7 @@ static int i830_flush_queue(drm_device_t * dev)
1239} 1239}
1240 1240
1241/* Must be called with the lock held */ 1241/* Must be called with the lock held */
1242void i830_reclaim_buffers(drm_device_t * dev, struct file *filp) 1242static void i830_reclaim_buffers(drm_device_t * dev, struct file *filp)
1243{ 1243{
1244 drm_device_dma_t *dma = dev->dma; 1244 drm_device_dma_t *dma = dev->dma;
1245 int i; 1245 int i;
diff --git a/drivers/char/drm/i830_drv.h b/drivers/char/drm/i830_drv.h
index bf9075b576bd..85bc5be6f916 100644
--- a/drivers/char/drm/i830_drv.h
+++ b/drivers/char/drm/i830_drv.h
@@ -123,9 +123,6 @@ typedef struct drm_i830_private {
123extern drm_ioctl_desc_t i830_ioctls[]; 123extern drm_ioctl_desc_t i830_ioctls[];
124extern int i830_max_ioctl; 124extern int i830_max_ioctl;
125 125
126/* i830_dma.c */
127extern void i830_reclaim_buffers(drm_device_t * dev, struct file *filp);
128
129/* i830_irq.c */ 126/* i830_irq.c */
130extern int i830_irq_emit(struct inode *inode, struct file *filp, 127extern int i830_irq_emit(struct inode *inode, struct file *filp,
131 unsigned int cmd, unsigned long arg); 128 unsigned int cmd, unsigned long arg);
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c
index 9140703da1ba..1ff4c7ca0bff 100644
--- a/drivers/char/drm/i915_dma.c
+++ b/drivers/char/drm/i915_dma.c
@@ -344,18 +344,20 @@ static int i915_emit_cmds(drm_device_t * dev, int __user * buffer, int dwords)
344 int i; 344 int i;
345 RING_LOCALS; 345 RING_LOCALS;
346 346
347 if ((dwords+1) * sizeof(int) >= dev_priv->ring.Size - 8)
348 return DRM_ERR(EINVAL);
349
350 BEGIN_LP_RING(((dwords+1)&~1));
351
347 for (i = 0; i < dwords;) { 352 for (i = 0; i < dwords;) {
348 int cmd, sz; 353 int cmd, sz;
349 354
350 if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i], sizeof(cmd))) 355 if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i], sizeof(cmd)))
351 return DRM_ERR(EINVAL); 356 return DRM_ERR(EINVAL);
352 357
353/* printk("%d/%d ", i, dwords); */
354
355 if ((sz = validate_cmd(cmd)) == 0 || i + sz > dwords) 358 if ((sz = validate_cmd(cmd)) == 0 || i + sz > dwords)
356 return DRM_ERR(EINVAL); 359 return DRM_ERR(EINVAL);
357 360
358 BEGIN_LP_RING(sz);
359 OUT_RING(cmd); 361 OUT_RING(cmd);
360 362
361 while (++i, --sz) { 363 while (++i, --sz) {
@@ -365,9 +367,13 @@ static int i915_emit_cmds(drm_device_t * dev, int __user * buffer, int dwords)
365 } 367 }
366 OUT_RING(cmd); 368 OUT_RING(cmd);
367 } 369 }
368 ADVANCE_LP_RING();
369 } 370 }
370 371
372 if (dwords & 1)
373 OUT_RING(0);
374
375 ADVANCE_LP_RING();
376
371 return 0; 377 return 0;
372} 378}
373 379
@@ -401,6 +407,21 @@ static int i915_emit_box(drm_device_t * dev,
401 return 0; 407 return 0;
402} 408}
403 409
410static void i915_emit_breadcrumb(drm_device_t *dev)
411{
412 drm_i915_private_t *dev_priv = dev->dev_private;
413 RING_LOCALS;
414
415 dev_priv->sarea_priv->last_enqueue = dev_priv->counter++;
416
417 BEGIN_LP_RING(4);
418 OUT_RING(CMD_STORE_DWORD_IDX);
419 OUT_RING(20);
420 OUT_RING(dev_priv->counter);
421 OUT_RING(0);
422 ADVANCE_LP_RING();
423}
424
404static int i915_dispatch_cmdbuffer(drm_device_t * dev, 425static int i915_dispatch_cmdbuffer(drm_device_t * dev,
405 drm_i915_cmdbuffer_t * cmd) 426 drm_i915_cmdbuffer_t * cmd)
406{ 427{
@@ -429,6 +450,7 @@ static int i915_dispatch_cmdbuffer(drm_device_t * dev,
429 return ret; 450 return ret;
430 } 451 }
431 452
453 i915_emit_breadcrumb(dev);
432 return 0; 454 return 0;
433} 455}
434 456
@@ -475,12 +497,7 @@ static int i915_dispatch_batchbuffer(drm_device_t * dev,
475 497
476 dev_priv->sarea_priv->last_enqueue = dev_priv->counter++; 498 dev_priv->sarea_priv->last_enqueue = dev_priv->counter++;
477 499
478 BEGIN_LP_RING(4); 500 i915_emit_breadcrumb(dev);
479 OUT_RING(CMD_STORE_DWORD_IDX);
480 OUT_RING(20);
481 OUT_RING(dev_priv->counter);
482 OUT_RING(0);
483 ADVANCE_LP_RING();
484 501
485 return 0; 502 return 0;
486} 503}
@@ -657,7 +674,7 @@ static int i915_getparam(DRM_IOCTL_ARGS)
657 value = READ_BREADCRUMB(dev_priv); 674 value = READ_BREADCRUMB(dev_priv);
658 break; 675 break;
659 default: 676 default:
660 DRM_ERROR("Unkown parameter %d\n", param.param); 677 DRM_ERROR("Unknown parameter %d\n", param.param);
661 return DRM_ERR(EINVAL); 678 return DRM_ERR(EINVAL);
662 } 679 }
663 680
@@ -742,7 +759,8 @@ drm_ioctl_desc_t i915_ioctls[] = {
742 [DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, DRM_AUTH}, 759 [DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, DRM_AUTH},
743 [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH}, 760 [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH},
744 [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, 761 [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
745 [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH} 762 [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH},
763 [DRM_IOCTL_NR(DRM_I915_DESTROY_HEAP)] = { i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }
746}; 764};
747 765
748int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); 766int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
diff --git a/drivers/char/drm/i915_drm.h b/drivers/char/drm/i915_drm.h
index 77412ddac007..4cb3da578330 100644
--- a/drivers/char/drm/i915_drm.h
+++ b/drivers/char/drm/i915_drm.h
@@ -74,6 +74,30 @@ typedef struct _drm_i915_sarea {
74 int pf_active; 74 int pf_active;
75 int pf_current_page; /* which buffer is being displayed? */ 75 int pf_current_page; /* which buffer is being displayed? */
76 int perf_boxes; /* performance boxes to be displayed */ 76 int perf_boxes; /* performance boxes to be displayed */
77 int width, height; /* screen size in pixels */
78
79 drm_handle_t front_handle;
80 int front_offset;
81 int front_size;
82
83 drm_handle_t back_handle;
84 int back_offset;
85 int back_size;
86
87 drm_handle_t depth_handle;
88 int depth_offset;
89 int depth_size;
90
91 drm_handle_t tex_handle;
92 int tex_offset;
93 int tex_size;
94 int log_tex_granularity;
95 int pitch;
96 int rotation; /* 0, 90, 180 or 270 */
97 int rotated_offset;
98 int rotated_size;
99 int rotated_pitch;
100 int virtualX, virtualY;
77} drm_i915_sarea_t; 101} drm_i915_sarea_t;
78 102
79/* Flags for perf_boxes 103/* Flags for perf_boxes
@@ -99,6 +123,7 @@ typedef struct _drm_i915_sarea {
99#define DRM_I915_FREE 0x09 123#define DRM_I915_FREE 0x09
100#define DRM_I915_INIT_HEAP 0x0a 124#define DRM_I915_INIT_HEAP 0x0a
101#define DRM_I915_CMDBUFFER 0x0b 125#define DRM_I915_CMDBUFFER 0x0b
126#define DRM_I915_DESTROY_HEAP 0x0c
102 127
103#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) 128#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
104#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) 129#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
@@ -112,6 +137,7 @@ typedef struct _drm_i915_sarea {
112#define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t) 137#define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)
113#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t) 138#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
114#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t) 139#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
140#define DRM_IOCTL_I915_DESTROY_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t)
115 141
116/* Allow drivers to submit batchbuffers directly to hardware, relying 142/* Allow drivers to submit batchbuffers directly to hardware, relying
117 * on the security mechanisms provided by hardware. 143 * on the security mechanisms provided by hardware.
@@ -191,4 +217,11 @@ typedef struct drm_i915_mem_init_heap {
191 int start; 217 int start;
192} drm_i915_mem_init_heap_t; 218} drm_i915_mem_init_heap_t;
193 219
220/* Allow memory manager to be torn down and re-initialized (eg on
221 * rotate):
222 */
223typedef struct drm_i915_mem_destroy_heap {
224 int region;
225} drm_i915_mem_destroy_heap_t;
226
194#endif /* _I915_DRM_H_ */ 227#endif /* _I915_DRM_H_ */
diff --git a/drivers/char/drm/i915_drv.h b/drivers/char/drm/i915_drv.h
index c6c71b45f101..7a65666899e4 100644
--- a/drivers/char/drm/i915_drv.h
+++ b/drivers/char/drm/i915_drv.h
@@ -37,16 +37,17 @@
37 37
38#define DRIVER_NAME "i915" 38#define DRIVER_NAME "i915"
39#define DRIVER_DESC "Intel Graphics" 39#define DRIVER_DESC "Intel Graphics"
40#define DRIVER_DATE "20051209" 40#define DRIVER_DATE "20060119"
41 41
42/* Interface history: 42/* Interface history:
43 * 43 *
44 * 1.1: Original. 44 * 1.1: Original.
45 * 1.2: Add Power Management 45 * 1.2: Add Power Management
46 * 1.3: Add vblank support 46 * 1.3: Add vblank support
47 * 1.4: Fix cmdbuffer path, add heap destroy
47 */ 48 */
48#define DRIVER_MAJOR 1 49#define DRIVER_MAJOR 1
49#define DRIVER_MINOR 3 50#define DRIVER_MINOR 4
50#define DRIVER_PATCHLEVEL 0 51#define DRIVER_PATCHLEVEL 0
51 52
52typedef struct _drm_i915_ring_buffer { 53typedef struct _drm_i915_ring_buffer {
@@ -123,6 +124,7 @@ extern void i915_driver_irq_uninstall(drm_device_t * dev);
123extern int i915_mem_alloc(DRM_IOCTL_ARGS); 124extern int i915_mem_alloc(DRM_IOCTL_ARGS);
124extern int i915_mem_free(DRM_IOCTL_ARGS); 125extern int i915_mem_free(DRM_IOCTL_ARGS);
125extern int i915_mem_init_heap(DRM_IOCTL_ARGS); 126extern int i915_mem_init_heap(DRM_IOCTL_ARGS);
127extern int i915_mem_destroy_heap(DRM_IOCTL_ARGS);
126extern void i915_mem_takedown(struct mem_block **heap); 128extern void i915_mem_takedown(struct mem_block **heap);
127extern void i915_mem_release(drm_device_t * dev, 129extern void i915_mem_release(drm_device_t * dev,
128 DRMFILE filp, struct mem_block *heap); 130 DRMFILE filp, struct mem_block *heap);
diff --git a/drivers/char/drm/i915_mem.c b/drivers/char/drm/i915_mem.c
index ba87ff17ff64..52c67324df58 100644
--- a/drivers/char/drm/i915_mem.c
+++ b/drivers/char/drm/i915_mem.c
@@ -365,3 +365,34 @@ int i915_mem_init_heap(DRM_IOCTL_ARGS)
365 365
366 return init_heap(heap, initheap.start, initheap.size); 366 return init_heap(heap, initheap.start, initheap.size);
367} 367}
368
369int i915_mem_destroy_heap( DRM_IOCTL_ARGS )
370{
371 DRM_DEVICE;
372 drm_i915_private_t *dev_priv = dev->dev_private;
373 drm_i915_mem_destroy_heap_t destroyheap;
374 struct mem_block **heap;
375
376 if ( !dev_priv ) {
377 DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
378 return DRM_ERR(EINVAL);
379 }
380
381 DRM_COPY_FROM_USER_IOCTL( destroyheap, (drm_i915_mem_destroy_heap_t *)data,
382 sizeof(destroyheap) );
383
384 heap = get_heap( dev_priv, destroyheap.region );
385 if (!heap) {
386 DRM_ERROR("get_heap failed");
387 return DRM_ERR(EFAULT);
388 }
389
390 if (!*heap) {
391 DRM_ERROR("heap not initialized?");
392 return DRM_ERR(EFAULT);
393 }
394
395 i915_mem_takedown( heap );
396 return 0;
397}
398
diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c
index 915665c7fe7c..9bb8ae0c1c27 100644
--- a/drivers/char/drm/radeon_cp.c
+++ b/drivers/char/drm/radeon_cp.c
@@ -1640,7 +1640,7 @@ static int radeon_do_cleanup_cp(drm_device_t * dev)
1640 if (dev_priv->gart_info.gart_table_location == DRM_ATI_GART_FB) 1640 if (dev_priv->gart_info.gart_table_location == DRM_ATI_GART_FB)
1641 { 1641 {
1642 drm_core_ioremapfree(&dev_priv->gart_info.mapping, dev); 1642 drm_core_ioremapfree(&dev_priv->gart_info.mapping, dev);
1643 dev_priv->gart_info.addr = 0; 1643 dev_priv->gart_info.addr = NULL;
1644 } 1644 }
1645 } 1645 }
1646 /* only clear to the start of flags */ 1646 /* only clear to the start of flags */
diff --git a/drivers/char/drm/savage_bci.c b/drivers/char/drm/savage_bci.c
index 0d426deeefec..59c7520bf9a2 100644
--- a/drivers/char/drm/savage_bci.c
+++ b/drivers/char/drm/savage_bci.c
@@ -32,6 +32,8 @@
32#define SAVAGE_EVENT_USEC_TIMEOUT 5000000 /* 5s */ 32#define SAVAGE_EVENT_USEC_TIMEOUT 5000000 /* 5s */
33#define SAVAGE_FREELIST_DEBUG 0 33#define SAVAGE_FREELIST_DEBUG 0
34 34
35static int savage_do_cleanup_bci(drm_device_t *dev);
36
35static int 37static int
36savage_bci_wait_fifo_shadow(drm_savage_private_t * dev_priv, unsigned int n) 38savage_bci_wait_fifo_shadow(drm_savage_private_t * dev_priv, unsigned int n)
37{ 39{
@@ -895,7 +897,7 @@ static int savage_do_init_bci(drm_device_t * dev, drm_savage_init_t * init)
895 return 0; 897 return 0;
896} 898}
897 899
898int savage_do_cleanup_bci(drm_device_t * dev) 900static int savage_do_cleanup_bci(drm_device_t * dev)
899{ 901{
900 drm_savage_private_t *dev_priv = dev->dev_private; 902 drm_savage_private_t *dev_priv = dev->dev_private;
901 903
diff --git a/drivers/char/drm/savage_drv.h b/drivers/char/drm/savage_drv.h
index dd46cb85439c..8f04b3d82292 100644
--- a/drivers/char/drm/savage_drv.h
+++ b/drivers/char/drm/savage_drv.h
@@ -212,7 +212,6 @@ extern int savage_driver_load(drm_device_t *dev, unsigned long chipset);
212extern int savage_driver_firstopen(drm_device_t *dev); 212extern int savage_driver_firstopen(drm_device_t *dev);
213extern void savage_driver_lastclose(drm_device_t *dev); 213extern void savage_driver_lastclose(drm_device_t *dev);
214extern int savage_driver_unload(drm_device_t *dev); 214extern int savage_driver_unload(drm_device_t *dev);
215extern int savage_do_cleanup_bci(drm_device_t * dev);
216extern void savage_reclaim_buffers(drm_device_t * dev, DRMFILE filp); 215extern void savage_reclaim_buffers(drm_device_t * dev, DRMFILE filp);
217 216
218/* state functions */ 217/* state functions */
diff --git a/drivers/char/drm/via_dma.c b/drivers/char/drm/via_dma.c
index 593c0b8f650a..a691ae74129d 100644
--- a/drivers/char/drm/via_dma.c
+++ b/drivers/char/drm/via_dma.c
@@ -222,7 +222,7 @@ static int via_initialize(drm_device_t * dev,
222 return 0; 222 return 0;
223} 223}
224 224
225int via_dma_init(DRM_IOCTL_ARGS) 225static int via_dma_init(DRM_IOCTL_ARGS)
226{ 226{
227 DRM_DEVICE; 227 DRM_DEVICE;
228 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; 228 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
@@ -321,7 +321,7 @@ int via_driver_dma_quiescent(drm_device_t * dev)
321 return 0; 321 return 0;
322} 322}
323 323
324int via_flush_ioctl(DRM_IOCTL_ARGS) 324static int via_flush_ioctl(DRM_IOCTL_ARGS)
325{ 325{
326 DRM_DEVICE; 326 DRM_DEVICE;
327 327
@@ -330,7 +330,7 @@ int via_flush_ioctl(DRM_IOCTL_ARGS)
330 return via_driver_dma_quiescent(dev); 330 return via_driver_dma_quiescent(dev);
331} 331}
332 332
333int via_cmdbuffer(DRM_IOCTL_ARGS) 333static int via_cmdbuffer(DRM_IOCTL_ARGS)
334{ 334{
335 DRM_DEVICE; 335 DRM_DEVICE;
336 drm_via_cmdbuffer_t cmdbuf; 336 drm_via_cmdbuffer_t cmdbuf;
@@ -375,7 +375,7 @@ static int via_dispatch_pci_cmdbuffer(drm_device_t * dev,
375 return ret; 375 return ret;
376} 376}
377 377
378int via_pci_cmdbuffer(DRM_IOCTL_ARGS) 378static int via_pci_cmdbuffer(DRM_IOCTL_ARGS)
379{ 379{
380 DRM_DEVICE; 380 DRM_DEVICE;
381 drm_via_cmdbuffer_t cmdbuf; 381 drm_via_cmdbuffer_t cmdbuf;
@@ -665,7 +665,7 @@ static void via_cmdbuf_reset(drm_via_private_t * dev_priv)
665 * User interface to the space and lag functions. 665 * User interface to the space and lag functions.
666 */ 666 */
667 667
668int via_cmdbuf_size(DRM_IOCTL_ARGS) 668static int via_cmdbuf_size(DRM_IOCTL_ARGS)
669{ 669{
670 DRM_DEVICE; 670 DRM_DEVICE;
671 drm_via_cmdbuf_size_t d_siz; 671 drm_via_cmdbuf_size_t d_siz;
diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c
index 9d5e027dae0e..b7f17457b424 100644
--- a/drivers/char/drm/via_dmablit.c
+++ b/drivers/char/drm/via_dmablit.c
@@ -108,7 +108,7 @@ via_map_blit_for_device(struct pci_dev *pdev,
108 int num_desc = 0; 108 int num_desc = 0;
109 int cur_line; 109 int cur_line;
110 dma_addr_t next = 0 | VIA_DMA_DPR_EC; 110 dma_addr_t next = 0 | VIA_DMA_DPR_EC;
111 drm_via_descriptor_t *desc_ptr = 0; 111 drm_via_descriptor_t *desc_ptr = NULL;
112 112
113 if (mode == 1) 113 if (mode == 1)
114 desc_ptr = vsg->desc_pages[cur_descriptor_page]; 114 desc_ptr = vsg->desc_pages[cur_descriptor_page];
@@ -167,7 +167,7 @@ via_map_blit_for_device(struct pci_dev *pdev,
167 */ 167 */
168 168
169 169
170void 170static void
171via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg) 171via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg)
172{ 172{
173 struct page *page; 173 struct page *page;
@@ -581,7 +581,7 @@ via_build_sg_info(drm_device_t *dev, drm_via_sg_info_t *vsg, drm_via_dmablit_t *
581 int ret = 0; 581 int ret = 0;
582 582
583 vsg->direction = (draw) ? DMA_TO_DEVICE : DMA_FROM_DEVICE; 583 vsg->direction = (draw) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
584 vsg->bounce_buffer = 0; 584 vsg->bounce_buffer = NULL;
585 585
586 vsg->state = dr_via_sg_init; 586 vsg->state = dr_via_sg_init;
587 587
diff --git a/drivers/char/drm/via_drv.h b/drivers/char/drm/via_drv.h
index aad4f99f5405..52bcc7b1ba45 100644
--- a/drivers/char/drm/via_drv.h
+++ b/drivers/char/drm/via_drv.h
@@ -110,11 +110,6 @@ extern int via_mem_free(DRM_IOCTL_ARGS);
110extern int via_agp_init(DRM_IOCTL_ARGS); 110extern int via_agp_init(DRM_IOCTL_ARGS);
111extern int via_map_init(DRM_IOCTL_ARGS); 111extern int via_map_init(DRM_IOCTL_ARGS);
112extern int via_decoder_futex(DRM_IOCTL_ARGS); 112extern int via_decoder_futex(DRM_IOCTL_ARGS);
113extern int via_dma_init(DRM_IOCTL_ARGS);
114extern int via_cmdbuffer(DRM_IOCTL_ARGS);
115extern int via_flush_ioctl(DRM_IOCTL_ARGS);
116extern int via_pci_cmdbuffer(DRM_IOCTL_ARGS);
117extern int via_cmdbuf_size(DRM_IOCTL_ARGS);
118extern int via_wait_irq(DRM_IOCTL_ARGS); 113extern int via_wait_irq(DRM_IOCTL_ARGS);
119extern int via_dma_blit_sync( DRM_IOCTL_ARGS ); 114extern int via_dma_blit_sync( DRM_IOCTL_ARGS );
120extern int via_dma_blit( DRM_IOCTL_ARGS ); 115extern int via_dma_blit( DRM_IOCTL_ARGS );
@@ -139,8 +134,6 @@ extern int via_driver_dma_quiescent(drm_device_t * dev);
139extern void via_init_futex(drm_via_private_t * dev_priv); 134extern void via_init_futex(drm_via_private_t * dev_priv);
140extern void via_cleanup_futex(drm_via_private_t * dev_priv); 135extern void via_cleanup_futex(drm_via_private_t * dev_priv);
141extern void via_release_futex(drm_via_private_t * dev_priv, int context); 136extern void via_release_futex(drm_via_private_t * dev_priv, int context);
142extern int via_driver_irq_wait(drm_device_t * dev, unsigned int irq,
143 int force_sequence, unsigned int *sequence);
144 137
145extern void via_dmablit_handler(drm_device_t *dev, int engine, int from_irq); 138extern void via_dmablit_handler(drm_device_t *dev, int engine, int from_irq);
146extern void via_init_dmablit(drm_device_t *dev); 139extern void via_init_dmablit(drm_device_t *dev);
diff --git a/drivers/char/drm/via_irq.c b/drivers/char/drm/via_irq.c
index 56d7e3daea12..6152415644e9 100644
--- a/drivers/char/drm/via_irq.c
+++ b/drivers/char/drm/via_irq.c
@@ -190,7 +190,7 @@ int via_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence)
190 return ret; 190 return ret;
191} 191}
192 192
193int 193static int
194via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence, 194via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence,
195 unsigned int *sequence) 195 unsigned int *sequence)
196{ 196{
diff --git a/drivers/char/esp.c b/drivers/char/esp.c
index 3f3ac039f4d9..57539d8f9f7c 100644
--- a/drivers/char/esp.c
+++ b/drivers/char/esp.c
@@ -359,7 +359,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)
359 } 359 }
360 } 360 }
361 361
362 schedule_delayed_work(&tty->buf.work, 1); 362 tty_schedule_flip(tty);
363 363
364 info->stat_flags &= ~ESP_STAT_RX_TIMEOUT; 364 info->stat_flags &= ~ESP_STAT_RX_TIMEOUT;
365 release_pio_buffer(pio_buf); 365 release_pio_buffer(pio_buf);
@@ -426,7 +426,7 @@ static inline void receive_chars_dma_done(struct esp_struct *info,
426 } 426 }
427 tty_insert_flip_char(tty, dma_buffer[num_bytes - 1], statflag); 427 tty_insert_flip_char(tty, dma_buffer[num_bytes - 1], statflag);
428 } 428 }
429 schedule_delayed_work(&tty->buf.work, 1); 429 tty_schedule_flip(tty);
430 } 430 }
431 431
432 if (dma_bytes != num_bytes) { 432 if (dma_bytes != num_bytes) {
diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c
index 40a67c86420c..ac626418b329 100644
--- a/drivers/char/hangcheck-timer.c
+++ b/drivers/char/hangcheck-timer.c
@@ -117,12 +117,9 @@ __setup("hcheck_reboot", hangcheck_parse_reboot);
117__setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks); 117__setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks);
118#endif /* not MODULE */ 118#endif /* not MODULE */
119 119
120#if defined(CONFIG_X86) 120#if defined(CONFIG_X86) || defined(CONFIG_S390)
121# define HAVE_MONOTONIC 121# define HAVE_MONOTONIC
122# define TIMER_FREQ 1000000000ULL 122# define TIMER_FREQ 1000000000ULL
123#elif defined(CONFIG_S390)
124/* FA240000 is 1 Second in the IBM time universe (Page 4-38 Principles of Op for zSeries */
125# define TIMER_FREQ 0xFA240000ULL
126#elif defined(CONFIG_IA64) 123#elif defined(CONFIG_IA64)
127# define TIMER_FREQ ((unsigned long long)local_cpu_data->itc_freq) 124# define TIMER_FREQ ((unsigned long long)local_cpu_data->itc_freq)
128#elif defined(CONFIG_PPC64) 125#elif defined(CONFIG_PPC64)
@@ -134,12 +131,7 @@ extern unsigned long long monotonic_clock(void);
134#else 131#else
135static inline unsigned long long monotonic_clock(void) 132static inline unsigned long long monotonic_clock(void)
136{ 133{
137# ifdef __s390__
138 /* returns the TOD. see 4-38 Principles of Op of zSeries */
139 return get_clock();
140# else
141 return get_cycles(); 134 return get_cycles();
142# endif /* __s390__ */
143} 135}
144#endif /* HAVE_MONOTONIC */ 136#endif /* HAVE_MONOTONIC */
145 137
@@ -188,8 +180,6 @@ static int __init hangcheck_init(void)
188 VERSION_STR, hangcheck_tick, hangcheck_margin); 180 VERSION_STR, hangcheck_tick, hangcheck_margin);
189#if defined (HAVE_MONOTONIC) 181#if defined (HAVE_MONOTONIC)
190 printk("Hangcheck: Using monotonic_clock().\n"); 182 printk("Hangcheck: Using monotonic_clock().\n");
191#elif defined(__s390__)
192 printk("Hangcheck: Using TOD.\n");
193#else 183#else
194 printk("Hangcheck: Using get_cycles().\n"); 184 printk("Hangcheck: Using get_cycles().\n");
195#endif /* HAVE_MONOTONIC */ 185#endif /* HAVE_MONOTONIC */
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 3808d9572619..66a2fee06eb9 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -927,9 +927,9 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
927 if (ACPI_SUCCESS(status)) { 927 if (ACPI_SUCCESS(status)) {
928 unsigned long size; 928 unsigned long size;
929 929
930 size = addr.max_address_range - addr.min_address_range + 1; 930 size = addr.maximum - addr.minimum + 1;
931 hdp->hd_phys_address = addr.min_address_range; 931 hdp->hd_phys_address = addr.minimum;
932 hdp->hd_address = ioremap(addr.min_address_range, size); 932 hdp->hd_address = ioremap(addr.minimum, size);
933 933
934 if (hpet_is_known(hdp)) { 934 if (hpet_is_known(hdp)) {
935 printk(KERN_DEBUG "%s: 0x%lx is busy\n", 935 printk(KERN_DEBUG "%s: 0x%lx is busy\n",
@@ -937,15 +937,15 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
937 iounmap(hdp->hd_address); 937 iounmap(hdp->hd_address);
938 return -EBUSY; 938 return -EBUSY;
939 } 939 }
940 } else if (res->id == ACPI_RSTYPE_FIXED_MEM32) { 940 } else if (res->type == ACPI_RESOURCE_TYPE_FIXED_MEMORY32) {
941 struct acpi_resource_fixed_mem32 *fixmem32; 941 struct acpi_resource_fixed_memory32 *fixmem32;
942 942
943 fixmem32 = &res->data.fixed_memory32; 943 fixmem32 = &res->data.fixed_memory32;
944 if (!fixmem32) 944 if (!fixmem32)
945 return -EINVAL; 945 return -EINVAL;
946 946
947 hdp->hd_phys_address = fixmem32->range_base_address; 947 hdp->hd_phys_address = fixmem32->address;
948 hdp->hd_address = ioremap(fixmem32->range_base_address, 948 hdp->hd_address = ioremap(fixmem32->address,
949 HPET_RANGE_SIZE); 949 HPET_RANGE_SIZE);
950 950
951 if (hpet_is_known(hdp)) { 951 if (hpet_is_known(hdp)) {
@@ -954,20 +954,20 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
954 iounmap(hdp->hd_address); 954 iounmap(hdp->hd_address);
955 return -EBUSY; 955 return -EBUSY;
956 } 956 }
957 } else if (res->id == ACPI_RSTYPE_EXT_IRQ) { 957 } else if (res->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ) {
958 struct acpi_resource_ext_irq *irqp; 958 struct acpi_resource_extended_irq *irqp;
959 int i; 959 int i;
960 960
961 irqp = &res->data.extended_irq; 961 irqp = &res->data.extended_irq;
962 962
963 if (irqp->number_of_interrupts > 0) { 963 if (irqp->interrupt_count > 0) {
964 hdp->hd_nirqs = irqp->number_of_interrupts; 964 hdp->hd_nirqs = irqp->interrupt_count;
965 965
966 for (i = 0; i < hdp->hd_nirqs; i++) { 966 for (i = 0; i < hdp->hd_nirqs; i++) {
967 int rc = 967 int rc =
968 acpi_register_gsi(irqp->interrupts[i], 968 acpi_register_gsi(irqp->interrupts[i],
969 irqp->edge_level, 969 irqp->triggering,
970 irqp->active_high_low); 970 irqp->polarity);
971 if (rc < 0) 971 if (rc < 0)
972 return AE_ERROR; 972 return AE_ERROR;
973 hdp->hd_irq[i] = rc; 973 hdp->hd_irq[i] = rc;
diff --git a/drivers/char/ip2/i2cmd.c b/drivers/char/ip2/i2cmd.c
index cb8f4198e9a3..e7af647800b6 100644
--- a/drivers/char/ip2/i2cmd.c
+++ b/drivers/char/ip2/i2cmd.c
@@ -139,7 +139,6 @@ static UCHAR ct79[] = { 2, BYP, 0x4F,0 }; // XMIT_NOW
139//static UCHAR ct86[]={ 2, BTH, 0x56,0 }; // RCV_ENABLE 139//static UCHAR ct86[]={ 2, BTH, 0x56,0 }; // RCV_ENABLE
140static UCHAR ct87[] = { 1, BYP, 0x57 }; // HW_TEST 140static UCHAR ct87[] = { 1, BYP, 0x57 }; // HW_TEST
141//static UCHAR ct88[]={ 3, BTH, 0x58,0,0 }; // RCV_THRESHOLD 141//static UCHAR ct88[]={ 3, BTH, 0x58,0,0 }; // RCV_THRESHOLD
142static UCHAR ct89[]={ 1, BYP, 0x59 }; // DSS_NOW
143//static UCHAR ct90[]={ 3, BYP, 0x5A,0,0 }; // Set SILO 142//static UCHAR ct90[]={ 3, BYP, 0x5A,0,0 }; // Set SILO
144//static UCHAR ct91[]={ 2, BYP, 0x5B,0 }; // timed break 143//static UCHAR ct91[]={ 2, BYP, 0x5B,0 }; // timed break
145 144
diff --git a/drivers/char/ip2main.c b/drivers/char/ip2main.c
index 56e93a5a1e24..48fcfba37bfa 100644
--- a/drivers/char/ip2main.c
+++ b/drivers/char/ip2main.c
@@ -2906,65 +2906,16 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg )
2906 rc = -EINVAL; 2906 rc = -EINVAL;
2907 break; 2907 break;
2908 case 3: // Trace device 2908 case 3: // Trace device
2909 if ( cmd == 1 ) { 2909 /*
2910 rc = put_user(iiSendPendingMail, pIndex++ ); 2910 * akpm: This used to write a whole bunch of function addresses
2911 rc = put_user(i2InitChannels, pIndex++ ); 2911 * to userspace, which generated lots of put_user() warnings.
2912 rc = put_user(i2QueueNeeds, pIndex++ ); 2912 * I killed it all. Just return "success" and don't do
2913 rc = put_user(i2QueueCommands, pIndex++ ); 2913 * anything.
2914 rc = put_user(i2GetStatus, pIndex++ ); 2914 */
2915 rc = put_user(i2Input, pIndex++ ); 2915 if (cmd == 1)
2916 rc = put_user(i2InputFlush, pIndex++ ); 2916 rc = 0;
2917 rc = put_user(i2Output, pIndex++ ); 2917 else
2918 rc = put_user(i2FlushOutput, pIndex++ );
2919 rc = put_user(i2DrainWakeup, pIndex++ );
2920 rc = put_user(i2DrainOutput, pIndex++ );
2921 rc = put_user(i2OutputFree, pIndex++ );
2922 rc = put_user(i2StripFifo, pIndex++ );
2923 rc = put_user(i2StuffFifoBypass, pIndex++ );
2924 rc = put_user(i2StuffFifoFlow, pIndex++ );
2925 rc = put_user(i2StuffFifoInline, pIndex++ );
2926 rc = put_user(i2ServiceBoard, pIndex++ );
2927 rc = put_user(serviceOutgoingFifo, pIndex++ );
2928 // rc = put_user(ip2_init, pIndex++ );
2929 rc = put_user(ip2_init_board, pIndex++ );
2930 rc = put_user(find_eisa_board, pIndex++ );
2931 rc = put_user(set_irq, pIndex++ );
2932 rc = put_user(ip2_interrupt, pIndex++ );
2933 rc = put_user(ip2_poll, pIndex++ );
2934 rc = put_user(service_all_boards, pIndex++ );
2935 rc = put_user(do_input, pIndex++ );
2936 rc = put_user(do_status, pIndex++ );
2937#ifndef IP2DEBUG_OPEN
2938 rc = put_user(0, pIndex++ );
2939#else
2940 rc = put_user(open_sanity_check, pIndex++ );
2941#endif
2942 rc = put_user(ip2_open, pIndex++ );
2943 rc = put_user(ip2_close, pIndex++ );
2944 rc = put_user(ip2_hangup, pIndex++ );
2945 rc = put_user(ip2_write, pIndex++ );
2946 rc = put_user(ip2_putchar, pIndex++ );
2947 rc = put_user(ip2_flush_chars, pIndex++ );
2948 rc = put_user(ip2_write_room, pIndex++ );
2949 rc = put_user(ip2_chars_in_buf, pIndex++ );
2950 rc = put_user(ip2_flush_buffer, pIndex++ );
2951
2952 //rc = put_user(ip2_wait_until_sent, pIndex++ );
2953 rc = put_user(0, pIndex++ );
2954
2955 rc = put_user(ip2_throttle, pIndex++ );
2956 rc = put_user(ip2_unthrottle, pIndex++ );
2957 rc = put_user(ip2_ioctl, pIndex++ );
2958 rc = put_user(0, pIndex++ );
2959 rc = put_user(get_serial_info, pIndex++ );
2960 rc = put_user(set_serial_info, pIndex++ );
2961 rc = put_user(ip2_set_termios, pIndex++ );
2962 rc = put_user(ip2_set_line_discipline, pIndex++ );
2963 rc = put_user(set_params, pIndex++ );
2964 } else {
2965 rc = -EINVAL; 2918 rc = -EINVAL;
2966 }
2967
2968 break; 2919 break;
2969 2920
2970 default: 2921 default:
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 0097f06fa67b..d745004281d0 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -481,7 +481,7 @@ int ipmi_validate_addr(struct ipmi_addr *addr, int len)
481 } 481 }
482 482
483 if ((addr->channel == IPMI_BMC_CHANNEL) 483 if ((addr->channel == IPMI_BMC_CHANNEL)
484 || (addr->channel >= IPMI_NUM_CHANNELS) 484 || (addr->channel >= IPMI_MAX_CHANNELS)
485 || (addr->channel < 0)) 485 || (addr->channel < 0))
486 return -EINVAL; 486 return -EINVAL;
487 487
@@ -1321,7 +1321,7 @@ static int i_ipmi_request(ipmi_user_t user,
1321 unsigned char ipmb_seq; 1321 unsigned char ipmb_seq;
1322 long seqid; 1322 long seqid;
1323 1323
1324 if (addr->channel >= IPMI_NUM_CHANNELS) { 1324 if (addr->channel >= IPMI_MAX_CHANNELS) {
1325 spin_lock_irqsave(&intf->counter_lock, flags); 1325 spin_lock_irqsave(&intf->counter_lock, flags);
1326 intf->sent_invalid_commands++; 1326 intf->sent_invalid_commands++;
1327 spin_unlock_irqrestore(&intf->counter_lock, flags); 1327 spin_unlock_irqrestore(&intf->counter_lock, flags);
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index c67ef3e47ad5..e59b638766ef 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -1270,36 +1270,36 @@ static int try_init_port(int intf_num, struct smi_info **new_info)
1270 return 0; 1270 return 0;
1271} 1271}
1272 1272
1273static unsigned char mem_inb(struct si_sm_io *io, unsigned int offset) 1273static unsigned char intf_mem_inb(struct si_sm_io *io, unsigned int offset)
1274{ 1274{
1275 return readb((io->addr)+(offset * io->regspacing)); 1275 return readb((io->addr)+(offset * io->regspacing));
1276} 1276}
1277 1277
1278static void mem_outb(struct si_sm_io *io, unsigned int offset, 1278static void intf_mem_outb(struct si_sm_io *io, unsigned int offset,
1279 unsigned char b) 1279 unsigned char b)
1280{ 1280{
1281 writeb(b, (io->addr)+(offset * io->regspacing)); 1281 writeb(b, (io->addr)+(offset * io->regspacing));
1282} 1282}
1283 1283
1284static unsigned char mem_inw(struct si_sm_io *io, unsigned int offset) 1284static unsigned char intf_mem_inw(struct si_sm_io *io, unsigned int offset)
1285{ 1285{
1286 return (readw((io->addr)+(offset * io->regspacing)) >> io->regshift) 1286 return (readw((io->addr)+(offset * io->regspacing)) >> io->regshift)
1287 && 0xff; 1287 && 0xff;
1288} 1288}
1289 1289
1290static void mem_outw(struct si_sm_io *io, unsigned int offset, 1290static void intf_mem_outw(struct si_sm_io *io, unsigned int offset,
1291 unsigned char b) 1291 unsigned char b)
1292{ 1292{
1293 writeb(b << io->regshift, (io->addr)+(offset * io->regspacing)); 1293 writeb(b << io->regshift, (io->addr)+(offset * io->regspacing));
1294} 1294}
1295 1295
1296static unsigned char mem_inl(struct si_sm_io *io, unsigned int offset) 1296static unsigned char intf_mem_inl(struct si_sm_io *io, unsigned int offset)
1297{ 1297{
1298 return (readl((io->addr)+(offset * io->regspacing)) >> io->regshift) 1298 return (readl((io->addr)+(offset * io->regspacing)) >> io->regshift)
1299 && 0xff; 1299 && 0xff;
1300} 1300}
1301 1301
1302static void mem_outl(struct si_sm_io *io, unsigned int offset, 1302static void intf_mem_outl(struct si_sm_io *io, unsigned int offset,
1303 unsigned char b) 1303 unsigned char b)
1304{ 1304{
1305 writel(b << io->regshift, (io->addr)+(offset * io->regspacing)); 1305 writel(b << io->regshift, (io->addr)+(offset * io->regspacing));
@@ -1349,16 +1349,16 @@ static int mem_setup(struct smi_info *info)
1349 upon the register size. */ 1349 upon the register size. */
1350 switch (info->io.regsize) { 1350 switch (info->io.regsize) {
1351 case 1: 1351 case 1:
1352 info->io.inputb = mem_inb; 1352 info->io.inputb = intf_mem_inb;
1353 info->io.outputb = mem_outb; 1353 info->io.outputb = intf_mem_outb;
1354 break; 1354 break;
1355 case 2: 1355 case 2:
1356 info->io.inputb = mem_inw; 1356 info->io.inputb = intf_mem_inw;
1357 info->io.outputb = mem_outw; 1357 info->io.outputb = intf_mem_outw;
1358 break; 1358 break;
1359 case 4: 1359 case 4:
1360 info->io.inputb = mem_inl; 1360 info->io.inputb = intf_mem_inl;
1361 info->io.outputb = mem_outl; 1361 info->io.outputb = intf_mem_outl;
1362 break; 1362 break;
1363#ifdef readq 1363#ifdef readq
1364 case 8: 1364 case 8:
@@ -1580,11 +1580,6 @@ static int try_init_acpi(int intf_num, struct smi_info **new_info)
1580 if (! is_new_interface(-1, addr_space, spmi->addr.address)) 1580 if (! is_new_interface(-1, addr_space, spmi->addr.address))
1581 return -ENODEV; 1581 return -ENODEV;
1582 1582
1583 if (! spmi->addr.register_bit_width) {
1584 acpi_failure = 1;
1585 return -ENODEV;
1586 }
1587
1588 /* Figure out the interface type. */ 1583 /* Figure out the interface type. */
1589 switch (spmi->InterfaceType) 1584 switch (spmi->InterfaceType)
1590 { 1585 {
@@ -1634,9 +1629,6 @@ static int try_init_acpi(int intf_num, struct smi_info **new_info)
1634 regspacings[intf_num] = spmi->addr.register_bit_width / 8; 1629 regspacings[intf_num] = spmi->addr.register_bit_width / 8;
1635 info->io.regspacing = spmi->addr.register_bit_width / 8; 1630 info->io.regspacing = spmi->addr.register_bit_width / 8;
1636 } else { 1631 } else {
1637 /* Some broken systems get this wrong and set the value
1638 * to zero. Assume it is the default spacing. If that
1639 * is wrong, too bad, the vendor should fix the tables. */
1640 regspacings[intf_num] = DEFAULT_REGSPACING; 1632 regspacings[intf_num] = DEFAULT_REGSPACING;
1641 info->io.regspacing = DEFAULT_REGSPACING; 1633 info->io.regspacing = DEFAULT_REGSPACING;
1642 } 1634 }
diff --git a/drivers/char/rio/cirrus.h b/drivers/char/rio/cirrus.h
index 217ff09f2fa1..89bd94eb45be 100644
--- a/drivers/char/rio/cirrus.h
+++ b/drivers/char/rio/cirrus.h
@@ -40,148 +40,6 @@
40#endif 40#endif
41#define _cirrus_h 1 41#define _cirrus_h 1
42 42
43#ifdef RTA
44#define TO_UART RX
45#define TO_DRIVER TX
46#endif
47
48#ifdef HOST
49#define TO_UART TX
50#define TO_DRIVER RX
51#endif
52#ifdef RTA
53/* Miscellaneous defines for CIRRUS addresses and related logic for
54 interrupts etc.
55*/
56#define MAP(a) ((short *)(cirrus_base + (a)))
57#define outp(a,b) (*MAP (a) =(b))
58#define inp(a) ((*MAP (a)) & 0xff)
59#define CIRRUS_FIRST (short*)0x7300
60#define CIRRUS_SECOND (short*)0x7200
61#define CIRRUS_THIRD (short*)0x7100
62#define CIRRUS_FOURTH (short*)0x7000
63#define PORTS_ON_CIRRUS 4
64#define CIRRUS_FIFO_SIZE 12
65#define SPACE 0x20
66#define TAB 0x09
67#define LINE_FEED 0x0a
68#define CARRIAGE_RETURN 0x0d
69#define BACKSPACE 0x08
70#define SPACES_IN_TABS 8
71#define SEND_ESCAPE 0x00
72#define START_BREAK 0x81
73#define TIMER_TICK 0x82
74#define STOP_BREAK 0x83
75#define BASE(a) ((a) < 4 ? (short*)CIRRUS_FIRST : ((a) < 8 ? (short *)CIRRUS_SECOND : ((a) < 12 ? (short*)CIRRUS_THIRD : (short *)CIRRUS_FOURTH)))
76#define txack1 ((short *)0x7104)
77#define rxack1 ((short *)0x7102)
78#define mdack1 ((short *)0x7106)
79#define txack2 ((short *)0x7006)
80#define rxack2 ((short *)0x7004)
81#define mdack2 ((short *)0x7100)
82#define int_latch ((short *) 0x7800)
83#define int_status ((short *) 0x7c00)
84#define tx1_pending 0x20
85#define rx1_pending 0x10
86#define md1_pending 0x40
87#define tx2_pending 0x02
88#define rx2_pending 0x01
89#define md2_pending 0x40
90#define module1_bits 0x07
91#define module1_modern 0x08
92#define module2_bits 0x70
93#define module2_modern 0x80
94#define module_blank 0xf
95#define rs232_d25 0x0
96#define rs232_rj45 0x1
97#define rs422_d25 0x3
98#define parallel 0x5
99
100#define CLK0 0x00
101#define CLK1 0x01
102#define CLK2 0x02
103#define CLK3 0x03
104#define CLK4 0x04
105
106#define CIRRUS_REVC 0x42
107#define CIRRUS_REVE 0x44
108
109#define TURNON 1
110#define TURNOFF 0
111
112/* The list of CIRRUS registers.
113 NB. These registers are relative values on 8 bit boundaries whereas
114 on the RTA's the CIRRUS registers are on word boundaries. Use pointer
115 arithmetic (short *) to obtain the real addresses required */
116#define ccr 0x05 /* Channel Command Register */
117#define ier 0x06 /* Interrupt Enable Register */
118#define cor1 0x08 /* Channel Option Register 1 */
119#define cor2 0x09 /* Channel Option Register 2 */
120#define cor3 0x0a /* Channel Option Register 3 */
121#define cor4 0x1e /* Channel Option Register 4 */
122#define cor5 0x1f /* Channel Option Register 5 */
123
124#define ccsr 0x0b /* Channel Control Status Register */
125#define rdcr 0x0e /* Receive Data Count Register */
126#define tdcr 0x12 /* Transmit Data Count Register */
127#define mcor1 0x15 /* Modem Change Option Register 1 */
128#define mcor2 0x16 /* Modem Change Option Regsiter 2 */
129
130#define livr 0x18 /* Local Interrupt Vector Register */
131#define schr1 0x1a /* Special Character Register 1 */
132#define schr2 0x1b /* Special Character Register 2 */
133#define schr3 0x1c /* Special Character Register 3 */
134#define schr4 0x1d /* Special Character Register 4 */
135
136#define rtr 0x20 /* Receive Timer Register */
137#define rtpr 0x21 /* Receive Timeout Period Register */
138#define lnc 0x24 /* Lnext character */
139
140#define rivr 0x43 /* Receive Interrupt Vector Register */
141#define tivr 0x42 /* Transmit Interrupt Vector Register */
142#define mivr 0x41 /* Modem Interrupt Vector Register */
143#define gfrcr 0x40 /* Global Firmware Revision code Reg */
144#define ricr 0x44 /* Receive Interrupting Channel Reg */
145#define ticr 0x45 /* Transmit Interrupting Channel Reg */
146#define micr 0x46 /* Modem Interrupting Channel Register */
147
148#define gcr 0x4b /* Global configuration register */
149#define misr 0x4c /* Modem interrupt status register */
150
151#define rbusr 0x59
152#define tbusr 0x5a
153#define mbusr 0x5b
154
155#define eoir 0x60 /* End Of Interrupt Register */
156#define rdsr 0x62 /* Receive Data / Status Register */
157#define tdr 0x63 /* Transmit Data Register */
158#define svrr 0x67 /* Service Request Register */
159
160#define car 0x68 /* Channel Access Register */
161#define mir 0x69 /* Modem Interrupt Register */
162#define tir 0x6a /* Transmit Interrupt Register */
163#define rir 0x6b /* Receive Interrupt Register */
164#define msvr1 0x6c /* Modem Signal Value Register 1 */
165#define msvr2 0x6d /* Modem Signal Value Register 2 */
166#define psvr 0x6f /* Printer Signal Value Register */
167
168#define tbpr 0x72 /* Transmit Baud Rate Period Register */
169#define tcor 0x76 /* Transmit Clock Option Register */
170
171#define rbpr 0x78 /* Receive Baud Rate Period Register */
172#define rber 0x7a /* Receive Baud Rate Extension Register */
173#define rcor 0x7c /* Receive Clock Option Register */
174#define ppr 0x7e /* Prescalar Period Register */
175
176/* Misc registers used for forcing the 1400 out of its reset woes */
177#define airl 0x6d
178#define airm 0x6e
179#define airh 0x6f
180#define btcr 0x66
181#define mtcr 0x6c
182#define tber 0x74
183
184#endif /* #ifdef RTA */
185 43
186 44
187/* Bit fields for particular registers */ 45/* Bit fields for particular registers */
diff --git a/drivers/char/rio/defaults.h b/drivers/char/rio/defaults.h
index 5b600c32ac02..d55c2f6a9877 100644
--- a/drivers/char/rio/defaults.h
+++ b/drivers/char/rio/defaults.h
@@ -45,13 +45,6 @@ static char *_rio_defaults_h_sccs = "@(#)defaults.h 1.1";
45#define MILLISECOND (int) (1000/64) /* 15.625 low ticks */ 45#define MILLISECOND (int) (1000/64) /* 15.625 low ticks */
46#define SECOND (int) 15625 /* Low priority ticks */ 46#define SECOND (int) 15625 /* Low priority ticks */
47 47
48#ifdef RTA
49#define RX_LIMIT (ushort) 3
50#endif
51#ifdef HOST
52#define RX_LIMIT (ushort) 1
53#endif
54
55#define LINK_TIMEOUT (int) (POLL_PERIOD / 2) 48#define LINK_TIMEOUT (int) (POLL_PERIOD / 2)
56 49
57 50
diff --git a/drivers/char/rio/link.h b/drivers/char/rio/link.h
index bfba5b0c033e..48d68ca7f825 100644
--- a/drivers/char/rio/link.h
+++ b/drivers/char/rio/link.h
@@ -102,30 +102,14 @@
102/* 102/*
103** LED stuff 103** LED stuff
104*/ 104*/
105#if defined(RTA)
106#define LED_OFF ((ushort) 0) /* LED off */
107#define LED_RED ((ushort) 1) /* LED Red */
108#define LED_GREEN ((ushort) 2) /* LED Green */
109#define LED_ORANGE ((ushort) 4) /* LED Orange */
110#define LED_1TO8_OPEN ((ushort) 1) /* Port 1->8 LED on */
111#define LED_9TO16_OPEN ((ushort) 2) /* Port 9->16 LED on */
112#define LED_SET_COLOUR(colour) (link->led = (colour))
113#define LED_OR_COLOUR(colour) (link->led |= (colour))
114#define LED_TIMEOUT(time) (link->led_timeout = RioTimePlus(RioTime(),(time)))
115#else
116#define LED_SET_COLOUR(colour) 105#define LED_SET_COLOUR(colour)
117#define LED_OR_COLOUR(colour) 106#define LED_OR_COLOUR(colour)
118#define LED_TIMEOUT(time) 107#define LED_TIMEOUT(time)
119#endif /* RTA */
120 108
121struct LPB { 109struct LPB {
122 WORD link_number; /* Link Number */ 110 WORD link_number; /* Link Number */
123 Channel_ptr in_ch; /* Link In Channel */ 111 Channel_ptr in_ch; /* Link In Channel */
124 Channel_ptr out_ch; /* Link Out Channel */ 112 Channel_ptr out_ch; /* Link Out Channel */
125#ifdef RTA
126 uchar stat_led; /* Port open leds */
127 uchar led; /* True, light led! */
128#endif
129 BYTE attached_serial[4]; /* Attached serial number */ 113 BYTE attached_serial[4]; /* Attached serial number */
130 BYTE attached_host_serial[4]; 114 BYTE attached_host_serial[4];
131 /* Serial number of Host who 115 /* Serial number of Host who
@@ -144,30 +128,12 @@ struct LPB {
144 WORD WaitNoBoot; /* Secs to hold off booting */ 128 WORD WaitNoBoot; /* Secs to hold off booting */
145 PKT_ptr add_packet_list; /* Add packets to here */ 129 PKT_ptr add_packet_list; /* Add packets to here */
146 PKT_ptr remove_packet_list; /* Send packets from here */ 130 PKT_ptr remove_packet_list; /* Send packets from here */
147#ifdef RTA
148#ifdef DCIRRUS
149#define QBUFS_PER_REDIRECT (4 / PKTS_PER_BUFFER + 1)
150#else
151#define QBUFS_PER_REDIRECT (8 / PKTS_PER_BUFFER + 1)
152#endif
153 PKT_ptr_ptr rd_add; /* Add a new Packet here */
154 Q_BUF_ptr rd_add_qb; /* Pointer to the add Q buf */
155 PKT_ptr_ptr rd_add_st_qbb; /* Pointer to start of the Q's buf */
156 PKT_ptr_ptr rd_add_end_qbb; /* Pointer to the end of the Q's buf */
157 PKT_ptr_ptr rd_remove; /* Remove a Packet here */
158 Q_BUF_ptr rd_remove_qb; /* Pointer to the remove Q buf */
159 PKT_ptr_ptr rd_remove_st_qbb; /* Pointer to the start of the Q buf */
160 PKT_ptr_ptr rd_remove_end_qbb; /* Pointer to the end of the Q buf */
161 ushort pkts_in_q; /* Packets in queue */
162#endif
163 131
164 Channel_ptr lrt_fail_chan; /* Lrt's failure channel */ 132 Channel_ptr lrt_fail_chan; /* Lrt's failure channel */
165 Channel_ptr ltt_fail_chan; /* Ltt's failure channel */ 133 Channel_ptr ltt_fail_chan; /* Ltt's failure channel */
166 134
167#if defined (HOST) || defined (INKERNEL)
168 /* RUP structure for HOST to driver communications */ 135 /* RUP structure for HOST to driver communications */
169 struct RUP rup; 136 struct RUP rup;
170#endif
171 struct RUP link_rup; /* RUP for the link (POLL, 137 struct RUP link_rup; /* RUP for the link (POLL,
172 topology etc.) */ 138 topology etc.) */
173 WORD attached_link; /* Number of attached link */ 139 WORD attached_link; /* Number of attached link */
diff --git a/drivers/char/rio/list.h b/drivers/char/rio/list.h
index 36aad4c9cb3a..79b853140ae5 100644
--- a/drivers/char/rio/list.h
+++ b/drivers/char/rio/list.h
@@ -44,8 +44,6 @@ static char *_rio_list_h_sccs = "@(#)list.h 1.9";
44 44
45#define PKT_IN_USE 0x1 45#define PKT_IN_USE 0x1
46 46
47#ifdef INKERNEL
48
49#define ZERO_PTR (ushort) 0x8000 47#define ZERO_PTR (ushort) 0x8000
50#define CaD PortP->Caddr 48#define CaD PortP->Caddr
51 49
@@ -54,143 +52,5 @@ static char *_rio_list_h_sccs = "@(#)list.h 1.9";
54** to by the TxAdd pointer has PKT_IN_USE clear in its address. 52** to by the TxAdd pointer has PKT_IN_USE clear in its address.
55*/ 53*/
56 54
57#ifndef linux
58#if defined( MIPS ) && !defined( MIPSEISA )
59/* May the shoes of the Devil dance on your grave for creating this */
60#define can_add_transmit(PacketP,PortP) \
61 (!((uint)(PacketP = (struct PKT *)RIO_PTR(CaD,RINDW(PortP->TxAdd))) \
62 & (PKT_IN_USE<<2)))
63
64#elif defined(MIPSEISA) || defined(nx6000) || \
65 defined(drs6000) || defined(UWsparc)
66
67#define can_add_transmit(PacketP,PortP) \
68 (!((uint)(PacketP = (struct PKT *)RIO_PTR(CaD,RINDW(PortP->TxAdd))) \
69 & PKT_IN_USE))
70
71#else
72#define can_add_transmit(PacketP,PortP) \
73 (!((uint)(PacketP = (struct PKT *)RIO_PTR(CaD,*PortP->TxAdd)) \
74 & PKT_IN_USE))
75#endif
76
77/*
78** To add a packet to the queue, you set the PKT_IN_USE bit in the address,
79** and then move the TxAdd pointer along one position to point to the next
80** packet pointer. You must wrap the pointer from the end back to the start.
81*/
82#if defined(MIPS) || defined(nx6000) || defined(drs6000) || defined(UWsparc)
83# define add_transmit(PortP) \
84 WINDW(PortP->TxAdd,RINDW(PortP->TxAdd) | PKT_IN_USE);\
85 if (PortP->TxAdd == PortP->TxEnd)\
86 PortP->TxAdd = PortP->TxStart;\
87 else\
88 PortP->TxAdd++;\
89 WWORD(PortP->PhbP->tx_add , RIO_OFF(CaD,PortP->TxAdd));
90#elif defined(AIX)
91# define add_transmit(PortP) \
92 {\
93 register ushort *TxAddP = (ushort *)RIO_PTR(Cad,PortP->TxAddO);\
94 WINDW( TxAddP, RINDW( TxAddP ) | PKT_IN_USE );\
95 if (PortP->TxAddO == PortP->TxEndO )\
96 PortP->TxAddO = PortP->TxStartO;\
97 else\
98 PortP->TxAddO += sizeof(ushort);\
99 WWORD(((PHB *)RIO_PTR(Cad,PortP->PhbO))->tx_add , PortP->TxAddO );\
100 }
101#else
102# define add_transmit(PortP) \
103 *PortP->TxAdd |= PKT_IN_USE;\
104 if (PortP->TxAdd == PortP->TxEnd)\
105 PortP->TxAdd = PortP->TxStart;\
106 else\
107 PortP->TxAdd++;\
108 PortP->PhbP->tx_add = RIO_OFF(CaD,PortP->TxAdd);
109#endif
110
111/*
112** can_remove_receive( PacketP, PortP ) returns non-zero if PKT_IN_USE is set
113** for the next packet on the queue. It will also set PacketP to point to the
114** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear,
115** then can_remove_receive() returns 0.
116*/
117#if defined(MIPS) || defined(nx6000) || defined(drs6000) || defined(UWsparc)
118# define can_remove_receive(PacketP,PortP) \
119 ((RINDW(PortP->RxRemove) & PKT_IN_USE) ? \
120 (PacketP=(struct PKT *)RIO_PTR(CaD,(RINDW(PortP->RxRemove) & ~PKT_IN_USE))):0)
121#elif defined(AIX)
122# define can_remove_receive(PacketP,PortP) \
123 ((RINDW((ushort *)RIO_PTR(Cad,PortP->RxRemoveO)) & PKT_IN_USE) ? \
124 (PacketP=(struct PKT *)RIO_PTR(Cad,RINDW((ushort *)RIO_PTR(Cad,PortP->RxRemoveO)) & ~PKT_IN_USE)):0)
125#else
126# define can_remove_receive(PacketP,PortP) \
127 ((*PortP->RxRemove & PKT_IN_USE) ? \
128 (PacketP=(struct PKT *)RIO_PTR(CaD,(*PortP->RxRemove & ~PKT_IN_USE))):0)
129#endif
130
131
132/*
133** Will God see it within his heart to forgive us for this thing that
134** we have created? To remove a packet from the receive queue you clear
135** its PKT_IN_USE bit, and then bump the pointers. Once the pointers
136** get to the end, they must be wrapped back to the start.
137*/
138#if defined(MIPS) || defined(nx6000) || defined(drs6000) || defined(UWsparc)
139# define remove_receive(PortP) \
140 WINDW(PortP->RxRemove, (RINDW(PortP->RxRemove) & ~PKT_IN_USE));\
141 if (PortP->RxRemove == PortP->RxEnd)\
142 PortP->RxRemove = PortP->RxStart;\
143 else\
144 PortP->RxRemove++;\
145 WWORD(PortP->PhbP->rx_remove , RIO_OFF(CaD,PortP->RxRemove));
146#elif defined(AIX)
147# define remove_receive(PortP) \
148 {\
149 register ushort *RxRemoveP = (ushort *)RIO_PTR(Cad,PortP->RxRemoveO);\
150 WINDW( RxRemoveP, RINDW( RxRemoveP ) & ~PKT_IN_USE );\
151 if (PortP->RxRemoveO == PortP->RxEndO)\
152 PortP->RxRemoveO = PortP->RxStartO;\
153 else\
154 PortP->RxRemoveO += sizeof(ushort);\
155 WWORD(((PHB *)RIO_PTR(Cad,PortP->PhbO))->rx_remove, PortP->RxRemoveO );\
156 }
157#else
158# define remove_receive(PortP) \
159 *PortP->RxRemove &= ~PKT_IN_USE;\
160 if (PortP->RxRemove == PortP->RxEnd)\
161 PortP->RxRemove = PortP->RxStart;\
162 else\
163 PortP->RxRemove++;\
164 PortP->PhbP->rx_remove = RIO_OFF(CaD,PortP->RxRemove);
165#endif
166#endif
167
168
169#else /* !IN_KERNEL */
170
171#define ZERO_PTR NULL
172
173
174#ifdef HOST
175/* #define can_remove_transmit(pkt,phb) ((((char*)pkt = (*(char**)(phb->tx_remove))-1) || 1)) && (*phb->u3.s2.tx_remove_ptr & PKT_IN_USE)) */
176#define remove_transmit(phb) *phb->u3.s2.tx_remove_ptr &= ~(ushort)PKT_IN_USE;\
177 if (phb->tx_remove == phb->tx_end)\
178 phb->tx_remove = phb->tx_start;\
179 else\
180 phb->tx_remove++;
181#define can_add_receive(phb) !(*phb->u4.s2.rx_add_ptr & PKT_IN_USE)
182#define add_receive(pkt,phb) *phb->rx_add = pkt;\
183 *phb->u4.s2.rx_add_ptr |= PKT_IN_USE;\
184 if (phb->rx_add == phb->rx_end)\
185 phb->rx_add = phb->rx_start;\
186 else\
187 phb->rx_add++;
188#endif
189#endif
190
191#ifdef RTA
192#define splx(oldspl) if ((oldspl) == 0) spl0()
193#endif
194
195#endif /* ifndef _list.h */ 55#endif /* ifndef _list.h */
196/*********** end of file ***********/ 56/*********** end of file ***********/
diff --git a/drivers/char/rio/parmmap.h b/drivers/char/rio/parmmap.h
index fe4e00567065..e24acc1d1844 100644
--- a/drivers/char/rio/parmmap.h
+++ b/drivers/char/rio/parmmap.h
@@ -78,14 +78,9 @@ struct PARM_MAP {
78 WORD idle_count; /* Idle time counter */ 78 WORD idle_count; /* Idle time counter */
79 WORD busy_count; /* Busy counter */ 79 WORD busy_count; /* Busy counter */
80 WORD idle_control; /* Control Idle Process */ 80 WORD idle_control; /* Control Idle Process */
81#if defined(HOST) || defined(INKERNEL)
82 WORD tx_intr; /* TX interrupt pending */ 81 WORD tx_intr; /* TX interrupt pending */
83 WORD rx_intr; /* RX interrupt pending */ 82 WORD rx_intr; /* RX interrupt pending */
84 WORD rup_intr; /* RUP interrupt pending */ 83 WORD rup_intr; /* RUP interrupt pending */
85#endif
86#if defined(RTA)
87 WORD dying_count; /* Count of processes dead */
88#endif
89}; 84};
90 85
91#endif 86#endif
diff --git a/drivers/char/rio/phb.h b/drivers/char/rio/phb.h
index 3baebf8513af..2663ca0306e2 100644
--- a/drivers/char/rio/phb.h
+++ b/drivers/char/rio/phb.h
@@ -44,17 +44,6 @@
44#endif 44#endif
45 45
46 46
47 /*************************************************
48 * Set the LIMIT values.
49 ************************************************/
50#ifdef RTA
51#define RX_LIMIT (ushort) 3
52#endif
53#ifdef HOST
54#define RX_LIMIT (ushort) 1
55#endif
56
57
58/************************************************* 47/*************************************************
59 * Handshake asserted. Deasserted by the LTT(s) 48 * Handshake asserted. Deasserted by the LTT(s)
60 ************************************************/ 49 ************************************************/
@@ -69,11 +58,7 @@
69/************************************************* 58/*************************************************
70 * Maximum number of PHB's 59 * Maximum number of PHB's
71 ************************************************/ 60 ************************************************/
72#if defined (HOST) || defined (INKERNEL)
73#define MAX_PHB ((ushort) 128) /* range 0-127 */ 61#define MAX_PHB ((ushort) 128) /* range 0-127 */
74#else
75#define MAX_PHB ((ushort) 8) /* range 0-7 */
76#endif
77 62
78/************************************************* 63/*************************************************
79 * Defines for the mode fields 64 * Defines for the mode fields
@@ -139,141 +124,23 @@
139 * the start. The pointer tx_add points to a SPACE to put a Packet. 124 * the start. The pointer tx_add points to a SPACE to put a Packet.
140 * The pointer tx_remove points to the next Packet to remove 125 * The pointer tx_remove points to the next Packet to remove
141 *************************************************************************/ 126 *************************************************************************/
142#ifndef INKERNEL
143#define src_unit u2.s2.unit
144#define src_port u2.s2.port
145#define dest_unit u1.s1.unit
146#define dest_port u1.s1.port
147#endif
148#ifdef HOST
149#define tx_start u3.s1.tx_start_ptr_ptr
150#define tx_add u3.s1.tx_add_ptr_ptr
151#define tx_end u3.s1.tx_end_ptr_ptr
152#define tx_remove u3.s1.tx_remove_ptr_ptr
153#define rx_start u4.s1.rx_start_ptr_ptr
154#define rx_add u4.s1.rx_add_ptr_ptr
155#define rx_end u4.s1.rx_end_ptr_ptr
156#define rx_remove u4.s1.rx_remove_ptr_ptr
157#endif
158typedef struct PHB PHB; 127typedef struct PHB PHB;
159struct PHB { 128struct PHB {
160#ifdef RTA
161 ushort port;
162#endif
163#ifdef INKERNEL
164 WORD source; 129 WORD source;
165#else
166 union {
167 ushort source; /* Complete source */
168 struct {
169 unsigned char unit; /* Source unit */
170 unsigned char port; /* Source port */
171 } s2;
172 } u2;
173#endif
174 WORD handshake; 130 WORD handshake;
175 WORD status; 131 WORD status;
176 NUMBER timeout; /* Maximum of 1.9 seconds */ 132 NUMBER timeout; /* Maximum of 1.9 seconds */
177 WORD link; /* Send down this link */ 133 WORD link; /* Send down this link */
178#ifdef INKERNEL
179 WORD destination; 134 WORD destination;
180#else
181 union {
182 ushort destination; /* Complete destination */
183 struct {
184 unsigned char unit; /* Destination unit */
185 unsigned char port; /* Destination port */
186 } s1;
187 } u1;
188#endif
189#ifdef RTA
190 ushort tx_pkts_added;
191 ushort tx_pkts_removed;
192 Q_BUF_ptr tx_q_start; /* Start of the Q list chain */
193 short num_tx_q_bufs; /* Number of Q buffers in the chain */
194 PKT_ptr_ptr tx_add; /* Add a new Packet here */
195 Q_BUF_ptr tx_add_qb; /* Pointer to the add Q buf */
196 PKT_ptr_ptr tx_add_st_qbb; /* Pointer to start of the Q's buf */
197 PKT_ptr_ptr tx_add_end_qbb; /* Pointer to the end of the Q's buf */
198 PKT_ptr_ptr tx_remove; /* Remove a Packet here */
199 Q_BUF_ptr tx_remove_qb; /* Pointer to the remove Q buf */
200 PKT_ptr_ptr tx_remove_st_qbb; /* Pointer to the start of the Q buf */
201 PKT_ptr_ptr tx_remove_end_qbb; /* Pointer to the end of the Q buf */
202#endif
203#ifdef INKERNEL
204 PKT_ptr_ptr tx_start; 135 PKT_ptr_ptr tx_start;
205 PKT_ptr_ptr tx_end; 136 PKT_ptr_ptr tx_end;
206 PKT_ptr_ptr tx_add; 137 PKT_ptr_ptr tx_add;
207 PKT_ptr_ptr tx_remove; 138 PKT_ptr_ptr tx_remove;
208#endif
209#ifdef HOST
210 union {
211 struct {
212 PKT_ptr_ptr tx_start_ptr_ptr;
213 PKT_ptr_ptr tx_end_ptr_ptr;
214 PKT_ptr_ptr tx_add_ptr_ptr;
215 PKT_ptr_ptr tx_remove_ptr_ptr;
216 } s1;
217 struct {
218 ushort *tx_start_ptr;
219 ushort *tx_end_ptr;
220 ushort *tx_add_ptr;
221 ushort *tx_remove_ptr;
222 } s2;
223 } u3;
224#endif
225 139
226#ifdef RTA
227 ushort rx_pkts_added;
228 ushort rx_pkts_removed;
229 Q_BUF_ptr rx_q_start; /* Start of the Q list chain */
230 short num_rx_q_bufs; /* Number of Q buffers in the chain */
231 PKT_ptr_ptr rx_add; /* Add a new Packet here */
232 Q_BUF_ptr rx_add_qb; /* Pointer to the add Q buf */
233 PKT_ptr_ptr rx_add_st_qbb; /* Pointer to start of the Q's buf */
234 PKT_ptr_ptr rx_add_end_qbb; /* Pointer to the end of the Q's buf */
235 PKT_ptr_ptr rx_remove; /* Remove a Packet here */
236 Q_BUF_ptr rx_remove_qb; /* Pointer to the remove Q buf */
237 PKT_ptr_ptr rx_remove_st_qbb; /* Pointer to the start of the Q buf */
238 PKT_ptr_ptr rx_remove_end_qbb; /* Pointer to the end of the Q buf */
239#endif
240#ifdef INKERNEL
241 PKT_ptr_ptr rx_start; 140 PKT_ptr_ptr rx_start;
242 PKT_ptr_ptr rx_end; 141 PKT_ptr_ptr rx_end;
243 PKT_ptr_ptr rx_add; 142 PKT_ptr_ptr rx_add;
244 PKT_ptr_ptr rx_remove; 143 PKT_ptr_ptr rx_remove;
245#endif
246#ifdef HOST
247 union {
248 struct {
249 PKT_ptr_ptr rx_start_ptr_ptr;
250 PKT_ptr_ptr rx_end_ptr_ptr;
251 PKT_ptr_ptr rx_add_ptr_ptr;
252 PKT_ptr_ptr rx_remove_ptr_ptr;
253 } s1;
254 struct {
255 ushort *rx_start_ptr;
256 ushort *rx_end_ptr;
257 ushort *rx_add_ptr;
258 ushort *rx_remove_ptr;
259 } s2;
260 } u4;
261#endif
262
263#ifdef RTA /* some fields for the remotes */
264 ushort flush_count; /* Count of write flushes */
265 ushort txmode; /* Modes for tx */
266 ushort rxmode; /* Modes for rx */
267 ushort portmode; /* Generic modes */
268 ushort column; /* TAB3 column count */
269 ushort tx_subscript; /* (TX) Subscript into data field */
270 ushort rx_subscript; /* (RX) Subscript into data field */
271 PKT_ptr rx_incomplete; /* Hold an incomplete packet here */
272 ushort modem_bits; /* Modem bits to mask */
273 ushort lastModem; /* Modem control lines. */
274 ushort addr; /* Address for sub commands */
275 ushort MonitorTstate; /* TRUE if monitoring tstop */
276#endif
277 144
278}; 145};
279 146
diff --git a/drivers/char/rio/pkt.h b/drivers/char/rio/pkt.h
index 882fd429ac2e..7011e52e82db 100644
--- a/drivers/char/rio/pkt.h
+++ b/drivers/char/rio/pkt.h
@@ -70,39 +70,12 @@
70#define CONTROL_DATA_WNDW (DATA_WNDW << 8) 70#define CONTROL_DATA_WNDW (DATA_WNDW << 8)
71 71
72struct PKT { 72struct PKT {
73#ifdef INKERNEL
74 BYTE dest_unit; /* Destination Unit Id */ 73 BYTE dest_unit; /* Destination Unit Id */
75 BYTE dest_port; /* Destination POrt */ 74 BYTE dest_port; /* Destination POrt */
76 BYTE src_unit; /* Source Unit Id */ 75 BYTE src_unit; /* Source Unit Id */
77 BYTE src_port; /* Source POrt */ 76 BYTE src_port; /* Source POrt */
78#else
79 union {
80 ushort destination; /* Complete destination */
81 struct {
82 unsigned char unit; /* Destination unit */
83 unsigned char port; /* Destination port */
84 } s1;
85 } u1;
86 union {
87 ushort source; /* Complete source */
88 struct {
89 unsigned char unit; /* Source unit */
90 unsigned char port; /* Source port */
91 } s2;
92 } u2;
93#endif
94#ifdef INKERNEL
95 BYTE len; 77 BYTE len;
96 BYTE control; 78 BYTE control;
97#else
98 union {
99 ushort control;
100 struct {
101 unsigned char len;
102 unsigned char control;
103 } s3;
104 } u3;
105#endif
106 BYTE data[PKT_MAX_DATA_LEN]; 79 BYTE data[PKT_MAX_DATA_LEN];
107 /* Actual data :-) */ 80 /* Actual data :-) */
108 WORD csum; /* C-SUM */ 81 WORD csum; /* C-SUM */
diff --git a/drivers/char/rio/qbuf.h b/drivers/char/rio/qbuf.h
index acd9e8e5307d..391ffc335535 100644
--- a/drivers/char/rio/qbuf.h
+++ b/drivers/char/rio/qbuf.h
@@ -46,11 +46,7 @@ static char *_rio_qbuf_h_sccs = "@(#)qbuf.h 1.1";
46 46
47 47
48 48
49#ifdef HOST
50#define PKTS_PER_BUFFER 1
51#else
52#define PKTS_PER_BUFFER (220 / PKT_LENGTH) 49#define PKTS_PER_BUFFER (220 / PKT_LENGTH)
53#endif
54 50
55typedef struct Q_BUF Q_BUF; 51typedef struct Q_BUF Q_BUF;
56struct Q_BUF { 52struct Q_BUF {
diff --git a/drivers/char/rio/riotypes.h b/drivers/char/rio/riotypes.h
index 9b67e2468bec..46084d5c7e98 100644
--- a/drivers/char/rio/riotypes.h
+++ b/drivers/char/rio/riotypes.h
@@ -43,9 +43,6 @@
43#endif 43#endif
44#endif 44#endif
45 45
46#ifdef INKERNEL
47
48#if !defined(MIPSAT)
49typedef unsigned short NUMBER_ptr; 46typedef unsigned short NUMBER_ptr;
50typedef unsigned short WORD_ptr; 47typedef unsigned short WORD_ptr;
51typedef unsigned short BYTE_ptr; 48typedef unsigned short BYTE_ptr;
@@ -65,69 +62,6 @@ typedef unsigned short RUP_ptr;
65typedef unsigned short short_ptr; 62typedef unsigned short short_ptr;
66typedef unsigned short u_short_ptr; 63typedef unsigned short u_short_ptr;
67typedef unsigned short ushort_ptr; 64typedef unsigned short ushort_ptr;
68#else
69/* MIPSAT types */
70typedef char RIO_POINTER[8];
71typedef RIO_POINTER NUMBER_ptr;
72typedef RIO_POINTER WORD_ptr;
73typedef RIO_POINTER BYTE_ptr;
74typedef RIO_POINTER char_ptr;
75typedef RIO_POINTER Channel_ptr;
76typedef RIO_POINTER FREE_LIST_ptr_ptr;
77typedef RIO_POINTER FREE_LIST_ptr;
78typedef RIO_POINTER LPB_ptr;
79typedef RIO_POINTER Process_ptr;
80typedef RIO_POINTER PHB_ptr;
81typedef RIO_POINTER PKT_ptr;
82typedef RIO_POINTER PKT_ptr_ptr;
83typedef RIO_POINTER Q_BUF_ptr;
84typedef RIO_POINTER Q_BUF_ptr_ptr;
85typedef RIO_POINTER ROUTE_STR_ptr;
86typedef RIO_POINTER RUP_ptr;
87typedef RIO_POINTER short_ptr;
88typedef RIO_POINTER u_short_ptr;
89typedef RIO_POINTER ushort_ptr;
90#endif
91
92#else /* not INKERNEL */
93typedef unsigned char BYTE;
94typedef unsigned short WORD;
95typedef unsigned long DWORD;
96typedef short NUMBER;
97typedef short *NUMBER_ptr;
98typedef unsigned short *WORD_ptr;
99typedef unsigned char *BYTE_ptr;
100typedef unsigned char uchar;
101typedef unsigned short ushort;
102typedef unsigned int uint;
103typedef unsigned long ulong;
104typedef unsigned char u_char;
105typedef unsigned short u_short;
106typedef unsigned int u_int;
107typedef unsigned long u_long;
108typedef unsigned short ERROR;
109typedef unsigned long ID;
110typedef char *char_ptr;
111typedef Channel *Channel_ptr;
112typedef struct FREE_LIST *FREE_LIST_ptr;
113typedef struct FREE_LIST **FREE_LIST_ptr_ptr;
114typedef struct LPB *LPB_ptr;
115typedef struct Process *Process_ptr;
116typedef struct PHB *PHB_ptr;
117typedef struct PKT *PKT_ptr;
118typedef struct PKT **PKT_ptr_ptr;
119typedef struct Q_BUF *Q_BUF_ptr;
120typedef struct Q_BUF **Q_BUF_ptr_ptr;
121typedef struct ROUTE_STR *ROUTE_STR_ptr;
122typedef struct RUP *RUP_ptr;
123typedef short *short_ptr;
124typedef u_short *u_short_ptr;
125typedef ushort *ushort_ptr;
126typedef struct PKT PKT;
127typedef struct LPB LPB;
128typedef struct RUP RUP;
129#endif
130
131 65
132#endif /* __riotypes__ */ 66#endif /* __riotypes__ */
133 67
diff --git a/drivers/char/rio/rup.h b/drivers/char/rio/rup.h
index 8d44fec91dd5..f74f67c6f702 100644
--- a/drivers/char/rio/rup.h
+++ b/drivers/char/rio/rup.h
@@ -43,12 +43,7 @@
43#endif 43#endif
44#endif 44#endif
45 45
46#if defined( HOST ) || defined( INKERNEL )
47#define MAX_RUP ((short) 16) 46#define MAX_RUP ((short) 16)
48#endif
49#ifdef RTA
50#define MAX_RUP ((short) 1)
51#endif
52 47
53#define PKTS_PER_RUP ((short) 2) /* They are always used in pairs */ 48#define PKTS_PER_RUP ((short) 2) /* They are always used in pairs */
54 49
diff --git a/drivers/char/rio/sam.h b/drivers/char/rio/sam.h
index 31494054b213..6f754e19015d 100644
--- a/drivers/char/rio/sam.h
+++ b/drivers/char/rio/sam.h
@@ -43,10 +43,6 @@
43#endif 43#endif
44 44
45 45
46#if !defined( HOST ) && !defined( INKERNEL )
47#define RTA 1
48#endif
49
50#define NUM_FREE_LIST_UNITS 500 46#define NUM_FREE_LIST_UNITS 500
51 47
52#ifndef FALSE 48#ifndef FALSE
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index 0949dcef0697..7edc6a4dbdc4 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -433,7 +433,7 @@ static void rp_do_receive(struct r_port *info,
433 count += ToRecv; 433 count += ToRecv;
434 } 434 }
435 /* Push the data up to the tty layer */ 435 /* Push the data up to the tty layer */
436 ld->receive_buf(tty, cbuf, fbuf, count); 436 ld->receive_buf(tty, chead, fhead, count);
437done: 437done:
438 tty_ldisc_deref(ld); 438 tty_ldisc_deref(ld);
439} 439}
diff --git a/drivers/char/ser_a2232.c b/drivers/char/ser_a2232.c
index 80a5b840e22f..fee68cc895f8 100644
--- a/drivers/char/ser_a2232.c
+++ b/drivers/char/ser_a2232.c
@@ -103,6 +103,7 @@
103 103
104#include <linux/serial.h> 104#include <linux/serial.h>
105#include <linux/generic_serial.h> 105#include <linux/generic_serial.h>
106#include <linux/tty_flip.h>
106 107
107#include "ser_a2232.h" 108#include "ser_a2232.h"
108#include "ser_a2232fw.h" 109#include "ser_a2232fw.h"
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index 64bf89cb574f..c2490e270f1f 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -931,7 +931,7 @@ static int sx_set_real_termios (void *ptr)
931 case CS6:sx_write_channel_byte (port, hi_mask, 0x3f);break; 931 case CS6:sx_write_channel_byte (port, hi_mask, 0x3f);break;
932 case CS5:sx_write_channel_byte (port, hi_mask, 0x1f);break; 932 case CS5:sx_write_channel_byte (port, hi_mask, 0x1f);break;
933 default: 933 default:
934 printk (KERN_INFO "sx: Invalid wordsize: %d\n", CFLAG & CSIZE); 934 printk (KERN_INFO "sx: Invalid wordsize: %u\n", CFLAG & CSIZE);
935 break; 935 break;
936 } 936 }
937 937
@@ -958,7 +958,7 @@ static int sx_set_real_termios (void *ptr)
958 } else { 958 } else {
959 set_bit(TTY_HW_COOK_IN, &port->gs.tty->flags); 959 set_bit(TTY_HW_COOK_IN, &port->gs.tty->flags);
960 } 960 }
961 sx_dprintk (SX_DEBUG_TERMIOS, "iflags: %x(%d) ", 961 sx_dprintk (SX_DEBUG_TERMIOS, "iflags: %x(%d) ",
962 port->gs.tty->termios->c_iflag, 962 port->gs.tty->termios->c_iflag,
963 I_OTHER(port->gs.tty)); 963 I_OTHER(port->gs.tty));
964 964
@@ -973,7 +973,7 @@ static int sx_set_real_termios (void *ptr)
973 } else { 973 } else {
974 clear_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags); 974 clear_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags);
975 } 975 }
976 sx_dprintk (SX_DEBUG_TERMIOS, "oflags: %x(%d)\n", 976 sx_dprintk (SX_DEBUG_TERMIOS, "oflags: %x(%d)\n",
977 port->gs.tty->termios->c_oflag, 977 port->gs.tty->termios->c_oflag,
978 O_OTHER(port->gs.tty)); 978 O_OTHER(port->gs.tty));
979 /* port->c_dcd = sx_get_CD (port); */ 979 /* port->c_dcd = sx_get_CD (port); */
diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
index aedf7a8e6da7..537aa45d8c67 100644
--- a/drivers/char/tpm/tpm_bios.c
+++ b/drivers/char/tpm/tpm_bios.c
@@ -191,7 +191,7 @@ static int get_event_name(char *dest, struct tcpa_event *event,
191 const char *name = ""; 191 const char *name = "";
192 char data[40] = ""; 192 char data[40] = "";
193 int i, n_len = 0, d_len = 0; 193 int i, n_len = 0, d_len = 0;
194 u32 event_id, event_data_size; 194 u32 event_id;
195 195
196 switch(event->event_type) { 196 switch(event->event_type) {
197 case PREBOOT: 197 case PREBOOT:
@@ -220,8 +220,7 @@ static int get_event_name(char *dest, struct tcpa_event *event,
220 } 220 }
221 break; 221 break;
222 case EVENT_TAG: 222 case EVENT_TAG:
223 event_id = be32_to_cpu(event_entry); 223 event_id = be32_to_cpu(*((u32 *)event_entry));
224 event_data_size = be32_to_cpu(&event_entry[4]);
225 224
226 /* ToDo Row data -> Base64 */ 225 /* ToDo Row data -> Base64 */
227 226
@@ -376,7 +375,7 @@ static int read_log(struct tpm_bios_log *log)
376{ 375{
377 struct acpi_tcpa *buff; 376 struct acpi_tcpa *buff;
378 acpi_status status; 377 acpi_status status;
379 void *virt; 378 struct acpi_table_header *virt;
380 379
381 if (log->bios_event_log != NULL) { 380 if (log->bios_event_log != NULL) {
382 printk(KERN_ERR 381 printk(KERN_ERR
@@ -413,7 +412,7 @@ static int read_log(struct tpm_bios_log *log)
413 412
414 log->bios_event_log_end = log->bios_event_log + buff->log_max_len; 413 log->bios_event_log_end = log->bios_event_log + buff->log_max_len;
415 414
416 acpi_os_map_memory(buff->log_start_addr, buff->log_max_len, &virt); 415 acpi_os_map_memory(buff->log_start_addr, buff->log_max_len, (void *) &virt);
417 416
418 memcpy(log->bios_event_log, virt, buff->log_max_len); 417 memcpy(log->bios_event_log, virt, buff->log_max_len);
419 418
@@ -487,26 +486,35 @@ struct file_operations tpm_binary_bios_measurements_ops = {
487 .release = tpm_bios_measurements_release, 486 .release = tpm_bios_measurements_release,
488}; 487};
489 488
489static int is_bad(void *p)
490{
491 if (!p)
492 return 1;
493 if (IS_ERR(p) && (PTR_ERR(p) != -ENODEV))
494 return 1;
495 return 0;
496}
497
490struct dentry **tpm_bios_log_setup(char *name) 498struct dentry **tpm_bios_log_setup(char *name)
491{ 499{
492 struct dentry **ret = NULL, *tpm_dir, *bin_file, *ascii_file; 500 struct dentry **ret = NULL, *tpm_dir, *bin_file, *ascii_file;
493 501
494 tpm_dir = securityfs_create_dir(name, NULL); 502 tpm_dir = securityfs_create_dir(name, NULL);
495 if (!tpm_dir) 503 if (is_bad(tpm_dir))
496 goto out; 504 goto out;
497 505
498 bin_file = 506 bin_file =
499 securityfs_create_file("binary_bios_measurements", 507 securityfs_create_file("binary_bios_measurements",
500 S_IRUSR | S_IRGRP, tpm_dir, NULL, 508 S_IRUSR | S_IRGRP, tpm_dir, NULL,
501 &tpm_binary_bios_measurements_ops); 509 &tpm_binary_bios_measurements_ops);
502 if (!bin_file) 510 if (is_bad(bin_file))
503 goto out_tpm; 511 goto out_tpm;
504 512
505 ascii_file = 513 ascii_file =
506 securityfs_create_file("ascii_bios_measurements", 514 securityfs_create_file("ascii_bios_measurements",
507 S_IRUSR | S_IRGRP, tpm_dir, NULL, 515 S_IRUSR | S_IRGRP, tpm_dir, NULL,
508 &tpm_ascii_bios_measurements_ops); 516 &tpm_ascii_bios_measurements_ops);
509 if (!ascii_file) 517 if (is_bad(ascii_file))
510 goto out_bin; 518 goto out_bin;
511 519
512 ret = kmalloc(3 * sizeof(struct dentry *), GFP_KERNEL); 520 ret = kmalloc(3 * sizeof(struct dentry *), GFP_KERNEL);
@@ -538,3 +546,4 @@ void tpm_bios_log_teardown(struct dentry **lst)
538 securityfs_remove(lst[i]); 546 securityfs_remove(lst[i]);
539} 547}
540EXPORT_SYMBOL_GPL(tpm_bios_log_teardown); 548EXPORT_SYMBOL_GPL(tpm_bios_log_teardown);
549MODULE_LICENSE("GPL");
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
index 8198dbb7370f..ec7590951af5 100644
--- a/drivers/char/tpm/tpm_infineon.c
+++ b/drivers/char/tpm/tpm_infineon.c
@@ -441,7 +441,7 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
441 441
442 if ((ioh << 8 | iol) != tpm_inf.base) { 442 if ((ioh << 8 | iol) != tpm_inf.base) {
443 dev_err(&dev->dev, 443 dev_err(&dev->dev,
444 "Could not set IO-ports to %04x\n", 444 "Could not set IO-ports to 0x%lx\n",
445 tpm_inf.base); 445 tpm_inf.base);
446 release_region(tpm_inf.base, TPM_INF_PORT_LEN); 446 release_region(tpm_inf.base, TPM_INF_PORT_LEN);
447 return -EIO; 447 return -EIO;
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index eb8b5be4e249..076e07c1da38 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -253,6 +253,7 @@ static void tty_buffer_free_all(struct tty_struct *tty)
253 253
254static void tty_buffer_init(struct tty_struct *tty) 254static void tty_buffer_init(struct tty_struct *tty)
255{ 255{
256 spin_lock_init(&tty->buf.lock);
256 tty->buf.head = NULL; 257 tty->buf.head = NULL;
257 tty->buf.tail = NULL; 258 tty->buf.tail = NULL;
258 tty->buf.free = NULL; 259 tty->buf.free = NULL;
@@ -266,6 +267,7 @@ static struct tty_buffer *tty_buffer_alloc(size_t size)
266 p->used = 0; 267 p->used = 0;
267 p->size = size; 268 p->size = size;
268 p->next = NULL; 269 p->next = NULL;
270 p->active = 0;
269 p->char_buf_ptr = (char *)(p->data); 271 p->char_buf_ptr = (char *)(p->data);
270 p->flag_buf_ptr = (unsigned char *)p->char_buf_ptr + size; 272 p->flag_buf_ptr = (unsigned char *)p->char_buf_ptr + size;
271/* printk("Flip create %p\n", p); */ 273/* printk("Flip create %p\n", p); */
@@ -312,25 +314,36 @@ static struct tty_buffer *tty_buffer_find(struct tty_struct *tty, size_t size)
312 314
313int tty_buffer_request_room(struct tty_struct *tty, size_t size) 315int tty_buffer_request_room(struct tty_struct *tty, size_t size)
314{ 316{
315 struct tty_buffer *b = tty->buf.tail, *n; 317 struct tty_buffer *b, *n;
316 int left = 0; 318 int left;
319 unsigned long flags;
320
321 spin_lock_irqsave(&tty->buf.lock, flags);
317 322
318 /* OPTIMISATION: We could keep a per tty "zero" sized buffer to 323 /* OPTIMISATION: We could keep a per tty "zero" sized buffer to
319 remove this conditional if its worth it. This would be invisible 324 remove this conditional if its worth it. This would be invisible
320 to the callers */ 325 to the callers */
321 if(b != NULL) 326 if ((b = tty->buf.tail) != NULL) {
322 left = b->size - b->used; 327 left = b->size - b->used;
323 if(left >= size) 328 b->active = 1;
324 return size; 329 } else
325 /* This is the slow path - looking for new buffers to use */ 330 left = 0;
326 n = tty_buffer_find(tty, size); 331
327 if(n == NULL) 332 if (left < size) {
328 return left; 333 /* This is the slow path - looking for new buffers to use */
329 if(b != NULL) 334 if ((n = tty_buffer_find(tty, size)) != NULL) {
330 b->next = n; 335 if (b != NULL) {
331 else 336 b->next = n;
332 tty->buf.head = n; 337 b->active = 0;
333 tty->buf.tail = n; 338 } else
339 tty->buf.head = n;
340 tty->buf.tail = n;
341 n->active = 1;
342 } else
343 size = left;
344 }
345
346 spin_unlock_irqrestore(&tty->buf.lock, flags);
334 return size; 347 return size;
335} 348}
336 349
@@ -396,10 +409,12 @@ EXPORT_SYMBOL_GPL(tty_insert_flip_string_flags);
396int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size) 409int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size)
397{ 410{
398 int space = tty_buffer_request_room(tty, size); 411 int space = tty_buffer_request_room(tty, size);
399 struct tty_buffer *tb = tty->buf.tail; 412 if (likely(space)) {
400 *chars = tb->char_buf_ptr + tb->used; 413 struct tty_buffer *tb = tty->buf.tail;
401 memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space); 414 *chars = tb->char_buf_ptr + tb->used;
402 tb->used += space; 415 memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space);
416 tb->used += space;
417 }
403 return space; 418 return space;
404} 419}
405 420
@@ -416,10 +431,12 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string);
416int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size) 431int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size)
417{ 432{
418 int space = tty_buffer_request_room(tty, size); 433 int space = tty_buffer_request_room(tty, size);
419 struct tty_buffer *tb = tty->buf.tail; 434 if (likely(space)) {
420 *chars = tb->char_buf_ptr + tb->used; 435 struct tty_buffer *tb = tty->buf.tail;
421 *flags = tb->flag_buf_ptr + tb->used; 436 *chars = tb->char_buf_ptr + tb->used;
422 tb->used += space; 437 *flags = tb->flag_buf_ptr + tb->used;
438 tb->used += space;
439 }
423 return space; 440 return space;
424} 441}
425 442
@@ -2747,20 +2764,20 @@ static void flush_to_ldisc(void *private_)
2747 schedule_delayed_work(&tty->buf.work, 1); 2764 schedule_delayed_work(&tty->buf.work, 1);
2748 goto out; 2765 goto out;
2749 } 2766 }
2750 spin_lock_irqsave(&tty->read_lock, flags); 2767 spin_lock_irqsave(&tty->buf.lock, flags);
2751 while((tbuf = tty->buf.head) != NULL) { 2768 while((tbuf = tty->buf.head) != NULL && !tbuf->active) {
2752 tty->buf.head = tbuf->next; 2769 tty->buf.head = tbuf->next;
2753 if (tty->buf.head == NULL) 2770 if (tty->buf.head == NULL)
2754 tty->buf.tail = NULL; 2771 tty->buf.tail = NULL;
2755 spin_unlock_irqrestore(&tty->read_lock, flags); 2772 spin_unlock_irqrestore(&tty->buf.lock, flags);
2756 /* printk("Process buffer %p for %d\n", tbuf, tbuf->used); */ 2773 /* printk("Process buffer %p for %d\n", tbuf, tbuf->used); */
2757 disc->receive_buf(tty, tbuf->char_buf_ptr, 2774 disc->receive_buf(tty, tbuf->char_buf_ptr,
2758 tbuf->flag_buf_ptr, 2775 tbuf->flag_buf_ptr,
2759 tbuf->used); 2776 tbuf->used);
2760 spin_lock_irqsave(&tty->read_lock, flags); 2777 spin_lock_irqsave(&tty->buf.lock, flags);
2761 tty_buffer_free(tty, tbuf); 2778 tty_buffer_free(tty, tbuf);
2762 } 2779 }
2763 spin_unlock_irqrestore(&tty->read_lock, flags); 2780 spin_unlock_irqrestore(&tty->buf.lock, flags);
2764out: 2781out:
2765 tty_ldisc_deref(disc); 2782 tty_ldisc_deref(disc);
2766} 2783}
@@ -2852,6 +2869,12 @@ EXPORT_SYMBOL(tty_get_baud_rate);
2852 2869
2853void tty_flip_buffer_push(struct tty_struct *tty) 2870void tty_flip_buffer_push(struct tty_struct *tty)
2854{ 2871{
2872 unsigned long flags;
2873 spin_lock_irqsave(&tty->buf.lock, flags);
2874 if (tty->buf.tail != NULL)
2875 tty->buf.tail->active = 0;
2876 spin_unlock_irqrestore(&tty->buf.lock, flags);
2877
2855 if (tty->low_latency) 2878 if (tty->low_latency)
2856 flush_to_ldisc((void *) tty); 2879 flush_to_ldisc((void *) tty);
2857 else 2880 else
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index f1d9cb7feae6..0900d1dbee59 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -3213,6 +3213,7 @@ void getconsxy(struct vc_data *vc, unsigned char *p)
3213 3213
3214void putconsxy(struct vc_data *vc, unsigned char *p) 3214void putconsxy(struct vc_data *vc, unsigned char *p)
3215{ 3215{
3216 hide_cursor(vc);
3216 gotoxy(vc, p[0], p[1]); 3217 gotoxy(vc, p[0], p[1]);
3217 set_cursor(vc); 3218 set_cursor(vc);
3218} 3219}
diff --git a/drivers/char/watchdog/sbc_epx_c3.c b/drivers/char/watchdog/sbc_epx_c3.c
index 951764614ebf..837b1ec3ffe3 100644
--- a/drivers/char/watchdog/sbc_epx_c3.c
+++ b/drivers/char/watchdog/sbc_epx_c3.c
@@ -25,6 +25,7 @@
25#include <linux/notifier.h> 25#include <linux/notifier.h>
26#include <linux/reboot.h> 26#include <linux/reboot.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/ioport.h>
28#include <asm/uaccess.h> 29#include <asm/uaccess.h>
29#include <asm/io.h> 30#include <asm/io.h>
30 31
@@ -91,7 +92,7 @@ static int epx_c3_release(struct inode *inode, struct file *file)
91 return 0; 92 return 0;
92} 93}
93 94
94static ssize_t epx_c3_write(struct file *file, const char *data, 95static ssize_t epx_c3_write(struct file *file, const char __user *data,
95 size_t len, loff_t *ppos) 96 size_t len, loff_t *ppos)
96{ 97{
97 /* Refresh the timer. */ 98 /* Refresh the timer. */
@@ -104,6 +105,7 @@ static int epx_c3_ioctl(struct inode *inode, struct file *file,
104 unsigned int cmd, unsigned long arg) 105 unsigned int cmd, unsigned long arg)
105{ 106{
106 int options, retval = -EINVAL; 107 int options, retval = -EINVAL;
108 int __user *argp = (void __user *)arg;
107 static struct watchdog_info ident = { 109 static struct watchdog_info ident = {
108 .options = WDIOF_KEEPALIVEPING | 110 .options = WDIOF_KEEPALIVEPING |
109 WDIOF_MAGICCLOSE, 111 WDIOF_MAGICCLOSE,
@@ -113,20 +115,19 @@ static int epx_c3_ioctl(struct inode *inode, struct file *file,
113 115
114 switch (cmd) { 116 switch (cmd) {
115 case WDIOC_GETSUPPORT: 117 case WDIOC_GETSUPPORT:
116 if (copy_to_user((struct watchdog_info *)arg, 118 if (copy_to_user(argp, &ident, sizeof(ident)))
117 &ident, sizeof(ident)))
118 return -EFAULT; 119 return -EFAULT;
119 return 0; 120 return 0;
120 case WDIOC_GETSTATUS: 121 case WDIOC_GETSTATUS:
121 case WDIOC_GETBOOTSTATUS: 122 case WDIOC_GETBOOTSTATUS:
122 return put_user(0,(int *)arg); 123 return put_user(0, argp);
123 case WDIOC_KEEPALIVE: 124 case WDIOC_KEEPALIVE:
124 epx_c3_pet(); 125 epx_c3_pet();
125 return 0; 126 return 0;
126 case WDIOC_GETTIMEOUT: 127 case WDIOC_GETTIMEOUT:
127 return put_user(WATCHDOG_TIMEOUT,(int *)arg); 128 return put_user(WATCHDOG_TIMEOUT, argp);
128 case WDIOC_SETOPTIONS: { 129 case WDIOC_SETOPTIONS:
129 if (get_user(options, (int *)arg)) 130 if (get_user(options, argp))
130 return -EFAULT; 131 return -EFAULT;
131 132
132 if (options & WDIOS_DISABLECARD) { 133 if (options & WDIOS_DISABLECARD) {
@@ -140,7 +141,6 @@ static int epx_c3_ioctl(struct inode *inode, struct file *file,
140 } 141 }
141 142
142 return retval; 143 return retval;
143 }
144 default: 144 default:
145 return -ENOIOCTLCMD; 145 return -ENOIOCTLCMD;
146 } 146 }
@@ -181,11 +181,14 @@ static int __init watchdog_init(void)
181{ 181{
182 int ret; 182 int ret;
183 183
184 if (!request_region(EPXC3_WATCHDOG_CTL_REG, 2, "epxc3_watchdog"))
185 return -EBUSY;
186
184 ret = register_reboot_notifier(&epx_c3_notifier); 187 ret = register_reboot_notifier(&epx_c3_notifier);
185 if (ret) { 188 if (ret) {
186 printk(KERN_ERR PFX "cannot register reboot notifier " 189 printk(KERN_ERR PFX "cannot register reboot notifier "
187 "(err=%d)\n", ret); 190 "(err=%d)\n", ret);
188 return ret; 191 goto out;
189 } 192 }
190 193
191 ret = misc_register(&epx_c3_miscdev); 194 ret = misc_register(&epx_c3_miscdev);
@@ -193,18 +196,23 @@ static int __init watchdog_init(void)
193 printk(KERN_ERR PFX "cannot register miscdev on minor=%d " 196 printk(KERN_ERR PFX "cannot register miscdev on minor=%d "
194 "(err=%d)\n", WATCHDOG_MINOR, ret); 197 "(err=%d)\n", WATCHDOG_MINOR, ret);
195 unregister_reboot_notifier(&epx_c3_notifier); 198 unregister_reboot_notifier(&epx_c3_notifier);
196 return ret; 199 goto out;
197 } 200 }
198 201
199 printk(banner); 202 printk(banner);
200 203
201 return 0; 204 return 0;
205
206out:
207 release_region(EPXC3_WATCHDOG_CTL_REG, 2);
208 return ret;
202} 209}
203 210
204static void __exit watchdog_exit(void) 211static void __exit watchdog_exit(void)
205{ 212{
206 misc_deregister(&epx_c3_miscdev); 213 misc_deregister(&epx_c3_miscdev);
207 unregister_reboot_notifier(&epx_c3_notifier); 214 unregister_reboot_notifier(&epx_c3_notifier);
215 release_region(EPXC3_WATCHDOG_CTL_REG, 2);
208} 216}
209 217
210module_init(watchdog_init); 218module_init(watchdog_init);