Unverified Commit c6eea4ff authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: adau1372: Fix error handling in adau1372_set_power()

Jihed Chaibi <jihed.chaibi.dev@gmail.com> says:

adau1372_set_power() had two related error handling issues in its enable
path: clk_prepare_enable() was called but its return value discarded, and
adau1372_enable_pll() was a void function that silently swallowed lock
failures, leaving mclk enabled and adau1372->enabled set to true despite
the device being in a broken state.

Patch 1 fixes the unchecked clk_prepare_enable() by making
adau1372_set_power() return int and propagating the error.

Patch 2 converts adau1372_enable_pll() to return int and adds a full
unwind in adau1372_set_power() if PLL lock fails, reversing the regcache,
GPIO power-down, and clock state.
parents c673efd5 bfe6a264
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -327,6 +327,7 @@ Henrik Rydberg <rydberg@bitmath.org>
Herbert Xu <herbert@gondor.apana.org.au>
Huacai Chen <chenhuacai@kernel.org> <chenhc@lemote.com>
Huacai Chen <chenhuacai@kernel.org> <chenhuacai@loongson.cn>
Ignat Korchagin <ignat@linux.win> <ignat@cloudflare.com>
Ike Panhc <ikepanhc@gmail.com> <ike.pan@canonical.com>
J. Bruce Fields <bfields@fieldses.org> <bfields@redhat.com>
J. Bruce Fields <bfields@fieldses.org> <bfields@citi.umich.edu>
+2 −0
Original line number Diff line number Diff line
@@ -336,6 +336,8 @@ command line arguments:
- ``--list_tests_attr``: If set, lists all tests that will be run and all of their
  attributes.

- ``--list_suites``: If set, lists all suites that will be run.

Command-line completion
==============================

+19 −7
Original line number Diff line number Diff line
@@ -19,9 +19,6 @@ description:
  Flash sub nodes describe the memory range and optional per-flash
  properties.

allOf:
  - $ref: mtd.yaml#

properties:
  compatible:
    const: st,spear600-smi
@@ -42,14 +39,29 @@ properties:
    $ref: /schemas/types.yaml#/definitions/uint32
    description: Functional clock rate of the SMI controller in Hz.

patternProperties:
  "^flash@.*$":
    $ref: /schemas/mtd/mtd.yaml#

    properties:
      reg:
        maxItems: 1

      st,smi-fast-mode:
        type: boolean
        description: Indicates that the attached flash supports fast read mode.

    unevaluatedProperties: false

    required:
      - reg

required:
  - compatible
  - reg
  - clock-rate
  - "#address-cells"
  - "#size-cells"

unevaluatedProperties: false

@@ -64,7 +76,7 @@ examples:
        interrupts = <12>;
        clock-rate = <50000000>;  /* 50 MHz */

        flash@f8000000 {
        flash@fc000000 {
            reg = <0xfc000000 0x1000>;
            st,smi-fast-mode;
        };
+2 −2
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ properties:
      offset from voltage set to regulator.

  regulator-uv-protection-microvolt:
    description: Set over under voltage protection limit. This is a limit where
    description: Set under voltage protection limit. This is a limit where
      hardware performs emergency shutdown. Zero can be passed to disable
      protection and value '1' indicates that protection should be enabled but
      limit setting can be omitted. Limit is given as microvolt offset from
@@ -182,7 +182,7 @@ properties:
      is given as microvolt offset from voltage set to regulator.

  regulator-uv-warn-microvolt:
    description: Set over under voltage warning limit. This is a limit where
    description: Set under voltage warning limit. This is a limit where
      hardware is assumed still to be functional but approaching limit where
      it gets damaged. Recovery actions should be initiated. Zero can be passed
      to disable detection and value '1' indicates that detection should
+48 −0
Original line number Diff line number Diff line
@@ -99,3 +99,51 @@ of the driver is decremented. All symlinks between the two are removed.
When a driver is removed, the list of devices that it supports is
iterated over, and the driver's remove callback is called for each
one. The device is removed from that list and the symlinks removed.


Driver Override
~~~~~~~~~~~~~~~

Userspace may override the standard matching by writing a driver name to
a device's ``driver_override`` sysfs attribute.  When set, only a driver
whose name matches the override will be considered during binding.  This
bypasses all bus-specific matching (OF, ACPI, ID tables, etc.).

The override may be cleared by writing an empty string, which returns
the device to standard matching rules.  Writing to ``driver_override``
does not automatically unbind the device from its current driver or
make any attempt to load the specified driver.

Buses opt into this mechanism by setting the ``driver_override`` flag in
their ``struct bus_type``::

  const struct bus_type example_bus_type = {
      ...
      .driver_override = true,
  };

When the flag is set, the driver core automatically creates the
``driver_override`` sysfs attribute for every device on that bus.

The bus's ``match()`` callback should check the override before performing
its own matching, using ``device_match_driver_override()``::

  static int example_match(struct device *dev, const struct device_driver *drv)
  {
      int ret;

      ret = device_match_driver_override(dev, drv);
      if (ret >= 0)
          return ret;

      /* Fall through to bus-specific matching... */
  }

``device_match_driver_override()`` returns > 0 if the override matches
the given driver, 0 if the override is set but does not match, or < 0 if
no override is set at all.

Additional helpers are available:

- ``device_set_driver_override()`` - set or clear the override from kernel code.
- ``device_has_driver_override()`` - check whether an override is set.
Loading