Changeset df747b9c in mainline for uspace/srv/devman


Ignore:
Timestamp:
2010-04-23T11:30:25Z (16 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5af21c5
Parents:
a78fa2a
Message:

added device states (usable, invalid, not present, not initialized); add_device driver callback method returns integer (errno) instead of bool

Location:
uspace/srv/devman
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/devman.c

    ra78fa2a rdf747b9c  
    519519        async_wait_for(req, &rc);
    520520        switch(rc) {
    521                 // TODO inspect return value to find out whether the device was successfully probed and added
    522521        case EOK:
     522                node->state = DEVICE_USABLE;
     523                break;
    523524        case ENOENT:
    524                
     525                node->state = DEVICE_NOT_PRESENT;
    525526                break;
    526                
     527        default:
     528                node->state = DEVICE_INVALID;           
    527529        }
    528530       
  • uspace/srv/devman/devman.h

    ra78fa2a rdf747b9c  
    9393} driver_list_t;
    9494
     95/** The state of the device. */
     96typedef enum {
     97        DEVICE_NOT_INITIALIZED = 0,
     98        DEVICE_USABLE,
     99        DEVICE_NOT_PRESENT,
     100        DEVICE_INVALID
     101} device_state_t;
     102
    95103/** Representation of a node in the device tree.*/
    96104struct node {
     
    113121        /** Driver of this device.*/
    114122        driver_t *drv;
     123        /** The state of the device. */
     124        device_state_t state;
    115125        /** Pointer to the previous and next device in the list of devices
    116126            owned by one driver */
  • uspace/srv/devman/main.c

    ra78fa2a rdf747b9c  
    309309                        driver = dev->parent->drv;             
    310310                }
    311         } else {
     311        } else if (DEVICE_USABLE == dev->state) {
    312312                driver = dev->drv;             
     313                assert(NULL != driver);
    313314        }
    314315       
    315316        if (NULL == driver) {   
    316                 printf(NAME ": devman_forward error - no driver to connect to.\n", handle);
     317                printf(NAME ": devman_forward error - the device is not in usable state.\n", handle);
    317318                ipc_answer_0(iid, ENOENT);
    318319                return;
     
    331332                return;
    332333        }
    333         printf(NAME ": devman_forward: forward connection to device %s to driver %s with phone %d.\n",
    334                 dev->pathname, driver->name, driver->phone);
     334        printf(NAME ": devman_forward: forward connection to device %s to driver %s.\n", dev->pathname, driver->name);
    335335        ipc_forward_fast(iid, driver->phone, method, dev->handle, 0, IPC_FF_NONE);     
    336336}
Note: See TracChangeset for help on using the changeset viewer.