From patchwork Tue Sep 3 19:42:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13789238 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.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 B55AF1D7E2B; Tue, 3 Sep 2024 19:43:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392598; cv=none; b=r8Ih+1j0mhGWMU4EYGflvFHD9qTXx0NDqT5CJfDTao2u26t0w5Unx378wfTfOQPPOazwGfopZndsk6NCVlHnsvdj9Fdd0eQz6B9HQWEh9Wdl8pYLGQIGfKzikuUgiHe1f+jhM/+sNploKr1zp9OoaY6DA02esxIgotJ6EETzIz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392598; c=relaxed/simple; bh=aZNu7iiv/TYq0BlMH229d2ccbsF2mWev0TPm5aNKaTc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RYaWDo5WqxypiKxD2NV7gsf+YU/oL+R9CImc2PVAKVXeUt8WU55CZo+qTDO/Ssvt5Cb2+GGDjDbQ2I+meMsvmGfw1q48GIEWlO2UGKsxrOLlki2keJjh6gBbFUHs2Nnd1nhm+/HgtU78RObR0msqwIFR4smfgGNkdp66oBq60c8= 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=A3B7Cexf; arc=none smtp.client-ip=209.85.214.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="A3B7Cexf" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-20551eeba95so23133785ad.2; Tue, 03 Sep 2024 12:43:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725392596; x=1725997396; 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=A3B7Cexfrez0CwVe83viCgaWxN7QeUTGg6jSLdyjYFjPuzWMh47m2ooXF4OGNzbdM8 lGVubgwDhTlknU3KtkCDUpubrQYt1By3d1ZDcSA4YZmcrbzcMSdubvHAQOgv/wZipCtm ptZGiunhAjcniDZ7XTwpEAllOtMStF1XPEfoTo9JoDjWhR4SkIhxrhm0jQ5wXrNdHRHE WyzNh64Chk5AISKhLOj1NdlryOwfmhpLXanxPuFq8PXyXofyfc2iqpno4x+m9fzcl0IA hp57dIneGnN8zyLMdXfngjmY5YVwwa2NOdBSgNh+XxYFZ835sffXbK+ICd6tTEeclabh pHjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725392596; x=1725997396; 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=n4eCjMdk2pRqvi26VBMg5dsjxERLfaJRDcM6uACtW3jG/vDDmTGiXjcj0Ak/uHHKhm tueG7ywZYBDGF6THVptTCy4hxFBiPIL7ahtkhe9q0b+bf+u4A1Sk/1belCW9n8BBSIfm Rdp1xizIk9n2KJTjtTeCiRMYIbaNGOaxoKdQSQf2ARcV/yzWxuTvGCBAU/UrYb2vFPI4 Bj3xAll2k0WGZb83B8IZ0ec47sthMVSccRcC20woq3GTwXqDuiI8mrPvgbnWOoKCXbtx ksvV4dKR+8I2dpMTiszpeSWV4UcV/sRYS+NBFzTCOVmZ2zy1v6UbwjQ06G3TUL/AmNVE WfYw== X-Forwarded-Encrypted: i=1; AJvYcCVrY7E+dhQgVsEY/x34XCZSdGCGZEHjM58MzG3EIbgmlJvUyIt56zOhJq1juGOaTEfiYm4IE5RmP84UUxc=@vger.kernel.org X-Gm-Message-State: AOJu0YxQHCtu9iDrs5t9WoPAU7QZAmZaM7ijt1wLXDWp0pOAAIcx/6Gu KePdYpOwX8+48WPumCrE874/qxVDaqr61/CvAsFvXZSG/U0O2um3hUaHSbd/ X-Google-Smtp-Source: AGHT+IHp86QFiMJKp6BMRbcXJOAvjw+IVpWWxd1HmQ0ZMRL7Nb4gdLwROUNn6cYHJ1sGHYEblzPmQA== X-Received: by 2002:a17:902:e550:b0:202:311c:1a59 with SMTP id d9443c01a7336-2054bcf1e9amr82892235ad.27.1725392595852; Tue, 03 Sep 2024 12:43:15 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea52a8asm1979505ad.182.2024.09.03.12.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 12:43:15 -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: [PATCHv2 net-next 1/8] net: ibm: emac: use devm for alloc_etherdev Date: Tue, 3 Sep 2024 12:42:37 -0700 Message-ID: <20240903194312.12718-2-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903194312.12718-1-rosenp@gmail.com> References: <20240903194312.12718-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 Tue Sep 3 19:42:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13789239 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 7CAB81C9DC4; Tue, 3 Sep 2024 19:43:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392599; cv=none; b=tftwHb4zsJLi7ziezOY3e5rUpFdCrN0fzI8+zQzEC8zhACfSA/825/o/W1QzKTSPVn6MPD7cRkCObjOFeWD08dhO1vV6bFggffJUEcm/T9kCTCVYzbrz9lOvBDFXQNVhClkK42uP6jxBbSJ3D8Hqw24OQ9nlcF6BK5Tni69AgOo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392599; c=relaxed/simple; bh=6uvvc9omu3anzlEvACmMTuKSdfG9cb2rFtNsC2yfkMo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hzmlAMRYtCPNQC99eITRrNxPnkEL4N4Ons8whLAVRdVhvy/V7I4aeac2ffJZd/PSCfWsyBFVW5rKGRelNj/6bvYKdcpru+gmZqR13H965PzYXYwjRv0XSefLhTccxZqb2SeFcVVgcUomevQ9rG24BfiU+XhsHxWxtelq57JvMew= 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=IV/B1VjJ; arc=none smtp.client-ip=209.85.214.171 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="IV/B1VjJ" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-20551eeba95so23134055ad.2; Tue, 03 Sep 2024 12:43:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725392598; x=1725997398; 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=KB25pXa0H13f7ZRmiCasC1oMh5SE34bhfNLrxpD/z/Q=; b=IV/B1VjJ483n+b5UM8P90bAPlhbsbucDI7MhecMbSjkLHkgddDO65I1grk6wKUKqKI v8oiDvamJYojH/Ng/z2+UPzf8yvq0AZnWEQ/LjFioRj5P8iV6rljI7bl7DjHbFOuOIpc q4uufOmejyF9frYbcem8r+b/atYLVSMVj0pnygG+btH3ZmOo85VHwUOx3fRpex93zw// y3K1f0eQiAzXApSUSPYTaeNahxk6/vWG+xDjfDO6v1besCqbIgKmeEoiXoJdQZFkLteh j4MoWApmN7SJQcLL520fx0ApOeN1RlbLUVHwXXoVRbNmoEEQZG7zsL4tWsn/5mZFnt54 PLaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725392598; x=1725997398; 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=KB25pXa0H13f7ZRmiCasC1oMh5SE34bhfNLrxpD/z/Q=; b=YMtcY6J9rF9R7LDXbq2XD6H5zL/N9ZSePAH3UiolTIkd++uf1XfBqtueX5lXjot4YL z9fyfaw3ylvr45l2f2WXFnvVM9t1NNXLGk8yszVLaPVYE80bfaxhtL1UDH9IH1s4ybx+ VOrdtbmTg3zu+OXJPvWZHtU5yRPdwp+Go++8b/mOgB+hO/yM/cx+9Kr5WWB8L0W5svxP lXKpdTXKAOZIZb6tZBLxtFS67BJ+1dAdOU/wCHQifEb2A2epobCJZDvcNDPads3sAkD6 CUm9ZugRFc6YjQhUXGlueAEz4hHfPHGtkmmVeckV1hGLsyY5n+C+C6iEDRfNGq9ih8sP G7MA== X-Forwarded-Encrypted: i=1; AJvYcCVQKHxzKoT3RC4Db2YdisVdp2iiImQwGwJMIellc0YA2YOS1s5X4jZFSCNrosS6FFHHJRyS9mcv6n+EV1w=@vger.kernel.org X-Gm-Message-State: AOJu0Yzz7e+SMLcbfaYxj++2D2e81WY2X9a6nEQbszyKyFZz/gopLV3+ cWz+g589tvAGL+editz2pD0/CAtYOfEfgQx5RPIfxu+cJ1oomnryrVl+ofCW X-Google-Smtp-Source: AGHT+IGlTSngbchI/Fat2wEQK0I/MeEpoR13iFU8f27B+Kh0meZehvD/b1BPt2vKVsMUN7QS5gVkWw== X-Received: by 2002:a17:902:e5d2:b0:206:a87c:2864 with SMTP id d9443c01a7336-206a87c2f32mr23233805ad.42.1725392597531; Tue, 03 Sep 2024 12:43:17 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea52a8asm1979505ad.182.2024.09.03.12.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 12:43:16 -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: [PATCHv2 net-next 2/8] net: ibm: emac: manage emac_irq with devm Date: Tue, 3 Sep 2024 12:42:38 -0700 Message-ID: <20240903194312.12718-3-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903194312.12718-1-rosenp@gmail.com> References: <20240903194312.12718-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_probe instead of printk. Handles EPROBE_DEFER automatically. Signed-off-by: Rosen Penev --- v2: used dev_err_probe 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..4e260abbaa56 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_probe(&ofdev->dev, err, "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 Tue Sep 3 19:42:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13789240 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 E093719146E; Tue, 3 Sep 2024 19:43:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392601; cv=none; b=YhWz3sRnY4ELnT4kFVvYNcGr6/ZnGYmi37HRbuUMRDbsc6DizBb9CYTXy0jMnz5vt7uFZhwV1dPJf48s6MwL/9C/caTIa+GpbOswbxGp+WaEO+4MsYpWa5xkV5WhOdvEnWbh4Z8DY0Sr3MAFrSK8jXtOD3H4ADI13KHtn9x2vR0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392601; c=relaxed/simple; bh=Kbytasq71n7TZ4AmPFNnHyoD8fiyS/BnZezEfZaL+kY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cyxAW4bJpb4n0XdSi7w8Ee3saq3sQCqXxTdDbS2p92ozpbPthGU6ETFnJvOBTn9X3zORhmqlcuDVE4r2MsHNavjbK5e9811O9c675thdF8Qz1WKTGNTvWCLM/D6iEwjkZq+g5sVztBsXxUDDsOxcdpJdf2q5kLtSqyibEEokaP0= 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=NtVGWKub; arc=none smtp.client-ip=209.85.214.176 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="NtVGWKub" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-204d391f53bso40838845ad.2; Tue, 03 Sep 2024 12:43:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725392599; x=1725997399; 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=twVF2G1UOixAdHqeKrG2eRrcvQZELS9sIkw44+Ffhao=; b=NtVGWKub/iSQjTy+500ft57Ge0+dNBSuwmQZ0Ri2/gOGT6NOkcET+tcp6/CunVSjV3 9PzyfEWx50tWV6LzvhCMCeYy2Ri2jDbIhMRqAhfGtLPmmTM2HAix2OnOu0YlsYvWdlN/ +XoEUqPwpMW8QxNyNil2Zb1ztFY7sQHA0RNIAEOc2KdmdHZGPTekkFZyrAMEdhrNgDjA I9wAwQtmP7nj/xPOZSiD8wYPd3tR2o86Iuok7HMi1XAWMtJcuF8EG86NDGxK9/jyBRvq kNJGj60Dti3zU1Azzc9sbdEjo+KDMxZZWUx6jfX8ATe5f5r9AoXg76kNam8ms90DsZlw O5/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725392599; x=1725997399; 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=twVF2G1UOixAdHqeKrG2eRrcvQZELS9sIkw44+Ffhao=; b=tG1XNEV7+uY8P79QFjFcUkdazf8hvVfat93sqk41brLUDtsVOtyoCbGkMdsnuBwUSC uMlcrjHFMSeRPFUR4XfQGQqZkgmvIlcaUQ6EIw4a1IhBuubGPLN+i0Y95zuw56QYakWY r8kvKm/04u3dZVY44RY/srajWz1hfznGqHA/gWVt+uFHgPa8Akjdg9G7/FVf24YJzJcR IV7mKELg/pAvbPtRLoxBvvqZQ5WYAkj4cEXiDU5NYi2AjflwFh1j5grB/m8qge6UwsKF 6IgbeRSJhABMjYnYwfgY/Z+xS5cULOtV+MoRmmabp4RjBLa/+JHI/Jln8LxXKkRqGnCB sg5Q== X-Forwarded-Encrypted: i=1; AJvYcCVYiewI9AHar9117nRF6edJSbXssFWsQQBowMHXmqf+jrtOypS3xHurXWKhXZUH8Ab2vMqGoB8m64dQlmk=@vger.kernel.org X-Gm-Message-State: AOJu0YxLRyCOI4DIu3DaDMM6lNvp1RCJWC9zq1zDuk9y7pUomw02LasT pPN6bdUq8b8tAgoP5ody9+pHm43RWbMBkIhO1mWI6BBmCJ6BAwEk3jS6yabK X-Google-Smtp-Source: AGHT+IEiUxsp8z4vKUZL1gW3K66t/atgu0OlBgai+cXNeuBdpHvFZvtQOh2EH2aldKoCaFVZp9EUDw== X-Received: by 2002:a17:903:2303:b0:205:4bc0:1993 with SMTP id d9443c01a7336-2054bc03268mr109289565ad.6.1725392598914; Tue, 03 Sep 2024 12:43:18 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea52a8asm1979505ad.182.2024.09.03.12.43.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 12:43:18 -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: [PATCHv2 net-next 3/8] net: ibm: emac: use devm for of_iomap Date: Tue, 3 Sep 2024 12:42:39 -0700 Message-ID: <20240903194312.12718-4-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903194312.12718-1-rosenp@gmail.com> References: <20240903194312.12718-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 4e260abbaa56..459f893a0a56 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 Tue Sep 3 19:42:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13789241 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.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 4B9A41D88C6; Tue, 3 Sep 2024 19:43:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392602; cv=none; b=XLxYqrlsswGsYdXm0lvvt8E2NO2As5+usVDET/WjfwjCRq42O6aPBf4BTDqinilL8gc4AJhOzNN3OlcfY4Ym2BpxzAXgUJVQ5db6/OaJU9M9fjTFPo3rBmoKL1u8jWamrbihto8/Q/akzvexpB9jFnwA19CQLSxcGEa4r+cw4gI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392602; c=relaxed/simple; bh=ykrgyKRFg1uLEC6ckT+l4Kd9SWyDpuZZ1qKLLmrC7QY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iMauzFVKcwsssfHxzuwHxBkhQLBZJaAZHnLzEL1797f8r6AAI6xOgkdH0C79Mj0ler9qKd9BnG4rz5ZdmzySDwHOfilH2Rz+WDHl3jkSSG0DUvFf3nn/jkBj6enhZ4r9/HAu77hDfqwm2SGguSjl9HsMmtiNPwwf+38HbqC5hv4= 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=jG75m5py; arc=none smtp.client-ip=209.85.214.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="jG75m5py" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20551e2f1f8so28139285ad.2; Tue, 03 Sep 2024 12:43:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725392600; x=1725997400; 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=QpNBuVDP6cW9RiD+NgwPMfYMJOKSgp1YQ143TP+6/kg=; b=jG75m5pymFHamBtpmRUaC3ZAZDioJ1iXWauh4UM1rk0iC0+sIZkbbbao3kctPJj+8y UoDecxnErtqCFOdifV3duFYhbhMgDq3xiN61sp5cm9AC5hmtwPe1QIkLYVejaz+CVg4C Ql2Ksw6qLzSo+cgXxrb8FJZ6UTQisBBhAHYBt6ukV3MX0U9lYaHeYiiHpKVI7gxZ1hHG 00ZRjmwOXeFF2+qI6i818UmpvMgn1iZMAqynSFGALVexAfL6g0gDlAqWd6T2OFC9Q3ki a67dc8pFySVIXxakt5j4lG6e/9YhLWmgzeiK3GAZZDGEfmRAARkfVmyltvBcYZcgUUg0 rC4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725392600; x=1725997400; 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=QpNBuVDP6cW9RiD+NgwPMfYMJOKSgp1YQ143TP+6/kg=; b=kQavOWRB9K3/9gGeeiH1EwXxMLxGL5H+/A0iMQkbXuxE4zntzgvPK/6vesr3a3a7hO 9o4PDi+CnrvP6+iRVqptW24wtNemvz1mAvcaA4daDymViby5KKUX4QbSEPfaRFdH5RRR qRZHkmjoBAyGCQphv+1TcIiWYz7OhVxzoBuXr9TyeQP2EDTEY0f059eZYMqaLRBgd9Aa jroAlt4kDiTAC3n7AY5yChktmsZ/0eR6v9ewpmjAiyoD0M8pPH/SrhpgHGiJVYT4YPAc 4l2hbebe6IrWJu5EKUBVIwC97LB5jC8OqRpIFR40FAmVEcnPnZlgCqYDTCOBLG0SjF0t wZiw== X-Forwarded-Encrypted: i=1; AJvYcCUvvVDtx7POvVzZYg/etPrPRDZb+KR91YbGtbdky2dKGcn8XqTVisPxfmpDhTilWeF0oUgmVZumrE5mKRg=@vger.kernel.org X-Gm-Message-State: AOJu0YxwjwaExtITbNU0JszEedwk3iYdvR6yXJ2+JEoYasjG9mbo/rSX s6hhul0RDVL5FBUzpSZbbDfI6X2Enb0nZre7Bd7UlcrY7a0dT3ZvpysOIYS8 X-Google-Smtp-Source: AGHT+IGxV6x7rXltNpJ482CNvHOEKrCD50BnCOMhXHgav/1+6JXZCS3QTDYhV0i1knBziRkxYXqVwQ== X-Received: by 2002:a17:902:ea05:b0:201:f0c2:9c7 with SMTP id d9443c01a7336-2058417ac35mr91548645ad.11.1725392600368; Tue, 03 Sep 2024 12:43:20 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea52a8asm1979505ad.182.2024.09.03.12.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 12:43:20 -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: [PATCHv2 net-next 4/8] net: ibm: emac: remove mii_bus with devm Date: Tue, 3 Sep 2024 12:42:40 -0700 Message-ID: <20240903194312.12718-5-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903194312.12718-1-rosenp@gmail.com> References: <20240903194312.12718-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 459f893a0a56..4cf8af9052bf 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 Tue Sep 3 19:42:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13789242 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.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 97B551D9D64; Tue, 3 Sep 2024 19:43:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392604; cv=none; b=GqmNB1nl5BLnZp7iyJImr9EsnRhauwH1Fmt1jI3z2yk+VdI8I3zsAXQk42v0hmjhU2zqiWfKOTuA/yE4zFHoMOCoZhWecn0DHieskyEzZdr2rhfTfU8reptdy43X1Qa9q935VTf9L/inz4+GHhcgl74+FGKISC/5atPynakBHPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392604; c=relaxed/simple; bh=+A93/qmhNUSFsa8xsnIjJsQwYteNUx+cGXbIS5ZQyxI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gI+lkbUe+gT1dfSQZj1Txv7xXAPmOhIgYL1wZBRst+ChyL640iTH20uUvuRdTrZtXu4mi2Cra2mhGgwU2xGfPNB3v2gvKpWdma62I77Ah1qpK3jUV7bYJjcfCQKmUlMn2vy6ukebZ4q6wawXNyAkm9R06zjzfbUwKDBHZhImNfo= 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=RvqBqjx1; arc=none smtp.client-ip=209.85.214.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="RvqBqjx1" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2057917c493so27055ad.0; Tue, 03 Sep 2024 12:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725392602; x=1725997402; 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=p4baQNPCRjIgAE/zZ8RJzkEeZj4xVTveUnxI2HObIxY=; b=RvqBqjx1uzdiuWvc5I/XyNUn7Dn9JCNT5B7fHbchOMYwLB3GGiRcCdlAhM/RNrLAST ydI+1cGm+iSBwHh4IRDQfIZAL7gDoATfuIf/CJ1kGd996OYRYS4jmMjXDFkhYrD7T4+Z ahSwgNxfspcYPx1h3NZ20nowqV7VB1XtTuB2SJNH0tI6F4f/IYDiR+WUxP3IBo6VVSJk /UeKzkdgqiyj+d5HVYXW4O+X8DsleptBOmt4ic604xE84TLQy+vgVU4jg6k1qyM6F3sU DbmjzTPmNpHXXHMwDU60X15htgTltffveyiB8nTTpPVh+ZDQCH4kYhGnwfzlhKVBDFUE M74g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725392602; x=1725997402; 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=p4baQNPCRjIgAE/zZ8RJzkEeZj4xVTveUnxI2HObIxY=; b=C2E5ID5l+i5kEjCqGYA30Fan2qs19t4BRcUcLc0mIztf/NGOMtEsSGm2B6PLsEMBXE LxnHjT5myWp3VhFEKERQrd9GeSJP/Vbi2NF8IA82TfKaEh9qk9zGx5n4e84zf1KmELGb lkEWoTrDKHWuVGkiGAcldg2U/vzYrB5VnV8m/UvYN4wNZWIE/KzD7D/npdmjhYWopzma Cxf6rK3bkEY7xs+GJ2kGL0QDbPNM624SIIuaC2HVvBWp9yqUh7G3oueHktASRNhhvRWQ mWjE6RAVGGP7Jybg2Yr1NZGpow56XvuAgZGmq9Z6yU8iR2liN5b0d+pqvOGYpYn0oNyM zZxQ== X-Forwarded-Encrypted: i=1; AJvYcCWVmociRxsnnH1zxQk940gDZ5O0uHsdzV2je+b55HD2cEj52KM6djVsxWOkqr85a5MEhr831T591N8GT8Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yz4ASsVpa0U6MYU+H1XIOWk4qu9G/o7Yn6dV3103KO6Yhr8L18K 11cXvMYcFhYatt65rORhA5uv7Vv951Q/N5xtyli2ygsRuF6LPORlsXFER6ER X-Google-Smtp-Source: AGHT+IHvdrZ+xsRlRtnl3Loac/06AcShNTFQ2IUDQhXpfl2FmgUBTopBk2OPcKfBGfuWGcG2rNuT+g== X-Received: by 2002:a17:902:ccc1:b0:205:76c1:3742 with SMTP id d9443c01a7336-20576c137a0mr159063195ad.3.1725392601663; Tue, 03 Sep 2024 12:43:21 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea52a8asm1979505ad.182.2024.09.03.12.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 12:43:21 -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: [PATCHv2 net-next 5/8] net: ibm: emac: use devm for register_netdev Date: Tue, 3 Sep 2024 12:42:41 -0700 Message-ID: <20240903194312.12718-6-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903194312.12718-1-rosenp@gmail.com> References: <20240903194312.12718-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 4cf8af9052bf..45984e420488 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 Tue Sep 3 19:42:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13789243 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.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 CB1551D9D8C; Tue, 3 Sep 2024 19:43:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392605; cv=none; b=tigJHrW2HVG6lCoNmefzFUG/PheHAlcI82FeZGgGpDsDpvq4CcMfBIoYQSDy8NGtyMgBNX8Lqky+EfrJABucrvQONx9pV7ebaiswlay00PRIIiZfrRgGyDt6AVaffhNI+rFOKR5iUSGV4ZGtu7gGNkQuhkCcNVSm0X1knUp/euw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392605; c=relaxed/simple; bh=mX3kGLJighXuGvdOPieHdrb0awbzzcng29W+gPcAoz8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s0+T3KVL2eJwQfteylZXBVnG9ZqBHWKbfD68s8rUNIiXNOaEOH0CVdIMtahOCejpbJrygAw42Yper23N4YabpMRvUMqRNzUHf9rqmi2ZXI0TQPduV8yU4p38kZeH9i/Kut0+OzKUsVbxpn8uFtK8S0Z/Jz4DF1ccu5bEHrQUlGc= 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=lzkYdbB9; arc=none smtp.client-ip=209.85.215.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="lzkYdbB9" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-7d4f85766f0so592175a12.2; Tue, 03 Sep 2024 12:43:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725392603; x=1725997403; 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=81sQTGyUrTjqH1KfW7Mrw33abUjSwj5schWd4BTRCqE=; b=lzkYdbB9BkTtiYTxMhkfxiMlnEHar4G2++K+mzd3F/FXSTLH4tE0M7i/JlQZonjEV7 8VtimPYDqwrBmA1EXl7N1UAutTRGkX74SXWRTuxhDaKWmbmKzJTX9ExGD7VFwILWu/G1 jT7DSz/sZ3gcnjoSmDE2powcQ52keqPENnVUQ68YSAlRmnRrxmoinzcRMEveQ78498ME DTrfh3oc1QGZMnO2f5pYVvq5IWGs8PtgHCWN/S8ECvqR3KWcYTnfd6/PRkEnEi+wsF7U vIg08MQ7X79Xt2qhibnSCyd6nRgMZ+XaBRhVEzT2mboFzPvQXZnecYg2huhTYEZ6t15K BYqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725392603; x=1725997403; 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=81sQTGyUrTjqH1KfW7Mrw33abUjSwj5schWd4BTRCqE=; b=E9PlbSlG9PjGsiDwzF4Ji+ducTSKwRqs4295rGgB0qRlQYaeK5EuVNKZqaPslRENKf QkGZE6TO5szuOryzhrDeX3W1EWRXWcrs73JFmwcbCto86Y+vTpksh/hEJ/7k9ivQC8Ff ZhMhnmEOxOp4jKW96Y/iKGdUxdNdYxs5bNgqTUun90NbWj93wN0c1gAX475uCdmqwx+c fBntGlNfdKg0iyWqA/uZP8kSgvsiQ2SYeKS8/S52k4gAzlw+biu4HChrRoRGZx9oS0xJ qqCh7J0/IZlF0uT+a2hY74x0f+CrZChnuYInzwSkzJx64p++SUTd/AUVgmd1drJkaE4m k4Yw== X-Forwarded-Encrypted: i=1; AJvYcCVfKoLi6UruIAY4+1lTPyfmTuPpTspKKq801CzEuiLM5oSAKHHQfOw08BHSqayXjLFhYxCgMH2UC/+DSig=@vger.kernel.org X-Gm-Message-State: AOJu0Yx217FhNRm+759FI7kmT+JrJIlcfelPPNHU8jbxmyceaHZz8OV6 VaIUXthSjhtz5OLV+NtzXYkmccQ4Ot3r4LzqrsxNmVWWqGjJ6P1OT8HgmwnB X-Google-Smtp-Source: AGHT+IGotFQpf5tNC3er0L31QQ5wJhj+55Q+ETcOBFhwKNK+JxKKpj6//TLEtDtYthACoxkaWXJrkg== X-Received: by 2002:a17:903:32d0:b0:205:36dc:c3d9 with SMTP id d9443c01a7336-20536dcc7femr162505265ad.33.1725392602917; Tue, 03 Sep 2024 12:43:22 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea52a8asm1979505ad.182.2024.09.03.12.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 12:43:22 -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: [PATCHv2 net-next 6/8] net: ibm: emac: use netdev's phydev directly Date: Tue, 3 Sep 2024 12:42:42 -0700 Message-ID: <20240903194312.12718-7-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903194312.12718-1-rosenp@gmail.com> References: <20240903194312.12718-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 45984e420488..121db9611cd9 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; From patchwork Tue Sep 3 19:42:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13789244 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.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 DF5B31D5880; Tue, 3 Sep 2024 19:43:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392606; cv=none; b=mac9V8AV5QuzRBupR3JtaYGPRhH+hfWq8kamHG7qShBgF+met4dUp3MTQmFaXoMqoMHsSMV4IccUbrneeed18zAG2IV3exLgJ/MSUkTMmTjiXu3/k3KFTN/oKE8Ac2YAnN8CDwKTPvR/85Em79AIXG08bwGOjcfwtjLlegssrHo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392606; c=relaxed/simple; bh=Vqa1JcGHbelpuSMZGTBLTJROHgdmvgVL9Omtrlf1C+s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qvTzk09zjexBnc1GoaKZa8L8fAUoguDwsxLgtCuie9i3WpY8enmxH9lCxP/toHP4/h4niM+7hRjI5F1Oxyq5MJjbwOqSN+h3v/lEt7CaEhNHXIJ31pI39OA+GXWn+GPMhiw7dwTjRvJS5p2feH5E7ZtlsMpXrWxvV5SXYNwaSlY= 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=SSUprc+2; arc=none smtp.client-ip=209.85.214.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="SSUprc+2" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-201d5af11a4so50055155ad.3; Tue, 03 Sep 2024 12:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725392604; x=1725997404; 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=aYleQ4wVeI+UIqewsN+uSfMEW3OIt7z6W9ffXRdutuU=; b=SSUprc+2eqC+UQVX1nH9WZQU51Ia1y/fhtx9cObiFLNbHRBWQRID6UOSNr9JZFuh2c Qpsl7/Jafd645e27ZBs0C/HS5D/+1+X4VUMkB+q8ZEMMHCoKU5Nb3q9PRxxHIg2HP4Qm G8PLlv6BCJGg6Pr62VMip1ru0RQJ4A+/MwZ1+eFedvRC4th/zCTsuhCat7aPsVU9+9KC iEbgu7RU0K8sT5Ghqzd4xFZQHwbMhEM+71jqI07n33hBFho1jQSkv7kVPWR7a6b41mTe eJ83b8wi96YLIRj4coM9J/i5lgpAJeYOh5W8bgLE24Q5szF2DSSKJZQFOX4pnvMemZYR 30jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725392604; x=1725997404; 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=aYleQ4wVeI+UIqewsN+uSfMEW3OIt7z6W9ffXRdutuU=; b=MQESOM/MXlwUjFX+gwNNJ79o+SYy9QiViHkr9V1Dg1H64abmq9mhLmY61DvHHhKGLx G/aEWq2IBqMQmwVHvaKJnWCvLMeVR/Slw8eGGcnsvVqIgTDbeBl3anwBxGyfJdfeUC+H f8tKgD1UtilK9CegkngA6j48bUwJKWQcwOCy7ful5eLlBzXod3oWMQ4Gkr6iZC5fYa7F x/GHozxzGR7VKRx/UhRm5vJ80HylpMajqo6BdExYJmgRhvE12btCDSD0m3uJD8CL5WOV t/y7UAMcFL8HnO7+l5f996D8bfjIUswFexWZG0hQFw+0RP6QCxdq4hubhk6Q1oHDjnwR Ub+w== X-Forwarded-Encrypted: i=1; AJvYcCXduUcIpWT7LbSGNUL6CQhU9zXdZM2+xGQgT6uGqKnlA/Kba8mIrWSVwIkUmda2t1a80XHAY6TmTzNL83Y=@vger.kernel.org X-Gm-Message-State: AOJu0YyaF54+tstdlwINYHXM9nkHRy4CWCEEdCHobyPa6UlMKorAIthJ tRRDgylhkhrMwmrOcwbeOapb02HfltEhj9gWtAjA93CQjF1io7eXdTJ4oXgY X-Google-Smtp-Source: AGHT+IH+W0wOtdVGBMNlUR3NzzhtwJUzozrCwqT9ynym+LQcxWrCbyQHclCypj1i9QH6KAiVFknEEg== X-Received: by 2002:a17:903:32cb:b0:205:88ca:9e24 with SMTP id d9443c01a7336-20588caa05cmr86225555ad.19.1725392604206; Tue, 03 Sep 2024 12:43:24 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea52a8asm1979505ad.182.2024.09.03.12.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 12:43:23 -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: [PATCHv2 net-next 7/8] net: ibm: emac: replace of_get_property Date: Tue, 3 Sep 2024 12:42:43 -0700 Message-ID: <20240903194312.12718-8-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903194312.12718-1-rosenp@gmail.com> References: <20240903194312.12718-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 of_property_read_u32 can be used. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/core.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index 121db9611cd9..6db76eeb4d9b 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -2444,15 +2444,14 @@ static int emac_wait_deps(struct emac_instance *dev) static int emac_read_uint_prop(struct device_node *np, const char *name, u32 *val, int fatal) { - int len; - const u32 *prop = of_get_property(np, name, &len); - if (prop == NULL || len < sizeof(u32)) { + int err; + + err = of_property_read_u32(np, name, val); + if (err) { if (fatal) - printk(KERN_ERR "%pOF: missing %s property\n", - np, name); - return -ENODEV; + pr_err("%pOF: missing %s property", np, name); + return err; } - *val = *prop; return 0; } @@ -3298,16 +3297,15 @@ static void __init emac_make_bootlist(void) /* Collect EMACs */ while((np = of_find_all_nodes(np)) != NULL) { - const u32 *idx; + u32 idx; if (of_match_node(emac_match, np) == NULL) continue; if (of_property_read_bool(np, "unused")) continue; - idx = of_get_property(np, "cell-index", NULL); - if (idx == NULL) + if (of_property_read_u32(np, "cell-index", &idx)) continue; - cell_indices[i] = *idx; + cell_indices[i] = idx; emac_boot_list[i++] = of_node_get(np); if (i >= EMAC_BOOT_LIST_SIZE) { of_node_put(np); From patchwork Tue Sep 3 19:42:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13789245 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 4A1DE1D58AA; Tue, 3 Sep 2024 19:43:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392607; cv=none; b=ogomeFu0ah9VEifdDWu+Xjfu/m9p6j/TKrlhhSFeQ3PBySJ2YmfxRq97NEP90GTb0e1h0gja5N74HPurMq90eBQBLEYtmxp6ETthxKuOvl2X7S2VxbOI1cC3xUFNYLXFSMj7J4fVlKyl0i4LBa7VMTi6gdi48JPkXjjDgKRqTSw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725392607; c=relaxed/simple; bh=ak/7Xp3m4pxkz2pP3Zn59wCuaBHPoWVar2RPr0X1K24=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=COJC0iCJ5rwqlph3raFubQn+QclqcipW05UGGThK8GWBKGhcR9MDxVCHfUk0ZAg/HEbYbQkfC2Bxav/FIzabcew04oIagmmxebMOT8SFOwMa8vHnRReVj35R+9l75LoB+GSCp0TNIyngpHIbR8OTXXFF2hGdkHyDoqII5vtbGyc= 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=elNm8rla; arc=none smtp.client-ip=209.85.214.182 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="elNm8rla" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-201d5af11a4so50055405ad.3; Tue, 03 Sep 2024 12:43:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725392605; x=1725997405; 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=2XV8JTTrQ+n17koZUnnvATzf/oJhYK0EfQN8SyVUPyk=; b=elNm8rlaP/sq4ewlh9jBGpchrh4PcTSzTyC61P9/nZ3elvHFl8Hi/3yeDjJPrqp/5z QqvDB1TjvPPuMWFokAYeOi5PR88HE6VWH7E6eYeA0sdruSvmj0Iuc5yIp0ogAHNfXCSw Q2JTpQ4UlrF6AvCVe4MRiSzwui9O8MILRYtpf2yJ622UNQNyY6B3IFw7MD9qeiX/0kWL yqG28xn/ylFQgZf4JNFKFKzSxQq6w0/KJiQaz02eg2omC3+1UXXD1tkkm06Q6oQgE9vE n/9JWDW6mbHB+pLDzDubLezxt31VOGRfq55kkU3ZTpuTlzeqDae++LGf386manK3VSaO YLDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725392605; x=1725997405; 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=2XV8JTTrQ+n17koZUnnvATzf/oJhYK0EfQN8SyVUPyk=; b=YJjUV1wzZOE+wTm/1rQFMm3euZtRNAgVkIvYKf9Rbmhkib71Wig6Ax1EqopU378QZA dihZgjRG8evegIZaePZBdBdMm4V2jfn7q+DgfR0zvcwYU4xcaCVbBDxEdSVjFo7VpeZm dp2yw+foMnITQ7ln/xN34GQEuvLRCdQfoSK7poQU9TFKIlX6OKIaoKTUD+RSsX02iUG2 u0ZbiCcKZOLgFEsm3eWlQGszu6Zn6Of1aBgffbGjwOyX5SlDrY/C0MwD333W5v4MuNDG +gORhlcuEb59MUYBy1+ldC0KS5SjO5QevYYfnWkhSZfgu1XD1jHw+rseW/ITmVbF0PbH CV+A== X-Forwarded-Encrypted: i=1; AJvYcCU29XP4DsDIPuqj529UdBtU2ifgwF9xoLVZD6MBCzj1ON5C1OEm+i3SWMWyXFaznbkvm6kbajiCOqql9A0=@vger.kernel.org X-Gm-Message-State: AOJu0YyLe9aMixjsfGlH+ZFcvJDzhjgStdLgNSaXUisV7O0AtajBfbO8 ZjWml38IMewiyVSAtX4KrXEENfCO6ADKefg0PcHI7AVH9MwcYHigI7I8L5DG X-Google-Smtp-Source: AGHT+IEji7zv5bJzaMjoJngvtD/kqPauLyrBVTIfFanCQoj6bha8Dh72TzqSsKeF9y+TMSZyla5IJA== X-Received: by 2002:a17:903:2c7:b0:206:aac4:b844 with SMTP id d9443c01a7336-206aac4ba88mr22123545ad.6.1725392605437; Tue, 03 Sep 2024 12:43:25 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea52a8asm1979505ad.182.2024.09.03.12.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 12:43:25 -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: [PATCHv2 net-next 8/8] net: ibm: emac: remove all waiting code Date: Tue, 3 Sep 2024 12:42:44 -0700 Message-ID: <20240903194312.12718-9-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903194312.12718-1-rosenp@gmail.com> References: <20240903194312.12718-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 EPROBE_DEFER, which probably wasn't available when this driver was written, can be used instead of waiting manually. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/core.c | 77 ++++++++-------------------- 1 file changed, 20 insertions(+), 57 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index 6db76eeb4d9b..21401a8cb32c 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -96,11 +95,6 @@ MODULE_LICENSE("GPL"); static u32 busy_phy_map; static DEFINE_MUTEX(emac_phy_map_lock); -/* This is the wait queue used to wait on any event related to probe, that - * is discovery of MALs, other EMACs, ZMII/RGMIIs, etc... - */ -static DECLARE_WAIT_QUEUE_HEAD(emac_probe_wait); - /* Having stable interface names is a doomed idea. However, it would be nice * if we didn't have completely random interface names at boot too :-) It's * just a matter of making everybody's life easier. Since we are doing @@ -116,9 +110,6 @@ static DECLARE_WAIT_QUEUE_HEAD(emac_probe_wait); #define EMAC_BOOT_LIST_SIZE 4 static struct device_node *emac_boot_list[EMAC_BOOT_LIST_SIZE]; -/* How long should I wait for dependent devices ? */ -#define EMAC_PROBE_DEP_TIMEOUT (HZ * 5) - /* I don't want to litter system log with timeout errors * when we have brain-damaged PHY. */ @@ -973,8 +964,6 @@ static void __emac_set_multicast_list(struct emac_instance *dev) * we need is just to stop RX channel. This seems to work on all * tested SoCs. --ebs * - * If we need the full reset, we might just trigger the workqueue - * and do it async... a bit nasty but should work --BenH */ dev->mcast_pending = 0; emac_rx_disable(dev); @@ -2378,7 +2367,9 @@ static int emac_check_deps(struct emac_instance *dev, if (deps[i].drvdata != NULL) there++; } - return there == EMAC_DEP_COUNT; + if (there != EMAC_DEP_COUNT) + return -EPROBE_DEFER; + return 0; } static void emac_put_deps(struct emac_instance *dev) @@ -2390,19 +2381,6 @@ static void emac_put_deps(struct emac_instance *dev) platform_device_put(dev->tah_dev); } -static int emac_of_bus_notify(struct notifier_block *nb, unsigned long action, - void *data) -{ - /* We are only intereted in device addition */ - if (action == BUS_NOTIFY_BOUND_DRIVER) - wake_up_all(&emac_probe_wait); - return 0; -} - -static struct notifier_block emac_of_bus_notifier = { - .notifier_call = emac_of_bus_notify -}; - static int emac_wait_deps(struct emac_instance *dev) { struct emac_depentry deps[EMAC_DEP_COUNT]; @@ -2419,26 +2397,25 @@ static int emac_wait_deps(struct emac_instance *dev) deps[EMAC_DEP_MDIO_IDX].phandle = dev->mdio_ph; if (dev->blist && dev->blist > emac_boot_list) deps[EMAC_DEP_PREV_IDX].phandle = 0xffffffffu; - bus_register_notifier(&platform_bus_type, &emac_of_bus_notifier); - wait_event_timeout(emac_probe_wait, - emac_check_deps(dev, deps), - EMAC_PROBE_DEP_TIMEOUT); - bus_unregister_notifier(&platform_bus_type, &emac_of_bus_notifier); - err = emac_check_deps(dev, deps) ? 0 : -ENODEV; + + err = emac_check_deps(dev, deps); + if (err) + return err; + for (i = 0; i < EMAC_DEP_COUNT; i++) { of_node_put(deps[i].node); - if (err) - platform_device_put(deps[i].ofdev); - } - if (err == 0) { - dev->mal_dev = deps[EMAC_DEP_MAL_IDX].ofdev; - dev->zmii_dev = deps[EMAC_DEP_ZMII_IDX].ofdev; - dev->rgmii_dev = deps[EMAC_DEP_RGMII_IDX].ofdev; - dev->tah_dev = deps[EMAC_DEP_TAH_IDX].ofdev; - dev->mdio_dev = deps[EMAC_DEP_MDIO_IDX].ofdev; + platform_device_put(deps[i].ofdev); } + + dev->mal_dev = deps[EMAC_DEP_MAL_IDX].ofdev; + dev->zmii_dev = deps[EMAC_DEP_ZMII_IDX].ofdev; + dev->rgmii_dev = deps[EMAC_DEP_RGMII_IDX].ofdev; + dev->tah_dev = deps[EMAC_DEP_TAH_IDX].ofdev; + dev->mdio_dev = deps[EMAC_DEP_MDIO_IDX].ofdev; + platform_device_put(deps[EMAC_DEP_PREV_IDX].ofdev); - return err; + + return 0; } static int emac_read_uint_prop(struct device_node *np, const char *name, @@ -3084,12 +3061,8 @@ static int emac_probe(struct platform_device *ofdev) /* Wait for dependent devices */ err = emac_wait_deps(dev); - if (err) { - printk(KERN_ERR - "%pOF: Timeout waiting for dependent devices\n", np); - /* display more info about what's missing ? */ + if (err) goto err_irq_unmap; - } dev->mal = platform_get_drvdata(dev->mal_dev); if (dev->mdio_dev != NULL) dev->mdio_instance = platform_get_drvdata(dev->mdio_dev); @@ -3189,10 +3162,6 @@ static int emac_probe(struct platform_device *ofdev) wmb(); platform_set_drvdata(ofdev, dev); - /* There's a new kid in town ! Let's tell everybody */ - wake_up_all(&emac_probe_wait); - - printk(KERN_INFO "%s: EMAC-%d %pOF, MAC %pM\n", ndev->name, dev->cell_index, np, ndev->dev_addr); @@ -3225,14 +3194,8 @@ static int emac_probe(struct platform_device *ofdev) if (dev->wol_irq) irq_dispose_mapping(dev->wol_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 - * on us - */ - if (blist) { + if (blist) *blist = NULL; - wake_up_all(&emac_probe_wait); - } return err; }