From patchwork Wed Dec 16 06:33:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 7860151 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8F5299FC65 for ; Wed, 16 Dec 2015 06:34:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7B43202FF for ; Wed, 16 Dec 2015 06:34:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 63CE22037C for ; Wed, 16 Dec 2015 06:34:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754648AbbLPGeC (ORCPT ); Wed, 16 Dec 2015 01:34:02 -0500 Received: from mail-wm0-f44.google.com ([74.125.82.44]:32811 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754650AbbLPGdl (ORCPT ); Wed, 16 Dec 2015 01:33:41 -0500 Received: by mail-wm0-f44.google.com with SMTP id n186so126566688wmn.0 for ; Tue, 15 Dec 2015 22:33:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-type:content-transfer-encoding; bh=+tmdkl0GzRp4+K47TVuBZjC7qj5JkBJ6+GwGN3Wj+yM=; b=ExYLybfV8l1vIKxtN1yiwBCZYxELKAoG+WFbBJAIQjBMSwna7110cTwLoyC8jTj5jS t+7td6omPW2szJ4WzMIcTSvO3eGgyWlyiLVZcGfquVcmyYksvgwDmypwYkTQZuZCxh1B FKvbKOpecWOKXLjw0vocN1GZzggJI1JXNRU/tW3tdXQ14x16LddIqxqptadR7CHcdn6f Qq6QIUFnZsEFgPMoYEcFRhlK+dXeNdMTcspfeAWRUQJu5vpFQSrq51N1QCRgKrIUvTBB yLhp5drJLJdNzUsvSrTlcht8JGPyC5CQApdME5fUbP6qRZlYNF0SgtbRUPQc8A7oos8F clHQ== X-Received: by 10.28.194.7 with SMTP id s7mr9539884wmf.29.1450247620384; Tue, 15 Dec 2015 22:33:40 -0800 (PST) Received: from ?IPv6:2003:62:5f55:ba00:2cb9:5d8a:228e:1f60? (p200300625F55BA002CB95D8A228E1F60.dip0.t-ipconnect.de. [2003:62:5f55:ba00:2cb9:5d8a:228e:1f60]) by smtp.googlemail.com with ESMTPSA id gl10sm4470222wjb.30.2015.12.15.22.33.39 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 15 Dec 2015 22:33:39 -0800 (PST) From: Heiner Kallweit Subject: [PATCH] pnp: respect PNP_DRIVER_RES_DO_NOT_CHANGE when detaching To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org Message-ID: <567105B2.3080109@gmail.com> Date: Wed, 16 Dec 2015 07:33:22 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP I have a device (Nuvoton 6779D Super-IO IR RC with nuvoton-cir driver) which works after initial boot but not any longer if I unload and re-load the driver module. Digging into the issue I found that unloading the driver calls pnp_disable_dev although the driver has flag PNP_DRIVER_RES_DO_NOT_CHANGE set. IMHO this is not right. Let's have a look at the call chain when probing a device: pnp_device_probe 1. attaches the device 2. if it's not active and PNP_DRIVER_RES_DO_NOT_CHANGE is not set it gets activated 3. probes driver I think pnp_device_remove should do it in reverse order and also respect PNP_DRIVER_RES_DO_NOT_CHANGE. Therefore: 1. call drivers remove callback 2. if device is active and PNP_DRIVER_RES_DO_NOT_CHANGE is not set disable it 3. detach device The change works for me and sounds logical to me. However I don't know the pnp driver in detail so I might be wrong. Signed-off-by: Heiner Kallweit --- drivers/pnp/driver.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index 153a493..74b201d 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c @@ -74,7 +74,6 @@ void pnp_device_detach(struct pnp_dev *pnp_dev) if (pnp_dev->status == PNP_ATTACHED) pnp_dev->status = PNP_READY; mutex_unlock(&pnp_lock); - pnp_disable_dev(pnp_dev); } static int pnp_device_probe(struct device *dev) @@ -131,6 +130,11 @@ static int pnp_device_remove(struct device *dev) drv->remove(pnp_dev); pnp_dev->driver = NULL; } + + if (pnp_dev->active && + (!drv || !(drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE))) + pnp_disable_dev(pnp_dev); + pnp_device_detach(pnp_dev); return 0; }