Changeset 6f445a67 in mainline for uspace/drv/time/cmos-rtc/cmos-rtc.c


Ignore:
Timestamp:
2012-08-20T20:46:43Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
60af6fc2
Parents:
1789023
Message:

Fix the rtc driver to support changes made by rev jiri@wiwaxia-20120817115220-5ffx5nsonz5y3ejj

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/time/cmos-rtc/cmos-rtc.c

    r1789023 r6f445a67  
    4848#include <fibril_synch.h>
    4949#include <device/hw_res.h>
    50 #include <devman.h>
    5150#include <macros.h>
    5251#include <ipc/clock_ctl.h>
     
    5857
    5958#define REG_COUNT 2
    60 
    61 #define RTC_FROM_FNODE(fnode)  ((rtc_t *) ((fnode)->dev->driver_data))
    62 #define RTC_FROM_DEV(devnode)  ((rtc_t *) ((devnode)->driver_data))
    6359
    6460typedef struct rtc {
     
    7773} rtc_t;
    7874
     75static rtc_t *dev_rtc(ddf_dev_t *dev);
     76static rtc_t *fun_rtc(ddf_fun_t *fun);
    7977static int  rtc_time_get(ddf_fun_t *fun, struct tm *t);
    8078static int  rtc_time_set(ddf_fun_t *fun, struct tm *t);
     
    116114};
    117115
     116/** Obtain soft state structure from device node */
     117static rtc_t *
     118dev_rtc(ddf_dev_t *dev)
     119{
     120        return ddf_dev_data_get(dev);
     121}
     122
     123/** Obtain soft state structure from function node */
     124static rtc_t *
     125fun_rtc(ddf_fun_t *fun)
     126{
     127        return dev_rtc(ddf_fun_get_dev(fun));
     128}
     129
    118130/** Initialize the RTC driver */
    119131static void
     
    136148rtc_dev_cleanup(rtc_t *rtc)
    137149{
    138         if (rtc->dev->parent_sess) {
    139                 async_hangup(rtc->dev->parent_sess);
    140                 rtc->dev->parent_sess = NULL;
    141         }
    142150}
    143151
     
    155163
    156164                ddf_msg(LVL_ERROR, "Cannot map the port %#" PRIx32
    157                     " for device %s", rtc->io_addr, rtc->dev->name);
     165                    " for device %s", rtc->io_addr, ddf_dev_get_name(rtc->dev));
    158166                return false;
    159167        }
     
    175183        hw_resource_t *res;
    176184        bool ioport = false;
    177 
    178         ddf_msg(LVL_DEBUG, "rtc_dev_initialize %s", rtc->dev->name);
     185        async_sess_t *parent_sess;
     186
     187        ddf_msg(LVL_DEBUG, "rtc_dev_initialize %s", ddf_dev_get_name(rtc->dev));
    179188
    180189        hw_resource_list_t hw_resources;
     
    183192        /* Connect to the parent's driver */
    184193
    185         rtc->dev->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE,
    186             rtc->dev->handle, IPC_FLAG_BLOCKING);
    187         if (!rtc->dev->parent_sess) {
     194        parent_sess = ddf_dev_parent_sess_create(rtc->dev, EXCHANGE_SERIALIZE);
     195        if (!parent_sess) {
    188196                ddf_msg(LVL_ERROR, "Failed to connect to parent driver\
    189                     of device %s.", rtc->dev->name);
     197                    of device %s.", ddf_dev_get_name(rtc->dev));
    190198                rc = ENOENT;
    191199                goto error;
     
    193201
    194202        /* Get the HW resources */
    195         rc = hw_res_get_resource_list(rtc->dev->parent_sess, &hw_resources);
     203        rc = hw_res_get_resource_list(parent_sess, &hw_resources);
    196204        if (rc != EOK) {
    197205                ddf_msg(LVL_ERROR, "Failed to get HW resources\
    198                     for device %s", rtc->dev->name);
     206                    for device %s", ddf_dev_get_name(rtc->dev));
    199207                goto error;
    200208        }
     
    206214                        if (res->res.io_range.size < REG_COUNT) {
    207215                                ddf_msg(LVL_ERROR, "I/O range assigned to \
    208                                     device %s is too small", rtc->dev->name);
     216                                    device %s is too small",
     217                                    ddf_dev_get_name(rtc->dev));
    209218                                rc = ELIMIT;
    210219                                goto error;
     
    213222                        ioport = true;
    214223                        ddf_msg(LVL_NOTE, "Device %s was assigned I/O address \
    215                             0x%x", rtc->dev->name, rtc->io_addr);
     224                            0x%x", ddf_dev_get_name(rtc->dev), rtc->io_addr);
    216225                }
    217226        }
     
    220229                /* No I/O address assigned to this device */
    221230                ddf_msg(LVL_ERROR, "Missing HW resource for device %s",
    222                     rtc->dev->name);
     231                    ddf_dev_get_name(rtc->dev));
    223232                rc = ENOENT;
    224233                goto error;
     
    287296        bool bcd_mode;
    288297        bool pm_mode = false;
    289         rtc_t *rtc = RTC_FROM_FNODE(fun);
     298        rtc_t *rtc = fun_rtc(fun);
    290299
    291300        if (boottime != 0) {
     
    389398        int  reg_a;
    390399        int  epoch;
    391         rtc_t *rtc = RTC_FROM_FNODE(fun);
     400        rtc_t *rtc = fun_rtc(fun);
    392401
    393402        /* Try to normalize the content of the tm structure */
     
    486495
    487496        ddf_msg(LVL_DEBUG, "rtc_dev_add %s (handle = %d)",
    488             dev->name, (int) dev->handle);
     497            ddf_dev_get_name(dev), (int) ddf_dev_get_handle(dev));
    489498
    490499        rtc = ddf_dev_data_alloc(dev, sizeof(rtc_t));
     
    513522        }
    514523
    515         fun->ops = &rtc_dev_ops;
     524        ddf_fun_set_ops(fun, &rtc_dev_ops);
    516525        rc = ddf_fun_bind(fun);
    517526        if (rc != EOK) {
     
    525534
    526535        ddf_msg(LVL_NOTE, "Device %s successfully initialized",
    527             dev->name);
     536            ddf_dev_get_name(dev));
    528537
    529538        return rc;
     
    546555rtc_dev_remove(ddf_dev_t *dev)
    547556{
    548         rtc_t *rtc = RTC_FROM_DEV(dev);
     557        rtc_t *rtc = dev_rtc(dev);
    549558        int rc;
    550559
     
    573582{
    574583        sysarg_t method = IPC_GET_IMETHOD(*call);
    575         rtc_t *rtc = RTC_FROM_FNODE(fun);
     584        rtc_t *rtc = fun_rtc(fun);
    576585        bool batt_ok;
    577586
     
    598607{
    599608        int rc;
    600         rtc_t *rtc = RTC_FROM_FNODE(fun);
     609        rtc_t *rtc = fun_rtc(fun);
    601610
    602611        fibril_mutex_lock(&rtc->mutex);
Note: See TracChangeset for help on using the changeset viewer.