[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a2hcjLomPg3HmXAEacdzYtgCFvBQoE5AUBgsH+ETTu-ZA@mail.gmail.com>
Date: Mon, 31 Jan 2022 13:51:39 +0100
From: Arnd Bergmann <arnd@...db.de>
To: Sami Kyostila <skyostil@...omium.org>
Cc: Greg KH <gregkh@...uxfoundation.org>,
LKML <linux-kernel@...r.kernel.org>,
Dmitry Torokhov <dtor@...omium.org>, evanbenn@...omium.org,
Arnd Bergmann <arnd@...db.de>,
Linux I2C <linux-i2c@...r.kernel.org>,
Wolfram Sang <wsa@...nel.org>
Subject: Re: [PATCH 2/2] drivers/misc: add transfer ioctl for HPS
On Mon, Jan 31, 2022 at 9:23 AM Sami Kyostila <skyostil@...omium.org> wrote:
>
> I guess we could add an LSM hook for I2C transfers, but that would
> require baking device addresses into the SELinux policy which seems a
> little unfortunate.
>
> I think that leaves the options suggested by Arnd (thanks!):
>
> a) Add a generic way to expose device nodes for individual I2C devices
> (something like /dev/i2c/by-id/NN?).
>
> b) Make the ioctl interface more fully featured instead of just exposing I2C.
>
> I think I'm leaning toward (a) since it's not yet totally clear what
> the right high level abstraction for this type of device is (e.g.,
> should it be HID, in which case the protocol should probably become
> HID-I2C).
(adding i2c list to cc)
I think the implementation of the character device should be really
straightforward, it can probably just use the exact same ioctls
as the normal device, or a subset of them, and filter out any access
that has the wrong address with ioctl(fd, I2C_SLAVE, ...) or other
commands.
The tricky part is coming up with a sensible way of creating those
character device nodes, as there generic method of knowing what
is attached to the bus. I suppose this could be done either
automatically based on the nodes in DT, or it could be done
with user interaction like a new ioctl command on the normal
device node or some sysfs interface to create the chardev for
a particular slave device.
Arnd
Powered by blists - more mailing lists