Re: [PATCH] PM / wakeirq: Add wakeup name to dedicated wake irqs

From: Tony Lindgren
Date: Fri Feb 16 2018 - 11:42:48 EST


* Rafael J. Wysocki <rafael@xxxxxxxxxx> [180216 09:42]:
> On Fri, Feb 9, 2018 at 5:14 PM, Tony Lindgren <tony@xxxxxxxxxxx> wrote:
> > This makes it easy to grep :wakeup /proc/interrupts.
> > diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c
> > --- a/drivers/base/power/wakeirq.c
> > +++ b/drivers/base/power/wakeirq.c
> > @@ -112,6 +112,7 @@ void dev_pm_clear_wake_irq(struct device *dev)
> > free_irq(wirq->irq, wirq);
> > wirq->status &= ~WAKE_IRQ_DEDICATED_MASK;
> > }
> > + kfree(wirq->name);
> > kfree(wirq);
> > }
> > EXPORT_SYMBOL_GPL(dev_pm_clear_wake_irq);
> > @@ -175,7 +176,8 @@ static irqreturn_t handle_threaded_wake_irq(int irq, void *_wirq)
> > int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq)
> > {
> > struct wake_irq *wirq;
> > - int err;
> > + int err, namelen;
> > + const char *postfix = ":wakeup";
> >
> > if (irq < 0)
> > return -EINVAL;
> > @@ -184,6 +186,14 @@ int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq)
> > if (!wirq)
> > return -ENOMEM;
> >
> > + namelen = strlen(dev_name(dev)) + strlen(postfix) + 1;
> > + wirq->name = kzalloc(namelen, GFP_KERNEL);
> > + if (!wirq->name) {
> > + err = -ENOMEM;
> > + goto err_free;
> > + }
> > +
> > + snprintf(wirq->name, namelen, "%s%s", dev_name(dev), postfix);
>
> As Andy said you can do
>
> wirq->name = kasprintf(GFP_KERNEL, "%s:wakeup", dev_name(dev));
> if (!wirq->name) {
> err = -ENOMEM;
> goto err_free;
> }
>
> here and it will allocate the buffer for you.

Yeah great, will update and repost next week. I'll also
give Andy's patch a try, sounds like we may want to do
both though.

Regards,

Tony