Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp852610pxu; Mon, 23 Nov 2020 05:56:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvmWAbM2EPsYxFl042kJIZk6YzPmI7gEj1H3YEzxkEbS72po+7NKKh8kHC7r+x1bYWLb3z X-Received: by 2002:aa7:df81:: with SMTP id b1mr46073164edy.365.1606139785653; Mon, 23 Nov 2020 05:56:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606139785; cv=none; d=google.com; s=arc-20160816; b=gbvwlQFgn0NZ63FWmwEW2HJsGi7D2YrL2b0mBoYC/ybBMcXkM1IMkPV/3FfLNjG2yq 3dQjt2rRNvX6f4sdtMiVYf8bhu9ol7/cJlTJW6nhrprkEvdt9F0iRBKOOxihrchE3Zv1 7FIttWlb5uy1ArKgqL+DU6QUXlGeijqv8egDGCntlNkdjtv7foOA920KNIv958eksqes o4iWdkViKxP5Wwjf+uO4dcCksyN51av970tez21w+94cedvGbGDK4RUWOX7vaUtDVLFs WRM5epNCgFQQFh3SY9lQXjHtP6o2Po4SmIJmOEccb1jl54bYqxSyWh1r2FJjKW9a7FwM 5qkg== 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=DTISRdKBV2WV8e9lTnA3HgZPM/rWlujw5yDxKgQzbJM=; b=gaWcU36L1H9wwNUb5DEXrKNPxv2yZEZ1gGN1vp6+pA5y0TLnZBw/Q2OYc9ko7kpLxd fZa8pBy06PIw4hf7y+W9qYqhHsDMQ9ly7e565t7IpOhDeaMgKCJcYxrfjJm5JFTAp/wk Bc2ngRr53/GqLHKa0a+9ED2DwznhKM4ax+cpOw/FoetCqjQIdOpSE2AcpnaNBoc+Jivy gQ610C/gmoxEtpe30Wwywx0LrNNEmO3p8U7Zz4KGw2ZXUy8jdU68H0SfykiHyh+VGOcy V131fQdBLVWF9SJXvRbeqUgAy15n1Z168RdifrSP0lorKu992+S/ceIT4XVDmUTVQvuA z73A== 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 x9si6646011ejy.403.2020.11.23.05.56.01; Mon, 23 Nov 2020 05:56:25 -0800 (PST) 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 S2388580AbgKWNwg (ORCPT + 99 others); Mon, 23 Nov 2020 08:52:36 -0500 Received: from mga14.intel.com ([192.55.52.115]:1517 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388215AbgKWNwf (ORCPT ); Mon, 23 Nov 2020 08:52:35 -0500 IronPort-SDR: +Xj8nF9BtGVC9+3Ard/b3tVYom0F4G6bsmvc6q9/BU0aKVW8PUaDg26ppJ8Vs1xb8UMqx7R5WY 3TwA97QMFNLA== X-IronPort-AV: E=McAfee;i="6000,8403,9813"; a="170981507" X-IronPort-AV: E=Sophos;i="5.78,363,1599548400"; d="scan'208";a="170981507" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2020 05:52:35 -0800 IronPort-SDR: ZpFg2E6bbIJ7ajCW1ggTmbmybcU5Y90nPijeaUgndCqKv/GfTQMadC2w5ZUqCpVxNGSkma4X6f ZwdLyiy5q+gg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,363,1599548400"; d="scan'208";a="370035655" Received: from bgsxx0031.iind.intel.com ([10.106.222.40]) by orsmga007.jf.intel.com with ESMTP; 23 Nov 2020 05:52:33 -0800 From: M Chetan Kumar To: netdev@vger.kernel.org, linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, krishna.c.sudi@intel.com, m.chetan.kumar@intel.com Subject: [RFC 15/18] net: iosm: uevent support Date: Mon, 23 Nov 2020 19:21:20 +0530 Message-Id: <20201123135123.48892-16-m.chetan.kumar@intel.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20201123135123.48892-1-m.chetan.kumar@intel.com> References: <20201123135123.48892-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 --- drivers/net/wwan/iosm/iosm_ipc_uevent.c | 47 +++++++++++++++++++++++++++++++++ drivers/net/wwan/iosm/iosm_ipc_uevent.h | 41 ++++++++++++++++++++++++++++ 2 files changed, 88 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..27542ca27613 --- /dev/null +++ b/drivers/net/wwan/iosm/iosm_ipc_uevent.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2020 Intel Corporation. + */ + +#include + +#include "iosm_ipc_sio.h" +#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; + + if (!uevent || !dev) + return; + + 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..422f64411c6e --- /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 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.12.3