GETINFO(9E) | Driver Entry Points | GETINFO(9E) |
#include <sys/ddi.h> #include <sys/sunddi.h> int prefixgetinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **resultp);
cmd
arg
resultp
When cmd is set to DDI_INFO_DEVT2INSTANCE, getinfo() should return the instance number associated with the dev_t arg. The instance number should be returned in the field pointed to by resultp.
Drivers which do not export cb_ops(9S) entry points are not required to provide a getinfo() entry point, and may use nodev(9F) in the devo_getinfo field of the dev_ops(9S) structure. A SCSI HBA driver is an example of a driver which is not required to provide cb_ops(9S) entry points.
DDI_SUCCESS
DDI_FAILURE
/*ARGSUSED*/ static int rd_getinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **resultp) { /* * Note that in this simple example * the minor number is the instance * number. */ devstate_t *sp; int error = DDI_FAILURE; switch (infocmd) { case DDI_INFO_DEVT2DEVINFO: if ((sp = ddi_get_soft_state(statep, getminor((dev_t) arg))) != NULL) { *resultp = sp->devi; error = DDI_SUCCESS; } else *result = NULL; break; case DDI_INFO_DEVT2INSTANCE: *resultp = (void *) (uintptr_t) getminor((dev_t) arg); error = DDI_SUCCESS; break; } return (error); }
Writing Device Drivers
January 16, 2008 | OmniOS |