From patchwork Sun Feb 2 06:59:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 3566541 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 062B2C02DC for ; Sun, 2 Feb 2014 07:00:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 388D12013D for ; Sun, 2 Feb 2014 07:00:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6D7852012F for ; Sun, 2 Feb 2014 07:00:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751163AbaBBHAs (ORCPT ); Sun, 2 Feb 2014 02:00:48 -0500 Received: from fallback4.mail.ru ([94.100.176.42]:36258 "EHLO fallback4.mail.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750959AbaBBHAr (ORCPT ); Sun, 2 Feb 2014 02:00:47 -0500 Received: from smtp40.i.mail.ru (smtp40.i.mail.ru [94.100.177.100]) by fallback4.mail.ru (mPOP.Fallback_MX) with ESMTP id DEAA91D8D87 for ; Sun, 2 Feb 2014 11:00:25 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=Zts7cHfNdy/yCHGL1WvwjNtzC8rhgtxzflA5KDi6dQk=; b=mM9xg+TBpUadRHTInX6+S+l0l8LxD6EwQZ/KdoPX58Us+emuFdmn/MO2uvb/6jS3IUM9glSnKhq43RF7PoLViaR3HhTBK84PjxaeZHLZuAgWCP10TwoV8vzCkLrMhQPOFuBZrlbL9agQNu9cwcKKCqgNkipmlzI+Bzo3tpowf0E=; Received: from [188.134.40.128] (port=62912 helo=shc.zet) by smtp40.i.mail.ru with esmtpa (envelope-from ) id 1W9r2H-0001vA-DR; Sun, 02 Feb 2014 11:00:09 +0400 From: Alexander Shiyan To: linux-spi@vger.kernel.org Cc: Mark Brown , Alexander Shiyan Subject: [PATCH 3/3] spi: clps711x: Use SPI-core "cs_gpios" property for storing GPIOs Date: Sun, 2 Feb 2014 10:59:50 +0400 Message-Id: <1391324390-17547-3-git-send-email-shc_work@mail.ru> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1391324390-17547-1-git-send-email-shc_work@mail.ru> References: <1391324390-17547-1-git-send-email-shc_work@mail.ru> X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Mras: Ok Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RDNS_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alexander Shiyan --- drivers/spi/spi-clps711x.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/drivers/spi/spi-clps711x.c b/drivers/spi/spi-clps711x.c index d9fa933..f973e97 100644 --- a/drivers/spi/spi-clps711x.c +++ b/drivers/spi/spi-clps711x.c @@ -33,17 +33,12 @@ struct spi_clps711x_data { u8 *rx_buf; unsigned int bpw; int len; - - int chipselect[0]; }; static int spi_clps711x_setup(struct spi_device *spi) { - struct spi_clps711x_data *hw = spi_master_get_devdata(spi->master); - /* We are expect that SPI-device is not selected */ - gpio_direction_output(hw->chipselect[spi->chip_select], - !(spi->mode & SPI_CS_HIGH)); + gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); return 0; } @@ -84,7 +79,6 @@ static int spi_clps711x_transfer_one_message(struct spi_master *master, struct spi_clps711x_data *hw = spi_master_get_devdata(master); struct spi_device *spi = msg->spi; struct spi_transfer *xfer; - int cs = hw->chipselect[spi->chip_select]; spi_clps711x_setup_mode(spi); @@ -93,7 +87,7 @@ static int spi_clps711x_transfer_one_message(struct spi_master *master, spi_clps711x_setup_xfer(spi, xfer); - gpio_set_value(cs, !!(spi->mode & SPI_CS_HIGH)); + gpio_set_value(spi->cs_gpio, !!(spi->mode & SPI_CS_HIGH)); reinit_completion(&hw->done); @@ -114,7 +108,7 @@ static int spi_clps711x_transfer_one_message(struct spi_master *master, if (xfer->cs_change || list_is_last(&xfer->transfer_list, &msg->transfers)) - gpio_set_value(cs, !(spi->mode & SPI_CS_HIGH)); + gpio_set_value(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); msg->actual_length += xfer->len; } @@ -163,12 +157,15 @@ static int spi_clps711x_probe(struct platform_device *pdev) return -EINVAL; } - master = spi_alloc_master(&pdev->dev, - sizeof(struct spi_clps711x_data) + - sizeof(int) * pdata->num_chipselect); - if (!master) { - dev_err(&pdev->dev, "SPI allocating memory error\n"); + master = spi_alloc_master(&pdev->dev, sizeof(*hw)); + if (!master) return -ENOMEM; + + master->cs_gpios = devm_kzalloc(&pdev->dev, sizeof(int) * + pdata->num_chipselect, GFP_KERNEL); + if (!master->cs_gpios) { + ret = -ENOMEM; + goto err_out; } master->bus_num = pdev->id; @@ -181,13 +178,13 @@ static int spi_clps711x_probe(struct platform_device *pdev) hw = spi_master_get_devdata(master); for (i = 0; i < master->num_chipselect; i++) { - hw->chipselect[i] = pdata->chipselect[i]; - if (!gpio_is_valid(hw->chipselect[i])) { + master->cs_gpios[i] = pdata->chipselect[i]; + if (!gpio_is_valid(master->cs_gpios[i])) { dev_err(&pdev->dev, "Invalid CS GPIO %i\n", i); ret = -EINVAL; goto err_out; } - if (devm_gpio_request(&pdev->dev, hw->chipselect[i], NULL)) { + if (devm_gpio_request(&pdev->dev, master->cs_gpios[i], NULL)) { dev_err(&pdev->dev, "Can't get CS GPIO %i\n", i); ret = -EINVAL; goto err_out;