|
16 | 16 | #include <linux/platform_data/mlxreg.h>
|
17 | 17 | #include <linux/platform_device.h>
|
18 | 18 | #include <linux/spinlock.h>
|
| 19 | +#include <linux/string_helpers.h> |
19 | 20 | #include <linux/regmap.h>
|
20 | 21 | #include <linux/workqueue.h>
|
21 | 22 |
|
@@ -71,14 +72,31 @@ struct mlxreg_hotplug_priv_data {
|
71 | 72 | u8 not_asserted;
|
72 | 73 | };
|
73 | 74 |
|
| 75 | +/* Environment variables array for udev. */ |
| 76 | +static char *mlxreg_hotplug_udev_envp[] = { NULL, NULL }; |
| 77 | + |
| 78 | +static int |
| 79 | +mlxreg_hotplug_udev_event_send(struct kobject *kobj, |
| 80 | + struct mlxreg_core_data *data, bool action) |
| 81 | +{ |
| 82 | + char event_str[MLXREG_CORE_LABEL_MAX_SIZE + 2]; |
| 83 | + char label[MLXREG_CORE_LABEL_MAX_SIZE] = { 0 }; |
| 84 | + |
| 85 | + mlxreg_hotplug_udev_envp[0] = event_str; |
| 86 | + string_upper(label, data->label); |
| 87 | + snprintf(event_str, MLXREG_CORE_LABEL_MAX_SIZE, "%s=%d", label, !!action); |
| 88 | + |
| 89 | + return kobject_uevent_env(kobj, KOBJ_CHANGE, mlxreg_hotplug_udev_envp); |
| 90 | +} |
| 91 | + |
74 | 92 | static int mlxreg_hotplug_device_create(struct mlxreg_hotplug_priv_data *priv,
|
75 | 93 | struct mlxreg_core_data *data)
|
76 | 94 | {
|
77 | 95 | struct mlxreg_core_hotplug_platform_data *pdata;
|
78 | 96 | struct i2c_client *client;
|
79 | 97 |
|
80 | 98 | /* Notify user by sending hwmon uevent. */
|
81 |
| - kobject_uevent(&priv->hwmon->kobj, KOBJ_CHANGE); |
| 99 | + mlxreg_hotplug_udev_event_send(&priv->hwmon->kobj, data, true); |
82 | 100 |
|
83 | 101 | /*
|
84 | 102 | * Return if adapter number is negative. It could be in case hotplug
|
@@ -118,7 +136,7 @@ mlxreg_hotplug_device_destroy(struct mlxreg_hotplug_priv_data *priv,
|
118 | 136 | struct mlxreg_core_data *data)
|
119 | 137 | {
|
120 | 138 | /* Notify user by sending hwmon uevent. */
|
121 |
| - kobject_uevent(&priv->hwmon->kobj, KOBJ_CHANGE); |
| 139 | + mlxreg_hotplug_udev_event_send(&priv->hwmon->kobj, data, false); |
122 | 140 |
|
123 | 141 | if (data->hpdev.client) {
|
124 | 142 | i2c_unregister_device(data->hpdev.client);
|
|
0 commit comments