/* 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;
/* Prevent the codec driver from further accessing the modem */
cx20442->tty = NULL;
+ codec->ready = false;
component->card->pop_time = 0;
}
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)
/* Set up codec driver access to modem controls */
cx20442->tty = tty;
+ codec->ready = true;
component->card->pop_time = 1;
}
}
* 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)
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)
{
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);
/* 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 */
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 */
/* 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 */