From patchwork Tue Sep 18 22:50:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trent Piepho X-Patchwork-Id: 10604973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFCC31508 for ; Tue, 18 Sep 2018 22:50:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C8282BDCD for ; Tue, 18 Sep 2018 22:50:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F35B2BEFF; Tue, 18 Sep 2018 22:50:38 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 C714C2BEF9 for ; Tue, 18 Sep 2018 22:50:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726744AbeISEZY (ORCPT ); Wed, 19 Sep 2018 00:25:24 -0400 Received: from mail-cys01nam02on0127.outbound.protection.outlook.com ([104.47.37.127]:64416 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725817AbeISEZY (ORCPT ); Wed, 19 Sep 2018 00:25:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=impinj.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=70LWnI60aWwO8ON39gIY5adZu/t/CeQELCXw2UEHFoU=; b=Xu24V2CeY2QSju6I5qomVhd7O7K1N6rwT9ML2Jz0JDtPGzkHkUrFCHrfeGH2QxK2XHiRBRDlfau5Nel8ej8ygyv2cqiEUgs7vQDneH9MA/YyzfPiGxGzw/YwZN3ZfIvanLS4/yyLJPjD6L59lf5m91Oz+PzbYLA22FnTNxNiBao= Received: from MWHPR0601MB3708.namprd06.prod.outlook.com (10.167.236.38) by MWHPR0601MB3610.namprd06.prod.outlook.com (10.167.236.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Tue, 18 Sep 2018 22:50:33 +0000 Received: from MWHPR0601MB3708.namprd06.prod.outlook.com ([fe80::eca3:1c00:bc20:bc48]) by MWHPR0601MB3708.namprd06.prod.outlook.com ([fe80::eca3:1c00:bc20:bc48%4]) with mapi id 15.20.1143.017; Tue, 18 Sep 2018 22:50:33 +0000 From: Trent Piepho To: "linux-spi@vger.kernel.org" CC: Henry Gomersall , Geert Uytterhoeven , Kyle Roeschley , Mark Brown , Trent Piepho Subject: [PATCH 1/2] spi: Add driver_override SPI device attribute Thread-Topic: [PATCH 1/2] spi: Add driver_override SPI device attribute Thread-Index: AQHUT6IB2datbrT5VUqVB3gVKe+Wig== Date: Tue, 18 Sep 2018 22:50:32 +0000 Message-ID: <20180918224525.28001-2-tpiepho@impinj.com> References: <20180918224525.28001-1-tpiepho@impinj.com> In-Reply-To: <20180918224525.28001-1-tpiepho@impinj.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: CY4PR22CA0071.namprd22.prod.outlook.com (2603:10b6:903:ae::33) To MWHPR0601MB3708.namprd06.prod.outlook.com (2603:10b6:301:7c::38) authentication-results: spf=none (sender IP is ) smtp.mailfrom=tpiepho@impinj.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [216.207.205.253] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR0601MB3610;6:7p4su0aNjS9Vj5qcQ0+yKB7AWa2Uaj+QwBv5WKdODBduaWD87B2cscdXKpr5nJASdXgdYnSJT/JrWwUWKrULtO4fEMyRI1PqK9+enxycFME2LhEqHYggJHCLNNNVi6DjqC4xHpUUAHt+VpYRYvRaafwhOSXDVgFXMNyYqD/3EIdoKs6hrmd++Fd2ahT07B5fGrxUvCFqedhjAVs4EQot0BlzE3RsTn4UKKLxwtjNTuNTpkJvlCwLGHn7sRjJ3U6w/U0ho5PvT+dm1SxFGYLxRWHJLOpMAcCEdaKHpL5uRYqhkqFRWRyk101UQsZghYyYJoOg3kD4jT/BhmfWGn3l6MNaubiJncu2FkXtHgfOH3enwvmYrUcJAlErnTa4cqjVCi27vt+YYmQpd3f8TJRY8qJbKr89kqjYYR7zQeXbf9+YhKP4EWDo5ILawBQHaTRZxEr19V7aCeUtVsgR6JfWwA==;5:mz5t4sAFWy4/6t/xawSEtWpph1/QKqu7SY4tlAI+zGtVXm5n3RyPwFw3G3R256YaJm5VwdlU1mDshlaFJcRTkeIRXRJZdbgD2Rr19Tf1iVe2H8lZpkOGHUDNtWTp/k+hcWIp2Bn5twUhzywBaOWhs1TotZ+r8FYxZXQg/sCb0lU=;7:QVVHgvESxPfipCcHnPzBhjCVOyqeEq8Fb9dWmqj8G1eYaBacJoeNTDLydaEX8BKMWMHIcOWxDiHpqam99tJGb9qkNkNmc6e4r5yrK5RwfdWV+y3NeMozDaDSUPm4ylWOL8Osy73CzTk7C/mA/Uy1sjq14m7M6zJJcAk2Ts3eyHR4THCLQPIsou1fObQAHI6Yh6riPfgZUcl17aJi1n/uJ76vv+qPEzGCMASXWEeMDRVzdur4FP1mnm1/GpX8Gfuc x-ms-office365-filtering-correlation-id: 4d9a93de-7309-45c7-9558-08d61db923bf x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:MWHPR0601MB3610; x-ms-traffictypediagnostic: MWHPR0601MB3610: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231355)(944501410)(52105095)(149027)(150027)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(20161123560045)(20161123558120)(20161123564045)(201708071742011)(7699050);SRVR:MWHPR0601MB3610;BCL:0;PCL:0;RULEID:;SRVR:MWHPR0601MB3610; x-forefront-prvs: 0799B1B2D7 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(136003)(366004)(39850400004)(376002)(396003)(199004)(189003)(52116002)(305945005)(107886003)(2900100001)(25786009)(256004)(8936002)(7736002)(81166006)(81156014)(6486002)(5640700003)(6436002)(8676002)(5024004)(316002)(6506007)(386003)(2906002)(5660300001)(6512007)(53936002)(86362001)(575784001)(54906003)(68736007)(6116002)(3846002)(36756003)(1076002)(97736004)(14444005)(2351001)(99286004)(66066001)(2501003)(102836004)(2616005)(476003)(11346002)(26005)(5250100002)(106356001)(4326008)(14454004)(6916009)(508600001)(486006)(446003)(105586002)(186003)(76176011);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR0601MB3610;H:MWHPR0601MB3708.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: impinj.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: RpLA7EeCvxu8pYRAEySwYlYdJUnzpcM11I05gtpbi88YeuUD8za1o+Qv+7/YRyBPq9CshCvhEk+9VyLOd98L6tC9q/jPMeMpkq2meXR6us3idU+c7R47y+U8Jw0u/AHO9jyxFqDkmd6voMu+hPW+aYK060N9gsTaf054BnrfH2xX6hZD9T1f0Q++WAJg2dKlQY038BxR2ad9bvbJPuUtDz52nK/BW5Hon7Zg8TlpzwujucEvFvNZ5yLk8RHGXtB8JMn/SvCuD+6f7fv7X7XkE8bB3UL/897HdM0JB8u+pubFjfggDjLkUwIQZEcDQAW/oHXBBT1mlcE8HPRv//z/dtu3Xodm0BlTNnJhD7SpSdY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: impinj.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d9a93de-7309-45c7-9558-08d61db923bf X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2018 22:50:32.9700 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 6de70f0f-7357-4529-a415-d8cbb7e93e5e X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR0601MB3610 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 This attribute works the same was as the identically named attribute for PCI, AMBA, and platform devices. For reference, see: commit 3cf385713460 ("ARM: 8256/1: driver coamba: add device binding path 'driver_override'") commit 3d713e0e382e ("driver core: platform: add device binding path 'driver_override'") commit 782a985d7af2 ("PCI: Introduce new device binding path using pci_dev.driver_override") If the name of a driver is written to this attribute, then the device will bind to the named driver and only the named driver. The device will bind to the driver even if the driver does not list the device in its id table. This behavior is different than the driver's bind attribute, which only allows binding to devices that are listed as supported by the driver. It can be used to bind a generic driver, like spidev, to a device. Signed-off-by: Trent Piepho --- drivers/spi/spi.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/spi/spi.h | 1 + 2 files changed, 54 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 03833924ca6c..2cdfc0dedafa 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -77,6 +77,54 @@ modalias_show(struct device *dev, struct device_attribute *a, char *buf) } static DEVICE_ATTR_RO(modalias); +static ssize_t driver_override_store(struct device *dev, + struct device_attribute *a, + const char *buf, size_t count) +{ + struct spi_device *spi = to_spi_device(dev); + const char *end = memchr(buf, '\n', count); + const size_t len = end ? end - buf : count; + const char *driver_override, *old; + int ret; + + /* We need to keep extra room for a newline when displaying value */ + if (len >= (PAGE_SIZE - 1)) + return -EINVAL; + + driver_override = kstrndup(buf, len, GFP_KERNEL); + if (!driver_override) + return -ENOMEM; + + device_lock(dev); + old = spi->driver_override; + if (len) { + spi->driver_override = driver_override; + } else { + /* Emptry string, disable driver override */ + spi->driver_override = NULL; + kfree(driver_override); + } + device_unlock(dev); + kfree(old); + + /* Attach device to new driver if it's not already attached */ + ret = device_attach(dev); + if (ret < 0 && ret != -EPROBE_DEFER) + dev_warn(dev, "device attach to '%s' failed (%d)\n", + spi->driver_override, ret); + + return count; +} + +static ssize_t driver_override_show(struct device *dev, + struct device_attribute *a, char *buf) +{ + const struct spi_device *spi = to_spi_device(dev); + + return snprintf(buf, PAGE_SIZE, "%s\n", spi->driver_override ? : ""); +} +static DEVICE_ATTR_RW(driver_override); + #define SPI_STATISTICS_ATTRS(field, file) \ static ssize_t spi_controller_##field##_show(struct device *dev, \ struct device_attribute *attr, \ @@ -158,6 +206,7 @@ SPI_STATISTICS_SHOW(transfers_split_maxsize, "%lu"); static struct attribute *spi_dev_attrs[] = { &dev_attr_modalias.attr, + &dev_attr_driver_override.attr, NULL, }; @@ -305,6 +354,10 @@ static int spi_match_device(struct device *dev, struct device_driver *drv) const struct spi_device *spi = to_spi_device(dev); const struct spi_driver *sdrv = to_spi_driver(drv); + /* Check override first, and if set, only use the named driver */ + if (spi->driver_override) + return strcmp(spi->driver_override, drv->name) == 0; + /* Attempt an OF style match */ if (of_driver_match_device(dev, drv)) return 1; diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 7bb36145e2ba..d90e55029704 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -168,6 +168,7 @@ struct spi_device { void *controller_state; void *controller_data; char modalias[SPI_NAME_SIZE]; + const char *driver_override; int cs_gpio; /* chip select gpio */ /* the statistics */ From patchwork Tue Sep 18 22:50:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trent Piepho X-Patchwork-Id: 10604975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 743D8157B for ; Tue, 18 Sep 2018 22:50:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62F862BDCD for ; Tue, 18 Sep 2018 22:50:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5699D2BEFF; Tue, 18 Sep 2018 22:50:39 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 0294E2BDCD for ; Tue, 18 Sep 2018 22:50:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725817AbeISEZZ (ORCPT ); Wed, 19 Sep 2018 00:25:25 -0400 Received: from mail-cys01nam02on0127.outbound.protection.outlook.com ([104.47.37.127]:64416 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726648AbeISEZZ (ORCPT ); Wed, 19 Sep 2018 00:25:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=impinj.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0QcrmQ0qchKMv6iwAZBhmEKyh9zb7QFXx3xvUgZoav8=; b=N362JahJfNuZgI53iSSU+HurGH/zsIiUqox8Gd64yM88FpfwxPUZC3SDeDm5itm5M8KZnC11JPIN2gir8Zsbm9xjLPwPAB05MgRY51J3yVxIf7OlLoQPRgjCdIbPmAqz5Z8D1aGXkF/OTWph/RX/dv9UHsYJTBpVTB8QwvI0Aqk= Received: from MWHPR0601MB3708.namprd06.prod.outlook.com (10.167.236.38) by MWHPR0601MB3610.namprd06.prod.outlook.com (10.167.236.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Tue, 18 Sep 2018 22:50:36 +0000 Received: from MWHPR0601MB3708.namprd06.prod.outlook.com ([fe80::eca3:1c00:bc20:bc48]) by MWHPR0601MB3708.namprd06.prod.outlook.com ([fe80::eca3:1c00:bc20:bc48%4]) with mapi id 15.20.1143.017; Tue, 18 Sep 2018 22:50:36 +0000 From: Trent Piepho To: "linux-spi@vger.kernel.org" CC: Henry Gomersall , Geert Uytterhoeven , Kyle Roeschley , Mark Brown , Trent Piepho Subject: [PATCH 2/2] spi: spidev: Fix OF tree warning logic Thread-Topic: [PATCH 2/2] spi: spidev: Fix OF tree warning logic Thread-Index: AQHUT6IDJy3qOScL+0SCt5FROsRgxQ== Date: Tue, 18 Sep 2018 22:50:35 +0000 Message-ID: <20180918224525.28001-3-tpiepho@impinj.com> References: <20180918224525.28001-1-tpiepho@impinj.com> In-Reply-To: <20180918224525.28001-1-tpiepho@impinj.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: CY4PR22CA0071.namprd22.prod.outlook.com (2603:10b6:903:ae::33) To MWHPR0601MB3708.namprd06.prod.outlook.com (2603:10b6:301:7c::38) authentication-results: spf=none (sender IP is ) smtp.mailfrom=tpiepho@impinj.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [216.207.205.253] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR0601MB3610;6:SioZz230M+pyxO1SQUANcmoe9aJw+TszH4yXfkC9hydmqX0bsStNNABgKBQkm6IT+Fxo4U6DG7qs7dIOondOWkn8R7SI6hyrAZNQIRxAkgTK9d0JoL2x07sk02NVrAfPHaMY9Ad2W0hzRTGoL9SD/q1vnUCxecXlQ6QaCMN2qlsVmVRVW/EZhBb8Pkx6XKEoCjX68oiUFc8nxqnkX5vl6GzWARAYJADasocD0/pB/wVFmUQ/ww2vf+SMt+DthsmAJ73VRccx6+dav2SHeiTaKifkrXxKU1AZ5N8y75IHHkT4ZYwj0nlru5KpeZpVdeDjJ18OD8Y6XrUc5FIvGQnqOyjkyCOtLOzd/bGGfQxlFwAngTNJCUVDlM/3M2uWofRbYgpg+LEftOKvf70Gd2YIMaQh6R8FxQJaZd0ywbYn8OrLgwLNDocFmWP6iJ7FUZb6BuYV31QObBputaKNPJ5pqg==;5:JxrF6hJ70j6tsdhbIkoE0Kb83hxPXL1BR55GZOjalmbpuyGCQE3N6lhMimFnLxdCtU+aS6OpVkbFXQQlO8IRb+kKsi1NKRvmaAqoVo7vYuky9UUjEPs2Q4Y6d2sbgpg5u37cd9FxHKR6yZ8fHUW4lf42ykCyqufimIWzeHJY2+E=;7:6TZ5wlA7YrHUBb7clRlXbb2TFXY8LA7u2mfNRs+opj0QzP1Sh1vKdXg3fEucS1f4oAFkgvK35qPaVcueNy4enocabVgTIWMj82/KaeSbP3ombC784xjOIM73aFKW6wVlhXWis6QFvYUTm1n+SYM7YTdLNCIFnXG4S1nYvr2iIbOWD+GKyNTuJBy9JspncUSCTBiURGb10afMfRifgGB0pPIg546S3wzj6JF3l3FCuO+6Avvf2nsXpo7P81e9An7v x-ms-office365-filtering-correlation-id: 5bebe27e-70e3-4d71-f60c-08d61db92596 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:MWHPR0601MB3610; x-ms-traffictypediagnostic: MWHPR0601MB3610: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231355)(944501410)(52105095)(149027)(150027)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(20161123560045)(20161123558120)(20161123564045)(201708071742011)(7699050);SRVR:MWHPR0601MB3610;BCL:0;PCL:0;RULEID:;SRVR:MWHPR0601MB3610; x-forefront-prvs: 0799B1B2D7 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(136003)(366004)(39850400004)(376002)(396003)(199004)(189003)(52116002)(305945005)(107886003)(2900100001)(25786009)(256004)(8936002)(7736002)(81166006)(81156014)(6486002)(5640700003)(6436002)(8676002)(316002)(6506007)(386003)(2906002)(5660300001)(6512007)(53936002)(86362001)(54906003)(68736007)(6116002)(3846002)(36756003)(1076002)(97736004)(2351001)(99286004)(66066001)(2501003)(102836004)(2616005)(476003)(11346002)(26005)(5250100002)(106356001)(4326008)(14454004)(6916009)(508600001)(486006)(446003)(105586002)(186003)(76176011);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR0601MB3610;H:MWHPR0601MB3708.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: impinj.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: P5a6+ORlWcjhyuq+RDI3wz6fdVUDu3A1pAK/QOMwX3JuMS6KYcwmjbtjUkpSJJHgbiFMJstMbIrR1EKkVQSXnQWzC4gWdj/GkVbs8K9hF3RAfWbiHQwQUfzKFgWhZqV2zoBMChw8J4KZdeKqjWiMnOMZXlJ4R251Tzf/XE8PKnlHwEOAHVsN934BXq7G/h4NemoDNffl3nuD6RmWlDObAcF/T/YT/684zNY4Ijo4+XNrcERzUw25Etj9NNp5Xs5cA8dptN+CPf0HypR9+CWxezQeaPxkvk2kYVCQeTtMV3jRfnMOU50Me9qU65RuS4bY7qq9+wQZI76ZT16vegXGvWHf9A+SCIhNA6+sqhR6ma4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: impinj.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5bebe27e-70e3-4d71-f60c-08d61db92596 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2018 22:50:35.9221 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 6de70f0f-7357-4529-a415-d8cbb7e93e5e X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR0601MB3610 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 spidev will make a big fuss if a device tree node binds a device by using "spidev" as the node's compatible property. However, the logic for this isn't looking for "spidev" in the compatible, but rather checking that the device is NOT compatible with spidev's list of devices. This causes a false positive if a device not named "rohm,dh2228fv", etc. binds to spidev, even if a means other than putting "spidev" in the device tree was used. E.g., the sysfs driver_override attribute. Signed-off-by: Trent Piepho Reviewed-by: Geert Uytterhoeven --- drivers/spi/spidev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index cda10719d1d1..eee976f8c399 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -724,10 +724,11 @@ static int spidev_probe(struct spi_device *spi) * compatible string, it is a Linux implementation thing * rather than a description of the hardware. */ - if (spi->dev.of_node && !of_match_device(spidev_dt_ids, &spi->dev)) { + if (spi->dev.of_node && + of_device_is_compatible(spi->dev.of_node, "spidev")) { dev_err(&spi->dev, "buggy DT: spidev listed directly in DT\n"); WARN_ON(spi->dev.of_node && - !of_match_device(spidev_dt_ids, &spi->dev)); + of_device_is_compatible(spi->dev.of_node, "spidev")); } spidev_probe_acpi(spi);