From: Michael Hunold <hunold-ml@web.de>
To: Greg KH <greg@kroah.com>
Cc: Michael Hunold <hunold@linuxtv.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
sensors@stimpy.netroedge.com
Subject: Re: [PATCH][2.6] Add command function to struct i2c_adapter
Date: Fri, 24 Sep 2004 19:06:41 +0200 [thread overview]
Message-ID: <41545421.5080408@web.de> (raw)
In-Reply-To: <20040921154111.GA13028@kroah.com>
Hi,
On 21.09.2004 17:41, Greg KH wrote:
> On Mon, Sep 20, 2004 at 07:19:24PM +0200, Michael Hunold wrote:
>
>>
>>+ /* a ioctl like command that can be used to perform specific functions
>>+ * with the adapter.
>>+ */
>>+ int (*command)(struct i2c_adapter *adapter, unsigned int cmd, void *arg);
>
>
> Ick ick ick. We don't like ioctls for the very reason they aren't type
> safe, and you can pretty much stick anything in there you want. So
> let's not try to add the same type of interface to another subsystem.
Ok, Gerd Knorr and I have been discussing this and we have come up with
the following idea.
We like to have an completly isolated i2c adapter, where the device
driver can invite i2c drivers to connect an i2c client to. When the
connection is made, an "interface" pointer with client-specific data or
function pointers can be provided.
- i2c adapter and i2c clients register themselves as usual
- add a new NO_PROBE flag to struct i2c_adapter, so a particular adapter
is never probed by anyone
- add these two functions to struct i2c_driver:
int (*connect)(struct i2c_adapter *adapter, void *interface, struct
i2c_client **client);
int (*disconnect)(struct i2c_client *client);
- add new generic i2c functions:
struct i2c_driver* i2c_driver_get(char *name);
void i2c_driver_put(struct i2c_driver *drv);
- the dvb-ttpci driver now can do the following:
struct stv0299_interface {
struct dvb_adapter *dvb_adap;
int tuner_addr;
};
struct stv0299_interface s_if;
struct i2c_driver *drv;
struct i2c_client *clt;
request_module("stv0299");
drv = i2c_driver_get("stv0299");
// fill s_if here
drv->connect(adap, &s_if, &clt);
Now inside the "connect" function of the stv0299 demodulator i2c driver
the device is probed, registered to the adapter and the pointer to the
interface with the h/w dependend information is stored.
> thanks,
> greg k-h
The crucial point is probably the void * interface pointer, isn't it? Is
this a no-no in this situation?
The dvb-ttpci driver is inviting a very specific driver, no probing
involved. The driver interface is well-defined and will only be hidden
behind the void * pointer to avoid a functional reference to the
demodulator driver.
We have discussed simply adding a type-safe stv0299-specific connect
function as well, but that would introduce a functional dependency. The
dvb-ttpci driver can be used with about 8 different frontend drivers, so
loading the driver would cause unnecessary frontend drivers to be loaded
as well.
CU
Michael.
next prev parent reply other threads:[~2004-09-24 17:11 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-20 17:19 [PATCH][2.6] Add command function to struct i2c_adapter Michael Hunold
2004-09-21 15:41 ` Greg KH
2004-09-21 17:10 ` Michael Hunold
2004-09-21 17:39 ` Jon Smirl
2004-09-21 18:05 ` Michael Hunold
2004-09-22 8:56 ` Adrian Cox
2004-09-22 12:08 ` Jean Delvare
2004-09-22 11:54 ` Adrian Cox
2004-09-22 13:38 ` Jean Delvare
2004-09-22 13:13 ` Adrian Cox
2004-09-22 15:40 ` Jon Smirl
2004-09-22 15:56 ` Adrian Cox
2004-09-22 16:07 ` Jon Smirl
2004-09-22 16:51 ` Adrian Cox
2004-09-22 17:17 ` Jon Smirl
2004-09-22 18:55 ` Jean Delvare
2004-09-22 18:32 ` Adrian Cox
2004-09-22 20:04 ` Mark M. Hoffman
2004-09-23 7:41 ` Michael Hunold
2004-09-23 7:48 ` Michael Hunold
2004-09-23 7:09 ` Michael Hunold
2004-09-23 20:18 ` Adrian Cox
2004-09-21 20:33 ` Jean Delvare
2004-09-21 21:02 ` Jon Smirl
2004-09-24 17:06 ` Michael Hunold [this message]
2004-09-24 18:05 ` Jean Delvare
2004-09-24 20:21 ` Michael Hunold
2004-10-01 6:52 ` Greg KH
2004-10-01 12:22 ` Adrian Cox
2004-10-01 13:57 ` Jean Delvare
2004-10-01 23:41 ` Greg KH
[not found] <41500BED.8090607@linuxtv.org>
2004-09-21 13:28 ` Jean Delvare
2004-09-21 14:38 ` Michael Hunold
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=41545421.5080408@web.de \
--to=hunold-ml@web.de \
--cc=greg@kroah.com \
--cc=hunold@linuxtv.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sensors@stimpy.netroedge.com \
/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