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
/* If Entry is NULL, then ASSERT(). If Entry is the head node of an empty list, then ASSERT(). If PcdMaximumLinkedListLength is not zero, and the number of nodes in the linked list containing Entry, including the Entry node, is greater than or equal to PcdMaximumLinkedListLength, then ASSERT(). */
LIST_ENTRY* EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
/* If Entry is NULL, then ASSERT(). If Entry is the head node of an empty list, then ASSERT(). If PcdMaximumLinkedListLength is not zero, and the number of nodes in the linked list containing Entry, including the Entry node, is greater than or equal to PcdMaximumLinkedListLength, then ASSERT(). */ LIST_ENTRY* EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
{ ASSERT (!IsListEmpty (Entry)); Entry->ForwardLink->BackLink = Entry->BackLink; Entry->BackLink->ForwardLink = Entry->ForwardLink; return Entry->ForwardLink; }
tianocore/edk2
C++
Other
4,240
/* Add Dns4 ServerIp to common list of addresses of all configured DNSv4 server. */
EFI_STATUS EFIAPI AddDns4ServerIp(IN LIST_ENTRY *Dns4ServerList, IN EFI_IPv4_ADDRESS ServerIp)
/* Add Dns4 ServerIp to common list of addresses of all configured DNSv4 server. */ EFI_STATUS EFIAPI AddDns4ServerIp(IN LIST_ENTRY *Dns4ServerList, IN EFI_IPv4_ADDRESS ServerIp)
{ DNS4_SERVER_IP *NewServerIp; DNS4_SERVER_IP *Item; LIST_ENTRY *Entry; LIST_ENTRY *Next; NewServerIp = NULL; Item = NULL; NET_LIST_FOR_EACH_SAFE (Entry, Next, Dns4ServerList) { Item = NET_LIST_USER_STRUCT (Entry, DNS4_SERVER_IP, AllServerLink); if (CompareMem (&Item->Dns4ServerIp, &ServerIp, sizeof (EFI_IPv4_ADDRESS)) == 0) { return EFI_SUCCESS; } } NewServerIp = AllocatePool (sizeof (DNS4_SERVER_IP)); if (NewServerIp == NULL) { return EFI_OUT_OF_RESOURCES; } InitializeListHead (&NewServerIp->AllServerLink); CopyMem (&NewServerIp->Dns4ServerIp, &ServerIp, sizeof (EFI_IPv4_ADDRESS)); InsertTailList (Dns4ServerList, &NewServerIp->AllServerLink); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Get the peripheral clock speed for the I2C device at base specified. */
uint32_t rcc_get_i2c_clk_freq(uint32_t i2c __attribute__((unused)))
/* Get the peripheral clock speed for the I2C device at base specified. */ uint32_t rcc_get_i2c_clk_freq(uint32_t i2c __attribute__((unused)))
{ return rcc_apb1_frequency; } /**@}
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* This function allows firmware update application to validate the firmware image without invoking the SetImage() first. */
EFI_STATUS EFIAPI CheckTheImage(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN UINT8 ImageIndex, IN CONST VOID *Image, IN UINTN ImageSize, OUT UINT32 *ImageUpdatable)
/* This function allows firmware update application to validate the firmware image without invoking the SetImage() first. */ EFI_STATUS EFIAPI CheckTheImage(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN UINT8 ImageIndex, IN CONST VOID *Image, IN UINTN ImageSize, OUT UINT32 *ImageUpdatable)
{ UINT32 LastAttemptStatus; return CheckTheImageInternal (This, ImageIndex, Image, ImageSize, ImageUpdatable, &LastAttemptStatus); }
tianocore/edk2
C++
Other
4,240
/* Prevents future blocking of tgt and unblocks it. Note, it is harmless to run scsi_unblock_requests() outside the card->lock protected section. On the other hand, running it inside the section might clash with shost->host_lock. */
static void sbp2_unblock(struct sbp2_target *tgt)
/* Prevents future blocking of tgt and unblocks it. Note, it is harmless to run scsi_unblock_requests() outside the card->lock protected section. On the other hand, running it inside the section might clash with shost->host_lock. */ static void sbp2_unblock(struct sbp2_target *tgt)
{ struct fw_card *card = target_device(tgt)->card; struct Scsi_Host *shost = container_of((void *)tgt, struct Scsi_Host, hostdata[0]); unsigned long flags; spin_lock_irqsave(&card->lock, flags); ++tgt->dont_block; spin_unlock_irqrestore(&card->lock, flags); scsi_unblock_requests(shost); }
robutest/uclinux
C++
GPL-2.0
60
/* param base XRDC2 peripheral base address. param periph The peripheral to operate. retval kStatus_Fail Failed to lock. retval kStatus_Success Locked succussfully. */
status_t XRDC2_TryLockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph)
/* param base XRDC2 peripheral base address. param periph The peripheral to operate. retval kStatus_Fail Failed to lock. retval kStatus_Success Locked succussfully. */ status_t XRDC2_TryLockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph)
{ status_t status; uint8_t curDomainID; uint32_t pac = XRDC2_GET_PAC((uint32_t)periph); uint32_t pdac = XRDC2_GET_PDAC((uint32_t)periph); volatile uint32_t *lockReg = &(base->PACI_PDACJ[pac][pdac].PAC_PDAC_W1); curDomainID = XRDC2_GetCurrentMasterDomainId(base); *lockReg = XRDC2_EAL_LOCKED; if (curDomainID != XRDC2_GetPeriphExclAccessLockDomainOwner(base, periph)) { status = kStatus_Fail; } else { status = kStatus_Success; } return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enables or disables the discontinuous mode on regular group channel for the specified ADC. */
void ADC_EnableDiscMode(ADC_Module *ADCx, FunctionalState Cmd)
/* Enables or disables the discontinuous mode on regular group channel for the specified ADC. */ void ADC_EnableDiscMode(ADC_Module *ADCx, FunctionalState Cmd)
{ assert_param(IsAdcModule(ADCx)); assert_param(IS_FUNCTIONAL_STATE(Cmd)); if (Cmd != DISABLE) { ADCx->CTRL1 |= CTRL1_DISC_EN_SET; } else { ADCx->CTRL1 &= CTRL1_DISC_EN_RESET; } }
pikasTech/PikaPython
C++
MIT License
1,403
/* Use this function to delete a BFA IOC. IOC should be stopped (by calling bfa_stop()) before this function call. */
void bfa_detach(struct bfa_s *bfa)
/* Use this function to delete a BFA IOC. IOC should be stopped (by calling bfa_stop()) before this function call. */ void bfa_detach(struct bfa_s *bfa)
{ int i; for (i = 0; hal_mods[i]; i++) hal_mods[i]->detach(bfa); bfa_iocfc_detach(bfa); }
robutest/uclinux
C++
GPL-2.0
60
/* Start the automatic loading of the CLUT or abort the transfer. */
void DMA2D_BGStart(FunctionalState NewState)
/* Start the automatic loading of the CLUT or abort the transfer. */ void DMA2D_BGStart(FunctionalState NewState)
{ assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { DMA2D->BGPFCCR |= DMA2D_BGPFCCR_START; } else { DMA2D->BGPFCCR &= (uint32_t)~DMA2D_BGPFCCR_START; } }
MaJerle/stm32f429
C++
null
2,036
/* Sets the FIFO level at which interrupts are generated. */
void UARTFIFOLevelSet(uint32_t ui32Base, uint32_t ui32TxLevel, uint32_t ui32RxLevel)
/* Sets the FIFO level at which interrupts are generated. */ void UARTFIFOLevelSet(uint32_t ui32Base, uint32_t ui32TxLevel, uint32_t ui32RxLevel)
{ ASSERT(_UARTBaseValid(ui32Base)); ASSERT((ui32TxLevel == UART_FIFO_TX1_8) || (ui32TxLevel == UART_FIFO_TX2_8) || (ui32TxLevel == UART_FIFO_TX4_8) || (ui32TxLevel == UART_FIFO_TX6_8) || (ui32TxLevel == UART_FIFO_TX7_8)); ASSERT((ui32RxLevel == UART_FIFO_RX1_8) || (ui32RxLevel == UART_FIFO_RX2_8) || (ui32RxLevel == UART_FIFO_RX4_8) || (ui32RxLevel == UART_FIFO_RX6_8) || (ui32RxLevel == UART_FIFO_RX7_8)); HWREG(ui32Base + UART_O_IFLS) = ui32TxLevel | ui32RxLevel; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* The callback invoked by QemuTimer when a delayed event is ready to be emitted */
static void monitor_protocol_event_handler(void *opaque)
/* The callback invoked by QemuTimer when a delayed event is ready to be emitted */ static void monitor_protocol_event_handler(void *opaque)
{ MonitorEventState *evstate = opaque; int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); trace_monitor_protocol_event_handler(evstate->event, evstate->data, evstate->last, now); if (evstate->data) { monitor_protocol_event_emit(evstate->event, evstate->data); qobject_decref(evstate->data); evstate->data = NULL; } evstate->last = now; }
ve3wwg/teensy3_qemu
C
Other
15
/* If AesContext is NULL, then return FALSE. If Input is NULL, then return FALSE. If InputSize is not multiple of block size (16 bytes), then return FALSE. If Ivec is NULL, then return FALSE. If Output is NULL, then return FALSE. */
BOOLEAN EFIAPI AesCbcDecrypt(IN VOID *AesContext, IN CONST UINT8 *Input, IN UINTN InputSize, IN CONST UINT8 *Ivec, OUT UINT8 *Output)
/* If AesContext is NULL, then return FALSE. If Input is NULL, then return FALSE. If InputSize is not multiple of block size (16 bytes), then return FALSE. If Ivec is NULL, then return FALSE. If Output is NULL, then return FALSE. */ BOOLEAN EFIAPI AesCbcDecrypt(IN VOID *AesContext, IN CONST UINT8 *Input, IN UINTN InputSize, IN CONST UINT8 *Ivec, OUT UINT8 *Output)
{ mbedtls_aes_context *AesCtx; UINT8 IvecBuffer[AES_BLOCK_SIZE]; if ((AesContext == NULL) || (Input == NULL) || ((InputSize % AES_BLOCK_SIZE) != 0)) { return FALSE; } if ((Ivec == NULL) || (Output == NULL) || (InputSize > INT_MAX)) { return FALSE; } AesCtx = (mbedtls_aes_context *)AesContext; CopyMem (IvecBuffer, Ivec, AES_BLOCK_SIZE); if (mbedtls_aes_crypt_cbc ( AesCtx + 1, MBEDTLS_AES_DECRYPT, (UINT32)InputSize, IvecBuffer, Input, Output ) != 0) { return FALSE; } else { return TRUE; } }
tianocore/edk2
C++
Other
4,240
/* LPT trivial GC is completed after a commit. Also LPT GC is done after a commit for the "big" LPT model. */
int ubifs_lpt_post_commit(struct ubifs_info *c)
/* LPT trivial GC is completed after a commit. Also LPT GC is done after a commit for the "big" LPT model. */ int ubifs_lpt_post_commit(struct ubifs_info *c)
{ int err; mutex_lock(&c->lp_mutex); err = lpt_tgc_end(c); if (err) goto out; if (c->big_lpt) while (need_write_all(c)) { mutex_unlock(&c->lp_mutex); err = lpt_gc(c); if (err) return err; mutex_lock(&c->lp_mutex); } out: mutex_unlock(&c->lp_mutex); return err; }
robutest/uclinux
C++
GPL-2.0
60
/* Check whether a tnode 'n' is "full", i.e. it is an internal node and no bits are skipped. See discussion in dyntree paper p. 6 */
static int tnode_full(const struct tnode *tn, const struct node *n)
/* Check whether a tnode 'n' is "full", i.e. it is an internal node and no bits are skipped. See discussion in dyntree paper p. 6 */ static int tnode_full(const struct tnode *tn, const struct node *n)
{ if (n == NULL || IS_LEAF(n)) return 0; return ((struct tnode *) n)->pos == tn->pos + tn->bits; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Disable the DAC module. Disables the DAC interface and the output buffer. */
void dac_disable(struct dac_module *const module_inst)
/* Disable the DAC module. Disables the DAC interface and the output buffer. */ void dac_disable(struct dac_module *const module_inst)
{ Assert(module_inst); Assert(module_inst->hw); Dac *const dac_module = module_inst->hw; while (dac_is_syncing(module_inst)) { }; dac_module->INTENCLR.reg = DAC_INTENCLR_MASK; dac_module->INTFLAG.reg = DAC_INTFLAG_MASK; dac_module->CTRLA.reg &= ~DAC_CTRLA_ENABLE; }
memfault/zero-to-main
C++
null
200
/* Adds a new element at the head of the queue. */
void g_queue_push_head(GQueue *queue, gpointer data)
/* Adds a new element at the head of the queue. */ void g_queue_push_head(GQueue *queue, gpointer data)
{ g_return_if_fail (queue != NULL); queue->head = g_list_prepend (queue->head, data); if (!queue->tail) queue->tail = queue->head; queue->length++; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* USBH_FindInterface Find the interface index for a specific class. */
uint8_t USBH_FindInterface(USBH_HandleTypeDef *phost, uint8_t Class, uint8_t SubClass, uint8_t Protocol)
/* USBH_FindInterface Find the interface index for a specific class. */ uint8_t USBH_FindInterface(USBH_HandleTypeDef *phost, uint8_t Class, uint8_t SubClass, uint8_t Protocol)
{ USBH_InterfaceDescTypeDef *pif ; USBH_CfgDescTypeDef *pcfg ; int8_t if_ix = 0; pif = (USBH_InterfaceDescTypeDef *)0; pcfg = &phost->device.CfgDesc; if((pif->bInterfaceClass == 0xFF) &&(pif->bInterfaceSubClass == 0xFF) && (pif->bInterfaceProtocol == 0xFF)) { return 0xFF; } while (if_ix < USBH_MAX_NUM_INTERFACES) { pif = &pcfg->Itf_Desc[if_ix]; if(((pif->bInterfaceClass == Class) || (Class == 0xFF))&& ((pif->bInterfaceSubClass == SubClass) || (SubClass == 0xFF))&& ((pif->bInterfaceProtocol == Protocol) || (Protocol == 0xFF))) { return if_ix; } if_ix++; } return 0xFF; }
micropython/micropython
C++
Other
18,334
/* After receiving an RR response with f-bit set to one, transmit window size is increased by one. Returns 0 for success, 1 otherwise. */
int llc_conn_ac_inc_tx_win_size(struct sock *sk, struct sk_buff *skb)
/* After receiving an RR response with f-bit set to one, transmit window size is increased by one. Returns 0 for success, 1 otherwise. */ int llc_conn_ac_inc_tx_win_size(struct sock *sk, struct sk_buff *skb)
{ struct llc_sock *llc = llc_sk(sk); llc->k += 1; if (llc->k > (u8) ~LLC_2_SEQ_NBR_MODULO) llc->k = (u8) ~LLC_2_SEQ_NBR_MODULO; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Handle a fatal parser error, i.e. violating Well-Formedness constraints */
static void xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *val)
/* Handle a fatal parser error, i.e. violating Well-Formedness constraints */ static void xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *val)
{ if ((ctxt != NULL) && (ctxt->disableSAX != 0) && (ctxt->instate == XML_PARSER_EOF)) return; if (ctxt != NULL) ctxt->errNo = error; __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL, NULL, 0, (const char *) val, NULL, NULL, 0, 0, msg, val); if (ctxt != NULL) { ctxt->wellFormed = 0; if (ctxt->recovery == 0) ctxt->disableSAX = 1; } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Read a line and try to load (compile) it first as an expression (by adding "return " in front of it) and second as a statement. Return the final status of load/call with the resulting function (if any) in the top of the stack. */
static int loadline(lua_State *L)
/* Read a line and try to load (compile) it first as an expression (by adding "return " in front of it) and second as a statement. Return the final status of load/call with the resulting function (if any) in the top of the stack. */ static int loadline(lua_State *L)
{ return -1; } if ((status = addreturn(L)) != LUA_OK) { status = multiline(L); } lua_remove(L, 1); lua_assert(lua_gettop(L) == 1); return status; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Receives a byte that has been sent to the I2C Master. */
unsigned long I2CMasterDataGet(unsigned long ulBase)
/* Receives a byte that has been sent to the I2C Master. */ unsigned long I2CMasterDataGet(unsigned long ulBase)
{ ASSERT((ulBase == I2C0_MASTER_BASE) || (ulBase == I2C1_MASTER_BASE)); return(HWREG(ulBase + I2C_O_MDR)); }
watterott/WebRadio
C++
null
71
/* Returns the most recent received data by the i2c peripheral. */
u8 I2C_ReceiveData(I2C_TypeDef *i2c)
/* Returns the most recent received data by the i2c peripheral. */ u8 I2C_ReceiveData(I2C_TypeDef *i2c)
{ I2C_CMD_DIR = 0; return (u8)i2c->IC_DATA_CMD; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Computes the packet time on air in ms for the given payload. \Remark Can only be called once SetRxConfig or SetTxConfig have been called */
uint32_t RadioTimeOnAir(RadioModems_t modem, uint32_t bandwidth, uint32_t datarate, uint8_t coderate, uint16_t preambleLen, bool fixLen, uint8_t payloadLen, bool crcOn)
/* Computes the packet time on air in ms for the given payload. \Remark Can only be called once SetRxConfig or SetTxConfig have been called */ uint32_t RadioTimeOnAir(RadioModems_t modem, uint32_t bandwidth, uint32_t datarate, uint8_t coderate, uint16_t preambleLen, bool fixLen, uint8_t payloadLen, bool crcOn)
{ uint32_t numerator = 0; uint32_t denominator = 1; switch( modem ) { case MODEM_FSK: { numerator = 1000U * RadioGetGfskTimeOnAirNumerator( datarate, coderate, preambleLen, fixLen, payloadLen, crcOn ); denominator = datarate; } break; case MODEM_LORA: { numerator = 1000U * RadioGetLoRaTimeOnAirNumerator( bandwidth, datarate, coderate, preambleLen, fixLen, payloadLen, crcOn ); denominator = RadioGetLoRaBandwidthInHz( Bandwidths[bandwidth] ); } break; } return ( numerator + denominator - 1 ) / denominator; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* If Alignment is not a power of two and Alignment is not zero, then ASSERT(). If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT(). */
VOID* EFIAPI AllocateAlignedRuntimePages(IN UINTN Pages, IN UINTN Alignment)
/* If Alignment is not a power of two and Alignment is not zero, then ASSERT(). If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT(). */ VOID* EFIAPI AllocateAlignedRuntimePages(IN UINTN Pages, IN UINTN Alignment)
{ VOID *Buffer; Buffer = InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment); if (Buffer != NULL) { MemoryProfileLibRecord ( (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0), MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RUNTIME_PAGES, EfiRuntimeServicesData, Buffer, EFI_PAGES_TO_SIZE (Pages), NULL ); } return Buffer; }
tianocore/edk2
C++
Other
4,240
/* Calculate the corresponding pci bus address according to the Mem parameter. */
EFI_PHYSICAL_ADDRESS UsbHcGetPciAddressForHostMem(IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size)
/* Calculate the corresponding pci bus address according to the Mem parameter. */ EFI_PHYSICAL_ADDRESS UsbHcGetPciAddressForHostMem(IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size)
{ USBHC_MEM_BLOCK *Head; USBHC_MEM_BLOCK *Block; UINTN AllocSize; EFI_PHYSICAL_ADDRESS PhyAddr; UINTN Offset; Head = Pool->Head; AllocSize = USBHC_MEM_ROUND (Size); if (Mem == NULL) { return 0; } for (Block = Head; Block != NULL; Block = Block->Next) { if ((Block->BufHost <= (UINT8 *)Mem) && (((UINT8 *)Mem + AllocSize) <= (Block->BufHost + Block->BufLen))) { break; } } ASSERT ((Block != NULL)); Offset = (UINT8 *)Mem - Block->BufHost; PhyAddr = (EFI_PHYSICAL_ADDRESS)(UINTN)(Block->Buf + Offset); return PhyAddr; }
tianocore/edk2
C++
Other
4,240
/* If 8-bit I/O port operations are not supported, then ASSERT(). */
UINT8 EFIAPI IoWrite8(IN UINTN Port, IN UINT8 Value)
/* If 8-bit I/O port operations are not supported, then ASSERT(). */ UINT8 EFIAPI IoWrite8(IN UINTN Port, IN UINT8 Value)
{ return (UINT8)IoWriteWorker (Port, SMM_IO_UINT8, Value); }
tianocore/edk2
C++
Other
4,240
/* Perform flash write operation with progress indicator. The start and end completion percentage values are passed into this function. If the requested flash write operation is broken up, then completion percentage between the start and end values may be passed to the provided Progress function. The caller of this function is required to call the Progress function for the start and end completion percentage values. This allows the Progress, StartPercentage, and EndPercentage parameters to be ignored if the requested flash write operation can not be broken up */
EFI_STATUS EFIAPI PerformFlashWriteWithProgress(IN PLATFORM_FIRMWARE_TYPE FirmwareType, IN EFI_PHYSICAL_ADDRESS FlashAddress, IN FLASH_ADDRESS_TYPE FlashAddressType, IN VOID *Buffer, IN UINTN Length, IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress OPTIONAL, IN UINTN StartPercentage, IN UINTN EndPercentage)
/* Perform flash write operation with progress indicator. The start and end completion percentage values are passed into this function. If the requested flash write operation is broken up, then completion percentage between the start and end values may be passed to the provided Progress function. The caller of this function is required to call the Progress function for the start and end completion percentage values. This allows the Progress, StartPercentage, and EndPercentage parameters to be ignored if the requested flash write operation can not be broken up */ EFI_STATUS EFIAPI PerformFlashWriteWithProgress(IN PLATFORM_FIRMWARE_TYPE FirmwareType, IN EFI_PHYSICAL_ADDRESS FlashAddress, IN FLASH_ADDRESS_TYPE FlashAddressType, IN VOID *Buffer, IN UINTN Length, IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress OPTIONAL, IN UINTN StartPercentage, IN UINTN EndPercentage)
{ if (FlashAddressType == FlashAddressTypeRelativeAddress) { FlashAddress = FlashAddress + mInternalFdAddress; } CopyMem ((VOID *)(UINTN)(FlashAddress), Buffer, Length); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Configures the LTDC clock Divider coming from PLLSAI. */
void RCC_LTDCCLKDivConfig(uint32_t RCC_PLLSAIDivR)
/* Configures the LTDC clock Divider coming from PLLSAI. */ void RCC_LTDCCLKDivConfig(uint32_t RCC_PLLSAIDivR)
{ uint32_t tmpreg = 0; assert_param(IS_RCC_PLLSAI_DIVR_VALUE(RCC_PLLSAIDivR)); tmpreg = RCC->DCKCFGR; tmpreg &= ~RCC_DCKCFGR_PLLSAIDIVR; tmpreg |= RCC_PLLSAIDivR; RCC->DCKCFGR = tmpreg; }
MaJerle/stm32f429
C++
null
2,036
/* Sets or clears the selected data port bit. */
void GPIO_WriteBit(GPIO_Module *GPIOx, uint16_t Pin, Bit_OperateType BitCmd)
/* Sets or clears the selected data port bit. */ void GPIO_WriteBit(GPIO_Module *GPIOx, uint16_t Pin, Bit_OperateType BitCmd)
{ assert_param(IS_GPIO_ALL_PERIPH(GPIOx)); assert_param(IS_GET_GPIO_PIN(Pin)); assert_param(IS_GPIO_BIT_OPERATE(BitCmd)); if (BitCmd != Bit_RESET) { GPIOx->PBSC = Pin; } else { GPIOx->PBC = Pin; } }
pikasTech/PikaPython
C++
MIT License
1,403
/* Needed to setup cifs_fattr data for the directory which is the junction to the new submount (ie to setup the fake directory which represents a DFS referral). */
static void cifs_create_dfs_fattr(struct cifs_fattr *fattr, struct super_block *sb)
/* Needed to setup cifs_fattr data for the directory which is the junction to the new submount (ie to setup the fake directory which represents a DFS referral). */ static void cifs_create_dfs_fattr(struct cifs_fattr *fattr, struct super_block *sb)
{ struct cifs_sb_info *cifs_sb = CIFS_SB(sb); cFYI(1, ("creating fake fattr for DFS referral")); memset(fattr, 0, sizeof(*fattr)); fattr->cf_mode = S_IFDIR | S_IXUGO | S_IRWXU; fattr->cf_uid = cifs_sb->mnt_uid; fattr->cf_gid = cifs_sb->mnt_gid; fattr->cf_atime = CURRENT_TIME; fattr->cf_ctime = CURRENT_TIME; fattr->cf_mtime = CURRENT_TIME; fattr->cf_nlink = 2; fattr->cf_flags |= CIFS_FATTR_DFS_REFERRAL; }
robutest/uclinux
C++
GPL-2.0
60
/* 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(LED3); BSP_LED_On(LED4); while(1) { } }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* This API gets the sensitivity of wake up feature in the sensor. */
uint16_t bma423_wakeup_get_sensitivity(uint8_t *sensitivity, struct bma4_dev *dev)
/* This API gets the sensitivity of wake up feature in the sensor. */ uint16_t bma423_wakeup_get_sensitivity(uint8_t *sensitivity, struct bma4_dev *dev)
{ uint8_t feature_config[BMA423_FEATURE_SIZE] = {0}; uint8_t index = BMA423_WAKEUP_OFFSET; uint16_t rslt = BMA4_OK; if (dev != NULL) { if (dev->chip_id == BMA423_CHIP_ID) { rslt = bma4_read_regs(BMA4_FEATURE_CONFIG_ADDR, feature_config, BMA423_FEATURE_SIZE, dev); if (rslt == BMA4_OK) { *sensitivity = BMA4_GET_BITSLICE(feature_config[index], BMA423_WAKEUP_SENS); } } else { rslt = BMA4_E_INVALID_SENSOR; } } else { rslt = BMA4_E_NULL_PTR; } return rslt; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* This function disables the Detector and Generator at same time of the VTC core. */
void XVtc_Disable(XVtc *InstancePtr)
/* This function disables the Detector and Generator at same time of the VTC core. */ void XVtc_Disable(XVtc *InstancePtr)
{ u32 CtrlRegValue; Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); CtrlRegValue = XVtc_ReadReg(InstancePtr->Config.BaseAddress, (XVTC_CTL_OFFSET)); CtrlRegValue &= ~XVTC_CTL_SW_MASK; XVtc_WriteReg(InstancePtr->Config.BaseAddress, (XVTC_CTL_OFFSET), CtrlRegValue); }
ua1arn/hftrx
C++
null
69
/* The block needs writes in both MSW and LSW in order for all data lines to reach their destination. */
static void stu300_wr8(u32 value, void __iomem *address)
/* The block needs writes in both MSW and LSW in order for all data lines to reach their destination. */ static void stu300_wr8(u32 value, void __iomem *address)
{ writel((value << 16) | value, address); }
robutest/uclinux
C++
GPL-2.0
60
/* Retrieves the set of peer addresses for which a bond has been established. */
int ble_store_util_bonded_peers(ble_addr_t *out_peer_id_addrs, int *out_num_peers, int max_peers)
/* Retrieves the set of peer addresses for which a bond has been established. */ int ble_store_util_bonded_peers(ble_addr_t *out_peer_id_addrs, int *out_num_peers, int max_peers)
{ struct ble_store_util_peer_set set = { .peer_id_addrs = out_peer_id_addrs, .num_peers = 0, .max_peers = max_peers, .status = 0, }; int rc; rc = ble_store_iterate(BLE_STORE_OBJ_TYPE_OUR_SEC, ble_store_util_iter_unique_peer, &set); if (rc != 0) { return rc; } if (set.status != 0) { return set.status; } *out_num_peers = set.num_peers; return 0; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Set the target state for a device and starts the state change. */
void dasd_set_target_state(struct dasd_device *device, int target)
/* Set the target state for a device and starts the state change. */ void dasd_set_target_state(struct dasd_device *device, int target)
{ dasd_get_device(device); if (dasd_probeonly && target > DASD_STATE_READY) target = DASD_STATE_READY; if (device->target != target) { if (device->state == target) { wake_up(&dasd_init_waitq); dasd_put_device(device); } device->target = target; } if (device->state != device->target) dasd_change_state(device); }
robutest/uclinux
C++
GPL-2.0
60
/* Selects the GPIO pin used as EXTI Line. */
void EXTI_LineConfig(u8 port_source_gpio, u8 pin_source)
/* Selects the GPIO pin used as EXTI Line. */ void EXTI_LineConfig(u8 port_source_gpio, u8 pin_source)
{ EXTI->CR[pin_source >> 0x02] &= ~(0x0F << (0x04 * (pin_source & 0x03))); EXTI->CR[pin_source >> 0x02] |= ((port_source_gpio) << (0x04 * (pin_source & 0x03))); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The protection flags indicate access permissions as follow: */
uint32_t EEPROMBlockProtectSet(uint32_t ui32Block, uint32_t ui32Protect)
/* The protection flags indicate access permissions as follow: */ uint32_t EEPROMBlockProtectSet(uint32_t ui32Block, uint32_t ui32Protect)
{ ASSERT(ui32Block < BLOCKS_FROM_EESIZE(HWREG(EEPROM_EESIZE))); HWREG(EEPROM_EEBLOCK) = ui32Block; HWREG(EEPROM_EEPROT) = ui32Protect; while (HWREG(EEPROM_EEDONE) & EEPROM_EEDONE_WORKING) { } return (HWREG(EEPROM_EEDONE)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* See if a policy node matches a policy OID. If mapping enabled look through expected policy set otherwise just valid policy. */
int policy_node_match(const X509_POLICY_LEVEL *lvl, const X509_POLICY_NODE *node, const ASN1_OBJECT *oid)
/* See if a policy node matches a policy OID. If mapping enabled look through expected policy set otherwise just valid policy. */ int policy_node_match(const X509_POLICY_LEVEL *lvl, const X509_POLICY_NODE *node, const ASN1_OBJECT *oid)
{ size_t i; ASN1_OBJECT *policy_oid; const X509_POLICY_DATA *x = node->data; if ((lvl->flags & X509_V_FLAG_INHIBIT_MAP) || !(x->flags & POLICY_DATA_FLAG_MAP_MASK)) { if (!OBJ_cmp(x->valid_policy, oid)) return 1; return 0; } for (i = 0; i < sk_ASN1_OBJECT_num(x->expected_policy_set); i++) { policy_oid = sk_ASN1_OBJECT_value(x->expected_policy_set, i); if (!OBJ_cmp(policy_oid, oid)) return 1; } return 0; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function does semi-dirty reads of local alloc size and state! This is ok however, as the values are re-checked once under mutex. */
int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits)
/* This function does semi-dirty reads of local alloc size and state! This is ok however, as the values are re-checked once under mutex. */ int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits)
{ int ret = 0; int la_bits; spin_lock(&osb->osb_lock); la_bits = osb->local_alloc_bits; if (!ocfs2_la_state_enabled(osb)) goto bail; if (bits > (la_bits / 2)) goto bail; ret = 1; bail: mlog(0, "state=%d, bits=%llu, la_bits=%d, ret=%d\n", osb->local_alloc_state, (unsigned long long)bits, la_bits, ret); spin_unlock(&osb->osb_lock); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Downsample pixel values of a single component. This version handles the special case of a full-size component, without smoothing. */
fullsize_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY output_data)
/* Downsample pixel values of a single component. This version handles the special case of a full-size component, without smoothing. */ fullsize_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY output_data)
{ jcopy_sample_rows(input_data, 0, output_data, 0, cinfo->max_v_samp_factor, cinfo->image_width); expand_right_edge(output_data, cinfo->max_v_samp_factor, cinfo->image_width, compptr->width_in_blocks * DCTSIZE); }
nanoframework/nf-interpreter
C++
MIT License
293
/* Set the transport function based on the device type */
static int usbat_set_transport(struct us_data *us, struct usbat_info *info, int devicetype)
/* Set the transport function based on the device type */ static int usbat_set_transport(struct us_data *us, struct usbat_info *info, int devicetype)
{ if (!info->devicetype) info->devicetype = devicetype; if (!info->devicetype) usbat_identify_device(us, info); switch (info->devicetype) { default: return USB_STOR_TRANSPORT_ERROR; case USBAT_DEV_HP8200: us->transport = usbat_hp8200e_transport; break; case USBAT_DEV_FLASH: us->transport = usbat_flash_transport; break; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Configures the processor context with the user-supplied procedure and argument. */
STATIC VOID SetApProcedure(IN CPU_AP_DATA *CpuData, IN EFI_AP_PROCEDURE Procedure, IN VOID *ProcedureArgument)
/* Configures the processor context with the user-supplied procedure and argument. */ STATIC VOID SetApProcedure(IN CPU_AP_DATA *CpuData, IN EFI_AP_PROCEDURE Procedure, IN VOID *ProcedureArgument)
{ ASSERT (CpuData != NULL); ASSERT (Procedure != NULL); CpuData->Parameter = ProcedureArgument; CpuData->Procedure = Procedure; }
tianocore/edk2
C++
Other
4,240
/* cpufreq_suspend - let the low level driver prepare for suspend */
static int cpufreq_suspend(struct sys_device *sysdev, pm_message_t pmsg)
/* cpufreq_suspend - let the low level driver prepare for suspend */ static int cpufreq_suspend(struct sys_device *sysdev, pm_message_t pmsg)
{ int ret = 0; int cpu = sysdev->id; struct cpufreq_policy *cpu_policy; dprintk("suspending cpu %u\n", cpu); if (!cpu_online(cpu)) return 0; cpu_policy = cpufreq_cpu_get(cpu); if (!cpu_policy) return -EINVAL; if (unlikely(cpu_policy->cpu != cpu)) goto out; if (cpufreq_driver->suspend) { ret = cpufreq_driver->suspend(cpu_policy, pmsg); if (ret) printk(KERN_ERR "cpufreq: suspend failed in ->suspend " "step on CPU %u\n", cpu_policy->cpu); } out: cpufreq_cpu_put(cpu_policy); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Return the pipe currently connected to the panel fitter, or -1 if the panel fitter is not present or not in use */
int intel_panel_fitter_pipe(struct drm_device *dev)
/* Return the pipe currently connected to the panel fitter, or -1 if the panel fitter is not present or not in use */ int intel_panel_fitter_pipe(struct drm_device *dev)
{ struct drm_i915_private *dev_priv = dev->dev_private; u32 pfit_control; if (IS_I830(dev)) return -1; pfit_control = I915_READ(PFIT_CONTROL); if ((pfit_control & PFIT_ENABLE) == 0) return -1; if (IS_I965G(dev)) return (pfit_control >> 29) & 0x3; return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* This flush is necessary when a backing file is in use. A crash during an allocating write could result in empty clusters in the image. If the write only touched a subregion of the cluster, then backing image sectors have been lost in the untouched region. The solution is to flush after writing a new data cluster and before updating the L2 table. */
static void qed_aio_write_flush_before_l2_update(void *opaque, int ret)
/* This flush is necessary when a backing file is in use. A crash during an allocating write could result in empty clusters in the image. If the write only touched a subregion of the cluster, then backing image sectors have been lost in the untouched region. The solution is to flush after writing a new data cluster and before updating the L2 table. */ static void qed_aio_write_flush_before_l2_update(void *opaque, int ret)
{ QEDAIOCB *acb = opaque; BDRVQEDState *s = acb_to_s(acb); if (!bdrv_aio_flush(s->bs->file, qed_aio_write_l2_update_cb, opaque)) { qed_aio_complete(acb, -EIO); } }
ve3wwg/teensy3_qemu
C++
Other
15
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
UINT32 EFIAPI PciSegmentBitFieldRead32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit)
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */ UINT32 EFIAPI PciSegmentBitFieldRead32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit)
{ UINTN Count; PCI_SEGMENT_INFO *SegmentInfo; SegmentInfo = GetPciSegmentInfo (&Count); return MmioBitFieldRead32 (PciSegmentLibGetEcamAddress (Address, SegmentInfo, Count), StartBit, EndBit); }
tianocore/edk2
C++
Other
4,240
/* XXX: maybe we should abandon the latter behavior and just require a failure handler. */
static void handle_failed_resolution(struct t3cdev *dev, struct sk_buff_head *arpq)
/* XXX: maybe we should abandon the latter behavior and just require a failure handler. */ static void handle_failed_resolution(struct t3cdev *dev, struct sk_buff_head *arpq)
{ struct sk_buff *skb, *tmp; skb_queue_walk_safe(arpq, skb, tmp) { struct l2t_skb_cb *cb = L2T_SKB_CB(skb); __skb_unlink(skb, arpq); if (cb->arp_failure_handler) cb->arp_failure_handler(dev, skb); else cxgb3_ofld_send(dev, skb); } }
robutest/uclinux
C++
GPL-2.0
60
/* If return is EFI_SUCCESS, the Filehandle is the opened directory's handle; otherwise, the Filehandle is NULL. If the directory already existed, this function opens the existing directory. */
EFI_STATUS EFIAPI ShellCreateDirectory(IN CONST CHAR16 *DirectoryName, OUT SHELL_FILE_HANDLE *FileHandle)
/* If return is EFI_SUCCESS, the Filehandle is the opened directory's handle; otherwise, the Filehandle is NULL. If the directory already existed, this function opens the existing directory. */ EFI_STATUS EFIAPI ShellCreateDirectory(IN CONST CHAR16 *DirectoryName, OUT SHELL_FILE_HANDLE *FileHandle)
{ if (gEfiShellProtocol != NULL) { return (gEfiShellProtocol->CreateFile ( DirectoryName, EFI_FILE_DIRECTORY, FileHandle )); } else { return (ShellOpenFileByName ( DirectoryName, FileHandle, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, EFI_FILE_DIRECTORY )); } }
tianocore/edk2
C++
Other
4,240
/* Fuse bank 1 row 9 is "reserved for future use" and therefore available for customer use. The APF27 board revision 1 uses the bit 0 to permanently store the presence of the second RAM chip 0: AFP27 with 1 RAM of 64 MiB 1: AFP27 with 2 RAM chips of 64 MiB each (128MB) */
static int get_num_ram_bank(void)
/* Fuse bank 1 row 9 is "reserved for future use" and therefore available for customer use. The APF27 board revision 1 uses the bit 0 to permanently store the presence of the second RAM chip 0: AFP27 with 1 RAM of 64 MiB 1: AFP27 with 2 RAM chips of 64 MiB each (128MB) */ static int get_num_ram_bank(void)
{ struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE; int nr_dram_banks = 1; if ((get_board_rev() > 0) && (CONFIG_NR_DRAM_BANKS > 1)) nr_dram_banks += readl(&iim->bank[1].fuse_regs[9]) & 0x01; else nr_dram_banks = CONFIG_NR_DRAM_POPULATED; return nr_dram_banks; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Configures maximum size of message payload, which can be stored either in dedicated transmit buffer or into transmit queue/FIFO. One size is applied both to transmit buffer and transmit queue / FIFO. Buffers can only be configured to sizes which are valid sizes of FDCAN payload. Sizes smaller than 8 are automatically padded to 8 bytes. */
int fdcan_set_tx_element_size(uint32_t canport, uint8_t txbuf)
/* Configures maximum size of message payload, which can be stored either in dedicated transmit buffer or into transmit queue/FIFO. One size is applied both to transmit buffer and transmit queue / FIFO. Buffers can only be configured to sizes which are valid sizes of FDCAN payload. Sizes smaller than 8 are automatically padded to 8 bytes. */ int fdcan_set_tx_element_size(uint32_t canport, uint8_t txbuf)
{ unsigned txbufdlc = fdcan_length_to_dlc(txbuf); if (txbufdlc == 0xFF) { return FDCAN_E_INVALID; } if (txbufdlc <= 8) { txbufdlc = 0; } else { txbufdlc &= ~(1 << 4); } FDCAN_TXESC(canport) = txbufdlc << FDCAN_TXESC_TBDS_SHIFT; return FDCAN_E_OK; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Enables ISO7816 smart card mode on the specified UART. */
void UARTSmartCardEnable(uint32_t ui32Base)
/* Enables ISO7816 smart card mode on the specified UART. */ void UARTSmartCardEnable(uint32_t ui32Base)
{ uint32_t ui32Val; ASSERT(_UARTBaseValid(ui32Base)); ui32Val = HWREG(ui32Base + UART_O_LCRH); ui32Val &= ~(UART_LCRH_SPS | UART_LCRH_EPS | UART_LCRH_PEN | UART_LCRH_WLEN_M); ui32Val |= UART_LCRH_WLEN_8 | UART_LCRH_PEN | UART_LCRH_EPS | UART_LCRH_STP2; HWREG(ui32Base + UART_O_LCRH) = ui32Val; HWREG(ui32Base + UART_O_CTL) |= UART_CTL_SMART; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Return the bit offset in bitmap of the allocated region, or -errno on failure. */
int bitmap_find_free_region(unsigned long *bitmap, int bits, int order)
/* Return the bit offset in bitmap of the allocated region, or -errno on failure. */ int bitmap_find_free_region(unsigned long *bitmap, int bits, int order)
{ int pos, end; for (pos = 0 ; (end = pos + (1 << order)) <= bits; pos = end) { if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE)) continue; __reg_op(bitmap, pos, order, REG_OP_ALLOC); return pos; } return -ENOMEM; }
robutest/uclinux
C++
GPL-2.0
60
/* This is a helper function which notifies all subscribers about a volume change event (creation, removal, re-sizing, re-naming, updating). Returns zero in case of success and a negative error code in case of failure. */
int ubi_volume_notify(struct ubi_device *ubi, struct ubi_volume *vol, int ntype)
/* This is a helper function which notifies all subscribers about a volume change event (creation, removal, re-sizing, re-naming, updating). Returns zero in case of success and a negative error code in case of failure. */ int ubi_volume_notify(struct ubi_device *ubi, struct ubi_volume *vol, int ntype)
{ int ret; struct ubi_notification nt; ubi_do_get_device_info(ubi, &nt.di); ubi_do_get_volume_info(ubi, vol, &nt.vi); switch (ntype) { case UBI_VOLUME_ADDED: case UBI_VOLUME_REMOVED: case UBI_VOLUME_RESIZED: case UBI_VOLUME_RENAMED: ret = ubi_update_fastmap(ubi); if (ret) ubi_msg(ubi, "Unable to write a new fastmap: %i", ret); } return blocking_notifier_call_chain(&ubi_notifiers, ntype, &nt); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Received data frames from IR-port, so we just pass them up to IrLMP for further processing */
void irlap_data_indication(struct irlap_cb *self, struct sk_buff *skb, int unreliable)
/* Received data frames from IR-port, so we just pass them up to IrLMP for further processing */ void irlap_data_indication(struct irlap_cb *self, struct sk_buff *skb, int unreliable)
{ skb_pull(skb, LAP_ADDR_HEADER+LAP_CTRL_HEADER); irlmp_link_data_indication(self->notify.instance, skb, unreliable); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* User-defined threshold value for xl interrupt event on generator. Data format is the same of output data raw: two’s complement with 1LSb = 1.5mG.. */
int32_t iis2mdc_int_gen_treshold_set(stmdev_ctx_t *ctx, int16_t val)
/* User-defined threshold value for xl interrupt event on generator. Data format is the same of output data raw: two’s complement with 1LSb = 1.5mG.. */ int32_t iis2mdc_int_gen_treshold_set(stmdev_ctx_t *ctx, int16_t val)
{ uint8_t buff[2]; int32_t ret; buff[1] = (uint8_t) ((uint16_t)val / 256U); buff[0] = (uint8_t) ((uint16_t)val - (buff[1] * 256U)); ret = iis2mdc_write_reg(ctx, IIS2MDC_INT_THS_L_REG, buff, 2); return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* This adds a single pci device to the global device list and adds sysfs and procfs entries */
int pci_bus_add_device(struct pci_dev *dev)
/* This adds a single pci device to the global device list and adds sysfs and procfs entries */ int pci_bus_add_device(struct pci_dev *dev)
{ int retval; retval = device_add(&dev->dev); if (retval) return retval; dev->is_added = 1; pci_proc_attach_device(dev); pci_create_sysfs_dev_files(dev); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Calibrate for too-slow or too-fast oscillator. If no correction is needed, set value to zero. */
enum status_code rtc_count_frequency_correction(struct rtc_module *const module, const int8_t value)
/* Calibrate for too-slow or too-fast oscillator. If no correction is needed, set value to zero. */ enum status_code rtc_count_frequency_correction(struct rtc_module *const module, const int8_t value)
{ Assert(module); Assert(module->hw); Rtc *const rtc_module = module->hw; if (abs(value) > 0x7F) { return STATUS_ERR_INVALID_ARG; } uint32_t new_correction_value; new_correction_value = abs(value); if (value < 0) { new_correction_value |= RTC_FREQCORR_SIGN; } while (rtc_count_is_syncing(module)) { } rtc_module->MODE0.FREQCORR.reg = new_correction_value; while (rtc_count_is_syncing(module)) { } return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* Event function to signal to this module that the entire transfer, initiated by TbxMbUartTransmit, completed. */
void TbxMbUartTransmitComplete(tTbxMbUartPort port)
/* Event function to signal to this module that the entire transfer, initiated by TbxMbUartTransmit, completed. */ void TbxMbUartTransmitComplete(tTbxMbUartPort port)
{ TBX_ASSERT(port < TBX_MB_UART_NUM_PORT); if (port < TBX_MB_UART_NUM_PORT) { if (uartInfo[port].transmitCompleteFcn != NULL) { uartInfo[port].transmitCompleteFcn(port); } } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Enables or disables the Low Speed APB (APB1) peripheral clock. */
void RCC_EnableAPB1PeriphClk(uint32_t RCC_APB1Periph, FunctionalState Cmd)
/* Enables or disables the Low Speed APB (APB1) peripheral clock. */ void RCC_EnableAPB1PeriphClk(uint32_t RCC_APB1Periph, FunctionalState Cmd)
{ assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph)); assert_param(IS_FUNCTIONAL_STATE(Cmd)); if (Cmd != DISABLE) { RCC->APB1PCLKEN |= RCC_APB1Periph; } else { RCC->APB1PCLKEN &= ~RCC_APB1Periph; } }
pikasTech/PikaPython
C++
MIT License
1,403
/* Sets the Mailbox mode. Needs the I2C Password presentation to be effective. */
int32_t BSP_NFCTAG_WriteMBMode(uint32_t Instance, const ST25DV_EN_STATUS MB_mode)
/* Sets the Mailbox mode. Needs the I2C Password presentation to be effective. */ int32_t BSP_NFCTAG_WriteMBMode(uint32_t Instance, const ST25DV_EN_STATUS MB_mode)
{ UNUSED(Instance); return ST25DV_WriteMBMode(&NfcTagObj, MB_mode); }
eclipse-threadx/getting-started
C++
Other
310
/* Enable the DMA of the specified SPI port. The */
void xSPIDMAEnable(unsigned long ulBase, unsigned long ulDmaMode)
/* Enable the DMA of the specified SPI port. The */ void xSPIDMAEnable(unsigned long ulBase, unsigned long ulDmaMode)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE)||(ulBase == SPI3_BASE) ); xHWREG(ulBase + SPI_DMACTL) |= ulDmaMode; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* acpi_enable_wakeup_device_prep - prepare wakeup devices @sleep_state: ACPI state Enable all wakup devices power if the devices' wakeup level is higher than requested sleep level */
void acpi_enable_wakeup_device_prep(u8 sleep_state)
/* acpi_enable_wakeup_device_prep - prepare wakeup devices @sleep_state: ACPI state Enable all wakup devices power if the devices' wakeup level is higher than requested sleep level */ void acpi_enable_wakeup_device_prep(u8 sleep_state)
{ struct list_head *node, *next; list_for_each_safe(node, next, &acpi_wakeup_device_list) { struct acpi_device *dev = container_of(node, struct acpi_device, wakeup_list); if (!dev->wakeup.flags.valid || !dev->wakeup.state.enabled || (sleep_state > (u32) dev->wakeup.sleep_state)) continue; acpi_enable_wakeup_device_power(dev, sleep_state); } }
robutest/uclinux
C++
GPL-2.0
60
/* Get the AML_BYTE_ENCODING entry in the field encoding table by providing an OpCode/SubOpCode couple. */
CONST AML_BYTE_ENCODING* EFIAPI AmlGetFieldEncodingByOpCode(IN UINT8 OpCode, IN UINT8 SubOpCode)
/* Get the AML_BYTE_ENCODING entry in the field encoding table by providing an OpCode/SubOpCode couple. */ CONST AML_BYTE_ENCODING* EFIAPI AmlGetFieldEncodingByOpCode(IN UINT8 OpCode, IN UINT8 SubOpCode)
{ UINT32 Index; for (Index = 0; Index < (sizeof (mAmlFieldEncoding) / sizeof (mAmlFieldEncoding[0])); Index++) { if ((mAmlFieldEncoding[Index].OpCode == OpCode) && (mAmlFieldEncoding[Index].SubOpCode == SubOpCode)) { return &mAmlFieldEncoding[Index]; } } return NULL; }
tianocore/edk2
C++
Other
4,240
/* Disables Source address filtering. When disabled GMAC forwards the received frames with updated SAMatch bit in RxStatus. */
void synopGMAC_src_addr_filter_disable(synopGMACdevice *gmacdev)
/* Disables Source address filtering. When disabled GMAC forwards the received frames with updated SAMatch bit in RxStatus. */ void synopGMAC_src_addr_filter_disable(synopGMACdevice *gmacdev)
{ synopGMACClearBits(gmacdev->MacBase, GmacFrameFilter, GmacSrcAddrFilter); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* fc_set_mfs() - Set the maximum frame size for a local port @lport: The local port to set the MFS for @mfs: The new MFS */
int fc_set_mfs(struct fc_lport *lport, u32 mfs)
/* fc_set_mfs() - Set the maximum frame size for a local port @lport: The local port to set the MFS for @mfs: The new MFS */ int fc_set_mfs(struct fc_lport *lport, u32 mfs)
{ unsigned int old_mfs; int rc = -EINVAL; mutex_lock(&lport->lp_mutex); old_mfs = lport->mfs; if (mfs >= FC_MIN_MAX_FRAME) { mfs &= ~3; if (mfs > FC_MAX_FRAME) mfs = FC_MAX_FRAME; mfs -= sizeof(struct fc_frame_header); lport->mfs = mfs; rc = 0; } if (!rc && mfs < old_mfs) fc_lport_enter_reset(lport); mutex_unlock(&lport->lp_mutex); return rc; }
robutest/uclinux
C++
GPL-2.0
60
/* vx_setup_pseudo_dma - set up the pseudo dma read/write mode. @do_write: 0 = read, 1 = set up for DMA write */
static void vx2_setup_pseudo_dma(struct vx_core *chip, int do_write)
/* vx_setup_pseudo_dma - set up the pseudo dma read/write mode. @do_write: 0 = read, 1 = set up for DMA write */ static void vx2_setup_pseudo_dma(struct vx_core *chip, int do_write)
{ vx_outl(chip, ICR, do_write ? ICR_TREQ : ICR_RREQ); vx_outl(chip, RESET_DMA, 0); }
robutest/uclinux
C++
GPL-2.0
60
/* In all cases, the width of the pulses generated is governed by the */
void EMACTimestampPPSCommand(uint32_t ui32Base, uint8_t ui8Cmd)
/* In all cases, the width of the pulses generated is governed by the */ void EMACTimestampPPSCommand(uint32_t ui32Base, uint8_t ui8Cmd)
{ ASSERT(ui32Base == EMAC0_BASE); while(HWREG(ui32Base + EMAC_O_PPSCTRL) & EMAC_PPSCTRL_PPSCTRL_M) { } HWREG(ui32Base + EMAC_O_PPSCTRL) = (EMAC_PPSCTRL_PPSEN0 | ui8Cmd); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set the maximum inode count for this filesystem */
STATIC void xfs_set_maxicount(xfs_mount_t *mp)
/* Set the maximum inode count for this filesystem */ STATIC void xfs_set_maxicount(xfs_mount_t *mp)
{ xfs_sb_t *sbp = &(mp->m_sb); __uint64_t icount; if (sbp->sb_imax_pct) { icount = sbp->sb_dblocks * sbp->sb_imax_pct; do_div(icount, 100); do_div(icount, mp->m_ialloc_blks); mp->m_maxicount = (icount * mp->m_ialloc_blks) << sbp->sb_inopblog; } else { mp->m_maxicount = 0; } }
robutest/uclinux
C++
GPL-2.0
60
/* Cause a EXTI Event trigger for a sample sequence of Regualr channel. */
void ADCExtiEventReguTrigger(unsigned long ulBase)
/* Cause a EXTI Event trigger for a sample sequence of Regualr channel. */ void ADCExtiEventReguTrigger(unsigned long ulBase)
{ xASSERT((ulBase == ADC1_BASE) || (ulBase == ADC2_BASE) || (ulBase == ADC3_BASE)); xHWREG(ulBase + ADC_CR2) |= ADC_CR2_EXTTRIG; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* @x0: x value of point 0 @y0: y value of point 0 @x1: x value of point 1 @y1: y value of point 1 @x: the linear interpolant */
static int ntc_fixp_linear_interpolate(int x0, int y0, int x1, int y1, int x)
/* @x0: x value of point 0 @y0: y value of point 0 @x1: x value of point 1 @y1: y value of point 1 @x: the linear interpolant */ static int ntc_fixp_linear_interpolate(int x0, int y0, int x1, int y1, int x)
{ if (y0 == y1 || x == x0) { return y0; } if (x1 == x0 || x == x1) { return y1; } return y0 + ((y1 - y0) * (x - x0) / (x1 - x0)); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* This file is part of the Simba project. */
int test_map(void)
/* This file is part of the Simba project. */ int test_map(void)
{ BTASSERT(midi_note_to_frequency(0) == 8.1757989156f); return (0); }
eerimoq/simba
C++
Other
337
/* parport_ip32_epp_read_addr - read a block of addresses in EPP mode */
static size_t parport_ip32_epp_read_addr(struct parport *p, void *buf, size_t len, int flags)
/* parport_ip32_epp_read_addr - read a block of addresses in EPP mode */ static size_t parport_ip32_epp_read_addr(struct parport *p, void *buf, size_t len, int flags)
{ struct parport_ip32_private * const priv = p->physport->private_data; return parport_ip32_epp_read(priv->regs.eppAddr, p, buf, len, flags); }
robutest/uclinux
C++
GPL-2.0
60
/* Checks if there is new accel/gyro data available for read. */
bool IMU_isDataReady(void)
/* Checks if there is new accel/gyro data available for read. */ bool IMU_isDataReady(void)
{ bool ready; if( IMU_state != IMU_STATE_READY ){ return false; } ready = ICM20648_isDataReady(); IMU_isDataReadyQueryCount++; if( ready ) { IMU_isDataReadyTrueCount++; } return ready; }
remotemcu/remcu-chip-sdks
C++
null
436
/* amd_set_pio_mode() is a callback from upper layers for PIO-only tuning. */
static void amd_set_pio_mode(ide_drive_t *drive, const u8 pio)
/* amd_set_pio_mode() is a callback from upper layers for PIO-only tuning. */ static void amd_set_pio_mode(ide_drive_t *drive, const u8 pio)
{ amd_set_drive(drive, XFER_PIO_0 + pio); }
robutest/uclinux
C++
GPL-2.0
60
/* Removes an interrupt handler for the specified PWM generator block. */
void PWMGenIntUnregister(uint32_t ui32Base, uint32_t ui32Gen)
/* Removes an interrupt handler for the specified PWM generator block. */ void PWMGenIntUnregister(uint32_t ui32Base, uint32_t ui32Gen)
{ uint32_t ui32Int; ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE)); ASSERT(_PWMGenValid(ui32Gen)); ui32Int = _PWMGenIntNumberGet(ui32Base, ui32Gen); ASSERT(ui32Int != 0); IntDisable(ui32Int); IntUnregister(ui32Int); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Return 0 to measure. Return 1 if already measured. For matching a DONT_MEASURE policy, no policy, or other error, return an error code. */
int ima_must_measure(struct ima_iint_cache *iint, struct inode *inode, int mask, int function)
/* Return 0 to measure. Return 1 if already measured. For matching a DONT_MEASURE policy, no policy, or other error, return an error code. */ int ima_must_measure(struct ima_iint_cache *iint, struct inode *inode, int mask, int function)
{ int must_measure; if (iint->flags & IMA_MEASURED) return 1; must_measure = ima_match_policy(inode, function, mask); return must_measure ? 0 : -EACCES; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* param base Pointer to the FLEXIO_SPI_Type structure. param mask interrupt source The parameter can be any combination of the following values: arg kFLEXIO_SPI_RxFullInterruptEnable arg kFLEXIO_SPI_TxEmptyInterruptEnable */
void FLEXIO_SPI_DisableInterrupts(FLEXIO_SPI_Type *base, uint32_t mask)
/* param base Pointer to the FLEXIO_SPI_Type structure. param mask interrupt source The parameter can be any combination of the following values: arg kFLEXIO_SPI_RxFullInterruptEnable arg kFLEXIO_SPI_TxEmptyInterruptEnable */ void FLEXIO_SPI_DisableInterrupts(FLEXIO_SPI_Type *base, uint32_t mask)
{ if ((mask & (uint32_t)kFLEXIO_SPI_TxEmptyInterruptEnable) != 0U) { FLEXIO_DisableShifterStatusInterrupts(base->flexioBase, 1UL << base->shifterIndex[0]); } if ((mask & (uint32_t)kFLEXIO_SPI_RxFullInterruptEnable) != 0U) { FLEXIO_DisableShifterStatusInterrupts(base->flexioBase, 1UL << base->shifterIndex[1]); } }
eclipse-threadx/getting-started
C++
Other
310
/* Sets the PWM output of the specified channel. */
err_t pca9685SetPWM(uint16_t channel, uint16_t on, uint16_t off)
/* Sets the PWM output of the specified channel. */ err_t pca9685SetPWM(uint16_t channel, uint16_t on, uint16_t off)
{ ASSERT(_pca9685Initialised, ERROR_DEVICENOTINITIALISED); if (on > 0xFFF) { on = 0xFFF; } if (off < on) { off = on; } if (off > 0xFFF) { off = 0xFFF; } ASSERT_STATUS(pca9685Write8(PCA9685_REG_LED0_ON_L+4*channel, on & 0xFF)); ASSERT_STATUS(pca9685Write8(PCA9685_REG_LED0_ON_H+4*channel, on >> 8)); ASSERT_STATUS(pca9685Write8(PCA9685_REG_LED0_OFF_L+4*channel, off & 0xFF)); ASSERT_STATUS(pca9685Write8(PCA9685_REG_LED0_OFF_H+4*channel, off >> 8)); return ERROR_NONE; }
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
UINT32 EFIAPI S3PciBitFieldRead32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */ UINT32 EFIAPI S3PciBitFieldRead32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
{ return InternalSavePciWrite32ValueToBootScript (Address, PciBitFieldRead32 (Address, StartBit, EndBit)); }
tianocore/edk2
C++
Other
4,240
/* p9_idpool_create - create a new per-connection id pool */
struct p9_idpool* p9_idpool_create(void)
/* p9_idpool_create - create a new per-connection id pool */ struct p9_idpool* p9_idpool_create(void)
{ struct p9_idpool *p; p = kmalloc(sizeof(struct p9_idpool), GFP_KERNEL); if (!p) return ERR_PTR(-ENOMEM); spin_lock_init(&p->lock); idr_init(&p->pool); return p; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* driver_detach - detach driver from all devices it controls. @drv: driver. */
void driver_detach(struct device_driver *drv)
/* driver_detach - detach driver from all devices it controls. @drv: driver. */ void driver_detach(struct device_driver *drv)
{ struct device_private *dev_prv; struct device *dev; for (;;) { spin_lock(&drv->p->klist_devices.k_lock); if (list_empty(&drv->p->klist_devices.k_list)) { spin_unlock(&drv->p->klist_devices.k_lock); break; } dev_prv = list_entry(drv->p->klist_devices.k_list.prev, struct device_private, knode_driver.n_node); dev = dev_prv->device; get_device(dev); spin_unlock(&drv->p->klist_devices.k_lock); if (dev->parent) down(&dev->parent->sem); down(&dev->sem); if (dev->driver == drv) __device_release_driver(dev); up(&dev->sem); if (dev->parent) up(&dev->parent->sem); put_device(dev); } }
robutest/uclinux
C++
GPL-2.0
60
/* Get the attempt config data from global structure by the ConfigIndex. */
ISCSI_ATTEMPT_CONFIG_NVDATA* IScsiConfigGetAttemptByConfigIndex(IN UINT8 AttemptConfigIndex)
/* Get the attempt config data from global structure by the ConfigIndex. */ ISCSI_ATTEMPT_CONFIG_NVDATA* IScsiConfigGetAttemptByConfigIndex(IN UINT8 AttemptConfigIndex)
{ LIST_ENTRY *Entry; ISCSI_ATTEMPT_CONFIG_NVDATA *Attempt; NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) { Attempt = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link); if (Attempt->AttemptConfigIndex == AttemptConfigIndex) { return Attempt; } } return NULL; }
tianocore/edk2
C++
Other
4,240
/* "Delete" a neighbour. The neighbour is only removed if the number of nodes that may use it is zero. */
static int nr_del_neigh(ax25_address *callsign, struct net_device *dev, unsigned int quality)
/* "Delete" a neighbour. The neighbour is only removed if the number of nodes that may use it is zero. */ static int nr_del_neigh(ax25_address *callsign, struct net_device *dev, unsigned int quality)
{ struct nr_neigh *nr_neigh; nr_neigh = nr_neigh_get_dev(callsign, dev); if (nr_neigh == NULL) return -EINVAL; nr_neigh->quality = quality; nr_neigh->locked = 0; if (nr_neigh->count == 0) nr_remove_neigh(nr_neigh); nr_neigh_put(nr_neigh); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* IDL typedef struct { IDL LOGON_IDENTITY_INFO identity_info; IDL LM_OWF_PASSWORD lmpassword; IDL NT_OWF_PASSWORD ntpassword; IDL } INTERACTIVE_INFO; */
static int netlogon_dissect_INTERACTIVE_INFO(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
/* IDL typedef struct { IDL LOGON_IDENTITY_INFO identity_info; IDL LM_OWF_PASSWORD lmpassword; IDL NT_OWF_PASSWORD ntpassword; IDL } INTERACTIVE_INFO; */ static int netlogon_dissect_INTERACTIVE_INFO(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
{ offset = netlogon_dissect_LOGON_IDENTITY_INFO(tvb, offset, pinfo, tree, di, drep); offset = netlogon_dissect_LM_OWF_PASSWORD(tvb, offset, pinfo, tree, di, drep); offset = netlogon_dissect_NT_OWF_PASSWORD(tvb, offset, pinfo, tree, di, drep); return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Add a single character to the jwt buffer. Detects overflow, and always keeps the buffer null terminated. */
static void base64_outch(struct jwt_builder *st, char ch)
/* Add a single character to the jwt buffer. Detects overflow, and always keeps the buffer null terminated. */ static void base64_outch(struct jwt_builder *st, char ch)
{ if (st->overflowed) { return; } if (st->len < 2) { st->overflowed = true; return; } *st->buf++ = ch; st->len--; *st->buf = 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* The tasks as described in the comments at the top of this file. */
static void prvQueueReceiveTask(void *pvParameters)
/* The tasks as described in the comments at the top of this file. */ static void prvQueueReceiveTask(void *pvParameters)
{ unsigned long ulReceivedValue; for( ;; ) { xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY ); if( ulReceivedValue == 100UL ) { ulReceived++; } } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* To use this function, the caller must first call the */
EFI_STATUS EFIAPI ShellFindNextFile(IN SHELL_FILE_HANDLE DirHandle, OUT EFI_FILE_INFO *Buffer, OUT BOOLEAN *NoFile)
/* To use this function, the caller must first call the */ EFI_STATUS EFIAPI ShellFindNextFile(IN SHELL_FILE_HANDLE DirHandle, OUT EFI_FILE_INFO *Buffer, OUT BOOLEAN *NoFile)
{ return (FileHandleFindNextFile (DirHandle, Buffer, NoFile)); }
tianocore/edk2
C++
Other
4,240
/* Enables or disables the EOC on each regular channel conversion. */
void ADC_EOCOnEachRegularChannelCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
/* Enables or disables the EOC on each regular channel conversion. */ void ADC_EOCOnEachRegularChannelCmd(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_EOCS; } else { ADCx->CR2 &= (uint32_t)(~ADC_CR2_EOCS); } }
MaJerle/stm32f429
C++
null
2,036
/* ADC Software Triggered Conversion on Regular Channels. Special F1 Note this is a software trigger and requires triggering to be enabled and the trigger source to be set appropriately otherwise conversion will not start. This is not the same as the ADC start conversion operation. */
void adc_start_conversion_regular(uint32_t adc)
/* ADC Software Triggered Conversion on Regular Channels. Special F1 Note this is a software trigger and requires triggering to be enabled and the trigger source to be set appropriately otherwise conversion will not start. This is not the same as the ADC start conversion operation. */ void adc_start_conversion_regular(uint32_t adc)
{ ADC_CR2(adc) |= ADC_CR2_SWSTART; while (ADC_CR2(adc) & ADC_CR2_SWSTART); }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* This API configures ADC module to be ready for convert the input from selected channel. */
void ADC_Open(ADC_T *adc, uint32_t u32InputMode, uint32_t u32OpMode, uint32_t u32ChMask)
/* This API configures ADC module to be ready for convert the input from selected channel. */ void ADC_Open(ADC_T *adc, uint32_t u32InputMode, uint32_t u32OpMode, uint32_t u32ChMask)
{ if ((adc->ADCALSTSR & ADC_ADCALSTSR_CALIF_Msk) == 0) { adc->ADCR |= ADC_ADCR_RESET_Msk; while((adc->ADCR & ADC_ADCR_RESET_Msk) == ADC_ADCR_RESET_Msk); adc->ADCALSTSR |= ADC_ADCALSTSR_CALIF_Msk; adc->ADCALR |= ADC_ADCALR_CALEN_Msk; ADC_START_CONV(adc); while((adc->ADCALSTSR & ADC_ADCALSTSR_CALIF_Msk) != ADC_ADCALSTSR_CALIF_Msk); } adc->ADCR = (adc->ADCR & (~(ADC_ADCR_DIFFEN_Msk | ADC_ADCR_ADMD_Msk))) | \ (u32InputMode) | \ (u32OpMode); adc->ADCHER = (adc->ADCHER & ~ADC_ADCHER_CHEN_Msk) | (u32ChMask); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Filter the received packet using the source Ip. */
BOOLEAN PxeBcFilterBySrcIp(IN EFI_PXE_BASE_CODE_MODE *Mode, IN VOID *Session, IN OUT EFI_IP_ADDRESS *SrcIp, IN UINT16 OpFlags)
/* Filter the received packet using the source Ip. */ BOOLEAN PxeBcFilterBySrcIp(IN EFI_PXE_BASE_CODE_MODE *Mode, IN VOID *Session, IN OUT EFI_IP_ADDRESS *SrcIp, IN UINT16 OpFlags)
{ if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP) != 0) { if (SrcIp != NULL) { if (Mode->UsingIpv6) { CopyMem ( SrcIp, &((EFI_UDP6_SESSION_DATA *)Session)->SourceAddress, sizeof (EFI_IPv6_ADDRESS) ); } else { ZeroMem (SrcIp, sizeof (EFI_IP_ADDRESS)); CopyMem ( SrcIp, &((EFI_UDP4_SESSION_DATA *)Session)->SourceAddress, sizeof (EFI_IPv4_ADDRESS) ); } } return TRUE; } else if ((SrcIp != NULL) && (EFI_IP4_EQUAL (SrcIp, &((EFI_UDP4_SESSION_DATA *)Session)->SourceAddress) || EFI_IP6_EQUAL (SrcIp, &((EFI_UDP6_SESSION_DATA *)Session)->SourceAddress))) { return TRUE; } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* Read magnetometer device ID. This function reads the magnetometer hardware identification registers and returns these values to the addresses specified in the function parameters. */
static bool hmc5883l_device_id(sensor_hal_t *hal, sensor_data_t *data)
/* Read magnetometer device ID. This function reads the magnetometer hardware identification registers and returns these values to the addresses specified in the function parameters. */ static bool hmc5883l_device_id(sensor_hal_t *hal, sensor_data_t *data)
{ uint32_t id_reg = 0; size_t const id_len = 3; size_t const count = sensor_bus_read (hal, HMC5883L_ID_REG_A, &id_reg, id_len); data->device.id = cpu_to_be32(id_reg) >> 8; data->device.version = 0; return (count == id_len); }
memfault/zero-to-main
C++
null
200
/* This function use to enable smartcard module UART mode and set baudrate. HIDDEN_SYMBOLS */
uint32_t SCUART_Open(SC_T *sc, uint32_t u32baudrate)
/* This function use to enable smartcard module UART mode and set baudrate. HIDDEN_SYMBOLS */ uint32_t SCUART_Open(SC_T *sc, uint32_t u32baudrate)
{ uint32_t u32Clk = SCUART_GetClock(sc), u32Div; u32Div = (u32Clk + (u32baudrate >> 1) - 1UL) / u32baudrate - 1UL; sc->CTL = SC_CTL_SCEN_Msk | SC_CTL_NSB_Msk; sc->UARTCTL = SCUART_CHAR_LEN_8 | SCUART_PARITY_NONE | SC_UARTCTL_UARTEN_Msk; sc->ETUCTL = u32Div; return (u32Clk / (u32Div + 1UL)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This API is used to configure the down sampling ratios of the accel and gyro data for FIFO.Also, it configures filtered or pre-filtered data for accel and gyro. */
int8_t bmi160_set_fifo_down(uint8_t fifo_down, const struct bmi160_dev *dev)
/* This API is used to configure the down sampling ratios of the accel and gyro data for FIFO.Also, it configures filtered or pre-filtered data for accel and gyro. */ int8_t bmi160_set_fifo_down(uint8_t fifo_down, const struct bmi160_dev *dev)
{ int8_t rslt = 0; uint8_t data = 0; uint8_t reg_addr = BMI160_FIFO_DOWN_ADDR; if (dev == NULL) { rslt = BMI160_E_NULL_PTR; } else { rslt = bmi160_get_regs(reg_addr, &data, BMI160_ONE, dev); if (rslt == BMI160_OK) { data = data | fifo_down; rslt = bmi160_set_regs(reg_addr, &data, BMI160_ONE, dev); } } return rslt; }
eclipse-threadx/getting-started
C++
Other
310
/* check whether the region which is pointed by address */
bool _flash_is_locked(struct _flash_device *const device, const uint32_t dst_addr)
/* check whether the region which is pointed by address */ bool _flash_is_locked(struct _flash_device *const device, const uint32_t dst_addr)
{ uint16_t region_id; region_id = dst_addr / (NVMCTRL_FLASH_SIZE / 16); return !(hri_nvmctrl_get_LOCK_reg(device->hw, 1 << region_id)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Check for loss of link and link establishment. Can not use mii_check_media because it does nothing if mode is forced. */
static void pcnet32_watchdog(struct net_device *)
/* Check for loss of link and link establishment. Can not use mii_check_media because it does nothing if mode is forced. */ static void pcnet32_watchdog(struct net_device *)
{ struct pcnet32_private *lp = netdev_priv(dev); unsigned long flags; spin_lock_irqsave(&lp->lock, flags); pcnet32_check_media(dev, 0); spin_unlock_irqrestore(&lp->lock, flags); mod_timer(&lp->watchdog_timer, round_jiffies(PCNET32_WATCHDOG_TIMEOUT)); }
robutest/uclinux
C++
GPL-2.0
60
/* This function registers ciphers and digests used directly and indirectly by SSL/TLS, and initializes the readable error messages. This function must be called before any other action takes places. */
BOOLEAN EFIAPI CryptoServiceTlsInitialize(VOID)
/* This function registers ciphers and digests used directly and indirectly by SSL/TLS, and initializes the readable error messages. This function must be called before any other action takes places. */ BOOLEAN EFIAPI CryptoServiceTlsInitialize(VOID)
{ return CALL_BASECRYPTLIB (Tls.Services.Initialize, TlsInitialize, (), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Alpha specific irq code. Performance counter hook. A module can override this to do something useful. */
static void dummy_perf(unsigned long vector, struct pt_regs *regs)
/* Alpha specific irq code. Performance counter hook. A module can override this to do something useful. */ static void dummy_perf(unsigned long vector, struct pt_regs *regs)
{ irq_err_count++; printk(KERN_CRIT "Performance counter interrupt!\n"); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Remove the hcd structure, and release resources that has been requested during probe. */
static int ehci_hcd_xilinx_of_remove(struct of_device *op)
/* Remove the hcd structure, and release resources that has been requested during probe. */ static int ehci_hcd_xilinx_of_remove(struct of_device *op)
{ struct usb_hcd *hcd = dev_get_drvdata(&op->dev); dev_set_drvdata(&op->dev, NULL); dev_dbg(&op->dev, "stopping XILINX-OF USB Controller\n"); usb_remove_hcd(hcd); iounmap(hcd->regs); release_mem_region(hcd->rsrc_start, hcd->rsrc_len); usb_put_hcd(hcd); return 0; }
robutest/uclinux
C++
GPL-2.0
60