Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2823097pxv; Mon, 12 Jul 2021 02:48:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxkMQ3JMGli3W7In6FfUr4/R5fiP3L/uZ86iLHC1ixyR99bkq0ROMpi9ufHyflyvGf9vKl X-Received: by 2002:a6b:490d:: with SMTP id u13mr39493776iob.176.1626083320569; Mon, 12 Jul 2021 02:48:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626083320; cv=none; d=google.com; s=arc-20160816; b=lBWFA7ttadCVMZQisgOYSSSjUE09cKWw9FGLUTfTHU1BU6YulWl505pID+PY4AYbyb Lqd5Pi0lZ9ErC6IVOLfb01tokR4ro6ZDqzkgk5UbSdkz72sP4sArEp6PyJ/klWyP6xOt MYQhJc1o/uxhHPo3I74VtkC5WLEdqe+LRNkyKRcr+tDh3NcqHEBKwaDqUPTHVMRqfWR1 xmNIFZ5AjFy/rLjJZ2zOYlH/8IxnYna5MwUsoV0yrA9LlsFUScp9/OnoLcxh5Z3laHON g/AcUZtIv/g+t3GZRIeVkZdluXK5D0Fz7NeISTadGXQt+OE8c+gBKoZiHZxzkgVNKfWP zKhg== 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=yDCqc8c/7jpGaW6BsNJdHDYXgvm5JbD5smpxU2kd7YQ=; b=HIevU+Zi7SO1rs7AbOoMURKoaXUvv7RVLzY13BYGrIoLv8/WSCXQmJ0Y1W2RBxWGV3 81EoHtyrNhcK06CbQQFQUEqQiSWPuMCD6C+rWOA2QXiiVBMLB15iWNuTjew45XMSFh62 3ASwjyC2JQhd2lytnzG2f1FoMGKGzx2/rsntLJxKAKVBs+CElURXtl8fZSo2LuTmIjeF 9gB6se5Au1a9X860uFfm4INQH9Xg/vVrybQM12moRfyEEglkWx6DxduMpgofdLFn1Htr XZEfDqVQCbfoNivx0XSAEiD0vWW+boWEwYPL3kIAtphjQtCtqR/QuBM8bA+jlPgyuKqJ 5OYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Jif3f6kq; 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 d5si16865362ilr.23.2021.07.12.02.48.29; Mon, 12 Jul 2021 02:48:40 -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=Jif3f6kq; 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 S238754AbhGLGoP (ORCPT + 99 others); Mon, 12 Jul 2021 02:44:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:54420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237832AbhGLGey (ORCPT ); Mon, 12 Jul 2021 02:34:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5240461008; Mon, 12 Jul 2021 06:31:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071510; bh=M4lXD5PdoEOae9tXQkmDAL0otB9pq6xK1O5bsCfdOwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jif3f6kqHH8R0ioaRmVy0pv6E+bOi4Az+nux3iO1dURFkkpJjnPWoTSp+GSMf0sLT mdwieC9VpoEzZmqtd6rXNlhuSxcjLDv5cn+LTFojVerYRp5ZHur+LaEO8v+QEXaIIa PVOIUMqyGjy/g8jmSUKgo/iWq0xRa4P1m4aQI6RA= 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 5.10 100/593] spi: Make of_register_spi_device also set the fwnode Date: Mon, 12 Jul 2021 08:04:20 +0200 Message-Id: <20210712060854.215385548@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@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 0cf67de741e7..bd8b1f79dce2 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2050,6 +2050,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