ALSA: hda - Use standard workqueue for unsol and jack events
authorTakashi Iwai <tiwai@suse.de>
Fri, 27 Feb 2015 21:43:26 +0000 (22:43 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 3 Mar 2015 10:37:57 +0000 (11:37 +0100)
The events that are handled by HD-audio drivers are no frequent and
urgent ones, so we can use the standard workqueue without any problem
nowadays.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_codec.h
sound/pci/hda/hda_intel.c
sound/pci/hda/patch_ca0132.c
sound/pci/hda/patch_hdmi.c
sound/pci/hda/patch_via.c

index 7085d3733d0decb96cd3d182ce8b3f6a67d630eb..f2ccb39a37881f2d7f3ede7435d5ba1c06b0ae3c 100644 (file)
@@ -681,7 +681,7 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
        struct hda_bus_unsolicited *unsol;
        unsigned int wp;
 
-       if (!bus || !bus->workq)
+       if (!bus)
                return 0;
 
        trace_hda_unsol_event(bus, res, res_ex);
@@ -693,7 +693,7 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
        unsol->queue[wp] = res;
        unsol->queue[wp + 1] = res_ex;
 
-       queue_work(bus->workq, &unsol->work);
+       schedule_work(&unsol->work);
 
        return 0;
 }
@@ -732,13 +732,9 @@ static void snd_hda_bus_free(struct hda_bus *bus)
                return;
 
        WARN_ON(!list_empty(&bus->codec_list));
-       if (bus->workq)
-               flush_workqueue(bus->workq);
+       cancel_work_sync(&bus->unsol.work);
        if (bus->ops.private_free)
                bus->ops.private_free(bus);
-       if (bus->workq)
-               destroy_workqueue(bus->workq);
-
        kfree(bus);
 }
 
@@ -785,16 +781,6 @@ int snd_hda_bus_new(struct snd_card *card,
        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);
-       bus->workq = create_singlethread_workqueue(bus->workq_name);
-       if (!bus->workq) {
-               dev_err(card->dev, "cannot create workqueue %s\n",
-                          bus->workq_name);
-               kfree(bus);
-               return -ENOMEM;
-       }
-
        err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops);
        if (err < 0) {
                snd_hda_bus_free(bus);
@@ -1068,8 +1054,8 @@ static void hda_jackpoll_work(struct work_struct *work)
        if (!codec->jackpoll_interval)
                return;
 
-       queue_delayed_work(codec->bus->workq, &codec->jackpoll_work,
-                          codec->jackpoll_interval);
+       schedule_delayed_work(&codec->jackpoll_work,
+                             codec->jackpoll_interval);
 }
 
 static void init_hda_cache(struct hda_cache_rec *cache,
@@ -1178,7 +1164,6 @@ static void codec_release_pcms(struct hda_codec *codec)
 void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec)
 {
        cancel_delayed_work_sync(&codec->jackpoll_work);
-       flush_workqueue(codec->bus->workq);
        if (!codec->in_freeing)
                snd_hda_ctls_clear(codec);
        codec_release_pcms(codec);
@@ -1214,7 +1199,6 @@ static void snd_hda_codec_free(struct hda_codec *codec)
        if (device_is_registered(hda_codec_dev(codec)))
                device_del(hda_codec_dev(codec));
        free_init_pincfgs(codec);
-       flush_workqueue(codec->bus->workq);
        list_del(&codec->list);
        codec->bus->caddr_tbl[codec->addr] = NULL;
        clear_bit(codec->addr, &codec->bus->codec_powered);
index 46d253e2f26637450368459f6cff78e38850d6ff..bf9efb7e1b9a3f6c72559c2189d30fd7d87da070 100644 (file)
@@ -132,8 +132,6 @@ struct hda_bus {
 
        /* unsolicited event queue */
        struct hda_bus_unsolicited unsol;
-       char workq_name[16];
-       struct workqueue_struct *workq; /* common workqueue for codecs */
 
        /* assigned PCMs */
        DECLARE_BITMAP(pcm_dev_bits, SNDRV_PCM_DEVICES);
index e81461a413b8b81a83ae3a956e3800a8a87af719..dbc5a593da46af42e88813d51e73788831635d5b 100644 (file)
@@ -528,10 +528,10 @@ static int azx_position_check(struct azx *chip, struct azx_dev *azx_dev)
        if (ok == 1) {
                azx_dev->irq_pending = 0;
                return ok;
-       } else if (ok == 0 && chip->bus && chip->bus->workq) {
+       } else if (ok == 0) {
                /* bogus IRQ, process it later */
                azx_dev->irq_pending = 1;
-               queue_work(chip->bus->workq, &hda->irq_pending_work);
+               schedule_work(&hda->irq_pending_work);
        }
        return 0;
 }
@@ -893,8 +893,8 @@ static int azx_runtime_resume(struct device *dev)
        if (status && bus) {
                list_for_each_entry(codec, &bus->codec_list, list)
                        if (status & (1 << codec->addr))
-                               queue_delayed_work(codec->bus->workq,
-                                                  &codec->jackpoll_work, codec->jackpoll_interval);
+                               schedule_delayed_work(&codec->jackpoll_work,
+                                                     codec->jackpoll_interval);
        }
 
        /* disable controller Wake Up event*/
index 555781fad26f008d554547583af0ec39a0464bcd..72d20652df504ba4cd9a2711bf918bc365608969 100644 (file)
@@ -4410,8 +4410,7 @@ static void hp_callback(struct hda_codec *codec, struct hda_jack_callback *cb)
         * state machine run.
         */
        cancel_delayed_work_sync(&spec->unsol_hp_work);
-       queue_delayed_work(codec->bus->workq, &spec->unsol_hp_work,
-                          msecs_to_jiffies(500));
+       schedule_delayed_work(&spec->unsol_hp_work, msecs_to_jiffies(500));
        cb->tbl->block_report = 1;
 }
 
index 708bbed15ea39973782d141185c65162bad0f60f..7e9ff7b16e5658d5fb3037c0201ee69b9268890d 100644 (file)
@@ -1576,9 +1576,8 @@ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
                        update_eld = true;
                }
                else if (repoll) {
-                       queue_delayed_work(codec->bus->workq,
-                                          &per_pin->work,
-                                          msecs_to_jiffies(300));
+                       schedule_delayed_work(&per_pin->work,
+                                             msecs_to_jiffies(300));
                        goto unlock;
                }
        }
@@ -2198,11 +2197,10 @@ static void generic_hdmi_free(struct hda_codec *codec)
        for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
                struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
 
-               cancel_delayed_work(&per_pin->work);
+               cancel_delayed_work_sync(&per_pin->work);
                eld_proc_free(per_pin);
        }
 
-       flush_workqueue(codec->bus->workq);
        hdmi_array_free(spec);
        kfree(spec);
 }
index 11a05638e03b9d41d2b189872aad78bfd055649e..2112fbe9e577022e300b2c0080fe277ec00998a8 100644 (file)
@@ -222,8 +222,7 @@ static void vt1708_update_hp_work(struct hda_codec *codec)
                if (!spec->hp_work_active) {
                        codec->jackpoll_interval = msecs_to_jiffies(100);
                        snd_hda_codec_write(codec, 0x1, 0, 0xf81, 0);
-                       queue_delayed_work(codec->bus->workq,
-                                          &codec->jackpoll_work, 0);
+                       schedule_delayed_work(&codec->jackpoll_work, 0);
                        spec->hp_work_active = true;
                }
        } else if (!hp_detect_with_aa(codec))