Module Name: src Committed By: mbalmer Date: Sun Oct 2 11:38:48 UTC 2011
Modified Files: src/sys/dev/i2c: i2c.c Log Message: ii2c can be built as module. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/dev/i2c/i2c.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/i2c/i2c.c diff -u src/sys/dev/i2c/i2c.c:1.27 src/sys/dev/i2c/i2c.c:1.28 --- src/sys/dev/i2c/i2c.c:1.27 Tue Aug 2 18:46:35 2011 +++ src/sys/dev/i2c/i2c.c Sun Oct 2 11:38:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: i2c.c,v 1.27 2011/08/02 18:46:35 pgoyette Exp $ */ +/* $NetBSD: i2c.c,v 1.28 2011/10/02 11:38:48 mbalmer Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.27 2011/08/02 18:46:35 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.28 2011/10/02 11:38:48 mbalmer Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -47,6 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.27 #include <sys/kthread.h> #include <sys/proc.h> #include <sys/kernel.h> +#include <sys/module.h> #include <dev/i2c/i2cvar.h> @@ -116,7 +117,7 @@ iic_search(device_t parent, cfdata_t cf, ia.ia_compat = NULL; if (config_match(parent, cf, &ia) > 0) { - if (ia.ia_addr == (i2c_addr_t)-1) + if (ia.ia_addr == (i2c_addr_t)-1) config_attach(parent, cf, &ia, iic_print); else if (ia.ia_addr <= I2C_MAX_ADDR && !sc->sc_devices[ia.ia_addr]) @@ -341,7 +342,7 @@ iic_smbus_intr_establish(i2c_tag_t ic, i il = malloc(sizeof(struct ic_intr_list), M_DEVBUF, M_WAITOK); if (il == NULL) return NULL; - + il->il_intr = intr; il->il_intrarg = intrarg; @@ -371,7 +372,7 @@ iic_smbus_intr_establish_proc(i2c_tag_t il = malloc(sizeof(struct ic_intr_list), M_DEVBUF, M_WAITOK); if (il == NULL) return NULL; - + il->il_intr = intr; il->il_intrarg = intrarg; @@ -460,3 +461,37 @@ iic_compat_match(struct i2c_attach_args CFATTACH_DECL2_NEW(iic, sizeof(struct iic_softc), iic_match, iic_attach, NULL, NULL, iic_rescan, iic_child_detach); + +MODULE(MODULE_CLASS_DRIVER, iic, NULL); + +#ifdef _MODULE +#include "ioconf.c" +#endif + +static int +iic_modcmd(modcmd_t cmd, void *opaque) +{ + int error; + + error = 0; + switch (cmd) { + case MODULE_CMD_INIT: +#ifdef _MODULE + error = config_init_component(cfdriver_ioconf_iic, + cfattach_ioconf_iic, cfdata_ioconf_iic); + if (error) + aprint_error("%s: unable to init component\n", + iic_cd.cd_name); +#endif + break; + case MODULE_CMD_FINI: +#ifdef _MODULE + config_fini_component(cfdriver_ioconf_iic, + cfattach_ioconf_iic, cfdata_ioconf_iic); +#endif + break; + default: + error = ENOTTY; + } + return error; +}