lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 8 Jul 2022 00:00:54 +0800
From:   kernel test robot <lkp@...el.com>
To:     Caleb Connolly <caleb.connolly@...aro.org>,
        Sebastian Reichel <sre@...nel.org>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzk@...nel.org>,
        Andy Gross <agross@...nel.org>,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        Nathan Chancellor <nathan@...nel.org>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Tom Rix <trix@...hat.com>, linux-pm@...r.kernel.org,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arm-msm@...r.kernel.org, llvm@...ts.linux.dev,
        phone-devel@...r.kernel.org
Cc:     kbuild-all@...ts.01.org
Subject: Re: [PATCH v4 1/2] power: supply: add Qualcomm PMI8998 SMB2 Charger
 driver

Hi Caleb,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on sre-power-supply/for-next]
[also build test WARNING on robh/for-next linus/master v5.19-rc5 next-20220707]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Caleb-Connolly/power-supply-introduce-support-for-the-Qualcomm-smb2-charger/20220707-034307
base:   https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next
config: alpha-allyesconfig
compiler: alpha-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/a6b315467a158024bb1af7fed00c9a5227c9b293
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Caleb-Connolly/power-supply-introduce-support-for-the-Qualcomm-smb2-charger/20220707-034307
        git checkout a6b315467a158024bb1af7fed00c9a5227c9b293
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=alpha SHELL=/bin/bash drivers/power/supply/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@...el.com>

All warnings (new ones prefixed by >>):

>> drivers/power/supply/qcom_pmi8998_charger.c:425:5: warning: no previous prototype for 'smb2_get_prop_usb_online' [-Wmissing-prototypes]
     425 | int smb2_get_prop_usb_online(struct smb2_chip *chip, int *val)
         |     ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/power/supply/qcom_pmi8998_charger.c:486:5: warning: no previous prototype for 'smb2_get_prop_status' [-Wmissing-prototypes]
     486 | int smb2_get_prop_status(struct smb2_chip *chip, int *val)
         |     ^~~~~~~~~~~~~~~~~~~~
>> drivers/power/supply/qcom_pmi8998_charger.c:565:6: warning: no previous prototype for 'smb2_status_change_work' [-Wmissing-prototypes]
     565 | void smb2_status_change_work(struct work_struct *work)
         |      ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/power/supply/qcom_pmi8998_charger.c:614:5: warning: no previous prototype for 'smb2_get_iio_chan' [-Wmissing-prototypes]
     614 | int smb2_get_iio_chan(struct smb2_chip *chip, struct iio_channel *chan,
         |     ^~~~~~~~~~~~~~~~~
>> drivers/power/supply/qcom_pmi8998_charger.c:635:5: warning: no previous prototype for 'smb2_get_prop_health' [-Wmissing-prototypes]
     635 | int smb2_get_prop_health(struct smb2_chip *chip, int *val)
         |     ^~~~~~~~~~~~~~~~~~~~
>> drivers/power/supply/qcom_pmi8998_charger.c:736:13: warning: no previous prototype for 'smb2_handle_batt_overvoltage' [-Wmissing-prototypes]
     736 | irqreturn_t smb2_handle_batt_overvoltage(int irq, void *data)
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/power/supply/qcom_pmi8998_charger.c:754:13: warning: no previous prototype for 'smb2_handle_usb_plugin' [-Wmissing-prototypes]
     754 | irqreturn_t smb2_handle_usb_plugin(int irq, void *data)
         |             ^~~~~~~~~~~~~~~~~~~~~~
>> drivers/power/supply/qcom_pmi8998_charger.c:766:13: warning: no previous prototype for 'smb2_handle_usb_icl_change' [-Wmissing-prototypes]
     766 | irqreturn_t smb2_handle_usb_icl_change(int irq, void *data)
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/power/supply/qcom_pmi8998_charger.c:775:13: warning: no previous prototype for 'smb2_handle_wdog_bark' [-Wmissing-prototypes]
     775 | irqreturn_t smb2_handle_wdog_bark(int irq, void *data)
         |             ^~~~~~~~~~~~~~~~~~~~~
   drivers/power/supply/qcom_pmi8998_charger.c:896:19: warning: initialized field overwritten [-Woverride-init]
     896 |           .addr = 1950000 / 25000 },
         |                   ^~~~~~~
   drivers/power/supply/qcom_pmi8998_charger.c:896:19: note: (near initialization for 'smb2_init_seq[17].addr')


vim +/smb2_get_prop_usb_online +425 drivers/power/supply/qcom_pmi8998_charger.c

   424	
 > 425	int smb2_get_prop_usb_online(struct smb2_chip *chip, int *val)
   426	{
   427		unsigned int stat;
   428		int rc;
   429	
   430		rc = regmap_read(chip->regmap, chip->base + POWER_PATH_STATUS, &stat);
   431		if (rc < 0) {
   432			dev_err(chip->dev, "Couldn't read POWER_PATH_STATUS! ret=%d\n",
   433				rc);
   434			return rc;
   435		}
   436	
   437		*val = (stat & P_PATH_USE_USBIN_BIT) &&
   438		       (stat & P_PATH_VALID_INPUT_POWER_SOURCE_STS_BIT);
   439		return 0;
   440	}
   441	
   442	/*
   443	 * Qualcomm "automatic power source detection" aka APSD
   444	 * tells us what type of charger we're connected to.
   445	 */
   446	static int smb2_apsd_get_charger_type(struct smb2_chip *chip, int *val)
   447	{
   448		int rc;
   449		unsigned int apsd_stat, stat;
   450		int usb_online;
   451	
   452		rc = smb2_get_prop_usb_online(chip, &usb_online);
   453		if (rc < 0 || !usb_online) {
   454			*val = POWER_SUPPLY_USB_TYPE_UNKNOWN;
   455			return 0;
   456		}
   457	
   458		rc = regmap_read(chip->regmap, chip->base + APSD_STATUS, &apsd_stat);
   459		if (rc < 0) {
   460			dev_err(chip->dev, "Failed to read apsd status, rc = %d", rc);
   461			return rc;
   462		}
   463		if (!(apsd_stat & APSD_DTC_STATUS_DONE_BIT)) {
   464			dev_err(chip->dev, "Apsd not ready");
   465			return -EAGAIN;
   466		}
   467	
   468		rc = regmap_read(chip->regmap, chip->base + APSD_RESULT_STATUS, &stat);
   469		if (rc < 0) {
   470			dev_err(chip->dev, "Failed to read apsd result, rc = %d", rc);
   471			return rc;
   472		}
   473	
   474		stat &= APSD_RESULT_STATUS_MASK;
   475	
   476		if (stat & CDP_CHARGER_BIT)
   477			*val = POWER_SUPPLY_USB_TYPE_CDP;
   478		else if (stat & (DCP_CHARGER_BIT | OCP_CHARGER_BIT | FLOAT_CHARGER_BIT))
   479			*val = POWER_SUPPLY_USB_TYPE_DCP;
   480		else /* SDP_CHARGER_BIT (or others) */
   481			*val = POWER_SUPPLY_USB_TYPE_SDP;
   482	
   483		return 0;
   484	}
   485	
 > 486	int smb2_get_prop_status(struct smb2_chip *chip, int *val)
   487	{
   488		int usb_online_val;
   489		unsigned char stat[2];
   490		int rc;
   491	
   492		rc = smb2_get_prop_usb_online(chip, &usb_online_val);
   493		if (rc < 0) {
   494			dev_err(chip->dev, "Couldn't get usb online property rc = %d\n",
   495				rc);
   496			return rc;
   497		}
   498	
   499		if (!usb_online_val) {
   500			*val = POWER_SUPPLY_STATUS_DISCHARGING;
   501			return rc;
   502		}
   503	
   504		rc = regmap_bulk_read(chip->regmap,
   505				      chip->base + BATTERY_CHARGER_STATUS_1, &stat, 2);
   506		if (rc < 0) {
   507			dev_err(chip->dev, "Failed to read charging status ret=%d\n",
   508				rc);
   509			return rc;
   510		}
   511	
   512		if (stat[1] & CHARGER_ERROR_STATUS_BAT_OV_BIT) {
   513			*val = POWER_SUPPLY_STATUS_NOT_CHARGING;
   514			return 0;
   515		}
   516	
   517		stat[0] = stat[0] & BATTERY_CHARGER_STATUS_MASK;
   518	
   519		switch (stat[0]) {
   520		case TRICKLE_CHARGE:
   521		case PRE_CHARGE:
   522		case FAST_CHARGE:
   523		case FULLON_CHARGE:
   524		case TAPER_CHARGE:
   525			*val = POWER_SUPPLY_STATUS_CHARGING;
   526			return rc;
   527		case DISABLE_CHARGE:
   528			*val = POWER_SUPPLY_STATUS_NOT_CHARGING;
   529			return rc;
   530		case TERMINATE_CHARGE:
   531			*val = POWER_SUPPLY_STATUS_FULL;
   532			return rc;
   533		case INHIBIT_CHARGE:
   534		default:
   535			*val = POWER_SUPPLY_STATUS_UNKNOWN;
   536			return rc;
   537		}
   538	}
   539	
   540	static inline int smb2_get_current_limit(struct smb2_chip *chip,
   541						 unsigned int *val)
   542	{
   543		int rc = regmap_read(chip->regmap, chip->base + ICL_STATUS, val);
   544	
   545		if (rc >= 0)
   546			*val *= 25000;
   547		return rc;
   548	}
   549	
   550	static int smb2_set_current_limit(struct smb2_chip *chip, unsigned int val)
   551	{
   552		unsigned char val_raw;
   553	
   554		if (val > 4800000) {
   555			dev_err(chip->dev,
   556				"Can't set current limit higher than 4800000uA");
   557			return -EINVAL;
   558		}
   559		val_raw = val / 25000;
   560	
   561		return regmap_write(chip->regmap, chip->base + USBIN_CURRENT_LIMIT_CFG,
   562				    val_raw);
   563	}
   564	
 > 565	void smb2_status_change_work(struct work_struct *work)
   566	{
   567		struct smb2_chip *chip =
   568			container_of(work, struct smb2_chip, status_change_work.work);
   569		unsigned int charger_type, current_ua;
   570		int usb_online, count, rc;
   571	
   572		smb2_get_prop_usb_online(chip, &usb_online);
   573		if (usb_online == 0) {
   574			chip->default_curr_limit = 0;
   575			return;
   576		}
   577	
   578		for (count = 0; count < 3; count++) {
   579			dev_dbg(chip->dev, "get charger type retry %d\n", count);
   580			rc = smb2_apsd_get_charger_type(chip, &charger_type);
   581			if (rc == 0)
   582				break;
   583			msleep(100);
   584		}
   585	
   586		if (rc < 0) {
   587			rc = regmap_update_bits(chip->regmap, chip->base + CMD_APSD,
   588						APSD_RERUN_BIT, APSD_RERUN_BIT);
   589			schedule_delayed_work(&chip->status_change_work,
   590					      msecs_to_jiffies(1500));
   591			dev_dbg(chip->dev, "get charger type failed, rerun apsd\n");
   592			return;
   593		}
   594	
   595		switch (charger_type) {
   596		case POWER_SUPPLY_USB_TYPE_CDP:
   597			current_ua = CDP_CURRENT_UA;
   598			break;
   599		case POWER_SUPPLY_USB_TYPE_DCP:
   600			current_ua = DCP_CURRENT_UA;
   601			break;
   602		case POWER_SUPPLY_USB_TYPE_SDP:
   603		default:
   604			current_ua = SDP_CURRENT_UA;
   605			break;
   606		}
   607	
   608		chip->default_curr_limit = current_ua;
   609	
   610		smb2_set_current_limit(chip, current_ua);
   611		power_supply_changed(chip->chg_psy);
   612	}
   613	
 > 614	int smb2_get_iio_chan(struct smb2_chip *chip, struct iio_channel *chan,
   615			      int *val)
   616	{
   617		int rc;
   618		union power_supply_propval status;
   619	
   620		rc = power_supply_get_property(chip->chg_psy, POWER_SUPPLY_PROP_STATUS,
   621					       &status);
   622		if (rc < 0 || status.intval != POWER_SUPPLY_STATUS_CHARGING) {
   623			*val = 0;
   624			return 0;
   625		}
   626	
   627		if (IS_ERR(chan)) {
   628			dev_err(chip->dev, "Failed to chan, err = %li", PTR_ERR(chan));
   629			return PTR_ERR(chan);
   630		}
   631	
   632		return iio_read_channel_processed(chan, val);
   633	}
   634	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

View attachment "config" of type "text/plain" (306786 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ