Changeset 3de67b4c in mainline for uspace/drv/block/ata_bd/main.c
- Timestamp:
- 2013-06-27T20:43:29Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4339f09
- Parents:
- 9f391e9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/block/ata_bd/main.c
r9f391e9 r3de67b4c 36 36 #include <ddf/driver.h> 37 37 #include <ddf/log.h> 38 #include <device/hw_res_parsed.h> 38 39 39 40 #include "ata_bd.h" … … 61 62 }; 62 63 64 static int ata_get_res(ddf_dev_t *dev, ata_base_t *ata_res) 65 { 66 async_sess_t *parent_sess; 67 hw_res_list_parsed_t hw_res; 68 int rc; 69 70 parent_sess = ddf_dev_parent_sess_create(dev, 71 EXCHANGE_SERIALIZE); 72 if (parent_sess == NULL) 73 return ENOMEM; 74 75 hw_res_list_parsed_init(&hw_res); 76 rc = hw_res_get_list_parsed(parent_sess, &hw_res, 0); 77 if (rc != EOK) 78 return rc; 79 80 if (hw_res.io_ranges.count != 2) { 81 rc = EINVAL; 82 goto error; 83 return EINVAL; 84 } 85 86 ata_res->cmd = hw_res.io_ranges.ranges[0].address; 87 ata_res->ctl = hw_res.io_ranges.ranges[1].address; 88 89 if (hw_res.io_ranges.ranges[0].size < sizeof(ata_ctl_t)) { 90 rc = EINVAL; 91 goto error; 92 } 93 94 if (hw_res.io_ranges.ranges[1].size < sizeof(ata_cmd_t)) { 95 rc = EINVAL; 96 goto error; 97 } 98 99 return EOK; 100 error: 101 hw_res_list_parsed_clean(&hw_res); 102 return rc; 103 } 63 104 64 105 /** Add new device … … 70 111 { 71 112 ata_ctrl_t *ctrl; 72 int rc; 113 ata_base_t res; 114 int rc; 115 116 rc = ata_get_res(dev, &res); 117 if (rc != EOK) { 118 ddf_msg(LVL_ERROR, "Invalid HW resource configuration."); 119 return EINVAL; 120 } 73 121 74 122 ctrl = ddf_dev_data_alloc(dev, sizeof(ata_ctrl_t)); … … 81 129 ctrl->dev = dev; 82 130 83 rc = ata_ctrl_init(ctrl );131 rc = ata_ctrl_init(ctrl, &res); 84 132 if (rc != EOK) { 85 133 ddf_msg(LVL_ERROR, "Failed initializing ATA controller.");
Note:
See TracChangeset
for help on using the changeset viewer.