From patchwork Mon Oct 16 23:20:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10010115 X-Patchwork-Delegate: rjw@sisk.pl 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 142CB60235 for ; Mon, 16 Oct 2017 23:21:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0524528676 for ; Mon, 16 Oct 2017 23:21:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECF2B286EF; Mon, 16 Oct 2017 23:20:59 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 0B70428676 for ; Mon, 16 Oct 2017 23:20:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757267AbdJPXU6 (ORCPT ); Mon, 16 Oct 2017 19:20:58 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:46161 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757263AbdJPXU5 (ORCPT ); Mon, 16 Oct 2017 19:20:57 -0400 Received: by mail-pg0-f45.google.com with SMTP id k7so8033271pga.3 for ; Mon, 16 Oct 2017 16:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=kR3+67E0vWTjWg9er2lszdh386/bjYPTSzpdZxPFoRA=; b=GP2MaVRtoQXrqQXytS8OaRbDE6zruk7FQrzbfk2/pX2uHsFrWmRUQDghOcxaluOBK7 FYJ1zmf7yj/qGll2vk0XiDvqZK73o4WC0S8i6SwAO7S9fTkebBIUB1piP+qV+Vx8Ym6/ K4YOQT80Sfk4B82U0tM1tCIX3uCPo+T6wPk+I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=kR3+67E0vWTjWg9er2lszdh386/bjYPTSzpdZxPFoRA=; b=JTYCVwPIbiJBmUCLj3lWlub4BvMpZiDIXQ5ErDZrOYKypFlrDpaQ9PrhapcWtdvtbX kmsiWj+WyS8qVjSKRi04ps2Bg+EwTiKjmTmsBiZHraUEIA9L+qc5Nz15EAeZ4xYIvyNy LKfIxmIwsfGtA6N/rC/E2e/oqEMn3PYkZQ5YhwXO9yuwJEDI901ZqO3mHGoyHRWYBkeT WCGBbcJQUzB4DsVdVkuyxximRRhPYLvGQwl/EFI5eBbErJ06M32Rr3E1b0+n6l7AA3UB wsyH0KESH+FTYw67owVBipAHQzbEZlYHb1fbntgnPceALtt3c7yQ0P9SlyzBlUk9T0PU 4Z/g== X-Gm-Message-State: AMCzsaV5piuzn6PP8ASkhLuCK6uAY2l0XLAXsmpOjzDsGtalsN8pZF4I uzeQOtE/c33/kEUPMJW/BEBpTw== X-Google-Smtp-Source: AOwi7QBoVK7F5hKy2H6Zh1odhwIsGWdeK7copZ3YZgyJy7ApkkKRZo0l6t9Dzfx/2nNFTs+pd8tlWg== X-Received: by 10.98.59.65 with SMTP id i62mr9800263pfa.143.1508196056805; Mon, 16 Oct 2017 16:20:56 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id u74sm17438259pfk.125.2017.10.16.16.20.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 16:20:55 -0700 (PDT) Date: Mon, 16 Oct 2017 16:20:55 -0700 From: Kees Cook To: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" , Pavel Machek , Len Brown , Greg Kroah-Hartman , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] PM: Convert timers to use timer_setup() Message-ID: <20171016232055.GA100369@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Removes test of .data field, since that will be going away. Cc: "Rafael J. Wysocki" Cc: Pavel Machek Cc: Len Brown Cc: Greg Kroah-Hartman Cc: linux-pm@vger.kernel.org Signed-off-by: Kees Cook Acked-by: Rafael J. Wysocki --- drivers/base/power/runtime.c | 7 +++---- drivers/base/power/wakeup.c | 11 +++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 7bcf80fa9ada..1cea431c0adf 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -894,9 +894,9 @@ static void pm_runtime_work(struct work_struct *work) * * Check if the time is right and queue a suspend request. */ -static void pm_suspend_timer_fn(unsigned long data) +static void pm_suspend_timer_fn(struct timer_list *t) { - struct device *dev = (struct device *)data; + struct device *dev = from_timer(dev, t, power.suspend_timer); unsigned long flags; unsigned long expires; @@ -1499,8 +1499,7 @@ void pm_runtime_init(struct device *dev) INIT_WORK(&dev->power.work, pm_runtime_work); dev->power.timer_expires = 0; - setup_timer(&dev->power.suspend_timer, pm_suspend_timer_fn, - (unsigned long)dev); + timer_setup(&dev->power.suspend_timer, pm_suspend_timer_fn, 0); init_waitqueue_head(&dev->power.wait_queue); } diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index cdd6f256da59..680ee1d36ac9 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -54,7 +54,7 @@ static unsigned int saved_count; static DEFINE_SPINLOCK(events_lock); -static void pm_wakeup_timer_fn(unsigned long data); +static void pm_wakeup_timer_fn(struct timer_list *t); static LIST_HEAD(wakeup_sources); @@ -176,7 +176,7 @@ void wakeup_source_add(struct wakeup_source *ws) return; spin_lock_init(&ws->lock); - setup_timer(&ws->timer, pm_wakeup_timer_fn, (unsigned long)ws); + timer_setup(&ws->timer, pm_wakeup_timer_fn, 0); ws->active = false; ws->last_time = ktime_get(); @@ -481,8 +481,7 @@ static bool wakeup_source_not_registered(struct wakeup_source *ws) * Use timer struct to check if the given source is initialized * by wakeup_source_add. */ - return ws->timer.function != pm_wakeup_timer_fn || - ws->timer.data != (unsigned long)ws; + return ws->timer.function != (TIMER_FUNC_TYPE)pm_wakeup_timer_fn; } /* @@ -724,9 +723,9 @@ EXPORT_SYMBOL_GPL(pm_relax); * in @data if it is currently active and its timer has not been canceled and * the expiration time of the timer is not in future. */ -static void pm_wakeup_timer_fn(unsigned long data) +static void pm_wakeup_timer_fn(struct timer_list *t) { - struct wakeup_source *ws = (struct wakeup_source *)data; + struct wakeup_source *ws = from_timer(ws, t, timer); unsigned long flags; spin_lock_irqsave(&ws->lock, flags);