1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Some small helpers for older Cirrus Logic parts. 4 * 5 * Copyright (C) 2021 Cirrus Logic, Inc. and 6 * Cirrus Logic International Semiconductor Ltd. 7 */ 8 9 static inline int cirrus_read_device_id(struct regmap *regmap, unsigned int reg) 10 { 11 u8 devid[3]; 12 int ret; 13 14 ret = regmap_bulk_read(regmap, reg, devid, ARRAY_SIZE(devid)); 15 if (ret < 0) 16 return ret; 17 18 return ((devid[0] & 0xFF) << 12) | 19 ((devid[1] & 0xFF) << 4) | 20 ((devid[2] & 0xF0) >> 4); 21 } 22