Run all .c and .h files in previous commits through nxstyle.

This commit is contained in:
Gregory Nutt
2020-03-21 13:54:03 -06:00
committed by Xiang Xiao
parent 533528af01
commit 547a3cb3d9
15 changed files with 1043 additions and 766 deletions
+58 -24
View File
@@ -33,6 +33,10 @@
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
@@ -55,6 +59,10 @@
#include "hardware/cxd56_emmc.h"
#include "cxd56_pinconfig.h"
/****************************************************************************
* Pre-processoro Definitions
****************************************************************************/
#define SECTOR_SIZE (512)
#define EMMC_DATA_WRITE 0
@@ -67,7 +75,27 @@
#define EMMC_RESP_R2 3
#define EMMC_RESP_R3 4
struct emmc_dma_desc_s {
#define EMMC_CLKDIV_UNDER_400KHZ (32u)
#define EMMC_CLKDIV_NON_DIV (0u)
#define EMMC_RCA (2) /* greater than 1 */
#define EMMC_DATA_TIMEOUT (0xFFFFFFu) /* max reg value */
#define EMMC_RESP_TIMEOUT (0xFFu) /* max reg value */
#define EMMC_MSIZE (6) /* Burst size is 512B */
#define EMMC_FIFO_DEPTH (0x100) /* FIFO size is 1KB */
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
/****************************************************************************
* Private Types
****************************************************************************/
struct emmc_dma_desc_s
{
uint32_t ctrl;
uint32_t size;
uint32_t addr;
@@ -81,6 +109,10 @@ struct cxd56_emmc_state_s
uint32_t total_sectors;
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* Block driver interfaces **************************************************/
static int cxd56_emmc_open(FAR struct inode *inode);
@@ -98,6 +130,10 @@ static int cxd56_emmc_geometry(FAR struct inode *inode,
struct geometry *geometry);
static int emmc_interrupt(int irq, FAR void *context, FAR void *arg);
/****************************************************************************
* Private Data
****************************************************************************/
static const struct block_operations g_bops =
{
cxd56_emmc_open, /* open */
@@ -106,29 +142,18 @@ static const struct block_operations g_bops =
#if !defined(CONFIG_MMCSD_READONLY)
cxd56_emmc_write, /* write */
#else
NULL, /* write */
NULL, /* write */
#endif
cxd56_emmc_geometry, /* geometry */
NULL /* ioctl */
NULL /* ioctl */
};
static sem_t g_waitsem;
struct cxd56_emmc_state_s g_emmcdev;
#define EMMC_CLKDIV_UNDER_400KHZ (32u)
#define EMMC_CLKDIV_NON_DIV (0u)
#define EMMC_RCA (2) /* greater than 1 */
#define EMMC_DATA_TIMEOUT (0xFFFFFFu) /* max reg value */
#define EMMC_RESP_TIMEOUT (0xFFu) /* max reg value */
#define EMMC_MSIZE (6) /* Burst size is 512B */
#define EMMC_FIFO_DEPTH (0x100) /* FIFO size is 1KB */
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
static void emmc_takesem(FAR sem_t *sem)
{
@@ -308,9 +333,9 @@ static struct emmc_dma_desc_s *emmc_setupdma(void *buf, unsigned int nbytes)
/* Adjust first and last descriptor members */
descs[0].ctrl |= EMMC_IDMAC_DES0_FD;
descs[ndescs-1].ctrl |= EMMC_IDMAC_DES0_LD;
descs[ndescs-1].next = 0;
descs[0].ctrl |= EMMC_IDMAC_DES0_FD;
descs[ndescs - 1].ctrl |= EMMC_IDMAC_DES0_LD;
descs[ndescs - 1].next = 0;
#ifdef CONFIG_DEBUG_VERBOSE
for (i = 0, d = descs; i < ndescs; i++, d++)
@@ -341,6 +366,7 @@ static int emmc_checkresponse(void)
ferr("Response error %08x\n", resp);
return -EIO;
}
return OK;
}
@@ -454,6 +480,7 @@ static int emmc_is_powerup(void)
{
return 0;
}
up_mdelay(5);
}
while (--retry);
@@ -716,7 +743,7 @@ static int cxd56_emmc_readsectors(FAR struct cxd56_emmc_state_s *priv,
ret = -EIO;
}
finish:
finish:
emmc_givesem(&priv->excsem);
kmm_free(descs);
@@ -787,7 +814,7 @@ static int cxd56_emmc_writesectors(FAR struct cxd56_emmc_state_s *priv,
emmc_flushwritefifo();
finish:
finish:
emmc_givesem(&priv->excsem);
kmm_free(descs);
@@ -826,8 +853,9 @@ static int cxd56_emmc_close(FAR struct inode *inode)
return OK;
}
static ssize_t cxd56_emmc_read(FAR struct inode *inode, unsigned char *buffer,
size_t start_sector, unsigned int nsectors)
static ssize_t cxd56_emmc_read(FAR struct inode *inode,
unsigned char *buffer, size_t start_sector,
unsigned int nsectors)
{
FAR struct cxd56_emmc_state_s *priv;
int ret;
@@ -927,9 +955,11 @@ int cxd56_emmcinitialize(void)
kmm_free(buf);
return -EIO;
}
priv->total_sectors = *(FAR uint32_t *)&buf[EXTCSD_SEC_COUNT];
kmm_free(descs);
}
kmm_free(buf);
}
@@ -943,6 +973,10 @@ int cxd56_emmcinitialize(void)
return OK;
}
/****************************************************************************
* Public Functions
****************************************************************************/
int emmc_uninitialize(void)
{
/* Send power off command */
+15 -8
View File
@@ -78,10 +78,13 @@ static int mmcl_open(FAR struct inode *inode);
static int mmcl_close(FAR struct inode *inode);
static ssize_t mmcl_read(FAR struct inode *inode, unsigned char *buffer,
size_t start_sector, unsigned int nsectors);
static ssize_t mmcl_write(FAR struct inode *inode, const unsigned char *buffer,
size_t start_sector, unsigned int nsectors);
static int mmcl_geometry(FAR struct inode *inode, struct geometry *geometry);
static int mmcl_ioctl(FAR struct inode *inode, int cmd, unsigned long arg);
static ssize_t mmcl_write(FAR struct inode *inode,
const unsigned char *buffer, size_t start_sector,
unsigned int nsectors);
static int mmcl_geometry(FAR struct inode *inode,
struct geometry *geometry);
static int mmcl_ioctl(FAR struct inode *inode, int cmd,
unsigned long arg);
/****************************************************************************
* Private Data
@@ -163,8 +166,9 @@ static ssize_t mmcl_read(FAR struct inode *inode, unsigned char *buffer,
*
****************************************************************************/
static ssize_t mmcl_write(FAR struct inode *inode, const unsigned char *buffer,
size_t start_sector, unsigned int nsectors)
static ssize_t mmcl_write(FAR struct inode *inode,
const unsigned char *buffer, size_t start_sector,
unsigned int nsectors)
{
ssize_t nwrite;
struct mmcl_dev_s *dev;
@@ -249,7 +253,8 @@ static int mmcl_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
* Name: mmcl_allocdev
****************************************************************************/
static FAR struct mmcl_dev_s *mmcl_allocdev(int number, FAR struct mtd_dev_s *mtd)
static FAR struct mmcl_dev_s *mmcl_allocdev(int number,
FAR struct mtd_dev_s *mtd)
{
struct mmcl_dev_s *dev;
int ret;
@@ -268,7 +273,8 @@ static FAR struct mmcl_dev_s *mmcl_allocdev(int number, FAR struct mtd_dev_s *mt
* from the size of a pointer).
*/
ret = MTD_IOCTL(mtd, MTDIOC_GEOMETRY, (unsigned long)((uintptr_t)&dev->geo));
ret = MTD_IOCTL(mtd, MTDIOC_GEOMETRY,
(unsigned long)((uintptr_t)&dev->geo));
if (ret < 0)
{
finfo("MTD ioctl(MTDIOC_GEOMETRY) failed: %d\n", ret);
@@ -317,6 +323,7 @@ int mmcl_initialize(int minor, FAR struct mtd_dev_s *mtd)
CONFIG_MTD_DEVPATH1,
#endif
};
int ret = -ENOMEM;
/* Sanity check */
@@ -65,9 +65,9 @@
#include "stm32l476vg-disco.h"
/* Conditional logic in stm32l476vg-disco.h will determine if certain features
* are supported. Tests for these features need to be made after including
* stm32l476vg-disco.h.
/* Conditional logic in stm32l476vg-disco.h will determine if certain
* features are supported. Tests for these features need to be made after
* including stm32l476vg-disco.h.
*/
#ifdef HAVE_RTC_DRIVER
@@ -129,7 +129,7 @@ int board_app_initialize(uintptr_t arg)
FAR struct rtc_lowerhalf_s *rtclower;
#endif
#if defined(HAVE_N25QXXX)
FAR struct mtd_dev_s *mtd_temp;
FAR struct mtd_dev_s *mtd_temp;
#endif
#if defined(HAVE_N25QXXX_CHARDEV)
char blockdev[18];
@@ -197,34 +197,35 @@ FAR struct mtd_dev_s *mtd_temp;
_err("ERROR: n25qxxx_initialize failed\n");
return ret;
}
g_mtd_fs = mtd_temp;
#ifdef CONFIG_MTD_PARTITION
{
FAR struct mtd_geometry_s geo;
off_t nblocks;
{
FAR struct mtd_geometry_s geo;
off_t nblocks;
/* Setup a partition of 256KiB for our file system. */
/* Setup a partition of 256KiB for our file system. */
ret = MTD_IOCTL(g_mtd_fs, MTDIOC_GEOMETRY,
(unsigned long)(uintptr_t)&geo);
if (ret < 0)
{
_err("ERROR: MTDIOC_GEOMETRY failed\n");
return ret;
}
ret = MTD_IOCTL(g_mtd_fs, MTDIOC_GEOMETRY,
(unsigned long)(uintptr_t)&geo);
if (ret < 0)
{
_err("ERROR: MTDIOC_GEOMETRY failed\n");
return ret;
}
nblocks = (256*1024) / geo.blocksize;
nblocks = (256 * 1024) / geo.blocksize;
mtd_temp = mtd_partition(g_mtd_fs, 0, nblocks);
if (!mtd_temp)
{
_err("ERROR: mtd_partition failed\n");
return ret;
}
mtd_temp = mtd_partition(g_mtd_fs, 0, nblocks);
if (!mtd_temp)
{
_err("ERROR: mtd_partition failed\n");
return ret;
}
g_mtd_fs = mtd_temp;
}
g_mtd_fs = mtd_temp;
}
#endif
#ifdef HAVE_N25QXXX_SMARTFS
+68 -76
View File
@@ -1,35 +1,20 @@
/****************************************************************************
* boards/boardctl.c
*
* Copyright (C) 2015-2017, 2018-2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* http://www.apache.org/licenses/LICENSE-2.0
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* 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.
*
****************************************************************************/
@@ -95,7 +80,8 @@
****************************************************************************/
#ifdef CONFIG_BOARDCTL_USBDEVCTRL
static inline int boardctl_usbdevctrl(FAR struct boardioc_usbdev_ctrl_s *ctrl)
static inline int
boardctl_usbdevctrl(FAR struct boardioc_usbdev_ctrl_s *ctrl)
{
int ret = OK;
@@ -297,10 +283,10 @@ static inline int boardctl_pmctrl(FAR struct boardioc_pm_ctrl_s *ctrl)
* to "correct" but awkward implementations.
*
* boardctl() is non-standard OS interface to alleviate the problem. It
* basically circumvents the normal device driver ioctl interlace and allows
* the application to perform direction IOCTL-like calls to the board-specific
* logic. In it is especially useful for setting up board operational and
* test configurations.
* basically circumvents the normal device driver ioctl interlace and
* allows the application to perform direction IOCTL-like calls to the
* board-specific logic. In it is especially useful for setting up board
* operational and test configurations.
*
* Input Parameters:
* cmd - Identifies the board command to be executed
@@ -322,16 +308,16 @@ int boardctl(unsigned int cmd, uintptr_t arg)
/* CMD: BOARDIOC_INIT
* DESCRIPTION: Perform one-time application initialization.
* ARG: The boardctl() argument is passed to the
* board_app_initialize() implementation without modification.
* The argument has no meaning to NuttX; the meaning of the
* argument is a contract between the board-specific
* initialization logic and the matching application logic.
* The value cold be such things as a mode enumeration value,
* a set of DIP switch switch settings, a pointer to
* configuration data read from a file or serial FLASH, or
* whatever you would like to do with it. Every
* implementation should accept zero/NULL as a default
* configuration.
* board_app_initialize() implementation without
* modification. The argument has no meaning to NuttX;
* the meaning of the argument is a contract between
* the board-specific initialization logic and the
* matching application logic. The value cold be such
* things as a mode enumeration value, a set of DIP
* switch switch settings, a pointer to configuration
* data read from a file or serial FLASH, or whatever
* you would like to do with it. Every implementation
* should accept zero/NULL as a default configuration.
* CONFIGURATION: CONFIG_LIB_BOARDCTL
* DEPENDENCIES: Board logic must provide board_app_initialization
*/
@@ -411,8 +397,9 @@ int boardctl(unsigned int cmd, uintptr_t arg)
/* CMD: BOARDIOC_UNIQUEID
* DESCRIPTION: Return a unique ID associated with the board (such
* as a serial number or a MAC address).
* ARG: A writable array of size CONFIG_BOARDCTL_UNIQUEID_SIZE
* in which to receive the board unique ID.
* ARG: A writable array of size
* CONFIG_BOARDCTL_UNIQUEID_SIZE in which to receive
* the board unique ID.
* DEPENDENCIES: Board logic must provide the board_uniqueid()
* interface.
*/
@@ -427,7 +414,8 @@ int boardctl(unsigned int cmd, uintptr_t arg)
#ifdef CONFIG_BOARDCTL_MKRD
/* CMD: BOARDIOC_MKRD
* DESCRIPTION: Create a RAM disk
* ARG: Pointer to read-only instance of struct boardioc_mkrd_s.
* ARG: Pointer to read-only instance of struct
* boardioc_mkrd_s.
* CONFIGURATION: CONFIG_BOARDCTL_MKRD
* DEPENDENCIES: None
*/
@@ -453,7 +441,8 @@ int boardctl(unsigned int cmd, uintptr_t arg)
#ifdef CONFIG_BOARDCTL_ROMDISK
/* CMD: BOARDIOC_ROMDISK
* DESCRIPTION: Register
* ARG: Pointer to read-only instance of struct boardioc_romdisk_s.
* ARG: Pointer to read-only instance of struct
* boardioc_romdisk_s.
* CONFIGURATION: CONFIG_BOARDCTL_ROMDISK
* DEPENDENCIES: None
*/
@@ -469,8 +458,8 @@ int boardctl(unsigned int cmd, uintptr_t arg)
}
else
{
ret = romdisk_register((int)desc->minor, desc->image, desc->nsectors,
desc->sectsize);
ret = romdisk_register((int)desc->minor, desc->image,
desc->nsectors, desc->sectsize);
}
}
break;
@@ -478,9 +467,9 @@ int boardctl(unsigned int cmd, uintptr_t arg)
#ifdef CONFIG_BOARDCTL_APP_SYMTAB
/* CMD: BOARDIOC_APP_SYMTAB
* DESCRIPTION: Select the application symbol table. This symbol table
* provides the symbol definitions exported to application
* code from application space.
* DESCRIPTION: Select the application symbol table. This symbol
* table provides the symbol definitions exported to
* application code from application space.
* ARG: A pointer to an instance of struct boardioc_symtab_s
* CONFIGURATION: CONFIG_BOARDCTL_APP_SYMTAB
* DEPENDENCIES: None
@@ -500,9 +489,9 @@ int boardctl(unsigned int cmd, uintptr_t arg)
#ifdef CONFIG_BOARDCTL_OS_SYMTAB
/* CMD: BOARDIOC_OS_SYMTAB
* DESCRIPTION: Select the OS symbol table. This symbol table provides
* the symbol definitions exported by the OS to kernel
* modules.
* DESCRIPTION: Select the OS symbol table. This symbol table
* provides the symbol definitions exported by the OS to
* kernal modules.
* ARG: A pointer to an instance of struct boardioc_symtab_s
* CONFIGURATION: CONFIG_BOARDCTL_OS_SYMTAB
* DEPENDENCIES: None
@@ -522,17 +511,18 @@ int boardctl(unsigned int cmd, uintptr_t arg)
#ifdef CONFIG_BUILTIN
/* CMD: BOARDIOC_BUILTINS
* DESCRIPTION: Provide the user-space list of built-in applications for
* use by BINFS in protected mode. Normally this is small
* set of globals provided by user-space logic. It provides
* name-value pairs for associating built-in application
* names with user-space entry point addresses. These
* globals are only needed for use by BINFS which executes
* built-in applications from kernel-space in PROTECTED mode.
* In the FLAT build, the user space globals are readily
* available. (BINFS is not supportable in KERNEL mode since
* user-space address have no general meaning that
* configuration).
* DESCRIPTION: Provide the user-space list of built-in applications
* for use by BINFS in protected mode. Normally this
* is small set of globals provided by user-space
* logic. It provides name-value pairs for associating
* built-in application names with user-space entry
* point addresses. These globals are only needed for
* use by BINFS which executes built-in applications
* from kernel-space in PROTECTED mode. In the FLAT
* build, the user space globals are readily
* available. (BINFS is not supportable in KERNEL mode
* since user-space address have no general meaning
* that configuration).
* ARG: A pointer to an instance of struct boardioc_builtin_s
* CONFIGURATION: This BOARDIOC command is always available when
* CONFIG_BUILTIN is enabled, but does nothing unless
@@ -557,7 +547,8 @@ int boardctl(unsigned int cmd, uintptr_t arg)
#ifdef CONFIG_BOARDCTL_USBDEVCTRL
/* CMD: BOARDIOC_USBDEV_CONTROL
* DESCRIPTION: Manage USB device classes
* ARG: A pointer to an instance of struct boardioc_usbdev_ctrl_s
* ARG: A pointer to an instance of struct
* boardioc_usbdev_ctrl_s
* CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_USBDEVCTRL
* DEPENDENCIES: Board logic must provide board_<usbdev>_initialize()
*/
@@ -673,9 +664,10 @@ int boardctl(unsigned int cmd, uintptr_t arg)
break;
/* CMD: BOARDIOC_NXTERM_IOCTL
* DESCRIPTION: Create an NX terminal IOCTL command. Normal IOCTLs
* cannot be be performed in most graphics contexts since
* the depend on the task holding an open file descriptor
* DESCRIPTION: Create an NX terminal IOCTL command. Normal
* IOCTLs cannot be be performed in most graphics
* contexts since the depend on the task holding an
* open file descriptor
* ARG: A reference readable/writable instance of struct
* boardioc_nxterm_ioctl_s
* CONFIGURATION: CONFIG_NXTERM
@@ -696,9 +688,9 @@ int boardctl(unsigned int cmd, uintptr_t arg)
#ifdef CONFIG_BOARDCTL_TESTSET
/* CMD: BOARDIOC_TESTSET
* DESCRIPTION: Access architecture-specific up_testset() operation
* ARG: A pointer to a write-able spinlock object. On success
* the preceding spinlock state is returned: 0=unlocked,
* 1=locked.
* ARG: A pointer to a write-able spinlock object. On
* success the preceding spinlock state is returned:
* 0=unlocked, 1=locked.
* CONFIGURATION: CONFIG_BOARDCTL_TESTSET
* DEPENDENCIES: Architecture-specific logic provides up_testset()
*/
@@ -722,10 +714,10 @@ int boardctl(unsigned int cmd, uintptr_t arg)
default:
{
#ifdef CONFIG_BOARDCTL_IOCTL
/* Boards may also select CONFIG_BOARDCTL_IOCTL=y to enable board-
* specific commands. In this case, all commands not recognized
* by boardctl() will be forwarded to the board-provided board_ioctl()
* function.
/* Boards may also select CONFIG_BOARDCTL_IOCTL=y to enable
* board-specific commands. In this case, all commands not
* recognized by boardctl() will be forwarded to the board-
* provided board_ioctl() function.
*/
ret = board_ioctl(cmd, arg);
+250 -210
View File
File diff suppressed because it is too large Load Diff
+142 -77
View File
@@ -82,6 +82,7 @@
#endif
/* Slot struct info *********************************************************/
/* Slot status definitions */
#define MMCSD_SLOTSTATUS_NOTREADY 0x01 /* Card not initialized */
@@ -90,6 +91,7 @@
#define MMCSD_SLOTSTATUS_MEDIACHGD 0x08 /* Media changed in slot */
/* Values in the MMC/SD command table ***************************************/
/* These define the value returned by the MMC/SD command */
#define MMCSD_CMDRESP_R1 0
@@ -250,9 +252,9 @@ static struct mmcsd_slot_s g_mmcsdslot[CONFIG_MMCSD_NSLOTS];
static const uint32_t g_transpeedru[8] =
{
10000, /* 0: 100 Kbit/sec / 10 */
100000, /* 1: 1 Mbit/sec / 10 */
1000000, /* 2: 10 Mbit/sec / 10 */
10000, /* 0: 100 Kbit/sec / 10 */
100000, /* 1: 1 Mbit/sec / 10 */
1000000, /* 2: 10 Mbit/sec / 10 */
10000000, /* 3: 100 Mbit/sec / 10 */
0, 0, 0, 0 /* 4-7: Reserved values */
@@ -260,7 +262,7 @@ static const uint32_t g_transpeedru[8] =
static const uint32_t g_transpeedtu[16] =
{
0, 10, 12, 13, /* 0-3: Reserved, 1.0, 1.1, 1.2, 1.3 */
0, 10, 12, 13, /* 0-3: Reserved, 1.0, 1.1, 1.2, 1.3 */
15, 20, 25, 30, /* 4-7: 1.5, 2.0, 2.5, 3.0 */
35, 40, 45, 50, /* 8-11: 3.5, 4.0, 4.5, 5.0 */
55, 60, 70, 80, /* 12-15: 5.5, 6.0, 7.0, 8.0 */
@@ -286,16 +288,16 @@ static const uint16_t g_taactu[8] =
{
/* Units of nanoseconds */
1, /* 0: 1 ns */
10, /* 1: 10 ns */
100, /* 2: 100 ns */
1, /* 0: 1 ns */
10, /* 1: 10 ns */
100, /* 2: 100 ns */
/* Units of microseconds */
1, /* 3: 1 us 1,000 ns */
10, /* 4: 10 us 10,000 ns */
100, /* 5: 100 us 100,000 ns */
1000, /* 6: 1 ms 1,000,000 ns */
1, /* 3: 1 us 1,000 ns */
10, /* 4: 10 us 10,000 ns */
100, /* 5: 100 us 100,000 ns */
1000, /* 6: 1 ms 1,000,000 ns */
10000, /* 7: 10 ms 10,000,000 ns */
};
@@ -309,27 +311,72 @@ static const uint16_t g_taactv[] =
/* Commands *****************************************************************/
static const struct mmcsd_cmdinfo_s g_cmd0 = {CMD0, MMCSD_CMDRESP_R1, 0x95};
static const struct mmcsd_cmdinfo_s g_cmd1 = {CMD1, MMCSD_CMDRESP_R1, 0xff};
static const struct mmcsd_cmdinfo_s g_cmd8 = {CMD8, MMCSD_CMDRESP_R7, 0x87};
static const struct mmcsd_cmdinfo_s g_cmd9 = {CMD9, MMCSD_CMDRESP_R1, 0xff};
static const struct mmcsd_cmdinfo_s g_cmd0 =
{
CMD0, MMCSD_CMDRESP_R1, 0x95
};
static const struct mmcsd_cmdinfo_s g_cmd1 =
{
CMD1, MMCSD_CMDRESP_R1, 0xff
};
static const struct mmcsd_cmdinfo_s g_cmd8 =
{
CMD8, MMCSD_CMDRESP_R7, 0x87
};
static const struct mmcsd_cmdinfo_s g_cmd9 =
{
CMD9, MMCSD_CMDRESP_R1, 0xff
};
#if 0 /* Not used */
static const struct mmcsd_cmdinfo_s g_cmd10 = {CMD10, MMCSD_CMDRESP_R1, 0xff};
static const struct mmcsd_cmdinfo_s g_cmd10 =
{
CMD10, MMCSD_CMDRESP_R1, 0xff
};
#endif
static const struct mmcsd_cmdinfo_s g_cmd12 = {CMD12, MMCSD_CMDRESP_R1, 0xff};
static const struct mmcsd_cmdinfo_s g_cmd16 = {CMD16, MMCSD_CMDRESP_R1, 0xff};
static const struct mmcsd_cmdinfo_s g_cmd17 = {CMD17, MMCSD_CMDRESP_R1, 0xff};
static const struct mmcsd_cmdinfo_s g_cmd18 = {CMD18, MMCSD_CMDRESP_R1, 0xff};
static const struct mmcsd_cmdinfo_s g_cmd12 =
{
CMD12, MMCSD_CMDRESP_R1, 0xff
};
static const struct mmcsd_cmdinfo_s g_cmd16 =
{
CMD16, MMCSD_CMDRESP_R1, 0xff
};
static const struct mmcsd_cmdinfo_s g_cmd17 =
{
CMD17, MMCSD_CMDRESP_R1, 0xff
};
static const struct mmcsd_cmdinfo_s g_cmd18 =
{
CMD18, MMCSD_CMDRESP_R1, 0xff
};
#if !defined(CONFIG_MMCSD_READONLY)
static const struct mmcsd_cmdinfo_s g_cmd24 = {CMD24, MMCSD_CMDRESP_R1, 0xff};
static const struct mmcsd_cmdinfo_s g_cmd25 = {CMD25, MMCSD_CMDRESP_R1, 0xff};
static const struct mmcsd_cmdinfo_s g_cmd24 =
{
CMD24, MMCSD_CMDRESP_R1, 0xff
};
static const struct mmcsd_cmdinfo_s g_cmd25 =
{
CMD25, MMCSD_CMDRESP_R1, 0xff
};
#endif
static const struct mmcsd_cmdinfo_s g_cmd55 = {CMD55, MMCSD_CMDRESP_R1, 0xff};
static const struct mmcsd_cmdinfo_s g_cmd58 = {CMD58, MMCSD_CMDRESP_R3, 0xff};
static const struct mmcsd_cmdinfo_s g_cmd55 =
{
CMD55, MMCSD_CMDRESP_R1, 0xff
};
static const struct mmcsd_cmdinfo_s g_cmd58 =
{
CMD58, MMCSD_CMDRESP_R3, 0xff
};
#if !defined(CONFIG_MMCSD_READONLY)
static const struct mmcsd_cmdinfo_s g_acmd23 = {ACMD23, MMCSD_CMDRESP_R1, 0xff};
static const struct mmcsd_cmdinfo_s g_acmd23 =
{
ACMD23, MMCSD_CMDRESP_R1, 0xff
};
#endif
static const struct mmcsd_cmdinfo_s g_acmd41 = {ACMD41, MMCSD_CMDRESP_R1, 0xff};
static const struct mmcsd_cmdinfo_s g_acmd41 =
{
ACMD41, MMCSD_CMDRESP_R1, 0xff
};
/****************************************************************************
* Private Functions
@@ -416,11 +463,11 @@ static int mmcsd_waitready(FAR struct mmcsd_slot_s *slot)
elapsed = ELAPSED_TIME(start);
if (elapsed > MMCSD_DELAY_10MS)
{
/* Give other threads time to run */
{
/* Give other threads time to run */
nxsig_usleep(10000);
}
nxsig_usleep(10000);
}
}
while (elapsed < MMCSD_DELAY_500MS);
@@ -440,7 +487,8 @@ static int mmcsd_waitready(FAR struct mmcsd_slot_s *slot)
****************************************************************************/
static uint32_t mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot,
const struct mmcsd_cmdinfo_s *cmd, uint32_t arg)
FAR const struct mmcsd_cmdinfo_s *cmd,
uint32_t arg)
{
FAR struct spi_dev_s *spi = slot->spi;
uint32_t result;
@@ -624,7 +672,7 @@ static uint32_t mmcsd_nsac(FAR struct mmcsd_slot_s *slot, uint8_t *csd,
* the maximum value is 25.5K clock cycles.
*/
uint32_t nsac = MMCSD_CSD_NSAC(csd) * ((uint32_t)100*1000);
uint32_t nsac = MMCSD_CSD_NSAC(csd) * ((uint32_t)100 * 1000);
uint32_t fhkz = (frequency + 500) / 1000;
return (nsac + (fhkz >> 1)) / fhkz;
}
@@ -647,7 +695,8 @@ static uint32_t mmcsd_taac(FAR struct mmcsd_slot_s *slot, uint8_t *csd)
* taccess = TU*TV + NSAC/spifrequency
*
* g_taactu holds TU in units of nanoseconds and microseconds (you have to
* use the index to distinguish. g_taactv holds TV with 8-bits of fraction.
* use the index to distinguish. g_taactv holds TV with 8-bits of
* fraction.
*/
tundx = MMCSD_CSD_TAAC_TIMEUNIT(csd);
@@ -663,7 +712,8 @@ static uint32_t mmcsd_taac(FAR struct mmcsd_slot_s *slot, uint8_t *csd)
{
/* Return the answer in microseconds */
return (g_taactu[tundx]*g_taactv[MMCSD_CSD_TAAC_TIMEVALUE(csd)] + 0x80) >> 8;
return (g_taactu[tundx] * g_taactv[MMCSD_CSD_TAAC_TIMEVALUE(csd)] +
0x80) >> 8;
}
}
@@ -714,24 +764,31 @@ static void mmcsd_decodecsd(FAR struct mmcsd_slot_s *slot, uint8_t *csd)
*
* Example: TAAC = 1.5 ms, NSAC = 0, r2wfactor = 4, CLK_TCK=100
* taccessus = 1,500uS
* taccess = (1,500 * 100) / 100,000) + 1 = 2 (ideal, 1.5)
* twrite = (1,500 * 4 * 100) / 100,000) + 1 = 7 (ideal 6.0)
* taccess = (1,500 * 100) / 100,000) + 1 = 2
* (ideal, 1.5)
* twrite = (1,500 * 4 * 100) / 100,000) + 1 = 7
* (ideal 6.0)
*
* First get the access time in microseconds
*/
uint32_t taccessus = mmcsd_taac(slot, csd) + mmcsd_nsac(slot, csd, frequency);
uint32_t taccessus = mmcsd_taac(slot, csd) +
mmcsd_nsac(slot, csd, frequency);
/* Then convert to system clock ticks. The maximum read access is 10 times
* the tacc value: taccess = 10 * (taccessus / 1,000,000) * CLK_TCK, or
/* Then convert to system clock ticks. The maximum read access is 10
* times the tacc value:
*
* taccess = 10 * (taccessus / 1,000,000) * CLK_TCK
*/
slot->taccess = (taccessus * CLK_TCK) / 100000 + 1;
/* NOTE that we add one to taccess to assure that we wait at least this
* time. The write access time is larger by the R2WFACTOR: */
/* NOTE that we add one to taccess to assure that we wait at least
* this time. The write access time is larger by the R2WFACTOR:
*/
slot->taccess = (taccessus * MMCSD_CSD_R2WFACTOR(csd) * CLK_TCK) / 100000 + 1;
slot->taccess = (taccessus * MMCSD_CSD_R2WFACTOR(csd) * CLK_TCK) /
100000 + 1;
}
else
{
@@ -769,6 +826,7 @@ static void mmcsd_decodecsd(FAR struct mmcsd_slot_s *slot, uint8_t *csd)
if (MMCSD_CSD_CSDSTRUCT(csd) != 0)
{
/* SDC structure ver 2.xx */
/* Note: On SD card WRITE_BL_LEN is always the same as READ_BL_LEN */
readbllen = SD20_CSD_READBLLEN(csd);
@@ -778,6 +836,7 @@ static void mmcsd_decodecsd(FAR struct mmcsd_slot_s *slot, uint8_t *csd)
else
{
/* MMC or SD structure ver 1.xx */
/* Note: On SD card WRITE_BL_LEN is always the same as READ_BL_LEN */
readbllen = MMCSD_CSD_READBLLEN(csd);
@@ -930,7 +989,8 @@ static int mmcsd_recvblock(FAR struct mmcsd_slot_s *slot, uint8_t *buffer,
/* Wait up to the maximum to receive a valid data token. taccess is the
* time from when the command is sent until the first byte of data is
* received */
* received.
*/
start = START_TIME;
do
@@ -1218,8 +1278,8 @@ static ssize_t mmcsd_read(FAR struct inode *inode, unsigned char *buffer,
goto errout_with_eio;
}
buffer += SECTORSIZE(slot);
}
buffer += SECTORSIZE(slot);
}
/* Send CMD12: Stops transmission */
@@ -1251,8 +1311,9 @@ errout_with_eio:
****************************************************************************/
#if !defined(CONFIG_MMCSD_READONLY)
static ssize_t mmcsd_write(FAR struct inode *inode, const unsigned char *buffer,
size_t start_sector, unsigned int nsectors)
static ssize_t mmcsd_write(FAR struct inode *inode,
FAR const unsigned char *buffer,
size_t start_sector, unsigned int nsectors)
{
FAR struct mmcsd_slot_s *slot;
FAR struct spi_dev_s *spi;
@@ -1376,7 +1437,7 @@ static ssize_t mmcsd_write(FAR struct inode *inode, const unsigned char *buffer,
ferr("ERROR: ACMD23 failed: R1=%02x\n", response);
goto errout_with_sem;
}
}
}
/* Send CMD25: Continuously write blocks of data until the
* transmission is stopped.
@@ -1398,6 +1459,7 @@ static ssize_t mmcsd_write(FAR struct inode *inode, const unsigned char *buffer,
ferr("ERROR: Failed: to receive the block\n");
goto errout_with_sem;
}
buffer += SECTORSIZE(slot);
if (mmcsd_waitready(slot) != OK)
@@ -1493,7 +1555,8 @@ static int mmcsd_geometry(FAR struct inode *inode, struct geometry *geometry)
/* Then return the card geometry */
geometry->geo_available =
((slot->state & (MMCSD_SLOTSTATUS_NOTREADY | MMCSD_SLOTSTATUS_NODISK)) == 0);
((slot->state & (MMCSD_SLOTSTATUS_NOTREADY |
MMCSD_SLOTSTATUS_NODISK)) == 0);
geometry->geo_mediachanged =
((slot->state & MMCSD_SLOTSTATUS_MEDIACHGD) != 0);
#if !defined(CONFIG_MMCSD_READONLY)
@@ -1521,10 +1584,6 @@ static int mmcsd_geometry(FAR struct inode *inode, struct geometry *geometry)
return OK;
}
/****************************************************************************
* Initialization
****************************************************************************/
/****************************************************************************
* Name: mmcsd_mediainitialize
*
@@ -1551,10 +1610,10 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot)
slot->state |= MMCSD_SLOTSTATUS_NOTREADY;
/* Check if there is a card present in the slot. This is normally a matter is
* of GPIO sensing and does not really involve SPI, but by putting this
* functionality in the SPI interface, we encapsulate the SPI MMC/SD
* interface
/* Check if there is a card present in the slot. This is normally a
* matter is of GPIO sensing and does not really involve SPI, but by
* putting this functionality in the SPI interface, we encapsulate the
* SPI MMC/SD interface
*/
if ((SPI_STATUS(spi, SPIDEV_MMCSD(0)) & SPI_STATUS_PRESENT) == 0)
@@ -1632,7 +1691,8 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot)
{
/* Verify the operating voltage and that the 0xaa was correctly echoed */
if (((slot->r7 & MMCSD_SPIR7_VOLTAGE_MASK) == MMCSD_SPIR7_VOLTAGE_27) &&
if (((slot->r7 & MMCSD_SPIR7_VOLTAGE_MASK) ==
MMCSD_SPIR7_VOLTAGE_27) &&
((slot->r7 & MMCSD_SPIR7_ECHO_MASK) == 0xaa))
{
/* Try CMD55/ACMD41 for up to 1 second or until the card exits
@@ -1645,7 +1705,8 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot)
{
finfo("%d. Send CMD55/ACMD41\n", elapsed);
result = mmcsd_sendcmd(slot, &g_cmd55, 0);
if (result == MMCSD_SPIR1_IDLESTATE || result == MMCSD_SPIR1_OK)
if (result == MMCSD_SPIR1_IDLESTATE ||
result == MMCSD_SPIR1_OK)
{
result = mmcsd_sendcmd(slot, &g_acmd41, (uint32_t)1 << 30);
if (result == MMCSD_SPIR1_OK)
@@ -1661,26 +1722,27 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot)
/* Check if ACMD41 was sent successfully */
if (elapsed < MMCSD_DELAY_1SEC)
{
finfo("Send CMD58\n");
{
finfo("Send CMD58\n");
SPI_SEND(spi, 0xff);
result = mmcsd_sendcmd(slot, &g_cmd58, 0);
if (result == MMCSD_SPIR1_OK)
{
SPI_SEND(spi, 0xff);
result = mmcsd_sendcmd(slot, &g_cmd58, 0);
if (result == MMCSD_SPIR1_OK)
{
finfo("OCR: %08x\n", slot->ocr);
if ((slot->ocr & MMCSD_OCR_CCS) != 0)
{
finfo("Identified SD ver2 card/with block access\n");
slot->type = MMCSD_CARDTYPE_SDV2 | MMCSD_CARDTYPE_BLOCK;
slot->type = MMCSD_CARDTYPE_SDV2 |
MMCSD_CARDTYPE_BLOCK;
}
else
{
finfo("Identified SD ver2 card\n");
slot->type = MMCSD_CARDTYPE_SDV2;
}
}
}
}
}
}
}
@@ -1714,7 +1776,8 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot)
{
finfo("%d. Send CMD55/ACMD41\n", elapsed);
result = mmcsd_sendcmd(slot, &g_cmd55, 0);
if (result == MMCSD_SPIR1_IDLESTATE || result == MMCSD_SPIR1_OK)
if (result == MMCSD_SPIR1_IDLESTATE ||
result == MMCSD_SPIR1_OK)
{
result = mmcsd_sendcmd(slot, &g_acmd41, 0);
if (result == MMCSD_SPIR1_OK)
@@ -1733,7 +1796,7 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot)
slot->type = MMCSD_CARDTYPE_MMC;
break;
}
}
}
elapsed = ELAPSED_TIME(start);
}
@@ -1785,13 +1848,13 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot)
*/
#ifdef CONFIG_MMCSD_SECTOR512
/* Using 512 byte sectors, the maximum ver1.x capacity is 4096 x 512 blocks.
* The saved slot->nsectors is converted to 512 byte blocks, so if slot->nsectors
* exceeds 4096 x 512, then we must be dealing with a card with read_bl_len
* of 1024 or 2048.
/* Using 512 byte sectors, the maximum ver1.x capacity is 4096 x 512
* blocks. The saved slot->nsectors is converted to 512 byte blocks, so
* if slot->nsectors exceeds 4096 x 512, then we must be dealing with a
* card with read_bl_len of 1024 or 2048.
*/
if (!IS_SDV2(slot->type) && slot->nsectors <= ((uint32_t)4096*12))
if (!IS_SDV2(slot->type) && slot->nsectors <= ((uint32_t)4096 * 12))
{
/* Don't set the block len on high capacity cards (ver1.x or ver2.x) */
@@ -1865,7 +1928,8 @@ static void mmcsd_mediachanged(void *arg)
* ready, then try re-initializing it
*/
else if ((oldstate & (MMCSD_SLOTSTATUS_NODISK | MMCSD_SLOTSTATUS_NOTREADY)) != 0)
else if ((oldstate & (MMCSD_SLOTSTATUS_NODISK |
MMCSD_SLOTSTATUS_NOTREADY)) != 0)
{
/* (Re-)initialize for the media in the slot */
@@ -1909,7 +1973,8 @@ int mmcsd_spislotinitialize(int minor, int slotno, FAR struct spi_dev_s *spi)
int ret;
#ifdef CONFIG_DEBUG_FEATURES
if ((unsigned)slotno >= CONFIG_MMCSD_NSLOTS || (unsigned)minor > 255 || !spi)
if ((unsigned)slotno >= CONFIG_MMCSD_NSLOTS || (unsigned)minor > 255 ||
spi == NULL)
{
ferr("ERROR: Invalid arguments\n");
return -EINVAL;
+9 -7
View File
@@ -56,6 +56,7 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifndef CONFIG_FILEMTD_BLOCKSIZE
@@ -383,9 +384,9 @@ static ssize_t filemtd_byteread(FAR struct mtd_dev_s *dev, off_t offset,
/* Don't let read read past end of buffer */
if (offset + nbytes > priv->nblocks * priv->erasesize)
{
return 0;
}
{
return 0;
}
filemtd_read(priv, buf, offset, nbytes);
return nbytes;
@@ -438,8 +439,8 @@ static int filemtd_ioctl(FAR struct mtd_dev_s *dev, int cmd,
if (geo)
{
/* Populate the geometry structure with information need to know
* the capacity and how to access the device.
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*/
geo->blocksize = priv->blocksize;
@@ -486,8 +487,9 @@ static int filemtd_ioctl(FAR struct mtd_dev_s *dev, int cmd,
*
****************************************************************************/
FAR struct mtd_dev_s *blockmtd_initialize(FAR const char *path, size_t offset,
size_t mtdlen, int16_t sectsize,
FAR struct mtd_dev_s *blockmtd_initialize(FAR const char *path,
size_t offset, size_t mtdlen,
int16_t sectsize,
int32_t erasesize)
{
FAR struct file_dev_s *priv;
+319 -207
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -414,7 +414,8 @@ int ramdisk_register(int minor, FAR uint8_t *buffer, uint32_t nsectors,
char devname[16];
int ret = -ENOMEM;
finfo("buffer: %p nsectors: %d sectsize: %d\n", buffer, nsectors, sectsize);
finfo("buffer: %p nsectors: %d sectsize: %d\n",
buffer, nsectors, sectsize);
/* Sanity check */
File diff suppressed because it is too large Load Diff
+16 -11
View File
@@ -68,13 +68,15 @@ struct part_struct_s
static int part_open(FAR struct inode *inode);
static int part_close(FAR struct inode *inode);
static ssize_t part_read(FAR struct inode *inode, unsigned char *buffer,
size_t start_sector, unsigned int nsectors);
static ssize_t part_write(FAR struct inode *inode, const unsigned char *buffer,
size_t start_sector, unsigned int nsectors);
static int part_geometry(FAR struct inode *inode, struct geometry *geometry);
static int part_ioctl(FAR struct inode *inode, int cmd, unsigned long arg);
static ssize_t part_read(FAR struct inode *inode, FAR unsigned char *buffer,
size_t start_sector, unsigned int nsectors);
static ssize_t part_write(FAR struct inode *inode,
FAR const unsigned char *buffer, size_t start_sector,
unsigned int nsectors);
static int part_geometry(FAR struct inode *inode,
FAR struct geometry *geometry);
static int part_ioctl(FAR struct inode *inode, int cmd,
unsigned long arg);
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int part_unlink(FAR struct inode *inode);
#endif
@@ -174,8 +176,9 @@ static ssize_t part_read(FAR struct inode *inode, unsigned char *buffer,
*
****************************************************************************/
static ssize_t part_write(FAR struct inode *inode, const unsigned char *buffer,
size_t start_sector, unsigned int nsectors)
static ssize_t part_write(FAR struct inode *inode,
FAR const unsigned char *buffer,
size_t start_sector, unsigned int nsectors)
{
FAR struct part_struct_s *dev = inode->i_private;
FAR struct inode *parent = dev->parent;
@@ -245,12 +248,14 @@ static int part_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
ret = parent->u.i_bops->geometry(parent, &geo);
if (ret >= 0)
{
*(FAR uint8_t *)base += dev->firstsector * geo.geo_sectorsize;
*(FAR uint8_t *)base +=
dev->firstsector * geo.geo_sectorsize;
}
}
else if (cmd == MTDIOC_GEOMETRY)
{
FAR struct mtd_geometry_s *mgeo = (FAR struct mtd_geometry_s *)arg;
FAR struct mtd_geometry_s *mgeo =
(FAR struct mtd_geometry_s *)arg;
uint32_t blkper = mgeo->erasesize / mgeo->blocksize;
mgeo->neraseblocks = dev->nsectors / blkper;
+2 -2
View File
@@ -488,8 +488,8 @@ int rename(FAR const char *oldpath, FAR const char *newpath)
FAR struct inode *oldinode;
int ret;
/* Ignore paths that are interpreted as the root directory which has no name
* and cannot be moved
/* Ignore paths that are interpreted as the root directory which has no
* name and cannot be moved
*/
if (!oldpath || *oldpath == '\0' || oldpath[0] != '/' ||
+3 -3
View File
@@ -138,9 +138,9 @@ int rmdir(FAR const char *pathname)
}
/* Remove the inode. NOTE: Because we hold a reference count on the
* inode, it will not be deleted now. But probably when inode_release()
* is called below. inode_remove should return -EBUSY to indicate that
* the inode was not deleted now.
* inode, it will not be deleted now. But probably when
* inode_release() is called below. inode_remove should return
* -EBUSY to indicate that the inode was not deleted now.
*/
inode_semtake();
+12 -27
View File
@@ -1,35 +1,20 @@
/****************************************************************************
* include/nuttx/drivers/ramdisk.h
*
* Copyright (C) 2008-2009, 2012-2013, 2015-2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* http://www.apache.org/licenses/LICENSE-2.0
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* 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.
*
****************************************************************************/
+7 -7
View File
@@ -157,14 +157,14 @@ static void get_base62(FAR uint8_t *ptr)
static void copy_base62(FAR const uint8_t *src, FAR char *dest, int len)
{
if (len < MAX_XS)
{
src += MAX_XS - len;
}
{
src += MAX_XS - len;
}
for (; len > 0; len--)
{
*dest++ = base62_to_char(*src++);
}
for (; len > 0; len--)
{
*dest++ = base62_to_char(*src++);
}
}
/****************************************************************************