Changeset 92574f4 in mainline for uspace/drv/rootpc/rootpc.c


Ignore:
Timestamp:
2011-02-24T12:03:27Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e7b7ebd5
Parents:
4837092 (diff), a80849c (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:

Merged development (changes in DDF, etc.).

Conflicts in uspace/drv/usbkbd/main.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/rootpc/rootpc.c

    r4837092 r92574f4  
    4646#include <macros.h>
    4747
    48 #include <driver.h>
     48#include <ddf/driver.h>
    4949#include <devman.h>
    5050#include <ipc/devman.h>
     
    5555#define NAME "rootpc"
    5656
    57 typedef struct rootpc_child_dev_data {
     57/** Obtain function soft-state from DDF function node */
     58#define ROOTPC_FUN(fnode) ((rootpc_fun_t *) (fnode)->driver_data)
     59
     60typedef struct rootpc_fun {
    5861        hw_resource_list_t hw_resources;
    59 } rootpc_child_dev_data_t;
    60 
    61 static int rootpc_add_device(device_t *dev);
     62} rootpc_fun_t;
     63
     64static int rootpc_add_device(ddf_dev_t *dev);
    6265static void root_pc_init(void);
    6366
     
    8285};
    8386
    84 static rootpc_child_dev_data_t pci_data = {
     87static rootpc_fun_t pci_data = {
    8588        .hw_resources = {
    8689                1,
     
    8992};
    9093
    91 static hw_resource_list_t *rootpc_get_child_resources(device_t *dev)
    92 {
    93         rootpc_child_dev_data_t *data;
    94        
    95         data = (rootpc_child_dev_data_t *) dev->driver_data;
    96         if (NULL == data)
    97                 return NULL;
    98        
    99         return &data->hw_resources;
    100 }
    101 
    102 static bool rootpc_enable_child_interrupt(device_t *dev)
     94static hw_resource_list_t *rootpc_get_resources(ddf_fun_t *fnode)
     95{
     96        rootpc_fun_t *fun = ROOTPC_FUN(fnode);
     97       
     98        assert(fun != NULL);
     99        return &fun->hw_resources;
     100}
     101
     102static bool rootpc_enable_interrupt(ddf_fun_t *fun)
    103103{
    104104        /* TODO */
     
    107107}
    108108
    109 static hw_res_ops_t child_hw_res_ops = {
    110         &rootpc_get_child_resources,
    111         &rootpc_enable_child_interrupt
     109static hw_res_ops_t fun_hw_res_ops = {
     110        &rootpc_get_resources,
     111        &rootpc_enable_interrupt
    112112};
    113113
    114114/* Initialized in root_pc_init() function. */
    115 static device_ops_t rootpc_child_ops;
     115static ddf_dev_ops_t rootpc_fun_ops;
    116116
    117117static bool
    118 rootpc_add_child(device_t *parent, const char *name, const char *str_match_id,
    119     rootpc_child_dev_data_t *drv_data)
    120 {
    121         printf(NAME ": adding new child device '%s'.\n", name);
    122        
    123         device_t *child = NULL;
     118rootpc_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id,
     119    rootpc_fun_t *fun)
     120{
     121        printf(NAME ": adding new function '%s'.\n", name);
     122       
     123        ddf_fun_t *fnode = NULL;
    124124        match_id_t *match_id = NULL;
    125125       
    126126        /* Create new device. */
    127         child = create_device();
    128         if (NULL == child)
     127        fnode = ddf_fun_create(dev, fun_inner, name);
     128        if (fnode == NULL)
    129129                goto failure;
    130130       
    131         child->name = name;
    132         child->driver_data = drv_data;
     131        fnode->driver_data = fun;
    133132       
    134133        /* Initialize match id list */
    135134        match_id = create_match_id();
    136         if (NULL == match_id)
     135        if (match_id == NULL)
    137136                goto failure;
    138137       
    139138        match_id->id = str_match_id;
    140139        match_id->score = 100;
    141         add_match_id(&child->match_ids, match_id);
     140        add_match_id(&fnode->match_ids, match_id);
    142141       
    143142        /* Set provided operations to the device. */
    144         child->ops = &rootpc_child_ops;
    145        
    146         /* Register child device. */
    147         if (EOK != child_device_register(child, parent))
     143        fnode->ops = &rootpc_fun_ops;
     144       
     145        /* Register function. */
     146        if (ddf_fun_bind(fnode) != EOK) {
     147                printf(NAME ": error binding function %s.\n", name);
    148148                goto failure;
     149        }
    149150       
    150151        return true;
    151152       
    152153failure:
    153         if (NULL != match_id)
     154        if (match_id != NULL)
    154155                match_id->id = NULL;
    155156       
    156         if (NULL != child) {
    157                 child->name = NULL;
    158                 delete_device(child);
    159         }
    160        
    161         printf(NAME ": failed to add child device '%s'.\n", name);
     157        if (fnode != NULL)
     158                ddf_fun_destroy(fnode);
     159       
     160        printf(NAME ": failed to add function '%s'.\n", name);
    162161       
    163162        return false;
    164163}
    165164
    166 static bool rootpc_add_children(device_t *dev)
    167 {
    168         return rootpc_add_child(dev, "pci0", "intel_pci", &pci_data);
     165static bool rootpc_add_functions(ddf_dev_t *dev)
     166{
     167        return rootpc_add_fun(dev, "pci0", "intel_pci", &pci_data);
    169168}
    170169
     
    175174 * @return              Zero on success, negative error number otherwise.
    176175 */
    177 static int rootpc_add_device(device_t *dev)
     176static int rootpc_add_device(ddf_dev_t *dev)
    178177{
    179178        printf(NAME ": rootpc_add_device, device handle = %d\n",
    180179            (int)dev->handle);
    181180       
    182         /* Register child devices. */
    183         if (!rootpc_add_children(dev)) {
    184                 printf(NAME ": failed to add child devices for PC platform.\n");
     181        /* Register functions. */
     182        if (!rootpc_add_functions(dev)) {
     183                printf(NAME ": failed to add functions for PC platform.\n");
    185184        }
    186185       
     
    190189static void root_pc_init(void)
    191190{
    192         rootpc_child_ops.interfaces[HW_RES_DEV_IFACE] = &child_hw_res_ops;
     191        rootpc_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;
    193192}
    194193
     
    197196        printf(NAME ": HelenOS PC platform driver\n");
    198197        root_pc_init();
    199         return driver_main(&rootpc_driver);
     198        return ddf_driver_main(&rootpc_driver);
    200199}
    201200
Note: See TracChangeset for help on using the changeset viewer.