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 |
|---|---|---|---|---|---|---|---|
/* Returns 0 on success or a negative error code. */ | int nla_validate(struct nlattr *head, int len, int maxtype, const struct nla_policy *policy) | /* Returns 0 on success or a negative error code. */
int nla_validate(struct nlattr *head, int len, int maxtype, const struct nla_policy *policy) | {
struct nlattr *nla;
int rem, err;
nla_for_each_attr(nla, head, len, rem) {
err = validate_nla(nla, maxtype, policy);
if (err < 0)
goto errout;
}
err = 0;
errout:
return err;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* API to retrieve frequency of USB PLL output clock */ | uint32_t XMC_SCU_CLOCK_GetUsbPllClockFrequency(void) | /* API to retrieve frequency of USB PLL output clock */
uint32_t XMC_SCU_CLOCK_GetUsbPllClockFrequency(void) | {
n_div = (uint32_t)((((SCU_PLL->USBPLLCON) & SCU_PLL_USBPLLCON_NDIV_Msk) >> SCU_PLL_USBPLLCON_NDIV_Pos) + 1UL);
p_div = (uint32_t)((((SCU_PLL->USBPLLCON) & SCU_PLL_USBPLLCON_PDIV_Msk) >> SCU_PLL_USBPLLCON_PDIV_Pos) + 1UL);
clock_frequency = (uint32_t)((clock_frequency * n_div)/ (uint32_t)(p_div * 2UL));
}
return (clock_frequency);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* When a control URB terminates with an error other than -EREMOTEIO, it is quite likely that the status stage of the transfer will not take place. */ | int usb_unlink_urb(struct urb *urb) | /* When a control URB terminates with an error other than -EREMOTEIO, it is quite likely that the status stage of the transfer will not take place. */
int usb_unlink_urb(struct urb *urb) | {
if (!urb)
return -EINVAL;
if (!urb->dev)
return -ENODEV;
if (!urb->ep)
return -EIDRM;
return usb_hcd_unlink_urb(urb, -ECONNRESET);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Message: QoSTeardownMessage Opcode: 0x014f Type: IntraCCM Direction: pbx2pbx VarLength: no */ | static void handle_QoSTeardownMessage(ptvcursor_t *cursor, packet_info *pinfo _U_) | /* Message: QoSTeardownMessage Opcode: 0x014f Type: IntraCCM Direction: pbx2pbx VarLength: no */
static void handle_QoSTeardownMessage(ptvcursor_t *cursor, packet_info *pinfo _U_) | {
ptvcursor_add(cursor, hf_skinny_conferenceID, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_passThruPartyID, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_ipv4or6(cursor, hf_skinny_remoteIpAddr_ipv4, hf_skinny_remoteIpAddr_ipv6, pinfo);
ptvcursor_add(cursor, hf_skinny_remotePortNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_direction, 4, ENC_LITTLE_ENDIAN);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Peek a message from the specified IPC channel. */ | rt_err_t rt_raw_channel_peek(rt_channel_t ch, rt_channel_msg_t data) | /* Peek a message from the specified IPC channel. */
rt_err_t rt_raw_channel_peek(rt_channel_t ch, rt_channel_msg_t data) | {
return _rt_raw_channel_recv_timeout(ch, data, 0);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* DMA Stream Enable Interrupt on Transfer Half Complete. */ | void dma_enable_half_transfer_interrupt(uint32_t dma, uint8_t stream) | /* DMA Stream Enable Interrupt on Transfer Half Complete. */
void dma_enable_half_transfer_interrupt(uint32_t dma, uint8_t stream) | {
dma_clear_interrupt_flags(dma, stream, DMA_HTIF);
DMA_SCR(dma, stream) |= DMA_SxCR_HTIE;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* This function is executed in case of error occurrence. */ | static void Error_Handler(void) | /* This function is executed in case of error occurrence. */
static void Error_Handler(void) | {
BSP_LED_On(LED_RED);
while(1)
{
}
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Gets the transfer mode for a uDMA channel control structure. */ | uint32_t uDMAChannelModeGet(uint32_t ui32ChannelStructIndex) | /* Gets the transfer mode for a uDMA channel control structure. */
uint32_t uDMAChannelModeGet(uint32_t ui32ChannelStructIndex) | {
tDMAControlTable *psControlTable;
uint32_t ui32Control;
ASSERT((ui32ChannelStructIndex & 0xffff) < 64);
ASSERT(HWREG(UDMA_CTLBASE) != 0);
ui32ChannelStructIndex &= 0x3f;
psControlTable = (tDMAControlTable *)HWREG(UDMA_CTLBASE);
ui32Control = (psControlTable[ui32ChannelStructIndex].ui32Control &
UDMA_CHCTL_XFERMODE_M);
if(((ui32Control & ~UDMA_MODE_ALT_SELECT) ==
UDMA_MODE_MEM_SCATTER_GATHER) ||
((ui32Control & ~UDMA_MODE_ALT_SELECT) == UDMA_MODE_PER_SCATTER_GATHER))
{
ui32Control &= ~UDMA_MODE_ALT_SELECT;
}
return(ui32Control);
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* What we want to do here is fill in any hole between the current end of allocation and the end of our write. That way the rest of the write path can treat it as an non-allocating write, which has no special case code for sparse/nonsparse files. */ | static int ocfs2_expand_nonsparse_inode(struct inode *inode, loff_t pos, unsigned len, struct ocfs2_write_ctxt *wc) | /* What we want to do here is fill in any hole between the current end of allocation and the end of our write. That way the rest of the write path can treat it as an non-allocating write, which has no special case code for sparse/nonsparse files. */
static int ocfs2_expand_nonsparse_inode(struct inode *inode, loff_t pos, unsigned len, struct ocfs2_write_ctxt *wc) | {
int ret;
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
loff_t newsize = pos + len;
if (ocfs2_sparse_alloc(osb))
return 0;
if (newsize <= i_size_read(inode))
return 0;
ret = ocfs2_extend_no_holes(inode, newsize, pos);
if (ret)
mlog_errno(ret);
wc->w_first_new_cpos =
ocfs2_clusters_for_bytes(inode->i_sb, i_size_read(inode));
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* We also need to register our function for guessing event sizes. */ | static int __init i1480_dfu_driver_init(void) | /* We also need to register our function for guessing event sizes. */
static int __init i1480_dfu_driver_init(void) | {
return usb_register(&i1480_dfu_driver);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Adds a new value to the sma_f_t instances. */ | void sma_f_add(sma_f_t *sma, float x) | /* Adds a new value to the sma_f_t instances. */
void sma_f_add(sma_f_t *sma, float x) | {
float *pSource = sma->buffer + (sma->k % sma->size);
sma->total -= *pSource;
*pSource = x;
sma->total += x;
sma->k++;
if (sma->k < sma->size)
return;
double tmp_total = sma->total;
uint64_t *ptr = (uint64_t *)(&tmp_total);
*ptr -= ((uint64_t)(sma->exponent)) << 52;
sma->avg = (float)(tmp_total);
} | microbuilder/LPC11U_LPC13U_CodeBase | C++ | Other | 54 |
/* pm8001_chip_phy_ctl_req - support the local phy operation @pm8001_ha: our hba card information. @num: the inbound queue number @phy_id: the phy id which we wanted to operate @phy_op: */ | static int pm8001_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, u32 phyId, u32 phy_op) | /* pm8001_chip_phy_ctl_req - support the local phy operation @pm8001_ha: our hba card information. @num: the inbound queue number @phy_id: the phy id which we wanted to operate @phy_op: */
static int pm8001_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, u32 phyId, u32 phy_op) | {
struct local_phy_ctl_req payload;
struct inbound_queue_table *circularQ;
int ret;
u32 opc = OPC_INB_LOCAL_PHY_CONTROL;
memset(&payload, 0, sizeof(payload));
circularQ = &pm8001_ha->inbnd_q_tbl[0];
payload.tag = 1;
payload.phyop_phyid =
cpu_to_le32(((phy_op & 0xff) << 8) | (phyId & 0x0F));
ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* ADC group injected end of unitary conversion interruption callback. */ | void AdcGrpInjectedUnitaryConvComplete_Callback() | /* ADC group injected end of unitary conversion interruption callback. */
void AdcGrpInjectedUnitaryConvComplete_Callback() | {
uhADCxGrpInjectedConvertedData = LL_ADC_INJ_ReadConversionData12(ADC1, LL_ADC_INJ_RANK_1);
uhADCxGrpInjectedConvertedData_Voltage_mVolt = __LL_ADC_CALC_DATA_TO_VOLTAGE(VDDA_APPLI, uhADCxGrpInjectedConvertedData, LL_ADC_RESOLUTION_12B);
ubAdcGrpInjectedUnitaryConvStatus = 1;
LED_On();
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Used to physically identify the NIC on the system. The Link LED will blink for a time specified by the user. Return value: 0 on success */ | static int vxge_ethtool_idnic(struct net_device *dev, u32 data) | /* Used to physically identify the NIC on the system. The Link LED will blink for a time specified by the user. Return value: 0 on success */
static int vxge_ethtool_idnic(struct net_device *dev, u32 data) | {
struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev);
struct __vxge_hw_device *hldev = (struct __vxge_hw_device *)
pci_get_drvdata(vdev->pdev);
vxge_hw_device_flick_link_led(hldev, VXGE_FLICKER_ON);
msleep_interruptible(data ? (data * HZ) : VXGE_MAX_FLICKER_TIME);
vxge_hw_device_flick_link_led(hldev, VXGE_FLICKER_OFF);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */ | void GPIOPinTypeGPIOOutput(unsigned long ulPort, unsigned char ucPins) | /* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
void GPIOPinTypeGPIOOutput(unsigned long ulPort, unsigned char ucPins) | {
ASSERT(GPIOBaseValid(ulPort));
GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_OUT);
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* This API reads the sensor time of Sensor time gets updated with every update of data register or FIFO. */ | uint16_t bma4_get_sensor_time(uint32_t *sensor_time, struct bma4_dev *dev) | /* This API reads the sensor time of Sensor time gets updated with every update of data register or FIFO. */
uint16_t bma4_get_sensor_time(uint32_t *sensor_time, struct bma4_dev *dev) | {
uint16_t rslt = 0;
uint8_t data[BMA4_SENSOR_TIME_LENGTH] = {0};
uint8_t msb = 0;
uint8_t xlsb = 0;
uint8_t lsb = 0;
if (dev == NULL) {
rslt |= BMA4_E_NULL_PTR;
} else {
rslt |= bma4_read_regs(BMA4_SENSORTIME_0_ADDR, data, BMA4_SENSOR_TIME_LENGTH, dev);
if (rslt == BMA4_OK) {
msb = data[BMA4_SENSOR_TIME_MSB_BYTE];
xlsb = data[BMA4_SENSOR_TIME_XLSB_BYTE];
lsb = data[BMA4_SENSOR_TIME_LSB_BYTE];
*sensor_time = (uint32_t)((msb << 16) | (xlsb << 8) | lsb);
}
}
return rslt;
} | arendst/Tasmota | C++ | GNU General Public License v3.0 | 21,318 |
/* fi An instance of a channel statemachine. event The event, just happened. arg Generic pointer, casted from channel * upon call. */ | static void ctcm_chx_iofatal(fsm_instance *fi, int event, void *arg) | /* fi An instance of a channel statemachine. event The event, just happened. arg Generic pointer, casted from channel * upon call. */
static void ctcm_chx_iofatal(fsm_instance *fi, int event, void *arg) | {
struct channel *ch = arg;
struct net_device *dev = ch->netdev;
struct ctcm_priv *priv = dev->ml_priv;
int rd = CHANNEL_DIRECTION(ch->flags);
fsm_deltimer(&ch->timer);
CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR,
"%s: %s: %s unrecoverable channel error",
CTCM_FUNTAIL, ch->id, rd == READ ? "RX" : "TX");
if (IS_MPC(ch)) {
priv->stats.tx_dropped++;
priv->stats.tx_errors++;
}
if (rd == READ) {
fsm_newstate(fi, CTC_STATE_RXERR);
fsm_event(priv->fsm, DEV_EVENT_RXDOWN, dev);
} else {
fsm_newstate(fi, CTC_STATE_TXERR);
fsm_event(priv->fsm, DEV_EVENT_TXDOWN, dev);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* PARAMETER erp current erp_head RETURN VALUES erp new erp_head - pointer to new ERP */ | static struct dasd_ccw_req* dasd_3990_erp_env_data(struct dasd_ccw_req *erp, char *sense) | /* PARAMETER erp current erp_head RETURN VALUES erp new erp_head - pointer to new ERP */
static struct dasd_ccw_req* dasd_3990_erp_env_data(struct dasd_ccw_req *erp, char *sense) | {
struct dasd_device *device = erp->startdev;
erp->function = dasd_3990_erp_env_data;
DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Environmental data present");
dasd_3990_handle_env_data(erp, sense);
if (sense[7] != 0x0F) {
erp = dasd_3990_erp_action_4(erp, sense);
} else {
erp->status = DASD_CQR_FILLED;
}
return erp;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Routine: set_muxconf_regs Description: Setting up the configuration Mux registers specific to the hardware. Many pins need to be moved from protect to primary mode. */ | void set_muxconf_regs(void) | /* Routine: set_muxconf_regs Description: Setting up the configuration Mux registers specific to the hardware. Many pins need to be moved from protect to primary mode. */
void set_muxconf_regs(void) | {
MUX_PANDORA();
if (get_cpu_family() == CPU_OMAP36XX) {
MUX_PANDORA_3730();
}
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* This function wakeup the USB PHY from the Low power mode. */ | void USB_PhyExitFromLowPowerMode(void) | /* This function wakeup the USB PHY from the Low power mode. */
void USB_PhyExitFromLowPowerMode(void) | {
GPIO_InitTypeDef GPIO_InitStruct;
__HAL_RCC_GPIOC_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_SET);
HAL_Delay(4);
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Return TRUE if the Fv has been processed, FALSE if not. */ | BOOLEAN FvHasBeenProcessed(IN EFI_HANDLE FvHandle) | /* Return TRUE if the Fv has been processed, FALSE if not. */
BOOLEAN FvHasBeenProcessed(IN EFI_HANDLE FvHandle) | {
LIST_ENTRY *Link;
KNOWN_HANDLE *KnownHandle;
for (Link = mFvHandleList.ForwardLink; Link != &mFvHandleList; Link = Link->ForwardLink) {
KnownHandle = CR (Link, KNOWN_HANDLE, Link, KNOWN_HANDLE_SIGNATURE);
if (KnownHandle->Handle == FvHandle) {
return TRUE;
}
}
return FALSE;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* param base USDHC peripheral base address. param mask The reset type mask(_usdhc_reset). param timeout Timeout for reset. retval true Reset successfully. retval false Reset failed. */ | bool USDHC_Reset(USDHC_Type *base, uint32_t mask, uint32_t timeout) | /* param base USDHC peripheral base address. param mask The reset type mask(_usdhc_reset). param timeout Timeout for reset. retval true Reset successfully. retval false Reset failed. */
bool USDHC_Reset(USDHC_Type *base, uint32_t mask, uint32_t timeout) | {
base->SYS_CTRL |= (mask & (USDHC_SYS_CTRL_RSTA_MASK | USDHC_SYS_CTRL_RSTC_MASK | USDHC_SYS_CTRL_RSTD_MASK));
while ((base->SYS_CTRL & mask) != 0U)
{
if (timeout == 0U)
{
break;
}
timeout--;
}
return ((!timeout) ? false : true);
} | nanoframework/nf-interpreter | C++ | MIT License | 293 |
/* manual mapping of mixer names if the mixer topology is too complicated and the parsed names are ambiguous, add the entries in usbmixer_maps.c. */ | static int check_mapped_name(struct mixer_build *state, int unitid, int control, char *buf, int buflen) | /* manual mapping of mixer names if the mixer topology is too complicated and the parsed names are ambiguous, add the entries in usbmixer_maps.c. */
static int check_mapped_name(struct mixer_build *state, int unitid, int control, char *buf, int buflen) | {
const struct usbmix_name_map *p;
if (! state->map)
return 0;
for (p = state->map; p->id; p++) {
if (p->id == unitid && p->name &&
(! control || ! p->control || control == p->control)) {
buflen--;
return strlcpy(buf, p->name, buflen);
}
}
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Clears or safeguards the OCREF3 signal on an external event. */ | void TIM_ClearOC3Ref(TIM_TypeDef *TIMx, uint16_t TIM_OCClear) | /* Clears or safeguards the OCREF3 signal on an external event. */
void TIM_ClearOC3Ref(TIM_TypeDef *TIMx, uint16_t TIM_OCClear) | {
uint16_t tmpccmr2 = 0;
assert_param(IS_TIM_LIST3_PERIPH(TIMx));
assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear));
tmpccmr2 = TIMx->CCMR2;
tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC3CE);
tmpccmr2 |= TIM_OCClear;
TIMx->CCMR2 = tmpccmr2;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Function: MX25_RDCR Arguments: ConfigReg, 8 bit buffer to store Configuration register value Description: The RDCR instruction is for reading Configuration Register Bits. Return Message: FlashOperationSuccess */ | ReturnMsg MX25_RDCR(uint8_t *ConfigReg) | /* Function: MX25_RDCR Arguments: ConfigReg, 8 bit buffer to store Configuration register value Description: The RDCR instruction is for reading Configuration Register Bits. Return Message: FlashOperationSuccess */
ReturnMsg MX25_RDCR(uint8_t *ConfigReg) | {
uint8_t gDataBuffer;
CS_Low();
SendByte( FLASH_CMD_RDCR, SIO );
gDataBuffer = GetByte( SIO );
CS_High();
*ConfigReg = gDataBuffer;
return FlashOperationSuccess;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* snd_vx_inb - read a byte from the register @offset: register offset */ | static unsigned char vxp_inb(struct vx_core *chip, int offset) | /* snd_vx_inb - read a byte from the register @offset: register offset */
static unsigned char vxp_inb(struct vx_core *chip, int offset) | {
return inb(vxp_reg_addr(chip, offset));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Deinitializes the EXTI peripheral registers to their default reset values. */ | void EXTI_DeInit(void) | /* Deinitializes the EXTI peripheral registers to their default reset values. */
void EXTI_DeInit(void) | {
EXTI->IMR = 0x0F940000;
EXTI->EMR = 0x00000000;
EXTI->RTSR = 0x00000000;
EXTI->FTSR = 0x00000000;
EXTI->PR = 0x006BFFFF;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Very simple enable function as the chip will allows normal reads during ring buffer operation so as long as it is indeed running before we notify the core, the precise ordering does not matter. */ | static int sca3000_hw_ring_preenable(struct iio_dev *indio_dev) | /* Very simple enable function as the chip will allows normal reads during ring buffer operation so as long as it is indeed running before we notify the core, the precise ordering does not matter. */
static int sca3000_hw_ring_preenable(struct iio_dev *indio_dev) | {
return __sca3000_hw_ring_state_set(indio_dev, 1);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* return a spent inode to the slab cache */ | static void romfs_destroy_inode(struct inode *inode) | /* return a spent inode to the slab cache */
static void romfs_destroy_inode(struct inode *inode) | {
kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* If 8-bit I/O port operations are not supported, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */ | UINT8 EFIAPI IoBitFieldRead8(IN UINTN Port, IN UINTN StartBit, IN UINTN EndBit) | /* If 8-bit I/O port operations are not supported, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
UINT8 EFIAPI IoBitFieldRead8(IN UINTN Port, IN UINTN StartBit, IN UINTN EndBit) | {
return BitFieldRead8 (IoRead8 (Port), StartBit, EndBit);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Reads an unsigned 8 bit value over I2C. */ | err_t lsm303accelRead8(uint8_t addr, uint8_t reg, uint8_t *value) | /* Reads an unsigned 8 bit value over I2C. */
err_t lsm303accelRead8(uint8_t addr, uint8_t reg, uint8_t *value) | {
I2CWriteLength = 2;
I2CReadLength = 0;
I2CMasterBuffer[0] = addr;
I2CMasterBuffer[1] = reg;
i2cEngine();
I2CWriteLength = 0;
I2CReadLength = 1;
I2CMasterBuffer[0] = addr | 0x01;
ASSERT_I2C_STATUS(i2cEngine());
*value = I2CSlaveBuffer[0];
return ERROR_NONE;
} | microbuilder/LPC11U_LPC13U_CodeBase | C++ | Other | 54 |
/* Return with head node of the linked list */ | void* lv_ll_get_head(const lv_ll_t *ll_p) | /* Return with head node of the linked list */
void* lv_ll_get_head(const lv_ll_t *ll_p) | {
void * head = NULL;
if(ll_p != NULL) {
head = ll_p->head;
}
return head;
} | RavenSystem/esp-homekit-devices | C++ | Other | 2,577 |
/* Check the availability of adafruit 1.8" TFT shield on top of STM32NUCLEO board. This is done by reading the state of IO PF.03 pin (mapped to JoyStick available on adafruit 1.8" TFT shield). If the state of PF.03
is high then the adafruit 1.8" TFT shield is available. */ | static ShieldStatus TFT_ShieldDetect(void) | /* Check the availability of adafruit 1.8" TFT shield on top of STM32NUCLEO board. This is done by reading the state of IO PF.03 pin (mapped to JoyStick available on adafruit 1.8" TFT shield). If the state of PF.03
is high then the adafruit 1.8" TFT shield is available. */
static ShieldStatus TFT_ShieldDetect(void) | {
GPIO_InitTypeDef GPIO_InitStruct;
NUCLEO_ADCx_GPIO_CLK_ENABLE();
GPIO_InitStruct.Pin = NUCLEO_ADCx_GPIO_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
HAL_GPIO_Init(NUCLEO_ADCx_GPIO_PORT , &GPIO_InitStruct);
if(HAL_GPIO_ReadPin(NUCLEO_ADCx_GPIO_PORT , NUCLEO_ADCx_GPIO_PIN) != 0)
{
return SHIELD_DETECTED;
}
else
{
return SHIELD_NOT_DETECTED;
}
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* nilfs_btnode_delete() invalidates the specified buffer and delete the page including the buffer if the page gets unbusy. */ | void nilfs_btnode_delete(struct buffer_head *bh) | /* nilfs_btnode_delete() invalidates the specified buffer and delete the page including the buffer if the page gets unbusy. */
void nilfs_btnode_delete(struct buffer_head *bh) | {
struct address_space *mapping;
struct page *page = bh->b_page;
pgoff_t index = page_index(page);
int still_dirty;
page_cache_get(page);
lock_page(page);
wait_on_page_writeback(page);
nilfs_forget_buffer(bh);
still_dirty = PageDirty(page);
mapping = page->mapping;
unlock_page(page);
page_cache_release(page);
if (!still_dirty && mapping)
invalidate_inode_pages2_range(mapping, index, index);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* set the line format on the internal serial adapter using the undocumented parameter setting command */ | static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag) | /* set the line format on the internal serial adapter using the undocumented parameter setting command */
static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag) | {
u16 val = 0;
if (cflag & PARENB)
val |= (cflag & PARODD) ? 0x10 : 0x20;
switch (cflag & CSIZE) {
case CS5:
val |= 5 << 8; break;
case CS6:
val |= 6 << 8; break;
case CS7:
val |= 7 << 8; break;
case CS8:
val |= 8 << 8; break;
default:
dev_err(cs->dev, "CSIZE was not CS5-CS8, using default of 8\n");
val |= 8 << 8;
break;
}
if (cflag & CSTOPB) {
if ((cflag & CSIZE) == CS5)
val |= 1;
else
val |= 2;
}
return set_value(cs, 3, val);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* ADC MSP De-Initialization This function freeze the hardware resources used in this example. */ | void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc) | /* ADC MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc) | {
if(hadc->Instance==ADC1)
{
HAL_RCC_ADC_CLK_ENABLED--;
if(HAL_RCC_ADC_CLK_ENABLED==0){
__HAL_RCC_ADC_CLK_DISABLE();
}
HAL_GPIO_DeInit(VBUS_SENSE_GPIO_Port, VBUS_SENSE_Pin);
HAL_GPIO_DeInit(GPIOF, GPIO_PIN_11);
}
else if(hadc->Instance==ADC2)
{
HAL_RCC_ADC_CLK_ENABLED--;
if(HAL_RCC_ADC_CLK_ENABLED==0){
__HAL_RCC_ADC_CLK_DISABLE();
}
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3);
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_6);
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_1);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Multiply two Big Numbers modulo BnM. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */ | BOOLEAN EFIAPI CryptoServiceBigNumMulMod(IN CONST VOID *BnA, IN CONST VOID *BnB, IN CONST VOID *BnM, OUT VOID *BnRes) | /* Multiply two Big Numbers modulo BnM. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */
BOOLEAN EFIAPI CryptoServiceBigNumMulMod(IN CONST VOID *BnA, IN CONST VOID *BnB, IN CONST VOID *BnM, OUT VOID *BnRes) | {
return CALL_BASECRYPTLIB (Bn.Services.MulMod, BigNumMulMod, (BnA, BnB, BnM, BnRes), FALSE);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function is usually called in the thermal zone device .unbind callback. */ | int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, int trip, struct thermal_cooling_device *cdev) | /* This function is usually called in the thermal zone device .unbind callback. */
int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, int trip, struct thermal_cooling_device *cdev) | {
struct thermal_cooling_device_instance *pos, *next;
mutex_lock(&tz->lock);
list_for_each_entry_safe(pos, next, &tz->cooling_devices, node) {
if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) {
list_del(&pos->node);
mutex_unlock(&tz->lock);
goto unbind;
}
}
mutex_unlock(&tz->lock);
return -ENODEV;
unbind:
device_remove_file(&tz->device, &pos->attr);
sysfs_remove_link(&tz->device.kobj, pos->name);
release_idr(&tz->idr, &tz->lock, pos->id);
kfree(pos);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* mpt_inactive_raid_list_free - This clears this link list. @ioc : pointer to per adapter structure */ | static void mpt_inactive_raid_list_free(MPT_ADAPTER *ioc) | /* mpt_inactive_raid_list_free - This clears this link list. @ioc : pointer to per adapter structure */
static void mpt_inactive_raid_list_free(MPT_ADAPTER *ioc) | {
struct inactive_raid_component_info *component_info, *pNext;
if (list_empty(&ioc->raid_data.inactive_list))
return;
mutex_lock(&ioc->raid_data.inactive_list_mutex);
list_for_each_entry_safe(component_info, pNext,
&ioc->raid_data.inactive_list, list) {
list_del(&component_info->list);
kfree(component_info);
}
mutex_unlock(&ioc->raid_data.inactive_list_mutex);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* UART Set Parity.
The parity bit can be selected as none, even or odd. */ | void uart_set_parity(uint32_t uart, uint8_t parity) | /* UART Set Parity.
The parity bit can be selected as none, even or odd. */
void uart_set_parity(uint32_t uart, uint8_t parity) | {
uint8_t reg8;
reg8 = UART_C1(uart);
reg8 = (reg8 & ~UART_PARITY_MASK) | parity;
UART_C1(uart) = reg8;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Check whether an operation is valid according to the requirement of current operation, which must make sure that the measure image operation is the last one. */ | BOOLEAN CheckAuthenticationOperation(IN UINT32 CurrentAuthOperation, IN UINT32 CheckAuthOperation) | /* Check whether an operation is valid according to the requirement of current operation, which must make sure that the measure image operation is the last one. */
BOOLEAN CheckAuthenticationOperation(IN UINT32 CurrentAuthOperation, IN UINT32 CheckAuthOperation) | {
ASSERT ((CheckAuthOperation & ~(EFI_AUTH_IMAGE_OPERATION_MASK | EFI_AUTH_OPERATION_AUTHENTICATION_STATE | EFI_AUTH_OPERATION_IMAGE_REQUIRED)) == 0);
if ((CurrentAuthOperation & EFI_AUTH_OPERATION_MEASURE_IMAGE) == EFI_AUTH_OPERATION_MEASURE_IMAGE) {
if (((CheckAuthOperation & EFI_AUTH_OPERATION_MEASURE_IMAGE) == EFI_AUTH_OPERATION_MEASURE_IMAGE) ||
((CheckAuthOperation & EFI_AUTH_IMAGE_OPERATION_MASK) == EFI_AUTH_OPERATION_NONE))
{
return TRUE;
} else {
return FALSE;
}
}
return TRUE;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Returns the last conversion result data for regular channel of SDADC1 and SDADC3. RSYNC bit of the SDADC3 should be already set. */ | uint32_t SDADC_GetConversionSDADC13Value(void) | /* Returns the last conversion result data for regular channel of SDADC1 and SDADC3. RSYNC bit of the SDADC3 should be already set. */
uint32_t SDADC_GetConversionSDADC13Value(void) | {
return (uint32_t) SDADC1->RDATA13R;
} | avem-labs/Avem | C++ | MIT License | 1,752 |
/* zfcp_fc_ns_gid_pn_request - initiate GID_PN nameserver request @port: port where GID_PN request is needed return: -ENOMEM on error, 0 otherwise */ | static int zfcp_fc_ns_gid_pn(struct zfcp_port *port) | /* zfcp_fc_ns_gid_pn_request - initiate GID_PN nameserver request @port: port where GID_PN request is needed return: -ENOMEM on error, 0 otherwise */
static int zfcp_fc_ns_gid_pn(struct zfcp_port *port) | {
int ret;
struct zfcp_fc_gid_pn *gid_pn;
struct zfcp_adapter *adapter = port->adapter;
gid_pn = mempool_alloc(adapter->pool.gid_pn, GFP_ATOMIC);
if (!gid_pn)
return -ENOMEM;
memset(gid_pn, 0, sizeof(*gid_pn));
ret = zfcp_fc_wka_port_get(&adapter->gs->ds);
if (ret)
goto out;
ret = zfcp_fc_ns_gid_pn_request(port, gid_pn);
zfcp_fc_wka_port_put(&adapter->gs->ds);
out:
mempool_free(gid_pn, adapter->pool.gid_pn);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled). */ | void IWDG_Enable(void) | /* Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled). */
void IWDG_Enable(void) | {
IWDG->KR = KR_KEY_ENABLE;
} | MaJerle/stm32f429 | C++ | null | 2,036 |
/* qm_read_drop_stat This function is used to read the drop statistics from the TMU hw drop counter. Since the hw counter is always cleared afer reading, this function maintains the previous drop count, and adds the new value to it. That value can be retrieved by passing a pointer to it with the total_drops arg. */ | u32 qm_read_drop_stat(u32 tmu, u32 queue, u32 *total_drops, int do_reset) | /* qm_read_drop_stat This function is used to read the drop statistics from the TMU hw drop counter. Since the hw counter is always cleared afer reading, this function maintains the previous drop count, and adds the new value to it. That value can be retrieved by passing a pointer to it with the total_drops arg. */
u32 qm_read_drop_stat(u32 tmu, u32 queue, u32 *total_drops, int do_reset) | {
static u32 qtotal[TMU_MAX_ID + 1][NUM_QUEUES];
u32 val;
writel((tmu << 8) | queue, TMU_TEQ_CTRL);
writel((tmu << 8) | queue, TMU_LLM_CTRL);
val = readl(TMU_TEQ_DROP_STAT);
qtotal[tmu][queue] += val;
if (total_drops)
*total_drops = qtotal[tmu][queue];
if (do_reset)
qtotal[tmu][queue] = 0;
return val;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* USBD_CtlReceiveStatus receive zero lzngth packet on the ctl pipe. */ | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev) | /* USBD_CtlReceiveStatus receive zero lzngth packet on the ctl pipe. */
USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev) | {
pdev->ep0_state = USBD_EP0_STATUS_OUT;
(void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
return USBD_OK;
} | ua1arn/hftrx | C++ | null | 69 |
/* Validate the behavior of cooperative thread when it yields.
Create 3 threads of priority -2, -1 and 0. Yield the main thread which is cooperative. Check if all the threads gets executed. */ | ZTEST(threads_scheduling, test_yield_cooperative) | /* Validate the behavior of cooperative thread when it yields.
Create 3 threads of priority -2, -1 and 0. Yield the main thread which is cooperative. Check if all the threads gets executed. */
ZTEST(threads_scheduling, test_yield_cooperative) | {
init_prio = -1;
setup_threads();
spawn_threads(0);
k_yield();
zassert_true(tdata[0].executed == 1);
zassert_true(tdata[1].executed == 1);
for (int i = 2; i < THREADS_NUM; i++) {
zassert_true(tdata[i].executed == 0);
}
teardown_threads();
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Erase all the Serial NOR devices connected on FlexSPI. */ | status_t FLEXSPI_NorFlash_EraseAll(uint32_t instance, flexspi_nor_config_t *config) | /* Erase all the Serial NOR devices connected on FlexSPI. */
status_t FLEXSPI_NorFlash_EraseAll(uint32_t instance, flexspi_nor_config_t *config) | {
assert(BOOTLOADER_API_TREE_POINTER);
return BOOTLOADER_API_TREE_POINTER->flexspiNorDriver->erase_all(instance, config);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* mxmlEntityAddCallback() - Add a callback to convert entities to Unicode. mxmlEntityGetName() - Get the name that corresponds to the character value. mxmlEntityGetValue() - Get the character corresponding to a named entity. mxmlEntityRemoveCallback() - Remove a callback. _mxml_entity_cb() - Lookup standard (X)HTML entities. Include necessary headers... 'mxmlEntityAddCallback()' - Add a callback to convert entities to Unicode. */ | int mxmlEntityAddCallback(mxml_entity_cb_t cb) | /* mxmlEntityAddCallback() - Add a callback to convert entities to Unicode. mxmlEntityGetName() - Get the name that corresponds to the character value. mxmlEntityGetValue() - Get the character corresponding to a named entity. mxmlEntityRemoveCallback() - Remove a callback. _mxml_entity_cb() - Lookup standard (X)HTML entities. Include necessary headers... 'mxmlEntityAddCallback()' - Add a callback to convert entities to Unicode. */
int mxmlEntityAddCallback(mxml_entity_cb_t cb) | {
_mxml_global_t *global = _mxml_global();
if (global->num_entity_cbs < (int)(sizeof(global->entity_cbs) / sizeof(global->entity_cbs[0])))
{
global->entity_cbs[global->num_entity_cbs] = cb;
global->num_entity_cbs ++;
return (0);
}
else
{
mxml_error("Unable to add entity callback!");
return (-1);
}
} | DC-SWAT/DreamShell | C++ | null | 404 |
/* set the number of remaining data to be transferred by the DMA */ | void dma_transfer_number_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_t number) | /* set the number of remaining data to be transferred by the DMA */
void dma_transfer_number_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_t number) | {
DMA_CHCNT(dma_periph, channelx) = number;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* We use the auto-increment feature of the CS4270 to read all registers in one shot. */ | static int cs4270_fill_cache(struct snd_soc_codec *codec) | /* We use the auto-increment feature of the CS4270 to read all registers in one shot. */
static int cs4270_fill_cache(struct snd_soc_codec *codec) | {
u8 *cache = codec->reg_cache;
struct i2c_client *i2c_client = codec->control_data;
s32 length;
length = i2c_smbus_read_i2c_block_data(i2c_client,
CS4270_FIRSTREG | CS4270_I2C_INCR, CS4270_NUMREGS, cache);
if (length != CS4270_NUMREGS) {
dev_err(codec->dev, "i2c read failure, addr=0x%x\n",
i2c_client->addr);
return -EIO;
}
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* 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(LED4);
while (1)
{
}
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* This is quite picky. Not only does the CPU have to advertise the "est" flag in the cpuid capability flags, we look for a specific CPU model and stepping, and we need to have the exact model name in our voltage tables. That is, be paranoid about not releasing someone's valuable magic smoke. */ | static int __init centrino_init(void) | /* This is quite picky. Not only does the CPU have to advertise the "est" flag in the cpuid capability flags, we look for a specific CPU model and stepping, and we need to have the exact model name in our voltage tables. That is, be paranoid about not releasing someone's valuable magic smoke. */
static int __init centrino_init(void) | {
struct cpuinfo_x86 *cpu = &cpu_data(0);
if (!cpu_has(cpu, X86_FEATURE_EST))
return -ENODEV;
return cpufreq_register_driver(¢rino_driver);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Compute the number of bytes required to write a package length. */ | UINT8 EFIAPI AmlComputePkgLengthWidth(IN UINT32 Length) | /* Compute the number of bytes required to write a package length. */
UINT8 EFIAPI AmlComputePkgLengthWidth(IN UINT32 Length) | {
if (Length >= (1 << 28)) {
ASSERT (0);
return 0;
} else if (Length >= (1 << 20)) {
return 4;
} else if (Length >= (1 << 12)) {
return 3;
} else if (Length >= (1 << 6)) {
return 2;
}
return 1;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Copy block pointers from one btree block to another. */ | STATIC void xfs_btree_copy_ptrs(struct xfs_btree_cur *cur, union xfs_btree_ptr *dst_ptr, union xfs_btree_ptr *src_ptr, int numptrs) | /* Copy block pointers from one btree block to another. */
STATIC void xfs_btree_copy_ptrs(struct xfs_btree_cur *cur, union xfs_btree_ptr *dst_ptr, union xfs_btree_ptr *src_ptr, int numptrs) | {
ASSERT(numptrs >= 0);
memcpy(dst_ptr, src_ptr, numptrs * xfs_btree_ptr_len(cur));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This service is a proxy for commands to the TPM. */ | EFI_STATUS EFIAPI TcgDxePassThroughToTpm(IN EFI_TCG_PROTOCOL *This, IN UINT32 TpmInputParameterBlockSize, IN UINT8 *TpmInputParameterBlock, IN UINT32 TpmOutputParameterBlockSize, IN UINT8 *TpmOutputParameterBlock) | /* This service is a proxy for commands to the TPM. */
EFI_STATUS EFIAPI TcgDxePassThroughToTpm(IN EFI_TCG_PROTOCOL *This, IN UINT32 TpmInputParameterBlockSize, IN UINT8 *TpmInputParameterBlock, IN UINT32 TpmOutputParameterBlockSize, IN UINT8 *TpmOutputParameterBlock) | {
if ((TpmInputParameterBlock == NULL) ||
(TpmOutputParameterBlock == NULL) ||
(TpmInputParameterBlockSize == 0) ||
(TpmOutputParameterBlockSize == 0))
{
return EFI_INVALID_PARAMETER;
}
return Tpm12SubmitCommand (
TpmInputParameterBlockSize,
TpmInputParameterBlock,
&TpmOutputParameterBlockSize,
TpmOutputParameterBlock
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Sets the mount operation to use an anonymous user if @anonymous is TRUE. */ | void g_mount_operation_set_anonymous(GMountOperation *op, gboolean anonymous) | /* Sets the mount operation to use an anonymous user if @anonymous is TRUE. */
void g_mount_operation_set_anonymous(GMountOperation *op, gboolean anonymous) | {
GMountOperationPrivate *priv;
g_return_if_fail (G_IS_MOUNT_OPERATION (op));
priv = op->priv;
if (priv->anonymous != anonymous)
{
priv->anonymous = anonymous;
g_object_notify (G_OBJECT (op), "anonymous");
}
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* If we're ending a destination (that is, the destination is changing), call ecEndGroupAction. Always restore relevant info from the top of the SAVE list. */ | int ecPopRtfState(RTF_Context *ctx) | /* If we're ending a destination (that is, the destination is changing), call ecEndGroupAction. Always restore relevant info from the top of the SAVE list. */
int ecPopRtfState(RTF_Context *ctx) | {
SAVE *psaveOld;
int ec;
if (!ctx->psave)
return ecStackUnderflow;
if (ctx->rds != ctx->psave->rds)
{
if ((ec = ecEndGroupAction(ctx, ctx->rds)) != ecOK)
return ec;
}
ctx->chp = ctx->psave->chp;
ctx->pap = ctx->psave->pap;
ctx->sep = ctx->psave->sep;
ctx->dop = ctx->psave->dop;
ctx->rds = ctx->psave->rds;
ctx->ris = ctx->psave->ris;
psaveOld = ctx->psave;
ctx->psave = ctx->psave->pNext;
ctx->cGroup--;
free(psaveOld);
return ecOK;
} | DC-SWAT/DreamShell | C++ | null | 404 |
/* Returns: The line termination string. This value is owned by GLib and must not be freed. */ | const gchar* g_io_channel_get_line_term(GIOChannel *channel, gint *length) | /* Returns: The line termination string. This value is owned by GLib and must not be freed. */
const gchar* g_io_channel_get_line_term(GIOChannel *channel, gint *length) | {
g_return_val_if_fail (channel != NULL, NULL);
if (length)
*length = channel->line_term_len;
return channel->line_term;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This function extracts p/f bit of input PDU. at first examines type of PDU and then extracts p/f bit. Returns the p/f bit. */ | static u8 llc_pdu_get_pf_bit(struct llc_pdu_sn *pdu) | /* This function extracts p/f bit of input PDU. at first examines type of PDU and then extracts p/f bit. Returns the p/f bit. */
static u8 llc_pdu_get_pf_bit(struct llc_pdu_sn *pdu) | {
u8 pdu_type;
u8 pf_bit = 0;
if (pdu->ctrl_1 & 1) {
if ((pdu->ctrl_1 & LLC_PDU_TYPE_U) == LLC_PDU_TYPE_U)
pdu_type = LLC_PDU_TYPE_U;
else
pdu_type = LLC_PDU_TYPE_S;
} else
pdu_type = LLC_PDU_TYPE_I;
switch (pdu_type) {
case LLC_PDU_TYPE_I:
case LLC_PDU_TYPE_S:
pf_bit = pdu->ctrl_2 & LLC_S_PF_BIT_MASK;
break;
case LLC_PDU_TYPE_U:
pf_bit = (pdu->ctrl_1 & LLC_U_PF_BIT_MASK) >> 4;
break;
}
return pf_bit;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Brief This function enables the interruption HSE ready, and start the HSE as external clock. */ | void StartHSE(void) | /* Brief This function enables the interruption HSE ready, and start the HSE as external clock. */
void StartHSE(void) | {
NVIC_EnableIRQ(RCC_IRQn);
NVIC_SetPriority(RCC_IRQn,0);
LL_RCC_EnableIT_HSERDY();
LL_RCC_HSE_EnableCSS();
LL_RCC_HSE_EnableBypass();
LL_RCC_HSE_Enable();
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Unregister the DDC bus for this connector then free the driver private structure. */ | static void intel_lvds_destroy(struct drm_connector *connector) | /* Unregister the DDC bus for this connector then free the driver private structure. */
static void intel_lvds_destroy(struct drm_connector *connector) | {
struct drm_device *dev = connector->dev;
struct intel_output *intel_output = to_intel_output(connector);
struct drm_i915_private *dev_priv = dev->dev_private;
if (intel_output->ddc_bus)
intel_i2c_destroy(intel_output->ddc_bus);
if (dev_priv->lid_notifier.notifier_call)
acpi_lid_notifier_unregister(&dev_priv->lid_notifier);
drm_sysfs_connector_remove(connector);
drm_connector_cleanup(connector);
kfree(connector);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Allocate the specified number of contiguous uncached pages on the the requested node. If not enough contiguous uncached pages are available on the requested node, roundrobin starting with the next higher node. */ | unsigned long uncached_alloc_page(int starting_nid, int n_pages) | /* Allocate the specified number of contiguous uncached pages on the the requested node. If not enough contiguous uncached pages are available on the requested node, roundrobin starting with the next higher node. */
unsigned long uncached_alloc_page(int starting_nid, int n_pages) | {
unsigned long uc_addr;
struct uncached_pool *uc_pool;
int nid;
if (unlikely(starting_nid >= MAX_NUMNODES))
return 0;
if (starting_nid < 0)
starting_nid = numa_node_id();
nid = starting_nid;
do {
if (!node_state(nid, N_HIGH_MEMORY))
continue;
uc_pool = &uncached_pools[nid];
if (uc_pool->pool == NULL)
continue;
do {
uc_addr = gen_pool_alloc(uc_pool->pool,
n_pages * PAGE_SIZE);
if (uc_addr != 0)
return uc_addr;
} while (uncached_add_chunk(uc_pool, nid) == 0);
} while ((nid = (nid + 1) % MAX_NUMNODES) != starting_nid);
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Initializes the critical section module. Should be called before the Enter/Exit functions are used. It is okay to call this initialization multiple times from different modules. */ | void UtilCriticalSectionInit(void) | /* Initializes the critical section module. Should be called before the Enter/Exit functions are used. It is okay to call this initialization multiple times from different modules. */
void UtilCriticalSectionInit(void) | {
if (!criticalSectionInitialized)
{
InitializeCriticalSection((CRITICAL_SECTION *)&criticalSection);
criticalSectionInitialized = true;
}
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Returns true if all multiport slot states appear valid. */ | static int slots_valid(struct grip_mp *grip) | /* Returns true if all multiport slot states appear valid. */
static int slots_valid(struct grip_mp *grip) | {
int flags, slot, invalid = 0, active = 0;
flags = get_and_decode_packet(grip, 0);
if (!(flags & IO_GOT_PACKET))
return 0;
for (slot = 0; slot < 4; slot++) {
if (grip->port[slot]->mode == GRIP_MODE_RESET)
invalid = 1;
if (grip->port[slot]->mode != GRIP_MODE_NONE)
active = 1;
}
if (!active)
return (flags & IO_DONE) ? 1 : 0;
return invalid ? 0 : 1;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Sets the direction and mode of the specified pin.
where */ | void GPIODirModeSet(unsigned long ulPort, unsigned long ulBit, unsigned long ulPinIO) | /* Sets the direction and mode of the specified pin.
where */
void GPIODirModeSet(unsigned long ulPort, unsigned long ulBit, unsigned long ulPinIO) | {
xASSERT(GPIOBaseValid(ulPort));
xASSERT((ulPinIO == xGPIO_DIR_MODE_IN) || (ulPinIO == xGPIO_DIR_MODE_OUT) ||
(ulPinIO == xGPIO_DIR_MODE_OD) || (ulPinIO == xGPIO_DIR_MODE_QB));
xHWREG(ulPort + GPIO_PMD) = (xHWREG(ulPort + GPIO_PMD) &
(~(3 << (ulBit * 2))));
xHWREG(ulPort + GPIO_PMD) = (xHWREG(ulPort + GPIO_PMD) |
((ulPinIO & GPIO_PMD_PMD0_M) << (ulBit * 2)));
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Adds a new value to the sma_i_t instances. */ | void sma_i_add(sma_i_t *sma, int32_t x) | /* Adds a new value to the sma_i_t instances. */
void sma_i_add(sma_i_t *sma, int32_t x) | {
int32_t *pSource = sma->buffer + (sma->k % sma->size);
sma->total -= *pSource;
*pSource = x;
sma->total += x;
sma->k++;
if (sma->k < sma->size)
return;
sma->avg = (int32_t)(sma->total >> sma->exponent);
} | microbuilder/LPC11U_LPC13U_CodeBase | C++ | Other | 54 |
/* Device requests a Key Update and sends a new Dynamic Key. The Dynamic Key is updated on the Host. */ | static void gzp_process_key_update(uint8_t *rx_payload) | /* Device requests a Key Update and sends a new Dynamic Key. The Dynamic Key is updated on the Host. */
static void gzp_process_key_update(uint8_t *rx_payload) | {
gzp_crypt_select_key(GZP_KEY_EXCHANGE);
gzp_crypt(&rx_payload[1], &rx_payload[1], GZP_CMD_KEY_UPDATE_PAYLOAD_LENGTH - 1);
if(gzp_validate_id(&rx_payload[GZP_CMD_KEY_UPDATE_VALIDATION_ID]))
{
gzp_crypt_set_dyn_key(&rx_payload[GZP_CMD_KEY_UPDATE_NEW_KEY]);
}
} | labapart/polymcu | C++ | null | 201 |
/* Attaches a new iclog I/O completion callback routine during transaction commit. If the log is in error state, a non-zero return code is handed back and the caller is responsible for executing the callback at an appropriate time. */ | int xfs_log_notify(xfs_mount_t *mp, void *iclog_hndl, xfs_log_callback_t *cb) | /* Attaches a new iclog I/O completion callback routine during transaction commit. If the log is in error state, a non-zero return code is handed back and the caller is responsible for executing the callback at an appropriate time. */
int xfs_log_notify(xfs_mount_t *mp, void *iclog_hndl, xfs_log_callback_t *cb) | {
xlog_in_core_t *iclog = (xlog_in_core_t *)iclog_hndl;
int abortflg;
spin_lock(&iclog->ic_callback_lock);
abortflg = (iclog->ic_state & XLOG_STATE_IOERROR);
if (!abortflg) {
ASSERT_ALWAYS((iclog->ic_state == XLOG_STATE_ACTIVE) ||
(iclog->ic_state == XLOG_STATE_WANT_SYNC));
cb->cb_next = NULL;
*(iclog->ic_callback_tail) = cb;
iclog->ic_callback_tail = &(cb->cb_next);
}
spin_unlock(&iclog->ic_callback_lock);
return abortflg;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* SYSCTRL GPIOC Bus Clock Enable and Reset Release. */ | void LL_SYSCTRL_GPIOC_ClkEnRstRelease(void) | /* SYSCTRL GPIOC Bus Clock Enable and Reset Release. */
void LL_SYSCTRL_GPIOC_ClkEnRstRelease(void) | {
__LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL);
__LL_SYSCTRL_GPIOCBusClk_En(SYSCTRL);
__LL_SYSCTRL_GPIOCSoftRst_Release(SYSCTRL);
__LL_SYSCTRL_Reg_Lock(SYSCTRL);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This callback function is used to set the color registers of a HGA board. Since we have only two fixed colors only @regno is checked. A zero is returned on success and 1 for failure. */ | static int hgafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *info) | /* This callback function is used to set the color registers of a HGA board. Since we have only two fixed colors only @regno is checked. A zero is returned on success and 1 for failure. */
static int hgafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *info) | {
if (regno > 1)
return 1;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Unlock the Flash Program and Erase Controller.
This enables write access to the Flash memory. It is locked by default on reset. */ | void flash_unlock(void) | /* Unlock the Flash Program and Erase Controller.
This enables write access to the Flash memory. It is locked by default on reset. */
void flash_unlock(void) | {
FLASH_CR |= FLASH_CR_LOCK;
FLASH_KEYR = FLASH_KEYR_KEY1;
FLASH_KEYR = FLASH_KEYR_KEY2;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Set the Offset value of a specific channel. */ | static int fdc2x1x_set_offset(const struct device *dev, uint8_t chx, uint16_t offset) | /* Set the Offset value of a specific channel. */
static int fdc2x1x_set_offset(const struct device *dev, uint8_t chx, uint16_t offset) | {
return fdc2x1x_reg_write(dev, FDC2X1X_OFFSET_CH0 + chx, offset);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Gets the states of the CTS modem status signals. */ | unsigned long UARTModemStatusGet(unsigned long ulBase) | /* Gets the states of the CTS modem status signals. */
unsigned long UARTModemStatusGet(unsigned long ulBase) | {
xASSERT((ulBase == UART0_BASE));
return(xHWREG(ulBase + UART_MSR) & (UART_MSR_CTS_ST));
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Must be called single threaded, uses a shared global area. */ | static void initio_read_eeprom(unsigned long base) | /* Must be called single threaded, uses a shared global area. */
static void initio_read_eeprom(unsigned long base) | {
u8 gctrl;
i91unvramp = &i91unvram;
gctrl = inb(base + TUL_GCTRL);
outb(gctrl | TUL_GCTRL_EEPROM_BIT, base + TUL_GCTRL);
if (initio_se2_rd_all(base) != 1) {
initio_se2_update_all(base);
initio_se2_rd_all(base);
}
gctrl = inb(base + TUL_GCTRL);
outb(gctrl & ~TUL_GCTRL_EEPROM_BIT, base + TUL_GCTRL);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Enables/Disable OIS chain DRDY on INT2 pin. This setting has priority over all other INT2 settings.. */ | int32_t lsm6dso_aux_drdy_on_int2_get(lsm6dso_ctx_t *ctx, uint8_t *val) | /* Enables/Disable OIS chain DRDY on INT2 pin. This setting has priority over all other INT2 settings.. */
int32_t lsm6dso_aux_drdy_on_int2_get(lsm6dso_ctx_t *ctx, uint8_t *val) | {
lsm6dso_int_ois_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t*)®, 1);
*val = reg.int2_drdy_ois;
return ret;
} | alexander-g-dean/ESF | C++ | null | 41 |
/* Some defaults have to be set earlier as they may affect earlier training steps. */ | void default_timings(struct mrc_params *mrc_params) | /* Some defaults have to be set earlier as they may affect earlier training steps. */
void default_timings(struct mrc_params *mrc_params) | {
uint8_t ch, rk, bl;
for (ch = 0; ch < NUM_CHANNELS; ch++) {
for (rk = 0; rk < NUM_RANKS; rk++) {
for (bl = 0; bl < NUM_BYTE_LANES; bl++) {
set_rdqs(ch, rk, bl, 24);
if (rk == 0) {
set_vref(ch, bl, 32);
}
}
}
}
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* return whether CAU peripheral is enabled or disabled */ | ControlStatus cau_enable_state_get(void) | /* return whether CAU peripheral is enabled or disabled */
ControlStatus cau_enable_state_get(void) | {
ControlStatus ret = DISABLE;
if(RESET != (CAU_CTL & CAU_CTL_CAUEN)){
ret = ENABLE;
}
return ret;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Check sanity of parameter control fields and if a path is present check that it is terminated and contains at least one "/". */ | static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param) | /* Check sanity of parameter control fields and if a path is present check that it is terminated and contains at least one "/". */
static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param) | {
int err;
err = check_dev_ioctl_version(cmd, param);
if (err) {
AUTOFS_WARN("invalid device control module version "
"supplied for cmd(0x%08x)", cmd);
goto out;
}
if (param->size > sizeof(*param)) {
err = invalid_str(param->path, param->size - sizeof(*param));
if (err) {
AUTOFS_WARN(
"path string terminator missing for cmd(0x%08x)",
cmd);
goto out;
}
err = check_name(param->path);
if (err) {
AUTOFS_WARN("invalid path supplied for cmd(0x%08x)",
cmd);
goto out;
}
}
err = 0;
out:
return err;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* set_seen - mark a PEB as seen. @ubi: UBI device description object @pnum: The PEB to be makred as seen @seen: integer array of @ubi->peb_count size */ | static void set_seen(struct ubi_device *ubi, int pnum, int *seen) | /* set_seen - mark a PEB as seen. @ubi: UBI device description object @pnum: The PEB to be makred as seen @seen: integer array of @ubi->peb_count size */
static void set_seen(struct ubi_device *ubi, int pnum, int *seen) | {
if (!ubi_dbg_chk_fastmap(ubi) || !seen)
return;
seen[pnum] = 1;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Returns CR_OK upon successfull completion, an error code otherwise. */ | enum CRStatus cr_statement_at_font_face_rule_get_decls(CRStatement *a_this, CRDeclaration **a_decls) | /* Returns CR_OK upon successfull completion, an error code otherwise. */
enum CRStatus cr_statement_at_font_face_rule_get_decls(CRStatement *a_this, CRDeclaration **a_decls) | {
g_return_val_if_fail (a_this
&& a_this->type == AT_FONT_FACE_RULE_STMT
&& a_this->kind.font_face_rule,
CR_BAD_PARAM_ERROR);
*a_decls = a_this->kind.font_face_rule->decl_list;
return CR_OK;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Free the route cache entry. It is reference counted. */ | VOID Ip6FreeRouteCacheEntry(IN OUT IP6_ROUTE_CACHE_ENTRY *RtCacheEntry) | /* Free the route cache entry. It is reference counted. */
VOID Ip6FreeRouteCacheEntry(IN OUT IP6_ROUTE_CACHE_ENTRY *RtCacheEntry) | {
ASSERT (RtCacheEntry->RefCnt > 0);
if (--RtCacheEntry->RefCnt == 0) {
FreePool (RtCacheEntry);
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Called during initialisation to register each path with an optional repeat_count. */ | static int rr_add_path(struct path_selector *ps, struct dm_path *path, int argc, char **argv, char **error) | /* Called during initialisation to register each path with an optional repeat_count. */
static int rr_add_path(struct path_selector *ps, struct dm_path *path, int argc, char **argv, char **error) | {
struct selector *s = (struct selector *) ps->context;
struct path_info *pi;
unsigned repeat_count = RR_MIN_IO;
if (argc > 1) {
*error = "round-robin ps: incorrect number of arguments";
return -EINVAL;
}
if ((argc == 1) && (sscanf(argv[0], "%u", &repeat_count) != 1)) {
*error = "round-robin ps: invalid repeat count";
return -EINVAL;
}
pi = kmalloc(sizeof(*pi), GFP_KERNEL);
if (!pi) {
*error = "round-robin ps: Error allocating path context";
return -ENOMEM;
}
pi->path = path;
pi->repeat_count = repeat_count;
path->pscontext = pi;
list_add_tail(&pi->list, &s->valid_paths);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Read sensor data.
This routine calls the appropriate internal data function to obtain the specified type of data from the sensor device. */ | static bool bma220_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 bma220_read(sensor_t *sensor, sensor_read_t type, sensor_data_t *data) | {
sensor_hal_t *const hal = sensor->hal;
switch (type) {
case SENSOR_READ_ACCELERATION:
return bma220_get_accel(hal, data);
case SENSOR_READ_ID:
return bma220_device_id(hal, data);
default:
sensor->err = SENSOR_ERR_FUNCTION;
return false;
}
} | memfault/zero-to-main | C++ | null | 200 |
/* param tcd A point to the TCD structure. param sourceOffset source address offset. param destOffset destination address offset. */ | void EDMA_TcdSetMajorOffsetConfig(edma_tcd_t *tcd, int32_t sourceOffset, int32_t destOffset) | /* param tcd A point to the TCD structure. param sourceOffset source address offset. param destOffset destination address offset. */
void EDMA_TcdSetMajorOffsetConfig(edma_tcd_t *tcd, int32_t sourceOffset, int32_t destOffset) | {
assert(tcd != NULL);
assert(((uint32_t)tcd & 0x1FU) == 0U);
tcd->SLAST = (uint32_t)sourceOffset;
tcd->DLAST_SGA = (uint32_t)destOffset;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Removes the next completed dtr from work array */ | void vxge_hw_channel_dtr_complete(struct __vxge_hw_channel *channel) | /* Removes the next completed dtr from work array */
void vxge_hw_channel_dtr_complete(struct __vxge_hw_channel *channel) | {
channel->work_arr[channel->compl_index] = NULL;
if (++channel->compl_index == channel->length)
channel->compl_index = 0;
channel->stats->total_compl_cnt++;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function returns the interrupt status read from Interrupt Status Register(IPISR). Use the XADCPS_IPIXR_* constants defined in xadcps_hw.h to interpret the returned value. */ | u32 XAdcPs_IntrGetStatus(XAdcPs *InstancePtr) | /* This function returns the interrupt status read from Interrupt Status Register(IPISR). Use the XADCPS_IPIXR_* constants defined in xadcps_hw.h to interpret the returned value. */
u32 XAdcPs_IntrGetStatus(XAdcPs *InstancePtr) | {
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
return XAdcPs_ReadReg(InstancePtr->Config.BaseAddress,
XADCPS_INT_STS_OFFSET) & XADCPS_INTX_ALL_MASK;
} | ua1arn/hftrx | C++ | null | 69 |
/* Append the version of AirPcap with which we were compiled to a GString. */ | void get_compiled_airpcap_version(GString *str) | /* Append the version of AirPcap with which we were compiled to a GString. */
void get_compiled_airpcap_version(GString *str) | {
g_string_append(str, "with AirPcap");
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Retrieves a parameter entry (including ID, value and privileges) from the parameter table that matches the given parameter ID. */ | static ParameterItem_t* const V2Params_GetParamFromTable(const uint8_t ParamID) | /* Retrieves a parameter entry (including ID, value and privileges) from the parameter table that matches the given parameter ID. */
static ParameterItem_t* const V2Params_GetParamFromTable(const uint8_t ParamID) | {
ParameterItem_t* CurrTableItem = ParameterTable;
for (uint8_t TableIndex = 0; TableIndex < TABLE_PARAM_COUNT; TableIndex++)
{
if (ParamID == CurrTableItem->ParamID)
return CurrTableItem;
CurrTableItem++;
}
return NULL;
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* Sets channel specific user data.
This function associates user data to a specif DMA channel */ | void dmacHw_setChannelUserData(dmacHw_HANDLE_t handle, void *userData) | /* Sets channel specific user data.
This function associates user data to a specif DMA channel */
void dmacHw_setChannelUserData(dmacHw_HANDLE_t handle, void *userData) | {
dmacHw_CBLK_t *pCblk = dmacHw_HANDLE_TO_CBLK(handle);
pCblk->userData = userData;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* param base Pointer to the FLEXIO_SPI_Type structure. param handle Pointer to the flexio_spi_master_handle_t structure to store the transfer state. param callback The callback function. param userData The parameter of the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */ | status_t FLEXIO_SPI_MasterTransferCreateHandle(FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle, flexio_spi_master_transfer_callback_t callback, void *userData) | /* param base Pointer to the FLEXIO_SPI_Type structure. param handle Pointer to the flexio_spi_master_handle_t structure to store the transfer state. param callback The callback function. param userData The parameter of the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */
status_t FLEXIO_SPI_MasterTransferCreateHandle(FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle, flexio_spi_master_transfer_callback_t callback, void *userData) | {
assert(handle != NULL);
IRQn_Type flexio_irqs[] = FLEXIO_IRQS;
(void)memset(handle, 0, sizeof(*handle));
handle->callback = callback;
handle->userData = userData;
NVIC_ClearPendingIRQ(flexio_irqs[FLEXIO_SPI_GetInstance(base)]);
(void)EnableIRQ(flexio_irqs[FLEXIO_SPI_GetInstance(base)]);
return FLEXIO_RegisterHandleIRQ(base, handle, FLEXIO_SPI_MasterTransferHandleIRQ);
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* This function returns %0 on success and a negative error code on failure. */ | int ubifs_write_sb_node(struct ubifs_info *c, struct ubifs_sb_node *sup) | /* This function returns %0 on success and a negative error code on failure. */
int ubifs_write_sb_node(struct ubifs_info *c, struct ubifs_sb_node *sup) | {
int len = ALIGN(UBIFS_SB_NODE_SZ, c->min_io_size);
ubifs_prepare_node(c, sup, UBIFS_SB_NODE_SZ, 1);
return ubifs_leb_change(c, UBIFS_SB_LNUM, sup, len, UBI_LONGTERM);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Reads a message from the receive buffer. If no message is available, the function returns immediately with return code canERR_NOMSG. */ | static canStatus LeafLightLibFuncRead(const CanHandle hnd, int32_t *id, void *msg, uint32_t *dlc, uint32_t *flag, uint32_t *time) | /* Reads a message from the receive buffer. If no message is available, the function returns immediately with return code canERR_NOMSG. */
static canStatus LeafLightLibFuncRead(const CanHandle hnd, int32_t *id, void *msg, uint32_t *dlc, uint32_t *flag, uint32_t *time) | {
canStatus result = canERR_NOTINITIALIZED;
assert(leafLightLibFuncReadPtr != NULL);
assert(leafLightDllHandle != NULL);
if ((leafLightLibFuncReadPtr != NULL) && (leafLightDllHandle != NULL))
{
result = leafLightLibFuncReadPtr(hnd, id, msg, dlc, flag, time);
}
return result;
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Set Serial Clock Baud Rate divider value (SCBR). */ | int16_t spi_set_baudrate_div(Spi *p_spi, uint32_t ul_pcs_ch, uint8_t uc_baudrate_divider) | /* Set Serial Clock Baud Rate divider value (SCBR). */
int16_t spi_set_baudrate_div(Spi *p_spi, uint32_t ul_pcs_ch, uint8_t uc_baudrate_divider) | {
if (!uc_baudrate_divider){
return -1;
}
p_spi->SPI_CSR[ul_pcs_ch] &= (~SPI_CSR_SCBR_Msk);
p_spi->SPI_CSR[ul_pcs_ch] |= SPI_CSR_SCBR(uc_baudrate_divider);
return 0;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Sets the G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET attribute in the file info to the given symlink target. */ | void g_file_info_set_symlink_target(GFileInfo *info, const char *symlink_target) | /* Sets the G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET attribute in the file info to the given symlink target. */
void g_file_info_set_symlink_target(GFileInfo *info, const char *symlink_target) | {
static guint32 attr = 0;
GFileAttributeValue *value;
g_return_if_fail (G_IS_FILE_INFO (info));
g_return_if_fail (symlink_target != NULL);
if (attr == 0)
attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET);
value = g_file_info_create_value (info, attr);
if (value)
_g_file_attribute_value_set_byte_string (value, symlink_target);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Called by hardware driver to remove the registration of a controller with the CAPI subsystem. Return value: 0 on success, error code < 0 on error */ | int detach_capi_ctr(struct capi_ctr *card) | /* Called by hardware driver to remove the registration of a controller with the CAPI subsystem. Return value: 0 on success, error code < 0 on error */
int detach_capi_ctr(struct capi_ctr *card) | {
if (card->cardstate != CARD_DETECTED)
capi_ctr_down(card);
ncards--;
if (card->procent) {
remove_proc_entry(card->procfn, NULL);
card->procent = NULL;
}
capi_cards[card->cnr - 1] = NULL;
printk(KERN_NOTICE "kcapi: Controller [%03d]: %s unregistered\n",
card->cnr, card->name);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Checks whether the specified RTC flag is set or not. */ | FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG) | /* Checks whether the specified RTC flag is set or not. */
FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG) | {
FlagStatus bitstatus = RESET;
uint32_t tmpreg = 0;
assert_param(IS_RTC_GET_FLAG(RTC_FLAG));
tmpreg = (uint32_t)(RTC->ISR & RTC_FLAGS_MASK);
if ((tmpreg & RTC_FLAG) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Clear ECC result and start a new ECC process. */ | void XFMC_RestartNandEcc(XFMC_Bank23_Module *Bank) | /* Clear ECC result and start a new ECC process. */
void XFMC_RestartNandEcc(XFMC_Bank23_Module *Bank) | {
Bank->CTRLx &= ~XFMC_NAND_ECC_ENABLE;
Bank->CTRLx |= XFMC_NAND_ECC_ENABLE;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Clear the specified Signal Flags of an active thread. */ | int32_t svcSignalClear(osThreadId thread_id, int32_t signals) | /* Clear the specified Signal Flags of an active thread. */
int32_t svcSignalClear(osThreadId thread_id, int32_t signals) | {
return (int32_t)0x80000000U;
}
if ((uint32_t)signals & (0xFFFFFFFFU << osFeature_Signals)) {
return (int32_t)0x80000000U;
}
sig = (int32_t)ptcb->events;
rt_evt_clr((uint16_t)signals, ptcb->task_id);
return sig;
} | labapart/polymcu | C++ | null | 201 |
/* Get the current compare value of specified compare.
Retrieves the current value of the specified compare. */ | enum status_code rtc_count_get_compare(struct rtc_module *const module, uint32_t *const comp_value, const enum rtc_count_compare comp_index) | /* Get the current compare value of specified compare.
Retrieves the current value of the specified compare. */
enum status_code rtc_count_get_compare(struct rtc_module *const module, uint32_t *const comp_value, const enum rtc_count_compare comp_index) | {
Assert(module);
Assert(module->hw);
Rtc *const rtc_module = module->hw;
switch (module->mode) {
case RTC_COUNT_MODE_32BIT:
if ((uint32_t)comp_index > RTC_NUM_OF_COMP32) {
return STATUS_ERR_INVALID_ARG;
}
*comp_value = rtc_module->MODE0.COMP[comp_index].reg;
break;
case RTC_COUNT_MODE_16BIT:
if ((uint32_t)comp_index > RTC_NUM_OF_COMP16) {
return STATUS_ERR_INVALID_ARG;
}
*comp_value = (uint32_t)rtc_module->MODE1.COMP[comp_index].reg;
break;
default:
Assert(false);
return STATUS_ERR_BAD_FORMAT;
}
return STATUS_OK;
} | memfault/zero-to-main | C++ | null | 200 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.