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
|
|---|---|---|---|---|---|---|---|
/* Error handlers called from the eh thread (one thread per HBA). */
|
static int sym53c8xx_eh_abort_handler(struct scsi_cmnd *cmd)
|
/* Error handlers called from the eh thread (one thread per HBA). */
static int sym53c8xx_eh_abort_handler(struct scsi_cmnd *cmd)
|
{
return sym_eh_handler(SYM_EH_ABORT, "ABORT", cmd);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Executes a return hook for Lua and C functions and sets/corrects 'oldpc'. (Note that this correction is needed by the line hook, so it is done even when return hooks are off.) */
|
static void rethook(lua_State *L, CallInfo *ci, int nres)
|
/* Executes a return hook for Lua and C functions and sets/corrects 'oldpc'. (Note that this correction is needed by the line hook, so it is done even when return hooks are off.) */
static void rethook(lua_State *L, CallInfo *ci, int nres)
|
{
StkId firstres = L->top - nres;
int delta = 0;
int ftransfer;
if (isLua(ci)) {
Proto *p = ci_func(ci)->p;
if (p->is_vararg)
delta = ci->u.l.nextraargs + p->numparams + 1;
}
ci->func += delta;
ftransfer = cast(unsigned short, firstres - ci->func);
luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres);
ci->func -= delta;
}
if (isLua(ci = ci->previous))
L->oldpc = pcRel(ci->u.l.savedpc, ci_func(ci)->p);
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* CAN Initialize a 16bit Message ID List Filter. */
|
void can_filter_id_list_16bit_init(uint32_t nr, uint16_t id1, uint16_t id2, uint16_t id3, uint16_t id4, uint32_t fifo, bool enable)
|
/* CAN Initialize a 16bit Message ID List Filter. */
void can_filter_id_list_16bit_init(uint32_t nr, uint16_t id1, uint16_t id2, uint16_t id3, uint16_t id4, uint32_t fifo, bool enable)
|
{
can_filter_init(nr, false, true,
((uint32_t)id1 << 16) | (uint32_t)id2,
((uint32_t)id3 << 16) | (uint32_t)id4, fifo, enable);
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* Returns the size of the resulting target surface for a rotozoomSurfaceXY() call. */
|
void rotozoomSurfaceSizeXY(int width, int height, double angle, double zoomx, double zoomy, int *dstwidth, int *dstheight)
|
/* Returns the size of the resulting target surface for a rotozoomSurfaceXY() call. */
void rotozoomSurfaceSizeXY(int width, int height, double angle, double zoomx, double zoomy, int *dstwidth, int *dstheight)
|
{
double dummy_sanglezoom, dummy_canglezoom;
_rotozoomSurfaceSizeTrig(width, height, angle, zoomx, zoomy, dstwidth, dstheight, &dummy_sanglezoom, &dummy_canglezoom);
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Forces the TIMx output 4 waveform to active or inactive level. */
|
void TIM_ForcedOC4Config(TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction)
|
/* Forces the TIMx output 4 waveform to active or inactive level. */
void TIM_ForcedOC4Config(TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction)
|
{
uint32_t tmpccmr2 = 0;
assert_param(IS_TIM_LIST3_PERIPH(TIMx));
assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
tmpccmr2 = TIMx->CCMR2;
tmpccmr2 &= (uint32_t)~TIM_CCMR2_OC4M;
tmpccmr2 |= ((uint32_t)TIM_ForcedAction << 8);
TIMx->CCMR2 = tmpccmr2;
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* For example, a divider value of 1 results in an EPI clock rate of half the system clock, value of 2 or 3 yields one quarter of the system clock and a value of 4 results in one sixth of the system clock rate. */
|
void EPIDividerCSSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32Divider)
|
/* For example, a divider value of 1 results in an EPI clock rate of half the system clock, value of 2 or 3 yields one quarter of the system clock and a value of 4 results in one sixth of the system clock rate. */
void EPIDividerCSSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32Divider)
|
{
uint32_t ui32Reg;
ASSERT(ui32Base == EPI0_BASE);
ASSERT(ui32CS < 4);
if (ui32CS < 2)
{
ui32Reg = HWREG(ui32Base + EPI_O_BAUD) & ~(0xffff << (16 * ui32CS));
ui32Reg |= ((ui32Divider & 0xffff) << (16 * ui32CS));
HWREG(ui32Base + EPI_O_BAUD) = ui32Reg;
}
else
{
ui32Reg = (HWREG(ui32Base + EPI_O_BAUD2) &
~(0xffff << (16 * (ui32CS - 2))));
ui32Reg |= ((ui32Divider & 0xffff) << (16 * (ui32CS - 2)));
HWREG(ui32Base + EPI_O_BAUD2) = ui32Reg;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* ZSTD_getDictID_fromDDict() : Provides the dictID of the dictionary loaded into */
|
unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict *ddict)
|
/* ZSTD_getDictID_fromDDict() : Provides the dictID of the dictionary loaded into */
unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict *ddict)
|
{
if (ddict == NULL)
return 0;
return ZSTD_getDictID_fromDict(ddict->dictContent, ddict->dictSize);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* CDC_ECM_Itf_Receive Data received over USB OUT endpoint are sent over CDC_ECM interface through this function. */
|
static int8_t CDC_ECM_Itf_Receive(uint8_t *Buf, uint32_t *Len)
|
/* CDC_ECM_Itf_Receive Data received over USB OUT endpoint are sent over CDC_ECM interface through this function. */
static int8_t CDC_ECM_Itf_Receive(uint8_t *Buf, uint32_t *Len)
|
{
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *)(USBD_Device.pClassData);
hcdc_cdc_ecm->RxState = 1U;
UNUSED(Len);
UNUSED(Buf);
return (0);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* param base PWM peripheral base address param subModule PWM submodule to configure param mask The status flags to clear. This is a logical OR of members of the enumeration ::pwm_status_flags_t */
|
void PWM_ClearStatusFlags(PWM_Type *base, pwm_submodule_t subModule, uint32_t mask)
|
/* param base PWM peripheral base address param subModule PWM submodule to configure param mask The status flags to clear. This is a logical OR of members of the enumeration ::pwm_status_flags_t */
void PWM_ClearStatusFlags(PWM_Type *base, pwm_submodule_t subModule, uint32_t mask)
|
{
uint16_t reg;
base->SM[subModule].STS = (mask & 0xFFFFU);
reg = base->FSTS;
reg &= ~(PWM_FSTS_FFLAG_MASK);
reg |= ((mask >> 16U) & PWM_FSTS_FFLAG_MASK);
base->FSTS = reg;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Search image from memory profile. It will return image, if (Address >= ImageBuffer) AND (Address < ImageBuffer + ImageSize). */
|
MEMORY_PROFILE_DRIVER_INFO_DATA* GetMemoryProfileDriverInfoFromAddress(IN MEMORY_PROFILE_CONTEXT_DATA *ContextData, IN PHYSICAL_ADDRESS Address)
|
/* Search image from memory profile. It will return image, if (Address >= ImageBuffer) AND (Address < ImageBuffer + ImageSize). */
MEMORY_PROFILE_DRIVER_INFO_DATA* GetMemoryProfileDriverInfoFromAddress(IN MEMORY_PROFILE_CONTEXT_DATA *ContextData, IN PHYSICAL_ADDRESS Address)
|
{
MEMORY_PROFILE_DRIVER_INFO *DriverInfo;
MEMORY_PROFILE_DRIVER_INFO_DATA *DriverInfoData;
LIST_ENTRY *DriverLink;
LIST_ENTRY *DriverInfoList;
DriverInfoList = ContextData->DriverInfoList;
for (DriverLink = DriverInfoList->ForwardLink;
DriverLink != DriverInfoList;
DriverLink = DriverLink->ForwardLink)
{
DriverInfoData = CR (
DriverLink,
MEMORY_PROFILE_DRIVER_INFO_DATA,
Link,
MEMORY_PROFILE_DRIVER_INFO_SIGNATURE
);
DriverInfo = &DriverInfoData->DriverInfo;
if ((Address >= DriverInfo->ImageBase) &&
(Address < (DriverInfo->ImageBase + DriverInfo->ImageSize)))
{
return DriverInfoData;
}
}
return NULL;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Callback function which provided by user to remove one node in NetDestroyLinkList process. */
|
EFI_STATUS EFIAPI Dhcp6DestroyChildEntry(IN LIST_ENTRY *Entry, IN VOID *Context)
|
/* Callback function which provided by user to remove one node in NetDestroyLinkList process. */
EFI_STATUS EFIAPI Dhcp6DestroyChildEntry(IN LIST_ENTRY *Entry, IN VOID *Context)
|
{
DHCP6_INSTANCE *Instance;
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER;
}
Instance = NET_LIST_USER_STRUCT_S (Entry, DHCP6_INSTANCE, Link, DHCP6_INSTANCE_SIGNATURE);
ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *)Context;
return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns transmit event start address in message RAM */
|
struct fdcan_tx_event_element* fdcan_get_txevt_addr(uint32_t canport)
|
/* Returns transmit event start address in message RAM */
struct fdcan_tx_event_element* fdcan_get_txevt_addr(uint32_t canport)
|
{
struct fdcan_tx_event_element *rxfifo = (struct fdcan_tx_event_element *)
(CAN_MSG_BASE + FDCAN_TXEVT_OFFSET(canport));
return rxfifo;
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* Auxiliary function for error processing.
Function called when in current substate the event apears and it cannot be processed. It should be called also on ERROR event. If given */
|
static void nrf_drv_twis_process_error(uint8_t instNr, nrf_drv_twis_evt_type_t ev, uint32_t error)
|
/* Auxiliary function for error processing.
Function called when in current substate the event apears and it cannot be processed. It should be called also on ERROR event. If given */
static void nrf_drv_twis_process_error(uint8_t instNr, nrf_drv_twis_evt_type_t ev, uint32_t error)
|
{
if(0 == error)
error = NRF_DRV_TWIS_ERROR_UNEXPECTED_EVENT;
nrf_drv_twis_evt_t evdata;
evdata.type = ev;
evdata.data.error = error;
m_var_inst[instNr].error |= error;
nrf_drv_call_event_handler(instNr, &evdata);
}
|
labapart/polymcu
|
C++
| null | 201
|
/* pdcs_size_read - Stable Storage size output. @buf: The output buffer to write to. */
|
static ssize_t pdcs_size_read(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
|
/* pdcs_size_read - Stable Storage size output. @buf: The output buffer to write to. */
static ssize_t pdcs_size_read(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
|
{
char *out = buf;
if (!buf)
return -EINVAL;
out += sprintf(out, "%ld\n", pdcs_size);
return out - buf;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Allocates a new cache entry. The new entry will not be valid initially, and thus cannot be looked up yet. It should be filled with data, and then inserted into the cache using mb_cache_entry_insert(). Returns NULL if no more memory was available. */
|
struct mb_cache_entry* mb_cache_entry_alloc(struct mb_cache *cache, gfp_t gfp_flags)
|
/* Allocates a new cache entry. The new entry will not be valid initially, and thus cannot be looked up yet. It should be filled with data, and then inserted into the cache using mb_cache_entry_insert(). Returns NULL if no more memory was available. */
struct mb_cache_entry* mb_cache_entry_alloc(struct mb_cache *cache, gfp_t gfp_flags)
|
{
struct mb_cache_entry *ce;
ce = kmem_cache_alloc(cache->c_entry_cache, gfp_flags);
if (ce) {
atomic_inc(&cache->c_entry_count);
INIT_LIST_HEAD(&ce->e_lru_list);
INIT_LIST_HEAD(&ce->e_block_list);
ce->e_cache = cache;
ce->e_used = 1 + MB_CACHE_WRITER;
ce->e_queued = 0;
}
return ce;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* param base CSI peripheral base address. param mask The interrupts to enable, pass in as OR'ed value of ref _csi_interrupt_enable. */
|
void CSI_EnableInterrupts(CSI_Type *base, uint32_t mask)
|
/* param base CSI peripheral base address. param mask The interrupts to enable, pass in as OR'ed value of ref _csi_interrupt_enable. */
void CSI_EnableInterrupts(CSI_Type *base, uint32_t mask)
|
{
CSI_REG_CR1(base) |= (mask & CSI_CSICR1_INT_EN_MASK);
CSI_REG_CR3(base) |= (mask & CSI_CSICR3_INT_EN_MASK);
CSI_REG_CR18(base) |= ((mask & CSI_CSICR18_INT_EN_MASK) >> 6U);
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Change Logs: Date Author Notes charlown first version */
|
rt_uint32_t ch32_get_sysclock_frequency(void)
|
/* Change Logs: Date Author Notes charlown first version */
rt_uint32_t ch32_get_sysclock_frequency(void)
|
{
RCC_ClocksTypeDef RCC_Clocks;
RCC_GetClocksFreq(&RCC_Clocks);
return RCC_Clocks.SYSCLK_Frequency;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Get timer prescale value. This function is used to get timer clock prescale value. */
|
unsigned long TimerPrescaleGet(unsigned long ulBase)
|
/* Get timer prescale value. This function is used to get timer clock prescale value. */
unsigned long TimerPrescaleGet(unsigned long ulBase)
|
{
xASSERT((ulBase == TIMER0_BASE) || (ulBase == TIMER1_BASE) ||
(ulBase == TIMER2_BASE) || (ulBase == TIMER3_BASE) );
return (xHWREG(ulBase + TIMER_PR));
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* param base USDHC peripheral base address. param enable/disable flag param nibble position */
|
void USDHC_EnableDDRMode(USDHC_Type *base, bool enable, uint32_t nibblePos)
|
/* param base USDHC peripheral base address. param enable/disable flag param nibble position */
void USDHC_EnableDDRMode(USDHC_Type *base, bool enable, uint32_t nibblePos)
|
{
uint32_t prescaler = (base->SYS_CTRL & USDHC_SYS_CTRL_SDCLKFS_MASK) >> USDHC_SYS_CTRL_SDCLKFS_SHIFT;
if (enable)
{
base->MIX_CTRL &= ~USDHC_MIX_CTRL_NIBBLE_POS_MASK;
base->MIX_CTRL |= (USDHC_MIX_CTRL_DDR_EN_MASK | USDHC_MIX_CTRL_NIBBLE_POS(nibblePos));
prescaler >>= 1UL;
}
else
{
base->MIX_CTRL &= ~USDHC_MIX_CTRL_DDR_EN_MASK;
if (prescaler == 0UL)
{
prescaler += 1UL;
}
else
{
prescaler <<= 1UL;
}
}
base->SYS_CTRL = (base->SYS_CTRL & (~USDHC_SYS_CTRL_SDCLKFS_MASK)) | USDHC_SYS_CTRL_SDCLKFS(prescaler);
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Disables input/output pin and its parents or children widgets. NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to do any widget power switching. */
|
int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, const char *pin)
|
/* Disables input/output pin and its parents or children widgets. NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to do any widget power switching. */
int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, const char *pin)
|
{
return snd_soc_dapm_set_pin(codec, pin, 0);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Allocate ring elements and chain them together One-to-one association of board descriptors with ring elements */
|
static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u32 base)
|
/* Allocate ring elements and chain them together One-to-one association of board descriptors with ring elements */
static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u32 base)
|
{
struct skge_tx_desc *d;
struct skge_element *e;
int i;
ring->start = kcalloc(ring->count, sizeof(*e), GFP_KERNEL);
if (!ring->start)
return -ENOMEM;
for (i = 0, e = ring->start, d = vaddr; i < ring->count; i++, e++, d++) {
e->desc = d;
if (i == ring->count - 1) {
e->next = ring->start;
d->next_offset = base;
} else {
e->next = e + 1;
d->next_offset = base + (i+1) * sizeof(*d);
}
}
ring->to_use = ring->to_clean = ring->start;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* 1 Mhz <= Fref <= 50 Mhz 200 Mhz <= Fvco <= 400 Mhz */
|
void arc_iot_pll_conf_reg(uint32_t val)
|
/* 1 Mhz <= Fref <= 50 Mhz 200 Mhz <= Fvco <= 400 Mhz */
void arc_iot_pll_conf_reg(uint32_t val)
|
{
sysconf_reg_ptr->CLKSEL = CLKSEL_EXT_16M;
sysconf_reg_ptr->PLLCON = val | (0x52000000);
sysconf_reg_ptr->PLLCON = val | (1 << PLLCON_BIT_OFFSET_PLLRST);
sysconf_reg_ptr->PLLCON = val & (~(1 << PLLCON_BIT_OFFSET_PLLRST));
while (!(sysconf_reg_ptr->PLLSTAT & (1 << PLLSTAT_BIT_OFFSET_PLLSTB))) {
;
}
sysconf_reg_ptr->CLKSEL = CLKSEL_PLL;
sysconf_reg_ptr->AHBCLKDIV_SEL |= 1;
sysconf_reg_ptr->AHBCLKDIV = 0x1;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Covert the input memory size to internal register set value. */
|
static status_t SEMC_CovertMemorySize(SEMC_Type *base, uint32_t size_kbytes, uint8_t *sizeConverted)
|
/* Covert the input memory size to internal register set value. */
static status_t SEMC_CovertMemorySize(SEMC_Type *base, uint32_t size_kbytes, uint8_t *sizeConverted)
|
{
assert(sizeConverted);
uint32_t memsize;
if ((size_kbytes < SEMC_BR_MEMSIZE_MIN) || (size_kbytes > SEMC_BR_MEMSIZE_MAX))
{
return kStatus_SEMC_InvalidMemorySize;
}
*sizeConverted = 0;
memsize = size_kbytes / 8;
while (memsize)
{
memsize >>= 1;
(*sizeConverted)++;
}
return kStatus_Success;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Send MIPI command to the LCD panel (cmdnum < 0xB0) */
|
static void send_mipi_dcs_command(const struct ssd2828_config *cfg, u8 cmdnum)
|
/* Send MIPI command to the LCD panel (cmdnum < 0xB0) */
static void send_mipi_dcs_command(const struct ssd2828_config *cfg, u8 cmdnum)
|
{
write_hw_register(cfg, SSD2828_PSCR1, 1);
write_hw_register(cfg, SSD2828_PDR, cmdnum);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* This function must not be called if the LIDD interface is currently configured to expect DMA transactions. If DMA was previously used to write to the panel, */
|
uint16_t LCDIDDIndexedRead(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Addr)
|
/* This function must not be called if the LIDD interface is currently configured to expect DMA transactions. If DMA was previously used to write to the panel, */
uint16_t LCDIDDIndexedRead(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Addr)
|
{
uint32_t ui32Addr;
ASSERT(ui32Base == LCD0_BASE);
ASSERT((ui32CS == 0) || (ui32CS == 1));
ui32Addr = ui32CS ? LCD_O_LIDDCS1ADDR : LCD_O_LIDDCS0ADDR;
HWREG(ui32Base + ui32Addr) = ui16Addr;
ui32Addr = ui32CS ? LCD_O_LIDDCS1DATA : LCD_O_LIDDCS0DATA;
return((uint16_t)HWREG(ui32Base + ui32Addr));
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Displays the code value as a character, not its ASCII value, as would be done by BASE_DEC and friends. */
|
static void format_bbo_weight_indicator(gchar *buf, guint32 value)
|
/* Displays the code value as a character, not its ASCII value, as would be done by BASE_DEC and friends. */
static void format_bbo_weight_indicator(gchar *buf, guint32 value)
|
{
g_snprintf(buf, ITEM_LABEL_LENGTH,
"%s (%c)",
val_to_str_const(value,
ouch_bbo_weight_indicator_val,
"Unknown"),
value);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Scan an MBUF chain until we reach fragment number "frag" Return its length and physical address. */
|
void MM_MapTxDma(PLM_DEVICE_BLOCK pDevice, struct _LM_PACKET *pPacket, T3_64BIT_HOST_ADDR *paddr, LM_UINT32 *len, int frag)
|
/* Scan an MBUF chain until we reach fragment number "frag" Return its length and physical address. */
void MM_MapTxDma(PLM_DEVICE_BLOCK pDevice, struct _LM_PACKET *pPacket, T3_64BIT_HOST_ADDR *paddr, LM_UINT32 *len, int frag)
|
{
PUM_PACKET pUmPacket = (PUM_PACKET) pPacket;
*len = pPacket->PacketSize;
MM_SetT3Addr (paddr, (dma_addr_t) pUmPacket->skbuff);
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Called from Libertas to transfer some data to the WLAN device We can't sleep here. */
|
static int if_spi_host_to_card(struct lbs_private *priv, u8 type, u8 *buf, u16 nb)
|
/* Called from Libertas to transfer some data to the WLAN device We can't sleep here. */
static int if_spi_host_to_card(struct lbs_private *priv, u8 type, u8 *buf, u16 nb)
|
{
int err = 0;
struct if_spi_card *card = priv->card;
lbs_deb_enter_args(LBS_DEB_SPI, "type %d, bytes %d", type, nb);
nb = ALIGN(nb, 4);
switch (type) {
case MVMS_CMD:
err = spu_write(card, IF_SPI_CMD_RDWRPORT_REG, buf, nb);
break;
case MVMS_DAT:
err = spu_write(card, IF_SPI_DATA_RDWRPORT_REG, buf, nb);
break;
default:
lbs_pr_err("can't transfer buffer of type %d", type);
err = -EINVAL;
break;
}
lbs_deb_leave_args(LBS_DEB_SPI, "err=%d", err);
return err;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns information about the random number generation implementation. */
|
STATIC EFI_STATUS EFIAPI VirtioRngGetInfo(IN EFI_RNG_PROTOCOL *This, IN OUT UINTN *RNGAlgorithmListSize, OUT EFI_RNG_ALGORITHM *RNGAlgorithmList)
|
/* Returns information about the random number generation implementation. */
STATIC EFI_STATUS EFIAPI VirtioRngGetInfo(IN EFI_RNG_PROTOCOL *This, IN OUT UINTN *RNGAlgorithmListSize, OUT EFI_RNG_ALGORITHM *RNGAlgorithmList)
|
{
if ((This == NULL) || (RNGAlgorithmListSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
if (*RNGAlgorithmListSize < sizeof (EFI_RNG_ALGORITHM)) {
*RNGAlgorithmListSize = sizeof (EFI_RNG_ALGORITHM);
return EFI_BUFFER_TOO_SMALL;
}
if (RNGAlgorithmList == NULL) {
return EFI_INVALID_PARAMETER;
}
*RNGAlgorithmListSize = sizeof (EFI_RNG_ALGORITHM);
CopyGuid (RNGAlgorithmList, &gEfiRngAlgorithmRaw);
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns the serialized #CRFontStyle. The caller must free the returned string using g_free(). */
|
const gchar* cr_font_style_to_string(enum CRFontStyle a_code)
|
/* Returns the serialized #CRFontStyle. The caller must free the returned string using g_free(). */
const gchar* cr_font_style_to_string(enum CRFontStyle a_code)
|
{
gchar *str = NULL;
switch (a_code) {
case FONT_STYLE_NORMAL:
str = (gchar *) "normal";
break;
case FONT_STYLE_ITALIC:
str = (gchar *) "italic";
break;
case FONT_STYLE_OBLIQUE:
str = (gchar *) "oblique";
break;
case FONT_STYLE_INHERIT:
str = (gchar *) "inherit";
break;
default:
str = (gchar *) "unknown font style value";
break;
}
return str;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* This function does the actual read of the EEPROM. It needs the buffer into which the read data is copied, the size of the EEPROM being read and the buffer size */
|
int read_eeprom(char *buffer, int eeprom_size, int size)
|
/* This function does the actual read of the EEPROM. It needs the buffer into which the read data is copied, the size of the EEPROM being read and the buffer size */
int read_eeprom(char *buffer, int eeprom_size, int size)
|
{
int i = 0, err;
send_start();
send_byte(W_HEADER);
recv_ack();
if (eeprom_size > 2048) {
send_byte(0x00);
recv_ack();
}
send_start();
send_byte(R_HEADER);
err = recv_ack();
if (err == -1)
return err;
for (i = 0; i < size; i++) {
*buffer++ = recv_byte();
send_ack();
}
send_stop();
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Prefetching cachelines help hardware performance. (Strictly a performance enhancement. Not functionally required). */
|
static void prefetch_data(void *p, int num, int stride)
|
/* Prefetching cachelines help hardware performance. (Strictly a performance enhancement. Not functionally required). */
static void prefetch_data(void *p, int num, int stride)
|
{
while (num-- > 0) {
prefetchw(p);
p += stride;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Read and write a data element from and to the SPI interface. */
|
unsigned long xSPISingleDataReadWrite(unsigned long ulBase, unsigned long ulWData)
|
/* Read and write a data element from and to the SPI interface. */
unsigned long xSPISingleDataReadWrite(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_STATUS) & SPI_STATUS_BUSY))
{
}
xHWREG(ulBase + SPI_TX) = ulWData;
while((xHWREG(ulBase + SPI_STATUS) & SPI_STATUS_BUSY))
{
}
ulReadTemp = xHWREG(ulBase + SPI_RX);
return ulReadTemp;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* The full hardware reset of the radio controller and all the PALs will be scheduled. */
|
void uwb_rc_reset_all(struct uwb_rc *rc)
|
/* The full hardware reset of the radio controller and all the PALs will be scheduled. */
void uwb_rc_reset_all(struct uwb_rc *rc)
|
{
struct uwb_event *evt;
evt = kzalloc(sizeof(struct uwb_event), GFP_ATOMIC);
if (unlikely(evt == NULL))
return;
evt->rc = __uwb_rc_get(rc);
evt->ts_jiffies = jiffies;
evt->type = UWB_EVT_TYPE_MSG;
evt->message = UWB_EVT_MSG_RESET;
uwbd_event_queue(evt);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Read sensor data.
If scaled data format is selected for the device, this routine gets a compensated "true pressure" sample using the sampling mode specified when the device was initialized. Otherwise a raw uncompensated pressure reading is returned in "data". */
|
static bool bmp_read(sensor_t *sensor, sensor_read_t type, sensor_data_t *data)
|
/* Read sensor data.
If scaled data format is selected for the device, this routine gets a compensated "true pressure" sample using the sampling mode specified when the device was initialized. Otherwise a raw uncompensated pressure reading is returned in "data". */
static bool bmp_read(sensor_t *sensor, sensor_read_t type, sensor_data_t *data)
|
{
switch (type) {
case SENSOR_READ_PRESSURE:
return bmp_get_pressure(sensor->hal, data);
case SENSOR_READ_TEMPERATURE:
return bmp_get_temperature(sensor->hal, data);
case SENSOR_READ_ID:
return bmp_device_id(sensor->hal, data);
default:
sensor->err = SENSOR_ERR_FUNCTION;
return false;
}
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Returns: the UTF-8 string value contained within the attribute, or NULL. */
|
const char* _g_file_attribute_value_get_string(const GFileAttributeValue *attr)
|
/* Returns: the UTF-8 string value contained within the attribute, or NULL. */
const char* _g_file_attribute_value_get_string(const GFileAttributeValue *attr)
|
{
if (attr == NULL)
return NULL;
g_return_val_if_fail (attr->type == G_FILE_ATTRIBUTE_TYPE_STRING, NULL);
return attr->u.string;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Disable the internal oscillator.
Sets the IOSCDIS bit in SYSCTL_RCC, disabling the internal oscillator. */
|
void rcc_disable_interal_osc(void)
|
/* Disable the internal oscillator.
Sets the IOSCDIS bit in SYSCTL_RCC, disabling the internal oscillator. */
void rcc_disable_interal_osc(void)
|
{
SYSCTL_RCC |= SYSCTL_RCC_IOSCDIS;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Prints a char string out of the ITM. */
|
void am_hal_itm_print(char *pcString)
|
/* Prints a char string out of the ITM. */
void am_hal_itm_print(char *pcString)
|
{
uint32_t ui32Length = 0;
while (*(pcString + ui32Length))
{
ui32Length++;
}
while (ui32Length)
{
am_hal_itm_stimulus_reg_byte_write(0, (uint8_t)*pcString++);
ui32Length--;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Gets a whole set of gyro data including data, accuracy and timestamp. */
|
void inv_get_gyro_set(long *data, int8_t *accuracy, inv_time_t *timestamp)
|
/* Gets a whole set of gyro data including data, accuracy and timestamp. */
void inv_get_gyro_set(long *data, int8_t *accuracy, inv_time_t *timestamp)
|
{
memcpy(data, sensors.gyro.calibrated, sizeof(sensors.gyro.calibrated));
if (timestamp != NULL) {
*timestamp = sensors.gyro.timestamp;
}
if (accuracy != NULL) {
*accuracy = sensors.gyro.accuracy;
}
}
|
Luos-io/luos_engine
|
C++
|
MIT License
| 496
|
/* Waits to send a character from the specified port. */
|
void UARTCharPut(unsigned long ulBase, unsigned char ucData)
|
/* Waits to send a character from the specified port. */
void UARTCharPut(unsigned long ulBase, unsigned char ucData)
|
{
xASSERT(UARTBaseValid(ulBase));
while(!(xHWREG(ulBase + USART_SR) & USART_SR_TXE))
{
}
xHWREG(ulBase + USART_DR) = ucData;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Sets the crytographic data length in the DES module. */
|
void DESLengthSet(uint32_t ui32Base, uint32_t ui32Length)
|
/* Sets the crytographic data length in the DES module. */
void DESLengthSet(uint32_t ui32Base, uint32_t ui32Length)
|
{
ASSERT(ui32Base == DES_BASE);
HWREG(ui32Base + DES_O_LENGTH) = ui32Length;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Find and report module image info to HOST. */
|
VOID FindAndReportModuleImageInfo(IN UINTN AlignSize)
|
/* Find and report module image info to HOST. */
VOID FindAndReportModuleImageInfo(IN UINTN AlignSize)
|
{
UINTN Pe32Data;
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
Pe32Data = PeCoffSearchImageBase ((UINTN)mErrorMsgVersionAlert);
if (Pe32Data != 0) {
ImageContext.ImageAddress = Pe32Data;
ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID *)(UINTN)ImageContext.ImageAddress);
PeCoffLoaderRelocateImageExtraAction (&ImageContext);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns pointer to a frame buffer colormap structure. */
|
const struct fb_cmap* fb_default_cmap(int len)
|
/* Returns pointer to a frame buffer colormap structure. */
const struct fb_cmap* fb_default_cmap(int len)
|
{
if (len <= 2)
return &default_2_colors;
if (len <= 4)
return &default_4_colors;
if (len <= 8)
return &default_8_colors;
return &default_16_colors;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* There are 2 headers, and the highest sequence number will represent the active header */
|
static int vhdx_create_new_headers(BlockDriverState *bs, uint64_t image_size, uint32_t log_size)
|
/* There are 2 headers, and the highest sequence number will represent the active header */
static int vhdx_create_new_headers(BlockDriverState *bs, uint64_t image_size, uint32_t log_size)
|
{
int ret = 0;
VHDXHeader *hdr = NULL;
hdr = g_malloc0(sizeof(VHDXHeader));
hdr->signature = VHDX_HEADER_SIGNATURE;
hdr->sequence_number = g_random_int();
hdr->log_version = 0;
hdr->version = 1;
hdr->log_length = log_size;
hdr->log_offset = VHDX_HEADER_SECTION_END;
vhdx_guid_generate(&hdr->file_write_guid);
vhdx_guid_generate(&hdr->data_write_guid);
ret = vhdx_write_header(bs, hdr, VHDX_HEADER1_OFFSET, false);
if (ret < 0) {
goto exit;
}
hdr->sequence_number++;
ret = vhdx_write_header(bs, hdr, VHDX_HEADER2_OFFSET, false);
if (ret < 0) {
goto exit;
}
exit:
g_free(hdr);
return ret;
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* returns: 0 on success Negative error code on failure */
|
static int overlay_fixup_phandles(void *fdt, void *fdto)
|
/* returns: 0 on success Negative error code on failure */
static int overlay_fixup_phandles(void *fdt, void *fdto)
|
{
int fixups_off, symbols_off;
int property;
fixups_off = fdt_path_offset(fdto, "/__fixups__");
if (fixups_off == -FDT_ERR_NOTFOUND)
return 0;
if (fixups_off < 0)
return fixups_off;
symbols_off = fdt_path_offset(fdt, "/__symbols__");
if ((symbols_off < 0 && (symbols_off != -FDT_ERR_NOTFOUND)))
return symbols_off;
fdt_for_each_property_offset(property, fdto, fixups_off) {
int ret;
ret = overlay_fixup_phandle(fdt, fdto, symbols_off, property);
if (ret)
return ret;
}
return 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */
|
VOID* EFIAPI AllocateRuntimePages(IN UINTN Pages)
|
/* Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */
VOID* EFIAPI AllocateRuntimePages(IN UINTN Pages)
|
{
VOID *Buffer;
Buffer = InternalAllocatePages (EfiRuntimeServicesData, Pages);
if (Buffer != NULL) {
MemoryProfileLibRecord (
(PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_PAGES,
EfiRuntimeServicesData,
Buffer,
EFI_PAGES_TO_SIZE (Pages),
NULL
);
}
return Buffer;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* callbacks for spdif output switch needs toggle two registers.. */
|
static int snd_cmipci_spdout_enable_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
/* callbacks for spdif output switch needs toggle two registers.. */
static int snd_cmipci_spdout_enable_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
{
int changed;
changed = _snd_cmipci_uswitch_get(kcontrol, ucontrol, &cmipci_switch_arg_spdif_enable);
changed |= _snd_cmipci_uswitch_get(kcontrol, ucontrol, &cmipci_switch_arg_spdo2dac);
return changed;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Converts a ATAPI device path structure to its string representative. */
|
VOID DevPathToTextAtapi(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
|
/* Converts a ATAPI device path structure to its string representative. */
VOID DevPathToTextAtapi(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
|
{
ATAPI_DEVICE_PATH *Atapi;
Atapi = DevPath;
if (DisplayOnly) {
UefiDevicePathLibCatPrint (Str, L"Ata(0x%x)", Atapi->Lun);
} else {
UefiDevicePathLibCatPrint (
Str,
L"Ata(%s,%s,0x%x)",
(Atapi->PrimarySecondary == 1) ? L"Secondary" : L"Primary",
(Atapi->SlaveMaster == 1) ? L"Slave" : L"Master",
Atapi->Lun
);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This is the callback procedure, and is called by the DefaultDirectory method every time a new TIFF directory is opened. */
|
static void _XTIFFDefaultDirectory(TIFF *tif)
|
/* This is the callback procedure, and is called by the DefaultDirectory method every time a new TIFF directory is opened. */
static void _XTIFFDefaultDirectory(TIFF *tif)
|
{
xtiff *xt;
if (!(tif->tif_flags & XTIFF_INITIALIZED))
{
xt = _TIFFmalloc(sizeof(xtiff));
if (!xt)
{
return;
}
_TIFFmemset(xt,0,sizeof(xtiff));
TIFFMEMBER(tif,clientdir) = (tidata_t)xt;
tif->tif_flags |= XTIFF_INITIALIZED;
}
_XTIFFLocalDefaultDirectory(tif);
if (_ParentExtender)
(*_ParentExtender)(tif);
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* This is called from certain upper protocol layers (multilink ppp and x25iface encapsulation module) that want to initiate dialing themselves. */
|
int isdn_net_dial_req(isdn_net_local *lp)
|
/* This is called from certain upper protocol layers (multilink ppp and x25iface encapsulation module) that want to initiate dialing themselves. */
int isdn_net_dial_req(isdn_net_local *lp)
|
{
if (!(ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_AUTO)) return -EBUSY;
return isdn_net_force_dial_lp(lp);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Light up or shut off Energy Mode indicator. */
|
void SegmentLCD_EnergyMode(int em, int on)
|
/* Light up or shut off Energy Mode indicator. */
void SegmentLCD_EnergyMode(int em, int on)
|
{
uint32_t com, bit;
com = EFM_Display.EMode.com[em];
bit = EFM_Display.EMode.bit[em];
if (on)
{
LCD_SegmentSet(com, bit, true);
}
else
{
LCD_SegmentSet(com, bit, false);
}
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Choose a pool in which to create a new thread, for svc_set_num_threads */
|
static struct svc_pool* choose_pool(struct svc_serv *serv, struct svc_pool *pool, unsigned int *state)
|
/* Choose a pool in which to create a new thread, for svc_set_num_threads */
static struct svc_pool* choose_pool(struct svc_serv *serv, struct svc_pool *pool, unsigned int *state)
|
{
if (pool != NULL)
return pool;
return &serv->sv_pools[(*state)++ % serv->sv_nrpools];
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* blf Created. Split out the lookup code from dir.c blf link, mknod, symlink support */
|
static int udf_match(int len1, const char *name1, int len2, const char *name2)
|
/* blf Created. Split out the lookup code from dir.c blf link, mknod, symlink support */
static int udf_match(int len1, const char *name1, int len2, const char *name2)
|
{
if (len1 != len2)
return 0;
return !memcmp(name1, name2, len1);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Initialize DMA Linked List Pointer (hereafter, LLP) mode config structure. Fill each pstcDmaInit with default value. */
|
int32_t DMA_LlpStructInit(stc_dma_llp_init_t *pstcDmaLlpInit)
|
/* Initialize DMA Linked List Pointer (hereafter, LLP) mode config structure. Fill each pstcDmaInit with default value. */
int32_t DMA_LlpStructInit(stc_dma_llp_init_t *pstcDmaLlpInit)
|
{
int32_t i32Ret = LL_OK;
if (NULL == pstcDmaLlpInit) {
i32Ret = LL_ERR_INVD_PARAM;
} else {
pstcDmaLlpInit->u32State = DMA_LLP_DISABLE;
pstcDmaLlpInit->u32Mode = DMA_LLP_WAIT;
pstcDmaLlpInit->u32Addr = 0x00UL;
}
return i32Ret;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Get the peripheral clock speed for the Timer at base specified. */
|
uint32_t rcc_get_timer_clk_freq(uint32_t timer)
|
/* Get the peripheral clock speed for the Timer at base specified. */
uint32_t rcc_get_timer_clk_freq(uint32_t timer)
|
{
if (timer >= TIM2_BASE && timer <= TIM7_BASE) {
uint8_t ppre1 = (RCC_CFGR >> RCC_CFGR_PPRE1_SHIFT) & RCC_CFGR_PPRE1_MASK;
return (ppre1 == RCC_CFGR_PPRE1_NODIV) ? rcc_apb1_frequency
: 2 * rcc_apb1_frequency;
} else {
uint8_t ppre2 = (RCC_CFGR >> RCC_CFGR_PPRE2_SHIFT) & RCC_CFGR_PPRE2_MASK;
return (ppre2 == RCC_CFGR_PPRE2_NODIV) ? rcc_apb2_frequency
: 2 * rcc_apb2_frequency;
}
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* ZigBee Device Profile dissector for the unbind response. */
|
void dissect_zbee_zdp_rsp_unbind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
/* ZigBee Device Profile dissector for the unbind response. */
void dissect_zbee_zdp_rsp_unbind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
{
guint offset = 0;
guint8 status;
status = zdp_parse_status(tree, tvb, &offset);
zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
zdp_dump_excess(tvb, offset, pinfo, tree);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Checks whether the specified DMA Channeln flag is set or not. */
|
FlagStatus DMA_GetFlagStatus(DMA_Flags_TypeDef flag)
|
/* Checks whether the specified DMA Channeln flag is set or not. */
FlagStatus DMA_GetFlagStatus(DMA_Flags_TypeDef flag)
|
{
if(flag >= DMA2_FLAG_GL1 ) {
return (DMA2->ISR & flag) ? SET : RESET;
}
return (DMA1->ISR & flag) ? SET : RESET;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
|
RETURN_STATUS EFIAPI SafeInt16ToUint16(IN INT16 Operand, OUT UINT16 *Result)
|
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt16ToUint16(IN INT16 Operand, OUT UINT16 *Result)
|
{
RETURN_STATUS Status;
if (Result == NULL) {
return RETURN_INVALID_PARAMETER;
}
if (Operand >= 0) {
*Result = (UINT16)Operand;
Status = RETURN_SUCCESS;
} else {
*Result = UINT16_ERROR;
Status = RETURN_BUFFER_TOO_SMALL;
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns the newly built instance of #CRSelector, or NULL in case of failure. */
|
CRSelector* cr_selector_new(CRSimpleSel *a_simple_sel)
|
/* Returns the newly built instance of #CRSelector, or NULL in case of failure. */
CRSelector* cr_selector_new(CRSimpleSel *a_simple_sel)
|
{
CRSelector *result = NULL;
result = g_try_malloc (sizeof (CRSelector));
if (!result) {
cr_utils_trace_info ("Out of memory");
return NULL;
}
memset (result, 0, sizeof (CRSelector));
result->simple_sel = a_simple_sel;
return result;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* The clock_cpu_getres() function shall return the resolution of CPU time, the number of nanosecond per tick. */
|
float clock_cpu_getres(void)
|
/* The clock_cpu_getres() function shall return the resolution of CPU time, the number of nanosecond per tick. */
float clock_cpu_getres(void)
|
{
if (_cputime_ops)
return _cputime_ops->cputime_getres();
rt_set_errno(ENOSYS);
return 0;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* param base LPSPI peripheral base address. param handle pointer to lpspi_master_edma_handle_t structure which stores the transfer state. */
|
void LPSPI_MasterTransferAbortEDMA(LPSPI_Type *base, lpspi_master_edma_handle_t *handle)
|
/* param base LPSPI peripheral base address. param handle pointer to lpspi_master_edma_handle_t structure which stores the transfer state. */
void LPSPI_MasterTransferAbortEDMA(LPSPI_Type *base, lpspi_master_edma_handle_t *handle)
|
{
assert(handle);
LPSPI_DisableDMA(base, kLPSPI_RxDmaEnable | kLPSPI_TxDmaEnable);
EDMA_AbortTransfer(handle->edmaRxRegToRxDataHandle);
EDMA_AbortTransfer(handle->edmaTxDataToTxRegHandle);
handle->state = kLPSPI_Idle;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Return the maximum number of color channels specified for a given photometric type. 0 is returned if photometric type isn't supported or no default value is defined by the specification. */
|
static int _TIFFGetMaxColorChannels(uint16 photometric)
|
/* Return the maximum number of color channels specified for a given photometric type. 0 is returned if photometric type isn't supported or no default value is defined by the specification. */
static int _TIFFGetMaxColorChannels(uint16 photometric)
|
{
switch (photometric) {
case PHOTOMETRIC_PALETTE:
case PHOTOMETRIC_MINISWHITE:
case PHOTOMETRIC_MINISBLACK:
return 1;
case PHOTOMETRIC_YCBCR:
case PHOTOMETRIC_RGB:
case PHOTOMETRIC_CIELAB:
return 3;
case PHOTOMETRIC_SEPARATED:
case PHOTOMETRIC_MASK:
return 4;
case PHOTOMETRIC_LOGL:
case PHOTOMETRIC_LOGLUV:
case PHOTOMETRIC_CFA:
case PHOTOMETRIC_ITULAB:
case PHOTOMETRIC_ICCLAB:
default:
return 0;
}
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Compute the largest value strictly less than y which is on a grid row. */
|
PIXMAN_EXPORT pixman_fixed_t pixman_sample_floor_y(pixman_fixed_t y, int n)
|
/* Compute the largest value strictly less than y which is on a grid row. */
PIXMAN_EXPORT pixman_fixed_t pixman_sample_floor_y(pixman_fixed_t y, int n)
|
{
pixman_fixed_t f = pixman_fixed_frac (y);
pixman_fixed_t i = pixman_fixed_floor (y);
f = DIV (f - pixman_fixed_e - Y_FRAC_FIRST (n), STEP_Y_SMALL (n)) * STEP_Y_SMALL (n) +
Y_FRAC_FIRST (n);
if (f < Y_FRAC_FIRST (n))
{
if (pixman_fixed_to_int (i) == 0x8000)
{
f = 0;
}
else
{
f = Y_FRAC_LAST (n);
i -= pixman_fixed_1;
}
}
return (i | f);
}
|
xboot/xboot
|
C++
|
MIT License
| 779
|
/* Resets the clock configuration to the default state. */
|
void RCM_Reset(void)
|
/* Resets the clock configuration to the default state. */
void RCM_Reset(void)
|
{
RCM->CTRL_B.HSIEN = BIT_SET;
RCM->CFG &= (uint32_t)0xF8FF0000;
RCM->CTRL &= (uint32_t)0xFEF6FFFF;
RCM->CTRL_B.HSEBCFG = BIT_RESET;
RCM->CFG &= (uint32_t)0xFF00FFFF;
RCM->INT = 0x009F0000;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This function computes the bit position of the highest bit set in the 32-bit value specified by Operand. If Operand is zero, then -1 is returned. Otherwise, a value between 0 and 31 is returned. */
|
INTN EFIAPI HighBitSet32(IN UINT32 Operand)
|
/* This function computes the bit position of the highest bit set in the 32-bit value specified by Operand. If Operand is zero, then -1 is returned. Otherwise, a value between 0 and 31 is returned. */
INTN EFIAPI HighBitSet32(IN UINT32 Operand)
|
{
INTN BitIndex;
if (Operand == 0) {
return -1;
}
for (BitIndex = 31; (INT32)Operand > 0; BitIndex--, Operand <<= 1) {
}
return BitIndex;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Read sensor data.
This routine calls the appropriate internal data function to obtain the specified type of data from the sensor device. */
|
static bool itg3200_read(sensor_t *sensor, sensor_read_t type, sensor_data_t *data)
|
/* Read sensor data.
This routine calls the appropriate internal data function to obtain the specified type of data from the sensor device. */
static bool itg3200_read(sensor_t *sensor, sensor_read_t type, sensor_data_t *data)
|
{
sensor_hal_t *const hal = sensor->hal;
switch (type) {
case SENSOR_READ_ROTATION:
return itg3200_get_rotation(hal, data);
case SENSOR_READ_TEMPERATURE:
return itg3200_get_temperature(hal, data);
case SENSOR_READ_ID:
return itg3200_device_id(hal, data);
default:
sensor->err = SENSOR_ERR_FUNCTION;
return false;
}
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Enables the ADC module.
Enables an ADC module that has previously been configured. */
|
void adc_enable(void)
|
/* Enables the ADC module.
Enables an ADC module that has previously been configured. */
void adc_enable(void)
|
{
system_clock_peripheral_enable(PERIPHERAL_ADC);
AON_GP_REGS0->AON_PMU_CTRL.reg &= \
~AON_GP_REGS_AON_PMU_CTRL_PMU_SENS_ADC_RST;
AON_GP_REGS0->AON_PMU_CTRL.reg |= \
AON_GP_REGS_AON_PMU_CTRL_PMU_SENS_ADC_EN | \
AON_GP_REGS_AON_PMU_CTRL_PMU_BGR_EN;
for (uint16_t i = 0; i < 0xFF; i++) {
}
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Note that the current directory string should exclude the tailing backslash character. */
|
CONST CHAR16* EFIAPI EfiShellGetCurDir(IN CONST CHAR16 *FileSystemMapping OPTIONAL)
|
/* Note that the current directory string should exclude the tailing backslash character. */
CONST CHAR16* EFIAPI EfiShellGetCurDir(IN CONST CHAR16 *FileSystemMapping OPTIONAL)
|
{
CHAR16 *PathToReturn;
UINTN Size;
SHELL_MAP_LIST *MapListItem;
if (!IsListEmpty (&gShellMapList.Link)) {
if (FileSystemMapping == NULL) {
return (EfiShellGetEnv (L"cwd"));
} else {
Size = 0;
PathToReturn = NULL;
MapListItem = ShellCommandFindMapItem (FileSystemMapping);
if (MapListItem != NULL) {
ASSERT ((PathToReturn == NULL && Size == 0) || (PathToReturn != NULL));
PathToReturn = StrnCatGrow (&PathToReturn, &Size, MapListItem->MapName, 0);
PathToReturn = StrnCatGrow (&PathToReturn, &Size, MapListItem->CurrentDirectoryPath, 0);
}
}
return (AddBufferToFreeList (PathToReturn));
} else {
return (NULL);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function configures the Cortex-M SysTick source to have 1ms time base. */
|
void LL_Init1msTick(uint32_t CPU_Frequency)
|
/* This function configures the Cortex-M SysTick source to have 1ms time base. */
void LL_Init1msTick(uint32_t CPU_Frequency)
|
{
LL_InitTick(CPU_Frequency, 1000U);
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* Prepares for the data used by CPU feature detection and initialization. */
|
VOID* EFIAPI ProcTraceGetConfigData(IN UINTN NumberOfProcessors)
|
/* Prepares for the data used by CPU feature detection and initialization. */
VOID* EFIAPI ProcTraceGetConfigData(IN UINTN NumberOfProcessors)
|
{
PROC_TRACE_DATA *ConfigData;
ConfigData = AllocateZeroPool (sizeof (PROC_TRACE_DATA) + sizeof (PROC_TRACE_PROCESSOR_DATA) * NumberOfProcessors);
ASSERT (ConfigData != NULL);
ConfigData->ProcessorData = (PROC_TRACE_PROCESSOR_DATA *)((UINT8 *)ConfigData + sizeof (PROC_TRACE_DATA));
ConfigData->NumberOfProcessors = (UINT32)NumberOfProcessors;
ConfigData->ProcTraceMemSize = PcdGet32 (PcdCpuProcTraceMemSize);
ConfigData->ProcTraceOutputScheme = PcdGet8 (PcdCpuProcTraceOutputScheme);
ConfigData->EnableOnBspOnly = PcdGetBool (PcdCpuProcTraceBspOnly);
ConfigData->EnablePerformanceCollecting = PcdGetBool (PcdCpuProcTracePerformanceCollecting);
return ConfigData;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* return true if the particular booting option is selected return false otherwise */
|
static u32 read_bootstrap(void)
|
/* return true if the particular booting option is selected return false otherwise */
static u32 read_bootstrap(void)
|
{
return (readl(CONFIG_SPEAR_BOOTSTRAPCFG) >> CONFIG_SPEAR_BOOTSTRAPSHFT)
& CONFIG_SPEAR_BOOTSTRAPMASK;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Clears the RCC reset flags. The reset flags are: RCC_FLAG_PINRST, RCC_FLAG_PORRST, RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST. */
|
void RCC_ClearFlag(void)
|
/* Clears the RCC reset flags. The reset flags are: RCC_FLAG_PINRST, RCC_FLAG_PORRST, RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST. */
void RCC_ClearFlag(void)
|
{
RCC->CSR |= CSR_RMVF_Set;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* The notifier will result in adding/deleteing of devices. Devices can only removed in user process, not in bh. */
|
static int notify_push(unsigned int cmd, u32 controller, u16 applid, u32 ncci)
|
/* The notifier will result in adding/deleteing of devices. Devices can only removed in user process, not in bh. */
static int notify_push(unsigned int cmd, u32 controller, u16 applid, u32 ncci)
|
{
struct capi_notifier *np = kmalloc(sizeof(*np), GFP_ATOMIC);
if (!np)
return -ENOMEM;
INIT_WORK(&np->work, notify_handler);
np->cmd = cmd;
np->controller = controller;
np->applid = applid;
np->ncci = ncci;
schedule_work(&np->work);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Start the SYSTICK.
This function starts the systick timer. */
|
void am_hal_systick_start(void)
|
/* Start the SYSTICK.
This function starts the systick timer. */
void am_hal_systick_start(void)
|
{
AM_REG(SYSTICK, SYSTCSR) |= AM_REG_SYSTICK_SYSTCSR_ENABLE_M;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Replaces 8 elements with their average value. Called by qdm2_decode_superblock before starting subblock decoding. */
|
static void average_quantized_coeffs(QDM2Context *q)
|
/* Replaces 8 elements with their average value. Called by qdm2_decode_superblock before starting subblock decoding. */
static void average_quantized_coeffs(QDM2Context *q)
|
{
int i, j, n, ch, sum;
n = coeff_per_sb_for_avg[q->coeff_per_sb_select][QDM2_SB_USED(q->sub_sampling) - 1] + 1;
for (ch = 0; ch < q->nb_channels; ch++)
for (i = 0; i < n; i++) {
sum = 0;
for (j = 0; j < 8; j++)
sum += q->quantized_coeffs[ch][i][j];
sum /= 8;
if (sum > 0)
sum--;
for (j=0; j < 8; j++)
q->quantized_coeffs[ch][i][j] = sum;
}
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* open and close keep track of how many times the CQ is mapped, to avoid releasing it. */
|
static void ipath_vma_open(struct vm_area_struct *vma)
|
/* open and close keep track of how many times the CQ is mapped, to avoid releasing it. */
static void ipath_vma_open(struct vm_area_struct *vma)
|
{
struct ipath_mmap_info *ip = vma->vm_private_data;
kref_get(&ip->ref);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Indicates that the controller has detected a resume or remote Wake-up sequence. */
|
static void usb_resume_isr(usb_core_instance *pdev)
|
/* Indicates that the controller has detected a resume or remote Wake-up sequence. */
static void usb_resume_isr(usb_core_instance *pdev)
|
{
if (0U != pdev->basic_cfgs.low_power) {
CLR_REG32_BIT(*pdev->regs.GCCTL, USBFS_GCCTL_STPPCLK | USBFS_GCCTL_GATEHCLK);
}
CLR_REG32_BIT(pdev->regs.DREGS->DCTL, USBFS_DCTL_RWUSIG);
dev_int_cbkpr->Resume(pdev);
WRITE_REG32(pdev->regs.GREGS->GINTSTS, USBFS_GINTSTS_WKUINT);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Simple function to compare two rate scale table types */
|
static bool table_type_matches(struct iwl_scale_tbl_info *a, struct iwl_scale_tbl_info *b)
|
/* Simple function to compare two rate scale table types */
static bool table_type_matches(struct iwl_scale_tbl_info *a, struct iwl_scale_tbl_info *b)
|
{
return (a->lq_type == b->lq_type) && (a->ant_type == b->ant_type) &&
(a->is_SGI == b->is_SGI);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns: the number of bits used to hold @number */
|
guint() g_bit_storage(gulong number)
|
/* Returns: the number of bits used to hold @number */
guint() g_bit_storage(gulong number)
|
{
return g_bit_storage_impl (number);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Fills each TIM_OCInitStruct member with its default value. */
|
void TIM_InitOcStruct(OCInitType *TIM_OCInitStruct)
|
/* Fills each TIM_OCInitStruct member with its default value. */
void TIM_InitOcStruct(OCInitType *TIM_OCInitStruct)
|
{
TIM_OCInitStruct->OcMode = TIM_OCMODE_TIMING;
TIM_OCInitStruct->OutputState = TIM_OUTPUT_STATE_DISABLE;
TIM_OCInitStruct->OutputNState = TIM_OUTPUT_NSTATE_DISABLE;
TIM_OCInitStruct->Pulse = 0x0000;
TIM_OCInitStruct->OcPolarity = TIM_OC_POLARITY_HIGH;
TIM_OCInitStruct->OcNPolarity = TIM_OC_POLARITY_HIGH;
TIM_OCInitStruct->OcIdleState = TIM_OC_IDLE_STATE_RESET;
TIM_OCInitStruct->OcNIdleState = TIM_OCN_IDLE_STATE_RESET;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Reads the specified I2C register and returns its value. */
|
uint16_t I2C_GetRegister(I2C_Module *I2Cx, uint8_t I2C_Register)
|
/* Reads the specified I2C register and returns its value. */
uint16_t I2C_GetRegister(I2C_Module *I2Cx, uint8_t I2C_Register)
|
{
__IO uint32_t tmp = 0;
assert_param(IS_I2C_PERIPH(I2Cx));
assert_param(IS_I2C_REG(I2C_Register));
tmp = (uint32_t)I2Cx;
tmp += I2C_Register;
return (*(__IO uint16_t*)tmp);
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Something has gone wrong with the descriptor usage. Reset all the buffers and descriptors. */
|
static void prvResetEverything(void)
|
/* Something has gone wrong with the descriptor usage. Reset all the buffers and descriptors. */
static void prvResetEverything(void)
|
{
portDISABLE_INTERRUPTS();
for( ;; );
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Description: Query @sk to see if there is a CIPSO option attached to the sock and if there is return the CIPSO security attributes in @secattr. This function requires that @sk be locked, or privately held, but it does not do any locking itself. Returns zero on success and negative values on failure. */
|
int cipso_v4_sock_getattr(struct sock *sk, struct netlbl_lsm_secattr *secattr)
|
/* Description: Query @sk to see if there is a CIPSO option attached to the sock and if there is return the CIPSO security attributes in @secattr. This function requires that @sk be locked, or privately held, but it does not do any locking itself. Returns zero on success and negative values on failure. */
int cipso_v4_sock_getattr(struct sock *sk, struct netlbl_lsm_secattr *secattr)
|
{
struct ip_options *opt;
opt = inet_sk(sk)->opt;
if (opt == NULL || opt->cipso == 0)
return -ENOMSG;
return cipso_v4_getattr(opt->__data + opt->cipso - sizeof(struct iphdr),
secattr);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* udc_startup - allow udc code to do any additional startup */
|
void udc_startup_events(struct usb_device_instance *device)
|
/* udc_startup - allow udc code to do any additional startup */
void udc_startup_events(struct usb_device_instance *device)
|
{
usbd_device_event_irq(device, DEVICE_INIT, 0);
usbd_device_event_irq(device, DEVICE_CREATE, 0);
udc_enable(device);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Release all the resource used the DNS service binding instance. */
|
VOID DnsDestroyService(IN DNS_SERVICE *DnsSb)
|
/* Release all the resource used the DNS service binding instance. */
VOID DnsDestroyService(IN DNS_SERVICE *DnsSb)
|
{
UdpIoFreeIo (DnsSb->ConnectUdp);
if (DnsSb->TimerToGetMap != NULL) {
gBS->CloseEvent (DnsSb->TimerToGetMap);
}
if (DnsSb->Timer != NULL) {
gBS->CloseEvent (DnsSb->Timer);
}
FreePool (DnsSb);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Configures the sensors as keys and assigns the channel numbers. */
|
static void config_sensor(void)
|
/* Configures the sensors as keys and assigns the channel numbers. */
static void config_sensor(void)
|
{
qt_enable_key(CHANNEL_0, NO_AKS_GROUP, 10, HYST_6_25);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* EISA bus I/O device probe. Probe from slot 1 since slot 0 is usually the motherboard. */
|
static int __init eisa_probe(struct net_device *dev, u_long iobase)
|
/* EISA bus I/O device probe. Probe from slot 1 since slot 0 is usually the motherboard. */
static int __init eisa_probe(struct net_device *dev, u_long iobase)
|
{
int i, maxSlots;
u_long iobase;
int ret = -ENODEV;
if (ioaddr < 0x1000)
goto out;
iobase = ioaddr;
i = (ioaddr >> 12);
maxSlots = i + 1;
for (i = 1; (i < maxSlots) && (dev != NULL); i++, iobase += EISA_SLOT_INC) {
if (EISA_signature(name, EISA_ID) == 0) {
if (request_region(iobase, EWRK3_TOTAL_SIZE, DRV_NAME) &&
DevicePresent(iobase) == 0) {
int irq = dev->irq;
ret = ewrk3_hw_init(dev, iobase);
if (!ret)
break;
dev->irq = irq;
}
release_region(iobase, EWRK3_TOTAL_SIZE);
}
}
out:
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The function is used to set ready counter bit length of HSI.
The */
|
void SysCtlHSIReadyCounterBitLengthSet(unsigned long ulBitLength)
|
/* The function is used to set ready counter bit length of HSI.
The */
void SysCtlHSIReadyCounterBitLengthSet(unsigned long ulBitLength)
|
{
xASSERT((ulBitLength == PWRCU_HSIRCR_HSIRCBL_7) ||
(ulBitLength == PWRCU_HSIRCR_HSIRCBL_8) ||
(ulBitLength == PWRCU_HSIRCR_HSIRCBL_9) ||
(ulBitLength == PWRCU_HSIRCR_HSIRCBL_10)
);
xHWREG(PWRCU_HSIRCR) &= ~PWRCU_HSIRCR_HSIRCBL_M;
xHWREG(PWRCU_HSIRCR) |= ulBitLength;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Enables or disables LPUART Wakeup in STOP2 mode. */
|
void LPUART_EnableWakeUpStop(FunctionalState Cmd)
|
/* Enables or disables LPUART Wakeup in STOP2 mode. */
void LPUART_EnableWakeUpStop(FunctionalState Cmd)
|
{
assert_param(IS_FUNCTIONAL_STATE(Cmd));
if (Cmd != DISABLE)
{
LPUART->CTRL |= CTRL_WUSTP_SET;
}
else
{
LPUART->CTRL &= CTRL_WUSTP_RESET;
}
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Retrieve the frequency of a clock source.
Determines the current operating frequency of a given clock source. */
|
uint32_t system_clock_source_get_hz(const enum system_clock_source clock_source)
|
/* Retrieve the frequency of a clock source.
Determines the current operating frequency of a given clock source. */
uint32_t system_clock_source_get_hz(const enum system_clock_source clock_source)
|
{
switch (clock_source) {
case SYSTEM_CLOCK_SOURCE_XOSC:
return _system_clock_inst.xosc.frequency;
case SYSTEM_CLOCK_SOURCE_OSC48M:
return 48000000UL / (OSCCTRL->OSC48MDIV.bit.DIV + 1);
case SYSTEM_CLOCK_SOURCE_OSC32K:
return 32768UL;
case SYSTEM_CLOCK_SOURCE_ULP32K:
return 32768UL;
case SYSTEM_CLOCK_SOURCE_XOSC32K:
return _system_clock_inst.xosc32k.frequency;
case SYSTEM_CLOCK_SOURCE_DPLL:
if (!(OSCCTRL->DPLLCTRLA.reg & OSCCTRL_DPLLCTRLA_ENABLE)) {
return 0;
}
return _system_clock_inst.dpll.frequency;
default:
return 0;
}
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Sets a fiber PHY's advertisement register to advertise the requested capabilities. */
|
int t3_phy_advertise_fiber(struct cphy *phy, unsigned int advert)
|
/* Sets a fiber PHY's advertisement register to advertise the requested capabilities. */
int t3_phy_advertise_fiber(struct cphy *phy, unsigned int advert)
|
{
unsigned int val = 0;
if (advert & ADVERTISED_1000baseT_Half)
val |= ADVERTISE_1000XHALF;
if (advert & ADVERTISED_1000baseT_Full)
val |= ADVERTISE_1000XFULL;
if (advert & ADVERTISED_Pause)
val |= ADVERTISE_1000XPAUSE;
if (advert & ADVERTISED_Asym_Pause)
val |= ADVERTISE_1000XPSE_ASYM;
return t3_mdio_write(phy, MDIO_DEVAD_NONE, MII_ADVERTISE, val);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Retrieve ordinal number of the given adc hardware instance. */
|
static uint8_t _adc_get_hardware_index(const void *const hw)
|
/* Retrieve ordinal number of the given adc hardware instance. */
static uint8_t _adc_get_hardware_index(const void *const hw)
|
{
(void)hw;
return 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Converts a Firmware Volume File device path structure to its string representative. */
|
VOID DevPathToTextFvFile(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
|
/* Converts a Firmware Volume File device path structure to its string representative. */
VOID DevPathToTextFvFile(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
|
{
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;
FvFile = DevPath;
UefiDevicePathLibCatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* NULL if vaddr invalid OR is not a valid GSEG vaddr. */
|
static struct gru_thread_state* gru_find_lock_gts(unsigned long vaddr)
|
/* NULL if vaddr invalid OR is not a valid GSEG vaddr. */
static struct gru_thread_state* gru_find_lock_gts(unsigned long vaddr)
|
{
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
struct gru_thread_state *gts = NULL;
down_read(&mm->mmap_sem);
vma = gru_find_vma(vaddr);
if (vma)
gts = gru_find_thread_state(vma, TSID(vaddr, vma));
if (gts)
mutex_lock(>s->ts_ctxlock);
else
up_read(&mm->mmap_sem);
return gts;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Writes value at the given offset in the register array which stores the VLAN filter table. */
|
void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value)
|
/* Writes value at the given offset in the register array which stores the VLAN filter table. */
void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value)
|
{
E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, value);
e1e_flush();
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Deinitializes the SYSCFG registers to their default reset values. */
|
void SYSCFG_DeInit(void)
|
/* Deinitializes the SYSCFG registers to their default reset values. */
void SYSCFG_DeInit(void)
|
{
SYSCFG->CFGR1 &= SYSCFG_CFGR1_MEM_MODE;
SYSCFG->CFGR1 |= 0x7C000000;
SYSCFG->EXTICR[0] = 0;
SYSCFG->EXTICR[1] = 0;
SYSCFG->EXTICR[2] = 0;
SYSCFG->EXTICR[3] = 0;
SYSCFG->CFGR2 = 0;
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* 6.5.4.4. Diagnostic Message (Unconfirmed Service Id = 1) 6.5.4.4.1. Request Message Parameters */
|
static void dissect_ff_msg_diagnostic_msg_req_dup_detection_stat(tvbuff_t *tvb, gint offset, proto_tree *tree)
|
/* 6.5.4.4. Diagnostic Message (Unconfirmed Service Id = 1) 6.5.4.4.1. Request Message Parameters */
static void dissect_ff_msg_diagnostic_msg_req_dup_detection_stat(tvbuff_t *tvb, gint offset, proto_tree *tree)
|
{
static const int * dup_flags[] = {
&hf_ff_lr_diagnostic_msg_req_dup_detection_state_reserved,
&hf_ff_lr_diagnostic_msg_req_dup_detection_state_pd_tag,
&hf_ff_lr_diagnostic_msg_req_dup_detection_state_device,
NULL
};
proto_tree_add_bitmask(tree, tvb, offset, hf_ff_lr_diagnostic_msg_req_dup_detection_state, ett_ff_lr_diagnostic_msg_req_dup_detection_stat, dup_flags, ENC_BIG_ENDIAN);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Creates 1-1-1 mapping and returns @da again, which can be adjusted if 'IOVMF_DA_ANON' is set. */
|
u32 iommu_kmap(struct iommu *obj, u32 da, u32 pa, size_t bytes, u32 flags)
|
/* Creates 1-1-1 mapping and returns @da again, which can be adjusted if 'IOVMF_DA_ANON' is set. */
u32 iommu_kmap(struct iommu *obj, u32 da, u32 pa, size_t bytes, u32 flags)
|
{
void *va;
if (!obj || !obj->dev || !bytes)
return -EINVAL;
bytes = PAGE_ALIGN(bytes);
va = ioremap(pa, bytes);
if (!va)
return -ENOMEM;
flags &= IOVMF_HW_MASK;
flags |= IOVMF_LINEAR;
flags |= IOVMF_MMIO;
flags |= (da ? IOVMF_DA_FIXED : IOVMF_DA_ANON);
da = __iommu_kmap(obj, da, pa, va, bytes, flags);
if (IS_ERR_VALUE(da))
iounmap(va);
return da;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Hides the details of the LRU cache etc from the filesystems. */
|
int read_cache_pages(struct address_space *mapping, struct list_head *pages, int(*filler)(void *, struct page *), void *data)
|
/* Hides the details of the LRU cache etc from the filesystems. */
int read_cache_pages(struct address_space *mapping, struct list_head *pages, int(*filler)(void *, struct page *), void *data)
|
{
struct page *page;
int ret = 0;
while (!list_empty(pages)) {
page = list_to_page(pages);
list_del(&page->lru);
if (add_to_page_cache_lru(page, mapping,
page->index, GFP_KERNEL)) {
read_cache_pages_invalidate_page(mapping, page);
continue;
}
page_cache_release(page);
ret = filler(data, page);
if (unlikely(ret)) {
read_cache_pages_invalidate_pages(mapping, pages);
break;
}
task_io_account_read(PAGE_CACHE_SIZE);
}
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Reads the I2C register and returns its value. */
|
uint16_t I2C_ReadRegister(I2C_T *i2c, I2C_REGISTER_T i2cRegister)
|
/* Reads the I2C register and returns its value. */
uint16_t I2C_ReadRegister(I2C_T *i2c, I2C_REGISTER_T i2cRegister)
|
{
switch (i2cRegister)
{
case I2C_REGISTER_CTRL1:
return i2c->CTRL1;
case I2C_REGISTER_CTRL2:
return i2c->CTRL2;
case I2C_REGISTER_SADDR1:
return i2c->SADDR1;
case I2C_REGISTER_SADDR2:
return i2c->SADDR2;
case I2C_REGISTER_DATA:
return i2c->DATA;
case I2C_REGISTER_STS1:
return i2c->STS1;
case I2C_REGISTER_STS2:
return i2c->STS2;
case I2C_REGISTER_CLKCTRL:
return i2c->CLKCTRL;
case I2C_REGISTER_RISETMAX:
return i2c->RISETMAX;
case I2C_REGISTER_SWITCH:
return i2c->I2C_SWITCH;
default:
return 0;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.