arm: msm: smd: checkpatch clean up of smd/proc_comm
[safe/jmp/linux-2.6] / arch / arm / mach-msm / smd.c
index e33fd02..b864592 100644 (file)
 #include "smd_private.h"
 #include "proc_comm.h"
 
+#if defined(CONFIG_ARCH_QSD8X50)
+#define CONFIG_QDSP6 1
+#endif
+
 void (*msm_hw_reset_hook)(void);
 
 #define MODULE_NAME "msm_smd"
@@ -46,8 +50,7 @@ enum {
 
 static int msm_smd_debug_mask;
 
-struct shared_info
-{
+struct shared_info {
        int ready;
        unsigned state;
 };
@@ -61,27 +64,37 @@ static struct shared_info smd_info = {
 module_param_named(debug_mask, msm_smd_debug_mask,
                   int, S_IRUGO | S_IWUSR | S_IWGRP);
 
-void *smem_find(unsigned id, unsigned size);
-static void *smem_item(unsigned id, unsigned *size);
+void *smem_item(unsigned id, unsigned *size);
 static void smd_diag(void);
 
 static unsigned last_heap_free = 0xffffffff;
 
-#define MSM_A2M_INT(n) (MSM_CSR_BASE + 0x400 + (n) * 4)
+static inline void msm_a2m_int(uint32_t irq)
+{
+#if defined(CONFIG_ARCH_MSM7X30)
+       writel(1 << irq, MSM_GCC_BASE + 0x8);
+#else
+       writel(1, MSM_CSR_BASE + 0x400 + (irq * 4));
+#endif
+}
+
 
 static inline void notify_other_smsm(void)
 {
-       writel(1, MSM_A2M_INT(5));
+       msm_a2m_int(5);
+#ifdef CONFIG_QDSP6
+       msm_a2m_int(8);
+#endif
 }
 
 static inline void notify_modem_smd(void)
 {
-       writel(1, MSM_A2M_INT(0));
+       msm_a2m_int(0);
 }
 
 static inline void notify_dsp_smd(void)
 {
-       writel(1, MSM_A2M_INT(8));
+       msm_a2m_int(8);
 }
 
 static void smd_diag(void)
@@ -110,8 +123,6 @@ static void handle_modem_crash(void)
                ;
 }
 
-extern int (*msm_check_for_modem_crash)(void);
-
 uint32_t raw_smsm_get_state(enum smsm_state_item item)
 {
        return readl(smd_info.state + item * 4);
@@ -126,119 +137,34 @@ static int check_for_modem_crash(void)
        return 0;
 }
 
-#define SMD_SS_CLOSED          0x00000000
-#define SMD_SS_OPENING         0x00000001
-#define SMD_SS_OPENED          0x00000002
-#define SMD_SS_FLUSHING                0x00000003
-#define SMD_SS_CLOSING         0x00000004
-#define SMD_SS_RESET           0x00000005
-#define SMD_SS_RESET_OPENING   0x00000006
-
-#define SMD_BUF_SIZE           8192
-#define SMD_CHANNELS           64
-
-#define SMD_HEADER_SIZE                20
-
-
 /* the spinlock is used to synchronize between the
-** irq handler and code that mutates the channel
-** list or fiddles with channel state
-*/
-static DEFINE_SPINLOCK(smd_lock);
-static DEFINE_SPINLOCK(smem_lock);
+ * irq handler and code that mutates the channel
+ * list or fiddles with channel state
+ */
+DEFINE_SPINLOCK(smd_lock);
+DEFINE_SPINLOCK(smem_lock);
 
 /* the mutex is used during open() and close()
-** operations to avoid races while creating or
-** destroying smd_channel structures
-*/
+ * operations to avoid races while creating or
+ * destroying smd_channel structures
+ */
 static DEFINE_MUTEX(smd_creation_mutex);
 
 static int smd_initialized;
 
-struct smd_alloc_elm {
-       char name[20];
-       uint32_t cid;
-       uint32_t ctype;
-       uint32_t ref_count;
-};
-
-struct smd_half_channel {
-       unsigned state;
-       unsigned char fDSR;
-       unsigned char fCTS;
-       unsigned char fCD;
-       unsigned char fRI;
-       unsigned char fHEAD;
-       unsigned char fTAIL;
-       unsigned char fSTATE;
-       unsigned char fUNUSED;
-       unsigned tail;
-       unsigned head;
-} __attribute__((packed));
-
-struct smd_shared_v1 {
-       struct smd_half_channel ch0;
-       unsigned char data0[SMD_BUF_SIZE];
-       struct smd_half_channel ch1;
-       unsigned char data1[SMD_BUF_SIZE];
-};
-
-struct smd_shared_v2 {
-       struct smd_half_channel ch0;
-       struct smd_half_channel ch1;
-};     
-
-struct smd_channel {
-       volatile struct smd_half_channel *send;
-       volatile struct smd_half_channel *recv;
-       unsigned char *send_data;
-       unsigned char *recv_data;
-
-       unsigned fifo_mask;
-       unsigned fifo_size;
-       unsigned current_packet;
-       unsigned n;
-
-       struct list_head ch_list;
-
-       void *priv;
-       void (*notify)(void *priv, unsigned flags);
-
-       int (*read)(smd_channel_t *ch, void *data, int len);
-       int (*write)(smd_channel_t *ch, const void *data, int len);
-       int (*read_avail)(smd_channel_t *ch);
-       int (*write_avail)(smd_channel_t *ch);
-
-       void (*update_state)(smd_channel_t *ch);
-       unsigned last_state;
-       void (*notify_other_cpu)(void);
-       unsigned type;
-
-       char name[32];
-       struct platform_device pdev;
-};
-
-static LIST_HEAD(smd_ch_closed_list);
-static LIST_HEAD(smd_ch_list); /* todo: per-target lists */
+LIST_HEAD(smd_ch_closed_list);
+LIST_HEAD(smd_ch_list_modem);
+LIST_HEAD(smd_ch_list_dsp);
 
 static unsigned char smd_ch_allocated[64];
 static struct work_struct probe_work;
 
-#define SMD_TYPE_MASK          0x0FF
-#define SMD_TYPE_APPS_MODEM    0x000
-#define SMD_TYPE_APPS_DSP      0x001
-#define SMD_TYPE_MODEM_DSP     0x002
-
-#define SMD_KIND_MASK          0xF00
-#define SMD_KIND_UNKNOWN       0x000
-#define SMD_KIND_STREAM                0x100
-#define SMD_KIND_PACKET                0x200
-
-static void smd_alloc_channel(const char *name, uint32_t cid, uint32_t type);
+static int smd_alloc_channel(const char *name, uint32_t cid, uint32_t type);
 
 static void smd_channel_probe_worker(struct work_struct *work)
 {
        struct smd_alloc_elm *shared;
+       unsigned ctype;
        unsigned type;
        unsigned n;
 
@@ -254,35 +180,20 @@ static void smd_channel_probe_worker(struct work_struct *work)
                        continue;
                if (!shared[n].name[0])
                        continue;
+               ctype = shared[n].ctype;
+               type = ctype & SMD_TYPE_MASK;
+
+               /* DAL channels are stream but neither the modem,
+                * nor the DSP correctly indicate this.  Fixup manually.
+                */
+               if (!memcmp(shared[n].name, "DAL", 3))
+                       ctype = (ctype & (~SMD_KIND_MASK)) | SMD_KIND_STREAM;
+
                type = shared[n].ctype & SMD_TYPE_MASK;
                if ((type == SMD_TYPE_APPS_MODEM) ||
                    (type == SMD_TYPE_APPS_DSP))
-                       smd_alloc_channel(shared[n].name,
-                                         shared[n].cid,
-                                         shared[n].ctype);
-               smd_ch_allocated[n] = 1;
-       }
-}
-
-static char *chstate(unsigned n)
-{
-       switch (n) {
-       case SMD_SS_CLOSED:
-               return "CLOSED";
-       case SMD_SS_OPENING:
-               return "OPENING";
-       case SMD_SS_OPENED:
-               return "OPENED";
-       case SMD_SS_FLUSHING:
-               return "FLUSHING";
-       case SMD_SS_CLOSING:
-               return "CLOSING";
-       case SMD_SS_RESET:
-               return "RESET";
-       case SMD_SS_RESET_OPENING:
-               return "ROPENING";
-       default:
-               return "UNKNOWN";
+                       if (!smd_alloc_channel(shared[n].name, shared[n].cid, ctype))
+                               smd_ch_allocated[n] = 1;
        }
 }
 
@@ -341,13 +252,13 @@ static void ch_read_done(struct smd_channel *ch, unsigned count)
 {
        BUG_ON(count > smd_stream_read_avail(ch));
        ch->recv->tail = (ch->recv->tail + count) & ch->fifo_mask;
-       ch->recv->fTAIL = 1;
+       ch->send->fTAIL = 1;
 }
 
 /* basic read interface to ch_read_{buffer,done} used
-** by smd_*_read() and update_packet_state()
-** will read-and-discard if the _data pointer is null
-*/
+ * by smd_*_read() and update_packet_state()
+ * will read-and-discard if the _data pointer is null
+ */
 static int ch_read(struct smd_channel *ch, void *_data, int len)
 {
        void *ptr;
@@ -454,8 +365,7 @@ static void smd_state_change(struct smd_channel *ch,
 {
        ch->last_state = next;
 
-       pr_info("SMD: ch %d %s -> %s\n", ch->n,
-               chstate(last), chstate(next));
+       pr_info("SMD: ch %d %d -> %d\n", ch->n, last, next);
 
        switch (next) {
        case SMD_SS_OPENING:
@@ -515,67 +425,59 @@ static void handle_smd_irq(struct list_head *list, void (*notify)(void))
        do_smd_probe();
 }
 
-static irqreturn_t smd_irq_handler(int irq, void *data)
+static irqreturn_t smd_modem_irq_handler(int irq, void *data)
+{
+       handle_smd_irq(&smd_ch_list_modem, notify_modem_smd);
+       return IRQ_HANDLED;
+}
+
+static irqreturn_t smd_dsp_irq_handler(int irq, void *data)
 {
-       handle_smd_irq(&smd_ch_list, notify_modem_smd);
+       handle_smd_irq(&smd_ch_list_dsp, notify_dsp_smd);
        return IRQ_HANDLED;
 }
 
 static void smd_fake_irq_handler(unsigned long arg)
 {
-       smd_irq_handler(0, NULL);
+       handle_smd_irq(&smd_ch_list_modem, notify_modem_smd);
+       handle_smd_irq(&smd_ch_list_dsp, notify_dsp_smd);
 }
 
 static DECLARE_TASKLET(smd_fake_irq_tasklet, smd_fake_irq_handler, 0);
 
+static inline int smd_need_int(struct smd_channel *ch)
+{
+       if (ch_is_open(ch)) {
+               if (ch->recv->fHEAD || ch->recv->fTAIL || ch->recv->fSTATE)
+                       return 1;
+               if (ch->recv->state != ch->last_state)
+                       return 1;
+       }
+       return 0;
+}
+
 void smd_sleep_exit(void)
 {
        unsigned long flags;
        struct smd_channel *ch;
-       unsigned tmp;
        int need_int = 0;
 
        spin_lock_irqsave(&smd_lock, flags);
-       list_for_each_entry(ch, &smd_ch_list, ch_list) {
-               if (ch_is_open(ch)) {
-                       if (ch->recv->fHEAD) {
-                               if (msm_smd_debug_mask & MSM_SMD_DEBUG)
-                                       pr_info("smd_sleep_exit ch %d fHEAD "
-                                               "%x %x %x\n",
-                                               ch->n, ch->recv->fHEAD,
-                                               ch->recv->head, ch->recv->tail);
-                               need_int = 1;
-                               break;
-                       }
-                       if (ch->recv->fTAIL) {
-                               if (msm_smd_debug_mask & MSM_SMD_DEBUG)
-                                       pr_info("smd_sleep_exit ch %d fTAIL "
-                                               "%x %x %x\n",
-                                               ch->n, ch->recv->fTAIL,
-                                               ch->send->head, ch->send->tail);
-                               need_int = 1;
-                               break;
-                       }
-                       if (ch->recv->fSTATE) {
-                               if (msm_smd_debug_mask & MSM_SMD_DEBUG)
-                                       pr_info("smd_sleep_exit ch %d fSTATE %x"
-                                               "\n", ch->n, ch->recv->fSTATE);
-                               need_int = 1;
-                               break;
-                       }
-                       tmp = ch->recv->state;
-                       if (tmp != ch->last_state) {
-                               if (msm_smd_debug_mask & MSM_SMD_DEBUG)
-                                       pr_info("smd_sleep_exit ch %d "
-                                               "state %x != %x\n",
-                                               ch->n, tmp, ch->last_state);
-                               need_int = 1;
-                               break;
-                       }
+       list_for_each_entry(ch, &smd_ch_list_modem, ch_list) {
+               if (smd_need_int(ch)) {
+                       need_int = 1;
+                       break;
+               }
+       }
+       list_for_each_entry(ch, &smd_ch_list_dsp, ch_list) {
+               if (smd_need_int(ch)) {
+                       need_int = 1;
+                       break;
                }
        }
        spin_unlock_irqrestore(&smd_lock, flags);
        do_smd_probe();
+
        if (need_int) {
                if (msm_smd_debug_mask & MSM_SMD_DEBUG)
                        pr_info("smd_sleep_exit need interrupt\n");
@@ -745,20 +647,20 @@ static int smd_alloc_v1(struct smd_channel *ch)
 }
 
 
-static void smd_alloc_channel(const char *name, uint32_t cid, uint32_t type)
+static int smd_alloc_channel(const char *name, uint32_t cid, uint32_t type)
 {
        struct smd_channel *ch;
 
        ch = kzalloc(sizeof(struct smd_channel), GFP_KERNEL);
        if (ch == 0) {
                pr_err("smd_alloc_channel() out of memory\n");
-               return;
+               return -1;
        }
        ch->n = cid;
 
        if (smd_alloc_v2(ch) && smd_alloc_v1(ch)) {
                kfree(ch);
-               return;
+               return -1;
        }
 
        ch->fifo_mask = ch->fifo_size - 1;
@@ -800,6 +702,7 @@ static void smd_alloc_channel(const char *name, uint32_t cid, uint32_t type)
        mutex_unlock(&smd_creation_mutex);
 
        platform_device_register(&ch->pdev);
+       return 0;
 }
 
 static void do_nothing_notify(void *priv, unsigned flags)
@@ -849,7 +752,11 @@ int smd_open(const char *name, smd_channel_t **_ch,
        *_ch = ch;
 
        spin_lock_irqsave(&smd_lock, flags);
-       list_add(&ch->ch_list, &smd_ch_list);
+
+       if ((ch->type & SMD_TYPE_MASK) == SMD_TYPE_APPS_MODEM)
+               list_add(&ch->ch_list, &smd_ch_list_modem);
+       else
+               list_add(&ch->ch_list, &smd_ch_list_dsp);
 
        /* If the remote side is CLOSING, we need to get it to
         * move to OPENING (which we'll do by moving from CLOSED to
@@ -903,6 +810,16 @@ int smd_write(smd_channel_t *ch, const void *data, int len)
        return ch->write(ch, data, len);
 }
 
+int smd_write_atomic(smd_channel_t *ch, const void *data, int len)
+{
+       unsigned long flags;
+       int res;
+       spin_lock_irqsave(&smd_lock, flags);
+       res = ch->write(ch, data, len);
+       spin_unlock_irqrestore(&smd_lock, flags);
+       return res;
+}
+
 int smd_read_avail(smd_channel_t *ch)
 {
        return ch->read_avail(ch);
@@ -936,7 +853,7 @@ void *smem_alloc(unsigned id, unsigned size)
        return smem_find(id, size);
 }
 
-static void *smem_item(unsigned id, unsigned *size)
+void *smem_item(unsigned id, unsigned *size)
 {
        struct smem_shared *shared = (void *) MSM_SHARED_RAM_BASE;
        struct smem_heap_entry *toc = shared->heap_toc;
@@ -985,9 +902,9 @@ static irqreturn_t smsm_irq_handler(int irq, void *data)
 
        if (msm_smd_debug_mask & MSM_SMSM_DEBUG)
                pr_info("<SM %08x %08x>\n", apps, modm);
-       if (modm & SMSM_RESET) {
+       if (modm & SMSM_RESET)
                handle_modem_crash();
-       }
+
        do_smd_probe();
 
        spin_unlock_irqrestore(&smem_lock, flags);
@@ -1038,106 +955,43 @@ uint32_t smsm_get_state(enum smsm_state_item item)
        return rv;
 }
 
+#ifdef CONFIG_ARCH_MSM_SCORPION
+
 int smsm_set_sleep_duration(uint32_t delay)
 {
-       uint32_t *ptr;
+       struct msm_dem_slave_data *ptr;
 
-       ptr = smem_alloc(SMEM_SMSM_SLEEP_DELAY, sizeof(*ptr));
+       ptr = smem_find(SMEM_APPS_DEM_SLAVE_DATA, sizeof(*ptr));
        if (ptr == NULL) {
-               pr_err("smsm_set_sleep_duration <SM NO SLEEP_DELAY>\n");
+               pr_err("smsm_set_sleep_duration <SM NO APPS_DEM_SLAVE_DATA>\n");
                return -EIO;
        }
        if (msm_smd_debug_mask & MSM_SMSM_DEBUG)
                pr_info("smsm_set_sleep_duration %d -> %d\n",
-                      *ptr, delay);
-       *ptr = delay;
+                      ptr->sleep_time, delay);
+       ptr->sleep_time = delay;
        return 0;
 }
 
-int smsm_set_interrupt_info(struct smsm_interrupt_info *info)
+#else
+
+int smsm_set_sleep_duration(uint32_t delay)
 {
-       struct smsm_interrupt_info *ptr;
+       uint32_t *ptr;
 
-       ptr = smem_alloc(SMEM_SMSM_INT_INFO, sizeof(*ptr));
+       ptr = smem_find(SMEM_SMSM_SLEEP_DELAY, sizeof(*ptr));
        if (ptr == NULL) {
-               pr_err("smsm_set_sleep_duration <SM NO INT_INFO>\n");
+               pr_err("smsm_set_sleep_duration <SM NO SLEEP_DELAY>\n");
                return -EIO;
        }
        if (msm_smd_debug_mask & MSM_SMSM_DEBUG)
-               pr_info("smsm_set_interrupt_info %x %x -> %x %x\n",
-                      ptr->aArm_en_mask, ptr->aArm_interrupts_pending,
-                      info->aArm_en_mask, info->aArm_interrupts_pending);
-       *ptr = *info;
+               pr_info("smsm_set_sleep_duration %d -> %d\n",
+                      *ptr, delay);
+       *ptr = delay;
        return 0;
 }
 
-#define MAX_NUM_SLEEP_CLIENTS          64
-#define MAX_SLEEP_NAME_LEN             8
-
-#define NUM_GPIO_INT_REGISTERS         6
-#define GPIO_SMEM_NUM_GROUPS           2
-#define GPIO_SMEM_MAX_PC_INTERRUPTS    8
-
-struct tramp_gpio_save {
-       unsigned int enable;
-       unsigned int detect;
-       unsigned int polarity;
-};
-
-struct tramp_gpio_smem {
-       uint16_t num_fired[GPIO_SMEM_NUM_GROUPS];
-       uint16_t fired[GPIO_SMEM_NUM_GROUPS][GPIO_SMEM_MAX_PC_INTERRUPTS];
-       uint32_t enabled[NUM_GPIO_INT_REGISTERS];
-       uint32_t detection[NUM_GPIO_INT_REGISTERS];
-       uint32_t polarity[NUM_GPIO_INT_REGISTERS];
-};
-
-
-void smsm_print_sleep_info(void)
-{
-       unsigned long flags;
-       uint32_t *ptr;
-       struct tramp_gpio_smem *gpio;
-       struct smsm_interrupt_info *int_info;
-
-
-       spin_lock_irqsave(&smem_lock, flags);
-
-       ptr = smem_alloc(SMEM_SMSM_SLEEP_DELAY, sizeof(*ptr));
-       if (ptr)
-               pr_info("SMEM_SMSM_SLEEP_DELAY: %x\n", *ptr);
-
-       ptr = smem_alloc(SMEM_SMSM_LIMIT_SLEEP, sizeof(*ptr));
-       if (ptr)
-               pr_info("SMEM_SMSM_LIMIT_SLEEP: %x\n", *ptr);
-
-       ptr = smem_alloc(SMEM_SLEEP_POWER_COLLAPSE_DISABLED, sizeof(*ptr));
-       if (ptr)
-               pr_info("SMEM_SLEEP_POWER_COLLAPSE_DISABLED: %x\n", *ptr);
-
-       int_info = smem_alloc(SMEM_SMSM_INT_INFO, sizeof(*int_info));
-       if (int_info)
-               pr_info("SMEM_SMSM_INT_INFO %x %x %x\n",
-                       int_info->aArm_en_mask,
-                       int_info->aArm_interrupts_pending,
-                       int_info->aArm_wakeup_reason);
-
-       gpio = smem_alloc(SMEM_GPIO_INT, sizeof(*gpio));
-       if (gpio) {
-               int i;
-               for (i = 0; i < NUM_GPIO_INT_REGISTERS; i++)
-                       pr_info("SMEM_GPIO_INT: %d: e %x d %x p %x\n",
-                               i, gpio->enabled[i], gpio->detection[i],
-                               gpio->polarity[i]);
-
-               for (i = 0; i < GPIO_SMEM_NUM_GROUPS; i++)
-                       pr_info("SMEM_GPIO_INT: %d: f %d: %d %d...\n",
-                               i, gpio->num_fired[i], gpio->fired[i][0],
-                               gpio->fired[i][1]);
-       }
-
-       spin_unlock_irqrestore(&smem_lock, flags);
-}
+#endif
 
 int smd_core_init(void)
 {
@@ -1157,7 +1011,7 @@ int smd_core_init(void)
 
        smd_info.ready = 1;
 
-       r = request_irq(INT_A9_M2A_0, smd_irq_handler,
+       r = request_irq(INT_A9_M2A_0, smd_modem_irq_handler,
                        IRQF_TRIGGER_RISING, "smd_dev", 0);
        if (r < 0)
                return r;
@@ -1175,211 +1029,31 @@ int smd_core_init(void)
        if (r < 0)
                pr_err("smd_core_init: enable_irq_wake failed for A9_M2A_5\n");
 
+#if defined(CONFIG_QDSP6)
+       r = request_irq(INT_ADSP_A11, smd_dsp_irq_handler,
+                       IRQF_TRIGGER_RISING, "smd_dsp", 0);
+       if (r < 0) {
+               free_irq(INT_A9_M2A_0, 0);
+               free_irq(INT_A9_M2A_5, 0);
+               return r;
+       }
+#endif
+
        /* check for any SMD channels that may already exist */
        do_smd_probe();
 
        /* indicate that we're up and running */
        smsm_change_state(SMSM_STATE_APPS,
-                         ~0, SMSM_INIT | SMSM_SMDINIT | SMSM_RPCINIT);
+                         ~0, SMSM_INIT | SMSM_SMDINIT | SMSM_RPCINIT | SMSM_RUN);
+#ifdef CONFIG_ARCH_MSM_SCORPION
+       smsm_change_state(SMSM_STATE_APPS_DEM, ~0, 0);
+#endif
 
        pr_info("smd_core_init() done\n");
 
        return 0;
 }
 
-#if defined(CONFIG_DEBUG_FS)
-
-static int dump_ch(char *buf, int max, struct smd_channel *ch)
-{
-       volatile struct smd_half_channel *s = ch->send;
-       volatile struct smd_half_channel *r = ch->recv;
-
-       return scnprintf(
-               buf, max,
-               "ch%02d:"
-               " %8s(%05d/%05d) %c%c%c%c%c%c%c <->"
-               " %8s(%05d/%05d) %c%c%c%c%c%c%c\n", ch->n,
-               chstate(s->state), s->tail, s->head,
-               s->fDSR ? 'D' : 'd',
-               s->fCTS ? 'C' : 'c',
-               s->fCD ? 'C' : 'c',
-               s->fRI ? 'I' : 'i',
-               s->fHEAD ? 'W' : 'w',
-               s->fTAIL ? 'R' : 'r',
-               s->fSTATE ? 'S' : 's',
-               chstate(r->state), r->tail, r->head,
-               r->fDSR ? 'D' : 'd',
-               r->fCTS ? 'R' : 'r',
-               r->fCD ? 'C' : 'c',
-               r->fRI ? 'I' : 'i',
-               r->fHEAD ? 'W' : 'w',
-               r->fTAIL ? 'R' : 'r',
-               r->fSTATE ? 'S' : 's'
-               );
-}
-
-static int debug_read_stat(char *buf, int max)
-{
-       char *msg;
-       int i = 0;
-
-       msg = smem_find(ID_DIAG_ERR_MSG, SZ_DIAG_ERR_MSG);
-
-       if (raw_smsm_get_state(SMSM_STATE_MODEM) & SMSM_RESET)
-               i += scnprintf(buf + i, max - i,
-                              "smsm: ARM9 HAS CRASHED\n");
-
-       i += scnprintf(buf + i, max - i, "smsm: a9: %08x a11: %08x\n",
-                      raw_smsm_get_state(SMSM_STATE_MODEM),
-                      raw_smsm_get_state(SMSM_STATE_APPS));
-
-       if (msg) {
-               msg[SZ_DIAG_ERR_MSG - 1] = 0;
-               i += scnprintf(buf + i, max - i, "diag: '%s'\n", msg);
-       }
-       return i;
-}
-
-static int debug_read_mem(char *buf, int max)
-{
-       unsigned n;
-       struct smem_shared *shared = (void *) MSM_SHARED_RAM_BASE;
-       struct smem_heap_entry *toc = shared->heap_toc;
-       int i = 0;
-
-       i += scnprintf(buf + i, max - i,
-                      "heap: init=%d free=%d remain=%d\n",
-                      shared->heap_info.initialized,
-                      shared->heap_info.free_offset,
-                      shared->heap_info.heap_remaining);
-
-       for (n = 0; n < SMEM_NUM_ITEMS; n++) {
-               if (toc[n].allocated == 0)
-                       continue;
-               i += scnprintf(buf + i, max - i,
-                              "%04d: offset %08x size %08x\n",
-                              n, toc[n].offset, toc[n].size);
-       }
-       return i;
-}
-
-static int debug_read_ch(char *buf, int max)
-{
-       struct smd_channel *ch;
-       unsigned long flags;
-       int i = 0;
-
-       spin_lock_irqsave(&smd_lock, flags);
-       list_for_each_entry(ch, &smd_ch_list, ch_list)
-               i += dump_ch(buf + i, max - i, ch);
-       list_for_each_entry(ch, &smd_ch_closed_list, ch_list)
-               i += dump_ch(buf + i, max - i, ch);
-       spin_unlock_irqrestore(&smd_lock, flags);
-
-       return i;
-}
-
-static int debug_read_version(char *buf, int max)
-{
-       struct smem_shared *shared = (void *) MSM_SHARED_RAM_BASE;
-       unsigned version = shared->version[VERSION_MODEM];
-       return sprintf(buf, "%d.%d\n", version >> 16, version & 0xffff);
-}
-
-static int debug_read_build_id(char *buf, int max)
-{
-       unsigned size;
-       void *data;
-
-       data = smem_item(SMEM_HW_SW_BUILD_ID, &size);
-       if (!data)
-               return 0;
-
-       if (size >= max)
-               size = max;
-       memcpy(buf, data, size);
-
-       return size;
-}
-
-static int debug_read_alloc_tbl(char *buf, int max)
-{
-       struct smd_alloc_elm *shared;
-       int n, i = 0;
-
-       shared = smem_find(ID_CH_ALLOC_TBL, sizeof(*shared) * 64);
-
-       for (n = 0; n < 64; n++) {
-               if (shared[n].ref_count == 0)
-                       continue;
-               i += scnprintf(buf + i, max - i,
-                              "%03d: %-20s cid=%02d type=%03d "
-                              "kind=%02d ref_count=%d\n",
-                              n, shared[n].name, shared[n].cid,
-                              shared[n].ctype & 0xff,
-                              (shared[n].ctype >> 8) & 0xf,
-                              shared[n].ref_count);
-       }
-
-       return i;
-}
-
-static int debug_boom(char *buf, int max)
-{
-       unsigned ms = 5000;
-       msm_proc_comm(PCOM_RESET_MODEM, &ms, 0);
-       return 0;
-}
-
-#define DEBUG_BUFMAX 4096
-static char debug_buffer[DEBUG_BUFMAX];
-
-static ssize_t debug_read(struct file *file, char __user *buf,
-                         size_t count, loff_t *ppos)
-{
-       int (*fill)(char *buf, int max) = file->private_data;
-       int bsize = fill(debug_buffer, DEBUG_BUFMAX);
-       return simple_read_from_buffer(buf, count, ppos, debug_buffer, bsize);
-}
-
-static int debug_open(struct inode *inode, struct file *file)
-{
-       file->private_data = inode->i_private;
-       return 0;
-}
-
-static const struct file_operations debug_ops = {
-       .read = debug_read,
-       .open = debug_open,
-};
-
-static void debug_create(const char *name, mode_t mode,
-                        struct dentry *dent,
-                        int (*fill)(char *buf, int max))
-{
-       debugfs_create_file(name, mode, dent, fill, &debug_ops);
-}
-
-static void smd_debugfs_init(void)
-{
-       struct dentry *dent;
-
-       dent = debugfs_create_dir("smd", 0);
-       if (IS_ERR(dent))
-               return;
-
-       debug_create("ch", 0444, dent, debug_read_ch);
-       debug_create("stat", 0444, dent, debug_read_stat);
-       debug_create("mem", 0444, dent, debug_read_mem);
-       debug_create("version", 0444, dent, debug_read_version);
-       debug_create("tbl", 0444, dent, debug_read_alloc_tbl);
-       debug_create("build", 0444, dent, debug_read_build_id);
-       debug_create("boom", 0444, dent, debug_boom);
-}
-#else
-static void smd_debugfs_init(void) {}
-#endif
-
 static int __init msm_smd_probe(struct platform_device *pdev)
 {
        pr_info("smd_init()\n");
@@ -1395,7 +1069,8 @@ static int __init msm_smd_probe(struct platform_device *pdev)
 
        msm_check_for_modem_crash = check_for_modem_crash;
 
-       smd_debugfs_init();
+       msm_init_last_radio_log(THIS_MODULE);
+
        smd_initialized = 1;
 
        return 0;