All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wen Yang <wenyang@linux.alibaba.com>
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
	heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org,
	linux-usb@vger.kernel.org
Cc: Chunfeng Yun <chunfeng.yun@mediatek.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	chenqiwu <chenqiwu@xiaomi.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: roles: Switch on role-switch uevent reporting
Date: Sat, 9 May 2020 11:24:08 +0800	[thread overview]
Message-ID: <fbd660ca-fe2a-8ca7-5076-f898acd1ca74@linux.alibaba.com> (raw)
In-Reply-To: <20200508162937.2566818-1-bryan.odonoghue@linaro.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 <heikki.krogerus@linux.intel.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Chunfeng Yun <chunfeng.yun@mediatek.com>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Wen Yang <wenyang@linux.alibaba.com>
> Cc: chenqiwu <chenqiwu@xiaomi.com>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>   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


  reply	other threads:[~2020-05-09  3:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08 16:29 [PATCH] usb: roles: Switch on role-switch uevent reporting Bryan O'Donoghue
2020-05-09  3:24 ` Wen Yang [this message]
2020-05-09 16:37   ` Bryan O'Donoghue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fbd660ca-fe2a-8ca7-5076-f898acd1ca74@linux.alibaba.com \
    --to=wenyang@linux.alibaba.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=bryan.odonoghue@linaro.org \
    --cc=chenqiwu@xiaomi.com \
    --cc=chunfeng.yun@mediatek.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=suzuki.poulose@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.