Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp325952ybg; Mon, 1 Jun 2020 02:21:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmX/SHzhooWvSKZKec8q5rjvAoJKCLwK/HR7ZibFN32X/21SMM9mhoQLkRRkQjbMFzIVgX X-Received: by 2002:a50:f094:: with SMTP id v20mr20476877edl.77.1591003268069; Mon, 01 Jun 2020 02:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591003268; cv=none; d=google.com; s=arc-20160816; b=cs3TL+3/EvZ1Dd8WeQ82a9dqo8hveaXcHoIe91Tq/S8YL8MD8U7jlGPhXE/eyy2XSA 63Iz5hXvQkzePMh7yhwRwRbzaQjQv95A3KE8tJQeM7AMPOAojzul1HxzKcM4/nl33RWP h8Hw2rnpU2N2koUW0jCta290AFpCGBYZ2Z75NZIsT8dKXHF2M/k2c1RC/EKn56h5jDuI X4fe4GldQtts5eW3bGJQQ/RdcEUXwMFjQDh2f2TPppaaMOdt8rN1NJljW1ZEVU6vPKV+ OOkYB9L5mzFQLH/DKBcgIrIPVQOE6Pz2LlBNuOzBtmX2TAfNF613BvByvTzFyYtI9k7/ sU+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=VQp5IfCU97SgRzF7avQDW7w3ZdHSwoW6megc62aVqsg=; b=GKi6Cp8tx4dNNgn7VEa43ek037SXU9kjhEGWVqHHB3ZbO1xhIo2fcYEMEznQxSwT09 Pk4GfQtKBWTAkJ2EQHFghlJQVogxEvJFm4AGO9ugL1J56ZvSX8dSf7DHCtj5aKMmY7KX 7ZpaygEUNE70UvSnONpyPIbcOi8ri/8Y67ZRi4xeVMKDdnDvWnYr6zDlo+WCII15bWEx tlVfsEB40QC73J9guHnT2P/zzTbqivqd/yM/n7zjZ2G//P59V4zczMdKoLcYIZYKsSkm dGj2vYlh8EMDacRJAJi3kRB3c2+6fVCqRQzuvFvttO8oR+hOmiBU4gaOO9C/jJw7BRHv SJeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n23si10596666ejk.174.2020.06.01.02.20.45; Mon, 01 Jun 2020 02:21:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726038AbgFAJTB (ORCPT + 99 others); Mon, 1 Jun 2020 05:19:01 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:51531 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725831AbgFAJTB (ORCPT ); Mon, 1 Jun 2020 05:19:01 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from vadimp@mellanox.com) with ESMTPS (AES256-SHA encrypted); 1 Jun 2020 12:18:59 +0300 Received: from r-build-lowlevel.mtr.labs.mlnx. (r-build-lowlevel.mtr.labs.mlnx [10.209.0.190]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 0519IsSq003135; Mon, 1 Jun 2020 12:18:58 +0300 From: Vadim Pasternak To: andy@infradead.org, dvhart@infradead.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Vadim Pasternak Subject: [PATCH platform-next v1 2/8] platform/mellanox: mlxreg-hotplug: Add environmental data to uevent Date: Mon, 1 Jun 2020 12:18:45 +0300 Message-Id: <20200601091851.5491-3-vadimp@mellanox.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200601091851.5491-1-vadimp@mellanox.com> References: <20200601091851.5491-1-vadimp@mellanox.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Send "udev" event with environmental data in order to allow handling "ENV{}" variables in "udev" rules. Signed-off-by: Vadim Pasternak --- drivers/platform/mellanox/mlxreg-hotplug.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c index 832fcf282d45..5420d5bb0e6c 100644 --- a/drivers/platform/mellanox/mlxreg-hotplug.c +++ b/drivers/platform/mellanox/mlxreg-hotplug.c @@ -97,13 +97,36 @@ struct mlxreg_hotplug_priv_data { u8 not_asserted; }; +/* Environment variables array for udev. */ +static char *mlxreg_hotplug_udev_envp[] = { NULL, NULL }; + +static int +mlxreg_hotplug_udev_event_send(struct kobject *kobj, + struct mlxreg_core_data *data, bool action) +{ + char event_str[MLXREG_CORE_LABEL_MAX_SIZE + 2]; + char label[MLXREG_CORE_LABEL_MAX_SIZE] = { 0 }; + int i; + + mlxreg_hotplug_udev_envp[0] = event_str; + for (i = 0; data->label[i]; i++) + label[i] = toupper(data->label[i]); + + if (action) + snprintf(event_str, MLXREG_CORE_LABEL_MAX_SIZE, "%s=1", label); + else + snprintf(event_str, MLXREG_CORE_LABEL_MAX_SIZE, "%s=0", label); + + return kobject_uevent_env(kobj, KOBJ_CHANGE, mlxreg_hotplug_udev_envp); +} + static int mlxreg_hotplug_device_create(struct mlxreg_hotplug_priv_data *priv, struct mlxreg_core_data *data) { struct mlxreg_core_hotplug_platform_data *pdata; /* Notify user by sending hwmon uevent. */ - kobject_uevent(&priv->hwmon->kobj, KOBJ_CHANGE); + mlxreg_hotplug_udev_event_send(&priv->hwmon->kobj, data, true); /* * Return if adapter number is negative. It could be in case hotplug @@ -141,7 +164,7 @@ mlxreg_hotplug_device_destroy(struct mlxreg_hotplug_priv_data *priv, struct mlxreg_core_data *data) { /* Notify user by sending hwmon uevent. */ - kobject_uevent(&priv->hwmon->kobj, KOBJ_CHANGE); + mlxreg_hotplug_udev_event_send(&priv->hwmon->kobj, data, false); if (data->hpdev.client) { i2c_unregister_device(data->hpdev.client); -- 2.11.0