ALSA: Convert timers to use timer_setup()
authorKees Cook <keescook@chromium.org>
Wed, 25 Oct 2017 15:09:27 +0000 (08:09 -0700)
committerTakashi Iwai <tiwai@suse.de>
Thu, 26 Oct 2017 12:44:59 +0000 (14:44 +0200)
In preparation for unconditionally passing the struct timer_list
pointer to all timer callbacks, switch to using the new timer_setup()
and from_timer() to pass the timer pointer explicitly. These are all the
"mechanical" changes remaining in the sound subsystem.

Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/i2c/other/ak4117.c
sound/pci/ctxfi/cttimer.c
sound/pci/echoaudio/midi.c
sound/pci/korg1212/korg1212.c
sound/pci/rme9652/hdsp.c
sound/pci/rme9652/hdspm.c
sound/soc/codecs/rt5645.c
sound/soc/omap/ams-delta.c

index 3ab099fb8c15fc913b73e0267e409a74bec7df65..b923342cadf4e4bb451fc514fa389cf578d3f0f1 100644 (file)
@@ -35,7 +35,7 @@ MODULE_LICENSE("GPL");
 
 #define AK4117_ADDR                    0x00 /* fixed address */
 
-static void snd_ak4117_timer(unsigned long data);
+static void snd_ak4117_timer(struct timer_list *t);
 
 static void reg_write(struct ak4117 *ak4117, unsigned char reg, unsigned char val)
 {
@@ -91,7 +91,7 @@ int snd_ak4117_create(struct snd_card *card, ak4117_read_t *read, ak4117_write_t
        chip->read = read;
        chip->write = write;
        chip->private_data = private_data;
-       setup_timer(&chip->timer, snd_ak4117_timer, (unsigned long)chip);
+       timer_setup(&chip->timer, snd_ak4117_timer, 0);
 
        for (reg = 0; reg < 5; reg++)
                chip->regmap[reg] = pgm[reg];
@@ -529,9 +529,9 @@ int snd_ak4117_check_rate_and_errors(struct ak4117 *ak4117, unsigned int flags)
        return res;
 }
 
-static void snd_ak4117_timer(unsigned long data)
+static void snd_ak4117_timer(struct timer_list *t)
 {
-       struct ak4117 *chip = (struct ak4117 *)data;
+       struct ak4117 *chip = from_timer(chip, t, timer);
 
        if (chip->init)
                return;
index 8f945341720bb594d54694bd5f99be855dcd339a..08e874e9a7f6419a26728ff871cc2bdd86480e8f 100644 (file)
@@ -63,9 +63,9 @@ struct ct_timer {
  * system-timer-based updates
  */
 
-static void ct_systimer_callback(unsigned long data)
+static void ct_systimer_callback(struct timer_list *t)
 {
-       struct ct_timer_instance *ti = (struct ct_timer_instance *)data;
+       struct ct_timer_instance *ti = from_timer(ti, t, timer);
        struct snd_pcm_substream *substream = ti->substream;
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct ct_atc_pcm *apcm = ti->apcm;
@@ -93,8 +93,7 @@ static void ct_systimer_callback(unsigned long data)
 
 static void ct_systimer_init(struct ct_timer_instance *ti)
 {
-       setup_timer(&ti->timer, ct_systimer_callback,
-                   (unsigned long)ti);
+       timer_setup(&ti->timer, ct_systimer_callback, 0);
 }
 
 static void ct_systimer_start(struct ct_timer_instance *ti)
index 8c685ddb1a41b8c4f1e7964274ebb0d27e8b35f3..6045a115cffe77d868d71d642196635e3e86787d 100644 (file)
@@ -199,9 +199,9 @@ static int snd_echo_midi_output_open(struct snd_rawmidi_substream *substream)
 
 
 
-static void snd_echo_midi_output_write(unsigned long data)
+static void snd_echo_midi_output_write(struct timer_list *t)
 {
-       struct echoaudio *chip = (struct echoaudio *)data;
+       struct echoaudio *chip = from_timer(chip, t, timer);
        unsigned long flags;
        int bytes, sent, time;
        unsigned char buf[MIDI_OUT_BUFFER_SIZE - 1];
@@ -257,8 +257,8 @@ static void snd_echo_midi_output_trigger(struct snd_rawmidi_substream *substream
        spin_lock_irq(&chip->lock);
        if (up) {
                if (!chip->tinuse) {
-                       setup_timer(&chip->timer, snd_echo_midi_output_write,
-                                   (unsigned long)chip);
+                       timer_setup(&chip->timer, snd_echo_midi_output_write,
+                                   0);
                        chip->tinuse = 1;
                }
        } else {
@@ -273,7 +273,7 @@ static void snd_echo_midi_output_trigger(struct snd_rawmidi_substream *substream
        spin_unlock_irq(&chip->lock);
 
        if (up && !chip->midi_full)
-               snd_echo_midi_output_write((unsigned long)chip);
+               snd_echo_midi_output_write(&chip->timer);
 }
 
 
index 04cd71c74e5ceac3bdd790cc64d1e39dd4543240..c7b007164c991abad63026be35c6948bd44893ab 100644 (file)
@@ -599,9 +599,9 @@ static void snd_korg1212_SendStopAndWait(struct snd_korg1212 *korg1212)
 }
 
 /* timer callback for checking the ack of stop request */
-static void snd_korg1212_timer_func(unsigned long data)
+static void snd_korg1212_timer_func(struct timer_list *t)
 {
-        struct snd_korg1212 *korg1212 = (struct snd_korg1212 *) data;
+       struct snd_korg1212 *korg1212 = from_timer(korg1212, t, timer);
        unsigned long flags;
        
        spin_lock_irqsave(&korg1212->lock, flags);
@@ -2189,8 +2189,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
         init_waitqueue_head(&korg1212->wait);
         spin_lock_init(&korg1212->lock);
        mutex_init(&korg1212->open_mutex);
-       setup_timer(&korg1212->timer, snd_korg1212_timer_func,
-                   (unsigned long)korg1212);
+       timer_setup(&korg1212->timer, snd_korg1212_timer_func, 0);
 
         korg1212->irq = -1;
         korg1212->clkSource = K1212_CLKIDX_Local;
index 9f0f73875f01d8a0ed2a373d725a23a1e6c0b5ed..1bff4b1b39cd04651f16efa1e151ca87c2804d9c 100644 (file)
@@ -1410,9 +1410,9 @@ static void snd_hdsp_midi_input_trigger(struct snd_rawmidi_substream *substream,
        spin_unlock_irqrestore (&hdsp->lock, flags);
 }
 
-static void snd_hdsp_midi_output_timer(unsigned long data)
+static void snd_hdsp_midi_output_timer(struct timer_list *t)
 {
-       struct hdsp_midi *hmidi = (struct hdsp_midi *) data;
+       struct hdsp_midi *hmidi = from_timer(hmidi, t, timer);
        unsigned long flags;
 
        snd_hdsp_midi_output_write(hmidi);
@@ -1439,8 +1439,8 @@ static void snd_hdsp_midi_output_trigger(struct snd_rawmidi_substream *substream
        spin_lock_irqsave (&hmidi->lock, flags);
        if (up) {
                if (!hmidi->istimer) {
-                       setup_timer(&hmidi->timer, snd_hdsp_midi_output_timer,
-                                   (unsigned long) hmidi);
+                       timer_setup(&hmidi->timer, snd_hdsp_midi_output_timer,
+                                   0);
                        mod_timer(&hmidi->timer, 1 + jiffies);
                        hmidi->istimer++;
                }
index f20d42714e4db0378b9400247870585f8f9fb270..4c59983158e0ed8d37bcad8ae3735129a1bd1ef8 100644 (file)
@@ -1946,9 +1946,9 @@ snd_hdspm_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
        spin_unlock_irqrestore (&hdspm->lock, flags);
 }
 
-static void snd_hdspm_midi_output_timer(unsigned long data)
+static void snd_hdspm_midi_output_timer(struct timer_list *t)
 {
-       struct hdspm_midi *hmidi = (struct hdspm_midi *) data;
+       struct hdspm_midi *hmidi = from_timer(hmidi, t, timer);
        unsigned long flags;
 
        snd_hdspm_midi_output_write(hmidi);
@@ -1976,8 +1976,8 @@ snd_hdspm_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
        spin_lock_irqsave (&hmidi->lock, flags);
        if (up) {
                if (!hmidi->istimer) {
-                       setup_timer(&hmidi->timer, snd_hdspm_midi_output_timer,
-                                   (unsigned long) hmidi);
+                       timer_setup(&hmidi->timer,
+                                   snd_hdspm_midi_output_timer, 0);
                        mod_timer(&hmidi->timer, 1 + jiffies);
                        hmidi->istimer++;
                }
index a98647ac497cc7e64a99990e9ad3b0097eb829e6..735f2d0033dd856f3d6492bd24a0d2963a92d36a 100644 (file)
@@ -3340,9 +3340,9 @@ static irqreturn_t rt5645_irq(int irq, void *data)
        return IRQ_HANDLED;
 }
 
-static void rt5645_btn_check_callback(unsigned long data)
+static void rt5645_btn_check_callback(struct timer_list *t)
 {
-       struct rt5645_priv *rt5645 = (struct rt5645_priv *)data;
+       struct rt5645_priv *rt5645 = from_timer(rt5645, t, btn_check_timer);
 
        queue_delayed_work(system_power_efficient_wq,
                   &rt5645->jack_detect_work, msecs_to_jiffies(5));
@@ -3934,8 +3934,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
                regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
                        RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV);
        }
-       setup_timer(&rt5645->btn_check_timer,
-               rt5645_btn_check_callback, (unsigned long)rt5645);
+       timer_setup(&rt5645->btn_check_timer, rt5645_btn_check_callback, 0);
 
        INIT_DELAYED_WORK(&rt5645->jack_detect_work, rt5645_jack_detect_work);
        INIT_DELAYED_WORK(&rt5645->rcclock_work, rt5645_rcclock_work);
index 6c49f3d6fd965bcbfe984f2fcf457c2bc832181b..d40219678700ed21fc6f45b0ef54f224ddeaa9da 100644 (file)
@@ -260,7 +260,7 @@ static bool cx81801_cmd_pending;
 static bool ams_delta_muted;
 static DEFINE_SPINLOCK(ams_delta_lock);
 
-static void cx81801_timeout(unsigned long data)
+static void cx81801_timeout(struct timer_list *unused)
 {
        int muted;
 
@@ -349,7 +349,7 @@ static void cx81801_receive(struct tty_struct *tty,
                /* First modem response, complete setup procedure */
 
                /* Initialize timer used for config pulse generation */
-               setup_timer(&cx81801_timer, cx81801_timeout, 0);
+               timer_setup(&cx81801_timer, cx81801_timeout, 0);
 
                v253_ops.receive_buf(tty, cp, fp, count);