From: Sudeep Holla <sudeep.holla@arm.com>
To: op-tee@lists.trustedfirmware.org
Subject: [PATCH 2/2] tee: avoid explicit sysfs_create/delete_group by initialising dev->groups
Date: Tue, 01 Sep 2020 11:33:35 +0100 [thread overview]
Message-ID: <20200901103335.685-2-sudeep.holla@arm.com> (raw)
In-Reply-To: <20200901103335.685-1-sudeep.holla@arm.com>
[-- Attachment #1: Type: text/plain, Size: 1826 bytes --]
If the dev->groups is initialised, the sysfs group is created as part
of device_add call. There is no need to call sysfs_create/delete_group
explicitly.
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/tee/tee_core.c | 21 ++++-----------------
1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
index b4a8b362d78f..f77d64fafead 100644
--- a/drivers/tee/tee_core.c
+++ b/drivers/tee/tee_core.c
@@ -962,9 +962,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
@@ -984,6 +982,8 @@ int tee_device_register(struct tee_device *teedev)
return -EINVAL;
}
+ teedev->dev.groups = tee_dev_groups;
+
rc = cdev_device_add(&teedev->cdev, &teedev->dev);
if (rc) {
dev_err(&teedev->dev,
@@ -993,19 +993,8 @@ int tee_device_register(struct tee_device *teedev)
return rc;
}
- 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:
- cdev_device_del(&teedev->cdev, &teedev->dev);
- return rc;
}
EXPORT_SYMBOL_GPL(tee_device_register);
@@ -1048,10 +1037,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);
+ 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);
--
2.17.1
next prev parent reply other threads:[~2020-09-01 10:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-01 10:33 [PATCH 1/2] tee: replace cdev_add + device_add with cdev_device_add Sudeep Holla
2020-09-01 10:33 ` Sudeep Holla [this message]
2020-09-18 8:41 ` Jens Wiklander
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200901103335.685-2-sudeep.holla@arm.com \
--to=sudeep.holla@arm.com \
--cc=op-tee@lists.trustedfirmware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox