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

Merge remote-tracking branches 'regmap/topic/mmio', 'regmap/topic/rbtree' and 'regmap/topic/seq' into regmap-next

+63 -90
-1
arch/mips/boot/dts/brcm/bcm6328.dtsi
··· 73 73 timer: timer@10000040 { 74 74 compatible = "syscon"; 75 75 reg = <0x10000040 0x2c>; 76 - little-endian; 77 76 }; 78 77 79 78 reboot {
-1
arch/mips/boot/dts/brcm/bcm7125.dtsi
··· 98 98 sun_top_ctrl: syscon@404000 { 99 99 compatible = "brcm,bcm7125-sun-top-ctrl", "syscon"; 100 100 reg = <0x404000 0x60c>; 101 - little-endian; 102 101 }; 103 102 104 103 reboot {
-1
arch/mips/boot/dts/brcm/bcm7346.dtsi
··· 118 118 sun_top_ctrl: syscon@404000 { 119 119 compatible = "brcm,bcm7346-sun-top-ctrl", "syscon"; 120 120 reg = <0x404000 0x51c>; 121 - little-endian; 122 121 }; 123 122 124 123 reboot {
-1
arch/mips/boot/dts/brcm/bcm7358.dtsi
··· 112 112 sun_top_ctrl: syscon@404000 { 113 113 compatible = "brcm,bcm7358-sun-top-ctrl", "syscon"; 114 114 reg = <0x404000 0x51c>; 115 - little-endian; 116 115 }; 117 116 118 117 reboot {
-1
arch/mips/boot/dts/brcm/bcm7360.dtsi
··· 112 112 sun_top_ctrl: syscon@404000 { 113 113 compatible = "brcm,bcm7360-sun-top-ctrl", "syscon"; 114 114 reg = <0x404000 0x51c>; 115 - little-endian; 116 115 }; 117 116 118 117 reboot {
-1
arch/mips/boot/dts/brcm/bcm7362.dtsi
··· 118 118 sun_top_ctrl: syscon@404000 { 119 119 compatible = "brcm,bcm7362-sun-top-ctrl", "syscon"; 120 120 reg = <0x404000 0x51c>; 121 - little-endian; 122 121 }; 123 122 124 123 reboot {
-1
arch/mips/boot/dts/brcm/bcm7420.dtsi
··· 99 99 sun_top_ctrl: syscon@404000 { 100 100 compatible = "brcm,bcm7420-sun-top-ctrl", "syscon"; 101 101 reg = <0x404000 0x60c>; 102 - little-endian; 103 102 }; 104 103 105 104 reboot {
-1
arch/mips/boot/dts/brcm/bcm7425.dtsi
··· 100 100 sun_top_ctrl: syscon@404000 { 101 101 compatible = "brcm,bcm7425-sun-top-ctrl", "syscon"; 102 102 reg = <0x404000 0x51c>; 103 - little-endian; 104 103 }; 105 104 106 105 reboot {
-1
arch/mips/boot/dts/brcm/bcm7435.dtsi
··· 114 114 sun_top_ctrl: syscon@404000 { 115 115 compatible = "brcm,bcm7425-sun-top-ctrl", "syscon"; 116 116 reg = <0x404000 0x51c>; 117 - little-endian; 118 117 }; 119 118 120 119 reboot {
+7 -2
drivers/base/regmap/regcache-rbtree.c
··· 414 414 max = reg + max_dist; 415 415 416 416 /* look for an adjacent register to the one we are about to add */ 417 - for (node = rb_first(&rbtree_ctx->root); node; 418 - node = rb_next(node)) { 417 + node = rbtree_ctx->root.rb_node; 418 + while (node) { 419 419 rbnode_tmp = rb_entry(node, struct regcache_rbtree_node, 420 420 node); 421 421 ··· 426 426 new_base_reg = min(reg, base_reg); 427 427 new_top_reg = max(reg, top_reg); 428 428 } else { 429 + if (max < base_reg) 430 + node = node->rb_left; 431 + else 432 + node = node->rb_right; 433 + 429 434 continue; 430 435 } 431 436
+18 -51
drivers/base/regmap/regmap-debugfs.c
··· 397 397 .llseek = default_llseek, 398 398 }; 399 399 400 - static ssize_t regmap_access_read_file(struct file *file, 401 - char __user *user_buf, size_t count, 402 - loff_t *ppos) 400 + static int regmap_access_show(struct seq_file *s, void *ignored) 403 401 { 404 - int reg_len, tot_len; 405 - size_t buf_pos = 0; 406 - loff_t p = 0; 407 - ssize_t ret; 408 - int i; 409 - struct regmap *map = file->private_data; 410 - char *buf; 402 + struct regmap *map = s->private; 403 + int i, reg_len; 411 404 412 - if (*ppos < 0 || !count) 413 - return -EINVAL; 414 - 415 - buf = kmalloc(count, GFP_KERNEL); 416 - if (!buf) 417 - return -ENOMEM; 418 - 419 - /* Calculate the length of a fixed format */ 420 405 reg_len = regmap_calc_reg_len(map->max_register); 421 - tot_len = reg_len + 10; /* ': R W V P\n' */ 422 406 423 407 for (i = 0; i <= map->max_register; i += map->reg_stride) { 424 408 /* Ignore registers which are neither readable nor writable */ 425 409 if (!regmap_readable(map, i) && !regmap_writeable(map, i)) 426 410 continue; 427 411 428 - /* If we're in the region the user is trying to read */ 429 - if (p >= *ppos) { 430 - /* ...but not beyond it */ 431 - if (buf_pos + tot_len + 1 >= count) 432 - break; 433 - 434 - /* Format the register */ 435 - snprintf(buf + buf_pos, count - buf_pos, 436 - "%.*x: %c %c %c %c\n", 437 - reg_len, i, 438 - regmap_readable(map, i) ? 'y' : 'n', 439 - regmap_writeable(map, i) ? 'y' : 'n', 440 - regmap_volatile(map, i) ? 'y' : 'n', 441 - regmap_precious(map, i) ? 'y' : 'n'); 442 - 443 - buf_pos += tot_len; 444 - } 445 - p += tot_len; 412 + /* Format the register */ 413 + seq_printf(s, "%.*x: %c %c %c %c\n", reg_len, i, 414 + regmap_readable(map, i) ? 'y' : 'n', 415 + regmap_writeable(map, i) ? 'y' : 'n', 416 + regmap_volatile(map, i) ? 'y' : 'n', 417 + regmap_precious(map, i) ? 'y' : 'n'); 446 418 } 447 419 448 - ret = buf_pos; 420 + return 0; 421 + } 449 422 450 - if (copy_to_user(user_buf, buf, buf_pos)) { 451 - ret = -EFAULT; 452 - goto out; 453 - } 454 - 455 - *ppos += buf_pos; 456 - 457 - out: 458 - kfree(buf); 459 - return ret; 423 + static int access_open(struct inode *inode, struct file *file) 424 + { 425 + return single_open(file, regmap_access_show, inode->i_private); 460 426 } 461 427 462 428 static const struct file_operations regmap_access_fops = { 463 - .open = simple_open, 464 - .read = regmap_access_read_file, 465 - .llseek = default_llseek, 429 + .open = access_open, 430 + .read = seq_read, 431 + .llseek = seq_lseek, 432 + .release = single_release, 466 433 }; 467 434 468 435 static ssize_t regmap_cache_only_write_file(struct file *file,
+38 -28
drivers/base/regmap/regmap-mmio.c
··· 61 61 } 62 62 } 63 63 64 + static int regmap_mmio_get_min_stride(size_t val_bits) 65 + { 66 + int min_stride; 67 + 68 + switch (val_bits) { 69 + case 8: 70 + /* The core treats 0 as 1 */ 71 + min_stride = 0; 72 + return 0; 73 + case 16: 74 + min_stride = 2; 75 + break; 76 + case 32: 77 + min_stride = 4; 78 + break; 79 + #ifdef CONFIG_64BIT 80 + case 64: 81 + min_stride = 8; 82 + break; 83 + #endif 84 + default: 85 + return -EINVAL; 86 + } 87 + 88 + return min_stride; 89 + } 90 + 64 91 static inline void regmap_mmio_count_check(size_t count, u32 offset) 65 92 { 66 93 BUG_ON(count <= offset); ··· 133 106 while (val_size) { 134 107 switch (ctx->val_bytes) { 135 108 case 1: 136 - writeb(*(u8 *)val, ctx->regs + offset); 109 + __raw_writeb(*(u8 *)val, ctx->regs + offset); 137 110 break; 138 111 case 2: 139 - writew(*(u16 *)val, ctx->regs + offset); 112 + __raw_writew(*(u16 *)val, ctx->regs + offset); 140 113 break; 141 114 case 4: 142 - writel(*(u32 *)val, ctx->regs + offset); 115 + __raw_writel(*(u32 *)val, ctx->regs + offset); 143 116 break; 144 117 #ifdef CONFIG_64BIT 145 118 case 8: 146 - writeq(*(u64 *)val, ctx->regs + offset); 119 + __raw_writeq(*(u64 *)val, ctx->regs + offset); 147 120 break; 148 121 #endif 149 122 default: ··· 193 166 while (val_size) { 194 167 switch (ctx->val_bytes) { 195 168 case 1: 196 - *(u8 *)val = readb(ctx->regs + offset); 169 + *(u8 *)val = __raw_readb(ctx->regs + offset); 197 170 break; 198 171 case 2: 199 - *(u16 *)val = readw(ctx->regs + offset); 172 + *(u16 *)val = __raw_readw(ctx->regs + offset); 200 173 break; 201 174 case 4: 202 - *(u32 *)val = readl(ctx->regs + offset); 175 + *(u32 *)val = __raw_readl(ctx->regs + offset); 203 176 break; 204 177 #ifdef CONFIG_64BIT 205 178 case 8: 206 - *(u64 *)val = readq(ctx->regs + offset); 179 + *(u64 *)val = __raw_readq(ctx->regs + offset); 207 180 break; 208 181 #endif 209 182 default: ··· 258 231 if (config->pad_bits) 259 232 return ERR_PTR(-EINVAL); 260 233 261 - switch (config->val_bits) { 262 - case 8: 263 - /* The core treats 0 as 1 */ 264 - min_stride = 0; 265 - break; 266 - case 16: 267 - min_stride = 2; 268 - break; 269 - case 32: 270 - min_stride = 4; 271 - break; 272 - #ifdef CONFIG_64BIT 273 - case 64: 274 - min_stride = 8; 275 - break; 276 - #endif 277 - break; 278 - default: 279 - return ERR_PTR(-EINVAL); 280 - } 234 + min_stride = regmap_mmio_get_min_stride(config->val_bits); 235 + if (min_stride < 0) 236 + return ERR_PTR(min_stride); 281 237 282 238 if (config->reg_stride < min_stride) 283 239 return ERR_PTR(-EINVAL);