Changeset 8b863a62 in mainline for uspace/lib/drv/generic/remote_battery_dev.c
- Timestamp:
- 2014-04-16T17:14:06Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f857e8b
- Parents:
- dba3e2c (diff), 70b570c (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/lib/drv/generic/remote_battery_dev.c
rdba3e2c r8b863a62 36 36 #include <errno.h> 37 37 #include <ops/battery_dev.h> 38 #include < device/battery_dev.h>38 #include <battery_iface.h> 39 39 #include <ddf/driver.h> 40 #include <macros.h> 41 42 /** Read the current battery status from the device 43 * 44 * @param sess Session of the device 45 * @param status Current status of the battery 46 * 47 * @return EOK on success or a negative error code 48 */ 49 int 50 battery_status_get(async_sess_t *sess, battery_status_t *batt_status) 51 { 52 sysarg_t status; 53 54 async_exch_t *exch = async_exchange_begin(sess); 55 56 int const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE), 57 BATTERY_STATUS_GET, &status); 58 59 async_exchange_end(exch); 60 61 if (rc == EOK) 62 *batt_status = (battery_status_t) status; 63 64 return rc; 65 } 66 67 /** Read the current battery charge level from the device 68 * 69 * @param sess Session of the device 70 * @param level Battery charge level (0 - 100) 71 * 72 * @return EOK on success or a negative error code 73 */ 74 int 75 battery_charge_level_get(async_sess_t *sess, int *level) 76 { 77 sysarg_t charge_level; 78 79 async_exch_t *exch = async_exchange_begin(sess); 80 81 int const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE), 82 BATTERY_CHARGE_LEVEL_GET, &charge_level); 83 84 async_exchange_end(exch); 85 86 if (rc == EOK) 87 *level = (int) charge_level; 88 89 return rc; 90 } 40 91 41 92 static void remote_battery_status_get(ddf_fun_t *, void *, ipc_callid_t, … … 45 96 46 97 /** Remote battery interface operations */ 47 static remote_iface_func_ptr_t remote_battery_dev_iface_ops[] = {48 &remote_battery_status_get,49 &remote_battery_charge_level_get,98 static const remote_iface_func_ptr_t remote_battery_dev_iface_ops[] = { 99 [BATTERY_STATUS_GET] = remote_battery_status_get, 100 [BATTERY_CHARGE_LEVEL_GET] = remote_battery_charge_level_get, 50 101 }; 51 102 … … 56 107 * 57 108 */ 58 remote_iface_t remote_battery_dev_iface = { 59 .method_count = sizeof(remote_battery_dev_iface_ops) / 60 sizeof(remote_iface_func_ptr_t), 109 const remote_iface_t remote_battery_dev_iface = { 110 .method_count = ARRAY_SIZE(remote_battery_dev_iface_ops), 61 111 .methods = remote_battery_dev_iface_ops, 62 112 };
Note:
See TracChangeset
for help on using the changeset viewer.