Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1595082

Re: [PATCH v2 1/2] Staging: comedi: comedi_fops: Change comedi_num_legacy_minors type

From Ian Abbott <abbotti@mev.co.uk>
Newsgroups linux.kernel
Subject Re: [PATCH v2 1/2] Staging: comedi: comedi_fops: Change comedi_num_legacy_minors type
Date 2017-03-08 12:50 +0100
Message-ID <tiIgp-5ZP-3@gated-at.bofh.it> (permalink)
References <tislk-35L-37@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 07/03/17 18:13, Cheah Kok Cheong wrote:
> Change to unsigned to allow removal of negative value check in
> init section. Use smaller data type since the max possible
> value currently is 48.
>
> Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
> ---
>
> V2:
> -No changes.
>
>  drivers/staging/comedi/comedi_fops.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
> index 57e8599..354d264 100644
> --- a/drivers/staging/comedi/comedi_fops.c
> +++ b/drivers/staging/comedi/comedi_fops.c
> @@ -76,8 +76,8 @@ struct comedi_file {
>  #define COMEDI_NUM_SUBDEVICE_MINORS	\
>  	(COMEDI_NUM_MINORS - COMEDI_NUM_BOARD_MINORS)
>
> -static int comedi_num_legacy_minors;
> -module_param(comedi_num_legacy_minors, int, 0444);
> +static unsigned short comedi_num_legacy_minors;
> +module_param(comedi_num_legacy_minors, ushort, 0444);
>  MODULE_PARM_DESC(comedi_num_legacy_minors,
>  		 "number of comedi minor devices to reserve for non-auto-configured devices (default 0)"
>  		);
> @@ -2857,8 +2857,7 @@ static int __init comedi_init(void)
>
>  	pr_info("version " COMEDI_RELEASE " - http://www.comedi.org\n");
>
> -	if (comedi_num_legacy_minors < 0 ||
> -	    comedi_num_legacy_minors > COMEDI_NUM_BOARD_MINORS) {
> +	if (comedi_num_legacy_minors > COMEDI_NUM_BOARD_MINORS) {
>  		pr_err("invalid value for module parameter \"comedi_num_legacy_minors\".  Valid values are 0 through %i.\n",
>  		       COMEDI_NUM_BOARD_MINORS);
>  		return -EINVAL;
>

Thanks.  (There is no harm in making the parameter unsigned short rather 
than unsigned int, although it's probably not worth it as you still need 
to check the value.  It doesn't matter either way.)

Reviewed-by: Ian Abbott <abbotti@mev.co.uk>

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk> )=-
-=(                          Web: http://www.mev.co.uk/  )=-

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v2 1/2] Staging: comedi: comedi_fops: Change comedi_num_legacy_minors type Cheah Kok Cheong <thrust73@gmail.com> - 2017-03-07 19:50 +0100
  [PATCH v2 2/2] Staging: comedi: comedi_fops: Fix "out of minor numbers for board device files" Cheah Kok Cheong <thrust73@gmail.com> - 2017-03-07 19:50 +0100
    Re: [PATCH v2 2/2] Staging: comedi: comedi_fops: Fix "out of minor  numbers for board device files" Ian Abbott <abbotti@mev.co.uk> - 2017-03-08 16:50 +0100
      Re: [PATCH v2 2/2] Staging: comedi: comedi_fops: Fix "out of minor  numbers for board device files" Cheah Kok Cheong <thrust73@gmail.com> - 2017-03-08 18:30 +0100
  Re: [PATCH v2 1/2] Staging: comedi: comedi_fops: Change  comedi_num_legacy_minors type Ian Abbott <abbotti@mev.co.uk> - 2017-03-08 12:50 +0100

csiph-web