tree: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git gpio-descriptors-regulator-fixup head: 0aaccc590e7a2f0d6f846c9e3698168e6d0c01f8 commit: 58ad90982e460e4f3439a3f25c86ee96f9dcb161 [6/10] regulator: max8973: Let core handle GPIO descriptor config: xtensa-allyesconfig (attached as .config) compiler: xtensa-linux-gcc (GCC) 8.1.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout 58ad90982e460e4f3439a3f25c86ee96f9dcb161 # save the attached .config to linux build tree GCC_VERSION=8.1.0 make.cross ARCH=xtensa Note: it may well be a FALSE warning. FWIW you are at least aware of it now. http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings All warnings (new ones prefixed by >>): drivers/regulator/max8973-regulator.c: In function 'max8973_probe': >> drivers/regulator/max8973-regulator.c:817:4: warning: 'gpiod' may be used uninitialized in this function [-Wmaybe-uninitialized] gpiod_put(gpiod); ^~~~~~~~~~~~~~~~ vim +/gpiod +817 drivers/regulator/max8973-regulator.c 624 625 static int max8973_probe(struct i2c_client *client, 626 const struct i2c_device_id *id) 627 { 628 struct max8973_regulator_platform_data *pdata; 629 struct regulator_init_data *ridata; 630 struct regulator_config config = { }; 631 struct regulator_dev *rdev; 632 struct max8973_chip *max; 633 bool pdata_from_dt = false; 634 unsigned int chip_id; 635 struct gpio_desc *gpiod; 636 enum gpiod_flags gflags; 637 int ret; 638 639 pdata = dev_get_platdata(&client->dev); 640 641 if (!pdata && client->dev.of_node) { 642 pdata = max8973_parse_dt(&client->dev); 643 pdata_from_dt = true; 644 } 645 646 if (!pdata) { 647 dev_err(&client->dev, "No Platform data"); 648 return -EIO; 649 } 650 651 if (pdata->dvs_gpio == -EPROBE_DEFER) 652 return -EPROBE_DEFER; 653 654 max = devm_kzalloc(&client->dev, sizeof(*max), GFP_KERNEL); 655 if (!max) 656 return -ENOMEM; 657 658 max->regmap = devm_regmap_init_i2c(client, &max8973_regmap_config); 659 if (IS_ERR(max->regmap)) { 660 ret = PTR_ERR(max->regmap); 661 dev_err(&client->dev, "regmap init failed, err %d\n", ret); 662 return ret; 663 } 664 665 if (client->dev.of_node) { 666 const struct of_device_id *match; 667 668 match = of_match_device(of_match_ptr(of_max8973_match_tbl), 669 &client->dev); 670 if (!match) 671 return -ENODATA; 672 max->id = (u32)((uintptr_t)match->data); 673 } else { 674 max->id = id->driver_data; 675 } 676 677 ret = regmap_read(max->regmap, MAX8973_CHIPID1, &chip_id); 678 if (ret < 0) { 679 dev_err(&client->dev, "register CHIPID1 read failed, %d", ret); 680 return ret; 681 } 682 683 dev_info(&client->dev, "CHIP-ID OTP: 0x%02x ID_M: 0x%02x\n", 684 (chip_id >> 4) & 0xF, (chip_id >> 1) & 0x7); 685 686 i2c_set_clientdata(client, max); 687 max->ops = max8973_dcdc_ops; 688 max->dev = &client->dev; 689 max->desc.name = id->name; 690 max->desc.id = 0; 691 max->desc.ops = &max->ops; 692 max->desc.type = REGULATOR_VOLTAGE; 693 max->desc.owner = THIS_MODULE; 694 max->desc.min_uV = MAX8973_MIN_VOLATGE; 695 max->desc.uV_step = MAX8973_VOLATGE_STEP; 696 max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE; 697 698 max->dvs_gpio = (pdata->dvs_gpio) ? pdata->dvs_gpio : -EINVAL; 699 max->enable_external_control = pdata->enable_ext_control; 700 max->curr_gpio_val = pdata->dvs_def_state; 701 max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state; 702 max->junction_temp_warning = pdata->junction_temp_warning; 703 704 max->lru_index[0] = max->curr_vout_reg; 705 706 if (gpio_is_valid(max->dvs_gpio)) { 707 int gpio_flags; 708 int i; 709 710 gpio_flags = (pdata->dvs_def_state) ? 711 GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; 712 ret = devm_gpio_request_one(&client->dev, max->dvs_gpio, 713 gpio_flags, "max8973-dvs"); 714 if (ret) { 715 dev_err(&client->dev, 716 "gpio_request for gpio %d failed, err = %d\n", 717 max->dvs_gpio, ret); 718 return ret; 719 } 720 721 /* 722 * Initialize the lru index with vout_reg id 723 * The index 0 will be most recently used and 724 * set with the max->curr_vout_reg */ 725 for (i = 0; i < MAX8973_MAX_VOUT_REG; ++i) 726 max->lru_index[i] = i; 727 max->lru_index[0] = max->curr_vout_reg; 728 max->lru_index[max->curr_vout_reg] = 0; 729 } else { 730 /* 731 * If there is no DVS GPIO, the VOUT register 732 * address is fixed. 733 */ 734 max->ops.set_voltage_sel = regulator_set_voltage_sel_regmap; 735 max->ops.get_voltage_sel = regulator_get_voltage_sel_regmap; 736 max->desc.vsel_reg = max->curr_vout_reg; 737 max->desc.vsel_mask = MAX8973_VOUT_MASK; 738 } 739 740 if (pdata_from_dt) 741 pdata->reg_init_data = of_get_regulator_init_data(&client->dev, 742 client->dev.of_node, &max->desc); 743 744 ridata = pdata->reg_init_data; 745 switch (max->id) { 746 case MAX8973: 747 if (!pdata->enable_ext_control) { 748 max->desc.enable_reg = MAX8973_VOUT; 749 max->desc.enable_mask = MAX8973_VOUT_ENABLE; 750 max->ops.enable = regulator_enable_regmap; 751 max->ops.disable = regulator_disable_regmap; 752 max->ops.is_enabled = regulator_is_enabled_regmap; 753 break; 754 } 755 756 if (ridata && (ridata->constraints.always_on || 757 ridata->constraints.boot_on)) 758 gflags = GPIOD_OUT_HIGH; 759 else 760 gflags = GPIOD_OUT_LOW; 761 gflags |= GPIOD_FLAGS_BIT_NONEXCLUSIVE; 762 gpiod = gpiod_get_optional(&client->dev, 763 "maxim,enable", 764 gflags); 765 if (IS_ERR(gpiod)) 766 return PTR_ERR(gpiod); 767 if (gpiod) { 768 config.ena_gpiod = gpiod; 769 max->enable_external_control = true; 770 } 771 772 break; 773 774 case MAX77621: 775 /* 776 * We do not let the core switch this regulator on/off, 777 * we just leave it on. 778 */ 779 gpiod = devm_gpiod_get_optional(&client->dev, 780 "maxim,enable", 781 GPIOD_OUT_HIGH); 782 if (IS_ERR(gpiod)) 783 return PTR_ERR(gpiod); 784 if (gpiod) 785 max->enable_external_control = true; 786 787 max->desc.enable_reg = MAX8973_VOUT; 788 max->desc.enable_mask = MAX8973_VOUT_ENABLE; 789 max->ops.enable = regulator_enable_regmap; 790 max->ops.disable = regulator_disable_regmap; 791 max->ops.is_enabled = regulator_is_enabled_regmap; 792 max->ops.set_current_limit = max8973_set_current_limit; 793 max->ops.get_current_limit = max8973_get_current_limit; 794 break; 795 default: 796 break; 797 } 798 799 ret = max8973_init_dcdc(max, pdata); 800 if (ret < 0) { 801 if (gpiod) 802 gpiod_put(gpiod); 803 dev_err(max->dev, "Max8973 Init failed, err = %d\n", ret); 804 return ret; 805 } 806 807 config.dev = &client->dev; 808 config.init_data = pdata->reg_init_data; 809 config.driver_data = max; 810 config.of_node = client->dev.of_node; 811 config.regmap = max->regmap; 812 813 /* Register the regulators */ 814 rdev = devm_regulator_register(&client->dev, &max->desc, &config); 815 if (IS_ERR(rdev)) { 816 if (gpiod) > 817 gpiod_put(gpiod); 818 ret = PTR_ERR(rdev); 819 dev_err(max->dev, "regulator register failed, err %d\n", ret); 820 return ret; 821 } 822 823 max8973_thermal_init(max); 824 return 0; 825 } 826 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
Attachment:
.config.gz
Description: application/gzip