diff --git a/arch/arm/src/lc823450/lc823450_i2s.c b/arch/arm/src/lc823450/lc823450_i2s.c index 9776d0ff665..20f3ba2204d 100644 --- a/arch/arm/src/lc823450/lc823450_i2s.c +++ b/arch/arm/src/lc823450/lc823450_i2s.c @@ -1017,7 +1017,7 @@ FAR struct i2s_dev_s *lc823450_i2sdev_initialize(void) * chip select structures. */ - priv = (struct lc823450_i2s_s *)zalloc(sizeof(struct lc823450_i2s_s)); + priv = (struct lc823450_i2s_s *)kmm_zalloc(sizeof(struct lc823450_i2s_s)); if (!priv) { i2serr("ERROR: Failed to allocate a chip select structure\n"); diff --git a/arch/arm/src/sam34/sam_spi.c b/arch/arm/src/sam34/sam_spi.c index 88a18b2b5ad..54852b209c9 100644 --- a/arch/arm/src/sam34/sam_spi.c +++ b/arch/arm/src/sam34/sam_spi.c @@ -54,6 +54,7 @@ #include #include +#include #include #include #include @@ -1745,7 +1746,7 @@ struct spi_dev_s *sam_spibus_initialize(int port) * chip select structures. */ - spics = (struct sam_spics_s *)zalloc(sizeof(struct sam_spics_s)); + spics = (struct sam_spics_s *)kmm_zalloc(sizeof(struct sam_spics_s)); if (!spics) { spierr("ERROR: Failed to allocate a chip select structure\n"); @@ -1753,7 +1754,7 @@ struct spi_dev_s *sam_spibus_initialize(int port) } /* Set up the initial state for this chip select structure. Other fields - * were zeroed by zalloc(). + * were zeroed by kmm_zalloc(). */ #ifdef CONFIG_SAM34_SPI_DMA diff --git a/arch/arm/src/sama5/sam_spi.c b/arch/arm/src/sama5/sam_spi.c index 1d88a0239f9..c16ec80cdf7 100644 --- a/arch/arm/src/sama5/sam_spi.c +++ b/arch/arm/src/sama5/sam_spi.c @@ -57,6 +57,7 @@ #include #include +#include #include #include #include @@ -1674,7 +1675,7 @@ struct spi_dev_s *sam_spibus_initialize(int port) * chip select structures. */ - spics = (struct sam_spics_s *)zalloc(sizeof(struct sam_spics_s)); + spics = (struct sam_spics_s *)kmm_zalloc(sizeof(struct sam_spics_s)); if (!spics) { spierr("ERROR: Failed to allocate a chip select structure\n"); @@ -1682,7 +1683,7 @@ struct spi_dev_s *sam_spibus_initialize(int port) } /* Set up the initial state for this chip select structure. Other fields - * were zeroed by zalloc(). + * were zeroed by kmm_zalloc(). */ #ifdef CONFIG_SAMA5_SPI_DMA diff --git a/arch/arm/src/sama5/sam_ssc.c b/arch/arm/src/sama5/sam_ssc.c index f16e1822f54..cd3ef0adc5e 100644 --- a/arch/arm/src/sama5/sam_ssc.c +++ b/arch/arm/src/sama5/sam_ssc.c @@ -3424,7 +3424,7 @@ struct i2s_dev_s *sam_ssc_initialize(int port) * chip select structures. */ - priv = (struct sam_ssc_s *)zalloc(sizeof(struct sam_ssc_s)); + priv = (struct sam_ssc_s *)kmm_zalloc(sizeof(struct sam_ssc_s)); if (!priv) { i2serr("ERROR: Failed to allocate a chip select structure\n"); @@ -3432,7 +3432,7 @@ struct i2s_dev_s *sam_ssc_initialize(int port) } /* Set up the initial state for this chip select structure. Other fields - * were zeroed by zalloc(). + * were zeroed by kmm_zalloc(). */ /* Initialize the common parts for the SSC device structure */ diff --git a/arch/arm/src/samv7/sam_spi.c b/arch/arm/src/samv7/sam_spi.c index 8ec500445e4..eb1effcd166 100644 --- a/arch/arm/src/samv7/sam_spi.c +++ b/arch/arm/src/samv7/sam_spi.c @@ -53,6 +53,7 @@ #include #include +#include #include #include #include @@ -2020,7 +2021,7 @@ FAR struct spi_dev_s *sam_spibus_initialize(int port) * chip select structures. */ - spics = (struct sam_spics_s *)zalloc(sizeof(struct sam_spics_s)); + spics = (struct sam_spics_s *)kmm_zalloc(sizeof(struct sam_spics_s)); if (!spics) { spierr("ERROR: Failed to allocate a chip select structure\n"); @@ -2028,7 +2029,7 @@ FAR struct spi_dev_s *sam_spibus_initialize(int port) } /* Set up the initial state for this chip select structure. Other fields - * were zeroed by zalloc(). + * were zeroed by kmm_zalloc(). */ #ifdef CONFIG_SAMV7_SPI_DMA diff --git a/arch/arm/src/samv7/sam_ssc.c b/arch/arm/src/samv7/sam_ssc.c index caa15e11ef0..bea20276291 100644 --- a/arch/arm/src/samv7/sam_ssc.c +++ b/arch/arm/src/samv7/sam_ssc.c @@ -3407,7 +3407,7 @@ struct i2s_dev_s *sam_ssc_initialize(int port) * chip select structures. */ - priv = (struct sam_ssc_s *)zalloc(sizeof(struct sam_ssc_s)); + priv = (struct sam_ssc_s *)kmm_zalloc(sizeof(struct sam_ssc_s)); if (!priv) { i2serr("ERROR: Failed to allocate a chip select structure\n"); diff --git a/arch/arm/src/stm32/stm32_i2s.c b/arch/arm/src/stm32/stm32_i2s.c index 4762abd25bf..e2dea335a89 100644 --- a/arch/arm/src/stm32/stm32_i2s.c +++ b/arch/arm/src/stm32/stm32_i2s.c @@ -72,17 +72,15 @@ #include #include -#include - -#include - -#include #include #include #include +#include #include #include +#include + #include "arm_internal.h" #include "arm_arch.h" @@ -2632,7 +2630,7 @@ FAR struct i2s_dev_s *stm32_i2sbus_initialize(int port) * chip select structures. */ - priv = (struct stm32_i2s_s *)zalloc(sizeof(struct stm32_i2s_s)); + priv = (struct stm32_i2s_s *)kmm_zalloc(sizeof(struct stm32_i2s_s)); if (!priv) { i2serr("ERROR: Failed to allocate a chip select structure\n"); @@ -2640,7 +2638,7 @@ FAR struct i2s_dev_s *stm32_i2sbus_initialize(int port) } /* Set up the initial state for this chip select structure. Other fields - * were zeroed by zalloc(). + * were zeroed by kmm_zalloc(). */ /* Initialize the common parts for the I2S device structure */ diff --git a/boards/arm/cxd56xx/common/src/cxd56_crashdump.c b/boards/arm/cxd56xx/common/src/cxd56_crashdump.c index 8aba8a6e3e7..f23ccad6761 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_crashdump.c +++ b/boards/arm/cxd56xx/common/src/cxd56_crashdump.c @@ -47,6 +47,8 @@ #include #include +#include + #include #include #include "cxd56_wdt.h" @@ -125,7 +127,7 @@ void board_crashdump(uintptr_t currentsp, FAR void *tcb, #ifdef CONFIG_CXD56_BACKUPLOG pdump = up_backuplog_alloc("crash", sizeof(fullcontext_t)); #else - pdump = malloc(sizeof(fullcontext_t)); + pdump = kmm_malloc(sizeof(fullcontext_t)); #endif if (!pdump) { diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c index 263e3c87b64..50bc978aa30 100644 --- a/drivers/spi/spi_bitbang.c +++ b/drivers/spi/spi_bitbang.c @@ -1,35 +1,20 @@ /**************************************************************************** * drivers/spi/spi_bitbang.c * - * Copyright (C) 2013, 2016-2017 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * 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. * ****************************************************************************/ @@ -44,6 +29,7 @@ #include #include +#include #include #include @@ -537,7 +523,8 @@ FAR struct spi_dev_s *spi_create_bitbang(FAR const struct /* Allocate an instance of the SPI bit bang structure */ - priv = (FAR struct spi_bitbang_s *)zalloc(sizeof(struct spi_bitbang_s)); + priv = (FAR struct spi_bitbang_s *) + kmm_zalloc(sizeof(struct spi_bitbang_s)); if (!priv) { spierr("ERROR: Failed to allocate the device structure\n"); diff --git a/drivers/usbhost/usbhost_composite.c b/drivers/usbhost/usbhost_composite.c index 2f6e96a03a7..3111dfc0211 100644 --- a/drivers/usbhost/usbhost_composite.c +++ b/drivers/usbhost/usbhost_composite.c @@ -1,35 +1,20 @@ /**************************************************************************** * drivers/usbhost/usbhost_composite.c * - * Copyright (C) 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * 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. * ****************************************************************************/ @@ -196,11 +181,11 @@ static void usbhost_disconnect_all(FAR struct usbhost_composite_s *priv) * desclen - The length in bytes of the configuration descriptor. * * Returned Value: - * On success, zero (OK) is returned. On a failure, a negated errno value is - * returned indicating the nature of the failure + * On success, zero (OK) is returned. On a failure, a negated errno value + * is returned indicating the nature of the failure * - * NOTE that the class instance remains valid upon return with a failure. It is - * the responsibility of the higher level enumeration logic to call + * NOTE that the class instance remains valid upon return with a failure. + * It is the responsibility of the higher level enumeration logic to call * CLASS_DISCONNECTED to free up the class driver resources. * * Assumptions: @@ -240,7 +225,8 @@ static int usbhost_connect(FAR struct usbhost_class_s *usbclass, static int usbhost_disconnected(struct usbhost_class_s *usbclass) { - FAR struct usbhost_composite_s *priv = (FAR struct usbhost_composite_s *)usbclass; + FAR struct usbhost_composite_s *priv = + (FAR struct usbhost_composite_s *)usbclass; DEBUGASSERT(priv != NULL); @@ -287,7 +273,8 @@ static int usbhost_disconnected(struct usbhost_class_s *usbclass) ****************************************************************************/ static int usbhost_copyinterface(uint8_t ifno, FAR const uint8_t *configdesc, - int desclen, FAR uint8_t *buffer, int buflen) + int desclen, FAR uint8_t *buffer, + int buflen) { FAR struct usb_desc_s *desc; FAR struct usb_ifdesc_s *ifdesc; @@ -383,20 +370,25 @@ static int usbhost_copyinterface(uint8_t ifno, FAR const uint8_t *configdesc, buflen -= len; retsize += len; - /* And reduce the number of endpoints we are looking for */ + /* And reduce the number of endpoints we are looking + * for. + */ if (--neps <= 0) { - /* That is all of them! Return the total size copied */ + /* That is all of them! Return the total size + * copied. + */ return retsize; } } - /* The endpoint descriptors following the interface descriptor - * should all be contiguous. But we will complain only if another - * interface descriptor is encountered before all of the endpoint - * descriptors have been found. + /* The endpoint descriptors following the interface + * descriptor should all be contiguous. But we will + * complain only if another interface descriptor is + * encountered before all of the endpoint descriptors have + * been found. */ else if (desc->type == USB_DESC_TYPE_INTERFACE) @@ -571,10 +563,10 @@ int usbhost_composite(FAR struct usbhost_hubport_s *hport, * bDeviceProtocol 0x01 */ - if (id->base != USB_CLASS_PER_INTERFACE && id->base != USB_CLASS_MISC) - { - return -ENOENT; - } + if (id->base != USB_CLASS_PER_INTERFACE && id->base != USB_CLASS_MISC) + { + return -ENOENT; + } /* First, count the number of interface descriptors (nintfs) and the * number of interfaces that are associated to one device via IAD @@ -612,9 +604,10 @@ int usbhost_composite(FAR struct usbhost_hubport_s *hport, * class driver. */ - else if (desc->type == USB_DESC_TYPE_INTERFACEASSOCIATION) - { - FAR struct usb_iaddesc_s *iad = (FAR struct usb_iaddesc_s *)desc; + else if (desc->type == USB_DESC_TYPE_INTERFACEASSOCIATION) + { + FAR struct usb_iaddesc_s *iad = + (FAR struct usb_iaddesc_s *)desc; uint32_t mask; /* Keep count of the number of interfaces that will be merged */ @@ -626,7 +619,7 @@ int usbhost_composite(FAR struct usbhost_hubport_s *hport, DEBUGASSERT(iad->firstif + iad->nifs < 32); mask = (1 << iad->nifs) - 1; mergeset |= mask << iad->firstif; - } + } } offset += len; @@ -721,7 +714,8 @@ int usbhost_composite(FAR struct usbhost_hubport_s *hport, * lookup information from the interface descriptor. */ - member = (FAR struct usbhost_member_s *)&priv->members[i]; + member = (FAR struct usbhost_member_s *) + &priv->members[i]; member->id.base = ifdesc->classid; member->id.subclass = ifdesc->subclass; member->id.proto = ifdesc->protocol; @@ -744,11 +738,13 @@ int usbhost_composite(FAR struct usbhost_hubport_s *hport, else if (desc->type == USB_DESC_TYPE_INTERFACEASSOCIATION) { - FAR struct usb_iaddesc_s *iad = (FAR struct usb_iaddesc_s *)desc; + FAR struct usb_iaddesc_s *iad = + (FAR struct usb_iaddesc_s *)desc; /* Yes.. Save the registry lookup information from the IAD. */ - member = (FAR struct usbhost_member_s *)&priv->members[i]; + member = (FAR struct usbhost_member_s *) + &priv->members[i]; member->id.base = iad->classid; member->id.subclass = iad->subclass; member->id.proto = iad->protocol; @@ -777,7 +773,7 @@ int usbhost_composite(FAR struct usbhost_hubport_s *hport, * configuration descriptor for each member class. */ - cfgbuffer = (FAR uint8_t *)malloc(CUSTOM_CONFIG_BUFSIZE); + cfgbuffer = (FAR uint8_t *)kmm_malloc(CUSTOM_CONFIG_BUFSIZE); if (cfgbuffer == NULL) { uerr("ERROR: Failed to allocate configuration buffer"); @@ -877,6 +873,7 @@ errout_with_members: } errout_with_container: + /* Then free the composite container itself */ kmm_free(priv);