.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright 2014 IBM Corp. |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or |
---|
5 | | - * modify it under the terms of the GNU General Public License |
---|
6 | | - * as published by the Free Software Foundation; either version |
---|
7 | | - * 2 of the License, or (at your option) any later version. |
---|
8 | 4 | */ |
---|
9 | 5 | |
---|
10 | 6 | #include <linux/pci_regs.h> |
---|
.. | .. |
---|
391 | 387 | rc = get_phb_index(np, phb_index); |
---|
392 | 388 | if (rc) { |
---|
393 | 389 | pr_err("cxl: invalid phb index\n"); |
---|
| 390 | + of_node_put(np); |
---|
394 | 391 | return rc; |
---|
395 | 392 | } |
---|
396 | 393 | |
---|
.. | .. |
---|
1168 | 1165 | * if it returns an error! |
---|
1169 | 1166 | */ |
---|
1170 | 1167 | if ((rc = cxl_register_afu(afu))) |
---|
1171 | | - goto err_put1; |
---|
| 1168 | + goto err_put_dev; |
---|
1172 | 1169 | |
---|
1173 | 1170 | if ((rc = cxl_sysfs_afu_add(afu))) |
---|
1174 | | - goto err_put1; |
---|
| 1171 | + goto err_del_dev; |
---|
1175 | 1172 | |
---|
1176 | 1173 | adapter->afu[afu->slice] = afu; |
---|
1177 | 1174 | |
---|
.. | .. |
---|
1180 | 1177 | |
---|
1181 | 1178 | return 0; |
---|
1182 | 1179 | |
---|
1183 | | -err_put1: |
---|
| 1180 | +err_del_dev: |
---|
| 1181 | + device_del(&afu->dev); |
---|
| 1182 | +err_put_dev: |
---|
1184 | 1183 | pci_deconfigure_afu(afu); |
---|
1185 | 1184 | cxl_debugfs_afu_remove(afu); |
---|
1186 | | - device_unregister(&afu->dev); |
---|
| 1185 | + put_device(&afu->dev); |
---|
1187 | 1186 | return rc; |
---|
1188 | 1187 | |
---|
1189 | 1188 | err_free_native: |
---|
.. | .. |
---|
1671 | 1670 | * even if it returns an error! |
---|
1672 | 1671 | */ |
---|
1673 | 1672 | if ((rc = cxl_register_adapter(adapter))) |
---|
1674 | | - goto err_put1; |
---|
| 1673 | + goto err_put_dev; |
---|
1675 | 1674 | |
---|
1676 | 1675 | if ((rc = cxl_sysfs_adapter_add(adapter))) |
---|
1677 | | - goto err_put1; |
---|
| 1676 | + goto err_del_dev; |
---|
1678 | 1677 | |
---|
1679 | 1678 | /* Release the context lock as adapter is configured */ |
---|
1680 | 1679 | cxl_adapter_context_unlock(adapter); |
---|
1681 | 1680 | |
---|
1682 | 1681 | return adapter; |
---|
1683 | 1682 | |
---|
1684 | | -err_put1: |
---|
| 1683 | +err_del_dev: |
---|
| 1684 | + device_del(&adapter->dev); |
---|
| 1685 | +err_put_dev: |
---|
1685 | 1686 | /* This should mirror cxl_remove_adapter, except without the |
---|
1686 | 1687 | * sysfs parts |
---|
1687 | 1688 | */ |
---|
1688 | 1689 | cxl_debugfs_adapter_remove(adapter); |
---|
1689 | 1690 | cxl_deconfigure_adapter(adapter); |
---|
1690 | | - device_unregister(&adapter->dev); |
---|
| 1691 | + put_device(&adapter->dev); |
---|
1691 | 1692 | return ERR_PTR(rc); |
---|
1692 | 1693 | |
---|
1693 | 1694 | err_release: |
---|
.. | .. |
---|
1718 | 1719 | { |
---|
1719 | 1720 | struct device_node *np; |
---|
1720 | 1721 | int depth = 0; |
---|
1721 | | - const __be32 *prop; |
---|
1722 | 1722 | |
---|
1723 | 1723 | if (!(np = pci_device_to_OF_node(dev))) { |
---|
1724 | 1724 | pr_err("cxl: np = NULL\n"); |
---|
.. | .. |
---|
1727 | 1727 | of_node_get(np); |
---|
1728 | 1728 | while (np) { |
---|
1729 | 1729 | np = of_get_next_parent(np); |
---|
1730 | | - prop = of_get_property(np, "device_type", NULL); |
---|
1731 | | - if (!prop || strcmp((char *)prop, "pciex")) |
---|
| 1730 | + if (!of_node_is_type(np, "pciex")) |
---|
1732 | 1731 | break; |
---|
1733 | 1732 | depth++; |
---|
1734 | 1733 | } |
---|