From: Brian King <brking@linux.vnet.ibm.com>
To: gregkh@linuxfoundation.org
Cc: Brian King <brking@linux.vnet.ibm.com>,
mmc@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org,
linux-serial@vger.kernel.org, brking@pobox.com
Subject: [PATCH v2 2/6] hvcs: Use dev_groups to manage hvcs device attributes
Date: Thu, 2 Feb 2023 16:28:00 -0600 [thread overview]
Message-ID: <20230202222804.383229-3-brking@linux.vnet.ibm.com> (raw)
In-Reply-To: <20230202222804.383229-1-brking@linux.vnet.ibm.com>
Use the dev_groups functionality to manage the attribute groups
for hvcs devices. This simplifies the code and also eliminates
errors coming from kernfs when attempting to remove a console
device that is in use.
Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---
drivers/tty/hvc/hvcs.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index faf5ccfc561e..7f79444b4d89 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -432,7 +432,7 @@ static ssize_t hvcs_index_show(struct device *dev, struct device_attribute *attr
static DEVICE_ATTR(index, S_IRUGO, hvcs_index_show, NULL);
-static struct attribute *hvcs_attrs[] = {
+static struct attribute *hvcs_dev_attrs[] = {
&dev_attr_partner_vtys.attr,
&dev_attr_partner_clcs.attr,
&dev_attr_current_vty.attr,
@@ -441,8 +441,13 @@ static struct attribute *hvcs_attrs[] = {
NULL,
};
-static struct attribute_group hvcs_attr_group = {
- .attrs = hvcs_attrs,
+static struct attribute_group hvcs_attr_dev_group = {
+ .attrs = hvcs_dev_attrs,
+};
+
+const static struct attribute_group *hvcs_attr_dev_groups[] = {
+ &hvcs_attr_dev_group,
+ NULL,
};
static ssize_t rescan_show(struct device_driver *ddp, char *buf)
@@ -688,8 +693,6 @@ static void hvcs_destruct_port(struct tty_port *p)
spin_unlock_irqrestore(&hvcsd->lock, flags);
spin_unlock(&hvcs_structs_lock);
- sysfs_remove_group(&vdev->dev.kobj, &hvcs_attr_group);
-
kfree(hvcsd);
}
@@ -721,7 +724,6 @@ static int hvcs_probe(
{
struct hvcs_struct *hvcsd;
int index, rc;
- int retval;
if (!dev || !id) {
printk(KERN_ERR "HVCS: probed with invalid parameter.\n");
@@ -778,13 +780,6 @@ static int hvcs_probe(
list_add_tail(&(hvcsd->next), &hvcs_structs);
spin_unlock(&hvcs_structs_lock);
- retval = sysfs_create_group(&dev->dev.kobj, &hvcs_attr_group);
- if (retval) {
- printk(KERN_ERR "HVCS: Can't create sysfs attrs for vty-server@%X\n",
- hvcsd->vdev->unit_address);
- return retval;
- }
-
printk(KERN_INFO "HVCS: vty-server@%X added to the vio bus.\n", dev->unit_address);
/*
@@ -831,6 +826,9 @@ static struct vio_driver hvcs_vio_driver = {
.probe = hvcs_probe,
.remove = hvcs_remove,
.name = hvcs_driver_name,
+ .driver = {
+ .dev_groups = hvcs_attr_dev_groups,
+ },
};
/* Only called from hvcs_get_pi please */
--
2.31.1
next prev parent reply other threads:[~2023-02-02 22:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 22:27 [PATCH v2 0/6] hvcs: Various hvcs device hotplug fixes Brian King
2023-02-02 22:27 ` [PATCH v2 1/6] hvcs: Fix hvcs port reference counting Brian King
2023-02-03 5:10 ` Greg KH
2023-02-02 22:28 ` Brian King [this message]
2023-02-03 5:10 ` [PATCH v2 2/6] hvcs: Use dev_groups to manage hvcs device attributes Greg KH
2023-02-02 22:28 ` [PATCH v2 3/6] hvcs: Use driver groups to manage driver attributes Brian King
2023-02-03 5:11 ` Greg KH
2023-02-02 22:28 ` [PATCH v2 4/6] hvcs: Get reference to tty in remove Brian King
2023-02-02 22:28 ` [PATCH v2 5/6] hvcs: Use vhangup in hotplug remove Brian King
2023-02-02 22:28 ` [PATCH v2 6/6] hvcs: Synchronize hotplug remove with port free Brian King
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=20230202222804.383229-3-brking@linux.vnet.ibm.com \
--to=brking@linux.vnet.ibm.com \
--cc=brking@pobox.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-serial@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mmc@linux.vnet.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).