diff mbox series

[iwl-next,v1,1/2] igb: simplify pci ops declaration

Message ID 20240210220109.3179408-2-jesse.brandeburg@intel.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series net: intel: cleanup power ops | expand

Checks

Context Check Description
netdev/series_format warning Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 989 this patch: 989
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1006 this patch: 1006
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1006 this patch: 1006
netdev/checkpatch warning CHECK: Alignment should match open parenthesis
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-13--00-00 (tests: 1436)

Commit Message

Jesse Brandeburg Feb. 10, 2024, 10:01 p.m. UTC
The igb driver was pre-declaring tons of functions just so that it could
have an early declaration of the pci_driver struct.

Delete a bunch of the declarations and move the struct to the bottom of the
file, after all the functions are declared.

Reviewed-by: Alan Brady <alan.brady@intel.com>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
---
e1p v2: add back mistakenly deleted pm ops struct.
---
 drivers/net/ethernet/intel/igb/igb_main.c | 51 ++++++++++-------------
 1 file changed, 22 insertions(+), 29 deletions(-)

Comments

Pucha, HimasekharX Reddy Feb. 14, 2024, 10:32 a.m. UTC | #1
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Jesse Brandeburg
> Sent: Sunday, February 11, 2024 3:31 AM
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; Brandeburg, Jesse <jesse.brandeburg@intel.com>; Eric Dumazet <edumazet@google.com>; Nguyen, Anthony L <anthony.l.nguyen@intel.com>; Brady, Alan <alan.brady@intel.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; David S. Miller <davem@davemloft.net>
> Subject: [Intel-wired-lan] [PATCH iwl-next v1 1/2] igb: simplify pci ops declaration
>
> The igb driver was pre-declaring tons of functions just so that it could
> have an early declaration of the pci_driver struct.
>
> Delete a bunch of the declarations and move the struct to the bottom of the
> file, after all the functions are declared.
>
> Reviewed-by: Alan Brady <alan.brady@intel.com>
> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
> ---
> e1p v2: add back mistakenly deleted pm ops struct.
> ---
>  drivers/net/ethernet/intel/igb/igb_main.c | 51 ++++++++++-------------
>  1 file changed, 22 insertions(+), 29 deletions(-)
>

Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
Simon Horman Feb. 19, 2024, 9:15 a.m. UTC | #2
On Sat, Feb 10, 2024 at 02:01:08PM -0800, Jesse Brandeburg wrote:
> The igb driver was pre-declaring tons of functions just so that it could
> have an early declaration of the pci_driver struct.
> 
> Delete a bunch of the declarations and move the struct to the bottom of the
> file, after all the functions are declared.
> 
> Reviewed-by: Alan Brady <alan.brady@intel.com>
> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>

...

> @@ -219,19 +203,6 @@ static const struct pci_error_handlers igb_err_handler = {
>  
>  static void igb_init_dmac(struct igb_adapter *adapter, u32 pba);
>  
> -static struct pci_driver igb_driver = {
> -	.name     = igb_driver_name,
> -	.id_table = igb_pci_tbl,
> -	.probe    = igb_probe,
> -	.remove   = igb_remove,
> -#ifdef CONFIG_PM
> -	.driver.pm = &igb_pm_ops,
> -#endif
> -	.shutdown = igb_shutdown,
> -	.sriov_configure = igb_pci_sriov_configure,
> -	.err_handler = &igb_err_handler
> -};
> -
>  MODULE_AUTHOR("Intel Corporation, <e1000-devel@lists.sourceforge.net>");
>  MODULE_DESCRIPTION("Intel(R) Gigabit Ethernet Network Driver");
>  MODULE_LICENSE("GPL v2");

...

> @@ -10169,4 +10142,24 @@ static void igb_nfc_filter_restore(struct igb_adapter *adapter)
>  
>  	spin_unlock(&adapter->nfc_lock);
>  }
> +
> +#ifdef CONFIG_PM
> +static const struct dev_pm_ops igb_pm_ops = {
> +	SET_SYSTEM_SLEEP_PM_OPS(igb_suspend, igb_resume)
> +	SET_RUNTIME_PM_OPS(igb_runtime_suspend, igb_runtime_resume,
> +			igb_runtime_idle)
> +};
> +#endif
> +
> +static struct pci_driver igb_driver = {
> +	.name     = igb_driver_name,
> +	.id_table = igb_pci_tbl,
> +	.probe    = igb_probe,
> +	.remove   = igb_remove,
> +	.driver.pm = &igb_pm_ops,

Hi Jesse,

the line above causes a build failure if CONFIG_PM is not set.

> +	.shutdown = igb_shutdown,
> +	.sriov_configure = igb_pci_sriov_configure,
> +	.err_handler = &igb_err_handler
> +};
> +
>  /* igb_main.c */

...
Jesse Brandeburg Feb. 20, 2024, 4:48 p.m. UTC | #3
On 2/19/2024 1:15 AM, Simon Horman wrote:
> On Sat, Feb 10, 2024 at 02:01:08PM -0800, Jesse Brandeburg wrote:
>> The igb driver was pre-declaring tons of functions just so that it could
>> have an early declaration of the pci_driver struct.
>>
>> Delete a bunch of the declarations and move the struct to the bottom of the
>> file, after all the functions are declared.
>>
>> Reviewed-by: Alan Brady <alan.brady@intel.com>
>> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>

>> -	.probe    = igb_probe,
>> -	.remove   = igb_remove,
>> -#ifdef CONFIG_PM
>> -	.driver.pm = &igb_pm_ops,
>> -#endif
>> -	.shutdown = igb_shutdown,


>> +	.probe    = igb_probe,
>> +	.remove   = igb_remove,
>> +	.driver.pm = &igb_pm_ops,
> 
> Hi Jesse,
> 
> the line above causes a build failure if CONFIG_PM is not set.

Hi Simon, thanks!

Yeah I missed that, but do we care since patch 2/2 then fixes it?
Simon Horman Feb. 21, 2024, 10:35 a.m. UTC | #4
On Tue, Feb 20, 2024 at 08:48:28AM -0800, Jesse Brandeburg wrote:
> On 2/19/2024 1:15 AM, Simon Horman wrote:
> > On Sat, Feb 10, 2024 at 02:01:08PM -0800, Jesse Brandeburg wrote:
> >> The igb driver was pre-declaring tons of functions just so that it could
> >> have an early declaration of the pci_driver struct.
> >>
> >> Delete a bunch of the declarations and move the struct to the bottom of the
> >> file, after all the functions are declared.
> >>
> >> Reviewed-by: Alan Brady <alan.brady@intel.com>
> >> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
> 
> >> -	.probe    = igb_probe,
> >> -	.remove   = igb_remove,
> >> -#ifdef CONFIG_PM
> >> -	.driver.pm = &igb_pm_ops,
> >> -#endif
> >> -	.shutdown = igb_shutdown,
> 
> 
> >> +	.probe    = igb_probe,
> >> +	.remove   = igb_remove,
> >> +	.driver.pm = &igb_pm_ops,
> > 
> > Hi Jesse,
> > 
> > the line above causes a build failure if CONFIG_PM is not set.
> 
> Hi Simon, thanks!
> 
> Yeah I missed that, but do we care since patch 2/2 then fixes it?

Right. TBH I wrote the above before noticing 2/2.
And I guess it is not a big deal either way.
Paul Menzel Feb. 21, 2024, 11:02 a.m. UTC | #5
Dear Jesse, dear Simon,


Am 21.02.24 um 11:35 schrieb Simon Horman:
> On Tue, Feb 20, 2024 at 08:48:28AM -0800, Jesse Brandeburg wrote:
>> On 2/19/2024 1:15 AM, Simon Horman wrote:
>>> On Sat, Feb 10, 2024 at 02:01:08PM -0800, Jesse Brandeburg wrote:
>>>> The igb driver was pre-declaring tons of functions just so that it could
>>>> have an early declaration of the pci_driver struct.
>>>>
>>>> Delete a bunch of the declarations and move the struct to the bottom of the
>>>> file, after all the functions are declared.
>>>>
>>>> Reviewed-by: Alan Brady <alan.brady@intel.com>
>>>> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
>>
>>>> -	.probe    = igb_probe,
>>>> -	.remove   = igb_remove,
>>>> -#ifdef CONFIG_PM
>>>> -	.driver.pm = &igb_pm_ops,
>>>> -#endif
>>>> -	.shutdown = igb_shutdown,
>>
>>
>>>> +	.probe    = igb_probe,
>>>> +	.remove   = igb_remove,
>>>> +	.driver.pm = &igb_pm_ops,

>>> the line above causes a build failure if CONFIG_PM is not set.

>> Yeah I missed that, but do we care since patch 2/2 then fixes it?
> 
> Right. TBH I wrote the above before noticing 2/2.
> And I guess it is not a big deal either way.

In my opinion, to ease bisecting, each commit should build, so if a 
build failure can be avoided, it’d be great if you could fix this before 
committing.


Kind regards,

Paul
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 4df8d4153aa5..fdca4901defa 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -106,8 +106,6 @@  static int igb_setup_all_rx_resources(struct igb_adapter *);
 static void igb_free_all_tx_resources(struct igb_adapter *);
 static void igb_free_all_rx_resources(struct igb_adapter *);
 static void igb_setup_mrqc(struct igb_adapter *);
-static int igb_probe(struct pci_dev *, const struct pci_device_id *);
-static void igb_remove(struct pci_dev *pdev);
 static void igb_init_queue_configuration(struct igb_adapter *adapter);
 static int igb_sw_init(struct igb_adapter *);
 int igb_open(struct net_device *);
@@ -178,20 +176,6 @@  static int igb_vf_configure(struct igb_adapter *adapter, int vf);
 static int igb_disable_sriov(struct pci_dev *dev, bool reinit);
 #endif
 
-static int igb_suspend(struct device *);
-static int igb_resume(struct device *);
-static int igb_runtime_suspend(struct device *dev);
-static int igb_runtime_resume(struct device *dev);
-static int igb_runtime_idle(struct device *dev);
-#ifdef CONFIG_PM
-static const struct dev_pm_ops igb_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(igb_suspend, igb_resume)
-	SET_RUNTIME_PM_OPS(igb_runtime_suspend, igb_runtime_resume,
-			igb_runtime_idle)
-};
-#endif
-static void igb_shutdown(struct pci_dev *);
-static int igb_pci_sriov_configure(struct pci_dev *dev, int num_vfs);
 #ifdef CONFIG_IGB_DCA
 static int igb_notify_dca(struct notifier_block *, unsigned long, void *);
 static struct notifier_block dca_notifier = {
@@ -219,19 +203,6 @@  static const struct pci_error_handlers igb_err_handler = {
 
 static void igb_init_dmac(struct igb_adapter *adapter, u32 pba);
 
-static struct pci_driver igb_driver = {
-	.name     = igb_driver_name,
-	.id_table = igb_pci_tbl,
-	.probe    = igb_probe,
-	.remove   = igb_remove,
-#ifdef CONFIG_PM
-	.driver.pm = &igb_pm_ops,
-#endif
-	.shutdown = igb_shutdown,
-	.sriov_configure = igb_pci_sriov_configure,
-	.err_handler = &igb_err_handler
-};
-
 MODULE_AUTHOR("Intel Corporation, <e1000-devel@lists.sourceforge.net>");
 MODULE_DESCRIPTION("Intel(R) Gigabit Ethernet Network Driver");
 MODULE_LICENSE("GPL v2");
@@ -647,6 +618,8 @@  struct net_device *igb_get_hw_dev(struct e1000_hw *hw)
 	return adapter->netdev;
 }
 
+static struct pci_driver igb_driver;
+
 /**
  *  igb_init_module - Driver Registration Routine
  *
@@ -10169,4 +10142,24 @@  static void igb_nfc_filter_restore(struct igb_adapter *adapter)
 
 	spin_unlock(&adapter->nfc_lock);
 }
+
+#ifdef CONFIG_PM
+static const struct dev_pm_ops igb_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(igb_suspend, igb_resume)
+	SET_RUNTIME_PM_OPS(igb_runtime_suspend, igb_runtime_resume,
+			igb_runtime_idle)
+};
+#endif
+
+static struct pci_driver igb_driver = {
+	.name     = igb_driver_name,
+	.id_table = igb_pci_tbl,
+	.probe    = igb_probe,
+	.remove   = igb_remove,
+	.driver.pm = &igb_pm_ops,
+	.shutdown = igb_shutdown,
+	.sriov_configure = igb_pci_sriov_configure,
+	.err_handler = &igb_err_handler
+};
+
 /* igb_main.c */