Changeset 923b2eba in mainline
- Timestamp:
- 2012-04-03T08:10:43Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2a5171db
- Parents:
- 8d2963d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/time/cmos-rtc/cmos-rtc.c
r8d2963d r923b2eba 49 49 50 50 #define REG_COUNT 2 51 52 #define RTC_FROM_FNODE(fnode) ((rtc_t *) ((fnode)->dev->driver_data)) 51 53 52 54 typedef struct rtc { … … 61 63 /** The I/O port used to access the CMOS registers */ 62 64 ioport8_t *port; 65 /** true if a client is connected to the device */ 66 bool client_connected; 63 67 } rtc_t; 64 68 … … 81 85 static void 82 86 rtc_dev_cleanup(rtc_t *rtc); 87 88 static int 89 rtc_open(ddf_fun_t *fun); 83 90 84 91 … … 109 116 ddf_log_init(NAME, LVL_ERROR); 110 117 111 rtc_dev_ops.open = NULL; /* XXX */118 rtc_dev_ops.open = rtc_open; 112 119 rtc_dev_ops.close = NULL; /* XXX */ 113 120 … … 302 309 ddf_fun_add_to_category(fun, "clock"); 303 310 311 rtc->client_connected = false; 312 304 313 ddf_msg(LVL_NOTE, "Device %s successfully initialized", 305 314 dev->name); … … 315 324 } 316 325 326 /** Open the device 327 * 328 * @param fun The function node 329 * 330 * @return EOK on success or a negative error code 331 */ 332 static int 333 rtc_open(ddf_fun_t *fun) 334 { 335 int rc; 336 rtc_t *rtc = RTC_FROM_FNODE(fun); 337 338 fibril_mutex_lock(&rtc->mutex); 339 340 if (rtc->client_connected) 341 rc = EBUSY; 342 else { 343 rc = EOK; 344 rtc->client_connected = true; 345 } 346 347 fibril_mutex_unlock(&rtc->mutex); 348 return rc; 349 } 350 317 351 int 318 352 main(int argc, char **argv)
Note:
See TracChangeset
for help on using the changeset viewer.