All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] cleanup unnecessary checking for pci_bus_add_device()
@ 2014-05-29  7:01 Yijing Wang
  2014-05-29  7:01 ` [PATCH 1/3] PCI: remove the unnecssary checking for pci_bus_add_device Yijing Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Yijing Wang @ 2014-05-29  7:01 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, Yinghai Lu, Yijing Wang


Yijing Wang (3):
  PCI: remove the unnecssary checking for pci_bus_add_device
  platform/x86: remove the unnecessary checking for pci_bus_add_device
  edac: remove the unnecessary checking for pci_bus_add_device

 drivers/edac/i82875p_edac.c         |    7 +------
 drivers/pci/bus.c                   |    6 +-----
 drivers/pci/iov.c                   |    2 +-
 drivers/platform/x86/asus-wmi.c     |    3 +--
 drivers/platform/x86/eeepc-laptop.c |    3 +--
 include/linux/pci.h                 |    2 +-
 6 files changed, 6 insertions(+), 17 deletions(-)



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

* [PATCH 1/3] PCI: remove the unnecssary checking for pci_bus_add_device
  2014-05-29  7:01 [PATCH 0/3] cleanup unnecessary checking for pci_bus_add_device() Yijing Wang
@ 2014-05-29  7:01 ` Yijing Wang
  2014-05-30  2:07   ` Bjorn Helgaas
  2014-05-29  7:01 ` [PATCH 2/3] platform/x86: remove the unnecessary " Yijing Wang
  2014-05-29  7:01 ` [PATCH 3/3] edac: " Yijing Wang
  2 siblings, 1 reply; 7+ messages in thread
From: Yijing Wang @ 2014-05-29  7:01 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, Yinghai Lu, Yijing Wang

Kernel will WARN_ON(retval < 0) if device_attach() fail with
error in pci_bus_add_device(). currently, all the kernel code
to check pci_bus_add_device() return value only for printing
warning message, no other actions. So we can remove the
unnecessary checking codes.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/pci/bus.c   |    6 +-----
 drivers/pci/iov.c   |    2 +-
 include/linux/pci.h |    2 +-
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index ba2bf55..f0efbee 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -266,16 +266,12 @@ void pci_bus_add_devices(const struct pci_bus *bus)
 {
 	struct pci_dev *dev;
 	struct pci_bus *child;
-	int retval;
 
 	list_for_each_entry(dev, &bus->devices, bus_list) {
 		/* Skip already-added devices */
 		if (dev->is_added)
 			continue;
-		retval = pci_bus_add_device(dev);
-		if (retval)
-			dev_err(&dev->dev, "Error adding device (%d)\n",
-				retval);
+		pci_bus_add_device(dev);
 	}
 
 	list_for_each_entry(dev, &bus->devices, bus_list) {
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index de7a747..cb6f247 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -106,7 +106,7 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
 	pci_device_add(virtfn, virtfn->bus);
 	mutex_unlock(&iov->dev->sriov->lock);
 
-	rc = pci_bus_add_device(virtfn);
+	pci_bus_add_device(virtfn);
 	sprintf(buf, "virtfn%u", id);
 	rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf);
 	if (rc)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 65f22e8..3c4c0cf 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -781,7 +781,7 @@ int pci_scan_slot(struct pci_bus *bus, int devfn);
 struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn);
 void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);
 unsigned int pci_scan_child_bus(struct pci_bus *bus);
-int __must_check pci_bus_add_device(struct pci_dev *dev);
+int pci_bus_add_device(struct pci_dev *dev);
 void pci_read_bridge_bases(struct pci_bus *child);
 struct resource *pci_find_parent_resource(const struct pci_dev *dev,
 					  struct resource *res);
-- 
1.7.1



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

* [PATCH 2/3] platform/x86: remove the unnecessary checking for pci_bus_add_device
  2014-05-29  7:01 [PATCH 0/3] cleanup unnecessary checking for pci_bus_add_device() Yijing Wang
  2014-05-29  7:01 ` [PATCH 1/3] PCI: remove the unnecssary checking for pci_bus_add_device Yijing Wang
@ 2014-05-29  7:01 ` Yijing Wang
  2014-05-29  7:01 ` [PATCH 3/3] edac: " Yijing Wang
  2 siblings, 0 replies; 7+ messages in thread
From: Yijing Wang @ 2014-05-29  7:01 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, Yinghai Lu, Yijing Wang

Pci_bus_add_device() always return 0, remove the unnecessary checking
for pci_bus_add_device().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/platform/x86/asus-wmi.c     |    3 +--
 drivers/platform/x86/eeepc-laptop.c |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index c5e082f..91ef69a 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -642,8 +642,7 @@ static void asus_rfkill_hotplug(struct asus_wmi *asus)
 			dev = pci_scan_single_device(bus, 0);
 			if (dev) {
 				pci_bus_assign_resources(bus);
-				if (pci_bus_add_device(dev))
-					pr_err("Unable to hotplug wifi\n");
+				pci_bus_add_device(dev);
 			}
 		} else {
 			dev = pci_get_slot(bus, 0);
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 399e8c5..9b0c57c 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -633,8 +633,7 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc, acpi_handle handle)
 			dev = pci_scan_single_device(bus, 0);
 			if (dev) {
 				pci_bus_assign_resources(bus);
-				if (pci_bus_add_device(dev))
-					pr_err("Unable to hotplug wifi\n");
+				pci_bus_add_device(dev);
 			}
 		} else {
 			dev = pci_get_slot(bus, 0);
-- 
1.7.1



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

* [PATCH 3/3] edac: remove the unnecessary checking for pci_bus_add_device
  2014-05-29  7:01 [PATCH 0/3] cleanup unnecessary checking for pci_bus_add_device() Yijing Wang
  2014-05-29  7:01 ` [PATCH 1/3] PCI: remove the unnecssary checking for pci_bus_add_device Yijing Wang
  2014-05-29  7:01 ` [PATCH 2/3] platform/x86: remove the unnecessary " Yijing Wang
@ 2014-05-29  7:01 ` Yijing Wang
  2014-05-29 22:13   ` Yinghai Lu
  2 siblings, 1 reply; 7+ messages in thread
From: Yijing Wang @ 2014-05-29  7:01 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, Yinghai Lu, Yijing Wang

Pci_bus_add_device() always return 0, remove the unnecessary
checking for pci_bus_add_device().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/edac/i82875p_edac.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/drivers/edac/i82875p_edac.c b/drivers/edac/i82875p_edac.c
index 8d0450b..8705ba6 100644
--- a/drivers/edac/i82875p_edac.c
+++ b/drivers/edac/i82875p_edac.c
@@ -293,12 +293,7 @@ static int i82875p_setup_overfl_dev(struct pci_dev *pdev,
 		if (dev == NULL)
 			return 1;
 
-		err = pci_bus_add_device(dev);
-		if (err) {
-			i82875p_printk(KERN_ERR,
-				"%s(): pci_bus_add_device() Failed\n",
-				__func__);
-		}
+		pci_bus_add_device(dev);
 		pci_bus_assign_resources(dev->bus);
 	}
 
-- 
1.7.1



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

* Re: [PATCH 3/3] edac: remove the unnecessary checking for pci_bus_add_device
  2014-05-29  7:01 ` [PATCH 3/3] edac: " Yijing Wang
@ 2014-05-29 22:13   ` Yinghai Lu
  0 siblings, 0 replies; 7+ messages in thread
From: Yinghai Lu @ 2014-05-29 22:13 UTC (permalink / raw)
  To: Yijing Wang, Ingo Molnar, Borislav Petkov, H. Peter Anvin
  Cc: Bjorn Helgaas, linux-pci

On Thu, May 29, 2014 at 12:01 AM, Yijing Wang <wangyijing@huawei.com> wrote:
> Pci_bus_add_device() always return 0, remove the unnecessary
> checking for pci_bus_add_device().
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> ---
>  drivers/edac/i82875p_edac.c |    7 +------
>  1 files changed, 1 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/edac/i82875p_edac.c b/drivers/edac/i82875p_edac.c
> index 8d0450b..8705ba6 100644
> --- a/drivers/edac/i82875p_edac.c
> +++ b/drivers/edac/i82875p_edac.c
> @@ -293,12 +293,7 @@ static int i82875p_setup_overfl_dev(struct pci_dev *pdev,
>                 if (dev == NULL)
>                         return 1;
>
> -               err = pci_bus_add_device(dev);
> -               if (err) {
> -                       i82875p_printk(KERN_ERR,
> -                               "%s(): pci_bus_add_device() Failed\n",
> -                               __func__);
> -               }
> +               pci_bus_add_device(dev);
>                 pci_bus_assign_resources(dev->bus);
>         }

Bjorn,

At same time, can you please apply

http://patchwork.ozlabs.org/patch/242480/

PCI, EDAC: fix ordering assign resource and bus_add

Thanks

Yinghai

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

* Re: [PATCH 1/3] PCI: remove the unnecssary checking for pci_bus_add_device
  2014-05-29  7:01 ` [PATCH 1/3] PCI: remove the unnecssary checking for pci_bus_add_device Yijing Wang
@ 2014-05-30  2:07   ` Bjorn Helgaas
  2014-05-30  2:42     ` Yijing Wang
  0 siblings, 1 reply; 7+ messages in thread
From: Bjorn Helgaas @ 2014-05-30  2:07 UTC (permalink / raw)
  To: Yijing Wang; +Cc: linux-pci, Yinghai Lu

On Thu, May 29, 2014 at 03:01:04PM +0800, Yijing Wang wrote:
> Kernel will WARN_ON(retval < 0) if device_attach() fail with
> error in pci_bus_add_device(). currently, all the kernel code
> to check pci_bus_add_device() return value only for printing
> warning message, no other actions. So we can remove the
> unnecessary checking codes.

If we remove all the checks of the return value, why wouldn't we convert it
to a void function?  If we keep the return value, it seems like we're
saying "this function could fail someday," but we removing all the code
that would actually *check* for that failure.

If you convert it to void, please just squash them all into a single patch.

> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> ---
>  drivers/pci/bus.c   |    6 +-----
>  drivers/pci/iov.c   |    2 +-
>  include/linux/pci.h |    2 +-
>  3 files changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
> index ba2bf55..f0efbee 100644
> --- a/drivers/pci/bus.c
> +++ b/drivers/pci/bus.c
> @@ -266,16 +266,12 @@ void pci_bus_add_devices(const struct pci_bus *bus)
>  {
>  	struct pci_dev *dev;
>  	struct pci_bus *child;
> -	int retval;
>  
>  	list_for_each_entry(dev, &bus->devices, bus_list) {
>  		/* Skip already-added devices */
>  		if (dev->is_added)
>  			continue;
> -		retval = pci_bus_add_device(dev);
> -		if (retval)
> -			dev_err(&dev->dev, "Error adding device (%d)\n",
> -				retval);
> +		pci_bus_add_device(dev);
>  	}
>  
>  	list_for_each_entry(dev, &bus->devices, bus_list) {
> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> index de7a747..cb6f247 100644
> --- a/drivers/pci/iov.c
> +++ b/drivers/pci/iov.c
> @@ -106,7 +106,7 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
>  	pci_device_add(virtfn, virtfn->bus);
>  	mutex_unlock(&iov->dev->sriov->lock);
>  
> -	rc = pci_bus_add_device(virtfn);
> +	pci_bus_add_device(virtfn);
>  	sprintf(buf, "virtfn%u", id);
>  	rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf);
>  	if (rc)
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 65f22e8..3c4c0cf 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -781,7 +781,7 @@ int pci_scan_slot(struct pci_bus *bus, int devfn);
>  struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn);
>  void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);
>  unsigned int pci_scan_child_bus(struct pci_bus *bus);
> -int __must_check pci_bus_add_device(struct pci_dev *dev);
> +int pci_bus_add_device(struct pci_dev *dev);
>  void pci_read_bridge_bases(struct pci_bus *child);
>  struct resource *pci_find_parent_resource(const struct pci_dev *dev,
>  					  struct resource *res);
> -- 
> 1.7.1
> 
> 

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

* Re: [PATCH 1/3] PCI: remove the unnecssary checking for pci_bus_add_device
  2014-05-30  2:07   ` Bjorn Helgaas
@ 2014-05-30  2:42     ` Yijing Wang
  0 siblings, 0 replies; 7+ messages in thread
From: Yijing Wang @ 2014-05-30  2:42 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, Yinghai Lu

On 2014/5/30 10:07, Bjorn Helgaas wrote:
> On Thu, May 29, 2014 at 03:01:04PM +0800, Yijing Wang wrote:
>> Kernel will WARN_ON(retval < 0) if device_attach() fail with
>> error in pci_bus_add_device(). currently, all the kernel code
>> to check pci_bus_add_device() return value only for printing
>> warning message, no other actions. So we can remove the
>> unnecessary checking codes.
> 
> If we remove all the checks of the return value, why wouldn't we convert it
> to a void function?  If we keep the return value, it seems like we're
> saying "this function could fail someday," but we removing all the code
> that would actually *check* for that failure.
> 
> If you convert it to void, please just squash them all into a single patch.

Hi Bjorn,
   I didn't convert it to void because the device_attach() has a __must_check prefix
which need a retval to avoid compiler warning. But as you mentioned, maybe this will
make people confuse. I will rework it and squash them into a single one.

Thanks!
Yijing.

> 
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> ---
>>  drivers/pci/bus.c   |    6 +-----
>>  drivers/pci/iov.c   |    2 +-
>>  include/linux/pci.h |    2 +-
>>  3 files changed, 3 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
>> index ba2bf55..f0efbee 100644
>> --- a/drivers/pci/bus.c
>> +++ b/drivers/pci/bus.c
>> @@ -266,16 +266,12 @@ void pci_bus_add_devices(const struct pci_bus *bus)
>>  {
>>  	struct pci_dev *dev;
>>  	struct pci_bus *child;
>> -	int retval;
>>  
>>  	list_for_each_entry(dev, &bus->devices, bus_list) {
>>  		/* Skip already-added devices */
>>  		if (dev->is_added)
>>  			continue;
>> -		retval = pci_bus_add_device(dev);
>> -		if (retval)
>> -			dev_err(&dev->dev, "Error adding device (%d)\n",
>> -				retval);
>> +		pci_bus_add_device(dev);
>>  	}
>>  
>>  	list_for_each_entry(dev, &bus->devices, bus_list) {
>> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
>> index de7a747..cb6f247 100644
>> --- a/drivers/pci/iov.c
>> +++ b/drivers/pci/iov.c
>> @@ -106,7 +106,7 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
>>  	pci_device_add(virtfn, virtfn->bus);
>>  	mutex_unlock(&iov->dev->sriov->lock);
>>  
>> -	rc = pci_bus_add_device(virtfn);
>> +	pci_bus_add_device(virtfn);
>>  	sprintf(buf, "virtfn%u", id);
>>  	rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf);
>>  	if (rc)
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 65f22e8..3c4c0cf 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -781,7 +781,7 @@ int pci_scan_slot(struct pci_bus *bus, int devfn);
>>  struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn);
>>  void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);
>>  unsigned int pci_scan_child_bus(struct pci_bus *bus);
>> -int __must_check pci_bus_add_device(struct pci_dev *dev);
>> +int pci_bus_add_device(struct pci_dev *dev);
>>  void pci_read_bridge_bases(struct pci_bus *child);
>>  struct resource *pci_find_parent_resource(const struct pci_dev *dev,
>>  					  struct resource *res);
>> -- 
>> 1.7.1
>>
>>
> 
> 


-- 
Thanks!
Yijing


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

end of thread, other threads:[~2014-05-30  2:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-29  7:01 [PATCH 0/3] cleanup unnecessary checking for pci_bus_add_device() Yijing Wang
2014-05-29  7:01 ` [PATCH 1/3] PCI: remove the unnecssary checking for pci_bus_add_device Yijing Wang
2014-05-30  2:07   ` Bjorn Helgaas
2014-05-30  2:42     ` Yijing Wang
2014-05-29  7:01 ` [PATCH 2/3] platform/x86: remove the unnecessary " Yijing Wang
2014-05-29  7:01 ` [PATCH 3/3] edac: " Yijing Wang
2014-05-29 22:13   ` Yinghai Lu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.