From patchwork Thu Sep 5 20:14:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13792972 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 4FECB19EEA0; Thu, 5 Sep 2024 20:15:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567313; cv=none; b=T2Igsuquj5dDlaBlBbKC/4ljhsrrZkSokWAiL8Wb36U9q7eVjIznJ0uAbz/eJT+Y3HIKpYjNl6NqB34Zwrsmod1T2YBVrdW0c0RjRGU2xo2NVMcrlHXBpbclfhrz5euVAuEDEC0Yq5uUvR3h1CRPceILVSQasceXc6KJrHUpKVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567313; c=relaxed/simple; bh=aZNu7iiv/TYq0BlMH229d2ccbsF2mWev0TPm5aNKaTc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cdY5oc72sSq8FasQLArhkSjFormrus4qYF6nhcsQzrBid8n4eTieeSVM3IWi8V6IduOxYBcbTpe1kt4UVt13hH9hJwcBzuvqLpddInZFUbcyPOqC7ungmAf/GQGX95ll8QsNNXNkN8Wxfq5lUBhPagz9Y6Vg3aL5tqkZK7oHcdM= 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=kaGY+s7r; arc=none smtp.client-ip=209.85.210.180 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="kaGY+s7r" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-7184a7c8a45so332468b3a.0; Thu, 05 Sep 2024 13:15:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725567311; x=1726172111; 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=kaGY+s7rG/O/TXHV8m2TJcUhnyWAY0spaiS8bfQHM6IwjruWAi/uIt42tTqhopB5tz i/CJsvSKuTmrrctnpVGwcCYc3eU882vTkP5FH9HqK6Vm+nHubyPxKHgG8d/UqkyFRJra p1HYJmSmUvKjMnp3+A2E5FxqSJDuPFSs+/ZPPjPCZt1eu1ALHV0aFdT25b1dTZGKDpie q6CIgX2CAVXNnEDn5rN4iRLqbkKA1Y1UXRno165dT+XXMumX4yz9zELEnGiA5bop/77F LZDL9URogoO2JDXGtMz5D3RpBf+hBaRyln/Esw55jMMkeUUz4fgG7zo0zB6+QD4jpU/P H33g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725567311; x=1726172111; 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=MZ0md2lbjrcUk4a42PufnFkJ9VzKIj0Qg2svZhfqW+EDzpfNgZXGu7LfMdt48vhOmQ VlPaif7G0ONO/JRIZ/Vfy9Ebhs6TU7r+QFlZUjSuGXAeZjVGlAnxaLjXj4erc8WrS3OI WMgSJpIuG+ggN5pJWmej5AotF4ZXSAI9LwySb70qvZf2JK2yX4nTS6f+LSpxR0qk8hkw f1d0TEeN5fUTjLgsVQ/oHbv28YV286wAG/+kdlNoRlP3eBj0DCNH9e53wOAj1R235GIa Xqcgk51tPuczCnHfZibdJR2WzFshCcyiR19Jtx9mAj9KighsLG4lTtEaHmp9AIN9UXlT az2A== X-Forwarded-Encrypted: i=1; AJvYcCWwHI85gg84Sz1V9r/6jUbRB9gfH+bi8a6gIXHfJ1RKy2qVEk63iDJtrWca215MkSlUsZUMkLMOZ/PG2Vk=@vger.kernel.org X-Gm-Message-State: AOJu0YwqT5Nk0xyRWAsvJj7ipr9Hhpd7ovbHckNYIT1mrrorb9/SL7CO F+UWH/tiFzjPetLrHFVXYw7Cr7ifMgyZNb/H1IdlmzB2gLFMpFeoijgGy8WB X-Google-Smtp-Source: AGHT+IH0C4sli2G1PL868GMVrz77JpWGqk/BE8epqMhKDlbcJ0taLYECCqwVUJl1Pc1pbbclILvxnQ== X-Received: by 2002:a05:6300:41:b0:1c6:ed3e:3e24 with SMTP id adf61e73a8af0-1cf1d0ee292mr137715637.19.1725567311464; Thu, 05 Sep 2024 13:15:11 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea68565sm32327075ad.294.2024.09.05.13.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 13:15:10 -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: [PATCHv3 net-next 1/9] net: ibm: emac: use devm for alloc_etherdev Date: Thu, 5 Sep 2024 13:14:58 -0700 Message-ID: <20240905201506.12679-2-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905201506.12679-1-rosenp@gmail.com> References: <20240905201506.12679-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 Reviewed-by: Andrew Lunn --- 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 Thu Sep 5 20:14:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13792973 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 F020A1A2570; Thu, 5 Sep 2024 20:15:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567315; cv=none; b=EQF/59Ub1Gyg6hOhPIFEhwDqPKoaNqVmKBkYYmMz+OypNidVuaL87rLR56OYU5Ri3oNOU2NJUThmf2/ID2Wi8f4TqHnQOGcB9xczwT09meRfAGab5zw1ylVMIZYAEXqhM/I5ft3GpS3kqT/9oZdMcxVN5pIdyulJjyEVhsrm3/8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567315; c=relaxed/simple; bh=NMFwqK9P8DdVP/XR1YebegPCUBcEds6Hmqj33CwL7Ao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qTjk1Y+wn8MvDyDDOA5jMI10FdQeQMtRNtU2U+lTMJAoXEQ+YSqIzIxIg+ubgIMjFzuACE/OU7oJwn5Nxwd+W1eXTht49Xhb/VDFgHbcW7N0tqBmdGmq7FQgVbcd/54mn36XYMi5WrgyTpt6bgK5/r461pVfGf4t3cnRlvTfVbM= 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=VRn/Mjvp; arc=none smtp.client-ip=209.85.214.178 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="VRn/Mjvp" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2068acc8a4fso13624585ad.1; Thu, 05 Sep 2024 13:15:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725567313; x=1726172113; 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=y8fL6/bDG5C4dR8XEsWsmydQA+3xhydB/w8ADOktWUI=; b=VRn/Mjvpq/kVGjUcF2KD6lmoGnWVtmZ3aVyLDTLCvI/5kEms1gzYhW/eGEdDG1agKq LamfKbYVhrKtZxYwXLRfd4ErNZSEONtASdWO7SiFslLYFXGtEsFhCiA8SI42ZZTaCe2l 1Pdjfka1kYwGix5CswShBaSCZC2i50rhCHDjhWsrx6zy1MfmGZsgwZTuW3CrgJt52lGq gNQbQOGtOZIpx20pFBnb9fjQacC6lqfQOQh773drJ/EJzinBlJlr+Cp8sdI3mAhSl67f /w36efb6PMGqZk4SfezTk5n+Ot8DvgkDbm6RDAlSs4qs++K2/+pzGjYR+Lz2CA9rJxkW MplQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725567313; x=1726172113; 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=y8fL6/bDG5C4dR8XEsWsmydQA+3xhydB/w8ADOktWUI=; b=EABfbYc/Ux385M9PGfk0AeaEs52kt/SotXXlBcIjXGaGVzGbkZAt+HsZa1mtR7NWTF 0pwwj5P7bZ1XSiyuJgenxZ5kobCLnRZ5Sfo96H5uKlMFlcHAlekveGznEj7/3Jjmg1xt vSfKZUX2UIVEf18VY1DMmlewEPpNBbFjFaLo78CUFDvaflBP9o8nv4YffThADMjFUJF2 ZmsPd3Ybpa52497t0rw9Gyuk+InG3fx9ay6wrVjulcyVVc6zHf2+pgjr3FGxm5i9lrh/ +/jxzGACdVFilDBBjjzmZ1dAos2vrv4kpynzlBJBYGphpN9k5INKFo2Gm1faUD/0BhxN gYgQ== X-Forwarded-Encrypted: i=1; AJvYcCUT6DWeJF4wJjA2GDMJwVHjqv/BDrhoTci3EOCUlRnOI71nEDIr9cZEAGeiPjbB9BL8N0gv7TGpu/jRua8=@vger.kernel.org X-Gm-Message-State: AOJu0YyND0tWIuF0VrbcN+i5Q/AIXmCB1E/ryP5BL0uk9pFbA1hb+mHr 0wIZNp++IHLEEpAe50ma1zCg4LuoTTQ6u1KKW4Vd05Q85DQ7cXXGx3MHCb+n X-Google-Smtp-Source: AGHT+IHS0rye7cxPWMkcywFbMLAAFeBhLyiPr6lbBCsHiJ/zAp4A+qq1e8uWMjs6mV4qC9fQey4IpQ== X-Received: by 2002:a17:902:dace:b0:205:8b9e:965f with SMTP id d9443c01a7336-2058b9e9b17mr149871485ad.31.1725567313053; Thu, 05 Sep 2024 13:15:13 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea68565sm32327075ad.294.2024.09.05.13.15.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 13:15:12 -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: [PATCHv3 net-next 2/9] net: ibm: emac: manage emac_irq with devm Date: Thu, 5 Sep 2024 13:14:59 -0700 Message-ID: <20240905201506.12679-3-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905201506.12679-1-rosenp@gmail.com> References: <20240905201506.12679-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 Reviewed-by: Andrew Lunn --- 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 Thu Sep 5 20:15:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13792974 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 4CA141A42A5; Thu, 5 Sep 2024 20:15:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567316; cv=none; b=lzYI5LfbvTFNTDovJLx+A+XpXwpM+yEsSl4Z3hQ7UYRQtsosDvzs7dCgG+uAQuAc77SyxX6PhCyPX/16ye3Bu6xTHm0iaYERPYmcHwqq3aqpUJOhEx44TNhlBsJmYdAzy48+2U/80t4mU2q8EFqucdw6M8uX22pf5bcX9ZiIb78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567316; c=relaxed/simple; bh=Kbytasq71n7TZ4AmPFNnHyoD8fiyS/BnZezEfZaL+kY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pUalapQpJjX8fvMRyBSxEFhmu0FDxGZTkU3D5uo5HBJqRwQQmRceLszl0ipK42edjIMU8E+utJCUu/wYo1nT4OA1CQTpjPDol8Nl9+Wh34NBUKacHqLTt+uQeGpTewQOp1+s8unUnIS8w1TlTcoAUecwafqzaO37UJd5rrTMnSg= 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=hoygwAIX; arc=none smtp.client-ip=209.85.214.175 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="hoygwAIX" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2054e22ce3fso12748815ad.2; Thu, 05 Sep 2024 13:15:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725567314; x=1726172114; 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=hoygwAIXJ8PW4PwJ3tl/JXVA321IIZlX0LJRe+eHgjtyh0oa5A2hptFc1Ug+yLehFR 6PHxBF25MWDpOVdgetqBmJNNJKZrPdNt8X8lyANYDxSDAq4hL4UUfnyFZkuS0AIifD1J d3S9q4789EwPJ6WSmvTl+IlwBmdyYQ8TDHHRipku6XFnmt78s5YOVaPm8oVldUH98hM9 Q2pbLTGzBUQTL3UAPTZfsKGO35pH7AtTQX6MVkrru5J4VkZSXcq95hWM81405l7mWhz4 ghqc450sczChwAmSVJtnLSM7G6gsSDsKKL1NRJus6JnOkFyXqN2AqmMApFHCQf3almjY glnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725567314; x=1726172114; 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=rfBZHOqsvbbYOBuuez6ZTLiTlyBHjDJOAOGiZ5jZt7O2tg1GYpl3/PoLCj/njyO/dd a1QjxS0fIXIWiB8i7SN2DofRTcPAjcp0l7RL/VXADFZhap5KEZYYiyKbXPnpFOkVgbKS B6NmAD1GoIELwUWOVolcB7sa+idiStl8YU1D5if36D/0bDPFXw1zsCN9+fpENO5/0dQF wLVxqRiz0oN27jS0G53RBLpqf7sbq01rswEGRNAAwZd3hOfoLDuP8uVn3cqCepSxcuFe MrOTUmTsLetgv0RE2JfKwcgDiBlVLT1LP65PPAMGX2S9qVH6iQ/rxTWvBFesE26dvNWx 2DOg== X-Forwarded-Encrypted: i=1; AJvYcCXWO7nIVSAl/c8kUsDBdO3dg0IKB8nAvjRKA1ONQgqU9kQcQ8L3dEhoeihu9cAQ/RSBTHztxplrZkrsv98=@vger.kernel.org X-Gm-Message-State: AOJu0YxsGjt8z7ffMe+L69QEdY50kO1WTi5tnsQE7ls6OPSQxgQH8LFn zgiRWnFNP6GF+TKdBH2ALfm8Iqd9o46eL6d00EQqaBB/hcS38eHXZl91EGlE X-Google-Smtp-Source: AGHT+IFnrt2HJU+gpTNxzE/4u1K/G+o6CpdxkIblRQ7lxhvT3E6kgbnrrHWro4hkwuipyENW2hqDsg== X-Received: by 2002:a17:903:2287:b0:205:4e15:54ce with SMTP id d9443c01a7336-206f050f178mr2861355ad.20.1725567314424; Thu, 05 Sep 2024 13:15:14 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea68565sm32327075ad.294.2024.09.05.13.15.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 13:15:14 -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: [PATCHv3 net-next 3/9] net: ibm: emac: use devm for of_iomap Date: Thu, 5 Sep 2024 13:15:00 -0700 Message-ID: <20240905201506.12679-4-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905201506.12679-1-rosenp@gmail.com> References: <20240905201506.12679-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 Reviewed-by: Andrew Lunn --- 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 Thu Sep 5 20:15:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13792975 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 950361A705C; Thu, 5 Sep 2024 20:15:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567318; cv=none; b=OLatSV2Vcqf/QYYNo+tQBkncBm034ZlHtjoHRVcAIrfukxtm6kIb4fLrYU+djMaqlF8baq+FJ/eIpBjJfcqUGyjH45P2M5M+xE2X//H9e+edqWiSXhfhp3nS1EanGcYcMJzfazvSApFa7LiXppKGKQO2u/VnV+k6dlXbf9wXb1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567318; c=relaxed/simple; bh=bSRHX1yZKX1Frj3AlhJcHG5pMJsG9aGMAJKiYvacp/U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hDsuzhh/zn/Zo5Fjbx2CJ144SldcagUGArquoZSY55+6f+GwCOctXb3CYc9T2/0IaXbXVeWUP3D9ieyJ+8sfoxX0SSjFVX3Ta9gXiWc4wWV6/9+B9OynM1lEm0Ia5fR0IBlf3I8GZ3z1aihxJP7rtKRwbUBHgcjxrjSXIa0y2wg= 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=YNVZg409; arc=none smtp.client-ip=209.85.214.180 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="YNVZg409" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2057835395aso12189995ad.3; Thu, 05 Sep 2024 13:15:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725567316; x=1726172116; 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=T3chJ1T19SwdPfSH8SDlP3tp4ORmuKyqtDERErOcPO0=; b=YNVZg4098L9Eey0lBfqyyBJxy3o6mpno9zcEksHqqMECwvo6xnG9s8UuvswIESTz+d 8N5dLfDEV4OSlzAqX5zEahYN9ApniHJD6WJxgk6G0rqU3lBBUf6QmVNkoP/oUzpJXngg qxg61JrWn8eUSmeIN0FyDkkKUGhJtk7pMgjevDtP/+XAVxKMM1O+r2jaK/7OrvRmn0/7 jsBV1s0yV2S+tiCYIUqUJ2zAuU4XnE+ZmJ4mqGrE/LX2M4+SDJUFVAuDBVTdsn2hqgh2 toRa9vCcc7XJncj6xcTk6AgqMVNk1AbyrjzINXfuAJ4Q79KzM50Rzeh17y3hdxC10F1F HWRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725567316; x=1726172116; 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=T3chJ1T19SwdPfSH8SDlP3tp4ORmuKyqtDERErOcPO0=; b=KAwpTv9KGPLSSZ1951cX6DOVgjiZmUG5OauyPVq85mhrEtSMNoEmfBdsfCtosr8thk Sln3B4woJgzbwI72o948e+MFiSYjcdah7EtOVh6d3RnAQ1vLoNUW6oDOVB37GRZpQOdS Z5PylOGUP5ZytPFH05Jtks/0v/JzhZ1zxH8SnDr8lfgCf0zfZsqEk7zM9L5STtaIKqm1 B7WpcOzDNHOCHD1dQERygwhTdd868Xu78/PQibuyXoJvsqipdz2hoqAfsZQ1L/920j79 IKzst30xeTp6DE6dbTVQWy39ZwsqEP84tIuazRaL7lKU+tGEZEz9Nwq5cfsLhNotWxXP fsFA== X-Forwarded-Encrypted: i=1; AJvYcCXXEdLba0O2TOfPjGUWQaGkcyvZbWPKSF08bwHPXh5ZzsLejrTWAAScnqzXkRE1JwruzgDethMhmF8LuHI=@vger.kernel.org X-Gm-Message-State: AOJu0YzNhKdK00q3VcyajG8ZcpgC5RtGkxvToITt1e2ctr7GaFT/4Di5 17OeeUUJ5vQ7iSgsu8Df8F5U0p/dEI34S0GSOuQ0BEcxUsHgPFW0FCgYnAgD X-Google-Smtp-Source: AGHT+IGJl+Qz+lHLDCHKPe3TKyeEXSQxX/l87XQswQctAW/TH3pYCn3NXMantg917U1RmkuX9eHhwg== X-Received: by 2002:a17:902:cecc:b0:205:7863:2dec with SMTP id d9443c01a7336-20578633103mr180415005ad.27.1725567315706; Thu, 05 Sep 2024 13:15:15 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea68565sm32327075ad.294.2024.09.05.13.15.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 13:15: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: [PATCHv3 net-next 4/9] net: ibm: emac: remove mii_bus with devm Date: Thu, 5 Sep 2024 13:15:01 -0700 Message-ID: <20240905201506.12679-5-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905201506.12679-1-rosenp@gmail.com> References: <20240905201506.12679-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 Reviewed-by: Andrew Lunn --- 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..66e8be73e09b 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -2581,6 +2581,7 @@ static const struct mii_phy_ops emac_dt_mdio_phy_ops = { static int emac_dt_mdio_probe(struct emac_instance *dev) { struct device_node *mii_np; + struct mii_bus *bus; int res; mii_np = of_get_child_by_name(dev->ofdev->dev.of_node, "mdio"); @@ -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 Thu Sep 5 20:15:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13792976 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 C52441A76B0; Thu, 5 Sep 2024 20:15:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567319; cv=none; b=D4FnGUkpFkxCChNslkU7aVENBfgYyMuguC0nax2XHFpLweSAInqLiGH9iDauJ2b1J95rW2XkwsDeFkSb0krCyuc+dFWQ5Fra4eJGjJlXcnH/ISVKrCkRiH1wUp2pdIbpnlLwRnmdDDFnLuZlA+RluM3+Y7+NyUVdTm6LLEcPqGc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567319; c=relaxed/simple; bh=GkYv+8kiWtz4hwfxKF8OeLtk5p6hspiOWUildlsVxtg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VLijRvC8XYKeJeIFLXa9ZHgr6PJrtLosSAnQIaDO+RbnWL/oXvVy0zZqfUy96x0x71CS4+2qya9aQxUvX/M+7fA3B7nV+njI+/QqGncn8/edZx+GrqqQOXlHYaz+UnvfJjYNSj7gu5R8AZLocSvEgN+tHc117zhzLkVpLuNeMQ0= 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=LorUjlkg; arc=none smtp.client-ip=209.85.214.180 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="LorUjlkg" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2055a3f80a4so10282045ad.2; Thu, 05 Sep 2024 13:15:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725567317; x=1726172117; 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=TPUULAONt1B1RbSQ7p1WxcMQIgouuFPwD4mGeO5shkE=; b=LorUjlkgVGFM4gu/6aCC2MuUX4arggVySPpR56KTKaGd2mzTUJy8mAjx0YgAma9s3Q rwnDPT8DUes3PrYXknv9sMbBbLpH9ug+5YswTuGFrhQF+lqggYV/fGqLwr0aaUuGblI2 FW0L8BItZanEHkgfADDT7i90Dl1Vr18rLgTHR3Rre5GUzNDBJz7dnCW9954iYvXAFon1 7eNG7jyWu9xIEoLq6AA6TNL8Q5rH1l480qyTPOaGw++uBirvJBGBb9gE+d5uU/dXIeZZ 1O0Yh5/X6l6VFLLUOrbBew1X5NiXaY+4ypeDbBTaV+zNAaN9RVvpyz/PeUJpRsXaXr5c XCOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725567317; x=1726172117; 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=TPUULAONt1B1RbSQ7p1WxcMQIgouuFPwD4mGeO5shkE=; b=PvxNyWov0oLHhZOTRK0+GywgpKFU6LtvuDpl02NvUxFwwLdCVN9jjvEvYa4ph5/NeU 40l1f3ugFrUUCn6p19dCoieKldRCSaZNFW71Oonmpa7NJkHVTx8VUz8IjbdDkoJpnLMV sDPm938YXUb5c5w/IO8TesjMC4ZM8vPqLT9zps3oeJDwHSP70jahVN7hXXQ+mr+16HxD PwhJJaYJoz5Pqao9W88Vg6AHo3WjWDH68sM0069LkhiXfQ9W3D+Caao+zOK0oeLkEq1t sInPLWnqhKKvAuueb9I3LUi/Zy2JDugtgQPOyxWmRBzXhc9tJgVJ28/YwCv4Ro0QQeBi X8fw== X-Forwarded-Encrypted: i=1; AJvYcCV+y4x/Zg15hB5sgA1fe2RW06ZlWqrUUSWm7PJT9mAcLIw8YctCv0JxiJcKmyf/Jmiu/6K6bxQbOsiosxg=@vger.kernel.org X-Gm-Message-State: AOJu0YzHvJlUi0acj9ZVbbVHiBt6D85DLChjjP6VTXn0ZilKfrY4N5F3 TwzkYrF4lHNJEQsE4XhsdAi2V1PTDSfLMkPMff0+WH2DuflkRq9QS27xRub4 X-Google-Smtp-Source: AGHT+IEc5FimREygWoBU81L3wvd9dFLgOOYGMDyFc67p1PK+yN7KgP9RKw1M2Thdxcwe9Ihgv+eTfQ== X-Received: by 2002:a17:903:1c5:b0:205:8b9e:964b with SMTP id d9443c01a7336-206f0612c09mr2265135ad.39.1725567317022; Thu, 05 Sep 2024 13:15:17 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea68565sm32327075ad.294.2024.09.05.13.15.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 13:15: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: [PATCHv3 net-next 5/9] net: ibm: emac: use devm for register_netdev Date: Thu, 5 Sep 2024 13:15:02 -0700 Message-ID: <20240905201506.12679-6-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905201506.12679-1-rosenp@gmail.com> References: <20240905201506.12679-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 Reviewed-by: Andrew Lunn --- 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 66e8be73e09b..e2abda947a51 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 Thu Sep 5 20:15:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13792977 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.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 1CF771AE033; Thu, 5 Sep 2024 20:15:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567320; cv=none; b=blSDvMLj0BUUzi9zuROjmH0CwNCql2nQ2Pscdn1ZRScTPa0yB3G2CVRkNX8pPnt6OeMZf5aQysb4LCJwOzWMRP3eEZYfJE/VVmnWCF+z+jNiOQPjAIjCHBucenvDo5LnBZtbwN+jnkbQUpS9G9aXQYjyHSS1WwQed7rN4VGlvh4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567320; c=relaxed/simple; bh=bY55F9Yt7ywbbfK3BGmP1sX8m6TqOLVevoO2SJWEKWk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CyH9+NJ6UQx92dk2QVWc7lGj26xOe/G4EAWWl3yh+3+fXA32gVXCxeTS07ICtjSEg1Wk5ucQON63NiI5I1U0EufaFNj56JpiRemDQZLYoqc95mBDqmh23QHCHYKFLD8R1KyVUqpiUvPOzy/LZs9whobe0HoYhnzge9Do5e4qR0c= 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=BKI/uJKX; arc=none smtp.client-ip=209.85.214.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="BKI/uJKX" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1fc47abc040so12413745ad.0; Thu, 05 Sep 2024 13:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725567318; x=1726172118; 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=/rULex6OkOrcFUaHqW8L17Ue37gBcZpzVH/KOfFKPcI=; b=BKI/uJKXgNW7Ud/Lf8OgEvgNJCgbz973wLZ6T7AmEf4X8Hlt6dpzBZYbdAfxQpljUq YOlt2HvqOMRlWWb+7CdaDH3uiwZOfyaq3s3KPpBKz5pnLk+JxQmobi/mbLmgjcfmABNa cuVDCiSz1cbVwOEzEQ9KhvN4SXMIK4U03plbWfx7DuJTQgRwDvx7AGwreVCSesVPnVBE w62K7kVfKgIuUhWyRBW00OvzMxcJau6Cg3aFREhq3CVZhYt7EjtLzzNTDIt4X9h0lCaU n9uB3o05jHwM0mHpSPPdVshwyeBroKvwisT+vJxX8926NWHduFOyzChJt9UElJSmJenD flqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725567318; x=1726172118; 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=/rULex6OkOrcFUaHqW8L17Ue37gBcZpzVH/KOfFKPcI=; b=fX3GAZSzbhNsTVpn+WXfSGNfG8jXP0DrkBaniQZimLT+Aod7aqJ3cmyVxi+euXJnrs AqPaBkAEA7OCiEsALVeiNOp3a+OIvUYWbuxakkxnGnnSkqX7VVBzzsHOuoNnLVCVxjyo iT2X6pYl2kSWcOFx0hIOY7UpMFpnupL+AXjrpEFvg/tFuawcfOwjniMuWEKYE6HlHh1G LNJsKdXa79d2gC+2gZZtcYKttWSlgi3g8QAMCF8MDNhb7NUgX7yuRVyUxUaCxy4CU/z5 MYOJQ5ErXwYZCzUU8ILd3zEmsRPPIMTcHrrDGoW4oIXJ9Nb2GGLj8+elJqleMdZYPbBm Q/aw== X-Forwarded-Encrypted: i=1; AJvYcCWiVZCxTwQ9OhDtAP7VyIldRviVgEe2xQlB5e73tFLf33HyXZXCUcdfkZ85UWfPYA+qCNv+vt7QIEX+NcQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzZvvJVN8VTpDo8sCT0q+67pqPTjTm+JU0ABfmV1m7ZNCForLeV VMUe8k6tpXOCJ4Xe1U6B4WsTT7wLFtHeqYCg5J5jv5fURAtBX6gljN5xvR4a X-Google-Smtp-Source: AGHT+IGjMVbQ4BUa/m/GDRSWNm7+l5K5JMeQLdUNRfHyp3LXx7BgRiHkwexlX03ByRd0CoxYpU5dXg== X-Received: by 2002:a17:902:ea05:b0:206:bdbb:116e with SMTP id d9443c01a7336-206bdbb1e8bmr56870415ad.65.1725567318294; Thu, 05 Sep 2024 13:15:18 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea68565sm32327075ad.294.2024.09.05.13.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 13:15:17 -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: [PATCHv3 net-next 6/9] net: ibm: emac: use netdev's phydev directly Date: Thu, 5 Sep 2024 13:15:03 -0700 Message-ID: <20240905201506.12679-7-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905201506.12679-1-rosenp@gmail.com> References: <20240905201506.12679-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 Reviewed-by: Andrew Lunn --- 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 e2abda947a51..cda368701ae4 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->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 Thu Sep 5 20:15:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13792978 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 72DB41B151B; Thu, 5 Sep 2024 20:15:20 +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=1725567321; cv=none; b=gosGJ9utdDCzKV4R866soMGXy9t1DFEdL14CAvKTWYO4z0PeAwnoU6FNnhfb3X4N+2ivLCYkIKa8QOAFhwhPu5+8XJ2srC1WyHM1Ne2s80yUj5wel0BGsbyVLFZSzRNF621OfNlqgv4crSjl3EG4h+PvCMX1wPxDMh7h7LhpoLs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567321; c=relaxed/simple; bh=Xr08sTFDdEUhabLb2fj+916WPoFxDcgNBGRB6aLUYPw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ao9bJykdxWjk+mdSrJpANH4D7HilrvhwX3A9STalNzyAHqfljCEAwFR4DuEIMKfnj3RUmx1mRATbwZhkAFCyiLB49td8YQ5C5i8YgTly8TF60Ue1BdmMI6H2LbFM9L+Ij+hpShTLSY5DeCmix8SZc1S7sXhwtwLK7sETHxteEmI= 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=l9HCYa2w; 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="l9HCYa2w" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2057835395aso12190625ad.3; Thu, 05 Sep 2024 13:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725567319; x=1726172119; 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=zerd9BuAuSDmlw4ZkhgvIif9TmKF6cW7mi84Axie7a8=; b=l9HCYa2wG5w2if+jIuWzarPrEmk2ta5PWEyUVU/7Azg9IXWuF1oQQNwUB2vi6vocVV ZIKLhFrWuOs7xlE3HyhQZXDrM5RVJPFZY8qbuTbTCM4fBl4HxJ5i56Arg5UUxqzNo+zL sVPYhwRgAQQcJSziRPcJZ1kASkYSdWnJgygZZPE88GCU5MfvzzAe5746wMomL8W3mTJ2 sV5oIFscp9q8NtiwUhjuz2zFU/DnccMQMZtvv9DdioLaPm5hcvNGbihv4stnSAttquFJ imExnEmbQgVnUJ1+zqU2citZyPW3l3Btm3J+SyfkmtCwi+4sl668uaiyOFBGvhhrZdWK u6YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725567319; x=1726172119; 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=zerd9BuAuSDmlw4ZkhgvIif9TmKF6cW7mi84Axie7a8=; b=bB/PbBVWxTz5UCz/F6eJHbdzkBoe89I+wRVuxAhsZ8K9EqCxiJw6zLvGYF9rARpJVT eVHaXDnZqYnxO/RLCnIPBsJ6pdHxot9Z7DO+4nmrgwr23ninOYYEjVxyQFXphzPWSR3O y5/5eCccRLVsx11VjPaw+mlhhslvWn/zdT7FPc3IPQO1Uv3wDggAKW3QvTJYvJNNPPC1 amNnSLdrhvcJuR8ni5ZhT3DvpSmdfNxFc79wbiW1nogvoPqok8IzSg04hBWWcNd2inUg FkmzlzmnK0JbBSNTviebYnoCTz+Ed723mow/eoDS37mUT/kxOsfi94c+CdincLmp3DXn bEtg== X-Forwarded-Encrypted: i=1; AJvYcCV2xbT09YIoT2rxOB3oSoiIYgoiwIOuZuoKsf4dnPokLEi29MYV8SB6WyQgiTNKklL0fC7TT+r1lbAkzrA=@vger.kernel.org X-Gm-Message-State: AOJu0Yy05Aiyd8mIgTjXZgKJ780UByPNliDmOHn9k8/OVFRVgVEfBxwT imyTAi1CYLgCeYVeYqwA9d3yv3aaA3PayMCbMjlarTDyUZ0dDGcocLruv3cJ X-Google-Smtp-Source: AGHT+IGz8a98+V4EvjpFibZaIbmyUzCSwDIt+5aHKEvOtCNhqx0yfKZIODYHUPEbh9nWC/mwWUYXAw== X-Received: by 2002:a17:902:f544:b0:206:b399:2f21 with SMTP id d9443c01a7336-206b3995a0amr72839655ad.43.1725567319603; Thu, 05 Sep 2024 13:15:19 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea68565sm32327075ad.294.2024.09.05.13.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 13:15:19 -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: [PATCHv3 net-next 7/9] net: ibm: emac: replace of_get_property Date: Thu, 5 Sep 2024 13:15:04 -0700 Message-ID: <20240905201506.12679-8-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905201506.12679-1-rosenp@gmail.com> References: <20240905201506.12679-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 Reviewed-by: Andrew Lunn --- 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 cda368701ae4..f4126a1f1fff 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 Thu Sep 5 20:15:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13792979 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (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 C5A2F1B3F0A; Thu, 5 Sep 2024 20:15:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567323; cv=none; b=pvD7izO21w6zyf0qjTu0PmrpKYZFOBO7q3mPFGPSUhTn/oW4BrPU8sOSpfZX+ysj/hQ5CaAoJ4BBqp8PNWBXvrusW1rR2AIDv+EE8Y0sqj/tHBTr2mDsjvCXd2GAnc1eaPQVuDynKnfcxtg9YnX/6Zu03/p9sHs4UMq2ku/GQk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567323; c=relaxed/simple; bh=Izcm9WXuBSSAe9duMn6Eqyxy90GSfOeOTQxkNKg9EOc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OGM7yGHKV9O3sBgw9l7K3Yw87Am/iiiqXG/dTktQ3jQQI/RuOh+w2tsWcqhTua6X0XW1ZPv6xur8ypv04Jy9gg7steFOPvSU4+/++aCvNEKJAyWZcvJTrVxgMDaBS76bIdR2UnR7qHUUZz0iSGorF1ugst4hKudZx6yRjgJE8P0= 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=PFGaNdTE; arc=none smtp.client-ip=209.85.215.170 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="PFGaNdTE" Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-7d4ed6158bcso999967a12.1; Thu, 05 Sep 2024 13:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725567321; x=1726172121; 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=VcjsOY959gV8Wql2beVgE2GRTWuYaOOOZlS0zc4YxNg=; b=PFGaNdTE/TOY2IQqt48vPLOl3fsN9SsX/opKoMU43FPL3g+Rls4ZCQzj2Ysm9MvRXA 9ZbpqLbbZgKV21FJWiulITkdhD9Vqv6D/9iw8nd5IgXrWvr7guEWnlrY6rujvCifBJ0G sVhxihb5M5Wc3qjHe7OQAOFJMKzcc3COgh44ZtIU63BW12q3+9mk4zgVEMWXhH6KV9oK gFvBO1906UeCj109AYPmpq0CsG1RYrYO0+LHgIwdqR9MkZIAWU47wEieTTtT4RQZlhih j+1Clvcr0AsSqeOlzWu5btLXkF1xFFh6FwxGkLs9wHxvt1GDSs8n2wNn/S2RL3Rpl9ob BVwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725567321; x=1726172121; 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=VcjsOY959gV8Wql2beVgE2GRTWuYaOOOZlS0zc4YxNg=; b=ZESd3Qy9C67hLaXbVOvQqvgwFWgsjSB9EcILUGKCkdw52D6lW0CowBoErVuxYlqGtA k8rf2+UCV3SCCV2MarTIJ00C3sY+FHQ9zyXcC3fo9Ag72GXNZ/KScFbsDK/lxuAIp4Kx qMPpLiiUg4aLRAgRRPdCxPj8zemqIwfZ4OxaY+LucvKjfcLGDPS4oxJUPWV600HCjFOx Akw52nDWMrUYoZcqSsOiXfBS91TNhony85aTZUC+nBbRepJDAFy7kKhBzrT2NhhOPE3w mjZKS81bp4x4jBr3T0TjFcYcscFziZ9KbvJ3U1jRhZu0spGZsNCG6corcAgfKoPBdTq1 5vVg== X-Forwarded-Encrypted: i=1; AJvYcCXUKz8Vq2kk24wIw24EtAdbRRo3U+rJ0+cg/CJCqHuHuyx6hCqqai4wY+k0h0MVv3WyBhkxix1Mz1fA47w=@vger.kernel.org X-Gm-Message-State: AOJu0YzfIW2FoIW1Aqw/lDTuVC1EDdN1xGhjVpWSVZImlSh+ct9Whf/h kAqVdNtwkIkjCI5gvbppyCIFYAslpJN+dFGGTVRIQBJsBUYi9NhGxqSU8hYy X-Google-Smtp-Source: AGHT+IGNXUyyf48sKzCqJnaGrN3KvCSxrJAsw+mag1+WvcQRokRgjCibmO6EYfsJ4m3JLa/oPzqIBg== X-Received: by 2002:a17:902:e543:b0:1fb:90e1:c8c5 with SMTP id d9443c01a7336-206f0535d23mr3464905ad.33.1725567320945; Thu, 05 Sep 2024 13:15:20 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea68565sm32327075ad.294.2024.09.05.13.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 13:15: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: [PATCHv3 net-next 8/9] net: ibm: emac: remove all waiting code Date: Thu, 5 Sep 2024 13:15:05 -0700 Message-ID: <20240905201506.12679-9-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905201506.12679-1-rosenp@gmail.com> References: <20240905201506.12679-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 | 55 ++++------------------------ 1 file changed, 7 insertions(+), 48 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index f4126a1f1fff..c643e99e77d9 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,18 +2397,13 @@ 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); 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) { + if (!err) { 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; @@ -3084,12 +3057,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 +3158,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 +3190,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; } From patchwork Thu Sep 5 20:15:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13792980 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 7331E1B86C7; Thu, 5 Sep 2024 20:15:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567324; cv=none; b=Lfm4et+2mz0O+h7slYxysn1Lu0bJv4gU/5PjMCvgDGc1/QPFMSdHBFB88cvScqhRpMs6zYdz/RXaU2KBIm3KvhySg36GV6sejoKO1KUKMFtzPN9QLGb+miOx2xKhyeoIz14rc8XH+2cYCP1zJHCHmRL6z11taqd0ZKzM1frH+9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567324; c=relaxed/simple; bh=BAta9vyXkz+IOZ8AXfVnWSqgq48uBbXOCNT4m7rPOPU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PsjeSKLOQICKu54ETSAQoe8EX+J7q4xR7fQbx7gqjhkX3wmrmjF+UgWPo2QQytKfy09fO+H64+omrHgugWqzhcG1uWTxveAC9f0dVMpUWhHUbqtNc/DlvCXkMwm346DGuGYdNt9btb6P33tRlJ3hHI92/6FC7A4ciFZUIUEPcaA= 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=LprD1eRV; arc=none smtp.client-ip=209.85.214.173 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="LprD1eRV" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-20551e2f1f8so12891815ad.2; Thu, 05 Sep 2024 13:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725567323; x=1726172123; 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=2n5GCIp2Flr7vEEXoglsKwWcYTQQ4pdePaiSU8geOMM=; b=LprD1eRV/PXMw7iSXGvmPSmjAg8UrwctPLXRGCSW2IPdtPCsE9U6Z1sp1DLhl3+3hp wTZDJE4bQYjiX0UNR13DBdb297wLNklCuDTnsX3+Naii9dJurZW2awNCs8oDH+YFr9zK uI4AsTCxsjNv63ywReBjzzrjoP8GR3tDlATaTQvB+NvNY+hkZcSIt8PCrrTVeDAULVo0 yf+pXhHWldGh2pcgPG4KZC1dn+rlUfhNomFPua77w0+W1UgiZyNGsKsCf9n1UZpGzTHh nYfyuk+fQU3aER2jbqHBlVi1w6XkLWOROZ9y2wGDXDu+e8/g2weUYdYEswNe1omoPS2C gRvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725567323; x=1726172123; 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=2n5GCIp2Flr7vEEXoglsKwWcYTQQ4pdePaiSU8geOMM=; b=BtddSMQHzYal5Y+hG4iAcNcQLPjkS3PloFglePkdGLC+EeRvTPrZAJYdDYX6R/MpoQ MXUmI10tTQJvb/yocT2iqZ0decpwKF9q8aCuFyVoqWYHNnoNWkw4COZXvxkaidpILoRm qEoqSjionU6hDu6yRGfVvNdWk+mEKtcR6N/7eOWLPnrEv1sZA3lBje8ijLX3def6AuDV X68xpatjopkfuCL8juec8LMRs9zaII7GpPeNL7KiLdCxe26VwcggeqEcOdu13o17c/CT /82/AiCfQwgncvzfquUUc6e8oMuWIjlRpuYVgGZuY4ERuHTMhH2RoS42fKtVRtMXsMfG jSCg== X-Forwarded-Encrypted: i=1; AJvYcCU9V6MLb0AWNCTwCI7NWC8tvQfKmCVBWBrscj7VBU58TbRvUoCixsDe9YU4aDu3CUC7tCrSYfbLnRlZUU4=@vger.kernel.org X-Gm-Message-State: AOJu0Yz1qWrqWFXtXGyEupO5XG7Vnjwl4E+DnfYpU52Lz9/67jqED3Q8 fKRb6rdVhmhPR5NaI6E3iPKiQ/quldtUw+HdqZW8AVy1RfDHjeH4Uz1/qQY7 X-Google-Smtp-Source: AGHT+IFP/+30VZmnVRxs1vj7LcvedJ/2GNqUznoiDPu5hb1TcaumoCPT3NaVCE72C27BaO4OVrdmuA== X-Received: by 2002:a17:902:f68b:b0:1fb:62e8:ae98 with SMTP id d9443c01a7336-206f04a10dbmr3320345ad.3.1725567322648; Thu, 05 Sep 2024 13:15:22 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea68565sm32327075ad.294.2024.09.05.13.15.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 13:15: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: [PATCHv3 net-next 9/9] net: ibm: emac: get rid of wol_irq Date: Thu, 5 Sep 2024 13:15:06 -0700 Message-ID: <20240905201506.12679-10-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905201506.12679-1-rosenp@gmail.com> References: <20240905201506.12679-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 This is completely unused. Signed-off-by: Rosen Penev Reviewed-by: Andrew Lunn --- drivers/net/ethernet/ibm/emac/core.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index c643e99e77d9..249cb8e78a4b 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -3029,9 +3029,8 @@ static int emac_probe(struct platform_device *ofdev) if (err) goto err_gone; - /* Get interrupts. EMAC irq is mandatory, WOL irq is optional */ + /* Get interrupts. EMAC irq is mandatory */ dev->emac_irq = irq_of_parse_and_map(np, 0); - dev->wol_irq = irq_of_parse_and_map(np, 1); if (!dev->emac_irq) { printk(KERN_ERR "%pOF: Can't map main interrupt\n", np); err = -ENODEV; @@ -3186,9 +3185,6 @@ static int emac_probe(struct platform_device *ofdev) mal_unregister_commac(dev->mal, &dev->commac); err_rel_deps: emac_put_deps(dev); - err_irq_unmap: - if (dev->wol_irq) - irq_dispose_mapping(dev->wol_irq); err_gone: if (blist) *blist = NULL; @@ -3215,9 +3211,6 @@ static void emac_remove(struct platform_device *ofdev) mal_unregister_commac(dev->mal, &dev->commac); emac_put_deps(dev); - - if (dev->wol_irq) - irq_dispose_mapping(dev->wol_irq); } /* XXX Features in here should be replaced by properties... */