comparison usr/src/uts/common/io/usb/usba/genconsole.c @ 3943:302736821720

6415231 Galaxy 1 system panics w/BAD TRAP (page fault) in "ohci" due to NULL pointer
author sl147100
date Sun, 01 Apr 2007 22:45:05 -0700
parents 053dcaf72871
children e4dbffd35ebc
comparison
equal deleted inserted replaced
3942:c202da1d3c1c 3943:302736821720
17 * information: Portions Copyright [yyyy] [name of copyright owner] 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 * 18 *
19 * CDDL HEADER END 19 * CDDL HEADER END
20 */ 20 */
21 /* 21 /*
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms. 23 * Use is subject to license terms.
24 */ 24 */
25 #pragma ident "%Z%%M% %I% %E% SMI" 25 #pragma ident "%Z%%M% %I% %E% SMI"
26 26
27 /* 27 /*
46 uchar_t **state_buf, 46 uchar_t **state_buf,
47 usb_console_info_t *console_input_info) 47 usb_console_info_t *console_input_info)
48 { 48 {
49 int ret; 49 int ret;
50 usba_device_t *usba_device; 50 usba_device_t *usba_device;
51 usb_console_info_impl_t *usb_console_input = kmem_zalloc( 51 usba_pipe_handle_data_t *ph_data;
52 sizeof (struct usb_console_info_impl), KM_SLEEP); 52 usb_console_info_impl_t *usb_console_input;
53
54 if (dip == NULL) {
55
56 return (USB_INVALID_ARGS);
57 }
58
59 if (DEVI_IS_DEVICE_REMOVED(dip)) {
60
61 return (USB_FAILURE);
62 }
63
64 usb_console_input = kmem_zalloc(
65 sizeof (struct usb_console_info_impl), KM_SLEEP);
53 66
54 /* 67 /*
55 * Save the dip 68 * Save the dip
56 */ 69 */
57 usb_console_input->uci_dip = dip; 70 usb_console_input->uci_dip = dip;
60 * Translate the dip into a device. 73 * Translate the dip into a device.
61 */ 74 */
62 usba_device = usba_get_usba_device(dip); 75 usba_device = usba_get_usba_device(dip);
63 76
64 /* 77 /*
78 * Get ph_data from pipe handle and hold the data
79 */
80 if ((ph_data = usba_hold_ph_data(pipe_handle)) == NULL) {
81 kmem_free(usb_console_input,
82 sizeof (struct usb_console_info_impl));
83
84 return (USB_INVALID_PIPE);
85 }
86
87 /*
65 * Call the lower layer to initialize any state information 88 * Call the lower layer to initialize any state information
66 */ 89 */
67 ret = usba_device->usb_hcdi_ops->usba_hcdi_console_input_init( 90 ret = usba_device->usb_hcdi_ops->usba_hcdi_console_input_init(
68 usba_get_ph_data(pipe_handle), state_buf, usb_console_input); 91 ph_data, state_buf, usb_console_input);
69 92
70 if (ret != USB_SUCCESS) { 93 if (ret != USB_SUCCESS) {
71 kmem_free(usb_console_input, 94 kmem_free(usb_console_input,
72 sizeof (struct usb_console_info_impl)); 95 sizeof (struct usb_console_info_impl));
73 } else { 96 } else {
74 *console_input_info = (usb_console_info_t)usb_console_input; 97 *console_input_info = (usb_console_info_t)usb_console_input;
75 } 98 }
99
100 usba_release_ph_data((usba_ph_impl_t *)pipe_handle);
76 101
77 return (ret); 102 return (ret);
78 } 103 }
79 104
80 105