Changeset 772 for GPL/trunk/lib32/irq.c


Ignore:
Timestamp:
Apr 19, 2025, 8:08:37 PM (4 months ago)
Author:
David Azarewicz
Message:

Merge in changes from 6.6-LTS branch.
Fixed additional 25+ problems.

Location:
GPL/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/lib32/irq.c

    r604 r772  
    249249//******************************************************************************
    250250
     251/*
     252 * Device resource management aware IRQ request/free implementation.
     253 */
     254struct irq_devres {
     255        unsigned int irq;
     256        void *dev_id;
     257};
     258
     259static void devm_irq_release(struct device *dev, void *res)
     260{
     261        struct irq_devres *this = res;
     262
     263        free_irq(this->irq, this->dev_id);
     264}
     265
     266/**
     267 *      devm_request_threaded_irq - allocate an interrupt line for a managed device
     268 *      @dev: device to request interrupt for
     269 *      @irq: Interrupt line to allocate
     270 *      @handler: Function to be called when the IRQ occurs
     271 *      @thread_fn: function to be called in a threaded interrupt context. NULL
     272 *                  for devices which handle everything in @handler
     273 *      @irqflags: Interrupt type flags
     274 *      @devname: An ascii name for the claiming device, dev_name(dev) if NULL
     275 *      @dev_id: A cookie passed back to the handler function
     276 *
     277 *      Except for the extra @dev argument, this function takes the
     278 *      same arguments and performs the same function as
     279 *      request_threaded_irq().  IRQs requested with this function will be
     280 *      automatically freed on driver detach.
     281 *
     282 *      If an IRQ allocated with this function needs to be freed
     283 *      separately, devm_free_irq() must be used.
     284 */
     285int devm_request_threaded_irq(struct device *dev, unsigned int irq,
     286                              irq_handler_t handler, irq_handler_t thread_fn,
     287                              unsigned long irqflags, const char *devname,
     288                              void *dev_id)
     289{
     290        struct irq_devres *dr;
     291        int rc;
     292
     293        dr = devres_alloc(devm_irq_release, sizeof(struct irq_devres),
     294                          GFP_KERNEL);
     295        if (!dr)
     296                return -ENOMEM;
     297
     298        if (!devname)
     299                devname = dev_name(dev);
     300
     301        rc = request_irq(irq, handler, irqflags, devname,
     302                                  dev_id);
     303        if (rc) {
     304                devres_free(dr);
     305                return rc;
     306        }
     307
     308        dr->irq = irq;
     309        dr->dev_id = dev_id;
     310        devres_add(dev, dr);
     311
     312        return 0;
     313}
Note: See TracChangeset for help on using the changeset viewer.