Changeset 652 for GPL/branches/uniaud32-next/lib32/regcache-rbtree.c
- Timestamp:
- Jan 24, 2021, 8:40:08 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/uniaud32-next/lib32/regcache-rbtree.c
r647 r652 1 /* 2 * Register cache access API - rbtree caching support 3 * 4 * Copyright 2011 Wolfson Microelectronics plc 5 * 6 * Author: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 */ 12 /* from 4.19.163 */ 1 // SPDX-License-Identifier: GPL-2.0 2 // 3 // Register cache access API - rbtree caching support 4 // 5 // Copyright 2011 Wolfson Microelectronics plc 6 // 7 // Author: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> 8 9 /* from 5.10.10 */ 13 10 14 11 //#include <linux/debugfs.h> … … 17 14 #include <linux/seq_file.h> 18 15 #include <linux/slab.h> 19 #include <linux/module.h> 20 #include <linux/workqueue.h> 21 #include <linux/byteorder/little_endian.h> 22 #include <linux/printk.h> 23 16 #ifdef TARGET_OS2 17 #include <linux/bitmap.h> 18 #endif 24 19 #include "internal.h" 25 20 26 /*static inline*/int regcache_rbtree_write(struct regmap *map, unsigned int reg,21 static int regcache_rbtree_write(struct regmap *map, unsigned int reg, 27 22 unsigned int value); 28 /*static inline*/int regcache_rbtree_exit(struct regmap *map);23 static int regcache_rbtree_exit(struct regmap *map); 29 24 30 25 struct regcache_rbtree_node { … … 39 34 /* the actual rbtree node holding this block */ 40 35 struct rb_node node; 41 } /*__attribute__ ((packed))*/;36 }; 42 37 43 38 struct regcache_rbtree_ctx { … … 46 41 }; 47 42 48 /*static inline*/inline void regcache_rbtree_get_base_top_reg(43 static inline void regcache_rbtree_get_base_top_reg( 49 44 struct regmap *map, 50 45 struct regcache_rbtree_node *rbnode, … … 55 50 } 56 51 57 /*static inline*/unsigned int regcache_rbtree_get_register(struct regmap *map,52 static unsigned int regcache_rbtree_get_register(struct regmap *map, 58 53 struct regcache_rbtree_node *rbnode, unsigned int idx) 59 54 { … … 61 56 } 62 57 63 /*static inline*/void regcache_rbtree_set_register(struct regmap *map,58 static void regcache_rbtree_set_register(struct regmap *map, 64 59 struct regcache_rbtree_node *rbnode, 65 60 unsigned int idx, unsigned int val) … … 69 64 } 70 65 71 /*static inline*/struct regcache_rbtree_node *regcache_rbtree_lookup(struct regmap *map,66 static struct regcache_rbtree_node *regcache_rbtree_lookup(struct regmap *map, 72 67 unsigned int reg) 73 68 { … … 103 98 } 104 99 105 /*static inline*/int regcache_rbtree_insert(struct regmap *map, struct rb_root *root,100 static int regcache_rbtree_insert(struct regmap *map, struct rb_root *root, 106 101 struct regcache_rbtree_node *rbnode) 107 102 { … … 139 134 140 135 #ifdef CONFIG_DEBUG_FS 141 /*static inline*/int rbtree_show(struct seq_file *s, void *ignored)136 static int rbtree_show(struct seq_file *s, void *ignored) 142 137 { 143 138 struct regmap *map = s->private; … … 183 178 } 184 179 185 /*static inline*/ int rbtree_open(struct inode *inode, struct file *file) 186 { 187 return single_open(file, rbtree_show, inode->i_private); 188 } 189 190 /*static inline*/ const struct file_operations rbtree_fops = { 191 .open = rbtree_open, 192 .read = seq_read, 193 .llseek = seq_lseek, 194 .release = single_release, 195 }; 196 197 /*static inline*/ void rbtree_debugfs_init(struct regmap *map) 180 DEFINE_SHOW_ATTRIBUTE(rbtree); 181 182 static void rbtree_debugfs_init(struct regmap *map) 198 183 { 199 184 debugfs_create_file("rbtree", 0400, map->debugfs, map, &rbtree_fops); … … 201 186 #endif 202 187 203 /*static inline*/int regcache_rbtree_init(struct regmap *map)188 static int regcache_rbtree_init(struct regmap *map) 204 189 { 205 190 struct regcache_rbtree_ctx *rbtree_ctx; 206 191 int i; 207 192 int ret; 193 208 194 #ifdef TARGET_OS2 209 195 // 2020-11-17 SHL FIXME patched struct rb_root … … 240 226 } 241 227 242 /*static inline*/int regcache_rbtree_exit(struct regmap *map)228 static int regcache_rbtree_exit(struct regmap *map) 243 229 { 244 230 struct rb_node *next; … … 269 255 } 270 256 271 /*static inline*/int regcache_rbtree_read(struct regmap *map,257 static int regcache_rbtree_read(struct regmap *map, 272 258 unsigned int reg, unsigned int *value) 273 259 { … … 289 275 290 276 291 /*static inline*/int regcache_rbtree_insert_to_block(struct regmap *map,277 static int regcache_rbtree_insert_to_block(struct regmap *map, 292 278 struct regcache_rbtree_node *rbnode, 293 279 unsigned int base_reg, … … 324 310 * sizeof(*present)); 325 311 } else { 326 present = (unsigned long *)rbnode->cache_present;312 present = rbnode->cache_present; 327 313 } 328 314 … … 338 324 rbnode->blklen = blklen; 339 325 rbnode->base_reg = base_reg; 340 rbnode->cache_present = (long*)present;326 rbnode->cache_present = present; 341 327 342 328 regcache_rbtree_set_register(map, rbnode, pos, value); … … 344 330 } 345 331 346 /*static inline*/struct regcache_rbtree_node *332 static struct regcache_rbtree_node * 347 333 regcache_rbtree_node_alloc(struct regmap *map, unsigned int reg) 348 334 { … … 396 382 } 397 383 398 /*static inline*/int regcache_rbtree_write(struct regmap *map, unsigned int reg,384 static int regcache_rbtree_write(struct regmap *map, unsigned int reg, 399 385 unsigned int value) 400 386 { … … 492 478 } 493 479 494 /*static inline*/int regcache_rbtree_sync(struct regmap *map, unsigned int min,480 static int regcache_rbtree_sync(struct regmap *map, unsigned int min, 495 481 unsigned int max) 496 482 { … … 524 510 525 511 ret = regcache_sync_block(map, rbnode->block, 526 (unsigned long *)rbnode->cache_present,512 rbnode->cache_present, 527 513 rbnode->base_reg, start, end); 528 514 if (ret != 0) … … 533 519 } 534 520 535 /*static inline*/int regcache_rbtree_drop(struct regmap *map, unsigned int min,521 static int regcache_rbtree_drop(struct regmap *map, unsigned int min, 536 522 unsigned int max) 537 523 { … … 563 549 end = rbnode->blklen; 564 550 565 bitmap_clear( (unsigned long *)rbnode->cache_present, start, end - start);551 bitmap_clear(rbnode->cache_present, start, end - start); 566 552 } 567 553
Note:
See TracChangeset
for help on using the changeset viewer.