Changeset 7eaeec1 in mainline for uspace/drv/nic/e1k/e1k.c


Ignore:
Timestamp:
2012-08-20T21:27:38Z (12 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
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.
Message:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/nic/e1k/e1k.c

    rf3a37e28 r7eaeec1  
    3232 *
    3333 */
     34
     35/* XXX Fix this */
     36#define _DDF_DATA_IMPLANT
    3437
    3538#include <assert.h>
     
    7174        ((e1000_t *) nic_get_specific(nic))
    7275
    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 */
    7481#define NIC_DATA_DEV(dev) \
    75         ((nic_t *) ((dev)->driver_data))
    76 
    77 /** device_t* -> e1000_t* cast */
     82        ((nic_t *) ddf_dev_data_get(dev))
     83
     84/** ddf_dev_t * -> e1000_t* cast */
    7885#define DRIVER_DATA_DEV(dev) \
    7986        (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)))
    8091
    8192/** Cast pointer to uint64_t
     
    305316 *
    306317 */
    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);
     318static int e1000_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state)
     319{
     320        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
    314321        if (E1000_REG_READ(e1000, E1000_STATUS) & (STATUS_LU))
    315322                *state = NIC_CS_PLUGGED;
     
    328335 *
    329336 */
    330 static int e1000_get_operation_mode(ddf_fun_t *dev, int *speed,
     337static int e1000_get_operation_mode(ddf_fun_t *fun, int *speed,
    331338    nic_channel_mode_t *duplex, nic_role_t *role)
    332339{
    333         e1000_t *e1000 = DRIVER_DATA_DEV(dev);
     340        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
    334341        uint32_t status = E1000_REG_READ(e1000, E1000_STATUS);
    335342       
     
    376383 *
    377384 */
    378 static int e1000_set_operation_mode(ddf_fun_t *dev, int speed,
     385static int e1000_set_operation_mode(ddf_fun_t *fun, int speed,
    379386    nic_channel_mode_t duplex, nic_role_t role)
    380387{
     
    385392                return EINVAL;
    386393       
    387         e1000_t *e1000 = DRIVER_DATA_DEV(dev);
     394        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
    388395       
    389396        fibril_mutex_lock(&e1000->ctrl_lock);
     
    424431 *
    425432 */
    426 static int e1000_autoneg_enable(ddf_fun_t *dev, uint32_t advertisement)
    427 {
    428         e1000_t *e1000 = DRIVER_DATA_DEV(dev);
     433static int e1000_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement)
     434{
     435        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
    429436       
    430437        fibril_mutex_lock(&e1000->ctrl_lock);
     
    452459 *
    453460 */
    454 static int e1000_autoneg_disable(ddf_fun_t *dev)
    455 {
    456         e1000_t *e1000 = DRIVER_DATA_DEV(dev);
     461static int e1000_autoneg_disable(ddf_fun_t *fun)
     462{
     463        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
    457464       
    458465        fibril_mutex_lock(&e1000->ctrl_lock);
     
    491498 *
    492499 */
    493 static int e1000_defective_get_mode(ddf_fun_t *device, uint32_t *mode)
    494 {
    495         e1000_t *e1000 = DRIVER_DATA_DEV(device);
     500static int e1000_defective_get_mode(ddf_fun_t *fun, uint32_t *mode)
     501{
     502        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
    496503       
    497504        *mode = 0;
     
    512519 *
    513520 */
    514 static int e1000_defective_set_mode(ddf_fun_t *device, uint32_t mode)
    515 {
    516         e1000_t *e1000 = DRIVER_DATA_DEV(device);
     521static int e1000_defective_set_mode(ddf_fun_t *fun, uint32_t mode)
     522{
     523        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
    517524        int rc = EOK;
    518525       
     
    10381045 *
    10391046 */
    1040 static int e1000_vlan_set_tag(ddf_fun_t *device, uint16_t tag, bool add,
     1047static int e1000_vlan_set_tag(ddf_fun_t *fun, uint16_t tag, bool add,
    10411048    bool strip)
    10421049{
     
    10521059                return ENOTSUP;
    10531060       
    1054         e1000_t *e1000 = DRIVER_DATA_DEV(device);
     1061        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
    10551062       
    10561063        e1000->vlan_tag = tag;
     
    18551862static e1000_t *e1000_create_dev_data(ddf_dev_t *dev)
    18561863{
    1857         assert(dev);
    1858         assert(!dev->driver_data);
    1859        
    18601864        nic_t *nic = nic_create_and_bind(dev);
    18611865        if (!nic)
     
    18961900        assert(dev);
    18971901       
    1898         if (dev->driver_data != NULL)
     1902        if (ddf_dev_data_get(dev) != NULL)
    18991903                nic_unbind_and_destroy(dev);
    19001904}
     
    19101914       
    19111915        e1000_delete_dev_data(dev);
    1912        
    1913         if (dev->parent_sess != NULL) {
    1914                 async_hangup(dev->parent_sess);
    1915                 dev->parent_sess = NULL;
    1916         }
    19171916}
    19181917
     
    19311930    const hw_res_list_parsed_t *hw_resources)
    19321931{
    1933         assert(dev != NULL);
    1934         assert(hw_resources != NULL);
    1935         assert(dev->driver_data != NULL);
    1936        
    19371932        e1000_t *e1000 = DRIVER_DATA_DEV(dev);
    19381933       
     
    20031998       
    20041999        uint16_t device_id;
    2005         rc = pci_config_space_read_16(dev->parent_sess, PCI_DEVICE_ID,
     2000        rc = pci_config_space_read_16(ddf_dev_parent_sess_get(dev), PCI_DEVICE_ID,
    20062001            &device_id);
    20072002        if (rc != EOK) {
     
    21212116       
    21222117        /* Device initialization */
    2123         nic_t *nic = dev->driver_data;
     2118        nic_t *nic = ddf_dev_data_get(dev);
    21242119        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
    21252120       
     
    21472142                goto err_tx_structure;
    21482143        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);
    21512146       
    21522147        rc = e1000_register_int_handler(nic);
     
    22782273 * @return Negative error code otherwise
    22792274 */
    2280 static int e1000_set_addr(ddf_fun_t *dev, const nic_address_t *addr)
    2281 {
    2282         nic_t *nic = NIC_DATA_DEV(dev);
     2275static int e1000_set_addr(ddf_fun_t *fun, const nic_address_t *addr)
     2276{
     2277        nic_t *nic = NIC_DATA_FUN(fun);
    22832278        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
    22842279       
Note: See TracChangeset for help on using the changeset viewer.