Commit 83c97fe1 authored by Guenter Roeck's avatar Guenter Roeck

hwmon: (acpi_power_meter) Don't crash the kernel unnecessarily

acpi_power_meter crashes the kernel if it detects an unexpected event
or an internal implementation error. While the detected conditions
suggest that there is a bug in the code, the condition is not fatal.
Replace BUG() with WARN().
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent c52ae3d2
...@@ -381,8 +381,10 @@ static ssize_t show_str(struct device *dev, ...@@ -381,8 +381,10 @@ static ssize_t show_str(struct device *dev,
val = resource->oem_info; val = resource->oem_info;
break; break;
default: default:
BUG(); WARN(1, "Implementation error: unexpected attribute index %d\n",
attr->index);
val = ""; val = "";
break;
} }
return sprintf(buf, "%s\n", val); return sprintf(buf, "%s\n", val);
...@@ -436,7 +438,9 @@ static ssize_t show_val(struct device *dev, ...@@ -436,7 +438,9 @@ static ssize_t show_val(struct device *dev,
val = resource->trip[attr->index - 7] * 1000; val = resource->trip[attr->index - 7] * 1000;
break; break;
default: default:
BUG(); WARN(1, "Implementation error: unexpected attribute index %d\n",
attr->index);
break;
} }
return sprintf(buf, "%llu\n", val); return sprintf(buf, "%llu\n", val);
...@@ -855,7 +859,8 @@ static void acpi_power_meter_notify(struct acpi_device *device, u32 event) ...@@ -855,7 +859,8 @@ static void acpi_power_meter_notify(struct acpi_device *device, u32 event)
dev_info(&device->dev, "Capping in progress.\n"); dev_info(&device->dev, "Capping in progress.\n");
break; break;
default: default:
BUG(); WARN(1, "Unexpected event %d\n", event);
break;
} }
mutex_unlock(&resource->lock); mutex_unlock(&resource->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment