All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: dummy: evgen: use irq_sim
Date: Thu, 28 Sep 2017 12:55:06 +0200	[thread overview]
Message-ID: <CAMRc=MdR+osCmb0mG5a53Ggk-s8HQoJ4x7VCvC8cfwqNC1EfvQ@mail.gmail.com> (raw)
In-Reply-To: <d8279093-c98a-20d9-ada4-8995243f4480@metafoo.de>

2017-09-28 10:04 GMT+02:00 Lars-Peter Clausen <lars@metafoo.de>:
> On 09/27/2017 09:23 PM, Bartosz Golaszewski wrote:
>>>>               return ret;
>>>> -     }
>>>> -     iio_evgen->chip.name = iio_evgen_name;
>>>> -     iio_evgen->chip.irq_mask = &iio_dummy_event_irqmask;
>>>> -     iio_evgen->chip.irq_unmask = &iio_dummy_event_irqunmask;
>>>> -     for (i = 0; i < IIO_EVENTGEN_NO; i++) {
>>>> -             irq_set_chip(iio_evgen->base + i, &iio_evgen->chip);
>>>> -             irq_set_handler(iio_evgen->base + i, &handle_simple_irq);
>>>> -             irq_modify_status(iio_evgen->base + i,
>>>> -                               IRQ_NOREQUEST | IRQ_NOAUTOEN,
>>>> -                               IRQ_NOPROBE);
>>>> -     }
>>>> -     init_irq_work(&iio_evgen->handler.work, iio_dummy_work_handler);
>>>> +
>>>> +     iio_evgen->base = irq_sim_irqnum(&iio_evgen->irq_sim, 0);
>>> I saw you introduced irq_sim_baseirq(), to get rid of ->base. But as far as
>>> I can see the only remaining places where we need the base is to do the
>>> reverse lookup from IRQ to index. It would be nice if the irq_sim had a
>>> function for that, then we wouldn't have to know about the base at all.
>>>
>>
>> I'm not sure I understand. Irq sim doesn't know anything about iio
>> data structures, so how would such a reverse lookup work in this case?
>
> Reverse lookup in the sense of translating IRQ number to offset. All we ever
> do with the base in the IIO code is `irq - base` to get the offset. I'd hide
> that calculation in a helper in the irq_sim code. This nicely splits
> functionality and implementation, the IIO code doesn't have to know how to
> get offset from the IRQ.

I see. Sounds like a good improvement for 4.16. In the meantime, I'll
send v2 with the missing kfree() added.

Thanks,
Bartosz

      reply	other threads:[~2017-09-28 10:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-26 16:49 [PATCH] iio: dummy: evgen: use irq_sim Bartosz Golaszewski
2017-09-27 17:12 ` Lars-Peter Clausen
2017-09-27 19:23   ` Bartosz Golaszewski
2017-09-28  8:04     ` Lars-Peter Clausen
2017-09-28 10:55       ` Bartosz Golaszewski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMRc=MdR+osCmb0mG5a53Ggk-s8HQoJ4x7VCvC8cfwqNC1EfvQ@mail.gmail.com' \
    --to=brgl@bgdev.pl \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.