Skip to contentSkip to conversation

ASoC: pass snd_soc_jack_gpio to jack_status_check callback

PATCH In review xiangxiao 2 participants 4 messages Feb 16, 2014 – Feb 23, 2014 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

xiangxiao

author
#0 lore raw

PATCH 1/1 ASoC: pass snd_soc_jack_gpio to jack_status_check callback

so the implementation could get the context data

Change-Id I5542613ccf9881deb672e71d0f0c4f603ad761fd
---
 include/sound/soc.h  | 2 +-
 sound/soc/soc-jack.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/sound/soc.h +1 -1
index 21038e0..e287462 100644
@@ -613,7 +613,7 @@ struct snd_soc_jack_gpio {
 	struct snd_soc_jack *jack;
 	struct delayed_work work;
 
-	int (*jack_status_check)(void);
+	int (*jack_status_check)(struct snd_soc_jack_gpio *gpio);
 };
 
 struct snd_soc_jack {
sound/soc/soc-jack.c +1 -1
index b12fce6..6028af5 100644
@@ -250,7 +250,7 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio)
 		report = 0;
 
 	if (gpio->jack_status_check)
-		report = gpio->jack_status_check();
+		report = gpio->jack_status_check(gpio);
 
 	snd_soc_jack_report(jack, report, gpio->report);
 }
Signature · 1 line
1.8.1.2
maintainer
#1 lore raw
Quoted 3 lines · xiangxiao

so the implementation could get the context data

Change-Id: I5542613ccf9881deb672e71d0f0c4f603ad761fd

This shouldn't be on upstream patches.

include/sound/soc.h struct snd_soc_jack_gpio { · line 616

Quoted 4 lines
include/sound/soc.h +1 -1
-	int (*jack_status_check)(void);
+	int (*jack_status_check)(struct snd_soc_jack_gpio *gpio);

Why is the callback using details of the implementation of snd_soc_jack_gpio? Perhaps there's a good reason, I'm not sure and you've not included any implementation. I'd have expected to see the jack able to provide its own context here?

A message that is not in the archive (sent off-list or not yet received): [email protected]

maintainer
#3 lore raw
Quoted 6 lines · 肖翔

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;
};
Quoted 6 lines

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.

author
#4 lore raw

Sure, I will update the change per your suggestion.

-----邮件原件-----
发件人: Mark Brown [mailto:[email protected]]
发送时间: 2014年2月22日 11:22
收件人: 肖翔
抄送: [email protected]; [email protected]
主题: Re: 答复: [PATCH] ASoC: pass snd_soc_jack_gpio to jack_status_check callback

Quoted 11 lines · 肖翔

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.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel