diff mbox series

[3/3] drivers: hwmon: i5k_amb: remove unnecessary #ifdef MODULE

Message ID 1559397700-15585-4-git-send-email-info@metux.net (mailing list archive)
State Changes Requested
Headers show
Series [1/3] drivers: cpufreq: cpufreq-nforce2: remove unnecessary #ifdef MODULE | expand

Commit Message

Enrico Weigelt, metux IT consult June 1, 2019, 2:01 p.m. UTC
The MODULE_DEVICE_TABLE() macro already checks for MODULE defined,
so the extra check here is not necessary.

Signed-off-by: Enrico Weigelt <info@metux.net>
---
 drivers/hwmon/i5k_amb.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Guenter Roeck June 1, 2019, 10:49 p.m. UTC | #1
On Sat, Jun 01, 2019 at 04:01:40PM +0200, Enrico Weigelt, metux IT consult wrote:
> The MODULE_DEVICE_TABLE() macro already checks for MODULE defined,
> so the extra check here is not necessary.
> 
> Signed-off-by: Enrico Weigelt <info@metux.net>
> ---
>  drivers/hwmon/i5k_amb.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c
> index b09c39a..b674c2f 100644
> --- a/drivers/hwmon/i5k_amb.c
> +++ b/drivers/hwmon/i5k_amb.c
> @@ -482,14 +482,12 @@ static int i5k_channel_probe(u16 *amb_present, unsigned long dev_id)
>  	{ 0, 0 }
>  };
>  
> -#ifdef MODULE
>  static const struct pci_device_id i5k_amb_ids[] = {
>  	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5000_ERR) },
>  	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5400_ERR) },
>  	{ 0, }
>  };
>  MODULE_DEVICE_TABLE(pci, i5k_amb_ids);
> -#endif
>  

I'd rather know what this table is used for in the first place.

Guenter

>  static int i5k_amb_probe(struct platform_device *pdev)
>  {
> -- 
> 1.9.1
>
Enrico Weigelt, metux IT consult June 5, 2019, 11:59 p.m. UTC | #2
On 01.06.19 22:49, Guenter Roeck wrote:
> On Sat, Jun 01, 2019 at 04:01:40PM +0200, Enrico Weigelt, metux IT consult wrote:
>> The MODULE_DEVICE_TABLE() macro already checks for MODULE defined,
>> so the extra check here is not necessary.
>>
>> Signed-off-by: Enrico Weigelt <info@metux.net>
>> ---
>>   drivers/hwmon/i5k_amb.c | 2 --
>>   1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c
>> index b09c39a..b674c2f 100644
>> --- a/drivers/hwmon/i5k_amb.c
>> +++ b/drivers/hwmon/i5k_amb.c
>> @@ -482,14 +482,12 @@ static int i5k_channel_probe(u16 *amb_present, unsigned long dev_id)
>>   	{ 0, 0 }
>>   };
>>   
>> -#ifdef MODULE
>>   static const struct pci_device_id i5k_amb_ids[] = {
>>   	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5000_ERR) },
>>   	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5400_ERR) },
>>   	{ 0, }
>>   };
>>   MODULE_DEVICE_TABLE(pci, i5k_amb_ids);
>> -#endif
>>   
> 
> I'd rather know what this table is used for in the first place.

Seems it's really just used for the module loader, while actual probing
is using a different table. IMHO, the worst thing my patch could do is
introducing a warning on unused variable (IMHO shouldn't happen when
it's static const).

I've just rewritten it to move everything into i5k_amb_ids ... just need
to run build tests on it (unfortunately can't run-test, as I don't have
that device).


--mtx
Guenter Roeck June 6, 2019, 1:35 a.m. UTC | #3
On 6/5/19 4:59 PM, Enrico Weigelt, metux IT consult wrote:
> On 01.06.19 22:49, Guenter Roeck wrote:
>> On Sat, Jun 01, 2019 at 04:01:40PM +0200, Enrico Weigelt, metux IT consult wrote:
>>> The MODULE_DEVICE_TABLE() macro already checks for MODULE defined,
>>> so the extra check here is not necessary.
>>>
>>> Signed-off-by: Enrico Weigelt <info@metux.net>
>>> ---
>>>   drivers/hwmon/i5k_amb.c | 2 --
>>>   1 file changed, 2 deletions(-)
>>>
>>> diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c
>>> index b09c39a..b674c2f 100644
>>> --- a/drivers/hwmon/i5k_amb.c
>>> +++ b/drivers/hwmon/i5k_amb.c
>>> @@ -482,14 +482,12 @@ static int i5k_channel_probe(u16 *amb_present, unsigned long dev_id)
>>>       { 0, 0 }
>>>   };
>>> -#ifdef MODULE
>>>   static const struct pci_device_id i5k_amb_ids[] = {
>>>       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5000_ERR) },
>>>       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5400_ERR) },
>>>       { 0, }
>>>   };
>>>   MODULE_DEVICE_TABLE(pci, i5k_amb_ids);
>>> -#endif
>>
>> I'd rather know what this table is used for in the first place.
> 
> Seems it's really just used for the module loader, while actual probing
> is using a different table. IMHO, the worst thing my patch could do is
> introducing a warning on unused variable (IMHO shouldn't happen when
> it's static const).
> 

You are wrong. You'll need __maybe_unused qualifiers for those variables
to avoid the warning.

Guenter

> I've just rewritten it to move everything into i5k_amb_ids ... just need
> to run build tests on it (unfortunately can't run-test, as I don't have
> that device).
> 
> 
> --mtx
>
diff mbox series

Patch

diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c
index b09c39a..b674c2f 100644
--- a/drivers/hwmon/i5k_amb.c
+++ b/drivers/hwmon/i5k_amb.c
@@ -482,14 +482,12 @@  static int i5k_channel_probe(u16 *amb_present, unsigned long dev_id)
 	{ 0, 0 }
 };
 
-#ifdef MODULE
 static const struct pci_device_id i5k_amb_ids[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5000_ERR) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5400_ERR) },
 	{ 0, }
 };
 MODULE_DEVICE_TABLE(pci, i5k_amb_ids);
-#endif
 
 static int i5k_amb_probe(struct platform_device *pdev)
 {