From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A08DEC47089 for ; Thu, 27 May 2021 07:28:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B71661028 for ; Thu, 27 May 2021 07:28:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232696AbhE0HaD (ORCPT ); Thu, 27 May 2021 03:30:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:38268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229753AbhE0HaD (ORCPT ); Thu, 27 May 2021 03:30:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 44EC861059; Thu, 27 May 2021 07:28:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622100509; bh=JaIyM9JOIaX8kTZxhm82AXcUEBSrdnzdxBrRGPKHC7w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kJJNGPzH150LOjO+txWMxQkpdLCxNFWP44M2DDeOl1Ya/ZpWgEBCANlKDUe6pkcu9 xr+gdroiMLX5ZWnPW7R24hgjWifhNm66keG2pHYqj0I8ITY2ES+agxLaZEnu7CwvEa Sztf9iqOlxqzfxX8SlSQmiOLa63PQID4fJD6/h70= Date: Thu, 27 May 2021 09:28:27 +0200 From: Greg Kroah-Hartman To: Chunfeng Yun Cc: Felipe Balbi , Matthias Brugger , Thinh Nguyen , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH 2/3] usb: common: add helper to get role-switch-default-mode Message-ID: References: <1621933165-9661-1-git-send-email-chunfeng.yun@mediatek.com> <1621933165-9661-2-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1621933165-9661-2-git-send-email-chunfeng.yun@mediatek.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Tue, May 25, 2021 at 04:59:24PM +0800, Chunfeng Yun wrote: > Add helper to get "role-switch-default-mode", and convert it > to the corresponding enum usb_dr_mode > > Signed-off-by: Chunfeng Yun > --- > drivers/usb/common/common.c | 20 ++++++++++++++++++++ > include/linux/usb/otg.h | 1 + > 2 files changed, 21 insertions(+) > > diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c > index fff318597337..78a625a4e526 100644 > --- a/drivers/usb/common/common.c > +++ b/drivers/usb/common/common.c > @@ -207,6 +207,26 @@ enum usb_dr_mode usb_get_dr_mode(struct device *dev) > } > EXPORT_SYMBOL_GPL(usb_get_dr_mode); > > +/** > + * usb_get_role_switch_default_mode - Get default mode for given device > + * @dev: Pointer to the given device > + * > + * The function gets string from property 'role-switch-default-mode', > + * and returns the corresponding enum usb_dr_mode. > + */ > +enum usb_dr_mode usb_get_role_switch_default_mode(struct device *dev) > +{ > + const char *str; > + int ret; > + > + ret = device_property_read_string(dev, "role-switch-default-mode", &str); > + if (ret < 0) > + return USB_DR_MODE_UNKNOWN; > + > + return usb_get_dr_mode_from_string(str); > +} > +EXPORT_SYMBOL_GPL(usb_get_role_switch_default_mode); > + > /** > * usb_decode_interval - Decode bInterval into the time expressed in 1us unit > * @epd: The descriptor of the endpoint > diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h > index a86ee6aad51b..bde313c97fb6 100644 > --- a/include/linux/usb/otg.h > +++ b/include/linux/usb/otg.h > @@ -121,5 +121,6 @@ enum usb_dr_mode { > }; > > extern enum usb_dr_mode usb_get_dr_mode(struct device *dev); > +extern enum usb_dr_mode usb_get_role_switch_default_mode(struct device *dev); What other code outside of the dwc3 driver will ever need to call this? thanks, greg k-h