Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp196712ybj; Fri, 8 May 2020 09:34:33 -0700 (PDT) X-Google-Smtp-Source: APiQypLJJjqNVvs8bDzegWxzvWSW/1ieWKaDu2z01osv7a1NnhvJ/5P/Cq4Om4gYIMQsG1Ttjhyg X-Received: by 2002:a17:906:35cd:: with SMTP id p13mr2735071ejb.206.1588955673105; Fri, 08 May 2020 09:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588955673; cv=none; d=google.com; s=arc-20160816; b=gDiQRT3k2Qg2MJRvdJ5YJJZHIJ7+QVVDHgeJigCjf0sM3eNiIeDQ8ZrFk/VCxiPYjs DOIXQo2mRcJFKkD5byRgKDBis8WhCGG1EZi5Nv90TkzXhIXm0mXfwjCJuuz+6CNtnq79 Vc1BTt5Pnku+Ses7e71MCyNmFJefLlnYAhLcJOM1hX0vJCJv26s2aCyEECyXd966dzDU kKQV1vwJoouDlSdsmlo+yGBWDysY94vJnHVsLiPPVW0mrI5ZGHTySh5AfvA/eIpqWth7 MEx7CJNfD/qekrlNLvr9GkJ8/Z2+9Ho/Mg1NUCDq/J7Qv3M0boIXMfoSiTrPlsplfqy4 Sv0g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=+iuOH/WKVgDwlOpqLtEZz1Xk/okLvZZF5WbQRpij0D4=; b=J4atJQ/20wp3d0klij6WsUwUQvSUM7p6rgkzXRpTlhQipwR7NpOr7d6wXlMna5V2Hx 6LoMTXBvEq6DJvrjkyYz0NPyDWLjVK+WyfsTb+1bTJkJrU+fipvPWbs7dlCmIFs5jnvT Vaoq2m2gHos7k1AEzRW6Ck9tfh5wQ0pNLJbW6Pz26qVl6MmJ2Fu3b8aW39/tDF3SaGI/ tDuNhlBUELeumxsFUyKzXBXcd2ots9VlxB0rG/zBWYfkwBFFieDt5svntbyyilNXGrz9 hpKeqBtFg7NgATmWwq1YYujPCMan2u+Glpxo0S/dpPGH3oDo9s2jyDVa9rk7gB7UpFBF KiJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AQt+ZF9/"; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d26si1307423ejc.216.2020.05.08.09.34.08; Fri, 08 May 2020 09:34:33 -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=@linaro.org header.s=google header.b="AQt+ZF9/"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727834AbgEHQ3q (ORCPT + 99 others); Fri, 8 May 2020 12:29:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726797AbgEHQ3q (ORCPT ); Fri, 8 May 2020 12:29:46 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3DC8C05BD09 for ; Fri, 8 May 2020 09:29:45 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id k1so2600106wrx.4 for ; Fri, 08 May 2020 09:29:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+iuOH/WKVgDwlOpqLtEZz1Xk/okLvZZF5WbQRpij0D4=; b=AQt+ZF9/H2qk/OzomabTHPI7WvMlnn1Z6hG6gqNJIe5EizYLqFoDrDWpINidOLAgaq qkxTNC5J00AzTlAZQvnF/dbaHsDAfE/fqpCtkW3hlE9kjdjAD2q5eUUncCpBNBKPnrdk 2wk+lL8bnj8EForOpu5KW38XHvLpS//BMB7EkbmGLPrMNq3FjPdICxV0v9XVmU+jc4kp 1fEPrrVGBkose3eZ3JXKQscdx2Fq7231IQxf8FdX6I8EeAomwFNy7dhjmQ01wP6ryr5h eH5eNWJrEHOenSXHxlSlCIxzCFu3/8/Fr8Nu6qAxo7p87nmqcfk0mWMEd+JSCV8IHaUm FvRg== 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:mime-version :content-transfer-encoding; bh=+iuOH/WKVgDwlOpqLtEZz1Xk/okLvZZF5WbQRpij0D4=; b=qZkIYPdLVKVyf6NGNgcDYG5DEj1ARxc6ENPjbuAtcD1YtthDFHNqyCmoMRmqIVpCq5 bSyP0VFSHqw4dBfvK3OgKHfH+LHqgmIBHwW7KTuLXUYd3m+sd3R4w4Xatgyy71cm/F4X /DNKhtlw424UKJ789wa4rZLBOYkN2vPapXwZ1fodov3IMYt9NcsNYGVSP5Af6pGDBfOr /B0vfXuHyq2G3O+KJYJHYb1Ywjsy3FU2iroMfabLiBvZ1AVtqk3IiiTpJFpMCY4LMoAZ Db6dEDKH5Sko9bK9d4nZZC3aesg5aPkr8uKQlVCA6wlSVamkgUraPhOePr0rqD8F1rQF hpVg== X-Gm-Message-State: AGi0PuY1r7ioY1/3UWWEnwSLYrpBDXYb1gz41m6/Z03YrxBBdHUDGeuY PiYTSDmTA6bGKnfcysTItotZ0w== X-Received: by 2002:a5d:61c5:: with SMTP id q5mr3933822wrv.398.1588955384626; Fri, 08 May 2020 09:29:44 -0700 (PDT) Received: from localhost.localdomain ([176.61.57.127]) by smtp.gmail.com with ESMTPSA id w15sm3602749wrl.73.2020.05.08.09.29.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2020 09:29:43 -0700 (PDT) From: Bryan O'Donoghue To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, bryan.odonoghue@linaro.org Cc: Chunfeng Yun , Suzuki K Poulose , Alexandre Belloni , Wen Yang , chenqiwu , linux-kernel@vger.kernel.org Subject: [PATCH] usb: roles: Switch on role-switch uevent reporting Date: Fri, 8 May 2020 17:29:37 +0100 Message-Id: <20200508162937.2566818-1-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.25.1 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 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); -- 2.25.1