[bug report] pinctrl: baytrail: consolidate common mask operation

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

 



Hello Raag Jadav,

The patch 4cfff5b7af8b: "pinctrl: baytrail: consolidate common mask
operation" from Aug 8, 2023 (linux-next), leads to the following
Smatch static checker warning:

	drivers/pinctrl/intel/pinctrl-baytrail.c:1023 byt_pin_config_set()
	error: uninitialized symbol 'db_pulse'.

drivers/pinctrl/intel/pinctrl-baytrail.c
    918 static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
    919                               unsigned int offset,
    920                               unsigned long *configs,
    921                               unsigned int num_configs)
    922 {
    923         struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctl_dev);
    924         unsigned int param, arg;
    925         void __iomem *conf_reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG);
    926         void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG);
    927         void __iomem *db_reg = byt_gpio_reg(vg, offset, BYT_DEBOUNCE_REG);
    928         u32 conf, val, db_pulse, debounce;
    929         unsigned long flags;
    930         int i, ret = 0;
    931 
    932         raw_spin_lock_irqsave(&byt_lock, flags);
    933 
    934         conf = readl(conf_reg);
    935         val = readl(val_reg);
    936 
    937         for (i = 0; i < num_configs; i++) {
    938                 param = pinconf_to_config_param(configs[i]);
    939                 arg = pinconf_to_config_argument(configs[i]);
    940 
    941                 switch (param) {
    942                 case PIN_CONFIG_BIAS_DISABLE:
    943                         conf &= ~BYT_PULL_ASSIGN_MASK;
    944                         break;
    945                 case PIN_CONFIG_BIAS_PULL_DOWN:
    946                         /* Set default strength value in case none is given */
    947                         if (arg == 1)
    948                                 arg = 2000;
    949 
    950                         /*
    951                          * Pull assignment is only applicable in input mode. If
    952                          * chip is not in input mode, set it and warn about it.
    953                          */
    954                         if (val & BYT_INPUT_EN) {
    955                                 val &= ~BYT_INPUT_EN;
    956                                 writel(val, val_reg);
    957                                 dev_warn(vg->dev, "Pin %i: forcibly set to input mode\n", offset);
    958                         }
    959 
    960                         conf &= ~BYT_PULL_ASSIGN_MASK;
    961                         conf |= BYT_PULL_ASSIGN_DOWN;
    962                         ret = byt_set_pull_strength(&conf, arg);
    963 
    964                         break;
    965                 case PIN_CONFIG_BIAS_PULL_UP:
    966                         /* Set default strength value in case none is given */
    967                         if (arg == 1)
    968                                 arg = 2000;
    969 
    970                         /*
    971                          * Pull assignment is only applicable in input mode. If
    972                          * chip is not in input mode, set it and warn about it.
    973                          */
    974                         if (val & BYT_INPUT_EN) {
    975                                 val &= ~BYT_INPUT_EN;
    976                                 writel(val, val_reg);
    977                                 dev_warn(vg->dev, "Pin %i: forcibly set to input mode\n", offset);
    978                         }
    979 
    980                         conf &= ~BYT_PULL_ASSIGN_MASK;
    981                         conf |= BYT_PULL_ASSIGN_UP;
    982                         ret = byt_set_pull_strength(&conf, arg);
    983 
    984                         break;
    985                 case PIN_CONFIG_INPUT_DEBOUNCE:
    986                         if (arg)
    987                                 conf |= BYT_DEBOUNCE_EN;
    988                         else
    989                                 conf &= ~BYT_DEBOUNCE_EN;
    990 
    991                         switch (arg) {
    992                         case 375:
    993                                 db_pulse = BYT_DEBOUNCE_PULSE_375US;
    994                                 break;
    995                         case 750:
    996                                 db_pulse = BYT_DEBOUNCE_PULSE_750US;
    997                                 break;
    998                         case 1500:
    999                                 db_pulse = BYT_DEBOUNCE_PULSE_1500US;
    1000                                 break;
    1001                         case 3000:
    1002                                 db_pulse = BYT_DEBOUNCE_PULSE_3MS;
    1003                                 break;
    1004                         case 6000:
    1005                                 db_pulse = BYT_DEBOUNCE_PULSE_6MS;
    1006                                 break;
    1007                         case 12000:
    1008                                 db_pulse = BYT_DEBOUNCE_PULSE_12MS;
    1009                                 break;
    1010                         case 24000:
    1011                                 db_pulse = BYT_DEBOUNCE_PULSE_24MS;
    1012                                 break;
    1013                         default:
    1014                                 if (arg)
    1015                                         ret = -EINVAL;

db_pulse is uninitialized if arg is zero.

    1016                                 break;
    1017                         }
    1018 
    1019                         if (ret)
    1020                                 break;
    1021 
    1022                         debounce = readl(db_reg);
--> 1023                         debounce = (debounce & ~BYT_DEBOUNCE_PULSE_MASK) | db_pulse;
    1024                         writel(debounce, db_reg);
    1025 
    1026                         break;
    1027                 default:
    1028                         ret = -ENOTSUPP;
    1029                 }
    1030 
    1031                 if (ret)
    1032                         break;
    1033         }
    1034 
    1035         if (!ret)
    1036                 writel(conf, conf_reg);
    1037 
    1038         raw_spin_unlock_irqrestore(&byt_lock, flags);
    1039 
    1040         return ret;
    1041 }

regards,
dan carpenter



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux