Re: [PATCH v8 04/10] reset: eyeq5: add platform driver

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

 



Hello,

I won't be answering to straight forward comments.

On Tue Feb 27, 2024 at 6:27 PM CET, Andy Shevchenko wrote:
> On Tue, Feb 27, 2024 at 03:55:25PM +0100, Théo Lebrun wrote:
> > Add the Mobileye EyeQ5 reset controller driver. It belongs to a syscon
> > region called OLB. It might grow to add later support of other
> > platforms from Mobileye.
>
> ...
>
> The inclusion block is a semi-random. Please, follow IWYU principle.
>
> + array_size.h
> + bits.h
> + bug.h
> + container_of.h
>
> > +#include <linux/cleanup.h>
> > +#include <linux/delay.h>
>
> + device.h
> + err.h
> + io.h
> + lockdep.h
>
> + mod_devicetable.h
>
> > +#include <linux/mutex.h>
>
> > +#include <linux/of.h>
> > +#include <linux/of_address.h>
> > +#include <linux/of_device.h>
>
> Are all of them in use?
>
> > +#include <linux/platform_device.h>
> > +#include <linux/reset-controller.h>
>
> + types.h

I'm adding yours + errno.h + init.h (for THIS_MODULE) + slab.h (for GFP
flags). I'm removing unused of_address.h and of_device.h.

delay.h will be removed and iopoll.h will be added based on changes
following your comments.

[...]

> > +static int eq5r_deassert(struct reset_controller_dev *rcdev, unsigned long id)
> > +{
> > +	struct eq5r_private *priv = rcdev_to_priv(rcdev);
> > +	u32 offset = id & GENMASK(7, 0);
> > +	u32 domain = id >> 8;
>
> Perhaps
>
> 	u32 offset = (id & GENMASK(7, 0)) >> 0;
> 	u32 domain = (id & GENMASK(31, 8)) >> 8;
>
> for better understanding the split?

Do the additional zero-bit-shift and GENMASK() help understanding? My
brain needs time to parse them to then notice they do nothing and
simplify the code in my head, back to the original version.

I personally like the simplest version (the original one). But otherwise
FIELD_GET() with two globally-defined masks could be a solution as
well. I still prefer the original version better. Less symbols, less
complexity.

[...]

> > +	struct eq5r_private *priv;
> > +	int ret, i;
>
> Why is i signed?

No reason, will switch to unsigned int.

>
> > +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> > +	if (!priv)
> > +		return -ENOMEM;
> > +
> > +	priv->base_d0 = devm_platform_ioremap_resource_byname(pdev, "d0");
> > +	if (IS_ERR(priv->base_d0))
> > +		return PTR_ERR(priv->base_d0);
> > +
> > +	priv->base_d1 = devm_platform_ioremap_resource_byname(pdev, "d1");
> > +	if (IS_ERR(priv->base_d1))
> > +		return PTR_ERR(priv->base_d1);
> > +
> > +	priv->base_d2 = devm_platform_ioremap_resource_byname(pdev, "d2");
> > +	if (IS_ERR(priv->base_d2))
> > +		return PTR_ERR(priv->base_d2);
> > +
> > +	for (i = 0; i < EQ5R_DOMAIN_COUNT; i++)
> > +		mutex_init(&priv->mutexes[i]);
> > +
> > +	priv->rcdev.ops = &eq5r_ops;
> > +	priv->rcdev.owner = THIS_MODULE;
> > +	priv->rcdev.dev = dev;
>
> > +	priv->rcdev.of_node = np;
>
> It's better to use device_set_node().

I don't see how device_set_node() can help? It works on struct device
pointers. Here priv->rcdev is a reset_controller_dev struct. There are
no users of device_set_node() in drivers/reset/.

>
> > +	priv->rcdev.of_reset_n_cells = 2;
> > +	priv->rcdev.of_xlate = eq5r_of_xlate;
> > +
> > +	priv->rcdev.nr_resets = 0;
> > +	for (i = 0; i < EQ5R_DOMAIN_COUNT; i++)
>
> > +		priv->rcdev.nr_resets += __builtin_popcount(eq5r_valid_masks[i]);
>
> Please, use corresponding hweightXX() API.

Noted. I did not find this keyword even though I searched quite a bit
for it. "popcount" sounds more logical to me. :-)

Thanks for the review Andy!

--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com






[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