Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp181308pxj; Thu, 20 May 2021 07:09:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzv/aFGUnZ8l9GeY0hV4p07SJCbEm/yrZFvT64/oVHZf01OVNKivXAAW3wuw5ZRpDgYXmSz X-Received: by 2002:a92:c52d:: with SMTP id m13mr4561259ili.191.1621519789326; Thu, 20 May 2021 07:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621519789; cv=none; d=google.com; s=arc-20160816; b=aIpNsU3wbIjKL5JtHeOEwNfgpgFLoqasU7DK7Ab1lB0SwjKz/h+ggy65N5IpX+JKWk x+gudhMFMqw0BrWLlHnFzGb83Up2mEoX+X6EheduCJrNvOmbWADgnat63SXsX0Up6gBX WA8Le7u1qFe6Cnal4Vu0hnFPD1xVrqzcqbBcMnKvIQ1Jmwa8Ut//tdMliQb1fE8dQbKB PVCEQrwal5000mcMu4nMUBzGrJ+OowjXJ+L1411EwpJQDErdP3/Z+HmhT3kXnGcL09Dk kLNRtI6BEa562JyWnIxJ5hbXZ8fpcEc/c8E6NkyDyriLzmF9pd1jnfugOzzgZpH59r+D Pd3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=TOvMf/jsse94+51V97NXOU3TlTPvf6nl+60l3/QZQSY=; b=BmSMLCTTwmbKVTlZf26A8StGmS15MJS9xTMhHcaqLICEXBXvsD3fWespEAvYrPVUYr WXcPQO7aLrS1qzHoLI9vUJwrN1+DxpsyjPbj8BKobpcl7sScC/oOTRl4zvhM9IlB7Jau swEtaq3sivVQ2uw2HqyGkCR1vFpnHLOlIZd1k5S7J4OgEW6Rx3qaNYw1g4L3F/tOl+Qt xMpl6uEh17oC/hiy4kKZ3QyLenas74DciL5qMAj5FFf97LRcOgvQHM75BpndZ8CH5w3n nQ0EcO4UCeABHOMsf1c3/rD38aJBZEyuOJ92gYjvryBk6MJgFZcsTXf7ell7pU1i8fup zpNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k7si2273620iok.65.2021.05.20.07.09.34; Thu, 20 May 2021 07:09:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240921AbhETOK1 (ORCPT + 99 others); Thu, 20 May 2021 10:10:27 -0400 Received: from mga11.intel.com ([192.55.52.93]:5047 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243757AbhETOJ2 (ORCPT ); Thu, 20 May 2021 10:09:28 -0400 IronPort-SDR: Gyj4mawADLZNprhqTfDFXNTEoVi6iHUzqYcuibaBzlG3ZNNKWvOoGyVa3j/EAO87KC5WstJUkr rHQ+fjWCIdog== X-IronPort-AV: E=McAfee;i="6200,9189,9989"; a="198144793" X-IronPort-AV: E=Sophos;i="5.82,313,1613462400"; d="scan'208";a="198144793" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2021 07:03:07 -0700 IronPort-SDR: wkfWrmzoOmnWUuN1tqsH5xsRwZ9dfXE7MMlizUqm7SyCXjAQD0/g/kbNkOn1GHdfM6IuCSk4Sa M0lNqWI8+dwg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,313,1613462400"; d="scan'208";a="631407654" Received: from bgsxx0031.iind.intel.com ([10.106.222.40]) by fmsmga005.fm.intel.com with ESMTP; 20 May 2021 07:03:05 -0700 From: M Chetan Kumar To: netdev@vger.kernel.org, linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, krishna.c.sudi@intel.com, linuxwwan@intel.com Subject: [PATCH V3 14/16] net: iosm: uevent support Date: Thu, 20 May 2021 19:31:56 +0530 Message-Id: <20210520140158.10132-15-m.chetan.kumar@intel.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20210520140158.10132-1-m.chetan.kumar@intel.com> References: <20210520140158.10132-1-m.chetan.kumar@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Report modem status via uevent. Signed-off-by: M Chetan Kumar --- v3: no change. v2: Removed non-related header file inclusion. --- drivers/net/wwan/iosm/iosm_ipc_uevent.c | 44 +++++++++++++++++++++++++ drivers/net/wwan/iosm/iosm_ipc_uevent.h | 41 +++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 drivers/net/wwan/iosm/iosm_ipc_uevent.c create mode 100644 drivers/net/wwan/iosm/iosm_ipc_uevent.h diff --git a/drivers/net/wwan/iosm/iosm_ipc_uevent.c b/drivers/net/wwan/iosm/iosm_ipc_uevent.c new file mode 100644 index 000000000000..2229d752926c --- /dev/null +++ b/drivers/net/wwan/iosm/iosm_ipc_uevent.c @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2020-21 Intel Corporation. + */ + +#include +#include +#include + +#include "iosm_ipc_uevent.h" + +/* Update the uevent in work queue context */ +static void ipc_uevent_work(struct work_struct *data) +{ + struct ipc_uevent_info *info; + char *envp[2] = { NULL, NULL }; + + info = container_of(data, struct ipc_uevent_info, work); + + envp[0] = info->uevent; + + if (kobject_uevent_env(&info->dev->kobj, KOBJ_CHANGE, envp)) + pr_err("uevent %s failed to sent", info->uevent); + + kfree(info); +} + +void ipc_uevent_send(struct device *dev, char *uevent) +{ + struct ipc_uevent_info *info = kzalloc(sizeof(*info), GFP_ATOMIC); + + if (!info) + return; + + /* Initialize the kernel work queue */ + INIT_WORK(&info->work, ipc_uevent_work); + + /* Store the device and event information */ + info->dev = dev; + snprintf(info->uevent, MAX_UEVENT_LEN, "%s: %s", dev_name(dev), uevent); + + /* Schedule uevent in process context using work queue */ + schedule_work(&info->work); +} diff --git a/drivers/net/wwan/iosm/iosm_ipc_uevent.h b/drivers/net/wwan/iosm/iosm_ipc_uevent.h new file mode 100644 index 000000000000..2e45c051b5f4 --- /dev/null +++ b/drivers/net/wwan/iosm/iosm_ipc_uevent.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0-only + * + * Copyright (C) 2020-21 Intel Corporation. + */ + +#ifndef IOSM_IPC_UEVENT_H +#define IOSM_IPC_UEVENT_H + +/* Baseband event strings */ +#define UEVENT_MDM_NOT_READY "MDM_NOT_READY" +#define UEVENT_ROM_READY "ROM_READY" +#define UEVENT_MDM_READY "MDM_READY" +#define UEVENT_CRASH "CRASH" +#define UEVENT_CD_READY "CD_READY" +#define UEVENT_CD_READY_LINK_DOWN "CD_READY_LINK_DOWN" +#define UEVENT_MDM_TIMEOUT "MDM_TIMEOUT" + +/* Maximum length of user events */ +#define MAX_UEVENT_LEN 64 + +/** + * struct ipc_uevent_info - Uevent information structure. + * @dev: Pointer to device structure + * @uevent: Uevent information + * @work: Uevent work struct + */ +struct ipc_uevent_info { + struct device *dev; + char uevent[MAX_UEVENT_LEN]; + struct work_struct work; +}; + +/** + * ipc_uevent_send - Send modem event to user space. + * @dev: Generic device pointer + * @uevent: Uevent information + * + */ +void ipc_uevent_send(struct device *dev, char *uevent); + +#endif -- 2.25.1