Skip to contentSkip to conversation

drivers: auxdisplay: ht16k33.c: Add option to refuse claiming primary fb

PATCH In review David Jander 2 participants 5 messages Mar 30, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover drivers: auxdisplay: ht16k33.c: Add option to refuse claiming primary fb

In the case there is also a display with a frame-buffer device, the probe order of the auxdisplay fb and the main fb is not predictable, possibly leading to the situation where the holtek auxdisplay becomes /dev/fb0. This is problematic because there is currently no way to automatically rename these devices, and too much user-space software that assumes fb0 to be the main display.
In such a situation, adding "holtek,refuse-primary-fb" to the DT, the auxdisplay driver returns -EPROBE_DEFER to wait for the primary fb device to get probed first.

David Jander (2):
drivers: auxdisplay: ht16k33.c: Add option to refuse claiming primary
fb
dt-bindings: auxdisplay: holtek,ht16k33.yaml: Add
holtek,refuse-primary-fb

 .../devicetree/bindings/auxdisplay/holtek,ht16k33.yaml    | 3 +++
 drivers/auxdisplay/ht16k33.c                              | 8 ++++++++
 2 files changed, 11 insertions(+)
Signature · 1 line
2.32.0
#1 lore raw

PATCH 1/2 drivers: auxdisplay: ht16k33.c: Add option to refuse claiming primary fb

In the case there is also a display with a frame-buffer device, the probe order of the auxdisplay fb and the main fb is not predictable, possibly leading to the situation where the holtek auxdisplay becomes /dev/fb0. This is problematic because there is currently no way to automatically rename these devices, and too much user-space software that assumes fb0 to be the main display.
In such a situation, adding "holtek,refuse-primary-fb" to the DT, the auxdisplay driver returns -EPROBE_DEFER to wait for the primary fb device to get probed first.

---
 drivers/auxdisplay/ht16k33.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/auxdisplay/ht16k33.c +8 -0
index 4fab3b2c7023..e8e0c644f2e4 100644
@@ -581,12 +581,20 @@ static int ht16k33_keypad_probe(struct i2c_client *client,
 	return input_register_device(keypad->dev);
 }
 
+extern int num_registered_fb;
+
 static int ht16k33_fbdev_probe(struct device *dev, struct ht16k33_priv *priv,
 			       uint32_t brightness)
 {
 	struct ht16k33_fbdev *fbdev = &priv->fbdev;
 	struct backlight_device *bl = NULL;
 	int err;
+	bool not_primary;
+
+	not_primary = device_property_read_bool(dev, "holtek,refuse-primary-fb");
+
+	if (!num_registered_fb && not_primary)
+		return -EPROBE_DEFER;
 
 	if (priv->led.dev) {
 		err = ht16k33_brightness_set(priv, brightness);
Signature · 1 line
2.32.0
#2 lore raw

PATCH 2/2 dt-bindings: auxdisplay: holtek,ht16k33.yaml: Add holtek,refuse-primary-fb

In reply to David Jander

Document the DT property that will cause the holtek auxdisplay driver to back off if it detects that it is the first driver to probe a framebuffer device.

---
 .../devicetree/bindings/auxdisplay/holtek,ht16k33.yaml         | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/auxdisplay/holtek,ht16k33.yaml +3 -0
index fc4873deb76f..4de32c3e26ce 100644
@@ -53,6 +53,9 @@ properties:
     $ref: /schemas/leds/common.yaml#
     unevaluatedProperties: false
 
+  holtek,refuse-primary-fb:
+    description: Refuse to claim the first framebuffer device
+
 required:
   - compatible
   - reg
Signature · 1 line
2.32.0
maintainer
#3 lore raw

Re: [PATCH 2/2] dt-bindings: auxdisplay: holtek,ht16k33.yaml: Add holtek,refuse-primary-fb

Quoted 9 lines · David Jander

Document the DT property that will cause the holtek auxdisplay driver to back off if it detects that it is the first driver to probe a framebuffer device.

---
 .../devicetree/bindings/auxdisplay/holtek,ht16k33.yaml         | 3 +++
 1 file changed, 3 insertions(+)

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/auxdisplay/holtek,ht16k33.yaml: properties:holtek,refuse-primary-fb: 'oneOf' conditional failed, one must be fixed:
'type' is a required property
hint: A vendor boolean property can use "type: boolean"
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/auxdisplay/holtek,ht16k33.yaml: properties:holtek,refuse-primary-fb: 'oneOf' conditional failed, one must be fixed:
'enum' is a required property
'const' is a required property
hint: A vendor string property with exact values has an implicit type
from schema $id: http://devicetree.org/meta-schemas/vendor-props.yaml#
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/auxdisplay/holtek,ht16k33.yaml: properties:holtek,refuse-primary-fb: 'oneOf' conditional failed, one must be fixed:
'$ref' is a required property
'allOf' is a required property
hint: A vendor property needs a $ref to types.yaml
from schema $id: http://devicetree.org/meta-schemas/vendor-props.yaml#
hint: Vendor specific properties must have a type and description unless they have a defined, common suffix.
from schema $id: http://devicetree.org/meta-schemas/vendor-props.yaml#
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/auxdisplay/holtek,ht16k33.yaml: ignoring, error in schema: properties: holtek,refuse-primary-fb Documentation/devicetree/bindings/auxdisplay/holtek,ht16k33.example.dt.yaml:0:0: /example-0/i2c1/ht16k33@70: failed to match any schema with compatible: ['holtek,ht16k33']

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/1610969

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

maintainer
#4 lore raw

Re: [PATCH 2/2] dt-bindings: auxdisplay: holtek,ht16k33.yaml: Add holtek,refuse-primary-fb

In reply to David Jander
Quoted 14 lines · David Jander

Document the DT property that will cause the holtek auxdisplay driver to back off if it detects that it is the first driver to probe a framebuffer device.

---
 .../devicetree/bindings/auxdisplay/holtek,ht16k33.yaml         | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/auxdisplay/holtek,ht16k33.yaml +0 -0
index fc4873deb76f..4de32c3e26ce 100644

Documentation/devicetree/bindings/auxdisplay/holtek,ht16k33.yaml properties: · line 57

Quoted 5 lines
Documentation/devicetree/bindings/auxdisplay/holtek,ht16k33.yaml +2 -0
@@ -53,6 +53,9 @@ properties:
     $ref: /schemas/leds/common.yaml#
     unevaluatedProperties: false
 
+  holtek,refuse-primary-fb:
+    description: Refuse to claim the first framebuffer device

How is this specific to this device?

Rob