devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Russell King <linux@armlinux.org.uk>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Jonathan Corbet <corbet@lwn.net>,
	kernel test robot <lkp@intel.com>,
	kernel@pengutronix.de, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-doc@vger.kernel.org, David Jander <david@protonic.nl>,
	Luka Perkov <luka.perkov@sartura.hr>,
	Robert Marko <robert.marko@sartura.hr>
Subject: Re: [PATCH net-next v5 5/7] ethtool: add interface to interact with Ethernet Power Equipment
Date: Thu, 1 Sep 2022 20:21:59 -0700	[thread overview]
Message-ID: <20220901202159.2a600c70@kernel.org> (raw)
In-Reply-To: <20220831133240.3236779-6-o.rempel@pengutronix.de>

On Wed, 31 Aug 2022 15:32:38 +0200 Oleksij Rempel wrote:
> +/**
> + * pse_ethtool_get_status - get status of PSE control
> + * @psec: PSE control pointer
> + * @extack: extack for reporting useful error messages
> + * @status: struct to store PSE status
> + */
> +int pse_ethtool_get_status(struct pse_control *psec,
> +			   struct netlink_ext_ack *extack,
> +			   struct pse_control_status *status)
> +{
> +	const struct pse_controller_ops *ops;
> +	int err;
> +
> +	if (!psec)
> +		return 0;

Defensive programming?

> +	if (WARN_ON(IS_ERR(psec)))
> +		return -EINVAL;
> +
> +	ops = psec->pcdev->ops;
> +
> +	if (!ops->ethtool_get_status) {
> +		NL_SET_ERR_MSG(extack,
> +			       "PSE driver does not support status report");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	mutex_lock(&psec->pcdev->lock);
> +	err = ops->ethtool_get_status(psec->pcdev, psec->id, extack, status);
> +	mutex_unlock(&psec->pcdev->lock);
> +
> +	return err;
> +}
> +EXPORT_SYMBOL_GPL(pse_ethtool_get_status);
> +
> +/**
> + * pse_ethtool_set_config - set PSE control configuration
> + * @psec: PSE control pointer
> + * @extack: extack for reporting useful error messages
> + * @config: Configuration of the test to run
> + */
> +int pse_ethtool_set_config(struct pse_control *psec,
> +			   struct netlink_ext_ack *extack,
> +			   const struct pse_control_config *config)
> +{
> +	const struct pse_controller_ops *ops;
> +	int err;
> +
> +	if (!psec)
> +		return 0;
> +
> +	if (WARN_ON(IS_ERR(psec)))
> +		return -EINVAL;

ditto

> +	ops = psec->pcdev->ops;
> +
> +	if (!ops->ethtool_set_config) {
> +		NL_SET_ERR_MSG(extack,
> +			       "PSE driver does not configuration");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	mutex_lock(&psec->pcdev->lock);
> +	err = ops->ethtool_set_config(psec->pcdev, psec->id, extack, config);
> +	mutex_unlock(&psec->pcdev->lock);
> +
> +	return err;
> +}
> +EXPORT_SYMBOL_GPL(pse_ethtool_set_config);

> +int pse_ethtool_get_status(struct pse_control *psec,
> +			   struct netlink_ext_ack *extack,
> +			   struct pse_control_status *status)
> +{
> +	return -ENOTSUPP;

EOPNOTSUPP, please run checkpatch --strict on this patch.
All of the complaints look legit at a glance.


> +	ETHTOOL_MSG_PSE_NTF,

I don't see you calling the ethtool_notify() function, does this ever

> +static int pse_prepare_data(const struct ethnl_req_info *req_base,
> +			       struct ethnl_reply_data *reply_base,
> +			       struct genl_info *info)
> +{
> +	struct pse_reply_data *data = PSE_REPDATA(reply_base);
> +	struct net_device *dev = reply_base->dev;
> +	int ret;
> +
> +	ret = ethnl_ops_begin(dev);
> +	if (ret < 0)
> +		return 0;

humpf, return ret;?

> +	ret = pse_get_pse_attributs(dev, info->extack, data);
> +
> +	ethnl_ops_complete(dev);
> +
> +	return ret;
> +}
> +
> +static int pse_reply_size(const struct ethnl_req_info *req_base,
> +			  const struct ethnl_reply_data *reply_base)
> +{
> +	const struct pse_reply_data *data = PSE_REPDATA(reply_base);
> +	const struct pse_control_status *st = &data->status;
> +	int len = 0;
> +
> +	if (st->podl_admin_state >= 0)

UNKNOWN is now 1, should be > 0 ?

> +		len += nla_total_size(sizeof(u32)); /* _PODL_PSE_ADMIN_STATE */
> +	if (st->podl_pw_status >= 0)
> +		len += nla_total_size(sizeof(u32)); /* _PODL_PSE_PW_D_STATUS */
> +
> +	return len;
> +}

> +	if (!phydev)
> +		return -EOPNOTSUPP;
> +
> +	if (!phydev->psec)
> +		ret = -EOPNOTSUPP;

Would be good to slap an extack msg on the two errors here.

> +	else
> +		ret = pse_ethtool_set_config(phydev->psec, extack, &config);

And avoid indenting the success path. So the !phydev->psec should
contain a return.

> +	return ret;
> +}

  reply	other threads:[~2022-09-02  3:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-31 13:32 [PATCH net-next v5 0/7] add generic PSE support Oleksij Rempel
2022-08-31 13:32 ` [PATCH net-next v5 1/7] dt-bindings: net: phy: add PoDL PSE property Oleksij Rempel
2022-08-31 13:32 ` [PATCH net-next v5 2/7] net: add framework to support Ethernet PSE and PDs devices Oleksij Rempel
2022-08-31 13:32 ` [PATCH net-next v5 3/7] net: mdiobus: fwnode_mdiobus_register_phy() rework error handling Oleksij Rempel
2022-08-31 13:32 ` [PATCH net-next v5 4/7] net: mdiobus: search for PSE nodes by parsing PHY nodes Oleksij Rempel
2022-08-31 13:32 ` [PATCH net-next v5 5/7] ethtool: add interface to interact with Ethernet Power Equipment Oleksij Rempel
2022-09-02  3:21   ` Jakub Kicinski [this message]
2022-09-02  3:22   ` Jakub Kicinski
2022-08-31 13:32 ` [PATCH net-next v5 6/7] dt-bindings: net: pse-dt: add bindings for regulator based PoDL PSE controller Oleksij Rempel
2022-09-02 20:50   ` Rob Herring
2022-08-31 13:32 ` [PATCH net-next v5 7/7] net: pse-pd: add regulator based PSE driver Oleksij Rempel

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=20220901202159.2a600c70@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=david@protonic.nl \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lkp@intel.com \
    --cc=luka.perkov@sartura.hr \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=robert.marko@sartura.hr \
    --cc=robh+dt@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).