siox: Provide a devm variant of siox_master_register()

This allows to simplify siox master drivers in the next step.

Acked-by: Thorsten Scherer <t.scherer@eckelmann.de>
Link: https://lore.kernel.org/r/e961dfb3e94f106b16f5eacff2110fc7fa0cab13.1708328466.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
This commit is contained in:
Uwe Kleine-König 2024-02-19 08:46:31 +01:00
parent 9ecfbf7053
commit 91d5bb579c
2 changed files with 21 additions and 0 deletions

View File

@ -795,6 +795,25 @@ void siox_master_unregister(struct siox_master *smaster)
} }
EXPORT_SYMBOL_GPL(siox_master_unregister); EXPORT_SYMBOL_GPL(siox_master_unregister);
static void devm_siox_master_unregister(void *data)
{
struct siox_master *smaster = data;
siox_master_unregister(smaster);
}
int devm_siox_master_register(struct device *dev, struct siox_master *smaster)
{
int ret;
ret = siox_master_register(smaster);
if (ret)
return ret;
return devm_add_action_or_reset(dev, devm_siox_master_unregister, smaster);
}
EXPORT_SYMBOL_GPL(devm_siox_master_register);
static struct siox_device *siox_device_add(struct siox_master *smaster, static struct siox_device *siox_device_add(struct siox_master *smaster,
const char *type, size_t inbytes, const char *type, size_t inbytes,
size_t outbytes, u8 statustype) size_t outbytes, u8 statustype)

View File

@ -49,3 +49,5 @@ struct siox_master *devm_siox_master_alloc(struct device *dev, size_t size);
int siox_master_register(struct siox_master *smaster); int siox_master_register(struct siox_master *smaster);
void siox_master_unregister(struct siox_master *smaster); void siox_master_unregister(struct siox_master *smaster);
int devm_siox_master_register(struct device *dev, struct siox_master *smaster);