From: Clark Wang <xiaoning.wang@nxp.com>
To: "broonie@kernel.org" <broonie@kernel.org>
Cc: "linux-spi@vger.kernel.org" <linux-spi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH 3/3] spi: lpspi: remove fsl_lpspi->chipselect
Date: Tue, 23 Apr 2019 10:46:24 +0000 [thread overview]
Message-ID: <20190423104649.24483-4-xiaoning.wang@nxp.com> (raw)
In-Reply-To: <20190423104649.24483-1-xiaoning.wang@nxp.com>
Replace fsl_lpspi->chipselect by controller->cs_gpios. Clean up the
code.
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
---
drivers/spi/spi-fsl-lpspi.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index a8e83cb96f61..aa6218cbc9e8 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -124,8 +124,6 @@ struct fsl_lpspi_data {
bool usedma;
struct completion dma_rx_completion;
struct completion dma_tx_completion;
-
- int chipselect[0];
};
static const struct of_device_id fsl_lpspi_dt_ids[] = {
@@ -230,10 +228,8 @@ static int lpspi_unprepare_xfer_hardware(struct spi_controller *controller)
static int fsl_lpspi_prepare_message(struct spi_controller *controller,
struct spi_message *msg)
{
- struct fsl_lpspi_data *fsl_lpspi =
- spi_controller_get_devdata(controller);
struct spi_device *spi = msg->spi;
- int gpio = fsl_lpspi->chipselect[spi->chip_select];
+ int gpio = controller->cs_gpios[spi->chip_select];
if (gpio_is_valid(gpio))
gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH ? 0 : 1);
@@ -877,6 +873,9 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
fsl_lpspi->dev = &pdev->dev;
fsl_lpspi->is_slave = is_slave;
+ controller->cs_gpios = devm_kzalloc(&controller->dev,
+ sizeof(int) * controller->num_chipselect, GFP_KERNEL);
+
if (!fsl_lpspi->is_slave) {
for (i = 0; i < controller->num_chipselect; i++) {
int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
@@ -884,19 +883,18 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
if (!gpio_is_valid(cs_gpio) && lpspi_platform_info)
cs_gpio = lpspi_platform_info->chipselect[i];
- fsl_lpspi->chipselect[i] = cs_gpio;
+ controller->cs_gpios[i] = cs_gpio;
if (!gpio_is_valid(cs_gpio))
continue;
ret = devm_gpio_request(&pdev->dev,
- fsl_lpspi->chipselect[i],
+ controller->cs_gpios[i],
DRIVER_NAME);
if (ret) {
dev_err(&pdev->dev, "can't get cs gpios\n");
goto out_controller_put;
}
}
- controller->cs_gpios = fsl_lpspi->chipselect;
controller->prepare_message = fsl_lpspi_prepare_message;
}
--
2.17.1
prev parent reply other threads:[~2019-04-23 10:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-23 10:46 [PATCH 0/3] spi: lpspi: SS function related changes Clark Wang
2019-04-23 10:46 ` [PATCH 1/3] spi: lpspi: add NULL check when probe device Clark Wang
2019-04-23 11:14 ` Fabio Estevam
2019-04-23 10:46 ` [PATCH 2/3] spi: lpspi: add multi SS support in PIO mode Clark Wang
2019-04-23 11:21 ` Fabio Estevam
2019-04-23 10:46 ` Clark Wang [this message]
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=20190423104649.24483-4-xiaoning.wang@nxp.com \
--to=xiaoning.wang@nxp.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.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).