From patchwork Sun Nov 26 16:40:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beniamino Galvani X-Patchwork-Id: 841417 X-Patchwork-Delegate: hs@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QwUg2kPo"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ylG3L1qznz9s0g for ; Mon, 27 Nov 2017 03:43:58 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C5CACC21E24; Sun, 26 Nov 2017 16:42:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 0B406C21DD0; Sun, 26 Nov 2017 16:41:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A934AC21E32; Sun, 26 Nov 2017 16:41:27 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by lists.denx.de (Postfix) with ESMTPS id 2D868C21E06 for ; Sun, 26 Nov 2017 16:41:23 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id k18so19257975wre.1 for ; Sun, 26 Nov 2017 08:41:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GqszJMpIPBvXwP2dnMsAg+qz9/cZVpT12MC8ALg9j38=; b=QwUg2kPoqcvdpSWYQJxXPQGfMTcjUNuieaFVXAAIGO+hVbacwD93IigGwxVkj4ypON jGgEDMPoGSlBc3At72LG9QMzxO0S9QmOPwo4HLrZBn5myFDKSbkLPJiEXWtjzL18lYny wWiNKk1jYP0Nx0KD+0seoUeNULqCcL9shrNxcItKieq8inFcrn/hQ0gvQuyAcUGXlWY+ bIMdRrnxFmv9/M88SYlUrD4Qn1g+p8I69T4Zf32E/uSobLfnmr1RmUGINxwMfUWxqHb4 L15JIwywsNiADMgTY/AtTKwA/Sk1AEgNQfngKBmeR+vd3BZUakJLYldCDwozW4GrVD5a bYGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GqszJMpIPBvXwP2dnMsAg+qz9/cZVpT12MC8ALg9j38=; b=UJdml7ATgZH3P0vF9+eLfRVC64IIUQtwaD/niTp6EjQOT6DoqHNUSiJRwktSVxUf4v Nq9/cMcoJH7pxtBo5sROnSBwHCdDlKwzWHKmJ9EqOGgD6Q4+PSTw/562DWb4wylWmNzc /wu+JWg3yoFMjPMW8zyRccTM+yLB3eOQSfulY2UuW5ZASF8IRu35gkEm0Nr3rKQELCT4 m3eR48crwzKMS5qe/bduMQbdPVFJB3eavMhOeARUHfIKxFw2d5JAnOyCM3Y/0S5RXEg9 /A/Sxltd+ziWLnCMo2d1723agy2vMCIuddhVQ/PqB0otnLlqYcYnp6GhiZposKk2pbRm sz1A== X-Gm-Message-State: AJaThX602TAyNAX9dtlADrOP+Y2Sc+rjYD6mFCEbiTzkG+Ha8RWdQtJh ekERjmK/vFO3NQzYsxVaocP7nt7y X-Google-Smtp-Source: AGs4zMbgsjthWA+Na2kTvwrUaeRAEZLD1I5tUDzCSeADyA0EZA++FlD/3cfo9P/h6Wgola2LSEFDIQ== X-Received: by 10.223.161.158 with SMTP id u30mr20248643wru.96.1511714482434; Sun, 26 Nov 2017 08:41:22 -0800 (PST) Received: from sark.homenet.telecomitalia.it (host78-28-dynamic.31-79-r.retail.telecomitalia.it. [79.31.28.78]) by smtp.gmail.com with ESMTPSA id k30sm47874486wrf.63.2017.11.26.08.41.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 26 Nov 2017 08:41:21 -0800 (PST) From: Beniamino Galvani To: u-boot@lists.denx.de Date: Sun, 26 Nov 2017 17:40:57 +0100 Message-Id: <20171126164057.27728-5-b.galvani@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171126164057.27728-1-b.galvani@gmail.com> References: <20171126164057.27728-1-b.galvani@gmail.com> Cc: trini@konsulko.com, Martin Blumenstingl , linux-amlogic@lists.infradead.org, =?utf-8?q?Andreas_F=C3=A4rber?= Subject: [U-Boot] [PATCH 4/4] i2c: meson: add some comments X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add some comment describing the purpose of struct members and functions. Signed-off-by: Beniamino Galvani Reviewed-by: Simon Glass Reviewed-by: Heiko Schocher --- drivers/i2c/meson_i2c.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/meson_i2c.c b/drivers/i2c/meson_i2c.c index 2f39214ad2..4f37d2f316 100644 --- a/drivers/i2c/meson_i2c.c +++ b/drivers/i2c/meson_i2c.c @@ -44,12 +44,12 @@ struct i2c_regs { struct meson_i2c { struct i2c_regs *regs; - struct i2c_msg *msg; - bool last; - uint count; - uint pos; - u32 tokens[2]; - uint num_tokens; + struct i2c_msg *msg; /* Current I2C message */ + bool last; /* Whether the message is the last */ + uint count; /* Number of bytes in the current transfer */ + uint pos; /* Position of current transfer in message */ + u32 tokens[2]; /* Sequence of tokens to be written */ + uint num_tokens; /* Number of tokens to be written */ }; static void meson_i2c_reset_tokens(struct meson_i2c *i2c) @@ -69,6 +69,10 @@ static void meson_i2c_add_token(struct meson_i2c *i2c, int token) i2c->num_tokens++; } +/* + * Retrieve data for the current transfer (which can be at most 8 + * bytes) from the device internal buffer. + */ static void meson_i2c_get_data(struct meson_i2c *i2c, u8 *buf, int len) { u32 rdata0, rdata1; @@ -86,6 +90,10 @@ static void meson_i2c_get_data(struct meson_i2c *i2c, u8 *buf, int len) *buf++ = (rdata1 >> (i - 4) * 8) & 0xff; } +/* + * Write data for the current transfer (which can be at most 8 bytes) + * to the device internal buffer. + */ static void meson_i2c_put_data(struct meson_i2c *i2c, u8 *buf, int len) { u32 wdata0 = 0, wdata1 = 0; @@ -103,6 +111,11 @@ static void meson_i2c_put_data(struct meson_i2c *i2c, u8 *buf, int len) debug("meson i2c: write data %08x %08x len %d\n", wdata0, wdata1, len); } +/* + * Prepare the next transfer: pick the next 8 bytes in the remaining + * part of message and write tokens and data (if needed) to the + * device. + */ static void meson_i2c_prepare_xfer(struct meson_i2c *i2c) { bool write = !(i2c->msg->flags & I2C_M_RD);