Ignore:
Timestamp:
Jan 3, 2021, 7:20:20 AM (5 years ago)
Author:
Paul Smedley
Message:

Code cleanups to simplify future maintenance, update regmap/regcache/rbtree to linux 4.19.163 level

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/uniaud32-next/lib32/regcache-rbtree.c

    r621 r625  
    1010 * published by the Free Software Foundation.
    1111 */
    12 /* from 4.14.202 */
     12/* from 4.19.163 */
    1313
    1414//#include <linux/debugfs.h>
     
    2424#include "internal.h"
    2525
    26 /*static*/ int regcache_rbtree_write(struct regmap *map, unsigned int reg,
    27                                  unsigned int value);
    28 /*static*/ int regcache_rbtree_exit(struct regmap *map);
    29 
    3026#ifdef TARGET_OS2
    3127#define UINT_MAX        (~0U)
    32 #pragma pack(1)
    3328#endif
     29
     30/*static inline*/ int regcache_rbtree_write(struct regmap *map, unsigned int reg,
     31                                 unsigned int value);
     32/*static inline*/ int regcache_rbtree_exit(struct regmap *map);
     33
    3434struct regcache_rbtree_node {
    3535        /* block of adjacent registers */
    3636        void *block;
    3737        /* Which registers are present */
    38         unsigned long *cache_present;
     38        long *cache_present;
    3939        /* base register handled by this block */
    4040        unsigned int base_reg;
     
    4343        /* the actual rbtree node holding this block */
    4444        struct rb_node node;
    45 #ifndef TARGET_OS2
    46 } __attribute__ ((packed));
    47 #else
    48 };
    49 #pragma pack()
    50 #endif
     45} /*__attribute__ ((packed))*/;
    5146
    5247struct regcache_rbtree_ctx {
     
    5550};
    5651
    57 /*static inline*/ void regcache_rbtree_get_base_top_reg(
     52/*static inline*/ inline void regcache_rbtree_get_base_top_reg(
    5853        struct regmap *map,
    5954        struct regcache_rbtree_node *rbnode,
     
    6459}
    6560
    66 /*static*/ unsigned int regcache_rbtree_get_register(struct regmap *map,
     61/*static inline*/ unsigned int regcache_rbtree_get_register(struct regmap *map,
    6762        struct regcache_rbtree_node *rbnode, unsigned int idx)
    6863{
     
    7065}
    7166
    72 /*static*/ void regcache_rbtree_set_register(struct regmap *map,
     67/*static inline*/ void regcache_rbtree_set_register(struct regmap *map,
    7368                                         struct regcache_rbtree_node *rbnode,
    7469                                         unsigned int idx, unsigned int val)
     
    7873}
    7974
    80 /*static*/ struct regcache_rbtree_node *regcache_rbtree_lookup(struct regmap *map,
     75/*static inline*/ struct regcache_rbtree_node *regcache_rbtree_lookup(struct regmap *map,
    8176                                                           unsigned int reg)
    8277{
     
    108103                }
    109104        }
     105
    110106        return NULL;
    111107}
    112108
    113 /*static*/ int regcache_rbtree_insert(struct regmap *map, struct rb_root *root,
     109/*static inline*/ int regcache_rbtree_insert(struct regmap *map, struct rb_root *root,
    114110                                  struct regcache_rbtree_node *rbnode)
    115111{
     
    121117        parent = NULL;
    122118        new = &root->rb_node;
    123 
    124119        while (*new) {
    125120                rbnode_tmp = rb_entry(*new, struct regcache_rbtree_node, node);
     
    148143
    149144#ifdef CONFIG_DEBUG_FS
    150 /*static*/ int rbtree_show(struct seq_file *s, void *ignored)
     145/*static inline*/ int rbtree_show(struct seq_file *s, void *ignored)
    151146{
    152147        struct regmap *map = s->private;
     
    192187}
    193188
    194 /*static*/ int rbtree_open(struct inode *inode, struct file *file)
     189/*static inline*/ int rbtree_open(struct inode *inode, struct file *file)
    195190{
    196191        return single_open(file, rbtree_show, inode->i_private);
    197192}
    198193
    199 /*static*/ const struct file_operations rbtree_fops = {
     194/*static inline*/ const struct file_operations rbtree_fops = {
    200195        .open           = rbtree_open,
    201196        .read           = seq_read,
     
    204199};
    205200
    206 /*static*/ void rbtree_debugfs_init(struct regmap *map)
     201/*static inline*/ void rbtree_debugfs_init(struct regmap *map)
    207202{
    208203        debugfs_create_file("rbtree", 0400, map->debugfs, map, &rbtree_fops);
     
    210205#endif
    211206
    212 /*static*/ int regcache_rbtree_init(struct regmap *map)
     207/*static inline*/ int regcache_rbtree_init(struct regmap *map)
    213208{
    214209        struct regcache_rbtree_ctx *rbtree_ctx;
     
    233228#endif
    234229        rbtree_ctx->cached_rbnode = NULL;
     230
    235231        for (i = 0; i < map->num_reg_defaults; i++) {
    236232                ret = regcache_rbtree_write(map,
     
    248244}
    249245
    250 /*static*/ int regcache_rbtree_exit(struct regmap *map)
     246/*static inline*/ int regcache_rbtree_exit(struct regmap *map)
    251247{
    252248        struct rb_node *next;
     
    277273}
    278274
    279 /*static*/ int regcache_rbtree_read(struct regmap *map,
     275/*static inline*/ int regcache_rbtree_read(struct regmap *map,
    280276                                unsigned int reg, unsigned int *value)
    281277{
     
    292288                return -ENOENT;
    293289        }
    294         return 0;
    295 }
    296 
    297 
    298 /*static*/ int regcache_rbtree_insert_to_block(struct regmap *map,
     290
     291        return 0;
     292}
     293
     294
     295/*static inline*/ int regcache_rbtree_insert_to_block(struct regmap *map,
    299296                                           struct regcache_rbtree_node *rbnode,
    300297                                           unsigned int base_reg,
     
    351348}
    352349
    353 /*static*/ struct regcache_rbtree_node *
     350/*static inline*/ struct regcache_rbtree_node *
    354351regcache_rbtree_node_alloc(struct regmap *map, unsigned int reg)
    355352{
     
    369366                                break;
    370367                }
     368
    371369                if (i != map->rd_table->n_yes_ranges) {
    372370                        range = &map->rd_table->yes_ranges[i];
     
    376374                }
    377375        }
     376
    378377        if (!rbnode->blklen) {
    379378                rbnode->blklen = 1;
     
    401400}
    402401
    403 /*static*/ int regcache_rbtree_write(struct regmap *map, unsigned int reg,
     402/*static inline*/ int regcache_rbtree_write(struct regmap *map, unsigned int reg,
    404403                                 unsigned int value)
    405404{
     
    476475                                                              new_top_reg, reg,
    477476                                                              value);
    478                         if (ret){
    479                                 return ret;}
     477                        if (ret)
     478                                return ret;
    480479                        rbtree_ctx->cached_rbnode = rbnode;
    481480                        return 0;
     
    486485                 */
    487486                rbnode = regcache_rbtree_node_alloc(map, reg);
    488                 if (!rbnode){
    489                         return -ENOMEM;}
     487                if (!rbnode)
     488                        return -ENOMEM;
    490489                regcache_rbtree_set_register(map, rbnode,
    491490                                             reg - rbnode->base_reg, value);
     
    493492                rbtree_ctx->cached_rbnode = rbnode;
    494493        }
    495         return 0;
    496 }
    497 
    498 /*static*/ int regcache_rbtree_sync(struct regmap *map, unsigned int min,
     494
     495        return 0;
     496}
     497
     498/*static inline*/ int regcache_rbtree_sync(struct regmap *map, unsigned int min,
    499499                                unsigned int max)
    500500{
     
    537537}
    538538
    539 /*static*/ int regcache_rbtree_drop(struct regmap *map, unsigned int min,
     539/*static inline*/ int regcache_rbtree_drop(struct regmap *map, unsigned int min,
    540540                                unsigned int max)
    541541{
Note: See TracChangeset for help on using the changeset viewer.