Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp294055pxu; Thu, 7 Jan 2021 05:22:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/AV0iTUR8byWjNtvdbqa/uzSOUJ+xFYddT1wTQDIa1HtGIxwsfs0UoKdOeq7SkShqG+4P X-Received: by 2002:a17:906:1ed6:: with SMTP id m22mr6569100ejj.231.1610025738548; Thu, 07 Jan 2021 05:22:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610025738; cv=none; d=google.com; s=arc-20160816; b=P46t8OXUQi/oB0Ncd2yrlLVnWOCZaD9gSrW/uO2CZ3mc+do2P8tgEiWzj0eW8hdd+G iq3XQyKw2WwdStx8qZhN6ng03RttoWm1SRHYj1Dj1wGGCzXRr0w24J/gkWzNc1TWPD+i Rtmb1DAfqH4U6FWHKsAh/1ky+ozq9fMxjr3poIdf/8tjf9zKF3sUAg13AWHCopMJGRWi y651nq5DRLrF4vqpGR+RW9274l8X42BbgAK+9YktVyAt+HAX7SiTclpWfZrBYDQXk09S aZyJEmp75BBG65/IcLx/2oXlisANosdqvVmam76rtBw+H2gPv/XLXoD7fLMFW3QWgZIu 1nAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8Wj6yAgUkkWjbVZhdFJhoPMfVzhIKr0qALaz9Qfu/EQ=; b=DaI2NFD/Wp6gX9J6KVuE4ajZxV7SXHf7c666LiEn3+vzAA4xk1v8kdF9KuzMwU4T/Y OJwy5Uoy9/TzPWHVuKo2v6cce0yK+eflDQ7INZ7Baz1fMw2vogNw0VoYIBNJKasjWpTX /yf3kf7j5TwfxKAeYbFQjN9ej5s6bX66IsZ9Y/Al7vHVqjb+la4te3kx1sKWjdK1YU9x FjVnKY++mCj7H23kD/BKhc8r1cMIQbcf2CxrGPCqupKXGFOZPU/pi7ElOzRLlx5q2EFe MOL8qIwpRDKrZleN1SnR3kOFP05gsQy21fAEstYjtcGYhYIgG6z6DoCc1psxK+ju47oR mKxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Thohcnoo; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce12si2290155edb.604.2021.01.07.05.21.54; Thu, 07 Jan 2021 05:22:18 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=Thohcnoo; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728161AbhAGNVP (ORCPT + 99 others); Thu, 7 Jan 2021 08:21:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:58096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728128AbhAGNVO (ORCPT ); Thu, 7 Jan 2021 08:21:14 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 90B5C2065E; Thu, 7 Jan 2021 13:20:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610025634; bh=VJr6FZamdmy1K/mFU31CgN1qGuUyEOLL56Ue/i5GmcU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ThohcnooT8qscZgi1lsumJwGuncTLxh3yt7kyMmUahNJar9yl1Aem9tr1eWhxQ7gj kfbeJ90aIU/LwxRYSZehp9xNtkMYIBdhEiAs+cUr57ZJiOrYx0jG5k5NJh2GMaSfMW 4brjGI0NtCCh1kqqW88m+LyOS0M2Vy+pdoUiPpdA= Date: Thu, 7 Jan 2021 14:21:54 +0100 From: Greg KH To: Prashant Malani Cc: "open list:USB NETWORKING DRIVERS" , Heikki Krogerus , Benson Leung , open list Subject: Re: [PATCH] usb: typec: Send uevent for num_altmodes update Message-ID: References: <20210107034904.4112029-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 07, 2021 at 11:57:08AM +0100, Greg KH wrote: > On Thu, Jan 07, 2021 at 01:50:53AM -0800, Prashant Malani wrote: > > Hi Greg, > > > > Thanks for taking a look at the patch. > > > > On Thu, Jan 7, 2021 at 1:16 AM Greg KH wrote: > > > > > > On Wed, Jan 06, 2021 at 07:49:04PM -0800, Prashant Malani wrote: > > > > Generate a change uevent when the "number_of_alternate_modes" sysfs file > > > > for partners and plugs is updated by a port driver. > > > > > > > > Cc: Heikki Krogerus > > > > Cc: Benson Leung > > > > Signed-off-by: Prashant Malani > > > > --- > > > > drivers/usb/typec/class.c | 2 ++ > > > > 1 file changed, 2 insertions(+) > > > > > > > > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c > > > > index ebfd3113a9a8..8f77669f9cf4 100644 > > > > --- a/drivers/usb/typec/class.c > > > > +++ b/drivers/usb/typec/class.c > > > > @@ -766,6 +766,7 @@ int typec_partner_set_num_altmodes(struct typec_partner *partner, int num_altmod > > > > return ret; > > > > > > > > sysfs_notify(&partner->dev.kobj, NULL, "number_of_alternate_modes"); > > > > + kobject_uevent(&partner->dev.kobj, KOBJ_CHANGE); > > > > > > Shouldn't the sysfs_notify() handle the "something has changed" logic > > > good enough for userspace, as obviously someone is polling on the thing > > > (otherwise we wouldn't be calling sysfs_notify...) > > > > > > The kobject itself hasn't "changed", but rather an individual attribute > > > has changed. We don't want to create uevents for every individual sysfs > > > attribute changing values, do we? > > > > Fair point. I noticed other attributes in this source file use a > > similar approach (sysfs_notify + kobject_uevent) > > and took guidance from there in an attempt to remain consistent > > (though, of course, your point still stands). > > > > I'm guessing it is for processes that rely on udev events > > (subsystem=typec) rather than polling. > > > > > > > > What is preventing a normal "monitor the sysfs file" logic from working > > > here for anyone who wants to know that the alternate modes have changed? > > > > One limitation I can think of is that this sysfs file is hidden till > > it has a valid value (i.e >= 0), so a user-space process might not > > be able to poll on the file till it is visible (I suppose even then > > one could poll on the parent). > > If the file is being added at this point in time, then yes, it is ok to > send a KOBJ_CHANGE event as that is needed. Is that what is happening > here? In looking at the code more, yes, you are right, I'll go queue this up now, thanks. greg k-h