17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5184cd04cScth * Common Development and Distribution License (the "License"). 6184cd04cScth * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22184cd04cScth * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #include <sys/types.h> 287c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 297c478bd9Sstevel@tonic-gate #include <sys/param.h> 307c478bd9Sstevel@tonic-gate #include <sys/conf.h> 317c478bd9Sstevel@tonic-gate #include <sys/systm.h> 327c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 337c478bd9Sstevel@tonic-gate #include <sys/buf.h> 347c478bd9Sstevel@tonic-gate #include <sys/cred.h> 357c478bd9Sstevel@tonic-gate #include <sys/user.h> 367c478bd9Sstevel@tonic-gate #include <sys/stat.h> 377c478bd9Sstevel@tonic-gate #include <sys/uio.h> 387c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 397c478bd9Sstevel@tonic-gate #include <sys/fs/snode.h> 407c478bd9Sstevel@tonic-gate #include <sys/open.h> 417c478bd9Sstevel@tonic-gate #include <sys/kmem.h> 427c478bd9Sstevel@tonic-gate #include <sys/file.h> 437c478bd9Sstevel@tonic-gate #include <sys/debug.h> 447c478bd9Sstevel@tonic-gate #include <sys/tnf_probe.h> 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* Don't #include <sys/ddi.h> - it #undef's getmajor() */ 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 497c478bd9Sstevel@tonic-gate #include <sys/sunndi.h> 507c478bd9Sstevel@tonic-gate #include <sys/sunpm.h> 517c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 527c478bd9Sstevel@tonic-gate #include <sys/ndi_impldefs.h> 537c478bd9Sstevel@tonic-gate #include <sys/esunddi.h> 547c478bd9Sstevel@tonic-gate #include <sys/autoconf.h> 557c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 567c478bd9Sstevel@tonic-gate #include <sys/epm.h> 577c478bd9Sstevel@tonic-gate #include <sys/dacf.h> 587c478bd9Sstevel@tonic-gate #include <sys/sunmdi.h> 597c478bd9Sstevel@tonic-gate #include <sys/instance.h> 607c478bd9Sstevel@tonic-gate #include <sys/sdt.h> 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate static void i_attach_ctlop(dev_info_t *, ddi_attach_cmd_t, ddi_pre_post_t, int); 637c478bd9Sstevel@tonic-gate static void i_detach_ctlop(dev_info_t *, ddi_detach_cmd_t, ddi_pre_post_t, int); 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /* decide what to do when a double dev_lclose is detected */ 667c478bd9Sstevel@tonic-gate #ifdef DEBUG 677c478bd9Sstevel@tonic-gate int dev_lclose_ce = CE_PANIC; 687c478bd9Sstevel@tonic-gate #else /* DEBUG */ 697c478bd9Sstevel@tonic-gate int dev_lclose_ce = CE_WARN; 707c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * Configuration-related entry points for nexus and leaf drivers 747c478bd9Sstevel@tonic-gate */ 757c478bd9Sstevel@tonic-gate int 767c478bd9Sstevel@tonic-gate devi_identify(dev_info_t *devi) 777c478bd9Sstevel@tonic-gate { 787c478bd9Sstevel@tonic-gate struct dev_ops *ops; 797c478bd9Sstevel@tonic-gate int (*fn)(dev_info_t *); 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate if ((ops = ddi_get_driver(devi)) == NULL || 827c478bd9Sstevel@tonic-gate (fn = ops->devo_identify) == NULL) 837c478bd9Sstevel@tonic-gate return (-1); 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate return ((*fn)(devi)); 867c478bd9Sstevel@tonic-gate } 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate int 897c478bd9Sstevel@tonic-gate devi_probe(dev_info_t *devi) 907c478bd9Sstevel@tonic-gate { 917c478bd9Sstevel@tonic-gate int rv, probe_failed; 927c478bd9Sstevel@tonic-gate pm_ppm_cookie_t ppm_cookie; 937c478bd9Sstevel@tonic-gate struct dev_ops *ops; 947c478bd9Sstevel@tonic-gate int (*fn)(dev_info_t *); 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate ops = ddi_get_driver(devi); 977c478bd9Sstevel@tonic-gate ASSERT(ops); 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate pm_pre_probe(devi, &ppm_cookie); 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate /* 1027c478bd9Sstevel@tonic-gate * probe(9E) in 2.0 implies that you can get 1037c478bd9Sstevel@tonic-gate * away with not writing one of these .. so we 1047c478bd9Sstevel@tonic-gate * pretend we're 'nulldev' if we don't find one (sigh). 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate if ((fn = ops->devo_probe) == NULL) 1077c478bd9Sstevel@tonic-gate rv = DDI_PROBE_DONTCARE; 1087c478bd9Sstevel@tonic-gate else 1097c478bd9Sstevel@tonic-gate rv = (*fn)(devi); 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate switch (rv) { 1127c478bd9Sstevel@tonic-gate case DDI_PROBE_DONTCARE: 1137c478bd9Sstevel@tonic-gate case DDI_PROBE_SUCCESS: 1147c478bd9Sstevel@tonic-gate probe_failed = 0; 1157c478bd9Sstevel@tonic-gate break; 1167c478bd9Sstevel@tonic-gate default: 1177c478bd9Sstevel@tonic-gate probe_failed = 1; 1187c478bd9Sstevel@tonic-gate break; 1197c478bd9Sstevel@tonic-gate } 1207c478bd9Sstevel@tonic-gate pm_post_probe(&ppm_cookie, rv, probe_failed); 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate return (rv); 1237c478bd9Sstevel@tonic-gate } 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate /* 1277c478bd9Sstevel@tonic-gate * devi_attach() 1287c478bd9Sstevel@tonic-gate * attach a device instance to the system if the driver supplies an 1297c478bd9Sstevel@tonic-gate * attach(9E) entrypoint. 1307c478bd9Sstevel@tonic-gate */ 1317c478bd9Sstevel@tonic-gate int 1327c478bd9Sstevel@tonic-gate devi_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) 1337c478bd9Sstevel@tonic-gate { 1347c478bd9Sstevel@tonic-gate struct dev_ops *ops; 1357c478bd9Sstevel@tonic-gate int error; 1367c478bd9Sstevel@tonic-gate int (*fn)(dev_info_t *, ddi_attach_cmd_t); 1377c478bd9Sstevel@tonic-gate pm_ppm_cookie_t pc; 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate if ((error = mdi_pre_attach(devi, cmd)) != DDI_SUCCESS) { 1407c478bd9Sstevel@tonic-gate return (error); 1417c478bd9Sstevel@tonic-gate } 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate pm_pre_attach(devi, &pc, cmd); 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate if ((cmd == DDI_RESUME || cmd == DDI_PM_RESUME) && 1467c478bd9Sstevel@tonic-gate e_ddi_parental_suspend_resume(devi)) { 1477c478bd9Sstevel@tonic-gate error = e_ddi_resume(devi, cmd); 1487c478bd9Sstevel@tonic-gate goto done; 1497c478bd9Sstevel@tonic-gate } 1507c478bd9Sstevel@tonic-gate ops = ddi_get_driver(devi); 1517c478bd9Sstevel@tonic-gate ASSERT(ops); 1527c478bd9Sstevel@tonic-gate if ((fn = ops->devo_attach) == NULL) { 1537c478bd9Sstevel@tonic-gate error = DDI_FAILURE; 1547c478bd9Sstevel@tonic-gate goto done; 1557c478bd9Sstevel@tonic-gate } 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate /* 1587c478bd9Sstevel@tonic-gate * Call the driver's attach(9e) entrypoint 1597c478bd9Sstevel@tonic-gate */ 1607c478bd9Sstevel@tonic-gate i_attach_ctlop(devi, cmd, DDI_PRE, 0); 1617c478bd9Sstevel@tonic-gate error = (*fn)(devi, cmd); 1627c478bd9Sstevel@tonic-gate i_attach_ctlop(devi, cmd, DDI_POST, error); 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate done: 1657c478bd9Sstevel@tonic-gate pm_post_attach(&pc, error); 1667c478bd9Sstevel@tonic-gate mdi_post_attach(devi, cmd, error); 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate return (error); 1697c478bd9Sstevel@tonic-gate } 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate /* 1727c478bd9Sstevel@tonic-gate * devi_detach() 1737c478bd9Sstevel@tonic-gate * detach a device instance from the system if the driver supplies a 1747c478bd9Sstevel@tonic-gate * detach(9E) entrypoint. 1757c478bd9Sstevel@tonic-gate */ 1767c478bd9Sstevel@tonic-gate int 1777c478bd9Sstevel@tonic-gate devi_detach(dev_info_t *devi, ddi_detach_cmd_t cmd) 1787c478bd9Sstevel@tonic-gate { 1797c478bd9Sstevel@tonic-gate struct dev_ops *ops; 1807c478bd9Sstevel@tonic-gate int error; 1817c478bd9Sstevel@tonic-gate int (*fn)(dev_info_t *, ddi_detach_cmd_t); 1827c478bd9Sstevel@tonic-gate pm_ppm_cookie_t pc; 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate ASSERT(cmd == DDI_SUSPEND || cmd == DDI_PM_SUSPEND || 1857c478bd9Sstevel@tonic-gate cmd == DDI_DETACH); 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate if ((cmd == DDI_SUSPEND || cmd == DDI_PM_SUSPEND) && 1887c478bd9Sstevel@tonic-gate e_ddi_parental_suspend_resume(devi)) { 1897c478bd9Sstevel@tonic-gate return (e_ddi_suspend(devi, cmd)); 1907c478bd9Sstevel@tonic-gate } 1917c478bd9Sstevel@tonic-gate ops = ddi_get_driver(devi); 1927c478bd9Sstevel@tonic-gate ASSERT(ops); 1937c478bd9Sstevel@tonic-gate if ((fn = ops->devo_detach) == NULL) 1947c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate if ((error = mdi_pre_detach(devi, cmd)) != DDI_SUCCESS) { 1977c478bd9Sstevel@tonic-gate return (error); 1987c478bd9Sstevel@tonic-gate } 1997c478bd9Sstevel@tonic-gate i_detach_ctlop(devi, cmd, DDI_PRE, 0); 2007c478bd9Sstevel@tonic-gate pm_pre_detach(devi, cmd, &pc); 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate /* 2037c478bd9Sstevel@tonic-gate * Call the driver's detach routine 2047c478bd9Sstevel@tonic-gate */ 2057c478bd9Sstevel@tonic-gate error = (*fn)(devi, cmd); 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate pm_post_detach(&pc, error); 2087c478bd9Sstevel@tonic-gate i_detach_ctlop(devi, cmd, DDI_POST, error); 2097c478bd9Sstevel@tonic-gate mdi_post_detach(devi, cmd, error); 2107c478bd9Sstevel@tonic-gate 2117c478bd9Sstevel@tonic-gate return (error); 2127c478bd9Sstevel@tonic-gate } 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate static void 2157c478bd9Sstevel@tonic-gate i_attach_ctlop(dev_info_t *devi, ddi_attach_cmd_t cmd, ddi_pre_post_t w, 2167c478bd9Sstevel@tonic-gate int ret) 2177c478bd9Sstevel@tonic-gate { 2187c478bd9Sstevel@tonic-gate int error; 2197c478bd9Sstevel@tonic-gate struct attachspec as; 2207c478bd9Sstevel@tonic-gate dev_info_t *pdip = ddi_get_parent(devi); 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate as.cmd = cmd; 2237c478bd9Sstevel@tonic-gate as.when = w; 2247c478bd9Sstevel@tonic-gate as.pdip = pdip; 2257c478bd9Sstevel@tonic-gate as.result = ret; 2267c478bd9Sstevel@tonic-gate (void) ddi_ctlops(devi, devi, DDI_CTLOPS_ATTACH, &as, &error); 2277c478bd9Sstevel@tonic-gate } 2287c478bd9Sstevel@tonic-gate 2297c478bd9Sstevel@tonic-gate static void 2307c478bd9Sstevel@tonic-gate i_detach_ctlop(dev_info_t *devi, ddi_detach_cmd_t cmd, ddi_pre_post_t w, 2317c478bd9Sstevel@tonic-gate int ret) 2327c478bd9Sstevel@tonic-gate { 2337c478bd9Sstevel@tonic-gate int error; 2347c478bd9Sstevel@tonic-gate struct detachspec ds; 2357c478bd9Sstevel@tonic-gate dev_info_t *pdip = ddi_get_parent(devi); 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate ds.cmd = cmd; 2387c478bd9Sstevel@tonic-gate ds.when = w; 2397c478bd9Sstevel@tonic-gate ds.pdip = pdip; 2407c478bd9Sstevel@tonic-gate ds.result = ret; 2417c478bd9Sstevel@tonic-gate (void) ddi_ctlops(devi, devi, DDI_CTLOPS_DETACH, &ds, &error); 2427c478bd9Sstevel@tonic-gate } 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate /* 2457c478bd9Sstevel@tonic-gate * This entry point not defined by Solaris 2.0 DDI/DKI, so 2467c478bd9Sstevel@tonic-gate * its inclusion here is somewhat moot. 2477c478bd9Sstevel@tonic-gate */ 2487c478bd9Sstevel@tonic-gate int 2497c478bd9Sstevel@tonic-gate devi_reset(dev_info_t *devi, ddi_reset_cmd_t cmd) 2507c478bd9Sstevel@tonic-gate { 2517c478bd9Sstevel@tonic-gate struct dev_ops *ops; 2527c478bd9Sstevel@tonic-gate int (*fn)(dev_info_t *, ddi_reset_cmd_t); 2537c478bd9Sstevel@tonic-gate 2547c478bd9Sstevel@tonic-gate if ((ops = ddi_get_driver(devi)) == NULL || 2557c478bd9Sstevel@tonic-gate (fn = ops->devo_reset) == NULL) 2567c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 2577c478bd9Sstevel@tonic-gate 2587c478bd9Sstevel@tonic-gate return ((*fn)(devi, cmd)); 2597c478bd9Sstevel@tonic-gate } 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate /* 2627c478bd9Sstevel@tonic-gate * Leaf driver entry points. The following [cb]dev_* functions are *not* part 2637c478bd9Sstevel@tonic-gate * of the DDI, please use functions defined in <sys/sunldi.h> and driver_lyr.c. 2647c478bd9Sstevel@tonic-gate */ 2657c478bd9Sstevel@tonic-gate int 2667c478bd9Sstevel@tonic-gate dev_open(dev_t *devp, int flag, int type, struct cred *cred) 2677c478bd9Sstevel@tonic-gate { 2687c478bd9Sstevel@tonic-gate struct cb_ops *cb; 2697c478bd9Sstevel@tonic-gate 2707c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(*devp)]->devo_cb_ops; 2717c478bd9Sstevel@tonic-gate return ((*cb->cb_open)(devp, flag, type, cred)); 2727c478bd9Sstevel@tonic-gate } 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate int 2757c478bd9Sstevel@tonic-gate dev_close(dev_t dev, int flag, int type, struct cred *cred) 2767c478bd9Sstevel@tonic-gate { 2777c478bd9Sstevel@tonic-gate struct cb_ops *cb; 2787c478bd9Sstevel@tonic-gate 2797c478bd9Sstevel@tonic-gate cb = (devopsp[getmajor(dev)])->devo_cb_ops; 2807c478bd9Sstevel@tonic-gate return ((*cb->cb_close)(dev, flag, type, cred)); 2817c478bd9Sstevel@tonic-gate } 2827c478bd9Sstevel@tonic-gate 2837c478bd9Sstevel@tonic-gate /* 2847c478bd9Sstevel@tonic-gate * New Leaf driver open entry point. We make a vnode and go through specfs 2857c478bd9Sstevel@tonic-gate * in order to obtain open close exclusions guarantees. Note that we drop 2867c478bd9Sstevel@tonic-gate * OTYP_LYR if it was specified - we are going through specfs and it provides 2877c478bd9Sstevel@tonic-gate * last close semantics (FKLYR is provided to open(9E)). Also, since 2887c478bd9Sstevel@tonic-gate * spec_open will drive attach via e_ddi_hold_devi_by_dev for a makespecvp 2897c478bd9Sstevel@tonic-gate * vnode with no SDIP_SET on the common snode, the dev_lopen caller no longer 2907c478bd9Sstevel@tonic-gate * needs to call ddi_hold_installed_driver. 2917c478bd9Sstevel@tonic-gate */ 2927c478bd9Sstevel@tonic-gate int 2937c478bd9Sstevel@tonic-gate dev_lopen(dev_t *devp, int flag, int otype, struct cred *cred) 2947c478bd9Sstevel@tonic-gate { 2957c478bd9Sstevel@tonic-gate struct vnode *vp; 2967c478bd9Sstevel@tonic-gate int error; 2977c478bd9Sstevel@tonic-gate struct vnode *cvp; 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate vp = makespecvp(*devp, (otype == OTYP_BLK) ? VBLK : VCHR); 300*da6c28aaSamw error = VOP_OPEN(&vp, flag | FKLYR, cred, NULL); 3017c478bd9Sstevel@tonic-gate if (error == 0) { 3027c478bd9Sstevel@tonic-gate /* Pick up the (possibly) new dev_t value. */ 3037c478bd9Sstevel@tonic-gate *devp = vp->v_rdev; 3047c478bd9Sstevel@tonic-gate 3057c478bd9Sstevel@tonic-gate /* 3067c478bd9Sstevel@tonic-gate * Place extra hold on the common vnode, which contains the 3077c478bd9Sstevel@tonic-gate * open count, so that it is not destroyed by the VN_RELE of 3087c478bd9Sstevel@tonic-gate * the shadow makespecvp vnode below. 3097c478bd9Sstevel@tonic-gate */ 3107c478bd9Sstevel@tonic-gate cvp = STOV(VTOCS(vp)); 3117c478bd9Sstevel@tonic-gate VN_HOLD(cvp); 3127c478bd9Sstevel@tonic-gate } 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate /* release the shadow makespecvp vnode. */ 3157c478bd9Sstevel@tonic-gate VN_RELE(vp); 3167c478bd9Sstevel@tonic-gate return (error); 3177c478bd9Sstevel@tonic-gate } 3187c478bd9Sstevel@tonic-gate 3197c478bd9Sstevel@tonic-gate /* 3207c478bd9Sstevel@tonic-gate * Leaf driver close entry point. We make a vnode and go through specfs in 3217c478bd9Sstevel@tonic-gate * order to obtain open close exclusions guarantees. Note that we drop 3227c478bd9Sstevel@tonic-gate * OTYP_LYR if it was specified - we are going through specfs and it provides 3237c478bd9Sstevel@tonic-gate * last close semantics (FLKYR is provided to close(9E)). 3247c478bd9Sstevel@tonic-gate */ 3257c478bd9Sstevel@tonic-gate int 3267c478bd9Sstevel@tonic-gate dev_lclose(dev_t dev, int flag, int otype, struct cred *cred) 3277c478bd9Sstevel@tonic-gate { 3287c478bd9Sstevel@tonic-gate struct vnode *vp; 3297c478bd9Sstevel@tonic-gate int error; 3307c478bd9Sstevel@tonic-gate struct vnode *cvp; 3317c478bd9Sstevel@tonic-gate char *funcname; 3327c478bd9Sstevel@tonic-gate ulong_t offset; 3337c478bd9Sstevel@tonic-gate 3347c478bd9Sstevel@tonic-gate vp = makespecvp(dev, (otype == OTYP_BLK) ? VBLK : VCHR); 335*da6c28aaSamw error = VOP_CLOSE(vp, flag | FKLYR, 1, (offset_t)0, cred, NULL); 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate /* 3387c478bd9Sstevel@tonic-gate * Release the extra dev_lopen hold on the common vnode. We inline a 3397c478bd9Sstevel@tonic-gate * VN_RELE(cvp) call so that we can detect more dev_lclose calls than 3407c478bd9Sstevel@tonic-gate * dev_lopen calls without panic. See vn_rele. If our inline of 341*da6c28aaSamw * vn_rele called VOP_INACTIVE(cvp, CRED(), ...) we would panic on the 3427c478bd9Sstevel@tonic-gate * "release the makespecvp vnode" VN_RELE(vp) that follows - so 3437c478bd9Sstevel@tonic-gate * instead we diagnose this situation. Note that the driver has 3447c478bd9Sstevel@tonic-gate * still seen a double close(9E), but that would have occurred with 3457c478bd9Sstevel@tonic-gate * the old dev_close implementation too. 3467c478bd9Sstevel@tonic-gate */ 3477c478bd9Sstevel@tonic-gate cvp = STOV(VTOCS(vp)); 3487c478bd9Sstevel@tonic-gate mutex_enter(&cvp->v_lock); 3497c478bd9Sstevel@tonic-gate switch (cvp->v_count) { 3507c478bd9Sstevel@tonic-gate default: 3517c478bd9Sstevel@tonic-gate cvp->v_count--; 3527c478bd9Sstevel@tonic-gate break; 3537c478bd9Sstevel@tonic-gate 3547c478bd9Sstevel@tonic-gate case 0: 3557c478bd9Sstevel@tonic-gate VTOS(vp)->s_commonvp = NULL; /* avoid panic */ 3567c478bd9Sstevel@tonic-gate /*FALLTHROUGH*/ 3577c478bd9Sstevel@tonic-gate case 1: 3587c478bd9Sstevel@tonic-gate /* 3597c478bd9Sstevel@tonic-gate * The following message indicates a serious problem in the 3607c478bd9Sstevel@tonic-gate * identified driver, the driver should be fixed. If obtaining 3617c478bd9Sstevel@tonic-gate * a panic dump is needed to diagnose the driver problem then 3627c478bd9Sstevel@tonic-gate * adding "set dev_lclose_ce=3" to /etc/system will cause a 3637c478bd9Sstevel@tonic-gate * panic when this occurs. 3647c478bd9Sstevel@tonic-gate */ 3657c478bd9Sstevel@tonic-gate funcname = modgetsymname((uintptr_t)caller(), &offset); 3667c478bd9Sstevel@tonic-gate cmn_err(dev_lclose_ce, "dev_lclose: extra close of dev_t 0x%lx " 3677c478bd9Sstevel@tonic-gate "from %s`%s()", dev, mod_containing_pc(caller()), 3687c478bd9Sstevel@tonic-gate funcname ? funcname : "unknown..."); 3697c478bd9Sstevel@tonic-gate break; 3707c478bd9Sstevel@tonic-gate } 3717c478bd9Sstevel@tonic-gate mutex_exit(&cvp->v_lock); 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate /* release the makespecvp vnode. */ 3747c478bd9Sstevel@tonic-gate VN_RELE(vp); 3757c478bd9Sstevel@tonic-gate return (error); 3767c478bd9Sstevel@tonic-gate } 3777c478bd9Sstevel@tonic-gate 3787c478bd9Sstevel@tonic-gate /* 3797c478bd9Sstevel@tonic-gate * Returns -1 or the instance number of the given dev_t as 3807c478bd9Sstevel@tonic-gate * interpreted by the device driver. The code may load the driver 3817c478bd9Sstevel@tonic-gate * but it does not attach any instances. 3827c478bd9Sstevel@tonic-gate * 3837c478bd9Sstevel@tonic-gate * Instance is supposed to be a int but drivers have assumed that 3847c478bd9Sstevel@tonic-gate * the pointer was a pointer to "void *" instead of a pointer to 3857c478bd9Sstevel@tonic-gate * "int *" so we now explicitly pass a pointer to "void *" and then 3867c478bd9Sstevel@tonic-gate * cast the result to an int when returning the value. 3877c478bd9Sstevel@tonic-gate */ 3887c478bd9Sstevel@tonic-gate int 3897c478bd9Sstevel@tonic-gate dev_to_instance(dev_t dev) 3907c478bd9Sstevel@tonic-gate { 3917c478bd9Sstevel@tonic-gate major_t major = getmajor(dev); 3927c478bd9Sstevel@tonic-gate struct dev_ops *ops; 3937c478bd9Sstevel@tonic-gate void *vinstance; 3947c478bd9Sstevel@tonic-gate int error; 3957c478bd9Sstevel@tonic-gate 3967c478bd9Sstevel@tonic-gate /* verify that the major number is reasonable and driver is loaded */ 3977c478bd9Sstevel@tonic-gate if ((major >= devcnt) || 3987c478bd9Sstevel@tonic-gate ((ops = mod_hold_dev_by_major(major)) == NULL)) 3997c478bd9Sstevel@tonic-gate return (-1); 4007c478bd9Sstevel@tonic-gate ASSERT(CB_DRV_INSTALLED(ops)); 4017c478bd9Sstevel@tonic-gate 4027c478bd9Sstevel@tonic-gate /* verify that it supports the getinfo(9E) entry point */ 4037c478bd9Sstevel@tonic-gate if (ops->devo_getinfo == NULL) { 4047c478bd9Sstevel@tonic-gate mod_rele_dev_by_major(major); 4057c478bd9Sstevel@tonic-gate return (-1); 4067c478bd9Sstevel@tonic-gate } 4077c478bd9Sstevel@tonic-gate 4087c478bd9Sstevel@tonic-gate /* ask the driver to extract the instance number from the devt */ 4097c478bd9Sstevel@tonic-gate error = (*ops->devo_getinfo)(NULL, DDI_INFO_DEVT2INSTANCE, 4107c478bd9Sstevel@tonic-gate (void *)dev, &vinstance); 4117c478bd9Sstevel@tonic-gate 4127c478bd9Sstevel@tonic-gate /* release the driver */ 4137c478bd9Sstevel@tonic-gate mod_rele_dev_by_major(major); 4147c478bd9Sstevel@tonic-gate 4157c478bd9Sstevel@tonic-gate if (error != DDI_SUCCESS) 4167c478bd9Sstevel@tonic-gate return (-1); 4177c478bd9Sstevel@tonic-gate 4187c478bd9Sstevel@tonic-gate return ((int)(uintptr_t)vinstance); 4197c478bd9Sstevel@tonic-gate } 4207c478bd9Sstevel@tonic-gate 4217c478bd9Sstevel@tonic-gate static void 4227c478bd9Sstevel@tonic-gate bdev_strategy_tnf_probe(struct buf *bp) 4237c478bd9Sstevel@tonic-gate { 4247c478bd9Sstevel@tonic-gate /* Kernel probe */ 4257c478bd9Sstevel@tonic-gate TNF_PROBE_5(strategy, "io blockio", /* CSTYLED */, 426184cd04cScth tnf_device, device, bp->b_edev, 427184cd04cScth tnf_diskaddr, block, bp->b_lblkno, 428184cd04cScth tnf_size, size, bp->b_bcount, 429184cd04cScth tnf_opaque, buf, bp, 430184cd04cScth tnf_bioflags, flags, bp->b_flags); 4317c478bd9Sstevel@tonic-gate } 4327c478bd9Sstevel@tonic-gate 4337c478bd9Sstevel@tonic-gate int 4347c478bd9Sstevel@tonic-gate bdev_strategy(struct buf *bp) 4357c478bd9Sstevel@tonic-gate { 4367c478bd9Sstevel@tonic-gate struct dev_ops *ops; 4377c478bd9Sstevel@tonic-gate 4387c478bd9Sstevel@tonic-gate ops = devopsp[getmajor(bp->b_edev)]; 4397c478bd9Sstevel@tonic-gate 4407c478bd9Sstevel@tonic-gate /* 4417c478bd9Sstevel@tonic-gate * Before we hit the io:::start probe, we need to fill in the b_dip 4427c478bd9Sstevel@tonic-gate * field of the buf structure. This should be -- for the most part -- 4437c478bd9Sstevel@tonic-gate * incredibly cheap. If you're in this code looking to bum cycles, 4447c478bd9Sstevel@tonic-gate * there is almost certainly bigger game further down the I/O path... 4457c478bd9Sstevel@tonic-gate */ 4467c478bd9Sstevel@tonic-gate (void) ops->devo_getinfo(NULL, DDI_INFO_DEVT2DEVINFO, 4477c478bd9Sstevel@tonic-gate (void *)bp->b_edev, (void **)&bp->b_dip); 4487c478bd9Sstevel@tonic-gate 4497c478bd9Sstevel@tonic-gate DTRACE_IO1(start, struct buf *, bp); 4507c478bd9Sstevel@tonic-gate bp->b_flags |= B_STARTED; 4517c478bd9Sstevel@tonic-gate 4527c478bd9Sstevel@tonic-gate /* 4537c478bd9Sstevel@tonic-gate * Call the TNF probe here instead of the inline code 4547c478bd9Sstevel@tonic-gate * to force our compiler to use the tail call optimization. 4557c478bd9Sstevel@tonic-gate */ 4567c478bd9Sstevel@tonic-gate bdev_strategy_tnf_probe(bp); 4577c478bd9Sstevel@tonic-gate 4587c478bd9Sstevel@tonic-gate return (ops->devo_cb_ops->cb_strategy(bp)); 4597c478bd9Sstevel@tonic-gate } 4607c478bd9Sstevel@tonic-gate 4617c478bd9Sstevel@tonic-gate int 4627c478bd9Sstevel@tonic-gate bdev_print(dev_t dev, caddr_t str) 4637c478bd9Sstevel@tonic-gate { 4647c478bd9Sstevel@tonic-gate struct cb_ops *cb; 4657c478bd9Sstevel@tonic-gate 4667c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 4677c478bd9Sstevel@tonic-gate return ((*cb->cb_print)(dev, str)); 4687c478bd9Sstevel@tonic-gate } 4697c478bd9Sstevel@tonic-gate 470184cd04cScth /* 471184cd04cScth * Return number of DEV_BSIZE byte blocks. 472184cd04cScth */ 4737c478bd9Sstevel@tonic-gate int 4747c478bd9Sstevel@tonic-gate bdev_size(dev_t dev) 4757c478bd9Sstevel@tonic-gate { 476184cd04cScth uint_t nblocks; 477184cd04cScth uint_t blksize; 478184cd04cScth 479184cd04cScth if ((nblocks = e_ddi_getprop(dev, VBLK, "nblocks", 480184cd04cScth DDI_PROP_NOTPROM | DDI_PROP_DONTPASS, -1)) == -1) 481184cd04cScth return (-1); 482184cd04cScth 483184cd04cScth /* Get blksize, default to DEV_BSIZE */ 484184cd04cScth if ((blksize = e_ddi_getprop(dev, VBLK, "blksize", 485184cd04cScth DDI_PROP_NOTPROM | DDI_PROP_DONTPASS, -1)) == -1) 486184cd04cScth blksize = e_ddi_getprop(DDI_DEV_T_ANY, VBLK, "device-blksize", 487184cd04cScth DDI_PROP_NOTPROM | DDI_PROP_DONTPASS, DEV_BSIZE); 488184cd04cScth 489184cd04cScth if (blksize >= DEV_BSIZE) 490184cd04cScth return (nblocks * (blksize / DEV_BSIZE)); 491184cd04cScth else 492184cd04cScth return (nblocks / (DEV_BSIZE / blksize)); 4937c478bd9Sstevel@tonic-gate } 4947c478bd9Sstevel@tonic-gate 4957c478bd9Sstevel@tonic-gate /* 4967c478bd9Sstevel@tonic-gate * Same for 64-bit Nblocks property 4977c478bd9Sstevel@tonic-gate */ 4987c478bd9Sstevel@tonic-gate uint64_t 4997c478bd9Sstevel@tonic-gate bdev_Size(dev_t dev) 5007c478bd9Sstevel@tonic-gate { 501184cd04cScth uint64_t nblocks; 502184cd04cScth uint_t blksize; 503184cd04cScth 504184cd04cScth if ((nblocks = e_ddi_getprop_int64(dev, VBLK, "Nblocks", 505184cd04cScth DDI_PROP_NOTPROM | DDI_PROP_DONTPASS, -1)) == -1) 506184cd04cScth return (-1); 507184cd04cScth 508184cd04cScth /* Get blksize, default to DEV_BSIZE */ 509184cd04cScth if ((blksize = e_ddi_getprop(dev, VBLK, "blksize", 510184cd04cScth DDI_PROP_NOTPROM | DDI_PROP_DONTPASS, -1)) == -1) 511184cd04cScth blksize = e_ddi_getprop(DDI_DEV_T_ANY, VBLK, "device-blksize", 512184cd04cScth DDI_PROP_NOTPROM | DDI_PROP_DONTPASS, DEV_BSIZE); 513184cd04cScth 514184cd04cScth if (blksize >= DEV_BSIZE) 515184cd04cScth return (nblocks * (blksize / DEV_BSIZE)); 516184cd04cScth else 517184cd04cScth return (nblocks / (DEV_BSIZE / blksize)); 5187c478bd9Sstevel@tonic-gate } 5197c478bd9Sstevel@tonic-gate 5207c478bd9Sstevel@tonic-gate int 5217c478bd9Sstevel@tonic-gate bdev_dump(dev_t dev, caddr_t addr, daddr_t blkno, int blkcnt) 5227c478bd9Sstevel@tonic-gate { 5237c478bd9Sstevel@tonic-gate struct cb_ops *cb; 5247c478bd9Sstevel@tonic-gate 5257c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 5267c478bd9Sstevel@tonic-gate return ((*cb->cb_dump)(dev, addr, blkno, blkcnt)); 5277c478bd9Sstevel@tonic-gate } 5287c478bd9Sstevel@tonic-gate 5297c478bd9Sstevel@tonic-gate int 5307c478bd9Sstevel@tonic-gate cdev_read(dev_t dev, struct uio *uiop, struct cred *cred) 5317c478bd9Sstevel@tonic-gate { 5327c478bd9Sstevel@tonic-gate struct cb_ops *cb; 5337c478bd9Sstevel@tonic-gate 5347c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 5357c478bd9Sstevel@tonic-gate return ((*cb->cb_read)(dev, uiop, cred)); 5367c478bd9Sstevel@tonic-gate } 5377c478bd9Sstevel@tonic-gate 5387c478bd9Sstevel@tonic-gate int 5397c478bd9Sstevel@tonic-gate cdev_write(dev_t dev, struct uio *uiop, struct cred *cred) 5407c478bd9Sstevel@tonic-gate { 5417c478bd9Sstevel@tonic-gate struct cb_ops *cb; 5427c478bd9Sstevel@tonic-gate 5437c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 5447c478bd9Sstevel@tonic-gate return ((*cb->cb_write)(dev, uiop, cred)); 5457c478bd9Sstevel@tonic-gate } 5467c478bd9Sstevel@tonic-gate 5477c478bd9Sstevel@tonic-gate int 5487c478bd9Sstevel@tonic-gate cdev_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, struct cred *cred, 5497c478bd9Sstevel@tonic-gate int *rvalp) 5507c478bd9Sstevel@tonic-gate { 5517c478bd9Sstevel@tonic-gate struct cb_ops *cb; 5527c478bd9Sstevel@tonic-gate 5537c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 5547c478bd9Sstevel@tonic-gate return ((*cb->cb_ioctl)(dev, cmd, arg, mode, cred, rvalp)); 5557c478bd9Sstevel@tonic-gate } 5567c478bd9Sstevel@tonic-gate 5577c478bd9Sstevel@tonic-gate int 5587c478bd9Sstevel@tonic-gate cdev_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, size_t len, 5597c478bd9Sstevel@tonic-gate size_t *maplen, uint_t mode) 5607c478bd9Sstevel@tonic-gate { 5617c478bd9Sstevel@tonic-gate struct cb_ops *cb; 5627c478bd9Sstevel@tonic-gate 5637c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 5647c478bd9Sstevel@tonic-gate return ((*cb->cb_devmap)(dev, dhp, off, len, maplen, mode)); 5657c478bd9Sstevel@tonic-gate } 5667c478bd9Sstevel@tonic-gate 5677c478bd9Sstevel@tonic-gate int 5687c478bd9Sstevel@tonic-gate cdev_mmap(int (*mapfunc)(dev_t, off_t, int), dev_t dev, off_t off, int prot) 5697c478bd9Sstevel@tonic-gate { 5707c478bd9Sstevel@tonic-gate return ((*mapfunc)(dev, off, prot)); 5717c478bd9Sstevel@tonic-gate } 5727c478bd9Sstevel@tonic-gate 5737c478bd9Sstevel@tonic-gate int 5747c478bd9Sstevel@tonic-gate cdev_segmap(dev_t dev, off_t off, struct as *as, caddr_t *addrp, off_t len, 5757c478bd9Sstevel@tonic-gate uint_t prot, uint_t maxprot, uint_t flags, cred_t *credp) 5767c478bd9Sstevel@tonic-gate { 5777c478bd9Sstevel@tonic-gate struct cb_ops *cb; 5787c478bd9Sstevel@tonic-gate 5797c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 5807c478bd9Sstevel@tonic-gate return ((*cb->cb_segmap)(dev, off, as, addrp, 5817c478bd9Sstevel@tonic-gate len, prot, maxprot, flags, credp)); 5827c478bd9Sstevel@tonic-gate } 5837c478bd9Sstevel@tonic-gate 5847c478bd9Sstevel@tonic-gate int 5857c478bd9Sstevel@tonic-gate cdev_poll(dev_t dev, short events, int anyyet, short *reventsp, 5867c478bd9Sstevel@tonic-gate struct pollhead **pollhdrp) 5877c478bd9Sstevel@tonic-gate { 5887c478bd9Sstevel@tonic-gate struct cb_ops *cb; 5897c478bd9Sstevel@tonic-gate 5907c478bd9Sstevel@tonic-gate cb = devopsp[getmajor(dev)]->devo_cb_ops; 5917c478bd9Sstevel@tonic-gate return ((*cb->cb_chpoll)(dev, events, anyyet, reventsp, pollhdrp)); 5927c478bd9Sstevel@tonic-gate } 5937c478bd9Sstevel@tonic-gate 5947c478bd9Sstevel@tonic-gate /* 5957c478bd9Sstevel@tonic-gate * A 'size' property can be provided by a VCHR device. 5967c478bd9Sstevel@tonic-gate * 5977c478bd9Sstevel@tonic-gate * Since it's defined as zero for STREAMS devices, so we avoid the 5987c478bd9Sstevel@tonic-gate * overhead of looking it up. Note also that we don't force an 5997c478bd9Sstevel@tonic-gate * unused driver into memory simply to ask about it's size. We also 6007c478bd9Sstevel@tonic-gate * don't bother to ask it its size unless it's already been attached 6017c478bd9Sstevel@tonic-gate * (the attach routine is the earliest place the property will be created) 6027c478bd9Sstevel@tonic-gate * 6037c478bd9Sstevel@tonic-gate * XXX In an ideal world, we'd call this at VOP_GETATTR() time. 6047c478bd9Sstevel@tonic-gate */ 6057c478bd9Sstevel@tonic-gate int 6067c478bd9Sstevel@tonic-gate cdev_size(dev_t dev) 6077c478bd9Sstevel@tonic-gate { 6087c478bd9Sstevel@tonic-gate major_t maj; 6097c478bd9Sstevel@tonic-gate struct devnames *dnp; 6107c478bd9Sstevel@tonic-gate 6117c478bd9Sstevel@tonic-gate if ((maj = getmajor(dev)) >= devcnt) 6127c478bd9Sstevel@tonic-gate return (0); 6137c478bd9Sstevel@tonic-gate 6147c478bd9Sstevel@tonic-gate dnp = &(devnamesp[maj]); 6157c478bd9Sstevel@tonic-gate LOCK_DEV_OPS(&dnp->dn_lock); 6167c478bd9Sstevel@tonic-gate if (devopsp[maj] && devopsp[maj]->devo_cb_ops && 6177c478bd9Sstevel@tonic-gate !devopsp[maj]->devo_cb_ops->cb_str) { 6187c478bd9Sstevel@tonic-gate UNLOCK_DEV_OPS(&dnp->dn_lock); 6197c478bd9Sstevel@tonic-gate return (e_ddi_getprop(dev, VCHR, "size", 6207c478bd9Sstevel@tonic-gate DDI_PROP_NOTPROM | DDI_PROP_DONTPASS, 0)); 6217c478bd9Sstevel@tonic-gate } 6227c478bd9Sstevel@tonic-gate UNLOCK_DEV_OPS(&dnp->dn_lock); 6237c478bd9Sstevel@tonic-gate return (0); 6247c478bd9Sstevel@tonic-gate } 6257c478bd9Sstevel@tonic-gate 6267c478bd9Sstevel@tonic-gate /* 6277c478bd9Sstevel@tonic-gate * same for 64-bit Size property 6287c478bd9Sstevel@tonic-gate */ 6297c478bd9Sstevel@tonic-gate uint64_t 6307c478bd9Sstevel@tonic-gate cdev_Size(dev_t dev) 6317c478bd9Sstevel@tonic-gate { 6327c478bd9Sstevel@tonic-gate major_t maj; 6337c478bd9Sstevel@tonic-gate struct devnames *dnp; 6347c478bd9Sstevel@tonic-gate 6357c478bd9Sstevel@tonic-gate if ((maj = getmajor(dev)) >= devcnt) 6367c478bd9Sstevel@tonic-gate return (0); 6377c478bd9Sstevel@tonic-gate 6387c478bd9Sstevel@tonic-gate dnp = &(devnamesp[maj]); 6397c478bd9Sstevel@tonic-gate LOCK_DEV_OPS(&dnp->dn_lock); 6407c478bd9Sstevel@tonic-gate if (devopsp[maj] && devopsp[maj]->devo_cb_ops && 6417c478bd9Sstevel@tonic-gate !devopsp[maj]->devo_cb_ops->cb_str) { 6427c478bd9Sstevel@tonic-gate UNLOCK_DEV_OPS(&dnp->dn_lock); 6437c478bd9Sstevel@tonic-gate return (e_ddi_getprop_int64(dev, VCHR, "Size", 6447c478bd9Sstevel@tonic-gate DDI_PROP_NOTPROM | DDI_PROP_DONTPASS, 0)); 6457c478bd9Sstevel@tonic-gate } 6467c478bd9Sstevel@tonic-gate UNLOCK_DEV_OPS(&dnp->dn_lock); 6477c478bd9Sstevel@tonic-gate return (0); 6487c478bd9Sstevel@tonic-gate } 6497c478bd9Sstevel@tonic-gate 6507c478bd9Sstevel@tonic-gate /* 6517c478bd9Sstevel@tonic-gate * XXX This routine is poorly named, because block devices can and do 6527c478bd9Sstevel@tonic-gate * have properties (see bdev_size() above). 6537c478bd9Sstevel@tonic-gate * 6547c478bd9Sstevel@tonic-gate * XXX fix the comment in devops.h that claims that cb_prop_op 6557c478bd9Sstevel@tonic-gate * is character-only. 6567c478bd9Sstevel@tonic-gate */ 6577c478bd9Sstevel@tonic-gate int 6587c478bd9Sstevel@tonic-gate cdev_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags, 6597c478bd9Sstevel@tonic-gate char *name, caddr_t valuep, int *lengthp) 6607c478bd9Sstevel@tonic-gate { 6617c478bd9Sstevel@tonic-gate struct cb_ops *cb; 6627c478bd9Sstevel@tonic-gate 6637c478bd9Sstevel@tonic-gate if ((cb = devopsp[DEVI(dip)->devi_major]->devo_cb_ops) == NULL) 6647c478bd9Sstevel@tonic-gate return (DDI_PROP_NOT_FOUND); 6657c478bd9Sstevel@tonic-gate 6667c478bd9Sstevel@tonic-gate return ((*cb->cb_prop_op)(dev, dip, prop_op, mod_flags, 6677c478bd9Sstevel@tonic-gate name, valuep, lengthp)); 6687c478bd9Sstevel@tonic-gate } 669