From patchwork Wed Jul 30 08:30:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 4646541 X-Patchwork-Delegate: vinod.koul@intel.com Return-Path: X-Original-To: patchwork-dmaengine@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 3BD139F36A for ; Wed, 30 Jul 2014 08:36:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7224C2012B for ; Wed, 30 Jul 2014 08:36:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 989D320123 for ; Wed, 30 Jul 2014 08:36:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752001AbaG3IgW (ORCPT ); Wed, 30 Jul 2014 04:36:22 -0400 Received: from top.free-electrons.com ([176.31.233.9]:53534 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751381AbaG3IfG (ORCPT ); Wed, 30 Jul 2014 04:35:06 -0400 Received: by mail.free-electrons.com (Postfix, from userid 106) id 54ACAFBB; Wed, 30 Jul 2014 10:35:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from localhost (col31-4-88-188-83-94.fbx.proxad.net [88.188.83.94]) by mail.free-electrons.com (Postfix) with ESMTPSA id E626883C; Wed, 30 Jul 2014 10:35:04 +0200 (CEST) From: Maxime Ripard To: Dan Williams , Vinod Koul Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, Maxime Ripard Subject: [PATCH 1/3] dmaengine: sun6i: Remove switch statement from buswidth convertion routine Date: Wed, 30 Jul 2014 10:30:21 +0200 Message-Id: <1406709023-7650-2-git-send-email-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.0.2 In-Reply-To: <1406709023-7650-1-git-send-email-maxime.ripard@free-electrons.com> References: <1406709023-7650-1-git-send-email-maxime.ripard@free-electrons.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since the conversion routine is quite trivial, we don't need this switch, and we can just use a simple calculation. Signed-off-by: Maxime Ripard --- drivers/dma/sun6i-dma.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c index c771d90b8ded..609c5d8cb947 100644 --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -248,20 +248,11 @@ static inline int convert_burst(u32 maxburst, u8 *burst) static inline int convert_buswidth(enum dma_slave_buswidth addr_width, u8 *width) { - switch (addr_width) { - case DMA_SLAVE_BUSWIDTH_1_BYTE: - *width = 0; - break; - case DMA_SLAVE_BUSWIDTH_2_BYTES: - *width = 1; - break; - case DMA_SLAVE_BUSWIDTH_4_BYTES: - *width = 2; - break; - default: + if ((addr_width < DMA_SLAVE_BUSWIDTH_1_BYTE) || + (addr_width > DMA_SLAVE_BUSWIDTH_4_BYTES)) return -EINVAL; - } + *width = addr_width >> 1; return 0; }