From patchwork Fri Sep 9 05:19:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Scott X-Patchwork-Id: 9322399 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6708860231 for ; Fri, 9 Sep 2016 05:19:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AB2E29BB4 for ; Fri, 9 Sep 2016 05:19:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F51F29BB6; Fri, 9 Sep 2016 05:19:48 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 E1EEC29BB4 for ; Fri, 9 Sep 2016 05:19:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750796AbcIIFTp (ORCPT ); Fri, 9 Sep 2016 01:19:45 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:50420 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750714AbcIIFTo (ORCPT ); Fri, 9 Sep 2016 01:19:44 -0400 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 44D848604B; Fri, 9 Sep 2016 17:19:42 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1473398382; bh=3GSPZbkLS7OZvBydfrWeyf1fV2t7mvj7+WTne/gbgaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=l6XFcqhhXS76KG85mdtmj0x/DVbbAMZFnWjjP03fopjbi+Jr+PE9+IbCMzPBZEAoA oz0Ui5t2e9fZFK8iuilOUeXl7H/G0c/qKGr+JIA6Utp0ZRNJM4zt0Mcou6nZa8jp0w Q1TdLPk90dKEisAEwz5SRb41lRe/pGOftOsV3pCw= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 3, 6, 7949) id ; Fri, 09 Sep 2016 17:19:42 +1200 Received: from joshuas-dl.ws.atlnz.lc (joshuas-dl.ws.atlnz.lc [10.33.13.25]) by smtp (Postfix) with ESMTP id C425B13EF09; Fri, 9 Sep 2016 17:19:40 +1200 (NZST) Received: by joshuas-dl.ws.atlnz.lc (Postfix, from userid 1634) id F11A61A03CA; Fri, 9 Sep 2016 17:19:41 +1200 (NZST) From: Joshua Scott To: Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org Cc: Joshua Scott , Chris Packham Subject: [PATCH 2/2] hwmon: adt7470: Allow faster removal Date: Fri, 9 Sep 2016 17:19:26 +1200 Message-Id: <20160909051926.4253-2-joshua.scott@alliedtelesis.co.nz> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160909051926.4253-1-joshua.scott@alliedtelesis.co.nz> References: <20160909051926.4253-1-joshua.scott@alliedtelesis.co.nz> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP adt7470_remove will wait for the update thread to complete before returning. This had a worst-case time of up to the user-configurable auto_update_interval. Replace msleep_interruptible with set_current_state and schedule_timeout so that kthread_stop will interrupt the sleep. Signed-off-by: Joshua Scott --- drivers/hwmon/adt7470.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c index dbd758b..ffe1edc 100644 --- a/drivers/hwmon/adt7470.c +++ b/drivers/hwmon/adt7470.c @@ -273,9 +273,12 @@ static int adt7470_update_thread(void *p) mutex_lock(&data->lock); adt7470_read_temperatures(client, data); mutex_unlock(&data->lock); + + set_current_state(TASK_INTERRUPTIBLE); if (kthread_should_stop()) break; - msleep_interruptible(data->auto_update_interval); + + schedule_timeout(msecs_to_jiffies(data->auto_update_interval)); } complete_all(&data->auto_update_stop);