From mboxrd@z Thu Jan 1 00:00:00 1970 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 78F39C4332F for ; Thu, 10 Nov 2022 13:08:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230192AbiKJNIE (ORCPT ); Thu, 10 Nov 2022 08:08:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230005AbiKJNIC (ORCPT ); Thu, 10 Nov 2022 08:08:02 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F13581A225 for ; Thu, 10 Nov 2022 05:07:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668085624; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8zMAudJpmdEKZtCKUy+05rwV5mHOrkDZJoA0XJ15CQ4=; b=TRNF16fIQg+6rv+ss24naYjUwi8Ge9/bk1EP0EyBLmbMXJPVyKWUaEZBjJ6mw+6GFweXJy Vo50vZSIY+LTYSXnLOWMeJamBmEcH3mod/u0eBh8eoqjeuxb3CA3RQfw7Xy5U/wnJTHyw1 KkYBDxPyKpzZXxksetqQIT95nmmHNLY= Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-593-cGbnPU2eP5i03DTRt0QT7Q-1; Thu, 10 Nov 2022 08:07:03 -0500 X-MC-Unique: cGbnPU2eP5i03DTRt0QT7Q-1 Received: by mail-pg1-f197.google.com with SMTP id q63-20020a632a42000000b0045724b1dfb9so981413pgq.3 for ; Thu, 10 Nov 2022 05:07:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=8zMAudJpmdEKZtCKUy+05rwV5mHOrkDZJoA0XJ15CQ4=; b=pjNrMsthvcVro2uMGXabWSNFajcnKItEhgGYbY1RXHe8PdvFudF1fmr1fUTrJMHmSX KHPz9J0DSEWbN8FtQZwPRf2qEJZtHJWyFcbAWwHddNiAtmooCnUbpxDEPBriaCmkn4ke wynRMtJQv3LITGj5I5GaE582wiCLU87AuRaBK9aKVsgMawxDaFUcH/2Xi+viUpwNUYj3 ygqoVcfFAHTV7BLO/IrEmSFSiq15C1wAMQRdcsZNypU5iJo2ErkkRbvJpqXbJEm0HoRv GFsqFQ9CZImPM2g9lrIhOcG19Lv5n5RQOZSqpz91mA6iIjRaF4pEuNQ+anRAGwd4sxDD TSnw== X-Gm-Message-State: ACrzQf2EDtjQ/tA7/OvmW9A07C4hsrdOxlFuIG1fv30VTRc1XcuFc1Vq XwLga9SP5Vv5fmtyiacLR5jhQJU/fJKqeviCBYQ3MRhc3PaMjbh5h+urcU2aIDj6DcbEk8hNB3u Bp6n31BEtKiKGSbK5q+zgMAtc X-Received: by 2002:a63:155b:0:b0:470:1a0b:ce3d with SMTP id 27-20020a63155b000000b004701a0bce3dmr34429930pgv.597.1668085621961; Thu, 10 Nov 2022 05:07:01 -0800 (PST) X-Google-Smtp-Source: AMsMyM4/ry76eNdJLG8wkw95+ZE+UZX4fN3mjnXvdaEyH+JPEN9B5VVng2ZratTCNQe1UctwEEQHtQ== X-Received: by 2002:a63:155b:0:b0:470:1a0b:ce3d with SMTP id 27-20020a63155b000000b004701a0bce3dmr34429912pgv.597.1668085621657; Thu, 10 Nov 2022 05:07:01 -0800 (PST) Received: from gerbillo.redhat.com (146-241-120-203.dyn.eolo.it. [146.241.120.203]) by smtp.gmail.com with ESMTPSA id lw5-20020a17090b180500b0020af2bab83fsm3081270pjb.23.2022.11.10.05.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 05:07:01 -0800 (PST) Message-ID: Subject: Re: [PATCH net-next v5 3/3] net: ethernet: ti: am65-cpsw: Add support for SERDES configuration From: Paolo Abeni To: Siddharth Vadapalli , davem@davemloft.net, edumazet@google.com, kuba@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski@linaro.org, krzysztof.kozlowski+dt@linaro.org, linux@armlinux.org.uk, vladimir.oltean@nxp.com, vigneshr@ti.com, nsekhar@ti.com Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, srk@ti.com Date: Thu, 10 Nov 2022 14:06:47 +0100 In-Reply-To: <20221109042203.375042-4-s-vadapalli@ti.com> References: <20221109042203.375042-1-s-vadapalli@ti.com> <20221109042203.375042-4-s-vadapalli@ti.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hello, On Wed, 2022-11-09 at 09:52 +0530, Siddharth Vadapalli wrote: [...] > +static void am65_cpsw_disable_serdes_phy(struct am65_cpsw_common *common) > +{ > + struct device_node *node, *port_np; > + struct device *dev = common->dev; > + const char *name = "serdes-phy"; > + struct phy *phy; > + > + node = of_get_child_by_name(dev->of_node, "ethernet-ports"); > + > + for_each_child_of_node(node, port_np) { > + phy = devm_of_phy_get(dev, port_np, name); The above will try to allocate some memory and can fail. Even if the the following code will handle a NULL ptr, the phy will not be disabled. I think it's better if you cache the serdes phy ptr in am65_cpsw_init_serdes_phy() and you use such reference here, without resorting to devm_of_phy_get(). Cheers, Paolo From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8DA7BC4332F for ; Thu, 10 Nov 2022 13:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:Cc:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=carluFsWx7QTbCw5WBVFOqHBnSuLP3MVGn3lI43BC0k=; b=pTY7/BCr74XPPw V6Lc8LkIndMgH+nhCj2xnd0jt3D6umAARzKiVUQBKliDOmB7w7CdGjIOHRhc95sRww7KfJLLOMfnm hm7dYxrGas3rgqqIEyyQR/MI1gyitbcsuiVNZGhpjoYRn3mwI6sOBJ+2UzmZyfhXSyOaDqREG4eI+ BibdBqq+hwUHqdnzUe1PiFBzXUO2nYRHMaTeiM8PEySqU0XtO4hbSPxUOhopE3LE6Ckrkl6vkDYos SCmlX7yylQ8F6j8G+xyZ4gHGVkwcmaUs8fJQNTJ8YtK/hWI7kkn1r0DEMhsQ70UdU0fsmJ6LHd2E5 Aw5OJascb3ZV56q7t7ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ot7Gy-005uiF-Ao; Thu, 10 Nov 2022 13:07:12 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ot7Gv-005ufx-3v for linux-arm-kernel@lists.infradead.org; Thu, 10 Nov 2022 13:07:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668085626; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8zMAudJpmdEKZtCKUy+05rwV5mHOrkDZJoA0XJ15CQ4=; b=VpXqlZ0JGY1gzomC2utFjvPxPIoKPHKGDNlg/t7W1tv8XhKlROcB8MKOr/6zOKbrQCpG8B Dnc4L5TRdgd5h75ZAaEyHQeBGe/Ar2Tr9c10Dkoi6jNi6F4Rngy/GABlgbO/ma6K4KzPoD OfTKcWurexLumndfte9klNhcWgjjdDY= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-632-NisjVknnM1-MXx0LlNvWjA-1; Thu, 10 Nov 2022 08:07:03 -0500 X-MC-Unique: NisjVknnM1-MXx0LlNvWjA-1 Received: by mail-pf1-f200.google.com with SMTP id g13-20020a056a000b8d00b0056e28b15757so1024027pfj.1 for ; Thu, 10 Nov 2022 05:07:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=8zMAudJpmdEKZtCKUy+05rwV5mHOrkDZJoA0XJ15CQ4=; b=qAQxY7aJaJ3stzKqGqDfg1MQZB2bTrY+kqZSp+S4gNZSPbm6B2HQwpzbNqW8X02UJU K/PvpQBDprXU2KDwPldLsgfiRK4LSMc/QXcVmXACEFQhufTunoJ7HzXK1sje4a5cFWe8 9P4FBOHoCI1JN7Tyqv/xAkPQ7qHbeDe5c0BfKvcWRcxGSCQL/20V992OmlmM/hjB9rWj MLZ3y+DKxRqy1bT5xlxwHuu2nH+0sPJr1g9z1ye91GkchQNQeLeBpZNoDN9VZIAh/cPV JjZGnozFSck0iZzCW60cBNuYMG/5hujeOkprJ65F7yFjebFwW6+MBhdhxDRcEAy4G2Zh lBPw== X-Gm-Message-State: ACrzQf3hTigrcTKL+IIw6k+wBGyqEh0G+0dmlcfnUzsylzkqmMBSQn4J GRN4vZEUeZxP5nrudvMAIDNfHQOq5tDPl9q8MnvJugeImAMnfD/trMo3mHJu8Xdnyve7SnTR6CC 1mPBKEtcWKBjsH/uqlf6W9K5wFHnCZUCoWR8= X-Received: by 2002:a63:155b:0:b0:470:1a0b:ce3d with SMTP id 27-20020a63155b000000b004701a0bce3dmr34429932pgv.597.1668085621961; Thu, 10 Nov 2022 05:07:01 -0800 (PST) X-Google-Smtp-Source: AMsMyM4/ry76eNdJLG8wkw95+ZE+UZX4fN3mjnXvdaEyH+JPEN9B5VVng2ZratTCNQe1UctwEEQHtQ== X-Received: by 2002:a63:155b:0:b0:470:1a0b:ce3d with SMTP id 27-20020a63155b000000b004701a0bce3dmr34429912pgv.597.1668085621657; Thu, 10 Nov 2022 05:07:01 -0800 (PST) Received: from gerbillo.redhat.com (146-241-120-203.dyn.eolo.it. [146.241.120.203]) by smtp.gmail.com with ESMTPSA id lw5-20020a17090b180500b0020af2bab83fsm3081270pjb.23.2022.11.10.05.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 05:07:01 -0800 (PST) Message-ID: Subject: Re: [PATCH net-next v5 3/3] net: ethernet: ti: am65-cpsw: Add support for SERDES configuration From: Paolo Abeni To: Siddharth Vadapalli , davem@davemloft.net, edumazet@google.com, kuba@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski@linaro.org, krzysztof.kozlowski+dt@linaro.org, linux@armlinux.org.uk, vladimir.oltean@nxp.com, vigneshr@ti.com, nsekhar@ti.com Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, srk@ti.com Date: Thu, 10 Nov 2022 14:06:47 +0100 In-Reply-To: <20221109042203.375042-4-s-vadapalli@ti.com> References: <20221109042203.375042-1-s-vadapalli@ti.com> <20221109042203.375042-4-s-vadapalli@ti.com> User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221110_050709_265601_52CCDB81 X-CRM114-Status: GOOD ( 11.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org hello, On Wed, 2022-11-09 at 09:52 +0530, Siddharth Vadapalli wrote: [...] > +static void am65_cpsw_disable_serdes_phy(struct am65_cpsw_common *common) > +{ > + struct device_node *node, *port_np; > + struct device *dev = common->dev; > + const char *name = "serdes-phy"; > + struct phy *phy; > + > + node = of_get_child_by_name(dev->of_node, "ethernet-ports"); > + > + for_each_child_of_node(node, port_np) { > + phy = devm_of_phy_get(dev, port_np, name); The above will try to allocate some memory and can fail. Even if the the following code will handle a NULL ptr, the phy will not be disabled. I think it's better if you cache the serdes phy ptr in am65_cpsw_init_serdes_phy() and you use such reference here, without resorting to devm_of_phy_get(). Cheers, Paolo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel