diff mbox

[5/6] PCI/AER: introduce pci_bus_ops_free to free pci_bus_ops

Message ID 1348022442-7816-6-git-send-email-wangyijing@huawei.com
State Changes Requested
Headers show

Commit Message

Yijing Wang Sept. 19, 2012, 2:40 a.m. UTC
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/pci/pcie/aer/aer_inject.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

Comments

Huang, Ying Sept. 19, 2012, 6:03 a.m. UTC | #1
On Wed, 2012-09-19 at 10:40 +0800, Yijing Wang wrote:
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> ---
>  drivers/pci/pcie/aer/aer_inject.c |   14 +++++++++++---
>  1 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/pcie/aer/aer_inject.c b/drivers/pci/pcie/aer/aer_inject.c
> index 0a12ac7..79b611d 100644
> --- a/drivers/pci/pcie/aer/aer_inject.c
> +++ b/drivers/pci/pcie/aer/aer_inject.c
> @@ -162,6 +162,16 @@ static struct pci_bus_ops *pci_bus_ops_pop(void)
>  	return bus_ops;
>  }
>  
> +static void pci_bus_ops_free(void)
> +{
> +	struct pci_bus_ops *bus_ops, *tmp_ops;
> +
> +	list_for_each_entry_safe(bus_ops, tmp_ops, &pci_bus_ops_list, list) {
> +		list_del(&bus_ops->list);
> +		kfree(bus_ops);
> +	}
> +}

IMHO, this can be inlined into aer_inject_exit

>  static struct pci_bus_ops *pci_bus_ops_get(struct pci_bus_ops *from)
>  {
>  	struct pci_bus_ops *bus_ops = NULL;
> @@ -641,9 +651,7 @@ static void __exit aer_inject_exit(void)
>  	 * module exit
>  	 */
>  	clean_untracked_pci_ops_aer();
> -
> -	while ((bus_ops = pci_bus_ops_pop()))

You can remove pci_bus_ops_pop now.

Best Regards,
Huang Ying

> -		kfree(bus_ops);
> +	pci_bus_ops_free();
>  
>  	spin_lock_irqsave(&inject_lock, flags);
>  	list_for_each_entry_safe(err, err_next, &einjected, list) {


--
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
Yijing Wang Sept. 19, 2012, 6:11 a.m. UTC | #2
On 2012/9/19 14:03, Huang Ying wrote:
> On Wed, 2012-09-19 at 10:40 +0800, Yijing Wang wrote:
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> ---
>>  drivers/pci/pcie/aer/aer_inject.c |   14 +++++++++++---
>>  1 files changed, 11 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/pci/pcie/aer/aer_inject.c b/drivers/pci/pcie/aer/aer_inject.c
>> index 0a12ac7..79b611d 100644
>> --- a/drivers/pci/pcie/aer/aer_inject.c
>> +++ b/drivers/pci/pcie/aer/aer_inject.c
>> @@ -162,6 +162,16 @@ static struct pci_bus_ops *pci_bus_ops_pop(void)
>>  	return bus_ops;
>>  }
>>  
>> +static void pci_bus_ops_free(void)
>> +{
>> +	struct pci_bus_ops *bus_ops, *tmp_ops;
>> +
>> +	list_for_each_entry_safe(bus_ops, tmp_ops, &pci_bus_ops_list, list) {
>> +		list_del(&bus_ops->list);
>> +		kfree(bus_ops);
>> +	}
>> +}
> 
> IMHO, this can be inlined into aer_inject_exit
> 
>>  static struct pci_bus_ops *pci_bus_ops_get(struct pci_bus_ops *from)
>>  {
>>  	struct pci_bus_ops *bus_ops = NULL;
>> @@ -641,9 +651,7 @@ static void __exit aer_inject_exit(void)
>>  	 * module exit
>>  	 */
>>  	clean_untracked_pci_ops_aer();
>> -
>> -	while ((bus_ops = pci_bus_ops_pop()))
> 
> You can remove pci_bus_ops_pop now.
> 

OK, I will move pci_bus_ops_free inlined into aer_inject_exit and remove pci_bus_ops_pop in this patch.

> Best Regards,
> Huang Ying
> 
>> -		kfree(bus_ops);
>> +	pci_bus_ops_free();
>>  
>>  	spin_lock_irqsave(&inject_lock, flags);
>>  	list_for_each_entry_safe(err, err_next, &einjected, list) {
> 
> 
> 
> .
>
Chen Gong Sept. 19, 2012, 7:11 a.m. UTC | #3
On Wed, Sep 19, 2012 at 10:40:41AM +0800, Yijing Wang wrote:
> Date: Wed, 19 Sep 2012 10:40:41 +0800
> From: Yijing Wang <wangyijing@huawei.com>
> To: Bjorn Helgaas <bhelgaas@google.com>, Huang Ying <ying.huang@intel.com>,
>  Chen Gong <gong.chen@linux.intel.com>
> CC: jiang.liu@huawei.com, Hanjun Guo <guohanjun@huawei.com>,
>  linux-pci@vger.kernel.org, Yijing Wang <wangyijing@huawei.com>
> Subject: [PATCH 5/6] PCI/AER: introduce pci_bus_ops_free to free pci_bus_ops
> X-Mailer: git-send-email 1.7.11.msysgit.1
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>

Your patch hasn't description.
Yijing Wang Sept. 19, 2012, 7:29 a.m. UTC | #4
On 2012/9/19 15:11, Chen Gong wrote:
> On Wed, Sep 19, 2012 at 10:40:41AM +0800, Yijing Wang wrote:
>> Date: Wed, 19 Sep 2012 10:40:41 +0800
>> From: Yijing Wang <wangyijing@huawei.com>
>> To: Bjorn Helgaas <bhelgaas@google.com>, Huang Ying <ying.huang@intel.com>,
>>  Chen Gong <gong.chen@linux.intel.com>
>> CC: jiang.liu@huawei.com, Hanjun Guo <guohanjun@huawei.com>,
>>  linux-pci@vger.kernel.org, Yijing Wang <wangyijing@huawei.com>
>> Subject: [PATCH 5/6] PCI/AER: introduce pci_bus_ops_free to free pci_bus_ops
>> X-Mailer: git-send-email 1.7.11.msysgit.1
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> 
> Your patch hasn't description.
> 
I will add description later, Thanks!
diff mbox

Patch

diff --git a/drivers/pci/pcie/aer/aer_inject.c b/drivers/pci/pcie/aer/aer_inject.c
index 0a12ac7..79b611d 100644
--- a/drivers/pci/pcie/aer/aer_inject.c
+++ b/drivers/pci/pcie/aer/aer_inject.c
@@ -162,6 +162,16 @@  static struct pci_bus_ops *pci_bus_ops_pop(void)
 	return bus_ops;
 }
 
+static void pci_bus_ops_free(void)
+{
+	struct pci_bus_ops *bus_ops, *tmp_ops;
+
+	list_for_each_entry_safe(bus_ops, tmp_ops, &pci_bus_ops_list, list) {
+		list_del(&bus_ops->list);
+		kfree(bus_ops);
+	}
+}
+
 static struct pci_bus_ops *pci_bus_ops_get(struct pci_bus_ops *from)
 {
 	struct pci_bus_ops *bus_ops = NULL;
@@ -641,9 +651,7 @@  static void __exit aer_inject_exit(void)
 	 * module exit
 	 */
 	clean_untracked_pci_ops_aer();
-
-	while ((bus_ops = pci_bus_ops_pop()))
-		kfree(bus_ops);
+	pci_bus_ops_free();
 
 	spin_lock_irqsave(&inject_lock, flags);
 	list_for_each_entry_safe(err, err_next, &einjected, list) {