Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/smbus/smbus.c
Show All 26 Lines | |||||
* | * | ||||
* | * | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/bus.h> | |||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/bus.h> | #include <sys/sbuf.h> | ||||
#include <dev/smbus/smbconf.h> | #include <dev/smbus/smbconf.h> | ||||
#include <dev/smbus/smbus.h> | #include <dev/smbus/smbus.h> | ||||
#include "smbus_if.h" | #include "smbus_if.h" | ||||
#include "bus_if.h" | #include "bus_if.h" | ||||
struct smbus_ivar | struct smbus_ivar | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | smbus_hinted_child(device_t bus, const char *dname, int dunit) | ||||
child = BUS_ADD_CHILD(bus, SMBUS_ORDER_HINTED, dname, dunit); | child = BUS_ADD_CHILD(bus, SMBUS_ORDER_HINTED, dname, dunit); | ||||
if (child == NULL) | if (child == NULL) | ||||
return; | return; | ||||
devi = device_get_ivars(child); | devi = device_get_ivars(child); | ||||
devi->addr = addr; | devi->addr = addr; | ||||
} | } | ||||
static int | static int | ||||
smbus_child_location_str(device_t parent, device_t child, char *buf, | smbus_child_location(device_t parent, device_t child, struct sbuf *sb) | ||||
size_t buflen) | |||||
{ | { | ||||
struct smbus_ivar *devi; | struct smbus_ivar *devi; | ||||
devi = device_get_ivars(child); | devi = device_get_ivars(child); | ||||
if (devi->addr != 0) | if (devi->addr != 0) | ||||
snprintf(buf, buflen, "addr=0x%x", devi->addr); | sbuf_printf(sb, "addr=0x%x", devi->addr); | ||||
else if (buflen) | |||||
buf[0] = 0; | |||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
smbus_print_child(device_t parent, device_t child) | smbus_print_child(device_t parent, device_t child) | ||||
{ | { | ||||
struct smbus_ivar *devi; | struct smbus_ivar *devi; | ||||
int retval; | int retval; | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | static device_method_t smbus_methods[] = { | ||||
DEVMETHOD(device_probe, smbus_probe), | DEVMETHOD(device_probe, smbus_probe), | ||||
DEVMETHOD(device_attach, smbus_attach), | DEVMETHOD(device_attach, smbus_attach), | ||||
DEVMETHOD(device_detach, smbus_detach), | DEVMETHOD(device_detach, smbus_detach), | ||||
/* bus interface */ | /* bus interface */ | ||||
DEVMETHOD(bus_add_child, smbus_add_child), | DEVMETHOD(bus_add_child, smbus_add_child), | ||||
DEVMETHOD(bus_hinted_child, smbus_hinted_child), | DEVMETHOD(bus_hinted_child, smbus_hinted_child), | ||||
DEVMETHOD(bus_probe_nomatch, smbus_probe_nomatch), | DEVMETHOD(bus_probe_nomatch, smbus_probe_nomatch), | ||||
DEVMETHOD(bus_child_location_str, smbus_child_location_str), | DEVMETHOD(bus_child_location, smbus_child_location), | ||||
DEVMETHOD(bus_print_child, smbus_print_child), | DEVMETHOD(bus_print_child, smbus_print_child), | ||||
DEVMETHOD(bus_read_ivar, smbus_read_ivar), | DEVMETHOD(bus_read_ivar, smbus_read_ivar), | ||||
DEVMETHOD(bus_write_ivar, smbus_write_ivar), | DEVMETHOD(bus_write_ivar, smbus_write_ivar), | ||||
DEVMETHOD_END | DEVMETHOD_END | ||||
}; | }; | ||||
driver_t smbus_driver = { | driver_t smbus_driver = { | ||||
"smbus", | "smbus", | ||||
smbus_methods, | smbus_methods, | ||||
sizeof(struct smbus_softc), | sizeof(struct smbus_softc), | ||||
}; | }; | ||||
devclass_t smbus_devclass; | devclass_t smbus_devclass; | ||||
MODULE_VERSION(smbus, SMBUS_MODVER); | MODULE_VERSION(smbus, SMBUS_MODVER); |