Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp661754ybl; Fri, 31 Jan 2020 05:52:26 -0800 (PST) X-Google-Smtp-Source: APXvYqwxnDyIsEQh5xZe6cDWYfTcXAQZNRZBS8l4Aj76570qS99+9W+p/Q8VjBrGEmCQJmoylskP X-Received: by 2002:a9d:8f1:: with SMTP id 104mr7203393otf.107.1580478746580; Fri, 31 Jan 2020 05:52:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580478746; cv=none; d=google.com; s=arc-20160816; b=Ymv5RhmZ8g5JlO7qQZcTgEU2gp6m2Mmwx64CuQxK9brPrbx48wdI3FJ5K0tf7ELnUe KCewLyHx3sbXnMlaxNkltQCGWqXnbdOx8hTwoucpmAjVTAYKUKGoyMrtz6VAnzUGf/Zm vr7T/n1LVVU7F/26txIfZ9Te0TTo5Pf7MEbV090OHxlpkzSFAH32ndb1UjdGzT7xvUIi 2IibM2OpA9rrMrlVQrNDCQ4DJj4gYOjtRiZrMi8aZWHUKtq5j/xyr/W7ikhiNxWyndyM NYJS8zyM3SVjmGtYro8eS3oH2iZeWqtHAoSDtX/Kg3dpBXTanMmuMGOQXwrFRcZzn++C irQQ== 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:dkim-signature; bh=He0nwyLyvw8iwRh/ZM4DB0MP2DrbC25Y5VstWb++R0I=; b=ZWJ+G1eGLn5BP6uplULaYEB39Dq5+vmjTLnfYp3daLg8plXMQgPRc4u00Gx6rRM6Ss GrHXJAzE4uGCagtaylxRl/fES5R9wkhiqCV0S9VJ76zk9K+QDIQlEHXIWnQ5kPNKr5a/ oKzQPXjJUWOAfZwr8yF1aPyWbBxg2ISCxqfVKdEO/v77LCYP5ajqJS6hdKstPq1/2PLV f1lAuS/v/beTyTE+b5P2lf3HHzdpBMKgNQVRNOoj4CeSBzB6YfjSL1yJtQ05s+Lmz7v3 oO25enRAe5no27OI5SSEjXQ3TXFdhZ2WN4z03AHE11TdNr0qoF9MReh1q2Lb07ovPqv1 Mitg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tE7FqOa9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5si4871258oti.22.2020.01.31.05.52.14; Fri, 31 Jan 2020 05:52:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tE7FqOa9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729088AbgAaNvC (ORCPT + 99 others); Fri, 31 Jan 2020 08:51:02 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:46293 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729081AbgAaNvB (ORCPT ); Fri, 31 Jan 2020 08:51:01 -0500 Received: by mail-pf1-f196.google.com with SMTP id k29so3344595pfp.13 for ; Fri, 31 Jan 2020 05:51:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=He0nwyLyvw8iwRh/ZM4DB0MP2DrbC25Y5VstWb++R0I=; b=tE7FqOa9X+oQPmznxweZVv2qyRcf0/JugZZGlB2MA3aM6IF2Hu5FI6D7wqXRqjVEQD 2G7e+iVbfqSzRuqWhkHbb9N9KJ4CE91lJQAQnS8ZRlVAANadb2zOOlAfu3cBGgPId5DD B2A6RiQNLK5VXoiDIfuoGHxRmHP7IVyscHnIWFYAlkHzw3shmqxRLPw1zM8dkWdwERWC ksppFFi3CkNCdJoVXPBTh2idBnD+U1Y4Bb49iy+F4rrO9DEMaiGinEcllwR7lKDnt6UV 8uRn3n5ryxJSD1sIzc1qSUjs/Ts+QGgm0gfAuG715xnxO7zE6cBAjaNCrLKxYNemMpvq KOKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=He0nwyLyvw8iwRh/ZM4DB0MP2DrbC25Y5VstWb++R0I=; b=Pl0G1TduS2EdS/aQ6r5vuqPq9QYbxURAiJk7N3Y12OrxT4hZ2Rr2C3j/viLaykh5I4 u9LWIu1Ex8a9Nm+f+F0ypJF4V4FPVwWrDI/t0czMIqrI8ztZwRb2KZ0O5xbqxNrH4bws BQInx5unwkMTD3rSU08Url5zhIxaHwrXV8uPYTQYL7yaPFoSKtTsf9hiKUjjwf9OgkQ1 DQoycTKehmIvtR3bWoQQlBkitCIhF3BBEIKFFtkmuWVuP8HJBWZGeISQYCiGqgyi8r/u YlLCQ6Kh5LWP1i9TFQFwFXkO+GTPoZCLBHb9q4ORopUtIIbN4m3vGQNdf2gkVZ7ilDCr CYsw== X-Gm-Message-State: APjAAAX8bni/whc3zAp7tdPJQIXFTkUa2LEPEgOW2L+dSLnabFP9qVor wCHqVdCjYvueTIHk1owVn8WT X-Received: by 2002:a62:ed0b:: with SMTP id u11mr10513356pfh.46.1580478661096; Fri, 31 Jan 2020 05:51:01 -0800 (PST) Received: from localhost.localdomain ([103.59.133.81]) by smtp.googlemail.com with ESMTPSA id p3sm10625632pfg.184.2020.01.31.05.50.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jan 2020 05:51:00 -0800 (PST) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org, arnd@arndb.de Cc: smohanad@codeaurora.org, jhugo@codeaurora.org, kvalo@codeaurora.org, bjorn.andersson@linaro.org, hemantk@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 12/16] bus: mhi: core: Add uevent support for module autoloading Date: Fri, 31 Jan 2020 19:20:05 +0530 Message-Id: <20200131135009.31477-13-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200131135009.31477-1-manivannan.sadhasivam@linaro.org> References: <20200131135009.31477-1-manivannan.sadhasivam@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add uevent support to MHI bus so that the client drivers can be autoloaded by udev when the MHI devices gets created. The client drivers are expected to provide MODULE_DEVICE_TABLE with the MHI id_table struct so that the alias can be exported. Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/init.c | 9 +++++++++ include/linux/mod_devicetable.h | 1 + scripts/mod/devicetable-offsets.c | 3 +++ scripts/mod/file2alias.c | 10 ++++++++++ 4 files changed, 23 insertions(+) diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index 4d0e5bbb3389..711ddc661530 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -1247,6 +1247,14 @@ void mhi_driver_unregister(struct mhi_driver *mhi_drv) } EXPORT_SYMBOL_GPL(mhi_driver_unregister); +static int mhi_uevent(struct device *dev, struct kobj_uevent_env *env) +{ + struct mhi_device *mhi_dev = to_mhi_device(dev); + + return add_uevent_var(env, "MODALIAS=" MHI_DEVICE_MODALIAS_FMT, + mhi_dev->chan_name); +} + static int mhi_match(struct device *dev, struct device_driver *drv) { struct mhi_device *mhi_dev = to_mhi_device(dev); @@ -1273,6 +1281,7 @@ struct bus_type mhi_bus_type = { .name = "mhi", .dev_name = "mhi", .match = mhi_match, + .uevent = mhi_uevent, }; static int __init mhi_init(void) diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index be15e997fe39..f10e779a3fd0 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -821,6 +821,7 @@ struct wmi_device_id { const void *context; }; +#define MHI_DEVICE_MODALIAS_FMT "mhi:%s" #define MHI_NAME_SIZE 32 /** diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index 054405b90ba4..fe3f4a95cb21 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c @@ -231,5 +231,8 @@ int main(void) DEVID(wmi_device_id); DEVID_FIELD(wmi_device_id, guid_string); + DEVID(mhi_device_id); + DEVID_FIELD(mhi_device_id, chan); + return 0; } diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index c91eba751804..cae6a4e471b5 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1335,6 +1335,15 @@ static int do_wmi_entry(const char *filename, void *symval, char *alias) return 1; } +/* Looks like: mhi:S */ +static int do_mhi_entry(const char *filename, void *symval, char *alias) +{ + DEF_FIELD_ADDR(symval, mhi_device_id, chan); + sprintf(alias, MHI_DEVICE_MODALIAS_FMT, *chan); + + return 1; +} + /* Does namelen bytes of name exactly match the symbol? */ static bool sym_is(const char *name, unsigned namelen, const char *symbol) { @@ -1407,6 +1416,7 @@ static const struct devtable devtable[] = { {"typec", SIZE_typec_device_id, do_typec_entry}, {"tee", SIZE_tee_client_device_id, do_tee_entry}, {"wmi", SIZE_wmi_device_id, do_wmi_entry}, + {"mhi", SIZE_mhi_device_id, do_mhi_entry}, }; /* Create MODULE_ALIAS() statements. -- 2.17.1