Skip to content

Commit

Permalink
ALSA: pci: Clean up with new procfs helpers
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
tiwai committed Feb 6, 2019
1 parent 5a170e9 commit 47f2769
Show file tree
Hide file tree
Showing 38 changed files with 133 additions and 278 deletions.
6 changes: 2 additions & 4 deletions sound/pci/ad1889.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,10 +741,8 @@ snd_ad1889_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffe
static void
snd_ad1889_proc_init(struct snd_ad1889 *chip)
{
struct snd_info_entry *entry;

if (!snd_card_proc_new(chip->card, chip->card->driver, &entry))
snd_info_set_text_ops(entry, chip, snd_ad1889_proc_read);
snd_card_ro_proc_new(chip->card, chip->card->driver,
chip, snd_ad1889_proc_read);
}

static const struct ac97_quirk ac97_quirks[] = {
Expand Down
5 changes: 1 addition & 4 deletions sound/pci/ak4531_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,5 @@ static void snd_ak4531_proc_read(struct snd_info_entry *entry,
static void
snd_ak4531_proc_init(struct snd_card *card, struct snd_ak4531 *ak4531)
{
struct snd_info_entry *entry;

if (! snd_card_proc_new(card, "ak4531", &entry))
snd_info_set_text_ops(entry, ak4531, snd_ak4531_proc_read);
snd_card_ro_proc_new(card, "ak4531", ak4531, snd_ak4531_proc_read);
}
4 changes: 1 addition & 3 deletions sound/pci/ali5451/ali5451.c
Original file line number Diff line number Diff line change
Expand Up @@ -2049,9 +2049,7 @@ static void snd_ali_proc_read(struct snd_info_entry *entry,

static void snd_ali_proc_init(struct snd_ali *codec)
{
struct snd_info_entry *entry;
if (!snd_card_proc_new(codec->card, "ali5451", &entry))
snd_info_set_text_ops(entry, codec, snd_ali_proc_read);
snd_card_ro_proc_new(codec->card, "ali5451", codec, snd_ali_proc_read);
}

static int snd_ali_resources(struct snd_ali *codec)
Expand Down
6 changes: 2 additions & 4 deletions sound/pci/asihpi/asihpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2782,10 +2782,8 @@ snd_asihpi_proc_read(struct snd_info_entry *entry,

static void snd_asihpi_proc_init(struct snd_card_asihpi *asihpi)
{
struct snd_info_entry *entry;

if (!snd_card_proc_new(asihpi->card, "info", &entry))
snd_info_set_text_ops(entry, asihpi, snd_asihpi_proc_read);
snd_card_ro_proc_new(asihpi->card, "info", asihpi,
snd_asihpi_proc_read);
}

/*------------------------------------------------------------
Expand Down
5 changes: 1 addition & 4 deletions sound/pci/atiixp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1543,10 +1543,7 @@ static void snd_atiixp_proc_read(struct snd_info_entry *entry,

static void snd_atiixp_proc_init(struct atiixp *chip)
{
struct snd_info_entry *entry;

if (! snd_card_proc_new(chip->card, "atiixp", &entry))
snd_info_set_text_ops(entry, chip, snd_atiixp_proc_read);
snd_card_ro_proc_new(chip->card, "atiixp", chip, snd_atiixp_proc_read);
}


Expand Down
6 changes: 2 additions & 4 deletions sound/pci/atiixp_modem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1170,10 +1170,8 @@ static void snd_atiixp_proc_read(struct snd_info_entry *entry,

static void snd_atiixp_proc_init(struct atiixp_modem *chip)
{
struct snd_info_entry *entry;

if (! snd_card_proc_new(chip->card, "atiixp-modem", &entry))
snd_info_set_text_ops(entry, chip, snd_atiixp_proc_read);
snd_card_ro_proc_new(chip->card, "atiixp-modem", chip,
snd_atiixp_proc_read);
}


Expand Down
40 changes: 15 additions & 25 deletions sound/pci/ca0106/ca0106_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,30 +424,20 @@ static void snd_ca0106_proc_i2c_write(struct snd_info_entry *entry,

int snd_ca0106_proc_init(struct snd_ca0106 *emu)
{
struct snd_info_entry *entry;

if(! snd_card_proc_new(emu->card, "iec958", &entry))
snd_info_set_text_ops(entry, emu, snd_ca0106_proc_iec958);
if(! snd_card_proc_new(emu->card, "ca0106_reg32", &entry)) {
snd_info_set_text_ops(entry, emu, snd_ca0106_proc_reg_read32);
entry->c.text.write = snd_ca0106_proc_reg_write32;
entry->mode |= 0200;
}
if(! snd_card_proc_new(emu->card, "ca0106_reg16", &entry))
snd_info_set_text_ops(entry, emu, snd_ca0106_proc_reg_read16);
if(! snd_card_proc_new(emu->card, "ca0106_reg8", &entry))
snd_info_set_text_ops(entry, emu, snd_ca0106_proc_reg_read8);
if(! snd_card_proc_new(emu->card, "ca0106_regs1", &entry)) {
snd_info_set_text_ops(entry, emu, snd_ca0106_proc_reg_read1);
entry->c.text.write = snd_ca0106_proc_reg_write;
entry->mode |= 0200;
}
if(! snd_card_proc_new(emu->card, "ca0106_i2c", &entry)) {
entry->c.text.write = snd_ca0106_proc_i2c_write;
entry->private_data = emu;
entry->mode |= 0200;
}
if(! snd_card_proc_new(emu->card, "ca0106_regs2", &entry))
snd_info_set_text_ops(entry, emu, snd_ca0106_proc_reg_read2);
snd_card_ro_proc_new(emu->card, "iec958", emu, snd_ca0106_proc_iec958);
snd_card_rw_proc_new(emu->card, "ca0106_reg32", emu,
snd_ca0106_proc_reg_read32,
snd_ca0106_proc_reg_write32);
snd_card_ro_proc_new(emu->card, "ca0106_reg16", emu,
snd_ca0106_proc_reg_read16);
snd_card_ro_proc_new(emu->card, "ca0106_reg8", emu,
snd_ca0106_proc_reg_read8);
snd_card_rw_proc_new(emu->card, "ca0106_regs1", emu,
snd_ca0106_proc_reg_read1,
snd_ca0106_proc_reg_write);
snd_card_rw_proc_new(emu->card, "ca0106_i2c", emu, NULL,
snd_ca0106_proc_i2c_write);
snd_card_ro_proc_new(emu->card, "ca0106_regs2", emu,
snd_ca0106_proc_reg_read2);
return 0;
}
5 changes: 1 addition & 4 deletions sound/pci/cmipci.c
Original file line number Diff line number Diff line change
Expand Up @@ -2792,10 +2792,7 @@ static void snd_cmipci_proc_read(struct snd_info_entry *entry,

static void snd_cmipci_proc_init(struct cmipci *cm)
{
struct snd_info_entry *entry;

if (! snd_card_proc_new(cm->card, "cmipci", &entry))
snd_info_set_text_ops(entry, cm, snd_cmipci_proc_read);
snd_card_ro_proc_new(cm->card, "cmipci", cm, snd_cmipci_proc_read);
}

static const struct pci_device_id snd_cmipci_ids[] = {
Expand Down
3 changes: 1 addition & 2 deletions sound/pci/cs4281.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,8 +1174,7 @@ static void snd_cs4281_proc_init(struct cs4281 *chip)
{
struct snd_info_entry *entry;

if (! snd_card_proc_new(chip->card, "cs4281", &entry))
snd_info_set_text_ops(entry, chip, snd_cs4281_proc_read);
snd_card_ro_proc_new(chip->card, "cs4281", chip, snd_cs4281_proc_read);
if (! snd_card_proc_new(chip->card, "cs4281_BA0", &entry)) {
entry->content = SNDRV_INFO_CONTENT_DATA;
entry->private_data = chip;
Expand Down
12 changes: 3 additions & 9 deletions sound/pci/emu10k1/emu10k1x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,15 +1065,9 @@ static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry,

static int snd_emu10k1x_proc_init(struct emu10k1x *emu)
{
struct snd_info_entry *entry;

if(! snd_card_proc_new(emu->card, "emu10k1x_regs", &entry)) {
snd_info_set_text_ops(entry, emu, snd_emu10k1x_proc_reg_read);
entry->c.text.write = snd_emu10k1x_proc_reg_write;
entry->mode |= 0200;
entry->private_data = emu;
}

snd_card_rw_proc_new(emu->card, "emu10k1x_regs", emu,
snd_emu10k1x_proc_reg_read,
snd_emu10k1x_proc_reg_write);
return 0;
}

Expand Down
81 changes: 31 additions & 50 deletions sound/pci/emu10k1/emuproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,55 +568,40 @@ int snd_emu10k1_proc_init(struct snd_emu10k1 *emu)
struct snd_info_entry *entry;
#ifdef CONFIG_SND_DEBUG
if (emu->card_capabilities->emu_model) {
if (! snd_card_proc_new(emu->card, "emu1010_regs", &entry))
snd_info_set_text_ops(entry, emu, snd_emu_proc_emu1010_reg_read);
}
if (! snd_card_proc_new(emu->card, "io_regs", &entry)) {
snd_info_set_text_ops(entry, emu, snd_emu_proc_io_reg_read);
entry->c.text.write = snd_emu_proc_io_reg_write;
entry->mode |= 0200;
}
if (! snd_card_proc_new(emu->card, "ptr_regs00a", &entry)) {
snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00a);
entry->c.text.write = snd_emu_proc_ptr_reg_write00;
entry->mode |= 0200;
}
if (! snd_card_proc_new(emu->card, "ptr_regs00b", &entry)) {
snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00b);
entry->c.text.write = snd_emu_proc_ptr_reg_write00;
entry->mode |= 0200;
}
if (! snd_card_proc_new(emu->card, "ptr_regs20a", &entry)) {
snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20a);
entry->c.text.write = snd_emu_proc_ptr_reg_write20;
entry->mode |= 0200;
}
if (! snd_card_proc_new(emu->card, "ptr_regs20b", &entry)) {
snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20b);
entry->c.text.write = snd_emu_proc_ptr_reg_write20;
entry->mode |= 0200;
}
if (! snd_card_proc_new(emu->card, "ptr_regs20c", &entry)) {
snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20c);
entry->c.text.write = snd_emu_proc_ptr_reg_write20;
entry->mode |= 0200;
snd_card_ro_proc_new(emu->card, "emu1010_regs",
emu, snd_emu_proc_emu1010_reg_read);
}
snd_card_rw_proc_new(emu->card, "io_regs", emu,
snd_emu_proc_io_reg_read,
snd_emu_proc_io_reg_write);
snd_card_rw_proc_new(emu->card, "ptr_regs00a", emu,
snd_emu_proc_ptr_reg_read00a,
snd_emu_proc_ptr_reg_write00);
snd_card_rw_proc_new(emu->card, "ptr_regs00b", emu,
snd_emu_proc_ptr_reg_read00b,
snd_emu_proc_ptr_reg_write00);
snd_card_rw_proc_new(emu->card, "ptr_regs20a", emu,
snd_emu_proc_ptr_reg_read20a,
snd_emu_proc_ptr_reg_write20);
snd_card_rw_proc_new(emu->card, "ptr_regs20b", emu,
snd_emu_proc_ptr_reg_read20b,
snd_emu_proc_ptr_reg_write20);
snd_card_rw_proc_new(emu->card, "ptr_regs20c", emu,
snd_emu_proc_ptr_reg_read20c,
snd_emu_proc_ptr_reg_write20);
#endif

if (! snd_card_proc_new(emu->card, "emu10k1", &entry))
snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_read);
snd_card_ro_proc_new(emu->card, "emu10k1", emu, snd_emu10k1_proc_read);

if (emu->card_capabilities->emu10k2_chip) {
if (! snd_card_proc_new(emu->card, "spdif-in", &entry))
snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_spdif_read);
}
if (emu->card_capabilities->ca0151_chip) {
if (! snd_card_proc_new(emu->card, "capture-rates", &entry))
snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_rates_read);
}
if (emu->card_capabilities->emu10k2_chip)
snd_card_ro_proc_new(emu->card, "spdif-in", emu,
snd_emu10k1_proc_spdif_read);
if (emu->card_capabilities->ca0151_chip)
snd_card_ro_proc_new(emu->card, "capture-rates", emu,
snd_emu10k1_proc_rates_read);

if (! snd_card_proc_new(emu->card, "voices", &entry))
snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_voices_read);
snd_card_ro_proc_new(emu->card, "voices", emu,
snd_emu10k1_proc_voices_read);

if (! snd_card_proc_new(emu->card, "fx8010_gpr", &entry)) {
entry->content = SNDRV_INFO_CONTENT_DATA;
Expand Down Expand Up @@ -646,11 +631,7 @@ int snd_emu10k1_proc_init(struct snd_emu10k1 *emu)
entry->size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE;
entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
}
if (! snd_card_proc_new(emu->card, "fx8010_acode", &entry)) {
entry->content = SNDRV_INFO_CONTENT_TEXT;
entry->private_data = emu;
entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
entry->c.text.read = snd_emu10k1_proc_acode_read;
}
snd_card_ro_proc_new(emu->card, "fx8010_acode", emu,
snd_emu10k1_proc_acode_read);
return 0;
}
6 changes: 2 additions & 4 deletions sound/pci/ens1370.c
Original file line number Diff line number Diff line change
Expand Up @@ -1902,10 +1902,8 @@ static void snd_ensoniq_proc_read(struct snd_info_entry *entry,

static void snd_ensoniq_proc_init(struct ensoniq *ensoniq)
{
struct snd_info_entry *entry;

if (! snd_card_proc_new(ensoniq->card, "audiopci", &entry))
snd_info_set_text_ops(entry, ensoniq, snd_ensoniq_proc_read);
snd_card_ro_proc_new(ensoniq->card, "audiopci", ensoniq,
snd_ensoniq_proc_read);
}

/*
Expand Down
9 changes: 1 addition & 8 deletions sound/pci/hda/hda_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,15 +919,8 @@ static void print_codec_info(struct snd_info_entry *entry,
int snd_hda_codec_proc_new(struct hda_codec *codec)
{
char name[32];
struct snd_info_entry *entry;
int err;

snprintf(name, sizeof(name), "codec#%d", codec->core.addr);
err = snd_card_proc_new(codec->card, name, &entry);
if (err < 0)
return err;

snd_info_set_text_ops(entry, codec, print_codec_info);
return 0;
return snd_card_ro_proc_new(codec->card, name, codec, print_codec_info);
}

5 changes: 1 addition & 4 deletions sound/pci/ice1712/ice1712.c
Original file line number Diff line number Diff line change
Expand Up @@ -1603,10 +1603,7 @@ static void snd_ice1712_proc_read(struct snd_info_entry *entry,

static void snd_ice1712_proc_init(struct snd_ice1712 *ice)
{
struct snd_info_entry *entry;

if (!snd_card_proc_new(ice->card, "ice1712", &entry))
snd_info_set_text_ops(entry, ice, snd_ice1712_proc_read);
snd_card_ro_proc_new(ice->card, "ice1712", ice, snd_ice1712_proc_read);
}

/*
Expand Down
5 changes: 1 addition & 4 deletions sound/pci/ice1712/ice1724.c
Original file line number Diff line number Diff line change
Expand Up @@ -1571,10 +1571,7 @@ static void snd_vt1724_proc_read(struct snd_info_entry *entry,

static void snd_vt1724_proc_init(struct snd_ice1712 *ice)
{
struct snd_info_entry *entry;

if (!snd_card_proc_new(ice->card, "ice1724", &entry))
snd_info_set_text_ops(entry, ice, snd_vt1724_proc_read);
snd_card_ro_proc_new(ice->card, "ice1724", ice, snd_vt1724_proc_read);
}

/*
Expand Down
12 changes: 3 additions & 9 deletions sound/pci/ice1712/pontis.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,12 +659,8 @@ static void wm_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buff

static void wm_proc_init(struct snd_ice1712 *ice)
{
struct snd_info_entry *entry;
if (! snd_card_proc_new(ice->card, "wm_codec", &entry)) {
snd_info_set_text_ops(entry, ice, wm_proc_regs_read);
entry->mode |= 0200;
entry->c.text.write = wm_proc_regs_write;
}
snd_card_rw_proc_new(ice->card, "wm_codec", ice, wm_proc_regs_read,
wm_proc_regs_write);
}

static void cs_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
Expand All @@ -684,9 +680,7 @@ static void cs_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buff

static void cs_proc_init(struct snd_ice1712 *ice)
{
struct snd_info_entry *entry;
if (! snd_card_proc_new(ice->card, "cs_codec", &entry))
snd_info_set_text_ops(entry, ice, cs_proc_regs_read);
snd_card_ro_proc_new(ice->card, "cs_codec", ice, cs_proc_regs_read);
}


Expand Down
5 changes: 2 additions & 3 deletions sound/pci/ice1712/prodigy192.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,8 @@ static void stac9460_proc_regs_read(struct snd_info_entry *entry,

static void stac9460_proc_init(struct snd_ice1712 *ice)
{
struct snd_info_entry *entry;
if (!snd_card_proc_new(ice->card, "stac9460_codec", &entry))
snd_info_set_text_ops(entry, ice, stac9460_proc_regs_read);
snd_card_ro_proc_new(ice->card, "stac9460_codec", ice,
stac9460_proc_regs_read);
}


Expand Down
8 changes: 2 additions & 6 deletions sound/pci/ice1712/prodigy_hifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,12 +904,8 @@ static void wm_proc_regs_read(struct snd_info_entry *entry,

static void wm_proc_init(struct snd_ice1712 *ice)
{
struct snd_info_entry *entry;
if (!snd_card_proc_new(ice->card, "wm_codec", &entry)) {
snd_info_set_text_ops(entry, ice, wm_proc_regs_read);
entry->mode |= 0200;
entry->c.text.write = wm_proc_regs_write;
}
snd_card_rw_proc_new(ice->card, "wm_codec", ice, wm_proc_regs_read,
wm_proc_regs_write);
}

static int prodigy_hifi_add_controls(struct snd_ice1712 *ice)
Expand Down
4 changes: 1 addition & 3 deletions sound/pci/ice1712/quartet.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,7 @@ static void proc_regs_read(struct snd_info_entry *entry,

static void proc_init(struct snd_ice1712 *ice)
{
struct snd_info_entry *entry;
if (!snd_card_proc_new(ice->card, "quartet", &entry))
snd_info_set_text_ops(entry, ice, proc_regs_read);
snd_card_ro_proc_new(ice->card, "quartet", ice, proc_regs_read);
}

static int qtet_mute_get(struct snd_kcontrol *kcontrol,
Expand Down
6 changes: 2 additions & 4 deletions sound/pci/intel8x0.c
Original file line number Diff line number Diff line change
Expand Up @@ -2863,10 +2863,8 @@ static void snd_intel8x0_proc_read(struct snd_info_entry * entry,

static void snd_intel8x0_proc_init(struct intel8x0 *chip)
{
struct snd_info_entry *entry;

if (! snd_card_proc_new(chip->card, "intel8x0", &entry))
snd_info_set_text_ops(entry, chip, snd_intel8x0_proc_read);
snd_card_ro_proc_new(chip->card, "intel8x0", chip,
snd_intel8x0_proc_read);
}

static int snd_intel8x0_dev_free(struct snd_device *device)
Expand Down
Loading

0 comments on commit 47f2769

Please sign in to comment.