1getinfo(9E)                   Driver Entry Points                  getinfo(9E)
2
3
4

NAME

6       getinfo - get device driver information
7

SYNOPSIS

9       #include <sys/ddi.h>
10       #include <sys/sunddi.h>
11
12
13
14       int prefixgetinfo(dev_info_t *dip, ddi_info_cmd_t cmd,
15            void *arg, void **resultp);
16
17

INTERFACE LEVEL

19       Solaris  DDI  specific  (Solaris DDI). This entry point is required for
20       drivers which export cb_ops(9S) entry points.
21

ARGUMENTS

23       dip        Do not use.
24
25
26       cmd        Command   argument    -    valid    command    values    are
27                  DDI_INFO_DEVT2DEVINFO and DDI_INFO_DEVT2INSTANCE.
28
29
30       arg        Command specific argument.
31
32
33       resultp    Pointer to where the requested information is stored.
34
35

DESCRIPTION

37       When  cmd  is set to DDI_INFO_DEVT2DEVINFO, getinfo() should return the
38       dev_info_t pointer  associated  with  the  dev_t  arg.  The  dev_info_t
39       pointer should be returned in the field pointed to by resultp.
40
41
42       When  cmd is set to DDI_INFO_DEVT2INSTANCE, getinfo() should return the
43       instance number associated with the  dev_t  arg.  The  instance  number
44       should be returned in the field pointed to by resultp.
45
46
47       Drivers which do not export cb_ops(9S) entry points are not required to
48       provide a getinfo() entry point, and may use nodev(9F) in the devo_get‐
49       info  field of the dev_ops(9S) structure. A SCSI HBA driver is an exam‐
50       ple of a driver which is  not  required  to  provide  cb_ops(9S)  entry
51       points.
52

RETURN VALUES

54       getinfo() should return:
55
56       DDI_SUCCESS    on success.
57
58
59       DDI_FAILURE    on failure.
60
61

EXAMPLES

63       Example 1 getinfo() implementation
64
65         /*ARGSUSED*/
66         static int
67         rd_getinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, \
68         void **resultp)
69         {
70                /* Note that in this simple example
71                 * the minor number is the instance
72                 * number.    */
73
74              devstate_t *sp;
75              int error = DDI_FAILURE;
76              switch (infocmd) {
77              case DDI_INFO_DEVT2DEVINFO:
78                   if ((sp = ddi_get_soft_state(statep,
79                       getminor((dev_t) arg))) != NULL) {
80                          *resultp = sp->devi;
81                          error = DDI_SUCCESS;
82                   } else
83                          *result = NULL;
84                   break;
85
86              case DDI_INFO_DEVT2INSTANCE:
87                   *resultp = (void *) (uintptr_t) getminor((dev_t) arg);
88                   error = DDI_SUCCESS;
89                   break;
90              }
91
92              return (error);
93         }
94
95

SEE ALSO

97       ddi_no_info(9F), nodev(9F), cb_ops(9S), dev_ops(9S)
98
99
100       Writing Device Drivers
101

NOTES

103       Non-gld(7D)-based DLPI network streams drivers are encouraged to switch
104       to gld(7D). Failing this, a driver that creates  DLPI  style-2    minor
105       nodes  must specify CLONE_DEV for its style-2 ddi_create_minor_node(9F)
106       nodes and use qassociate(9F). A driver that supports both  style-1  and
107       style-2     minor     nodes     should     return    DDI_FAILURE    for
108       DDI_INFO_DEVT2INSTANCE and  DDI_INFO_DEVT2DEVINFO  getinfo()  calls  to
109       style-2 minor nodes. (The correct association is already established by
110       qassociate(9F)). A driver that only supports style-2  minor  nodes  can
111       use  ddi_no_info(9F) for its getinfo() implementation. For drivers that
112       do not follow these rules, the results of a modunload(1M) of the driver
113       or  a  cfgadm(1M) remove of hardware controlled by the driver are unde‐
114       fined.
115
116
117
118SunOS 5.11                        16 Jan 2008                      getinfo(9E)
Impressum