Skip to contentSkip to conversation

PCI: hv: Make functions only used locally static in pci-hyperv.c

PATCH Superseded Krzysztof Wilczynski 5 participants 10 messages Aug 26, 2019 – Sep 4, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: hv: Make functions only used locally static in pci-hyperv.c

Functions hv_read_config_block(), hv_write_config_block() and hv_register_block_invalidate() are not used anywhere else and are local to drivers/pci/controller/pci-hyperv.c, and do not need to be in global scope, so make these static.

Resolve compiler warning that can be seen when building with warnings enabled (W=1).

---
 drivers/pci/controller/pci-hyperv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/controller/pci-hyperv.c +3 -3
index f1f300218fab..c9642e429c2d 100644
@@ -930,7 +930,7 @@ static void hv_pci_read_config_compl(void *context, struct pci_response *resp,
  *
  * Return: 0 on success, -errno on failure
  */
-int hv_read_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
+static int hv_read_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
 			 unsigned int block_id, unsigned int *bytes_returned)
 {
 	struct hv_pcibus_device *hbus =
@@ -1010,7 +1010,7 @@ static void hv_pci_write_config_compl(void *context, struct pci_response *resp,
  *
  * Return: 0 on success, -errno on failure
  */
-int hv_write_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
+static int hv_write_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
 			  unsigned int block_id)
 {
 	struct hv_pcibus_device *hbus =
@@ -1079,7 +1079,7 @@ int hv_write_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
  *
  * Return: 0 on success, -errno on failure
  */
-int hv_register_block_invalidate(struct pci_dev *pdev, void *context,
+static int hv_register_block_invalidate(struct pci_dev *pdev, void *context,
 				 void (*block_invalidate)(void *context,
 							  u64 block_mask))
 {
Signature · 1 line
2.22.1
#1 lore raw

PATCH v2 1/1 PCI: hv: Make functions only used locally static in pci-hyperv.c

Functions hv_read_config_block(), hv_write_config_block() and hv_register_block_invalidate() are not used anywhere else and are local to drivers/pci/controller/pci-hyperv.c, and do not need to be in global scope, so make these static.

Resolve following compiler warning that can be seen when building with warnings enabled (W=1):

drivers/pci/controller/pci-hyperv.c:933:5: warning: no previous prototype for ‘hv_read_config_block’ [-Wmissing-prototypes]
int hv_read_config_block(struct pci_dev *pdev, void *buf, unsigned int len,

     ^
drivers/pci/controller/pci-hyperv.c:1013:5: warning: no previous prototype for ‘hv_write_config_block’ [-Wmissing-prototypes]
 int hv_write_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
     ^
drivers/pci/controller/pci-hyperv.c:1082:5: warning: no previous prototype for ‘hv_register_block_invalidate’ [-Wmissing-prototypes]
 int hv_register_block_invalidate(struct pci_dev *pdev, void *context,
     ^

---
Changes in v2:
Update commit message to include compiler warning.

 drivers/pci/controller/pci-hyperv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/controller/pci-hyperv.c +3 -3
index f1f300218fab..c9642e429c2d 100644
@@ -930,7 +930,7 @@ static void hv_pci_read_config_compl(void *context, struct pci_response *resp,
  *
  * Return: 0 on success, -errno on failure
  */
-int hv_read_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
+static int hv_read_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
 			 unsigned int block_id, unsigned int *bytes_returned)
 {
 	struct hv_pcibus_device *hbus =
@@ -1010,7 +1010,7 @@ static void hv_pci_write_config_compl(void *context, struct pci_response *resp,
  *
  * Return: 0 on success, -errno on failure
  */
-int hv_write_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
+static int hv_write_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
 			  unsigned int block_id)
 {
 	struct hv_pcibus_device *hbus =
@@ -1079,7 +1079,7 @@ int hv_write_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
  *
  * Return: 0 on success, -errno on failure
  */
-int hv_register_block_invalidate(struct pci_dev *pdev, void *context,
+static int hv_register_block_invalidate(struct pci_dev *pdev, void *context,
 				 void (*block_invalidate)(void *context,
 							  u64 block_mask))
 {
Signature · 1 line
2.22.1
#8 lore raw
In reply to Krzysztof Wilczynski

Maybe just:

PCI: hv: Make functions static

since we already know it's in pci-hyperv.c, and it's obvious that you can only do this for functions that are only used locally.

Quoted 7 lines · Krzysztof Wilczynski

Functions hv_read_config_block(), hv_write_config_block() and hv_register_block_invalidate() are not used anywhere else and are local to drivers/pci/controller/pci-hyperv.c, and do not need to be in global scope, so make these static.

Resolve compiler warning that can be seen when building with warnings enabled (W=1).

Rewrap commit log to fill 75 columns.

Does this fix all the similar warnings in drivers/pci/? If there are more, maybe we could fix them all in a single patch or at least a single series?

Quoted 39 lines
---
 drivers/pci/controller/pci-hyperv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/controller/pci-hyperv.c +3 -3
index f1f300218fab..c9642e429c2d 100644
@@ -930,7 +930,7 @@ static void hv_pci_read_config_compl(void *context, struct pci_response *resp,
  *
  * Return: 0 on success, -errno on failure
  */
-int hv_read_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
+static int hv_read_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
 			 unsigned int block_id, unsigned int *bytes_returned)
 {
 	struct hv_pcibus_device *hbus =
@@ -1010,7 +1010,7 @@ static void hv_pci_write_config_compl(void *context, struct pci_response *resp,
  *
  * Return: 0 on success, -errno on failure
  */
-int hv_write_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
+static int hv_write_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
 			  unsigned int block_id)
 {
 	struct hv_pcibus_device *hbus =
@@ -1079,7 +1079,7 @@ int hv_write_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
  *
  * Return: 0 on success, -errno on failure
  */
-int hv_register_block_invalidate(struct pci_dev *pdev, void *context,
+static int hv_register_block_invalidate(struct pci_dev *pdev, void *context,
 				 void (*block_invalidate)(void *context,
 							  u64 block_mask))
 {
Signature · 1 line
2.22.1
maintainer
#2 lore raw
In reply to Krzysztof Wilczynski
Quoted 49 lines

-----Original Message-----
From: Krzysztof Wilczynski <[email protected]> On Behalf Of Krzysztof Wilczynski
Sent: Wednesday, August 28, 2019 3:19 PM
To: Bjorn Helgaas <[email protected]>
Cc: KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; Stephen Hemminger <[email protected]>; Sasha Levin <[email protected]>; Lorenzo Pieralisi <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: [PATCH v2] PCI: hv: Make functions only used locally static in pci- hyperv.c

Functions hv_read_config_block(), hv_write_config_block() and hv_register_block_invalidate() are not used anywhere else and are local to drivers/pci/controller/pci-hyperv.c, and do not need to be in global scope, so make these static.

Resolve following compiler warning that can be seen when building with warnings enabled (W=1):

drivers/pci/controller/pci-hyperv.c:933:5: warning: no previous prototype for ‘hv_read_config_block’ [-Wmissing-prototypes]
int hv_read_config_block(struct pci_dev *pdev, void *buf, unsigned int len,

     ^
drivers/pci/controller/pci-hyperv.c:1013:5: warning: no previous prototype
for ‘hv_write_config_block’ [-Wmissing-prototypes]
 int hv_write_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
     ^
drivers/pci/controller/pci-hyperv.c:1082:5: warning: no previous prototype
for ‘hv_register_block_invalidate’ [-Wmissing-prototypes]
 int hv_register_block_invalidate(struct pci_dev *pdev, void *context,
     ^

---
Changes in v2:
Update commit message to include compiler warning.

 drivers/pci/controller/pci-hyperv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/controller/pci- renamed from drivers/pci/controller/pci-hyperv.c +0 -0

hyperv.c
index f1f300218fab..c9642e429c2d 100644

drivers/pci/controller/pci-hyperv.c static void hv_pci_read_config_compl(void *context, · line 935

Quoted 7 lines
drivers/pci/controller/pci-hyperv.c +1 -1
@@ -930,7 +930,7 @@ static void hv_pci_read_config_compl(void *context,
 struct pci_response *resp,
  *
  * Return: 0 on success, -errno on failure
  */
-int hv_read_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
+static int hv_read_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
 			 unsigned int block_id, unsigned int *bytes_returned)

The second line should be aligned next to the "(" on the first line. Also the first line is now over 80 chars.

Thanks,
- Haiyang

#9 lore raw
In reply to Bjorn Helgaas

Hello Bjorn,
Thank you for feedback.

[...]

Quoted 6 lines

Maybe just:

PCI: hv: Make functions static

since we already know it's in pci-hyperv.c, and it's obvious that you can only do this for functions that are only used locally.

Makes sense. I will update the subject line in v3.

[...]

Quoted 1 line

Rewrap commit log to fill 75 columns.

Sorry about this. I wasn't sure if one also should wrap compiler and/or checkpatch.pl script warnings or errors. I will fix this.

Quoted 3 lines

Does this fix all the similar warnings in drivers/pci/? If there are more, maybe we could fix them all in a single patch or at least a single series?

At the moment, while compiling the drivers/pci the compiler yields a similar warning for the following files:

arch/x86/pci/xen.c
arch/x86/pci/numachip.c
drivers/pci/controller/pci-hyperv.c
drivers/pci/vc.c

I will have a look at each closer.

Krzysztof

#3 lore raw
In reply to Haiyang Zhang

Hello Haiyang,

Thank you for feedback.

[...]

Quoted 2 lines

The second line should be aligned next to the "(" on the first line. Also the first line is now over 80 chars.

Sorry about this. I will fix it in v3. Thank you for pointing this out.

To address both the alignment and line length of hv_register_block_invalidate(), I took a hint from the way how hv_compose_msi_req_v1() is current formatted. I hope that this would be acceptable.

Krzysztof

#4 lore raw

PATCH v3 1/1 PCI: hv: Make functions static

In reply to Krzysztof Wilczynski

Functions hv_read_config_block(), hv_write_config_block() and hv_register_block_invalidate() are not used anywhere else and are local to drivers/pci/controller/pci-hyperv.c, and do not need to be in global scope, so make these static.

Resolve following compiler warning that can be seen when building with warnings enabled (W=1):

drivers/pci/controller/pci-hyperv.c:933:5: warning:
no previous prototype for ‘hv_read_config_block’
[-Wmissing-prototypes]

drivers/pci/controller/pci-hyperv.c:1013:5: warning:
no previous prototype for ‘hv_write_config_block’
[-Wmissing-prototypes]

drivers/pci/controller/pci-hyperv.c:1082:5: warning:
no previous prototype for ‘hv_register_block_invalidate’
[-Wmissing-prototypes]

---
Changes in v3:
Commit message has been wrapped to fit 75 columns. Addressed formatting based on feedback from v2.

Changes in v2:
Update commit message to include compiler warning.

 drivers/pci/controller/pci-hyperv.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/pci/controller/pci-hyperv.c +8 -8
index f1f300218fab..ba988fe033b5 100644
@@ -930,8 +930,9 @@ static void hv_pci_read_config_compl(void *context, struct pci_response *resp,
  *
  * Return: 0 on success, -errno on failure
  */
-int hv_read_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
-			 unsigned int block_id, unsigned int *bytes_returned)
+static int hv_read_config_block(struct pci_dev *pdev, void *buf,
+				unsigned int len, unsigned int block_id,
+				unsigned int *bytes_returned)
 {
 	struct hv_pcibus_device *hbus =
 		container_of(pdev->bus->sysdata, struct hv_pcibus_device,
@@ -1010,8 +1011,8 @@ static void hv_pci_write_config_compl(void *context, struct pci_response *resp,
  *
  * Return: 0 on success, -errno on failure
  */
-int hv_write_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
-			  unsigned int block_id)
+static int hv_write_config_block(struct pci_dev *pdev, void *buf,
+				 unsigned int len, unsigned int block_id)
 {
 	struct hv_pcibus_device *hbus =
 		container_of(pdev->bus->sysdata, struct hv_pcibus_device,
@@ -1079,9 +1080,9 @@ int hv_write_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
  *
  * Return: 0 on success, -errno on failure
  */
-int hv_register_block_invalidate(struct pci_dev *pdev, void *context,
-				 void (*block_invalidate)(void *context,
-							  u64 block_mask))
+static int hv_register_block_invalidate(
+	struct pci_dev *pdev, void *context,
+	void (*block_invalidate)(void *context, u64 block_mask))
 {
 	struct hv_pcibus_device *hbus =
 		container_of(pdev->bus->sysdata, struct hv_pcibus_device,
@@ -1097,7 +1098,6 @@ int hv_register_block_invalidate(struct pci_dev *pdev, void *context,
 
 	put_pcichild(hpdev);
 	return 0;
-
 }
 
 /* Interrupt management hooks */
Signature · 1 line
2.22.1
maintainer Reviewed-by on v3 1/1
#5 lore raw

RE: [PATCH v3] PCI: hv: Make functions static

Quoted 30 lines

-----Original Message-----
From: Krzysztof Wilczynski <[email protected]> On Behalf Of Krzysztof Wilczynski
Sent: Thursday, August 29, 2019 2:17 AM
To: Bjorn Helgaas <[email protected]>
Cc: KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; Stephen Hemminger <[email protected]>; Sasha Levin <[email protected]>; Lorenzo Pieralisi <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: [PATCH v3] PCI: hv: Make functions static

Functions hv_read_config_block(), hv_write_config_block() and hv_register_block_invalidate() are not used anywhere else and are local to drivers/pci/controller/pci-hyperv.c,
and do not need to be in global scope, so make these static.

Resolve following compiler warning that can be seen when building with warnings enabled (W=1):

drivers/pci/controller/pci-hyperv.c:933:5: warning:
no previous prototype for ‘hv_read_config_block’
[-Wmissing-prototypes]

drivers/pci/controller/pci-hyperv.c:1013:5: warning:
no previous prototype for ‘hv_write_config_block’
[-Wmissing-prototypes]

Quoted 5 lines

drivers/pci/controller/pci-hyperv.c:1082:5: warning:
no previous prototype for ‘hv_register_block_invalidate’
[-Wmissing-prototypes]

Thanks!

#6 lore raw

Re: [PATCH v3] PCI: hv: Make functions static

Quoted 30 lines · Haiyang Zhang
Quoted 30 lines

-----Original Message-----
From: Krzysztof Wilczynski <[email protected]> On Behalf Of Krzysztof Wilczynski
Sent: Thursday, August 29, 2019 2:17 AM
To: Bjorn Helgaas <[email protected]>
Cc: KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; Stephen Hemminger <[email protected]>; Sasha Levin <[email protected]>; Lorenzo Pieralisi <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: [PATCH v3] PCI: hv: Make functions static

Functions hv_read_config_block(), hv_write_config_block() and hv_register_block_invalidate() are not used anywhere else and are local to drivers/pci/controller/pci-hyperv.c,
and do not need to be in global scope, so make these static.

Resolve following compiler warning that can be seen when building with warnings enabled (W=1):

drivers/pci/controller/pci-hyperv.c:933:5: warning:
no previous prototype for ‘hv_read_config_block’
[-Wmissing-prototypes]

drivers/pci/controller/pci-hyperv.c:1013:5: warning:
no previous prototype for ‘hv_write_config_block’
[-Wmissing-prototypes]

Quoted 7 lines
Quoted 5 lines

drivers/pci/controller/pci-hyperv.c:1082:5: warning:
no previous prototype for ‘hv_register_block_invalidate’
[-Wmissing-prototypes]

This patch should go via the net tree - the code it is fixing is queued there, I will drop this patch from the PCI review queue.

If it helps:

#7 lore raw

Re: [PATCH v3] PCI: hv: Make functions static

Hello Lorenzo,

[...]

Quoted 3 lines

This patch should go via the net tree - the code it is fixing is queued there, I will drop this patch from the PCI review queue.

[...]

Thank you! Appreciated.

Krzysztof