Changeset 4006447 in mainline for uspace/drv/root/root.c


Ignore:
Timestamp:
2010-12-06T20:03:54Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c0bd08d
Parents:
b38dfd8 (diff), 463e734 (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:

Merge from lp:~vojtech-horky/helenos/ddf-fixes.

File:
1 edited

Legend:

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

    rb38dfd8 r4006447  
    11/*
    22 * Copyright (c) 2010 Lenka Trochtova
     3 * Copyright (c) 2010 Vojtech Horky
    34 * All rights reserved.
    45 *
     
    5354#define NAME "root"
    5455
     56#define PLATFORM_DEVICE_NAME "hw"
     57#define PLATFORM_DEVICE_MATCH_ID STRING(UARCH)
     58#define PLATFORM_DEVICE_MATCH_SCORE 100
     59
     60#define VIRTUAL_DEVICE_NAME "virt"
     61#define VIRTUAL_DEVICE_MATCH_ID "rootvirt"
     62#define VIRTUAL_DEVICE_MATCH_SCORE 100
     63
    5564static int root_add_device(device_t *dev);
    5665
     
    6675};
    6776
     77/** Create the device which represents the root of virtual device tree.
     78 *
     79 * @param parent Parent of the newly created device.
     80 * @return Error code.
     81 */
     82static int add_virtual_root_child(device_t *parent)
     83{
     84        printf(NAME ": adding new child for virtual devices.\n");
     85        printf(NAME ":   device node is `%s' (%d %s)\n", VIRTUAL_DEVICE_NAME,
     86            VIRTUAL_DEVICE_MATCH_SCORE, VIRTUAL_DEVICE_MATCH_ID);
     87
     88        int res = child_device_register_wrapper(parent, VIRTUAL_DEVICE_NAME,
     89            VIRTUAL_DEVICE_MATCH_ID, VIRTUAL_DEVICE_MATCH_SCORE);
     90
     91        return res;
     92}
     93
    6894/** Create the device which represents the root of HW device tree.
    6995 *
     
    74100{
    75101        printf(NAME ": adding new child for platform device.\n");
     102        printf(NAME ":   device node is `%s' (%d %s)\n", PLATFORM_DEVICE_NAME,
     103            PLATFORM_DEVICE_MATCH_SCORE, PLATFORM_DEVICE_MATCH_ID);
    76104       
    77         int res = EOK;
    78         device_t *platform = NULL;
    79         match_id_t *match_id = NULL;
    80        
    81         /* Create new device. */
    82         platform = create_device();
    83         if (NULL == platform) {
    84                 res = ENOMEM;
    85                 goto failure;
    86         }       
    87        
    88         platform->name = "hw";
    89         printf(NAME ": the new device's name is %s.\n", platform->name);
    90        
    91         /* Initialize match id list. */
    92         match_id = create_match_id();
    93         if (NULL == match_id) {
    94                 res = ENOMEM;
    95                 goto failure;
    96         }
    97        
    98         /* TODO - replace this with some better solution (sysinfo ?) */
    99         match_id->id = STRING(UARCH);
    100         match_id->score = 100;
    101         add_match_id(&platform->match_ids, match_id);
    102        
    103         /* Register child device. */
    104         res = child_device_register(platform, parent);
    105         if (EOK != res)
    106                 goto failure;
    107        
    108         return res;
    109        
    110 failure:
    111         if (NULL != match_id)
    112                 match_id->id = NULL;
    113        
    114         if (NULL != platform) {
    115                 platform->name = NULL;
    116                 delete_device(platform);
    117         }
    118        
     105        int res = child_device_register_wrapper(parent, PLATFORM_DEVICE_NAME,
     106            PLATFORM_DEVICE_MATCH_ID, PLATFORM_DEVICE_MATCH_SCORE);
     107
    119108        return res;
    120109}
     
    130119            dev->handle);
    131120       
     121        /*
     122         * Register virtual devices root.
     123         * We ignore error occurrence because virtual devices shall not be
     124         * vital for the system.
     125         */
     126        add_virtual_root_child(dev);
     127
    132128        /* Register root device's children. */
    133129        int res = add_platform_child(dev);
Note: See TracChangeset for help on using the changeset viewer.