Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp109398ybk; Fri, 8 May 2020 20:26:14 -0700 (PDT) X-Google-Smtp-Source: APiQypJNPgUKuHSisdaH7UbHEsihQEDbnXlWx1uTUl8oUnDO0KjqrRFY9d153g2pipkeuU0oQBAY X-Received: by 2002:a17:906:534b:: with SMTP id j11mr4444805ejo.142.1588994774782; Fri, 08 May 2020 20:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588994774; cv=none; d=google.com; s=arc-20160816; b=Bwjzn5hkkvCGqx7YvdfzCOSlUmjdVjxW0pL9MCYRDpgrmA9lBQ+3l+QDy8tJ4tniY9 Ja/S/F3sK/QRq/4yDNT+mDRkpn2pwnYhPfvYpjLo9luuxvdeeWVX3kM5ZfpH213gCDpe YOc0VszKGBky4KNuBYPg9VoMjVmJUxxBbFcyIBa5FAj+ygx/8pWCq5xylzmx7wYIw5f4 6hozAtu8QZmMopBzbhY2gnyUxwFvD4HLQAm/xziUAVA+pjAAkiP38lfewMRCCr6sjsx6 3vrW5yk8yIZhC79bBdRT0va4lzGRfN1EqZNWlEqVjC3FXy6hek9sArwfdXQIuCcaDN/E AvMA== 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:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=VCha0HiNMvajEi5zlTXgkd/UcvUs4a/gMrfzzG0S0i0=; b=hZJLCpJqmNc0n/rBNBTbJJLQVtNcvMW5F/TTFf145C1gY4ZX8zXzQfGxqPM9iPUgDk h/4jjnpU9KoshnG35eWYmEhBUVa0XD+qjHVp4cpdEQ2rxF8e6aI1QXZ51X+wf6oGjU2C ubMfZfCWqJhiVz87Ud8ifwaX+4djfku8GDgWnmhixNpAWMmrkP2IsXQpOLSSub+uvEUl dMZZYKDgi3QBDc4it35oKBoy0kNocU05YEGmolQqXnVsYZTiP3OUhv6PLmWe7dqICM+R xPBvfB8tnbF0VezoScggbm6Y0z6s2jrfOG5A+hTrHG0C3sdPUX8fP65vhPZQX1M1457O FULw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r25si1690811edo.482.2020.05.08.20.25.51; Fri, 08 May 2020 20:26:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728575AbgEIDYM (ORCPT + 99 others); Fri, 8 May 2020 23:24:12 -0400 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:37030 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728355AbgEIDYL (ORCPT ); Fri, 8 May 2020 23:24:11 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04397;MF=wenyang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0Txzw3bb_1588994648; Received: from IT-C02W23QPG8WN.local(mailfrom:wenyang@linux.alibaba.com fp:SMTPD_---0Txzw3bb_1588994648) by smtp.aliyun-inc.com(127.0.0.1); Sat, 09 May 2020 11:24:08 +0800 Subject: Re: [PATCH] usb: roles: Switch on role-switch uevent reporting To: Bryan O'Donoghue , heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org Cc: Chunfeng Yun , Suzuki K Poulose , Alexandre Belloni , chenqiwu , linux-kernel@vger.kernel.org References: <20200508162937.2566818-1-bryan.odonoghue@linaro.org> From: Wen Yang Message-ID: Date: Sat, 9 May 2020 11:24:08 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <20200508162937.2566818-1-bryan.odonoghue@linaro.org> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ?? 2020/5/9 ????12:29, Bryan O'Donoghue ะด??: > Right now we don't report to user-space a role switch when doing a > usb_role_switch_set_role() despite having registered the uevent callbacks. > > This patch switches on the notifications allowing user-space to see > role-switch change notifications and subsequently determine the current > controller data-role. > > example: > PFX=/devices/platform/soc/78d9000.usb/ci_hdrc.0 > > root@somebox# udevadm monitor -p > > KERNEL[49.894994] change $PFX/usb_role/ci_hdrc.0-role-switch (usb_role) > ACTION=change > DEVPATH=$PFX/usb_role/ci_hdrc.0-role-switch > SUBSYSTEM=usb_role > DEVTYPE=usb_role_switch > USB_ROLE_SWITCH=ci_hdrc.0-role-switch > SEQNUM=2432 > > Cc: Heikki Krogerus > Cc: Greg Kroah-Hartman > Cc: Chunfeng Yun > Cc: Suzuki K Poulose > Cc: Alexandre Belloni > Cc: Wen Yang > Cc: chenqiwu > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Bryan O'Donoghue > --- > drivers/usb/roles/class.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c > index 5b17709821df..27d92af29635 100644 > --- a/drivers/usb/roles/class.c > +++ b/drivers/usb/roles/class.c > @@ -49,8 +49,10 @@ int usb_role_switch_set_role(struct usb_role_switch *sw, enum usb_role role) > mutex_lock(&sw->lock); > > ret = sw->set(sw, role); > - if (!ret) > + if (!ret) { > sw->role = role; > + kobject_uevent(&sw->dev.kobj, KOBJ_CHANGE); > + } > > mutex_unlock(&sw->lock); > > Hi, we may also need to deal with the return value of kobject_uevent(). Should we move it under the line mutex_unlock(&sw->lock)? Regards, Wen