Express that at least one patternProperties is required

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

 



Hi Rob,

I'm preparing a patch to do a slight improvement in [1] where if there are no channels
given in the devicetree, it does not really make sense to probe the device. Now,
I want to express this in the bindings doc [2] but I'm failing to find a way to say that
at least one of the patternProperties channel has to be present. For my shame,
this is the only way I could express it:

----
diff --git a/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml b/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml
index 0f79d9a01c49..27c17e07aeb0 100644
--- a/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml
+++ b/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml
@@ -382,6 +382,207 @@ required:
   - reg
   - interrupts
 
+# at least one sensor channel must be present
+anyOf:
+  - required:
+      - thermocouple@1
+  - required:
+      - thermocouple@2
+  - required:
+      - thermocouple@3
+  - required:
+      - thermocouple@4
+  - required:
+      - thermocouple@5
+  - required:
+      - thermocouple@6
+  - required:
+      - thermocouple@7
+  - required:
+      - thermocouple@8
+  - required:
+      - thermocouple@9
+  - required:
+      - thermocouple@10
+  - required:
+      - thermocouple@11
+  - required:
+      - thermocouple@12
+  - required:
+      - thermocouple@13
+  - required:
+      - thermocouple@14
+  - required:
+      - thermocouple@15
+  - required:
+      - thermocouple@16
+  - required:
+      - thermocouple@17
+  - required:
+      - thermocouple@18
+  - required:
+      - thermocouple@19
+  - required:
+      - thermocouple@20
+  - required:
+      - diode@1
+  - required:
+      - diode@2
+  - required:
+      - diode@3
+  - required:
+      - diode@4
+  - required:
+      - diode@5
+  - required:
+      - diode@6
+  - required:
+      - diode@7
+  - required:
+      - diode@8
+  - required:
+      - diode@9
+  - required:
+      - diode@10
+  - required:
+      - diode@11
+  - required:
+      - diode@12
+  - required:
+      - diode@13
+  - required:
+      - diode@14
+  - required:
+      - diode@15
+  - required:
+      - diode@16
+  - required:
+      - diode@17
+  - required:
+      - diode@18
+  - required:
+      - diode@19
+  - required:
+      - diode@20
+  - required:
+      - rtd@2
+  - required:
+      - rtd@3
+  - required:
+      - rtd@4
+  - required:
+      - rtd@5
+  - required:
+      - rtd@6
+  - required:
+      - rtd@7
+  - required:
+      - rtd@8
+  - required:
+      - rtd@9
+  - required:
+      - rtd@10
+  - required:
+      - rtd@11
+  - required:
+      - rtd@12
+  - required:
+      - rtd@13
+  - required:
+      - rtd@14
+  - required:
+      - rtd@15
+  - required:
+      - rtd@16
+  - required:
+      - rtd@17
+  - required:
+      - rtd@18
+  - required:
+      - rtd@19
+  - required:
+      - rtd@20
+  - required:
+      - thermistor@1
+  - required:
+      - thermistor@2
+  - required:
+      - thermistor@3
+  - required:
+      - thermistor@4
+  - required:
+      - thermistor@5
+  - required:
+      - thermistor@6
+  - required:
+      - thermistor@7
+  - required:
+      - thermistor@8
+  - required:
+      - thermistor@9
+  - required:
+      - thermistor@10
+  - required:
+      - thermistor@11
+  - required:
+      - thermistor@12
+  - required:
+      - thermistor@13
+  - required:
+      - thermistor@14
+  - required:
+      - thermistor@15
+  - required:
+      - thermistor@16
+  - required:
+      - thermistor@17
+  - required:
+      - thermistor@18
+  - required:
+      - thermistor@19
+  - required:
+      - thermistor@20
+  - required:
+      - adc@1
+  - required:
+      - adc@2
+  - required:
+      - adc@3
+  - required:
+      - adc@4
+  - required:
+      - adc@5
+  - required:
+      - adc@6
+  - required:
+      - adc@7
+  - required:
+      - adc@8
+  - required:
+      - adc@9
+  - required:
+      - adc@10
+  - required:
+      - adc@11
+  - required:
+      - adc@12
+  - required:
+      - adc@13
+  - required:
+      - adc@14
+  - required:
+      - adc@15
+  - required:
+      - adc@16
+  - required:
+      - adc@17
+  - required:
+      - adc@18
+  - required:
+      - adc@19
+  - required:
+      - adc@20
+
 additionalProperties: false
 
 examples:

----

Obviously, this looks bad but I'm not sure we can actually use regex in the required schema?
Is there any clever way of expressing this or is this the only way?

[1]: https://elixir.bootlin.com/linux/v5.14-rc6/source/drivers/iio/temperature/ltc2983.c#L1275
[2]: https://elixir.bootlin.com/linux/v5.14-rc6/source/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml

Thanks!
- Nuno Sá





[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