Changeset 5159ae9 in mainline
- Timestamp:
- 2010-05-29T08:37:38Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ce89036b
- Parents:
- 692c40cb
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/driver.c
r692c40cb r5159ae9 224 224 int ret = EOK; 225 225 // 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); 228 228 } 229 229 … … 240 240 case IPC_M_PHONE_HUNGUP: 241 241 // 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); 244 244 } 245 245 ipc_answer_0(callid, EOK); -
uspace/lib/drv/include/driver.h
r692c40cb r5159ae9 80 80 // device class 81 81 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. */ 83 typedef struct device_ops { 86 84 /** Optional callback function called when a client is connecting to the device. */ 87 85 int (*open)(device_t *dev); … … 93 91 * by any of the standard interfaces, the default handler is used.*/ 94 92 remote_handler_t *default_handler; 95 } device_ class_t;93 } device_ops_t; 96 94 97 95 … … 112 110 /** The device driver's data associated with this device.*/ 113 111 void *driver_data; 114 /** Device class consist of class id and table of interfaces supported by thedevice.*/115 device_ class_t *class;112 /** The implementation of operations provided by this device.*/ 113 device_ops_t *ops; 116 114 /** Pointer to the previous and next device in the list of devices handled by the driver */ 117 115 link_t link; … … 168 166 { 169 167 assert(is_valid_iface_idx(idx)); 170 if (NULL == dev-> class) {168 if (NULL == dev->ops) { 171 169 return NULL; 172 170 } 173 return dev-> class->interfaces[idx];171 return dev->ops->interfaces[idx]; 174 172 } 175 173 … … 280 278 static inline remote_handler_t * device_get_default_handler(device_t *dev) 281 279 { 282 if (NULL == dev-> class) {280 if (NULL == dev->ops) { 283 281 return NULL; 284 282 } 285 283 286 return dev-> class->default_handler;284 return dev->ops->default_handler; 287 285 } 288 286 -
uspace/srv/drivers/isa/isa.c
r692c40cb r5159ae9 87 87 }; 88 88 89 static device_ class_t isa_child_class;89 static device_ops_t isa_child_dev_ops; 90 90 91 91 static int isa_add_device(device_t *dev); … … 449 449 } 450 450 451 // set a class (including the corresponding set of interfaces)to the device452 dev-> class = &isa_child_class;451 // set device operations to the device 452 dev->ops = &isa_child_dev_ops; 453 453 454 454 printf(NAME ": child_device_register(dev, parent); device is %s.\n", dev->name); … … 487 487 static void isa_init() 488 488 { 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; 491 490 } 492 491 -
uspace/srv/drivers/ns8250/ns8250.c
r692c40cb r5159ae9 228 228 } 229 229 230 static device_ class_t ns8250_dev_class;230 static device_ops_t ns8250_dev_ops; 231 231 232 232 /** The character interface's callbacks. … … 758 758 } 759 759 760 dev->class = &ns8250_dev_class; 760 // set device operations 761 dev->ops = &ns8250_dev_ops; 761 762 762 763 add_device_to_class(dev, "serial"); … … 900 901 /** Initialize the serial port driver. 901 902 * 902 * Initialize class structures with callback methods for handling903 * Initialize device operations structures with callback methods for handling 903 904 * client requests to the serial port devices. 904 905 */ 905 906 static void ns8250_init() 906 907 { 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; 914 913 } 915 914 -
uspace/srv/drivers/pciintel/pci.c
r692c40cb r5159ae9 82 82 }; 83 83 84 static device_ class_t pci_child_class;84 static device_ops_t pci_child_ops; 85 85 86 86 … … 398 398 pci_read_interrupt(dev); 399 399 400 dev-> class = &pci_child_class;400 dev->ops = &pci_child_ops; 401 401 402 402 printf(NAME ": adding new child device %s.\n", dev->name); … … 491 491 static void pciintel_init() 492 492 { 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; 495 494 } 496 495 -
uspace/srv/drivers/rootia32/rootia32.c
r692c40cb r5159ae9 113 113 114 114 // initialized in root_ia32_init() function 115 static device_ class_t rootia32_child_class;115 static device_ops_t rootia32_child_ops; 116 116 117 117 static bool rootia32_add_child( … … 140 140 add_match_id(&child->match_ids, match_id); 141 141 142 // set class to the device143 child-> class = &rootia32_child_class;142 // set provided operations to the device 143 child->ops = &rootia32_child_ops; 144 144 145 145 // register child device … … 188 188 189 189 static 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; 193 191 } 194 192
Note:
See TracChangeset
for help on using the changeset viewer.