module probe not working
Steve Jardine
sjardine at acm.org
Sat Oct 20 19:20:12 PDT 2012
Lonni,
When I do an insmod module.ko, it loads. But I never see the printk's in the probe routine. This indicates, to me, that it is never getting to the probe routine. The probe routine is initializing a device so it can be used by another executable.
As a side note, this is an Arm embedded tablet. I am now exploring whether the manufacturer of the software has stuffed a board_info somewher where I have not found. This would mean that the i2c bus would not be loaded with the i2c address for this device.
Thanks..
Steve
On Sat, 20 Oct 2012 09:12:48 -0700
Lonni J Friedman <netllama at gmail.com> wrote:
> Sorry, but what's the actual problem that you're trying to solve? Are
> you saying that running 'modprobe mymodule' is silently(?) failing?
> Something else? How did you install this module?
>
> On Sat, Oct 20, 2012 at 12:08 AM, Steve Jardine <sjardine at acm.org> wrote:
> > Heya All,
> >
> > I have a module that I have written for an i2c device. It will load, but never gets into the probe routine. Any ideas?
> >
> > It has this basic structure:
> >
> > #include<linux/module.h>
> > #include<linux/delay.h>
> > #include<linux/err.h>
> > #include<linux/i2c.h>
> > #include<linux/interrupt.h>
> > #include<linux/kthread.h>
> > #include<linux/platform_device.h>
> >
> >
> > static int silly_probe(struct i2c_client *adapter,
> > const struct i2c_device_id *device_id);
> > static int silly_remove(struct i2c_client *client);
> >
> > static const struct i2c_device_id silly_id[] = { { "silly", 0 }, { }, };
> >
> > static struct i2c_driver silly_driver = {
> > .driver = {
> > .name = "silly",
> > .owner = THIS_MODULE,
> > },
> > .probe = silly_probe,
> > .remove = __devexit_p(silly_remove),
> > .id_table = silly_id,
> > };
> >
> > static int silly_probe(struct i2c_client *client,
> > const struct i2c_device_id *id)
> > {
> > char buf[10] = {0};
> > int res;
> >
> > //Configure device
> > buf[0]=0xE0;
> > buf[1]=0x60;
> > buf[2]=0xFC;
> > buf[3]=0x0C;
> > res=i2c_master_send(client, buf, 4);
> > if (res!= 4) {
> > /* ERROR HANDLING: i2c transaction failed */
> > printk(KERN_INFO "Failed to write to the i2c bus.\n");
> > }
> > return(res);
> > }
> >
> > /*!
> > * silly I2C detach function
> > *
> > * @param client struct i2c_client *
> > * @return Error code indicating success or failure
> > */
> > static int silly_remove(struct i2c_client *client) {
> > char buf[10] = {0};
> > int res;
> >
> > pr_info("*** %s", __FUNCTION__);
> > buf[0]=0x20; // Shutdown
> >
> > res=i2c_master_send(client, buf, 1);
> > if (res != 1) {
> > /* ERROR HANDLING: i2c transaction failed */
> > printk(KERN_INFO "Failed to write to the i2c bus.\n");
> > }
> >
> > return(res);
> > }
> >
> >
> > static int __init silly_init(void)
> > {
> > /* register driver */
> > int res = i2c_add_driver(&silly_driver);
> > if (res< 0) {
> > printk(KERN_INFO "add silly i2c driver failed\n");
> > return -ENODEV;
> > }
> > printk(KERN_INFO "added silly i2c driver\n");
> > return (res);
> > }
> > module_init(silly_init);
> >
> > static void __exit silly_exit(void)
> > {
> > printk(KERN_INFO "remove silly i2c driver.\n");
> > /* reset the silly */
> > i2c_del_driver(&silly_driver);
> > }
> >
> > module_exit(silly_exit);
> >
> > --
> > Steve Jardine <sjardine at acm.org>
> > _______________________________________________
> > Linux-users mailing list
> > Linux-users at linux-sxs.org
> > http://mailman.celestial.com/mailman/listinfo/linux-users
>
>
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> L. Friedman netllama at gmail.com
> LlamaLand https://netllama.linux-sxs.org
> _______________________________________________
> Linux-users mailing list
> Linux-users at linux-sxs.org
> http://mailman.celestial.com/mailman/listinfo/linux-users
--
Steve Jardine <sjardine at acm.org>
More information about the Linux-users
mailing list