Simplify how the vendor and device ID are computed by using
get_unaligned_le16 instead of open-coded bit operations.

While there, also store the IDs into variables and log them for debugging.

Signed-off-by: Luca Ceresoli <[email protected]>

---

Changes in v2:
- new patch, split out of v1 patch 1 (Javier)
---
 drivers/gpu/drm/bridge/ite-it66121.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ite-it66121.c 
b/drivers/gpu/drm/bridge/ite-it66121.c
index 8bc96ef006f8..4642a32f1bd0 100644
--- a/drivers/gpu/drm/bridge/ite-it66121.c
+++ b/drivers/gpu/drm/bridge/ite-it66121.c
@@ -1573,6 +1573,7 @@ static const struct it66121_chip_info it66xx_chip_info[] 
= {
 static int it66121_probe(struct i2c_client *client)
 {
        __u8 chip_id_regs[4];
+       u16 vendor_id, device_id;
        u32 revision_id;
        struct device_node *ep;
        int ret, i;
@@ -1646,10 +1647,14 @@ static int it66121_probe(struct i2c_client *client)
        revision_id = FIELD_GET(IT66121_REVISION_MASK, chip_id_regs[3]);
        chip_id_regs[3] &= IT66121_DEVICE_ID1_MASK;
 
+       vendor_id = get_unaligned_le16(&chip_id_regs[0]);
+       device_id = get_unaligned_le16(&chip_id_regs[2]);
+       dev_dbg(dev, "vendor %04x device %04x (rev %01x)\n", vendor_id, 
device_id, revision_id);
+
        for (i = 0; i < ARRAY_SIZE(it66xx_chip_info); i++) {
                chip_info = &it66xx_chip_info[i];
-               if ((chip_id_regs[1] << 8 | chip_id_regs[0]) == chip_info->vid 
&&
-                   (chip_id_regs[3] << 8 | chip_id_regs[2]) == chip_info->pid) 
{
+               if (vendor_id == chip_info->vid &&
+                   device_id == chip_info->pid) {
                        ctx->id = chip_info->id;
                        break;
                }

-- 
2.56.1

Reply via email to