You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/10/06 15:32:54 UTC

[GitHub] [incubator-nuttx] acassis commented on a diff in pull request #7248: drivers: modem: update altair modem

acassis commented on code in PR #7248:
URL: https://github.com/apache/incubator-nuttx/pull/7248#discussion_r989190457


##########
drivers/modem/alt1250/alt1250.c:
##########
@@ -0,0 +1,1279 @@
+/****************************************************************************
+ * drivers/modem/alt1250/alt1250.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/kmalloc.h>
+#include <nuttx/fs/fs.h>
+#include <poll.h>
+#include <errno.h>
+#include <nuttx/wireless/lte/lte_ioctl.h>
+#include <nuttx/modem/alt1250.h>
+#include <assert.h>
+
+#include "altcom_pkt.h"
+#include "altcom_hdlr.h"
+#include "altmdm.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define WRITE_OK 0
+#define WRITE_NG 1
+
+#define rel_evtbufinst(inst, dev) unlock_evtbufinst(inst, dev)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* Character driver methods. */
+
+static int alt1250_open(FAR struct file *filep);
+static int alt1250_close(FAR struct file *filep);
+static ssize_t alt1250_read(FAR struct file *filep, FAR char *buffer,
+  size_t len);
+static int alt1250_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
+static int alt1250_poll(FAR struct file *filep, struct pollfd *fds,
+  bool setup);
+
+parse_handler_t alt1250_additional_parsehdlr(uint16_t, uint8_t);
+compose_handler_t alt1250_additional_composehdlr(uint32_t,
+    FAR uint8_t *, size_t);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* This the vtable that supports the character driver interface. */
+
+static const struct file_operations g_alt1250fops =
+{
+  alt1250_open,  /* open */
+  alt1250_close, /* close */
+  alt1250_read,  /* read */
+  0,             /* write */
+  0,             /* seek */
+  alt1250_ioctl, /* ioctl */
+  alt1250_poll,  /* poll */
+};
+static uint8_t g_recvbuff[ALTCOM_RX_PKT_SIZE_MAX];
+static uint8_t g_sendbuff[ALTCOM_PKT_SIZE_MAX];
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: add_list
+ ****************************************************************************/
+
+static void add_list(FAR struct alt_queue_s *head,
+  FAR struct alt_container_s *list)
+{
+  FAR struct alt_container_s *next;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  while (list != NULL)
+    {
+      next = (FAR struct alt_container_s *)sq_next(&list->node);
+
+      sq_next(&list->node) = NULL;
+      sq_addlast(&list->node, &head->queue);
+
+      list = next;
+    }
+
+  nxsem_post(&head->lock);
+}
+
+/****************************************************************************
+ * Name: remove_list_all
+ ****************************************************************************/
+
+static FAR struct alt_container_s *remove_list_all(
+  FAR struct alt_queue_s *head)
+{
+  FAR struct alt_container_s *list;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  list = (FAR struct alt_container_s *)sq_peek(&head->queue);
+  sq_init(&head->queue);
+
+  nxsem_post(&head->lock);
+
+  return list;
+}
+
+/****************************************************************************
+ * Name: remove_list
+ ****************************************************************************/
+
+static FAR struct alt_container_s *remove_list(FAR struct alt_queue_s *head,
+  uint16_t cmdid, uint16_t transid)
+{
+  FAR struct alt_container_s *list;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  list = (FAR struct alt_container_s *)sq_peek(&head->queue);
+  while (list != NULL)
+    {
+      if ((list->altcid == cmdid) && (list->alttid == transid))
+        {
+          sq_rem(&list->node, &head->queue);
+          sq_next(&list->node) = NULL;
+          break;
+        }
+
+      list = (FAR struct alt_container_s *)sq_next(&list->node);
+    }
+
+  nxsem_post(&head->lock);
+
+  return list;
+}
+
+/****************************************************************************
+ * Name: set_senddisable
+ ****************************************************************************/
+
+static void set_senddisable(FAR struct alt1250_dev_s *dev, bool disable)
+{
+  nxsem_wait_uninterruptible(&dev->senddisablelock);
+
+  dev->senddisable = disable;
+
+  nxsem_post(&dev->senddisablelock);
+}
+
+/****************************************************************************
+ * Name: is_senddisable
+ ****************************************************************************/
+
+static bool is_senddisable(FAR struct alt1250_dev_s *dev)
+{
+  bool disable;
+
+  nxsem_wait_uninterruptible(&dev->senddisablelock);
+
+  disable = dev->senddisable;
+
+  nxsem_post(&dev->senddisablelock);
+
+  return disable;
+}
+
+/****************************************************************************
+ * Name: read_evtbitmap
+ ****************************************************************************/
+
+static ssize_t read_data(FAR struct alt1250_dev_s *dev,
+  FAR struct alt_readdata_s *rdata)
+{
+  int idx;
+
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  /* change status to NOT WRITABLE */
+
+  for (idx = 0; idx < (sizeof(uint64_t) * 8); idx++)
+    {
+      if (dev->evtbitmap & (1ULL << idx))
+        {
+          if (dev->evtbuff->ninst >= idx)
+            {
+              FAR alt_evtbuf_inst_t *inst = &dev->evtbuff->inst[idx];
+
+              nxsem_wait_uninterruptible(&inst->stat_lock);
+
+              inst->stat = ALTEVTBUF_ST_NOTWRITABLE;
+
+              nxsem_post(&inst->stat_lock);
+            }
+        }
+    }
+
+  rdata->evtbitmap = dev->evtbitmap;
+  rdata->head = remove_list_all(&dev->replylist);
+
+  if (dev->evtbitmap & ALT1250_EVTBIT_RESET)
+    {
+      /* Resume sending because daemon has been notified of the reset
+       * reliably.
+       */
+
+      set_senddisable(dev, false);
+    }
+
+  dev->evtbitmap = 0ULL;
+
+  nxsem_post(&dev->evtmaplock);
+
+  return sizeof(struct alt_readdata_s);
+}
+
+/****************************************************************************
+ * Name: write_evtbitmap
+ ****************************************************************************/
+
+static void write_evtbitmap(FAR struct alt1250_dev_s *dev,
+  uint64_t bitmap)
+{
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  dev->evtbitmap |= bitmap;
+
+  if (dev->evtbitmap & ALT1250_EVTBIT_RESET)

Review Comment:
   It should be a good idea to explain that when reset bit is enabled all remaining bits are ignored and only reset bit will be kept.



##########
drivers/modem/alt1250/alt1250.c:
##########
@@ -0,0 +1,1279 @@
+/****************************************************************************
+ * drivers/modem/alt1250/alt1250.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/kmalloc.h>
+#include <nuttx/fs/fs.h>
+#include <poll.h>
+#include <errno.h>
+#include <nuttx/wireless/lte/lte_ioctl.h>
+#include <nuttx/modem/alt1250.h>
+#include <assert.h>
+
+#include "altcom_pkt.h"
+#include "altcom_hdlr.h"
+#include "altmdm.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define WRITE_OK 0
+#define WRITE_NG 1
+
+#define rel_evtbufinst(inst, dev) unlock_evtbufinst(inst, dev)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* Character driver methods. */
+
+static int alt1250_open(FAR struct file *filep);
+static int alt1250_close(FAR struct file *filep);
+static ssize_t alt1250_read(FAR struct file *filep, FAR char *buffer,
+  size_t len);
+static int alt1250_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
+static int alt1250_poll(FAR struct file *filep, struct pollfd *fds,
+  bool setup);
+
+parse_handler_t alt1250_additional_parsehdlr(uint16_t, uint8_t);
+compose_handler_t alt1250_additional_composehdlr(uint32_t,
+    FAR uint8_t *, size_t);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* This the vtable that supports the character driver interface. */
+
+static const struct file_operations g_alt1250fops =
+{
+  alt1250_open,  /* open */
+  alt1250_close, /* close */
+  alt1250_read,  /* read */
+  0,             /* write */
+  0,             /* seek */
+  alt1250_ioctl, /* ioctl */
+  alt1250_poll,  /* poll */
+};
+static uint8_t g_recvbuff[ALTCOM_RX_PKT_SIZE_MAX];
+static uint8_t g_sendbuff[ALTCOM_PKT_SIZE_MAX];
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: add_list
+ ****************************************************************************/
+
+static void add_list(FAR struct alt_queue_s *head,
+  FAR struct alt_container_s *list)
+{
+  FAR struct alt_container_s *next;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  while (list != NULL)
+    {
+      next = (FAR struct alt_container_s *)sq_next(&list->node);
+
+      sq_next(&list->node) = NULL;
+      sq_addlast(&list->node, &head->queue);
+
+      list = next;
+    }
+
+  nxsem_post(&head->lock);
+}
+
+/****************************************************************************
+ * Name: remove_list_all
+ ****************************************************************************/
+
+static FAR struct alt_container_s *remove_list_all(
+  FAR struct alt_queue_s *head)
+{
+  FAR struct alt_container_s *list;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  list = (FAR struct alt_container_s *)sq_peek(&head->queue);
+  sq_init(&head->queue);
+
+  nxsem_post(&head->lock);
+
+  return list;
+}
+
+/****************************************************************************
+ * Name: remove_list
+ ****************************************************************************/
+
+static FAR struct alt_container_s *remove_list(FAR struct alt_queue_s *head,
+  uint16_t cmdid, uint16_t transid)
+{
+  FAR struct alt_container_s *list;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  list = (FAR struct alt_container_s *)sq_peek(&head->queue);
+  while (list != NULL)
+    {
+      if ((list->altcid == cmdid) && (list->alttid == transid))
+        {
+          sq_rem(&list->node, &head->queue);
+          sq_next(&list->node) = NULL;
+          break;
+        }
+
+      list = (FAR struct alt_container_s *)sq_next(&list->node);
+    }
+
+  nxsem_post(&head->lock);
+
+  return list;
+}
+
+/****************************************************************************
+ * Name: set_senddisable
+ ****************************************************************************/
+
+static void set_senddisable(FAR struct alt1250_dev_s *dev, bool disable)
+{
+  nxsem_wait_uninterruptible(&dev->senddisablelock);
+
+  dev->senddisable = disable;
+
+  nxsem_post(&dev->senddisablelock);
+}
+
+/****************************************************************************
+ * Name: is_senddisable
+ ****************************************************************************/
+
+static bool is_senddisable(FAR struct alt1250_dev_s *dev)
+{
+  bool disable;
+
+  nxsem_wait_uninterruptible(&dev->senddisablelock);
+
+  disable = dev->senddisable;
+
+  nxsem_post(&dev->senddisablelock);
+
+  return disable;
+}
+
+/****************************************************************************
+ * Name: read_evtbitmap
+ ****************************************************************************/
+
+static ssize_t read_data(FAR struct alt1250_dev_s *dev,
+  FAR struct alt_readdata_s *rdata)
+{
+  int idx;
+
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  /* change status to NOT WRITABLE */
+
+  for (idx = 0; idx < (sizeof(uint64_t) * 8); idx++)
+    {
+      if (dev->evtbitmap & (1ULL << idx))
+        {
+          if (dev->evtbuff->ninst >= idx)
+            {
+              FAR alt_evtbuf_inst_t *inst = &dev->evtbuff->inst[idx];
+
+              nxsem_wait_uninterruptible(&inst->stat_lock);
+
+              inst->stat = ALTEVTBUF_ST_NOTWRITABLE;
+
+              nxsem_post(&inst->stat_lock);
+            }
+        }
+    }
+
+  rdata->evtbitmap = dev->evtbitmap;
+  rdata->head = remove_list_all(&dev->replylist);
+
+  if (dev->evtbitmap & ALT1250_EVTBIT_RESET)
+    {
+      /* Resume sending because daemon has been notified of the reset
+       * reliably.
+       */
+
+      set_senddisable(dev, false);
+    }
+
+  dev->evtbitmap = 0ULL;
+
+  nxsem_post(&dev->evtmaplock);
+
+  return sizeof(struct alt_readdata_s);
+}
+
+/****************************************************************************
+ * Name: write_evtbitmap
+ ****************************************************************************/
+
+static void write_evtbitmap(FAR struct alt1250_dev_s *dev,
+  uint64_t bitmap)
+{
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  dev->evtbitmap |= bitmap;
+
+  if (dev->evtbitmap & ALT1250_EVTBIT_RESET)
+    {
+      dev->evtbitmap = ALT1250_EVTBIT_RESET;
+    }
+
+  m_info("write bitmap: 0x%llx\n", bitmap);
+
+  nxsem_post(&dev->evtmaplock);
+}
+
+/****************************************************************************
+ * Name: write_evtbitmapwithlist
+ ****************************************************************************/
+
+static void write_evtbitmapwithlist(FAR struct alt1250_dev_s *dev,
+  uint64_t bitmap, FAR struct alt_container_s *container)
+{
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  dev->evtbitmap |= bitmap;
+
+  if (dev->evtbitmap & ALT1250_EVTBIT_RESET)
+    {
+      dev->evtbitmap = ALT1250_EVTBIT_RESET;
+    }
+
+  add_list(&dev->replylist, container);
+
+  nxsem_post(&dev->evtmaplock);
+}
+
+/****************************************************************************
+ * Name: add_evtbuff
+ ****************************************************************************/
+
+static void add_evtbuff(FAR struct alt1250_dev_s *dev,
+  FAR struct alt_evtbuffer_s *buff)
+{
+  dev->evtbuff = buff;
+}
+
+/****************************************************************************
+ * Name: write_evtbuff_byidx
+ ****************************************************************************/
+
+static int write_evtbuff_byidx(FAR struct alt1250_dev_s *dev,
+  uint64_t idx, void(*write_func)(FAR void *outp[], FAR void *inp),
+  FAR void *inp)
+{
+  int ret = WRITE_NG;
+
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  if (dev->evtbuff)
+    {
+      if (dev->evtbuff->ninst >= idx)
+        {
+          FAR alt_evtbuf_inst_t *inst = &dev->evtbuff->inst[idx];
+
+          nxsem_wait_uninterruptible(&inst->stat_lock);
+          if (inst->stat == ALTEVTBUF_ST_WRITABLE)
+            {
+              write_func(inst->outparam, inp);
+              dev->evtbitmap |= (1ULL << idx);
+              ret = WRITE_OK;
+            }
+
+          nxsem_post(&inst->stat_lock);
+        }
+    }
+
+  nxsem_post(&dev->evtmaplock);
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: lock_evtbuffinst
+ ****************************************************************************/
+
+static void lock_evtbuffinst(FAR alt_evtbuf_inst_t *inst,
+  FAR struct alt1250_dev_s *dev)
+{
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+  nxsem_wait_uninterruptible(&inst->stat_lock);
+}
+
+/****************************************************************************
+ * Name: unlock_evtbufinst
+ ****************************************************************************/
+
+static void unlock_evtbufinst(FAR alt_evtbuf_inst_t *inst,
+  FAR struct alt1250_dev_s *dev)
+{
+  nxsem_post(&inst->stat_lock);
+  nxsem_post(&dev->evtmaplock);
+}
+
+/****************************************************************************
+ * Name: search_evtbufinst
+ ****************************************************************************/
+
+static FAR alt_evtbuf_inst_t *search_evtbufinst(uint16_t cid,
+  FAR uint64_t *bitmap, FAR struct alt1250_dev_s *dev)
+{
+  FAR alt_evtbuf_inst_t *ret = NULL;
+  unsigned int i;
+
+  *bitmap = 0ULL;
+
+  for (i = 0; i < dev->evtbuff->ninst; i++)
+    {
+      ret = &dev->evtbuff->inst[i];
+
+      if (ret->altcid == cid)
+        {
+          *bitmap = 1ULL << i;
+          return ret;
+        }
+    }
+
+  return NULL;
+}
+
+/****************************************************************************
+ * Name: cid_to_searchable
+ ****************************************************************************/
+
+static uint16_t cid_to_searchable(uint16_t cid, uint8_t altver)
+{
+  uint16_t cidv1;
+
+  cid &= ~ALTCOM_CMDID_REPLY_BIT;
+  if (altver == ALTCOM_VER4)
+    {
+      /* Change the command ID to Version 1
+       * Even if it cannot be converted, try to search the table
+       * using the original command ID.
+       */
+
+      cidv1 = convert_cid2v1(cid);
+      if (cidv1 != APICMDID_UNKNOWN)
+        {
+          cid = cidv1;
+        }
+    }
+
+  return cid;
+}
+
+/****************************************************************************
+ * Name: get_bitmap
+ ****************************************************************************/
+
+static uint64_t get_bitmap(FAR struct alt1250_dev_s *dev, uint16_t cid,
+  uint8_t altver)
+{
+  uint64_t bitmap = 0ULL;
+
+  cid = cid_to_searchable(cid, altver);
+
+  search_evtbufinst(cid, &bitmap, dev);
+
+  return bitmap;
+}
+
+/****************************************************************************
+ * Name: get_evtbuffinst_withlock
+ ****************************************************************************/
+
+static FAR alt_evtbuf_inst_t *get_evtbuffinst_withlock(
+  FAR struct alt1250_dev_s *dev, uint16_t cid, uint8_t altver,
+  FAR uint64_t *bitmap)
+{
+  FAR alt_evtbuf_inst_t *inst = NULL;
+  FAR alt_evtbuf_inst_t *ret = NULL;
+
+  cid = cid_to_searchable(cid, altver);
+
+  if (cid == APICMDID_SOCK_SELECT)
+    {
+      ret = &dev->select_inst;
+
+      lock_evtbuffinst(ret, dev);
+
+      ret->outparam = dev->select_container->outparam;
+      ret->outparamlen = dev->select_container->outparamlen;
+
+      search_evtbufinst(cid, bitmap, dev);
+    }
+  else
+    {
+      inst = search_evtbufinst(cid, bitmap, dev);
+      if (inst)
+        {
+          lock_evtbuffinst(inst, dev);
+
+          if (inst->stat == ALTEVTBUF_ST_WRITABLE)
+            {
+              ret = inst;
+            }
+          else
+            {
+              unlock_evtbufinst(inst, dev);
+            }
+        }
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: write_restart_param
+ ****************************************************************************/
+
+static void write_restart_param(FAR void *outp[], FAR void *buff)
+{
+  FAR int *out_reason = (FAR int *)outp[0];
+  FAR int *in_reason = (FAR int *)buff;
+
+  *out_reason = *in_reason;
+}
+
+/****************************************************************************
+ * Name: pollnotify
+ ****************************************************************************/
+
+static void pollnotify(FAR struct alt1250_dev_s *dev)
+{
+  nxsem_wait_uninterruptible(&dev->pfdlock);
+
+  if (dev->pfd)
+    {
+      /* If poll() waits, notify  */
+
+      poll_notify(&dev->pfd, 1, POLLIN);
+    }
+
+  nxsem_post(&dev->pfdlock);
+}
+
+/****************************************************************************
+ * Name: get_composehdlr
+ ****************************************************************************/
+
+compose_handler_t get_composehdlr(uint32_t cmdid, FAR uint8_t *payload,
+  size_t size)
+{
+  compose_handler_t ret = NULL;
+
+  ret = alt1250_composehdlr(cmdid);
+
+#ifdef CONFIG_MODEM_ALT1250_ADDITIONAL_FUNC
+  if (ret == NULL)
+    {
+      ret = alt1250_additional_composehdlr(cmdid, payload, size);
+    }
+#endif
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: get_parsehdlr
+ ****************************************************************************/
+
+parse_handler_t get_parsehdlr(uint16_t altcid, uint8_t altver)
+{
+  parse_handler_t ret = NULL;
+
+  ret = alt1250_parsehdlr(altcid, altver);
+
+#ifdef CONFIG_MODEM_ALT1250_ADDITIONAL_FUNC
+  if (ret == NULL)
+    {
+      ret = alt1250_additional_parsehdlr(altcid, altver);
+    }
+#endif
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: alt1250_power_control
+ ****************************************************************************/
+
+static int alt1250_power_control(FAR struct alt1250_dev_s *dev,
+  FAR struct alt_power_s *req)
+{
+  int ret = OK;
+
+  switch (req->cmdid)
+    {
+      case LTE_CMDID_POWERON:
+        ret = altmdm_poweron();
+        break;
+
+      case LTE_CMDID_POWEROFF:
+        ret = altmdm_poweroff();
+        break;
+
+      case LTE_CMDID_TAKEWLOCK:
+        ret = altmdm_take_wlock();
+        break;
+
+      case LTE_CMDID_GIVEWLOCK:
+        ret = altmdm_give_wlock();
+        break;
+
+      default:
+        ret = -EINVAL;
+        break;
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: make_altcomcmd_and_send
+ ****************************************************************************/
+
+static int make_altcomcmd_and_send(FAR struct alt1250_dev_s *dev,
+  FAR alt_container_t *req)
+{
+  int ret = OK;
+  compose_handler_t handler;
+  uint8_t altver;
+  uint16_t cid;
+  uint16_t tid;
+  FAR uint8_t *payload;
+  int remainlen;
+  int pos;
+
+  m_info("send request: command ID=0x%08lx\n", req->cmdid);
+
+  payload = get_payload((FAR struct altcom_cmdhdr_s *)g_sendbuff);
+
+  handler = get_composehdlr(req->cmdid & ~LTE_CMDOPT_ASYNC_BIT, payload,
+    ALTCOM_PAYLOAD_SIZE_MAX);

Review Comment:
   please align



##########
drivers/modem/alt1250/Kconfig:
##########
@@ -0,0 +1,33 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+menuconfig MODEM_ALT1250
+	bool "ALT1250 modem support"
+	default n
+	select SPI
+	select NET
+	select NETDEV_MODEM_LTE_IOCTL
+	---help---
+		Enable driver for the ALT1250 modem.
+
+if MODEM_ALT1250
+
+config MODEM_ALT1250_ADDITIONAL_FUNC
+	bool
+	default n

Review Comment:
   This config is not used, please remove



##########
drivers/modem/alt1250/alt1250.c:
##########
@@ -0,0 +1,1279 @@
+/****************************************************************************
+ * drivers/modem/alt1250/alt1250.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/kmalloc.h>
+#include <nuttx/fs/fs.h>
+#include <poll.h>
+#include <errno.h>
+#include <nuttx/wireless/lte/lte_ioctl.h>
+#include <nuttx/modem/alt1250.h>
+#include <assert.h>
+
+#include "altcom_pkt.h"
+#include "altcom_hdlr.h"
+#include "altmdm.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define WRITE_OK 0
+#define WRITE_NG 1
+
+#define rel_evtbufinst(inst, dev) unlock_evtbufinst(inst, dev)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* Character driver methods. */
+
+static int alt1250_open(FAR struct file *filep);
+static int alt1250_close(FAR struct file *filep);
+static ssize_t alt1250_read(FAR struct file *filep, FAR char *buffer,
+  size_t len);
+static int alt1250_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
+static int alt1250_poll(FAR struct file *filep, struct pollfd *fds,
+  bool setup);
+
+parse_handler_t alt1250_additional_parsehdlr(uint16_t, uint8_t);
+compose_handler_t alt1250_additional_composehdlr(uint32_t,
+    FAR uint8_t *, size_t);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* This the vtable that supports the character driver interface. */
+
+static const struct file_operations g_alt1250fops =
+{
+  alt1250_open,  /* open */
+  alt1250_close, /* close */
+  alt1250_read,  /* read */
+  0,             /* write */
+  0,             /* seek */
+  alt1250_ioctl, /* ioctl */
+  alt1250_poll,  /* poll */
+};
+static uint8_t g_recvbuff[ALTCOM_RX_PKT_SIZE_MAX];
+static uint8_t g_sendbuff[ALTCOM_PKT_SIZE_MAX];
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: add_list
+ ****************************************************************************/
+
+static void add_list(FAR struct alt_queue_s *head,
+  FAR struct alt_container_s *list)
+{
+  FAR struct alt_container_s *next;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  while (list != NULL)
+    {
+      next = (FAR struct alt_container_s *)sq_next(&list->node);
+
+      sq_next(&list->node) = NULL;
+      sq_addlast(&list->node, &head->queue);
+
+      list = next;
+    }
+
+  nxsem_post(&head->lock);
+}
+
+/****************************************************************************
+ * Name: remove_list_all
+ ****************************************************************************/
+
+static FAR struct alt_container_s *remove_list_all(
+  FAR struct alt_queue_s *head)
+{
+  FAR struct alt_container_s *list;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  list = (FAR struct alt_container_s *)sq_peek(&head->queue);
+  sq_init(&head->queue);
+
+  nxsem_post(&head->lock);
+
+  return list;
+}
+
+/****************************************************************************
+ * Name: remove_list
+ ****************************************************************************/
+
+static FAR struct alt_container_s *remove_list(FAR struct alt_queue_s *head,
+  uint16_t cmdid, uint16_t transid)
+{
+  FAR struct alt_container_s *list;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  list = (FAR struct alt_container_s *)sq_peek(&head->queue);
+  while (list != NULL)
+    {
+      if ((list->altcid == cmdid) && (list->alttid == transid))
+        {
+          sq_rem(&list->node, &head->queue);
+          sq_next(&list->node) = NULL;
+          break;
+        }
+
+      list = (FAR struct alt_container_s *)sq_next(&list->node);
+    }
+
+  nxsem_post(&head->lock);
+
+  return list;
+}
+
+/****************************************************************************
+ * Name: set_senddisable
+ ****************************************************************************/
+
+static void set_senddisable(FAR struct alt1250_dev_s *dev, bool disable)
+{
+  nxsem_wait_uninterruptible(&dev->senddisablelock);
+
+  dev->senddisable = disable;
+
+  nxsem_post(&dev->senddisablelock);
+}
+
+/****************************************************************************
+ * Name: is_senddisable
+ ****************************************************************************/
+
+static bool is_senddisable(FAR struct alt1250_dev_s *dev)
+{
+  bool disable;
+
+  nxsem_wait_uninterruptible(&dev->senddisablelock);
+
+  disable = dev->senddisable;
+
+  nxsem_post(&dev->senddisablelock);
+
+  return disable;
+}
+
+/****************************************************************************
+ * Name: read_evtbitmap
+ ****************************************************************************/
+
+static ssize_t read_data(FAR struct alt1250_dev_s *dev,
+  FAR struct alt_readdata_s *rdata)
+{
+  int idx;
+
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  /* change status to NOT WRITABLE */
+
+  for (idx = 0; idx < (sizeof(uint64_t) * 8); idx++)
+    {
+      if (dev->evtbitmap & (1ULL << idx))
+        {
+          if (dev->evtbuff->ninst >= idx)
+            {
+              FAR alt_evtbuf_inst_t *inst = &dev->evtbuff->inst[idx];
+
+              nxsem_wait_uninterruptible(&inst->stat_lock);
+
+              inst->stat = ALTEVTBUF_ST_NOTWRITABLE;
+
+              nxsem_post(&inst->stat_lock);
+            }
+        }
+    }
+
+  rdata->evtbitmap = dev->evtbitmap;
+  rdata->head = remove_list_all(&dev->replylist);
+
+  if (dev->evtbitmap & ALT1250_EVTBIT_RESET)
+    {
+      /* Resume sending because daemon has been notified of the reset
+       * reliably.
+       */
+
+      set_senddisable(dev, false);
+    }
+
+  dev->evtbitmap = 0ULL;
+
+  nxsem_post(&dev->evtmaplock);
+
+  return sizeof(struct alt_readdata_s);
+}
+
+/****************************************************************************
+ * Name: write_evtbitmap
+ ****************************************************************************/
+
+static void write_evtbitmap(FAR struct alt1250_dev_s *dev,
+  uint64_t bitmap)
+{
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  dev->evtbitmap |= bitmap;
+
+  if (dev->evtbitmap & ALT1250_EVTBIT_RESET)
+    {
+      dev->evtbitmap = ALT1250_EVTBIT_RESET;
+    }
+
+  m_info("write bitmap: 0x%llx\n", bitmap);
+
+  nxsem_post(&dev->evtmaplock);
+}
+
+/****************************************************************************
+ * Name: write_evtbitmapwithlist
+ ****************************************************************************/
+
+static void write_evtbitmapwithlist(FAR struct alt1250_dev_s *dev,
+  uint64_t bitmap, FAR struct alt_container_s *container)
+{
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  dev->evtbitmap |= bitmap;
+
+  if (dev->evtbitmap & ALT1250_EVTBIT_RESET)
+    {
+      dev->evtbitmap = ALT1250_EVTBIT_RESET;
+    }
+
+  add_list(&dev->replylist, container);
+
+  nxsem_post(&dev->evtmaplock);
+}
+
+/****************************************************************************
+ * Name: add_evtbuff
+ ****************************************************************************/
+
+static void add_evtbuff(FAR struct alt1250_dev_s *dev,
+  FAR struct alt_evtbuffer_s *buff)
+{
+  dev->evtbuff = buff;
+}
+
+/****************************************************************************
+ * Name: write_evtbuff_byidx
+ ****************************************************************************/
+
+static int write_evtbuff_byidx(FAR struct alt1250_dev_s *dev,
+  uint64_t idx, void(*write_func)(FAR void *outp[], FAR void *inp),
+  FAR void *inp)
+{
+  int ret = WRITE_NG;
+
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  if (dev->evtbuff)
+    {
+      if (dev->evtbuff->ninst >= idx)
+        {
+          FAR alt_evtbuf_inst_t *inst = &dev->evtbuff->inst[idx];
+
+          nxsem_wait_uninterruptible(&inst->stat_lock);
+          if (inst->stat == ALTEVTBUF_ST_WRITABLE)
+            {
+              write_func(inst->outparam, inp);
+              dev->evtbitmap |= (1ULL << idx);
+              ret = WRITE_OK;
+            }
+
+          nxsem_post(&inst->stat_lock);
+        }
+    }
+
+  nxsem_post(&dev->evtmaplock);
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: lock_evtbuffinst
+ ****************************************************************************/
+
+static void lock_evtbuffinst(FAR alt_evtbuf_inst_t *inst,
+  FAR struct alt1250_dev_s *dev)
+{
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+  nxsem_wait_uninterruptible(&inst->stat_lock);
+}
+
+/****************************************************************************
+ * Name: unlock_evtbufinst
+ ****************************************************************************/
+
+static void unlock_evtbufinst(FAR alt_evtbuf_inst_t *inst,
+  FAR struct alt1250_dev_s *dev)
+{
+  nxsem_post(&inst->stat_lock);
+  nxsem_post(&dev->evtmaplock);
+}
+
+/****************************************************************************
+ * Name: search_evtbufinst
+ ****************************************************************************/
+
+static FAR alt_evtbuf_inst_t *search_evtbufinst(uint16_t cid,
+  FAR uint64_t *bitmap, FAR struct alt1250_dev_s *dev)
+{
+  FAR alt_evtbuf_inst_t *ret = NULL;
+  unsigned int i;
+
+  *bitmap = 0ULL;
+
+  for (i = 0; i < dev->evtbuff->ninst; i++)
+    {
+      ret = &dev->evtbuff->inst[i];
+
+      if (ret->altcid == cid)
+        {
+          *bitmap = 1ULL << i;
+          return ret;
+        }
+    }
+
+  return NULL;
+}
+
+/****************************************************************************
+ * Name: cid_to_searchable
+ ****************************************************************************/
+
+static uint16_t cid_to_searchable(uint16_t cid, uint8_t altver)
+{
+  uint16_t cidv1;
+
+  cid &= ~ALTCOM_CMDID_REPLY_BIT;
+  if (altver == ALTCOM_VER4)
+    {
+      /* Change the command ID to Version 1
+       * Even if it cannot be converted, try to search the table
+       * using the original command ID.
+       */
+
+      cidv1 = convert_cid2v1(cid);
+      if (cidv1 != APICMDID_UNKNOWN)
+        {
+          cid = cidv1;
+        }
+    }
+
+  return cid;
+}
+
+/****************************************************************************
+ * Name: get_bitmap
+ ****************************************************************************/
+
+static uint64_t get_bitmap(FAR struct alt1250_dev_s *dev, uint16_t cid,
+  uint8_t altver)
+{
+  uint64_t bitmap = 0ULL;
+
+  cid = cid_to_searchable(cid, altver);
+
+  search_evtbufinst(cid, &bitmap, dev);
+
+  return bitmap;
+}
+
+/****************************************************************************
+ * Name: get_evtbuffinst_withlock
+ ****************************************************************************/
+
+static FAR alt_evtbuf_inst_t *get_evtbuffinst_withlock(
+  FAR struct alt1250_dev_s *dev, uint16_t cid, uint8_t altver,
+  FAR uint64_t *bitmap)
+{
+  FAR alt_evtbuf_inst_t *inst = NULL;
+  FAR alt_evtbuf_inst_t *ret = NULL;
+
+  cid = cid_to_searchable(cid, altver);
+
+  if (cid == APICMDID_SOCK_SELECT)
+    {
+      ret = &dev->select_inst;
+
+      lock_evtbuffinst(ret, dev);
+
+      ret->outparam = dev->select_container->outparam;
+      ret->outparamlen = dev->select_container->outparamlen;
+
+      search_evtbufinst(cid, bitmap, dev);
+    }
+  else
+    {
+      inst = search_evtbufinst(cid, bitmap, dev);
+      if (inst)
+        {
+          lock_evtbuffinst(inst, dev);
+
+          if (inst->stat == ALTEVTBUF_ST_WRITABLE)
+            {
+              ret = inst;
+            }
+          else
+            {
+              unlock_evtbufinst(inst, dev);
+            }
+        }
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: write_restart_param
+ ****************************************************************************/
+
+static void write_restart_param(FAR void *outp[], FAR void *buff)
+{
+  FAR int *out_reason = (FAR int *)outp[0];
+  FAR int *in_reason = (FAR int *)buff;
+
+  *out_reason = *in_reason;
+}
+
+/****************************************************************************
+ * Name: pollnotify
+ ****************************************************************************/
+
+static void pollnotify(FAR struct alt1250_dev_s *dev)
+{
+  nxsem_wait_uninterruptible(&dev->pfdlock);
+
+  if (dev->pfd)
+    {
+      /* If poll() waits, notify  */
+
+      poll_notify(&dev->pfd, 1, POLLIN);
+    }
+
+  nxsem_post(&dev->pfdlock);
+}
+
+/****************************************************************************
+ * Name: get_composehdlr
+ ****************************************************************************/
+
+compose_handler_t get_composehdlr(uint32_t cmdid, FAR uint8_t *payload,
+  size_t size)
+{
+  compose_handler_t ret = NULL;
+
+  ret = alt1250_composehdlr(cmdid);
+
+#ifdef CONFIG_MODEM_ALT1250_ADDITIONAL_FUNC
+  if (ret == NULL)
+    {
+      ret = alt1250_additional_composehdlr(cmdid, payload, size);
+    }
+#endif
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: get_parsehdlr
+ ****************************************************************************/
+
+parse_handler_t get_parsehdlr(uint16_t altcid, uint8_t altver)
+{
+  parse_handler_t ret = NULL;
+
+  ret = alt1250_parsehdlr(altcid, altver);
+
+#ifdef CONFIG_MODEM_ALT1250_ADDITIONAL_FUNC
+  if (ret == NULL)
+    {
+      ret = alt1250_additional_parsehdlr(altcid, altver);
+    }
+#endif
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: alt1250_power_control
+ ****************************************************************************/
+
+static int alt1250_power_control(FAR struct alt1250_dev_s *dev,
+  FAR struct alt_power_s *req)
+{
+  int ret = OK;
+
+  switch (req->cmdid)
+    {
+      case LTE_CMDID_POWERON:
+        ret = altmdm_poweron();
+        break;
+
+      case LTE_CMDID_POWEROFF:
+        ret = altmdm_poweroff();
+        break;
+
+      case LTE_CMDID_TAKEWLOCK:
+        ret = altmdm_take_wlock();
+        break;
+
+      case LTE_CMDID_GIVEWLOCK:
+        ret = altmdm_give_wlock();
+        break;
+
+      default:
+        ret = -EINVAL;
+        break;
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: make_altcomcmd_and_send
+ ****************************************************************************/
+
+static int make_altcomcmd_and_send(FAR struct alt1250_dev_s *dev,
+  FAR alt_container_t *req)
+{
+  int ret = OK;
+  compose_handler_t handler;
+  uint8_t altver;
+  uint16_t cid;
+  uint16_t tid;
+  FAR uint8_t *payload;
+  int remainlen;
+  int pos;
+
+  m_info("send request: command ID=0x%08lx\n", req->cmdid);
+
+  payload = get_payload((FAR struct altcom_cmdhdr_s *)g_sendbuff);
+
+  handler = get_composehdlr(req->cmdid & ~LTE_CMDOPT_ASYNC_BIT, payload,
+    ALTCOM_PAYLOAD_SIZE_MAX);
+  if (handler)
+    {
+      altver = altmdm_get_protoversion();
+      if ((altver == ALTCOM_VERX) || is_senddisable(dev))
+        {
+          ret = -ENETDOWN;
+        }
+      else
+        {
+          ret = handler(req->inparam, req->inparamlen, altver, payload,
+            ALTCOM_PAYLOAD_SIZE_MAX, &cid);

Review Comment:
   align



##########
drivers/modem/alt1250/alt1250.c:
##########
@@ -0,0 +1,1279 @@
+/****************************************************************************
+ * drivers/modem/alt1250/alt1250.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/kmalloc.h>
+#include <nuttx/fs/fs.h>
+#include <poll.h>
+#include <errno.h>
+#include <nuttx/wireless/lte/lte_ioctl.h>
+#include <nuttx/modem/alt1250.h>
+#include <assert.h>
+
+#include "altcom_pkt.h"
+#include "altcom_hdlr.h"
+#include "altmdm.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define WRITE_OK 0
+#define WRITE_NG 1
+
+#define rel_evtbufinst(inst, dev) unlock_evtbufinst(inst, dev)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* Character driver methods. */
+
+static int alt1250_open(FAR struct file *filep);
+static int alt1250_close(FAR struct file *filep);
+static ssize_t alt1250_read(FAR struct file *filep, FAR char *buffer,
+  size_t len);
+static int alt1250_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
+static int alt1250_poll(FAR struct file *filep, struct pollfd *fds,
+  bool setup);
+
+parse_handler_t alt1250_additional_parsehdlr(uint16_t, uint8_t);
+compose_handler_t alt1250_additional_composehdlr(uint32_t,
+    FAR uint8_t *, size_t);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* This the vtable that supports the character driver interface. */
+
+static const struct file_operations g_alt1250fops =
+{
+  alt1250_open,  /* open */
+  alt1250_close, /* close */
+  alt1250_read,  /* read */
+  0,             /* write */
+  0,             /* seek */
+  alt1250_ioctl, /* ioctl */
+  alt1250_poll,  /* poll */
+};
+static uint8_t g_recvbuff[ALTCOM_RX_PKT_SIZE_MAX];
+static uint8_t g_sendbuff[ALTCOM_PKT_SIZE_MAX];
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: add_list
+ ****************************************************************************/
+
+static void add_list(FAR struct alt_queue_s *head,
+  FAR struct alt_container_s *list)
+{
+  FAR struct alt_container_s *next;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  while (list != NULL)
+    {
+      next = (FAR struct alt_container_s *)sq_next(&list->node);
+
+      sq_next(&list->node) = NULL;
+      sq_addlast(&list->node, &head->queue);
+
+      list = next;
+    }
+
+  nxsem_post(&head->lock);
+}
+
+/****************************************************************************
+ * Name: remove_list_all
+ ****************************************************************************/
+
+static FAR struct alt_container_s *remove_list_all(
+  FAR struct alt_queue_s *head)
+{
+  FAR struct alt_container_s *list;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  list = (FAR struct alt_container_s *)sq_peek(&head->queue);
+  sq_init(&head->queue);
+
+  nxsem_post(&head->lock);
+
+  return list;
+}
+
+/****************************************************************************
+ * Name: remove_list
+ ****************************************************************************/
+
+static FAR struct alt_container_s *remove_list(FAR struct alt_queue_s *head,
+  uint16_t cmdid, uint16_t transid)
+{
+  FAR struct alt_container_s *list;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  list = (FAR struct alt_container_s *)sq_peek(&head->queue);
+  while (list != NULL)
+    {
+      if ((list->altcid == cmdid) && (list->alttid == transid))
+        {
+          sq_rem(&list->node, &head->queue);
+          sq_next(&list->node) = NULL;
+          break;
+        }
+
+      list = (FAR struct alt_container_s *)sq_next(&list->node);
+    }
+
+  nxsem_post(&head->lock);
+
+  return list;
+}
+
+/****************************************************************************
+ * Name: set_senddisable
+ ****************************************************************************/
+
+static void set_senddisable(FAR struct alt1250_dev_s *dev, bool disable)
+{
+  nxsem_wait_uninterruptible(&dev->senddisablelock);
+
+  dev->senddisable = disable;
+
+  nxsem_post(&dev->senddisablelock);
+}
+
+/****************************************************************************
+ * Name: is_senddisable
+ ****************************************************************************/
+
+static bool is_senddisable(FAR struct alt1250_dev_s *dev)
+{
+  bool disable;
+
+  nxsem_wait_uninterruptible(&dev->senddisablelock);
+
+  disable = dev->senddisable;
+
+  nxsem_post(&dev->senddisablelock);
+
+  return disable;
+}
+
+/****************************************************************************
+ * Name: read_evtbitmap
+ ****************************************************************************/
+
+static ssize_t read_data(FAR struct alt1250_dev_s *dev,
+  FAR struct alt_readdata_s *rdata)
+{
+  int idx;
+
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  /* change status to NOT WRITABLE */
+
+  for (idx = 0; idx < (sizeof(uint64_t) * 8); idx++)
+    {
+      if (dev->evtbitmap & (1ULL << idx))
+        {
+          if (dev->evtbuff->ninst >= idx)
+            {
+              FAR alt_evtbuf_inst_t *inst = &dev->evtbuff->inst[idx];
+
+              nxsem_wait_uninterruptible(&inst->stat_lock);
+
+              inst->stat = ALTEVTBUF_ST_NOTWRITABLE;
+
+              nxsem_post(&inst->stat_lock);
+            }
+        }
+    }
+
+  rdata->evtbitmap = dev->evtbitmap;
+  rdata->head = remove_list_all(&dev->replylist);
+
+  if (dev->evtbitmap & ALT1250_EVTBIT_RESET)
+    {
+      /* Resume sending because daemon has been notified of the reset
+       * reliably.
+       */
+
+      set_senddisable(dev, false);
+    }
+
+  dev->evtbitmap = 0ULL;
+
+  nxsem_post(&dev->evtmaplock);
+
+  return sizeof(struct alt_readdata_s);
+}
+
+/****************************************************************************
+ * Name: write_evtbitmap
+ ****************************************************************************/
+
+static void write_evtbitmap(FAR struct alt1250_dev_s *dev,
+  uint64_t bitmap)
+{
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  dev->evtbitmap |= bitmap;
+
+  if (dev->evtbitmap & ALT1250_EVTBIT_RESET)
+    {
+      dev->evtbitmap = ALT1250_EVTBIT_RESET;
+    }
+
+  m_info("write bitmap: 0x%llx\n", bitmap);
+
+  nxsem_post(&dev->evtmaplock);
+}
+
+/****************************************************************************
+ * Name: write_evtbitmapwithlist
+ ****************************************************************************/
+
+static void write_evtbitmapwithlist(FAR struct alt1250_dev_s *dev,
+  uint64_t bitmap, FAR struct alt_container_s *container)
+{
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  dev->evtbitmap |= bitmap;
+
+  if (dev->evtbitmap & ALT1250_EVTBIT_RESET)
+    {
+      dev->evtbitmap = ALT1250_EVTBIT_RESET;
+    }
+
+  add_list(&dev->replylist, container);
+
+  nxsem_post(&dev->evtmaplock);
+}
+
+/****************************************************************************
+ * Name: add_evtbuff
+ ****************************************************************************/
+
+static void add_evtbuff(FAR struct alt1250_dev_s *dev,
+  FAR struct alt_evtbuffer_s *buff)
+{
+  dev->evtbuff = buff;
+}
+
+/****************************************************************************
+ * Name: write_evtbuff_byidx
+ ****************************************************************************/
+
+static int write_evtbuff_byidx(FAR struct alt1250_dev_s *dev,
+  uint64_t idx, void(*write_func)(FAR void *outp[], FAR void *inp),
+  FAR void *inp)
+{
+  int ret = WRITE_NG;
+
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  if (dev->evtbuff)
+    {
+      if (dev->evtbuff->ninst >= idx)
+        {
+          FAR alt_evtbuf_inst_t *inst = &dev->evtbuff->inst[idx];
+
+          nxsem_wait_uninterruptible(&inst->stat_lock);
+          if (inst->stat == ALTEVTBUF_ST_WRITABLE)
+            {
+              write_func(inst->outparam, inp);
+              dev->evtbitmap |= (1ULL << idx);
+              ret = WRITE_OK;
+            }
+
+          nxsem_post(&inst->stat_lock);
+        }
+    }
+
+  nxsem_post(&dev->evtmaplock);
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: lock_evtbuffinst
+ ****************************************************************************/
+
+static void lock_evtbuffinst(FAR alt_evtbuf_inst_t *inst,
+  FAR struct alt1250_dev_s *dev)
+{
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+  nxsem_wait_uninterruptible(&inst->stat_lock);
+}
+
+/****************************************************************************
+ * Name: unlock_evtbufinst
+ ****************************************************************************/
+
+static void unlock_evtbufinst(FAR alt_evtbuf_inst_t *inst,
+  FAR struct alt1250_dev_s *dev)

Review Comment:
   Please align



##########
drivers/modem/alt1250/altcom_cmd.h:
##########
@@ -0,0 +1,965 @@
+/****************************************************************************
+ * drivers/modem/alt1250/altcom_cmd.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_H__
+#define __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_H__
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <stdbool.h>
+#include <stdint.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define APICMD_ACTIVATEPDN_APNNAME_MAXLEN         (101)
+#define APICMD_ACTIVATEPDN_USERNAME_MAXLEN        (64)
+#define APICMD_ACTIVATEPDN_PASSWORD_MAXLEN        (32)
+
+#define APICMD_CELLINFO_CELLID_MIN    (0)
+#define APICMD_CELLINFO_CELLID_MAX    (503)
+#define APICMD_CELLINFO_EARFCN_MIN    (0)
+#define APICMD_CELLINFO_EARFCN_MAX    (262143)
+#define APICMD_CELLINFO_DIGIT_NUM_MIN (0)
+#define APICMD_CELLINFO_DIGIT_NUM_MAX (9)
+#define APICMD_CELLINFO_MCC_DIGIT             (3)
+#define APICMD_CELLINFO_MNC_DIGIT_MIN         (2)
+#define APICMD_CELLINFO_MNC_DIGIT_MAX         (3)
+#define APICMD_CELLINFO_GCID_MAX              (16)
+#define APICMD_CELLINFO_TIMEDIFF_INDEX_MAX    (4095)
+#define APICMD_CELLINFO_TA_MAX                (1282)
+#define APICMD_CELLINFO_SFN_MAX               (0x03FF)
+#define APICMD_CELLINFO_NEIGHBOR_CELL_NUM_MAX (32)
+#define APICMD_CELLINFO_VALID_TIMEDIFFIDX     (1 << 1)
+#define APICMD_CELLINFO_VALID_TA              (1 << 2)
+#define APICMD_CELLINFO_VALID_SFN             (1 << 3)
+#define APICMD_CELLINFO_VALID_RSRP            (1 << 4)
+#define APICMD_CELLINFO_VALID_RSRQ            (1 << 5)
+
+#define APICMD_DATAALLOW_DATAALLOW_ALLOW        (0)
+#define APICMD_DATAALLOW_DATAALLOW_DISALLOW     (1)
+
+#define APICMD_DATAALLOW_DATAROAMALLOW_ALLOW    (0)
+#define APICMD_DATAALLOW_DATAROAMALLOW_DISALLOW (1)
+
+#define APICMD_DEACTIVATEPDN_SESSIONID_MIN          (0)
+#define APICMD_DEACTIVATEPDN_SESSIONID_MAX          (255)
+
+#define APICMD_EDRX_ACTTYPE_NOTUSE   (0) /* eDRX is not running */
+#define APICMD_EDRX_ACTTYPE_ECGSMIOT (1) /* EC-GSM-IoT (A/Gb mode) */
+#define APICMD_EDRX_ACTTYPE_GSM      (2) /* GSM (A/Gb mode) */
+#define APICMD_EDRX_ACTTYPE_IU       (3) /* UTRAN (Iu mode) */
+#define APICMD_EDRX_ACTTYPE_WBS1     (4) /* E-UTRAN (WB-S1 mode) */
+#define APICMD_EDRX_ACTTYPE_NBS1     (5) /* E-UTRAN (NB-S1 mode) */
+
+#define APICMD_ENTERPIN_NEWPINCODE_UNUSE         (0)
+#define APICMD_ENTERPIN_NEWPINCODE_USE           (1)
+#define APICMD_ENTERPIN_PINCODE_LEN              9
+
+#define APICMD_ERRINFO_ERRSTR_MAX_LEN                (64)
+
+#define APICMD_IMSCAP_ENABLE         (0)
+#define APICMD_IMSCAP_DISABLE        (1)
+
+#define APICMD_GETSIMINFO_MCC_DIXIT_MAX          (3)
+#define APICMD_GETSIMINFO_MNC_DIXIT_MAX          (3)
+#define APICMD_GETSIMINFO_SPN_MAX_LEN            (16)
+#define APICMD_GETSIMINFO_ICCID_MAX_LEN          (10)
+#define APICMD_GETSIMINFO_IMSI_LEN               (15)
+#define APICMD_GETSIMINFO_GID_LEN                (128)
+
+#define APICMD_IMEI_LEN     16
+#define APICMD_IMSI_LEN                   16
+
+#define APICMD_NETINFO_PDNCOUNT_MAX           (5)
+
+#define APICMD_OPERATOR_LEN     17
+#define APICMD_OPERATOR_LEN_V4  33

Review Comment:
   align



##########
drivers/modem/alt1250/alt1250.c:
##########
@@ -0,0 +1,1279 @@
+/****************************************************************************
+ * drivers/modem/alt1250/alt1250.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/kmalloc.h>
+#include <nuttx/fs/fs.h>
+#include <poll.h>
+#include <errno.h>
+#include <nuttx/wireless/lte/lte_ioctl.h>
+#include <nuttx/modem/alt1250.h>
+#include <assert.h>
+
+#include "altcom_pkt.h"
+#include "altcom_hdlr.h"
+#include "altmdm.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define WRITE_OK 0
+#define WRITE_NG 1
+
+#define rel_evtbufinst(inst, dev) unlock_evtbufinst(inst, dev)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* Character driver methods. */
+
+static int alt1250_open(FAR struct file *filep);
+static int alt1250_close(FAR struct file *filep);
+static ssize_t alt1250_read(FAR struct file *filep, FAR char *buffer,
+  size_t len);
+static int alt1250_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
+static int alt1250_poll(FAR struct file *filep, struct pollfd *fds,
+  bool setup);
+
+parse_handler_t alt1250_additional_parsehdlr(uint16_t, uint8_t);
+compose_handler_t alt1250_additional_composehdlr(uint32_t,
+    FAR uint8_t *, size_t);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* This the vtable that supports the character driver interface. */
+
+static const struct file_operations g_alt1250fops =
+{
+  alt1250_open,  /* open */
+  alt1250_close, /* close */
+  alt1250_read,  /* read */
+  0,             /* write */
+  0,             /* seek */
+  alt1250_ioctl, /* ioctl */
+  alt1250_poll,  /* poll */
+};
+static uint8_t g_recvbuff[ALTCOM_RX_PKT_SIZE_MAX];
+static uint8_t g_sendbuff[ALTCOM_PKT_SIZE_MAX];
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: add_list
+ ****************************************************************************/
+
+static void add_list(FAR struct alt_queue_s *head,
+  FAR struct alt_container_s *list)
+{
+  FAR struct alt_container_s *next;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  while (list != NULL)
+    {
+      next = (FAR struct alt_container_s *)sq_next(&list->node);
+
+      sq_next(&list->node) = NULL;
+      sq_addlast(&list->node, &head->queue);
+
+      list = next;
+    }
+
+  nxsem_post(&head->lock);
+}
+
+/****************************************************************************
+ * Name: remove_list_all
+ ****************************************************************************/
+
+static FAR struct alt_container_s *remove_list_all(
+  FAR struct alt_queue_s *head)
+{
+  FAR struct alt_container_s *list;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  list = (FAR struct alt_container_s *)sq_peek(&head->queue);
+  sq_init(&head->queue);
+
+  nxsem_post(&head->lock);
+
+  return list;
+}
+
+/****************************************************************************
+ * Name: remove_list
+ ****************************************************************************/
+
+static FAR struct alt_container_s *remove_list(FAR struct alt_queue_s *head,
+  uint16_t cmdid, uint16_t transid)
+{
+  FAR struct alt_container_s *list;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  list = (FAR struct alt_container_s *)sq_peek(&head->queue);
+  while (list != NULL)
+    {
+      if ((list->altcid == cmdid) && (list->alttid == transid))
+        {
+          sq_rem(&list->node, &head->queue);
+          sq_next(&list->node) = NULL;
+          break;
+        }
+
+      list = (FAR struct alt_container_s *)sq_next(&list->node);
+    }
+
+  nxsem_post(&head->lock);
+
+  return list;
+}
+
+/****************************************************************************
+ * Name: set_senddisable
+ ****************************************************************************/
+
+static void set_senddisable(FAR struct alt1250_dev_s *dev, bool disable)
+{
+  nxsem_wait_uninterruptible(&dev->senddisablelock);
+
+  dev->senddisable = disable;
+
+  nxsem_post(&dev->senddisablelock);
+}
+
+/****************************************************************************
+ * Name: is_senddisable
+ ****************************************************************************/
+
+static bool is_senddisable(FAR struct alt1250_dev_s *dev)
+{
+  bool disable;
+
+  nxsem_wait_uninterruptible(&dev->senddisablelock);
+
+  disable = dev->senddisable;
+
+  nxsem_post(&dev->senddisablelock);
+
+  return disable;
+}
+
+/****************************************************************************
+ * Name: read_evtbitmap
+ ****************************************************************************/
+
+static ssize_t read_data(FAR struct alt1250_dev_s *dev,
+  FAR struct alt_readdata_s *rdata)
+{
+  int idx;
+
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  /* change status to NOT WRITABLE */
+
+  for (idx = 0; idx < (sizeof(uint64_t) * 8); idx++)
+    {
+      if (dev->evtbitmap & (1ULL << idx))
+        {
+          if (dev->evtbuff->ninst >= idx)
+            {
+              FAR alt_evtbuf_inst_t *inst = &dev->evtbuff->inst[idx];
+
+              nxsem_wait_uninterruptible(&inst->stat_lock);
+
+              inst->stat = ALTEVTBUF_ST_NOTWRITABLE;
+
+              nxsem_post(&inst->stat_lock);
+            }
+        }
+    }
+
+  rdata->evtbitmap = dev->evtbitmap;
+  rdata->head = remove_list_all(&dev->replylist);
+
+  if (dev->evtbitmap & ALT1250_EVTBIT_RESET)
+    {
+      /* Resume sending because daemon has been notified of the reset
+       * reliably.
+       */
+
+      set_senddisable(dev, false);
+    }
+
+  dev->evtbitmap = 0ULL;
+
+  nxsem_post(&dev->evtmaplock);
+
+  return sizeof(struct alt_readdata_s);
+}
+
+/****************************************************************************
+ * Name: write_evtbitmap
+ ****************************************************************************/
+
+static void write_evtbitmap(FAR struct alt1250_dev_s *dev,
+  uint64_t bitmap)

Review Comment:
   Please align this line starting after the "(" from previous line



##########
drivers/modem/alt1250/altcom_cmd.h:
##########
@@ -0,0 +1,965 @@
+/****************************************************************************
+ * drivers/modem/alt1250/altcom_cmd.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_H__
+#define __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_H__
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <stdbool.h>
+#include <stdint.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define APICMD_ACTIVATEPDN_APNNAME_MAXLEN         (101)
+#define APICMD_ACTIVATEPDN_USERNAME_MAXLEN        (64)
+#define APICMD_ACTIVATEPDN_PASSWORD_MAXLEN        (32)
+
+#define APICMD_CELLINFO_CELLID_MIN    (0)
+#define APICMD_CELLINFO_CELLID_MAX    (503)
+#define APICMD_CELLINFO_EARFCN_MIN    (0)
+#define APICMD_CELLINFO_EARFCN_MAX    (262143)
+#define APICMD_CELLINFO_DIGIT_NUM_MIN (0)
+#define APICMD_CELLINFO_DIGIT_NUM_MAX (9)
+#define APICMD_CELLINFO_MCC_DIGIT             (3)
+#define APICMD_CELLINFO_MNC_DIGIT_MIN         (2)
+#define APICMD_CELLINFO_MNC_DIGIT_MAX         (3)
+#define APICMD_CELLINFO_GCID_MAX              (16)
+#define APICMD_CELLINFO_TIMEDIFF_INDEX_MAX    (4095)
+#define APICMD_CELLINFO_TA_MAX                (1282)
+#define APICMD_CELLINFO_SFN_MAX               (0x03FF)
+#define APICMD_CELLINFO_NEIGHBOR_CELL_NUM_MAX (32)
+#define APICMD_CELLINFO_VALID_TIMEDIFFIDX     (1 << 1)
+#define APICMD_CELLINFO_VALID_TA              (1 << 2)
+#define APICMD_CELLINFO_VALID_SFN             (1 << 3)
+#define APICMD_CELLINFO_VALID_RSRP            (1 << 4)
+#define APICMD_CELLINFO_VALID_RSRQ            (1 << 5)
+
+#define APICMD_DATAALLOW_DATAALLOW_ALLOW        (0)
+#define APICMD_DATAALLOW_DATAALLOW_DISALLOW     (1)
+
+#define APICMD_DATAALLOW_DATAROAMALLOW_ALLOW    (0)
+#define APICMD_DATAALLOW_DATAROAMALLOW_DISALLOW (1)
+
+#define APICMD_DEACTIVATEPDN_SESSIONID_MIN          (0)
+#define APICMD_DEACTIVATEPDN_SESSIONID_MAX          (255)
+
+#define APICMD_EDRX_ACTTYPE_NOTUSE   (0) /* eDRX is not running */
+#define APICMD_EDRX_ACTTYPE_ECGSMIOT (1) /* EC-GSM-IoT (A/Gb mode) */
+#define APICMD_EDRX_ACTTYPE_GSM      (2) /* GSM (A/Gb mode) */
+#define APICMD_EDRX_ACTTYPE_IU       (3) /* UTRAN (Iu mode) */
+#define APICMD_EDRX_ACTTYPE_WBS1     (4) /* E-UTRAN (WB-S1 mode) */
+#define APICMD_EDRX_ACTTYPE_NBS1     (5) /* E-UTRAN (NB-S1 mode) */
+
+#define APICMD_ENTERPIN_NEWPINCODE_UNUSE         (0)
+#define APICMD_ENTERPIN_NEWPINCODE_USE           (1)
+#define APICMD_ENTERPIN_PINCODE_LEN              9
+
+#define APICMD_ERRINFO_ERRSTR_MAX_LEN                (64)
+
+#define APICMD_IMSCAP_ENABLE         (0)
+#define APICMD_IMSCAP_DISABLE        (1)
+
+#define APICMD_GETSIMINFO_MCC_DIXIT_MAX          (3)
+#define APICMD_GETSIMINFO_MNC_DIXIT_MAX          (3)
+#define APICMD_GETSIMINFO_SPN_MAX_LEN            (16)
+#define APICMD_GETSIMINFO_ICCID_MAX_LEN          (10)
+#define APICMD_GETSIMINFO_IMSI_LEN               (15)
+#define APICMD_GETSIMINFO_GID_LEN                (128)
+
+#define APICMD_IMEI_LEN     16
+#define APICMD_IMSI_LEN                   16
+
+#define APICMD_NETINFO_PDNCOUNT_MAX           (5)
+
+#define APICMD_OPERATOR_LEN     17
+#define APICMD_OPERATOR_LEN_V4  33
+
+#define APICMD_PDN_IMS_REG                (0)
+#define APICMD_PDN_IMS_UNREG              (1)
+
+#define APICMD_PDN_DATAALLOW_ALLOW        (0)
+#define APICMD_PDN_DATAALLOW_DISALLOW     (1)
+
+#define APICMD_PDN_DATAROAMALLOW_ALLOW    (0)
+#define APICMD_PDN_DATAROAMALLOW_DISALLOW (1)
+
+#define APICMD_PDN_IPCOUNT_MAX            (2)
+#define APICMD_PDN_IPADDR_MAXLEN          (40)
+
+#define APICMD_PDN_DNSCOUNT_MAX           (4)
+
+#define APICMD_PHONENO_LEN                   41

Review Comment:
   align



##########
drivers/modem/alt1250/alt1250.c:
##########
@@ -0,0 +1,1279 @@
+/****************************************************************************
+ * drivers/modem/alt1250/alt1250.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/kmalloc.h>
+#include <nuttx/fs/fs.h>
+#include <poll.h>
+#include <errno.h>
+#include <nuttx/wireless/lte/lte_ioctl.h>
+#include <nuttx/modem/alt1250.h>
+#include <assert.h>
+
+#include "altcom_pkt.h"
+#include "altcom_hdlr.h"
+#include "altmdm.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define WRITE_OK 0
+#define WRITE_NG 1
+
+#define rel_evtbufinst(inst, dev) unlock_evtbufinst(inst, dev)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* Character driver methods. */
+
+static int alt1250_open(FAR struct file *filep);
+static int alt1250_close(FAR struct file *filep);
+static ssize_t alt1250_read(FAR struct file *filep, FAR char *buffer,
+  size_t len);
+static int alt1250_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
+static int alt1250_poll(FAR struct file *filep, struct pollfd *fds,
+  bool setup);
+
+parse_handler_t alt1250_additional_parsehdlr(uint16_t, uint8_t);
+compose_handler_t alt1250_additional_composehdlr(uint32_t,
+    FAR uint8_t *, size_t);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* This the vtable that supports the character driver interface. */
+
+static const struct file_operations g_alt1250fops =
+{
+  alt1250_open,  /* open */
+  alt1250_close, /* close */
+  alt1250_read,  /* read */
+  0,             /* write */
+  0,             /* seek */
+  alt1250_ioctl, /* ioctl */
+  alt1250_poll,  /* poll */
+};
+static uint8_t g_recvbuff[ALTCOM_RX_PKT_SIZE_MAX];
+static uint8_t g_sendbuff[ALTCOM_PKT_SIZE_MAX];
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: add_list
+ ****************************************************************************/
+
+static void add_list(FAR struct alt_queue_s *head,
+  FAR struct alt_container_s *list)
+{
+  FAR struct alt_container_s *next;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  while (list != NULL)
+    {
+      next = (FAR struct alt_container_s *)sq_next(&list->node);
+
+      sq_next(&list->node) = NULL;
+      sq_addlast(&list->node, &head->queue);
+
+      list = next;
+    }
+
+  nxsem_post(&head->lock);
+}
+
+/****************************************************************************
+ * Name: remove_list_all
+ ****************************************************************************/
+
+static FAR struct alt_container_s *remove_list_all(
+  FAR struct alt_queue_s *head)
+{
+  FAR struct alt_container_s *list;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  list = (FAR struct alt_container_s *)sq_peek(&head->queue);
+  sq_init(&head->queue);
+
+  nxsem_post(&head->lock);
+
+  return list;
+}
+
+/****************************************************************************
+ * Name: remove_list
+ ****************************************************************************/
+
+static FAR struct alt_container_s *remove_list(FAR struct alt_queue_s *head,
+  uint16_t cmdid, uint16_t transid)
+{
+  FAR struct alt_container_s *list;
+
+  nxsem_wait_uninterruptible(&head->lock);
+
+  list = (FAR struct alt_container_s *)sq_peek(&head->queue);
+  while (list != NULL)
+    {
+      if ((list->altcid == cmdid) && (list->alttid == transid))
+        {
+          sq_rem(&list->node, &head->queue);
+          sq_next(&list->node) = NULL;
+          break;
+        }
+
+      list = (FAR struct alt_container_s *)sq_next(&list->node);
+    }
+
+  nxsem_post(&head->lock);
+
+  return list;
+}
+
+/****************************************************************************
+ * Name: set_senddisable
+ ****************************************************************************/
+
+static void set_senddisable(FAR struct alt1250_dev_s *dev, bool disable)
+{
+  nxsem_wait_uninterruptible(&dev->senddisablelock);
+
+  dev->senddisable = disable;
+
+  nxsem_post(&dev->senddisablelock);
+}
+
+/****************************************************************************
+ * Name: is_senddisable
+ ****************************************************************************/
+
+static bool is_senddisable(FAR struct alt1250_dev_s *dev)
+{
+  bool disable;
+
+  nxsem_wait_uninterruptible(&dev->senddisablelock);
+
+  disable = dev->senddisable;
+
+  nxsem_post(&dev->senddisablelock);
+
+  return disable;
+}
+
+/****************************************************************************
+ * Name: read_evtbitmap
+ ****************************************************************************/
+
+static ssize_t read_data(FAR struct alt1250_dev_s *dev,
+  FAR struct alt_readdata_s *rdata)
+{
+  int idx;
+
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  /* change status to NOT WRITABLE */
+
+  for (idx = 0; idx < (sizeof(uint64_t) * 8); idx++)
+    {
+      if (dev->evtbitmap & (1ULL << idx))
+        {
+          if (dev->evtbuff->ninst >= idx)
+            {
+              FAR alt_evtbuf_inst_t *inst = &dev->evtbuff->inst[idx];
+
+              nxsem_wait_uninterruptible(&inst->stat_lock);
+
+              inst->stat = ALTEVTBUF_ST_NOTWRITABLE;
+
+              nxsem_post(&inst->stat_lock);
+            }
+        }
+    }
+
+  rdata->evtbitmap = dev->evtbitmap;
+  rdata->head = remove_list_all(&dev->replylist);
+
+  if (dev->evtbitmap & ALT1250_EVTBIT_RESET)
+    {
+      /* Resume sending because daemon has been notified of the reset
+       * reliably.
+       */
+
+      set_senddisable(dev, false);
+    }
+
+  dev->evtbitmap = 0ULL;
+
+  nxsem_post(&dev->evtmaplock);
+
+  return sizeof(struct alt_readdata_s);
+}
+
+/****************************************************************************
+ * Name: write_evtbitmap
+ ****************************************************************************/
+
+static void write_evtbitmap(FAR struct alt1250_dev_s *dev,
+  uint64_t bitmap)
+{
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  dev->evtbitmap |= bitmap;
+
+  if (dev->evtbitmap & ALT1250_EVTBIT_RESET)
+    {
+      dev->evtbitmap = ALT1250_EVTBIT_RESET;
+    }
+
+  m_info("write bitmap: 0x%llx\n", bitmap);
+
+  nxsem_post(&dev->evtmaplock);
+}
+
+/****************************************************************************
+ * Name: write_evtbitmapwithlist
+ ****************************************************************************/
+
+static void write_evtbitmapwithlist(FAR struct alt1250_dev_s *dev,
+  uint64_t bitmap, FAR struct alt_container_s *container)
+{
+  nxsem_wait_uninterruptible(&dev->evtmaplock);
+
+  dev->evtbitmap |= bitmap;
+
+  if (dev->evtbitmap & ALT1250_EVTBIT_RESET)

Review Comment:
   Ditto



##########
drivers/modem/alt1250/altcom_cmd.h:
##########
@@ -0,0 +1,965 @@
+/****************************************************************************
+ * drivers/modem/alt1250/altcom_cmd.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_H__
+#define __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_H__
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <stdbool.h>
+#include <stdint.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define APICMD_ACTIVATEPDN_APNNAME_MAXLEN         (101)
+#define APICMD_ACTIVATEPDN_USERNAME_MAXLEN        (64)
+#define APICMD_ACTIVATEPDN_PASSWORD_MAXLEN        (32)
+
+#define APICMD_CELLINFO_CELLID_MIN    (0)
+#define APICMD_CELLINFO_CELLID_MAX    (503)
+#define APICMD_CELLINFO_EARFCN_MIN    (0)
+#define APICMD_CELLINFO_EARFCN_MAX    (262143)
+#define APICMD_CELLINFO_DIGIT_NUM_MIN (0)
+#define APICMD_CELLINFO_DIGIT_NUM_MAX (9)
+#define APICMD_CELLINFO_MCC_DIGIT             (3)
+#define APICMD_CELLINFO_MNC_DIGIT_MIN         (2)
+#define APICMD_CELLINFO_MNC_DIGIT_MAX         (3)
+#define APICMD_CELLINFO_GCID_MAX              (16)
+#define APICMD_CELLINFO_TIMEDIFF_INDEX_MAX    (4095)
+#define APICMD_CELLINFO_TA_MAX                (1282)
+#define APICMD_CELLINFO_SFN_MAX               (0x03FF)
+#define APICMD_CELLINFO_NEIGHBOR_CELL_NUM_MAX (32)
+#define APICMD_CELLINFO_VALID_TIMEDIFFIDX     (1 << 1)
+#define APICMD_CELLINFO_VALID_TA              (1 << 2)
+#define APICMD_CELLINFO_VALID_SFN             (1 << 3)
+#define APICMD_CELLINFO_VALID_RSRP            (1 << 4)
+#define APICMD_CELLINFO_VALID_RSRQ            (1 << 5)
+
+#define APICMD_DATAALLOW_DATAALLOW_ALLOW        (0)
+#define APICMD_DATAALLOW_DATAALLOW_DISALLOW     (1)
+
+#define APICMD_DATAALLOW_DATAROAMALLOW_ALLOW    (0)
+#define APICMD_DATAALLOW_DATAROAMALLOW_DISALLOW (1)
+
+#define APICMD_DEACTIVATEPDN_SESSIONID_MIN          (0)
+#define APICMD_DEACTIVATEPDN_SESSIONID_MAX          (255)
+
+#define APICMD_EDRX_ACTTYPE_NOTUSE   (0) /* eDRX is not running */
+#define APICMD_EDRX_ACTTYPE_ECGSMIOT (1) /* EC-GSM-IoT (A/Gb mode) */
+#define APICMD_EDRX_ACTTYPE_GSM      (2) /* GSM (A/Gb mode) */
+#define APICMD_EDRX_ACTTYPE_IU       (3) /* UTRAN (Iu mode) */
+#define APICMD_EDRX_ACTTYPE_WBS1     (4) /* E-UTRAN (WB-S1 mode) */
+#define APICMD_EDRX_ACTTYPE_NBS1     (5) /* E-UTRAN (NB-S1 mode) */
+
+#define APICMD_ENTERPIN_NEWPINCODE_UNUSE         (0)
+#define APICMD_ENTERPIN_NEWPINCODE_USE           (1)
+#define APICMD_ENTERPIN_PINCODE_LEN              9
+
+#define APICMD_ERRINFO_ERRSTR_MAX_LEN                (64)
+
+#define APICMD_IMSCAP_ENABLE         (0)
+#define APICMD_IMSCAP_DISABLE        (1)
+
+#define APICMD_GETSIMINFO_MCC_DIXIT_MAX          (3)
+#define APICMD_GETSIMINFO_MNC_DIXIT_MAX          (3)
+#define APICMD_GETSIMINFO_SPN_MAX_LEN            (16)
+#define APICMD_GETSIMINFO_ICCID_MAX_LEN          (10)
+#define APICMD_GETSIMINFO_IMSI_LEN               (15)
+#define APICMD_GETSIMINFO_GID_LEN                (128)
+
+#define APICMD_IMEI_LEN     16
+#define APICMD_IMSI_LEN                   16

Review Comment:
   align



##########
drivers/modem/alt1250/altcom_cmd.h:
##########
@@ -0,0 +1,965 @@
+/****************************************************************************
+ * drivers/modem/alt1250/altcom_cmd.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_H__
+#define __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_H__
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <stdbool.h>
+#include <stdint.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define APICMD_ACTIVATEPDN_APNNAME_MAXLEN         (101)
+#define APICMD_ACTIVATEPDN_USERNAME_MAXLEN        (64)
+#define APICMD_ACTIVATEPDN_PASSWORD_MAXLEN        (32)
+
+#define APICMD_CELLINFO_CELLID_MIN    (0)
+#define APICMD_CELLINFO_CELLID_MAX    (503)
+#define APICMD_CELLINFO_EARFCN_MIN    (0)
+#define APICMD_CELLINFO_EARFCN_MAX    (262143)
+#define APICMD_CELLINFO_DIGIT_NUM_MIN (0)
+#define APICMD_CELLINFO_DIGIT_NUM_MAX (9)

Review Comment:
   align with next lines



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org