Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

reset: fold ida_alloc() into reset_create_gpio_aux_device()

We don't need to know the IDA value outside of the function that creates
the auxiliary reset-gpio device. Simplify error handling by folding it
into reset_create_gpio_aux_device().

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

authored by

Bartosz Golaszewski and committed by
Philipp Zabel
6703784a 20adbf3b

+14 -15
+14 -15
drivers/reset/core.c
··· 824 824 } 825 825 826 826 static int reset_create_gpio_aux_device(struct reset_gpio_lookup *rgpio_dev, 827 - struct device *parent, int id) 827 + struct device *parent) 828 828 { 829 829 struct auxiliary_device *adev = &rgpio_dev->adev; 830 - int ret; 830 + int ret, id; 831 + 832 + id = ida_alloc(&reset_gpio_ida, GFP_KERNEL); 833 + if (id < 0) 834 + return -ENOMEM; 831 835 832 836 adev->id = id; 833 837 adev->name = "gpio"; ··· 841 837 device_set_node(&adev->dev, rgpio_dev->swnode); 842 838 843 839 ret = auxiliary_device_init(adev); 844 - if (ret) 840 + if (ret) { 841 + ida_free(&reset_gpio_ida, id); 845 842 return ret; 843 + } 846 844 847 845 ret = __auxiliary_device_add(adev, "reset"); 848 846 if (ret) { 849 847 auxiliary_device_uninit(adev); 848 + ida_free(&reset_gpio_ida, id); 850 849 return ret; 851 850 } 852 851 ··· 898 891 unsigned int offset, of_flags, lflags; 899 892 struct reset_gpio_lookup *rgpio_dev; 900 893 struct device *parent; 901 - int id, ret, prop = 0; 894 + int ret, prop = 0; 902 895 903 896 /* 904 897 * Currently only #gpio-cells=2 is supported with the meaning of: ··· 958 951 properties[prop++] = PROPERTY_ENTRY_STRING("compatible", "reset-gpio"); 959 952 properties[prop++] = PROPERTY_ENTRY_GPIO("reset-gpios", parent->fwnode, offset, lflags); 960 953 961 - id = ida_alloc(&reset_gpio_ida, GFP_KERNEL); 962 - if (id < 0) 963 - return id; 964 - 965 954 /* Not freed on success, because it is persisent subsystem data. */ 966 955 rgpio_dev = kzalloc_obj(*rgpio_dev); 967 - if (!rgpio_dev) { 968 - ret = -ENOMEM; 969 - goto err_ida_free; 970 - } 956 + if (!rgpio_dev) 957 + return -ENOMEM; 971 958 972 959 rgpio_dev->of_args = *args; 973 960 /* ··· 977 976 goto err_put_of_node; 978 977 } 979 978 980 - ret = reset_create_gpio_aux_device(rgpio_dev, parent, id); 979 + ret = reset_create_gpio_aux_device(rgpio_dev, parent); 981 980 if (ret) 982 981 goto err_del_swnode; 983 982 ··· 991 990 err_put_of_node: 992 991 of_node_put(rgpio_dev->of_args.np); 993 992 kfree(rgpio_dev); 994 - err_ida_free: 995 - ida_free(&reset_gpio_ida, id); 996 993 997 994 return ret; 998 995 }