Messages in this thread | | | From | Arnd Bergmann <> | Subject | Re: [PATCH] NFC: Driver for Inside Secure MicroRead NFC chip | Date | Tue, 29 Mar 2011 13:05:02 +0200 |
| |
On Tuesday 29 March 2011, Waldemar.Rymarkiewicz@tieto.com wrote: > >Yes, NFC seems to be a good fit for a new socket family. > >Especially if we ever want to have a proper NFC p2p support > >from the kernel. > >Sending HCI commands should be done through a dedicated > >netlink socket too. > > > >I am currently strting to work on such solution, and I hope to > >be able to come up with a basic prototype for it in a few weeks. > > What about common drivers interface in this case. > Should we go for common /dev/nfcX interface as well?
I fear there can only be one. A good implementation of a socket interface would mean that there is no need for a character device.
The difference between the two is where you keep the common NFC logic:
If you have a character device, it will be like a serial port connecting to a modem. Any higher-level protocols live in the user space and are limited to a single application then, which is required to have appropriate priviledges to open the device.
In contrast, a socket implementation puts the protocol stack into the kernel, which requires much more kernel code but almost no user space library code, aside from perhaps a small shim layer. It makes it possible to have multiple applications and/or users concurrently use NFC to make connections to separate endpoints. Since sockets have no implicit permission handling, the kernel code then needs to implement a way to enforce policy.
I still don't understand enough about NFC to judge which of the two is better suited for the problem, but my feeling is that a socket based implementation would be better if you expect a lot of people to use it, while the main advantage of the character device is its simplicity, so that would be preferred if you only expect a very small set of possible applications for this.
Arnd
| |