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
|
|---|---|---|---|---|---|---|---|
/* This routine is to be registered to the kernel's PCI subsystem. When an Emulex HBA is removed from PCI bus, the driver core invokes this routine. This routine dispatches the action to the proper SLI-3 or SLI-4 device remove routine, which will perform all the necessary cleanup for the device to be removed from the PCI subsystem properly. */
|
static void __devexit lpfc_pci_remove_one(struct pci_dev *pdev)
|
/* This routine is to be registered to the kernel's PCI subsystem. When an Emulex HBA is removed from PCI bus, the driver core invokes this routine. This routine dispatches the action to the proper SLI-3 or SLI-4 device remove routine, which will perform all the necessary cleanup for the device to be removed from the PCI subsystem properly. */
static void __devexit lpfc_pci_remove_one(struct pci_dev *pdev)
|
{
struct Scsi_Host *shost = pci_get_drvdata(pdev);
struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
switch (phba->pci_dev_grp) {
case LPFC_PCI_DEV_LP:
lpfc_pci_remove_one_s3(pdev);
break;
case LPFC_PCI_DEV_OC:
lpfc_pci_remove_one_s4(pdev);
break;
default:
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"1424 Invalid PCI device group: 0x%x\n",
phba->pci_dev_grp);
break;
}
return;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function calculates and returns the number of LEBs which should be kept for index usage. */
|
int ubifs_calc_min_idx_lebs(struct ubifs_info *c)
|
/* This function calculates and returns the number of LEBs which should be kept for index usage. */
int ubifs_calc_min_idx_lebs(struct ubifs_info *c)
|
{
int idx_lebs;
long long idx_size;
idx_size = c->bi.old_idx_sz + c->bi.idx_growth + c->bi.uncommitted_idx;
idx_size += idx_size << 1;
idx_lebs = div_u64(idx_size + c->idx_leb_size - 1, c->idx_leb_size);
idx_lebs += 1;
if (idx_lebs < MIN_INDEX_LEBS)
idx_lebs = MIN_INDEX_LEBS;
return idx_lebs;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* read widget caps for each widget and store in cache */
|
static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
|
/* read widget caps for each widget and store in cache */
static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
|
{
int i;
hda_nid_t nid;
codec->num_nodes = snd_hda_get_sub_nodes(codec, fg_node,
&codec->start_nid);
codec->wcaps = kmalloc(codec->num_nodes * 4, GFP_KERNEL);
if (!codec->wcaps)
return -ENOMEM;
nid = codec->start_nid;
for (i = 0; i < codec->num_nodes; i++, nid++)
codec->wcaps[i] = snd_hda_param_read(codec, nid,
AC_PAR_AUDIO_WIDGET_CAP);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If 8-bit I/O port operations are not supported, then ASSERT(). */
|
UINT8 EFIAPI IoAndThenOr8(IN UINTN Port, IN UINT8 AndData, IN UINT8 OrData)
|
/* If 8-bit I/O port operations are not supported, then ASSERT(). */
UINT8 EFIAPI IoAndThenOr8(IN UINTN Port, IN UINT8 AndData, IN UINT8 OrData)
|
{
return IoWrite8 (Port, (UINT8)((IoRead8 (Port) & AndData) | OrData));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* called by RMT enable CLAIM/BEACON interrupts (only called if these events are of interest, e.g. in DETECT state the interrupt must not be permanently enabled RMT calls this function periodically (timer driven polling) */
|
void sm_mac_check_beacon_claim(struct s_smc *smc)
|
/* called by RMT enable CLAIM/BEACON interrupts (only called if these events are of interest, e.g. in DETECT state the interrupt must not be permanently enabled RMT calls this function periodically (timer driven polling) */
void sm_mac_check_beacon_claim(struct s_smc *smc)
|
{
outpw(FM_A(FM_IMSK2U),~(mac_imsk2u | mac_beacon_imsk2u)) ;
formac_rcv_restart(smc) ;
process_receive(smc) ;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Wake up duration event. 1LSb = 1 / ODR. */
|
int32_t lsm6dso_wkup_dur_get(stmdev_ctx_t *ctx, uint8_t *val)
|
/* Wake up duration event. 1LSb = 1 / ODR. */
int32_t lsm6dso_wkup_dur_get(stmdev_ctx_t *ctx, uint8_t *val)
|
{
lsm6dso_wake_up_dur_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t *)®, 1);
*val = reg.wake_dur;
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Initial Wireless Extension code for Aironet driver by : Jean Tourrilhes */
|
static u8 airo_rssi_to_dbm(tdsRssiEntry *rssi_rid, u8 rssi)
|
/* Initial Wireless Extension code for Aironet driver by : Jean Tourrilhes */
static u8 airo_rssi_to_dbm(tdsRssiEntry *rssi_rid, u8 rssi)
|
{
if (!rssi_rid)
return 0;
return (0x100 - rssi_rid[rssi].rssidBm);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* param base to FLEXIO_UART_Type structure. param handle Pointer to the flexio_uart_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_UART_TransferCreateHandle(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, flexio_uart_transfer_callback_t callback, void *userData)
|
/* param base to FLEXIO_UART_Type structure. param handle Pointer to the flexio_uart_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_UART_TransferCreateHandle(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, flexio_uart_transfer_callback_t callback, void *userData)
|
{
assert(handle);
IRQn_Type flexio_irqs[] = FLEXIO_IRQS;
memset(handle, 0, sizeof(*handle));
handle->rxState = kFLEXIO_UART_RxIdle;
handle->txState = kFLEXIO_UART_TxIdle;
handle->callback = callback;
handle->userData = userData;
EnableIRQ(flexio_irqs[FLEXIO_UART_GetInstance(base)]);
return FLEXIO_RegisterHandleIRQ(base, handle, FLEXIO_UART_TransferHandleIRQ);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Returns a value representing the currently configured low battery detection behavior. The return value will be one of the following: */
|
unsigned long HibernateLowBatGet(void)
|
/* Returns a value representing the currently configured low battery detection behavior. The return value will be one of the following: */
unsigned long HibernateLowBatGet(void)
|
{
return(HWREG(HIB_CTL) & HIBERNATE_LOW_BAT_ABORT);
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* Construct an asymmetric key ID from a pair of binary blobs. */
|
struct asymmetric_key_id* asymmetric_key_generate_id(const void *val_1, size_t len_1, const void *val_2, size_t len_2)
|
/* Construct an asymmetric key ID from a pair of binary blobs. */
struct asymmetric_key_id* asymmetric_key_generate_id(const void *val_1, size_t len_1, const void *val_2, size_t len_2)
|
{
struct asymmetric_key_id *kid;
kid = kmalloc(sizeof(struct asymmetric_key_id) + len_1 + len_2,
GFP_KERNEL);
if (!kid)
return ERR_PTR(-ENOMEM);
kid->len = len_1 + len_2;
memcpy(kid->data, val_1, len_1);
memcpy(kid->data + len_1, val_2, len_2);
return kid;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* displays all the filtering records belonging to all the ports
Note that this function is documented in the main component header file, IxEthDB.h. */
|
IX_ETH_DB_PUBLIC void ixEthDBFilteringDatabaseShowAll()
|
/* displays all the filtering records belonging to all the ports
Note that this function is documented in the main component header file, IxEthDB.h. */
IX_ETH_DB_PUBLIC void ixEthDBFilteringDatabaseShowAll()
|
{
IxEthDBPortId portIndex;
printf("\nEthernet learning/filtering database: listing %d ports\n\n", (UINT32) IX_ETH_DB_NUMBER_OF_PORTS);
for (portIndex = 0 ; portIndex < IX_ETH_DB_NUMBER_OF_PORTS ; portIndex++)
{
ixEthDBFilteringDatabaseShow(portIndex);
if (portIndex < IX_ETH_DB_NUMBER_OF_PORTS - 1)
{
printf("\n");
}
}
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* The skb has to be unshared, we'll end up calling ipxitf_send, that'll modify the packet */
|
int ipxrtr_route_skb(struct sk_buff *skb)
|
/* The skb has to be unshared, we'll end up calling ipxitf_send, that'll modify the packet */
int ipxrtr_route_skb(struct sk_buff *skb)
|
{
struct ipxhdr *ipx = ipx_hdr(skb);
struct ipx_route *r = ipxrtr_lookup(IPX_SKB_CB(skb)->ipx_dest_net);
if (!r) {
kfree_skb(skb);
return 0;
}
ipxitf_hold(r->ir_intrfc);
ipxitf_send(r->ir_intrfc, skb, r->ir_routed ?
r->ir_router_node : ipx->ipx_dest.node);
ipxitf_put(r->ir_intrfc);
ipxrtr_put(r);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Extract the System Firmware image from an authenticated image. */
|
BOOLEAN EFIAPI ExtractSystemFirmwareImage(IN VOID *AuthenticatedImage, IN UINTN AuthenticatedImageSize, OUT VOID **SystemFirmwareImage, OUT UINTN *SystemFirmwareImageSize)
|
/* Extract the System Firmware image from an authenticated image. */
BOOLEAN EFIAPI ExtractSystemFirmwareImage(IN VOID *AuthenticatedImage, IN UINTN AuthenticatedImageSize, OUT VOID **SystemFirmwareImage, OUT UINTN *SystemFirmwareImageSize)
|
{
BOOLEAN Result;
UINT32 FileHeaderSize;
*SystemFirmwareImage = NULL;
*SystemFirmwareImageSize = 0;
Result = GetFfsByName (AuthenticatedImage, AuthenticatedImageSize, &mEdkiiSystemFirmwareFileGuid, EFI_FV_FILETYPE_RAW, SystemFirmwareImage, SystemFirmwareImageSize);
if (!Result) {
*SystemFirmwareImage = AuthenticatedImage;
*SystemFirmwareImageSize = AuthenticatedImageSize;
return TRUE;
}
if (IS_FFS_FILE2 (*SystemFirmwareImage)) {
FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER2);
} else {
FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER);
}
*SystemFirmwareImage = (UINT8 *)*SystemFirmwareImage + FileHeaderSize;
*SystemFirmwareImageSize = *SystemFirmwareImageSize - FileHeaderSize;
return Result;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* The function will fail if the Node is in its parent's fixed argument list. The Node is not deleted. The deletion is done separately from the removal. */
|
EFI_STATUS EFIAPI AmlDetachNode(IN AML_NODE_HEADER *Node)
|
/* The function will fail if the Node is in its parent's fixed argument list. The Node is not deleted. The deletion is done separately from the removal. */
EFI_STATUS EFIAPI AmlDetachNode(IN AML_NODE_HEADER *Node)
|
{
return AmlRemoveNodeFromVarArgList (Node);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function also eliminates unnecessarily updating the file's atime locally, as the NFS server sets the file's atime, and this client must read the updated atime from the server back into its cache. */
|
ssize_t nfs_file_direct_read(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos)
|
/* This function also eliminates unnecessarily updating the file's atime locally, as the NFS server sets the file's atime, and this client must read the updated atime from the server back into its cache. */
ssize_t nfs_file_direct_read(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos)
|
{
ssize_t retval = -EINVAL;
struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping;
size_t count;
count = iov_length(iov, nr_segs);
nfs_add_stats(mapping->host, NFSIOS_DIRECTREADBYTES, count);
dfprintk(FILE, "NFS: direct read(%s/%s, %zd@%Ld)\n",
file->f_path.dentry->d_parent->d_name.name,
file->f_path.dentry->d_name.name,
count, (long long) pos);
retval = 0;
if (!count)
goto out;
retval = nfs_sync_mapping(mapping);
if (retval)
goto out;
retval = nfs_direct_read(iocb, iov, nr_segs, pos);
if (retval > 0)
iocb->ki_pos = pos + retval;
out:
return retval;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Dispatch function for SMM lock box restore all in place. */
|
VOID SmmLockBoxRestoreAllInPlace(IN EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *LockBoxParameterRestoreAllInPlace)
|
/* Dispatch function for SMM lock box restore all in place. */
VOID SmmLockBoxRestoreAllInPlace(IN EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *LockBoxParameterRestoreAllInPlace)
|
{
EFI_STATUS Status;
Status = RestoreAllLockBoxInPlace ();
LockBoxParameterRestoreAllInPlace->Header.ReturnStatus = (UINT64)Status;
return;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* mux the pin to the "B" internal peripheral role. */
|
int at91_set_b_periph(unsigned port, unsigned pin, int use_pullup)
|
/* mux the pin to the "B" internal peripheral role. */
int at91_set_b_periph(unsigned port, unsigned pin, int use_pullup)
|
{
struct at91_port *at91_port = at91_pio_get_port(port);
u32 mask;
if (at91_port && (pin < GPIO_PER_BANK)) {
mask = 1 << pin;
writel(mask, &at91_port->idr);
at91_set_pio_pullup(port, pin, use_pullup);
writel(mask, &at91_port->mux.pio2.bsr);
writel(mask, &at91_port->pdr);
}
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Enables or disables the ADC DMA request after last transfer (Single-ADC mode) */
|
void ADC_DMARequestAfterLastTransferCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
|
/* Enables or disables the ADC DMA request after last transfer (Single-ADC mode) */
void ADC_DMARequestAfterLastTransferCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
|
{
assert_param(IS_ADC_ALL_PERIPH(ADCx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
ADCx->CR2 |= (uint32_t)ADC_CR2_DDS;
}
else
{
ADCx->CR2 &= (uint32_t)(~ADC_CR2_DDS);
}
}
|
MaJerle/stm32f429
|
C++
| null | 2,036
|
/* Writes an unsigned 8 bit values over I2C. */
|
err_t lis3dhWrite8(uint8_t reg, uint8_t value)
|
/* Writes an unsigned 8 bit values over I2C. */
err_t lis3dhWrite8(uint8_t reg, uint8_t value)
|
{
I2CWriteLength = 3;
I2CReadLength = 0;
I2CMasterBuffer[0] = LIS3DH_ADDRESS;
I2CMasterBuffer[1] = reg;
I2CMasterBuffer[2] = (value);
ASSERT_I2C_STATUS(i2cEngine());
return ERROR_NONE;
}
|
microbuilder/LPC11U_LPC13U_CodeBase
|
C++
|
Other
| 54
|
/* Verify checksum over a complete header that includes the checksum field. Return 1 when OK, otherwise 0. */
|
static int main_hdr_checksum_ok(void *hdr)
|
/* Verify checksum over a complete header that includes the checksum field. Return 1 when OK, otherwise 0. */
static int main_hdr_checksum_ok(void *hdr)
|
{
struct main_hdr_v0 *main_hdr = (struct main_hdr_v0 *)hdr;
uint8_t checksum;
checksum = image_checksum8(hdr, kwbimage_header_size(hdr));
checksum -= main_hdr->checksum;
return checksum == main_hdr->checksum;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Free registers used by expressions 'e1' and 'e2' (if any) in proper order. */
|
static void freeexps(FuncState *fs, expdesc *e1, expdesc *e2)
|
/* Free registers used by expressions 'e1' and 'e2' (if any) in proper order. */
static void freeexps(FuncState *fs, expdesc *e1, expdesc *e2)
|
{
freereg(fs, r1);
freereg(fs, r2);
}
else {
freereg(fs, r2);
freereg(fs, r1);
}
}
|
nodemcu/nodemcu-firmware
|
C++
|
MIT License
| 7,566
|
/* This function may only be called from the entry point function of the driver, and only after PcdQ35SmramAtDefaultSmbase has been determined to be TRUE. */
|
VOID SmbaseInstallFirstSmiHandler(VOID)
|
/* This function may only be called from the entry point function of the driver, and only after PcdQ35SmramAtDefaultSmbase has been determined to be TRUE. */
VOID SmbaseInstallFirstSmiHandler(VOID)
|
{
FIRST_SMI_HANDLER_CONTEXT *Context;
CopyMem (
(VOID *)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET),
mFirstSmiHandler,
mFirstSmiHandlerSize
);
Context = (VOID *)(UINTN)SMM_DEFAULT_SMBASE;
Context->ApicIdGate = MAX_UINT64;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Task function for blinking the LED as a fixed timer interval. */
|
void LedBlinkTask(void)
|
/* Task function for blinking the LED as a fixed timer interval. */
void LedBlinkTask(void)
|
{
static blt_bool ledOn = BLT_FALSE;
static blt_int32u nextBlinkEvent = 0;
if (TimerGet() >= nextBlinkEvent)
{
if (ledOn == BLT_FALSE)
{
ledOn = BLT_TRUE;
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET);
}
else
{
ledOn = BLT_FALSE;
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET);
}
nextBlinkEvent = TimerGet() + ledBlinkIntervalMs;
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Generate NEC header value: active 9ms + negative 4.5ms. */
|
static void nec_fill_item_header(rmt_item32_t *item)
|
/* Generate NEC header value: active 9ms + negative 4.5ms. */
static void nec_fill_item_header(rmt_item32_t *item)
|
{
nec_fill_item_level(item, NEC_HEADER_HIGH_US, NEC_HEADER_LOW_US);
}
|
retro-esp32/RetroESP32
|
C++
|
Creative Commons Attribution Share Alike 4.0 International
| 581
|
/* This API enable the external mode configuration.
This API configure the secondary interface. */
|
static int8_t config_sec_if(const struct bmi160_dev *dev)
|
/* This API enable the external mode configuration.
This API configure the secondary interface. */
static int8_t config_sec_if(const struct bmi160_dev *dev)
|
{
int8_t rslt;
uint8_t if_conf = 0;
uint8_t cmd = BMI160_AUX_NORMAL_MODE;
rslt = bmi160_set_regs(BMI160_COMMAND_REG_ADDR, &cmd, 1, dev);
if (rslt == BMI160_OK)
{
dev->delay_ms(1);
rslt = bmi160_get_regs(BMI160_IF_CONF_ADDR, &if_conf, 1, dev);
if_conf |= (uint8_t)(1 << 5);
if (rslt == BMI160_OK)
{
rslt = bmi160_set_regs(BMI160_IF_CONF_ADDR, &if_conf, 1, dev);
}
}
return rslt;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Enable/Disable the detection of a low level on the pin NRST as User Reset */
|
void RSTC_SetUserResetEnable(AT91PS_RSTC rstc, unsigned char enable)
|
/* Enable/Disable the detection of a low level on the pin NRST as User Reset */
void RSTC_SetUserResetEnable(AT91PS_RSTC rstc, unsigned char enable)
|
{
unsigned int rmr = READ_RSTC(rstc, RSTC_RMR) & (~AT91C_RSTC_KEY);
if (enable) {
rmr |= AT91C_RSTC_URSTEN;
}
else {
rmr &= ~AT91C_RSTC_URSTEN;
}
WRITE_RSTC(rstc, RSTC_RMR, rmr | RSTC_KEY_PASSWORD);
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Get a random number and block until it works. Unless you have a clock problem, this should always return "promptly" If you have a clock problem, you will wait here forever! Check device RM for clock requirements (usually fRNGCLK > fHCLK/16 or fRNGCLK > fHCLK/32 */
|
uint32_t rng_get_random_blocking(void)
|
/* Get a random number and block until it works. Unless you have a clock problem, this should always return "promptly" If you have a clock problem, you will wait here forever! Check device RM for clock requirements (usually fRNGCLK > fHCLK/16 or fRNGCLK > fHCLK/32 */
uint32_t rng_get_random_blocking(void)
|
{
uint32_t rv;
bool done;
do {
if (RNG_SR & RNG_SR_SEIS) {
RNG_SR = RNG_SR & ~RNG_SR_SEIS;
for (int i = 12; i != 0; i--) {
rv = RNG_DR;
}
RNG_CR &= ~RNG_CR_RNGEN;
RNG_CR |= RNG_CR_RNGEN;
}
if (RNG_SR & RNG_SR_CEIS) {
RNG_SR = RNG_SR & ~RNG_SR_CEIS;
}
done = rng_get_random(&rv);
} while (!done);
return rv;
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* Generate the PORTx address of the give pin. */
|
static uint16_t _port_addr(gpio_t pin)
|
/* Generate the PORTx address of the give pin. */
static uint16_t _port_addr(gpio_t pin)
|
{
uint8_t port_num = _port_num(pin);
uint16_t port_addr = port_num * GPIO_OFFSET_PIN_PIN;
port_addr += GPIO_BASE_PORT_A;
port_addr += GPIO_OFFSET_PIN_PORT;
if (port_num > PORT_G) {
port_addr += GPIO_OFFSET_PORT_H;
}
return port_addr;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* This function processes and stores DMA config provided by client driver into the runtime state maintained by the SSP controller driver */
|
static int process_dma_info(struct pl022_config_chip *chip_info, struct chip_data *chip)
|
/* This function processes and stores DMA config provided by client driver into the runtime state maintained by the SSP controller driver */
static int process_dma_info(struct pl022_config_chip *chip_info, struct chip_data *chip)
|
{
dev_err(chip_info->dev,
"cannot process DMA info, DMA not implemented!\n");
return -ENOTSUPP;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Get CNTPCT This function returns the value of the 64 bits PL1 Physical Count Register (CNTPCT). return CNTPCT Register value */
|
static rt_uint64_t __get_cntpct(void)
|
/* Get CNTPCT This function returns the value of the 64 bits PL1 Physical Count Register (CNTPCT). return CNTPCT Register value */
static rt_uint64_t __get_cntpct(void)
|
{
rt_uint64_t result;
__get_cp64(15, 0, result, 14);
return result;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* DMA Stream Set the Base Memory Address 1.
Set the address pointer to the memory location for DMA transfers. The DMA stream must normally be disabled before setting this address, however it is possible to change this in double buffer mode when the current target is memory area 0 (see */
|
void dma_set_memory_address_1(uint32_t dma, uint8_t stream, uint32_t address)
|
/* DMA Stream Set the Base Memory Address 1.
Set the address pointer to the memory location for DMA transfers. The DMA stream must normally be disabled before setting this address, however it is possible to change this in double buffer mode when the current target is memory area 0 (see */
void dma_set_memory_address_1(uint32_t dma, uint8_t stream, uint32_t address)
|
{
uint32_t reg32 = DMA_SCR(dma, stream);
if (!(reg32 & DMA_SxCR_EN) ||
(!(reg32 & DMA_SxCR_CT) && (reg32 & DMA_SxCR_DBM))) {
DMA_SM1AR(dma, stream) = (uint32_t *) address;
}
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* param base FlexCAN peripheral base address. param handle FlexCAN handle pointer. param xfer FlexCAN Rx FIFO transfer structure. See the ref flexcan_fifo_transfer_t. retval kStatus_Success - Start Rx FIFO receiving process successfully. retval kStatus_FLEXCAN_RxFifoBusy - Rx FIFO is currently in use. */
|
status_t FLEXCAN_TransferReceiveFifoNonBlocking(CAN_Type *base, flexcan_handle_t *handle, flexcan_fifo_transfer_t *xfer)
|
/* param base FlexCAN peripheral base address. param handle FlexCAN handle pointer. param xfer FlexCAN Rx FIFO transfer structure. See the ref flexcan_fifo_transfer_t. retval kStatus_Success - Start Rx FIFO receiving process successfully. retval kStatus_FLEXCAN_RxFifoBusy - Rx FIFO is currently in use. */
status_t FLEXCAN_TransferReceiveFifoNonBlocking(CAN_Type *base, flexcan_handle_t *handle, flexcan_fifo_transfer_t *xfer)
|
{
assert(NULL != handle);
assert(NULL != xfer);
if ((uint8_t)kFLEXCAN_StateIdle == handle->rxFifoState)
{
handle->rxFifoState = (uint8_t)kFLEXCAN_StateRxFifo;
handle->rxFifoFrameBuf = xfer->frame;
FLEXCAN_EnableMbInterrupts(base, (uint32_t)kFLEXCAN_RxFifoOverflowFlag | (uint32_t)kFLEXCAN_RxFifoWarningFlag |
(uint32_t)kFLEXCAN_RxFifoFrameAvlFlag);
return kStatus_Success;
}
else
{
return kStatus_FLEXCAN_RxFifoBusy;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Disable compare register write completed interrupt (CMPOKIE). @rmtoll IER CMPOKIE LPTIM_DisableIT_CMPOK. */
|
void LPTIM_DisableIT_CMPOK(LPTIM_Module *LPTIMx)
|
/* Disable compare register write completed interrupt (CMPOKIE). @rmtoll IER CMPOKIE LPTIM_DisableIT_CMPOK. */
void LPTIM_DisableIT_CMPOK(LPTIM_Module *LPTIMx)
|
{
CLEAR_BIT(LPTIMx->INTEN, LPTIM_INTEN_CMPUPDIE);
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Return the revision of the Winbond bridge which this function is part of. */
|
static u8 sl82c105_bridge_revision(struct pci_dev *dev)
|
/* Return the revision of the Winbond bridge which this function is part of. */
static u8 sl82c105_bridge_revision(struct pci_dev *dev)
|
{
struct pci_dev *bridge;
bridge = pci_get_bus_and_slot(dev->bus->number,
PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
if (!bridge)
return -1;
if (bridge->vendor != PCI_VENDOR_ID_WINBOND ||
bridge->device != PCI_DEVICE_ID_WINBOND_83C553 ||
bridge->class >> 8 != PCI_CLASS_BRIDGE_ISA) {
pci_dev_put(bridge);
return -1;
}
pci_dev_put(bridge);
return bridge->revision;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Get EP CmdStat pointer Parameters: EPNum: endpoint number */
|
U32* GetEpCmdStatPtr(U32 EPNum)
|
/* Get EP CmdStat pointer Parameters: EPNum: endpoint number */
U32* GetEpCmdStatPtr(U32 EPNum)
|
{
U32 ptr = 0;
if (EPNum & 0x80) {
EPNum &= ~0x80;
ptr = 8;
}
ptr += EP_LIST_BASE + EPNum * 16;
return ((U32 *)ptr);
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* 7.3.2.8 Slice layer without partitioning RBSP syntax slice_layer_without_partitioning_rbsp( ) */
|
static void dissect_h264_slice_layer_without_partitioning_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
|
/* 7.3.2.8 Slice layer without partitioning RBSP syntax slice_layer_without_partitioning_rbsp( ) */
static void dissect_h264_slice_layer_without_partitioning_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
|
{
gint bit_offset;
bit_offset = offset <<3;
bit_offset = dissect_h264_slice_header(tree, tvb, pinfo, bit_offset);
proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, bit_offset>>3, -1);
return;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Enables callback.
Enables the callback function registered by the usart_register_callback. The callback function will be called from the interrupt handler when the conditions for the callback type are met. */
|
void uart_enable_callback(struct uart_module *const module, enum uart_callback callback_type)
|
/* Enables callback.
Enables the callback function registered by the usart_register_callback. The callback function will be called from the interrupt handler when the conditions for the callback type are met. */
void uart_enable_callback(struct uart_module *const module, enum uart_callback callback_type)
|
{
Assert(module);
module->callback_enable_mask |= (1 << callback_type);
if (callback_type == UART_CTS_ACTIVE) {
module->hw->TX_INTERRUPT_MASK.reg |= UART_TX_INTERRUPT_MASK_CTS_ACTIVE_MASK;
}
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Configure the internal voltage reference buffer high impedance mode. */
|
void HAL_SYSCFG_VREFBUF_HighImpedanceConfig(uint32_t Mode)
|
/* Configure the internal voltage reference buffer high impedance mode. */
void HAL_SYSCFG_VREFBUF_HighImpedanceConfig(uint32_t Mode)
|
{
assert_param(IS_SYSCFG_VREFBUF_HIGH_IMPEDANCE(Mode));
MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_HIZ, Mode);
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* Initialize the mPhysMemAddressWidth variable, based on guest RAM size. */
|
VOID AddressWidthInitialization(VOID)
|
/* Initialize the mPhysMemAddressWidth variable, based on guest RAM size. */
VOID AddressWidthInitialization(VOID)
|
{
UINT64 FirstNonAddress;
FirstNonAddress = GetFirstNonAddress ();
mPhysMemAddressWidth = (UINT8)HighBitSet64 (FirstNonAddress);
if ((FirstNonAddress & (FirstNonAddress - 1)) != 0) {
++mPhysMemAddressWidth;
}
if (mPhysMemAddressWidth <= 36) {
mPhysMemAddressWidth = 36;
}
ASSERT (mPhysMemAddressWidth <= 48);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Set direction flag, which controls whether we accept only incoming packets, only outgoing packets, or both. Note that, depending on the platform, some or all direction arguments might not be supported. */
|
int pcap_setdirection(pcap_t *p, pcap_direction_t d)
|
/* Set direction flag, which controls whether we accept only incoming packets, only outgoing packets, or both. Note that, depending on the platform, some or all direction arguments might not be supported. */
int pcap_setdirection(pcap_t *p, pcap_direction_t d)
|
{
if (p->setdirection_op == NULL) {
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"Setting direction is not implemented on this platform");
return (-1);
} else
return (p->setdirection_op(p, d));
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Starts a new thread with priority "prio" that will begin its execution in the function "thread()". The "arg" argument will be passed as an argument to the thread() function. The id of the new thread is returned. Both the id and the priority are system dependent. */
|
sys_thread_t sys_thread_new(void(*thread)(void *arg), void *arg, int prio)
|
/* Starts a new thread with priority "prio" that will begin its execution in the function "thread()". The "arg" argument will be passed as an argument to the thread() function. The id of the new thread is returned. Both the id and the priority are system dependent. */
sys_thread_t sys_thread_new(void(*thread)(void *arg), void *arg, int prio)
|
{
xTaskHandle CreatedTask;
int result;
static int iCall = 0;
if( iCall == 0 )
{
result = xTaskCreate( thread, ( signed char * ) "lwIP", lwipTCP_STACK_SIZE, arg, prio, &CreatedTask );
iCall++;
}
else
{
result = xTaskCreate( thread, ( signed char * ) "WEBSvr", lwipBASIC_SERVER_STACK_SIZE, arg, prio, &CreatedTask );
}
timeoutlist[nextthread++].pid = CreatedTask;
if(result == pdPASS)
{
return CreatedTask;
}
else
{
return NULL;
}
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Skip adding the timer int on secondary nodes, which causes a small but painful rift in the time-space continuum. */
|
static int numaq_multi_timer_check(int apic, int irq)
|
/* Skip adding the timer int on secondary nodes, which causes a small but painful rift in the time-space continuum. */
static int numaq_multi_timer_check(int apic, int irq)
|
{
return apic != 0 && irq == 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This function handles external line 13 interrupt request. */
|
void USER_BUTTON_IRQHANDLER(void)
|
/* This function handles external line 13 interrupt request. */
void USER_BUTTON_IRQHANDLER(void)
|
{
if(LL_EXTI_IsActiveFlag_0_31(USER_BUTTON_EXTI_LINE) != RESET)
{
UserButton_Callback();
LL_EXTI_ClearFlag_0_31(USER_BUTTON_EXTI_LINE);
}
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* ADC Read the End-of-Conversion Flag for Injected Conversion.
This flag is set by hardware at the end of each injected conversion of a channel when a new data is available in the corresponding ADCx_JDRy register. */
|
bool adc_eoc_injected(uint32_t adc)
|
/* ADC Read the End-of-Conversion Flag for Injected Conversion.
This flag is set by hardware at the end of each injected conversion of a channel when a new data is available in the corresponding ADCx_JDRy register. */
bool adc_eoc_injected(uint32_t adc)
|
{
return ADC_ISR(adc) & ADC_ISR_JEOC;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Read the word at offset "off" into the "struct user". We actually access the pt_regs stored on the kernel stack. */
|
static int ptrace_read_user(struct task_struct *tsk, unsigned long off, unsigned long __user *ret)
|
/* Read the word at offset "off" into the "struct user". We actually access the pt_regs stored on the kernel stack. */
static int ptrace_read_user(struct task_struct *tsk, unsigned long off, unsigned long __user *ret)
|
{
unsigned long tmp;
tmp = 0;
if (off == PT_TEXT_ADDR)
tmp = tsk->mm->start_code;
else if (off == PT_DATA_ADDR)
tmp = tsk->mm->start_data;
else if (off == PT_TEXT_END_ADDR)
tmp = tsk->mm->end_code;
else if (off < sizeof(struct pt_regs))
tmp = get_user_reg(tsk, off >> 2);
else
return -EIO;
return put_user(tmp, ret);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Flush any dirty pages for this process, and check for write errors. The return status from this call provides a reliable indication of whether any write errors occurred for this process. */
|
static int nfs_file_fsync(struct file *, struct dentry *dentry, int datasync)
|
/* Flush any dirty pages for this process, and check for write errors. The return status from this call provides a reliable indication of whether any write errors occurred for this process. */
static int nfs_file_fsync(struct file *, struct dentry *dentry, int datasync)
|
{
struct nfs_open_context *ctx = nfs_file_open_context(file);
struct inode *inode = dentry->d_inode;
dprintk("NFS: fsync file(%s/%s) datasync %d\n",
dentry->d_parent->d_name.name, dentry->d_name.name,
datasync);
nfs_inc_stats(inode, NFSIOS_VFSFSYNC);
return nfs_do_fsync(ctx, inode);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Initialize MMC - Get Card ID, Set RCA, Frequency and bus width. */
|
int mmc_init(uint32_t instance, int bus_width)
|
/* Initialize MMC - Get Card ID, Set RCA, Frequency and bus width. */
int mmc_init(uint32_t instance, int bus_width)
|
{
int status = FAIL;
usdhc_printf("Get CID.\n");
if (card_get_cid(instance) == SUCCESS) {
usdhc_printf("Set RCA.\n");
if (mmc_set_rca(instance) == SUCCESS) {
usdhc_printf("Set operating frequency.\n");
host_cfg_clock(instance, OPERATING_FREQ);
usdhc_printf("Enter transfer state.\n");
if (card_enter_trans(instance) == SUCCESS) {
usdhc_printf("Set bus width.\n");
if (mmc_set_bus_width(instance, bus_width) == SUCCESS) {
host_set_bus_width(instance, bus_width);
{
status = SUCCESS;
}
}
}
}
}
return status;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* RTC interrupt handler. Clear the RTC interrupt flag and execute the callback function. */
|
void RTCIntHandler(void)
|
/* RTC interrupt handler. Clear the RTC interrupt flag and execute the callback function. */
void RTCIntHandler(void)
|
{
unsigned long ulEventFlags;
ulEventFlags = (xHWREG(RTC_RIIR) & (RTC_RIIR_TIF | RTC_RIIR_AIF));
xHWREG(RTC_RIIR) = ulEventFlags;
if(g_pfnRTCHandlerCallbacks[0] != 0)
{
g_pfnRTCHandlerCallbacks[0](0, 0, ulEventFlags, 0);
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Evaluates the LPC amplitude spectrum envelope from the line spectrum pairs. */
|
static void eval_lpcenv(TwinContext *tctx, const float *cos_vals, float *lpc)
|
/* Evaluates the LPC amplitude spectrum envelope from the line spectrum pairs. */
static void eval_lpcenv(TwinContext *tctx, const float *cos_vals, float *lpc)
|
{
int i;
const ModeTab *mtab = tctx->mtab;
int size_s = mtab->size / mtab->fmode[FT_SHORT].sub;
for (i = 0; i < size_s/2; i++) {
float cos_i = tctx->cos_tabs[0][i];
lpc[i] = eval_lpc_spectrum(cos_vals, cos_i, mtab->n_lsp);
lpc[size_s-i-1] = eval_lpc_spectrum(cos_vals, -cos_i, mtab->n_lsp);
}
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* During early boot, before section_mem_map is used for an actual mem_map, we use section_mem_map to store the section's NUMA node. This keeps us from having to use another data structure. The node information is cleared just before we store the real mem_map. */
|
static unsigned long sparse_encode_early_nid(int nid)
|
/* During early boot, before section_mem_map is used for an actual mem_map, we use section_mem_map to store the section's NUMA node. This keeps us from having to use another data structure. The node information is cleared just before we store the real mem_map. */
static unsigned long sparse_encode_early_nid(int nid)
|
{
return (nid << SECTION_NID_SHIFT);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Changes the duty cycle of the PWM signal. D = (T/P)*100 where T is the pulse duration and P is the PWM signal period. */
|
__STATIC_INLINE void Configure_DutyCycle(uint32_t D)
|
/* Changes the duty cycle of the PWM signal. D = (T/P)*100 where T is the pulse duration and P is the PWM signal period. */
__STATIC_INLINE void Configure_DutyCycle(uint32_t D)
|
{
uint32_t P;
uint32_t T;
T = LL_TIM_GetAutoReload(TIM2) + 1;
P = (D*T)/100;
LL_TIM_OC_SetCompareCH1(TIM2, P);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Disable the Capture of the PWM module.
The */
|
void PWMCAPDisable(unsigned long ulBase, unsigned long ulChannel)
|
/* Disable the Capture of the PWM module.
The */
void PWMCAPDisable(unsigned long ulBase, unsigned long ulChannel)
|
{
xASSERT(ulBase == PWMA_BASE);
xASSERT(((ulChannel >= 0) || (ulChannel <= 3)));
xHWREG(ulBase + PWM_CCR0 + (ulChannel >> 1)*4) &=
~(PWM_CCR0_CAPCH0EN << ((ulChannel % 2) ? 16 : 0));
xHWREG(ulBase + PWM_PCR) &= ~(PWM_PCR_CH0EN << (ulChannel << 3));
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Sets the value of the RTC pre-divider trim register. */
|
void HibernateRTCTrimSet(uint32_t ui32Trim)
|
/* Sets the value of the RTC pre-divider trim register. */
void HibernateRTCTrimSet(uint32_t ui32Trim)
|
{
ASSERT(ui32Trim < 0x10000);
HWREG(HIB_RTCT) = ui32Trim;
_HibernateWriteComplete();
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Register address automatically incremented during a multiple byte access with a serial interface (I2C or SPI).. */
|
int32_t lps22hb_auto_add_inc_get(stmdev_ctx_t *ctx, uint8_t *val)
|
/* Register address automatically incremented during a multiple byte access with a serial interface (I2C or SPI).. */
int32_t lps22hb_auto_add_inc_get(stmdev_ctx_t *ctx, uint8_t *val)
|
{
lps22hb_ctrl_reg2_t ctrl_reg2;
int32_t ret;
ret = lps22hb_read_reg(ctx, LPS22HB_CTRL_REG2, (uint8_t*)&ctrl_reg2, 1);
*val = ctrl_reg2.if_add_inc;
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Stores the line number associated with a given controller (board), aiop and channel number. */
|
static unsigned char SetLineNumber(int ctrl, int aiop, int ch)
|
/* Stores the line number associated with a given controller (board), aiop and channel number. */
static unsigned char SetLineNumber(int ctrl, int aiop, int ch)
|
{
lineNumbers[(ctrl << 5) | (aiop << 3) | ch] = nextLineNumber++;
return (nextLineNumber - 1);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns the date and time this file (and firmware) was built. */
|
VOID GetReleaseTime(OUT EFI_TIME *Time)
|
/* Returns the date and time this file (and firmware) was built. */
VOID GetReleaseTime(OUT EFI_TIME *Time)
|
{
CONST CHAR8 *ReleaseDate = __DATE__;
CONST CHAR8 *ReleaseTime = __TIME__;
UINTN i;
for (i = 0; i < 12; i++) {
if (AsciiStrnCmp (ReleaseDate, mMonthDescription[i].MonthStr, 3) == 0) {
break;
}
}
Time->Month = mMonthDescription[i].MonthInt;
Time->Day = AsciiStrDecimalToUintn (ReleaseDate + 4);
Time->Year = AsciiStrDecimalToUintn (ReleaseDate + 7);
Time->Hour = AsciiStrDecimalToUintn (ReleaseTime);
Time->Minute = AsciiStrDecimalToUintn (ReleaseTime + 3);
Time->Second = AsciiStrDecimalToUintn (ReleaseTime + 6);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Note that the clock adjustment in ppb must be entered (which is the negative value of the deviation). */
|
static int rx8025_get_clock_adjust(struct device *dev, int *adj)
|
/* Note that the clock adjustment in ppb must be entered (which is the negative value of the deviation). */
static int rx8025_get_clock_adjust(struct device *dev, int *adj)
|
{
struct i2c_client *client = to_i2c_client(dev);
u8 digoff;
int err;
err = rx8025_read_reg(client, RX8025_REG_DIGOFF, &digoff);
if (err)
return err;
*adj = digoff >= 64 ? digoff - 128 : digoff;
if (*adj > 0)
(*adj)--;
*adj *= -RX8025_ADJ_RESOLUTION;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
|
UINT16 EFIAPI S3PciSegmentBitFieldAnd16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData)
|
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT16 EFIAPI S3PciSegmentBitFieldAnd16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData)
|
{
return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentBitFieldAnd16 (Address, StartBit, EndBit, AndData));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Tries to acquire an active reference. grab_super() is used when we had just found a superblock in super_blocks or fs_type->fs_supers and want to turn it into a full-blown active reference. grab_super() is called with sb_lock held and drops it. Returns 1 in case of success, 0 if we had failed (superblock contents was already dead or dying when grab_super() had been called). */
|
static int grab_super(struct super_block *s) __releases(sb_lock)
|
/* Tries to acquire an active reference. grab_super() is used when we had just found a superblock in super_blocks or fs_type->fs_supers and want to turn it into a full-blown active reference. grab_super() is called with sb_lock held and drops it. Returns 1 in case of success, 0 if we had failed (superblock contents was already dead or dying when grab_super() had been called). */
static int grab_super(struct super_block *s) __releases(sb_lock)
|
{
s->s_count++;
spin_unlock(&sb_lock);
down_write(&s->s_umount);
if (s->s_root) {
spin_lock(&sb_lock);
if (s->s_count > S_BIAS) {
atomic_inc(&s->s_active);
s->s_count--;
spin_unlock(&sb_lock);
return 1;
}
spin_unlock(&sb_lock);
}
up_write(&s->s_umount);
put_super(s);
yield();
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Locks GPIO Pins configuration registers until next system reset. */
|
void GPIO_PinLockConfig(GPIO_TypeDef *gpio, u16 pin)
|
/* Locks GPIO Pins configuration registers until next system reset. */
void GPIO_PinLockConfig(GPIO_TypeDef *gpio, u16 pin)
|
{
gpio->LCKR = GPIO_LCKR_LCKK | pin;
gpio->LCKR = pin;
gpio->LCKR = GPIO_LCKR_LCKK | pin;
gpio->LCKR;
gpio->LCKR;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Pretty-print EEPROM content.
Respond on memory print command. */
|
static void do_print_data(void)
|
/* Pretty-print EEPROM content.
Respond on memory print command. */
static void do_print_data(void)
|
{
size_t addr;
uint8_t buff[IN_LINE_PRINT_CNT];
for (addr=0; addr<(EEPROM_SIM_SIZE); addr+=(IN_LINE_PRINT_CNT))
{
ret_code_t err_code;
err_code = eeprom_read(addr, buff, IN_LINE_PRINT_CNT);
if (NRF_SUCCESS != err_code)
{
NRF_LOG_WARNING("Communication error\r\n");
return;
}
NRF_LOG_RAW_INFO("%.2x: ", addr);
NRF_LOG_RAW_HEXDUMP_INFO(buff, IN_LINE_PRINT_CNT);
}
NRF_LOG_FLUSH();
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Active the Calibration operation for the selected ADC. */
|
uint32_t ADC_GetCalibrationFactor(ADC_TypeDef *ADCx)
|
/* Active the Calibration operation for the selected ADC. */
uint32_t ADC_GetCalibrationFactor(ADC_TypeDef *ADCx)
|
{
uint32_t tmpreg = 0, calibrationcounter = 0, calibrationstatus = 0;
assert_param(IS_ADC_ALL_PERIPH(ADCx));
ADCx->CR |= (uint32_t)ADC_CR_ADCAL;
do
{
calibrationstatus = ADCx->CR & ADC_CR_ADCAL;
calibrationcounter++;
} while((calibrationcounter != CALIBRATION_TIMEOUT) && (calibrationstatus != 0x00));
if((uint32_t)(ADCx->CR & ADC_CR_ADCAL) == RESET)
{
tmpreg = ADCx->DR;
}
else
{
tmpreg = 0x00000000;
}
return tmpreg;
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* This is called by the entropy decoder after it has read an appropriate number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder has already read a marker from the data source. Under normal conditions cinfo->unread_marker will be reset to 0 before returning; if not reset, it holds a marker which the decoder will be unable to read past. */
|
read_restart_marker(j_decompress_ptr cinfo)
|
/* This is called by the entropy decoder after it has read an appropriate number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder has already read a marker from the data source. Under normal conditions cinfo->unread_marker will be reset to 0 before returning; if not reset, it holds a marker which the decoder will be unable to read past. */
read_restart_marker(j_decompress_ptr cinfo)
|
{
if (cinfo->unread_marker == 0) {
if (! next_marker(cinfo))
return FALSE;
}
if (cinfo->unread_marker ==
((int) M_RST0 + cinfo->marker->next_restart_num)) {
TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num);
cinfo->unread_marker = 0;
} else {
if (! (*cinfo->src->resync_to_restart) (cinfo,
cinfo->marker->next_restart_num))
return FALSE;
}
cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7;
return TRUE;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* This routine waits for the TX holding register or TX FIFO to be ready and then it writes a character to the data register. */
|
static void apbuart_poll_out(const struct device *dev, unsigned char x)
|
/* This routine waits for the TX holding register or TX FIFO to be ready and then it writes a character to the data register. */
static void apbuart_poll_out(const struct device *dev, unsigned char x)
|
{
const struct apbuart_dev_cfg *config = dev->config;
struct apbuart_dev_data *data = dev->data;
volatile struct apbuart_regs *regs = (void *) config->regs;
if (data->usefifo) {
while (regs->status & APBUART_STATUS_TF) {
;
}
} else {
while (!(regs->status & APBUART_STATUS_HOLD_REGISTER_EMPTY)) {
;
}
}
regs->data = x & 0xff;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Manages the multicast receive filters of a network interface. */
|
EFI_STATUS EFIAPI VirtioNetReceiveFilters(IN EFI_SIMPLE_NETWORK_PROTOCOL *This, IN UINT32 Enable, IN UINT32 Disable, IN BOOLEAN ResetMCastFilter, IN UINTN MCastFilterCnt OPTIONAL, IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL)
|
/* Manages the multicast receive filters of a network interface. */
EFI_STATUS EFIAPI VirtioNetReceiveFilters(IN EFI_SIMPLE_NETWORK_PROTOCOL *This, IN UINT32 Enable, IN UINT32 Disable, IN BOOLEAN ResetMCastFilter, IN UINTN MCastFilterCnt OPTIONAL, IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL)
|
{
VNET_DEV *Dev;
EFI_TPL OldTpl;
EFI_STATUS Status;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
Dev = VIRTIO_NET_FROM_SNP (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (Dev->Snm.State) {
case EfiSimpleNetworkStopped:
Status = EFI_NOT_STARTED;
goto Exit;
case EfiSimpleNetworkStarted:
Status = EFI_DEVICE_ERROR;
goto Exit;
default:
break;
}
Status = (
((Enable | Disable) & ~Dev->Snm.ReceiveFilterMask) != 0 ||
(!ResetMCastFilter && MCastFilterCnt > Dev->Snm.MaxMCastFilterCount)
) ? EFI_INVALID_PARAMETER : EFI_SUCCESS;
Exit:
gBS->RestoreTPL (OldTpl);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Get a single property from the fuel gauge */
|
static int max17048_get_single_prop_impl(const struct device *dev, fuel_gauge_prop_t prop, union fuel_gauge_prop_val *val)
|
/* Get a single property from the fuel gauge */
static int max17048_get_single_prop_impl(const struct device *dev, fuel_gauge_prop_t prop, union fuel_gauge_prop_val *val)
|
{
struct max17048_data *data = dev->data;
int rc = 0;
switch (prop) {
case FUEL_GAUGE_RUNTIME_TO_EMPTY:
val->runtime_to_empty = data->time_to_empty;
break;
case FUEL_GAUGE_RUNTIME_TO_FULL:
val->runtime_to_full = data->time_to_full;
break;
case FUEL_GAUGE_RELATIVE_STATE_OF_CHARGE:
val->relative_state_of_charge = data->charge;
break;
case FUEL_GAUGE_VOLTAGE:
val->voltage = data->voltage;
break;
default:
rc = -ENOTSUP;
}
return rc;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Set the synaptics touchpad mode byte by special commands */
|
static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode)
|
/* Set the synaptics touchpad mode byte by special commands */
static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode)
|
{
unsigned char param[1];
if (psmouse_sliced_command(psmouse, mode))
return -1;
param[0] = SYN_PS_SET_MODE2;
if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_SETRATE))
return -1;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* param base LPUART peripheral base address. param handle LPUART handle pointer. param count Receive bytes count. retval kStatus_NoTransferInProgress No receive in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter */
|
status_t LPUART_TransferGetReceiveCountEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, uint32_t *count)
|
/* param base LPUART peripheral base address. param handle LPUART handle pointer. param count Receive bytes count. retval kStatus_NoTransferInProgress No receive in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter */
status_t LPUART_TransferGetReceiveCountEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, uint32_t *count)
|
{
assert(NULL != handle);
assert(NULL != handle->rxEdmaHandle);
assert(NULL != count);
if ((uint8_t)kLPUART_RxIdle == handle->rxState)
{
return kStatus_NoTransferInProgress;
}
*count = handle->rxDataSizeAll -
((uint32_t)handle->nbytes *
EDMA_GetRemainingMajorLoopCount(handle->rxEdmaHandle->base, handle->rxEdmaHandle->channel));
return kStatus_Success;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* This routine waits for the SEEQ chip to assert that the FIFO is ready by checking for a window interrupt, and then clearing it. This has to occur in the interrupt handler! */
|
void wait_for_buffer(struct net_device *dev)
|
/* This routine waits for the SEEQ chip to assert that the FIFO is ready by checking for a window interrupt, and then clearing it. This has to occur in the interrupt handler! */
void wait_for_buffer(struct net_device *dev)
|
{
int ioaddr = dev->base_addr;
unsigned long tmp;
int status;
tmp = jiffies + HZ;
while ( ( ((status=inw(SEEQ_STATUS)) & SEEQSTAT_WINDOW_INT) != SEEQSTAT_WINDOW_INT) && time_before(jiffies, tmp))
cpu_relax();
if ( (status & SEEQSTAT_WINDOW_INT) == SEEQSTAT_WINDOW_INT)
outw( SEEQCMD_WINDOW_INT_ACK | (status & SEEQCMD_INT_MASK), SEEQ_CMD);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Clear the I2C interrupt flag of the specified I2C port.
The */
|
void I2CIntFlagClear(unsigned long ulBase)
|
/* Clear the I2C interrupt flag of the specified I2C port.
The */
void I2CIntFlagClear(unsigned long ulBase)
|
{
xASSERT((ulBase == I2C0_BASE));
xHWREG(ulBase + I2C_CON) |= I2C_CON_SI;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* RFC3280 says nothing about the relationship between CRL path and certificate path, which could lead to situations where a certificate could be revoked or validated by a CA not authorised to do so. RFC5280 is more strict and states that the two paths must end in the same trust anchor, though some discussions remain... until this is resolved we use the RFC5280 version */
|
static int check_crl_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *cert_path, STACK_OF(X509) *crl_path)
|
/* RFC3280 says nothing about the relationship between CRL path and certificate path, which could lead to situations where a certificate could be revoked or validated by a CA not authorised to do so. RFC5280 is more strict and states that the two paths must end in the same trust anchor, though some discussions remain... until this is resolved we use the RFC5280 version */
static int check_crl_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *cert_path, STACK_OF(X509) *crl_path)
|
{
X509 *cert_ta, *crl_ta;
cert_ta = sk_X509_value(cert_path, sk_X509_num(cert_path) - 1);
crl_ta = sk_X509_value(crl_path, sk_X509_num(crl_path) - 1);
if (!X509_cmp(cert_ta, crl_ta))
return 1;
return 0;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Get the PWM duty of the PWM module.
The */
|
unsigned long PWMDutyGet(unsigned long ulBase, unsigned long ulChannel)
|
/* Get the PWM duty of the PWM module.
The */
unsigned long PWMDutyGet(unsigned long ulBase, unsigned long ulChannel)
|
{
unsigned long ulChannelTemp;
unsigned long ulCMRData;
unsigned long ulCNRData;
ulChannelTemp = (ulBase == PWMA_BASE) ? ulChannel : (ulChannel - 4);
xASSERT((ulBase == PWMA_BASE) || (ulBase == PWMB_BASE));
xASSERT((ulChannelTemp >= 0) || (ulChannelTemp <= 3));
ulCNRData = PWMCRRGet(ulBase);
ulCMRData = xHWREG(ulBase + TIMER_CH0CCR + ulChannelTemp * 4);
ulChannelTemp = (ulCMRData + 1) * 100 / (ulCNRData + 1);
return ulChannelTemp;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Process attributes of devices on this host bridge */
|
EFI_STATUS PciHostBridgeDeviceAttribute(IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc)
|
/* Process attributes of devices on this host bridge */
EFI_STATUS PciHostBridgeDeviceAttribute(IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc)
|
{
EFI_HANDLE RootBridgeHandle;
PCI_IO_DEVICE *RootBridgeDev;
EFI_STATUS Status;
RootBridgeHandle = NULL;
while (PciResAlloc->GetNextRootBridge (PciResAlloc, &RootBridgeHandle) == EFI_SUCCESS) {
RootBridgeDev = GetRootBridgeByHandle (RootBridgeHandle);
if (RootBridgeDev == NULL) {
return EFI_NOT_FOUND;
}
Status = DetermineDeviceAttribute (RootBridgeDev);
if (EFI_ERROR (Status)) {
return Status;
}
}
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Decodes the message length according to the MQTT algorithm, non-blocking */
|
static int decodenb(mqtt_transport_t *trp)
|
/* Decodes the message length according to the MQTT algorithm, non-blocking */
static int decodenb(mqtt_transport_t *trp)
|
{
unsigned char c;
int rc = MQTTPACKET_READ_ERROR;
FUNC_ENTRY;
if(trp->len == 0){
trp->multiplier = 1;
trp->rem_len = 0;
}
do {
int frc;
if (++(trp->len) > MAX_NO_OF_REMAINING_LENGTH_BYTES)
goto exit;
if ((frc=(*trp->getfn)(trp->sck, &c, 1)) == -1)
goto exit;
if (frc == 0){
rc = 0;
goto exit;
}
trp->rem_len += (c & 127) * trp->multiplier;
trp->multiplier *= 128;
} while ((c & 128) != 0);
rc = trp->len;
exit:
FUNC_EXIT_RC(rc);
return rc;
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* Starts the TIMER PWM signal generation on the complementary output. in DMA mode. */
|
ald_status_t ald_timer_pwmn_start_by_dma(ald_timer_handle_t *hperh, ald_timer_channel_t ch, uint16_t *buf, uint32_t len, uint8_t dma_ch)
|
/* Starts the TIMER PWM signal generation on the complementary output. in DMA mode. */
ald_status_t ald_timer_pwmn_start_by_dma(ald_timer_handle_t *hperh, ald_timer_channel_t ch, uint16_t *buf, uint32_t len, uint8_t dma_ch)
|
{
return ald_timer_ocn_start_by_dma(hperh, ch, buf, len, dma_ch);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Function called in case of error detected in SPI IT Handler. */
|
void SPI_TransferError_Callback(void)
|
/* Function called in case of error detected in SPI IT Handler. */
void SPI_TransferError_Callback(void)
|
{
LL_DMA_DisableStream(DMA2, LL_DMA_STREAM_3);
LL_DMA_DisableStream(DMA1, LL_DMA_STREAM_3);
LED_Blinking(LED_BLINK_ERROR);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* This routine looks up the ndlp lists for the given RPI. If rpi found it returns the node list element pointer else return NULL. */
|
struct lpfc_nodelist* __lpfc_findnode_rpi(struct lpfc_vport *vport, uint16_t rpi)
|
/* This routine looks up the ndlp lists for the given RPI. If rpi found it returns the node list element pointer else return NULL. */
struct lpfc_nodelist* __lpfc_findnode_rpi(struct lpfc_vport *vport, uint16_t rpi)
|
{
return __lpfc_find_node(vport, lpfc_filter_by_rpi, &rpi);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* N.B. this function is only ever called from knfsd and ownership of locks is never checked. */
|
int lock_may_read(struct inode *inode, loff_t start, unsigned long len)
|
/* N.B. this function is only ever called from knfsd and ownership of locks is never checked. */
int lock_may_read(struct inode *inode, loff_t start, unsigned long len)
|
{
struct file_lock *fl;
int result = 1;
lock_kernel();
for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
if (IS_POSIX(fl)) {
if (fl->fl_type == F_RDLCK)
continue;
if ((fl->fl_end < start) || (fl->fl_start > (start + len)))
continue;
} else if (IS_FLOCK(fl)) {
if (!(fl->fl_type & LOCK_MAND))
continue;
if (fl->fl_type & LOCK_READ)
continue;
} else
continue;
result = 0;
break;
}
unlock_kernel();
return result;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Call repeatedly until it returns -EAGAIN, meaning there's nothing more that can be done. */
|
static int autofs_dev_ioctl_expire(struct file *fp, struct autofs_sb_info *sbi, struct autofs_dev_ioctl *param)
|
/* Call repeatedly until it returns -EAGAIN, meaning there's nothing more that can be done. */
static int autofs_dev_ioctl_expire(struct file *fp, struct autofs_sb_info *sbi, struct autofs_dev_ioctl *param)
|
{
struct vfsmount *mnt;
int how;
how = param->expire.how;
mnt = fp->f_path.mnt;
return autofs4_do_expire_multi(sbi->sb, mnt, sbi, how);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function looks for a wear leveling entry with erase counter closest to @max and less then @max. */
|
static struct ubi_wl_entry* find_wl_entry(struct rb_root *root, int max)
|
/* This function looks for a wear leveling entry with erase counter closest to @max and less then @max. */
static struct ubi_wl_entry* find_wl_entry(struct rb_root *root, int max)
|
{
struct rb_node *p;
struct ubi_wl_entry *e;
e = rb_entry(rb_first(root), struct ubi_wl_entry, u.rb);
max += e->ec;
p = root->rb_node;
while (p) {
struct ubi_wl_entry *e1;
e1 = rb_entry(p, struct ubi_wl_entry, u.rb);
if (e1->ec >= max)
p = p->rb_left;
else {
p = p->rb_right;
e = e1;
}
}
return e;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns 0 on success and < 0 on error */
|
static int rewrite_footer(BlockDriverState *bs)
|
/* Returns 0 on success and < 0 on error */
static int rewrite_footer(BlockDriverState *bs)
|
{
int ret;
BDRVVPCState *s = bs->opaque;
int64_t offset = s->free_data_block_offset;
ret = bdrv_pwrite_sync(bs->file, offset, s->footer_buf, HEADER_SIZE);
if (ret < 0)
return ret;
return 0;
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* Check to see if xpc_handle_notify_IRQ_sn2() dropped any IRQs on the floor because the write to their associated amo variable completed after the IRQ was received. */
|
static void xpc_check_for_dropped_notify_IRQ_sn2(struct xpc_partition *part)
|
/* Check to see if xpc_handle_notify_IRQ_sn2() dropped any IRQs on the floor because the write to their associated amo variable completed after the IRQ was received. */
static void xpc_check_for_dropped_notify_IRQ_sn2(struct xpc_partition *part)
|
{
struct xpc_partition_sn2 *part_sn2 = &part->sn.sn2;
if (xpc_part_ref(part)) {
xpc_check_for_sent_chctl_flags_sn2(part);
part_sn2->dropped_notify_IRQ_timer.expires = jiffies +
XPC_DROPPED_NOTIFY_IRQ_WAIT_INTERVAL;
add_timer(&part_sn2->dropped_notify_IRQ_timer);
xpc_part_deref(part);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* param base SPDIF base pointer param handle SPDIF eDMA handle pointer. */
|
void SPDIF_TransferAbortReceiveEDMA(SPDIF_Type *base, spdif_edma_handle_t *handle)
|
/* param base SPDIF base pointer param handle SPDIF eDMA handle pointer. */
void SPDIF_TransferAbortReceiveEDMA(SPDIF_Type *base, spdif_edma_handle_t *handle)
|
{
assert(handle != NULL);
EDMA_AbortTransfer(handle->dmaLeftHandle);
EDMA_AbortTransfer(handle->dmaRightHandle);
SPDIF_EnableDMA(base, kSPDIF_RxDMAEnable, false);
(void)memset(handle->spdifQueue, 0, sizeof(handle->spdifQueue));
(void)memset(handle->transferSize, 0, sizeof(handle->transferSize));
handle->queueUser = 0U;
handle->queueDriver = 0U;
handle->state = kSPDIF_Idle;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* __wait_latch - Wait up to 100us for a port latch to get a certain value, returning zero if the value is obtained. Callers must hold hdaps_mtx. */
|
static int __wait_latch(u16 port, u8 val)
|
/* __wait_latch - Wait up to 100us for a port latch to get a certain value, returning zero if the value is obtained. Callers must hold hdaps_mtx. */
static int __wait_latch(u16 port, u8 val)
|
{
unsigned int i;
for (i = 0; i < 20; i++) {
if (!__check_latch(port, val))
return 0;
udelay(5);
}
return -EIO;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Registers an interrupt handler for the timer interrupt. */
|
void TimerIntRegister(unsigned long ulBase, unsigned long ulTimer, void(*pfnHandler)(void))
|
/* Registers an interrupt handler for the timer interrupt. */
void TimerIntRegister(unsigned long ulBase, unsigned long ulTimer, void(*pfnHandler)(void))
|
{
ASSERT(TimerBaseValid(ulBase));
ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B) ||
(ulTimer == TIMER_BOTH));
ulBase = ((ulBase == TIMER0_BASE) ? INT_TIMER0A :
((ulBase == TIMER1_BASE) ? INT_TIMER1A :
((ulBase == TIMER2_BASE) ? INT_TIMER2A : INT_TIMER3A)));
if(ulTimer & TIMER_A)
{
IntRegister(ulBase, pfnHandler);
IntEnable(ulBase);
}
if(ulTimer & TIMER_B)
{
IntRegister(ulBase + 1, pfnHandler);
IntEnable(ulBase + 1);
}
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* configure keys, rotors and sliders.
Example configuration for touch keys, rotors and sliders. */
|
touch_ret_t touch_sensors_config(void)
|
/* configure keys, rotors and sliders.
Example configuration for touch keys, rotors and sliders. */
touch_ret_t touch_sensors_config(void)
|
{
touch_ret_t touch_ret = TOUCH_SUCCESS;
sensor_id_t sensor_id;
touch_ret =
touch_qt_sensor_config (SENSOR_TYPE_KEY, (channel_t) 0u,
(channel_t) 0u, NO_AKS_GROUP, 15u, HYST_6_25,
RES_1_BIT, &sensor_id);
if (touch_ret != TOUCH_SUCCESS)
{
while (1);
}
touch_ret =
touch_qt_sensor_config (SENSOR_TYPE_SLIDER,
(channel_t) 1u, (channel_t) 3u, NO_AKS_GROUP, 12u,
(hysteresis_t) HYST_6_25, RES_8_BIT, &sensor_id);
if (touch_ret != TOUCH_SUCCESS)
{
while (1);
}
return (touch_ret);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Is this a VMS UCX file handle? Check for: (1) leading code byte (2) followed by string of printing chars & spaces (3) followed by string of nulls */
|
static int is_UCX(const unsigned char *, u_int)
|
/* Is this a VMS UCX file handle? Check for: (1) leading code byte (2) followed by string of printing chars & spaces (3) followed by string of nulls */
static int is_UCX(const unsigned char *, u_int)
|
{
register u_int i;
int seen_null = 0;
if (len < 28/4)
return(0);
for (i = 1; i < 14; i++) {
if (ND_ISPRINT(fhp[i])) {
if (seen_null)
return(0);
else
continue;
}
else if (fhp[i] == 0) {
seen_null = 1;
continue;
}
else
return(0);
}
return(1);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Returns the file offset start of the new payload block */
|
static int vhdx_allocate_block(BlockDriverState *bs, BDRVVHDXState *s, uint64_t *new_offset)
|
/* Returns the file offset start of the new payload block */
static int vhdx_allocate_block(BlockDriverState *bs, BDRVVHDXState *s, uint64_t *new_offset)
|
{
*new_offset = bdrv_getlength(bs->file);
*new_offset = ROUND_UP(*new_offset, 1024 * 1024);
return bdrv_truncate(bs->file, *new_offset + s->block_size);
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* i s C P U t i m e L i m i t E x c e e d e d */
|
BooleanType QProblem_isCPUtimeLimitExceeded(QProblem *_THIS, const real_t *const cputime, real_t starttime, int nWSR)
|
/* i s C P U t i m e L i m i t E x c e e d e d */
BooleanType QProblem_isCPUtimeLimitExceeded(QProblem *_THIS, const real_t *const cputime, real_t starttime, int nWSR)
|
{
real_t elapsedTime, timePerIteration;
if ( cputime == 0 )
return BT_FALSE;
if ( nWSR <= 0 )
return BT_FALSE;
elapsedTime = qpOASES_getCPUtime( ) - starttime;
timePerIteration = elapsedTime / ((real_t) nWSR);
if ( ( elapsedTime + timePerIteration*1.25 ) <= ( *cputime ) )
return BT_FALSE;
else
return BT_TRUE;
}
|
DanielMartensson/EmbeddedLapack
|
C++
|
MIT License
| 129
|
/* Set the sleep mode of the HIF layer. */
|
NMI_API void hif_set_sleep_mode(uint8 u8Pstype)
|
/* Set the sleep mode of the HIF layer. */
NMI_API void hif_set_sleep_mode(uint8 u8Pstype)
|
{
gu8ChipMode = u8Pstype;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* input MUX helper snd_hda_input_mux_info_info - Info callback helper for the input-mux enum */
|
int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem_info *uinfo)
|
/* input MUX helper snd_hda_input_mux_info_info - Info callback helper for the input-mux enum */
int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem_info *uinfo)
|
{
unsigned int index;
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
uinfo->value.enumerated.items = imux->num_items;
if (!imux->num_items)
return 0;
index = uinfo->value.enumerated.item;
if (index >= imux->num_items)
index = imux->num_items - 1;
strcpy(uinfo->value.enumerated.name, imux->items[index].label);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* When a context switch is performed from the task level the saved task context is made to look as if it occurred from within the tick ISR. This way the same restore context function can be used when restoring the context saved from the ISR or that saved from a call to vPortYieldProcessor. */
|
void vPortYieldProcessor(void)
|
/* When a context switch is performed from the task level the saved task context is made to look as if it occurred from within the tick ISR. This way the same restore context function can be used when restoring the context saved from the ISR or that saved from a call to vPortYieldProcessor. */
void vPortYieldProcessor(void)
|
{
__asm volatile ( "ADD LR, LR, #4" );
portSAVE_CONTEXT();
__asm volatile ( "bl vTaskSwitchContext" );
portRESTORE_CONTEXT();}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Configures the TIMx Output Compare 1 Fast feature. */
|
void TIM_OC1FastConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCFast)
|
/* Configures the TIMx Output Compare 1 Fast feature. */
void TIM_OC1FastConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCFast)
|
{
uint16_t tmpccmr1 = 0;
assert_param(IS_TIM_LIST8_PERIPH(TIMx));
assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
tmpccmr1 = TIMx->CCMR1;
tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC1FE);
tmpccmr1 |= TIM_OCFast;
TIMx->CCMR1 = tmpccmr1;
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* Returns the number of TSEC devices that were initialized */
|
int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsecs, int num)
|
/* Returns the number of TSEC devices that were initialized */
int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsecs, int num)
|
{
int i;
int count = 0;
for (i = 0; i < num; i++) {
int ret = tsec_initialize(bis, &tsecs[i]);
if (ret > 0)
count += ret;
}
return count;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Registers a pair of callbacks function to be called upon addition or removal of MTD devices. Causes the 'add' callback to be immediately invoked for each MTD device currently present in the system. */
|
void register_mtd_user(struct mtd_notifier *new)
|
/* Registers a pair of callbacks function to be called upon addition or removal of MTD devices. Causes the 'add' callback to be immediately invoked for each MTD device currently present in the system. */
void register_mtd_user(struct mtd_notifier *new)
|
{
struct mtd_info *mtd;
mutex_lock(&mtd_table_mutex);
list_add(&new->list, &mtd_notifiers);
__module_get(THIS_MODULE);
mtd_for_each_device(mtd)
new->add(mtd);
mutex_unlock(&mtd_table_mutex);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Returns 0 if granted; +ve if granted, but inode_killpriv() is required; and -ve to deny the change. */
|
int cap_inode_need_killpriv(struct dentry *dentry)
|
/* Returns 0 if granted; +ve if granted, but inode_killpriv() is required; and -ve to deny the change. */
int cap_inode_need_killpriv(struct dentry *dentry)
|
{
struct inode *inode = dentry->d_inode;
int error;
if (!inode->i_op->getxattr)
return 0;
error = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, NULL, 0);
if (error <= 0)
return 0;
return 1;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* RETURNS: Device type, ATA_DEV_ATA, ATA_DEV_ATAPI, ATA_DEV_PMP or ATA_DEV_UNKNOWN the event of failure. */
|
unsigned int ata_dev_classify(const struct ata_taskfile *tf)
|
/* RETURNS: Device type, ATA_DEV_ATA, ATA_DEV_ATAPI, ATA_DEV_PMP or ATA_DEV_UNKNOWN the event of failure. */
unsigned int ata_dev_classify(const struct ata_taskfile *tf)
|
{
if ((tf->lbam == 0) && (tf->lbah == 0)) {
DPRINTK("found ATA device by sig\n");
return ATA_DEV_ATA;
}
if ((tf->lbam == 0x14) && (tf->lbah == 0xeb)) {
DPRINTK("found ATAPI device by sig\n");
return ATA_DEV_ATAPI;
}
if ((tf->lbam == 0x69) && (tf->lbah == 0x96)) {
DPRINTK("found PMP device by sig\n");
return ATA_DEV_PMP;
}
if ((tf->lbam == 0x3c) && (tf->lbah == 0xc3)) {
DPRINTK("found SEMB device by sig (could be ATA device)\n");
return ATA_DEV_SEMB;
}
DPRINTK("unknown device\n");
return ATA_DEV_UNKNOWN;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Converts a Mode Register bit mask to a stop bit configuration enum value.
Converts a bit mask representing the UART's stop bit setting within the UART's Mode Register into a value of an enumeration type provided by the UART driver API. */
|
static enum uart_config_stop_bits uart_xlnx_ps_ll2cfg_stopbits(uint32_t mode_reg)
|
/* Converts a Mode Register bit mask to a stop bit configuration enum value.
Converts a bit mask representing the UART's stop bit setting within the UART's Mode Register into a value of an enumeration type provided by the UART driver API. */
static enum uart_config_stop_bits uart_xlnx_ps_ll2cfg_stopbits(uint32_t mode_reg)
|
{
switch ((mode_reg & XUARTPS_MR_STOPMODE_MASK)) {
case XUARTPS_MR_STOPMODE_1_BIT:
default:
return UART_CFG_STOP_BITS_1;
case XUARTPS_MR_STOPMODE_1_5_BIT:
return UART_CFG_STOP_BITS_1_5;
case XUARTPS_MR_STOPMODE_2_BIT:
return UART_CFG_STOP_BITS_2;
}
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Called by regulator drivers to unregister a regulator. */
|
void regulator_unregister(struct regulator_dev *rdev)
|
/* Called by regulator drivers to unregister a regulator. */
void regulator_unregister(struct regulator_dev *rdev)
|
{
if (rdev == NULL)
return;
mutex_lock(®ulator_list_mutex);
WARN_ON(rdev->open_count);
unset_regulator_supplies(rdev);
list_del(&rdev->list);
if (rdev->supply)
sysfs_remove_link(&rdev->dev.kobj, "supply");
device_unregister(&rdev->dev);
mutex_unlock(®ulator_list_mutex);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Called for each key in the table of all dissector tables. This is used if we get a list of table names, sort it, and process the list. */
|
static void dissector_all_tables_foreach_list_func(gpointer key, gpointer user_data)
|
/* Called for each key in the table of all dissector tables. This is used if we get a list of table names, sort it, and process the list. */
static void dissector_all_tables_foreach_list_func(gpointer key, gpointer user_data)
|
{
dissector_table_t table;
dissector_foreach_table_info_t *info;
table = (dissector_table_t)g_hash_table_lookup( dissector_tables, key );
info = (dissector_foreach_table_info_t *)user_data;
(*info->caller_func)((gchar*)key, table->ui_name, info->caller_data);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.