Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp459256pxu; Thu, 7 Jan 2021 09:10:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOr4J/emJ1JUIRNDeUwl6fKK8GE7QJYoTuG+I4WgC6ZhcpVryLspXeHulMqB0Irag8u16P X-Received: by 2002:a17:906:2c54:: with SMTP id f20mr7162182ejh.318.1610039426165; Thu, 07 Jan 2021 09:10:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610039426; cv=none; d=google.com; s=arc-20160816; b=xeowZexG4PB+dz1P006Nnm9AfKVtIHsya+jMGwBlDEjstDThGWGrTnKLv6kmMWLyJ7 FpNBFCW71+kalmOHePprqPr/tW2WB/KrYlZeDjhKF3a3vDE+jL3WUIwwrYLuqV2OR1HF TQ3OBripv89atM2UUAi9rtH/z9KOAQ5A8UTsBJ30dEQe06A8jIfKS5OnA+3+l/caIaxa Z7snZATOoK3e7f3kt/FMsyKl4OmukSUAu/0ymZ0ftG9QXDxYQzCUbWoVbt6jIJMiMLyU bstV8fYIGEHFEAtyunqkiaU9FuF8zFCPSKKzNSPjAYba1hwQh38NhZb0AHBo6Vs4IQYx b8OA== 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=qxdHwh0Iyat4D9I5ml02AfNtLGHMEb4L1ETxqfyJBqA=; b=E2Q5uYn/ErIqAL5i+2tByTm5dNG8KCs0f2eZfqI1gzsEldquvpun/QqL2pkM6rsC9/ XCLCCeLxvlvdl0dg9NFJJfR2VfJq2Or294qUeJ07VgixAjGN6kSzj1WLjp6srJqNMYfI CPNcKgyscf6coJNE15dAizvh3j4utccJ+h7GiwztirqRx+KdU9Teu2hME90VRuFXvQ4x SZISiibwl79rBnhNEkqQTZtM6r66pHUMC5At/nblWVpYTF9BwTnioN0p1HGmqh/y1LjP xYn50ZyYxwRhitt6h2vk6tszfVB5IChos+MMFpOPU0OpOW2pm4BZAJg6m6f/+pd1bjC8 im9w== 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 u7si2598508edb.213.2021.01.07.09.10.03; Thu, 07 Jan 2021 09:10:26 -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 S1729084AbhAGRH3 (ORCPT + 99 others); Thu, 7 Jan 2021 12:07:29 -0500 Received: from mga14.intel.com ([192.55.52.115]:53942 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729081AbhAGRH3 (ORCPT ); Thu, 7 Jan 2021 12:07:29 -0500 IronPort-SDR: K6ccX36oliDOaFiDjBQZaKzex/9KJuxdsCFK2mMOBs6tp6fVhe88/N8WoWytPYt9RUVITTTgi4 6YBih9qFeQkQ== X-IronPort-AV: E=McAfee;i="6000,8403,9857"; a="176681037" X-IronPort-AV: E=Sophos;i="5.79,329,1602572400"; d="scan'208";a="176681037" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jan 2021 09:06:36 -0800 IronPort-SDR: /l/Z8dND4oajdoCjl27XrY0mFcrifLPhMkfyiL6+N7xUvBMpItRo9FYLd0bUSDJZa2+HpiBJjN VCf9G4bDnFdw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,329,1602572400"; d="scan'208";a="422644052" Received: from bgsxx0031.iind.intel.com ([10.106.222.40]) by orsmga001.jf.intel.com with ESMTP; 07 Jan 2021 09:06:34 -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: [PATCH 15/18] net: iosm: uevent support Date: Thu, 7 Jan 2021 22:35:20 +0530 Message-Id: <20210107170523.26531-16-m.chetan.kumar@intel.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20210107170523.26531-1-m.chetan.kumar@intel.com> References: <20210107170523.26531-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 | 43 +++++++++++++++++++++++++++++++++ drivers/net/wwan/iosm/iosm_ipc_uevent.h | 41 +++++++++++++++++++++++++++++++ 2 files changed, 84 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..9040ee6f6065 --- /dev/null +++ b/drivers/net/wwan/iosm/iosm_ipc_uevent.c @@ -0,0 +1,43 @@ +// 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 = 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