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.