*/
void btmrvl_interrupt(struct btmrvl_private *priv)
{
- BT_DBG("Enter");
-
priv->adapter->ps_state = PS_AWAKE;
priv->adapter->wakeup_tries = 0;
priv->adapter->int_count++;
wake_up_interruptible(&priv->main_thread.wait_q);
-
- BT_DBG("Leave");
}
EXPORT_SYMBOL_GPL(btmrvl_interrupt);
struct hci_ev_cmd_complete *ec;
u16 opcode, ocf;
- BT_DBG("Enter");
-
if (hdr->evt == HCI_EV_CMD_COMPLETE) {
ec = (void *) (skb->data + HCI_EVENT_HDR_SIZE);
opcode = __le16_to_cpu(ec->opcode);
wake_up_interruptible(&priv->adapter->cmd_wait_q);
}
}
-
- BT_DBG("Leave");
}
EXPORT_SYMBOL_GPL(btmrvl_check_evtpkt);
struct btmrvl_event *event;
u8 ret = 0;
- BT_DBG("Enter");
-
event = (struct btmrvl_event *) skb->data;
if (event->ec != 0xff) {
BT_DBG("Not Marvell Event=%x", event->ec);
if (!ret)
kfree_skb(skb);
- BT_DBG("Leave");
-
return ret;
}
EXPORT_SYMBOL_GPL(btmrvl_process_event);
{
struct sk_buff *skb;
struct btmrvl_cmd *cmd;
- u8 ret = 0;
-
- BT_DBG("Enter");
+ int ret = 0;
skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
if (skb == NULL) {
BT_ERR("No free skb");
- ret = -ENOMEM;
- goto exit;
+ return -ENOMEM;
}
cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
BT_DBG("module cfg Command done");
-exit:
- BT_DBG("Leave");
-
return ret;
}
EXPORT_SYMBOL_GPL(btmrvl_send_module_cfg_cmd);
{
struct sk_buff *skb;
struct btmrvl_cmd *cmd;
- u8 ret = 0;
-
- BT_DBG("Enter");
+ int ret = 0;
skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
if (skb == NULL) {
BT_ERR("No free skb");
- ret = -ENOMEM;
- goto exit;
+ return -ENOMEM;
}
cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
priv->adapter->wakeup_tries);
}
-exit:
- BT_DBG("Leave");
-
return ret;
}
{
struct sk_buff *skb = NULL;
struct btmrvl_cmd *cmd;
- u8 ret = 0;
-
- BT_DBG("Enter");
+ int ret = 0;
if (priv->btmrvl_dev.hscfgcmd) {
priv->btmrvl_dev.hscfgcmd = 0;
skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
if (skb == NULL) {
BT_ERR("No free skb");
- ret = -ENOMEM;
- goto exit;
+ return -ENOMEM;
}
cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
if (skb == NULL) {
BT_ERR("No free skb");
- ret = -ENOMEM;
- goto exit;
+ return -ENOMEM;
}
cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
}
}
-exit:
- BT_DBG("Leave");
-
return ret;
}
static int btmrvl_tx_pkt(struct btmrvl_private *priv, struct sk_buff *skb)
{
- u8 ret = 0;
+ int ret = 0;
- BT_DBG("Enter");
-
- if (!skb || !skb->data) {
- BT_DBG("Leave");
+ if (!skb || !skb->data)
return -EINVAL;
- }
if (!skb->len || ((skb->len + BTM_HEADER_LEN) > BTM_UPLD_SIZE)) {
BT_ERR("Tx Error: Bad skb length %d : %d",
skb->len, BTM_UPLD_SIZE);
- BT_DBG("Leave");
return -EINVAL;
}
BT_ERR("Tx Error: realloc_headroom failed %d",
BTM_HEADER_LEN);
skb = tmp;
- BT_DBG("Leave");
return -EINVAL;
}
if (priv->hw_host_to_card)
ret = priv->hw_host_to_card(priv, skb->data, skb->len);
- BT_DBG("Leave");
-
return ret;
}
static void btmrvl_init_adapter(struct btmrvl_private *priv)
{
- BT_DBG("Enter");
-
skb_queue_head_init(&priv->adapter->tx_queue);
priv->adapter->ps_state = PS_AWAKE;
init_waitqueue_head(&priv->adapter->cmd_wait_q);
-
- BT_DBG("Leave");
}
static void btmrvl_free_adapter(struct btmrvl_private *priv)
{
- BT_DBG("Enter");
-
skb_queue_purge(&priv->adapter->tx_queue);
kfree(priv->adapter);
priv->adapter = NULL;
-
- BT_DBG("Leave");
}
static int btmrvl_ioctl(struct hci_dev *hdev,
unsigned int cmd, unsigned long arg)
{
- BT_DBG("Enter");
-
- BT_DBG("Leave");
-
return -ENOIOCTLCMD;
}
static void btmrvl_destruct(struct hci_dev *hdev)
{
- BT_DBG("Enter");
-
- BT_DBG("Leave");
}
static int btmrvl_send_frame(struct sk_buff *skb)
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
struct btmrvl_private *priv = NULL;
- BT_DBG("Enter: type=%d, len=%d", skb->pkt_type, skb->len);
+ BT_DBG("type=%d, len=%d", skb->pkt_type, skb->len);
if (!hdev || !hdev->driver_data) {
BT_ERR("Frame for unknown HCI device");
- BT_DBG("Leave");
return -ENODEV;
}
BT_ERR("Failed testing HCI_RUNING, flags=%lx", hdev->flags);
print_hex_dump_bytes("data: ", DUMP_PREFIX_OFFSET,
skb->data, skb->len);
- BT_DBG("Leave");
return -EBUSY;
}
wake_up_interruptible(&priv->main_thread.wait_q);
- BT_DBG("Leave");
-
return 0;
}
{
struct btmrvl_private *priv = hdev->driver_data;
- BT_DBG("Enter");
-
skb_queue_purge(&priv->adapter->tx_queue);
- BT_DBG("Leave");
-
return 0;
}
{
struct btmrvl_private *priv = hdev->driver_data;
- BT_DBG("Enter");
-
- if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) {
- BT_DBG("Leave");
+ if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
return 0;
- }
skb_queue_purge(&priv->adapter->tx_queue);
- BT_DBG("Leave");
-
return 0;
}
static int btmrvl_open(struct hci_dev *hdev)
{
- BT_DBG("Enter");
-
set_bit(HCI_RUNNING, &hdev->flags);
- BT_DBG("Leave");
-
return 0;
}
struct sk_buff *skb;
ulong flags;
- BT_DBG("Enter");
-
init_waitqueue_entry(&wait, current);
current->flags |= PF_NOFREEZE;
}
}
- BT_DBG("Leave");
-
return 0;
}
struct btmrvl_private *priv;
int ret;
- BT_DBG("Enter");
-
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) {
BT_ERR("Can not allocate priv");
btmrvl_debugfs_init(hdev);
#endif
- BT_DBG("Leave");
return priv;
err_hci_register_dev:
kfree(priv);
err_priv:
- BT_DBG("Leave");
-
return NULL;
}
EXPORT_SYMBOL_GPL(btmrvl_add_card);
{
struct hci_dev *hdev;
- BT_DBG("Enter");
-
hdev = priv->btmrvl_dev.hcidev;
wake_up_interruptible(&priv->adapter->cmd_wait_q);
kfree(priv);
- BT_DBG("Leave");
-
return 0;
}
EXPORT_SYMBOL_GPL(btmrvl_remove_card);
u8 reg;
int ret;
- BT_DBG("Enter");
-
reg = sdio_readb(card->func, CARD_RX_UNIT_REG, &ret);
if (!ret)
card->rx_unit = reg;
- BT_DBG("Leave");
-
return ret;
}
static int btmrvl_sdio_read_fw_status(struct btmrvl_sdio_card *card, u16 *dat)
{
- int ret;
u8 fws0, fws1;
-
- BT_DBG("Enter");
+ int ret;
*dat = 0;
if (!ret)
fws1 = sdio_readb(card->func, CARD_FW_STATUS1_REG, &ret);
- if (ret) {
- BT_DBG("Leave");
+ if (ret)
return -EIO;
- }
*dat = (((u16) fws1) << 8) | fws0;
- BT_DBG("Leave");
-
return 0;
}
static int btmrvl_sdio_read_rx_len(struct btmrvl_sdio_card *card, u16 *dat)
{
- int ret;
u8 reg;
-
- BT_DBG("Enter");
+ int ret;
reg = sdio_readb(card->func, CARD_RX_LEN_REG, &ret);
if (!ret)
*dat = (u16) reg << card->rx_unit;
- BT_DBG("Leave");
-
return ret;
}
{
int ret;
- BT_DBG("Enter");
-
sdio_writeb(card->func, mask, HOST_INT_MASK_REG, &ret);
if (ret) {
BT_ERR("Unable to enable the host interrupt!");
ret = -EIO;
}
- BT_DBG("Leave");
-
return ret;
}
static int btmrvl_sdio_disable_host_int_mask(struct btmrvl_sdio_card *card,
u8 mask)
{
- int ret;
u8 host_int_mask;
-
- BT_DBG("Enter");
+ int ret;
host_int_mask = sdio_readb(card->func, HOST_INT_MASK_REG, &ret);
- if (ret) {
- ret = -EIO;
- goto done;
- }
+ if (ret)
+ return -EIO;
host_int_mask &= ~mask;
sdio_writeb(card->func, host_int_mask, HOST_INT_MASK_REG, &ret);
if (ret < 0) {
BT_ERR("Unable to disable the host interrupt!");
- ret = -EIO;
- goto done;
+ return -EIO;
}
- ret = 0;
-
-done:
- BT_DBG("Leave");
-
- return ret;
+ return 0;
}
static int btmrvl_sdio_poll_card_status(struct btmrvl_sdio_card *card, u8 bits)
{
unsigned int tries;
- int ret;
u8 status;
-
- BT_DBG("Enter");
+ int ret;
for (tries = 0; tries < MAX_POLL_TRIES * 1000; tries++) {
status = sdio_readb(card->func, CARD_STATUS_REG, &ret);
if (ret)
goto failed;
if ((status & bits) == bits)
- goto done;
+ return ret;
udelay(1);
}
failed:
BT_ERR("FAILED! ret=%d", ret);
-done:
- BT_DBG("Leave");
-
return ret;
}
u16 firmwarestat;
unsigned int tries;
- BT_DBG("Enter");
-
/* Wait for firmware to become ready */
for (tries = 0; tries < pollnum; tries++) {
if (btmrvl_sdio_read_fw_status(card, &firmwarestat) < 0)
}
}
- BT_DBG("Leave");
-
return ret;
}
u8 *helperbuf;
u32 tx_len;
- BT_DBG("Enter");
-
ret = request_firmware(&fw_helper, card->helper,
&card->func->dev);
if ((ret < 0) || !fw_helper) {
if (fw_helper)
release_firmware(fw_helper);
- BT_DBG("Leave");
-
return ret;
}
u16 len;
int txlen = 0, tx_blocks = 0, count = 0;
- BT_DBG("Enter");
-
ret = request_firmware(&fw_firmware, card->firmware,
&card->func->dev);
if ((ret < 0) || !fw_firmware) {
if (fw_firmware)
release_firmware(fw_firmware);
- BT_DBG("Leave");
-
return ret;
}
struct hci_dev *hdev = priv->btmrvl_dev.hcidev;
struct btmrvl_sdio_card *card = priv->btmrvl_dev.card;
- BT_DBG("Enter");
-
if (!card || !card->func) {
BT_ERR("card or function is NULL!");
ret = -EINVAL;
kfree_skb(skb);
}
- BT_DBG("Leave");
-
return ret;
}
u8 sdio_ireg = 0;
struct btmrvl_sdio_card *card = priv->btmrvl_dev.card;
- BT_DBG("Enter");
-
*ireg = 0;
sdio_ireg = sdio_readb(card->func, HOST_INTSTATUS_REG, &ret);
ret = 0;
done:
- BT_DBG("Leave");
-
return ret;
}
struct btmrvl_sdio_card *card;
u8 ireg = 0;
- BT_DBG("Enter");
-
card = sdio_get_drvdata(func);
if (card && card->priv) {
priv = card->priv;
btmrvl_interrupt(priv);
}
-
- BT_DBG("Leave");
}
static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card)
u8 reg;
int ret = 0;
- BT_DBG("Enter");
-
if (!card || !card->func) {
BT_ERR("Error: card or function is NULL!");
ret = -EINVAL;
sdio_release_host(func);
- BT_DBG("Leave");
return 0;
release_irq:
sdio_release_host(func);
failed:
- BT_DBG("Leave");
return ret;
}
static int btmrvl_sdio_unregister_dev(struct btmrvl_sdio_card *card)
{
- BT_DBG("Enter");
-
if (card && card->func) {
sdio_claim_host(card->func);
sdio_release_irq(card->func);
sdio_set_drvdata(card->func, NULL);
}
- BT_DBG("Leave");
-
return 0;
}
{
int ret;
- BT_DBG("Enter");
-
- if (!card || !card->func) {
- BT_DBG("Leave");
+ if (!card || !card->func)
return -EINVAL;
- }
sdio_claim_host(card->func);
sdio_release_host(card->func);
- BT_DBG("Leave");
-
return ret;
}
{
int ret;
- BT_DBG("Enter");
-
- if (!card || !card->func) {
- BT_DBG("Leave");
+ if (!card || !card->func)
return -EINVAL;
- }
sdio_claim_host(card->func);
sdio_release_host(card->func);
- BT_DBG("Leave");
-
return ret;
}
void *tmpbuf = NULL;
int tmpbufsz;
- BT_DBG("Enter");
-
if (!card || !card->func) {
BT_ERR("card or function is NULL!");
- BT_DBG("Leave");
return -EINVAL;
}
exit:
sdio_release_host(card->func);
- BT_DBG("Leave");
-
return ret;
}
{
int ret = 0;
- BT_DBG("Enter");
-
if (!card || !card->func) {
BT_ERR("card or function is NULL!");
- BT_DBG("Leave");
return -EINVAL;
}
sdio_claim_host(card->func);
done:
sdio_release_host(card->func);
- BT_DBG("Leave");
-
return ret;
}
struct btmrvl_sdio_card *card = priv->btmrvl_dev.card;
int ret = 0;
- BT_DBG("Enter");
-
if (!card || !card->func) {
BT_ERR("card or function is NULL!");
- BT_DBG("Leave");
return -EINVAL;
}
BT_DBG("wake up firmware");
- BT_DBG("Leave");
-
return ret;
}
struct btmrvl_private *priv = NULL;
struct btmrvl_sdio_card *card = NULL;
- BT_DBG("Enter");
-
BT_INFO("vendor=0x%x, device=0x%x, class=%d, fn=%d",
id->vendor, id->device, id->class, func->num);
btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ);
- BT_DBG("Leave");
-
return 0;
disable_host_int:
free_card:
kfree(card);
done:
- BT_DBG("Leave");
-
return ret;
}
{
struct btmrvl_sdio_card *card;
- BT_DBG("Enter");
-
if (func) {
card = sdio_get_drvdata(func);
if (card) {
kfree(card);
}
}
-
- BT_DBG("Leave");
}
static struct sdio_driver bt_mrvl_sdio = {
static int btmrvl_sdio_init_module(void)
{
- BT_DBG("Enter");
-
if (sdio_register_driver(&bt_mrvl_sdio) != 0) {
BT_ERR("SDIO Driver Registration Failed");
- BT_DBG("Leave");
return -ENODEV;
}
/* Clear the flag in case user removes the card. */
user_rmmod = 0;
- BT_DBG("Leave");
-
return 0;
}
static void btmrvl_sdio_exit_module(void)
{
- BT_DBG("Enter");
-
/* Set the flag as user is removing this module. */
user_rmmod = 1;
sdio_unregister_driver(&bt_mrvl_sdio);
-
- BT_DBG("Leave");
}
module_init(btmrvl_sdio_init_module);