docstring
stringlengths
22
576
signature
stringlengths
9
317
prompt
stringlengths
57
886
code
stringlengths
20
1.36k
repository
stringclasses
49 values
language
stringclasses
2 values
license
stringclasses
9 values
stars
int64
15
21.3k
/* DMA2D MSP Initialization This function configures the hardware resources used in this example: */
void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef *hdma2d)
/* DMA2D MSP Initialization This function configures the hardware resources used in this example: */ void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef *hdma2d)
{ __HAL_RCC_DMA2D_CLK_ENABLE(); HAL_NVIC_SetPriority(DMA2D_IRQn, 0, 0); HAL_NVIC_EnableIRQ(DMA2D_IRQn); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
UINT8* EFIAPI MmioReadBuffer8(IN UINTN StartAddress, IN UINTN Length, OUT UINT8 *Buffer)
/* If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */ UINT8* EFIAPI MmioReadBuffer8(IN UINTN StartAddress, IN UINTN Length, OUT UINT8 *Buffer)
{ UINT8 *ReturnBuffer; ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); ReturnBuffer = Buffer; while (Length-- != 0) { *(Buffer++) = MmioRead8 (StartAddress++); } return ReturnBuffer; }
tianocore/edk2
C++
Other
4,240
/* Marks an end time, so calls to g_timer_elapsed() will return the difference between this end time and the start time. */
void g_timer_stop(GTimer *timer)
/* Marks an end time, so calls to g_timer_elapsed() will return the difference between this end time and the start time. */ void g_timer_stop(GTimer *timer)
{ g_return_if_fail (timer != NULL); timer->active = FALSE; timer->end = g_get_monotonic_time (); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function will do USB_REQ_GET_DESCRIPTO' bRequest for the usb device instance, */
rt_err_t rt_usbh_get_descriptor(uinst_t device, rt_uint8_t type, void *buffer, int nbytes)
/* This function will do USB_REQ_GET_DESCRIPTO' bRequest for the usb device instance, */ rt_err_t rt_usbh_get_descriptor(uinst_t device, rt_uint8_t type, void *buffer, int nbytes)
{ struct urequest setup; int timeout = USB_TIMEOUT_BASIC; RT_ASSERT(device != RT_NULL); setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_DEVICE; setup.bRequest = USB_REQ_GET_DESCRIPTOR; setup.wIndex = 0; setup.wLength = nbytes; setup.wValue = type << 8; if(rt_usb_hcd_setup_xfer(device->hcd, device->pipe_ep0_out, &setup, timeout) == 8) { if(rt_usb_hcd_pipe_xfer(device->hcd, device->pipe_ep0_in, buffer, nbytes, timeout) == nbytes) { if(rt_usb_hcd_pipe_xfer(device->hcd, device->pipe_ep0_out, RT_NULL, 0, timeout) == 0) { return RT_EOK; } } } return RT_ERROR; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Returns: 1 if alloc required, 0 if not, -ve on error */
int gfs2_diradd_alloc_required(struct inode *inode, const struct qstr *name)
/* Returns: 1 if alloc required, 0 if not, -ve on error */ int gfs2_diradd_alloc_required(struct inode *inode, const struct qstr *name)
{ struct gfs2_dirent *dent; struct buffer_head *bh; dent = gfs2_dirent_search(inode, name, gfs2_dirent_find_space, &bh); if (!dent) { return 1; } if (IS_ERR(dent)) return PTR_ERR(dent); brelse(bh); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This subroutine sets the compass raw data for the soft iron transformation. */
void inv_set_compass_soft_iron_input_data(const long *data)
/* This subroutine sets the compass raw data for the soft iron transformation. */ void inv_set_compass_soft_iron_input_data(const long *data)
{ sensors.soft_iron.raw[i] = data[i]; } if (sensors.soft_iron.enable == 1) { mlMatrixVectorMult(sensors.soft_iron.matrix_d, data, sensors.soft_iron.trans); } else { for (i=0; i<3; i++) { sensors.soft_iron.trans[i] = data[i]; } } }
Luos-io/luos_engine
C++
MIT License
496
/* We could modify them to use the GLib Unicode routines or the International Components for Unicode library but it's not apparent that we could do so without consuming a lot more CPU and memory or that searching would be significantly better. */
gboolean cf_find_packet_data(capture_file *cf, const guint8 *string, size_t string_size, search_direction dir)
/* We could modify them to use the GLib Unicode routines or the International Components for Unicode library but it's not apparent that we could do so without consuming a lot more CPU and memory or that searching would be significantly better. */ gboolean cf_find_packet_data(capture_file *cf, const guint8 *string, size_t string_size, search_direction dir)
{ cbs_t info; info.data = string; info.data_len = string_size; if (cf->regex) { return find_packet(cf, match_regex, NULL, dir); } else if (cf->string) { switch (cf->scs_type) { case SCS_NARROW_AND_WIDE: return find_packet(cf, match_narrow_and_wide, &info, dir); case SCS_NARROW: return find_packet(cf, match_narrow, &info, dir); case SCS_WIDE: return find_packet(cf, match_wide, &info, dir); default: g_assert_not_reached(); return FALSE; } } else return find_packet(cf, match_binary, &info, dir); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Get Allocate summary information structure by caller address. */
MEMORY_PROFILE_ALLOC_SUMMARY_INFO_DATA* GetAllocSummaryInfoByCallerAddress(IN PHYSICAL_ADDRESS CallerAddress, IN MEMORY_PROFILE_DRIVER_SUMMARY_INFO_DATA *DriverSummaryInfoData)
/* Get Allocate summary information structure by caller address. */ MEMORY_PROFILE_ALLOC_SUMMARY_INFO_DATA* GetAllocSummaryInfoByCallerAddress(IN PHYSICAL_ADDRESS CallerAddress, IN MEMORY_PROFILE_DRIVER_SUMMARY_INFO_DATA *DriverSummaryInfoData)
{ LIST_ENTRY *AllocSummaryInfoList; LIST_ENTRY *AllocSummaryLink; MEMORY_PROFILE_ALLOC_SUMMARY_INFO *AllocSummaryInfo; MEMORY_PROFILE_ALLOC_SUMMARY_INFO_DATA *AllocSummaryInfoData; AllocSummaryInfoList = DriverSummaryInfoData->AllocSummaryInfoList; for (AllocSummaryLink = AllocSummaryInfoList->ForwardLink; AllocSummaryLink != AllocSummaryInfoList; AllocSummaryLink = AllocSummaryLink->ForwardLink) { AllocSummaryInfoData = CR ( AllocSummaryLink, MEMORY_PROFILE_ALLOC_SUMMARY_INFO_DATA, Link, MEMORY_PROFILE_ALLOC_SUMMARY_INFO_SIGNATURE ); AllocSummaryInfo = &AllocSummaryInfoData->AllocSummaryInfo; if (AllocSummaryInfo->CallerAddress == CallerAddress) { return AllocSummaryInfoData; } } return NULL; }
tianocore/edk2
C++
Other
4,240
/* It gets the address/port the system picked for this socket (on connected sockets). On unconnected client sockets it does not work because the system dynamically chooses a port only when the socket calls a send() call. */
int sock_getmyinfo(SOCKET sock, char *address, int addrlen, char *port, int portlen, int flags, char *errbuf, int errbuflen)
/* It gets the address/port the system picked for this socket (on connected sockets). On unconnected client sockets it does not work because the system dynamically chooses a port only when the socket calls a send() call. */ int sock_getmyinfo(SOCKET sock, char *address, int addrlen, char *port, int portlen, int flags, char *errbuf, int errbuflen)
{ struct sockaddr_storage mysockaddr; socklen_t sockaddrlen; sockaddrlen = sizeof(struct sockaddr_storage); if (getsockname(sock, (struct sockaddr *) &mysockaddr, &sockaddrlen) == -1) { sock_geterror("getsockname()", errbuf, errbuflen); return 0; } return sock_getascii_addrport(&mysockaddr, address, addrlen, port, portlen, flags, errbuf, errbuflen); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Search for an appropriate visual. Promote where necessary. Check to make sure that ENOUGH colormap entries are writeable. basePixel was determined when XAllocColorCells() contiguously allocated enough entries. basePixel is used below in GetTIFFImage. */
Boolean SearchVisualList(int image_depth, int visual_class, Visual **visual)
/* Search for an appropriate visual. Promote where necessary. Check to make sure that ENOUGH colormap entries are writeable. basePixel was determined when XAllocColorCells() contiguously allocated enough entries. basePixel is used below in GetTIFFImage. */ Boolean SearchVisualList(int image_depth, int visual_class, Visual **visual)
{ XVisualInfo template_visual, *visual_list, *vl; int i, n_visuals; template_visual.screen = xScreen; vl = visual_list = XGetVisualInfo(xDisplay, VisualScreenMask, &template_visual, &n_visuals); if (n_visuals == 0) { fprintf(stderr, "xtiff: visual list not available\n"); exit(0); } for (i = 0; i < n_visuals; vl++, i++) { if ((vl->class == visual_class) && (vl->depth >= image_depth) && (vl->visual->map_entries >= (1 << vl->depth))) { *visual = vl->visual; xImageDepth = vl->depth; xRedMask = vl->red_mask; xGreenMask = vl->green_mask; xBlueMask = vl->blue_mask; XFree((char *) visual_list); return True; } } XFree((char *) visual_list); return False; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Selects the USART WakeUp method from mute mode. */
void USART_MuteModeWakeUpConfig(USART_TypeDef *USARTx, uint32_t USART_WakeUp)
/* Selects the USART WakeUp method from mute mode. */ void USART_MuteModeWakeUpConfig(USART_TypeDef *USARTx, uint32_t USART_WakeUp)
{ assert_param(IS_USART_ALL_PERIPH(USARTx)); assert_param(IS_USART_MUTEMODE_WAKEUP(USART_WakeUp)); USARTx->CR1 &= (uint32_t)~((uint32_t)USART_CR1_WAKE); USARTx->CR1 |= USART_WakeUp; }
ajhc/demo-cortex-m3
C++
null
38
/* Remove request from queue. Note: must be called with spin lock held. */
static void __rpc_remove_wait_queue(struct rpc_wait_queue *queue, struct rpc_task *task)
/* Remove request from queue. Note: must be called with spin lock held. */ static void __rpc_remove_wait_queue(struct rpc_wait_queue *queue, struct rpc_task *task)
{ __rpc_disable_timer(queue, task); if (RPC_IS_PRIORITY(queue)) __rpc_remove_wait_queue_priority(task); list_del(&task->u.tk_wait.list); queue->qlen--; dprintk("RPC: %5u removed from queue %p \"%s\"\n", task->tk_pid, queue, rpc_qname(queue)); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* unlink the first attachment of a key from a keyring */
long keyctl_keyring_unlink(key_serial_t id, key_serial_t ringid)
/* unlink the first attachment of a key from a keyring */ long keyctl_keyring_unlink(key_serial_t id, key_serial_t ringid)
{ key_ref_t keyring_ref, key_ref; long ret; keyring_ref = lookup_user_key(ringid, 0, KEY_WRITE); if (IS_ERR(keyring_ref)) { ret = PTR_ERR(keyring_ref); goto error; } key_ref = lookup_user_key(id, KEY_LOOKUP_FOR_UNLINK, 0); if (IS_ERR(key_ref)) { ret = PTR_ERR(key_ref); goto error2; } ret = key_unlink(key_ref_to_ptr(keyring_ref), key_ref_to_ptr(key_ref)); key_ref_put(key_ref); error2: key_ref_put(keyring_ref); error: return ret; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Main program entry point. This routine contains the overall program flow, including initial setup of all components and the main program loop. */
int main(void)
/* Main program entry point. This routine contains the overall program flow, including initial setup of all components and the main program loop. */ int main(void)
{ SetupHardware(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); for (;;) { CheckJoystickMovement(); CDC_Device_ReceiveByte(&VirtualSerial1_CDC_Interface); int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial2_CDC_Interface); if (!(ReceivedByte < 0)) CDC_Device_SendByte(&VirtualSerial2_CDC_Interface, (uint8_t)ReceivedByte); CDC_Device_USBTask(&VirtualSerial1_CDC_Interface); CDC_Device_USBTask(&VirtualSerial2_CDC_Interface); USB_USBTask(); } }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* This function will config an desc in alternate setting object. */
rt_err_t rt_usbd_altsetting_config_descriptor(ualtsetting_t setting, const void *desc, rt_off_t intf_pos)
/* This function will config an desc in alternate setting object. */ rt_err_t rt_usbd_altsetting_config_descriptor(ualtsetting_t setting, const void *desc, rt_off_t intf_pos)
{ RT_ASSERT(setting != RT_NULL); RT_ASSERT(setting->desc !=RT_NULL); rt_memcpy(setting->desc, desc, setting->desc_size); setting->intf_desc = (uintf_desc_t)((char*)setting->desc + intf_pos); return RT_EOK; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Registers 0x00 - 0x50 are FIFOs. The 0x50+ are the control registers and they're all 32bits long. 0xB8+ are reserved, so don't bother. */
static void dump_regs(struct eth_device *dev)
/* Registers 0x00 - 0x50 are FIFOs. The 0x50+ are the control registers and they're all 32bits long. 0xB8+ are reserved, so don't bother. */ static void dump_regs(struct eth_device *dev)
{ u8 i, j = 0; for (i = 0x50; i < 0xB8; i += sizeof(u32)) printf("%02x: 0x%08x %c", i, smc911x_reg_read(dev, i), (j++ % 2 ? '\n' : ' ')); }
EmcraftSystems/u-boot
C++
Other
181
/* Convert time structure to register_value. Retrieves register_value convert by the time structure. */
uint32_t rtc_calendar_time_to_register_value(struct rtc_module *const module, const struct rtc_calendar_time *const time)
/* Convert time structure to register_value. Retrieves register_value convert by the time structure. */ uint32_t rtc_calendar_time_to_register_value(struct rtc_module *const module, const struct rtc_calendar_time *const time)
{ uint32_t register_value; register_value = (time->year - module->year_init_value) << RTC_MODE2_CLOCK_YEAR_Pos; register_value |= (time->month << RTC_MODE2_CLOCK_MONTH_Pos); register_value |= (time->day << RTC_MODE2_CLOCK_DAY_Pos); register_value |= (time->hour << RTC_MODE2_CLOCK_HOUR_Pos); if (!(module->clock_24h) && (time->pm)) { register_value |= (0x10u << RTC_MODE2_CLOCK_HOUR_Pos); } register_value |= (time->minute << RTC_MODE2_CLOCK_MINUTE_Pos); register_value |= (time->second << RTC_MODE2_CLOCK_SECOND_Pos); return register_value; }
memfault/zero-to-main
C++
null
200
/* Determines whether the SSI transmitter is busy or not. */
tBoolean SSIBusy(unsigned long ulBase)
/* Determines whether the SSI transmitter is busy or not. */ tBoolean SSIBusy(unsigned long ulBase)
{ ASSERT(SSIBaseValid(ulBase)); return((HWREG(ulBase + SSI_O_SR) & SSI_SR_BSY) ? true : false); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Find a variable with the given name 'n', handling global variables too. */
static void singlevar(LexState *ls, expdesc *var)
/* Find a variable with the given name 'n', handling global variables too. */ static void singlevar(LexState *ls, expdesc *var)
{ expdesc key; singlevaraux(fs, ls->envn, var, 1); lua_assert(var->k != VVOID); codestring(&key, varname); luaK_indexed(fs, var, &key); } }
Nicholas3388/LuaNode
C++
Other
1,055
/* CIA Pass 1 and PYXIS Pass 1 and 2 have a broken scatter-gather tlb. It cannot be invalidated. Rather than hard code the pass numbers, actually try the tbia to see if it works. */
void cia_pci_tbi(struct pci_controller *hose, dma_addr_t start, dma_addr_t end)
/* CIA Pass 1 and PYXIS Pass 1 and 2 have a broken scatter-gather tlb. It cannot be invalidated. Rather than hard code the pass numbers, actually try the tbia to see if it works. */ void cia_pci_tbi(struct pci_controller *hose, dma_addr_t start, dma_addr_t end)
{ wmb(); *(vip)CIA_IOC_PCI_TBIA = 3; mb(); *(vip)CIA_IOC_PCI_TBIA; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Difference in percentage of the effective ODR(and timestamp rate) with respect to the typical. Step: 0.15%. 8-bit format, 2's complement.. */
int32_t lsm6dso_odr_cal_reg_get(lsm6dso_ctx_t *ctx, uint8_t *val)
/* Difference in percentage of the effective ODR(and timestamp rate) with respect to the typical. Step: 0.15%. 8-bit format, 2's complement.. */ int32_t lsm6dso_odr_cal_reg_get(lsm6dso_ctx_t *ctx, uint8_t *val)
{ lsm6dso_internal_freq_fine_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_INTERNAL_FREQ_FINE, (uint8_t*)&reg, 1); *val = reg.freq_fine; return ret; }
alexander-g-dean/ESF
C++
null
41
/* Read a register value. Registers have an address and a 16-bit value */
static int max17262_reg_read(const struct device *dev, uint8_t reg_addr, int16_t *valp)
/* Read a register value. Registers have an address and a 16-bit value */ static int max17262_reg_read(const struct device *dev, uint8_t reg_addr, int16_t *valp)
{ const struct max17262_config *cfg = dev->config; uint8_t i2c_data[2]; int rc; rc = i2c_burst_read_dt(&cfg->i2c, reg_addr, i2c_data, 2); if (rc < 0) { LOG_ERR("Unable to read register 0x%02x", reg_addr); return rc; } *valp = ((int16_t)i2c_data[1] << 8) | i2c_data[0]; return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* The read routines must check the error status of the last configuration cycle. If there was an error, the routine returns all hex f's. */
static int iop3xx_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
/* The read routines must check the error status of the last configuration cycle. If there was an error, the routine returns all hex f's. */ static int iop3xx_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
{ unsigned long addr = iop3xx_cfg_address(bus, devfn, where); u32 val = iop3xx_read(addr) >> ((where & 3) * 8); if (iop3xx_pci_status()) val = 0xffffffff; *value = val; return PCIBIOS_SUCCESSFUL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Attempts to connect the NvVarsFileLib to the specified file system. */
EFI_STATUS EFIAPI ConnectNvVarsToFileSystem(IN EFI_HANDLE FsHandle)
/* Attempts to connect the NvVarsFileLib to the specified file system. */ EFI_STATUS EFIAPI ConnectNvVarsToFileSystem(IN EFI_HANDLE FsHandle)
{ EFI_STATUS Status; if (FeaturePcdGet (PcdSecureBootSupported) || FeaturePcdGet (PcdBootRestrictToFirmware)) { return EFI_UNSUPPORTED; } LoadNvVarsFromFs (FsHandle); Status = SaveNvVarsToFs (FsHandle); if (!EFI_ERROR (Status)) { mNvVarsFileLibFsHandle = FsHandle; } return Status; }
tianocore/edk2
C++
Other
4,240
/* Configures internally by software the NSS pin for the selected SPI. */
void SPI_NSSInternalSoftwareConfig(SPI_TypeDef *SPIx, uint16_t SPI_NSSInternalSoft)
/* Configures internally by software the NSS pin for the selected SPI. */ void SPI_NSSInternalSoftwareConfig(SPI_TypeDef *SPIx, uint16_t SPI_NSSInternalSoft)
{ assert_param(IS_SPI_ALL_PERIPH(SPIx)); assert_param(IS_SPI_NSS_INTERNAL(SPI_NSSInternalSoft)); if (SPI_NSSInternalSoft != SPI_NSSInternalSoft_Reset) { SPIx->GCTL |= SPI_NSSInternalSoft_Set; } else { SPIx->GCTL &= SPI_NSSInternalSoft_Reset; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Call backs all registered clients once a offload device is activated */
void cxgb3_add_clients(struct t3cdev *tdev)
/* Call backs all registered clients once a offload device is activated */ void cxgb3_add_clients(struct t3cdev *tdev)
{ struct cxgb3_client *client; mutex_lock(&cxgb3_db_lock); list_for_each_entry(client, &client_list, client_list) { if (client->add) client->add(tdev); } mutex_unlock(&cxgb3_db_lock); }
robutest/uclinux
C++
GPL-2.0
60
/* Gets the direction and mode of a pin. */
unsigned long GPIODirModeGet(unsigned long ulPort, unsigned long ulBit)
/* Gets the direction and mode of a pin. */ unsigned long GPIODirModeGet(unsigned long ulPort, unsigned long ulBit)
{ xASSERT(GPIOBaseValid(ulPort)); xASSERT(ulBit < 8); return((xHWREG(ulPort + GPIO_PMD) & (3 << (ulBit * 2))) >> (ulBit * 2)); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Read pixel from LCD RAM in RGB888 format. */
static ST7789H2_Rgb888 ST7789H2_ReadPixel_rgb888(uint16_t Xpos, uint16_t Ypos)
/* Read pixel from LCD RAM in RGB888 format. */ static ST7789H2_Rgb888 ST7789H2_ReadPixel_rgb888(uint16_t Xpos, uint16_t Ypos)
{ ST7789H2_Rgb888 rgb888; uint16_t rgb888_part1, rgb888_part2; ST7789H2_SetCursor(Xpos, Ypos); ST7789H2_WriteReg(ST7789H2_READ_RAM, (uint8_t*)NULL, 0); LCD_IO_ReadData(); rgb888_part1 = LCD_IO_ReadData(); rgb888_part2 = LCD_IO_ReadData(); rgb888.red = (rgb888_part1 & 0xFC00) >> 8; rgb888.green = (rgb888_part1 & 0x00FC) >> 0; rgb888.blue = (rgb888_part2 & 0xFC00) >> 8; return rgb888; }
eclipse-threadx/getting-started
C++
Other
310
/* Retrieve the block pointer from the cursor at the given level. This may be an inode btree root or from a buffer. */
STATIC struct xfs_btree_block* xfs_btree_get_block(struct xfs_btree_cur *cur, int level, struct xfs_buf **bpp)
/* Retrieve the block pointer from the cursor at the given level. This may be an inode btree root or from a buffer. */ STATIC struct xfs_btree_block* xfs_btree_get_block(struct xfs_btree_cur *cur, int level, struct xfs_buf **bpp)
{ if ((cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) && (level == cur->bc_nlevels - 1)) { *bpp = NULL; return xfs_btree_get_iroot(cur); } *bpp = cur->bc_bufs[level]; return XFS_BUF_TO_BLOCK(*bpp); }
robutest/uclinux
C++
GPL-2.0
60
/* DMA callback function for FLEXIO SPI send transfer. */
static void FLEXIO_SPI_TxDMACallback(dma_handle_t *handle, void *param)
/* DMA callback function for FLEXIO SPI send transfer. */ static void FLEXIO_SPI_TxDMACallback(dma_handle_t *handle, void *param)
{ flexio_spi_master_dma_private_handle_t *spiPrivateHandle = (flexio_spi_master_dma_private_handle_t *)param; FLEXIO_SPI_EnableDMA(spiPrivateHandle->base, kFLEXIO_SPI_TxDmaEnable, false); DMA_DisableInterrupts(handle->base, handle->channel); spiPrivateHandle->handle->txInProgress = false; if ((spiPrivateHandle->handle->txInProgress == false) && (spiPrivateHandle->handle->rxInProgress == false)) { if (spiPrivateHandle->handle->callback) { (spiPrivateHandle->handle->callback)(spiPrivateHandle->base, spiPrivateHandle->handle, kStatus_Success, spiPrivateHandle->handle->userData); } } }
labapart/polymcu
C++
null
201
/* Refer to SD Host Controller Simplified spec 3.0 Section 3.3 for details. */
EFI_STATUS EmmcPeimHcPowerControl(IN UINTN Bar, IN UINT8 PowerCtrl)
/* Refer to SD Host Controller Simplified spec 3.0 Section 3.3 for details. */ EFI_STATUS EmmcPeimHcPowerControl(IN UINTN Bar, IN UINT8 PowerCtrl)
{ EFI_STATUS Status; PowerCtrl &= (UINT8) ~BIT0; Status = EmmcPeimHcRwMmio (Bar + EMMC_HC_POWER_CTRL, FALSE, sizeof (PowerCtrl), &PowerCtrl); if (EFI_ERROR (Status)) { return Status; } PowerCtrl |= BIT0; Status = EmmcPeimHcRwMmio (Bar + EMMC_HC_POWER_CTRL, FALSE, sizeof (PowerCtrl), &PowerCtrl); return Status; }
tianocore/edk2
C++
Other
4,240
/* A device event has occurred. Watch for devices going down and delete our use of them (iface and route). */
static int ddp_device_event(struct notifier_block *this, unsigned long event, void *ptr)
/* A device event has occurred. Watch for devices going down and delete our use of them (iface and route). */ static int ddp_device_event(struct notifier_block *this, unsigned long event, void *ptr)
{ struct net_device *dev = ptr; if (!net_eq(dev_net(dev), &init_net)) return NOTIFY_DONE; if (event == NETDEV_DOWN) atalk_dev_down(dev); return NOTIFY_DONE; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* atl1e_init_module is the first routine called when the driver is loaded. All it does is register with the PCI subsystem. */
static int __init atl1e_init_module(void)
/* atl1e_init_module is the first routine called when the driver is loaded. All it does is register with the PCI subsystem. */ static int __init atl1e_init_module(void)
{ return pci_register_driver(&atl1e_driver); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns CR_OK upon successfull completion, an error code otherwise. */
enum CRStatus cr_statement_ruleset_set_sel_list(CRStatement *a_this, CRSelector *a_sel_list)
/* Returns CR_OK upon successfull completion, an error code otherwise. */ enum CRStatus cr_statement_ruleset_set_sel_list(CRStatement *a_this, CRSelector *a_sel_list)
{ g_return_val_if_fail (a_this && a_this->type == RULESET_STMT, CR_BAD_PARAM_ERROR); if (a_this->kind.ruleset->sel_list) cr_selector_unref (a_this->kind.ruleset->sel_list); a_this->kind.ruleset->sel_list = a_sel_list; if (a_sel_list) cr_selector_ref (a_sel_list); return CR_OK; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Enables or disables the selected ADC automatic injected group conversion after regular one. */
void ADC_AutoInjectedConvCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
/* Enables or disables the selected ADC automatic injected group conversion after regular one. */ void ADC_AutoInjectedConvCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
{ assert_param(IS_ADC_ALL_PERIPH(ADCx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { ADCx->CR1 |= ADC_CR1_JAUTO; } else { ADCx->CR1 &= (uint32_t)(~ADC_CR1_JAUTO); } }
avem-labs/Avem
C++
MIT License
1,752
/* Gets the GPIO instance according to the GPIO base. */
static uint32_t GPIO_GetInstance(GPIO_Type *base)
/* Gets the GPIO instance according to the GPIO base. */ static uint32_t GPIO_GetInstance(GPIO_Type *base)
{ uint32_t instance; for (instance = 0; instance < ARRAY_SIZE(s_gpioBases); instance++) { if (s_gpioBases[instance] == base) { break; } } assert(instance < ARRAY_SIZE(s_gpioBases)); return instance; }
nanoframework/nf-interpreter
C++
MIT License
293
/* When a new group registers or changes it's set of interesting events this function updates the fsnotify_mask to contain all interesting events */
void fsnotify_recalc_global_mask(void)
/* When a new group registers or changes it's set of interesting events this function updates the fsnotify_mask to contain all interesting events */ void fsnotify_recalc_global_mask(void)
{ struct fsnotify_group *group; __u32 mask = 0; int idx; idx = srcu_read_lock(&fsnotify_grp_srcu); list_for_each_entry_rcu(group, &fsnotify_groups, group_list) mask |= group->mask; srcu_read_unlock(&fsnotify_grp_srcu, idx); fsnotify_mask = mask; }
robutest/uclinux
C++
GPL-2.0
60
/* if the device is still up, then dev_close calls strip_close_low */
static int strip_open_low(struct net_device *dev)
/* if the device is still up, then dev_close calls strip_close_low */ static int strip_open_low(struct net_device *dev)
{ struct strip *strip_info = netdev_priv(dev); if (strip_info->tty == NULL) return (-ENODEV); if (!allocate_buffers(strip_info, dev->mtu)) return (-ENOMEM); strip_info->sx_count = 0; strip_info->tx_left = 0; strip_info->discard = 0; strip_info->working = FALSE; strip_info->firmware_level = NoStructure; strip_info->next_command = CompatibilityCommand; strip_info->user_baud = tty_get_baud_rate(strip_info->tty); printk(KERN_INFO "%s: Initializing Radio.\n", strip_info->dev->name); ResetRadio(strip_info); strip_info->idle_timer.expires = jiffies + 1 * HZ; add_timer(&strip_info->idle_timer); netif_wake_queue(dev); return (0); }
robutest/uclinux
C++
GPL-2.0
60
/* @hsotg: Programming view of DWC_otg controller @num: Tx FIFO to flush */
void dwc2_flush_tx_fifo(struct dwc2_hsotg *hsotg, const int num)
/* @hsotg: Programming view of DWC_otg controller @num: Tx FIFO to flush */ void dwc2_flush_tx_fifo(struct dwc2_hsotg *hsotg, const int num)
{ u32 greset; int count = 0; dev_vdbg(hsotg->dev, "Flush Tx FIFO %d\n", num); greset = GRSTCTL_TXFFLSH; greset |= num << GRSTCTL_TXFNUM_SHIFT & GRSTCTL_TXFNUM_MASK; writel(greset, hsotg->regs + GRSTCTL); do { greset = readl(hsotg->regs + GRSTCTL); if (++count > 10000) { dev_warn(hsotg->dev, "%s() HANG! GRSTCTL=%0x GNPTXSTS=0x%08x\n", __func__, greset, readl(hsotg->regs + GNPTXSTS)); break; } udelay(1); } while (greset & GRSTCTL_TXFFLSH); udelay(1); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* copy from fs while checksumming, otherwise like csum_partial */
__wsum csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *csum_err)
/* copy from fs while checksumming, otherwise like csum_partial */ __wsum csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *csum_err)
{ int missing; missing = __copy_from_user(dst, src, len); if (missing) { memset(dst + len - missing, 0, missing); *csum_err = -EFAULT; } else *csum_err = 0; return csum_partial(dst, len, sum); }
robutest/uclinux
C++
GPL-2.0
60
/* Free up all resource allocated for a BM_MENU_ENTRY. */
VOID LibDestroyMenuEntry(MENU_ENTRY *MenuEntry)
/* Free up all resource allocated for a BM_MENU_ENTRY. */ VOID LibDestroyMenuEntry(MENU_ENTRY *MenuEntry)
{ FILE_CONTEXT *FileContext; FileContext = (FILE_CONTEXT *)MenuEntry->VariableContext; if (!FileContext->IsRoot) { if (FileContext->DevicePath != NULL) { FreePool (FileContext->DevicePath); } } else { if (FileContext->FileHandle != NULL) { FileContext->FileHandle->Close (FileContext->FileHandle); } } if (FileContext->FileName != NULL) { FreePool (FileContext->FileName); } FreePool (FileContext); if (MenuEntry->DisplayString != NULL) { FreePool (MenuEntry->DisplayString); } if (MenuEntry->HelpString != NULL) { FreePool (MenuEntry->HelpString); } FreePool (MenuEntry); }
tianocore/edk2
C++
Other
4,240
/* Reads and returns the serial flash device ID. */
uint32_t s25fl1xx_read_jedec_id(struct qspid_t *qspid)
/* Reads and returns the serial flash device ID. */ uint32_t s25fl1xx_read_jedec_id(struct qspid_t *qspid)
{ static uint32_t id; s25fl1xx_exec_command(qspid, S25FL1XX_READ_JEDEC_ID, 0, &id, QSPI_READ_ACCESS, 3); return id; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Function called in case of error detected in SPI IT Handler. */
void SPI1_TransferError_Callback(void)
/* Function called in case of error detected in SPI IT Handler. */ void SPI1_TransferError_Callback(void)
{ LL_SPI_DisableIT_RXNE(SPI1); LL_SPI_DisableIT_TXE(SPI1); LED_Blinking(LED_BLINK_ERROR); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI PciAnd32(IN UINTN Address, IN UINT32 AndData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */ UINT32 EFIAPI PciAnd32(IN UINTN Address, IN UINT32 AndData)
{ return PciCf8And32 (Address, AndData); }
tianocore/edk2
C++
Other
4,240
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */
int main(void)
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */ int main(void)
{ SetupHardware(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); for (;;) { Mouse_Task(); USB_USBTask(); } }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Discard the internal output buffer for this device. If no method is provided then either the buffer cannot be hardware flushed or there is no buffer driver side. */
void tty_driver_flush_buffer(struct tty_struct *tty)
/* Discard the internal output buffer for this device. If no method is provided then either the buffer cannot be hardware flushed or there is no buffer driver side. */ void tty_driver_flush_buffer(struct tty_struct *tty)
{ if (tty->ops->flush_buffer) tty->ops->flush_buffer(tty); }
robutest/uclinux
C++
GPL-2.0
60
/* If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 128-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
VOID* EFIAPI ScanGuid(IN CONST VOID *Buffer, IN UINTN Length, IN CONST GUID *Guid)
/* If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 128-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */ VOID* EFIAPI ScanGuid(IN CONST VOID *Buffer, IN UINTN Length, IN CONST GUID *Guid)
{ CONST GUID *GuidPtr; ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0); ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1)); ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0); GuidPtr = (GUID *)Buffer; Buffer = GuidPtr + Length / sizeof (*GuidPtr); while (GuidPtr < (CONST GUID *)Buffer) { if (InternalMemCompareGuid (GuidPtr, Guid)) { return (VOID *)GuidPtr; } GuidPtr++; } return NULL; }
tianocore/edk2
C++
Other
4,240
/* Returns: Pointer to next entry in queue / NULL if empty */
static struct ibmvfc_async_crq* ibmvfc_next_async_crq(struct ibmvfc_host *vhost)
/* Returns: Pointer to next entry in queue / NULL if empty */ static struct ibmvfc_async_crq* ibmvfc_next_async_crq(struct ibmvfc_host *vhost)
{ struct ibmvfc_async_crq_queue *async_crq = &vhost->async_crq; struct ibmvfc_async_crq *crq; crq = &async_crq->msgs[async_crq->cur]; if (crq->valid & 0x80) { if (++async_crq->cur == async_crq->size) async_crq->cur = 0; } else crq = NULL; return crq; }
robutest/uclinux
C++
GPL-2.0
60
/* Called by the PCI code when it finds an SCC PATA controller. We then use the IDE PCI generic helper to do most of the work. */
static int __devinit scc_init_one(struct pci_dev *dev, const struct pci_device_id *id)
/* Called by the PCI code when it finds an SCC PATA controller. We then use the IDE PCI generic helper to do most of the work. */ static int __devinit scc_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{ return init_setup_scc(dev, &scc_chipset); }
robutest/uclinux
C++
GPL-2.0
60
/* Checks if any Ipv4 header checksum error in the frame just transmitted. This serves as indication that error occureed in the IPv4 header checksum insertion. The sent out frame doesnot carry any ipv4 header checksum inserted by the hardware. */
bool synopGMAC_is_tx_ipv4header_checksum_error(synopGMACdevice *gmacdev, u32 status)
/* Checks if any Ipv4 header checksum error in the frame just transmitted. This serves as indication that error occureed in the IPv4 header checksum insertion. The sent out frame doesnot carry any ipv4 header checksum inserted by the hardware. */ bool synopGMAC_is_tx_ipv4header_checksum_error(synopGMACdevice *gmacdev, u32 status)
{ return((status & DescTxIpv4ChkError) == DescTxIpv4ChkError); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* sunxi_lcd_tcon_disable - disable timing controller. @screen_id: The index of screen. */
void sunxi_lcd_tcon_disable(u32 screen_id)
/* sunxi_lcd_tcon_disable - disable timing controller. @screen_id: The index of screen. */ void sunxi_lcd_tcon_disable(u32 screen_id)
{ if (g_lcd_drv.src_ops.sunxi_lcd_tcon_disable) g_lcd_drv.src_ops.sunxi_lcd_tcon_disable(screen_id); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Caution: This function may receive untrusted input. PE/COFF image is external input, so this function will make sure the PE/COFF image content read is within the image buffer. */
EFI_STATUS EFIAPI Tcg2DxeImageRead(IN VOID *FileHandle, IN UINTN FileOffset, IN OUT UINTN *ReadSize, OUT VOID *Buffer)
/* Caution: This function may receive untrusted input. PE/COFF image is external input, so this function will make sure the PE/COFF image content read is within the image buffer. */ EFI_STATUS EFIAPI Tcg2DxeImageRead(IN VOID *FileHandle, IN UINTN FileOffset, IN OUT UINTN *ReadSize, OUT VOID *Buffer)
{ UINTN EndPosition; if ((FileHandle == NULL) || (ReadSize == NULL) || (Buffer == NULL)) { return EFI_INVALID_PARAMETER; } if (MAX_ADDRESS - FileOffset < *ReadSize) { return EFI_INVALID_PARAMETER; } EndPosition = FileOffset + *ReadSize; if (EndPosition > mTcg2DxeImageSize) { *ReadSize = (UINT32)(mTcg2DxeImageSize - FileOffset); } if (FileOffset >= mTcg2DxeImageSize) { *ReadSize = 0; } CopyMem (Buffer, (UINT8 *)((UINTN)FileHandle + FileOffset), *ReadSize); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Deinitializes all the resources used by the codec (those initialized by */
uint32_t EVAL_AUDIO_DeInit(void)
/* Deinitializes all the resources used by the codec (those initialized by */ uint32_t EVAL_AUDIO_DeInit(void)
{ Audio_MAL_DeInit(); Codec_DeInit(); return 0; }
avem-labs/Avem
C++
MIT License
1,752
/* Enables ODR CHANGE virtual sensor to be batched in FIFO.. */
int32_t lsm6dso_fifo_virtual_sens_odr_chg_get(stmdev_ctx_t *ctx, uint8_t *val)
/* Enables ODR CHANGE virtual sensor to be batched in FIFO.. */ int32_t lsm6dso_fifo_virtual_sens_odr_chg_get(stmdev_ctx_t *ctx, uint8_t *val)
{ lsm6dso_fifo_ctrl2_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)&reg, 1); *val = reg.odrchg_en; return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Get current timer count value from OSTIMER. This function will get a decimal timer count value. The RAW value of timer count is gray code format, will be translated to decimal data internally. */
uint64_t OSTIMER_GetCurrentTimerValue(OSTIMER_Type *base)
/* Get current timer count value from OSTIMER. This function will get a decimal timer count value. The RAW value of timer count is gray code format, will be translated to decimal data internally. */ uint64_t OSTIMER_GetCurrentTimerValue(OSTIMER_Type *base)
{ uint64_t tmp = 0U; tmp = OSTIMER_GetCurrentTimerRawValue(base); return OSTIMER_GrayToDecimal(tmp); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* retrieve application data structure for an application ID */
static struct gigaset_capi_appl* get_appl(struct gigaset_capi_ctr *iif, u16 appl)
/* retrieve application data structure for an application ID */ static struct gigaset_capi_appl* get_appl(struct gigaset_capi_ctr *iif, u16 appl)
{ struct gigaset_capi_appl *ap; list_for_each_entry(ap, &iif->appls, ctrlist) if (ap->id == appl) return ap; return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Discard all buffered characters. On the next scan, YY_INPUT will be called. */
void yy_flush_buffer(YY_BUFFER_STATE b)
/* Discard all buffered characters. On the next scan, YY_INPUT will be called. */ void yy_flush_buffer(YY_BUFFER_STATE b)
{ if ( ! b ) return; b->yy_n_chars = 0; b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) yy_load_buffer_state( ); }
pikasTech/PikaPython
C++
MIT License
1,403
/* param base FlexCAN peripheral base address. param handle Pointer to flexcan_edma_handle_t structure. param pEdmaConfig The user configuration structure of type edma_transfer_t. retval kStatus_Success if succeed, others failed. retval kStatus_FLEXCAN_RxFifoBusy Previous transfer ongoing. */
status_t FLEXCAN_StartTransferDatafromRxFIFO(CAN_Type *base, flexcan_edma_handle_t *handle, edma_transfer_config_t *pEdmaConfig)
/* param base FlexCAN peripheral base address. param handle Pointer to flexcan_edma_handle_t structure. param pEdmaConfig The user configuration structure of type edma_transfer_t. retval kStatus_Success if succeed, others failed. retval kStatus_FLEXCAN_RxFifoBusy Previous transfer ongoing. */ status_t FLEXCAN_StartTransferDatafromRxFIFO(CAN_Type *base, flexcan_edma_handle_t *handle, edma_transfer_config_t *pEdmaConfig)
{ assert(NULL != handle->rxFifoEdmaHandle); assert(NULL != pEdmaConfig); status_t status; if ((uint8_t)KFLEXCAN_RxFifoBusy == handle->rxFifoState) { status = kStatus_FLEXCAN_RxFifoBusy; } else { handle->rxFifoState = (uint8_t)KFLEXCAN_RxFifoBusy; FLEXCAN_EnableRxFifoDMA(base, true); (void)EDMA_SubmitTransfer(handle->rxFifoEdmaHandle, (const edma_transfer_config_t *)pEdmaConfig); EDMA_StartTransfer(handle->rxFifoEdmaHandle); status = kStatus_Success; } return status; }
eclipse-threadx/getting-started
C++
Other
310
/* In the table, -1 means don't assign an IRQ number. This is usually because it is the Saturn IO (SIO) PCI/ISA Bridge Chip. */
static int __init eb66p_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
/* In the table, -1 means don't assign an IRQ number. This is usually because it is the Saturn IO (SIO) PCI/ISA Bridge Chip. */ static int __init eb66p_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
{ static char irq_tab[5][5] __initdata = { {16+0, 16+0, 16+5, 16+9, 16+13}, {16+1, 16+1, 16+6, 16+10, 16+14}, { -1, -1, -1, -1, -1}, {16+2, 16+2, 16+7, 16+11, 16+15}, {16+3, 16+3, 16+8, 16+12, 16+6} }; const long min_idsel = 6, max_idsel = 10, irqs_per_slot = 5; return COMMON_TABLE_LOOKUP; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Event handler for the library USB Configuration Changed event. */
void EVENT_USB_Device_ConfigurationChanged(void)
/* Event handler for the library USB Configuration Changed event. */ void EVENT_USB_Device_ConfigurationChanged(void)
{ bool ConfigSuccess = true; ConfigSuccess &= MS_Device_ConfigureEndpoints(&Disk_MS_Interface); LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Process received addresses and clean up temporary stuff Called by oonf_api after message was parsed */
static enum rfc5444_result _nhdp_msg_end_cb(struct rfc5444_reader_tlvblock_context *cont __attribute__((unused)), bool dropped)
/* Process received addresses and clean up temporary stuff Called by oonf_api after message was parsed */ static enum rfc5444_result _nhdp_msg_end_cb(struct rfc5444_reader_tlvblock_context *cont __attribute__((unused)), bool dropped)
{ if (!dropped) { process_temp_tables(); } val_time = 0ULL; int_time = 0ULL; sym = 0; lost = 0; nhdp_reset_addresses_tmp_usg(1); if (dropped) { return RFC5444_DROP_MESSAGE; } return RFC5444_OKAY; }
labapart/polymcu
C++
null
201
/* Set boot source from LDROM or APROM after next software reset. */
void FMC_SetBootSource(int32_t i32BootSrc)
/* Set boot source from LDROM or APROM after next software reset. */ void FMC_SetBootSource(int32_t i32BootSrc)
{ if(i32BootSrc) { FMC->ISPCTL |= FMC_ISPCTL_BS_Msk; } else { FMC->ISPCTL &= ~FMC_ISPCTL_BS_Msk; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* @desc: block device descriptor @part: partition number Return: 1 if a file system exists on the partition 0 otherwise */
static int efi_fs_exists(struct blk_desc *desc, int part)
/* @desc: block device descriptor @part: partition number Return: 1 if a file system exists on the partition 0 otherwise */ static int efi_fs_exists(struct blk_desc *desc, int part)
{ if (fs_set_blk_dev_with_part(desc, part)) return 0; if (fs_get_type() == FS_TYPE_ANY) return 0; fs_close(); return 1; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Sets the integration time and gain (controls sensitivity) */
tsl2561Error_t tsl2561SetTiming(tsl2561IntegrationTime_t integration, tsl2561Gain_t gain)
/* Sets the integration time and gain (controls sensitivity) */ tsl2561Error_t tsl2561SetTiming(tsl2561IntegrationTime_t integration, tsl2561Gain_t gain)
{ if (!_tsl2561Initialised) tsl2561Init(); tsl2561Error_t error = TSL2561_ERROR_OK; error = tsl2561Enable(); if (error) return error; error = tsl2561Write8(TSL2561_COMMAND_BIT | TSL2561_REGISTER_TIMING, integration | gain); if (error) return error; _tsl2561IntegrationTime = integration; _tsl2561Gain = gain; error = tsl2561Disable(); if (error) return error; return error; }
microbuilder/LPC1343CodeBase
C++
Other
73
/* parport_ip32_init_state - for core parport code @dev: pointer to &struct pardevice @s: pointer to &struct parport_state to initialize */
static void parport_ip32_init_state(struct pardevice *dev, struct parport_state *s)
/* parport_ip32_init_state - for core parport code @dev: pointer to &struct pardevice @s: pointer to &struct parport_state to initialize */ static void parport_ip32_init_state(struct pardevice *dev, struct parport_state *s)
{ s->u.ip32.dcr = DCR_SELECT | DCR_nINIT; s->u.ip32.ecr = ECR_MODE_PS2 | ECR_nERRINTR | ECR_SERVINTR; }
robutest/uclinux
C++
GPL-2.0
60
/* list_move - delete from one list and add as another's head @list: the entry to move @head: the head that will precede our entry */
static void list_move(struct list_head *list, struct list_head *head)
/* list_move - delete from one list and add as another's head @list: the entry to move @head: the head that will precede our entry */ static void list_move(struct list_head *list, struct list_head *head)
{ __list_del(list->prev, list->next); list_add(list, head); }
robutest/uclinux
C++
GPL-2.0
60
/* Process the option ROM for all the children of the specified parent PCI device. It can only be used after the first full Option ROM process. */
VOID ProcessOptionRomLight(IN PCI_IO_DEVICE *PciIoDevice)
/* Process the option ROM for all the children of the specified parent PCI device. It can only be used after the first full Option ROM process. */ VOID ProcessOptionRomLight(IN PCI_IO_DEVICE *PciIoDevice)
{ PCI_IO_DEVICE *Temp; LIST_ENTRY *CurrentLink; CurrentLink = PciIoDevice->ChildList.ForwardLink; while (CurrentLink != NULL && CurrentLink != &PciIoDevice->ChildList) { Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink); if (!IsListEmpty (&Temp->ChildList)) { ProcessOptionRomLight (Temp); } Temp->AllOpRomProcessed = PciRomGetImageMapping (Temp); CurrentLink = CurrentLink->ForwardLink; } }
tianocore/edk2
C++
Other
4,240
/* mpt_add_chain_64bit - Place a 64 bit chain SGE at address pAddr. @pAddr: virtual address for SGE @next: nextChainOffset value (u32's) @length: length of next SGL segment @dma_addr: Physical address */
static void mpt_add_chain_64bit(void *pAddr, u8 next, u16 length, dma_addr_t dma_addr)
/* mpt_add_chain_64bit - Place a 64 bit chain SGE at address pAddr. @pAddr: virtual address for SGE @next: nextChainOffset value (u32's) @length: length of next SGL segment @dma_addr: Physical address */ static void mpt_add_chain_64bit(void *pAddr, u8 next, u16 length, dma_addr_t dma_addr)
{ SGEChain64_t *pChain = (SGEChain64_t *) pAddr; u32 tmp = dma_addr & 0xFFFFFFFF; pChain->Length = cpu_to_le16(length); pChain->Flags = (MPI_SGE_FLAGS_CHAIN_ELEMENT | MPI_SGE_FLAGS_64_BIT_ADDRESSING); pChain->NextChainOffset = next; pChain->Address.Low = cpu_to_le32(tmp); tmp = (u32)(upper_32_bits(dma_addr)); pChain->Address.High = cpu_to_le32(tmp); }
robutest/uclinux
C++
GPL-2.0
60
/* ks_update_link_status - link status update. @netdev: The network device being opened. @ks: The chip information */
static void ks_update_link_status(struct net_device *netdev, struct ks_net *ks)
/* ks_update_link_status - link status update. @netdev: The network device being opened. @ks: The chip information */ static void ks_update_link_status(struct net_device *netdev, struct ks_net *ks)
{ u32 link_up_status; if (ks_rdreg16(ks, KS_P1SR) & P1SR_LINK_GOOD) { netif_carrier_on(netdev); link_up_status = true; } else { netif_carrier_off(netdev); link_up_status = false; } if (netif_msg_link(ks)) ks_dbg(ks, "%s: %s\n", __func__, link_up_status ? "UP" : "DOWN"); }
robutest/uclinux
C++
GPL-2.0
60
/* Set the GO_BUSY bit to trigger a SPI data transfer. */
void SPIBitGoBusySet(unsigned long ulBase)
/* Set the GO_BUSY bit to trigger a SPI data transfer. */ void SPIBitGoBusySet(unsigned long ulBase)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE) ); xHWREG(ulBase + SPI_CNTRL) |= SPI_CNTRL_GO_BUSY; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Return QMSPI unit size of the number of units field in QMSPI control/descriptor register. Input: power of 2 unit size 4, 2, or 0(default) corresponding to 16, 4, or 1 byte units. */
static uint32_t get_qunits(uint32_t qshift)
/* Return QMSPI unit size of the number of units field in QMSPI control/descriptor register. Input: power of 2 unit size 4, 2, or 0(default) corresponding to 16, 4, or 1 byte units. */ static uint32_t get_qunits(uint32_t qshift)
{ if (qshift == 4) { return MCHP_QMSPI_C_XFR_UNITS_16; } else if (qshift == 2) { return MCHP_QMSPI_C_XFR_UNITS_4; } else { return MCHP_QMSPI_C_XFR_UNITS_1; } }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* This function will post an message to the usb message queue, */
rt_err_t rt_usbh_event_signal(uhcd_t hcd, struct uhost_msg *msg)
/* This function will post an message to the usb message queue, */ rt_err_t rt_usbh_event_signal(uhcd_t hcd, struct uhost_msg *msg)
{ RT_ASSERT(msg != RT_NULL); rt_mq_send(hcd->usb_mq, (void*)msg, sizeof(struct uhost_msg)); return RT_EOK; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Initialize the dquot log item for a newly allocated dquot. The dquot isn't locked at this point, but it isn't on any of the lists either, so we don't care. */
void xfs_qm_dquot_logitem_init(struct xfs_dquot *dqp)
/* Initialize the dquot log item for a newly allocated dquot. The dquot isn't locked at this point, but it isn't on any of the lists either, so we don't care. */ void xfs_qm_dquot_logitem_init(struct xfs_dquot *dqp)
{ xfs_dq_logitem_t *lp; lp = &dqp->q_logitem; lp->qli_item.li_type = XFS_LI_DQUOT; lp->qli_item.li_ops = &xfs_dquot_item_ops; lp->qli_item.li_mountp = dqp->q_mount; lp->qli_dquot = dqp; lp->qli_format.qlf_type = XFS_LI_DQUOT; lp->qli_format.qlf_id = be32_to_cpu(dqp->q_core.d_id); lp->qli_format.qlf_blkno = dqp->q_blkno; lp->qli_format.qlf_len = 1; lp->qli_format.qlf_boffset = (__uint32_t)dqp->q_bufoffset; }
robutest/uclinux
C++
GPL-2.0
60
/* Wait end of transfer and check if received Data are well. */
void WaitAndCheckEndOfTransfer(void)
/* Wait end of transfer and check if received Data are well. */ void WaitAndCheckEndOfTransfer(void)
{ while (ubTransmissionComplete != 1) { } LL_DMA_DisableStream(DMA2, LL_DMA_STREAM_3); while (ubReceptionComplete != 1) { } LL_DMA_DisableStream(DMA1, LL_DMA_STREAM_3); if(Buffercmp8((uint8_t*)aTxBuffer, (uint8_t*)aRxBuffer, ubNbDataToTransmit)) { LED_Blinking(LED_BLINK_ERROR); } else { LED_On(); } }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Driver done interrupt service routine for channel 6. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC */
void XDmaPs_DoneISR_6(XDmaPs *InstPtr)
/* Driver done interrupt service routine for channel 6. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC */ void XDmaPs_DoneISR_6(XDmaPs *InstPtr)
{ XDmaPs_DoneISR_n(InstPtr, 6); }
ua1arn/hftrx
C++
null
69
/* This function is used for getting the count of block I/O devices that one specific block driver detects. To the PEI ATAPI driver, it returns the number of all the detected ATAPI devices it detects during the enumeration process. To the PEI legacy floppy driver, it returns the number of all the legacy devices it finds during its enumeration process. If no device is detected, then the function will return zero. */
EFI_STATUS EFIAPI EmmcBlockIoPeimGetDeviceNo(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, OUT UINTN *NumberBlockDevices)
/* This function is used for getting the count of block I/O devices that one specific block driver detects. To the PEI ATAPI driver, it returns the number of all the detected ATAPI devices it detects during the enumeration process. To the PEI legacy floppy driver, it returns the number of all the legacy devices it finds during its enumeration process. If no device is detected, then the function will return zero. */ EFI_STATUS EFIAPI EmmcBlockIoPeimGetDeviceNo(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, OUT UINTN *NumberBlockDevices)
{ EMMC_PEIM_HC_PRIVATE_DATA *Private; Private = GET_EMMC_PEIM_HC_PRIVATE_DATA_FROM_THIS (This); *NumberBlockDevices = Private->TotalBlkIoDevices; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Returns the list with a_new prepended or NULL in case of error. */
CRDeclaration* cr_declaration_prepend(CRDeclaration *a_this, CRDeclaration *a_new)
/* Returns the list with a_new prepended or NULL in case of error. */ CRDeclaration* cr_declaration_prepend(CRDeclaration *a_this, CRDeclaration *a_new)
{ CRDeclaration *cur = NULL; g_return_val_if_fail (a_new, NULL); if (!a_this) return a_new; a_this->prev = a_new; a_new->next = a_this; for (cur = a_new; cur && cur->prev; cur = cur->prev) ; return cur; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Returns port number being used to access the switch device. */
static u8 rio_get_swpinfo_inport(struct rio_mport *mport, u16 destid, u8 hopcount)
/* Returns port number being used to access the switch device. */ static u8 rio_get_swpinfo_inport(struct rio_mport *mport, u16 destid, u8 hopcount)
{ u32 result; rio_mport_read_config_32(mport, destid, hopcount, RIO_SWP_INFO_CAR, &result); return (u8) (result & 0xff); }
robutest/uclinux
C++
GPL-2.0
60
/* This file will be overwritten when reconfiguring your Atmel Start project. Please copy examples or other code you want to keep to a separate file or main.c to avoid loosing it when reconfiguring. */
void STDIO_REDIRECT_0_example(void)
/* This file will be overwritten when reconfiguring your Atmel Start project. Please copy examples or other code you want to keep to a separate file or main.c to avoid loosing it when reconfiguring. */ void STDIO_REDIRECT_0_example(void)
{ printf("\r\nHello ATMEL World!\r\n"); }
eclipse-threadx/getting-started
C++
Other
310
/* Fills each I2S_InitStruct member with its default value. */
void I2S_InitStruct(I2S_InitType *I2S_InitStruct)
/* Fills each I2S_InitStruct member with its default value. */ void I2S_InitStruct(I2S_InitType *I2S_InitStruct)
{ I2S_InitStruct->I2sMode = I2S_MODE_SlAVE_TX; I2S_InitStruct->Standard = I2S_STD_PHILLIPS; I2S_InitStruct->DataFormat = I2S_DATA_FMT_16BITS; I2S_InitStruct->MCLKEnable = I2S_MCLK_DISABLE; I2S_InitStruct->AudioFrequency = I2S_AUDIO_FREQ_DEFAULT; I2S_InitStruct->CLKPOL = I2S_CLKPOL_LOW; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Read current date/time or alarm date/time from RTC setting. This function is to Read current date/time or alarm date/time from RTC setting. */
void xRTCTimeRead(xtTime *pxtTime, unsigned long ulTimeAlarm)
/* Read current date/time or alarm date/time from RTC setting. This function is to Read current date/time or alarm date/time from RTC setting. */ void xRTCTimeRead(xtTime *pxtTime, unsigned long ulTimeAlarm)
{ RTCTimeRead((tTime *)pxtTime, ulTimeAlarm); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Computes the period of a dashed stroke style. Returns 0 for non-dashed styles. */
double _cairo_stroke_style_dash_period(const cairo_stroke_style_t *style)
/* Computes the period of a dashed stroke style. Returns 0 for non-dashed styles. */ double _cairo_stroke_style_dash_period(const cairo_stroke_style_t *style)
{ double period; unsigned int i; period = 0.0; for (i = 0; i < style->num_dashes; i++) period += style->dash[i]; if (style->num_dashes & 1) period *= 2.0; return period; }
xboot/xboot
C++
MIT License
779
/* Get the peripheral clock speed for the Timer at base specified. */
uint32_t rcc_get_timer_clk_freq(uint32_t timer)
/* Get the peripheral clock speed for the Timer at base specified. */ uint32_t rcc_get_timer_clk_freq(uint32_t timer)
{ if (timer >= TIM2_BASE && timer <= TIM7_BASE) { uint8_t ppre1 = (RCC_CFGR >> RCC_CFGR_PPRE1_SHIFT) & RCC_CFGR_PPRE1_MASK; return (ppre1 == RCC_CFGR_PPRE1_HCLK_NODIV) ? rcc_apb1_frequency : 2 * rcc_apb1_frequency; } else { uint8_t ppre2 = (RCC_CFGR >> RCC_CFGR_PPRE2_SHIFT) & RCC_CFGR_PPRE2_MASK; return (ppre2 == RCC_CFGR_PPRE2_HCLK_NODIV) ? rcc_apb2_frequency : 2 * rcc_apb2_frequency; } }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* ppc440spe_adma_free_slots - flags descriptor slots for reuse @slot: Slot to free Caller must hold &ppc440spe_chan->lock while calling this function */
static void ppc440spe_adma_free_slots(struct ppc440spe_adma_desc_slot *slot, struct ppc440spe_adma_chan *chan)
/* ppc440spe_adma_free_slots - flags descriptor slots for reuse @slot: Slot to free Caller must hold &ppc440spe_chan->lock while calling this function */ static void ppc440spe_adma_free_slots(struct ppc440spe_adma_desc_slot *slot, struct ppc440spe_adma_chan *chan)
{ int stride = slot->slots_per_op; while (stride--) { slot->slots_per_op = 0; slot = list_entry(slot->slot_node.next, struct ppc440spe_adma_desc_slot, slot_node); } }
robutest/uclinux
C++
GPL-2.0
60
/* The goal and function of the following code is to support the two clock rates used by the audio subsystem, allowing for proper audio playback and capture without any pitch or speed changes. */
bool ccu_sdm_helper_has_rate(struct ccu_common *common, struct ccu_sdm_internal *sdm, unsigned long rate)
/* The goal and function of the following code is to support the two clock rates used by the audio subsystem, allowing for proper audio playback and capture without any pitch or speed changes. */ bool ccu_sdm_helper_has_rate(struct ccu_common *common, struct ccu_sdm_internal *sdm, unsigned long rate)
{ unsigned int i; if (!(common->features & CCU_FEATURE_SIGMA_DELTA_MOD)) { return false; } for (i = 0; i < sdm->table_size; i++) if (sdm->table[i].rate == rate) { return true; } return false; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If there are less @len bytes available in the data stream, or if any other errors occur, such as a corrupted compressed stream, an error is printed an the platform's exit() function is called. */
void gunzip_discard(struct gunzip_state *state, int len)
/* If there are less @len bytes available in the data stream, or if any other errors occur, such as a corrupted compressed stream, an error is printed an the platform's exit() function is called. */ void gunzip_discard(struct gunzip_state *state, int len)
{ static char discard_buf[128]; while (len > sizeof(discard_buf)) { gunzip_exactly(state, discard_buf, sizeof(discard_buf)); len -= sizeof(discard_buf); } if (len > 0) gunzip_exactly(state, discard_buf, len); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function is called each second during the boot manager waits the timeout. */
VOID EFIAPI PlatformBootManagerWaitCallback(UINT16 TimeoutRemain)
/* This function is called each second during the boot manager waits the timeout. */ VOID EFIAPI PlatformBootManagerWaitCallback(UINT16 TimeoutRemain)
{ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black; EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White; UINT16 Timeout; EFI_STATUS Status; Timeout = PcdGet16 (PcdPlatformBootTimeOut); Black.Raw = 0x00000000; White.Raw = 0x00FFFFFF; Status = BootLogoUpdateProgress ( White.Pixel, Black.Pixel, L"Press ESCAPE for boot options", White.Pixel, (Timeout - TimeoutRemain) * 100 / Timeout, 0 ); if (EFI_ERROR (Status)) { Print (L"."); } }
tianocore/edk2
C++
Other
4,240
/* Disable a DMA channel (by index ch: 0 .. 31) by clearing a bit in DMA_ERQ. */
int kinetis_dma_ch_disable(int ch)
/* Disable a DMA channel (by index ch: 0 .. 31) by clearing a bit in DMA_ERQ. */ int kinetis_dma_ch_disable(int ch)
{ return __kinetis_dma_ch_enable(ch, 0, 0); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Validate PDU Type.2 Validaes the encoding. Adds Expert Info if format invalid This also validates Spec Type.2.1. */
static void validate_c3(packet_info *pinfo, proto_item *pi, guint32, gint len)
/* Validate PDU Type.2 Validaes the encoding. Adds Expert Info if format invalid This also validates Spec Type.2.1. */ static void validate_c3(packet_info *pinfo, proto_item *pi, guint32, gint len)
{ if (len > 1 && val < 0x80) { expert_add_info_format(pinfo, pi, &ei_c2_c3_c4_format, "DOF Violation: Type.2.1: Compressed 24-bit Compression Manditory." ); } if (len > 2 && val < 0x4000) { expert_add_info_format(pinfo, pi, &ei_c2_c3_c4_format, "DOF Violation: Type.2.1: Compressed 24-bit Compression Manditory."); } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* 5.23 Serving Cell Identifier IE The Serving Cell Identifier IE is encoded as in 3GPP TS 48.008 (excluding IEI and length field). 5.24 Encryption Key */
static guint16 de_blap_enc_key(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
/* 5.23 Serving Cell Identifier IE The Serving Cell Identifier IE is encoded as in 3GPP TS 48.008 (excluding IEI and length field). 5.24 Encryption Key */ static guint16 de_blap_enc_key(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
{ guint32 curr_offset; curr_offset = offset; proto_tree_add_item(tree, hf_gsm_bsslap_encryption_key, tvb, curr_offset, 8, ENC_NA); curr_offset = curr_offset + 8; return(curr_offset - offset); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Update the Stack Hob if the stack has been moved */
VOID UpdateStackHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
/* Update the Stack Hob if the stack has been moved */ VOID UpdateStackHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
{ EFI_PEI_HOB_POINTERS Hob; Hob.Raw = GetHobList (); while ((Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw)) != NULL) { if (CompareGuid (&gEfiHobMemoryAllocStackGuid, &(Hob.MemoryAllocationStack->AllocDescriptor.Name))) { BuildMemoryAllocationHob ( Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress, Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength, EfiConventionalMemory ); Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress = BaseAddress; Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength = Length; break; } Hob.Raw = GET_NEXT_HOB (Hob); } }
tianocore/edk2
C++
Other
4,240
/* Description: Searches for a valid DOI definition and if one is found it is returned to the caller. Otherwise NULL is returned. The caller must ensure that rcu_read_lock() is held while accessing the returned definition and the DOI definition reference count is decremented when the caller is done. */
struct cipso_v4_doi* cipso_v4_doi_getdef(u32 doi)
/* Description: Searches for a valid DOI definition and if one is found it is returned to the caller. Otherwise NULL is returned. The caller must ensure that rcu_read_lock() is held while accessing the returned definition and the DOI definition reference count is decremented when the caller is done. */ struct cipso_v4_doi* cipso_v4_doi_getdef(u32 doi)
{ struct cipso_v4_doi *doi_def; rcu_read_lock(); doi_def = cipso_v4_doi_search(doi); if (doi_def == NULL) goto doi_getdef_return; if (!atomic_inc_not_zero(&doi_def->refcount)) doi_def = NULL; doi_getdef_return: rcu_read_unlock(); return doi_def; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Called with cgroup_mutex held or else with an RCU-protected cgroup reference. Writes path of cgroup into buf. Returns 0 on success, -errno on error. */
int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen)
/* Called with cgroup_mutex held or else with an RCU-protected cgroup reference. Writes path of cgroup into buf. Returns 0 on success, -errno on error. */ int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen)
{ char *start; struct dentry *dentry = rcu_dereference(cgrp->dentry); if (!dentry || cgrp == dummytop) { strcpy(buf, "/"); return 0; } start = buf + buflen; *--start = '\0'; for (;;) { int len = dentry->d_name.len; if ((start -= len) < buf) return -ENAMETOOLONG; memcpy(start, cgrp->dentry->d_name.name, len); cgrp = cgrp->parent; if (!cgrp) break; dentry = rcu_dereference(cgrp->dentry); if (!cgrp->parent) continue; if (--start < buf) return -ENAMETOOLONG; *start = '/'; } memmove(buf, start, buf + buflen - start); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Allocate enough 32bit PA addressable pages to cover @size from the page level allocator and map them into continguos kernel virtual space. */
void* vmalloc_32(unsigned long size)
/* Allocate enough 32bit PA addressable pages to cover @size from the page level allocator and map them into continguos kernel virtual space. */ void* vmalloc_32(unsigned long size)
{ return __vmalloc(size, GFP_KERNEL, PAGE_KERNEL); }
robutest/uclinux
C++
GPL-2.0
60
/* Set the MAC address of the es module. */
ES_WIFI_Status_t ES_WIFI_SetMACAddress(ES_WIFIObject_t *Obj, uint8_t *mac)
/* Set the MAC address of the es module. */ ES_WIFI_Status_t ES_WIFI_SetMACAddress(ES_WIFIObject_t *Obj, uint8_t *mac)
{ ES_WIFI_Status_t ret ; sprintf((char*)Obj->CmdData,"Z4=%X:%X:%X:%X:%X:%X\r",mac[0],mac[1],mac[2],mac[3],mac[4],mac[5] ); ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); if(ret == ES_WIFI_STATUS_OK) { sprintf((char*)Obj->CmdData,"Z1\r"); ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); } return ret; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Read a long word (32 bits) from a memory location, and byte swap the value before returning to the caller. */
unsigned int mpc824x_mpc107_read32(unsigned int address)
/* Read a long word (32 bits) from a memory location, and byte swap the value before returning to the caller. */ unsigned int mpc824x_mpc107_read32(unsigned int address)
{ unsigned int retVal; retVal = LONGSWAP (*(unsigned int *) address); return (retVal); }
EmcraftSystems/u-boot
C++
Other
181
/* param base ENET peripheral base address. param phyAddr The PHY address. param phyReg The PHY register. Range from 0 ~ 31. param operation The read operation. */
void ENET_StartSMIRead(ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, enet_mii_read_t operation)
/* param base ENET peripheral base address. param phyAddr The PHY address. param phyReg The PHY register. Range from 0 ~ 31. param operation The read operation. */ void ENET_StartSMIRead(ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, enet_mii_read_t operation)
{ uint32_t mmfr = 0; mmfr = ENET_MMFR_ST(1U) | ENET_MMFR_OP(operation) | ENET_MMFR_PA(phyAddr) | ENET_MMFR_RA(phyReg) | ENET_MMFR_TA(2U); base->MMFR = mmfr; }
eclipse-threadx/getting-started
C++
Other
310
/* Finds offset of next category of transitions in transition table. Returns the start index of next category. */
static u16 __init llc_find_next_offset(struct llc_conn_state *state, u16 offset)
/* Finds offset of next category of transitions in transition table. Returns the start index of next category. */ static u16 __init llc_find_next_offset(struct llc_conn_state *state, u16 offset)
{ u16 cnt = 0; struct llc_conn_state_trans **next_trans; for (next_trans = state->transitions + offset; (*next_trans)->ev; next_trans++) ++cnt; return cnt; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Notify all object if a style is modified */
void lv_obj_report_style_mod(lv_style_t *style)
/* Notify all object if a style is modified */ void lv_obj_report_style_mod(lv_style_t *style)
{ lv_disp_t * d = lv_disp_get_next(NULL); while(d) { lv_obj_t * i; LV_LL_READ(d->scr_ll, i) { if(i->style_p == style || style == NULL) { lv_obj_refresh_style(i); } report_style_mod_core(style, i); } d = lv_disp_get_next(d); } }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Converts a 16-bit short to a big endian byte stream */
unsigned char* inv_int16_to_big8(short x, unsigned char *big8)
/* Converts a 16-bit short to a big endian byte stream */ unsigned char* inv_int16_to_big8(short x, unsigned char *big8)
{ big8[0] = (unsigned char)((x >> 8) & 0xff); big8[1] = (unsigned char)(x & 0xff); return big8; }
Luos-io/luos_engine
C++
MIT License
496