Fork us on GitHub Follow us on Facebook Follow us on Twitter

Ignore:
Timestamp:
2014-01-17T17:26:48Z (8 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
5828554, cf982ff
Parents:
61b5b73d (diff), 66be0288 (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.
Message:

Merge libdrv cleanup.

  • move 'client side' device iface to libdrv (from libc)
  • hide remote_* libdrv headers
  • add a bunch of const qualifiers and change static data to const
  • cleanup: index initialized arrays, array size macro, removes duplicit enums, …

TODO

move hw_res, pio_window and co to libdrv. (too entangled with libc to move right now)
move clock_dev iface to libdrv. (also tied to libc, we need a time provider solution)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_battery_dev.c

    r61b5b73d r476f62c  
    3636#include <errno.h>
    3737#include <ops/battery_dev.h>
    38 #include <device/battery_dev.h>
     38#include <battery_iface.h>
    3939#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 */
     49int
     50battery_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 */
     74int
     75battery_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}
    4091
    4192static void remote_battery_status_get(ddf_fun_t *, void *, ipc_callid_t,
     
    4596
    4697/** 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,
     98static 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,
    50101};
    51102
     
    56107 *
    57108 */
    58 remote_iface_t remote_battery_dev_iface = {
    59         .method_count = sizeof(remote_battery_dev_iface_ops) /
    60             sizeof(remote_iface_func_ptr_t),
     109const remote_iface_t remote_battery_dev_iface = {
     110        .method_count = ARRAY_SIZE(remote_battery_dev_iface_ops),
    61111        .methods = remote_battery_dev_iface_ops,
    62112};
Note: See TracChangeset for help on using the changeset viewer.