From: Pavel Machek <pavel@ucw.cz>

ipw2100 uses custom debug prints that are sometimes longer and always harder
to read than normal printk.  They also introduced some bugs where prefix is
printed twice.

Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/net/wireless/ipw2100.c |   91 ++++++++++++++++++++---------------------
 1 files changed, 45 insertions(+), 46 deletions(-)

diff -puN drivers/net/wireless/ipw2100.c~ipw2100-cleanup-debug-prints drivers/net/wireless/ipw2100.c
--- devel/drivers/net/wireless/ipw2100.c~ipw2100-cleanup-debug-prints	2005-07-09 01:23:59.000000000 -0700
+++ devel-akpm/drivers/net/wireless/ipw2100.c	2005-07-09 01:25:02.000000000 -0700
@@ -484,7 +484,7 @@ int ipw2100_get_ordinal(struct ipw2100_p
 	u32 total_length;
 
 	if (ordinals->table1_addr == 0) {
-		IPW_DEBUG_WARNING(DRV_NAME ": attempt to use fw ordinals "
+		printk(KERN_WARNING DRV_NAME ": attempt to use fw ordinals "
 		       "before they have been loaded.\n");
 		return -EINVAL;
 	}
@@ -493,8 +493,7 @@ int ipw2100_get_ordinal(struct ipw2100_p
 		if (*len < IPW_ORD_TAB_1_ENTRY_SIZE) {
 			*len = IPW_ORD_TAB_1_ENTRY_SIZE;
 
-			IPW_DEBUG_WARNING(DRV_NAME
-			       ": ordinal buffer length too small, need %d\n",
+			printk(KERN_WARNING DRV_NAME ": ordinal buffer length too small, need %d\n",
 			       IPW_ORD_TAB_1_ENTRY_SIZE);
 
 			return -EINVAL;
@@ -546,7 +545,7 @@ int ipw2100_get_ordinal(struct ipw2100_p
 		return 0;
 	}
 
-	IPW_DEBUG_WARNING(DRV_NAME ": ordinal %d neither in table 1 nor "
+	printk(KERN_WARNING DRV_NAME ": ordinal %d neither in table 1 nor "
 	       "in table 2\n", ord);
 
 	return -EINVAL;
@@ -761,7 +760,7 @@ static int ipw2100_hw_send_command(struc
 	}
 
 	if (priv->fatal_error) {
-		IPW_DEBUG_WARNING("%s: firmware fatal error\n",
+		printk(KERN_WARNING DRV_NAME ": %s: firmware fatal error\n",
 		       priv->net_dev->name);
 		return -EIO;
 	}
@@ -1001,7 +1000,7 @@ static int ipw2100_download_firmware(str
 	/* load microcode */
 	err = ipw2100_ucode_download(priv, &ipw2100_firmware);
 	if (err) {
-		IPW_DEBUG_ERROR("%s: Error loading microcode: %d\n",
+		printk(KERN_ERR DRV_NAME ": %s: Error loading microcode: %d\n",
 		       priv->net_dev->name, err);
 		goto fail;
 	}
@@ -1014,7 +1013,7 @@ static int ipw2100_download_firmware(str
 	/* s/w reset and clock stabilization (again!!!) */
 	err = sw_reset_and_clock(priv);
 	if (err) {
-		IPW_DEBUG_ERROR("%s: sw_reset_and_clock failed: %d\n",
+		printk(KERN_ERR DRV_NAME ": %s: sw_reset_and_clock failed: %d\n",
 		       priv->net_dev->name, err);
 		goto fail;
 	}
@@ -1208,7 +1207,7 @@ static int ipw2100_start_adapter(struct 
 	 * fw & dino ucode
 	 */
 	if (ipw2100_download_firmware(priv)) {
-		IPW_DEBUG_ERROR("%s: Failed to power on the adapter.\n",
+		printk(KERN_ERR DRV_NAME ": %s: Failed to power on the adapter.\n",
 		       priv->net_dev->name);
 		return -EIO;
 	}
@@ -1268,7 +1267,7 @@ static int ipw2100_start_adapter(struct 
 		     i ? "SUCCESS" : "FAILED");
 
 	if (!i) {
-		IPW_DEBUG_WARNING("%s: Firmware did not initialize.\n",
+		printk(KERN_WARNING DRV_NAME ": %s: Firmware did not initialize.\n",
 		       priv->net_dev->name);
 		return -EIO;
 	}
@@ -1464,7 +1463,7 @@ static int ipw2100_hw_stop_adapter(struc
 
 		err = ipw2100_hw_phy_off(priv);
 		if (err)
-			IPW_DEBUG_WARNING("Error disabling radio %d\n", err);
+			printk(KERN_WARNING DRV_NAME ": Error disabling radio %d\n", err);
 
 		/*
 		 * If in D0-standby mode going directly to D3 may cause a
@@ -1490,7 +1489,7 @@ static int ipw2100_hw_stop_adapter(struc
 
 		err = ipw2100_hw_send_command(priv, &cmd);
 		if (err)
-			IPW_DEBUG_WARNING(
+			printk(KERN_WARNING DRV_NAME ": "
 			       "%s: Power down command failed: Error %d\n",
 			       priv->net_dev->name, err);
 		else {
@@ -1531,7 +1530,7 @@ static int ipw2100_hw_stop_adapter(struc
 	}
 
 	if (i == 0)
-		IPW_DEBUG_WARNING(DRV_NAME
+		printk(KERN_WARNING DRV_NAME
 		       ": %s: Could now power down adapter.\n",
 		       priv->net_dev->name);
 
@@ -1571,13 +1570,13 @@ static int ipw2100_disable_adapter(struc
 
 	err = ipw2100_hw_send_command(priv, &cmd);
 	if (err) {
-		IPW_DEBUG_WARNING("exit - failed to send CARD_DISABLE command\n");
+		printk(KERN_WARNING DRV_NAME ": exit - failed to send CARD_DISABLE command\n");
 		goto fail_up;
 	}
 
 	err = ipw2100_wait_for_card_state(priv, IPW_HW_STATE_DISABLED);
 	if (err) {
-		IPW_DEBUG_WARNING("exit - card failed to change to DISABLED\n");
+		printk(KERN_WARNING DRV_NAME ": exit - card failed to change to DISABLED\n");
 		goto fail_up;
 	}
 
@@ -1687,7 +1686,7 @@ static int ipw2100_up(struct ipw2100_pri
 	    (priv->status & STATUS_RESET_PENDING)) {
 		/* Power cycle the card ... */
 		if (ipw2100_power_cycle_adapter(priv)) {
-			IPW_DEBUG_WARNING("%s: Could not cycle adapter.\n",
+			printk(KERN_WARNING DRV_NAME ": %s: Could not cycle adapter.\n",
 					  priv->net_dev->name);
 			rc = 1;
 			goto exit;
@@ -1697,7 +1696,7 @@ static int ipw2100_up(struct ipw2100_pri
 
 	/* Load the firmware, start the clocks, etc. */
 	if (ipw2100_start_adapter(priv)) {
-	       	IPW_DEBUG_ERROR("%s: Failed to start the firmware.\n",
+	       	printk(KERN_ERR DRV_NAME ": %s: Failed to start the firmware.\n",
 				priv->net_dev->name);
 		rc = 1;
 		goto exit;
@@ -1707,7 +1706,7 @@ static int ipw2100_up(struct ipw2100_pri
 
 	/* Determine capabilities of this particular HW configuration */
 	if (ipw2100_get_hw_features(priv)) {
-		IPW_DEBUG_ERROR("%s: Failed to determine HW features.\n",
+		printk(KERN_ERR DRV_NAME ": %s: Failed to determine HW features.\n",
 				priv->net_dev->name);
 		rc = 1;
 		goto exit;
@@ -1715,7 +1714,7 @@ static int ipw2100_up(struct ipw2100_pri
 
 	lock = LOCK_NONE;
 	if (ipw2100_set_ordinal(priv, IPW_ORD_PERS_DB_LOCK, &lock, &ord_len)) {
-		IPW_DEBUG_ERROR("%s: Failed to clear ordinal lock.\n",
+		printk(KERN_ERR DRV_NAME ": %s: Failed to clear ordinal lock.\n",
 				priv->net_dev->name);
 		rc = 1;
 		goto exit;
@@ -1741,7 +1740,7 @@ static int ipw2100_up(struct ipw2100_pri
 	/* Send all of the commands that must be sent prior to
 	 * HOST_COMPLETE */
 	if (ipw2100_adapter_setup(priv)) {
-		IPW_DEBUG_ERROR("%s: Failed to start the card.\n",
+		printk(KERN_ERR DRV_NAME ": %s: Failed to start the card.\n",
 				priv->net_dev->name);
 		rc = 1;
 		goto exit;
@@ -1750,7 +1749,7 @@ static int ipw2100_up(struct ipw2100_pri
 	if (!deferred) {
 		/* Enable the adapter - sends HOST_COMPLETE */
 		if (ipw2100_enable_adapter(priv)) {
-			IPW_DEBUG_ERROR(
+			printk(KERN_ERR DRV_NAME ": "
 				"%s: failed in call to enable adapter.\n",
 				priv->net_dev->name);
 			ipw2100_hw_stop_adapter(priv);
@@ -1808,7 +1807,7 @@ static void ipw2100_down(struct ipw2100_
 	spin_unlock_irqrestore(&priv->low_lock, flags);
 
 	if (ipw2100_hw_stop_adapter(priv))
-		IPW_DEBUG_ERROR("%s: Error stopping adapter.\n",
+		printk(KERN_ERR DRV_NAME ": %s: Error stopping adapter.\n",
 		       priv->net_dev->name);
 
 	/* Do not disable the interrupt until _after_ we disable
@@ -2415,7 +2414,7 @@ static inline void isr_rx(struct ipw2100
 
 	/* We need to allocate a new SKB and attach it to the RDB. */
 	if (unlikely(ipw2100_alloc_skb(priv, packet))) {
-		IPW_DEBUG_WARNING(
+		printk(KERN_WARNING DRV_NAME ": "
 			"%s: Unable to allocate SKB onto RBD ring - disabling "
 			"adapter.\n", priv->net_dev->name);
 		/* TODO: schedule adapter shutdown */
@@ -2677,7 +2676,7 @@ static inline int __ipw2100_tx_process(s
 		break;
 
 	default:
-		IPW_DEBUG_WARNING("%s: Bad fw_pend_list entry!\n",
+		printk(KERN_WARNING DRV_NAME ": %s: Bad fw_pend_list entry!\n",
 				   priv->net_dev->name);
 		return 0;
 	}
@@ -2691,7 +2690,7 @@ static inline int __ipw2100_tx_process(s
 	read_register(priv->net_dev, IPW_MEM_HOST_SHARED_TX_QUEUE_WRITE_INDEX,
 		      &w);
 	if (w != txq->next)
-		IPW_DEBUG_WARNING("%s: write index mismatch\n",
+		printk(KERN_WARNING DRV_NAME ": %s: write index mismatch\n",
 		       priv->net_dev->name);
 
         /*
@@ -2752,7 +2751,7 @@ static inline int __ipw2100_tx_process(s
 	switch (packet->type) {
 	case DATA:
 		if (txq->drv[txq->oldest].status.info.fields.txType != 0)
-			IPW_DEBUG_WARNING("%s: Queue mismatch.  "
+			printk(KERN_WARNING DRV_NAME ": %s: Queue mismatch.  "
 			       "Expecting DATA TBD but pulled "
 			       "something else: ids %d=%d.\n",
 			       priv->net_dev->name, txq->oldest, packet->index);
@@ -2799,7 +2798,7 @@ static inline int __ipw2100_tx_process(s
 
 	case COMMAND:
 		if (txq->drv[txq->oldest].status.info.fields.txType != 1)
-			IPW_DEBUG_WARNING("%s: Queue mismatch.  "
+			printk(KERN_WARNING DRV_NAME ": %s: Queue mismatch.  "
 			       "Expecting COMMAND TBD but pulled "
 			       "something else: ids %d=%d.\n",
 			       priv->net_dev->name, txq->oldest, packet->index);
@@ -3083,7 +3082,7 @@ static void ipw2100_irq_tasklet(struct i
 		      (unsigned long)inta & IPW_INTERRUPT_MASK);
 
 	if (inta & IPW2100_INTA_FATAL_ERROR) {
-		IPW_DEBUG_WARNING(DRV_NAME
+		printk(KERN_WARNING DRV_NAME
 				  ": Fatal interrupt. Scheduling firmware restart.\n");
 		priv->inta_other++;
 		write_register(
@@ -3103,7 +3102,7 @@ static void ipw2100_irq_tasklet(struct i
 	}
 
 	if (inta & IPW2100_INTA_PARITY_ERROR) {
-		IPW_DEBUG_ERROR("***** PARITY ERROR INTERRUPT !!!! \n");
+		printk(KERN_ERR DRV_NAME ": ***** PARITY ERROR INTERRUPT !!!! \n");
 		priv->inta_other++;
 		write_register(
 			dev, IPW_REG_INTA,
@@ -3221,7 +3220,7 @@ static irqreturn_t ipw2100_interrupt(int
 
 	if (inta == 0xFFFFFFFF) {
 		/* Hardware disappeared */
-		IPW_DEBUG_WARNING("IRQ INTA == 0xFFFFFFFF\n");
+		printk(KERN_WARNING DRV_NAME ": IRQ INTA == 0xFFFFFFFF\n");
 		goto none;
 	}
 
@@ -3306,7 +3305,7 @@ static int ipw2100_msg_allocate(struct i
 		IPW_COMMAND_POOL_SIZE * sizeof(struct ipw2100_tx_packet),
 		GFP_KERNEL);
 	if (!priv->msg_buffers) {
-		IPW_DEBUG_ERROR("%s: PCI alloc failed for msg "
+		printk(KERN_ERR DRV_NAME ": %s: PCI alloc failed for msg "
 		       "buffers.\n", priv->net_dev->name);
 		return -ENOMEM;
 	}
@@ -3317,7 +3316,7 @@ static int ipw2100_msg_allocate(struct i
 			sizeof(struct ipw2100_cmd_header),
 			&p);
 		if (!v) {
-			IPW_DEBUG_ERROR(
+			printk(KERN_ERR DRV_NAME ": "
 			       "%s: PCI alloc failed for msg "
 			       "buffers.\n",
 			       priv->net_dev->name);
@@ -3814,7 +3813,7 @@ int ipw2100_switch_mode(struct ipw2100_p
 
 	err = ipw2100_disable_adapter(priv);
 	if (err) {
-		IPW_DEBUG_ERROR("%s: Could not disable adapter %d\n",
+		printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n",
 		       priv->net_dev->name, err);
 		return err;
 	}
@@ -4255,7 +4254,7 @@ static int ipw2100_tx_allocate(struct ip
 		TX_PENDED_QUEUE_LENGTH * sizeof(struct ipw2100_tx_packet),
 		GFP_ATOMIC);
 	if (!priv->tx_buffers) {
-		IPW_DEBUG_ERROR("%s: alloc failed form tx buffers.\n",
+		printk(KERN_ERR DRV_NAME ": %s: alloc failed form tx buffers.\n",
 		       priv->net_dev->name);
 		bd_queue_free(priv, &priv->tx_queue);
 		return -ENOMEM;
@@ -4265,7 +4264,7 @@ static int ipw2100_tx_allocate(struct ip
 		v = pci_alloc_consistent(
 			priv->pci_dev, sizeof(struct ipw2100_data_header), &p);
 		if (!v) {
-			IPW_DEBUG_ERROR("%s: PCI alloc failed for tx "
+			printk(KERN_ERR DRV_NAME ": %s: PCI alloc failed for tx "
 			       "buffers.\n", priv->net_dev->name);
 			err = -ENOMEM;
 			break;
@@ -4576,7 +4575,7 @@ int ipw2100_set_port_type(struct ipw2100
 	if (!batch_mode) {
 		err = ipw2100_disable_adapter(priv);
 		if (err) {
-			IPW_DEBUG_ERROR("%s: Could not disable adapter %d\n",
+			printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n",
 			       priv->net_dev->name, err);
 			return err;
 		}
@@ -5195,7 +5194,7 @@ static int ipw2100_set_wep_flags(struct 
 	if (!batch_mode) {
 		err = ipw2100_disable_adapter(priv);
 		if (err) {
-			IPW_DEBUG_ERROR("%s: Could not disable adapter %d\n",
+			printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n",
 			       priv->net_dev->name, err);
 			return err;
 		}
@@ -5283,7 +5282,7 @@ static int ipw2100_set_key(struct ipw210
 		err = ipw2100_disable_adapter(priv);
 		/* FIXME: IPG: shouldn't this prink be in _disable_adapter()? */
 		if (err) {
-			IPW_DEBUG_ERROR("%s: Could not disable adapter %d\n",
+			printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n",
 			       priv->net_dev->name, err);
 			return err;
 		}
@@ -5319,7 +5318,7 @@ static int ipw2100_set_key_index(struct 
 	if (!batch_mode) {
 		err = ipw2100_disable_adapter(priv);
 		if (err) {
-			IPW_DEBUG_ERROR("%s: Could not disable adapter %d\n",
+			printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n",
 			       priv->net_dev->name, err);
 			return err;
 		}
@@ -5867,7 +5866,7 @@ static int ipw2100_wpa_set_param(struct 
 			break;
 
 		default:
-			IPW_DEBUG_ERROR("%s: Unknown WPA param: %d\n",
+			printk(KERN_ERR DRV_NAME ": %s: Unknown WPA param: %d\n",
 					    dev->name, name);
 			ret = -EOPNOTSUPP;
 	}
@@ -5890,7 +5889,7 @@ static int ipw2100_wpa_mlme(struct net_d
 			break;
 
 		default:
-			IPW_DEBUG_ERROR("%s: Unknown MLME request: %d\n",
+			printk(KERN_ERR DRV_NAME ": %s: Unknown MLME request: %d\n",
 					    dev->name, command);
 			ret = -EOPNOTSUPP;
 	}
@@ -6140,7 +6139,7 @@ static int ipw2100_wpa_supplicant(struct
 		break;
 
 	default:
-		IPW_DEBUG_ERROR("%s: Unknown WPA supplicant request: %d\n",
+		printk(KERN_ERR DRV_NAME ": %s: Unknown WPA supplicant request: %d\n",
 				dev->name, param->cmd);
 		ret = -EOPNOTSUPP;
 
@@ -8362,7 +8361,7 @@ static int ipw2100_mod_firmware_load(str
 		(struct ipw2100_fw_header *)fw->fw_entry->data;
 
 	if (IPW2100_FW_MAJOR(h->version) != IPW2100_FW_MAJOR_VERSION) {
-		IPW_DEBUG_WARNING("Firmware image not compatible "
+		printk(KERN_WARNING DRV_NAME ": Firmware image not compatible "
 		       "(detected version id of %u). "
 		       "See Documentation/networking/README.ipw2100\n",
 		       h->version);
@@ -8405,7 +8404,7 @@ int ipw2100_get_firmware(struct ipw2100_
 	rc = request_firmware(&fw->fw_entry, fw_name, &priv->pci_dev->dev);
 
 	if (rc < 0) {
-		IPW_DEBUG_ERROR(
+		printk(KERN_ERR DRV_NAME ": "
 		       "%s: Firmware '%s' not available or load failed.\n",
 		       priv->net_dev->name, fw_name);
 		return rc;
@@ -8487,7 +8486,7 @@ int ipw2100_fw_download(struct ipw2100_p
 		firmware_data_left -= 2;
 
 		if (len > 32) {
-			IPW_DEBUG_ERROR(
+			printk(KERN_ERR DRV_NAME ": "
 			       "Invalid firmware run-length of %d bytes\n",
 			       len);
 			return -EINVAL;
@@ -8597,7 +8596,7 @@ int ipw2100_ucode_download(struct ipw210
 	}
 
 	if (i == 10) {
-		IPW_DEBUG_ERROR("%s: Error initializing Symbol\n",
+		printk(KERN_ERR DRV_NAME ": %s: Error initializing Symbol\n",
 		       dev->name);
 		return -EIO;
 	}
@@ -8618,7 +8617,7 @@ int ipw2100_ucode_download(struct ipw210
 	}
 
 	if (i == 30) {
-		IPW_DEBUG_ERROR("%s: No response from Symbol - hw not alive\n",
+		printk(KERN_ERR DRV_NAME ": %s: No response from Symbol - hw not alive\n",
 		       dev->name);
 		printk_buf(IPW_DL_ERROR, (u8*)&response, sizeof(response));
 		return -EIO;
_