/** * devm_gpio_free - free an interrupt * @dev: device to free gpio for * @gpio: gpio to free * * Except for the extra @dev argument, this function takes the * same arguments and performs the same function as gpio_free(). * This function instead of gpio_free() should be used to manually * free GPIOs allocated with devm_gpio_request(). */ void devm_gpio_free(struct device *dev, unsigned int gpio) { WARN_ON(devres_destroy(dev, devm_gpio_release, devm_gpio_match, &gpio)); gpio_free(gpio); }
void devm_stm_device_exit(struct device *dev, struct stm_device_state *state) { int err; __stm_device_exit(state); err = devres_destroy(dev, stm_device_devres_exit, stm_device_devres_match, state); WARN_ON(err); }
/** * input_unregister_polled_device - unregister polled device * @dev: device to unregister * * The function unregisters previously registered polled input * device from input layer. Polling is stopped and device is * ready to be freed with call to input_free_polled_device(). */ void input_unregister_polled_device(struct input_polled_dev *dev) { if (dev->devres_managed) WARN_ON(devres_destroy(dev->input->dev.parent, devm_input_polldev_unregister, devm_input_polldev_match, dev)); input_unregister_device(dev->input); }
/** * input_free_polled_device - free memory allocated for polled device * @dev: device to free * * The function frees memory allocated for polling device and drops * reference to the associated input device. */ void input_free_polled_device(struct input_polled_dev *dev) { if (dev) { if (dev->devres_managed) WARN_ON(devres_destroy(dev->input->dev.parent, devm_input_polldev_release, devm_input_polldev_match, dev)); input_put_device(dev->input); kfree(dev); } }
/** * snd_hdac_acomp_exit - Finalize audio component * @bus: HDA core bus * * This function is supposed to be used only by a HD-audio controller * driver that needs the interaction with graphics driver. * * This function releases the audio component that has been used. * * Returns zero for success or a negative error code. */ int snd_hdac_acomp_exit(struct hdac_bus *bus) { struct device *dev = bus->dev; struct drm_audio_component *acomp = bus->audio_component; if (!acomp) return 0; WARN_ON(bus->drm_power_refcount); if (bus->drm_power_refcount > 0 && acomp->ops) acomp->ops->put_power(acomp->dev); component_master_del(dev, &hdac_component_master_ops); bus->audio_component = NULL; devres_destroy(dev, hdac_acomp_release, NULL, NULL); return 0; }
/** * snd_hdac_acomp_init - Initialize audio component * @bus: HDA core bus * @match_master: match function for finding components * @extra_size: Extra bytes to allocate * * This function is supposed to be used only by a HD-audio controller * driver that needs the interaction with graphics driver. * * This function initializes and sets up the audio component to communicate * with graphics driver. * * Unlike snd_hdac_i915_init(), this function doesn't synchronize with the * binding with the DRM component. Each caller needs to sync via master_bind * audio_ops. * * Returns zero for success or a negative error code. */ int snd_hdac_acomp_init(struct hdac_bus *bus, const struct drm_audio_component_audio_ops *aops, int (*match_master)(struct device *, void *), size_t extra_size) { struct component_match *match = NULL; struct device *dev = bus->dev; struct drm_audio_component *acomp; int ret; if (WARN_ON(hdac_get_acomp(dev))) return -EBUSY; acomp = devres_alloc(hdac_acomp_release, sizeof(*acomp) + extra_size, GFP_KERNEL); if (!acomp) return -ENOMEM; acomp->audio_ops = aops; bus->audio_component = acomp; devres_add(dev, acomp); component_match_add(dev, &match, match_master, bus); ret = component_master_add_with_match(dev, &hdac_component_master_ops, match); if (ret < 0) goto out_err; return 0; out_err: bus->audio_component = NULL; devres_destroy(dev, hdac_acomp_release, NULL, NULL); dev_info(dev, "failed to add audio component master (%d)\n", ret); return ret; }
void devm_memunmap(struct device *dev, void *addr) { WARN_ON(devres_destroy(dev, devm_memremap_release, devm_memremap_match, addr)); memunmap(addr); }
/** * devm_ioport_unmap - Managed ioport_unmap() * @dev: Generic device to unmap for * @addr: Address to unmap * * Managed ioport_unmap(). @addr must have been mapped using * devm_ioport_map(). */ void devm_ioport_unmap(struct device *dev, void __iomem *addr) { ioport_unmap(addr); WARN_ON(devres_destroy(dev, devm_ioport_map_release, devm_ioport_map_match, (__force void *)addr)); }
/** * devm_iounmap - Managed iounmap() * @dev: Generic device to unmap for * @addr: Address to unmap * * Managed iounmap(). @addr must have been mapped using devm_ioremap*(). */ void devm_iounmap(struct device *dev, void __iomem *addr) { WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match, (void *)addr)); iounmap(addr); }