Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1177896ybt; Tue, 7 Jul 2020 09:24:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzA32lXFdO28n32GpAAy6blq7eRtOOwZ6pgjP8TAZqJcmgBiz7IHoh4A+N8Eoy1//ZJkLPD X-Received: by 2002:a05:6402:1614:: with SMTP id f20mr59967291edv.129.1594139098277; Tue, 07 Jul 2020 09:24:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594139098; cv=none; d=google.com; s=arc-20160816; b=KZyrZha9HBPOqTKPiYyxDCodrJn9J9t/X8tRwf93sz/bK2rP+FfWv5tyiHRT9AZ5bz ra7cAgN85gWMnHwOrez5Q37ddYWLoM+rKYUOy0q2N13E3/Jg4l0PD8Px+zt5EvkevFv5 Qou29T8191Uop1D0XXkPVAGg+gbCiL2c8oOaEr1Vt6xIxbZ0iXS/AkgMbw03AvQMnpLm TCGgYIFEWF4TocikyZFVfv2bVwNwzzds+XqdZIDc9oQwrm60DEplXHmvHtK816ruWVse z8/+t2ZjdqomgY6yHmzhJhxb/C76HAmHLSLp1Ai1DhV0pCCApKM4i0k8csKAqUUSjwu/ Pl9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=u5qLlzv2IdrRVupqKqhulZt6939J+XBU60CiFxmM7cU=; b=Hjq+8eUMNLwYftOePnccm19y7yB7coSGmcFoZI2FeetvSXjt8H5M45D7sVM/xD7zix 3b2oKwlBuvtTMM9oe831OvC7baGBXQZvmZGd++sqlxDsWqc4zXCCICJxuaj52kOGemUb xJV7WAtAqpd677dnOBjNFMVQTePHCSXDLRJaUH78XK8lmxXvxATGjr0r8coT9ReCRxSg 8bCKXt1+tcBCTI+VjzczsByg0l5HcWQwM9LlwcvIG5UfO00i0wxXI/B72l60p3HYiuEU fo0eF/TVHwSng9rFY8vGT/Exq48OE7qD99xkBK8LcJisku+9dzTpdBGrPipcIs7lmYdl sogw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VQXfal6S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z11si1078808ejm.102.2020.07.07.09.24.35; Tue, 07 Jul 2020 09:24:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VQXfal6S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727789AbgGGQYa (ORCPT + 99 others); Tue, 7 Jul 2020 12:24:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728191AbgGGQY3 (ORCPT ); Tue, 7 Jul 2020 12:24:29 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3BAEC08C5E1 for ; Tue, 7 Jul 2020 09:24:29 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id 207so18453604pfu.3 for ; Tue, 07 Jul 2020 09:24:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u5qLlzv2IdrRVupqKqhulZt6939J+XBU60CiFxmM7cU=; b=VQXfal6SP48mb+vig4iHdom3I2bB3mnJ44t9z32OcHIh1Nr57lzNzH42xrgkRUiF/w GnrEUHLPWufx2Smn911xp8Ln7oxiyrNsVjYM6SKl3dAaOKQIW1UZR7Ay2+MA3gkD8xUq kTfdRupNbe3AbhnA8wa+W1HyqMOsP99kfS9yo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u5qLlzv2IdrRVupqKqhulZt6939J+XBU60CiFxmM7cU=; b=jOHoo1oJYYY2QiqQQVdfqdyuWfRJ5I7JMfz5n2McjkLqDKFuGXNNiSD7rLULgvN8+s UawupaMdHjJY7EM8BO1Ln9FcAStllpP+w6CyPzJSMKjmSXvs8pCwqqh1NOnBEFLshlDu 3Omkc7sFy1Rr8ADoQgVs4vlq0f+n17b2i7G7LvnsQxZXPqGTkAxo40yUs+KkavNxCA+7 CQIvYbrQl9bLA8bOpbk3+CWv+eJQWENXgzB+Y1o6cFHcvO1eMzj1nj2ekRu9dJElPylm WIQd/b+cEDOefoNHcwHfNQ3TcqIio3XaISJV/KvoZYUpZEo+GI/B6xRWcVJz5YxaBd9w 2X/Q== X-Gm-Message-State: AOAM530NLRXbT9FRphKwDQ2p+K27cNn3RwxB10lHt5NDF4WJAWbf670x nEUic+/pgZk8mCh3AZcxVHE+oA== X-Received: by 2002:a63:3508:: with SMTP id c8mr46959312pga.9.1594139069345; Tue, 07 Jul 2020 09:24:29 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id s10sm3758196pjf.3.2020.07.07.09.24.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 09:24:28 -0700 (PDT) From: Abhishek Pandit-Subedi To: Greg Kroah-Hartman , linux-pm@vger.kernel.org Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, rafael.j.wysocki@intel.com, swboyd@chromium.org, Abhishek Pandit-Subedi , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Pavel Machek Subject: [PATCH v4 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove Date: Tue, 7 Jul 2020 09:24:17 -0700 Message-Id: <20200707092406.v4.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200707162417.3514284-1-abhishekpandit@chromium.org> References: <20200707162417.3514284-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Udev rules that depend on the power/wakeup attribute don't get triggered correctly if device_set_wakeup_capable is called after the device is created. This can happen for several reasons (driver sets wakeup after device is created, wakeup is changed on parent device, etc) and it seems reasonable to emit a changed event when adding or removing attributes on the device. Signed-off-by: Abhishek Pandit-Subedi --- Changes in v4: - Fix warning where returning from void and tested on device Changes in v3: - Simplified error handling Changes in v2: - Add newline at end of bt_dev_err drivers/base/power/sysfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index 24d25cf8ab1487..aeb58d40aac8de 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* sysfs entries for device PM */ #include +#include #include #include #include @@ -739,12 +740,18 @@ int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid) int wakeup_sysfs_add(struct device *dev) { - return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); + int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); + + if (ret) + return ret; + + return kobject_uevent(&dev->kobj, KOBJ_CHANGE); } void wakeup_sysfs_remove(struct device *dev) { sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); + kobject_uevent(&dev->kobj, KOBJ_CHANGE); } int pm_qos_sysfs_add_resume_latency(struct device *dev) -- 2.27.0.212.ge8ba1cc988-goog