Changeset df747b9c in mainline for uspace/lib/libdrv


Ignore:
Timestamp:
2010-04-23T11:30:25Z (15 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/lib/libdrv
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libdrv/generic/driver.c

    ra78fa2a rdf747b9c  
    103103static void driver_add_device(ipc_callid_t iid, ipc_call_t *icall)
    104104{
    105         // TODO device state - the driver may detect the device is not actually present
    106         // (old non PnP devices) or is not working properly.
    107         // We should send such information to device manager.
    108        
    109         ipcarg_t ret;
     105        char *dev_name = NULL;
     106        int res = EOK;
     107       
    110108        device_handle_t dev_handle =  IPC_GET_ARG1(*icall);
    111109        device_t *dev = driver_create_device();
    112110        dev->handle = dev_handle;
    113         async_string_receive(&dev->name, 0, NULL);
    114         add_to_devices_list(dev);
    115         if (driver->driver_ops->add_device(dev)) {             
     111       
     112        async_string_receive(&dev_name, 0, NULL);
     113        dev->name = dev_name;
     114       
     115        add_to_devices_list(dev);               
     116        res = driver->driver_ops->add_device(dev);
     117        if (0 == res) {
    116118                printf("%s: new device with handle = %x was added.\n", driver->name, dev_handle);
    117                 ret = 1;
    118119        } else {
    119                 printf("%s: failed to add a new device with handle = %x.\n", driver->name, dev_handle);
     120                printf("%s: failed to add a new device with handle = %d.\n", driver->name, dev_handle);
    120121                remove_from_devices_list(dev);
    121                 // TODO delete device           
    122                 ret = 0;
    123         }
    124         ipc_answer_0(iid, EOK);
     122                delete_device(dev);             
     123        }
     124       
     125        ipc_answer_0(iid, res);
    125126}
    126127
     
    270271}
    271272
    272 bool child_device_register(device_t *child, device_t *parent)
     273int child_device_register(device_t *child, device_t *parent)
    273274{
    274275        // printf("%s: child_device_register\n", driver->name);
     
    276277        assert(NULL != child->name);
    277278
     279        int res;
     280       
    278281        add_to_devices_list(child);
    279         if (EOK == devman_child_device_register(child->name, &child->match_ids, parent->handle, &child->handle)) {
    280                 return true;
     282        if (EOK == (res = devman_child_device_register(child->name, &child->match_ids, parent->handle, &child->handle))) {
     283                return res;
    281284        }
    282285        remove_from_devices_list(child);       
    283         return false;
     286        return res;
    284287}
    285288
  • uspace/lib/libdrv/include/driver.h

    ra78fa2a rdf747b9c  
    109109typedef struct driver_ops {
    110110        /** Callback method for passing a new device to the device driver.*/
    111         bool (*add_device)(device_t *dev);
     111        int (*add_device)(device_t *dev);
    112112        // TODO add other generic driver operations
    113113} driver_ops_t;
     
    161161}
    162162
    163 bool child_device_register(device_t *child, device_t *parent);
     163int child_device_register(device_t *child, device_t *parent);
    164164
    165165
Note: See TracChangeset for help on using the changeset viewer.