Changeset b5f813c in mainline for uspace/drv
- Timestamp:
- 2015-07-04T03:28:02Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 55346870
- Parents:
- 2dbfe44
- Location:
- uspace/drv/bus/usb
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/ehci_endpoint.c
r2dbfe44 rb5f813c 80 80 { 81 81 assert(ep); 82 hc_t *hc = hcd_get_driver_data(hcd); 83 82 84 ehci_endpoint_t *ehci_ep = malloc(sizeof(ehci_endpoint_t)); 83 85 if (ehci_ep == NULL) … … 95 97 endpoint_set_hc_data( 96 98 ep, ehci_ep, ehci_ep_toggle_get, ehci_ep_toggle_set); 97 hc_enqueue_endpoint(hc d->driver.data, ep);99 hc_enqueue_endpoint(hc, ep); 98 100 return EOK; 99 101 } … … 108 110 assert(hcd); 109 111 assert(ep); 112 hc_t *hc = hcd_get_driver_data(hcd); 113 110 114 ehci_endpoint_t *instance = ehci_endpoint_get(ep); 111 hc_dequeue_endpoint(hc d->driver.data, ep);115 hc_dequeue_endpoint(hc, ep); 112 116 endpoint_clear_hc_data(ep); 113 117 usb_log_debug2("EP(%p): Destroying for %p", instance, ep); -
uspace/drv/bus/usb/ehci/hc.c
r2dbfe44 rb5f813c 273 273 { 274 274 assert(hcd); 275 hc_t *instance = hcd ->driver.data;275 hc_t *instance = hcd_get_driver_data(hcd); 276 276 assert(instance); 277 277 assert(status); … … 294 294 { 295 295 assert(hcd); 296 hc_t *instance = hcd ->driver.data;296 hc_t *instance = hcd_get_driver_data(hcd); 297 297 assert(instance); 298 298 … … 325 325 { 326 326 assert(hcd); 327 hc_t *instance = hcd ->driver.data;327 hc_t *instance = hcd_get_driver_data(hcd); 328 328 status = EHCI_RD(status); 329 329 assert(instance); -
uspace/drv/bus/usb/ehci/main.c
r2dbfe44 rb5f813c 50 50 #define NAME "ehci" 51 51 52 static int ehci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool); 53 static void ehci_driver_fini(hcd_t *); 54 55 static const ddf_hc_driver_t ehci_hc_driver = { 56 .claim = disable_legacy, 57 .hc_speed = USB_SPEED_HIGH, 58 .irq_code_gen = ehci_hc_gen_irq_code, 59 .init = ehci_driver_init, 60 .fini = ehci_driver_fini, 61 .name = "EHCI-PCI", 62 .ops = { 63 .schedule = ehci_hc_schedule, 64 .ep_add_hook = ehci_endpoint_init, 65 .ep_remove_hook = ehci_endpoint_fini, 66 .irq_hook = ehci_hc_interrupt, 67 .status_hook = ehci_hc_status, 68 } 69 }; 70 71 52 72 static int ehci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq) 53 73 { 54 74 assert(hcd); 55 assert(hcd ->driver.data== NULL);75 assert(hcd_get_driver_data(hcd) == NULL); 56 76 57 77 hc_t *instance = malloc(sizeof(hc_t)); … … 61 81 const int ret = hc_init(instance, res, irq); 62 82 if (ret == EOK) 63 hcd_set_implementation(hcd, instance, ehci_hc_schedule, 64 ehci_endpoint_init, ehci_endpoint_fini, ehci_hc_interrupt, 65 ehci_hc_status); 83 hcd_set_implementation(hcd, instance, &ehci_hc_driver.ops); 66 84 return ret; 67 85 } … … 70 88 { 71 89 assert(hcd); 72 if (hcd->driver.data) 73 hc_fini(hcd->driver.data); 90 hc_t *hc = hcd_get_driver_data(hcd); 91 if (hc) 92 hc_fini(hc); 74 93 75 free(hc d->driver.data);76 hcd_set_implementation(hcd, NULL, NULL , NULL, NULL, NULL, NULL);94 free(hc); 95 hcd_set_implementation(hcd, NULL, NULL); 77 96 } 78 79 static int ehci_dev_add(ddf_dev_t *device);80 81 static const driver_ops_t ehci_driver_ops = {82 .dev_add = ehci_dev_add,83 };84 85 static const driver_t ehci_driver = {86 .name = NAME,87 .driver_ops = &ehci_driver_ops88 };89 90 91 static const ddf_hc_driver_t ehci_hc_driver = {92 .claim = disable_legacy,93 .hc_speed = USB_SPEED_HIGH,94 .irq_code_gen = ehci_hc_gen_irq_code,95 .init = ehci_driver_init,96 .fini = ehci_driver_fini,97 .name = "EHCI-PCI"98 };99 97 100 98 /** Initializes a new ddf driver instance of EHCI hcd. … … 111 109 112 110 } 111 112 113 static const driver_ops_t ehci_driver_ops = { 114 .dev_add = ehci_dev_add, 115 }; 116 117 static const driver_t ehci_driver = { 118 .name = NAME, 119 .driver_ops = &ehci_driver_ops 120 }; 121 113 122 114 123 /** Initializes global driver structures (NONE). -
uspace/drv/bus/usb/ohci/hc.c
r2dbfe44 rb5f813c 271 271 assert(hcd); 272 272 assert(status); 273 hc_t *instance = hcd ->driver.data;273 hc_t *instance = hcd_get_driver_data(hcd); 274 274 assert(instance); 275 275 … … 290 290 { 291 291 assert(hcd); 292 hc_t *instance = hcd ->driver.data;292 hc_t *instance = hcd_get_driver_data(hcd); 293 293 assert(instance); 294 294 … … 330 330 { 331 331 assert(hcd); 332 hc_t *instance = hcd ->driver.data;332 hc_t *instance = hcd_get_driver_data(hcd); 333 333 status = OHCI_RD(status); 334 334 assert(instance); -
uspace/drv/bus/usb/ohci/main.c
r2dbfe44 rb5f813c 46 46 47 47 #define NAME "ohci" 48 static int ohci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool); 49 static void ohci_driver_fini(hcd_t *); 50 51 static const ddf_hc_driver_t ohci_hc_driver = { 52 .hc_speed = USB_SPEED_FULL, 53 .irq_code_gen = ohci_hc_gen_irq_code, 54 .init = ohci_driver_init, 55 .fini = ohci_driver_fini, 56 .name = "OHCI", 57 .ops = { 58 .schedule = ohci_hc_schedule, 59 .ep_add_hook = ohci_endpoint_init, 60 .ep_remove_hook = ohci_endpoint_fini, 61 .irq_hook = ohci_hc_interrupt, 62 .status_hook = ohci_hc_status, 63 }, 64 }; 65 48 66 49 67 static int ohci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq) 50 68 { 51 69 assert(hcd); 52 assert(hcd ->driver.data== NULL);70 assert(hcd_get_driver_data(hcd) == NULL); 53 71 54 72 hc_t *instance = malloc(sizeof(hc_t)); … … 58 76 const int ret = hc_init(instance, res, irq); 59 77 if (ret == EOK) 60 hcd_set_implementation(hcd, instance, ohci_hc_schedule, 61 ohci_endpoint_init, ohci_endpoint_fini, ohci_hc_interrupt, 62 ohci_hc_status); 78 hcd_set_implementation(hcd, instance, &ohci_hc_driver.ops); 63 79 return ret; 64 80 } … … 67 83 { 68 84 assert(hcd); 69 if (hcd->driver.data) 70 hc_fini(hcd->driver.data); 85 hc_t *hc = hcd_get_driver_data(hcd); 86 if (hc) 87 hc_fini(hc); 71 88 72 free(hcd->driver.data);73 hcd_set_implementation(hcd, NULL, NULL, NULL, NULL, NULL, NULL);89 hcd_set_implementation(hcd, NULL, NULL); 90 free(hc); 74 91 } 75 76 static const ddf_hc_driver_t ohci_hc_driver = {77 .hc_speed = USB_SPEED_FULL,78 .irq_code_gen = ohci_hc_gen_irq_code,79 .init = ohci_driver_init,80 .fini = ohci_driver_fini,81 .name = "OHCI"82 };83 92 84 93 /** Initializes a new ddf driver instance of OHCI hcd. -
uspace/drv/bus/usb/ohci/ohci_endpoint.c
r2dbfe44 rb5f813c 95 95 endpoint_set_hc_data( 96 96 ep, ohci_ep, ohci_ep_toggle_get, ohci_ep_toggle_set); 97 hc_enqueue_endpoint(hcd ->driver.data, ep);97 hc_enqueue_endpoint(hcd_get_driver_data(hcd), ep); 98 98 return EOK; 99 99 } … … 109 109 assert(ep); 110 110 ohci_endpoint_t *instance = ohci_endpoint_get(ep); 111 hc_dequeue_endpoint(hcd->driver.data, ep); 111 hc_dequeue_endpoint(hcd_get_driver_data(hcd), ep); 112 endpoint_clear_hc_data(ep); 112 113 if (instance) { 113 114 free32(instance->ed); … … 115 116 free(instance); 116 117 } 117 endpoint_clear_hc_data(ep);118 118 } 119 119 /** -
uspace/drv/bus/usb/uhci/hc.c
r2dbfe44 rb5f813c 157 157 { 158 158 assert(hcd); 159 hc_t *instance = hcd ->driver.data;159 hc_t *instance = hcd_get_driver_data(hcd); 160 160 assert(instance); 161 161 /* Lower 2 bits are transaction error and transaction complete */ … … 412 412 assert(hcd); 413 413 assert(status); 414 hc_t *instance = hcd ->driver.data;414 hc_t *instance = hcd_get_driver_data(hcd); 415 415 assert(instance); 416 416 … … 435 435 { 436 436 assert(hcd); 437 hc_t *instance = hcd ->driver.data;437 hc_t *instance = hcd_get_driver_data(hcd); 438 438 assert(instance); 439 439 assert(batch); -
uspace/drv/bus/usb/uhci/main.c
r2dbfe44 rb5f813c 48 48 #define NAME "uhci" 49 49 50 static int uhci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool); 51 static void uhci_driver_fini(hcd_t *); 52 static int disable_legacy(ddf_dev_t *); 53 54 static const ddf_hc_driver_t uhci_hc_driver = { 55 .claim = disable_legacy, 56 .hc_speed = USB_SPEED_FULL, 57 .irq_code_gen = uhci_hc_gen_irq_code, 58 .init = uhci_driver_init, 59 .fini = uhci_driver_fini, 60 .name = "UHCI", 61 .ops = { 62 .schedule = uhci_hc_schedule, 63 .irq_hook = uhci_hc_interrupt, 64 .status_hook = uhci_hc_status, 65 }, 66 }; 67 50 68 static int uhci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq) 51 69 { 52 70 assert(hcd); 53 assert(hcd ->driver.data== NULL);71 assert(hcd_get_driver_data(hcd) == NULL); 54 72 55 73 hc_t *instance = malloc(sizeof(hc_t)); … … 59 77 const int ret = hc_init(instance, res, irq); 60 78 if (ret == EOK) 61 hcd_set_implementation(hcd, instance, uhci_hc_schedule, NULL, 62 NULL, uhci_hc_interrupt, uhci_hc_status); 79 hcd_set_implementation(hcd, instance, &uhci_hc_driver.ops); 63 80 return ret; 64 81 } … … 67 84 { 68 85 assert(hcd); 69 if (hcd->driver.data) 70 hc_fini(hcd->driver.data); 86 hc_t *hc = hcd_get_driver_data(hcd); 87 if (hc) 88 hc_fini(hc); 71 89 72 free(hcd->driver.data);73 hcd_set_implementation(hcd, NULL, NULL, NULL, NULL, NULL, NULL);90 hcd_set_implementation(hcd, NULL, NULL); 91 free(hc); 74 92 } 75 76 static int uhci_dev_add(ddf_dev_t *device);77 78 static const driver_ops_t uhci_driver_ops = {79 .dev_add = uhci_dev_add,80 };81 82 static const driver_t uhci_driver = {83 .name = NAME,84 .driver_ops = &uhci_driver_ops85 };86 93 87 94 /** Call the PCI driver with a request to clear legacy support register … … 106 113 return rc; 107 114 } 108 static const ddf_hc_driver_t uhci_hc_driver = {109 .claim = disable_legacy,110 .hc_speed = USB_SPEED_FULL,111 .irq_code_gen = uhci_hc_gen_irq_code,112 .init = uhci_driver_init,113 .fini = uhci_driver_fini,114 .name = "UHCI"115 };116 117 115 118 116 /** Initialize a new ddf driver instance for uhci hc and hub. … … 121 119 * @return Error code. 122 120 */ 123 int uhci_dev_add(ddf_dev_t *device)121 static int uhci_dev_add(ddf_dev_t *device) 124 122 { 125 123 usb_log_debug2("uhci_dev_add() called\n"); … … 127 125 return hcd_ddf_add_hc(device, &uhci_hc_driver); 128 126 } 127 128 static const driver_ops_t uhci_driver_ops = { 129 .dev_add = uhci_dev_add, 130 }; 131 132 static const driver_t uhci_driver = { 133 .name = NAME, 134 .driver_ops = &uhci_driver_ops 135 }; 136 129 137 130 138 /** Initialize global driver structures (NONE). -
uspace/drv/bus/usb/vhc/main.c
r2dbfe44 rb5f813c 74 74 } 75 75 76 hcd_ops_t vhc_hc_ops = { 77 .schedule = vhc_schedule, 78 }; 79 76 80 static int vhc_dev_add(ddf_dev_t *dev) 77 81 { … … 95 99 } 96 100 97 hcd_set_implementation(dev_to_hcd(dev), data, vhc_schedule, NULL, NULL, NULL, NULL);101 hcd_set_implementation(dev_to_hcd(dev), data, &vhc_hc_ops); 98 102 99 103 /* Add virtual hub device */ -
uspace/drv/bus/usb/vhc/transfer.c
r2dbfe44 rb5f813c 167 167 assert(hcd); 168 168 assert(batch); 169 vhc_data_t *vhc = hcd ->driver.data;169 vhc_data_t *vhc = hcd_get_driver_data(hcd); 170 170 assert(vhc); 171 171
Note:
See TracChangeset
for help on using the changeset viewer.