Commit e3749aae authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Jonathan Cameron
Browse files

iio: adc: at91: simplify with cleanup.h



Allocate the memory with scoped/cleanup.h to reduce error handling and
make the code a bit simpler.

Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240705-cleanup-h-iio-v1-3-77114c7e84c5@linaro.org


Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent c74f7c09
Loading
Loading
Loading
Loading
+5 −8
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@

#include <linux/bitmap.h>
#include <linux/bitops.h>
#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/io.h>
@@ -541,8 +542,7 @@ static int at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
	int i;

	for (i = 0; i < st->caps->trigger_number; i++) {
		char *name = kasprintf(GFP_KERNEL,
				"%s-dev%d-%s",
		char *name __free(kfree) = kasprintf(GFP_KERNEL, "%s-dev%d-%s",
						     idev->name,
						     iio_device_id(idev),
						     triggers[i].name);
@@ -550,13 +550,10 @@ static int at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
			return -ENOMEM;

		if (strcmp(trigger_name, name) == 0) {
			kfree(name);
			if (triggers[i].value == 0)
				return -EINVAL;
			return triggers[i].value;
		}

		kfree(name);
	}

	return -EINVAL;