regulator: fixed-helper: Save a few bytes of memory when registering a 'nfc_llc'...
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 20 Jan 2024 11:03:26 +0000 (12:03 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 22 Jan 2024 17:56:32 +0000 (17:56 +0000)
regulator_register_always_on() calls pass a string literal as the 'name'
parameter.

So kstrdup_const() can be used instead of kfree() to avoid a memory
allocation in such cases.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://msgid.link/r/3f990a7b80d72c31371735b24ed08acbb8392c80.1705748586.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/fixed-helper.c

index 0eb2442456f0c7a8c246743ea4aa023cad0c6450..2d5a42b2b3d801e11fc97befd1e077a779b285bc 100644 (file)
@@ -15,7 +15,7 @@ static void regulator_fixed_release(struct device *dev)
 {
        struct fixed_regulator_data *data = container_of(dev,
                        struct fixed_regulator_data, pdev.dev);
-       kfree(data->cfg.supply_name);
+       kfree_const(data->cfg.supply_name);
        kfree(data);
 }
 
@@ -36,7 +36,7 @@ struct platform_device *regulator_register_always_on(int id, const char *name,
        if (!data)
                return NULL;
 
-       data->cfg.supply_name = kstrdup(name, GFP_KERNEL);
+       data->cfg.supply_name = kstrdup_const(name, GFP_KERNEL);
        if (!data->cfg.supply_name) {
                kfree(data);
                return NULL;