Re: [PATCH v5 2/2] counter: add IRQ or GPIO based event counter
From: William Breathitt Gray <hidden>
Date: 2021-02-26 06:59:50
Also in:
linux-iio, lkml
On Fri, Feb 26, 2021 at 07:46:01AM +0100, Oleksij Rempel wrote:
On Wed, Feb 24, 2021 at 05:20:21PM +0900, William Breathitt Gray wrote:quoted
On Wed, Feb 24, 2021 at 05:11:03PM +0900, William Breathitt Gray wrote:quoted
On Wed, Feb 24, 2021 at 08:35:06AM +0100, Oleksij Rempel wrote:quoted
On Wed, Feb 24, 2021 at 11:34:06AM +0900, William Breathitt Gray wrote:quoted
Alternatively, we can take a more generic approach: ignore the GPIO names and focus solely on the IRQ lines; because the GPIO lines will always be tied to respective IRQ lines here, using the IRQ as the basis of the name should always be valid. The "name" member of the struct irq_chip can work for this. I haven't tested this, but I think something like this would work: cnt_signals[0].name = irq_get_chip(priv->irq)->name;ok, i'll take a look at it.If that doesn't work, then use devm_kasprintf() to generate the name based on the IRQ line number. The idea here is that the user should be able to identify that the Signal component for this Count is the respective IRQ. William Breathitt GrayI realized that these irq_chip names are often just the device name which isn't very useful either. :-( In that case, I suppose we really are just left with generating the name based on the IRQ line number then. This should be fine then: cnt_signals[0].name = devm_kasprintf(dev, GFP_KERNEL, "IRQ %d", priv->irq); if (!cnt_signals[0].name) return -ENOMEM; I think this would make it clear to the user that this Signal is the respective IRQ (whether sourced from GPIO or not).ack, with one correction. cnt_signals should be allocated, otherwise this value will be set per driver not per device. Regards, Oleksij -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Yes you're right, cnt_signals will need to be allocated then because these will be different per device. Thanks, William Breathitt Gray
Attachments
- signature.asc [application/pgp-signature] 833 bytes