Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

extcon: cht-wc: Correct USBID bit field handling

USBID is 2-bit bit field according to specification. Make it clear.

No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

authored by

Andy Shevchenko and committed by
Chanwoo Choi
a4722503 001d3ecc

+19 -13
+19 -13
drivers/extcon/extcon-intel-cht-wc.c
··· 62 62 #define CHT_WC_PWRSRC_VBUS BIT(0) 63 63 #define CHT_WC_PWRSRC_DC BIT(1) 64 64 #define CHT_WC_PWRSRC_BATT BIT(2) 65 - #define CHT_WC_PWRSRC_ID_GND BIT(3) 66 - #define CHT_WC_PWRSRC_ID_FLOAT BIT(4) 65 + #define CHT_WC_PWRSRC_USBID_MASK GENMASK(4, 3) 66 + #define CHT_WC_PWRSRC_USBID_SHIFT 3 67 + #define CHT_WC_PWRSRC_RID_ACA 0 68 + #define CHT_WC_PWRSRC_RID_GND 1 69 + #define CHT_WC_PWRSRC_RID_FLOAT 2 67 70 68 71 #define CHT_WC_VBUS_GPIO_CTLO 0x6e2d 69 72 #define CHT_WC_VBUS_GPIO_CTLO_OUTPUT BIT(0) ··· 107 104 108 105 static int cht_wc_extcon_get_id(struct cht_wc_extcon_data *ext, int pwrsrc_sts) 109 106 { 110 - if (pwrsrc_sts & CHT_WC_PWRSRC_ID_GND) 107 + switch ((pwrsrc_sts & CHT_WC_PWRSRC_USBID_MASK) >> CHT_WC_PWRSRC_USBID_SHIFT) { 108 + case CHT_WC_PWRSRC_RID_GND: 111 109 return USB_ID_GND; 112 - if (pwrsrc_sts & CHT_WC_PWRSRC_ID_FLOAT) 110 + case CHT_WC_PWRSRC_RID_FLOAT: 113 111 return USB_ID_FLOAT; 114 - 115 - /* 116 - * Once we have iio support for the gpadc we should read the USBID 117 - * gpadc channel here and determine ACA role based on that. 118 - */ 119 - return USB_ID_FLOAT; 112 + case CHT_WC_PWRSRC_RID_ACA: 113 + default: 114 + /* 115 + * Once we have IIO support for the GPADC we should read 116 + * the USBID GPADC channel here and determine ACA role 117 + * based on that. 118 + */ 119 + return USB_ID_FLOAT; 120 + } 120 121 } 121 122 122 123 static int cht_wc_extcon_get_charger(struct cht_wc_extcon_data *ext, ··· 299 292 { 300 293 struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent); 301 294 struct cht_wc_extcon_data *ext; 295 + unsigned long mask = ~(CHT_WC_PWRSRC_VBUS | CHT_WC_PWRSRC_USBID_MASK); 302 296 int irq, ret; 303 297 304 298 irq = platform_get_irq(pdev, 0); ··· 360 352 } 361 353 362 354 /* Unmask irqs */ 363 - ret = regmap_write(ext->regmap, CHT_WC_PWRSRC_IRQ_MASK, 364 - (int)~(CHT_WC_PWRSRC_VBUS | CHT_WC_PWRSRC_ID_GND | 365 - CHT_WC_PWRSRC_ID_FLOAT)); 355 + ret = regmap_write(ext->regmap, CHT_WC_PWRSRC_IRQ_MASK, mask); 366 356 if (ret) { 367 357 dev_err(ext->dev, "Error writing irq-mask: %d\n", ret); 368 358 goto disable_sw_control;