On Fri, Sep 11, 2009 at 09:19, Hennerich, Michael wrote: > On Friday 11 September 2009, Song, Barry wrote: > +static int __init ad714x_init(void) > +{ > + > + int ret = 0; > + ret = ad714x_spi_register_driver(&ad714x_spi_driver); > + if (ret) > + goto err; > + ret = ad714x_i2c_add_driver(&ad714x_i2c_driver); > + if (ret) > + ad714x_spi_unregister_driver(&ad714x_spi_driver); > +err: > + return ret; > +} > + > +static void __exit ad714x_exit(void) > +{ > + ad714x_spi_unregister_driver(&ad714x_spi_driver); > + ad714x_i2c_del_driver(&ad714x_i2c_driver); > +} > > This doesn't make much sense! > Assuming we have two AD714x in a system. One connected by SPI the other > by I2C. > Why would I remove the SPI one in case the other I2C fails, or not even > try the SPI one if the I2C fails? is this a realistic problem ? we arent talking about failure to probe the device, we're talking about failure to register the driver as available. i.e. the only way the module_init step should fail is if i2c_add_driver() or spi_register_driver() fails. and if either of those fail, it's most likely a pretty bad situation. failure to probe/detect/talk to the device are a different issue and a problem with one interface will not affect the other. > Who says that a driver can't have two module_init()? Mr. C Code says it wont work. if ad714x is built as a module and both I2C and SPI support are enabled, we get: drivers/input/misc/ad714x.c:1621: error: redefinition of ‘__inittest’ drivers/input/misc/ad714x.c:1492: error: previous definition of ‘__inittest’ was here these lines correspond to the module_init() macro linux/init.h says: /* Each module must use one module_init(). */ #define module_init(initfn) \ static inline initcall_t __inittest(void) \ { return initfn; } \ int init_module(void) __attribute__((alias(#initfn))); and indeed, the error makes sense -- you cant have multiple functions named the same thing (in this case, we'd have two __inittest() and two init_module()) -mike -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html