iosm_ipc_uevent.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2020-21 Intel Corporation.
  4. */
  5. #include <linux/device.h>
  6. #include <linux/kobject.h>
  7. #include <linux/slab.h>
  8. #include "iosm_ipc_uevent.h"
  9. /* Update the uevent in work queue context */
  10. static void ipc_uevent_work(struct work_struct *data)
  11. {
  12. struct ipc_uevent_info *info;
  13. char *envp[2] = { NULL, NULL };
  14. info = container_of(data, struct ipc_uevent_info, work);
  15. envp[0] = info->uevent;
  16. if (kobject_uevent_env(&info->dev->kobj, KOBJ_CHANGE, envp))
  17. pr_err("uevent %s failed to sent", info->uevent);
  18. kfree(info);
  19. }
  20. void ipc_uevent_send(struct device *dev, char *uevent)
  21. {
  22. struct ipc_uevent_info *info = kzalloc(sizeof(*info), GFP_ATOMIC);
  23. if (!info)
  24. return;
  25. /* Initialize the kernel work queue */
  26. INIT_WORK(&info->work, ipc_uevent_work);
  27. /* Store the device and event information */
  28. info->dev = dev;
  29. snprintf(info->uevent, MAX_UEVENT_LEN, "IOSM_EVENT=%s", uevent);
  30. /* Schedule uevent in process context using work queue */
  31. schedule_work(&info->work);
  32. }