linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: core: export i2c_smbus_pec()
@ 2021-05-17  3:11 Matt Johnston
  2021-05-28  8:42 ` Wolfram Sang
  0 siblings, 1 reply; 3+ messages in thread
From: Matt Johnston @ 2021-05-17  3:11 UTC (permalink / raw)
  To: linux-i2c; +Cc: Jeremy Kerr

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c: core: export i2c_smbus_pec()
  2021-05-17  3:11 [PATCH] i2c: core: export i2c_smbus_pec() Matt Johnston
@ 2021-05-28  8:42 ` Wolfram Sang
  2021-06-25 15:06   ` Wolfram Sang
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfram Sang @ 2021-05-28  8:42 UTC (permalink / raw)
  To: Matt Johnston; +Cc: linux-i2c, Jeremy Kerr

[-- Attachment #1: Type: text/plain, Size: 468 bytes --]

On Mon, May 17, 2021 at 11:11:38AM +0800, Matt Johnston wrote:
> 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>

This is fine per se. Yet, there should be a user if we export it. So,
I suggest to resend it together with the slave driver using it and I
will ack this then.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c: core: export i2c_smbus_pec()
  2021-05-28  8:42 ` Wolfram Sang
@ 2021-06-25 15:06   ` Wolfram Sang
  0 siblings, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2021-06-25 15:06 UTC (permalink / raw)
  To: Matt Johnston; +Cc: linux-i2c, Jeremy Kerr

[-- Attachment #1: Type: text/plain, Size: 1035 bytes --]

On Fri, May 28, 2021 at 10:42:14AM +0200, Wolfram Sang wrote:
> On Mon, May 17, 2021 at 11:11:38AM +0800, Matt Johnston wrote:
> > 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>
> 
> This is fine per se. Yet, there should be a user if we export it. So,
> I suggest to resend it together with the slave driver using it and I
> will ack this then.

Okay, there was another user requesting this feature with a patch. It
also provided kdoc for i2c_smbus_pec. This, together with the simplified
dependencies of two users in flight, made me apply the other patch, so
you can base your work on top of for-next or 5.14 now. I added you with
an acked-by tag to have you credited, too. I hope you are fine with this
approach.

http://patchwork.ozlabs.org/project/linux-i2c/patch/20210519074934.20712-2-quan@os.amperecomputing.com/


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-25 15:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17  3:11 [PATCH] i2c: core: export i2c_smbus_pec() Matt Johnston
2021-05-28  8:42 ` Wolfram Sang
2021-06-25 15:06   ` Wolfram Sang

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).