summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
diff options
context:
space:
mode:
authorJonas Jelonek <jelonek.jonas@gmail.com>2025-09-27 10:19:28 +0000
committerAndi Shyti <andi.shyti@kernel.org>2025-10-04 11:43:40 +0200
commit059374aa0ab11a758a9e2219e90361911397b03d (patch)
treeb71e1142eeeb686f48e6750f60a0525a47933992 /drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
parentd5b4fd6ed8ea3eb5dc072285a5e4c0ee32e829b2 (diff)
i2c: rtl9300: separate xfer configuration and execution
So far, the rtl9300_i2c_smbus_xfer code is quite a mess with function calls distributed over the whole function setting different values in different cases. Calls to rtl9300_i2c_config_xfer and rtl9300_i2c_reg_addr_set are used in every case-block with varying values whose meaning is not instantly obvious. In some cases, there are additional calls within these case-blocks doing more things. This is in general a bad design and especially really bad for readability and maintainability because it distributes changes or issues to multiple locations due to the same function being called with different hardcoded values in different places. To have a good structure, setting different parameters based on the desired operation should not be interleaved with applying these parameters to the hardware registers. Or in different words, the parameter site should be mixed with the call site. Thus, separate configuration and execution of an SMBus xfer within rtl9300_i2c_smbus_xfer to improve readability and maintainability. Add a new 'struct rtl9300_i2c_xfer' to carry the required parameters for an xfer which are configured based on the input parameters within a single switch-case block, without having any function calls within this block. The function calls to actually apply these values to the hardware registers then appear below in a single place and just operate on the passed instance of 'struct rtl9300_i2c_xfer'. These are 'rtl9300_i2c_prepare_xfer' which combines applying all parameters of the xfer to the corresponding register, and 'rtl9300_i2c_do_xfer' which actually executes the xfer and does post-processing if needed. Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com> Tested-by: Sven Eckelmann <sven@narfation.org> Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # On RTL9302C based board Tested-by: Markus Stockhausen <markus.stockhausen@gmx.de> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20250927101931.71575-7-jelonek.jonas@gmail.com
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c')
0 files changed, 0 insertions, 0 deletions