From 6595eeab48c24ebc95ab8a9401d881f785a413fb Mon Sep 17 00:00:00 2001 From: Ryan Lattrel Date: Wed, 30 Jan 2019 09:53:36 -0600 Subject: [PATCH] muc_uart: add attr for muc fw vers Record the muc fw vers when it is sent from the muc and provide access to it from an attribute. Change-Id: Ibbee1cf8c7c6ef7a6d936e8d08ff198d0d963d75 Signed-off-by: Ryan Lattrel Reviewed-on: https://gerrit.mot.com/1303136 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Kenneth Kessler Submit-Approved: Jira Key --- drivers/mmi_muc_uart/muc_uart.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/mmi_muc_uart/muc_uart.c b/drivers/mmi_muc_uart/muc_uart.c index 75307de9ee43..721aea16d5f1 100644 --- a/drivers/mmi_muc_uart/muc_uart.c +++ b/drivers/mmi_muc_uart/muc_uart.c @@ -85,6 +85,9 @@ void *muc_ipc_log; /* How many times to try to send a message before giving up */ #define MUC_UART_RETRY_COUNT 100 +/* Max number of chars we will copy from the fw vers sent by the muc */ +#define MUC_FW_VERS_MAX_SIZE 32 + struct write_data { struct list_head list; uint16_t cmd; @@ -138,6 +141,7 @@ struct mod_muc_data_t { struct power_supply *dc_psy; atomic_t sleep_req_pending; struct notifier_block ps_nb; + char muc_fw_vers[MUC_FW_VERS_MAX_SIZE]; }; /* How long until we move on without an ack */ @@ -218,11 +222,26 @@ static ssize_t mod_attached_show(struct device *dev, return snprintf(buf, 4, "%u\n", gpio_state); } +static ssize_t muc_fw_vers_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct platform_device *pdev = to_platform_device(dev); + struct mod_muc_data_t *mm_data = platform_get_drvdata(pdev); + + if (mm_data && mm_data->muc_fw_vers[0] != '\0') + return snprintf(buf, strlen(mm_data->muc_fw_vers) + 1, + "%s", mm_data->muc_fw_vers); + + return 0; +} + /* /sys/devices/soc:mod_uart/mod_attached */ DEVICE_ATTR_RO(mod_attached); +DEVICE_ATTR_RO(muc_fw_vers); static struct attribute *muc_uart_attrs[] = { &dev_attr_mod_attached.attr, + &dev_attr_muc_fw_vers.attr, NULL }; @@ -1138,6 +1157,11 @@ static void muc_uart_handle_message(struct mod_muc_data_t *mm_data, MUC_LOG("muc_fw_ver: %.*s\n", (int)payload_len, (char *)payload); + memset(mm_data->muc_fw_vers, 0, MUC_FW_VERS_MAX_SIZE); + /* Last value of muc_fw_vers should be null char */ + memcpy(mm_data->muc_fw_vers, payload, + payload_len < (MUC_FW_VERS_MAX_SIZE - 1) ? + payload_len : (MUC_FW_VERS_MAX_SIZE - 1)); } else muc_uart_send(mm_data, MUC_FW_VERSION|MSG_NACK_MASK, NULL, 0); break;