From patchwork Sat Sep 7 22:21:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13795288 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08CF3157E9F; Sat, 7 Sep 2024 22:21:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725747713; cv=none; b=LY6gC5aiOK0TpF00SCISt7pNSYMxbKYMRZ4R4TxLDfYHOm3qJfibe49+hB8zOABUNTXRds7Y7L3ci9VTdVZ9ZmFRJn6n1/gS2LZLr1yNu85X3bpBNCFDdMASsHCgcoyI/Bmd355sG7el2ENBUltE+aYMyG93OluT3tIJZhYAXxE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725747713; c=relaxed/simple; bh=02yYXdvDx31Qs4Dj8pQC42UZW21KEG4h3gy4Rhlut7s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U7scGVkaf5PLiD4/xvEPbwh7nExas/5VOwdIr7Dmz/bFXfA7nH9yAzkjFTUoQiPABi9i5X4B8IInYo2kQtVTyBUbH3SI1FNCy2aQbMT9JbSxSddJMX+g4+IVYG7dNlrNV0obUc9m1GQ9p4PTxaewWEzKNqM/8+HnvXMTghW41IU= 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=Sgca2a6u; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Sgca2a6u" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-718d6ad6050so1435735b3a.0; Sat, 07 Sep 2024 15:21:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725747711; x=1726352511; 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=i0E/gFh6bgM5JAxun4jikcDPrvGdw7HEaUT/qNC5C78=; b=Sgca2a6uJVAQCgavBY1mGRjPBEZMj+ahq2on61yQXbn04mbEmH/PUfGxvtbnRYuWtO 1QiWs8szC01H3il4TcwfWiTS41Vs8WiWPKkWTM94SAYRNAzv0UdP6aKdKZGA2rkEc5Y7 P/wnupU3wbA+1GorxnK7RNqedUTuYq/a+XiHyTCq0SrR20wCsMZcJBCeRR5ZlZVW3Vez zGNs2qA7/vkjC4HzH6eH9fSF52EM9Mnf+Xr5a8B+Nvqgh95ysfDrGW3JutDzWyzNfGny 3kz5npmXZlyvMf0QpQmACf9iu6NY3k3Lxlj5WbhFsLseXS79vtslqgCh2hkQphI09KHT fsKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725747711; x=1726352511; 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=i0E/gFh6bgM5JAxun4jikcDPrvGdw7HEaUT/qNC5C78=; b=ZBUAkcy2fe4Dtrh5+EsnuHZBsXHEpS1tTihEqWeHeY1HkaZnucU0RkMrjoRx/+pbWp Ti2tkI28A1ULtfEg8Y1l/KJ5ijghu8WBlky/bkHEEyEVKjR5pw+CV1+Har3IXokgy712 PXKHCpvVWBWFUHeaMvZwz/jSNaq/cQxNjqquuMJ8EpJCzcbc3biQCGLXckeaePd94pdw tiDq164xmxk9dlG9PRWzg1i/mAv2YlP1qFPGlTop69h/mq5GJUB28G64GNmay1aFNHFS ECR53esd8XZhUnMHdSz3hWfzE8MmQd9H1XfvxXYnQekQhMfZ8Bug5SkbJe/MrD58Z6H0 hgmQ== X-Forwarded-Encrypted: i=1; AJvYcCUxSGJEtRm2D2euCowHfmNvDcx/5zVRunZdDiznSGI5PPlM04SuU0pQsbQ88SSkClcNdEr45pftk4g0ZY0=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3onpKec0ouJnqI+wK1qyCNQ/UoHFzk2KiGDHM2xnKHs6vPBxq K24Gu+Xnm7OUe0zYxyyb0UuFbtHSj0Sfoi3qrDQC3bNvJ27oxuvwm8gxNeL7 X-Google-Smtp-Source: AGHT+IFx/TqZURwFbSBWwIWPNoCcrr7MZdj4GmgQ1l4OgP/SKPpo0LUYxkZDv5TiVQcXAWOa6hwkgA== X-Received: by 2002:a05:6a20:c6ca:b0:1c0:e997:7081 with SMTP id adf61e73a8af0-1cf1d1396e7mr7671240637.29.1725747710802; Sat, 07 Sep 2024 15:21:50 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7d860a4d202sm1077198a12.85.2024.09.07.15.21.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Sep 2024 15:21:50 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: andrew@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, jacob.e.keller@intel.com, horms@kernel.org, sd@queasysnail.net, chunkeey@gmail.com Subject: [PATCH net-next 1/4] net: ibm: emac: tah: use devm and dev_err Date: Sat, 7 Sep 2024 15:21:44 -0700 Message-ID: <20240907222147.21723-2-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240907222147.21723-1-rosenp@gmail.com> References: <20240907222147.21723-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 Simplifies the driver by removing manual frees and using dev_err instead of printk. pdev->dev has the of_node name in it. eg. TAH /plb/opb/emac-tah@ef601350 initialized vs emac-tah 4ef601350.emac-tah: initialized close enough. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/tah.c | 60 ++++++++++------------------- 1 file changed, 21 insertions(+), 39 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/tah.c b/drivers/net/ethernet/ibm/emac/tah.c index fa3488258ca2..84e2091c193a 100644 --- a/drivers/net/ethernet/ibm/emac/tah.c +++ b/drivers/net/ethernet/ibm/emac/tah.c @@ -43,9 +43,9 @@ void tah_detach(struct platform_device *ofdev, int channel) mutex_unlock(&dev->lock); } -void tah_reset(struct platform_device *ofdev) +void tah_reset(struct platform_device *pdev) { - struct tah_instance *dev = platform_get_drvdata(ofdev); + struct tah_instance *dev = platform_get_drvdata(pdev); struct tah_regs __iomem *p = dev->base; int n; @@ -56,7 +56,7 @@ void tah_reset(struct platform_device *ofdev) --n; if (unlikely(!n)) - printk(KERN_ERR "%pOF: reset timeout\n", ofdev->dev.of_node); + dev_err(&pdev->dev, "reset timeout"); /* 10KB TAH TX FIFO accommodates the max MTU of 9000 */ out_be32(&p->mr, @@ -85,61 +85,44 @@ void *tah_dump_regs(struct platform_device *ofdev, void *buf) return regs + 1; } -static int tah_probe(struct platform_device *ofdev) +static int tah_probe(struct platform_device *pdev) { - struct device_node *np = ofdev->dev.of_node; + struct device_node *np = pdev->dev.of_node; struct tah_instance *dev; struct resource regs; int rc; - rc = -ENOMEM; - dev = kzalloc(sizeof(struct tah_instance), GFP_KERNEL); - if (dev == NULL) - goto err_gone; + dev = devm_kzalloc(&pdev->dev, sizeof(struct tah_instance), GFP_KERNEL); + if (!dev) + return -ENOMEM; mutex_init(&dev->lock); - dev->ofdev = ofdev; + dev->ofdev = pdev; - rc = -ENXIO; - if (of_address_to_resource(np, 0, ®s)) { - printk(KERN_ERR "%pOF: Can't get registers address\n", np); - goto err_free; + rc = of_address_to_resource(np, 0, ®s); + if (rc) { + dev_err(&pdev->dev, "can't get registers address"); + return rc; } - rc = -ENOMEM; - dev->base = (struct tah_regs __iomem *)ioremap(regs.start, - sizeof(struct tah_regs)); - if (dev->base == NULL) { - printk(KERN_ERR "%pOF: Can't map device registers!\n", np); - goto err_free; + dev->base = + devm_ioremap(&pdev->dev, regs.start, sizeof(struct tah_regs)); + if (!dev->base) { + dev_err(&pdev->dev, "can't map device registers"); + return -ENOMEM; } - platform_set_drvdata(ofdev, dev); + platform_set_drvdata(pdev, dev); /* Initialize TAH and enable IPv4 checksum verification, no TSO yet */ - tah_reset(ofdev); + tah_reset(pdev); - printk(KERN_INFO "TAH %pOF initialized\n", ofdev->dev.of_node); + dev_info(&pdev->dev, "initialized"); wmb(); - return 0; - - err_free: - kfree(dev); - err_gone: return rc; } -static void tah_remove(struct platform_device *ofdev) -{ - struct tah_instance *dev = platform_get_drvdata(ofdev); - - WARN_ON(dev->users != 0); - - iounmap(dev->base); - kfree(dev); -} - static const struct of_device_id tah_match[] = { { @@ -158,7 +141,6 @@ static struct platform_driver tah_driver = { .of_match_table = tah_match, }, .probe = tah_probe, - .remove_new = tah_remove, }; int __init tah_init(void) From patchwork Sat Sep 7 22:21:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13795289 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 5402416A38B; Sat, 7 Sep 2024 22:21:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725747714; cv=none; b=tn+GmYIVqS/3mkkun8TpeimZyjhPUSrAZ86lVYBSBwI0TItN6hreumTmvcVwoLtqZ2BEX2zP4bOiGNnPz8pKQ/sZfUcXkYPgVUzlfC5J1MClYLqadyRuWNT7bf2Nz4eeHgOL0OLRlXH4WFjOgN0v49LIBIOv1UxZG+SVD+/qyrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725747714; c=relaxed/simple; bh=2zBigd//G5iO+BesE7TX1KWH9iAckaNRR4Wz2TbMkUA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OFW/2RuznbEeSU5vyQV921RT405TXjP0kp6LkxU81+mGR9SmQotvBa4YDC9ZWABUmIwVb+rRY8NsVBav7iEHgkSm+Tkc3db3oC7fE1GbH9VgnTJhsItdZ6GiJiOx3y2x+0Rp+tgrqGxkcbB3PbMYzZm34HAVIzdhaTcIV0lBNV4= 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=IXj9qwVQ; arc=none smtp.client-ip=209.85.215.176 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="IXj9qwVQ" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-7cb3db0932cso2491132a12.1; Sat, 07 Sep 2024 15:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725747712; x=1726352512; 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=f6aKpbMa8frBMXy12QNcNTsich8eKSzF/iMdpWXYNc4=; b=IXj9qwVQ8ai/Adoo1nNhGMHBM0sVODXzx+xk8IQUchlh8gJccpz//eI1nF/K3yQ6we iu5cDNeWp/gIQU5NariWKrmhSVou2KnstlNX6f2giKJM3YJcT8VwqfJ4vnlNwWLtPT5Z ujSgU/mfELifHMM9O2oJA9jh3o9ZhVZEuckALq4501YIANVrLiYgmqN83/Cx7K+Oasua llHYvsa+OyPWdMV0WCK7DnHYcNJ5GJN+Cpsn+yRNPhoKZmZjSJiTAMhCsLZq5J0YOyyC erL7f6HOyaKhPyRb1Pqj7kfxschi2Um9w3WzQ/CfpbBY/F3u+GO+XZTMI80O2qs9Nx8g 3+Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725747712; x=1726352512; 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=f6aKpbMa8frBMXy12QNcNTsich8eKSzF/iMdpWXYNc4=; b=rY3i0EHH3Ztqby6W1HMK0/eSW/aaF2P6WvYvePZ75lDfz3OGvNguCF7fDcisZw0Jcz mISJDwqDYWr9CxWRvjqOdfZ470hvclhTwAuskr9eZvYGDGyRFXPAw1NlexK3VVHmSglQ 700PX/fBdgh2P5xxJfEsn4Cil4fVeqslUl2Ss0IQvCSij/1GkFioqMuV1rwG2UcR/PXi ZOGxELva9OAMohbVXzpM/cCCm5NH/AD93SRXx0WO/6sNfyn+ZRRYZRC3bO3uB3rYCDV8 hJilUqGd0PNSja5XIQ6uIgAiR1wx1mD2PXizo3d5I7s6wgH6ni59NKLJFTYmdeiEIygV 6hZg== X-Forwarded-Encrypted: i=1; AJvYcCUaNewEM0gj+7Mlrez983DpZRq1OzQXnjJ8guQkxdJfY2AyCaWkxrNcGn/m7jVku0qkSuD8I/KTvezFzuc=@vger.kernel.org X-Gm-Message-State: AOJu0Yw4iTyhM4WBKd5Be7PTdqCPk+Af0iPQPJAgBo4YXiKjfzr1Ri8W +SjKa0TkJ+ONq9r4zoGWI2cLse3V0DKUK2/8llJV1YMFeqku0Cc5E0omx6Df X-Google-Smtp-Source: AGHT+IFCeoo/WZzK9Sa6bTj4f44C1IwMZFEVD/gvOjmu+FlktDh/R/BOCJ4sym6MpTalk/xZNyZ7Bg== X-Received: by 2002:a17:903:230f:b0:205:9112:efea with SMTP id d9443c01a7336-2070a578bdemr31392565ad.35.1725747712312; Sat, 07 Sep 2024 15:21:52 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7d860a4d202sm1077198a12.85.2024.09.07.15.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Sep 2024 15:21:52 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: andrew@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, jacob.e.keller@intel.com, horms@kernel.org, sd@queasysnail.net, chunkeey@gmail.com Subject: [PATCH net-next 2/4] net: ibm: emac: rgmii: use devm and dev_err Date: Sat, 7 Sep 2024 15:21:45 -0700 Message-ID: <20240907222147.21723-3-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240907222147.21723-1-rosenp@gmail.com> References: <20240907222147.21723-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 Simplifies the driver by removing manual frees and using dev_err instead of printk. pdev->dev has the of_node name in it. eg. RGMII /plb/opb/emac-rgmii@ef601500 initialized with MDIO support vs. emac-rgmii 4ef601500.emac-rgmii: initialized with MDIO support Close enough. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/rgmii.c | 76 ++++++++++----------------- 1 file changed, 27 insertions(+), 49 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/rgmii.c b/drivers/net/ethernet/ibm/emac/rgmii.c index e1712fdc3c31..bcf6b7d0dcf9 100644 --- a/drivers/net/ethernet/ibm/emac/rgmii.c +++ b/drivers/net/ethernet/ibm/emac/rgmii.c @@ -77,17 +77,16 @@ static inline u32 rgmii_mode_mask(int mode, int input) } } -int rgmii_attach(struct platform_device *ofdev, int input, int mode) +int rgmii_attach(struct platform_device *pdev, int input, int mode) { - struct rgmii_instance *dev = platform_get_drvdata(ofdev); + struct rgmii_instance *dev = platform_get_drvdata(pdev); struct rgmii_regs __iomem *p = dev->base; RGMII_DBG(dev, "attach(%d)" NL, input); /* Check if we need to attach to a RGMII */ if (input < 0 || !rgmii_valid_mode(mode)) { - printk(KERN_ERR "%pOF: unsupported settings !\n", - ofdev->dev.of_node); + dev_err(&pdev->dev, "unsupported settings"); return -ENODEV; } @@ -96,8 +95,7 @@ int rgmii_attach(struct platform_device *ofdev, int input, int mode) /* Enable this input */ out_be32(&p->fer, in_be32(&p->fer) | rgmii_mode_mask(mode, input)); - printk(KERN_NOTICE "%pOF: input %d in %s mode\n", - ofdev->dev.of_node, input, phy_modes(mode)); + dev_info(&pdev->dev, "input %d in %s mode", input, phy_modes(mode)); ++dev->users; @@ -213,76 +211,57 @@ void *rgmii_dump_regs(struct platform_device *ofdev, void *buf) return regs + 1; } - -static int rgmii_probe(struct platform_device *ofdev) +static int rgmii_probe(struct platform_device *pdev) { - struct device_node *np = ofdev->dev.of_node; + struct device_node *np = pdev->dev.of_node; struct rgmii_instance *dev; struct resource regs; int rc; - rc = -ENOMEM; - dev = kzalloc(sizeof(struct rgmii_instance), GFP_KERNEL); - if (dev == NULL) - goto err_gone; + dev = devm_kzalloc(&pdev->dev, sizeof(struct rgmii_instance), + GFP_KERNEL); + if (!dev) + return -ENOMEM; mutex_init(&dev->lock); - dev->ofdev = ofdev; + dev->ofdev = pdev; - rc = -ENXIO; - if (of_address_to_resource(np, 0, ®s)) { - printk(KERN_ERR "%pOF: Can't get registers address\n", np); - goto err_free; + rc = of_address_to_resource(np, 0, ®s); + if (rc) { + dev_err(&pdev->dev, "can't get registers address"); + return rc; } - rc = -ENOMEM; - dev->base = (struct rgmii_regs __iomem *)ioremap(regs.start, - sizeof(struct rgmii_regs)); - if (dev->base == NULL) { - printk(KERN_ERR "%pOF: Can't map device registers!\n", np); - goto err_free; + dev->base = + devm_ioremap(&pdev->dev, regs.start, sizeof(struct rgmii_regs)); + if (!dev->base) { + dev_err(&pdev->dev, "can't map device registers"); + return -ENOMEM; } /* Check for RGMII flags */ - if (of_property_read_bool(ofdev->dev.of_node, "has-mdio")) + if (of_property_read_bool(pdev->dev.of_node, "has-mdio")) dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; /* CAB lacks the right properties, fix this up */ - if (of_device_is_compatible(ofdev->dev.of_node, "ibm,rgmii-axon")) + if (of_device_is_compatible(pdev->dev.of_node, "ibm,rgmii-axon")) dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; - DBG2(dev, " Boot FER = 0x%08x, SSR = 0x%08x\n", - in_be32(&dev->base->fer), in_be32(&dev->base->ssr)); + dev_dbg(&pdev->dev, "Boot FER = 0x%08x, SSR = 0x%08x", + in_be32(&dev->base->fer), in_be32(&dev->base->ssr)); /* Disable all inputs by default */ out_be32(&dev->base->fer, 0); - printk(KERN_INFO - "RGMII %pOF initialized with%s MDIO support\n", - ofdev->dev.of_node, - (dev->flags & EMAC_RGMII_FLAG_HAS_MDIO) ? "" : "out"); + dev_info(&pdev->dev, "initialized with%s MDIO support", + (dev->flags & EMAC_RGMII_FLAG_HAS_MDIO) ? "" : "out"); wmb(); - platform_set_drvdata(ofdev, dev); + platform_set_drvdata(pdev, dev); - return 0; - - err_free: - kfree(dev); - err_gone: return rc; } -static void rgmii_remove(struct platform_device *ofdev) -{ - struct rgmii_instance *dev = platform_get_drvdata(ofdev); - - WARN_ON(dev->users != 0); - - iounmap(dev->base); - kfree(dev); -} - static const struct of_device_id rgmii_match[] = { { @@ -300,7 +279,6 @@ static struct platform_driver rgmii_driver = { .of_match_table = rgmii_match, }, .probe = rgmii_probe, - .remove_new = rgmii_remove, }; int __init rgmii_init(void) From patchwork Sat Sep 7 22:21:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13795290 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.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 B0F5216B39C; Sat, 7 Sep 2024 22:21:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725747716; cv=none; b=P7cHlPGyqotcaQuaRSVMSnIT2Xyz2kmL+whoXFQrh2lydoo3DE6meI2tnigoM3gzOo/UeD7QLQAvk8ifYC6q6mGSUiG+5RHIW5zH2V0Ohnbl1HSmH3vJAf7v8ROMchtXEWljheF/Ld6MqEKWkO3mQBJaoJLDx6QNZRCzk1Omrkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725747716; c=relaxed/simple; bh=zascTxCSTeDJYFuG2ES4XtW1ZqJ6eDTFndx7BFMyFCY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nqxbsaxki3idUmkcdDjitVuY3ESvKkDIVNPXaBp1bpjOfLERHCrVY0IAA7y8n5oJGO31iFxRELh2KVqEb5sTK9XCsCFrVERXtpub+nm2dLbeQh8ZuAIQo3NQNjs7+mk3rMGFxBH6AkKXPIIfvv/hZCFUM1y/JWJrucO6Fcucxo0= 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=Zz5lHLxi; arc=none smtp.client-ip=209.85.210.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="Zz5lHLxi" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-718e11e4186so1166335b3a.2; Sat, 07 Sep 2024 15:21:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725747714; x=1726352514; 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=1P7s/b/ONveiPzs1KvreGYULcOsjJGg/ShVezWj3vsk=; b=Zz5lHLxiZeNDKUzolSofjdEnM5nistw7GSYJsefNHrD5MFhkfSFstk7wbVjHH3Oa9D aUmZPilSt1I1asTks8CwFwN/hx3dxh2vdOUXe0TeKW4kNnFRlvJgbs88N9wOXsDlmkF7 nH9CfLcwbxkw01HcjGWDiubHEeGr0ZDoq8o+pGhmRozxL5xCQqZG7977jRXyASGxSvoY Rt/ekphI3EeKb02q24KcP6P7PRZGcbkkWylp2n62V6LtW5A5XBy7J3kwpyD2qX84/JP1 b9J5CIUca4AO5CvWIVO2k7NV591p4jGK5dg1M0DLAzDyeYOwSA5ecaK4d84BJtSl4uo5 DJog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725747714; x=1726352514; 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=1P7s/b/ONveiPzs1KvreGYULcOsjJGg/ShVezWj3vsk=; b=ZcetU3/UMORgdb1yJzn513YrdlUGIEx60AJ7UEltJWYRYQyxc4ae8A3tNExWZtXB5u JIYKF+Bl06EwP1rR4RiqlZ2BbVwHXnfH76yX3GdGAe27g6KNACU6nMxvDXeiBtSJdDnQ RxsrLbM4SM50JOBx1wYSal+gXHLWUzSxLa5iP5TiMuowYlDcwXQF/lcggkjrbcX0leCC pH6b5eE9bdVgq57qGql9J8JHn05ywcuzoNaFREvn8jaDcek2Eph3pH3iw5o+uvaZEUFi 0R+LSniv8pPm1Q7Iy/fdGldlmqOnN11YJzNPcIub2ZBUpIOqx3lILyxZmcXP3i2R/lgy TPYQ== X-Forwarded-Encrypted: i=1; AJvYcCXQDZfo+6leAO5RO1T2oxqwWz5o2Cy1T55ARVJQEW3Ps2sZ3uZw32+OGUo5vWv8KbVQXvQ/QNiqAPm9qmQ=@vger.kernel.org X-Gm-Message-State: AOJu0Ywg+sCljPn4I/Zb2jmbDAZmrusde9hIYvTf4vnq2TqKzTKUF8TE KP5ES+hfNr+nRehSoG9SEEBrkJlZEhoDJR3cboX0ARv1o485z90lP7UsvJrj X-Google-Smtp-Source: AGHT+IHtaxbB9xjXF+OsFijtRXgkWnvRTxJ3PuzLwTtvoERC1BWc1GnySDL6YyR4Y/QxBqCr5amjdA== X-Received: by 2002:a05:6a00:14c6:b0:714:2533:1b82 with SMTP id d2e1a72fcca58-718e3455a65mr4888316b3a.23.1725747713742; Sat, 07 Sep 2024 15:21:53 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7d860a4d202sm1077198a12.85.2024.09.07.15.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Sep 2024 15:21:53 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: andrew@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, jacob.e.keller@intel.com, horms@kernel.org, sd@queasysnail.net, chunkeey@gmail.com Subject: [PATCH net-next 3/4] net: ibm: emac: zmii: use devm and dev_err Date: Sat, 7 Sep 2024 15:21:46 -0700 Message-ID: <20240907222147.21723-4-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240907222147.21723-1-rosenp@gmail.com> References: <20240907222147.21723-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 Simplifies the driver by removing manual frees and using dev_err instead of printk. pdev->dev has the of_node name in it. Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/zmii.c | 53 ++++++++++------------------ 1 file changed, 18 insertions(+), 35 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/zmii.c b/drivers/net/ethernet/ibm/emac/zmii.c index 26e86cdee2f6..1e6c3169ee4d 100644 --- a/drivers/net/ethernet/ibm/emac/zmii.c +++ b/drivers/net/ethernet/ibm/emac/zmii.c @@ -230,34 +230,33 @@ void *zmii_dump_regs(struct platform_device *ofdev, void *buf) return regs + 1; } -static int zmii_probe(struct platform_device *ofdev) +static int zmii_probe(struct platform_device *pdev) { - struct device_node *np = ofdev->dev.of_node; + struct device_node *np = pdev->dev.of_node; struct zmii_instance *dev; struct resource regs; int rc; - rc = -ENOMEM; - dev = kzalloc(sizeof(struct zmii_instance), GFP_KERNEL); - if (dev == NULL) - goto err_gone; + dev = devm_kzalloc(&pdev->dev, sizeof(struct zmii_instance), + GFP_KERNEL); + if (!dev) + return -ENOMEM; mutex_init(&dev->lock); - dev->ofdev = ofdev; + dev->ofdev = pdev; dev->mode = PHY_INTERFACE_MODE_NA; - rc = -ENXIO; - if (of_address_to_resource(np, 0, ®s)) { - printk(KERN_ERR "%pOF: Can't get registers address\n", np); - goto err_free; + rc = of_address_to_resource(np, 0, ®s); + if (rc) { + dev_err(&pdev->dev, "can't get registers address"); + return rc; } - rc = -ENOMEM; - dev->base = (struct zmii_regs __iomem *)ioremap(regs.start, - sizeof(struct zmii_regs)); - if (dev->base == NULL) { - printk(KERN_ERR "%pOF: Can't map device registers!\n", np); - goto err_free; + dev->base = + devm_ioremap(&pdev->dev, regs.start, sizeof(struct zmii_regs)); + if (!dev->base) { + dev_err(&pdev->dev, "can't map device registers"); + return -ENOMEM; } /* We may need FER value for autodetection later */ @@ -266,28 +265,13 @@ static int zmii_probe(struct platform_device *ofdev) /* Disable all inputs by default */ out_be32(&dev->base->fer, 0); - printk(KERN_INFO "ZMII %pOF initialized\n", ofdev->dev.of_node); + dev_info(&pdev->dev, "initialized"); wmb(); - platform_set_drvdata(ofdev, dev); + platform_set_drvdata(pdev, dev); - return 0; - - err_free: - kfree(dev); - err_gone: return rc; } -static void zmii_remove(struct platform_device *ofdev) -{ - struct zmii_instance *dev = platform_get_drvdata(ofdev); - - WARN_ON(dev->users != 0); - - iounmap(dev->base); - kfree(dev); -} - static const struct of_device_id zmii_match[] = { { @@ -306,7 +290,6 @@ static struct platform_driver zmii_driver = { .of_match_table = zmii_match, }, .probe = zmii_probe, - .remove_new = zmii_remove, }; int __init zmii_init(void) From patchwork Sat Sep 7 22:21:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13795291 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.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 82DE716BE13; Sat, 7 Sep 2024 22:21:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725747718; cv=none; b=UZSsX0luK7osbxp3BoXcq0p0VPWu/Dw6MtWNxncSopaQaPv7RkFotdhSC4o4yDfppbQV3EIkFfWK6XFeeM2EuCXvby6sS9QOayvfr2Kb0AhvLx2n40X4VceE+Kn1HSy7xebfFshK8mB9Uc1wHy5TW4ubAcIER2huzojFi90pOw0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725747718; c=relaxed/simple; bh=DiDDJP6Pm2z/OTNn+uGgEtWoySH0EoDuDh525D4cvBs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nM1j1SS5aa3qFp69rXflfG3uhaBolGiGmrna6k2tePDIHFpnr/the8EblIjNBtPm+fRafw7B9WOnkbHsuN5PdlPpDam/HW2vVaODjbgiaNjcQwSiCxhCb5DJ4zJZWCUuaL/1Z/1pjUXZR41irZ1cxfGHBZn485K4tRox4mJo5Bk= 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=cTZK6vjr; arc=none smtp.client-ip=209.85.215.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="cTZK6vjr" Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-7cf5e179b68so2412354a12.1; Sat, 07 Sep 2024 15:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725747715; x=1726352515; 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=CRCIdYnIa2p6nZZlzYLZy1O5bnyhZ6eDPBWIoa9hH9Q=; b=cTZK6vjrRX5LsMHyGcVTZh6NVIbwkGfdrXdOMZHZ+mhp0IezjLyiIXjB1RTaIedGVd cdaK3C9+xU+h4Q09Kj5KRo5kcfw9vvaZadjsADN5rLPXBzZ4Fdix4KQZTyXkQKs0njcn anXDy67u91rrOj7THNyfAoAXApes5h+I+tPB9oC2h8qPUOtRK5q4ZWdfnSX3flLQkxxZ vxqu+NDCvEODRCLee7SWyp3kP5Kb91a6UXWL3h3uZnmOnoUVUsek1TjZmVZGfoYSz9NM 8HnwLPAd0yU/MyEdJ11UBYl1T4NnOrRUjHqiOF0sodQ+ZgYKG0p42gWI05HedXba7/PM HTUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725747715; x=1726352515; 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=CRCIdYnIa2p6nZZlzYLZy1O5bnyhZ6eDPBWIoa9hH9Q=; b=p6yE02ivT9Q5+sE7DxLwIRaoUXH3MQlUKQUbn1vwQGR0ThY2ixyEdJemRV6dj2vd0Q HRfALO+uuLGxvwa50B6w/t7hSfF/JYhUlZ8nLCu5Xm3rPIL+RgKkQkYedqzelyY8ZCGA eGdgs8ZgYc6FjKsiE4Po3Rr5h3/zv8Nd52XLvEtQEjSee6zQ5XK9ca717SQE7hKycgKN svsvob6AnTLGvirNssSEAAeztyGSrEP4VwFr46F/huozAdXDnhYWGhe3dMegpz6KyfgA MPxc8g0uS6BOS5kOwSl5KC6eWfT2ziKk8esoPIjhcGBbexBOtRFz5ErkkTgOBfyVDN3R yOfg== X-Forwarded-Encrypted: i=1; AJvYcCXruDYfteE/76BoTE9lV+XMTxdU45fFR0ug1js8x1wmit9msp+0XsC8aiM8HVk5OnvycHMjhs91Gxc/VGs=@vger.kernel.org X-Gm-Message-State: AOJu0Yyhd72vDu4wK1McbLstcqJF5+ZLFr8mWscnuigJRuXEmfWsVXdh lf4kOSn8xqYtL+eNctlMm3Bbj1mFpOGIMdSb8r58djmW5y9K6DSHAWFkkl0+ X-Google-Smtp-Source: AGHT+IEfgT5cKoq7ClzOLcbQtZuxZ77W+Kug8efojSR9Qj7spDtRbec4EsEo4WTB+T7+O5BVzaeyqw== X-Received: by 2002:a05:6a21:385:b0:1ce:e975:7017 with SMTP id adf61e73a8af0-1cf1c10851dmr9153251637.16.1725747715413; Sat, 07 Sep 2024 15:21:55 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7d860a4d202sm1077198a12.85.2024.09.07.15.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Sep 2024 15:21:55 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: andrew@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, jacob.e.keller@intel.com, horms@kernel.org, sd@queasysnail.net, chunkeey@gmail.com Subject: [PATCH net-next 4/4] net: ibm: emac: mal: use devm and dev_err Date: Sat, 7 Sep 2024 15:21:47 -0700 Message-ID: <20240907222147.21723-5-rosenp@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240907222147.21723-1-rosenp@gmail.com> References: <20240907222147.21723-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 Simplifies the driver by removing manual frees and using dev_err instead of printk. pdev->dev has the of_node name in it. eg. MAL v2 /plb/mcmal, 1 TX channels, 1 RX channels vs mcmal plb:mcmal: MAL version 2, 1 TX channels, 1 RX channels Close enough Signed-off-by: Rosen Penev --- drivers/net/ethernet/ibm/emac/mal.c | 144 ++++++++++++---------------- 1 file changed, 61 insertions(+), 83 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/mal.c b/drivers/net/ethernet/ibm/emac/mal.c index d92dd9c83031..ceee51781c1e 100644 --- a/drivers/net/ethernet/ibm/emac/mal.c +++ b/drivers/net/ethernet/ibm/emac/mal.c @@ -513,7 +513,7 @@ void *mal_dump_regs(struct mal_instance *mal, void *buf) return regs + 1; } -static int mal_probe(struct platform_device *ofdev) +static int mal_probe(struct platform_device *pdev) { struct mal_instance *mal; int err = 0, i, bd_size; @@ -524,79 +524,71 @@ static int mal_probe(struct platform_device *ofdev) unsigned long irqflags; irq_handler_t hdlr_serr, hdlr_txde, hdlr_rxde; - mal = kzalloc(sizeof(struct mal_instance), GFP_KERNEL); + mal = devm_kzalloc(&pdev->dev, sizeof(struct mal_instance), GFP_KERNEL); if (!mal) return -ENOMEM; mal->index = index; - mal->ofdev = ofdev; - mal->version = of_device_is_compatible(ofdev->dev.of_node, "ibm,mcmal2") ? 2 : 1; + mal->ofdev = pdev; + if (of_device_is_compatible(pdev->dev.of_node, "ibm,mcmal2")) + mal->version = 2; + else + mal->version = 1; MAL_DBG(mal, "probe" NL); - prop = of_get_property(ofdev->dev.of_node, "num-tx-chans", NULL); - if (prop == NULL) { - printk(KERN_ERR - "mal%d: can't find MAL num-tx-chans property!\n", - index); - err = -ENODEV; - goto fail; + prop = of_get_property(pdev->dev.of_node, "num-tx-chans", NULL); + if (!prop) { + dev_err(&pdev->dev, + "mal%d: can't find MAL num-tx-chans property", index); + return -ENODEV; } mal->num_tx_chans = prop[0]; - prop = of_get_property(ofdev->dev.of_node, "num-rx-chans", NULL); - if (prop == NULL) { - printk(KERN_ERR - "mal%d: can't find MAL num-rx-chans property!\n", - index); - err = -ENODEV; - goto fail; + prop = of_get_property(pdev->dev.of_node, "num-rx-chans", NULL); + if (!prop) { + dev_err(&pdev->dev, + "mal%d: can't find MAL num-rx-chans property", index); + return -ENODEV; } mal->num_rx_chans = prop[0]; - dcr_base = dcr_resource_start(ofdev->dev.of_node, 0); + dcr_base = dcr_resource_start(pdev->dev.of_node, 0); if (dcr_base == 0) { - printk(KERN_ERR - "mal%d: can't find DCR resource!\n", index); - err = -ENODEV; - goto fail; + dev_err(&pdev->dev, "mal%d: can't find DCR resource", index); + return -ENODEV; } - mal->dcr_host = dcr_map(ofdev->dev.of_node, dcr_base, 0x100); + mal->dcr_host = dcr_map(pdev->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 = -ENODEV; - goto fail; + dev_err(&pdev->dev, "mal%d: failed to map DCRs", index); + return -ENODEV; } - if (of_device_is_compatible(ofdev->dev.of_node, "ibm,mcmal-405ez")) { + if (of_device_is_compatible(pdev->dev.of_node, "ibm,mcmal-405ez")) { #if defined(CONFIG_IBM_EMAC_MAL_CLR_ICINTSTAT) && \ defined(CONFIG_IBM_EMAC_MAL_COMMON_ERR) mal->features |= (MAL_FTR_CLEAR_ICINTSTAT | MAL_FTR_COMMON_ERR_INT); #else - printk(KERN_ERR "%pOF: Support for 405EZ not enabled!\n", - ofdev->dev.of_node); - err = -ENODEV; - goto fail; + dev_err(&pdev->dev, "support for 405EZ not enabled"); + return -ENODEV; #endif } - mal->txeob_irq = irq_of_parse_and_map(ofdev->dev.of_node, 0); - mal->rxeob_irq = irq_of_parse_and_map(ofdev->dev.of_node, 1); - mal->serr_irq = irq_of_parse_and_map(ofdev->dev.of_node, 2); + mal->txeob_irq = irq_of_parse_and_map(pdev->dev.of_node, 0); + mal->rxeob_irq = irq_of_parse_and_map(pdev->dev.of_node, 1); + mal->serr_irq = irq_of_parse_and_map(pdev->dev.of_node, 2); if (mal_has_feature(mal, MAL_FTR_COMMON_ERR_INT)) { mal->txde_irq = mal->rxde_irq = mal->serr_irq; } else { - mal->txde_irq = irq_of_parse_and_map(ofdev->dev.of_node, 3); - mal->rxde_irq = irq_of_parse_and_map(ofdev->dev.of_node, 4); + mal->txde_irq = irq_of_parse_and_map(pdev->dev.of_node, 3); + mal->rxde_irq = irq_of_parse_and_map(pdev->dev.of_node, 4); } if (!mal->txeob_irq || !mal->rxeob_irq || !mal->serr_irq || !mal->txde_irq || !mal->rxde_irq) { - printk(KERN_ERR - "mal%d: failed to map interrupts !\n", index); + dev_err(&pdev->dev, "mal%d: failed to map interrupts", index); err = -ENODEV; goto fail_unmap; } @@ -624,7 +616,7 @@ static int mal_probe(struct platform_device *ofdev) /* Current Axon is not happy with priority being non-0, it can * deadlock, fix it up here */ - if (of_device_is_compatible(ofdev->dev.of_node, "ibm,mcmal-axon")) + if (of_device_is_compatible(pdev->dev.of_node, "ibm,mcmal-axon")) cfg &= ~(MAL2_CFG_RPP_10 | MAL2_CFG_WPP_10); /* Apply configuration */ @@ -637,7 +629,7 @@ static int mal_probe(struct platform_device *ofdev) bd_size = sizeof(struct mal_descriptor) * (NUM_TX_BUFF * mal->num_tx_chans + NUM_RX_BUFF * mal->num_rx_chans); - mal->bd_virt = dma_alloc_coherent(&ofdev->dev, bd_size, &mal->bd_dma, + mal->bd_virt = dma_alloc_coherent(&pdev->dev, bd_size, &mal->bd_dma, GFP_KERNEL); if (mal->bd_virt == NULL) { err = -ENOMEM; @@ -664,21 +656,26 @@ static int mal_probe(struct platform_device *ofdev) hdlr_rxde = mal_rxde; } - err = request_irq(mal->serr_irq, hdlr_serr, irqflags, "MAL SERR", mal); + err = devm_request_irq(&pdev->dev, mal->serr_irq, hdlr_serr, irqflags, + "MAL SERR", mal); if (err) goto fail2; - err = request_irq(mal->txde_irq, hdlr_txde, irqflags, "MAL TX DE", mal); + err = devm_request_irq(&pdev->dev, mal->txde_irq, hdlr_txde, irqflags, + "MAL TX DE", mal); if (err) - goto fail3; - err = request_irq(mal->txeob_irq, mal_txeob, 0, "MAL TX EOB", mal); + goto fail2; + err = devm_request_irq(&pdev->dev, mal->txeob_irq, mal_txeob, 0, + "MAL TX EOB", mal); if (err) - goto fail4; - err = request_irq(mal->rxde_irq, hdlr_rxde, irqflags, "MAL RX DE", mal); + goto fail2; + err = devm_request_irq(&pdev->dev, mal->rxde_irq, hdlr_rxde, irqflags, + "MAL RX DE", mal); if (err) - goto fail5; - err = request_irq(mal->rxeob_irq, mal_rxeob, 0, "MAL RX EOB", mal); + goto fail2; + err = devm_request_irq(&pdev->dev, mal->rxeob_irq, mal_rxeob, 0, + "MAL RX EOB", mal); if (err) - goto fail6; + goto fail2; /* Enable all MAL SERR interrupt sources */ set_mal_dcrn(mal, MAL_IER, MAL_IER_EVENTS); @@ -686,40 +683,28 @@ static int mal_probe(struct platform_device *ofdev) /* Enable EOB interrupt */ mal_enable_eob_irq(mal); - printk(KERN_INFO - "MAL v%d %pOF, %d TX channels, %d RX channels\n", - mal->version, ofdev->dev.of_node, - mal->num_tx_chans, mal->num_rx_chans); + dev_err(&pdev->dev, "MAL version %d, %d TX channels, %d RX channels", + mal->version, mal->num_tx_chans, mal->num_rx_chans); /* Advertise this instance to the rest of the world */ wmb(); - platform_set_drvdata(ofdev, mal); + platform_set_drvdata(pdev, mal); return 0; - 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: +fail2: + dma_free_coherent(&pdev->dev, bd_size, mal->bd_virt, mal->bd_dma); +fail_dummy: free_netdev(mal->dummy_dev); - fail_unmap: +fail_unmap: dcr_unmap(mal->dcr_host, 0x100); - fail: - kfree(mal); return err; } -static void mal_remove(struct platform_device *ofdev) +static void mal_remove(struct platform_device *pdev) { - struct mal_instance *mal = platform_get_drvdata(ofdev); + struct mal_instance *mal = platform_get_drvdata(pdev); MAL_DBG(mal, "remove" NL); @@ -732,22 +717,15 @@ static void mal_remove(struct platform_device *ofdev) "mal%d: commac list is not empty on remove!\n", mal->index); - 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); free_netdev(mal->dummy_dev); - dma_free_coherent(&ofdev->dev, + dma_free_coherent(&pdev->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); } static const struct of_device_id mal_platform_match[] =