Merge branch 'topic/pci-rescan-prep-v2' into for-next
authorTakashi Iwai <tiwai@suse.de>
Tue, 25 May 2021 06:50:03 +0000 (08:50 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 25 May 2021 06:50:03 +0000 (08:50 +0200)
Pull PCI rescan prep work.

Link: https://lore.kernel.org/r/20210523090920.15345-1-tiwai@suse.de
1  2 
sound/usb/usx2y/us122l.c

diff --combined sound/usb/usx2y/us122l.c
@@@ -49,7 -49,7 +49,7 @@@ static int us122l_create_usbmidi(struc
        static const struct snd_usb_audio_quirk quirk = {
                .vendor_name =  "US122L",
                .product_name = NAME_ALLCAPS,
 -              .ifnum =        1,
 +              .ifnum =        1,
                .type = QUIRK_MIDI_US122L,
                .data = &quirk_data
        };
@@@ -71,7 -71,7 +71,7 @@@ static int us144_create_usbmidi(struct 
        static const struct snd_usb_audio_quirk quirk = {
                .vendor_name =  "US144",
                .product_name = NAME_ALLCAPS,
 -              .ifnum =        0,
 +              .ifnum =        0,
                .type = QUIRK_MIDI_US122L,
                .data = &quirk_data
        };
@@@ -95,7 -95,6 +95,7 @@@ static void pt_info_set(struct usb_devi
  static void usb_stream_hwdep_vm_open(struct vm_area_struct *area)
  {
        struct us122l *us122l = area->vm_private_data;
 +
        atomic_inc(&us122l->mmap_count);
        snd_printdd(KERN_DEBUG "%i\n", atomic_read(&us122l->mmap_count));
  }
@@@ -114,9 -113,9 +114,9 @@@ static vm_fault_t usb_stream_hwdep_vm_f
                goto unlock;
  
        offset = vmf->pgoff << PAGE_SHIFT;
 -      if (offset < PAGE_ALIGN(s->read_size))
 +      if (offset < PAGE_ALIGN(s->read_size)) {
                vaddr = (char *)s + offset;
 -      else {
 +      else {
                offset -= PAGE_ALIGN(s->read_size);
                if (offset >= PAGE_ALIGN(s->write_size))
                        goto unlock;
@@@ -139,7 -138,6 +139,7 @@@ unlock
  static void usb_stream_hwdep_vm_close(struct vm_area_struct *area)
  {
        struct us122l *us122l = area->vm_private_data;
 +
        atomic_dec(&us122l->mmap_count);
        snd_printdd(KERN_DEBUG "%i\n", atomic_read(&us122l->mmap_count));
  }
@@@ -150,11 -148,11 +150,11 @@@ static const struct vm_operations_struc
        .close = usb_stream_hwdep_vm_close,
  };
  
 -
  static int usb_stream_hwdep_open(struct snd_hwdep *hw, struct file *file)
  {
        struct us122l   *us122l = hw->private_data;
        struct usb_interface *iface;
 +
        snd_printdd(KERN_DEBUG "%p %p\n", hw, file);
        if (hw->used >= 2)
                return -EBUSY;
@@@ -175,7 -173,6 +175,7 @@@ static int usb_stream_hwdep_release(str
  {
        struct us122l   *us122l = hw->private_data;
        struct usb_interface *iface;
 +
        snd_printdd(KERN_DEBUG "%p %p\n", hw, file);
  
        if (us122l->is_us144) {
@@@ -238,7 -235,7 +238,7 @@@ static __poll_t usb_stream_hwdep_poll(s
                                          struct file *file, poll_table *wait)
  {
        struct us122l   *us122l = hw->private_data;
 -      unsigned        *polled;
 +      unsigned int    *polled;
        __poll_t        mask;
  
        poll_wait(file, &us122l->sk.sleep, wait);
        mask = EPOLLIN | EPOLLOUT | EPOLLWRNORM | EPOLLERR;
        if (mutex_trylock(&us122l->mutex)) {
                struct usb_stream *s = us122l->sk.s;
 +
                if (s && s->state == usb_stream_ready) {
                        if (us122l->first == file)
                                polled = &s->periods_polled;
                        if (*polled != s->periods_done) {
                                *polled = s->periods_done;
                                mask = EPOLLIN | EPOLLOUT | EPOLLWRNORM;
 -                      } else
 +                      } else {
                                mask = 0;
 +                      }
                }
                mutex_unlock(&us122l->mutex);
        }
  static void us122l_stop(struct us122l *us122l)
  {
        struct list_head *p;
 +
        list_for_each(p, &us122l->midi_list)
                snd_usbmidi_input_stop(p);
  
@@@ -295,11 -289,11 +295,11 @@@ static int us122l_set_sample_rate(struc
  }
  
  static bool us122l_start(struct us122l *us122l,
 -                       unsigned rate, unsigned period_frames)
 +                       unsigned int rate, unsigned int period_frames)
  {
        struct list_head *p;
        int err;
 -      unsigned use_packsize = 0;
 +      unsigned int use_packsize = 0;
        bool success = false;
  
        if (us122l->dev->speed == USB_SPEED_HIGH) {
        err = us122l_set_sample_rate(us122l->dev, rate);
        if (err < 0) {
                us122l_stop(us122l);
 -              snd_printk(KERN_ERR "us122l_set_sample_rate error \n");
 +              snd_printk(KERN_ERR "us122l_set_sample_rate error\n");
                goto out;
        }
        err = usb_stream_start(&us122l->sk);
        if (err < 0) {
                us122l_stop(us122l);
 -              snd_printk(KERN_ERR "us122l_start error %i \n", err);
 +              snd_printk(KERN_ERR "%s error %i\n", __func__, err);
                goto out;
        }
        list_for_each(p, &us122l->midi_list)
@@@ -343,12 -337,12 +343,12 @@@ out
  }
  
  static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
 -                                unsigned cmd, unsigned long arg)
 +                                unsigned int cmd, unsigned long arg)
  {
        struct usb_stream_config cfg;
        struct us122l *us122l = hw->private_data;
        struct usb_stream *s;
 -      unsigned min_period_frames;
 +      unsigned int min_period_frames;
        int err = 0;
        bool high_speed;
  
        if (cfg.period_frames < min_period_frames)
                return -EINVAL;
  
-       snd_power_wait(hw->card, SNDRV_CTL_POWER_D0);
+       snd_power_wait(hw->card);
  
        mutex_lock(&us122l->mutex);
        s = us122l->sk.s;
 -      if (!us122l->master)
 +      if (!us122l->master) {
                us122l->master = file;
 -      else if (us122l->master != file) {
 +      else if (us122l->master != file) {
                if (!s || memcmp(&cfg, &s->cfg, sizeof(cfg))) {
                        err = -EIO;
                        goto unlock;
@@@ -437,6 -431,7 +437,6 @@@ static int usb_stream_hwdep_new(struct 
        return 0;
  }
  
 -
  static bool us122l_create_card(struct snd_card *card)
  {
        int err;
        if (us122l->is_us144) {
                err = usb_set_interface(us122l->dev, 0, 1);
                if (err) {
 -                      snd_printk(KERN_ERR "usb_set_interface error \n");
 +                      snd_printk(KERN_ERR "usb_set_interface error\n");
                        return false;
                }
        }
        err = usb_set_interface(us122l->dev, 1, 1);
        if (err) {
 -              snd_printk(KERN_ERR "usb_set_interface error \n");
 +              snd_printk(KERN_ERR "usb_set_interface error\n");
                return false;
        }
  
        else
                err = us122l_create_usbmidi(card);
        if (err < 0) {
 -              snd_printk(KERN_ERR "us122l_create_usbmidi error %i \n", err);
 +              snd_printk(KERN_ERR "us122l_create_usbmidi error %i\n", err);
                goto stop;
        }
        err = usb_stream_hwdep_new(card);
        if (err < 0) {
 -/* release the midi resources */
 +              /* release the midi resources */
                struct list_head *p;
 +
                list_for_each(p, &us122l->midi_list)
                        snd_usbmidi_disconnect(p);
  
@@@ -490,8 -484,7 +490,8 @@@ static void snd_us122l_free(struct snd_
  {
        struct us122l   *us122l = US122L(card);
        int             index = us122l->card_index;
 -      if (index >= 0  &&  index < SNDRV_CARDS)
 +
 +      if (index >= 0 && index < SNDRV_CARDS)
                snd_us122l_card_used[index] = 0;
  }
  
@@@ -572,7 -565,7 +572,7 @@@ static int snd_us122l_probe(struct usb_
  
        if (id->driver_info & US122L_FLAG_US144 &&
                        device->speed == USB_SPEED_HIGH) {
 -              snd_printk(KERN_ERR "disable ehci-hcd to run US-144 \n");
 +              snd_printk(KERN_ERR "disable ehci-hcd to run US-144\n");
                return -ENODEV;
        }
  
@@@ -608,7 -601,7 +608,7 @@@ static void snd_us122l_disconnect(struc
        us122l_stop(us122l);
        mutex_unlock(&us122l->mutex);
  
 -/* release the midi resources */
 +      /* release the midi resources */
        list_for_each(p, &us122l->midi_list) {
                snd_usbmidi_disconnect(p);
        }
@@@ -668,13 -661,13 +668,13 @@@ static int snd_us122l_resume(struct usb
        if (us122l->is_us144) {
                err = usb_set_interface(us122l->dev, 0, 1);
                if (err) {
 -                      snd_printk(KERN_ERR "usb_set_interface error \n");
 +                      snd_printk(KERN_ERR "usb_set_interface error\n");
                        goto unlock;
                }
        }
        err = usb_set_interface(us122l->dev, 1, 1);
        if (err) {
 -              snd_printk(KERN_ERR "usb_set_interface error \n");
 +              snd_printk(KERN_ERR "usb_set_interface error\n");
                goto unlock;
        }
  
        err = us122l_set_sample_rate(us122l->dev,
                                     us122l->sk.s->cfg.sample_rate);
        if (err < 0) {
 -              snd_printk(KERN_ERR "us122l_set_sample_rate error \n");
 +              snd_printk(KERN_ERR "us122l_set_sample_rate error\n");
                goto unlock;
        }
        err = usb_stream_start(&us122l->sk);
@@@ -724,8 -717,8 +724,8 @@@ static const struct usb_device_id snd_u
        },
        { /* terminator */ }
  };
 -
  MODULE_DEVICE_TABLE(usb, snd_us122l_usb_id_table);
 +
  static struct usb_driver snd_us122l_usb_driver = {
        .name =         "snd-usb-us122l",
        .probe =        snd_us122l_probe,