From patchwork Tue Feb 11 12:54:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3626901 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 51AACBF418 for ; Tue, 11 Feb 2014 12:54:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 80CDC201F4 for ; Tue, 11 Feb 2014 12:54:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9AB5E201F2 for ; Tue, 11 Feb 2014 12:54:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750984AbaBKMyY (ORCPT ); Tue, 11 Feb 2014 07:54:24 -0500 Received: from mail-pb0-f47.google.com ([209.85.160.47]:63888 "EHLO mail-pb0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750862AbaBKMyX (ORCPT ); Tue, 11 Feb 2014 07:54:23 -0500 Received: by mail-pb0-f47.google.com with SMTP id rp16so7682900pbb.20 for ; Tue, 11 Feb 2014 04:54:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=l0qR32rKfkpkwn/3niklmhrWPvWvxrJoWyuKZ2qxsuM=; b=czsEokCmOMrZrQL6/1UJUePDth7C98JzqSxu3qDLrOGU7sSDqmOjscSpw+3CeWiB8Z S09sJxb/o6xpbQcW9oMrY+t2944i671ZmuODNCX+ODoZYn8yHl8babGEVHnuifC84vre t26n76GoKHtO4FS1JXlA9D1/eP1ERy3quxrAj4JNmNTBLjjB3ZPoSzYgvCIIm54ITMoz dVLySLQCFZJRkxvW0gQNbSrcjgfogXmG/UfbkSL2/1lPPbOMGa2Y6e5+Uj8uX2jQozVe AexzCIrxVQsSL5MSJYoRsFjc+VvnaM3eGhUm14AlX9PvlO/y8qz2IQDqUSMiFhyiSLJI k66A== X-Gm-Message-State: ALoCoQlpDlW4rvZITTBqCjLFqq9C0K1u3D2rZv6ILLXL3DDiHSgaoL/AnsflL7y0zQ38i6CnivFp X-Received: by 10.68.218.3 with SMTP id pc3mr44462336pbc.71.1392123263248; Tue, 11 Feb 2014 04:54:23 -0800 (PST) Received: from [10.145.55.56] ([60.245.65.194]) by mx.google.com with ESMTPSA id nz11sm4801181pab.6.2014.02.11.04.54.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Feb 2014 04:54:22 -0800 (PST) Message-ID: <1392123257.1351.9.camel@phoenix> Subject: [PATCH] spi: sc18is602: Move checking chip_select for SC18IS602 to sc18is602_setup From: Axel Lin To: Mark Brown Cc: Guenter Roeck , linux-spi@vger.kernel.org Date: Tue, 11 Feb 2014 20:54:17 +0800 X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 So it will be checked when spi device is added onto the spi bus. spi_add_device() calls spi_setup() which then calls spi->master->setup(). No need to check it every time sc18is602_transfer_one() is called. Signed-off-by: Axel Lin Acked-by: Guenter Roeck --- drivers/spi/spi-sc18is602.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-sc18is602.c b/drivers/spi/spi-sc18is602.c index b3ac776..7fba10b 100644 --- a/drivers/spi/spi-sc18is602.c +++ b/drivers/spi/spi-sc18is602.c @@ -205,12 +205,6 @@ static int sc18is602_transfer_one(struct spi_master *master, struct spi_transfer *t; int status = 0; - /* SC18IS602 does not support CS2 */ - if (hw->id == sc18is602 && spi->chip_select == 2) { - status = -ENXIO; - goto error; - } - hw->tlen = 0; list_for_each_entry(t, &m->transfers, transfer_list) { u32 hz = t->speed_hz ? : spi->max_speed_hz; @@ -238,13 +232,23 @@ static int sc18is602_transfer_one(struct spi_master *master, if (t->delay_usecs) udelay(t->delay_usecs); } -error: m->status = status; spi_finalize_current_message(master); return status; } +static int sc18is602_setup(struct spi_device *spi) +{ + struct sc18is602 *hw = spi_master_get_devdata(spi->master); + + /* SC18IS602 does not support CS2 */ + if (hw->id == sc18is602 && spi->chip_select == 2) + return -ENXIO; + + return 0; +} + static int sc18is602_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -298,6 +302,7 @@ static int sc18is602_probe(struct i2c_client *client, master->bus_num = client->adapter->nr; master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_LSB_FIRST; master->bits_per_word_mask = SPI_BPW_MASK(8); + master->setup = sc18is602_setup; master->transfer_one_message = sc18is602_transfer_one; master->dev.of_node = np;