From patchwork Thu Sep 20 19:18:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Trent Piepho X-Patchwork-Id: 10608639 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 58EE45A4 for ; Thu, 20 Sep 2018 19:22:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 434212E40A for ; Thu, 20 Sep 2018 19:22:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3732B2E404; Thu, 20 Sep 2018 19:22:00 +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 C392E2E3FA for ; Thu, 20 Sep 2018 19:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388736AbeIUBDf (ORCPT ); Thu, 20 Sep 2018 21:03:35 -0400 Received: from mail-eopbgr690137.outbound.protection.outlook.com ([40.107.69.137]:14528 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388732AbeIUBDe (ORCPT ); Thu, 20 Sep 2018 21:03:34 -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=cfT7p0Kc3zCsqJArfvSLqH77W3dZ2Yycw0Jm3JhrYOE=; b=kUZGJmXncxiV2rs2eDFQ/vUGL69N3VFUdvZJp7XHgxQCtDG8eQWb64438wSn1hcd+QEakJCv1QK7l6krQQbplLVR6Uvng2ivuiFzQwHYpBfuFwrhytQIt5pKXQ0m/cnqhoh65QPAoXr269Xrj+/0qHrS1ZtC/56wnqr/q9wk5V4= Received: from MWHPR0601MB3708.namprd06.prod.outlook.com (10.167.236.38) by MWHPR0601MB3675.namprd06.prod.outlook.com (10.167.236.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Thu, 20 Sep 2018 19:18: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.019; Thu, 20 Sep 2018 19:18:33 +0000 From: Trent Piepho To: "linux-spi@vger.kernel.org" CC: Henry Gomersall , Geert Uytterhoeven , Kyle Roeschley , Mark Brown , Trent Piepho Subject: [PATCH v2 2/3] spi: Automatically attempt attach after driver_override alteration Thread-Topic: [PATCH v2 2/3] spi: Automatically attempt attach after driver_override alteration Thread-Index: AQHUURa4KKJFDwO2w02MbtCs9lb58Q== Date: Thu, 20 Sep 2018 19:18:33 +0000 Message-ID: <20180920191759.17781-3-tpiepho@impinj.com> References: <20180920191759.17781-1-tpiepho@impinj.com> In-Reply-To: <20180920191759.17781-1-tpiepho@impinj.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: DM5PR13CA0026.namprd13.prod.outlook.com (2603:10b6:3:7b::12) To MWHPR0601MB3708.namprd06.prod.outlook.com (2603:10b6:301:7c::38) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [216.207.205.253] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR0601MB3675;6:JmYKGwiXWQmkOZ4oGizDrAv4gtksugMvs6pLavnGzVA2s/LS/IqkE6yGAvWrBR19vvjJMbYiTtoEL6mi4RU+dQ/nozOHikM1ciXcqtJEpHZ+R9Vv+j8XZblpuu6odhjjw+hAuxc7zMcCh3R4TOTiWUAyoP3s4fKHD/qoFDhh+cnZMbgnXKR8XW2gdYLHbwEXm9Eqzdm2aR3yjok9TzbC6Me33fqKH0aM7PIFC0UbvfxEPQOoiRaTalDS2oE/ZY9Tc9K9/tWqz+oLbkAhkFcBEJ5fdnj5Qh8eGRtdH2T2JiQAZdfmyak4z3mRtj5JgiRVZDy2Q64lRs7H69yc2J8YowDv/vDwnkTfpa69Taj1g7TkMyvdlMM8orosMTg/xejzGUFPX0oL9tRs5Ro2/d3df4hEWs0ZdkFiihLUFFtaKM4r1dxwcuj07ZvPnTy7bn+nwqrEjAheA/i8V6NpaF2gig==;5:DTEsCx7dG3wzoSMTSlhfpRgvYMv2kJZQJRt1wgpBwhtk//Wv9gM/ZNcjGvtkxkVJ9N9u2E+3my/LfiJBJTL+FFkwtO0Mten0TT8YGOrPtPnnbAgAao2W51Hi37lR7ei9sAKNY3lbRtKgRTT7IbbaHb5+j229mNE+1xOz/Sa+/yw=;7:Ool1tX05ApHiNa/4Vyvw8PbfQmAdh9N6+2FRl45ZxetLcGuVgEeL+8NwFk0oiVBIIxwZIqtL6b2vvnQJ3h/emxKM4wlMvkiaptFigXWiiOn8ZSTm62QbmMXrStj9UVp2o9+tHiLSYcgKMwgJZOvoxwYQFKlORwsvVemO7pZSuMUsLLMc2O7odxVPVk08BHOASAUa3ob6rbOIpEaXtWzxfra2KrXtZ9iqT+JTaToc0UOesxCtIeNCcQL2R2S0vWTv x-ms-office365-filtering-correlation-id: d9d4b581-1d8f-4952-6f3d-08d61f2ddb33 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:MWHPR0601MB3675; x-ms-traffictypediagnostic: MWHPR0601MB3675: 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)(3231355)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(201708071742011)(7699051)(76991041);SRVR:MWHPR0601MB3675;BCL:0;PCL:0;RULEID:;SRVR:MWHPR0601MB3675; x-forefront-prvs: 0801F2E62B x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39850400004)(396003)(376002)(346002)(136003)(366004)(199004)(189003)(4326008)(3846002)(6512007)(5250100002)(6116002)(76176011)(36756003)(2501003)(53936002)(1076002)(2906002)(99286004)(52116002)(316002)(54906003)(81166006)(81156014)(5660300001)(105586002)(106356001)(2351001)(97736004)(14454004)(2900100001)(8936002)(8676002)(71190400001)(71200400001)(478600001)(305945005)(7736002)(6916009)(66066001)(86362001)(5024004)(256004)(186003)(6346003)(26005)(486006)(102836004)(386003)(11346002)(6506007)(5640700003)(6436002)(68736007)(446003)(476003)(2616005)(6486002)(107886003)(25786009);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR0601MB3675;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) authentication-results: spf=none (sender IP is ) smtp.mailfrom=tpiepho@impinj.com; x-microsoft-antispam-message-info: huwMf/fINamYPe2ZqS4N32ZU4ivPJrv20CfT//g1LnlyuOPTgbdsbiboRM5oYAQVb6QBiuWJZoOEiA6BPWFS5ocLkx3DdRPF1ewDQGw4y25+OgVRAdmLiw/vrMT7sG1+I4tjA10hpmaRFapVtqLL6RJqhex8DOJn8OaowEt8CZuyB3rGE9H0GkkCQdKsTDTjtTOGyFcdhqjyogXJoQfVfb3ZUALMVY3iugHvntKa4TBQnxPGFblyHL4mhqboW+e3kawM32e6VP0DMy6W1rdU/QyRC2Ji5Y0WNJc8q5QhfjTl+ZuO0GQ/vacWS8pz6Ux0UPkZHhpNnUQ0Pidl8LoHg8pEYw4hRSfJZRhmhBdVWqI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: impinj.com X-MS-Exchange-CrossTenant-Network-Message-Id: d9d4b581-1d8f-4952-6f3d-08d61f2ddb33 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Sep 2018 19:18:33.5237 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 6de70f0f-7357-4529-a415-d8cbb7e93e5e X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR0601MB3675 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 When driver_override is set, call device_attach() to attempt to bind to the new driver. Presumably, that is why driver_override was set. This makes driver_override easier to use from udev rules to bind a device to a new driver. This will not unbind from an existing driver. Signed-off-by: Trent Piepho Reviewed-by: Jan Kundrát Tested-by: Jan Kundrát Reviewed-by: Geert Uytterhoeven --- drivers/spi/spi.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 823fc130248b..5bac7a28b6e9 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -86,6 +86,7 @@ static ssize_t driver_override_store(struct 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)) @@ -107,6 +108,12 @@ static ssize_t driver_override_store(struct device *dev, 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; }