forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/drivers/of/dynamic.c
....@@ -63,15 +63,14 @@
6363 }
6464 EXPORT_SYMBOL_GPL(of_reconfig_notifier_unregister);
6565
66
-#ifdef DEBUG
67
-const char *action_names[] = {
66
+static const char *action_names[] = {
67
+ [0] = "INVALID",
6868 [OF_RECONFIG_ATTACH_NODE] = "ATTACH_NODE",
6969 [OF_RECONFIG_DETACH_NODE] = "DETACH_NODE",
7070 [OF_RECONFIG_ADD_PROPERTY] = "ADD_PROPERTY",
7171 [OF_RECONFIG_REMOVE_PROPERTY] = "REMOVE_PROPERTY",
7272 [OF_RECONFIG_UPDATE_PROPERTY] = "UPDATE_PROPERTY",
7373 };
74
-#endif
7574
7675 int of_reconfig_notify(unsigned long action, struct of_reconfig_data *p)
7776 {
....@@ -207,11 +206,8 @@
207206
208207 if (!of_node_check_flag(np, OF_OVERLAY)) {
209208 np->name = __of_get_property(np, "name", NULL);
210
- np->type = __of_get_property(np, "device_type", NULL);
211209 if (!np->name)
212210 np->name = "<NULL>";
213
- if (!np->type)
214
- np->type = "<NULL>";
215211
216212 phandle = __of_get_property(np, "phandle", &sz);
217213 if (!phandle)
....@@ -279,7 +275,7 @@
279275 of_node_set_flag(np, OF_DETACHED);
280276
281277 /* race with of_find_node_by_phandle() prevented by devtree_lock */
282
- __of_free_phandle_cache_entry(np->phandle);
278
+ __of_phandle_cache_inv_entry(np->phandle);
283279 }
284280
285281 /**
....@@ -289,7 +285,6 @@
289285 {
290286 struct of_reconfig_data rd;
291287 unsigned long flags;
292
- int rc = 0;
293288
294289 memset(&rd, 0, sizeof(rd));
295290 rd.dn = np;
....@@ -304,7 +299,7 @@
304299
305300 of_reconfig_notify(OF_RECONFIG_DETACH_NODE, &rd);
306301
307
- return rc;
302
+ return 0;
308303 }
309304 EXPORT_SYMBOL_GPL(of_detach_node);
310305
....@@ -360,6 +355,7 @@
360355
361356 property_list_free(node->properties);
362357 property_list_free(node->deadprops);
358
+ fwnode_links_purge(of_fwnode_handle(node));
363359
364360 kfree(node->full_name);
365361 kfree(node->data);
....@@ -593,21 +589,9 @@
593589 }
594590
595591 ret = __of_add_property(ce->np, ce->prop);
596
- if (ret) {
597
- pr_err("changeset: add_property failed @%pOF/%s\n",
598
- ce->np,
599
- ce->prop->name);
600
- break;
601
- }
602592 break;
603593 case OF_RECONFIG_REMOVE_PROPERTY:
604594 ret = __of_remove_property(ce->np, ce->prop);
605
- if (ret) {
606
- pr_err("changeset: remove_property failed @%pOF/%s\n",
607
- ce->np,
608
- ce->prop->name);
609
- break;
610
- }
611595 break;
612596
613597 case OF_RECONFIG_UPDATE_PROPERTY:
....@@ -621,20 +605,17 @@
621605 }
622606
623607 ret = __of_update_property(ce->np, ce->prop, &old_prop);
624
- if (ret) {
625
- pr_err("changeset: update_property failed @%pOF/%s\n",
626
- ce->np,
627
- ce->prop->name);
628
- break;
629
- }
630608 break;
631609 default:
632610 ret = -EINVAL;
633611 }
634612 raw_spin_unlock_irqrestore(&devtree_lock, flags);
635613
636
- if (ret)
614
+ if (ret) {
615
+ pr_err("changeset: apply failed: %-15s %pOF:%s\n",
616
+ action_names[ce->action], ce->np, ce->prop->name);
637617 return ret;
618
+ }
638619
639620 switch (ce->action) {
640621 case OF_RECONFIG_ATTACH_NODE:
....@@ -913,6 +894,9 @@
913894 {
914895 struct of_changeset_entry *ce;
915896
897
+ if (WARN_ON(action >= ARRAY_SIZE(action_names)))
898
+ return -EINVAL;
899
+
916900 ce = kzalloc(sizeof(*ce), GFP_KERNEL);
917901 if (!ce)
918902 return -ENOMEM;