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

Configure Feed

Select the types of activity you want to include in your feed.

power: supply: bq25890: Add bq25890_set_otg_cfg() helper

Add a bq25890_set_otg_cfg() helper function, this is a preparation
patch for adding regulator support.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Hans de Goede and committed by
Sebastian Reichel
5575802d f481d5b8

+15 -13
+15 -13
drivers/power/supply/bq25890_charger.c
··· 832 832 return PTR_ERR_OR_ZERO(bq->charger); 833 833 } 834 834 835 + static int bq25890_set_otg_cfg(struct bq25890_device *bq, u8 val) 836 + { 837 + int ret; 838 + 839 + ret = bq25890_field_write(bq, F_OTG_CFG, val); 840 + if (ret < 0) 841 + dev_err(bq->dev, "Error switching to boost/charger mode: %d\n", ret); 842 + 843 + return ret; 844 + } 845 + 835 846 static void bq25890_usb_work(struct work_struct *data) 836 847 { 837 848 int ret; ··· 852 841 switch (bq->usb_event) { 853 842 case USB_EVENT_ID: 854 843 /* Enable boost mode */ 855 - ret = bq25890_field_write(bq, F_OTG_CFG, 1); 856 - if (ret < 0) 857 - goto error; 844 + bq25890_set_otg_cfg(bq, 1); 858 845 break; 859 846 860 847 case USB_EVENT_NONE: 861 848 /* Disable boost mode */ 862 - ret = bq25890_field_write(bq, F_OTG_CFG, 0); 863 - if (ret < 0) 864 - goto error; 865 - 866 - power_supply_changed(bq->charger); 849 + ret = bq25890_set_otg_cfg(bq, 0); 850 + if (ret == 0) 851 + power_supply_changed(bq->charger); 867 852 break; 868 853 } 869 - 870 - return; 871 - 872 - error: 873 - dev_err(bq->dev, "Error switching to boost/charger mode.\n"); 874 854 } 875 855 876 856 static int bq25890_usb_notifier(struct notifier_block *nb, unsigned long val,