mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org,
	Sebastian Reichel <sre@kernel.org>,
	Enric Balletbo Serra <enric.balletbo@collabora.com>,
	Guenter Roeck <linux@roeck-us.net>
Subject: drivers/power/supply/ucs1002_power.c:185:29: sparse: sparse: cast to restricted __be32
Date: Mon, 18 Dec 2023 00:04:58 +0800	[thread overview]
Message-ID: <202312172352.HLNLQ0pr-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   3b8a9b2e6809d281890dd0a1102dc14d2cd11caf
commit: 9a2688e42638f2e057dbdfce82e221b38bfba0a7 power: supply: Add driver for Microchip UCS1002
date:   4 years, 8 months ago
config: parisc-randconfig-m041-20230821 (https://download.01.org/0day-ci/archive/20231217/202312172352.HLNLQ0pr-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20231217/202312172352.HLNLQ0pr-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312172352.HLNLQ0pr-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
   drivers/power/supply/ucs1002_power.c: note: in included file (through arch/parisc/include/uapi/asm/unistd.h, arch/parisc/include/asm/unistd.h, include/uapi/linux/unistd.h, ...):
   ./arch/parisc/include/generated/uapi/asm/unistd_32.h:367:41: sparse: sparse: no newline at end of file
>> drivers/power/supply/ucs1002_power.c:185:29: sparse: sparse: cast to restricted __be32

vim +185 drivers/power/supply/ucs1002_power.c

   131	
   132	static int ucs1002_get_charge(struct ucs1002_info *info,
   133				      union power_supply_propval *val)
   134	{
   135		/*
   136		 * To fit within 32 bits some values are rounded (uA/h)
   137		 *
   138		 * For Total Accumulated Charge Middle Low Byte register, addr
   139		 * 03h, byte 2
   140		 *
   141		 *   B0: 0.01084 mA/h rounded to 11 uA/h
   142		 *   B1: 0.02169 mA/h rounded to 22 uA/h
   143		 *   B2: 0.04340 mA/h rounded to 43 uA/h
   144		 *   B3: 0.08676 mA/h rounded to 87 uA/h
   145		 *   B4: 0.17350 mA/h rounded to 173 uÁ/h
   146		 *
   147		 * For Total Accumulated Charge Low Byte register, addr 04h,
   148		 * byte 3
   149		 *
   150		 *   B6: 0.00271 mA/h rounded to 3 uA/h
   151		 *   B7: 0.005422 mA/h rounded to 5 uA/h
   152		 */
   153		static const int bit_weights_uAh[BITS_PER_TYPE(u32)] = {
   154			/*
   155			 * Bit corresponding to low byte (offset 0x04)
   156			 * B0 B1 B2 B3 B4 B5 B6 B7
   157			 */
   158			0, 0, 0, 0, 0, 0, 3, 5,
   159			/*
   160			 * Bit corresponding to middle low byte (offset 0x03)
   161			 * B0 B1 B2 B3 B4 B5 B6 B7
   162			 */
   163			11, 22, 43, 87, 173, 347, 694, 1388,
   164			/*
   165			 * Bit corresponding to middle high byte (offset 0x02)
   166			 * B0 B1 B2 B3 B4 B5 B6 B7
   167			 */
   168			2776, 5552, 11105, 22210, 44420, 88840, 177700, 355400,
   169			/*
   170			 * Bit corresponding to high byte (offset 0x01)
   171			 * B0 B1 B2 B3 B4 B5 B6 B7
   172			 */
   173			710700, 1421000, 2843000, 5685000, 11371000, 22742000,
   174			45484000, 90968000,
   175		};
   176		unsigned long total_acc_charger;
   177		unsigned int reg;
   178		int i, ret;
   179	
   180		ret = regmap_bulk_read(info->regmap, UCS1002_REG_TOTAL_ACC_CHARGE,
   181				       &reg, sizeof(u32));
   182		if (ret)
   183			return ret;
   184	
 > 185		total_acc_charger = be32_to_cpu(reg); /* BE as per offsets above */
   186		val->intval = 0;
   187	
   188		for_each_set_bit(i, &total_acc_charger, ARRAY_SIZE(bit_weights_uAh))
   189			val->intval += bit_weights_uAh[i];
   190	
   191		return 0;
   192	}
   193	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

                 reply	other threads:[~2023-12-17 16:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202312172352.HLNLQ0pr-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=andrew.smirnov@gmail.com \
    --cc=enric.balletbo@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®