Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2775863yba; Mon, 22 Apr 2019 12:45:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrEn9QL3Mebp+qJHMbLeh1DK6nHTsLhbKGbIz9igS063cJ2FHRxhO9F/19xpy7NvOFDWpN X-Received: by 2002:a62:5206:: with SMTP id g6mr21918335pfb.227.1555962304308; Mon, 22 Apr 2019 12:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555962304; cv=none; d=google.com; s=arc-20160816; b=b9kFRfCyYGssPNgYP+5u9iWuFpnzabtFdEYKyKV1OYEoyAIAQus48nkHfZ80RRwqoA cIKHL0gKM71+/idWZBKx23usTT/TOSTei5Ivd56pfmHmUzE6NUwjVZvDLKQRdGCHM6ma 4ylM6gvpFyRrGZDXoCFhaJ8KheB3UfKjqpRK84cINFqsXZKs8ZqqLsKJljPIIZm/RT5p trfHmvFgVo+2S8lF/h+sxG0aR2ZFOelhkEebpmVtKKSD2YopVuW+uln/UZJseq/BZQvp 2rznyMk/FWSlfN7FvY06U+kSbmCltyiJNojnaaXqFKUD8IgdvvssbbcrxEk+enaMfRMk Nv+g== 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=uUzJUoE5jWlDYAx1AyE8BuhbCKO8fePSDWcNgWfLA50=; b=caJDNrpgDnaVUmmfYcsZN6XqdNiH3b9l6hh3QEPEs8ERouRqQTVfklDAUtPlXGlcqU G8wUIoykIvLmDDBoYEcqc7tcnppDb4v0FYSC/UAtGnOdsM2515/zSvucaX4obyjqfYTS aITcV80Xk898JjBdVrXmJl3dClscJnvZr6CqVRkqnC8x2XEqMa2FXXTI+u/LYtfPyRTA mQon6R8HienTynUhfXkg6+O+UmB/2niYHdlApVCOUgWcfPtnNBs0wfWtubyFCEKzcED4 /l2cvIK6PGvmew62Qg8A5gNDLqzaO8Jv7o6Su87Pq710/Sc9Hv9A4sQq9MZ4ZxqVOT6o fXxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b0xhTX9G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l191si13167154pgd.549.2019.04.22.12.44.49; Mon, 22 Apr 2019 12:45:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=b0xhTX9G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729164AbfDVTnW (ORCPT + 99 others); Mon, 22 Apr 2019 15:43:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:43900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729128AbfDVTnV (ORCPT ); Mon, 22 Apr 2019 15:43:21 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 807AC2075A; Mon, 22 Apr 2019 19:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962199; bh=SYXSczzpGuOW/A27+PQSyngiYCRFC1ygmSahEGORUXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b0xhTX9GT+O+H2UNiWx/a3/Kn7AD3OiaOcaB/74vGJbnOMLQRwBod1Adm0jFW+xVx dd48mXTAbT7xBVrV5GT0t0yTsrnjjKBiMmq7bpt2NjJPzpKcJ7Y9Dw3xGHv1nt0G1r gOySG7NqDbtc/ll3VXCTFUCfNH/wxol4ZBuNIpeA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lukas Wunner , Frank Pavlic , Ben Dooks , Tristram Ha , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 39/98] net: ks8851: Delay requesting IRQ until opened Date: Mon, 22 Apr 2019 15:41:06 -0400 Message-Id: <20190422194205.10404-39-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194205.10404-1-sashal@kernel.org> References: <20190422194205.10404-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lukas Wunner [ Upstream commit d268f31552794abf5b6aa5af31021643411f25f5 ] The ks8851 driver currently requests the IRQ before registering the net_device. Because the net_device name is used as IRQ name and is still "eth%d" when the IRQ is requested, it's impossibe to tell IRQs apart if multiple ks8851 chips are present. Most other drivers delay requesting the IRQ until the net_device is opened. Do the same. The driver doesn't enable interrupts on the chip before opening the net_device and disables them when closing it, so there doesn't seem to be a need to request the IRQ already on probe. Signed-off-by: Lukas Wunner Cc: Frank Pavlic Cc: Ben Dooks Cc: Tristram Ha Signed-off-by: David S. Miller Signed-off-by: Sasha Levin (Microsoft) --- drivers/net/ethernet/micrel/ks8851.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c index 1633fa5c709c..c9faec4c5b25 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c @@ -785,6 +785,15 @@ static void ks8851_tx_work(struct work_struct *work) static int ks8851_net_open(struct net_device *dev) { struct ks8851_net *ks = netdev_priv(dev); + int ret; + + ret = request_threaded_irq(dev->irq, NULL, ks8851_irq, + IRQF_TRIGGER_LOW | IRQF_ONESHOT, + dev->name, ks); + if (ret < 0) { + netdev_err(dev, "failed to get irq\n"); + return ret; + } /* lock the card, even if we may not actually be doing anything * else at the moment */ @@ -899,6 +908,8 @@ static int ks8851_net_stop(struct net_device *dev) dev_kfree_skb(txb); } + free_irq(dev->irq, ks); + return 0; } @@ -1529,14 +1540,6 @@ static int ks8851_probe(struct spi_device *spi) ks8851_read_selftest(ks); ks8851_init_mac(ks); - ret = request_threaded_irq(spi->irq, NULL, ks8851_irq, - IRQF_TRIGGER_LOW | IRQF_ONESHOT, - ndev->name, ks); - if (ret < 0) { - dev_err(&spi->dev, "failed to get irq\n"); - goto err_irq; - } - ret = register_netdev(ndev); if (ret) { dev_err(&spi->dev, "failed to register network device\n"); @@ -1549,11 +1552,7 @@ static int ks8851_probe(struct spi_device *spi) return 0; - err_netdev: - free_irq(ndev->irq, ks); - -err_irq: err_id: if (gpio_is_valid(gpio)) gpio_set_value(gpio, 0); @@ -1574,7 +1573,6 @@ static int ks8851_remove(struct spi_device *spi) dev_info(&spi->dev, "remove\n"); unregister_netdev(priv->netdev); - free_irq(spi->irq, priv); if (gpio_is_valid(priv->gpio)) gpio_set_value(priv->gpio, 0); regulator_disable(priv->vdd_reg); -- 2.19.1