* [PATCH v1 2/4] ALSA: fm801: convert rest outw() / inw() to use helpers
2015-12-18 19:14 [PATCH v1 1/4] ALSA: fm801: explicitly free IRQ line Andy Shevchenko
@ 2015-12-18 19:14 ` Andy Shevchenko
2015-12-18 19:14 ` [PATCH v1 3/4] ALSA: fm801: put curly braces around empty if-body Andy Shevchenko
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2015-12-18 19:14 UTC (permalink / raw)
To: Takashi Iwai, alsa-devel; +Cc: Andy Shevchenko
From: Andy Shevchenko <andy.shevchenko@gmail.com>
The patch introduces two new helpers fm801_iowrite16() and fm801_ioread16() to
write and read the registers by offset. Previously similar was done to access
the hardware registers by their names.
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
sound/pci/fm801.c | 36 ++++++++++++++++++++++++++----------
1 file changed, 26 insertions(+), 10 deletions(-)
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index f57847c..c2afb41 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -212,6 +212,20 @@ struct fm801 {
#endif
};
+/*
+ * IO accessors
+ */
+
+static inline void fm801_iowrite16(struct fm801 *chip, unsigned short offset, u16 value)
+{
+ outw(value, chip->port + offset);
+}
+
+static inline u16 fm801_ioread16(struct fm801 *chip, unsigned short offset)
+{
+ return inw(chip->port + offset);
+}
+
static const struct pci_device_id snd_fm801_ids[] = {
{ 0x1319, 0x0801, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0, }, /* FM801 */
{ 0x5213, 0x0510, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0, }, /* Gallant Odyssey Sound 4 */
@@ -256,11 +270,11 @@ static int snd_fm801_update_bits(struct fm801 *chip, unsigned short reg,
unsigned short old, new;
spin_lock_irqsave(&chip->reg_lock, flags);
- old = inw(chip->port + reg);
+ old = fm801_ioread16(chip, reg);
new = (old & ~mask) | value;
change = old != new;
if (change)
- outw(new, chip->port + reg);
+ fm801_iowrite16(chip, reg, new);
spin_unlock_irqrestore(&chip->reg_lock, flags);
return change;
}
@@ -851,10 +865,11 @@ static int snd_fm801_get_single(struct snd_kcontrol *kcontrol,
int shift = (kcontrol->private_value >> 8) & 0xff;
int mask = (kcontrol->private_value >> 16) & 0xff;
int invert = (kcontrol->private_value >> 24) & 0xff;
+ long *value = ucontrol->value.integer.value;
- ucontrol->value.integer.value[0] = (inw(chip->port + reg) >> shift) & mask;
+ value[0] = (fm801_ioread16(chip, reg) >> shift) & mask;
if (invert)
- ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
+ value[0] = mask - value[0];
return 0;
}
@@ -907,14 +922,15 @@ static int snd_fm801_get_double(struct snd_kcontrol *kcontrol,
int shift_right = (kcontrol->private_value >> 12) & 0x0f;
int mask = (kcontrol->private_value >> 16) & 0xff;
int invert = (kcontrol->private_value >> 24) & 0xff;
+ long *value = ucontrol->value.integer.value;
spin_lock_irq(&chip->reg_lock);
- ucontrol->value.integer.value[0] = (inw(chip->port + reg) >> shift_left) & mask;
- ucontrol->value.integer.value[1] = (inw(chip->port + reg) >> shift_right) & mask;
+ value[0] = (fm801_ioread16(chip, reg) >> shift_left) & mask;
+ value[1] = (fm801_ioread16(chip, reg) >> shift_right) & mask;
spin_unlock_irq(&chip->reg_lock);
if (invert) {
- ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
- ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1];
+ value[0] = mask - value[0];
+ value[1] = mask - value[1];
}
return 0;
}
@@ -1372,7 +1388,7 @@ static int snd_fm801_suspend(struct device *dev)
snd_ac97_suspend(chip->ac97);
snd_ac97_suspend(chip->ac97_sec);
for (i = 0; i < ARRAY_SIZE(saved_regs); i++)
- chip->saved_regs[i] = inw(chip->port + saved_regs[i]);
+ chip->saved_regs[i] = fm801_ioread16(chip, saved_regs[i]);
/* FIXME: tea575x suspend */
return 0;
}
@@ -1387,7 +1403,7 @@ static int snd_fm801_resume(struct device *dev)
snd_ac97_resume(chip->ac97);
snd_ac97_resume(chip->ac97_sec);
for (i = 0; i < ARRAY_SIZE(saved_regs); i++)
- outw(chip->saved_regs[i], chip->port + saved_regs[i]);
+ fm801_iowrite16(chip, saved_regs[i], chip->saved_regs[i]);
snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
--
2.6.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 3/4] ALSA: fm801: put curly braces around empty if-body
2015-12-18 19:14 [PATCH v1 1/4] ALSA: fm801: explicitly free IRQ line Andy Shevchenko
2015-12-18 19:14 ` [PATCH v1 2/4] ALSA: fm801: convert rest outw() / inw() to use helpers Andy Shevchenko
@ 2015-12-18 19:14 ` Andy Shevchenko
2015-12-18 19:14 ` [PATCH v1 4/4] ALSA: fm801: store struct device instead of pci_dev Andy Shevchenko
2015-12-20 21:34 ` [PATCH v1 1/4] ALSA: fm801: explicitly free IRQ line Takashi Iwai
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2015-12-18 19:14 UTC (permalink / raw)
To: Takashi Iwai, alsa-devel; +Cc: Andy Shevchenko
The compiler complains on unused condition as follows
sound/pci/fm801.c: In function ‘snd_fm801_interrupt’:
sound/pci/fm801.c:585:3: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
Put the curly braces around empty body as suggested.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
sound/pci/fm801.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index c2afb41..c24cb04 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -592,8 +592,9 @@ static irqreturn_t snd_fm801_interrupt(int irq, void *dev_id)
}
if (chip->rmidi && (status & FM801_IRQ_MPU))
snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data);
- if (status & FM801_IRQ_VOLUME)
- ;/* TODO */
+ if (status & FM801_IRQ_VOLUME) {
+ /* TODO */
+ }
return IRQ_HANDLED;
}
--
2.6.4
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 4/4] ALSA: fm801: store struct device instead of pci_dev
2015-12-18 19:14 [PATCH v1 1/4] ALSA: fm801: explicitly free IRQ line Andy Shevchenko
2015-12-18 19:14 ` [PATCH v1 2/4] ALSA: fm801: convert rest outw() / inw() to use helpers Andy Shevchenko
2015-12-18 19:14 ` [PATCH v1 3/4] ALSA: fm801: put curly braces around empty if-body Andy Shevchenko
@ 2015-12-18 19:14 ` Andy Shevchenko
2015-12-20 21:34 ` [PATCH v1 1/4] ALSA: fm801: explicitly free IRQ line Takashi Iwai
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2015-12-18 19:14 UTC (permalink / raw)
To: Takashi Iwai, alsa-devel; +Cc: Andy Shevchenko
There is no need to store struct pci_dev in struct fm801. Generic struct device
can be easily translated to struct pci_dev whenever it's needed, in particular
for one user for now.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
sound/pci/fm801.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index c24cb04..e4e610c 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -163,6 +163,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device numbers");
* @cap_ctrl: capture control
*/
struct fm801 {
+ struct device *dev;
int irq;
unsigned long port;
@@ -190,7 +191,6 @@ struct fm801 {
struct snd_ac97 *ac97;
struct snd_ac97 *ac97_sec;
- struct pci_dev *pci;
struct snd_card *card;
struct snd_pcm *pcm;
struct snd_rawmidi *rmidi;
@@ -715,6 +715,7 @@ static struct snd_pcm_ops snd_fm801_capture_ops = {
static int snd_fm801_pcm(struct fm801 *chip, int device)
{
+ struct pci_dev *pdev = to_pci_dev(chip->dev);
struct snd_pcm *pcm;
int err;
@@ -730,7 +731,7 @@ static int snd_fm801_pcm(struct fm801 *chip, int device)
chip->pcm = pcm;
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
- snd_dma_pci_data(chip->pci),
+ snd_dma_pci_data(pdev),
chip->multichannel ? 128*1024 : 64*1024, 128*1024);
return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
@@ -1182,7 +1183,7 @@ static int snd_fm801_free(struct fm801 *chip)
cmdw |= 0x00c3;
fm801_writew(chip, IRQ_MASK, cmdw);
- devm_free_irq(&chip->pci->dev, chip->irq, chip);
+ devm_free_irq(chip->dev, chip->irq, chip);
__end_hw:
#ifdef CONFIG_SND_FM801_TEA575X_BOOL
@@ -1220,7 +1221,7 @@ static int snd_fm801_create(struct snd_card *card,
return -ENOMEM;
spin_lock_init(&chip->reg_lock);
chip->card = card;
- chip->pci = pci;
+ chip->dev = &pci->dev;
chip->irq = -1;
chip->tea575x_tuner = tea575x_tuner;
if ((err = pci_request_regions(pci, "FM801")) < 0)
--
2.6.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/4] ALSA: fm801: explicitly free IRQ line
2015-12-18 19:14 [PATCH v1 1/4] ALSA: fm801: explicitly free IRQ line Andy Shevchenko
` (2 preceding siblings ...)
2015-12-18 19:14 ` [PATCH v1 4/4] ALSA: fm801: store struct device instead of pci_dev Andy Shevchenko
@ 2015-12-20 21:34 ` Takashi Iwai
3 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2015-12-20 21:34 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: alsa-devel
On Fri, 18 Dec 2015 20:14:10 +0100,
Andy Shevchenko wrote:
>
> Otherwise we will have a warning on ->remove() since device is a PCI one.
>
> WARNING: CPU: 4 PID: 1411 at /home/andy/prj/linux/fs/proc/generic.c:575 remove_proc_entry+0x137/0x160()
> remove_proc_entry: removing non-empty directory 'irq/21', leaking at least 'snd_fm801'
>
> Fixes: 5618955c4269 (ALSA: fm801: move to pcim_* and devm_* functions)
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> The patch series has been tested on SF64-PCR card.
Applied all four patches. Thanks.
Takashi
> sound/pci/fm801.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
> index 1fdd92b6..f57847c 100644
> --- a/sound/pci/fm801.c
> +++ b/sound/pci/fm801.c
> @@ -1165,6 +1165,8 @@ static int snd_fm801_free(struct fm801 *chip)
> cmdw |= 0x00c3;
> fm801_writew(chip, IRQ_MASK, cmdw);
>
> + devm_free_irq(&chip->pci->dev, chip->irq, chip);
> +
> __end_hw:
> #ifdef CONFIG_SND_FM801_TEA575X_BOOL
> if (!(chip->tea575x_tuner & TUNER_DISABLED)) {
> --
> 2.6.4
>
> .
>
^ permalink raw reply [flat|nested] 5+ messages in thread