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

reset: mpfs: use the auxiliary device creation

The auxiliary device creation of this driver is simple enough to
use the available auxiliary device creation helper.

Use it and remove some boilerplate code.

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Link: https://lore.kernel.org/r/20250611-rst-mpfs-aux-v1-1-c86534b473c3@baylibre.com
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

authored by

Jerome Brunet and committed by
Philipp Zabel
9d33595c fd4a06a2

+5 -51
+5 -51
drivers/reset/reset-mpfs.c
··· 155 155 return devm_reset_controller_register(dev, rcdev); 156 156 } 157 157 158 - static void mpfs_reset_unregister_adev(void *_adev) 159 - { 160 - struct auxiliary_device *adev = _adev; 161 - 162 - auxiliary_device_delete(adev); 163 - auxiliary_device_uninit(adev); 164 - } 165 - 166 - static void mpfs_reset_adev_release(struct device *dev) 167 - { 168 - struct auxiliary_device *adev = to_auxiliary_dev(dev); 169 - 170 - kfree(adev); 171 - } 172 - 173 - static struct auxiliary_device *mpfs_reset_adev_alloc(struct device *clk_dev) 174 - { 175 - struct auxiliary_device *adev; 176 - int ret; 177 - 178 - adev = kzalloc(sizeof(*adev), GFP_KERNEL); 179 - if (!adev) 180 - return ERR_PTR(-ENOMEM); 181 - 182 - adev->name = "reset-mpfs"; 183 - adev->dev.parent = clk_dev; 184 - adev->dev.release = mpfs_reset_adev_release; 185 - adev->id = 666u; 186 - 187 - ret = auxiliary_device_init(adev); 188 - if (ret) { 189 - kfree(adev); 190 - return ERR_PTR(ret); 191 - } 192 - 193 - return adev; 194 - } 195 - 196 158 int mpfs_reset_controller_register(struct device *clk_dev, void __iomem *base) 197 159 { 198 160 struct auxiliary_device *adev; 199 - int ret; 200 161 201 - adev = mpfs_reset_adev_alloc(clk_dev); 202 - if (IS_ERR(adev)) 203 - return PTR_ERR(adev); 162 + adev = devm_auxiliary_device_create(clk_dev, "reset-mpfs", 163 + (__force void *)base); 164 + if (!adev) 165 + return -ENODEV; 204 166 205 - ret = auxiliary_device_add(adev); 206 - if (ret) { 207 - auxiliary_device_uninit(adev); 208 - return ret; 209 - } 210 - 211 - adev->dev.platform_data = (__force void *)base; 212 - 213 - return devm_add_action_or_reset(clk_dev, mpfs_reset_unregister_adev, adev); 167 + return 0; 214 168 } 215 169 EXPORT_SYMBOL_NS_GPL(mpfs_reset_controller_register, "MCHP_CLK_MPFS"); 216 170