Recently I ended up experimenting with some sysfs PM controls and while trying to figure out how to use them stumbled upon some code duplication in sysfs and debugfs handling.
There seems to be a number of places which parse input strings into arrays of longs and those places look a lot like copy&paste. There is also some redundancy in how strsep is used, ie. code that could be simplified and made more clear. So I went to eliminate and consolidate, plus some other minor cleanups. Sending as RFC because I am not the best equipped to verify I introduced no regressions and also because the common parsing helper I put in amdgpu.h. Which is quite bad, but I did not figure out (yet) what is the "official" way of sharing common helpers between PM, display and amdgpu.ko itself. Therefore if someone has a suggestion on where to place it, or general feedback telling me if this whole cleanup is something AMD wants to entertain or not. There could be some further cleanups as well, for example a lot of the places are quite over the top with stack usage, and with not very obvious reasons why they happen to be safe against overflows. Tvrtko Ursulin (6): drm/amd/pm: Remove unnecessary local variable initialization drm/amd/display: Use memdup_user drm/amd/display: Align data types in debugfs code drm/amd/display: Simplify debugfs token parsing drm/amd: Move display debugfs array of longs parsing into common drm/amd/pm: Use common helper for parsing sysfs writes drivers/gpu/drm/amd/amdgpu/amdgpu.h | 36 ++ .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 421 +++++++----------- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 296 +++++------- 3 files changed, 306 insertions(+), 447 deletions(-) -- 2.48.0
