Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5478104pxb; Wed, 26 Jan 2022 13:00:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRdoLSQWSXk3hmlKzdefAAxOud7xWdUrdTdKJyzpVIXH+cbQhk+N6JL8KMseh8DM4o0IKf X-Received: by 2002:a63:184a:: with SMTP id 10mr446026pgy.609.1643230815687; Wed, 26 Jan 2022 13:00:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643230815; cv=none; d=google.com; s=arc-20160816; b=rgi3E3e37E8v0tpe7oBqkw43eyKa4bGUGkXjSPxjisttFLW3JOelvcSw2n6lJEmQo6 8u1sOH2ZYNBrx8yWbdilvCBU4wSkHWg+XoEEq51SLfxDkGiiZx/FFeGZCkFT/qu6I1Mx r1bBOFjflAV+24+l2rUARg8VBES+kbjXrKNsxozq9E0omx674ptLxzyBsSZAOYgHApV9 2/cPoq8QHREsFVpaFnJRj1UgD5HAhLlivLCg0kZeG3TdeXeGJXlsnLXzKn38iLQYBaEy K/EFbWJtklHs8ScrSY8cFdTZUR88skGpJ7j1E0F4B6fmJt8SgICeoONImpvEekZ5hNHU S+KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/mvM51A5cZB1/LP8bxdtukBhEKxdmFmIE0WYJdIBCJA=; b=Qo3E2pLPMqe+dSRGhHQugiA2F03BI93qKycbW9xFpoUpvWWZWdkBVg0hJV1wYR5cQp eIOwJ69JyI5237vVwsxVWuaw9iVfGmDiK2QOZRMJzoJlpIoYS2wSRs1/DOeRV0auBe6u J5POjRHYGoqcqAQP94oW8CQgUFdQDdxK3DYN8co3Yv0RHhFXPQwz+5A3jUxxtut8mUoY wZmS3DM2MYaZTZCP/AErNLYl9pVXUN2pqwPGx325XE0f5Q4cytbFN+YAzKshP01pXl6c fzkFKj1zYcrlh0cO9rj1+xDo4y5jFm/IJD1kS4pCoGJR+1CyAtA+9uFf3+9J9xs+xusS 7+ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@waldekranz-com.20210112.gappssmtp.com header.s=20210112 header.b=mvIP15AW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v8si287836pgi.789.2022.01.26.13.00.03; Wed, 26 Jan 2022 13:00:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@waldekranz-com.20210112.gappssmtp.com header.s=20210112 header.b=mvIP15AW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239740AbiAZKOz (ORCPT + 99 others); Wed, 26 Jan 2022 05:14:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239733AbiAZKOw (ORCPT ); Wed, 26 Jan 2022 05:14:52 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F6DBC061747 for ; Wed, 26 Jan 2022 02:14:52 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id u14so31051128lfo.11 for ; Wed, 26 Jan 2022 02:14:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=/mvM51A5cZB1/LP8bxdtukBhEKxdmFmIE0WYJdIBCJA=; b=mvIP15AWvQg1ZCiSg0C3i/x1fq4RgGtsbSqHGugR8AvKBMBhnyQpIvYdTa0Q1lSPf9 4rI0oX+gyII5WDvROn/rYgWLGUEkOOeVq+2PN9wQ1m3SQWOXPkYqFU1VTMstSvYYveCj H2yYU0GNO/jwjQRZg5P9ux025ZhnUCBYVTIsdRWKVdc+j9dwPfsIGx/Y6ClttcDRVsMu ShkjLCwfwlDESlOcUrMr4QmsUFqYcJCRJcD1UbnXBwrD5KYNfZup3CxAEgEZ+u375Mjl gtS1T6Bfu43yUZAXYZ+jVMxGjPIJOIvURAGvzRg4KfqzK76meuahOnSz7vUWritSnzDd yp3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=/mvM51A5cZB1/LP8bxdtukBhEKxdmFmIE0WYJdIBCJA=; b=a+XQvrhCac9oMVzQJfBKIU+2WnAVDPKIlU0HOXRxGn4NrDfpXk0KSXH6bwHL4IX20I e2yYH9pkow2ty6MJbl4EwBqUI8KOGHnVsvXYdzaqF19pcmfoCtHBbzClPkVUGtt2RrjK jNDOyxySy72MuAxJefQvPveaB+OnCoWv/z54bZpBjNqpaJxKKCu5LQ8bvc3s3Z34e6gv fw4P2xiFBVasCMvQSnI2bUsIGy2bx31PuWbCFtZ94TQOfxB+cQPU7edVYdnhF6R83zyd QRjpU1FhMzd9TRgJMPpht60frPdZIQYGd+9g4mVbbw0ATsRq746DcqWXcx/ee9eIJ/8d svnA== X-Gm-Message-State: AOAM530v47Jg0ZJeF4YlvjQi8a39QyfXWJEMjooDdzBUd06YCvMtdYK2 p58sTfQmBbB56eYpsE4LayIb29KyN/bY+A== X-Received: by 2002:a05:6512:3406:: with SMTP id i6mr19581169lfr.637.1643192090820; Wed, 26 Jan 2022 02:14:50 -0800 (PST) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id h13sm1351906lfv.100.2022.01.26.02.14.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 02:14:50 -0800 (PST) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, Andrew Lunn , Marcin Wojtas , Calvin Johnson , Markus Koch , linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/5] net/fsl: xgmac_mdio: Use managed device resources Date: Wed, 26 Jan 2022 11:14:29 +0100 Message-Id: <20220126101432.822818-3-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220126101432.822818-1-tobias@waldekranz.com> References: <20220126101432.822818-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All of the resources used by this driver has managed interfaces, so use them. Heed the warning in the comment before platform_get_resource and use a bare devm_ioremap to allow for non-exclusive access to the IO memory. Signed-off-by: Tobias Waldekranz --- drivers/net/ethernet/freescale/xgmac_mdio.c | 35 ++++----------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c index 266e562bd67a..40442d64a247 100644 --- a/drivers/net/ethernet/freescale/xgmac_mdio.c +++ b/drivers/net/ethernet/freescale/xgmac_mdio.c @@ -273,7 +273,7 @@ static int xgmac_mdio_probe(struct platform_device *pdev) return -EINVAL; } - bus = mdiobus_alloc_size(sizeof(struct mdio_fsl_priv)); + bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(struct mdio_fsl_priv)); if (!bus) return -ENOMEM; @@ -284,13 +284,11 @@ static int xgmac_mdio_probe(struct platform_device *pdev) bus->probe_capabilities = MDIOBUS_C22_C45; snprintf(bus->id, MII_BUS_ID_SIZE, "%pa", &res->start); - /* Set the PHY base address */ priv = bus->priv; - priv->mdio_base = ioremap(res->start, resource_size(res)); - if (!priv->mdio_base) { - ret = -ENOMEM; - goto err_ioremap; - } + priv->mdio_base = devm_ioremap(&pdev->dev, res->start, + resource_size(res)); + if (IS_ERR(priv->mdio_base)) + return PTR_ERR(priv->mdio_base); /* For both ACPI and DT cases, endianness of MDIO controller * needs to be specified using "little-endian" property. @@ -312,31 +310,11 @@ static int xgmac_mdio_probe(struct platform_device *pdev) ret = -EINVAL; if (ret) { dev_err(&pdev->dev, "cannot register MDIO bus\n"); - goto err_registration; + return ret; } platform_set_drvdata(pdev, bus); - return 0; - -err_registration: - iounmap(priv->mdio_base); - -err_ioremap: - mdiobus_free(bus); - - return ret; -} - -static int xgmac_mdio_remove(struct platform_device *pdev) -{ - struct mii_bus *bus = platform_get_drvdata(pdev); - struct mdio_fsl_priv *priv = bus->priv; - - mdiobus_unregister(bus); - iounmap(priv->mdio_base); - mdiobus_free(bus); - return 0; } @@ -364,7 +342,6 @@ static struct platform_driver xgmac_mdio_driver = { .acpi_match_table = xgmac_acpi_match, }, .probe = xgmac_mdio_probe, - .remove = xgmac_mdio_remove, }; module_platform_driver(xgmac_mdio_driver); -- 2.25.1