From patchwork Fri May 13 11:46:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 12848696 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 DEDD7C433F5 for ; Fri, 13 May 2022 11:46:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379988AbiEMLqc (ORCPT ); Fri, 13 May 2022 07:46:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378423AbiEMLq3 (ORCPT ); Fri, 13 May 2022 07:46:29 -0400 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93598275E0 for ; Fri, 13 May 2022 04:46:23 -0700 (PDT) Received: by mail-oi1-x232.google.com with SMTP id w130so9874615oig.0 for ; Fri, 13 May 2022 04:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=l8ACeZsVDDPCahRKVeDrr11bf5fhg05CS/FIvEPfNmw=; b=ZM/quJ2eyPfnV4ct5dd6Bd3NNNgBIa8nMSqmH8hRQzvK2VkEqjCHMMp8hfPoYXD6OA GlKP8S2+5HMiFVt6A1exyo92QddRvGWb0IiOnWFvmL1FTjlZsGbolSkRYNfrJipv4kax BdqJKQp+5WjIxPqkJ8/hMM0PeFEnEc9/TMmRNC/iaiBOhSfUpqgwdlAjq4TywJNKgH6J wPArRcnmH9OcPCUPpS05AWEd10mBfUoDzdEYPYKaNn1ymsTfUYDeTzv78frnbhVXwZRb 8GCKo5+2QodfL0G+/Gk+u+EtxCCeZrFVcm+duyGKVgcPnadReP42nXpBdKEwuBl5c3BF cK8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=l8ACeZsVDDPCahRKVeDrr11bf5fhg05CS/FIvEPfNmw=; b=qPrMyGLvIv75aRc9+LxJEy8ieeDguBf9IOJpASnGGwb+rEwW43puuI1TDl89ItyxGT cqYdxpjcxrk8C/uYe+BNi+HrPSBDNwu2LVYcBVsHVBG+HxsHToK0VHhxe7dCPJmrc/M7 TqZkNJ0YTAIy1GVky9B710hJvcq43mLX9YqevwFVqbzCxf8/L9Se0Xw0j8Dp8UF7Ie7k iWbmRMpAzKb0KqLaHp3sP+sUB9ecVIOGNwJn6LEpGKQSk6oMxjU64STDeo/ldOMA9m18 wpBWT1jymRfHk+aDf7y3//6sA8pnioXnaaP1g1BjtlsSG2K7ap7+Z31A8oQyBEjcg0wC hdeQ== X-Gm-Message-State: AOAM532FMADu/kffIB1+fbiPwOQUC628iuBOHicaCXNb6yrvKc79j8pt F1npdzb8UxTfoqeFxaNi4bhgDbJON6vmtQ== X-Google-Smtp-Source: ABdhPJwvmy1teuvWeq0uD161HKh9MC6mhFnpCLNxttZLGHk4wssNogBnmgx9EzS5eJacmdvEHdso3A== X-Received: by 2002:a54:4386:0:b0:325:91ed:9b18 with SMTP id u6-20020a544386000000b0032591ed9b18mr2093152oiv.286.1652442382654; Fri, 13 May 2022 04:46:22 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:485:4b69:7c3a:c7b:fd8a:c501]) by smtp.gmail.com with ESMTPSA id b18-20020a9d6b92000000b00606b1f72fcbsm872458otq.31.2022.05.13.04.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 04:46:22 -0700 (PDT) From: Fabio Estevam To: kuba@kernel.org Cc: davem@davemloft.net, andrew@lunn.ch, netdev@vger.kernel.org, Fabio Estevam Subject: [PATCH net-next 1/2] net: phy: micrel: Allow probing without .driver_data Date: Fri, 13 May 2022 08:46:12 -0300 Message-Id: <20220513114613.762810-1-festevam@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Fabio Estevam Currently, if the .probe element is present in the phy_driver structure and the .driver_data is not, a NULL pointer dereference happens. Allow passing .probe without .driver_data by inserting NULL checks for priv->type. Signed-off-by: Fabio Estevam Reviewed-by: Andrew Lunn --- drivers/net/phy/micrel.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index c34a93403d1e..5e356e23c1b7 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -520,7 +520,7 @@ static int kszphy_config_reset(struct phy_device *phydev) } } - if (priv->led_mode >= 0) + if (priv->type && priv->led_mode >= 0) kszphy_setup_led(phydev, priv->type->led_mode_reg, priv->led_mode); return 0; @@ -536,10 +536,10 @@ static int kszphy_config_init(struct phy_device *phydev) type = priv->type; - if (type->has_broadcast_disable) + if (type && type->has_broadcast_disable) kszphy_broadcast_disable(phydev); - if (type->has_nand_tree_disable) + if (type && type->has_nand_tree_disable) kszphy_nand_tree_disable(phydev); return kszphy_config_reset(phydev); @@ -1730,7 +1730,7 @@ static int kszphy_probe(struct phy_device *phydev) priv->type = type; - if (type->led_mode_reg) { + if (type && type->led_mode_reg) { ret = of_property_read_u32(np, "micrel,led-mode", &priv->led_mode); if (ret) @@ -1751,7 +1751,8 @@ static int kszphy_probe(struct phy_device *phydev) unsigned long rate = clk_get_rate(clk); bool rmii_ref_clk_sel_25_mhz; - priv->rmii_ref_clk_sel = type->has_rmii_ref_clk_sel; + if (type) + priv->rmii_ref_clk_sel = type->has_rmii_ref_clk_sel; rmii_ref_clk_sel_25_mhz = of_property_read_bool(np, "micrel,rmii-reference-clock-select-25-mhz"); From patchwork Fri May 13 11:46:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 12848697 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 A8A1CC433FE for ; Fri, 13 May 2022 11:46:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380005AbiEMLqe (ORCPT ); Fri, 13 May 2022 07:46:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbiEMLq3 (ORCPT ); Fri, 13 May 2022 07:46:29 -0400 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D55491CB22 for ; Fri, 13 May 2022 04:46:25 -0700 (PDT) Received: by mail-oi1-x232.google.com with SMTP id j12so9833055oie.1 for ; Fri, 13 May 2022 04:46:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4N1T/RG64MaJ9K2EPr9r4NPNoZ7d/jiFoWOLU7hUaCk=; b=mK3Nnsy+szG2jzQB2ofRgVA69xXzHyPm0DWHvJ6cxgma6eixU6APn5VTy2131BbbXJ 6EO3jsSj/eY9U106SaOCt+JdfrgEHJzjlVGNJyiZ3ul5+MgcUbw+2lhVQlJJEp9jo0AI rwkitiSwnpNnt1MGzSsyVJAeeJ6AFCUtnSFmFCNL0F8Sd4RpcbghnzoPlVpfiTUPLXbm Zp5E04PjT0M3fQX69R1F45/KrqtFlKqCtm/BzMbW2jwnzg96TL4WigdZn2TRMXzAaj8p ZXYJRCXhE8pC5L6G88FfVYbrH/vEQl7D7hOIjHCPTACcRPzsOSKvOPZCC+ToMXiV9jqZ 8qmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4N1T/RG64MaJ9K2EPr9r4NPNoZ7d/jiFoWOLU7hUaCk=; b=DlMz0yfj7IKGbtN04eNwP5gvT7FJEsqX2V+kkFV3VniGyF826s8Nw1G+y9qRVXfvOE 8LsqN9TsvfxZTNWOkDIiVXK85eH6oZuROl1m6dWZgIy9f+BEFE9g65MyjV0QOaPGIsqv cw+g9iemvF+XiUxuClQkHgFPwsrO8dk/xNIxEs/4+qhPoh1Nwe95qgN9Wd6jUp/ki2ep AAkq1m7ZJ+Qc9k4HNiYZ1QHfaL5MU2HGKwPQ57gw5Ob59arlDwLQbwa0g9BCe2nEBma2 22fvE5I0WS/t2V+4E48BGFxYDASO177fV9BtwarjioNDA//RSzrN4gv9MbEg1CjvfeQf u0hQ== X-Gm-Message-State: AOAM5312t1SKpCOTzHDBw5O6I6PZnjtzHir6gSxawQ2EwEdulaVu70G2 8XuZPxnmKv8EiyskaHJCJJ+pm6te8XuOMw== X-Google-Smtp-Source: ABdhPJwCD9oxyyklkqXdpIxJl/0d/ctsVYIblkgBfSgjnEBAEj0nfkF62bwsx1Sun0geRRFO8NlTAA== X-Received: by 2002:a05:6808:1155:b0:326:795e:1e07 with SMTP id u21-20020a056808115500b00326795e1e07mr7474017oiu.296.1652442385217; Fri, 13 May 2022 04:46:25 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:485:4b69:7c3a:c7b:fd8a:c501]) by smtp.gmail.com with ESMTPSA id b18-20020a9d6b92000000b00606b1f72fcbsm872458otq.31.2022.05.13.04.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 04:46:24 -0700 (PDT) From: Fabio Estevam To: kuba@kernel.org Cc: davem@davemloft.net, andrew@lunn.ch, netdev@vger.kernel.org, Fabio Estevam Subject: [PATCH net-next 2/2] net: phy: micrel: Use the kszphy probe/suspend/resume Date: Fri, 13 May 2022 08:46:13 -0300 Message-Id: <20220513114613.762810-2-festevam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220513114613.762810-1-festevam@gmail.com> References: <20220513114613.762810-1-festevam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Fabio Estevam Now that it is possible to use .probe without having .driver_data, let KSZ8061 use the kszphy specific hooks for probe,suspend and resume, which is preferred. Switch to using the dedicated kszphy probe/suspend/resume functions. Signed-off-by: Fabio Estevam Reviewed-by: Andrew Lunn --- drivers/net/phy/micrel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 5e356e23c1b7..22139901f01c 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -3019,11 +3019,12 @@ static struct phy_driver ksphy_driver[] = { .name = "Micrel KSZ8061", .phy_id_mask = MICREL_PHY_ID_MASK, /* PHY_BASIC_FEATURES */ + .probe = kszphy_probe, .config_init = ksz8061_config_init, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, - .suspend = genphy_suspend, - .resume = genphy_resume, + .suspend = kszphy_suspend, + .resume = kszphy_resume, }, { .phy_id = PHY_ID_KSZ9021, .phy_id_mask = 0x000ffffe,