Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4154444pxv; Mon, 19 Jul 2021 18:39:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFdZYUbxXsxPrr1mmz78OUWjjlx9L2pgUXAxOiEheeeWI65VKJ3qXBSff/Lu/bVN4ZzwbY X-Received: by 2002:aa7:d801:: with SMTP id v1mr37768282edq.349.1626745192498; Mon, 19 Jul 2021 18:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626745192; cv=none; d=google.com; s=arc-20160816; b=EVsVPXrXr55wrro9d2gT35+EPEK/8xLWt2TJE4yYZuz8qCnOZP9dI1oqDT9zQkrRjH Qz+fegbboo2QfU1Bl7Z/gVo6IMVCy/qYl0UNjX4xkpHwABPwcLV946uqgc5jdePGch5l /SeUSxWwrOmmTru86m9ZfzH69Tx1300wbgU+phenZOEM03yGlJDGZCwPcVGTjNNedZbZ rIaimx0BMbgjFSly3Xp2FhAe1ZPiLGuDw6Me6py9vbq56+I5Aseh/81kkz1NE+DMQJkC N1ERPpAybzCQTlXUB7fpZDma1UiPkrd0fxwKSpU17g2b7mmpMTi3A7GJy9ZP509F6VHi +3rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VWhETQLYOmYGfpUQ2sKKzcwOeuekklf6R8ZXQoIGYTg=; b=BSpFHDsdCZwcPbyS/gb7QYWitCn5MJPEjAU1JlF6lXlzN6AJv+QBUe8NHy+D1DCzNc fbWy9S8/klpGgJATPkLDUb+qcnimr9VnIs6tWNQF9p8ozO0DFcyHUj5/79ZFOrGyNjMn +RBkoPEjI4UzGy2DvAVIHbyj/aqrqz0kjBQAOdrTRSObqPpdaJyJKVW3k7UdLWK70O7V hG6adJ3v4Lxy07g1aQ6QDjLs29keNw6tGPZ6iKWZZJmf25IvQ+5XSYnDDMfhzhf6I9Ss u01JY+DBAqhcX7k/BA22iA28nvBh431QjDWvvpIGuE+MrUocE/tlxQH7JXgvrFLZvBxI cgnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="zjni+/0u"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k9si25767079edv.565.2021.07.19.18.39.30; Mon, 19 Jul 2021 18:39:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="zjni+/0u"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238382AbhGSO5A (ORCPT + 99 others); Mon, 19 Jul 2021 10:57:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:55666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244494AbhGSOgh (ORCPT ); Mon, 19 Jul 2021 10:36:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C374A611ED; Mon, 19 Jul 2021 15:17:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707822; bh=WU1bSrE8aufbaP+Iz2ayxRaykURKJQ0Z9dZKgWW19Jo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zjni+/0uU/FPWx5Sq69GeARUzJqsokQ0RFCYLo5AzbWtVuepDDUpK3jlEJMLc9iE1 zDTH+ZcKoBpYjgJr0w6qfrKWrXcLMZbn7CnaY/tbI+313y4y7Wb5yLNsiTP3e5WYYk 5Nh3TnY3wZ9Sse9sWSBPU38SaHHjiCpPfdaEQDzk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Charles Keepax , Mark Brown , Sasha Levin Subject: [PATCH 4.14 037/315] spi: Make of_register_spi_device also set the fwnode Date: Mon, 19 Jul 2021 16:48:46 +0200 Message-Id: <20210719144944.094734846@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.861561397@linuxfoundation.org> References: <20210719144942.861561397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Charles Keepax [ Upstream commit 0e793ba77c18382f08e440260fe72bc6fce2a3cb ] Currently, the SPI core doesn't set the struct device fwnode pointer when it creates a new SPI device. This means when the device is registered the fwnode is NULL and the check in device_add which sets the fwnode->dev pointer is skipped. This wasn't previously an issue, however these two patches: commit 4731210c09f5 ("gpiolib: Bind gpio_device to a driver to enable fw_devlink=on by default") commit ced2af419528 ("gpiolib: Don't probe gpio_device if it's not the primary device") Added some code to the GPIO core which relies on using that fwnode->dev pointer to determine if a driver is bound to the fwnode and if not bind a stub GPIO driver. This means the GPIO providers behind SPI will get both the expected driver and this stub driver causing the stub driver to fail if it attempts to request any pin configuration. For example on my system: madera-pinctrl madera-pinctrl: pin gpio5 already requested by madera-pinctrl; cannot claim for gpiochip3 madera-pinctrl madera-pinctrl: pin-4 (gpiochip3) status -22 madera-pinctrl madera-pinctrl: could not request pin 4 (gpio5) from group aif1 on device madera-pinctrl gpio_stub_drv gpiochip3: Error applying setting, reverse things back gpio_stub_drv: probe of gpiochip3 failed with error -22 The firmware node on the device created by the GPIO framework is set through the of_node pointer hence things generally actually work, however that fwnode->dev is never set, as the check was skipped at device_add time. This fix appears to match how the I2C subsystem handles the same situation. Signed-off-by: Charles Keepax Link: https://lore.kernel.org/r/20210421101402.8468-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index da71a53b0df7..71f74015efb9 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1670,6 +1670,7 @@ of_register_spi_device(struct spi_controller *ctlr, struct device_node *nc) /* Store a pointer to the node in the device structure */ of_node_get(nc); spi->dev.of_node = nc; + spi->dev.fwnode = of_fwnode_handle(nc); /* Register the new device */ rc = spi_add_device(spi); -- 2.30.2