From patchwork Mon Oct 17 13:59:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralf Ramsauer X-Patchwork-Id: 9379365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3518D6086B for ; Mon, 17 Oct 2016 14:02:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 273DE29225 for ; Mon, 17 Oct 2016 14:02:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BD622924C; Mon, 17 Oct 2016 14:02:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8A5529225 for ; Mon, 17 Oct 2016 14:02:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933718AbcJQOAd (ORCPT ); Mon, 17 Oct 2016 10:00:33 -0400 Received: from ramses-pyramidenbau.de ([37.120.178.10]:43046 "EHLO mail.ramses-pyramidenbau.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933235AbcJQOAK (ORCPT ); Mon, 17 Oct 2016 10:00:10 -0400 Received: from pluto.local (unknown [IPv6:2001:638:a01:8061:aefd:ceff:fef3:ba65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.ramses-pyramidenbau.de (Postfix) with ESMTPSA id 0E928123ABC; Mon, 17 Oct 2016 16:01:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ramses-pyramidenbau.de; s=default; t=1476712878; bh=oqEX61SRRACtmWiz+k+lemdMmCpt8GU8Y1XQthW3bO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yJMdYnarY8OKS+C7aHxGg0uSTbvkR1NrfAD5+NVvge+XMpgVY6/mdP+hYksmuVaR9 pNdYPd20o0Cl1foHVoOmvgxXhvUMv29emYgKd3X9D2MsRu2WMpCHEALVV0iGcRUiaT SXRuUA0d1Pzw9j7rRdpVWFVRlGPH6Q0YK1T2MvxI= From: Ralf Ramsauer To: Mark Brown , Geert Uytterhoeven , Wolfram Sang , Linux SPI , Linux I2C Cc: Ralf Ramsauer , "linux-kernel @ vger . kernel . org" , Pantelis Antoniou Subject: [PATCH v2 1/2] spi: mark device nodes only in case of successful instantiation Date: Mon, 17 Oct 2016 15:59:56 +0200 Message-Id: <20161017135957.20297-2-ralf@ramses-pyramidenbau.de> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161017135957.20297-1-ralf@ramses-pyramidenbau.de> References: <20161017135957.20297-1-ralf@ramses-pyramidenbau.de> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instantiated SPI device nodes are marked with OF_POPULATE. This was introduced in bd6c164. On unloading, loaded device nodes will of course be unmarked. The problem are nodes that fail during initialisation: If a node fails, it won't be unloaded and hence not be unmarked. If a SPI driver module is unloaded and reloaded, it will skip nodes that failed before. Skip device nodes that are already populated and mark them only in case of success. Note that the same issue exists for I2C. Fixes: bd6c164 ("spi: Mark instantiated device nodes with OF_POPULATE") Signed-off-by: Ralf Ramsauer Reviewed-by: Geert Uytterhoeven Acked-by: Pantelis Antoniou --- drivers/spi/spi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 5787b72..838783c 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1618,9 +1618,11 @@ static void of_register_spi_devices(struct spi_master *master) if (of_node_test_and_set_flag(nc, OF_POPULATED)) continue; spi = of_register_spi_device(master, nc); - if (IS_ERR(spi)) + if (IS_ERR(spi)) { dev_warn(&master->dev, "Failed to create SPI device for %s\n", nc->full_name); + of_node_clear_flag(nc, OF_POPULATED); + } } } #else @@ -3131,6 +3133,7 @@ static int of_spi_notify(struct notifier_block *nb, unsigned long action, if (IS_ERR(spi)) { pr_err("%s: failed to create for '%s'\n", __func__, rd->dn->full_name); + of_node_clear_flag(rd->dn, OF_POPULATED); return notifier_from_errno(PTR_ERR(spi)); } break;