From patchwork Mon Sep 2 18:15:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13787575 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC4433BB22; Mon, 2 Sep 2024 18:15:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725300936; cv=none; b=fSgsOiosxwxdcKbcW0E/3fArlycWD82jplHB0uYdo17/yHlc7tGuKNZQnqm68tEPQa2QmsVusjBnSBm6VlLr5To7hZTxqNQPPWYRiVk6XOQLvXmoc5q8qftFslIg4o7ZP7Xd2QwUp/YOZJ/zxUpn6+QoHsYWGo8NERbdzyULQmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725300936; c=relaxed/simple; bh=aZNu7iiv/TYq0BlMH229d2ccbsF2mWev0TPm5aNKaTc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A1V92qddAvF6iqRBlr6Oq4YqFHPEn5UcBX7rLlJZuGRzYGBgDYFKbyf/1VKLeQKs7/3Z0TB2AdRjl4aUVGr5pjwaA4WlpckXm50ebXZQS8h3/bRoFuI2xsug6zhbOd/FtJ5/ULKFerRAjJof8EBJgCiVm9A92Dj0MFIBjxm+k3s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lpw3eOUx; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lpw3eOUx" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-717594b4ce7so960922b3a.0; Mon, 02 Sep 2024 11:15:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725300934; x=1725905734; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ltddfl1/seB86FuPt28B0OUAnAVJMcJpdwKzmOTOXTQ=; b=lpw3eOUxp2Et7IBvzT0wDl9akX7a7rcknSTaxWjOUa29mK8qeXEUctKZMGC9MEMtvF j05Nr+kBZmY9niAeWb7bL4OdXHlSIKnMn9SEpbZz9Lj5PLlCwdgNCvhhDAoVSZeCK75f iUhDRcof+S60tWBVA/nbsWYUKifllQKclFsLsmyVGbNwyPEVTtPrumqPPEYqtzP97uI6 JFSlS4NzAtwiwrbbXeiu8RCnkwrLpv3SaUBNzIo9CgkOFAf5mpLlRe9cCAGJSCrGokjE 2mFOPjr2HSykpdLRpzKKcEeRTHuaB3wfoQTc8M8sH+0IKIXHs1mrXedLMWuCl/N0KWm+ qQqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725300934; x=1725905734; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ltddfl1/seB86FuPt28B0OUAnAVJMcJpdwKzmOTOXTQ=; b=e6sO+CAc4puC0Kil5/gIAnmz9F9O1/UGKt0YU3lvIYv4l5ebaPu61LHvj3iyak2W97 JOcXcOfmuICJTygoAPJXSFv85GYy5Y1E7VwR7PMUnlKI/uZrTIsrzrLTkwqN+XF3giDp OnvEhQgQCNWAbEqg/by74jpGYU7ddyNZse6yBxGV1FH9yJgbKiZG6Mv3qoL8WspUoey+ RdYKEaE5m5srNjZ2zstOgyXKiam5x4iMDsIAChCgPRlWvRlgFvAdN/7sZO1G7ddLna9e 3ge9+bE71K2xHLbct5rp+8Z8H46iix/Km7bv+QhyMNjHakNVeAQXsjB8yVb3LzItewt7 0pRg== X-Forwarded-Encrypted: i=1; AJvYcCV1XcCdGYq2XdHd6Nkb6IvUoCa4ZX5DnLO1wRp8zd918qYjjeKHbgApasbIWlNXCZGawTvZtD3QgnbguS4=@vger.kernel.org X-Gm-Message-State: AOJu0YzWwx0Hj1oXCoZs+U0PbcqLAbopQasYWnx3FceBWo5ienHRcmF+ CEKq4Lqzh5ohmXFxFRWr6ulolFbqSlWKq9Uvy30GJgBpE5ChKnkuqsE6T6KI X-Google-Smtp-Source: AGHT+IH+EoF+mK4CtJKAyWIF/BV/EBXvbSOjjOqW3p9vQ9eJdwW0JI/bmrLic//uxm0aYn2bDVOo1Q== X-Received: by 2002:a05:6a00:198d:b0:714:21f0:c799 with SMTP id d2e1a72fcca58-715dfb26b96mr16308074b3a.12.1725300933971; Mon, 02 Sep 2024 11:15:33 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e56d7804sm7109167b3a.154.2024.09.02.11.15.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 11:15:33 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, jacob.e.keller@intel.com, horms@kernel.org, sd@queasysnail.net, chunkeey@gmail.com Subject: [PATCH 1/6] net: ibm: emac: use devm for alloc_etherdev Date: Mon, 2 Sep 2024 11:15:10 -0700 Message-ID: <20240902181530.6852-2-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240902181530.6852-1-rosenp@gmail.com> References: <20240902181530.6852-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Allows to simplify the code slightly. This is safe to do as free_netdev gets called last. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/core.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index a19d098f2e2b..348702f462bd 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -3053,7 +3053,7 @@ static int emac_probe(struct platform_device *ofdev) /* Allocate our net_device structure */ err = -ENOMEM; - ndev = alloc_etherdev(sizeof(struct emac_instance)); + ndev = devm_alloc_etherdev(&ofdev->dev, sizeof(struct emac_instance)); if (!ndev) goto err_gone; @@ -3072,7 +3072,7 @@ static int emac_probe(struct platform_device *ofdev) /* Init various config data based on device-tree */ err = emac_init_config(dev); if (err) - goto err_free; + goto err_gone; /* Get interrupts. EMAC irq is mandatory, WOL irq is optional */ dev->emac_irq = irq_of_parse_and_map(np, 0); @@ -3080,7 +3080,7 @@ static int emac_probe(struct platform_device *ofdev) if (!dev->emac_irq) { printk(KERN_ERR "%pOF: Can't map main interrupt\n", np); err = -ENODEV; - goto err_free; + goto err_gone; } ndev->irq = dev->emac_irq; @@ -3239,8 +3239,6 @@ static int emac_probe(struct platform_device *ofdev) irq_dispose_mapping(dev->wol_irq); if (dev->emac_irq) irq_dispose_mapping(dev->emac_irq); - err_free: - free_netdev(ndev); err_gone: /* if we were on the bootlist, remove us as we won't show up and * wake up all waiters to notify them in case they were waiting @@ -3289,7 +3287,6 @@ static void emac_remove(struct platform_device *ofdev) if (dev->emac_irq) irq_dispose_mapping(dev->emac_irq); - free_netdev(dev->ndev); } /* XXX Features in here should be replaced by properties... */ From patchwork Mon Sep 2 18:15:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13787576 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAC311D45EC; Mon, 2 Sep 2024 18:15:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725300938; cv=none; b=MwInX4Qd0nszgjjDfUgSBAjH9SMt9u+Vt7KVsG/+SO+NituOs3htkUjWJ2YmyHmCqq4RtyoKBHw5MJEjZ//7ZHaeTWGQQUwy5o9fvQ/YKdcbERSIGiW/FyqXzMmCL+TH5pgq8KmWjZXEBX8zPr8cUaJv0ZYiRDcf+BAYhVHX3eY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725300938; c=relaxed/simple; bh=iEdAo+LnjsKQrn7okcoj0se14qGPlNhh5N0i54I2l6E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q5aqOiXayr3iNtF0giiLYtPP81+UeBdVX07RrwpIFMf8uKoj4XY11QAO75e+kYn2tfXQGseorGZwpuGgMwUhhrdIj6cSgWVEuONdTdZKZVdLzxnvPJ0e9Y8cFfSr1Ee3pn7MIkkEAcwcMwtYsc+Qi4CFT6RhQZRZaWxvzfvB4mI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lJziwNrE; arc=none smtp.client-ip=209.85.210.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lJziwNrE" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-7141285db14so3816791b3a.1; Mon, 02 Sep 2024 11:15:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725300935; x=1725905735; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mDinSLZMzS23FvuwGD0vhfWMGAsaBTQCMgwSSoKV0Uc=; b=lJziwNrELarcE59/39svs7mhpcGs5EWAMKZKt8U76g/K2mdOYou6SQBWhSK8r4f+Gv heZTnGKcp9rALkBJ7LQhTzWfUTIphcfUadoa8jyaTBAnpX7W8bVa5Dp9H9iblQhrA940 doBHiaQudI8YII1IfowRucn6pkDxBWgX7lHrvTU/oAxqfVlQDWQ4Yy0NmGFA8LSsKGa6 R+v+rFbIgujKjqT0uUcvrKWJqDJVj4eZpv9g2AYbKOoUWxuCaeFqEWqYMijvttYhQL70 1wJMeFfN8l3566Ivq2kp8z/MpW7cqwRrNSTPDA5JKLDrX+g2961QxbWipviopom4vyjs c5dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725300935; x=1725905735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mDinSLZMzS23FvuwGD0vhfWMGAsaBTQCMgwSSoKV0Uc=; b=rzgS+2cklFJ3JcgGZ4BYr49+qfqCh5VKZVcjNBr+XknR9Sp9ywTxqpMDJABV4vZSmK EZghgITT/Fg42D31bMCm35C2KdUtKpHhtn5FcG18dDh5e8MP3KQYxudpS0xs8hXi7kcR i68FDxe7sQgoDVyWKyS/u9Bc7r0T2DRtYrhMS1dO1cnfcvqfRRpwQza+d+aGdqDW4mG1 NFkzQrTViNEikU50eU/50/ulaUx661j19DIS7e4913fYDcTy/U97uUXtPdv8dsF66dt5 b/4w/Zzmgg9m+lraBsK2Z8z2qtqegbda9pa2jAlmVRuqy9o69ssjM9FXysObMJlifrM+ LdpQ== X-Forwarded-Encrypted: i=1; AJvYcCWPRN/NPQ+OhmifOdEvQOWmHEFRKoNYsPecjxJeV9YpIDrrKZ2GZXLfHjvjHHUepV+4KQbE7fTh4onX4Jc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2YggZGlGxbf7PO9HKhToIVYxm3Ok53Ot4sAd5XpdErXaT/urK eVkvP1BeT+BfrgM3C+Fm5nLbz9rhR8vzxwMxlCmHaW3borqbYJwI7N4oPOlN X-Google-Smtp-Source: AGHT+IEKb0XvpzGiLq6i8MA7YjLH9eKuvu57oVka0eMv0/0pNtbzTn8ceJ7hyDYzmpUHLHkD2HjB4w== X-Received: by 2002:a05:6a21:118a:b0:1cc:e43f:1fc9 with SMTP id adf61e73a8af0-1cecdf31e5amr10221667637.30.1725300935377; Mon, 02 Sep 2024 11:15:35 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e56d7804sm7109167b3a.154.2024.09.02.11.15.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 11:15:35 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, jacob.e.keller@intel.com, horms@kernel.org, sd@queasysnail.net, chunkeey@gmail.com Subject: [PATCH 2/6] net: ibm: emac: manage emac_irq with devm Date: Mon, 2 Sep 2024 11:15:11 -0700 Message-ID: <20240902181530.6852-3-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240902181530.6852-1-rosenp@gmail.com> References: <20240902181530.6852-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org It's the last to go in remove. Safe to let devm handle it. Also move request_irq to probe for clarity. It's removed in _remove not close. Use dev_err instead of printk. Handles names automatically. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/core.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index 348702f462bd..98d1b711969b 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -1228,18 +1228,10 @@ static void emac_print_link_status(struct emac_instance *dev) static int emac_open(struct net_device *ndev) { struct emac_instance *dev = netdev_priv(ndev); - int err, i; + int i; DBG(dev, "open" NL); - /* Setup error IRQ handler */ - err = request_irq(dev->emac_irq, emac_irq, 0, "EMAC", dev); - if (err) { - printk(KERN_ERR "%s: failed to request IRQ %d\n", - ndev->name, dev->emac_irq); - return err; - } - /* Allocate RX ring */ for (i = 0; i < NUM_RX_BUFF; ++i) if (emac_alloc_rx_skb(dev, i)) { @@ -1293,8 +1285,6 @@ static int emac_open(struct net_device *ndev) return 0; oom: emac_clean_rx_ring(dev); - free_irq(dev->emac_irq, dev); - return -ENOMEM; } @@ -1408,8 +1398,6 @@ static int emac_close(struct net_device *ndev) emac_clean_tx_ring(dev); emac_clean_rx_ring(dev); - free_irq(dev->emac_irq, dev); - netif_carrier_off(ndev); return 0; @@ -3082,6 +3070,14 @@ static int emac_probe(struct platform_device *ofdev) err = -ENODEV; goto err_gone; } + + /* Setup error IRQ handler */ + err = devm_request_irq(&ofdev->dev, dev->emac_irq, emac_irq, 0, "EMAC", dev); + if (err) { + dev_err(&ofdev->dev, "failed to request IRQ %d", dev->emac_irq); + goto err_gone; + } + ndev->irq = dev->emac_irq; /* Map EMAC regs */ @@ -3237,8 +3233,6 @@ static int emac_probe(struct platform_device *ofdev) err_irq_unmap: if (dev->wol_irq) irq_dispose_mapping(dev->wol_irq); - if (dev->emac_irq) - irq_dispose_mapping(dev->emac_irq); err_gone: /* if we were on the bootlist, remove us as we won't show up and * wake up all waiters to notify them in case they were waiting @@ -3284,9 +3278,6 @@ static void emac_remove(struct platform_device *ofdev) if (dev->wol_irq) irq_dispose_mapping(dev->wol_irq); - if (dev->emac_irq) - irq_dispose_mapping(dev->emac_irq); - } /* XXX Features in here should be replaced by properties... */ From patchwork Mon Sep 2 18:15:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13787577 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C93F5680; Mon, 2 Sep 2024 18:15:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725300939; cv=none; b=UMJLk/UdgYRt07tYWQsuI9+2LB1wZgAKAawoxs4BnDLsQ7fnAViJk2/YoMMH1uO2VW4qBOMQ+HNhMj45FFGDfxxVJY0ZgicnHn9GN9Tuwjh42LzAu8ICHlM8qWmfNfarWpiOqP/JKyE3XK/Yj1od/qAoqHdgR/R2+7Dz7sAwYQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725300939; c=relaxed/simple; bh=U4PcNnx+tTc60z7zpQ78dqWgGU8LYCy8cARMM3w73e4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JZ0HxhxokaxVPaWYqYo9o7SvopwAjCazKxCGFys14YoFJXQ/+EdGgHEtxkki+H4d9/r+b7nuppfe0nUiXmlZoPDwFE6Q/50rFkj+ta1FYFjlvZHhT/8RKqzm35lOeynVAqs8imLF4XInJ9MfLMAWMTJXHTcQFZzUJskl3RRH1Bw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=D0VBJFiN; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D0VBJFiN" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-714287e4083so4040545b3a.2; Mon, 02 Sep 2024 11:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725300937; x=1725905737; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LtEV84BBq0rZJHR4vDOH0nemlHNjQdE0nFpOJPWT6Yw=; b=D0VBJFiNPRz9YLi8Ice11BrnW1jPZ4gbyRHuuOSmRxYCBIMIAQs1xxE0sMd3gibq7m 9m8oFExT5LEef9NdsHIuLz3WMUawOXpNenpfC4QbuE5u7fyCOYA4lXS97yqwIhtc3WfU RMOkvr4NPye8EaiJZ7UgZBX4a/zZ77QDXg2/0nSFOILrxvDtzFc/dtNIRiLR6H5pIKEI IbrT5yIe4ovmj8PN6mI0LDFlSt1dv6QPjfEhK4WcjMlTvjtPDyThrTVddfutPHyuVu+B S9TXponwQeNqtHqljjB0wQeCrRBQwMKC2Fq3d6sbyzDAH0sz72sbVSsHLS8vj9Rf3/vE +KsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725300937; x=1725905737; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LtEV84BBq0rZJHR4vDOH0nemlHNjQdE0nFpOJPWT6Yw=; b=nnkgA5Ty7jP5IB5wwECdAny+W+TGaZApnG9yn7XVP3W/YUhn//AuWiXMnwWdrh4ZSM RHSZRK9i+cjkNGlwQpfaU1tBEeO9fonQIeFWs9MVK0FIELssr/XiBZE/Z5ksrmQAx6J/ euuU3M9GoTQqSgRRv9tFxkKJmW/n8ugjDIcFcBPDR4es2oC4Fj/WKTM9TJLUbKV0Fwye CzAhIV+wId/n9GKR7RxPerMI2VDwqpBleA9KYmjKrqf4izSAEVtseXpi/eX4SWTCibQH 2eqm0sArdGR0++NEUhWjcXChBIme9t76KLZ5lTJNhNo4/bQnSL5Wn1WPJgl7t64Ege6W i7DQ== X-Forwarded-Encrypted: i=1; AJvYcCVHfGRialuzHhIFddQiVu1fY0RSECtSIWx/s6O08Hgsh4b0shM1aKnXQRq91BaS9SmgaaJAgdT6JZAsQfc=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3IokmGkUPBDEr+1D5rKEPLoFnDdmkuNFSzbRzlt1cmplBxIS1 HZ+hdDfeMb849ojJO4MbsvTBcL79KjlE7ECRSGSm5O7nSY6MOLjc07v3cYEX X-Google-Smtp-Source: AGHT+IFAQ11/9AuEJyl+KhjlsXP306dSSn4RXBScsJJJoUemj0tRAs/T/azTrV6IcSOXYd+7BF5HfQ== X-Received: by 2002:a05:6a21:e8c:b0:1cc:dedd:d8e8 with SMTP id adf61e73a8af0-1cecdee3b51mr11145692637.9.1725300937100; Mon, 02 Sep 2024 11:15:37 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e56d7804sm7109167b3a.154.2024.09.02.11.15.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 11:15:36 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, jacob.e.keller@intel.com, horms@kernel.org, sd@queasysnail.net, chunkeey@gmail.com Subject: [PATCH 3/6] net: ibm: emac: use devm for of_iomap Date: Mon, 2 Sep 2024 11:15:12 -0700 Message-ID: <20240902181530.6852-4-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240902181530.6852-1-rosenp@gmail.com> References: <20240902181530.6852-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Allows removing manual iounmap. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/core.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index 98d1b711969b..1a4c9fd87663 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -3082,10 +3082,9 @@ static int emac_probe(struct platform_device *ofdev) /* Map EMAC regs */ // TODO : platform_get_resource() and devm_ioremap_resource() - dev->emacp = of_iomap(np, 0); - if (dev->emacp == NULL) { - printk(KERN_ERR "%pOF: Can't map device registers!\n", np); - err = -ENOMEM; + dev->emacp = devm_of_iomap(&ofdev->dev, np, 0, NULL); + if (!dev->emacp) { + err = dev_err_probe(&ofdev->dev, -ENOMEM, "can't map device registers"); goto err_irq_unmap; } @@ -3095,7 +3094,7 @@ static int emac_probe(struct platform_device *ofdev) printk(KERN_ERR "%pOF: Timeout waiting for dependent devices\n", np); /* display more info about what's missing ? */ - goto err_reg_unmap; + goto err_irq_unmap; } dev->mal = platform_get_drvdata(dev->mal_dev); if (dev->mdio_dev != NULL) @@ -3228,8 +3227,6 @@ static int emac_probe(struct platform_device *ofdev) mal_unregister_commac(dev->mal, &dev->commac); err_rel_deps: emac_put_deps(dev); - err_reg_unmap: - iounmap(dev->emacp); err_irq_unmap: if (dev->wol_irq) irq_dispose_mapping(dev->wol_irq); @@ -3274,8 +3271,6 @@ static void emac_remove(struct platform_device *ofdev) mal_unregister_commac(dev->mal, &dev->commac); emac_put_deps(dev); - iounmap(dev->emacp); - if (dev->wol_irq) irq_dispose_mapping(dev->wol_irq); } From patchwork Mon Sep 2 18:15:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13787578 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 956A43BB22; Mon, 2 Sep 2024 18:15:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725300941; cv=none; b=p1Jd/CWk1s/pUvbR+2a4SzntQZAID7lKluLCm0y6IpKC/b0LrDmPqBn8O9w3LwdakjSFq+72VasiD9wD8pMhA7BQGY8Rtg6kG2+lBPbHb74MpfJqYTSEL9t6PihuZs8befBkhttNLYxOQJw/mTeyfblcTIF5ZjyCbodywdH7ng4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725300941; c=relaxed/simple; bh=PnIAzZu+MDJAm+gsXxmqEewg/2XRFhRoTemtVw7cehs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tqtlZX4j9sjD2YRjk7bvNl1b81uWWSUC8zjxLu+izXZKPzS41nnbHiTjVxW3v5tzz7+SOl+eQnXSngNu3s50Tu6HZI3FbuI069eGJziUT121GCReA7GFPqKl8OMCLjjPu76cA5/JnYUvubCQ9ksJqEU7pfjQpVAXki7m9AhuSaQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ds1lhAkZ; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ds1lhAkZ" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-714114be925so3627092b3a.2; Mon, 02 Sep 2024 11:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725300939; x=1725905739; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JPRjyz9vFHJOAVQ7s5yA4b/J4xdj+tyqzGLlTB6HBC4=; b=Ds1lhAkZXxG1vmenfKCQkn7bxCeshX6QmxC+XtdfFBYug9Ok0BsH8lv6Ht6cKLJWTL WWrUqpmlx590qKTtb63DPwB6mT+EMfODifVp1nn1VL7klZVIc2c/bA/AwH8yEABV5Q5I +h1v/TSBscHjRkboj2F5TaxUADo8DBWmzECZZVHpvS/cR4iU/LVmp8DY8or7vRWSozSp z0tHHc+YTayvYCUdmzSnE5o51+0C9KKBTeeNV8vxelNVPZiyxx1vJ0MMqEhrHOeXcRh2 /3N/eYu/m1CPo+aBsPMret4zGGhgMpB0WCnpoDuhxi7vSE9Zf5PInwpEs9/uPgazKeew YJEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725300939; x=1725905739; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JPRjyz9vFHJOAVQ7s5yA4b/J4xdj+tyqzGLlTB6HBC4=; b=m7I/kq0OcFyBpNn9MWJXwXpF0Yp3FVxu+ACd6D2JPEZ/joEzvctKRAYLA0E+hsJeJZ G3EcGLx+VTwGdGoih301GDtvYTWpV4H/uhvEz5GHFcINHp/YsQdbT9O/tXTU3CDeEJk2 Tuc9ts9UWcjdHfGbetSwsqYqebMd6bP2taCQxzW6W+xvRWhvdLhAa8nX2w8tw0KODeM+ 1i6RX60PKKen9le174BPOZHdlbFl8gmJmtmRAlnhW3+tFpYrbrCHSqQ25reOFIKwZjiv GxBqtl9jgHZQx+RB5Dxb6wnVa/THzi2gCWwpnO2TbZY//OwzAihyXHPFqRCYVHsmdQu2 Ub+g== X-Forwarded-Encrypted: i=1; AJvYcCVwB1TOGhFjOPnKY+3c9dF40qW6CxR33e/aEkYC7DYutI9TqMLT78qBbZuJoV2PG6nvGeJnfc8lcmYQVqE=@vger.kernel.org X-Gm-Message-State: AOJu0YwtyeuJqjZlSRWOPqQjQEdVnwBo/beqQue9PXPyipelnar2fOit zHZ6N3Cu5tmze8PRbJCeI5V+PpweoN6LG/Qgwb65nmWbRVezQA4PeBmCWDJf X-Google-Smtp-Source: AGHT+IFRyta+qrOOcrQJawpaE+2/q3ar1Gq7rDtNbSKm5oPpPROSOUTrKKLjX8ZNm/0Z79DTClHElw== X-Received: by 2002:a05:6a20:b418:b0:1c6:a562:997f with SMTP id adf61e73a8af0-1cecf757f5cmr9374776637.42.1725300938513; Mon, 02 Sep 2024 11:15:38 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e56d7804sm7109167b3a.154.2024.09.02.11.15.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 11:15:38 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, jacob.e.keller@intel.com, horms@kernel.org, sd@queasysnail.net, chunkeey@gmail.com Subject: [PATCH 4/6] net: ibm: emac: remove mii_bus with devm Date: Mon, 2 Sep 2024 11:15:13 -0700 Message-ID: <20240902181530.6852-5-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240902181530.6852-1-rosenp@gmail.com> References: <20240902181530.6852-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Switching to devm management of mii_bus allows to remove mdiobus_unregister calls and thus avoids needing a mii_bus global struct member. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/core.c | 32 +++++++++++----------------- drivers/net/ethernet/ibm/emac/core.h | 1 - 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index 1a4c9fd87663..af26a30bb5de 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -2580,6 +2580,7 @@ static const struct mii_phy_ops emac_dt_mdio_phy_ops = { static int emac_dt_mdio_probe(struct emac_instance *dev) { + struct mii_bus *bus; struct device_node *mii_np; int res; @@ -2594,23 +2595,23 @@ static int emac_dt_mdio_probe(struct emac_instance *dev) goto put_node; } - dev->mii_bus = devm_mdiobus_alloc(&dev->ofdev->dev); - if (!dev->mii_bus) { + bus = devm_mdiobus_alloc(&dev->ofdev->dev); + if (!bus) { res = -ENOMEM; goto put_node; } - dev->mii_bus->priv = dev->ndev; - dev->mii_bus->parent = dev->ndev->dev.parent; - dev->mii_bus->name = "emac_mdio"; - dev->mii_bus->read = &emac_mii_bus_read; - dev->mii_bus->write = &emac_mii_bus_write; - dev->mii_bus->reset = &emac_mii_bus_reset; - snprintf(dev->mii_bus->id, MII_BUS_ID_SIZE, "%s", dev->ofdev->name); - res = of_mdiobus_register(dev->mii_bus, mii_np); + bus->priv = dev->ndev; + bus->parent = dev->ndev->dev.parent; + bus->name = "emac_mdio"; + bus->read = &emac_mii_bus_read; + bus->write = &emac_mii_bus_write; + bus->reset = &emac_mii_bus_reset; + snprintf(bus->id, MII_BUS_ID_SIZE, "%s", dev->ofdev->name); + res = devm_of_mdiobus_register(&dev->ofdev->dev, bus, mii_np); if (res) { dev_err(&dev->ofdev->dev, "cannot register MDIO bus %s (%d)", - dev->mii_bus->name, res); + bus->name, res); } put_node: @@ -2656,8 +2657,6 @@ static int emac_dt_phy_probe(struct emac_instance *dev) res = emac_dt_mdio_probe(dev); if (!res) { res = emac_dt_phy_connect(dev, phy_handle); - if (res) - mdiobus_unregister(dev->mii_bus); } } @@ -2697,10 +2696,8 @@ static int emac_init_phy(struct emac_instance *dev) res = of_phy_register_fixed_link(np); dev->phy_dev = of_phy_find_device(np); - if (res || !dev->phy_dev) { - mdiobus_unregister(dev->mii_bus); + if (res || !dev->phy_dev) return res ? res : -EINVAL; - } emac_adjust_link(dev->ndev); put_device(&dev->phy_dev->mdio.dev); } @@ -3262,9 +3259,6 @@ static void emac_remove(struct platform_device *ofdev) if (dev->phy_dev) phy_disconnect(dev->phy_dev); - if (dev->mii_bus) - mdiobus_unregister(dev->mii_bus); - busy_phy_map &= ~(1 << dev->phy.address); DBG(dev, "busy_phy_map now %#x" NL, busy_phy_map); diff --git a/drivers/net/ethernet/ibm/emac/core.h b/drivers/net/ethernet/ibm/emac/core.h index 295516b07662..f4bd4cd8ac4a 100644 --- a/drivers/net/ethernet/ibm/emac/core.h +++ b/drivers/net/ethernet/ibm/emac/core.h @@ -189,7 +189,6 @@ struct emac_instance { struct mutex mdio_lock; /* Device-tree based phy configuration */ - struct mii_bus *mii_bus; struct phy_device *phy_dev; /* ZMII infos if any */ From patchwork Mon Sep 2 18:15:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13787579 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C100D21C176; Mon, 2 Sep 2024 18:15:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725300942; cv=none; b=M50Os30KerXfXunEbVAQdANt8drBJGT89Q/UpIpXDcIqN2F69z73Qi1smzGO4uacxxGCJwKAngPYigURTM+fAR3bgj9lZ3LjgasgQZo8IubPXCS+sXZvQ74HlEega7/AeyYmqImINeiLUJ6ZfWhxJYWIRTmEQdPK3MaTHmkXPCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725300942; c=relaxed/simple; bh=ojSmE4ICakMQsFJ/VK/KFMShrLGJutH8NtGfBIPXUhY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q6WiaRTDhGOseota8KxoW5sXEpyphOufEsswZytH8AI5G3B6bqhXyhtellYph2/LbRMcPcNC0Tpi0JWhAo+4Eg3IZE5kCZyqqDiov7EXCoTvNYbFgm0zFv1SRSWeoIhHlEbx1m/zOVulM2CLt3SMC5ve6ZfGTakbbGf3AnGBwIo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jfV00p4r; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jfV00p4r" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-7142a93ea9cso3534162b3a.3; Mon, 02 Sep 2024 11:15:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725300940; x=1725905740; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Zdx1W0I5G+0kXQYcOyiGjfzO3ruj8/A6WXXhcyeobog=; b=jfV00p4rv7cr/Qcbty65BcgMGMXVgMB+0h1w9jAvGdk0sljrUuZtYJ94FWXm4Fp08t 7CM75q32XY5J7G0aZ0tkaK6+sykd3SrAESaJBTdR0EvCGmg/S6LO86i60I0P89Co2TfF CaEANrkFnK2zKgl7cb0TkNvNNNFxzQcVu+LKvazci1aYOLvYOXM47A+9MDU/tf7sCbYW SxN71J7DjkSUsM7UnZmiHnaLuYiyc2/ra/avU1TOfN2b9knKoolRt98tYa2RRHmpHhDP +y0leEwbLC8eCPcD9O5g9iMY8hHoKRPypsF/3rEtU4TLaMxiEkztLkDSGBB7uCR4mjzp brwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725300940; x=1725905740; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Zdx1W0I5G+0kXQYcOyiGjfzO3ruj8/A6WXXhcyeobog=; b=e29osjBjSquWdFtSACMBkPrSsym92e2iT1eghV+apB8B/w+NpSIf+Rz81dyh4OabyP 6wx10s6Hky8NC40y3xsgVnNVBD8ydVTpvnd5D8HGMk5SIXgQBx29Uk06DRl20lKSrHhl mSyVpswatFfxOHEBXtBeZ3732cr6dX8JTdGy2A8ucQzVS5sQDoluDzHWP93Wqhq1VRVI 62FMKsIWVJo2KrHOf7Rzqk4ZFL2b5VUqRwKi1iD5SKRuYqzmO8k9VuB5RnF3Nuy/Pt/r zdbXArrrkT8Fu/+bRhZtzJentU87JUPVpc5M1g5VW6EWg+sf+sogo/l4lLcEUhoUWMuX 9OvA== X-Forwarded-Encrypted: i=1; AJvYcCWETplAHr4UZgb7xL13GnwCpIEQnq59Uv7m80Qltp2QBC03NjvRIv2f2FFvw32/4tkPzWfY7Qv/QKHXxQg=@vger.kernel.org X-Gm-Message-State: AOJu0YxTCUoJn2SDMzEkZmDP1S0m4915CECIF/BVaaugVxSRRYzORc6S Z/zT+hWhVGrS4pgcoTWbTbJhxzTmuQCaImF2TPf1FH/fLPXXiSYPwNyO+XuI X-Google-Smtp-Source: AGHT+IH5I9LECsloxp3pXs0FjKTSbm9dFP/LdgZoURsFmmogv7iJz/Gj748W3iaaaCbrcwZflA0MTw== X-Received: by 2002:a05:6a00:10cc:b0:70d:2725:ebe4 with SMTP id d2e1a72fcca58-717457cc68amr6340529b3a.13.1725300939919; Mon, 02 Sep 2024 11:15:39 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e56d7804sm7109167b3a.154.2024.09.02.11.15.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 11:15:39 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, jacob.e.keller@intel.com, horms@kernel.org, sd@queasysnail.net, chunkeey@gmail.com Subject: [PATCH 5/6] net: ibm: emac: use devm for register_netdev Date: Mon, 2 Sep 2024 11:15:14 -0700 Message-ID: <20240902181530.6852-6-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240902181530.6852-1-rosenp@gmail.com> References: <20240902181530.6852-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Cleans it up automatically. No need to handle manually. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index af26a30bb5de..fa871d7f93a9 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -3179,7 +3179,7 @@ static int emac_probe(struct platform_device *ofdev) netif_carrier_off(ndev); - err = register_netdev(ndev); + err = devm_register_netdev(&ofdev->dev, ndev); if (err) { printk(KERN_ERR "%pOF: failed to register net device (%d)!\n", np, err); @@ -3245,8 +3245,6 @@ static void emac_remove(struct platform_device *ofdev) DBG(dev, "remove" NL); - unregister_netdev(dev->ndev); - cancel_work_sync(&dev->reset_work); if (emac_has_feature(dev, EMAC_FTR_HAS_TAH)) From patchwork Mon Sep 2 18:15:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13787580 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74C0D3DABE8; Mon, 2 Sep 2024 18:15:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725300943; cv=none; b=cNwdA25eDtnAZske4aFaLiEJqLDPpL+NrHFdzv+2oF02maXJ1+7d7SjsJGLosJCEmbM54OIiSpCacgBrJdndC65ltobMTIjs4F4FMUkO8gvdCCc60Mj9VPglHOb0Eg87bhGoFKEh1e/eHbd/o880SdfmdBe2MzUnFf3wOwNZ/Sk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725300943; c=relaxed/simple; bh=sAzTeWjaMXA+mcojDxjAl+KB46Q8YZoFqsYu3ebkais=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SNZ2zCnIyCfNItbHRVwSTEE8oKooN406eBKKBe8Z14LsIAS1SzwQWXxxh6eTcFdjEC+hO7SMZtrO+g9Qr5iOlVNpe74nImyr9o73miwPLII8cHZvxseIzMQcxSAgevaJEetpA9xGLGalb+mnONs6nDYRdFgdcaKaGfwIlasda/Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=a2SK5XvD; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a2SK5XvD" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-714186ce2f2so3653301b3a.0; Mon, 02 Sep 2024 11:15:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725300941; x=1725905741; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s0P2T6oCbry27gpab3OBQR4pOyHpWlTZxFjava/v4V4=; b=a2SK5XvDLmUL4LP5KE3kig3OP1jnlfBtM4HbMuqO9gaHev7uQ3WeUhLHP/gRsUlVLG WOgaJruaW+uUiJE/sIr19oTc9GtunHjYaiViBvrdR0e7xSvfpW6Dqwf/f9w3VrcqGryH 1RSxiQY2CvZ6+w3OgrI2tprkbGfDufm9vU0fjx+lLAlyvoD+Crl+VsWTM+B8uTTnFgv1 mBI82/t841TEjVBRbwsunYYrG14Fa1oFz4ArCdNfDAhYkmLTgDw4OKqJ9YlI72LhGe5T 9f7b08muTZvCKr/JjSRhYYwf7KJhYWRlLyn/5RRvLuWjm4CQ/eKIir3xGRDwOgB+LE+7 cViA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725300941; x=1725905741; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s0P2T6oCbry27gpab3OBQR4pOyHpWlTZxFjava/v4V4=; b=FgSZAm2lTiVGguj38Bh5gmXRhdVOzgH/mO2iaFgeoTUc1nzOQNnYSGbx8YVsNLuCk9 decT1xKsZTuaGknOJMWblddVsFybh3rI6Go1QFIH3UxZFvAW6UmSQi0S2uE+2bMIH7d8 go9U0SuBxx8ZFWeORyz2VCe11vcW5D5SrexjSyyu9KKrvUkGhKeuLP2srGNUm9lXSZN5 xCzo0FJm6+NAvdzInDsZjtGfwYEsWq8tL1ZUvoXh3bIg8qwO/i9LLeFV77Illx7/vcVQ TJMZZvWYLM2qJNZR8XT+NIiWgUgAF8kUxqogYA9txXe3eiXnoq5gn5IHt9bfqmSvXoU6 MuVQ== X-Forwarded-Encrypted: i=1; AJvYcCUgzQOGbgyjOKxLLGgfhEvCSZ+uVCJ81MAadPU31t1fGqtF8u8a4nk0cp8rc65oH9XxNybvwnEGrLf8Um8=@vger.kernel.org X-Gm-Message-State: AOJu0YzKe/9h2AtLvNaseUtjdGIkwnxdQZwPKUMBp84srtE0ShCAo/o8 BN3V92PrxbtBGdOKNnifAe37HFp+n4y1jOz5fC4FS8m+tVczWMQXuTueEE3u X-Google-Smtp-Source: AGHT+IEyFvkXw1jzLm4G63s1mqUkqbb8n9RJCxzbJDrEAsuxQUOtX7cAtZKe10z154S+t4jdqfm23w== X-Received: by 2002:a05:6a21:39b:b0:1cc:ef31:da6d with SMTP id adf61e73a8af0-1ccef31dc1emr11120950637.52.1725300941404; Mon, 02 Sep 2024 11:15:41 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e56d7804sm7109167b3a.154.2024.09.02.11.15.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 11:15:41 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, jacob.e.keller@intel.com, horms@kernel.org, sd@queasysnail.net, chunkeey@gmail.com Subject: [PATCH 6/6] net: ibm: emac: use netdev's phydev directly Date: Mon, 2 Sep 2024 11:15:15 -0700 Message-ID: <20240902181530.6852-7-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240902181530.6852-1-rosenp@gmail.com> References: <20240902181530.6852-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Avoids having to use own struct member. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/core.c | 47 +++++++++++++--------------- drivers/net/ethernet/ibm/emac/core.h | 3 -- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index fa871d7f93a9..78cc57c8cd19 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -2459,7 +2459,7 @@ static int emac_read_uint_prop(struct device_node *np, const char *name, static void emac_adjust_link(struct net_device *ndev) { struct emac_instance *dev = netdev_priv(ndev); - struct phy_device *phy = dev->phy_dev; + struct phy_device *phy = ndev->phydev; dev->phy.autoneg = phy->autoneg; dev->phy.speed = phy->speed; @@ -2510,22 +2510,20 @@ static int emac_mdio_phy_start_aneg(struct mii_phy *phy, static int emac_mdio_setup_aneg(struct mii_phy *phy, u32 advertise) { struct net_device *ndev = phy->dev; - struct emac_instance *dev = netdev_priv(ndev); phy->autoneg = AUTONEG_ENABLE; phy->advertising = advertise; - return emac_mdio_phy_start_aneg(phy, dev->phy_dev); + return emac_mdio_phy_start_aneg(phy, ndev->phydev); } static int emac_mdio_setup_forced(struct mii_phy *phy, int speed, int fd) { struct net_device *ndev = phy->dev; - struct emac_instance *dev = netdev_priv(ndev); phy->autoneg = AUTONEG_DISABLE; phy->speed = speed; phy->duplex = fd; - return emac_mdio_phy_start_aneg(phy, dev->phy_dev); + return emac_mdio_phy_start_aneg(phy, ndev->phydev); } static int emac_mdio_poll_link(struct mii_phy *phy) @@ -2534,20 +2532,19 @@ static int emac_mdio_poll_link(struct mii_phy *phy) struct emac_instance *dev = netdev_priv(ndev); int res; - res = phy_read_status(dev->phy_dev); + res = phy_read_status(ndev->phydev); if (res) { dev_err(&dev->ofdev->dev, "link update failed (%d).", res); return ethtool_op_get_link(ndev); } - return dev->phy_dev->link; + return ndev->phydev->link; } static int emac_mdio_read_link(struct mii_phy *phy) { struct net_device *ndev = phy->dev; - struct emac_instance *dev = netdev_priv(ndev); - struct phy_device *phy_dev = dev->phy_dev; + struct phy_device *phy_dev = ndev->phydev; int res; res = phy_read_status(phy_dev); @@ -2564,10 +2561,9 @@ static int emac_mdio_read_link(struct mii_phy *phy) static int emac_mdio_init_phy(struct mii_phy *phy) { struct net_device *ndev = phy->dev; - struct emac_instance *dev = netdev_priv(ndev); - phy_start(dev->phy_dev); - return phy_init_hw(dev->phy_dev); + phy_start(ndev->phydev); + return phy_init_hw(ndev->phydev); } static const struct mii_phy_ops emac_dt_mdio_phy_ops = { @@ -2622,26 +2618,28 @@ static int emac_dt_mdio_probe(struct emac_instance *dev) static int emac_dt_phy_connect(struct emac_instance *dev, struct device_node *phy_handle) { + struct phy_device *phy_dev = dev->ndev->phydev; + dev->phy.def = devm_kzalloc(&dev->ofdev->dev, sizeof(*dev->phy.def), GFP_KERNEL); if (!dev->phy.def) return -ENOMEM; - dev->phy_dev = of_phy_connect(dev->ndev, phy_handle, &emac_adjust_link, + phy_dev = of_phy_connect(dev->ndev, phy_handle, &emac_adjust_link, 0, dev->phy_mode); - if (!dev->phy_dev) { + if (!phy_dev) { dev_err(&dev->ofdev->dev, "failed to connect to PHY.\n"); return -ENODEV; } - dev->phy.def->phy_id = dev->phy_dev->drv->phy_id; - dev->phy.def->phy_id_mask = dev->phy_dev->drv->phy_id_mask; - dev->phy.def->name = dev->phy_dev->drv->name; + dev->phy.def->phy_id = phy_dev->drv->phy_id; + dev->phy.def->phy_id_mask = phy_dev->drv->phy_id_mask; + dev->phy.def->name = phy_dev->drv->name; dev->phy.def->ops = &emac_dt_mdio_phy_ops; ethtool_convert_link_mode_to_legacy_u32(&dev->phy.features, - dev->phy_dev->supported); - dev->phy.address = dev->phy_dev->mdio.addr; - dev->phy.mode = dev->phy_dev->interface; + phy_dev->supported); + dev->phy.address = phy_dev->mdio.addr; + dev->phy.mode = phy_dev->interface; return 0; } @@ -2695,11 +2693,11 @@ static int emac_init_phy(struct emac_instance *dev) return res; res = of_phy_register_fixed_link(np); - dev->phy_dev = of_phy_find_device(np); - if (res || !dev->phy_dev) + ndev->phydev = of_phy_find_device(np); + if (res || !ndev->phydev) return res ? res : -EINVAL; emac_adjust_link(dev->ndev); - put_device(&dev->phy_dev->mdio.dev); + put_device(&ndev->phydev->mdio.dev); } return 0; } @@ -3254,9 +3252,6 @@ static void emac_remove(struct platform_device *ofdev) if (emac_has_feature(dev, EMAC_FTR_HAS_ZMII)) zmii_detach(dev->zmii_dev, dev->zmii_port); - if (dev->phy_dev) - phy_disconnect(dev->phy_dev); - busy_phy_map &= ~(1 << dev->phy.address); DBG(dev, "busy_phy_map now %#x" NL, busy_phy_map); diff --git a/drivers/net/ethernet/ibm/emac/core.h b/drivers/net/ethernet/ibm/emac/core.h index f4bd4cd8ac4a..b820a4f6e8c7 100644 --- a/drivers/net/ethernet/ibm/emac/core.h +++ b/drivers/net/ethernet/ibm/emac/core.h @@ -188,9 +188,6 @@ struct emac_instance { struct emac_instance *mdio_instance; struct mutex mdio_lock; - /* Device-tree based phy configuration */ - struct phy_device *phy_dev; - /* ZMII infos if any */ u32 zmii_ph; u32 zmii_port;