6955758 cfgadm -c connect returns "invalid transition" when device is already connected
authorScott M. Carter <Scott.Carter@Oracle.COM>
Fri, 04 Jun 2010 12:01:07 -0700
changeset 12555 60887a11148c
parent 12554 d94f78979a75
child 12556 b7f7250e66fe
6955758 cfgadm -c connect returns "invalid transition" when device is already connected
usr/src/lib/cfgadm_plugins/shp/common/shp.c
--- a/usr/src/lib/cfgadm_plugins/shp/common/shp.c	Fri Jun 04 07:13:28 2010 -0700
+++ b/usr/src/lib/cfgadm_plugins/shp/common/shp.c	Fri Jun 04 12:01:07 2010 -0700
@@ -20,8 +20,7 @@
  */
 
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -653,27 +652,26 @@
 	DBG(1, ("cfga_change_state: state is %d\n", state));
 	switch (state_change_cmd) {
 	case CFGA_CMD_CONNECT:
-		if ((state == DDI_HP_CN_STATE_EMPTY) ||
-		    (state >= DDI_HP_CN_STATE_POWERED)) {
+		DBG(1, ("connect\n"));
+		if (state == DDI_HP_CN_STATE_EMPTY) {
 			cfga_err(errstring, ERR_AP_ERR, 0);
 			rv = CFGA_INVAL;
-		} else {
-			/* Lets connect the slot */
+		} else if (state == DDI_HP_CN_STATE_PRESENT) {
+			/* Connect the slot */
 			if (hp_set_state(node, 0, new_state, &results) != 0) {
 				rv = CFGA_ERROR;
 				cfga_err(errstring, CMD_SLOT_CONNECT, 0);
 			}
 		}
-
 		break;
 
 	case CFGA_CMD_DISCONNECT:
 		DBG(1, ("disconnect\n"));
-
-		if (state < DDI_HP_CN_STATE_POWERED) {
+		if (state == DDI_HP_CN_STATE_EMPTY) {
 			cfga_err(errstring, ERR_AP_ERR, 0);
 			rv = CFGA_INVAL;
-		} else {
+		} else if (state > DDI_HP_CN_STATE_PRESENT) {
+			/* Disconnect the slot */
 			if ((rv = hp_set_state(node, 0, new_state, &results))
 			    != 0) {
 				if (rv == EBUSY)
@@ -690,7 +688,6 @@
 				}
 			}
 		}
-
 		break;
 
 	case CFGA_CMD_CONFIGURE:
@@ -699,17 +696,22 @@
 		 * configure on the same slot because one
 		 * func can be configured and other one won't
 		 */
-		if (hp_set_state(node, 0, new_state, &results) != 0) {
+		DBG(1, ("configure\n"));
+		if (state == DDI_HP_CN_STATE_EMPTY) {
+			cfga_err(errstring, ERR_AP_ERR, 0);
+			rv = CFGA_INVAL;
+		} else if (hp_set_state(node, 0, new_state, &results) != 0) {
 			rv = CFGA_ERROR;
 			cfga_err(errstring, CMD_SLOT_CONFIGURE, 0);
 		}
-
 		break;
 
 	case CFGA_CMD_UNCONFIGURE:
 		DBG(1, ("unconfigure\n"));
-
-		if (state >= DDI_HP_CN_STATE_ENABLED) {
+		if (state == DDI_HP_CN_STATE_EMPTY) {
+			cfga_err(errstring, ERR_AP_ERR, 0);
+			rv = CFGA_INVAL;
+		} else if (state >= DDI_HP_CN_STATE_ENABLED) {
 			if ((rv = hp_set_state(node, 0, new_state, &results))
 			    != 0) {
 				if (rv == EBUSY)
@@ -725,11 +727,7 @@
 					    CMD_SLOT_UNCONFIGURE, 0);
 				}
 			}
-		} else {
-			cfga_err(errstring, ERR_AP_ERR, 0);
-			rv = CFGA_INVAL;
 		}
-
 		DBG(1, ("unconfigure rv:(%i)\n", rv));
 		break;