From patchwork Mon Feb 10 14:26:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3619051 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 67E23BF418 for ; Mon, 10 Feb 2014 14:26:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 873CA20171 for ; Mon, 10 Feb 2014 14:26:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9EDA6201B6 for ; Mon, 10 Feb 2014 14:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751977AbaBJO0q (ORCPT ); Mon, 10 Feb 2014 09:26:46 -0500 Received: from mail-pd0-f171.google.com ([209.85.192.171]:38416 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751962AbaBJO0p (ORCPT ); Mon, 10 Feb 2014 09:26:45 -0500 Received: by mail-pd0-f171.google.com with SMTP id g10so6166262pdj.2 for ; Mon, 10 Feb 2014 06:26:45 -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=JjVEH2wEvK+im5ErYiN7hAYdkETArLqVKejhX5C1gGc=; b=OigxdYi9bVvn+6lR9NdF2lKGJYxKXiT1fvpEIvSe3GwJWMiA85+XnWuKwE3mDRX0Is kTkCusdReVmlOnrfFBocPSCqFsGpWe/m6igIVnDR0crPprKQR+9yayHafA2I1IXtuHic ZGIKgvChH2ZYDQ1wGPZrOXZqiF8yUn42p/SJnpwEztU/bDb8dmKED5llCJmpIm1tOspA YCDPPRP3aw8F/KtHqFEaKIWoGkKlXbKpe2+HVzQSbyV2XU/eqQKB0yUvaQSoyPMZ1Opa XMVW5l6FQfv2QGArP5PJEBlewiXjEtgh9y3W+qbRd1IeMQdsHZCaY7FjX9Z/ToUqL1Fe rJMA== X-Gm-Message-State: ALoCoQlG3nvOsTqoDmTLu+SCszQ2DgGb7B86KL+swtfo3gpG2WMFlHA26kgXymXz1yqxs0he2Gyx X-Received: by 10.68.209.193 with SMTP id mo1mr38472919pbc.38.1392042405190; Mon, 10 Feb 2014 06:26:45 -0800 (PST) Received: from [10.145.55.56] ([60.245.65.194]) by mx.google.com with ESMTPSA id yo9sm112020558pab.16.2014.02.10.06.26.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Feb 2014 06:26:44 -0800 (PST) Message-ID: <1392042400.9602.3.camel@phoenix> Subject: [PATCH] spi: topcliff-pch: Convert to use master->max_speed_hz From: Axel Lin To: Mark Brown Cc: Tomoya MORINAGA , linux-spi@vger.kernel.org Date: Mon, 10 Feb 2014 22:26:40 +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=unavailable 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 Set "master->max_speed_hz = PCH_MAX_BAUDRATE" then we can remove pch_spi_setup. In additional, pspi->max_speed_hz will never be 0 because it's default value will be set to master->max_speed_hz. Also remove list_empty checking in pch_spi_transfer() because the checking is done by spi core. Signed-off-by: Axel Lin --- drivers/spi/spi-topcliff-pch.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c index 2e7f38c..6304c91 100644 --- a/drivers/spi/spi-topcliff-pch.c +++ b/drivers/spi/spi-topcliff-pch.c @@ -464,20 +464,6 @@ static void pch_spi_reset(struct spi_master *master) pch_spi_writereg(master, PCH_SRST, 0x0); } -static int pch_spi_setup(struct spi_device *pspi) -{ - /* Check baud rate setting */ - /* if baud rate of chip is greater than - max we can support,return error */ - if ((pspi->max_speed_hz) > PCH_MAX_BAUDRATE) - pspi->max_speed_hz = PCH_MAX_BAUDRATE; - - dev_dbg(&pspi->dev, "%s MODE = %x\n", __func__, - (pspi->mode) & (SPI_CPOL | SPI_CPHA)); - - return 0; -} - static int pch_spi_transfer(struct spi_device *pspi, struct spi_message *pmsg) { @@ -486,23 +472,6 @@ static int pch_spi_transfer(struct spi_device *pspi, struct spi_message *pmsg) int retval; unsigned long flags; - /* validate spi message and baud rate */ - if (unlikely(list_empty(&pmsg->transfers) == 1)) { - dev_err(&pspi->dev, "%s list empty\n", __func__); - retval = -EINVAL; - goto err_out; - } - - if (unlikely(pspi->max_speed_hz == 0)) { - dev_err(&pspi->dev, "%s pch_spi_transfer maxspeed=%d\n", - __func__, pspi->max_speed_hz); - retval = -EINVAL; - goto err_out; - } - - dev_dbg(&pspi->dev, - "%s Transfer List not empty. Transfer Speed is set.\n", __func__); - spin_lock_irqsave(&data->lock, flags); /* validate Tx/Rx buffers and Transfer length */ list_for_each_entry(transfer, &pmsg->transfers, transfer_list) { @@ -523,10 +492,6 @@ static int pch_spi_transfer(struct spi_device *pspi, struct spi_message *pmsg) dev_dbg(&pspi->dev, "%s Tx/Rx buffer valid. Transfer length valid\n", __func__); - - /* if baud rate has been specified validate the same */ - if (transfer->speed_hz > PCH_MAX_BAUDRATE) - transfer->speed_hz = PCH_MAX_BAUDRATE; } spin_unlock_irqrestore(&data->lock, flags); @@ -1418,10 +1383,10 @@ static int pch_spi_pd_probe(struct platform_device *plat_dev) /* initialize members of SPI master */ master->num_chipselect = PCH_MAX_CS; - master->setup = pch_spi_setup; master->transfer = pch_spi_transfer; master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16); + master->max_speed_hz = PCH_MAX_BAUDRATE; data->board_dat = board_dat; data->plat_dev = plat_dev;