ASoC: ti: ams-delta: Stop (ab)using card->pop_time

A flag is needed that tells the card driver if the codec has been
initialized successfully over the modem's line discipline.  Initially,
codec->hw_write was used as the flag, but it was then dropped and the
flag function associated with card->pop_time, already managed by the
codec driver for diagnostic purposes.  Since now the card->pop_time is
going to be killed, stop abusing foreign fields in favor of an own one.

Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://patch.msgid.link/87v7ctwj0w.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Janusz Krzysztofik
2026-05-12 00:47:43 +00:00
committed by Mark Brown
parent 5200f5f493
commit 446c921ece
3 changed files with 23 additions and 11 deletions

View File

@@ -236,7 +236,8 @@ static int v253_open(struct tty_struct *tty)
/* Line discipline .close() */
static void v253_close(struct tty_struct *tty)
{
struct snd_soc_component *component = tty->disc_data;
struct cx20442_codec *codec = tty->disc_data;
struct snd_soc_component *component = codec->component;
struct cx20442_priv *cx20442;
tty->disc_data = NULL;
@@ -248,6 +249,7 @@ static void v253_close(struct tty_struct *tty)
/* Prevent the codec driver from further accessing the modem */
cx20442->tty = NULL;
codec->ready = false;
component->card->pop_time = 0;
}
@@ -261,7 +263,8 @@ static void v253_hangup(struct tty_struct *tty)
static void v253_receive(struct tty_struct *tty, const u8 *cp, const u8 *fp,
size_t count)
{
struct snd_soc_component *component = tty->disc_data;
struct cx20442_codec *codec = tty->disc_data;
struct snd_soc_component *component = codec->component;
struct cx20442_priv *cx20442;
if (!component)
@@ -274,6 +277,7 @@ static void v253_receive(struct tty_struct *tty, const u8 *cp, const u8 *fp,
/* Set up codec driver access to modem controls */
cx20442->tty = tty;
codec->ready = true;
component->card->pop_time = 1;
}
}

View File

@@ -8,6 +8,11 @@
#ifndef _CX20442_CODEC_H
#define _CX20442_CODEC_H
struct cx20442_codec {
struct snd_soc_component *component;
bool ready;
};
extern struct tty_ldisc_ops v253_ops;
#endif

View File

@@ -93,7 +93,7 @@ static unsigned short ams_delta_audio_agc;
* Used for passing a codec structure pointer
* from the board initialization code to the tty line discipline.
*/
static struct snd_soc_component *cx20442_codec;
static struct cx20442_codec cx20442_codec;
static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
@@ -105,7 +105,7 @@ static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol,
int pin, changed = 0;
/* Refuse any mode changes if we are not able to control the codec. */
if (!cx20442_codec->card->pop_time)
if (!cx20442_codec.ready)
return -EUNATCH;
if (ucontrol->value.enumerated.item[0] >= control->items)
@@ -280,14 +280,14 @@ static int cx81801_open(struct tty_struct *tty)
{
int ret;
if (!cx20442_codec)
if (!cx20442_codec.component)
return -ENODEV;
/*
* Pass the codec structure pointer for use by other ldisc callbacks,
* both the card and the codec specific parts.
*/
tty->disc_data = cx20442_codec;
tty->disc_data = &cx20442_codec;
ret = v253_ops.open(tty);
@@ -300,9 +300,12 @@ static int cx81801_open(struct tty_struct *tty)
/* Line discipline .close() */
static void cx81801_close(struct tty_struct *tty)
{
struct snd_soc_component *component = tty->disc_data;
struct snd_soc_component *component = cx20442_codec.component;
struct snd_soc_dapm_context *dapm;
if (WARN_ON(tty->disc_data != &cx20442_codec))
return;
timer_delete_sync(&cx81801_timer);
/* Prevent the hook switch from further changing the DAPM pins */
@@ -339,14 +342,14 @@ static void cx81801_hangup(struct tty_struct *tty)
static void cx81801_receive(struct tty_struct *tty, const u8 *cp, const u8 *fp,
size_t count)
{
struct snd_soc_component *component = tty->disc_data;
struct snd_soc_component *component = cx20442_codec.component;
const unsigned char *c;
int apply, ret;
if (!component)
if (WARN_ON(tty->disc_data != &cx20442_codec))
return;
if (!component->card->pop_time) {
if (!cx20442_codec.ready) {
/* First modem response, complete setup procedure */
/* Initialize timer used for config pulse generation */
@@ -467,7 +470,7 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
/* Codec is ready, now add/activate board specific controls */
/* Store a pointer to the codec structure for tty ldisc use */
cx20442_codec = snd_soc_rtd_to_codec(rtd, 0)->component;
cx20442_codec.component = snd_soc_rtd_to_codec(rtd, 0)->component;
/* Add hook switch - can be used to control the codec from userspace
* even if line discipline fails */