acpi_thermal: some style corrections

Change-Id: I7194be3b284e2de839afb53037b26fc691984dd7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3442
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Lt-Henry
2020-12-04 07:29:11 +00:00
committed by Adrien Destugues
parent 3d0f2eea4f
commit e6bb814359
@@ -29,11 +29,11 @@
// name of pnp generator of path ids // name of pnp generator of path ids
#define ACPI_THERMAL_PATHID_GENERATOR "acpi_thermal/path_id" #define ACPI_THERMAL_PATHID_GENERATOR "acpi_thermal/path_id"
static device_manager_info *sDeviceManager; static device_manager_info* sDeviceManager;
typedef struct acpi_ns_device_info { typedef struct acpi_ns_device_info {
device_node *node; device_node* node;
acpi_device_module_info *acpi; acpi_device_module_info* acpi;
acpi_device acpi_cookie; acpi_device acpi_cookie;
} acpi_thermal_device_info; } acpi_thermal_device_info;
@@ -42,16 +42,16 @@ status_t acpi_thermal_control(void* _cookie, uint32 op, void* arg, size_t len);
static status_t static status_t
acpi_thermal_open(void *_cookie, const char *path, int flags, void** cookie) acpi_thermal_open(void* _cookie, const char* path, int flags, void** cookie)
{ {
acpi_thermal_device_info *device = (acpi_thermal_device_info *)_cookie; acpi_thermal_device_info* device = (acpi_thermal_device_info*)_cookie;
*cookie = device; *cookie = device;
return B_OK; return B_OK;
} }
static status_t static status_t
acpi_thermal_read(void* _cookie, off_t position, void *buf, size_t* num_bytes) acpi_thermal_read(void* _cookie, off_t position, void* buf, size_t* num_bytes)
{ {
acpi_thermal_device_info* device = (acpi_thermal_device_info*)_cookie; acpi_thermal_device_info* device = (acpi_thermal_device_info*)_cookie;
acpi_thermal_type therm_info; acpi_thermal_type therm_info;
@@ -61,7 +61,7 @@ acpi_thermal_read(void* _cookie, off_t position, void *buf, size_t* num_bytes)
if (position == 0) { if (position == 0) {
size_t max_len = *num_bytes; size_t max_len = *num_bytes;
char *str = (char *)buf; char* str = (char*)buf;
acpi_thermal_control(device, drvOpGetThermalType, &therm_info, 0); acpi_thermal_control(device, drvOpGetThermalType, &therm_info, 0);
snprintf(str, max_len, " Critical Temperature: %lu.%lu K\n", snprintf(str, max_len, " Critical Temperature: %lu.%lu K\n",
@@ -96,7 +96,7 @@ acpi_thermal_read(void* _cookie, off_t position, void *buf, size_t* num_bytes)
*/ */
free(therm_info.passive_package); free(therm_info.passive_package);
} }
*num_bytes = strlen((char *)buf); *num_bytes = strlen((char*)buf);
} else { } else {
*num_bytes = 0; *num_bytes = 0;
} }
@@ -118,7 +118,7 @@ acpi_thermal_control(void* _cookie, uint32 op, void* arg, size_t len)
acpi_thermal_device_info* device = (acpi_thermal_device_info*)_cookie; acpi_thermal_device_info* device = (acpi_thermal_device_info*)_cookie;
status_t err = B_ERROR; status_t err = B_ERROR;
acpi_thermal_type *att = NULL; acpi_thermal_type* att = NULL;
acpi_object_type object; acpi_object_type object;
@@ -128,17 +128,29 @@ acpi_thermal_control(void* _cookie, uint32 op, void* arg, size_t len)
switch (op) { switch (op) {
case drvOpGetThermalType: { case drvOpGetThermalType: {
att = (acpi_thermal_type *)arg; att = (acpi_thermal_type*)arg;
// Read basic temperature thresholds. // Read basic temperature thresholds.
err = device->acpi->evaluate_method(device->acpi_cookie, "_CRT", NULL, &buffer); err = device->acpi->evaluate_method (device->acpi_cookie, "_CRT",
att->critical_temp = (err == B_OK && object.object_type == ACPI_TYPE_INTEGER) ? object.integer.integer : 0; NULL, &buffer);
err = device->acpi->evaluate_method(device->acpi_cookie, "_TMP", NULL, &buffer); att->critical_temp =
att->current_temp = (err == B_OK && object.object_type == ACPI_TYPE_INTEGER) ? object.integer.integer : 0; (err == B_OK && object.object_type == ACPI_TYPE_INTEGER)
? object.integer.integer : 0;
err = device->acpi->evaluate_method(device->acpi_cookie, "_HOT", NULL, &buffer); err = device->acpi->evaluate_method (device->acpi_cookie, "_TMP",
att->hot_temp = (err == B_OK && object.object_type == ACPI_TYPE_INTEGER) ? object.integer.integer : 0; NULL, &buffer);
att->current_temp =
(err == B_OK && object.object_type == ACPI_TYPE_INTEGER)
? object.integer.integer : 0;
err = device->acpi->evaluate_method(device->acpi_cookie, "_HOT",
NULL, &buffer);
att->hot_temp =
(err == B_OK && object.object_type == ACPI_TYPE_INTEGER)
? object.integer.integer : 0;
// Read Passive Cooling devices // Read Passive Cooling devices
att->passive_package = NULL; att->passive_package = NULL;
@@ -175,7 +187,7 @@ acpi_thermal_free (void* cookie)
static float static float
acpi_thermal_support(device_node *parent) acpi_thermal_support(device_node *parent)
{ {
const char *bus; const char* bus;
uint32 device_type; uint32 device_type;
// make sure parent is really the ACPI bus manager // make sure parent is really the ACPI bus manager
@@ -205,12 +217,13 @@ acpi_thermal_register_device(device_node *node)
{ NULL } { NULL }
}; };
return sDeviceManager->register_node(node, ACPI_THERMAL_MODULE_NAME, attrs, NULL, NULL); return sDeviceManager->register_node(node, ACPI_THERMAL_MODULE_NAME, attrs,
NULL, NULL);
} }
static status_t static status_t
acpi_thermal_init_driver(device_node *node, void **_driverCookie) acpi_thermal_init_driver(device_node* node, void** _driverCookie)
{ {
*_driverCookie = node; *_driverCookie = node;
return B_OK; return B_OK;
@@ -218,15 +231,15 @@ acpi_thermal_init_driver(device_node *node, void **_driverCookie)
static void static void
acpi_thermal_uninit_driver(void *driverCookie) acpi_thermal_uninit_driver(void* driverCookie)
{ {
} }
static status_t static status_t
acpi_thermal_register_child_devices(void *_cookie) acpi_thermal_register_child_devices(void* _cookie)
{ {
device_node *node = _cookie; device_node* node = _cookie;
int path_id; int path_id;
char name[128]; char name[128];
@@ -238,26 +251,27 @@ acpi_thermal_register_child_devices(void *_cookie)
snprintf(name, sizeof(name), ACPI_THERMAL_BASENAME, path_id); snprintf(name, sizeof(name), ACPI_THERMAL_BASENAME, path_id);
return sDeviceManager->publish_device(node, name, ACPI_THERMAL_DEVICE_MODULE_NAME); return sDeviceManager->publish_device(node, name,
ACPI_THERMAL_DEVICE_MODULE_NAME);
} }
static status_t static status_t
acpi_thermal_init_device(void *_cookie, void **cookie) acpi_thermal_init_device(void* _cookie, void** cookie)
{ {
device_node *node = (device_node *)_cookie; device_node* node = (device_node*)_cookie;
acpi_thermal_device_info *device; acpi_thermal_device_info* device;
device_node *parent; device_node* parent;
device = (acpi_thermal_device_info *)calloc(1, sizeof(*device)); device = (acpi_thermal_device_info*)calloc(1, sizeof(*device));
if (device == NULL) if (device == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
device->node = node; device->node = node;
parent = sDeviceManager->get_parent_node(node); parent = sDeviceManager->get_parent_node(node);
sDeviceManager->get_driver(parent, (driver_module_info **)&device->acpi, sDeviceManager->get_driver(parent, (driver_module_info**)&device->acpi,
(void **)&device->acpi_cookie); (void**)&device->acpi_cookie);
sDeviceManager->put_node(parent); sDeviceManager->put_node(parent);
*cookie = device; *cookie = device;
@@ -266,16 +280,16 @@ acpi_thermal_init_device(void *_cookie, void **cookie)
static void static void
acpi_thermal_uninit_device(void *_cookie) acpi_thermal_uninit_device(void* _cookie)
{ {
acpi_thermal_device_info *device = (acpi_thermal_device_info *)_cookie; acpi_thermal_device_info* device = (acpi_thermal_device_info*)_cookie;
free(device); free(device);
} }
module_dependency module_dependencies[] = { module_dependency module_dependencies[] = {
{ B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&sDeviceManager }, { B_DEVICE_MANAGER_MODULE_NAME, (module_info**)&sDeviceManager },
{} {}
}; };
@@ -320,8 +334,8 @@ struct device_module_info acpi_thermal_device_module = {
NULL NULL
}; };
module_info *modules[] = { module_info* modules[] = {
(module_info *)&acpi_thermal_driver_module, (module_info*)&acpi_thermal_driver_module,
(module_info *)&acpi_thermal_device_module, (module_info*)&acpi_thermal_device_module,
NULL NULL
}; };