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: 682992 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3syKdv0pHPz9sxS for ; Tue, 18 Oct 2016 01:02:27 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ramses-pyramidenbau.de header.i=@ramses-pyramidenbau.de header.b=yJMdYnar; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933622AbcJQOA2 (ORCPT ); Mon, 17 Oct 2016 10:00:28 -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-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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;