Unverified Commit 4c716711 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Mark Brown
Browse files

regulator: fixed-helper: Save a few bytes of memory when registering a 'nfc_llc' engine



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: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://msgid.link/r/3f990a7b80d72c31371735b24ed08acbb8392c80.1705748586.git.christophe.jaillet@wanadoo.fr


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent a6ffa02b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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;