Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1543424rdb; Thu, 7 Dec 2023 02:03:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IEbaXiDMouu9lBLfs0+tn69PoRNooVMK+tj9kCpXo2m38CrgKyDqcYd+29+sds27x3cJBpf X-Received: by 2002:a05:6a20:7da7:b0:18f:e697:19d7 with SMTP id v39-20020a056a207da700b0018fe69719d7mr1977653pzj.55.1701943382112; Thu, 07 Dec 2023 02:03:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701943382; cv=none; d=google.com; s=arc-20160816; b=TX8zMClDZSD00SFUtSsI1aL0GAbZgmjob9gdyX+MKkM/XLNyeSHoItINT2cXSG6tQe 9Ip4GlQ+5/oZ+jn5w/DXSfgHZeY/YZdR85pHn1ghFKLq7wGpml14X8kYN8JHIPGClUdA 5wrGE4tj0lGjQ/aQ5xupHXzo87U+zSgfutEwd9UNt8xBp4o+fIlA7m5z9lXmIzeinCqp at9AUMIG0GU7yJsCLWfEiG428Lc7S6a8AnQbQT4SOsynnueb/4aZQqt4O52/q35yi6LG z29cx6M0rY6k2/0n11421b5SsltV0I3OXp9b0FJoRWg2pNslKvFrtdXhELe1zuV1JMvX qRcw== 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=VmaVtqgtTDFH04sQy1qVQqvjp2Sbq2/X8bJeZlgu6CA=; fh=cFnXvyTT3ReEyYQhZiles+5GEFSR1fmpNaMDS+e4xko=; b=jEjoJ81DYj2jPD2PmqgKinHsxMcdyD+XfgrNyn7axCEBZlojKFxKr7Rj5By0MPsxpH 7mD/7VsS8NxV8Z/dcAg+4mYrBDrYkYkk+rdEqaQ7RxJwtCbBAbDqdakFejGeIXU+yNWh y+qAysyRKOEljz6R0TIILU7UAMwd19gOn7VSMYoFv9oL33CR92lNsTWhvMJL5DvRTaBl xU/o8s3TQaHZhznx04VQgpSV9nuexfqYabHcm/Qu/YoaHDpF3UoZYMh0a1eNw0wYiT5z hkth8+QBLJ1oQJTsWm6PXU795sMeTtL4fO+D4uybJZgcUmBaAYg3AluV/MV3aQNILWXE uWeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JGbWkqWp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id mh7-20020a17090b4ac700b00286e8838b6fsi872486pjb.119.2023.12.07.02.03.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 02:03:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JGbWkqWp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5F1B98041E9C; Thu, 7 Dec 2023 02:02:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232406AbjLGKCn (ORCPT + 99 others); Thu, 7 Dec 2023 05:02:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232066AbjLGKCm (ORCPT ); Thu, 7 Dec 2023 05:02:42 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF253A8 for ; Thu, 7 Dec 2023 02:02:48 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A7E0C433C8; Thu, 7 Dec 2023 10:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1701943368; bh=SPYAWlnL7TYvvD5fILwvuEjH1F0EdpQ2gn+SMCdXalU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JGbWkqWpE69/KJTLtC9uM/RqiNerYeh5JRHhvMQxGLKrVcgHs+Y1zw+vFVQ9PkZce 11S9dN4QYOZ6GJPXmQz8QV21+ujNRkIa0TTugszsraf4/zenmpWN536nrfxuUpfUl2 bSPBfKG/ulSlq2nXvBrk65Pw8961XtNzLOTLXlb0= Date: Thu, 7 Dec 2023 11:02:43 +0100 From: Greg Kroah-Hartman To: Stanley Chang Cc: Vinod Koul , Johan Hovold , Kishon Vijay Abraham I , Geert Uytterhoeven , Jinjie Ruan , Rob Herring , Alan Stern , Heikki Krogerus , Flavio Suligoi , Ricardo =?iso-8859-1?Q?Ca=F1uelo?= , linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, linux-usb@vger.kernel.org Subject: Re: [PATCH v3 RESEND 1/4] phy: core: add notify_connect and notify_disconnect callback Message-ID: <2023120750-giggle-annotate-dc4f@gregkh> References: <20231207074022.14116-1-stanley_chang@realtek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231207074022.14116-1-stanley_chang@realtek.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 07 Dec 2023 02:02:59 -0800 (PST) On Thu, Dec 07, 2023 at 03:38:04PM +0800, Stanley Chang wrote: > In Realtek SoC, the parameter of usb phy is designed to can dynamic > tuning base on port status. Therefore, add a notify callback of phy > driver when usb connection/disconnection change. > > Signed-off-by: Stanley Chang > --- > RESEND: > Because there is no extcon device provided in the USB framework to > notify connect and disconnect. > Therefore, I added the notification connection/disconnection based > on the generic phy. So I no use the EXTCON framework for notifying > connect/disconnect. > v2 to v3: > No change > v1 to v2: > No change > --- > drivers/phy/phy-core.c | 47 +++++++++++++++++++++++++++++++++++++++++ > include/linux/phy/phy.h | 18 ++++++++++++++++ > 2 files changed, 65 insertions(+) > > diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c > index 96a0b1e111f3..a84ad4896b7f 100644 > --- a/drivers/phy/phy-core.c > +++ b/drivers/phy/phy-core.c > @@ -489,6 +489,53 @@ int phy_calibrate(struct phy *phy) > } > EXPORT_SYMBOL_GPL(phy_calibrate); > > +/** > + * phy_notify_connect() - phy connect notify > + * @phy: the phy returned by phy_get() > + * @port: the port index for connect > + * > + * If phy need the get connection status, the callback can be used. > + * Returns: %0 if successful, a negative error code otherwise > + */ > +int phy_notify_connect(struct phy *phy, int port) > +{ > + int ret; > + > + if (!phy || !phy->ops->connect) > + return 0; How can phy be null? And it is not successful if connect is not valid, so why not return an error there? > + > + mutex_lock(&phy->mutex); > + ret = phy->ops->connect(phy, port); > + mutex_unlock(&phy->mutex); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(phy_notify_connect); > + > +/** > + * phy_notify_disconnect() - phy disconnect notify > + * @phy: the phy returned by phy_get() > + * @port: the port index for disconnect > + * > + * If phy need the get disconnection status, the callback can be used. > + * > + * Returns: %0 if successful, a negative error code otherwise > + */ > +int phy_notify_disconnect(struct phy *phy, int port) > +{ > + int ret; > + > + if (!phy || !phy->ops->disconnect) > + return 0; Same as above. > + > + mutex_lock(&phy->mutex); > + ret = phy->ops->disconnect(phy, port); > + mutex_unlock(&phy->mutex); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(phy_notify_disconnect); > + > /** > * phy_configure() - Changes the phy parameters > * @phy: the phy returned by phy_get() > diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h > index f6d607ef0e80..cf98cb29ddaa 100644 > --- a/include/linux/phy/phy.h > +++ b/include/linux/phy/phy.h > @@ -122,6 +122,8 @@ struct phy_ops { > union phy_configure_opts *opts); > int (*reset)(struct phy *phy); > int (*calibrate)(struct phy *phy); > + int (*connect)(struct phy *phy, int port); > + int (*disconnect)(struct phy *phy, int port); You forgot to document these and would have a warning from the documentation build if this was applied :( > void (*release)(struct phy *phy); > struct module *owner; > }; > @@ -243,6 +245,8 @@ static inline enum phy_mode phy_get_mode(struct phy *phy) > } > int phy_reset(struct phy *phy); > int phy_calibrate(struct phy *phy); > +int phy_notify_connect(struct phy *phy, int port); > +int phy_notify_disconnect(struct phy *phy, int port); > static inline int phy_get_bus_width(struct phy *phy) > { > return phy->attrs.bus_width; > @@ -396,6 +400,20 @@ static inline int phy_calibrate(struct phy *phy) > return -ENOSYS; > } > > +static inline int phy_notify_connect(struct phy *phy, int index) > +{ > + if (!phy) > + return 0; Why check this? > + return -ENOSYS; > +} > + > +static inline int phy_notify_disconnect(struct phy *phy, int index) > +{ > + if (!phy) > + return 0; Again, why check this? thanks, greg k-h