diff options
author | Bill Richardson <wfrichar@google.com> | 2018-03-07 02:50:40 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-03-07 02:50:40 +0000 |
commit | 12fb202f400a7ff394442b5f9a47d434c7921441 (patch) | |
tree | 83e4ea2839333424800eedb29b1b0d522156e74a | |
parent | c48e911d96ef4e9205a3e9bc9c55fd02b0805abf (diff) | |
parent | 5a91e250b372e796b2dbad85c540d600542a6c30 (diff) | |
download | android-12fb202f400a7ff394442b5f9a47d434c7921441.tar.gz |
Merge "Add LOG_TAG for libnos_datagram functions"
-rw-r--r-- | citadel/libnos_datagram/citadel.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/citadel/libnos_datagram/citadel.c b/citadel/libnos_datagram/citadel.c index 9c8a058..2bcb53b 100644 --- a/citadel/libnos_datagram/citadel.c +++ b/citadel/libnos_datagram/citadel.c @@ -14,6 +14,8 @@ * limitations under the License. */ +#define LOG_TAG "libnos_datagram" +#include <cutils/log.h> #include <nos/device.h> #include <ctype.h> @@ -21,7 +23,6 @@ #include <fcntl.h> #include <getopt.h> #include <linux/types.h> -#include <log/log.h> #include <poll.h> #include <stdarg.h> #include <stdint.h> @@ -46,12 +47,6 @@ struct citadel_ioc_tpm_datagram { #define DEV_CITADEL "/dev/citadel0" -static void aperror(const char* msg) { - char buffer[80]; - strerror_r(errno, buffer, sizeof(buffer)); - ALOGE("%s: %s", msg, buffer); -} - static uint8_t in_buf[MAX_DEVICE_TRANSFER]; static int read_datagram(void *ctx, uint32_t command, uint8_t *buf, uint32_t len) { struct citadel_ioc_tpm_datagram dg = { @@ -81,7 +76,7 @@ static int read_datagram(void *ctx, uint32_t command, uint8_t *buf, uint32_t len ret = ioctl(fd, CITADEL_IOC_TPM_DATAGRAM, &dg); if (ret < 0) { - aperror("can't send spi message"); + ALOGE("can't send spi message: %s", strerror(errno)); return -errno; } @@ -120,7 +115,7 @@ static int write_datagram(void *ctx, uint32_t command, const uint8_t *buf, uint3 ret = ioctl(fd, CITADEL_IOC_TPM_DATAGRAM, &dg); if (ret < 0) { - aperror("can't send spi message"); + ALOGE("can't send spi message: %s", strerror(errno)); return -errno; } @@ -133,7 +128,7 @@ static void wait_for_interrupt(void *ctx) { // poll() was used because select() doesn't work here for some reason. if (poll(&fds, 1 /*nfds*/, -1) < 0) { - aperror("poll"); + ALOGE("poll: %s", strerror(errno)); } } @@ -154,7 +149,7 @@ static int reset(void *ctx) { ret = ioctl(fd, CITADEL_IOC_RESET); if (ret < 0) { - aperror("can't reset Citadel"); + ALOGE("can't reset Citadel: %s", strerror(errno)); return -errno; } return 0; @@ -174,7 +169,7 @@ static void close_device(void *ctx) { } if (close(fd) < 0) - aperror("Problem closing device (ignored)"); + ALOGE("Problem closing device (ignored): %s", strerror(errno)); free(ctx); } @@ -183,13 +178,13 @@ int nos_device_open(const char *device_name, struct nos_device *dev) { fd = open(device_name ? device_name : DEV_CITADEL, O_RDWR); if (fd < 0) { - aperror("can't open device"); + ALOGE("can't open device: %s", strerror(errno)); return -errno; } new_fd = (int *)malloc(sizeof(int)); if (!new_fd) { - aperror("can't malloc new fd"); + ALOGE("can't malloc new fd: %s", strerror(errno)); close(fd); return -ENOMEM; } |