Changeset 68414f4a in mainline for uspace/drv/root/root.c


Ignore:
Timestamp:
2011-02-13T20:03:45Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bab6388
Parents:
8b1e15ac
Message:

Refactor drivers

  • Rename soft-state structures to have the simplest names
  • Use soft-state structures as a starting point instead of DDF device or function nodes
  • Convert to standard naming scheme
File:
1 edited

Legend:

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

    r8b1e15ac r68414f4a  
    22 * Copyright (c) 2010 Lenka Trochtova
    33 * Copyright (c) 2010 Vojtech Horky
     4 * Copyright (c) 2011 Jiri Svoboda
    45 * All rights reserved.
    56 *
     
    5556#define NAME "root"
    5657
    57 #define PLATFORM_DEVICE_NAME "hw"
    58 #define PLATFORM_DEVICE_MATCH_ID_FMT "platform/%s"
    59 #define PLATFORM_DEVICE_MATCH_SCORE 100
     58#define PLATFORM_FUN_NAME "hw"
     59#define PLATFORM_FUN_MATCH_ID_FMT "platform/%s"
     60#define PLATFORM_FUN_MATCH_SCORE 100
    6061
    61 #define VIRTUAL_DEVICE_NAME "virt"
    62 #define VIRTUAL_DEVICE_MATCH_ID "rootvirt"
    63 #define VIRTUAL_DEVICE_MATCH_SCORE 100
     62#define VIRTUAL_FUN_NAME "virt"
     63#define VIRTUAL_FUN_MATCH_ID "rootvirt"
     64#define VIRTUAL_FUN_MATCH_SCORE 100
    6465
    6566static int root_add_device(device_t *dev);
     
    7677};
    7778
    78 /** Create the device which represents the root of virtual device tree.
     79/** Create the function which represents the root of virtual device tree.
    7980 *
    80  * @param parent Parent of the newly created device.
    81  * @return Error code.
     81 * @param dev   Device
     82 * @return      EOK on success or negative error code
    8283 */
    83 static int add_virtual_root_child(device_t *parent)
     84static int add_virtual_root_fun(device_t *dev)
    8485{
    85         printf(NAME ": adding new child for virtual devices.\n");
    86         printf(NAME ":   device node is `%s' (%d %s)\n", VIRTUAL_DEVICE_NAME,
    87             VIRTUAL_DEVICE_MATCH_SCORE, VIRTUAL_DEVICE_MATCH_ID);
     86        printf(NAME ": adding new function for virtual devices.\n");
     87        printf(NAME ":   function node is `%s' (%d %s)\n", VIRTUAL_FUN_NAME,
     88            VIRTUAL_FUN_MATCH_SCORE, VIRTUAL_FUN_MATCH_ID);
    8889
    89         int res = register_function_wrapper(parent, VIRTUAL_DEVICE_NAME,
    90             VIRTUAL_DEVICE_MATCH_ID, VIRTUAL_DEVICE_MATCH_SCORE);
     90        int res = register_function_wrapper(dev, VIRTUAL_FUN_NAME,
     91            VIRTUAL_FUN_MATCH_ID, VIRTUAL_FUN_MATCH_SCORE);
    9192
    9293        return res;
    9394}
    9495
    95 /** Create the device which represents the root of HW device tree.
     96/** Create the function which represents the root of HW device tree.
    9697 *
    97  * @param parent        Parent of the newly created device.
    98  * @return 0 on success, negative error number otherwise.
     98 * @param dev   Device
     99 * @return      EOK on success or negative error code
    99100 */
    100 static int add_platform_child(device_t *parent)
     101static int add_platform_fun(device_t *dev)
    101102{
    102103        char *match_id;
     
    106107
    107108        /* Get platform name from sysinfo. */
    108 
    109109        platform = sysinfo_get_data("platform", &platform_size);
    110110        if (platform == NULL) {
     
    123123
    124124        /* Construct match ID. */
    125 
    126         if (asprintf(&match_id, PLATFORM_DEVICE_MATCH_ID_FMT, platform) == -1) {
     125        if (asprintf(&match_id, PLATFORM_FUN_MATCH_ID_FMT, platform) == -1) {
    127126                printf(NAME ": Memory allocation failed.\n");
    128127                return ENOMEM;
    129128        }
    130129
    131         /* Add child. */
     130        /* Add function. */
     131        printf(NAME ": adding platform function\n");
     132        printf(NAME ":   function node is `%s' (%d %s)\n", PLATFORM_FUN_NAME,
     133            PLATFORM_FUN_MATCH_SCORE, match_id);
    132134
    133         printf(NAME ": adding new child for platform device.\n");
    134         printf(NAME ":   device node is `%s' (%d %s)\n", PLATFORM_DEVICE_NAME,
    135             PLATFORM_DEVICE_MATCH_SCORE, match_id);
    136 
    137         res = register_function_wrapper(parent, PLATFORM_DEVICE_NAME,
    138             match_id, PLATFORM_DEVICE_MATCH_SCORE);
     135        res = register_function_wrapper(dev, PLATFORM_FUN_NAME,
     136            match_id, PLATFORM_FUN_MATCH_SCORE);
    139137
    140138        return res;
     
    156154         * vital for the system.
    157155         */
    158         add_virtual_root_child(dev);
     156        add_virtual_root_fun(dev);
    159157
    160158        /* Register root device's children. */
    161         int res = add_platform_child(dev);
     159        int res = add_platform_fun(dev);
    162160        if (EOK != res)
    163161                printf(NAME ": failed to add child device for platform.\n");
Note: See TracChangeset for help on using the changeset viewer.