Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'asoc-fix-ac97-v3.19-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus

ASoC: AC'97 fixes

These are rather too large for this late in the release cycle but
they're clear, well understood and have been tested to fix a regression
which was introduced for v3.19. The details are all in Lars' changelog
and they've been cooking in -next for a while, to a large extent out
of conservatism about the size.

+57 -20
+1
include/sound/soc.h
··· 498 498 unsigned int mask, unsigned int value); 499 499 500 500 #ifdef CONFIG_SND_SOC_AC97_BUS 501 + struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec); 501 502 struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec); 502 503 void snd_soc_free_ac97_codec(struct snd_ac97 *ac97); 503 504
+10 -6
sound/soc/codecs/wm9705.c
··· 344 344 struct snd_ac97 *ac97; 345 345 int ret = 0; 346 346 347 - ac97 = snd_soc_new_ac97_codec(codec); 347 + ac97 = snd_soc_alloc_ac97_codec(codec); 348 348 if (IS_ERR(ac97)) { 349 349 ret = PTR_ERR(ac97); 350 350 dev_err(codec->dev, "Failed to register AC97 codec\n"); 351 351 return ret; 352 352 } 353 353 354 - snd_soc_codec_set_drvdata(codec, ac97); 355 - 356 354 ret = wm9705_reset(codec); 357 355 if (ret) 358 - goto reset_err; 356 + goto err_put_device; 357 + 358 + ret = device_add(&ac97->dev); 359 + if (ret) 360 + goto err_put_device; 361 + 362 + snd_soc_codec_set_drvdata(codec, ac97); 359 363 360 364 return 0; 361 365 362 - reset_err: 363 - snd_soc_free_ac97_codec(ac97); 366 + err_put_device: 367 + put_device(&ac97->dev); 364 368 return ret; 365 369 } 366 370
+8 -4
sound/soc/codecs/wm9712.c
··· 666 666 struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); 667 667 int ret = 0; 668 668 669 - wm9712->ac97 = snd_soc_new_ac97_codec(codec); 669 + wm9712->ac97 = snd_soc_alloc_ac97_codec(codec); 670 670 if (IS_ERR(wm9712->ac97)) { 671 671 ret = PTR_ERR(wm9712->ac97); 672 672 dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret); ··· 675 675 676 676 ret = wm9712_reset(codec, 0); 677 677 if (ret < 0) 678 - goto reset_err; 678 + goto err_put_device; 679 + 680 + ret = device_add(&wm9712->ac97->dev); 681 + if (ret) 682 + goto err_put_device; 679 683 680 684 /* set alc mux to none */ 681 685 ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000); 682 686 683 687 return 0; 684 688 685 - reset_err: 686 - snd_soc_free_ac97_codec(wm9712->ac97); 689 + err_put_device: 690 + put_device(&wm9712->ac97->dev); 687 691 return ret; 688 692 } 689 693
+8 -4
sound/soc/codecs/wm9713.c
··· 1225 1225 struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); 1226 1226 int ret = 0, reg; 1227 1227 1228 - wm9713->ac97 = snd_soc_new_ac97_codec(codec); 1228 + wm9713->ac97 = snd_soc_alloc_ac97_codec(codec); 1229 1229 if (IS_ERR(wm9713->ac97)) 1230 1230 return PTR_ERR(wm9713->ac97); 1231 1231 ··· 1234 1234 wm9713_reset(codec, 0); 1235 1235 ret = wm9713_reset(codec, 1); 1236 1236 if (ret < 0) 1237 - goto reset_err; 1237 + goto err_put_device; 1238 + 1239 + ret = device_add(&wm9713->ac97->dev); 1240 + if (ret) 1241 + goto err_put_device; 1238 1242 1239 1243 /* unmute the adc - move to kcontrol */ 1240 1244 reg = ac97_read(codec, AC97_CD) & 0x7fff; ··· 1246 1242 1247 1243 return 0; 1248 1244 1249 - reset_err: 1250 - snd_soc_free_ac97_codec(wm9713->ac97); 1245 + err_put_device: 1246 + put_device(&wm9713->ac97->dev); 1251 1247 return ret; 1252 1248 } 1253 1249
+30 -6
sound/soc/soc-ac97.c
··· 48 48 } 49 49 50 50 /** 51 - * snd_soc_new_ac97_codec - initailise AC97 device 52 - * @codec: audio codec 51 + * snd_soc_alloc_ac97_codec() - Allocate new a AC'97 device 52 + * @codec: The CODEC for which to create the AC'97 device 53 53 * 54 - * Initialises AC97 codec resources for use by ad-hoc devices only. 54 + * Allocated a new snd_ac97 device and intializes it, but does not yet register 55 + * it. The caller is responsible to either call device_add(&ac97->dev) to 56 + * register the device, or to call put_device(&ac97->dev) to free the device. 57 + * 58 + * Returns: A snd_ac97 device or a PTR_ERR in case of an error. 55 59 */ 56 - struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec) 60 + struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec) 57 61 { 58 62 struct snd_ac97 *ac97; 59 - int ret; 60 63 61 64 ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL); 62 65 if (ac97 == NULL) ··· 76 73 codec->component.card->snd_card->number, 0, 77 74 codec->component.name); 78 75 79 - ret = device_register(&ac97->dev); 76 + device_initialize(&ac97->dev); 77 + 78 + return ac97; 79 + } 80 + EXPORT_SYMBOL(snd_soc_alloc_ac97_codec); 81 + 82 + /** 83 + * snd_soc_new_ac97_codec - initailise AC97 device 84 + * @codec: audio codec 85 + * 86 + * Initialises AC97 codec resources for use by ad-hoc devices only. 87 + */ 88 + struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec) 89 + { 90 + struct snd_ac97 *ac97; 91 + int ret; 92 + 93 + ac97 = snd_soc_alloc_ac97_codec(codec); 94 + if (IS_ERR(ac97)) 95 + return ac97; 96 + 97 + ret = device_add(&ac97->dev); 80 98 if (ret) { 81 99 put_device(&ac97->dev); 82 100 return ERR_PTR(ret);