regmap: Drop CONFIG_64BIT checks from core
Subsystems (2)
RFC PATCH 1/1 regmap: Drop CONFIG_64BIT checks from core
Drop the CONFIG_64BIT checks from core regmap code, as it is well possible to access e.g. an SPI device with 64bit registers from a 32bit CPU. The CONFIG_64BIT checks are still left in place in the regmap mmio code however.
--- drivers/base/regmap/regcache.c | 4 ---- drivers/base/regmap/regmap.c | 14 -------------- 2 files changed, 18 deletions(-)
drivers/base/regmap/regcache.c +0 -4
@@ -577,14 +577,12 @@ bool regcache_set_val(struct regmap *map, void *base, unsigned int idx, cache[idx] = val;break ; } -#ifdef CONFIG_64BIT case 8 : {u64 *cache = base; cache[idx] = val;break ; } -#endif default :BUG (); }
@@ -618,13 +616,11 @@ unsigned int regcache_get_val(struct regmap *map, const void *base,return cache[idx]; } -#ifdef CONFIG_64BIT case 8 : {const u64 *cache = base;return cache[idx]; } -#endif default :BUG (); }
drivers/base/regmap/regmap.c +0 -14
@@ -298,7 +298,6 @@ static void regmap_format_32_native(void *buf, unsigned int val, *(u32 *)buf = val << shift; } -#ifdef CONFIG_64BIT static void regmap_format_64_be (void *buf,unsigned int val,unsigned int shift) {__be64 *b = buf;
@@ -318,7 +317,6 @@ static void regmap_format_64_native(void *buf, unsigned int val, { *(u64 *)buf = (u64 )val << shift; } -#endif static void regmap_parse_inplace_noop (void *buf) {
@@ -407,7 +405,6 @@ static unsigned int regmap_parse_32_native(const void *buf)return *(u32 *)buf; } -#ifdef CONFIG_64BIT static unsigned int regmap_parse_64_be (const void *buf) {const __be64 *b = buf;
@@ -440,7 +437,6 @@ static unsigned int regmap_parse_64_native(const void *buf) {return *(u64 *)buf; } -#endif static void regmap_lock_hwlock (void *__map) {
@@ -921,7 +917,6 @@ struct regmap *__regmap_init(struct device *dev, }break ; -#ifdef CONFIG_64BIT case 64 :switch (reg_endian) {case REGMAP_ENDIAN_BIG :
@@ -937,7 +932,6 @@ struct regmap *__regmap_init(struct device *dev, goto err_hwlock; }break ; -#endif default : goto err_hwlock;
@@ -998,7 +992,6 @@ struct regmap *__regmap_init(struct device *dev, goto err_hwlock; }break ; -#ifdef CONFIG_64BIT case 64 :switch (val_endian) {case REGMAP_ENDIAN_BIG :
@@ -1019,7 +1012,6 @@ struct regmap *__regmap_init(struct device *dev, goto err_hwlock; }break ; -#endif }if (map->format.format_write) {
@@ -2081,11 +2073,9 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,case 4 : ival = *(u32 *)(val + (i * val_bytes));break ; -#ifdef CONFIG_64BIT case 8 : ival = *(u64 *)(val + (i * val_bytes));break ; -#endif default : ret = -EINVAL ; goto out;
@@ -2809,9 +2799,7 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,for (i =0 ; i < val_count * val_bytes; i += val_bytes) map->format.parse_inplace (val + i); }else { -#ifdef CONFIG_64BIT u64 *u64 = val; -#endif u32 *u32 = val;u16 *u16 = val;u8 *u8 = val;
@@ -2827,11 +2815,9 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, goto out;switch (map->format.val_bytes) { -#ifdef CONFIG_64BIT case 8 : u64[i] = ival;break ; -#endif case 4 : u32[i] = ival;break ;
Signature · 1 line
2.20.1
Mark Brown
maintainerQuoted 4 lines · Marek Vasut
Drop the
CONFIG_64BITchecks from core regmap code, as it is well possible to access e.g. an SPI device with 64bit registers from a 32bit CPU. TheCONFIG_64BITchecks are still left in place in the regmap mmio code however.
The issue with 8 bit registers was that we use unsigned long for addresses and values and a 64 bit value won't fit in those on a 32 bit system. Some of the bulk APIs will work but things like individual register writes and the caches will have problems.
Quoted 7 lines · Mark Brown
Quoted 4 lines · Marek Vasut
Drop the
CONFIG_64BITchecks from core regmap code, as it is well possible to access e.g. an SPI device with 64bit registers from a 32bit CPU. TheCONFIG_64BITchecks are still left in place in the regmap mmio code however.The issue with 8 bit
byte
Quoted 4 lines
registers was that we use unsigned long for
addresses and values and a 64 bit value won't fit in those on a 32 bit system. Some of the bulk APIs will work but things like individual register writes and the caches will have problems.
Good thing I sent this as RFC, I realized that shortly after too.
So, what would be the suggestion here ?
Signature · 2 lines
Best regards, Marek Vasut
Mark Brown
maintainerQuoted 10 lines · Marek Vasut
Quoted 4 lines · Mark Brown
registers was that we use unsigned long for
addresses and values and a 64 bit value won't fit in those on a 32 bit system. Some of the bulk APIs will work but things like individual register writes and the caches will have problems.Good thing I sent this as RFC, I realized that shortly after too.
So, what would be the suggestion here ?
I think if I had any really good ideas I'd have done it at the time :/ Converting to unsigned long long is going to hurt performance for the common case but it'd probably be what we need to do, I think we'd need to have some sort of preprocessor fun and build two copies of the code with a 64 bit clean version available for devices that need it which is ugly but bleh. It's how we handle similar issues with zlib.