6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2012 Gary Mills
24 *
25 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
26 */
27 /*
28 * Copyright (c) 2009, Pyun YongHyeon <yongari@FreeBSD.org>
29 * All rights reserved.
30 *
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
33 * are met:
34 * 1. Redistributions of source code must retain the above copyright
35 * notice unmodified, this list of conditions, and the following
36 * disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 *
41 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1335 mii_start(atgep->atge_mii);
1336
1337 return (DDI_SUCCESS);
1338
1339 fail5:
1340 (void) mac_unregister(atgep->atge_mh);
1341 atge_device_stop(atgep);
1342 mii_stop(atgep->atge_mii);
1343 mii_free(atgep->atge_mii);
1344 fail4:
1345 atge_free_dma(atgep);
1346 mutex_destroy(&atgep->atge_intr_lock);
1347 mutex_destroy(&atgep->atge_tx_lock);
1348 mutex_destroy(&atgep->atge_rx_lock);
1349 atge_remove_intr(atgep);
1350 fail3:
1351 ddi_regs_map_free(&atgep->atge_io_handle);
1352 fail2:
1353 pci_config_teardown(&atgep->atge_conf_handle);
1354 fail1:
1355 if (atgep)
1356 kmem_free(atgep, sizeof (atge_t));
1357
1358 return (DDI_FAILURE);
1359 }
1360
1361 static int
1362 atge_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
1363 {
1364 atge_t *atgep;
1365
1366 atgep = ddi_get_driver_private(dip);
1367 if (atgep == NULL) {
1368 atge_error(dip, "No soft state in detach");
1369 return (DDI_FAILURE);
1370 }
1371
1372 switch (cmd) {
1373 case DDI_DETACH:
1374
1375 /*
1376 * First unregister with MAC layer before stopping DMA
1377 */
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2012 Gary Mills
24 *
25 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
26 *
27 * Copyright (c) 2018, Joyent, Inc.
28 */
29 /*
30 * Copyright (c) 2009, Pyun YongHyeon <yongari@FreeBSD.org>
31 * All rights reserved.
32 *
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
35 * are met:
36 * 1. Redistributions of source code must retain the above copyright
37 * notice unmodified, this list of conditions, and the following
38 * disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
42 *
43 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1337 mii_start(atgep->atge_mii);
1338
1339 return (DDI_SUCCESS);
1340
1341 fail5:
1342 (void) mac_unregister(atgep->atge_mh);
1343 atge_device_stop(atgep);
1344 mii_stop(atgep->atge_mii);
1345 mii_free(atgep->atge_mii);
1346 fail4:
1347 atge_free_dma(atgep);
1348 mutex_destroy(&atgep->atge_intr_lock);
1349 mutex_destroy(&atgep->atge_tx_lock);
1350 mutex_destroy(&atgep->atge_rx_lock);
1351 atge_remove_intr(atgep);
1352 fail3:
1353 ddi_regs_map_free(&atgep->atge_io_handle);
1354 fail2:
1355 pci_config_teardown(&atgep->atge_conf_handle);
1356 fail1:
1357 kmem_free(atgep, sizeof (atge_t));
1358 return (DDI_FAILURE);
1359 }
1360
1361 static int
1362 atge_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
1363 {
1364 atge_t *atgep;
1365
1366 atgep = ddi_get_driver_private(dip);
1367 if (atgep == NULL) {
1368 atge_error(dip, "No soft state in detach");
1369 return (DDI_FAILURE);
1370 }
1371
1372 switch (cmd) {
1373 case DDI_DETACH:
1374
1375 /*
1376 * First unregister with MAC layer before stopping DMA
1377 */
|