Re: [RESEND PATCH v2 7/7] usb: typec: qcom: Add a pm8150b TCPM driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Bryan,

Thanks for your patch! Perhaps something to improve:

[auto build test WARNING on usb/usb-testing]
[also build test WARNING on robh/for-next linus/master v5.15-rc7 next-20211029]
[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]

url:    https://github.com/0day-ci/linux/commits/Bryan-O-Donoghue/Add-pm8150b-TPCM-driver/20211029-010406
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: riscv-randconfig-c006-20211028 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
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
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://github.com/0day-ci/linux/commit/fe4e9d995058581a4428c9c5c91e848eab3beef5
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Bryan-O-Donoghue/Add-pm8150b-TPCM-driver/20211029-010406
        git checkout fe4e9d995058581a4428c9c5c91e848eab3beef5
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


clang-analyzer warnings: (new ones prefixed by >>)

>> drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_typec.c:214:2: warning: Value stored to 'debounced' is never read [clang-analyzer-deadcode.DeadStores]
           debounced = !!(misc & TYPEC_DEBOUNCE_DONE);
           ^           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

>> drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_typec.c:308:2: warning: Value stored to 'orientation' is never read [clang-analyzer-deadcode.DeadStores]
           orientation = !!(misc & CC_ORIENTATION);
           ^             ~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/debounced +214 drivers/usb/typec/tcpm/qcom/qcom_pmic_tcpm_typec.c

fe4e9d99505858 Bryan O'Donoghue 2021-10-28  199  int qcom_pmic_tcpm_typec_get_cc(struct pmic_typec *pmic_typec,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  200  				enum typec_cc_status *cc1,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  201  				enum typec_cc_status *cc2)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  202  {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  203  	struct device *dev = pmic_typec->dev;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  204  	unsigned int misc, val;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  205  	bool attached, debounced;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  206  	int ret = 0;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  207
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  208  	ret = regmap_read(pmic_typec->regmap,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  209  			  pmic_typec->base + TYPEC_MISC_STATUS_REG, &misc);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  210  	if (ret)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  211  		goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  212
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  213  	attached = !!(misc & CC_ATTACHED);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 @214  	debounced = !!(misc & TYPEC_DEBOUNCE_DONE);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  215
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  216  	if (pmic_typec->debouncing_cc) {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  217  		ret = -EBUSY;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  218  		goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  219  	}
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  220
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  221  	*cc1 = TYPEC_CC_OPEN;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  222  	*cc2 = TYPEC_CC_OPEN;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  223
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  224  	if (!(attached))
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  225  		goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  226
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  227  	if (misc & SNK_SRC_MODE) {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  228  		ret = regmap_read(pmic_typec->regmap,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  229  				  pmic_typec->base + TYPEC_SRC_STATUS_REG,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  230  				  &val);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  231  		if (ret)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  232  			goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  233  		switch (val & DETECTED_SRC_TYPE_MASK) {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  234  		case SRC_RD_OPEN:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  235  			val = TYPEC_CC_RD;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  236  			break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  237  		case SRC_RD_RA_VCONN:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  238  			val = TYPEC_CC_RD;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  239  			*cc1 = TYPEC_CC_RA;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  240  			*cc2 = TYPEC_CC_RA;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  241  			break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  242  		default:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  243  			dev_warn(dev, "unexpected src status %.2x\n", val);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  244  			val = TYPEC_CC_RD;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  245  			break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  246  		}
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  247  	} else {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  248  		ret = regmap_read(pmic_typec->regmap,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  249  				  pmic_typec->base + TYPEC_SNK_STATUS_REG,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  250  				  &val);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  251  		if (ret)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  252  			goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  253  		switch (val & DETECTED_SNK_TYPE_MASK) {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  254  		case SNK_RP_STD:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  255  			val = TYPEC_CC_RP_DEF;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  256  			break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  257  		case SNK_RP_1P5:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  258  			val = TYPEC_CC_RP_1_5;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  259  			break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  260  		case SNK_RP_3P0:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  261  			val = TYPEC_CC_RP_3_0;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  262  			break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  263  		default:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  264  			dev_warn(dev, "unexpected snk status %.2x\n", val);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  265  			val = TYPEC_CC_RP_DEF;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  266  			break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  267  		}
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  268  		val = TYPEC_CC_RP_DEF;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  269  	}
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  270
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  271  	if (misc & CC_ORIENTATION)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  272  		*cc2 = val;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  273  	else
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  274  		*cc1 = val;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  275
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  276  done:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  277  	dev_dbg(dev, "get_cc: misc 0x%08x cc1 0x%08x %s cc2 0x%08x %s attached %d cc=%s\n",
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  278  		misc, *cc1, cc_to_name(*cc1), *cc2, cc_to_name(*cc2), !!(misc & CC_ATTACHED),
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  279  		misc_to_cc(misc));
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  280
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  281  	return ret;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  282  }
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  283
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  284  static void qcom_pmic_set_cc_debounce(struct pmic_typec *pmic_typec)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  285  {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  286  	pmic_typec->debouncing_cc = true;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  287  	schedule_delayed_work(&pmic_typec->cc_debounce_dwork,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  288  			      msecs_to_jiffies(2));
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  289  }
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  290
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  291  int qcom_pmic_tcpm_typec_set_cc(struct pmic_typec *pmic_typec,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  292  				enum typec_cc_status cc)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  293  {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  294  	struct device *dev = pmic_typec->dev;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  295  	unsigned int mode, currsrc;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  296  	unsigned int orientation, misc;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  297  	unsigned long flags;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  298  	int ret;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  299
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  300  	spin_lock_irqsave(&pmic_typec->lock, flags);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  301
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  302  	ret = regmap_read(pmic_typec->regmap,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  303  			  pmic_typec->base + TYPEC_MISC_STATUS_REG,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  304  			  &misc);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  305  	if (ret)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  306  		goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  307
fe4e9d99505858 Bryan O'Donoghue 2021-10-28 @308  	orientation = !!(misc & CC_ORIENTATION);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  309
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  310  	mode = EN_SRC_ONLY;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  311
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  312  	switch (cc) {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  313  	case TYPEC_CC_OPEN:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  314  		currsrc = TYPEC_SRC_RP_SEL_80UA;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  315  		break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  316  	case TYPEC_CC_RP_DEF:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  317  		currsrc = TYPEC_SRC_RP_SEL_80UA;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  318  		break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  319  	case TYPEC_CC_RP_1_5:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  320  		currsrc = TYPEC_SRC_RP_SEL_180UA;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  321  		break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  322  	case TYPEC_CC_RP_3_0:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  323  		currsrc = TYPEC_SRC_RP_SEL_330UA;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  324  		break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  325  	case TYPEC_CC_RD:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  326  		currsrc = TYPEC_SRC_RP_SEL_80UA;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  327  		mode = EN_SNK_ONLY;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  328  		break;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  329  	default:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  330  		dev_warn(dev, "unexpected set_cc %d\n", cc);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  331  		ret = -EINVAL;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  332  		goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  333  	}
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  334
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  335  	if (mode == EN_SRC_ONLY) {
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  336  		ret = regmap_write(pmic_typec->regmap,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  337  				   pmic_typec->base + TYPEC_CURRSRC_CFG_REG,
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  338  				   currsrc);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  339  		if (ret)
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  340  			goto done;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  341  	}
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  342
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  343  	pmic_typec->cc = cc;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  344  	qcom_pmic_set_cc_debounce(pmic_typec);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  345  	ret = 0;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  346
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  347  done:
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  348  	spin_unlock_irqrestore(&pmic_typec->lock, flags);
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  349
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  350  	dev_dbg(dev, "set_cc: currsrc=%x %s mode %s debounce %d attached %d cc=%s\n",
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  351  		currsrc, rp_sel_to_name(currsrc),
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  352  		mode == EN_SRC_ONLY ? "EN_SRC_ONLY" : "EN_SNK_ONLY",
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  353  		pmic_typec->debouncing_cc, !!(misc & CC_ATTACHED),
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  354  		misc_to_cc(misc));
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  355
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  356  	return ret;
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  357  }
fe4e9d99505858 Bryan O'Donoghue 2021-10-28  358

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux