From nobody Mon Nov 25 02:25:17 2024 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A7AC199FB1; Wed, 30 Oct 2024 20:37:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320660; cv=none; b=bhtqXEwsHQnob+3zQEfhARe67kHwmYTKe+i+D4JRTM9YFmX18LDXAlKkVcGdtsy+ydDlgZr/hzrH4GTg+h1/VWJNddkxY9I90wk2nAz3/bmFCtZkDJhGXHqQRPhu5ZITNG3K0EAXN8oHEnjHhEbweDjKymDg68p87EZRxvhIXhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320660; c=relaxed/simple; bh=cJF/r9FSp+IKgOh3m+uNrY4TgV5AxmsrJVO7MLbSC9U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sDvu7pVHRKzG7zs6+vfEq+mizjmAB8b1aI+o6rU4scEFfuxVBz/+E5n451P8ST5ZQwda820F8ZYgyQijqk9BASFRt1w1bOl1AxW3tfa5MXnMRSlcZvk0yFbYxm1osp8HzJGiJ+6aZTd2rSEYRvR9HkCQo4aFTlHlKyxQw5U1sz8= 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=I1CgS6Ml; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I1CgS6Ml" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-20b5affde14so2138565ad.3; Wed, 30 Oct 2024 13:37:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730320658; x=1730925458; 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=2oZNHqXM6KLZf+eEXFCkM1XpVoPkfn5qBUjcN0umbNM=; b=I1CgS6Ml2tG4rEPkMXbBfJAJWDai439v48N04YtyYi/tQb1KsP3qNxMJCr7qFC2yNz v6z06qTpqJ9jrPdScjCfn5PV2d30E0sa1Euuo242ijGN58bTQ0qrK+C3vTLPJNeKx18I IYRm7BWQbCf7kmtZFpA1UN30Wg7NbFJtdMQ8znPsvIbFwO0Atf/8TqFXmUZkfcLW3Den 15cpETbUwWKJvennLxw42K/YwbhKrTXeQ7ewTzFszH0vWZJx4fJXC+e84PLMNgTNK9ls To17bl99SpKvO5GcVX7ZK2pLSjpPitXggvoJq2HK8EmFAuhAIJeFphEOdH9N1aTJnoOU bkmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730320658; x=1730925458; 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=2oZNHqXM6KLZf+eEXFCkM1XpVoPkfn5qBUjcN0umbNM=; b=UIhUfhkplJEOZPcXv+RHEC7PgYt8Mn8mHQGCcdMiQPA4D3eiCkAAVPRbdaHg5nIHkK J33flQ7Y5CN9PJHSZiv5j5jVf132NeVjJqGIU/IZKZU7BYpIMiNfvvz0RxSvGw1mXJjV QDylonSOnL5PnMyt3HeMHsavLec744JQUZBa4l2+n1U67I3hUBhanMW3CvDcpNACFNrV y4EMg53a/bBMFQ7FMKaqvXSrTqjSv2re37RPgof0rESghRvmXHnm2CpIa0lrx6QR85kC ixNrZuIAVzh86fnibYLdWxPKenYq4+IA5OYx+RPwzAL3xw0r5hlxR+qrEU21kDsz9ZvA 30dQ== X-Forwarded-Encrypted: i=1; AJvYcCV0g3CyUEwBrAZ3NZRVTlyRLeQ6rlUm+prISdyITg8+m2SsqQkk98A70dIYDORZjR8IRjbc/3CA+e0fhik=@vger.kernel.org X-Gm-Message-State: AOJu0YyCvNU17cSjd6yMFgUiIWalMQwd81IhU7BT2rbK5f6tMkS2HsW6 Q5VnNzmtQXFvymeQBB9wz/Tyi0wAjDB5PU5g0bzu96gLqdm5P5Wh6Zdly7y+ X-Google-Smtp-Source: AGHT+IHO6/QY0oKNd96E78XoWzLNYP2UBQWxWGmGxUa+7tNjgfq278EHHzid915c06iCvaCcEwaHjg== X-Received: by 2002:a17:903:2302:b0:20b:9062:7b16 with SMTP id d9443c01a7336-210c6872d94mr228484595ad.9.1730320657573; Wed, 30 Oct 2024 13:37:37 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211056ed85dsm40645ad.5.2024.10.30.13.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 13:37:37 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rosen Penev , Breno Leitao , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 01/12] net: ibm: emac: tah: use devm for kzalloc Date: Wed, 30 Oct 2024 13:37:16 -0700 Message-ID: <20241030203727.6039-2-rosenp@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030203727.6039-1-rosenp@gmail.com> References: <20241030203727.6039-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" Simplifies the probe function by removing gotos. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/tah.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/tah.c b/drivers/net/ethernet/ibm= /emac/tah.c index c605c8ff933e..267c23ec15d7 100644 --- a/drivers/net/ethernet/ibm/emac/tah.c +++ b/drivers/net/ethernet/ibm/emac/tah.c @@ -90,28 +90,25 @@ static int tah_probe(struct platform_device *ofdev) struct device_node *np =3D ofdev->dev.of_node; struct tah_instance *dev; struct resource regs; - int rc; =20 - rc =3D -ENOMEM; - dev =3D kzalloc(sizeof(struct tah_instance), GFP_KERNEL); - if (dev =3D=3D NULL) - goto err_gone; + dev =3D devm_kzalloc(&ofdev->dev, sizeof(struct tah_instance), + GFP_KERNEL); + if (!dev) + return -ENOMEM; =20 mutex_init(&dev->lock); dev->ofdev =3D ofdev; =20 - rc =3D -ENXIO; if (of_address_to_resource(np, 0, ®s)) { printk(KERN_ERR "%pOF: Can't get registers address\n", np); - goto err_free; + return -ENXIO; } =20 - rc =3D -ENOMEM; dev->base =3D (struct tah_regs __iomem *)ioremap(regs.start, sizeof(struct tah_regs)); if (dev->base =3D=3D NULL) { printk(KERN_ERR "%pOF: Can't map device registers!\n", np); - goto err_free; + return -ENOMEM; } =20 platform_set_drvdata(ofdev, dev); @@ -123,11 +120,6 @@ static int tah_probe(struct platform_device *ofdev) wmb(); =20 return 0; - - err_free: - kfree(dev); - err_gone: - return rc; } =20 static void tah_remove(struct platform_device *ofdev) @@ -137,7 +129,6 @@ static void tah_remove(struct platform_device *ofdev) WARN_ON(dev->users !=3D 0); =20 iounmap(dev->base); - kfree(dev); } =20 static const struct of_device_id tah_match[] =3D --=20 2.47.0 From nobody Mon Nov 25 02:25:17 2024 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C99F71F4713; Wed, 30 Oct 2024 20:37:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320661; cv=none; b=LwVrhoJn8fbM48AfnEkxiIWMLySNSwgHvtv6Y9YjSo1m+S3CYJcMcOKakoh6phdeR5uaCzw23/WLNBenxTi7YkOdjYuMCmti7WKclmSDpPQer8hsTKPH3o16oCz/WNn7L/iRWpREhAd+A9AhH4u0CtBEULCpIJSxj5KJJc27TE0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320661; c=relaxed/simple; bh=0SRoFqBcsDw85/QaKVA6EwGOPq1eSAenDqaeKxv/yfI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LVCp3Dp1DWwk6KmEwQqIt3fYn6786xqTDDnfirGWjHgkdNr4zj/cskyeGgtO0Sl+wIEpsZ5GdIQDU0ayWdIUpacm+SpG87/p/xLzJQiwi8DIkxSLMGZw/uCLu/GEmj6xrhaiisvIHhDEAQ+BJcssXJy4Bc3OkhLEWGb5EKqGeBU= 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=JgucLx0h; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JgucLx0h" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20c803787abso2269775ad.0; Wed, 30 Oct 2024 13:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730320659; x=1730925459; 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=Q5aBaoW4lFkmcmvYotmRAFRNfP1wDd/xzHaiUde4U+w=; b=JgucLx0h2UPAHxiQWRfWRn6bR5CBN7tZcNAfcrzGPw2CwEeGevCYR8IDNfmwNv1gz+ /4TiPEl+pmAQW7BxtiMvfyzTyxrYQNSKif6dUG8O6R5Gk+JUj7ohSyue+xNc43ChsrbO dQm8rY+OlhmsNSwXh5vua46gQs+czur66z/byzeJcaua45J5p12Osn6cLQcrr++EE5/M L0vyFzEpiY3TGxkrAlZHxAW8uGwYtGYDtATKLp77NZ1pMdnki8cxpjmzll1x5MZYaAdB qwLWppFCeaUrGe3+K7lOjJyOBX4wxbQj9VXMwb69tLPv3dYpzSCeYsg8c3fW/3M7ev/U g4YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730320659; x=1730925459; 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=Q5aBaoW4lFkmcmvYotmRAFRNfP1wDd/xzHaiUde4U+w=; b=WLKmjEp+kz1W/xXbqa7V2vXrv4zqIyecWX3Kx63gseYUDhIOlnxp4Il+LGdH12pRio vBI4YSRsavpFni3Moz/rmLyHVylscOHgezvgh3ICOrq9Pn2r2PM6do6/J48YDU2oEMhV hHuBq31+VpnZW7nIx7INkDD248KnpOMtcLEObavM6Gh0q8rkyo85k2ppklbN+CrengTX OWAK6+2zAVUBeJpWEQBJ5E96e8L67DTOp4o7Ozln2oXDGucXakOQSaxmtrKBg7VUrV2I w3jYVPcGjTiU1GMT6iJvAcHlEDnYmlsZRIdY/le1lyQ+S8AOFKtBFOYhPJEFiK4gxypv py0Q== X-Forwarded-Encrypted: i=1; AJvYcCXVYhhGpw5jJ1ksv2msrDf5nmooq3CdpttZK3aIsLbmVtm5/nm600TmF81nq0E4v8dvSSbbQBkdvTvlX2s=@vger.kernel.org X-Gm-Message-State: AOJu0YxhnbzCwTwRdL0aW3sV6A3q/cmCLQq5qlDcyM4Y0xjQFkSSGbla ohpxaPPcT+ybCZ1E6AGsAMG5k9AL56tGQRpavI4N4Z7W2wWAo+1H1HGXObY7 X-Google-Smtp-Source: AGHT+IEslBPsWMVT3kfzLveckiZE/aUDHqe0JSGMATWwFGxenxaBxCHDrKRDl5uJf1tayeMUUJ+8zA== X-Received: by 2002:a17:902:e88a:b0:20c:cd01:79ae with SMTP id d9443c01a7336-210f9043b2dmr58075525ad.24.1730320658853; Wed, 30 Oct 2024 13:37:38 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211056ed85dsm40645ad.5.2024.10.30.13.37.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 13:37:38 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rosen Penev , Breno Leitao , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 02/12] net: ibm: emac: tah: use devm for mutex_init Date: Wed, 30 Oct 2024 13:37:17 -0700 Message-ID: <20241030203727.6039-3-rosenp@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030203727.6039-1-rosenp@gmail.com> References: <20241030203727.6039-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 seems that since inception, this driver never called mutex_destroy in _remove. Use devm to handle this automatically. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/tah.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ibm/emac/tah.c b/drivers/net/ethernet/ibm= /emac/tah.c index 267c23ec15d7..4b325505053b 100644 --- a/drivers/net/ethernet/ibm/emac/tah.c +++ b/drivers/net/ethernet/ibm/emac/tah.c @@ -90,13 +90,17 @@ static int tah_probe(struct platform_device *ofdev) struct device_node *np =3D ofdev->dev.of_node; struct tah_instance *dev; struct resource regs; + int err; =20 dev =3D devm_kzalloc(&ofdev->dev, sizeof(struct tah_instance), GFP_KERNEL); if (!dev) return -ENOMEM; =20 - mutex_init(&dev->lock); + err =3D devm_mutex_init(&ofdev->dev, &dev->lock); + if (err) + return err; + dev->ofdev =3D ofdev; =20 if (of_address_to_resource(np, 0, ®s)) { --=20 2.47.0 From nobody Mon Nov 25 02:25:17 2024 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38FEE21503D; Wed, 30 Oct 2024 20:37:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320663; cv=none; b=GhjGETe+uS2gkfT4sfQMo24f8c/CH9dmxUv0LWPicsbPP4ln+kvevygtANk8/Bt0aWa3tBv5FuZZiilPzhiPONbx8cqHmF2qMEq+FsvMDFivAtYIoeY8ugCk0XcL2MXCYzMdThGsfQRSQKa8QuF6iRHSf+U8j8fUNczaOGU+ZK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320663; c=relaxed/simple; bh=8H/HGfseD6Hcty/U1z5QkzaKDuq6wTTa2iAs5w8qdz8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hy4IGja9tQ6zo8RzeQ+A2d9G5qoqlkrly2OhRTJqWmtn3VkVlMvcYvUny5FbA62vGbh5o1cQe/wFMq3PjeIOm2qmlgzEWkWditPE099XChpSeMb23PMNI+yQkea+nZTIbuGJdTbbFv5uQcA3GHTfcgRfL9e5bD2ne7dmL/jnM3g= 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=QavkYgpp; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QavkYgpp" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20b5affde14so2138865ad.3; Wed, 30 Oct 2024 13:37:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730320660; x=1730925460; 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=I1nVodfyPN+fRTJh2xp4PUTmWLc6YUs5p24LJwjzuGA=; b=QavkYgppk0dErnlqX/WOdqjZk99BT3owjdVTT53GQf0ZUv4cLdS5QEJg6J9Sh6kxLA J4eBCQvdtnOCy4Mn5VyzVtHqPb24EJsztFs53EBXtPA9b+6vJ9wVCsBX4OoyceyQefSJ ZubpFiFP4pqSNdaN7xV5d29qdd3uij+5T93Qg0GJ+SQnjClYNe2SC36BZEE6aFreLgBS gWE4a2ET1qYEixJe7qkLUJGd9gV68cJyhTjryxvQ1jHr/XSVoeugrzz3Hc754ZnI82Pq Yr7iPqsQPIVoDfS7oqRpPfQzGMilC4/us3DDrAMWIlYKhluRelalbQX7RDBmPACz8Z4b teHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730320660; x=1730925460; 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=I1nVodfyPN+fRTJh2xp4PUTmWLc6YUs5p24LJwjzuGA=; b=e0XywQDe9hZtZXSA/lL65D/IisRuJHyvWOsGppJ35aQbGIUBQuWNruD66hxEvATDgr 85BT3lRAd/ck07F/Me9qWGxlt1s0fUhTJta86ljDRCWK/qTuZ5li20pB6wOH7OrRBQsr i0cIsSRfk+YUu/YpAmg6mqAIKyiw36itOeQDNA0ul2GnsDDrmNgEP82eTZ0IP3h+WPJz ihYWfmbhdeSpFfCOOJ6djFZzOE/UP4VawunF83RrA6kCxEngEs0i+auibtNIbh+2aU6I sAygQzCq9rvSENG4MVLkLLrRrf/GKPLOJ1sxgivA1Pyp3Es4pUPZmH9YdzZhRmaNAvvW jfjw== X-Forwarded-Encrypted: i=1; AJvYcCXBeTrHitx2qBRWH62qIe6A9OcwroV5j0EO+nFmbX2OdUKacjjzU3LpN9diYc1XYlGUA3McFuCNjUD+VFs=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/H7NDPjR85yI4XrJuEOxeH6dBNeAKX4/u6Cg7fpamlV+PJ3Zn OVRqJHo2rlIzNZRRNrNBlqu/GPCmzj0NC2h3b9rmHU3eh65LE0YDwRSCpjou X-Google-Smtp-Source: AGHT+IGxprz3EHb/FK2QzLFyo0d6Petk3zgqKuGy5tkXioh0CukmsMpyiYLi4eLeNKwS+ZHywg7OgQ== X-Received: by 2002:a17:902:db0f:b0:20c:cf39:fe3c with SMTP id d9443c01a7336-210c6c34824mr228108785ad.41.1730320660256; Wed, 30 Oct 2024 13:37:40 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211056ed85dsm40645ad.5.2024.10.30.13.37.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 13:37:39 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rosen Penev , Breno Leitao , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 03/12] net: ibm: emac: tah: devm_platform_get_resources Date: Wed, 30 Oct 2024 13:37:18 -0700 Message-ID: <20241030203727.6039-4-rosenp@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030203727.6039-1-rosenp@gmail.com> References: <20241030203727.6039-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" Simplifies the probe function by a bit and allows removing the _remove function such that devm now handles all cleanup. printk gets converted to dev_err as np is now gone. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/tah.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/tah.c b/drivers/net/ethernet/ibm= /emac/tah.c index 4b325505053b..09f6373ed2f9 100644 --- a/drivers/net/ethernet/ibm/emac/tah.c +++ b/drivers/net/ethernet/ibm/emac/tah.c @@ -87,9 +87,7 @@ void *tah_dump_regs(struct platform_device *ofdev, void *= buf) =20 static int tah_probe(struct platform_device *ofdev) { - struct device_node *np =3D ofdev->dev.of_node; struct tah_instance *dev; - struct resource regs; int err; =20 dev =3D devm_kzalloc(&ofdev->dev, sizeof(struct tah_instance), @@ -103,16 +101,10 @@ static int tah_probe(struct platform_device *ofdev) =20 dev->ofdev =3D ofdev; =20 - if (of_address_to_resource(np, 0, ®s)) { - printk(KERN_ERR "%pOF: Can't get registers address\n", np); - return -ENXIO; - } - - dev->base =3D (struct tah_regs __iomem *)ioremap(regs.start, - sizeof(struct tah_regs)); - if (dev->base =3D=3D NULL) { - printk(KERN_ERR "%pOF: Can't map device registers!\n", np); - return -ENOMEM; + dev->base =3D devm_platform_ioremap_resource(ofdev, 0); + if (IS_ERR(dev->base)) { + dev_err(&ofdev->dev, "can't map device registers"); + return PTR_ERR(dev->base); } =20 platform_set_drvdata(ofdev, dev); @@ -126,15 +118,6 @@ static int tah_probe(struct platform_device *ofdev) return 0; } =20 -static void tah_remove(struct platform_device *ofdev) -{ - struct tah_instance *dev =3D platform_get_drvdata(ofdev); - - WARN_ON(dev->users !=3D 0); - - iounmap(dev->base); -} - static const struct of_device_id tah_match[] =3D { { @@ -153,7 +136,6 @@ static struct platform_driver tah_driver =3D { .of_match_table =3D tah_match, }, .probe =3D tah_probe, - .remove =3D tah_remove, }; =20 int __init tah_init(void) --=20 2.47.0 From nobody Mon Nov 25 02:25:17 2024 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0263217640; Wed, 30 Oct 2024 20:37:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320664; cv=none; b=RJnSxa5B5MHRLFaE8fiADB+9Psi8TDkL5g9xdvXC3XvUgn4i1SuLEqT5wSegOY+/m880ByLm5eHJzJByzxNm0lVbgDbATjGv+/60z6EiBfmxfeADYdGZY+ahUt7K69C+9xU7+liMl0sI8FB7z5xHMq3mxp5TcJYg9eqo+FN8a7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320664; c=relaxed/simple; bh=/AyfdLsc4FboZTScYL4z+M7CyC+1MlkGFgvrkEtv8Po=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y+WfMyW70rQWU/evpwZ8lCSqEd+htO9UlxCxwpvjLNpAk5HbgEO18OdxKTA3If3K8IAnyjsUqntW/0XxABZCTYf1aGjAnItY1uOP++lG7/upC48jt2x++iZplG6CmBl5rVNSQSs1L/7pq/SMp7efgsNmiG4C7kLlPN7tOfEgBVo= 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=Q4tDvtjx; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q4tDvtjx" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20cdbe608b3so2666175ad.1; Wed, 30 Oct 2024 13:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730320662; x=1730925462; 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=n4hNqSoXogKVl9LYR/Mqj/g1unmfokChedKgYC3ItUk=; b=Q4tDvtjxSRX6SaBvT0xD4yJSl+u8MkGfQN96MkJsIkLcv/5WynloLeR9sw6213f+DY vzwoTOOTApHwDaFyjw+Kdk4u9bZZYW3MODkz+O4zh15Z5UWpETTlZ1wmRrgHj/7s3IBE cOOXlZnesW+RYDWUTNSmys5pKA86SnNOw2lzZFdm5fQHYvLMNVHwkp/Zbk2sBoVMKMSd BqsXK8qVyJcoKBgamxd9VkX/fxVbIAEUqo/a9xxSI2W6pf2899iWVv2i3J/DEl8TUQRp KACPM2D3/R8s+XtlY+yD285ndMdM49irOAhh3UAJDLeR6WqD8sHhWRcTQgLOqh2/uyw2 PBBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730320662; x=1730925462; 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=n4hNqSoXogKVl9LYR/Mqj/g1unmfokChedKgYC3ItUk=; b=MW/EHcnVVj1rZNh8vWwNtkPeJihqFx/MvW6GbrBPvaMbObBpS7bGRqT1nK9KgVRcHI opZNd5Sk4Ah5amHpK0SOFHWui3XfCBuWuOTykd8VjDRsYtiiWGQLdJHA/nvnRxuOk5B7 95ZuygB2T/5L6nos4d3bex3Uo4Izz1rxY9jL6L48Gpg1wPpJ6YD4q2xBhI/b8lA0+koY E3bVuG3qlgPzVcN6texlaHaxQ09p+agjgRWwlhcJmhGl4v7f1aj2tCjRH3MKXiXAO8iW Wgg9cWwhq9gbQ7MBLRU3NjgvEwoOBdy9DKgh4XadMeM8942IYpPnxr5X1HNsWNfVL3dZ s4zg== X-Forwarded-Encrypted: i=1; AJvYcCW9tG5b/1kifEmiaIwHn4bqMUn+2QKRaflsJv/pY8LOZCnAuWmyHgM39YqsXrseKlEJaU9QfgTYEmMpGzc=@vger.kernel.org X-Gm-Message-State: AOJu0YzXaGEJcyosBKY1Ggdsu++EikmGSVnOTX7wkTJNAaChWoUHXHDE lorVf4zYmQMkQ3kxaqjnnuGNmsw7Raaamhvab6hsLXPdHH482swOVA5eb1an X-Google-Smtp-Source: AGHT+IHjsHLUmxVu1UxOIRcoo/yQk04XRdvaSISDcPg2PKTem4MjkrUo8cfIT6qLJC0y6uw6tJv9+A== X-Received: by 2002:a17:902:e888:b0:20b:4f95:932d with SMTP id d9443c01a7336-210f74f6f4bmr62398505ad.3.1730320661624; Wed, 30 Oct 2024 13:37:41 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211056ed85dsm40645ad.5.2024.10.30.13.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 13:37:41 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rosen Penev , Breno Leitao , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 04/12] net: ibm: emac: rgmii: use devm for kzalloc Date: Wed, 30 Oct 2024 13:37:19 -0700 Message-ID: <20241030203727.6039-5-rosenp@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030203727.6039-1-rosenp@gmail.com> References: <20241030203727.6039-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" Simplifies the probe function by removing gotos. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/rgmii.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/rgmii.c b/drivers/net/ethernet/i= bm/emac/rgmii.c index 317c22d09172..7bafe2edfc50 100644 --- a/drivers/net/ethernet/ibm/emac/rgmii.c +++ b/drivers/net/ethernet/ibm/emac/rgmii.c @@ -219,28 +219,25 @@ static int rgmii_probe(struct platform_device *ofdev) struct device_node *np =3D ofdev->dev.of_node; struct rgmii_instance *dev; struct resource regs; - int rc; =20 - rc =3D -ENOMEM; - dev =3D kzalloc(sizeof(struct rgmii_instance), GFP_KERNEL); - if (dev =3D=3D NULL) - goto err_gone; + dev =3D devm_kzalloc(&ofdev->dev, sizeof(struct rgmii_instance), + GFP_KERNEL); + if (!dev) + return -ENOMEM; =20 mutex_init(&dev->lock); dev->ofdev =3D ofdev; =20 - rc =3D -ENXIO; if (of_address_to_resource(np, 0, ®s)) { printk(KERN_ERR "%pOF: Can't get registers address\n", np); - goto err_free; + return -ENXIO; } =20 - rc =3D -ENOMEM; dev->base =3D (struct rgmii_regs __iomem *)ioremap(regs.start, sizeof(struct rgmii_regs)); if (dev->base =3D=3D NULL) { printk(KERN_ERR "%pOF: Can't map device registers!\n", np); - goto err_free; + return -ENOMEM; } =20 /* Check for RGMII flags */ @@ -266,11 +263,6 @@ static int rgmii_probe(struct platform_device *ofdev) platform_set_drvdata(ofdev, dev); =20 return 0; - - err_free: - kfree(dev); - err_gone: - return rc; } =20 static void rgmii_remove(struct platform_device *ofdev) @@ -280,7 +272,6 @@ static void rgmii_remove(struct platform_device *ofdev) WARN_ON(dev->users !=3D 0); =20 iounmap(dev->base); - kfree(dev); } =20 static const struct of_device_id rgmii_match[] =3D --=20 2.47.0 From nobody Mon Nov 25 02:25:17 2024 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6759217673; Wed, 30 Oct 2024 20:37:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320665; cv=none; b=KFBZV7cqTpQUu6+8u0Eq9t5RXWMUa8hDqNKrvLb5xaHrKsk8z0KdzsA3cExXf8pIl30uJHeT6hPL5cFRTlRaYDsaUExl9gjmP4xJhPkwCEl//teChv8Ue6jG/iw9tx9LY8A4fkipv0/1fEh20gvKcb3x6eJd6HarsIqB+ZOvxU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320665; c=relaxed/simple; bh=v7srOjqtlI8zBYZmnnMlS0QgbQ1Xmte4f/J97QkvqTg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D82dvrZWK5Ksidbm6XjBX6brmbUJ/QHCHVYw/ZU1RpuFCrudHpZD7G2QNRLmflNIf3GwfoQRcvI1PAYnBejmhObgZTawKlUVcPLcJX2dLLvXzseqGiOv9kf5W1ZzfoTksUlDcQA5W1SWMO9XyGP6jrvIhwyDJvQBgEohd5cHYno= 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=O20y19dt; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O20y19dt" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20cdb889222so2661405ad.3; Wed, 30 Oct 2024 13:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730320663; x=1730925463; 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=LGjqz3SA0up6rh8S9ZVt9un5axwKXR+AKnW0GCRAI7Q=; b=O20y19dtdhDI6kglq776P/pNbLN19GXN/43JLdVHLoku4h3SGJzMRClZIy435H55zB DZi14uqBINJehv4dC95AAwwHaqZ2njI/adVbtqoJSTbW7pN+exLnD3/ANO3g2OgSo6ut nlgC+qsJVCwrBSbTvluxw8+6LNOoWXDHHm8wuqXMSdgQHSFo2GwUvm3hnCIkV4GoGPIe +4xiVqycApt6UJVlOEuMvD1oQ1Es4/W27BGI0VStirn/wRXo20PXam5CMoEUIcwkwYfB MfyRqPYy8yJxNPDs40jCg83KHHOrdZZJQnRU/QOq531mhDU3yM7E4UzGCf5zIBvINDWu KUSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730320663; x=1730925463; 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=LGjqz3SA0up6rh8S9ZVt9un5axwKXR+AKnW0GCRAI7Q=; b=kFlIEABlLhX/0NPbrjKzkiZjRUqh0zN2obTQTltjfo0nR+Hgn2TJ/PkKr82S2vVjz5 1utLae/juzu4+sZYeI8Wb6A/uh/yLgNNxeToE6nVdBR6B4w3gd/+ljuZHgUpOVF163KN +pzQBhjP9lKau3TROUGiXux/RKMJ3P2Hj0vY9tu7cC7KdlVEmumkVJzvoB8hsH3UQsg6 xp6DfnIV12IANptb8QxthxcZJTBI7hmcPInCSxo4zT4i0lTXaQ9FyGC6aUQGgwFgrq48 tNmuquFLUbSDzdxRA8281i95XZqzRxVebHWDvvjZkAVyUox8CAXOZA2VQ116anDZjFOJ fBSg== X-Forwarded-Encrypted: i=1; AJvYcCVuDhudri8/xgd2CZS60SXUAN+rqhOL+NoH8zzLDCI7vo73sEYRO+16PFIzJ3Gx6XIpx93thzl5+57qGVw=@vger.kernel.org X-Gm-Message-State: AOJu0YxG12KLpl+KsQr9vKQV4NcNcpZ45UBhOziFYFTubTJ3MdRadxbt wTDAfy22XirnI8VXq0jSfTRZeIdfwBrPkQS3cMF485Oltu1yQ3vDXN4G3w/v X-Google-Smtp-Source: AGHT+IHSGW6mlYFHi4beFpyKFuf1XvqIf1GRY23TFora9lQMdaXHvIU3Omdy765N7oJ8oOb05WQpAQ== X-Received: by 2002:a17:902:cf12:b0:20b:6d47:a3b0 with SMTP id d9443c01a7336-21103acdc86mr9831685ad.21.1730320662966; Wed, 30 Oct 2024 13:37:42 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211056ed85dsm40645ad.5.2024.10.30.13.37.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 13:37:42 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rosen Penev , Breno Leitao , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 05/12] net: ibm: emac: rgmii: use devm for mutex_init Date: Wed, 30 Oct 2024 13:37:20 -0700 Message-ID: <20241030203727.6039-6-rosenp@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030203727.6039-1-rosenp@gmail.com> References: <20241030203727.6039-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 seems that since inception, this driver never called mutex_destroy in _remove. Use devm to handle this automatically. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/rgmii.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ibm/emac/rgmii.c b/drivers/net/ethernet/i= bm/emac/rgmii.c index 7bafe2edfc50..9063f0a17e25 100644 --- a/drivers/net/ethernet/ibm/emac/rgmii.c +++ b/drivers/net/ethernet/ibm/emac/rgmii.c @@ -219,13 +219,17 @@ static int rgmii_probe(struct platform_device *ofdev) struct device_node *np =3D ofdev->dev.of_node; struct rgmii_instance *dev; struct resource regs; + int err; =20 dev =3D devm_kzalloc(&ofdev->dev, sizeof(struct rgmii_instance), GFP_KERNEL); if (!dev) return -ENOMEM; =20 - mutex_init(&dev->lock); + err =3D devm_mutex_init(&ofdev->dev, &dev->lock); + if (err) + return err; + dev->ofdev =3D ofdev; =20 if (of_address_to_resource(np, 0, ®s)) { --=20 2.47.0 From nobody Mon Nov 25 02:25:17 2024 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6407821791A; Wed, 30 Oct 2024 20:37:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320667; cv=none; b=YxW7NoZGJTjHWOGLUy/JCKFZZd4B6huGBKm5aOtcZQtJbvPuhedIxqfB+DL0mJXYKmjfpJ2nDnTxbLeOlPTCHu/8UI1hLr4a2UJTRzJqF/T0NUmgxDN+OjKqwrEdP0LAprvoT+wfaFbPd4JxMCx/7uiDSmV9+hvmndKYSlRj/LI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320667; c=relaxed/simple; bh=oUBWD/M0B0TffrY5t5Pz3/WjlPaOX+qXwTvhg8PD1rM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XXcHrp3UpsdgtiLFcWsSRQUHPR7lBkZQU0IMfnV/YI0m+uO/xvxjoT62GFnyBH6ph+edpRFue7/NPiR5bp1qem6oS1cLfv1O0AZhtep2rzkdS68hKvfyiWjgVn1jeH6p1JTS702mHwmpoRvi53aDLO/Kg4PZsaYwc1ZeW8zKGDo= 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=U1tt5xdk; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U1tt5xdk" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-20cb47387ceso2692575ad.1; Wed, 30 Oct 2024 13:37:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730320664; x=1730925464; 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=QY2wE+4G57UieRa9G7ux/y9sqS3sWK/jiT39IANX1qc=; b=U1tt5xdkeNhXK8KnPPVsZhl7kJOWg7tIC1KALMOY2MmmZk1UwPprlrYOyFQCQ/Be2/ UuwDsZGIV4DJg9FdHd79Rup80dUPKvSCoeD7ltASpX6jIYcwonB4G5nWfW31sIUyrPYY N8JQ4GFPGQ55TuAoD9Fm4ahKazgs50OfUOZfG/gv7za8DiOcw0Zv3EcRshHsOFaR/Gw4 2j+eEAvo6e+uEyBTuA7BQf1EXQPLzP5Mz9RM9LdScV+X438c2o3Pe9JVIiV/KCWkr0e5 3rzuPnfzj/fVVAlQD2v0LDJ7Xq7PD8/Z0k+OUeVvSA9wSs9J9qYJPfujLwin1XcQtjVI VTVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730320664; x=1730925464; 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=QY2wE+4G57UieRa9G7ux/y9sqS3sWK/jiT39IANX1qc=; b=f90w26r3OPyjboer6ko1Y8DjBSDU6Y/TmRx9brpfY1bKWt7f0eEahj/aLF/4nINRmC 9twhcrR7zTB53ockLE45WKFPbtC1zANr2V2rOdcoqs805ioc4l/o7semVTS58eIw7c8X qM1uTzSlcQYcGNm/Z+Pvtnt+iqHI3ycCPfHz4orqKVGpUNH95c2HjVRv6fV996baQv3G aw5Y6aYHa/XBlR0iB2xawcHxA2aQIvueX46RHSsdf25BklqtEttJl/gQ6huLpbsK6aYW rpb5KiiJhLscoXWAN5A/4yyddqTRcWYAdfoNal/A9bvkrsvDjvSrPuaPzGP1xnwQ/IGd k0yw== X-Forwarded-Encrypted: i=1; AJvYcCU1b/hRTZOjsFW/VKy0VSDzzBGECdw2mbhx2HrXtKyzHfTotR32Cx6u+xB2wFyROZanpyVLK4vt7I7I1Ws=@vger.kernel.org X-Gm-Message-State: AOJu0YyMsp5TrOCv/xUzUMVPG8vCC8kWGDV6f0OR7il5Pd106Leij/+v PXVVFH0cllH8tFtMs5aqzfGf8aDx2pvp/2dP700x2TCf0qR0qu/lzrxFZq2n X-Google-Smtp-Source: AGHT+IE9J6nQTVU2LrVa5XQfz+8m3vQ+uL64pSHNLHmM4jQ4i6yuIh1VkqYbiXmc7uZ8QIRtEcPJlA== X-Received: by 2002:a17:902:cec3:b0:20e:57c8:6ab3 with SMTP id d9443c01a7336-210c68739b0mr257368515ad.4.1730320664415; Wed, 30 Oct 2024 13:37:44 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211056ed85dsm40645ad.5.2024.10.30.13.37.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 13:37:44 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rosen Penev , Breno Leitao , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 06/12] net: ibm: emac: rgmii: devm_platform_get_resource Date: Wed, 30 Oct 2024 13:37:21 -0700 Message-ID: <20241030203727.6039-7-rosenp@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030203727.6039-1-rosenp@gmail.com> References: <20241030203727.6039-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" Simplifies the probe function by a bit and allows removing the _remove function such that devm now handles all cleanup. printk gets converted to dev_err as np is now gone. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/rgmii.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/rgmii.c b/drivers/net/ethernet/i= bm/emac/rgmii.c index 9063f0a17e25..b544dd8633b7 100644 --- a/drivers/net/ethernet/ibm/emac/rgmii.c +++ b/drivers/net/ethernet/ibm/emac/rgmii.c @@ -216,9 +216,7 @@ void *rgmii_dump_regs(struct platform_device *ofdev, vo= id *buf) =20 static int rgmii_probe(struct platform_device *ofdev) { - struct device_node *np =3D ofdev->dev.of_node; struct rgmii_instance *dev; - struct resource regs; int err; =20 dev =3D devm_kzalloc(&ofdev->dev, sizeof(struct rgmii_instance), @@ -232,16 +230,10 @@ static int rgmii_probe(struct platform_device *ofdev) =20 dev->ofdev =3D ofdev; =20 - if (of_address_to_resource(np, 0, ®s)) { - printk(KERN_ERR "%pOF: Can't get registers address\n", np); - return -ENXIO; - } - - dev->base =3D (struct rgmii_regs __iomem *)ioremap(regs.start, - sizeof(struct rgmii_regs)); - if (dev->base =3D=3D NULL) { - printk(KERN_ERR "%pOF: Can't map device registers!\n", np); - return -ENOMEM; + dev->base =3D devm_platform_ioremap_resource(ofdev, 0); + if (IS_ERR(dev->base)) { + dev_err(&ofdev->dev, "can't map device registers"); + return PTR_ERR(dev->base); } =20 /* Check for RGMII flags */ @@ -269,15 +261,6 @@ static int rgmii_probe(struct platform_device *ofdev) return 0; } =20 -static void rgmii_remove(struct platform_device *ofdev) -{ - struct rgmii_instance *dev =3D platform_get_drvdata(ofdev); - - WARN_ON(dev->users !=3D 0); - - iounmap(dev->base); -} - static const struct of_device_id rgmii_match[] =3D { { @@ -295,7 +278,6 @@ static struct platform_driver rgmii_driver =3D { .of_match_table =3D rgmii_match, }, .probe =3D rgmii_probe, - .remove =3D rgmii_remove, }; =20 int __init rgmii_init(void) --=20 2.47.0 From nobody Mon Nov 25 02:25:17 2024 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E719C218925; Wed, 30 Oct 2024 20:37:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320668; cv=none; b=socYxSU/hITFzyfSvPE7TOLt5YqLIh0oOj4D9Dmzv94VIPVGh/+RFEVoSjh7zrfaARCJsPzc2Ap1zW9/zzepjuqljFqj4+04loOEvkKByiKFN/eMo2wF5Q/JgWsAugAiW9fkSxR8WUfMNZShbmt3uoPxcnl+yqiR1EkH+WxQeq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320668; c=relaxed/simple; bh=+29W1hGAiiSPNBeHDHEL6mYe0YOrEjIjkU4LktL0Nk4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tdTWs0z7ckaGJxa38F1d0o7ftsBOJwWRaUvSnGJ7DdkAGDs2DQkDLbZ4lWMyXT3XVUFcRlaz0lyDH4yPDvE3lFI5wsq72Ql/duIBSombC9aet89H5mZe6JzTrHBA5+M5w6fsctE4Z9egt4K4Odn2R4r4so9mxqmAic8ydEj3DXA= 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=gvlgz9R9; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gvlgz9R9" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-20c805a0753so2813475ad.0; Wed, 30 Oct 2024 13:37:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730320666; x=1730925466; 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=7UNwU0Pp2g8R4kSmqpFNoaUX/T46EUzMVaC6ZnQkuv0=; b=gvlgz9R9Y13A7jshgz/5wuML82zyfJc+EYXYBEfLDLUePmTihDtxueCjNmXujYQoVQ sR8TgReTVlBMEvX1Ib7ownx23dIKxO3AL/0dygsQa5sSCmjBX3y1+nyqUIQs4L7mvCb0 mJQ1sSZQnQ0OUDhJIzSqZ+4g7DB2lnysAGkX4fkvhbkd1fIxRs3x0eLCMV4TfvuhDwpH QvVMS0bgnnBUrsmWnyd5I0hKeAs3v2F5siHcGAGHqmqIs+L46bocG0b2KGpha4p7Bf3K 73+kRYAqU+rfuGVP8fN4b/UWCdQEXSkxP2GgZMQ4Y2XnTCzzq9KMQydABRm2kBTwwVQb B+Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730320666; x=1730925466; 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=7UNwU0Pp2g8R4kSmqpFNoaUX/T46EUzMVaC6ZnQkuv0=; b=SGBliWme4RGrnm2StWusSKQf2XM875+h3l1ow4iHtguqxaXE+cCdPEbuO9MidT3inz fXH5tkaFeKdAJgSowMYxqnRrBS8Zgvbi1aBb0JFA1wbbS6+iehdwHTAC5LmO3Wr7x8n/ rIlJWLqc6zKUBMlaOihNdMWc5wjmfWK332Fg7i622znO17iAblW5YKTWfjzBDttK0FbS tGhun6w9XCexX84yt1IBXvkt1csB1yq0ZQ24ZUSf+LVoOypq6PZLPCYcfdSzyDt5ePDQ ahN/RofBr7daRNI0SdMx4TlExj1L9fjbH5VKrw2Me8qJw/2QOP+sXYc+erfw5HFi8yty TMOg== X-Forwarded-Encrypted: i=1; AJvYcCXOfIQhwDkSNxdSu7kr2RdxSqyK2451t7np28942cuRdZJNCJogkjWYU5fOqdr0amjyfBd+8y78cFaMT64=@vger.kernel.org X-Gm-Message-State: AOJu0Yw95glF3G2E94C2gM+w6S5AN/yUtNd2amOJkprrfE1jZD71srKr eeYQlOwdfquo94FV9uh+2QUmka7h1JTLDFK3UJ8+FX62LC/lJpdbqqG9R7n2 X-Google-Smtp-Source: AGHT+IFYUUgxNrDPxXSain3rNUQ/d87FHplCyGSIpV/m2lazGrVxfpG61SeBR7BIXFI9OEKT07OwSg== X-Received: by 2002:a17:903:1108:b0:20c:e262:2580 with SMTP id d9443c01a7336-210c6c3ffb6mr180712505ad.44.1730320665813; Wed, 30 Oct 2024 13:37:45 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211056ed85dsm40645ad.5.2024.10.30.13.37.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 13:37:45 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rosen Penev , Breno Leitao , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 07/12] net: ibm: emac: zmii: use devm for kzalloc Date: Wed, 30 Oct 2024 13:37:22 -0700 Message-ID: <20241030203727.6039-8-rosenp@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030203727.6039-1-rosenp@gmail.com> References: <20241030203727.6039-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" Simplifies the probe function by removing gotos. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/zmii.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/zmii.c b/drivers/net/ethernet/ib= m/emac/zmii.c index 03bab3f95fe4..e9097b9ceb3d 100644 --- a/drivers/net/ethernet/ibm/emac/zmii.c +++ b/drivers/net/ethernet/ibm/emac/zmii.c @@ -235,29 +235,26 @@ static int zmii_probe(struct platform_device *ofdev) struct device_node *np =3D ofdev->dev.of_node; struct zmii_instance *dev; struct resource regs; - int rc; =20 - rc =3D -ENOMEM; - dev =3D kzalloc(sizeof(struct zmii_instance), GFP_KERNEL); - if (dev =3D=3D NULL) - goto err_gone; + dev =3D devm_kzalloc(&ofdev->dev, sizeof(struct zmii_instance), + GFP_KERNEL); + if (!dev) + return -ENOMEM; =20 mutex_init(&dev->lock); dev->ofdev =3D ofdev; dev->mode =3D PHY_INTERFACE_MODE_NA; =20 - rc =3D -ENXIO; if (of_address_to_resource(np, 0, ®s)) { printk(KERN_ERR "%pOF: Can't get registers address\n", np); - goto err_free; + return -ENXIO; } =20 - rc =3D -ENOMEM; dev->base =3D (struct zmii_regs __iomem *)ioremap(regs.start, sizeof(struct zmii_regs)); - if (dev->base =3D=3D NULL) { + if (!dev->base) { printk(KERN_ERR "%pOF: Can't map device registers!\n", np); - goto err_free; + return -ENOMEM; } =20 /* We may need FER value for autodetection later */ @@ -271,11 +268,6 @@ static int zmii_probe(struct platform_device *ofdev) platform_set_drvdata(ofdev, dev); =20 return 0; - - err_free: - kfree(dev); - err_gone: - return rc; } =20 static void zmii_remove(struct platform_device *ofdev) @@ -285,7 +277,6 @@ static void zmii_remove(struct platform_device *ofdev) WARN_ON(dev->users !=3D 0); =20 iounmap(dev->base); - kfree(dev); } =20 static const struct of_device_id zmii_match[] =3D --=20 2.47.0 From nobody Mon Nov 25 02:25:17 2024 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24FFD218D62; Wed, 30 Oct 2024 20:37:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320669; cv=none; b=ZrxGPsmzhHlMV5YuEDLp7x1YyvsD+pawgTk8UpZdy5Hx9m1i7W1Drrw36Yui+UM2EpTfTxdw62l1nDwjKacc+Ji4J/5sLoAMn/3x9L5jUFCM/syilawqoeRQMRVCnEtI9tRtbri2Pt02DUU435DRd6OmGkMMBokktPlRDJAh0Kg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320669; c=relaxed/simple; bh=rCl9KUSKOelviF42N+RjutZ3gn8ll0dQ23dBMW+WlIo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FTtDmqWe0weMzAOBapE4OVNGo8F22c2rqpw5Da8YNkmX3QGOP3g/5my00RlMlQSh/5NDJ36N4H9lepo+OJzL3J2hje4oRpUFxjblqUbhQPpKcbtY46IVrgnIpMvdZ/srmy16aNWJDb/6C8rLkHAm8mi3sgR7H9r0JbaUGlWJeKM= 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=W0Hqg9vM; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W0Hqg9vM" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20cdb889222so2661865ad.3; Wed, 30 Oct 2024 13:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730320667; x=1730925467; 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=zLiQhACMTYsRCBHRriNGhiQgk9Pih5KygQx6n+YOD34=; b=W0Hqg9vMTgtjwed6QhQejZ7NpYi7mB6GgHHmy2HEMLgSMP1SLSv7zq9fdMSXa1IInu iqiemAbdi6HcYr+tvulSGqw2rHJFOP99pgcXFrDcLSd8jBM+aQXhMN+dvB1nK07y3Wk1 oaqTJAy93/Mvk8eWQuro09y85VINaNyA9MVn+salm1CBOaVMOlK0TB7b5wL7+1L6REC4 R/airSQyZ3S6+HQyE2kzvq2kDTTLQM92++kWl/jk6kJO9FZXqsBbq7L+lT5gseGqouna ejj8+8BQVOFyzhPS11WpN2+HjTu2tp0m34UK8a7A1Obpk1fCYJlW1uaSH99wq2lVIeWO 3hWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730320667; x=1730925467; 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=zLiQhACMTYsRCBHRriNGhiQgk9Pih5KygQx6n+YOD34=; b=fNrzfLpZH/f52mt2PZn/qOSFvVI8W2EfwrvtIJ69/9iPcpZXZvwAOz3muDUQlMKzMa 9M+LOaph+5Kg7pSzsItLGOD0oXVbv9M+ffyQk3g2ykn7a2R6NcsabWkLwrbMZ2vO9mtR 32PG1ToVecvD94jL1ldBZMbsvcGcnhU80H/fQzfhKayMAXg6YSUpX3hisPHHlKDiTm7D t3D4YwysAokMpCBCALSYsSJtRNi1thDoprzdGiyOuZllkPRfexpPN+l1Xrm3DNktPCzy Vdifg/H6FeiYXUvCn46wkldM6BxM89F1Awoa/WYSXzuQymmE9vA6l9R1PzmLQ3feCDRe rIgg== X-Forwarded-Encrypted: i=1; AJvYcCW/eSf0KaY8OwxJy5fTYKN30QpdEIgD+c0ggfqXVNe8Ug60kBiDsF9sNgovTGWmjPko1ICXH76JDkQutMw=@vger.kernel.org X-Gm-Message-State: AOJu0YzAN6Ac8btA+nyovsy5h7no+P2m4V0PRaU6wkm9ah3XymoD1pNw Lu6F4nNhxeEkupUaH0h1k5cqY/BiiwyAh+b6s4f61d5thWzufKxJmSd2f/bQ X-Google-Smtp-Source: AGHT+IEd+FXNwDj5VgJj3TSE8VWyd3/j+oKdoAK5NMAcab9IKqXGydMNJgIMmqKuG88zHnJ2xwtx3Q== X-Received: by 2002:a17:902:cf4c:b0:20b:7be8:8eb9 with SMTP id d9443c01a7336-21103c971c0mr7910975ad.54.1730320667235; Wed, 30 Oct 2024 13:37:47 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211056ed85dsm40645ad.5.2024.10.30.13.37.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 13:37:46 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rosen Penev , Breno Leitao , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 08/12] net: ibm: emac: zmii: use devm for mutex_init Date: Wed, 30 Oct 2024 13:37:23 -0700 Message-ID: <20241030203727.6039-9-rosenp@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030203727.6039-1-rosenp@gmail.com> References: <20241030203727.6039-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 seems that since inception, this driver never called mutex_destroy in _remove. Use devm to handle this automatically. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/zmii.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ibm/emac/zmii.c b/drivers/net/ethernet/ib= m/emac/zmii.c index e9097b9ceb3d..cb57c960b34d 100644 --- a/drivers/net/ethernet/ibm/emac/zmii.c +++ b/drivers/net/ethernet/ibm/emac/zmii.c @@ -235,13 +235,17 @@ static int zmii_probe(struct platform_device *ofdev) struct device_node *np =3D ofdev->dev.of_node; struct zmii_instance *dev; struct resource regs; + int err; =20 dev =3D devm_kzalloc(&ofdev->dev, sizeof(struct zmii_instance), GFP_KERNEL); if (!dev) return -ENOMEM; =20 - mutex_init(&dev->lock); + err =3D devm_mutex_init(&ofdev->dev, &dev->lock); + if (err) + return err; + dev->ofdev =3D ofdev; dev->mode =3D PHY_INTERFACE_MODE_NA; =20 --=20 2.47.0 From nobody Mon Nov 25 02:25:17 2024 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AE2E2139A2; Wed, 30 Oct 2024 20:37:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320671; cv=none; b=s6ZExe29yAnG/O/WKl8g3uheCTdFmenWiDgLpHeEPw1FfwFxxLZ2uk7b0YdAmGY2hePlO3UA+4KA39UBtoLRHh+u281c2rOStV08oum2C/gMV58WxATO37CoFI3SfrcffSY+UwDXp9rBVYVfcXOvLaTP5JHqT2C9dRlWKmkp84s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320671; c=relaxed/simple; bh=Q7rnMMxa/pvWqWYaaxB3zFX1k6+sjf9uJXOd0B/QvXE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rrmMqpp0jQsT0F4KcYZOYfthJXBF5X4E83VKXrCBimuHCxiwfCoJLfEU9dvRYlccIjK2y7ZqgSiZjxPgz3gRrdU2DqHy4SvNp3vayiNQNgh9ZH95FvMdzHcuTQg+iLSVmR8IiLWbyOA06yCTsEnMgVuTrrbGxcuGnb8PtCE9G18= 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=FGF/ZFNB; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FGF/ZFNB" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20e6981ca77so2923345ad.2; Wed, 30 Oct 2024 13:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730320668; x=1730925468; 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=CIpfNz/rRY9sLm3UcQVmGGrsDelYAZ0JJmvbVWZ2784=; b=FGF/ZFNBw2N2x+T8lfsOdfChQb7JMCClJOBWaywYIsUa80jjYDwdxp9CLO9IEpWol5 un4WgfKztxt9GyNg5DStLldArXaSRKNgaEU4Vct8NLq9MI2hVCVYqaUhB4/Ijy8oRLsL tmuN6mRlpIhhhEvlO2+9RHa7W3+PCq5MFICMzz6L4u7VxTBmKZyd8Acbkm6FBX4NqqVX mbq6qnhh+V6VDOvpItyePrQyRKGPfXKjegDsgzhtd3cYGsOvapmqUQVmXVfE/HXhjIAk s4WeB5mEse6CsZgAUp0iNRzO+lof9bWo8uMglAaCgK6uAFdZYl/LvSCfntqkqbR/WMPH 86XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730320668; x=1730925468; 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=CIpfNz/rRY9sLm3UcQVmGGrsDelYAZ0JJmvbVWZ2784=; b=snbN/38ph1VfAos7eAlkusyVMaxYsDdKWPcE9eHJQifaM4+cjsweiqYeBUHdo9Ue0O IREOoEKQZXAF78xyTf5eDctK4CHKTHWaAuzoRJm+KAEdotaJfs3RHCzrbcEKBFmcWODn sQXeVRkyozTKucPzHaJCl6TKE862dfpouPiesC9JjZTvV80TGesfuN8ZGnN/wTrOZnAE E27cHSWZ1vKO/Bru1mQno+VT7GMjLT3yHKPb9aJ0+tvNhfEBBDTfTaGG3GkwE88pxKLS Zvc2AXgyY6OyKiSFjjjiokzIoOoWclxXk1Dl1TKh3nNjWNk/LaSN3U6TMO0alPtTJomU RUpw== X-Forwarded-Encrypted: i=1; AJvYcCUlmZpOB0a7TbWTiZqRi/Xn3agwhykYafW4mKgPvpgsRzFvwJAbYRMkEbq3LjaiWoAnCw0oz8tujkoulL0=@vger.kernel.org X-Gm-Message-State: AOJu0Yx52DuPEIQzk+eMFyJD6GsROgxU/hHe1pTqU8z5K2cmOdo/lwwb 1PHIPESv+nO/56qbEIar+g06zkwdUreGDF2cS4p4Md9Fvwub8ttAC1f9IEgH X-Google-Smtp-Source: AGHT+IHBvENisdwEiQtDJivAouMTS01+pVIhmfTqy5w4GQXQm63+Gkmh38WH6n7msfnf3u2xto7ltw== X-Received: by 2002:a17:903:2286:b0:20c:5fd7:d71 with SMTP id d9443c01a7336-21103ace2aemr10627135ad.22.1730320668561; Wed, 30 Oct 2024 13:37:48 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211056ed85dsm40645ad.5.2024.10.30.13.37.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 13:37:48 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rosen Penev , Breno Leitao , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 09/12] net: ibm: emac: zmii: devm_platform_get_resource Date: Wed, 30 Oct 2024 13:37:24 -0700 Message-ID: <20241030203727.6039-10-rosenp@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030203727.6039-1-rosenp@gmail.com> References: <20241030203727.6039-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" Simplifies the probe function by a bit and allows removing the _remove function such that devm now handles all cleanup. printk gets converted to dev_err as np is now gone. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/zmii.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/zmii.c b/drivers/net/ethernet/ib= m/emac/zmii.c index cb57c960b34d..69ca6065de1c 100644 --- a/drivers/net/ethernet/ibm/emac/zmii.c +++ b/drivers/net/ethernet/ibm/emac/zmii.c @@ -232,9 +232,7 @@ void *zmii_dump_regs(struct platform_device *ofdev, voi= d *buf) =20 static int zmii_probe(struct platform_device *ofdev) { - struct device_node *np =3D ofdev->dev.of_node; struct zmii_instance *dev; - struct resource regs; int err; =20 dev =3D devm_kzalloc(&ofdev->dev, sizeof(struct zmii_instance), @@ -249,16 +247,10 @@ static int zmii_probe(struct platform_device *ofdev) dev->ofdev =3D ofdev; dev->mode =3D PHY_INTERFACE_MODE_NA; =20 - if (of_address_to_resource(np, 0, ®s)) { - printk(KERN_ERR "%pOF: Can't get registers address\n", np); - return -ENXIO; - } - - dev->base =3D (struct zmii_regs __iomem *)ioremap(regs.start, - sizeof(struct zmii_regs)); - if (!dev->base) { - printk(KERN_ERR "%pOF: Can't map device registers!\n", np); - return -ENOMEM; + dev->base =3D devm_platform_ioremap_resource(ofdev, 0); + if (IS_ERR(dev->base)) { + dev_err(&ofdev->dev, "can't map device registers"); + return PTR_ERR(dev->base); } =20 /* We may need FER value for autodetection later */ @@ -274,15 +266,6 @@ static int zmii_probe(struct platform_device *ofdev) return 0; } =20 -static void zmii_remove(struct platform_device *ofdev) -{ - struct zmii_instance *dev =3D platform_get_drvdata(ofdev); - - WARN_ON(dev->users !=3D 0); - - iounmap(dev->base); -} - static const struct of_device_id zmii_match[] =3D { { @@ -301,7 +284,6 @@ static struct platform_driver zmii_driver =3D { .of_match_table =3D zmii_match, }, .probe =3D zmii_probe, - .remove =3D zmii_remove, }; =20 int __init zmii_init(void) --=20 2.47.0 From nobody Mon Nov 25 02:25:17 2024 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFD43219C88; Wed, 30 Oct 2024 20:37:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320672; cv=none; b=czsAms/a1oUM3sni7CH7ZvVxH2RAWfI4G4PXt+IsvuP2BLnqmXC+cAevd8U6KbF3hPTav0VTFxmCxlxEs301afAmpTGhoeDO/WG7zkQ+U0EwS2je277ydE1PPqcEZH6lE6GQN9nrJAtpFC63KmGWVtrxknpJI6QNka80iIUYU5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320672; c=relaxed/simple; bh=Pippea4A0H/5O0N0+1LmmcHeawuPIfLMq79gNqGFIEg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SeUTUaW6i/Io9lyV6wLrjd76YUZOQmy3sKJ7WLpqs6gBpj1OaV9H/aQcXrC91HDxOg4ldbe3QEpO2tAGeC2NDu0fCDw6sM7jzyNQSEFa+nUyrp8qc1X4g/bfk7EibtAtm3weWJ+7ZY2ayZAxi/l5idnkaWl+RvQWK/nBObmxfXY= 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=l0aKRU7u; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l0aKRU7u" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-20cbca51687so2662885ad.1; Wed, 30 Oct 2024 13:37:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730320670; x=1730925470; 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=FexutNNiNogmeYOctg/LStxLING3hlfbG5xuaoCRTR4=; b=l0aKRU7u18SmSalbSZPqREU0Q5M7Tp9HdzhPSnticY6rtzOH8qqZ0h817qRKNt/BTK zOJAOGHsDj5pV780Bz8O4wPSLZcbKjAeDaIYLrftEBRhgMlYcSFcm3P99LwW+jQd63+U fs6l48HMbvA7Wv+fvunHf8L2AMMHaZxIMD+VqugrA9WK1N7gu+Pyf7VhYO9H9axEZE9A KaEmzf4R+gzGAj3894MWThQhLRdgv2gZ7/9eYo3ivU5HzehRbjxc8805jGeZV0bsp3wq 8Q8xc0ihcY2DBmD/sVOdpziptroRCCBR7+KwpZSrq3h7h1o6Fc1P5RDvNEjx5A8go/Zu bNfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730320670; x=1730925470; 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=FexutNNiNogmeYOctg/LStxLING3hlfbG5xuaoCRTR4=; b=hTvra9lnnxOH/OQQSXmiFuMoyP6UaeCmuYHipmZEnrTLO4XVvA53ZyjdgS/hXk8wFy 5xoAHeVcaL2b+O/UO6ITvfRcT/o9vnsFkWK3fvcYcKAJc+I8FpSNpFo2bSu8u6Ufgqzl ymirafOkjv3jgQWK1K8qoNJePop5Jno/BT0pfpkfXqLYAfQ/Vh2TF/ws0JiLaLwNDkfX Uy3uvmwUwKoEOfcn27TwQ3FO2MfbJuDGzrDXVBHhWkfpXmfxUF8ovl0gS4GkBjkMA6fJ Y1gk98SPn2FogtBteE84UsDhnluugOvA0fUNphNms5RjHpGqpvHDNKANVYRq3/IDHTKw f4Hg== X-Forwarded-Encrypted: i=1; AJvYcCWGcCujQFh1EFusgR/2WLszWRnJuMzJSUAvGIAWYAJ/b5c9B1bfZ8aIN2qnB7wVMURHK+kJoupqWSGNaQk=@vger.kernel.org X-Gm-Message-State: AOJu0YzMKCl6WxMuzZrcyy5v/zqSZRJJAVmocmCBS4zhNaW0Qm66GeHf ybW5leHsOGx3X+OeCLBZEz31sIy3aXrXs9jTQQaKN8cJZmCrNXFTpZjNv5+K X-Google-Smtp-Source: AGHT+IFD7vdoW72C+WLtt6VoJCNQSDzctDbRK+J1vSlX514kcP7Pnoagz8rZLd9TehylYidOrhF5Cw== X-Received: by 2002:a17:902:f64e:b0:20c:ef81:db with SMTP id d9443c01a7336-210c6c01188mr222383835ad.28.1730320669927; Wed, 30 Oct 2024 13:37:49 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211056ed85dsm40645ad.5.2024.10.30.13.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 13:37:49 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rosen Penev , Breno Leitao , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 10/12] net: ibm: emac: mal: use devm for kzalloc Date: Wed, 30 Oct 2024 13:37:25 -0700 Message-ID: <20241030203727.6039-11-rosenp@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030203727.6039-1-rosenp@gmail.com> References: <20241030203727.6039-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" Simplifies the probe function by removing gotos. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/mal.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/mal.c b/drivers/net/ethernet/ibm= /emac/mal.c index c634534710d9..f1f5e805ebba 100644 --- a/drivers/net/ethernet/ibm/emac/mal.c +++ b/drivers/net/ethernet/ibm/emac/mal.c @@ -524,7 +524,8 @@ static int mal_probe(struct platform_device *ofdev) unsigned long irqflags; irq_handler_t hdlr_serr, hdlr_txde, hdlr_rxde; =20 - mal =3D kzalloc(sizeof(struct mal_instance), GFP_KERNEL); + mal =3D devm_kzalloc(&ofdev->dev, sizeof(struct mal_instance), + GFP_KERNEL); if (!mal) return -ENOMEM; =20 @@ -539,8 +540,7 @@ static int mal_probe(struct platform_device *ofdev) printk(KERN_ERR "mal%d: can't find MAL num-tx-chans property!\n", index); - err =3D -ENODEV; - goto fail; + return -ENODEV; } mal->num_tx_chans =3D prop[0]; =20 @@ -549,8 +549,7 @@ static int mal_probe(struct platform_device *ofdev) printk(KERN_ERR "mal%d: can't find MAL num-rx-chans property!\n", index); - err =3D -ENODEV; - goto fail; + return -ENODEV; } mal->num_rx_chans =3D prop[0]; =20 @@ -558,15 +557,13 @@ static int mal_probe(struct platform_device *ofdev) if (dcr_base =3D=3D 0) { printk(KERN_ERR "mal%d: can't find DCR resource!\n", index); - err =3D -ENODEV; - goto fail; + return -ENODEV; } mal->dcr_host =3D dcr_map(ofdev->dev.of_node, dcr_base, 0x100); if (!DCR_MAP_OK(mal->dcr_host)) { printk(KERN_ERR "mal%d: failed to map DCRs !\n", index); - err =3D -ENODEV; - goto fail; + return -ENODEV; } =20 if (of_device_is_compatible(ofdev->dev.of_node, "ibm,mcmal-405ez")) { @@ -711,9 +708,6 @@ static int mal_probe(struct platform_device *ofdev) free_netdev(mal->dummy_dev); fail_unmap: dcr_unmap(mal->dcr_host, 0x100); - fail: - kfree(mal); - return err; } =20 @@ -746,10 +740,9 @@ static void mal_remove(struct platform_device *ofdev) =20 dma_free_coherent(&ofdev->dev, sizeof(struct mal_descriptor) * - (NUM_TX_BUFF * mal->num_tx_chans + - NUM_RX_BUFF * mal->num_rx_chans), mal->bd_virt, - mal->bd_dma); - kfree(mal); + (NUM_TX_BUFF * mal->num_tx_chans + + NUM_RX_BUFF * mal->num_rx_chans), + mal->bd_virt, mal->bd_dma); } =20 static const struct of_device_id mal_platform_match[] =3D --=20 2.47.0 From nobody Mon Nov 25 02:25:17 2024 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D7AC219CB8; Wed, 30 Oct 2024 20:37:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320674; cv=none; b=RX0xiz3qDR9te93VqdgWLmymUqvx4RF5AqcmUpyXOxw32aYo3pkr5awKSmsO2omVPtrpIKpqZGVmh9Jye2rvCNau86Ki4TeDxZGJVmzSS05J615oQFZ5jmEt0zLcrN4tmPE8tocCRNqecGkJCMRQfMzgI4sEaN1ohaxjGqrqvRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320674; c=relaxed/simple; bh=/K5++S38XfNOZWH6vhXti7vJhwOaQ5IyE0gLS3qtgeQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DYPmWxj9fVxCquI+y6WPWe+w3w9WKG4Yx497+rk7+wqDXcNgNZaWcKGcMDRNQRkVO5JGVmu95kMet5vqkQr76PVNVWfRcW0WmnGVKUHSNXTYZQsp+eNSzgRhP80WJVdv3N9lvJ8f3/hg73l/pv3vaFpfZRpMR9f0P6LypSzTPK0= 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=D37XqUCf; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D37XqUCf" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20e6981ca77so2923645ad.2; Wed, 30 Oct 2024 13:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730320671; x=1730925471; 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=2VAXIt8AhQYwCN28Cvrq4oXREVihAdW454RUv6EGuGI=; b=D37XqUCfbDkkFHu2WHy4I4HcjUtNkxBUSPQMo61KQiKw9pV/IKna7W3ixT7vYcdFj4 1t6EnDjJqoF3ADtX+Kq1jeIY8b6okjyEQyzcmuRQOCm6b7Z/RDwCOh41UMaPIpcXwshO UV5c9QH3n89D5RgcFGicq0LJIKAhphI52U6fzrkhNUrEv77uQDLpOp5vlXfh2Igs6E4U cw3nSYj9do5KUKwAHUwDEMYfcCf9gMHVfiVYMElA6Gskz66vsXFCCmYA1pAM62AJ2+kX Zg/wmC89ai11tjb2l08IzoQv0Fsxt9/jQK2dQHVg31qTlxvAf+dg9chamX46TbjkR/VL DOxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730320671; x=1730925471; 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=2VAXIt8AhQYwCN28Cvrq4oXREVihAdW454RUv6EGuGI=; b=C3ZPM0q1MomIGM7GGznGU5bCTb+aoFaccYkzCM7uENC73aKsvQViCrRIqnkXOY561G lfoJVIzqZedwYvy4Etz6tNGs7DDA4P/zhEfRrPTd8x78fBnAcguutit1zQV2+cr0N8vE YiZiKkkloUCynDJ6jJgYbd59A0KdSXmyj32N421/rpSieqf4Patw9axVtGlekZRTZ+nR r+4pLUBSVEbzg+AiGPZB8NjxAolJsQkWDvFw65KGc4pbiVy8ECbWGFU0wiO7PLE9sDZM ysowozZ9rq+T9PmPvNcZ2zycYPWa9h/xOS+mwP8lKYf8DSNhHg3CIk3tMg9bz2iWJ6uE BHIA== X-Forwarded-Encrypted: i=1; AJvYcCWmRNxSnk3m86EzYufPrzWx8VJN0i42taWKIFvdiQSeQfpSWz1Ky4maO3wBzk8b2BMQ5oJtwaalKiu96vI=@vger.kernel.org X-Gm-Message-State: AOJu0YzzV9xTBd+TMJOMnTI+EisGCmBf7zSp/PVzulZPhtxi6V2q7hd9 p63trEtdqqMu6zpaf96oRITFSgSvCQtnIbmysXc/1heNzNHolJqlpj1U4Bkt X-Google-Smtp-Source: AGHT+IFuVNdOWXsLmAfg6Yrfd5gyDTk3V7xa+havLkLzGaWG+VTUxYHZ1o3gc/txY1FyrH7kQ7sP5A== X-Received: by 2002:a17:902:ea0a:b0:20c:b876:b4eb with SMTP id d9443c01a7336-21103ca9ebemr8403085ad.59.1730320671355; Wed, 30 Oct 2024 13:37:51 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211056ed85dsm40645ad.5.2024.10.30.13.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 13:37:51 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rosen Penev , Breno Leitao , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 11/12] net: ibm: emac: mal: use devm for request_irq Date: Wed, 30 Oct 2024 13:37:26 -0700 Message-ID: <20241030203727.6039-12-rosenp@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030203727.6039-1-rosenp@gmail.com> References: <20241030203727.6039-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 manual frees. Also replaced irq_of_parse_and_map with platform_get_irq since it's simpler and does the same thing. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/mal.c | 51 ++++++++++++----------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/mal.c b/drivers/net/ethernet/ibm= /emac/mal.c index f1f5e805ebba..db9faac21317 100644 --- a/drivers/net/ethernet/ibm/emac/mal.c +++ b/drivers/net/ethernet/ibm/emac/mal.c @@ -579,19 +579,19 @@ static int mal_probe(struct platform_device *ofdev) #endif } =20 - mal->txeob_irq =3D irq_of_parse_and_map(ofdev->dev.of_node, 0); - mal->rxeob_irq =3D irq_of_parse_and_map(ofdev->dev.of_node, 1); - mal->serr_irq =3D irq_of_parse_and_map(ofdev->dev.of_node, 2); + mal->txeob_irq =3D platform_get_irq(ofdev, 0); + mal->rxeob_irq =3D platform_get_irq(ofdev, 1); + mal->serr_irq =3D platform_get_irq(ofdev, 2); =20 if (mal_has_feature(mal, MAL_FTR_COMMON_ERR_INT)) { mal->txde_irq =3D mal->rxde_irq =3D mal->serr_irq; } else { - mal->txde_irq =3D irq_of_parse_and_map(ofdev->dev.of_node, 3); - mal->rxde_irq =3D irq_of_parse_and_map(ofdev->dev.of_node, 4); + mal->txde_irq =3D platform_get_irq(ofdev, 3); + mal->rxde_irq =3D platform_get_irq(ofdev, 4); } =20 - if (!mal->txeob_irq || !mal->rxeob_irq || !mal->serr_irq || - !mal->txde_irq || !mal->rxde_irq) { + if (mal->txeob_irq < 0 || mal->rxeob_irq < 0 || mal->serr_irq < 0 || + mal->txde_irq < 0 || mal->rxde_irq < 0) { printk(KERN_ERR "mal%d: failed to map interrupts !\n", index); err =3D -ENODEV; @@ -661,21 +661,26 @@ static int mal_probe(struct platform_device *ofdev) hdlr_rxde =3D mal_rxde; } =20 - err =3D request_irq(mal->serr_irq, hdlr_serr, irqflags, "MAL SERR", mal); + err =3D devm_request_irq(&ofdev->dev, mal->serr_irq, hdlr_serr, irqflags, + "MAL SERR", mal); if (err) goto fail2; - err =3D request_irq(mal->txde_irq, hdlr_txde, irqflags, "MAL TX DE", mal); + err =3D devm_request_irq(&ofdev->dev, mal->txde_irq, hdlr_txde, irqflags, + "MAL TX DE", mal); if (err) - goto fail3; - err =3D request_irq(mal->txeob_irq, mal_txeob, 0, "MAL TX EOB", mal); + goto fail2; + err =3D devm_request_irq(&ofdev->dev, mal->txeob_irq, mal_txeob, 0, + "MAL TX EOB", mal); if (err) - goto fail4; - err =3D request_irq(mal->rxde_irq, hdlr_rxde, irqflags, "MAL RX DE", mal); + goto fail2; + err =3D devm_request_irq(&ofdev->dev, mal->rxde_irq, hdlr_rxde, irqflags, + "MAL RX DE", mal); if (err) - goto fail5; - err =3D request_irq(mal->rxeob_irq, mal_rxeob, 0, "MAL RX EOB", mal); + goto fail2; + err =3D devm_request_irq(&ofdev->dev, mal->rxeob_irq, mal_rxeob, 0, + "MAL RX EOB", mal); if (err) - goto fail6; + goto fail2; =20 /* Enable all MAL SERR interrupt sources */ set_mal_dcrn(mal, MAL_IER, MAL_IER_EVENTS); @@ -694,14 +699,6 @@ static int mal_probe(struct platform_device *ofdev) =20 return 0; =20 - fail6: - free_irq(mal->rxde_irq, mal); - fail5: - free_irq(mal->txeob_irq, mal); - fail4: - free_irq(mal->txde_irq, mal); - fail3: - free_irq(mal->serr_irq, mal); fail2: dma_free_coherent(&ofdev->dev, bd_size, mal->bd_virt, mal->bd_dma); fail_dummy: @@ -726,12 +723,6 @@ static void mal_remove(struct platform_device *ofdev) "mal%d: commac list is not empty on remove!\n", mal->index); =20 - free_irq(mal->serr_irq, mal); - free_irq(mal->txde_irq, mal); - free_irq(mal->txeob_irq, mal); - free_irq(mal->rxde_irq, mal); - free_irq(mal->rxeob_irq, mal); - mal_reset(mal); =20 free_netdev(mal->dummy_dev); --=20 2.47.0 From nobody Mon Nov 25 02:25:17 2024 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 879C221A6F2; Wed, 30 Oct 2024 20:37:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320675; cv=none; b=NX3r73j4qolWVj4oIjSPInqhgxitoCz9qHrKNPo33TfkzIHVg6aqQxkA7jX9PbQEHtLlke5BWMjpjFUILZQTzGDEb17aNR5yIhnXmYIM963LlrsC0H2uflD1w3t2/4afM+fg6qiTJFzjn8gOMrF1HwRdOB079XV9gQgnz5VZLkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730320675; c=relaxed/simple; bh=39rMKr6P9uONlLHbEfUR52r0/BVHxtYYU2jmy++PC6M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rr5W++66ezVycV7HBei6y9rK/lfthP+2vi+DS2MF8lw9J50Ah09oCgW/NDag+lbS3Gwt+75p1AFTGqfGd24NCTzZbOmTJLXcUG/VZLg2BciVlXhSzGbvTqdZauTNuElPUSK/u52lShVsOnzoac26dup4yTVrK0EjkTbma4x5bu8= 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=DCzsT5cB; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DCzsT5cB" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-20cf3e36a76so2894395ad.0; Wed, 30 Oct 2024 13:37:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730320673; x=1730925473; 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=JPFQQ5MQ7iFYLKfJ1x4ney8Y6u5IyairNMMG2cxgXZ4=; b=DCzsT5cBQr3DcOHrd18DRIsfFUBQ8abM2ajhvbRxP/o9z234zyNR9fo3cby/pR8IfK XFYMgtG1lzChjudn87jB1sQi4MRbk8Dqns5D/DCTyqg42OhOSbzua4Axc2bYoAMkeap8 1W2RLmSV9A8rrwL8eNu2p9APG7PgafIohDZkvQ+6I+3+HZ0o0JWd+Ft4HNJbmdu0nE7B Sd1tu5+adxzGiZYGMsJTS0A4JcO2BzQboc1NwcAkpsiZm4IlYkiurXr6QqCslSVlT1ND sHo6TmbMBujIR0QucBjY2/0F5mlBYQQX7ILCA0PTgDDSfCxs5h6B/zzg681aGwfleXSY QzpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730320673; x=1730925473; 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=JPFQQ5MQ7iFYLKfJ1x4ney8Y6u5IyairNMMG2cxgXZ4=; b=hvsSOQQFN0YpjhOSHCai2cN5uSw2orkHOQ8+fzw8N/Xk20De3ixFfnXlpTCBW/+GAJ h2QJhJcLISelbpUaKxeCcSeeV80Sh8pPCHweOA59zWoUeKTo+PFaN7p7uouoh+wglJni 41QGHN3lWG3pi9SlvRg+ukjGq6rhDXXu/N9PUkRL7S8kjX97CAbVInYDE7TXFF4zQtd4 Nho06QT0lihjWozy1ow9aCUItWcGXXaIFylC7FIAQ1tJg7lBSMKDn5wr12UwYiOLwXPc kUqid7aejKkZHkuHN/KdZ553l07Casdp0tFW4MGvMEaqv9THk/hHcedKZf4GGwk2Ykb9 wV5w== X-Forwarded-Encrypted: i=1; AJvYcCV1guyZkiFkPRM5m3g0bbTd++BE8eyxiYwvgHCg9mmEY2lUPwF8JITGbIRSlyGcbqkB4MXRSYWGxAmKYi4=@vger.kernel.org X-Gm-Message-State: AOJu0YxM5WELAYudwT0aKUvYEGulJcCv3wDcibq8RrM1fCaeY4hRZUFv uncjIYu6BO6z/b8TxIRizg6LBoZ//wnuu7Erdga26GisBMgj0jFYCU4LUCNv X-Google-Smtp-Source: AGHT+IFobBB1rfzr/+5jKe4ndgUF5+rHGgIxZ1WnI+e7DYKZ2V1e62pB8MZnyKc6sZ4FgndvJ3yKzA== X-Received: by 2002:a17:903:32cb:b0:20b:6f02:b4e5 with SMTP id d9443c01a7336-21103aaa7d3mr10575605ad.9.1730320672695; Wed, 30 Oct 2024 13:37:52 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211056ed85dsm40645ad.5.2024.10.30.13.37.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 13:37:52 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rosen Penev , Breno Leitao , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 12/12] net: ibm: emac: mal: move irq maps down Date: Wed, 30 Oct 2024 13:37:27 -0700 Message-ID: <20241030203727.6039-13-rosenp@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030203727.6039-1-rosenp@gmail.com> References: <20241030203727.6039-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" Moves the handling right before they are used and allows merging a branch. Also get rid of the error handling as devm_request_irq can handle that. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/mal.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/mal.c b/drivers/net/ethernet/ibm= /emac/mal.c index db9faac21317..7d70056e9008 100644 --- a/drivers/net/ethernet/ibm/emac/mal.c +++ b/drivers/net/ethernet/ibm/emac/mal.c @@ -579,25 +579,6 @@ static int mal_probe(struct platform_device *ofdev) #endif } =20 - mal->txeob_irq =3D platform_get_irq(ofdev, 0); - mal->rxeob_irq =3D platform_get_irq(ofdev, 1); - mal->serr_irq =3D platform_get_irq(ofdev, 2); - - if (mal_has_feature(mal, MAL_FTR_COMMON_ERR_INT)) { - mal->txde_irq =3D mal->rxde_irq =3D mal->serr_irq; - } else { - mal->txde_irq =3D platform_get_irq(ofdev, 3); - mal->rxde_irq =3D platform_get_irq(ofdev, 4); - } - - if (mal->txeob_irq < 0 || mal->rxeob_irq < 0 || mal->serr_irq < 0 || - mal->txde_irq < 0 || mal->rxde_irq < 0) { - printk(KERN_ERR - "mal%d: failed to map interrupts !\n", index); - err =3D -ENODEV; - goto fail_unmap; - } - INIT_LIST_HEAD(&mal->poll_list); INIT_LIST_HEAD(&mal->list); spin_lock_init(&mal->lock); @@ -651,10 +632,17 @@ static int mal_probe(struct platform_device *ofdev) sizeof(struct mal_descriptor) * mal_rx_bd_offset(mal, i)); =20 + mal->txeob_irq =3D platform_get_irq(ofdev, 0); + mal->rxeob_irq =3D platform_get_irq(ofdev, 1); + mal->serr_irq =3D platform_get_irq(ofdev, 2); + if (mal_has_feature(mal, MAL_FTR_COMMON_ERR_INT)) { + mal->txde_irq =3D mal->rxde_irq =3D mal->serr_irq; irqflags =3D IRQF_SHARED; hdlr_serr =3D hdlr_txde =3D hdlr_rxde =3D mal_int; } else { + mal->txde_irq =3D platform_get_irq(ofdev, 3); + mal->rxde_irq =3D platform_get_irq(ofdev, 4); irqflags =3D 0; hdlr_serr =3D mal_serr; hdlr_txde =3D mal_txde; --=20 2.47.0