linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH v2 6/7] spi/imx: copy gpio number passed by platform data into driver private data
Date: Mon, 11 Jul 2011 09:45:29 +0200	[thread overview]
Message-ID: <20110711074529.GD13840@pengutronix.de> (raw)
In-Reply-To: <1310231801-18761-7-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

On Sun, Jul 10, 2011 at 01:16:40AM +0800, Shawn Guo wrote:
> It copies gpio number passed via platform data embedded pointer into
> driver private data, so that we do not need to refer to this embedded
> pointer passed by platform data after probe function exits.
> 
> Signed-off-by: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> Cc: Uwe Kleine-König <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Cc: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
> ---
>  drivers/spi/spi-imx.c |   12 +++++++-----
>  1 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> index 2ed9c32..ad61828 100644
> --- a/drivers/spi/spi-imx.c
> +++ b/drivers/spi/spi-imx.c
> @@ -84,7 +84,6 @@ struct spi_imx_data {
>  	int irq;
>  	struct clk *clk;
>  	unsigned long spi_clk;
> -	int *chipselect;
>  
>  	unsigned int count;
>  	void (*tx)(struct spi_imx_data *);
> @@ -94,6 +93,7 @@ struct spi_imx_data {
>  	unsigned int txfifo; /* number of words pushed in tx FIFO */
>  
>  	struct spi_imx_devtype_data *devtype_data;
> +	int chipselect[0];
It's not needed to use a zero-length array here (which is a gcc
extension). A (C99) flexible array member should be fine.
Long words short: s/0//

>  };
>  
>  static inline int is_imx27_cspi(struct spi_imx_data *d)
> @@ -743,7 +743,7 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
>  	struct spi_master *master;
>  	struct spi_imx_data *spi_imx;
>  	struct resource *res;
> -	int i, ret;
> +	int i, ret, num_cs;
>  
>  	mxc_platform_info = dev_get_platdata(&pdev->dev);
>  	if (!mxc_platform_info) {
> @@ -751,20 +751,22 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> -	master = spi_alloc_master(&pdev->dev, sizeof(struct spi_imx_data));
> +	num_cs = mxc_platform_info->num_chipselect;
> +	master = spi_alloc_master(&pdev->dev,
> +			sizeof(struct spi_imx_data) + sizeof(int) * num_cs);
>  	if (!master)
>  		return -ENOMEM;
>  
>  	platform_set_drvdata(pdev, master);
>  
>  	master->bus_num = pdev->id;
> -	master->num_chipselect = mxc_platform_info->num_chipselect;
> +	master->num_chipselect = num_cs;
>  
>  	spi_imx = spi_master_get_devdata(master);
>  	spi_imx->bitbang.master = spi_master_get(master);
> -	spi_imx->chipselect = mxc_platform_info->chipselect;
>  
>  	for (i = 0; i < master->num_chipselect; i++) {
> +		spi_imx->chipselect[i] = mxc_platform_info->chipselect[i];
>  		if (spi_imx->chipselect[i] < 0)
>  			continue;
>  		ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME);
> -- 
> 1.7.4.1
> 
> 

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  parent reply	other threads:[~2011-07-11  7:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-09 17:16 [PATCH v2 0/7] Add device tree support for imx spi driver Shawn Guo
     [not found] ` <1310231801-18761-1-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2011-07-09 17:16   ` [PATCH v2 1/7] spi/imx: do not make copy of spi_imx_devtype_data Shawn Guo
2011-07-11  7:15     ` Lothar Waßmann
     [not found]       ` <19994.41750.920408.162356-VjFSrY7JcPWvSplVBqRQBQ@public.gmane.org>
2011-07-11  7:31         ` Uwe Kleine-König
2011-07-11  7:49           ` Lothar Waßmann
2011-07-11  7:35       ` Shawn Guo
     [not found]         ` <20110711073523.GA19105-+NayF8gZjK2ctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2011-07-11  7:32           ` Lothar Waßmann
     [not found]     ` <1310231801-18761-2-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2011-07-15  2:53       ` Grant Likely
2011-07-09 17:16   ` [PATCH v2 2/7] spi/imx: use mx21 to name SPI_IMX_VER_0_0 function and macro Shawn Guo
     [not found]     ` <1310231801-18761-3-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2011-07-11  7:35       ` Uwe Kleine-König
     [not found]         ` <20110711073523.GB13840-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2011-07-15  2:53           ` Grant Likely
2011-07-09 17:16   ` [PATCH v2 3/7] spi/imx: do not use spi_imx2_3 to name SPI_IMX_VER_2_3 " Shawn Guo
     [not found]     ` <1310231801-18761-4-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2011-07-15  2:53       ` Grant Likely
2011-07-09 17:16   ` [PATCH v2 4/7] spi/imx: merge type SPI_IMX_VER_0_7 into SPI_IMX_VER_0_4 Shawn Guo
     [not found]     ` <1310231801-18761-5-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2011-07-11  7:38       ` Uwe Kleine-König
2011-07-09 17:16   ` [PATCH v2 5/7] spi/imx: use soc name in spi device type naming scheme Shawn Guo
     [not found]     ` <1310231801-18761-6-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2011-07-15  2:53       ` Grant Likely
2011-07-09 17:16   ` [PATCH v2 6/7] spi/imx: copy gpio number passed by platform data into driver private data Shawn Guo
     [not found]     ` <1310231801-18761-7-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2011-07-11  7:45       ` Uwe Kleine-König [this message]
2011-07-09 17:16   ` [PATCH v2 7/7] spi/imx: add device tree probe support Shawn Guo
     [not found]     ` <1310231801-18761-8-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2011-07-15  2:53       ` Grant Likely

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=20110711074529.GD13840@pengutronix.de \
    --to=u.kleine-koenig-bicnvbalz9megne8c9+irq@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).