Merge branch 'linus' into sched/devel
[pandora-kernel.git] / arch / powerpc / sysdev / qe_lib / ucc_slow.c
index 0174b3a..e1d6a13 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/stddef.h>
 #include <linux/interrupt.h>
 #include <linux/err.h>
+#include <linux/module.h>
 
 #include <asm/io.h>
 #include <asm/immap_qe.h>
@@ -41,6 +42,7 @@ u32 ucc_slow_get_qe_cr_subblock(int uccs_num)
        default: return QE_CR_SUBBLOCK_INVALID;
        }
 }
+EXPORT_SYMBOL(ucc_slow_get_qe_cr_subblock);
 
 void ucc_slow_poll_transmitter_now(struct ucc_slow_private * uccs)
 {
@@ -56,6 +58,7 @@ void ucc_slow_graceful_stop_tx(struct ucc_slow_private * uccs)
        qe_issue_cmd(QE_GRACEFUL_STOP_TX, id,
                         QE_CR_PROTOCOL_UNSPECIFIED, 0);
 }
+EXPORT_SYMBOL(ucc_slow_graceful_stop_tx);
 
 void ucc_slow_stop_tx(struct ucc_slow_private * uccs)
 {
@@ -65,6 +68,7 @@ void ucc_slow_stop_tx(struct ucc_slow_private * uccs)
        id = ucc_slow_get_qe_cr_subblock(us_info->ucc_num);
        qe_issue_cmd(QE_STOP_TX, id, QE_CR_PROTOCOL_UNSPECIFIED, 0);
 }
+EXPORT_SYMBOL(ucc_slow_stop_tx);
 
 void ucc_slow_restart_tx(struct ucc_slow_private * uccs)
 {
@@ -74,6 +78,7 @@ void ucc_slow_restart_tx(struct ucc_slow_private * uccs)
        id = ucc_slow_get_qe_cr_subblock(us_info->ucc_num);
        qe_issue_cmd(QE_RESTART_TX, id, QE_CR_PROTOCOL_UNSPECIFIED, 0);
 }
+EXPORT_SYMBOL(ucc_slow_restart_tx);
 
 void ucc_slow_enable(struct ucc_slow_private * uccs, enum comm_dir mode)
 {
@@ -94,6 +99,7 @@ void ucc_slow_enable(struct ucc_slow_private * uccs, enum comm_dir mode)
        }
        out_be32(&us_regs->gumr_l, gumr_l);
 }
+EXPORT_SYMBOL(ucc_slow_enable);
 
 void ucc_slow_disable(struct ucc_slow_private * uccs, enum comm_dir mode)
 {
@@ -114,6 +120,7 @@ void ucc_slow_disable(struct ucc_slow_private * uccs, enum comm_dir mode)
        }
        out_be32(&us_regs->gumr_l, gumr_l);
 }
+EXPORT_SYMBOL(ucc_slow_disable);
 
 /* Initialize the UCC for Slow operations
  *
@@ -135,7 +142,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
 
        /* check if the UCC port number is in range. */
        if ((us_info->ucc_num < 0) || (us_info->ucc_num > UCC_MAX_NUM - 1)) {
-               printk(KERN_ERR "%s: illegal UCC number\n", __FUNCTION__);
+               printk(KERN_ERR "%s: illegal UCC number\n", __func__);
                return -EINVAL;
        }
 
@@ -154,7 +161,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
        uccs = kzalloc(sizeof(struct ucc_slow_private), GFP_KERNEL);
        if (!uccs) {
                printk(KERN_ERR "%s: Cannot allocate private data\n",
-                       __FUNCTION__);
+                       __func__);
                return -ENOMEM;
        }
 
@@ -163,7 +170,8 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
        /* Set the PHY base address */
        uccs->us_regs = ioremap(us_info->regs, sizeof(struct ucc_slow));
        if (uccs->us_regs == NULL) {
-               printk(KERN_ERR "%s: Cannot map UCC registers\n", __FUNCTION__);
+               printk(KERN_ERR "%s: Cannot map UCC registers\n", __func__);
+               kfree(uccs);
                return -ENOMEM;
        }
 
@@ -182,7 +190,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
        uccs->us_pram_offset =
                qe_muram_alloc(UCC_SLOW_PRAM_SIZE, ALIGNMENT_OF_UCC_SLOW_PRAM);
        if (IS_ERR_VALUE(uccs->us_pram_offset)) {
-               printk(KERN_ERR "%s: cannot allocate MURAM for PRAM", __FUNCTION__);
+               printk(KERN_ERR "%s: cannot allocate MURAM for PRAM", __func__);
                ucc_slow_free(uccs);
                return -ENOMEM;
        }
@@ -195,7 +203,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
        /* Set UCC to slow type */
        ret = ucc_set_type(us_info->ucc_num, UCC_SPEED_TYPE_SLOW);
        if (ret) {
-               printk(KERN_ERR "%s: cannot set UCC type", __FUNCTION__);
+               printk(KERN_ERR "%s: cannot set UCC type", __func__);
                ucc_slow_free(uccs);
                return ret;
        }
@@ -209,7 +217,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
                qe_muram_alloc(us_info->rx_bd_ring_len * sizeof(struct qe_bd),
                                QE_ALIGNMENT_OF_BD);
        if (IS_ERR_VALUE(uccs->rx_base_offset)) {
-               printk(KERN_ERR "%s: cannot allocate %u RX BDs\n", __FUNCTION__,
+               printk(KERN_ERR "%s: cannot allocate %u RX BDs\n", __func__,
                        us_info->rx_bd_ring_len);
                uccs->rx_base_offset = 0;
                ucc_slow_free(uccs);
@@ -220,7 +228,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
                qe_muram_alloc(us_info->tx_bd_ring_len * sizeof(struct qe_bd),
                        QE_ALIGNMENT_OF_BD);
        if (IS_ERR_VALUE(uccs->tx_base_offset)) {
-               printk(KERN_ERR "%s: cannot allocate TX BDs", __FUNCTION__);
+               printk(KERN_ERR "%s: cannot allocate TX BDs", __func__);
                uccs->tx_base_offset = 0;
                ucc_slow_free(uccs);
                return -ENOMEM;
@@ -310,7 +318,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
                if (ucc_set_qe_mux_rxtx(us_info->ucc_num, us_info->rx_clock,
                                        COMM_DIR_RX)) {
                        printk(KERN_ERR "%s: illegal value for RX clock\n",
-                              __FUNCTION__);
+                              __func__);
                        ucc_slow_free(uccs);
                        return -EINVAL;
                }
@@ -318,7 +326,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
                if (ucc_set_qe_mux_rxtx(us_info->ucc_num, us_info->tx_clock,
                                        COMM_DIR_TX)) {
                        printk(KERN_ERR "%s: illegal value for TX clock\n",
-                              __FUNCTION__);
+                              __func__);
                        ucc_slow_free(uccs);
                        return -EINVAL;
                }
@@ -347,6 +355,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
        *uccs_ret = uccs;
        return 0;
 }
+EXPORT_SYMBOL(ucc_slow_init);
 
 void ucc_slow_free(struct ucc_slow_private * uccs)
 {
@@ -359,12 +368,13 @@ void ucc_slow_free(struct ucc_slow_private * uccs)
        if (uccs->tx_base_offset)
                qe_muram_free(uccs->tx_base_offset);
 
-       if (uccs->us_pram) {
+       if (uccs->us_pram)
                qe_muram_free(uccs->us_pram_offset);
-               uccs->us_pram = NULL;
-       }
+
+       if (uccs->us_regs)
+               iounmap(uccs->us_regs);
 
        kfree(uccs);
 }
-
+EXPORT_SYMBOL(ucc_slow_free);