> On 9 Jan 2019, at 18:37, Kumar Gala <kumar.gala@xxxxxxxxxx> 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. Off the top of my head, the syntax should stay away from arithmetic style operators (Ie. prop += <new data>; prop = <new> + $oldval;) since we do arithmetic calculations for prop values, and the existing syntax already is a concatenation of multiple datum. I think we first need a representation for existing data that is distinct from <>, “”, [], and &. Maybe using a ‘@‘ and using some python array syntax? @@ current prop val @prop another prop val @/path/prop prop in another node @@[0] Element 0 of current prop. (Need to define if element is a byte or a tuple/string. The later makes more logical sense, but we don’t have that info in dtb) @prop[2] element 2 of another prop @@[3][6] byte 6 of element 3? @@[4:7] elements 4 though 7 @@[:3] elements 0 through 3 @@[5:] elements 5 to the end The @ might be unnecessary except for current prop values. Merely using a word may be enough to indicate that it is a prop reference. I’ll try this out with the below examples: > > 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 prop = @@, <newdata>; > * Add an entry at head of array prop = <newdata>, @@; > > - 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 prop[5][1]= newvalue; > > - SPI controller, having an overlay .dtsi that wants to update a cs-gpio entry > * Replace an entry at a specific index prop[3] = <newvalue>; > > 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, prop = @@[:3] @@[5:]; > deleting head prop = @@[1:]; > or deleting tail. prop = @@[:-1]; IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.