diff mbox series

[RFC,09/12] RDMA/rtrs: Clean up rtrs_rdma_dev_pd_ops

Message ID 20221113010823.6436-10-guoqing.jiang@linux.dev (mailing list archive)
State Changes Requested
Headers show
Series Misc changes for rtrs | expand

Commit Message

Guoqing Jiang Nov. 13, 2022, 1:08 a.m. UTC
Let's remove them since the three members are not used.

Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
---
 drivers/infiniband/ulp/rtrs/rtrs-pri.h |  3 ---
 drivers/infiniband/ulp/rtrs/rtrs.c     | 22 ++++------------------
 2 files changed, 4 insertions(+), 21 deletions(-)

Comments

Haris Iqbal Nov. 15, 2022, 9:18 a.m. UTC | #1
On Sun, Nov 13, 2022 at 2:08 AM Guoqing Jiang <guoqing.jiang@linux.dev> wrote:
>
> Let's remove them since the three members are not used.
>
> Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Acked-by: Md Haris Iqbal <haris.iqbal@ionos.com>

Thanks

> ---
>  drivers/infiniband/ulp/rtrs/rtrs-pri.h |  3 ---
>  drivers/infiniband/ulp/rtrs/rtrs.c     | 22 ++++------------------
>  2 files changed, 4 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-pri.h b/drivers/infiniband/ulp/rtrs/rtrs-pri.h
> index c4ddaeba1c59..4d15a6fd96b6 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-pri.h
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-pri.h
> @@ -68,10 +68,7 @@ enum {
>  struct rtrs_ib_dev;
>
>  struct rtrs_rdma_dev_pd_ops {
> -       struct rtrs_ib_dev *(*alloc)(void);
> -       void (*free)(struct rtrs_ib_dev *dev);
>         int (*init)(struct rtrs_ib_dev *dev);
> -       void (*deinit)(struct rtrs_ib_dev *dev);
>  };
>
>  struct rtrs_rdma_dev_pd {
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c
> index ed324b47d93a..4bf9d868cc52 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs.c
> @@ -557,7 +557,6 @@ EXPORT_SYMBOL(rtrs_addr_to_sockaddr);
>  void rtrs_rdma_dev_pd_init(enum ib_pd_flags pd_flags,
>                             struct rtrs_rdma_dev_pd *pool)
>  {
> -       WARN_ON(pool->ops && (!pool->ops->alloc ^ !pool->ops->free));
>         INIT_LIST_HEAD(&pool->list);
>         mutex_init(&pool->mutex);
>         pool->pd_flags = pd_flags;
> @@ -583,15 +582,8 @@ static void dev_free(struct kref *ref)
>         list_del(&dev->entry);
>         mutex_unlock(&pool->mutex);
>
> -       if (pool->ops && pool->ops->deinit)
> -               pool->ops->deinit(dev);
> -
>         ib_dealloc_pd(dev->ib_pd);
> -
> -       if (pool->ops && pool->ops->free)
> -               pool->ops->free(dev);
> -       else
> -               kfree(dev);
> +       kfree(dev);
>  }
>
>  int rtrs_ib_dev_put(struct rtrs_ib_dev *dev)
> @@ -618,11 +610,8 @@ rtrs_ib_dev_find_or_add(struct ib_device *ib_dev,
>                         goto out_unlock;
>         }
>         mutex_unlock(&pool->mutex);
> -       if (pool->ops && pool->ops->alloc)
> -               dev = pool->ops->alloc();
> -       else
> -               dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> -       if (IS_ERR_OR_NULL(dev))
> +       dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> +       if (!dev)
>                 goto out_err;
>
>         kref_init(&dev->ref);
> @@ -644,10 +633,7 @@ rtrs_ib_dev_find_or_add(struct ib_device *ib_dev,
>  out_free_pd:
>         ib_dealloc_pd(dev->ib_pd);
>  out_free_dev:
> -       if (pool->ops && pool->ops->free)
> -               pool->ops->free(dev);
> -       else
> -               kfree(dev);
> +       kfree(dev);
>  out_err:
>         return NULL;
>  }
> --
> 2.31.1
>
diff mbox series

Patch

diff --git a/drivers/infiniband/ulp/rtrs/rtrs-pri.h b/drivers/infiniband/ulp/rtrs/rtrs-pri.h
index c4ddaeba1c59..4d15a6fd96b6 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-pri.h
+++ b/drivers/infiniband/ulp/rtrs/rtrs-pri.h
@@ -68,10 +68,7 @@  enum {
 struct rtrs_ib_dev;
 
 struct rtrs_rdma_dev_pd_ops {
-	struct rtrs_ib_dev *(*alloc)(void);
-	void (*free)(struct rtrs_ib_dev *dev);
 	int (*init)(struct rtrs_ib_dev *dev);
-	void (*deinit)(struct rtrs_ib_dev *dev);
 };
 
 struct rtrs_rdma_dev_pd {
diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c
index ed324b47d93a..4bf9d868cc52 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs.c
@@ -557,7 +557,6 @@  EXPORT_SYMBOL(rtrs_addr_to_sockaddr);
 void rtrs_rdma_dev_pd_init(enum ib_pd_flags pd_flags,
 			    struct rtrs_rdma_dev_pd *pool)
 {
-	WARN_ON(pool->ops && (!pool->ops->alloc ^ !pool->ops->free));
 	INIT_LIST_HEAD(&pool->list);
 	mutex_init(&pool->mutex);
 	pool->pd_flags = pd_flags;
@@ -583,15 +582,8 @@  static void dev_free(struct kref *ref)
 	list_del(&dev->entry);
 	mutex_unlock(&pool->mutex);
 
-	if (pool->ops && pool->ops->deinit)
-		pool->ops->deinit(dev);
-
 	ib_dealloc_pd(dev->ib_pd);
-
-	if (pool->ops && pool->ops->free)
-		pool->ops->free(dev);
-	else
-		kfree(dev);
+	kfree(dev);
 }
 
 int rtrs_ib_dev_put(struct rtrs_ib_dev *dev)
@@ -618,11 +610,8 @@  rtrs_ib_dev_find_or_add(struct ib_device *ib_dev,
 			goto out_unlock;
 	}
 	mutex_unlock(&pool->mutex);
-	if (pool->ops && pool->ops->alloc)
-		dev = pool->ops->alloc();
-	else
-		dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (IS_ERR_OR_NULL(dev))
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev)
 		goto out_err;
 
 	kref_init(&dev->ref);
@@ -644,10 +633,7 @@  rtrs_ib_dev_find_or_add(struct ib_device *ib_dev,
 out_free_pd:
 	ib_dealloc_pd(dev->ib_pd);
 out_free_dev:
-	if (pool->ops && pool->ops->free)
-		pool->ops->free(dev);
-	else
-		kfree(dev);
+	kfree(dev);
 out_err:
 	return NULL;
 }