public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* How to manually call i2c_client's probe from i2c-dev.c ioctl
@ 2009-09-16 16:56 Chuck Kamas
       [not found] ` <C62896630644CE43BF64B0FF0AC27F0E18153F-RKsfjrak5bi0VCHWTNMfawC/G2K4zDHf@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Chuck Kamas @ 2009-09-16 16:56 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA

Hi all,

I am trying to backport Michael's patch to add PROBE and REMOVE ioctls
to 2.6.21
http://article.gmane.org/gmane.linux.drivers.i2c/3339/match=ioctls+probe

I have been able to add the IOCTLS and re-compile the kernel module, but
am confused as to what function to call in the old device model.  I
believe that I should use i2c_attach_client() from i2c-core.c.  Is this
correct?

This is what I have so far:

I2c-dev.c:
static int i2cdev_ioctl(struct inode *inode, struct file *file,
		unsigned int cmd, unsigned long arg)
{
	char   *colon, request[I2C_NAME_SIZE + 5];
	char   probeTemp[I2C_NAME_SIZE];
	int    addr;
...
	case I2C_PROBE:
		res = copy_from_user(request, (char *)arg,
sizeof(request));
		if (res)
			return res;
		colon = strchr(request, ',');
		if((!colon) || (colon - request > I2C_NAME_SIZE - 1))
			return -EINVAL;
		memset (probeTemp,0,sizeof(probeTemp)); // set the whole
buffer to 0 so that when the string is added it is automatically null
terminated.
		strncpy(probeTemp, request, colon - request);
		addr = simple_strtoul(colon + 1, NULL, 0);
		printk (KERN_ERR "got %s and %d\n",probeTemp,addr);
		printk (KERN_ERR "client info name: %s\n",
client->name);
		printk (KERN_ERR "client's adapter's name: %s\n",
client->adapter->name); // this is what probe wants
		/* Check for address business */
		if (i2c_check_addr(client->adapter, client->addr))
			return -EBUSY;

??? What call to put here to probe the actual chip ???

		return 0;


Thanks!
Chuck

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

end of thread, other threads:[~2009-09-17 16:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-16 16:56 How to manually call i2c_client's probe from i2c-dev.c ioctl Chuck Kamas
     [not found] ` <C62896630644CE43BF64B0FF0AC27F0E18153F-RKsfjrak5bi0VCHWTNMfawC/G2K4zDHf@public.gmane.org>
2009-09-16 20:52   ` Jean Delvare
     [not found]     ` <20090916225247.2094619b-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-09-16 23:25       ` Chuck Kamas
     [not found]         ` <C62896630644CE43BF64B0FF0AC27F0E1815B9-RKsfjrak5bi0VCHWTNMfawC/G2K4zDHf@public.gmane.org>
2009-09-17  7:26           ` Jean Delvare
     [not found]             ` <20090917092612.53327f80-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-09-17 15:45               ` Chuck Kamas
     [not found]                 ` <C62896630644CE43BF64B0FF0AC27F0E1815EC-RKsfjrak5bi0VCHWTNMfawC/G2K4zDHf@public.gmane.org>
2009-09-17 16:04                   ` Jean Delvare
     [not found]                     ` <20090917180407.5460bf33-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-09-17 16:38                       ` Chuck Kamas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox