Linux-ide Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] drivers/ide: convert to list_for_each_entry_safe()
@ 2020-02-14  9:16 qiwuchen55
  2020-04-03  1:07 ` David Miller
  2020-04-05 17:29 ` Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: qiwuchen55 @ 2020-02-14  9:16 UTC (permalink / raw)
  To: davem; +Cc: linux-ide, chenqiwu

From: chenqiwu <chenqiwu@xiaomi.com>

Use list_for_each_entry_safe() instead of list_for_each_safe()
to simplify the code.

Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
---
 drivers/ide/ide-scan-pci.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/ide/ide-scan-pci.c b/drivers/ide/ide-scan-pci.c
index acf8748..383f0d8 100644
--- a/drivers/ide/ide-scan-pci.c
+++ b/drivers/ide/ide-scan-pci.c
@@ -89,8 +89,7 @@ static int __init ide_scan_pcidev(struct pci_dev *dev)
 static int __init ide_scan_pcibus(void)
 {
 	struct pci_dev *dev = NULL;
-	struct pci_driver *d;
-	struct list_head *l, *n;
+	struct pci_driver *d, *tmp;
 
 	pre_init = 0;
 	for_each_pci_dev(dev)
@@ -101,9 +100,8 @@ static int __init ide_scan_pcibus(void)
 	 *	are post init.
 	 */
 
-	list_for_each_safe(l, n, &ide_pci_drivers) {
-		list_del(l);
-		d = list_entry(l, struct pci_driver, node);
+	list_for_each_entry_safe(d, tmp, &ide_pci_drivers, node) {
+		list_del(d->node);
 		if (__pci_register_driver(d, d->driver.owner,
 					  d->driver.mod_name))
 			printk(KERN_ERR "%s: failed to register %s driver\n",
-- 
1.9.1


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

* Re: [PATCH] drivers/ide: convert to list_for_each_entry_safe()
  2020-02-14  9:16 [PATCH] drivers/ide: convert to list_for_each_entry_safe() qiwuchen55
@ 2020-04-03  1:07 ` David Miller
  2020-04-05 17:29 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-04-03  1:07 UTC (permalink / raw)
  To: qiwuchen55; +Cc: linux-ide, chenqiwu

From: qiwuchen55@gmail.com
Date: Fri, 14 Feb 2020 17:16:25 +0800

> From: chenqiwu <chenqiwu@xiaomi.com>
> 
> Use list_for_each_entry_safe() instead of list_for_each_safe()
> to simplify the code.
> 
> Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>

Applied, thank you.

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

* Re: [PATCH] drivers/ide: convert to list_for_each_entry_safe()
  2020-02-14  9:16 [PATCH] drivers/ide: convert to list_for_each_entry_safe() qiwuchen55
  2020-04-03  1:07 ` David Miller
@ 2020-04-05 17:29 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2020-04-05 17:29 UTC (permalink / raw)
  To: qiwuchen55; +Cc: davem, linux-ide, chenqiwu

On Fri, Feb 14, 2020 at 05:16:25PM +0800, qiwuchen55@gmail.com wrote:
> From: chenqiwu <chenqiwu@xiaomi.com>
> 
> Use list_for_each_entry_safe() instead of list_for_each_safe()
> to simplify the code.
> 
> Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
> ---
>  drivers/ide/ide-scan-pci.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/ide/ide-scan-pci.c b/drivers/ide/ide-scan-pci.c
> index acf8748..383f0d8 100644
> --- a/drivers/ide/ide-scan-pci.c
> +++ b/drivers/ide/ide-scan-pci.c
> @@ -89,8 +89,7 @@ static int __init ide_scan_pcidev(struct pci_dev *dev)
>  static int __init ide_scan_pcibus(void)
>  {
>  	struct pci_dev *dev = NULL;
> -	struct pci_driver *d;
> -	struct list_head *l, *n;
> +	struct pci_driver *d, *tmp;
>  
>  	pre_init = 0;
>  	for_each_pci_dev(dev)
> @@ -101,9 +100,8 @@ static int __init ide_scan_pcibus(void)
>  	 *	are post init.
>  	 */
>  
> -	list_for_each_safe(l, n, &ide_pci_drivers) {
> -		list_del(l);
> -		d = list_entry(l, struct pci_driver, node);
> +	list_for_each_entry_safe(d, tmp, &ide_pci_drivers, node) {
> +		list_del(d->node);

Just in case this wasn't reported yet.

drivers/ide/ide-scan-pci.c: In function 'ide_scan_pcibus':
drivers/ide/ide-scan-pci.c:104:13: error: incompatible type for argument 1 of 'list_del'
  104 |   list_del(d->node);
      |            ~^~~~~~
      |             |
      |             struct list_head
In file included from include/linux/module.h:12,
                 from drivers/ide/ide-scan-pci.c:12:
include/linux/list.h:144:47: note: expected 'struct list_head *' but argument is of type 'struct list_head'
  144 | static inline void list_del(struct list_head *entry)

Guenter

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14  9:16 [PATCH] drivers/ide: convert to list_for_each_entry_safe() qiwuchen55
2020-04-03  1:07 ` David Miller
2020-04-05 17:29 ` Guenter Roeck

Linux-ide Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-ide/0 linux-ide/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-ide linux-ide/ https://lore.kernel.org/linux-ide \
		linux-ide@vger.kernel.org
	public-inbox-index linux-ide

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-ide


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git