Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: iosm: uevent support

Report modem status via uevent.

Signed-off-by: M Chetan Kumar <m.chetan.kumar@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

M Chetan Kumar and committed by
David S. Miller
110e6e02 64516f63

+85
+44
drivers/net/wwan/iosm/iosm_ipc_uevent.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (C) 2020-21 Intel Corporation. 4 + */ 5 + 6 + #include <linux/device.h> 7 + #include <linux/kobject.h> 8 + #include <linux/slab.h> 9 + 10 + #include "iosm_ipc_uevent.h" 11 + 12 + /* Update the uevent in work queue context */ 13 + static void ipc_uevent_work(struct work_struct *data) 14 + { 15 + struct ipc_uevent_info *info; 16 + char *envp[2] = { NULL, NULL }; 17 + 18 + info = container_of(data, struct ipc_uevent_info, work); 19 + 20 + envp[0] = info->uevent; 21 + 22 + if (kobject_uevent_env(&info->dev->kobj, KOBJ_CHANGE, envp)) 23 + pr_err("uevent %s failed to sent", info->uevent); 24 + 25 + kfree(info); 26 + } 27 + 28 + void ipc_uevent_send(struct device *dev, char *uevent) 29 + { 30 + struct ipc_uevent_info *info = kzalloc(sizeof(*info), GFP_ATOMIC); 31 + 32 + if (!info) 33 + return; 34 + 35 + /* Initialize the kernel work queue */ 36 + INIT_WORK(&info->work, ipc_uevent_work); 37 + 38 + /* Store the device and event information */ 39 + info->dev = dev; 40 + snprintf(info->uevent, MAX_UEVENT_LEN, "%s: %s", dev_name(dev), uevent); 41 + 42 + /* Schedule uevent in process context using work queue */ 43 + schedule_work(&info->work); 44 + }
+41
drivers/net/wwan/iosm/iosm_ipc_uevent.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only 2 + * 3 + * Copyright (C) 2020-21 Intel Corporation. 4 + */ 5 + 6 + #ifndef IOSM_IPC_UEVENT_H 7 + #define IOSM_IPC_UEVENT_H 8 + 9 + /* Baseband event strings */ 10 + #define UEVENT_MDM_NOT_READY "MDM_NOT_READY" 11 + #define UEVENT_ROM_READY "ROM_READY" 12 + #define UEVENT_MDM_READY "MDM_READY" 13 + #define UEVENT_CRASH "CRASH" 14 + #define UEVENT_CD_READY "CD_READY" 15 + #define UEVENT_CD_READY_LINK_DOWN "CD_READY_LINK_DOWN" 16 + #define UEVENT_MDM_TIMEOUT "MDM_TIMEOUT" 17 + 18 + /* Maximum length of user events */ 19 + #define MAX_UEVENT_LEN 64 20 + 21 + /** 22 + * struct ipc_uevent_info - Uevent information structure. 23 + * @dev: Pointer to device structure 24 + * @uevent: Uevent information 25 + * @work: Uevent work struct 26 + */ 27 + struct ipc_uevent_info { 28 + struct device *dev; 29 + char uevent[MAX_UEVENT_LEN]; 30 + struct work_struct work; 31 + }; 32 + 33 + /** 34 + * ipc_uevent_send - Send modem event to user space. 35 + * @dev: Generic device pointer 36 + * @uevent: Uevent information 37 + * 38 + */ 39 + void ipc_uevent_send(struct device *dev, char *uevent); 40 + 41 + #endif