Commit a3f47b9c authored by David Kilroy's avatar David Kilroy Committed by John W. Linville

orinoco: use dev_err in early initialisation routines

This allows us to use determine_fw_capabilities,
orinoco_hw_read_card_setting and orinoco_hw_allocate_fid prior to
netdev registration.

Since dev_dbg only prints if DEBUG is defined (or dynamic debug is
enabled), move a couple of the more useful prints up to info.
Signed-off-by: default avatarDavid Kilroy <kilroyd@googlemail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 42a51b93
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* See copyright notice in main.c * See copyright notice in main.c
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/device.h>
#include <linux/if_arp.h> #include <linux/if_arp.h>
#include <linux/ieee80211.h> #include <linux/ieee80211.h>
#include <linux/wireless.h> #include <linux/wireless.h>
...@@ -56,10 +57,13 @@ static inline fwtype_t determine_firmware_type(struct comp_id *nic_id) ...@@ -56,10 +57,13 @@ static inline fwtype_t determine_firmware_type(struct comp_id *nic_id)
return FIRMWARE_TYPE_INTERSIL; return FIRMWARE_TYPE_INTERSIL;
} }
/* Set priv->firmware type, determine firmware properties */ /* Set priv->firmware type, determine firmware properties
* This function can be called before we have registerred with netdev,
* so all errors go out with dev_* rather than printk
*/
int determine_fw_capabilities(struct orinoco_private *priv) int determine_fw_capabilities(struct orinoco_private *priv)
{ {
struct net_device *dev = priv->ndev; struct device *dev = priv->dev;
hermes_t *hw = &priv->hw; hermes_t *hw = &priv->hw;
int err; int err;
struct comp_id nic_id, sta_id; struct comp_id nic_id, sta_id;
...@@ -69,8 +73,8 @@ int determine_fw_capabilities(struct orinoco_private *priv) ...@@ -69,8 +73,8 @@ int determine_fw_capabilities(struct orinoco_private *priv)
/* Get the hardware version */ /* Get the hardware version */
err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_NICID, &nic_id); err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_NICID, &nic_id);
if (err) { if (err) {
printk(KERN_ERR "%s: Cannot read hardware identity: error %d\n", dev_err(dev, "Cannot read hardware identity: error %d\n",
dev->name, err); err);
return err; return err;
} }
...@@ -78,17 +82,16 @@ int determine_fw_capabilities(struct orinoco_private *priv) ...@@ -78,17 +82,16 @@ int determine_fw_capabilities(struct orinoco_private *priv)
le16_to_cpus(&nic_id.variant); le16_to_cpus(&nic_id.variant);
le16_to_cpus(&nic_id.major); le16_to_cpus(&nic_id.major);
le16_to_cpus(&nic_id.minor); le16_to_cpus(&nic_id.minor);
printk(KERN_DEBUG "%s: Hardware identity %04x:%04x:%04x:%04x\n", dev_info(dev, "Hardware identity %04x:%04x:%04x:%04x\n",
dev->name, nic_id.id, nic_id.variant, nic_id.id, nic_id.variant, nic_id.major, nic_id.minor);
nic_id.major, nic_id.minor);
priv->firmware_type = determine_firmware_type(&nic_id); priv->firmware_type = determine_firmware_type(&nic_id);
/* Get the firmware version */ /* Get the firmware version */
err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_STAID, &sta_id); err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_STAID, &sta_id);
if (err) { if (err) {
printk(KERN_ERR "%s: Cannot read station identity: error %d\n", dev_err(dev, "Cannot read station identity: error %d\n",
dev->name, err); err);
return err; return err;
} }
...@@ -96,25 +99,21 @@ int determine_fw_capabilities(struct orinoco_private *priv) ...@@ -96,25 +99,21 @@ int determine_fw_capabilities(struct orinoco_private *priv)
le16_to_cpus(&sta_id.variant); le16_to_cpus(&sta_id.variant);
le16_to_cpus(&sta_id.major); le16_to_cpus(&sta_id.major);
le16_to_cpus(&sta_id.minor); le16_to_cpus(&sta_id.minor);
printk(KERN_DEBUG "%s: Station identity %04x:%04x:%04x:%04x\n", dev_info(dev, "Station identity %04x:%04x:%04x:%04x\n",
dev->name, sta_id.id, sta_id.variant, sta_id.id, sta_id.variant, sta_id.major, sta_id.minor);
sta_id.major, sta_id.minor);
switch (sta_id.id) { switch (sta_id.id) {
case 0x15: case 0x15:
printk(KERN_ERR "%s: Primary firmware is active\n", dev_err(dev, "Primary firmware is active\n");
dev->name);
return -ENODEV; return -ENODEV;
case 0x14b: case 0x14b:
printk(KERN_ERR "%s: Tertiary firmware is active\n", dev_err(dev, "Tertiary firmware is active\n");
dev->name);
return -ENODEV; return -ENODEV;
case 0x1f: /* Intersil, Agere, Symbol Spectrum24 */ case 0x1f: /* Intersil, Agere, Symbol Spectrum24 */
case 0x21: /* Symbol Spectrum24 Trilogy */ case 0x21: /* Symbol Spectrum24 Trilogy */
break; break;
default: default:
printk(KERN_NOTICE "%s: Unknown station ID, please report\n", dev_notice(dev, "Unknown station ID, please report\n");
dev->name);
break; break;
} }
...@@ -168,10 +167,8 @@ int determine_fw_capabilities(struct orinoco_private *priv) ...@@ -168,10 +167,8 @@ int determine_fw_capabilities(struct orinoco_private *priv)
HERMES_RID_SECONDARYVERSION_SYMBOL, HERMES_RID_SECONDARYVERSION_SYMBOL,
SYMBOL_MAX_VER_LEN, NULL, &tmp); SYMBOL_MAX_VER_LEN, NULL, &tmp);
if (err) { if (err) {
printk(KERN_WARNING dev_warn(dev, "Error %d reading Symbol firmware info. "
"%s: Error %d reading Symbol firmware info. " "Wildly guessing capabilities...\n", err);
"Wildly guessing capabilities...\n",
dev->name, err);
firmver = 0; firmver = 0;
tmp[0] = '\0'; tmp[0] = '\0';
} else { } else {
...@@ -242,24 +239,24 @@ int determine_fw_capabilities(struct orinoco_private *priv) ...@@ -242,24 +239,24 @@ int determine_fw_capabilities(struct orinoco_private *priv)
if (firmver >= 0x000800) if (firmver >= 0x000800)
priv->ibss_port = 0; priv->ibss_port = 0;
else { else {
printk(KERN_NOTICE "%s: Intersil firmware earlier " dev_notice(dev, "Intersil firmware earlier than v0.8.x"
"than v0.8.x - several features not supported\n", " - several features not supported\n");
dev->name);
priv->ibss_port = 1; priv->ibss_port = 1;
} }
break; break;
} }
printk(KERN_DEBUG "%s: Firmware determined as %s\n", dev->name, dev_info(dev, "Firmware determined as %s\n", priv->fw_name);
priv->fw_name);
return 0; return 0;
} }
/* Read settings from EEPROM into our private structure. /* Read settings from EEPROM into our private structure.
* MAC address gets dropped into callers buffer */ * MAC address gets dropped into callers buffer
* Can be called before netdev registration.
*/
int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr)
{ {
struct net_device *dev = priv->ndev; struct device *dev = priv->dev;
struct hermes_idstring nickbuf; struct hermes_idstring nickbuf;
hermes_t *hw = &priv->hw; hermes_t *hw = &priv->hw;
int len; int len;
...@@ -270,20 +267,17 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) ...@@ -270,20 +267,17 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr)
err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR, err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR,
ETH_ALEN, NULL, dev_addr); ETH_ALEN, NULL, dev_addr);
if (err) { if (err) {
printk(KERN_WARNING "%s: failed to read MAC address!\n", dev_warn(dev, "Failed to read MAC address!\n");
dev->name);
goto out; goto out;
} }
printk(KERN_DEBUG "%s: MAC address %pM\n", dev_dbg(dev, "MAC address %pM\n", dev_addr);
dev->name, dev_addr);
/* Get the station name */ /* Get the station name */
err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME, err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME,
sizeof(nickbuf), &reclen, &nickbuf); sizeof(nickbuf), &reclen, &nickbuf);
if (err) { if (err) {
printk(KERN_ERR "%s: failed to read station name\n", dev_err(dev, "failed to read station name\n");
dev->name);
goto out; goto out;
} }
if (nickbuf.len) if (nickbuf.len)
...@@ -293,14 +287,13 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) ...@@ -293,14 +287,13 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr)
memcpy(priv->nick, &nickbuf.val, len); memcpy(priv->nick, &nickbuf.val, len);
priv->nick[len] = '\0'; priv->nick[len] = '\0';
printk(KERN_DEBUG "%s: Station name \"%s\"\n", dev->name, priv->nick); dev_dbg(dev, "Station name \"%s\"\n", priv->nick);
/* Get allowed channels */ /* Get allowed channels */
err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CHANNELLIST, err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CHANNELLIST,
&priv->channel_mask); &priv->channel_mask);
if (err) { if (err) {
printk(KERN_ERR "%s: failed to read channel list!\n", dev_err(dev, "Failed to read channel list!\n");
dev->name);
goto out; goto out;
} }
...@@ -314,8 +307,7 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) ...@@ -314,8 +307,7 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr)
err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD, err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD,
&priv->rts_thresh); &priv->rts_thresh);
if (err) { if (err) {
printk(KERN_ERR "%s: failed to read RTS threshold!\n", dev_err(dev, "Failed to read RTS threshold!\n");
dev->name);
goto out; goto out;
} }
...@@ -329,8 +321,7 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) ...@@ -329,8 +321,7 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr)
HERMES_RID_CNFFRAGMENTATIONTHRESHOLD, HERMES_RID_CNFFRAGMENTATIONTHRESHOLD,
&priv->frag_thresh); &priv->frag_thresh);
if (err) { if (err) {
printk(KERN_ERR "%s: failed to read fragmentation settings!\n", dev_err(dev, "Failed to read fragmentation settings!\n");
dev->name);
goto out; goto out;
} }
...@@ -342,16 +333,16 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) ...@@ -342,16 +333,16 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr)
HERMES_RID_CNFMAXSLEEPDURATION, HERMES_RID_CNFMAXSLEEPDURATION,
&priv->pm_period); &priv->pm_period);
if (err) { if (err) {
printk(KERN_ERR "%s: failed to read power management " dev_err(dev, "Failed to read power management "
"period!\n", dev->name); "period!\n");
goto out; goto out;
} }
err = hermes_read_wordrec(hw, USER_BAP, err = hermes_read_wordrec(hw, USER_BAP,
HERMES_RID_CNFPMHOLDOVERDURATION, HERMES_RID_CNFPMHOLDOVERDURATION,
&priv->pm_timeout); &priv->pm_timeout);
if (err) { if (err) {
printk(KERN_ERR "%s: failed to read power management " dev_err(dev, "Failed to read power management "
"timeout!\n", dev->name); "timeout!\n");
goto out; goto out;
} }
} }
...@@ -367,9 +358,10 @@ out: ...@@ -367,9 +358,10 @@ out:
return err; return err;
} }
/* Can be called before netdev registration */
int orinoco_hw_allocate_fid(struct orinoco_private *priv) int orinoco_hw_allocate_fid(struct orinoco_private *priv)
{ {
struct net_device *dev = priv->ndev; struct device *dev = priv->dev;
struct hermes *hw = &priv->hw; struct hermes *hw = &priv->hw;
int err; int err;
...@@ -379,9 +371,9 @@ int orinoco_hw_allocate_fid(struct orinoco_private *priv) ...@@ -379,9 +371,9 @@ int orinoco_hw_allocate_fid(struct orinoco_private *priv)
priv->nicbuf_size = TX_NICBUF_SIZE_BUG; priv->nicbuf_size = TX_NICBUF_SIZE_BUG;
err = hermes_allocate(hw, priv->nicbuf_size, &priv->txfid); err = hermes_allocate(hw, priv->nicbuf_size, &priv->txfid);
printk(KERN_WARNING "%s: firmware ALLOC bug detected " dev_warn(dev, "Firmware ALLOC bug detected "
"(old Symbol firmware?). Work around %s\n", "(old Symbol firmware?). Work around %s\n",
dev->name, err ? "failed!" : "ok."); err ? "failed!" : "ok.");
} }
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment