diff options
author | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2016-12-13 02:31:32 +0100 |
---|---|---|
committer | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2016-12-13 02:31:32 +0100 |
commit | e7e8f7d29063df2017d419a898fe877b56b14653 (patch) | |
tree | b450d69a7775c0b898e15956fac7069975513aab /libsensors/akmdfs/AKFS_FileIO.c | |
parent | 80d404b929c222f3fdc7ecad7694753c8c27a537 (diff) | |
parent | 25eedce86d2723b23b6fc21dece20540f7ec68c0 (diff) | |
download | device_samsung_i9300-e7e8f7d29063df2017d419a898fe877b56b14653.zip device_samsung_i9300-e7e8f7d29063df2017d419a898fe877b56b14653.tar.gz device_samsung_i9300-e7e8f7d29063df2017d419a898fe877b56b14653.tar.bz2 |
Merge branch 'cm-13.0' of https://github.com/CyanogenMod/android_device_samsung_i9300 into replicant-6.0replicant-6.0-alpha-0006
Diffstat (limited to 'libsensors/akmdfs/AKFS_FileIO.c')
-rw-r--r-- | libsensors/akmdfs/AKFS_FileIO.c | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/libsensors/akmdfs/AKFS_FileIO.c b/libsensors/akmdfs/AKFS_FileIO.c deleted file mode 100644 index 92c2ce9..0000000 --- a/libsensors/akmdfs/AKFS_FileIO.c +++ /dev/null @@ -1,130 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2012 Asahi Kasei Microdevices Corporation, Japan - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ -#include "AKFS_FileIO.h" - -/*** Constant definition ******************************************************/ -#ifdef AKFS_PRECISION_DOUBLE -#define AKFS_SCANF_FORMAT "%63s = %lf" -#else -#define AKFS_SCANF_FORMAT "%63s = %f" -#endif -#define AKFS_PRINTF_FORMAT "%s = %f\n" -#define LOAD_BUF_SIZE 64 - -/*! - Load parameters from file which is specified with #path. This function reads - data from a beginning of the file line by line, and check parameter name - sequentially. In otherword, this function depends on the order of eache - parameter described in the file. - @return If function fails, the return value is #AKM_FAIL. When function fails, - the output is undefined. Therefore, parameters which are possibly overwritten - by this function should be initialized again. If function succeeds, the - return value is #AKM_SUCCESS. - @param[out] prms A pointer to #AK8975PRMS structure. Loaded parameter is - stored to the member of this structure. - @param[in] path A path to the setting file. - */ -int16 AKFS_LoadParameters(AK8975PRMS * prms, const char* path) -{ - int16 ret; - char buf[LOAD_BUF_SIZE]; - FILE *fp = NULL; - - /* Open setting file for read. */ - if ((fp = fopen(path, "r")) == NULL) { - AKMERROR_STR("fopen"); - return AKM_FAIL; - } - - ret = 1; - - /* Load data to HO */ - if (fscanf(fp, AKFS_SCANF_FORMAT, buf, &prms->mfv_ho.u.x) != 2) { - ret = 0; - } else { - if (strncmp(buf, "HO.x", sizeof(buf)) != 0) { - ret = 0; - } - } - if (fscanf(fp, AKFS_SCANF_FORMAT, buf, &prms->mfv_ho.u.y) != 2) { - ret = 0; - } else { - if (strncmp(buf, "HO.y", sizeof(buf)) != 0) { - ret = 0; - } - } - if (fscanf(fp, AKFS_SCANF_FORMAT, buf, &prms->mfv_ho.u.z) != 2) { - ret = 0; - } else { - if (strncmp(buf, "HO.z", sizeof(buf)) != 0) { - ret = 0; - } - } - - if (fclose(fp) != 0) { - AKMERROR_STR("fclose"); - ret = 0; - } - - if (ret == 0) { - AKMERROR; - return AKM_FAIL; - } - - return AKM_SUCCESS; -} - -/*! - Save parameters to file which is specified with #path. This function saves - variables when the offsets of magnetic sensor estimated successfully. - @return If function fails, the return value is #AKM_FAIL. When function fails, - the parameter file may collapsed. Therefore, the parameters file should be - discarded. If function succeeds, the return value is #AKM_SUCCESS. - @param[out] prms A pointer to #AK8975PRMS structure. Member variables are - saved to the parameter file. - @param[in] path A path to the setting file. - */ -int16 AKFS_SaveParameters(AK8975PRMS *prms, const char* path) -{ - int16 ret = 1; - FILE *fp; - - /*Open setting file for write. */ - if ((fp = fopen(path, "w")) == NULL) { - AKMERROR_STR("fopen"); - return AKM_FAIL; - } - - /* Save data to HO */ - if (fprintf(fp, AKFS_PRINTF_FORMAT, "HO.x", prms->mfv_ho.u.x) < 0) { ret = 0; } - if (fprintf(fp, AKFS_PRINTF_FORMAT, "HO.y", prms->mfv_ho.u.y) < 0) { ret = 0; } - if (fprintf(fp, AKFS_PRINTF_FORMAT, "HO.z", prms->mfv_ho.u.z) < 0) { ret = 0; } - - if (fclose(fp) != 0) { - AKMERROR_STR("fclose"); - ret = 0; - } - - if (ret == 0) { - AKMERROR; - return AKM_FAIL; - } - - return AKM_SUCCESS; -} - |