6411129 ssc050_get_port_bit does not handle all return values of ddi_get_soft_state
--- a/usr/src/uts/sun4u/cherrystone/os/cherrystone.c Wed Jan 10 13:46:29 2007 -0800
+++ b/usr/src/uts/sun4u/cherrystone/os/cherrystone.c Wed Jan 10 14:41:22 2007 -0800
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -165,6 +165,11 @@
e_ddi_walk_driver("i2c-ssc050", cherry_dev_search, (void *)&keysw_dip);
ASSERT(keysw_dip != NULL);
+ /*
+ * prevent detach of i2c-ssc050
+ */
+ e_ddi_hold_devi(keysw_dip);
+
keypoll_timeout_hz = drv_usectohz(10 * MICROSEC);
keyswitch_poll(keysw_dip);
abort_seq_handler = cherry_abort_seq_handler;
@@ -225,6 +230,8 @@
err = cherry_ssc050_get_port_bit(dip, port, bit,
&port_byte, I2C_NOSLEEP);
if (err != 0) {
+ cmn_err(CE_WARN, "keyswitch polling disabled: "
+ "errno=%d while reading ssc050", err);
return;
}
--- a/usr/src/uts/sun4u/daktari/os/daktari.c Wed Jan 10 13:46:29 2007 -0800
+++ b/usr/src/uts/sun4u/daktari/os/daktari.c Wed Jan 10 14:41:22 2007 -0800
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -30,6 +30,7 @@
#include <sys/systm.h>
#include <sys/sunddi.h>
#include <sys/ddi.h>
+#include <sys/esunddi.h>
#include <sys/sysmacros.h>
#include <sys/note.h>
@@ -161,6 +162,11 @@
ddi_walk_devs(ddi_root_node(), daktari_dev_search, (void *)&keysw_dip);
ASSERT(keysw_dip != NULL);
+ /*
+ * prevent detach of i2c-ssc050
+ */
+ e_ddi_hold_devi(keysw_dip);
+
keypoll_timeout_hz = drv_usectohz(10 * MICROSEC);
keyswitch_poll(keysw_dip);
abort_seq_handler = daktari_abort_seq_handler;
@@ -216,6 +222,8 @@
err = daktari_ssc050_get_port_bit(dip, port, bit,
&port_byte, I2C_NOSLEEP);
if (err != 0) {
+ cmn_err(CE_WARN, "keyswitch polling disabled: "
+ "errno=%d while reading ssc050", err);
return;
}
--- a/usr/src/uts/sun4u/io/i2c/clients/ssc050.c Wed Jan 10 13:46:29 2007 -0800
+++ b/usr/src/uts/sun4u/io/i2c/clients/ssc050.c Wed Jan 10 14:41:22 2007 -0800
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -696,5 +695,8 @@
instance = ddi_get_instance(dip);
unitp = ddi_get_soft_state(ssc050soft_statep, instance);
+ if (unitp == NULL) {
+ return (ENXIO);
+ }
return (ssc050_get(unitp, reg, rval, flags));
}