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

platform: arm64: lenovo-yoga-c630: use the auxiliary device creation helper

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.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Link: https://lore.kernel.org/r/20250610-yoga-aux-v1-1-d6115aa1683c@baylibre.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Jerome Brunet and committed by
Ilpo Järvinen
d2b16853 dce77641

+3 -37
+3 -37
drivers/platform/arm64/lenovo-yoga-c630.c
··· 191 191 } 192 192 EXPORT_SYMBOL_GPL(yoga_c630_ec_unregister_notify); 193 193 194 - static void yoga_c630_aux_release(struct device *dev) 195 - { 196 - struct auxiliary_device *adev = to_auxiliary_dev(dev); 197 - 198 - kfree(adev); 199 - } 200 - 201 - static void yoga_c630_aux_remove(void *data) 202 - { 203 - struct auxiliary_device *adev = data; 204 - 205 - auxiliary_device_delete(adev); 206 - auxiliary_device_uninit(adev); 207 - } 208 - 209 194 static int yoga_c630_aux_init(struct device *parent, const char *name, 210 195 struct yoga_c630_ec *ec) 211 196 { 212 197 struct auxiliary_device *adev; 213 - int ret; 214 198 215 - adev = kzalloc(sizeof(*adev), GFP_KERNEL); 199 + adev = devm_auxiliary_device_create(parent, name, ec); 216 200 if (!adev) 217 - return -ENOMEM; 201 + return -ENODEV; 218 202 219 - adev->name = name; 220 - adev->id = 0; 221 - adev->dev.parent = parent; 222 - adev->dev.release = yoga_c630_aux_release; 223 - adev->dev.platform_data = ec; 224 - 225 - ret = auxiliary_device_init(adev); 226 - if (ret) { 227 - kfree(adev); 228 - return ret; 229 - } 230 - 231 - ret = auxiliary_device_add(adev); 232 - if (ret) { 233 - auxiliary_device_uninit(adev); 234 - return ret; 235 - } 236 - 237 - return devm_add_action_or_reset(parent, yoga_c630_aux_remove, adev); 203 + return 0; 238 204 } 239 205 240 206 static int yoga_c630_ec_probe(struct i2c_client *client)