linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/3] wireless/libertas: don't cast a pointer to pointer of list_head
@ 2007-12-06  9:57 Li Zefan
  2007-12-06 10:49 ` Holger Schurig
  0 siblings, 1 reply; 2+ messages in thread
From: Li Zefan @ 2007-12-06  9:57 UTC (permalink / raw)
  To: davem; +Cc: LKML, Andrew Morton, linux-wireless, hs4233


Don't cast struct foo * to struct list_head *, it's safe only when
the list member is the first member of struct foo.

Also don't cast struct list_head * to struct foo *.


BTW: I'm not so sure where this patch should go to.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>

---
 drivers/net/wireless/libertas/cmd.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index be5cfd8..0fce9bb 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -946,11 +946,10 @@ void libertas_queue_cmd(wlan_adapter * adapter, struct cmd_ctrl_node *cmdnode, u
 	spin_lock_irqsave(&adapter->driver_lock, flags);
 
 	if (addtail) {
-		list_add_tail((struct list_head *)cmdnode,
-			      &adapter->cmdpendingq);
+		list_add_tail(&cmdnode->list, &adapter->cmdpendingq);
 		adapter->nr_cmd_pending++;
 	} else
-		list_add((struct list_head *)cmdnode, &adapter->cmdpendingq);
+		list_add(&cmdnode->list, &adapter->cmdpendingq);
 
 	spin_unlock_irqrestore(&adapter->driver_lock, flags);
 
@@ -1068,7 +1067,7 @@ void __libertas_cleanup_and_insert_cmd(wlan_private * priv, struct cmd_ctrl_node
 		return;
 
 	cleanup_cmdnode(ptempcmd);
-	list_add_tail((struct list_head *)ptempcmd, &adapter->cmdfreeq);
+	list_add_tail(&ptempcmd->list, &adapter->cmdfreeq);
 }
 
 static void libertas_cleanup_and_insert_cmd(wlan_private * priv, struct cmd_ctrl_node *ptempcmd)
@@ -1558,8 +1557,9 @@ struct cmd_ctrl_node *libertas_get_free_cmd_ctrl_node(wlan_private * priv)
 	spin_lock_irqsave(&adapter->driver_lock, flags);
 
 	if (!list_empty(&adapter->cmdfreeq)) {
-		tempnode = (struct cmd_ctrl_node *)adapter->cmdfreeq.next;
-		list_del((struct list_head *)tempnode);
+		tempnode = list_first_entry(&adapter->cmdfreeq,
+					    struct cmd_ctrl_node, list);
+		list_del(&tempnode->list);
 	} else {
 		lbs_deb_host("GET_CMD_NODE: cmd_ctrl_node is not available\n");
 		tempnode = NULL;
@@ -1656,8 +1656,8 @@ int libertas_execute_next_command(wlan_private * priv)
 	}
 
 	if (!list_empty(&adapter->cmdpendingq)) {
-		cmdnode = (struct cmd_ctrl_node *)
-		    adapter->cmdpendingq.next;
+		cmdnode = list_first_entry(&adapter->cmdpendingq,
+					   struct cmd_ctrl_node, list);
 	}
 
 	spin_unlock_irqrestore(&adapter->driver_lock, flags);
@@ -1721,7 +1721,7 @@ int libertas_execute_next_command(wlan_private * priv)
 				    cpu_to_le16(CMD_SUBCMD_EXIT_PS)) {
 					lbs_deb_host(
 					       "EXEC_NEXT_CMD: ignore ENTER_PS cmd\n");
-					list_del((struct list_head *)cmdnode);
+					list_del(&cmdnode->list);
 					libertas_cleanup_and_insert_cmd(priv, cmdnode);
 
 					ret = 0;
@@ -1732,7 +1732,7 @@ int libertas_execute_next_command(wlan_private * priv)
 				    (adapter->psstate == PS_STATE_PRE_SLEEP)) {
 					lbs_deb_host(
 					       "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n");
-					list_del((struct list_head *)cmdnode);
+					list_del(&cmdnode->list);
 					libertas_cleanup_and_insert_cmd(priv, cmdnode);
 					adapter->needtowakeup = 1;
 
@@ -1744,7 +1744,7 @@ int libertas_execute_next_command(wlan_private * priv)
 				       "EXEC_NEXT_CMD: sending EXIT_PS\n");
 			}
 		}
-		list_del((struct list_head *)cmdnode);
+		list_del(&cmdnode->list);
 		lbs_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n",
 			    le16_to_cpu(cmdptr->command));
 		DownloadcommandToStation(priv, cmdnode);
-- 
1.5.3.rc7


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

* Re: [PATCH 3/3] wireless/libertas: don't cast a pointer to pointer of list_head
  2007-12-06  9:57 [PATCH 3/3] wireless/libertas: don't cast a pointer to pointer of list_head Li Zefan
@ 2007-12-06 10:49 ` Holger Schurig
  0 siblings, 0 replies; 2+ messages in thread
From: Holger Schurig @ 2007-12-06 10:49 UTC (permalink / raw)
  To: linux-wireless; +Cc: Li Zefan, davem, LKML, Andrew Morton

> BTW: I'm not so sure where this patch should go to.

To <linux-wireless@vger.kernel.org>, as Dan Williams (libertas 
maintainer) monitors this list.

The wireless development tree is wireless-2.6, branch everything. 
You patch doesn't apply to this tree currently, but it's easy to 
fix. I'll bring it in shape, and resubmit.




As a side note: if you want to make comments, put them below --- 
under your Signed-off-by line. Your "BTW"-Line would have ended 
up in the output of "git log".



libertas: fixes blah mumpf worps

This fixes the worps feature.

Signed-of-by: Donald Duck <dduck@entenhausen.de>

---
Here you can put any comments about your patch that should not 
end up in the history of git that you can see with "git log".

[patch comes here]

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

end of thread, other threads:[~2007-12-06 10:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-06  9:57 [PATCH 3/3] wireless/libertas: don't cast a pointer to pointer of list_head Li Zefan
2007-12-06 10:49 ` Holger Schurig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).