]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ALSA: hda - Embed struct hda_bus_unsolicited into struct hda_bus
authorTakashi Iwai <tiwai@suse.de>
Tue, 17 Feb 2015 13:46:40 +0000 (14:46 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 17 Feb 2015 13:46:40 +0000 (14:46 +0100)
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: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_codec.h
sound/pci/hda/hda_local.h

index 215bf048c668760463495d549aa9413be660e630..0734cb35887d7a5d62aff6f576f362284ea7b26c 100644 (file)
@@ -762,10 +762,7 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
                return 0;
 
        trace_hda_unsol_event(bus, res, res_ex);
-       unsol = bus->unsol;
-       if (!unsol)
-               return 0;
-
+       unsol = &bus->unsol;
        wp = (unsol->wp + 1) % HDA_UNSOL_QUEUE_SIZE;
        unsol->wp = wp;
 
@@ -784,9 +781,8 @@ EXPORT_SYMBOL_GPL(snd_hda_queue_unsol_event);
  */
 static void process_unsol_events(struct work_struct *work)
 {
-       struct hda_bus_unsolicited *unsol =
-               container_of(work, struct hda_bus_unsolicited, work);
-       struct hda_bus *bus = unsol->bus;
+       struct hda_bus *bus = container_of(work, struct hda_bus, unsol.work);
+       struct hda_bus_unsolicited *unsol = &bus->unsol;
        struct hda_codec *codec;
        unsigned int rp, caddr, res;
 
@@ -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
  */
@@ -836,7 +811,6 @@ static void snd_hda_bus_free(struct hda_bus *bus)
        WARN_ON(!list_empty(&bus->codec_list));
        if (bus->workq)
                flush_workqueue(bus->workq);
-       kfree(bus->unsol);
        if (bus->ops.private_free)
                bus->ops.private_free(bus);
        if (bus->workq)
@@ -888,6 +862,7 @@ int snd_hda_bus_new(struct snd_card *card,
        mutex_init(&bus->cmd_mutex);
        mutex_init(&bus->prepare_mutex);
        INIT_LIST_HEAD(&bus->codec_list);
+       INIT_WORK(&bus->unsol.work, process_unsol_events);
 
        snprintf(bus->workq_name, sizeof(bus->workq_name),
                 "hd-audio%d", card->number);
@@ -1689,12 +1664,6 @@ int snd_hda_codec_configure(struct hda_codec *codec)
                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 */
        if (codec->afg || !*codec->bus->card->mixername)
                snprintf(codec->bus->card->mixername,
index 5a6594884069244668d4ccabba64834e6fa0db08..96421a3b32cd94d76771a7b2636be2662c4af712 100644 (file)
@@ -66,7 +66,6 @@ struct hda_beep;
 struct hda_codec;
 struct hda_pcm;
 struct hda_pcm_stream;
-struct hda_bus_unsolicited;
 
 /* NID type */
 typedef u16 hda_nid_t;
@@ -101,6 +100,16 @@ struct hda_bus_ops {
 #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
  *
@@ -126,7 +135,7 @@ struct hda_bus {
        struct mutex prepare_mutex;
 
        /* unsolicited event queue */
-       struct hda_bus_unsolicited *unsol;
+       struct hda_bus_unsolicited unsol;
        char workq_name[16];
        struct workqueue_struct *workq; /* common workqueue for codecs */
 
index 62658f2f8c9f2db94fca481a86da8432858105a0..49c08a7278c449f195cfc3de5ae14d2075c6c97b 100644 (file)
@@ -466,23 +466,6 @@ void snd_hda_pick_pin_fixup(struct hda_codec *codec,
                            const struct snd_hda_pin_quirk *pin_quirk,
                            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 */
 #define get_defcfg_connect(cfg) \
        ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT)