Changeset 93fb170c in mainline for uspace/drv/root/root.c


Ignore:
Timestamp:
2011-01-08T18:51:31Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
15be932
Parents:
8f748215 (diff), a523af4 (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 main branch

File:
1 edited

Legend:

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

    r8f748215 r93fb170c  
    4747#include <macros.h>
    4848#include <inttypes.h>
     49#include <sysinfo.h>
    4950
    5051#include <driver.h>
     
    5556
    5657#define PLATFORM_DEVICE_NAME "hw"
    57 #define PLATFORM_DEVICE_MATCH_ID STRING(UARCH)
     58#define PLATFORM_DEVICE_MATCH_ID_FMT "platform/%s"
    5859#define PLATFORM_DEVICE_MATCH_SCORE 100
    5960
     
    100101static int add_platform_child(device_t *parent)
    101102{
     103        char *match_id;
     104        char *platform;
     105        size_t platform_size;
     106        int res;
     107
     108        /* Get platform name from sysinfo. */
     109
     110        platform = sysinfo_get_data("platform", &platform_size);
     111        if (platform == NULL) {
     112                printf(NAME ": Failed to obtain platform name.\n");
     113                return ENOENT;
     114        }
     115
     116        /* Null-terminate string. */
     117        platform = realloc(platform, platform_size + 1);
     118        if (platform == NULL) {
     119                printf(NAME ": Memory allocation failed.\n");
     120                return ENOMEM;
     121        }
     122
     123        platform[platform_size] = '\0';
     124
     125        /* Construct match ID. */
     126
     127        if (asprintf(&match_id, PLATFORM_DEVICE_MATCH_ID_FMT, platform) == -1) {
     128                printf(NAME ": Memory allocation failed.\n");
     129                return ENOMEM;
     130        }
     131
     132        /* Add child. */
     133
    102134        printf(NAME ": adding new child for platform device.\n");
    103135        printf(NAME ":   device node is `%s' (%d %s)\n", PLATFORM_DEVICE_NAME,
    104             PLATFORM_DEVICE_MATCH_SCORE, PLATFORM_DEVICE_MATCH_ID);
    105        
    106         int res = child_device_register_wrapper(parent, PLATFORM_DEVICE_NAME,
    107             PLATFORM_DEVICE_MATCH_ID, PLATFORM_DEVICE_MATCH_SCORE,
    108             NULL);
     136            PLATFORM_DEVICE_MATCH_SCORE, match_id);
     137
     138        res = child_device_register_wrapper(parent, PLATFORM_DEVICE_NAME,
     139            match_id, PLATFORM_DEVICE_MATCH_SCORE, NULL);
    109140
    110141        return res;
Note: See TracChangeset for help on using the changeset viewer.