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

Changeset bda60d9 in mainline for uspace/srv/drivers/root/root.c


Ignore:
Timestamp:
2010-03-19T14:40:14Z (12 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master
Children:
d347b53
Parents:
7707954
Message:

adding child device - parts of code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/drivers/root/root.c

    r7707954 rbda60d9  
    4444#include <string.h>
    4545#include <ctype.h>
     46#include <macros.h>
    4647
    4748#include <driver.h>
     
    6364};
    6465
     66static bool add_platform_child(device_t *parent) {
     67        printf(NAME ": adding new child for platform device.\n");
     68       
     69        device_t *platform = NULL;
     70        match_id_t *match_id = NULL;   
     71       
     72        // create new device
     73        if (NULL == (platform = create_device())) {
     74                goto failure;
     75        }
     76       
     77        // TODO - replace this with some better solution
     78        platform->name = STRING(UARCH);
     79        printf(NAME ": the new device's name is %s.\n", platform->name);
     80       
     81        // initialize match id list
     82        if (NULL == (match_id = create_match_id())) {
     83                goto failure;
     84        }
     85        match_id->id = platform->name;
     86        match_id->score = 100;
     87        add_match_id(&platform->match_ids, match_id);   
     88       
     89        // register child  device
     90        if (!child_device_register(platform, parent)) {
     91                goto failure;
     92        }
     93       
     94        return true;
     95       
     96failure:
     97        if (NULL != match_id) {
     98                match_id->id = NULL;
     99        }
     100       
     101        if (NULL != platform) {
     102                platform->name = NULL;
     103                delete_device(platform);               
     104        }
     105       
     106        return false;   
     107}
     108
    65109static bool root_add_device(device_t *dev)
    66110{
    67         printf(NAME ": root_add_device, device handle = %s", dev->handle);
    68         // TODO add root device and register its children
     111        printf(NAME ": root_add_device, device handle = %d\n", dev->handle);
     112       
     113        // register root device's children     
     114        if (!add_platform_child(dev)) {
     115                return false;
     116        }
     117       
    69118        return true;
    70119}
     
    90139 * @}
    91140 */
     141 
Note: See TracChangeset for help on using the changeset viewer.