From patchwork Mon Oct 21 00:08:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 177002 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2665376ill; Sun, 20 Oct 2019 17:10:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhBzYmepdZM/3sn1s8rXbLgtZE0IzmqSjP7e67vFC8wBmqXu8qjYkPvXnXVB4n90nody8m X-Received: by 2002:a17:906:f258:: with SMTP id gy24mr19936533ejb.25.1571616636297; Sun, 20 Oct 2019 17:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571616636; cv=none; d=google.com; s=arc-20160816; b=BDmTiNQgBt8mV+1+qXi+GDfjCZ/TmV/aNkV7T9CHVVfRpzd2i7ojZYs3YgbWFiligB ngYdLKdy1ZJMP+2krXlOUymPrLuE4eYE71vebPNoOrFo6N1RC2P80sRrq3IGEUNscJ8C YBGGQlmLkz8yTq/wgFyKR9EVG8ax5LhaIB5rMMPm4elUcVk3DOWnCnOU2keKA7vpokyL RfCLtbo21TLx4+q1nzclNWIvDRvKgNTvucQtZf44oSajgRR6JXYnaxFdfQj7NzAf/mME a1EpsQF0Icp8Rb/6VZRkNdZMFZUhc5WA9r0+krBwnZVniM0IQRN7JYKZ7ojsegFzwHYO gwwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kkHVPrwW+udBDpjAVf93ePr4kr7CnBbxsMjmX8osV5o=; b=zJZkForwquwVXPWmS5by6cpTREodt8//9B7ToRZUHKhpUOiA2Mz+QNqB4dccCl0QgY AcYiLiouQQLKZZuHkhk7XJ00ZTvDwhwwB5GuqBiMENdwEsU0QIbVo9jpiIq+kcz+H8hw IIPv8mZhlUEtm5wdh4Hx2WTtUZzaA1H6QKhcHZg2UiHzNP9vGDgjffsq9Zs29CGxFP/g h6cYuS0aQx6x39kZQOstpMyLMdWfymxj9oc6YQxtZm8qPRp/l4ZrXAW2DPetIQv/khbc qzg+Dv9/IgyngLFIju7wkVIIIxLxVnbSEpVv268cA9aoKxoFpcpAwaUvaLWn71q1RR1t RSqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VQit91pF; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h49si574683edh.2.2019.10.20.17.10.36; Sun, 20 Oct 2019 17:10:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VQit91pF; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726859AbfJUAKf (ORCPT + 8 others); Sun, 20 Oct 2019 20:10:35 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:35199 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbfJUAKe (ORCPT ); Sun, 20 Oct 2019 20:10:34 -0400 Received: by mail-lf1-f65.google.com with SMTP id y6so2296530lfj.2 for ; Sun, 20 Oct 2019 17:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kkHVPrwW+udBDpjAVf93ePr4kr7CnBbxsMjmX8osV5o=; b=VQit91pF8e5h0je2IrXBZjvqhweZKHs/fnKtt4b1yfmIyboo7b6zrjHF3srL8BPXIk gvdWDNH0BuAy7iKpY26ZeqlahiRcU3cWChG8eox2o7tqK/sgWiEhN+I5r5UaQMIoagnU qGKzPTRohi+ZDVeVA8R3AV49WJ3ILlMyLzWcSfXtNRwz0oDMgLhEIIzbOopUkZLH/oGb FNqCbGxfm/f32fxB5Bus8e0kEuvj3PVN+TUO81mVn1sDoyQsNrDy8UY9qTiXAjWZctx6 peD3F5SoSQDnSoU79Jr1oF97ZkvZ+gIh5KyarUsqi1lKpvt5/1L59SBDAPID2TCS6zgN 88bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kkHVPrwW+udBDpjAVf93ePr4kr7CnBbxsMjmX8osV5o=; b=ShvlV1aJtWXwCaDQ3xIUWCyJGlcJuhM3vaoZ+FZVcCKCjoajt9K6k/3q8EtByesz4K BOKBUjqvbo1VkgJRa/WCd8Bg2Gy7kUX5xk98NWbzb48Q9Gopu3DwFSCeHwzKgZoxCSXx xZdvxH6zWgLLTmCq3EPncGcFljBFDJZaqS7eNdw1a1Eb3jh1MQqcgCpwgNP1Wq+CorK0 SuxHyprWGjsknj5fDcNPCnxEcYrVPxbJaDtBsj630yojIMNKIB7pDic1d3XR3sI/bfSX fuCS7+RFzITldUtjZ623f70JJ7sMxZr4xmUU3CE1sgiQnDA0C1pPknGhGCGwNyZWGqUv TuIQ== X-Gm-Message-State: APjAAAX9vjMDVeDQ9HgfCx1RWgXxygGqysjHtCdtvYdADA1vNCEYpeuJ evlP60fSIycE/4SQjfaX3LLdfRpsLGg= X-Received: by 2002:a19:ed16:: with SMTP id y22mr2359217lfy.166.1571616632149; Sun, 20 Oct 2019 17:10:32 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-79c8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.200.121]) by smtp.gmail.com with ESMTPSA id a18sm2723081lfi.15.2019.10.20.17.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2019 17:10:27 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Linus Walleij Subject: [PATCH 07/10] net: ehernet: ixp4xx: Use devm_alloc_etherdev() Date: Mon, 21 Oct 2019 02:08:21 +0200 Message-Id: <20191021000824.531-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191021000824.531-1-linus.walleij@linaro.org> References: <20191021000824.531-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Using the devm_alloc_etherdev() function simplifies the error path. I also patch the message to use dev_info(). Signed-off-by: Linus Walleij --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) -- 2.21.0 diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index fbe328693de5..df18d8ebb170 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1378,7 +1378,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) plat = dev_get_platdata(dev); - if (!(ndev = alloc_etherdev(sizeof(struct port)))) + if (!(ndev = devm_alloc_etherdev(dev, sizeof(struct port)))) return -ENOMEM; SET_NETDEV_DEV(ndev, dev); @@ -1432,8 +1432,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) regs_phys = IXP4XX_EthC_BASE_PHYS; break; default: - err = -ENODEV; - goto err_free; + return -ENODEV; } ndev->netdev_ops = &ixp4xx_netdev_ops; @@ -1442,10 +1441,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) netif_napi_add(ndev, &port->napi, eth_poll, NAPI_WEIGHT); - if (!(port->npe = npe_request(NPE_ID(port->id)))) { - err = -EIO; - goto err_free; - } + if (!(port->npe = npe_request(NPE_ID(port->id)))) + return -EIO; port->mem_res = request_mem_region(regs_phys, REGS_SIZE, ndev->name); if (!port->mem_res) { @@ -1479,8 +1476,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) if ((err = register_netdev(ndev))) goto err_phy_dis; - printk(KERN_INFO "%s: MII PHY %i on %s\n", ndev->name, plat->phy, - npe_name(port->npe)); + dev_info(dev, "%s: MII PHY %i on %s\n", ndev->name, plat->phy, + npe_name(port->npe)); return 0; @@ -1491,8 +1488,6 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) release_resource(port->mem_res); err_npe_rel: npe_release(port->npe); -err_free: - free_netdev(ndev); return err; } @@ -1508,7 +1503,6 @@ static int ixp4xx_eth_remove(struct platform_device *pdev) npe_port_tab[NPE_ID(port->id)] = NULL; npe_release(port->npe); release_resource(port->mem_res); - free_netdev(ndev); return 0; }