[gpio:devel 48/52] drivers/gpio/gpio-amd-fch.c:45:27: sparse: warning: incorrect type in return expression (different address spaces)

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

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git devel
head:   cc8be4820bb5db727abd27c7e9caaa107f05c817
commit: e09d168f13f0d63df7fe095d52be04c16cbe1cef [48/52] gpio: AMD G-Series PCH gpio driver
reproduce:
        # apt-get install sparse
        git checkout e09d168f13f0d63df7fe095d52be04c16cbe1cef
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

All warnings (new ones prefixed by >>):

>> drivers/gpio/gpio-amd-fch.c:45:27: sparse: warning: incorrect type in return expression (different address spaces)
   drivers/gpio/gpio-amd-fch.c:45:27: sparse:    expected void *
   drivers/gpio/gpio-amd-fch.c:45:27: sparse:    got void [noderef] <asn:2> *
>> drivers/gpio/gpio-amd-fch.c:56:9: sparse: warning: incorrect type in argument 1 (different address spaces)
   drivers/gpio/gpio-amd-fch.c:56:9: sparse:    expected void const volatile [noderef] <asn:2> *addr
   drivers/gpio/gpio-amd-fch.c:56:9: sparse:    got void *ptr
   drivers/gpio/gpio-amd-fch.c:56:9: sparse: warning: incorrect type in argument 2 (different address spaces)
   drivers/gpio/gpio-amd-fch.c:56:9: sparse:    expected void volatile [noderef] <asn:2> *addr
   drivers/gpio/gpio-amd-fch.c:56:9: sparse:    got void *ptr
   drivers/gpio/gpio-amd-fch.c:70:9: sparse: warning: incorrect type in argument 1 (different address spaces)
   drivers/gpio/gpio-amd-fch.c:70:9: sparse:    expected void const volatile [noderef] <asn:2> *addr
   drivers/gpio/gpio-amd-fch.c:70:9: sparse:    got void *ptr
   drivers/gpio/gpio-amd-fch.c:70:9: sparse: warning: incorrect type in argument 2 (different address spaces)
   drivers/gpio/gpio-amd-fch.c:70:9: sparse:    expected void volatile [noderef] <asn:2> *addr
   drivers/gpio/gpio-amd-fch.c:70:9: sparse:    got void *ptr
   drivers/gpio/gpio-amd-fch.c:84:16: sparse: warning: incorrect type in argument 1 (different address spaces)
   drivers/gpio/gpio-amd-fch.c:84:16: sparse:    expected void const volatile [noderef] <asn:2> *addr
   drivers/gpio/gpio-amd-fch.c:84:16: sparse:    got void *ptr
   drivers/gpio/gpio-amd-fch.c:100:16: sparse: warning: incorrect type in argument 1 (different address spaces)
   drivers/gpio/gpio-amd-fch.c:100:16: sparse:    expected void const volatile [noderef] <asn:2> *addr
   drivers/gpio/gpio-amd-fch.c:100:16: sparse:    got void *ptr
   drivers/gpio/gpio-amd-fch.c:105:9: sparse: warning: incorrect type in argument 2 (different address spaces)
   drivers/gpio/gpio-amd-fch.c:105:9: sparse:    expected void volatile [noderef] <asn:2> *addr
   drivers/gpio/gpio-amd-fch.c:105:9: sparse:    got void *ptr
   drivers/gpio/gpio-amd-fch.c:119:16: sparse: warning: incorrect type in argument 1 (different address spaces)
   drivers/gpio/gpio-amd-fch.c:119:16: sparse:    expected void const volatile [noderef] <asn:2> *addr
   drivers/gpio/gpio-amd-fch.c:119:16: sparse:    got void *ptr
>> drivers/gpio/gpio-amd-fch.c:164:57: sparse: warning: incorrect type in argument 2 (different modifiers)
   drivers/gpio/gpio-amd-fch.c:164:57: sparse:    expected struct resource *res
   drivers/gpio/gpio-amd-fch.c:164:57: sparse:    got struct resource const *
--
   drivers/gpio/gpio-amd-fch.c: In function 'amd_fch_gpio_probe':
>> drivers/gpio/gpio-amd-fch.c:164:49: warning: passing argument 2 of 'devm_ioremap_resource' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     priv->base = devm_ioremap_resource(&pdev->dev, &amd_fch_gpio_iores);
                                                    ^~~~~~~~~~~~~~~~~~~
   In file included from include/linux/platform_device.h:14,
                    from drivers/gpio/gpio-amd-fch.c:15:
   include/linux/device.h:708:15: note: expected 'struct resource *' but argument is of type 'const struct resource *'
    void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
                  ^~~~~~~~~~~~~~~~~~~~~

sparse warnings: (new ones prefixed by >>)

   drivers/gpio/gpio-amd-fch.c:45:27: sparse: warning: incorrect type in return expression (different address spaces)
>> drivers/gpio/gpio-amd-fch.c:45:27: sparse:    expected void *
>> drivers/gpio/gpio-amd-fch.c:45:27: sparse:    got void [noderef] <asn:2> *
   drivers/gpio/gpio-amd-fch.c:56:9: sparse: warning: incorrect type in argument 1 (different address spaces)
>> drivers/gpio/gpio-amd-fch.c:56:9: sparse:    expected void const volatile [noderef] <asn:2> *addr
>> drivers/gpio/gpio-amd-fch.c:56:9: sparse:    got void *ptr
   drivers/gpio/gpio-amd-fch.c:56:9: sparse: warning: incorrect type in argument 2 (different address spaces)
>> drivers/gpio/gpio-amd-fch.c:56:9: sparse:    expected void volatile [noderef] <asn:2> *addr
>> drivers/gpio/gpio-amd-fch.c:56:9: sparse:    got void *ptr
   drivers/gpio/gpio-amd-fch.c:70:9: sparse: warning: incorrect type in argument 1 (different address spaces)
   drivers/gpio/gpio-amd-fch.c:70:9: sparse:    expected void const volatile [noderef] <asn:2> *addr
   drivers/gpio/gpio-amd-fch.c:70:9: sparse:    got void *ptr
   drivers/gpio/gpio-amd-fch.c:70:9: sparse: warning: incorrect type in argument 2 (different address spaces)
   drivers/gpio/gpio-amd-fch.c:70:9: sparse:    expected void volatile [noderef] <asn:2> *addr
   drivers/gpio/gpio-amd-fch.c:70:9: sparse:    got void *ptr
   drivers/gpio/gpio-amd-fch.c:84:16: sparse: warning: incorrect type in argument 1 (different address spaces)
   drivers/gpio/gpio-amd-fch.c:84:16: sparse:    expected void const volatile [noderef] <asn:2> *addr
   drivers/gpio/gpio-amd-fch.c:84:16: sparse:    got void *ptr
   drivers/gpio/gpio-amd-fch.c:100:16: sparse: warning: incorrect type in argument 1 (different address spaces)
   drivers/gpio/gpio-amd-fch.c:100:16: sparse:    expected void const volatile [noderef] <asn:2> *addr
   drivers/gpio/gpio-amd-fch.c:100:16: sparse:    got void *ptr
   drivers/gpio/gpio-amd-fch.c:105:9: sparse: warning: incorrect type in argument 2 (different address spaces)
   drivers/gpio/gpio-amd-fch.c:105:9: sparse:    expected void volatile [noderef] <asn:2> *addr
   drivers/gpio/gpio-amd-fch.c:105:9: sparse:    got void *ptr
   drivers/gpio/gpio-amd-fch.c:119:16: sparse: warning: incorrect type in argument 1 (different address spaces)
   drivers/gpio/gpio-amd-fch.c:119:16: sparse:    expected void const volatile [noderef] <asn:2> *addr
   drivers/gpio/gpio-amd-fch.c:119:16: sparse:    got void *ptr
   drivers/gpio/gpio-amd-fch.c:164:57: sparse: warning: incorrect type in argument 2 (different modifiers)
>> drivers/gpio/gpio-amd-fch.c:164:57: sparse:    expected struct resource *res
>> drivers/gpio/gpio-amd-fch.c:164:57: sparse:    got struct resource const *

vim +45 drivers/gpio/gpio-amd-fch.c

    41	
    42	static void *amd_fch_gpio_addr(struct amd_fch_gpio_priv *priv,
    43				       unsigned int gpio)
    44	{
  > 45		return priv->base + priv->pdata->gpio_reg[gpio]*sizeof(u32);
    46	}
    47	
    48	static int amd_fch_gpio_direction_input(struct gpio_chip *gc,
    49						unsigned int offset)
    50	{
    51		unsigned long flags;
    52		struct amd_fch_gpio_priv *priv = gpiochip_get_data(gc);
    53		void *ptr = amd_fch_gpio_addr(priv, offset);
    54	
    55		spin_lock_irqsave(&priv->lock, flags);
  > 56		writel_relaxed(readl_relaxed(ptr) & ~AMD_FCH_GPIO_FLAG_DIRECTION, ptr);
    57		spin_unlock_irqrestore(&priv->lock, flags);
    58	
    59		return 0;
    60	}
    61	
    62	static int amd_fch_gpio_direction_output(struct gpio_chip *gc,
    63						 unsigned int gpio, int value)
    64	{
    65		unsigned long flags;
    66		struct amd_fch_gpio_priv *priv = gpiochip_get_data(gc);
    67		void *ptr = amd_fch_gpio_addr(priv, gpio);
    68	
    69		spin_lock_irqsave(&priv->lock, flags);
    70		writel_relaxed(readl_relaxed(ptr) | AMD_FCH_GPIO_FLAG_DIRECTION, ptr);
    71		spin_unlock_irqrestore(&priv->lock, flags);
    72	
    73		return 0;
    74	}
    75	
    76	static int amd_fch_gpio_get_direction(struct gpio_chip *gc, unsigned int gpio)
    77	{
    78		int ret;
    79		unsigned long flags;
    80		struct amd_fch_gpio_priv *priv = gpiochip_get_data(gc);
    81		void *ptr = amd_fch_gpio_addr(priv, gpio);
    82	
    83		spin_lock_irqsave(&priv->lock, flags);
    84		ret = (readl_relaxed(ptr) & AMD_FCH_GPIO_FLAG_DIRECTION);
    85		spin_unlock_irqrestore(&priv->lock, flags);
    86	
    87		return ret;
    88	}
    89	
    90	static void amd_fch_gpio_set(struct gpio_chip *gc,
    91				     unsigned int gpio, int value)
    92	{
    93		unsigned long flags;
    94		struct amd_fch_gpio_priv *priv = gpiochip_get_data(gc);
    95		void *ptr = amd_fch_gpio_addr(priv, gpio);
    96		u32 mask;
    97	
    98		spin_lock_irqsave(&priv->lock, flags);
    99	
 > 100		mask = readl_relaxed(ptr);
   101		if (value)
   102			mask |= AMD_FCH_GPIO_FLAG_WRITE;
   103		else
   104			mask &= ~AMD_FCH_GPIO_FLAG_WRITE;
   105		writel_relaxed(mask, ptr);
   106	
   107		spin_unlock_irqrestore(&priv->lock, flags);
   108	}
   109	
   110	static int amd_fch_gpio_get(struct gpio_chip *gc,
   111				    unsigned int offset)
   112	{
   113		unsigned long flags;
   114		int ret;
   115		struct amd_fch_gpio_priv *priv = gpiochip_get_data(gc);
   116		void *ptr = amd_fch_gpio_addr(priv, offset);
   117	
   118		spin_lock_irqsave(&priv->lock, flags);
   119		ret = (readl_relaxed(ptr) & AMD_FCH_GPIO_FLAG_READ);
   120		spin_unlock_irqrestore(&priv->lock, flags);
   121	
   122		return ret;
   123	}
   124	
   125	static int amd_fch_gpio_request(struct gpio_chip *chip,
   126					unsigned int gpio_pin)
   127	{
   128		return 0;
   129	}
   130	
   131	static int amd_fch_gpio_probe(struct platform_device *pdev)
   132	{
   133		struct amd_fch_gpio_priv *priv;
   134		struct amd_fch_gpio_pdata *pdata;
   135	
   136		pdata = dev_get_platdata(&pdev->dev);
   137		if (!pdata) {
   138			dev_err(&pdev->dev, "no platform_data\n");
   139			return -ENOENT;
   140		}
   141	
   142		priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
   143		if (!priv)
   144			return -ENOMEM;
   145	
   146		priv->pdata	= pdata;
   147		priv->pdev	= pdev;
   148	
   149		priv->gc.owner			= THIS_MODULE;
   150		priv->gc.parent			= &pdev->dev;
   151		priv->gc.label			= dev_name(&pdev->dev);
   152		priv->gc.ngpio			= priv->pdata->gpio_num;
   153		priv->gc.names			= priv->pdata->gpio_names;
   154		priv->gc.base			= -1;
   155		priv->gc.request		= amd_fch_gpio_request;
   156		priv->gc.direction_input	= amd_fch_gpio_direction_input;
   157		priv->gc.direction_output	= amd_fch_gpio_direction_output;
   158		priv->gc.get_direction		= amd_fch_gpio_get_direction;
   159		priv->gc.get			= amd_fch_gpio_get;
   160		priv->gc.set			= amd_fch_gpio_set;
   161	
   162		spin_lock_init(&priv->lock);
   163	
 > 164		priv->base = devm_ioremap_resource(&pdev->dev, &amd_fch_gpio_iores);
   165		if (IS_ERR(priv->base))
   166			return PTR_ERR(priv->base);
   167	
   168		platform_set_drvdata(pdev, priv);
   169	
   170		return devm_gpiochip_add_data(&pdev->dev, &priv->gc, priv);
   171	}
   172	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[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