Skip to content

Commit 3359e9b

Browse files
morimotobroonie
authored andcommitted
ASoC: soc-card: move snd_soc_card_jack_new() to soc-card
Card related function should be implemented at soc-card now. This patch moves it. Signed-off-by: Kuninori Morimoto <[email protected]> Reviewed-by: Ranjani Sridharan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 209c6cd commit 3359e9b

File tree

4 files changed

+42
-42
lines changed

4 files changed

+42
-42
lines changed

include/sound/soc-card.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@
1010

1111
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
1212
const char *name);
13+
int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
14+
struct snd_soc_jack *jack,
15+
struct snd_soc_jack_pin *pins, unsigned int num_pins);
1316

1417
#endif /* __SOC_CARD_H */

include/sound/soc.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,10 +509,6 @@ int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
509509
const struct snd_pcm_hardware *hw);
510510

511511
/* Jack reporting */
512-
int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
513-
struct snd_soc_jack *jack, struct snd_soc_jack_pin *pins,
514-
unsigned int num_pins);
515-
516512
void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
517513
int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
518514
struct snd_soc_jack_pin *pins);

sound/soc/soc-card.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Kuninori Morimoto <[email protected]>
77
//
88
#include <sound/soc.h>
9+
#include <sound/jack.h>
910

1011
#define soc_card_ret(dai, ret) _soc_card_ret(dai, __func__, ret)
1112
static inline int _soc_card_ret(struct snd_soc_card *card,
@@ -40,3 +41,41 @@ struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
4041
return NULL;
4142
}
4243
EXPORT_SYMBOL_GPL(snd_soc_card_get_kcontrol);
44+
45+
/**
46+
* snd_soc_card_jack_new - Create a new jack
47+
* @card: ASoC card
48+
* @id: an identifying string for this jack
49+
* @type: a bitmask of enum snd_jack_type values that can be detected by
50+
* this jack
51+
* @jack: structure to use for the jack
52+
* @pins: Array of jack pins to be added to the jack or NULL
53+
* @num_pins: Number of elements in the @pins array
54+
*
55+
* Creates a new jack object.
56+
*
57+
* Returns zero if successful, or a negative error code on failure.
58+
* On success jack will be initialised.
59+
*/
60+
int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
61+
struct snd_soc_jack *jack,
62+
struct snd_soc_jack_pin *pins, unsigned int num_pins)
63+
{
64+
int ret;
65+
66+
mutex_init(&jack->mutex);
67+
jack->card = card;
68+
INIT_LIST_HEAD(&jack->pins);
69+
INIT_LIST_HEAD(&jack->jack_zones);
70+
BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier);
71+
72+
ret = snd_jack_new(card->snd_card, id, type, &jack->jack, false, false);
73+
if (ret)
74+
goto end;
75+
76+
if (num_pins)
77+
ret = snd_soc_jack_add_pins(jack, num_pins, pins);
78+
end:
79+
return soc_card_ret(card, ret);
80+
}
81+
EXPORT_SYMBOL_GPL(snd_soc_card_jack_new);

sound/soc/soc-jack.c

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,44 +23,6 @@ struct jack_gpio_tbl {
2323
struct snd_soc_jack_gpio *gpios;
2424
};
2525

26-
/**
27-
* snd_soc_card_jack_new - Create a new jack
28-
* @card: ASoC card
29-
* @id: an identifying string for this jack
30-
* @type: a bitmask of enum snd_jack_type values that can be detected by
31-
* this jack
32-
* @jack: structure to use for the jack
33-
* @pins: Array of jack pins to be added to the jack or NULL
34-
* @num_pins: Number of elements in the @pins array
35-
*
36-
* Creates a new jack object.
37-
*
38-
* Returns zero if successful, or a negative error code on failure.
39-
* On success jack will be initialised.
40-
*/
41-
int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
42-
struct snd_soc_jack *jack, struct snd_soc_jack_pin *pins,
43-
unsigned int num_pins)
44-
{
45-
int ret;
46-
47-
mutex_init(&jack->mutex);
48-
jack->card = card;
49-
INIT_LIST_HEAD(&jack->pins);
50-
INIT_LIST_HEAD(&jack->jack_zones);
51-
BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier);
52-
53-
ret = snd_jack_new(card->snd_card, id, type, &jack->jack, false, false);
54-
if (ret)
55-
return ret;
56-
57-
if (num_pins)
58-
return snd_soc_jack_add_pins(jack, num_pins, pins);
59-
60-
return 0;
61-
}
62-
EXPORT_SYMBOL_GPL(snd_soc_card_jack_new);
63-
6426
/**
6527
* snd_soc_jack_report - Report the current status for a jack
6628
*

0 commit comments

Comments
 (0)