int exception_pop_handler(int code, ExceptionHandler handler) { unsigned int state = safe_entry(); if (code > (int)(sizeof(exception_stacks) / sizeof(*exception_stacks))) { e9printf("exception_add_handler: invalid code: %d\n", code); kerror(-1, "invalid code"); safe_exit(state); return -1; } for (LinkNode *node=exception_stacks[code].first; node; node=node->next) { if (node->data == handler) { klist_remove(exception_stacks+code, node); exc_free_node(node); safe_exit(state); return 0; //success } } e9printf("failed to find handler %x for %d\n", handler, code); safe_exit(state); return -1; //couldn't find handler }
/* * __device_release_driver() must be called with @dev lock held. * When called for a USB interface, @dev->parent lock must be held as well. */ static void __device_release_driver(struct device *dev) { struct device_driver *drv; drv = dev->driver; if (drv) { pm_runtime_get_sync(dev); driver_sysfs_remove(dev); if (dev->bus) blocking_notifier_call_chain(&dev->bus->p->bus_notifier, BUS_NOTIFY_UNBIND_DRIVER, dev); pm_runtime_put_sync(dev); if (dev->bus && dev->bus->remove) dev->bus->remove(dev); else if (drv->remove) drv->remove(dev); devres_release_all(dev); dev->driver = NULL; klist_remove(&dev->p->knode_driver); if (dev->bus) blocking_notifier_call_chain(&dev->bus->p->bus_notifier, BUS_NOTIFY_UNBOUND_DRIVER, dev); } }
int close(int fd) { FSFile *file = (FSFile*)fd; if (!_valid_file(fd)) return -1; //do reference counting file->refs--; if (file->refs > 0) { return 0; } file->closed = 1; if (file->fs->close) { _lock_file(file); file->fs->close(file->fs, file->device, file->internalfd); _unlock_file(file); } file->magic = 0; Process *p = process_get_current(0); LinkNode *node; for (node=p->open_files.first; node; node=node->next) { if (node->data == file) { klist_remove(&p->open_files, node); kfree(node); break; } } return 0; }
/** * bus_remove_device - remove device from bus * @dev: device to be removed * * - Remove symlink from bus's directory. * - Delete device from bus's list. * - Detach from its driver. * - Drop reference taken in bus_add_device(). */ void bus_remove_device(struct device * dev) { if (dev->bus) { sysfs_remove_link(&dev->kobj, "bus"); sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id); device_remove_attrs(dev->bus, dev); klist_remove(&dev->knode_bus); pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id); device_release_driver(dev); put_bus(dev->bus); } }
void bus_remove_driver(struct device_driver * drv) { if (drv->bus) { remove_bind_files(drv); driver_remove_attrs(drv->bus, drv); klist_remove(&drv->knode_bus); pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name); driver_detach(drv); module_remove_driver(drv); kobject_unregister(&drv->kobj); put_bus(drv->bus); } }
/** * bus_remove_driver - delete driver from bus's knowledge. * @drv: driver. * * Detach the driver from the devices it controls, and remove * it from its bus's list of drivers. Finally, we drop the reference * to the bus we took in bus_add_driver(). */ void bus_remove_driver(struct device_driver *drv) { if (!drv->bus) return; remove_bind_files(drv); driver_remove_attrs(drv->bus, drv); driver_remove_file(drv, &driver_attr_uevent); klist_remove(&drv->p->knode_bus); pr_debug("bus: '%s': remove driver %s\n", drv->bus->name, drv->name); driver_detach(drv); module_remove_driver(drv); kobject_put(&drv->p->kobj); bus_put(drv->bus); }
/* * __device_release_driver() must be called with @dev->sem held. * When called for a USB interface, @dev->parent->sem must be held as well. */ static void __device_release_driver(struct device * dev) { struct device_driver * drv; drv = get_driver(dev->driver); if (drv) { driver_sysfs_remove(dev); sysfs_remove_link(&dev->kobj, "driver"); klist_remove(&dev->knode_driver); if (dev->bus) blocking_notifier_call_chain(&dev->bus->bus_notifier, BUS_NOTIFY_UNBIND_DRIVER, dev); if (dev->bus && dev->bus->remove) dev->bus->remove(dev); else if (drv->remove) drv->remove(dev); devres_release_all(dev); dev->driver = NULL; put_driver(drv); } }