nvmem device tree naming pattern - linux-kernel

In the nvmem.yml there is
properties:
$nodename:
pattern: "^(eeprom|efuse|nvram)(#.*|-[0-9a-f])*$"
I have a hard time finding the pattern in the source code itself.
Where can I find that the nvmem device tree nodename must be 'eeprom' or 'efuse' or 'nvram'.

The pattern doesn't exist in the code. The schema (nvmem.yaml) can be used to validate device trees but the kernel code doesn't enforce the node name.

Related

driver doesnt find property in device tree during linux init

I try to bring up Cortex A9 (Arria V) based board.
During the init the cadence-qspi driver complains that it cannot find the property of the correspondent node int he device tree and fails to initialize. When I look at the representation of the DT, and specifically at /sys/bus/patform/devices/ff705000.qspi/of_node/fifo-depth - I see that it keeps correct value.
What can be the reason for such behavior?
kernel 4.14.130-ltsi from linux-socfpga.git
Thanks,
Ilya
During the init the cadence-qspi driver complains that it cannot find the property of the correspondent node int he device tree
...
I see that it keeps correct value.
The value of the property is irrelevant when the issue is the driver "cannot find the property".
"Finding" a property relates to the name of that property, rather than its value.
What can be the reason for such behavior?
The likeliest reason is the property name (that you used) in your Device Tree does not match the required property name (specified by a character string) in the kernel driver.
The file Documentation/devicetree/bindings/mtd/cadence-quadspi.txt states that the actual name of the property in question is:
cdns,fifo-depth
whereas you report that your Device Tree uses just fifo-depth (and is obviously not a string match).
Beware that there are other required and optional properties for this node that utilize the cdns, prefix, so other lines in your Device Tree may need correction.

What is the difference between the 'Avl' suffix and the original function in the Win32 API?

I've dumped the export table of ntdll.dll looking for specific APIs, but found the same function but one 'Avl' appended to it, what does it mean?
like:
RtlDeleteElementGenericTable
RtlDeleteElementGenericTableAvl
That is just the simple meaning, For example: RtlDeleteElementGenericTable and RtlDeleteElementGenericTableAvl, The parameter type of RtlDeleteElementGenericTable is RTL_GENERIC_TABLE, But RtlDeleteElementGenericTableAvl is RTL_AVL_TABLE.
The RTL_AVL_TABLE structure contains file system-specific data for an
Adelson-Velsky/Landis (AVL) tree. An AVL tree ensures a more balanced,
shallower tree implementation than a splay tree implementation of a
generic table (RTL_GENERIC_TABLE).
So that's is also the differences between * and *Avl functions.

Trie with custom insert and delete functions

I need to create four custom function for a Trie data structure without changing its O(n) complexity:
makeDir("pathToDir")
make("pathToFile")
delete("pathToDir")
forceDelete("pathToDirOrFile")
makeDir("pathToDir"): adds path to the trie only if it is a valid path
make("pathToFile"): adds path to the trie only if it is a valid path (a file node can't call makeDir() )
delete("pathToDir"): deletes the path from trie only if it has no child dirs
forceDelete("pathToDirOrFile"): deletes path and its child dirs
For example a list of commands would be:
makeDir("\dir");
makeDir("\dir\foo")
makeDir("\dir\foo\lol\ok"); /* incorrect path */
make("\dir\file");
makeDir("\dir\file\abc"); /* file can't have sub dirs */
delete("\dir"); /* has childs, incorrect */
delete("\dir\file");
forceDelete("\dir");
Does anybody have any idea on how to recognize that the node indicates the path of a files? What is the best way to implement these functions?
Validating and splitting the path
It's OS specific, so just pick any library that works with paths for your target system.
The trie
Once you can split a path into pieces, you can build a trie. Keep strings in its edges. For instance, if you have a foo/bar path, there'll be 3 nodes and two edges: the first one (1->2) is marked with foo and the second one (2->3) is marked with bar.
You can store a flag in each node to indicate if it's a regular file or a directory.
To check if a directory is empty, just make sure it's node has no children.
To check if a directory/file can be created, take its base dir (all parts of the path except the last one), check that it exists by traversing your trie from the root and that its node is a directory, not a regular file.
Efficient traversal
You can store edges in hash table that maps a string to a node.

`esprima` AST Tree: How to easily detect and add function parens?

TL;DR: i want to do same thing as there https://github.com/nolanlawson/optimize-js but with esprima when i traverse through AST tree with estraverse.
ESPrima gives same output nodes for following code:
!function (){}()
and
!(function (){})()
http://esprima.org/demo/parse.html?code=!function%20()%7B%7D()%0A%0A!(function%20()%7B%7D)()
For example - i will traverse through AST tree. On Function Expression ExpressionStatement node i want to check - if that node doesn't have parens around function - i want to add it.
So, how i can detect function parens, how i can add them? I look at tokens, but i have no idea how i can associate flat tokens object with object with specified AST node.
Seems it task not for esprima but for escodegen
https://github.com/estools/escodegen/issues/315

SNMP OID with non-unique node names

I am writing an extension to my companies existing SNMP MIB. I have a whole list of objects, with the same properties on each. I want to be able to get and set these through SNMP.
So for example, consider my object has name, desc, arg0, arg1. What I want is to be able to refer to these as:
fullpath.objects.ObjectA.name
fullpath.objects.ObjectA.desc
fullpath.objects.ObjectA.arg0
fullpath.objects.ObjectB.name
fullpath.objects.ObjectB.desc
fullpath.objects.ObjectB.arg0
However the leaf nodes appear to have to have unique names, so I am unable to define this.
I can use a SNMP table to produce:
fullpath.objects.table.name.1
fullpath.objects.table.desc.1
fullpath.objects.table.arg0.1
fullpath.objects.table.name.2
fullpath.objects.table.desc.2
fullpath.objects.table.arg0.2
But there is nowhere to look up that 2 means ObjectB. This leaves it open to user error looking up the wrong value and setting the wrong thing.
At the moment the best solution I can see is:
fullpath.objects.ObjectAName
fullpath.objects.ObjectADesc
fullpath.objects.ObjectAArg0
fullpath.objects.ObjectBName
fullpath.objects.ObjectBDesc
fullpath.objects.ObjectBArg0
which involves defining name for every object (there are 20 or so of them). The set of objects is fixed, so this is ok...just not very tidy.
Is there some way to define names for index in the table?
Is there some way of defining a container type?
Is there some way of allowing leaf nodes to be non-unique?
Any other ideas?
You should definitely use SNMP tables to accomplish what is required. This is the only way.
MIB Object names must be unique within entire MIB file.
You can easily use object of OCTET STRING type as Table index. So each byte/symbol/char of OCTET STRING value will be translated to corresponding numeric ASCII code in OID.
I ended up just using a naming convention and adding each of the settings directly into the MIB.
Not really the answer I wanted, but it means that all of the settings show up in the MIB, and that reduces the chance of users setting the wrong setting.

Resources