Changeset 1d5a540 in mainline for uspace/lib/nic/src/nic_driver.c
- Timestamp:
- 2012-08-17T11:52:20Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 034c4202
- Parents:
- 8312577 (diff), 56fd7cf (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/nic/src/nic_driver.c
r8312577 r1d5a540 47 47 #include <sysinfo.h> 48 48 #include <as.h> 49 #include <devman.h>50 49 #include <ddf/interrupt.h> 51 50 #include <ops/nic.h> … … 250 249 { 251 250 ddf_dev_t *dev = nic_data->dev; 251 async_sess_t *parent_sess; 252 252 253 253 /* Connect to the parent's driver. */ 254 dev->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE, 255 dev->handle, IPC_FLAG_BLOCKING); 256 if (dev->parent_sess == NULL) 254 parent_sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE); 255 if (parent_sess == NULL) 257 256 return EPARTY; 258 257 259 return hw_res_get_list_parsed( nic_data->dev->parent_sess, resources, 0);258 return hw_res_get_list_parsed(parent_sess, resources, 0); 260 259 } 261 260 … … 650 649 * 651 650 */ 652 static nic_t *nic_create( void)653 { 654 nic_t *nic_data = malloc(sizeof(nic_t));651 static nic_t *nic_create(ddf_dev_t *dev) 652 { 653 nic_t *nic_data = ddf_dev_data_alloc(dev, sizeof(nic_t)); 655 654 if (nic_data == NULL) 656 655 return NULL; 657 656 658 657 /* Force zero to all uninitialized fields (e.g. added in future) */ 659 bzero(nic_data, sizeof(nic_t));660 658 if (nic_rxc_init(&nic_data->rx_control) != EOK) { 661 free(nic_data);662 659 return NULL; 663 660 } 664 661 665 662 if (nic_wol_virtues_init(&nic_data->wol_virtues) != EOK) { 666 free(nic_data);667 663 return NULL; 668 664 } … … 705 701 nic_t *nic_create_and_bind(ddf_dev_t *device) 706 702 { 707 assert(device); 708 assert(!device->driver_data); 709 710 nic_t *nic_data = nic_create(); 703 nic_t *nic_data = nic_create(device); 711 704 if (!nic_data) 712 705 return NULL; 713 706 714 707 nic_data->dev = device; 715 device->driver_data = nic_data;716 708 717 709 return nic_data; … … 724 716 * @param data 725 717 */ 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 718 static void nic_destroy(nic_t *nic_data) 719 { 731 720 free(nic_data->specific); 732 free(nic_data);733 721 } 734 722 … … 740 728 * @param device The NIC device structure 741 729 */ 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; 730 void nic_unbind_and_destroy(ddf_dev_t *device) 731 { 732 nic_destroy(nic_get_from_ddf_dev(device)); 750 733 return; 751 734 } … … 983 966 nic_t *nic_get_from_ddf_dev(ddf_dev_t *dev) 984 967 { 985 return (nic_t *) d ev->driver_data;986 } ;968 return (nic_t *) ddf_dev_data_get(dev); 969 } 987 970 988 971 /** … … 992 975 nic_t *nic_get_from_ddf_fun(ddf_fun_t *fun) 993 976 { 994 return (nic_t *) fun->driver_data;995 } ;977 return (nic_t *) ddf_fun_data_get(fun); 978 } 996 979 997 980 /**
Note:
See TracChangeset
for help on using the changeset viewer.