From patchwork Sun Mar 2 14:48:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3749571 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 00F069F381 for ; Sun, 2 Mar 2014 14:48:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 19CC12037D for ; Sun, 2 Mar 2014 14:48:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4528320374 for ; Sun, 2 Mar 2014 14:48:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750789AbaCBOsq (ORCPT ); Sun, 2 Mar 2014 09:48:46 -0500 Received: from mail-pd0-f182.google.com ([209.85.192.182]:32876 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750788AbaCBOsq (ORCPT ); Sun, 2 Mar 2014 09:48:46 -0500 Received: by mail-pd0-f182.google.com with SMTP id g10so2711766pdj.27 for ; Sun, 02 Mar 2014 06:48:46 -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=r7d0zH+wzVFNLWnCwadaY5NL3WN60fq4lpOORKIUtJw=; b=llrSa6ZIjplxn6ay72a2Xe2Swc61nORMlsQ2JVe5uRL9j3ExZnpBfiGb5yfk2mKpB0 wzaixrJULx9nbuOtyErK3X2M4QkDwwilgkKu3420StSu4yty19wahOM2jel1ll9kYd5T uXCNsfCr4OL2ED1InWOH8uul6O4rH7PhG4qrUI42wQBouzigmMt0LhWu7KGrOLLE2+8A nZuPocQqrpEl6lyRW9QbC3qMACVmgQ0DmpedIlW9UTRloO/KAXUYk+rNGcWGiJ6rzfry 3SSj+cDpw4lSfyYWzh2Cij5aXhC3TbtD5koLB/1ZwKV0snYxV/9iuf/qqI/vzhdUAdeE PUZQ== X-Gm-Message-State: ALoCoQkv7JfxhZfZPeMFf96PsOYpL/RXpsOlZkR4UT1I10scDdOq8VSuC+/axZlKFqyYgv48qK5j X-Received: by 10.68.229.106 with SMTP id sp10mr14401008pbc.23.1393771726032; Sun, 02 Mar 2014 06:48:46 -0800 (PST) Received: from [192.168.0.102] (218-164-136-100.dynamic.hinet.net. [218.164.136.100]) by mx.google.com with ESMTPSA id ug2sm63033849pac.21.2014.03.02.06.48.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Mar 2014 06:48:45 -0800 (PST) Message-ID: <1393771721.4044.7.camel@phoenix> Subject: [PATCH] spi: xcomm: Remove duplicate code to set default bits_per_word and max speed From: Axel Lin To: Mark Brown Cc: Lars-Peter Clausen , linux-spi@vger.kernel.org Date: Sun, 02 Mar 2014 22:48:41 +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=-6.9 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 In the implementation of __spi_validate(), spi core will set transfer bits_per_word and max speed as spi device default if it is not set for this transfer. So we can remove the same logic in spi_xcomm_setup_transfer(). Also remove a redundant code to initialize is_first variable. Signed-off-by: Axel Lin Acked-by: Lars-Peter Clausen --- drivers/spi/spi-xcomm.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-xcomm.c b/drivers/spi/spi-xcomm.c index 350a76b..bb478dc 100644 --- a/drivers/spi/spi-xcomm.c +++ b/drivers/spi/spi-xcomm.c @@ -73,15 +73,13 @@ static void spi_xcomm_chipselect(struct spi_xcomm *spi_xcomm, static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm, struct spi_device *spi, struct spi_transfer *t, unsigned int *settings) { - unsigned int speed; - if (t->len > 62) return -EINVAL; - speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz; + if (t->speed_hz != spi_xcomm->current_speed) { + unsigned int divider; - if (speed != spi_xcomm->current_speed) { - unsigned int divider = DIV_ROUND_UP(SPI_XCOMM_CLOCK, speed); + divider = DIV_ROUND_UP(SPI_XCOMM_CLOCK, t->speed_hz); if (divider >= 64) *settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_64; else if (divider >= 16) @@ -89,7 +87,7 @@ static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm, else *settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_4; - spi_xcomm->current_speed = speed; + spi_xcomm->current_speed = t->speed_hz; } if (spi->mode & SPI_CPOL) @@ -147,8 +145,6 @@ static int spi_xcomm_transfer_one(struct spi_master *master, int status = 0; bool is_last; - is_first = true; - spi_xcomm_chipselect(spi_xcomm, spi, true); list_for_each_entry(t, &msg->transfers, transfer_list) {