Changeset 8b1e15ac in mainline for uspace/drv/rootpc/rootpc.c


Ignore:
Timestamp:
2011-02-11T22:26:36Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
68414f4a
Parents:
1b367b4
Message:

Finish splitting device node: devman client in C library, drv library. Update device drivers accordingly.

File:
1 edited

Legend:

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

    r1b367b4 r8b1e15ac  
    5555#define NAME "rootpc"
    5656
    57 typedef struct rootpc_child_dev_data {
     57typedef struct rootpc_fun_data {
    5858        hw_resource_list_t hw_resources;
    59 } rootpc_child_dev_data_t;
     59} rootpc_fun_data_t;
    6060
    6161static int rootpc_add_device(device_t *dev);
     
    8282};
    8383
    84 static rootpc_child_dev_data_t pci_data = {
     84static rootpc_fun_data_t pci_data = {
    8585        .hw_resources = {
    8686                1,
     
    8989};
    9090
    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;
     91static hw_resource_list_t *rootpc_get_fun_resources(function_t *fun)
     92{
     93        rootpc_fun_data_t *data;
     94       
     95        data = (rootpc_fun_data_t *) fun->driver_data;
    9696        if (NULL == data)
    9797                return NULL;
     
    100100}
    101101
    102 static bool rootpc_enable_child_interrupt(device_t *dev)
     102static bool rootpc_enable_fun_interrupt(function_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_fun_resources,
     111        &rootpc_enable_fun_interrupt
    112112};
    113113
    114114/* Initialized in root_pc_init() function. */
    115 static device_ops_t rootpc_child_ops;
     115static device_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(device_t *parent, const char *name, const char *str_match_id,
     119    rootpc_fun_data_t *drv_data)
     120{
     121        printf(NAME ": adding new function '%s'.\n", name);
     122       
     123        function_t *fun = NULL;
    124124        match_id_t *match_id = NULL;
    125125       
    126126        /* Create new device. */
    127         child = create_device();
    128         if (NULL == child)
     127        fun = create_function();
     128        if (fun == NULL)
    129129                goto failure;
    130130       
    131         child->name = name;
    132         child->driver_data = drv_data;
     131        fun->name = name;
     132        fun->driver_data = drv_data;
     133        fun->ftype = fun_inner;
    133134       
    134135        /* Initialize match id list */
     
    139140        match_id->id = str_match_id;
    140141        match_id->score = 100;
    141         add_match_id(&child->match_ids, match_id);
     142        add_match_id(&fun->match_ids, match_id);
    142143       
    143144        /* 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))
     145        fun->ops = &rootpc_fun_ops;
     146       
     147        /* Register function. */
     148        if (EOK != register_function(fun, parent))
    148149                goto failure;
     150        printf(NAME ": registered function handle = %u\n", fun->handle);
    149151       
    150152        return true;
     
    154156                match_id->id = NULL;
    155157       
    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);
     158        if (NULL != fun) {
     159                fun->name = NULL;
     160                delete_function(fun);
     161        }
     162       
     163        printf(NAME ": failed to add function '%s'.\n", name);
    162164       
    163165        return false;
    164166}
    165167
    166 static bool rootpc_add_children(device_t *dev)
    167 {
    168         return rootpc_add_child(dev, "pci0", "intel_pci", &pci_data);
     168static bool rootpc_add_functions(device_t *dev)
     169{
     170        return rootpc_add_fun(dev, "pci0", "intel_pci", &pci_data);
    169171}
    170172
     
    180182            (int)dev->handle);
    181183       
    182         /* Register child devices. */
    183         if (!rootpc_add_children(dev)) {
    184                 printf(NAME ": failed to add child devices for PC platform.\n");
     184        /* Register functions. */
     185        if (!rootpc_add_functions(dev)) {
     186                printf(NAME ": failed to add functions for PC platform.\n");
    185187        }
    186188       
     
    190192static void root_pc_init(void)
    191193{
    192         rootpc_child_ops.interfaces[HW_RES_DEV_IFACE] = &child_hw_res_ops;
     194        rootpc_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;
    193195}
    194196
Note: See TracChangeset for help on using the changeset viewer.