Skip to contentSkip to conversation

Staging: comedi: drivers: Remove unused functions

PATCH Superseded Bhumika Goyal 2 participants 3 messages Sep 14, 2016 – Sep 15, 2016 Staging

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: comedi: drivers: Remove unused functions

The functions s626_get_latch_source, s626_get_load_trig, s626_set_clk_pol and s626_set_index_src are not used anywhere in the kernel. Therefore, remove them. The static unused functions were detected using Coccinelle but the changes were done by hand. Script used :

@initialize:python@
@@
def display(name,p):

	print(name,p[0].file)

@r1@
identifier func;
type T;
position p;
@@
static T func@p(...)
{
...
}

@r@
identifier r1.func;
position p;
@@
(
func(...)
|
func
)

@script:python depends on !r@
func<<r1.func;
p<<r1.p;
@@
display(func,p)

---
 drivers/staging/comedi/drivers/s626.c | 51 -----------------------------------
 1 file changed, 51 deletions(-)
drivers/staging/comedi/drivers/s626.c +0 -51
index 6d89ca0..670d55c 100644
@@ -1034,14 +1034,6 @@ static uint16_t s626_get_enable(struct comedi_device *dev,
 }
 #endif
 
-#ifdef unused
-static uint16_t s626_get_latch_source(struct comedi_device *dev,
-				      unsigned int chan)
-{
-	return S626_GET_CRB_LATCHSRC(s626_debi_read(dev, S626_LP_CRB(chan)));
-}
-#endif
-
 /*
  * Return/set the event that will trigger transfer of the preload
  * register into the counter.  0=ThisCntr_Index, 1=ThisCntr_Overflow,
@@ -1066,19 +1058,6 @@ static void s626_set_load_trig(struct comedi_device *dev,
 	s626_debi_replace(dev, reg, ~mask, set);
 }
 
-#ifdef unused
-static uint16_t s626_get_load_trig(struct comedi_device *dev,
-				   unsigned int chan)
-{
-	if (chan < 3)
-		return S626_GET_CRA_LOADSRC_A(s626_debi_read(dev,
-							S626_LP_CRA(chan)));
-	else
-		return S626_GET_CRB_LOADSRC_B(s626_debi_read(dev,
-							S626_LP_CRB(chan)));
-}
-#endif
-
 /*
  * Return/set counter interrupt source and clear any captured
  * index/overflow events.  int_source: 0=Disabled, 1=OverflowOnly,
@@ -1168,21 +1147,6 @@ static void s626_set_clk_mult(struct comedi_device *dev,
 }
 
 /*
- * Return/set the clock polarity.
- */
-static void s626_set_clk_pol(struct comedi_device *dev,
-			     unsigned int chan, uint16_t value)
-{
-	uint16_t mode;
-
-	mode = s626_get_mode(dev, chan);
-	mode &= ~S626_STDMSK_CLKPOL;
-	mode |= S626_SET_STD_CLKPOL(value);
-
-	s626_set_mode(dev, chan, mode, false);
-}
-
-/*
  * Return/set the encoder mode.
  */
 static void s626_set_enc_mode(struct comedi_device *dev,
@@ -1203,21 +1167,6 @@ static uint16_t s626_get_index_pol(struct comedi_device *dev,
 	return S626_GET_STD_INDXPOL(s626_get_mode(dev, chan));
 }
 
-/*
- * Return/set the index source.
- */
-static void s626_set_index_src(struct comedi_device *dev,
-			       unsigned int chan, uint16_t value)
-{
-	uint16_t mode;
-
-	mode = s626_get_mode(dev, chan);
-	mode &= ~S626_STDMSK_INDXSRC;
-	mode |= S626_SET_STD_INDXSRC(value != 0);
-
-	s626_set_mode(dev, chan, mode, false);
-}
-
 static uint16_t s626_get_index_src(struct comedi_device *dev,
 				   unsigned int chan)
 {
Signature · 1 line
1.9.1
#1 lore raw
Quoted 21 lines · Bhumika Goyal

The functions s626_get_latch_source, s626_get_load_trig, s626_set_clk_pol and s626_set_index_src are not used anywhere in the kernel. Therefore, remove them. The static unused functions were detected using Coccinelle but the changes were done by hand. Script used :

@initialize:python@
@@
def display(name,p):

	print(name,p[0].file)

@r1@
identifier func;
type T;
position p;
@@
static T func@p(...)
{
...
}

Quoted 9 lines

@r@
identifier r1.func;
position p;
@@
(
func(...)
|
func
)

This pattern is unnecessarily complex. The second part (just func), will also match anything the first part matches. So you can just put func.

Quoted 4 lines

@script:python depends on !r@
func<<r1.func;
p<<r1.p;

Perhaps it is just my personal taste, but I always put spaces around <<.

Looks good otherwise.

julia

Quoted 101 lines

@@
display(func,p)

---
 drivers/staging/comedi/drivers/s626.c | 51 -----------------------------------
 1 file changed, 51 deletions(-)
drivers/staging/comedi/drivers/s626.c +0 -52
index 6d89ca0..670d55c 100644
@@ -1034,14 +1034,6 @@ static uint16_t s626_get_enable(struct comedi_device *dev,
 }
 #endif
 
-#ifdef unused
-static uint16_t s626_get_latch_source(struct comedi_device *dev,
-				      unsigned int chan)
-{
-	return S626_GET_CRB_LATCHSRC(s626_debi_read(dev, S626_LP_CRB(chan)));
-}
-#endif
-
 /*
  * Return/set the event that will trigger transfer of the preload
  * register into the counter.  0=ThisCntr_Index, 1=ThisCntr_Overflow,
@@ -1066,19 +1058,6 @@ static void s626_set_load_trig(struct comedi_device *dev,
 	s626_debi_replace(dev, reg, ~mask, set);
 }
 
-#ifdef unused
-static uint16_t s626_get_load_trig(struct comedi_device *dev,
-				   unsigned int chan)
-{
-	if (chan < 3)
-		return S626_GET_CRA_LOADSRC_A(s626_debi_read(dev,
-							S626_LP_CRA(chan)));
-	else
-		return S626_GET_CRB_LOADSRC_B(s626_debi_read(dev,
-							S626_LP_CRB(chan)));
-}
-#endif
-
 /*
  * Return/set counter interrupt source and clear any captured
  * index/overflow events.  int_source: 0=Disabled, 1=OverflowOnly,
@@ -1168,21 +1147,6 @@ static void s626_set_clk_mult(struct comedi_device *dev,
 }
 
 /*
- * Return/set the clock polarity.
- */
-static void s626_set_clk_pol(struct comedi_device *dev,
-			     unsigned int chan, uint16_t value)
-{
-	uint16_t mode;
-
-	mode = s626_get_mode(dev, chan);
-	mode &= ~S626_STDMSK_CLKPOL;
-	mode |= S626_SET_STD_CLKPOL(value);
-
-	s626_set_mode(dev, chan, mode, false);
-}
-
-/*
  * Return/set the encoder mode.
  */
 static void s626_set_enc_mode(struct comedi_device *dev,
@@ -1203,21 +1167,6 @@ static uint16_t s626_get_index_pol(struct comedi_device *dev,
 	return S626_GET_STD_INDXPOL(s626_get_mode(dev, chan));
 }
 
-/*
- * Return/set the index source.
- */
-static void s626_set_index_src(struct comedi_device *dev,
-			       unsigned int chan, uint16_t value)
-{
-	uint16_t mode;
-
-	mode = s626_get_mode(dev, chan);
-	mode &= ~S626_STDMSK_INDXSRC;
-	mode |= S626_SET_STD_INDXSRC(value != 0);
-
-	s626_set_mode(dev, chan, mode, false);
-}
-
 static uint16_t s626_get_index_src(struct comedi_device *dev,
 				   unsigned int chan)
 {
--

1.9.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/1473865793-20468-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 35 lines · Julia Lawall
Quoted 21 lines · Bhumika Goyal

The functions s626_get_latch_source, s626_get_load_trig, s626_set_clk_pol and s626_set_index_src are not used anywhere in the kernel. Therefore, remove them. The static unused functions were detected using Coccinelle but the changes were done by hand. Script used :

@initialize:python@
@@
def display(name,p):

      print(name,p[0].file)

@r1@
identifier func;
type T;
position p;
@@
static T func@p(...)
{
...
}

Quoted 9 lines

@r@
identifier r1.func;
position p;
@@
(
func(...)
|
func
)

Quoted 3 lines

This pattern is unnecessarily complex. The second part (just func), will also match anything the first part matches. So you can just put func.

Yes, it is really unnecessary to put func(...) here. I will make the changes and send a v2 for both the patches.
Thank you for the input.

Quoted 9 lines
Quoted 4 lines

@script:python depends on !r@
func<<r1.func;
p<<r1.p;

Perhaps it is just my personal taste, but I always put spaces around <<.

Looks good otherwise.

Ok, I will keep this in mind too :D.

Thanks,
Bhumika

Quoted 103 lines

julia

Quoted 101 lines

@@
display(func,p)

---
 drivers/staging/comedi/drivers/s626.c | 51 -----------------------------------
 1 file changed, 51 deletions(-)
drivers/staging/comedi/drivers/s626.c +0 -52
index 6d89ca0..670d55c 100644
@@ -1034,14 +1034,6 @@ static uint16_t s626_get_enable(struct comedi_device *dev,
 }
 #endif
 
-#ifdef unused
-static uint16_t s626_get_latch_source(struct comedi_device *dev,
-                                   unsigned int chan)
-{
-     return S626_GET_CRB_LATCHSRC(s626_debi_read(dev, S626_LP_CRB(chan)));
-}
-#endif
-
 /*
  * Return/set the event that will trigger transfer of the preload
  * register into the counter.  0=ThisCntr_Index, 1=ThisCntr_Overflow,
@@ -1066,19 +1058,6 @@ static void s626_set_load_trig(struct comedi_device *dev,
      s626_debi_replace(dev, reg, ~mask, set);
 }
 
-#ifdef unused
-static uint16_t s626_get_load_trig(struct comedi_device *dev,
-                                unsigned int chan)
-{
-     if (chan < 3)
-             return S626_GET_CRA_LOADSRC_A(s626_debi_read(dev,
-                                                     S626_LP_CRA(chan)));
-     else
-             return S626_GET_CRB_LOADSRC_B(s626_debi_read(dev,
-                                                     S626_LP_CRB(chan)));
-}
-#endif
-
 /*
  * Return/set counter interrupt source and clear any captured
  * index/overflow events.  int_source: 0=Disabled, 1=OverflowOnly,
@@ -1168,21 +1147,6 @@ static void s626_set_clk_mult(struct comedi_device *dev,
 }
 
 /*
- * Return/set the clock polarity.
- */
-static void s626_set_clk_pol(struct comedi_device *dev,
-                          unsigned int chan, uint16_t value)
-{
-     uint16_t mode;
-
-     mode = s626_get_mode(dev, chan);
-     mode &= ~S626_STDMSK_CLKPOL;
-     mode |= S626_SET_STD_CLKPOL(value);
-
-     s626_set_mode(dev, chan, mode, false);
-}
-
-/*
  * Return/set the encoder mode.
  */
 static void s626_set_enc_mode(struct comedi_device *dev,
@@ -1203,21 +1167,6 @@ static uint16_t s626_get_index_pol(struct comedi_device *dev,
      return S626_GET_STD_INDXPOL(s626_get_mode(dev, chan));
 }
 
-/*
- * Return/set the index source.
- */
-static void s626_set_index_src(struct comedi_device *dev,
-                            unsigned int chan, uint16_t value)
-{
-     uint16_t mode;
-
-     mode = s626_get_mode(dev, chan);
-     mode &= ~S626_STDMSK_INDXSRC;
-     mode |= S626_SET_STD_INDXSRC(value != 0);
-
-     s626_set_mode(dev, chan, mode, false);
-}
-
 static uint16_t s626_get_index_src(struct comedi_device *dev,
                                 unsigned int chan)
 {
--

1.9.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/1473865793-20468-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.