From patchwork Tue Nov 30 08:21:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinbo Zhu X-Patchwork-Id: 12646507 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EDBDC433F5 for ; Tue, 30 Nov 2021 08:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239315AbhK3IZ4 (ORCPT ); Tue, 30 Nov 2021 03:25:56 -0500 Received: from mail.loongson.cn ([114.242.206.163]:39896 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234234AbhK3IZx (ORCPT ); Tue, 30 Nov 2021 03:25:53 -0500 Received: from localhost.localdomain.localdomain (unknown [10.2.5.46]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxz8on36Vhh7UBAA--.4073S2; Tue, 30 Nov 2021 16:22:06 +0800 (CST) From: Yinbo Zhu To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Masahiro Yamada , Michal Marek , Nick Desaulniers , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Cc: zhuyinbo@loongson.cn Subject: [PATCH v3 1/2] modpost: file2alias: make mdio alias configure match mdio uevent Date: Tue, 30 Nov 2021 16:21:56 +0800 Message-Id: <1638260517-13634-1-git-send-email-zhuyinbo@loongson.cn> X-Mailer: git-send-email 1.8.3.1 X-CM-TRANSID: AQAAf9Dxz8on36Vhh7UBAA--.4073S2 X-Coremail-Antispam: 1UD129KBjvJXoWxJr1DXF4rJw4xJFWUAFW8Zwb_yoW8Cw4UpF ZxGa42grWkWF47Wa15ua4DJr1UXw4kC3s5WayY9a10gFWqyrZYqr4SkFsIyr15CFWkXa40 gw13uFy8uw4UXrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvC14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I8E87Iv6xkF7I0E14v26r xl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E 8cxan2IY04v7MxkIecxEwVCm-wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJV W8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF 1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6x IIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAI cVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2Kf nxnUUI43ZEXa7VU1a9aPUUUUU== X-CM-SenderInfo: 52kx5xhqerqz5rrqw2lrqou0/ Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The do_mdio_entry was responsible for generating a phy alias configure that according to the phy driver's mdio_device_id, before apply this patch, which alias configure is like "alias mdio:000000010100000100001 1011101????", it doesn't match the phy_id of mdio_uevent, because of the phy_id was a hexadecimal digit and the mido uevent is consisit of phy_id with the char 'p', the uevent string is different from alias. Add this patch that mdio alias configure will can match mdio uevent. Signed-off-by: Yinbo Zhu Reported-by: Yinbo Zhu Signed-off-by: Russell King (Oracle) --- Change in v3: Rework the patch commit log information. include/linux/mod_devicetable.h | 2 ++ scripts/mod/file2alias.c | 17 +---------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index ae2e75d..7bd23bf 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -595,6 +595,8 @@ struct platform_device_id { kernel_ulong_t driver_data; }; +#define MDIO_ANY_ID (~0) + #define MDIO_NAME_SIZE 32 #define MDIO_MODULE_PREFIX "mdio:" diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 49aba86..63f3149 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1027,24 +1027,9 @@ static int do_platform_entry(const char *filename, static int do_mdio_entry(const char *filename, void *symval, char *alias) { - int i; DEF_FIELD(symval, mdio_device_id, phy_id); - DEF_FIELD(symval, mdio_device_id, phy_id_mask); - alias += sprintf(alias, MDIO_MODULE_PREFIX); - - for (i = 0; i < 32; i++) { - if (!((phy_id_mask >> (31-i)) & 1)) - *(alias++) = '?'; - else if ((phy_id >> (31-i)) & 1) - *(alias++) = '1'; - else - *(alias++) = '0'; - } - - /* Terminate the string */ - *alias = 0; - + ADD(alias, "p", phy_id != MDIO_ANY_ID, phy_id); return 1; } From patchwork Tue Nov 30 08:21:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinbo Zhu X-Patchwork-Id: 12646505 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C80F9C433EF for ; Tue, 30 Nov 2021 08:22:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235299AbhK3IZz (ORCPT ); Tue, 30 Nov 2021 03:25:55 -0500 Received: from mail.loongson.cn ([114.242.206.163]:39886 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229951AbhK3IZw (ORCPT ); Tue, 30 Nov 2021 03:25:52 -0500 Received: from localhost.localdomain.localdomain (unknown [10.2.5.46]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxz8on36Vhh7UBAA--.4073S3; Tue, 30 Nov 2021 16:22:06 +0800 (CST) From: Yinbo Zhu To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Masahiro Yamada , Michal Marek , Nick Desaulniers , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Cc: zhuyinbo@loongson.cn Subject: [PATCH v3 2/2] net: mdio: rework mdio_uevent for mdio ethernet phy device Date: Tue, 30 Nov 2021 16:21:57 +0800 Message-Id: <1638260517-13634-2-git-send-email-zhuyinbo@loongson.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1638260517-13634-1-git-send-email-zhuyinbo@loongson.cn> References: <1638260517-13634-1-git-send-email-zhuyinbo@loongson.cn> X-CM-TRANSID: AQAAf9Dxz8on36Vhh7UBAA--.4073S3 X-Coremail-Antispam: 1UD129KBjvJXoW7tw48GF15Arykuw48Zr4Utwb_yoW8CFy5pF 4rJFyrtrWjgr47Wwn5C3yDWF1a9397K397GryF9wsY9rs8AryDXFyftFy29r13AFW8u3W7 ta4vqr18ua4DJa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPm14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26F4UJVW0owA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1l e2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI 8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwAC jcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka0x kIwI1lc2xSY4AK6svPMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I 3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxV WUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8I cVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aV AFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZE Xa7VUjLL07UUUUU== X-CM-SenderInfo: 52kx5xhqerqz5rrqw2lrqou0/ Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The of_device_uevent_modalias is service for 'of' type platform driver , which ask the first args must be 'of' that use MODULE_DEVICE_TABLE when driver was exported, but ethernet phy is a kind of 'mdio' type device and it is inappropriate if driver use 'of' type for exporting, in fact, most mainstream ethernet phy driver hasn't used 'of' type, even though phy driver was exported use 'of' type and it's irrelevant with mdio_uevent, at this time, platform_uevent was responsible for reporting uevent to match modules.alias configure, so, whatever that of_device_uevent_modalias was unnecessary, this patch was to remove it and add phy_id as modio uevent then ethernet phy module auto load function will work well. Signed-off-by: Yinbo Zhu --- Change in v3: Rework the patch commit log information. drivers/net/phy/mdio_bus.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 6865d93..999f0d4 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -962,12 +962,12 @@ static int mdio_bus_match(struct device *dev, struct device_driver *drv) static int mdio_uevent(struct device *dev, struct kobj_uevent_env *env) { - int rc; + struct phy_device *pdev; - /* Some devices have extra OF data and an OF-style MODALIAS */ - rc = of_device_uevent_modalias(dev, env); - if (rc != -ENODEV) - return rc; + pdev = to_phy_device(dev); + + if (add_uevent_var(env, "MODALIAS=mdio:p%08X", pdev->phy_id)) + return -ENOMEM; return 0; } @@ -991,7 +991,7 @@ static int mdio_uevent(struct device *dev, struct kobj_uevent_env *env) }; struct bus_type mdio_bus_type = { - .name = "mdio_bus", + .name = "mdio", .dev_groups = mdio_bus_dev_groups, .match = mdio_bus_match, .uevent = mdio_uevent,