From patchwork Wed Dec 23 16:56:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 7913241 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AC7B8BEEED for ; Wed, 23 Dec 2015 16:57:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C374420460 for ; Wed, 23 Dec 2015 16:57:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A16A620465 for ; Wed, 23 Dec 2015 16:57:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752825AbbLWQ5R (ORCPT ); Wed, 23 Dec 2015 11:57:17 -0500 Received: from sauhun.de ([89.238.76.85]:58277 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751609AbbLWQ5Q (ORCPT ); Wed, 23 Dec 2015 11:57:16 -0500 Received: from p4fe25b6b.dip0.t-ipconnect.de ([79.226.91.107]:40625 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1aBmiw-0006an-Lo; Wed, 23 Dec 2015 17:57:14 +0100 From: Wolfram Sang To: linux-i2c@vger.kernel.org Cc: Wolfram Sang , linux-sh@vger.kernel.org, Magnus Damm , Yoshihiro Shimoda , Geert Uytterhoeven , Geert Uytterhoeven Subject: [PATCH 2/3] i2c: rcar: remove macros dealing with flags Date: Wed, 23 Dec 2015 17:56:33 +0100 Message-Id: <1450889794-9509-3-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1450889794-9509-1-git-send-email-wsa@the-dreams.de> References: <1450889794-9509-1-git-send-email-wsa@the-dreams.de> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@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 From: Wolfram Sang These macros don't really hide complexity, but C idioms. Removing them makes the code easier to read IMO and make a planned extension easier. Acked-by: Geert Uytterhoeven Signed-off-by: Wolfram Sang --- drivers/i2c/busses/i2c-rcar.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 74077e9ab8cad6..fab841899e65f2 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -122,9 +122,6 @@ struct rcar_i2c_priv { #define rcar_i2c_priv_to_dev(p) ((p)->adap.dev.parent) #define rcar_i2c_is_recv(p) ((p)->msg->flags & I2C_M_RD) -#define rcar_i2c_flags_set(p, f) ((p)->flags |= (f)) -#define rcar_i2c_flags_has(p, f) ((p)->flags & (f)) - #define LOOP_TIMEOUT 1024 @@ -258,7 +255,7 @@ static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv) priv->pos = 0; if (priv->msgs_left == 1) - rcar_i2c_flags_set(priv, ID_LAST_MSG); + priv->flags |= ID_LAST_MSG; rcar_i2c_write(priv, ICMAR, (priv->msg->addr << 1) | read); /* @@ -266,7 +263,7 @@ static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv) * of ICMSR and ICMCR depends on whether we issue START or REP_START. Since * it didn't cause a drawback for me, let's rather be safe than sorry. */ - if (rcar_i2c_flags_has(priv, ID_FIRST_MSG)) { + if (priv->flags & ID_FIRST_MSG) { rcar_i2c_write(priv, ICMSR, 0); rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START); } else { @@ -438,7 +435,7 @@ static irqreturn_t rcar_i2c_irq(int irq, void *ptr) /* Arbitration lost */ if (msr & MAL) { - rcar_i2c_flags_set(priv, (ID_DONE | ID_ARBLOST)); + priv->flags |= ID_DONE | ID_ARBLOST; goto out; } @@ -446,14 +443,14 @@ static irqreturn_t rcar_i2c_irq(int irq, void *ptr) if (msr & MNR) { /* HW automatically sends STOP after received NACK */ rcar_i2c_write(priv, ICMIER, RCAR_IRQ_STOP); - rcar_i2c_flags_set(priv, ID_NACK); + priv->flags |= ID_NACK; goto out; } /* Stop */ if (msr & MST) { priv->msgs_left--; /* The last message also made it */ - rcar_i2c_flags_set(priv, ID_DONE); + priv->flags |= ID_DONE; goto out; } @@ -463,7 +460,7 @@ static irqreturn_t rcar_i2c_irq(int irq, void *ptr) rcar_i2c_irq_send(priv, msr); out: - if (rcar_i2c_flags_has(priv, ID_DONE)) { + if (priv->flags & ID_DONE) { rcar_i2c_write(priv, ICMIER, 0); rcar_i2c_write(priv, ICMSR, 0); wake_up(&priv->wait); @@ -501,15 +498,14 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap, priv->flags = ID_FIRST_MSG; rcar_i2c_prepare_msg(priv); - time_left = wait_event_timeout(priv->wait, - rcar_i2c_flags_has(priv, ID_DONE), + time_left = wait_event_timeout(priv->wait, priv->flags & ID_DONE, num * adap->timeout); if (!time_left) { rcar_i2c_init(priv); ret = -ETIMEDOUT; - } else if (rcar_i2c_flags_has(priv, ID_NACK)) { + } else if (priv->flags & ID_NACK) { ret = -ENXIO; - } else if (rcar_i2c_flags_has(priv, ID_ARBLOST)) { + } else if (priv->flags & ID_ARBLOST) { ret = -EAGAIN; } else { ret = num - priv->msgs_left; /* The number of transfer */