Re: [PATCH RESEND net-next v7 05/16] net: pcs: add Renesas MII converter driver

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

 



On Fri, 10 Jun 2022 12:37:01 +0200 Clément Léger wrote:
> Subject: [PATCH RESEND net-next v7 05/16] net: pcs: add Renesas MII converter driver
> 
> Add a PCS driver for the MII converter that is present on the Renesas
> RZ/N1 SoC. This MII converter is reponsible for converting MII to
> RMII/RGMII or act as a MII pass-trough. Exposing it as a PCS allows to
> reuse it in both the switch driver and the stmmac driver. Currently,
> this driver only allows the PCS to be used by the dual Cortex-A7
> subsystem since the register locking system is not used.

Could someone with MII &| PCS knowledge cast an eye over this code?
All I can do is point out error path issues...

> +struct phylink_pcs *miic_create(struct device *dev, struct device_node *np)
> +{
> +	struct platform_device *pdev;
> +	struct miic_port *miic_port;
> +	struct device_node *pcs_np;
> +	struct miic *miic;
> +	u32 port;
> +
> +	if (!of_device_is_available(np))
> +		return ERR_PTR(-ENODEV);
> +
> +	if (of_property_read_u32(np, "reg", &port))
> +		return ERR_PTR(-EINVAL);
> +
> +	if (port > MIIC_MAX_NR_PORTS || port < 1)
> +		return ERR_PTR(-EINVAL);
> +
> +	/* The PCS pdev is attached to the parent node */
> +	pcs_np = of_get_parent(np);

of_get_parent()? ..

> +	if (!pcs_np)
> +		return ERR_PTR(-ENODEV);
> +
> +	if (!of_device_is_available(pcs_np))
> +		return ERR_PTR(-ENODEV);

.. more like of_leak_parent()

> +	pdev = of_find_device_by_node(pcs_np);
> +	if (!pdev || !platform_get_drvdata(pdev))
> +		return ERR_PTR(-EPROBE_DEFER);
> +
> +	miic_port = kzalloc(sizeof(*miic_port), GFP_KERNEL);
> +	if (!miic_port)
> +		return ERR_PTR(-ENOMEM);
> +
> +	miic = platform_get_drvdata(pdev);
> +	device_link_add(dev, miic->dev, DL_FLAG_AUTOREMOVE_CONSUMER);
> +
> +	miic_port->miic = miic;
> +	miic_port->port = port - 1;
> +	miic_port->pcs.ops = &miic_phylink_ops;
> +
> +	return &miic_port->pcs;
> +}
> +EXPORT_SYMBOL(miic_create);

> +static int miic_parse_dt(struct device *dev, u32 *mode_cfg)
> +{
> +	s8 dt_val[MIIC_MODCTRL_CONF_CONV_NUM];
> +	struct device_node *np = dev->of_node;
> +	struct device_node *conv;
> +	u32 conf;
> +	int port;
> +
> +	memset(dt_val, MIIC_MODCTRL_CONF_NONE, sizeof(dt_val));
> +
> +	of_property_read_u32(np, "renesas,miic-switch-portin", &conf);
> +	dt_val[0] = conf;
> +
> +	for_each_child_of_node(np, conv) {
> +		if (of_property_read_u32(conv, "reg", &port))
> +			continue;
> +
> +		if (!of_device_is_available(conv))
> +			continue;
> +
> +		if (of_property_read_u32(conv, "renesas,miic-input", &conf) == 0)
> +			dt_val[port] = conf;
> +
> +		of_node_put(conv);

Don't these iteration functions put() the current before taking the
next one all by themselves? Or is there supposed to be a "break" here?

> +	}
> +
> +	return miic_match_dt_conf(dev, dt_val, mode_cfg);
> +}




[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux