From patchwork Fri Nov 26 09:45: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: 12640313 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 75F35C433F5 for ; Fri, 26 Nov 2021 09:48:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376467AbhKZJvb (ORCPT ); Fri, 26 Nov 2021 04:51:31 -0500 Received: from mail.loongson.cn ([114.242.206.163]:33930 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236947AbhKZJta (ORCPT ); Fri, 26 Nov 2021 04:49:30 -0500 Received: from localhost.localdomain.localdomain (unknown [10.2.5.46]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxWsjWrKBhSyEAAA--.43S2; Fri, 26 Nov 2021 17:46:03 +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 v2 1/2] modpost: file2alias: fixup mdio alias garbled code in modules.alias Date: Fri, 26 Nov 2021 17:45:56 +0800 Message-Id: <1637919957-21635-1-git-send-email-zhuyinbo@loongson.cn> X-Mailer: git-send-email 1.8.3.1 X-CM-TRANSID: AQAAf9AxWsjWrKBhSyEAAA--.43S2 X-Coremail-Antispam: 1UD129KBjvJXoW7tF1UAry5Ww47XF18Xr1xuFg_yoW8CF45pF ZxGa4SgFWkWF47uan5ua4DAr1UXw4DK3s5Wa1j9F40gF9Iyry0vF4SkFnay3WUAFZ7Xa40 g343uFyUur47XrUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvC14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2 Y2ka0xkIwI1lc2xSY4AK6svPMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r 4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF 67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2I x0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Wr1j6rW3Jr1lIxAI cVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2Kf nxnUUI43ZEXa7VUbXdbUUUUUU== X-CM-SenderInfo: 52kx5xhqerqz5rrqw2lrqou0/ Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org After module compilation, module alias mechanism will generate a ugly mdio modules alias configure if ethernet phy was selected, this patch is to fixup mdio alias garbled code. In addition, that ugly alias configure will cause ethernet phy module doens't match udev, phy module auto-load is fail, but add this patch that it is well mdio driver alias configure match phy device uevent. Signed-off-by: Yinbo Zhu Reported-by: Yinbo Zhu Signed-off-by: Russell King (Oracle) --- Change in v2: Add a MDIO_ANY_ID for considering some special phy device which phy id doesn't be read from phy register. 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 Fri Nov 26 09:45: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: 12640311 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 0CA73C433EF for ; Fri, 26 Nov 2021 09:48:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376395AbhKZJva (ORCPT ); Fri, 26 Nov 2021 04:51:30 -0500 Received: from mail.loongson.cn ([114.242.206.163]:33922 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232640AbhKZJt3 (ORCPT ); Fri, 26 Nov 2021 04:49:29 -0500 Received: from localhost.localdomain.localdomain (unknown [10.2.5.46]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxWsjWrKBhSyEAAA--.43S3; Fri, 26 Nov 2021 17:46:03 +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 v2 2/2] net: mdio: fixup ethernet phy module auto-load function Date: Fri, 26 Nov 2021 17:45:57 +0800 Message-Id: <1637919957-21635-2-git-send-email-zhuyinbo@loongson.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1637919957-21635-1-git-send-email-zhuyinbo@loongson.cn> References: <1637919957-21635-1-git-send-email-zhuyinbo@loongson.cn> X-CM-TRANSID: AQAAf9AxWsjWrKBhSyEAAA--.43S3 X-Coremail-Antispam: 1UD129KBjvJXoWxJr1DXFyxJF43WFyfWr1rZwb_yoW8GFyUpF sYyFyrtrWUXwsrWws5Cw4DGF1F93y0y3srGrW0939Y9rs8Jry0qFWfKFyjvF15GFWrZ3W7 Xay0qF18XF97ArDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPv14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCY02Avz4vE-syl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2Iq xVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r 1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY 6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67 AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuY vjfU86wZUUUUU X-CM-SenderInfo: 52kx5xhqerqz5rrqw2lrqou0/ Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org the phy_id is only phy identifier, that phy module auto-load function should according the phy_id event rather than other information, this patch is remove other unnecessary information and add phy_id event in mdio_uevent function and ethernet phy module auto-load function will work well. Signed-off-by: Yinbo Zhu --- 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,