Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH] sky2: avoid using uninitialized variable
From: Stephen Hemminger @ 2011-06-14  4:02 UTC (permalink / raw)
  To: Greg Thelen; +Cc: Stephen Hemminger, netdev, linux-kernel@vger.kernel.org
In-Reply-To: <BANLkTi=jw5=9LcwxnXW6xNkF4RbFhHaB55Au=oDhn1yYWf53dA@mail.gmail.com>

On Mon, 13 Jun 2011 17:34:00 -0700
Greg Thelen <gthelen@google.com> wrote:

> On Mon, Jun 13, 2011 at 3:12 PM, Stephen Hemminger
> <shemminger@vyatta.com> wrote:
> > On Mon, 13 Jun 2011 14:21:59 -0700
> > Greg Thelen <gthelen@google.com> wrote:
> >
> >> I am not sure if 0 or ~0 would be a better choice in the gm_phy_read()
> >> error case.  I used 0.  A more complete solution might be to plumb up
> >> error handling to the callers of gm_phy_read().
> >>
> >> ==
> >> From 37486219a3d93881f3b2619a4b2bb21be62db7d4 Mon Sep 17 00:00:00 2001
> >> From: Greg Thelen <gthelen@google.com>
> >> Date: Mon, 13 Jun 2011 14:09:07 -0700
> >> Subject: [PATCH] sky2: avoid using uninitialized variable
> >>
> >> Prior to this change gm_phy_read() could return an uninitialized
> >> variable if __gm_phy_read() failed.
> >>
> >> This change returns zero in the failure case.
> >>
> >> Signed-off-by: Greg Thelen <gthelen@google.com>
> >
> > Shouldn't the callers be changed to check rather than just returning
> > 0 and masking the problem.
> 
> I agree that the right long term solution is to plumb the error
> handling up through the callers.  This would involve deleting the
> error-free gm_phy_read() routine and replacing all calls to it with
> calls to error-capable __gm_phy_read().  This would require converting
> several routines from returning void to returning int allowing errors
> to propagate upwards.  Notable affected routines include:
> sky2_phy_power_up(), sky2_wol_init(), sky2_phy_power_down(),
> sky2_hw_down(), sky2_mac_init(), sky2_hw_up(), sky2_phy_intr(),
> sky2_led().  sky2_restart() would likely have to re-queue the work
> item in the case of failure.  Presumably sky2_poll() would return 0 if
> error is seen.  On a related note, it also seems that gm_phy_write()
> callers should be checking its return value to also handle the same
> class of I/O errors.  Testing these changes would involve injecting
> error values or access to certain kinds of broken hardware.

In my experience if phy reads once successfully, it is going
to read every time. If there is a problem it only happens on
the first access (powered off, bad timing, etc).


 
> For the short term I figured that not consuming random data was a step
> in right direction.  But I understand if you prefer to hold out for
> the complete solution.  Unfortunately, I do not currently have time to
> contribute to the complete solution.


^ permalink raw reply

* [PATCH net-next 0/2] drivers/net: Remove casts of void *
From: Joe Perches @ 2011-06-14  4:02 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel, linux-wireless, ath9k-devel

Joe Perches (2):
  wireless: Remove casts of void *
  drivers/net: Remove casts of void *

 drivers/net/a2065.c                            |    2 +-
 drivers/net/appletalk/ltpc.c                   |    8 ++--
 drivers/net/atl1e/atl1e_main.c                 |    5 +--
 drivers/net/atlx/atl2.c                        |    3 +-
 drivers/net/benet/be_cmds.c                    |    3 +-
 drivers/net/benet/be_ethtool.c                 |    4 +-
 drivers/net/bna/bfa_cee.c                      |    2 +-
 drivers/net/bna/cna.h                          |    2 +-
 drivers/net/caif/caif_shmcore.c                |    2 +-
 drivers/net/cnic.c                             |    4 +-
 drivers/net/cxgb3/cxgb3_offload.c              |    2 +-
 drivers/net/davinci_cpdma.c                    |    2 +-
 drivers/net/declance.c                         |   38 ++++++++++++---------
 drivers/net/depca.c                            |    4 +-
 drivers/net/dl2k.c                             |    4 +-
 drivers/net/ehea/ehea_qmr.c                    |    2 +-
 drivers/net/epic100.c                          |    4 +-
 drivers/net/fealnx.c                           |    4 +-
 drivers/net/gianfar.c                          |    4 +-
 drivers/net/hamachi.c                          |    4 +-
 drivers/net/macmace.c                          |    2 +-
 drivers/net/mlx4/en_rx.c                       |    2 +-
 drivers/net/mlx4/en_tx.c                       |    5 +--
 drivers/net/myri_sbus.c                        |    3 +-
 drivers/net/netxen/netxen_nic_ctx.c            |   16 ++++----
 drivers/net/pxa168_eth.c                       |    2 +-
 drivers/net/qla3xxx.c                          |    5 +--
 drivers/net/qlcnic/qlcnic_ctx.c                |   26 +++++++-------
 drivers/net/qlcnic/qlcnic_ethtool.c            |    2 +-
 drivers/net/qlcnic/qlcnic_hw.c                 |    3 +-
 drivers/net/qlcnic/qlcnic_main.c               |    2 +-
 drivers/net/qlge/qlge_main.c                   |    4 +-
 drivers/net/s2io.c                             |   18 ++++------
 drivers/net/sfc/siena.c                        |    2 +-
 drivers/net/sis900.c                           |    4 +-
 drivers/net/tokenring/madgemc.c                |    2 +-
 drivers/net/typhoon.c                          |    2 +-
 drivers/net/vxge/vxge-config.c                 |   44 ++++++++---------------
 drivers/net/vxge/vxge-traffic.c                |    6 ++--
 drivers/net/wan/pc300_tty.c                    |    2 +-
 drivers/net/wireless/ath/ath9k/ar9003_mac.c    |    2 +-
 drivers/net/wireless/ath/ath9k/htc_hst.c       |    6 +--
 drivers/net/wireless/ath/ath9k/init.c          |    2 +-
 drivers/net/wireless/ath/ath9k/wmi.c           |    2 +-
 drivers/net/wireless/ath/carl9170/usb.c        |    2 +-
 drivers/net/wireless/hostap/hostap_cs.c        |    4 +-
 drivers/net/wireless/hostap/hostap_pci.c       |    4 +-
 drivers/net/wireless/hostap/hostap_plx.c       |    4 +-
 drivers/net/wireless/ipw2x00/ipw2100.c         |    6 +--
 drivers/net/wireless/iwlegacy/iwl-4965-rs.c    |    2 +-
 drivers/net/wireless/iwlegacy/iwl-4965-ucode.c |    8 ++--
 drivers/net/wireless/iwlegacy/iwl3945-base.c   |    8 ++--
 drivers/net/wireless/iwlegacy/iwl4965-base.c   |    2 +-
 drivers/net/wireless/iwlwifi/iwl-agn-rs.c      |    2 +-
 drivers/net/wireless/mwifiex/11n.c             |    5 +--
 drivers/net/wireless/mwifiex/cmdevt.c          |    3 +-
 drivers/net/wireless/mwifiex/join.c            |    2 +-
 drivers/net/wireless/mwifiex/scan.c            |    2 +-
 drivers/net/wireless/mwifiex/sta_cmd.c         |    4 +-
 drivers/net/wireless/mwifiex/sta_cmdresp.c     |   12 +++---
 drivers/net/wireless/mwifiex/txrx.c            |    2 +-
 drivers/net/wireless/p54/eeprom.c              |    4 +-
 drivers/net/xilinx_emaclite.c                  |    4 +-
 drivers/net/yellowfin.c                        |    6 ++--
 64 files changed, 164 insertions(+), 189 deletions(-)

-- 
1.7.6.rc0

^ permalink raw reply

* [PATCH net-next 1/2] wireless: Remove casts of void *
From: Joe Perches @ 2011-06-14  4:02 UTC (permalink / raw)
  To: netdev
  Cc: Luis R. Rodriguez, Jouni Malinen, Vasanthakumar Thiagarajan,
	Senthil Balasubramanian, John W. Linville, Christian Lamparter,
	Stanislaw Gruszka, Wey-Yi Guy, Intel Linux Wireless,
	linux-wireless, ath9k-devel, linux-kernel
In-Reply-To: <cover.1308024069.git.joe@perches.com>

Unnecessary casts of void * clutter the code.

These are the remainder casts after several specific
patches to remove netdev_priv and dev_priv.

Done via coccinelle script:

$ cat cast_void_pointer.cocci
@@
type T;
T *pt;
void *pv;
@@

- pt = (T *)pv;
+ pt = pv;

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/wireless/ath/ath9k/ar9003_mac.c    |    2 +-
 drivers/net/wireless/ath/ath9k/htc_hst.c       |    6 ++----
 drivers/net/wireless/ath/ath9k/init.c          |    2 +-
 drivers/net/wireless/ath/ath9k/wmi.c           |    2 +-
 drivers/net/wireless/ath/carl9170/usb.c        |    2 +-
 drivers/net/wireless/hostap/hostap_cs.c        |    4 ++--
 drivers/net/wireless/hostap/hostap_pci.c       |    4 ++--
 drivers/net/wireless/hostap/hostap_plx.c       |    4 ++--
 drivers/net/wireless/ipw2x00/ipw2100.c         |    6 ++----
 drivers/net/wireless/iwlegacy/iwl-4965-rs.c    |    2 +-
 drivers/net/wireless/iwlegacy/iwl-4965-ucode.c |    8 ++++----
 drivers/net/wireless/iwlegacy/iwl3945-base.c   |    8 ++++----
 drivers/net/wireless/iwlegacy/iwl4965-base.c   |    2 +-
 drivers/net/wireless/iwlwifi/iwl-agn-rs.c      |    2 +-
 drivers/net/wireless/mwifiex/11n.c             |    5 ++---
 drivers/net/wireless/mwifiex/cmdevt.c          |    3 +--
 drivers/net/wireless/mwifiex/join.c            |    2 +-
 drivers/net/wireless/mwifiex/scan.c            |    2 +-
 drivers/net/wireless/mwifiex/sta_cmd.c         |    4 ++--
 drivers/net/wireless/mwifiex/sta_cmdresp.c     |   12 ++++++------
 drivers/net/wireless/mwifiex/txrx.c            |    2 +-
 drivers/net/wireless/p54/eeprom.c              |    4 ++--
 22 files changed, 41 insertions(+), 47 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
index 04e6be0..2321e5b 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
@@ -654,7 +654,7 @@ void ath9k_hw_setup_statusring(struct ath_hw *ah, void *ts_start,
 	ah->ts_paddr_start = ts_paddr_start;
 	ah->ts_paddr_end = ts_paddr_start + (size * sizeof(struct ar9003_txs));
 	ah->ts_size = size;
-	ah->ts_ring = (struct ar9003_txs *) ts_start;
+	ah->ts_ring = ts_start;
 
 	ath9k_hw_reset_txstatus_ring(ah);
 }
diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c
index 1b90ed8..34e42c8 100644
--- a/drivers/net/wireless/ath/ath9k/htc_hst.c
+++ b/drivers/net/wireless/ath/ath9k/htc_hst.c
@@ -107,8 +107,7 @@ static void htc_process_conn_rsp(struct htc_target *target,
 	u16 max_msglen;
 	enum htc_endpoint_id epid, tepid;
 
-	svc_rspmsg = (struct htc_conn_svc_rspmsg *)
-		((void *) htc_hdr + sizeof(struct htc_frame_hdr));
+	svc_rspmsg = (void *)htc_hdr + sizeof(struct htc_frame_hdr);
 
 	if (svc_rspmsg->status == HTC_SERVICE_SUCCESS) {
 		epid = svc_rspmsg->endpoint_id;
@@ -393,8 +392,7 @@ void ath9k_htc_rx_msg(struct htc_target *htc_handle,
 		}
 
 		/* Get the message ID */
-		msg_id = (__be16 *) ((void *) htc_hdr +
-				     sizeof(struct htc_frame_hdr));
+		msg_id = (void *)htc_hdr + sizeof(struct htc_frame_hdr);
 
 		/* Now process HTC messages */
 		switch (be16_to_cpu(*msg_id)) {
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index d4b166c..d4b44a8 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -352,7 +352,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
 		error = -ENOMEM;
 		goto fail;
 	}
-	ds = (u8 *) dd->dd_desc;
+	ds = dd->dd_desc;
 	ath_dbg(common, ATH_DBG_CONFIG, "%s DMA map: %p (%u) -> %llx (%u)\n",
 		name, ds, (u32) dd->dd_desc_len,
 		ito64(dd->dd_desc_paddr), /*XXX*/(u32) dd->dd_desc_len);
diff --git a/drivers/net/wireless/ath/ath9k/wmi.c b/drivers/net/wireless/ath/ath9k/wmi.c
index 35422fc..0934b38 100644
--- a/drivers/net/wireless/ath/ath9k/wmi.c
+++ b/drivers/net/wireless/ath/ath9k/wmi.c
@@ -156,7 +156,7 @@ void ath9k_wmi_event_tasklet(unsigned long data)
 
 		switch (cmd_id) {
 		case WMI_SWBA_EVENTID:
-			swba = (struct wmi_event_swba *) wmi_event;
+			swba = wmi_event;
 			ath9k_htc_swba(priv, swba);
 			break;
 		case WMI_FATAL_EVENTID:
diff --git a/drivers/net/wireless/ath/carl9170/usb.c b/drivers/net/wireless/ath/carl9170/usb.c
index 2fb53d0..7f1d13a 100644
--- a/drivers/net/wireless/ath/carl9170/usb.c
+++ b/drivers/net/wireless/ath/carl9170/usb.c
@@ -649,7 +649,7 @@ int carl9170_exec_cmd(struct ar9170 *ar, const enum carl9170_cmd_oids cmd,
 		memcpy(ar->cmd.data, payload, plen);
 
 	spin_lock_bh(&ar->cmd_lock);
-	ar->readbuf = (u8 *)out;
+	ar->readbuf = out;
 	ar->readlen = outlen;
 	spin_unlock_bh(&ar->cmd_lock);
 
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index c052a0d..4273b96 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -160,7 +160,7 @@ static int hfa384x_from_bap(struct net_device *dev, u16 bap, void *buf,
 	u16 *pos;
 
 	d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
-	pos = (u16 *) buf;
+	pos = buf;
 
 	if (len / 2)
 		HFA384X_INSW(d_off, buf, len / 2);
@@ -179,7 +179,7 @@ static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
 	u16 *pos;
 
 	d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
-	pos = (u16 *) buf;
+	pos = buf;
 
 	if (len / 2)
 		HFA384X_OUTSW(d_off, buf, len / 2);
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c
index 972a9c3..ec723e5 100644
--- a/drivers/net/wireless/hostap/hostap_pci.c
+++ b/drivers/net/wireless/hostap/hostap_pci.c
@@ -187,7 +187,7 @@ static int hfa384x_from_bap(struct net_device *dev, u16 bap, void *buf,
 	__le16 *pos;
 
 	d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
-	pos = (__le16 *) buf;
+	pos = buf;
 
 	for ( ; len > 1; len -= 2)
 		*pos++ = HFA384X_INW_DATA(d_off);
@@ -205,7 +205,7 @@ static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
 	__le16 *pos;
 
 	d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
-	pos = (__le16 *) buf;
+	pos = buf;
 
 	for ( ; len > 1; len -= 2)
 		HFA384X_OUTW_DATA(*pos++, d_off);
diff --git a/drivers/net/wireless/hostap/hostap_plx.c b/drivers/net/wireless/hostap/hostap_plx.c
index 33e7903..8f6bdd0 100644
--- a/drivers/net/wireless/hostap/hostap_plx.c
+++ b/drivers/net/wireless/hostap/hostap_plx.c
@@ -228,7 +228,7 @@ static int hfa384x_from_bap(struct net_device *dev, u16 bap, void *buf,
 	u16 *pos;
 
 	d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
-	pos = (u16 *) buf;
+	pos = buf;
 
 	if (len / 2)
 		HFA384X_INSW(d_off, buf, len / 2);
@@ -247,7 +247,7 @@ static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
 	u16 *pos;
 
 	d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
-	pos = (u16 *) buf;
+	pos = buf;
 
 	if (len / 2)
 		HFA384X_OUTSW(d_off, buf, len / 2);
diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c
index 4430775..4bb90d1 100644
--- a/drivers/net/wireless/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/ipw2x00/ipw2100.c
@@ -3482,8 +3482,7 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv)
 		memset(v, 0, sizeof(struct ipw2100_cmd_header));
 
 		priv->msg_buffers[i].type = COMMAND;
-		priv->msg_buffers[i].info.c_struct.cmd =
-		    (struct ipw2100_cmd_header *)v;
+		priv->msg_buffers[i].info.c_struct.cmd = v;
 		priv->msg_buffers[i].info.c_struct.cmd_phys = p;
 	}
 
@@ -4510,8 +4509,7 @@ static int ipw2100_tx_allocate(struct ipw2100_priv *priv)
 		}
 
 		priv->tx_buffers[i].type = DATA;
-		priv->tx_buffers[i].info.d_struct.data =
-		    (struct ipw2100_data_header *)v;
+		priv->tx_buffers[i].info.d_struct.data = v;
 		priv->tx_buffers[i].info.d_struct.data_phys = p;
 		priv->tx_buffers[i].info.d_struct.txb = NULL;
 	}
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c
index 9b65153..d850fdc 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c
@@ -2323,7 +2323,7 @@ static void *iwl4965_rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta,
 				(struct iwl_station_priv *) sta->drv_priv;
 	struct iwl_priv *priv;
 
-	priv = (struct iwl_priv *)priv_rate;
+	priv = priv_rate;
 	IWL_DEBUG_RATE(priv, "create station rate scale window\n");
 
 	lq_sta = &sta_priv->lq_sta;
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c
index 001d148..35b6ca2 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c
@@ -127,7 +127,7 @@ int iwl4965_verify_ucode(struct iwl_priv *priv)
 	int ret;
 
 	/* Try bootstrap */
-	image = (__le32 *)priv->ucode_boot.v_addr;
+	image = priv->ucode_boot.v_addr;
 	len = priv->ucode_boot.len;
 	ret = iwl4965_verify_inst_sparse(priv, image, len);
 	if (!ret) {
@@ -136,7 +136,7 @@ int iwl4965_verify_ucode(struct iwl_priv *priv)
 	}
 
 	/* Try initialize */
-	image = (__le32 *)priv->ucode_init.v_addr;
+	image = priv->ucode_init.v_addr;
 	len = priv->ucode_init.len;
 	ret = iwl4965_verify_inst_sparse(priv, image, len);
 	if (!ret) {
@@ -145,7 +145,7 @@ int iwl4965_verify_ucode(struct iwl_priv *priv)
 	}
 
 	/* Try runtime/protocol */
-	image = (__le32 *)priv->ucode_code.v_addr;
+	image = priv->ucode_code.v_addr;
 	len = priv->ucode_code.len;
 	ret = iwl4965_verify_inst_sparse(priv, image, len);
 	if (!ret) {
@@ -158,7 +158,7 @@ int iwl4965_verify_ucode(struct iwl_priv *priv)
 	/* Since nothing seems to match, show first several data entries in
 	 * instruction SRAM, so maybe visual inspection will give a clue.
 	 * Selection of bootstrap image (vs. other images) is arbitrary. */
-	image = (__le32 *)priv->ucode_boot.v_addr;
+	image = priv->ucode_boot.v_addr;
 	len = priv->ucode_boot.len;
 	ret = iwl4965_verify_inst_full(priv, image, len);
 
diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c
index 0ee6be6..13b41b2 100644
--- a/drivers/net/wireless/iwlegacy/iwl3945-base.c
+++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c
@@ -2029,7 +2029,7 @@ static int iwl3945_verify_ucode(struct iwl_priv *priv)
 	int rc = 0;
 
 	/* Try bootstrap */
-	image = (__le32 *)priv->ucode_boot.v_addr;
+	image = priv->ucode_boot.v_addr;
 	len = priv->ucode_boot.len;
 	rc = iwl3945_verify_inst_sparse(priv, image, len);
 	if (rc == 0) {
@@ -2038,7 +2038,7 @@ static int iwl3945_verify_ucode(struct iwl_priv *priv)
 	}
 
 	/* Try initialize */
-	image = (__le32 *)priv->ucode_init.v_addr;
+	image = priv->ucode_init.v_addr;
 	len = priv->ucode_init.len;
 	rc = iwl3945_verify_inst_sparse(priv, image, len);
 	if (rc == 0) {
@@ -2047,7 +2047,7 @@ static int iwl3945_verify_ucode(struct iwl_priv *priv)
 	}
 
 	/* Try runtime/protocol */
-	image = (__le32 *)priv->ucode_code.v_addr;
+	image = priv->ucode_code.v_addr;
 	len = priv->ucode_code.len;
 	rc = iwl3945_verify_inst_sparse(priv, image, len);
 	if (rc == 0) {
@@ -2060,7 +2060,7 @@ static int iwl3945_verify_ucode(struct iwl_priv *priv)
 	/* Since nothing seems to match, show first several data entries in
 	 * instruction SRAM, so maybe visual inspection will give a clue.
 	 * Selection of bootstrap image (vs. other images) is arbitrary. */
-	image = (__le32 *)priv->ucode_boot.v_addr;
+	image = priv->ucode_boot.v_addr;
 	len = priv->ucode_boot.len;
 	rc = iwl3945_verify_inst_full(priv, image, len);
 
diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c
index af2ae22..3a6d5df 100644
--- a/drivers/net/wireless/iwlegacy/iwl4965-base.c
+++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c
@@ -379,7 +379,7 @@ int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv,
 	u32 num_tbs;
 
 	q = &txq->q;
-	tfd_tmp = (struct iwl_tfd *)txq->tfds;
+	tfd_tmp = txq->tfds;
 	tfd = &tfd_tmp[q->write_ptr];
 
 	if (reset)
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 85e0828..f546045 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -2799,7 +2799,7 @@ static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta,
 	struct iwl_station_priv *sta_priv = (struct iwl_station_priv *) sta->drv_priv;
 	struct iwl_priv *priv;
 
-	priv = (struct iwl_priv *)priv_rate;
+	priv = priv_rate;
 	IWL_DEBUG_RATE(priv, "create station rate scale window\n");
 
 	return &sta_priv->lq_sta;
diff --git a/drivers/net/wireless/mwifiex/11n.c b/drivers/net/wireless/mwifiex/11n.c
index 916183d..6378c04 100644
--- a/drivers/net/wireless/mwifiex/11n.c
+++ b/drivers/net/wireless/mwifiex/11n.c
@@ -191,7 +191,7 @@ int mwifiex_ret_11n_cfg(struct host_cmd_ds_command *resp, void *data_buf)
 	struct host_cmd_ds_11n_cfg *htcfg = &resp->params.htcfg;
 
 	if (data_buf) {
-		tx_cfg = (struct mwifiex_ds_11n_tx_cfg *) data_buf;
+		tx_cfg = data_buf;
 		tx_cfg->tx_htcap = le16_to_cpu(htcfg->ht_tx_cap);
 		tx_cfg->tx_htinfo = le16_to_cpu(htcfg->ht_tx_info);
 	}
@@ -279,8 +279,7 @@ int mwifiex_ret_amsdu_aggr_ctrl(struct host_cmd_ds_command *resp,
 		&resp->params.amsdu_aggr_ctrl;
 
 	if (data_buf) {
-		amsdu_aggr_ctrl =
-			(struct mwifiex_ds_11n_amsdu_aggr_ctrl *) data_buf;
+		amsdu_aggr_ctrl = data_buf;
 		amsdu_aggr_ctrl->enable = le16_to_cpu(amsdu_ctrl->enable);
 		amsdu_aggr_ctrl->curr_buf_size =
 			le16_to_cpu(amsdu_ctrl->curr_buf_size);
diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c
index cd89fed..c5be38d 100644
--- a/drivers/net/wireless/mwifiex/cmdevt.c
+++ b/drivers/net/wireless/mwifiex/cmdevt.c
@@ -712,8 +712,7 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
 		dev_dbg(adapter->dev, "info: host cmd resp size = %d\n", size);
 		size = min_t(u16, size, MWIFIEX_SIZE_OF_CMD_BUFFER);
 		if (adapter->curr_cmd->data_buf) {
-			hostcmd = (struct mwifiex_ds_misc_cmd *)
-						adapter->curr_cmd->data_buf;
+			hostcmd = adapter->curr_cmd->data_buf;
 			hostcmd->len = size;
 			memcpy(hostcmd->cmd, (void *) resp, size);
 		}
diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c
index 5eab3dc..91c7eca 100644
--- a/drivers/net/wireless/mwifiex/join.c
+++ b/drivers/net/wireless/mwifiex/join.c
@@ -380,7 +380,7 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
 	u8 *pos;
 	int rsn_ie_len = 0;
 
-	bss_desc = (struct mwifiex_bssdescriptor *) data_buf;
+	bss_desc = data_buf;
 	pos = (u8 *) assoc;
 
 	mwifiex_cfg_tx_buf(priv, bss_desc);
diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c
index 5c22860..a20dcb8 100644
--- a/drivers/net/wireless/mwifiex/scan.c
+++ b/drivers/net/wireless/mwifiex/scan.c
@@ -2362,7 +2362,7 @@ int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd, void *data_buf)
 	struct host_cmd_ds_802_11_scan *scan_cmd = &cmd->params.scan;
 	struct mwifiex_scan_cmd_config *scan_cfg;
 
-	scan_cfg = (struct mwifiex_scan_cmd_config *) data_buf;
+	scan_cfg = data_buf;
 
 	/* Set fixed field variables in scan command */
 	scan_cmd->bss_mode = scan_cfg->bss_mode;
diff --git a/drivers/net/wireless/mwifiex/sta_cmd.c b/drivers/net/wireless/mwifiex/sta_cmd.c
index 8af3a78..5571a4d 100644
--- a/drivers/net/wireless/mwifiex/sta_cmd.c
+++ b/drivers/net/wireless/mwifiex/sta_cmd.c
@@ -283,7 +283,7 @@ static int mwifiex_cmd_tx_power_cfg(struct host_cmd_ds_command *cmd,
 		cpu_to_le16(S_DS_GEN + sizeof(struct host_cmd_ds_txpwr_cfg));
 	switch (cmd_action) {
 	case HostCmd_ACT_GEN_SET:
-		txp = (struct host_cmd_ds_txpwr_cfg *) data_buf;
+		txp = data_buf;
 		if (txp->mode) {
 			pg_tlv = (struct mwifiex_types_power_group
 				  *) ((unsigned long) data_buf +
@@ -824,7 +824,7 @@ static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd,
 {
 	struct mwifiex_ds_reg_rw *reg_rw;
 
-	reg_rw = (struct mwifiex_ds_reg_rw *) data_buf;
+	reg_rw = data_buf;
 	switch (le16_to_cpu(cmd->command)) {
 	case HostCmd_CMD_MAC_REG_ACCESS:
 	{
diff --git a/drivers/net/wireless/mwifiex/sta_cmdresp.c b/drivers/net/wireless/mwifiex/sta_cmdresp.c
index d08f764..f495627 100644
--- a/drivers/net/wireless/mwifiex/sta_cmdresp.c
+++ b/drivers/net/wireless/mwifiex/sta_cmdresp.c
@@ -140,7 +140,7 @@ static int mwifiex_ret_802_11_rssi_info(struct mwifiex_private *priv,
 
 	/* Need to indicate IOCTL complete */
 	if (data_buf) {
-		signal = (struct mwifiex_ds_get_signal *) data_buf;
+		signal = data_buf;
 		memset(signal, 0, sizeof(struct mwifiex_ds_get_signal));
 
 		signal->selector = ALL_RSSI_INFO_MASK;
@@ -235,7 +235,7 @@ static int mwifiex_ret_get_log(struct mwifiex_private *priv,
 	struct mwifiex_ds_get_stats *stats;
 
 	if (data_buf) {
-		stats = (struct mwifiex_ds_get_stats *) data_buf;
+		stats = data_buf;
 		stats->mcast_tx_frame = le32_to_cpu(get_log->mcast_tx_frame);
 		stats->failed = le32_to_cpu(get_log->failed);
 		stats->retry = le32_to_cpu(get_log->retry);
@@ -330,7 +330,7 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
 					  HostCmd_ACT_GEN_GET, 0, NULL);
 
 	if (data_buf) {
-		ds_rate = (struct mwifiex_rate_cfg *) data_buf;
+		ds_rate = data_buf;
 		if (le16_to_cpu(rate_cfg->action) == HostCmd_ACT_GEN_GET) {
 			if (priv->is_data_rate_auto) {
 				ds_rate->is_rate_auto = 1;
@@ -664,7 +664,7 @@ static int mwifiex_ret_ver_ext(struct mwifiex_private *priv,
 	struct host_cmd_ds_version_ext *version_ext;
 
 	if (data_buf) {
-		version_ext = (struct host_cmd_ds_version_ext *)data_buf;
+		version_ext = data_buf;
 		version_ext->version_str_sel = ver_ext->version_str_sel;
 		memcpy(version_ext->version_str, ver_ext->version_str,
 		       sizeof(char) * 128);
@@ -686,8 +686,8 @@ static int mwifiex_ret_reg_access(u16 type, struct host_cmd_ds_command *resp,
 	struct mwifiex_ds_read_eeprom *eeprom;
 
 	if (data_buf) {
-		reg_rw = (struct mwifiex_ds_reg_rw *) data_buf;
-		eeprom = (struct mwifiex_ds_read_eeprom *) data_buf;
+		reg_rw = data_buf;
+		eeprom = data_buf;
 		switch (type) {
 		case HostCmd_CMD_MAC_REG_ACCESS:
 			{
diff --git a/drivers/net/wireless/mwifiex/txrx.c b/drivers/net/wireless/mwifiex/txrx.c
index aaa50c0..6190b2f 100644
--- a/drivers/net/wireless/mwifiex/txrx.c
+++ b/drivers/net/wireless/mwifiex/txrx.c
@@ -71,7 +71,7 @@ int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb,
 	u8 *head_ptr;
 	struct txpd *local_tx_pd = NULL;
 
-	head_ptr = (u8 *) mwifiex_process_sta_txpd(priv, skb);
+	head_ptr = mwifiex_process_sta_txpd(priv, skb);
 	if (head_ptr) {
 		if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA)
 			local_tx_pd =
diff --git a/drivers/net/wireless/p54/eeprom.c b/drivers/net/wireless/p54/eeprom.c
index 54cc0bb..bdb571f 100644
--- a/drivers/net/wireless/p54/eeprom.c
+++ b/drivers/net/wireless/p54/eeprom.c
@@ -570,7 +570,7 @@ static void p54_parse_default_country(struct ieee80211_hw *dev,
 		return;
 	}
 
-	country = (struct pda_country *) data;
+	country = data;
 	if (country->flags == PDR_COUNTRY_CERT_CODE_PSEUDO)
 		regulatory_hint(dev->wiphy, country->alpha2);
 	else {
@@ -659,7 +659,7 @@ int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
 	u16 synth = 0;
 	u16 crc16 = ~0;
 
-	wrap = (struct eeprom_pda_wrap *) eeprom;
+	wrap = eeprom;
 	entry = (void *)wrap->data + le16_to_cpu(wrap->len);
 
 	/* verify that at least the entry length/code fits */
-- 
1.7.6.rc0

^ permalink raw reply related

* [PATCH net-next 2/2] drivers/net: Remove casts of void *
From: Joe Perches @ 2011-06-14  4:02 UTC (permalink / raw)
  To: netdev
  Cc: Arnaldo Carvalho de Melo, Jay Cliburn, Chris Snook, Jie Yang,
	Sathya Perla, Subbu Seetharaman, Ajit Khaparde, Rasesh Mody,
	Debashis Dutt, Sjur Braendeland, Divy Le Ray, Breno Leitao,
	Amit Kumar Salecha, Ron Mercer, linux-driver, Anirban Chakraborty,
	Jon Mason, Solarflare linux maintainers, Steve Hodgson,
	Ben Hutchings, Daniele Venzano, David Dillow <dav
In-Reply-To: <cover.1308024069.git.joe@perches.com>

Unnecessary casts of void * clutter the code.

These are the remainder casts after several specific
patches to remove netdev_priv and dev_priv.

Done via coccinelle script:

$ cat cast_void_pointer.cocci
@@
type T;
T *pt;
void *pv;
@@

- pt = (T *)pv;
+ pt = pv;

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/a2065.c                 |    2 +-
 drivers/net/appletalk/ltpc.c        |    8 +++---
 drivers/net/atl1e/atl1e_main.c      |    5 +--
 drivers/net/atlx/atl2.c             |    3 +-
 drivers/net/benet/be_cmds.c         |    3 +-
 drivers/net/benet/be_ethtool.c      |    4 +-
 drivers/net/bna/bfa_cee.c           |    2 +-
 drivers/net/bna/cna.h               |    2 +-
 drivers/net/caif/caif_shmcore.c     |    2 +-
 drivers/net/cnic.c                  |    4 +-
 drivers/net/cxgb3/cxgb3_offload.c   |    2 +-
 drivers/net/davinci_cpdma.c         |    2 +-
 drivers/net/declance.c              |   38 +++++++++++++++++------------
 drivers/net/depca.c                 |    4 +-
 drivers/net/dl2k.c                  |    4 +-
 drivers/net/ehea/ehea_qmr.c         |    2 +-
 drivers/net/epic100.c               |    4 +-
 drivers/net/fealnx.c                |    4 +-
 drivers/net/gianfar.c               |    4 +-
 drivers/net/hamachi.c               |    4 +-
 drivers/net/macmace.c               |    2 +-
 drivers/net/mlx4/en_rx.c            |    2 +-
 drivers/net/mlx4/en_tx.c            |    5 +--
 drivers/net/myri_sbus.c             |    3 +-
 drivers/net/netxen/netxen_nic_ctx.c |   16 ++++++------
 drivers/net/pxa168_eth.c            |    2 +-
 drivers/net/qla3xxx.c               |    5 +--
 drivers/net/qlcnic/qlcnic_ctx.c     |   26 ++++++++++----------
 drivers/net/qlcnic/qlcnic_ethtool.c |    2 +-
 drivers/net/qlcnic/qlcnic_hw.c      |    3 +-
 drivers/net/qlcnic/qlcnic_main.c    |    2 +-
 drivers/net/qlge/qlge_main.c        |    4 +-
 drivers/net/s2io.c                  |   18 +++++--------
 drivers/net/sfc/siena.c             |    2 +-
 drivers/net/sis900.c                |    4 +-
 drivers/net/tokenring/madgemc.c     |    2 +-
 drivers/net/typhoon.c               |    2 +-
 drivers/net/vxge/vxge-config.c      |   44 ++++++++++++-----------------------
 drivers/net/vxge/vxge-traffic.c     |    6 ++--
 drivers/net/wan/pc300_tty.c         |    2 +-
 drivers/net/xilinx_emaclite.c       |    4 +-
 drivers/net/yellowfin.c             |    6 ++--
 42 files changed, 123 insertions(+), 142 deletions(-)

diff --git a/drivers/net/a2065.c b/drivers/net/a2065.c
index deaa8bc..0230fc2 100644
--- a/drivers/net/a2065.c
+++ b/drivers/net/a2065.c
@@ -426,7 +426,7 @@ static irqreturn_t lance_interrupt (int irq, void *dev_id)
 	volatile struct lance_regs *ll;
 	int csr0;
 
-	dev = (struct net_device *) dev_id;
+	dev = dev_id;
 
 	lp = netdev_priv(dev);
 	ll = lp->ll;
diff --git a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c
index e69eead..34ffb54 100644
--- a/drivers/net/appletalk/ltpc.c
+++ b/drivers/net/appletalk/ltpc.c
@@ -652,9 +652,9 @@ static int do_write(struct net_device *dev, void *cbuf, int cbuflen,
 	int ret;
 
 	if(i) {
-		qels[i].cbuf = (unsigned char *) cbuf;
+		qels[i].cbuf = cbuf;
 		qels[i].cbuflen = cbuflen;
-		qels[i].dbuf = (unsigned char *) dbuf;
+		qels[i].dbuf = dbuf;
 		qels[i].dbuflen = dbuflen;
 		qels[i].QWrite = 1;
 		qels[i].mailbox = i;  /* this should be initted rather */
@@ -676,9 +676,9 @@ static int do_read(struct net_device *dev, void *cbuf, int cbuflen,
 	int ret;
 
 	if(i) {
-		qels[i].cbuf = (unsigned char *) cbuf;
+		qels[i].cbuf = cbuf;
 		qels[i].cbuflen = cbuflen;
-		qels[i].dbuf = (unsigned char *) dbuf;
+		qels[i].dbuf = dbuf;
 		qels[i].dbuflen = dbuflen;
 		qels[i].QWrite = 0;
 		qels[i].mailbox = i;  /* this should be initted rather */
diff --git a/drivers/net/atl1e/atl1e_main.c b/drivers/net/atl1e/atl1e_main.c
index 86a9122..c3c5db1 100644
--- a/drivers/net/atl1e/atl1e_main.c
+++ b/drivers/net/atl1e/atl1e_main.c
@@ -800,8 +800,7 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter)
 	/* Init TPD Ring */
 	tx_ring->dma = roundup(adapter->ring_dma, 8);
 	offset = tx_ring->dma - adapter->ring_dma;
-	tx_ring->desc = (struct atl1e_tpd_desc *)
-			(adapter->ring_vir_addr + offset);
+	tx_ring->desc = adapter->ring_vir_addr + offset;
 	size = sizeof(struct atl1e_tx_buffer) * (tx_ring->count);
 	tx_ring->tx_buffer = kzalloc(size, GFP_KERNEL);
 	if (tx_ring->tx_buffer == NULL) {
@@ -827,7 +826,7 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter)
 
 	/* Init CMB dma address */
 	tx_ring->cmb_dma = adapter->ring_dma + offset;
-	tx_ring->cmb     = (u32 *)(adapter->ring_vir_addr + offset);
+	tx_ring->cmb = adapter->ring_vir_addr + offset;
 	offset += sizeof(u32);
 
 	for (i = 0; i < adapter->num_rx_queues; i++) {
diff --git a/drivers/net/atlx/atl2.c b/drivers/net/atlx/atl2.c
index 16249e9..24e1592 100644
--- a/drivers/net/atlx/atl2.c
+++ b/drivers/net/atlx/atl2.c
@@ -311,8 +311,7 @@ static s32 atl2_setup_ring_resources(struct atl2_adapter *adapter)
 	adapter->txd_dma = adapter->ring_dma ;
 	offset = (adapter->txd_dma & 0x7) ? (8 - (adapter->txd_dma & 0x7)) : 0;
 	adapter->txd_dma += offset;
-	adapter->txd_ring = (struct tx_pkt_header *) (adapter->ring_vir_addr +
-		offset);
+	adapter->txd_ring = adapter->ring_vir_addr + offset;
 
 	/* Init TXS Ring */
 	adapter->txs_dma = adapter->txd_dma + adapter->txd_ring_size;
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c
index 0c12c2d..30719f5 100644
--- a/drivers/net/benet/be_cmds.c
+++ b/drivers/net/benet/be_cmds.c
@@ -2334,8 +2334,7 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
 
 	status = be_mbox_notify_wait(adapter);
 	if (!status) {
-		attribs = (struct mgmt_controller_attrib *)( attribs_cmd.va +
-					sizeof(struct be_cmd_resp_hdr));
+		attribs = attribs_cmd.va + sizeof(struct be_cmd_resp_hdr);
 		adapter->hba_port_num = attribs->hba_attribs.phy_port;
 	}
 
diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c
index facfe3c..5572c78 100644
--- a/drivers/net/benet/be_ethtool.c
+++ b/drivers/net/benet/be_ethtool.c
@@ -386,7 +386,7 @@ static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 		}
 		status = be_cmd_get_phy_info(adapter, &phy_cmd);
 		if (!status) {
-			resp = (struct be_cmd_resp_get_phy_info *) phy_cmd.va;
+			resp = phy_cmd.va;
 			intf_type = le16_to_cpu(resp->interface_type);
 
 			switch (intf_type) {
@@ -690,7 +690,7 @@ be_read_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom,
 	status = be_cmd_get_seeprom_data(adapter, &eeprom_cmd);
 
 	if (!status) {
-		resp = (struct be_cmd_resp_seeprom_read *) eeprom_cmd.va;
+		resp = eeprom_cmd.va;
 		memcpy(data, resp->seeprom_data + eeprom->offset, eeprom->len);
 	}
 	dma_free_coherent(&adapter->pdev->dev, eeprom_cmd.size, eeprom_cmd.va,
diff --git a/drivers/net/bna/bfa_cee.c b/drivers/net/bna/bfa_cee.c
index f7b789a..dcfbf08 100644
--- a/drivers/net/bna/bfa_cee.c
+++ b/drivers/net/bna/bfa_cee.c
@@ -236,7 +236,7 @@ static void
 bfa_cee_hbfail(void *arg)
 {
 	struct bfa_cee *cee;
-	cee = (struct bfa_cee *) arg;
+	cee = arg;
 
 	if (cee->get_attr_pending == true) {
 		cee->get_attr_status = BFA_STATUS_FAILED;
diff --git a/drivers/net/bna/cna.h b/drivers/net/bna/cna.h
index bbd39dc..3c47dc5 100644
--- a/drivers/net/bna/cna.h
+++ b/drivers/net/bna/cna.h
@@ -74,7 +74,7 @@ typedef struct mac { u8 mac[MAC_ADDRLEN]; } mac_t;
 		bfa_q_next(_q) = bfa_q_next(*((struct list_head **) _qe)); \
 		bfa_q_qe_init(*((struct list_head **) _qe));		\
 	} else {							\
-		*((struct list_head **) (_qe)) = (struct list_head *) NULL; \
+		*((struct list_head **)(_qe)) = NULL;			\
 	}								\
 }
 
diff --git a/drivers/net/caif/caif_shmcore.c b/drivers/net/caif/caif_shmcore.c
index 731aa11..d4b26fb 100644
--- a/drivers/net/caif/caif_shmcore.c
+++ b/drivers/net/caif/caif_shmcore.c
@@ -134,7 +134,7 @@ int caif_shmdrv_rx_cb(u32 mbx_msg, void *priv)
 	u32 avail_emptybuff = 0;
 	unsigned long flags = 0;
 
-	pshm_drv = (struct shmdrv_layer *)priv;
+	pshm_drv = priv;
 
 	/* Check for received buffers. */
 	if (mbx_msg & SHM_FULL_MASK) {
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 363c7f3..8548cbe 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -4290,7 +4290,7 @@ static void cnic_init_bnx2_tx_ring(struct cnic_dev *dev)
 	val = BNX2_L2CTX_CMD_TYPE_TYPE_L2 | (8 << 16);
 	cnic_ctx_wr(dev, cid_addr, offset1, val);
 
-	txbd = (struct tx_bd *) udev->l2_ring;
+	txbd = udev->l2_ring;
 
 	buf_map = udev->l2_buf_map;
 	for (i = 0; i < MAX_TX_DESC_CNT; i++, txbd++) {
@@ -4349,7 +4349,7 @@ static void cnic_init_bnx2_rx_ring(struct cnic_dev *dev)
 		val = BNX2_L2CTX_L2_STATUSB_NUM(sb_id);
 	cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_HOST_BDIDX, val);
 
-	rxbd = (struct rx_bd *) (udev->l2_ring + BCM_PAGE_SIZE);
+	rxbd = udev->l2_ring + BCM_PAGE_SIZE;
 	for (i = 0; i < MAX_RX_DESC_CNT; i++, rxbd++) {
 		dma_addr_t buf_map;
 		int n = (i % cp->l2_rx_ring_size) + 1;
diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
index 862804f..9db9068 100644
--- a/drivers/net/cxgb3/cxgb3_offload.c
+++ b/drivers/net/cxgb3/cxgb3_offload.c
@@ -567,7 +567,7 @@ static void t3_process_tid_release_list(struct work_struct *work)
 	while (td->tid_release_list) {
 		struct t3c_tid_entry *p = td->tid_release_list;
 
-		td->tid_release_list = (struct t3c_tid_entry *)p->ctx;
+		td->tid_release_list = p->ctx;
 		spin_unlock_bh(&td->tid_release_lock);
 
 		skb = alloc_skb(sizeof(struct cpl_tid_release),
diff --git a/drivers/net/davinci_cpdma.c b/drivers/net/davinci_cpdma.c
index ae47f23..dca9d33 100644
--- a/drivers/net/davinci_cpdma.c
+++ b/drivers/net/davinci_cpdma.c
@@ -167,7 +167,7 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr,
 	} else {
 		pool->cpumap = dma_alloc_coherent(dev, size, &pool->phys,
 						  GFP_KERNEL);
-		pool->iomap = (void __force __iomem *)pool->cpumap;
+		pool->iomap = pool->cpumap;
 		pool->hw_addr = pool->phys;
 	}
 
diff --git a/drivers/net/declance.c b/drivers/net/declance.c
index 219eb5a..cabd3a5 100644
--- a/drivers/net/declance.c
+++ b/drivers/net/declance.c
@@ -326,15 +326,18 @@ static void load_csrs(struct lance_private *lp)
  */
 static void cp_to_buf(const int type, void *to, const void *from, int len)
 {
-	unsigned short *tp, *fp, clen;
-	unsigned char *rtp, *rfp;
+	unsigned short *tp;
+	const unsigned short *fp;
+	unsigned short clen;
+	unsigned char *rtp;
+	const unsigned char *rfp;
 
 	if (type == PMAD_LANCE) {
 		memcpy(to, from, len);
 	} else if (type == PMAX_LANCE) {
 		clen = len >> 1;
-		tp = (unsigned short *) to;
-		fp = (unsigned short *) from;
+		tp = to;
+		fp = from;
 
 		while (clen--) {
 			*tp++ = *fp++;
@@ -342,8 +345,8 @@ static void cp_to_buf(const int type, void *to, const void *from, int len)
 		}
 
 		clen = len & 1;
-		rtp = (unsigned char *) tp;
-		rfp = (unsigned char *) fp;
+		rtp = tp;
+		rfp = fp;
 		while (clen--) {
 			*rtp++ = *rfp++;
 		}
@@ -352,8 +355,8 @@ static void cp_to_buf(const int type, void *to, const void *from, int len)
 		 * copy 16 Byte chunks
 		 */
 		clen = len >> 4;
-		tp = (unsigned short *) to;
-		fp = (unsigned short *) from;
+		tp = to;
+		fp = from;
 		while (clen--) {
 			*tp++ = *fp++;
 			*tp++ = *fp++;
@@ -382,15 +385,18 @@ static void cp_to_buf(const int type, void *to, const void *from, int len)
 
 static void cp_from_buf(const int type, void *to, const void *from, int len)
 {
-	unsigned short *tp, *fp, clen;
-	unsigned char *rtp, *rfp;
+	unsigned short *tp;
+	const unsigned short *fp;
+	unsigned short clen;
+	unsigned char *rtp;
+	const unsigned char *rfp;
 
 	if (type == PMAD_LANCE) {
 		memcpy(to, from, len);
 	} else if (type == PMAX_LANCE) {
 		clen = len >> 1;
-		tp = (unsigned short *) to;
-		fp = (unsigned short *) from;
+		tp = to;
+		fp = from;
 		while (clen--) {
 			*tp++ = *fp++;
 			fp++;
@@ -398,8 +404,8 @@ static void cp_from_buf(const int type, void *to, const void *from, int len)
 
 		clen = len & 1;
 
-		rtp = (unsigned char *) tp;
-		rfp = (unsigned char *) fp;
+		rtp = tp;
+		rfp = fp;
 
 		while (clen--) {
 			*rtp++ = *rfp++;
@@ -410,8 +416,8 @@ static void cp_from_buf(const int type, void *to, const void *from, int len)
 		 * copy 16 Byte chunks
 		 */
 		clen = len >> 4;
-		tp = (unsigned short *) to;
-		fp = (unsigned short *) from;
+		tp = to;
+		fp = from;
 		while (clen--) {
 			*tp++ = *fp++;
 			*tp++ = *fp++;
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index 8b0084d..d54a0e9 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -708,11 +708,11 @@ static int __init depca_hw_init (struct net_device *dev, struct device *device)
 
 	/* Tx & Rx descriptors (aligned to a quadword boundary) */
 	offset = (offset + DEPCA_ALIGN) & ~DEPCA_ALIGN;
-	lp->rx_ring = (struct depca_rx_desc __iomem *) (lp->sh_mem + offset);
+	lp->rx_ring = lp->sh_mem + offset;
 	lp->rx_ring_offset = offset;
 
 	offset += (sizeof(struct depca_rx_desc) * NUM_RX_DESC);
-	lp->tx_ring = (struct depca_tx_desc __iomem *) (lp->sh_mem + offset);
+	lp->tx_ring = lp->sh_mem + offset;
 	lp->tx_ring_offset = offset;
 
 	offset += (sizeof(struct depca_tx_desc) * NUM_TX_DESC);
diff --git a/drivers/net/dl2k.c b/drivers/net/dl2k.c
index c445457..05e64b2 100644
--- a/drivers/net/dl2k.c
+++ b/drivers/net/dl2k.c
@@ -221,13 +221,13 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
 	ring_space = pci_alloc_consistent (pdev, TX_TOTAL_SIZE, &ring_dma);
 	if (!ring_space)
 		goto err_out_iounmap;
-	np->tx_ring = (struct netdev_desc *) ring_space;
+	np->tx_ring = ring_space;
 	np->tx_ring_dma = ring_dma;
 
 	ring_space = pci_alloc_consistent (pdev, RX_TOTAL_SIZE, &ring_dma);
 	if (!ring_space)
 		goto err_out_unmap_tx;
-	np->rx_ring = (struct netdev_desc *) ring_space;
+	np->rx_ring = ring_space;
 	np->rx_ring_dma = ring_dma;
 
 	/* Parse eeprom data */
diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c
index cd44bb8..95b9f4f 100644
--- a/drivers/net/ehea/ehea_qmr.c
+++ b/drivers/net/ehea/ehea_qmr.c
@@ -331,7 +331,7 @@ struct ehea_eqe *ehea_poll_eq(struct ehea_eq *eq)
 	unsigned long flags;
 
 	spin_lock_irqsave(&eq->spinlock, flags);
-	eqe = (struct ehea_eqe *)hw_eqit_eq_get_inc_valid(&eq->hw_queue);
+	eqe = hw_eqit_eq_get_inc_valid(&eq->hw_queue);
 	spin_unlock_irqrestore(&eq->spinlock, flags);
 
 	return eqe;
diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c
index c353bf3..814c187 100644
--- a/drivers/net/epic100.c
+++ b/drivers/net/epic100.c
@@ -391,13 +391,13 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
 	ring_space = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
 	if (!ring_space)
 		goto err_out_iounmap;
-	ep->tx_ring = (struct epic_tx_desc *)ring_space;
+	ep->tx_ring = ring_space;
 	ep->tx_ring_dma = ring_dma;
 
 	ring_space = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma);
 	if (!ring_space)
 		goto err_out_unmap_tx;
-	ep->rx_ring = (struct epic_rx_desc *)ring_space;
+	ep->rx_ring = ring_space;
 	ep->rx_ring_dma = ring_dma;
 
 	if (dev->mem_start) {
diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c
index dd54abe..fa8677c 100644
--- a/drivers/net/fealnx.c
+++ b/drivers/net/fealnx.c
@@ -566,7 +566,7 @@ static int __devinit fealnx_init_one(struct pci_dev *pdev,
 		err = -ENOMEM;
 		goto err_out_free_dev;
 	}
-	np->rx_ring = (struct fealnx_desc *)ring_space;
+	np->rx_ring = ring_space;
 	np->rx_ring_dma = ring_dma;
 
 	ring_space = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
@@ -574,7 +574,7 @@ static int __devinit fealnx_init_one(struct pci_dev *pdev,
 		err = -ENOMEM;
 		goto err_out_free_rx;
 	}
-	np->tx_ring = (struct fealnx_desc *)ring_space;
+	np->tx_ring = ring_space;
 	np->tx_ring_dma = ring_dma;
 
 	/* find the connected MII xcvrs */
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index ff60b23..3564551 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -266,7 +266,7 @@ static int gfar_alloc_skb_resources(struct net_device *ndev)
 
 	for (i = 0; i < priv->num_tx_queues; i++) {
 		tx_queue = priv->tx_queue[i];
-		tx_queue->tx_bd_base = (struct txbd8 *) vaddr;
+		tx_queue->tx_bd_base = vaddr;
 		tx_queue->tx_bd_dma_base = addr;
 		tx_queue->dev = ndev;
 		/* enet DMA only understands physical addresses */
@@ -277,7 +277,7 @@ static int gfar_alloc_skb_resources(struct net_device *ndev)
 	/* Start the rx descriptor ring where the tx ring leaves off */
 	for (i = 0; i < priv->num_rx_queues; i++) {
 		rx_queue = priv->rx_queue[i];
-		rx_queue->rx_bd_base = (struct rxbd8 *) vaddr;
+		rx_queue->rx_bd_base = vaddr;
 		rx_queue->rx_bd_dma_base = addr;
 		rx_queue->dev = ndev;
 		addr    += sizeof (struct rxbd8) * rx_queue->rx_ring_size;
diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c
index a09041a..c274b3d 100644
--- a/drivers/net/hamachi.c
+++ b/drivers/net/hamachi.c
@@ -648,13 +648,13 @@ static int __devinit hamachi_init_one (struct pci_dev *pdev,
 	ring_space = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
 	if (!ring_space)
 		goto err_out_cleardev;
-	hmp->tx_ring = (struct hamachi_desc *)ring_space;
+	hmp->tx_ring = ring_space;
 	hmp->tx_ring_dma = ring_dma;
 
 	ring_space = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma);
 	if (!ring_space)
 		goto err_out_unmap_tx;
-	hmp->rx_ring = (struct hamachi_desc *)ring_space;
+	hmp->rx_ring = ring_space;
 	hmp->rx_ring_dma = ring_dma;
 
 	/* Check for options being passed in */
diff --git a/drivers/net/macmace.c b/drivers/net/macmace.c
index c685a46..4286e67 100644
--- a/drivers/net/macmace.c
+++ b/drivers/net/macmace.c
@@ -221,7 +221,7 @@ static int __devinit mace_probe(struct platform_device *pdev)
 	SET_NETDEV_DEV(dev, &pdev->dev);
 
 	dev->base_addr = (u32)MACE_BASE;
-	mp->mace = (volatile struct mace *) MACE_BASE;
+	mp->mace = MACE_BASE;
 
 	dev->irq = IRQ_MAC_MACE;
 	mp->dma_intr = IRQ_MAC_MACE_DMA;
diff --git a/drivers/net/mlx4/en_rx.c b/drivers/net/mlx4/en_rx.c
index 277215f..5197b50 100644
--- a/drivers/net/mlx4/en_rx.c
+++ b/drivers/net/mlx4/en_rx.c
@@ -859,7 +859,7 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
 				priv->rx_ring[0].cqn, &context);
 
 	ptr = ((void *) &context) + 0x3c;
-	rss_context = (struct mlx4_en_rss_context *) ptr;
+	rss_context = ptr;
 	rss_context->base_qpn = cpu_to_be32(ilog2(priv->rx_ring_num) << 24 |
 					    (rss_map->base_qpn));
 	rss_context->default_qpn = cpu_to_be32(rss_map->base_qpn);
diff --git a/drivers/net/mlx4/en_tx.c b/drivers/net/mlx4/en_tx.c
index b229acf..6e03de0 100644
--- a/drivers/net/mlx4/en_tx.c
+++ b/drivers/net/mlx4/en_tx.c
@@ -238,8 +238,7 @@ static u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv,
 	} else {
 		if (!tx_info->inl) {
 			if ((void *) data >= end) {
-				data = (struct mlx4_wqe_data_seg *)
-						(ring->buf + ((void *) data - end));
+				data = ring->buf + ((void *)data - end);
 			}
 
 			if (tx_info->linear) {
@@ -253,7 +252,7 @@ static u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv,
 			for (i = 0; i < frags; i++) {
 				/* Check for wraparound before unmapping */
 				if ((void *) data >= end)
-					data = (struct mlx4_wqe_data_seg *) ring->buf;
+					data = ring->buf;
 				frag = &skb_shinfo(skb)->frags[i];
 				pci_unmap_page(mdev->pdev,
 					(dma_addr_t) be64_to_cpu(data->addr),
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index 53aeea4..0f4cb88 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -1041,8 +1041,7 @@ static int __devinit myri_sbus_probe(struct platform_device *op)
 
 	DET(("Shared memory base is %04x, ", mp->shmem_base));
 
-	mp->shmem = (struct myri_shmem __iomem *)
-		(mp->lanai + (mp->shmem_base * 2));
+	mp->shmem = mp->lanai + (mp->shmem_base * 2);
 	DET(("shmem mapped at %p\n", mp->shmem));
 
 	mp->rqack	= &mp->shmem->channel.recvqa;
diff --git a/drivers/net/netxen/netxen_nic_ctx.c b/drivers/net/netxen/netxen_nic_ctx.c
index f16966a..a925392 100644
--- a/drivers/net/netxen/netxen_nic_ctx.c
+++ b/drivers/net/netxen/netxen_nic_ctx.c
@@ -163,7 +163,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
 				rq_size, &hostrq_phys_addr);
 	if (addr == NULL)
 		return -ENOMEM;
-	prq = (nx_hostrq_rx_ctx_t *)addr;
+	prq = addr;
 
 	addr = pci_alloc_consistent(adapter->pdev,
 			rsp_size, &cardrsp_phys_addr);
@@ -171,7 +171,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
 		err = -ENOMEM;
 		goto out_free_rq;
 	}
-	prsp = (nx_cardrsp_rx_ctx_t *)addr;
+	prsp = addr;
 
 	prq->host_rsp_dma_addr = cpu_to_le64(cardrsp_phys_addr);
 
@@ -318,10 +318,10 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter)
 	}
 
 	memset(rq_addr, 0, rq_size);
-	prq = (nx_hostrq_tx_ctx_t *)rq_addr;
+	prq = rq_addr;
 
 	memset(rsp_addr, 0, rsp_size);
-	prsp = (nx_cardrsp_tx_ctx_t *)rsp_addr;
+	prsp = rsp_addr;
 
 	prq->host_rsp_dma_addr = cpu_to_le64(rsp_phys_addr);
 
@@ -629,7 +629,7 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
 	}
 
 	memset(addr, 0, sizeof(struct netxen_ring_ctx));
-	recv_ctx->hwctx = (struct netxen_ring_ctx *)addr;
+	recv_ctx->hwctx = addr;
 	recv_ctx->hwctx->ctx_id = cpu_to_le32(port);
 	recv_ctx->hwctx->cmd_consumer_offset =
 		cpu_to_le64(recv_ctx->phys_addr +
@@ -648,7 +648,7 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
 		goto err_out_free;
 	}
 
-	tx_ring->desc_head = (struct cmd_desc_type0 *)addr;
+	tx_ring->desc_head = addr;
 
 	for (ring = 0; ring < adapter->max_rds_rings; ring++) {
 		rds_ring = &recv_ctx->rds_rings[ring];
@@ -662,7 +662,7 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
 			err = -ENOMEM;
 			goto err_out_free;
 		}
-		rds_ring->desc_head = (struct rcv_desc *)addr;
+		rds_ring->desc_head = addr;
 
 		if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
 			rds_ring->crb_rcv_producer =
@@ -683,7 +683,7 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
 			err = -ENOMEM;
 			goto err_out_free;
 		}
-		sds_ring->desc_head = (struct status_desc *)addr;
+		sds_ring->desc_head = addr;
 
 		if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
 			sds_ring->crb_sts_consumer =
diff --git a/drivers/net/pxa168_eth.c b/drivers/net/pxa168_eth.c
index 89f7540..abd1693 100644
--- a/drivers/net/pxa168_eth.c
+++ b/drivers/net/pxa168_eth.c
@@ -502,7 +502,7 @@ static int add_del_hash_entry(struct pxa168_eth_private *pep,
 	 * Pick the appropriate table, start scanning for free/reusable
 	 * entries at the index obtained by hashing the specified MAC address
 	 */
-	start = (struct addr_table_entry *)(pep->htpr);
+	start = pep->htpr;
 	entry = start + hash_function(mac_addr);
 	for (i = 0; i < HOP_NUMBER; i++) {
 		if (!(le32_to_cpu(entry->lo) & HASH_ENTRY_VALID)) {
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c
index 771bb61..2f69140 100644
--- a/drivers/net/qla3xxx.c
+++ b/drivers/net/qla3xxx.c
@@ -2873,7 +2873,7 @@ static int ql_alloc_mem_resources(struct ql3_adapter *qdev)
 				     PAGE_SIZE, &qdev->shadow_reg_phy_addr);
 
 	if (qdev->shadow_reg_virt_addr != NULL) {
-		qdev->preq_consumer_index = (u16 *) qdev->shadow_reg_virt_addr;
+		qdev->preq_consumer_index = qdev->shadow_reg_virt_addr;
 		qdev->req_consumer_index_phy_addr_high =
 			MS_64BITS(qdev->shadow_reg_phy_addr);
 		qdev->req_consumer_index_phy_addr_low =
@@ -3114,8 +3114,7 @@ static int ql_adapter_initialize(struct ql3_adapter *qdev)
 	qdev->small_buf_release_cnt = 8;
 	qdev->lrg_buf_q_producer_index = qdev->num_lbufq_entries - 1;
 	qdev->lrg_buf_release_cnt = 8;
-	qdev->lrg_buf_next_free =
-	    (struct bufq_addr_element *)qdev->lrg_buf_q_virt_addr;
+	qdev->lrg_buf_next_free = qdev->lrg_buf_q_virt_addr;
 	qdev->small_buf_index = 0;
 	qdev->lrg_buf_index = 0;
 	qdev->lrg_buf_free_count = 0;
diff --git a/drivers/net/qlcnic/qlcnic_ctx.c b/drivers/net/qlcnic/qlcnic_ctx.c
index bab041a..c77024f 100644
--- a/drivers/net/qlcnic/qlcnic_ctx.c
+++ b/drivers/net/qlcnic/qlcnic_ctx.c
@@ -126,7 +126,7 @@ int qlcnic_fw_cmd_get_minidump_temp(struct qlcnic_adapter *adapter)
 		err = -EIO;
 		goto error;
 	}
-	tmp_tmpl = (struct qlcnic_dump_template_hdr *) tmp_addr;
+	tmp_tmpl = tmp_addr;
 	csum = qlcnic_temp_checksum((uint32_t *) tmp_addr, temp_size);
 	if (csum) {
 		dev_err(&adapter->pdev->dev,
@@ -139,7 +139,7 @@ int qlcnic_fw_cmd_get_minidump_temp(struct qlcnic_adapter *adapter)
 		err = -EIO;
 		goto error;
 	}
-	tmp_buf = (u32 *) tmp_addr;
+	tmp_buf = tmp_addr;
 	template = (u32 *) ahw->fw_dump.tmpl_hdr;
 	for (i = 0; i < temp_size/sizeof(u32); i++)
 		*template++ = __le32_to_cpu(*tmp_buf++);
@@ -214,7 +214,7 @@ qlcnic_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter)
 			&hostrq_phys_addr, GFP_KERNEL);
 	if (addr == NULL)
 		return -ENOMEM;
-	prq = (struct qlcnic_hostrq_rx_ctx *)addr;
+	prq = addr;
 
 	addr = dma_alloc_coherent(&adapter->pdev->dev, rsp_size,
 			&cardrsp_phys_addr, GFP_KERNEL);
@@ -222,7 +222,7 @@ qlcnic_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter)
 		err = -ENOMEM;
 		goto out_free_rq;
 	}
-	prsp = (struct qlcnic_cardrsp_rx_ctx *)addr;
+	prsp = addr;
 
 	prq->host_rsp_dma_addr = cpu_to_le64(cardrsp_phys_addr);
 
@@ -380,10 +380,10 @@ qlcnic_fw_cmd_create_tx_ctx(struct qlcnic_adapter *adapter)
 	}
 
 	memset(rq_addr, 0, rq_size);
-	prq = (struct qlcnic_hostrq_tx_ctx *)rq_addr;
+	prq = rq_addr;
 
 	memset(rsp_addr, 0, rsp_size);
-	prsp = (struct qlcnic_cardrsp_tx_ctx *)rsp_addr;
+	prsp = rsp_addr;
 
 	prq->host_rsp_dma_addr = cpu_to_le64(rsp_phys_addr);
 
@@ -493,7 +493,7 @@ int qlcnic_alloc_hw_resources(struct qlcnic_adapter *adapter)
 		goto err_out_free;
 	}
 
-	tx_ring->desc_head = (struct cmd_desc_type0 *)addr;
+	tx_ring->desc_head = addr;
 
 	for (ring = 0; ring < adapter->max_rds_rings; ring++) {
 		rds_ring = &recv_ctx->rds_rings[ring];
@@ -506,7 +506,7 @@ int qlcnic_alloc_hw_resources(struct qlcnic_adapter *adapter)
 			err = -ENOMEM;
 			goto err_out_free;
 		}
-		rds_ring->desc_head = (struct rcv_desc *)addr;
+		rds_ring->desc_head = addr;
 
 	}
 
@@ -522,7 +522,7 @@ int qlcnic_alloc_hw_resources(struct qlcnic_adapter *adapter)
 			err = -ENOMEM;
 			goto err_out_free;
 		}
-		sds_ring->desc_head = (struct status_desc *)addr;
+		sds_ring->desc_head = addr;
 	}
 
 	return 0;
@@ -662,7 +662,7 @@ int qlcnic_get_nic_info(struct qlcnic_adapter *adapter,
 		return -ENOMEM;
 	memset(nic_info_addr, 0, nic_size);
 
-	nic_info = (struct qlcnic_info *) nic_info_addr;
+	nic_info = nic_info_addr;
 	err = qlcnic_issue_cmd(adapter,
 			adapter->ahw->pci_func,
 			adapter->fw_hal_version,
@@ -720,7 +720,7 @@ int qlcnic_set_nic_info(struct qlcnic_adapter *adapter, struct qlcnic_info *nic)
 		return -ENOMEM;
 
 	memset(nic_info_addr, 0, nic_size);
-	nic_info = (struct qlcnic_info *)nic_info_addr;
+	nic_info = nic_info_addr;
 
 	nic_info->pci_func = cpu_to_le16(nic->pci_func);
 	nic_info->op_mode = cpu_to_le16(nic->op_mode);
@@ -769,7 +769,7 @@ int qlcnic_get_pci_info(struct qlcnic_adapter *adapter,
 		return -ENOMEM;
 	memset(pci_info_addr, 0, pci_size);
 
-	npar = (struct qlcnic_pci_info *) pci_info_addr;
+	npar = pci_info_addr;
 	err = qlcnic_issue_cmd(adapter,
 			adapter->ahw->pci_func,
 			adapter->fw_hal_version,
@@ -877,7 +877,7 @@ int qlcnic_get_port_stats(struct qlcnic_adapter *adapter, const u8 func,
 			QLCNIC_CDRP_CMD_GET_ESWITCH_STATS);
 
 	if (!err) {
-		stats = (struct __qlcnic_esw_statistics *)stats_addr;
+		stats = stats_addr;
 		esw_stats->context_id = le16_to_cpu(stats->context_id);
 		esw_stats->version = le16_to_cpu(stats->version);
 		esw_stats->size = le16_to_cpu(stats->size);
diff --git a/drivers/net/qlcnic/qlcnic_ethtool.c b/drivers/net/qlcnic/qlcnic_ethtool.c
index 9efc690..8ea8001 100644
--- a/drivers/net/qlcnic/qlcnic_ethtool.c
+++ b/drivers/net/qlcnic/qlcnic_ethtool.c
@@ -996,7 +996,7 @@ qlcnic_get_dump_data(struct net_device *netdev, struct ethtool_dump *dump,
 	/* Copy template header first */
 	copy_sz = fw_dump->tmpl_hdr->size;
 	hdr_ptr = (u32 *) fw_dump->tmpl_hdr;
-	data = (u32 *) buffer;
+	data = buffer;
 	for (i = 0; i < copy_sz/sizeof(u32); i++)
 		*data++ = cpu_to_le32(*hdr_ptr++);
 
diff --git a/drivers/net/qlcnic/qlcnic_hw.c b/drivers/net/qlcnic/qlcnic_hw.c
index e965661..ea0f11e 100644
--- a/drivers/net/qlcnic/qlcnic_hw.c
+++ b/drivers/net/qlcnic/qlcnic_hw.c
@@ -1672,8 +1672,7 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
 	tmpl_hdr->sys_info[1] = adapter->fw_version;
 
 	for (i = 0; i < no_entries; i++) {
-		entry = (struct qlcnic_dump_entry *) ((void *) tmpl_hdr +
-			entry_offset);
+		entry = (void *)tmpl_hdr + entry_offset;
 		if (!(entry->hdr.mask & tmpl_hdr->drv_cap_mask)) {
 			entry->hdr.flags |= QLCNIC_DUMP_SKIP;
 			entry_offset += entry->hdr.offset;
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index 3ab7d2c..0a6c1c9 100644
--- a/drivers/net/qlcnic/qlcnic_main.c
+++ b/drivers/net/qlcnic/qlcnic_main.c
@@ -1861,7 +1861,7 @@ qlcnic_alloc_lb_filters_mem(struct qlcnic_adapter *adapter)
 		return;
 
 	adapter->fhash.fmax = QLCNIC_LB_MAX_FILTERS;
-	adapter->fhash.fhead = (struct hlist_head *)head;
+	adapter->fhash.fhead = head;
 
 	for (i = 0; i < adapter->fhash.fmax; i++)
 		INIT_HLIST_HEAD(&adapter->fhash.fhead[i]);
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index 930ae45..be89610 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -3096,7 +3096,7 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
 	if (rx_ring->lbq_len) {
 		cqicb->flags |= FLAGS_LL;	/* Load lbq values */
 		tmp = (u64)rx_ring->lbq_base_dma;
-		base_indirect_ptr = (__le64 *) rx_ring->lbq_base_indirect;
+		base_indirect_ptr = rx_ring->lbq_base_indirect;
 		page_entries = 0;
 		do {
 			*base_indirect_ptr = cpu_to_le64(tmp);
@@ -3120,7 +3120,7 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
 	if (rx_ring->sbq_len) {
 		cqicb->flags |= FLAGS_LS;	/* Load sbq values */
 		tmp = (u64)rx_ring->sbq_base_dma;
-		base_indirect_ptr = (__le64 *) rx_ring->sbq_base_indirect;
+		base_indirect_ptr = rx_ring->sbq_base_indirect;
 		page_entries = 0;
 		do {
 			*base_indirect_ptr = cpu_to_le64(tmp);
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index df0d2c8..f4d80f9 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -841,7 +841,7 @@ static int init_shared_mem(struct s2io_nic *nic)
 			tmp_p_addr = ring->rx_blocks[j].block_dma_addr;
 			tmp_p_addr_next = ring->rx_blocks[next].block_dma_addr;
 
-			pre_rxd_blk = (struct RxD_block *)tmp_v_addr;
+			pre_rxd_blk = tmp_v_addr;
 			pre_rxd_blk->reserved_2_pNext_RxD_block =
 				(unsigned long)tmp_v_addr_next;
 			pre_rxd_blk->pNext_RxD_Blk_physical =
@@ -918,7 +918,7 @@ static int init_shared_mem(struct s2io_nic *nic)
 	mac_control->stats_mem_sz = size;
 
 	tmp_v_addr = mac_control->stats_mem;
-	mac_control->stats_info = (struct stat_block *)tmp_v_addr;
+	mac_control->stats_info = tmp_v_addr;
 	memset(tmp_v_addr, 0, size);
 	DBG_PRINT(INIT_DBG, "%s: Ring Mem PHY: 0x%llx\n",
 		dev_name(&nic->pdev->dev), (unsigned long long)tmp_p_addr);
@@ -2439,7 +2439,7 @@ static void free_tx_buffers(struct s2io_nic *nic)
 
 		spin_lock_irqsave(&fifo->tx_lock, flags);
 		for (j = 0; j < tx_cfg->fifo_len; j++) {
-			txdp = (struct TxD *)fifo->list_info[j].list_virt_addr;
+			txdp = fifo->list_info[j].list_virt_addr;
 			skb = s2io_txdl_getskb(&mac_control->fifos[i], txdp, j);
 			if (skb) {
 				swstats->mem_freed += skb->truesize;
@@ -3075,8 +3075,7 @@ static void tx_intr_handler(struct fifo_info *fifo_data)
 
 	get_info = fifo_data->tx_curr_get_info;
 	memcpy(&put_info, &fifo_data->tx_curr_put_info, sizeof(put_info));
-	txdlp = (struct TxD *)
-		fifo_data->list_info[get_info.offset].list_virt_addr;
+	txdlp = fifo_data->list_info[get_info.offset].list_virt_addr;
 	while ((!(txdlp->Control_1 & TXD_LIST_OWN_XENA)) &&
 	       (get_info.offset != put_info.offset) &&
 	       (txdlp->Host_Control)) {
@@ -3129,8 +3128,7 @@ static void tx_intr_handler(struct fifo_info *fifo_data)
 		get_info.offset++;
 		if (get_info.offset == get_info.fifo_len + 1)
 			get_info.offset = 0;
-		txdlp = (struct TxD *)
-			fifo_data->list_info[get_info.offset].list_virt_addr;
+		txdlp = fifo_data->list_info[get_info.offset].list_virt_addr;
 		fifo_data->tx_curr_get_info.offset = get_info.offset;
 	}
 
@@ -4163,7 +4161,7 @@ static netdev_tx_t s2io_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	put_off = (u16)fifo->tx_curr_put_info.offset;
 	get_off = (u16)fifo->tx_curr_get_info.offset;
-	txdp = (struct TxD *)fifo->list_info[put_off].list_virt_addr;
+	txdp = fifo->list_info[put_off].list_virt_addr;
 
 	queue_len = fifo->tx_curr_put_info.fifo_len + 1;
 	/* Avoid "put" pointer going beyond "get" pointer */
@@ -7972,9 +7970,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
 
 	/* Initializing the BAR1 address as the start of the FIFO pointer. */
 	for (j = 0; j < MAX_TX_FIFOS; j++) {
-		mac_control->tx_FIFO_start[j] =
-			(struct TxFIFO_element __iomem *)
-			(sp->bar1 + (j * 0x00020000));
+		mac_control->tx_FIFO_start[j] = sp->bar1 + (j * 0x00020000);
 	}
 
 	/*  Driver entry points */
diff --git a/drivers/net/sfc/siena.c b/drivers/net/sfc/siena.c
index fb4721f..a66818e 100644
--- a/drivers/net/sfc/siena.c
+++ b/drivers/net/sfc/siena.c
@@ -400,7 +400,7 @@ static int siena_try_update_nic_stats(struct efx_nic *efx)
 	u64 generation_end;
 
 	mac_stats = &efx->mac_stats;
-	dma_stats = (u64 *)efx->stats_buffer.addr;
+	dma_stats = efx->stats_buffer.addr;
 
 	generation_end = dma_stats[MC_CMD_MAC_GENERATION_END];
 	if (generation_end == STATS_GENERATION_INVALID)
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index 484f795..658a192 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -482,7 +482,7 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
 		ret = -ENOMEM;
 		goto err_out_cleardev;
 	}
-	sis_priv->tx_ring = (BufferDesc *)ring_space;
+	sis_priv->tx_ring = ring_space;
 	sis_priv->tx_ring_dma = ring_dma;
 
 	ring_space = pci_alloc_consistent(pci_dev, RX_TOTAL_SIZE, &ring_dma);
@@ -490,7 +490,7 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
 		ret = -ENOMEM;
 		goto err_unmap_tx;
 	}
-	sis_priv->rx_ring = (BufferDesc *)ring_space;
+	sis_priv->rx_ring = ring_space;
 	sis_priv->rx_ring_dma = ring_dma;
 
 	/* The SiS900-specific entries in the device structure. */
diff --git a/drivers/net/tokenring/madgemc.c b/drivers/net/tokenring/madgemc.c
index 2bedc0a..6153cfd 100644
--- a/drivers/net/tokenring/madgemc.c
+++ b/drivers/net/tokenring/madgemc.c
@@ -418,7 +418,7 @@ static irqreturn_t madgemc_interrupt(int irq, void *dev_id)
 		return IRQ_NONE;
 	}
 
-	dev = (struct net_device *)dev_id;
+	dev = dev_id;
 
 	/* Make sure its really us. -- the Madge way */
 	pending = inb(dev->base_addr + MC_CONTROL_REG0);
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index 3de4283..1d5091a 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -2367,7 +2367,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	dev->irq = pdev->irq;
 	tp = netdev_priv(dev);
-	tp->shared = (struct typhoon_shared *) shared;
+	tp->shared = shared;
 	tp->shared_dma = shared_dma;
 	tp->pdev = pdev;
 	tp->tx_pdev = pdev;
diff --git a/drivers/net/vxge/vxge-config.c b/drivers/net/vxge/vxge-config.c
index 32763b2..857618a 100644
--- a/drivers/net/vxge/vxge-config.c
+++ b/drivers/net/vxge/vxge-config.c
@@ -582,7 +582,7 @@ __vxge_hw_device_toc_get(void __iomem *bar0)
 		goto exit;
 
 	val64 =	readq(&legacy_reg->toc_first_pointer);
-	toc = (struct vxge_hw_toc_reg __iomem *)(bar0+val64);
+	toc = bar0 + val64;
 exit:
 	return toc;
 }
@@ -600,7 +600,7 @@ __vxge_hw_device_reg_addr_get(struct __vxge_hw_device *hldev)
 	u32 i;
 	enum vxge_hw_status status = VXGE_HW_OK;
 
-	hldev->legacy_reg = (struct vxge_hw_legacy_reg __iomem *)hldev->bar0;
+	hldev->legacy_reg = hldev->bar0;
 
 	hldev->toc_reg = __vxge_hw_device_toc_get(hldev->bar0);
 	if (hldev->toc_reg  == NULL) {
@@ -609,39 +609,31 @@ __vxge_hw_device_reg_addr_get(struct __vxge_hw_device *hldev)
 	}
 
 	val64 = readq(&hldev->toc_reg->toc_common_pointer);
-	hldev->common_reg =
-	(struct vxge_hw_common_reg __iomem *)(hldev->bar0 + val64);
+	hldev->common_reg = hldev->bar0 + val64;
 
 	val64 = readq(&hldev->toc_reg->toc_mrpcim_pointer);
-	hldev->mrpcim_reg =
-		(struct vxge_hw_mrpcim_reg __iomem *)(hldev->bar0 + val64);
+	hldev->mrpcim_reg = hldev->bar0 + val64;
 
 	for (i = 0; i < VXGE_HW_TITAN_SRPCIM_REG_SPACES; i++) {
 		val64 = readq(&hldev->toc_reg->toc_srpcim_pointer[i]);
-		hldev->srpcim_reg[i] =
-			(struct vxge_hw_srpcim_reg __iomem *)
-				(hldev->bar0 + val64);
+		hldev->srpcim_reg[i] = hldev->bar0 + val64;
 	}
 
 	for (i = 0; i < VXGE_HW_TITAN_VPMGMT_REG_SPACES; i++) {
 		val64 = readq(&hldev->toc_reg->toc_vpmgmt_pointer[i]);
-		hldev->vpmgmt_reg[i] =
-		(struct vxge_hw_vpmgmt_reg __iomem *)(hldev->bar0 + val64);
+		hldev->vpmgmt_reg[i] = hldev->bar0 + val64;
 	}
 
 	for (i = 0; i < VXGE_HW_TITAN_VPATH_REG_SPACES; i++) {
 		val64 = readq(&hldev->toc_reg->toc_vpath_pointer[i]);
-		hldev->vpath_reg[i] =
-			(struct vxge_hw_vpath_reg __iomem *)
-				(hldev->bar0 + val64);
+		hldev->vpath_reg[i] = hldev->bar0 + val64;
 	}
 
 	val64 = readq(&hldev->toc_reg->toc_kdfc);
 
 	switch (VXGE_HW_TOC_GET_KDFC_INITIAL_BIR(val64)) {
 	case 0:
-		hldev->kdfc = (u8 __iomem *)(hldev->bar0 +
-			VXGE_HW_TOC_GET_KDFC_INITIAL_OFFSET(val64));
+		hldev->kdfc = hldev->bar0 + VXGE_HW_TOC_GET_KDFC_INITIAL_OFFSET(val64) ;
 		break;
 	default:
 		break;
@@ -1024,7 +1016,7 @@ vxge_hw_device_hw_info_get(void __iomem *bar0,
 	}
 
 	val64 = readq(&toc->toc_common_pointer);
-	common_reg = (struct vxge_hw_common_reg __iomem *)(bar0 + val64);
+	common_reg = bar0 + val64;
 
 	status = __vxge_hw_device_vpath_reset_in_prog_check(
 		(u64 __iomem *)&common_reg->vpath_rst_in_prog);
@@ -1044,8 +1036,7 @@ vxge_hw_device_hw_info_get(void __iomem *bar0,
 
 		val64 = readq(&toc->toc_vpmgmt_pointer[i]);
 
-		vpmgmt_reg = (struct vxge_hw_vpmgmt_reg __iomem *)
-				(bar0 + val64);
+		vpmgmt_reg = bar0 + val64;
 
 		hw_info->func_id = __vxge_hw_vpath_func_id_get(vpmgmt_reg);
 		if (__vxge_hw_device_access_rights_get(hw_info->host_type,
@@ -1054,8 +1045,7 @@ vxge_hw_device_hw_info_get(void __iomem *bar0,
 
 			val64 = readq(&toc->toc_mrpcim_pointer);
 
-			mrpcim_reg = (struct vxge_hw_mrpcim_reg __iomem *)
-					(bar0 + val64);
+			mrpcim_reg = bar0 + val64;
 
 			writeq(0, &mrpcim_reg->xgmac_gen_fw_memo_mask);
 			wmb();
@@ -1064,8 +1054,7 @@ vxge_hw_device_hw_info_get(void __iomem *bar0,
 		val64 = readq(&toc->toc_vpath_pointer[i]);
 
 		spin_lock_init(&vpath.lock);
-		vpath.vp_reg = (struct vxge_hw_vpath_reg __iomem *)
-			       (bar0 + val64);
+		vpath.vp_reg = bar0 + val64;
 		vpath.vp_open = VXGE_HW_VP_NOT_OPEN;
 
 		status = __vxge_hw_vpath_pci_func_mode_get(&vpath, hw_info);
@@ -1088,8 +1077,7 @@ vxge_hw_device_hw_info_get(void __iomem *bar0,
 			continue;
 
 		val64 = readq(&toc->toc_vpath_pointer[i]);
-		vpath.vp_reg = (struct vxge_hw_vpath_reg __iomem *)
-			       (bar0 + val64);
+		vpath.vp_reg = bar0 + val64;
 		vpath.vp_open = VXGE_HW_VP_NOT_OPEN;
 
 		status =  __vxge_hw_vpath_addr_get(&vpath,
@@ -2140,8 +2128,7 @@ __vxge_hw_ring_mempool_item_alloc(struct vxge_hw_mempool *mempoolh,
 					memblock_index, item,
 					&memblock_item_idx);
 
-		rxdp = (struct vxge_hw_ring_rxd_1 *)
-				ring->channel.reserve_arr[reserve_index];
+		rxdp = ring->channel.reserve_arr[reserve_index];
 
 		uld_priv = ((u8 *)rxdblock_priv + ring->rxd_priv_size * i);
 
@@ -4880,8 +4867,7 @@ vxge_hw_vpath_open(struct __vxge_hw_device *hldev,
 		goto vpath_open_exit8;
 	}
 
-	vpath->hw_stats = (struct vxge_hw_vpath_stats_hw_info *)vpath->
-			stats_block->memblock;
+	vpath->hw_stats = vpath->stats_block->memblock;
 	memset(vpath->hw_stats, 0,
 		sizeof(struct vxge_hw_vpath_stats_hw_info));
 
diff --git a/drivers/net/vxge/vxge-traffic.c b/drivers/net/vxge/vxge-traffic.c
index f935170..ad64ce0 100644
--- a/drivers/net/vxge/vxge-traffic.c
+++ b/drivers/net/vxge/vxge-traffic.c
@@ -1309,7 +1309,7 @@ enum vxge_hw_status vxge_hw_ring_rxd_next_completed(
 
 	vxge_hw_channel_dtr_try_complete(channel, rxdh);
 
-	rxdp = (struct vxge_hw_ring_rxd_1 *)*rxdh;
+	rxdp = *rxdh;
 	if (rxdp == NULL) {
 		status = VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS;
 		goto exit;
@@ -1565,7 +1565,7 @@ void vxge_hw_fifo_txdl_post(struct __vxge_hw_fifo *fifo, void *txdlh)
 	channel = &fifo->channel;
 
 	txdl_priv = __vxge_hw_fifo_txdl_priv(fifo, txdlh);
-	txdp_first = (struct vxge_hw_fifo_txd *)txdlh;
+	txdp_first = txdlh;
 
 	txdp_last = (struct vxge_hw_fifo_txd *)txdlh  +  (txdl_priv->frags - 1);
 	txdp_last->control_0 |=
@@ -1631,7 +1631,7 @@ enum vxge_hw_status vxge_hw_fifo_txdl_next_completed(
 
 	vxge_hw_channel_dtr_try_complete(channel, txdlh);
 
-	txdp = (struct vxge_hw_fifo_txd *)*txdlh;
+	txdp = *txdlh;
 	if (txdp == NULL) {
 		status = VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS;
 		goto exit;
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
index 1c65d1c..850fc84 100644
--- a/drivers/net/wan/pc300_tty.c
+++ b/drivers/net/wan/pc300_tty.c
@@ -755,7 +755,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
 
 	dsr_rx = cpc_readb(card->hw.scabase + DSR_RX(ch));
 
-	cpc_tty = (st_cpc_tty_area *)pc300dev->cpc_tty; 
+	cpc_tty = pc300dev->cpc_tty; 
 
 	while (1) { 
 		rx_len = 0;
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index 9cb4cdc..bbb8c65 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -252,11 +252,11 @@ static void xemaclite_aligned_write(void *src_ptr, u32 *dest_ptr,
 	u16 *from_u16_ptr, *to_u16_ptr;
 
 	to_u32_ptr = dest_ptr;
-	from_u16_ptr = (u16 *) src_ptr;
+	from_u16_ptr = src_ptr;
 	align_buffer = 0;
 
 	for (; length > 3; length -= 4) {
-		to_u16_ptr = (u16 *) ((void *) &align_buffer);
+		to_u16_ptr = (u16 *)&align_buffer;
 		*to_u16_ptr++ = *from_u16_ptr++;
 		*to_u16_ptr++ = *from_u16_ptr++;
 
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
index ec47e22..3e5ac60 100644
--- a/drivers/net/yellowfin.c
+++ b/drivers/net/yellowfin.c
@@ -442,19 +442,19 @@ static int __devinit yellowfin_init_one(struct pci_dev *pdev,
 	ring_space = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
 	if (!ring_space)
 		goto err_out_cleardev;
-	np->tx_ring = (struct yellowfin_desc *)ring_space;
+	np->tx_ring = ring_space;
 	np->tx_ring_dma = ring_dma;
 
 	ring_space = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma);
 	if (!ring_space)
 		goto err_out_unmap_tx;
-	np->rx_ring = (struct yellowfin_desc *)ring_space;
+	np->rx_ring = ring_space;
 	np->rx_ring_dma = ring_dma;
 
 	ring_space = pci_alloc_consistent(pdev, STATUS_TOTAL_SIZE, &ring_dma);
 	if (!ring_space)
 		goto err_out_unmap_rx;
-	np->tx_status = (struct tx_status_words *)ring_space;
+	np->tx_status = ring_space;
 	np->tx_status_dma = ring_dma;
 
 	if (dev->mem_start)
-- 
1.7.6.rc0


^ permalink raw reply related

* Re: [PATCH net-next 1/2] wireless: Remove casts of void *
From: Julian Calaby @ 2011-06-14  5:23 UTC (permalink / raw)
  To: Joe Perches
  Cc: netdev, Luis R. Rodriguez, Jouni Malinen,
	Vasanthakumar Thiagarajan, Senthil Balasubramanian,
	John W. Linville, Christian Lamparter, Stanislaw Gruszka,
	Wey-Yi Guy, Intel Linux Wireless, linux-wireless, ath9k-devel,
	linux-kernel
In-Reply-To: <337c22b774ff7f007b90b266b25c9a33ff555c48.1308024069.git.joe@perches.com>

Joe,

On Tue, Jun 14, 2011 at 14:02, Joe Perches <joe@perches.com> wrote:
> Unnecessary casts of void * clutter the code.
>
> These are the remainder casts after several specific
> patches to remove netdev_priv and dev_priv.

You seem to have removed a lot of casts that don't relate to these cleanups.

In particular, some of the casts seem to relate more to documentation
rather than just changing pointer types to make the compiler happy. In
particular, I'm referring to the casts describing the different usages
of data_buf in mwiflex, and around some pointer math in ath9k.

Whilst I'm sure that the compiler is smart enough to handle automatic
casts between pointer types, some of these, in particular the mwiflex
bits, add some documentation to the code.

Thanks,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
.Plan: http://sites.google.com/site/juliancalaby/

^ permalink raw reply

* Re: [PATCH net-next 1/2] wireless: Remove casts of void *
From: Joe Perches @ 2011-06-14  5:32 UTC (permalink / raw)
  To: Julian Calaby
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Luis R. Rodriguez, Jouni Malinen,
	Vasanthakumar Thiagarajan, Senthil Balasubramanian,
	John W. Linville, Christian Lamparter, Stanislaw Gruszka,
	Wey-Yi Guy, Intel Linux Wireless,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	ath9k-devel-xDcbHBWguxHbcTqmT+pZeQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <BANLkTi=i30Rn7gpCDbn9KKJucq8CB=hssA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Tue, 2011-06-14 at 15:23 +1000, Julian Calaby wrote:
> Joe,

Hi Julian.

> On Tue, Jun 14, 2011 at 14:02, Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org> wrote:
> > Unnecessary casts of void * clutter the code.
> > These are the remainder casts after several specific
> > patches to remove netdev_priv and dev_priv.
> You seem to have removed a lot of casts that don't relate to these cleanups.
> In particular, some of the casts seem to relate more to documentation
> rather than just changing pointer types to make the compiler happy.

All of the cast removals are casts of void* types.
I think none of of the casts are useful.
None of them are required, all are duplicative.

> In
> particular, I'm referring to the casts describing the different usages
> of data_buf in mwiflex, and around some pointer math in ath9k.

Can you describe more in detail why you think these are documentary?

This sort of cast:

diff --git a/drivers/net/wireless/mwifiex/11n.c b/drivers/net/wireless/mwifiex/11n.c
@@ -191,7 +191,7 @@ int mwifiex_ret_11n_cfg(struct host_cmd_ds_command *resp, void *data_buf)
 	struct host_cmd_ds_11n_cfg *htcfg = &resp->params.htcfg;
 
 	if (data_buf) {
-		tx_cfg = (struct mwifiex_ds_11n_tx_cfg *) data_buf;
+               tx_cfg = data_buf;

I think pretty useless.  tx_cfg is a struct mwifiex_ds_11n_tx_cfg *.

> Whilst I'm sure that the compiler is smart enough to handle automatic
> casts between pointer types, some of these, in particular the mwiflex
> bits, add some documentation to the code.

I think not.  Opinions of course can vary.

cheers, Joe

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH net-next 1/2] wireless: Remove casts of void *
From: Julian Calaby @ 2011-06-14  5:39 UTC (permalink / raw)
  To: Joe Perches
  Cc: Intel Linux Wireless, netdev, linux-wireless, John W. Linville,
	Jouni Malinen, Senthil Balasubramanian, ath9k-devel, Wey-Yi Guy,
	Vasanthakumar Thiagarajan, Christian Lamparter, Stanislaw Gruszka,
	linux-kernel
In-Reply-To: <1308029532.26699.68.camel@Joe-Laptop>

Joe,

On Tue, Jun 14, 2011 at 15:32, Joe Perches <joe@perches.com> wrote:
> On Tue, 2011-06-14 at 15:23 +1000, Julian Calaby wrote:
>> Joe,
>
> Hi Julian.
>
>> On Tue, Jun 14, 2011 at 14:02, Joe Perches <joe@perches.com> wrote:
>> > Unnecessary casts of void * clutter the code.
>> > These are the remainder casts after several specific
>> > patches to remove netdev_priv and dev_priv.
>> You seem to have removed a lot of casts that don't relate to these cleanups.
>> In particular, some of the casts seem to relate more to documentation
>> rather than just changing pointer types to make the compiler happy.
>
> All of the cast removals are casts of void* types.
> I think none of of the casts are useful.
> None of them are required, all are duplicative.

My issue here is that you mention in the commit log that this relates
to the removal of netdev_priv and dev_priv, but the casts removed
(mostly) don't.

>> In
>> particular, I'm referring to the casts describing the different usages
>> of data_buf in mwiflex, and around some pointer math in ath9k.
>
> Can you describe more in detail why you think these are documentary?
>
> This sort of cast:
>
> diff --git a/drivers/net/wireless/mwifiex/11n.c b/drivers/net/wireless/mwifiex/11n.c
> @@ -191,7 +191,7 @@ int mwifiex_ret_11n_cfg(struct host_cmd_ds_command *resp, void *data_buf)
>        struct host_cmd_ds_11n_cfg *htcfg = &resp->params.htcfg;
>
>        if (data_buf) {
> -               tx_cfg = (struct mwifiex_ds_11n_tx_cfg *) data_buf;
> +               tx_cfg = data_buf;
>
> I think pretty useless.  tx_cfg is a struct mwifiex_ds_11n_tx_cfg *.

True, but IMHO, this documents, particularly in a random snippet like
this, what's going on. Arguably though, a better fix would be to move
the cast to the place where this function is called.

>> Whilst I'm sure that the compiler is smart enough to handle automatic
>> casts between pointer types, some of these, in particular the mwiflex
>> bits, add some documentation to the code.
>
> I think not.  Opinions of course can vary.

Of course. I rarely look at full files, so the more information that
can be stuffed into a patch, the better for me. That said, I agree
that all the casts removed are superfluous.

Thanks,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
.Plan: http://sites.google.com/site/juliancalaby/

^ permalink raw reply

* Re: Re: [RFC PATCH 1/1] IPVS netns shutdown/startup dead-lock
From: Julian Anastasov @ 2011-06-14  6:36 UTC (permalink / raw)
  To: Hans Schillstrom
  Cc: Hans Schillstrom, horms, wensong, lvs-devel, netdev,
	netfilter-devel
In-Reply-To: <oth2obo.8109e7bd386ff72c34c0bda4b6945edf@obelix.schillstrom.com>


	Hello,

On Tue, 14 Jun 2011, Hans Schillstrom wrote:

> >On Mon, 13 Jun 2011, Hans Schillstrom wrote:
> >
> >> ip_vs_mutext is used by both netns shutdown code and startup
> >> and both implicit uses sk_lock-AF_INET mutex.
> >> 
> >> cleanup CPU-1         startup CPU-2
> >> ip_vs_dst_event()     ip_vs_genl_set_cmd()
> >>  sk_lock-AF_INET     __ip_vs_mutex
> >>                      sk_lock-AF_INET
> >> __ip_vs_mutex
> >> * DEAD LOCK *
> >
> >	So, sk_lock-AF_INET is locked before calling
> >ip_vs_dst_event ? Do you have a backtrace for this case?
> 
> Yes plenty this one is with lockdep
> 
> Chain exists of:
>   rtnl_mutex --> __ip_vs_mutex --> sk_lock-AF_INET
> 
>  Possible unsafe locking scenario:
> 
>        CPU0                    CPU1
>        ----                    ----
>   lock(sk_lock-AF_INET);
>                                lock(__ip_vs_mutex);
>                                lock(sk_lock-AF_INET);
>   lock(rtnl_mutex);
> 
>  *** DEADLOCK ***
> 
> 3 locks held by ipvsadm/993:
>  #0:  (genl_mutex){+.+.+.}, at: [<ffffffff812edc52>] genl_lock+0x17/0x19
>  #1:  (__ip_vs_mutex){+.+.+.}, at: [<ffffffff81307dcb>] ip_vs_genl_set_cmd+0xe1/0x3a3
>  #2:  (sk_lock-AF_INET){+.+.+.}, at: [<ffffffff8130ffc1>] start_sync_thread+0x3ec/0x5ff

	I see

> >> ip_vs_mutex per name-space seems to be a more future proof solution.
> >
> >	Global mutex protects some global lists such as
> >virtual services. If your patch works, better way to fix this problem
> >is to use some new mutex. May be we can move the IPVS_CMD_NEW_DAEMON,
> >IPVS_CMD_DEL_DAEMON and IP_VS_SO_GET_DAEMON code before the
> >__ip_vs_mutex locking. This mutex should be used for start_sync_thread,
> >stop_sync_thread, ip_vs_genl_dump_daemons and IP_VS_SO_GET_DAEMON.
> >For example, ip_vs_sync_mutex.
> 
> I think we should avoid global mutexes as a rule of tumb, 
> because it's realy hard to keep track of all possible cases 
> that can occur when multiple netns is alive and/or goes up and down.
> 
> There might be more suprises while a netns exits (in terms of locks)...
> my gut feeling is, avoid global locks as long as possible.

	There should not be a problem between two netns when
using global mutexes. And there are no many places in IPVS
where other modules are accessed.

> >	Note that __ip_vs_sync_cleanup is missing a
> >__ip_vs_mutex lock. We have to use the new mutex there.
> 
> OK
> 
> >
> >> Which one should be used ?
> >
> >	For now __ip_vs_mutex should be global ...
> 
> I do agree, but in the long term I vote for mutex per netns.

	It will not help because the problem does not happen
between two netspaces but between ipvs and other modules.
The same problem would happen even if __ip_vs_mutex was
pernet mutex. So, lets try with new mutex.

Regards

--
Julian Anastasov <ja@ssi.bg>

^ permalink raw reply

* Re: [PATCH net-next 1/2] wireless: Remove casts of void *
From: Joe Perches @ 2011-06-14  7:19 UTC (permalink / raw)
  To: Julian Calaby
  Cc: netdev, Luis R. Rodriguez, Jouni Malinen,
	Vasanthakumar Thiagarajan, Senthil Balasubramanian,
	John W. Linville, Christian Lamparter, Stanislaw Gruszka,
	Wey-Yi Guy, Intel Linux Wireless, linux-wireless, ath9k-devel,
	linux-kernel
In-Reply-To: <BANLkTik4fWbCc8pRZfKCzvKD2f6sK9QCEw@mail.gmail.com>

On Tue, 2011-06-14 at 15:39 +1000, Julian Calaby wrote:
> My issue here is that you mention in the commit log that this relates
> to the removal of netdev_priv and dev_priv, but the casts removed
> (mostly) don't.

Sorry if that was unclear to you.

None of these patches remove casts of netdev_priv.

What I meant to say was that net and drivers/net have
had many patches that remove casts of void * like the
patches that removed casts of netdev_priv.

These patches remove the last casts of void * types
in net and drivers/net.

cheers, Joe

^ permalink raw reply

* Re: [PATCH net-next 2/2] drivers/net: Remove casts of void *
From: Debashis Dutt @ 2011-06-14  7:56 UTC (permalink / raw)
  To: Joe Perches
  Cc: netdev, Arnaldo Carvalho de Melo, Jay Cliburn, Chris Snook,
	Jie Yang, Sathya Perla, Subbu Seetharaman, Ajit Khaparde,
	Rasesh Mody, Debashis Dutt, Sjur Braendeland, Divy Le Ray,
	Breno Leitao, Amit Kumar Salecha, Ron Mercer, linux-driver,
	Anirban Chakraborty, Jon Mason, Solarflare linux maintainers,
	Steve Hodgson, Ben Hutchings, Daniele Venzano
In-Reply-To: <486a21b708a9dce0c1c0059a21a2f9b66dac9e3c.1308024069.git.joe@perches.com>

> diff --git a/drivers/net/bna/bfa_cee.c b/drivers/net/bna/bfa_cee.c
> index f7b789a..dcfbf08 100644
> --- a/drivers/net/bna/bfa_cee.c
> +++ b/drivers/net/bna/bfa_cee.c
> @@ -236,7 +236,7 @@ static void
>  bfa_cee_hbfail(void *arg)
>  {
>        struct bfa_cee *cee;
> -       cee = (struct bfa_cee *) arg;
> +       cee = arg;
>
>        if (cee->get_attr_pending == true) {
>                cee->get_attr_status = BFA_STATUS_FAILED;
> diff --git a/drivers/net/bna/cna.h b/drivers/net/bna/cna.h
> index bbd39dc..3c47dc5 100644
> --- a/drivers/net/bna/cna.h
> +++ b/drivers/net/bna/cna.h
> @@ -74,7 +74,7 @@ typedef struct mac { u8 mac[MAC_ADDRLEN]; } mac_t;
>                bfa_q_next(_q) = bfa_q_next(*((struct list_head **) _qe)); \
>                bfa_q_qe_init(*((struct list_head **) _qe));            \
>        } else {                                                        \
> -               *((struct list_head **) (_qe)) = (struct list_head *) NULL; \
> +               *((struct list_head **)(_qe)) = NULL;                   \
>        }                                                               \
>  }
>

"bna" patches look good.

Thanks
--Debashis

^ permalink raw reply

* Re: [PATCH net-next 2/2] drivers/net: Remove casts of void *
From: Daniele Venzano @ 2011-06-14  8:18 UTC (permalink / raw)
  To: Joe Perches
  Cc: netdev, Arnaldo Carvalho de Melo, Jay Cliburn, Chris Snook,
	Jie Yang, Sathya Perla, Subbu Seetharaman, Ajit Khaparde,
	Rasesh Mody, Debashis Dutt, Sjur Braendeland, Divy Le Ray,
	Breno Leitao, Amit Kumar Salecha, Ron Mercer, linux-driver,
	Anirban Chakraborty, Jon Mason, Solarflare linux maintainers,
	Steve Hodgson, Ben Hutchings, David Dillow
In-Reply-To: <486a21b708a9dce0c1c0059a21a2f9b66dac9e3c.1308024069.git.joe@perches.com>

2011/6/14 Joe Perches <joe@perches.com>:
> Unnecessary casts of void * clutter the code.

> diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
> index 484f795..658a192 100644
> --- a/drivers/net/sis900.c
> +++ b/drivers/net/sis900.c
> @@ -482,7 +482,7 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
>                ret = -ENOMEM;
>                goto err_out_cleardev;
>        }
> -       sis_priv->tx_ring = (BufferDesc *)ring_space;
> +       sis_priv->tx_ring = ring_space;
>        sis_priv->tx_ring_dma = ring_dma;
>
>        ring_space = pci_alloc_consistent(pci_dev, RX_TOTAL_SIZE, &ring_dma);
> @@ -490,7 +490,7 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
>                ret = -ENOMEM;
>                goto err_unmap_tx;
>        }
> -       sis_priv->rx_ring = (BufferDesc *)ring_space;
> +       sis_priv->rx_ring = ring_space;
>        sis_priv->rx_ring_dma = ring_dma;
>
>        /* The SiS900-specific entries in the device structure. */

sis900 looks good, too.

-- 
Daniele Venzano
venza@brownhat.org
http://www.brownhat.org

^ permalink raw reply

* RE: [PATCH net-next 1/2] wireless: Remove casts of void *
From: Bing Zhao @ 2011-06-14  8:45 UTC (permalink / raw)
  To: Julian Calaby, Joe Perches
  Cc: netdev@vger.kernel.org, Luis R. Rodriguez, Jouni Malinen,
	Vasanthakumar Thiagarajan, Senthil Balasubramanian,
	John W. Linville, Christian Lamparter, Stanislaw Gruszka,
	Wey-Yi Guy, Intel Linux Wireless, linux-wireless@vger.kernel.org,
	ath9k-devel@lists.ath9k.org, linux-kernel@vger.kernel.org
In-Reply-To: <BANLkTik4fWbCc8pRZfKCzvKD2f6sK9QCEw@mail.gmail.com>

>> diff --git a/drivers/net/wireless/mwifiex/11n.c b/drivers/net/wireless/mwifiex/11n.c
>> @@ -191,7 +191,7 @@ int mwifiex_ret_11n_cfg(struct host_cmd_ds_command *resp, void *data_buf)
>>        struct host_cmd_ds_11n_cfg *htcfg = &resp->params.htcfg;
>>
>>        if (data_buf) {
>> -               tx_cfg = (struct mwifiex_ds_11n_tx_cfg *) data_buf;
>> +               tx_cfg = data_buf;
>>
>> I think pretty useless.  tx_cfg is a struct mwifiex_ds_11n_tx_cfg *.
> 
> True, but IMHO, this documents, particularly in a random snippet like
> this, what's going on. Arguably though, a better fix would be to move
> the cast to the place where this function is called.

Hi Julian,

Thanks for your comment. We will work on this.

Regards,
Bing

^ permalink raw reply

* RE: [PATCH net-next 1/2] wireless: Remove casts of void *
From: Bing Zhao @ 2011-06-14  8:46 UTC (permalink / raw)
  To: Joe Perches, netdev@vger.kernel.org
  Cc: Luis R. Rodriguez, Jouni Malinen, Vasanthakumar Thiagarajan,
	Senthil Balasubramanian, John W. Linville, Christian Lamparter,
	Stanislaw Gruszka, Wey-Yi Guy, Intel Linux Wireless,
	linux-wireless@vger.kernel.org, ath9k-devel@lists.ath9k.org,
	linux-kernel@vger.kernel.org
In-Reply-To: <337c22b774ff7f007b90b266b25c9a33ff555c48.1308024069.git.joe@perches.com>

> - pt = (T *)pv;
> + pt = pv;
> 
> Signed-off-by: Joe Perches joe@perches.com
...
> drivers/net/wireless/mwifiex/11n.c             |    5 ++---
> drivers/net/wireless/mwifiex/cmdevt.c          |    3 +--
> drivers/net/wireless/mwifiex/join.c            |    2 +-
> drivers/net/wireless/mwifiex/scan.c            |    2 +-
> drivers/net/wireless/mwifiex/sta_cmd.c         |    4 ++--
> drivers/net/wireless/mwifiex/sta_cmdresp.c     |   12 ++++++------
> drivers/net/wireless/mwifiex/txrx.c            |    2 +-
> drivers/net/wireless/p54/eeprom.c              |    4 ++--
> 22 files changed, 41 insertions(+), 47 deletions(-)

For mwifiex part, Acked-by: Bing Zhao bzhao@marvell.com

Thanks,
Bing

^ permalink raw reply

* Re: [PATCH] net/usb: Add Samsung Kalmia driver for Samsung GT-B3730
From: Oliver Neukum @ 2011-06-14  8:49 UTC (permalink / raw)
  To: Marius B. Kotsbak
  Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, Marius B. Kotsbak
In-Reply-To: <1307829318-18246-1-git-send-email-marius-iy5w9mehe2BBDgjK7y7TUQ@public.gmane.org>

Am Samstag, 11. Juni 2011, 23:55:18 schrieb Marius B. Kotsbak:

Hi,

thanks for writing a new driver. My comments are included in the quote.

	Regards
		Oliver

> +static int
> +kalmia_init_and_get_ethernet_addr(struct usbnet *dev, u8 *ethernet_addr)
> +{
> +	char init_msg_1[] =
> +		{ 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
> +		0x00, 0x00 };
> +	char init_msg_2[] =
> +		{ 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xf4,
> +		0x00, 0x00 };
> +	char receive_buf[28];

You are doing DMA on the stack. This will fail on some architectures.

> +	int status;
> +
> +	status = kalmia_send_init_packet(dev, init_msg_1, sizeof(init_msg_1)
> +		/ sizeof(init_msg_1[0]), receive_buf, 24);
> +	if (status != 0)
> +		return status;
> +
> +	status = kalmia_send_init_packet(dev, init_msg_2, sizeof(init_msg_2)
> +		/ sizeof(init_msg_2[0]), receive_buf, 28);
> +	if (status != 0)
> +		return status;
> +
> +	memcpy(ethernet_addr, receive_buf + 10, ETH_ALEN);
> +
> +	return status;
> +}
> +
> +static int
> +kalmia_bind(struct usbnet *dev, struct usb_interface *intf)
> +{
> +	u8 status;
> +	u8 ethernet_addr[ETH_ALEN];
> +
> +	/* Don't bind to AT command interface */
> +	if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC)
> +		return -EINVAL;
> +
> +	dev->in = usb_rcvbulkpipe(dev->udev, 0x81 & USB_ENDPOINT_NUMBER_MASK);
> +	dev->out = usb_sndbulkpipe(dev->udev, 0x02 & USB_ENDPOINT_NUMBER_MASK);
> +	dev->status = NULL;
> +
> +	dev->net->hard_header_len += KALMIA_HEADER_LENGTH;
> +	dev->hard_mtu = 1400;
> +	dev->rx_urb_size = dev->hard_mtu * 10; // Found as optimal after testing
> +
> +	status = kalmia_init_and_get_ethernet_addr(dev, ethernet_addr);
> +
> +	if (status < 0) {
> +		usb_set_intfdata(intf, NULL);
> +		usb_driver_release_interface(driver_of(intf), intf);
> +		return status;

Why are you doing this? What is to be undone?

> +	}
> +
> +	memcpy(dev->net->dev_addr, ethernet_addr, ETH_ALEN);
> +	memcpy(dev->net->perm_addr, ethernet_addr, ETH_ALEN);
> +
> +	return status;
> +}
> +
> +static struct sk_buff *
> +kalmia_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
> +{
> +	struct sk_buff *skb2 = NULL;
> +	u16 content_len;
> +	unsigned char *header_start;
> +	unsigned char ether_type_1, ether_type_2;
> +	u8 remainder, padlen = 0;
> +
> +	if (!skb_cloned(skb)) {
> +		int headroom = skb_headroom(skb);
> +		int tailroom = skb_tailroom(skb);
> +
> +		if ((tailroom >= KALMIA_ALIGN_SIZE) && (headroom
> +			>= KALMIA_HEADER_LENGTH))
> +			goto done;
> +
> +		if ((headroom + tailroom) > (KALMIA_HEADER_LENGTH
> +			+ KALMIA_ALIGN_SIZE)) {
> +			skb->data = memmove(skb->head + KALMIA_HEADER_LENGTH,
> +				skb->data, skb->len);
> +			skb_set_tail_pointer(skb, skb->len);
> +			goto done;
> +		}
> +	}
> +
> +	skb2 = skb_copy_expand(skb, KALMIA_HEADER_LENGTH,
> +		KALMIA_ALIGN_SIZE, flags);
> +	if (!skb2)
> +		return NULL;
> +
> +	dev_kfree_skb_any(skb);
> +	skb = skb2;
> +
> +	done: header_start = skb_push(skb, KALMIA_HEADER_LENGTH);

coding style

> +	ether_type_1 = header_start[KALMIA_HEADER_LENGTH + 12];
> +	ether_type_2 = header_start[KALMIA_HEADER_LENGTH + 13];
> +
> +	netdev_dbg(dev->net, "Sending etherType: %02x%02x", ether_type_1,
> +		ether_type_2);
> +
> +	/* According to empiric data for data packages */
> +	header_start[0] = 0x57;
> +	header_start[1] = 0x44;
> +	content_len = skb->len - KALMIA_HEADER_LENGTH;
> +	header_start[2] = (content_len & 0xff); /* low byte */
> +	header_start[3] = (content_len >> 8); /* high byte */

Please use an endianness macro

> +	header_start[4] = ether_type_1;
> +	header_start[5] = ether_type_2;
> +
> +	/* Align to 4 bytes by padding with zeros */
> +	remainder = skb->len % KALMIA_ALIGN_SIZE;
> +	if (remainder > 0) {
> +		padlen = KALMIA_ALIGN_SIZE - remainder;
> +		memset(skb_put(skb, padlen), 0, padlen);
> +	}
> +
> +	netdev_dbg(
> +		dev->net,
> +		"Sending package with length %i and padding %i. Header: %02x:%02x:%02x:%02x:%02x:%02x.",
> +		content_len, padlen, header_start[0], header_start[1],
> +		header_start[2], header_start[3], header_start[4],
> +		header_start[5]);
> +
> +	return skb;
> +}
> +
> +static int
> +kalmia_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
> +{
> +	/*
> +	 * Our task here is to strip off framing, leaving skb with one
> +	 * data frame for the usbnet framework code to process.
> +	 */
> +	const u8 HEADER_END_OF_USB_PACKET[] =
> +		{ 0x57, 0x5a, 0x00, 0x00, 0x08, 0x00 };
> +	const u8 EXPECTED_UNKNOWN_HEADER_1[] =
> +		{ 0x57, 0x43, 0x1e, 0x00, 0x15, 0x02 };
> +	const u8 EXPECTED_UNKNOWN_HEADER_2[] =
> +		{ 0x57, 0x50, 0x0e, 0x00, 0x00, 0x00 };

What does the compiler do to this declaration?

> +	u8 i = 0;

Why not int?

> +
> +	/* incomplete header? */
> +	if (skb->len < KALMIA_HEADER_LENGTH)
> +		return 0;
> +
> +	do {
> +		struct sk_buff *skb2 = NULL;
> +		u8 *header_start;
> +		u16 usb_packet_length, ether_packet_length;
> +		int is_last;
> +
> +		header_start = skb->data;
> +
> +		if (unlikely(header_start[0] != 0x57 || header_start[1] != 0x44)) {
> +			if (!memcmp(header_start, EXPECTED_UNKNOWN_HEADER_1,
> +				sizeof(EXPECTED_UNKNOWN_HEADER_1)) || !memcmp(
> +				header_start, EXPECTED_UNKNOWN_HEADER_2,
> +				sizeof(EXPECTED_UNKNOWN_HEADER_2))) {
> +				netdev_dbg(
> +					dev->net,
> +					"Received expected unknown frame header: %02x:%02x:%02x:%02x:%02x:%02x. Package length: %i\n",
> +					header_start[0], header_start[1],
> +					header_start[2], header_start[3],
> +					header_start[4], header_start[5],
> +					skb->len - KALMIA_HEADER_LENGTH);
> +			}
> +			else {
> +				netdev_err(
> +					dev->net,
> +					"Received unknown frame header: %02x:%02x:%02x:%02x:%02x:%02x. Package length: %i\n",
> +					header_start[0], header_start[1],
> +					header_start[2], header_start[3],
> +					header_start[4], header_start[5],
> +					skb->len - KALMIA_HEADER_LENGTH);
> +				return 0;
> +			}
> +		}
> +		else
> +			netdev_dbg(
> +				dev->net,
> +				"Received header: %02x:%02x:%02x:%02x:%02x:%02x. Package length: %i\n",
> +				header_start[0], header_start[1], header_start[2],
> +				header_start[3], header_start[4], header_start[5],
> +				skb->len - KALMIA_HEADER_LENGTH);
> +
> +		/* subtract start header and end header */
> +		usb_packet_length = skb->len - (2 * KALMIA_HEADER_LENGTH);
> +		ether_packet_length = header_start[2] + (header_start[3] << 8);

Please use an endianness macro

> +		skb_pull(skb, KALMIA_HEADER_LENGTH);
> +
> +		/* Some small packets misses end marker */
> +		if (usb_packet_length < ether_packet_length) {
> +			ether_packet_length = usb_packet_length
> +				+ KALMIA_HEADER_LENGTH;
> +			is_last = true;
> +		}
> +		else {
> +			netdev_dbg(dev->net, "Correct package length #%i", i
> +				+ 1);
> +
> +			is_last = (memcmp(skb->data + ether_packet_length,
> +				HEADER_END_OF_USB_PACKET,
> +				sizeof(HEADER_END_OF_USB_PACKET)) == 0);
> +			if (!is_last) {
> +				header_start = skb->data + ether_packet_length;
> +				netdev_dbg(
> +					dev->net,
> +					"End header: %02x:%02x:%02x:%02x:%02x:%02x. Package length: %i\n",
> +					header_start[0], header_start[1],
> +					header_start[2], header_start[3],
> +					header_start[4], header_start[5],
> +					skb->len - KALMIA_HEADER_LENGTH);
> +			}
> +		}
> +
> +		if (is_last) {
> +			skb2 = skb;
> +		}
> +		else {
> +			skb2 = skb_clone(skb, GFP_ATOMIC);
> +			if (unlikely(!skb2))
> +				return 0;
> +		}
> +
> +		skb_trim(skb2, ether_packet_length);
> +
> +		if (is_last) {
> +			return 1;
> +		}
> +		else {
> +			usbnet_skb_return(dev, skb2);
> +			skb_pull(skb, ether_packet_length);
> +		}
> +
> +		i++;
> +	}
> +	while (skb->len);
> +
> +	return 1;
> +}
> +
> +static const struct driver_info kalmia_info = {
> +	.description = "Samsung Kalmia LTE USB dongle",
> +	.flags = FLAG_WWAN,
> +	.bind = kalmia_bind,
> +	.rx_fixup = kalmia_rx_fixup,
> +	.tx_fixup = kalmia_tx_fixup
> +};
> +
> +/*-------------------------------------------------------------------------*/
> +
> +static const struct usb_device_id products[] = {
> +	/* The unswitched USB ID, to get the module auto loaded: */
> +	{ USB_DEVICE(0x04e8, 0x689a) },

Why is this needed? Doesn't the switch trigger an autoload?

> +	/* The stick swithed into modem (by e.g. usb_modeswitch): */
> +	{ USB_DEVICE(0x04e8, 0x6889),
> +		.driver_info = (unsigned long) &kalmia_info, },
> +	{ /* EMPTY == end of list */} };
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH net-next 2/2] drivers/net: Remove casts of void *
From: Geert Uytterhoeven @ 2011-06-14  9:21 UTC (permalink / raw)
  To: Joe Perches
  Cc: netdev, Arnaldo Carvalho de Melo, Jay Cliburn, Chris Snook,
	Jie Yang, Sathya Perla, Subbu Seetharaman, Ajit Khaparde,
	Rasesh Mody, Debashis Dutt, Sjur Braendeland, Divy Le Ray,
	Breno Leitao, Amit Kumar Salecha, Ron Mercer, linux-driver,
	Anirban Chakraborty, Jon Mason, Solarflare linux maintainers,
	Steve Hodgson, Ben Hutchings, Daniele Venzano
In-Reply-To: <486a21b708a9dce0c1c0059a21a2f9b66dac9e3c.1308024069.git.joe@perches.com>

On Tue, Jun 14, 2011 at 06:02, Joe Perches <joe@perches.com> wrote:
> Unnecessary casts of void * clutter the code.

> --- a/drivers/net/a2065.c
> +++ b/drivers/net/a2065.c
> @@ -426,7 +426,7 @@ static irqreturn_t lance_interrupt (int irq, void *dev_id)
>        volatile struct lance_regs *ll;
>        int csr0;
>
> -       dev = (struct net_device *) dev_id;
> +       dev = dev_id;

I think it would look better if you merge this line with the line that
defines "dev".

>
>        lp = netdev_priv(dev);
>        ll = lp->ll;

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* Re: [PATCH] net/usb: Add Samsung Kalmia driver for Samsung GT-B3730
From: Marius Kotsbak @ 2011-06-14  9:32 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, Marius B. Kotsbak
In-Reply-To: <201106141049.39150.oneukum-l3A5Bk7waGM@public.gmane.org>

Den 14. juni 2011 10:49, skrev Oliver Neukum:
> Am Samstag, 11. Juni 2011, 23:55:18 schrieb Marius B. Kotsbak:
>
>> +static int
>> +kalmia_init_and_get_ethernet_addr(struct usbnet *dev, u8 *ethernet_addr)
>> +{
>> +	char init_msg_1[] =
>> +		{ 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
>> +		0x00, 0x00 };
>> +	char init_msg_2[] =
>> +		{ 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xf4,
>> +		0x00, 0x00 };
>> +	char receive_buf[28];
> You are doing DMA on the stack. This will fail on some architectures.
>

Okay, a bit strange that this API is available then. Which API functions 
should be used in this case?

>> +	int status;
>> +
>> +	status = kalmia_send_init_packet(dev, init_msg_1, sizeof(init_msg_1)
>> +		/ sizeof(init_msg_1[0]), receive_buf, 24);
>> +	if (status != 0)
>> +		return status;
>> +
>> +	status = kalmia_send_init_packet(dev, init_msg_2, sizeof(init_msg_2)
>> +		/ sizeof(init_msg_2[0]), receive_buf, 28);
>> +	if (status != 0)
>> +		return status;
>> +
>> +	memcpy(ethernet_addr, receive_buf + 10, ETH_ALEN);
>> +
>> +	return status;
>> +}
>> +
>> +static int
>> +kalmia_bind(struct usbnet *dev, struct usb_interface *intf)
>> +{
>> +	u8 status;
>> +	u8 ethernet_addr[ETH_ALEN];
>> +
>> +	/* Don't bind to AT command interface */
>> +	if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC)
>> +		return -EINVAL;
>> +
>> +	dev->in = usb_rcvbulkpipe(dev->udev, 0x81&  USB_ENDPOINT_NUMBER_MASK);
>> +	dev->out = usb_sndbulkpipe(dev->udev, 0x02&  USB_ENDPOINT_NUMBER_MASK);
>> +	dev->status = NULL;
>> +
>> +	dev->net->hard_header_len += KALMIA_HEADER_LENGTH;
>> +	dev->hard_mtu = 1400;
>> +	dev->rx_urb_size = dev->hard_mtu * 10; // Found as optimal after testing
>> +
>> +	status = kalmia_init_and_get_ethernet_addr(dev, ethernet_addr);
>> +
>> +	if (status<  0) {
>> +		usb_set_intfdata(intf, NULL);
>> +		usb_driver_release_interface(driver_of(intf), intf);
>> +		return status;
> Why are you doing this? What is to be undone?

You mean the 3 last lines? I just did the same as done in another 
similar usbnet based driver. Is it incorrect if the init fails?

>> +	}
>> +
>> +	memcpy(dev->net->dev_addr, ethernet_addr, ETH_ALEN);
>> +	memcpy(dev->net->perm_addr, ethernet_addr, ETH_ALEN);
>> +
>> +	return status;
>> +}
>> +
>> +static struct sk_buff *
>> +kalmia_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
>> +{
>> +	struct sk_buff *skb2 = NULL;
>> +	u16 content_len;
>> +	unsigned char *header_start;
>> +	unsigned char ether_type_1, ether_type_2;
>> +	u8 remainder, padlen = 0;
>> +
>> +	if (!skb_cloned(skb)) {
>> +		int headroom = skb_headroom(skb);
>> +		int tailroom = skb_tailroom(skb);
>> +
>> +		if ((tailroom>= KALMIA_ALIGN_SIZE)&&  (headroom
>> +			>= KALMIA_HEADER_LENGTH))
>> +			goto done;
>> +
>> +		if ((headroom + tailroom)>  (KALMIA_HEADER_LENGTH
>> +			+ KALMIA_ALIGN_SIZE)) {
>> +			skb->data = memmove(skb->head + KALMIA_HEADER_LENGTH,
>> +				skb->data, skb->len);
>> +			skb_set_tail_pointer(skb, skb->len);
>> +			goto done;
>> +		}
>> +	}
>> +
>> +	skb2 = skb_copy_expand(skb, KALMIA_HEADER_LENGTH,
>> +		KALMIA_ALIGN_SIZE, flags);
>> +	if (!skb2)
>> +		return NULL;
>> +
>> +	dev_kfree_skb_any(skb);
>> +	skb = skb2;
>> +
>> +	done: header_start = skb_push(skb, KALMIA_HEADER_LENGTH);
> coding style

The last line? I see.

>> +	ether_type_1 = header_start[KALMIA_HEADER_LENGTH + 12];
>> +	ether_type_2 = header_start[KALMIA_HEADER_LENGTH + 13];
>> +
>> +	netdev_dbg(dev->net, "Sending etherType: %02x%02x", ether_type_1,
>> +		ether_type_2);
>> +
>> +	/* According to empiric data for data packages */
>> +	header_start[0] = 0x57;
>> +	header_start[1] = 0x44;
>> +	content_len = skb->len - KALMIA_HEADER_LENGTH;
>> +	header_start[2] = (content_len&  0xff); /* low byte */
>> +	header_start[3] = (content_len>>  8); /* high byte */
> Please use an endianness macro

Wil fix. It will be very relevant to support other architectures for 
this driver, as I want to run it on a ARM based NAS as LTE router.

>> +	header_start[4] = ether_type_1;
>> +	header_start[5] = ether_type_2;
>> +
>> +	/* Align to 4 bytes by padding with zeros */
>> +	remainder = skb->len % KALMIA_ALIGN_SIZE;
>> +	if (remainder>  0) {
>> +		padlen = KALMIA_ALIGN_SIZE - remainder;
>> +		memset(skb_put(skb, padlen), 0, padlen);
>> +	}
>> +
>> +	netdev_dbg(
>> +		dev->net,
>> +		"Sending package with length %i and padding %i. Header: %02x:%02x:%02x:%02x:%02x:%02x.",
>> +		content_len, padlen, header_start[0], header_start[1],
>> +		header_start[2], header_start[3], header_start[4],
>> +		header_start[5]);
>> +
>> +	return skb;
>> +}
>> +
>> +static int
>> +kalmia_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
>> +{
>> +	/*
>> +	 * Our task here is to strip off framing, leaving skb with one
>> +	 * data frame for the usbnet framework code to process.
>> +	 */
>> +	const u8 HEADER_END_OF_USB_PACKET[] =
>> +		{ 0x57, 0x5a, 0x00, 0x00, 0x08, 0x00 };
>> +	const u8 EXPECTED_UNKNOWN_HEADER_1[] =
>> +		{ 0x57, 0x43, 0x1e, 0x00, 0x15, 0x02 };
>> +	const u8 EXPECTED_UNKNOWN_HEADER_2[] =
>> +		{ 0x57, 0x50, 0x0e, 0x00, 0x00, 0x00 };
> What does the compiler do to this declaration?

Not sure I understand what you mean here.

>> +	u8 i = 0;
> Why not int?

I can change that. Thought int was not to be used because it is of 
unknown size.
>> +
>> +	/* incomplete header? */
>> +	if (skb->len<  KALMIA_HEADER_LENGTH)
>> +		return 0;
>> +
>> +	do {
>> +		struct sk_buff *skb2 = NULL;
>> +		u8 *header_start;
>> +		u16 usb_packet_length, ether_packet_length;
>> +		int is_last;
>> +
>> +		header_start = skb->data;
>> +
>> +		if (unlikely(header_start[0] != 0x57 || header_start[1] != 0x44)) {
>> +			if (!memcmp(header_start, EXPECTED_UNKNOWN_HEADER_1,
>> +				sizeof(EXPECTED_UNKNOWN_HEADER_1)) || !memcmp(
>> +				header_start, EXPECTED_UNKNOWN_HEADER_2,
>> +				sizeof(EXPECTED_UNKNOWN_HEADER_2))) {
>> +				netdev_dbg(
>> +					dev->net,
>> +					"Received expected unknown frame header: %02x:%02x:%02x:%02x:%02x:%02x. Package length: %i\n",
>> +					header_start[0], header_start[1],
>> +					header_start[2], header_start[3],
>> +					header_start[4], header_start[5],
>> +					skb->len - KALMIA_HEADER_LENGTH);
>> +			}
>> +			else {
>> +				netdev_err(
>> +					dev->net,
>> +					"Received unknown frame header: %02x:%02x:%02x:%02x:%02x:%02x. Package length: %i\n",
>> +					header_start[0], header_start[1],
>> +					header_start[2], header_start[3],
>> +					header_start[4], header_start[5],
>> +					skb->len - KALMIA_HEADER_LENGTH);
>> +				return 0;
>> +			}
>> +		}
>> +		else
>> +			netdev_dbg(
>> +				dev->net,
>> +				"Received header: %02x:%02x:%02x:%02x:%02x:%02x. Package length: %i\n",
>> +				header_start[0], header_start[1], header_start[2],
>> +				header_start[3], header_start[4], header_start[5],
>> +				skb->len - KALMIA_HEADER_LENGTH);
>> +
>> +		/* subtract start header and end header */
>> +		usb_packet_length = skb->len - (2 * KALMIA_HEADER_LENGTH);
>> +		ether_packet_length = header_start[2] + (header_start[3]<<  8);
> Please use an endianness macro

Oki.
>> +		skb_pull(skb, KALMIA_HEADER_LENGTH);
>> +
>> +		/* Some small packets misses end marker */
>> +		if (usb_packet_length<  ether_packet_length) {
>> +			ether_packet_length = usb_packet_length
>> +				+ KALMIA_HEADER_LENGTH;
>> +			is_last = true;
>> +		}
>> +		else {
>> +			netdev_dbg(dev->net, "Correct package length #%i", i
>> +				+ 1);
>> +
>> +			is_last = (memcmp(skb->data + ether_packet_length,
>> +				HEADER_END_OF_USB_PACKET,
>> +				sizeof(HEADER_END_OF_USB_PACKET)) == 0);
>> +			if (!is_last) {
>> +				header_start = skb->data + ether_packet_length;
>> +				netdev_dbg(
>> +					dev->net,
>> +					"End header: %02x:%02x:%02x:%02x:%02x:%02x. Package length: %i\n",
>> +					header_start[0], header_start[1],
>> +					header_start[2], header_start[3],
>> +					header_start[4], header_start[5],
>> +					skb->len - KALMIA_HEADER_LENGTH);
>> +			}
>> +		}
>> +
>> +		if (is_last) {
>> +			skb2 = skb;
>> +		}
>> +		else {
>> +			skb2 = skb_clone(skb, GFP_ATOMIC);
>> +			if (unlikely(!skb2))
>> +				return 0;
>> +		}
>> +
>> +		skb_trim(skb2, ether_packet_length);
>> +
>> +		if (is_last) {
>> +			return 1;
>> +		}
>> +		else {
>> +			usbnet_skb_return(dev, skb2);
>> +			skb_pull(skb, ether_packet_length);
>> +		}
>> +
>> +		i++;
>> +	}
>> +	while (skb->len);
>> +
>> +	return 1;
>> +}
>> +
>> +static const struct driver_info kalmia_info = {
>> +	.description = "Samsung Kalmia LTE USB dongle",
>> +	.flags = FLAG_WWAN,
>> +	.bind = kalmia_bind,
>> +	.rx_fixup = kalmia_rx_fixup,
>> +	.tx_fixup = kalmia_tx_fixup
>> +};
>> +
>> +/*-------------------------------------------------------------------------*/
>> +
>> +static const struct usb_device_id products[] = {
>> +	/* The unswitched USB ID, to get the module auto loaded: */
>> +	{ USB_DEVICE(0x04e8, 0x689a) },
> Why is this needed? Doesn't the switch trigger an autoload?

Please see the comment from Dan Williams. Will test his proposal.

Anyway it should not do any damage for anyone (I think even the driver 
disk is available with this included). The module could in fact also do 
the switch into modem mode to avoid the dependency on usb_modeswitch.

--
Marius


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* RE: [PATCH] net/r8169: Update the new parser for the new firmware
From: hayeswang @ 2011-06-14  9:36 UTC (permalink / raw)
  To: 'Francois Romieu'; +Cc: netdev, linux-kernel
In-Reply-To: <20110613143241.GA1579@electric-eye.fr.zoreil.com>

 

> -----Original Message-----
> From: Francois Romieu [mailto:romieu@fr.zoreil.com] 
> Sent: Monday, June 13, 2011 10:33 PM
> To: Hayeswang
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] net/r8169: Update the new parser for the 
> new firmware
> 
> Hayes Wang <hayeswang@realtek.com> :
> > Update the parser for the new firmware which is embedded 
> some information.
> > The paser cannot be used for the old firmware. It is only 
> for the new type one.
> 
> > 
> > Signed-off-by: Hayes Wang <hayeswang@realtek.com>
> > ---
> >  drivers/net/r8169.c |   59 
> ++++++++++++++++++++++++++++----------------------
> >  1 files changed, 33 insertions(+), 26 deletions(-)
> > 
> > diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 
> > ef1ce2e..87b684f 100644
> > --- a/drivers/net/r8169.c
> > +++ b/drivers/net/r8169.c
> > @@ -36,11 +36,11 @@
> >  #define MODULENAME "r8169"
> >  #define PFX MODULENAME ": "
> >  
> > -#define FIRMWARE_8168D_1	"rtl_nic/rtl8168d-1.fw"
> > -#define FIRMWARE_8168D_2	"rtl_nic/rtl8168d-2.fw"
> > -#define FIRMWARE_8168E_1	"rtl_nic/rtl8168e-1.fw"
> > -#define FIRMWARE_8168E_2	"rtl_nic/rtl8168e-2.fw"
> > -#define FIRMWARE_8105E_1	"rtl_nic/rtl8105e-1.fw"
> > +#define FIRMWARE_8168D_1	"rtl_nic/rtl8168d-3.fw"
> > +#define FIRMWARE_8168D_2	"rtl_nic/rtl8168d-4.fw"
> > +#define FIRMWARE_8168E_1	"rtl_nic/rtl8168e-3.fw"
> > +#define FIRMWARE_8168E_2	"rtl_nic/rtl8168e-4.fw"
> > +#define FIRMWARE_8105E_1	"rtl_nic/rtl8105e-2.fw"
> 
> Why ?

I want to keep the old firmware used by the old paser. The old paser cannot use
the new firmware and the new paser cannot use the old firmware, so I separate
them.

> 
> I see it more as a calling convention to communicate with 
> userspace than as a place to funnel a partial version information.
> 
> >  #ifdef RTL8169_DEBUG
> >  #define assert(expr) \
> > @@ -594,6 +594,13 @@ struct ring_info {
> >  	u8		__pad[sizeof(void *) - sizeof(u32)];
> >  };
> >  
> > +struct fw_info {
> > +	char	version[32];
> > +	u32	fw_start;
> > +	u32	fw_len;
> > +	u8	chksum;
> 
> The chksum field is never used.

This field in the binary file makes sure the checksum is zero. Driver don't need
to access this address. But it needs in the binary file for checking.

> 
> [...]
> > @@ -1743,16 +1750,30 @@ static void rtl_writephy_batch(struct 
> > rtl8169_private *tp,  static void  rtl_phy_write_fw(struct 
> > rtl8169_private *tp, const struct firmware *fw)  {
> > -	__le32 *phytable = (__le32 *)fw->data;
> > +	__le32 *phytable;
> >  	struct net_device *dev = tp->dev;
> > -	size_t index, fw_size = fw->size / sizeof(*phytable);
> > +	struct fw_info *f_info;
> > +	size_t index, fw_size;
> 
> s/index/i/

Yes, I would replace it.

> 
> >  	u32 predata, count;
> > +	u8 checksum;
> > +
> > +	f_info = (struct fw_info *)fw->data;
> 
> It will not work very well on big-endian computers. start and 
> len should both use le32_to_cpu.
> 

I would fix these. Thanks.

> >  
> > -	if (fw->size % sizeof(*phytable)) {
> > -		netif_err(tp, probe, dev, "odd sized firmware 
> %zd\n", fw->size);
> > +	if (checksum != 0) {
> > +		netif_err(tp, probe, dev, "none zero 
> checksum(%u)\n", checksum);
> >  		return;
> >  	}
> 
> Nit: "checksum" is not used beyond this point. It should be 
> possible to put a few things in distinct functions to save 
> some local variables.
> 

I would separate this into another function.

> > +	netif_info(tp, probe, dev, "firmware: %s\n", f_info->version);
> > +
> > +	phytable = (__le32 *)(fw->data + f_info->fw_start);
> > +	fw_size = f_info->fw_len;
> > +
> >  	for (index = 0; index < fw_size; index++) {
> 
> It's a bit paranoid but I would feel safer if f_info->fw_len 
> was compared to fw->size beforehand.
> 

You are right. I would do it.

> [...]
> > @@ -1892,14 +1913,6 @@ static void 
> rtl_apply_firmware(struct rtl8169_private *tp)
> >  		rtl_phy_write_fw(tp, fw);
> >  }
> >  
> > -static void rtl_apply_firmware_cond(struct rtl8169_private *tp, u8 
> > reg, u16 val) -{
> > -	if (rtl_readphy(tp, reg) != val)
> > -		netif_warn(tp, hw, tp->dev, "chipset not ready 
> for firmware\n");
> > -	else
> > -		rtl_apply_firmware(tp);
> > -}
> > -
> >  static void rtl8169s_hw_phy_config(struct rtl8169_private *tp)  {
> >  	static const struct phy_reg phy_reg_init[] = { @@ 
> -2334,10 +2347,7 
> > @@ static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp)
> >  	rtl_w1w0_phy(tp, 0x02, 0x0100, 0x0600);
> >  	rtl_w1w0_phy(tp, 0x03, 0x0000, 0xe000);
> >  
> > -	rtl_writephy(tp, 0x1f, 0x0005);
> > -	rtl_writephy(tp, 0x05, 0x001b);
> > -
> > -	rtl_apply_firmware_cond(tp, MII_EXPANSION, 0xbf00);
> > +	rtl_apply_firmware(tp);
> >  
> >  	rtl_writephy(tp, 0x1f, 0x0000);
> >  }
> > @@ -2437,10 +2447,7 @@ static void 
> rtl8168d_2_hw_phy_config(struct rtl8169_private *tp)
> >  	rtl_writephy(tp, 0x1f, 0x0002);
> >  	rtl_patchphy(tp, 0x0f, 0x0017);
> >  
> > -	rtl_writephy(tp, 0x1f, 0x0005);
> > -	rtl_writephy(tp, 0x05, 0x001b);
> > -
> > -	rtl_apply_firmware_cond(tp, MII_EXPANSION, 0xb300);
> > +	rtl_apply_firmware(tp);
> 
> Actually both the format and the content of the firmware are 
> changed by the patch.
> 
> Imho the new firmware format could include some specific 
> string so that the driver can identify the new firmware 
> format and fallback to the old format otherwise. Any fixed 
> magic prefix would be enough as the new format mandates the 
> version information.
> 
> This way Linus's test machine won't risk of breaking 
> (again...) if he builds a new kernel without updating the 
> firmware at the same time.
> 

I plan to let the old paser loads the old firmware and the new paser loads the
new firmware. If you build the new kernel without updating the firmware, you
just load no firmware because the new firmware doesn't exist. However, it is
more dangerous for the old paser to load the new firmware. That is why I create
the new ones, not replace the existing files.

 
Best Regards,
Hayes

^ permalink raw reply

* Re: [PATCH] net/usb: Add Samsung Kalmia driver for Samsung GT-B3730
From: Oliver Neukum @ 2011-06-14  9:46 UTC (permalink / raw)
  To: Marius Kotsbak
  Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, Marius B. Kotsbak
In-Reply-To: <4DF72A90.1070702-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Am Dienstag, 14. Juni 2011, 11:32:00 schrieb Marius Kotsbak:
> Den 14. juni 2011 10:49, skrev Oliver Neukum:
> > Am Samstag, 11. Juni 2011, 23:55:18 schrieb Marius B. Kotsbak:
> >
> >> +static int
> >> +kalmia_init_and_get_ethernet_addr(struct usbnet *dev, u8 *ethernet_addr)
> >> +{
> >> +	char init_msg_1[] =
> >> +		{ 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
> >> +		0x00, 0x00 };
> >> +	char init_msg_2[] =
> >> +		{ 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xf4,
> >> +		0x00, 0x00 };
> >> +	char receive_buf[28];
> > You are doing DMA on the stack. This will fail on some architectures.
> >
> 
> Okay, a bit strange that this API is available then. Which API functions 
> should be used in this case?

The API is correct. You just need to copy the init strings into buffers
allocated with kmalloc.

> >> +	if (status<  0) {
> >> +		usb_set_intfdata(intf, NULL);
> >> +		usb_driver_release_interface(driver_of(intf), intf);
> >> +		return status;
> > Why are you doing this? What is to be undone?
> 
> You mean the 3 last lines? I just did the same as done in another 
> similar usbnet based driver. Is it incorrect if the init fails?

Yes, the last three lines. If all drivers do that this is an opportunity to
share common code in usbnet. I'll look at it. 

> >> +static int
> >> +kalmia_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
> >> +{
> >> +	/*
> >> +	 * Our task here is to strip off framing, leaving skb with one
> >> +	 * data frame for the usbnet framework code to process.
> >> +	 */
> >> +	const u8 HEADER_END_OF_USB_PACKET[] =
> >> +		{ 0x57, 0x5a, 0x00, 0x00, 0x08, 0x00 };
> >> +	const u8 EXPECTED_UNKNOWN_HEADER_1[] =
> >> +		{ 0x57, 0x43, 0x1e, 0x00, 0x15, 0x02 };
> >> +	const u8 EXPECTED_UNKNOWN_HEADER_2[] =
> >> +		{ 0x57, 0x50, 0x0e, 0x00, 0x00, 0x00 };
> > What does the compiler do to this declaration?
> 
> Not sure I understand what you mean here.

Will the compiler put those strings into the image or build them on
the stack each time the function is called? Shouldn't they be static?

> >> +	u8 i = 0;
> > Why not int?
> 
> I can change that. Thought int was not to be used because it is of 
> unknown size.

Well, then are you sure i will never be larger than 255?

> Anyway it should not do any damage for anyone (I think even the driver 
> disk is available with this included). The module could in fact also do 
> the switch into modem mode to avoid the dependency on usb_modeswitch.

Please don't do that. It has been decided to put such things into usb_modeswitch
for now.

	Regards
		Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: Re: Re: [RFC PATCH 1/1] IPVS netns shutdown/startup dead-lock
From: Hans Schillstrom @ 2011-06-14  9:47 UTC (permalink / raw)
  To: Julian Anastasov
  Cc: Hans Schillstrom, horms, wensong, lvs-devel, netdev,
	netfilter-devel


Hello,
>
>On Tue, 14 Jun 2011, Hans Schillstrom wrote:
>
>> >On Mon, 13 Jun 2011, Hans Schillstrom wrote:
>> >
>> >> ip_vs_mutext is used by both netns shutdown code and startup
>> >> and both implicit uses sk_lock-AF_INET mutex.
>> >> 
>> >> cleanup CPU-1         startup CPU-2
>> >> ip_vs_dst_event()     ip_vs_genl_set_cmd()
>> >>  sk_lock-AF_INET     __ip_vs_mutex
>> >>                      sk_lock-AF_INET
>> >> __ip_vs_mutex
>> >> * DEAD LOCK *
>> >
>> >	So, sk_lock-AF_INET is locked before calling
>> >ip_vs_dst_event ? Do you have a backtrace for this case?
>> 
>> Yes plenty this one is with lockdep
>> 
>> Chain exists of:
>>   rtnl_mutex --> __ip_vs_mutex --> sk_lock-AF_INET
>> 
>>  Possible unsafe locking scenario:
>> 
>>        CPU0                    CPU1
>>        ----                    ----
>>   lock(sk_lock-AF_INET);
>>                                lock(__ip_vs_mutex);
>>                                lock(sk_lock-AF_INET);
>>   lock(rtnl_mutex);
>> 
>>  *** DEADLOCK ***
>> 
>> 3 locks held by ipvsadm/993:
>>  #0:  (genl_mutex){+.+.+.}, at: [<ffffffff812edc52>] genl_lock+0x17/0x19
>>  #1:  (__ip_vs_mutex){+.+.+.}, at: [<ffffffff81307dcb>] ip_vs_genl_set_cmd+0xe1/0x3a3
>>  #2:  (sk_lock-AF_INET){+.+.+.}, at: [<ffffffff8130ffc1>] start_sync_thread+0x3ec/0x5ff
>
>	I see
>
>> >> ip_vs_mutex per name-space seems to be a more future proof solution.
>> >
>> >	Global mutex protects some global lists such as
>> >virtual services. If your patch works, better way to fix this problem
>> >is to use some new mutex. May be we can move the IPVS_CMD_NEW_DAEMON,
>> >IPVS_CMD_DEL_DAEMON and IP_VS_SO_GET_DAEMON code before the
>> >__ip_vs_mutex locking. This mutex should be used for start_sync_thread,
>> >stop_sync_thread, ip_vs_genl_dump_daemons and IP_VS_SO_GET_DAEMON.
>> >For example, ip_vs_sync_mutex.
>> 
>> I think we should avoid global mutexes as a rule of tumb, 
>> because it's realy hard to keep track of all possible cases 
>> that can occur when multiple netns is alive and/or goes up and down.
>> 
>> There might be more suprises while a netns exits (in terms of locks)...
>> my gut feeling is, avoid global locks as long as possible.
>
>	There should not be a problem between two netns when
>using global mutexes. 

as long as the locking occurs in the same order :-)

>And there are no many places in IPVS
>where other modules are accessed.
>
>> >	Note that __ip_vs_sync_cleanup is missing a
>> >__ip_vs_mutex lock. We have to use the new mutex there.
>> 
>> OK
>> 
>> >
>> >> Which one should be used ?
>> >
>> >	For now __ip_vs_mutex should be global ...
>> 
>> I do agree, but in the long term I vote for mutex per netns.
>
>	It will not help because the problem does not happen
>between two netspaces but between ipvs and other modules.
>The same problem would happen even if __ip_vs_mutex was
>pernet mutex. 

Actually it's between userspaces that uses different netns
i.e. when starting a thread and exit a container (with different namespaces)
This bug would not have occured if a per netns mutex had been used.

>So, lets try with new mutex.

OK, I missed the reading of thread status, i.e. a sync_mutex is needed

There is no need for a lock(mutex) in ip_vs_sync_net_cleanup() before stoping threads,
because when it's called no user processes exits in that namespace.

Regards
Hans Schillstrom






^ permalink raw reply

* Re: [PATCH] linux-firmware: Add a new bnx2x FW 7.0.20.0
From: David Woodhouse @ 2011-06-14  9:48 UTC (permalink / raw)
  To: Vlad Zolotarov
  Cc: netdev@vger.kernel.org, Eilon Greenstein, Dmitry Kravkov,
	Yaniv Rosner
In-Reply-To: <201106141241.40764.vladz@broadcom.com>

On Tue, 2011-06-14 at 12:41 +0300, Vlad Zolotarov wrote:
> 
>  bnx2x/bnx2x-e1-7.0.20.0.fw.ihex  |10075 +++++++++++++++++++++
>  bnx2x/bnx2x-e1h-7.0.20.0.fw.ihex |10538 ++++++++++++++++++++++
>  bnx2x/bnx2x-e2-7.0.20.0.fw.ihex  |18190 ++++++++++++++++++++++++++++++++++++++

You haven't tested this, have you?

Add the binary file, not an ihex version.

-- 
dwmw2


^ permalink raw reply

* Re: [PATCH] linux-firmware: Add a new bnx2x FW 7.0.20.0
From: Vlad Zolotarov @ 2011-06-14  9:57 UTC (permalink / raw)
  To: David Woodhouse
  Cc: netdev@vger.kernel.org, Eilon Greenstein, Dmitry Kravkov,
	Yaniv Rosner
In-Reply-To: <1308044887.3450.4.camel@i7.infradead.org>

On Tuesday 14 June 2011 12:48:06 David Woodhouse wrote:
> On Tue, 2011-06-14 at 12:41 +0300, Vlad Zolotarov wrote:
> > 
> >  bnx2x/bnx2x-e1-7.0.20.0.fw.ihex  |10075 +++++++++++++++++++++
> >  bnx2x/bnx2x-e1h-7.0.20.0.fw.ihex |10538 ++++++++++++++++++++++
> >  bnx2x/bnx2x-e2-7.0.20.0.fw.ihex  |18190 ++++++++++++++++++++++++++++++++++++++
> 
> You haven't tested this, have you?

What do u mean? I do have put the ihex files under the net-next kernel tree at the regular location plus I updated the the kernel's firmware/WHENCE and firmware/Makefile files and of course I ran a functionality tests for the driver after all patches and with the new firmware.

If u meant the different sort of testing, pls., clarify.

> 
> Add the binary file, not an ihex version.

I'll resend the binary files. 

thanks,
vlad

> 
> 


^ permalink raw reply

* Re: [PATCH] linux-firmware: Add a new bnx2x FW 7.0.20.0
From: David Woodhouse @ 2011-06-14 10:04 UTC (permalink / raw)
  To: Vlad Zolotarov
  Cc: netdev@vger.kernel.org, Eilon Greenstein, Dmitry Kravkov,
	Yaniv Rosner
In-Reply-To: <201106141257.40621.vladz@broadcom.com>

On Tue, 2011-06-14 at 12:57 +0300, Vlad Zolotarov wrote:
> 
> What do u mean? I do have put the ihex files under the net-next kernel
> tree at the regular location plus I updated the the kernel's
> firmware/WHENCE and firmware/Makefile files and of course I ran a
> functionality tests for the driver after all patches and with the new
> firmware.

Ah, there lies your problem.

Never put new firmware into the kernel source tree. It doesn't belong
there.

In the linux-firmware tree we store the *binary* files, which go
directly into /lib/firmware as-is.

-- 
dwmw2


^ permalink raw reply

* Re: [PATCH] linux-firmware: Add a new bnx2x FW 7.0.20.0
From: Vlad Zolotarov @ 2011-06-14 10:10 UTC (permalink / raw)
  To: David Woodhouse
  Cc: netdev@vger.kernel.org, Eilon Greenstein, Dmitry Kravkov,
	Yaniv Rosner
In-Reply-To: <1308045859.3450.6.camel@i7.infradead.org>

On Tuesday 14 June 2011 13:04:18 David Woodhouse wrote:
> On Tue, 2011-06-14 at 12:57 +0300, Vlad Zolotarov wrote:
> > 
> > What do u mean? I do have put the ihex files under the net-next kernel
> > tree at the regular location plus I updated the the kernel's
> > firmware/WHENCE and firmware/Makefile files and of course I ran a
> > functionality tests for the driver after all patches and with the new
> > firmware.
> 
> Ah, there lies your problem.
> 
> Never put new firmware into the kernel source tree. It doesn't belong
> there.
> 
> In the linux-firmware tree we store the *binary* files, which go
> directly into /lib/firmware as-is.

Aha... Correct me if I got u wrong: to test it I need to manually copy the new .fw files into the /lib/firmware directory, install the clean net-next kernel with the driver that supports this new FW and it should work. Is it what u meant?

thanks,
vlad

> 
> 


^ permalink raw reply

* Re: [PATCH] linux-firmware: Add a new bnx2x FW 7.0.20.0
From: David Woodhouse @ 2011-06-14 10:16 UTC (permalink / raw)
  To: Vlad Zolotarov
  Cc: netdev@vger.kernel.org, Eilon Greenstein, Dmitry Kravkov,
	Yaniv Rosner
In-Reply-To: <201106141310.16440.vladz@broadcom.com>

On Tue, 2011-06-14 at 13:10 +0300, Vlad Zolotarov wrote:
> 
> Aha... Correct me if I got u wrong: to test it I need to manually copy
> the new .fw files into the /lib/firmware directory, install the clean
> net-next kernel with the driver that supports this new FW and it
> should work. Is it what u meant?

Right. Imagine that you have checked out the linux-firmware.git
repository directly into /lib/firmware, and nothing else has been
written there.

-- 
dwmw2


^ permalink raw reply

* Re: [PATCH net-next 2/2] drivers/net: Remove casts of void *
From: Chris Snook @ 2011-06-14 10:34 UTC (permalink / raw)
  To: Joe Perches
  Cc: netdev, Arnaldo Carvalho de Melo, Jay Cliburn, Jie Yang,
	Sathya Perla, Subbu Seetharaman, Ajit Khaparde, Rasesh Mody,
	Debashis Dutt, Sjur Braendeland, Divy Le Ray, Breno Leitao,
	Amit Kumar Salecha, Ron Mercer, linux-driver, Anirban Chakraborty,
	Jon Mason, Solarflare linux maintainers, Steve Hodgson,
	Ben Hutchings, Daniele Venzano, David Dillow
In-Reply-To: <486a21b708a9dce0c1c0059a21a2f9b66dac9e3c.1308024069.git.joe@perches.com>

On Tue, Jun 14, 2011 at 12:02 AM, Joe Perches <joe@perches.com> wrote:

> diff --git a/drivers/net/atl1e/atl1e_main.c b/drivers/net/atl1e/atl1e_main.c
> index 86a9122..c3c5db1 100644
> --- a/drivers/net/atl1e/atl1e_main.c
> +++ b/drivers/net/atl1e/atl1e_main.c
> @@ -800,8 +800,7 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter)
>        /* Init TPD Ring */
>        tx_ring->dma = roundup(adapter->ring_dma, 8);
>        offset = tx_ring->dma - adapter->ring_dma;
> -       tx_ring->desc = (struct atl1e_tpd_desc *)
> -                       (adapter->ring_vir_addr + offset);
> +       tx_ring->desc = adapter->ring_vir_addr + offset;
>        size = sizeof(struct atl1e_tx_buffer) * (tx_ring->count);
>        tx_ring->tx_buffer = kzalloc(size, GFP_KERNEL);
>        if (tx_ring->tx_buffer == NULL) {
> @@ -827,7 +826,7 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter)
>
>        /* Init CMB dma address */
>        tx_ring->cmb_dma = adapter->ring_dma + offset;
> -       tx_ring->cmb     = (u32 *)(adapter->ring_vir_addr + offset);
> +       tx_ring->cmb = adapter->ring_vir_addr + offset;
>        offset += sizeof(u32);
>
>        for (i = 0; i < adapter->num_rx_queues; i++) {
> diff --git a/drivers/net/atlx/atl2.c b/drivers/net/atlx/atl2.c
> index 16249e9..24e1592 100644
> --- a/drivers/net/atlx/atl2.c
> +++ b/drivers/net/atlx/atl2.c
> @@ -311,8 +311,7 @@ static s32 atl2_setup_ring_resources(struct atl2_adapter *adapter)
>        adapter->txd_dma = adapter->ring_dma ;
>        offset = (adapter->txd_dma & 0x7) ? (8 - (adapter->txd_dma & 0x7)) : 0;
>        adapter->txd_dma += offset;
> -       adapter->txd_ring = (struct tx_pkt_header *) (adapter->ring_vir_addr +
> -               offset);
> +       adapter->txd_ring = adapter->ring_vir_addr + offset;
>
>        /* Init TXS Ring */
>        adapter->txs_dma = adapter->txd_dma + adapter->txd_ring_size;

atlx looks fine.

Acked-By: Chris Snook <chris.snook@gmail.com>

^ permalink raw reply


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