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

Merge tag 'regmap-v4.3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap

Pull regmap updates from Mark Brown:
"This has been a busy release for regmap.

By far the biggest set of changes here are those from Markus Pargmann
which implement support for block transfers in smbus devices. This
required quite a bit of refactoring but leaves us better able to
handle odd restrictions that controllers may have and with better
performance on smbus.

Other new features include:

- Fix interactions with lockdep for nested regmaps (eg, when a device
using regmap is connected to a bus where the bus controller has a
separate regmap). Lockdep's default class identification is too
crude to work without help.

- Support for must write bitfield operations, useful for operations
which require writing a bit to trigger them from Kuniori Morimoto.

- Support for delaying during register patch application from Nariman
Poushin.

- Support for overriding cache state via the debugfs implementation
from Richard Fitzgerald"

* tag 'regmap-v4.3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap: (25 commits)
regmap: fix a NULL pointer dereference in __regmap_init
regmap: Support bulk reads for devices without raw formatting
regmap-i2c: Add smbus i2c block support
regmap: Add raw_write/read checks for max_raw_write/read sizes
regmap: regmap max_raw_read/write getter functions
regmap: Introduce max_raw_read/write for regmap_bulk_read/write
regmap: Add missing comments about struct regmap_bus
regmap: No multi_write support if bus->write does not exist
regmap: Split use_single_rw internally into use_single_read/write
regmap: Fix regmap_bulk_write for bus writes
regmap: regmap_raw_read return error on !bus->read
regulator: core: Print at debug level on debugfs creation failure
regmap: Fix regmap_can_raw_write check
regmap: fix typos in regmap.c
regmap: Fix integertypes for register address and value
regmap: Move documentation to regmap.h
regmap: Use different lockdep class for each regmap init call
thermal: sti: Add parentheses around bridge->ops->regmap_init call
mfd: vexpress: Add parentheses around bridge->ops->regmap_init call
regmap: debugfs: Fix misuse of IS_ENABLED
...

+806 -301
+8 -2
drivers/base/regmap/internal.h
··· 139 139 struct reg_sequence *patch; 140 140 int patch_regs; 141 141 142 - /* if set, converts bulk rw to single rw */ 143 - bool use_single_rw; 142 + /* if set, converts bulk read to single read */ 143 + bool use_single_read; 144 + /* if set, converts bulk read to single read */ 145 + bool use_single_write; 144 146 /* if set, the device supports multi write mode */ 145 147 bool can_multi_write; 148 + 149 + /* if set, raw reads/writes are limited to this size */ 150 + size_t max_raw_read; 151 + size_t max_raw_write; 146 152 147 153 struct rb_root range_tree; 148 154 void *selector_work_buf; /* Scratch buffer used for selector */
+1 -1
drivers/base/regmap/regcache.c
··· 729 729 unsigned int block_base, unsigned int start, 730 730 unsigned int end) 731 731 { 732 - if (regmap_can_raw_write(map) && !map->use_single_rw) 732 + if (regmap_can_raw_write(map) && !map->use_single_write) 733 733 return regcache_sync_block_raw(map, block, cache_present, 734 734 block_base, start, end); 735 735 else
+14 -27
drivers/base/regmap/regmap-ac97.c
··· 78 78 .reg_read = regmap_ac97_reg_read, 79 79 }; 80 80 81 - /** 82 - * regmap_init_ac97(): Initialise AC'97 register map 83 - * 84 - * @ac97: Device that will be interacted with 85 - * @config: Configuration for register map 86 - * 87 - * The return value will be an ERR_PTR() on error or a valid pointer to 88 - * a struct regmap. 89 - */ 90 - struct regmap *regmap_init_ac97(struct snd_ac97 *ac97, 91 - const struct regmap_config *config) 81 + struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97, 82 + const struct regmap_config *config, 83 + struct lock_class_key *lock_key, 84 + const char *lock_name) 92 85 { 93 - return regmap_init(&ac97->dev, &ac97_regmap_bus, ac97, config); 86 + return __regmap_init(&ac97->dev, &ac97_regmap_bus, ac97, config, 87 + lock_key, lock_name); 94 88 } 95 - EXPORT_SYMBOL_GPL(regmap_init_ac97); 89 + EXPORT_SYMBOL_GPL(__regmap_init_ac97); 96 90 97 - /** 98 - * devm_regmap_init_ac97(): Initialise AC'97 register map 99 - * 100 - * @ac97: Device that will be interacted with 101 - * @config: Configuration for register map 102 - * 103 - * The return value will be an ERR_PTR() on error or a valid pointer 104 - * to a struct regmap. The regmap will be automatically freed by the 105 - * device management code. 106 - */ 107 - struct regmap *devm_regmap_init_ac97(struct snd_ac97 *ac97, 108 - const struct regmap_config *config) 91 + struct regmap *__devm_regmap_init_ac97(struct snd_ac97 *ac97, 92 + const struct regmap_config *config, 93 + struct lock_class_key *lock_key, 94 + const char *lock_name) 109 95 { 110 - return devm_regmap_init(&ac97->dev, &ac97_regmap_bus, ac97, config); 96 + return __devm_regmap_init(&ac97->dev, &ac97_regmap_bus, ac97, config, 97 + lock_key, lock_name); 111 98 } 112 - EXPORT_SYMBOL_GPL(devm_regmap_init_ac97); 99 + EXPORT_SYMBOL_GPL(__devm_regmap_init_ac97); 113 100 114 101 MODULE_LICENSE("GPL v2");
+91 -8
drivers/base/regmap/regmap-debugfs.c
··· 469 469 .llseek = default_llseek, 470 470 }; 471 471 472 + static ssize_t regmap_cache_only_write_file(struct file *file, 473 + const char __user *user_buf, 474 + size_t count, loff_t *ppos) 475 + { 476 + struct regmap *map = container_of(file->private_data, 477 + struct regmap, cache_only); 478 + ssize_t result; 479 + bool was_enabled, require_sync = false; 480 + int err; 481 + 482 + map->lock(map->lock_arg); 483 + 484 + was_enabled = map->cache_only; 485 + 486 + result = debugfs_write_file_bool(file, user_buf, count, ppos); 487 + if (result < 0) { 488 + map->unlock(map->lock_arg); 489 + return result; 490 + } 491 + 492 + if (map->cache_only && !was_enabled) { 493 + dev_warn(map->dev, "debugfs cache_only=Y forced\n"); 494 + add_taint(TAINT_USER, LOCKDEP_STILL_OK); 495 + } else if (!map->cache_only && was_enabled) { 496 + dev_warn(map->dev, "debugfs cache_only=N forced: syncing cache\n"); 497 + require_sync = true; 498 + } 499 + 500 + map->unlock(map->lock_arg); 501 + 502 + if (require_sync) { 503 + err = regcache_sync(map); 504 + if (err) 505 + dev_err(map->dev, "Failed to sync cache %d\n", err); 506 + } 507 + 508 + return result; 509 + } 510 + 511 + static const struct file_operations regmap_cache_only_fops = { 512 + .open = simple_open, 513 + .read = debugfs_read_file_bool, 514 + .write = regmap_cache_only_write_file, 515 + }; 516 + 517 + static ssize_t regmap_cache_bypass_write_file(struct file *file, 518 + const char __user *user_buf, 519 + size_t count, loff_t *ppos) 520 + { 521 + struct regmap *map = container_of(file->private_data, 522 + struct regmap, cache_bypass); 523 + ssize_t result; 524 + bool was_enabled; 525 + 526 + map->lock(map->lock_arg); 527 + 528 + was_enabled = map->cache_bypass; 529 + 530 + result = debugfs_write_file_bool(file, user_buf, count, ppos); 531 + if (result < 0) 532 + goto out; 533 + 534 + if (map->cache_bypass && !was_enabled) { 535 + dev_warn(map->dev, "debugfs cache_bypass=Y forced\n"); 536 + add_taint(TAINT_USER, LOCKDEP_STILL_OK); 537 + } else if (!map->cache_bypass && was_enabled) { 538 + dev_warn(map->dev, "debugfs cache_bypass=N forced\n"); 539 + } 540 + 541 + out: 542 + map->unlock(map->lock_arg); 543 + 544 + return result; 545 + } 546 + 547 + static const struct file_operations regmap_cache_bypass_fops = { 548 + .open = simple_open, 549 + .read = debugfs_read_file_bool, 550 + .write = regmap_cache_bypass_write_file, 551 + }; 552 + 472 553 void regmap_debugfs_init(struct regmap *map, const char *name) 473 554 { 474 555 struct rb_node *next; ··· 599 518 if (map->max_register || regmap_readable(map, 0)) { 600 519 umode_t registers_mode; 601 520 602 - if (IS_ENABLED(REGMAP_ALLOW_WRITE_DEBUGFS)) 603 - registers_mode = 0600; 604 - else 605 - registers_mode = 0400; 521 + #if defined(REGMAP_ALLOW_WRITE_DEBUGFS) 522 + registers_mode = 0600; 523 + #else 524 + registers_mode = 0400; 525 + #endif 606 526 607 527 debugfs_create_file("registers", registers_mode, map->debugfs, 608 528 map, &regmap_map_fops); ··· 612 530 } 613 531 614 532 if (map->cache_type) { 615 - debugfs_create_bool("cache_only", 0400, map->debugfs, 616 - &map->cache_only); 533 + debugfs_create_file("cache_only", 0600, map->debugfs, 534 + &map->cache_only, &regmap_cache_only_fops); 617 535 debugfs_create_bool("cache_dirty", 0400, map->debugfs, 618 536 &map->cache_dirty); 619 - debugfs_create_bool("cache_bypass", 0400, map->debugfs, 620 - &map->cache_bypass); 537 + debugfs_create_file("cache_bypass", 0600, map->debugfs, 538 + &map->cache_bypass, 539 + &regmap_cache_bypass_fops); 621 540 } 622 541 623 542 next = rb_first(&map->range_tree);
+63 -27
drivers/base/regmap/regmap-i2c.c
··· 209 209 .val_format_endian_default = REGMAP_ENDIAN_BIG, 210 210 }; 211 211 212 + static int regmap_i2c_smbus_i2c_write(void *context, const void *data, 213 + size_t count) 214 + { 215 + struct device *dev = context; 216 + struct i2c_client *i2c = to_i2c_client(dev); 217 + 218 + if (count < 1) 219 + return -EINVAL; 220 + if (count >= I2C_SMBUS_BLOCK_MAX) 221 + return -E2BIG; 222 + 223 + --count; 224 + return i2c_smbus_write_i2c_block_data(i2c, ((u8 *)data)[0], count, 225 + ((u8 *)data + 1)); 226 + } 227 + 228 + static int regmap_i2c_smbus_i2c_read(void *context, const void *reg, 229 + size_t reg_size, void *val, 230 + size_t val_size) 231 + { 232 + struct device *dev = context; 233 + struct i2c_client *i2c = to_i2c_client(dev); 234 + int ret; 235 + 236 + if (reg_size != 1 || val_size < 1) 237 + return -EINVAL; 238 + if (val_size >= I2C_SMBUS_BLOCK_MAX) 239 + return -E2BIG; 240 + 241 + ret = i2c_smbus_read_i2c_block_data(i2c, ((u8 *)reg)[0], val_size, val); 242 + if (ret == val_size) 243 + return 0; 244 + else if (ret < 0) 245 + return ret; 246 + else 247 + return -EIO; 248 + } 249 + 250 + static struct regmap_bus regmap_i2c_smbus_i2c_block = { 251 + .write = regmap_i2c_smbus_i2c_write, 252 + .read = regmap_i2c_smbus_i2c_read, 253 + .max_raw_read = I2C_SMBUS_BLOCK_MAX, 254 + .max_raw_write = I2C_SMBUS_BLOCK_MAX, 255 + }; 256 + 212 257 static const struct regmap_bus *regmap_get_i2c_bus(struct i2c_client *i2c, 213 258 const struct regmap_config *config) 214 259 { 215 260 if (i2c_check_functionality(i2c->adapter, I2C_FUNC_I2C)) 216 261 return &regmap_i2c; 262 + else if (config->reg_bits == 8 && 263 + i2c_check_functionality(i2c->adapter, 264 + I2C_FUNC_SMBUS_I2C_BLOCK)) 265 + return &regmap_i2c_smbus_i2c_block; 217 266 else if (config->val_bits == 16 && config->reg_bits == 8 && 218 267 i2c_check_functionality(i2c->adapter, 219 268 I2C_FUNC_SMBUS_WORD_DATA)) ··· 282 233 return ERR_PTR(-ENOTSUPP); 283 234 } 284 235 285 - /** 286 - * regmap_init_i2c(): Initialise register map 287 - * 288 - * @i2c: Device that will be interacted with 289 - * @config: Configuration for register map 290 - * 291 - * The return value will be an ERR_PTR() on error or a valid pointer to 292 - * a struct regmap. 293 - */ 294 - struct regmap *regmap_init_i2c(struct i2c_client *i2c, 295 - const struct regmap_config *config) 236 + struct regmap *__regmap_init_i2c(struct i2c_client *i2c, 237 + const struct regmap_config *config, 238 + struct lock_class_key *lock_key, 239 + const char *lock_name) 296 240 { 297 241 const struct regmap_bus *bus = regmap_get_i2c_bus(i2c, config); 298 242 299 243 if (IS_ERR(bus)) 300 244 return ERR_CAST(bus); 301 245 302 - return regmap_init(&i2c->dev, bus, &i2c->dev, config); 246 + return __regmap_init(&i2c->dev, bus, &i2c->dev, config, 247 + lock_key, lock_name); 303 248 } 304 - EXPORT_SYMBOL_GPL(regmap_init_i2c); 249 + EXPORT_SYMBOL_GPL(__regmap_init_i2c); 305 250 306 - /** 307 - * devm_regmap_init_i2c(): Initialise managed register map 308 - * 309 - * @i2c: Device that will be interacted with 310 - * @config: Configuration for register map 311 - * 312 - * The return value will be an ERR_PTR() on error or a valid pointer 313 - * to a struct regmap. The regmap will be automatically freed by the 314 - * device management code. 315 - */ 316 - struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c, 317 - const struct regmap_config *config) 251 + struct regmap *__devm_regmap_init_i2c(struct i2c_client *i2c, 252 + const struct regmap_config *config, 253 + struct lock_class_key *lock_key, 254 + const char *lock_name) 318 255 { 319 256 const struct regmap_bus *bus = regmap_get_i2c_bus(i2c, config); 320 257 321 258 if (IS_ERR(bus)) 322 259 return ERR_CAST(bus); 323 260 324 - return devm_regmap_init(&i2c->dev, bus, &i2c->dev, config); 261 + return __devm_regmap_init(&i2c->dev, bus, &i2c->dev, config, 262 + lock_key, lock_name); 325 263 } 326 - EXPORT_SYMBOL_GPL(devm_regmap_init_i2c); 264 + EXPORT_SYMBOL_GPL(__devm_regmap_init_i2c); 327 265 328 266 MODULE_LICENSE("GPL");
+2 -2
drivers/base/regmap/regmap-irq.c
··· 209 209 * Read in the statuses, using a single bulk read if possible 210 210 * in order to reduce the I/O overheads. 211 211 */ 212 - if (!map->use_single_rw && map->reg_stride == 1 && 212 + if (!map->use_single_read && map->reg_stride == 1 && 213 213 data->irq_reg_stride == 1) { 214 214 u8 *buf8 = data->status_reg_buf; 215 215 u16 *buf16 = data->status_reg_buf; ··· 398 398 else 399 399 d->irq_reg_stride = 1; 400 400 401 - if (!map->use_single_rw && map->reg_stride == 1 && 401 + if (!map->use_single_read && map->reg_stride == 1 && 402 402 d->irq_reg_stride == 1) { 403 403 d->status_reg_buf = kmalloc(map->format.val_bytes * 404 404 chip->num_regs, GFP_KERNEL);
+17 -33
drivers/base/regmap/regmap-mmio.c
··· 296 296 return ERR_PTR(ret); 297 297 } 298 298 299 - /** 300 - * regmap_init_mmio_clk(): Initialise register map with register clock 301 - * 302 - * @dev: Device that will be interacted with 303 - * @clk_id: register clock consumer ID 304 - * @regs: Pointer to memory-mapped IO region 305 - * @config: Configuration for register map 306 - * 307 - * The return value will be an ERR_PTR() on error or a valid pointer to 308 - * a struct regmap. 309 - */ 310 - struct regmap *regmap_init_mmio_clk(struct device *dev, const char *clk_id, 311 - void __iomem *regs, 312 - const struct regmap_config *config) 299 + struct regmap *__regmap_init_mmio_clk(struct device *dev, const char *clk_id, 300 + void __iomem *regs, 301 + const struct regmap_config *config, 302 + struct lock_class_key *lock_key, 303 + const char *lock_name) 313 304 { 314 305 struct regmap_mmio_context *ctx; 315 306 ··· 308 317 if (IS_ERR(ctx)) 309 318 return ERR_CAST(ctx); 310 319 311 - return regmap_init(dev, &regmap_mmio, ctx, config); 320 + return __regmap_init(dev, &regmap_mmio, ctx, config, 321 + lock_key, lock_name); 312 322 } 313 - EXPORT_SYMBOL_GPL(regmap_init_mmio_clk); 323 + EXPORT_SYMBOL_GPL(__regmap_init_mmio_clk); 314 324 315 - /** 316 - * devm_regmap_init_mmio_clk(): Initialise managed register map with clock 317 - * 318 - * @dev: Device that will be interacted with 319 - * @clk_id: register clock consumer ID 320 - * @regs: Pointer to memory-mapped IO region 321 - * @config: Configuration for register map 322 - * 323 - * The return value will be an ERR_PTR() on error or a valid pointer 324 - * to a struct regmap. The regmap will be automatically freed by the 325 - * device management code. 326 - */ 327 - struct regmap *devm_regmap_init_mmio_clk(struct device *dev, const char *clk_id, 328 - void __iomem *regs, 329 - const struct regmap_config *config) 325 + struct regmap *__devm_regmap_init_mmio_clk(struct device *dev, 326 + const char *clk_id, 327 + void __iomem *regs, 328 + const struct regmap_config *config, 329 + struct lock_class_key *lock_key, 330 + const char *lock_name) 330 331 { 331 332 struct regmap_mmio_context *ctx; 332 333 ··· 326 343 if (IS_ERR(ctx)) 327 344 return ERR_CAST(ctx); 328 345 329 - return devm_regmap_init(dev, &regmap_mmio, ctx, config); 346 + return __devm_regmap_init(dev, &regmap_mmio, ctx, config, 347 + lock_key, lock_name); 330 348 } 331 - EXPORT_SYMBOL_GPL(devm_regmap_init_mmio_clk); 349 + EXPORT_SYMBOL_GPL(__devm_regmap_init_mmio_clk); 332 350 333 351 MODULE_LICENSE("GPL v2");
+14 -27
drivers/base/regmap/regmap-spi.c
··· 113 113 .val_format_endian_default = REGMAP_ENDIAN_BIG, 114 114 }; 115 115 116 - /** 117 - * regmap_init_spi(): Initialise register map 118 - * 119 - * @spi: Device that will be interacted with 120 - * @config: Configuration for register map 121 - * 122 - * The return value will be an ERR_PTR() on error or a valid pointer to 123 - * a struct regmap. 124 - */ 125 - struct regmap *regmap_init_spi(struct spi_device *spi, 126 - const struct regmap_config *config) 116 + struct regmap *__regmap_init_spi(struct spi_device *spi, 117 + const struct regmap_config *config, 118 + struct lock_class_key *lock_key, 119 + const char *lock_name) 127 120 { 128 - return regmap_init(&spi->dev, &regmap_spi, &spi->dev, config); 121 + return __regmap_init(&spi->dev, &regmap_spi, &spi->dev, config, 122 + lock_key, lock_name); 129 123 } 130 - EXPORT_SYMBOL_GPL(regmap_init_spi); 124 + EXPORT_SYMBOL_GPL(__regmap_init_spi); 131 125 132 - /** 133 - * devm_regmap_init_spi(): Initialise register map 134 - * 135 - * @spi: Device that will be interacted with 136 - * @config: Configuration for register map 137 - * 138 - * The return value will be an ERR_PTR() on error or a valid pointer 139 - * to a struct regmap. The map will be automatically freed by the 140 - * device management code. 141 - */ 142 - struct regmap *devm_regmap_init_spi(struct spi_device *spi, 143 - const struct regmap_config *config) 126 + struct regmap *__devm_regmap_init_spi(struct spi_device *spi, 127 + const struct regmap_config *config, 128 + struct lock_class_key *lock_key, 129 + const char *lock_name) 144 130 { 145 - return devm_regmap_init(&spi->dev, &regmap_spi, &spi->dev, config); 131 + return __devm_regmap_init(&spi->dev, &regmap_spi, &spi->dev, config, 132 + lock_key, lock_name); 146 133 } 147 - EXPORT_SYMBOL_GPL(devm_regmap_init_spi); 134 + EXPORT_SYMBOL_GPL(__devm_regmap_init_spi); 148 135 149 136 MODULE_LICENSE("GPL");
+28 -50
drivers/base/regmap/regmap-spmi.c
··· 91 91 .val_format_endian_default = REGMAP_ENDIAN_NATIVE, 92 92 }; 93 93 94 - /** 95 - * regmap_init_spmi_base(): Create regmap for the Base register space 96 - * @sdev: SPMI device that will be interacted with 97 - * @config: Configuration for register map 98 - * 99 - * The return value will be an ERR_PTR() on error or a valid pointer to 100 - * a struct regmap. 101 - */ 102 - struct regmap *regmap_init_spmi_base(struct spmi_device *sdev, 103 - const struct regmap_config *config) 94 + struct regmap *__regmap_init_spmi_base(struct spmi_device *sdev, 95 + const struct regmap_config *config, 96 + struct lock_class_key *lock_key, 97 + const char *lock_name) 104 98 { 105 - return regmap_init(&sdev->dev, &regmap_spmi_base, sdev, config); 99 + return __regmap_init(&sdev->dev, &regmap_spmi_base, sdev, config, 100 + lock_key, lock_name); 106 101 } 107 - EXPORT_SYMBOL_GPL(regmap_init_spmi_base); 102 + EXPORT_SYMBOL_GPL(__regmap_init_spmi_base); 108 103 109 - /** 110 - * devm_regmap_init_spmi_base(): Create managed regmap for Base register space 111 - * @sdev: SPMI device that will be interacted with 112 - * @config: Configuration for register map 113 - * 114 - * The return value will be an ERR_PTR() on error or a valid pointer 115 - * to a struct regmap. The regmap will be automatically freed by the 116 - * device management code. 117 - */ 118 - struct regmap *devm_regmap_init_spmi_base(struct spmi_device *sdev, 119 - const struct regmap_config *config) 104 + struct regmap *__devm_regmap_init_spmi_base(struct spmi_device *sdev, 105 + const struct regmap_config *config, 106 + struct lock_class_key *lock_key, 107 + const char *lock_name) 120 108 { 121 - return devm_regmap_init(&sdev->dev, &regmap_spmi_base, sdev, config); 109 + return __devm_regmap_init(&sdev->dev, &regmap_spmi_base, sdev, config, 110 + lock_key, lock_name); 122 111 } 123 - EXPORT_SYMBOL_GPL(devm_regmap_init_spmi_base); 112 + EXPORT_SYMBOL_GPL(__devm_regmap_init_spmi_base); 124 113 125 114 static int regmap_spmi_ext_read(void *context, 126 115 const void *reg, size_t reg_size, ··· 211 222 .val_format_endian_default = REGMAP_ENDIAN_NATIVE, 212 223 }; 213 224 214 - /** 215 - * regmap_init_spmi_ext(): Create regmap for Ext register space 216 - * @sdev: Device that will be interacted with 217 - * @config: Configuration for register map 218 - * 219 - * The return value will be an ERR_PTR() on error or a valid pointer to 220 - * a struct regmap. 221 - */ 222 - struct regmap *regmap_init_spmi_ext(struct spmi_device *sdev, 223 - const struct regmap_config *config) 225 + struct regmap *__regmap_init_spmi_ext(struct spmi_device *sdev, 226 + const struct regmap_config *config, 227 + struct lock_class_key *lock_key, 228 + const char *lock_name) 224 229 { 225 - return regmap_init(&sdev->dev, &regmap_spmi_ext, sdev, config); 230 + return __regmap_init(&sdev->dev, &regmap_spmi_ext, sdev, config, 231 + lock_key, lock_name); 226 232 } 227 - EXPORT_SYMBOL_GPL(regmap_init_spmi_ext); 233 + EXPORT_SYMBOL_GPL(__regmap_init_spmi_ext); 228 234 229 - /** 230 - * devm_regmap_init_spmi_ext(): Create managed regmap for Ext register space 231 - * @sdev: SPMI device that will be interacted with 232 - * @config: Configuration for register map 233 - * 234 - * The return value will be an ERR_PTR() on error or a valid pointer 235 - * to a struct regmap. The regmap will be automatically freed by the 236 - * device management code. 237 - */ 238 - struct regmap *devm_regmap_init_spmi_ext(struct spmi_device *sdev, 239 - const struct regmap_config *config) 235 + struct regmap *__devm_regmap_init_spmi_ext(struct spmi_device *sdev, 236 + const struct regmap_config *config, 237 + struct lock_class_key *lock_key, 238 + const char *lock_name) 240 239 { 241 - return devm_regmap_init(&sdev->dev, &regmap_spmi_ext, sdev, config); 240 + return __devm_regmap_init(&sdev->dev, &regmap_spmi_ext, sdev, config, 241 + lock_key, lock_name); 242 242 } 243 - EXPORT_SYMBOL_GPL(devm_regmap_init_spmi_ext); 243 + EXPORT_SYMBOL_GPL(__devm_regmap_init_spmi_ext); 244 244 245 245 MODULE_LICENSE("GPL");
+230 -65
drivers/base/regmap/regmap.c
··· 18 18 #include <linux/of.h> 19 19 #include <linux/rbtree.h> 20 20 #include <linux/sched.h> 21 + #include <linux/delay.h> 21 22 22 23 #define CREATE_TRACE_POINTS 23 24 #include "trace.h" ··· 94 93 95 94 bool regmap_readable(struct regmap *map, unsigned int reg) 96 95 { 96 + if (!map->reg_read) 97 + return false; 98 + 97 99 if (map->max_register && reg > map->max_register) 98 100 return false; 99 101 ··· 519 515 } 520 516 EXPORT_SYMBOL_GPL(regmap_get_val_endian); 521 517 522 - /** 523 - * regmap_init(): Initialise register map 524 - * 525 - * @dev: Device that will be interacted with 526 - * @bus: Bus-specific callbacks to use with device 527 - * @bus_context: Data passed to bus-specific callbacks 528 - * @config: Configuration for register map 529 - * 530 - * The return value will be an ERR_PTR() on error or a valid pointer to 531 - * a struct regmap. This function should generally not be called 532 - * directly, it should be called by bus-specific init functions. 533 - */ 534 - struct regmap *regmap_init(struct device *dev, 535 - const struct regmap_bus *bus, 536 - void *bus_context, 537 - const struct regmap_config *config) 518 + struct regmap *__regmap_init(struct device *dev, 519 + const struct regmap_bus *bus, 520 + void *bus_context, 521 + const struct regmap_config *config, 522 + struct lock_class_key *lock_key, 523 + const char *lock_name) 538 524 { 539 525 struct regmap *map; 540 526 int ret = -EINVAL; ··· 550 556 spin_lock_init(&map->spinlock); 551 557 map->lock = regmap_lock_spinlock; 552 558 map->unlock = regmap_unlock_spinlock; 559 + lockdep_set_class_and_name(&map->spinlock, 560 + lock_key, lock_name); 553 561 } else { 554 562 mutex_init(&map->mutex); 555 563 map->lock = regmap_lock_mutex; 556 564 map->unlock = regmap_unlock_mutex; 565 + lockdep_set_class_and_name(&map->mutex, 566 + lock_key, lock_name); 557 567 } 558 568 map->lock_arg = map; 559 569 } ··· 571 573 map->reg_stride = config->reg_stride; 572 574 else 573 575 map->reg_stride = 1; 574 - map->use_single_rw = config->use_single_rw; 575 - map->can_multi_write = config->can_multi_write; 576 + map->use_single_read = config->use_single_rw || !bus || !bus->read; 577 + map->use_single_write = config->use_single_rw || !bus || !bus->write; 578 + map->can_multi_write = config->can_multi_write && bus && bus->write; 579 + if (bus) { 580 + map->max_raw_read = bus->max_raw_read; 581 + map->max_raw_write = bus->max_raw_write; 582 + } 576 583 map->dev = dev; 577 584 map->bus = bus; 578 585 map->bus_context = bus_context; ··· 766 763 if ((reg_endian != REGMAP_ENDIAN_BIG) || 767 764 (val_endian != REGMAP_ENDIAN_BIG)) 768 765 goto err_map; 769 - map->use_single_rw = true; 766 + map->use_single_write = true; 770 767 } 771 768 772 769 if (!map->format.format_write && ··· 902 899 err: 903 900 return ERR_PTR(ret); 904 901 } 905 - EXPORT_SYMBOL_GPL(regmap_init); 902 + EXPORT_SYMBOL_GPL(__regmap_init); 906 903 907 904 static void devm_regmap_release(struct device *dev, void *res) 908 905 { 909 906 regmap_exit(*(struct regmap **)res); 910 907 } 911 908 912 - /** 913 - * devm_regmap_init(): Initialise managed register map 914 - * 915 - * @dev: Device that will be interacted with 916 - * @bus: Bus-specific callbacks to use with device 917 - * @bus_context: Data passed to bus-specific callbacks 918 - * @config: Configuration for register map 919 - * 920 - * The return value will be an ERR_PTR() on error or a valid pointer 921 - * to a struct regmap. This function should generally not be called 922 - * directly, it should be called by bus-specific init functions. The 923 - * map will be automatically freed by the device management code. 924 - */ 925 - struct regmap *devm_regmap_init(struct device *dev, 926 - const struct regmap_bus *bus, 927 - void *bus_context, 928 - const struct regmap_config *config) 909 + struct regmap *__devm_regmap_init(struct device *dev, 910 + const struct regmap_bus *bus, 911 + void *bus_context, 912 + const struct regmap_config *config, 913 + struct lock_class_key *lock_key, 914 + const char *lock_name) 929 915 { 930 916 struct regmap **ptr, *regmap; 931 917 ··· 922 930 if (!ptr) 923 931 return ERR_PTR(-ENOMEM); 924 932 925 - regmap = regmap_init(dev, bus, bus_context, config); 933 + regmap = __regmap_init(dev, bus, bus_context, config, 934 + lock_key, lock_name); 926 935 if (!IS_ERR(regmap)) { 927 936 *ptr = regmap; 928 937 devres_add(dev, ptr); ··· 933 940 934 941 return regmap; 935 942 } 936 - EXPORT_SYMBOL_GPL(devm_regmap_init); 943 + EXPORT_SYMBOL_GPL(__devm_regmap_init); 937 944 938 945 static void regmap_field_init(struct regmap_field *rm_field, 939 946 struct regmap *regmap, struct reg_field reg_field) ··· 1375 1382 */ 1376 1383 bool regmap_can_raw_write(struct regmap *map) 1377 1384 { 1378 - return map->bus && map->format.format_val && map->format.format_reg; 1385 + return map->bus && map->bus->write && map->format.format_val && 1386 + map->format.format_reg; 1379 1387 } 1380 1388 EXPORT_SYMBOL_GPL(regmap_can_raw_write); 1389 + 1390 + /** 1391 + * regmap_get_raw_read_max - Get the maximum size we can read 1392 + * 1393 + * @map: Map to check. 1394 + */ 1395 + size_t regmap_get_raw_read_max(struct regmap *map) 1396 + { 1397 + return map->max_raw_read; 1398 + } 1399 + EXPORT_SYMBOL_GPL(regmap_get_raw_read_max); 1400 + 1401 + /** 1402 + * regmap_get_raw_write_max - Get the maximum size we can read 1403 + * 1404 + * @map: Map to check. 1405 + */ 1406 + size_t regmap_get_raw_write_max(struct regmap *map) 1407 + { 1408 + return map->max_raw_write; 1409 + } 1410 + EXPORT_SYMBOL_GPL(regmap_get_raw_write_max); 1381 1411 1382 1412 static int _regmap_bus_formatted_write(void *context, unsigned int reg, 1383 1413 unsigned int val) ··· 1571 1555 return -EINVAL; 1572 1556 if (val_len % map->format.val_bytes) 1573 1557 return -EINVAL; 1558 + if (map->max_raw_write && map->max_raw_write > val_len) 1559 + return -E2BIG; 1574 1560 1575 1561 map->lock(map->lock_arg); 1576 1562 ··· 1699 1681 { 1700 1682 int ret = 0, i; 1701 1683 size_t val_bytes = map->format.val_bytes; 1684 + size_t total_size = val_bytes * val_count; 1702 1685 1703 1686 if (map->bus && !map->format.parse_inplace) 1704 1687 return -EINVAL; ··· 1708 1689 1709 1690 /* 1710 1691 * Some devices don't support bulk write, for 1711 - * them we have a series of single write operations. 1692 + * them we have a series of single write operations in the first two if 1693 + * blocks. 1694 + * 1695 + * The first if block is used for memory mapped io. It does not allow 1696 + * val_bytes of 3 for example. 1697 + * The second one is used for busses which do not have this limitation 1698 + * and can write arbitrary value lengths. 1712 1699 */ 1713 - if (!map->bus || map->use_single_rw) { 1700 + if (!map->bus) { 1714 1701 map->lock(map->lock_arg); 1715 1702 for (i = 0; i < val_count; i++) { 1716 1703 unsigned int ival; ··· 1748 1723 } 1749 1724 out: 1750 1725 map->unlock(map->lock_arg); 1726 + } else if (map->use_single_write || 1727 + (map->max_raw_write && map->max_raw_write < total_size)) { 1728 + int chunk_stride = map->reg_stride; 1729 + size_t chunk_size = val_bytes; 1730 + size_t chunk_count = val_count; 1731 + 1732 + if (!map->use_single_write) { 1733 + chunk_size = map->max_raw_write; 1734 + if (chunk_size % val_bytes) 1735 + chunk_size -= chunk_size % val_bytes; 1736 + chunk_count = total_size / chunk_size; 1737 + chunk_stride *= chunk_size / val_bytes; 1738 + } 1739 + 1740 + map->lock(map->lock_arg); 1741 + /* Write as many bytes as possible with chunk_size */ 1742 + for (i = 0; i < chunk_count; i++) { 1743 + ret = _regmap_raw_write(map, 1744 + reg + (i * chunk_stride), 1745 + val + (i * chunk_size), 1746 + chunk_size); 1747 + if (ret) 1748 + break; 1749 + } 1750 + 1751 + /* Write remaining bytes */ 1752 + if (!ret && chunk_size * i < total_size) { 1753 + ret = _regmap_raw_write(map, reg + (i * chunk_stride), 1754 + val + (i * chunk_size), 1755 + total_size - i * chunk_size); 1756 + } 1757 + map->unlock(map->lock_arg); 1751 1758 } else { 1752 1759 void *wval; 1753 1760 ··· 1809 1752 * 1810 1753 * the (register,newvalue) pairs in regs have not been formatted, but 1811 1754 * they are all in the same page and have been changed to being page 1812 - * relative. The page register has been written if that was neccessary. 1755 + * relative. The page register has been written if that was necessary. 1813 1756 */ 1814 1757 static int _regmap_raw_multi_reg_write(struct regmap *map, 1815 1758 const struct reg_sequence *regs, ··· 1837 1780 u8 = buf; 1838 1781 1839 1782 for (i = 0; i < num_regs; i++) { 1840 - int reg = regs[i].reg; 1841 - int val = regs[i].def; 1783 + unsigned int reg = regs[i].reg; 1784 + unsigned int val = regs[i].def; 1842 1785 trace_regmap_hw_write_start(map, reg, 1); 1843 1786 map->format.format_reg(u8, reg, map->reg_shift); 1844 1787 u8 += reg_bytes + pad_bytes; ··· 1876 1819 int i, n; 1877 1820 struct reg_sequence *base; 1878 1821 unsigned int this_page = 0; 1822 + unsigned int page_change = 0; 1879 1823 /* 1880 1824 * the set of registers are not neccessarily in order, but 1881 1825 * since the order of write must be preserved this algorithm 1882 - * chops the set each time the page changes 1826 + * chops the set each time the page changes. This also applies 1827 + * if there is a delay required at any point in the sequence. 1883 1828 */ 1884 1829 base = regs; 1885 1830 for (i = 0, n = 0; i < num_regs; i++, n++) { ··· 1897 1838 this_page = win_page; 1898 1839 if (win_page != this_page) { 1899 1840 this_page = win_page; 1841 + page_change = 1; 1842 + } 1843 + } 1844 + 1845 + /* If we have both a page change and a delay make sure to 1846 + * write the regs and apply the delay before we change the 1847 + * page. 1848 + */ 1849 + 1850 + if (page_change || regs[i].delay_us) { 1851 + 1852 + /* For situations where the first write requires 1853 + * a delay we need to make sure we don't call 1854 + * raw_multi_reg_write with n=0 1855 + * This can't occur with page breaks as we 1856 + * never write on the first iteration 1857 + */ 1858 + if (regs[i].delay_us && i == 0) 1859 + n = 1; 1860 + 1900 1861 ret = _regmap_raw_multi_reg_write(map, base, n); 1901 1862 if (ret != 0) 1902 1863 return ret; 1864 + 1865 + if (regs[i].delay_us) 1866 + udelay(regs[i].delay_us); 1867 + 1903 1868 base += n; 1904 1869 n = 0; 1905 - } 1906 - ret = _regmap_select_page(map, &base[n].reg, range, 1); 1907 - if (ret != 0) 1908 - return ret; 1870 + 1871 + if (page_change) { 1872 + ret = _regmap_select_page(map, 1873 + &base[n].reg, 1874 + range, 1); 1875 + if (ret != 0) 1876 + return ret; 1877 + 1878 + page_change = 0; 1879 + } 1880 + 1909 1881 } 1882 + 1910 1883 } 1911 1884 if (n > 0) 1912 1885 return _regmap_raw_multi_reg_write(map, base, n); ··· 1957 1866 ret = _regmap_write(map, regs[i].reg, regs[i].def); 1958 1867 if (ret != 0) 1959 1868 return ret; 1869 + 1870 + if (regs[i].delay_us) 1871 + udelay(regs[i].delay_us); 1960 1872 } 1961 1873 return 0; 1962 1874 } ··· 1999 1905 for (i = 0; i < num_regs; i++) { 2000 1906 unsigned int reg = regs[i].reg; 2001 1907 struct regmap_range_node *range; 1908 + 1909 + /* Coalesce all the writes between a page break or a delay 1910 + * in a sequence 1911 + */ 2002 1912 range = _regmap_range_lookup(map, reg); 2003 - if (range) { 1913 + if (range || regs[i].delay_us) { 2004 1914 size_t len = sizeof(struct reg_sequence)*num_regs; 2005 1915 struct reg_sequence *base = kmemdup(regs, len, 2006 1916 GFP_KERNEL); ··· 2160 2062 2161 2063 /* 2162 2064 * Some buses or devices flag reads by setting the high bits in the 2163 - * register addresss; since it's always the high bits for all 2065 + * register address; since it's always the high bits for all 2164 2066 * current formats we can do this here rather than in 2165 2067 * formatting. This may break if we get interesting formats. 2166 2068 */ ··· 2206 2108 { 2207 2109 int ret; 2208 2110 void *context = _regmap_map_get_context(map); 2209 - 2210 - WARN_ON(!map->reg_read); 2211 2111 2212 2112 if (!map->cache_bypass) { 2213 2113 ret = regcache_read(map, reg, val); ··· 2287 2191 return -EINVAL; 2288 2192 if (reg % map->reg_stride) 2289 2193 return -EINVAL; 2194 + if (val_count == 0) 2195 + return -EINVAL; 2290 2196 2291 2197 map->lock(map->lock_arg); 2292 2198 2293 2199 if (regmap_volatile_range(map, reg, val_count) || map->cache_bypass || 2294 2200 map->cache_type == REGCACHE_NONE) { 2201 + if (!map->bus->read) { 2202 + ret = -ENOTSUPP; 2203 + goto out; 2204 + } 2205 + if (map->max_raw_read && map->max_raw_read < val_len) { 2206 + ret = -E2BIG; 2207 + goto out; 2208 + } 2209 + 2295 2210 /* Physical block read if there's no cache involved */ 2296 2211 ret = _regmap_raw_read(map, reg, val, val_len); 2297 2212 ··· 2411 2304 * Some devices does not support bulk read, for 2412 2305 * them we have a series of single read operations. 2413 2306 */ 2414 - if (map->use_single_rw) { 2415 - for (i = 0; i < val_count; i++) { 2416 - ret = regmap_raw_read(map, 2417 - reg + (i * map->reg_stride), 2418 - val + (i * val_bytes), 2419 - val_bytes); 2420 - if (ret != 0) 2421 - return ret; 2422 - } 2423 - } else { 2307 + size_t total_size = val_bytes * val_count; 2308 + 2309 + if (!map->use_single_read && 2310 + (!map->max_raw_read || map->max_raw_read > total_size)) { 2424 2311 ret = regmap_raw_read(map, reg, val, 2425 2312 val_bytes * val_count); 2426 2313 if (ret != 0) 2427 2314 return ret; 2315 + } else { 2316 + /* 2317 + * Some devices do not support bulk read or do not 2318 + * support large bulk reads, for them we have a series 2319 + * of read operations. 2320 + */ 2321 + int chunk_stride = map->reg_stride; 2322 + size_t chunk_size = val_bytes; 2323 + size_t chunk_count = val_count; 2324 + 2325 + if (!map->use_single_read) { 2326 + chunk_size = map->max_raw_read; 2327 + if (chunk_size % val_bytes) 2328 + chunk_size -= chunk_size % val_bytes; 2329 + chunk_count = total_size / chunk_size; 2330 + chunk_stride *= chunk_size / val_bytes; 2331 + } 2332 + 2333 + /* Read bytes that fit into a multiple of chunk_size */ 2334 + for (i = 0; i < chunk_count; i++) { 2335 + ret = regmap_raw_read(map, 2336 + reg + (i * chunk_stride), 2337 + val + (i * chunk_size), 2338 + chunk_size); 2339 + if (ret != 0) 2340 + return ret; 2341 + } 2342 + 2343 + /* Read remaining bytes */ 2344 + if (chunk_size * i < total_size) { 2345 + ret = regmap_raw_read(map, 2346 + reg + (i * chunk_stride), 2347 + val + (i * chunk_size), 2348 + total_size - i * chunk_size); 2349 + if (ret != 0) 2350 + return ret; 2351 + } 2428 2352 } 2429 2353 2430 2354 for (i = 0; i < val_count * val_bytes; i += val_bytes) ··· 2467 2329 &ival); 2468 2330 if (ret != 0) 2469 2331 return ret; 2470 - map->format.format_val(val + (i * val_bytes), ival, 0); 2332 + 2333 + if (map->format.format_val) { 2334 + map->format.format_val(val + (i * val_bytes), ival, 0); 2335 + } else { 2336 + /* Devices providing read and write 2337 + * operations can use the bulk I/O 2338 + * functions if they define a val_bytes, 2339 + * we assume that the values are native 2340 + * endian. 2341 + */ 2342 + u32 *u32 = val; 2343 + u16 *u16 = val; 2344 + u8 *u8 = val; 2345 + 2346 + switch (map->format.val_bytes) { 2347 + case 4: 2348 + u32[i] = ival; 2349 + break; 2350 + case 2: 2351 + u16[i] = ival; 2352 + break; 2353 + case 1: 2354 + u8[i] = ival; 2355 + break; 2356 + default: 2357 + return -EINVAL; 2358 + } 2359 + } 2471 2360 } 2472 2361 } 2473 2362
+1 -1
drivers/bus/vexpress-config.c
··· 107 107 if (!res) 108 108 return ERR_PTR(-ENOMEM); 109 109 110 - regmap = bridge->ops->regmap_init(dev, bridge->context); 110 + regmap = (bridge->ops->regmap_init)(dev, bridge->context); 111 111 if (IS_ERR(regmap)) { 112 112 devres_free(res); 113 113 return regmap;
+1 -1
drivers/regulator/core.c
··· 1262 1262 regulator->debugfs = debugfs_create_dir(regulator->supply_name, 1263 1263 rdev->debugfs); 1264 1264 if (!regulator->debugfs) { 1265 - rdev_warn(rdev, "Failed to create debugfs directory\n"); 1265 + rdev_dbg(rdev, "Failed to create debugfs directory\n"); 1266 1266 } else { 1267 1267 debugfs_create_u32("uA_load", 0444, regulator->debugfs, 1268 1268 &regulator->uA_load);
+1 -1
drivers/thermal/st/st_thermal.c
··· 214 214 215 215 sensor->ops = sensor->cdata->ops; 216 216 217 - ret = sensor->ops->regmap_init(sensor); 217 + ret = (sensor->ops->regmap_init)(sensor); 218 218 if (ret) 219 219 return ret; 220 220
+8 -6
fs/debugfs/file.c
··· 435 435 } 436 436 EXPORT_SYMBOL_GPL(debugfs_create_atomic_t); 437 437 438 - static ssize_t read_file_bool(struct file *file, char __user *user_buf, 439 - size_t count, loff_t *ppos) 438 + ssize_t debugfs_read_file_bool(struct file *file, char __user *user_buf, 439 + size_t count, loff_t *ppos) 440 440 { 441 441 char buf[3]; 442 442 u32 *val = file->private_data; ··· 449 449 buf[2] = 0x00; 450 450 return simple_read_from_buffer(user_buf, count, ppos, buf, 2); 451 451 } 452 + EXPORT_SYMBOL_GPL(debugfs_read_file_bool); 452 453 453 - static ssize_t write_file_bool(struct file *file, const char __user *user_buf, 454 - size_t count, loff_t *ppos) 454 + ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf, 455 + size_t count, loff_t *ppos) 455 456 { 456 457 char buf[32]; 457 458 size_t buf_size; ··· 469 468 470 469 return count; 471 470 } 471 + EXPORT_SYMBOL_GPL(debugfs_write_file_bool); 472 472 473 473 static const struct file_operations fops_bool = { 474 - .read = read_file_bool, 475 - .write = write_file_bool, 474 + .read = debugfs_read_file_bool, 475 + .write = debugfs_write_file_bool, 476 476 .open = simple_open, 477 477 .llseek = default_llseek, 478 478 };
+20
include/linux/debugfs.h
··· 116 116 117 117 bool debugfs_initialized(void); 118 118 119 + ssize_t debugfs_read_file_bool(struct file *file, char __user *user_buf, 120 + size_t count, loff_t *ppos); 121 + 122 + ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf, 123 + size_t count, loff_t *ppos); 124 + 119 125 #else 120 126 121 127 #include <linux/err.h> ··· 286 280 void *data)) 287 281 { 288 282 return ERR_PTR(-ENODEV); 283 + } 284 + 285 + static inline ssize_t debugfs_read_file_bool(struct file *file, 286 + char __user *user_buf, 287 + size_t count, loff_t *ppos) 288 + { 289 + return -ENODEV; 290 + } 291 + 292 + static inline ssize_t debugfs_write_file_bool(struct file *file, 293 + const char __user *user_buf, 294 + size_t count, loff_t *ppos) 295 + { 296 + return -ENODEV; 289 297 } 290 298 291 299 #endif
+307 -50
include/linux/regmap.h
··· 17 17 #include <linux/rbtree.h> 18 18 #include <linux/err.h> 19 19 #include <linux/bug.h> 20 + #include <linux/lockdep.h> 20 21 21 22 struct module; 22 23 struct device; ··· 52 51 }; 53 52 54 53 /** 55 - * Register/value pairs for sequences of writes 54 + * Register/value pairs for sequences of writes with an optional delay in 55 + * microseconds to be applied after each write. 56 56 * 57 57 * @reg: Register address. 58 58 * @def: Register value. 59 + * @delay_us: Delay to be applied after the register write in microseconds 59 60 */ 60 61 struct reg_sequence { 61 62 unsigned int reg; 62 63 unsigned int def; 64 + unsigned int delay_us; 63 65 }; 64 66 65 67 #ifdef CONFIG_REGMAP ··· 311 307 * if not implemented on a given device. 312 308 * @async_write: Write operation which completes asynchronously, optional and 313 309 * must serialise with respect to non-async I/O. 310 + * @reg_write: Write a single register value to the given register address. This 311 + * write operation has to complete when returning from the function. 314 312 * @read: Read operation. Data is returned in the buffer used to transmit 315 313 * data. 314 + * @reg_read: Read a single register value from a given register address. 315 + * @free_context: Free context. 316 316 * @async_alloc: Allocate a regmap_async() structure. 317 317 * @read_flag_mask: Mask to be set in the top byte of the register when doing 318 318 * a read. ··· 326 318 * @val_format_endian_default: Default endianness for formatted register 327 319 * values. Used when the regmap_config specifies DEFAULT. If this is 328 320 * DEFAULT, BIG is assumed. 329 - * @async_size: Size of struct used for async work. 321 + * @max_raw_read: Max raw read size that can be used on the bus. 322 + * @max_raw_write: Max raw write size that can be used on the bus. 330 323 */ 331 324 struct regmap_bus { 332 325 bool fast_io; ··· 342 333 u8 read_flag_mask; 343 334 enum regmap_endian reg_format_endian_default; 344 335 enum regmap_endian val_format_endian_default; 336 + size_t max_raw_read; 337 + size_t max_raw_write; 345 338 }; 346 339 347 - struct regmap *regmap_init(struct device *dev, 348 - const struct regmap_bus *bus, 349 - void *bus_context, 350 - const struct regmap_config *config); 340 + /* 341 + * __regmap_init functions. 342 + * 343 + * These functions take a lock key and name parameter, and should not be called 344 + * directly. Instead, use the regmap_init macros that generate a key and name 345 + * for each call. 346 + */ 347 + struct regmap *__regmap_init(struct device *dev, 348 + const struct regmap_bus *bus, 349 + void *bus_context, 350 + const struct regmap_config *config, 351 + struct lock_class_key *lock_key, 352 + const char *lock_name); 353 + struct regmap *__regmap_init_i2c(struct i2c_client *i2c, 354 + const struct regmap_config *config, 355 + struct lock_class_key *lock_key, 356 + const char *lock_name); 357 + struct regmap *__regmap_init_spi(struct spi_device *dev, 358 + const struct regmap_config *config, 359 + struct lock_class_key *lock_key, 360 + const char *lock_name); 361 + struct regmap *__regmap_init_spmi_base(struct spmi_device *dev, 362 + const struct regmap_config *config, 363 + struct lock_class_key *lock_key, 364 + const char *lock_name); 365 + struct regmap *__regmap_init_spmi_ext(struct spmi_device *dev, 366 + const struct regmap_config *config, 367 + struct lock_class_key *lock_key, 368 + const char *lock_name); 369 + struct regmap *__regmap_init_mmio_clk(struct device *dev, const char *clk_id, 370 + void __iomem *regs, 371 + const struct regmap_config *config, 372 + struct lock_class_key *lock_key, 373 + const char *lock_name); 374 + struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97, 375 + const struct regmap_config *config, 376 + struct lock_class_key *lock_key, 377 + const char *lock_name); 378 + 379 + struct regmap *__devm_regmap_init(struct device *dev, 380 + const struct regmap_bus *bus, 381 + void *bus_context, 382 + const struct regmap_config *config, 383 + struct lock_class_key *lock_key, 384 + const char *lock_name); 385 + struct regmap *__devm_regmap_init_i2c(struct i2c_client *i2c, 386 + const struct regmap_config *config, 387 + struct lock_class_key *lock_key, 388 + const char *lock_name); 389 + struct regmap *__devm_regmap_init_spi(struct spi_device *dev, 390 + const struct regmap_config *config, 391 + struct lock_class_key *lock_key, 392 + const char *lock_name); 393 + struct regmap *__devm_regmap_init_spmi_base(struct spmi_device *dev, 394 + const struct regmap_config *config, 395 + struct lock_class_key *lock_key, 396 + const char *lock_name); 397 + struct regmap *__devm_regmap_init_spmi_ext(struct spmi_device *dev, 398 + const struct regmap_config *config, 399 + struct lock_class_key *lock_key, 400 + const char *lock_name); 401 + struct regmap *__devm_regmap_init_mmio_clk(struct device *dev, 402 + const char *clk_id, 403 + void __iomem *regs, 404 + const struct regmap_config *config, 405 + struct lock_class_key *lock_key, 406 + const char *lock_name); 407 + struct regmap *__devm_regmap_init_ac97(struct snd_ac97 *ac97, 408 + const struct regmap_config *config, 409 + struct lock_class_key *lock_key, 410 + const char *lock_name); 411 + 412 + /* 413 + * Wrapper for regmap_init macros to include a unique lockdep key and name 414 + * for each call. No-op if CONFIG_LOCKDEP is not set. 415 + * 416 + * @fn: Real function to call (in the form __[*_]regmap_init[_*]) 417 + * @name: Config variable name (#config in the calling macro) 418 + **/ 419 + #ifdef CONFIG_LOCKDEP 420 + #define __regmap_lockdep_wrapper(fn, name, ...) \ 421 + ( \ 422 + ({ \ 423 + static struct lock_class_key _key; \ 424 + fn(__VA_ARGS__, &_key, \ 425 + KBUILD_BASENAME ":" \ 426 + __stringify(__LINE__) ":" \ 427 + "(" name ")->lock"); \ 428 + }) \ 429 + ) 430 + #else 431 + #define __regmap_lockdep_wrapper(fn, name, ...) fn(__VA_ARGS__, NULL, NULL) 432 + #endif 433 + 434 + /** 435 + * regmap_init(): Initialise register map 436 + * 437 + * @dev: Device that will be interacted with 438 + * @bus: Bus-specific callbacks to use with device 439 + * @bus_context: Data passed to bus-specific callbacks 440 + * @config: Configuration for register map 441 + * 442 + * The return value will be an ERR_PTR() on error or a valid pointer to 443 + * a struct regmap. This function should generally not be called 444 + * directly, it should be called by bus-specific init functions. 445 + */ 446 + #define regmap_init(dev, bus, bus_context, config) \ 447 + __regmap_lockdep_wrapper(__regmap_init, #config, \ 448 + dev, bus, bus_context, config) 351 449 int regmap_attach_dev(struct device *dev, struct regmap *map, 352 - const struct regmap_config *config); 353 - struct regmap *regmap_init_i2c(struct i2c_client *i2c, 354 - const struct regmap_config *config); 355 - struct regmap *regmap_init_spi(struct spi_device *dev, 356 - const struct regmap_config *config); 357 - struct regmap *regmap_init_spmi_base(struct spmi_device *dev, 358 - const struct regmap_config *config); 359 - struct regmap *regmap_init_spmi_ext(struct spmi_device *dev, 360 - const struct regmap_config *config); 361 - struct regmap *regmap_init_mmio_clk(struct device *dev, const char *clk_id, 362 - void __iomem *regs, 363 - const struct regmap_config *config); 364 - struct regmap *regmap_init_ac97(struct snd_ac97 *ac97, 365 - const struct regmap_config *config); 450 + const struct regmap_config *config); 366 451 367 - struct regmap *devm_regmap_init(struct device *dev, 368 - const struct regmap_bus *bus, 369 - void *bus_context, 370 - const struct regmap_config *config); 371 - struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c, 372 - const struct regmap_config *config); 373 - struct regmap *devm_regmap_init_spi(struct spi_device *dev, 374 - const struct regmap_config *config); 375 - struct regmap *devm_regmap_init_spmi_base(struct spmi_device *dev, 376 - const struct regmap_config *config); 377 - struct regmap *devm_regmap_init_spmi_ext(struct spmi_device *dev, 378 - const struct regmap_config *config); 379 - struct regmap *devm_regmap_init_mmio_clk(struct device *dev, const char *clk_id, 380 - void __iomem *regs, 381 - const struct regmap_config *config); 382 - struct regmap *devm_regmap_init_ac97(struct snd_ac97 *ac97, 383 - const struct regmap_config *config); 452 + /** 453 + * regmap_init_i2c(): Initialise register map 454 + * 455 + * @i2c: Device that will be interacted with 456 + * @config: Configuration for register map 457 + * 458 + * The return value will be an ERR_PTR() on error or a valid pointer to 459 + * a struct regmap. 460 + */ 461 + #define regmap_init_i2c(i2c, config) \ 462 + __regmap_lockdep_wrapper(__regmap_init_i2c, #config, \ 463 + i2c, config) 384 464 385 - bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); 465 + /** 466 + * regmap_init_spi(): Initialise register map 467 + * 468 + * @spi: Device that will be interacted with 469 + * @config: Configuration for register map 470 + * 471 + * The return value will be an ERR_PTR() on error or a valid pointer to 472 + * a struct regmap. 473 + */ 474 + #define regmap_init_spi(dev, config) \ 475 + __regmap_lockdep_wrapper(__regmap_init_spi, #config, \ 476 + dev, config) 477 + 478 + /** 479 + * regmap_init_spmi_base(): Create regmap for the Base register space 480 + * @sdev: SPMI device that will be interacted with 481 + * @config: Configuration for register map 482 + * 483 + * The return value will be an ERR_PTR() on error or a valid pointer to 484 + * a struct regmap. 485 + */ 486 + #define regmap_init_spmi_base(dev, config) \ 487 + __regmap_lockdep_wrapper(__regmap_init_spmi_base, #config, \ 488 + dev, config) 489 + 490 + /** 491 + * regmap_init_spmi_ext(): Create regmap for Ext register space 492 + * @sdev: Device that will be interacted with 493 + * @config: Configuration for register map 494 + * 495 + * The return value will be an ERR_PTR() on error or a valid pointer to 496 + * a struct regmap. 497 + */ 498 + #define regmap_init_spmi_ext(dev, config) \ 499 + __regmap_lockdep_wrapper(__regmap_init_spmi_ext, #config, \ 500 + dev, config) 501 + 502 + /** 503 + * regmap_init_mmio_clk(): Initialise register map with register clock 504 + * 505 + * @dev: Device that will be interacted with 506 + * @clk_id: register clock consumer ID 507 + * @regs: Pointer to memory-mapped IO region 508 + * @config: Configuration for register map 509 + * 510 + * The return value will be an ERR_PTR() on error or a valid pointer to 511 + * a struct regmap. 512 + */ 513 + #define regmap_init_mmio_clk(dev, clk_id, regs, config) \ 514 + __regmap_lockdep_wrapper(__regmap_init_mmio_clk, #config, \ 515 + dev, clk_id, regs, config) 386 516 387 517 /** 388 518 * regmap_init_mmio(): Initialise register map ··· 533 385 * The return value will be an ERR_PTR() on error or a valid pointer to 534 386 * a struct regmap. 535 387 */ 536 - static inline struct regmap *regmap_init_mmio(struct device *dev, 537 - void __iomem *regs, 538 - const struct regmap_config *config) 539 - { 540 - return regmap_init_mmio_clk(dev, NULL, regs, config); 541 - } 388 + #define regmap_init_mmio(dev, regs, config) \ 389 + regmap_init_mmio_clk(dev, NULL, regs, config) 390 + 391 + /** 392 + * regmap_init_ac97(): Initialise AC'97 register map 393 + * 394 + * @ac97: Device that will be interacted with 395 + * @config: Configuration for register map 396 + * 397 + * The return value will be an ERR_PTR() on error or a valid pointer to 398 + * a struct regmap. 399 + */ 400 + #define regmap_init_ac97(ac97, config) \ 401 + __regmap_lockdep_wrapper(__regmap_init_ac97, #config, \ 402 + ac97, config) 403 + bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); 404 + 405 + /** 406 + * devm_regmap_init(): Initialise managed register map 407 + * 408 + * @dev: Device that will be interacted with 409 + * @bus: Bus-specific callbacks to use with device 410 + * @bus_context: Data passed to bus-specific callbacks 411 + * @config: Configuration for register map 412 + * 413 + * The return value will be an ERR_PTR() on error or a valid pointer 414 + * to a struct regmap. This function should generally not be called 415 + * directly, it should be called by bus-specific init functions. The 416 + * map will be automatically freed by the device management code. 417 + */ 418 + #define devm_regmap_init(dev, bus, bus_context, config) \ 419 + __regmap_lockdep_wrapper(__devm_regmap_init, #config, \ 420 + dev, bus, bus_context, config) 421 + 422 + /** 423 + * devm_regmap_init_i2c(): Initialise managed register map 424 + * 425 + * @i2c: Device that will be interacted with 426 + * @config: Configuration for register map 427 + * 428 + * The return value will be an ERR_PTR() on error or a valid pointer 429 + * to a struct regmap. The regmap will be automatically freed by the 430 + * device management code. 431 + */ 432 + #define devm_regmap_init_i2c(i2c, config) \ 433 + __regmap_lockdep_wrapper(__devm_regmap_init_i2c, #config, \ 434 + i2c, config) 435 + 436 + /** 437 + * devm_regmap_init_spi(): Initialise register map 438 + * 439 + * @spi: Device that will be interacted with 440 + * @config: Configuration for register map 441 + * 442 + * The return value will be an ERR_PTR() on error or a valid pointer 443 + * to a struct regmap. The map will be automatically freed by the 444 + * device management code. 445 + */ 446 + #define devm_regmap_init_spi(dev, config) \ 447 + __regmap_lockdep_wrapper(__devm_regmap_init_spi, #config, \ 448 + dev, config) 449 + 450 + /** 451 + * devm_regmap_init_spmi_base(): Create managed regmap for Base register space 452 + * @sdev: SPMI device that will be interacted with 453 + * @config: Configuration for register map 454 + * 455 + * The return value will be an ERR_PTR() on error or a valid pointer 456 + * to a struct regmap. The regmap will be automatically freed by the 457 + * device management code. 458 + */ 459 + #define devm_regmap_init_spmi_base(dev, config) \ 460 + __regmap_lockdep_wrapper(__devm_regmap_init_spmi_base, #config, \ 461 + dev, config) 462 + 463 + /** 464 + * devm_regmap_init_spmi_ext(): Create managed regmap for Ext register space 465 + * @sdev: SPMI device that will be interacted with 466 + * @config: Configuration for register map 467 + * 468 + * The return value will be an ERR_PTR() on error or a valid pointer 469 + * to a struct regmap. The regmap will be automatically freed by the 470 + * device management code. 471 + */ 472 + #define devm_regmap_init_spmi_ext(dev, config) \ 473 + __regmap_lockdep_wrapper(__devm_regmap_init_spmi_ext, #config, \ 474 + dev, config) 475 + 476 + /** 477 + * devm_regmap_init_mmio_clk(): Initialise managed register map with clock 478 + * 479 + * @dev: Device that will be interacted with 480 + * @clk_id: register clock consumer ID 481 + * @regs: Pointer to memory-mapped IO region 482 + * @config: Configuration for register map 483 + * 484 + * The return value will be an ERR_PTR() on error or a valid pointer 485 + * to a struct regmap. The regmap will be automatically freed by the 486 + * device management code. 487 + */ 488 + #define devm_regmap_init_mmio_clk(dev, clk_id, regs, config) \ 489 + __regmap_lockdep_wrapper(__devm_regmap_init_mmio_clk, #config, \ 490 + dev, clk_id, regs, config) 542 491 543 492 /** 544 493 * devm_regmap_init_mmio(): Initialise managed register map ··· 648 403 * to a struct regmap. The regmap will be automatically freed by the 649 404 * device management code. 650 405 */ 651 - static inline struct regmap *devm_regmap_init_mmio(struct device *dev, 652 - void __iomem *regs, 653 - const struct regmap_config *config) 654 - { 655 - return devm_regmap_init_mmio_clk(dev, NULL, regs, config); 656 - } 406 + #define devm_regmap_init_mmio(dev, regs, config) \ 407 + devm_regmap_init_mmio_clk(dev, NULL, regs, config) 408 + 409 + /** 410 + * devm_regmap_init_ac97(): Initialise AC'97 register map 411 + * 412 + * @ac97: Device that will be interacted with 413 + * @config: Configuration for register map 414 + * 415 + * The return value will be an ERR_PTR() on error or a valid pointer 416 + * to a struct regmap. The regmap will be automatically freed by the 417 + * device management code. 418 + */ 419 + #define devm_regmap_init_ac97(ac97, config) \ 420 + __regmap_lockdep_wrapper(__devm_regmap_init_ac97, #config, \ 421 + ac97, config) 657 422 658 423 void regmap_exit(struct regmap *map); 659 424 int regmap_reinit_cache(struct regmap *map, ··· 705 450 int regmap_get_reg_stride(struct regmap *map); 706 451 int regmap_async_complete(struct regmap *map); 707 452 bool regmap_can_raw_write(struct regmap *map); 453 + size_t regmap_get_raw_read_max(struct regmap *map); 454 + size_t regmap_get_raw_write_max(struct regmap *map); 708 455 709 456 int regcache_sync(struct regmap *map); 710 457 int regcache_sync_region(struct regmap *map, unsigned int min,