From patchwork Tue Nov 3 07:21:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 11876089 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6180592C for ; Tue, 3 Nov 2020 07:21:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 479B5222B9 for ; Tue, 3 Nov 2020 07:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604388082; bh=o6fp+CQROb5mfkUvFmDCY/ytcmgYQcBWN6do/tECBIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=DvDxrPxCr8OXJRBvMgYRhTWW0xeMt+928j666jlLCsYA+/lHL5iiQLcfSPhHF+ExU p/1cyRK7QrfeZxtrwytv+G16oGq0xPlCeE7HIgE73w4Nl8pYahC8JlzlPTSh+lMt3M MP5ioDndfNjdTBL4rm9hbNk0EeUxw+KDoZD7lwtU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725997AbgKCHVW (ORCPT ); Tue, 3 Nov 2020 02:21:22 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35555 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725958AbgKCHVV (ORCPT ); Tue, 3 Nov 2020 02:21:21 -0500 Received: by mail-pg1-f194.google.com with SMTP id f38so12999746pgm.2 for ; Mon, 02 Nov 2020 23:21:20 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=OOpWyyHN6uEjTvvh/CVgoIUoFWTPjExj/lMI6RgwbCs=; b=FeZSkAWcCh00kT1Dh9uSZOzqPWHzUPmYWJtsb93AiBuJzdB181HlvB84/0TFANjnop HuIYCz6Omr/HRulTyTmclR6koMh60loTSib32gIPaV2sfPNBjnpuTy7XST730UpzmCUd HULDN1RuXqUbhV/2dnLGy2B7N2Rib6rynp7Zlf6vABNne/7Jdm+idGP0xHSahITCFvDl 2knR+/F1xSn2Cc/k2s5IxJLAu3EIWPYX11GKhv+arRLnlZkRqSHgVc7wnduVKTt9uYuz OGxgAX6tMqv8cMpa+yqNJsZmxkJQNVe0CrU+1JPRXzbTtg/Iy9rWDdBcCHCt8FSMYiSM 62wg== X-Gm-Message-State: AOAM533b5tOL4MzjKLnBRHFsls3uWLu74fHQA0PsMREaWWDHmySUzdzk 3c+TiJAcJMw9m2nJfFSa9Y0= X-Google-Smtp-Source: ABdhPJyZ46fJyMlfSYG/hN1MaxfeIP9tzsSxvDbslRAOFhEVOzum4WDewVzMirmUfSkUX/ou9zsDzA== X-Received: by 2002:a17:90a:4295:: with SMTP id p21mr2395451pjg.217.1604388079739; Mon, 02 Nov 2020 23:21:19 -0800 (PST) Received: from localhost ([2601:647:5b00:1161:a4cc:eef9:fbc0:2781]) by smtp.gmail.com with ESMTPSA id e23sm15388992pfi.191.2020.11.02.23.21.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 23:21:19 -0800 (PST) From: Moritz Fischer To: gregkh@linuxfoundation.org Cc: linux-fpga@vger.kernel.org, Xu Yilun , Tom Rix , Moritz Fischer Subject: [PATCH 1/4] fpga: dfl: fix the definitions of type & feature_id for dfl devices Date: Mon, 2 Nov 2020 23:21:01 -0800 Message-Id: <20201103072104.12361-2-mdf@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103072104.12361-1-mdf@kernel.org> References: <20201103072104.12361-1-mdf@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Xu Yilun The value of the field dfl_device.type comes from the 12 bits register field DFH_ID according to DFL spec. So this patch changes the definition of the type field to u16. Also it is not necessary to illustrate the valid bits of the type field in comments. Instead we should explicitly define the possible values in the enumeration type for it, because they are shared by hardware spec. We should not let the compiler decide these values. Similar changes are also applied to dfl_device.feature_id. This patch also fixed the MODALIAS format according to the changes above. Signed-off-by: Xu Yilun Reviewed-by: Tom Rix Signed-off-by: Moritz Fischer --- drivers/fpga/dfl.c | 3 +-- drivers/fpga/dfl.h | 14 +++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c index b450870b75ed..5a6ba3b2fa05 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -298,8 +298,7 @@ static int dfl_bus_uevent(struct device *dev, struct kobj_uevent_env *env) { struct dfl_device *ddev = to_dfl_dev(dev); - /* The type has 4 valid bits and feature_id has 12 valid bits */ - return add_uevent_var(env, "MODALIAS=dfl:t%01Xf%03X", + return add_uevent_var(env, "MODALIAS=dfl:t%04Xf%04X", ddev->type, ddev->feature_id); } diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h index 5dc758f655b7..ac373b1fcff9 100644 --- a/drivers/fpga/dfl.h +++ b/drivers/fpga/dfl.h @@ -520,19 +520,19 @@ long dfl_feature_ioctl_set_irq(struct platform_device *pdev, * enum dfl_id_type - define the DFL FIU types */ enum dfl_id_type { - FME_ID, - PORT_ID, + FME_ID = 0, + PORT_ID = 1, DFL_ID_MAX, }; /** * struct dfl_device_id - dfl device identifier - * @type: contains 4 bits DFL FIU type of the device. See enum dfl_id_type. - * @feature_id: contains 12 bits feature identifier local to its DFL FIU type. + * @type: DFL FIU type of the device. See enum dfl_id_type. + * @feature_id: feature identifier local to its DFL FIU type. * @driver_data: driver specific data. */ struct dfl_device_id { - u8 type; + u16 type; u16 feature_id; unsigned long driver_data; }; @@ -543,7 +543,7 @@ struct dfl_device_id { * @dev: generic device interface. * @id: id of the dfl device. * @type: type of DFL FIU of the device. See enum dfl_id_type. - * @feature_id: 16 bits feature identifier local to its DFL FIU type. + * @feature_id: feature identifier local to its DFL FIU type. * @mmio_res: mmio resource of this dfl device. * @irqs: list of Linux IRQ numbers of this dfl device. * @num_irqs: number of IRQs supported by this dfl device. @@ -553,7 +553,7 @@ struct dfl_device_id { struct dfl_device { struct device dev; int id; - u8 type; + u16 type; u16 feature_id; struct resource mmio_res; int *irqs; From patchwork Tue Nov 3 07:21:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 11876091 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8B79E14B2 for ; Tue, 3 Nov 2020 07:21:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71A71223AC for ; Tue, 3 Nov 2020 07:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604388082; bh=td+EII7C7Eltj96WtL1xMdv7T1aEFd7VvO5LI+IT26g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=aeCuxid9m2biVdWgLtSgjcifXrjWPAm4hnc7P+dL+n5gQnlIuEvnSYKFb6xmVcSEJ 9Y47IS3tXG0fTZWWAyI0ZEEamhk83BwTMKE698QJ1nWUWzKyP5aQJLf0JalMvHHUSA AH06V3cihFBiWASGw/LTVI+gyt+mNuCSFEUiFwCg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725958AbgKCHVW (ORCPT ); Tue, 3 Nov 2020 02:21:22 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:32957 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbgKCHVV (ORCPT ); Tue, 3 Nov 2020 02:21:21 -0500 Received: by mail-pl1-f194.google.com with SMTP id b19so8163784pld.0 for ; Mon, 02 Nov 2020 23:21:21 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=inYJkkmj+hglF0hl9VW5FqoaH1VFBfk/UnPb1jfM00w=; b=opK2XSvGgQI76saXXf0mUUPBqzq9IYDBj5WUiZO1w3GtjtisX4qNNqyFFTlYb3XAfd o8hU+GDHYeq6qZAnph9YFS4WWAhJwMqX9zejlgrUaacKyfAfqzTwK/XwtCaxxjdFljAc l4dkY38xXeaAK9ADzXMn7Rz0WTZA7N9gzSZ9z7r843QYsa035EemeICpqUlLqEKa1CF4 bxg/t0yfbLR4/ztXNQ/s0M7DVbRiAduAukYFJRE8w9dd6LFyNQKOfoLv9SHV2zdCdayu CgsAQVbTj5+frdTgGCqbu6iICnf2/s1zCrlzSY05WLJ9eoOqbPrWwXV2+//O7GkldlBa lrHA== X-Gm-Message-State: AOAM531urkkxdiOakDbLTMnyUHVAvwEQQx5us+ZM7HHG4FTOeQYrtUI2 pNwxJGpXhofbC0CuCvMeQNc= X-Google-Smtp-Source: ABdhPJyeJDwuQU3x3wBQVaPke9Zx+QggAIRDzLh89uDPfWIZ/+rj9EVYQoKkeNVz2hUW9Xc3FjSo/A== X-Received: by 2002:a17:902:e788:b029:d6:dc69:80a8 with SMTP id cp8-20020a170902e788b02900d6dc6980a8mr4190254plb.59.1604388081055; Mon, 02 Nov 2020 23:21:21 -0800 (PST) Received: from localhost ([2601:647:5b00:1161:a4cc:eef9:fbc0:2781]) by smtp.gmail.com with ESMTPSA id cv4sm1961092pjb.1.2020.11.02.23.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 23:21:20 -0800 (PST) From: Moritz Fischer To: gregkh@linuxfoundation.org Cc: linux-fpga@vger.kernel.org, Xu Yilun , Wu Hao , Matthew Gerlach , Russ Weight , Tom Rix , Moritz Fischer Subject: [PATCH 2/4] fpga: dfl: move dfl_device_id to mod_devicetable.h Date: Mon, 2 Nov 2020 23:21:02 -0800 Message-Id: <20201103072104.12361-3-mdf@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103072104.12361-1-mdf@kernel.org> References: <20201103072104.12361-1-mdf@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Xu Yilun In order to support MODULE_DEVICE_TABLE() for dfl device driver, this patch moves struct dfl_device_id to mod_devicetable.h Some brief description for DFL (Device Feature List) is added to make the DFL known to the whole kernel. Signed-off-by: Xu Yilun Signed-off-by: Wu Hao Signed-off-by: Matthew Gerlach Signed-off-by: Russ Weight Reviewed-by: Tom Rix Acked-by: Wu Hao Signed-off-by: Moritz Fischer --- drivers/fpga/dfl.h | 13 +------------ include/linux/mod_devicetable.h | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h index ac373b1fcff9..549c7900dcfd 100644 --- a/drivers/fpga/dfl.h +++ b/drivers/fpga/dfl.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -525,18 +526,6 @@ enum dfl_id_type { DFL_ID_MAX, }; -/** - * struct dfl_device_id - dfl device identifier - * @type: DFL FIU type of the device. See enum dfl_id_type. - * @feature_id: feature identifier local to its DFL FIU type. - * @driver_data: driver specific data. - */ -struct dfl_device_id { - u16 type; - u16 feature_id; - unsigned long driver_data; -}; - /** * struct dfl_device - represent an dfl device on dfl bus * diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 5b08a473cdba..e4870e5d3ea8 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -838,4 +838,28 @@ struct mhi_device_id { kernel_ulong_t driver_data; }; +/* + * DFL (Device Feature List) + * + * DFL defines a linked list of feature headers within the device MMIO space to + * provide an extensible way of adding features. Software can walk through these + * predefined data structures to enumerate features. It is now used in the FPGA. + * See Documentation/fpga/dfl.rst for more information. + * + * The dfl bus type is introduced to match the individual feature devices (dfl + * devices) for specific dfl drivers. + */ + +/** + * struct dfl_device_id - dfl device identifier + * @type: DFL FIU type of the device. See enum dfl_id_type. + * @feature_id: feature identifier local to its DFL FIU type. + * @driver_data: driver specific data. + */ +struct dfl_device_id { + __u16 type; + __u16 feature_id; + unsigned long driver_data; +}; + #endif /* LINUX_MOD_DEVICETABLE_H */ From patchwork Tue Nov 3 07:21:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 11876093 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A65416A2 for ; Tue, 3 Nov 2020 07:21:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 894CD223AB for ; Tue, 3 Nov 2020 07:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604388083; bh=k/w0aqn0JiVeD86f2wpSQvfawk8c2dc0l+X/lvcrFeY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=M2yMpUIyz8OybFse0MXIEFy/cEcHYME4faUzwUExysFWtvRd6KldAzxL6Vi/5myaV qk3bVOsFu5uQMxGpv5iWoCDNIg0VyEjJUQd9spXpJBW2sG9jd10GKZ4zQTTF24xau8 Ss7qmMiA39oeyVKWw0mHENxlixXvBw+aBsa5EDwE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727589AbgKCHVX (ORCPT ); Tue, 3 Nov 2020 02:21:23 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:46568 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbgKCHVX (ORCPT ); Tue, 3 Nov 2020 02:21:23 -0500 Received: by mail-pf1-f193.google.com with SMTP id y14so13390661pfp.13 for ; Mon, 02 Nov 2020 23:21:22 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=/l5+sH9ZV3KVY9dL9+dpfycY1OwjtZ+7+ED7dKIYk/A=; b=tXKvV/nUlvE2984H5kbrXotdokZmgwboe53Qomh6N/KVVc7xsOhLX5N9n/k1dmSlDS GwRXZDoSBGyrAjrf1vqjOXr4Gqcmj85HTP008FbmDebutW6lMHZDDSjL/iAEbFJHGbMs 1rW+3vWydeTPALzu1fS5bLTkf0AFtHOBBZedu81riNe5nlf0FPefS0TVgNaUNggGJ+Hx MYXQ1G8t8h+/UpEBf3eFgjnIg4ZZKMjyLKAfJCnPpsSP3ou3JK1NMZKAF9ZdPYZSk+w5 g01fr0vw1O2ar2zyUr3Ld4mDSmNlQBAtYget5+TPNKewSMuJzzCq6m0rsZWyZgNObvDH rBvg== X-Gm-Message-State: AOAM532UQS+3R9zUFMKIavPyG5f1eBN/CRebe5+Wv49KkzFvnZoIBas6 UIbNEfVvJA1a7J3sI8ZxJon5XN2/E4o= X-Google-Smtp-Source: ABdhPJz3dhtVOVNibbUyxxosjfqjKln57WrQPg+HMEX4I2vlIC6BlgytE7542a7DY68qVsk0TJ5jfg== X-Received: by 2002:a62:f846:0:b029:15f:f897:7647 with SMTP id c6-20020a62f8460000b029015ff8977647mr24631885pfm.75.1604388082448; Mon, 02 Nov 2020 23:21:22 -0800 (PST) Received: from localhost ([2601:647:5b00:1161:a4cc:eef9:fbc0:2781]) by smtp.gmail.com with ESMTPSA id y141sm15755634pfb.17.2020.11.02.23.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 23:21:22 -0800 (PST) From: Moritz Fischer To: gregkh@linuxfoundation.org Cc: linux-fpga@vger.kernel.org, Xu Yilun , Wu Hao , Matthew Gerlach , Russ Weight , Moritz Fischer Subject: [PATCH 3/4] fpga: dfl: add dfl bus support to MODULE_DEVICE_TABLE() Date: Mon, 2 Nov 2020 23:21:03 -0800 Message-Id: <20201103072104.12361-4-mdf@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103072104.12361-1-mdf@kernel.org> References: <20201103072104.12361-1-mdf@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Xu Yilun Device Feature List (DFL) is a linked list of feature headers within the device MMIO space. It is used by FPGA to enumerate multiple sub features within it. Each feature can be uniquely identified by DFL type and feature id, which can be read out from feature headers. A dfl bus helps DFL framework modularize DFL device drivers for different sub features. The dfl bus matches its devices and drivers by DFL type and feature id. This patch adds dfl bus support to MODULE_DEVICE_TABLE() by adding info about struct dfl_device_id in devicetable-offsets.c and add a dfl entry point in file2alias.c. Signed-off-by: Xu Yilun Signed-off-by: Wu Hao Signed-off-by: Matthew Gerlach Signed-off-by: Russ Weight Acked-by: Wu Hao Signed-off-by: Moritz Fischer --- scripts/mod/devicetable-offsets.c | 4 ++++ scripts/mod/file2alias.c | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index 27007c18e754..d8350eea6d1a 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c @@ -243,5 +243,9 @@ int main(void) DEVID(mhi_device_id); DEVID_FIELD(mhi_device_id, chan); + DEVID(dfl_device_id); + DEVID_FIELD(dfl_device_id, type); + DEVID_FIELD(dfl_device_id, feature_id); + return 0; } diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 2417dd1dee33..8a438c94dcd9 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1368,6 +1368,18 @@ static int do_mhi_entry(const char *filename, void *symval, char *alias) return 1; } +/* Looks like: dfl:tNfN */ +static int do_dfl_entry(const char *filename, void *symval, char *alias) +{ + DEF_FIELD(symval, dfl_device_id, type); + DEF_FIELD(symval, dfl_device_id, feature_id); + + sprintf(alias, "dfl:t%04Xf%04X", type, feature_id); + + add_wildcard(alias); + return 1; +} + /* Does namelen bytes of name exactly match the symbol? */ static bool sym_is(const char *name, unsigned namelen, const char *symbol) { @@ -1442,6 +1454,7 @@ static const struct devtable devtable[] = { {"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}, + {"dfl", SIZE_dfl_device_id, do_dfl_entry}, }; /* Create MODULE_ALIAS() statements. From patchwork Tue Nov 3 07:21:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 11876095 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B658292C for ; Tue, 3 Nov 2020 07:21:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 96383223AB for ; Tue, 3 Nov 2020 07:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604388086; bh=X+WGVcgXBQxBSVpOYJp2p6pXyfE7SRk1ducMJq0x0yA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=UMQxTDwbuq4BPBRjSvnbbWXP6nKx5fjhWU4Vb58Inv6EZIVIRNwd+Z9m1BDajjkaq p4fKU0hVtGKevdQx+mJQCMksnMYwjWU9Pnz/jrJgxUYuqh2nfEdm1JGrixWFlKsbxP LX3EvUFg3OPBwchHwPwJIKUXp0LKsa98msL5+TVM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727686AbgKCHV0 (ORCPT ); Tue, 3 Nov 2020 02:21:26 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:40061 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbgKCHV0 (ORCPT ); Tue, 3 Nov 2020 02:21:26 -0500 Received: by mail-pl1-f195.google.com with SMTP id j5so8148620plk.7 for ; Mon, 02 Nov 2020 23:21:24 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=SBdjqSepf9b8NkBiN3+hl1ONOd5Sr5UVS9OwjhE/lMo=; b=nG2bhC3tzeSZt+gBBNO1kPn0vx94PS6Df78j1BFiuKiJSIpmjS6uVR8+zRsmaRxgo5 D2cilsLEdV/S+tHjF6psHO6esKRyVphBxfXXTj/a5tx8Uallen8J6rm7sCxagpwHJgFx be5EMnRTWcFbvARwzm3DYlYAustw0llWCmpr/uwtwpQGViTk52BLjvYEKrXlb/PdVP1P kUTSS7CKhDk9OiwW6C8+rdRyqCP4ZsZbS3TIe/GtXeDNgoBFSQ3cucIsbryhDFrJK34O B+2DZBn61FVvmmlfaH9qLLmVGGRsZvu96xS5f+KLJenDdOjItwEvoa5FrLv37vhUg8mc vJcA== X-Gm-Message-State: AOAM533ejc31BxyoabRPM8i8t2zKFtew8DnOVX6hIEnriXWaj+ivlYEZ 5v6XtYooukgfJ4nPByxgElM= X-Google-Smtp-Source: ABdhPJyYW3wRIF1jMpwYzcLRUSAA1hpG6tMnOvaoIXZ6fKkdUG+C7IcAj0YrzFAUqduTH4j8wULrmQ== X-Received: by 2002:a17:902:6b88:b029:d3:e6c5:fa3c with SMTP id p8-20020a1709026b88b02900d3e6c5fa3cmr24412185plk.80.1604388083868; Mon, 02 Nov 2020 23:21:23 -0800 (PST) Received: from localhost ([2601:647:5b00:1161:a4cc:eef9:fbc0:2781]) by smtp.gmail.com with ESMTPSA id j12sm5550303pga.78.2020.11.02.23.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 23:21:23 -0800 (PST) From: Moritz Fischer To: gregkh@linuxfoundation.org Cc: linux-fpga@vger.kernel.org, Xu Yilun , Tom Rix , Wu Hao , Moritz Fischer Subject: [PATCH 4/4] fpga: dfl: move dfl bus related APIs to include/linux/dfl.h Date: Mon, 2 Nov 2020 23:21:04 -0800 Message-Id: <20201103072104.12361-5-mdf@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103072104.12361-1-mdf@kernel.org> References: <20201103072104.12361-1-mdf@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Xu Yilun Now the dfl drivers could be made as independent modules and put in different folders according to their functionalities. In order for scattered dfl device drivers to include dfl bus APIs, move the dfl bus APIs to a new header file in the public folder. [mdf@kernel.org: Fixed up header guards to match filename] Signed-off-by: Xu Yilun Reviewed-by: Tom Rix Acked-by: Wu Hao Signed-off-by: Moritz Fischer --- MAINTAINERS | 1 + drivers/fpga/dfl.c | 1 + drivers/fpga/dfl.h | 72 ------------------------------------- include/linux/dfl.h | 86 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 72 deletions(-) create mode 100644 include/linux/dfl.h diff --git a/MAINTAINERS b/MAINTAINERS index e73636b75f29..9bbb378308a8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6886,6 +6886,7 @@ S: Maintained F: Documentation/ABI/testing/sysfs-bus-dfl F: Documentation/fpga/dfl.rst F: drivers/fpga/dfl* +F: include/linux/dfl.h F: include/uapi/linux/fpga-dfl.h FPGA MANAGER FRAMEWORK diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c index 5a6ba3b2fa05..511b20ff35a3 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -10,6 +10,7 @@ * Wu Hao * Xiao Guangrong */ +#include #include #include #include diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h index 549c7900dcfd..2b82c96ba56c 100644 --- a/drivers/fpga/dfl.h +++ b/drivers/fpga/dfl.h @@ -517,76 +517,4 @@ long dfl_feature_ioctl_set_irq(struct platform_device *pdev, struct dfl_feature *feature, unsigned long arg); -/** - * enum dfl_id_type - define the DFL FIU types - */ -enum dfl_id_type { - FME_ID = 0, - PORT_ID = 1, - DFL_ID_MAX, -}; - -/** - * struct dfl_device - represent an dfl device on dfl bus - * - * @dev: generic device interface. - * @id: id of the dfl device. - * @type: type of DFL FIU of the device. See enum dfl_id_type. - * @feature_id: feature identifier local to its DFL FIU type. - * @mmio_res: mmio resource of this dfl device. - * @irqs: list of Linux IRQ numbers of this dfl device. - * @num_irqs: number of IRQs supported by this dfl device. - * @cdev: pointer to DFL FPGA container device this dfl device belongs to. - * @id_entry: matched id entry in dfl driver's id table. - */ -struct dfl_device { - struct device dev; - int id; - u16 type; - u16 feature_id; - struct resource mmio_res; - int *irqs; - unsigned int num_irqs; - struct dfl_fpga_cdev *cdev; - const struct dfl_device_id *id_entry; -}; - -/** - * struct dfl_driver - represent an dfl device driver - * - * @drv: driver model structure. - * @id_table: pointer to table of device IDs the driver is interested in. - * { } member terminated. - * @probe: mandatory callback for device binding. - * @remove: callback for device unbinding. - */ -struct dfl_driver { - struct device_driver drv; - const struct dfl_device_id *id_table; - - int (*probe)(struct dfl_device *dfl_dev); - void (*remove)(struct dfl_device *dfl_dev); -}; - -#define to_dfl_dev(d) container_of(d, struct dfl_device, dev) -#define to_dfl_drv(d) container_of(d, struct dfl_driver, drv) - -/* - * use a macro to avoid include chaining to get THIS_MODULE. - */ -#define dfl_driver_register(drv) \ - __dfl_driver_register(drv, THIS_MODULE) -int __dfl_driver_register(struct dfl_driver *dfl_drv, struct module *owner); -void dfl_driver_unregister(struct dfl_driver *dfl_drv); - -/* - * module_dfl_driver() - Helper macro for drivers that don't do - * anything special in module init/exit. This eliminates a lot of - * boilerplate. Each module may only use this macro once, and - * calling it replaces module_init() and module_exit(). - */ -#define module_dfl_driver(__dfl_driver) \ - module_driver(__dfl_driver, dfl_driver_register, \ - dfl_driver_unregister) - #endif /* __FPGA_DFL_H */ diff --git a/include/linux/dfl.h b/include/linux/dfl.h new file mode 100644 index 000000000000..6cc10982351a --- /dev/null +++ b/include/linux/dfl.h @@ -0,0 +1,86 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Header file for DFL driver and device API + * + * Copyright (C) 2020 Intel Corporation, Inc. + */ + +#ifndef __LINUX_DFL_H +#define __LINUX_DFL_H + +#include +#include + +/** + * enum dfl_id_type - define the DFL FIU types + */ +enum dfl_id_type { + FME_ID = 0, + PORT_ID = 1, + DFL_ID_MAX, +}; + +/** + * struct dfl_device - represent an dfl device on dfl bus + * + * @dev: generic device interface. + * @id: id of the dfl device. + * @type: type of DFL FIU of the device. See enum dfl_id_type. + * @feature_id: feature identifier local to its DFL FIU type. + * @mmio_res: mmio resource of this dfl device. + * @irqs: list of Linux IRQ numbers of this dfl device. + * @num_irqs: number of IRQs supported by this dfl device. + * @cdev: pointer to DFL FPGA container device this dfl device belongs to. + * @id_entry: matched id entry in dfl driver's id table. + */ +struct dfl_device { + struct device dev; + int id; + u16 type; + u16 feature_id; + struct resource mmio_res; + int *irqs; + unsigned int num_irqs; + struct dfl_fpga_cdev *cdev; + const struct dfl_device_id *id_entry; +}; + +/** + * struct dfl_driver - represent an dfl device driver + * + * @drv: driver model structure. + * @id_table: pointer to table of device IDs the driver is interested in. + * { } member terminated. + * @probe: mandatory callback for device binding. + * @remove: callback for device unbinding. + */ +struct dfl_driver { + struct device_driver drv; + const struct dfl_device_id *id_table; + + int (*probe)(struct dfl_device *dfl_dev); + void (*remove)(struct dfl_device *dfl_dev); +}; + +#define to_dfl_dev(d) container_of(d, struct dfl_device, dev) +#define to_dfl_drv(d) container_of(d, struct dfl_driver, drv) + +/* + * use a macro to avoid include chaining to get THIS_MODULE. + */ +#define dfl_driver_register(drv) \ + __dfl_driver_register(drv, THIS_MODULE) +int __dfl_driver_register(struct dfl_driver *dfl_drv, struct module *owner); +void dfl_driver_unregister(struct dfl_driver *dfl_drv); + +/* + * module_dfl_driver() - Helper macro for drivers that don't do + * anything special in module init/exit. This eliminates a lot of + * boilerplate. Each module may only use this macro once, and + * calling it replaces module_init() and module_exit(). + */ +#define module_dfl_driver(__dfl_driver) \ + module_driver(__dfl_driver, dfl_driver_register, \ + dfl_driver_unregister) + +#endif /* __LINUX_DFL_H */