[alsa-devel] 答复: [PATCH] ASoC: pass snd_soc_jack_gpio to jack_status_check callback

Mark Brown broonie at kernel.org
Sat Feb 22 04:21:40 CET 2014

On Wed, Feb 19, 2014 at 02:20:07PM +0000, 肖翔 wrote:
> The new parameter isn't used to get the internal field of snd_soc_jack_gpio.
> the usage is very like work_struct, here is the demo code:
> struct xxx_priv {
> 	truct snd_soc_jack_gpio gpio;
> };
> static int xxx_ jack_status_check(struct snd_soc_jack_gpio *gpio)
> {
> 	struct xxx_priv *xxx = container_of(gpio, struct xxx_priv, gpio);
> 	......
> }
> Without this parameter, codec driver has to save xxx_priv as a global variable.

OK, this makes sense as a reason for passing the argument in however how
about instead of passing in the structure adding a void * to it which
gets passed as the argument instead?  The user can then assign it to
point to the data they want directly without it looking like they should
be using the private data for the core code.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20140222/6f94da53/attachment-0001.sig>

More information about the Alsa-devel mailing list