old mode 100644new mode 100755.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Dongle BUS interface for USB, OS independent |
---|
3 | 4 | * |
---|
.. | .. |
---|
54 | 55 | #define USB_DEV_ISBAD(u) (u->pub->attrib.devid == 0xDEAD) |
---|
55 | 56 | #define USB_DLGO_SPINWAIT 100 /* wait after DL_GO (ms) */ |
---|
56 | 57 | #define TEST_CHIP 0x4328 |
---|
57 | | - |
---|
58 | | -/* driver info, initialized when bcmsdh_register is called */ |
---|
59 | | -static dbus_driver_t drvinfo = {NULL, NULL, NULL, NULL}; |
---|
60 | 58 | |
---|
61 | 59 | typedef struct { |
---|
62 | 60 | dbus_pub_t *pub; |
---|
.. | .. |
---|
150 | 148 | * attach() is not called at probe and detach() |
---|
151 | 149 | * can be called inside disconnect() |
---|
152 | 150 | */ |
---|
| 151 | +static probe_cb_t probe_cb = NULL; |
---|
| 152 | +static disconnect_cb_t disconnect_cb = NULL; |
---|
| 153 | +static void *probe_arg = NULL; |
---|
| 154 | +static void *disc_arg = NULL; |
---|
153 | 155 | static dbus_intf_t *g_dbusintf = NULL; |
---|
154 | 156 | static dbus_intf_t dbus_usb_intf; /** functions called by higher layer DBUS into lower layer */ |
---|
155 | 157 | |
---|
.. | .. |
---|
159 | 161 | */ |
---|
160 | 162 | static void *dbus_usb_attach(dbus_pub_t *pub, void *cbarg, dbus_intf_callbacks_t *cbs); |
---|
161 | 163 | static void dbus_usb_detach(dbus_pub_t *pub, void *info); |
---|
162 | | -static void * dbus_usb_probe(uint16 bus_no, uint16 slot, uint32 hdrlen); |
---|
| 164 | +static void * dbus_usb_probe(void *arg, const char *desc, uint32 bustype, |
---|
| 165 | + uint16 bus_no, uint16 slot, uint32 hdrlen); |
---|
163 | 166 | |
---|
164 | 167 | /* functions */ |
---|
165 | 168 | |
---|
.. | .. |
---|
168 | 171 | * lower level DBUS functions to call (in both dbus_usb.c and dbus_usb_os.c). |
---|
169 | 172 | */ |
---|
170 | 173 | static void * |
---|
171 | | -dbus_usb_probe(uint16 bus_no, uint16 slot, uint32 hdrlen) |
---|
| 174 | +dbus_usb_probe(void *arg, const char *desc, uint32 bustype, uint16 bus_no, |
---|
| 175 | + uint16 slot, uint32 hdrlen) |
---|
172 | 176 | { |
---|
173 | 177 | DBUSTRACE(("%s(): \n", __FUNCTION__)); |
---|
174 | | - if (drvinfo.probe) { |
---|
| 178 | + if (probe_cb) { |
---|
| 179 | + |
---|
175 | 180 | if (g_dbusintf != NULL) { |
---|
176 | 181 | /* First, initialize all lower-level functions as default |
---|
177 | 182 | * so that dbus.c simply calls directly to dbus_usb_os.c. |
---|
.. | .. |
---|
187 | 192 | dbus_usb_intf.dlrun = dbus_usb_dlrun; |
---|
188 | 193 | } |
---|
189 | 194 | |
---|
190 | | - return drvinfo.probe(bus_no, slot, hdrlen); |
---|
| 195 | + disc_arg = probe_cb(probe_arg, "DBUS USB", USB_BUS, bus_no, slot, hdrlen); |
---|
| 196 | + return disc_arg; |
---|
191 | 197 | } |
---|
192 | 198 | |
---|
193 | 199 | return NULL; |
---|
194 | 200 | } |
---|
195 | | - |
---|
196 | | -static int |
---|
197 | | -dbus_usb_suspend(void *handle) |
---|
198 | | -{ |
---|
199 | | - DBUSTRACE(("%s(): \n", __FUNCTION__)); |
---|
200 | | - |
---|
201 | | - if (drvinfo.suspend) |
---|
202 | | - return drvinfo.suspend(handle); |
---|
203 | | - |
---|
204 | | - return BCME_OK; |
---|
205 | | -} |
---|
206 | | - |
---|
207 | | -static int |
---|
208 | | -dbus_usb_resume(void *handle) |
---|
209 | | -{ |
---|
210 | | - DBUSTRACE(("%s(): \n", __FUNCTION__)); |
---|
211 | | - |
---|
212 | | - if (drvinfo.resume) |
---|
213 | | - drvinfo.resume(handle); |
---|
214 | | - |
---|
215 | | - return 0; |
---|
216 | | -} |
---|
217 | | - |
---|
218 | | -static dbus_driver_t dhd_usb_dbus = { |
---|
219 | | - dbus_usb_probe, |
---|
220 | | - dbus_usb_disconnect, |
---|
221 | | - dbus_usb_suspend, |
---|
222 | | - dbus_usb_resume |
---|
223 | | -}; |
---|
224 | 201 | |
---|
225 | 202 | /** |
---|
226 | 203 | * On return, *intf contains this or lower-level DBUS functions to be called by higher |
---|
227 | 204 | * level (dbus.c) |
---|
228 | 205 | */ |
---|
229 | 206 | int |
---|
230 | | -dbus_bus_register(dbus_driver_t *driver, dbus_intf_t **intf) |
---|
| 207 | +dbus_bus_register(int vid, int pid, probe_cb_t prcb, |
---|
| 208 | + disconnect_cb_t discb, void *prarg, dbus_intf_t **intf, void *param1, void *param2) |
---|
231 | 209 | { |
---|
232 | 210 | int err; |
---|
233 | 211 | |
---|
234 | 212 | DBUSTRACE(("%s(): \n", __FUNCTION__)); |
---|
235 | | - drvinfo = *driver; |
---|
| 213 | + probe_cb = prcb; |
---|
| 214 | + disconnect_cb = discb; |
---|
| 215 | + probe_arg = prarg; |
---|
| 216 | + |
---|
236 | 217 | *intf = &dbus_usb_intf; |
---|
237 | 218 | |
---|
238 | | - err = dbus_bus_osl_register(&dhd_usb_dbus, &g_dbusintf); |
---|
| 219 | + err = dbus_bus_osl_register(vid, pid, dbus_usb_probe, |
---|
| 220 | + dbus_usb_disconnect, NULL, &g_dbusintf, param1, param2); |
---|
239 | 221 | |
---|
240 | 222 | ASSERT(g_dbusintf); |
---|
241 | 223 | return err; |
---|
.. | .. |
---|
311 | 293 | dbus_usb_disconnect(void *handle) |
---|
312 | 294 | { |
---|
313 | 295 | DBUSTRACE(("%s(): \n", __FUNCTION__)); |
---|
314 | | - if (drvinfo.remove) |
---|
315 | | - drvinfo.remove(handle); |
---|
| 296 | + if (disconnect_cb) |
---|
| 297 | + disconnect_cb(disc_arg); |
---|
316 | 298 | } |
---|
317 | 299 | |
---|
318 | 300 | /** |
---|