net: r8169: add device tree based LED configuration for r8125#496
net: r8169: add device tree based LED configuration for r8125#496mingzhangqun wants to merge 2 commits into
Conversation
437a17e to
f6da7e9
Compare
|
This is a better approach using device tree for board-specific LED config. A few suggestions to improve efficiency and safety: 1. Avoid Repeated Memory AllocationThe function allocates and parses on every call (WoL + hardware init). Cache the config once during probe instead: // In rtl8169_private struct:
u32 *led_config;
int led_config_count;
// Parse once during probe, then reuse in rtl8125_apply_dt_led_config()This eliminates the 2. Eliminate Redundant CallsCurrently called twice during init—from both 3. Improve Type Safety (Minor)for (i = 0; i < count; i += 2)
RTL_W16(tp, (unsigned int)led_data[i], (u16)led_data[i + 1]);Use |
Read r8125 LED register/value pairs from the PCIe controller DT "realtek,led-data" property, instead of hardcoding in the shared driver path. Walk up the device parent chain to find the PCIe platform device's of_node, since PCI devices on Rockchip platforms do not have their of_node set directly. Parse the DT property once during probe and cache it in the driver private struct. Apply the cached config from rtl_hw_start_8125_common only, eliminating redundant calls and repeated memory allocation.
f6da7e9 to
21bb15e
Compare
|
@HeyMeco Thanks for the review! All three suggestions applied in the latest push:
Patch updated to v2 (21bb15e). The diff vs the previous revision is essentially the parse/apply split + the struct fields + the probe/remove wiring. |
|
Superseded by #497 (branch recreated due to CI runner failure). All discussion migrated. |
Summary
Read r8125 LED register/value pairs from the PCIe controller device tree
realtek,led-dataproperty, instead of hardcoding in the shared driver path.The driver searches DT nodes for
realtek,led-dataand writes each reg/value pair viaRTL_W16.Tested on Seeed reComputer RK3588 DevKit