introduce i2c-slave-mqueue
Subsystems (3)
cover introduce i2c-slave-mqueue
Wolfram,
I am sending you the i2c-slave-mqueue driver. Apparently Haiyue had to move on to another project and does not have cycles to continue with the comments on this driver after some time waiting for feedback,
that is essentially why I took over.
Here is a small changelog from V5 to V6:
- Added DT support for probing via Device Tree
- Docummented DT bindings
- Documented sysfs ABI
- Small fixes on wording and Kconfig entries.
Haiyue's V5: https://lkml.org/lkml/2018/4/23/835
BR,
Eduardo Valentin (2):
dt-bindings: i2c: document bindings for i2c-slave-mqueue
Documentation: ABI: Add i2c-slave-mqueue sysfs documentation
Haiyue Wang (1):
i2c: slave-mqueue: add a slave backend to receive and queue messages
.../sysfs-bus-i2c-devices-slave-mqueue | 10 + .../bindings/i2c/i2c-slave-mqueue.txt | 34 +++ Documentation/i2c/slave-mqueue-backend.rst | 124 ++++++++++ MAINTAINERS | 8 + drivers/i2c/Kconfig | 25 +++ drivers/i2c/Makefile | 1 + drivers/i2c/i2c-slave-mqueue.c | 211 ++++++++++++++++++ 7 files changed, 413 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-slave-mqueue create mode 100644 Documentation/devicetree/bindings/i2c/i2c-slave-mqueue.txt create mode 100644 Documentation/i2c/slave-mqueue-backend.rst create mode 100644 drivers/i2c/i2c-slave-mqueue.c
Signature · 1 line
2.21.0
PATCH 1/3 dt-bindings: i2c: document bindings for i2c-slave-mqueue
Document the i2c-slave-mqueue binding by adding
descriptor, required properties, and example.
--- .../bindings/i2c/i2c-slave-mqueue.txt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-slave-mqueue.txt
Documentation/devicetree/bindings/i2c/i2c-slave-mqueue.txt new file +34 -0
@@ -0,0 +1,34 @@ +=============================================== +Device Tree for I2C slave message queue backend +=============================================== + +Some protocols over I2C/SMBus are designed for bi-directional transferring +messages by using I2C Master Write protocol. This requires that both sides +of the communication have slave addresses. + +This I2C slave mqueue (message queue) is used to receive and queue +messages from the remote i2c intelligent device; and it will add the target +slave address (with R/W# bit is always 0) into the message at the first byte. + +Links +---- +`Intelligent Platform Management Bus +Communications Protocol Specification +<https://www.intel.com/content/dam/www/public/us/en/documents/product-briefs/ipmp-spec-v1.0.pdf>`_ + +`Management Component Transport Protocol (MCTP) +SMBus/I2C Transport Binding Specification +<https://www.dmtf.org/sites/default/files/standards/documents/DSP0237_1.1.0.pdf>`_ + +Required Properties: +- compatible : should be "i2c-slave-mqueue" +- reg : slave address + +Example: + +i2c { + slave_mqueue: i2c-slave-mqueue { + compatible = "i2c-slave-mqueue"; + reg = <0x10>; + }; +};
Signature · 1 line
2.21.0
PATCH 2/3 i2c: slave-mqueue: add a slave backend to receive and queue messages
In reply to Eduardo ValentinFrom: Haiyue Wang <[email protected]>
Some protocols over I2C are designed for bi-directional transferring messages by using I2C Master Write protocol. Like the MCTP (Management Component Transport Protocol) and IPMB (Intelligent Platform Management Bus), they both require that the userspace can receive messages from I2C dirvers under slave mode.
This new slave mqueue backend is used to receive and queue messages, it will exposes these messages to userspace by sysfs bin file.
Note: DT interface and a couple of minor fixes here and there by Eduardo, so I kept the original authorship here.
--- Documentation/i2c/slave-mqueue-backend.rst | 124 ++++++++++++ MAINTAINERS | 8 + drivers/i2c/Kconfig | 25 +++ drivers/i2c/Makefile | 1 + drivers/i2c/i2c-slave-mqueue.c | 211 +++++++++++++++++++++ 5 files changed, 369 insertions(+) create mode 100644 Documentation/i2c/slave-mqueue-backend.rst create mode 100644 drivers/i2c/i2c-slave-mqueue.c
Documentation/i2c/slave-mqueue-backend.rst new file +124 -0
@@ -0,0 +1,124 @@ +.. SPDX-License-Identifier: GPL-2.0 + +===================================== +Linux I2C slave message queue backend +===================================== + +:Author: Haiyue Wang <[email protected]> + +Some protocols over I2C/SMBus are designed for bi-directional transferring +messages by using I2C Master Write protocol. This requires that both sides +of the communication have slave addresses. + +Like MCTP (Management Component Transport Protocol) and IPMB (Intelligent +Platform Management Bus), they both require that the userspace can receive +messages from i2c drivers under slave mode. + +This I2C slave mqueue (message queue) backend is used to receive and queue +messages from the remote i2c intelligent device; and it will add the target +slave address (with R/W# bit is always 0) into the message at the first byte, +so that userspace can use this byte to dispatch the messages into different +handling modules. Also, like IPMB, the address byte is in its message format, +it needs it to do checksum. + +For messages are time related, so this backend will flush the oldest message +to queue the newest one. + +Link +---- +`Intelligent Platform Management Bus +Communications Protocol Specification +<https://www.intel.com/content/dam/www/public/us/en/documents/product-briefs/ipmp-spec-v1.0.pdf>`_ + +`Management Component Transport Protocol (MCTP) +SMBus/I2C Transport Binding Specification +<https://www.dmtf.org/sites/default/files/standards/documents/DSP0237_1.1.0.pdf>`_ + +How to use +---------- +For example, the I2C5 bus has slave address 0x10, the below command will create +the related message queue interface: + + echo slave-mqueue 0x1010 > /sys/bus/i2c/devices/i2c-5/new_device + +Then you can dump the messages like this: + + hexdump -C /sys/bus/i2c/devices/5-1010/slave-mqueue + +Code Example +------------ +*Note: call 'lseek' before 'read', this is a requirement from kernfs' design.* + +:: + + #include <sys/types.h> + #include <sys/stat.h> + #include <unistd.h> + #include <poll.h> + #include <time.h> + #include <fcntl.h> + #include <stdio.h> + + int main(int argc, char *argv[]) + { + int i, r; + struct pollfd pfd; + struct timespec ts; + unsigned char data[256]; + + pfd.fd = open(argv[1], O_RDONLY | O_NONBLOCK); + if (pfd.fd < 0) + return -1; + + pfd.events = POLLPRI; + + while (1) { + r = poll(&pfd, 1, 5000); + + if (r < 0) + break; + + if (r == 0 || !(pfd.revents & POLLPRI)) + continue; + + lseek(pfd.fd, 0, SEEK_SET); + r = read(pfd.fd, data, sizeof(data)); + if (r <= 0) + continue; + + clock_gettime(CLOCK_MONOTONIC, &ts); + printf("[%ld.%.9ld] :", ts.tv_sec, ts.tv_nsec); + for (i = 0; i < r; i++) + printf(" %02x", data[i]); + printf("\n"); + } + + close(pfd.fd); + + return 0; + } + +Result +------ +*./a.out "/sys/bus/i2c/devices/5-1010/slave-mqueue"* + +:: + + [10183.232500449] : 20 18 c8 2c 78 01 5b + [10183.479358348] : 20 18 c8 2c 78 01 5b + [10183.726556812] : 20 18 c8 2c 78 01 5b + [10183.972605863] : 20 18 c8 2c 78 01 5b + [10184.220124772] : 20 18 c8 2c 78 01 5b + [10184.467764166] : 20 18 c8 2c 78 01 5b + [10193.233421784] : 20 18 c8 2c 7c 01 57 + [10193.480273460] : 20 18 c8 2c 7c 01 57 + [10193.726788733] : 20 18 c8 2c 7c 01 57 + [10193.972781945] : 20 18 c8 2c 7c 01 57 + [10194.220487360] : 20 18 c8 2c 7c 01 57 + [10194.468089259] : 20 18 c8 2c 7c 01 57 + [10203.233433099] : 20 18 c8 2c 80 01 53 + [10203.481058715] : 20 18 c8 2c 80 01 53 + [10203.727610472] : 20 18 c8 2c 80 01 53 + [10203.974044856] : 20 18 c8 2c 80 01 53 + [10204.220734634] : 20 18 c8 2c 80 01 53 + [10204.468461664] : 20 18 c8 2c 80 01 53
MAINTAINERS +8 -0
@@ -7445,6 +7445,14 @@ L: [email protected] S: Maintained F: drivers/i2c/i2c-stub.c +I2C SLAVE MQUEUE DRIVER +M: Eduardo Valentin <[email protected]> +L: [email protected] +S: Maintained +F: drivers/i2c/i2c-slave-mqueue.c +F: Documentation/i2c/slave-mqueue-backend.rst +F: Documentation/devicetree/bindings/i2c/i2c-slave-mqueue.txt + I3C SUBSYSTEM M: Boris Brezillon <[email protected]> L: [email protected]
drivers/i2c/Kconfig +25 -0
@@ -119,6 +119,31 @@ if I2C_SLAVE config I2C_SLAVE_EEPROM tristate "I2C eeprom slave driver" +config I2C_SLAVE_MQUEUE + tristate "I2C mqueue (message queue) slave driver" + help + Some protocols over I2C are designed for bi-directional transferring + messages by using I2C Master Write protocol. This driver is used to + receive and queue messages from the remote I2C device. + + Userspace can get the messages by reading sysfs file that this driver + exposes. + + This support is also available as a module. If so, the module will be + called i2c-slave-mqueue. + +config I2C_SLAVE_MQUEUE_MESSAGE_SIZE + int "The message size of I2C mqueue slave" + depends on I2C_SLAVE_MQUEUE + default 120 + +config I2C_SLAVE_MQUEUE_QUEUE_SIZE + int "The queue size of I2C mqueue slave" + depends on I2C_SLAVE_MQUEUE + default 32 + help + This number MUST be power of 2. + endif config I2C_DEBUG_CORE
drivers/i2c/Makefile +1 -0
@@ -16,5 +16,6 @@ obj-$(CONFIG_I2C_MUX) += i2c-mux.o obj-y += algos/ busses/ muxes/ obj-$(CONFIG_I2C_STUB) += i2c-stub.o obj-$(CONFIG_I2C_SLAVE_EEPROM) += i2c-slave-eeprom.o +obj-$(CONFIG_I2C_SLAVE_MQUEUE) += i2c-slave-mqueue.o ccflags-$(CONFIG_I2C_DEBUG_CORE) := -DDEBUG
drivers/i2c/i2c-slave-mqueue.c new file +211 -0
211 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH 3/3 Documentation: ABI: Add i2c-slave-mqueue sysfs documentation
In reply to Eduardo ValentinDocument the slave-mqueue sysfs attribute used by
the i2c-slave-mqueue driver.
--- .../ABI/testing/sysfs-bus-i2c-devices-slave-mqueue | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-slave-mqueue
Documentation/ABI/testing/sysfs-bus-i2c-devices-slave-mqueue new file +10 -0
@@ -0,0 +1,10 @@ +What: /sys/bus/i2c/devices/*/slave-mqueue +Date: May 2019 +KernelVersion: 5.2 +Contact: Eduardo Valentin <[email protected]> +Description: + Reading to this file will return exactly one message, + when available, of the i2c-slave-mqueue device attached + to that bus. Userspace can also poll on this file to + get notified when new messages are available. +Users: i2c-slave-mqueue driver
Signature · 1 line
2.21.0
Re: [PATCH 2/3] i2c: slave-mqueue: add a slave backend to receive and queue messages
In reply to Eduardo ValentinQuoted 14 lines · Eduardo Valentin
From: Haiyue Wang <[email protected]>
Some protocols over I2C are designed for bi-directional transferring messages by using I2C Master Write protocol. Like the MCTP (Management Component Transport Protocol) and IPMB (Intelligent Platform Management Bus), they both require that the userspace can receive messages from I2C dirvers under slave mode.
This new slave mqueue backend is used to receive and queue messages, it will exposes these messages to userspace by sysfs bin file.
Note: DT interface and a couple of minor fixes here and there by Eduardo, so I kept the original authorship here.
drivers/i2c/i2c-slave-mqueue.c line 14
Quoted 4 lines
drivers/i2c/i2c-slave-mqueue.c new file +3
-0+#define MQ_MSGBUF_SIZE CONFIG_I2C_SLAVE_MQUEUE_MESSAGE_SIZE +#define MQ_QUEUE_SIZE CONFIG_I2C_SLAVE_MQUEUE_QUEUE_SIZE +#define MQ_QUEUE_NEXT (x) (((x) + 1) & (MQ_QUEUE_SIZE - 1))
Also possible ((x + 1) % ..._SIZE)
drivers/i2c/i2c-slave-mqueue.c line 95
Quoted 1 line
drivers/i2c/i2c-slave-mqueue.c new file +1
-0+ mq = dev_get_drvdata(container_of(kobj, struct device, kobj));
kobj_to_dev()
Quoted 4 lines
drivers/i2c/i2c-slave-mqueue.c new file +4
-0+static int i2c_slave_mqueue_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +struct device *dev = &client->dev;
drivers/i2c/i2c-slave-mqueue.c line 132
Quoted 10 lines
drivers/i2c/i2c-slave-mqueue.c new file +9
-0+struct mq_queue *mq; +int ret, i; +void *buf; + + mq =devm_kzalloc (dev,sizeof (*mq),GFP_KERNEL ); +if (!mq) +return -ENOMEM ; + +BUILD_BUG_ON (!is_power_of_2 (MQ_QUEUE_SIZE ));
Perhaps start function with this kind of assertions?
drivers/i2c/i2c-slave-mqueue.c line 140
Quoted 8 lines
drivers/i2c/i2c-slave-mqueue.c new file +8
-0+ + buf =devm_kmalloc_array (dev,MQ_QUEUE_SIZE ,MQ_MSGBUF_SIZE , +GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + +for (i =0 ; i <MQ_QUEUE_SIZE ; i++) + mq->queue[i].buf = buf + i *MQ_MSGBUF_SIZE ;
Just wondering if kfifo API can bring an advantage here?
drivers/i2c/i2c-slave-mqueue.c line 195
Quoted 9 lines
drivers/i2c/i2c-slave-mqueue.c new file +7
-0+return 0 ; +} +static const struct of_device_id i2c_slave_mqueue_of_match[] = { + { + .compatible ="i2c-slave-mqueue" , + }, + { },
No need for comma here.
drivers/i2c/i2c-slave-mqueue.c line 201
Quoted 8 lines
drivers/i2c/i2c-slave-mqueue.c new file +6
-0+}; + +static struct i2c_driver i2c_slave_mqueue_driver = { + .driver = { + .name ="i2c-slave-mqueue" , + .of_match_table =of_match_ptr (i2c_slave_mqueue_of_match),
Wouldn't compiler warn you due to unused data?
Perhaps drop of_match_ptr() for good...
Quoted 5 lines
drivers/i2c/i2c-slave-mqueue.c new file +5
-0+ }, + .probe = i2c_slave_mqueue_probe, + .remove = i2c_slave_mqueue_remove, + .id_table = i2c_slave_mqueue_id, +};
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 2/3] i2c: slave-mqueue: add a slave backend to receive and queue messages
Hey Andry,
Long time no seeing :-)
Quoted 15 lines · Andy Shevchenko
Quoted 13 lines · Eduardo Valentin
From: Haiyue Wang <[email protected]>
Some protocols over I2C are designed for bi-directional transferring messages by using I2C Master Write protocol. Like the MCTP (Management Component Transport Protocol) and IPMB (Intelligent Platform Management Bus), they both require that the userspace can receive messages from I2C dirvers under slave mode.
This new slave mqueue backend is used to receive and queue messages, it will exposes these messages to userspace by sysfs bin file.
Note: DT interface and a couple of minor fixes here and there by Eduardo, so I kept the original authorship here.
Quoted 6 lines
drivers/i2c/i2c-slave-mqueue.c line 14
Quoted 4 lines
drivers/i2c/i2c-slave-mqueue.c new file +3
-0+#define MQ_MSGBUF_SIZE CONFIG_I2C_SLAVE_MQUEUE_MESSAGE_SIZE +#define MQ_QUEUE_SIZE CONFIG_I2C_SLAVE_MQUEUE_QUEUE_SIZE +#define MQ_QUEUE_NEXT (x) (((x) + 1) & (MQ_QUEUE_SIZE - 1))Also possible ((x + 1) % ..._SIZE)
Right.. but I suppose the original idea is to avoid divisions on the hotpath.
So, I am actually fine with the limitation of only using power of 2.
Quoted 4 lines
drivers/i2c/i2c-slave-mqueue.c line 95
Quoted 2 lines
drivers/i2c/i2c-slave-mqueue.c new file +1
-0+ mq = dev_get_drvdata(container_of(kobj, struct device, kobj));
kobj_to_dev()
Well, yeah, I guess this is a nit, but I can add that in case of a real need for a v7.
Quoted 14 lines
Quoted 13 lines
drivers/i2c/i2c-slave-mqueue.c new file +12
-0+static int i2c_slave_mqueue_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +struct device *dev = &client->dev; +struct mq_queue *mq; +int ret, i; +void *buf; + + mq =devm_kzalloc (dev,sizeof (*mq),GFP_KERNEL ); +if (!mq) +return -ENOMEM ; +
Quoted 4 lines
drivers/i2c/i2c-slave-mqueue.c line 132
Quoted 1 line
drivers/i2c/i2c-slave-mqueue.c new file +1
-0+BUILD_BUG_ON (!is_power_of_2 (MQ_QUEUE_SIZE ));Perhaps start function with this kind of assertions?
same here, in case I see a huge ask for a v7, I can move this up.
Quoted 12 lines
drivers/i2c/i2c-slave-mqueue.c line 140
Quoted 8 lines
drivers/i2c/i2c-slave-mqueue.c new file +8
-0+ + buf =devm_kmalloc_array (dev,MQ_QUEUE_SIZE ,MQ_MSGBUF_SIZE , +GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + +for (i =0 ; i <MQ_QUEUE_SIZE ; i++) + mq->queue[i].buf = buf + i *MQ_MSGBUF_SIZE ;Just wondering if kfifo API can bring an advantage here?
Well, then again, I suppose the idea is simplify here, not if we need to go kfifo as the Protocol on top of this is perfectly fine with the current discipline of just having a simple drop of older messages.
Quoted 11 lines
drivers/i2c/i2c-slave-mqueue.c line 195
Quoted 9 lines
drivers/i2c/i2c-slave-mqueue.c new file +7
-0+return 0 ; +} +static const struct of_device_id i2c_slave_mqueue_of_match[] = { + { + .compatible ="i2c-slave-mqueue" , + }, + { },No need for comma here.
It does not hurt to have it either :-)
Quoted 8 lines
Quoted 7 lines
drivers/i2c/i2c-slave-mqueue.c new file +5
-0+}; + +static struct i2c_driver i2c_slave_mqueue_driver = { + .driver = { + .name ="i2c-slave-mqueue" ,
Quoted 4 lines
drivers/i2c/i2c-slave-mqueue.c line 201
Quoted 1 line
drivers/i2c/i2c-slave-mqueue.c new file +1
-0+ .of_match_table = of_match_ptr(i2c_slave_mqueue_of_match),Wouldn't compiler warn you due to unused data?
Perhaps dropof_match_ptr()for good...
Not sure what you meant here. I dont see any compiler warning. Also, of_match_ptr seams to be well spread in the kernel.
Quoted 12 lines
Quoted 6 lines
drivers/i2c/i2c-slave-mqueue.c new file +5
-0+ }, + .probe = i2c_slave_mqueue_probe, + .remove = i2c_slave_mqueue_remove, + .id_table = i2c_slave_mqueue_id, +};Signature · 2 lines
With Best Regards, Andy Shevchenko
Signature · 2 lines
All the best, Eduardo Valentin
Re: [PATCH 2/3] i2c: slave-mqueue: add a slave backend to receive and queue messages
Quoted 4 lines · Eduardo Valentin
Hey Andry,
Long time no seeing :-)
True!
Quoted 10 lines
Quoted 6 lines
drivers/i2c/i2c-slave-mqueue.c line 14
Quoted 4 lines
drivers/i2c/i2c-slave-mqueue.c new file +3
-0+#define MQ_MSGBUF_SIZE CONFIG_I2C_SLAVE_MQUEUE_MESSAGE_SIZE +#define MQ_QUEUE_SIZE CONFIG_I2C_SLAVE_MQUEUE_QUEUE_SIZE +#define MQ_QUEUE_NEXT (x) (((x) + 1) & (MQ_QUEUE_SIZE - 1))Also possible ((x + 1) % ..._SIZE)
Right.. but I suppose the original idea is to avoid divisions on the hotpath.
So, I am actually fine with the limitation of only using power of 2.
The original code implies that anyway, so, my proposal doesn't restrict it any farther.
Quoted 9 lines
Quoted 7 lines
drivers/i2c/i2c-slave-mqueue.c line 195
Quoted 5 lines
drivers/i2c/i2c-slave-mqueue.c new file +4
-0+ { + .compatible = "i2c-slave-mqueue", + }, + { },No need for comma here.
It does not hurt to have it either :-)
It's just a protection against some weird cases of adding entries behind the terminator.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
+ .of_match_table =
of_match_ptr(i2c_slave_mqueue_of_match),Wouldn't compiler warn you due to unused data?
Perhaps dropof_match_ptr()for good...Not sure what you meant here. I dont see any compiler warning. Also,
of_match_ptrseams to be well spread in the kernel.
If this will be compiled with CONFIG_OF=n...
Though I didn't check all dependencies to see if it even possible. In any case of_match_ptr() is redundant in both cases here. Either you need to protect i2c_slave_mqueue_of_match with #ifdef CONFIG_OF, or drop the macro use.
P.S. Taking into account the last part, I would wait for v7 with that fixed followed by fixing other nits.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 2/3] i2c: slave-mqueue: add a slave backend to receive and queue messages
Quoted 14 lines · Andy Shevchenko
Quoted 4 lines · Eduardo Valentin
Hey Andry,
Long time no seeing :-)
True!
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
drivers/i2c/i2c-slave-mqueue.c new file +3
-0+#define MQ_MSGBUF_SIZE CONFIG_I2C_SLAVE_MQUEUE_MESSAGE_SIZE +#define MQ_QUEUE_SIZE CONFIG_I2C_SLAVE_MQUEUE_QUEUE_SIZE +#define MQ_QUEUE_NEXT (x) (((x) + 1) & (MQ_QUEUE_SIZE - 1))
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Also possible ((x + 1) % ..._SIZE)
Right.. but I suppose the original idea is to avoid divisions on the hotpath.
So, I am actually fine with the limitation of only using power of 2.
The original code implies that anyway, so, my proposal doesn't restrict it any farther.
Well, yes, but the point is you would be switching from a simple AND (&) operation to a division...
I am keeping the power of 2 dep so that we can keep this with a simple &.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
drivers/i2c/i2c-slave-mqueue.c new file +3
-0+ { + .compatible = "i2c-slave-mqueue", + },
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
+ { },
No need for comma here.
It does not hurt to have it either :-)
It's just a protection against some weird cases of adding entries behind the terminator.
Fair..
Quoted 11 lines
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
+ .of_match_table =
of_match_ptr(i2c_slave_mqueue_of_match),Wouldn't compiler warn you due to unused data?
Perhaps dropof_match_ptr()for good...Not sure what you meant here. I dont see any compiler warning. Also,
of_match_ptrseams to be well spread in the kernel.If this will be compiled with
CONFIG_OF=n...
I see.. I obviously did not test with that config..
Quoted 4 lines
Though I didn't check all dependencies to see if it even possible. In any case
of_match_ptr()is redundant in both cases here. Either you need to protecti2c_slave_mqueue_of_matchwith #ifdefCONFIG_OF, or drop the macro use.
I will wrap it into CONFIG_OF..
Quoted 3 lines
P.S. Taking into account the last part, I would wait for v7 with that fixed followed by fixing other nits.
I agree, the warn on CONFIG_OF=n is enough to spin out an extra version. I will include the other nits too.
Quoted 4 lines
Signature · 3 lines
-- With Best Regards, Andy Shevchenko
Signature · 2 lines
All the best, Eduardo Valentin
Re: [PATCH 2/3] i2c: slave-mqueue: add a slave backend to receive and queue messages
Quoted 7 lines · Eduardo Valentin
Quoted 1 line · Andy Shevchenko
On Wed, Jun 5, 2019 at 6:30 AM Eduardo Valentin <[email protected]> wrote:
Well, yes, but the point is you would be switching from a simple AND (&) operation to a division...
I am keeping the power of 2 dep so that we can keep this with a simple &.
Works for me.
Quoted 10 lines
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
+ .of_match_table =
of_match_ptr(i2c_slave_mqueue_of_match),Wouldn't compiler warn you due to unused data?
Perhaps dropof_match_ptr()for good...Not sure what you meant here. I dont see any compiler warning. Also,
of_match_ptrseams to be well spread in the kernel.If this will be compiled with
CONFIG_OF=n...
Quoted 8 lines
I see.. I obviously did not test with that config..
Quoted 4 lines
Though I didn't check all dependencies to see if it even possible. In any case
of_match_ptr()is redundant in both cases here. Either you need to protecti2c_slave_mqueue_of_matchwith #ifdefCONFIG_OF, or drop the macro use.I will wrap it into
CONFIG_OF..
Would be this expected to work in the case of CONFIG_OF=n? If no, why to introduce ugly #ifdef:s and additional macros? Wouldn't be better to have
depends on OF || COMPILE_TEST
?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 2/3] i2c: slave-mqueue: add a slave backend to receive and queue messages
Quoted 28 lines · Andy Shevchenko
Quoted 7 lines · Eduardo Valentin
Quoted 1 line · Andy Shevchenko
On Wed, Jun 5, 2019 at 6:30 AM Eduardo Valentin <[email protected]> wrote:
Well, yes, but the point is you would be switching from a simple AND (&) operation to a division...
I am keeping the power of 2 dep so that we can keep this with a simple &.
Works for me.
Quoted 17 lines
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
+ .of_match_table =
of_match_ptr(i2c_slave_mqueue_of_match),Wouldn't compiler warn you due to unused data?
Perhaps dropof_match_ptr()for good...Not sure what you meant here. I dont see any compiler warning. Also,
of_match_ptrseams to be well spread in the kernel.If this will be compiled with
CONFIG_OF=n...I see.. I obviously did not test with that config..
Quoted 4 lines
Though I didn't check all dependencies to see if it even possible. In any case
of_match_ptr()is redundant in both cases here. Either you need to protecti2c_slave_mqueue_of_matchwith #ifdefCONFIG_OF, or drop the macro use.
Quoted 4 lines
Quoted 1 line
I will wrap it into
CONFIG_OF..Would be this expected to work in the case of
CONFIG_OF=n? If no, why to introduce ugly #ifdef:s and additional macros?
I do hate those too...
Quoted 2 lines
Wouldn't be better to have
depends on OF ||COMPILE_TEST
Well, technically, the original author had a case for using this without CONFIG_OF. That is why I did not force here to be a strong dependency on CONFIG_OF. So, I guess in this case the driver will work properly in both cases if we:
+#ifdef CONFIG_OF
+static const struct of_device_id i2c_slave_mqueue_of_match[] = {
+ {
+ .compatible = "i2c-slave-mqueue",
+ },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, i2c_slave_mqueue_of_match); +#endif
+
+static struct i2c_driver i2c_slave_mqueue_driver = {
+ .driver = {
+ .name = "i2c-slave-mqueue",
+ .of_match_table = of_match_ptr(i2c_slave_mqueue_of_match),
+ }, + .probe = i2c_slave_mqueue_probe, + .remove = i2c_slave_mqueue_remove, + .id_table = i2c_slave_mqueue_id,
+};
The above is a well stablish pattern across the drivers.
Quoted 5 lines
?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Signature · 2 lines
All the best, Eduardo Valentin
Re: [PATCH 2/3] i2c: slave-mqueue: add a slave backend to receive and queue messages
Quoted 57 lines · Eduardo Valentin
Quoted 21 lines · Andy Shevchenko
Quoted 20 lines · Eduardo Valentin
Quoted 11 lines · Andy Shevchenko
Quoted 7 lines · Eduardo Valentin
Quoted 4 lines
Quoted 1 line
+ .of_match_table =
of_match_ptr(i2c_slave_mqueue_of_match),Wouldn't compiler warn you due to unused data?
Perhaps dropof_match_ptr()for good...Not sure what you meant here. I dont see any compiler warning. Also,
of_match_ptrseams to be well spread in the kernel.If this will be compiled with
CONFIG_OF=n...I see.. I obviously did not test with that config..
Quoted 4 lines
Though I didn't check all dependencies to see if it even possible. In any case
of_match_ptr()is redundant in both cases here. Either you need to protecti2c_slave_mqueue_of_matchwith #ifdefCONFIG_OF, or drop the macro use.Quoted 4 lines
Quoted 1 line
I will wrap it into
CONFIG_OF..Would be this expected to work in the case of
CONFIG_OF=n? If no, why to introduce ugly #ifdef:s and additional macros?I do hate those too...
Quoted 2 lines
Wouldn't be better to have
depends on OF ||COMPILE_TESTWell, technically, the original author had a case for using this without
CONFIG_OF. That is why I did not force here to be a strong dependency onCONFIG_OF. So, I guess in this case the driver will work properly in both cases if we:(quoted diff) +19
-0+#ifdef CONFIG_OF +static const struct of_device_id i2c_slave_mqueue_of_match[] = { + { + .compatible = "i2c-slave-mqueue", + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, i2c_slave_mqueue_of_match); +#endif + +static struct i2c_driver i2c_slave_mqueue_driver = { + .driver = { + .name = "i2c-slave-mqueue", + .of_match_table = of_match_ptr(i2c_slave_mqueue_of_match), + }, + .probe = i2c_slave_mqueue_probe, + .remove = i2c_slave_mqueue_remove, + .id_table = i2c_slave_mqueue_id, +};
Quoted 1 line
The above is a well stablish pattern across the drivers.
My point here that you may achieve the same by simple dropping of_match_ptr().
P.S. Many of the drivers just old enough and not being simplified due to pointless churn there, but for new drivers we may avoid it.
Signature · 2 lines
With Best Regards, Andy Shevchenko