Changeset b3db669 in mainline
- Timestamp:
- 2012-03-30T20:35:50Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5ef13847
- Parents:
- 0b8a3e7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/time/rtc.c
r0b8a3e7 rb3db669 43 43 #include <ops/clock.h> 44 44 #include <fibril_synch.h> 45 #include <device/hw_res.h> 46 #include <devman.h> 45 47 46 48 #define NAME "RTC" 47 48 static int49 rtc_time_get(ddf_fun_t *fun, time_t *t);50 51 static int52 rtc_time_set(ddf_fun_t *fun, time_t t);53 54 static int55 rtc_dev_add(ddf_dev_t *dev);56 57 58 static ddf_dev_ops_t rtc_dev_ops;59 60 /** The RTC device driver's standard operations */61 static driver_ops_t rtc_ops = {62 .dev_add = rtc_dev_add,63 .dev_remove = NULL,64 };65 66 /** The RTC device driver structure */67 static driver_t rtc_driver = {68 .name = NAME,69 .driver_ops = &rtc_ops,70 };71 72 /** Clock interface */73 static clock_dev_ops_t rtc_clock_dev_ops = {74 .time_get = rtc_time_get,75 .time_set = rtc_time_set,76 };77 49 78 50 typedef struct rtc { … … 86 58 87 59 60 static int 61 rtc_time_get(ddf_fun_t *fun, time_t *t); 62 63 static int 64 rtc_time_set(ddf_fun_t *fun, time_t t); 65 66 static int 67 rtc_dev_add(ddf_dev_t *dev); 68 69 static int 70 rtc_dev_initialize(rtc_t *rtc); 71 72 73 static ddf_dev_ops_t rtc_dev_ops; 74 75 /** The RTC device driver's standard operations */ 76 static driver_ops_t rtc_ops = { 77 .dev_add = rtc_dev_add, 78 .dev_remove = NULL, 79 }; 80 81 /** The RTC device driver structure */ 82 static driver_t rtc_driver = { 83 .name = NAME, 84 .driver_ops = &rtc_ops, 85 }; 86 87 /** Clock interface */ 88 static clock_dev_ops_t rtc_clock_dev_ops = { 89 .time_get = rtc_time_get, 90 .time_set = rtc_time_set, 91 }; 92 88 93 /** Initialize the RTC driver */ 89 94 static void … … 99 104 } 100 105 106 /** Initialize the RTC device 107 * 108 * @param rtc Pointer to the RTC device 109 * 110 * @return EOK on success or a negative error code 111 */ 112 static int 113 rtc_dev_initialize(rtc_t *rtc) 114 { 115 int rc; 116 117 ddf_msg(LVL_DEBUG, "rtc_dev_initialize %s", rtc->dev->name); 118 119 hw_resource_list_t hw_resources; 120 memset(&hw_resources, 0, sizeof(hw_resource_list_t)); 121 122 /* Connect to the parent's driver */ 123 124 rtc->dev->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE, 125 rtc->dev->handle, IPC_FLAG_BLOCKING); 126 if (!rtc->dev->parent_sess) { 127 ddf_msg(LVL_ERROR, "Failed to connect to parent driver\ 128 of device %s.", rtc->dev->name); 129 return ENOENT; 130 } 131 132 /* Get the HW resources */ 133 rc = hw_res_get_resource_list(rtc->dev->parent_sess, &hw_resources); 134 if (rc != EOK) { 135 ddf_msg(LVL_ERROR, "Failed to get HW resources\ 136 for device %s", rtc->dev->name); 137 return rc; 138 } 139 140 return EOK; 141 } 142 101 143 /** Read the current time from the CMOS 102 144 * … … 135 177 { 136 178 rtc_t *rtc; 179 int rc; 137 180 138 181 ddf_msg(LVL_DEBUG, "rtc_dev_add %s (handle = %d)", … … 146 189 fibril_mutex_initialize(&rtc->mutex); 147 190 148 return EOK; 191 rc = rtc_dev_initialize(rtc); 192 if (rc != EOK) 193 return rc; 194 195 return rc; 149 196 } 150 197
Note:
See TracChangeset
for help on using the changeset viewer.