diff options
author | Bing Zhao <bzhao@marvell.com> | 2014-03-28 00:30:42 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-03-28 03:09:30 -0400 |
commit | 8af4840a36f3d8210604ecfd5b1ce9b39745e7ba (patch) | |
tree | 5307f7fa10919c3783db940be8be62ba22a39d86 /drivers/bluetooth | |
parent | 8002d77ca9edbf81b81ab5154d75f7cce3d0511e (diff) |
Bluetooth: btmrvl: separate write-to-clear function from interrupt handler
This patch improves readability and makes future changes easier.
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r-- | drivers/bluetooth/btmrvl_sdio.c | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c index 1b52c9f5230d..7883793717fd 100644 --- a/drivers/bluetooth/btmrvl_sdio.c +++ b/drivers/bluetooth/btmrvl_sdio.c | |||
@@ -667,6 +667,36 @@ static int btmrvl_sdio_process_int_status(struct btmrvl_private *priv) | |||
667 | return 0; | 667 | return 0; |
668 | } | 668 | } |
669 | 669 | ||
670 | static int btmrvl_sdio_write_to_clear(struct btmrvl_sdio_card *card, u8 *ireg) | ||
671 | { | ||
672 | int ret; | ||
673 | |||
674 | *ireg = sdio_readb(card->func, card->reg->host_intstatus, &ret); | ||
675 | if (ret) { | ||
676 | BT_ERR("sdio_readb: read int status failed: %d", ret); | ||
677 | return ret; | ||
678 | } | ||
679 | |||
680 | if (*ireg) { | ||
681 | /* | ||
682 | * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS | ||
683 | * Clear the interrupt status register and re-enable the | ||
684 | * interrupt. | ||
685 | */ | ||
686 | BT_DBG("int_status = 0x%x", *ireg); | ||
687 | |||
688 | sdio_writeb(card->func, ~(*ireg) & (DN_LD_HOST_INT_STATUS | | ||
689 | UP_LD_HOST_INT_STATUS), | ||
690 | card->reg->host_intstatus, &ret); | ||
691 | if (ret) { | ||
692 | BT_ERR("sdio_writeb: clear int status failed: %d", ret); | ||
693 | return ret; | ||
694 | } | ||
695 | } | ||
696 | |||
697 | return 0; | ||
698 | } | ||
699 | |||
670 | static void btmrvl_sdio_interrupt(struct sdio_func *func) | 700 | static void btmrvl_sdio_interrupt(struct sdio_func *func) |
671 | { | 701 | { |
672 | struct btmrvl_private *priv; | 702 | struct btmrvl_private *priv; |
@@ -684,28 +714,9 @@ static void btmrvl_sdio_interrupt(struct sdio_func *func) | |||
684 | 714 | ||
685 | priv = card->priv; | 715 | priv = card->priv; |
686 | 716 | ||
687 | ireg = sdio_readb(card->func, card->reg->host_intstatus, &ret); | 717 | ret = btmrvl_sdio_write_to_clear(card, &ireg); |
688 | if (ret) { | 718 | if (ret) |
689 | BT_ERR("sdio_readb: read int status register failed"); | ||
690 | return; | 719 | return; |
691 | } | ||
692 | |||
693 | if (ireg != 0) { | ||
694 | /* | ||
695 | * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS | ||
696 | * Clear the interrupt status register and re-enable the | ||
697 | * interrupt. | ||
698 | */ | ||
699 | BT_DBG("ireg = 0x%x", ireg); | ||
700 | |||
701 | sdio_writeb(card->func, ~(ireg) & (DN_LD_HOST_INT_STATUS | | ||
702 | UP_LD_HOST_INT_STATUS), | ||
703 | card->reg->host_intstatus, &ret); | ||
704 | if (ret) { | ||
705 | BT_ERR("sdio_writeb: clear int status register failed"); | ||
706 | return; | ||
707 | } | ||
708 | } | ||
709 | 720 | ||
710 | spin_lock_irqsave(&priv->driver_lock, flags); | 721 | spin_lock_irqsave(&priv->driver_lock, flags); |
711 | sdio_ireg |= ireg; | 722 | sdio_ireg |= ireg; |