Skip to contentSkip to conversation

Staging: comedi: logical || vs bitwise |

PATCH In review Dan Carpenter 2 participants 2 messages Jan 17, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: comedi: logical || vs bitwise |

These are bitfields and the intend was to OR them together. A logical OR here is simply 1.

drivers/staging/comedi/drivers/dt9812.c +2 -2
index 32d9c42..e86ab58 100644
@@ -527,7 +527,7 @@ static void dt9812_configure_gain(struct usb_dt9812 *dev,
 		 * 11x -> Gain =  0.5
 		 */
 	case DT9812_GAIN_0PT5:
-		rmw->or_value = F020_MASK_ADC0CF_AMP0GN2 ||
+		rmw->or_value = F020_MASK_ADC0CF_AMP0GN2 |
 		    F020_MASK_ADC0CF_AMP0GN1;
 		break;
 	case DT9812_GAIN_1:
@@ -540,7 +540,7 @@ static void dt9812_configure_gain(struct usb_dt9812 *dev,
 		rmw->or_value = F020_MASK_ADC0CF_AMP0GN1;
 		break;
 	case DT9812_GAIN_8:
-		rmw->or_value = F020_MASK_ADC0CF_AMP0GN1 ||
+		rmw->or_value = F020_MASK_ADC0CF_AMP0GN1 |
 		    F020_MASK_ADC0CF_AMP0GN0;
 		break;
 	case DT9812_GAIN_16:
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Dan Carpenter

These are bitfields and the intend was to OR them together. A logical OR here is simply 1.

You have my ack. I'll just add that since the driver is incomplete, the buggy code is not currently reached. (In fact, as the AI and AO subdevices have neither a range_table nor a range_table_list, the comedi core's COMEDI_INSN/COMEDI_INSNLIST ioctl handlers will return an error for these subdevices before it even calls the driver's insn handlers for these subdevices!)

Signature · 2 lines
-=( Ian Abbott @ MEV Ltd.    E-mail: <[email protected]>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-