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: 10075437 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 070A96057C for ; Sun, 26 Nov 2017 16:41:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED1FE28771 for ; Sun, 26 Nov 2017 16:41:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E214328A4C; Sun, 26 Nov 2017 16:41:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9089D28A72 for ; Sun, 26 Nov 2017 16:41:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=8DM95PV6zkDr1RIszxOmtCnTueJb1fF+00dxLPa5D8c=; b=ZBL60MrPIAzFXfU8MyYJC12OaF fHlBderAO2F/oSTxgWLsrv8rzkAuaEYH+DvEANfO40GiKBY4SAzw/pkNc18/yu36DYGqhZkGCUvcr AfeMkYDRaw5SURpk0+wI8TM1MQKP2Lda9vhK3CQ3PUg8Tl1f4kpbyBLFZvg8pdFqwgcnXjgyR6Qfd guUk8PHz+sf0lvO5bw1rLMnhMixO/N+rz3dp/4GS7/UngCmqTwM8ShGi1VOWy6gUVkfJnaGnibDYf rDfOd+PbBm9Z1uZinQyz4idewgrYkcmxw3XLi/Zm9MsRScI0P2r9tvBhZo3vA5qeIMsqoIet0GeM+ qfQZM/3w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eJ006-0001TW-TZ; Sun, 26 Nov 2017 16:41:50 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eJ000-0001G7-75 for linux-amlogic@lists.infradead.org; Sun, 26 Nov 2017 16:41:46 +0000 Received: by mail-wr0-x243.google.com with SMTP id z34so946995wrz.10 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=b62VAsXXvS19TuhWgW6Vb69azSDbpziymLOJGddEfKX1w7hiweZfd0AvOPIpisJlGC 2EA4XkKKcBlGAyK2y7MpNO2zPiEnbOzUeV5RFqFb6zedtO0YNBot9VYRDnPFXb2yuSrV UWc+6oPIqjz/FkGF8oq0Zp2D2d04ND+oLTkSQz33NgDDkw1WLpoOGltWXahK3MvSLj8M 4XHiNtQMDKrU64dTija9Aj/GAjQBVq7HfUuKTIeGJqn7vYhsXGEbdsXbUr9FhSTOGAP2 z25uon+f8FsxFiEoWrn2Efs1u61zm2w5Hm7d6N1VzvDKkICaqvP+DR5cURtcGbu7teYa Jz+Q== X-Gm-Message-State: AJaThX5m1PQ0OF37B0CELgaR0ghkGuTM3imIcd9hZGFsKSBmLbuAMVrc mdS8IO80vhT7t3t90QHH1/E= 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 Subject: [PATCH 4/4] i2c: meson: add some comments 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171126_084144_512501_A52DB463 X-CRM114-Status: GOOD ( 10.16 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Albert Aribaud , trini@konsulko.com, Martin Blumenstingl , Simon Glass , Neil Armstrong , Beniamino Galvani , linux-amlogic@lists.infradead.org, Heiko Schocher , =?UTF-8?q?Andreas=20F=C3=A4rber?= MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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);