Skip to content

Commit 27fef30

Browse files
andy-shevbroonie
authored andcommitted
regcache: flat: Remove unneeded check and error message for -ENOMEM
There is a convention in the kernel to avoid error messages in the cases of -ENOMEM errors. Besides that, the idea behind using struct_size() and other macros from overflow.h is to saturate the size that the following allocation call will definitely fail, hence the check and the error messaging added in regcache_flat_init() are redundant. Remove them. Acked-by: Sander Vanheule <sander@svanheule.net> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://patch.msgid.link/20251031080540.3970776-4-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent bda6f87 commit 27fef30

1 file changed

Lines changed: 1 addition & 9 deletions

File tree

drivers/base/regmap/regcache-flat.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,14 @@ struct regcache_flat_data {
3030
static int regcache_flat_init(struct regmap *map)
3131
{
3232
int i;
33-
size_t cache_data_size;
3433
unsigned int cache_size;
3534
struct regcache_flat_data *cache;
3635

3736
if (!map || map->reg_stride_order < 0 || !map->max_register_is_set)
3837
return -EINVAL;
3938

4039
cache_size = regcache_flat_get_index(map, map->max_register) + 1;
41-
cache_data_size = struct_size(cache, data, cache_size);
42-
43-
if (cache_data_size == SIZE_MAX) {
44-
dev_err(map->dev, "cannot allocate regmap cache");
45-
return -ENOMEM;
46-
}
47-
48-
cache = kzalloc(cache_data_size, map->alloc_flags);
40+
cache = kzalloc(struct_size(cache, data, cache_size), map->alloc_flags);
4941
if (!cache)
5042
return -ENOMEM;
5143

0 commit comments

Comments
 (0)