aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial/of_serial.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-16 20:58:08 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-16 20:58:08 -0400
commit489de30259e667d7bc47da9da44a0270b050cd97 (patch)
tree6807814f443fe2c5d041c3bc3fe3ca8d22a955ca /drivers/serial/of_serial.c
parent1f1c2881f673671539b25686df463518d69c4649 (diff)
parentbf22f6fe2d72b4d7e9035be8ceb340414cf490e3 (diff)
Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
* 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc: (209 commits) [POWERPC] Create add_rtc() function to enable the RTC CMOS driver [POWERPC] Add H_ILLAN_ATTRIBUTES hcall number [POWERPC] xilinxfb: Parameterize xilinxfb platform device registration [POWERPC] Oprofile support for Power 5++ [POWERPC] Enable arbitary speed tty ioctls and split input/output speed [POWERPC] Make drivers/char/hvc_console.c:khvcd() static [POWERPC] Remove dead code for preventing pread() and pwrite() calls [POWERPC] Remove unnecessary #undef printk from prom.c [POWERPC] Fix typo in Ebony default DTS [POWERPC] Check for NULL ppc_md.init_IRQ() before calling [POWERPC] Remove extra return statement [POWERPC] pasemi: Don't auto-select CONFIG_EMBEDDED [POWERPC] pasemi: Rename platform [POWERPC] arch/powerpc/kernel/sysfs.c: Move NUMA exports [POWERPC] Add __read_mostly support for powerpc [POWERPC] Modify sched_clock() to make CONFIG_PRINTK_TIME more sane [POWERPC] Create a dummy zImage if no valid platform has been selected [POWERPC] PS3: Bootwrapper support. [POWERPC] powermac i2c: Use mutex [POWERPC] Schedule removal of arch/ppc ... Fixed up conflicts manually in: Documentation/feature-removal-schedule.txt arch/powerpc/kernel/pci_32.c arch/powerpc/kernel/pci_64.c include/asm-powerpc/pci.h and asked the powerpc people to double-check the result..
Diffstat (limited to 'drivers/serial/of_serial.c')
-rw-r--r--drivers/serial/of_serial.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c
index 7ffdaeaf0545..a64d85821996 100644
--- a/drivers/serial/of_serial.c
+++ b/drivers/serial/of_serial.c
@@ -17,6 +17,11 @@
17#include <asm/of_platform.h> 17#include <asm/of_platform.h>
18#include <asm/prom.h> 18#include <asm/prom.h>
19 19
20struct of_serial_info {
21 int type;
22 int line;
23};
24
20/* 25/*
21 * Fill a struct uart_port for a given device node 26 * Fill a struct uart_port for a given device node
22 */ 27 */
@@ -62,6 +67,7 @@ static int __devinit of_platform_serial_setup(struct of_device *ofdev,
62static int __devinit of_platform_serial_probe(struct of_device *ofdev, 67static int __devinit of_platform_serial_probe(struct of_device *ofdev,
63 const struct of_device_id *id) 68 const struct of_device_id *id)
64{ 69{
70 struct of_serial_info *info;
65 struct uart_port port; 71 struct uart_port port;
66 int port_type; 72 int port_type;
67 int ret; 73 int ret;
@@ -69,30 +75,35 @@ static int __devinit of_platform_serial_probe(struct of_device *ofdev,
69 if (of_find_property(ofdev->node, "used-by-rtas", NULL)) 75 if (of_find_property(ofdev->node, "used-by-rtas", NULL))
70 return -EBUSY; 76 return -EBUSY;
71 77
78 info = kmalloc(sizeof(*info), GFP_KERNEL);
79 if (info == NULL)
80 return -ENOMEM;
81
72 port_type = (unsigned long)id->data; 82 port_type = (unsigned long)id->data;
73 ret = of_platform_serial_setup(ofdev, port_type, &port); 83 ret = of_platform_serial_setup(ofdev, port_type, &port);
74 if (ret) 84 if (ret)
75 goto out; 85 goto out;
76 86
77 switch (port_type) { 87 switch (port_type) {
78 case PORT_UNKNOWN:
79 dev_info(&ofdev->dev, "Unknown serial port found, "
80 "attempting to use 8250 driver\n");
81 /* fallthrough */
82 case PORT_8250 ... PORT_MAX_8250: 88 case PORT_8250 ... PORT_MAX_8250:
83 ret = serial8250_register_port(&port); 89 ret = serial8250_register_port(&port);
84 break; 90 break;
85 default: 91 default:
86 /* need to add code for these */ 92 /* need to add code for these */
93 case PORT_UNKNOWN:
94 dev_info(&ofdev->dev, "Unknown serial port found, ignored\n");
87 ret = -ENODEV; 95 ret = -ENODEV;
88 break; 96 break;
89 } 97 }
90 if (ret < 0) 98 if (ret < 0)
91 goto out; 99 goto out;
92 100
93 ofdev->dev.driver_data = (void *)(unsigned long)ret; 101 info->type = port_type;
102 info->line = ret;
103 ofdev->dev.driver_data = info;
94 return 0; 104 return 0;
95out: 105out:
106 kfree(info);
96 irq_dispose_mapping(port.irq); 107 irq_dispose_mapping(port.irq);
97 return ret; 108 return ret;
98} 109}
@@ -102,8 +113,16 @@ out:
102 */ 113 */
103static int of_platform_serial_remove(struct of_device *ofdev) 114static int of_platform_serial_remove(struct of_device *ofdev)
104{ 115{
105 int line = (unsigned long)ofdev->dev.driver_data; 116 struct of_serial_info *info = ofdev->dev.driver_data;
106 serial8250_unregister_port(line); 117 switch (info->type) {
118 case PORT_8250 ... PORT_MAX_8250:
119 serial8250_unregister_port(info->line);
120 break;
121 default:
122 /* need to add code for these */
123 break;
124 }
125 kfree(info);
107 return 0; 126 return 0;
108} 127}
109 128