Hi Ansuel, url: https://github.com/0day-ci/linux/commits/Ansuel-Smith/drivers-thermal-tsens-Add-VER_0-tsens-version/20210325-064422 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next config: riscv-randconfig-m031-20210330 (attached as .config) compiler: riscv32-linux-gcc (GCC) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@xxxxxxxxx> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> New smatch warnings: drivers/thermal/qcom/tsens.c:792 init_common() warn: passing zero to 'PTR_ERR' vim +/PTR_ERR +792 drivers/thermal/qcom/tsens.c a7ff82976122eb Amit Kucheria 2020-04-29 741 int __init init_common(struct tsens_priv *priv) a7ff82976122eb Amit Kucheria 2020-04-29 742 { a7ff82976122eb Amit Kucheria 2020-04-29 743 void __iomem *tm_base, *srot_base; a7ff82976122eb Amit Kucheria 2020-04-29 744 struct device *dev = priv->dev; a7ff82976122eb Amit Kucheria 2020-04-29 745 u32 ver_minor; a7ff82976122eb Amit Kucheria 2020-04-29 746 struct resource *res; a7ff82976122eb Amit Kucheria 2020-04-29 747 u32 enabled; a7ff82976122eb Amit Kucheria 2020-04-29 748 int ret, i, j; a7ff82976122eb Amit Kucheria 2020-04-29 749 struct platform_device *op = of_find_device_by_node(priv->dev->of_node); a7ff82976122eb Amit Kucheria 2020-04-29 750 a7ff82976122eb Amit Kucheria 2020-04-29 751 if (!op) a7ff82976122eb Amit Kucheria 2020-04-29 752 return -EINVAL; a7ff82976122eb Amit Kucheria 2020-04-29 753 a7ff82976122eb Amit Kucheria 2020-04-29 754 if (op->num_resources > 1) { a7ff82976122eb Amit Kucheria 2020-04-29 755 /* DT with separate SROT and TM address space */ a7ff82976122eb Amit Kucheria 2020-04-29 756 priv->tm_offset = 0; a7ff82976122eb Amit Kucheria 2020-04-29 757 res = platform_get_resource(op, IORESOURCE_MEM, 1); a7ff82976122eb Amit Kucheria 2020-04-29 758 srot_base = devm_ioremap_resource(dev, res); a7ff82976122eb Amit Kucheria 2020-04-29 759 if (IS_ERR(srot_base)) { a7ff82976122eb Amit Kucheria 2020-04-29 760 ret = PTR_ERR(srot_base); a7ff82976122eb Amit Kucheria 2020-04-29 761 goto err_put_device; a7ff82976122eb Amit Kucheria 2020-04-29 762 } a7ff82976122eb Amit Kucheria 2020-04-29 763 a7ff82976122eb Amit Kucheria 2020-04-29 764 priv->srot_map = devm_regmap_init_mmio(dev, srot_base, a7ff82976122eb Amit Kucheria 2020-04-29 765 &tsens_srot_config); a7ff82976122eb Amit Kucheria 2020-04-29 766 if (IS_ERR(priv->srot_map)) { a7ff82976122eb Amit Kucheria 2020-04-29 767 ret = PTR_ERR(priv->srot_map); a7ff82976122eb Amit Kucheria 2020-04-29 768 goto err_put_device; a7ff82976122eb Amit Kucheria 2020-04-29 769 } a7ff82976122eb Amit Kucheria 2020-04-29 770 } else { a7ff82976122eb Amit Kucheria 2020-04-29 771 /* old DTs where SROT and TM were in a contiguous 2K block */ a7ff82976122eb Amit Kucheria 2020-04-29 772 priv->tm_offset = 0x1000; a7ff82976122eb Amit Kucheria 2020-04-29 773 } a7ff82976122eb Amit Kucheria 2020-04-29 774 fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 775 if (tsens_version(priv) >= VER_0_1) { a7ff82976122eb Amit Kucheria 2020-04-29 776 res = platform_get_resource(op, IORESOURCE_MEM, 0); a7ff82976122eb Amit Kucheria 2020-04-29 777 tm_base = devm_ioremap_resource(dev, res); a7ff82976122eb Amit Kucheria 2020-04-29 778 if (IS_ERR(tm_base)) { a7ff82976122eb Amit Kucheria 2020-04-29 779 ret = PTR_ERR(tm_base); a7ff82976122eb Amit Kucheria 2020-04-29 780 goto err_put_device; a7ff82976122eb Amit Kucheria 2020-04-29 781 } a7ff82976122eb Amit Kucheria 2020-04-29 782 a7ff82976122eb Amit Kucheria 2020-04-29 783 priv->tm_map = devm_regmap_init_mmio(dev, tm_base, &tsens_config); fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 784 } else { /* VER_0 share the same gcc regs using a syscon */ fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 785 struct device *parent = priv->dev->parent; fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 786 fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 787 if (parent) fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 788 priv->tm_map = syscon_node_to_regmap(parent->of_node); fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 789 } fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 790 fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 791 if (IS_ERR_OR_NULL(priv->tm_map)) { This used to be an IS_ERR() check, but now if "priv->tm_map" is NULL we short cut the rest of the function and return success. It's hard to tell without more context if that's intentional or if it should be something like: if (IS_ERR_OR_NULL(priv->tm_map)) { if (!priv->tm_map) ret = -ENODEV; else ret = PTR_ERR(priv->tm_map); goto err_put_device; } a7ff82976122eb Amit Kucheria 2020-04-29 @792 ret = PTR_ERR(priv->tm_map); a7ff82976122eb Amit Kucheria 2020-04-29 793 goto err_put_device; a7ff82976122eb Amit Kucheria 2020-04-29 794 } a7ff82976122eb Amit Kucheria 2020-04-29 795 fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 796 /* VER_0 have only tm_map */ fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 797 if (!priv->srot_map) fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 798 priv->srot_map = priv->tm_map; fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 799 a7ff82976122eb Amit Kucheria 2020-04-29 800 if (tsens_version(priv) > VER_0_1) { a7ff82976122eb Amit Kucheria 2020-04-29 801 for (i = VER_MAJOR; i <= VER_STEP; i++) { a7ff82976122eb Amit Kucheria 2020-04-29 802 priv->rf[i] = devm_regmap_field_alloc(dev, priv->srot_map, a7ff82976122eb Amit Kucheria 2020-04-29 803 priv->fields[i]); a7ff82976122eb Amit Kucheria 2020-04-29 804 if (IS_ERR(priv->rf[i])) a7ff82976122eb Amit Kucheria 2020-04-29 805 return PTR_ERR(priv->rf[i]); a7ff82976122eb Amit Kucheria 2020-04-29 806 } a7ff82976122eb Amit Kucheria 2020-04-29 807 ret = regmap_field_read(priv->rf[VER_MINOR], &ver_minor); a7ff82976122eb Amit Kucheria 2020-04-29 808 if (ret) a7ff82976122eb Amit Kucheria 2020-04-29 809 goto err_put_device; a7ff82976122eb Amit Kucheria 2020-04-29 810 } a7ff82976122eb Amit Kucheria 2020-04-29 811 a7ff82976122eb Amit Kucheria 2020-04-29 812 priv->rf[TSENS_EN] = devm_regmap_field_alloc(dev, priv->srot_map, a7ff82976122eb Amit Kucheria 2020-04-29 813 priv->fields[TSENS_EN]); a7ff82976122eb Amit Kucheria 2020-04-29 814 if (IS_ERR(priv->rf[TSENS_EN])) { a7ff82976122eb Amit Kucheria 2020-04-29 815 ret = PTR_ERR(priv->rf[TSENS_EN]); a7ff82976122eb Amit Kucheria 2020-04-29 816 goto err_put_device; a7ff82976122eb Amit Kucheria 2020-04-29 817 } fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 818 /* in VER_0 TSENS need to be explicitly enabled */ fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 819 if (tsens_version(priv) == VER_0) fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 820 regmap_field_write(priv->rf[TSENS_EN], 1); fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 821 a7ff82976122eb Amit Kucheria 2020-04-29 822 ret = regmap_field_read(priv->rf[TSENS_EN], &enabled); a7ff82976122eb Amit Kucheria 2020-04-29 823 if (ret) a7ff82976122eb Amit Kucheria 2020-04-29 824 goto err_put_device; a7ff82976122eb Amit Kucheria 2020-04-29 825 if (!enabled) { a7ff82976122eb Amit Kucheria 2020-04-29 826 dev_err(dev, "%s: device not enabled\n", __func__); a7ff82976122eb Amit Kucheria 2020-04-29 827 ret = -ENODEV; a7ff82976122eb Amit Kucheria 2020-04-29 828 goto err_put_device; a7ff82976122eb Amit Kucheria 2020-04-29 829 } a7ff82976122eb Amit Kucheria 2020-04-29 830 a7ff82976122eb Amit Kucheria 2020-04-29 831 priv->rf[SENSOR_EN] = devm_regmap_field_alloc(dev, priv->srot_map, a7ff82976122eb Amit Kucheria 2020-04-29 832 priv->fields[SENSOR_EN]); a7ff82976122eb Amit Kucheria 2020-04-29 833 if (IS_ERR(priv->rf[SENSOR_EN])) { a7ff82976122eb Amit Kucheria 2020-04-29 834 ret = PTR_ERR(priv->rf[SENSOR_EN]); a7ff82976122eb Amit Kucheria 2020-04-29 835 goto err_put_device; a7ff82976122eb Amit Kucheria 2020-04-29 836 } a7ff82976122eb Amit Kucheria 2020-04-29 837 priv->rf[INT_EN] = devm_regmap_field_alloc(dev, priv->tm_map, a7ff82976122eb Amit Kucheria 2020-04-29 838 priv->fields[INT_EN]); a7ff82976122eb Amit Kucheria 2020-04-29 839 if (IS_ERR(priv->rf[INT_EN])) { a7ff82976122eb Amit Kucheria 2020-04-29 840 ret = PTR_ERR(priv->rf[INT_EN]); a7ff82976122eb Amit Kucheria 2020-04-29 841 goto err_put_device; a7ff82976122eb Amit Kucheria 2020-04-29 842 } a7ff82976122eb Amit Kucheria 2020-04-29 843 fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 844 priv->rf[TSENS_SW_RST] = fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 845 devm_regmap_field_alloc(dev, priv->srot_map, priv->fields[TSENS_SW_RST]); fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 846 if (IS_ERR(priv->rf[TSENS_SW_RST])) { fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 847 ret = PTR_ERR(priv->rf[TSENS_SW_RST]); fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 848 goto err_put_device; fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 849 } fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 850 fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 851 priv->rf[TRDY] = devm_regmap_field_alloc(dev, priv->tm_map, priv->fields[TRDY]); fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 852 if (IS_ERR(priv->rf[TRDY])) { fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 853 ret = PTR_ERR(priv->rf[TRDY]); fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 854 goto err_put_device; fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 855 } fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 856 a7ff82976122eb Amit Kucheria 2020-04-29 857 /* This loop might need changes if enum regfield_ids is reordered */ a7ff82976122eb Amit Kucheria 2020-04-29 858 for (j = LAST_TEMP_0; j <= UP_THRESH_15; j += 16) { a7ff82976122eb Amit Kucheria 2020-04-29 859 for (i = 0; i < priv->feat->max_sensors; i++) { a7ff82976122eb Amit Kucheria 2020-04-29 860 int idx = j + i; a7ff82976122eb Amit Kucheria 2020-04-29 861 a7ff82976122eb Amit Kucheria 2020-04-29 862 priv->rf[idx] = devm_regmap_field_alloc(dev, a7ff82976122eb Amit Kucheria 2020-04-29 863 priv->tm_map, a7ff82976122eb Amit Kucheria 2020-04-29 864 priv->fields[idx]); a7ff82976122eb Amit Kucheria 2020-04-29 865 if (IS_ERR(priv->rf[idx])) { a7ff82976122eb Amit Kucheria 2020-04-29 866 ret = PTR_ERR(priv->rf[idx]); a7ff82976122eb Amit Kucheria 2020-04-29 867 goto err_put_device; a7ff82976122eb Amit Kucheria 2020-04-29 868 } a7ff82976122eb Amit Kucheria 2020-04-29 869 } a7ff82976122eb Amit Kucheria 2020-04-29 870 } a7ff82976122eb Amit Kucheria 2020-04-29 871 fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 872 if (priv->feat->crit_int || tsens_version(priv) < VER_0_1) { a7ff82976122eb Amit Kucheria 2020-04-29 873 /* Loop might need changes if enum regfield_ids is reordered */ a7ff82976122eb Amit Kucheria 2020-04-29 874 for (j = CRITICAL_STATUS_0; j <= CRIT_THRESH_15; j += 16) { a7ff82976122eb Amit Kucheria 2020-04-29 875 for (i = 0; i < priv->feat->max_sensors; i++) { a7ff82976122eb Amit Kucheria 2020-04-29 876 int idx = j + i; a7ff82976122eb Amit Kucheria 2020-04-29 877 a7ff82976122eb Amit Kucheria 2020-04-29 878 priv->rf[idx] = a7ff82976122eb Amit Kucheria 2020-04-29 879 devm_regmap_field_alloc(dev, a7ff82976122eb Amit Kucheria 2020-04-29 880 priv->tm_map, a7ff82976122eb Amit Kucheria 2020-04-29 881 priv->fields[idx]); a7ff82976122eb Amit Kucheria 2020-04-29 882 if (IS_ERR(priv->rf[idx])) { a7ff82976122eb Amit Kucheria 2020-04-29 883 ret = PTR_ERR(priv->rf[idx]); a7ff82976122eb Amit Kucheria 2020-04-29 884 goto err_put_device; a7ff82976122eb Amit Kucheria 2020-04-29 885 } a7ff82976122eb Amit Kucheria 2020-04-29 886 } a7ff82976122eb Amit Kucheria 2020-04-29 887 } a7ff82976122eb Amit Kucheria 2020-04-29 888 } a7ff82976122eb Amit Kucheria 2020-04-29 889 a7ff82976122eb Amit Kucheria 2020-04-29 890 if (tsens_version(priv) > VER_1_X && ver_minor > 2) { a7ff82976122eb Amit Kucheria 2020-04-29 891 /* Watchdog is present only on v2.3+ */ a7ff82976122eb Amit Kucheria 2020-04-29 892 priv->feat->has_watchdog = 1; a7ff82976122eb Amit Kucheria 2020-04-29 893 for (i = WDOG_BARK_STATUS; i <= CC_MON_MASK; i++) { a7ff82976122eb Amit Kucheria 2020-04-29 894 priv->rf[i] = devm_regmap_field_alloc(dev, priv->tm_map, a7ff82976122eb Amit Kucheria 2020-04-29 895 priv->fields[i]); a7ff82976122eb Amit Kucheria 2020-04-29 896 if (IS_ERR(priv->rf[i])) { a7ff82976122eb Amit Kucheria 2020-04-29 897 ret = PTR_ERR(priv->rf[i]); a7ff82976122eb Amit Kucheria 2020-04-29 898 goto err_put_device; a7ff82976122eb Amit Kucheria 2020-04-29 899 } a7ff82976122eb Amit Kucheria 2020-04-29 900 } a7ff82976122eb Amit Kucheria 2020-04-29 901 /* a7ff82976122eb Amit Kucheria 2020-04-29 902 * Watchdog is already enabled, unmask the bark. a7ff82976122eb Amit Kucheria 2020-04-29 903 * Disable cycle completion monitoring a7ff82976122eb Amit Kucheria 2020-04-29 904 */ a7ff82976122eb Amit Kucheria 2020-04-29 905 regmap_field_write(priv->rf[WDOG_BARK_MASK], 0); a7ff82976122eb Amit Kucheria 2020-04-29 906 regmap_field_write(priv->rf[CC_MON_MASK], 1); a7ff82976122eb Amit Kucheria 2020-04-29 907 } a7ff82976122eb Amit Kucheria 2020-04-29 908 a7ff82976122eb Amit Kucheria 2020-04-29 909 spin_lock_init(&priv->ul_lock); fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 910 fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 911 /* VER_0 interrupt doesn't need to be enabled */ fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 912 if (tsens_version(priv) >= VER_0_1) a7ff82976122eb Amit Kucheria 2020-04-29 913 tsens_enable_irq(priv); fea5c5e6f2e2a0 Ansuel Smith 2021-03-24 914 a7ff82976122eb Amit Kucheria 2020-04-29 915 tsens_debug_init(op); a7ff82976122eb Amit Kucheria 2020-04-29 916 a7ff82976122eb Amit Kucheria 2020-04-29 917 err_put_device: a7ff82976122eb Amit Kucheria 2020-04-29 918 put_device(&op->dev); a7ff82976122eb Amit Kucheria 2020-04-29 919 return ret; a7ff82976122eb Amit Kucheria 2020-04-29 920 } --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip
_______________________________________________ kbuild mailing list -- kbuild@xxxxxxxxxxxx To unsubscribe send an email to kbuild-leave@xxxxxxxxxxxx