reset: ACPI reset support
PATCH 1/1 reset: ACPI reset support
Some of the IO devices like I2C or SPI require reset at runtime to recover from an error condition without changing the power state of the system. Added check for ACPI handle and a call to method '__RST' if supported. Devices using device tree method are unaffected by this.
--- drivers/reset/core.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/reset/core.c +6 -0
@@ -12,6 +12,7 @@#include <linux/kref.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/acpi.h> #include <linux/reset.h> #include <linux/reset-controller.h> #include <linux/slab.h>
@@ -1107,6 +1108,11 @@ int __device_reset(struct device *dev, bool optional)struct reset_control *rstc;int ret; +acpi_handle handle =ACPI_HANDLE (dev); + +if (handle) +return acpi_evaluate_object (handle,"_RST" ,NULL ,NULL ); + rstc =__reset_control_get (dev,NULL ,0 ,0 , optional, true);if (IS_ERR (rstc))return PTR_ERR (rstc);
Signature · 1 line
2.7.4
Philipp Zabel
maintainerHi Krishna,
drivers/reset/core.c int __device_reset(struct device *dev, bool optional)
Quoted 24 lines · Krishna Yarlagadda
Some of the IO devices like I2C or SPI require reset at runtime to recover from an error condition without changing the power state of the system. Added check for ACPI handle and a call to method '
__RST' if supported. Devices using device tree method are unaffected by this.Signed-off-by Krishna Yarlagadda <[email protected]>---
drivers/reset/core.c | 6 ++++++1 file changed, 6 insertions(+)drivers/reset/core.c +1
-0@@ -12,6 +12,7 @@ #include <linux/kref.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/acpi.h> #include <linux/reset.h> #include <linux/reset-controller.h> #include <linux/slab.h>@@ -1107,6 +1108,11 @@ int __device_reset(struct device *dev, bool optional)
Could you add a sentence to the kerneldoc description above this, for example "For ACPI devices this calls the _RST method"?
Quoted 6 lines
drivers/reset/core.c +0
-0struct reset_control *rstc; int ret;
+ acpi_handle handle =ACPI_HANDLE(dev);
+
+ if (handle)
What does acpi_evaluate_object() do if the _RST method is not present? I think we have to check
if (!acpi_has_method(handle, "_RST")) return optional ? 0 : -ENOENT;
here.
Quoted 1 line
+ return
acpi_evaluate_object(handle, "_RST", NULL, NULL);
acpi_evaluate_object() returns acpi_status, so that should probably be something like:
status = acpi_evaluate_object(handle, "_RST", NULL, NULL); if (ACPI_FAILURE(status)) return -EIO;
Quoted 4 lines
+
rstc =__reset_control_get(dev, NULL, 0, 0, optional, true); if (IS_ERR(rstc))
returnPTR_ERR(rstc);
regards
Philipp