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
/* Check the status of the Tx buffer of the specified SPI port. */
xtBoolean xSPIIsTxFull(unsigned long ulBase)
/* Check the status of the Tx buffer of the specified SPI port. */ xtBoolean xSPIIsTxFull(unsigned long ulBase)
{ xASSERT(ulBase == SPI0_BASE); return ((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_TX_FULL)? xtrue : xfalse); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Check if there is media according to sense data. */
BOOLEAN IsNoMedia(IN ATAPI_REQUEST_SENSE_DATA *SenseData, IN UINTN SenseCounts)
/* Check if there is media according to sense data. */ BOOLEAN IsNoMedia(IN ATAPI_REQUEST_SENSE_DATA *SenseData, IN UINTN SenseCounts)
{ ATAPI_REQUEST_SENSE_DATA *SensePtr; UINTN Index; BOOLEAN IsNoMedia; IsNoMedia = FALSE; SensePtr = SenseData; for (Index = 0; Index < SenseCounts; Index++) { if ((SensePtr->sense_key == ATA_SK_NOT_READY) && (SensePtr->addnl_sense_code == ATA_ASC_NO_MEDIA)) { IsNoMedia = TRUE; } SensePtr++; } return IsNoMedia; }
tianocore/edk2
C++
Other
4,240
/* Check if the Trb is a transaction of the URB. */
BOOLEAN IsTrbInTrsRing(IN TRANSFER_RING *Ring, IN TRB_TEMPLATE *Trb)
/* Check if the Trb is a transaction of the URB. */ BOOLEAN IsTrbInTrsRing(IN TRANSFER_RING *Ring, IN TRB_TEMPLATE *Trb)
{ TRB_TEMPLATE *CheckedTrb; UINTN Index; CheckedTrb = (TRB_TEMPLATE *)(UINTN)Ring->RingSeg0; ASSERT (Ring->TrbNumber == TR_RING_TRB_NUMBER); for (Index = 0; Index < Ring->TrbNumber; Index++) { if (Trb == CheckedTrb) { return TRUE; } CheckedTrb++; } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* Determine whether a process may access another, returning 0 if permission granted, -ve if denied. */
int cap_ptrace_access_check(struct task_struct *child, unsigned int mode)
/* Determine whether a process may access another, returning 0 if permission granted, -ve if denied. */ int cap_ptrace_access_check(struct task_struct *child, unsigned int mode)
{ int ret = 0; rcu_read_lock(); if (!cap_issubset(__task_cred(child)->cap_permitted, current_cred()->cap_permitted) && !capable(CAP_SYS_PTRACE)) ret = -EPERM; rcu_read_unlock(); return ret; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* bsec_read_SR_lock() - read SR lock (Shadowing) @base: base address of bsec IP @otp: otp number (0 - BSEC_OTP_MAX_VALUE) Return: true if locked else false */
static bool bsec_read_SR_lock(u32 base, u32 otp)
/* bsec_read_SR_lock() - read SR lock (Shadowing) @base: base address of bsec IP @otp: otp number (0 - BSEC_OTP_MAX_VALUE) Return: true if locked else false */ static bool bsec_read_SR_lock(u32 base, u32 otp)
{ return bsec_read_lock(base + BSEC_SRLOCK_OFF, otp); }
4ms/stm32mp1-baremetal
C++
Other
137
/* This function initiates the Cmd transfer to SD card. */
s32 XSdPs_SendCmd(XSdPs *InstancePtr, u32 Cmd)
/* This function initiates the Cmd transfer to SD card. */ s32 XSdPs_SendCmd(XSdPs *InstancePtr, u32 Cmd)
{ u32 PresentStateReg; u32 CommandReg; s32 Status; CommandReg = XSdPs_FrameCmd(InstancePtr, Cmd); CommandReg = CommandReg & 0x3FFFU; if ((Cmd != CMD21) && (Cmd != CMD19)) { PresentStateReg = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, XSDPS_PRES_STATE_OFFSET); if (((PresentStateReg & XSDPS_PSR_INHIBIT_DAT_MASK) != 0U) && ((CommandReg & XSDPS_DAT_PRESENT_SEL_MASK) != 0U)) { Status = XST_FAILURE; goto RETURN_PATH; } } XSdPs_WriteReg(InstancePtr->Config.BaseAddress, XSDPS_XFER_MODE_OFFSET, (CommandReg << 16) | InstancePtr->TransferMode); Status = XST_SUCCESS; RETURN_PATH: return Status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* create a new Lua closure, push it in the stack, and initialize its upvalues. Note that the call to 'luaC_barrierproto' must come before the assignment to 'p->cache', as the function needs the original value of that field. */
static void pushclosure(lua_State *L, Proto *p, UpVal **encup, StkId base, StkId ra)
/* create a new Lua closure, push it in the stack, and initialize its upvalues. Note that the call to 'luaC_barrierproto' must come before the assignment to 'p->cache', as the function needs the original value of that field. */ static void pushclosure(lua_State *L, Proto *p, UpVal **encup, StkId base, StkId ra)
{ int nup = p->sizeupvalues; Upvaldesc *uv = p->upvalues; int i; Closure *ncl = luaF_newLclosure(L, nup); ncl->l.p = p; setclLvalue(L, ra, ncl); for (i = 0; i < nup; i++) { if (uv[i].instack) ncl->l.upvals[i] = luaF_findupval(L, base + uv[i].idx); else ncl->l.upvals[i] = encup[uv[i].idx]; } luaC_barrierproto(L, p, ncl); p->cache = ncl; }
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* Determine the total remaining free memory from all membags. */
size_t membag_get_total_free(void)
/* Determine the total remaining free memory from all membags. */ size_t membag_get_total_free(void)
{ uint8_t i; size_t total_free = 0; for (i = 0; i < ARRAY_LEN(membag_list); i++) { total_free += membag_list[i].blocks_free * membag_list[i].block_size; } return total_free; }
memfault/zero-to-main
C++
null
200
/* Created on: 8 feb. 2019 Author: Daniel Mårtensson Take the transpose of a matrix A, with the dimension row x column. The result will be A' with the dimension column x row */
void tran(double *A, int row, int column)
/* Created on: 8 feb. 2019 Author: Daniel Mårtensson Take the transpose of a matrix A, with the dimension row x column. The result will be A' with the dimension column x row */ void tran(double *A, int row, int column)
{ transpose = &B[i]; for (int j = 0; j < column; j++) { *transpose = *ptr_A; ptr_A++; transpose += row; } } memcpy(A, B, row*column*sizeof(double)); }
DanielMartensson/EmbeddedLapack
C++
MIT License
129
/* This function is used by the driver entity to get inquiry data. Data format of Identify data is defined by the Interface GUID. */
EFI_STATUS EFIAPI SdDiskInfoInquiry(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *InquiryData, IN OUT UINT32 *InquiryDataSize)
/* This function is used by the driver entity to get inquiry data. Data format of Identify data is defined by the Interface GUID. */ EFI_STATUS EFIAPI SdDiskInfoInquiry(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *InquiryData, IN OUT UINT32 *InquiryDataSize)
{ EFI_STATUS Status; SD_DEVICE *Device; Device = SD_DEVICE_DATA_FROM_DISKINFO (This); if (*InquiryDataSize >= sizeof (Device->Cid)) { Status = EFI_SUCCESS; CopyMem (InquiryData, &Device->Cid, sizeof (Device->Cid)); } else { Status = EFI_BUFFER_TOO_SMALL; } *InquiryDataSize = sizeof (Device->Cid); return Status; }
tianocore/edk2
C++
Other
4,240
/* I2C Set the 7 bit Slave Address for the Peripheral. This sets an address for Slave mode operation, in 7 bit form. */
void i2c_set_own_7bit_slave_address(uint32_t i2c, uint8_t slave)
/* I2C Set the 7 bit Slave Address for the Peripheral. This sets an address for Slave mode operation, in 7 bit form. */ void i2c_set_own_7bit_slave_address(uint32_t i2c, uint8_t slave)
{ I2C_OAR1(i2c) = (uint16_t)(slave << 1); I2C_OAR1(i2c) &= ~I2C_OAR1_OA1MODE; I2C_OAR1(i2c) |= (1 << 14); }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* All net warning printk()s should be guarded by this function. */
int net_ratelimit(void)
/* All net warning printk()s should be guarded by this function. */ int net_ratelimit(void)
{ return __ratelimit(&net_ratelimit_state); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* The header type of IPv4 device path node is MESSAGING_DEVICE_PATH. The header subtype of IPv4 device path node is MSG_IPv4_DP. Get other info from parameters to make up the whole IPv4 device path node. */
VOID EFIAPI NetLibCreateIPv4DPathNode(IN OUT IPv4_DEVICE_PATH *Node, IN EFI_HANDLE Controller, IN IP4_ADDR LocalIp, IN UINT16 LocalPort, IN IP4_ADDR RemoteIp, IN UINT16 RemotePort, IN UINT16 Protocol, IN BOOLEAN UseDefaultAddress)
/* The header type of IPv4 device path node is MESSAGING_DEVICE_PATH. The header subtype of IPv4 device path node is MSG_IPv4_DP. Get other info from parameters to make up the whole IPv4 device path node. */ VOID EFIAPI NetLibCreateIPv4DPathNode(IN OUT IPv4_DEVICE_PATH *Node, IN EFI_HANDLE Controller, IN IP4_ADDR LocalIp, IN UINT16 LocalPort, IN IP4_ADDR RemoteIp, IN UINT16 RemotePort, IN UINT16 Protocol, IN BOOLEAN UseDefaultAddress)
{ ASSERT (Node != NULL); Node->Header.Type = MESSAGING_DEVICE_PATH; Node->Header.SubType = MSG_IPv4_DP; SetDevicePathNodeLength (&Node->Header, sizeof (IPv4_DEVICE_PATH)); CopyMem (&Node->LocalIpAddress, &LocalIp, sizeof (EFI_IPv4_ADDRESS)); CopyMem (&Node->RemoteIpAddress, &RemoteIp, sizeof (EFI_IPv4_ADDRESS)); Node->LocalPort = LocalPort; Node->RemotePort = RemotePort; Node->Protocol = Protocol; if (!UseDefaultAddress) { Node->StaticIpAddress = TRUE; } else { Node->StaticIpAddress = NetLibDefaultAddressIsStatic (Controller); } ZeroMem (&Node->GatewayIpAddress, sizeof (EFI_IPv4_ADDRESS)); SetMem (&Node->SubnetMask, sizeof (EFI_IPv4_ADDRESS), 0xff); Node->SubnetMask.Addr[3] = 0; }
tianocore/edk2
C++
Other
4,240
/* Priority of the task has changed. Check to see if we preempt the current task. */
static void prio_changed_fair(struct rq *rq, struct task_struct *p, int oldprio, int running)
/* Priority of the task has changed. Check to see if we preempt the current task. */ static void prio_changed_fair(struct rq *rq, struct task_struct *p, int oldprio, int running)
{ if (running) { if (p->prio > oldprio) resched_task(rq->curr); } else check_preempt_curr(rq, p, 0); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Send the Data in a sequence of Data Out PDUs one by one. */
EFI_STATUS IScsiSendDataOutPduSequence(IN UINT8 *Data, IN UINT64 Lun, IN ISCSI_TCB *Tcb)
/* Send the Data in a sequence of Data Out PDUs one by one. */ EFI_STATUS IScsiSendDataOutPduSequence(IN UINT8 *Data, IN UINT64 Lun, IN ISCSI_TCB *Tcb)
{ LIST_ENTRY *DataOutPduList; LIST_ENTRY *Entry; NET_BUF *Pdu; EFI_STATUS Status; DataOutPduList = IScsiGenerateDataOutPduSequence (Data, Tcb, Lun); if (DataOutPduList == NULL) { return EFI_OUT_OF_RESOURCES; } Status = EFI_SUCCESS; NET_LIST_FOR_EACH (Entry, DataOutPduList) { Pdu = NET_LIST_USER_STRUCT (Entry, NET_BUF, List); Status = TcpIoTransmit (&Tcb->Conn->TcpIo, Pdu); if (EFI_ERROR (Status)) { break; } } IScsiFreeNbufList (DataOutPduList); return Status; }
tianocore/edk2
C++
Other
4,240
/* Return a buffer to the list of free buffers. */
static void prvReturnBuffer(unsigned char *pucBuffer)
/* Return a buffer to the list of free buffers. */ static void prvReturnBuffer(unsigned char *pucBuffer)
{ unsigned long ul; for( ul = 0; ul < emacNUM_BUFFERS; ul++ ) { if( &( xEthernetBuffers[ ul ][ 0 ] ) == ( void * ) pucBuffer ) { ucBufferInUse[ ul ] = pdFALSE; break; } } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* SATA interface between low level driver and command layer */
ulong sata_read(int dev, u32 blknr, u32 blkcnt, void *buffer)
/* SATA interface between low level driver and command layer */ ulong sata_read(int dev, u32 blknr, u32 blkcnt, void *buffer)
{ u32 rc; if (sata_dev_desc[dev].lba48) rc = ata_low_level_rw_lba48(dev, blknr, blkcnt, buffer, READ_CMD); else rc = ata_low_level_rw_lba28(dev, blknr, blkcnt, buffer, READ_CMD); return rc; }
EmcraftSystems/u-boot
C++
Other
181
/* Configure LIS302DL Click function. you can use this function to configure LIS302DL Click function. */
Result LIS302DLClickCfg(uint32_t Cfg)
/* Configure LIS302DL Click function. you can use this function to configure LIS302DL Click function. */ Result LIS302DLClickCfg(uint32_t Cfg)
{ Result retv = SUCCESS; uint8_t TmpReg = 0; ASSERT((Cfg & (~CLK_INT_MASK)) == 0); retv = LIS302DLRegReadByte(CLICK_CFG, &TmpReg); if(retv != SUCCESS) { return (FAILURE); } TmpReg &= (uint8_t) ((~Cfg) >> 8); TmpReg |= (uint8_t)(Cfg); retv = LIS302DLRegWriteByte(CLICK_CFG, TmpReg); if(retv != SUCCESS) { return (FAILURE); } return (SUCCESS); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* unuse callback - send ALL_SOUNDS_OFF and RESET_CONTROLLERS events to subscribers. Note: this callback is called only after all subscribers are removed. */
static int dummy_unuse(void *private_data, struct snd_seq_port_subscribe *info)
/* unuse callback - send ALL_SOUNDS_OFF and RESET_CONTROLLERS events to subscribers. Note: this callback is called only after all subscribers are removed. */ static int dummy_unuse(void *private_data, struct snd_seq_port_subscribe *info)
{ struct snd_seq_dummy_port *p; int i; struct snd_seq_event ev; p = private_data; memset(&ev, 0, sizeof(ev)); if (p->duplex) ev.source.port = p->connect; else ev.source.port = p->port; ev.dest.client = SNDRV_SEQ_ADDRESS_SUBSCRIBERS; ev.type = SNDRV_SEQ_EVENT_CONTROLLER; for (i = 0; i < 16; i++) { ev.data.control.channel = i; ev.data.control.param = MIDI_CTL_ALL_SOUNDS_OFF; snd_seq_kernel_client_dispatch(p->client, &ev, 0, 0); ev.data.control.param = MIDI_CTL_RESET_CONTROLLERS; snd_seq_kernel_client_dispatch(p->client, &ev, 0, 0); } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Interface function to upper layer. Each one who wants to get a SAP (for example NetBEUI) should call this function. Returns the opened SAP for success, NULL for failure. */
struct llc_sap* llc_sap_open(unsigned char lsap, int(*func)(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev))
/* Interface function to upper layer. Each one who wants to get a SAP (for example NetBEUI) should call this function. Returns the opened SAP for success, NULL for failure. */ struct llc_sap* llc_sap_open(unsigned char lsap, int(*func)(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev))
{ struct llc_sap *sap = NULL; write_lock_bh(&llc_sap_list_lock); if (__llc_sap_find(lsap)) goto out; sap = llc_sap_alloc(); if (!sap) goto out; sap->laddr.lsap = lsap; sap->rcv_func = func; llc_add_sap(sap); out: write_unlock_bh(&llc_sap_list_lock); return sap; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Setting context type (Direct calls are not recommended) Change Logs: Date Author Notes tyx the first version */
rt_err_t rt_hwcrypto_set_type(struct rt_hwcrypto_ctx *ctx, hwcrypto_type type)
/* Setting context type (Direct calls are not recommended) Change Logs: Date Author Notes tyx the first version */ rt_err_t rt_hwcrypto_set_type(struct rt_hwcrypto_ctx *ctx, hwcrypto_type type)
{ if (ctx) { if ((ctx->type & HWCRYPTO_MAIN_TYPE_MASK) == (type & HWCRYPTO_MAIN_TYPE_MASK)) { ctx->type = type; return RT_EOK; } else if (ctx->type == HWCRYPTO_TYPE_NULL) { ctx->type = type; return RT_EOK; } else { return -RT_ERROR; } } return -RT_EINVAL; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Check VLAN configuration variable and delete the duplicative content if has identical Vlan ID. */
EFI_STATUS MnpCheckVlanVariable(IN MNP_DEVICE_DATA *MnpDeviceData, IN VLAN_TCI *Buffer, IN UINTN NumberOfVlan, OUT UINTN *NewNumberOfVlan)
/* Check VLAN configuration variable and delete the duplicative content if has identical Vlan ID. */ EFI_STATUS MnpCheckVlanVariable(IN MNP_DEVICE_DATA *MnpDeviceData, IN VLAN_TCI *Buffer, IN UINTN NumberOfVlan, OUT UINTN *NewNumberOfVlan)
{ UINTN Index; UINTN Index2; UINTN Count; BOOLEAN FoundDuplicateItem; EFI_STATUS Status; Count = 0; FoundDuplicateItem = FALSE; Status = EFI_SUCCESS; for (Index = 0; Index < NumberOfVlan; Index++) { for (Index2 = Index + 1; Index2 < NumberOfVlan; Index2++) { if (Buffer[Index].Bits.Vid == Buffer[Index2].Bits.Vid) { FoundDuplicateItem = TRUE; Count++; break; } } if (FoundDuplicateItem) { for (Index2 = Index +1; Index2 < NumberOfVlan; Index++, Index2++) { CopyMem (Buffer + Index, Buffer + Index2, sizeof (VLAN_TCI)); } } FoundDuplicateItem = FALSE; } *NewNumberOfVlan = NumberOfVlan - Count; if (Count != 0) { Status = MnpSetVlanVariable (MnpDeviceData, *NewNumberOfVlan, Buffer); } return Status; }
tianocore/edk2
C++
Other
4,240
/* If an error would be returned, then the function will ASSERT(). */
RETURN_STATUS EFIAPI AsciiValueToStringS(IN OUT CHAR8 *Buffer, IN UINTN BufferSize, IN UINTN Flags, IN INT64 Value, IN UINTN Width)
/* If an error would be returned, then the function will ASSERT(). */ RETURN_STATUS EFIAPI AsciiValueToStringS(IN OUT CHAR8 *Buffer, IN UINTN BufferSize, IN UINTN Flags, IN INT64 Value, IN UINTN Width)
{ return BasePrintLibConvertValueToStringS (Buffer, BufferSize, Flags, Value, Width, 1); }
tianocore/edk2
C++
Other
4,240
/* Typically this will just store a device pointer. In case it was not probed, we will attempt to do so. dev may be NULL to unset the active device. */
void eth_set_dev(struct udevice *dev)
/* Typically this will just store a device pointer. In case it was not probed, we will attempt to do so. dev may be NULL to unset the active device. */ void eth_set_dev(struct udevice *dev)
{ if (dev && !device_active(dev)) { eth_errno = device_probe(dev); if (eth_errno) dev = NULL; } eth_get_uclass_priv()->current = dev; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Simple read/write access callback for the alert level characteristic. */
static int ble_svc_lls_access(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg)
/* Simple read/write access callback for the alert level characteristic. */ static int ble_svc_lls_access(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg)
{ assert(ctxt->chr == &ble_svc_lls_defs[0].characteristics[0]); int rc; switch (ctxt->op) { case BLE_GATT_ACCESS_OP_READ_CHR: rc = os_mbuf_append(ctxt->om, &ble_svc_lls_alert_level, sizeof ble_svc_lls_alert_level); return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES; case BLE_GATT_ACCESS_OP_WRITE_CHR: rc = ble_svc_lls_chr_write(ctxt->om, sizeof ble_svc_lls_alert_level, sizeof ble_svc_lls_alert_level, &ble_svc_lls_alert_level, NULL); return rc; default: assert(0); return BLE_ATT_ERR_UNLIKELY; } return 0; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* param base XRDC2 peripheral base address. param memSlot The memory slot to operate. retval kStatus_Fail Failed to lock. retval kStatus_Success Locked succussfully. */
status_t XRDC2_TryLockMemSlotExclAccess(XRDC2_Type *base, xrdc2_mem_slot_t memSlot)
/* param base XRDC2 peripheral base address. param memSlot The memory slot to operate. retval kStatus_Fail Failed to lock. retval kStatus_Success Locked succussfully. */ status_t XRDC2_TryLockMemSlotExclAccess(XRDC2_Type *base, xrdc2_mem_slot_t memSlot)
{ status_t status; uint8_t curDomainID; volatile uint32_t *lockReg = &(base->MSCI_MSAC_WK[(uint32_t)memSlot].MSC_MSAC_W1); curDomainID = XRDC2_GetCurrentMasterDomainId(base); *lockReg = XRDC2_EAL_LOCKED; if (curDomainID != XRDC2_GetMemSlotExclAccessLockDomainOwner(base, memSlot)) { status = kStatus_Fail; } else { status = kStatus_Success; } return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* We try operations in the following order: (1) erase the affected block, to allow OOB marker to be written cleanly (2) write bad block marker to OOB area of affected block (unless flag NAND_BBT_NO_OOB_BBM is present) (3) update the BBT Note that we retain the first error encountered in (2) or (3), finish the procedures, and dump the error in the end. */
static int nand_block_markbad_lowlevel(struct mtd_info *mtd, loff_t ofs)
/* We try operations in the following order: (1) erase the affected block, to allow OOB marker to be written cleanly (2) write bad block marker to OOB area of affected block (unless flag NAND_BBT_NO_OOB_BBM is present) (3) update the BBT Note that we retain the first error encountered in (2) or (3), finish the procedures, and dump the error in the end. */ static int nand_block_markbad_lowlevel(struct mtd_info *mtd, loff_t ofs)
{ struct nand_chip *chip = mtd_to_nand(mtd); int res, ret = 0; if (!(chip->bbt_options & NAND_BBT_NO_OOB_BBM)) { struct erase_info einfo; memset(&einfo, 0, sizeof(einfo)); einfo.mtd = mtd; einfo.addr = ofs; einfo.len = 1ULL << chip->phys_erase_shift; nand_erase_nand(mtd, &einfo, 0); nand_get_device(mtd, FL_WRITING); ret = chip->block_markbad(mtd, ofs); nand_release_device(mtd); } if (chip->bbt) { res = nand_markbad_bbt(mtd, ofs); if (!ret) ret = res; } if (!ret) mtd->ecc_stats.badblocks++; return ret; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Updates the sense data of a LUN with the given key and codes. */
void SBC_UpdateSenseData(SBCRequestSenseData *requestSenseData, unsigned char senseKey, unsigned char additionalSenseCode, unsigned char additionalSenseCodeQualifier)
/* Updates the sense data of a LUN with the given key and codes. */ void SBC_UpdateSenseData(SBCRequestSenseData *requestSenseData, unsigned char senseKey, unsigned char additionalSenseCode, unsigned char additionalSenseCodeQualifier)
{ requestSenseData->bSenseKey = senseKey; requestSenseData->bAdditionalSenseCode = additionalSenseCode; requestSenseData->bAdditionalSenseCodeQualifier = additionalSenseCodeQualifier; }
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* This file is part of the Simba project. */
int mock_write_jtag_soft_module_init(int res)
/* This file is part of the Simba project. */ int mock_write_jtag_soft_module_init(int res)
{ harness_mock_write("jtag_soft_module_init()", NULL, 0); harness_mock_write("jtag_soft_module_init(): return (res)", &res, sizeof(res)); return (0); }
eerimoq/simba
C++
Other
337
/* Waiting the specified bit in the register change to SET/RESET. */
ald_status_t ald_wait_flag(uint32_t *reg, uint32_t bit, flag_status_t status, uint32_t timeout)
/* Waiting the specified bit in the register change to SET/RESET. */ ald_status_t ald_wait_flag(uint32_t *reg, uint32_t bit, flag_status_t status, uint32_t timeout)
{ uint32_t tick = ald_get_tick(); assert_param(timeout > 0); if (status == SET) { while (!(IS_BIT_SET(*reg, bit))) { if (((ald_get_tick()) - tick) > timeout) return TIMEOUT; } } else { while ((IS_BIT_SET(*reg, bit))) { if (((ald_get_tick()) - tick) > timeout) return TIMEOUT; } } return OK; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Convert an u32_t from host to network byte order. */
static uint32_t ntohl(uint32_t n)
/* Convert an u32_t from host to network byte order. */ static uint32_t ntohl(uint32_t n)
{ return ((n & 0xff) << 24) | ((n & 0xff00) << 8) | ((n & 0xff0000UL) >> 8) | ((n & 0xff000000UL) >> 24); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Read Opposite Error Recovery Function: Used, when Read Forward does not work */
static int tape_34xx_erp_read_opposite(struct tape_device *device, struct tape_request *request)
/* Read Opposite Error Recovery Function: Used, when Read Forward does not work */ static int tape_34xx_erp_read_opposite(struct tape_device *device, struct tape_request *request)
{ if (request->op == TO_RFO) { tape_std_read_backward(device, request); return tape_34xx_erp_retry(request); } return tape_34xx_erp_failed(request, -EIO); }
robutest/uclinux
C++
GPL-2.0
60
/* Configures the high and low thresholds of the analog watchdog2. */
void ADC_AnalogWatchdog2ThresholdsConfig(ADC_TypeDef *ADCx, uint8_t HighThreshold, uint8_t LowThreshold)
/* Configures the high and low thresholds of the analog watchdog2. */ void ADC_AnalogWatchdog2ThresholdsConfig(ADC_TypeDef *ADCx, uint8_t HighThreshold, uint8_t LowThreshold)
{ assert_param(IS_ADC_ALL_PERIPH(ADCx)); ADCx->TR2 &= ~(uint32_t)ADC_TR2_HT2; ADCx->TR2 |= (uint32_t)((uint32_t)HighThreshold << 16); ADCx->TR2 &= ~(uint32_t)ADC_TR2_LT2; ADCx->TR2 |= LowThreshold; }
ajhc/demo-cortex-m3
C++
null
38
/* megasas_clear_interrupt_xscale - Check & clear interrupt @regs: MFI register set */
static int megasas_clear_intr_xscale(struct megasas_register_set __iomem *regs)
/* megasas_clear_interrupt_xscale - Check & clear interrupt @regs: MFI register set */ static int megasas_clear_intr_xscale(struct megasas_register_set __iomem *regs)
{ u32 status; status = readl(&regs->outbound_intr_status); if (!(status & MFI_OB_INTR_STATUS_MASK)) { return 1; } writel(status, &regs->outbound_intr_status); readl(&regs->outbound_intr_status); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
{ if(htim_base->Instance==TIM2) { __HAL_RCC_TIM2_CLK_DISABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function will provide the caller with the specified block device's media information. If the media changes, calling this function will update the media information accordingly. */
EFI_STATUS EFIAPI UfsBlockIoPeimGetMediaInfo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, IN UINTN DeviceIndex, OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo)
/* This function will provide the caller with the specified block device's media information. If the media changes, calling this function will update the media information accordingly. */ EFI_STATUS EFIAPI UfsBlockIoPeimGetMediaInfo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, IN UINTN DeviceIndex, OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo)
{ EFI_STATUS Status; UFS_PEIM_HC_PRIVATE_DATA *Private; EFI_PEI_BLOCK_IO_MEDIA Media; UINTN Lun; Private = GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS2 (This); Status = UfsBlockIoPeimGetMediaInfo ( PeiServices, &Private->BlkIoPpi, DeviceIndex, &Media ); if (EFI_ERROR (Status)) { return Status; } Lun = DeviceIndex - 1; CopyMem (MediaInfo, &(Private->Media[Lun]), sizeof (EFI_PEI_BLOCK_IO2_MEDIA)); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Before you start, select your target, on the right of the "Load" button */
int main(void)
/* Before you start, select your target, on the right of the "Load" button */ int main(void)
{ if (position == 1000) { position = 2000; } else { position = 1000; } TM_PWM_SetChannelMicros(&TIM2_Data, TM_PWM_Channel_1, position); Delayms(1500); } }
MaJerle/stm32f429
C++
null
2,036
/* TLS Extensions (in Client Hello and Server Hello). {{{ */
static gint ssl_dissect_hnd_hello_ext_sig_hash_algs(ssl_common_dissect_t *hf, tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint32 ext_len)
/* TLS Extensions (in Client Hello and Server Hello). {{{ */ static gint ssl_dissect_hnd_hello_ext_sig_hash_algs(ssl_common_dissect_t *hf, tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint32 ext_len)
{ guint16 sh_alg_length; gint ret; sh_alg_length = tvb_get_ntohs(tvb, offset); proto_tree_add_uint(tree, hf->hf.hs_sig_hash_alg_len, tvb, offset, 2, sh_alg_length); offset += 2; if (ext_len < 2 || sh_alg_length != ext_len - 2) { return offset; } ret = ssl_dissect_hash_alg_list(hf, tvb, tree, pinfo, offset, sh_alg_length); if (ret >= 0) offset += ret; return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function calculates the CRC32 of the input data. */
static uint32_t _eval_crc_32(const uint8_t *puc_buf_ptr, uint32_t ul_len, uint32_t ul_crc_init)
/* This function calculates the CRC32 of the input data. */ static uint32_t _eval_crc_32(const uint8_t *puc_buf_ptr, uint32_t ul_len, uint32_t ul_crc_init)
{ uint8_t uc_idx; uint32_t ul_crc; ul_crc = ul_crc_init; if (ul_len != 0) { while (ul_len--) { uc_idx = (uint8_t)(ul_crc >> 24) ^ *puc_buf_ptr++; ul_crc = (ul_crc << 8) ^ pul_crc32_table[uc_idx]; } } return ul_crc; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Enable the interrupt mode for the selected IT source. */
int32_t MFXSTM32L152_EnableITSource(MFXSTM32L152_Object_t *pObj, uint8_t Source)
/* Enable the interrupt mode for the selected IT source. */ int32_t MFXSTM32L152_EnableITSource(MFXSTM32L152_Object_t *pObj, uint8_t Source)
{ int32_t ret = MFXSTM32L152_OK; uint8_t tmp; if (mfxstm32l152_read_reg(&pObj->Ctx, MFXSTM32L152_REG_ADR_IRQ_SRC_EN, &tmp, 1) != MFXSTM32L152_OK) { ret = MFXSTM32L152_ERROR; } else { tmp |= Source; if (mfxstm32l152_write_reg(&pObj->Ctx, MFXSTM32L152_REG_ADR_IRQ_SRC_EN, &tmp, 1) != MFXSTM32L152_OK) { ret = MFXSTM32L152_ERROR; } } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* The following routines act on original old Stallion boards. */
static void stli_stalinit(struct stlibrd *brdp)
/* The following routines act on original old Stallion boards. */ static void stli_stalinit(struct stlibrd *brdp)
{ outb(0x1, brdp->iobase); mdelay(1000); }
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); while (1) { } }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* This function is executed in case of error occurrence. */
void Error_Handler(void)
/* This function is executed in case of error occurrence. */ void Error_Handler(void)
{ BSP_LED_On(LED3); while(1) {} }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Return value: 0 on success / other on failure */
static int ibmvfc_send_crq_init_complete(struct ibmvfc_host *vhost)
/* Return value: 0 on success / other on failure */ static int ibmvfc_send_crq_init_complete(struct ibmvfc_host *vhost)
{ ibmvfc_dbg(vhost, "Sending CRQ init complete\n"); return ibmvfc_send_crq(vhost, 0xC002000000000000LL, 0); }
robutest/uclinux
C++
GPL-2.0
60
/* If FormatString is NULL, then ASSERT() and 0 is returned. If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then ASSERT() and 0 is returned. */
UINTN EFIAPI SPrintLength(IN CONST CHAR16 *FormatString, IN VA_LIST Marker)
/* If FormatString is NULL, then ASSERT() and 0 is returned. If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then ASSERT() and 0 is returned. */ UINTN EFIAPI SPrintLength(IN CONST CHAR16 *FormatString, IN VA_LIST Marker)
{ ASSERT_UNICODE_BUFFER (FormatString); return BasePrintLibSPrintMarker (NULL, 0, FORMAT_UNICODE | OUTPUT_UNICODE | COUNT_ONLY_NO_PRINT, (CHAR8 *)FormatString, Marker, NULL); }
tianocore/edk2
C++
Other
4,240
/* Clean up the SPI controller after a specified SPI slave device */
static void spi_a2f_cleanup(struct spi_device *s)
/* Clean up the SPI controller after a specified SPI slave device */ static void spi_a2f_cleanup(struct spi_device *s)
{ d_printk(1, "slv=%s\n", dev_name(&s->dev)); }
robutest/uclinux
C++
GPL-2.0
60
/* Enables or disables the SS output for the selected SPI. */
void SPI_SSOutputCmd(SPI_TypeDef *SPIx, FunctionalState NewState)
/* Enables or disables the SS output for the selected SPI. */ void SPI_SSOutputCmd(SPI_TypeDef *SPIx, FunctionalState NewState)
{ assert_param(IS_SPI_ALL_PERIPH(SPIx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { SPIx->CR2 |= CR2_SSOE_Set; } else { SPIx->CR2 &= CR2_SSOE_Reset; } }
gcallipo/RadioDSP-Stm32f103
C++
Common Creative - Attribution 3.0
51
/* Write a field stored at a device register or memory address. This routine writes a specified value to a bit field within a 1-Byte device register or memory address. The set bits in the mask parameter determine the field location. For example, if the mask is 30h and the value is 2h, the value 20h will be bitwise logically OR'd into the 1-Byte register value after clearing the bit values in the field. */
void bus_reg_fieldset(bus_desc_t *bus, uint8_t addr, uint8_t mask, uint8_t value)
/* Write a field stored at a device register or memory address. This routine writes a specified value to a bit field within a 1-Byte device register or memory address. The set bits in the mask parameter determine the field location. For example, if the mask is 30h and the value is 2h, the value 20h will be bitwise logically OR'd into the 1-Byte register value after clearing the bit values in the field. */ void bus_reg_fieldset(bus_desc_t *bus, uint8_t addr, uint8_t mask, uint8_t value)
{ uint8_t const reg = ~mask &bus_get(bus, addr); value *= (mask & ~(mask << 1)); bus_put(bus, addr, reg | (value & mask)); }
memfault/zero-to-main
C++
null
200
/* Returns true if an usbgecko adapter is found. */
static int ug_is_adapter_present(void)
/* Returns true if an usbgecko adapter is found. */ static int ug_is_adapter_present(void)
{ if (!ug_io_base) return 0; return ug_io_transaction(0x90000000) == 0x04700000; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Funciton alloc_irdadev Allocates and sets up an IRDA device in a manner similar to alloc_etherdev. */
struct net_device* alloc_irdadev(int sizeof_priv)
/* Funciton alloc_irdadev Allocates and sets up an IRDA device in a manner similar to alloc_etherdev. */ struct net_device* alloc_irdadev(int sizeof_priv)
{ return alloc_netdev(sizeof_priv, "irda%d", irda_device_setup); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* _detach is called to deconfigure a device. It should deallocate resources. This function is also called when _attach() fails, so it should be careful not to release resources that were not necessarily allocated by _attach(). dev->private and dev->subdevices are deallocated automatically by the core. */
static int s526_detach(struct comedi_device *dev)
/* _detach is called to deconfigure a device. It should deallocate resources. This function is also called when _attach() fails, so it should be careful not to release resources that were not necessarily allocated by _attach(). dev->private and dev->subdevices are deallocated automatically by the core. */ static int s526_detach(struct comedi_device *dev)
{ printk("comedi%d: s526: remove\n", dev->minor); if (dev->iobase > 0) release_region(dev->iobase, S526_IOSIZE); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This function is called with a list of IOCBs to cancel. It cancels the IOCB on the list by invoking the complete callback function associated with the IOCB with the provided @ulpstatus and @ulpword4 set to the IOCB commond fields. */
void lpfc_sli_cancel_iocbs(struct lpfc_hba *phba, struct list_head *iocblist, uint32_t ulpstatus, uint32_t ulpWord4)
/* This function is called with a list of IOCBs to cancel. It cancels the IOCB on the list by invoking the complete callback function associated with the IOCB with the provided @ulpstatus and @ulpword4 set to the IOCB commond fields. */ void lpfc_sli_cancel_iocbs(struct lpfc_hba *phba, struct list_head *iocblist, uint32_t ulpstatus, uint32_t ulpWord4)
{ struct lpfc_iocbq *piocb; while (!list_empty(iocblist)) { list_remove_head(iocblist, piocb, struct lpfc_iocbq, list); if (!piocb->iocb_cmpl) lpfc_sli_release_iocbq(phba, piocb); else { piocb->iocb.ulpStatus = ulpstatus; piocb->iocb.un.ulpWord[4] = ulpWord4; (piocb->iocb_cmpl) (phba, piocb, piocb); } } return; }
robutest/uclinux
C++
GPL-2.0
60
/* Return the local rtp port used by the RTP connection */
int rtp_get_local_rtp_port(URLContext *h)
/* Return the local rtp port used by the RTP connection */ int rtp_get_local_rtp_port(URLContext *h)
{ RTPContext *s = h->priv_data; return udp_get_local_port(s->rtp_hd); }
DC-SWAT/DreamShell
C++
null
404
/* send zero lzngth packet on the ctl pipe */
void usb_ctrlstatustx(usb_core_instance *pdev)
/* send zero lzngth packet on the ctl pipe */ void usb_ctrlstatustx(usb_core_instance *pdev)
{ pdev->dev.device_state = USB_EP0_STATUS_IN; usb_deveptx(pdev, 0U, pdev->dev.setup_pkt_buf, 0U); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* USI UART get empty entry count in TX FIFO . */
u32 USI_UARTGetTxFifoEmptyCnt(USI_TypeDef *USIx)
/* USI UART get empty entry count in TX FIFO . */ u32 USI_UARTGetTxFifoEmptyCnt(USI_TypeDef *USIx)
{ assert_param(IS_ALL_USI_PERIPH(USIx)); return (u32)((USIx->TX_FIFO_STATUS & USI_TXFIFO_EMPTY_SPACE)>>8); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* ppc440spe_desc_init_memset - initialize the descriptor for MEMSET operation */
static void ppc440spe_desc_init_memset(struct ppc440spe_adma_desc_slot *desc, int value, unsigned long flags)
/* ppc440spe_desc_init_memset - initialize the descriptor for MEMSET operation */ static void ppc440spe_desc_init_memset(struct ppc440spe_adma_desc_slot *desc, int value, unsigned long flags)
{ struct dma_cdb *hw_desc = desc->hw_desc; memset(desc->hw_desc, 0, sizeof(struct dma_cdb)); desc->hw_next = NULL; desc->src_cnt = 1; desc->dst_cnt = 1; if (flags & DMA_PREP_INTERRUPT) set_bit(PPC440SPE_DESC_INT, &desc->flags); else clear_bit(PPC440SPE_DESC_INT, &desc->flags); hw_desc->sg1u = hw_desc->sg1l = cpu_to_le32((u32)value); hw_desc->sg3u = hw_desc->sg3l = cpu_to_le32((u32)value); hw_desc->opc = DMA_CDB_OPC_DFILL128; }
robutest/uclinux
C++
GPL-2.0
60
/* RCC Enable Bypass. Enable an external clock to bypass the internal clock (high speed and low speed clocks only). The external clock must be enabled (see */
void rcc_osc_bypass_enable(enum rcc_osc osc)
/* RCC Enable Bypass. Enable an external clock to bypass the internal clock (high speed and low speed clocks only). The external clock must be enabled (see */ void rcc_osc_bypass_enable(enum rcc_osc osc)
{ switch (osc) { case RCC_HSE: RCC_CR |= RCC_CR_HSEBYP; break; case RCC_LSE: RCC_BDCR |= RCC_BDCR_LSEBYP; break; case RCC_HSI48: case RCC_HSI14: case RCC_HSI: case RCC_LSI: case RCC_PLL: break; } }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* pos: channel void *buffer: rt_uint32_t pulse size : number of pulse, only set to sizeof(rt_uint32_t). */
static rt_ssize_t _pwm_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
/* pos: channel void *buffer: rt_uint32_t pulse size : number of pulse, only set to sizeof(rt_uint32_t). */ static rt_ssize_t _pwm_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
{ rt_err_t result = RT_EOK; struct rt_device_pwm *pwm = (struct rt_device_pwm *)dev; rt_uint32_t *pulse = (rt_uint32_t *)buffer; struct rt_pwm_configuration configuration = {0}; configuration.channel = (pos > 0) ? (pos) : (-pos); if (pwm->ops->control) { result = pwm->ops->control(pwm, PWM_CMD_GET, &configuration); if (result != RT_EOK) { return 0; } *pulse = configuration.pulse; } return size; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Brief This function handles I2C1 (Slave) error interrupt request. Param None Retval None */
void I2C1_ER_IRQHandler(void)
/* Brief This function handles I2C1 (Slave) error interrupt request. Param None Retval None */ void I2C1_ER_IRQHandler(void)
{ if((ubSlaveNbDataToTransmit == 0) && \ (LL_I2C_IsActiveFlag_AF(I2C1)) && \ (LL_I2C_GetTransferDirection(I2C1) == LL_I2C_DIRECTION_WRITE)) { LL_I2C_ClearFlag_AF(I2C1); Slave_Complete_Callback(); } else { Error_Callback(); } }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Returns the last adc conversion result data for regular channel. */
u16 ADC_GetConversionValue(ADC_TypeDef *adc)
/* Returns the last adc conversion result data for regular channel. */ u16 ADC_GetConversionValue(ADC_TypeDef *adc)
{ return (u16)adc->ADDATA; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Periodic callback for GDB. This function is used to catch a ctrl-c or other break in type command from GDB. */
VOID EFIAPI GdbPeriodicCallBack(IN OUT EFI_SYSTEM_CONTEXT SystemContext)
/* Periodic callback for GDB. This function is used to catch a ctrl-c or other break in type command from GDB. */ VOID EFIAPI GdbPeriodicCallBack(IN OUT EFI_SYSTEM_CONTEXT SystemContext)
{ if (!gCtrlCBreakFlag && !gProcessingFPacket) { while (TRUE) { if (!GdbIsCharAvailable ()) { break; } if (GdbGetChar () == 0x03) { gCtrlCBreakFlag = TRUE; break; } } } if (gCtrlCBreakFlag) { AddSingleStep (SystemContext); gCtrlCBreakFlag = FALSE; } }
tianocore/edk2
C++
Other
4,240
/* writes the data to data register of I2C module when \ifstart one the start signal will be sent followed by the \data when \ifstart zero only the \data will be send */
void tls_i2c_write_byte(u8 data, u8 ifstart)
/* writes the data to data register of I2C module when \ifstart one the start signal will be sent followed by the \data when \ifstart zero only the \data will be send */ void tls_i2c_write_byte(u8 data, u8 ifstart)
{ tls_reg_write32(HR_I2C_TX_RX, data); if(ifstart) tls_reg_write32(HR_I2C_CR_SR, I2C_CR_STA | I2C_CR_WR); else tls_reg_write32(HR_I2C_CR_SR, I2C_CR_WR); while(tls_reg_read32(HR_I2C_CR_SR) & I2C_SR_TIP); }
Nicholas3388/LuaNode
C++
Other
1,055
/* encode a location element of a fs_locations structure */
static __be32 nfsd4_encode_fs_location4(struct nfsd4_fs_location *location, __be32 **pp, int *buflen)
/* encode a location element of a fs_locations structure */ static __be32 nfsd4_encode_fs_location4(struct nfsd4_fs_location *location, __be32 **pp, int *buflen)
{ __be32 status; __be32 *p = *pp; status = nfsd4_encode_components(':', location->hosts, &p, buflen); if (status) return status; status = nfsd4_encode_components('/', location->path, &p, buflen); if (status) return status; *pp = p; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* The caller must have previously called ext3_reserve_inode_write(). Give this, we know that the caller already has write access to iloc->bh. */
int ext3_mark_iloc_dirty(handle_t *handle, struct inode *inode, struct ext3_iloc *iloc)
/* The caller must have previously called ext3_reserve_inode_write(). Give this, we know that the caller already has write access to iloc->bh. */ int ext3_mark_iloc_dirty(handle_t *handle, struct inode *inode, struct ext3_iloc *iloc)
{ int err = 0; get_bh(iloc->bh); err = ext3_do_update_inode(handle, inode, iloc); put_bh(iloc->bh); return err; }
robutest/uclinux
C++
GPL-2.0
60
/* Get Digital Core logic supply source to be used during Deep Sleep. */
static void lf_get_deepsleep_core_supply_cfg(uint32_t exclude_from_pd, uint32_t *dcdc_voltage)
/* Get Digital Core logic supply source to be used during Deep Sleep. */ static void lf_get_deepsleep_core_supply_cfg(uint32_t exclude_from_pd, uint32_t *dcdc_voltage)
{ *dcdc_voltage = V_DCDC_0P950; if (((exclude_from_pd & (uint32_t)kPDRUNCFG_PD_USB1_PHY) != 0) && ((exclude_from_pd & (uint32_t)kPDRUNCFG_PD_LDOUSBHS) != 0)) { PMC->MISCCTRL |= PMC_MISCCTRL_LOWPWR_FLASH_BUF_MASK; *dcdc_voltage = V_DCDC_1P000; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The functions for inserting/removing us as a module. */
static int __init mtouch_init(void)
/* The functions for inserting/removing us as a module. */ static int __init mtouch_init(void)
{ return serio_register_driver(&mtouch_drv); }
robutest/uclinux
C++
GPL-2.0
60
/* HCD_SubmitRequest This function prepare a HC and start a transfer. */
uint32_t HCD_SubmitRequest(USB_OTG_CORE_HANDLE *pdev, uint8_t hc_num)
/* HCD_SubmitRequest This function prepare a HC and start a transfer. */ uint32_t HCD_SubmitRequest(USB_OTG_CORE_HANDLE *pdev, uint8_t hc_num)
{ pdev->host.URB_State[hc_num] = URB_IDLE; pdev->host.hc[hc_num].xfer_count = 0 ; return USB_OTG_HC_StartXfer(pdev, hc_num); }
MaJerle/stm32f429
C++
null
2,036
/* Find specified table in XSDT, run handler on it and return its return value */
int sfi_acpi_table_parse(char *signature, char *oem_id, char *oem_table_id, int(*handler)(struct acpi_table_header *))
/* Find specified table in XSDT, run handler on it and return its return value */ int sfi_acpi_table_parse(char *signature, char *oem_id, char *oem_table_id, int(*handler)(struct acpi_table_header *))
{ struct acpi_table_header *table = NULL; struct sfi_table_key key; int ret = 0; if (sfi_disabled) return -1; key.sig = signature; key.oem_id = oem_id; key.oem_table_id = oem_table_id; table = sfi_acpi_get_table(&key); if (!table) return -EINVAL; ret = handler(table); sfi_acpi_put_table(table); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Since 64-bit pointers are twice the size, we lose half the capacity in the base structure. Also note that no effort is made to efficiently pack objects across page boundaries. */
struct flex_array* flex_array_alloc(int element_size, unsigned int total, gfp_t flags)
/* Since 64-bit pointers are twice the size, we lose half the capacity in the base structure. Also note that no effort is made to efficiently pack objects across page boundaries. */ struct flex_array* flex_array_alloc(int element_size, unsigned int total, gfp_t flags)
{ struct flex_array *ret; int max_size = FLEX_ARRAY_NR_BASE_PTRS * FLEX_ARRAY_ELEMENTS_PER_PART(element_size); if (total > max_size) return NULL; ret = kzalloc(sizeof(struct flex_array), flags); if (!ret) return NULL; ret->element_size = element_size; ret->total_nr_elements = total; if (elements_fit_in_base(ret) && !(flags & __GFP_ZERO)) memset(ret->parts[0], FLEX_ARRAY_FREE, FLEX_ARRAY_BASE_BYTES_LEFT); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Checks to see if the device can support the effect. */
int SDL_HapticEffectSupported(SDL_Haptic *haptic, SDL_HapticEffect *effect)
/* Checks to see if the device can support the effect. */ int SDL_HapticEffectSupported(SDL_Haptic *haptic, SDL_HapticEffect *effect)
{ if (!ValidHaptic(haptic)) { return -1; } if ((haptic->supported & effect->type) != 0) return SDL_TRUE; return SDL_FALSE; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Decodes input (uint8_t) into output (uint32_t). Assumes len is a multiple of 4. */
static void ICACHE_FLASH_ATTR Decode(uint32_t *output, const uint8_t *input, uint32_t len)
/* Decodes input (uint8_t) into output (uint32_t). Assumes len is a multiple of 4. */ static void ICACHE_FLASH_ATTR Decode(uint32_t *output, const uint8_t *input, uint32_t len)
{ uint32_t i, j; for (i = 0, j = 0; j < len; i++, j += 4) output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) | (((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24); }
eerimoq/simba
C++
Other
337
/* Get the number of valid entries in ADC receive FIFO. */
u32 ADC_GetRxCount(void)
/* Get the number of valid entries in ADC receive FIFO. */ u32 ADC_GetRxCount(void)
{ ADC_TypeDef *adc = ADC; return adc->ADC_FLR & BIT_MASK_FLR; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Try to drop buffers from the pages in a pagevec */
void pagevec_strip(struct pagevec *pvec)
/* Try to drop buffers from the pages in a pagevec */ void pagevec_strip(struct pagevec *pvec)
{ int i; for (i = 0; i < pagevec_count(pvec); i++) { struct page *page = pvec->pages[i]; if (page_has_private(page) && trylock_page(page)) { if (page_has_private(page)) try_to_release_page(page, 0); unlock_page(page); } } }
robutest/uclinux
C++
GPL-2.0
60
/* Returns 0 on success or -ENOENT if no matching textsearch registration was found. */
int textsearch_unregister(struct ts_ops *ops)
/* Returns 0 on success or -ENOENT if no matching textsearch registration was found. */ int textsearch_unregister(struct ts_ops *ops)
{ int err = 0; struct ts_ops *o; spin_lock(&ts_mod_lock); list_for_each_entry(o, &ts_ops, list) { if (o == ops) { list_del_rcu(&o->list); goto out; } } err = -ENOENT; out: spin_unlock(&ts_mod_lock); return err; }
robutest/uclinux
C++
GPL-2.0
60
/* Call a callback for each child of a class */
void rtnl_class_foreach_child(struct rtnl_class *class, struct nl_cache *cache, void(*cb)(struct nl_object *, void *), void *arg)
/* Call a callback for each child of a class */ void rtnl_class_foreach_child(struct rtnl_class *class, struct nl_cache *cache, void(*cb)(struct nl_object *, void *), void *arg)
{ struct rtnl_class *filter; filter = rtnl_class_alloc(); if (!filter) return; rtnl_class_set_parent(filter, class->c_handle); rtnl_class_set_ifindex(filter, class->c_ifindex); rtnl_class_set_kind(filter, class->c_kind); nl_cache_foreach_filter(cache, (struct nl_object *) filter, cb, arg); rtnl_class_put(filter); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Function to check on various aspects of a connection. */
static unsigned int rtsp_conncheck(struct connectdata *check, unsigned int checks_to_perform)
/* Function to check on various aspects of a connection. */ static unsigned int rtsp_conncheck(struct connectdata *check, unsigned int checks_to_perform)
{ unsigned int ret_val = CONNRESULT_NONE; if(checks_to_perform & CONNCHECK_ISDEAD) { if(rtsp_connisdead(check)) ret_val |= CONNRESULT_DEAD; } return ret_val; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Initiates an A/D conversion and reads the sample when done. */
static uint16_t getAdcSample(void)
/* Initiates an A/D conversion and reads the sample when done. */ static uint16_t getAdcSample(void)
{ ADC_Start( ADC0, adcStartSingle ); while( !( ADC_IntGet( ADC0 ) & ADC_IF_SINGLE ) ) ; return ADC_DataSingleGet( ADC0 ); }
remotemcu/remcu-chip-sdks
C++
null
436
/* When value set Success, call the submit callback function. */
VOID SubmitCallback(IN FORM_BROWSER_FORMSET *FormSet, IN FORM_BROWSER_FORM *Form)
/* When value set Success, call the submit callback function. */ VOID SubmitCallback(IN FORM_BROWSER_FORMSET *FormSet, IN FORM_BROWSER_FORM *Form)
{ FORM_BROWSER_FORM *CurrentForm; LIST_ENTRY *Link; if (Form != NULL) { SubmitCallbackForForm (FormSet, Form); return; } Link = GetFirstNode (&FormSet->FormListHead); while (!IsNull (&FormSet->FormListHead, Link)) { CurrentForm = FORM_BROWSER_FORM_FROM_LINK (Link); Link = GetNextNode (&FormSet->FormListHead, Link); SubmitCallbackForForm (FormSet, CurrentForm); } }
tianocore/edk2
C++
Other
4,240
/* copy src to dest, skipping leading and trailing blanks and null terminate the string "len" is the size of available memory including the terminating '\0' */
static void ident_cpy(unsigned char *dst, unsigned char *src, unsigned int len)
/* copy src to dest, skipping leading and trailing blanks and null terminate the string "len" is the size of available memory including the terminating '\0' */ static void ident_cpy(unsigned char *dst, unsigned char *src, unsigned int len)
{ unsigned char *end, *last; last = dst; end = src + len - 1; if (len < 2) goto OUT; while ((*src) && (src < end) && (*src == ' ')) ++src; while ((*src) && (src < end)) { *dst++ = *src; if (*src++ != ' ') last = dst; } OUT: *last = '\0'; }
4ms/stm32mp1-baremetal
C++
Other
137
/* This method returns the STM32L4XX NUCLEO BSP Driver revision. */
uint32_t BSP_GetVersion(void)
/* This method returns the STM32L4XX NUCLEO BSP Driver revision. */ uint32_t BSP_GetVersion(void)
{ return __STM32L4XX_NUCLEO_BSP_VERSION; }
labapart/polymcu
C++
null
201
/* Initialize Cache Module. This function does low level cache configuration. */
int32_t _cmcc_init(void)
/* Initialize Cache Module. This function does low level cache configuration. */ int32_t _cmcc_init(void)
{ int32_t return_value; _cmcc_disable(CMCC); if (_is_cache_disabled(CMCC)) { hri_cmcc_write_CFG_reg( CMCC, (CMCC_CFG_CSIZESW(CONF_CMCC_CACHE_SIZE) | (CONF_CMCC_DATA_CACHE_DISABLE << CMCC_CFG_DCDIS_Pos) | (CONF_CMCC_INST_CACHE_DISABLE << CMCC_CFG_ICDIS_Pos) | (CONF_CMCC_CLK_GATING_DISABLE))); _cmcc_enable(CMCC); return_value = _is_cache_enabled(CMCC) == true ? ERR_NONE : ERR_FAILURE; } else { return_value = ERR_NOT_INITIALIZED; } return return_value; }
eclipse-threadx/getting-started
C++
Other
310
/* Platform hook to retrieve the 16550 UART base address from the GUID Hob that caches the UART base address from early boot stage and store it in PcdSerialRegisterBase. */
RETURN_STATUS EFIAPI PlatformHookSerialPortInitialize(VOID)
/* Platform hook to retrieve the 16550 UART base address from the GUID Hob that caches the UART base address from early boot stage and store it in PcdSerialRegisterBase. */ RETURN_STATUS EFIAPI PlatformHookSerialPortInitialize(VOID)
{ VOID *Hob; UINT64 *UartBase; if (PcdGet64 (PcdSerialRegisterBase) != 0) { return RETURN_SUCCESS; } Hob = GetFirstGuidHob (&gEarly16550UartBaseAddressGuid); if ((Hob == NULL) || (GET_GUID_HOB_DATA_SIZE (Hob) != sizeof (*UartBase))) { return RETURN_NOT_FOUND; } UartBase = GET_GUID_HOB_DATA (Hob); if ((UINTN)*UartBase == 0) { return RETURN_NOT_FOUND; } return (RETURN_STATUS)PcdSet64S (PcdSerialRegisterBase, (UINTN)*UartBase); }
tianocore/edk2
C++
Other
4,240
/* introduce function FLEXIO_I2C_MasterTransferStateMachineStart. This function was deal with Initial state, i2c start state. */
static void FLEXIO_I2C_MasterTransferStateMachineStart(FLEXIO_I2C_Type *base, flexio_i2c_master_handle_t *handle)
/* introduce function FLEXIO_I2C_MasterTransferStateMachineStart. This function was deal with Initial state, i2c start state. */ static void FLEXIO_I2C_MasterTransferStateMachineStart(FLEXIO_I2C_Type *base, flexio_i2c_master_handle_t *handle)
{ if (handle->needRestart) { FLEXIO_I2C_MasterStart(base, handle->transfer.slaveAddress, kFLEXIO_I2C_Write); } else { FLEXIO_I2C_MasterStart(base, handle->transfer.slaveAddress, handle->transfer.direction); } if (handle->transfer.subaddressSize == 0U) { if (handle->transfer.direction == kFLEXIO_I2C_Write) { handle->state = (uint8_t)kFLEXIO_I2C_SendData; } else { handle->state = (uint8_t)kFLEXIO_I2C_ReceiveDataBegin; } } else { handle->state = (uint8_t)kFLEXIO_I2C_SendCommand; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* flow_process_* == common groups of fields, probably could be inline */
static int flow_process_ints(proto_tree *pdutree, tvbuff_t *tvb, int offset)
/* flow_process_* == common groups of fields, probably could be inline */ static int flow_process_ints(proto_tree *pdutree, tvbuff_t *tvb, int offset)
{ proto_tree_add_item(pdutree, hf_cflow_inputint, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(pdutree, hf_cflow_outputint, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* helper function to update the item for a given subvolumes log root in the tree of log roots */
static int update_log_root(struct btrfs_trans_handle *trans, struct btrfs_root *log)
/* helper function to update the item for a given subvolumes log root in the tree of log roots */ static int update_log_root(struct btrfs_trans_handle *trans, struct btrfs_root *log)
{ int ret; if (log->log_transid == 1) { ret = btrfs_insert_root(trans, log->fs_info->log_root_tree, &log->root_key, &log->root_item); } else { ret = btrfs_update_root(trans, log->fs_info->log_root_tree, &log->root_key, &log->root_item); } return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Initializes the TIMx Time Base Unit peripheral according to the specified parameters in the TIM_TimeBaseInitStruct. */
void TIM_TimeBaseInit(TIM_TypeDef *TIMx, TIM_TimeBaseInitTypeDef *TIM_TimeBaseInitStruct)
/* Initializes the TIMx Time Base Unit peripheral according to the specified parameters in the TIM_TimeBaseInitStruct. */ void TIM_TimeBaseInit(TIM_TypeDef *TIMx, TIM_TimeBaseInitTypeDef *TIM_TimeBaseInitStruct)
{ assert_param(IS_TIM_123458_PERIPH(TIMx)); assert_param(IS_TIM_COUNTER_MODE(TIM_TimeBaseInitStruct->TIM_CounterMode)); assert_param(IS_TIM_CKD_DIV(TIM_TimeBaseInitStruct->TIM_ClockDivision)); TIMx->CR1 &= CR1_CKD_Mask & CR1_CounterMode_Mask; TIMx->CR1 |= (uint32_t)TIM_TimeBaseInitStruct->TIM_ClockDivision | TIM_TimeBaseInitStruct->TIM_CounterMode; TIMx->ARR = TIM_TimeBaseInitStruct->TIM_Period ; TIMx->PSC = TIM_TimeBaseInitStruct->TIM_Prescaler; if(*(uint32_t*)&TIMx == TIM1_BASE) { TIMx->RCR = TIM_TimeBaseInitStruct->TIM_RepetitionCounter; } TIMx->EGR = TIM_PSCReloadMode_Immediate; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function allows the user to provide an iterator, which will be called for each stored value in the list. */
void qlist_iter(const QList *qlist, void(*iter)(QObject *obj, void *opaque), void *opaque)
/* This function allows the user to provide an iterator, which will be called for each stored value in the list. */ void qlist_iter(const QList *qlist, void(*iter)(QObject *obj, void *opaque), void *opaque)
{ QListEntry *entry; QTAILQ_FOREACH(entry, &qlist->head, next) iter(entry->value, opaque); }
ve3wwg/teensy3_qemu
C++
Other
15
/* Check the validity of the device path of a ATA AHCI host controller. */
EFI_STATUS AhciIsHcDevicePathValid(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN UINTN DevicePathLength)
/* Check the validity of the device path of a ATA AHCI host controller. */ EFI_STATUS AhciIsHcDevicePathValid(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN UINTN DevicePathLength)
{ EFI_DEVICE_PATH_PROTOCOL *Start; UINTN Size; if (DevicePath == NULL) { return EFI_INVALID_PARAMETER; } if (DevicePathLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) { return EFI_INVALID_PARAMETER; } Start = DevicePath; while (!(DevicePath->Type == END_DEVICE_PATH_TYPE && DevicePath->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)) { DevicePath = NextDevicePathNode (DevicePath); if ((UINTN)DevicePath <= (UINTN)Start) { return EFI_INVALID_PARAMETER; } if ((UINTN)DevicePath - (UINTN)Start > DevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)) { return EFI_INVALID_PARAMETER; } } Size = ((UINTN)DevicePath - (UINTN)Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL); if (Size != DevicePathLength) { return EFI_INVALID_PARAMETER; } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Returns a constant string giving the name of the mode requested. */
const char* ide_xfer_verbose(u8 mode)
/* Returns a constant string giving the name of the mode requested. */ const char* ide_xfer_verbose(u8 mode)
{ const char *s; u8 i = mode & 0xf; if (mode >= XFER_UDMA_0 && mode <= XFER_UDMA_7) s = udma_str[i]; else if (mode >= XFER_MW_DMA_0 && mode <= XFER_MW_DMA_4) s = mwdma_str[i]; else if (mode >= XFER_SW_DMA_0 && mode <= XFER_SW_DMA_2) s = swdma_str[i]; else if (mode >= XFER_PIO_0 && mode <= XFER_PIO_6) s = pio_str[i & 0x7]; else if (mode == XFER_PIO_SLOW) s = "PIO SLOW"; else s = "XFER ERROR"; return s; }
robutest/uclinux
C++
GPL-2.0
60
/* Stack canary error handler. This function is invoked when a stack canary error is detected. */
void _StackCheckHandler(void)
/* Stack canary error handler. This function is invoked when a stack canary error is detected. */ void _StackCheckHandler(void)
{ z_except_reason(K_ERR_STACK_CHK_FAIL); CODE_UNREACHABLE; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* optimize L2 flush all operation by set/way format */
static void xsc3_l2_flush_all(void)
/* optimize L2 flush all operation by set/way format */ static void xsc3_l2_flush_all(void)
{ unsigned long l2ctype, set_way; int set, way; __asm__("mrc p15, 1, %0, c0, c0, 1" : "=r" (l2ctype)); for (set = 0; set < CACHE_SET_SIZE(l2ctype); set++) { for (way = 0; way < CACHE_WAY_PER_SET; way++) { set_way = (way << 29) | (set << 5); __asm__("mcr p15, 1, %0, c7, c15, 2" : : "r"(set_way)); } } dsb(); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* TMSI reallocation complete No data MM Null No data 9.3.1 Alerting */
static void dtap_cc_alerting(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
/* TMSI reallocation complete No data MM Null No data 9.3.1 Alerting */ static void dtap_cc_alerting(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
{ guint32 curr_offset; guint32 consumed; guint curr_len; curr_offset = offset; curr_len = len; is_uplink = IS_UPLINK_TRUE; ELEM_OPT_TLV(0x1c, GSM_A_PDU_TYPE_DTAP, DE_FACILITY, NULL); ELEM_OPT_TLV(0x1e, GSM_A_PDU_TYPE_DTAP, DE_PROG_IND, NULL); ELEM_OPT_TLV(0x7e, GSM_A_PDU_TYPE_DTAP, DE_USER_USER, NULL); ELEM_OPT_TLV(0x7f, GSM_A_PDU_TYPE_DTAP, DE_SS_VER_IND, NULL); EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_dtap_extraneous_data); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function runs timers and the timer-tq in bottom half context. */
static void run_timer_softirq(struct softirq_action *h)
/* This function runs timers and the timer-tq in bottom half context. */ static void run_timer_softirq(struct softirq_action *h)
{ struct tvec_base *base = __get_cpu_var(tvec_bases); hrtimer_run_pending(); if (time_after_eq(jiffies, base->timer_jiffies)) __run_timers(base); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Initialize the game controller system, mostly load our DB of controller config mappings */
int SDL_GameControllerInitMappings(void)
/* Initialize the game controller system, mostly load our DB of controller config mappings */ int SDL_GameControllerInitMappings(void)
{ char szControllerMapPath[1024]; int i = 0; const char *pMappingString = NULL; pMappingString = s_ControllerMappings[i]; while (pMappingString) { SDL_PrivateGameControllerAddMapping(pMappingString, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT); i++; pMappingString = s_ControllerMappings[i]; } if (SDL_GetControllerMappingFilePath(szControllerMapPath, sizeof(szControllerMapPath))) { SDL_GameControllerAddMappingsFromFile(szControllerMapPath); } SDL_GameControllerLoadHints(); SDL_AddHintCallback(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES, SDL_GameControllerIgnoreDevicesChanged, NULL); SDL_AddHintCallback(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT, SDL_GameControllerIgnoreDevicesExceptChanged, NULL); return (0); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* The function creates a memory based bbt by scanning the device for manufacturer / software marked good / bad blocks */
static int nand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
/* The function creates a memory based bbt by scanning the device for manufacturer / software marked good / bad blocks */ static int nand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
{ struct nand_chip *this = mtd->priv; bd->options &= ~NAND_BBT_SCANEMPTY; return create_bbt(mtd, this->buffers->databuf, bd, -1); }
EmcraftSystems/u-boot
C++
Other
181
/* Enables or disables the tim peripheral Preload register on CCR4. */
void TIM_OC4PreloadConfig(TIM_TypeDef *tim, TIMOCPE_Typedef preload)
/* Enables or disables the tim peripheral Preload register on CCR4. */ void TIM_OC4PreloadConfig(TIM_TypeDef *tim, TIMOCPE_Typedef preload)
{ MODIFY_REG(tim->CCMR2, TIM_CCMR2_OC4PEN, preload << 8); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Configure a set of GPIO pins using the given configuration table. Returns 0 on success. */
int lpc178x_gpio_config_table(const struct lpc178x_gpio_pin_config *table, unsigned int len)
/* Configure a set of GPIO pins using the given configuration table. Returns 0 on success. */ int lpc178x_gpio_config_table(const struct lpc178x_gpio_pin_config *table, unsigned int len)
{ unsigned int i; int rv; for (i = 0; i < len; i ++) { rv = lpc178x_gpio_config(&table[i].dsc, table[i].regval); if (rv != 0) goto out; } rv = 0; out: return rv; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Retrieve the EC Private Key from the password-protected PEM key data. */
BOOLEAN EFIAPI CryptoServiceEcGetPrivateKeyFromPem(IN CONST UINT8 *PemData, IN UINTN PemSize, IN CONST CHAR8 *Password, OUT VOID **EcContext)
/* Retrieve the EC Private Key from the password-protected PEM key data. */ BOOLEAN EFIAPI CryptoServiceEcGetPrivateKeyFromPem(IN CONST UINT8 *PemData, IN UINTN PemSize, IN CONST CHAR8 *Password, OUT VOID **EcContext)
{ return CALL_BASECRYPTLIB (Ec.Services.GetPrivateKeyFromPem, EcGetPrivateKeyFromPem, (PemData, PemSize, Password, EcContext), FALSE); }
tianocore/edk2
C++
Other
4,240
/* param base Quad Timer peripheral base address param channel Quad Timer channel number param ticks Timer period in units of ticks */
void QTMR_SetTimerPeriod(TMR_Type *base, qtmr_channel_selection_t channel, uint16_t ticks)
/* param base Quad Timer peripheral base address param channel Quad Timer channel number param ticks Timer period in units of ticks */ void QTMR_SetTimerPeriod(TMR_Type *base, qtmr_channel_selection_t channel, uint16_t ticks)
{ base->CHANNEL[channel].CTRL |= TMR_CTRL_LENGTH_MASK; base->CHANNEL[channel].LOAD &= (uint16_t)(~TMR_LOAD_LOAD_MASK); if ((base->CHANNEL[channel].CTRL & TMR_CTRL_DIR_MASK) != 0U) { base->CHANNEL[channel].COMP2 = ticks - 1U; } else { base->CHANNEL[channel].COMP1 = ticks - 1U; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Configure Modem function. This function configure uart modem. */
void UARTModemCfg(unsigned long ulBase, unsigned long ulCfg)
/* Configure Modem function. This function configure uart modem. */ void UARTModemCfg(unsigned long ulBase, unsigned long ulCfg)
{ unsigned long ulTmpReg = 0; xASSERT(ulBase == UART1_BASE); xASSERT( (ulCfg & ~( LOOPBACK_MODE_EN | LOOPBACK_MODE_DIS | AUTO_RTS_EN | AUTO_RTS_DIS | AUTO_CTS_EN | AUTO_CTS_DIS ) ) == 0); ulTmpReg = xHWREG(ulBase + MCR); ulTmpReg &= ((~ulCfg) >> 16); ulTmpReg |= (ulCfg & 0xFFFF); xHWREG(ulBase + MCR) = ulTmpReg; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104