From: Matt Johnston <matt@codeconstruct.com.au>
To: linux-i2c@vger.kernel.org
Cc: Jeremy Kerr <jk@codeconstruct.com.au>
Subject: [PATCH] i2c: core: export i2c_smbus_pec()
Date: Mon, 17 May 2021 11:11:38 +0800 [thread overview]
Message-ID: <20210517031138.133934-1-matt@codeconstruct.com.au> (raw)
I2C slave interface drivers have to calculate the PEC themselves
in the i2c slave event handler. This will be used for an in-progress
driver for MCTP I2C transport.
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
---
drivers/i2c/i2c-core-smbus.c | 3 ++-
include/linux/i2c.h | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c
index d2d32c0fd8c3..27a06b80decb 100644
--- a/drivers/i2c/i2c-core-smbus.c
+++ b/drivers/i2c/i2c-core-smbus.c
@@ -38,7 +38,7 @@ static u8 crc8(u16 data)
}
/* Incremental CRC8 over count bytes in the array pointed to by p */
-static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count)
+u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count)
{
int i;
@@ -46,6 +46,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count)
crc = crc8((crc ^ p[i]) << 8);
return crc;
}
+EXPORT_SYMBOL_GPL(i2c_smbus_pec);
/* Assume a 7-bit address, which is reasonable for SMBus */
static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg)
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index e8f2ac8c9c3d..9e5e5e8192c3 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -186,6 +186,8 @@ s32 i2c_smbus_read_i2c_block_data_or_emulated(const struct i2c_client *client,
u8 *values);
int i2c_get_device_id(const struct i2c_client *client,
struct i2c_device_identity *id);
+
+u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count);
#endif /* I2C */
/**
--
2.30.2
next reply other threads:[~2021-05-17 3:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-17 3:11 Matt Johnston [this message]
2021-05-28 8:42 ` [PATCH] i2c: core: export i2c_smbus_pec() Wolfram Sang
2021-06-25 15:06 ` Wolfram Sang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210517031138.133934-1-matt@codeconstruct.com.au \
--to=matt@codeconstruct.com.au \
--cc=jk@codeconstruct.com.au \
--cc=linux-i2c@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).