public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Kirti Wankhede <kwankhede@nvidia.com>,
	Tony Krowiak <akrowiak@linux.ibm.com>,
	Halil Pasic <pasic@linux.ibm.com>,
	Jason Herne <jjherne@linux.ibm.com>,
	Eric Farman <farman@linux.ibm.com>,
	Matthew Rosato <mjrosato@linux.ibm.com>,
	Zhenyu Wang <zhenyuw@linux.intel.com>,
	Zhi Wang <zhi.a.wang@intel.com>,
	Alex Williamson <alex.williamson@redhat.com>
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	intel-gvt-dev@lists.freedesktop.org
Subject: [PATCH 4/8] vfio/mdev: remove mdev_{create,remove}_sysfs_files
Date: Fri,  3 Jun 2022 08:33:24 +0200	[thread overview]
Message-ID: <20220603063328.3715-5-hch@lst.de> (raw)
In-Reply-To: <20220603063328.3715-1-hch@lst.de>

Just fold these two trivial helpers into their only callers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/vfio/mdev/mdev_core.c    | 12 ++++++++++--
 drivers/vfio/mdev/mdev_private.h |  3 ---
 drivers/vfio/mdev/mdev_sysfs.c   | 28 ----------------------------
 3 files changed, 10 insertions(+), 33 deletions(-)

diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
index ff38c9549a55e..34b01d45cfe9f 100644
--- a/drivers/vfio/mdev/mdev_core.c
+++ b/drivers/vfio/mdev/mdev_core.c
@@ -46,7 +46,8 @@ static void mdev_device_remove_common(struct mdev_device *mdev)
 {
 	struct mdev_parent *parent = mdev->type->parent;
 
-	mdev_remove_sysfs_files(mdev);
+	sysfs_remove_link(&mdev->dev.kobj, "mdev_type");
+	sysfs_remove_link(mdev->type->devices_kobj, dev_name(&mdev->dev));
 	device_del(&mdev->dev);
 	lockdep_assert_held(&parent->unreg_sem);
 	/* Balances with device_initialize() */
@@ -193,16 +194,23 @@ int mdev_device_create(struct mdev_type *type, const guid_t *uuid)
 	if (ret)
 		goto out_del;
 
-	ret = mdev_create_sysfs_files(mdev);
+	ret = sysfs_create_link(type->devices_kobj, &mdev->dev.kobj,
+				dev_name(&mdev->dev));
 	if (ret)
 		goto out_del;
 
+	ret = sysfs_create_link(&mdev->dev.kobj, &type->kobj, "mdev_type");
+	if (ret)
+		goto out_remove_type_link;
+
 	mdev->active = true;
 	dev_dbg(&mdev->dev, "MDEV: created\n");
 	up_read(&parent->unreg_sem);
 
 	return 0;
 
+out_remove_type_link:
+	sysfs_remove_link(mdev->type->devices_kobj, dev_name(&mdev->dev));
 out_del:
 	device_del(&mdev->dev);
 out_unlock:
diff --git a/drivers/vfio/mdev/mdev_private.h b/drivers/vfio/mdev/mdev_private.h
index 476cc0379ede0..277819f1ebed8 100644
--- a/drivers/vfio/mdev/mdev_private.h
+++ b/drivers/vfio/mdev/mdev_private.h
@@ -20,9 +20,6 @@ extern const struct attribute_group *mdev_device_groups[];
 #define to_mdev_type(_kobj)		\
 	container_of(_kobj, struct mdev_type, kobj)
 
-int  mdev_create_sysfs_files(struct mdev_device *mdev);
-void mdev_remove_sysfs_files(struct mdev_device *mdev);
-
 int mdev_device_create(struct mdev_type *kobj, const guid_t *uuid);
 int  mdev_device_remove(struct mdev_device *dev);
 
diff --git a/drivers/vfio/mdev/mdev_sysfs.c b/drivers/vfio/mdev/mdev_sysfs.c
index fb058755d85b8..b6bc623487f06 100644
--- a/drivers/vfio/mdev/mdev_sysfs.c
+++ b/drivers/vfio/mdev/mdev_sysfs.c
@@ -176,31 +176,3 @@ const struct attribute_group *mdev_device_groups[] = {
 	&mdev_device_group,
 	NULL
 };
-
-int mdev_create_sysfs_files(struct mdev_device *mdev)
-{
-	struct mdev_type *type = mdev->type;
-	struct kobject *kobj = &mdev->dev.kobj;
-	int ret;
-
-	ret = sysfs_create_link(type->devices_kobj, kobj, dev_name(&mdev->dev));
-	if (ret)
-		return ret;
-
-	ret = sysfs_create_link(kobj, &type->kobj, "mdev_type");
-	if (ret)
-		goto type_link_failed;
-	return ret;
-
-type_link_failed:
-	sysfs_remove_link(mdev->type->devices_kobj, dev_name(&mdev->dev));
-	return ret;
-}
-
-void mdev_remove_sysfs_files(struct mdev_device *mdev)
-{
-	struct kobject *kobj = &mdev->dev.kobj;
-
-	sysfs_remove_link(kobj, "mdev_type");
-	sysfs_remove_link(mdev->type->devices_kobj, dev_name(&mdev->dev));
-}
-- 
2.30.2


  parent reply	other threads:[~2022-06-03  6:33 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-03  6:33 simplify the mdev interface Christoph Hellwig
2022-06-03  6:33 ` [PATCH 1/8] vfio/mdev: make mdev.h standalone includable Christoph Hellwig
2022-06-06 23:21   ` Jason Gunthorpe
2022-06-09  6:43   ` Tian, Kevin
2022-06-03  6:33 ` [PATCH 2/8] vfio/mdev: embedd struct mdev_parent in the parent data structure Christoph Hellwig
2022-06-06 19:22   ` Kirti Wankhede
2022-06-07  5:48     ` Christoph Hellwig
2022-06-09  6:52       ` Tian, Kevin
2022-06-03  6:33 ` [PATCH 3/8] vfio/mdev: simplify mdev_type handling Christoph Hellwig
2022-06-06 19:22   ` Kirti Wankhede
2022-06-07  5:50     ` Christoph Hellwig
2022-06-08 17:57       ` Kirti Wankhede
2022-06-09  7:16         ` Christoph Hellwig
2022-06-06 23:38   ` Jason Gunthorpe
2022-06-07  5:56     ` Christoph Hellwig
2022-06-03  6:33 ` Christoph Hellwig [this message]
2022-06-06 23:38   ` [PATCH 4/8] vfio/mdev: remove mdev_{create,remove}_sysfs_files Jason Gunthorpe
2022-06-09  6:55   ` Tian, Kevin
2022-06-03  6:33 ` [PATCH 5/8] vfio/mdev: remove mdev_from_dev Christoph Hellwig
2022-06-06 23:45   ` Jason Gunthorpe
2022-06-09  6:56   ` Tian, Kevin
2022-06-03  6:33 ` [PATCH 6/8] vfio/mdev: unexport mdev_bus_type Christoph Hellwig
2022-06-06 23:46   ` Jason Gunthorpe
2022-06-09  6:57   ` Tian, Kevin
2022-06-03  6:33 ` [PATCH 7/8] vfio/mdev: remove mdev_parent_dev Christoph Hellwig
2022-06-06 23:46   ` Jason Gunthorpe
2022-06-09  6:58   ` Tian, Kevin
2022-06-03  6:33 ` [PATCH 8/8] vfio/mdev: remove mtype_get_parent_dev Christoph Hellwig
2022-06-06 23:46   ` Jason Gunthorpe
2022-06-09  6:58   ` Tian, Kevin

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=20220603063328.3715-5-hch@lst.de \
    --to=hch@lst.de \
    --cc=akrowiak@linux.ibm.com \
    --cc=alex.williamson@redhat.com \
    --cc=farman@linux.ibm.com \
    --cc=intel-gvt-dev@lists.freedesktop.org \
    --cc=jjherne@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwankhede@nvidia.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjrosato@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=zhenyuw@linux.intel.com \
    --cc=zhi.a.wang@intel.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