Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 9b1fe05

Browse files
tititiou36broonie
authored andcommitted
regmap: Reorder fields in 'struct regmap_config' to save some memory
On x86_64 and allmodconfig, this shrinks the size of 'struct regmap_config' from 328 to 312 bytes. This is usually a win, because this structure is used as a static global variable. When moving the kerneldoc fields, I've tried to keep the layout as consistent as possible, which is not really easy! Before: /* size: 328, cachelines: 6, members: 55 */ /* sum members: 296, holes: 6, sum holes: 25 */ /* padding: 7 */ /* last cacheline: 8 bytes */ After: /* size: 312, cachelines: 5, members: 55 */ /* sum members: 296, holes: 5, sum holes: 16 */ /* last cacheline: 56 bytes */ For the records, this is also widely used: $git grep static.*regmap_config | wc -l 1327 Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/r/5e039cd8fe415dd7ab3169948c08a5311db9fb9a.1715024007.git.christophe.jaillet@wanadoo.fr Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 991b5e2 commit 9b1fe05

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

include/linux/regmap.h

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,6 @@ typedef void (*regmap_unlock)(void *);
297297
* performed on such table (a register is no increment
298298
* readable if it belongs to one of the ranges specified
299299
* by rd_noinc_table).
300-
* @disable_locking: This regmap is either protected by external means or
301-
* is guaranteed not to be accessed from multiple threads.
302-
* Don't use any locking mechanisms.
303-
* @lock: Optional lock callback (overrides regmap's default lock
304-
* function, based on spinlock or mutex).
305-
* @unlock: As above for unlocking.
306-
* @lock_arg: this field is passed as the only argument of lock/unlock
307-
* functions (ignored in case regular lock/unlock functions
308-
* are not overridden).
309300
* @reg_read: Optional callback that if filled will be used to perform
310301
* all the reads from the registers. Should only be provided for
311302
* devices whose read operation cannot be represented as a simple
@@ -323,6 +314,7 @@ typedef void (*regmap_unlock)(void *);
323314
* @write: Same as above for writing.
324315
* @max_raw_read: Max raw read size that can be used on the device.
325316
* @max_raw_write: Max raw write size that can be used on the device.
317+
* @can_sleep: Optional, specifies whether regmap operations can sleep.
326318
* @fast_io: Register IO is fast. Use a spinlock instead of a mutex
327319
* to perform locking. This field is ignored if custom lock/unlock
328320
* functions are used (see fields lock/unlock of struct regmap_config).
@@ -331,6 +323,15 @@ typedef void (*regmap_unlock)(void *);
331323
* Use it only for "no-bus" cases.
332324
* @io_port: Support IO port accessors. Makes sense only when MMIO vs. IO port
333325
* access can be distinguished.
326+
* @disable_locking: This regmap is either protected by external means or
327+
* is guaranteed not to be accessed from multiple threads.
328+
* Don't use any locking mechanisms.
329+
* @lock: Optional lock callback (overrides regmap's default lock
330+
* function, based on spinlock or mutex).
331+
* @unlock: As above for unlocking.
332+
* @lock_arg: This field is passed as the only argument of lock/unlock
333+
* functions (ignored in case regular lock/unlock functions
334+
* are not overridden).
334335
* @max_register: Optional, specifies the maximum valid register address.
335336
* @max_register_is_0: Optional, specifies that zero value in @max_register
336337
* should be taken into account. This is a workaround to
@@ -373,21 +374,20 @@ typedef void (*regmap_unlock)(void *);
373374
* @reg_defaults_raw: Power on reset values for registers (for use with
374375
* register cache support).
375376
* @num_reg_defaults_raw: Number of elements in reg_defaults_raw.
376-
* @reg_format_endian: Endianness for formatted register addresses. If this is
377-
* DEFAULT, the @reg_format_endian_default value from the
378-
* regmap bus is used.
379-
* @val_format_endian: Endianness for formatted register values. If this is
380-
* DEFAULT, the @reg_format_endian_default value from the
381-
* regmap bus is used.
382-
*
383-
* @ranges: Array of configuration entries for virtual address ranges.
384-
* @num_ranges: Number of range configuration entries.
385377
* @use_hwlock: Indicate if a hardware spinlock should be used.
386378
* @use_raw_spinlock: Indicate if a raw spinlock should be used.
387379
* @hwlock_id: Specify the hardware spinlock id.
388380
* @hwlock_mode: The hardware spinlock mode, should be HWLOCK_IRQSTATE,
389381
* HWLOCK_IRQ or 0.
390-
* @can_sleep: Optional, specifies whether regmap operations can sleep.
382+
* @reg_format_endian: Endianness for formatted register addresses. If this is
383+
* DEFAULT, the @reg_format_endian_default value from the
384+
* regmap bus is used.
385+
* @val_format_endian: Endianness for formatted register values. If this is
386+
* DEFAULT, the @reg_format_endian_default value from the
387+
* regmap bus is used.
388+
*
389+
* @ranges: Array of configuration entries for virtual address ranges.
390+
* @num_ranges: Number of range configuration entries.
391391
*/
392392
struct regmap_config {
393393
const char *name;
@@ -406,11 +406,6 @@ struct regmap_config {
406406
bool (*writeable_noinc_reg)(struct device *dev, unsigned int reg);
407407
bool (*readable_noinc_reg)(struct device *dev, unsigned int reg);
408408

409-
bool disable_locking;
410-
regmap_lock lock;
411-
regmap_unlock unlock;
412-
void *lock_arg;
413-
414409
int (*reg_read)(void *context, unsigned int reg, unsigned int *val);
415410
int (*reg_write)(void *context, unsigned int reg, unsigned int val);
416411
int (*reg_update_bits)(void *context, unsigned int reg,
@@ -422,9 +417,16 @@ struct regmap_config {
422417
size_t max_raw_read;
423418
size_t max_raw_write;
424419

420+
bool can_sleep;
421+
425422
bool fast_io;
426423
bool io_port;
427424

425+
bool disable_locking;
426+
regmap_lock lock;
427+
regmap_unlock unlock;
428+
void *lock_arg;
429+
428430
unsigned int max_register;
429431
bool max_register_is_0;
430432
const struct regmap_access_table *wr_table;
@@ -448,18 +450,16 @@ struct regmap_config {
448450
bool use_relaxed_mmio;
449451
bool can_multi_write;
450452

451-
enum regmap_endian reg_format_endian;
452-
enum regmap_endian val_format_endian;
453-
454-
const struct regmap_range_cfg *ranges;
455-
unsigned int num_ranges;
456-
457453
bool use_hwlock;
458454
bool use_raw_spinlock;
459455
unsigned int hwlock_id;
460456
unsigned int hwlock_mode;
461457

462-
bool can_sleep;
458+
enum regmap_endian reg_format_endian;
459+
enum regmap_endian val_format_endian;
460+
461+
const struct regmap_range_cfg *ranges;
462+
unsigned int num_ranges;
463463
};
464464

465465
/**

0 commit comments

Comments
 (0)