Hi Matti, [FYI, it's a private test report for your RFC patch.] [auto build test WARNING on sre-power-supply/for-next] [also build test WARNING on lee-mfd/for-mfd-next v5.16-rc1 next-20211118] [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/Matti-Vaittinen/power-supply-Add-some-fuel-gauge-logic/20211116-203220 base: https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next config: riscv-randconfig-s031-20211116 (attached as .config) compiler: riscv32-linux-gcc (GCC) 11.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # apt-get install sparse # sparse version: v0.6.4-dirty # https://github.com/0day-ci/linux/commit/bcab8f5e195119b2d4e405451a1b54bb7edb82c5 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Matti-Vaittinen/power-supply-Add-some-fuel-gauge-logic/20211116-203220 git checkout bcab8f5e195119b2d4e405451a1b54bb7edb82c5 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=riscv If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot sparse warnings: (new ones prefixed by >>) >> drivers/power/supply/bd71827-power.c:476:26: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __be16 [addressable] [usertype] tmp_curr @@ got int @@ drivers/power/supply/bd71827-power.c:476:26: sparse: expected restricted __be16 [addressable] [usertype] tmp_curr drivers/power/supply/bd71827-power.c:476:26: sparse: got int >> drivers/power/supply/bd71827-power.c:478:36: sparse: sparse: cast from restricted __be16 >> drivers/power/supply/bd71827-power.c:645:37: sparse: sparse: incorrect type in initializer (different base types) @@ expected unsigned short [usertype] *swap_lo @@ got restricted __be16 [usertype] * @@ drivers/power/supply/bd71827-power.c:645:37: sparse: expected unsigned short [usertype] *swap_lo drivers/power/supply/bd71827-power.c:645:37: sparse: got restricted __be16 [usertype] * vim +476 drivers/power/supply/bd71827-power.c 456 457 static int bd71827_get_current_ds_adc(struct bd71827_power *pwr, int *curr, int *curr_avg) 458 { 459 __be16 tmp_curr; 460 char *tmp = (char *)&tmp_curr; 461 int dir = 1; 462 int regs[] = { pwr->regs->ibat, pwr->regs->ibat_avg }; 463 int *vals[] = { curr, curr_avg }; 464 int ret, i; 465 466 for (dir = 1, i = 0; i < ARRAY_SIZE(regs); i++) { 467 ret = regmap_bulk_read(pwr->regmap, regs[i], &tmp_curr, 468 sizeof(tmp_curr)); 469 if (ret) 470 break; 471 472 if (*tmp & BD7182x_MASK_CURDIR_DISCHG) 473 dir = -1; 474 475 *tmp &= BD7182x_MASK_IBAT_U; > 476 tmp_curr = be16_to_cpu(tmp_curr); 477 > 478 *vals[i] = dir * ((int)tmp_curr) * pwr->curr_factor; 479 } 480 481 return ret; 482 } 483 484 static int bd71827_voltage_to_capacity(struct simple_gauge *sw, int ocv, 485 int temp __always_unused, 486 int *dsoc); 487 488 static int bd71827_voltage_to_capacity(struct simple_gauge *sw, int ocv, int temp, 489 int *dsoc) 490 { 491 int i = 0; 492 struct bd71827_power *pwr; 493 494 /* If ocv_table is not given try luck with batinfo */ 495 if (!use_load_bat_params || !ocv_table[0]) { 496 if (!sw) 497 return -EINVAL; 498 499 pwr = simple_gauge_get_drvdata(sw); 500 *dsoc = power_supply_batinfo_ocv2dcap(&pwr->batinfo, ocv, 0); 501 if (*dsoc < 0) 502 return *dsoc; 503 504 return 0; 505 } 506 507 /* Default or module param OCV table. We have NUM_BAT_PARAMS */ 508 if (ocv > ocv_table[0]) { 509 *dsoc = soc_table[0]; 510 } else { 511 for (i = 0; i < NUM_BAT_PARAMS; i++) { 512 if ((ocv <= ocv_table[i]) && (ocv > ocv_table[i+1])) { 513 *dsoc = (soc_table[i] - soc_table[i+1]) * 514 (ocv - ocv_table[i+1]) / 515 (ocv_table[i] - ocv_table[i+1]); 516 *dsoc += soc_table[i+1]; 517 break; 518 } 519 } 520 if (i == NUM_BAT_PARAMS) 521 *dsoc = soc_table[i - 1]; 522 } 523 524 return 0; 525 } 526 527 /* Unit is tenths of degree C */ 528 static int bd71827_get_temp(struct simple_gauge *sw, int *temp) 529 { 530 struct bd71827_power *pwr = simple_gauge_get_drvdata(sw); 531 struct regmap *regmap = pwr->regmap; 532 int ret; 533 int t; 534 535 ret = regmap_read(regmap, pwr->regs->btemp_vth, &t); 536 t = 200 - t; 537 538 if (ret || t > 200) { 539 dev_err(pwr->dev, "Failed to read battery temperature\n"); 540 *temp = 2000; 541 } else { 542 *temp = t * 10; 543 } 544 545 return ret; 546 } 547 548 /* Unit is tenths of degree C */ 549 static int bd71828_get_temp(struct simple_gauge *sw, int *temp) 550 { 551 struct bd71827_power *pwr = simple_gauge_get_drvdata(sw); 552 uint16_t t; 553 int ret; 554 int tmp = 200 * 10000; 555 556 ret = bd7182x_read16_himask(pwr, pwr->regs->btemp_vth, 557 BD71828_MASK_VM_BTMP_U, &t); 558 if (ret || t > 3200) 559 dev_err(pwr->dev, 560 "Failed to read system min average voltage\n"); 561 562 tmp -= 625ULL * (unsigned int)t; 563 *temp = tmp / 1000; 564 565 return ret; 566 } 567 568 static int bd71827_charge_status(struct bd71827_power *pwr, 569 int *s, int *h) 570 { 571 unsigned int state; 572 int status, health; 573 int ret = 1; 574 575 ret = regmap_read(pwr->regmap, pwr->regs->chg_state, &state); 576 if (ret) 577 dev_err(pwr->dev, "charger status reading failed (%d)\n", ret); 578 579 state &= BD7182x_MASK_CHG_STATE; 580 581 dev_dbg(pwr->dev, "CHG_STATE %d\n", state); 582 583 switch (state) { 584 case 0x00: 585 ret = 0; 586 status = POWER_SUPPLY_STATUS_DISCHARGING; 587 health = POWER_SUPPLY_HEALTH_GOOD; 588 break; 589 case 0x01: 590 case 0x02: 591 case 0x03: 592 case 0x0E: 593 status = POWER_SUPPLY_STATUS_CHARGING; 594 health = POWER_SUPPLY_HEALTH_GOOD; 595 break; 596 case 0x0F: 597 ret = 0; 598 status = POWER_SUPPLY_STATUS_FULL; 599 health = POWER_SUPPLY_HEALTH_GOOD; 600 break; 601 case 0x10: 602 case 0x11: 603 case 0x12: 604 case 0x13: 605 case 0x14: 606 case 0x20: 607 case 0x21: 608 case 0x22: 609 case 0x23: 610 case 0x24: 611 ret = 0; 612 status = POWER_SUPPLY_STATUS_NOT_CHARGING; 613 health = POWER_SUPPLY_HEALTH_OVERHEAT; 614 break; 615 case 0x30: 616 case 0x31: 617 case 0x32: 618 case 0x40: 619 ret = 0; 620 status = POWER_SUPPLY_STATUS_DISCHARGING; 621 health = POWER_SUPPLY_HEALTH_GOOD; 622 break; 623 case 0x7f: 624 default: 625 ret = 0; 626 status = POWER_SUPPLY_STATUS_NOT_CHARGING; 627 health = POWER_SUPPLY_HEALTH_DEAD; 628 break; 629 } 630 631 if (s) 632 *s = status; 633 if (h) 634 *h = health; 635 636 return ret; 637 } 638 639 static int __write_cc(struct bd71827_power *pwr, uint16_t bcap, 640 unsigned int reg, uint32_t *new) 641 { 642 int ret; 643 __be32 tmp; 644 __be16 *swap_hi = (__be16 *)&tmp; > 645 uint16_t *swap_lo = swap_hi + 1; 646 647 *swap_hi = cpu_to_be16(bcap & BD7182x_MASK_CC_CCNTD_HI); 648 *swap_lo = 0; 649 650 ret = regmap_bulk_write(pwr->regmap, reg, &tmp, sizeof(tmp)); 651 if (ret) { 652 dev_err(pwr->dev, "Failed to write coulomb counter\n"); 653 return ret; 654 } 655 if (new) 656 *new = be32_to_cpu(tmp); 657 658 return ret; 659 } 660 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org