Changes in uspace/lib/nic/src/nic_driver.c [56fd7cf:77ad86c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/nic/src/nic_driver.c
r56fd7cf r77ad86c 47 47 #include <sysinfo.h> 48 48 #include <as.h> 49 #include <devman.h> 49 50 #include <ddf/interrupt.h> 50 51 #include <ops/nic.h> … … 249 250 { 250 251 ddf_dev_t *dev = nic_data->dev; 251 async_sess_t *parent_sess;252 252 253 253 /* Connect to the parent's driver. */ 254 parent_sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE); 255 if (parent_sess == NULL) 254 dev->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE, 255 dev->handle, IPC_FLAG_BLOCKING); 256 if (dev->parent_sess == NULL) 256 257 return EPARTY; 257 258 258 return hw_res_get_list_parsed( parent_sess, resources, 0);259 return hw_res_get_list_parsed(nic_data->dev->parent_sess, resources, 0); 259 260 } 260 261 … … 649 650 * 650 651 */ 651 static nic_t *nic_create( ddf_dev_t *dev)652 { 653 nic_t *nic_data = ddf_dev_data_alloc(dev,sizeof(nic_t));652 static nic_t *nic_create(void) 653 { 654 nic_t *nic_data = malloc(sizeof(nic_t)); 654 655 if (nic_data == NULL) 655 656 return NULL; 656 657 657 658 /* Force zero to all uninitialized fields (e.g. added in future) */ 659 bzero(nic_data, sizeof(nic_t)); 658 660 if (nic_rxc_init(&nic_data->rx_control) != EOK) { 661 free(nic_data); 659 662 return NULL; 660 663 } 661 664 662 665 if (nic_wol_virtues_init(&nic_data->wol_virtues) != EOK) { 666 free(nic_data); 663 667 return NULL; 664 668 } … … 701 705 nic_t *nic_create_and_bind(ddf_dev_t *device) 702 706 { 703 nic_t *nic_data = nic_create(device); 707 assert(device); 708 assert(!device->driver_data); 709 710 nic_t *nic_data = nic_create(); 704 711 if (!nic_data) 705 712 return NULL; 706 713 707 714 nic_data->dev = device; 715 device->driver_data = nic_data; 708 716 709 717 return nic_data; … … 716 724 * @param data 717 725 */ 718 static void nic_destroy(nic_t *nic_data) 719 { 726 static void nic_destroy(nic_t *nic_data) { 727 if (nic_data->client_session != NULL) { 728 async_hangup(nic_data->client_session); 729 } 730 720 731 free(nic_data->specific); 732 free(nic_data); 721 733 } 722 734 … … 728 740 * @param device The NIC device structure 729 741 */ 730 void nic_unbind_and_destroy(ddf_dev_t *device) 731 { 732 nic_destroy(nic_get_from_ddf_dev(device)); 742 void nic_unbind_and_destroy(ddf_dev_t *device){ 743 if (!device) 744 return; 745 if (!device->driver_data) 746 return; 747 748 nic_destroy((nic_t *) device->driver_data); 749 device->driver_data = NULL; 733 750 return; 734 751 } … … 966 983 nic_t *nic_get_from_ddf_dev(ddf_dev_t *dev) 967 984 { 968 return (nic_t *) d df_dev_data_get(dev);969 } 985 return (nic_t *) dev->driver_data; 986 }; 970 987 971 988 /** … … 975 992 nic_t *nic_get_from_ddf_fun(ddf_fun_t *fun) 976 993 { 977 return (nic_t *) ddf_fun_data_get(fun);978 } 994 return (nic_t *) fun->driver_data; 995 }; 979 996 980 997 /**
Note:
See TracChangeset
for help on using the changeset viewer.