Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright (C) 2020-21 Intel Corporation.
0004  */
0005 
0006 #include <linux/device.h>
0007 #include <linux/kobject.h>
0008 #include <linux/slab.h>
0009 
0010 #include "iosm_ipc_uevent.h"
0011 
0012 /* Update the uevent in work queue context */
0013 static void ipc_uevent_work(struct work_struct *data)
0014 {
0015     struct ipc_uevent_info *info;
0016     char *envp[2] = { NULL, NULL };
0017 
0018     info = container_of(data, struct ipc_uevent_info, work);
0019 
0020     envp[0] = info->uevent;
0021 
0022     if (kobject_uevent_env(&info->dev->kobj, KOBJ_CHANGE, envp))
0023         pr_err("uevent %s failed to sent", info->uevent);
0024 
0025     kfree(info);
0026 }
0027 
0028 void ipc_uevent_send(struct device *dev, char *uevent)
0029 {
0030     struct ipc_uevent_info *info = kzalloc(sizeof(*info), GFP_ATOMIC);
0031 
0032     if (!info)
0033         return;
0034 
0035     /* Initialize the kernel work queue */
0036     INIT_WORK(&info->work, ipc_uevent_work);
0037 
0038     /* Store the device and event information */
0039     info->dev = dev;
0040     snprintf(info->uevent, MAX_UEVENT_LEN, "IOSM_EVENT=%s", uevent);
0041 
0042     /* Schedule uevent in process context using work queue */
0043     schedule_work(&info->work);
0044 }