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 |
|---|---|---|---|---|---|---|---|
/* Try to set the controller to a given power mode. */ | __attribute__((weak)) | /* Try to set the controller to a given power mode. */
__attribute__((weak)) | {
switch (target) {
case LPM_IDLE:
case LPM_SLEEP:
case LPM_POWERDOWN:
case LPM_OFF:
__DSB();
__WFI();
break;
case LPM_UNKNOWN:
case LPM_ON:
default:
break;
}
return 0;
} | labapart/polymcu | C++ | null | 201 |
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */ | void GPIOPinTypeFan(uint32_t ui32Port, uint8_t ui8Pins) | /* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
void GPIOPinTypeFan(uint32_t ui32Port, uint8_t ui8Pins) | {
ASSERT(_GPIOBaseValid(ui32Port));
GPIODirModeSet(ui32Port, ui8Pins, GPIO_DIR_MODE_HW);
GPIOPadConfigSet(ui32Port, ui8Pins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Slave sends single byte through the USIx peripheral after receiving read request of Master. */ | void USI_I2C_SlaveSend(USI_TypeDef *USIx, u8 Data) | /* Slave sends single byte through the USIx peripheral after receiving read request of Master. */
void USI_I2C_SlaveSend(USI_TypeDef *USIx, u8 Data) | {
assert_param(IS_USI_I2C_ALL_PERIPH(USIx));
USIx->TX_FIFO_WRITE = Data;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* mraid_mm_teardown_dma_pools - Free all per adapter dma buffers @adp : Adapter softstate */ | static void mraid_mm_teardown_dma_pools(mraid_mmadp_t *) | /* mraid_mm_teardown_dma_pools - Free all per adapter dma buffers @adp : Adapter softstate */
static void mraid_mm_teardown_dma_pools(mraid_mmadp_t *) | {
int i;
mm_dmapool_t *pool;
for (i = 0; i < MAX_DMA_POOLS; i++) {
pool = &adp->dma_pool_list[i];
if (pool->handle) {
if (pool->vaddr)
pci_pool_free(pool->handle, pool->vaddr,
pool->paddr);
pci_pool_destroy(pool->handle);
pool->handle = NULL;
}
}
return;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Set a QH or TD vertically to be connected with a specific QH. */ | VOID SetQHVerticalQHorTDSelect(IN QH_STRUCT *PtrQH, IN BOOLEAN IsQH) | /* Set a QH or TD vertically to be connected with a specific QH. */
VOID SetQHVerticalQHorTDSelect(IN QH_STRUCT *PtrQH, IN BOOLEAN IsQH) | {
PtrQH->QueueHead.QHVerticalQSelect = IsQH ? 1 : 0;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Wrapper function for adding an entry to the hash. This function takes care of locking itself. */ | static void add_dma_entry(struct dma_debug_entry *entry) | /* Wrapper function for adding an entry to the hash. This function takes care of locking itself. */
static void add_dma_entry(struct dma_debug_entry *entry) | {
struct hash_bucket *bucket;
unsigned long flags;
bucket = get_hash_bucket(entry, &flags);
hash_bucket_add(bucket, entry);
put_hash_bucket(bucket, &flags);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* interrupt source= plc2 this function is called in nwfbisr.asm */ | void plc2_irq(struct s_smc *smc) | /* interrupt source= plc2 this function is called in nwfbisr.asm */
void plc2_irq(struct s_smc *smc) | {
u_short st = inpw(PLC(PA,PL_INTR_EVENT)) ;
plc_irq(smc,PA,st) ;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* find reloc tree by address of tree root */ | static struct btrfs_root* find_reloc_root(struct reloc_control *rc, u64 bytenr) | /* find reloc tree by address of tree root */
static struct btrfs_root* find_reloc_root(struct reloc_control *rc, u64 bytenr) | {
struct rb_node *rb_node;
struct mapping_node *node;
struct btrfs_root *root = NULL;
spin_lock(&rc->reloc_root_tree.lock);
rb_node = tree_search(&rc->reloc_root_tree.rb_root, bytenr);
if (rb_node) {
node = rb_entry(rb_node, struct mapping_node, rb_node);
root = (struct btrfs_root *)node->data;
}
spin_unlock(&rc->reloc_root_tree.lock);
return root;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). */ | UINT8* EFIAPI MmioWriteBuffer8(IN UINTN StartAddress, IN UINTN Length, IN CONST 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 MmioWriteBuffer8(IN UINTN StartAddress, IN UINTN Length, IN CONST UINT8 *Buffer) | {
VOID *ReturnBuffer;
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
ReturnBuffer = (UINT8 *)Buffer;
while (Length-- > 0) {
MmioWrite8 (StartAddress++, *(Buffer++));
}
return ReturnBuffer;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Notify the system that the SMM variable driver is ready. */ | VOID Tcg2NotifyMmReady(VOID) | /* Notify the system that the SMM variable driver is ready. */
VOID Tcg2NotifyMmReady(VOID) | {
EFI_STATUS Status;
EFI_HANDLE Handle;
Handle = NULL;
Status = gBS->InstallProtocolInterface (
&Handle,
&gTcg2MmSwSmiRegisteredGuid,
EFI_NATIVE_INTERFACE,
NULL
);
ASSERT_EFI_ERROR (Status);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* TRUE if the progress dialog doesn't exist and it looks like we'll take > 2s to load, FALSE otherwise. */ | static gboolean progress_is_slow(progdlg_t *progdlg, GTimer *prog_timer, gint64 size, gint64 pos) | /* TRUE if the progress dialog doesn't exist and it looks like we'll take > 2s to load, FALSE otherwise. */
static gboolean progress_is_slow(progdlg_t *progdlg, GTimer *prog_timer, gint64 size, gint64 pos) | {
double elapsed;
if (progdlg) return FALSE;
elapsed = g_timer_elapsed(prog_timer, NULL);
if ((elapsed / 2 > PROGBAR_SHOW_DELAY && (size / pos) > 2)
|| elapsed > PROGBAR_SHOW_DELAY) {
return TRUE;
}
return FALSE;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* return The enabled interrupts. This is the logical OR of members of the enumeration ::snvs_interrupt_enable_t */ | uint32_t SNVS_HP_RTC_GetEnabledInterrupts(SNVS_Type *base) | /* return The enabled interrupts. This is the logical OR of members of the enumeration ::snvs_interrupt_enable_t */
uint32_t SNVS_HP_RTC_GetEnabledInterrupts(SNVS_Type *base) | {
uint32_t val = 0U;
if (base->HPCR & SNVS_HPCR_PI_EN_MASK)
{
val |= kSNVS_RTC_PeriodicInterrupt;
}
if (base->HPCR & SNVS_HPCR_HPTA_EN_MASK)
{
val |= kSNVS_RTC_AlarmInterrupt;
}
return val;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Converts a data bit enum value to a Mode Register bit mask.
It is assumed that the Mode Register contents that are being modified within this function come with the bits modified by this function already masked out by the caller. */ | static bool uart_xlnx_ps_cfg2ll_databits(uint32_t *mode_reg, enum uart_config_data_bits databits) | /* Converts a data bit enum value to a Mode Register bit mask.
It is assumed that the Mode Register contents that are being modified within this function come with the bits modified by this function already masked out by the caller. */
static bool uart_xlnx_ps_cfg2ll_databits(uint32_t *mode_reg, enum uart_config_data_bits databits) | {
switch (databits) {
case UART_CFG_DATA_BITS_5:
case UART_CFG_DATA_BITS_9:
return false;
default:
case UART_CFG_DATA_BITS_8:
*mode_reg |= XUARTPS_MR_CHARLEN_8_BIT;
break;
case UART_CFG_DATA_BITS_7:
*mode_reg |= XUARTPS_MR_CHARLEN_7_BIT;
break;
case UART_CFG_DATA_BITS_6:
*mode_reg |= XUARTPS_MR_CHARLEN_6_BIT;
break;
}
return true;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Shutdown an omap_hwomd @oh. Intended to be called by omap_device_shutdown(). Returns -EINVAL on error or passes along the return value from _shutdown(). */ | int omap_hwmod_shutdown(struct omap_hwmod *oh) | /* Shutdown an omap_hwomd @oh. Intended to be called by omap_device_shutdown(). Returns -EINVAL on error or passes along the return value from _shutdown(). */
int omap_hwmod_shutdown(struct omap_hwmod *oh) | {
if (!oh)
return -EINVAL;
mutex_lock(&omap_hwmod_mutex);
_shutdown(oh);
mutex_unlock(&omap_hwmod_mutex);
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This function looks for the highest region of memory lower than 4GB which has enough space for U-Boot where U-Boot is aligned on a page boundary. It overrides the default implementation found elsewhere which simply picks the end of ram, wherever that may be. The location of the stack, the relocation address, and how far U-Boot is moved by relocation are set in the global data structure. */ | ulong board_get_usable_ram_top(ulong total_size) | /* This function looks for the highest region of memory lower than 4GB which has enough space for U-Boot where U-Boot is aligned on a page boundary. It overrides the default implementation found elsewhere which simply picks the end of ram, wherever that may be. The location of the stack, the relocation address, and how far U-Boot is moved by relocation are set in the global data structure. */
ulong board_get_usable_ram_top(ulong total_size) | {
uintptr_t dest_addr = 0;
int i;
for (i = 0; i < lib_sysinfo.n_memranges; i++) {
struct memrange *memrange = &lib_sysinfo.memrange[i];
uint64_t start = roundup(memrange->base, 1 << 12);
uint64_t end = memrange->base + memrange->size;
if (memrange->type != CB_MEM_RAM)
continue;
if (end > 0xffffffffULL)
end = 0x100000000ULL;
if (end - start < total_size)
continue;
if (end > dest_addr)
dest_addr = end;
}
if (!dest_addr)
panic("No available memory found for relocation");
return (ulong)dest_addr;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Before you start, select your target, on the right of the "Load" button */ | int main(void) | /* Before you start, select your target, on the right of the "Load" button */
int main(void) | {
TM_RTC_WriteBackupRegister(4, 0x1244);
TM_DISCO_LedOn(LED_RED);
} else {
if (TM_RTC_ReadBackupRegister(4) == 0x1244) {
TM_DISCO_LedOn(LED_GREEN);
}
}
while (1) {
if (TM_DISCO_ButtonPressed()) {
NVIC_SystemReset();
}
}
} | MaJerle/stm32f429 | C++ | null | 2,036 |
/* Maps in a memory region such that it can be used for performing a DMA. */ | int dma_map_start(DMA_MemMap_t *memMap, enum dma_data_direction dir) | /* Maps in a memory region such that it can be used for performing a DMA. */
int dma_map_start(DMA_MemMap_t *memMap, enum dma_data_direction dir) | {
int rc;
down(&memMap->lock);
DMA_MAP_PRINT("memMap: %p\n", memMap);
if (memMap->inUse) {
printk(KERN_ERR "%s: memory map %p is already being used\n",
__func__, memMap);
rc = -EBUSY;
goto out;
}
memMap->inUse = 1;
memMap->dir = dir;
memMap->numRegionsUsed = 0;
rc = 0;
out:
DMA_MAP_PRINT("returning %d", rc);
up(&memMap->lock);
return rc;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This function looks for the device configuration based on the unique device ID. The table XGpioPs_ConfigTable contains the configuration information for each device in the system. */ | XGpioPs_Config* XGpioPs_LookupConfig(u16 DeviceId) | /* This function looks for the device configuration based on the unique device ID. The table XGpioPs_ConfigTable contains the configuration information for each device in the system. */
XGpioPs_Config* XGpioPs_LookupConfig(u16 DeviceId) | {
XGpioPs_Config *CfgPtr = NULL;
u32 Index;
for (Index = 0U; Index < (u32)XPAR_XGPIOPS_NUM_INSTANCES; Index++) {
if (XGpioPs_ConfigTable[Index].DeviceId == DeviceId) {
CfgPtr = &XGpioPs_ConfigTable[Index];
break;
}
}
return (XGpioPs_Config *)CfgPtr;
}
/** @} | ua1arn/hftrx | C++ | null | 69 |
/* Clears RTC compare match flag.
Clears the compare flag. The compare flag is set when there is a compare match between the counter and the compare. */ | enum status_code rtc_count_clear_compare_match(struct rtc_module *const module, const enum rtc_count_compare comp_index) | /* Clears RTC compare match flag.
Clears the compare flag. The compare flag is set when there is a compare match between the counter and the compare. */
enum status_code rtc_count_clear_compare_match(struct rtc_module *const module, const enum rtc_count_compare comp_index) | {
Assert(module);
Assert(module->hw);
Rtc *const rtc_module = module->hw;
switch (module->mode){
case RTC_COUNT_MODE_32BIT:
if (comp_index > RTC_NUM_OF_COMP32) {
return STATUS_ERR_INVALID_ARG;
}
break;
case RTC_COUNT_MODE_16BIT:
if (comp_index > RTC_NUM_OF_COMP16) {
return STATUS_ERR_INVALID_ARG;
}
break;
default:
Assert(false);
return STATUS_ERR_BAD_FORMAT;
}
rtc_module->MODE0.INTFLAG.reg = RTC_MODE1_INTFLAG_CMP(1 << comp_index);
return STATUS_OK;
} | memfault/zero-to-main | C++ | null | 200 |
/* Check, if the block is bad. Either by reading the bad block table or calling of the scan function. */ | static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int allowbbt) | /* Check, if the block is bad. Either by reading the bad block table or calling of the scan function. */
static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int allowbbt) | {
struct nand_chip *chip = mtd_to_nand(mtd);
if (!(chip->options & NAND_SKIP_BBTSCAN) &&
!(chip->options & NAND_BBT_SCANNED)) {
chip->options |= NAND_BBT_SCANNED;
chip->scan_bbt(mtd);
}
if (!chip->bbt)
return chip->block_bad(mtd, ofs);
return nand_isbad_bbt(mtd, ofs, allowbbt);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* libc/string/strcspn.c Finds in a string the last occurrence of a byte not in a set */ | size_t strcspn(const char *s, const char *reject) | /* libc/string/strcspn.c Finds in a string the last occurrence of a byte not in a set */
size_t strcspn(const char *s, const char *reject) | {
const char * p;
const char * r;
size_t count = 0;
for (p = s; *p != '\0'; ++p)
{
for (r = reject; *r != '\0'; ++r)
{
if (*p == *r)
return count;
}
++count;
}
return count;
} | xboot/xboot | C++ | MIT License | 779 |
/* Check if there is any duplicate of the current setting.
This function checks if there is any duplicated data further in the buffer. */ | static bool settings_fcb_check_duplicate(struct settings_fcb *cf, const struct fcb_entry_ctx *entry_ctx, const char *const name) | /* Check if there is any duplicate of the current setting.
This function checks if there is any duplicated data further in the buffer. */
static bool settings_fcb_check_duplicate(struct settings_fcb *cf, const struct fcb_entry_ctx *entry_ctx, const char *const name) | {
struct fcb_entry_ctx entry2_ctx = *entry_ctx;
while (fcb_getnext(&cf->cf_fcb, &entry2_ctx.loc) == 0) {
char name2[SETTINGS_MAX_NAME_LEN + SETTINGS_EXTRA_LEN + 1];
size_t name2_len;
if (settings_line_name_read(name2, sizeof(name2), &name2_len,
&entry2_ctx)) {
LOG_ERR("failed to load line");
continue;
}
name2[name2_len] = '\0';
if (!strcmp(name, name2)) {
return true;
}
}
return false;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Rearrange the destination address in @iph and the addresses in @rthdr so that they appear in the order they will at the final destination. See Appendix A2 of RFC 2402 for details. */ | static void ipv6_rearrange_rthdr(struct ipv6hdr *iph, struct ipv6_rt_hdr *rthdr) | /* Rearrange the destination address in @iph and the addresses in @rthdr so that they appear in the order they will at the final destination. See Appendix A2 of RFC 2402 for details. */
static void ipv6_rearrange_rthdr(struct ipv6hdr *iph, struct ipv6_rt_hdr *rthdr) | {
int segments, segments_left;
struct in6_addr *addrs;
struct in6_addr final_addr;
segments_left = rthdr->segments_left;
if (segments_left == 0)
return;
rthdr->segments_left = 0;
segments = rthdr->hdrlen >> 1;
addrs = ((struct rt0_hdr *)rthdr)->addr;
ipv6_addr_copy(&final_addr, addrs + segments - 1);
addrs += segments - segments_left;
memmove(addrs + 1, addrs, (segments_left - 1) * sizeof(*addrs));
ipv6_addr_copy(addrs, &iph->daddr);
ipv6_addr_copy(&iph->daddr, &final_addr);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Fills each USART_ClockInitStruct member with its default value. */ | void USART_ClockStructInit(USART_ClockInitType *USART_ClockInitStruct) | /* Fills each USART_ClockInitStruct member with its default value. */
void USART_ClockStructInit(USART_ClockInitType *USART_ClockInitStruct) | {
USART_ClockInitStruct->Clock = USART_CLK_DISABLE;
USART_ClockInitStruct->Polarity = USART_CLKPOL_LOW;
USART_ClockInitStruct->Phase = USART_CLKPHA_1EDGE;
USART_ClockInitStruct->LastBit = USART_CLKLB_DISABLE;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* param base PDM base pointer param config Voice activity detector noise filter configure structure pointer . */ | void PDM_SetHwvadNoiseFilterConfig(PDM_Type *base, const pdm_hwvad_noise_filter_t *config) | /* param base PDM base pointer param config Voice activity detector noise filter configure structure pointer . */
void PDM_SetHwvadNoiseFilterConfig(PDM_Type *base, const pdm_hwvad_noise_filter_t *config) | {
assert(config != NULL);
base->VAD0_NCONFIG =
(PDM_VAD0_NCONFIG_VADNFILAUTO(config->enableAutoNoiseFilter) |
PDM_VAD0_NCONFIG_VADNOREN(config->enableNoiseDetectOR) | PDM_VAD0_NCONFIG_VADNMINEN(config->enableNoiseMin) |
PDM_VAD0_NCONFIG_VADNDECEN(config->enableNoiseDecimation) |
PDM_VAD0_NCONFIG_VADNFILADJ(config->noiseFilterAdjustment) | PDM_VAD0_NCONFIG_VADNGAIN(config->noiseGain));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Return the clockdomain's current state transition mode from the corresponding domain CM_CLKSTCTRL register. Returns -EINVAL if clk is NULL or the current mode upon success. */ | static int omap2_clkdm_clktrctrl_read(struct clockdomain *clkdm) | /* Return the clockdomain's current state transition mode from the corresponding domain CM_CLKSTCTRL register. Returns -EINVAL if clk is NULL or the current mode upon success. */
static int omap2_clkdm_clktrctrl_read(struct clockdomain *clkdm) | {
u32 v;
if (!clkdm)
return -EINVAL;
v = cm_read_mod_reg(clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);
v &= clkdm->clktrctrl_mask;
v >>= __ffs(clkdm->clktrctrl_mask);
return v;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Restart an (async) RPC call from the call_prepare state. Usually called from within the exit handler. */ | void rpc_restart_call_prepare(struct rpc_task *task) | /* Restart an (async) RPC call from the call_prepare state. Usually called from within the exit handler. */
void rpc_restart_call_prepare(struct rpc_task *task) | {
if (RPC_ASSASSINATED(task))
return;
task->tk_action = rpc_prepare_task;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* release_open_intent - free up open intent resources @nd: pointer to nameidata */ | void release_open_intent(struct nameidata *nd) | /* release_open_intent - free up open intent resources @nd: pointer to nameidata */
void release_open_intent(struct nameidata *nd) | {
if (nd->intent.open.file->f_path.dentry == NULL)
put_filp(nd->intent.open.file);
else
fput(nd->intent.open.file);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Enable or disable the specified hardware stop condition. */ | void TMR2_HWStopCondCmd(CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch, uint32_t u32Cond, en_functional_state_t enNewState) | /* Enable or disable the specified hardware stop condition. */
void TMR2_HWStopCondCmd(CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch, uint32_t u32Cond, en_functional_state_t enNewState) | {
DDL_ASSERT(IS_TMR2_UNIT(TMR2x));
DDL_ASSERT(IS_TMR2_CH(u32Ch));
DDL_ASSERT(IS_TMR2_STOP_COND(u32Cond));
DDL_ASSERT(IS_FUNCTIONAL_STATE(enNewState));
u32Cond <<= (u32Ch * TMR2_CH_OFFSET);
if (enNewState == ENABLE) {
SET_REG32_BIT(TMR2x->HCONR, u32Cond);
} else {
CLR_REG32_BIT(TMR2x->HCONR, u32Cond);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function is used to unregister drivers using the composite driver framework. */ | void usb_composite_unregister(struct usb_composite_driver *driver) | /* This function is used to unregister drivers using the composite driver framework. */
void usb_composite_unregister(struct usb_composite_driver *driver) | {
if (composite != driver)
return;
usb_gadget_unregister_driver(&composite_driver);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Preprocess dependency expression and update DriverEntry to reflect the state of Before and After dependencies. If DriverEntry->Before or DriverEntry->After is set it will never be cleared. */ | EFI_STATUS SmmPreProcessDepex(IN EFI_SMM_DRIVER_ENTRY *DriverEntry) | /* Preprocess dependency expression and update DriverEntry to reflect the state of Before and After dependencies. If DriverEntry->Before or DriverEntry->After is set it will never be cleared. */
EFI_STATUS SmmPreProcessDepex(IN EFI_SMM_DRIVER_ENTRY *DriverEntry) | {
UINT8 *Iterator;
Iterator = DriverEntry->Depex;
DriverEntry->Dependent = TRUE;
if (*Iterator == EFI_DEP_BEFORE) {
DriverEntry->Before = TRUE;
} else if (*Iterator == EFI_DEP_AFTER) {
DriverEntry->After = TRUE;
}
if (DriverEntry->Before || DriverEntry->After) {
CopyMem (&DriverEntry->BeforeAfterGuid, Iterator + 1, sizeof (EFI_GUID));
}
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Open a file and copy its content to a buffer. */ | uint32_t Storage_CheckBitmapFile(const char *BmpName, uint32_t *FileLen) | /* Open a file and copy its content to a buffer. */
uint32_t Storage_CheckBitmapFile(const char *BmpName, uint32_t *FileLen) | {
if(f_mount(&fs, (TCHAR const*)"",0))
{
return 1;
}
if(f_open (&F, (TCHAR const*)BmpName, FA_READ))
{
return 2;
}
f_read (&F, sector, 6, (UINT *)&BytesRead);
if (Buffercmp((uint8_t *)SlidesCheck, (uint8_t *) sector, 2) != 0)
{
return 3;
}
return 0;
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* If the page does not get brought uptodate, return -EIO. */ | struct page* read_cache_page_async(struct address_space *mapping, pgoff_t index, int(*filler)(void *, struct page *), void *data) | /* If the page does not get brought uptodate, return -EIO. */
struct page* read_cache_page_async(struct address_space *mapping, pgoff_t index, int(*filler)(void *, struct page *), void *data) | {
return do_read_cache_page(mapping, index, filler, data, mapping_gfp_mask(mapping));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Return: 0 on success, -1 if the module can't be powered up, or if there is a timeout waiting for the transition. */ | int psc_enable_module(u32 mod_num) | /* Return: 0 on success, -1 if the module can't be powered up, or if there is a timeout waiting for the transition. */
int psc_enable_module(u32 mod_num) | {
u32 mdctl;
mdctl = __raw_readl(KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
if ((mdctl & 0x3f) == PSC_REG_VAL_MDSTAT_STATE_ON)
return 0;
return psc_set_state(mod_num, PSC_REG_VAL_MDCTL_NEXT_ON);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* get a byte (8bits) from a pointer
Caller should ensure parameters are valid. */ | uint8_t BytesGet8(const void *ptr) | /* get a byte (8bits) from a pointer
Caller should ensure parameters are valid. */
uint8_t BytesGet8(const void *ptr) | {
const uint8_t *p = (const uint8_t *)ptr;
return p[0];
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Lookup the data. This is trivial - if the dentry didn't already exist, we know it is negative. Set d_op to delete negative dentries. */ | struct dentry* simple_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | /* Lookup the data. This is trivial - if the dentry didn't already exist, we know it is negative. Set d_op to delete negative dentries. */
struct dentry* simple_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | {
static const struct dentry_operations simple_dentry_operations = {
.d_delete = simple_delete_dentry,
};
if (dentry->d_name.len > NAME_MAX)
return ERR_PTR(-ENAMETOOLONG);
dentry->d_op = &simple_dentry_operations;
d_add(dentry, NULL);
return NULL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Send command to store channel/effects setup/amp setup to PODxt Pro. */ | static ssize_t pod_send_store_command(struct device *dev, const char *buf, size_t count, short block0, short block1) | /* Send command to store channel/effects setup/amp setup to PODxt Pro. */
static ssize_t pod_send_store_command(struct device *dev, const char *buf, size_t count, short block0, short block1) | {
struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_pod *pod = usb_get_intfdata(interface);
int ret;
int size = 3 + sizeof(pod->prog_data_buf);
char *sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_STORE, size);
if (!sysex)
return 0;
sysex[SYSEX_DATA_OFS] = 5;
ret = pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS + 1);
if (ret) {
kfree(sysex);
return ret;
}
memcpy(sysex + SYSEX_DATA_OFS + 3, &pod->prog_data_buf, sizeof(pod->prog_data_buf));
line6_send_sysex_message(&pod->line6, sysex, size);
kfree(sysex);
return count;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Set the receive buffer size for a given USB endpoint. */ | uint16_t st_usbfs_set_ep_rx_bufsize(usbd_device *dev, uint8_t ep, uint32_t size) | /* Set the receive buffer size for a given USB endpoint. */
uint16_t st_usbfs_set_ep_rx_bufsize(usbd_device *dev, uint8_t ep, uint32_t size) | {
uint16_t realsize;
(void)dev;
if (size > 62) {
size = ((size - 1) >> 5) & 0x1F;
realsize = (size + 1) << 5;
size |= (1<<5);
} else {
size = (size + 1) >> 1;
realsize = size << 1;
}
USB_SET_EP_RX_COUNT(ep, size << 10);
return realsize;
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* Copy the fuse bits values to a RAM buffer. */ | static void mem_configuration_read(void *dst, isp_addr_t src, uint16_t nbytes) | /* Copy the fuse bits values to a RAM buffer. */
static void mem_configuration_read(void *dst, isp_addr_t src, uint16_t nbytes) | {
U8 *dest = dst;
while (nbytes--) {
*dest++ = flash_api_read_gp_fuse_bit(src++);
}
} | memfault/zero-to-main | C++ | null | 200 |
/* Reads a page of data from an emulated RWW EEPROM memory page.
Reads an emulated RWW EEPROM page of data from the emulated RWW EEPROM memory space. */ | enum status_code rww_eeprom_emulator_read_page(const uint8_t logical_page, uint8_t *const data) | /* Reads a page of data from an emulated RWW EEPROM memory page.
Reads an emulated RWW EEPROM page of data from the emulated RWW EEPROM memory space. */
enum status_code rww_eeprom_emulator_read_page(const uint8_t logical_page, uint8_t *const data) | {
if (_eeprom_instance.initialized == false) {
return STATUS_ERR_NOT_INITIALIZED;
}
if (logical_page >= _eeprom_instance.logical_pages) {
return STATUS_ERR_BAD_ADDRESS;
}
if ((_eeprom_instance.cache_active == true) &&
(_eeprom_instance.cache.header.logical_page == logical_page)) {
memcpy(data, _eeprom_instance.cache.data, RWW_EEPROM_PAGE_SIZE);
} else {
struct _rww_eeprom_page temp;
if (_rww_eeprom_emulator_nvm_read_page(
_eeprom_instance.page_map[logical_page], &temp)){
memcpy(data, temp.data, RWW_EEPROM_PAGE_SIZE);
}else{
memcpy(data, temp.data, RWW_EEPROM_PAGE_SIZE);
return STATUS_ERR_BAD_FORMAT;
}
}
return STATUS_OK;
} | memfault/zero-to-main | C++ | null | 200 |
/* param base ENET peripheral base address. param phyAddr The PHY address. param phyReg The PHY register. param data The data written to PHY. */ | void ENET_QOS_StartSMIWrite(ENET_QOS_Type *base, uint32_t phyAddr, uint32_t phyReg, uint32_t data) | /* param base ENET peripheral base address. param phyAddr The PHY address. param phyReg The PHY register. param data The data written to PHY. */
void ENET_QOS_StartSMIWrite(ENET_QOS_Type *base, uint32_t phyAddr, uint32_t phyReg, uint32_t data) | {
uint32_t reg = base->MAC_MDIO_ADDRESS & ENET_QOS_MAC_MDIO_ADDRESS_CR_MASK;
base->MAC_MDIO_ADDRESS = reg | (uint32_t)kENET_QOS_MiiWriteFrame | ENET_QOS_MAC_MDIO_ADDRESS_PA(phyAddr) |
ENET_QOS_MAC_MDIO_ADDRESS_RDA(phyReg);
base->MAC_MDIO_DATA = data;
base->MAC_MDIO_ADDRESS |= ENET_QOS_MAC_MDIO_ADDRESS_GB_MASK;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Queue a mailbox command request to firmware. Waits if mailbox is busy. Responsibility of caller to serialize */ | void bfa_ioc_mbox_queue(struct bfa_ioc_s *ioc, struct bfa_mbox_cmd_s *cmd) | /* Queue a mailbox command request to firmware. Waits if mailbox is busy. Responsibility of caller to serialize */
void bfa_ioc_mbox_queue(struct bfa_ioc_s *ioc, struct bfa_mbox_cmd_s *cmd) | {
struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod;
u32 stat;
if (!list_empty(&mod->cmd_q)) {
list_add_tail(&cmd->qe, &mod->cmd_q);
return;
}
stat = bfa_reg_read(ioc->ioc_regs.hfn_mbox_cmd);
if (stat) {
list_add_tail(&cmd->qe, &mod->cmd_q);
return;
}
bfa_ioc_mbox_send(ioc, cmd->msg, sizeof(cmd->msg));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Checks whether the specified RCC flag is set or not. */ | FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG) | /* Checks whether the specified RCC flag is set or not. */
FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG) | {
uint32_t tmp = 0;
uint32_t statusreg = 0;
FlagStatus bitstatus = RESET;
assert_param(IS_RCC_FLAG(RCC_FLAG));
tmp = RCC_FLAG >> 5;
if (tmp == 1)
{
statusreg = RCC->CR;
}
else if (tmp == 2)
{
statusreg = RCC->BDCR;
}
else
{
statusreg = RCC->CSR;
}
tmp = RCC_FLAG & FLAG_MASK;
if ((statusreg & ((uint32_t)1 << tmp)) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
} | MaJerle/stm32f429 | C++ | null | 2,036 |
/* Called by the SCLP to report incoming event buffers. */ | static void sclp_vt220_receiver_fn(struct evbuf_header *evbuf) | /* Called by the SCLP to report incoming event buffers. */
static void sclp_vt220_receiver_fn(struct evbuf_header *evbuf) | {
char *buffer;
unsigned int count;
if (sclp_vt220_tty == NULL)
return;
buffer = (char *) ((addr_t) evbuf + sizeof(struct evbuf_header));
count = evbuf->length - sizeof(struct evbuf_header);
switch (*buffer) {
case SCLP_VT220_SESSION_ENDED:
case SCLP_VT220_SESSION_STARTED:
break;
case SCLP_VT220_SESSION_DATA:
buffer++;
count--;
tty_insert_flip_string(sclp_vt220_tty, buffer, count);
tty_flip_buffer_push(sclp_vt220_tty);
break;
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Locking: Caller. Returns: -EINVAL if IPM is not supported, 0 otherwise. */ | void ata_dev_enable_pm(struct ata_device *dev, enum link_pm policy) | /* Locking: Caller. Returns: -EINVAL if IPM is not supported, 0 otherwise. */
void ata_dev_enable_pm(struct ata_device *dev, enum link_pm policy) | {
int rc = 0;
struct ata_port *ap = dev->link->ap;
if (ap->ops->enable_pm)
rc = ap->ops->enable_pm(ap, policy);
if (rc)
goto enable_pm_out;
rc = ata_dev_set_dipm(dev, policy);
enable_pm_out:
if (rc)
ap->pm_policy = MAX_PERFORMANCE;
else
ap->pm_policy = policy;
return;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Flash channel enable asserted flag. A 0-to-1 or 1-to-0 transition on "Flash Access Channel Enable" bit. */ | static void espi_it8xxx2_flash_ch_en_isr(const struct device *dev, bool enable) | /* Flash channel enable asserted flag. A 0-to-1 or 1-to-0 transition on "Flash Access Channel Enable" bit. */
static void espi_it8xxx2_flash_ch_en_isr(const struct device *dev, bool enable) | {
if (enable) {
espi_it8xxx2_send_vwire(dev, ESPI_VWIRE_SIGNAL_SLV_BOOT_STS, 1);
espi_it8xxx2_send_vwire(dev,
ESPI_VWIRE_SIGNAL_SLV_BOOT_DONE, 1);
}
espi_it8xxx2_ch_notify_system_state(dev, ESPI_CHANNEL_FLASH, enable);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* 11.3 Information Element Identifier (IEI) 11.3.1 Alignment octets */ | static guint16 de_bssgp_aligment_octets(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_) | /* 11.3 Information Element Identifier (IEI) 11.3.1 Alignment octets */
static guint16 de_bssgp_aligment_octets(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_) | {
guint32 curr_offset;
curr_offset = offset;
proto_tree_add_item(tree, hf_bssgp_spare, tvb, curr_offset, len, ENC_NA);
return(len);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Signals an event group by placing a new event in the group temporarily and signaling it. */ | EFI_STATUS EFIAPI EfiEventGroupSignal(IN CONST EFI_GUID *EventGroup) | /* Signals an event group by placing a new event in the group temporarily and signaling it. */
EFI_STATUS EFIAPI EfiEventGroupSignal(IN CONST EFI_GUID *EventGroup) | {
EFI_STATUS Status;
EFI_EVENT Event;
if (EventGroup == NULL) {
return EFI_INVALID_PARAMETER;
}
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_CALLBACK,
EfiEventEmptyFunction,
NULL,
EventGroup,
&Event
);
if (EFI_ERROR (Status)) {
return Status;
}
Status = gBS->SignalEvent (Event);
gBS->CloseEvent (Event);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Returns: the value of @symbol in the current scope, or NULL if @symbol is not bound in the current scope */ | gpointer g_scanner_lookup_symbol(GScanner *scanner, const gchar *symbol) | /* Returns: the value of @symbol in the current scope, or NULL if @symbol is not bound in the current scope */
gpointer g_scanner_lookup_symbol(GScanner *scanner, const gchar *symbol) | {
GScannerKey *key;
guint scope_id;
g_return_val_if_fail (scanner != NULL, NULL);
if (!symbol)
return NULL;
scope_id = scanner->scope_id;
key = g_scanner_lookup_internal (scanner, scope_id, symbol);
if (!key && scope_id && scanner->config->scope_0_fallback)
key = g_scanner_lookup_internal (scanner, 0, symbol);
if (key)
return key->value;
else
return NULL;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Lock POSIX mutex with non-blocking call.
See IEEE 1003.1 */ | int pthread_mutex_trylock(pthread_mutex_t *m) | /* Lock POSIX mutex with non-blocking call.
See IEEE 1003.1 */
int pthread_mutex_trylock(pthread_mutex_t *m) | {
return acquire_mutex(m, K_NO_WAIT);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Get the list of all available shell internal commands. This is a linked list (via LIST_ENTRY structure). enumerate through it using the BaseLib linked list functions. do not modify the values. */ | CONST COMMAND_LIST* EFIAPI ShellCommandGetCommandList(IN CONST BOOLEAN Sort) | /* Get the list of all available shell internal commands. This is a linked list (via LIST_ENTRY structure). enumerate through it using the BaseLib linked list functions. do not modify the values. */
CONST COMMAND_LIST* EFIAPI ShellCommandGetCommandList(IN CONST BOOLEAN Sort) | {
return ((COMMAND_LIST *)(&mCommandList));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Get the dimensions of the display and of the current clipping area. */ | EMSTATUS DMD_getDisplayGeometry(DMD_DisplayGeometry **geometry) | /* Get the dimensions of the display and of the current clipping area. */
EMSTATUS DMD_getDisplayGeometry(DMD_DisplayGeometry **geometry) | {
if (!initialized)
{
return DMD_ERROR_DRIVER_NOT_INITIALIZED;
}
*geometry = &dimensions;
return DMD_OK;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* If the linux inode is valid, mark it dirty. Used when commiting a dirty inode into a transaction so that the inode will get written back by the linux code */ | void xfs_mark_inode_dirty_sync(xfs_inode_t *ip) | /* If the linux inode is valid, mark it dirty. Used when commiting a dirty inode into a transaction so that the inode will get written back by the linux code */
void xfs_mark_inode_dirty_sync(xfs_inode_t *ip) | {
struct inode *inode = VFS_I(ip);
if (!(inode->i_state & (I_WILL_FREE|I_FREEING|I_CLEAR)))
mark_inode_dirty_sync(inode);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Enables or disables the TIMx peripheral Preload register on CCR2. */ | void TIM_OC2PreloadConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCPreload) | /* Enables or disables the TIMx peripheral Preload register on CCR2. */
void TIM_OC2PreloadConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCPreload) | {
uint16_t tmpccmr1 = 0;
assert_param(IS_TIM_LIST6_PERIPH(TIMx));
assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload));
tmpccmr1 = TIMx->CCMR1;
tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC2PE);
tmpccmr1 |= (uint16_t)(TIM_OCPreload << 8);
TIMx->CCMR1 = tmpccmr1;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* !brief Release the channel map array allocated via #snd_pcm_query_chmaps */ | void snd_pcm_free_chmaps(snd_pcm_chmap_query_t **maps) | /* !brief Release the channel map array allocated via #snd_pcm_query_chmaps */
void snd_pcm_free_chmaps(snd_pcm_chmap_query_t **maps) | {
snd_pcm_chmap_query_t **p;
if (!maps)
return;
for (p = maps; *p; p++)
free(*p);
free(maps);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* USB Device Set Address Function Parameters: adr: USB Device Address setup: Called in setup stage (!=0), else after status stage Return Value: None */ | void USBD_SetAddress(uint32_t adr, uint32_t setup) | /* USB Device Set Address Function Parameters: adr: USB Device Address setup: Called in setup stage (!=0), else after status stage Return Value: None */
void USBD_SetAddress(uint32_t adr, uint32_t setup) | {
if (setup) {
return;
}
if (adr) {
UDPHS->UDPHS_CTRL |= (UDPHS_CTRL_FADDR_EN | adr);
} else {
UDPHS->UDPHS_CTRL &= ~(UDPHS_CTRL_FADDR_EN | UDPHS_CTRL_DEV_ADDR_Msk);
}
} | ARMmbed/DAPLink | C++ | Apache License 2.0 | 2,140 |
/* Heart beat timer handler, queues the DPC at TPL_CALLBACK. */ | VOID EFIAPI TcpTicking(IN EFI_EVENT Event, IN VOID *Context) | /* Heart beat timer handler, queues the DPC at TPL_CALLBACK. */
VOID EFIAPI TcpTicking(IN EFI_EVENT Event, IN VOID *Context) | {
QueueDpc (TPL_CALLBACK, TcpTickingDpc, Context);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Return: 0 if the link was established successfully, -ve on error */ | static int establish_link(struct udevice *dev) | /* Return: 0 if the link was established successfully, -ve on error */
static int establish_link(struct udevice *dev) | {
struct dp_tx *dp_tx = dev_get_priv(dev);
int status;
int status2;
u32 mask;
reset_dp_phy(dev, PHY_CONFIG_PHY_RESET_MASK);
disable_main_link(dev);
mask = phy_status_lanes_ready_mask(dp_tx->max_lane_count);
status = wait_phy_ready(dev, mask);
if (status)
return -EIO;
status = run_training(dev);
status2 = set_training_pattern(dev, TRAINING_PATTERN_SET_OFF);
if (status || status2)
return -EIO;
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Generate a syncookie. mssp points to the mss, which is returned rounded down to the value encoded in the cookie. */ | __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp) | /* Generate a syncookie. mssp points to the mss, which is returned rounded down to the value encoded in the cookie. */
__u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp) | {
const struct iphdr *iph = ip_hdr(skb);
const struct tcphdr *th = tcp_hdr(skb);
int mssind;
const __u16 mss = *mssp;
tcp_synq_overflow(sk);
for (mssind = 0; mss > msstab[mssind + 1]; mssind++)
;
*mssp = msstab[mssind] + 1;
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESSENT);
return secure_tcp_syn_cookie(iph->saddr, iph->daddr,
th->source, th->dest, ntohl(th->seq),
jiffies / (HZ * 60), mssind);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Config all pins to the right pull state based on pmap_func table after soc wakeup from sleep. */ | CONFIG_FW_CRITICAL_CODE_SECTION void pinmap_wake(void) | /* Config all pins to the right pull state based on pmap_func table after soc wakeup from sleep. */
CONFIG_FW_CRITICAL_CODE_SECTION void pinmap_wake(void) | {
int i = 0;
int PinName = 0;
for (;;) {
if (pmap_func_sleep[i].PinName == _PNC) {
break;
}
if (pmap_func_sleep[i].SleepPuPd == GPIO_PuPd_KEEP)
goto next;
PinName = pmap_func_sleep[i].PinName;
if (pmap_func[PinName].FuncPuPd == GPIO_PuPd_SHUTDOWN) {
PAD_CMD(PinName, DISABLE);
} else {
PAD_PullCtrl(PinName, pmap_func[PinName].FuncPuPd);
}
next:
i++;
}
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Calls the switch specific add_entry() method to add a route entry on a switch. The route table can be specified using the @table argument if a switch has per port routing tables or the normal use is to specific all tables (or the global table) by passing RIO_GLOBAL_TABLE in @table. Returns %0 on success or %-EINVAL on failure. */ | static int rio_route_add_entry(struct rio_mport *mport, struct rio_switch *rswitch, u16 table, u16 route_destid, u8 route_port) | /* Calls the switch specific add_entry() method to add a route entry on a switch. The route table can be specified using the @table argument if a switch has per port routing tables or the normal use is to specific all tables (or the global table) by passing RIO_GLOBAL_TABLE in @table. Returns %0 on success or %-EINVAL on failure. */
static int rio_route_add_entry(struct rio_mport *mport, struct rio_switch *rswitch, u16 table, u16 route_destid, u8 route_port) | {
return rswitch->add_entry(mport, rswitch->destid,
rswitch->hopcount, table,
route_destid, route_port);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Read len bytes from the chip into a buffer */ | static void read_buf(struct mtd_info *mtd, uint8_t *buf, int len) | /* Read len bytes from the chip into a buffer */
static void read_buf(struct mtd_info *mtd, uint8_t *buf, int len) | {
int i, s;
unsigned int reg;
struct nand_chip *chip = mtd_to_nand(mtd);
struct nand_drv *info = (struct nand_drv *)nand_get_controller_data(chip);
for (i = 0; i < len; i += 4) {
s = (len - i) > 4 ? 4 : len - i;
writel(CMD_PIO | CMD_RX | CMD_A_VALID | CMD_CE0 |
((s - 1) << CMD_TRANS_SIZE_SHIFT) | CMD_GO,
&info->reg->command);
if (!nand_waitfor_cmd_completion(info->reg))
puts("Command timeout during read_buf\n");
reg = readl(&info->reg->resp);
memcpy(buf + i, ®, s);
}
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* This function will sleep at least once waiting for new free space to show up, and then it will check the block group free space numbers for our min num_bytes. Another option is to have it go ahead and look in the rbtree for a free extent of a given size, but this is a good start. */ | static noinline int wait_block_group_cache_progress(struct btrfs_block_group_cache *cache, u64 num_bytes) | /* This function will sleep at least once waiting for new free space to show up, and then it will check the block group free space numbers for our min num_bytes. Another option is to have it go ahead and look in the rbtree for a free extent of a given size, but this is a good start. */
static noinline int wait_block_group_cache_progress(struct btrfs_block_group_cache *cache, u64 num_bytes) | {
struct btrfs_caching_control *caching_ctl;
DEFINE_WAIT(wait);
caching_ctl = get_caching_control(cache);
if (!caching_ctl)
return 0;
wait_event(caching_ctl->wait, block_group_cache_done(cache) ||
(cache->free_space >= num_bytes));
put_caching_control(caching_ctl);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* The return value is the rounded version of the @j parameter. */ | unsigned long round_jiffies_relative(unsigned long j) | /* The return value is the rounded version of the @j parameter. */
unsigned long round_jiffies_relative(unsigned long j) | {
return __round_jiffies_relative(j, raw_smp_processor_id());
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Set, replace or remove an extended attribute into inode block. */ | static int ocfs2_xattr_ibody_set(struct inode *inode, struct ocfs2_xattr_info *xi, struct ocfs2_xattr_search *xs, struct ocfs2_xattr_set_ctxt *ctxt) | /* Set, replace or remove an extended attribute into inode block. */
static int ocfs2_xattr_ibody_set(struct inode *inode, struct ocfs2_xattr_info *xi, struct ocfs2_xattr_search *xs, struct ocfs2_xattr_set_ctxt *ctxt) | {
struct ocfs2_inode_info *oi = OCFS2_I(inode);
struct ocfs2_dinode *di = (struct ocfs2_dinode *)xs->inode_bh->b_data;
int ret;
if (inode->i_sb->s_blocksize == OCFS2_MIN_BLOCKSIZE)
return -ENOSPC;
down_write(&oi->ip_alloc_sem);
if (!(oi->ip_dyn_features & OCFS2_INLINE_XATTR_FL)) {
if (!ocfs2_xattr_has_space_inline(inode, di)) {
ret = -ENOSPC;
goto out;
}
}
ret = ocfs2_xattr_set_entry(inode, xi, xs, ctxt,
(OCFS2_INLINE_XATTR_FL | OCFS2_HAS_XATTR_FL));
out:
up_write(&oi->ip_alloc_sem);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This routine will return true only if the device node is a hotpluggable slot. This routine will return false for built-in pci slots (even when the built-in slots are dlparable.) */ | static int is_php_dn(struct device_node *dn, const int **indexes, const int **names, const int **types, const int **power_domains) | /* This routine will return true only if the device node is a hotpluggable slot. This routine will return false for built-in pci slots (even when the built-in slots are dlparable.) */
static int is_php_dn(struct device_node *dn, const int **indexes, const int **names, const int **types, const int **power_domains) | {
const int *drc_types;
int rc;
rc = get_children_props(dn, indexes, names, &drc_types, power_domains);
if (rc < 0)
return 0;
if (!is_php_type((char *) &drc_types[1]))
return 0;
*types = drc_types;
return 1;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function Deletes a Task.
Deletes a Task and remove it from list of running task */ | void osi_TaskDelete(OsiTaskHandle *pTaskHandle) | /* This function Deletes a Task.
Deletes a Task and remove it from list of running task */
void osi_TaskDelete(OsiTaskHandle *pTaskHandle) | {
vTaskDelete((TaskHandle_t)*pTaskHandle);
} | micropython/micropython | C++ | Other | 18,334 |
/* this function handles External lines 21 and 22 interrupt exception */ | void ADC_CMP_IRQHandler(void) | /* this function handles External lines 21 and 22 interrupt exception */
void ADC_CMP_IRQHandler(void) | {
if(RESET != exti_interrupt_flag_get(EXTI_21)){
gd_eval_ledon(LED2);
exti_interrupt_flag_clear(EXTI_21);
}
} | liuxuming/trochili | C++ | Apache License 2.0 | 132 |
/* Process Option Rom on the specified host bridge. */ | EFI_STATUS PciHostBridgeP2CProcess(IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc) | /* Process Option Rom on the specified host bridge. */
EFI_STATUS PciHostBridgeP2CProcess(IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc) | {
EFI_HANDLE RootBridgeHandle;
PCI_IO_DEVICE *RootBridgeDev;
EFI_STATUS Status;
if (!FeaturePcdGet (PcdPciBusHotplugDeviceSupport)) {
return EFI_SUCCESS;
}
RootBridgeHandle = NULL;
while (PciResAlloc->GetNextRootBridge (PciResAlloc, &RootBridgeHandle) == EFI_SUCCESS) {
RootBridgeDev = GetRootBridgeByHandle (RootBridgeHandle);
if (RootBridgeDev == NULL) {
return EFI_NOT_FOUND;
}
Status = PciRootBridgeP2CProcess (RootBridgeDev);
if (EFI_ERROR (Status)) {
return Status;
}
}
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Locking: Called functions take ldisc and termios_rwsem locks */ | static int set_termios(struct tty_struct *tty, void *arg, int opt) | /* Locking: Called functions take ldisc and termios_rwsem locks */
static int set_termios(struct tty_struct *tty, void *arg, int opt) | {
struct termios old_termios;
struct tty_ldisc *ld = RT_NULL;
struct termios *new_termios = (struct termios *)arg;
rt_base_t level = 0;
int retval = tty_check_change(tty);
if (retval)
{
return retval;
}
memcpy(&old_termios, &(tty->init_termios), sizeof(struct termios));
level = rt_spin_lock_irqsave(&tty->spinlock);
tty->init_termios = *new_termios;
rt_spin_unlock_irqrestore(&tty->spinlock, level);
ld = tty->ldisc;
if (ld != NULL)
{
if (ld->ops->set_termios)
{
ld->ops->set_termios(tty, &old_termios);
}
}
return 0;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Check whether the specified SPI flag is set or not. */ | uint8_t SPI_ReadStatusFlag(SPI_T *spi, SPI_FLAG_T flag) | /* Check whether the specified SPI flag is set or not. */
uint8_t SPI_ReadStatusFlag(SPI_T *spi, SPI_FLAG_T flag) | {
if ((spi->STS & flag) != RESET)
{
return SET;
}
else
{
return RESET;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* rtw_cbuf_free - free the given rtw_cbuf @cbuf: pointer of struct rtw_cbuf to free */ | void rtw_cbuf_free(struct rtw_cbuf *cbuf) | /* rtw_cbuf_free - free the given rtw_cbuf @cbuf: pointer of struct rtw_cbuf to free */
void rtw_cbuf_free(struct rtw_cbuf *cbuf) | {
rtw_mfree((u8*)cbuf, sizeof(*cbuf) + sizeof(void*)*cbuf->size);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Sets TC module count value.
Sets the current timer count value of a initialized TC module. The specified TC module may be started or stopped. */ | enum status_code tc_set_count_value(const struct tc_module *const module_inst, const uint32_t count) | /* Sets TC module count value.
Sets the current timer count value of a initialized TC module. The specified TC module may be started or stopped. */
enum status_code tc_set_count_value(const struct tc_module *const module_inst, const uint32_t count) | {
Assert(module_inst);
Assert(module_inst->hw);
Tc *const tc_module = module_inst->hw;
while (tc_is_syncing(module_inst)) {
}
switch (module_inst->counter_size) {
case TC_COUNTER_SIZE_8BIT:
tc_module->COUNT8.COUNT.reg = (uint8_t)count;
return STATUS_OK;
case TC_COUNTER_SIZE_16BIT:
tc_module->COUNT16.COUNT.reg = (uint16_t)count;
return STATUS_OK;
case TC_COUNTER_SIZE_32BIT:
tc_module->COUNT32.COUNT.reg = (uint32_t)count;
return STATUS_OK;
default:
return STATUS_ERR_INVALID_ARG;
}
} | memfault/zero-to-main | C++ | null | 200 |
/* Starts each SGE queue set's timer call back */ | void t3_start_sge_timers(struct adapter *adap) | /* Starts each SGE queue set's timer call back */
void t3_start_sge_timers(struct adapter *adap) | {
int i;
for (i = 0; i < SGE_QSETS; ++i) {
struct sge_qset *q = &adap->sge.qs[i];
if (q->tx_reclaim_timer.function)
mod_timer(&q->tx_reclaim_timer, jiffies + TX_RECLAIM_PERIOD);
if (q->rx_reclaim_timer.function)
mod_timer(&q->rx_reclaim_timer, jiffies + RX_RECLAIM_PERIOD);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This command desynchronizes the ICAP After this command, a bitstream containing a NULL packet, followed by a SYNCH packet is required before the ICAP will recognize commands. */ | static int hwicap_command_desync(struct hwicap_drvdata *drvdata) | /* This command desynchronizes the ICAP After this command, a bitstream containing a NULL packet, followed by a SYNCH packet is required before the ICAP will recognize commands. */
static int hwicap_command_desync(struct hwicap_drvdata *drvdata) | {
u32 buffer[4];
u32 index = 0;
buffer[index++] = hwicap_type_1_write(drvdata->config_regs->CMD) | 1;
buffer[index++] = XHI_CMD_DESYNCH;
buffer[index++] = XHI_NOOP_PACKET;
buffer[index++] = XHI_NOOP_PACKET;
return drvdata->config->set_configuration(drvdata,
&buffer[0], index);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* register an RxRPC security handler for use by RxRPC */ | int rxrpc_register_security(struct rxrpc_security *sec) | /* register an RxRPC security handler for use by RxRPC */
int rxrpc_register_security(struct rxrpc_security *sec) | {
struct rxrpc_security *psec;
int ret;
_enter("");
down_write(&rxrpc_security_sem);
ret = -EEXIST;
list_for_each_entry(psec, &rxrpc_security_methods, link) {
if (psec->security_index == sec->security_index)
goto out;
}
list_add(&sec->link, &rxrpc_security_methods);
printk(KERN_NOTICE "RxRPC: Registered security type %d '%s'\n",
sec->security_index, sec->name);
ret = 0;
out:
up_write(&rxrpc_security_sem);
_leave(" = %d", ret);
return ret;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This function configures the source of the time base. The time source is configured to have 1ms time base with a dedicated Tick interrupt priority. */ | __weak void ald_tick_init(uint32_t prio) | /* This function configures the source of the time base. The time source is configured to have 1ms time base with a dedicated Tick interrupt priority. */
__weak void ald_tick_init(uint32_t prio) | {
csi_coret_config(ald_cmu_get_sys_clock() / ALD_SYSTICK_INTERVAL_1MS, CLINT_IRQn);
csi_vic_set_prio(CLINT_IRQn, prio);
csi_vic_enable_sirq(CLINT_IRQn);
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Read a single byte from the serial port. Returns 1 on success, 0 otherwise. When the function is succesfull, the character read is written into its argument c. */ | int serial_tstc(void) | /* Read a single byte from the serial port. Returns 1 on success, 0 otherwise. When the function is succesfull, the character read is written into its argument c. */
int serial_tstc(void) | {
return !(IO_SYSFLG1 & SYSFLG1_URXFE);
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Set higher or lower the codec volume level. */ | uint32_t cs42l51_SetVolume(uint16_t DeviceAddr, uint8_t Volume) | /* Set higher or lower the codec volume level. */
uint32_t cs42l51_SetVolume(uint16_t DeviceAddr, uint8_t Volume) | {
uint32_t counter = 0;
uint8_t convertedvol = VOLUME_CONVERT(Volume);
counter += CODEC_IO_Write(DeviceAddr, 0x16, convertedvol);
counter += CODEC_IO_Write(DeviceAddr, 0x17, convertedvol);
return counter;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. Author: Keith Packard, MIT X Consortium Invert bit order within each BYTE of an array. */ | BitOrderInvert(unsigned char *buf, size_t nbytes) | /* Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. Author: Keith Packard, MIT X Consortium Invert bit order within each BYTE of an array. */
BitOrderInvert(unsigned char *buf, size_t nbytes) | {
for ( ; nbytes > 0; nbytes--, buf++ )
{
unsigned int val = *buf;
val = ( ( val >> 1 ) & 0x55 ) | ( ( val << 1 ) & 0xAA );
val = ( ( val >> 2 ) & 0x33 ) | ( ( val << 2 ) & 0xCC );
val = ( ( val >> 4 ) & 0x0F ) | ( ( val << 4 ) & 0xF0 );
*buf = (unsigned char)val;
}
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* param base eDMA peripheral base address. param channel eDMA channel number. param srcModulo A source modulo value. param destModulo A destination modulo value. */ | void EDMA_SetModulo(EDMA_Type *base, uint32_t channel, edma_modulo_t srcModulo, edma_modulo_t destModulo) | /* param base eDMA peripheral base address. param channel eDMA channel number. param srcModulo A source modulo value. param destModulo A destination modulo value. */
void EDMA_SetModulo(EDMA_Type *base, uint32_t channel, edma_modulo_t srcModulo, edma_modulo_t destModulo) | {
assert(channel < (uint32_t)FSL_FEATURE_EDMA_MODULE_CHANNEL(base));
uint16_t tmpreg = EDMA_TCD_BASE(base, channel)->ATTR & (~(uint16_t)(DMA_ATTR_SMOD_MASK | DMA_ATTR_DMOD_MASK));
EDMA_TCD_BASE(base, channel)->ATTR = tmpreg | DMA_ATTR_DMOD(destModulo) | DMA_ATTR_SMOD(srcModulo);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* As the device removal will change the state of other devices (usb host controller, most likely interrupt controller too) we have to wait with it until */ | static void usb_host_post_load_bh(void *opaque) | /* As the device removal will change the state of other devices (usb host controller, most likely interrupt controller too) we have to wait with it until */
static void usb_host_post_load_bh(void *opaque) | {
USBHostDevice *dev = opaque;
USBDevice *udev = USB_DEVICE(dev);
if (dev->dh != NULL) {
usb_host_close(dev);
}
if (udev->attached) {
usb_device_detach(udev);
}
usb_host_auto_check(NULL);
} | ve3wwg/teensy3_qemu | C++ | Other | 15 |
/* param base Pointer to FLEXIO_I2S_Type structure. param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state */ | void FLEXIO_I2S_TransferAbortReceive(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle) | /* param base Pointer to FLEXIO_I2S_Type structure. param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state */
void FLEXIO_I2S_TransferAbortReceive(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle) | {
assert(handle != NULL);
FLEXIO_I2S_DisableInterrupts(base, kFLEXIO_I2S_RxDataRegFullInterruptEnable);
handle->state = (uint32_t)kFLEXIO_I2S_Idle;
(void)memset(handle->queue, 0, sizeof(flexio_i2s_transfer_t) * FLEXIO_I2S_XFER_QUEUE_SIZE);
handle->queueDriver = 0;
handle->queueUser = 0;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Sets ExtractHandlerGuidTable so it points at a callee allocated array of registered GUIDs. The total number of GUIDs in the array are returned. Since the array of GUIDs is callee allocated and caller must treat this array of GUIDs as read-only data. If ExtractHandlerGuidTable is NULL, then ASSERT(). */ | UINTN EFIAPI ExtractGuidedSectionGetGuidList(OUT GUID **ExtractHandlerGuidTable) | /* Sets ExtractHandlerGuidTable so it points at a callee allocated array of registered GUIDs. The total number of GUIDs in the array are returned. Since the array of GUIDs is callee allocated and caller must treat this array of GUIDs as read-only data. If ExtractHandlerGuidTable is NULL, then ASSERT(). */
UINTN EFIAPI ExtractGuidedSectionGetGuidList(OUT GUID **ExtractHandlerGuidTable) | {
EFI_STATUS Status;
PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;
ASSERT (ExtractHandlerGuidTable != NULL);
Status = PeiGetExtractGuidedSectionHandlerInfo (&HandlerInfo);
if (EFI_ERROR (Status)) {
*ExtractHandlerGuidTable = NULL;
return 0;
}
ASSERT (HandlerInfo != NULL);
*ExtractHandlerGuidTable = HandlerInfo->ExtractHandlerGuidTable;
return HandlerInfo->NumberOfExtractHandler;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Adds the driver structure to the list of registered drivers. Returns a negative value on error, otherwise 0. If no error occurred, the driver remains registered even if no device was claimed during registration. */ | int __pci_register_driver(struct pci_driver *drv, struct module *owner, const char *mod_name) | /* Adds the driver structure to the list of registered drivers. Returns a negative value on error, otherwise 0. If no error occurred, the driver remains registered even if no device was claimed during registration. */
int __pci_register_driver(struct pci_driver *drv, struct module *owner, const char *mod_name) | {
int error;
drv->driver.name = drv->name;
drv->driver.bus = &pci_bus_type;
drv->driver.owner = owner;
drv->driver.mod_name = mod_name;
spin_lock_init(&drv->dynids.lock);
INIT_LIST_HEAD(&drv->dynids.list);
error = driver_register(&drv->driver);
if (error)
goto out;
error = pci_create_newid_file(drv);
if (error)
goto out_newid;
error = pci_create_removeid_file(drv);
if (error)
goto out_removeid;
out:
return error;
out_removeid:
pci_remove_newid_file(drv);
out_newid:
driver_unregister(&drv->driver);
goto out;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Create performance record with event description and a timestamp. */ | RETURN_STATUS EFIAPI LogPerformanceMeasurement(IN CONST VOID *CallerIdentifier, IN CONST VOID *Guid OPTIONAL, IN CONST CHAR8 *String OPTIONAL, IN UINT64 Address OPTIONAL, IN UINT32 Identifier) | /* Create performance record with event description and a timestamp. */
RETURN_STATUS EFIAPI LogPerformanceMeasurement(IN CONST VOID *CallerIdentifier, IN CONST VOID *Guid OPTIONAL, IN CONST CHAR8 *String OPTIONAL, IN UINT64 Address OPTIONAL, IN UINT32 Identifier) | {
EFI_STATUS Status;
Status = GetPerformanceMeasurementProtocol ();
if (EFI_ERROR (Status)) {
return RETURN_OUT_OF_RESOURCES;
}
if (mPerformanceMeasurement != NULL) {
Status = mPerformanceMeasurement->CreatePerformanceMeasurement (CallerIdentifier, Guid, String, 0, Address, Identifier, PerfEntry);
} else {
ASSERT (FALSE);
}
return (RETURN_STATUS)Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Searches through the list of registers of the driver instance and retrieves a pointer to the register that matches the given address. */ | ad717x_st_reg* AD717X_GetReg(ad717x_dev *device, uint8_t reg_address) | /* Searches through the list of registers of the driver instance and retrieves a pointer to the register that matches the given address. */
ad717x_st_reg* AD717X_GetReg(ad717x_dev *device, uint8_t reg_address) | {
uint8_t i;
ad717x_st_reg *reg = 0;
if (!device || !device->regs)
return 0;
for (i = 0; i < device->num_regs; i++) {
if (device->regs[i].addr == reg_address) {
reg = &device->regs[i];
break;
}
}
return reg;
} | analogdevicesinc/EVAL-ADICUP3029 | C++ | Other | 36 |
/* If HmacSha256Context is NULL, then return FALSE. If HmacValue is NULL, then return FALSE. */ | BOOLEAN EFIAPI HmacSha256Final(IN OUT VOID *HmacSha256Context, OUT UINT8 *HmacValue) | /* If HmacSha256Context is NULL, then return FALSE. If HmacValue is NULL, then return FALSE. */
BOOLEAN EFIAPI HmacSha256Final(IN OUT VOID *HmacSha256Context, OUT UINT8 *HmacValue) | {
return HmacMdFinal (HmacSha256Context, HmacValue);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This file is part of the Simba project. */ | int emacs(const char *path_p, void *chin_p, void *chout_p) | /* This file is part of the Simba project. */
int emacs(const char *path_p, void *chin_p, void *chout_p) | {
ASSERTN(chin_p != NULL, EINVAL);
ASSERTN(chout_p != NULL, EINVAL);
const char *args[2];
args[1] = path_p;
atto_curses_set_input_channel(chin_p);
atto_curses_set_output_channel(chout_p);
if (path_p != NULL) {
return (atto_main(2, (char **)args));
} else {
return (atto_main(1, NULL));
}
} | eerimoq/simba | C++ | Other | 337 |
/* Converts channel number to channel frequency. Returns 0 if the channel is out of range. Also used by some code in wlc_iw.c */ | uint wf_channel2freq(uint channel) | /* Converts channel number to channel frequency. Returns 0 if the channel is out of range. Also used by some code in wlc_iw.c */
uint wf_channel2freq(uint channel) | {
uint i;
for (i = 0; i < ARRAYSIZE(chan_info); i++)
if (chan_info[i].chan == channel)
return (chan_info[i].freq);
return (0);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Copy a signature memory section to a RAM buffer. */ | static void mem_signature_read(void *dst, isp_addr_t src, uint16_t nbytes) | /* Copy a signature memory section to a RAM buffer. */
static void mem_signature_read(void *dst, isp_addr_t src, uint16_t nbytes) | {
memcpy(dst, (uint8_t*)&mem_signature + src, nbytes);
} | memfault/zero-to-main | C++ | null | 200 |
/* Return a pointer to the n-th block pointer in the btree block. */ | STATIC union xfs_btree_ptr* xfs_btree_ptr_addr(struct xfs_btree_cur *cur, int n, struct xfs_btree_block *block) | /* Return a pointer to the n-th block pointer in the btree block. */
STATIC union xfs_btree_ptr* xfs_btree_ptr_addr(struct xfs_btree_cur *cur, int n, struct xfs_btree_block *block) | {
int level = xfs_btree_get_level(block);
ASSERT(block->bb_level != 0);
return (union xfs_btree_ptr *)
((char *)block + xfs_btree_ptr_offset(cur, n, level));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Uses the ISR, but with special processing. MUST be single-threaded. */ | static void mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice) | /* Uses the ISR, but with special processing. MUST be single-threaded. */
static void mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice) | {
INTERNAL_CMD iocmd;
if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT)
return;
if (vdevice->vtarget->type != TYPE_DISK || vdevice->vtarget->deleted ||
!vdevice->configured_lun)
return;
iocmd.cmd = SYNCHRONIZE_CACHE;
iocmd.flags = 0;
iocmd.physDiskNum = -1;
iocmd.data = NULL;
iocmd.data_dma = -1;
iocmd.size = 0;
iocmd.rsvd = iocmd.rsvd2 = 0;
iocmd.channel = vdevice->vtarget->channel;
iocmd.id = vdevice->vtarget->id;
iocmd.lun = vdevice->lun;
mptscsih_do_cmd(hd, &iocmd);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* remove the ring buffer and release it if assigned */ | static void atiixp_clear_dma_packets(struct atiixp_modem *chip, struct atiixp_dma *dma, struct snd_pcm_substream *substream) | /* remove the ring buffer and release it if assigned */
static void atiixp_clear_dma_packets(struct atiixp_modem *chip, struct atiixp_dma *dma, struct snd_pcm_substream *substream) | {
if (dma->desc_buf.area) {
writel(0, chip->remap_addr + dma->ops->llp_offset);
snd_dma_free_pages(&dma->desc_buf);
dma->desc_buf.area = NULL;
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Check if PTE can be modified, if not branch to LABEL. Regardless restore PTE with value from PTR when done. */ | static void __cpuinit build_pte_modifiable(u32 **p, struct uasm_reloc **r, unsigned int pte, unsigned int ptr, enum label_id lid) | /* Check if PTE can be modified, if not branch to LABEL. Regardless restore PTE with value from PTR when done. */
static void __cpuinit build_pte_modifiable(u32 **p, struct uasm_reloc **r, unsigned int pte, unsigned int ptr, enum label_id lid) | {
uasm_i_andi(p, pte, pte, _PAGE_WRITE);
uasm_il_beqz(p, r, pte, lid);
iPTE_LW(p, pte, ptr);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* For moronic filesystems that do not allow holes in file. We may have to extend the file. */ | int cont_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata, get_block_t *get_block, loff_t *bytes) | /* For moronic filesystems that do not allow holes in file. We may have to extend the file. */
int cont_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata, get_block_t *get_block, loff_t *bytes) | {
struct inode *inode = mapping->host;
unsigned blocksize = 1 << inode->i_blkbits;
unsigned zerofrom;
int err;
err = cont_expand_zero(file, mapping, pos, bytes);
if (err)
goto out;
zerofrom = *bytes & ~PAGE_CACHE_MASK;
if (pos+len > *bytes && zerofrom & (blocksize-1)) {
*bytes |= (blocksize-1);
(*bytes)++;
}
*pagep = NULL;
err = block_write_begin(file, mapping, pos, len,
flags, pagep, fsdata, get_block);
out:
return err;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function takes a hexadecimal character (e.g. '7' or 'C') and returns the integer equivalent. */ | static u8 h2i(char p) | /* This function takes a hexadecimal character (e.g. '7' or 'C') and returns the integer equivalent. */
static u8 h2i(char p) | {
if ((p >= '0') && (p <= '9'))
return p - '0';
if ((p >= 'A') && (p <= 'F'))
return (p - 'A') + 10;
if ((p >= 'a') && (p <= 'f'))
return (p - 'a') + 10;
return 0;
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Calculate offset of the n-th block pointer in a btree block. */ | STATIC size_t xfs_btree_ptr_offset(struct xfs_btree_cur *cur, int n, int level) | /* Calculate offset of the n-th block pointer in a btree block. */
STATIC size_t xfs_btree_ptr_offset(struct xfs_btree_cur *cur, int n, int level) | {
return xfs_btree_block_len(cur) +
cur->bc_ops->get_maxrecs(cur, level) * cur->bc_ops->key_len +
(n - 1) * xfs_btree_ptr_len(cur);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function is called to initialize system tick source (typically a timer generating interrupts every 1 to 100 mS). We decided to use Core Timer as the tick interrupt source. */ | void rt_hw_core_timer_init(void) | /* This function is called to initialize system tick source (typically a timer generating interrupts every 1 to 100 mS). We decided to use Core Timer as the tick interrupt source. */
void rt_hw_core_timer_init(void) | {
*pTCNTL = 1;
*pTSCALE = 0x00;
*pTCOUNT = CCLKSPEED / RT_TICK_PER_SECOND;
*pTPERIOD = CCLKSPEED / RT_TICK_PER_SECOND;
register_handler(ik_timer,rt_hw_timer_handler);
*pTCNTL = 0x07;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* nilfs_segbuf_map_cont - map a new log behind a given log @segbuf: new segment buffer @prev: segment buffer containing a log to be continued */ | void nilfs_segbuf_map_cont(struct nilfs_segment_buffer *segbuf, struct nilfs_segment_buffer *prev) | /* nilfs_segbuf_map_cont - map a new log behind a given log @segbuf: new segment buffer @prev: segment buffer containing a log to be continued */
void nilfs_segbuf_map_cont(struct nilfs_segment_buffer *segbuf, struct nilfs_segment_buffer *prev) | {
segbuf->sb_segnum = prev->sb_segnum;
segbuf->sb_fseg_start = prev->sb_fseg_start;
segbuf->sb_fseg_end = prev->sb_fseg_end;
segbuf->sb_pseg_start = prev->sb_pseg_start + prev->sb_sum.nblocks;
segbuf->sb_rest_blocks =
segbuf->sb_fseg_end - segbuf->sb_pseg_start + 1;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.