Commit 922c88a8 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Embed struct hda_bus_unsolicited into struct hda_bus

There is no big merit to handle hda_bus_unsolicited object
individually, as it's tightly coupled with the hda_bus object itself.
Embedding it makes the code simpler in the end.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent ef744978
...@@ -762,10 +762,7 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex) ...@@ -762,10 +762,7 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
return 0; return 0;
trace_hda_unsol_event(bus, res, res_ex); trace_hda_unsol_event(bus, res, res_ex);
unsol = bus->unsol; unsol = &bus->unsol;
if (!unsol)
return 0;
wp = (unsol->wp + 1) % HDA_UNSOL_QUEUE_SIZE; wp = (unsol->wp + 1) % HDA_UNSOL_QUEUE_SIZE;
unsol->wp = wp; unsol->wp = wp;
...@@ -784,9 +781,8 @@ EXPORT_SYMBOL_GPL(snd_hda_queue_unsol_event); ...@@ -784,9 +781,8 @@ EXPORT_SYMBOL_GPL(snd_hda_queue_unsol_event);
*/ */
static void process_unsol_events(struct work_struct *work) static void process_unsol_events(struct work_struct *work)
{ {
struct hda_bus_unsolicited *unsol = struct hda_bus *bus = container_of(work, struct hda_bus, unsol.work);
container_of(work, struct hda_bus_unsolicited, work); struct hda_bus_unsolicited *unsol = &bus->unsol;
struct hda_bus *bus = unsol->bus;
struct hda_codec *codec; struct hda_codec *codec;
unsigned int rp, caddr, res; unsigned int rp, caddr, res;
...@@ -804,27 +800,6 @@ static void process_unsol_events(struct work_struct *work) ...@@ -804,27 +800,6 @@ static void process_unsol_events(struct work_struct *work)
} }
} }
/*
* initialize unsolicited queue
*/
static int init_unsol_queue(struct hda_bus *bus)
{
struct hda_bus_unsolicited *unsol;
if (bus->unsol) /* already initialized */
return 0;
unsol = kzalloc(sizeof(*unsol), GFP_KERNEL);
if (!unsol) {
dev_err(bus->card->dev, "can't allocate unsolicited queue\n");
return -ENOMEM;
}
INIT_WORK(&unsol->work, process_unsol_events);
unsol->bus = bus;
bus->unsol = unsol;
return 0;
}
/* /*
* destructor * destructor
*/ */
...@@ -836,7 +811,6 @@ static void snd_hda_bus_free(struct hda_bus *bus) ...@@ -836,7 +811,6 @@ static void snd_hda_bus_free(struct hda_bus *bus)
WARN_ON(!list_empty(&bus->codec_list)); WARN_ON(!list_empty(&bus->codec_list));
if (bus->workq) if (bus->workq)
flush_workqueue(bus->workq); flush_workqueue(bus->workq);
kfree(bus->unsol);
if (bus->ops.private_free) if (bus->ops.private_free)
bus->ops.private_free(bus); bus->ops.private_free(bus);
if (bus->workq) if (bus->workq)
...@@ -888,6 +862,7 @@ int snd_hda_bus_new(struct snd_card *card, ...@@ -888,6 +862,7 @@ int snd_hda_bus_new(struct snd_card *card,
mutex_init(&bus->cmd_mutex); mutex_init(&bus->cmd_mutex);
mutex_init(&bus->prepare_mutex); mutex_init(&bus->prepare_mutex);
INIT_LIST_HEAD(&bus->codec_list); INIT_LIST_HEAD(&bus->codec_list);
INIT_WORK(&bus->unsol.work, process_unsol_events);
snprintf(bus->workq_name, sizeof(bus->workq_name), snprintf(bus->workq_name, sizeof(bus->workq_name),
"hd-audio%d", card->number); "hd-audio%d", card->number);
...@@ -1689,12 +1664,6 @@ int snd_hda_codec_configure(struct hda_codec *codec) ...@@ -1689,12 +1664,6 @@ int snd_hda_codec_configure(struct hda_codec *codec)
return err; return err;
} }
if (codec->patch_ops.unsol_event) {
err = init_unsol_queue(codec->bus);
if (err < 0)
return err;
}
/* audio codec should override the mixer name */ /* audio codec should override the mixer name */
if (codec->afg || !*codec->bus->card->mixername) if (codec->afg || !*codec->bus->card->mixername)
snprintf(codec->bus->card->mixername, snprintf(codec->bus->card->mixername,
......
...@@ -66,7 +66,6 @@ struct hda_beep; ...@@ -66,7 +66,6 @@ struct hda_beep;
struct hda_codec; struct hda_codec;
struct hda_pcm; struct hda_pcm;
struct hda_pcm_stream; struct hda_pcm_stream;
struct hda_bus_unsolicited;
/* NID type */ /* NID type */
typedef u16 hda_nid_t; typedef u16 hda_nid_t;
...@@ -101,6 +100,16 @@ struct hda_bus_ops { ...@@ -101,6 +100,16 @@ struct hda_bus_ops {
#endif #endif
}; };
/* unsolicited event handler */
#define HDA_UNSOL_QUEUE_SIZE 64
struct hda_bus_unsolicited {
/* ring buffer */
u32 queue[HDA_UNSOL_QUEUE_SIZE * 2];
unsigned int rp, wp;
/* workqueue */
struct work_struct work;
};
/* /*
* codec bus * codec bus
* *
...@@ -126,7 +135,7 @@ struct hda_bus { ...@@ -126,7 +135,7 @@ struct hda_bus {
struct mutex prepare_mutex; struct mutex prepare_mutex;
/* unsolicited event queue */ /* unsolicited event queue */
struct hda_bus_unsolicited *unsol; struct hda_bus_unsolicited unsol;
char workq_name[16]; char workq_name[16];
struct workqueue_struct *workq; /* common workqueue for codecs */ struct workqueue_struct *workq; /* common workqueue for codecs */
......
...@@ -466,23 +466,6 @@ void snd_hda_pick_pin_fixup(struct hda_codec *codec, ...@@ -466,23 +466,6 @@ void snd_hda_pick_pin_fixup(struct hda_codec *codec,
const struct snd_hda_pin_quirk *pin_quirk, const struct snd_hda_pin_quirk *pin_quirk,
const struct hda_fixup *fixlist); const struct hda_fixup *fixlist);
/*
* unsolicited event handler
*/
#define HDA_UNSOL_QUEUE_SIZE 64
struct hda_bus_unsolicited {
/* ring buffer */
u32 queue[HDA_UNSOL_QUEUE_SIZE * 2];
unsigned int rp, wp;
/* workqueue */
struct work_struct work;
struct hda_bus *bus;
};
/* helper macros to retrieve pin default-config values */ /* helper macros to retrieve pin default-config values */
#define get_defcfg_connect(cfg) \ #define get_defcfg_connect(cfg) \
((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT) ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment