Changeset 7eaeec1 in mainline for uspace/drv/nic/e1k/e1k.c
- Timestamp:
- 2012-08-20T21:27:38Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6a97f2e
- Parents:
- f3a37e28 (diff), dd13349 (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/drv/nic/e1k/e1k.c
rf3a37e28 r7eaeec1 32 32 * 33 33 */ 34 35 /* XXX Fix this */ 36 #define _DDF_DATA_IMPLANT 34 37 35 38 #include <assert.h> … … 71 74 ((e1000_t *) nic_get_specific(nic)) 72 75 73 /** device_t* -> nic_driver_data_t* cast */ 76 /** ddf_fun_t * -> nic_driver_data_t* cast */ 77 #define NIC_DATA_FUN(fun) \ 78 ((nic_t *) ddf_fun_data_get(fun)) 79 80 /** ddf_dev_t * -> nic_driver_data_t* cast */ 74 81 #define NIC_DATA_DEV(dev) \ 75 ((nic_t *) ((dev)->driver_data))76 77 /** d evice_t* -> e1000_t* cast */82 ((nic_t *) ddf_dev_data_get(dev)) 83 84 /** ddf_dev_t * -> e1000_t* cast */ 78 85 #define DRIVER_DATA_DEV(dev) \ 79 86 (DRIVER_DATA_NIC(NIC_DATA_DEV(dev))) 87 88 /** ddf_fun_t * -> e1000_t* cast */ 89 #define DRIVER_DATA_FUN(fun) \ 90 (DRIVER_DATA_NIC(NIC_DATA_FUN(fun))) 80 91 81 92 /** Cast pointer to uint64_t … … 305 316 * 306 317 */ 307 static int e1000_get_cable_state(ddf_fun_t *dev, nic_cable_state_t *state) 308 { 309 assert(dev); 310 assert(DRIVER_DATA_DEV(dev)); 311 assert(state); 312 313 e1000_t *e1000 = DRIVER_DATA_DEV(dev); 318 static int e1000_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state) 319 { 320 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 314 321 if (E1000_REG_READ(e1000, E1000_STATUS) & (STATUS_LU)) 315 322 *state = NIC_CS_PLUGGED; … … 328 335 * 329 336 */ 330 static int e1000_get_operation_mode(ddf_fun_t * dev, int *speed,337 static int e1000_get_operation_mode(ddf_fun_t *fun, int *speed, 331 338 nic_channel_mode_t *duplex, nic_role_t *role) 332 339 { 333 e1000_t *e1000 = DRIVER_DATA_ DEV(dev);340 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 334 341 uint32_t status = E1000_REG_READ(e1000, E1000_STATUS); 335 342 … … 376 383 * 377 384 */ 378 static int e1000_set_operation_mode(ddf_fun_t * dev, int speed,385 static int e1000_set_operation_mode(ddf_fun_t *fun, int speed, 379 386 nic_channel_mode_t duplex, nic_role_t role) 380 387 { … … 385 392 return EINVAL; 386 393 387 e1000_t *e1000 = DRIVER_DATA_ DEV(dev);394 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 388 395 389 396 fibril_mutex_lock(&e1000->ctrl_lock); … … 424 431 * 425 432 */ 426 static int e1000_autoneg_enable(ddf_fun_t * dev, uint32_t advertisement)427 { 428 e1000_t *e1000 = DRIVER_DATA_ DEV(dev);433 static int e1000_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement) 434 { 435 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 429 436 430 437 fibril_mutex_lock(&e1000->ctrl_lock); … … 452 459 * 453 460 */ 454 static int e1000_autoneg_disable(ddf_fun_t * dev)455 { 456 e1000_t *e1000 = DRIVER_DATA_ DEV(dev);461 static int e1000_autoneg_disable(ddf_fun_t *fun) 462 { 463 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 457 464 458 465 fibril_mutex_lock(&e1000->ctrl_lock); … … 491 498 * 492 499 */ 493 static int e1000_defective_get_mode(ddf_fun_t * device, uint32_t *mode)494 { 495 e1000_t *e1000 = DRIVER_DATA_ DEV(device);500 static int e1000_defective_get_mode(ddf_fun_t *fun, uint32_t *mode) 501 { 502 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 496 503 497 504 *mode = 0; … … 512 519 * 513 520 */ 514 static int e1000_defective_set_mode(ddf_fun_t * device, uint32_t mode)515 { 516 e1000_t *e1000 = DRIVER_DATA_ DEV(device);521 static int e1000_defective_set_mode(ddf_fun_t *fun, uint32_t mode) 522 { 523 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 517 524 int rc = EOK; 518 525 … … 1038 1045 * 1039 1046 */ 1040 static int e1000_vlan_set_tag(ddf_fun_t * device, uint16_t tag, bool add,1047 static int e1000_vlan_set_tag(ddf_fun_t *fun, uint16_t tag, bool add, 1041 1048 bool strip) 1042 1049 { … … 1052 1059 return ENOTSUP; 1053 1060 1054 e1000_t *e1000 = DRIVER_DATA_ DEV(device);1061 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 1055 1062 1056 1063 e1000->vlan_tag = tag; … … 1855 1862 static e1000_t *e1000_create_dev_data(ddf_dev_t *dev) 1856 1863 { 1857 assert(dev);1858 assert(!dev->driver_data);1859 1860 1864 nic_t *nic = nic_create_and_bind(dev); 1861 1865 if (!nic) … … 1896 1900 assert(dev); 1897 1901 1898 if (d ev->driver_data!= NULL)1902 if (ddf_dev_data_get(dev) != NULL) 1899 1903 nic_unbind_and_destroy(dev); 1900 1904 } … … 1910 1914 1911 1915 e1000_delete_dev_data(dev); 1912 1913 if (dev->parent_sess != NULL) {1914 async_hangup(dev->parent_sess);1915 dev->parent_sess = NULL;1916 }1917 1916 } 1918 1917 … … 1931 1930 const hw_res_list_parsed_t *hw_resources) 1932 1931 { 1933 assert(dev != NULL);1934 assert(hw_resources != NULL);1935 assert(dev->driver_data != NULL);1936 1937 1932 e1000_t *e1000 = DRIVER_DATA_DEV(dev); 1938 1933 … … 2003 1998 2004 1999 uint16_t device_id; 2005 rc = pci_config_space_read_16(d ev->parent_sess, PCI_DEVICE_ID,2000 rc = pci_config_space_read_16(ddf_dev_parent_sess_get(dev), PCI_DEVICE_ID, 2006 2001 &device_id); 2007 2002 if (rc != EOK) { … … 2121 2116 2122 2117 /* Device initialization */ 2123 nic_t *nic = d ev->driver_data;2118 nic_t *nic = ddf_dev_data_get(dev); 2124 2119 e1000_t *e1000 = DRIVER_DATA_NIC(nic); 2125 2120 … … 2147 2142 goto err_tx_structure; 2148 2143 nic_set_ddf_fun(nic, fun); 2149 fun->ops = &e1000_dev_ops;2150 fun->driver_data = nic;2144 ddf_fun_set_ops(fun, &e1000_dev_ops); 2145 ddf_fun_data_implant(fun, nic); 2151 2146 2152 2147 rc = e1000_register_int_handler(nic); … … 2278 2273 * @return Negative error code otherwise 2279 2274 */ 2280 static int e1000_set_addr(ddf_fun_t * dev, const nic_address_t *addr)2281 { 2282 nic_t *nic = NIC_DATA_ DEV(dev);2275 static int e1000_set_addr(ddf_fun_t *fun, const nic_address_t *addr) 2276 { 2277 nic_t *nic = NIC_DATA_FUN(fun); 2283 2278 e1000_t *e1000 = DRIVER_DATA_NIC(nic); 2284 2279
Note:
See TracChangeset
for help on using the changeset viewer.