Re: [PATCH net-next v5 5/7] ethtool: add interface to interact with Ethernet Power Equipment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
> +}



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux