1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 30*7c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 31*7c478bd9Sstevel@tonic-gate #include <sys/param.h> 32*7c478bd9Sstevel@tonic-gate #include <sys/conf.h> 33*7c478bd9Sstevel@tonic-gate #include <sys/systm.h> 34*7c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 35*7c478bd9Sstevel@tonic-gate #include <sys/buf.h> 36*7c478bd9Sstevel@tonic-gate #include <sys/cred.h> 37*7c478bd9Sstevel@tonic-gate #include <sys/user.h> 38*7c478bd9Sstevel@tonic-gate #include <sys/stat.h> 39*7c478bd9Sstevel@tonic-gate #include <sys/uio.h> 40*7c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 41*7c478bd9Sstevel@tonic-gate #include <sys/fs/snode.h> 42*7c478bd9Sstevel@tonic-gate #include <sys/open.h> 43*7c478bd9Sstevel@tonic-gate #include <sys/kmem.h> 44*7c478bd9Sstevel@tonic-gate #include <sys/file.h> 45*7c478bd9Sstevel@tonic-gate #include <sys/debug.h> 46*7c478bd9Sstevel@tonic-gate #include <sys/tnf_probe.h> 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gate /* Don't #include <sys/ddi.h> - it #undef's getmajor() */ 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 51*7c478bd9Sstevel@tonic-gate #include <sys/sunndi.h> 52*7c478bd9Sstevel@tonic-gate #include <sys/sunpm.h> 53*7c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 54*7c478bd9Sstevel@tonic-gate #include <sys/ndi_impldefs.h> 55*7c478bd9Sstevel@tonic-gate #include <sys/esunddi.h> 56*7c478bd9Sstevel@tonic-gate #include <sys/autoconf.h> 57*7c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 58*7c478bd9Sstevel@tonic-gate #include <sys/epm.h> 59*7c478bd9Sstevel@tonic-gate #include <sys/dacf.h> 60*7c478bd9Sstevel@tonic-gate #include <sys/sunmdi.h> 61*7c478bd9Sstevel@tonic-gate #include <sys/instance.h> 62*7c478bd9Sstevel@tonic-gate #include <sys/sdt.h> 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate static void i_attach_ctlop(dev_info_t *, ddi_attach_cmd_t, ddi_pre_post_t, int); 65*7c478bd9Sstevel@tonic-gate static void i_detach_ctlop(dev_info_t *, ddi_detach_cmd_t, ddi_pre_post_t, int); 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate /* decide what to do when a double dev_lclose is detected */ 68*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 69*7c478bd9Sstevel@tonic-gate int dev_lclose_ce = CE_PANIC; 70*7c478bd9Sstevel@tonic-gate #else /* DEBUG */ 71*7c478bd9Sstevel@tonic-gate int dev_lclose_ce = CE_WARN; 72*7c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 73*7c478bd9Sstevel@tonic-gate 74*7c478bd9Sstevel@tonic-gate /* 75*7c478bd9Sstevel@tonic-gate * Configuration-related entry points for nexus and leaf drivers 76*7c478bd9Sstevel@tonic-gate */ 77*7c478bd9Sstevel@tonic-gate int 78*7c478bd9Sstevel@tonic-gate devi_identify(dev_info_t *devi) 79*7c478bd9Sstevel@tonic-gate { 80*7c478bd9Sstevel@tonic-gate struct dev_ops *ops; 81*7c478bd9Sstevel@tonic-gate int (*fn)(dev_info_t *); 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate if ((ops = ddi_get_driver(devi)) == NULL || 84*7c478bd9Sstevel@tonic-gate (fn = ops->devo_identify) == NULL) 85*7c478bd9Sstevel@tonic-gate return (-1); 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate return ((*fn)(devi)); 88*7c478bd9Sstevel@tonic-gate } 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate int 91*7c478bd9Sstevel@tonic-gate devi_probe(dev_info_t *devi) 92*7c478bd9Sstevel@tonic-gate { 93*7c478bd9Sstevel@tonic-gate int rv, probe_failed; 94*7c478bd9Sstevel@tonic-gate pm_ppm_cookie_t ppm_cookie; 95*7c478bd9Sstevel@tonic-gate struct dev_ops *ops; 96*7c478bd9Sstevel@tonic-gate int (*fn)(dev_info_t *); 97*7c478bd9Sstevel@tonic-gate 98*7c478bd9Sstevel@tonic-gate ops = ddi_get_driver(devi); 99*7c478bd9Sstevel@tonic-gate ASSERT(ops); 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate pm_pre_probe(devi, &ppm_cookie); 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate /* 104*7c478bd9Sstevel@tonic-gate * probe(9E) in 2.0 implies that you can get 105*7c478bd9Sstevel@tonic-gate * away with not writing one of these .. so we 106*7c478bd9Sstevel@tonic-gate * pretend we're 'nulldev' if we don't find one (sigh). 107*7c478bd9Sstevel@tonic-gate */ 108*7c478bd9Sstevel@tonic-gate if ((fn = ops->devo_probe) == NULL) 109*7c478bd9Sstevel@tonic-gate rv = DDI_PROBE_DONTCARE; 110*7c478bd9Sstevel@tonic-gate else 111*7c478bd9Sstevel@tonic-gate rv = (*fn)(devi); 112*7c478bd9Sstevel@tonic-gate 113*7c478bd9Sstevel@tonic-gate switch (rv) { 114*7c478bd9Sstevel@tonic-gate case DDI_PROBE_DONTCARE: 115*7c478bd9Sstevel@tonic-gate case DDI_PROBE_SUCCESS: 116*7c478bd9Sstevel@tonic-gate probe_failed = 0; 117*7c478bd9Sstevel@tonic-gate break; 118*7c478bd9Sstevel@tonic-gate default: 119*7c478bd9Sstevel@tonic-gate probe_failed = 1; 120*7c478bd9Sstevel@tonic-gate break; 121*7c478bd9Sstevel@tonic-gate } 122*7c478bd9Sstevel@tonic-gate pm_post_probe(&ppm_cookie, rv, probe_failed); 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate return (rv); 125*7c478bd9Sstevel@tonic-gate } 126*7c478bd9Sstevel@tonic-gate 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate /* 129*7c478bd9Sstevel@tonic-gate * devi_attach() 130*7c478bd9Sstevel@tonic-gate * attach a device instance to the system if the driver supplies an 131*7c478bd9Sstevel@tonic-gate * attach(9E) entrypoint. 132*7c478bd9Sstevel@tonic-gate */ 133*7c478bd9Sstevel@tonic-gate int 134*7c478bd9Sstevel@tonic-gate devi_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) 135*7c478bd9Sstevel@tonic-gate { 136*7c478bd9Sstevel@tonic-gate struct dev_ops *ops; 137*7c478bd9Sstevel@tonic-gate int error; 138*7c478bd9Sstevel@tonic-gate int (*fn)(dev_info_t *, ddi_attach_cmd_t); 139*7c478bd9Sstevel@tonic-gate pm_ppm_cookie_t pc; 140*7c478bd9Sstevel@tonic-gate 141*7c478bd9Sstevel@tonic-gate if ((error = mdi_pre_attach(devi, cmd)) != DDI_SUCCESS) { 142*7c478bd9Sstevel@tonic-gate return (error); 143*7c478bd9Sstevel@tonic-gate } 144*7c478bd9Sstevel@tonic-gate 145*7c478bd9Sstevel@tonic-gate pm_pre_attach(devi, &pc, cmd); 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate if ((cmd == DDI_RESUME || cmd == DDI_PM_RESUME) && 148*7c478bd9Sstevel@tonic-gate e_ddi_parental_suspend_resume(devi)) { 149*7c478bd9Sstevel@tonic-gate error = e_ddi_resume(devi, cmd); 150*7c478bd9Sstevel@tonic-gate goto done; 151*7c478bd9Sstevel@tonic-gate } 152*7c478bd9Sstevel@tonic-gate ops = ddi_get_driver(devi); 153*7c478bd9Sstevel@tonic-gate ASSERT(ops); 154*7c478bd9Sstevel@tonic-gate if ((fn = ops->devo_attach) == NULL) { 155*7c478bd9Sstevel@tonic-gate error = DDI_FAILURE; 156*7c478bd9Sstevel@tonic-gate goto done; 157*7c478bd9Sstevel@tonic-gate } 158*7c478bd9Sstevel@tonic-gate 159*7c478bd9Sstevel@tonic-gate /* 160*7c478bd9Sstevel@tonic-gate * Call the driver's attach(9e) entrypoint 161*7c478bd9Sstevel@tonic-gate */ 162*7c478bd9Sstevel@tonic-gate i_attach_ctlop(devi, cmd, DDI_PRE, 0); 163*7c478bd9Sstevel@tonic-gate error = (*fn)(devi, cmd); 164*7c478bd9Sstevel@tonic-gate i_attach_ctlop(devi, cmd, DDI_POST, error); 165*7c478bd9Sstevel@tonic-gate 166*7c478bd9Sstevel@tonic-gate done: 167*7c478bd9Sstevel@tonic-gate pm_post_attach(&pc, error); 168*7c478bd9Sstevel@tonic-gate mdi_post_attach(devi, cmd, error); 169*7c478bd9Sstevel@tonic-gate 170*7c478bd9Sstevel@tonic-gate return (error); 171*7c478bd9Sstevel@tonic-gate } 172*7c478bd9Sstevel@tonic-gate 173*7c478bd9Sstevel@tonic-gate /* 174*7c478bd9Sstevel@tonic-gate * devi_detach() 175*7c478bd9Sstevel@tonic-gate * detach a device instance from the system if the driver supplies a 176*7c478bd9Sstevel@tonic-gate * detach(9E) entrypoint. 177*7c478bd9Sstevel@tonic-gate */ 178*7c478bd9Sstevel@tonic-gate int 179*7c478bd9Sstevel@tonic-gate devi_detach(dev_info_t *devi, ddi_detach_cmd_t cmd) 180*7c478bd9Sstevel@tonic-gate { 181*7c478bd9Sstevel@tonic-gate struct dev_ops *ops; 182*7c478bd9Sstevel@tonic-gate int error; 183*7c478bd9Sstevel@tonic-gate int (*fn)(dev_info_t *, ddi_detach_cmd_t); 184*7c478bd9Sstevel@tonic-gate pm_ppm_cookie_t pc; 185*7c478bd9Sstevel@tonic-gate 186*7c478bd9Sstevel@tonic-gate ASSERT(cmd == DDI_SUSPEND || cmd == DDI_PM_SUSPEND || 187*7c478bd9Sstevel@tonic-gate cmd == DDI_DETACH); 188*7c478bd9Sstevel@tonic-gate 189*7c478bd9Sstevel@tonic-gate if ((cmd == DDI_SUSPEND || cmd == DDI_PM_SUSPEND) && 190*7c478bd9Sstevel@tonic-gate e_ddi_parental_suspend_resume(devi)) { 191*7c478bd9Sstevel@tonic-gate return (e_ddi_suspend(devi, cmd)); 192*7c478bd9Sstevel@tonic-gate } 193*7c478bd9Sstevel@tonic-gate ops = ddi_get_driver(devi); 194*7c478bd9Sstevel@tonic-gate ASSERT(ops); 195*7c478bd9Sstevel@tonic-gate if ((fn = ops->devo_detach) == NULL) 196*7c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 197*7c478bd9Sstevel@tonic-gate 198*7c478bd9Sstevel@tonic-gate if ((error = mdi_pre_detach(devi, cmd)) != DDI_SUCCESS) { 199*7c478bd9Sstevel@tonic-gate return (error); 200*7c478bd9Sstevel@tonic-gate } 201*7c478bd9Sstevel@tonic-gate i_detach_ctlop(devi, cmd, DDI_PRE, 0); 202*7c478bd9Sstevel@tonic-gate pm_pre_detach(devi, cmd, &pc); 203*7c478bd9Sstevel@tonic-gate 204*7c478bd9Sstevel@tonic-gate /* 205*7c478bd9Sstevel@tonic-gate * Call the driver's detach routine 206*7c478bd9Sstevel@tonic-gate */ 207*7c478bd9Sstevel@tonic-gate error = (*fn)(devi, cmd); 208*7c478bd9Sstevel@tonic-gate 209*7c478bd9Sstevel@tonic-gate pm_post_detach(&pc, error); 210*7c478bd9Sstevel@tonic-gate i_detach_ctlop(devi, cmd, DDI_POST, error); 211*7c478bd9Sstevel@tonic-gate mdi_post_detach(devi, cmd, error); 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gate return (error); 214*7c478bd9Sstevel@tonic-gate } 215*7c478bd9Sstevel@tonic-gate 216*7c478bd9Sstevel@tonic-gate static void 217*7c478bd9Sstevel@tonic-gate i_attach_ctlop(dev_info_t *devi, ddi_attach_cmd_t cmd, ddi_pre_post_t w, 218*7c478bd9Sstevel@tonic-gate int ret) 219*7c478bd9Sstevel@tonic-gate { 220*7c478bd9Sstevel@tonic-gate int error; 221*7c478bd9Sstevel@tonic-gate struct attachspec as; 222*7c478bd9Sstevel@tonic-gate dev_info_t *pdip = ddi_get_parent(devi); 223*7c478bd9Sstevel@tonic-gate 224*7c478bd9Sstevel@tonic-gate as.cmd = cmd; 225*7c478bd9Sstevel@tonic-gate as.when = w; 226*7c478bd9Sstevel@tonic-gate as.pdip = pdip; 227*7c478bd9Sstevel@tonic-gate as.result = ret; 228*7c478bd9Sstevel@tonic-gate (void) ddi_ctlops(devi, devi, DDI_CTLOPS_ATTACH, &as, &error); 229*7c478bd9Sstevel@tonic-gate } 230*7c478bd9Sstevel@tonic-gate 231*7c478bd9Sstevel@tonic-gate static void 232*7c478bd9Sstevel@tonic-gate i_detach_ctlop(dev_info_t *devi, ddi_detach_cmd_t cmd, ddi_pre_post_t w, 233*7c478bd9Sstevel@tonic-gate int ret) 234*7c478bd9Sstevel@tonic-gate { 235*7c478bd9Sstevel@tonic-gate int error; 236*7c478bd9Sstevel@tonic-gate struct detachspec ds; 237*7c478bd9Sstevel@tonic-gate dev_info_t *pdip = ddi_get_parent(devi); 238*7c478bd9Sstevel@tonic-gate 239*7c478bd9Sstevel@tonic-gate ds.cmd = cmd; 240*7c478bd9Sstevel@tonic-gate ds.when = w; 241*7c478bd9Sstevel@tonic-gate ds.pdip = pdip; 242*7c478bd9Sstevel@tonic-gate ds.result = ret; 243*7c478bd9Sstevel@tonic-gate (void) ddi_ctlops(devi, devi, DDI_CTLOPS_DETACH, &ds, &error); 244*7c478bd9Sstevel@tonic-gate } 245*7c478bd9Sstevel@tonic-gate 246*7c478bd9Sstevel@tonic-gate /* 247*7c478bd9Sstevel@tonic-gate * This entry point not defined by Solaris 2.0 DDI/DKI, so 248*7c478bd9Sstevel@tonic-gate * its inclusion here is somewhat moot. 249*7c478bd9Sstevel@tonic-gate */ 250*7c478bd9Sstevel@tonic-gate int 251*7c478bd9Sstevel@tonic-gate devi_reset(dev_info_t *devi, ddi_reset_cmd_t cmd) 252*7c478bd9Sstevel@tonic-gate { 253*7c478bd9Sstevel@tonic-gate struct dev_ops *ops; 254*7c478bd9Sstevel@tonic-gate int (*fn)(dev_info_t *, ddi_reset_cmd_t); 255*7c478bd9Sstevel@tonic-gate 256*7c478bd9Sstevel@tonic-gate if ((ops = ddi_get_driver(devi)) == NULL || 257*7c478bd9Sstevel@tonic-gate (fn = ops->devo_reset) == NULL) 258*7c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 259*7c478bd9Sstevel@tonic-gate 260*7c478bd9Sstevel@tonic-gate return ((*fn)(devi, cmd)); 261*7c478bd9Sstevel@tonic-gate } 262*7c478bd9Sstevel@tonic-gate 263*7c478bd9Sstevel@tonic-gate /* 264*7c478bd9Sstevel@tonic-gate * Leaf driver entry points. The following [cb]dev_* functions are *not* part 265*7c478bd9Sstevel@tonic-gate * of the DDI, please use functions defined in <sys/sunldi.h> and driver_lyr.c. 266*7c478bd9Sstevel@tonic-gate */ 267*7c478bd9Sstevel@tonic-gate int 268*7c478bd9Sstevel@tonic-gate dev_open(dev_t *devp, int flag, int type, struct cred *cred) 269*7c478bd9Sstevel@tonic-gate { 270*7c478bd9Sstevel@tonic-gate struct cb_ops *cb; 271*7c478bd9Sstevel@tonic-gate 272*7c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(*devp)]->devo_cb_ops; 273*7c478bd9Sstevel@tonic-gate return ((*cb->cb_open)(devp, flag, type, cred)); 274*7c478bd9Sstevel@tonic-gate } 275*7c478bd9Sstevel@tonic-gate 276*7c478bd9Sstevel@tonic-gate int 277*7c478bd9Sstevel@tonic-gate dev_close(dev_t dev, int flag, int type, struct cred *cred) 278*7c478bd9Sstevel@tonic-gate { 279*7c478bd9Sstevel@tonic-gate struct cb_ops *cb; 280*7c478bd9Sstevel@tonic-gate 281*7c478bd9Sstevel@tonic-gate cb = (devopsp[getmajor(dev)])->devo_cb_ops; 282*7c478bd9Sstevel@tonic-gate return ((*cb->cb_close)(dev, flag, type, cred)); 283*7c478bd9Sstevel@tonic-gate } 284*7c478bd9Sstevel@tonic-gate 285*7c478bd9Sstevel@tonic-gate /* 286*7c478bd9Sstevel@tonic-gate * New Leaf driver open entry point. We make a vnode and go through specfs 287*7c478bd9Sstevel@tonic-gate * in order to obtain open close exclusions guarantees. Note that we drop 288*7c478bd9Sstevel@tonic-gate * OTYP_LYR if it was specified - we are going through specfs and it provides 289*7c478bd9Sstevel@tonic-gate * last close semantics (FKLYR is provided to open(9E)). Also, since 290*7c478bd9Sstevel@tonic-gate * spec_open will drive attach via e_ddi_hold_devi_by_dev for a makespecvp 291*7c478bd9Sstevel@tonic-gate * vnode with no SDIP_SET on the common snode, the dev_lopen caller no longer 292*7c478bd9Sstevel@tonic-gate * needs to call ddi_hold_installed_driver. 293*7c478bd9Sstevel@tonic-gate */ 294*7c478bd9Sstevel@tonic-gate int 295*7c478bd9Sstevel@tonic-gate dev_lopen(dev_t *devp, int flag, int otype, struct cred *cred) 296*7c478bd9Sstevel@tonic-gate { 297*7c478bd9Sstevel@tonic-gate struct vnode *vp; 298*7c478bd9Sstevel@tonic-gate int error; 299*7c478bd9Sstevel@tonic-gate struct vnode *cvp; 300*7c478bd9Sstevel@tonic-gate 301*7c478bd9Sstevel@tonic-gate vp = makespecvp(*devp, (otype == OTYP_BLK) ? VBLK : VCHR); 302*7c478bd9Sstevel@tonic-gate error = VOP_OPEN(&vp, flag | FKLYR, cred); 303*7c478bd9Sstevel@tonic-gate if (error == 0) { 304*7c478bd9Sstevel@tonic-gate /* Pick up the (possibly) new dev_t value. */ 305*7c478bd9Sstevel@tonic-gate *devp = vp->v_rdev; 306*7c478bd9Sstevel@tonic-gate 307*7c478bd9Sstevel@tonic-gate /* 308*7c478bd9Sstevel@tonic-gate * Place extra hold on the common vnode, which contains the 309*7c478bd9Sstevel@tonic-gate * open count, so that it is not destroyed by the VN_RELE of 310*7c478bd9Sstevel@tonic-gate * the shadow makespecvp vnode below. 311*7c478bd9Sstevel@tonic-gate */ 312*7c478bd9Sstevel@tonic-gate cvp = STOV(VTOCS(vp)); 313*7c478bd9Sstevel@tonic-gate VN_HOLD(cvp); 314*7c478bd9Sstevel@tonic-gate } 315*7c478bd9Sstevel@tonic-gate 316*7c478bd9Sstevel@tonic-gate /* release the shadow makespecvp vnode. */ 317*7c478bd9Sstevel@tonic-gate VN_RELE(vp); 318*7c478bd9Sstevel@tonic-gate return (error); 319*7c478bd9Sstevel@tonic-gate } 320*7c478bd9Sstevel@tonic-gate 321*7c478bd9Sstevel@tonic-gate /* 322*7c478bd9Sstevel@tonic-gate * Leaf driver close entry point. We make a vnode and go through specfs in 323*7c478bd9Sstevel@tonic-gate * order to obtain open close exclusions guarantees. Note that we drop 324*7c478bd9Sstevel@tonic-gate * OTYP_LYR if it was specified - we are going through specfs and it provides 325*7c478bd9Sstevel@tonic-gate * last close semantics (FLKYR is provided to close(9E)). 326*7c478bd9Sstevel@tonic-gate */ 327*7c478bd9Sstevel@tonic-gate int 328*7c478bd9Sstevel@tonic-gate dev_lclose(dev_t dev, int flag, int otype, struct cred *cred) 329*7c478bd9Sstevel@tonic-gate { 330*7c478bd9Sstevel@tonic-gate struct vnode *vp; 331*7c478bd9Sstevel@tonic-gate int error; 332*7c478bd9Sstevel@tonic-gate struct vnode *cvp; 333*7c478bd9Sstevel@tonic-gate char *funcname; 334*7c478bd9Sstevel@tonic-gate ulong_t offset; 335*7c478bd9Sstevel@tonic-gate 336*7c478bd9Sstevel@tonic-gate vp = makespecvp(dev, (otype == OTYP_BLK) ? VBLK : VCHR); 337*7c478bd9Sstevel@tonic-gate error = VOP_CLOSE(vp, flag | FKLYR, 1, (offset_t)0, cred); 338*7c478bd9Sstevel@tonic-gate 339*7c478bd9Sstevel@tonic-gate /* 340*7c478bd9Sstevel@tonic-gate * Release the extra dev_lopen hold on the common vnode. We inline a 341*7c478bd9Sstevel@tonic-gate * VN_RELE(cvp) call so that we can detect more dev_lclose calls than 342*7c478bd9Sstevel@tonic-gate * dev_lopen calls without panic. See vn_rele. If our inline of 343*7c478bd9Sstevel@tonic-gate * vn_rele called VOP_INACTIVE(cvp, CRED()) we would panic on the 344*7c478bd9Sstevel@tonic-gate * "release the makespecvp vnode" VN_RELE(vp) that follows - so 345*7c478bd9Sstevel@tonic-gate * instead we diagnose this situation. Note that the driver has 346*7c478bd9Sstevel@tonic-gate * still seen a double close(9E), but that would have occurred with 347*7c478bd9Sstevel@tonic-gate * the old dev_close implementation too. 348*7c478bd9Sstevel@tonic-gate */ 349*7c478bd9Sstevel@tonic-gate cvp = STOV(VTOCS(vp)); 350*7c478bd9Sstevel@tonic-gate mutex_enter(&cvp->v_lock); 351*7c478bd9Sstevel@tonic-gate switch (cvp->v_count) { 352*7c478bd9Sstevel@tonic-gate default: 353*7c478bd9Sstevel@tonic-gate cvp->v_count--; 354*7c478bd9Sstevel@tonic-gate break; 355*7c478bd9Sstevel@tonic-gate 356*7c478bd9Sstevel@tonic-gate case 0: 357*7c478bd9Sstevel@tonic-gate VTOS(vp)->s_commonvp = NULL; /* avoid panic */ 358*7c478bd9Sstevel@tonic-gate /*FALLTHROUGH*/ 359*7c478bd9Sstevel@tonic-gate case 1: 360*7c478bd9Sstevel@tonic-gate /* 361*7c478bd9Sstevel@tonic-gate * The following message indicates a serious problem in the 362*7c478bd9Sstevel@tonic-gate * identified driver, the driver should be fixed. If obtaining 363*7c478bd9Sstevel@tonic-gate * a panic dump is needed to diagnose the driver problem then 364*7c478bd9Sstevel@tonic-gate * adding "set dev_lclose_ce=3" to /etc/system will cause a 365*7c478bd9Sstevel@tonic-gate * panic when this occurs. 366*7c478bd9Sstevel@tonic-gate */ 367*7c478bd9Sstevel@tonic-gate funcname = modgetsymname((uintptr_t)caller(), &offset); 368*7c478bd9Sstevel@tonic-gate cmn_err(dev_lclose_ce, "dev_lclose: extra close of dev_t 0x%lx " 369*7c478bd9Sstevel@tonic-gate "from %s`%s()", dev, mod_containing_pc(caller()), 370*7c478bd9Sstevel@tonic-gate funcname ? funcname : "unknown..."); 371*7c478bd9Sstevel@tonic-gate break; 372*7c478bd9Sstevel@tonic-gate } 373*7c478bd9Sstevel@tonic-gate mutex_exit(&cvp->v_lock); 374*7c478bd9Sstevel@tonic-gate 375*7c478bd9Sstevel@tonic-gate /* release the makespecvp vnode. */ 376*7c478bd9Sstevel@tonic-gate VN_RELE(vp); 377*7c478bd9Sstevel@tonic-gate return (error); 378*7c478bd9Sstevel@tonic-gate } 379*7c478bd9Sstevel@tonic-gate 380*7c478bd9Sstevel@tonic-gate /* 381*7c478bd9Sstevel@tonic-gate * Returns -1 or the instance number of the given dev_t as 382*7c478bd9Sstevel@tonic-gate * interpreted by the device driver. The code may load the driver 383*7c478bd9Sstevel@tonic-gate * but it does not attach any instances. 384*7c478bd9Sstevel@tonic-gate * 385*7c478bd9Sstevel@tonic-gate * Instance is supposed to be a int but drivers have assumed that 386*7c478bd9Sstevel@tonic-gate * the pointer was a pointer to "void *" instead of a pointer to 387*7c478bd9Sstevel@tonic-gate * "int *" so we now explicitly pass a pointer to "void *" and then 388*7c478bd9Sstevel@tonic-gate * cast the result to an int when returning the value. 389*7c478bd9Sstevel@tonic-gate */ 390*7c478bd9Sstevel@tonic-gate int 391*7c478bd9Sstevel@tonic-gate dev_to_instance(dev_t dev) 392*7c478bd9Sstevel@tonic-gate { 393*7c478bd9Sstevel@tonic-gate major_t major = getmajor(dev); 394*7c478bd9Sstevel@tonic-gate struct dev_ops *ops; 395*7c478bd9Sstevel@tonic-gate void *vinstance; 396*7c478bd9Sstevel@tonic-gate int error; 397*7c478bd9Sstevel@tonic-gate 398*7c478bd9Sstevel@tonic-gate /* verify that the major number is reasonable and driver is loaded */ 399*7c478bd9Sstevel@tonic-gate if ((major >= devcnt) || 400*7c478bd9Sstevel@tonic-gate ((ops = mod_hold_dev_by_major(major)) == NULL)) 401*7c478bd9Sstevel@tonic-gate return (-1); 402*7c478bd9Sstevel@tonic-gate ASSERT(CB_DRV_INSTALLED(ops)); 403*7c478bd9Sstevel@tonic-gate 404*7c478bd9Sstevel@tonic-gate /* verify that it supports the getinfo(9E) entry point */ 405*7c478bd9Sstevel@tonic-gate if (ops->devo_getinfo == NULL) { 406*7c478bd9Sstevel@tonic-gate mod_rele_dev_by_major(major); 407*7c478bd9Sstevel@tonic-gate return (-1); 408*7c478bd9Sstevel@tonic-gate } 409*7c478bd9Sstevel@tonic-gate 410*7c478bd9Sstevel@tonic-gate /* ask the driver to extract the instance number from the devt */ 411*7c478bd9Sstevel@tonic-gate error = (*ops->devo_getinfo)(NULL, DDI_INFO_DEVT2INSTANCE, 412*7c478bd9Sstevel@tonic-gate (void *)dev, &vinstance); 413*7c478bd9Sstevel@tonic-gate 414*7c478bd9Sstevel@tonic-gate /* release the driver */ 415*7c478bd9Sstevel@tonic-gate mod_rele_dev_by_major(major); 416*7c478bd9Sstevel@tonic-gate 417*7c478bd9Sstevel@tonic-gate if (error != DDI_SUCCESS) 418*7c478bd9Sstevel@tonic-gate return (-1); 419*7c478bd9Sstevel@tonic-gate 420*7c478bd9Sstevel@tonic-gate return ((int)(uintptr_t)vinstance); 421*7c478bd9Sstevel@tonic-gate } 422*7c478bd9Sstevel@tonic-gate 423*7c478bd9Sstevel@tonic-gate static void 424*7c478bd9Sstevel@tonic-gate bdev_strategy_tnf_probe(struct buf *bp) 425*7c478bd9Sstevel@tonic-gate { 426*7c478bd9Sstevel@tonic-gate /* Kernel probe */ 427*7c478bd9Sstevel@tonic-gate TNF_PROBE_5(strategy, "io blockio", /* CSTYLED */, 428*7c478bd9Sstevel@tonic-gate tnf_device, device, bp->b_edev, 429*7c478bd9Sstevel@tonic-gate tnf_diskaddr, block, bp->b_lblkno, 430*7c478bd9Sstevel@tonic-gate tnf_size, size, bp->b_bcount, 431*7c478bd9Sstevel@tonic-gate tnf_opaque, buf, bp, 432*7c478bd9Sstevel@tonic-gate tnf_bioflags, flags, bp->b_flags); 433*7c478bd9Sstevel@tonic-gate } 434*7c478bd9Sstevel@tonic-gate 435*7c478bd9Sstevel@tonic-gate int 436*7c478bd9Sstevel@tonic-gate bdev_strategy(struct buf *bp) 437*7c478bd9Sstevel@tonic-gate { 438*7c478bd9Sstevel@tonic-gate struct dev_ops *ops; 439*7c478bd9Sstevel@tonic-gate 440*7c478bd9Sstevel@tonic-gate ops = devopsp[getmajor(bp->b_edev)]; 441*7c478bd9Sstevel@tonic-gate 442*7c478bd9Sstevel@tonic-gate /* 443*7c478bd9Sstevel@tonic-gate * Before we hit the io:::start probe, we need to fill in the b_dip 444*7c478bd9Sstevel@tonic-gate * field of the buf structure. This should be -- for the most part -- 445*7c478bd9Sstevel@tonic-gate * incredibly cheap. If you're in this code looking to bum cycles, 446*7c478bd9Sstevel@tonic-gate * there is almost certainly bigger game further down the I/O path... 447*7c478bd9Sstevel@tonic-gate */ 448*7c478bd9Sstevel@tonic-gate (void) ops->devo_getinfo(NULL, DDI_INFO_DEVT2DEVINFO, 449*7c478bd9Sstevel@tonic-gate (void *)bp->b_edev, (void **)&bp->b_dip); 450*7c478bd9Sstevel@tonic-gate 451*7c478bd9Sstevel@tonic-gate DTRACE_IO1(start, struct buf *, bp); 452*7c478bd9Sstevel@tonic-gate bp->b_flags |= B_STARTED; 453*7c478bd9Sstevel@tonic-gate 454*7c478bd9Sstevel@tonic-gate /* 455*7c478bd9Sstevel@tonic-gate * Call the TNF probe here instead of the inline code 456*7c478bd9Sstevel@tonic-gate * to force our compiler to use the tail call optimization. 457*7c478bd9Sstevel@tonic-gate */ 458*7c478bd9Sstevel@tonic-gate bdev_strategy_tnf_probe(bp); 459*7c478bd9Sstevel@tonic-gate 460*7c478bd9Sstevel@tonic-gate return (ops->devo_cb_ops->cb_strategy(bp)); 461*7c478bd9Sstevel@tonic-gate } 462*7c478bd9Sstevel@tonic-gate 463*7c478bd9Sstevel@tonic-gate int 464*7c478bd9Sstevel@tonic-gate bdev_print(dev_t dev, caddr_t str) 465*7c478bd9Sstevel@tonic-gate { 466*7c478bd9Sstevel@tonic-gate struct cb_ops *cb; 467*7c478bd9Sstevel@tonic-gate 468*7c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 469*7c478bd9Sstevel@tonic-gate return ((*cb->cb_print)(dev, str)); 470*7c478bd9Sstevel@tonic-gate } 471*7c478bd9Sstevel@tonic-gate 472*7c478bd9Sstevel@tonic-gate int 473*7c478bd9Sstevel@tonic-gate bdev_size(dev_t dev) 474*7c478bd9Sstevel@tonic-gate { 475*7c478bd9Sstevel@tonic-gate return (e_ddi_getprop(dev, VBLK, "nblocks", 476*7c478bd9Sstevel@tonic-gate DDI_PROP_NOTPROM | DDI_PROP_DONTPASS, -1)); 477*7c478bd9Sstevel@tonic-gate } 478*7c478bd9Sstevel@tonic-gate 479*7c478bd9Sstevel@tonic-gate /* 480*7c478bd9Sstevel@tonic-gate * Same for 64-bit Nblocks property 481*7c478bd9Sstevel@tonic-gate */ 482*7c478bd9Sstevel@tonic-gate uint64_t 483*7c478bd9Sstevel@tonic-gate bdev_Size(dev_t dev) 484*7c478bd9Sstevel@tonic-gate { 485*7c478bd9Sstevel@tonic-gate return (e_ddi_getprop_int64(dev, VBLK, "Nblocks", 486*7c478bd9Sstevel@tonic-gate DDI_PROP_NOTPROM | DDI_PROP_DONTPASS, -1)); 487*7c478bd9Sstevel@tonic-gate } 488*7c478bd9Sstevel@tonic-gate 489*7c478bd9Sstevel@tonic-gate int 490*7c478bd9Sstevel@tonic-gate bdev_dump(dev_t dev, caddr_t addr, daddr_t blkno, int blkcnt) 491*7c478bd9Sstevel@tonic-gate { 492*7c478bd9Sstevel@tonic-gate struct cb_ops *cb; 493*7c478bd9Sstevel@tonic-gate 494*7c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 495*7c478bd9Sstevel@tonic-gate return ((*cb->cb_dump)(dev, addr, blkno, blkcnt)); 496*7c478bd9Sstevel@tonic-gate } 497*7c478bd9Sstevel@tonic-gate 498*7c478bd9Sstevel@tonic-gate int 499*7c478bd9Sstevel@tonic-gate cdev_read(dev_t dev, struct uio *uiop, struct cred *cred) 500*7c478bd9Sstevel@tonic-gate { 501*7c478bd9Sstevel@tonic-gate struct cb_ops *cb; 502*7c478bd9Sstevel@tonic-gate 503*7c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 504*7c478bd9Sstevel@tonic-gate return ((*cb->cb_read)(dev, uiop, cred)); 505*7c478bd9Sstevel@tonic-gate } 506*7c478bd9Sstevel@tonic-gate 507*7c478bd9Sstevel@tonic-gate int 508*7c478bd9Sstevel@tonic-gate cdev_write(dev_t dev, struct uio *uiop, struct cred *cred) 509*7c478bd9Sstevel@tonic-gate { 510*7c478bd9Sstevel@tonic-gate struct cb_ops *cb; 511*7c478bd9Sstevel@tonic-gate 512*7c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 513*7c478bd9Sstevel@tonic-gate return ((*cb->cb_write)(dev, uiop, cred)); 514*7c478bd9Sstevel@tonic-gate } 515*7c478bd9Sstevel@tonic-gate 516*7c478bd9Sstevel@tonic-gate int 517*7c478bd9Sstevel@tonic-gate cdev_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, struct cred *cred, 518*7c478bd9Sstevel@tonic-gate int *rvalp) 519*7c478bd9Sstevel@tonic-gate { 520*7c478bd9Sstevel@tonic-gate struct cb_ops *cb; 521*7c478bd9Sstevel@tonic-gate 522*7c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 523*7c478bd9Sstevel@tonic-gate return ((*cb->cb_ioctl)(dev, cmd, arg, mode, cred, rvalp)); 524*7c478bd9Sstevel@tonic-gate } 525*7c478bd9Sstevel@tonic-gate 526*7c478bd9Sstevel@tonic-gate int 527*7c478bd9Sstevel@tonic-gate cdev_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, size_t len, 528*7c478bd9Sstevel@tonic-gate size_t *maplen, uint_t mode) 529*7c478bd9Sstevel@tonic-gate { 530*7c478bd9Sstevel@tonic-gate struct cb_ops *cb; 531*7c478bd9Sstevel@tonic-gate 532*7c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 533*7c478bd9Sstevel@tonic-gate return ((*cb->cb_devmap)(dev, dhp, off, len, maplen, mode)); 534*7c478bd9Sstevel@tonic-gate } 535*7c478bd9Sstevel@tonic-gate 536*7c478bd9Sstevel@tonic-gate int 537*7c478bd9Sstevel@tonic-gate cdev_mmap(int (*mapfunc)(dev_t, off_t, int), dev_t dev, off_t off, int prot) 538*7c478bd9Sstevel@tonic-gate { 539*7c478bd9Sstevel@tonic-gate return ((*mapfunc)(dev, off, prot)); 540*7c478bd9Sstevel@tonic-gate } 541*7c478bd9Sstevel@tonic-gate 542*7c478bd9Sstevel@tonic-gate int 543*7c478bd9Sstevel@tonic-gate cdev_segmap(dev_t dev, off_t off, struct as *as, caddr_t *addrp, off_t len, 544*7c478bd9Sstevel@tonic-gate uint_t prot, uint_t maxprot, uint_t flags, cred_t *credp) 545*7c478bd9Sstevel@tonic-gate { 546*7c478bd9Sstevel@tonic-gate struct cb_ops *cb; 547*7c478bd9Sstevel@tonic-gate 548*7c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 549*7c478bd9Sstevel@tonic-gate return ((*cb->cb_segmap)(dev, off, as, addrp, 550*7c478bd9Sstevel@tonic-gate len, prot, maxprot, flags, credp)); 551*7c478bd9Sstevel@tonic-gate } 552*7c478bd9Sstevel@tonic-gate 553*7c478bd9Sstevel@tonic-gate int 554*7c478bd9Sstevel@tonic-gate cdev_poll(dev_t dev, short events, int anyyet, short *reventsp, 555*7c478bd9Sstevel@tonic-gate struct pollhead **pollhdrp) 556*7c478bd9Sstevel@tonic-gate { 557*7c478bd9Sstevel@tonic-gate struct cb_ops *cb; 558*7c478bd9Sstevel@tonic-gate 559*7c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 560*7c478bd9Sstevel@tonic-gate return ((*cb->cb_chpoll)(dev, events, anyyet, reventsp, pollhdrp)); 561*7c478bd9Sstevel@tonic-gate } 562*7c478bd9Sstevel@tonic-gate 563*7c478bd9Sstevel@tonic-gate /* 564*7c478bd9Sstevel@tonic-gate * A 'size' property can be provided by a VCHR device. 565*7c478bd9Sstevel@tonic-gate * 566*7c478bd9Sstevel@tonic-gate * Since it's defined as zero for STREAMS devices, so we avoid the 567*7c478bd9Sstevel@tonic-gate * overhead of looking it up. Note also that we don't force an 568*7c478bd9Sstevel@tonic-gate * unused driver into memory simply to ask about it's size. We also 569*7c478bd9Sstevel@tonic-gate * don't bother to ask it its size unless it's already been attached 570*7c478bd9Sstevel@tonic-gate * (the attach routine is the earliest place the property will be created) 571*7c478bd9Sstevel@tonic-gate * 572*7c478bd9Sstevel@tonic-gate * XXX In an ideal world, we'd call this at VOP_GETATTR() time. 573*7c478bd9Sstevel@tonic-gate */ 574*7c478bd9Sstevel@tonic-gate int 575*7c478bd9Sstevel@tonic-gate cdev_size(dev_t dev) 576*7c478bd9Sstevel@tonic-gate { 577*7c478bd9Sstevel@tonic-gate major_t maj; 578*7c478bd9Sstevel@tonic-gate struct devnames *dnp; 579*7c478bd9Sstevel@tonic-gate 580*7c478bd9Sstevel@tonic-gate if ((maj = getmajor(dev)) >= devcnt) 581*7c478bd9Sstevel@tonic-gate return (0); 582*7c478bd9Sstevel@tonic-gate 583*7c478bd9Sstevel@tonic-gate dnp = &(devnamesp[maj]); 584*7c478bd9Sstevel@tonic-gate LOCK_DEV_OPS(&dnp->dn_lock); 585*7c478bd9Sstevel@tonic-gate if (devopsp[maj] && devopsp[maj]->devo_cb_ops && 586*7c478bd9Sstevel@tonic-gate !devopsp[maj]->devo_cb_ops->cb_str) { 587*7c478bd9Sstevel@tonic-gate UNLOCK_DEV_OPS(&dnp->dn_lock); 588*7c478bd9Sstevel@tonic-gate return (e_ddi_getprop(dev, VCHR, "size", 589*7c478bd9Sstevel@tonic-gate DDI_PROP_NOTPROM | DDI_PROP_DONTPASS, 0)); 590*7c478bd9Sstevel@tonic-gate } 591*7c478bd9Sstevel@tonic-gate UNLOCK_DEV_OPS(&dnp->dn_lock); 592*7c478bd9Sstevel@tonic-gate return (0); 593*7c478bd9Sstevel@tonic-gate } 594*7c478bd9Sstevel@tonic-gate 595*7c478bd9Sstevel@tonic-gate /* 596*7c478bd9Sstevel@tonic-gate * same for 64-bit Size property 597*7c478bd9Sstevel@tonic-gate */ 598*7c478bd9Sstevel@tonic-gate uint64_t 599*7c478bd9Sstevel@tonic-gate cdev_Size(dev_t dev) 600*7c478bd9Sstevel@tonic-gate { 601*7c478bd9Sstevel@tonic-gate major_t maj; 602*7c478bd9Sstevel@tonic-gate struct devnames *dnp; 603*7c478bd9Sstevel@tonic-gate 604*7c478bd9Sstevel@tonic-gate if ((maj = getmajor(dev)) >= devcnt) 605*7c478bd9Sstevel@tonic-gate return (0); 606*7c478bd9Sstevel@tonic-gate 607*7c478bd9Sstevel@tonic-gate dnp = &(devnamesp[maj]); 608*7c478bd9Sstevel@tonic-gate LOCK_DEV_OPS(&dnp->dn_lock); 609*7c478bd9Sstevel@tonic-gate if (devopsp[maj] && devopsp[maj]->devo_cb_ops && 610*7c478bd9Sstevel@tonic-gate !devopsp[maj]->devo_cb_ops->cb_str) { 611*7c478bd9Sstevel@tonic-gate UNLOCK_DEV_OPS(&dnp->dn_lock); 612*7c478bd9Sstevel@tonic-gate return (e_ddi_getprop_int64(dev, VCHR, "Size", 613*7c478bd9Sstevel@tonic-gate DDI_PROP_NOTPROM | DDI_PROP_DONTPASS, 0)); 614*7c478bd9Sstevel@tonic-gate } 615*7c478bd9Sstevel@tonic-gate UNLOCK_DEV_OPS(&dnp->dn_lock); 616*7c478bd9Sstevel@tonic-gate return (0); 617*7c478bd9Sstevel@tonic-gate } 618*7c478bd9Sstevel@tonic-gate 619*7c478bd9Sstevel@tonic-gate /* 620*7c478bd9Sstevel@tonic-gate * XXX This routine is poorly named, because block devices can and do 621*7c478bd9Sstevel@tonic-gate * have properties (see bdev_size() above). 622*7c478bd9Sstevel@tonic-gate * 623*7c478bd9Sstevel@tonic-gate * XXX fix the comment in devops.h that claims that cb_prop_op 624*7c478bd9Sstevel@tonic-gate * is character-only. 625*7c478bd9Sstevel@tonic-gate */ 626*7c478bd9Sstevel@tonic-gate int 627*7c478bd9Sstevel@tonic-gate cdev_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags, 628*7c478bd9Sstevel@tonic-gate char *name, caddr_t valuep, int *lengthp) 629*7c478bd9Sstevel@tonic-gate { 630*7c478bd9Sstevel@tonic-gate struct cb_ops *cb; 631*7c478bd9Sstevel@tonic-gate 632*7c478bd9Sstevel@tonic-gate if ((cb = devopsp[DEVI(dip)->devi_major]->devo_cb_ops) == NULL) 633*7c478bd9Sstevel@tonic-gate return (DDI_PROP_NOT_FOUND); 634*7c478bd9Sstevel@tonic-gate 635*7c478bd9Sstevel@tonic-gate return ((*cb->cb_prop_op)(dev, dip, prop_op, mod_flags, 636*7c478bd9Sstevel@tonic-gate name, valuep, lengthp)); 637*7c478bd9Sstevel@tonic-gate } 638