netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/2] cleanup for Realtek 8139CP
@ 2014-07-22  7:20 varkabhadram
  2014-07-22  7:20 ` [PATCH net-next v2 1/2] ethernet: realtek: use module_pci_driver varkabhadram
  2014-07-22  7:20 ` [PATCH net-next v2 2/2] ethernet: realtek: use pci_device_id varkabhadram
  0 siblings, 2 replies; 9+ messages in thread
From: varkabhadram @ 2014-07-22  7:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, Varka Bhadram

From: Varka Bhadram <varkab@cdac.in>

changes since v1:
	-removed unused varible warning

Varka Bhadram (2):
  ethernet: realtek: use module_pci_driver
  ethernet: realtek: use pci_device_id

 drivers/net/ethernet/realtek/8139cp.c |   36 +++++++++------------------------
 1 file changed, 9 insertions(+), 27 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH net-next v2 1/2] ethernet: realtek: use module_pci_driver
  2014-07-22  7:20 [PATCH net-next v2 0/2] cleanup for Realtek 8139CP varkabhadram
@ 2014-07-22  7:20 ` varkabhadram
  2014-07-22  7:28   ` David Miller
  2014-07-22 14:38   ` Sergei Shtylyov
  2014-07-22  7:20 ` [PATCH net-next v2 2/2] ethernet: realtek: use pci_device_id varkabhadram
  1 sibling, 2 replies; 9+ messages in thread
From: varkabhadram @ 2014-07-22  7:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, Varka Bhadram

From: Varka Bhadram <varkab@cdac.in>

This patch converts to use the macro module_pci_driver, which makes
the code smaller and simpler.

Signed-off-by: Varka Bhadram <varkab@cdac.in>
---
 drivers/net/ethernet/realtek/8139cp.c |   22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
index 2bc728e..9fb68b9 100644
--- a/drivers/net/ethernet/realtek/8139cp.c
+++ b/drivers/net/ethernet/realtek/8139cp.c
@@ -1887,11 +1887,7 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 	resource_size_t pciaddr;
 	unsigned int addr_len, i, pci_using_dac;
 
-#ifndef MODULE
-	static int version_printed;
-	if (version_printed++ == 0)
-		pr_info("%s", version);
-#endif
+	pr_info("%s", version);
 
 	if (pdev->vendor == PCI_VENDOR_ID_REALTEK &&
 	    pdev->device == PCI_DEVICE_ID_REALTEK_8139 && pdev->revision < 0x20) {
@@ -2121,18 +2117,4 @@ static struct pci_driver cp_driver = {
 #endif
 };
 
-static int __init cp_init (void)
-{
-#ifdef MODULE
-	pr_info("%s", version);
-#endif
-	return pci_register_driver(&cp_driver);
-}
-
-static void __exit cp_exit (void)
-{
-	pci_unregister_driver (&cp_driver);
-}
-
-module_init(cp_init);
-module_exit(cp_exit);
+module_pci_driver(cp_driver);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net-next v2 2/2] ethernet: realtek: use pci_device_id
  2014-07-22  7:20 [PATCH net-next v2 0/2] cleanup for Realtek 8139CP varkabhadram
  2014-07-22  7:20 ` [PATCH net-next v2 1/2] ethernet: realtek: use module_pci_driver varkabhadram
@ 2014-07-22  7:20 ` varkabhadram
  1 sibling, 0 replies; 9+ messages in thread
From: varkabhadram @ 2014-07-22  7:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, Varka Bhadram

From: Varka Bhadram <varkab@cdac.in>

This patch use the struct pci_device_id instead of using macro
DEFINE_PCI_DEVICE_TABLE which is deprecated and should not be used.
And also moves these ids after probe and remove functionalities.

Signed-off-by: Varka Bhadram <varkab@cdac.in>
---
 drivers/net/ethernet/realtek/8139cp.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
index 9fb68b9..6873122 100644
--- a/drivers/net/ethernet/realtek/8139cp.c
+++ b/drivers/net/ethernet/realtek/8139cp.c
@@ -382,13 +382,6 @@ static int cp_get_eeprom(struct net_device *dev,
 static int cp_set_eeprom(struct net_device *dev,
 			 struct ethtool_eeprom *eeprom, u8 *data);
 
-static DEFINE_PCI_DEVICE_TABLE(cp_pci_tbl) = {
-	{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK,	PCI_DEVICE_ID_REALTEK_8139), },
-	{ PCI_DEVICE(PCI_VENDOR_ID_TTTECH,	PCI_DEVICE_ID_TTTECH_MC322), },
-	{ },
-};
-MODULE_DEVICE_TABLE(pci, cp_pci_tbl);
-
 static struct {
 	const char str[ETH_GSTRING_LEN];
 } ethtool_stats_keys[] = {
@@ -2106,6 +2099,13 @@ static int cp_resume (struct pci_dev *pdev)
 }
 #endif /* CONFIG_PM */
 
+static const struct pci_device_id cp_pci_tbl[] = {
+        { PCI_DEVICE(PCI_VENDOR_ID_REALTEK,     PCI_DEVICE_ID_REALTEK_8139), },
+        { PCI_DEVICE(PCI_VENDOR_ID_TTTECH,      PCI_DEVICE_ID_TTTECH_MC322), },
+        { },
+};
+MODULE_DEVICE_TABLE(pci, cp_pci_tbl);
+
 static struct pci_driver cp_driver = {
 	.name         = DRV_NAME,
 	.id_table     = cp_pci_tbl,
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next v2 1/2] ethernet: realtek: use module_pci_driver
  2014-07-22  7:20 ` [PATCH net-next v2 1/2] ethernet: realtek: use module_pci_driver varkabhadram
@ 2014-07-22  7:28   ` David Miller
  2014-07-22  8:24     ` Varka Bhadram
  2014-07-22 14:38   ` Sergei Shtylyov
  1 sibling, 1 reply; 9+ messages in thread
From: David Miller @ 2014-07-22  7:28 UTC (permalink / raw)
  To: varkabhadram; +Cc: netdev, varkab

From: varkabhadram@gmail.com
Date: Tue, 22 Jul 2014 12:50:21 +0530

> @@ -1887,11 +1887,7 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
>  	resource_size_t pciaddr;
>  	unsigned int addr_len, i, pci_using_dac;
>  
> -#ifndef MODULE
> -	static int version_printed;
> -	if (version_printed++ == 0)
> -		pr_info("%s", version);
> -#endif
> +	pr_info("%s", version);

Now you're changing behavior undesirably, it will now print the
version string into the logs for every instance of the device which is
discovered.

Seriously, the driver is worse off after these "cleanups".

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next v2 1/2] ethernet: realtek: use module_pci_driver
  2014-07-22  7:28   ` David Miller
@ 2014-07-22  8:24     ` Varka Bhadram
  0 siblings, 0 replies; 9+ messages in thread
From: Varka Bhadram @ 2014-07-22  8:24 UTC (permalink / raw)
  To: David Miller, varkabhadram; +Cc: netdev

On 07/22/2014 12:58 PM, David Miller wrote:
> From: varkabhadram@gmail.com
> Date: Tue, 22 Jul 2014 12:50:21 +0530
>
>> @@ -1887,11 +1887,7 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
>>   	resource_size_t pciaddr;
>>   	unsigned int addr_len, i, pci_using_dac;
>>   
>> -#ifndef MODULE
>> -	static int version_printed;
>> -	if (version_printed++ == 0)
>> -		pr_info("%s", version);
>> -#endif
>> +	pr_info("%s", version);
> Now you're changing behavior undesirably, it will now print the
> version string into the logs for every instance of the device which is
> discovered.
>
> Seriously, the driver is worse off after these "cleanups".

Here we are having two possibilities here:

1. Removing the version info completely. Ofcourse this is not desirable.
  
2. Accepting the version info to be print into log messages.

I will put like this by removing #ifdefs:
	static int version_printed;
	if (version_printed++ == 0)
		pr_info("%s", version);


Will it be OK ..?

-- 
Regards,
Varka Bhadram.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next v2 1/2] ethernet: realtek: use module_pci_driver
  2014-07-22  7:20 ` [PATCH net-next v2 1/2] ethernet: realtek: use module_pci_driver varkabhadram
  2014-07-22  7:28   ` David Miller
@ 2014-07-22 14:38   ` Sergei Shtylyov
  2014-07-22 14:43     ` Varka Bhadram
  1 sibling, 1 reply; 9+ messages in thread
From: Sergei Shtylyov @ 2014-07-22 14:38 UTC (permalink / raw)
  To: varkabhadram, netdev; +Cc: davem, Varka Bhadram

On 07/22/2014 11:20 AM, varkabhadram@gmail.com wrote:

> From: Varka Bhadram <varkab@cdac.in>

> This patch converts to use the macro module_pci_driver, which makes
> the code smaller and simpler.

> Signed-off-by: Varka Bhadram <varkab@cdac.in>
> ---
>   drivers/net/ethernet/realtek/8139cp.c |   22 ++--------------------
>   1 file changed, 2 insertions(+), 20 deletions(-)

> diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
> index 2bc728e..9fb68b9 100644
> --- a/drivers/net/ethernet/realtek/8139cp.c
> +++ b/drivers/net/ethernet/realtek/8139cp.c
> @@ -1887,11 +1887,7 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
>   	resource_size_t pciaddr;
>   	unsigned int addr_len, i, pci_using_dac;
>
> -#ifndef MODULE
> -	static int version_printed;
> -	if (version_printed++ == 0)
> -		pr_info("%s", version);
> -#endif
> +	pr_info("%s", version);

    Use pr_info_once().

WBR, Sergei

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next v2 1/2] ethernet: realtek: use module_pci_driver
  2014-07-22 14:38   ` Sergei Shtylyov
@ 2014-07-22 14:43     ` Varka Bhadram
  2014-07-22 15:01       ` Sergei Shtylyov
  0 siblings, 1 reply; 9+ messages in thread
From: Varka Bhadram @ 2014-07-22 14:43 UTC (permalink / raw)
  To: Sergei Shtylyov, netdev; +Cc: davem, Varka Bhadram

On Tuesday 22 July 2014 08:08 PM, Sergei Shtylyov wrote:
> On 07/22/2014 11:20 AM, varkabhadram@gmail.com wrote:
>
>> From: Varka Bhadram <varkab@cdac.in>
>
>> This patch converts to use the macro module_pci_driver, which makes
>> the code smaller and simpler.
>
>> Signed-off-by: Varka Bhadram <varkab@cdac.in>
>> ---
>>   drivers/net/ethernet/realtek/8139cp.c |   22 ++--------------------
>>   1 file changed, 2 insertions(+), 20 deletions(-)
>
>> diff --git a/drivers/net/ethernet/realtek/8139cp.c 
>> b/drivers/net/ethernet/realtek/8139cp.c
>> index 2bc728e..9fb68b9 100644
>> --- a/drivers/net/ethernet/realtek/8139cp.c
>> +++ b/drivers/net/ethernet/realtek/8139cp.c
>> @@ -1887,11 +1887,7 @@ static int cp_init_one (struct pci_dev *pdev, 
>> const struct pci_device_id *ent)
>>       resource_size_t pciaddr;
>>       unsigned int addr_len, i, pci_using_dac;
>>
>> -#ifndef MODULE
>> -    static int version_printed;
>> -    if (version_printed++ == 0)
>> -        pr_info("%s", version);
>> -#endif
>> +    pr_info("%s", version);
>
>    Use pr_info_once().
>
> WBR, Sergei
>
I am going to utilize the removed code by removing the #ifndef MODULE...

It will be like:

	static int version_printed;

	if (version_printed++ == 0)
		pr_info("%s", version);


Will it be Ok...?

-- 
Regards,
Varka Bhadram

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next v2 1/2] ethernet: realtek: use module_pci_driver
  2014-07-22 14:43     ` Varka Bhadram
@ 2014-07-22 15:01       ` Sergei Shtylyov
  2014-07-22 15:03         ` Varka Bhadram
  0 siblings, 1 reply; 9+ messages in thread
From: Sergei Shtylyov @ 2014-07-22 15:01 UTC (permalink / raw)
  To: Varka Bhadram, netdev; +Cc: davem, Varka Bhadram

On 07/22/2014 06:43 PM, Varka Bhadram wrote:

>>> From: Varka Bhadram <varkab@cdac.in>

>>> This patch converts to use the macro module_pci_driver, which makes
>>> the code smaller and simpler.

>>> Signed-off-by: Varka Bhadram <varkab@cdac.in>
>>> ---
>>>   drivers/net/ethernet/realtek/8139cp.c |   22 ++--------------------
>>>   1 file changed, 2 insertions(+), 20 deletions(-)

>>> diff --git a/drivers/net/ethernet/realtek/8139cp.c
>>> b/drivers/net/ethernet/realtek/8139cp.c
>>> index 2bc728e..9fb68b9 100644
>>> --- a/drivers/net/ethernet/realtek/8139cp.c
>>> +++ b/drivers/net/ethernet/realtek/8139cp.c
>>> @@ -1887,11 +1887,7 @@ static int cp_init_one (struct pci_dev *pdev, const
>>> struct pci_device_id *ent)
>>>       resource_size_t pciaddr;
>>>       unsigned int addr_len, i, pci_using_dac;
>>>
>>> -#ifndef MODULE
>>> -    static int version_printed;
>>> -    if (version_printed++ == 0)
>>> -        pr_info("%s", version);
>>> -#endif
>>> +    pr_info("%s", version);

>>    Use pr_info_once().

>> WBR, Sergei

> I am going to utilize the removed code by removing the #ifndef MODULE...

> It will be like:
>
>      static int version_printed;
>
>      if (version_printed++ == 0)
>          pr_info("%s", version);

    pr_info_once() is much shorter and the effect is the same.

WBR, Sergei

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next v2 1/2] ethernet: realtek: use module_pci_driver
  2014-07-22 15:01       ` Sergei Shtylyov
@ 2014-07-22 15:03         ` Varka Bhadram
  0 siblings, 0 replies; 9+ messages in thread
From: Varka Bhadram @ 2014-07-22 15:03 UTC (permalink / raw)
  To: Sergei Shtylyov, netdev; +Cc: davem, Varka Bhadram

On Tuesday 22 July 2014 08:31 PM, Sergei Shtylyov wrote:
> On 07/22/2014 06:43 PM, Varka Bhadram wrote:
>
>>>> From: Varka Bhadram <varkab@cdac.in>
>
>>>> This patch converts to use the macro module_pci_driver, which makes
>>>> the code smaller and simpler.
>
>>>> Signed-off-by: Varka Bhadram <varkab@cdac.in>
>>>> ---
>>>>   drivers/net/ethernet/realtek/8139cp.c |   22 ++--------------------
>>>>   1 file changed, 2 insertions(+), 20 deletions(-)
>
>>>> diff --git a/drivers/net/ethernet/realtek/8139cp.c
>>>> b/drivers/net/ethernet/realtek/8139cp.c
>>>> index 2bc728e..9fb68b9 100644
>>>> --- a/drivers/net/ethernet/realtek/8139cp.c
>>>> +++ b/drivers/net/ethernet/realtek/8139cp.c
>>>> @@ -1887,11 +1887,7 @@ static int cp_init_one (struct pci_dev 
>>>> *pdev, const
>>>> struct pci_device_id *ent)
>>>>       resource_size_t pciaddr;
>>>>       unsigned int addr_len, i, pci_using_dac;
>>>>
>>>> -#ifndef MODULE
>>>> -    static int version_printed;
>>>> -    if (version_printed++ == 0)
>>>> -        pr_info("%s", version);
>>>> -#endif
>>>> +    pr_info("%s", version);
>
>>>    Use pr_info_once().
>
>>> WBR, Sergei
>
>> I am going to utilize the removed code by removing the #ifndef MODULE...
>
>> It will be like:
>>
>>      static int version_printed;
>>
>>      if (version_printed++ == 0)
>>          pr_info("%s", version);
>
>    pr_info_once() is much shorter and the effect is the same.
>
> WBR, Sergei
>
Thanks for your suggestion. I will do this in next version.


-- 
Regards,
Varka Bhadram

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-07-22 15:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-22  7:20 [PATCH net-next v2 0/2] cleanup for Realtek 8139CP varkabhadram
2014-07-22  7:20 ` [PATCH net-next v2 1/2] ethernet: realtek: use module_pci_driver varkabhadram
2014-07-22  7:28   ` David Miller
2014-07-22  8:24     ` Varka Bhadram
2014-07-22 14:38   ` Sergei Shtylyov
2014-07-22 14:43     ` Varka Bhadram
2014-07-22 15:01       ` Sergei Shtylyov
2014-07-22 15:03         ` Varka Bhadram
2014-07-22  7:20 ` [PATCH net-next v2 2/2] ethernet: realtek: use pci_device_id varkabhadram

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).