Changeset 7eaeec1 in mainline for uspace/drv/nic/rtl8139/driver.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/rtl8139/driver.c

    rf3a37e28 r7eaeec1  
    2727 */
    2828
     29/* XXX Fix this */
     30#define _DDF_DATA_IMPLANT
     31
    2932#include <assert.h>
    3033#include <errno.h>
     
    212215        rtl8139_regs_lock(rtl8139->io_port);
    213216
     217        async_sess_t *pci_sess =
     218                ddf_dev_parent_sess_get(nic_get_ddf_dev(rtl8139->nic_data));
     219
    214220        if (bit_val) {
    215                 async_sess_t *pci_sess =
    216                         nic_get_ddf_dev(rtl8139->nic_data)->parent_sess;
    217221                uint8_t pmen;
    218222                pci_config_space_read_8(pci_sess, 0x55, &pmen);
    219223                pci_config_space_write_8(pci_sess, 0x55, pmen | 1 | (1 << 7));
    220224        } else {
    221                 async_sess_t *pci_sess =
    222                         nic_get_ddf_dev(rtl8139->nic_data)->parent_sess;
    223225                uint8_t pmen;
    224226                pci_config_space_read_8(pci_sess, 0x55, &pmen);
     
    10521054        assert(dev);
    10531055
    1054         if (dev->driver_data)
     1056        if (ddf_dev_data_get(dev))
    10551057                nic_unbind_and_destroy(dev);
    1056 
    1057         if (dev->parent_sess != NULL) {
    1058                 async_hangup(dev->parent_sess);
    1059                 dev->parent_sess = NULL;
    1060         }
    10611058}
    10621059
     
    10801077
    10811078        if (hw_resources->irqs.count != 1) {
    1082                 ddf_msg(LVL_ERROR, "%s device: unexpected irq count", dev->name);
     1079                ddf_msg(LVL_ERROR, "%s device: unexpected irq count", ddf_dev_get_name(dev));
    10831080                return EINVAL;
    10841081        };
    10851082        if (hw_resources->io_ranges.count != 1) {
    1086                 ddf_msg(LVL_ERROR, "%s device: unexpected io ranges count", dev->name);
     1083                ddf_msg(LVL_ERROR, "%s device: unexpected io ranges count", ddf_dev_get_name(dev));
    10871084                return EINVAL;
    10881085        }
    10891086
    10901087        rtl8139->irq = hw_resources->irqs.irqs[0];
    1091         ddf_msg(LVL_DEBUG, "%s device: irq 0x%x assigned", dev->name, rtl8139->irq);
     1088        ddf_msg(LVL_DEBUG, "%s device: irq 0x%x assigned", ddf_dev_get_name(dev), rtl8139->irq);
    10921089
    10931090        rtl8139->io_addr = IOADDR_TO_PTR(hw_resources->io_ranges.ranges[0].address);
    10941091        if (hw_resources->io_ranges.ranges[0].size < RTL8139_IO_SIZE) {
    10951092                ddf_msg(LVL_ERROR, "i/o range assigned to the device "
    1096                     "%s is too small.", dev->name);
     1093                    "%s is too small.", ddf_dev_get_name(dev));
    10971094                return EINVAL;
    10981095        }
    1099         ddf_msg(LVL_DEBUG, "%s device: i/o addr %p assigned.", dev->name, rtl8139->io_addr);
     1096        ddf_msg(LVL_DEBUG, "%s device: i/o addr %p assigned.", ddf_dev_get_name(dev), rtl8139->io_addr);
    11001097
    11011098        return EOK;
     
    11921189static int rtl8139_device_initialize(ddf_dev_t *dev)
    11931190{
    1194         ddf_msg(LVL_DEBUG, "rtl8139_dev_initialize %s", dev->name);
     1191        ddf_msg(LVL_DEBUG, "rtl8139_dev_initialize %s", ddf_dev_get_name(dev));
    11951192
    11961193        int ret = EOK;
     
    12011198        rtl8139_t *rtl8139 = rtl8139_create_dev_data(dev);
    12021199        if (rtl8139 == NULL) {
    1203                 ddf_msg(LVL_ERROR, "Not enough memory for initializing %s.", dev->name);
     1200                ddf_msg(LVL_ERROR, "Not enough memory for initializing %s.", ddf_dev_get_name(dev));
    12041201                return ENOMEM;
    12051202        }
     
    12461243static int rtl8139_pio_enable(ddf_dev_t *dev)
    12471244{
    1248         ddf_msg(LVL_DEBUG, NAME ": rtl8139_pio_enable %s", dev->name);
     1245        ddf_msg(LVL_DEBUG, NAME ": rtl8139_pio_enable %s", ddf_dev_get_name(dev));
    12491246
    12501247        rtl8139_t *rtl8139 = nic_get_specific(nic_get_from_ddf_dev(dev));
     
    12531250        if (pio_enable(rtl8139->io_addr, RTL8139_IO_SIZE, &rtl8139->io_port)) {
    12541251                ddf_msg(LVL_ERROR, "Cannot gain the port %lx for device %s.", rtl8139->io_addr,
    1255                     dev->name);
     1252                    ddf_dev_get_name(dev));
    12561253                return EADDRNOTAVAIL;
    12571254        }
     
    12991296
    13001297        assert(dev);
    1301         ddf_msg(LVL_NOTE, "RTL8139_dev_add %s (handle = %d)", dev->name, dev->handle);
     1298        ddf_msg(LVL_NOTE, "RTL8139_dev_add %s (handle = %d)",
     1299            ddf_dev_get_name(dev), ddf_dev_get_handle(dev));
    13021300
    13031301        /* Init device structure for rtl8139 */
     
    13401338        }
    13411339        nic_set_ddf_fun(nic_data, fun);
    1342         fun->ops = &rtl8139_dev_ops;
    1343         fun->driver_data = nic_data;
     1340        ddf_fun_set_ops(fun, &rtl8139_dev_ops);
     1341        ddf_fun_data_implant(fun, nic_data);
    13441342
    13451343        rc = ddf_fun_bind(fun);
     
    13551353
    13561354        ddf_msg(LVL_NOTE, "The %s device has been successfully initialized.",
    1357             dev->name);
     1355            ddf_dev_get_name(dev));
    13581356
    13591357        return EOK;
Note: See TracChangeset for help on using the changeset viewer.