[PATCH] hostap: Use void *hw_priv instead of #ifdef in local data
Replace hardware model specific #ifdef's in struct local_info with void *hw_priv that is pointing to cs/pci/plx specific data structure. This removes unneeded #ifdef's and as such, is a step towards making it possible to share objects for hostap_hw.c and hostap_download.c with cs/pci/plx drivers without having to compile and link the same code separately for each one. Signed-off-by: Jouni Malinen <jkmaline@cc.hut.fi> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
This commit is contained in:
committed by
Jeff Garzik
parent
ea3f1865f3
commit
67e0e473fb
@@ -40,6 +40,14 @@ module_param(ignore_cis_vcc, int, 0444);
|
|||||||
MODULE_PARM_DESC(ignore_cis_vcc, "Ignore broken CIS VCC entry");
|
MODULE_PARM_DESC(ignore_cis_vcc, "Ignore broken CIS VCC entry");
|
||||||
|
|
||||||
|
|
||||||
|
/* struct local_info::hw_priv */
|
||||||
|
struct hostap_cs_priv {
|
||||||
|
dev_node_t node;
|
||||||
|
dev_link_t *link;
|
||||||
|
int sandisk_connectplus;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef PRISM2_IO_DEBUG
|
#ifdef PRISM2_IO_DEBUG
|
||||||
|
|
||||||
static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v)
|
static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v)
|
||||||
@@ -203,8 +211,9 @@ static int prism2_event(event_t event, int priority,
|
|||||||
|
|
||||||
static int prism2_pccard_card_present(local_info_t *local)
|
static int prism2_pccard_card_present(local_info_t *local)
|
||||||
{
|
{
|
||||||
if (local->link != NULL &&
|
struct hostap_cs_priv *hw_priv = local->hw_priv;
|
||||||
((local->link->state & (DEV_PRESENT | DEV_CONFIG)) ==
|
if (hw_priv->link != NULL &&
|
||||||
|
((hw_priv->link->state & (DEV_PRESENT | DEV_CONFIG)) ==
|
||||||
(DEV_PRESENT | DEV_CONFIG)))
|
(DEV_PRESENT | DEV_CONFIG)))
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -224,12 +233,14 @@ static void sandisk_set_iobase(local_info_t *local)
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
conf_reg_t reg;
|
conf_reg_t reg;
|
||||||
|
struct hostap_cs_priv *hw_priv = local->hw_priv;
|
||||||
|
|
||||||
reg.Function = 0;
|
reg.Function = 0;
|
||||||
reg.Action = CS_WRITE;
|
reg.Action = CS_WRITE;
|
||||||
reg.Offset = 0x10; /* 0x3f0 IO base 1 */
|
reg.Offset = 0x10; /* 0x3f0 IO base 1 */
|
||||||
reg.Value = local->link->io.BasePort1 & 0x00ff;
|
reg.Value = hw_priv->link->io.BasePort1 & 0x00ff;
|
||||||
res = pcmcia_access_configuration_register(local->link->handle, ®);
|
res = pcmcia_access_configuration_register(hw_priv->link->handle,
|
||||||
|
®);
|
||||||
if (res != CS_SUCCESS) {
|
if (res != CS_SUCCESS) {
|
||||||
printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -"
|
printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -"
|
||||||
" res=%d\n", res);
|
" res=%d\n", res);
|
||||||
@@ -239,8 +250,9 @@ static void sandisk_set_iobase(local_info_t *local)
|
|||||||
reg.Function = 0;
|
reg.Function = 0;
|
||||||
reg.Action = CS_WRITE;
|
reg.Action = CS_WRITE;
|
||||||
reg.Offset = 0x12; /* 0x3f2 IO base 2 */
|
reg.Offset = 0x12; /* 0x3f2 IO base 2 */
|
||||||
reg.Value = (local->link->io.BasePort1 & 0xff00) >> 8;
|
reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8;
|
||||||
res = pcmcia_access_configuration_register(local->link->handle, ®);
|
res = pcmcia_access_configuration_register(hw_priv->link->handle,
|
||||||
|
®);
|
||||||
if (res != CS_SUCCESS) {
|
if (res != CS_SUCCESS) {
|
||||||
printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -"
|
printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -"
|
||||||
" res=%d\n", res);
|
" res=%d\n", res);
|
||||||
@@ -272,8 +284,9 @@ static int sandisk_enable_wireless(struct net_device *dev)
|
|||||||
tuple_t tuple;
|
tuple_t tuple;
|
||||||
cisparse_t *parse = NULL;
|
cisparse_t *parse = NULL;
|
||||||
u_char buf[64];
|
u_char buf[64];
|
||||||
|
struct hostap_cs_priv *hw_priv = local->hw_priv;
|
||||||
|
|
||||||
if (local->link->io.NumPorts1 < 0x42) {
|
if (hw_priv->link->io.NumPorts1 < 0x42) {
|
||||||
/* Not enough ports to be SanDisk multi-function card */
|
/* Not enough ports to be SanDisk multi-function card */
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
goto done;
|
goto done;
|
||||||
@@ -290,9 +303,9 @@ static int sandisk_enable_wireless(struct net_device *dev)
|
|||||||
tuple.TupleData = buf;
|
tuple.TupleData = buf;
|
||||||
tuple.TupleDataMax = sizeof(buf);
|
tuple.TupleDataMax = sizeof(buf);
|
||||||
tuple.TupleOffset = 0;
|
tuple.TupleOffset = 0;
|
||||||
if (pcmcia_get_first_tuple(local->link->handle, &tuple) ||
|
if (pcmcia_get_first_tuple(hw_priv->link->handle, &tuple) ||
|
||||||
pcmcia_get_tuple_data(local->link->handle, &tuple) ||
|
pcmcia_get_tuple_data(hw_priv->link->handle, &tuple) ||
|
||||||
pcmcia_parse_tuple(local->link->handle, &tuple, parse) ||
|
pcmcia_parse_tuple(hw_priv->link->handle, &tuple, parse) ||
|
||||||
parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) {
|
parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) {
|
||||||
/* No SanDisk manfid found */
|
/* No SanDisk manfid found */
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
@@ -300,9 +313,9 @@ static int sandisk_enable_wireless(struct net_device *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
tuple.DesiredTuple = CISTPL_LONGLINK_MFC;
|
tuple.DesiredTuple = CISTPL_LONGLINK_MFC;
|
||||||
if (pcmcia_get_first_tuple(local->link->handle, &tuple) ||
|
if (pcmcia_get_first_tuple(hw_priv->link->handle, &tuple) ||
|
||||||
pcmcia_get_tuple_data(local->link->handle, &tuple) ||
|
pcmcia_get_tuple_data(hw_priv->link->handle, &tuple) ||
|
||||||
pcmcia_parse_tuple(local->link->handle, &tuple, parse) ||
|
pcmcia_parse_tuple(hw_priv->link->handle, &tuple, parse) ||
|
||||||
parse->longlink_mfc.nfn < 2) {
|
parse->longlink_mfc.nfn < 2) {
|
||||||
/* No multi-function links found */
|
/* No multi-function links found */
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
@@ -311,13 +324,14 @@ static int sandisk_enable_wireless(struct net_device *dev)
|
|||||||
|
|
||||||
printk(KERN_DEBUG "%s: Multi-function SanDisk ConnectPlus detected"
|
printk(KERN_DEBUG "%s: Multi-function SanDisk ConnectPlus detected"
|
||||||
" - using vendor-specific initialization\n", dev->name);
|
" - using vendor-specific initialization\n", dev->name);
|
||||||
local->sandisk_connectplus = 1;
|
hw_priv->sandisk_connectplus = 1;
|
||||||
|
|
||||||
reg.Function = 0;
|
reg.Function = 0;
|
||||||
reg.Action = CS_WRITE;
|
reg.Action = CS_WRITE;
|
||||||
reg.Offset = CISREG_COR;
|
reg.Offset = CISREG_COR;
|
||||||
reg.Value = COR_SOFT_RESET;
|
reg.Value = COR_SOFT_RESET;
|
||||||
res = pcmcia_access_configuration_register(local->link->handle, ®);
|
res = pcmcia_access_configuration_register(hw_priv->link->handle,
|
||||||
|
®);
|
||||||
if (res != CS_SUCCESS) {
|
if (res != CS_SUCCESS) {
|
||||||
printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
|
printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
|
||||||
dev->name, res);
|
dev->name, res);
|
||||||
@@ -333,7 +347,8 @@ static int sandisk_enable_wireless(struct net_device *dev)
|
|||||||
* will be enabled during the first cor_sreset call.
|
* will be enabled during the first cor_sreset call.
|
||||||
*/
|
*/
|
||||||
reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA;
|
reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA;
|
||||||
res = pcmcia_access_configuration_register(local->link->handle, ®);
|
res = pcmcia_access_configuration_register(hw_priv->link->handle,
|
||||||
|
®);
|
||||||
if (res != CS_SUCCESS) {
|
if (res != CS_SUCCESS) {
|
||||||
printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
|
printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
|
||||||
dev->name, res);
|
dev->name, res);
|
||||||
@@ -358,6 +373,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local)
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
conf_reg_t reg;
|
conf_reg_t reg;
|
||||||
|
struct hostap_cs_priv *hw_priv = local->hw_priv;
|
||||||
|
|
||||||
if (!prism2_pccard_card_present(local))
|
if (!prism2_pccard_card_present(local))
|
||||||
return;
|
return;
|
||||||
@@ -366,7 +382,8 @@ static void prism2_pccard_cor_sreset(local_info_t *local)
|
|||||||
reg.Action = CS_READ;
|
reg.Action = CS_READ;
|
||||||
reg.Offset = CISREG_COR;
|
reg.Offset = CISREG_COR;
|
||||||
reg.Value = 0;
|
reg.Value = 0;
|
||||||
res = pcmcia_access_configuration_register(local->link->handle, ®);
|
res = pcmcia_access_configuration_register(hw_priv->link->handle,
|
||||||
|
®);
|
||||||
if (res != CS_SUCCESS) {
|
if (res != CS_SUCCESS) {
|
||||||
printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n",
|
printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n",
|
||||||
res);
|
res);
|
||||||
@@ -377,28 +394,30 @@ static void prism2_pccard_cor_sreset(local_info_t *local)
|
|||||||
|
|
||||||
reg.Action = CS_WRITE;
|
reg.Action = CS_WRITE;
|
||||||
reg.Value |= COR_SOFT_RESET;
|
reg.Value |= COR_SOFT_RESET;
|
||||||
res = pcmcia_access_configuration_register(local->link->handle, ®);
|
res = pcmcia_access_configuration_register(hw_priv->link->handle,
|
||||||
|
®);
|
||||||
if (res != CS_SUCCESS) {
|
if (res != CS_SUCCESS) {
|
||||||
printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n",
|
printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n",
|
||||||
res);
|
res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mdelay(local->sandisk_connectplus ? 5 : 2);
|
mdelay(hw_priv->sandisk_connectplus ? 5 : 2);
|
||||||
|
|
||||||
reg.Value &= ~COR_SOFT_RESET;
|
reg.Value &= ~COR_SOFT_RESET;
|
||||||
if (local->sandisk_connectplus)
|
if (hw_priv->sandisk_connectplus)
|
||||||
reg.Value |= COR_IREQ_ENA;
|
reg.Value |= COR_IREQ_ENA;
|
||||||
res = pcmcia_access_configuration_register(local->link->handle, ®);
|
res = pcmcia_access_configuration_register(hw_priv->link->handle,
|
||||||
|
®);
|
||||||
if (res != CS_SUCCESS) {
|
if (res != CS_SUCCESS) {
|
||||||
printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n",
|
printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n",
|
||||||
res);
|
res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mdelay(local->sandisk_connectplus ? 5 : 2);
|
mdelay(hw_priv->sandisk_connectplus ? 5 : 2);
|
||||||
|
|
||||||
if (local->sandisk_connectplus)
|
if (hw_priv->sandisk_connectplus)
|
||||||
sandisk_set_iobase(local);
|
sandisk_set_iobase(local);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,11 +427,12 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
|
|||||||
int res;
|
int res;
|
||||||
conf_reg_t reg;
|
conf_reg_t reg;
|
||||||
int old_cor;
|
int old_cor;
|
||||||
|
struct hostap_cs_priv *hw_priv = local->hw_priv;
|
||||||
|
|
||||||
if (!prism2_pccard_card_present(local))
|
if (!prism2_pccard_card_present(local))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (local->sandisk_connectplus) {
|
if (hw_priv->sandisk_connectplus) {
|
||||||
sandisk_write_hcr(local, hcr);
|
sandisk_write_hcr(local, hcr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -421,7 +441,8 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
|
|||||||
reg.Action = CS_READ;
|
reg.Action = CS_READ;
|
||||||
reg.Offset = CISREG_COR;
|
reg.Offset = CISREG_COR;
|
||||||
reg.Value = 0;
|
reg.Value = 0;
|
||||||
res = pcmcia_access_configuration_register(local->link->handle, ®);
|
res = pcmcia_access_configuration_register(hw_priv->link->handle,
|
||||||
|
®);
|
||||||
if (res != CS_SUCCESS) {
|
if (res != CS_SUCCESS) {
|
||||||
printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 "
|
printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 "
|
||||||
"(%d)\n", res);
|
"(%d)\n", res);
|
||||||
@@ -433,7 +454,8 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
|
|||||||
|
|
||||||
reg.Action = CS_WRITE;
|
reg.Action = CS_WRITE;
|
||||||
reg.Value |= COR_SOFT_RESET;
|
reg.Value |= COR_SOFT_RESET;
|
||||||
res = pcmcia_access_configuration_register(local->link->handle, ®);
|
res = pcmcia_access_configuration_register(hw_priv->link->handle,
|
||||||
|
®);
|
||||||
if (res != CS_SUCCESS) {
|
if (res != CS_SUCCESS) {
|
||||||
printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 "
|
printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 "
|
||||||
"(%d)\n", res);
|
"(%d)\n", res);
|
||||||
@@ -446,7 +468,8 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
|
|||||||
reg.Action = CS_WRITE;
|
reg.Action = CS_WRITE;
|
||||||
reg.Value = hcr;
|
reg.Value = hcr;
|
||||||
reg.Offset = CISREG_CCSR;
|
reg.Offset = CISREG_CCSR;
|
||||||
res = pcmcia_access_configuration_register(local->link->handle, ®);
|
res = pcmcia_access_configuration_register(hw_priv->link->handle,
|
||||||
|
®);
|
||||||
if (res != CS_SUCCESS) {
|
if (res != CS_SUCCESS) {
|
||||||
printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 "
|
printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 "
|
||||||
"(%d)\n", res);
|
"(%d)\n", res);
|
||||||
@@ -457,7 +480,8 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
|
|||||||
reg.Action = CS_WRITE;
|
reg.Action = CS_WRITE;
|
||||||
reg.Offset = CISREG_COR;
|
reg.Offset = CISREG_COR;
|
||||||
reg.Value = old_cor & ~COR_SOFT_RESET;
|
reg.Value = old_cor & ~COR_SOFT_RESET;
|
||||||
res = pcmcia_access_configuration_register(local->link->handle, ®);
|
res = pcmcia_access_configuration_register(hw_priv->link->handle,
|
||||||
|
®);
|
||||||
if (res != CS_SUCCESS) {
|
if (res != CS_SUCCESS) {
|
||||||
printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 "
|
printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 "
|
||||||
"(%d)\n", res);
|
"(%d)\n", res);
|
||||||
@@ -470,23 +494,29 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
|
|||||||
|
|
||||||
static int prism2_pccard_dev_open(local_info_t *local)
|
static int prism2_pccard_dev_open(local_info_t *local)
|
||||||
{
|
{
|
||||||
local->link->open++;
|
struct hostap_cs_priv *hw_priv = local->hw_priv;
|
||||||
|
hw_priv->link->open++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int prism2_pccard_dev_close(local_info_t *local)
|
static int prism2_pccard_dev_close(local_info_t *local)
|
||||||
{
|
{
|
||||||
if (local == NULL || local->link == NULL)
|
struct hostap_cs_priv *hw_priv;
|
||||||
|
|
||||||
|
if (local == NULL || local->hw_priv == NULL)
|
||||||
|
return 1;
|
||||||
|
hw_priv = local->hw_priv;
|
||||||
|
if (hw_priv->link == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!local->link->open) {
|
if (!hw_priv->link->open) {
|
||||||
printk(KERN_WARNING "%s: prism2_pccard_dev_close(): "
|
printk(KERN_WARNING "%s: prism2_pccard_dev_close(): "
|
||||||
"link not open?!\n", local->dev->name);
|
"link not open?!\n", local->dev->name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
local->link->open--;
|
hw_priv->link->open--;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -567,8 +597,13 @@ static void prism2_detach(dev_link_t *link)
|
|||||||
*linkp = link->next;
|
*linkp = link->next;
|
||||||
/* release net devices */
|
/* release net devices */
|
||||||
if (link->priv) {
|
if (link->priv) {
|
||||||
prism2_free_local_data((struct net_device *) link->priv);
|
struct net_device *dev;
|
||||||
|
struct hostap_interface *iface;
|
||||||
|
dev = link->priv;
|
||||||
|
iface = netdev_priv(dev);
|
||||||
|
kfree(iface->local->hw_priv);
|
||||||
|
iface->local->hw_priv = NULL;
|
||||||
|
prism2_free_local_data(dev);
|
||||||
}
|
}
|
||||||
kfree(link);
|
kfree(link);
|
||||||
}
|
}
|
||||||
@@ -601,14 +636,19 @@ static int prism2_config(dev_link_t *link)
|
|||||||
u_char buf[64];
|
u_char buf[64];
|
||||||
config_info_t conf;
|
config_info_t conf;
|
||||||
cistpl_cftable_entry_t dflt = { 0 };
|
cistpl_cftable_entry_t dflt = { 0 };
|
||||||
|
struct hostap_cs_priv *hw_priv;
|
||||||
|
|
||||||
PDEBUG(DEBUG_FLOW, "prism2_config()\n");
|
PDEBUG(DEBUG_FLOW, "prism2_config()\n");
|
||||||
|
|
||||||
parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
|
parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
|
||||||
if (parse == NULL) {
|
hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
|
||||||
|
if (parse == NULL || hw_priv == NULL) {
|
||||||
|
kfree(parse);
|
||||||
|
kfree(hw_priv);
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
memset(hw_priv, 0, sizeof(*hw_priv));
|
||||||
|
|
||||||
tuple.DesiredTuple = CISTPL_CONFIG;
|
tuple.DesiredTuple = CISTPL_CONFIG;
|
||||||
tuple.Attributes = 0;
|
tuple.Attributes = 0;
|
||||||
@@ -779,9 +819,10 @@ static int prism2_config(dev_link_t *link)
|
|||||||
|
|
||||||
iface = netdev_priv(dev);
|
iface = netdev_priv(dev);
|
||||||
local = iface->local;
|
local = iface->local;
|
||||||
local->link = link;
|
local->hw_priv = hw_priv;
|
||||||
strcpy(local->node.dev_name, dev->name);
|
hw_priv->link = link;
|
||||||
link->dev = &local->node;
|
strcpy(hw_priv->node.dev_name, dev->name);
|
||||||
|
link->dev = &hw_priv->node;
|
||||||
|
|
||||||
local->shutdown = 0;
|
local->shutdown = 0;
|
||||||
|
|
||||||
@@ -791,7 +832,7 @@ static int prism2_config(dev_link_t *link)
|
|||||||
if (!ret) {
|
if (!ret) {
|
||||||
ret = hostap_hw_ready(dev);
|
ret = hostap_hw_ready(dev);
|
||||||
if (ret == 0 && local->ddev)
|
if (ret == 0 && local->ddev)
|
||||||
strcpy(local->node.dev_name, local->ddev->name);
|
strcpy(hw_priv->node.dev_name, local->ddev->name);
|
||||||
}
|
}
|
||||||
kfree(parse);
|
kfree(parse);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -801,6 +842,7 @@ static int prism2_config(dev_link_t *link)
|
|||||||
|
|
||||||
failed:
|
failed:
|
||||||
kfree(parse);
|
kfree(parse);
|
||||||
|
kfree(hw_priv);
|
||||||
prism2_release((u_long)link);
|
prism2_release((u_long)link);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,12 @@ MODULE_LICENSE("GPL");
|
|||||||
MODULE_VERSION(PRISM2_VERSION);
|
MODULE_VERSION(PRISM2_VERSION);
|
||||||
|
|
||||||
|
|
||||||
|
/* struct local_info::hw_priv */
|
||||||
|
struct hostap_pci_priv {
|
||||||
|
void __iomem *mem_start;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* FIX: do we need mb/wmb/rmb with memory operations? */
|
/* FIX: do we need mb/wmb/rmb with memory operations? */
|
||||||
|
|
||||||
|
|
||||||
@@ -61,7 +67,7 @@ static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v)
|
|||||||
|
|
||||||
spin_lock_irqsave(&local->lock, flags);
|
spin_lock_irqsave(&local->lock, flags);
|
||||||
prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v);
|
prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v);
|
||||||
writeb(v, local->mem_start + a);
|
writeb(v, hw_priv->mem_start + a);
|
||||||
spin_unlock_irqrestore(&local->lock, flags);
|
spin_unlock_irqrestore(&local->lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +82,7 @@ static inline u8 hfa384x_inb_debug(struct net_device *dev, int a)
|
|||||||
local = iface->local;
|
local = iface->local;
|
||||||
|
|
||||||
spin_lock_irqsave(&local->lock, flags);
|
spin_lock_irqsave(&local->lock, flags);
|
||||||
v = readb(local->mem_start + a);
|
v = readb(hw_priv->mem_start + a);
|
||||||
prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INB, a, v);
|
prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INB, a, v);
|
||||||
spin_unlock_irqrestore(&local->lock, flags);
|
spin_unlock_irqrestore(&local->lock, flags);
|
||||||
return v;
|
return v;
|
||||||
@@ -93,7 +99,7 @@ static inline void hfa384x_outw_debug(struct net_device *dev, int a, u16 v)
|
|||||||
|
|
||||||
spin_lock_irqsave(&local->lock, flags);
|
spin_lock_irqsave(&local->lock, flags);
|
||||||
prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v);
|
prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v);
|
||||||
writew(v, local->mem_start + a);
|
writew(v, hw_priv->mem_start + a);
|
||||||
spin_unlock_irqrestore(&local->lock, flags);
|
spin_unlock_irqrestore(&local->lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +114,7 @@ static inline u16 hfa384x_inw_debug(struct net_device *dev, int a)
|
|||||||
local = iface->local;
|
local = iface->local;
|
||||||
|
|
||||||
spin_lock_irqsave(&local->lock, flags);
|
spin_lock_irqsave(&local->lock, flags);
|
||||||
v = readw(local->mem_start + a);
|
v = readw(hw_priv->mem_start + a);
|
||||||
prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INW, a, v);
|
prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INW, a, v);
|
||||||
spin_unlock_irqrestore(&local->lock, flags);
|
spin_unlock_irqrestore(&local->lock, flags);
|
||||||
return v;
|
return v;
|
||||||
@@ -126,37 +132,37 @@ static inline u16 hfa384x_inw_debug(struct net_device *dev, int a)
|
|||||||
static inline void hfa384x_outb(struct net_device *dev, int a, u8 v)
|
static inline void hfa384x_outb(struct net_device *dev, int a, u8 v)
|
||||||
{
|
{
|
||||||
struct hostap_interface *iface;
|
struct hostap_interface *iface;
|
||||||
local_info_t *local;
|
struct hostap_pci_priv *hw_priv;
|
||||||
iface = netdev_priv(dev);
|
iface = netdev_priv(dev);
|
||||||
local = iface->local;
|
hw_priv = iface->local->hw_priv;
|
||||||
writeb(v, local->mem_start + a);
|
writeb(v, hw_priv->mem_start + a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u8 hfa384x_inb(struct net_device *dev, int a)
|
static inline u8 hfa384x_inb(struct net_device *dev, int a)
|
||||||
{
|
{
|
||||||
struct hostap_interface *iface;
|
struct hostap_interface *iface;
|
||||||
local_info_t *local;
|
struct hostap_pci_priv *hw_priv;
|
||||||
iface = netdev_priv(dev);
|
iface = netdev_priv(dev);
|
||||||
local = iface->local;
|
hw_priv = iface->local->hw_priv;
|
||||||
return readb(local->mem_start + a);
|
return readb(hw_priv->mem_start + a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void hfa384x_outw(struct net_device *dev, int a, u16 v)
|
static inline void hfa384x_outw(struct net_device *dev, int a, u16 v)
|
||||||
{
|
{
|
||||||
struct hostap_interface *iface;
|
struct hostap_interface *iface;
|
||||||
local_info_t *local;
|
struct hostap_pci_priv *hw_priv;
|
||||||
iface = netdev_priv(dev);
|
iface = netdev_priv(dev);
|
||||||
local = iface->local;
|
hw_priv = iface->local->hw_priv;
|
||||||
writew(v, local->mem_start + a);
|
writew(v, hw_priv->mem_start + a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u16 hfa384x_inw(struct net_device *dev, int a)
|
static inline u16 hfa384x_inw(struct net_device *dev, int a)
|
||||||
{
|
{
|
||||||
struct hostap_interface *iface;
|
struct hostap_interface *iface;
|
||||||
local_info_t *local;
|
struct hostap_pci_priv *hw_priv;
|
||||||
iface = netdev_priv(dev);
|
iface = netdev_priv(dev);
|
||||||
local = iface->local;
|
hw_priv = iface->local->hw_priv;
|
||||||
return readw(local->mem_start + a);
|
return readw(hw_priv->mem_start + a);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HFA384X_OUTB(v,a) hfa384x_outb(dev, (a), (v))
|
#define HFA384X_OUTB(v,a) hfa384x_outb(dev, (a), (v))
|
||||||
@@ -288,6 +294,12 @@ static int prism2_pci_probe(struct pci_dev *pdev,
|
|||||||
static int cards_found /* = 0 */;
|
static int cards_found /* = 0 */;
|
||||||
int irq_registered = 0;
|
int irq_registered = 0;
|
||||||
struct hostap_interface *iface;
|
struct hostap_interface *iface;
|
||||||
|
struct hostap_pci_priv *hw_priv;
|
||||||
|
|
||||||
|
hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
|
||||||
|
if (hw_priv == NULL)
|
||||||
|
return -ENOMEM;
|
||||||
|
memset(hw_priv, 0, sizeof(*hw_priv));
|
||||||
|
|
||||||
if (pci_enable_device(pdev))
|
if (pci_enable_device(pdev))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
@@ -311,10 +323,11 @@ static int prism2_pci_probe(struct pci_dev *pdev,
|
|||||||
goto fail;
|
goto fail;
|
||||||
iface = netdev_priv(dev);
|
iface = netdev_priv(dev);
|
||||||
local = iface->local;
|
local = iface->local;
|
||||||
|
local->hw_priv = hw_priv;
|
||||||
cards_found++;
|
cards_found++;
|
||||||
|
|
||||||
dev->irq = pdev->irq;
|
dev->irq = pdev->irq;
|
||||||
local->mem_start = mem;
|
hw_priv->mem_start = mem;
|
||||||
|
|
||||||
prism2_pci_cor_sreset(local);
|
prism2_pci_cor_sreset(local);
|
||||||
|
|
||||||
@@ -339,6 +352,8 @@ static int prism2_pci_probe(struct pci_dev *pdev,
|
|||||||
return hostap_hw_ready(dev);
|
return hostap_hw_ready(dev);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
kfree(hw_priv);
|
||||||
|
|
||||||
if (irq_registered && dev)
|
if (irq_registered && dev)
|
||||||
free_irq(dev->irq, dev);
|
free_irq(dev->irq, dev);
|
||||||
|
|
||||||
@@ -349,6 +364,9 @@ static int prism2_pci_probe(struct pci_dev *pdev,
|
|||||||
|
|
||||||
err_out_disable:
|
err_out_disable:
|
||||||
pci_disable_device(pdev);
|
pci_disable_device(pdev);
|
||||||
|
kfree(hw_priv);
|
||||||
|
if (local)
|
||||||
|
local->hw_priv = NULL;
|
||||||
prism2_free_local_data(dev);
|
prism2_free_local_data(dev);
|
||||||
|
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
@@ -360,9 +378,11 @@ static void prism2_pci_remove(struct pci_dev *pdev)
|
|||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
struct hostap_interface *iface;
|
struct hostap_interface *iface;
|
||||||
void __iomem *mem_start;
|
void __iomem *mem_start;
|
||||||
|
struct hostap_pci_priv *hw_priv;
|
||||||
|
|
||||||
dev = pci_get_drvdata(pdev);
|
dev = pci_get_drvdata(pdev);
|
||||||
iface = netdev_priv(dev);
|
iface = netdev_priv(dev);
|
||||||
|
hw_priv = iface->local->hw_priv;
|
||||||
|
|
||||||
/* Reset the hardware, and ensure interrupts are disabled. */
|
/* Reset the hardware, and ensure interrupts are disabled. */
|
||||||
prism2_pci_cor_sreset(iface->local);
|
prism2_pci_cor_sreset(iface->local);
|
||||||
@@ -371,7 +391,9 @@ static void prism2_pci_remove(struct pci_dev *pdev)
|
|||||||
if (dev->irq)
|
if (dev->irq)
|
||||||
free_irq(dev->irq, dev);
|
free_irq(dev->irq, dev);
|
||||||
|
|
||||||
mem_start = iface->local->mem_start;
|
mem_start = hw_priv->mem_start;
|
||||||
|
kfree(hw_priv);
|
||||||
|
iface->local->hw_priv = NULL;
|
||||||
prism2_free_local_data(dev);
|
prism2_free_local_data(dev);
|
||||||
|
|
||||||
iounmap(mem_start);
|
iounmap(mem_start);
|
||||||
|
@@ -42,6 +42,13 @@ module_param(ignore_cis, int, 0444);
|
|||||||
MODULE_PARM_DESC(ignore_cis, "Do not verify manfid information in CIS");
|
MODULE_PARM_DESC(ignore_cis, "Do not verify manfid information in CIS");
|
||||||
|
|
||||||
|
|
||||||
|
/* struct local_info::hw_priv */
|
||||||
|
struct hostap_plx_priv {
|
||||||
|
void __iomem *attr_mem;
|
||||||
|
unsigned int cor_offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#define PLX_MIN_ATTR_LEN 512 /* at least 2 x 256 is needed for CIS */
|
#define PLX_MIN_ATTR_LEN 512 /* at least 2 x 256 is needed for CIS */
|
||||||
#define COR_SRESET 0x80
|
#define COR_SRESET 0x80
|
||||||
#define COR_LEVLREQ 0x40
|
#define COR_LEVLREQ 0x40
|
||||||
@@ -261,27 +268,28 @@ static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
|
|||||||
static void prism2_plx_cor_sreset(local_info_t *local)
|
static void prism2_plx_cor_sreset(local_info_t *local)
|
||||||
{
|
{
|
||||||
unsigned char corsave;
|
unsigned char corsave;
|
||||||
|
struct hostap_plx_priv *hw_priv = local->hw_priv;
|
||||||
|
|
||||||
printk(KERN_DEBUG "%s: Doing reset via direct COR access.\n",
|
printk(KERN_DEBUG "%s: Doing reset via direct COR access.\n",
|
||||||
dev_info);
|
dev_info);
|
||||||
|
|
||||||
/* Set sreset bit of COR and clear it after hold time */
|
/* Set sreset bit of COR and clear it after hold time */
|
||||||
|
|
||||||
if (local->attr_mem == NULL) {
|
if (hw_priv->attr_mem == NULL) {
|
||||||
/* TMD7160 - COR at card's first I/O addr */
|
/* TMD7160 - COR at card's first I/O addr */
|
||||||
corsave = inb(local->cor_offset);
|
corsave = inb(hw_priv->cor_offset);
|
||||||
outb(corsave | COR_SRESET, local->cor_offset);
|
outb(corsave | COR_SRESET, hw_priv->cor_offset);
|
||||||
mdelay(2);
|
mdelay(2);
|
||||||
outb(corsave & ~COR_SRESET, local->cor_offset);
|
outb(corsave & ~COR_SRESET, hw_priv->cor_offset);
|
||||||
mdelay(2);
|
mdelay(2);
|
||||||
} else {
|
} else {
|
||||||
/* PLX9052 */
|
/* PLX9052 */
|
||||||
corsave = readb(local->attr_mem + local->cor_offset);
|
corsave = readb(hw_priv->attr_mem + hw_priv->cor_offset);
|
||||||
writeb(corsave | COR_SRESET,
|
writeb(corsave | COR_SRESET,
|
||||||
local->attr_mem + local->cor_offset);
|
hw_priv->attr_mem + hw_priv->cor_offset);
|
||||||
mdelay(2);
|
mdelay(2);
|
||||||
writeb(corsave & ~COR_SRESET,
|
writeb(corsave & ~COR_SRESET,
|
||||||
local->attr_mem + local->cor_offset);
|
hw_priv->attr_mem + hw_priv->cor_offset);
|
||||||
mdelay(2);
|
mdelay(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -290,26 +298,27 @@ static void prism2_plx_cor_sreset(local_info_t *local)
|
|||||||
static void prism2_plx_genesis_reset(local_info_t *local, int hcr)
|
static void prism2_plx_genesis_reset(local_info_t *local, int hcr)
|
||||||
{
|
{
|
||||||
unsigned char corsave;
|
unsigned char corsave;
|
||||||
|
struct hostap_plx_priv *hw_priv = local->hw_priv;
|
||||||
|
|
||||||
if (local->attr_mem == NULL) {
|
if (hw_priv->attr_mem == NULL) {
|
||||||
/* TMD7160 - COR at card's first I/O addr */
|
/* TMD7160 - COR at card's first I/O addr */
|
||||||
corsave = inb(local->cor_offset);
|
corsave = inb(hw_priv->cor_offset);
|
||||||
outb(corsave | COR_SRESET, local->cor_offset);
|
outb(corsave | COR_SRESET, hw_priv->cor_offset);
|
||||||
mdelay(10);
|
mdelay(10);
|
||||||
outb(hcr, local->cor_offset + 2);
|
outb(hcr, hw_priv->cor_offset + 2);
|
||||||
mdelay(10);
|
mdelay(10);
|
||||||
outb(corsave & ~COR_SRESET, local->cor_offset);
|
outb(corsave & ~COR_SRESET, hw_priv->cor_offset);
|
||||||
mdelay(10);
|
mdelay(10);
|
||||||
} else {
|
} else {
|
||||||
/* PLX9052 */
|
/* PLX9052 */
|
||||||
corsave = readb(local->attr_mem + local->cor_offset);
|
corsave = readb(hw_priv->attr_mem + hw_priv->cor_offset);
|
||||||
writeb(corsave | COR_SRESET,
|
writeb(corsave | COR_SRESET,
|
||||||
local->attr_mem + local->cor_offset);
|
hw_priv->attr_mem + hw_priv->cor_offset);
|
||||||
mdelay(10);
|
mdelay(10);
|
||||||
writeb(hcr, local->attr_mem + local->cor_offset + 2);
|
writeb(hcr, hw_priv->attr_mem + hw_priv->cor_offset + 2);
|
||||||
mdelay(10);
|
mdelay(10);
|
||||||
writeb(corsave & ~COR_SRESET,
|
writeb(corsave & ~COR_SRESET,
|
||||||
local->attr_mem + local->cor_offset);
|
hw_priv->attr_mem + hw_priv->cor_offset);
|
||||||
mdelay(10);
|
mdelay(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -438,6 +447,12 @@ static int prism2_plx_probe(struct pci_dev *pdev,
|
|||||||
static int cards_found /* = 0 */;
|
static int cards_found /* = 0 */;
|
||||||
int irq_registered = 0;
|
int irq_registered = 0;
|
||||||
int tmd7160;
|
int tmd7160;
|
||||||
|
struct hostap_plx_priv *hw_priv;
|
||||||
|
|
||||||
|
hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
|
||||||
|
if (hw_priv == NULL)
|
||||||
|
return -ENOMEM;
|
||||||
|
memset(hw_priv, 0, sizeof(*hw_priv));
|
||||||
|
|
||||||
if (pci_enable_device(pdev))
|
if (pci_enable_device(pdev))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
@@ -529,12 +544,13 @@ static int prism2_plx_probe(struct pci_dev *pdev,
|
|||||||
goto fail;
|
goto fail;
|
||||||
iface = netdev_priv(dev);
|
iface = netdev_priv(dev);
|
||||||
local = iface->local;
|
local = iface->local;
|
||||||
|
local->hw_priv = hw_priv;
|
||||||
cards_found++;
|
cards_found++;
|
||||||
|
|
||||||
dev->irq = pdev->irq;
|
dev->irq = pdev->irq;
|
||||||
dev->base_addr = pccard_ioaddr;
|
dev->base_addr = pccard_ioaddr;
|
||||||
local->attr_mem = attr_mem;
|
hw_priv->attr_mem = attr_mem;
|
||||||
local->cor_offset = cor_offset;
|
hw_priv->cor_offset = cor_offset;
|
||||||
|
|
||||||
pci_set_drvdata(pdev, dev);
|
pci_set_drvdata(pdev, dev);
|
||||||
|
|
||||||
@@ -554,6 +570,9 @@ static int prism2_plx_probe(struct pci_dev *pdev,
|
|||||||
return hostap_hw_ready(dev);
|
return hostap_hw_ready(dev);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
kfree(hw_priv);
|
||||||
|
if (local)
|
||||||
|
local->hw_priv = NULL;
|
||||||
prism2_free_local_data(dev);
|
prism2_free_local_data(dev);
|
||||||
|
|
||||||
if (irq_registered && dev)
|
if (irq_registered && dev)
|
||||||
@@ -572,19 +591,23 @@ static void prism2_plx_remove(struct pci_dev *pdev)
|
|||||||
{
|
{
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
struct hostap_interface *iface;
|
struct hostap_interface *iface;
|
||||||
|
struct hostap_plx_priv *hw_priv;
|
||||||
|
|
||||||
dev = pci_get_drvdata(pdev);
|
dev = pci_get_drvdata(pdev);
|
||||||
iface = netdev_priv(dev);
|
iface = netdev_priv(dev);
|
||||||
|
hw_priv = iface->local->hw_priv;
|
||||||
|
|
||||||
/* Reset the hardware, and ensure interrupts are disabled. */
|
/* Reset the hardware, and ensure interrupts are disabled. */
|
||||||
prism2_plx_cor_sreset(iface->local);
|
prism2_plx_cor_sreset(iface->local);
|
||||||
hfa384x_disable_interrupts(dev);
|
hfa384x_disable_interrupts(dev);
|
||||||
|
|
||||||
if (iface->local->attr_mem)
|
if (hw_priv->attr_mem)
|
||||||
iounmap(iface->local->attr_mem);
|
iounmap(hw_priv->attr_mem);
|
||||||
if (dev->irq)
|
if (dev->irq)
|
||||||
free_irq(dev->irq, dev);
|
free_irq(dev->irq, dev);
|
||||||
|
|
||||||
|
kfree(iface->local->hw_priv);
|
||||||
|
iface->local->hw_priv = NULL;
|
||||||
prism2_free_local_data(dev);
|
prism2_free_local_data(dev);
|
||||||
pci_disable_device(pdev);
|
pci_disable_device(pdev);
|
||||||
}
|
}
|
||||||
|
@@ -876,27 +876,8 @@ struct local_info {
|
|||||||
int io_debug_enabled;
|
int io_debug_enabled;
|
||||||
#endif /* PRISM2_IO_DEBUG */
|
#endif /* PRISM2_IO_DEBUG */
|
||||||
|
|
||||||
/* struct local_info is used also in hostap.o that does not define
|
/* Pointer to hardware model specific (cs,pci,plx) private data. */
|
||||||
* any PRISM2_{PCCARD,PLX,PCI}. Make sure that the hardware version
|
void *hw_priv;
|
||||||
* specific fields are in the end of the struct (these could also be
|
|
||||||
* moved to void *priv or something like that). */
|
|
||||||
#ifdef PRISM2_PCCARD
|
|
||||||
dev_node_t node;
|
|
||||||
dev_link_t *link;
|
|
||||||
int sandisk_connectplus;
|
|
||||||
#endif /* PRISM2_PCCARD */
|
|
||||||
|
|
||||||
#ifdef PRISM2_PLX
|
|
||||||
void __iomem *attr_mem;
|
|
||||||
unsigned int cor_offset;
|
|
||||||
#endif /* PRISM2_PLX */
|
|
||||||
|
|
||||||
#ifdef PRISM2_PCI
|
|
||||||
void __iomem *mem_start;
|
|
||||||
#endif /* PRISM2_PCI */
|
|
||||||
|
|
||||||
/* NOTE! Do not add common entries here after hardware version
|
|
||||||
* specific blocks. */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user