Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal: intel: intel_soc_dts_iosf: Utilize for_each_set_clump8 macro

Utilize for_each_set_clump8 macro, and the bitmap_set_value8 and
bitmap_get_value8 functions, where appropriate. In addition, remove the
now unnecessary temp_mask and temp_shift members of the
intel_soc_dts_sensor_entry structure.

Link: http://lkml.kernel.org/r/2d3c74e9a00a52954f31d19e04623a7f4bc85520.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Mathias Duckeck <m.duckeck@kunbus.de>
Cc: Morten Hein Tiljeset <morten.tiljeset@prevas.dk>
Cc: Phil Reid <preid@electromag.com.au>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

William Breathitt Gray and committed by
Linus Torvalds
9f00ebf5 b2ca9ebf

+18 -15
+18 -13
drivers/thermal/intel/intel_soc_dts_iosf.c
··· 6 6 7 7 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8 8 9 + #include <linux/bitops.h> 9 10 #include <linux/module.h> 10 11 #include <linux/slab.h> 11 12 #include <linux/interrupt.h> ··· 104 103 int status; 105 104 u32 temp_out; 106 105 u32 out; 106 + unsigned long update_ptps; 107 107 u32 store_ptps; 108 108 u32 store_ptmc; 109 109 u32 store_te_out; ··· 122 120 if (status) 123 121 return status; 124 122 125 - out = (store_ptps & ~(0xFF << (thres_index * 8))); 126 - out |= (temp_out & 0xFF) << (thres_index * 8); 123 + update_ptps = store_ptps; 124 + bitmap_set_value8(&update_ptps, temp_out & 0xFF, thres_index * 8); 125 + out = update_ptps; 126 + 127 127 status = iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, 128 128 SOC_DTS_OFFSET_PTPS, out); 129 129 if (status) ··· 227 223 u32 out; 228 224 struct intel_soc_dts_sensor_entry *dts; 229 225 struct intel_soc_dts_sensors *sensors; 226 + unsigned long raw; 230 227 231 228 dts = tzd->devdata; 232 229 sensors = dts->sensors; ··· 236 231 if (status) 237 232 return status; 238 233 239 - out = (out & dts->temp_mask) >> dts->temp_shift; 240 - out -= SOC_DTS_TJMAX_ENCODING; 234 + raw = out; 235 + out = bitmap_get_value8(&raw, dts->id * 8) - SOC_DTS_TJMAX_ENCODING; 241 236 *temp = sensors->tj_max - out * 1000; 242 237 243 238 return 0; ··· 285 280 int read_only_trip_cnt) 286 281 { 287 282 char name[10]; 283 + unsigned long trip; 288 284 int trip_count = 0; 289 285 int trip_mask = 0; 286 + int writable_trip_cnt = 0; 287 + unsigned long ptps; 290 288 u32 store_ptps; 289 + unsigned long i; 291 290 int ret; 292 - int i; 293 291 294 292 /* Store status to restor on exit */ 295 293 ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ··· 301 293 goto err_ret; 302 294 303 295 dts->id = id; 304 - dts->temp_mask = 0x00FF << (id * 8); 305 - dts->temp_shift = id * 8; 306 296 if (notification_support) { 307 297 trip_count = min(SOC_MAX_DTS_TRIPS, trip_cnt); 308 - trip_mask = BIT(trip_count - read_only_trip_cnt) - 1; 298 + writable_trip_cnt = trip_count - read_only_trip_cnt; 299 + trip_mask = GENMASK(writable_trip_cnt - 1, 0); 309 300 } 310 301 311 302 /* Check if the writable trip we provide is not used by BIOS */ ··· 313 306 if (ret) 314 307 trip_mask = 0; 315 308 else { 316 - for (i = 0; i < trip_count; ++i) { 317 - if (trip_mask & BIT(i)) 318 - if (store_ptps & (0xff << (i * 8))) 319 - trip_mask &= ~BIT(i); 320 - } 309 + ptps = store_ptps; 310 + for_each_set_clump8(i, trip, &ptps, writable_trip_cnt * 8) 311 + trip_mask &= ~BIT(i / 8); 321 312 } 322 313 dts->trip_mask = trip_mask; 323 314 dts->trip_count = trip_count;
-2
drivers/thermal/intel/intel_soc_dts_iosf.h
··· 24 24 25 25 struct intel_soc_dts_sensor_entry { 26 26 int id; 27 - u32 temp_mask; 28 - u32 temp_shift; 29 27 u32 store_status; 30 28 u32 trip_mask; 31 29 u32 trip_count;