[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202312172352.HLNLQ0pr-lkp@intel.com>
Date: Mon, 18 Dec 2023 00:04:58 +0800
From: kernel test robot <lkp@...el.com>
To: Andrey Smirnov <andrew.smirnov@...il.com>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
Sebastian Reichel <sre@...nel.org>,
Enric Balletbo Serra <enric.balletbo@...labora.com>,
Guenter Roeck <linux@...ck-us.net>
Subject: drivers/power/supply/ucs1002_power.c:185:29: sparse: sparse: cast to
restricted __be32
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@...el.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 ®, 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
Powered by blists - more mailing lists