px_devctl.c (36fe4a92) | px_devctl.c (b65731f1) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 6 unchanged lines hidden (view full) --- 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 6 unchanged lines hidden (view full) --- 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* |
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. | 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
24 * Use is subject to license terms. 25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29/* 30 * PCI nexus HotPlug devctl interface 31 */ --- 45 unchanged lines hidden (view full) --- 77 nodev /* int (*cb_awrite)() */ 78}; 79 80/* ARGSUSED3 */ 81static int 82px_open(dev_t *devp, int flags, int otyp, cred_t *credp) 83{ 84 px_t *px_p; | 24 * Use is subject to license terms. 25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29/* 30 * PCI nexus HotPlug devctl interface 31 */ --- 45 unchanged lines hidden (view full) --- 77 nodev /* int (*cb_awrite)() */ 78}; 79 80/* ARGSUSED3 */ 81static int 82px_open(dev_t *devp, int flags, int otyp, cred_t *credp) 83{ 84 px_t *px_p; |
85 int rval; 86 uint_t orig_px_soft_state; |
|
85 86 /* 87 * Make sure the open is for the right file type. 88 */ 89 if (otyp != OTYP_CHR) 90 return (EINVAL); 91 92 /* 93 * Get the soft state structure for the device. 94 */ 95 px_p = PX_DEV_TO_SOFTSTATE(*devp); 96 if (px_p == NULL) 97 return (ENXIO); 98 99 /* 100 * Handle the open by tracking the device state. 101 */ 102 DBG(DBG_OPEN, px_p->px_dip, "devp=%x: flags=%x\n", devp, flags); 103 mutex_enter(&px_p->px_mutex); | 87 88 /* 89 * Make sure the open is for the right file type. 90 */ 91 if (otyp != OTYP_CHR) 92 return (EINVAL); 93 94 /* 95 * Get the soft state structure for the device. 96 */ 97 px_p = PX_DEV_TO_SOFTSTATE(*devp); 98 if (px_p == NULL) 99 return (ENXIO); 100 101 /* 102 * Handle the open by tracking the device state. 103 */ 104 DBG(DBG_OPEN, px_p->px_dip, "devp=%x: flags=%x\n", devp, flags); 105 mutex_enter(&px_p->px_mutex); |
106 orig_px_soft_state = px_p->px_soft_state; |
|
104 if (flags & FEXCL) { 105 if (px_p->px_soft_state != PX_SOFT_STATE_CLOSED) { 106 mutex_exit(&px_p->px_mutex); 107 DBG(DBG_OPEN, px_p->px_dip, "busy\n"); 108 return (EBUSY); 109 } 110 px_p->px_soft_state = PX_SOFT_STATE_OPEN_EXCL; 111 } else { 112 if (px_p->px_soft_state == PX_SOFT_STATE_OPEN_EXCL) { 113 mutex_exit(&px_p->px_mutex); 114 DBG(DBG_OPEN, px_p->px_dip, "busy\n"); 115 return (EBUSY); 116 } 117 px_p->px_soft_state = PX_SOFT_STATE_OPEN; 118 } | 107 if (flags & FEXCL) { 108 if (px_p->px_soft_state != PX_SOFT_STATE_CLOSED) { 109 mutex_exit(&px_p->px_mutex); 110 DBG(DBG_OPEN, px_p->px_dip, "busy\n"); 111 return (EBUSY); 112 } 113 px_p->px_soft_state = PX_SOFT_STATE_OPEN_EXCL; 114 } else { 115 if (px_p->px_soft_state == PX_SOFT_STATE_OPEN_EXCL) { 116 mutex_exit(&px_p->px_mutex); 117 DBG(DBG_OPEN, px_p->px_dip, "busy\n"); 118 return (EBUSY); 119 } 120 px_p->px_soft_state = PX_SOFT_STATE_OPEN; 121 } |
122 123 if (px_p->px_dev_caps & PX_HOTPLUG_CAPABLE) 124 if (rval = (pcihp_get_cb_ops())->cb_open(devp, flags, 125 otyp, credp)) { 126 px_p->px_soft_state = orig_px_soft_state; 127 mutex_exit(&px_p->px_mutex); 128 return (rval); 129 } 130 |
|
119 px_p->px_open_count++; 120 mutex_exit(&px_p->px_mutex); 121 return (0); 122} 123 124 125/* ARGSUSED */ 126static int 127px_close(dev_t dev, int flags, int otyp, cred_t *credp) 128{ 129 px_t *px_p; | 131 px_p->px_open_count++; 132 mutex_exit(&px_p->px_mutex); 133 return (0); 134} 135 136 137/* ARGSUSED */ 138static int 139px_close(dev_t dev, int flags, int otyp, cred_t *credp) 140{ 141 px_t *px_p; |
142 int rval; |
|
130 131 if (otyp != OTYP_CHR) 132 return (EINVAL); 133 134 px_p = PX_DEV_TO_SOFTSTATE(dev); 135 if (px_p == NULL) 136 return (ENXIO); 137 138 DBG(DBG_CLOSE, px_p->px_dip, "dev=%x: flags=%x\n", dev, flags); 139 mutex_enter(&px_p->px_mutex); | 143 144 if (otyp != OTYP_CHR) 145 return (EINVAL); 146 147 px_p = PX_DEV_TO_SOFTSTATE(dev); 148 if (px_p == NULL) 149 return (ENXIO); 150 151 DBG(DBG_CLOSE, px_p->px_dip, "dev=%x: flags=%x\n", dev, flags); 152 mutex_enter(&px_p->px_mutex); |
153 154 if (px_p->px_dev_caps & PX_HOTPLUG_CAPABLE) 155 if (rval = (pcihp_get_cb_ops())->cb_close(dev, flags, 156 otyp, credp)) { 157 mutex_exit(&px_p->px_mutex); 158 return (rval); 159 } 160 |
|
140 px_p->px_soft_state = PX_SOFT_STATE_CLOSED; 141 px_p->px_open_count = 0; 142 mutex_exit(&px_p->px_mutex); 143 return (0); 144} 145 146/* ARGSUSED */ 147static int --- 77 unchanged lines hidden (view full) --- 225 break; 226 227 default: 228 rv = ENOTTY; 229 } 230 return (rv); 231 232 default: | 161 px_p->px_soft_state = PX_SOFT_STATE_CLOSED; 162 px_p->px_open_count = 0; 163 mutex_exit(&px_p->px_mutex); 164 return (0); 165} 166 167/* ARGSUSED */ 168static int --- 77 unchanged lines hidden (view full) --- 246 break; 247 248 default: 249 rv = ENOTTY; 250 } 251 return (rv); 252 253 default: |
254 if (px_p->px_dev_caps & PX_HOTPLUG_CAPABLE) 255 return ((pcihp_get_cb_ops())->cb_ioctl(dev, cmd, 256 arg, mode, credp, rvalp)); |
|
233 break; 234 } 235 236 if ((cmd & ~PPMREQ_MASK) == PPMREQ) { 237 238 /* Need privileges to use these ioctls. */ 239 if (drv_priv(credp)) { 240 DBG(DBG_TOOLS, dip, --- 76 unchanged lines hidden --- | 257 break; 258 } 259 260 if ((cmd & ~PPMREQ_MASK) == PPMREQ) { 261 262 /* Need privileges to use these ioctls. */ 263 if (drv_priv(credp)) { 264 DBG(DBG_TOOLS, dip, --- 76 unchanged lines hidden --- |