Re: [PATCH 1/2] of: property: add of_property_for_each_u64

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

 



Hello Peng,

On Fri, 28 Jun 2024 16:16:17 +0200
Luca Ceresoli <luca.ceresoli@xxxxxxxxxxx> wrote:

[...]

> > > > > +#define of_property_for_each_u64(np, propname, prop, p, u)	\
> > > > > +	for (prop = of_find_property(np, propname, NULL),	\
> > > > > +		p = of_prop_next_u64(prop, NULL, &u);		\
> > > > > +		p;						\
> > > > > +		p = of_prop_next_u64(prop, p, &u))    
> > > >
> > > > I think we want to define this differently to avoid exposing struct
> > > > property and the property data directly. Like this:
> > > >
> > > > #define of_property_for_each_u64(np, propname, u) \
> > > >   for (struct property *_prop = of_find_property(np, propname, NULL),
> > > >          const __be32 *_p = of_prop_next_u64(_prop, NULL, &u);
> > > >          _p;
> > > >          _p = of_prop_next_u64(_prop, _p, &u))    
> > 
> > This will trigger a compilation error, because C not allow
> > declare two variables with different types as for loop expression 1.
> > Need to think about other methods.  
> 
> I have a working draft here where I solved it somehow, let me just find
> the proper branch and send it. Perhaps next week, but I'm striving to do
> that by Mon-Tue.

Ok, that slipped to Wednesday, but here it is:
https://lore.kernel.org/all/20240703-of_property_for_each_u32-v1-1-42c1fc0b82aa@xxxxxxxxxxx/

I think you can reuse the technique I used in that patch to write
of_property_for_each_u64(np, propname, u), taking only 3 parameters.

Luca

-- 
Luca Ceresoli, 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