Discussion:
[PATCH v3 1/5] sound: pci: ctxfi: added reference of snd_card
Sudip Mukherjee
2014-09-21 16:03:37 UTC
Permalink
added and initialized a pointer of snd_card in the struct hw to get a reference of
the card in other functions

Signed-off-by: Sudip Mukherjee <***@vectorindia.org>
---
sound/pci/ctxfi/ctatc.c | 1 +
sound/pci/ctxfi/cthardware.h | 2 ++
2 files changed, 3 insertions(+)

diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index d92a08c..b21eda4 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -1333,6 +1333,7 @@ static int atc_create_hw_devs(struct ct_atc *atc)
pr_err("Failed to create hw obj!!!\n");
return err;
}
+ hw->card = atc->card;
atc->hw = hw;

/* Initialize card hardware. */
diff --git a/sound/pci/ctxfi/cthardware.h b/sound/pci/ctxfi/cthardware.h
index 5977e9a..940bbd0 100644
--- a/sound/pci/ctxfi/cthardware.h
+++ b/sound/pci/ctxfi/cthardware.h
@@ -20,6 +20,7 @@

#include <linux/types.h>
#include <linux/pci.h>
+#include <sound/core.h>

enum CHIPTYP {
ATC20K1,
@@ -184,6 +185,7 @@ struct hw {
void *irq_callback_data;

struct pci_dev *pci; /* the pci kernel structure of this card */
+ struct snd_card *card; /* pointer to this card */
int irq;
unsigned long io_base;
unsigned long mem_base;
--
1.8.1.2
Sudip Mukherjee
2014-09-21 16:03:38 UTC
Permalink
added reference of the card in the convert_format function
so that we can know which card has called the function

Signed-off-by: Sudip Mukherjee <***@vectorindia.org>
---
sound/pci/ctxfi/ctatc.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index b21eda4..3e29e13 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -171,7 +171,8 @@ static unsigned long atc_get_ptp_phys(struct ct_atc *atc, int index)
return atc->vm->get_ptp_phys(atc->vm, index);
}

-static unsigned int convert_format(snd_pcm_format_t snd_format)
+static unsigned int convert_format(snd_pcm_format_t snd_format,
+ struct snd_card *card)
{
switch (snd_format) {
case SNDRV_PCM_FORMAT_U8:
@@ -268,7 +269,8 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm)
src = apcm->src;
src->ops->set_pitch(src, pitch);
src->ops->set_rom(src, select_rom(pitch));
- src->ops->set_sf(src, convert_format(apcm->substream->runtime->format));
+ src->ops->set_sf(src, convert_format(apcm->substream->runtime->format,
+ atc->card));
src->ops->set_pm(src, (src->ops->next_interleave(src) != NULL));

/* Get AMIXER resource */
@@ -738,7 +740,8 @@ static int atc_pcm_capture_start(struct ct_atc *atc, struct ct_atc_pcm *apcm)

/* Set up recording SRC */
src = apcm->src;
- src->ops->set_sf(src, convert_format(apcm->substream->runtime->format));
+ src->ops->set_sf(src, convert_format(apcm->substream->runtime->format,
+ atc->card));
src->ops->set_sa(src, apcm->vm_block->addr);
src->ops->set_la(src, apcm->vm_block->addr + apcm->vm_block->size);
src->ops->set_ca(src, apcm->vm_block->addr);
@@ -807,7 +810,8 @@ static int spdif_passthru_playback_get_resources(struct ct_atc *atc,
src = apcm->src;
src->ops->set_pitch(src, pitch);
src->ops->set_rom(src, select_rom(pitch));
- src->ops->set_sf(src, convert_format(apcm->substream->runtime->format));
+ src->ops->set_sf(src, convert_format(apcm->substream->runtime->format,
+ atc->card));
src->ops->set_pm(src, (src->ops->next_interleave(src) != NULL));
src->ops->set_bp(src, 1);
--
1.8.1.2
Sudip Mukherjee
2014-09-21 16:03:39 UTC
Permalink
pr_* macros replaced with dev_* as they are more preffered over pr_*.

Signed-off-by: Sudip Mukherjee <***@vectorindia.org>
---
sound/pci/ctxfi/ctamixer.c | 6 ++++--
sound/pci/ctxfi/ctatc.c | 27 ++++++++++++++++-----------
sound/pci/ctxfi/ctdaio.c | 3 ++-
sound/pci/ctxfi/cthw20k1.c | 15 +++++++++------
sound/pci/ctxfi/cthw20k2.c | 24 +++++++++++++++---------
sound/pci/ctxfi/ctmixer.c | 6 ++++--
sound/pci/ctxfi/ctpcm.c | 9 ++++++---
sound/pci/ctxfi/ctresource.c | 18 ++++++++++++------
sound/pci/ctxfi/ctsrc.c | 6 ++++--
sound/pci/ctxfi/ctvmem.c | 12 ++++++++----
sound/pci/ctxfi/xfi.c | 15 +++++++++------
11 files changed, 89 insertions(+), 52 deletions(-)

diff --git a/sound/pci/ctxfi/ctamixer.c b/sound/pci/ctxfi/ctamixer.c
index fed6e6a..955b2af 100644
--- a/sound/pci/ctxfi/ctamixer.c
+++ b/sound/pci/ctxfi/ctamixer.c
@@ -258,7 +258,8 @@ static int get_amixer_rsc(struct amixer_mgr *mgr,
}
spin_unlock_irqrestore(&mgr->mgr_lock, flags);
if (err) {
- pr_err("ctxfi: Can't meet AMIXER resource request!\n");
+ dev_err(((struct hw *)(mgr->mgr.hw))->card->dev,
+ "Can't meet AMIXER resource request!\n");
goto error;
}

@@ -411,7 +412,8 @@ static int get_sum_rsc(struct sum_mgr *mgr,
}
spin_unlock_irqrestore(&mgr->mgr_lock, flags);
if (err) {
- pr_err("ctxfi: Can't meet SUM resource request!\n");
+ dev_err(((struct hw *)(mgr->mgr.hw))->card->dev,
+ "Can't meet SUM resource request!\n");
goto error;
}

diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index 3e29e13..6c185d0 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -186,7 +186,7 @@ static unsigned int convert_format(snd_pcm_format_t snd_format,
case SNDRV_PCM_FORMAT_FLOAT_LE:
return SRC_SF_F32;
default:
- pr_err("ctxfi: not recognized snd format is %d\n",
+ dev_err(card->dev, "ctxfi: not recognized snd format is %d\n",
snd_format);
return SRC_SF_S16;
}
@@ -1286,8 +1286,9 @@ static int atc_identify_card(struct ct_atc *atc, unsigned int ssid)
p = snd_pci_quirk_lookup_id(vendor_id, device_id, list);
if (p) {
if (p->value < 0) {
- pr_err("ctxfi: Device %04x:%04x is black-listed\n",
- vendor_id, device_id);
+ dev_err(atc->card->dev,
+ "ctxfi: Device %04x:%04x is black-listed\n",
+ vendor_id, device_id);
return -ENOENT;
}
atc->model = p->value;
@@ -1318,7 +1319,8 @@ int ct_atc_create_alsa_devs(struct ct_atc *atc)
err = alsa_dev_funcs[i].create(atc, i,
alsa_dev_funcs[i].public_name);
if (err) {
- pr_err("ctxfi: Creating alsa device %d failed!\n", i);
+ dev_err(atc->card->dev,
+ "ctxfi: Creating alsa device %d failed!\n", i);
return err;
}
}
@@ -1334,7 +1336,7 @@ static int atc_create_hw_devs(struct ct_atc *atc)

err = create_hw_obj(atc->pci, atc->chip_type, atc->model, &hw);
if (err) {
- pr_err("Failed to create hw obj!!!\n");
+ dev_err(atc->card->dev, "Failed to create hw obj!!!\n");
return err;
}
hw->card = atc->card;
@@ -1354,7 +1356,8 @@ static int atc_create_hw_devs(struct ct_atc *atc)

err = rsc_mgr_funcs[i].create(atc->hw, &atc->rsc_mgrs[i]);
if (err) {
- pr_err("ctxfi: Failed to create rsc_mgr %d!!!\n", i);
+ dev_err(atc->card->dev,
+ "ctxfi: Failed to create rsc_mgr %d!!!\n", i);
return err;
}
}
@@ -1401,7 +1404,8 @@ static int atc_get_resources(struct ct_atc *atc)
err = daio_mgr->get_daio(daio_mgr, &da_desc,
(struct daio **)&atc->daios[i]);
if (err) {
- pr_err("ctxfi: Failed to get DAIO resource %d!!!\n",
+ dev_err(atc->card->dev,
+ "ctxfi: Failed to get DAIO resource %d!!!\n",
i);
return err;
}
@@ -1605,7 +1609,8 @@ static int atc_resume(struct ct_atc *atc)
/* Do hardware resume. */
err = atc_hw_resume(atc);
if (err < 0) {
- pr_err("ctxfi: pci_enable_device failed, disabling device\n");
+ dev_err(atc->card->dev,
+ "ctxfi: pci_enable_device failed, disabling device\n");
snd_card_disconnect(atc->card);
return err;
}
@@ -1702,7 +1707,7 @@ int ct_atc_create(struct snd_card *card, struct pci_dev *pci,
/* Find card model */
err = atc_identify_card(atc, ssid);
if (err < 0) {
- pr_err("ctatc: Card not recognised\n");
+ dev_err(card->dev, "ctatc: Card not recognised\n");
goto error1;
}

@@ -1718,7 +1723,7 @@ int ct_atc_create(struct snd_card *card, struct pci_dev *pci,

err = ct_mixer_create(atc, (struct ct_mixer **)&atc->mixer);
if (err) {
- pr_err("ctxfi: Failed to create mixer obj!!!\n");
+ dev_err(card->dev, "ctxfi: Failed to create mixer obj!!!\n");
goto error1;
}

@@ -1745,6 +1750,6 @@ int ct_atc_create(struct snd_card *card, struct pci_dev *pci,

error1:
ct_atc_destroy(atc);
- pr_err("ctxfi: Something wrong!!!\n");
+ dev_err(card->dev, "ctxfi: Something wrong!!!\n");
return err;
}
diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c
index 6f0654e..ddd8109 100644
--- a/sound/pci/ctxfi/ctdaio.c
+++ b/sound/pci/ctxfi/ctdaio.c
@@ -541,7 +541,8 @@ static int get_daio_rsc(struct daio_mgr *mgr,
err = daio_mgr_get_rsc(&mgr->mgr, desc->type);
spin_unlock_irqrestore(&mgr->mgr_lock, flags);
if (err) {
- pr_err("Can't meet DAIO resource request!\n");
+ dev_err(((struct hw *)(mgr->mgr.hw))->card->dev,
+ "Can't meet DAIO resource request!\n");
return err;
}

diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c
index 71d496f..b807391 100644
--- a/sound/pci/ctxfi/cthw20k1.c
+++ b/sound/pci/ctxfi/cthw20k1.c
@@ -1268,7 +1268,8 @@ static int hw_trn_init(struct hw *hw, const struct trn_conf *info)

/* Set up device page table */
if ((~0UL) == info->vm_pgt_phys) {
- pr_err("Wrong device page table page address!\n");
+ dev_err(hw->card->dev,
+ "Wrong device page table page address!\n");
return -1;
}

@@ -1327,7 +1328,7 @@ static int hw_pll_init(struct hw *hw, unsigned int rsr)
mdelay(40);
}
if (i >= 3) {
- pr_alert("PLL initialization failed!!!\n");
+ dev_alert(hw->card->dev, "PLL initialization failed!!!\n");
return -EBUSY;
}

@@ -1351,7 +1352,7 @@ static int hw_auto_init(struct hw *hw)
break;
}
if (!get_field(gctl, GCTL_AID)) {
- pr_alert("Card Auto-init failed!!!\n");
+ dev_alert(hw->card->dev, "Card Auto-init failed!!!\n");
return -EBUSY;
}

@@ -1911,8 +1912,9 @@ static int hw_card_start(struct hw *hw)
/* Set DMA transfer mask */
if (pci_set_dma_mask(pci, CT_XFI_DMA_MASK) < 0 ||
pci_set_consistent_dma_mask(pci, CT_XFI_DMA_MASK) < 0) {
- pr_err("architecture does not support PCI busmaster DMA with mask 0x%llx\n",
- CT_XFI_DMA_MASK);
+ dev_err(hw->card->dev,
+ "architecture does not support PCI busmaster DMA with mask 0x%llx\n",
+ CT_XFI_DMA_MASK);
err = -ENXIO;
goto error1;
}
@@ -1941,7 +1943,8 @@ static int hw_card_start(struct hw *hw)
err = request_irq(pci->irq, ct_20k1_interrupt, IRQF_SHARED,
KBUILD_MODNAME, hw);
if (err < 0) {
- pr_err("XFi: Cannot get irq %d\n", pci->irq);
+ dev_err(hw->card->dev,
+ "XFi: Cannot get irq %d\n", pci->irq);
goto error2;
}
hw->irq = pci->irq;
diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c
index df2d8c5..665eeb2 100644
--- a/sound/pci/ctxfi/cthw20k2.c
+++ b/sound/pci/ctxfi/cthw20k2.c
@@ -1187,7 +1187,8 @@ static int hw_daio_init(struct hw *hw, const struct daio_conf *info)
hw_write_20kx(hw, AUDIO_IO_TX_BLRCLK, 0x21212121);
hw_write_20kx(hw, AUDIO_IO_RX_BLRCLK, 0);
} else {
- pr_alert("ctxfi: ERROR!!! Invalid sampling rate!!!\n");
+ dev_alert(hw->card->dev,
+ "ctxfi: ERROR!!! Invalid sampling rate!!!\n");
return -EINVAL;
}

@@ -1246,7 +1247,8 @@ static int hw_trn_init(struct hw *hw, const struct trn_conf *info)

/* Set up device page table */
if ((~0UL) == info->vm_pgt_phys) {
- pr_alert("ctxfi: Wrong device page table page address!!!\n");
+ dev_alert(hw->card->dev,
+ "ctxfi: Wrong device page table page address!!!\n");
return -1;
}

@@ -1351,7 +1353,8 @@ static int hw_pll_init(struct hw *hw, unsigned int rsr)
break;
}
if (i >= 1000) {
- pr_alert("ctxfi: PLL initialization failed!!!\n");
+ dev_alert(hw->card->dev,
+ "ctxfi: PLL initialization failed!!!\n");
return -EBUSY;
}

@@ -1375,7 +1378,7 @@ static int hw_auto_init(struct hw *hw)
break;
}
if (!get_field(gctl, GCTL_AID)) {
- pr_alert("ctxfi: Card Auto-init failed!!!\n");
+ dev_alert(hw->card->dev, "ctxfi: Card Auto-init failed!!!\n");
return -EBUSY;
}

@@ -1846,7 +1849,7 @@ static int hw_adc_init(struct hw *hw, const struct adc_conf *info)
/* Initialize I2C */
err = hw20k2_i2c_init(hw, 0x1A, 1, 1);
if (err < 0) {
- pr_alert("ctxfi: Failure to acquire I2C!!!\n");
+ dev_alert(hw->card->dev, "ctxfi: Failure to acquire I2C!!!\n");
goto error;
}

@@ -1889,8 +1892,9 @@ static int hw_adc_init(struct hw *hw, const struct adc_conf *info)
hw20k2_i2c_write(hw, MAKE_WM8775_ADDR(WM8775_MMC, 0x0A),
MAKE_WM8775_DATA(0x0A));
} else {
- pr_alert("ctxfi: Invalid master sampling rate (msr %d)!!!\n",
- info->msr);
+ dev_alert(hw->card->dev,
+ "ctxfi: Invalid master sampling rate (msr %d)!!!\n",
+ info->msr);
err = -EINVAL;
goto error;
}
@@ -2033,7 +2037,8 @@ static int hw_card_start(struct hw *hw)
/* Set DMA transfer mask */
if (pci_set_dma_mask(pci, CT_XFI_DMA_MASK) < 0 ||
pci_set_consistent_dma_mask(pci, CT_XFI_DMA_MASK) < 0) {
- pr_err("ctxfi: architecture does not support PCI busmaster DMA with mask 0x%llx\n",
+ dev_err(hw->card->dev,
+ "ctxfi: architecture does not support PCI busmaster DMA with mask 0x%llx\n",
CT_XFI_DMA_MASK);
err = -ENXIO;
goto error1;
@@ -2062,7 +2067,8 @@ static int hw_card_start(struct hw *hw)
err = request_irq(pci->irq, ct_20k2_interrupt, IRQF_SHARED,
KBUILD_MODNAME, hw);
if (err < 0) {
- pr_err("XFi: Cannot get irq %d\n", pci->irq);
+ dev_err(hw->card->dev,
+ "XFi: Cannot get irq %d\n", pci->irq);
goto error2;
}
hw->irq = pci->irq;
diff --git a/sound/pci/ctxfi/ctmixer.c b/sound/pci/ctxfi/ctmixer.c
index 017fa91..43f3483 100644
--- a/sound/pci/ctxfi/ctmixer.c
+++ b/sound/pci/ctxfi/ctmixer.c
@@ -854,7 +854,8 @@ static int ct_mixer_get_resources(struct ct_mixer *mixer)
for (i = 0; i < (NUM_CT_SUMS * CHN_NUM); i++) {
err = sum_mgr->get_sum(sum_mgr, &sum_desc, &sum);
if (err) {
- pr_err("ctxfi:Failed to get sum resources for front output!\n");
+ dev_err(mixer->atc->card->dev,
+ "ctxfi:Failed to get sum resources for front output!\n");
break;
}
mixer->sums[i] = sum;
@@ -868,7 +869,8 @@ static int ct_mixer_get_resources(struct ct_mixer *mixer)
for (i = 0; i < (NUM_CT_AMIXERS * CHN_NUM); i++) {
err = amixer_mgr->get_amixer(amixer_mgr, &am_desc, &amixer);
if (err) {
- pr_err("ctxfi:Failed to get amixer resources for mixer obj!\n");
+ dev_err(mixer->atc->card->dev,
+ "ctxfi:Failed to get amixer resources for mixer obj!\n");
break;
}
mixer->amixers[i] = amixer;
diff --git a/sound/pci/ctxfi/ctpcm.c b/sound/pci/ctxfi/ctpcm.c
index 6826c2c..9d337e5 100644
--- a/sound/pci/ctxfi/ctpcm.c
+++ b/sound/pci/ctxfi/ctpcm.c
@@ -217,7 +217,8 @@ static int ct_pcm_playback_prepare(struct snd_pcm_substream *substream)
err = atc->pcm_playback_prepare(atc, apcm);

if (err < 0) {
- pr_err("ctxfi: Preparing pcm playback failed!!!\n");
+ dev_err(atc->card->dev,
+ "ctxfi: Preparing pcm playback failed!!!\n");
return err;
}

@@ -324,7 +325,8 @@ static int ct_pcm_capture_prepare(struct snd_pcm_substream *substream)

err = atc->pcm_capture_prepare(atc, apcm);
if (err < 0) {
- pr_err("ctxfi: Preparing pcm capture failed!!!\n");
+ dev_err(atc->card->dev,
+ "ctxfi: Preparing pcm capture failed!!!\n");
return err;
}

@@ -435,7 +437,8 @@ int ct_alsa_pcm_create(struct ct_atc *atc,
err = snd_pcm_new(atc->card, "ctxfi", device,
playback_count, capture_count, &pcm);
if (err < 0) {
- pr_err("ctxfi: snd_pcm_new failed!! Err=%d\n", err);
+ dev_err(atc->card->dev, "ctxfi: snd_pcm_new failed!! Err=%d\n",
+ err);
return err;
}

diff --git a/sound/pci/ctxfi/ctresource.c b/sound/pci/ctxfi/ctresource.c
index e49d2be..a6e875b 100644
--- a/sound/pci/ctxfi/ctresource.c
+++ b/sound/pci/ctxfi/ctresource.c
@@ -162,12 +162,14 @@ int rsc_init(struct rsc *rsc, u32 idx, enum RSCTYP type, u32 msr, void *hw)
case DAIO:
break;
default:
- pr_err("ctxfi: Invalid resource type value %d!\n", type);
+ dev_err(((struct hw *)hw)->card->dev,
+ "Invalid resource type value %d!\n", type);
return -EINVAL;
}

if (err) {
- pr_err("ctxfi: Failed to get resource control block!\n");
+ dev_err(((struct hw *)hw)->card->dev,
+ "Failed to get resource control block!\n");
return err;
}

@@ -190,7 +192,8 @@ int rsc_uninit(struct rsc *rsc)
case DAIO:
break;
default:
- pr_err("ctxfi: Invalid resource type value %d!\n",
+ dev_err(((struct hw *)rsc->hw)->card->dev,
+ "Invalid resource type value %d!\n",
rsc->type);
break;
}
@@ -233,13 +236,15 @@ int rsc_mgr_init(struct rsc_mgr *mgr, enum RSCTYP type,
case SUM:
break;
default:
- pr_err("ctxfi: Invalid resource type value %d!\n", type);
+ dev_err(hw->card->dev,
+ "Invalid resource type value %d!\n", type);
err = -EINVAL;
goto error;
}

if (err) {
- pr_err("ctxfi: Failed to get manager control block!\n");
+ dev_err(hw->card->dev,
+ "Failed to get manager control block!\n");
goto error;
}

@@ -282,7 +287,8 @@ int rsc_mgr_uninit(struct rsc_mgr *mgr)
case SUM:
break;
default:
- pr_err("ctxfi: Invalid resource type value %d!\n",
+ dev_err(((struct hw *)mgr->hw)->card->dev,
+ "Invalid resource type value %d!\n",
mgr->type);
break;
}
diff --git a/sound/pci/ctxfi/ctsrc.c b/sound/pci/ctxfi/ctsrc.c
index 19df9b4..3683726 100644
--- a/sound/pci/ctxfi/ctsrc.c
+++ b/sound/pci/ctxfi/ctsrc.c
@@ -431,7 +431,8 @@ get_src_rsc(struct src_mgr *mgr, const struct src_desc *desc, struct src **rsrc)

spin_unlock_irqrestore(&mgr->mgr_lock, flags);
if (err) {
- pr_err("ctxfi: Can't meet SRC resource request!\n");
+ dev_err(((struct hw *)(mgr->mgr.hw))->card->dev,
+ "Can't meet SRC resource request!\n");
return err;
}

@@ -739,7 +740,8 @@ static int get_srcimp_rsc(struct srcimp_mgr *mgr,
}
spin_unlock_irqrestore(&mgr->mgr_lock, flags);
if (err) {
- pr_err("ctxfi: Can't meet SRCIMP resource request!\n");
+ dev_err(((struct hw *)(mgr->mgr.hw))->card->dev,
+ "Can't meet SRCIMP resource request!\n");
goto error1;
}

diff --git a/sound/pci/ctxfi/ctvmem.c b/sound/pci/ctxfi/ctvmem.c
index 38163f5..419306e 100644
--- a/sound/pci/ctxfi/ctvmem.c
+++ b/sound/pci/ctxfi/ctvmem.c
@@ -16,6 +16,7 @@
*/

#include "ctvmem.h"
+#include "ctatc.h"
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/io.h>
@@ -29,14 +30,15 @@
* @size must be page aligned.
* */
static struct ct_vm_block *
-get_vm_block(struct ct_vm *vm, unsigned int size)
+get_vm_block(struct ct_vm *vm, unsigned int size, struct ct_atc *atc)
{
struct ct_vm_block *block = NULL, *entry;
struct list_head *pos;

size = CT_PAGE_ALIGN(size);
if (size > vm->size) {
- pr_err("ctxfi: Fail! No sufficient device virtual memory space available!\n");
+ dev_err(atc->card->dev,
+ "Fail! No sufficient device virtual memory space available!\n");
return NULL;
}

@@ -128,10 +130,12 @@ ct_vm_map(struct ct_vm *vm, struct snd_pcm_substream *substream, int size)
unsigned int pte_start;
unsigned i, pages;
unsigned long *ptp;
+ struct ct_atc *atc = snd_pcm_substream_chip(substream);

- block = get_vm_block(vm, size);
+ block = get_vm_block(vm, size, atc);
if (block == NULL) {
- pr_err("ctxfi: No virtual memory block that is big enough to allocate!\n");
+ dev_err(atc->card->dev,
+ "No virtual memory block that is big enough to allocate!\n");
return NULL;
}

diff --git a/sound/pci/ctxfi/xfi.c b/sound/pci/ctxfi/xfi.c
index 35e85ba..2eae617 100644
--- a/sound/pci/ctxfi/xfi.c
+++ b/sound/pci/ctxfi/xfi.c
@@ -76,15 +76,18 @@ ct_card_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
if (err)
return err;
if ((reference_rate != 48000) && (reference_rate != 44100)) {
- pr_err("ctxfi: Invalid reference_rate value %u!!!\n",
- reference_rate);
- pr_err("ctxfi: The valid values for reference_rate are 48000 and 44100, Value 48000 is assumed.\n");
+ dev_err(card->dev,
+ "ctxfi: Invalid reference_rate value %u!!!\n",
+ reference_rate);
+ dev_err(card->dev,
+ "ctxfi: The valid values for reference_rate are 48000 and 44100, Value 48000 is assumed.\n");
reference_rate = 48000;
}
if ((multiple != 1) && (multiple != 2) && (multiple != 4)) {
- pr_err("ctxfi: Invalid multiple value %u!!!\n",
- multiple);
- pr_err("ctxfi: The valid values for multiple are 1, 2 and 4, Value 2 is assumed.\n");
+ dev_err(card->dev, "ctxfi: Invalid multiple value %u!!!\n",
+ multiple);
+ dev_err(card->dev,
+ "ctxfi: The valid values for multiple are 1, 2 and 4, Value 2 is assumed.\n");
multiple = 2;
}
err = ct_atc_create(card, pci, reference_rate, multiple,
--
1.8.1.2
Takashi Iwai
2014-09-22 07:08:05 UTC
Permalink
At Sun, 21 Sep 2014 21:33:39 +0530,
Post by Sudip Mukherjee
pr_* macros replaced with dev_* as they are more preffered over pr_*.
In this patch, it's not trivial conversion, so it's not bad to spend
more words to explain how you did it. Nevertheless...

(snip)
Post by Sudip Mukherjee
diff --git a/sound/pci/ctxfi/ctamixer.c b/sound/pci/ctxfi/ctamixer.c
index fed6e6a..955b2af 100644
--- a/sound/pci/ctxfi/ctamixer.c
+++ b/sound/pci/ctxfi/ctamixer.c
@@ -258,7 +258,8 @@ static int get_amixer_rsc(struct amixer_mgr *mgr,
}
spin_unlock_irqrestore(&mgr->mgr_lock, flags);
if (err) {
- pr_err("ctxfi: Can't meet AMIXER resource request!\n");
+ dev_err(((struct hw *)(mgr->mgr.hw))->card->dev,
+ "Can't meet AMIXER resource request!\n");
Do we agree that such a change is too ugly, right? And...
Post by Sudip Mukherjee
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index 3e29e13..6c185d0 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -186,7 +186,7 @@ static unsigned int convert_format(snd_pcm_format_t snd_format,
return SRC_SF_F32;
- pr_err("ctxfi: not recognized snd format is %d\n",
+ dev_err(card->dev, "ctxfi: not recognized snd format is %d\n",
snd_format);
You forgot to strip the superfluous prefix in many places.


Takashi
Sudip Mukherjee
2014-09-22 08:08:16 UTC
Permalink
Post by Takashi Iwai
At Sun, 21 Sep 2014 21:33:39 +0530,
Post by Sudip Mukherjee
pr_* macros replaced with dev_* as they are more preffered over pr_*.
In this patch, it's not trivial conversion, so it's not bad to spend
more words to explain how you did it. Nevertheless...
(snip)
Post by Sudip Mukherjee
diff --git a/sound/pci/ctxfi/ctamixer.c b/sound/pci/ctxfi/ctamixer.c
index fed6e6a..955b2af 100644
--- a/sound/pci/ctxfi/ctamixer.c
+++ b/sound/pci/ctxfi/ctamixer.c
@@ -258,7 +258,8 @@ static int get_amixer_rsc(struct amixer_mgr *mgr,
}
spin_unlock_irqrestore(&mgr->mgr_lock, flags);
if (err) {
- pr_err("ctxfi: Can't meet AMIXER resource request!\n");
+ dev_err(((struct hw *)(mgr->mgr.hw))->card->dev,
+ "Can't meet AMIXER resource request!\n");
Do we agree that such a change is too ugly, right? And...
yes , it looks bad. we can have a pointer to the card in the struct of the managers.
Post by Takashi Iwai
Post by Sudip Mukherjee
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index 3e29e13..6c185d0 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -186,7 +186,7 @@ static unsigned int convert_format(snd_pcm_format_t snd_format,
return SRC_SF_F32;
- pr_err("ctxfi: not recognized snd format is %d\n",
+ dev_err(card->dev, "ctxfi: not recognized snd format is %d\n",
snd_format);
You forgot to strip the superfluous prefix in many places.
oops .. sorry ..

sudip
Post by Takashi Iwai
Takashi
Sudip Mukherjee
2014-09-21 16:03:40 UTC
Permalink
fixed sparse warning of incorrect type (different address spaces)

Signed-off-by: Sudip Mukherjee <***@vectorindia.org>
---
sound/pci/ctxfi/cthw20k2.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c
index 665eeb2..25ef60b 100644
--- a/sound/pci/ctxfi/cthw20k2.c
+++ b/sound/pci/ctxfi/cthw20k2.c
@@ -2112,7 +2112,7 @@ static int hw_card_shutdown(struct hw *hw)
hw->irq = -1;

if (hw->mem_base)
- iounmap((void *)hw->mem_base);
+ iounmap((void __iomem *)hw->mem_base);

hw->mem_base = (unsigned long)NULL;

@@ -2234,12 +2234,12 @@ static int hw_resume(struct hw *hw, struct card_conf *info)

static u32 hw_read_20kx(struct hw *hw, u32 reg)
{
- return readl((void *)(hw->mem_base + reg));
+ return readl((void __iomem *)(hw->mem_base + reg));
}

static void hw_write_20kx(struct hw *hw, u32 reg, u32 data)
{
- writel(data, (void *)(hw->mem_base + reg));
+ writel(data, (void __iomem *)(hw->mem_base + reg));
}

static struct hw ct20k2_preset = {
--
1.8.1.2
Takashi Iwai
2014-09-22 07:10:03 UTC
Permalink
At Sun, 21 Sep 2014 21:33:40 +0530,
Post by Sudip Mukherjee
fixed sparse warning of incorrect type (different address spaces)
Better to rather fix the type of hw.base_mem field.

Last but not least, try to align the subject line with other commits
to this driver. See git log and compare with yours.


thanks,

Takashi
Post by Sudip Mukherjee
---
sound/pci/ctxfi/cthw20k2.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c
index 665eeb2..25ef60b 100644
--- a/sound/pci/ctxfi/cthw20k2.c
+++ b/sound/pci/ctxfi/cthw20k2.c
@@ -2112,7 +2112,7 @@ static int hw_card_shutdown(struct hw *hw)
hw->irq = -1;
if (hw->mem_base)
- iounmap((void *)hw->mem_base);
+ iounmap((void __iomem *)hw->mem_base);
hw->mem_base = (unsigned long)NULL;
@@ -2234,12 +2234,12 @@ static int hw_resume(struct hw *hw, struct card_conf *info)
static u32 hw_read_20kx(struct hw *hw, u32 reg)
{
- return readl((void *)(hw->mem_base + reg));
+ return readl((void __iomem *)(hw->mem_base + reg));
}
static void hw_write_20kx(struct hw *hw, u32 reg, u32 data)
{
- writel(data, (void *)(hw->mem_base + reg));
+ writel(data, (void __iomem *)(hw->mem_base + reg));
}
static struct hw ct20k2_preset = {
--
1.8.1.2
Sudip Mukherjee
2014-09-22 08:09:56 UTC
Permalink
Post by Takashi Iwai
At Sun, 21 Sep 2014 21:33:40 +0530,
Post by Sudip Mukherjee
fixed sparse warning of incorrect type (different address spaces)
Better to rather fix the type of hw.base_mem field.
Last but not least, try to align the subject line with other commits
to this driver. See git log and compare with yours.
ok .. will do likewise.

thanks
sudip
Post by Takashi Iwai
thanks,
Takashi
Post by Sudip Mukherjee
---
sound/pci/ctxfi/cthw20k2.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c
index 665eeb2..25ef60b 100644
--- a/sound/pci/ctxfi/cthw20k2.c
+++ b/sound/pci/ctxfi/cthw20k2.c
@@ -2112,7 +2112,7 @@ static int hw_card_shutdown(struct hw *hw)
hw->irq = -1;
if (hw->mem_base)
- iounmap((void *)hw->mem_base);
+ iounmap((void __iomem *)hw->mem_base);
hw->mem_base = (unsigned long)NULL;
@@ -2234,12 +2234,12 @@ static int hw_resume(struct hw *hw, struct card_conf *info)
static u32 hw_read_20kx(struct hw *hw, u32 reg)
{
- return readl((void *)(hw->mem_base + reg));
+ return readl((void __iomem *)(hw->mem_base + reg));
}
static void hw_write_20kx(struct hw *hw, u32 reg, u32 data)
{
- writel(data, (void *)(hw->mem_base + reg));
+ writel(data, (void __iomem *)(hw->mem_base + reg));
}
static struct hw ct20k2_preset = {
--
1.8.1.2
Sudip Mukherjee
2014-09-21 16:03:41 UTC
Permalink
fixed sparse warning incorrect type (different address spaces)

Signed-off-by: Sudip Mukherjee <***@vectorindia.org>
---
sound/pci/ctxfi/cthw20k1.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c
index b807391..76db449 100644
--- a/sound/pci/ctxfi/cthw20k1.c
+++ b/sound/pci/ctxfi/cthw20k1.c
@@ -1803,7 +1803,7 @@ static int uaa_to_xfi(struct pci_dev *pci)
unsigned int is_uaa;
unsigned int data[4] = {0};
unsigned int io_base;
- void *mem_base;
+ void __iomem *mem_base;
int i;
const u32 CTLX = CTLBITS('C', 'T', 'L', 'X');
const u32 CTL_ = CTLBITS('C', 'T', 'L', '-');
@@ -1987,7 +1987,7 @@ static int hw_card_shutdown(struct hw *hw)
hw->irq = -1;

if (hw->mem_base)
- iounmap((void *)hw->mem_base);
+ iounmap((void __iomem *)hw->mem_base);

hw->mem_base = (unsigned long)NULL;
--
1.8.1.2
Takashi Iwai
2014-09-22 07:04:53 UTC
Permalink
At Sun, 21 Sep 2014 21:33:37 +0530,
Post by Sudip Mukherjee
added and initialized a pointer of snd_card in the struct hw to get a reference of
the card in other functions
You need to explain why this change is needed. The above text shows
what it'd do, but it doesn't give any explanation to convince why this
patch must be merged in. In this case, it's a preliminary patch for
the changes to convert to dev_*() later. It's the most important bit,
so don't forget it.


thanks,

Takashi
Post by Sudip Mukherjee
---
sound/pci/ctxfi/ctatc.c | 1 +
sound/pci/ctxfi/cthardware.h | 2 ++
2 files changed, 3 insertions(+)
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index d92a08c..b21eda4 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -1333,6 +1333,7 @@ static int atc_create_hw_devs(struct ct_atc *atc)
pr_err("Failed to create hw obj!!!\n");
return err;
}
+ hw->card = atc->card;
atc->hw = hw;
/* Initialize card hardware. */
diff --git a/sound/pci/ctxfi/cthardware.h b/sound/pci/ctxfi/cthardware.h
index 5977e9a..940bbd0 100644
--- a/sound/pci/ctxfi/cthardware.h
+++ b/sound/pci/ctxfi/cthardware.h
@@ -20,6 +20,7 @@
#include <linux/types.h>
#include <linux/pci.h>
+#include <sound/core.h>
enum CHIPTYP {
ATC20K1,
@@ -184,6 +185,7 @@ struct hw {
void *irq_callback_data;
struct pci_dev *pci; /* the pci kernel structure of this card */
+ struct snd_card *card; /* pointer to this card */
int irq;
unsigned long io_base;
unsigned long mem_base;
--
1.8.1.2
Sudip Mukherjee
2014-09-22 08:15:41 UTC
Permalink
Post by Takashi Iwai
At Sun, 21 Sep 2014 21:33:37 +0530,
Post by Sudip Mukherjee
added and initialized a pointer of snd_card in the struct hw to get a reference of
the card in other functions
You need to explain why this change is needed. The above text shows
what it'd do, but it doesn't give any explanation to convince why this
patch must be merged in. In this case, it's a preliminary patch for
the changes to convert to dev_*() later. It's the most important bit,
so don't forget it.
then do i mention in the commit that it is the preliminary patch for the later changes to dev_* ?
i was thinking that we can get a reference of the card from other functions which are using struct hw
is a reason by itself.

thanks
sudip
Post by Takashi Iwai
thanks,
Takashi
Post by Sudip Mukherjee
---
sound/pci/ctxfi/ctatc.c | 1 +
sound/pci/ctxfi/cthardware.h | 2 ++
2 files changed, 3 insertions(+)
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index d92a08c..b21eda4 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -1333,6 +1333,7 @@ static int atc_create_hw_devs(struct ct_atc *atc)
pr_err("Failed to create hw obj!!!\n");
return err;
}
+ hw->card = atc->card;
atc->hw = hw;
/* Initialize card hardware. */
diff --git a/sound/pci/ctxfi/cthardware.h b/sound/pci/ctxfi/cthardware.h
index 5977e9a..940bbd0 100644
--- a/sound/pci/ctxfi/cthardware.h
+++ b/sound/pci/ctxfi/cthardware.h
@@ -20,6 +20,7 @@
#include <linux/types.h>
#include <linux/pci.h>
+#include <sound/core.h>
enum CHIPTYP {
ATC20K1,
@@ -184,6 +185,7 @@ struct hw {
void *irq_callback_data;
struct pci_dev *pci; /* the pci kernel structure of this card */
+ struct snd_card *card; /* pointer to this card */
int irq;
unsigned long io_base;
unsigned long mem_base;
--
1.8.1.2
Takashi Iwai
2014-09-22 08:21:19 UTC
Permalink
At Mon, 22 Sep 2014 13:45:41 +0530,
Post by Sudip Mukherjee
Post by Takashi Iwai
At Sun, 21 Sep 2014 21:33:37 +0530,
Post by Sudip Mukherjee
added and initialized a pointer of snd_card in the struct hw to get a reference of
the card in other functions
You need to explain why this change is needed. The above text shows
what it'd do, but it doesn't give any explanation to convince why this
patch must be merged in. In this case, it's a preliminary patch for
the changes to convert to dev_*() later. It's the most important bit,
so don't forget it.
then do i mention in the commit that it is the preliminary patch for the later changes to dev_* ?
If the purpose of this patch is so, just write what it'll be used
for.
Post by Sudip Mukherjee
i was thinking that we can get a reference of the card from other functions which are using struct hw
is a reason by itself.
If the purpose of this patch is rather broader, just write what it'll
be used for.

Do you see what was missing?


Takashi
Sudip Mukherjee
2014-09-22 08:46:05 UTC
Permalink
Post by Takashi Iwai
At Mon, 22 Sep 2014 13:45:41 +0530,
Post by Sudip Mukherjee
Post by Takashi Iwai
At Sun, 21 Sep 2014 21:33:37 +0530,
Post by Sudip Mukherjee
added and initialized a pointer of snd_card in the struct hw to get a reference of
the card in other functions
You need to explain why this change is needed. The above text shows
what it'd do, but it doesn't give any explanation to convince why this
patch must be merged in. In this case, it's a preliminary patch for
the changes to convert to dev_*() later. It's the most important bit,
so don't forget it.
then do i mention in the commit that it is the preliminary patch for the later changes to dev_* ?
If the purpose of this patch is so, just write what it'll be used
for.
Post by Sudip Mukherjee
i was thinking that we can get a reference of the card from other functions which are using struct hw
is a reason by itself.
If the purpose of this patch is rather broader, just write what it'll
be used for.
Do you see what was missing?
understood.
thanks . I hope v4 will be a better series than this .

sudip
Post by Takashi Iwai
Takashi
Loading...