px4/common:mtd Use inttypes

This commit is contained in:
David Sidrane
2021-04-21 05:59:04 -07:00
committed by Julian Oes
parent 1b80018f30
commit dc23c85085
2 changed files with 12 additions and 10 deletions

View File

@@ -14,7 +14,7 @@
* *
* Derived from drivers/mtd/m25px.c * Derived from drivers/mtd/m25px.c
* *
* Copyright (C) 2009-2011 Gregory Nutt. All rights reserved. * Copyright (C) 2009-2011, 2021 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -55,6 +55,7 @@
#include <px4_platform_common/time.h> #include <px4_platform_common/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <inttypes.h>
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
@@ -270,7 +271,7 @@ void at24c_test(void)
} }
} else if (result != 1) { } else if (result != 1) {
syslog(LOG_INFO, "unexpected %u\n", result); syslog(LOG_INFO, "unexpected %zu\n", result);
} }
if ((count % 100) == 0) { if ((count % 100) == 0) {
@@ -314,7 +315,7 @@ static ssize_t at24c_bread(FAR struct mtd_dev_s *dev, off_t startblock,
#endif #endif
blocksleft = nblocks; blocksleft = nblocks;
finfo("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks); finfo("startblock: %08jx nblocks: %zu\n", (intmax_t)startblock, nblocks);
if (startblock >= priv->npages) { if (startblock >= priv->npages) {
return 0; return 0;
@@ -409,7 +410,7 @@ static ssize_t at24c_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t
nblocks = priv->npages - startblock; nblocks = priv->npages - startblock;
} }
finfo("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks); finfo("startblock: %08jx nblocks: %zu\n", (intmax_t)startblock, nblocks);
BOARD_EEPROM_WP_CTRL(false); BOARD_EEPROM_WP_CTRL(false);
@@ -505,7 +506,7 @@ static int at24c_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
#endif #endif
ret = OK; ret = OK;
finfo("blocksize: %d erasesize: %d neraseblocks: %d\n", finfo("blocksize: %" PRId32 " erasesize: %" PRId32 " neraseblocks: %" PRId32 "\n",
geo->blocksize, geo->erasesize, geo->neraseblocks); geo->blocksize, geo->erasesize, geo->neraseblocks);
} }
} }

View File

@@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
* *
* Copyright (c) 2020 PX4 Development Team. All rights reserved. * Copyright (c) 2020, 2021 PX4 Development Team. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@@ -49,6 +49,7 @@
#include <px4_platform_common/log.h> #include <px4_platform_common/log.h>
#include <px4_platform_common/spi.h> #include <px4_platform_common/spi.h>
#include <inttypes.h>
#include <errno.h> #include <errno.h>
#include <stdbool.h> #include <stdbool.h>
#include "systemlib/px4_macros.h" #include "systemlib/px4_macros.h"
@@ -363,7 +364,7 @@ memoryout:
char blockname[32]; char blockname[32];
unsigned offset; unsigned long offset;
unsigned part; unsigned part;
for (offset = 0, part = 0; rv == 0 && part < nparts; offset += instances[i].partition_block_counts[part], part++) { for (offset = 0, part = 0; rv == 0 && part < nparts; offset += instances[i].partition_block_counts[part], part++) {
@@ -373,8 +374,8 @@ memoryout:
instances[i].part_dev[part] = mtd_partition(instances[i].mtd_dev, offset, instances[i].partition_block_counts[part]); instances[i].part_dev[part] = mtd_partition(instances[i].mtd_dev, offset, instances[i].partition_block_counts[part]);
if (instances[i].part_dev[part] == nullptr) { if (instances[i].part_dev[part] == nullptr) {
PX4_ERR("mtd_partition failed. offset=%lu nblocks=%lu", PX4_ERR("mtd_partition failed. offset=%lu nblocks=%u",
(unsigned long)offset, (unsigned long)nblocks); offset, nblocks);
rv = -ENOSPC; rv = -ENOSPC;
goto errout; goto errout;
} }
@@ -407,7 +408,7 @@ memoryout:
errout: errout:
if (rv < 0) { if (rv < 0) {
PX4_ERR("mtd failure: %d bus %d address %d class %d", PX4_ERR("mtd failure: %d bus %" PRId32 " address %" PRId32 " class %d",
rv, rv,
PX4_I2C_DEVID_BUS(instances[i].devid), PX4_I2C_DEVID_BUS(instances[i].devid),
PX4_I2C_DEVID_ADDR(instances[i].devid), PX4_I2C_DEVID_ADDR(instances[i].devid),