Reorder placement of skd_construct(), skd_cons_sg_list(), skd_destruct()
and skd_free_sg_list() functions. Then remove no longer needed function
prototypes.

Cc: Akhil Bhansali <abhans...@stec-inc.com>
Cc: Jeff Moyer <jmo...@redhat.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnier...@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.p...@samsung.com>
---
 drivers/block/skd_main.c | 314 ++++++++++++++++++++++-------------------------
 1 file changed, 144 insertions(+), 170 deletions(-)

diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index 2ff8e37..c72b0e4 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -497,7 +497,6 @@ MODULE_PARM_DESC(skd_bio,
 /* Major device number dynamically assigned. */
 static u32 skd_major;
 
-static struct skd_device *skd_construct(struct pci_dev *pdev);
 static void skd_destruct(struct skd_device *skdev);
 static const struct block_device_operations skd_blockdev_ops;
 static void skd_send_fitmsg(struct skd_device *skdev,
@@ -4408,102 +4407,6 @@ static void skd_release_irq(struct skd_device *skdev)
  *****************************************************************************
  */
 
-static int skd_cons_skcomp(struct skd_device *skdev);
-static int skd_cons_skmsg(struct skd_device *skdev);
-static int skd_cons_skreq(struct skd_device *skdev);
-static int skd_cons_skspcl(struct skd_device *skdev);
-static int skd_cons_sksb(struct skd_device *skdev);
-static struct fit_sg_descriptor *skd_cons_sg_list(struct skd_device *skdev,
-                                                 u32 n_sg,
-                                                 dma_addr_t *ret_dma_addr);
-static int skd_cons_disk(struct skd_device *skdev);
-
-#define SKD_N_DEV_TABLE         16u
-static u32 skd_next_devno;
-
-static struct skd_device *skd_construct(struct pci_dev *pdev)
-{
-       struct skd_device *skdev;
-       int blk_major = skd_major;
-       int rc;
-
-       skdev = kzalloc(sizeof(*skdev), GFP_KERNEL);
-
-       if (!skdev) {
-               pr_err(PFX "(%s): memory alloc failure\n",
-                      pci_name(pdev));
-               return NULL;
-       }
-
-       skdev->state = SKD_DRVR_STATE_LOAD;
-       skdev->pdev = pdev;
-       skdev->devno = skd_next_devno++;
-       skdev->major = blk_major;
-       skdev->irq_type = skd_isr_type;
-       sprintf(skdev->name, DRV_NAME "%d", skdev->devno);
-       skdev->dev_max_queue_depth = 0;
-
-       skdev->num_req_context = skd_max_queue_depth;
-       skdev->num_fitmsg_context = skd_max_queue_depth;
-       skdev->n_special = skd_max_pass_thru;
-       skdev->cur_max_queue_depth = 1;
-       skdev->queue_low_water_mark = 1;
-       skdev->proto_ver = 99;
-       skdev->sgs_per_request = skd_sgs_per_request;
-       skdev->dbg_level = skd_dbg_level;
-
-       if (skd_bio)
-               bio_list_init(&skdev->bio_queue);
-
-
-       atomic_set(&skdev->device_count, 0);
-
-       spin_lock_init(&skdev->lock);
-
-       INIT_WORK(&skdev->completion_worker, skd_completion_worker);
-       INIT_LIST_HEAD(&skdev->flush_list);
-
-       VPRINTK(skdev, "skcomp\n");
-       rc = skd_cons_skcomp(skdev);
-       if (rc < 0)
-               goto err_out;
-
-       VPRINTK(skdev, "skmsg\n");
-       rc = skd_cons_skmsg(skdev);
-       if (rc < 0)
-               goto err_out;
-
-       VPRINTK(skdev, "skreq\n");
-       rc = skd_cons_skreq(skdev);
-       if (rc < 0)
-               goto err_out;
-
-       VPRINTK(skdev, "skspcl\n");
-       rc = skd_cons_skspcl(skdev);
-       if (rc < 0)
-               goto err_out;
-
-       VPRINTK(skdev, "sksb\n");
-       rc = skd_cons_sksb(skdev);
-       if (rc < 0)
-               goto err_out;
-
-       VPRINTK(skdev, "disk\n");
-       rc = skd_cons_disk(skdev);
-       if (rc < 0)
-               goto err_out;
-
-
-
-       DPRINTK(skdev, "VICTORY\n");
-       return skdev;
-
-err_out:
-       DPRINTK(skdev, "construct failed\n");
-       skd_destruct(skdev);
-       return NULL;
-}
-
 static int skd_cons_skcomp(struct skd_device *skdev)
 {
        int rc = 0;
@@ -4590,6 +4493,35 @@ err_out:
        return rc;
 }
 
+static struct fit_sg_descriptor *skd_cons_sg_list(struct skd_device *skdev,
+                                                 u32 n_sg,
+                                                 dma_addr_t *ret_dma_addr)
+{
+       struct fit_sg_descriptor *sg_list;
+       u32 nbytes;
+
+       nbytes = sizeof(*sg_list) * n_sg;
+
+       sg_list = pci_alloc_consistent(skdev->pdev, nbytes, ret_dma_addr);
+
+       if (sg_list != NULL) {
+               uint64_t dma_address = *ret_dma_addr;
+               u32 i;
+
+               memset(sg_list, 0, nbytes);
+
+               for (i = 0; i < n_sg - 1; i++) {
+                       uint64_t ndp_off;
+                       ndp_off = (i + 1) * sizeof(struct fit_sg_descriptor);
+
+                       sg_list[i].next_desc_ptr = dma_address + ndp_off;
+               }
+               sg_list[i].next_desc_ptr = 0LL;
+       }
+
+       return sg_list;
+}
+
 static int skd_cons_skreq(struct skd_device *skdev)
 {
        int rc = 0;
@@ -4760,35 +4692,6 @@ err_out:
        return rc;
 }
 
-static struct fit_sg_descriptor *skd_cons_sg_list(struct skd_device *skdev,
-                                                 u32 n_sg,
-                                                 dma_addr_t *ret_dma_addr)
-{
-       struct fit_sg_descriptor *sg_list;
-       u32 nbytes;
-
-       nbytes = sizeof(*sg_list) * n_sg;
-
-       sg_list = pci_alloc_consistent(skdev->pdev, nbytes, ret_dma_addr);
-
-       if (sg_list != NULL) {
-               uint64_t dma_address = *ret_dma_addr;
-               u32 i;
-
-               memset(sg_list, 0, nbytes);
-
-               for (i = 0; i < n_sg - 1; i++) {
-                       uint64_t ndp_off;
-                       ndp_off = (i + 1) * sizeof(struct fit_sg_descriptor);
-
-                       sg_list[i].next_desc_ptr = dma_address + ndp_off;
-               }
-               sg_list[i].next_desc_ptr = 0LL;
-       }
-
-       return sg_list;
-}
-
 static int skd_cons_disk(struct skd_device *skdev)
 {
        int rc = 0;
@@ -4855,50 +4758,96 @@ err_out:
        return rc;
 }
 
-/*
- *****************************************************************************
- * DESTRUCT (FREE)
- *****************************************************************************
- */
-
-static void skd_free_skcomp(struct skd_device *skdev);
-static void skd_free_skmsg(struct skd_device *skdev);
-static void skd_free_skreq(struct skd_device *skdev);
-static void skd_free_skspcl(struct skd_device *skdev);
-static void skd_free_sksb(struct skd_device *skdev);
-static void skd_free_sg_list(struct skd_device *skdev,
-                            struct fit_sg_descriptor *sg_list,
-                            u32 n_sg, dma_addr_t dma_addr);
-static void skd_free_disk(struct skd_device *skdev);
+#define SKD_N_DEV_TABLE         16u
+static u32 skd_next_devno;
 
-static void skd_destruct(struct skd_device *skdev)
+static struct skd_device *skd_construct(struct pci_dev *pdev)
 {
-       if (skdev == NULL)
-               return;
+       struct skd_device *skdev;
+       int blk_major = skd_major;
+       int rc;
 
+       skdev = kzalloc(sizeof(*skdev), GFP_KERNEL);
 
-       VPRINTK(skdev, "disk\n");
-       skd_free_disk(skdev);
+       if (!skdev) {
+               pr_err(PFX "(%s): memory alloc failure\n",
+                      pci_name(pdev));
+               return NULL;
+       }
 
-       VPRINTK(skdev, "sksb\n");
-       skd_free_sksb(skdev);
+       skdev->state = SKD_DRVR_STATE_LOAD;
+       skdev->pdev = pdev;
+       skdev->devno = skd_next_devno++;
+       skdev->major = blk_major;
+       skdev->irq_type = skd_isr_type;
+       sprintf(skdev->name, DRV_NAME "%d", skdev->devno);
+       skdev->dev_max_queue_depth = 0;
 
-       VPRINTK(skdev, "skspcl\n");
-       skd_free_skspcl(skdev);
+       skdev->num_req_context = skd_max_queue_depth;
+       skdev->num_fitmsg_context = skd_max_queue_depth;
+       skdev->n_special = skd_max_pass_thru;
+       skdev->cur_max_queue_depth = 1;
+       skdev->queue_low_water_mark = 1;
+       skdev->proto_ver = 99;
+       skdev->sgs_per_request = skd_sgs_per_request;
+       skdev->dbg_level = skd_dbg_level;
 
-       VPRINTK(skdev, "skreq\n");
-       skd_free_skreq(skdev);
+       if (skd_bio)
+               bio_list_init(&skdev->bio_queue);
 
-       VPRINTK(skdev, "skmsg\n");
-       skd_free_skmsg(skdev);
+
+       atomic_set(&skdev->device_count, 0);
+
+       spin_lock_init(&skdev->lock);
+
+       INIT_WORK(&skdev->completion_worker, skd_completion_worker);
+       INIT_LIST_HEAD(&skdev->flush_list);
 
        VPRINTK(skdev, "skcomp\n");
-       skd_free_skcomp(skdev);
+       rc = skd_cons_skcomp(skdev);
+       if (rc < 0)
+               goto err_out;
 
-       VPRINTK(skdev, "skdev\n");
-       kfree(skdev);
+       VPRINTK(skdev, "skmsg\n");
+       rc = skd_cons_skmsg(skdev);
+       if (rc < 0)
+               goto err_out;
+
+       VPRINTK(skdev, "skreq\n");
+       rc = skd_cons_skreq(skdev);
+       if (rc < 0)
+               goto err_out;
+
+       VPRINTK(skdev, "skspcl\n");
+       rc = skd_cons_skspcl(skdev);
+       if (rc < 0)
+               goto err_out;
+
+       VPRINTK(skdev, "sksb\n");
+       rc = skd_cons_sksb(skdev);
+       if (rc < 0)
+               goto err_out;
+
+       VPRINTK(skdev, "disk\n");
+       rc = skd_cons_disk(skdev);
+       if (rc < 0)
+               goto err_out;
+
+       DPRINTK(skdev, "VICTORY\n");
+       return skdev;
+
+err_out:
+       DPRINTK(skdev, "construct failed\n");
+       skd_destruct(skdev);
+       return NULL;
 }
 
+/*
+ *****************************************************************************
+ * DESTRUCT (FREE)
+ *****************************************************************************
+ */
+
 static void skd_free_skcomp(struct skd_device *skdev)
 {
        if (skdev->skcomp_table != NULL) {
@@ -4941,6 +4890,19 @@ static void skd_free_skmsg(struct skd_device *skdev)
        skdev->skmsg_table = NULL;
 }
 
+static void skd_free_sg_list(struct skd_device *skdev,
+                            struct fit_sg_descriptor *sg_list,
+                            u32 n_sg, dma_addr_t dma_addr)
+{
+       if (sg_list != NULL) {
+               u32 nbytes;
+
+               nbytes = sizeof(*sg_list) * n_sg;
+
+               pci_free_consistent(skdev->pdev, nbytes, sg_list, dma_addr);
+       }
+}
+
 static void skd_free_skreq(struct skd_device *skdev)
 {
        u32 i;
@@ -5037,19 +4999,6 @@ static void skd_free_sksb(struct skd_device *skdev)
        skspcl->req.sksg_dma_address = 0;
 }
 
-static void skd_free_sg_list(struct skd_device *skdev,
-                            struct fit_sg_descriptor *sg_list,
-                            u32 n_sg, dma_addr_t dma_addr)
-{
-       if (sg_list != NULL) {
-               u32 nbytes;
-
-               nbytes = sizeof(*sg_list) * n_sg;
-
-               pci_free_consistent(skdev->pdev, nbytes, sg_list, dma_addr);
-       }
-}
-
 static void skd_free_disk(struct skd_device *skdev)
 {
        struct gendisk *disk = skdev->disk;
@@ -5066,7 +5015,32 @@ static void skd_free_disk(struct skd_device *skdev)
        skdev->disk = NULL;
 }
 
+static void skd_destruct(struct skd_device *skdev)
+{
+       if (skdev == NULL)
+               return;
+
+       VPRINTK(skdev, "disk\n");
+       skd_free_disk(skdev);
 
+       VPRINTK(skdev, "sksb\n");
+       skd_free_sksb(skdev);
+
+       VPRINTK(skdev, "skspcl\n");
+       skd_free_skspcl(skdev);
+
+       VPRINTK(skdev, "skreq\n");
+       skd_free_skreq(skdev);
+
+       VPRINTK(skdev, "skmsg\n");
+       skd_free_skmsg(skdev);
+
+       VPRINTK(skdev, "skcomp\n");
+       skd_free_skcomp(skdev);
+
+       VPRINTK(skdev, "skdev\n");
+       kfree(skdev);
+}
 
 /*
  *****************************************************************************
-- 
1.8.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to