Changeset 4b44de57 in mainline
- Timestamp:
- 2012-04-01T20:19:01Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 28ca043f
- Parents:
- 0883de8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/time/cmos-rtc/cmos-rtc.c
r0883de8 r4b44de57 79 79 rtc_pio_enable(rtc_t *rtc); 80 80 81 static void 82 rtc_dev_cleanup(rtc_t *rtc); 83 81 84 82 85 static ddf_dev_ops_t rtc_dev_ops; … … 113 116 } 114 117 118 /** Clean up the RTC soft state 119 * 120 * @param rtc The RTC device 121 */ 122 static void 123 rtc_dev_cleanup(rtc_t *rtc) 124 { 125 if (rtc->dev->parent_sess) { 126 async_hangup(rtc->dev->parent_sess); 127 rtc->dev->parent_sess = NULL; 128 } 129 } 130 115 131 /** Enable the I/O ports of the device 116 132 * … … 142 158 rtc_dev_initialize(rtc_t *rtc) 143 159 { 144 /* XXX Do cleanup in case of failure */145 160 int rc; 146 161 size_t i; … … 160 175 ddf_msg(LVL_ERROR, "Failed to connect to parent driver\ 161 176 of device %s.", rtc->dev->name); 162 return ENOENT; 177 rc = ENOENT; 178 goto error; 163 179 } 164 180 … … 168 184 ddf_msg(LVL_ERROR, "Failed to get HW resources\ 169 185 for device %s", rtc->dev->name); 170 return rc;186 goto error; 171 187 } 172 188 … … 186 202 ddf_msg(LVL_ERROR, "Missing HW resource for device %s", 187 203 rtc->dev->name); 188 return ENOENT; 204 rc = ENOENT; 205 goto error; 189 206 } 190 207 … … 192 209 193 210 return EOK; 211 212 error: 213 rtc_dev_cleanup(rtc); 214 hw_res_clean_resource_list(&hw_resources); 215 216 return rc; 194 217 } 195 218 … … 230 253 { 231 254 rtc_t *rtc; 232 ddf_fun_t *fun ;255 ddf_fun_t *fun = NULL; 233 256 int rc; 257 bool need_cleanup = false; 234 258 235 259 ddf_msg(LVL_DEBUG, "rtc_dev_add %s (handle = %d)", … … 245 269 rc = rtc_dev_initialize(rtc); 246 270 if (rc != EOK) 247 return rc; 248 249 /* XXX Need cleanup */ 250 if (!rtc_pio_enable(rtc)) 251 return EADDRNOTAVAIL; 271 goto error; 272 273 need_cleanup = true; 274 275 if (!rtc_pio_enable(rtc)) { 276 rc = EADDRNOTAVAIL; 277 goto error; 278 } 252 279 253 280 fun = ddf_fun_create(dev, fun_exposed, "a"); 254 281 if (!fun) { 255 282 ddf_msg(LVL_ERROR, "Failed creating function"); 256 return ENOENT; 283 rc = ENOENT; 284 goto error; 257 285 } 258 286 … … 261 289 if (rc != EOK) { 262 290 ddf_msg(LVL_ERROR, "Failed binding function"); 263 return rc;291 goto error; 264 292 } 265 293 … … 271 299 dev->name); 272 300 301 return rc; 302 303 error: 304 if (fun) 305 ddf_fun_destroy(fun); 306 if (need_cleanup) 307 rtc_dev_cleanup(rtc); 273 308 return rc; 274 309 }
Note:
See TracChangeset
for help on using the changeset viewer.