|
3 | 3 | #define _I8042_SPARCIO_H
|
4 | 4 |
|
5 | 5 | #include <linux/of_device.h>
|
| 6 | +#include <linux/types.h> |
6 | 7 |
|
7 | 8 | #include <asm/io.h>
|
8 | 9 | #include <asm/oplib.h>
|
@@ -103,12 +104,25 @@ static struct platform_driver sparc_i8042_driver = {
|
103 | 104 | .remove = sparc_i8042_remove,
|
104 | 105 | };
|
105 | 106 |
|
106 |
| -static int __init i8042_platform_init(void) |
| 107 | +static bool i8042_is_mr_coffee(void) |
107 | 108 | {
|
108 |
| - struct device_node *root = of_find_node_by_path("/"); |
109 |
| - const char *name = of_get_property(root, "name", NULL); |
| 109 | + struct device_node *root; |
| 110 | + const char *name; |
| 111 | + bool is_mr_coffee; |
| 112 | + |
| 113 | + root = of_find_node_by_path("/"); |
| 114 | + |
| 115 | + name = of_get_property(root, "name", NULL); |
| 116 | + is_mr_coffee = name && !strcmp(name, "SUNW,JavaStation-1"); |
110 | 117 |
|
111 |
| - if (name && !strcmp(name, "SUNW,JavaStation-1")) { |
| 118 | + of_node_put(root); |
| 119 | + |
| 120 | + return is_mr_coffee; |
| 121 | +} |
| 122 | + |
| 123 | +static int __init i8042_platform_init(void) |
| 124 | +{ |
| 125 | + if (i8042_is_mr_coffee()) { |
112 | 126 | /* Hardcoded values for MrCoffee. */
|
113 | 127 | i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
|
114 | 128 | kbd_iobase = ioremap(0x71300060, 8);
|
@@ -136,10 +150,7 @@ static int __init i8042_platform_init(void)
|
136 | 150 |
|
137 | 151 | static inline void i8042_platform_exit(void)
|
138 | 152 | {
|
139 |
| - struct device_node *root = of_find_node_by_path("/"); |
140 |
| - const char *name = of_get_property(root, "name", NULL); |
141 |
| - |
142 |
| - if (!name || strcmp(name, "SUNW,JavaStation-1")) |
| 153 | + if (!i8042_is_mr_coffee()) |
143 | 154 | platform_driver_unregister(&sparc_i8042_driver);
|
144 | 155 | }
|
145 | 156 |
|
|
0 commit comments