RE: [PATCH] staging: comedi: gsc_hpdi: make internal functions static

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday, September 24, 2012 7:48 AM, Ian Abbott wrote:
> This module does not export any symbols so declare all the functions as
> `static`.  Some of them are currently unused but might get used in the
> future, so tag them as `__maybe_unused` for now to get rid of compiler
> warnings.
>
> Signed-off-by: Ian Abbott <abbotti@xxxxxxxxx>
> ---
>  drivers/staging/comedi/drivers/gsc_hpdi.c | 41 +++++++++++++++++--------------
>  1 file changed, 22 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c
> index 5d3fa71..5fbd827 100644
> --- a/drivers/staging/comedi/drivers/gsc_hpdi.c
> +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c
> @@ -104,7 +104,7 @@ enum hpdi_registers {
>  	INTERRUPT_POLARITY_REG = 0x54,
>  };
>  
> -int command_channel_valid(unsigned int channel)
> +static int command_channel_valid(unsigned int channel)
>  {
>  	if (channel == 0 || channel > 6) {
>  		printk(KERN_WARNING

Ian,

Many of these should either just be removed or converted to macros.
Then the __maybe_unused would not be needed. This one could just
be something like:

#define CMD_CHAN_VALID(x)		((((x) > 0) && ((x) <= 6)) ? 1 : 0)

> @@ -119,17 +119,18 @@ int command_channel_valid(unsigned int channel)
>  enum firmware_revision_bits {
>  	FEATURES_REG_PRESENT_BIT = 0x8000,
>  };
> -int firmware_revision(uint32_t fwr_bits)
> +
> +static int __maybe_unused firmware_revision(uint32_t fwr_bits)
>  {
>  	return fwr_bits & 0xff;
>  }

#define FIRMWARE_REV(x)		((x) & 0xff)
 
> -int pcb_revision(uint32_t fwr_bits)
> +static int __maybe_unused pcb_revision(uint32_t fwr_bits)
>  {
>  	return (fwr_bits >> 8) & 0xff;
>  }
 
#define PCB_REV(x)		(((x) >> 8) & 0xff)

> -int hpdi_subid(uint32_t fwr_bits)
> +static int __maybe_unused hpdi_subid(uint32_t fwr_bits)
>  {
>  	return (fwr_bits >> 16) & 0xff;
>  }

#define HPDI_SUBID(x)		(((x) >> 16) & 0xff)

> @@ -147,8 +148,9 @@ enum board_control_bits {
>  	CABLE_THROTTLE_ENABLE_BIT = 0x20,
>  	TEST_MODE_ENABLE_BIT = 0x80000000,
>  };
> -uint32_t command_discrete_output_bits(unsigned int channel, int output,
> -				      int output_value)
> +
> +static uint32_t __maybe_unused
> +command_discrete_output_bits(unsigned int channel, int output, int output_value)
>  {
>  	uint32_t bits = 0;
>  
> @@ -182,24 +184,24 @@ enum board_status_bits {
>  	RX_OVERRUN_BIT = 0x800000,
>  };

This one is a bit messy to be a macro. It's also not used so 
maybe just remove it.

>  
> -uint32_t almost_full_bits(unsigned int num_words)
> +static uint32_t almost_full_bits(unsigned int num_words)
>  {
> -/* XXX need to add or subtract one? */
> +	/* XXX need to add or subtract one? */
>  	return (num_words << 16) & 0xff0000;
>  }

#deifne ALMOST_FULL_BITS(x)	(((x) << 16) & 0xff0000)

>  
> -uint32_t almost_empty_bits(unsigned int num_words)
> +static uint32_t almost_empty_bits(unsigned int num_words)
>  {
>  	return num_words & 0xffff;
>  }

#define ALMOST_EMPTY_BITS(x)	((x) & 0xffff)
 
> -unsigned int almost_full_num_words(uint32_t bits)
> +static unsigned int __maybe_unused almost_full_num_words(uint32_t bits)
>  {
> -/* XXX need to add or subtract one? */
> +	/* XXX need to add or subtract one? */
>  	return (bits >> 16) & 0xffff;
>  }

#define ALMOST_FULL_NUM_WORDS(x)	(((x) >> 16) & 0xffff)
 
> -unsigned int almost_empty_num_words(uint32_t bits)
> +static unsigned int __maybe_unused almost_empty_num_words(uint32_t bits)
>  {
>  	return bits & 0xffff;
>  }

#define ALMOST_EMPTY_NUM_WORDS(x)	((x) & 0xffff)

> @@ -225,39 +227,40 @@ enum interrupt_sources {
>  	RX_ALMOST_FULL_INTR = 14,
>  	RX_FULL_INTR = 15,
>  };
> -int command_intr_source(unsigned int channel)
> +
> +static int __maybe_unused command_intr_source(unsigned int channel)
>  {
>  	if (command_channel_valid(channel) == 0)
>  		channel = 1;
>  	return channel + 1;
>  }

#define CMD_INTR_SOURCE(x)	(CMD_CHAN_VALID(x) ? ((x) + 1) : 1)

> -uint32_t intr_bit(int interrupt_source)
> +static uint32_t intr_bit(int interrupt_source)
>  {
>  	return 0x1 << interrupt_source;
>  }
 
#define INTR_BIT(x)		(1 << (x))

> -uint32_t tx_clock_divisor_bits(unsigned int divisor)
> +static uint32_t __maybe_unused tx_clock_divisor_bits(unsigned int divisor)
>  {
>  	return divisor & 0xff;
>  }

#define TX_CLK_DIV(x)	((x) & 0xff)
 
> -unsigned int fifo_size(uint32_t fifo_size_bits)
> +static unsigned int fifo_size(uint32_t fifo_size_bits)
>  {
>  	return fifo_size_bits & 0xfffff;
>  }
 
#define FIFO_SIZE(x)		((x) & 0x fffff)

> -unsigned int fifo_words(uint32_t fifo_words_bits)
> +static unsigned int __maybe_unused fifo_words(uint32_t fifo_words_bits)
>  {
>  	return fifo_words_bits & 0xfffff;
>  }
 
#define FIFO_WORDS(x)	((x) & 0xfffff)

> -uint32_t intr_edge_bit(int interrupt_source)
> +static uint32_t __maybe_unused intr_edge_bit(int interrupt_source)
>  {
>  	return 0x1 << interrupt_source;
>  }
 
#define INTR_EDGE_BIT(x)	(1 << (x))

> -uint32_t intr_active_high_bit(int interrupt_source)
> +static uint32_t __maybe_unused intr_active_high_bit(int interrupt_source)
>  {
>  	return 0x1 << interrupt_source;
>  }

#define INTR_ACTIVE_HIGH_BIT(x)	(1 << (x))

Regards,
Hartley

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux