Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2008402pxj; Sun, 13 Jun 2021 05:53:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwleHPSatuGrV87dFSAXyLo5Hf4aADIkMTCqxpVFGW2EY757uf72PLm5GmlDatoj+9/W8Y4 X-Received: by 2002:a17:907:628a:: with SMTP id nd10mr11416028ejc.326.1623588784723; Sun, 13 Jun 2021 05:53:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623588784; cv=none; d=google.com; s=arc-20160816; b=ROz6pHN5GvojShDqIPHORI7soLxF169UdUx74nl8DC2CAigAkpsoLkNW27GOStn+Yf zj1QPgYc3vQxckYp+815N3N13Cl8UBL0NRY7GtIHLxI2PZdkIwxgk6WCobSipVdITwxU O9wnxuKRKK7L1UPMt1Ulv834Cm395Cbm4z2pKqEe7KpcZ6vvsckZg9wTgo72Au3qGD+S Tzsku/6iTNGKjvXbUmSGFDs07NrW7WtG+yOePb65U3RVjouYzdnzFIML3lxwVUJJaDyH CZrUg8rlmXq6k1VcQX2/XPw7o+atcSlk1ZTiiXZdg5mMgrbOREgulb6AfY7eL/SSFgHa LUmQ== 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=c2zpPCt6KhogmsqyqYYWrL+9kZ56/wy2NLHMlkBBSQM=; b=EbqyFVKduD1G6yQBwoOz4qp4jRRNasv+4pd5vfd/OMHRHKVsGwnTafgtGSLuigqUHm 9dxLng8rsOCmoW8BZzXWm0AtfkVIWptW5VyWpWZp8dRq5CiOF+1j5fijZZH8WGQ/9AhM rUyzT82QaQgxa12pg6ER6EtadSkVL9DrBKY8yOeYXGWBMJlTc23giBSKG0FkiNK7a1NO ZuCriPI0SygyGXZm/zrRQB+zITod15Js0S+p8sJ8aPFrgYRWly5x2v0H6LOmQWag3XfD GF2MBNyTvAXFdsxMtfLMLvOO1lfPzJGatWJUHxS0GTJJ0RzLHQDcFa+UYJBVdPwuGGXW CVgg== 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 v12si9474954ejb.163.2021.06.13.05.52.42; Sun, 13 Jun 2021 05:53:04 -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 S231946AbhFMMxm (ORCPT + 99 others); Sun, 13 Jun 2021 08:53:42 -0400 Received: from mga01.intel.com ([192.55.52.88]:20219 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231966AbhFMMx2 (ORCPT ); Sun, 13 Jun 2021 08:53:28 -0400 IronPort-SDR: H3IZOFuYwu1i/x7SG7pq+yEpwmLFp9zf6ExMuyeyZuojLTeTTwIUYl0YtKyCoERVMbp4vCAcTC py3tnLFsKmxQ== X-IronPort-AV: E=McAfee;i="6200,9189,10013"; a="227158491" X-IronPort-AV: E=Sophos;i="5.83,271,1616482800"; d="scan'208";a="227158491" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2021 05:51:26 -0700 IronPort-SDR: jatA0sDVcHodo1+G4s6WsfAF1G5S2kStJ2+h/lk9mI2Vy20WuHxZedk3AwykYy5rVftDHQMAgO m/JSZ+E6fJTw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,271,1616482800"; d="scan'208";a="449613076" Received: from bgsxx0031.iind.intel.com ([10.106.222.40]) by orsmga008.jf.intel.com with ESMTP; 13 Jun 2021 05:51:23 -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 V5 14/16] net: iosm: uevent support Date: Sun, 13 Jun 2021 18:20:21 +0530 Message-Id: <20210613125023.18945-15-m.chetan.kumar@intel.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20210613125023.18945-1-m.chetan.kumar@intel.com> References: <20210613125023.18945-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 --- v5: no change. v4: no change. 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