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
|
---|---|---|---|---|---|---|---|
/* Write a "service pulse" to the AD5755 watchdog timer when enabled. */ | void ad5755_feed_watch_dog_timer(struct ad5755_dev *dev) | /* Write a "service pulse" to the AD5755 watchdog timer when enabled. */
void ad5755_feed_watch_dog_timer(struct ad5755_dev *dev) | {
ad5755_set_control_registers(dev,
AD5755_CREG_SOFT,
0,
AD5755_SPI_CODE);
} | analogdevicesinc/EVAL-ADICUP3029 | C++ | Other | 36 |
/* Recover from broken hardware with a full reset. */ | void whc_hw_error(struct whc *whc, const char *reason) | /* Recover from broken hardware with a full reset. */
void whc_hw_error(struct whc *whc, const char *reason) | {
struct wusbhc *wusbhc = &whc->wusbhc;
dev_err(&whc->umc->dev, "hardware error: %s\n", reason);
wusbhc_reset_all(wusbhc);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Switch the DPLL clock on the HPT3xxN devices. This is a right mess. */ | static void hpt3xxn_set_clock(ide_hwif_t *hwif, u8 mode) | /* Switch the DPLL clock on the HPT3xxN devices. This is a right mess. */
static void hpt3xxn_set_clock(ide_hwif_t *hwif, u8 mode) | {
unsigned long base = hwif->extra_base;
u8 scr2 = inb(base + 0x6b);
if ((scr2 & 0x7f) == mode)
return;
outb(0x80, base + 0x63);
outb(0x80, base + 0x67);
outb(mode, base + 0x6b);
outb(0xc0, base + 0x69);
outb(inb(base + 0x60) | 0x32, base + 0x60);
outb(inb(base + 0x64) | 0x32, base + 0x64);
outb(0x00, base + 0x69);
outb(0x00, base + 0x63);
outb(0x00, base + 0x67);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* set up the iterator to start reading from the first line */ | static void* slow_work_runqueue_start(struct seq_file *m, loff_t *_pos) | /* set up the iterator to start reading from the first line */
static void* slow_work_runqueue_start(struct seq_file *m, loff_t *_pos) | {
spin_lock_irq(&slow_work_queue_lock);
return slow_work_runqueue_index(m, _pos);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* unregister_hw_breakpoint - unregister a user-space hardware breakpoint @bp: the breakpoint structure to unregister */ | void unregister_hw_breakpoint(struct perf_event *bp) | /* unregister_hw_breakpoint - unregister a user-space hardware breakpoint @bp: the breakpoint structure to unregister */
void unregister_hw_breakpoint(struct perf_event *bp) | {
if (!bp)
return;
perf_event_release_kernel(bp);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Calculate the distance between two menus and include the skip value of StartMenu. */ | UINTN GetDistanceBetweenMenus(IN LIST_ENTRY *StartMenu, IN LIST_ENTRY *EndMenu) | /* Calculate the distance between two menus and include the skip value of StartMenu. */
UINTN GetDistanceBetweenMenus(IN LIST_ENTRY *StartMenu, IN LIST_ENTRY *EndMenu) | {
LIST_ENTRY *Link;
UI_MENU_OPTION *MenuOption;
UINTN Distance;
Distance = 0;
Link = StartMenu;
while (Link != EndMenu) {
MenuOption = MENU_OPTION_FROM_LINK (Link);
if (MenuOption->Row == 0) {
UpdateOptionSkipLines (MenuOption);
}
Distance += MenuOption->Skip;
Link = Link->BackLink;
}
return Distance;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Callers are responsible for ensuring the channel mapping logic is included in that particular EDMA variant (Eg : dm646x) */ | static void __init map_dmach_param(unsigned ctlr) | /* Callers are responsible for ensuring the channel mapping logic is included in that particular EDMA variant (Eg : dm646x) */
static void __init map_dmach_param(unsigned ctlr) | {
int i;
for (i = 0; i < EDMA_MAX_DMACH; i++)
edma_write_array(ctlr, EDMA_DCHMAP , i , (i << 5));
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Gets the value of the Read Status Register (RDSR/0x05) */ | uint8_t at25GetRSR() | /* Gets the value of the Read Status Register (RDSR/0x05) */
uint8_t at25GetRSR() | {
AT25_SELECT();
src_addr[0] = AT25_RDSR;
sspSend(0, (uint8_t *)src_addr, 1);
sspReceive(0, (uint8_t *)dest_addr, 1);
AT25_DESELECT();
return dest_addr[0] & (AT25_RDSR_WEN | AT25_RDSR_RDY);
} | microbuilder/LPC1343CodeBase | C++ | Other | 73 |
/* Unlock the tx ready semaphore if '> ' is received. */ | MODEM_CMD_DIRECT_DEFINE(on_cmd_tx_ready) | /* Unlock the tx ready semaphore if '> ' is received. */
MODEM_CMD_DIRECT_DEFINE(on_cmd_tx_ready) | {
k_sem_give(&mdata.sem_tx_ready);
return len;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* it is not clear exactly how/where/why to abstract this, as it assumes the use of a local APIC (but there's no other mechanism). */ | void arch_sched_ipi(void) | /* it is not clear exactly how/where/why to abstract this, as it assumes the use of a local APIC (but there's no other mechanism). */
void arch_sched_ipi(void) | {
z_loapic_ipi(0, LOAPIC_ICR_IPI_OTHERS, CONFIG_SCHED_IPI_VECTOR);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* hwpath_to_device - Finds the generic device corresponding to a given hardware path. @modpath: the hardware path. */ | struct device* hwpath_to_device(struct hardware_path *modpath) | /* hwpath_to_device - Finds the generic device corresponding to a given hardware path. @modpath: the hardware path. */
struct device* hwpath_to_device(struct hardware_path *modpath) | {
int i;
struct device *parent = &root;
for (i = 0; i < 6; i++) {
if (modpath->bc[i] == -1)
continue;
parent = parse_tree_node(parent, i, modpath);
if (!parent)
return NULL;
}
if (is_pci_dev(parent))
return parent;
else
return parse_tree_node(parent, 6, modpath);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* a3d_open() is a callback from the input open routine. */ | static int a3d_open(struct input_dev *dev) | /* a3d_open() is a callback from the input open routine. */
static int a3d_open(struct input_dev *dev) | {
struct a3d *a3d = input_get_drvdata(dev);
gameport_start_polling(a3d->gameport);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* calculate agaw for each iommu. "SAGAW" may be different across iommus, use a default agaw, and get a supported less agaw for iommus that don't support the default agaw. */ | int iommu_calculate_agaw(struct intel_iommu *iommu) | /* calculate agaw for each iommu. "SAGAW" may be different across iommus, use a default agaw, and get a supported less agaw for iommus that don't support the default agaw. */
int iommu_calculate_agaw(struct intel_iommu *iommu) | {
return __iommu_calculate_agaw(iommu, DEFAULT_DOMAIN_ADDRESS_WIDTH);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* SPI Data Write and Read Exchange.
Data is written to the SPI interface, then a read is done after the incoming transfer has finished. */ | uint16_t spi_xfer(uint32_t spi, uint16_t data) | /* SPI Data Write and Read Exchange.
Data is written to the SPI interface, then a read is done after the incoming transfer has finished. */
uint16_t spi_xfer(uint32_t spi, uint16_t data) | {
spi_write(spi, data);
while (!(SPI_SR(spi) & SPI_SR_RXNE));
return SPI_DR(spi);
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Get the frequency of clock selected by MCG_C2.
This clock's two output: */ | static uint32_t CLOCK_GetInternalRefClkSelectFreq(void) | /* Get the frequency of clock selected by MCG_C2.
This clock's two output: */
static uint32_t CLOCK_GetInternalRefClkSelectFreq(void) | {
if (kMCG_IrcSlow == MCG_S_IRCST_VAL)
{
return s_slowIrcFreq;
}
else
{
return s_fastIrcFreq >> MCG_SC_FCRDIV_VAL;
}
} | labapart/polymcu | C++ | null | 201 |
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */ | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base) | /* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base) | {
if(htim_base->Instance==TIM12)
{
__HAL_RCC_TIM12_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOH, GPIO_PIN_9);
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_14);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Read errors are reported with an console message in Rawshark. */ | static void read_failure_message(const char *filename, int err) | /* Read errors are reported with an console message in Rawshark. */
static void read_failure_message(const char *filename, int err) | {
cmdarg_err("An error occurred while reading from the file \"%s\": %s.",
filename, g_strerror(err));
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Fills each SDIO_InitStruct member with its default value. */ | void SDIO_StructInit(SDIO_InitTypeDef *SDIO_InitStruct) | /* Fills each SDIO_InitStruct member with its default value. */
void SDIO_StructInit(SDIO_InitTypeDef *SDIO_InitStruct) | {
SDIO_InitStruct->SDIO_ClockDiv = 0x00;
SDIO_InitStruct->SDIO_ClockEdge = SDIO_ClockEdge_Rising;
SDIO_InitStruct->SDIO_ClockBypass = SDIO_ClockBypass_Disable;
SDIO_InitStruct->SDIO_ClockPowerSave = SDIO_ClockPowerSave_Disable;
SDIO_InitStruct->SDIO_BusWide = SDIO_BusWide_1b;
SDIO_InitStruct->SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable;
} | gcallipo/RadioDSP-Stm32f103 | C++ | Common Creative - Attribution 3.0 | 51 |
/* Software SMI handler that is called when a Legacy Boot event is signalled. The SMM Core uses this signal to know that a Legacy Boot has been performed and that gSmmCorePrivate that is shared between the UEFI and SMM execution environments can not be accessed from SMM anymore since that structure is considered free memory by a legacy OS. Then the SMM Core also install SMM Legacy Boot protocol to notify SMM driver that system enter legacy boot. */ | EFI_STATUS EFIAPI SmmLegacyBootHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL) | /* Software SMI handler that is called when a Legacy Boot event is signalled. The SMM Core uses this signal to know that a Legacy Boot has been performed and that gSmmCorePrivate that is shared between the UEFI and SMM execution environments can not be accessed from SMM anymore since that structure is considered free memory by a legacy OS. Then the SMM Core also install SMM Legacy Boot protocol to notify SMM driver that system enter legacy boot. */
EFI_STATUS EFIAPI SmmLegacyBootHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL) | {
EFI_STATUS Status;
EFI_HANDLE SmmHandle;
UINTN Index;
SmmHandle = NULL;
Status = SmmInstallProtocolInterface (
&SmmHandle,
&gEdkiiSmmLegacyBootProtocolGuid,
EFI_NATIVE_INTERFACE,
NULL
);
mInLegacyBoot = TRUE;
SmiHandlerUnRegister (DispatchHandle);
for (Index = 0; mSmmCoreSmiHandlers[Index].HandlerType != NULL; Index++) {
if (CompareGuid (mSmmCoreSmiHandlers[Index].HandlerType, &gEfiEventExitBootServicesGuid)) {
SmiHandlerUnRegister (mSmmCoreSmiHandlers[Index].DispatchHandle);
break;
}
}
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Reads a page of data from an emulated EEPROM memory page.
Reads an emulated EEPROM page of data from the emulated EEPROM memory space. */ | enum status_code eeprom_emulator_read_page(const uint8_t logical_page, uint8_t *const data) | /* Reads a page of data from an emulated EEPROM memory page.
Reads an emulated EEPROM page of data from the emulated EEPROM memory space. */
enum status_code 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, EEPROM_PAGE_SIZE);
} else {
struct _eeprom_page temp;
_eeprom_emulator_nvm_read_page(
_eeprom_instance.page_map[logical_page], &temp);
memcpy(data, temp.data, EEPROM_PAGE_SIZE);
}
return STATUS_OK;
} | memfault/zero-to-main | C++ | null | 200 |
/* If Sha512Context is NULL, then return FALSE. If NewSha512Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. */ | BOOLEAN EFIAPI Sha512Duplicate(IN CONST VOID *Sha512Context, OUT VOID *NewSha512Context) | /* If Sha512Context is NULL, then return FALSE. If NewSha512Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI Sha512Duplicate(IN CONST VOID *Sha512Context, OUT VOID *NewSha512Context) | {
CALL_CRYPTO_SERVICE (Sha512Duplicate, (Sha512Context, NewSha512Context), FALSE);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* In order to wait for pages to become available there must be waitqueues associated with pages. By using a hash table of waitqueues where the bucket discipline is to maintain all waiters on the same queue and wake all when any of the pages become available, and for the woken contexts to check to be sure the appropriate page became available, this saves space at a cost of "thundering herd" phenomena during rare hash collisions. */ | static wait_queue_head_t* page_waitqueue(struct page *page) | /* In order to wait for pages to become available there must be waitqueues associated with pages. By using a hash table of waitqueues where the bucket discipline is to maintain all waiters on the same queue and wake all when any of the pages become available, and for the woken contexts to check to be sure the appropriate page became available, this saves space at a cost of "thundering herd" phenomena during rare hash collisions. */
static wait_queue_head_t* page_waitqueue(struct page *page) | {
const struct zone *zone = page_zone(page);
return &zone->wait_table[hash_ptr(page, zone->wait_table_bits)];
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Initializes the USARTx peripheral Clock according to the specified parameters in the USART_ClockInitStruct. */ | void USART_ClockInit(USART_TypeDef *USARTx, USART_ClockInitTypeDef *USART_ClockInitStruct) | /* Initializes the USARTx peripheral Clock according to the specified parameters in the USART_ClockInitStruct. */
void USART_ClockInit(USART_TypeDef *USARTx, USART_ClockInitTypeDef *USART_ClockInitStruct) | {
uint32_t tmpreg = 0;
assert_param(IS_USART_ALL_PERIPH(USARTx));
assert_param(IS_USART_CLOCK(USART_ClockInitStruct->USART_Clock));
assert_param(IS_USART_CPOL(USART_ClockInitStruct->USART_CPOL));
assert_param(IS_USART_CPHA(USART_ClockInitStruct->USART_CPHA));
assert_param(IS_USART_LASTBIT(USART_ClockInitStruct->USART_LastBit));
tmpreg = USARTx->CR2;
tmpreg &= (uint32_t)~((uint32_t)CR2_CLOCK_CLEAR_MASK);
tmpreg |= (uint32_t)(USART_ClockInitStruct->USART_Clock | USART_ClockInitStruct->USART_CPOL |
USART_ClockInitStruct->USART_CPHA | USART_ClockInitStruct->USART_LastBit);
USARTx->CR2 = tmpreg;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This macro is used to disable input channel interrupt. */ | void ECAP_DisableINT(ECAP_T *ecap, uint32_t u32Mask) | /* This macro is used to disable input channel interrupt. */
void ECAP_DisableINT(ECAP_T *ecap, uint32_t u32Mask) | {
ecap->CTL0 &= ~(u32Mask);
if(ecap == (ECAP_T*)ECAP0)
{
NVIC_DisableIRQ((IRQn_Type)ECAP0_IRQn);
}
else
{
NVIC_DisableIRQ((IRQn_Type)ECAP1_IRQn);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* If the writer ends up delaying the write, the writer needs to increment the page use counts until he is done with the page. */ | static int smb_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata) | /* If the writer ends up delaying the write, the writer needs to increment the page use counts until he is done with the page. */
static int smb_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata) | {
pgoff_t index = pos >> PAGE_CACHE_SHIFT;
*pagep = grab_cache_page_write_begin(mapping, index, flags);
if (!*pagep)
return -ENOMEM;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function waits until the SDIO DMA data transfer is finished. This function should be called after SDIO_WriteBlock() and SDIO_WriteMultiBlocks() function to insure that all data sent by the card are already transferred by the DMA controller. */ | SD_Error SD_WaitWriteOperation(void) | /* This function waits until the SDIO DMA data transfer is finished. This function should be called after SDIO_WriteBlock() and SDIO_WriteMultiBlocks() function to insure that all data sent by the card are already transferred by the DMA controller. */
SD_Error SD_WaitWriteOperation(void) | {
SD_Error errorstatus = SD_OK;
while ((SD_DMAEndOfTransferStatus() == RESET) && (TransferEnd == 0) && (TransferError == SD_OK))
{}
if (TransferError != SD_OK)
{
return(TransferError);
}
SDIO_ClearFlag(SDIO_STATIC_FLAGS);
return(errorstatus);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Function for Timer 0 initialization, which will be started and stopped by timer1 and timer2 using PPI. */ | static void timer0_init(void) | /* Function for Timer 0 initialization, which will be started and stopped by timer1 and timer2 using PPI. */
static void timer0_init(void) | {
nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
timer_cfg.mode = NRF_TIMER_MODE_COUNTER;
ret_code_t err_code = nrf_drv_timer_init(&timer0, &timer_cfg, timer_event_handler);
APP_ERROR_CHECK(err_code);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* returns the length of an OpcUa message. This function reads the length information from the transport header. */ | static guint get_opcua_message_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_) | /* returns the length of an OpcUa message. This function reads the length information from the transport header. */
static guint get_opcua_message_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_) | {
gint32 plen;
plen = tvb_get_letohl(tvb, offset + 4);
return plen;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* @reg: List of regions to print @count: Number of regions */ | static void show_region_list(struct fdt_region *reg, int count) | /* @reg: List of regions to print @count: Number of regions */
static void show_region_list(struct fdt_region *reg, int count) | {
int i;
printf("Regions: %d\n", count);
for (i = 0; i < count; i++, reg++) {
printf("%d: %-10x %-10x\n", i, reg->offset,
reg->offset + reg->size);
}
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Send the Send CSD command and check the response. */ | int32_t SDMMC_CMD9_SendCSD(CM_SDIOC_TypeDef *SDIOCx, uint32_t u32RCA, uint32_t *pu32ErrStatus) | /* Send the Send CSD command and check the response. */
int32_t SDMMC_CMD9_SendCSD(CM_SDIOC_TypeDef *SDIOCx, uint32_t u32RCA, uint32_t *pu32ErrStatus) | {
int32_t i32Ret;
stc_sdioc_cmd_config_t stcCmdConfig;
if (NULL == pu32ErrStatus) {
i32Ret = LL_ERR_INVD_PARAM;
} else {
stcCmdConfig.u32Argument = u32RCA;
stcCmdConfig.u16CmdIndex = SDIOC_CMD9_SEND_CSD;
stcCmdConfig.u16CmdType = SDIOC_CMD_TYPE_NORMAL;
stcCmdConfig.u16DataLine = SDIOC_DATA_LINE_DISABLE;
stcCmdConfig.u16ResponseType = SDIOC_RESP_TYPE_R2;
i32Ret = SDIOC_SendCommand(SDIOCx, &stcCmdConfig);
if (LL_OK == i32Ret) {
i32Ret = SDMMC_GetCmdResp2(SDIOCx, pu32ErrStatus);
}
}
return i32Ret;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Description: Check the setsockopt() call and if the user is trying to replace the IP options on a socket and a NetLabel is in place for the socket deny the access; otherwise allow the access. Returns zero when the access is allowed, -EACCES when denied, and other negative values on error. */ | int selinux_netlbl_socket_setsockopt(struct socket *sock, int level, int optname) | /* Description: Check the setsockopt() call and if the user is trying to replace the IP options on a socket and a NetLabel is in place for the socket deny the access; otherwise allow the access. Returns zero when the access is allowed, -EACCES when denied, and other negative values on error. */
int selinux_netlbl_socket_setsockopt(struct socket *sock, int level, int optname) | {
int rc = 0;
struct sock *sk = sock->sk;
struct sk_security_struct *sksec = sk->sk_security;
struct netlbl_lsm_secattr secattr;
if (level == IPPROTO_IP && optname == IP_OPTIONS &&
(sksec->nlbl_state == NLBL_LABELED ||
sksec->nlbl_state == NLBL_CONNLABELED)) {
netlbl_secattr_init(&secattr);
lock_sock(sk);
rc = netlbl_sock_getattr(sk, &secattr);
release_sock(sk);
if (rc == 0)
rc = -EACCES;
else if (rc == -ENOMSG)
rc = 0;
netlbl_secattr_destroy(&secattr);
}
return rc;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* In Half duplex GMAC enables the back pressure operation */ | void synopGMAC_tx_flow_control_enable(synopGMACdevice *gmacdev) | /* In Half duplex GMAC enables the back pressure operation */
void synopGMAC_tx_flow_control_enable(synopGMACdevice *gmacdev) | {
synopGMACSetBits(gmacdev->MacBase, GmacFlowControl, GmacTxFlowControl);
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function performs the setup phase of the control transfer */ | static int ctrlreq_setup_phase(struct usb_device *dev, struct devrequest *setup) | /* This function performs the setup phase of the control transfer */
static int ctrlreq_setup_phase(struct usb_device *dev, struct devrequest *setup) | {
int result;
u16 csr;
write_fifo(MUSB_CONTROL_EP, sizeof(struct devrequest), (void *)setup);
csr = readw(&musbr->txcsr);
csr |= (MUSB_CSR0_TXPKTRDY|MUSB_CSR0_H_SETUPPKT);
writew(csr, &musbr->txcsr);
result = wait_until_ep0_ready(dev, MUSB_CSR0_TXPKTRDY);
dev->act_len = 0;
return result;
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* configure counter value, window value, and prescaler divider value */ | void wwdgt_config(uint16_t counter, uint16_t window, uint32_t prescaler) | /* configure counter value, window value, and prescaler divider value */
void wwdgt_config(uint16_t counter, uint16_t window, uint32_t prescaler) | {
uint32_t reg_cfg = 0, reg_ctl = 0;
reg_cfg = WWDGT_CFG &((~(uint32_t)WWDGT_CFG_WIN)|(~(uint32_t)WWDGT_CFG_PSC));
reg_ctl = WWDGT_CTL &(~(uint32_t)WWDGT_CTL_CNT);
reg_cfg |= (uint32_t)(CFG_WIN(window));
reg_cfg |= (uint32_t)(prescaler);
reg_ctl |= (uint32_t)(CTL_CNT(counter));
WWDGT_CFG = (uint32_t)reg_cfg;
WWDGT_CTL = (uint32_t)reg_ctl;
} | liuxuming/trochili | C++ | Apache License 2.0 | 132 |
/* If the volume is damaged because of an interrupted update this function just returns immediately with %-EBADF code. */ | int ubi_leb_erase(struct ubi_volume_desc *desc, int lnum) | /* If the volume is damaged because of an interrupted update this function just returns immediately with %-EBADF code. */
int ubi_leb_erase(struct ubi_volume_desc *desc, int lnum) | {
struct ubi_volume *vol = desc->vol;
struct ubi_device *ubi = vol->ubi;
int err;
dbg_gen("erase LEB %d:%d", vol->vol_id, lnum);
if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME)
return -EROFS;
if (lnum < 0 || lnum >= vol->reserved_pebs)
return -EINVAL;
if (vol->upd_marker)
return -EBADF;
err = ubi_eba_unmap_leb(ubi, vol, lnum);
if (err)
return err;
return ubi_wl_flush(ubi, vol->vol_id, lnum);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* This function erases an instance of the customer INFO space. */ | int am_hal_flash_erase_info(uint32_t ui32ProgramKey, uint32_t ui32Inst) | /* This function erases an instance of the customer INFO space. */
int am_hal_flash_erase_info(uint32_t ui32ProgramKey, uint32_t ui32Inst) | {
return g_am_hal_flash.flash_erase_info(ui32ProgramKey, ui32Inst);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Function for sending service changed indications if it is pending on any connections. */ | static void service_changed_pending_flags_check(void) | /* Function for sending service changed indications if it is pending on any connections. */
static void service_changed_pending_flags_check(void) | {
sdk_mapped_flags_t service_changed_pending_flags;
service_changed_pending_flags = ble_conn_state_user_flag_collection(m_gcm.flag_id_service_changed_pending);
if (sdk_mapped_flags_any_set(service_changed_pending_flags))
{
sdk_mapped_flags_key_list_t conn_handle_list;
conn_handle_list = ble_conn_state_conn_handles();
for (uint32_t i = 0; i < conn_handle_list.len; i++)
{
if ( ble_conn_state_user_flag_get(conn_handle_list.flag_keys[i],
m_gcm.flag_id_service_changed_pending)
&& !ble_conn_state_user_flag_get(conn_handle_list.flag_keys[i],
m_gcm.flag_id_service_changed_sent))
{
service_changed_send_in_evt(conn_handle_list.flag_keys[i]);
}
}
}
} | labapart/polymcu | C++ | null | 201 |
/* Note that although the calls are asynchronous, and are therefore guaranteed to complete, we still always attempt to wait for completion in order to be able to correctly track the lock state. */ | static int nlmclnt_async_call(struct rpc_cred *cred, struct nlm_rqst *req, u32 proc, const struct rpc_call_ops *tk_ops) | /* Note that although the calls are asynchronous, and are therefore guaranteed to complete, we still always attempt to wait for completion in order to be able to correctly track the lock state. */
static int nlmclnt_async_call(struct rpc_cred *cred, struct nlm_rqst *req, u32 proc, const struct rpc_call_ops *tk_ops) | {
struct rpc_message msg = {
.rpc_argp = &req->a_args,
.rpc_resp = &req->a_res,
.rpc_cred = cred,
};
struct rpc_task *task;
int err;
task = __nlm_async_call(req, proc, &msg, tk_ops);
if (IS_ERR(task))
return PTR_ERR(task);
err = rpc_wait_for_completion_task(task);
rpc_put_task(task);
return err;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* E5 Section 11.8.5: implement 'x < y' and then use negate and eval_left_first flags to get the rest. */ | DUK_INTERNAL duk_small_int_t duk_js_data_compare(const duk_uint8_t *buf1, const duk_uint8_t *buf2, duk_size_t len1, duk_size_t len2) | /* E5 Section 11.8.5: implement 'x < y' and then use negate and eval_left_first flags to get the rest. */
DUK_INTERNAL duk_small_int_t duk_js_data_compare(const duk_uint8_t *buf1, const duk_uint8_t *buf2, duk_size_t len1, duk_size_t len2) | {
duk_bool_t rc;
rc = duk_js_equals_helper(thr,
DUK_GET_TVAL_NEGIDX(thr, -2),
DUK_GET_TVAL_NEGIDX(thr, -1),
0);
duk_pop_2_unsafe(thr);
return rc;
}
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* HRPWM positive edge adjust delay counts configuration for specified channel. */ | void HRPWM_ChPositiveAdjustConfig(uint32_t u32Ch, uint8_t u8DelayNum) | /* HRPWM positive edge adjust delay counts configuration for specified channel. */
void HRPWM_ChPositiveAdjustConfig(uint32_t u32Ch, uint8_t u8DelayNum) | {
__IO uint32_t *CRx;
DDL_ASSERT(IS_VALID_HRPWM_CH(u32Ch));
CRx = (__IO uint32_t *)(((uint32_t)&CM_HRPWM->CR1) + 4UL * (u32Ch - 1UL));
MODIFY_REG32(*CRx, HRPWM_CR_PSEL, ((uint32_t)u8DelayNum - 1UL) << HRPWM_CR_PSEL_POS);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Registers an interrupt handler for a fault condition detected in a PWM module. */ | void PWMFaultIntRegister(uint32_t ui32Base, void(*pfnIntHandler)(void)) | /* Registers an interrupt handler for a fault condition detected in a PWM module. */
void PWMFaultIntRegister(uint32_t ui32Base, void(*pfnIntHandler)(void)) | {
uint32_t ui32Int;
ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
ui32Int = _PWMFaultIntNumberGet(ui32Base);
ASSERT(ui32Int != 0);
IntRegister(ui32Int, pfnIntHandler);
IntEnable(ui32Int);
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Remove a group address from the array of group addresses. Although the function doesn't assume the byte order of Group, the network byte order is used by the caller. */ | EFI_STATUS Ip6RemoveGroup(IN OUT IP6_PROTOCOL *IpInstance, IN EFI_IPv6_ADDRESS *Group) | /* Remove a group address from the array of group addresses. Although the function doesn't assume the byte order of Group, the network byte order is used by the caller. */
EFI_STATUS Ip6RemoveGroup(IN OUT IP6_PROTOCOL *IpInstance, IN EFI_IPv6_ADDRESS *Group) | {
UINT32 Index;
UINT32 Count;
Count = IpInstance->GroupCount;
for (Index = 0; Index < Count; Index++) {
if (EFI_IP6_EQUAL (IpInstance->GroupList + Index, Group)) {
break;
}
}
if (Index == Count) {
return EFI_NOT_FOUND;
}
while (Index < Count - 1) {
IP6_COPY_ADDRESS (IpInstance->GroupList + Index, IpInstance->GroupList + Index + 1);
Index++;
}
ASSERT (IpInstance->GroupCount > 0);
IpInstance->GroupCount--;
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Description: Removes an existing NetLabel static label used when protocol provided labels are not present on incoming traffic. If @dev_name is NULL then the default interface will be used. Returns zero on success, negative values on failure. */ | int netlbl_cfg_unlbl_static_del(struct net *net, const char *dev_name, const void *addr, const void *mask, u16 family, struct netlbl_audit *audit_info) | /* Description: Removes an existing NetLabel static label used when protocol provided labels are not present on incoming traffic. If @dev_name is NULL then the default interface will be used. Returns zero on success, negative values on failure. */
int netlbl_cfg_unlbl_static_del(struct net *net, const char *dev_name, const void *addr, const void *mask, u16 family, struct netlbl_audit *audit_info) | {
u32 addr_len;
switch (family) {
case AF_INET:
addr_len = sizeof(struct in_addr);
break;
case AF_INET6:
addr_len = sizeof(struct in6_addr);
break;
default:
return -EPFNOSUPPORT;
}
return netlbl_unlhsh_remove(net,
dev_name, addr, mask, addr_len,
audit_info);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Switched to packing state if the number of used buffers on a queue reaches a certain limit. */ | static void qeth_switch_to_packing_if_needed(struct qeth_qdio_out_q *queue) | /* Switched to packing state if the number of used buffers on a queue reaches a certain limit. */
static void qeth_switch_to_packing_if_needed(struct qeth_qdio_out_q *queue) | {
if (!queue->do_pack) {
if (atomic_read(&queue->used_buffers)
>= QETH_HIGH_WATERMARK_PACK){
QETH_DBF_TEXT(TRACE, 6, "np->pack");
if (queue->card->options.performance_stats)
queue->card->perf_stats.sc_dp_p++;
queue->do_pack = 1;
}
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Return the attribute of a non-leaf page table entry. */ | UINT64 PageTableLibGetPnleMapAttribute(IN IA32_PAGE_NON_LEAF_ENTRY *Pnle, IN IA32_MAP_ATTRIBUTE *ParentMapAttribute) | /* Return the attribute of a non-leaf page table entry. */
UINT64 PageTableLibGetPnleMapAttribute(IN IA32_PAGE_NON_LEAF_ENTRY *Pnle, IN IA32_MAP_ATTRIBUTE *ParentMapAttribute) | {
IA32_MAP_ATTRIBUTE MapAttribute;
MapAttribute.Uint64 = Pnle->Uint64;
MapAttribute.Bits.Present = ParentMapAttribute->Bits.Present & Pnle->Bits.Present;
MapAttribute.Bits.ReadWrite = ParentMapAttribute->Bits.ReadWrite & Pnle->Bits.ReadWrite;
MapAttribute.Bits.UserSupervisor = ParentMapAttribute->Bits.UserSupervisor & Pnle->Bits.UserSupervisor;
MapAttribute.Bits.Nx = ParentMapAttribute->Bits.Nx | Pnle->Bits.Nx;
MapAttribute.Bits.WriteThrough = Pnle->Bits.WriteThrough;
MapAttribute.Bits.CacheDisabled = Pnle->Bits.CacheDisabled;
MapAttribute.Bits.Accessed = Pnle->Bits.Accessed;
return MapAttribute.Uint64;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Install the handlers for level 1 UEFI Shell 2.0 commands. */ | EFI_STATUS EFIAPI ShellInstall1CommandsLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) | /* Install the handlers for level 1 UEFI Shell 2.0 commands. */
EFI_STATUS EFIAPI ShellInstall1CommandsLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) | {
if ((PcdGet8 (PcdShellProfileMask) & BIT2) == 0) {
return (EFI_SUCCESS);
}
return (BcfgLibraryRegisterBcfgCommand (ImageHandle, SystemTable, L"Install1"));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* If an entry with is already available in the table, return its index without adding a new entry. */ | STATIC UINT32 EFIAPI MappingTableAdd(IN MAPPING_TABLE *MappingTable, IN UINT32 Integer) | /* If an entry with is already available in the table, return its index without adding a new entry. */
STATIC UINT32 EFIAPI MappingTableAdd(IN MAPPING_TABLE *MappingTable, IN UINT32 Integer) | {
UINT32 *Table;
UINT32 Index;
UINT32 LastIndex;
ASSERT (MappingTable != NULL);
ASSERT (MappingTable->Table != NULL);
Table = MappingTable->Table;
LastIndex = MappingTable->LastIndex;
for (Index = 0; Index < LastIndex; Index++) {
if (Table[Index] == Integer) {
return Index;
}
}
ASSERT (LastIndex < MappingTable->MaxIndex);
Table[LastIndex] = Integer;
return MappingTable->LastIndex++;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function searches UBI device number object by its major number. If UBI device was not found, this function returns -ENODEV, otherwise the UBI device number is returned. */ | int ubi_major2num(int major) | /* This function searches UBI device number object by its major number. If UBI device was not found, this function returns -ENODEV, otherwise the UBI device number is returned. */
int ubi_major2num(int major) | {
int i, ubi_num = -ENODEV;
spin_lock(&ubi_devices_lock);
for (i = 0; i < UBI_MAX_DEVICES; i++) {
struct ubi_device *ubi = ubi_devices[i];
if (ubi && MAJOR(ubi->cdev.dev) == major) {
ubi_num = ubi->ubi_num;
break;
}
}
spin_unlock(&ubi_devices_lock);
return ubi_num;
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* param base ITRC peripheral base address param word 32bit word represent corresponding event/action in STATUS register to be cleared (see ITRC_STATUS_INx/OUTx_STATUS) return kStatus_Success if success, kStatus_InvalidArgument otherwise */ | status_t ITRC_ClearStatus(ITRC_Type *base, uint32_t word) | /* param base ITRC peripheral base address param word 32bit word represent corresponding event/action in STATUS register to be cleared (see ITRC_STATUS_INx/OUTx_STATUS) return kStatus_Success if success, kStatus_InvalidArgument otherwise */
status_t ITRC_ClearStatus(ITRC_Type *base, uint32_t word) | {
if ((word & ~(IN_EVENTS_MASK | OUT_ACTIONS_MASK)) != 0u)
{
return kStatus_InvalidArgument;
}
base->STATUS |= word;
return kStatus_Success;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Build a conntrack cache holding all conntrack currently in the kernel */ | int nfnl_ct_alloc_cache(struct nl_sock *sk, struct nl_cache **result) | /* Build a conntrack cache holding all conntrack currently in the kernel */
int nfnl_ct_alloc_cache(struct nl_sock *sk, struct nl_cache **result) | {
return nl_cache_alloc_and_fill(&nfnl_ct_ops, sk, result);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* param base SPI peripheral base address. param handle SPI DMA handle pointer. */ | void SPI_MasterTransferAbortDMA(SPI_Type *base, spi_dma_handle_t *handle) | /* param base SPI peripheral base address. param handle SPI DMA handle pointer. */
void SPI_MasterTransferAbortDMA(SPI_Type *base, spi_dma_handle_t *handle) | {
assert(NULL != handle);
DMA_AbortTransfer(handle->txHandle);
DMA_AbortTransfer(handle->rxHandle);
handle->txInProgress = false;
handle->rxInProgress = false;
handle->state = (uint8_t)kSPI_Idle;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Checks the unique counts of other tasks to ensure they are still operational. Returns pdTRUE if an error is detected, otherwise pdFALSE. */ | static char prvCheckOtherTasksAreStillRunning(void) | /* Checks the unique counts of other tasks to ensure they are still operational. Returns pdTRUE if an error is detected, otherwise pdFALSE. */
static char prvCheckOtherTasksAreStillRunning(void) | {
char cErrorHasOccurred = ( char ) pdFALSE;
if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
{
cErrorHasOccurred = ( char ) pdTRUE;
}
if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
{
cErrorHasOccurred = ( char ) pdTRUE;
}
return cErrorHasOccurred;
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* deal with a change in the status of the CTS line */ | static void mn10300_serial_cts_changed(struct mn10300_serial_port *port, u8 st) | /* deal with a change in the status of the CTS line */
static void mn10300_serial_cts_changed(struct mn10300_serial_port *port, u8 st) | {
u16 ctr;
port->tx_cts = st;
port->uart.icount.cts++;
ctr = *port->_control;
ctr ^= SC2CTR_TWS;
*port->_control = ctr;
uart_handle_cts_change(&port->uart, st & SC2STR_CTS);
wake_up_interruptible(&port->uart.state->port.delta_msr_wait);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Register a network interface with the forwarding module. */ | void uip_fw_register(struct uip_fw_netif *netif) | /* Register a network interface with the forwarding module. */
void uip_fw_register(struct uip_fw_netif *netif) | {
netif->next = netifs;
netifs = netif;
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* Sets a default choice for the mount operation. */ | void g_mount_operation_set_choice(GMountOperation *op, int choice) | /* Sets a default choice for the mount operation. */
void g_mount_operation_set_choice(GMountOperation *op, int choice) | {
GMountOperationPrivate *priv;
g_return_if_fail (G_IS_MOUNT_OPERATION (op));
priv = op->priv;
if (priv->choice != choice)
{
priv->choice = choice;
g_object_notify (G_OBJECT (op), "choice");
}
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Converts IP v6 address to its text representation. */ | VOID CatIPv6Address(IN OUT POOL_PRINT *Str, IN EFI_IPv6_ADDRESS *Address) | /* Converts IP v6 address to its text representation. */
VOID CatIPv6Address(IN OUT POOL_PRINT *Str, IN EFI_IPv6_ADDRESS *Address) | {
UefiDevicePathLibCatPrint (
Str,
L"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
Address->Addr[0],
Address->Addr[1],
Address->Addr[2],
Address->Addr[3],
Address->Addr[4],
Address->Addr[5],
Address->Addr[6],
Address->Addr[7],
Address->Addr[8],
Address->Addr[9],
Address->Addr[10],
Address->Addr[11],
Address->Addr[12],
Address->Addr[13],
Address->Addr[14],
Address->Addr[15]
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function initializes interrupt descript table and 8259 interrupt controller */ | void rt_hw_interrupt_init(void) | /* This function initializes interrupt descript table and 8259 interrupt controller */
void rt_hw_interrupt_init(void) | {
rt_hw_idt_init();
rt_hw_pic_init();
} | armink/FreeModbus_Slave-Master-RTT-STM32 | C++ | Other | 1,477 |
/* Returns the address space associated with the fault. Returns 0 for kernel space and 1 for user space. */ | static int user_space_fault(unsigned long trans_exc_code) | /* Returns the address space associated with the fault. Returns 0 for kernel space and 1 for user space. */
static int user_space_fault(unsigned long trans_exc_code) | {
trans_exc_code &= 3;
if (trans_exc_code == 2)
return current->thread.mm_segment.ar4;
if (user_mode == HOME_SPACE_MODE)
return trans_exc_code == 3;
return trans_exc_code != 3;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* If the controller handle does not have the EFI_IP4_CONFIG2_PROTOCOL installed, the default address is static. If failed to get the policy from Ip4 Config2 Protocol, the default address is static. Otherwise, get the result from Ip4 Config2 Protocol. */ | BOOLEAN NetLibDefaultAddressIsStatic(IN EFI_HANDLE Controller) | /* If the controller handle does not have the EFI_IP4_CONFIG2_PROTOCOL installed, the default address is static. If failed to get the policy from Ip4 Config2 Protocol, the default address is static. Otherwise, get the result from Ip4 Config2 Protocol. */
BOOLEAN NetLibDefaultAddressIsStatic(IN EFI_HANDLE Controller) | {
EFI_STATUS Status;
EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
UINTN DataSize;
EFI_IP4_CONFIG2_POLICY Policy;
BOOLEAN IsStatic;
Ip4Config2 = NULL;
DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);
IsStatic = TRUE;
Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **)&Ip4Config2);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
Status = Ip4Config2->GetData (Ip4Config2, Ip4Config2DataTypePolicy, &DataSize, &Policy);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
IsStatic = (BOOLEAN)(Policy == Ip4Config2PolicyStatic);
ON_EXIT:
return IsStatic;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Enables or disables the USART's transmitter or receiver. */ | void USART_DirectionModeCmd(USART_TypeDef *USARTx, uint32_t USART_DirectionMode, FunctionalState NewState) | /* Enables or disables the USART's transmitter or receiver. */
void USART_DirectionModeCmd(USART_TypeDef *USARTx, uint32_t USART_DirectionMode, FunctionalState NewState) | {
assert_param(IS_USART_ALL_PERIPH(USARTx));
assert_param(IS_USART_MODE(USART_DirectionMode));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
USARTx->CR1 |= USART_DirectionMode;
}
else
{
USARTx->CR1 &= (uint32_t)~USART_DirectionMode;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* param config transceiver configurations. param bitWidth audio data bitWidth. param mode audio data channel. param saiChannelMask channel mask value to enable. */ | void SAI_GetTDMConfig(sai_transceiver_t *config, sai_frame_sync_len_t frameSyncWidth, sai_word_width_t bitWidth, uint32_t dataWordNum, uint32_t saiChannelMask) | /* param config transceiver configurations. param bitWidth audio data bitWidth. param mode audio data channel. param saiChannelMask channel mask value to enable. */
void SAI_GetTDMConfig(sai_transceiver_t *config, sai_frame_sync_len_t frameSyncWidth, sai_word_width_t bitWidth, uint32_t dataWordNum, uint32_t saiChannelMask) | {
assert(NULL != config);
assert(saiChannelMask != 0U);
assert(dataWordNum <= 32U);
SAI_GetCommonConfig(config, bitWidth, kSAI_Stereo, saiChannelMask);
switch (frameSyncWidth)
{
case kSAI_FrameSyncLenOneBitClk:
config->frameSync.frameSyncWidth = 1U;
break;
case kSAI_FrameSyncLenPerWordWidth:
break;
default:
assert(false);
}
config->frameSync.frameSyncEarly = false;
config->frameSync.frameSyncPolarity = kSAI_PolarityActiveHigh;
config->serialData.dataWordNum = dataWordNum;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Return with tail node of the linked list. */ | void* ramfs_ll_get_tail(ramfs_ll_t *ll) | /* Return with tail node of the linked list. */
void* ramfs_ll_get_tail(ramfs_ll_t *ll) | {
void *tail = NULL;
if (ll->tail != NULL) {
tail = ll->tail;
}
return tail;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* spider_net_write_reg - writes to an SMMIO register of a card @card: device structure @reg: register to write to @value: value to write into the specified SMMIO register */ | static void spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value) | /* spider_net_write_reg - writes to an SMMIO register of a card @card: device structure @reg: register to write to @value: value to write into the specified SMMIO register */
static void spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value) | {
out_be32(card->regs + reg, value);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* fc_seq_els_rsp_send() - Send an ELS response using infomation from the existing sequence/exchange. @sp: */ | static void fc_seq_els_rsp_send(struct fc_seq *sp, enum fc_els_cmd els_cmd, struct fc_seq_els_data *els_data) | /* fc_seq_els_rsp_send() - Send an ELS response using infomation from the existing sequence/exchange. @sp: */
static void fc_seq_els_rsp_send(struct fc_seq *sp, enum fc_els_cmd els_cmd, struct fc_seq_els_data *els_data) | {
switch (els_cmd) {
case ELS_LS_RJT:
fc_seq_ls_rjt(sp, els_data->reason, els_data->explan);
break;
case ELS_LS_ACC:
fc_seq_ls_acc(sp);
break;
case ELS_RRQ:
fc_exch_els_rrq(sp, els_data->fp);
break;
case ELS_REC:
fc_exch_els_rec(sp, els_data->fp);
break;
default:
FC_EXCH_DBG(fc_seq_exch(sp), "Invalid ELS CMD:%x\n", els_cmd);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Reset the system.
This routine resets the processor. */ | void sys_arch_reboot(int type) | /* Reset the system.
This routine resets the processor. */
void sys_arch_reboot(int type) | {
ARG_UNUSED(type);
extern void z_do_software_reboot(void);
extern void z_force_exit_one_nested_irq(void);
__asm__ volatile("cpsie i" :::);
if ((SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) == 0) {
z_do_software_reboot();
} else {
__asm__ volatile(
"ldr r0, =z_force_exit_one_nested_irq\n\t"
"bx r0\n\t"
:::);
}
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Returns 0 on success, a negative error code otherwise. */ | int nand_change_read_column_op(struct nand_chip *chip, unsigned int offset_in_page, void *buf, unsigned int len, bool force_8bit) | /* Returns 0 on success, a negative error code otherwise. */
int nand_change_read_column_op(struct nand_chip *chip, unsigned int offset_in_page, void *buf, unsigned int len, bool force_8bit) | {
struct mtd_info *mtd = nand_to_mtd(chip);
if (len && !buf)
return -EINVAL;
if (offset_in_page + len > mtd->writesize + mtd->oobsize)
return -EINVAL;
chip->cmdfunc(mtd, NAND_CMD_RNDOUT, offset_in_page, -1);
if (len)
chip->read_buf(mtd, buf, len);
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* x_{j} /= 2^(c - c_{j}), c_{j} = c */ | int prop_descriptor_init(struct prop_descriptor *pd, int shift) | /* x_{j} /= 2^(c - c_{j}), c_{j} = c */
int prop_descriptor_init(struct prop_descriptor *pd, int shift) | {
int err;
if (shift > PROP_MAX_SHIFT)
shift = PROP_MAX_SHIFT;
pd->index = 0;
pd->pg[0].shift = shift;
mutex_init(&pd->mutex);
err = percpu_counter_init(&pd->pg[0].events, 0);
if (err)
goto out;
err = percpu_counter_init(&pd->pg[1].events, 0);
if (err)
percpu_counter_destroy(&pd->pg[0].events);
out:
return err;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Objects are considered unreferenced only if their color is white, they have not be deleted and have a minimum age to avoid false positives caused by pointers temporarily stored in CPU registers. */ | static bool unreferenced_object(struct kmemleak_object *object) | /* Objects are considered unreferenced only if their color is white, they have not be deleted and have a minimum age to avoid false positives caused by pointers temporarily stored in CPU registers. */
static bool unreferenced_object(struct kmemleak_object *object) | {
return (color_white(object) && object->flags & OBJECT_ALLOCATED) &&
time_before_eq(object->jiffies + jiffies_min_age,
jiffies_last_scan);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* s e t u p Q P d a t a */ | returnValue QProblemBCPY_setupQPdata(QProblem *_THIS, real_t *const _H, const real_t *const _g, const real_t *const _lb, const real_t *const _ub) | /* s e t u p Q P d a t a */
returnValue QProblemBCPY_setupQPdata(QProblem *_THIS, real_t *const _H, const real_t *const _g, const real_t *const _lb, const real_t *const _ub) | {
QProblem_setH( _THIS,_H );
if ( _g == 0 )
return THROWERROR( RET_INVALID_ARGUMENTS );
else
QProblem_setG( _THIS,_g );
QProblem_setLB( _THIS,_lb );
QProblem_setUB( _THIS,_ub );
return SUCCESSFUL_RETURN;
} | DanielMartensson/EmbeddedLapack | C++ | MIT License | 129 |
/* The purpose of this function is for layers and drivers to be able to set the maximum QoS possible and then "and in" their own limitations */ | void irda_init_max_qos_capabilies(struct qos_info *qos) | /* The purpose of this function is for layers and drivers to be able to set the maximum QoS possible and then "and in" their own limitations */
void irda_init_max_qos_capabilies(struct qos_info *qos) | {
int i;
i = value_lower_bits(sysctl_max_baud_rate, baud_rates, 10,
&qos->baud_rate.bits);
sysctl_max_baud_rate = index_value(i, baud_rates);
i = value_lower_bits(sysctl_max_noreply_time, link_disc_times, 8,
&qos->link_disc_time.bits);
sysctl_max_noreply_time = index_value(i, link_disc_times);
qos->baud_rate.bits &= 0x03ff;
qos->window_size.bits = 0x7f;
qos->min_turn_time.bits = 0xff;
qos->max_turn_time.bits = 0x0f;
qos->data_size.bits = 0x3f;
qos->link_disc_time.bits &= 0xff;
qos->additional_bofs.bits = 0xff;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* et131x_rx_dma_disable - Stop of Rx_DMA on the ET1310 @etdev: pointer to our adapter structure */ | void et131x_rx_dma_disable(struct et131x_adapter *etdev) | /* et131x_rx_dma_disable - Stop of Rx_DMA on the ET1310 @etdev: pointer to our adapter structure */
void et131x_rx_dma_disable(struct et131x_adapter *etdev) | {
RXDMA_CSR_t csr;
writel(0x00002001, &etdev->regs->rxdma.csr.value);
csr.value = readl(&etdev->regs->rxdma.csr.value);
if (csr.bits.halt_status != 1) {
udelay(5);
csr.value = readl(&etdev->regs->rxdma.csr.value);
if (csr.bits.halt_status != 1)
dev_err(&etdev->pdev->dev,
"RX Dma failed to enter halt state. CSR 0x%08x\n",
csr.value);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This module is a confidential and proprietary property of RealTek and possession or use of this module requires written permission of RealTek. strpbrk - Find the first occurrence of a set of characters @cs: The string to be searched @ct: The characters to search for */ | LIBC_ROM_TEXT_SECTION _LONG_CALL_ char* _strpbrk(const char *cs, const char *ct) | /* This module is a confidential and proprietary property of RealTek and possession or use of this module requires written permission of RealTek. strpbrk - Find the first occurrence of a set of characters @cs: The string to be searched @ct: The characters to search for */
LIBC_ROM_TEXT_SECTION _LONG_CALL_ char* _strpbrk(const char *cs, const char *ct) | {
const char *sc1, *sc2;
for (sc1 = cs; *sc1 != '\0'; ++sc1) {
for (sc2 = ct; *sc2 != '\0'; ++sc2) {
if (*sc1 == *sc2)
return (char *)sc1;
}
}
return NULL;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* This helper function allocates and initializes UBIFS write-buffers. Returns zero in case of success and %-ENOMEM in case of failure. */ | static int alloc_wbufs(struct ubifs_info *c) | /* This helper function allocates and initializes UBIFS write-buffers. Returns zero in case of success and %-ENOMEM in case of failure. */
static int alloc_wbufs(struct ubifs_info *c) | {
int i, err;
c->jheads = kcalloc(c->jhead_cnt, sizeof(struct ubifs_jhead),
GFP_KERNEL);
if (!c->jheads)
return -ENOMEM;
for (i = 0; i < c->jhead_cnt; i++) {
INIT_LIST_HEAD(&c->jheads[i].buds_list);
err = ubifs_wbuf_init(c, &c->jheads[i].wbuf);
if (err)
return err;
c->jheads[i].wbuf.sync_callback = &bud_wbuf_callback;
c->jheads[i].wbuf.jhead = i;
c->jheads[i].grouped = 1;
}
c->jheads[GCHD].wbuf.no_timer = 1;
c->jheads[GCHD].grouped = 0;
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* "Block" until the queue of IOM transactions is over. */ | void am_hal_iom_sleeping_queue_flush(uint32_t ui32Module) | /* "Block" until the queue of IOM transactions is over. */
void am_hal_iom_sleeping_queue_flush(uint32_t ui32Module) | {
bool bWaiting = true;
uint32_t ui32Critical;
if ( ui32Module >= AM_REG_IOMSTR_NUM_MODULES )
{
return;
}
while ( bWaiting )
{
ui32Critical = am_hal_interrupt_master_disable();
if ( (g_bIomBusy[ui32Module] == false) &&
am_hal_queue_empty(&g_psIOMQueue[ui32Module]) )
{
bWaiting = false;
}
else
{
am_hal_sysctrl_sleep(AM_HAL_SYSCTRL_SLEEP_NORMAL);
}
am_hal_interrupt_master_set(ui32Critical);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Returns: NULL if the TLV is not found, otherwise a pointer to it. If the sizes don't match, an error is printed and NULL returned. */ | static const struct i2400m_tlv_hdr* i2400m_tlv_find(struct i2400m *i2400m, const struct i2400m_tlv_hdr *tlv_hdr, size_t size, enum i2400m_tlv tlv_type, ssize_t tlv_size) | /* Returns: NULL if the TLV is not found, otherwise a pointer to it. If the sizes don't match, an error is printed and NULL returned. */
static const struct i2400m_tlv_hdr* i2400m_tlv_find(struct i2400m *i2400m, const struct i2400m_tlv_hdr *tlv_hdr, size_t size, enum i2400m_tlv tlv_type, ssize_t tlv_size) | {
ssize_t match;
struct device *dev = i2400m_dev(i2400m);
const struct i2400m_tlv_hdr *tlv = NULL;
while ((tlv = i2400m_tlv_buffer_walk(i2400m, tlv_hdr, size, tlv))) {
match = i2400m_tlv_match(tlv, tlv_type, tlv_size);
if (match == 0)
break;
if (match > 0)
dev_warn(dev, "TLV type 0x%04x found with size "
"mismatch (%zu vs %zu needed)\n",
tlv_type, match, tlv_size);
}
return tlv;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Function for evaluating if the page erase operation is required for the current page. */ | static bool is_page_erase_required(void) | /* Function for evaluating if the page erase operation is required for the current page. */
static bool is_page_erase_required(void) | {
bool ret;
const cmd_queue_element_t * p_cmd = &m_cmd_queue.cmd[m_cmd_queue.rp];
const pstorage_block_t cmd_block_id = p_cmd->storage_addr.block_id;
const uint32_t id_last_page_to_be_cleared = (cmd_block_id + p_cmd->size +
p_cmd->offset - 1u) /
PSTORAGE_FLASH_PAGE_SIZE;
if ((m_current_page_id < id_last_page_to_be_cleared) ||
((m_current_page_id == id_last_page_to_be_cleared) && (m_tail_word_size == 0)))
{
ret = true;
}
else
{
ret = false;
}
return ret;
} | labapart/polymcu | C++ | null | 201 |
/* simple bin_search frontend that does the right thing for leaves vs nodes */ | static int bin_search(struct extent_buffer *eb, struct btrfs_key *key, int level, int *slot) | /* simple bin_search frontend that does the right thing for leaves vs nodes */
static int bin_search(struct extent_buffer *eb, struct btrfs_key *key, int level, int *slot) | {
if (level == 0) {
return generic_bin_search(eb,
offsetof(struct btrfs_leaf, items),
sizeof(struct btrfs_item),
key, btrfs_header_nritems(eb),
slot);
} else {
return generic_bin_search(eb,
offsetof(struct btrfs_node, ptrs),
sizeof(struct btrfs_key_ptr),
key, btrfs_header_nritems(eb),
slot);
}
return -1;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* When writing a value in TC74 registers through I2C0,we can set I2C0 Master transfer setup data structure using this API. */ | void TC74RegWrite(unsigned char ucReg, unsigned char ucValue) | /* When writing a value in TC74 registers through I2C0,we can set I2C0 Master transfer setup data structure using this API. */
void TC74RegWrite(unsigned char ucReg, unsigned char ucValue) | {
xtI2CMasterTransferCfg Cfg;
unsigned char ucSendBuf[2];
unsigned long ulSendLength = 2;
unsigned char ucReceiveBuf[1] ={0};
unsigned long ulReceiveLength = 0;
ucSendBuf[0] = ucReg;
ucSendBuf[1] = ucValue;
Cfg.ulSlave = TC74Address;
Cfg.pvWBuf = ucSendBuf;
Cfg.ulWLen = ulSendLength;
Cfg.ulWCount = 0;
Cfg.pvRBuf = ucReceiveBuf;
Cfg.ulRLen = ulReceiveLength;
Cfg.ulRCount = 0;
I2CMasterTransfer(I2C_BASE, &Cfg, I2C_TRANSFER_POLLING);
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* The device can be found directly from the address (see wusb_cack_add() for where the device address is set to port_idx +2), except when the address is zero. */ | static struct wusb_dev* wusbhc_find_dev_by_addr(struct wusbhc *wusbhc, u8 addr) | /* The device can be found directly from the address (see wusb_cack_add() for where the device address is set to port_idx +2), except when the address is zero. */
static struct wusb_dev* wusbhc_find_dev_by_addr(struct wusbhc *wusbhc, u8 addr) | {
int p;
if (addr == 0xff)
return NULL;
if (addr > 0) {
int port = (addr & ~0x80) - 2;
if (port < 0 || port >= wusbhc->ports_max)
return NULL;
return wusb_port_by_idx(wusbhc, port)->wusb_dev;
}
for (p = 0; p < wusbhc->ports_max; p++) {
struct wusb_dev *wusb_dev = wusb_port_by_idx(wusbhc, p)->wusb_dev;
if (wusb_dev && wusb_dev->addr == addr)
return wusb_dev;
}
return NULL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Add a usage to the temporary parser table. */ | static int hid_add_usage(struct hid_parser *parser, unsigned usage) | /* Add a usage to the temporary parser table. */
static int hid_add_usage(struct hid_parser *parser, unsigned usage) | {
if (parser->local.usage_index >= HID_MAX_USAGES) {
dbg_hid("usage index exceeded\n");
return -1;
}
parser->local.usage[parser->local.usage_index] = usage;
parser->local.collection_index[parser->local.usage_index] =
parser->collection_stack_ptr ?
parser->collection_stack[parser->collection_stack_ptr - 1] : 0;
parser->local.usage_index++;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* If MtrrSetting is not NULL, gets the variable MTRRs raw value from input MTRR settings buffer. If MtrrSetting is NULL, gets the variable MTRRs raw value from MTRRs. */ | MTRR_VARIABLE_SETTINGS* MtrrGetVariableMtrrWorker(IN MTRR_SETTINGS *MtrrSetting, IN UINT32 VariableMtrrCount, OUT MTRR_VARIABLE_SETTINGS *VariableSettings) | /* If MtrrSetting is not NULL, gets the variable MTRRs raw value from input MTRR settings buffer. If MtrrSetting is NULL, gets the variable MTRRs raw value from MTRRs. */
MTRR_VARIABLE_SETTINGS* MtrrGetVariableMtrrWorker(IN MTRR_SETTINGS *MtrrSetting, IN UINT32 VariableMtrrCount, OUT MTRR_VARIABLE_SETTINGS *VariableSettings) | {
UINT32 Index;
ASSERT (VariableMtrrCount <= ARRAY_SIZE (VariableSettings->Mtrr));
for (Index = 0; Index < VariableMtrrCount; Index++) {
if (MtrrSetting == NULL) {
VariableSettings->Mtrr[Index].Base =
AsmReadMsr64 (MSR_IA32_MTRR_PHYSBASE0 + (Index << 1));
VariableSettings->Mtrr[Index].Mask =
AsmReadMsr64 (MSR_IA32_MTRR_PHYSMASK0 + (Index << 1));
} else {
VariableSettings->Mtrr[Index].Base = MtrrSetting->Variables.Mtrr[Index].Base;
VariableSettings->Mtrr[Index].Mask = MtrrSetting->Variables.Mtrr[Index].Mask;
}
}
return VariableSettings;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Sets the operating mode for the UART transmit interrupt. */ | void UARTTxIntModeSet(unsigned long ulBase, unsigned long ulMode) | /* Sets the operating mode for the UART transmit interrupt. */
void UARTTxIntModeSet(unsigned long ulBase, unsigned long ulMode) | {
ASSERT(UARTBaseValid(ulBase));
ASSERT((ulMode == UART_TXINT_MODE_EOT) ||
(ulMode == UART_TXINT_MODE_FIFO));
HWREG(ulBase + UART_O_CTL) = ((HWREG(ulBase + UART_O_CTL) &
~(UART_TXINT_MODE_EOT |
UART_TXINT_MODE_FIFO)) | ulMode);
} | micropython/micropython | C++ | Other | 18,334 |
/* Selects the GMII port. When called GMII (1000Mbps) port is selected (programmable only in 10/100/1000 Mbps configuration). */ | void synopGMAC_select_gmii(synopGMACdevice *gmacdev) | /* Selects the GMII port. When called GMII (1000Mbps) port is selected (programmable only in 10/100/1000 Mbps configuration). */
void synopGMAC_select_gmii(synopGMACdevice *gmacdev) | {
synopGMACClearBits(gmacdev->MacBase, GmacConfig, GmacMiiGmii);
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Restart the card from scratch, as if from a cold-boot. Implementation resembles the first-half of the igbvf_resume routine. */ | static pci_ers_result_t igbvf_io_slot_reset(struct pci_dev *pdev) | /* Restart the card from scratch, as if from a cold-boot. Implementation resembles the first-half of the igbvf_resume routine. */
static pci_ers_result_t igbvf_io_slot_reset(struct pci_dev *pdev) | {
struct net_device *netdev = pci_get_drvdata(pdev);
struct igbvf_adapter *adapter = netdev_priv(netdev);
if (pci_enable_device_mem(pdev)) {
dev_err(&pdev->dev,
"Cannot re-enable PCI device after reset.\n");
return PCI_ERS_RESULT_DISCONNECT;
}
pci_set_master(pdev);
igbvf_reset(adapter);
return PCI_ERS_RESULT_RECOVERED;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* release the midi device if it was registered */ | int snd_seq_oss_midi_check_exit_port(int client, int port) | /* release the midi device if it was registered */
int snd_seq_oss_midi_check_exit_port(int client, int port) | {
struct seq_oss_midi *mdev;
unsigned long flags;
int index;
if ((mdev = find_slot(client, port)) != NULL) {
spin_lock_irqsave(®ister_lock, flags);
midi_devs[mdev->seq_device] = NULL;
spin_unlock_irqrestore(®ister_lock, flags);
snd_use_lock_free(&mdev->use_lock);
snd_use_lock_sync(&mdev->use_lock);
if (mdev->coder)
snd_midi_event_free(mdev->coder);
kfree(mdev);
}
spin_lock_irqsave(®ister_lock, flags);
for (index = max_midi_devs - 1; index >= 0; index--) {
if (midi_devs[index])
break;
}
max_midi_devs = index + 1;
spin_unlock_irqrestore(®ister_lock, flags);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This is the Event call back function is triggered in SMM to notify the Library the system is entering SmmLocked phase and set InSmm flag. */ | EFI_STATUS EFIAPI S3BootScriptSmmEventCallBack(IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle) | /* This is the Event call back function is triggered in SMM to notify the Library the system is entering SmmLocked phase and set InSmm flag. */
EFI_STATUS EFIAPI S3BootScriptSmmEventCallBack(IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle) | {
if (mS3BootScriptTablePtr == mS3BootScriptTableSmmPtr) {
return EFI_SUCCESS;
}
S3BootScriptEventCallBack (NULL, NULL);
if (mS3BootScriptTableSmmPtr->TableBase == NULL) {
CopyMem (mS3BootScriptTableSmmPtr, mS3BootScriptTablePtr, sizeof (*mS3BootScriptTablePtr));
mS3BootScriptTableSmmPtr->InSmm = TRUE;
}
mS3BootScriptTablePtr = mS3BootScriptTableSmmPtr;
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Displays a string on the LCD on the specified line. */ | void halLcdPrintLine(char String[], unsigned char Line, unsigned char TextStyle) | /* Displays a string on the LCD on the specified line. */
void halLcdPrintLine(char String[], unsigned char Line, unsigned char TextStyle) | {
int temp;
temp = Line * FONT_HEIGHT ;
halLcdSetAddress( temp << 5 ) ;
halLcdPrint(String, TextStyle);
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* Return the DPLL's autoidle bits, shifted down to bit 0. Returns -EINVAL if passed a null pointer or if the struct clk does not appear to refer to a DPLL. */ | u32 omap3_dpll_autoidle_read(struct clk *clk) | /* Return the DPLL's autoidle bits, shifted down to bit 0. Returns -EINVAL if passed a null pointer or if the struct clk does not appear to refer to a DPLL. */
u32 omap3_dpll_autoidle_read(struct clk *clk) | {
const struct dpll_data *dd;
u32 v;
if (!clk || !clk->dpll_data)
return -EINVAL;
dd = clk->dpll_data;
v = __raw_readl(dd->autoidle_reg);
v &= dd->autoidle_mask;
v >>= __ffs(dd->autoidle_mask);
return v;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This function will wake up a pending thread on the specified waiting queue that meets the conditions. */ | void rt_wqueue_wakeup(rt_wqueue_t *queue, void *key) | /* This function will wake up a pending thread on the specified waiting queue that meets the conditions. */
void rt_wqueue_wakeup(rt_wqueue_t *queue, void *key) | {
rt_base_t level;
int need_schedule = 0;
rt_list_t *queue_list;
struct rt_list_node *node;
struct rt_wqueue_node *entry;
queue_list = &(queue->waiting_list);
level = rt_spin_lock_irqsave(&(queue->spinlock));
queue->flag = RT_WQ_FLAG_WAKEUP;
if (!(rt_list_isempty(queue_list)))
{
for (node = queue_list->next; node != queue_list; node = node->next)
{
entry = rt_list_entry(node, struct rt_wqueue_node, list);
if (entry->wakeup(entry, key) == 0)
{
rt_thread_resume(entry->polling_thread);
need_schedule = 1;
rt_list_remove(&(entry->list));
break;
}
}
}
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
if (need_schedule)
rt_schedule();
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Wait specified time interval to poll for BSY bit clear in the Status Register. */ | EFI_STATUS WaitForBSYClear(IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev, IN IDE_BASE_REGISTERS *IdeIoRegisters, IN UINTN TimeoutInMilliSeconds) | /* Wait specified time interval to poll for BSY bit clear in the Status Register. */
EFI_STATUS WaitForBSYClear(IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev, IN IDE_BASE_REGISTERS *IdeIoRegisters, IN UINTN TimeoutInMilliSeconds) | {
UINTN Delay;
UINT16 StatusRegister;
UINT8 StatusValue;
StatusValue = 0;
StatusRegister = IdeIoRegisters->Reg.Status;
Delay = ((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 250) + 1;
do {
StatusValue = IoRead8 (StatusRegister);
if ((StatusValue & ATA_STSREG_BSY) == 0x00) {
break;
}
MicroSecondDelay (250);
Delay--;
} while (Delay != 0);
if (Delay == 0) {
return EFI_TIMEOUT;
}
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Query the Atmel flash ID Parameter: data: buffer to store the ID queried Return: SUCCESS on success, otherwise FAIL */ | int spi_nor_query_atmel(uint8_t *data) | /* Query the Atmel flash ID Parameter: data: buffer to store the ID queried Return: SUCCESS on success, otherwise FAIL */
int spi_nor_query_atmel(uint8_t *data) | {
spi_nor_tx_buf[3] = JEDEC_ID;
if (ecspi_xfer(dev_spi_nor, spi_nor_tx_buf, spi_nor_rx_buf, 20 * 8) == FALSE) {
return FAIL;
}
data[0] = spi_nor_rx_buf[0];
data[1] = spi_nor_rx_buf[1];
data[2] = spi_nor_rx_buf[2];
data[3] = spi_nor_rx_buf[3];
return SUCCESS;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Put a frame into the transmit FIFO TO-DO: support frames of size != 8 */ | static void spi_a2f_hw_txfifo_put(struct spi_a2f *c, int wb, const void *tx, int i) | /* Put a frame into the transmit FIFO TO-DO: support frames of size != 8 */
static void spi_a2f_hw_txfifo_put(struct spi_a2f *c, int wb, const void *tx, int i) | {
int j;
unsigned int d = 0;
unsigned char *p = (unsigned char *)tx;
if (p) {
for (j = 0; j < wb; j++) {
d <<= 8;
d |= p[i*wb + j];
}
}
writel(d, &MSS_SPI(c)->spi_tx_data);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Delivers a (partial) bundle of Rx offload packets to an offload device. */ | static void deliver_partial_bundle(struct t3cdev *tdev, struct sge_rspq *q, struct sk_buff *skbs[], int n) | /* Delivers a (partial) bundle of Rx offload packets to an offload device. */
static void deliver_partial_bundle(struct t3cdev *tdev, struct sge_rspq *q, struct sk_buff *skbs[], int n) | {
if (n) {
q->offload_bundles++;
tdev->recv(tdev, skbs, n);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* look up a certain register in ar5416_phy_init and return the init. value for the band and bandwidth given. Return 0 if register address not found. */ | static u32 ar9170_get_default_phy_reg_val(u32 reg, bool is_2ghz, bool is_40mhz) | /* look up a certain register in ar5416_phy_init and return the init. value for the band and bandwidth given. Return 0 if register address not found. */
static u32 ar9170_get_default_phy_reg_val(u32 reg, bool is_2ghz, bool is_40mhz) | {
unsigned int i;
for (i = 0; i < ARRAY_SIZE(ar5416_phy_init); i++) {
if (ar5416_phy_init[i].reg != reg)
continue;
if (is_2ghz) {
if (is_40mhz)
return ar5416_phy_init[i]._2ghz_40;
else
return ar5416_phy_init[i]._2ghz_20;
} else {
if (is_40mhz)
return ar5416_phy_init[i]._5ghz_40;
else
return ar5416_phy_init[i]._5ghz_20;
}
}
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Return a weak reference to the QObject associated with 'key' if 'key' is present in the dictionary, NULL otherwise. */ | QObject* qdict_get(const QDict *qdict, const char *key) | /* Return a weak reference to the QObject associated with 'key' if 'key' is present in the dictionary, NULL otherwise. */
QObject* qdict_get(const QDict *qdict, const char *key) | {
QDictEntry *entry;
entry = qdict_find(qdict, key, tdb_hash(key) % QDICT_BUCKET_MAX);
return (entry == NULL ? NULL : entry->value);
} | ve3wwg/teensy3_qemu | C++ | Other | 15 |
/* Returns: (nullable) (transfer none): a #GCancellable from the top of the stack, or NULL if the stack is empty. */ | GCancellable* g_cancellable_get_current(void) | /* Returns: (nullable) (transfer none): a #GCancellable from the top of the stack, or NULL if the stack is empty. */
GCancellable* g_cancellable_get_current(void) | {
GSList *l;
l = g_private_get (¤t_cancellable);
if (l == NULL)
return NULL;
return G_CANCELLABLE (l->data);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Build register value of waveform for NEC one data bit. */ | static void nec_fill_item_level(rmt_item32_t *item, int high_us, int low_us) | /* Build register value of waveform for NEC one data bit. */
static void nec_fill_item_level(rmt_item32_t *item, int high_us, int low_us) | {
item->level0 = 1;
item->duration0 = (high_us) / 10 * RMT_TICK_10_US;
item->level1 = 0;
item->duration1 = (low_us) / 10 * RMT_TICK_10_US;
} | retro-esp32/RetroESP32 | C++ | Creative Commons Attribution Share Alike 4.0 International | 581 |
/* brief SDIF return the controller capability param base SDIF peripheral base address. param sdif capability pointer */ | void SDIF_GetCapability(SDIF_Type *base, sdif_capability_t *capability) | /* brief SDIF return the controller capability param base SDIF peripheral base address. param sdif capability pointer */
void SDIF_GetCapability(SDIF_Type *base, sdif_capability_t *capability) | {
assert(NULL != capability);
(void)memset(capability, 0, sizeof(*capability));
capability->sdVersion = SDIF_SUPPORT_SD_VERSION;
capability->mmcVersion = SDIF_SUPPORT_MMC_VERSION;
capability->maxBlockLength = SDIF_BLKSIZ_BLOCK_SIZE_MASK;
capability->maxBlockCount = SDIF_BYTCNT_BYTE_COUNT_MASK / SDIF_BLKSIZ_BLOCK_SIZE_MASK;
capability->flags = (uint32_t)kSDIF_SupportHighSpeedFlag | (uint32_t)kSDIF_SupportDmaFlag |
(uint32_t)kSDIF_SupportSuspendResumeFlag | (uint32_t)kSDIF_SupportV330Flag |
(uint32_t)kSDIF_Support4BitFlag | (uint32_t)kSDIF_Support8BitFlag;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Get the width of a glyph with kerning */ | uint16_t lv_font_get_glyph_width(const lv_font_t *font, uint32_t letter, uint32_t letter_next) | /* Get the width of a glyph with kerning */
uint16_t lv_font_get_glyph_width(const lv_font_t *font, uint32_t letter, uint32_t letter_next) | {
LV_ASSERT_NULL(font);
lv_font_glyph_dsc_t g;
bool ret;
ret = lv_font_get_glyph_dsc(font, &g, letter, letter_next);
if(ret) return g.adv_w;
else return 0;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* If AuthData is NULL, then return FALSE. If ImageHash is NULL, then return FALSE. If this interface is not supported, then return FALSE. */ | BOOLEAN EFIAPI AuthenticodeVerify(IN CONST UINT8 *AuthData, IN UINTN DataSize, IN CONST UINT8 *TrustedCert, IN UINTN CertSize, IN CONST UINT8 *ImageHash, IN UINTN HashSize) | /* If AuthData is NULL, then return FALSE. If ImageHash is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI AuthenticodeVerify(IN CONST UINT8 *AuthData, IN UINTN DataSize, IN CONST UINT8 *TrustedCert, IN UINTN CertSize, IN CONST UINT8 *ImageHash, IN UINTN HashSize) | {
CALL_CRYPTO_SERVICE (AuthenticodeVerify, (AuthData, DataSize, TrustedCert, CertSize, ImageHash, HashSize), FALSE);
} | tianocore/edk2 | C++ | Other | 4,240 |