Private
Public Access
2
0

swig: add unexport() calls to be used by destructors in object api

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2014-05-02 16:31:16 +01:00
parent 3e0d0c8241
commit 09cec0931b
5 changed files with 41 additions and 11 deletions

View File

@@ -158,16 +158,20 @@ maa_gpio_write(maa_gpio_context *dev, int value)
if (dev->value_fp == NULL) {
maa_gpio_get_valfp(dev);
}
fseek(dev->value_fp, SEEK_SET, 0);
if (fseek(dev->value_fp, SEEK_SET, 0) != 0) {
return MAA_ERROR_INVALID_RESOURCE;
}
fprintf(dev->value_fp, "%d", value);
fseek(dev->value_fp, SEEK_SET, 0);
if (fseek(dev->value_fp, SEEK_SET, 0) != 0) {
return MAA_ERROR_INVALID_RESOURCE;
}
if (ferror(dev->value_fp) != 0)
return MAA_ERROR_INVALID_RESOURCE;
return MAA_SUCCESS;
}
maa_result_t
maa_gpio_close(maa_gpio_context *dev)
maa_gpio_unexport(maa_gpio_context *dev)
{
FILE *unexport_f;
@@ -179,6 +183,12 @@ maa_gpio_close(maa_gpio_context *dev)
fclose(unexport_f);
if (ferror(dev->value_fp) != 0)
return MAA_ERROR_INVALID_RESOURCE;
}
maa_result_t
maa_gpio_close(maa_gpio_context *dev)
{
maa_gpio_unexport(dev);
free(dev);
return MAA_SUCCESS;
}