All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Farman <farman@linux.ibm.com>
To: kvm@vger.kernel.org, linux-s390@vger.kernel.org
Cc: Cornelia Huck <cohuck@redhat.com>,
	Jason Herne <jjherne@linux.ibm.com>,
	Jared Rossi <jrossi@linux.ibm.com>,
	Eric Farman <farman@linux.ibm.com>
Subject: [RFC PATCH v1 01/10] vfio-ccw: Introduce new helper functions to free/destroy regions
Date: Fri, 15 Nov 2019 03:56:11 +0100	[thread overview]
Message-ID: <20191115025620.19593-2-farman@linux.ibm.com> (raw)
In-Reply-To: <20191115025620.19593-1-farman@linux.ibm.com>

From: Farhan Ali <alifm@linux.ibm.com>

Consolidate some of the cleanup code for the regions, so that
as more are added we reduce code duplication.

Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Signed-off-by: Eric Farman <farman@linux.ibm.com>
---

Notes:
    v0->v1: [EF]
     - Commit message

 drivers/s390/cio/vfio_ccw_drv.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c
index e401a3d0aa57..91989269faf1 100644
--- a/drivers/s390/cio/vfio_ccw_drv.c
+++ b/drivers/s390/cio/vfio_ccw_drv.c
@@ -116,6 +116,14 @@ static void vfio_ccw_sch_irq(struct subchannel *sch)
 	vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_INTERRUPT);
 }
 
+static void vfio_ccw_free_regions(struct vfio_ccw_private *private)
+{
+	if (private->cmd_region)
+		kmem_cache_free(vfio_ccw_cmd_region, private->cmd_region);
+	if (private->io_region)
+		kmem_cache_free(vfio_ccw_io_region, private->io_region);
+}
+
 static int vfio_ccw_sch_probe(struct subchannel *sch)
 {
 	struct pmcw *pmcw = &sch->schib.pmcw;
@@ -176,10 +184,7 @@ static int vfio_ccw_sch_probe(struct subchannel *sch)
 	cio_disable_subchannel(sch);
 out_free:
 	dev_set_drvdata(&sch->dev, NULL);
-	if (private->cmd_region)
-		kmem_cache_free(vfio_ccw_cmd_region, private->cmd_region);
-	if (private->io_region)
-		kmem_cache_free(vfio_ccw_io_region, private->io_region);
+	vfio_ccw_free_regions(private);
 	kfree(private->cp.guest_cp);
 	kfree(private);
 	return ret;
@@ -195,8 +200,7 @@ static int vfio_ccw_sch_remove(struct subchannel *sch)
 
 	dev_set_drvdata(&sch->dev, NULL);
 
-	kmem_cache_free(vfio_ccw_cmd_region, private->cmd_region);
-	kmem_cache_free(vfio_ccw_io_region, private->io_region);
+	vfio_ccw_free_regions(private);
 	kfree(private->cp.guest_cp);
 	kfree(private);
 
@@ -299,6 +303,12 @@ static void vfio_ccw_debug_exit(void)
 	debug_unregister(vfio_ccw_debug_trace_id);
 }
 
+static void vfio_ccw_destroy_regions(void)
+{
+	kmem_cache_destroy(vfio_ccw_cmd_region);
+	kmem_cache_destroy(vfio_ccw_io_region);
+}
+
 static int __init vfio_ccw_sch_init(void)
 {
 	int ret;
@@ -341,8 +351,7 @@ static int __init vfio_ccw_sch_init(void)
 	return ret;
 
 out_err:
-	kmem_cache_destroy(vfio_ccw_cmd_region);
-	kmem_cache_destroy(vfio_ccw_io_region);
+	vfio_ccw_destroy_regions();
 	destroy_workqueue(vfio_ccw_work_q);
 	vfio_ccw_debug_exit();
 	return ret;
@@ -352,8 +361,7 @@ static void __exit vfio_ccw_sch_exit(void)
 {
 	css_driver_unregister(&vfio_ccw_sch_driver);
 	isc_unregister(VFIO_CCW_ISC);
-	kmem_cache_destroy(vfio_ccw_io_region);
-	kmem_cache_destroy(vfio_ccw_cmd_region);
+	vfio_ccw_destroy_regions();
 	destroy_workqueue(vfio_ccw_work_q);
 	vfio_ccw_debug_exit();
 }
-- 
2.17.1

  reply	other threads:[~2019-11-15  3:27 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-15  2:56 [RFC PATCH v1 00/10] s390/vfio-ccw: Channel Path Handling Eric Farman
2019-11-15  2:56 ` Eric Farman [this message]
2019-11-19 12:33   ` [RFC PATCH v1 01/10] vfio-ccw: Introduce new helper functions to free/destroy regions Cornelia Huck
2019-11-15  2:56 ` [RFC PATCH v1 02/10] vfio-ccw: Register a chp_event callback for vfio-ccw Eric Farman
2019-11-19 12:48   ` Cornelia Huck
2019-11-19 15:45     ` Eric Farman
2019-11-15  2:56 ` [RFC PATCH v1 03/10] vfio-ccw: Use subchannel lpm in the orb Eric Farman
2019-11-19 13:00   ` Cornelia Huck
2019-11-19 15:16     ` Eric Farman
2019-11-19 15:38       ` Cornelia Huck
2019-11-19 18:58         ` Eric Farman
2019-11-15  2:56 ` [RFC PATCH v1 04/10] vfio-ccw: Refactor the unregister of the async regions Eric Farman
2019-11-19 16:21   ` Cornelia Huck
2019-11-15  2:56 ` [RFC PATCH v1 05/10] vfio-ccw: Introduce a new schib region Eric Farman
2019-11-19 16:52   ` Cornelia Huck
2019-11-20 16:49     ` Eric Farman
2019-11-15  2:56 ` [RFC PATCH v1 06/10] vfio-ccw: Introduce a new CRW region Eric Farman
2019-11-19 17:17   ` Cornelia Huck
2019-11-15  2:56 ` [RFC PATCH v1 07/10] vfio-ccw: Refactor IRQ handlers Eric Farman
2019-11-19 17:18   ` Cornelia Huck
2019-11-15  2:56 ` [RFC PATCH v1 08/10] vfio-ccw: Wire up the CRW irq and CRW region Eric Farman
2019-11-19 18:52   ` Cornelia Huck
2019-12-05 20:43     ` Eric Farman
2019-12-06 10:21       ` Cornelia Huck
2019-12-06 21:24         ` Eric Farman
2019-12-09 12:38           ` Cornelia Huck
2019-11-15  2:56 ` [RFC PATCH v1 09/10] vfio-ccw: Add trace for CRW event Eric Farman
2019-11-15  2:56 ` [RFC PATCH v1 10/10] vfio-ccw: Remove inline get_schid() routine Eric Farman
2019-11-15 11:15 ` [RFC PATCH v1 00/10] s390/vfio-ccw: Channel Path Handling Cornelia Huck

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=20191115025620.19593-2-farman@linux.ibm.com \
    --to=farman@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=jjherne@linux.ibm.com \
    --cc=jrossi@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.