Skip to contentSkip to conversation

staging: comedi: Prefer using BIT macro in various files.

PATCH Superseded Sanjana Sanikommu 2 participants 10 messages Mar 31, 2019 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: comedi: Prefer using BIT macro in various files.

This patchset does the following.
1. Replace bit assignment with macro

Sanjana Sanikommu (6):
staging: comedi: das08: Prefer using the BIT macro
staging: comedi: Prefer using the BIT macro
staging: comedi: Prefer using the BIT macro
staging: comedi: Prefer using the BIT macro
staging: comedi: Prefer using the BIT macro
staging: comedi: Prefer using the BIT macro

 drivers/staging/comedi/drivers/amplc_pci230.c  | 2 +-
 drivers/staging/comedi/drivers/das08.c         | 4 ++--
 drivers/staging/comedi/drivers/dyna_pci10xx.c  | 2 +-
 drivers/staging/comedi/drivers/ni_at_ao.c      | 2 +-
 drivers/staging/comedi/drivers/ni_daq_700.c    | 2 +-
 drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++--
 6 files changed, 8 insertions(+), 8 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/6 staging: comedi: das08: Prefer using the BIT macro

Challenge suggested by coccinelle.

Replace bit shifting on 1 with the BIT(x) macro.
Coccinelle script:

@@
constant c;
@@

-(1 << c)
+BIT(c)

---
 drivers/staging/comedi/drivers/das08.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/comedi/drivers/das08.c +2 -2
index 327ecf9aea30..65e5f2e6c122 100644
@@ -236,9 +236,9 @@ static int das08_ai_insn_read(struct comedi_device *dev,
 			 * COMEDI 16-bit bipolar data value for 0V is 0x8000.
 			 */
 			if (msb & 0x80)
-				data[n] = (1 << 15) + magnitude;
+				data[n] = BIT(15) + magnitude;
 			else
-				data[n] = (1 << 15) - magnitude;
+				data[n] = BIT(15) - magnitude;
 		} else {
 			dev_err(dev->class_dev, "bug! unknown ai encoding\n");
 			return -1;
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/6 staging: comedi: Prefer using the BIT macro

In reply to Sanjana Sanikommu

Challenge suggested by coccinelle.

Replace bit shifting on 1 with the BIT(x) macro.
Coccinelle script:

@@
constant c;
@@

-(1 << c)
+BIT(c)

---
 drivers/staging/comedi/drivers/ni_at_ao.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/comedi/drivers/ni_at_ao.c +1 -1
index aad0b295ee2b..814895d01ffa 100644
@@ -244,7 +244,7 @@ static int atao_calib_insn_write(struct comedi_device *dev,
 
 		/* write the channel and last data value to the caldac */
 		/* clock the bitstring to the caldac; MSB -> LSB */
-		for (bit = 1 << 10; bit; bit >>= 1) {
+		for (bit = BIT(10); bit; bit >>= 1) {
 			bits = (bit & bitstring) ? ATAO_CFG2_SDATA : 0;
 
 			outw(bits, dev->iobase + ATAO_CFG2_REG);
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/6 staging: comedi: Prefer using the BIT macro

In reply to Sanjana Sanikommu

Challenge suggested by coccinelle.

Replace bit shifting on 1 with the BIT(x) macro.
Coccinelle script:

@@
constant c;
@@

-(1 << c)
+BIT(c)

---
 drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/comedi/drivers/ni_mio_common.c +2 -2
index 5edf59ac6706..cdc9d0ed15c4 100644
@@ -4780,7 +4780,7 @@ static int cs5529_do_conversion(struct comedi_device *dev,
 	if (data) {
 		*data = ni_ao_win_inw(dev, NI67XX_CAL_DATA_REG);
 		/* cs5529 returns 16 bit signed data in bipolar mode */
-		*data ^= (1 << 15);
+		*data ^= BIT(15);
 	}
 	return 0;
 }
@@ -6189,7 +6189,7 @@ static int ni_E_init(struct comedi_device *dev,
 		s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_INTERNAL;
 		/*  one channel for each analog output channel */
 		s->n_chan = board->n_aochan;
-		s->maxdata = (1 << 16) - 1;
+		s->maxdata = BIT(16) - 1;
 		s->range_table = &range_unknown;	/* XXX */
 		s->insn_read = cs5529_ai_insn_read;
 		s->insn_config = NULL;
Signature · 1 line
2.17.1
#4 lore raw

PATCH 4/6 staging: comedi: Prefer using the BIT macro

In reply to Sanjana Sanikommu

Challenge suggested by coccinelle.

Replace bit shifting on 1 with the BIT(x) macro.
Coccinelle script:

@@
constant c;
@@

-(1 << c)
+BIT(c)

---
 drivers/staging/comedi/drivers/dyna_pci10xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/comedi/drivers/dyna_pci10xx.c +1 -1
index e50536731d11..9bdd5bf2eb99 100644
@@ -54,7 +54,7 @@ static int dyna_pci10xx_ai_eoc(struct comedi_device *dev,
 	unsigned int status;
 
 	status = inw_p(dev->iobase);
-	if (status & (1 << 15))
+	if (status & BIT(15))
 		return 0;
 	return -EBUSY;
 }
Signature · 1 line
2.17.1
#5 lore raw
In reply to Sanjana Sanikommu
Quoted 10 lines · Sanjana Sanikommu

This patchset does the following.
1. Replace bit assignment with macro

Sanjana Sanikommu (6):
staging: comedi: das08: Prefer using the BIT macro
staging: comedi: Prefer using the BIT macro
staging: comedi: Prefer using the BIT macro
staging: comedi: Prefer using the BIT macro
staging: comedi: Prefer using the BIT macro
staging: comedi: Prefer using the BIT macro

Each patch needs to have a different subject line.

Since the changes seem to be fairly small, maybe it can just be one patch.

julia

Quoted 19 lines
 drivers/staging/comedi/drivers/amplc_pci230.c  | 2 +-
 drivers/staging/comedi/drivers/das08.c         | 4 ++--
 drivers/staging/comedi/drivers/dyna_pci10xx.c  | 2 +-
 drivers/staging/comedi/drivers/ni_at_ao.c      | 2 +-
 drivers/staging/comedi/drivers/ni_daq_700.c    | 2 +-
 drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++--
 6 files changed, 8 insertions(+), 8 deletions(-)

--
2.17.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190331103204.21358-1-sanjana99reddy99%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#6 lore raw
Quoted 16 lines · Julia Lawall
Quoted 10 lines · Sanjana Sanikommu

This patchset does the following.
1. Replace bit assignment with macro

Sanjana Sanikommu (6):
staging: comedi: das08: Prefer using the BIT macro
staging: comedi: Prefer using the BIT macro
staging: comedi: Prefer using the BIT macro
staging: comedi: Prefer using the BIT macro
staging: comedi: Prefer using the BIT macro
staging: comedi: Prefer using the BIT macro

Quoted 4 lines

Each patch needs to have a different subject line.

Since the changes seem to be fairly small, maybe it can just be one patch.

Sure, I would remove series and make a single patch. Thank you
Sanjana

Quoted 28 lines

julia

Quoted 14 lines
 drivers/staging/comedi/drivers/amplc_pci230.c  | 2 +- 
 drivers/staging/comedi/drivers/das08.c         | 4 ++-- 
 drivers/staging/comedi/drivers/dyna_pci10xx.c  | 2 +- 
 drivers/staging/comedi/drivers/ni_at_ao.c      | 2 +- 
 drivers/staging/comedi/drivers/ni_daq_700.c    | 2 +- 
 drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++-- 
 6 files changed, 8 insertions(+), 8 deletions(-) 
Signature · 4 lines
2.17.1 

-- 
You received this message because you are subscribed to the Google 

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected] <javascript:>.

Quoted 1 line

To post to this group, send email to [email protected]

<javascript:>.

Quoted 1 line

To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/20190331103204.21358-1-sanjana99reddy99%40gmail.com.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

#7 lore raw

PATCH 5/6 staging: comedi: Prefer using the BIT macro

In reply to Sanjana Sanikommu

Challenge suggested by coccinelle.

Replace bit shifting on 1 with the BIT(x) macro.
Coccinelle script:

@@
constant c;
@@

-(1 << c)
+BIT(c)

---
 drivers/staging/comedi/drivers/ni_daq_700.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/comedi/drivers/ni_daq_700.c +1 -1
index b9e525b9beb9..81fd4c26a16f 100644
@@ -239,7 +239,7 @@ static int daq700_auto_attach(struct comedi_device *dev,
 	s->type = COMEDI_SUBD_AI;
 	s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
 	s->n_chan = 16;
-	s->maxdata = (1 << 12) - 1;
+	s->maxdata = BIT(12) - 1;
 	s->range_table = &range_daq700_ai;
 	s->insn_read = daq700_ai_rinsn;
 	daq700_ai_config(dev, s);
Signature · 1 line
2.17.1
#8 lore raw

PATCH 6/6 staging: comedi: Prefer using the BIT macro

In reply to Sanjana Sanikommu

Challenge suggested by coccinelle.

Replace bit shifting on 1 with the BIT(x) macro.
Coccinelle script:

@@
constant c;
@@

-(1 << c)
+BIT(c)

---
 drivers/staging/comedi/drivers/amplc_pci230.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/comedi/drivers/amplc_pci230.c +1 -1
index 08ffe26c5d43..65f60c2b702a 100644
@@ -2464,7 +2464,7 @@ static int pci230_auto_attach(struct comedi_device *dev,
 	devpriv->adcg = 0;
 	devpriv->adccon = PCI230_ADC_TRIG_NONE | PCI230_ADC_IM_SE |
 			  PCI230_ADC_IR_BIP;
-	outw(1 << 0, devpriv->daqio + PCI230_ADCEN);
+	outw(BIT(0), devpriv->daqio + PCI230_ADCEN);
 	outw(devpriv->adcg, devpriv->daqio + PCI230_ADCG);
 	outw(devpriv->adccon | PCI230_ADC_FIFO_RESET,
 	     devpriv->daqio + PCI230_ADCCON);
Signature · 1 line
2.17.1
#9 lore raw

PATCH v2 1/1 staging: comedi: Prefer using BIT macro in various files.

In reply to Sanjana Sanikommu

Challenge suggested by coccinelle.

Replace bit shifting on 1 with the BIT(x) macro.
Coccinelle script:

@@
constant c;
@@

-(1 << c)
+BIT(c)

---
Changes in v2:
Remove patch series and make all changes into 1 patch

 drivers/staging/comedi/drivers/amplc_pci230.c  | 2 +-
 drivers/staging/comedi/drivers/das08.c         | 4 ++--
 drivers/staging/comedi/drivers/dyna_pci10xx.c  | 2 +-
 drivers/staging/comedi/drivers/ni_at_ao.c      | 2 +-
 drivers/staging/comedi/drivers/ni_daq_700.c    | 2 +-
 drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++--
 6 files changed, 8 insertions(+), 8 deletions(-)
drivers/staging/comedi/drivers/amplc_pci230.c +1 -1
index 08ffe26c5d43..65f60c2b702a 100644
@@ -2464,7 +2464,7 @@ static int pci230_auto_attach(struct comedi_device *dev,
 	devpriv->adcg = 0;
 	devpriv->adccon = PCI230_ADC_TRIG_NONE | PCI230_ADC_IM_SE |
 			  PCI230_ADC_IR_BIP;
-	outw(1 << 0, devpriv->daqio + PCI230_ADCEN);
+	outw(BIT(0), devpriv->daqio + PCI230_ADCEN);
 	outw(devpriv->adcg, devpriv->daqio + PCI230_ADCG);
 	outw(devpriv->adccon | PCI230_ADC_FIFO_RESET,
 	     devpriv->daqio + PCI230_ADCCON);
drivers/staging/comedi/drivers/das08.c +2 -2
index 327ecf9aea30..65e5f2e6c122 100644
@@ -236,9 +236,9 @@ static int das08_ai_insn_read(struct comedi_device *dev,
 			 * COMEDI 16-bit bipolar data value for 0V is 0x8000.
 			 */
 			if (msb & 0x80)
-				data[n] = (1 << 15) + magnitude;
+				data[n] = BIT(15) + magnitude;
 			else
-				data[n] = (1 << 15) - magnitude;
+				data[n] = BIT(15) - magnitude;
 		} else {
 			dev_err(dev->class_dev, "bug! unknown ai encoding\n");
 			return -1;
drivers/staging/comedi/drivers/dyna_pci10xx.c +1 -1
index e50536731d11..9bdd5bf2eb99 100644
@@ -54,7 +54,7 @@ static int dyna_pci10xx_ai_eoc(struct comedi_device *dev,
 	unsigned int status;
 
 	status = inw_p(dev->iobase);
-	if (status & (1 << 15))
+	if (status & BIT(15))
 		return 0;
 	return -EBUSY;
 }
drivers/staging/comedi/drivers/ni_at_ao.c +1 -1
index aad0b295ee2b..814895d01ffa 100644
@@ -244,7 +244,7 @@ static int atao_calib_insn_write(struct comedi_device *dev,
 
 		/* write the channel and last data value to the caldac */
 		/* clock the bitstring to the caldac; MSB -> LSB */
-		for (bit = 1 << 10; bit; bit >>= 1) {
+		for (bit = BIT(10); bit; bit >>= 1) {
 			bits = (bit & bitstring) ? ATAO_CFG2_SDATA : 0;
 
 			outw(bits, dev->iobase + ATAO_CFG2_REG);
drivers/staging/comedi/drivers/ni_daq_700.c +1 -1
index b9e525b9beb9..81fd4c26a16f 100644
@@ -239,7 +239,7 @@ static int daq700_auto_attach(struct comedi_device *dev,
 	s->type = COMEDI_SUBD_AI;
 	s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
 	s->n_chan = 16;
-	s->maxdata = (1 << 12) - 1;
+	s->maxdata = BIT(12) - 1;
 	s->range_table = &range_daq700_ai;
 	s->insn_read = daq700_ai_rinsn;
 	daq700_ai_config(dev, s);
drivers/staging/comedi/drivers/ni_mio_common.c +2 -2
index 5edf59ac6706..cdc9d0ed15c4 100644
@@ -4780,7 +4780,7 @@ static int cs5529_do_conversion(struct comedi_device *dev,
 	if (data) {
 		*data = ni_ao_win_inw(dev, NI67XX_CAL_DATA_REG);
 		/* cs5529 returns 16 bit signed data in bipolar mode */
-		*data ^= (1 << 15);
+		*data ^= BIT(15);
 	}
 	return 0;
 }
@@ -6189,7 +6189,7 @@ static int ni_E_init(struct comedi_device *dev,
 		s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_INTERNAL;
 		/*  one channel for each analog output channel */
 		s->n_chan = board->n_aochan;
-		s->maxdata = (1 << 16) - 1;
+		s->maxdata = BIT(16) - 1;
 		s->range_table = &range_unknown;	/* XXX */
 		s->insn_read = cs5529_ai_insn_read;
 		s->insn_config = NULL;
Signature · 1 line
2.17.1