ALSA: usb: Clean up with new procfs helpers
authorTakashi Iwai <tiwai@suse.de>
Mon, 4 Feb 2019 15:07:35 +0000 (16:07 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 6 Feb 2019 17:11:57 +0000 (18:11 +0100)
Simplify the proc fs creation code with new helper functions,
snd_card_ro_proc_new() and snd_card_rw_proc_new().
Just a code refactoring and no functional changes.

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/mixer.c
sound/usb/mixer_quirks.c
sound/usb/proc.c

index 8ad1a24c8f2867b438584f9d9be0e2580cdf4d1c..73d7dff425c1f80b1e2171c8f215d56ad9e101db 100644 (file)
@@ -3441,7 +3441,6 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
                .dev_free = snd_usb_mixer_dev_free
        };
        struct usb_mixer_interface *mixer;
-       struct snd_info_entry *entry;
        int err;
 
        strcpy(chip->card->mixername, "USB Mixer");
@@ -3497,9 +3496,9 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
        if (err < 0)
                goto _error;
 
-       if (list_empty(&chip->mixer_list) &&
-           !snd_card_proc_new(chip->card, "usbmixer", &entry))
-               snd_info_set_text_ops(entry, chip, snd_usb_mixer_proc_read);
+       if (list_empty(&chip->mixer_list))
+               snd_card_ro_proc_new(chip->card, "usbmixer", chip,
+                                    snd_usb_mixer_proc_read);
 
        list_add(&mixer->list, &chip->mixer_list);
        return 0;
index 85ae0ff2382a28433f3d30bfc69e490e654438d9..a751a18ca4c286bfa3d5b27f7af226142909d40b 100644 (file)
@@ -2195,7 +2195,6 @@ static int snd_rme_controls_create(struct usb_mixer_interface *mixer)
 int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
 {
        int err = 0;
-       struct snd_info_entry *entry;
 
        err = snd_usb_soundblaster_remote_init(mixer);
        if (err < 0)
@@ -2214,9 +2213,8 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
                err = snd_audigy2nx_controls_create(mixer);
                if (err < 0)
                        break;
-               if (!snd_card_proc_new(mixer->chip->card, "audigy2nx", &entry))
-                       snd_info_set_text_ops(entry, mixer,
-                                             snd_audigy2nx_proc_read);
+               snd_card_ro_proc_new(mixer->chip->card, "audigy2nx",
+                                    mixer, snd_audigy2nx_proc_read);
                break;
 
        /* EMU0204 */
index 0ac89e294d31d50895f57aa20d1805b31adf9572..e80c9d0749c9a3832bda8912f8a890d3115b5f48 100644 (file)
@@ -61,11 +61,10 @@ static void proc_audio_usbid_read(struct snd_info_entry *entry, struct snd_info_
 
 void snd_usb_audio_create_proc(struct snd_usb_audio *chip)
 {
-       struct snd_info_entry *entry;
-       if (!snd_card_proc_new(chip->card, "usbbus", &entry))
-               snd_info_set_text_ops(entry, chip, proc_audio_usbbus_read);
-       if (!snd_card_proc_new(chip->card, "usbid", &entry))
-               snd_info_set_text_ops(entry, chip, proc_audio_usbid_read);
+       snd_card_ro_proc_new(chip->card, "usbbus", chip,
+                            proc_audio_usbbus_read);
+       snd_card_ro_proc_new(chip->card, "usbid", chip,
+                            proc_audio_usbid_read);
 }
 
 /*
@@ -167,12 +166,10 @@ static void proc_pcm_format_read(struct snd_info_entry *entry, struct snd_info_b
 
 void snd_usb_proc_pcm_format_add(struct snd_usb_stream *stream)
 {
-       struct snd_info_entry *entry;
        char name[32];
        struct snd_card *card = stream->chip->card;
 
        sprintf(name, "stream%d", stream->pcm_index);
-       if (!snd_card_proc_new(card, name, &entry))
-               snd_info_set_text_ops(entry, stream, proc_pcm_format_read);
+       snd_card_ro_proc_new(card, name, stream, proc_pcm_format_read);
 }