From patchwork Thu Oct 14 16:19:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 253491 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9EGKD9j028028 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 14 Oct 2010 16:20:54 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1P6QXN-0008D8-7B; Thu, 14 Oct 2010 16:20:13 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1P6QXL-0008Ci-MP for spi-devel-general@lists.sourceforge.net; Thu, 14 Oct 2010 16:20:11 +0000 X-ACL-Warn: Received: from mail-pw0-f47.google.com ([209.85.160.47]) by sog-mx-1.v43.ch3.sourceforge.com with esmtp (Exim 4.69) id 1P6QXH-00089I-Ip for spi-devel-general@lists.sourceforge.net; Thu, 14 Oct 2010 16:20:11 +0000 Received: by pwj9 with SMTP id 9so149655pwj.34 for ; Thu, 14 Oct 2010 09:20:02 -0700 (PDT) Received: by 10.142.162.9 with SMTP id k9mr8973231wfe.411.1287073201987; Thu, 14 Oct 2010 09:20:01 -0700 (PDT) Received: from angua (S01060002b3d79728.cg.shawcable.net [70.72.87.49]) by mx.google.com with ESMTPS id q13sm13845793wfc.17.2010.10.14.09.20.00 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 14 Oct 2010 09:20:01 -0700 (PDT) Received: from localhost6.localdomain6 (unknown [IPv6:::1]) by angua (Postfix) with ESMTP id C19313C00E4; Thu, 14 Oct 2010 10:19:59 -0600 (MDT) Subject: [RFC PATCH 1/3] spi/xilinx: Eliminate pdata references from common code. To: spi-devel-general@lists.sourceforge.net, richard.rojfors@mocean-labs.com, john.linn@xilinx.com, monstr@monstr.eu From: Grant Likely Date: Thu, 14 Oct 2010 10:19:59 -0600 Message-ID: <20101014161959.18966.88876.stgit@localhost6.localdomain6> In-Reply-To: <20101014161724.18966.42340.stgit@localhost6.localdomain6> References: <20101014161724.18966.42340.stgit@localhost6.localdomain6> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Spam-Score: -0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.47 listed in list.dnswl.org] -0.0 AWL AWL: From: address is in the auto white-list X-Headers-End: 1P6QXH-00089I-Ip Cc: linux-kernel@vger.kernel.org X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 14 Oct 2010 16:20:54 +0000 (UTC) diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c index 80f2db5..efb28ba 100644 --- a/drivers/spi/xilinx_spi.c +++ b/drivers/spi/xilinx_spi.c @@ -351,18 +351,12 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id) } struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, - u32 irq, s16 bus_num) + u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word) { struct spi_master *master; struct xilinx_spi *xspi; - struct xspi_platform_data *pdata = dev->platform_data; int ret; - if (!pdata) { - dev_err(dev, "No platform data attached\n"); - return NULL; - } - master = spi_alloc_master(dev, sizeof(struct xilinx_spi)); if (!master) return NULL; @@ -389,21 +383,21 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, } master->bus_num = bus_num; - master->num_chipselect = pdata->num_chipselect; + master->num_chipselect = num_cs; #ifdef CONFIG_OF master->dev.of_node = dev->of_node; #endif xspi->mem = *mem; xspi->irq = irq; - if (pdata->little_endian) { + if (little_endian) { xspi->read_fn = xspi_read32; xspi->write_fn = xspi_write32; } else { xspi->read_fn = xspi_read32_be; xspi->write_fn = xspi_write32_be; } - xspi->bits_per_word = pdata->bits_per_word; + xspi->bits_per_word = bits_per_word; if (xspi->bits_per_word == 8) { xspi->tx_fn = xspi_tx8; xspi->rx_fn = xspi_rx8; diff --git a/drivers/spi/xilinx_spi.h b/drivers/spi/xilinx_spi.h index d211acc..d710a33 100644 --- a/drivers/spi/xilinx_spi.h +++ b/drivers/spi/xilinx_spi.h @@ -26,7 +26,7 @@ #define XILINX_SPI_NAME "xilinx_spi" struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, - u32 irq, s16 bus_num); + u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word); void xilinx_spi_deinit(struct spi_master *master); #endif diff --git a/drivers/spi/xilinx_spi_of.c b/drivers/spi/xilinx_spi_of.c index b66c2db..c2d8ade 100644 --- a/drivers/spi/xilinx_spi_of.c +++ b/drivers/spi/xilinx_spi_of.c @@ -42,12 +42,11 @@ static int __devinit xilinx_spi_of_probe(struct platform_device *ofdev, const struct of_device_id *match) { struct spi_master *master; - struct xspi_platform_data *pdata; struct resource r_mem; struct resource r_irq; int rc = 0; const u32 *prop; - int len; + int len, num_cs; rc = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem); if (rc) { @@ -61,21 +60,15 @@ static int __devinit xilinx_spi_of_probe(struct platform_device *ofdev, return -ENODEV; } - ofdev->dev.platform_data = - kzalloc(sizeof(struct xspi_platform_data), GFP_KERNEL); - pdata = ofdev->dev.platform_data; - if (!pdata) - return -ENOMEM; - /* number of slave select bits is required */ prop = of_get_property(ofdev->dev.of_node, "xlnx,num-ss-bits", &len); if (!prop || len < sizeof(*prop)) { dev_warn(&ofdev->dev, "no 'xlnx,num-ss-bits' property\n"); return -EINVAL; } - pdata->num_chipselect = *prop; - pdata->bits_per_word = 8; - master = xilinx_spi_init(&ofdev->dev, &r_mem, r_irq.start, -1); + num_cs = __be32_to_cpup(prop); + master = xilinx_spi_init(&ofdev->dev, &r_mem, r_irq.start, -1, + num_cs, 0, 8); if (!master) return -ENODEV; @@ -88,8 +81,6 @@ static int __devexit xilinx_spi_remove(struct platform_device *ofdev) { xilinx_spi_deinit(dev_get_drvdata(&ofdev->dev)); dev_set_drvdata(&ofdev->dev, 0); - kfree(ofdev->dev.platform_data); - ofdev->dev.platform_data = NULL; return 0; } diff --git a/drivers/spi/xilinx_spi_pltfm.c b/drivers/spi/xilinx_spi_pltfm.c index 24debac..a16722a 100644 --- a/drivers/spi/xilinx_spi_pltfm.c +++ b/drivers/spi/xilinx_spi_pltfm.c @@ -54,7 +54,9 @@ static int __devinit xilinx_spi_probe(struct platform_device *dev) if (irq < 0) return -ENXIO; - master = xilinx_spi_init(&dev->dev, r, irq, dev->id); + master = xilinx_spi_init(&dev->dev, r, irq, dev->id, + pdata->num_chipselect, pdata->little_endian, + pdata->bits_per_word); if (!master) return -ENODEV;