diff mbox series

lustre: don't manage module refs in obd_class_open/close.

Message ID 87r2cegbbt.fsf@notabene.neil.brown.name (mailing list archive)
State New, archived
Headers show
Series lustre: don't manage module refs in obd_class_open/close. | expand

Commit Message

NeilBrown Feb. 11, 2019, 5:09 a.m. UTC
Core Linux code for managed char-devs ensures that the relevant
module is held active which a char-dev is open - see cdev_get()
and cdev_put().
So there is no need for lustre/obd_class to manage the module
ref count as well.

As this is all that obd_class_open and obd_class_close do, those
functions can be removed.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/obdclass/class_obd.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

Comments

James Simmons Feb. 12, 2019, 4:17 a.m. UTC | #1
> Core Linux code for managed char-devs ensures that the relevant
> module is held active which a char-dev is open - see cdev_get()
> and cdev_put().
> So there is no need for lustre/obd_class to manage the module
> ref count as well.
> 
> As this is all that obd_class_open and obd_class_close do, those
> functions can be removed.

I was planning to do this but didn't get around to it. Thanks.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/obdclass/class_obd.c | 18 +-----------------
>  1 file changed, 1 insertion(+), 17 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
> index 84c077ec0116..b8fc74044fe3 100644
> --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
> +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
> @@ -544,20 +544,6 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
>  	return err;
>  } /* class_handle_ioctl */
>  
> -/*  opening /dev/obd */
> -static int obd_class_open(struct inode *inode, struct file *file)
> -{
> -	try_module_get(THIS_MODULE);
> -	return 0;
> -}
> -
> -/*  closing /dev/obd */
> -static int obd_class_release(struct inode *inode, struct file *file)
> -{
> -	module_put(THIS_MODULE);
> -	return 0;
> -}
> -
>  /* to control /dev/obd */
>  static long obd_class_ioctl(struct file *filp, unsigned int cmd,
>  			    unsigned long arg)
> @@ -575,9 +561,7 @@ static long obd_class_ioctl(struct file *filp, unsigned int cmd,
>  /* declare character device */
>  static const struct file_operations obd_psdev_fops = {
>  	.owner		= THIS_MODULE,
> -	.unlocked_ioctl	= obd_class_ioctl,	/* unlocked_ioctl */
> -	.open		= obd_class_open,	/* open */
> -	.release	= obd_class_release,	/* release */
> +	.unlocked_ioctl	= obd_class_ioctl,
>  };
>  
>  /* modules setup */
> -- 
> 2.14.0.rc0.dirty
> 
>
diff mbox series

Patch

diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
index 84c077ec0116..b8fc74044fe3 100644
--- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
@@ -544,20 +544,6 @@  int class_handle_ioctl(unsigned int cmd, unsigned long arg)
 	return err;
 } /* class_handle_ioctl */
 
-/*  opening /dev/obd */
-static int obd_class_open(struct inode *inode, struct file *file)
-{
-	try_module_get(THIS_MODULE);
-	return 0;
-}
-
-/*  closing /dev/obd */
-static int obd_class_release(struct inode *inode, struct file *file)
-{
-	module_put(THIS_MODULE);
-	return 0;
-}
-
 /* to control /dev/obd */
 static long obd_class_ioctl(struct file *filp, unsigned int cmd,
 			    unsigned long arg)
@@ -575,9 +561,7 @@  static long obd_class_ioctl(struct file *filp, unsigned int cmd,
 /* declare character device */
 static const struct file_operations obd_psdev_fops = {
 	.owner		= THIS_MODULE,
-	.unlocked_ioctl	= obd_class_ioctl,	/* unlocked_ioctl */
-	.open		= obd_class_open,	/* open */
-	.release	= obd_class_release,	/* release */
+	.unlocked_ioctl	= obd_class_ioctl,
 };
 
 /* modules setup */