mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pci: remove redundant function calls in pci_reassigndev_resource_alignment()
@ 2012-12-28  7:31 Lin Feng
  2012-12-28  7:45 ` Yinghai Lu
  0 siblings, 1 reply; 4+ messages in thread
From: Lin Feng @ 2012-12-28  7:31 UTC (permalink / raw)
  To: bhelgaas, linux-pci; +Cc: linux-kernel, yinghai, tangchen, Lin Feng

pci_reassigndev_resource_alignment() potentially calls
pci_specified_resource_alignment() twice, which is redundant.

pci_is_reassigndev() is only called in pci_reassigndev_resource_alignment(),
and from sematic/functionality aspects pci_specified_resource_alignment() is
sufficient to substitute, so also make some cleanup.

Signed-off-by: Lin Feng <linfeng@cn.fujitsu.com>
Cc: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/pci.c |   16 ++--------------
 1 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 5cb5820..789f401 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3766,18 +3766,6 @@ resource_size_t pci_specified_resource_alignment(struct pci_dev *dev)
 	return align;
 }
 
-/**
- * pci_is_reassigndev - check if specified PCI is target device to reassign
- * @dev: the PCI device to check
- *
- * RETURNS: non-zero for PCI device is a target device to reassign,
- *          or zero is not.
- */
-int pci_is_reassigndev(struct pci_dev *dev)
-{
-	return (pci_specified_resource_alignment(dev) != 0);
-}
-
 /*
  * This function disables memory decoding and releases memory resources
  * of the device specified by kernel's boot parameter 'pci=resource_alignment='.
@@ -3792,7 +3780,8 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
 	resource_size_t align, size;
 	u16 command;
 
-	if (!pci_is_reassigndev(dev))
+	align = pci_specified_resource_alignment(dev);
+	if (!align)
 		return;
 
 	if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL &&
@@ -3808,7 +3797,6 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
 	command &= ~PCI_COMMAND_MEMORY;
 	pci_write_config_word(dev, PCI_COMMAND, command);
 
-	align = pci_specified_resource_alignment(dev);
 	for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) {
 		r = &dev->resource[i];
 		if (!(r->flags & IORESOURCE_MEM))
-- 
1.7.1


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

* Re: [PATCH] pci: remove redundant function calls in pci_reassigndev_resource_alignment()
  2012-12-28  7:31 [PATCH] pci: remove redundant function calls in pci_reassigndev_resource_alignment() Lin Feng
@ 2012-12-28  7:45 ` Yinghai Lu
  2012-12-28  8:55   ` Lin Feng
  0 siblings, 1 reply; 4+ messages in thread
From: Yinghai Lu @ 2012-12-28  7:45 UTC (permalink / raw)
  To: Lin Feng; +Cc: bhelgaas, linux-pci, linux-kernel, tangchen

On Thu, Dec 27, 2012 at 11:31 PM, Lin Feng <linfeng@cn.fujitsu.com> wrote:
> pci_reassigndev_resource_alignment() potentially calls
> pci_specified_resource_alignment() twice, which is redundant.
>
> pci_is_reassigndev() is only called in pci_reassigndev_resource_alignment(),
> and from sematic/functionality aspects pci_specified_resource_alignment() is
> sufficient to substitute, so also make some cleanup.
>
> Signed-off-by: Lin Feng <linfeng@cn.fujitsu.com>
> Cc: Yinghai Lu <yinghai@kernel.org>
> ---
>  drivers/pci/pci.c |   16 ++--------------
>  1 files changed, 2 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 5cb5820..789f401 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -3766,18 +3766,6 @@ resource_size_t pci_specified_resource_alignment(struct pci_dev *dev)
>         return align;
>  }
>
> -/**
> - * pci_is_reassigndev - check if specified PCI is target device to reassign
> - * @dev: the PCI device to check
> - *
> - * RETURNS: non-zero for PCI device is a target device to reassign,
> - *          or zero is not.
> - */
> -int pci_is_reassigndev(struct pci_dev *dev)
> -{
> -       return (pci_specified_resource_alignment(dev) != 0);
> -}
> -
>  /*
>   * This function disables memory decoding and releases memory resources
>   * of the device specified by kernel's boot parameter 'pci=resource_alignment='.
> @@ -3792,7 +3780,8 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
>         resource_size_t align, size;
>         u16 command;
>
> -       if (!pci_is_reassigndev(dev))
> +       align = pci_specified_resource_alignment(dev);
> +       if (!align)
>                 return;
>
>         if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL &&
> @@ -3808,7 +3797,6 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
>         command &= ~PCI_COMMAND_MEMORY;
>         pci_write_config_word(dev, PCI_COMMAND, command);
>
> -       align = pci_specified_resource_alignment(dev);
>         for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) {
>                 r = &dev->resource[i];
>                 if (!(r->flags & IORESOURCE_MEM))
> --
> 1.7.1
>

looks the same as the one that i posted 6 months ago.

http://copilotco.com/mail-archives/linux-kernel.2012/msg18498.html

Yinghai

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

* Re: [PATCH] pci: remove redundant function calls in pci_reassigndev_resource_alignment()
  2012-12-28  7:45 ` Yinghai Lu
@ 2012-12-28  8:55   ` Lin Feng
  2013-01-25  4:23     ` Bjorn Helgaas
  0 siblings, 1 reply; 4+ messages in thread
From: Lin Feng @ 2012-12-28  8:55 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: bhelgaas, linux-pci, linux-kernel, tangchen



On 12/28/2012 03:45 PM, Yinghai Lu wrote:
> On Thu, Dec 27, 2012 at 11:31 PM, Lin Feng <linfeng@cn.fujitsu.com> wrote:
>> pci_reassigndev_resource_alignment() potentially calls
>> pci_specified_resource_alignment() twice, which is redundant.
>>
>> pci_is_reassigndev() is only called in pci_reassigndev_resource_alignment(),
>> and from sematic/functionality aspects pci_specified_resource_alignment() is
>> sufficient to substitute, so also make some cleanup.
>>
>> Signed-off-by: Lin Feng <linfeng@cn.fujitsu.com>
>> Cc: Yinghai Lu <yinghai@kernel.org>
>> ---
>>  drivers/pci/pci.c |   16 ++--------------
>>  1 files changed, 2 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>> index 5cb5820..789f401 100644
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -3766,18 +3766,6 @@ resource_size_t pci_specified_resource_alignment(struct pci_dev *dev)
>>         return align;
>>  }
>>
>> -/**
>> - * pci_is_reassigndev - check if specified PCI is target device to reassign
>> - * @dev: the PCI device to check
>> - *
>> - * RETURNS: non-zero for PCI device is a target device to reassign,
>> - *          or zero is not.
>> - */
>> -int pci_is_reassigndev(struct pci_dev *dev)
>> -{
>> -       return (pci_specified_resource_alignment(dev) != 0);
>> -}
>> -
>>  /*
>>   * This function disables memory decoding and releases memory resources
>>   * of the device specified by kernel's boot parameter 'pci=resource_alignment='.
>> @@ -3792,7 +3780,8 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
>>         resource_size_t align, size;
>>         u16 command;
>>
>> -       if (!pci_is_reassigndev(dev))
>> +       align = pci_specified_resource_alignment(dev);
>> +       if (!align)
>>                 return;
>>
>>         if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL &&
>> @@ -3808,7 +3797,6 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
>>         command &= ~PCI_COMMAND_MEMORY;
>>         pci_write_config_word(dev, PCI_COMMAND, command);
>>
>> -       align = pci_specified_resource_alignment(dev);
>>         for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) {
>>                 r = &dev->resource[i];
>>                 if (!(r->flags & IORESOURCE_MEM))
>> --
>> 1.7.1
>>
> 
> looks the same as the one that i posted 6 months ago.
> 
> http://copilotco.com/mail-archives/linux-kernel.2012/msg18498.html
Sorry, I didn't notice your patchset before :)
Yes, they are the same. But why does nobody care this?
> 
> Yinghai
> 

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

* Re: [PATCH] pci: remove redundant function calls in pci_reassigndev_resource_alignment()
  2012-12-28  8:55   ` Lin Feng
@ 2013-01-25  4:23     ` Bjorn Helgaas
  0 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2013-01-25  4:23 UTC (permalink / raw)
  To: Lin Feng; +Cc: Yinghai Lu, linux-pci, linux-kernel, tangchen

On Fri, Dec 28, 2012 at 1:55 AM, Lin Feng <linfeng@cn.fujitsu.com> wrote:
>
>
> On 12/28/2012 03:45 PM, Yinghai Lu wrote:
>> On Thu, Dec 27, 2012 at 11:31 PM, Lin Feng <linfeng@cn.fujitsu.com> wrote:
>>> pci_reassigndev_resource_alignment() potentially calls
>>> pci_specified_resource_alignment() twice, which is redundant.
>>>
>>> pci_is_reassigndev() is only called in pci_reassigndev_resource_alignment(),
>>> and from sematic/functionality aspects pci_specified_resource_alignment() is
>>> sufficient to substitute, so also make some cleanup.
>>>
>>> Signed-off-by: Lin Feng <linfeng@cn.fujitsu.com>
>>> Cc: Yinghai Lu <yinghai@kernel.org>
>>> ---
>>>  drivers/pci/pci.c |   16 ++--------------
>>>  1 files changed, 2 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>>> index 5cb5820..789f401 100644
>>> --- a/drivers/pci/pci.c
>>> +++ b/drivers/pci/pci.c
>>> @@ -3766,18 +3766,6 @@ resource_size_t pci_specified_resource_alignment(struct pci_dev *dev)
>>>         return align;
>>>  }
>>>
>>> -/**
>>> - * pci_is_reassigndev - check if specified PCI is target device to reassign
>>> - * @dev: the PCI device to check
>>> - *
>>> - * RETURNS: non-zero for PCI device is a target device to reassign,
>>> - *          or zero is not.
>>> - */
>>> -int pci_is_reassigndev(struct pci_dev *dev)
>>> -{
>>> -       return (pci_specified_resource_alignment(dev) != 0);
>>> -}
>>> -
>>>  /*
>>>   * This function disables memory decoding and releases memory resources
>>>   * of the device specified by kernel's boot parameter 'pci=resource_alignment='.
>>> @@ -3792,7 +3780,8 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
>>>         resource_size_t align, size;
>>>         u16 command;
>>>
>>> -       if (!pci_is_reassigndev(dev))
>>> +       align = pci_specified_resource_alignment(dev);
>>> +       if (!align)
>>>                 return;
>>>
>>>         if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL &&
>>> @@ -3808,7 +3797,6 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
>>>         command &= ~PCI_COMMAND_MEMORY;
>>>         pci_write_config_word(dev, PCI_COMMAND, command);
>>>
>>> -       align = pci_specified_resource_alignment(dev);
>>>         for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) {
>>>                 r = &dev->resource[i];
>>>                 if (!(r->flags & IORESOURCE_MEM))
>>> --
>>> 1.7.1
>>>
>>
>> looks the same as the one that i posted 6 months ago.
>>
>> http://copilotco.com/mail-archives/linux-kernel.2012/msg18498.html
> Sorry, I didn't notice your patchset before :)
> Yes, they are the same. But why does nobody care this?

I applied Yinghai's patch to my pci/misc branch, headed for v3.9.

Bjorn

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

end of thread, other threads:[~2013-01-25  4:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-28  7:31 [PATCH] pci: remove redundant function calls in pci_reassigndev_resource_alignment() Lin Feng
2012-12-28  7:45 ` Yinghai Lu
2012-12-28  8:55   ` Lin Feng
2013-01-25  4:23     ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®