diff options
Diffstat (limited to 'drivers/sh/maple/maple.c')
-rw-r--r-- | drivers/sh/maple/maple.c | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c index be97789fa5f..d1812d32f47 100644 --- a/drivers/sh/maple/maple.c +++ b/drivers/sh/maple/maple.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * Core maple bus functionality | 2 | * Core maple bus functionality |
3 | * | 3 | * |
4 | * Copyright (C) 2007, 2008 Adrian McMenamin | 4 | * Copyright (C) 2007, 2008 Adrian McMenamin |
5 | * Copyright (C) 2001 - 2008 Paul Mundt | ||
5 | * | 6 | * |
6 | * Based on 2.4 code by: | 7 | * Based on 2.4 code by: |
7 | * | 8 | * |
@@ -31,7 +32,7 @@ | |||
31 | #include <mach/dma.h> | 32 | #include <mach/dma.h> |
32 | #include <mach/sysasic.h> | 33 | #include <mach/sysasic.h> |
33 | 34 | ||
34 | MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, M.R. Brown, Adrian McMenamin"); | 35 | MODULE_AUTHOR("Yaegashi Takeshi, Paul Mundt, M. R. Brown, Adrian McMenamin"); |
35 | MODULE_DESCRIPTION("Maple bus driver for Dreamcast"); | 36 | MODULE_DESCRIPTION("Maple bus driver for Dreamcast"); |
36 | MODULE_LICENSE("GPL v2"); | 37 | MODULE_LICENSE("GPL v2"); |
37 | MODULE_SUPPORTED_DEVICE("{{SEGA, Dreamcast/Maple}}"); | 38 | MODULE_SUPPORTED_DEVICE("{{SEGA, Dreamcast/Maple}}"); |
@@ -65,19 +66,36 @@ static bool checked[4]; | |||
65 | static struct maple_device *baseunits[4]; | 66 | static struct maple_device *baseunits[4]; |
66 | 67 | ||
67 | /** | 68 | /** |
68 | * maple_driver_register - register a device driver | 69 | * maple_driver_register - register a maple driver |
69 | * automatically makes the driver bus a maple bus | 70 | * @drv: maple driver to be registered. |
70 | * @drv: the driver to be registered | 71 | * |
72 | * Registers the passed in @drv, while updating the bus type. | ||
73 | * Devices with matching function IDs will be automatically probed. | ||
71 | */ | 74 | */ |
72 | int maple_driver_register(struct device_driver *drv) | 75 | int maple_driver_register(struct maple_driver *drv) |
73 | { | 76 | { |
74 | if (!drv) | 77 | if (!drv) |
75 | return -EINVAL; | 78 | return -EINVAL; |
76 | drv->bus = &maple_bus_type; | 79 | |
77 | return driver_register(drv); | 80 | drv->drv.bus = &maple_bus_type; |
81 | |||
82 | return driver_register(&drv->drv); | ||
78 | } | 83 | } |
79 | EXPORT_SYMBOL_GPL(maple_driver_register); | 84 | EXPORT_SYMBOL_GPL(maple_driver_register); |
80 | 85 | ||
86 | /** | ||
87 | * maple_driver_unregister - unregister a maple driver. | ||
88 | * @drv: maple driver to unregister. | ||
89 | * | ||
90 | * Cleans up after maple_driver_register(). To be invoked in the exit | ||
91 | * path of any module drivers. | ||
92 | */ | ||
93 | void maple_driver_unregister(struct maple_driver *drv) | ||
94 | { | ||
95 | driver_unregister(&drv->drv); | ||
96 | } | ||
97 | EXPORT_SYMBOL_GPL(maple_driver_unregister); | ||
98 | |||
81 | /* set hardware registers to enable next round of dma */ | 99 | /* set hardware registers to enable next round of dma */ |
82 | static void maplebus_dma_reset(void) | 100 | static void maplebus_dma_reset(void) |
83 | { | 101 | { |
@@ -129,13 +147,13 @@ static void maple_release_device(struct device *dev) | |||
129 | kfree(mdev); | 147 | kfree(mdev); |
130 | } | 148 | } |
131 | 149 | ||
132 | /* | 150 | /** |
133 | * maple_add_packet - add a single instruction to the queue | 151 | * maple_add_packet - add a single instruction to the queue |
134 | * @mdev - maple device | 152 | * @mdev: maple device |
135 | * @function - function on device being queried | 153 | * @function: function on device being queried |
136 | * @command - maple command to add | 154 | * @command: maple command to add |
137 | * @length - length of command string (in 32 bit words) | 155 | * @length: length of command string (in 32 bit words) |
138 | * @data - remainder of command string | 156 | * @data: remainder of command string |
139 | */ | 157 | */ |
140 | int maple_add_packet(struct maple_device *mdev, u32 function, u32 command, | 158 | int maple_add_packet(struct maple_device *mdev, u32 function, u32 command, |
141 | size_t length, void *data) | 159 | size_t length, void *data) |
@@ -176,14 +194,15 @@ out: | |||
176 | } | 194 | } |
177 | EXPORT_SYMBOL_GPL(maple_add_packet); | 195 | EXPORT_SYMBOL_GPL(maple_add_packet); |
178 | 196 | ||
179 | /* | 197 | /** |
180 | * maple_add_packet_sleeps - add a single instruction to the queue | 198 | * maple_add_packet_sleeps - add a single instruction to the queue |
181 | * - waits for lock to be free | 199 | * @mdev: maple device |
182 | * @mdev - maple device | 200 | * @function: function on device being queried |
183 | * @function - function on device being queried | 201 | * @command: maple command to add |
184 | * @command - maple command to add | 202 | * @length: length of command string (in 32 bit words) |
185 | * @length - length of command string (in 32 bit words) | 203 | * @data: remainder of command string |
186 | * @data - remainder of command string | 204 | * |
205 | * Same as maple_add_packet(), but waits for the lock to become free. | ||
187 | */ | 206 | */ |
188 | int maple_add_packet_sleeps(struct maple_device *mdev, u32 function, | 207 | int maple_add_packet_sleeps(struct maple_device *mdev, u32 function, |
189 | u32 command, size_t length, void *data) | 208 | u32 command, size_t length, void *data) |
@@ -724,11 +743,9 @@ static int maple_get_dma_buffer(void) | |||
724 | static int match_maple_bus_driver(struct device *devptr, | 743 | static int match_maple_bus_driver(struct device *devptr, |
725 | struct device_driver *drvptr) | 744 | struct device_driver *drvptr) |
726 | { | 745 | { |
727 | struct maple_driver *maple_drv; | 746 | struct maple_driver *maple_drv = to_maple_driver(drvptr); |
728 | struct maple_device *maple_dev; | 747 | struct maple_device *maple_dev = to_maple_dev(devptr); |
729 | 748 | ||
730 | maple_drv = container_of(drvptr, struct maple_driver, drv); | ||
731 | maple_dev = container_of(devptr, struct maple_device, dev); | ||
732 | /* Trap empty port case */ | 749 | /* Trap empty port case */ |
733 | if (maple_dev->devinfo.function == 0xFFFFFFFF) | 750 | if (maple_dev->devinfo.function == 0xFFFFFFFF) |
734 | return 0; | 751 | return 0; |