From patchwork Tue Oct 1 21:21: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: 13818773 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.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 5FA471CB32B; Tue, 1 Oct 2024 21:22:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727817729; cv=none; b=MMU/+2BYl3x1x/TAvL9hyW52OJzO+W8JrR0PaYduuMs+ah4eUsf3HHTr4RXT1LkKGRisiWqVjNKE6FSX2T22RnDPXl8yvhZq5B7jlmWMPXRZSokdKkucFfgXQjQ+6Ayz8A2zZn+tEyTs/MJePSKG0QY6EIg5yBIFw4hbysyCyco= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727817729; c=relaxed/simple; bh=hhklg4yLt1h2Wz9df0/FTZACN12RjqBc1AxUO/gxZoM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R+Y2QDerXpKibnSXkVmCrRHMus/60xTa8E8L4MpPL+uVw7GaAOWAjJTlazYVhQArNV1ULO2WC+Um8S0NQISUnf5S2lSL+lHSEI7zYiMlg/1aoeTXBQ9fVTI4NvCrgiupdOayFds+TJMATmBJlh0uXL4VgfUMQYentjAyqkaM6H8= 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=io/Ed1Xe; arc=none smtp.client-ip=209.85.215.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="io/Ed1Xe" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-6e7b121be30so3992607a12.1; Tue, 01 Oct 2024 14:22:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727817727; x=1728422527; 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=GlKzGJWvIyH1JxaQcaFoiD0eGzn+zzbstxcpO0iRkjg=; b=io/Ed1XetD8O8/LgxKhm67UYB2Whd0aL5EudYK+zlDVrtO68HClzmz8p9A0+O/ee1F rZd21srS6lrQL2X6D2L1o77eztV2UEyvYml2lMbV72oLFYRKROb6teDkLFcMdxJ2DS4t w/ehl+5rgQnoH6lNoRjg98s6gXFf8UVHBhRjyB0kTIekbtX/hLSJwkah441y8OyC8fed 6zs8P6pMzBZk4wSxVPUCpmxp8yC0MVyfHjDFpdgPSA3jZ56EEd5JLyuDBJ5CAsHBSUxp lhPCHxy8j+dtIv6juO+ai+WV5K5DiAlH608Mz41XBGb67H0ANnWcMRUUVba7OAQ1m+rA wuJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727817727; x=1728422527; 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=GlKzGJWvIyH1JxaQcaFoiD0eGzn+zzbstxcpO0iRkjg=; b=lvCGDKdINnWGYArmxT8ilsSdyBLPivPGUDzRU65xfUhHaKWE706B64LsVVGlTc6riv hsVlko+3EWHlvF5vakvxBE5rRsULQ+F7kRjNpjEd1WDXl93Fp5m333TqDpA9FcwYZMm6 IJdC9HpOxvX9DZZuvw06fuukM8kjr0SiJuXApvCDLE7CZ5tsDz9pXURXs/kJlg0ZjkjN 6cQogyhHbiDOh8LSqFgffNiSfsJGnN6fm8P7L1dmDsHzAFeKL8UuNZ9QnoWpHfS4jenx W/twTQiiL/fkbWa8JGhcqA/YoPJxY775kssNDwIkpLJMohwyR2HtxJ99xep/Qs/NlD3X 8wIw== X-Forwarded-Encrypted: i=1; AJvYcCVtyLMklC3I6jf2GFYS98GI4HwLrDILO9KHPACQx8gmvSNokkGs0MJZ8Bgb2xPrLljee0BlTGQ6WlwTyrE=@vger.kernel.org X-Gm-Message-State: AOJu0YzE3G/Iulljhd/j1hCZnXjC9B/MpDfg2IaMpQpcnpZbucq+LjyN A8PmfUmfR7RsDSGJjTydXspCdiLPgmFgCiLlLkzy5i/QdbWdKwB4ed9p0gUW X-Google-Smtp-Source: AGHT+IFhK7D9yDpogVQahtIKWfZLfTQBY22duKUPmp61hLbcecssFRAvC0kA9V2+uVlB+baYEhBFpw== X-Received: by 2002:a17:90b:20c:b0:2d8:da35:b4d6 with SMTP id 98e67ed59e1d1-2e18466dbf5mr1225247a91.14.1727817727531; Tue, 01 Oct 2024 14:22:07 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f8a731asm47144a91.34.2024.10.01.14.22.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 14:22: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, claudiu.manoil@nxp.com Subject: [PATCH net-next 1/6] net: gianfar: use devm_alloc_etherdev_mqs Date: Tue, 1 Oct 2024 14:21:59 -0700 Message-ID: <20241001212204.308758-2-rosenp@gmail.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241001212204.308758-1-rosenp@gmail.com> References: <20241001212204.308758-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 There seems to be a mistake here. There's a num_rx_qs variable that is not being passed to the allocation function. The mq variant just calls mqs with the last parameter of the former duplicated to the last parameter of the latter. That's fine if they match. Not sure they do. Also avoids manual free_netdev Signed-off-by: Rosen Penev Reviewed-by: Maxime Chevallier --- drivers/net/ethernet/freescale/gianfar.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index ecb1703ea150..b0f65cdf4872 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -475,8 +475,6 @@ static void free_gfar_dev(struct gfar_private *priv) kfree(priv->gfargrp[i].irqinfo[j]); priv->gfargrp[i].irqinfo[j] = NULL; } - - free_netdev(priv->ndev); } static void disable_napi(struct gfar_private *priv) @@ -681,7 +679,8 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) return -EINVAL; } - *pdev = alloc_etherdev_mq(sizeof(*priv), num_tx_qs); + *pdev = devm_alloc_etherdev_mqs(&ofdev->dev, sizeof(*priv), num_tx_qs, + num_rx_qs); dev = *pdev; if (NULL == dev) return -ENOMEM; From patchwork Tue Oct 1 21:22: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: 13818774 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.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 A3FF11CEAAD; Tue, 1 Oct 2024 21:22:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727817731; cv=none; b=KXq7yxeiKHFRG3KOYTzncud3zAZnCQ8JneyzfxxZVCQ9WFpfNmRbpJD0jkhu0Z6d6Yc2iurcNchX9f+t+mdl5wi0RseMrMXqqma9+ld5//A8zDeaJ6ylSmbj3JPReAPWGU/t/U4shMzKjT8lDL8ZSxaHgUfQhpNRC8n+SYlKQp4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727817731; c=relaxed/simple; bh=9Q5agciWdA2H/WJ7vJSOTUGmr/gveKXGkvwR3V8N9XU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZUNIlq9Co9I5MCFd8ZkKm2fj1sESiqxSXBTAMuWUys4Y/nYks9X+6jbi0D99jFpxgOHnNa5kXaLzySWeO8sKH21Cv6Ns7eJbbcXk46kl6E8zTQZTESedd+ISVo6NZKhb+bclXuaBYgWySwl3/VmflE2vm7Nj8jQTZwIGwURJTv0= 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=i2TstskJ; arc=none smtp.client-ip=209.85.214.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="i2TstskJ" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-207115e3056so53283535ad.2; Tue, 01 Oct 2024 14:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727817729; x=1728422529; 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=Cf6XPBJXsV3C1pdORRthVZYcFYNc0YmjoVi/+fynFic=; b=i2TstskJ7N8+8NsafPjtJFWGEBjOlGlS4NSvWTw+H5WrPnnWstPHFJtSLI6i3rJzUo I+K6/wjm+YhCAh+YwwUZLwmpVSR+ZJ4lrCTCCaJkmUdfPXDeDcGGkSOvrFfcygwtmyRx D3KPH479ybiL3j+IUntd6UF4+L2qYGg9HWkXWqYMelP4hj+ioKPAHlgLuP87N2H7f3+F NL/ULia4wxeLoF70BnfGWr6zoga5gAwPddWdxa5IgZB4OcjevSq4FVfIQYPi0/zDmX7f iHVfiPIaiDReB6UwO7jxD8LD9GgRRhcG3Yr/343B4NuACxU6ATv+zN7M/JCefqxiliRl UX5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727817729; x=1728422529; 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=Cf6XPBJXsV3C1pdORRthVZYcFYNc0YmjoVi/+fynFic=; b=pIMI/VT6kbPNP+hR6OkQ172zA9paRjdCW7GqGAzHJw7i66bndKe5cW0v3BTrgtCU6U qNSCjeDDLCbqbHC6aT45ohbxvJBEzrjP38BuaNsvVuyofPig1gjpuZVairxaNmvry/EF 3E9f+6+McZ4FTSGHPbUmlZgVq+mCmSztCqCEqhYH7RwaXTbgGnB6vwShz8ZS1Fb0Bmvc qE+TyhUlhfWibIWuwwxQ3fPxYTzElNSizeow6DAijER+vJJzMJ2WYpnVQCF4Gro1Gywv Eyp7NGR+tK4BBmzy8C5sobHvxl7LcUGT+1yc9BrODcIpaY+KraUi6pgC9kaa2/kw0ij1 BW0A== X-Forwarded-Encrypted: i=1; AJvYcCWHoivBaDVnhpBGz4gK7p/p28XXm8Sdvv/q+hfs5mts8rg8hRmAJcn/KXhUOoScZIWdTsp5chyZxY7MY10=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5mNmiiTtPsLpTiuu/OmKv013bD7VWWNnuto6x1gvwb5nUm0kU 8Gcq+Kl9gOUbYUM74mAbAb1uC9D6SKTKKH1D/WfT3w26H2Gw5kgMo4Nwjuo4 X-Google-Smtp-Source: AGHT+IE1gh4CPWQ9a7myNbF/0/fAZ7oWNfd3eupBEgKmKOPkijAW4+43Ffa8jr8XzPDqLPg2UMSwYg== X-Received: by 2002:a17:90a:62c3:b0:2c9:6cd2:1732 with SMTP id 98e67ed59e1d1-2e182cad975mr1248967a91.0.1727817728818; Tue, 01 Oct 2024 14:22:08 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f8a731asm47144a91.34.2024.10.01.14.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 14:22: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, claudiu.manoil@nxp.com Subject: [PATCH net-next 2/6] net: gianfar: remove free_gfar_dev Date: Tue, 1 Oct 2024 14:22:00 -0700 Message-ID: <20241001212204.308758-3-rosenp@gmail.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241001212204.308758-1-rosenp@gmail.com> References: <20241001212204.308758-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 Can be completely removed with devm. Signed-off-by: Rosen Penev Reviewed-by: Maxime Chevallier --- drivers/net/ethernet/freescale/gianfar.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index b0f65cdf4872..9f0824f0b2d1 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -466,17 +466,6 @@ static void unmap_group_regs(struct gfar_private *priv) iounmap(priv->gfargrp[i].regs); } -static void free_gfar_dev(struct gfar_private *priv) -{ - int i, j; - - for (i = 0; i < priv->num_grps; i++) - for (j = 0; j < GFAR_NUM_IRQS; j++) { - kfree(priv->gfargrp[i].irqinfo[j]); - priv->gfargrp[i].irqinfo[j] = NULL; - } -} - static void disable_napi(struct gfar_private *priv) { int i; @@ -504,8 +493,8 @@ static int gfar_parse_group(struct device_node *np, int i; for (i = 0; i < GFAR_NUM_IRQS; i++) { - grp->irqinfo[i] = kzalloc(sizeof(struct gfar_irqinfo), - GFP_KERNEL); + grp->irqinfo[i] = devm_kzalloc( + priv->dev, sizeof(struct gfar_irqinfo), GFP_KERNEL); if (!grp->irqinfo[i]) return -ENOMEM; } @@ -818,7 +807,6 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) gfar_free_rx_queues(priv); tx_alloc_failed: gfar_free_tx_queues(priv); - free_gfar_dev(priv); return err; } @@ -3361,7 +3349,6 @@ static int gfar_probe(struct platform_device *ofdev) gfar_free_tx_queues(priv); of_node_put(priv->phy_node); of_node_put(priv->tbi_node); - free_gfar_dev(priv); return err; } @@ -3381,7 +3368,6 @@ static void gfar_remove(struct platform_device *ofdev) unmap_group_regs(priv); gfar_free_rx_queues(priv); gfar_free_tx_queues(priv); - free_gfar_dev(priv); } #ifdef CONFIG_PM From patchwork Tue Oct 1 21:22: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: 13818775 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 CC7E01CEE92; Tue, 1 Oct 2024 21:22:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727817732; cv=none; b=eMg6qDP7zEKKIBnkTUgFsPsblRKQrqMkMzKBKStwYJMUEN7ULJHsrMfTDofqaOJ8DtZlKMxtvxpVXklkieGCW3LeWCTFymnd4oV2VrEAeqy8R08Cb3CV4COF8vb6PuIsxS+eT6G7b4vfpPotIXYKlPoDJGaypjxmvDHBofeFaQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727817732; c=relaxed/simple; bh=4bvbj6hyND3H9ZiJGPMA/wt3pdXVll77E089pRZgFIA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=coxNfjhYJ5IneQddFThZdZCNSCp+yAdxENWFOdtVHbgfEf0BT8wtkUaGUQRoL3Y5S23NoARrbyHZgORQMnJLNlJa+24IAKF48NqR0Ie/HtlxL0DRe4kURKEWfNESsbq37LQHcKWg/0JZSvcsOX0f2K3Sw308WVBOrYp4HKz8gtI= 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=LoD9Tsru; arc=none smtp.client-ip=209.85.216.47 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="LoD9Tsru" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2e09d9f2021so4031763a91.0; Tue, 01 Oct 2024 14:22:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727817730; x=1728422530; 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=2lztIAy9xf7LQ0hu6hXNHnpiCKulbigvMb5PRXJdlzo=; b=LoD9TsruAY54wptLwSMFQOIvGWrZrKYlbLpiQQh5vhrYjvXHXwY7MeY9zwpzpu5sJP 2zTRSFik7H28Ok6l9XO1Xio7nxU1q4OToZGf/kTFeBfJsZfAMFtlWf0bcZFPu8VNNA6O 10lWBkXYatgfiLK8GlcVY24hJoJKk6utSKry/JCQRGucb3ot/vVwRIfvvHZhCXr7bX7E uIoIMUalbx0l1tG98EG7ktAuBSe5hVLrNi/oQZxE0cu5Il709916gMG/oPOIQKzK81vo aTOoantOgbDMnyaXcuHdtWzOjatviws0CB4N9Z5FmFRZ32a/N9AUoJ1IWGo48NF/VbNN Uzzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727817730; x=1728422530; 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=2lztIAy9xf7LQ0hu6hXNHnpiCKulbigvMb5PRXJdlzo=; b=XYIYtCYM6ORJyaktoLXg2T5selWqqYRsuX+FBgxH+QCrszY4mghvIYgWyENmoq5vUl 5fG2J1RXGaFekw0wV3DLpoyhJH0KwAzoPa3q07c9Q9EIsYck02HlEBMxcqgsOTNPNThz 1DWuZQ25PIoXjLN7zPWB8gHFYWqTb0rwrZO1H0bf8pbHHrkvIDZ6uHlo/au0+WC4xooG GRWqsibmr4zDdUGIR4oO1pRl4OriBIYClZNTlND0biDJMyPFJogqjs2S4WWLsWDeba6Z YTrkaT+GRFxCRAfgTONXYhbSA8otx8K/H25peu3W5dZ+vXmAP1+yIQ+l3ob6B/T8IUU2 TNVw== X-Forwarded-Encrypted: i=1; AJvYcCXmyUp0h0pAGosO9OFvMWEjt7zhtEjPOsMaR7FB8vvrpHbjEt1wctN7PFlXk/HvLXdrzjKYuNcnjvj84T4=@vger.kernel.org X-Gm-Message-State: AOJu0YyekW3Odva/teOkSSirqNP8B5U2LnsM4ieK3ZEy8lH3rrIBRAfT 7IwN8zRBrTRzMK11hZDL02t1vNVlDkb8egxb9Ow9Ypu5S8o3eEW062dzEhJJ X-Google-Smtp-Source: AGHT+IHHVe8QgwY+tXSw3a/mEp9ukaVxz27NO6vBfDPMrusy/XW3XUexpl+ih3SfeBhgHVjHk2sTmw== X-Received: by 2002:a17:90b:3a85:b0:2c9:df1c:4a58 with SMTP id 98e67ed59e1d1-2e1846a6a16mr1309626a91.23.1727817730075; Tue, 01 Oct 2024 14:22:10 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f8a731asm47144a91.34.2024.10.01.14.22.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 14:22:09 -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, claudiu.manoil@nxp.com Subject: [PATCH net-next 3/6] net: gianfar: allocate queues with devm Date: Tue, 1 Oct 2024 14:22:01 -0700 Message-ID: <20241001212204.308758-4-rosenp@gmail.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241001212204.308758-1-rosenp@gmail.com> References: <20241001212204.308758-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 There seems to be a mistake here where free_tx_queue is called on failure. Just let devm deal with it. Signed-off-by: Rosen Penev Reviewed-by: Maxime Chevallier --- drivers/net/ethernet/freescale/gianfar.c | 38 +++++------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 9f0824f0b2d1..66818d63cced 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -412,8 +412,8 @@ static int gfar_alloc_tx_queues(struct gfar_private *priv) int i; for (i = 0; i < priv->num_tx_queues; i++) { - priv->tx_queue[i] = kzalloc(sizeof(struct gfar_priv_tx_q), - GFP_KERNEL); + priv->tx_queue[i] = devm_kzalloc( + priv->dev, sizeof(struct gfar_priv_tx_q), GFP_KERNEL); if (!priv->tx_queue[i]) return -ENOMEM; @@ -430,8 +430,8 @@ static int gfar_alloc_rx_queues(struct gfar_private *priv) int i; for (i = 0; i < priv->num_rx_queues; i++) { - priv->rx_queue[i] = kzalloc(sizeof(struct gfar_priv_rx_q), - GFP_KERNEL); + priv->rx_queue[i] = devm_kzalloc( + priv->dev, sizeof(struct gfar_priv_rx_q), GFP_KERNEL); if (!priv->rx_queue[i]) return -ENOMEM; @@ -441,22 +441,6 @@ static int gfar_alloc_rx_queues(struct gfar_private *priv) return 0; } -static void gfar_free_tx_queues(struct gfar_private *priv) -{ - int i; - - for (i = 0; i < priv->num_tx_queues; i++) - kfree(priv->tx_queue[i]); -} - -static void gfar_free_rx_queues(struct gfar_private *priv) -{ - int i; - - for (i = 0; i < priv->num_rx_queues; i++) - kfree(priv->rx_queue[i]); -} - static void unmap_group_regs(struct gfar_private *priv) { int i; @@ -685,16 +669,16 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) err = gfar_alloc_tx_queues(priv); if (err) - goto tx_alloc_failed; + return err; err = gfar_alloc_rx_queues(priv); if (err) - goto rx_alloc_failed; + return err; err = of_property_read_string(np, "model", &model); if (err) { pr_err("Device model property missing, aborting\n"); - goto rx_alloc_failed; + return err; } /* Init Rx queue filer rule set linked list */ @@ -803,10 +787,6 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) err_grp_init: unmap_group_regs(priv); -rx_alloc_failed: - gfar_free_rx_queues(priv); -tx_alloc_failed: - gfar_free_tx_queues(priv); return err; } @@ -3345,8 +3325,6 @@ static int gfar_probe(struct platform_device *ofdev) if (of_phy_is_fixed_link(np)) of_phy_deregister_fixed_link(np); unmap_group_regs(priv); - gfar_free_rx_queues(priv); - gfar_free_tx_queues(priv); of_node_put(priv->phy_node); of_node_put(priv->tbi_node); return err; @@ -3366,8 +3344,6 @@ static void gfar_remove(struct platform_device *ofdev) of_phy_deregister_fixed_link(np); unmap_group_regs(priv); - gfar_free_rx_queues(priv); - gfar_free_tx_queues(priv); } #ifdef CONFIG_PM From patchwork Tue Oct 1 21:22: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: 13818776 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.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 155B61CF28A; Tue, 1 Oct 2024 21:22:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727817733; cv=none; b=kK3afjzDs9m2Wibn1ll9c3Hkj6sTBEWsVzaKGNbEvZNMKNCjVmTgw4A7BVSQZDGqmOZ+F3wT9nOvpATjafyMZkVGREHxBbXFf/F55xLvxrt2zUvVlhRMDA5nqTU6ZFwsk7zSIiLWuBsuinbut9vGCWT9dlz8ZI1aZL91fbcajCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727817733; c=relaxed/simple; bh=Fi+ECuYMHlGLDL8STuDo19b4YsDm6goZ0VDI8gcOZb8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dpq+E0MsYsumPO/wuw3DuP6kLuXuQ5D367PlNbEFLTXfvSBXLnbkbuzeiu3H9RY8ujdV2MO7yNSbMFj+FLoAl7RJHKVo9RxNCS+yxHIlNL5PValJj3fwXXksIHXfyLDMJKu5QPLgrMaH/m0R4aI0cOIM3SVqTvhAxGbIa1rWuuw= 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=cDnSgdlm; arc=none smtp.client-ip=209.85.214.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="cDnSgdlm" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-20bc2970df5so5326055ad.3; Tue, 01 Oct 2024 14:22:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727817731; x=1728422531; 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=oefF03u0ufsPVzfuPqkdhg2BxRUbFBRgPpQWx4Hepeo=; b=cDnSgdlmJvzGjUDuHkatbgx/H8yf9TcWwSXbW1yLdXhwgysi3WViyhG7kCLuWVivLT qrxbMfR8sR5OxtKbP+cqtRnKAwpOPc5ZS8+9dqsVxS7pkfh3JUcFdZUwpfCTsR4Jsv/m 1JQd0OGucBKo4nbcsqjero4reFWFp9CVTWLuh2ClvTo+q/dWeXc4x31kZayHOA7zRukG BsJT7I90QdA2hA0qyt1aVd6uoXIjgNfwLf9mvfiXfYQj8ihV+ETNbdQM/zIPo8nJLTtR A4VfE2jc6dHGoixQSr3ESK6V+ZHF1dpuHpELPiE9NpwsfKqLr/gkfM94/41b00/BhD0f kHtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727817731; x=1728422531; 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=oefF03u0ufsPVzfuPqkdhg2BxRUbFBRgPpQWx4Hepeo=; b=NtEDnratiNqzZHgvb7pTE1ypvi+TvLi1NRksmNu8ccX2Ed8K4mJXsRNeKKd08sV7Vn ixBXViJaEm6h/DjewwtiGfRACcq3ed0XswymyAJ0j5W8tG9VkBqhJaP1EKeqzfwPg6EY 1gw6tLfw85O7Nw5r+YLINPnlHa5M5nVr9JHBz9Ig9Q81wGwhQ90mDYrSSvxFsdSsFMO7 cqfo7t+f+GSr2toXgGvL7P9Lo9fzTqE2gLXSPsPcQNyMFYuDPn769XS3DZ2XwNCX9WDx 0i1B1gnqKxxEw9d7mOIZYY68D6/LFIk9ycqt6ju1ZrMZhffOisx8Fa5ghe2Vhkgi0J8/ B9jg== X-Forwarded-Encrypted: i=1; AJvYcCUAsBlOi5T2anUIMEtb4qoLpx4oIIdZ4/w6TqMkC7SPQZt1jLEhQyOFFq2pV9ZLhekQYgOpiwBlIys2ato=@vger.kernel.org X-Gm-Message-State: AOJu0YwGPa1PBE3CTXaz5RLbu0TKYJ6u6APDibF6/HvZuc/Jpw86R1fQ qrRNyog5ajJeYT5+XuBZAS3xKpA+AXhI4mym32xP2/woMybWpAnkjJVyUgMZ X-Google-Smtp-Source: AGHT+IHaphqiFkMaYdlPMI+fw+y+7TMDwH76R8Gof4MQ+OL6pIBsTof5KGkAADt+gcw0if6tN2fT/g== X-Received: by 2002:a17:90b:3a85:b0:2c9:df1c:4a58 with SMTP id 98e67ed59e1d1-2e1846a6a16mr1309690a91.23.1727817731284; Tue, 01 Oct 2024 14:22:11 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f8a731asm47144a91.34.2024.10.01.14.22.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 14:22: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, claudiu.manoil@nxp.com Subject: [PATCH net-next 4/6] net: gianfar: use devm for register_netdev Date: Tue, 1 Oct 2024 14:22:02 -0700 Message-ID: <20241001212204.308758-5-rosenp@gmail.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241001212204.308758-1-rosenp@gmail.com> References: <20241001212204.308758-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 manual unregister netdev. Signed-off-by: Rosen Penev --- drivers/net/ethernet/freescale/gianfar.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 66818d63cced..07936dccc389 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -3272,7 +3272,7 @@ static int gfar_probe(struct platform_device *ofdev) /* Carrier starts down, phylib will bring it up */ netif_carrier_off(dev); - err = register_netdev(dev); + err = devm_register_netdev(&ofdev->dev, dev); if (err) { pr_err("%s: Cannot register net device, aborting\n", dev->name); @@ -3338,8 +3338,6 @@ static void gfar_remove(struct platform_device *ofdev) of_node_put(priv->phy_node); of_node_put(priv->tbi_node); - unregister_netdev(priv->ndev); - if (of_phy_is_fixed_link(np)) of_phy_deregister_fixed_link(np); From patchwork Tue Oct 1 21:22: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: 13818777 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 545CF1CF2B7; Tue, 1 Oct 2024 21:22:13 +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=1727817734; cv=none; b=FfblASJ2mzCNj4ou9NNuxc+Pqb5Na567+a1NtybeC4IouiczFyVsCDZBnON0Gh1hm8kOmLFC6C7v1JKjXyUyxInF4X5Oir1ENEP315Hlk06VkRNtJg5YR7d7IPk7rfrBWCfkHokeq8zPwc5tdHAhKeyyB4J02bYxn626dQE4nkw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727817734; c=relaxed/simple; bh=DZYFjktoIihobhlGbWl9pbIqwhs7oZ9mIFgmBRiZeZU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hYrkMR08I7PDOMfkAAeEjybQVpypo4xgthMOlUILfAI5PmqUlWa57QYqMMQij2WxnL5SfsSInLsTaboVSLi9jKXDWudl008AjlyEci9GEYL4B98e+buwVFHQSaii6QkkxnM2+7gWZU2vzmXDvkP6RpOKeiLNvYaLB92TXMB6qCg= 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=MkeTw59N; 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="MkeTw59N" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-20b1335e4e4so54565045ad.0; Tue, 01 Oct 2024 14:22:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727817732; x=1728422532; 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=/HhAsvUSxcaPvt/idfj9E3lnChQ0pfTApWXnOCNYoO4=; b=MkeTw59NWov90ACw7s2E1BjAemSu6YimLVyA/zcrcNJ267pErctxe8zXuHY+oLxCFT RBlTnvhoMrEIvwHPKDWpYZTnGKKX4ZSnuuQzHiTIIT6e8V7mjDUSYjQH0TiM/v/LkPjy 1jdk6eRMe/zP6RvP7Sl7oqYTbY/eMu0GJNyVYoJ71sN/B8lCp4YAKEjsMJVriNblNaOh ImuGbkHZ6UuxQpzGrBG8Wz047K3KqlpDWLg68XOi+Jsz4qhSPfSfdHTWdyRX9UigWCX4 Ilp08/+R9BfVVjDQzqaPxJpkmtvkUvtEHYsnGuw4ymfZtsxojbVNwoa7RmLb3cTw3kB6 X2/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727817732; x=1728422532; 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=/HhAsvUSxcaPvt/idfj9E3lnChQ0pfTApWXnOCNYoO4=; b=aHmrhSR8dDAOXrH08WybVjSpmAcnrol5xvzMBVQHPUEkgHVqUsPY++zuTJz4PRB7iQ VG9KLKoRa6BQvEnnNO22aMevpJX5XUI/gwCyJki+1X2L8Kyy6HoEN8OP+XFE6LXJpnzf 72BcieD6hcfw2fjSIXsingm0lj2OH4VFTK3y1qaCiZW65nlqVkRfvGGV9kltzlY8h6y6 lXiNmV9IX4CYVTnmWNj1WUx6NTT2kMRN/C8rdf5NC7caTA40oXLdhhOHAOVpyTlTHQbD eOZwOWnUt7Sj0HICxZtOM34NRDPlpQEOUCPRV5+nkQukkI0EgpVmoOQpAPSzQe/5b6HI c4eg== X-Forwarded-Encrypted: i=1; AJvYcCUNRw2zzCHY9XpzBtBezKhwJMEkzvyU5Kd6R4oxSkfVCK9fPV6cPbmr8Nqj6kO3xi+Nn5JuidcFYoKpghY=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5FMe/1yUBFVjGXK2/ZRMtuvyHbWr0D4AGOe2QvAZsO3dSpumX OhkDFmVCHWru+8I2YCuaDDqUGGbUtUlk2iGTjGlHJWHKytgf8LA4TqRgYgGy X-Google-Smtp-Source: AGHT+IGGl9SQ8ZXgyHHQ/BcdNGdw6gW7afgVBUCZEAPuizlVnCQtyJJfdxwK8rFM1uLtzR7uleHEIw== X-Received: by 2002:a17:90a:f40d:b0:2e0:a931:cb11 with SMTP id 98e67ed59e1d1-2e18454bfafmr1321298a91.4.1727817732527; Tue, 01 Oct 2024 14:22:12 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f8a731asm47144a91.34.2024.10.01.14.22.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 14:22:12 -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, claudiu.manoil@nxp.com Subject: [PATCH net-next 5/6] net: gianfar: use devm for request_irq Date: Tue, 1 Oct 2024 14:22:03 -0700 Message-ID: <20241001212204.308758-6-rosenp@gmail.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241001212204.308758-1-rosenp@gmail.com> References: <20241001212204.308758-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 Signed-off-by: Rosen Penev --- drivers/net/ethernet/freescale/gianfar.c | 67 +++++++----------------- 1 file changed, 18 insertions(+), 49 deletions(-) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 07936dccc389..78fdab3c6f77 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -2769,13 +2769,6 @@ static void gfar_netpoll(struct net_device *dev) } #endif -static void free_grp_irqs(struct gfar_priv_grp *grp) -{ - free_irq(gfar_irq(grp, TX)->irq, grp); - free_irq(gfar_irq(grp, RX)->irq, grp); - free_irq(gfar_irq(grp, ER)->irq, grp); -} - static int register_grp_irqs(struct gfar_priv_grp *grp) { struct gfar_private *priv = grp->priv; @@ -2789,80 +2782,58 @@ static int register_grp_irqs(struct gfar_priv_grp *grp) /* Install our interrupt handlers for Error, * Transmit, and Receive */ - err = request_irq(gfar_irq(grp, ER)->irq, gfar_error, 0, - gfar_irq(grp, ER)->name, grp); + err = devm_request_irq(priv->dev, gfar_irq(grp, ER)->irq, + gfar_error, 0, gfar_irq(grp, ER)->name, + grp); if (err < 0) { netif_err(priv, intr, dev, "Can't get IRQ %d\n", gfar_irq(grp, ER)->irq); - goto err_irq_fail; + return err; } enable_irq_wake(gfar_irq(grp, ER)->irq); - err = request_irq(gfar_irq(grp, TX)->irq, gfar_transmit, 0, - gfar_irq(grp, TX)->name, grp); + err = devm_request_irq(priv->dev, gfar_irq(grp, TX)->irq, + gfar_transmit, 0, + gfar_irq(grp, TX)->name, grp); if (err < 0) { netif_err(priv, intr, dev, "Can't get IRQ %d\n", gfar_irq(grp, TX)->irq); - goto tx_irq_fail; + return err; } - err = request_irq(gfar_irq(grp, RX)->irq, gfar_receive, 0, - gfar_irq(grp, RX)->name, grp); + err = devm_request_irq(priv->dev, gfar_irq(grp, RX)->irq, + gfar_receive, 0, gfar_irq(grp, RX)->name, + grp); if (err < 0) { netif_err(priv, intr, dev, "Can't get IRQ %d\n", gfar_irq(grp, RX)->irq); - goto rx_irq_fail; + return err; } enable_irq_wake(gfar_irq(grp, RX)->irq); } else { - err = request_irq(gfar_irq(grp, TX)->irq, gfar_interrupt, 0, - gfar_irq(grp, TX)->name, grp); + err = devm_request_irq(priv->dev, gfar_irq(grp, TX)->irq, + gfar_interrupt, 0, + gfar_irq(grp, TX)->name, grp); if (err < 0) { netif_err(priv, intr, dev, "Can't get IRQ %d\n", gfar_irq(grp, TX)->irq); - goto err_irq_fail; + return err; } enable_irq_wake(gfar_irq(grp, TX)->irq); } return 0; - -rx_irq_fail: - free_irq(gfar_irq(grp, TX)->irq, grp); -tx_irq_fail: - free_irq(gfar_irq(grp, ER)->irq, grp); -err_irq_fail: - return err; - -} - -static void gfar_free_irq(struct gfar_private *priv) -{ - int i; - - /* Free the IRQs */ - if (priv->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) { - for (i = 0; i < priv->num_grps; i++) - free_grp_irqs(&priv->gfargrp[i]); - } else { - for (i = 0; i < priv->num_grps; i++) - free_irq(gfar_irq(&priv->gfargrp[i], TX)->irq, - &priv->gfargrp[i]); - } } static int gfar_request_irq(struct gfar_private *priv) { - int err, i, j; + int err, i; for (i = 0; i < priv->num_grps; i++) { err = register_grp_irqs(&priv->gfargrp[i]); - if (err) { - for (j = 0; j < i; j++) - free_grp_irqs(&priv->gfargrp[j]); + if (err) return err; - } } return 0; @@ -2902,8 +2873,6 @@ static int gfar_close(struct net_device *dev) /* Disconnect from the PHY */ phy_disconnect(dev->phydev); - gfar_free_irq(priv); - return 0; } From patchwork Tue Oct 1 21:22: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: 13818778 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 7F5AD1CF5E8; Tue, 1 Oct 2024 21:22:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727817735; cv=none; b=NYgpQ2ud9P1vhV8fFeqv3xcWg1YKGzcXO+2CJBzCU836kKu/uSuEoF4ZNOQwzyCYB2NT/DF7ycvTcdGfaw0evA58u5ZIXCvIXxIUPGd2psek036fmZN5j4IMT8B76BPSTYInk++E62AesueiCSgXlyze5+dXaMjCwQ6O0icKOGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727817735; c=relaxed/simple; bh=koyYEeR5HN11pk9/ElqN2hDHdB83gfCX3Cgnt9VKvw8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W+G+GeC3LEF+cIbPjeUviVstVHXlqF/CW3mHTrW6ZOX1dD4x6usbzK9R3hmpoB8qIUzu8Vha5wfDprXUMLr8eOT+sEAP+hNLf3P/ZWSV5KFEcWu3R7qWWwdaygA6hb0rQXMatXdPQWtPPuYFki+K9IVRgangNzTtXoz1BPfH8HI= 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=hc3guapQ; arc=none smtp.client-ip=209.85.216.45 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="hc3guapQ" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2e0b0142bbfso164780a91.1; Tue, 01 Oct 2024 14:22:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727817734; x=1728422534; 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=PKbA8fFdky5oW8OnyEI3WYz8g/QfgSnOjbnn2zla0ck=; b=hc3guapQDzmlrWmUbFnkC/5ztdxw/IrqgjpdQDTXrJhJIoTAQZQQ7oDQOl1/RxSVEE Vuwn+D8ofCgMDP1xPEZA9J8VJ5ssCrvRnHDPdrtH1zKiIiFjm5QLGz6487W5vzpHbrl+ oxfR56K8JhhuYty/UI18h0Qw8oDDZttu0lHl3bnGG0LIxsB+gFcLmWVkutJhcP69MvIr luBFb8IHkVKCW5/v16VCTAzK8qxeJG9e/07lAstVAkCVFEKntlCM+5YeKIoi8QWiHe1w o/YANbuz2Jr5/zViVLJNrUm2BO6y+qRefAbbYkLvnekIWRMfC1taluXeW/ILpi1WXH+x bwnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727817734; x=1728422534; 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=PKbA8fFdky5oW8OnyEI3WYz8g/QfgSnOjbnn2zla0ck=; b=Qn1GQ+S7wPJiunBC3iclO5H2vOkgyOglXgU70uvZpTPBsUhP1qtxSoWGZt9piWLQQI gBCNC7pENuA2LCCf+rjcpO6IvUgxqPKD6qbgCdNMWTFYGaVo6t5jE0MTeH8CpuUmeuKt gddPs1Wyx/HhedrY5s8swV1h/StIwaLGwPRGvxLE6Y/gx+EsQc4/30awh6yRjfq/ndZZ rKr3rGy28UPgx9MZuv7aEVke5xMX5UfPyUnwF55F1EhYe0vI7jmbre9wifBDqRgWYmC/ RW4xOKnQKoXlBcRIf2B7Z/j7PGhIcJJOtW1eIb+GiLbOCpk9ba+oiymik6g46zgSASMH LYWA== X-Forwarded-Encrypted: i=1; AJvYcCVIIAE0MF/fkNNqPysNY393xIKhnUPPwHa2+q7vqrCWOvPeemcm/4FnI5ziI+zzJsy7J2b5DQOFkRS2c4I=@vger.kernel.org X-Gm-Message-State: AOJu0YxHJYaBp+nnc/5G8QMODnaIIunrnB8Y0CZ95xEqf22OWTald3+c aWM1+T/b9x5rBkq79nKLx+8XrlS0PnXaqoACqPYoilbQAB897XD7R2ociIeV X-Google-Smtp-Source: AGHT+IHyiaJ63rtVJ6JDEYDWdud4DyoFh2zxGza9w241E9der5D/TE9vnecuksGpMHZcOh3z3/B9AA== X-Received: by 2002:a17:90a:7448:b0:2d8:3f7a:edf2 with SMTP id 98e67ed59e1d1-2e15a272c6dmr6901122a91.12.1727817733757; Tue, 01 Oct 2024 14:22:13 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f8a731asm47144a91.34.2024.10.01.14.22.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 14:22: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, claudiu.manoil@nxp.com Subject: [PATCH net-next 6/6] net: gianfar: use devm for of_iomap Date: Tue, 1 Oct 2024 14:22:04 -0700 Message-ID: <20241001212204.308758-7-rosenp@gmail.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241001212204.308758-1-rosenp@gmail.com> References: <20241001212204.308758-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 manually unmap. Removes all gotos in probe. Signed-off-by: Rosen Penev Reviewed-by: Maxime Chevallier --- drivers/net/ethernet/freescale/gianfar.c | 26 +++++------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 78fdab3c6f77..96eeef0d6bd3 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -441,15 +441,6 @@ static int gfar_alloc_rx_queues(struct gfar_private *priv) return 0; } -static void unmap_group_regs(struct gfar_private *priv) -{ - int i; - - for (i = 0; i < MAXGROUPS; i++) - if (priv->gfargrp[i].regs) - iounmap(priv->gfargrp[i].regs); -} - static void disable_napi(struct gfar_private *priv) { int i; @@ -483,7 +474,7 @@ static int gfar_parse_group(struct device_node *np, return -ENOMEM; } - grp->regs = of_iomap(np, 0); + grp->regs = devm_of_iomap(priv->dev, np, 0, NULL); if (!grp->regs) return -ENOMEM; @@ -698,13 +689,13 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) err = gfar_parse_group(child, priv, model); if (err) { of_node_put(child); - goto err_grp_init; + return err; } } } else { /* SQ_SG_MODE */ err = gfar_parse_group(np, priv, model); if (err) - goto err_grp_init; + return err; } if (of_property_read_bool(np, "bd-stash")) { @@ -727,7 +718,7 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) err = of_get_ethdev_address(np, dev); if (err == -EPROBE_DEFER) - goto err_grp_init; + return err; if (err) { eth_hw_addr_random(dev); dev_info(&ofdev->dev, "Using random MAC address: %pM\n", dev->dev_addr); @@ -775,7 +766,7 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) if (!priv->phy_node && of_phy_is_fixed_link(np)) { err = of_phy_register_fixed_link(np); if (err) - goto err_grp_init; + return err; priv->phy_node = of_node_get(np); } @@ -784,10 +775,6 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) priv->tbi_node = of_parse_phandle(np, "tbi-handle", 0); return 0; - -err_grp_init: - unmap_group_regs(priv); - return err; } static u32 cluster_entry_per_class(struct gfar_private *priv, u32 rqfar, @@ -3293,7 +3280,6 @@ static int gfar_probe(struct platform_device *ofdev) register_fail: if (of_phy_is_fixed_link(np)) of_phy_deregister_fixed_link(np); - unmap_group_regs(priv); of_node_put(priv->phy_node); of_node_put(priv->tbi_node); return err; @@ -3309,8 +3295,6 @@ static void gfar_remove(struct platform_device *ofdev) if (of_phy_is_fixed_link(np)) of_phy_deregister_fixed_link(np); - - unmap_group_regs(priv); } #ifdef CONFIG_PM