Patchwork [1/2] PCI: sysfs: Staticize local symbols

login
register
mail settings
Submitter Sachin Kamat
Date Sept. 28, 2013, 10:12 a.m.
Message ID <1380363121-1977-1-git-send-email-sachin.kamat@linaro.org>
Download mbox | patch
Permalink /patch/278729/
State Accepted
Headers show

Comments

Sachin Kamat - Sept. 28, 2013, 10:12 a.m.
Local variables used only in this file are made static.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/pci/pci-sysfs.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
Bjorn Helgaas - Oct. 4, 2013, 6:09 p.m.
On Sat, Sep 28, 2013 at 4:12 AM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
> Local variables used only in this file are made static.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
>  drivers/pci/pci-sysfs.c |   14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index d8eb880..ec1dbea 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -304,7 +304,7 @@ static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf,
>  }
>  static BUS_ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, bus_rescan_store);
>
> -struct attribute *pci_bus_attrs[] = {
> +static struct attribute *pci_bus_attrs[] = {

Did you compile this?  I see this:

drivers/pci/pci-sysfs.c:306:29: error: static declaration of
‘pci_bus_attrs’ follows non-static declaration
drivers/pci/pci.h:159:29: note: previous declaration of ‘pci_bus_attrs’ was here

and there is a use in drivers/pci/pci-driver.c.

I applied this (without the pci_bus_attrs hunk) to my pci/misc branch, thanks!

Bjorn

>         &bus_attr_rescan.attr,
>         NULL,
>  };
> @@ -335,8 +335,9 @@ dev_rescan_store(struct device *dev, struct device_attribute *attr,
>         }
>         return count;
>  }
> -struct device_attribute dev_rescan_attr = __ATTR(rescan, (S_IWUSR|S_IWGRP),
> -                                                NULL, dev_rescan_store);
> +static struct device_attribute dev_rescan_attr = __ATTR(rescan,
> +                                                       (S_IWUSR|S_IWGRP),
> +                                                       NULL, dev_rescan_store);
>
>  static void remove_callback(struct device *dev)
>  {
> @@ -366,8 +367,9 @@ remove_store(struct device *dev, struct device_attribute *dummy,
>                 count = ret;
>         return count;
>  }
> -struct device_attribute dev_remove_attr = __ATTR(remove, (S_IWUSR|S_IWGRP),
> -                                                NULL, remove_store);
> +static struct device_attribute dev_remove_attr = __ATTR(remove,
> +                                                       (S_IWUSR|S_IWGRP),
> +                                                       NULL, remove_store);
>
>  static ssize_t
>  dev_bus_rescan_store(struct device *dev, struct device_attribute *attr,
> @@ -554,7 +556,7 @@ boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf)
>                 !!(pdev->resource[PCI_ROM_RESOURCE].flags &
>                    IORESOURCE_ROM_SHADOW));
>  }
> -struct device_attribute vga_attr = __ATTR_RO(boot_vga);
> +static struct device_attribute vga_attr = __ATTR_RO(boot_vga);
>
>  static ssize_t
>  pci_read_config(struct file *filp, struct kobject *kobj,
> --
> 1.7.9.5
>
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sachin Kamat - Oct. 7, 2013, 3:55 a.m.
On 4 October 2013 23:39, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Sat, Sep 28, 2013 at 4:12 AM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
>>
>> -struct attribute *pci_bus_attrs[] = {
>> +static struct attribute *pci_bus_attrs[] = {
>
> Did you compile this?  I see this:
>
> drivers/pci/pci-sysfs.c:306:29: error: static declaration of
> ‘pci_bus_attrs’ follows non-static declaration
> drivers/pci/pci.h:159:29: note: previous declaration of ‘pci_bus_attrs’ was here

Hmm.. strange. I did compile both these patches and did not see this
error on my setup.
Infact it was during compilation that I came across the need for this
change and verified it after. However I used
the linux-next tree and not your tree to generate these.

>
> and there is a use in drivers/pci/pci-driver.c.
>
> I applied this (without the pci_bus_attrs hunk) to my pci/misc branch, thanks!

Thanks for taking care of this and sorry for the trouble. I will check
this once again on my setup.

With warm regards,
Sachin
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjorn Helgaas - Oct. 7, 2013, 5:40 p.m.
On Sun, Oct 6, 2013 at 9:55 PM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
> On 4 October 2013 23:39, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> On Sat, Sep 28, 2013 at 4:12 AM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
>>>
>>> -struct attribute *pci_bus_attrs[] = {
>>> +static struct attribute *pci_bus_attrs[] = {
>>
>> Did you compile this?  I see this:
>>
>> drivers/pci/pci-sysfs.c:306:29: error: static declaration of
>> ‘pci_bus_attrs’ follows non-static declaration
>> drivers/pci/pci.h:159:29: note: previous declaration of ‘pci_bus_attrs’ was here
>
> Hmm.. strange. I did compile both these patches and did not see this
> error on my setup.
> Infact it was during compilation that I came across the need for this
> change and verified it after. However I used
> the linux-next tree and not your tree to generate these.

Oh, I see what happened.  Greg's 244afeca ("PCI: convert bus code to
use bus_groups") removed the use of pci_bus_attrs[] in pci-driver.c.
That commit is in linux-next, but not in my tree.  I probably should
have merged that commit via my tree to avoid confusion like this.  Oh,
well, maybe I'll do better next time.

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjorn Helgaas - Oct. 7, 2013, 9:17 p.m.
[+cc Greg]

On Mon, Oct 7, 2013 at 11:40 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Sun, Oct 6, 2013 at 9:55 PM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
>> On 4 October 2013 23:39, Bjorn Helgaas <bhelgaas@google.com> wrote:
>>> On Sat, Sep 28, 2013 at 4:12 AM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
>>>>
>>>> -struct attribute *pci_bus_attrs[] = {
>>>> +static struct attribute *pci_bus_attrs[] = {
>>>
>>> Did you compile this?  I see this:
>>>
>>> drivers/pci/pci-sysfs.c:306:29: error: static declaration of
>>> ‘pci_bus_attrs’ follows non-static declaration
>>> drivers/pci/pci.h:159:29: note: previous declaration of ‘pci_bus_attrs’ was here
>>
>> Hmm.. strange. I did compile both these patches and did not see this
>> error on my setup.
>> Infact it was during compilation that I came across the need for this
>> change and verified it after. However I used
>> the linux-next tree and not your tree to generate these.
>
> Oh, I see what happened.  Greg's 244afeca ("PCI: convert bus code to
> use bus_groups") removed the use of pci_bus_attrs[] in pci-driver.c.
> That commit is in linux-next, but not in my tree.  I probably should
> have merged that commit via my tree to avoid confusion like this.  Oh,
> well, maybe I'll do better next time.

OK, I cherry-picked Greg's changes, then applied your original patch on top:

16373b2 PCI: Make pci_bus_attrs, dev_rescan_attr, dev_remove_attr,
vga_attr static
5136b2d PCI: convert bus code to use dev_groups
2229c1f PCI: convert bus code to use drv_groups
0f49ba5 PCI: convert bus code to use bus_groups

These are all in my pci/gregkh-driver-core branch, which will go in
v3.13.  Thanks!

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index d8eb880..ec1dbea 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -304,7 +304,7 @@  static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf,
 }
 static BUS_ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, bus_rescan_store);
 
-struct attribute *pci_bus_attrs[] = {
+static struct attribute *pci_bus_attrs[] = {
 	&bus_attr_rescan.attr,
 	NULL,
 };
@@ -335,8 +335,9 @@  dev_rescan_store(struct device *dev, struct device_attribute *attr,
 	}
 	return count;
 }
-struct device_attribute dev_rescan_attr = __ATTR(rescan, (S_IWUSR|S_IWGRP),
-						 NULL, dev_rescan_store);
+static struct device_attribute dev_rescan_attr = __ATTR(rescan,
+							(S_IWUSR|S_IWGRP),
+							NULL, dev_rescan_store);
 
 static void remove_callback(struct device *dev)
 {
@@ -366,8 +367,9 @@  remove_store(struct device *dev, struct device_attribute *dummy,
 		count = ret;
 	return count;
 }
-struct device_attribute dev_remove_attr = __ATTR(remove, (S_IWUSR|S_IWGRP),
-						 NULL, remove_store);
+static struct device_attribute dev_remove_attr = __ATTR(remove,
+							(S_IWUSR|S_IWGRP),
+							NULL, remove_store);
 
 static ssize_t
 dev_bus_rescan_store(struct device *dev, struct device_attribute *attr,
@@ -554,7 +556,7 @@  boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf)
 		!!(pdev->resource[PCI_ROM_RESOURCE].flags &
 		   IORESOURCE_ROM_SHADOW));
 }
-struct device_attribute vga_attr = __ATTR_RO(boot_vga);
+static struct device_attribute vga_attr = __ATTR_RO(boot_vga);
 
 static ssize_t
 pci_read_config(struct file *filp, struct kobject *kobj,