Skip to content

Commit 92d020f

Browse files
mellanoxbmcandy-shev
authored andcommitted
platform/mellanox: mlxreg-hotplug: Add environmental data to uevent
Send "udev" event with environmental data in order to allow handling "ENV{}" variables in "udev" rules. Signed-off-by: Vadim Pasternak <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]>
1 parent 0a43f7b commit 92d020f

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

drivers/platform/mellanox/mlxreg-hotplug.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/platform_data/mlxreg.h>
1717
#include <linux/platform_device.h>
1818
#include <linux/spinlock.h>
19+
#include <linux/string_helpers.h>
1920
#include <linux/regmap.h>
2021
#include <linux/workqueue.h>
2122

@@ -71,14 +72,31 @@ struct mlxreg_hotplug_priv_data {
7172
u8 not_asserted;
7273
};
7374

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+
7492
static int mlxreg_hotplug_device_create(struct mlxreg_hotplug_priv_data *priv,
7593
struct mlxreg_core_data *data)
7694
{
7795
struct mlxreg_core_hotplug_platform_data *pdata;
7896
struct i2c_client *client;
7997

8098
/* 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);
82100

83101
/*
84102
* 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,
118136
struct mlxreg_core_data *data)
119137
{
120138
/* 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);
122140

123141
if (data->hpdev.client) {
124142
i2c_unregister_device(data->hpdev.client);

0 commit comments

Comments
 (0)