Simplify tee_device_register() and friends
Uses cdev_device_add() instead of the cdev_add() device_add() combination. Initializes dev->groups instead of direct calls to sysfs_create_group() and friends. -----BEGIN PGP SIGNATURE----- iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAl9kdqUaHGplbnMud2lr bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJcnsBAAysa3ggeat7K/Y8Sw9Ewh J5Kxbvn3BQ0DXOlOtrQIuNcRr4kSmJWCPJ8E0IxiB2q01QLldOFqwE0zOKDmWYb9 eGe/CuDlbFM2vbaTrPfXX6uhCjWd5VexF2K11oJc9TuH5u/ZEycGIO+/BRE7u758 YY5puPwP82wbDesR+sDg7/115aRJ36fQFwWMm4LRCd8fLtrFgB6RSngdBxLr+Ue7 Bya9+fmHsBhlUCBOvxCoFOy/PLMruYzJwXg0IFt+V7SDS+1KPErdn6TTCIeWeWbX oYPn07bChU5/pdAi6gch9y5WUesG7mRnN8m58A3G3Cg6WFr4RZKJqIFYLb3R+z26 RCLWmhf3ldqF/a3KW/UBuTXRwFZB0WnxuAhBgptkvYAxyC2/qEfjTnXdXLiIP+2F 0HWtEaPU1rkZWLHEjsw3H8hVLGcwBNSTS8k6qtDI17pLoWFQ794u9OrRiMhtiOlz wcdhzWjSkQcFL3Wiq3I+eYmzIMtnRVqFbisEBMR5iB+0fYznEtIKNJHassivsdxf 7njcHo+jQ0ayEOIft/v+Ob13U8fIrC3dVdPVDNSE5rzH2FcTL9eEqSfdhaqicoLv 7OqfmCOZQ7b9uvbPWV2ils3BKF679g5iRcrqQr6193V8TxRNIlScuqWTsBVzd+Vd Q4ecnuA/1BA1j2bz5uB8ZP8= =Knzl -----END PGP SIGNATURE----- Merge tag 'tee-dev-cleanup-for-v5.10' of git://git.linaro.org:/people/jens.wiklander/linux-tee into arm/drivers Simplify tee_device_register() and friends Uses cdev_device_add() instead of the cdev_add() device_add() combination. Initializes dev->groups instead of direct calls to sysfs_create_group() and friends. * tag 'tee-dev-cleanup-for-v5.10' of git://git.linaro.org:/people/jens.wiklander/linux-tee: tee: avoid explicit sysfs_create/delete_group by initialising dev->groups tee: replace cdev_add + device_add with cdev_device_add Link: https://lore.kernel.org/r/20200918144130.GB1219771@jade Signed-off-by: Olof Johansson <olof@lixom.net>
This commit is contained in:
Коммит
5746b3b886
|
@ -930,7 +930,6 @@ struct tee_device *tee_device_alloc(const struct tee_desc *teedesc,
|
|||
|
||||
cdev_init(&teedev->cdev, &tee_fops);
|
||||
teedev->cdev.owner = teedesc->owner;
|
||||
teedev->cdev.kobj.parent = &teedev->dev.kobj;
|
||||
|
||||
dev_set_drvdata(&teedev->dev, driver_data);
|
||||
device_initialize(&teedev->dev);
|
||||
|
@ -976,9 +975,7 @@ static struct attribute *tee_dev_attrs[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
static const struct attribute_group tee_dev_group = {
|
||||
.attrs = tee_dev_attrs,
|
||||
};
|
||||
ATTRIBUTE_GROUPS(tee_dev);
|
||||
|
||||
/**
|
||||
* tee_device_register() - Registers a TEE device
|
||||
|
@ -998,39 +995,19 @@ int tee_device_register(struct tee_device *teedev)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = cdev_add(&teedev->cdev, teedev->dev.devt, 1);
|
||||
teedev->dev.groups = tee_dev_groups;
|
||||
|
||||
rc = cdev_device_add(&teedev->cdev, &teedev->dev);
|
||||
if (rc) {
|
||||
dev_err(&teedev->dev,
|
||||
"unable to cdev_add() %s, major %d, minor %d, err=%d\n",
|
||||
"unable to cdev_device_add() %s, major %d, minor %d, err=%d\n",
|
||||
teedev->name, MAJOR(teedev->dev.devt),
|
||||
MINOR(teedev->dev.devt), rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = device_add(&teedev->dev);
|
||||
if (rc) {
|
||||
dev_err(&teedev->dev,
|
||||
"unable to device_add() %s, major %d, minor %d, err=%d\n",
|
||||
teedev->name, MAJOR(teedev->dev.devt),
|
||||
MINOR(teedev->dev.devt), rc);
|
||||
goto err_device_add;
|
||||
}
|
||||
|
||||
rc = sysfs_create_group(&teedev->dev.kobj, &tee_dev_group);
|
||||
if (rc) {
|
||||
dev_err(&teedev->dev,
|
||||
"failed to create sysfs attributes, err=%d\n", rc);
|
||||
goto err_sysfs_create_group;
|
||||
}
|
||||
|
||||
teedev->flags |= TEE_DEVICE_FLAG_REGISTERED;
|
||||
return 0;
|
||||
|
||||
err_sysfs_create_group:
|
||||
device_del(&teedev->dev);
|
||||
err_device_add:
|
||||
cdev_del(&teedev->cdev);
|
||||
return rc;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(tee_device_register);
|
||||
|
||||
|
@ -1073,11 +1050,8 @@ void tee_device_unregister(struct tee_device *teedev)
|
|||
if (!teedev)
|
||||
return;
|
||||
|
||||
if (teedev->flags & TEE_DEVICE_FLAG_REGISTERED) {
|
||||
sysfs_remove_group(&teedev->dev.kobj, &tee_dev_group);
|
||||
cdev_del(&teedev->cdev);
|
||||
device_del(&teedev->dev);
|
||||
}
|
||||
if (teedev->flags & TEE_DEVICE_FLAG_REGISTERED)
|
||||
cdev_device_del(&teedev->cdev, &teedev->dev);
|
||||
|
||||
tee_device_put(teedev);
|
||||
wait_for_completion(&teedev->c_no_users);
|
||||
|
|
Загрузка…
Ссылка в новой задаче