Skip to contentSkip to conversation

staging: comedi: Remove unused variable ‘min_full_scale’ and function 'get_min_full_scales'

PATCH In review Bixuan Cui 3 participants 6 messages May 14, 2021 – May 19, 2021 Comedi drivers

lore
Share & tools
lore

Bixuan Cui

author
#0 lore raw

PATCH v2 1/1 staging: comedi: Remove unused variable ‘min_full_scale’ and function 'get_min_full_scales'

The variable ‘min_full_scale’ and function 'get_min_full_scales' are not used, So delete them.

---
Changes from v2:
* Delete function 'get_min_full_scales'

 drivers/comedi/drivers/jr3_pci.c | 15 ---------------
 1 file changed, 15 deletions(-)
drivers/comedi/drivers/jr3_pci.c +0 -15
index 7a02c4fa3cda..f963080dd61f 100644
@@ -186,19 +186,6 @@ static void set_full_scales(struct jr3_sensor __iomem *sensor,
 	set_s16(&sensor->command_word0, 0x0a00);
 }
 
-static struct six_axis_t get_min_full_scales(struct jr3_sensor __iomem *sensor)
-{
-	struct six_axis_t result;
-
-	result.fx = get_s16(&sensor->min_full_scale.fx);
-	result.fy = get_s16(&sensor->min_full_scale.fy);
-	result.fz = get_s16(&sensor->min_full_scale.fz);
-	result.mx = get_s16(&sensor->min_full_scale.mx);
-	result.my = get_s16(&sensor->min_full_scale.my);
-	result.mz = get_s16(&sensor->min_full_scale.mz);
-	return result;
-}
-
 static struct six_axis_t get_max_full_scales(struct jr3_sensor __iomem *sensor)
 {
 	struct six_axis_t result;
@@ -504,10 +491,8 @@ jr3_pci_poll_subdevice(struct comedi_subdevice *s)
 			result = poll_delay_min_max(20, 100);
 		} else {
 			/* Set full scale */
-			struct six_axis_t min_full_scale;
 			struct six_axis_t max_full_scale;
 
-			min_full_scale = get_min_full_scales(sensor);
 			max_full_scale = get_max_full_scales(sensor);
 			set_full_scales(sensor, max_full_scale);
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 20 lines · Bixuan Cui

The variable ‘min_full_scale’ and function 'get_min_full_scales' are not used, So delete them.

---
Changes from v2:
* Delete function 'get_min_full_scales'

 drivers/comedi/drivers/jr3_pci.c | 15 ---------------
 1 file changed, 15 deletions(-)
drivers/comedi/drivers/jr3_pci.c +0 -1
index 7a02c4fa3cda..f963080dd61f 100644
@@ -186,19 +186,6 @@ static void set_full_scales(struct jr3_sensor __iomem *sensor,
 	set_s16(&sensor->command_word0, 0x0a00);
 }
 
-static struct six_axis_t get_min_full_scales(struct jr3_sensor __iomem *sensor)

drivers/comedi/drivers/jr3_pci.c static void set_full_scales(struct jr3_sensor __iomem *sensor, · line 199

Quoted 10 lines
drivers/comedi/drivers/jr3_pci.c +0 -10
-{
-	struct six_axis_t result;
-
-	result.fx = get_s16(&sensor->min_full_scale.fx);
-	result.fy = get_s16(&sensor->min_full_scale.fy);
-	result.fz = get_s16(&sensor->min_full_scale.fz);
-	result.mx = get_s16(&sensor->min_full_scale.mx);
-	result.my = get_s16(&sensor->min_full_scale.my);
-	result.mz = get_s16(&sensor->min_full_scale.mz);
-	return result;

Are you _SURE_ that this is ok to do? You are reading from the hardware, and that is sometimes required depending on the internal-to-the-device state machine.

Have you tested to verify that not doing these reads does not break something?

This is a constant theme in these "remove variables that are not being used" patches, please be aware that how hardware works is very specific and when you mess with how it is accessed, that has the chance of causing problems.

thanks,

greg k-h

maintainer
#2 lore raw
Quoted 36 lines · Greg KH
Quoted 20 lines · Bixuan Cui

The variable ‘min_full_scale’ and function 'get_min_full_scales' are not used, So delete them.

---
Changes from v2:
* Delete function 'get_min_full_scales'

  drivers/comedi/drivers/jr3_pci.c | 15 ---------------
  1 file changed, 15 deletions(-)
drivers/comedi/drivers/jr3_pci.c +0 -1
index 7a02c4fa3cda..f963080dd61f 100644
@@ -186,19 +186,6 @@ static void set_full_scales(struct jr3_sensor __iomem *sensor,
  	set_s16(&sensor->command_word0, 0x0a00);
  }
 
-static struct six_axis_t get_min_full_scales(struct jr3_sensor __iomem *sensor)

drivers/comedi/drivers/jr3_pci.c static void set_full_scales(struct jr3_sensor __iomem *sensor, · line 199

Quoted 10 lines
drivers/comedi/drivers/jr3_pci.c +0 -10
-{
-	struct six_axis_t result;
-
-	result.fx = get_s16(&sensor->min_full_scale.fx);
-	result.fy = get_s16(&sensor->min_full_scale.fy);
-	result.fz = get_s16(&sensor->min_full_scale.fz);
-	result.mx = get_s16(&sensor->min_full_scale.mx);
-	result.my = get_s16(&sensor->min_full_scale.my);
-	result.mz = get_s16(&sensor->min_full_scale.mz);
-	return result;

Are you _SURE_ that this is ok to do? You are reading from the hardware, and that is sometimes required depending on the internal-to-the-device state machine.

Quoted 7 lines

Have you tested to verify that not doing these reads does not break something?

This is a constant theme in these "remove variables that are not being used" patches, please be aware that how hardware works is very specific and when you mess with how it is accessed, that has the chance of causing problems.

I don't think removing this would do any harm. The get_s16 function is just a simple wrapper around readl that converts the type of the returned value to s16. The registers for minimum full scale and maximum full scale are just informational, and there is nothing in the manual[1] about reading registers in a particular order. The driver used to print these values to the kernel log, but that code was removed in commit a1d16659538a ("staging: comedi: jr3_pci: remove noisy printk").

[1] 5907E - Legacy PCI Receiver Manual
<https://www.jr3.com/component/phocadownload/category/6-product-manuals?download=36:5907e-legacy-pci-receiver-manual>

Signature · 4 lines
-=( Ian Abbott <[email protected]> || MEV Ltd. is a company  )=-
-=( registered in England & Wales.  Regd. number: 02862268.  )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-
#3 lore raw
Quoted 52 lines · Ian Abbott
Quoted 35 lines · Greg KH
Quoted 19 lines · Bixuan Cui

The variable ‘min_full_scale’ and function 'get_min_full_scales' are not used, So delete them.

---
Changes from v2:
* Delete function 'get_min_full_scales'

  drivers/comedi/drivers/jr3_pci.c | 15 ---------------
  1 file changed, 15 deletions(-)
drivers/comedi/drivers/jr3_pci.c +0 -1
index 7a02c4fa3cda..f963080dd61f 100644
@@ -186,19 +186,6 @@ static void set_full_scales(struct jr3_sensor __iomem *sensor,
  	set_s16(&sensor->command_word0, 0x0a00);
  }
-static struct six_axis_t get_min_full_scales(struct jr3_sensor __iomem *sensor)

drivers/comedi/drivers/jr3_pci.c static void set_full_scales(struct jr3_sensor __iomem *sensor, · line 198

Quoted 10 lines
drivers/comedi/drivers/jr3_pci.c +0 -10
-{
-	struct six_axis_t result;
-
-	result.fx = get_s16(&sensor->min_full_scale.fx);
-	result.fy = get_s16(&sensor->min_full_scale.fy);
-	result.fz = get_s16(&sensor->min_full_scale.fz);
-	result.mx = get_s16(&sensor->min_full_scale.mx);
-	result.my = get_s16(&sensor->min_full_scale.my);
-	result.mz = get_s16(&sensor->min_full_scale.mz);
-	return result;

Are you _SURE_ that this is ok to do? You are reading from the hardware, and that is sometimes required depending on the internal-to-the-device state machine.

Quoted 7 lines

Have you tested to verify that not doing these reads does not break something?

This is a constant theme in these "remove variables that are not being used" patches, please be aware that how hardware works is very specific and when you mess with how it is accessed, that has the chance of causing problems.

I don't think removing this would do any harm. The get_s16 function is just a simple wrapper around readl that converts the type of the returned value to s16. The registers for minimum full scale and maximum full scale are just informational, and there is nothing in the manual[1] about reading registers in a particular order. The driver used to print these values to the kernel log, but that code was removed in commit a1d16659538a ("staging:
comedi: jr3_pci: remove noisy printk").

Quoted 3 lines

[1] 5907E - Legacy PCI Receiver Manual
<https://www.jr3.com/component/phocadownload/category/6-product-manuals?download=36:5907e-legacy-pci-receiver-manual>

Ok, can I get a "reviewed-by:" then?

thanks,

greg k-h

maintainer Reviewed-by on v2 1/1
#4 lore raw
In reply to Bixuan Cui
Quoted 37 lines · Bixuan Cui

The variable ‘min_full_scale’ and function 'get_min_full_scales' are not used, So delete them.

---
Changes from v2:
* Delete function 'get_min_full_scales'

  drivers/comedi/drivers/jr3_pci.c | 15 ---------------
  1 file changed, 15 deletions(-)
drivers/comedi/drivers/jr3_pci.c +0 -13
index 7a02c4fa3cda..f963080dd61f 100644
@@ -186,19 +186,6 @@ static void set_full_scales(struct jr3_sensor __iomem *sensor,
  	set_s16(&sensor->command_word0, 0x0a00);
  }
 
-static struct six_axis_t get_min_full_scales(struct jr3_sensor __iomem *sensor)
-{
-	struct six_axis_t result;
-
-	result.fx = get_s16(&sensor->min_full_scale.fx);
-	result.fy = get_s16(&sensor->min_full_scale.fy);
-	result.fz = get_s16(&sensor->min_full_scale.fz);
-	result.mx = get_s16(&sensor->min_full_scale.mx);
-	result.my = get_s16(&sensor->min_full_scale.my);
-	result.mz = get_s16(&sensor->min_full_scale.mz);
-	return result;
-}
-
  static struct six_axis_t get_max_full_scales(struct jr3_sensor __iomem *sensor)
  {
  	struct six_axis_t result;

drivers/comedi/drivers/jr3_pci.c jr3_pci_poll_subdevice(struct comedi_subdevice *s) · line 498

Quoted 10 lines
drivers/comedi/drivers/jr3_pci.c +0 -2
@@ -504,10 +491,8 @@ jr3_pci_poll_subdevice(struct comedi_subdevice *s)
  			result = poll_delay_min_max(20, 100);
  		} else {
  			/* Set full scale */
-			struct six_axis_t min_full_scale;
  			struct six_axis_t max_full_scale;
 
-			min_full_scale = get_min_full_scales(sensor);
  			max_full_scale = get_max_full_scales(sensor);
  			set_full_scales(sensor, max_full_scale);
 

I'm pretty sure this is OK. The min_full_scale registers are just informational. The driver used to print the values, but not since commit a1d16659538a ("staging: comedi: jr3_pci: remove noisy printk") so this code is now redundant.

Signature · 4 lines
-=( Ian Abbott <[email protected]> || MEV Ltd. is a company  )=-
-=( registered in England & Wales.  Regd. number: 02862268.  )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-
author
#5 lore raw
Quoted 39 lines · Ian Abbott
Quoted 38 lines · Bixuan Cui

The variable ‘min_full_scale’ and function 'get_min_full_scales' are not used, So delete them.

---
Changes from v2:
* Delete function 'get_min_full_scales'

  drivers/comedi/drivers/jr3_pci.c | 15 ---------------

  1 file changed, 15 deletions(-)
drivers/comedi/drivers/jr3_pci.c +0 -12
index 7a02c4fa3cda..f963080dd61f 100644
@@ -186,19 +186,6 @@ static void set_full_scales(struct jr3_sensor __iomem *sensor,
       set_s16(&sensor->command_word0, 0x0a00);
   }
   -static struct six_axis_t get_min_full_scales(struct jr3_sensor __iomem *sensor)
-{
-    struct six_axis_t result;
-
-    result.fx = get_s16(&sensor->min_full_scale.fx);
-    result.fy = get_s16(&sensor->min_full_scale.fy);
-    result.fz = get_s16(&sensor->min_full_scale.fz);
-    result.mx = get_s16(&sensor->min_full_scale.mx);
-    result.my = get_s16(&sensor->min_full_scale.my);
-    result.mz = get_s16(&sensor->min_full_scale.mz);
-    return result;
-}
-
   static struct six_axis_t get_max_full_scales(struct jr3_sensor __iomem *sensor)
   {
       struct six_axis_t result;
@@ -504,10 +491,8 @@ jr3_pci_poll_subdevice(struct comedi_subdevice *s)
               result = poll_delay_min_max(20, 100);
           } else {
               /* Set full scale */
Quoted 8 lines
Quoted 6 lines
drivers/comedi/drivers/jr3_pci.c +0 -1
-            struct six_axis_t min_full_scale;
               struct six_axis_t max_full_scale;
   -            min_full_scale = get_min_full_scales(sensor);
               max_full_scale = get_max_full_scales(sensor);
               set_full_scales(sensor, max_full_scale);

I'm pretty sure this is OK.  The min_full_scale registers are just informational.  The driver used to print the values, but not since commit a1d16659538a ("staging: comedi: jr3_pci: remove noisy printk") so this code is now redundant.

Thanks for your reply.

Thanks
Bixuan Cui

Quoted 3 lines