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 |
|---|---|---|---|---|---|---|---|
/* Free Big Number context that was allocated with BigNumNewContext(). */ | VOID EFIAPI CryptoServiceBigNumContextFree(IN VOID *BnCtx) | /* Free Big Number context that was allocated with BigNumNewContext(). */
VOID EFIAPI CryptoServiceBigNumContextFree(IN VOID *BnCtx) | {
CALL_VOID_BASECRYPTLIB (Bn.Services.ContextFree, BigNumContextFree, (BnCtx));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Read a string of bytes through the software UART. */ | int32_t swuart_read_string(struct swuart_dev *dev, uint8_t *string, uint32_t size) | /* Read a string of bytes through the software UART. */
int32_t swuart_read_string(struct swuart_dev *dev, uint8_t *string, uint32_t size) | {
uint32_t i;
int32_t check;
for(i = 0; i < size; i++) {
check = swuart_read_char(dev, &string[i]);
if(check != 0)
return check;
}
return check;
} | analogdevicesinc/EVAL-ADICUP3029 | C++ | Other | 36 |
/* Converts a Wi-Fi device path structure to its string representative. */ | VOID DevPathToTextWiFi(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts) | /* Converts a Wi-Fi device path structure to its string representative. */
VOID DevPathToTextWiFi(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts) | {
WIFI_DEVICE_PATH *WiFi;
UINT8 SSId[33];
WiFi = DevPath;
SSId[32] = '\0';
CopyMem (SSId, WiFi->SSId, 32);
UefiDevicePathLibCatPrint (Str, L"Wi-Fi(%a)", SSId);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Set the msi range after reset/standby. Until MSIRGSEl bit is set, this defines the MSI range. Note that not all MSI range values are allowed here! */ | void rcc_set_msi_range_standby(uint32_t msi_range) | /* Set the msi range after reset/standby. Until MSIRGSEl bit is set, this defines the MSI range. Note that not all MSI range values are allowed here! */
void rcc_set_msi_range_standby(uint32_t msi_range) | {
uint32_t reg = RCC_CSR;
reg &= ~(RCC_CSR_MSIRANGE_MASK << RCC_CSR_MSIRANGE_SHIFT);
reg |= msi_range << RCC_CSR_MSIRANGE_SHIFT;
RCC_CSR = reg;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Returns the most recent received data by the I2Cx peripheral. */ | uint8_t I2C_RecvData(I2C_Module *I2Cx) | /* Returns the most recent received data by the I2Cx peripheral. */
uint8_t I2C_RecvData(I2C_Module *I2Cx) | {
assert_param(IS_I2C_PERIPH(I2Cx));
return (uint8_t)I2Cx->DAT;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Set DMP output rate. Only used when DMP is on. */ | int dmp_set_fifo_rate(unsigned short rate) | /* Set DMP output rate. Only used when DMP is on. */
int dmp_set_fifo_rate(unsigned short rate) | {
const unsigned char regs_end[12] = {DINAFE, DINAF2, DINAAB,
0xc4, DINAAA, DINAF1, DINADF, DINADF, 0xBB, 0xAF, DINADF, DINADF};
unsigned short div;
unsigned char tmp[8];
if (rate > DMP_SAMPLE_RATE)
return -1;
div = DMP_SAMPLE_RATE / rate - 1;
tmp[0] = (unsigned char)((div >> 8) & 0xFF);
tmp[1] = (unsigned char)(div & 0xFF);
if (mpu_write_mem(D_0_22, 2, tmp))
return -1;
if (mpu_write_mem(CFG_6, 12, (unsigned char*)regs_end))
return -1;
dmp.fifo_rate = rate;
return 0;
} | Luos-io/luos_engine | C++ | MIT License | 496 |
/* Use only for very small delays ( < 1 msec). Should probably use a lookup table, really, as the multiplications take much too long with short delays. This is a "reasonable" implementation, though (and the first constant multiplications gets optimized away if the delay is a constant) */ | void __udelay(unsigned long us) | /* Use only for very small delays ( < 1 msec). Should probably use a lookup table, really, as the multiplications take much too long with short delays. This is a "reasonable" implementation, though (and the first constant multiplications gets optimized away if the delay is a constant) */
void __udelay(unsigned long us) | {
unsigned int lpj = current_cpu_data.udelay_val;
__delay((us * 0x000010c7ull * HZ * lpj) >> 32);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Writes data to the specified Data Backup Register. */ | void UTIL_WriteBackupRegister(u16 BKP_DR, u16 Data) | /* Writes data to the specified Data Backup Register. */
void UTIL_WriteBackupRegister(u16 BKP_DR, u16 Data) | {
*(vu16 *)( BKP_BASE + 4 * BKP_DR ) = Data;
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* Return a compatible lock_state. If no initialized lock_state structure exists, return an uninitialized one. */ | static struct nfs4_lock_state* nfs4_alloc_lock_state(struct nfs4_state *state, fl_owner_t fl_owner) | /* Return a compatible lock_state. If no initialized lock_state structure exists, return an uninitialized one. */
static struct nfs4_lock_state* nfs4_alloc_lock_state(struct nfs4_state *state, fl_owner_t fl_owner) | {
struct nfs4_lock_state *lsp;
struct nfs_client *clp = state->owner->so_client;
lsp = kzalloc(sizeof(*lsp), GFP_KERNEL);
if (lsp == NULL)
return NULL;
rpc_init_wait_queue(&lsp->ls_sequence.wait, "lock_seqid_waitqueue");
spin_lock_init(&lsp->ls_sequence.lock);
INIT_LIST_HEAD(&lsp->ls_sequence.list);
lsp->ls_seqid.sequence = &lsp->ls_sequence;
atomic_set(&lsp->ls_count, 1);
lsp->ls_state = state;
lsp->ls_owner = fl_owner;
spin_lock(&clp->cl_lock);
nfs_alloc_unique_id(&clp->cl_lockowner_id, &lsp->ls_id, 1, 64);
spin_unlock(&clp->cl_lock);
INIT_LIST_HEAD(&lsp->ls_locks);
return lsp;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Read and write a data element from and to the SPI interface. */ | unsigned long SPISingleDataReadWrite(unsigned long ulBase, unsigned long ulWData) | /* Read and write a data element from and to the SPI interface. */
unsigned long SPISingleDataReadWrite(unsigned long ulBase, unsigned long ulWData) | {
unsigned long ulReadTemp;
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE)||(ulBase == SPI3_BASE) );
while((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_GO_BUSY))
{
}
xHWREG(ulBase + SPI_TX0) = ulWData;
xHWREG(ulBase + SPI_CNTRL) |= SPI_CNTRL_GO_BUSY;
while((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_GO_BUSY))
{
}
ulReadTemp = xHWREG(ulBase + SPI_RX0);
return ulReadTemp;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Toggles GPIO.
Toggles GPIO by GPIO number according to MUX list */ | void gpio_toggle(uint32_t gpio) | /* Toggles GPIO.
Toggles GPIO by GPIO number according to MUX list */
void gpio_toggle(uint32_t gpio) | {
uint32_t port = GPIO(gpio / 32);
GPIO_PTOR(port) = GPIO_OFFSET(gpio);
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* This function prepares node at @node to be written to the media - it calculates node CRC, fills the common header, and adds proper padding up to the next minimum I/O unit if @pad is not zero. */ | void ubifs_prepare_node(struct ubifs_info *c, void *node, int len, int pad) | /* This function prepares node at @node to be written to the media - it calculates node CRC, fills the common header, and adds proper padding up to the next minimum I/O unit if @pad is not zero. */
void ubifs_prepare_node(struct ubifs_info *c, void *node, int len, int pad) | {
uint32_t crc;
struct ubifs_ch *ch = node;
unsigned long long sqnum = next_sqnum(c);
ubifs_assert(len >= UBIFS_CH_SZ);
ch->magic = cpu_to_le32(UBIFS_NODE_MAGIC);
ch->len = cpu_to_le32(len);
ch->group_type = UBIFS_NO_NODE_GROUP;
ch->sqnum = cpu_to_le64(sqnum);
ch->padding[0] = ch->padding[1] = 0;
crc = crc32(UBIFS_CRC32_INIT, node + 8, len - 8);
ch->crc = cpu_to_le32(crc);
if (pad) {
len = ALIGN(len, 8);
pad = ALIGN(len, c->min_io_size) - len;
ubifs_pad(c, node + len, pad);
}
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* This API computes the number of bytes of accel FIFO data which is to be parsed.
Static Function Declarations */ | static void get_accel_len_to_parse(u8 *data_index, u8 *data_read_length, u8 accel_frame_count, u8 fifo_data_select, struct fifo_configuration *fifo_conf) | /* This API computes the number of bytes of accel FIFO data which is to be parsed.
Static Function Declarations */
static void get_accel_len_to_parse(u8 *data_index, u8 *data_read_length, u8 accel_frame_count, u8 fifo_data_select, struct fifo_configuration *fifo_conf) | {
*data_index = fifo_conf->accel_byte_start_index;
if (fifo_data_select == BMA2x2_FIFO_XYZ_DATA_ENABLED)
{
*data_read_length = accel_frame_count *
BMA2x2_FIFO_XYZ_AXES_FRAME_SIZE;
}
else
{
*data_read_length = accel_frame_count *
BMA2x2_FIFO_SINGLE_AXIS_FRAME_SIZE;
}
if ((*data_read_length) > fifo_conf->fifo_length)
{
*data_read_length = fifo_conf->fifo_length;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Get either a Short Allocation Descriptor or a Long Allocation Descriptor from file's data. */ | EFI_STATUS GetAllocationDescriptor(IN UDF_FE_RECORDING_FLAGS RecordingFlags, IN VOID *Data, IN OUT UINT64 *Offset, IN UINT64 Length, OUT VOID **FoundAd) | /* Get either a Short Allocation Descriptor or a Long Allocation Descriptor from file's data. */
EFI_STATUS GetAllocationDescriptor(IN UDF_FE_RECORDING_FLAGS RecordingFlags, IN VOID *Data, IN OUT UINT64 *Offset, IN UINT64 Length, OUT VOID **FoundAd) | {
if (RecordingFlags == LongAdsSequence) {
return GetLongAdFromAds (
Data,
Offset,
Length,
(UDF_LONG_ALLOCATION_DESCRIPTOR **)FoundAd
);
} else if (RecordingFlags == ShortAdsSequence) {
return GetShortAdFromAds (
Data,
Offset,
Length,
(UDF_SHORT_ALLOCATION_DESCRIPTOR **)FoundAd
);
}
ASSERT (FALSE);
return EFI_DEVICE_ERROR;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Generates EC key and returns EC public key (X, Y), Please note, this function uses pseudo random number generator. The caller must make sure */ | BOOLEAN EFIAPI EcGenerateKey(IN OUT VOID *EcContext, OUT UINT8 *PublicKey, IN OUT UINTN *PublicKeySize) | /* Generates EC key and returns EC public key (X, Y), Please note, this function uses pseudo random number generator. The caller must make sure */
BOOLEAN EFIAPI EcGenerateKey(IN OUT VOID *EcContext, OUT UINT8 *PublicKey, IN OUT UINTN *PublicKeySize) | {
CALL_CRYPTO_SERVICE (EcGenerateKey, (EcContext, PublicKey, PublicKeySize), FALSE);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Removes all the events in the protocol database that match Event. */ | EFI_STATUS CoreUnregisterProtocolNotify(IN EFI_EVENT Event) | /* Removes all the events in the protocol database that match Event. */
EFI_STATUS CoreUnregisterProtocolNotify(IN EFI_EVENT Event) | {
EFI_STATUS Status;
do {
Status = CoreUnregisterProtocolNotifyEvent (Event);
} while (!EFI_ERROR (Status));
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Extend the matching conditions of TMR4 OC channel. */ | void TMR4_OC_ExtendControlCmd(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, en_functional_state_t enNewState) | /* Extend the matching conditions of TMR4 OC channel. */
void TMR4_OC_ExtendControlCmd(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, en_functional_state_t enNewState) | {
__IO uint16_t *OCER;
DDL_ASSERT(IS_TMR4_UNIT(TMR4x));
DDL_ASSERT(IS_TMR4_OC_CH(u32Ch));
DDL_ASSERT(IS_FUNCTIONAL_STATE(enNewState));
OCER = TMR4_OCER(TMR4x, u32Ch);
MODIFY_REG16(*OCER, TMR4_OCER_MCECx_MASK(u32Ch), TMR4_OCER_MCECx(u32Ch, enNewState));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* reads and returns guest's timestamp counter "register" guest_tsc = host_tsc + tsc_offset */ | static u64 guest_read_tsc(void) | /* reads and returns guest's timestamp counter "register" guest_tsc = host_tsc + tsc_offset */
static u64 guest_read_tsc(void) | {
u64 host_tsc, tsc_offset;
rdtscll(host_tsc);
tsc_offset = vmcs_read64(TSC_OFFSET);
return host_tsc + tsc_offset;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Utility function to check if generic address points to NULL */ | STATIC BOOLEAN EFIAPI IsNullGenericAddress(IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *Address) | /* Utility function to check if generic address points to NULL */
STATIC BOOLEAN EFIAPI IsNullGenericAddress(IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *Address) | {
if ((Address == NULL) ||
((Address->AddressSpaceId == EFI_ACPI_6_4_SYSTEM_MEMORY) &&
(Address->Address == 0x0)))
{
return TRUE;
}
return FALSE;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Find out the protection domain structure for a given PCI device. This will give us the pointer to the page table root for example. */ | static struct protection_domain* domain_for_device(struct device *dev) | /* Find out the protection domain structure for a given PCI device. This will give us the pointer to the page table root for example. */
static struct protection_domain* domain_for_device(struct device *dev) | {
struct protection_domain *dom;
struct iommu_dev_data *dev_data, *alias_data;
unsigned long flags;
u16 devid, alias;
devid = get_device_id(dev);
alias = amd_iommu_alias_table[devid];
dev_data = get_dev_data(dev);
alias_data = get_dev_data(dev_data->alias);
if (!alias_data)
return NULL;
read_lock_irqsave(&amd_iommu_devtable_lock, flags);
dom = dev_data->domain;
if (dom == NULL &&
alias_data->domain != NULL) {
__attach_device(dev, alias_data->domain);
dom = alias_data->domain;
}
read_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
return dom;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* BACnet-Error ::= CHOICE { addListElement ChangeList-Error, removeListElement ChangeList-Error, writePropertyMultiple WritePropertyMultiple-Error, confirmedPrivatTransfer ConfirmedPrivateTransfer-Error, vtClose VTClose-Error, readRange ObjectAccessService-Error Error } */ | static guint fBACnetError(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, guint service) | /* BACnet-Error ::= CHOICE { addListElement ChangeList-Error, removeListElement ChangeList-Error, writePropertyMultiple WritePropertyMultiple-Error, confirmedPrivatTransfer ConfirmedPrivateTransfer-Error, vtClose VTClose-Error, readRange ObjectAccessService-Error Error } */
static guint fBACnetError(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, guint service) | {
switch (service) {
case 8:
case 9:
offset = fChangeListError(tvb, pinfo, tree, offset);
break;
case 10:
offset = fCreateObjectError(tvb, pinfo, tree, offset);
break;
case 16:
offset = fWritePropertyMultipleError(tvb, pinfo, tree, offset);
break;
case 18:
offset = fConfirmedPrivateTransferError(tvb, pinfo, tree, offset);
break;
case 22:
offset = fVTCloseError(tvb, pinfo, tree, offset);
break;
default:
return fError(tvb, pinfo, tree, offset);
}
return offset;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Configures ACK override behavior of the I2C Slave. */ | void I2CSlaveACKOverride(uint32_t ui32Base, bool bEnable) | /* Configures ACK override behavior of the I2C Slave. */
void I2CSlaveACKOverride(uint32_t ui32Base, bool bEnable) | {
ASSERT(_I2CBaseValid(ui32Base));
if(bEnable)
{
HWREG(ui32Base + I2C_O_SACKCTL) |= I2C_SACKCTL_ACKOEN;
}
else
{
HWREG(ui32Base + I2C_O_SACKCTL) &= ~I2C_SACKCTL_ACKOEN;
}
} | micropython/micropython | C++ | Other | 18,334 |
/* slave mode tx data transmit phase adjust set. */ | void SPI_SlaveAdjust(SPI_TypeDef *spi, SPI_SlaveAdjust_TypeDef adjust_value) | /* slave mode tx data transmit phase adjust set. */
void SPI_SlaveAdjust(SPI_TypeDef *spi, SPI_SlaveAdjust_TypeDef adjust_value) | {
(adjust_value) ? SET_BIT(spi->CCR, SPI_CCR_RXEDGE) : CLEAR_BIT(spi->CCR, SPI_CCR_RXEDGE);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Return Value: TRUE if the @channel is buffered. */ | gboolean g_io_channel_get_buffered(GIOChannel *channel) | /* Return Value: TRUE if the @channel is buffered. */
gboolean g_io_channel_get_buffered(GIOChannel *channel) | {
g_return_val_if_fail (channel != NULL, FALSE);
return channel->use_buffer;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Enables an External Interrupt event output.
Enables one or more output events from the External Interrupt module. See here for a list of events this module supports. */ | void extint_enable_events(struct extint_events *const events) | /* Enables an External Interrupt event output.
Enables one or more output events from the External Interrupt module. See here for a list of events this module supports. */
void extint_enable_events(struct extint_events *const events) | {
Assert(events);
Eic *const eics[EIC_INST_NUM] = EIC_INSTS;
for (uint32_t i = 0; i < EIC_INST_NUM; i++) {
uint32_t event_mask = 0;
for (uint32_t j = 0; j < 32; j++) {
if (events->generate_event_on_detect[(32 * i) + j]) {
event_mask |= (1UL << j);
}
}
eics[i]->EVCTRL.reg |= event_mask;
}
} | memfault/zero-to-main | C++ | null | 200 |
/* Disable the PWM output of the PWM module.
The */ | void PWMOutputDisable(unsigned long ulBase, unsigned long ulChannel) | /* Disable the PWM output of the PWM module.
The */
void PWMOutputDisable(unsigned long ulBase, unsigned long ulChannel) | {
unsigned long ulChannelTemp;
ulChannelTemp = ulChannel;
xASSERT((ulBase == PWMA_BASE) || (ulBase == PWMB_BASE));
xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 5)));
xHWREG(ulBase + PWM_POEN) &= ~(1 << (ulChannelTemp));
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Returns : OK if register call-back succeeded, others if failed. */ | s32 ccu_reg_mclk_cb(__maybe_unused u32 mclk, __pNotifier_t pcb) | /* Returns : OK if register call-back succeeded, others if failed. */
s32 ccu_reg_mclk_cb(__maybe_unused u32 mclk, __pNotifier_t pcb) | {
return notifier_insert(&apbs2_notifier_head, pcb);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Function: MX25_ENSO Arguments: None. Description: The ENSO instruction is for entering the secured OTP mode. Return Message: FlashOperationSuccess */ | ReturnMsg MX25_ENSO(void) | /* Function: MX25_ENSO Arguments: None. Description: The ENSO instruction is for entering the secured OTP mode. Return Message: FlashOperationSuccess */
ReturnMsg MX25_ENSO(void) | {
CS_Low();
SendByte( FLASH_CMD_ENSO, SIO );
CS_High();
return FlashOperationSuccess;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Release the memory region(s) being used by 'port'. */ | static void sa1100_release_port(struct uart_port *port) | /* Release the memory region(s) being used by 'port'. */
static void sa1100_release_port(struct uart_port *port) | {
struct sa1100_port *sport = (struct sa1100_port *)port;
release_mem_region(sport->port.mapbase, UART_PORT_SIZE);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Set the specified Thread Flags of a thread. */ | __STATIC_INLINE uint32_t isrRtxThreadFlagsSet(osThreadId_t thread_id, uint32_t flags) | /* Set the specified Thread Flags of a thread. */
__STATIC_INLINE uint32_t isrRtxThreadFlagsSet(osThreadId_t thread_id, uint32_t flags) | {
EvrRtxThreadFlagsError(thread, (int32_t)osErrorParameter);
return ((uint32_t)osErrorParameter);
}
if (thread->state == osRtxThreadTerminated) {
EvrRtxThreadFlagsError(thread, (int32_t)osErrorResource);
return ((uint32_t)osErrorResource);
}
thread_flags = ThreadFlagsSet(thread, flags);
osRtxPostProcess(osRtxObject(thread));
EvrRtxThreadFlagsSetDone(thread, thread_flags);
return thread_flags;
} | ARMmbed/DAPLink | C++ | Apache License 2.0 | 2,140 |
/* If the EXT2_FEATURE_COMPAT_EXT_ATTR feature of this file system is not set, set it. */ | static void ext2_xattr_update_super_block(struct super_block *sb) | /* If the EXT2_FEATURE_COMPAT_EXT_ATTR feature of this file system is not set, set it. */
static void ext2_xattr_update_super_block(struct super_block *sb) | {
if (EXT2_HAS_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR))
return;
EXT2_SET_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR);
sb->s_dirt = 1;
mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* It checks skb, netlink header and msg sizes, and calls callback helper. */ | static void cn_rx_skb(struct sk_buff *__skb) | /* It checks skb, netlink header and msg sizes, and calls callback helper. */
static void cn_rx_skb(struct sk_buff *__skb) | {
struct nlmsghdr *nlh;
int err;
struct sk_buff *skb;
skb = skb_get(__skb);
if (skb->len >= NLMSG_SPACE(0)) {
nlh = nlmsg_hdr(skb);
if (nlh->nlmsg_len < sizeof(struct cn_msg) ||
skb->len < nlh->nlmsg_len ||
nlh->nlmsg_len > CONNECTOR_MAX_MSG_SIZE) {
kfree_skb(skb);
return;
}
err = cn_call_callback(skb);
if (err < 0)
kfree_skb(skb);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Find the top of screen menu base on the previous record menu info. */ | LIST_ENTRY* FindTopOfScreenMenuOption(IN LIST_ENTRY *HighLightMenu) | /* Find the top of screen menu base on the previous record menu info. */
LIST_ENTRY* FindTopOfScreenMenuOption(IN LIST_ENTRY *HighLightMenu) | {
LIST_ENTRY *NewPos;
UI_MENU_OPTION *MenuOption;
UINTN TopRow;
UINTN BottomRow;
TopRow = gStatementDimensions.TopRow + SCROLL_ARROW_HEIGHT;
BottomRow = gStatementDimensions.BottomRow - SCROLL_ARROW_HEIGHT;
NewPos = gMenuOption.ForwardLink;
MenuOption = MENU_OPTION_FROM_LINK (NewPos);
while (!IsTopOfScreeMenuOption (MenuOption)) {
NewPos = NewPos->ForwardLink;
if (NewPos == &gMenuOption) {
break;
}
MenuOption = MENU_OPTION_FROM_LINK (NewPos);
}
if (NewPos == &gMenuOption) {
return NULL;
}
if (GetDistanceBetweenMenus (HighLightMenu, NewPos) + 1 > BottomRow - TopRow) {
return NULL;
}
return NewPos;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Add an entry to the mDiscoveredList. Allocate memory to store the DriverEntry, and initilize any state variables. Read the Depex from the FV and store it in DriverEntry. Pre-process the Depex to set the SOR, Before and After state. The Discovered list is never free'ed and contains booleans that represent the other possible DXE driver states. */ | EFI_STATUS CoreAddToDriverList(IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv, IN EFI_HANDLE FvHandle, IN EFI_GUID *DriverName, IN EFI_FV_FILETYPE Type) | /* Add an entry to the mDiscoveredList. Allocate memory to store the DriverEntry, and initilize any state variables. Read the Depex from the FV and store it in DriverEntry. Pre-process the Depex to set the SOR, Before and After state. The Discovered list is never free'ed and contains booleans that represent the other possible DXE driver states. */
EFI_STATUS CoreAddToDriverList(IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv, IN EFI_HANDLE FvHandle, IN EFI_GUID *DriverName, IN EFI_FV_FILETYPE Type) | {
EFI_CORE_DRIVER_ENTRY *DriverEntry;
DriverEntry = AllocateZeroPool (sizeof (EFI_CORE_DRIVER_ENTRY));
ASSERT (DriverEntry != NULL);
if (Type == EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {
DriverEntry->IsFvImage = TRUE;
}
DriverEntry->Signature = EFI_CORE_DRIVER_ENTRY_SIGNATURE;
CopyGuid (&DriverEntry->FileName, DriverName);
DriverEntry->FvHandle = FvHandle;
DriverEntry->Fv = Fv;
DriverEntry->FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, DriverName);
CoreGetDepexSectionAndPreProccess (DriverEntry);
CoreAcquireDispatcherLock ();
InsertTailList (&mDiscoveredList, &DriverEntry->Link);
CoreReleaseDispatcherLock ();
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Copy data from socket buffer to an application provided receive buffer. */ | VOID SockSetTcpRxData(IN SOCKET *Sock, IN VOID *TcpRxData, IN UINT32 RcvdBytes, IN BOOLEAN IsUrg) | /* Copy data from socket buffer to an application provided receive buffer. */
VOID SockSetTcpRxData(IN SOCKET *Sock, IN VOID *TcpRxData, IN UINT32 RcvdBytes, IN BOOLEAN IsUrg) | {
UINT32 Index;
UINT32 CopyBytes;
UINT32 OffSet;
EFI_TCP4_RECEIVE_DATA *RxData;
EFI_TCP4_FRAGMENT_DATA *Fragment;
RxData = (EFI_TCP4_RECEIVE_DATA *)TcpRxData;
OffSet = 0;
ASSERT (RxData->DataLength >= RcvdBytes);
RxData->DataLength = RcvdBytes;
RxData->UrgentFlag = IsUrg;
for (Index = 0; (Index < RxData->FragmentCount) && (RcvdBytes > 0); Index++) {
Fragment = &RxData->FragmentTable[Index];
CopyBytes = MIN ((UINT32)(Fragment->FragmentLength), RcvdBytes);
NetbufQueCopy (
Sock->RcvBuffer.DataQueue,
OffSet,
CopyBytes,
Fragment->FragmentBuffer
);
Fragment->FragmentLength = CopyBytes;
RcvdBytes -= CopyBytes;
OffSet += CopyBytes;
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Since: 2.24 Returns: the allocated memory, or NULL. */ | gpointer g_try_malloc_n(gsize n_blocks, gsize n_block_bytes) | /* Since: 2.24 Returns: the allocated memory, or NULL. */
gpointer g_try_malloc_n(gsize n_blocks, gsize n_block_bytes) | {
if (SIZE_OVERFLOWS (n_blocks, n_block_bytes))
return NULL;
return g_try_malloc (n_blocks * n_block_bytes);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details. */ | EFI_STATUS SdPeimAllSendCid(IN SD_PEIM_HC_SLOT *Slot) | /* Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details. */
EFI_STATUS SdPeimAllSendCid(IN SD_PEIM_HC_SLOT *Slot) | {
SD_COMMAND_BLOCK SdCmdBlk;
SD_STATUS_BLOCK SdStatusBlk;
SD_COMMAND_PACKET Packet;
EFI_STATUS Status;
ZeroMem (&SdCmdBlk, sizeof (SdCmdBlk));
ZeroMem (&SdStatusBlk, sizeof (SdStatusBlk));
ZeroMem (&Packet, sizeof (Packet));
Packet.SdCmdBlk = &SdCmdBlk;
Packet.SdStatusBlk = &SdStatusBlk;
Packet.Timeout = SD_TIMEOUT;
SdCmdBlk.CommandIndex = SD_ALL_SEND_CID;
SdCmdBlk.CommandType = SdCommandTypeBcr;
SdCmdBlk.ResponseType = SdResponseTypeR2;
SdCmdBlk.CommandArgument = 0;
Status = SdPeimExecCmd (Slot, &Packet);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* device_create_bin_file - create sysfs binary attribute file for device. @dev: device. @attr: device binary attribute descriptor. */ | int device_create_bin_file(struct device *dev, const struct bin_attribute *attr) | /* device_create_bin_file - create sysfs binary attribute file for device. @dev: device. @attr: device binary attribute descriptor. */
int device_create_bin_file(struct device *dev, const struct bin_attribute *attr) | {
int error = -EINVAL;
if (dev)
error = sysfs_create_bin_file(&dev->kobj, attr);
return error;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns the UART hardware flow control mode currently in use. */ | uint32_t UARTFlowControlGet(uint32_t ui32Base) | /* Returns the UART hardware flow control mode currently in use. */
uint32_t UARTFlowControlGet(uint32_t ui32Base) | {
ASSERT(_UARTBaseValid(ui32Base));
return (HWREG(ui32Base + UART_O_CTL) & (UART_FLOWCONTROL_TX |
UART_FLOWCONTROL_RX));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* stm32_copro_is_running() - Is the STM32 remote processor running @dev: corresponding STM32 remote processor device */ | static int stm32_copro_is_running(struct udevice *dev) | /* stm32_copro_is_running() - Is the STM32 remote processor running @dev: corresponding STM32 remote processor device */
static int stm32_copro_is_running(struct udevice *dev) | {
return (readl(TAMP_COPRO_STATE) == TAMP_COPRO_STATE_OFF);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Unregister the adapter from the i2c layer, then free the structure. */ | void intel_i2c_destroy(struct i2c_adapter *adapter) | /* Unregister the adapter from the i2c layer, then free the structure. */
void intel_i2c_destroy(struct i2c_adapter *adapter) | {
struct intel_i2c_chan *chan;
if (!adapter)
return;
chan = container_of(adapter,
struct intel_i2c_chan,
adapter);
i2c_del_adapter(&chan->adapter);
kfree(chan);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* SD_Detection checks detection and writes msg on display. */ | void SD_Detection(void) | /* SD_Detection checks detection and writes msg on display. */
void SD_Detection(void) | {
static uint8_t prev_status = 2;
if(BSP_SD_IsDetected() != SD_PRESENT)
{
if(prev_status != SD_NOT_PRESENT)
{
prev_status = SD_NOT_PRESENT;
BSP_LCD_SetTextColor(LCD_COLOR_RED);
BSP_LCD_DisplayStringAt(5, BSP_LCD_GetYSize()-15, (uint8_t *)"SD Not Connected", LEFT_MODE);
}
}
else if (prev_status != SD_PRESENT)
{
prev_status = SD_PRESENT;
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
BSP_LCD_DisplayStringAt(5, BSP_LCD_GetYSize()-15, (uint8_t *)"SD Connected ", LEFT_MODE);
}
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* See _g_freedesktop_dbus_call_remove_match_sync() for the synchronous, blocking version of this method. */ | void _g_freedesktop_dbus_call_remove_match(_GFreedesktopDBus *proxy, const gchar *arg_rule, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) | /* See _g_freedesktop_dbus_call_remove_match_sync() for the synchronous, blocking version of this method. */
void _g_freedesktop_dbus_call_remove_match(_GFreedesktopDBus *proxy, const gchar *arg_rule, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) | {
g_dbus_proxy_call (G_DBUS_PROXY (proxy),
"RemoveMatch",
g_variant_new ("(s)",
arg_rule),
G_DBUS_CALL_FLAGS_NONE,
-1,
cancellable,
callback,
user_data);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Handles the GET_DESCRIPTOR callback. All required descriptors must be handled here. */ | static const USBDescriptor* get_descriptor(USBDriver *usbp, uint8_t dtype, uint8_t dindex, uint16_t lang) | /* Handles the GET_DESCRIPTOR callback. All required descriptors must be handled here. */
static const USBDescriptor* get_descriptor(USBDriver *usbp, uint8_t dtype, uint8_t dindex, uint16_t lang) | {
(void)usbp;
(void)lang;
switch (dtype) {
case USB_DESCRIPTOR_DEVICE:
return &vcom_device_descriptor;
case USB_DESCRIPTOR_CONFIGURATION:
return &vcom_configuration_descriptor;
case USB_DESCRIPTOR_STRING:
if (dindex < 4)
{
if(dindex == 3)
{
Get_SerialNum((uint8_t*)&usb_serial_number.bPropertyData[INDEX_OF_WCHAR_FOR_UNIQUE_ID]);
}
return &vcom_strings[dindex];
}
}
return NULL;
} | nanoframework/nf-interpreter | C++ | MIT License | 293 |
/* decode the IR frame when all the frame is received, the rc5_frame_received will equal to YES */ | void rc5_decode(rc5_frame_struct *rc5_frame) | /* decode the IR frame when all the frame is received, the rc5_frame_received will equal to YES */
void rc5_decode(rc5_frame_struct *rc5_frame) | {
if(rc5_frame_received != NO){
rc5_data = rc5_tmp_packet.data ;
rc5_frame->address = (rc5_tmp_packet.data >> 6) & 0x1F;
rc5_frame->command = (rc5_tmp_packet.data) & 0x3F;
rc5_frame->field_bit = (rc5_tmp_packet.data >> 12) & 0x1;
rc5_frame->toggle_bit = (rc5_tmp_packet.data >> 11) & 0x1;
if(rc5_frame->field_bit == 0x00){
rc5_frame->command = (1<<6)| rc5_frame->command;
}
rc5_frame_received = NO;
rc5_reset_packet();
}
} | liuxuming/trochili | C++ | Apache License 2.0 | 132 |
/* Cleans up the LED blink driver. This is intended to be used upon program exit. */ | void LedBlinkExit(void) | /* Cleans up the LED blink driver. This is intended to be used upon program exit. */
void LedBlinkExit(void) | {
LL_GPIO_ResetOutputPin(GPIOF, LL_GPIO_PIN_8);
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Offsets are specified to support either contiguous or discontiguous memory transfers, or repeated access to a hardware register, as needed. When accessing hardware registers, both offsets are normally zero. */ | void edma_set_src_index(unsigned slot, s16 src_bidx, s16 src_cidx) | /* Offsets are specified to support either contiguous or discontiguous memory transfers, or repeated access to a hardware register, as needed. When accessing hardware registers, both offsets are normally zero. */
void edma_set_src_index(unsigned slot, s16 src_bidx, s16 src_cidx) | {
unsigned ctlr;
ctlr = EDMA_CTLR(slot);
slot = EDMA_CHAN_SLOT(slot);
if (slot < edma_info[ctlr]->num_slots) {
edma_parm_modify(ctlr, PARM_SRC_DST_BIDX, slot,
0xffff0000, src_bidx);
edma_parm_modify(ctlr, PARM_SRC_DST_CIDX, slot,
0xffff0000, src_cidx);
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Request the PE to perform a Fast Role Swap. */ | USBPD_StatusTypeDef USBPD_DPM_RequestFastRoleSwap(uint8_t PortNum) | /* Request the PE to perform a Fast Role Swap. */
USBPD_StatusTypeDef USBPD_DPM_RequestFastRoleSwap(uint8_t PortNum) | {
return USBPD_PE_Request_CtrlMessage(PortNum, USBPD_CONTROLMSG_FR_SWAP, USBPD_SOPTYPE_SOP);
} | st-one/X-CUBE-USB-PD | C++ | null | 110 |
/* Returns the obtained response value, or -1 for an error. */ | unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, int direct, unsigned int verb, unsigned int parm) | /* Returns the obtained response value, or -1 for an error. */
unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, int direct, unsigned int verb, unsigned int parm) | {
unsigned cmd = make_codec_cmd(codec, nid, direct, verb, parm);
unsigned int res;
codec_exec_verb(codec, cmd, &res);
return res;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Aborts an ongoing job running on serializer.
Aborts an ongoing job. */ | void i2s_serializer_abort_job(struct i2s_module *const module_inst, const enum i2s_serializer serializer, const enum i2s_job_type job_type) | /* Aborts an ongoing job running on serializer.
Aborts an ongoing job. */
void i2s_serializer_abort_job(struct i2s_module *const module_inst, const enum i2s_serializer serializer, const enum i2s_job_type job_type) | {
Assert(module_inst);
Assert(module_inst->hw);
Assert(serializer < I2S_SERIALIZER_N);
if (job_type == I2S_JOB_WRITE_BUFFER) {
module_inst->hw->INTENCLR.reg = (I2S_INTENCLR_TXRDY0 << serializer);
module_inst->serializer[serializer].job_status = STATUS_ABORTED;
} else if (job_type == I2S_JOB_READ_BUFFER) {
module_inst->hw->INTENCLR.reg = (I2S_INTENCLR_RXRDY0 << serializer);
module_inst->serializer[serializer].job_status = STATUS_ABORTED;
}
} | memfault/zero-to-main | C++ | null | 200 |
/* This API is used to check whether the auxiliary Mag is enabled or not in the sensor. */ | uint16_t bma4_get_mag_enable(uint8_t *mag_en, struct bma4_dev *dev) | /* This API is used to check whether the auxiliary Mag is enabled or not in the sensor. */
uint16_t bma4_get_mag_enable(uint8_t *mag_en, struct bma4_dev *dev) | {
uint16_t rslt = 0;
uint8_t data = 0;
if (dev == NULL) {
rslt |= BMA4_E_NULL_PTR;
} else {
rslt |= bma4_read_regs(BMA4_POWER_CTRL_ADDR, &data, 1, dev);
if (rslt == BMA4_OK)
*mag_en = BMA4_GET_BITS_POS_0(data, BMA4_MAG_ENABLE);
}
return rslt;
} | arendst/Tasmota | C++ | GNU General Public License v3.0 | 21,318 |
/* Return value is the character in the string which caused the parse to end (typically a null terminator, if @str is completely parseable). */ | char* get_options(const char *str, int nints, int *ints) | /* Return value is the character in the string which caused the parse to end (typically a null terminator, if @str is completely parseable). */
char* get_options(const char *str, int nints, int *ints) | {
int res, i = 1;
while (i < nints) {
res = get_option ((char **)&str, ints + i);
if (res == 0)
break;
if (res == 3) {
int range_nums;
range_nums = get_range((char **)&str, ints + i);
if (range_nums < 0)
break;
i += (range_nums - 1);
}
i++;
if (res == 1)
break;
}
ints[0] = i - 1;
return (char *)str;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Dequantize 4x4 block of DC values for 16x16 macroblock. */ | static void rv34_dequant4x4_16x16(DCTELEM *block, int Qdc, int Q) | /* Dequantize 4x4 block of DC values for 16x16 macroblock. */
static void rv34_dequant4x4_16x16(DCTELEM *block, int Qdc, int Q) | {
int i;
for(i = 0; i < 3; i++)
block[rv34_dezigzag[i]] = (block[rv34_dezigzag[i]] * Qdc + 8) >> 4;
for(; i < 16; i++)
block[rv34_dezigzag[i]] = (block[rv34_dezigzag[i]] * Q + 8) >> 4;
}
/** @} | DC-SWAT/DreamShell | C++ | null | 404 |
/* Set higher or lower the codec volume level. */ | int32_t CS42L51_SetVolume(CS42L51_Object_t *pObj, uint32_t InputOutput, uint8_t Volume) | /* Set higher or lower the codec volume level. */
int32_t CS42L51_SetVolume(CS42L51_Object_t *pObj, uint32_t InputOutput, uint8_t Volume) | {
int32_t ret;
uint8_t convertedvol;
if (InputOutput != VOLUME_OUTPUT)
{
ret = CS42L51_ERROR;
}
else
{
convertedvol = VOLUME_CONVERT(Volume);
ret = cs42l51_write_reg(&pObj->Ctx, CS42L51_AOUTA_VOL_CTRL, &convertedvol, 1);
ret += cs42l51_write_reg(&pObj->Ctx, CS42L51_AOUTB_VOL_CTRL, &convertedvol, 1);
}
if (ret != CS42L51_OK)
{
ret = CS42L51_ERROR;
}
return ret;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* If 16-bit I/O port operations are not supported, then ASSERT(). */ | UINT16 EFIAPI IoWrite16(IN UINTN Port, IN UINT16 Value) | /* If 16-bit I/O port operations are not supported, then ASSERT(). */
UINT16 EFIAPI IoWrite16(IN UINTN Port, IN UINT16 Value) | {
ASSERT ((Port & 1) == 0);
return (UINT16)IoWriteWorker (Port, SMM_IO_UINT16, Value);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Unlock a GTS that was previously locked with gru_find_lock_gts(). */ | static void gru_unlock_gts(struct gru_thread_state *gts) | /* Unlock a GTS that was previously locked with gru_find_lock_gts(). */
static void gru_unlock_gts(struct gru_thread_state *gts) | {
mutex_unlock(>s->ts_ctxlock);
up_read(¤t->mm->mmap_sem);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* dispatch a get volume entry by ID operation */ | int afs_vl_get_entry_by_id(struct in_addr *addr, struct key *key, afs_volid_t volid, afs_voltype_t voltype, struct afs_cache_vlocation *entry, const struct afs_wait_mode *wait_mode) | /* dispatch a get volume entry by ID operation */
int afs_vl_get_entry_by_id(struct in_addr *addr, struct key *key, afs_volid_t volid, afs_voltype_t voltype, struct afs_cache_vlocation *entry, const struct afs_wait_mode *wait_mode) | {
struct afs_call *call;
__be32 *bp;
_enter("");
call = afs_alloc_flat_call(&afs_RXVLGetEntryById, 12, 384);
if (!call)
return -ENOMEM;
call->key = key;
call->reply = entry;
call->service_id = VL_SERVICE;
call->port = htons(AFS_VL_PORT);
bp = call->request;
*bp++ = htonl(VLGETENTRYBYID);
*bp++ = htonl(volid);
*bp = htonl(voltype);
return afs_make_call(addr, call, GFP_KERNEL, wait_mode);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns 0 if current can read the floor of the filesystem, and error code otherwise */ | static int smack_sb_statfs(struct dentry *dentry) | /* Returns 0 if current can read the floor of the filesystem, and error code otherwise */
static int smack_sb_statfs(struct dentry *dentry) | {
struct superblock_smack *sbp = dentry->d_sb->s_security;
int rc;
struct smk_audit_info ad;
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS);
smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
rc = smk_curacc(sbp->smk_floor, MAY_READ, &ad);
return rc;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* De-Initializes the Low Level portion of the Host driver. */ | USBH_StatusTypeDef USBH_LL_DeInit(USBH_HandleTypeDef *phost) | /* De-Initializes the Low Level portion of the Host driver. */
USBH_StatusTypeDef USBH_LL_DeInit(USBH_HandleTypeDef *phost) | {
HAL_HCD_DeInit(phost->pData);
return USBH_OK;
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Disable the DMA of the specified SPI port.
The */ | void SPI3PDMADisable(unsigned long ulBase, unsigned long ulDmaMode) | /* Disable the DMA of the specified SPI port.
The */
void SPI3PDMADisable(unsigned long ulBase, unsigned long ulDmaMode) | {
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE) || (ulBase == SPI3_BASE));
xHWREG(ulBase + SPI_DMACTL) &= ~ulDmaMode;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Sync version of i2c send stop condition command. */ | int32_t i2c_m_sync_send_stop(struct i2c_m_sync_desc *const i2c) | /* Sync version of i2c send stop condition command. */
int32_t i2c_m_sync_send_stop(struct i2c_m_sync_desc *const i2c) | {
return _i2c_m_sync_send_stop(&i2c->device);
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* This function delete and build multi-instance device path ConIn console device. */ | EFI_STATUS Var_UpdateConsoleInpOption(VOID) | /* This function delete and build multi-instance device path ConIn console device. */
EFI_STATUS Var_UpdateConsoleInpOption(VOID) | {
return Var_UpdateConsoleOption (L"ConIn", &ConsoleInpMenu, FORM_CON_IN_ID);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Return the number of bytes of space available in the circular buffer. */ | static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb) | /* Return the number of bytes of space available in the circular buffer. */
static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb) | {
if (pb == NULL)
return 0;
return (pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This file is part of the Simba project. */ | int mock_write_spi_module_init(int res) | /* This file is part of the Simba project. */
int mock_write_spi_module_init(int res) | {
harness_mock_write("spi_module_init()",
NULL,
0);
harness_mock_write("spi_module_init(): return (res)",
&res,
sizeof(res));
return (0);
} | eerimoq/simba | C++ | Other | 337 |
/* *** The journal_head may be freed by this call! *** */ | void jbd2_journal_refile_buffer(journal_t *journal, struct journal_head *jh) | /* *** The journal_head may be freed by this call! *** */
void jbd2_journal_refile_buffer(journal_t *journal, struct journal_head *jh) | {
struct buffer_head *bh = jh2bh(jh);
jbd_lock_bh_state(bh);
spin_lock(&journal->j_list_lock);
__jbd2_journal_refile_buffer(jh);
jbd_unlock_bh_state(bh);
jbd2_journal_remove_journal_head(bh);
spin_unlock(&journal->j_list_lock);
__brelse(bh);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Get interrupt vector priority level.
Retrieves the priority level of the requested external interrupt or exception. */ | enum system_interrupt_priority_level system_interrupt_get_priority(const enum system_interrupt_vector vector) | /* Get interrupt vector priority level.
Retrieves the priority level of the requested external interrupt or exception. */
enum system_interrupt_priority_level system_interrupt_get_priority(const enum system_interrupt_vector vector) | {
uint8_t register_num = vector / 4;
uint8_t priority_pos = ((vector % 4) * 8) + (8 - __NVIC_PRIO_BITS);
enum system_interrupt_priority_level priority = SYSTEM_INTERRUPT_PRIORITY_LEVEL_0;
if (vector >= 0) {
priority = (enum system_interrupt_priority_level)
((NVIC->IP[register_num] >> priority_pos) & _SYSTEM_INTERRUPT_PRIORITY_MASK);
} else if (vector == SYSTEM_INTERRUPT_SYSTICK) {
priority = (enum system_interrupt_priority_level)
((SCB->SHP[1] >> _SYSTEM_INTERRUPT_SYSTICK_PRI_POS) & _SYSTEM_INTERRUPT_PRIORITY_MASK);
}
return priority;
} | memfault/zero-to-main | C++ | null | 200 |
/* From experiments, it appears that a USB reset causes USBReEP to re-initialise to 3 (= just the control endpoints). However, a USB bus reset does not disturb the USBMaxPSize settings. */ | static void USBHwEPRealize(int idx, unsigned short wMaxPSize) | /* From experiments, it appears that a USB reset causes USBReEP to re-initialise to 3 (= just the control endpoints). However, a USB bus reset does not disturb the USBMaxPSize settings. */
static void USBHwEPRealize(int idx, unsigned short wMaxPSize) | {
LPC_USB->USBReEP |= (1 << idx);
LPC_USB->USBEpInd = idx;
LPC_USB->USBMaxPSize = wMaxPSize;
Wait4DevInt(EP_RLZED);
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* Deinitializes COMP peripheral registers to their default reset values. */ | void COMP_DeInit(COMP_Selection_TypeDef selection) | /* Deinitializes COMP peripheral registers to their default reset values. */
void COMP_DeInit(COMP_Selection_TypeDef selection) | {
*(vu32*)(COMP_BASE + selection) = 0;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Just like the default show function above, but this one is for when the sysfs "store" is requested (when a value is written to a file.) */ | static ssize_t foo_attr_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t len) | /* Just like the default show function above, but this one is for when the sysfs "store" is requested (when a value is written to a file.) */
static ssize_t foo_attr_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t len) | {
struct foo_attribute *attribute;
struct foo_obj *foo;
attribute = to_foo_attr(attr);
foo = to_foo_obj(kobj);
if (!attribute->store)
return -EIO;
return attribute->store(foo, attribute, buf, len);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Get I2C status of the specified I2C port.
The */ | unsigned long I2CStatusGet(unsigned long ulBase) | /* Get I2C status of the specified I2C port.
The */
unsigned long I2CStatusGet(unsigned long ulBase) | {
xASSERT((ulBase == I2C0_BASE) || ((ulBase == I2C1_BASE)));
return (xHWREGB(ulBase + I2C_STATUS));
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Writes a void element of a given size. Useful for reserving space in the file to be written to later. */ | static void put_ebml_void(ByteIOContext *pb, uint64_t size) | /* Writes a void element of a given size. Useful for reserving space in the file to be written to later. */
static void put_ebml_void(ByteIOContext *pb, uint64_t size) | {
int64_t currentpos = url_ftell(pb);
assert(size >= 2);
put_ebml_id(pb, EBML_ID_VOID);
if (size < 10)
put_ebml_num(pb, size-1, 0);
else
put_ebml_num(pb, size-9, 8);
while(url_ftell(pb) < currentpos + size)
put_byte(pb, 0);
} | DC-SWAT/DreamShell | C++ | null | 404 |
/* Registers an interrupt handler for watchdog timer interrupt. */ | void WatchdogIntRegister(unsigned long ulBase, void(*pfnHandler)(void)) | /* Registers an interrupt handler for watchdog timer interrupt. */
void WatchdogIntRegister(unsigned long ulBase, void(*pfnHandler)(void)) | {
ASSERT((ulBase == WATCHDOG0_BASE) || (ulBase == WATCHDOG1_BASE));
IntRegister(INT_WATCHDOG, pfnHandler);
IntEnable(INT_WATCHDOG);
} | watterott/WebRadio | C++ | null | 71 |
/* This function returns an offset into the muram area. Use cpm_dpram_addr() to get the virtual address of the area. Use cpm_muram_free() to free the allocation. */ | unsigned long cpm_muram_alloc(unsigned long size, unsigned long align) | /* This function returns an offset into the muram area. Use cpm_dpram_addr() to get the virtual address of the area. Use cpm_muram_free() to free the allocation. */
unsigned long cpm_muram_alloc(unsigned long size, unsigned long align) | {
unsigned long start;
unsigned long flags;
spin_lock_irqsave(&cpm_muram_lock, flags);
cpm_muram_info.alignment = align;
start = rh_alloc(&cpm_muram_info, size, "commproc");
spin_unlock_irqrestore(&cpm_muram_lock, flags);
return start;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Starts quiescing a region in preparation for recovery. */ | static int __rh_recovery_prepare(struct dm_region_hash *rh) | /* Starts quiescing a region in preparation for recovery. */
static int __rh_recovery_prepare(struct dm_region_hash *rh) | {
int r;
region_t region;
struct dm_region *reg;
r = rh->log->type->get_resync_work(rh->log, ®ion);
if (r <= 0)
return r;
read_lock(&rh->hash_lock);
reg = __rh_find(rh, region);
read_unlock(&rh->hash_lock);
spin_lock_irq(&rh->region_lock);
reg->state = DM_RH_RECOVERING;
if (atomic_read(®->pending))
list_del_init(®->list);
else
list_move(®->list, &rh->quiesced_regions);
spin_unlock_irq(&rh->region_lock);
return 1;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Sends data through a SPI peripheral. If the SPI is configured to use a fixed peripheral select, the npcs value is meaningless. Otherwise, it identifies the component which shall be addressed. */ | void SPI_Write(AT91S_SPI *spi, unsigned int npcs, unsigned short data) | /* Sends data through a SPI peripheral. If the SPI is configured to use a fixed peripheral select, the npcs value is meaningless. Otherwise, it identifies the component which shall be addressed. */
void SPI_Write(AT91S_SPI *spi, unsigned int npcs, unsigned short data) | {
while ((spi->SPI_SR & AT91C_SPI_TXEMPTY) == 0);
spi->SPI_TDR = data | SPI_PCS(npcs);
while ((spi->SPI_SR & AT91C_SPI_TDRE) == 0);
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* Configure the XOSC32K external 32KHz oscillator clock source.
Configures the external 32KHz oscillator clock source with the given configuration settings. */ | void system_clock_source_xosc32k_set_config(struct system_clock_source_xosc32k_config *const config) | /* Configure the XOSC32K external 32KHz oscillator clock source.
Configures the external 32KHz oscillator clock source with the given configuration settings. */
void system_clock_source_xosc32k_set_config(struct system_clock_source_xosc32k_config *const config) | {
OSC32KCTRL_XOSC32K_Type temp = OSC32KCTRL->XOSC32K;
temp.bit.STARTUP = config->startup_time;
if (config->external_clock == SYSTEM_CLOCK_EXTERNAL_CRYSTAL) {
temp.bit.XTALEN = 1;
} else {
temp.bit.XTALEN = 0;
}
temp.bit.EN1K = config->enable_1khz_output;
temp.bit.EN32K = config->enable_32khz_output;
temp.bit.ONDEMAND = config->on_demand;
temp.bit.RUNSTDBY = config->run_in_standby;
temp.bit.WRTLOCK = config->write_once;
_system_clock_inst.xosc32k.frequency = config->frequency;
OSC32KCTRL->XOSC32K = temp;
} | memfault/zero-to-main | C++ | null | 200 |
/* return The status flags. This is the logical OR of members of the enumeration ::snvs_status_flags_t */ | uint32_t SNVS_HP_RTC_GetStatusFlags(SNVS_Type *base) | /* return The status flags. This is the logical OR of members of the enumeration ::snvs_status_flags_t */
uint32_t SNVS_HP_RTC_GetStatusFlags(SNVS_Type *base) | {
uint32_t flags = 0U;
if (base->HPSR & SNVS_HPSR_PI_MASK)
{
flags |= kSNVS_RTC_PeriodicInterruptFlag;
}
if (base->HPSR & SNVS_HPSR_HPTA_MASK)
{
flags |= kSNVS_RTC_AlarmInterruptFlag;
}
return flags;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function scans each BD in sequence. If we find a BD that is not ready (READY=1), then we return 0 indicating that the QE is still sending data. If we reach the last BD (WRAP=1), then we know we've scanned the entire list, and all BDs are done. */ | static unsigned int qe_uart_tx_empty(struct uart_port *port) | /* This function scans each BD in sequence. If we find a BD that is not ready (READY=1), then we return 0 indicating that the QE is still sending data. If we reach the last BD (WRAP=1), then we know we've scanned the entire list, and all BDs are done. */
static unsigned int qe_uart_tx_empty(struct uart_port *port) | {
struct uart_qe_port *qe_port =
container_of(port, struct uart_qe_port, port);
struct qe_bd *bdp = qe_port->tx_bd_base;
while (1) {
if (in_be16(&bdp->status) & BD_SC_READY)
return 0;
if (in_be16(&bdp->status) & BD_SC_WRAP)
return 1;
bdp++;
};
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Before reading touch pad, we need to initialize the RTC IO. */ | static void tp_example_touch_pad_init() | /* Before reading touch pad, we need to initialize the RTC IO. */
static void tp_example_touch_pad_init() | {
for (int i = 0;i< TOUCH_PAD_MAX;i++) {
touch_pad_config(i, TOUCH_THRESH_NO_USE);
}
} | retro-esp32/RetroESP32 | C++ | Creative Commons Attribution Share Alike 4.0 International | 581 |
/* Checks whether the specified ETHERNET DMA interrupt has occured or not. */ | INTStatus ETH_GetDmaIntStatus(uint32_t ETH_DMA_IT) | /* Checks whether the specified ETHERNET DMA interrupt has occured or not. */
INTStatus ETH_GetDmaIntStatus(uint32_t ETH_DMA_IT) | {
INTStatus bitstatus = RESET;
assert_param(IS_ETH_DMA_GET_INT(ETH_DMA_IT));
if ((ETH->DMASTS & ETH_DMA_IT) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* copy from fs while checksumming, otherwise like csum_partial */ | __wsum csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *csum_err) | /* copy from fs while checksumming, otherwise like csum_partial */
__wsum csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *csum_err) | {
int rem;
if (csum_err)
*csum_err = 0;
rem = copy_from_user(dst, src, len);
if (rem != 0) {
if (csum_err)
*csum_err = -EFAULT;
memset(dst + len - rem, 0, rem);
len = rem;
}
return csum_partial(dst, len, sum);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Sets or clears the selected data port bit. */ | void GPIO_WriteBit(GPIO_TypeDef *GPIOx, GPIO_Pin_TypeDef GPIO_Pin, BitAction GPIO_BitVal) | /* Sets or clears the selected data port bit. */
void GPIO_WriteBit(GPIO_TypeDef *GPIOx, GPIO_Pin_TypeDef GPIO_Pin, BitAction GPIO_BitVal) | {
assert_param(IS_GPIO_PIN(GPIO_Pin));
assert_param(IS_STATE_VALUE(GPIO_BitVal));
if (GPIO_BitVal != RESET)
{
GPIOx->ODR |= GPIO_Pin;
}
else
{
GPIOx->ODR &= (uint8_t)(~GPIO_Pin);
}
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* USBH_ClrFeature This request is used to clear or disable a specific feature. */ | USBH_StatusTypeDef USBH_ClrFeature(USBH_HandleTypeDef *phost, uint8_t ep_num) | /* USBH_ClrFeature This request is used to clear or disable a specific feature. */
USBH_StatusTypeDef USBH_ClrFeature(USBH_HandleTypeDef *phost, uint8_t ep_num) | {
if(phost->RequestState == CMD_SEND)
{
phost->Control.setup.b.bmRequestType = USB_H2D |
USB_REQ_RECIPIENT_ENDPOINT |
USB_REQ_TYPE_STANDARD;
phost->Control.setup.b.bRequest = USB_REQ_CLEAR_FEATURE;
phost->Control.setup.b.wValue.w = FEATURE_SELECTOR_ENDPOINT;
phost->Control.setup.b.wIndex.w = ep_num;
phost->Control.setup.b.wLength.w = 0;
}
return USBH_CtlReq(phost, 0 , 0 );
} | labapart/polymcu | C++ | null | 201 |
/* Init the MLD data of the IP6 service instance. Configure MNP to receive ALL SYSTEM multicast. */ | EFI_STATUS Ip6InitMld(IN IP6_SERVICE *IpSb) | /* Init the MLD data of the IP6 service instance. Configure MNP to receive ALL SYSTEM multicast. */
EFI_STATUS Ip6InitMld(IN IP6_SERVICE *IpSb) | {
EFI_IPv6_ADDRESS AllNodes;
IP6_MLD_GROUP *Group;
EFI_STATUS Status;
Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes);
Group = Ip6CreateMldEntry (IpSb, &AllNodes, (UINT32)IP6_INFINIT_LIFETIME);
if (Group == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = Ip6GetMulticastMac (IpSb->Mnp, &AllNodes, &Group->Mac);
if (EFI_ERROR (Status)) {
goto ERROR;
}
Status = IpSb->Mnp->Groups (IpSb->Mnp, TRUE, &Group->Mac);
if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
goto ERROR;
}
return EFI_SUCCESS;
ERROR:
RemoveEntryList (&Group->Link);
FreePool (Group);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function calculates and returns the nnode number for the nnode at @row and @col. */ | static int calc_nnode_num(int row, int col) | /* This function calculates and returns the nnode number for the nnode at @row and @col. */
static int calc_nnode_num(int row, int col) | {
int num, bits;
num = 1;
while (row--) {
bits = (col & (UBIFS_LPT_FANOUT - 1));
col >>= UBIFS_LPT_FANOUT_SHIFT;
num <<= UBIFS_LPT_FANOUT_SHIFT;
num |= bits;
}
return num;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* strstr - Find the first substring in a NUL terminated string @s1: The string to be searched @s2: The string to search for */ | char* strstr(const char *s1, const char *s2) | /* strstr - Find the first substring in a NUL terminated string @s1: The string to be searched @s2: The string to search for */
char* strstr(const char *s1, const char *s2) | {
size_t l1, l2;
l2 = strlen(s2);
if (!l2)
return (char *)s1;
l1 = strlen(s1);
while (l1 >= l2) {
l1--;
if (!memcmp(s1, s2, l2))
return (char *)s1;
s1++;
}
return NULL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Compare two big integers for equality. The integers use unsigned big-endian encoding; extra leading bytes (of value 0) are allowed. */ | static int eqbigint(const unsigned char *b1, size_t len1, const unsigned char *b2, size_t len2) | /* Compare two big integers for equality. The integers use unsigned big-endian encoding; extra leading bytes (of value 0) are allowed. */
static int eqbigint(const unsigned char *b1, size_t len1, const unsigned char *b2, size_t len2) | {
while (len1 > 0 && *b1 == 0) {
b1 ++;
len1 --;
}
while (len2 > 0 && *b2 == 0) {
b2 ++;
len2 --;
}
if (len1 != len2) {
return 0;
}
return memcmp(b1, b2, len1) == 0;
} | RavenSystem/esp-homekit-devices | C++ | Other | 2,577 |
/* sunxi_lcd_dsi_gen_short_read2p - generic read with 2 param @screen_id: The index of screen. @paran: Para to be transfer. */ | s32 sunxi_lcd_dsi_gen_short_read2p(u32 screen_id, u8 para0, u8 para1, u8 *result) | /* sunxi_lcd_dsi_gen_short_read2p - generic read with 2 param @screen_id: The index of screen. @paran: Para to be transfer. */
s32 sunxi_lcd_dsi_gen_short_read2p(u32 screen_id, u8 para0, u8 para1, u8 *result) | {
u8 tmp[2];
tmp[0] = para0;
tmp[1] = para1;
return sunxi_lcd_dsi_gen_short_read(screen_id, tmp, 2, result);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* param base SPDIF base pointer. param handle SPDIF eDMA handle pointer. */ | void SPDIF_TransferAbortSendEDMA(SPDIF_Type *base, spdif_edma_handle_t *handle) | /* param base SPDIF base pointer. param handle SPDIF eDMA handle pointer. */
void SPDIF_TransferAbortSendEDMA(SPDIF_Type *base, spdif_edma_handle_t *handle) | {
assert(handle != NULL);
EDMA_AbortTransfer(handle->dmaLeftHandle);
EDMA_AbortTransfer(handle->dmaRightHandle);
SPDIF_EnableDMA(base, kSPDIF_TxDMAEnable, false);
(void)memset(handle->spdifQueue, 0, sizeof(handle->spdifQueue));
(void)memset(handle->transferSize, 0, sizeof(handle->transferSize));
handle->queueUser = 0U;
handle->queueDriver = 0U;
handle->state = kSPDIF_Idle;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* This function is executed in case of error occurrence. */ | void Error_Handler(void) | /* This function is executed in case of error occurrence. */
void Error_Handler(void) | {
BSP_LED_On(LED2);
while (1)
{
}
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Specifies the ouput polarity of the PWM at the specified state of counter. */ | void TMR2_PWM_SetPolarity(CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch, uint8_t u8CountState, uint32_t u32Polarity) | /* Specifies the ouput polarity of the PWM at the specified state of counter. */
void TMR2_PWM_SetPolarity(CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch, uint8_t u8CountState, uint32_t u32Polarity) | {
uint32_t u32PolarityPos;
DDL_ASSERT(IS_TMR2_UNIT(TMR2x));
DDL_ASSERT(IS_TMR2_CH(u32Ch));
DDL_ASSERT(IS_TMR2_PWM_POLARITY(u8CountState, u32Polarity));
u32PolarityPos = ((uint32_t)u8CountState * TMR2_PWM_POLARITY_OFFSET) + (u32Ch * TMR2_CH_OFFSET);
MODIFY_REG32(TMR2x->PCONR, TMR2_PCONR_STACA << u32PolarityPos, u32Polarity << u32PolarityPos);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Return code 0 - Successfully processed FARPR IOCB (currently always return 0) */ | static int lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, struct lpfc_nodelist *ndlp) | /* Return code 0 - Successfully processed FARPR IOCB (currently always return 0) */
static int lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, struct lpfc_nodelist *ndlp) | {
struct lpfc_dmabuf *pcmd;
uint32_t *lp;
IOCB_t *icmd;
uint32_t cmd, did;
icmd = &cmdiocb->iocb;
did = icmd->un.elsreq64.remoteID;
pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
lp = (uint32_t *) pcmd->virt;
cmd = *lp++;
lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
"0600 FARP-RSP received from DID x%x\n", did);
lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* async completion call-back from the block layer, when scsi/ide/whatever calls end_that_request_last() on a request */ | static void bsg_rq_end_io(struct request *rq, int uptodate) | /* async completion call-back from the block layer, when scsi/ide/whatever calls end_that_request_last() on a request */
static void bsg_rq_end_io(struct request *rq, int uptodate) | {
struct bsg_command *bc = rq->end_io_data;
struct bsg_device *bd = bc->bd;
unsigned long flags;
dprintk("%s: finished rq %p bc %p, bio %p stat %d\n",
bd->name, rq, bc, bc->bio, uptodate);
bc->hdr.duration = jiffies_to_msecs(jiffies - bc->hdr.duration);
spin_lock_irqsave(&bd->lock, flags);
list_move_tail(&bc->list, &bd->done_list);
bd->done_cmds++;
spin_unlock_irqrestore(&bd->lock, flags);
wake_up(&bd->wq_done);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* The FSEAL bit prevents the PMIC from turning off DCDC5 and DCDC6. It can be toggled at most 3 times: 0->1, 1->0, and finally 0->1. After the third switch its value is locked and can only be reset by powering off the PMIC entirely. */ | int tps65218_lock_fseal(void) | /* The FSEAL bit prevents the PMIC from turning off DCDC5 and DCDC6. It can be toggled at most 3 times: 0->1, 1->0, and finally 0->1. After the third switch its value is locked and can only be reset by powering off the PMIC entirely. */
int tps65218_lock_fseal(void) | {
int i;
for (i = 0; i < 3; i++)
if (tps65218_toggle_fseal())
return -EBADE;
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned. */ | UINTN EFIAPI UnicodeBSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString, IN BASE_LIST Marker) | /* If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned. */
UINTN EFIAPI UnicodeBSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString, IN BASE_LIST Marker) | {
ASSERT_UNICODE_BUFFER (StartOfBuffer);
ASSERT_UNICODE_BUFFER (FormatString);
return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, gNullVaList, Marker);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Wait the operation register's bit as specified by Bit to become set (or clear). */ | EFI_STATUS XhcWaitOpRegBit(IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset, IN UINT32 Bit, IN BOOLEAN WaitToSet, IN UINT32 Timeout) | /* Wait the operation register's bit as specified by Bit to become set (or clear). */
EFI_STATUS XhcWaitOpRegBit(IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset, IN UINT32 Bit, IN BOOLEAN WaitToSet, IN UINT32 Timeout) | {
UINT64 TimeoutTicks;
UINT64 ElapsedTicks;
UINT64 TicksDelta;
UINT64 CurrentTick;
if (Timeout == 0) {
return EFI_TIMEOUT;
}
TimeoutTicks = XhcConvertTimeToTicks (XHC_MICROSECOND_TO_NANOSECOND (Timeout * XHC_1_MILLISECOND));
ElapsedTicks = 0;
CurrentTick = GetPerformanceCounter ();
do {
if (XHC_REG_BIT_IS_SET (Xhc, Offset, Bit) == WaitToSet) {
return EFI_SUCCESS;
}
gBS->Stall (XHC_1_MICROSECOND);
TicksDelta = XhcGetElapsedTicks (&CurrentTick);
if (TicksDelta == 0) {
TicksDelta = XhcConvertTimeToTicks (XHC_MICROSECOND_TO_NANOSECOND (XHC_1_MICROSECOND));
}
ElapsedTicks += TicksDelta;
} while (ElapsedTicks < TimeoutTicks);
return EFI_TIMEOUT;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Returns the RTC Day Light Saving stored operation. */ | uint32_t RTC_GetStoreOperation(void) | /* Returns the RTC Day Light Saving stored operation. */
uint32_t RTC_GetStoreOperation(void) | {
return (RTC->CTRL & RTC_CTRL_BAKP);
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Checks whether the specified I2C interrupt has occurred or not. */ | INTStatus I2C_GetIntStatus(I2C_Module *I2Cx, uint32_t I2C_IT) | /* Checks whether the specified I2C interrupt has occurred or not. */
INTStatus I2C_GetIntStatus(I2C_Module *I2Cx, uint32_t I2C_IT) | {
INTStatus bitstatus = RESET;
uint32_t enablestatus = 0;
assert_param(IS_I2C_PERIPH(I2Cx));
assert_param(IS_I2C_GET_INT(I2C_IT));
enablestatus = (uint32_t)(((I2C_IT & INTEN_MASK) >> 16) & (I2Cx->CTRL2));
I2C_IT &= FLAG_MASK;
if (((I2Cx->STS1 & I2C_IT) != (uint32_t)RESET) && enablestatus)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* No locks are assumed to be held when calling this function. */ | static void neo_clear_break(struct jsm_channel *ch, int force) | /* No locks are assumed to be held when calling this function. */
static void neo_clear_break(struct jsm_channel *ch, int force) | {
unsigned long lock_flags;
spin_lock_irqsave(&ch->ch_lock, lock_flags);
if (ch->ch_flags & CH_BREAK_SENDING) {
u8 temp = readb(&ch->ch_neo_uart->lcr);
writeb((temp & ~UART_LCR_SBC), &ch->ch_neo_uart->lcr);
ch->ch_flags &= ~(CH_BREAK_SENDING);
jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev,
"clear break Finishing UART_LCR_SBC! finished: %lx\n", jiffies);
neo_pci_posting_flush(ch->ch_bd);
}
spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function will set network interface device DNS server address. @NOTE it can only be called in the network interface device driver. */ | void netdev_low_level_set_dns_server(struct netdev *netdev, uint8_t dns_num, const ip_addr_t *dns_server) | /* This function will set network interface device DNS server address. @NOTE it can only be called in the network interface device driver. */
void netdev_low_level_set_dns_server(struct netdev *netdev, uint8_t dns_num, const ip_addr_t *dns_server) | {
int index;
RT_ASSERT(dns_server);
if (netdev == RT_NULL)
{
return;
}
for (index = 0; index < NETDEV_DNS_SERVERS_NUM; index++)
{
if (ip_addr_cmp(&(netdev->dns_servers[index]), dns_server))
{
return;
}
}
if (dns_num < NETDEV_DNS_SERVERS_NUM)
{
ip_addr_copy(netdev->dns_servers[dns_num], *dns_server);
if (netdev->addr_callback)
{
netdev->addr_callback(netdev, NETDEV_CB_ADDR_DNS_SERVER);
}
}
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.