lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 9 Oct 2018 10:52:53 +0530
From:   Kishon Vijay Abraham I <kishon@...com>
To:     Grygorii Strashko <grygorii.strashko@...com>,
        "David S. Miller" <davem@...emloft.net>, <netdev@...r.kernel.org>,
        Tony Lindgren <tony@...mide.com>,
        Rob Herring <robh+dt@...nel.org>
CC:     Sekhar Nori <nsekhar@...com>, <linux-kernel@...r.kernel.org>,
        <linux-omap@...r.kernel.org>, <devicetree@...r.kernel.org>
Subject: Re: [RFC PATCH 01/11] phy: core add phy_set_netif_mode() api

Hi Grygorii,

On Tuesday 09 October 2018 05:19 AM, Grygorii Strashko wrote:
> Add new API phy_set_netif_mode(struct phy *phy, phy_interface_t mode) and
> new PHY operation callback .set_netif_mode() which intended to be implemnte
> by PHY drivers which supports Network interrfaces mode selection. Both
> accepts phy_interface_t vlaue as input parameter.
> 
> Cc: Kishon Vijay Abraham I <kishon@...com>
> Cc: Tony Lindgren <tony@...mide.com>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@...com>
> ---
>  drivers/phy/phy-core.c  | 15 +++++++++++++++
>  include/linux/phy/phy.h | 12 ++++++++++++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index 35fd38c..d9aba1a 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -377,6 +377,21 @@ int phy_set_mode(struct phy *phy, enum phy_mode mode)
>  }
>  EXPORT_SYMBOL_GPL(phy_set_mode);
>  
> +int phy_set_netif_mode(struct phy *phy, phy_interface_t mode)
> +{
> +	int ret;
> +
> +	if (!phy || !phy->ops->set_netif_mode)
> +		return 0;
> +
> +	mutex_lock(&phy->mutex);
> +	ret = phy->ops->set_netif_mode(phy, mode);
> +	mutex_unlock(&phy->mutex);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(phy_set_netif_mode);

We should try to add only generic PHY APIs and not subsystem specific APIs. In
this case I think phy_set_mode should suffice.

Thanks
Kishon

> +
>  int phy_reset(struct phy *phy)
>  {
>  	int ret;
> diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
> index 9713aeb..bc73d2b 100644
> --- a/include/linux/phy/phy.h
> +++ b/include/linux/phy/phy.h
> @@ -17,6 +17,7 @@
>  #include <linux/err.h>
>  #include <linux/of.h>
>  #include <linux/device.h>
> +#include <linux/phy.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/regulator/consumer.h>
>  
> @@ -49,6 +50,7 @@ enum phy_mode {
>   * @power_on: powering on the phy
>   * @power_off: powering off the phy
>   * @set_mode: set the mode of the phy
> + * @set_netif_mode: set the mode of the net interface phy
>   * @reset: resetting the phy
>   * @calibrate: calibrate the phy
>   * @owner: the module owner containing the ops
> @@ -59,6 +61,7 @@ struct phy_ops {
>  	int	(*power_on)(struct phy *phy);
>  	int	(*power_off)(struct phy *phy);
>  	int	(*set_mode)(struct phy *phy, enum phy_mode mode);
> +	int	(*set_netif_mode)(struct phy *phy, phy_interface_t mode);
>  	int	(*reset)(struct phy *phy);
>  	int	(*calibrate)(struct phy *phy);
>  	struct module *owner;
> @@ -163,6 +166,7 @@ int phy_exit(struct phy *phy);
>  int phy_power_on(struct phy *phy);
>  int phy_power_off(struct phy *phy);
>  int phy_set_mode(struct phy *phy, enum phy_mode mode);
> +int phy_set_netif_mode(struct phy *phy, phy_interface_t mode);
>  static inline enum phy_mode phy_get_mode(struct phy *phy)
>  {
>  	return phy->attrs.mode;
> @@ -283,6 +287,14 @@ static inline int phy_set_mode(struct phy *phy, enum phy_mode mode)
>  	return -ENOSYS;
>  }
>  
> +static inline int phy_set_netif_mode(struct phy *phy,
> +				     phy_interface_t mode)
> +{
> +	if (!phy)
> +		return 0;
> +	return -ENOTSUPP;
> +}
> +
>  static inline enum phy_mode phy_get_mode(struct phy *phy)
>  {
>  	return PHY_MODE_INVALID;
> 

Powered by blists - more mailing lists