From nobody Sat Nov 30 03:29:48 2024 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.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 BBBBF86126; Thu, 12 Sep 2024 02:49:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109350; cv=none; b=dR+zIFz9/cuVQMewXCKdojJ3GFz6tECqYN8KQP7/Nt2mqgRrBeOHlKoB65dDWY1fucL2M6Tk0AgZXHE9C65LCbf+3YwJAutkrEXISqyXmiYGyjC//bPmPFpNGrEyPhU91qQLSaysIRpOK20rj0uyY9GddAWRW9p2P5BtqK/UfAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109350; c=relaxed/simple; bh=aoXk9arIfv3ecnzbz6memLs14hzaDhWaeSs2rtozQkI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h0+xDfqyy1Ihj2L0zWTLTrOkM+Gay/dR9Cr3rqvad1HpPeuee3yiF+NLnB/cUQLL01LqyT/EcDzAzWrIyEfoIzEM1k1TGaPfcaoghfQtslwjJbVQuC+WQY24Ue9xS/MTJzqf9+IRMJeygVm2OVMGKlfLvK+msRdJCUcR0CBdfxM= 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=IwwGieyF; arc=none smtp.client-ip=209.85.215.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="IwwGieyF" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-7c6b4222fe3so310269a12.3; Wed, 11 Sep 2024 19:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726109348; x=1726714148; 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=eXGljPI9SoQttRL3JczIBiwQbDmmnUm1+/a0VChwsQ8=; b=IwwGieyF1uXhYk58p8AHMsUPq3lZeqzV/68LgbtaZ5yNcOVtMrJx157E0+Jug/LFUz yAALCzyQWYxcoLiqEknlBMAXaoSJ6Wtsbbc1WIPn6UI9BiV/QKwE0u8cyy2LA3Lys1Hx pU0tu/SF6T4UPhlYkMdvvvqZi4e6my/KEaCwi/gCVTgSqQ9UaVFy5xAXHbwZhyDtsw8u k3FwPNuJ1yWszFxmGGWsBCIpxFVYXi0gQstEr7driIraIAmkbWTAHoj2vg0IfmLO5/Ne DWwPgoIWvMmLd9V3gXHKiowqCk6tfzNz5QDv+h22ZMbb2xOWEYwgvoN8WvZ7W87rPFK/ qu3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726109348; x=1726714148; 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=eXGljPI9SoQttRL3JczIBiwQbDmmnUm1+/a0VChwsQ8=; b=mtrWB2xqG76LfzBZF3D0mjZlGdBaCc/BQXncHFzvr3mDMavUvQAphsu4DuFP+GTTRe 2UeECjm/ywuvKCsj4CBGmedama4R/ViQI4cWFCHt8tTr+TGF61jEWhgCS8bi0ElETkfs BoQklqSiIRblW3p6qpgLXtGZt4xHRfOfppNJklB1/j9s4RgQCmfxZUKCQ50YgAULLEum mtEGWZB//RIQndL/4WlF6eD8v8nz4xFue5sqHQS7AUTVqTwfIa2uhepW2wdZxZzIFJ47 yjYr2vGpqNddKlLp7kS2KFKHG47ksijK/y5jGO0bCdbhclx9I24WNdUR+adCVcCmEqLz KdIg== X-Forwarded-Encrypted: i=1; AJvYcCUIACSngMQED7IjhagNBM9WTqiYw8q2lPdNowuZEH0cjSG8w5j74tBViQ4f690lIkTroogCaquJzi8zB70=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5acvsDXEvzdvXoAs4wAMK1BveTXLgZjUEbcMA78EocqmMnUPd EnrkAXA3IAkMDyr3RNR1DubY6vvX17jDlTOaJ8MqnYPgozeWNTJvWoI81Srj X-Google-Smtp-Source: AGHT+IFoGD1B7jwJYlF5TCar891eksJRHKY0yIeiCDC9yJVTsnzh7Z9gm7ofQn5vFFNsAPha+u4pDQ== X-Received: by 2002:a17:90a:684c:b0:2d3:d414:4511 with SMTP id 98e67ed59e1d1-2db9ffefa37mr1467150a91.24.1726109347734; Wed, 11 Sep 2024 19:49:07 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadbfe4897sm11457868a91.7.2024.09.11.19.49.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 19:49:07 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: andrew@lunn.ch, 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: [PATCHv5 net-next 1/9] net: ibm: emac: use devm for alloc_etherdev Date: Wed, 11 Sep 2024 19:48:55 -0700 Message-ID: <20240912024903.6201-2-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912024903.6201-1-rosenp@gmail.com> References: <20240912024903.6201-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/ib= m/emac/core.c index 6ace55837172..0e94b3899078 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) =20 /* Allocate our net_device structure */ err =3D -ENOMEM; - ndev =3D alloc_etherdev(sizeof(struct emac_instance)); + ndev =3D devm_alloc_etherdev(&ofdev->dev, sizeof(struct emac_instance)); if (!ndev) goto err_gone; =20 @@ -3072,7 +3072,7 @@ static int emac_probe(struct platform_device *ofdev) /* Init various config data based on device-tree */ err =3D emac_init_config(dev); if (err) - goto err_free; + goto err_gone; =20 /* Get interrupts. EMAC irq is mandatory, WOL irq is optional */ dev->emac_irq =3D 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 =3D -ENODEV; - goto err_free; + goto err_gone; } ndev->irq =3D dev->emac_irq; =20 @@ -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); =20 - free_netdev(dev->ndev); } =20 /* XXX Features in here should be replaced by properties... */ --=20 2.46.0 From nobody Sat Nov 30 03:29:48 2024 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 2D7A4126C0F; Thu, 12 Sep 2024 02:49:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109351; cv=none; b=dY1Mb6rBc/EpIW09k5gcWj+VfxpcdISkYkXlvlVq64wADqWdATtVI/88GokR53Lu8gobkGJLWxgAUpyILTh1pEL7VtfvyjFu4GoiMPjpVKX/xyMObwqbygC8iWlDDLk5HyB5K2yrKbameXC67xCy7JdWBpVhocy/TKjd13EBxbw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109351; c=relaxed/simple; bh=sp7upOnKj9BWAZsQm3OTJSA5cb9EWu67dP5FR9B4uhQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V2oRp5XzR6FUUCk8aYeEGzOBWQ7EWsVk2HBlOy35X6aQHkYxO6bL10GLyAtF1oKhfFLFMAK4/YZGgiESIg597nLbnqCCCSYEdJsWtB+fmRY7fq6IQRm/tWU/GDDzxaPRDMw8fskE6c4dSk2s7R0bycZ5GfvibrTwOSlObQCijUc= 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=RGqnJAij; arc=none smtp.client-ip=209.85.216.54 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="RGqnJAij" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2d88690837eso368346a91.2; Wed, 11 Sep 2024 19:49:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726109349; x=1726714149; 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=n3Oz5YgiTX6XCFX9x34lSE/cTVjBYyM6D2G16QhUEzs=; b=RGqnJAijxjdo8/Kd4SrIvZTe/POI9anZvMdz3GyipEs62WFCiBNYBwKIrLpY/4gDBq JqqenFFyKtMlSJ1R4EfnWGNuj32/sz8CBoTCq+AbuwfoKN1Bn40ggLWGhjA7aaVUO9lK gV3TVZMg4gcfEn1Ykrhd18lBztKfEKXaabe8GcKsittDrtMC8Ybo6EvUknzL8YqQS7ua Cq0p/XuNDz+GmLLQJ0Hk5pvp+ecHZ8iOacH7lodabgjUNxacu6tJYhOWAb3nw+r/Rssj Psa293RSOyhzJ7FHZ2zK7xWyb7OVcmQ1ueMdwO4AdytzdRY8WZPimTrXcIrbVtxr9d8Y Bweg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726109349; x=1726714149; 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=n3Oz5YgiTX6XCFX9x34lSE/cTVjBYyM6D2G16QhUEzs=; b=j7G9hiZdY9DUGxmKGl3F9A23EqDn0LTni+0/jaU1a6XfqcYWvysnHyyqN/mlDbt+OI Zq2Vk96POGSvm51ORUQpfOU5YZ5I4jkwkZ0KGLioN7DF9N+J6T7U8yLpCy53elq5Vs+Z eYTHge91uWdTvLWf5US79je4QBIdqmIWGWkVirl6CuIaaYZiU1eia2USkFGXnzfPs63K mS6CrW4xLn0PAncORzdVqiQsRKtRetrW9XYwlmrcQ2mzLWbVdjMONv2uhQFZpHjvlA/f OPY38JCQZpjA4ls6wk0FyrOs8cBPU/Gf7ulx7RJqyxaPzt1HnP3ppSBI5wSfh4TOef8O jkSQ== X-Forwarded-Encrypted: i=1; AJvYcCXef7V1CmvCDsXkjVZWfOTTULqGXkUcsgD5u8vJhazzecx0kwOGp3KZ7Y6Tkpe5e5fqoLLZvVSoqk79XXQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzG5JcNTCl7grGF9DNeR3i2iweLqHxP24oLjRw2V65xNBIaAGhn sbkfdo3Fs4B6s40MOYrjxVMBgHavYuunD2+Y4E6co045RCZYNiM6CKuNaufW X-Google-Smtp-Source: AGHT+IHnWZN3AMSyuf/njAe1gCegnP+9DEVmh3IonoUthg+YU0l/AxMvBDYDKsxNOmBk/UsHCwKOkA== X-Received: by 2002:a17:90a:d903:b0:2d8:840b:9654 with SMTP id 98e67ed59e1d1-2dba007e059mr1398504a91.34.1726109349122; Wed, 11 Sep 2024 19:49:09 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadbfe4897sm11457868a91.7.2024.09.11.19.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 19:49:08 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: andrew@lunn.ch, 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: [PATCHv5 net-next 2/9] net: ibm: emac: manage emac_irq with devm Date: Wed, 11 Sep 2024 19:48:56 -0700 Message-ID: <20240912024903.6201-3-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912024903.6201-1-rosenp@gmail.com> References: <20240912024903.6201-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 | 29 +++++++++++----------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ib= m/emac/core.c index 0e94b3899078..d1e1b3a09209 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_inst= ance *dev) static int emac_open(struct net_device *ndev) { struct emac_instance *dev =3D netdev_priv(ndev); - int err, i; + int i; =20 DBG(dev, "open" NL); =20 - /* Setup error IRQ handler */ - err =3D 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 =3D 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; } =20 @@ -1408,8 +1398,6 @@ static int emac_close(struct net_device *ndev) emac_clean_tx_ring(dev); emac_clean_rx_ring(dev); =20 - free_irq(dev->emac_irq, dev); - netif_carrier_off(ndev); =20 return 0; @@ -3082,6 +3070,16 @@ static int emac_probe(struct platform_device *ofdev) err =3D -ENODEV; goto err_gone; } + + /* Setup error IRQ handler */ + err =3D 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 =3D dev->emac_irq; =20 /* Map EMAC regs */ @@ -3237,8 +3235,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 +3280,6 @@ static void emac_remove(struct platform_device *ofdev) =20 if (dev->wol_irq) irq_dispose_mapping(dev->wol_irq); - if (dev->emac_irq) - irq_dispose_mapping(dev->emac_irq); - } =20 /* XXX Features in here should be replaced by properties... */ --=20 2.46.0 From nobody Sat Nov 30 03:29:48 2024 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 93A3B13D281; Thu, 12 Sep 2024 02:49:11 +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=1726109353; cv=none; b=gxR6o0Oqz3UZk0sID20O2I9irxnERYvddHSNMNSTG4l/p0FqwlRq1ScyMy/QDMCfQmoRN3FuA9kQ0JEutIvmpHiIglz1xPPFxjrUI90xiughnLjH6QQ42s2sbVrgOqnKlQ3fdM3iTBHwv9K//tFOoPApXxcUdq6wEt2YFdQlYeg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109353; c=relaxed/simple; bh=4417gaXl8FXFi2g8/QrmuQcNe480XU3gPSFGn3wpTpw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OwWQ+90rWaP179E8Glku/HPBpePOixHIluUmPMbCi1XyhFE+nFIeGyBD4I7Ot7K7CLztVJ5XfTNQFK3szga4Wyf9HfLlWkclP6IgX/XdVPE3vKI3TmdBb0QMY+C3XtYLSNisyqFjj0uAWz+IMtHmT5tVg0T9pRxiXNUxJAlxL84= 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=PdY/Gs3H; 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="PdY/Gs3H" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2053f6b8201so4559525ad.2; Wed, 11 Sep 2024 19:49:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726109351; x=1726714151; 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=5CVImb9caOCrRdmt62xCIIDvZ7oEnEcSXvnot+RJZns=; b=PdY/Gs3H5goOw6SE+RkFD7F3LLlYZyOieVLnqCZQ/C6Scm5SmAyW6Lg2nyHZXOkGVN 21GeHQd532aiDhUh3WAima2yLSNk7KHE0i4N2xCPvONP5qqL8tdbTD5LLR1Kuf0rHYYp VkP25gqw9txS6UPaEAKVL6aaqB+Trw5AsnsPqMX4DEaZIUL+0+VdtvGV+/wmy17i9aZR lHCo1Hgp4r0bj74NuqckR9aXln1cxkU+vHRzj3WMXqJa2gJDUG7xy+z3vppXv5iTl3YG 7U+1qIJg0+ro4/804LDCuVS744HwIhx7TqjtJHQSzuwiWUYiR2mDhWMyFZH3ARqQ8lMX QzrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726109351; x=1726714151; 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=5CVImb9caOCrRdmt62xCIIDvZ7oEnEcSXvnot+RJZns=; b=nKRJVB886KN3ftBJxvtkFdCnNMOdD2uKVFcPbSDtjLDbb8yNk81RQI/7W3A0JrtPeQ 59hNhr5Bl9+74puIia1J2QCmIh34ea4Z8fSycxzuQvgJQZ27CNmSryd5qI/OW44GUGgx L3ku7tYzEjGySBFxX+b9G5c38rWwHNKDurv4nYQHTgIlly395FBma7vRNSHci5zj2nb3 8tVGpm+5QcJUxMVGJwwV7xj9X8TR6RMhR8cIySYYBG12hkzWTZEhysezeWqpurbzWT2c DIKV0uaVtKEBp9N6ri3YIos0haZKHQtf0zyexjfLqm2V4gaLC2lKObpeDXL0qJDsnECF q7Vw== X-Forwarded-Encrypted: i=1; AJvYcCVx2pnF+fBGk/yOEyMu9hBHpyQm/GxpEZLp41tFCAfleM7+buE0F9E1ZG9/LZctTH2KSKgzJxVic7FANfw=@vger.kernel.org X-Gm-Message-State: AOJu0Yx0nKGIjOt6XMahvdvU0rKZuVBqbSu8Gr6tKbSaHaFChk0YJdkd BZZ5K/WCjlyMlpieadAet/JzGFn2RtrzuFg34e2Xg4eD80miHdPSGkf4DWvZ X-Google-Smtp-Source: AGHT+IGMXF5l0ACXDWT98fbifi5mLZqeT0xF203cgm/Qisn7bdm18fHEW5xL+SVotrEN6iNLeEbSFw== X-Received: by 2002:a17:90a:4dca:b0:2c9:321:1bf1 with SMTP id 98e67ed59e1d1-2dba0068058mr1565472a91.39.1726109350617; Wed, 11 Sep 2024 19:49:10 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadbfe4897sm11457868a91.7.2024.09.11.19.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 19:49:10 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: andrew@lunn.ch, 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: [PATCHv5 net-next 3/9] net: ibm: emac: use devm for of_iomap Date: Wed, 11 Sep 2024 19:48:57 -0700 Message-ID: <20240912024903.6201-4-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912024903.6201-1-rosenp@gmail.com> References: <20240912024903.6201-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allows removing manual iounmap. Signed-off-by: Rosen Penev Reviewed-by: Andrew Lunn --- drivers/net/ethernet/ibm/emac/core.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ib= m/emac/core.c index d1e1b3a09209..ad361202e805 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -3084,9 +3084,9 @@ static int emac_probe(struct platform_device *ofdev) =20 /* Map EMAC regs */ // TODO : platform_get_resource() and devm_ioremap_resource() - dev->emacp =3D of_iomap(np, 0); - if (dev->emacp =3D=3D NULL) { - printk(KERN_ERR "%pOF: Can't map device registers!\n", np); + dev->emacp =3D devm_of_iomap(&ofdev->dev, np, 0, NULL); + if (!dev->emacp) { + dev_err(&ofdev->dev, "can't map device registers"); err =3D -ENOMEM; goto err_irq_unmap; } @@ -3097,7 +3097,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 =3D platform_get_drvdata(dev->mal_dev); if (dev->mdio_dev !=3D NULL) @@ -3230,8 +3230,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); @@ -3276,8 +3274,6 @@ static void emac_remove(struct platform_device *ofdev) mal_unregister_commac(dev->mal, &dev->commac); emac_put_deps(dev); =20 - iounmap(dev->emacp); - if (dev->wol_irq) irq_dispose_mapping(dev->wol_irq); } --=20 2.46.0 From nobody Sat Nov 30 03:29:48 2024 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 0C265143748; Thu, 12 Sep 2024 02:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109354; cv=none; b=Lx+uddp/BJOGDfA6+7UnXWd0rN8T0sgNRQ2fEN3fW1ab/+IHxj6YegNbxwl+yW7coImlD67AQdzsvEOVnCAm8tGEqUICUrinuJ9oL+6Jm0jPdWdj4XT3okDUHxBHAUfJfzW53TjAzHiqt+/0T0039uYqxEGUI5rmQjv806r6gI8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109354; c=relaxed/simple; bh=/HRFUxqMU8Q5Rbr1ovrH+JLmllMAbcmsBJ2p3nIaJk8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X0foyw6u3EbEqWViOd0PiHbQXljbE397fmFSDO3X9IisWx2R+Zhu8XawIzIJ9LWrI9EsXcptwvEXEI5LUWzsbDFM9dUVRldX1gh7LEvE4T9f0NuMqq8w28jlizD2vTr272NUyqVIriCk5VNQ3qjhpXN/1efxRmKWqX2L18Evfac= 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=GjJpuDX1; arc=none smtp.client-ip=209.85.216.42 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="GjJpuDX1" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2d88690837eso368366a91.2; Wed, 11 Sep 2024 19:49:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726109352; x=1726714152; 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=ARlP6/Q8jF5xtzZpR1qmLezgEPxQWF7QTJCTo4RZeQI=; b=GjJpuDX1djTZbdh8eqZjvmW47nw39WLQ8HIZcZdYBDM3puJ43elZgELCO+c0Po+PDZ jaZmH/8m0l8dOj609Xu6w69x5pC2P9qoCsT46972wgKw0Ti4ZosYORMio3AaEom3+ZKU 0twj5jY1NE2B2CHQAF74i0MxiEfWITLH4nCC4V7HdSBRMIBFNEPWFGe/tKkDUOEZ9OIs tkF7thiuBVljEgvBOWV04mKe3aSNWO8YQctS6NI4UmB6544/RbVUVbHdfxad/LlWK+Yd BNwWuBDdNvtxrvta7l1Rq72b366nRQ+sflQ414Hg2MqsPNwFae6wGjo36Jp75K8Y0WRY VWUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726109352; x=1726714152; 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=ARlP6/Q8jF5xtzZpR1qmLezgEPxQWF7QTJCTo4RZeQI=; b=gmTQQKvT12JTo0qI1Tyrko+TLwid4rin1QeiVrDOH+MRyQQ4KOobdH0G/Rt6giKVMP Tc/MLkp7A0O87XjIYczKYPP8rl1QkVUywmzxZxedPocolYqdsTtdEjl15TEHjkfvCLTM 4GcoTSOFXqs/PxmDoPiqs0q1ydZ8+PVHYSsZk+id7mUtCYK52MZdLntrXsbHB8lplLvM F1NkSEvh8crsNkJhGJNcjwDg5I7+uTWZ1wJgN+5RGCLK29fv0xq013QMwahrNpQhrTE3 gztSChzszoi93wR0hEoSDD1b7krPBKmEyxLLy6wg0R/psfpMMTTgXWYuXt0efnoV52SD pS1Q== X-Forwarded-Encrypted: i=1; AJvYcCWiHl8xTQSXcS2knSCYUWRb+hm80SQA5hb+AnCR492L0pqpJGrMu08VD2ndqqBp0WRskY3qzeTkro7hvGM=@vger.kernel.org X-Gm-Message-State: AOJu0YwGEL7W6ShSJKgqHBnKHcr9haObdhaeXUjwJ3U8mBtf6A/U4PkR 0yPlVLX6SWLLREbBUeOwsLDOIvlMzZCadTb1O5GIC793DThpY/WJz8HHBK+8 X-Google-Smtp-Source: AGHT+IFH6gsCNBEagDsTIs61Iw8ezk3cMUGHP7KQ7Swfn167P84G4NFUM+TtsMWikw720i40Beqzvg== X-Received: by 2002:a17:90a:ba94:b0:2cf:f3e9:d5c9 with SMTP id 98e67ed59e1d1-2db9ffdc386mr1306294a91.21.1726109351964; Wed, 11 Sep 2024 19:49:11 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadbfe4897sm11457868a91.7.2024.09.11.19.49.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 19:49:11 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: andrew@lunn.ch, 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: [PATCHv5 net-next 4/9] net: ibm: emac: remove mii_bus with devm Date: Wed, 11 Sep 2024 19:48:58 -0700 Message-ID: <20240912024903.6201-5-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912024903.6201-1-rosenp@gmail.com> References: <20240912024903.6201-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/ib= m/emac/core.c index ad361202e805..9596eca20317 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 = =3D { static int emac_dt_mdio_probe(struct emac_instance *dev) { struct device_node *mii_np; + struct mii_bus *bus; int res; =20 mii_np =3D 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; } =20 - dev->mii_bus =3D devm_mdiobus_alloc(&dev->ofdev->dev); - if (!dev->mii_bus) { + bus =3D devm_mdiobus_alloc(&dev->ofdev->dev); + if (!bus) { res =3D -ENOMEM; goto put_node; } =20 - dev->mii_bus->priv =3D dev->ndev; - dev->mii_bus->parent =3D dev->ndev->dev.parent; - dev->mii_bus->name =3D "emac_mdio"; - dev->mii_bus->read =3D &emac_mii_bus_read; - dev->mii_bus->write =3D &emac_mii_bus_write; - dev->mii_bus->reset =3D &emac_mii_bus_reset; - snprintf(dev->mii_bus->id, MII_BUS_ID_SIZE, "%s", dev->ofdev->name); - res =3D of_mdiobus_register(dev->mii_bus, mii_np); + bus->priv =3D dev->ndev; + bus->parent =3D dev->ndev->dev.parent; + bus->name =3D "emac_mdio"; + bus->read =3D &emac_mii_bus_read; + bus->write =3D &emac_mii_bus_write; + bus->reset =3D &emac_mii_bus_reset; + snprintf(bus->id, MII_BUS_ID_SIZE, "%s", dev->ofdev->name); + res =3D 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); } =20 put_node: @@ -2656,8 +2657,6 @@ static int emac_dt_phy_probe(struct emac_instance *de= v) res =3D emac_dt_mdio_probe(dev); if (!res) { res =3D emac_dt_phy_connect(dev, phy_handle); - if (res) - mdiobus_unregister(dev->mii_bus); } } =20 @@ -2697,10 +2696,8 @@ static int emac_init_phy(struct emac_instance *dev) =20 res =3D of_phy_register_fixed_link(np); dev->phy_dev =3D 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); } @@ -3265,9 +3262,6 @@ static void emac_remove(struct platform_device *ofdev) if (dev->phy_dev) phy_disconnect(dev->phy_dev); =20 - if (dev->mii_bus) - mdiobus_unregister(dev->mii_bus); - busy_phy_map &=3D ~(1 << dev->phy.address); DBG(dev, "busy_phy_map now %#x" NL, busy_phy_map); =20 diff --git a/drivers/net/ethernet/ibm/emac/core.h b/drivers/net/ethernet/ib= m/emac/core.h index d8664bd65e1f..5a9d4b56d7cf 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; =20 /* Device-tree based phy configuration */ - struct mii_bus *mii_bus; struct phy_device *phy_dev; =20 /* ZMII infos if any */ --=20 2.46.0 From nobody Sat Nov 30 03:29:48 2024 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 805A015381F; Thu, 12 Sep 2024 02:49:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109355; cv=none; b=poWOycfOa8h91ogaOGX9wz8o6Ntov0zYD8wBm56wuM9KX7Ih1pzcyLXbaYaHV1IW9BYIkTZlMkuSRGYo2Xc4eYEKuPq60/PDQRbwslIJ17ZLjYateEWuY26AkeiulAjvn07O6XoVEcnSV0yUJPTr6XQ/IWIV19WV4nhtZCVXOi0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109355; c=relaxed/simple; bh=cQL5yPbQcYe6yme7gcbKAIFuXBiN8YmNK8P5nr9cbPo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o2mPaPEJLuiG0h1sCUqtRC4pVyN0cIpYubz86F6HCtm1B+T02eEKjQmEHALotOBkLDTIZIY3170XbcRBz2YjrsQDME8devgH7BHkLniFv2kp6V4WqUQlHy9BfumWKi4dW6bgiurLVLAroWDkSxG4HtmGZMFqL4rdoXALeqW/9bk= 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=jddS98DK; arc=none smtp.client-ip=209.85.216.49 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="jddS98DK" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-2d877dab61fso319779a91.3; Wed, 11 Sep 2024 19:49:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726109354; x=1726714154; 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=JdM6LajGMTp7t7LfZYUjKJErX6CVQyZIDaz77Lj5L1w=; b=jddS98DK0Pyobm+uMkoe2lQhe5sAwisRDa2DhmhBy9sUzcQwq4F4wHwQllnD2rs2V1 OBVAg4Uob5yvcX22Z4bGEIKdi2HofFu5t4r+sZFQC8d0PbvN/ir6R0LqJxFsxezxhAS5 Z1qZM2BZcLGGeGC2SwUORjvq208Jh7s3JNXLfOZnzisKjsD6q475LnlFTxqpfhQ2Nv9d 2H5ojR8dV8xACZTGFMVobshEV28ighCD1FaUE0tmh1D6D37/Of5cRZuk9S0eFSkVHmI8 RLnfBJyF6pe/gAq+8Q0Zkla100ovT4Y0hA6LuqhJ/gmju7StBCvMma+Tcykp/qpRDbxI ErHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726109354; x=1726714154; 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=JdM6LajGMTp7t7LfZYUjKJErX6CVQyZIDaz77Lj5L1w=; b=j+tkB5qb9g/aP+ZKpJvSxgIkFIeNFkvpCkwjtWw3LRvzxSpgLLEr5T/9oV9OH3fNgA AePQz4VMenJc2m5+dwE4J4NzPiOxG7xscnuOxwVqFUZWA8fexNUplP03a1KmYkZ+uUNX UDDq/gudwQYL3ok1dpNN/C80qjHSWTXGZCxj83LCWIFKr515H0CJ99meVUm5VqlF7SAf KyjYQSz2CWLyEStB94ElSVtOZfq2HEC/m4XW1eDZiv3XAElrC6oIB4LFyUazWmeeUEoa X+HLRG0HZVOab8JQc6EzgoRTD1jsmjz++a2fvwRJTikpMiqV91ErN0NZ29olCCobP9Hc iHFg== X-Forwarded-Encrypted: i=1; AJvYcCUh6qHz8qEy16DRg2R4da+RpRW4mkGu+DRNz5297vqnbxRm77zeBw1dY7arGMBRzpkwHiohagr+3l3tXmk=@vger.kernel.org X-Gm-Message-State: AOJu0YzUB7DeC4/8iw4M/YlrFlCKT655yGztNi0eG6s5SYMjHiRcDQhp M5rF3oaDdMxftY6ZKGRzk9P3IjYdeI1JA69waoY66A/Zy0VhOSQJGIqI/qk+ X-Google-Smtp-Source: AGHT+IHFoUgida2Frn96ClWM1JjgBIz73y8GF76HHUxNIvJ/VpSIEvpi/zTbF8meQnsOXf1MEF0O2w== X-Received: by 2002:a17:90b:5252:b0:2cf:2bf6:b030 with SMTP id 98e67ed59e1d1-2dba007f3cbmr1605938a91.33.1726109353588; Wed, 11 Sep 2024 19:49:13 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadbfe4897sm11457868a91.7.2024.09.11.19.49.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 19:49:13 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: andrew@lunn.ch, 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: [PATCHv5 net-next 5/9] net: ibm: emac: use devm for register_netdev Date: Wed, 11 Sep 2024 19:48:59 -0700 Message-ID: <20240912024903.6201-6-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912024903.6201-1-rosenp@gmail.com> References: <20240912024903.6201-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/ib= m/emac/core.c index 9596eca20317..65e78f9a5038 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -3182,7 +3182,7 @@ static int emac_probe(struct platform_device *ofdev) =20 netif_carrier_off(ndev); =20 - err =3D register_netdev(ndev); + err =3D devm_register_netdev(&ofdev->dev, ndev); if (err) { printk(KERN_ERR "%pOF: failed to register net device (%d)!\n", np, err); @@ -3248,8 +3248,6 @@ static void emac_remove(struct platform_device *ofdev) =20 DBG(dev, "remove" NL); =20 - unregister_netdev(dev->ndev); - cancel_work_sync(&dev->reset_work); =20 if (emac_has_feature(dev, EMAC_FTR_HAS_TAH)) --=20 2.46.0 From nobody Sat Nov 30 03:29:48 2024 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 17CCE126BE3; Thu, 12 Sep 2024 02:49:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109357; cv=none; b=mvLJk+bNQH4WJFBDTh7/7CmzjRlzt0BLshe3tLlknSXXAQR4qHE7Rc6JkvK1vqm96TwzLD5Yr5K+Nu9eWCPOw3/AjJ92+KekKCJwoa9BntSTuM6eOjERh1o9hogWDTezqv4sPiY21oNyyHMU2VGhyGneF7N1vPZQpLwJTa31GRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109357; c=relaxed/simple; bh=49c02I6ZOrgFmFq7qJyVmZB1W60G9Zv7OfWrs3I0gI0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f3NtlpPpxuBPLzHplkz/3PPOHI6lxwMQjZQFS3x1xGJMSaoR0AGdKXwX7PRiHKz/dl0WtVsL2TtIbgxZsyUFs1wCYpSLYT7Nn22DKslZxtZeQGYoyxXBrjPGQEUSYFAymcDWl9+BU2RQkMDF3tlU7IpSQ8JsBHGx0xc28juP8RQ= 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=VEZmJcWP; arc=none smtp.client-ip=209.85.216.54 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="VEZmJcWP" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2d8b679d7f2so400084a91.1; Wed, 11 Sep 2024 19:49:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726109355; x=1726714155; 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=QIQk+mM3AiQJnx01Ed1veGArYkm9ITnlxL8jOGEyZtU=; b=VEZmJcWPVFRqNttkGA5Qb0dXsKlPM4PDsuwecOlmpYQ5Kf41HHdrIlKzKLp9Tn+tVA E+Ui1iF2zknph+jpj65Wr1H3Ifm07fFu//mLOQTGZM9YOZcGrYUgRaRcZV4zA37uJ6i4 p4UQKSqnXi3qyCgwtHKh0r/WeTbVnBnX8UfoG1zgdWacEj75Aq6oNc3KEbEF6DuzPtoJ N+YJ6vVWAe3BhVBcF79Fj6LVvWIjlouVyB8HSw742pDe3E5Q7F31jpJz/Ca2ZJNqUpkd JhFGJftnYHzrEVeWwCqmTel7aaaxoYeAtKGmC0miBjx3pBYGuvKd3bPjV9unGylFGXFM Ozbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726109355; x=1726714155; 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=QIQk+mM3AiQJnx01Ed1veGArYkm9ITnlxL8jOGEyZtU=; b=dnyC5yQ1/SVPXWqAFibHnSmQYRx/+FcSZI1CPY7EZkF7Det5nj/rhjWsuVbEWSNpMX q4hGyX8jvmBofDv8gR8fj1DfbtP4HlpXRYytxIQzQGyJm+sb0Xajkrnwq8sKDSWrvm/h hUgZknHbQBUdlz6BOGrwsXdKwn5GrUfkL4fVUNlAiw8EUzYbHR0UvHmECx903nRShD1u El8QuDmiKWJfISCjUOgsMqyaN9fE1zPtEKtbfY5V5dkrhvWQ4+3UhHG5SA6ju+n980GF qGex9OtUmR3GuBO6E2uL9s6u5Z4Cy0ywjOM76l6pF5Ys/orecH+bVY1i54nhoksAlxKO OQEQ== X-Forwarded-Encrypted: i=1; AJvYcCUon7dZ603eMwl+Xs9i56YLgDV8GY+RUl7ZXVsiZ/MfK0iZKH6jzK9E2BovbLVffVuTPErYbrB5mDEhZtQ=@vger.kernel.org X-Gm-Message-State: AOJu0Ywm3D7QfPA/TkBES8fOocjpoKvOePpH4ut0TJc3oDqcK+5zRQV9 BGjwRg56zSN50VRnLIJYz3ZTZA6coQIvagUsOPhVJOBBflp3KLDzgklzUWmM X-Google-Smtp-Source: AGHT+IFaklKQQrUb/vUWZ4fbgLtNDkiQQs+GXsQPdSCY0aIWGDijON3E4Snxyu1H+Gz2S8IlsS76Ww== X-Received: by 2002:a17:90a:6887:b0:2d8:905e:d25b with SMTP id 98e67ed59e1d1-2db9ff90633mr1620743a91.9.1726109355088; Wed, 11 Sep 2024 19:49:15 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadbfe4897sm11457868a91.7.2024.09.11.19.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 19:49:14 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: andrew@lunn.ch, 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: [PATCHv5 net-next 6/9] net: ibm: emac: use netdev's phydev directly Date: Wed, 11 Sep 2024 19:49:00 -0700 Message-ID: <20240912024903.6201-7-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912024903.6201-1-rosenp@gmail.com> References: <20240912024903.6201-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Avoids having to use own struct member. Signed-off-by: Rosen Penev Reviewed-by: Andrew Lunn --- drivers/net/ethernet/ibm/emac/core.c | 49 +++++++++++++--------------- drivers/net/ethernet/ibm/emac/core.h | 3 -- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ib= m/emac/core.c index 65e78f9a5038..f79481b6da30 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 =3D netdev_priv(ndev); - struct phy_device *phy =3D dev->phy_dev; + struct phy_device *phy =3D ndev->phydev; =20 dev->phy.autoneg =3D phy->autoneg; dev->phy.speed =3D 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 =3D phy->dev; - struct emac_instance *dev =3D netdev_priv(ndev); =20 phy->autoneg =3D AUTONEG_ENABLE; phy->advertising =3D advertise; - return emac_mdio_phy_start_aneg(phy, dev->phy_dev); + return emac_mdio_phy_start_aneg(phy, ndev->phydev); } =20 static int emac_mdio_setup_forced(struct mii_phy *phy, int speed, int fd) { struct net_device *ndev =3D phy->dev; - struct emac_instance *dev =3D netdev_priv(ndev); =20 phy->autoneg =3D AUTONEG_DISABLE; phy->speed =3D speed; phy->duplex =3D fd; - return emac_mdio_phy_start_aneg(phy, dev->phy_dev); + return emac_mdio_phy_start_aneg(phy, ndev->phydev); } =20 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 =3D netdev_priv(ndev); int res; =20 - res =3D phy_read_status(dev->phy_dev); + res =3D phy_read_status(ndev->phydev); if (res) { dev_err(&dev->ofdev->dev, "link update failed (%d).", res); return ethtool_op_get_link(ndev); } =20 - return dev->phy_dev->link; + return ndev->phydev->link; } =20 static int emac_mdio_read_link(struct mii_phy *phy) { struct net_device *ndev =3D phy->dev; - struct emac_instance *dev =3D netdev_priv(ndev); - struct phy_device *phy_dev =3D dev->phy_dev; + struct phy_device *phy_dev =3D ndev->phydev; int res; =20 res =3D 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 =3D phy->dev; - struct emac_instance *dev =3D netdev_priv(ndev); =20 - phy_start(dev->phy_dev); - return phy_init_hw(dev->phy_dev); + phy_start(ndev->phydev); + return phy_init_hw(ndev->phydev); } =20 static const struct mii_phy_ops emac_dt_mdio_phy_ops =3D { @@ -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 =3D devm_kzalloc(&dev->ofdev->dev, sizeof(*dev->phy.def), GFP_KERNEL); if (!dev->phy.def) return -ENOMEM; =20 - dev->phy_dev =3D of_phy_connect(dev->ndev, phy_handle, &emac_adjust_link, - 0, dev->phy_mode); - if (!dev->phy_dev) { + phy_dev =3D of_phy_connect(dev->ndev, phy_handle, &emac_adjust_link, 0, + dev->phy_mode); + if (!phy_dev) { dev_err(&dev->ofdev->dev, "failed to connect to PHY.\n"); return -ENODEV; } =20 - dev->phy.def->phy_id =3D dev->phy_dev->drv->phy_id; - dev->phy.def->phy_id_mask =3D dev->phy_dev->drv->phy_id_mask; - dev->phy.def->name =3D dev->phy_dev->drv->name; + dev->phy.def->phy_id =3D phy_dev->drv->phy_id; + dev->phy.def->phy_id_mask =3D phy_dev->drv->phy_id_mask; + dev->phy.def->name =3D phy_dev->drv->name; dev->phy.def->ops =3D &emac_dt_mdio_phy_ops; ethtool_convert_link_mode_to_legacy_u32(&dev->phy.features, - dev->phy_dev->supported); - dev->phy.address =3D dev->phy_dev->mdio.addr; - dev->phy.mode =3D dev->phy_dev->interface; + phy_dev->supported); + dev->phy.address =3D phy_dev->mdio.addr; + dev->phy.mode =3D phy_dev->interface; return 0; } =20 @@ -2695,11 +2693,11 @@ static int emac_init_phy(struct emac_instance *dev) return res; =20 res =3D of_phy_register_fixed_link(np); - dev->phy_dev =3D of_phy_find_device(np); - if (res || !dev->phy_dev) + ndev->phydev =3D 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; } @@ -3257,9 +3255,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); =20 - if (dev->phy_dev) - phy_disconnect(dev->phy_dev); - busy_phy_map &=3D ~(1 << dev->phy.address); DBG(dev, "busy_phy_map now %#x" NL, busy_phy_map); =20 diff --git a/drivers/net/ethernet/ibm/emac/core.h b/drivers/net/ethernet/ib= m/emac/core.h index 5a9d4b56d7cf..89fa1683ec3c 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; =20 - /* Device-tree based phy configuration */ - struct phy_device *phy_dev; - /* ZMII infos if any */ u32 zmii_ph; u32 zmii_port; --=20 2.46.0 From nobody Sat Nov 30 03:29:48 2024 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) (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 633CD1714D0; Thu, 12 Sep 2024 02:49:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109358; cv=none; b=QQaQHm0xZdAIoKnxT/O+39m0puc6Ls/VJNTF1hPp2YMKNXknav6d+pkLDgyqeCYmDwzMCwDztD/QEpeZMeNnIciwmUJuIeRkGAgzXy5sSirVBEcv3E6G+mJQoNW/qFSa5+B4lv32YOFTwEKHgmFmCU44R8RJQEH2CtMirHkt2A4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109358; c=relaxed/simple; bh=2i2M/OGGqpsddwsJZ9tuwhPH3SSIh30ZP9VSe0uNJAI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i8j/uskK8sgJAc1XZXnbh4MJHrV9i47INeHkKFvtQ1NjI6uhLi7zonQQNfUPC4qzbjtVY8jbATnmmsm/2RsWz2JjY2I+EQd74H4wSy/wxBVwIELgYM1L1SnOjyB0iONLBcqBHSKsS4UO+AmHHIDvicOPsLUOgK6P/5+kP8wbv84= 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=OQRosFMw; arc=none smtp.client-ip=209.85.216.46 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="OQRosFMw" Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2d8818337a5so1165654a91.1; Wed, 11 Sep 2024 19:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726109356; x=1726714156; 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=WKSmeMBI0xqoZ2BrFo0nUluXTJXqB5d/naPVU/Qsaqs=; b=OQRosFMwz1TGhEM26tPtJ28SsUDDx0aKGIKT1AfFON8jVdSFvmQcrzS//yZ4vtXQWT Gn1gRPyKnXnO5kCsV6XN/mPooENyg+HAmZ3Zc8pYVMqokP9jCMaRu4J6JDQd/g3L6rub rGyBS554UK/mPi65J5DaIvElXKBcckuaqlGvzGfMRHUtGsZNyDzWhsrlMvl1bzSnCb7a /n1VIGN1aSSeULe/uekInJRvSx/r71M+CuhagF5mc3IquaAjUK7scrQB9d0CA7l8BCSo pwe+z7UXeg7nXRHjqiMFuwARo3uqWyRHVJYB11FS2LDvppO1BqMrE/eB2eRdiO9hziKZ LVRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726109356; x=1726714156; 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=WKSmeMBI0xqoZ2BrFo0nUluXTJXqB5d/naPVU/Qsaqs=; b=OYuqWbqxoB2Z61AkIBVjtz0Z5wmoK4wCF97339Tsske/qOCOAypG7GR+CpRIo9jTIT Avf9oxQdG4l+rydwXrBGRKHa2ieiliaKiGmqdR3gGIKBKx2s8IVt99sij/jc62POyGwN jxlwCjbV89NU1YvN7iP7JmgME1Dx3G81NFa9c3Ovo01tiAKCT7C/HgTIH6/hEscd7dte IhpMAT1130DXqorwsHS2inpgnXD4SmrrCYrM5kcm7r6J88iWjDmP5YdtX95lLDPoU829 sd7sEuVBHdcwR7E93F9rZVYdvIp2DaDJnFCQKeYuPa6yh6Mc7Q/CqKXE9JbMaH9rAtam mkNA== X-Forwarded-Encrypted: i=1; AJvYcCXY+WJDisiCPeiWZwlxJI2gu19u32D84VKhusn//c5JRTJw+R9yB7zYIU84nwCSLEuneT+m4dA1j0bDqG4=@vger.kernel.org X-Gm-Message-State: AOJu0YzK3vyflEemvsHTAYqAWli1OR3dljmaVeZAOpqhWU6R2Pbqhuoy 5Y30bkGXvGtvpbZiG1ruL2BSqBH6Rq5PCpHXJLLWO3WvL3ZOMTi+yhxDbQmU X-Google-Smtp-Source: AGHT+IGiunGRUyXupyW2k2tPkSpsAEMfalA//U2LOuxp5sEzNuai/K8z1OKUBBLG5nvXeHkcHU+9Xw== X-Received: by 2002:a17:90b:906:b0:2da:82d4:c63c with SMTP id 98e67ed59e1d1-2db6717819bmr12903883a91.4.1726109356639; Wed, 11 Sep 2024 19:49:16 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadbfe4897sm11457868a91.7.2024.09.11.19.49.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 19:49:16 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: andrew@lunn.ch, 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: [PATCHv5 net-next 7/9] net: ibm: emac: replace of_get_property Date: Wed, 11 Sep 2024 19:49:01 -0700 Message-ID: <20240912024903.6201-8-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912024903.6201-1-rosenp@gmail.com> References: <20240912024903.6201-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/ib= m/emac/core.c index f79481b6da30..6556f9b2b48f 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 =3D of_get_property(np, name, &len); - if (prop =3D=3D NULL || len < sizeof(u32)) { + int err; + + err =3D 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 =3D *prop; return 0; } =20 @@ -3301,16 +3300,15 @@ static void __init emac_make_bootlist(void) =20 /* Collect EMACs */ while((np =3D of_find_all_nodes(np)) !=3D NULL) { - const u32 *idx; + u32 idx; =20 if (of_match_node(emac_match, np) =3D=3D NULL) continue; if (of_property_read_bool(np, "unused")) continue; - idx =3D of_get_property(np, "cell-index", NULL); - if (idx =3D=3D NULL) + if (of_property_read_u32(np, "cell-index", &idx)) continue; - cell_indices[i] =3D *idx; + cell_indices[i] =3D idx; emac_boot_list[i++] =3D of_node_get(np); if (i >=3D EMAC_BOOT_LIST_SIZE) { of_node_put(np); --=20 2.46.0 From nobody Sat Nov 30 03:29:48 2024 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 1056D18454E; Thu, 12 Sep 2024 02:49:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109360; cv=none; b=Vsr0H1QJaZcM94dO2fVy4KlGoYbwSqwmmgHzpWoLijn5kIQD2a6bT73MkuHI1MINZ/QTRehXDMK5c4EiTwPOtPqBQICUEk/lmQZYbgsE/M9FAgIub4TUzQLDD1EOSxa33go73HxD0KK4AuUh8pcDE1aSRsjNIPiWZEmhSWDR7LY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109360; c=relaxed/simple; bh=MpKQum0tr3BS9RUq7x1/3dRFKuJ8n1B3Rp374A6OKCg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dRbjeOLiAG0s+q1gpH5el/iLNKfQcbnfxO1MvVCxddaYXYtlFY9qHD/lySvEKRzJA9NrqnsOltfeaDISVHLPL6kkYfIh5peoOvbWB9XUL+yA4OS+2qRV7VvFqtVLLdmkG5Y2iKhxF9LHi4YP//uptin1ehrDfQDGvtqebVyk52E= 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=PFkOecj2; arc=none smtp.client-ip=209.85.216.48 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="PFkOecj2" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2d87f34a650so293398a91.1; Wed, 11 Sep 2024 19:49:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726109358; x=1726714158; 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=HHbY3iXU6oTg8xBbw7cLs3EtU4xaU9OWnxt/k7vTmRI=; b=PFkOecj28E/q0kjUOlVTeJzeOx90LC096Fm7QaBCN/4joIZh0VMAu4jG1rPC2u2pGw DNrRQVLRgyJ6biehDx0q9iLDbLscaZzaFicRTMD/bEf07kOOeEWJCR3RKzMWaqgfAs3N o2ulqkUjqRC5wQoCHJURKniGpZ80Sc9pzy+Lmy1nif4y3Pp4ABLDpHjTzW96deEDx4bD kuDsu1ICheXqNbEQnaOTwnJnN663qkS3cctxsnnJLc4eKWtr4reixCgHZMewb4gg/7dv hdXVoAuDT30HzsFNuaa3EiaWcy9bySHTSxQViBL+tRonaOs8HD0AimyMJaP3hodxbUFX ZcvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726109358; x=1726714158; 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=HHbY3iXU6oTg8xBbw7cLs3EtU4xaU9OWnxt/k7vTmRI=; b=C15C/KBa5WOYc+5YxvImx+szXHpVnGD8C0Ef00xYe3viUfpfpMwIlcpxyIV976+Ddd vonVfwA0u97g1s3JW8LEhfi9ZvtHnsC9nYbPsuuH6G1eu/O3t47IEOX5WDJM6G0lEoWc Y9dWPBK9X6y5oOOMIngj5z7QEEDCx3e+XRkM3rfxEjZKpigWy5dedsr190NdEllRvCKx h9OnZhWYy4gLwPh+EGZWEfGMuTLQpSj0enqwf7VcVLUD+dUUMEm8upFInV7vdllqgWv3 AZv2dnGEbJ/Yzgd8hmhxC+CvrSfBksBetW32VzmRL1nAaf6c4hzwVpVJwWHI4WRNAeNg PCiQ== X-Forwarded-Encrypted: i=1; AJvYcCWJ0lgOUm+zvnnP7dZJwHGTWXq31MLDyE8Yxwe5bn2Gy1TOUDWikphb1pc9eqNyAvfMSnDqS9DSQ7BYGQE=@vger.kernel.org X-Gm-Message-State: AOJu0YwauLLbPj3OyExHZAFYBqwSwXErN/UWatUxsLF8cxxi2d/kQVFH OMyxlxVl6NX8GaXcshqJnQbLdu5K4roLdxhWRh0MPMwFIp54bKsssFdulZEk X-Google-Smtp-Source: AGHT+IFHI+tv4FqYFefd5/J4FcwpjjrphiiIcuVrtRcQN9xJFjQCoJV00A1NFHST+OPRYnYBesqcjQ== X-Received: by 2002:a17:90a:ee86:b0:2d8:719d:98a2 with SMTP id 98e67ed59e1d1-2db9fc5416bmr2016564a91.7.1726109358136; Wed, 11 Sep 2024 19:49:18 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadbfe4897sm11457868a91.7.2024.09.11.19.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 19:49:17 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: andrew@lunn.ch, 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: [PATCHv5 net-next 8/9] net: ibm: emac: remove all waiting code Date: Wed, 11 Sep 2024 19:49:02 -0700 Message-ID: <20240912024903.6201-9-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912024903.6201-1-rosenp@gmail.com> References: <20240912024903.6201-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/ib= m/emac/core.c index 6556f9b2b48f..60c4943ca09d 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); =20 -/* 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 ni= ce * 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]; =20 -/* 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_insta= nce *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 =3D 0; emac_rx_disable(dev); @@ -2378,7 +2367,9 @@ static int emac_check_deps(struct emac_instance *dev, if (deps[i].drvdata !=3D NULL) there++; } - return there =3D=3D EMAC_DEP_COUNT; + if (there !=3D EMAC_DEP_COUNT) + return -EPROBE_DEFER; + return 0; } =20 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); } =20 -static int emac_of_bus_notify(struct notifier_block *nb, unsigned long act= ion, - void *data) -{ - /* We are only intereted in device addition */ - if (action =3D=3D BUS_NOTIFY_BOUND_DRIVER) - wake_up_all(&emac_probe_wait); - return 0; -} - -static struct notifier_block emac_of_bus_notifier =3D { - .notifier_call =3D 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 =3D dev->mdio_ph; if (dev->blist && dev->blist > emac_boot_list) deps[EMAC_DEP_PREV_IDX].phandle =3D 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 =3D emac_check_deps(dev, deps) ? 0 : -ENODEV; + err =3D emac_check_deps(dev, deps); for (i =3D 0; i < EMAC_DEP_COUNT; i++) { of_node_put(deps[i].node); if (err) platform_device_put(deps[i].ofdev); } - if (err =3D=3D 0) { + if (!err) { dev->mal_dev =3D deps[EMAC_DEP_MAL_IDX].ofdev; dev->zmii_dev =3D deps[EMAC_DEP_ZMII_IDX].ofdev; dev->rgmii_dev =3D deps[EMAC_DEP_RGMII_IDX].ofdev; @@ -3087,12 +3060,8 @@ static int emac_probe(struct platform_device *ofdev) =20 /* Wait for dependent devices */ err =3D 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 =3D platform_get_drvdata(dev->mal_dev); if (dev->mdio_dev !=3D NULL) dev->mdio_instance =3D platform_get_drvdata(dev->mdio_dev); @@ -3192,10 +3161,6 @@ static int emac_probe(struct platform_device *ofdev) wmb(); platform_set_drvdata(ofdev, dev); =20 - /* 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); =20 @@ -3228,14 +3193,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 =3D NULL; - wake_up_all(&emac_probe_wait); - } return err; } =20 --=20 2.46.0 From nobody Sat Nov 30 03:29:48 2024 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 614DE1865ED; Thu, 12 Sep 2024 02:49:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109361; cv=none; b=Br6l5Z7cW5pZzW0C9a+a8TaYoPhF1Qc89Q4KhI6/DDo61cTRAQDjOCXjLcfZAITv85tYhmZPlyfgvTwcT1Y5DiajvK4jCv1DR43mIJyNiZDiNFjQPxvrQZHnTBKNotx5pDbN4cyR1/3ES+SgC5q3Q9OZeUHZZjh4bEfriXij+aw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726109361; c=relaxed/simple; bh=YuhkxiKelW07zOkVj2Rxf9p0M25KQ7Taj3/ZESvg2ac=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PTwC/p387P8XxnIcaSqiV62ZD4iZgsj/o5p1gbsWTOHrWYsPM/FdnbcZKnvBkRZxV0sxgX7E+92cN/X6BD5El/K51o5RNV2YDPip77UKsV8AVxrX/tF/wkceZ9ZMaocPYFJ0gVbNrnLq56KMtQSTp9VVV23eGaKfp+QD4JohSss= 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=AW5Km/b4; arc=none smtp.client-ip=209.85.216.54 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="AW5Km/b4" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2d8abac30ddso384305a91.0; Wed, 11 Sep 2024 19:49:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726109359; x=1726714159; 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=wlsJzSA2eH+FC3sZW03rQKJ3IOa/GsfL6MLaSKHuklI=; b=AW5Km/b4TiEYcueoxiesCxndyyflu5xgX+gbjbkyi+wE2cP40ljhv934dvqw4nIPOb iU0PMFrhWCpp/7T3pTeGxqiYyf3rsSnl3S5mSuk0fTEWL/88zmo6IGzRj2K+UUyMX1Cv 5ogTGy1D92j9uReYg2dgK54Dunn9BB0WANt/OtsHdn5H5vVuhmmmkd6UMYuu7FmIiNju Ke8RfTbUq555JLsGOkSqjYdSilVIBI70NHfdFZ5d6Xk+wpv2XZPsPfjwodds5+5R1r1T 38YqDKGFJECTB3QnoPxdFmNeLHYBKsV8iTOpb/uwJIQjRrdz9uPocDzZlcO/iDUUQVpm DvHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726109359; x=1726714159; 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=wlsJzSA2eH+FC3sZW03rQKJ3IOa/GsfL6MLaSKHuklI=; b=U3mzl1IKS51mk3zVlr1UntifXcWrEz6/Qj8RjTdBY2QLUxVWpTKnmswUI5jr/KL6I6 IaF94lc8FTvuG02beJrJYpaAatYvFXyy7tz1qTMuPgRxH0m+QrmF7WnzOpkUWEyjOfw3 L9SMvy1EE66rDKZ7eKfkLuGn5dIo8tnEcpsXLn9FxbIt98kW480dGMxCopwAT7YpMi/T pkL3CSBWDBi7JVMKkZEyef9hyTDMyeVKgX0vFCvNRLBDXvckH0XejkV2HktWBDTsfYE7 zcb6o1qbFpUy90OMQ8imo+mmJWBRDwP0Pmspe3VzU1fegIIQaUvBmcqEazHGOKcSWJCo LF/g== X-Forwarded-Encrypted: i=1; AJvYcCXLNoZxczs0eWBSLWwepVNyMbO3VITmAC5jfGuJtRL0pyfQJn1hB2TMGsQBfu9VyvX+mwISmDaeIwxSfGA=@vger.kernel.org X-Gm-Message-State: AOJu0YxOAmlBGcN+YDROwTrLtCTF4THauZW1oZg/TEX9qN3Lz0W/LACD UmddEDmU0vwOYkNHis/Kv06mMojpiyGwyDWgM/eFxgHIwNkC+R2tHqY2hbQG X-Google-Smtp-Source: AGHT+IFq4uLyJF+fHCXrCU6xczE4PGO7pby5jjXU+wmJ0XNIt4G6GnyJcM6GpJxvFWJaoQJB2uvfVg== X-Received: by 2002:a17:90a:c28c:b0:2d8:7a54:51a6 with SMTP id 98e67ed59e1d1-2dba007dfc2mr1576106a91.33.1726109359598; Wed, 11 Sep 2024 19:49:19 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadbfe4897sm11457868a91.7.2024.09.11.19.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 19:49:19 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: andrew@lunn.ch, 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: [PATCHv5 net-next 9/9] net: ibm: emac: get rid of wol_irq Date: Wed, 11 Sep 2024 19:49:03 -0700 Message-ID: <20240912024903.6201-10-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912024903.6201-1-rosenp@gmail.com> References: <20240912024903.6201-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is completely unused. Signed-off-by: Rosen Penev Reviewed-by: Andrew Lunn --- drivers/net/ethernet/ibm/emac/core.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ib= m/emac/core.c index 60c4943ca09d..dac570f3c110 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; =20 - /* Get interrupts. EMAC irq is mandatory, WOL irq is optional */ + /* Get interrupts. EMAC irq is mandatory */ dev->emac_irq =3D irq_of_parse_and_map(np, 0); - dev->wol_irq =3D irq_of_parse_and_map(np, 1); if (!dev->emac_irq) { printk(KERN_ERR "%pOF: Can't map main interrupt\n", np); err =3D -ENODEV; @@ -3055,13 +3054,13 @@ static int emac_probe(struct platform_device *ofdev) if (!dev->emacp) { dev_err(&ofdev->dev, "can't map device registers"); err =3D -ENOMEM; - goto err_irq_unmap; + goto err_gone; } =20 /* Wait for dependent devices */ err =3D emac_wait_deps(dev); if (err) - goto err_irq_unmap; + goto err_gone; dev->mal =3D platform_get_drvdata(dev->mal_dev); if (dev->mdio_dev !=3D NULL) dev->mdio_instance =3D platform_get_drvdata(dev->mdio_dev); @@ -3189,9 +3188,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 =3D NULL; @@ -3218,9 +3214,6 @@ static void emac_remove(struct platform_device *ofdev) =20 mal_unregister_commac(dev->mal, &dev->commac); emac_put_deps(dev); - - if (dev->wol_irq) - irq_dispose_mapping(dev->wol_irq); } =20 /* XXX Features in here should be replaced by properties... */ --=20 2.46.0