On Wed, Jan 09, 2019 at 12:36:56PM -0600, Kumar Gala wrote: > There are a number of cases I’ve come across when we want to manipulate an array property in DTS. Most cases I’ve see today end up replacing the whole property because we don’t have any means/syntax to manipulate the array. > > I was hoping to see if, one there is interest in adding support to manipulate array’s to dtc, and defining what features and syntax would be. > > Figured I’d start with some use examples I know of: > > - Updating compatible when we have a base SoC .dtsi file shared across a family of SoC’s. Than a more specific SoC .dtsi file wanting to append a more specific compatible. > * Add an entry at tail of array So, this can already be done with fdt_appendprop() - if we want more typed convenience wrappers around that, that's easy to do. > * Add an entry at head of array We could add an fdt_prependprop() function pretty easily if that's useful. > > - QSPI nodes where the reg’s are to both the controller and mmap QSPI region, the board dts might want to manipulate the size element > * Modify a cell of a specific index That can be done with fdt_setprop_inplace_namelen_partial() - but we probably want some more convenient wrappers around it. > > - SPI controller, having an overlay .dtsi that wants to update a cs-gpio entry > * Replace an entry at a specific index With an entry of the same size, or different? If the same size, then fdt_setprop_inplace_namelen_partial() can again be used. > Will let other’s hopefully chime in with other use cases examples > they’ve seen. I’m guessing there are probably cases for deleting a > specific index, deleting head or deleting tail. Hmm... I think the general solution is to expose a function called, say, fdt_spliceprop(). It would take a property, an offset and length within that property and a new buffer and length. It would replace the given chunk of the property with the new buffer contents, expanding or contracting as necessary. appendprop and prependprop would become special case wrappers of that. I think we already have something pretty similar as an internal non-exposed function, so it shouldn't be too hard to do. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Attachment:
signature.asc
Description: PGP signature