X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Famd.c;h=7d77da5e5e302311f4d53341e6f852d1754adc69;hb=b01d095d6b123bcc7ed221cccf2c04295834cc84;hp=4660aa5c1e44fe41118d283d76d6561b03ce5b7d;hpb=131ea07f2e205245510c1dcefb0fb14769fd7643;p=psensor.git diff --git a/src/lib/amd.c b/src/lib/amd.c index 4660aa5..7d77da5 100644 --- a/src/lib/amd.c +++ b/src/lib/amd.c @@ -1,21 +1,22 @@ /* - Copyright (C) 2010-2011 thgreasi@gmail.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA -*/ + * Copyright (C) 2010-2011 thgreasi@gmail.com, jeanfi@gmail.com + * Copyright (C) 2010-2012 jeanfi@gmail.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ #ifndef LINUX #define LINUX 1 #endif @@ -60,22 +61,13 @@ static int *active_amd_adapters; /* Memory allocation function */ static void __stdcall *adl_main_memory_alloc(int isize) { - void *lpbuffer = malloc(isize); - return lpbuffer; -} - -/* Optional Memory de-allocation function */ -static void __stdcall adl_main_memory_free(void **lpbuffer) -{ - if (*lpbuffer) { - free(*lpbuffer); - *lpbuffer = NULL; - } + void *lpbuffer = malloc(isize); + return lpbuffer; } -static void *getprocaddress(void *plibrary, const char * name) +static void *getprocaddress(void *plibrary, const char *name) { - return dlsym(plibrary, name); + return dlsym(plibrary, name); } /* @@ -126,10 +118,10 @@ static struct psensor *create_sensor(int id, int values_len) sensor_type = SENSOR_TYPE_AMD_TEMP; } - sid = malloc(strlen("AMD") + 1 + strlen(name) + 1); - sprintf(sid, "AMD %s", name); + sid = malloc(strlen("amd") + 1 + strlen(name) + 1); + sprintf(sid, "amd %s", name); - s = psensor_create(sid, strdup(name), + s = psensor_create(sid, strdup(name), strdup("ATI GPU"), sensor_type, values_len); s->amd_id = active_amd_adapters[id]; @@ -146,7 +138,7 @@ static struct psensor *create_sensor(int id, int values_len) static int init() { LPAdapterInfo lpadapterinfo = NULL; - int i, inumberadapters, inumberadaptersactive = 0; + int i, inumberadapters, inumberadaptersactive = 0; int lpstatus, iadapterindex; hdll = NULL; @@ -155,8 +147,7 @@ static int init() hdll = dlopen("libatiadlxx.so", RTLD_LAZY|RTLD_GLOBAL); if (!hdll) { - fprintf(stderr, - _("ERROR: ADL library not found!\n")); + log_err(_("AMD: cannot found ADL library.")); return 0; } @@ -180,8 +171,7 @@ static int init() !adl_adapter_adapterinfo_get || !adl_overdrive5_temperature_get || !adl_overdrive5_fanspeed_get) { - fprintf(stderr, - _("ERROR: ADL's API is missing!\n")); + log_err(_("AMD: missing ADL's API.")); return 0; } @@ -189,16 +179,14 @@ static int init() retrieve adapter information only for adapters that are physically present and enabled in the system */ if (ADL_OK != adl_main_control_create(adl_main_memory_alloc, 1)) { - fprintf(stderr, - _("ERROR: ADL Initialization Error!\n")); + log_err(_("AMD: failed to initialize ADL.")); return 0; } adl_main_control_done = 1; /* Obtain the number of adapters for the system */ if (ADL_OK != adl_adapter_numberofadapters_get(&inumberadapters)) { - fprintf(stderr, - _("ERROR: Cannot get the number of adapters!\n")); + log_err(_("AMD: cannot get the number of adapters.")); return 0; } @@ -235,7 +223,7 @@ static int init() active_amd_adapters[inumberadaptersactive-1] = iadapterindex; } - adl_main_memory_free((void **) &lpadapterinfo); + free(lpadapterinfo); /* Each Adapter has one GPU temperature sensor and one fan control sensor */