hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/misc/cxl/pci.c
....@@ -1,10 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * 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.
84 */
95
106 #include <linux/pci_regs.h>
....@@ -391,6 +387,7 @@
391387 rc = get_phb_index(np, phb_index);
392388 if (rc) {
393389 pr_err("cxl: invalid phb index\n");
390
+ of_node_put(np);
394391 return rc;
395392 }
396393
....@@ -1168,10 +1165,10 @@
11681165 * if it returns an error!
11691166 */
11701167 if ((rc = cxl_register_afu(afu)))
1171
- goto err_put1;
1168
+ goto err_put_dev;
11721169
11731170 if ((rc = cxl_sysfs_afu_add(afu)))
1174
- goto err_put1;
1171
+ goto err_del_dev;
11751172
11761173 adapter->afu[afu->slice] = afu;
11771174
....@@ -1180,10 +1177,12 @@
11801177
11811178 return 0;
11821179
1183
-err_put1:
1180
+err_del_dev:
1181
+ device_del(&afu->dev);
1182
+err_put_dev:
11841183 pci_deconfigure_afu(afu);
11851184 cxl_debugfs_afu_remove(afu);
1186
- device_unregister(&afu->dev);
1185
+ put_device(&afu->dev);
11871186 return rc;
11881187
11891188 err_free_native:
....@@ -1671,23 +1670,25 @@
16711670 * even if it returns an error!
16721671 */
16731672 if ((rc = cxl_register_adapter(adapter)))
1674
- goto err_put1;
1673
+ goto err_put_dev;
16751674
16761675 if ((rc = cxl_sysfs_adapter_add(adapter)))
1677
- goto err_put1;
1676
+ goto err_del_dev;
16781677
16791678 /* Release the context lock as adapter is configured */
16801679 cxl_adapter_context_unlock(adapter);
16811680
16821681 return adapter;
16831682
1684
-err_put1:
1683
+err_del_dev:
1684
+ device_del(&adapter->dev);
1685
+err_put_dev:
16851686 /* This should mirror cxl_remove_adapter, except without the
16861687 * sysfs parts
16871688 */
16881689 cxl_debugfs_adapter_remove(adapter);
16891690 cxl_deconfigure_adapter(adapter);
1690
- device_unregister(&adapter->dev);
1691
+ put_device(&adapter->dev);
16911692 return ERR_PTR(rc);
16921693
16931694 err_release:
....@@ -1718,7 +1719,6 @@
17181719 {
17191720 struct device_node *np;
17201721 int depth = 0;
1721
- const __be32 *prop;
17221722
17231723 if (!(np = pci_device_to_OF_node(dev))) {
17241724 pr_err("cxl: np = NULL\n");
....@@ -1727,8 +1727,7 @@
17271727 of_node_get(np);
17281728 while (np) {
17291729 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"))
17321731 break;
17331732 depth++;
17341733 }