[PATCH 12/15] dmaengine: pxa: make the filter function internal

2018-04-02 Thread Robert Jarzmik
As the pxa architecture and all its related drivers do not rely anymore
on the filter function, thanks to the slave map conversion, make
pxad_filter_fn() static, and remove it from the global namespace.

Signed-off-by: Robert Jarzmik 
---
 drivers/dma/pxa_dma.c   |  5 ++---
 include/linux/dma/pxa-dma.h | 11 ---
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index 9505334f9c6e..a332ad1d7dfb 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -179,7 +179,7 @@ static unsigned int pxad_drcmr(unsigned int line)
return 0x1000 + line * 4;
 }
 
-bool pxad_filter_fn(struct dma_chan *chan, void *param);
+static bool pxad_filter_fn(struct dma_chan *chan, void *param);
 
 /*
  * Debug fs
@@ -1496,7 +1496,7 @@ static struct platform_driver pxad_driver = {
.remove = pxad_remove,
 };
 
-bool pxad_filter_fn(struct dma_chan *chan, void *param)
+static bool pxad_filter_fn(struct dma_chan *chan, void *param)
 {
struct pxad_chan *c = to_pxad_chan(chan);
struct pxad_param *p = param;
@@ -1509,7 +1509,6 @@ bool pxad_filter_fn(struct dma_chan *chan, void *param)
 
return true;
 }
-EXPORT_SYMBOL_GPL(pxad_filter_fn);
 
 module_platform_driver(pxad_driver);
 
diff --git a/include/linux/dma/pxa-dma.h b/include/linux/dma/pxa-dma.h
index 9fc594f69eff..fceb5df07097 100644
--- a/include/linux/dma/pxa-dma.h
+++ b/include/linux/dma/pxa-dma.h
@@ -23,15 +23,4 @@ struct pxad_param {
enum pxad_chan_prio prio;
 };
 
-struct dma_chan;
-
-#ifdef CONFIG_PXA_DMA
-bool pxad_filter_fn(struct dma_chan *chan, void *param);
-#else
-static inline bool pxad_filter_fn(struct dma_chan *chan, void *param)
-{
-   return false;
-}
-#endif
-
 #endif /* _PXA_DMA_H_ */
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/15] ARM: pxa: remove the DMA IO resources

2018-04-02 Thread Robert Jarzmik
As the last driver using the former mechanism to acquire the DMA
requestor line has be converted to the dma_slave_map, remove all these
resources from the PXA devices.

Signed-off-by: Robert Jarzmik 
---
 arch/arm/mach-pxa/devices.c | 136 
 1 file changed, 136 deletions(-)

diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index da67ebe9a7d5..c0b3c90fd67f 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -61,16 +61,6 @@ static struct resource pxamci_resources[] = {
.end= IRQ_MMC,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   .start  = 21,
-   .end= 21,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   .start  = 22,
-   .end= 22,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 static u64 pxamci_dmamask = 0xUL;
@@ -408,16 +398,6 @@ static struct resource pxa_ir_resources[] = {
.end= 0x40700023,
.flags  = IORESOURCE_MEM,
},
-   [5] = {
-   .start  = 17,
-   .end= 17,
-   .flags  = IORESOURCE_DMA,
-   },
-   [6] = {
-   .start  = 18,
-   .end= 18,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa_device_ficp = {
@@ -546,18 +526,6 @@ static struct resource pxa25x_resource_ssp[] = {
.end= IRQ_SSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 13,
-   .end= 13,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 14,
-   .end= 14,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa25x_device_ssp = {
@@ -584,18 +552,6 @@ static struct resource pxa25x_resource_nssp[] = {
.end= IRQ_NSSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 15,
-   .end= 15,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 16,
-   .end= 16,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa25x_device_nssp = {
@@ -622,18 +578,6 @@ static struct resource pxa25x_resource_assp[] = {
.end= IRQ_ASSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 23,
-   .end= 23,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 24,
-   .end= 24,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa25x_device_assp = {
@@ -752,18 +696,6 @@ static struct resource pxa27x_resource_ssp1[] = {
.end= IRQ_SSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 13,
-   .end= 13,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 14,
-   .end= 14,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa27x_device_ssp1 = {
@@ -790,18 +722,6 @@ static struct resource pxa27x_resource_ssp2[] = {
.end= IRQ_SSP2,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 15,
-   .end= 15,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 16,
-   .end= 16,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa27x_device_ssp2 = {
@@ -828,18 +748,6 @@ static struct resource pxa27x_resource_ssp3[] = {
.end= IRQ_SSP3,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 66,
-   .end= 66,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 67,
-   .end= 67,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa27x_device_ssp3 = {
@@ -896,16 +804,6 @@ static struct resource pxa3xx_resources_mci2[] = {
.end= IRQ_MMC2,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   .start  = 93,
-   .end= 93,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   .start  = 9

[PATCH 14/15] ARM: pxa: change SSP devices allocation

2018-04-02 Thread Robert Jarzmik
In order to prepare for the dma_slave_map change for SSP DMA channels
allocation, the SSP platform devices will now include a platform data
structure which in turn selects which dma channel has to be used for
data transfers, especially the PCM ones.

Signed-off-by: Robert Jarzmik 
---
 arch/arm/mach-pxa/devices.c| 78 +-
 arch/arm/mach-pxa/devices.h| 14 ++
 arch/arm/mach-pxa/include/mach/audio.h | 12 ++
 arch/arm/mach-pxa/pxa25x.c |  4 +-
 arch/arm/mach-pxa/pxa27x.c |  4 +-
 arch/arm/mach-pxa/pxa3xx.c |  5 +--
 6 files changed, 86 insertions(+), 31 deletions(-)

diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index c0b3c90fd67f..955d255dc4f4 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -481,6 +481,17 @@ void __init pxa_set_ac97_info(pxa2xx_audio_ops_t *ops)
pxa_register_device(&pxa_device_ac97, ops);
 }
 
+static struct pxa_ssp_info pxa_ssp_infos[] = {
+   { .dma_chan_rx_name = "ssp1_rx", .dma_chan_tx_name = "ssp1_tx", },
+   { .dma_chan_rx_name = "ssp1_rx", .dma_chan_tx_name = "ssp1_tx", },
+   { .dma_chan_rx_name = "ssp2_rx", .dma_chan_tx_name = "ssp2_tx", },
+   { .dma_chan_rx_name = "ssp2_rx", .dma_chan_tx_name = "ssp2_tx", },
+   { .dma_chan_rx_name = "ssp3_rx", .dma_chan_tx_name = "ssp3_tx", },
+   { .dma_chan_rx_name = "ssp3_rx", .dma_chan_tx_name = "ssp3_tx", },
+   { .dma_chan_rx_name = "ssp4_rx", .dma_chan_tx_name = "ssp4_tx", },
+   { .dma_chan_rx_name = "ssp4_rx", .dma_chan_tx_name = "ssp4_tx", },
+};
+
 #ifdef CONFIG_PXA25x
 
 static struct resource pxa25x_resource_pwm0[] = {
@@ -528,7 +539,7 @@ static struct resource pxa25x_resource_ssp[] = {
},
 };
 
-struct platform_device pxa25x_device_ssp = {
+static struct platform_device pxa25x_device_ssp = {
.name   = "pxa25x-ssp",
.id = 0,
.dev= {
@@ -554,7 +565,7 @@ static struct resource pxa25x_resource_nssp[] = {
},
 };
 
-struct platform_device pxa25x_device_nssp = {
+static struct platform_device pxa25x_device_nssp = {
.name   = "pxa25x-nssp",
.id = 1,
.dev= {
@@ -580,7 +591,7 @@ static struct resource pxa25x_resource_assp[] = {
},
 };
 
-struct platform_device pxa25x_device_assp = {
+static struct platform_device pxa25x_device_assp = {
/* ASSP is basically equivalent to NSSP */
.name   = "pxa25x-nssp",
.id = 2,
@@ -591,6 +602,22 @@ struct platform_device pxa25x_device_assp = {
.resource   = pxa25x_resource_assp,
.num_resources  = ARRAY_SIZE(pxa25x_resource_assp),
 };
+
+static struct platform_device *pxa25x_device_ssps[] = {
+   &pxa25x_device_ssp,
+   &pxa25x_device_nssp,
+   &pxa25x_device_assp,
+};
+
+void __init pxa25x_set_ssp_info(void)
+{
+   int ssp;
+
+   for (ssp = 0; ssp < ARRAY_SIZE(pxa25x_device_ssps); ssp++)
+   pxa_register_device(pxa25x_device_ssps[ssp],
+   &pxa_ssp_infos[ssp]);
+}
+
 #endif /* CONFIG_PXA25x */
 
 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
@@ -698,7 +725,7 @@ static struct resource pxa27x_resource_ssp1[] = {
},
 };
 
-struct platform_device pxa27x_device_ssp1 = {
+static struct platform_device pxa27x_device_ssp1 = {
.name   = "pxa27x-ssp",
.id = 0,
.dev= {
@@ -724,7 +751,7 @@ static struct resource pxa27x_resource_ssp2[] = {
},
 };
 
-struct platform_device pxa27x_device_ssp2 = {
+static struct platform_device pxa27x_device_ssp2 = {
.name   = "pxa27x-ssp",
.id = 1,
.dev= {
@@ -750,7 +777,7 @@ static struct resource pxa27x_resource_ssp3[] = {
},
 };
 
-struct platform_device pxa27x_device_ssp3 = {
+static struct platform_device pxa27x_device_ssp3 = {
.name   = "pxa27x-ssp",
.id = 2,
.dev= {
@@ -761,6 +788,21 @@ struct platform_device pxa27x_device_ssp3 = {
.num_resources  = ARRAY_SIZE(pxa27x_resource_ssp3),
 };
 
+static struct platform_device *pxa27x_device_ssps[] = {
+   &pxa27x_device_ssp1,
+   &pxa27x_device_ssp2,
+   &pxa27x_device_ssp3,
+};
+
+void __init pxa27x_set_ssp_info(void)
+{
+   int ssp;
+
+   for (ssp = 0; ssp < ARRAY_SIZE(pxa27x_device_ssps); ssp++)
+   pxa_register_device(pxa27x_device_ssps[ssp],
+   &pxa_ssp_infos[ssp]);
+}
+
 static struct resource pxa27x_resource_pwm0[] = {
[0] = {
.start  = 0x40b0,
@@ -951,7 +993,7 @@ static struct resource pxa3xx_resource_ssp4[] = {
  * make the driver set the correct internal type, hence we provide specific
  * platform_devices for each of them.
  */
-struct platform_device pxa3xx_device_ssp1 = {
+static struct

[PATCH 15/15] ARM: pxa: change SSP DMA channels allocation

2018-04-02 Thread Robert Jarzmik
Now the dma_slave_map is available for PXA architecture, switch the SSP
device to it.

This specifically means that :
- for platform data based machines, the DMA requestor channels are
  extracted from platform data and passed further to the SSP user,
  ie. usually the pxa-pcm-audio driver

- for device tree platforms, the dma node should be hooked into the
  pxa-pcm-audio node.

Signed-off-by: Robert Jarzmik 
---
 arch/arm/plat-pxa/ssp.c| 50 +-
 include/linux/pxa2xx_ssp.h |  4 ++--
 sound/soc/pxa/pxa-ssp.c|  5 ++---
 3 files changed, 9 insertions(+), 50 deletions(-)

diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c
index ba13f793fbce..3457f01e3340 100644
--- a/arch/arm/plat-pxa/ssp.c
+++ b/arch/arm/plat-pxa/ssp.c
@@ -16,6 +16,7 @@
  *  Author: Liam Girdwood 
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -116,6 +117,7 @@ static int pxa_ssp_probe(struct platform_device *pdev)
struct resource *res;
struct ssp_device *ssp;
struct device *dev = &pdev->dev;
+   struct pxa_ssp_info *info = dev_get_platdata(dev);
 
ssp = devm_kzalloc(dev, sizeof(struct ssp_device), GFP_KERNEL);
if (ssp == NULL)
@@ -127,51 +129,9 @@ static int pxa_ssp_probe(struct platform_device *pdev)
if (IS_ERR(ssp->clk))
return PTR_ERR(ssp->clk);
 
-   if (dev->of_node) {
-   struct of_phandle_args dma_spec;
-   struct device_node *np = dev->of_node;
-   int ret;
-
-   /*
-* FIXME: we should allocate the DMA channel from this
-* context and pass the channel down to the ssp users.
-* For now, we lookup the rx and tx indices manually
-*/
-
-   /* rx */
-   ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells",
-0, &dma_spec);
-
-   if (ret) {
-   dev_err(dev, "Can't parse dmas property\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_rx = dma_spec.args[0];
-   of_node_put(dma_spec.np);
-
-   /* tx */
-   ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells",
-1, &dma_spec);
-   if (ret) {
-   dev_err(dev, "Can't parse dmas property\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_tx = dma_spec.args[0];
-   of_node_put(dma_spec.np);
-   } else {
-   res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-   if (res == NULL) {
-   dev_err(dev, "no SSP RX DRCMR defined\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_rx = res->start;
-
-   res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
-   if (res == NULL) {
-   dev_err(dev, "no SSP TX DRCMR defined\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_tx = res->start;
+   if (!dev->of_node && info) {
+   ssp->dma_chan_rx = info->dma_chan_rx_name;
+   ssp->dma_chan_tx = info->dma_chan_tx_name;
}
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/include/linux/pxa2xx_ssp.h b/include/linux/pxa2xx_ssp.h
index 8461b18e4608..99c99d397e4d 100644
--- a/include/linux/pxa2xx_ssp.h
+++ b/include/linux/pxa2xx_ssp.h
@@ -212,9 +212,9 @@ struct ssp_device {
int type;
int use_count;
int irq;
-   int drcmr_rx;
-   int drcmr_tx;
 
+   const char  *dma_chan_rx;
+   const char  *dma_chan_tx;
struct device_node  *of_node;
 };
 
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index 0291c7cb64eb..a0189b88f1d2 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -104,9 +104,8 @@ static int pxa_ssp_startup(struct snd_pcm_substream 
*substream,
dma = kzalloc(sizeof(struct snd_dmaengine_dai_dma_data), GFP_KERNEL);
if (!dma)
return -ENOMEM;
-
-   dma->filter_data = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
-   &ssp->drcmr_tx : &ssp->drcmr_rx;
+   dma->chan_name = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
+   ssp->dma_chan_tx : ssp->dma_chan_rx;
 
snd_soc_dai_set_dma_data(cpu_dai, substream, dma);
 
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 01/75] staging: ks7010: Use the ARRAY_SIZE() macro to calculate array sizes.

2018-04-02 Thread Joe Perches
On Mon, 2018-04-02 at 14:45 +0300, Dan Carpenter wrote:
> On Sat, Mar 31, 2018 at 07:12:53AM -0700, Joe Perches wrote:
> > On Sat, 2018-03-31 at 11:41 +0300, Dan Carpenter wrote:
> > > On Fri, Mar 30, 2018 at 11:36:13PM -0700, Joe Perches wrote:
> > > > On Fri, 2018-03-30 at 23:07 -0700, Quytelda Kahja wrote:
> > > > > This macro, provided in 'linux/kernel.h', will calculate the size
> > > > > more succinctly than a division operation.
> > > > 
> > > > It's nice that you send patches, but please try to send a
> > > > cover letter with your patch series.
> > > > 
> > > 
> > > There are obviously times when a cover letter is required but what's the
> > > point of that for this particular series?
> > 
> > practice
> > 
> It really pisses me off to see patch submitters get assign busy work
> for no reason.  This is not school and these are not your students.

Please take a chill pill Dan.
I think cover letters are best practice.

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 12/15] dmaengine: pxa: make the filter function internal

2018-04-02 Thread kbuild test robot
Hi Robert,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.16]
[cannot apply to arm-soc/for-next next-20180329]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Robert-Jarzmik/ARM-pxa-switch-to-DMA-slave-maps/20180402-233029
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   In file included from drivers/mtd/nand/marvell_nand.c:21:0:
   drivers/mtd/nand/marvell_nand.c: In function 'marvell_nfc_init_dma':
>> drivers/mtd/nand/marvell_nand.c:2621:42: error: 'pxad_filter_fn' undeclared 
>> (first use in this function); did you mean 'dma_filter_fn'?
  dma_request_slave_channel_compat(mask, pxad_filter_fn,
 ^
   include/linux/dmaengine.h:1408:46: note: in definition of macro 
'dma_request_slave_channel_compat'
 __dma_request_slave_channel_compat(&(mask), x, y, dev, name)
 ^
   drivers/mtd/nand/marvell_nand.c:2621:42: note: each undeclared identifier is 
reported only once for each function it appears in
  dma_request_slave_channel_compat(mask, pxad_filter_fn,
 ^
   include/linux/dmaengine.h:1408:46: note: in definition of macro 
'dma_request_slave_channel_compat'
 __dma_request_slave_channel_compat(&(mask), x, y, dev, name)
 ^

vim +2621 drivers/mtd/nand/marvell_nand.c

02f26ecf Miquel Raynal 2018-01-09  2588  
02f26ecf Miquel Raynal 2018-01-09  2589  static int marvell_nfc_init_dma(struct 
marvell_nfc *nfc)
02f26ecf Miquel Raynal 2018-01-09  2590  {
02f26ecf Miquel Raynal 2018-01-09  2591 struct platform_device *pdev = 
container_of(nfc->dev,
02f26ecf Miquel Raynal 2018-01-09  2592 
struct platform_device,
02f26ecf Miquel Raynal 2018-01-09  2593 
dev);
02f26ecf Miquel Raynal 2018-01-09  2594 struct dma_slave_config config 
= {};
02f26ecf Miquel Raynal 2018-01-09  2595 struct resource *r;
02f26ecf Miquel Raynal 2018-01-09  2596 dma_cap_mask_t mask;
02f26ecf Miquel Raynal 2018-01-09  2597 struct pxad_param param;
02f26ecf Miquel Raynal 2018-01-09  2598 int ret;
02f26ecf Miquel Raynal 2018-01-09  2599  
02f26ecf Miquel Raynal 2018-01-09  2600 if 
(!IS_ENABLED(CONFIG_PXA_DMA)) {
02f26ecf Miquel Raynal 2018-01-09  2601 dev_warn(nfc->dev,
02f26ecf Miquel Raynal 2018-01-09  2602  "DMA not 
enabled in configuration\n");
02f26ecf Miquel Raynal 2018-01-09  2603 return -ENOTSUPP;
02f26ecf Miquel Raynal 2018-01-09  2604 }
02f26ecf Miquel Raynal 2018-01-09  2605  
02f26ecf Miquel Raynal 2018-01-09  2606 ret = 
dma_set_mask_and_coherent(nfc->dev, DMA_BIT_MASK(32));
02f26ecf Miquel Raynal 2018-01-09  2607 if (ret)
02f26ecf Miquel Raynal 2018-01-09  2608 return ret;
02f26ecf Miquel Raynal 2018-01-09  2609  
02f26ecf Miquel Raynal 2018-01-09  2610 r = platform_get_resource(pdev, 
IORESOURCE_DMA, 0);
02f26ecf Miquel Raynal 2018-01-09  2611 if (!r) {
02f26ecf Miquel Raynal 2018-01-09  2612 dev_err(nfc->dev, "No 
resource defined for data DMA\n");
02f26ecf Miquel Raynal 2018-01-09  2613 return -ENXIO;
02f26ecf Miquel Raynal 2018-01-09  2614 }
02f26ecf Miquel Raynal 2018-01-09  2615  
02f26ecf Miquel Raynal 2018-01-09  2616 param.drcmr = r->start;
02f26ecf Miquel Raynal 2018-01-09  2617 param.prio = PXAD_PRIO_LOWEST;
02f26ecf Miquel Raynal 2018-01-09  2618 dma_cap_zero(mask);
02f26ecf Miquel Raynal 2018-01-09  2619 dma_cap_set(DMA_SLAVE, mask);
02f26ecf Miquel Raynal 2018-01-09  2620 nfc->dma_chan =
02f26ecf Miquel Raynal 2018-01-09 @2621 
dma_request_slave_channel_compat(mask, pxad_filter_fn,
02f26ecf Miquel Raynal 2018-01-09  2622 
 ¶m, nfc->dev,
02f26ecf Miquel Raynal 2018-01-09  2623 
 "data");
02f26ecf Miquel Raynal 2018-01-09  2624 if (!nfc->dma_chan) {
02f26ecf Miquel Raynal 2018-01-09  2625 dev_err(nfc->dev,
02f26ecf Miquel Raynal 2018-01-09  2626 "Unable to 
request data DMA channel\n");
02f26ecf Miquel Raynal 2018-01-09  2627 return -ENODEV;
02f26ecf Miquel Raynal 2018-01-09  2628 }
02f26ecf Miquel Raynal 2018-01-09  2629

Re: [PATCH 12/15] dmaengine: pxa: make the filter function internal

2018-04-02 Thread kbuild test robot
Hi Robert,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.16]
[cannot apply to arm-soc/for-next next-20180329]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Robert-Jarzmik/ARM-pxa-switch-to-DMA-slave-maps/20180402-233029
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   drivers/mtd/nand/marvell_nand.c:2621:17: sparse: undefined identifier 
'pxad_filter_fn'
>> drivers/mtd/nand/marvell_nand.c:2621:17: sparse: call with no type!
   In file included from drivers/mtd/nand/marvell_nand.c:21:0:
   drivers/mtd/nand/marvell_nand.c: In function 'marvell_nfc_init_dma':
   drivers/mtd/nand/marvell_nand.c:2621:42: error: 'pxad_filter_fn' undeclared 
(first use in this function); did you mean 'dma_filter_fn'?
  dma_request_slave_channel_compat(mask, pxad_filter_fn,
 ^
   include/linux/dmaengine.h:1408:46: note: in definition of macro 
'dma_request_slave_channel_compat'
 __dma_request_slave_channel_compat(&(mask), x, y, dev, name)
 ^
   drivers/mtd/nand/marvell_nand.c:2621:42: note: each undeclared identifier is 
reported only once for each function it appears in
  dma_request_slave_channel_compat(mask, pxad_filter_fn,
 ^
   include/linux/dmaengine.h:1408:46: note: in definition of macro 
'dma_request_slave_channel_compat'
 __dma_request_slave_channel_compat(&(mask), x, y, dev, name)
 ^

vim +2621 drivers/mtd/nand/marvell_nand.c

02f26ecf Miquel Raynal 2018-01-09  2588  
02f26ecf Miquel Raynal 2018-01-09  2589  static int marvell_nfc_init_dma(struct 
marvell_nfc *nfc)
02f26ecf Miquel Raynal 2018-01-09  2590  {
02f26ecf Miquel Raynal 2018-01-09  2591 struct platform_device *pdev = 
container_of(nfc->dev,
02f26ecf Miquel Raynal 2018-01-09  2592 
struct platform_device,
02f26ecf Miquel Raynal 2018-01-09  2593 
dev);
02f26ecf Miquel Raynal 2018-01-09  2594 struct dma_slave_config config 
= {};
02f26ecf Miquel Raynal 2018-01-09  2595 struct resource *r;
02f26ecf Miquel Raynal 2018-01-09  2596 dma_cap_mask_t mask;
02f26ecf Miquel Raynal 2018-01-09  2597 struct pxad_param param;
02f26ecf Miquel Raynal 2018-01-09  2598 int ret;
02f26ecf Miquel Raynal 2018-01-09  2599  
02f26ecf Miquel Raynal 2018-01-09  2600 if 
(!IS_ENABLED(CONFIG_PXA_DMA)) {
02f26ecf Miquel Raynal 2018-01-09  2601 dev_warn(nfc->dev,
02f26ecf Miquel Raynal 2018-01-09  2602  "DMA not 
enabled in configuration\n");
02f26ecf Miquel Raynal 2018-01-09  2603 return -ENOTSUPP;
02f26ecf Miquel Raynal 2018-01-09  2604 }
02f26ecf Miquel Raynal 2018-01-09  2605  
02f26ecf Miquel Raynal 2018-01-09  2606 ret = 
dma_set_mask_and_coherent(nfc->dev, DMA_BIT_MASK(32));
02f26ecf Miquel Raynal 2018-01-09  2607 if (ret)
02f26ecf Miquel Raynal 2018-01-09  2608 return ret;
02f26ecf Miquel Raynal 2018-01-09  2609  
02f26ecf Miquel Raynal 2018-01-09  2610 r = platform_get_resource(pdev, 
IORESOURCE_DMA, 0);
02f26ecf Miquel Raynal 2018-01-09  2611 if (!r) {
02f26ecf Miquel Raynal 2018-01-09  2612 dev_err(nfc->dev, "No 
resource defined for data DMA\n");
02f26ecf Miquel Raynal 2018-01-09  2613 return -ENXIO;
02f26ecf Miquel Raynal 2018-01-09  2614 }
02f26ecf Miquel Raynal 2018-01-09  2615  
02f26ecf Miquel Raynal 2018-01-09  2616 param.drcmr = r->start;
02f26ecf Miquel Raynal 2018-01-09  2617 param.prio = PXAD_PRIO_LOWEST;
02f26ecf Miquel Raynal 2018-01-09  2618 dma_cap_zero(mask);
02f26ecf Miquel Raynal 2018-01-09  2619 dma_cap_set(DMA_SLAVE, mask);
02f26ecf Miquel Raynal 2018-01-09  2620 nfc->dma_chan =
02f26ecf Miquel Raynal 2018-01-09 @2621 
dma_request_slave_channel_compat(mask, pxad_filter_fn,
02f26ecf Miquel Raynal 2018-01-09  2622 
 ¶m, nfc->dev,
02f26ecf Miquel Raynal 2018-01-09  2623 
 "data");
02f26ecf Miquel Raynal 2018-01-09  2624 if (!nfc->dma_chan) {
02f26ecf Miquel Raynal 2018-01-09  2625 dev_err(nfc->dev,
02f26ecf Miquel Raynal 2018-01-09  2626 "Unable to 
request data DMA channel\n");
02f26ecf Miquel Raynal 2018-01-09  2627 

[PATCH 21/34] staging: mt7621-mmc: Remove unused datastructures

2018-04-02 Thread Christian Lütke-Stetzkamp
Remove unused datastructures and comments referring to their former use.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 23 ---
 1 file changed, 23 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 552bf0824d31..7cc7aa4b6ec7 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -198,25 +198,6 @@ struct msdc_hw msdc0_hw = {
 // .flags  = MSDC_SYS_SUSPEND | MSDC_WP_PIN_EN | MSDC_CD_PIN_EN | 
MSDC_REMOVABLE,
 };
 
-static struct resource mtk_sd_resources[] = {
-   [0] = {
-   .start  = RALINK_MSDC_BASE,
-   .end= RALINK_MSDC_BASE + 0x3fff,
-   .flags  = IORESOURCE_MEM,
-   },
-   [1] = {
-   .start  = IRQ_SDC,  /*FIXME*/
-   .end= IRQ_SDC,  /*FIXME*/
-   .flags  = IORESOURCE_IRQ,
-   },
-};
-
-static struct platform_device mtk_sd_device = {
-   .name   = "mtk-sd",
-   .id = 0,
-   .num_resources  = ARRAY_SIZE(mtk_sd_resources),
-   .resource   = mtk_sd_resources,
-};
 /* end of +++ */
 
 static int msdc_rsp[] = {
@@ -2986,14 +2967,11 @@ static int __init mt_msdc_init(void)
u32 reg;
 
printk("MTK MSDC device init.\n");
-   mtk_sd_device.dev.platform_data = &msdc0_hw;
 
// Set the pins for sdxc to sdxc mode
//FIXME: this should be done by pinctl and not by the sd driver
reg = sdr_read32((volatile u32 *)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3 
<< 18);
sdr_write32((volatile u32 *)(RALINK_SYSCTL_BASE + 0x60), reg);
-   //platform_device_register(&mtk_sd_device);
-/* end of +++ */
 
ret = platform_driver_register(&mt_msdc_driver);
if (ret) {
@@ -3010,7 +2988,6 @@ static int __init mt_msdc_init(void)
 
 static void __exit mt_msdc_exit(void)
 {
-//platform_device_unregister(&mtk_sd_device);
platform_driver_unregister(&mt_msdc_driver);
 }
 
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/34] staging: mt7621-mmc: Remove whitespace errors in dbg.c

2018-04-02 Thread Christian Lütke-Stetzkamp
The whitespace errors in the file dbg.c are fixed by using the
cleanfile script. Indentations with whitespaces are not changed
in this patch.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/dbg.c | 190 +++
 1 file changed, 95 insertions(+), 95 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/dbg.c b/drivers/staging/mt7621-mmc/dbg.c
index 4dc115b53993..3f204d7480c9 100644
--- a/drivers/staging/mt7621-mmc/dbg.c
+++ b/drivers/staging/mt7621-mmc/dbg.c
@@ -32,7 +32,7 @@
  * have been modified by MediaTek Inc. All revisions are subject to any 
receiver's
  * applicable license agreements with MediaTek Inc.
  */
- 
+
 #include 
 #include 
 #include 
@@ -78,151 +78,151 @@ msdc_mode drv_mode[4]={
 u32 gpt_enable = 0;
 u32 sdio_pro_enable = 0;   /* make sure gpt is enabled */
 u32 sdio_pro_time = 0; /* no more than 30s */
-struct sdio_profile sdio_perfomance = {0};  
+struct sdio_profile sdio_perfomance = {0};
 
 #if 0 /* --- chhung */
 void msdc_init_gpt(void)
 {
-GPT_CONFIG config; 
-
+GPT_CONFIG config;
+
 config.num  = GPT6;
 config.mode = GPT_FREE_RUN;
 config.clkSrc = GPT_CLK_SRC_SYS;
 config.clkDiv = GPT_CLK_DIV_1;   /* 13MHz GPT6 */
-
+
 if (GPT_Config(config) == FALSE )
-return;   
-
-GPT_Start(GPT6);   
+return;
+
+GPT_Start(GPT6);
 }
 #endif /* end of --- */
 
 u32 msdc_time_calc(u32 old_L32, u32 old_H32, u32 new_L32, u32 new_H32)
 {
-u32 ret = 0; 
-
+u32 ret = 0;
+
 if (new_H32 == old_H32) {
 ret = new_L32 - old_L32;
 } else if(new_H32 == (old_H32 + 1)) {
-if (new_L32 > old_L32) {   
-printk("msdc old_L<0x%x> new_L<0x%x>\n", old_L32, new_L32);
+if (new_L32 > old_L32) {
+printk("msdc old_L<0x%x> new_L<0x%x>\n", old_L32, new_L32);
 }
-ret = (0x - old_L32);
-ret += new_L32; 
+ret = (0x - old_L32);
+ret += new_L32;
 } else {
-printk("msdc old_H<0x%x> new_H<0x%x>\n", old_H32, new_H32);
+printk("msdc old_H<0x%x> new_H<0x%x>\n", old_H32, new_H32);
 }
 
-return ret;
+return ret;
 }
 
 void msdc_sdio_profile(struct sdio_profile* result)
 {
 struct cmd_profile*  cmd;
-u32 i; 
-
+u32 i;
+
 printk("sdio === performance dump ===\n");
-printk("sdio === total execute tick<%d> time<%dms> Tx<%dB> Rx<%dB>\n", 
-result->total_tc, result->total_tc / TICKS_ONE_MS, 
-result->total_tx_bytes, result->total_rx_bytes);
+printk("sdio === total execute tick<%d> time<%dms> Tx<%dB> Rx<%dB>\n",
+result->total_tc, result->total_tc / TICKS_ONE_MS,
+result->total_tx_bytes, result->total_rx_bytes);
 
 /* CMD52 Dump */
-cmd = &result->cmd52_rx; 
-printk("sdio === CMD52 Rx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", 
cmd->count, cmd->tot_tc, 
-cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count); 
-cmd = &result->cmd52_tx; 
-printk("sdio === CMD52 Tx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", 
cmd->count, cmd->tot_tc, 
-cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count);   
-
+cmd = &result->cmd52_rx;
+printk("sdio === CMD52 Rx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", 
cmd->count, cmd->tot_tc,
+cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count);
+cmd = &result->cmd52_tx;
+printk("sdio === CMD52 Tx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", 
cmd->count, cmd->tot_tc,
+cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count);
+
 /* CMD53 Rx bytes + block mode */
 for (i=0; i<512; i++) {
 cmd = &result->cmd53_rx_byte[i];
 if (cmd->count) {
-printk("sdio<%6d><%3dB>_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", 
cmd->count, i, cmd->tot_tc, 
+printk("sdio<%6d><%3dB>_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", 
cmd->count, i, cmd->tot_tc,
  cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
- cmd->tot_bytes, (cmd->tot_bytes/10)*13 / 
(cmd->tot_tc/10));   
-}  
-}  
+ cmd->tot_bytes, (cmd->tot_bytes/10)*13 / 
(cmd->tot_tc/10));
+}
+}
 for (i=0; i<100; i++) {
 cmd = &result->cmd53_rx_blk[i];
 if (cmd->count) {
-printk("sdio<%6d><%3d>B_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", 
cmd->count, i, cmd->tot_tc, 
+printk("sdio<%6d><%3d>B_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", 
cmd->count, i, cmd->tot_tc,
  cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
- cmd->tot_bytes, (cmd->tot_bytes/10)*13 / 
(cmd->tot_tc/10));   
-  

[PATCH 30/34] staging: mt7621-mmc: Fix different caps for different devices

2018-04-02 Thread Christian Lütke-Stetzkamp
Current code saves the need for polling in a global variable, that
leeds to problems, when the driver should handle multiple devices with
different capabilities. By looking up the capability in the mmc_host
capabilities, they now have per device scope.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index e7a4adf53e1d..acee35282678 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -153,7 +153,6 @@
 static struct msdc_regs *msdc_reg[HOST_MAX_NUM];
 #endif
 
-static int mtk_sw_poll;
 
 static int cd_active_low = 1;
 
@@ -2361,7 +2360,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id)
 
/* card change interrupt */
if (intsts & MSDC_INT_CDSC) {
-   if (mtk_sw_poll)
+   if (host->mmc->caps & MMC_CAP_NEEDS_POLL)
return IRQ_HANDLED;
IRQ_MSG("MSDC_INT_CDSC irq<0x%.8x>", intsts);
 #if 0 /* ---/+++ by chhung: fix slot mechanical bounce issue */
@@ -2739,9 +2738,8 @@ static int msdc_drv_probe(struct platform_device *pdev)
mmc->caps |= MMC_CAP_SDIO_IRQ;  /* yes for sdio */
 
cd_active_low = !of_property_read_bool(pdev->dev.of_node, 
"mediatek,cd-high");
-   mtk_sw_poll = of_property_read_bool(pdev->dev.of_node, 
"mediatek,cd-poll");
 
-   if (mtk_sw_poll)
+   if (of_property_read_bool(pdev->dev.of_node, "mediatek,cd-poll"))
mmc->caps |= MMC_CAP_NEEDS_POLL;
 
/* MMC core transfer sizes tunable parameters */
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/34] staging: mt7621-mmc: Remove global initialise to 0

2018-04-02 Thread Christian Lütke-Stetzkamp
Fix checkpatch error: GLOBAL_INITIALISERS

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/dbg.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/dbg.c b/drivers/staging/mt7621-mmc/dbg.c
index 60c704d6adc2..1e4c95b659da 100644
--- a/drivers/staging/mt7621-mmc/dbg.c
+++ b/drivers/staging/mt7621-mmc/dbg.c
@@ -76,9 +76,9 @@ enum msdc_mode drv_mode[4] = {
 #if defined(MT6575_SD_DEBUG)
 /* for driver profile */
 #define TICKS_ONE_MS  (13000)
-u32 gpt_enable = 0;
-u32 sdio_pro_enable = 0;   /* make sure gpt is enabled */
-u32 sdio_pro_time = 0; /* no more than 30s */
+u32 gpt_enable;
+u32 sdio_pro_enable;   /* make sure gpt is enabled */
+u32 sdio_pro_time; /* no more than 30s */
 struct sdio_profile sdio_perfomance = {0};
 
 #if 0 /* --- chhung */
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/34] staging: mt7621-mmc: Remove whitespace errors in sd.c

2018-04-02 Thread Christian Lütke-Stetzkamp
The whitespace errors in the file sd.c are fixed by using the
cleanfile script. Indentations with whitespaces are not changed
in this patch.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 1142 +++
 1 file changed, 571 insertions(+), 571 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index a1d0173eba56..a5b20fdb459a 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -130,7 +130,7 @@
 
 #if 0 /* --- by chhung */
 #define MSDC_CLKSRC_REG (0xf10C)
-#define PDN_REG   (0xF110) 
+#define PDN_REG   (0xF110)
 #endif /* end of --- */
 
 #define DEFAULT_DEBOUNCE(8)   /* 8 cycles */
@@ -148,11 +148,11 @@
 #define MAX_HW_SGMTS(MAX_BD_NUM)
 #define MAX_PHY_SGMTS   (MAX_BD_NUM)
 #define MAX_SGMT_SZ (MAX_DMA_CNT)
-#define MAX_REQ_SZ  (MAX_SGMT_SZ * 8)  
+#define MAX_REQ_SZ  (MAX_SGMT_SZ * 8)
 
 #ifdef MT6575_SD_DEBUG
 static struct msdc_regs *msdc_reg[HOST_MAX_NUM];
-#endif 
+#endif
 
 static int mtk_sw_poll;
 
@@ -167,7 +167,7 @@ static int cd_active_low = 1;
 struct msdc_host *msdc_6575_host[] = {NULL,NULL,NULL,NULL};
 #if 0 /* --- by chhung */
 /* gate means clock power down */
-static int g_clk_gate = 0; 
+static int g_clk_gate = 0;
 #define msdc_gate_clock(id) \
 do { \
 g_clk_gate &= ~(1 << ((id) + PERI_MSDC0_PDN)); \
@@ -178,10 +178,10 @@ static int g_clk_gate = 0;
 g_clk_gate |= 1 << ((id) + PERI_MSDC0_PDN); \
 } while(0)
 
-// do we need sync object or not 
+// do we need sync object or not
 void msdc_clk_status(int * status)
 {
-*status = g_clk_gate;  
+*status = g_clk_gate;
 }
 #endif /* end of --- */
 
@@ -240,7 +240,7 @@ static int msdc_rsp[] = {
 ((gpd_t*)gpd)->arg= arg; \
 ((gpd_t*)gpd)->blknum = blknum; \
 }while(0)
-
+
 #define msdc_init_bd(bd, blkpad, dwpad, dptr, dlen) \
 do { \
 BUG_ON(dlen > 0xUL); \
@@ -255,7 +255,7 @@ static int msdc_rsp[] = {
 #define msdc_fifo_write32(v)   sdr_write32(MSDC_TXDATA, (v))
 #define msdc_fifo_write8(v)sdr_write8(MSDC_TXDATA, (v))
 #define msdc_fifo_read32()   sdr_read32(MSDC_RXDATA)
-#define msdc_fifo_read8()sdr_read8(MSDC_RXDATA)
+#define msdc_fifo_read8()sdr_read8(MSDC_RXDATA)
 
 
 #define msdc_dma_on()sdr_clr_bits(MSDC_CFG, MSDC_CFG_PIO)
@@ -308,7 +308,7 @@ static int msdc_rsp[] = {
 val = sdr_read32(MSDC_INTEN); \
 sdr_clr_bits(MSDC_INTEN, val); \
 } while(0)
-   
+
 #define msdc_irq_restore(val) \
 do { \
 sdr_set_bits(MSDC_INTEN, val); \
@@ -323,7 +323,7 @@ static u32 hclks[] = {5000}; /* +/- by chhung */
 
 //
 // the power for msdc host controller: global
-//always keep the VMC on. 
+//always keep the VMC on.
 //
 #define msdc_vcore_on(host) \
 do { \
@@ -337,17 +337,17 @@ static u32 hclks[] = {5000}; /* +/- by chhung */
 } while (0)
 
 //
-// the vdd output for card: global 
-//   always keep the VMCH on. 
-// 
+// the vdd output for card: global
+//   always keep the VMCH on.
+//
 #define msdc_vdd_on(host) \
 do { \
 (void)hwPowerOn(MT65XX_POWER_LDO_VMCH, VOL_3300, "SD"); \
-} while (0)   
+} while (0)
 #define msdc_vdd_off(host) \
 do { \
 (void)hwPowerDown(MT65XX_POWER_LDO_VMCH, "SD"); \
-} while (0)  
+} while (0)
 
 #define sdc_is_busy()  (sdr_read32(SDC_STS) & SDC_STS_SDCBUSY)
 #define sdc_is_cmd_busy()  (sdr_read32(SDC_STS) & SDC_STS_CMDBUSY)
@@ -369,11 +369,11 @@ static u32 hclks[] = {5000}; /* +/- by chhung */
 #define PHYSADDR(a) ((a) & 0x1fff)
 #endif
 /* end of +++ */
-static unsigned int msdc_do_command(struct msdc_host   *host, 
+static unsigned int msdc_do_command(struct msdc_host   *host,
   struct mmc_command *cmd,
   int tune,
-  unsigned long   timeout);  
- 
+  unsigned long   timeout);
+
 static int msdc_tune_cmdrsp(struct msdc_host*host,struct mmc_command *cmd);
 
 #ifdef MT6575_SD_DEBUG
@@ -444,7 +444,7 @@ static void msdc_dump_card_status(struct msdc_host *host, 
u32 status)
 N_MSG(RSP, "[CARD_STATUS] Switch error");
 if (status & R1_APP_CMD)
 N_MSG(RSP, "[CARD_STATUS] App Command");
-
+
 N_MSG(RSP, "[CARD_STATUS] '%s' State", state[R1_CURRENT_STATE(status)]);
 }
 
@@ -486,9 +486,9 @@ static void msdc_dump_rca_resp(struct msdc_host *host, u32 
resp)
  (((resp >> 14) & 0x1) << 22) |
  (((resp >> 13) & 0x1) << 19) |

[PATCH 31/34] staging: mt7621-mmc: Remove dead codepath from probe function

2018-04-02 Thread Christian Lütke-Stetzkamp
The probe function contains lots of code, that is never used, because
the fields it checks for in the msdc_hw structure are never
initialized. Removing them should be safe.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 20 
 1 file changed, 20 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index acee35282678..86b2f4e0833c 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -153,7 +153,6 @@
 static struct msdc_regs *msdc_reg[HOST_MAX_NUM];
 #endif
 
-
 static int cd_active_low = 1;
 
 //=
@@ -2807,25 +2806,6 @@ static int msdc_drv_probe(struct platform_device *pdev)
goto release;
// mt65xx_irq_unmask(irq); /* --- by chhung */
 
-   if (hw->flags & MSDC_CD_PIN_EN) { /* not set for sdio */
-   if (hw->request_cd_eirq) { /* not set for MT6575 */
-   hw->request_cd_eirq(msdc_eirq_cd, (void *)host); /* 
msdc_eirq_cd will not be used! */
-   }
-   }
-
-   if (hw->request_sdio_eirq) /* set to combo_sdio_request_eirq() for WIFI 
*/
-   hw->request_sdio_eirq(msdc_eirq_sdio, (void *)host); /* 
msdc_eirq_sdio() will be called when EIRQ */
-
-   if (hw->register_pm) {/* yes for sdio */
-#ifdef CONFIG_PM
-   hw->register_pm(msdc_pm, (void *)host);  /* 
combo_sdio_register_pm() */
-#endif
-   if (hw->flags & MSDC_SYS_SUSPEND) { /* will not set for WIFI */
-   ERR_MSG("MSDC_SYS_SUSPEND and register_pm both set");
-   }
-   //mmc->pm_flags |= MMC_PM_IGNORE_PM_NOTIFY; /* pm not 
controlled by system but by client. */ /* --- by chhung */
-   }
-
platform_set_drvdata(pdev, mmc);
 
ret = mmc_add_host(mmc);
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/34] staging: mt7621-mmc: First cleanups

2018-04-02 Thread Christian Lütke-Stetzkamp
This patch series does the first cleanups in this driver. At some
points I already tried to get the code of this driver as near as
possible to the mk-sd driver in mainline.

Christian Lütke-Stetzkamp (34):
  staging: mt7621-mmc: Remove whitespace errors in board.h
  staging: mt7621-mmc: Remove whitespace errors in dbg.c
  staging: mt7621-mmc: Remove whitespace errors in dbg.h
  staging: mt7621-mmc: Remove whitespace errors in mt6575_sd.h
  staging: mt7621-mmc: Remove whitespace errors in sd.c
  staging: mt7621-mmc: Fix indent for dbg.c
  staging: mt7621-mmc: Fix indent for board.h
  staging: mt7621-mmc: Fix indent for dbg.h
  staging: mt7621-mmc: Fix indent for mt6575_sd.h
  staging: mt7621-mmc: Fix indent for sd.c
  staging: mt7621-mmc: Fix spacing
  staging: mt7621-mmc: Fix Pointer Location
  staging: mt7621-mmc: Remove unnecessary typedefs
  staging: mt7621-mmc: Fix trailing statements
  staging: mt7621-mmc: Remove global initialise to 0
  staging: mt7621-mmc: Fix style of braces
  staging: mt7621-mmc: Remove redundant driver owner assignment
  staging: mt7621-mmc: Replace seq_printf with seq_puts where possible
  staging: mt7621-mmc: Remove code guarded by nonexistent config option
  staging: mt7621-mmc: Remove code for different soc types
  staging: mt7621-mmc: Remove unused datastructures
  staging: mt7621-mmc: Cleanup function mt_msdc_init
  staging: mt7621-mmc: Refactor suspend, resume
  staging: mt7621-mmc: Fix memory leek in case of error in probe
  staging: mt7621-mmc: Remove code checking for old kernel versions
  staging: mt7621-mmc: Fix unmatched release_mem_regin
  staging: mt7621-mmc: Fix bug on dma_alloc_coherent fail
  staging: mt7621-mmc: Remove unnecessary setting of dev.platform_data
  staging: mt7621-mmc: Remove unnecessary field from struct msdc_hw
  staging: mt7621-mmc: Fix different caps for different devices
  staging: mt7621-mmc: Remove dead codepath from probe function
  staging: mt7621-mmc: Fix dma_alloc_coherent should get device as first
param
  staging: mt7621-mmc: Fix requesting of irq
  staging: mt7621-mmc: Remove duplicate defines

 drivers/staging/mt7621-mmc/board.h |   75 +-
 drivers/staging/mt7621-mmc/dbg.c   |  389 +--
 drivers/staging/mt7621-mmc/dbg.h   |   98 +-
 drivers/staging/mt7621-mmc/mt6575_sd.h | 1104 
 drivers/staging/mt7621-mmc/sd.c| 4682 
 5 files changed, 3140 insertions(+), 3208 deletions(-)

-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 29/34] staging: mt7621-mmc: Remove unnecessary field from struct msdc_hw

2018-04-02 Thread Christian Lütke-Stetzkamp
Remove the unnecessary field data_pins from msdc_hw, later this
information should be taken from the device tree.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/board.h |  1 -
 drivers/staging/mt7621-mmc/sd.c| 10 --
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/board.h 
b/drivers/staging/mt7621-mmc/board.h
index b9cf7b875cfa..aa62a7243c80 100644
--- a/drivers/staging/mt7621-mmc/board.h
+++ b/drivers/staging/mt7621-mmc/board.h
@@ -81,7 +81,6 @@ struct msdc_hw {
unsigned char  cmd_drv;  /* command pad driving */
unsigned char  dat_drv;  /* data pad driving */
unsigned long  flags;/* hardware capability flags */
-   unsigned long  data_pins;/* data pins */
unsigned long  data_offset;  /* data address offset */
 
/* config gpio pull mode */
diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 81c0efdc5449..e7a4adf53e1d 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -192,7 +192,6 @@ struct msdc_hw msdc0_hw = {
.clk_drv= 4,
.cmd_drv= 4,
.dat_drv= 4,
-   .data_pins  = 4,
.data_offset= 0,
.flags  = MSDC_SYS_SUSPEND | MSDC_CD_PIN_EN | MSDC_REMOVABLE | 
MSDC_HIGHSPEED,
 // .flags  = MSDC_SYS_SUSPEND | MSDC_WP_PIN_EN | MSDC_CD_PIN_EN | 
MSDC_REMOVABLE,
@@ -2732,11 +2731,10 @@ static int msdc_drv_probe(struct platform_device *pdev)
   For sdio   : MSDC_EXT_SDIO_IRQ | MSDC_HIGHSPEED */
if (hw->flags & MSDC_HIGHSPEED)
mmc->caps   = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED;
-   if (hw->data_pins == 4) { /* current data_pins are all 4*/
-   mmc->caps  |= MMC_CAP_4_BIT_DATA;
-   } else if (hw->data_pins == 8) {
-   mmc->caps  |= MMC_CAP_8_BIT_DATA;
-   }
+
+   //TODO: read this as bus-width from dt (via mmc_of_parse)
+   mmc->caps  |= MMC_CAP_4_BIT_DATA;
+
if ((hw->flags & MSDC_SDIO_IRQ) || (hw->flags & MSDC_EXT_SDIO_IRQ))
mmc->caps |= MMC_CAP_SDIO_IRQ;  /* yes for sdio */
 
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/34] staging: mt7621-mmc: Remove whitespace errors in mt6575_sd.h

2018-04-02 Thread Christian Lütke-Stetzkamp
The whitespace errors in the file mt6575_sd.h are fixed by using the
cleanfile script. Indentations with whitespaces are not changed
in this patch.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/mt6575_sd.h | 49 +-
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h 
b/drivers/staging/mt7621-mmc/mt6575_sd.h
index e90c4f1d1df7..251b0b019084 100644
--- a/drivers/staging/mt7621-mmc/mt6575_sd.h
+++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
@@ -301,7 +301,7 @@ enum {
 #define SDC_CFG_INSWKUP (0x1  << 1) /* RW */
 #define SDC_CFG_BUSWIDTH(0x3  << 16)/* RW */
 #define SDC_CFG_SDIO(0x1  << 19)/* RW */
-#define SDC_CFG_SDIOIDE (0x1  << 20)/* RW */  
+#define SDC_CFG_SDIOIDE (0x1  << 20)/* RW */
 #define SDC_CFG_INTATGAP(0x1  << 21)/* RW */
 #define SDC_CFG_DTOC(0xffUL << 24)  /* RW */
 
@@ -493,7 +493,7 @@ typedef struct {
 u32 ckstb:1;
 u32 ckdiv:8;
 u32 ckmod:2;
-u32 pad:14;
+u32 pad:14;
 } msdc_cfg_reg;
 typedef struct {
 u32 sdr104cksel:1;
@@ -597,7 +597,7 @@ typedef struct {
 u32 dtype:2;
 u32 rw:1;
 u32 stop:1;
-u32 goirq:1;
+u32 goirq:1;
 u32 blklen:12;
 u32 atocmd:2;
 u32 volswth:1;
@@ -616,16 +616,16 @@ typedef struct {
 u32 val;
 } sdc_resp0_reg;
 typedef struct {
-u32 val;   
+u32 val;
 } sdc_resp1_reg;
 typedef struct {
-u32 val;   
+u32 val;
 } sdc_resp2_reg;
 typedef struct {
-u32 val;   
+u32 val;
 } sdc_resp3_reg;
 typedef struct {
-u32 num;   
+u32 num;
 } sdc_blknum_reg;
 typedef struct {
 u32 sts;
@@ -717,7 +717,7 @@ typedef struct {
 u32 rsv1:1;
 u32 clksr:1;
 u32 rsv2:7;
-u32 clkpd:1;
+u32 clkpd:1;
 u32 clkpu:1;
 u32 clksmt:1;
 u32 clkies:1;
@@ -726,12 +726,12 @@ typedef struct {
 } msdc_pad_ctl0_reg;
 typedef struct {
 u32 cmddrvn:3;
-u32 rsv0:1;
+u32 rsv0:1;
 u32 cmddrvp:3;
 u32 rsv1:1;
 u32 cmdsr:1;
 u32 rsv2:7;
-u32 cmdpd:1;
+u32 cmdpd:1;
 u32 cmdpu:1;
 u32 cmdsmt:1;
 u32 cmdies:1;
@@ -745,7 +745,7 @@ typedef struct {
 u32 rsv1:1;
 u32 datsr:1;
 u32 rsv2:7;
-u32 datpd:1;
+u32 datpd:1;
 u32 datpu:1;
 u32 datsmt:1;
 u32 daties:1;
@@ -766,7 +766,7 @@ typedef struct {
 u32 dat2:5;
 u32 rsv2:3;
 u32 dat3:5;
-u32 rsv3:3;
+u32 rsv3:3;
 } msdc_dat_rddly0;
 typedef struct {
 u32 dat4:5;
@@ -843,7 +843,7 @@ struct msdc_regs {
 msdc_dat_rddly0 dat_rddly0;/* base+0xf0h */
 msdc_dat_rddly1 dat_rddly1;/* base+0xf4h */
 msdc_hw_dbg_reg hw_dbg;/* base+0xf8h */
-u32 rsv7[1];   
+u32 rsv7[1];
 msdc_version_regversion;   /* base+0x100h */
 msdc_eco_ver_regeco_ver;   /* base+0x104h */
 };
@@ -891,17 +891,17 @@ struct msdc_host
 struct mmc_host *mmc;   /* mmc structure */
 struct mmc_command  *cmd;
 struct mmc_data *data;
-struct mmc_request  *mrq; 
+struct mmc_request  *mrq;
 int cmd_rsp;
 int cmd_rsp_done;
 int cmd_r1b_done;
 
-int error; 
+int error;
 spinlock_t  lock;   /* mutex */
-struct semaphoresem; 
+struct semaphoresem;
 
 u32 blksz;  /* host block size */
-u32 base;   /* host base address */
+u32 base;   /* host base address */
 int id; /* host id */
 int pwr_ref;/* core power reference count 
*/
 
@@ -922,9 +922,9 @@ struct msdc_host
 
 struct tasklet_struct   card_tasklet;
 #if 0
-struct work_struct card_workqueue;
+struct work_struct card_workqueue;
 #else
-struct delayed_workcard_delaywork;
+struct delayed_workcard_delaywork;
 #endif
 
 struct completion   cmd_done;
@@ -932,17 +932,17 @@ struct msdc_host
 struct pm_message   pm_state;
 
 u32 mclk;   /* mmc subsystem clock */
-u32 hclk;   /* host clock speed */ 
+u32 hclk;   /* host clock speed */
 u32 sclk;   /* SD/MS clock speed */
 u8  core_clkon; /* Host core clock on ? */
 u8  card_clkon; /* Card clock on ? */
-u8  core_power; /* core power */
+u8  core_p

[PATCH 09/34] staging: mt7621-mmc: Fix indent for mt6575_sd.h

2018-04-02 Thread Christian Lütke-Stetzkamp
This fixes the indentaions in the file mt7621_sd.h

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/mt6575_sd.h | 820 -
 1 file changed, 410 insertions(+), 410 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h 
b/drivers/staging/mt7621-mmc/mt6575_sd.h
index 251b0b019084..78a4b6754a60 100644
--- a/drivers/staging/mt7621-mmc/mt6575_sd.h
+++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
@@ -448,34 +448,34 @@ enum {
 /* Descriptor Structure */
 /*--*/
 typedef struct {
-u32  hwo:1; /* could be changed by hw */
-u32  bdp:1;
-u32  rsv0:6;
-u32  chksum:8;
-u32  intr:1;
-u32  rsv1:15;
-void *next;
-void *ptr;
-u32  buflen:16;
-u32  extlen:8;
-u32  rsv2:8;
-u32  arg;
-u32  blknum;
-u32  cmd;
+   u32  hwo:1; /* could be changed by hw */
+   u32  bdp:1;
+   u32  rsv0:6;
+   u32  chksum:8;
+   u32  intr:1;
+   u32  rsv1:15;
+   void *next;
+   void *ptr;
+   u32  buflen:16;
+   u32  extlen:8;
+   u32  rsv2:8;
+   u32  arg;
+   u32  blknum;
+   u32  cmd;
 } gpd_t;
 
 typedef struct {
-u32  eol:1;
-u32  rsv0:7;
-u32  chksum:8;
-u32  rsv1:1;
-u32  blkpad:1;
-u32  dwpad:1;
-u32  rsv2:13;
-void *next;
-void *ptr;
-u32  buflen:16;
-u32  rsv3:16;
+   u32  eol:1;
+   u32  rsv0:7;
+   u32  chksum:8;
+   u32  rsv1:1;
+   u32  blkpad:1;
+   u32  dwpad:1;
+   u32  rsv2:13;
+   void *next;
+   void *ptr;
+   u32  buflen:16;
+   u32  rsv3:16;
 } bd_t;
 
 /*--*/
@@ -483,376 +483,376 @@ typedef struct {
 /*--*/
 
 typedef struct {
-u32 msdc:1;
-u32 ckpwn:1;
-u32 rst:1;
-u32 pio:1;
-u32 ckdrven:1;
-u32 start18v:1;
-u32 pass18v:1;
-u32 ckstb:1;
-u32 ckdiv:8;
-u32 ckmod:2;
-u32 pad:14;
+   u32 msdc:1;
+   u32 ckpwn:1;
+   u32 rst:1;
+   u32 pio:1;
+   u32 ckdrven:1;
+   u32 start18v:1;
+   u32 pass18v:1;
+   u32 ckstb:1;
+   u32 ckdiv:8;
+   u32 ckmod:2;
+   u32 pad:14;
 } msdc_cfg_reg;
 typedef struct {
-u32 sdr104cksel:1;
-u32 rsmpl:1;
-u32 dsmpl:1;
-u32 ddlysel:1;
-u32 ddr50ckd:1;
-u32 dsplsel:1;
-u32 pad1:10;
-u32 d0spl:1;
-u32 d1spl:1;
-u32 d2spl:1;
-u32 d3spl:1;
-u32 d4spl:1;
-u32 d5spl:1;
-u32 d6spl:1;
-u32 d7spl:1;
-u32 riscsz:1;
-u32 pad2:7;
+   u32 sdr104cksel:1;
+   u32 rsmpl:1;
+   u32 dsmpl:1;
+   u32 ddlysel:1;
+   u32 ddr50ckd:1;
+   u32 dsplsel:1;
+   u32 pad1:10;
+   u32 d0spl:1;
+   u32 d1spl:1;
+   u32 d2spl:1;
+   u32 d3spl:1;
+   u32 d4spl:1;
+   u32 d5spl:1;
+   u32 d6spl:1;
+   u32 d7spl:1;
+   u32 riscsz:1;
+   u32 pad2:7;
 } msdc_iocon_reg;
 typedef struct {
-u32 cden:1;
-u32 cdsts:1;
-u32 pad1:10;
-u32 cddebounce:4;
-u32 dat:8;
-u32 cmd:1;
-u32 pad2:6;
-u32 wp:1;
+   u32 cden:1;
+   u32 cdsts:1;
+   u32 pad1:10;
+   u32 cddebounce:4;
+   u32 dat:8;
+   u32 cmd:1;
+   u32 pad2:6;
+   u32 wp:1;
 } msdc_ps_reg;
 typedef struct {
-u32 mmcirq:1;
-u32 cdsc:1;
-u32 pad1:1;
-u32 atocmdrdy:1;
-u32 atocmdtmo:1;
-u32 atocmdcrc:1;
-u32 dmaqempty:1;
-u32 sdioirq:1;
-u32 cmdrdy:1;
-u32 cmdtmo:1;
-u32 rspcrc:1;
-u32 csta:1;
-u32 xfercomp:1;
-u32 dxferdone:1;
-u32 dattmo:1;
-u32 datcrc:1;
-u32 atocmd19done:1;
-u32 pad2:15;
+   u32 mmcirq:1;
+   u32 cdsc:1;
+   u32 pad1:1;
+   u32 atocmdrdy:1;
+   u32 atocmdtmo:1;
+   u32 atocmdcrc:1;
+   u32 dmaqempty:1;
+   u32 sdioirq:1;
+   u32 cmdrdy:1;
+   u32 cmdtmo:1;
+   u32 rspcrc:1;
+   u32 csta:1;
+   u32 xfercomp:1;
+   u32 dxferdone:1;
+   u32 dattmo:1;
+   u32 datcrc:1;
+   u32 atocmd19done:1;
+   u32 pad2:15;
 } msdc_int_reg;
 typedef struct {
-u32 mmcirq:1;
-u32 cdsc:1;
-u32 pad1:1;
-u32 atocmdrdy:1;
-u32 atocmdtmo:1;
-u32 atocmdcrc:1;
-u32 dmaqempty:1;
-u32 sdioirq:1;
-u32 cmdrdy:1;
-u32 cmdtmo:1;
-u32 rspcrc:1;
-u32 csta:1;
-u32 xfercomp:1;
-u32 dxferdone:1;
-u32 dattmo:1;
-u32 datcrc:1;
-u32 atocmd19done:1;
-u32 pad2:15;
+   u32 mmcirq:1;
+   u32 cdsc:1;
+   u32 pad1:1;
+   u32 atocmdrdy:1;
+   u32 atocmdtmo:1;
+   u32 atocmdcrc:1;
+   u32 dmaqempty:1;
+   u32 sdioirq:1;
+   u32 cmdrdy:1;
+   u32 cmdtmo:1;
+   u32 rspcrc:1;
+   u32 csta:1;
+   u32 xfercomp:1;
+   u32 dxferdone:1;
+   u32 dattmo:

[PATCH 03/34] staging: mt7621-mmc: Remove whitespace errors in dbg.h

2018-04-02 Thread Christian Lütke-Stetzkamp
The whitespace errors in the file dbg.h are fixed by using the
cleanfile script. Indentations with whitespaces are not changed
in this patch.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/dbg.h | 38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/dbg.h b/drivers/staging/mt7621-mmc/dbg.h
index e58c4312933e..00c7b07c78b4 100644
--- a/drivers/staging/mt7621-mmc/dbg.h
+++ b/drivers/staging/mt7621-mmc/dbg.h
@@ -40,9 +40,9 @@ extern u32 sdio_pro_enable;
 /* for a type command, e.g. CMD53, 2 blocks */
 struct cmd_profile {
 u32 max_tc;/* Max tick count */
-u32 min_tc;
+u32 min_tc;
 u32 tot_tc;/* total tick count */
-u32 tot_bytes;  
+u32 tot_bytes;
 u32 count; /* the counts of the command */
 };
 
@@ -51,27 +51,27 @@ struct sdio_profile {
 u32 total_tc; /* total tick count of CMD52 and CMD53 */
 u32 total_tx_bytes;   /* total bytes of CMD53 Tx */
 u32 total_rx_bytes;   /* total bytes of CMD53 Rx */
-
+
 /*CMD52*/
-struct cmd_profile cmd52_tx; 
-struct cmd_profile cmd52_rx; 
+struct cmd_profile cmd52_tx;
+struct cmd_profile cmd52_rx;
 
 /*CMD53 in byte unit */
-struct cmd_profile cmd53_tx_byte[512]; 
-struct cmd_profile cmd53_rx_byte[512]; 
-
+struct cmd_profile cmd53_tx_byte[512];
+struct cmd_profile cmd53_rx_byte[512];
+
 /*CMD53 in block unit */
-struct cmd_profile cmd53_tx_blk[100]; 
-struct cmd_profile cmd53_rx_blk[100]; 
+struct cmd_profile cmd53_tx_blk[100];
+struct cmd_profile cmd53_rx_blk[100];
 };
 
 //==
 typedef enum {
-SD_TOOL_ZONE = 0, 
-SD_TOOL_DMA_SIZE  = 1, 
+SD_TOOL_ZONE = 0,
+SD_TOOL_DMA_SIZE  = 1,
 SD_TOOL_PM_ENABLE = 2,
-SD_TOOL_SDIO_PROFILE = 3, 
-} msdc_dbg;
+SD_TOOL_SDIO_PROFILE = 3,
+} msdc_dbg;
 
 typedef enum {
 MODE_PIO = 0,
@@ -123,12 +123,12 @@ do {\
 do { \
 printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
 host->id,  ##args , __FUNCTION__, __LINE__, current->comm, 
current->pid); \
-} while(0); 
+} while(0);
 
 #if 1
-//defined CONFIG_MTK_MMC_CD_POLL
+//defined CONFIG_MTK_MMC_CD_POLL
 #define INIT_MSG(fmt, args...)
-#define IRQ_MSG(fmt, args...) 
+#define IRQ_MSG(fmt, args...)
 #else
 #define INIT_MSG(fmt, args...) \
 do { \
@@ -144,13 +144,13 @@ do { \
 } while(0);
 #endif
 
-int msdc_debug_proc_init(void); 
+int msdc_debug_proc_init(void);
 
 #if 0 /* --- chhung */
 void msdc_init_gpt(void);
 extern void GPT_GetCounter64(UINT32 *cntL32, UINT32 *cntH32);
 #endif /* end of --- */
 u32 msdc_time_calc(u32 old_L32, u32 old_H32, u32 new_L32, u32 new_H32);
-void msdc_performance(u32 opcode, u32 sizes, u32 bRx, u32 ticks);   
+void msdc_performance(u32 opcode, u32 sizes, u32 bRx, u32 ticks);
 
 #endif
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 33/34] staging: mt7621-mmc: Fix requesting of irq

2018-04-02 Thread Christian Lütke-Stetzkamp
The request of the irq line is not correctly handled by the current
code, platform_get_irq may fail and if the irq is requested via
devm_request_irq, its release is automatically done.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 29 +
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index e709e4d47965..95c439069c2b 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -2696,7 +2696,7 @@ static int msdc_drv_probe(struct platform_device *pdev)
struct mmc_host *mmc;
struct msdc_host *host;
struct msdc_hw *hw;
-   int ret, irq;
+   int ret;
 
hw = &msdc0_hw;
 
@@ -2708,10 +2708,6 @@ static int msdc_drv_probe(struct platform_device *pdev)
if (!mmc)
return -ENOMEM;
 
-   irq  = platform_get_irq(pdev, 0);
-
-   //BUG_ON((!hw) || (!mem) || (irq < 0)); /* --- by chhung */
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0)
base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(base)) {
@@ -2756,7 +2752,13 @@ static int msdc_drv_probe(struct platform_device *pdev)
if (host->id < 0 || host->id >= 4)
host->id = 0;
host->error = 0;
-   host->irq   = irq;
+
+   host->irq   = platform_get_irq(pdev, 0);
+   if (host->irq < 0) {
+   ret = -EINVAL;
+   goto host_free;
+   }
+
host->base  = (unsigned long)base;
host->mclk  = 0;   /* mclk: the request clock of 
mmc sub-system */
host->hclk  = hclks[hw->clk_src];  /* hclk: clock of clock source 
to msdc controller */
@@ -2801,20 +2803,18 @@ static int msdc_drv_probe(struct platform_device *pdev)
spin_lock_init(&host->lock);
msdc_init_hw(host);
 
-   if (ralink_soc == MT762X_SOC_MT7621AT)
-   ret = request_irq((unsigned int)irq, msdc_irq, 0, 
dev_name(&pdev->dev), host);
-   else
-   ret = request_irq((unsigned int)irq, msdc_irq, 
IRQF_TRIGGER_LOW, dev_name(&pdev->dev), host);
-
+   //TODO check weather flags 0 is correct, the mtk-sd driver uses
+   //IRQF_TRIGGER_LOW | IRQF_ONESHOT for flags
+   ret = devm_request_irq(&pdev->dev, host->irq, msdc_irq, 0, pdev->name,
+  host);
if (ret)
goto release;
-   // mt65xx_irq_unmask(irq); /* --- by chhung */
 
platform_set_drvdata(pdev, mmc);
 
ret = mmc_add_host(mmc);
if (ret)
-   goto free_irq;
+   goto release;
 
/* Config card detection pin and enable interrupts */
if (hw->flags & MSDC_CD_PIN_EN) {  /* set for card */
@@ -2825,8 +2825,6 @@ static int msdc_drv_probe(struct platform_device *pdev)
 
return 0;
 
-free_irq:
-   free_irq(irq, host);
 release:
platform_set_drvdata(pdev, NULL);
msdc_deinit_hw(host);
@@ -2873,7 +2871,6 @@ static int msdc_drv_remove(struct platform_device *pdev)
 #else
cancel_delayed_work_sync(&host->card_delaywork);
 #endif
-   free_irq(host->irq, host);
 
dma_free_coherent(&pdev->dev, MAX_GPD_NUM * sizeof(struct gpt),
  host->dma.gpd, host->dma.gpd_addr);
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 19/34] staging: mt7621-mmc: Remove code guarded by nonexistent config option

2018-04-02 Thread Christian Lütke-Stetzkamp
Remove a piece of code that is guarded by a config option, that is
nonexistent, the function it calls is also nonexistent.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index ed89ec9733a4..e28635ab556a 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -2985,13 +2985,6 @@ static int __init mt_msdc_init(void)
 /* +++ by chhung */
u32 reg;
 
-#if defined(CONFIG_MTD_ANY_RALINK)
-   extern int ra_check_flash_type(void);
-   if (ra_check_flash_type() == 2) { /* NAND */
-   printk("%s: ! SDXC Module Initialize Fail !", __func__);
-   return 0;
-   }
-#endif
printk("MTK MSDC device init.\n");
mtk_sd_device.dev.platform_data = &msdc0_hw;
if (ralink_soc == MT762X_SOC_MT7620A || ralink_soc == 
MT762X_SOC_MT7621AT) {
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 18/34] staging: mt7621-mmc: Replace seq_printf with seq_puts where possible

2018-04-02 Thread Christian Lütke-Stetzkamp
Replace seq_printf with seq_puts when the string is const.
Fix checkpatch warning: PREFER_SEQ_PUTS

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/dbg.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/dbg.c b/drivers/staging/mt7621-mmc/dbg.c
index 70f1abe7012d..abf92a84a417 100644
--- a/drivers/staging/mt7621-mmc/dbg.c
+++ b/drivers/staging/mt7621-mmc/dbg.c
@@ -226,27 +226,27 @@ void msdc_performance(u32 opcode, u32 sizes, u32 bRx, u32 
ticks)
 //== driver proc interface ===
 static int msdc_debug_proc_read(struct seq_file *s, void *p)
 {
-   seq_printf(s, "\n=\n");
-   seq_printf(s, "Index<0> + Id + Zone\n");
-   seq_printf(s, "-> PWR<9> WRN<8> | FIO<7> OPS<6> FUN<5> CFG<4> | INT<3> 
RSP<2> CMD<1> DMA<0>\n");
-   seq_printf(s, "-> echo 0 3 0x3ff >msdc_bebug -> host[3] debug zone set 
to 0x3ff\n");
+   seq_puts(s, "\n=\n");
+   seq_puts(s, "Index<0> + Id + Zone\n");
+   seq_puts(s, "-> PWR<9> WRN<8> | FIO<7> OPS<6> FUN<5> CFG<4> | INT<3> 
RSP<2> CMD<1> DMA<0>\n");
+   seq_puts(s, "-> echo 0 3 0x3ff >msdc_bebug -> host[3] debug zone set to 
0x3ff\n");
seq_printf(s, "-> MSDC[0] Zone: 0x%.8x\n", sd_debug_zone[0]);
seq_printf(s, "-> MSDC[1] Zone: 0x%.8x\n", sd_debug_zone[1]);
seq_printf(s, "-> MSDC[2] Zone: 0x%.8x\n", sd_debug_zone[2]);
seq_printf(s, "-> MSDC[3] Zone: 0x%.8x\n", sd_debug_zone[3]);
 
-   seq_printf(s, "Index<1> + ID:4|Mode:4 + DMA_SIZE\n");
-   seq_printf(s, "-> 0)PIO 1)DMA 2)SIZE\n");
-   seq_printf(s, "-> echo 1 22 0x200 >msdc_bebug -> host[2] size mode, dma 
when >= 512\n");
+   seq_puts(s, "Index<1> + ID:4|Mode:4 + DMA_SIZE\n");
+   seq_puts(s, "-> 0)PIO 1)DMA 2)SIZE\n");
+   seq_puts(s, "-> echo 1 22 0x200 >msdc_bebug -> host[2] size mode, dma 
when >= 512\n");
seq_printf(s, "-> MSDC[0] mode<%d> size<%d>\n", drv_mode[0], 
dma_size[0]);
seq_printf(s, "-> MSDC[1] mode<%d> size<%d>\n", drv_mode[1], 
dma_size[1]);
seq_printf(s, "-> MSDC[2] mode<%d> size<%d>\n", drv_mode[2], 
dma_size[2]);
seq_printf(s, "-> MSDC[3] mode<%d> size<%d>\n", drv_mode[3], 
dma_size[3]);
 
-   seq_printf(s, "Index<3> + SDIO_PROFILE + TIME\n");
-   seq_printf(s, "-> echo 3 1 0x1E >msdc_bebug -> enable sdio_profile, 
30s\n");
+   seq_puts(s, "Index<3> + SDIO_PROFILE + TIME\n");
+   seq_puts(s, "-> echo 3 1 0x1E >msdc_bebug -> enable sdio_profile, 
30s\n");
seq_printf(s, "-> SDIO_PROFILE<%d> TIME<%ds>\n", sdio_pro_enable, 
sdio_pro_time);
-   seq_printf(s, "=\n\n");
+   seq_puts(s, "=\n\n");
 
return 0;
 }
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/34] staging: mt7621-mmc: Fix indent for dbg.h

2018-04-02 Thread Christian Lütke-Stetzkamp
This fixes the indentaions in the file dbg.h

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/dbg.h | 60 
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/dbg.h b/drivers/staging/mt7621-mmc/dbg.h
index 00c7b07c78b4..e7bc544823ed 100644
--- a/drivers/staging/mt7621-mmc/dbg.h
+++ b/drivers/staging/mt7621-mmc/dbg.h
@@ -39,44 +39,44 @@
 extern u32 sdio_pro_enable;
 /* for a type command, e.g. CMD53, 2 blocks */
 struct cmd_profile {
-u32 max_tc;/* Max tick count */
-u32 min_tc;
-u32 tot_tc;/* total tick count */
-u32 tot_bytes;
-u32 count; /* the counts of the command */
+   u32 max_tc;/* Max tick count */
+   u32 min_tc;
+   u32 tot_tc;/* total tick count */
+   u32 tot_bytes;
+   u32 count; /* the counts of the command */
 };
 
 /* dump when total_tc and total_bytes */
 struct sdio_profile {
-u32 total_tc; /* total tick count of CMD52 and CMD53 */
-u32 total_tx_bytes;   /* total bytes of CMD53 Tx */
-u32 total_rx_bytes;   /* total bytes of CMD53 Rx */
+   u32 total_tc; /* total tick count of CMD52 and CMD53 */
+   u32 total_tx_bytes;   /* total bytes of CMD53 Tx */
+   u32 total_rx_bytes;   /* total bytes of CMD53 Rx */
 
-/*CMD52*/
-struct cmd_profile cmd52_tx;
-struct cmd_profile cmd52_rx;
+   /*CMD52*/
+   struct cmd_profile cmd52_tx;
+   struct cmd_profile cmd52_rx;
 
-/*CMD53 in byte unit */
-struct cmd_profile cmd53_tx_byte[512];
-struct cmd_profile cmd53_rx_byte[512];
+   /*CMD53 in byte unit */
+   struct cmd_profile cmd53_tx_byte[512];
+   struct cmd_profile cmd53_rx_byte[512];
 
-/*CMD53 in block unit */
-struct cmd_profile cmd53_tx_blk[100];
-struct cmd_profile cmd53_rx_blk[100];
+   /*CMD53 in block unit */
+   struct cmd_profile cmd53_tx_blk[100];
+   struct cmd_profile cmd53_rx_blk[100];
 };
 
 //==
 typedef enum {
-SD_TOOL_ZONE = 0,
-SD_TOOL_DMA_SIZE  = 1,
-SD_TOOL_PM_ENABLE = 2,
-SD_TOOL_SDIO_PROFILE = 3,
+   SD_TOOL_ZONE = 0,
+   SD_TOOL_DMA_SIZE  = 1,
+   SD_TOOL_PM_ENABLE = 2,
+   SD_TOOL_SDIO_PROFILE = 3,
 } msdc_dbg;
 
 typedef enum {
-MODE_PIO = 0,
-MODE_DMA = 1,
-MODE_SIZE_DEP = 2,
+   MODE_PIO = 0,
+   MODE_DMA = 1,
+   MODE_SIZE_DEP = 2,
 } msdc_mode;
 extern msdc_mode drv_mode[4];
 extern u32 dma_size[4];
@@ -121,8 +121,8 @@ do {\
 
 #define ERR_MSG(fmt, args...) \
 do { \
-printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
-host->id,  ##args , __FUNCTION__, __LINE__, current->comm, 
current->pid); \
+   printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
+  host->id,  ##args , __FUNCTION__, __LINE__, current->comm, 
current->pid); \
 } while(0);
 
 #if 1
@@ -132,15 +132,15 @@ do { \
 #else
 #define INIT_MSG(fmt, args...) \
 do { \
-printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
-host->id,  ##args , __FUNCTION__, __LINE__, current->comm, 
current->pid); \
+   printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
+  host->id,  ##args , __FUNCTION__, __LINE__, current->comm, 
current->pid); \
 } while(0);
 
 /* PID in ISR in not corrent */
 #define IRQ_MSG(fmt, args...) \
 do { \
-printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d>\n", \
-host->id,  ##args , __FUNCTION__, __LINE__); \
+   printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d>\n", \
+  host->id,  ##args , __FUNCTION__, __LINE__); \
 } while(0);
 #endif
 
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 34/34] staging: mt7621-mmc: Remove duplicate defines

2018-04-02 Thread Christian Lütke-Stetzkamp
Remove defines that are both in board.h and sd.c from sd.c, this file
already includes board.h

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 95c439069c2b..66bf15455830 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -60,13 +60,6 @@
 #include 
 #include 
 
-#define MSDC_SMPL_FALLING   (1)
-#define MSDC_CD_PIN_EN  (1 << 0)  /* card detection pin is wired   */
-#define MSDC_WP_PIN_EN  (1 << 1)  /* write protection pin is wired */
-#define MSDC_REMOVABLE  (1 << 5)  /* removable slot*/
-#define MSDC_SYS_SUSPEND(1 << 6)  /* suspended by system   */
-#define MSDC_HIGHSPEED  (1 << 7)
-
 //#define IRQ_SDC 14   //MT7620 /*FIXME*/
 #ifdef CONFIG_SOC_MT7621
 #define RALINK_SYSCTL_BASE 0xbe00
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 25/34] staging: mt7621-mmc: Remove code checking for old kernel versions

2018-04-02 Thread Christian Lütke-Stetzkamp
Remove code, that is checking for old kernel versions, leaving only
the case for current versions.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 64933bad91e1..82b983575394 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -2749,12 +2749,8 @@ static int msdc_drv_probe(struct platform_device *pdev)
mmc->caps |= MMC_CAP_NEEDS_POLL;
 
/* MMC core transfer sizes tunable parameters */
-#if LINUX_VERSION_CODE > KERNEL_VERSION(3, 10, 0)
mmc->max_segs  = MAX_HW_SGMTS;
-#else
-   mmc->max_hw_segs   = MAX_HW_SGMTS;
-   mmc->max_phys_segs = MAX_PHY_SGMTS;
-#endif
+
mmc->max_seg_size  = MAX_SGMT_SZ;
mmc->max_blk_size  = HOST_MAX_BLKSZ;
mmc->max_req_size  = MAX_REQ_SZ;
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/34] staging: mt7621-mmc: Fix Pointer Location

2018-04-02 Thread Christian Lütke-Stetzkamp
Fix checkpatch error: POINTER_LOCATION

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/board.h |  2 +-
 drivers/staging/mt7621-mmc/dbg.c   |  8 +++---
 drivers/staging/mt7621-mmc/sd.c| 56 +++---
 3 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/board.h 
b/drivers/staging/mt7621-mmc/board.h
index 496357d1ce4d..b9cf7b875cfa 100644
--- a/drivers/staging/mt7621-mmc/board.h
+++ b/drivers/staging/mt7621-mmc/board.h
@@ -43,7 +43,7 @@
 // #include 
 /* end of chhung */
 
-typedef void (*sdio_irq_handler_t)(void*);  /* external irq handler */
+typedef void (*sdio_irq_handler_t)(void *);  /* external irq handler */
 typedef void (*pm_callback_t)(pm_message_t state, void *data);
 
 #define MSDC_CD_PIN_EN  (1 << 0)  /* card detection pin is wired   */
diff --git a/drivers/staging/mt7621-mmc/dbg.c b/drivers/staging/mt7621-mmc/dbg.c
index 215b2fc8c899..1ae9708efd20 100644
--- a/drivers/staging/mt7621-mmc/dbg.c
+++ b/drivers/staging/mt7621-mmc/dbg.c
@@ -117,9 +117,9 @@ u32 msdc_time_calc(u32 old_L32, u32 old_H32, u32 new_L32, 
u32 new_H32)
return ret;
 }
 
-void msdc_sdio_profile(struct sdio_profile* result)
+void msdc_sdio_profile(struct sdio_profile *result)
 {
-   struct cmd_profile*  cmd;
+   struct cmd_profile *cmd;
u32 i;
 
printk("sdio === performance dump ===\n");
@@ -177,8 +177,8 @@ void msdc_sdio_profile(struct sdio_profile* result)
 //= sdio command table ===
 void msdc_performance(u32 opcode, u32 sizes, u32 bRx, u32 ticks)
 {
-   struct sdio_profile* result = &sdio_perfomance;
-   struct cmd_profile*  cmd;
+   struct sdio_profile *result = &sdio_perfomance;
+   struct cmd_profile *cmd;
u32 block;
 
if (sdio_pro_enable == 0) {
diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 0a5e32f48b8a..b5bd31e220d6 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -178,7 +178,7 @@ static int g_clk_gate = 0;
} while (0)
 
 // do we need sync object or not
-void msdc_clk_status(int * status)
+void msdc_clk_status(int *status)
 {
*status = g_clk_gate;
 }
@@ -234,19 +234,19 @@ static int msdc_rsp[] = {
 /* For Inhanced DMA */
 #define msdc_init_gpd_ex(gpd, extlen, cmd, arg, blknum) \
do {\
-   ((gpd_t*)gpd)->extlen = extlen; \
-   ((gpd_t*)gpd)->cmd= cmd;\
-   ((gpd_t*)gpd)->arg= arg;\
-   ((gpd_t*)gpd)->blknum = blknum; \
+   ((gpd_t *)gpd)->extlen = extlen;\
+   ((gpd_t *)gpd)->cmd= cmd;   \
+   ((gpd_t *)gpd)->arg= arg;   \
+   ((gpd_t *)gpd)->blknum = blknum;\
} while (0)
 
 #define msdc_init_bd(bd, blkpad, dwpad, dptr, dlen) \
do {\
BUG_ON(dlen > 0xUL);\
-   ((bd_t*)bd)->blkpad = blkpad;   \
-   ((bd_t*)bd)->dwpad  = dwpad;\
-   ((bd_t*)bd)->ptr= (void*)dptr;  \
-   ((bd_t*)bd)->buflen = dlen; \
+   ((bd_t *)bd)->blkpad = blkpad;  \
+   ((bd_t *)bd)->dwpad  = dwpad;   \
+   ((bd_t *)bd)->ptr= (void *)dptr;  \
+   ((bd_t *)bd)->buflen = dlen;\
} while (0)
 
 #define msdc_txfifocnt()   ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_TXCNT) >> 
16)
@@ -358,7 +358,7 @@ static u32 hclks[] = {5000}; /* +/- by chhung */
 
 // can modify to read h/w register.
 //#define is_card_present(h)   ((sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1);
-#define is_card_present(h) (((struct msdc_host*)(h))->card_inserted)
+#define is_card_present(h) (((struct msdc_host *)(h))->card_inserted)
 
 /* +++ by chhung */
 #ifndef __ASSEMBLY__
@@ -372,7 +372,7 @@ static unsigned int msdc_do_command(struct msdc_host   
*host,
int tune,
unsigned long   timeout);
 
-static int msdc_tune_cmdrsp(struct msdc_host*host, struct mmc_command *cmd);
+static int msdc_tune_cmdrsp(struct msdc_host *host, struct mmc_command *cmd);
 
 #ifdef MT6575_SD_DEBUG
 static void msdc_dump_card_status(struct msdc_host *host, u32 status)
@@ -614,7 +614,7 @@ static u8 clk_src_bit[4] = {
0, 3, 5, 7
 };
 
-static void msdc_select_clksrc(struct msdc_host* host, unsigned char clksrc)
+static void msdc_select_clksrc(struct msdc_host *host, unsigned char clksrc)
 {
u32 val;
u32 base = host->base;
@@ -1253,7 +1253,7 @@ static int msdc_pio_read(struct msdc_host *host, struct 
mmc_data *data)
which means, memory card block read/write won't using pio
then don't need to handle the CMD12 when data error.
 */
-static int msdc_pio_write(struct msdc_host

[PATCH 16/34] staging: mt7621-mmc: Fix style of braces

2018-04-02 Thread Christian Lütke-Stetzkamp
Fix checkpatch errors, warnings, checks about braces:
BRACES, ELSE_AFTER_BRACE, OPEN_BRACE

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/dbg.c   |  31 +++
 drivers/staging/mt7621-mmc/mt6575_sd.h |   3 +-
 drivers/staging/mt7621-mmc/sd.c| 154 +
 3 files changed, 70 insertions(+), 118 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/dbg.c b/drivers/staging/mt7621-mmc/dbg.c
index 1e4c95b659da..70f1abe7012d 100644
--- a/drivers/staging/mt7621-mmc/dbg.c
+++ b/drivers/staging/mt7621-mmc/dbg.c
@@ -105,9 +105,8 @@ u32 msdc_time_calc(u32 old_L32, u32 old_H32, u32 new_L32, 
u32 new_H32)
if (new_H32 == old_H32) {
ret = new_L32 - old_L32;
} else if (new_H32 == (old_H32 + 1)) {
-   if (new_L32 > old_L32) {
+   if (new_L32 > old_L32)
printk("msdc old_L<0x%x> new_L<0x%x>\n", old_L32, 
new_L32);
-   }
ret = (0x - old_L32);
ret += new_L32;
} else {
@@ -181,9 +180,8 @@ void msdc_performance(u32 opcode, u32 sizes, u32 bRx, u32 
ticks)
struct cmd_profile *cmd;
u32 block;
 
-   if (sdio_pro_enable == 0) {
+   if (sdio_pro_enable == 0)
return;
-   }
 
if (opcode == 52) {
cmd = bRx ?  &result->cmd52_rx : &result->cmd52_tx;
@@ -204,21 +202,18 @@ void msdc_performance(u32 opcode, u32 sizes, u32 bRx, u32 
ticks)
}
 
/* update the members */
-   if (ticks > cmd->max_tc) {
+   if (ticks > cmd->max_tc)
cmd->max_tc = ticks;
-   }
-   if (cmd->min_tc == 0 || ticks < cmd->min_tc) {
+   if (cmd->min_tc == 0 || ticks < cmd->min_tc)
cmd->min_tc = ticks;
-   }
cmd->tot_tc += ticks;
cmd->tot_bytes += sizes;
cmd->count++;
 
-   if (bRx) {
+   if (bRx)
result->total_rx_bytes += sizes;
-   } else {
+   else
result->total_tx_bytes += sizes;
-   }
result->total_tc += ticks;
 
/* dump when total_tc > 30s */
@@ -286,12 +281,10 @@ static ssize_t msdc_debug_proc_write(struct file *file,
printk("msdc host_id<%d> zone<0x%.8x>\n", id, zone);
if (id >= 0 && id <= 3) {
sd_debug_zone[id] = zone;
-   }
-   else if (id == 4) {
+   } else if (id == 4) {
sd_debug_zone[0] = sd_debug_zone[1] = zone;
sd_debug_zone[2] = sd_debug_zone[3] = zone;
-   }
-   else{
+   } else {
printk("msdc host_id error when set debug zone\n");
}
} else if (cmd == SD_TOOL_DMA_SIZE) {
@@ -301,14 +294,12 @@ static ssize_t msdc_debug_proc_write(struct file *file,
if (id >= 0 && id <= 3) {
drv_mode[id] = mode;
dma_size[id] = p2;
-   }
-   else if (id == 4) {
+   } else if (id == 4) {
drv_mode[0] = drv_mode[1] = mode;
drv_mode[2] = drv_mode[3] = mode;
dma_size[0] = dma_size[1] = p2;
dma_size[2] = dma_size[3] = p2;
-   }
-   else{
+   } else {
printk("msdc host_id error when select mode\n");
}
} else if (cmd == SD_TOOL_SDIO_PROFILE) {
@@ -323,7 +314,7 @@ static ssize_t msdc_debug_proc_write(struct file *file,
if (p2 >= 30)
p2 = 30;
sdio_pro_time = p2;
-   }   else if (p1 == 0) {
+   } else if (p1 == 0) {
/* todo */
sdio_pro_enable = 0;
}
diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h 
b/drivers/staging/mt7621-mmc/mt6575_sd.h
index 99ca8b75711f..f6daaf69bcab 100644
--- a/drivers/staging/mt7621-mmc/mt6575_sd.h
+++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
@@ -925,8 +925,7 @@ struct msdc_dma {
u32 used_bd; /* the number of used bd elements */
 };
 
-struct msdc_host
-{
+struct msdc_host {
struct msdc_hw  *hw;
 
struct mmc_host *mmc;   /* mmc structure */
diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index e7c2d74b9f2f..3be653dc1d4a 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -590,9 +590,8 @@ static void msdc_tasklet_card(struct work_struct *work)
host->card_inserted = inserted;
 
if (change && !host->suspend) {
-   if (inserted) {
+   if (inserted)
host->mmc->f_max = HOST_MAX_MCLK;  // work around
-   }
mmc_detect_change(host->mmc, msecs_to_jiffies

[PATCH 20/34] staging: mt7621-mmc: Remove code for different soc types

2018-04-02 Thread Christian Lütke-Stetzkamp
Remove code that is intended for soc other then the mt7621 because
this driver is only for that soc. This also removes some conditions.
However the remaining code is also at the wrong place, it just selects
the mode of the pins, this is a job for pinctl not for the sdxc driver.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 25 -
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index e28635ab556a..552bf0824d31 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -2987,27 +2987,10 @@ static int __init mt_msdc_init(void)
 
printk("MTK MSDC device init.\n");
mtk_sd_device.dev.platform_data = &msdc0_hw;
-   if (ralink_soc == MT762X_SOC_MT7620A || ralink_soc == 
MT762X_SOC_MT7621AT) {
-//#if defined (CONFIG_RALINK_MT7620) || defined (CONFIG_RALINK_MT7621)
-   reg = sdr_read32((volatile u32 *)(RALINK_SYSCTL_BASE + 0x60)) & 
~(0x3 << 18);
-//#if defined (CONFIG_RALINK_MT7620)
-   if (ralink_soc == MT762X_SOC_MT7620A)
-   reg |= 0x1 << 18;
-//#endif
-   } else {
-//#elif defined (CONFIG_RALINK_MT7628)
-   /* TODO: maybe omitted when RAether already toggle AGPIO_CFG */
-   reg = sdr_read32((volatile u32 *)(RALINK_SYSCTL_BASE + 0x3c));
-   reg |= 0x1e << 16;
-   sdr_write32((volatile u32 *)(RALINK_SYSCTL_BASE + 0x3c), reg);
-
-   reg = sdr_read32((volatile u32 *)(RALINK_SYSCTL_BASE + 0x60)) & 
~(0x3 << 10);
-#if defined(CONFIG_MTK_MMC_EMMC_8BIT)
-   reg |= 0x3 << 26 | 0x3 << 28 | 0x3 << 30;
-   msdc0_hw.data_pins  = 8,
-#endif
-//#endif
-   }
+
+   // Set the pins for sdxc to sdxc mode
+   //FIXME: this should be done by pinctl and not by the sd driver
+   reg = sdr_read32((volatile u32 *)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3 
<< 18);
sdr_write32((volatile u32 *)(RALINK_SYSCTL_BASE + 0x60), reg);
//platform_device_register(&mtk_sd_device);
 /* end of +++ */
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 22/34] staging: mt7621-mmc: Cleanup function mt_msdc_init

2018-04-02 Thread Christian Lütke-Stetzkamp
Cleanup the mt_msdc_init function, remove excceding printk.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 7cc7aa4b6ec7..4fe378040ce3 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -2963,11 +2963,8 @@ static struct platform_driver mt_msdc_driver = {
 static int __init mt_msdc_init(void)
 {
int ret;
-/* +++ by chhung */
u32 reg;
 
-   printk("MTK MSDC device init.\n");
-
// Set the pins for sdxc to sdxc mode
//FIXME: this should be done by pinctl and not by the sd driver
reg = sdr_read32((volatile u32 *)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3 
<< 18);
@@ -2978,7 +2975,6 @@ static int __init mt_msdc_init(void)
printk(KERN_ERR DRV_NAME ": Can't register driver");
return ret;
}
-   printk(KERN_INFO DRV_NAME ": MediaTek MT6575 MSDC Driver\n");
 
 #if defined(MT6575_SD_DEBUG)
msdc_debug_proc_init();
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/34] staging: mt7621-mmc: Fix indent for dbg.c

2018-04-02 Thread Christian Lütke-Stetzkamp
This fixes the indentaions in the file dbg.c

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/dbg.c | 258 +++
 1 file changed, 129 insertions(+), 129 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/dbg.c b/drivers/staging/mt7621-mmc/dbg.c
index 3f204d7480c9..1c5ceee577f9 100644
--- a/drivers/staging/mt7621-mmc/dbg.c
+++ b/drivers/staging/mt7621-mmc/dbg.c
@@ -83,147 +83,147 @@ struct sdio_profile sdio_perfomance = {0};
 #if 0 /* --- chhung */
 void msdc_init_gpt(void)
 {
-GPT_CONFIG config;
+   GPT_CONFIG config;
 
-config.num  = GPT6;
-config.mode = GPT_FREE_RUN;
-config.clkSrc = GPT_CLK_SRC_SYS;
-config.clkDiv = GPT_CLK_DIV_1;   /* 13MHz GPT6 */
+   config.num  = GPT6;
+   config.mode = GPT_FREE_RUN;
+   config.clkSrc = GPT_CLK_SRC_SYS;
+   config.clkDiv = GPT_CLK_DIV_1;   /* 13MHz GPT6 */
 
-if (GPT_Config(config) == FALSE )
-return;
+   if (GPT_Config(config) == FALSE )
+   return;
 
-GPT_Start(GPT6);
+   GPT_Start(GPT6);
 }
 #endif /* end of --- */
 
 u32 msdc_time_calc(u32 old_L32, u32 old_H32, u32 new_L32, u32 new_H32)
 {
-u32 ret = 0;
-
-if (new_H32 == old_H32) {
-ret = new_L32 - old_L32;
-} else if(new_H32 == (old_H32 + 1)) {
-if (new_L32 > old_L32) {
-printk("msdc old_L<0x%x> new_L<0x%x>\n", old_L32, new_L32);
-}
-ret = (0x - old_L32);
-ret += new_L32;
-} else {
-printk("msdc old_H<0x%x> new_H<0x%x>\n", old_H32, new_H32);
-}
-
-return ret;
+   u32 ret = 0;
+
+   if (new_H32 == old_H32) {
+   ret = new_L32 - old_L32;
+   } else if(new_H32 == (old_H32 + 1)) {
+   if (new_L32 > old_L32) {
+   printk("msdc old_L<0x%x> new_L<0x%x>\n", old_L32, 
new_L32);
+   }
+   ret = (0x - old_L32);
+   ret += new_L32;
+   } else {
+   printk("msdc old_H<0x%x> new_H<0x%x>\n", old_H32, new_H32);
+   }
+
+   return ret;
 }
 
 void msdc_sdio_profile(struct sdio_profile* result)
 {
-struct cmd_profile*  cmd;
-u32 i;
-
-printk("sdio === performance dump ===\n");
-printk("sdio === total execute tick<%d> time<%dms> Tx<%dB> Rx<%dB>\n",
-result->total_tc, result->total_tc / TICKS_ONE_MS,
-result->total_tx_bytes, result->total_rx_bytes);
-
-/* CMD52 Dump */
-cmd = &result->cmd52_rx;
-printk("sdio === CMD52 Rx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", 
cmd->count, cmd->tot_tc,
-cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count);
-cmd = &result->cmd52_tx;
-printk("sdio === CMD52 Tx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", 
cmd->count, cmd->tot_tc,
-cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count);
-
-/* CMD53 Rx bytes + block mode */
-for (i=0; i<512; i++) {
-cmd = &result->cmd53_rx_byte[i];
-if (cmd->count) {
-printk("sdio<%6d><%3dB>_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", 
cmd->count, i, cmd->tot_tc,
- cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
- cmd->tot_bytes, (cmd->tot_bytes/10)*13 / 
(cmd->tot_tc/10));
-}
-}
-for (i=0; i<100; i++) {
-cmd = &result->cmd53_rx_blk[i];
-if (cmd->count) {
-printk("sdio<%6d><%3d>B_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", 
cmd->count, i, cmd->tot_tc,
- cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
- cmd->tot_bytes, (cmd->tot_bytes/10)*13 / 
(cmd->tot_tc/10));
-}
-}
-
-/* CMD53 Tx bytes + block mode */
-for (i=0; i<512; i++) {
-cmd = &result->cmd53_tx_byte[i];
-if (cmd->count) {
-printk("sdio<%6d><%3dB>_Tx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", 
cmd->count, i, cmd->tot_tc,
- cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
- cmd->tot_bytes, (cmd->tot_bytes/10)*13 / 
(cmd->tot_tc/10));
-}
-}
-for (i=0; i<100; i++) {
-cmd = &result->cmd53_tx_blk[i];
-if (cmd->count) {
-printk("sdio<%6d><%3d>B_Tx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", 
cmd->count, i, cmd->tot_tc,
- cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
- cmd->tot_bytes, (cmd->tot_bytes/10)*13 / 
(cmd->tot_tc/10));
-}
-}
-
-printk("sdio === performance dump done ===\n");
+   struct cmd_profile*  cmd;
+   u32 i;
+
+   printk("sdio === performance dump ===\n");
+   printk("sdio === total execute tick<%d> time<%dms> Tx<%dB> Rx<%dB>\n",
+   result->total_tc, result->total_tc / TICKS_ONE_MS,
+   result->total_tx_bytes, result->total_rx_bytes);
+
+   /* CMD52 Dump */
+   cmd = &result->cmd52_rx;
+  

[PATCH 14/34] staging: mt7621-mmc: Fix trailing statements

2018-04-02 Thread Christian Lütke-Stetzkamp
Fix checkpatch error: TRAILING_STATEMENTS

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/dbg.c | 25 ++---
 drivers/staging/mt7621-mmc/dbg.h |  3 ++-
 drivers/staging/mt7621-mmc/sd.c  | 39 ++-
 3 files changed, 46 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/dbg.c b/drivers/staging/mt7621-mmc/dbg.c
index e7677155a789..60c704d6adc2 100644
--- a/drivers/staging/mt7621-mmc/dbg.c
+++ b/drivers/staging/mt7621-mmc/dbg.c
@@ -194,7 +194,8 @@ void msdc_performance(u32 opcode, u32 sizes, u32 bRx, u32 
ticks)
block = sizes / 512;
if (block >= 99) {
printk("cmd53 error blocks\n");
-   while (1);
+   while (1)
+   ;
}
cmd = bRx ?  &result->cmd53_rx_blk[block] : 
&result->cmd53_tx_blk[block];
}
@@ -264,11 +265,14 @@ static ssize_t msdc_debug_proc_write(struct file *file,
int id, zone;
int mode, size;
 
-   if (count == 0)return -1;
-   if (count > 255)count = 255;
+   if (count == 0)
+   return -1;
+   if (count > 255)
+   count = 255;
 
ret = copy_from_user(cmd_buf, buf, count);
-   if (ret < 0)return -1;
+   if (ret < 0)
+   return -1;
 
cmd_buf[count] = '\0';
printk("msdc Write %s\n", cmd_buf);
@@ -276,7 +280,9 @@ static ssize_t msdc_debug_proc_write(struct file *file,
sscanf(cmd_buf, "%x %x %x", &cmd, &p1, &p2);
 
if (cmd == SD_TOOL_ZONE) {
-   id = p1; zone = p2; zone &= 0x3ff;
+   id = p1;
+   zone = p2;
+   zone &= 0x3ff;
printk("msdc host_id<%d> zone<0x%.8x>\n", id, zone);
if (id >= 0 && id <= 3) {
sd_debug_zone[id] = zone;
@@ -289,7 +295,9 @@ static ssize_t msdc_debug_proc_write(struct file *file,
printk("msdc host_id error when set debug zone\n");
}
} else if (cmd == SD_TOOL_DMA_SIZE) {
-   id = p1 >> 4;  mode = (p1 & 0xf); size = p2;
+   id = p1 >> 4;
+   mode = (p1 & 0xf);
+   size = p2;
if (id >= 0 && id <= 3) {
drv_mode[id] = mode;
dma_size[id] = p2;
@@ -310,7 +318,10 @@ static ssize_t msdc_debug_proc_write(struct file *file,
gpt_enable = 1;
}
sdio_pro_enable = 1;
-   if (p2 == 0) p2 = 1; if (p2 >= 30) p2 = 30;
+   if (p2 == 0)
+   p2 = 1;
+   if (p2 >= 30)
+   p2 = 30;
sdio_pro_time = p2;
}   else if (p1 == 0) {
/* todo */
diff --git a/drivers/staging/mt7621-mmc/dbg.h b/drivers/staging/mt7621-mmc/dbg.h
index fdeefea7ed52..5469c9d16804 100644
--- a/drivers/staging/mt7621-mmc/dbg.h
+++ b/drivers/staging/mt7621-mmc/dbg.h
@@ -105,7 +105,8 @@ extern unsigned int sd_debug_zone[4];
 do { \
if (x) { \
printk("[BUG] %s LINE:%d FILE:%s\n", #x, __LINE__, __FILE__); \
-   while (1); \
+   while (1)   \
+   ;   \
} \
 } while (0)
 #endif /* end of +++ */
diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index ec28925093cd..e7c2d74b9f2f 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -263,7 +263,8 @@ static int msdc_rsp[] = {
do {\
int backup = cnt;   \
while (retry) { \
-   if (!(expr)) break; \
+   if (!(expr))\
+   break;  \
if (cnt-- == 0) {   \
retry--; mdelay(1); cnt = backup;   \
}   \
@@ -694,7 +695,8 @@ static void msdc_set_mclk(struct msdc_host *host, int ddr, 
unsigned int hz)
sdr_set_field(MSDC_CFG, MSDC_CFG_CKDIV, div);
 
/* wait clock stable */
-   while (!(sdr_read32(MSDC_CFG) & MSDC_CFG_CKSTB));
+   while (!(sdr_read32(MSDC_CFG) & MSDC_CFG_CKSTB))
+   ;
 
host->sclk = sclk;
host->mclk = hz;
@@ -1245,7 +1247,8 @@ static int msdc_pio_read(struct msdc_host *host, struct 

[PATCH 32/34] staging: mt7621-mmc: Fix dma_alloc_coherent should get device as first param

2018-04-02 Thread Christian Lütke-Stetzkamp
The dma_alloc_coherent (and also dma_free_coherent) should get the
device, the dma memory is allocated for as the first parameter.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 86b2f4e0833c..e709e4d47965 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -2779,8 +2779,12 @@ static int msdc_drv_probe(struct platform_device *pdev)
mmc_dev(mmc)->dma_mask = NULL;
 
/* using dma_alloc_coherent*/  /* todo: using 1, for all 4 slots */
-   host->dma.gpd = dma_alloc_coherent(NULL, MAX_GPD_NUM * sizeof(struct 
gpt), &host->dma.gpd_addr, GFP_KERNEL);
-   host->dma.bd =  dma_alloc_coherent(NULL, MAX_BD_NUM  * sizeof(struct 
bd),  &host->dma.bd_addr,  GFP_KERNEL);
+   host->dma.gpd = dma_alloc_coherent(&pdev->dev,
+  MAX_GPD_NUM * sizeof(struct gpt),
+  &host->dma.gpd_addr, GFP_KERNEL);
+   host->dma.bd =  dma_alloc_coherent(&pdev->dev,
+  MAX_BD_NUM  * sizeof(struct bd),
+  &host->dma.bd_addr,  GFP_KERNEL);
if (!host->dma.gdp || !host->dma.bd) {
ret = -ENOMEM;
goto release_mem;
@@ -2835,10 +2839,10 @@ static int msdc_drv_probe(struct platform_device *pdev)
 
 release_mem:
if (host->dma.gpd)
-   dma_free_coherent(NULL, MAX_GPD_NUM * sizeof(struct gpt),
+   dma_free_coherent(&pdev->dev, MAX_GPD_NUM * sizeof(struct gpt),
  host->dma.gpd, host->dma.gpd_addr);
if (host->dma.bd)
-   dma_free_coherent(NULL, MAX_BD_NUM * sizeof(struct bd),
+   dma_free_coherent(&pdev->dev, MAX_BD_NUM * sizeof(struct bd),
  host->dma.bd, host->dma.bd_addr);
 host_free:
mmc_free_host(mmc);
@@ -2871,8 +2875,10 @@ static int msdc_drv_remove(struct platform_device *pdev)
 #endif
free_irq(host->irq, host);
 
-   dma_free_coherent(NULL, MAX_GPD_NUM * sizeof(struct gpt), 
host->dma.gpd, host->dma.gpd_addr);
-   dma_free_coherent(NULL, MAX_BD_NUM  * sizeof(struct bd),  host->dma.bd, 
 host->dma.bd_addr);
+   dma_free_coherent(&pdev->dev, MAX_GPD_NUM * sizeof(struct gpt),
+ host->dma.gpd, host->dma.gpd_addr);
+   dma_free_coherent(&pdev->dev, MAX_BD_NUM  * sizeof(struct bd),
+ host->dma.bd,  host->dma.bd_addr);
 
mmc_free_host(host->mmc);
 
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/34] staging: mt7621-mmc: Remove whitespace errors in board.h

2018-04-02 Thread Christian Lütke-Stetzkamp
The whitespace errors in the file board.h are fixed by using the
cleanfile script. Indentations with whitespaces are not changed
in this patch.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/board.h | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/board.h 
b/drivers/staging/mt7621-mmc/board.h
index 33bfc7b9597a..6179ac9714d7 100644
--- a/drivers/staging/mt7621-mmc/board.h
+++ b/drivers/staging/mt7621-mmc/board.h
@@ -102,7 +102,7 @@ struct msdc_hw {
 void (*enable_cd_eirq)(void);
 void (*disable_cd_eirq)(void);
 int  (*get_cd_status)(void);
-
+
 /* power management callback for external module */
 void (*register_pm)(pm_callback_t pm_cb, void *data);
 };
@@ -122,8 +122,8 @@ extern struct mt3326_gps_hardware mt3326_gps_hw;
 
 /* NAND driver */
 struct mt6575_nand_host_hw {
-unsigned int nfi_bus_width;/* NFI_BUS_WIDTH */ 
-   unsigned int nfi_access_timing; /* NFI_ACCESS_TIMING */  
+unsigned int nfi_bus_width;/* NFI_BUS_WIDTH */
+   unsigned int nfi_access_timing; /* NFI_ACCESS_TIMING */
unsigned int nfi_cs_num;/* NFI_CS_NUM */
unsigned int nand_sec_size; /* NAND_SECTOR_SIZE */
unsigned int nand_sec_shift;/* NAND_SECTOR_SHIFT */
@@ -134,4 +134,3 @@ struct mt6575_nand_host_hw {
 extern struct mt6575_nand_host_hw mt6575_nand_hw;
 
 #endif /* __ARCH_ARM_MACH_BOARD_H */
-
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 24/34] staging: mt7621-mmc: Fix memory leek in case of error in probe

2018-04-02 Thread Christian Lütke-Stetzkamp
If the base address is not successfully obtained in the probe
function, then the mmc_host struct is not freed. Adding an exit for
that case fixes the bug.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index c7a00834deca..64933bad91e1 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -2719,8 +2719,10 @@ static int msdc_drv_probe(struct platform_device *pdev)
//BUG_ON((!hw) || (!mem) || (irq < 0)); /* --- by chhung */
 
base = devm_ioremap_resource(&pdev->dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   if (IS_ERR(base)) {
+   ret = PTR_ERR(base);
+   goto host_free;
+   }
 
/* Set host parameters to mmc */
mmc->ops= &mt_msdc_ops;
@@ -2861,6 +2863,7 @@ static int msdc_drv_probe(struct platform_device *pdev)
if (mem)
release_mem_region(mem->start, mem->end - mem->start + 1);
 
+host_free:
mmc_free_host(mmc);
 
return ret;
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 28/34] staging: mt7621-mmc: Remove unnecessary setting of dev.platform_data

2018-04-02 Thread Christian Lütke-Stetzkamp
In the probe function, pdev->dev.platform_data is set to &msdc0_hw,
but the only get access to that is also in the probe function. So that
assignment is removed. The msdc0_hw structure is still available to the
driver as part of the msdc_host structure.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 0d4877483e54..81c0efdc5449 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -2701,7 +2701,7 @@ static int msdc_drv_probe(struct platform_device *pdev)
struct msdc_hw *hw;
int ret, irq;
 
-   pdev->dev.platform_data = &msdc0_hw;
+   hw = &msdc0_hw;
 
if (of_property_read_bool(pdev->dev.of_node, "mtk,wp-en"))
msdc0_hw.flags |= MSDC_WP_PIN_EN;
@@ -2711,7 +2711,6 @@ static int msdc_drv_probe(struct platform_device *pdev)
if (!mmc)
return -ENOMEM;
 
-   hw   = (struct msdc_hw *)pdev->dev.platform_data;
irq  = platform_get_irq(pdev, 0);
 
//BUG_ON((!hw) || (!mem) || (irq < 0)); /* --- by chhung */
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/34] staging: mt7621-mmc: Remove unnecessary typedefs

2018-04-02 Thread Christian Lütke-Stetzkamp
Fixes checkpatch warning: NEW_TYPEDEFS

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/dbg.c   |   2 +-
 drivers/staging/mt7621-mmc/dbg.h   |  11 +-
 drivers/staging/mt7621-mmc/mt6575_sd.h | 305 +++--
 drivers/staging/mt7621-mmc/sd.c|  48 +++---
 4 files changed, 204 insertions(+), 162 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/dbg.c b/drivers/staging/mt7621-mmc/dbg.c
index 1ae9708efd20..e7677155a789 100644
--- a/drivers/staging/mt7621-mmc/dbg.c
+++ b/drivers/staging/mt7621-mmc/dbg.c
@@ -66,7 +66,7 @@ u32 dma_size[4] = {
512
 };
 
-msdc_mode drv_mode[4] = {
+enum msdc_mode drv_mode[4] = {
MODE_SIZE_DEP, /* using DMA or not depend on the size */
MODE_SIZE_DEP,
MODE_SIZE_DEP,
diff --git a/drivers/staging/mt7621-mmc/dbg.h b/drivers/staging/mt7621-mmc/dbg.h
index f4d32dd9a3f4..fdeefea7ed52 100644
--- a/drivers/staging/mt7621-mmc/dbg.h
+++ b/drivers/staging/mt7621-mmc/dbg.h
@@ -66,19 +66,20 @@ struct sdio_profile {
 };
 
 //==
-typedef enum {
+enum msdc_dbg {
SD_TOOL_ZONE = 0,
SD_TOOL_DMA_SIZE  = 1,
SD_TOOL_PM_ENABLE = 2,
SD_TOOL_SDIO_PROFILE = 3,
-} msdc_dbg;
+};
 
-typedef enum {
+enum msdc_mode {
MODE_PIO = 0,
MODE_DMA = 1,
MODE_SIZE_DEP = 2,
-} msdc_mode;
-extern msdc_mode drv_mode[4];
+};
+
+extern enum msdc_mode drv_mode[4];
 extern u32 dma_size[4];
 
 /* Debug message event */
diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h 
b/drivers/staging/mt7621-mmc/mt6575_sd.h
index bd555ebf85d3..99ca8b75711f 100644
--- a/drivers/staging/mt7621-mmc/mt6575_sd.h
+++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
@@ -447,7 +447,7 @@ enum {
 /*--*/
 /* Descriptor Structure */
 /*--*/
-typedef struct {
+struct gpd {
u32  hwo:1; /* could be changed by hw */
u32  bdp:1;
u32  rsv0:6;
@@ -462,9 +462,9 @@ typedef struct {
u32  arg;
u32  blknum;
u32  cmd;
-} gpd_t;
+};
 
-typedef struct {
+struct bd {
u32  eol:1;
u32  rsv0:7;
u32  chksum:8;
@@ -476,13 +476,13 @@ typedef struct {
void *ptr;
u32  buflen:16;
u32  rsv3:16;
-} bd_t;
+};
 
 /*--*/
 /* Register Debugging Structure */
 /*--*/
 
-typedef struct {
+struct msdc_cfg_reg {
u32 msdc:1;
u32 ckpwn:1;
u32 rst:1;
@@ -494,8 +494,9 @@ typedef struct {
u32 ckdiv:8;
u32 ckmod:2;
u32 pad:14;
-} msdc_cfg_reg;
-typedef struct {
+};
+
+struct msdc_iocon_reg {
u32 sdr104cksel:1;
u32 rsmpl:1;
u32 dsmpl:1;
@@ -513,8 +514,9 @@ typedef struct {
u32 d7spl:1;
u32 riscsz:1;
u32 pad2:7;
-} msdc_iocon_reg;
-typedef struct {
+};
+
+struct msdc_ps_reg {
u32 cden:1;
u32 cdsts:1;
u32 pad1:10;
@@ -523,8 +525,9 @@ typedef struct {
u32 cmd:1;
u32 pad2:6;
u32 wp:1;
-} msdc_ps_reg;
-typedef struct {
+};
+
+struct msdc_int_reg {
u32 mmcirq:1;
u32 cdsc:1;
u32 pad1:1;
@@ -543,8 +546,9 @@ typedef struct {
u32 datcrc:1;
u32 atocmd19done:1;
u32 pad2:15;
-} msdc_int_reg;
-typedef struct {
+};
+
+struct msdc_inten_reg {
u32 mmcirq:1;
u32 cdsc:1;
u32 pad1:1;
@@ -563,21 +567,25 @@ typedef struct {
u32 datcrc:1;
u32 atocmd19done:1;
u32 pad2:15;
-} msdc_inten_reg;
-typedef struct {
+};
+
+struct msdc_fifocs_reg {
u32 rxcnt:8;
u32 pad1:8;
u32 txcnt:8;
u32 pad2:7;
u32 clr:1;
-} msdc_fifocs_reg;
-typedef struct {
+};
+
+struct msdc_txdat_reg {
u32 val;
-} msdc_txdat_reg;
-typedef struct {
+};
+
+struct msdc_rxdat_reg {
u32 val;
-} msdc_rxdat_reg;
-typedef struct {
+};
+
+struct sdc_cfg_reg {
u32 sdiowkup:1;
u32 inswkup:1;
u32 pad1:14;
@@ -588,8 +596,9 @@ typedef struct {
u32 intblkgap:1;
u32 pad4:2;
u32 dtoc:8;
-} sdc_cfg_reg;
-typedef struct {
+};
+
+struct sdc_cmd_reg {
u32 cmd:6;
u32 brk:1;
u32 rsptyp:3;
@@ -602,43 +611,54 @@ typedef struct {
u32 atocmd:2;
u32 volswth:1;
u32 pad2:1;
-} sdc_cmd_reg;
-typedef struct {
+};
+
+struct sdc_arg_reg {
u32 arg;
-} sdc_arg_reg;
-typedef struct {
+};
+
+struct sdc_sts_reg {
u32 sdcbusy:1;
u32 cmdbusy:1;
u32 pad:29;
u32 swrcmpl:1;
-} sdc_sts_reg;
-typedef struct {
+};
+
+struct sdc_resp0_reg {
u32 val;
-} sdc_resp0_reg;
-typedef struct {
+};
+
+struct sdc_resp1_reg {
u32 val;
-} 

[PATCH 26/34] staging: mt7621-mmc: Fix unmatched release_mem_regin

2018-04-02 Thread Christian Lütke-Stetzkamp
Current code calls release_mem_regin on driver remove without
requesting it explicit first. The region is only requested via
devm_ioremap_resource and that releases it automatically. Removing the
release_mem_region calls fixes this.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 82b983575394..9cc8f4c8ef28 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -2694,10 +2694,9 @@ static void msdc_init_gpd_bd(struct msdc_host *host, 
struct msdc_dma *dma)
 
 static int msdc_drv_probe(struct platform_device *pdev)
 {
-   struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   struct resource *res;
__iomem void *base;
struct mmc_host *mmc;
-   struct resource *mem;
struct msdc_host *host;
struct msdc_hw *hw;
int ret, irq;
@@ -2713,11 +2712,11 @@ static int msdc_drv_probe(struct platform_device *pdev)
return -ENOMEM;
 
hw   = (struct msdc_hw *)pdev->dev.platform_data;
-   mem  = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq  = platform_get_irq(pdev, 0);
 
//BUG_ON((!hw) || (!mem) || (irq < 0)); /* --- by chhung */
 
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0)
base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(base)) {
ret = PTR_ERR(base);
@@ -2856,9 +2855,6 @@ static int msdc_drv_probe(struct platform_device *pdev)
cancel_delayed_work_sync(&host->card_delaywork);
 #endif
 
-   if (mem)
-   release_mem_region(mem->start, mem->end - mem->start + 1);
-
 host_free:
mmc_free_host(mmc);
 
@@ -2870,7 +2866,6 @@ static int msdc_drv_remove(struct platform_device *pdev)
 {
struct mmc_host *mmc;
struct msdc_host *host;
-   struct resource *mem;
 
mmc  = platform_get_drvdata(pdev);
BUG_ON(!mmc);
@@ -2894,11 +2889,6 @@ static int msdc_drv_remove(struct platform_device *pdev)
dma_free_coherent(NULL, MAX_GPD_NUM * sizeof(struct gpt), 
host->dma.gpd, host->dma.gpd_addr);
dma_free_coherent(NULL, MAX_BD_NUM  * sizeof(struct bd),  host->dma.bd, 
 host->dma.bd_addr);
 
-   mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
-   if (mem)
-   release_mem_region(mem->start, mem->end - mem->start + 1);
-
mmc_free_host(host->mmc);
 
return 0;
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/34] staging: mt7621-mmc: Fix spacing

2018-04-02 Thread Christian Lütke-Stetzkamp
Fixes checkpatch errors, warnings, checks:
SPACING, LEADING_SPACE, LINE_SPACING

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/board.h |   3 +-
 drivers/staging/mt7621-mmc/dbg.c   |  67 -
 drivers/staging/mt7621-mmc/dbg.h   |  16 +--
 drivers/staging/mt7621-mmc/mt6575_sd.h |  61 
 drivers/staging/mt7621-mmc/sd.c| 245 -
 5 files changed, 197 insertions(+), 195 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/board.h 
b/drivers/staging/mt7621-mmc/board.h
index e8a7a1137653..496357d1ce4d 100644
--- a/drivers/staging/mt7621-mmc/board.h
+++ b/drivers/staging/mt7621-mmc/board.h
@@ -57,7 +57,6 @@ typedef void (*pm_callback_t)(pm_message_t state, void *data);
 #define MSDC_UHS1   (1 << 8)  /* uhs-1 mode support*/
 #define MSDC_DDR(1 << 9)  /* ddr mode support  */
 
-
 #define MSDC_SMPL_RISING(0)
 #define MSDC_SMPL_FALLING   (1)
 
@@ -118,6 +117,7 @@ struct mt3326_gps_hardware {
int (*ext_power_on)(int);
int (*ext_power_off)(int);
 };
+
 extern struct mt3326_gps_hardware mt3326_gps_hw;
 
 /* NAND driver */
@@ -131,6 +131,7 @@ struct mt6575_nand_host_hw {
unsigned int nand_ecc_bytes;
unsigned int nand_ecc_mode;
 };
+
 extern struct mt6575_nand_host_hw mt6575_nand_hw;
 
 #endif /* __ARCH_ARM_MACH_BOARD_H */
diff --git a/drivers/staging/mt7621-mmc/dbg.c b/drivers/staging/mt7621-mmc/dbg.c
index 1c5ceee577f9..215b2fc8c899 100644
--- a/drivers/staging/mt7621-mmc/dbg.c
+++ b/drivers/staging/mt7621-mmc/dbg.c
@@ -51,7 +51,7 @@
 static char cmd_buf[256];
 
 /* for debug zone */
-unsigned int sd_debug_zone[4]={
+unsigned int sd_debug_zone[4] = {
0,
0,
0,
@@ -59,20 +59,21 @@ unsigned int sd_debug_zone[4]={
 };
 
 /* mode select */
-u32 dma_size[4]={
+u32 dma_size[4] = {
512,
512,
512,
512
 };
-msdc_mode drv_mode[4]={
+
+msdc_mode drv_mode[4] = {
MODE_SIZE_DEP, /* using DMA or not depend on the size */
MODE_SIZE_DEP,
MODE_SIZE_DEP,
MODE_SIZE_DEP
 };
 
-#if defined (MT6575_SD_DEBUG)
+#if defined(MT6575_SD_DEBUG)
 /* for driver profile */
 #define TICKS_ONE_MS  (13000)
 u32 gpt_enable = 0;
@@ -90,7 +91,7 @@ void msdc_init_gpt(void)
config.clkSrc = GPT_CLK_SRC_SYS;
config.clkDiv = GPT_CLK_DIV_1;   /* 13MHz GPT6 */
 
-   if (GPT_Config(config) == FALSE )
+   if (GPT_Config(config) == FALSE)
return;
 
GPT_Start(GPT6);
@@ -103,7 +104,7 @@ u32 msdc_time_calc(u32 old_L32, u32 old_H32, u32 new_L32, 
u32 new_H32)
 
if (new_H32 == old_H32) {
ret = new_L32 - old_L32;
-   } else if(new_H32 == (old_H32 + 1)) {
+   } else if (new_H32 == (old_H32 + 1)) {
if (new_L32 > old_L32) {
printk("msdc old_L<0x%x> new_L<0x%x>\n", old_L32, 
new_L32);
}
@@ -129,44 +130,44 @@ void msdc_sdio_profile(struct sdio_profile* result)
/* CMD52 Dump */
cmd = &result->cmd52_rx;
printk("sdio === CMD52 Rx <%d>times tick<%d> Max<%d> Min<%d> 
Aver<%d>\n", cmd->count, cmd->tot_tc,
-  cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count);
+  cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count);
cmd = &result->cmd52_tx;
printk("sdio === CMD52 Tx <%d>times tick<%d> Max<%d> Min<%d> 
Aver<%d>\n", cmd->count, cmd->tot_tc,
-  cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count);
+  cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count);
 
/* CMD53 Rx bytes + block mode */
-   for (i=0; i<512; i++) {
+   for (i = 0; i < 512; i++) {
cmd = &result->cmd53_rx_byte[i];
if (cmd->count) {

printk("sdio<%6d><%3dB>_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, 
cmd->tot_tc,
-  cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
-  cmd->tot_bytes, (cmd->tot_bytes/10)*13 / 
(cmd->tot_tc/10));
+  cmd->max_tc, cmd->min_tc, cmd->tot_tc / 
cmd->count,
+  cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / 
(cmd->tot_tc / 10));
}
}
-   for (i=0; i<100; i++) {
+   for (i = 0; i < 100; i++) {
cmd = &result->cmd53_rx_blk[i];
if (cmd->count) {

printk("sdio<%6d><%3d>B_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, 
cmd->tot_tc,
-  cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
-  cmd->tot_bytes, (cmd->tot_bytes/10)*13 / 
(cmd->tot_tc/10));
+  cmd->max_tc, cmd->min_tc, cmd->tot_tc / 
cmd->count,
+  cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / 
(cmd->tot_tc / 10));
}
}
 
/* CMD53 Tx bytes + block mode */
-  

[PATCH 23/34] staging: mt7621-mmc: Refactor suspend, resume

2018-04-02 Thread Christian Lütke-Stetzkamp
Refactor msdc_drv_{suspend, resume} by adding a new function
msdc_drv_pm, that cleans up the code and removes double code.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 26 +++---
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 4fe378040ce3..c7a00834deca 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -2907,34 +2907,30 @@ static int msdc_drv_remove(struct platform_device *pdev)
 
 /* Fix me: Power Flow */
 #ifdef CONFIG_PM
-static int msdc_drv_suspend(struct platform_device *pdev, pm_message_t state)
+
+static void msdc_drv_pm(struct platform_device *pdev, pm_message state)
 {
-   int ret = 0;
struct mmc_host *mmc = platform_get_drvdata(pdev);
struct msdc_host *host = mmc_priv(mmc);
 
-   if (mmc && state.event == PM_EVENT_SUSPEND && (host->hw->flags & 
MSDC_SYS_SUSPEND)) { /* will set for card */
+   if (mmc && (host->hw->flags & MSDC_SYS_SUSPEND))
msdc_pm(state, (void *)host);
-   }
+}
 
-   return ret;
+static int msdc_drv_suspend(struct platform_device *pdev, pm_message_t state)
+{
+   if (state.event == PM_EVENT_SUSPEND)
+   msdc_drv_pm(pdev, state);
+   return 0;
 }
 
 static int msdc_drv_resume(struct platform_device *pdev)
 {
-   int ret = 0;
-   struct mmc_host *mmc = platform_get_drvdata(pdev);
-   struct msdc_host *host = mmc_priv(mmc);
struct pm_message state;
 
state.event = PM_EVENT_RESUME;
-   if (mmc && (host->hw->flags & MSDC_SYS_SUSPEND)) {/* will set for card 
*/
-   msdc_pm(state, (void *)host);
-   }
-
-   /* This mean WIFI not controller by PM */
-
-   return ret;
+   msdc_drv_pm(pdev, state);
+   return 0;
 }
 #endif
 
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/34] staging: mt7621-mmc: Fix indent for board.h

2018-04-02 Thread Christian Lütke-Stetzkamp
This fixes the indentaions in the file board.h

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/board.h | 68 +++---
 1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/board.h 
b/drivers/staging/mt7621-mmc/board.h
index 6179ac9714d7..e8a7a1137653 100644
--- a/drivers/staging/mt7621-mmc/board.h
+++ b/drivers/staging/mt7621-mmc/board.h
@@ -68,43 +68,43 @@ typedef void (*pm_callback_t)(pm_message_t state, void 
*data);
 #define MSDC_RST_PIN(4)
 
 enum {
-MSDC_CLKSRC_48MHZ = 0,
+   MSDC_CLKSRC_48MHZ = 0,
 //MSDC_CLKSRC_26MHZ = 0,
 //MSDC_CLKSRC_197MHZ = 1,
 //MSDC_CLKSRC_208MHZ = 2
 };
 
 struct msdc_hw {
-unsigned char  clk_src;  /* host clock source */
-unsigned char  cmd_edge; /* command latch edge */
-unsigned char  data_edge;/* data latch edge */
-unsigned char  clk_drv;  /* clock pad driving */
-unsigned char  cmd_drv;  /* command pad driving */
-unsigned char  dat_drv;  /* data pad driving */
-unsigned long  flags;/* hardware capability flags */
-unsigned long  data_pins;/* data pins */
-unsigned long  data_offset;  /* data address offset */
-
-/* config gpio pull mode */
-void (*config_gpio_pin)(int type, int pull);
-
-/* external power control for card */
-void (*ext_power_on)(void);
-void (*ext_power_off)(void);
-
-/* external sdio irq operations */
-void (*request_sdio_eirq)(sdio_irq_handler_t sdio_irq_handler, void *data);
-void (*enable_sdio_eirq)(void);
-void (*disable_sdio_eirq)(void);
-
-/* external cd irq operations */
-void (*request_cd_eirq)(sdio_irq_handler_t cd_irq_handler, void *data);
-void (*enable_cd_eirq)(void);
-void (*disable_cd_eirq)(void);
-int  (*get_cd_status)(void);
-
-/* power management callback for external module */
-void (*register_pm)(pm_callback_t pm_cb, void *data);
+   unsigned char  clk_src;  /* host clock source */
+   unsigned char  cmd_edge; /* command latch edge */
+   unsigned char  data_edge;/* data latch edge */
+   unsigned char  clk_drv;  /* clock pad driving */
+   unsigned char  cmd_drv;  /* command pad driving */
+   unsigned char  dat_drv;  /* data pad driving */
+   unsigned long  flags;/* hardware capability flags */
+   unsigned long  data_pins;/* data pins */
+   unsigned long  data_offset;  /* data address offset */
+
+   /* config gpio pull mode */
+   void (*config_gpio_pin)(int type, int pull);
+
+   /* external power control for card */
+   void (*ext_power_on)(void);
+   void (*ext_power_off)(void);
+
+   /* external sdio irq operations */
+   void (*request_sdio_eirq)(sdio_irq_handler_t sdio_irq_handler, void 
*data);
+   void (*enable_sdio_eirq)(void);
+   void (*disable_sdio_eirq)(void);
+
+   /* external cd irq operations */
+   void (*request_cd_eirq)(sdio_irq_handler_t cd_irq_handler, void *data);
+   void (*enable_cd_eirq)(void);
+   void (*disable_cd_eirq)(void);
+   int  (*get_cd_status)(void);
+
+   /* power management callback for external module */
+   void (*register_pm)(pm_callback_t pm_cb, void *data);
 };
 
 extern struct msdc_hw msdc0_hw;
@@ -115,14 +115,14 @@ extern struct msdc_hw msdc3_hw;
 /*GPS driver*/
 #define GPS_FLAG_FORCE_OFF  0x0001
 struct mt3326_gps_hardware {
-int (*ext_power_on)(int);
-int (*ext_power_off)(int);
+   int (*ext_power_on)(int);
+   int (*ext_power_off)(int);
 };
 extern struct mt3326_gps_hardware mt3326_gps_hw;
 
 /* NAND driver */
 struct mt6575_nand_host_hw {
-unsigned int nfi_bus_width;/* NFI_BUS_WIDTH */
+   unsigned int nfi_bus_width; /* NFI_BUS_WIDTH */
unsigned int nfi_access_timing; /* NFI_ACCESS_TIMING */
unsigned int nfi_cs_num;/* NFI_CS_NUM */
unsigned int nand_sec_size; /* NAND_SECTOR_SIZE */
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 17/34] staging: mt7621-mmc: Remove redundant driver owner assignment

2018-04-02 Thread Christian Lütke-Stetzkamp
Remove the owner assignment form the platform driver as
platform_driver_register() already initializes the owner.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 3be653dc1d4a..ed89ec9733a4 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -2972,7 +2972,6 @@ static struct platform_driver mt_msdc_driver = {
 #endif
.driver  = {
.name  = DRV_NAME,
-   .owner = THIS_MODULE,
.of_match_table = mt7620_sdhci_match,
},
 };
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 27/34] staging: mt7621-mmc: Fix bug on dma_alloc_coherent fail

2018-04-02 Thread Christian Lütke-Stetzkamp
In case of dma_alloc_coherent failing the current code just called
BUG_ON. By adding error handling for that case this can be avoided.
This also fixes a memory leek in case of a fail later on in the probe
function.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 9cc8f4c8ef28..0d4877483e54 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -2787,7 +2787,10 @@ static int msdc_drv_probe(struct platform_device *pdev)
/* using dma_alloc_coherent*/  /* todo: using 1, for all 4 slots */
host->dma.gpd = dma_alloc_coherent(NULL, MAX_GPD_NUM * sizeof(struct 
gpt), &host->dma.gpd_addr, GFP_KERNEL);
host->dma.bd =  dma_alloc_coherent(NULL, MAX_BD_NUM  * sizeof(struct 
bd),  &host->dma.bd_addr,  GFP_KERNEL);
-   BUG_ON((!host->dma.gpd) || (!host->dma.bd));
+   if (!host->dma.gdp || !host->dma.bd) {
+   ret = -ENOMEM;
+   goto release_mem;
+   }
msdc_init_gpd_bd(host, &host->dma);
/*for emmc*/
msdc_6575_host[pdev->id] = host;
@@ -2855,6 +2858,13 @@ static int msdc_drv_probe(struct platform_device *pdev)
cancel_delayed_work_sync(&host->card_delaywork);
 #endif
 
+release_mem:
+   if (host->dma.gpd)
+   dma_free_coherent(NULL, MAX_GPD_NUM * sizeof(struct gpt),
+ host->dma.gpd, host->dma.gpd_addr);
+   if (host->dma.bd)
+   dma_free_coherent(NULL, MAX_BD_NUM * sizeof(struct bd),
+ host->dma.bd, host->dma.bd_addr);
 host_free:
mmc_free_host(mmc);
 
-- 
2.16.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 15/15] ARM: pxa: change SSP DMA channels allocation

2018-04-02 Thread kbuild test robot
Hi Robert,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.16]
[cannot apply to arm-soc/for-next next-20180329]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Robert-Jarzmik/ARM-pxa-switch-to-DMA-slave-maps/20180402-233029
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

>> arch/arm/plat-pxa/ssp.c:19:10: fatal error: mach/audio.h: No such file or 
>> directory
#include 
 ^~
   compilation terminated.

vim +19 arch/arm/plat-pxa/ssp.c

  > 19  #include 
20  #include 
21  #include 
22  #include 
23  #include 
24  #include 
25  #include 
26  #include 
27  #include 
28  #include 
29  #include 
30  #include 
31  #include 
32  #include 
33  #include 
34  #include 
35  #include 
36  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: mt7621-eth: Fix sparse warning in ethtool.c

2018-04-02 Thread NeilBrown
On Mon, Apr 02 2018, Christian Lütke-Stetzkamp wrote:

> On Mon, Apr 02, 2018 at 01:41:33PM +1000, NeilBrown wrote:
>> On Mon, Apr 02 2018, Sean Wang wrote:
>> > Hi, Neil
>> >
>> > Forgive me I cannot find the cover letter in the original series in my
>> > mailbox to make a reply, so I rudely made here just letting you know
>> > something good to the growth of mt7621 support in upstream.
>> >
>> > If so, it would become a bit easier for me that maybe I could give a
>> > hand for migrating these staging driver for mt7621 to mainline. I
>> > thought mmc, pci, ethernet, gsw and hsdma all could probably reuse the
>> > current mainline code.
>> 
>> I agree that it is quite likely that several of these drivers could and
>> should reuse current mainline code.  I would love to have some help
>> sorting this out.  I won't have much time myself to dig into it for
>> several weeks, but I'll make time to review and test any code that is
>> contributed.
>> 
>> Thanks,
>> NeilBrown
>
> Hi,
>
> I have started a patch series for the mmc driver that is currently in
> staging, that makes some of the first cleanups (whitespace, indent,..)
> and also starts to clean up the code, to make the similarities and
> differences to the current mainline code clearer. The series is far
> from being complete, but I think I'm going to send it out today, so
> you can look and comment.
>
> I would suggest that we continue cleaning the code that is currently
> in staging to remove the dead parts and make the diff to the mainline
> code obvious. Do you agree with that proposal or do you suggest a
> different plan?

I think this is an excellent plan - thanks for doing it.
I'll hopefully look over your patches today and send any comments.

Thanks,
NeilBrown


signature.asc
Description: PGP signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 71/75] staging: ks7010: Remove dummy address set.

2018-04-02 Thread Dan Carpenter
On Sat, Mar 31, 2018 at 11:46:40AM +0300, Dan Carpenter wrote:
> On Fri, Mar 30, 2018 at 11:08:51PM -0700, Quytelda Kahja wrote:
> > Setting a dummy address during the driver probe is not necessary.
> > The dev_addr field is already zeroed out from alloc_etherdev().
> > 
> > Signed-off-by: Quytelda Kahja 
> > ---
> >  drivers/staging/ks7010/ks_wlan_net.c | 6 --
> >  1 file changed, 6 deletions(-)
> > 
> > diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
> > b/drivers/staging/ks7010/ks_wlan_net.c
> > index 5c5569000fce..afbc472baa05 100644
> > --- a/drivers/staging/ks7010/ks_wlan_net.c
> > +++ b/drivers/staging/ks7010/ks_wlan_net.c
> > @@ -2852,9 +2852,6 @@ int ks_wlan_close(struct net_device *dev)
> >  /* Operational parameters that usually are not changed. */
> >  /* Time in jiffies before concluding the transmitter is hung. */
> >  #define TX_TIMEOUT  (3 * HZ)
> > -static const unsigned char dummy_addr[] = {
> > -   0x00, 0x0b, 0xe3, 0x00, 0x00, 0x00
> 
> Of course, this isn't a zero address.  Do we know why they chose this
> particular address?  I was expecting it to be zero from the patch
> description.
> 
> regards,
> dan carpenter
> 

Quytelda asked me about this patch privately.  When I originally read
the commit description, I basically saw that we're removing code because
the dev_addr was already initialized to zero.  But actaully it says that
we're just removing nonsense code.

So that's fine.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 02/15] ARM: pxa: add dma slave map

2018-04-02 Thread Arnd Bergmann
On Mon, Apr 2, 2018 at 4:26 PM, Robert Jarzmik  wrote:
> +
> +static const struct dma_slave_map pxa_slave_map[] = {
> +   /* PXA25x, PXA27x and PXA3xx common entries */
> +   { "pxa-pcm-audio", "ac97_mic_mono", PDMA_FILTER_PARAM(LOWEST, 8) },
> +   { "pxa-pcm-audio", "ac97_aux_mono_in", PDMA_FILTER_PARAM(LOWEST, 9) },
> +   { "pxa-pcm-audio", "ac97_aux_mono_out", PDMA_FILTER_PARAM(LOWEST, 10) 
> },
> +   { "pxa-pcm-audio", "ac97_stereo_in", PDMA_FILTER_PARAM(LOWEST, 11) },
> +   { "pxa-pcm-audio", "ac97_stereo_out", PDMA_FILTER_PARAM(LOWEST, 12) },
> +   { "pxa-pcm-audio", "ssp1_rx", PDMA_FILTER_PARAM(LOWEST, 13) },
> +   { "pxa-pcm-audio", "ssp1_tx", PDMA_FILTER_PARAM(LOWEST, 14) },
> +   { "pxa-pcm-audio", "ssp2_rx", PDMA_FILTER_PARAM(LOWEST, 15) },
> +   { "pxa-pcm-audio", "ssp2_tx", PDMA_FILTER_PARAM(LOWEST, 16) },
> +   { "pxa2xx-ir", "rx", PDMA_FILTER_PARAM(LOWEST, 17) },
> +   { "pxa2xx-ir", "tx", PDMA_FILTER_PARAM(LOWEST, 18) },
> +   { "pxa2xx-mci.0", "rx", PDMA_FILTER_PARAM(LOWEST, 21) },
> +   { "pxa2xx-mci.0", "tx", PDMA_FILTER_PARAM(LOWEST, 22) },


> +   { "smc911x.0", "rx", PDMA_FILTER_PARAM(LOWEST, -1) },
> +   { "smc911x.0", "tx", PDMA_FILTER_PARAM(LOWEST, -1) },
> +   { "smc91x.0", "data", PDMA_FILTER_PARAM(LOWEST, -1) },

This one is interesting, as you are dealing with an off-chip device,
and the channel number is '-'1. How does this even work? Does it
mean

> +   /* PXA25x specific map */
> +   { "pxa25x-ssp.0", "rx", PDMA_FILTER_PARAM(LOWEST, 13) },
> +   { "pxa25x-ssp.0", "tx", PDMA_FILTER_PARAM(LOWEST, 14) },
> +   { "pxa25x-nssp.1", "rx", PDMA_FILTER_PARAM(LOWEST, 15) },
> +   { "pxa25x-nssp.1", "tx", PDMA_FILTER_PARAM(LOWEST, 16) },
> +   { "pxa25x-nssp.2", "rx", PDMA_FILTER_PARAM(LOWEST, 23) },
> +   { "pxa25x-nssp.2", "tx", PDMA_FILTER_PARAM(LOWEST, 24) },
> +   { "pxa-pcm-audio", "nssp2_rx", PDMA_FILTER_PARAM(LOWEST, 15) },
> +   { "pxa-pcm-audio", "nssp2_tx", PDMA_FILTER_PARAM(LOWEST, 16) },
> +   { "pxa-pcm-audio", "nssp3_rx", PDMA_FILTER_PARAM(LOWEST, 23) },
> +   { "pxa-pcm-audio", "nssp3_tx", PDMA_FILTER_PARAM(LOWEST, 24) },
> +
> +   /* PXA27x specific map */
> +   { "pxa-pcm-audio", "ssp3_rx", PDMA_FILTER_PARAM(LOWEST, 66) },
> +   { "pxa-pcm-audio", "ssp3_tx", PDMA_FILTER_PARAM(LOWEST, 67) },
> +   { "pxa27x-camera.0", "CI_Y", PDMA_FILTER_PARAM(HIGHEST, 68) },
> +   { "pxa27x-camera.0", "CI_U", PDMA_FILTER_PARAM(HIGHEST, 69) },
> +   { "pxa27x-camera.0", "CI_V", PDMA_FILTER_PARAM(HIGHEST, 70) },
> +
> +   /* PXA3xx specific map */
> +   { "pxa-pcm-audio", "ssp4_rx", PDMA_FILTER_PARAM(LOWEST, 2) },
> +   { "pxa-pcm-audio", "ssp4_tx", PDMA_FILTER_PARAM(LOWEST, 3) },
> +   { "pxa2xx-mci.1", "rx", PDMA_FILTER_PARAM(LOWEST, 93) },
> +   { "pxa2xx-mci.1", "tx", PDMA_FILTER_PARAM(LOWEST, 94) },
> +   { "pxa3xx-nand", "data", PDMA_FILTER_PARAM(LOWEST, 97) },
> +   { "pxa2xx-mci.2", "rx", PDMA_FILTER_PARAM(LOWEST, 100) },
> +   { "pxa2xx-mci.2", "tx", PDMA_FILTER_PARAM(LOWEST, 101) },
> +};

Since more than half the entries in here are chip specific, maybe it would be
better to split that table into three and have a copy for each one in
arch/arm/mach-pxa/pxa{25x.27x.3xx}.c? Does that mean it's actually
a memory-to-memory transfer with a device being on the external
SRAM interface?

   Arnd
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: mt7621-eth: Fix sparse warning in ethtool.c

2018-04-02 Thread Christian Lütke-Stetzkamp
On Mon, Apr 02, 2018 at 01:41:33PM +1000, NeilBrown wrote:
> On Mon, Apr 02 2018, Sean Wang wrote:
> > Hi, Neil
> >
> > Forgive me I cannot find the cover letter in the original series in my
> > mailbox to make a reply, so I rudely made here just letting you know
> > something good to the growth of mt7621 support in upstream.
> >
> > If so, it would become a bit easier for me that maybe I could give a
> > hand for migrating these staging driver for mt7621 to mainline. I
> > thought mmc, pci, ethernet, gsw and hsdma all could probably reuse the
> > current mainline code.
> 
> I agree that it is quite likely that several of these drivers could and
> should reuse current mainline code.  I would love to have some help
> sorting this out.  I won't have much time myself to dig into it for
> several weeks, but I'll make time to review and test any code that is
> contributed.
> 
> Thanks,
> NeilBrown

Hi,

I have started a patch series for the mmc driver that is currently in
staging, that makes some of the first cleanups (whitespace, indent,..)
and also starts to clean up the code, to make the similarities and
differences to the current mainline code clearer. The series is far
from being complete, but I think I'm going to send it out today, so
you can look and comment.

I would suggest that we continue cleaning the code that is currently
in staging to remove the dead parts and make the diff to the mainline
code obvious. Do you agree with that proposal or do you suggest a
different plan?

Christian
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 01/75] staging: ks7010: Use the ARRAY_SIZE() macro to calculate array sizes.

2018-04-02 Thread Dan Carpenter
On Sat, Mar 31, 2018 at 07:12:53AM -0700, Joe Perches wrote:
> On Sat, 2018-03-31 at 11:41 +0300, Dan Carpenter wrote:
> > On Fri, Mar 30, 2018 at 11:36:13PM -0700, Joe Perches wrote:
> > > On Fri, 2018-03-30 at 23:07 -0700, Quytelda Kahja wrote:
> > > > This macro, provided in 'linux/kernel.h', will calculate the size
> > > > more succinctly than a division operation.
> > > 
> > > It's nice that you send patches, but please try to send a
> > > cover letter with your patch series.
> > > 
> > 
> > There are obviously times when a cover letter is required but what's the
> > point of that for this particular series?
> 
> practice
> 

It really pisses me off to see patch submitters get assign busy work
for no reason.  This is not school and these are not your students.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/15] ARM: pxa: switch to DMA slave maps

2018-04-02 Thread Robert Jarzmik
Hi,

This serie is aimed at removing the dmaengine slave compat use, and transfer
knowledge of the DMA requestors into architecture code.

This was discussed/advised by Arnd a couple of years back, it's almost time.

The serie is divided in 3 phasees :
 - phase 1 : patch 1/15 and patch 2/15
   => this is the preparation work
 - phase 2 : patches 3/15 .. 10/15
   => this is the switch of all the drivers
   => this one will require either an Ack of the maintainers or be taken by them
  once phase 1 is merged
 - phase 3 : patches 11/15
   => this is the last part, cleanup and removal of export of the DMA filter
  function

As this looks like a patch bomb, each maintainer expressing for his tree either
an Ack or "I want to take through my tree" will be spared in the next iterations
of this serie.

Several of these changes have been tested on actual hardware, including :
 - pxamci
 - pxa_camera
 - smc*
 - ASoC and SSP

Happy review.

Robert Jarzmik (15):
  dmaengine: pxa: use a dma slave map
  ARM: pxa: add dma slave map
  mmc: pxamci: remove the dmaengine compat need
  media: pxa_camera: remove the dmaengine compat need
  mtd: nand: pxa3xx: remove the dmaengine compat need
  net: smc911x: remove the dmaengine compat need
  net: smc91x: remove the dmaengine compat need
  ASoC: pxa: remove the dmaengine compat need
  net: irda: pxaficp_ir: remove the dmaengine compat need
  ata: pata_pxa: remove the dmaengine compat need
  dmaengine: pxa: document pxad_param
  dmaengine: pxa: make the filter function internal
  ARM: pxa: remove the DMA IO resources
  ARM: pxa: change SSP devices allocation
  ARM: pxa: change SSP DMA channels allocation

 arch/arm/mach-pxa/devices.c   | 269 ++
 arch/arm/mach-pxa/devices.h   |  14 +-
 arch/arm/mach-pxa/include/mach/audio.h|  12 ++
 arch/arm/mach-pxa/pxa25x.c|   4 +-
 arch/arm/mach-pxa/pxa27x.c|   4 +-
 arch/arm/mach-pxa/pxa3xx.c|   5 +-
 arch/arm/plat-pxa/ssp.c   |  50 +-
 drivers/ata/pata_pxa.c|  10 +-
 drivers/dma/pxa_dma.c |  13 +-
 drivers/media/platform/pxa_camera.c   |  22 +--
 drivers/mmc/host/pxamci.c |  29 +---
 drivers/mtd/nand/pxa3xx_nand.c|  10 +-
 drivers/net/ethernet/smsc/smc911x.c   |  16 +-
 drivers/net/ethernet/smsc/smc91x.c|  12 +-
 drivers/net/ethernet/smsc/smc91x.h|   1 -
 drivers/staging/irda/drivers/pxaficp_ir.c |  14 +-
 include/linux/dma/pxa-dma.h   |  20 +--
 include/linux/platform_data/mmp_dma.h |   4 +
 include/linux/pxa2xx_ssp.h|   4 +-
 sound/arm/pxa2xx-ac97.c   |  14 +-
 sound/arm/pxa2xx-pcm-lib.c|   6 +-
 sound/soc/pxa/pxa-ssp.c   |   5 +-
 sound/soc/pxa/pxa2xx-ac97.c   |  32 +---
 23 files changed, 196 insertions(+), 374 deletions(-)

-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/15] ARM: pxa: add dma slave map

2018-04-02 Thread Robert Jarzmik
In order to remove the specific knowledge of the dma mapping from PXA
drivers, add a default slave map for pxa architectures.

This is the first step, and once all drivers are converted,
pxad_filter_fn() will be made static, and the DMA resources removed from
device.c.

Signed-off-by: Robert Jarzmik 
Reported-by: Arnd Bergmann 
---
 arch/arm/mach-pxa/devices.c | 55 +
 1 file changed, 55 insertions(+)

diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index d7c9a8476d57..da67ebe9a7d5 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -4,6 +4,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -1202,9 +1204,62 @@ void __init pxa2xx_set_spi_info(unsigned id, struct 
pxa2xx_spi_master *info)
platform_device_add(pd);
 }
 
+#define PDMA_FILTER_PARAM(_prio, _requestor) (&(struct pxad_param) { \
+   .prio = PXAD_PRIO_##_prio, .drcmr = _requestor })
+
+static const struct dma_slave_map pxa_slave_map[] = {
+   /* PXA25x, PXA27x and PXA3xx common entries */
+   { "pxa-pcm-audio", "ac97_mic_mono", PDMA_FILTER_PARAM(LOWEST, 8) },
+   { "pxa-pcm-audio", "ac97_aux_mono_in", PDMA_FILTER_PARAM(LOWEST, 9) },
+   { "pxa-pcm-audio", "ac97_aux_mono_out", PDMA_FILTER_PARAM(LOWEST, 10) },
+   { "pxa-pcm-audio", "ac97_stereo_in", PDMA_FILTER_PARAM(LOWEST, 11) },
+   { "pxa-pcm-audio", "ac97_stereo_out", PDMA_FILTER_PARAM(LOWEST, 12) },
+   { "pxa-pcm-audio", "ssp1_rx", PDMA_FILTER_PARAM(LOWEST, 13) },
+   { "pxa-pcm-audio", "ssp1_tx", PDMA_FILTER_PARAM(LOWEST, 14) },
+   { "pxa-pcm-audio", "ssp2_rx", PDMA_FILTER_PARAM(LOWEST, 15) },
+   { "pxa-pcm-audio", "ssp2_tx", PDMA_FILTER_PARAM(LOWEST, 16) },
+   { "pxa2xx-ir", "rx", PDMA_FILTER_PARAM(LOWEST, 17) },
+   { "pxa2xx-ir", "tx", PDMA_FILTER_PARAM(LOWEST, 18) },
+   { "pxa2xx-mci.0", "rx", PDMA_FILTER_PARAM(LOWEST, 21) },
+   { "pxa2xx-mci.0", "tx", PDMA_FILTER_PARAM(LOWEST, 22) },
+   { "smc911x.0", "rx", PDMA_FILTER_PARAM(LOWEST, -1) },
+   { "smc911x.0", "tx", PDMA_FILTER_PARAM(LOWEST, -1) },
+   { "smc91x.0", "data", PDMA_FILTER_PARAM(LOWEST, -1) },
+
+   /* PXA25x specific map */
+   { "pxa25x-ssp.0", "rx", PDMA_FILTER_PARAM(LOWEST, 13) },
+   { "pxa25x-ssp.0", "tx", PDMA_FILTER_PARAM(LOWEST, 14) },
+   { "pxa25x-nssp.1", "rx", PDMA_FILTER_PARAM(LOWEST, 15) },
+   { "pxa25x-nssp.1", "tx", PDMA_FILTER_PARAM(LOWEST, 16) },
+   { "pxa25x-nssp.2", "rx", PDMA_FILTER_PARAM(LOWEST, 23) },
+   { "pxa25x-nssp.2", "tx", PDMA_FILTER_PARAM(LOWEST, 24) },
+   { "pxa-pcm-audio", "nssp2_rx", PDMA_FILTER_PARAM(LOWEST, 15) },
+   { "pxa-pcm-audio", "nssp2_tx", PDMA_FILTER_PARAM(LOWEST, 16) },
+   { "pxa-pcm-audio", "nssp3_rx", PDMA_FILTER_PARAM(LOWEST, 23) },
+   { "pxa-pcm-audio", "nssp3_tx", PDMA_FILTER_PARAM(LOWEST, 24) },
+
+   /* PXA27x specific map */
+   { "pxa-pcm-audio", "ssp3_rx", PDMA_FILTER_PARAM(LOWEST, 66) },
+   { "pxa-pcm-audio", "ssp3_tx", PDMA_FILTER_PARAM(LOWEST, 67) },
+   { "pxa27x-camera.0", "CI_Y", PDMA_FILTER_PARAM(HIGHEST, 68) },
+   { "pxa27x-camera.0", "CI_U", PDMA_FILTER_PARAM(HIGHEST, 69) },
+   { "pxa27x-camera.0", "CI_V", PDMA_FILTER_PARAM(HIGHEST, 70) },
+
+   /* PXA3xx specific map */
+   { "pxa-pcm-audio", "ssp4_rx", PDMA_FILTER_PARAM(LOWEST, 2) },
+   { "pxa-pcm-audio", "ssp4_tx", PDMA_FILTER_PARAM(LOWEST, 3) },
+   { "pxa2xx-mci.1", "rx", PDMA_FILTER_PARAM(LOWEST, 93) },
+   { "pxa2xx-mci.1", "tx", PDMA_FILTER_PARAM(LOWEST, 94) },
+   { "pxa3xx-nand", "data", PDMA_FILTER_PARAM(LOWEST, 97) },
+   { "pxa2xx-mci.2", "rx", PDMA_FILTER_PARAM(LOWEST, 100) },
+   { "pxa2xx-mci.2", "tx", PDMA_FILTER_PARAM(LOWEST, 101) },
+};
+
 static struct mmp_dma_platdata pxa_dma_pdata = {
.dma_channels   = 0,
.nb_requestors  = 0,
+   .slave_map  = pxa_slave_map,
+   .slave_map_cnt  = ARRAY_SIZE(pxa_slave_map),
 };
 
 static struct resource pxa_dma_resource[] = {
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/15] mtd: nand: pxa3xx: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
From: Robert Jarzmik 

As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik 
---
 drivers/mtd/nand/pxa3xx_nand.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index d1979c7dbe7e..4a56a0aef5b1 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -1518,8 +1518,6 @@ static int pxa3xx_nand_init_buff(struct pxa3xx_nand_info 
*info)
 {
struct platform_device *pdev = info->pdev;
struct dma_slave_config config;
-   dma_cap_mask_t mask;
-   struct pxad_param param;
int ret;
 
info->data_buff = kmalloc(info->buf_size, GFP_KERNEL);
@@ -1533,13 +1531,7 @@ static int pxa3xx_nand_init_buff(struct pxa3xx_nand_info 
*info)
return ret;
 
sg_init_one(&info->sg, info->data_buff, info->buf_size);
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = info->drcmr_dat;
-   info->dma_chan = dma_request_slave_channel_compat(mask, pxad_filter_fn,
- ¶m, &pdev->dev,
- "data");
+   info->dma_chan = dma_request_slave_channel(&pdev->dev, "data");
if (!info->dma_chan) {
dev_err(&pdev->dev, "unable to request data dma channel\n");
return -ENODEV;
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/15] media: pxa_camera: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
From: Robert Jarzmik 

As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik 
---
 drivers/media/platform/pxa_camera.c | 22 +++---
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/media/platform/pxa_camera.c 
b/drivers/media/platform/pxa_camera.c
index c71a00736541..4c82d1880753 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -2357,8 +2357,6 @@ static int pxa_camera_probe(struct platform_device *pdev)
.src_maxburst = 8,
.direction = DMA_DEV_TO_MEM,
};
-   dma_cap_mask_t mask;
-   struct pxad_param params;
char clk_name[V4L2_CLK_NAME_SIZE];
int irq;
int err = 0, i;
@@ -2432,34 +2430,20 @@ static int pxa_camera_probe(struct platform_device 
*pdev)
pcdev->base = base;
 
/* request dma */
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   dma_cap_set(DMA_PRIVATE, mask);
-
-   params.prio = 0;
-   params.drcmr = 68;
-   pcdev->dma_chans[0] =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-¶ms, &pdev->dev, "CI_Y");
+   pcdev->dma_chans[0] = dma_request_slave_channel(&pdev->dev, "CI_Y");
if (!pcdev->dma_chans[0]) {
dev_err(&pdev->dev, "Can't request DMA for Y\n");
return -ENODEV;
}
 
-   params.drcmr = 69;
-   pcdev->dma_chans[1] =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-¶ms, &pdev->dev, "CI_U");
+   pcdev->dma_chans[1] = dma_request_slave_channel(&pdev->dev, "CI_U");
if (!pcdev->dma_chans[1]) {
dev_err(&pdev->dev, "Can't request DMA for Y\n");
err = -ENODEV;
goto exit_free_dma_y;
}
 
-   params.drcmr = 70;
-   pcdev->dma_chans[2] =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-¶ms, &pdev->dev, "CI_V");
+   pcdev->dma_chans[2] = dma_request_slave_channel(&pdev->dev, "CI_V");
if (!pcdev->dma_chans[2]) {
dev_err(&pdev->dev, "Can't request DMA for V\n");
err = -ENODEV;
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/15] mmc: pxamci: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik 
---
 drivers/mmc/host/pxamci.c | 29 +++--
 1 file changed, 3 insertions(+), 26 deletions(-)

diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index c763b404510f..6c94474e36f4 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -24,7 +24,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -637,10 +636,8 @@ static int pxamci_probe(struct platform_device *pdev)
 {
struct mmc_host *mmc;
struct pxamci_host *host = NULL;
-   struct resource *r, *dmarx, *dmatx;
-   struct pxad_param param_rx, param_tx;
+   struct resource *r;
int ret, irq, gpio_cd = -1, gpio_ro = -1, gpio_power = -1;
-   dma_cap_mask_t mask;
 
ret = pxamci_of_init(pdev);
if (ret)
@@ -739,34 +736,14 @@ static int pxamci_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, mmc);
 
-   if (!pdev->dev.of_node) {
-   dmarx = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-   dmatx = platform_get_resource(pdev, IORESOURCE_DMA, 1);
-   if (!dmarx || !dmatx) {
-   ret = -ENXIO;
-   goto out;
-   }
-   param_rx.prio = PXAD_PRIO_LOWEST;
-   param_rx.drcmr = dmarx->start;
-   param_tx.prio = PXAD_PRIO_LOWEST;
-   param_tx.drcmr = dmatx->start;
-   }
-
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-
-   host->dma_chan_rx =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-¶m_rx, &pdev->dev, "rx");
+   host->dma_chan_rx = dma_request_slave_channel(&pdev->dev, "rx");
if (host->dma_chan_rx == NULL) {
dev_err(&pdev->dev, "unable to request rx dma channel\n");
ret = -ENODEV;
goto out;
}
 
-   host->dma_chan_tx =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-¶m_tx,  &pdev->dev, "tx");
+   host->dma_chan_tx = dma_request_slave_channel(&pdev->dev, "tx");
if (host->dma_chan_tx == NULL) {
dev_err(&pdev->dev, "unable to request tx dma channel\n");
ret = -ENODEV;
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/15] dmaengine: pxa: use a dma slave map

2018-04-02 Thread Robert Jarzmik
In order to remove the specific knowledge of the dma mapping from PXA
drivers, add a default slave map for pxa architectures.

This won't impact MMP architecture, but is aimed only at all PXA boards.

This is the first step, and once all drivers are converted,
pxad_filter_fn() will be made static, and the DMA resources removed from
device.c.

Signed-off-by: Robert Jarzmik 
Reported-by: Arnd Bergmann 
---
 drivers/dma/pxa_dma.c | 10 +-
 include/linux/platform_data/mmp_dma.h |  4 
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index b53fb618bbf6..9505334f9c6e 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -179,6 +179,8 @@ static unsigned int pxad_drcmr(unsigned int line)
return 0x1000 + line * 4;
 }
 
+bool pxad_filter_fn(struct dma_chan *chan, void *param);
+
 /*
  * Debug fs
  */
@@ -1396,9 +1398,10 @@ static int pxad_probe(struct platform_device *op)
 {
struct pxad_device *pdev;
const struct of_device_id *of_id;
+   const struct dma_slave_map *slave_map = NULL;
struct mmp_dma_platdata *pdata = dev_get_platdata(&op->dev);
struct resource *iores;
-   int ret, dma_channels = 0, nb_requestors = 0;
+   int ret, dma_channels = 0, nb_requestors = 0, slave_map_cnt = 0;
const enum dma_slave_buswidth widths =
DMA_SLAVE_BUSWIDTH_1_BYTE   | DMA_SLAVE_BUSWIDTH_2_BYTES |
DMA_SLAVE_BUSWIDTH_4_BYTES;
@@ -1429,6 +1432,8 @@ static int pxad_probe(struct platform_device *op)
} else if (pdata && pdata->dma_channels) {
dma_channels = pdata->dma_channels;
nb_requestors = pdata->nb_requestors;
+   slave_map = pdata->slave_map;
+   slave_map_cnt = pdata->slave_map_cnt;
} else {
dma_channels = 32;  /* default 32 channel */
}
@@ -1440,6 +1445,9 @@ static int pxad_probe(struct platform_device *op)
pdev->slave.device_prep_dma_memcpy = pxad_prep_memcpy;
pdev->slave.device_prep_slave_sg = pxad_prep_slave_sg;
pdev->slave.device_prep_dma_cyclic = pxad_prep_dma_cyclic;
+   pdev->slave.filter.map = slave_map;
+   pdev->slave.filter.mapcnt = slave_map_cnt;
+   pdev->slave.filter.fn = pxad_filter_fn;
 
pdev->slave.copy_align = PDMA_ALIGNMENT;
pdev->slave.src_addr_widths = widths;
diff --git a/include/linux/platform_data/mmp_dma.h 
b/include/linux/platform_data/mmp_dma.h
index d1397c8ed94e..6397b9c8149a 100644
--- a/include/linux/platform_data/mmp_dma.h
+++ b/include/linux/platform_data/mmp_dma.h
@@ -12,9 +12,13 @@
 #ifndef MMP_DMA_H
 #define MMP_DMA_H
 
+struct dma_slave_map;
+
 struct mmp_dma_platdata {
int dma_channels;
int nb_requestors;
+   int slave_map_cnt;
+   const struct dma_slave_map *slave_map;
 };
 
 #endif /* MMP_DMA_H */
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/15] ASoC: pxa: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik 
---
 sound/arm/pxa2xx-ac97.c | 14 ++
 sound/arm/pxa2xx-pcm-lib.c  |  6 +++---
 sound/soc/pxa/pxa2xx-ac97.c | 32 +---
 3 files changed, 10 insertions(+), 42 deletions(-)

diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index 4bc244c40f80..236a63cdaf9f 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -63,28 +63,18 @@ static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
.reset  = pxa2xx_ac97_legacy_reset,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_out_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 12,
-};
-
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_out = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_out",
.maxburst   = 32,
-   .filter_data= &pxa2xx_ac97_pcm_out_req,
-};
-
-static struct pxad_param pxa2xx_ac97_pcm_in_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 11,
 };
 
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_in = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_in",
.maxburst   = 32,
-   .filter_data= &pxa2xx_ac97_pcm_in_req,
 };
 
 static struct snd_pcm *pxa2xx_ac97_pcm;
diff --git a/sound/arm/pxa2xx-pcm-lib.c b/sound/arm/pxa2xx-pcm-lib.c
index e8da3b8ee721..cbfaba60b79a 100644
--- a/sound/arm/pxa2xx-pcm-lib.c
+++ b/sound/arm/pxa2xx-pcm-lib.c
@@ -125,9 +125,9 @@ int __pxa2xx_pcm_open(struct snd_pcm_substream *substream)
if (ret < 0)
return ret;
 
-   return snd_dmaengine_pcm_open_request_chan(substream,
-   pxad_filter_fn,
-   dma_params->filter_data);
+   return snd_dmaengine_pcm_open(
+   substream, dma_request_slave_channel(rtd->platform->dev,
+dma_params->chan_name));
 }
 EXPORT_SYMBOL(__pxa2xx_pcm_open);
 
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index 803818aabee9..1b41c0f2a8fb 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -68,61 +68,39 @@ static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
.reset  = pxa2xx_ac97_cold_reset,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_stereo_in_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 11,
-};
-
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_in = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_in",
.maxburst   = 32,
-   .filter_data= &pxa2xx_ac97_pcm_stereo_in_req,
-};
-
-static struct pxad_param pxa2xx_ac97_pcm_stereo_out_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 12,
 };
 
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_out = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_out",
.maxburst   = 32,
-   .filter_data= &pxa2xx_ac97_pcm_stereo_out_req,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_aux_mono_out_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 10,
-};
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_out = {
.addr   = __PREG(MODR),
.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .chan_name  = "pcm_aux_mono_out",
.maxburst   = 16,
-   .filter_data= &pxa2xx_ac97_pcm_aux_mono_out_req,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_aux_mono_in_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 9,
-};
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_in = {
.addr   = __PREG(MODR),
.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .chan_name  = "pcm_aux_mono_in",
.maxburst   = 16,
-   .filter_data= &pxa2xx_ac97_pcm_aux_mono_in_req,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_aux_mic_mono_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 8,
-};
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_mic_mono_in = {
.addr   = __PREG(MCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .chan_name  = "pcm_aux_mic_mono",
.maxburst   = 16,
-   .filter_data= &pxa2xx_ac97_pcm_aux_mic_mono_req,
 };
 
 static int pxa2xx_ac97_hifi_startup(struct snd_pcm_substream *substream,
-- 
2.11.0

___
devel mailing 

[PATCH 10/15] ata: pata_pxa: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik 
---
 drivers/ata/pata_pxa.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
index f6c46e9a4dc0..e8b6a2e464c9 100644
--- a/drivers/ata/pata_pxa.c
+++ b/drivers/ata/pata_pxa.c
@@ -25,7 +25,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -180,8 +179,6 @@ static int pxa_ata_probe(struct platform_device *pdev)
struct resource *irq_res;
struct pata_pxa_pdata *pdata = dev_get_platdata(&pdev->dev);
struct dma_slave_config config;
-   dma_cap_mask_t mask;
-   struct pxad_param param;
int ret = 0;
 
/*
@@ -278,10 +275,6 @@ static int pxa_ata_probe(struct platform_device *pdev)
 
ap->private_data = data;
 
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = pdata->dma_dreq;
memset(&config, 0, sizeof(config));
config.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
config.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
@@ -294,8 +287,7 @@ static int pxa_ata_probe(struct platform_device *pdev)
 * Request the DMA channel
 */
data->dma_chan =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-¶m, &pdev->dev, "data");
+   dma_request_slave_channel(&pdev->dev, "data");
if (!data->dma_chan)
return -EBUSY;
ret = dmaengine_slave_config(data->dma_chan, &config);
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/15] net: irda: pxaficp_ir: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik 
---
 drivers/staging/irda/drivers/pxaficp_ir.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/irda/drivers/pxaficp_ir.c 
b/drivers/staging/irda/drivers/pxaficp_ir.c
index 2ea00a6531f9..9dd6e21dc11e 100644
--- a/drivers/staging/irda/drivers/pxaficp_ir.c
+++ b/drivers/staging/irda/drivers/pxaficp_ir.c
@@ -20,7 +20,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -735,9 +734,7 @@ static void pxa_irda_shutdown(struct pxa_irda *si)
 static int pxa_irda_start(struct net_device *dev)
 {
struct pxa_irda *si = netdev_priv(dev);
-   dma_cap_mask_t mask;
struct dma_slave_config config;
-   struct pxad_param param;
int err;
 
si->speed = 9600;
@@ -757,9 +754,6 @@ static int pxa_irda_start(struct net_device *dev)
disable_irq(si->icp_irq);
 
err = -EBUSY;
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
 
memset(&config, 0, sizeof(config));
config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
@@ -769,15 +763,11 @@ static int pxa_irda_start(struct net_device *dev)
config.src_maxburst = 32;
config.dst_maxburst = 32;
 
-   param.drcmr = si->drcmr_rx;
-   si->rxdma = dma_request_slave_channel_compat(mask, pxad_filter_fn,
-¶m, &dev->dev, "rx");
+   si->rxdma = dma_request_slave_channel(&dev->dev, "rx");
if (!si->rxdma)
goto err_rx_dma;
 
-   param.drcmr = si->drcmr_tx;
-   si->txdma = dma_request_slave_channel_compat(mask, pxad_filter_fn,
-¶m, &dev->dev, "tx");
+   si->txdma = dma_request_slave_channel(&dev->dev, "tx");
if (!si->txdma)
goto err_tx_dma;
 
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/15] net: smc91x: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
From: Robert Jarzmik 

As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik 
---
 drivers/net/ethernet/smsc/smc91x.c | 12 +---
 drivers/net/ethernet/smsc/smc91x.h |  1 -
 2 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 080428762858..4c600f430f6d 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2018,18 +2018,8 @@ static int smc_probe(struct net_device *dev, void 
__iomem *ioaddr,
lp->cfg.flags |= SMC91X_USE_DMA;
 #  endif
if (lp->cfg.flags & SMC91X_USE_DMA) {
-   dma_cap_mask_t mask;
-   struct pxad_param param;
-
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = -1UL;
-
lp->dma_chan =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-¶m, &dev->dev,
-"data");
+   dma_request_slave_channel(lp->device, "data");
}
 #endif
 
diff --git a/drivers/net/ethernet/smsc/smc91x.h 
b/drivers/net/ethernet/smsc/smc91x.h
index 08b17adf0a65..e849b6c2fa60 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -327,7 +327,6 @@ struct smc_local {
  * as RX which can overrun memory and lose packets.
  */
 #include 
-#include 
 
 #ifdef SMC_insl
 #undef SMC_insl
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/15] net: smc911x: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
From: Robert Jarzmik 

As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik 
---
 drivers/net/ethernet/smsc/smc911x.c | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc911x.c 
b/drivers/net/ethernet/smsc/smc911x.c
index 05157442a980..4c3713bd5caa 100644
--- a/drivers/net/ethernet/smsc/smc911x.c
+++ b/drivers/net/ethernet/smsc/smc911x.c
@@ -74,7 +74,6 @@ static const char version[] =
 #include 
 
 #include 
-#include 
 
 #include 
 
@@ -1794,8 +1793,6 @@ static int smc911x_probe(struct net_device *dev)
unsigned long irq_flags;
 #ifdef SMC_USE_DMA
struct dma_slave_config config;
-   dma_cap_mask_t mask;
-   struct pxad_param param;
 #endif
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
@@ -1969,17 +1966,8 @@ static int smc911x_probe(struct net_device *dev)
 
 #ifdef SMC_USE_DMA
 
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = -1UL;
-
-   lp->rxdma =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-¶m, &dev->dev, "rx");
-   lp->txdma =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-¶m, &dev->dev, "tx");
+   lp->rxdma = dma_request_slave_channel(&dev->dev, "rx");
+   lp->txdma = dma_request_slave_channel(&dev->dev, "tx");
lp->rxdma_active = 0;
lp->txdma_active = 0;
 
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/15] dmaengine: pxa: document pxad_param

2018-04-02 Thread Robert Jarzmik
Add some documentation for the pxad_param structure, and describe the
contract behind the minimal required priority of a DMA channel.

Signed-off-by: Robert Jarzmik 
---
 include/linux/dma/pxa-dma.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/include/linux/dma/pxa-dma.h b/include/linux/dma/pxa-dma.h
index e56ec7af4fd7..9fc594f69eff 100644
--- a/include/linux/dma/pxa-dma.h
+++ b/include/linux/dma/pxa-dma.h
@@ -9,6 +9,15 @@ enum pxad_chan_prio {
PXAD_PRIO_LOWEST,
 };
 
+/**
+ * struct pxad_param - dma channel request parameters
+ * @drcmr: requestor line number
+ * @prio: minimal mandatory priority of the channel
+ *
+ * If a requested channel is granted, its priority will be at least @prio,
+ * ie. if PXAD_PRIO_LOW is required, the requested channel will be either
+ * PXAD_PRIO_LOW, PXAD_PRIO_NORMAL or PXAD_PRIO_HIGHEST.
+ */
 struct pxad_param {
unsigned int drcmr;
enum pxad_chan_prio prio;
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel