[alsa-devel] [RFC] ucb1400 touchscreen, irq auto probing and ac97 with its private field
Takashi Iwai
tiwai at suse.de
Fri Apr 25 09:52:23 CEST 2008
At Fri, 25 Apr 2008 09:35:47 +0200 (CEST),
Jaroslav Kysela wrote:
>
> On Fri, 25 Apr 2008, Takashi Iwai wrote:
>
> > > Sure. I applied the simple 'void *device_private_data' patch, because
> > > current usage request is really trivial. We can implement complex code to
> > > handle data for multiple "extra" devices on AC97 bus later.
> >
> > Actually, it's not "used" yet. The ucb1000 reads the data but no one
> > stores yet. And, if its usage request is trivial, we should use "int
>
> Yes, I hope that the appropriate initialization code will be added to SoC
> drivers, too.
>
> > irq" as in the original patch instead of void data and cast.
>
> But other SoC (or other) drivers might want to pass to extra devices on
> AC97 bus something different or more complex. Mark Brown already noted
> that. I would keep it as 'void *'.
That's the very problem I've been trying to point out.
The void pointer is good if the same driver assigns and casts. But,
in this case, the allocator and the receiver are different. Thus,
there is no guarantee that the data type is what you want. OTOH, if
it's "int irq", this is crystal clear.
So, in short:
- if only one device needs such data, it should be a strong type like
"int irq" anyway -- no extra need to cast to void pointer
- if multiple devices need such a pass-away mechanism, then they can
crash because you have no data type check. The void pointer is
dangerous for multiple devices.
thanks,
Takashi
More information about the Alsa-devel
mailing list