Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 5159ae9 in mainline


Ignore:
Timestamp:
2010-05-29T08:37:38Z (11 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master
Children:
ce89036b
Parents:
692c40cb
Message:

Rename 'device_class' structure to a more appropriate 'device_ops'. The device_class structure has nothing in common with the device classes introduced by the previous commit and it evolved to just a set of callback functions.

Location:
uspace
Files:
6 edited

Legend:

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

    r692c40cb r5159ae9  
    224224        int ret = EOK;
    225225        // open the device
    226         if (NULL != dev->class && NULL != dev->class->open) {
    227                 ret = (*dev->class->open)(dev);
     226        if (NULL != dev->ops && NULL != dev->ops->open) {
     227                ret = (*dev->ops->open)(dev);
    228228        }
    229229       
     
    240240                case IPC_M_PHONE_HUNGUP:               
    241241                        // close the device
    242                         if (NULL != dev->class && NULL != dev->class->close) {
    243                                 (*dev->class->close)(dev);
     242                        if (NULL != dev->ops && NULL != dev->ops->close) {
     243                                (*dev->ops->close)(dev);
    244244                        }                       
    245245                        ipc_answer_0(callid, EOK);
  • uspace/lib/drv/include/driver.h

    r692c40cb r5159ae9  
    8080// device class
    8181
    82 /** Devices belonging to the same class should implement the same set of interfaces.*/
    83 typedef struct device_class {
    84         /** Unique identification of the class. */
    85         int id;
     82/** Devices operations. */
     83typedef struct device_ops {
    8684        /** Optional callback function called when a client is connecting to the device. */
    8785        int (*open)(device_t *dev);
     
    9391         * by any of the standard interfaces, the default handler is used.*/
    9492        remote_handler_t *default_handler;
    95 } device_class_t;
     93} device_ops_t;
    9694
    9795
     
    112110        /** The device driver's data associated with this device.*/
    113111        void *driver_data;
    114         /** Device class consist of class id and table of interfaces supported by the device.*/
    115         device_class_t *class;
     112        /** The implementation of operations provided by this device.*/
     113        device_ops_t *ops;
    116114        /** Pointer to the previous and next device in the list of devices handled by the driver */
    117115        link_t link;
     
    168166{
    169167        assert(is_valid_iface_idx(idx));       
    170         if (NULL == dev->class) {
     168        if (NULL == dev->ops) {
    171169                return NULL;
    172170        }
    173         return dev->class->interfaces[idx];     
     171        return dev->ops->interfaces[idx];       
    174172}
    175173
     
    280278static inline remote_handler_t * device_get_default_handler(device_t *dev)
    281279{
    282         if (NULL == dev->class) {
     280        if (NULL == dev->ops) {
    283281                return NULL;
    284282        }
    285283       
    286         return dev->class->default_handler;     
     284        return dev->ops->default_handler;       
    287285}
    288286
  • uspace/srv/drivers/isa/isa.c

    r692c40cb r5159ae9  
    8787};
    8888
    89 static device_class_t isa_child_class;
     89static device_ops_t isa_child_dev_ops;
    9090
    9191static int isa_add_device(device_t *dev);
     
    449449        }
    450450       
    451         // set a class (including the corresponding set of interfaces) to the device
    452         dev->class = &isa_child_class;
     451        // set device operations to the device
     452        dev->ops = &isa_child_dev_ops;
    453453       
    454454        printf(NAME ": child_device_register(dev, parent); device is %s.\n", dev->name);
     
    487487static void isa_init()
    488488{
    489         isa_child_class.id = 0; // TODO
    490         isa_child_class.interfaces[HW_RES_DEV_IFACE] = &isa_child_res_iface;
     489        isa_child_dev_ops.interfaces[HW_RES_DEV_IFACE] = &isa_child_res_iface;
    491490}
    492491
  • uspace/srv/drivers/ns8250/ns8250.c

    r692c40cb r5159ae9  
    228228}
    229229
    230 static device_class_t ns8250_dev_class;
     230static device_ops_t ns8250_dev_ops;
    231231
    232232/** The character interface's callbacks.
     
    758758        }       
    759759       
    760         dev->class = &ns8250_dev_class;
     760        // set device operations
     761        dev->ops = &ns8250_dev_ops;
    761762       
    762763        add_device_to_class(dev, "serial");
     
    900901/** Initialize the serial port driver.
    901902 *
    902  * Initialize class structures with callback methods for handling
     903 * Initialize device operations structures with callback methods for handling
    903904 * client requests to the serial port devices.
    904905 */
    905906static void ns8250_init()
    906907{
    907         // TODO
    908         ns8250_dev_class.id = 0;
    909         ns8250_dev_class.open = &ns8250_open;
    910         ns8250_dev_class.close = &ns8250_close;
    911        
    912         ns8250_dev_class.interfaces[CHAR_DEV_IFACE] = &ns8250_char_iface;
    913         ns8250_dev_class.default_handler = &ns8250_default_handler;
     908        ns8250_dev_ops.open = &ns8250_open;
     909        ns8250_dev_ops.close = &ns8250_close;   
     910       
     911        ns8250_dev_ops.interfaces[CHAR_DEV_IFACE] = &ns8250_char_iface;
     912        ns8250_dev_ops.default_handler = &ns8250_default_handler;
    914913}
    915914
  • uspace/srv/drivers/pciintel/pci.c

    r692c40cb r5159ae9  
    8282};
    8383
    84 static device_class_t pci_child_class;
     84static device_ops_t pci_child_ops;
    8585
    8686
     
    398398                        pci_read_interrupt(dev);
    399399                       
    400                         dev->class = &pci_child_class;                 
     400                        dev->ops = &pci_child_ops;                     
    401401                       
    402402                        printf(NAME ": adding new child device %s.\n", dev->name);
     
    491491static void pciintel_init()
    492492{
    493         pci_child_class.id = 0; // TODO
    494         pci_child_class.interfaces[HW_RES_DEV_IFACE] = &pciintel_child_res_iface;
     493        pci_child_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_child_res_iface;
    495494}
    496495
  • uspace/srv/drivers/rootia32/rootia32.c

    r692c40cb r5159ae9  
    113113
    114114// initialized in root_ia32_init() function
    115 static device_class_t rootia32_child_class;
     115static device_ops_t rootia32_child_ops;
    116116
    117117static bool rootia32_add_child(
     
    140140        add_match_id(&child->match_ids, match_id);     
    141141       
    142         // set class to the device
    143         child->class = &rootia32_child_class;
     142        // set provided operations to the device
     143        child->ops = &rootia32_child_ops;
    144144       
    145145        // register child  device
     
    188188
    189189static void root_ia32_init() {
    190         // initialize child device class               
    191         rootia32_child_class.id = 0;    // TODO
    192         rootia32_child_class.interfaces[HW_RES_DEV_IFACE] = &child_res_iface;
     190        rootia32_child_ops.interfaces[HW_RES_DEV_IFACE] = &child_res_iface;
    193191}
    194192
Note: See TracChangeset for help on using the changeset viewer.