From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751360AbdAOPXw (ORCPT ); Sun, 15 Jan 2017 10:23:52 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:58259 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751054AbdAOPXu (ORCPT ); Sun, 15 Jan 2017 10:23:50 -0500 Subject: Re: Calling device_init_wakeup() on driver removal To: "Rafael J. Wysocki" References: <3852101.qr97BxrLhj@aspire.rjw.lan> Cc: Len Brown , Pavel Machek , Greg Kroah-Hartman , "linux-pm@vger.kernel.org" , "linux-kernel@vger.kernel.org" From: Guenter Roeck Message-ID: Date: Sun, 15 Jan 2017 07:23:28 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <3852101.qr97BxrLhj@aspire.rjw.lan> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: linux@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: linux@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/15/2017 06:49 AM, Rafael J. Wysocki wrote: > On Saturday, January 14, 2017 08:46:05 PM Guenter Roeck wrote: >> Hi folks, > > Hi, > >> while looking through driver initialization and removal functions, I noticed that many drivers >> call device_init_wakeup(dev, false) in the removal function. Given that the driver is about >> to be removed, that doesn't make much sense to me, especially since device_wakeup_disable() >> is called from device_pm_remove() anyway. >> >> Is it safe to assume that all those calls can be removed, or is there a possible reason for >> keeping them around ? > > Removing them automatically might break things, because device_init_wakeup(dev, false) > also clears the power.can_wakeup flag and removes the "wakeup" attribute from sysfs. > I had the same concern, but I concluded that the wakeup attribute should be removed automatically, since it is added with sysfs_merge_group(), and the matching unmerge call is also made in dpm_sysfs_remove(). power.can_wakeup is part of the device structure, which is in the process of being removed, so I am not sure I understand how that can be problematic. > I guess they could be removed safely in the majority of cases, though. How would one decide if it is needed ? I see some drivers call it on remove, but others don't. I don't see a clear pattern; unless I am missing something, it seems to be more or less random. Thanks, Guenter