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

Changeset 26c03dbd in mainline


Ignore:
Timestamp:
2013-12-31T19:44:11Z (8 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
7858acbf
Parents:
7f620e8
Message:

libc,libdrv: Move battery iface to libdrv.

Location:
uspace/lib
Files:
1 deleted
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    r7f620e8 r26c03dbd  
    7171        generic/device/char_dev.c \
    7272        generic/device/clock_dev.c \
    73         generic/device/battery_dev.c \
    7473        generic/device/graph_dev.c \
    7574        generic/device/nic.c \
  • uspace/lib/drv/generic/remote_battery_dev.c

    r7f620e8 r26c03dbd  
    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>
    4040#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}
    4191
    4292static void remote_battery_status_get(ddf_fun_t *, void *, ipc_callid_t,
  • uspace/lib/drv/include/battery_iface.h

    r7f620e8 r26c03dbd  
    3333 */
    3434
    35 #ifndef LIBC_DEVICE_BATTERY_DEV_H_
    36 #define LIBC_DEVICE_BATTERY_DEV_H_
     35#ifndef LIBDRV_BATTERY_IFACE_H_
     36#define LIBDRV_BATTERY_IFACE_H_
    3737
    3838#include <async.h>
  • uspace/lib/drv/include/ops/battery_dev.h

    r7f620e8 r26c03dbd  
    3737
    3838#include "../ddf/driver.h"
    39 #include "device/battery_dev.h"
     39#include "battery_iface.h"
    4040
    4141typedef struct {
Note: See TracChangeset for help on using the changeset viewer.