[alsa-devel] [RFC] ucb1400 touchscreen, irq auto probing and ac97 with its private field
Takashi Iwai
tiwai at suse.de
Fri Apr 25 09:18:49 CEST 2008
At Fri, 25 Apr 2008 09:10:31 +0200 (CEST),
Jaroslav Kysela wrote:
>
> On Fri, 25 Apr 2008, Takashi Iwai wrote:
>
> > Hm, indeed it's more than a single value...
> >
> > For multiple anonymous data, we can use a data with a key like below:
> >
> > struct device_hint {
> > char *key;
> > void *data;
> > struct list_head list;
> > };
> >
> > and the controller driver assigns the data like
> >
> > controller_init()
> > {
> > ...
> > controller.hint.key = "ucb1000-irq";
> > controller.hint.data = whatever;
> > list_add(&controller.hint. &ac97->device_hint_list);
> > ...
> > }
> >
> > and the device driver retrieves the data like
> >
> > device_init()
> > {
> > struct device_hint *hint;
> > hint = device_hint_get(&ac97->device_hint_list, "ucb1000-irq");
> > if (hint) {
> > whatever = hint->data;
> > ...
> > }
> > }
> >
> > where device_hint_get() is defined like
> >
> > struct device_hint *device_hint_get(struct device_hint *head,
> > const char *key)
> > {
> > struct device_hint *hint;
> > list_for_each_entry(hint, head, list)
> > if (!strcmp(hint, key))
> > return hint;
> > return NULL;
> > }
> >
> > Of course, we can cast via container_of() to a container type instead
> > of using a void pointer there.
> >
> > This is obviously an overweight for a single use-case, but if we have
> > more and more complex ones, maybe worth to consider.
>
> 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
irq" as in the original patch instead of void data and cast.
thanks,
Takashi
More information about the Alsa-devel
mailing list