diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-09-11 08:39:09 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-09-15 05:50:48 -0400 |
commit | bda17b82bfa9601f167ec338755b0b96909db5a0 (patch) | |
tree | 54b53015593eb1665c89855da780130c2096e12d /sound/pci | |
parent | 81965f1f58ce120a616f2fdd0594916fa183c5fc (diff) |
ALSA: hda - Make snd_hda_jack_detect_enable_callback() returning the jack object
STAC/IDT driver calls snd_hda_jack_tbl_get() again after calling
snd_hda_jack_detect_enable_callback(). For simplifying this, let's
make snd_hda_jack_detect_enable_callback() returning the pointer while
handling the error with the standard IS_ERR() & co.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r-- | sound/pci/hda/hda_jack.c | 24 | ||||
-rw-r--r-- | sound/pci/hda/hda_jack.h | 5 | ||||
-rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 14 |
3 files changed, 26 insertions, 17 deletions
diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index 7f332794993f..a5fe1b428015 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c | |||
@@ -214,29 +214,39 @@ EXPORT_SYMBOL_GPL(snd_hda_jack_detect_state); | |||
214 | 214 | ||
215 | /** | 215 | /** |
216 | * snd_hda_jack_detect_enable - enable the jack-detection | 216 | * snd_hda_jack_detect_enable - enable the jack-detection |
217 | * | ||
218 | * In the case of error, the return value will be a pointer embedded with | ||
219 | * errno. Check and handle the return value appropriately with standard | ||
220 | * macros such as @IS_ERR() and @PTR_ERR(). | ||
217 | */ | 221 | */ |
218 | int snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid, | 222 | struct hda_jack_tbl * |
219 | hda_jack_callback cb) | 223 | snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid, |
224 | hda_jack_callback cb) | ||
220 | { | 225 | { |
221 | struct hda_jack_tbl *jack = snd_hda_jack_tbl_new(codec, nid); | 226 | struct hda_jack_tbl *jack = snd_hda_jack_tbl_new(codec, nid); |
227 | int err; | ||
228 | |||
222 | if (!jack) | 229 | if (!jack) |
223 | return -ENOMEM; | 230 | return ERR_PTR(-ENOMEM); |
224 | if (jack->jack_detect) | 231 | if (jack->jack_detect) |
225 | return 0; /* already registered */ | 232 | return jack; /* already registered */ |
226 | jack->jack_detect = 1; | 233 | jack->jack_detect = 1; |
227 | if (cb) | 234 | if (cb) |
228 | jack->callback = cb; | 235 | jack->callback = cb; |
229 | if (codec->jackpoll_interval > 0) | 236 | if (codec->jackpoll_interval > 0) |
230 | return 0; /* No unsol if we're polling instead */ | 237 | return jack; /* No unsol if we're polling instead */ |
231 | return snd_hda_codec_write_cache(codec, nid, 0, | 238 | err = snd_hda_codec_write_cache(codec, nid, 0, |
232 | AC_VERB_SET_UNSOLICITED_ENABLE, | 239 | AC_VERB_SET_UNSOLICITED_ENABLE, |
233 | AC_USRSP_EN | jack->tag); | 240 | AC_USRSP_EN | jack->tag); |
241 | if (err < 0) | ||
242 | return ERR_PTR(err); | ||
243 | return jack; | ||
234 | } | 244 | } |
235 | EXPORT_SYMBOL_GPL(snd_hda_jack_detect_enable_callback); | 245 | EXPORT_SYMBOL_GPL(snd_hda_jack_detect_enable_callback); |
236 | 246 | ||
237 | int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid) | 247 | int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid) |
238 | { | 248 | { |
239 | return snd_hda_jack_detect_enable_callback(codec, nid, NULL); | 249 | return PTR_ERR_OR_ZERO(snd_hda_jack_detect_enable_callback(codec, nid, NULL)); |
240 | } | 250 | } |
241 | EXPORT_SYMBOL_GPL(snd_hda_jack_detect_enable); | 251 | EXPORT_SYMBOL_GPL(snd_hda_jack_detect_enable); |
242 | 252 | ||
diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h index 67f42db9c89c..668669ce3e52 100644 --- a/sound/pci/hda/hda_jack.h +++ b/sound/pci/hda/hda_jack.h | |||
@@ -47,8 +47,9 @@ void snd_hda_jack_tbl_clear(struct hda_codec *codec); | |||
47 | void snd_hda_jack_set_dirty_all(struct hda_codec *codec); | 47 | void snd_hda_jack_set_dirty_all(struct hda_codec *codec); |
48 | 48 | ||
49 | int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid); | 49 | int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid); |
50 | int snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid, | 50 | struct hda_jack_tbl * |
51 | hda_jack_callback cb); | 51 | snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid, |
52 | hda_jack_callback cb); | ||
52 | 53 | ||
53 | int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid, | 54 | int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid, |
54 | hda_nid_t gating_nid); | 55 | hda_nid_t gating_nid); |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index bc371cfb5d84..4b338beb9449 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -3019,10 +3019,9 @@ static void stac92hd71bxx_fixup_hp_m4(struct hda_codec *codec, | |||
3019 | /* Enable VREF power saving on GPIO1 detect */ | 3019 | /* Enable VREF power saving on GPIO1 detect */ |
3020 | snd_hda_codec_write_cache(codec, codec->afg, 0, | 3020 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
3021 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); | 3021 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); |
3022 | snd_hda_jack_detect_enable_callback(codec, codec->afg, | 3022 | jack = snd_hda_jack_detect_enable_callback(codec, codec->afg, |
3023 | stac_vref_event); | 3023 | stac_vref_event); |
3024 | jack = snd_hda_jack_tbl_get(codec, codec->afg); | 3024 | if (!IS_ERR(jack)) |
3025 | if (jack) | ||
3026 | jack->private_data = 0x02; | 3025 | jack->private_data = 0x02; |
3027 | 3026 | ||
3028 | spec->gpio_mask |= 0x02; | 3027 | spec->gpio_mask |= 0x02; |
@@ -4042,10 +4041,9 @@ static void stac9205_fixup_dell_m43(struct hda_codec *codec, | |||
4042 | /* Enable unsol response for GPIO4/Dock HP connection */ | 4041 | /* Enable unsol response for GPIO4/Dock HP connection */ |
4043 | snd_hda_codec_write_cache(codec, codec->afg, 0, | 4042 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
4044 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); | 4043 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); |
4045 | snd_hda_jack_detect_enable_callback(codec, codec->afg, | 4044 | jack = snd_hda_jack_detect_enable_callback(codec, codec->afg, |
4046 | stac_vref_event); | 4045 | stac_vref_event); |
4047 | jack = snd_hda_jack_tbl_get(codec, codec->afg); | 4046 | if (!IS_ERR(jack)) |
4048 | if (jack) | ||
4049 | jack->private_data = 0x01; | 4047 | jack->private_data = 0x01; |
4050 | 4048 | ||
4051 | spec->gpio_dir = 0x0b; | 4049 | spec->gpio_dir = 0x0b; |