From: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
haavard.skinnemoen@atmel.com, kernel@avr32linux.org,
nicolas.ferre@atmel.com
Subject: Re: [PATCH 1/2] atmel-mci: change use of dma slave interface
Date: Tue, 29 Sep 2009 12:29:28 -0700 [thread overview]
Message-ID: <20090929122928.f5fea29b.akpm@linux-foundation.org> (raw)
In-Reply-To: <1253204967-30010-2-git-send-email-nicolas.ferre@atmel.com>
On Thu, 17 Sep 2009 18:29:26 +0200
Nicolas Ferre <nicolas.ferre@atmel.com> wrote:
> Allow the use of another DMA controller driver in atmel-mci sd/mmc driver. This
> adds a generic dma_slave pointer to the mci platform structure where we can
> store DMA controller information. In atmel-mci we use information provided by
> this structure to initialize the driver (with new helper functions that are
> architecture dependant).
> This also adds at32/avr32 chip modifications to cope with this new access
> method.
>
> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> arch/avr32/mach-at32ap/at32ap700x.c | 6 ++-
> drivers/mmc/host/atmel-mci.c | 82 ++++++++++++++++++++++++++---------
> include/linux/atmel-mci.h | 3 +-
> 3 files changed, 68 insertions(+), 23 deletions(-)
>
> diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
> index eb9d4dc..d1fe145 100644
> --- a/arch/avr32/mach-at32ap/at32ap700x.c
> +++ b/arch/avr32/mach-at32ap/at32ap700x.c
> @@ -1320,7 +1320,7 @@ struct platform_device *__init
> at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
> {
> struct platform_device *pdev;
> - struct dw_dma_slave *dws = &data->dma_slave;
> + struct dw_dma_slave *dws;
> u32 pioa_mask;
> u32 piob_mask;
>
> @@ -1339,6 +1339,8 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
> ARRAY_SIZE(atmel_mci0_resource)))
> goto fail;
>
> + dws = kzalloc(sizeof(struct dw_dma_slave), GFP_KERNEL);
I don't see anywhere where this gets freed again?
> dws->dma_dev = &dw_dmac0_device.dev;
> dws->reg_width = DW_DMA_SLAVE_WIDTH_32BIT;
> dws->cfg_hi = (DWC_CFGH_SRC_PER(0)
> @@ -1346,6 +1348,8 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
> dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL
> | DWC_CFGL_HS_SRC_POL);
>
> + data->dma_slave = dws;
> +
> if (platform_device_add_data(pdev, data,
> sizeof(struct mci_platform_data)))
> goto fail;
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 065fa81..1689396 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -1575,16 +1575,71 @@ static void __exit atmci_cleanup_slot(struct atmel_mci_slot *slot,
> }
>
> #ifdef CONFIG_MMC_ATMELMCI_DMA
> -static bool filter(struct dma_chan *chan, void *slave)
> +static struct device *find_slave_dev(void *slave)
> +{
> + if (!slave)
> + return NULL;
> +
> + if (cpu_is_at32ap7000())
> + return ((struct dw_dma_slave *)slave)->dma_dev;
> + else
> + return ((struct at_dma_slave *)slave)->dma_dev;
> +}
Quite a few unsafeish typecasts here.
> struct mci_platform_data {
> - struct dw_dma_slave dma_slave;
> + void *dma_slave;
> struct mci_slot_pdata slot[ATMEL_MCI_MAX_NR_SLOTS];
> };
I think the code would come out better if this has type dw_dma_slave*.
You'll still need typecasts to support the dma_request_channel()
callback, but the code will be safer and cleaner, I expect.
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
haavard.skinnemoen@atmel.com, kernel@avr32linux.org,
nicolas.ferre@atmel.com
Subject: Re: [PATCH 1/2] atmel-mci: change use of dma slave interface
Date: Tue, 29 Sep 2009 12:29:28 -0700 [thread overview]
Message-ID: <20090929122928.f5fea29b.akpm@linux-foundation.org> (raw)
In-Reply-To: <1253204967-30010-2-git-send-email-nicolas.ferre@atmel.com>
On Thu, 17 Sep 2009 18:29:26 +0200
Nicolas Ferre <nicolas.ferre@atmel.com> wrote:
> Allow the use of another DMA controller driver in atmel-mci sd/mmc driver. This
> adds a generic dma_slave pointer to the mci platform structure where we can
> store DMA controller information. In atmel-mci we use information provided by
> this structure to initialize the driver (with new helper functions that are
> architecture dependant).
> This also adds at32/avr32 chip modifications to cope with this new access
> method.
>
> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> arch/avr32/mach-at32ap/at32ap700x.c | 6 ++-
> drivers/mmc/host/atmel-mci.c | 82 ++++++++++++++++++++++++++---------
> include/linux/atmel-mci.h | 3 +-
> 3 files changed, 68 insertions(+), 23 deletions(-)
>
> diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
> index eb9d4dc..d1fe145 100644
> --- a/arch/avr32/mach-at32ap/at32ap700x.c
> +++ b/arch/avr32/mach-at32ap/at32ap700x.c
> @@ -1320,7 +1320,7 @@ struct platform_device *__init
> at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
> {
> struct platform_device *pdev;
> - struct dw_dma_slave *dws = &data->dma_slave;
> + struct dw_dma_slave *dws;
> u32 pioa_mask;
> u32 piob_mask;
>
> @@ -1339,6 +1339,8 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
> ARRAY_SIZE(atmel_mci0_resource)))
> goto fail;
>
> + dws = kzalloc(sizeof(struct dw_dma_slave), GFP_KERNEL);
I don't see anywhere where this gets freed again?
> dws->dma_dev = &dw_dmac0_device.dev;
> dws->reg_width = DW_DMA_SLAVE_WIDTH_32BIT;
> dws->cfg_hi = (DWC_CFGH_SRC_PER(0)
> @@ -1346,6 +1348,8 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
> dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL
> | DWC_CFGL_HS_SRC_POL);
>
> + data->dma_slave = dws;
> +
> if (platform_device_add_data(pdev, data,
> sizeof(struct mci_platform_data)))
> goto fail;
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 065fa81..1689396 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -1575,16 +1575,71 @@ static void __exit atmci_cleanup_slot(struct atmel_mci_slot *slot,
> }
>
> #ifdef CONFIG_MMC_ATMELMCI_DMA
> -static bool filter(struct dma_chan *chan, void *slave)
> +static struct device *find_slave_dev(void *slave)
> +{
> + if (!slave)
> + return NULL;
> +
> + if (cpu_is_at32ap7000())
> + return ((struct dw_dma_slave *)slave)->dma_dev;
> + else
> + return ((struct at_dma_slave *)slave)->dma_dev;
> +}
Quite a few unsafeish typecasts here.
> struct mci_platform_data {
> - struct dw_dma_slave dma_slave;
> + void *dma_slave;
> struct mci_slot_pdata slot[ATMEL_MCI_MAX_NR_SLOTS];
> };
I think the code would come out better if this has type dw_dma_slave*.
You'll still need typecasts to support the dma_request_channel()
callback, but the code will be safer and cleaner, I expect.
next prev parent reply other threads:[~2009-09-29 19:29 UTC|newest]
Thread overview: 97+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-17 16:29 [PATCH 0/2] mmc: atmel-mci: introduce MCI2 support on at91 Nicolas Ferre
2009-09-17 16:29 ` [PATCH 1/2] atmel-mci: change use of dma slave interface Nicolas Ferre
2009-09-29 19:29 ` Andrew Morton [this message]
2009-09-29 19:29 ` Andrew Morton
2009-09-30 13:33 ` Nicolas Ferre
2009-09-30 13:55 ` Haavard Skinnemoen
2009-10-23 16:34 ` [PATCH 0/2 v2]mmc: atmel-mci: introduce MCI2 support on at91 Nicolas Ferre
2009-10-23 16:34 ` Nicolas Ferre
2009-10-23 16:34 ` [PATCH 1/3 v2] atmel-mci: change use of dma slave interface Nicolas Ferre
2009-10-23 16:34 ` Nicolas Ferre
2009-10-23 16:34 ` Nicolas Ferre
2009-10-23 16:34 ` [PATCH 2/3 v2] mmc: atmel-mci: New MCI2 module support in atmel-mci driver Nicolas Ferre
2009-10-23 16:34 ` Nicolas Ferre
2009-11-02 17:18 ` Nicolas Ferre
2009-11-02 17:18 ` Nicolas Ferre
2009-11-18 13:33 ` Nicolas Ferre
2009-11-18 13:33 ` Nicolas Ferre
2009-10-23 16:34 ` [PATCH 3/3 v2] at91/atmel-mci: inclusion of sd/mmc driver in at91sam9g45 chip and board Nicolas Ferre
2009-10-23 16:34 ` Nicolas Ferre
2009-10-26 8:15 ` Yegor Yefremov
2009-10-26 8:15 ` Yegor Yefremov
2009-11-02 17:14 ` Nicolas Ferre
2009-11-02 17:14 ` Nicolas Ferre
2009-10-27 19:43 ` Andrew Victor
2009-10-27 19:43 ` Andrew Victor
2009-10-27 19:43 ` Andrew Victor
2009-10-28 0:35 ` Haavard Skinnemoen
2009-10-28 0:35 ` Haavard Skinnemoen
2009-10-28 0:35 ` Haavard Skinnemoen
2009-10-28 0:53 ` Thiago A. Corrêa
2009-10-28 0:53 ` Thiago A. Corrêa
2009-10-28 0:53 ` Thiago A. Corrêa
2009-10-28 1:31 ` Haavard Skinnemoen
2009-10-28 1:31 ` Haavard Skinnemoen
2009-10-28 1:31 ` Haavard Skinnemoen
2009-10-28 19:53 ` Andrew Victor
2009-10-28 19:53 ` Andrew Victor
2009-10-28 19:53 ` Andrew Victor
2009-10-28 20:50 ` Ben Nizette
2009-10-28 20:50 ` Ben Nizette
2009-10-28 20:50 ` Ben Nizette
2009-11-02 17:11 ` Nicolas Ferre
2009-11-02 17:11 ` Nicolas Ferre
2009-11-02 22:10 ` Ben Nizette
2009-11-02 22:10 ` Ben Nizette
2009-11-02 22:14 ` Ben Nizette
2009-11-02 22:14 ` Ben Nizette
2009-11-03 2:30 ` Ryan Mallon
2009-11-03 2:30 ` Ryan Mallon
2009-11-03 2:30 ` Ryan Mallon
2009-11-03 2:55 ` Ben Nizette
2009-11-03 2:55 ` Ben Nizette
2009-11-07 11:20 ` Haavard Skinnemoen
2009-11-07 11:20 ` Haavard Skinnemoen
2010-08-23 15:01 ` [PATCH] pio: add arch specific gpio_is_valid() function Nicolas Ferre
2010-08-23 15:01 ` Nicolas Ferre
2010-08-23 16:36 ` David Brownell
2010-08-23 16:36 ` David Brownell
2010-08-24 8:19 ` Nicolas Ferre
2010-08-24 8:19 ` Nicolas Ferre
2010-09-06 14:21 ` [PATCH v2] AT91: pio: add " Nicolas Ferre
2010-09-06 14:21 ` Nicolas Ferre
2010-09-07 1:51 ` David Brownell
2010-09-07 1:51 ` David Brownell
2010-09-03 16:41 ` [PATCH] pio: add arch specific " Jean-Christophe PLAGNIOL-VILLARD
2010-09-03 16:41 ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-07 2:23 ` David Brownell
2010-09-07 2:23 ` David Brownell
2010-09-07 2:44 ` Ryan Mallon
2010-09-07 2:44 ` Ryan Mallon
2010-09-07 3:54 ` Eric Miao
2010-09-07 3:54 ` Eric Miao
2010-09-07 4:07 ` Ryan Mallon
2010-09-07 4:07 ` Ryan Mallon
2010-09-07 4:19 ` Eric Miao
2010-09-07 4:19 ` Eric Miao
2010-09-07 4:26 ` Ryan Mallon
2010-09-07 4:26 ` Ryan Mallon
2010-09-07 18:10 ` David Brownell
2010-09-07 18:10 ` David Brownell
2010-09-07 19:13 ` avictor.za at gmail.com
2010-09-07 19:13 ` avictor.za
2010-09-07 19:30 ` Ryan Mallon
2010-09-07 19:30 ` Ryan Mallon
2010-09-07 21:22 ` Alan Cox
2010-09-07 21:22 ` Alan Cox
2010-09-07 23:44 ` David Brownell
2010-09-07 23:44 ` David Brownell
2010-09-08 0:11 ` Alan Cox
2010-09-08 0:11 ` Alan Cox
2010-09-07 6:33 ` David Brownell
2010-09-07 6:33 ` David Brownell
2010-09-07 8:41 ` Ben Nizette
2010-09-07 8:41 ` Ben Nizette
2010-09-07 17:32 ` David Brownell
2010-09-07 17:32 ` David Brownell
2009-09-17 16:29 ` [PATCH 2/2] mmc: atmel-mci: New MCI2 module support in atmel-mci driver Nicolas Ferre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090929122928.f5fea29b.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=haavard.skinnemoen@atmel.com \
--cc=kernel@avr32linux.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=nicolas.ferre@atmel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.