bus: mhi: Use bitfield operations for register read and write
authorManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Tue, 1 Mar 2022 16:03:03 +0000 (21:33 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 18 Mar 2022 13:02:54 +0000 (14:02 +0100)
commitd28cab4d4aa06cdb203196cefcd31208a8ccd808
tree14ac992b8959c149d1df555de1c11dceb1416ab3
parenta0f5a630668cb8b2ebf5204f08e957875e991780
bus: mhi: Use bitfield operations for register read and write

Functions like mhi_read_reg_field(), mhi_poll_reg_field() and
mhi_write_reg_field() could be modified to not depend on the shift value
passed as an argument. Instead, the bitfield operation could be used to
extract the shift value from the mask itself.

This eliminates the need to define _SHIFT (and _SHFT) macros and
simplifies the code a bit. For shift values those cannot be determined
during build time, "__ffs()" helper is used find the shift value during
runtime.

While at it, let's also get rid of 32-bit masks like CHDBOFF_CHDBOFF_MASK
by doing the full 32-bit register read.

Suggested-by: Alex Elder <elder@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20220301160308.107452-6-manivannan.sadhasivam@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/bus/mhi/host/boot.c
drivers/bus/mhi/host/debugfs.c
drivers/bus/mhi/host/init.c
drivers/bus/mhi/host/internal.h
drivers/bus/mhi/host/main.c
drivers/bus/mhi/host/pm.c