Changeset 7eaeec1 in mainline for uspace/drv/nic/rtl8139/driver.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/rtl8139/driver.c
rf3a37e28 r7eaeec1 27 27 */ 28 28 29 /* XXX Fix this */ 30 #define _DDF_DATA_IMPLANT 31 29 32 #include <assert.h> 30 33 #include <errno.h> … … 212 215 rtl8139_regs_lock(rtl8139->io_port); 213 216 217 async_sess_t *pci_sess = 218 ddf_dev_parent_sess_get(nic_get_ddf_dev(rtl8139->nic_data)); 219 214 220 if (bit_val) { 215 async_sess_t *pci_sess =216 nic_get_ddf_dev(rtl8139->nic_data)->parent_sess;217 221 uint8_t pmen; 218 222 pci_config_space_read_8(pci_sess, 0x55, &pmen); 219 223 pci_config_space_write_8(pci_sess, 0x55, pmen | 1 | (1 << 7)); 220 224 } else { 221 async_sess_t *pci_sess =222 nic_get_ddf_dev(rtl8139->nic_data)->parent_sess;223 225 uint8_t pmen; 224 226 pci_config_space_read_8(pci_sess, 0x55, &pmen); … … 1052 1054 assert(dev); 1053 1055 1054 if (d ev->driver_data)1056 if (ddf_dev_data_get(dev)) 1055 1057 nic_unbind_and_destroy(dev); 1056 1057 if (dev->parent_sess != NULL) {1058 async_hangup(dev->parent_sess);1059 dev->parent_sess = NULL;1060 }1061 1058 } 1062 1059 … … 1080 1077 1081 1078 if (hw_resources->irqs.count != 1) { 1082 ddf_msg(LVL_ERROR, "%s device: unexpected irq count", d ev->name);1079 ddf_msg(LVL_ERROR, "%s device: unexpected irq count", ddf_dev_get_name(dev)); 1083 1080 return EINVAL; 1084 1081 }; 1085 1082 if (hw_resources->io_ranges.count != 1) { 1086 ddf_msg(LVL_ERROR, "%s device: unexpected io ranges count", d ev->name);1083 ddf_msg(LVL_ERROR, "%s device: unexpected io ranges count", ddf_dev_get_name(dev)); 1087 1084 return EINVAL; 1088 1085 } 1089 1086 1090 1087 rtl8139->irq = hw_resources->irqs.irqs[0]; 1091 ddf_msg(LVL_DEBUG, "%s device: irq 0x%x assigned", d ev->name, rtl8139->irq);1088 ddf_msg(LVL_DEBUG, "%s device: irq 0x%x assigned", ddf_dev_get_name(dev), rtl8139->irq); 1092 1089 1093 1090 rtl8139->io_addr = IOADDR_TO_PTR(hw_resources->io_ranges.ranges[0].address); 1094 1091 if (hw_resources->io_ranges.ranges[0].size < RTL8139_IO_SIZE) { 1095 1092 ddf_msg(LVL_ERROR, "i/o range assigned to the device " 1096 "%s is too small.", d ev->name);1093 "%s is too small.", ddf_dev_get_name(dev)); 1097 1094 return EINVAL; 1098 1095 } 1099 ddf_msg(LVL_DEBUG, "%s device: i/o addr %p assigned.", d ev->name, rtl8139->io_addr);1096 ddf_msg(LVL_DEBUG, "%s device: i/o addr %p assigned.", ddf_dev_get_name(dev), rtl8139->io_addr); 1100 1097 1101 1098 return EOK; … … 1192 1189 static int rtl8139_device_initialize(ddf_dev_t *dev) 1193 1190 { 1194 ddf_msg(LVL_DEBUG, "rtl8139_dev_initialize %s", d ev->name);1191 ddf_msg(LVL_DEBUG, "rtl8139_dev_initialize %s", ddf_dev_get_name(dev)); 1195 1192 1196 1193 int ret = EOK; … … 1201 1198 rtl8139_t *rtl8139 = rtl8139_create_dev_data(dev); 1202 1199 if (rtl8139 == NULL) { 1203 ddf_msg(LVL_ERROR, "Not enough memory for initializing %s.", d ev->name);1200 ddf_msg(LVL_ERROR, "Not enough memory for initializing %s.", ddf_dev_get_name(dev)); 1204 1201 return ENOMEM; 1205 1202 } … … 1246 1243 static int rtl8139_pio_enable(ddf_dev_t *dev) 1247 1244 { 1248 ddf_msg(LVL_DEBUG, NAME ": rtl8139_pio_enable %s", d ev->name);1245 ddf_msg(LVL_DEBUG, NAME ": rtl8139_pio_enable %s", ddf_dev_get_name(dev)); 1249 1246 1250 1247 rtl8139_t *rtl8139 = nic_get_specific(nic_get_from_ddf_dev(dev)); … … 1253 1250 if (pio_enable(rtl8139->io_addr, RTL8139_IO_SIZE, &rtl8139->io_port)) { 1254 1251 ddf_msg(LVL_ERROR, "Cannot gain the port %lx for device %s.", rtl8139->io_addr, 1255 d ev->name);1252 ddf_dev_get_name(dev)); 1256 1253 return EADDRNOTAVAIL; 1257 1254 } … … 1299 1296 1300 1297 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)); 1302 1300 1303 1301 /* Init device structure for rtl8139 */ … … 1340 1338 } 1341 1339 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); 1344 1342 1345 1343 rc = ddf_fun_bind(fun); … … 1355 1353 1356 1354 ddf_msg(LVL_NOTE, "The %s device has been successfully initialized.", 1357 d ev->name);1355 ddf_dev_get_name(dev)); 1358 1356 1359 1357 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.