All of lore.kernel.org
 help / color / mirror / Atom feed
* [hwmon:hwmon-next 30/32] drivers/hwmon/sch5627.c:439:79: sparse: sparse: Using plain integer as NULL pointer
@ 2021-04-14  2:13 ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-04-14  2:13 UTC (permalink / raw)
  To: Armin Wolf; +Cc: kbuild-all, linux-hwmon, Guenter Roeck, Hans de Goede

[-- Attachment #1: Type: text/plain, Size: 5153 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
head:   56940c97f6e59864a807cc19db7d6fd120bff340
commit: 4564645d213f1101f5afaff6c9cf9ec2620234d4 [30/32] hwmon: (sch5627) Convert to hwmon_device_register_with_info()
config: i386-randconfig-s002-20210413 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-280-g2cd6d34e-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git/commit/?id=4564645d213f1101f5afaff6c9cf9ec2620234d4
        git remote add hwmon https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git
        git fetch --no-tags hwmon hwmon-next
        git checkout 4564645d213f1101f5afaff6c9cf9ec2620234d4
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
>> drivers/hwmon/sch5627.c:439:79: sparse: sparse: Using plain integer as NULL pointer

vim +439 drivers/hwmon/sch5627.c

   337	
   338	static int sch5627_probe(struct platform_device *pdev)
   339	{
   340		struct sch5627_data *data;
   341		int err, build_code, build_id, hwmon_rev, val;
   342	
   343		data = devm_kzalloc(&pdev->dev, sizeof(struct sch5627_data),
   344				    GFP_KERNEL);
   345		if (!data)
   346			return -ENOMEM;
   347	
   348		data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start;
   349		mutex_init(&data->update_lock);
   350		platform_set_drvdata(pdev, data);
   351	
   352		val = sch56xx_read_virtual_reg(data->addr, SCH5627_REG_HWMON_ID);
   353		if (val < 0) {
   354			err = val;
   355			goto error;
   356		}
   357		if (val != SCH5627_HWMON_ID) {
   358			pr_err("invalid %s id: 0x%02X (expected 0x%02X)\n", "hwmon",
   359			       val, SCH5627_HWMON_ID);
   360			err = -ENODEV;
   361			goto error;
   362		}
   363	
   364		val = sch56xx_read_virtual_reg(data->addr, SCH5627_REG_COMPANY_ID);
   365		if (val < 0) {
   366			err = val;
   367			goto error;
   368		}
   369		if (val != SCH5627_COMPANY_ID) {
   370			pr_err("invalid %s id: 0x%02X (expected 0x%02X)\n", "company",
   371			       val, SCH5627_COMPANY_ID);
   372			err = -ENODEV;
   373			goto error;
   374		}
   375	
   376		val = sch56xx_read_virtual_reg(data->addr, SCH5627_REG_PRIMARY_ID);
   377		if (val < 0) {
   378			err = val;
   379			goto error;
   380		}
   381		if (val != SCH5627_PRIMARY_ID) {
   382			pr_err("invalid %s id: 0x%02X (expected 0x%02X)\n", "primary",
   383			       val, SCH5627_PRIMARY_ID);
   384			err = -ENODEV;
   385			goto error;
   386		}
   387	
   388		build_code = sch56xx_read_virtual_reg(data->addr,
   389						      SCH5627_REG_BUILD_CODE);
   390		if (build_code < 0) {
   391			err = build_code;
   392			goto error;
   393		}
   394	
   395		build_id = sch56xx_read_virtual_reg16(data->addr,
   396						      SCH5627_REG_BUILD_ID);
   397		if (build_id < 0) {
   398			err = build_id;
   399			goto error;
   400		}
   401	
   402		hwmon_rev = sch56xx_read_virtual_reg(data->addr,
   403						     SCH5627_REG_HWMON_REV);
   404		if (hwmon_rev < 0) {
   405			err = hwmon_rev;
   406			goto error;
   407		}
   408	
   409		val = sch56xx_read_virtual_reg(data->addr, SCH5627_REG_CTRL);
   410		if (val < 0) {
   411			err = val;
   412			goto error;
   413		}
   414		data->control = val;
   415		if (!(data->control & 0x01)) {
   416			pr_err("hardware monitoring not enabled\n");
   417			err = -ENODEV;
   418			goto error;
   419		}
   420		/* Trigger a Vbat voltage measurement, so that we get a valid reading
   421		   the first time we read Vbat */
   422		sch56xx_write_virtual_reg(data->addr, SCH5627_REG_CTRL,
   423					  data->control | 0x10);
   424		data->last_battery = jiffies;
   425	
   426		/*
   427		 * Read limits, we do this only once as reading a register on
   428		 * the sch5627 is quite expensive (and they don't change).
   429		 */
   430		err = sch5627_read_limits(data);
   431		if (err)
   432			goto error;
   433	
   434		pr_info("found %s chip at %#hx\n", DEVNAME, data->addr);
   435		pr_info("firmware build: code 0x%02X, id 0x%04X, hwmon: rev 0x%02X\n",
   436			build_code, build_id, hwmon_rev);
   437	
   438		data->hwmon_dev = hwmon_device_register_with_info(&pdev->dev, DEVNAME, data,
 > 439								  &sch5627_chip_info, 0);
   440		if (IS_ERR(data->hwmon_dev)) {
   441			err = PTR_ERR(data->hwmon_dev);
   442			data->hwmon_dev = NULL;
   443			goto error;
   444		}
   445	
   446		/* Note failing to register the watchdog is not a fatal error */
   447		data->watchdog = sch56xx_watchdog_register(&pdev->dev, data->addr,
   448				(build_code << 24) | (build_id << 8) | hwmon_rev,
   449				&data->update_lock, 1);
   450	
   451		return 0;
   452	
   453	error:
   454		sch5627_remove(pdev);
   455		return err;
   456	}
   457	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 36303 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [hwmon:hwmon-next 30/32] drivers/hwmon/sch5627.c:439:79: sparse: sparse: Using plain integer as NULL pointer
@ 2021-04-14  2:13 ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-04-14  2:13 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 5304 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
head:   56940c97f6e59864a807cc19db7d6fd120bff340
commit: 4564645d213f1101f5afaff6c9cf9ec2620234d4 [30/32] hwmon: (sch5627) Convert to hwmon_device_register_with_info()
config: i386-randconfig-s002-20210413 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-280-g2cd6d34e-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git/commit/?id=4564645d213f1101f5afaff6c9cf9ec2620234d4
        git remote add hwmon https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git
        git fetch --no-tags hwmon hwmon-next
        git checkout 4564645d213f1101f5afaff6c9cf9ec2620234d4
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
>> drivers/hwmon/sch5627.c:439:79: sparse: sparse: Using plain integer as NULL pointer

vim +439 drivers/hwmon/sch5627.c

   337	
   338	static int sch5627_probe(struct platform_device *pdev)
   339	{
   340		struct sch5627_data *data;
   341		int err, build_code, build_id, hwmon_rev, val;
   342	
   343		data = devm_kzalloc(&pdev->dev, sizeof(struct sch5627_data),
   344				    GFP_KERNEL);
   345		if (!data)
   346			return -ENOMEM;
   347	
   348		data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start;
   349		mutex_init(&data->update_lock);
   350		platform_set_drvdata(pdev, data);
   351	
   352		val = sch56xx_read_virtual_reg(data->addr, SCH5627_REG_HWMON_ID);
   353		if (val < 0) {
   354			err = val;
   355			goto error;
   356		}
   357		if (val != SCH5627_HWMON_ID) {
   358			pr_err("invalid %s id: 0x%02X (expected 0x%02X)\n", "hwmon",
   359			       val, SCH5627_HWMON_ID);
   360			err = -ENODEV;
   361			goto error;
   362		}
   363	
   364		val = sch56xx_read_virtual_reg(data->addr, SCH5627_REG_COMPANY_ID);
   365		if (val < 0) {
   366			err = val;
   367			goto error;
   368		}
   369		if (val != SCH5627_COMPANY_ID) {
   370			pr_err("invalid %s id: 0x%02X (expected 0x%02X)\n", "company",
   371			       val, SCH5627_COMPANY_ID);
   372			err = -ENODEV;
   373			goto error;
   374		}
   375	
   376		val = sch56xx_read_virtual_reg(data->addr, SCH5627_REG_PRIMARY_ID);
   377		if (val < 0) {
   378			err = val;
   379			goto error;
   380		}
   381		if (val != SCH5627_PRIMARY_ID) {
   382			pr_err("invalid %s id: 0x%02X (expected 0x%02X)\n", "primary",
   383			       val, SCH5627_PRIMARY_ID);
   384			err = -ENODEV;
   385			goto error;
   386		}
   387	
   388		build_code = sch56xx_read_virtual_reg(data->addr,
   389						      SCH5627_REG_BUILD_CODE);
   390		if (build_code < 0) {
   391			err = build_code;
   392			goto error;
   393		}
   394	
   395		build_id = sch56xx_read_virtual_reg16(data->addr,
   396						      SCH5627_REG_BUILD_ID);
   397		if (build_id < 0) {
   398			err = build_id;
   399			goto error;
   400		}
   401	
   402		hwmon_rev = sch56xx_read_virtual_reg(data->addr,
   403						     SCH5627_REG_HWMON_REV);
   404		if (hwmon_rev < 0) {
   405			err = hwmon_rev;
   406			goto error;
   407		}
   408	
   409		val = sch56xx_read_virtual_reg(data->addr, SCH5627_REG_CTRL);
   410		if (val < 0) {
   411			err = val;
   412			goto error;
   413		}
   414		data->control = val;
   415		if (!(data->control & 0x01)) {
   416			pr_err("hardware monitoring not enabled\n");
   417			err = -ENODEV;
   418			goto error;
   419		}
   420		/* Trigger a Vbat voltage measurement, so that we get a valid reading
   421		   the first time we read Vbat */
   422		sch56xx_write_virtual_reg(data->addr, SCH5627_REG_CTRL,
   423					  data->control | 0x10);
   424		data->last_battery = jiffies;
   425	
   426		/*
   427		 * Read limits, we do this only once as reading a register on
   428		 * the sch5627 is quite expensive (and they don't change).
   429		 */
   430		err = sch5627_read_limits(data);
   431		if (err)
   432			goto error;
   433	
   434		pr_info("found %s chip at %#hx\n", DEVNAME, data->addr);
   435		pr_info("firmware build: code 0x%02X, id 0x%04X, hwmon: rev 0x%02X\n",
   436			build_code, build_id, hwmon_rev);
   437	
   438		data->hwmon_dev = hwmon_device_register_with_info(&pdev->dev, DEVNAME, data,
 > 439								  &sch5627_chip_info, 0);
   440		if (IS_ERR(data->hwmon_dev)) {
   441			err = PTR_ERR(data->hwmon_dev);
   442			data->hwmon_dev = NULL;
   443			goto error;
   444		}
   445	
   446		/* Note failing to register the watchdog is not a fatal error */
   447		data->watchdog = sch56xx_watchdog_register(&pdev->dev, data->addr,
   448				(build_code << 24) | (build_id << 8) | hwmon_rev,
   449				&data->update_lock, 1);
   450	
   451		return 0;
   452	
   453	error:
   454		sch5627_remove(pdev);
   455		return err;
   456	}
   457	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 36303 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [hwmon:hwmon-next 30/32] drivers/hwmon/sch5627.c:439:79: sparse: sparse: Using plain integer as NULL pointer
  2021-04-14  2:13 ` kernel test robot
@ 2021-04-14  3:26   ` Guenter Roeck
  -1 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2021-04-14  3:26 UTC (permalink / raw)
  To: Armin Wolf; +Cc: kbuild-all, linux-hwmon, Hans de Goede

On Wed, Apr 14, 2021 at 10:13:15AM +0800, kernel test robot wrote:
>    437	
>    438		data->hwmon_dev = hwmon_device_register_with_info(&pdev->dev, DEVNAME, data,
>  > 439								  &sch5627_chip_info, 0);

I fixed this up, no need to resend.

Guenter

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [hwmon:hwmon-next 30/32] drivers/hwmon/sch5627.c:439:79: sparse: sparse: Using plain integer as NULL pointer
@ 2021-04-14  3:26   ` Guenter Roeck
  0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2021-04-14  3:26 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 258 bytes --]

On Wed, Apr 14, 2021 at 10:13:15AM +0800, kernel test robot wrote:
>    437	
>    438		data->hwmon_dev = hwmon_device_register_with_info(&pdev->dev, DEVNAME, data,
>  > 439								  &sch5627_chip_info, 0);

I fixed this up, no need to resend.

Guenter

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-14  3:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-14  2:13 [hwmon:hwmon-next 30/32] drivers/hwmon/sch5627.c:439:79: sparse: sparse: Using plain integer as NULL pointer kernel test robot
2021-04-14  2:13 ` kernel test robot
2021-04-14  3:26 ` Guenter Roeck
2021-04-14  3:26   ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.