docstring
stringlengths 22
576
| signature
stringlengths 9
317
| prompt
stringlengths 57
886
| code
stringlengths 20
1.36k
| repository
stringclasses 49
values | language
stringclasses 2
values | license
stringclasses 9
values | stars
int64 15
21.3k
|
|---|---|---|---|---|---|---|---|
/* This code is used to initialize a usb_bus structure, memory for which is separately managed. */
|
static void usb_bus_init(struct usb_bus *bus)
|
/* This code is used to initialize a usb_bus structure, memory for which is separately managed. */
static void usb_bus_init(struct usb_bus *bus)
|
{
memset (&bus->devmap, 0, sizeof(struct usb_devmap));
bus->devnum_next = 1;
bus->root_hub = NULL;
bus->busnum = -1;
bus->bandwidth_allocated = 0;
bus->bandwidth_int_reqs = 0;
bus->bandwidth_isoc_reqs = 0;
INIT_LIST_HEAD (&bus->bus_list);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function changes properties of LEB @lnum. It is a helper wrapper over 'ubifs_change_lp()' which hides lprops get/release. The arguments are the same as in case of 'ubifs_change_lp()'. Returns zero in case of success and a negative error code in case of failure. */
|
int ubifs_change_one_lp(struct ubifs_info *c, int lnum, int free, int dirty, int flags_set, int flags_clean, int idx_gc_cnt)
|
/* This function changes properties of LEB @lnum. It is a helper wrapper over 'ubifs_change_lp()' which hides lprops get/release. The arguments are the same as in case of 'ubifs_change_lp()'. Returns zero in case of success and a negative error code in case of failure. */
int ubifs_change_one_lp(struct ubifs_info *c, int lnum, int free, int dirty, int flags_set, int flags_clean, int idx_gc_cnt)
|
{
int err = 0, flags;
const struct ubifs_lprops *lp;
ubifs_get_lprops(c);
lp = ubifs_lpt_lookup_dirty(c, lnum);
if (IS_ERR(lp)) {
err = PTR_ERR(lp);
goto out;
}
flags = (lp->flags | flags_set) & ~flags_clean;
lp = ubifs_change_lp(c, lp, free, dirty, flags, idx_gc_cnt);
if (IS_ERR(lp))
err = PTR_ERR(lp);
out:
ubifs_release_lprops(c);
if (err)
ubifs_err(c, "cannot change properties of LEB %d, error %d",
lnum, err);
return err;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Interrupt on "pin change" from switch to do wakeup on USB Callback running when USB Host enable mouse interface.
Note: This interrupt is enable when the USB host enable remotewakeup feature This interrupt wakeup the CPU if this one is in idle mode */
|
ISR(PORTF_INT0_vect)
|
/* Interrupt on "pin change" from switch to do wakeup on USB Callback running when USB Host enable mouse interface.
Note: This interrupt is enable when the USB host enable remotewakeup feature This interrupt wakeup the CPU if this one is in idle mode */
ISR(PORTF_INT0_vect)
|
{
PORT_t *port;
port = ioport_pin_to_port(GPIO_PUSH_BUTTON_0);
port->INTFLAGS = 0x01;
udc_remotewakeup();
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Set our PIO requirements. This is fairly simple on the HPT3x3 as all we have to do is clear the MWDMA and UDMA bits then load the mode number. */
|
static void hpt3x3_set_piomode(struct ata_port *ap, struct ata_device *adev)
|
/* Set our PIO requirements. This is fairly simple on the HPT3x3 as all we have to do is clear the MWDMA and UDMA bits then load the mode number. */
static void hpt3x3_set_piomode(struct ata_port *ap, struct ata_device *adev)
|
{
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u32 r1, r2;
int dn = 2 * ap->port_no + adev->devno;
pci_read_config_dword(pdev, 0x44, &r1);
pci_read_config_dword(pdev, 0x48, &r2);
r1 &= ~(7 << (3 * dn));
r1 |= (adev->pio_mode - XFER_PIO_0) << (3 * dn);
r2 &= ~(0x11 << dn);
pci_write_config_dword(pdev, 0x44, r1);
pci_write_config_dword(pdev, 0x48, r2);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Deinitialize SPI to the default state (reset value). */
|
void SPI_DeInit(SPI_Type *pSPI)
|
/* Deinitialize SPI to the default state (reset value). */
void SPI_DeInit(SPI_Type *pSPI)
|
{
int16 i;
pSPI->C1 = SPI_C1_DEFAULT;
pSPI->C2 = SPI_C2_DEFAULT;
pSPI->BR = SPI_BR_DEFAULT;
pSPI->M = SPI_M_DEFAULT;
for(i = 0; i<100; i++);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Releases a Modbus server channel object, previously created with */
|
void TbxMbServerFree(tTbxMbServer channel)
|
/* Releases a Modbus server channel object, previously created with */
void TbxMbServerFree(tTbxMbServer channel)
|
{
TBX_ASSERT(channel != NULL);
if (channel != NULL)
{
tTbxMbServerCtx * serverCtx = (tTbxMbServerCtx *)channel;
TBX_ASSERT(serverCtx->type == TBX_MB_SERVER_CONTEXT_TYPE);
TbxCriticalSectionEnter();
serverCtx->tpCtx->channelCtx = NULL;
serverCtx->tpCtx = NULL;
serverCtx->type = 0U;
serverCtx->pollFcn = NULL;
serverCtx->processFcn = NULL;
TbxCriticalSectionExit();
TbxMemPoolRelease(serverCtx);
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* WWDG MSP Initialization This function configures the hardware resources used in this example. */
|
void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg)
|
/* WWDG MSP Initialization This function configures the hardware resources used in this example. */
void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg)
|
{
if(hwwdg->Instance==WWDG)
{
__HAL_RCC_WWDG_CLK_ENABLE();
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* If any reserved bits in Address are set, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
|
UINT8 EFIAPI PciSegmentBitFieldAndThenOr8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData, IN UINT8 OrData)
|
/* If any reserved bits in Address are set, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT8 EFIAPI PciSegmentBitFieldAndThenOr8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData, IN UINT8 OrData)
|
{
UINTN Count;
PCI_SEGMENT_INFO *SegmentInfo;
SegmentInfo = GetPciSegmentInfo (&Count);
return MmioBitFieldAndThenOr8 (PciSegmentLibGetEcamAddress (Address, SegmentInfo, Count), StartBit, EndBit, AndData, OrData);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* set the register value of WM codec and remember it */
|
static void wm_put_nocache(struct snd_ice1712 *ice, int reg, unsigned short val)
|
/* set the register value of WM codec and remember it */
static void wm_put_nocache(struct snd_ice1712 *ice, int reg, unsigned short val)
|
{
unsigned short cval;
cval = (reg << 9) | val;
snd_vt1724_write_i2c(ice, WM_DEV, cval >> 8, cval & 0xff);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Releases a binary semaphore object, previously created with */
|
void TbxMbOsalSemFree(tTbxMbOsalSem sem)
|
/* Releases a binary semaphore object, previously created with */
void TbxMbOsalSemFree(tTbxMbOsalSem sem)
|
{
TBX_ASSERT(sem != NULL);
if (sem != NULL)
{
tTbxMbOsalSemCtx * semCtx = (tTbxMbOsalSemCtx *)sem;
TBX_ASSERT(semCtx->type == TBX_MB_OSAL_SEM_CONTEXT_TYPE);
TbxMemPoolRelease(semCtx);
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* param base SAI base pointer. param handle Pointer to the sai_handle_t structure which stores the transfer state. param count Bytes count sent. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. */
|
status_t SAI_TransferGetSendCount(I2S_Type *base, sai_handle_t *handle, size_t *count)
|
/* param base SAI base pointer. param handle Pointer to the sai_handle_t structure which stores the transfer state. param count Bytes count sent. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. */
status_t SAI_TransferGetSendCount(I2S_Type *base, sai_handle_t *handle, size_t *count)
|
{
assert(handle);
status_t status = kStatus_Success;
if (handle->state != kSAI_Busy)
{
status = kStatus_NoTransferInProgress;
}
else
{
*count = (handle->transferSize[handle->queueDriver] - handle->saiQueue[handle->queueDriver].dataSize);
}
return status;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This is called to fill in the vector of log iovecs for the given efd log item. We use only 1 iovec, and we point that at the efd_log_format structure embedded in the efd item. It is at this point that we assert that all of the extent slots in the efd item have been filled. */
|
STATIC void xfs_efd_item_format(xfs_efd_log_item_t *efdp, xfs_log_iovec_t *log_vector)
|
/* This is called to fill in the vector of log iovecs for the given efd log item. We use only 1 iovec, and we point that at the efd_log_format structure embedded in the efd item. It is at this point that we assert that all of the extent slots in the efd item have been filled. */
STATIC void xfs_efd_item_format(xfs_efd_log_item_t *efdp, xfs_log_iovec_t *log_vector)
|
{
uint size;
ASSERT(efdp->efd_next_extent == efdp->efd_format.efd_nextents);
efdp->efd_format.efd_type = XFS_LI_EFD;
size = sizeof(xfs_efd_log_format_t);
size += (efdp->efd_format.efd_nextents - 1) * sizeof(xfs_extent_t);
efdp->efd_format.efd_size = 1;
log_vector->i_addr = (xfs_caddr_t)&(efdp->efd_format);
log_vector->i_len = size;
XLOG_VEC_SET_TYPE(log_vector, XLOG_REG_TYPE_EFD_FORMAT);
ASSERT(size >= sizeof(xfs_efd_log_format_t));
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Cortron PS/2 protocol detection. There's no special way to detect it, so it must be forced by sysfs protocol writing. */
|
static int cortron_detect(struct psmouse *psmouse, bool set_properties)
|
/* Cortron PS/2 protocol detection. There's no special way to detect it, so it must be forced by sysfs protocol writing. */
static int cortron_detect(struct psmouse *psmouse, bool set_properties)
|
{
if (set_properties) {
psmouse->vendor = "Cortron";
psmouse->name = "PS/2 Trackball";
__set_bit(BTN_MIDDLE, psmouse->dev->keybit);
__set_bit(BTN_SIDE, psmouse->dev->keybit);
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Removes a "struct epitem" from the eventpoll RB tree and deallocates all the associated resources. Must be called with "mtx" held. */
|
static int ep_remove(struct eventpoll *ep, struct epitem *epi)
|
/* Removes a "struct epitem" from the eventpoll RB tree and deallocates all the associated resources. Must be called with "mtx" held. */
static int ep_remove(struct eventpoll *ep, struct epitem *epi)
|
{
unsigned long flags;
struct file *file = epi->ffd.file;
ep_unregister_pollwait(ep, epi);
spin_lock(&file->f_lock);
if (ep_is_linked(&epi->fllink))
list_del_init(&epi->fllink);
spin_unlock(&file->f_lock);
rb_erase(&epi->rbn, &ep->rbr);
spin_lock_irqsave(&ep->lock, flags);
if (ep_is_linked(&epi->rdllink))
list_del_init(&epi->rdllink);
spin_unlock_irqrestore(&ep->lock, flags);
kmem_cache_free(epi_cache, epi);
atomic_dec(&ep->user->epoll_watches);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Double a value in finite field GF(2^128), defined with modulus X^128+X^7+X^2+X+1. */
|
static void double_gf128(unsigned char *dst, const unsigned char *src)
|
/* Double a value in finite field GF(2^128), defined with modulus X^128+X^7+X^2+X+1. */
static void double_gf128(unsigned char *dst, const unsigned char *src)
|
{
unsigned cc;
int i;
cc = 0x87 & -((unsigned)src[0] >> 7);
for (i = 15; i >= 0; i --) {
unsigned z;
z = (src[i] << 1) ^ cc;
cc = z >> 8;
dst[i] = (unsigned char)z;
}
}
|
arendst/Tasmota
|
C++
|
GNU General Public License v3.0
| 21,318
|
/* FSM start address register (r/w). First available address is 0x033C.. */
|
int32_t lsm6dso_fsm_start_address_set(stmdev_ctx_t *ctx, uint16_t val)
|
/* FSM start address register (r/w). First available address is 0x033C.. */
int32_t lsm6dso_fsm_start_address_set(stmdev_ctx_t *ctx, uint16_t val)
|
{
uint8_t buff[2];
int32_t ret;
buff[1] = (uint8_t) (val / 256U);
buff[0] = (uint8_t) (val - (buff[1] * 256U));
ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_FSM_START_ADD_L,
&buff[0]);
if (ret == 0) {
ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_FSM_START_ADD_H,
&buff[1]);
}
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Initialize the instruction parsing context, which includes decoding the instruction prefixes. */
|
EFI_STATUS CcInitInstructionData(IN OUT CC_INSTRUCTION_DATA *InstructionData, IN GHCB *Ghcb, IN EFI_SYSTEM_CONTEXT_X64 *Regs)
|
/* Initialize the instruction parsing context, which includes decoding the instruction prefixes. */
EFI_STATUS CcInitInstructionData(IN OUT CC_INSTRUCTION_DATA *InstructionData, IN GHCB *Ghcb, IN EFI_SYSTEM_CONTEXT_X64 *Regs)
|
{
SetMem (InstructionData, sizeof (*InstructionData), 0);
InstructionData->Ghcb = Ghcb;
InstructionData->Begin = (UINT8 *)Regs->Rip;
InstructionData->End = (UINT8 *)Regs->Rip;
return DecodePrefixes (Regs, InstructionData);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* One problem of the isdn net device code is that is uses struct net_device for masters and slaves. However, only master interface are registered to the network layer, and therefore, it only makes sense to call netif_* functions on them. */
|
static __inline__ int isdn_net_device_started(isdn_net_dev *n)
|
/* One problem of the isdn net device code is that is uses struct net_device for masters and slaves. However, only master interface are registered to the network layer, and therefore, it only makes sense to call netif_* functions on them. */
static __inline__ int isdn_net_device_started(isdn_net_dev *n)
|
{
isdn_net_local *lp = n->local;
struct net_device *dev;
if (lp->master)
dev = lp->master;
else
dev = n->dev;
return netif_running(dev);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Allocate memory for configure parameter such as timeout value for Dst, then copy the configure parameter from Src to Dst. */
|
EFI_STATUS Dns6CopyConfigure(OUT EFI_DNS6_CONFIG_DATA *Dst, IN EFI_DNS6_CONFIG_DATA *Src)
|
/* Allocate memory for configure parameter such as timeout value for Dst, then copy the configure parameter from Src to Dst. */
EFI_STATUS Dns6CopyConfigure(OUT EFI_DNS6_CONFIG_DATA *Dst, IN EFI_DNS6_CONFIG_DATA *Src)
|
{
UINTN Len;
UINT32 Index;
CopyMem (Dst, Src, sizeof (*Dst));
Dst->DnsServerList = NULL;
if (Src->DnsServerList != NULL) {
Len = Src->DnsServerCount * sizeof (EFI_IPv6_ADDRESS);
Dst->DnsServerList = AllocatePool (Len);
if (Dst->DnsServerList == NULL) {
Dns6CleanConfigure (Dst);
return EFI_OUT_OF_RESOURCES;
}
for (Index = 0; Index < Src->DnsServerCount; Index++) {
CopyMem (&Dst->DnsServerList[Index], &Src->DnsServerList[Index], sizeof (EFI_IPv6_ADDRESS));
}
}
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Setup of the IPI irq handler is done in irq.c:init_IRQ_SMP(). */
|
void __init init_smp_config(void)
|
/* Setup of the IPI irq handler is done in irq.c:init_IRQ_SMP(). */
void __init init_smp_config(void)
|
{
struct fptr {
unsigned long fp;
unsigned long gp;
} *ap_startup;
long sal_ret;
ap_startup = (struct fptr *) start_ap;
sal_ret = ia64_sal_set_vectors(SAL_VECTOR_OS_BOOT_RENDEZ,
ia64_tpa(ap_startup->fp), ia64_tpa(ap_startup->gp), 0, 0, 0, 0);
if (sal_ret < 0)
printk(KERN_ERR "SMP: Can't set SAL AP Boot Rendezvous: %s\n",
ia64_sal_strerror(sal_ret));
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* If applicable, the reference to the target uwb_dev will be released. */
|
void uwb_rsv_terminate(struct uwb_rsv *rsv)
|
/* If applicable, the reference to the target uwb_dev will be released. */
void uwb_rsv_terminate(struct uwb_rsv *rsv)
|
{
struct uwb_rc *rc = rsv->rc;
mutex_lock(&rc->rsvs_mutex);
if (rsv->state != UWB_RSV_STATE_NONE)
uwb_rsv_set_state(rsv, UWB_RSV_STATE_NONE);
mutex_unlock(&rc->rsvs_mutex);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Execute a channel program on @cdev to release an existing PGID reservation. When finished, call ccw_device_stlck_done with a return code specifying the result. */
|
void ccw_device_stlck_start(struct ccw_device *cdev, void *data, void *buf1, void *buf2)
|
/* Execute a channel program on @cdev to release an existing PGID reservation. When finished, call ccw_device_stlck_done with a return code specifying the result. */
void ccw_device_stlck_start(struct ccw_device *cdev, void *data, void *buf1, void *buf2)
|
{
struct subchannel *sch = to_subchannel(cdev->dev.parent);
struct ccw_request *req = &cdev->private->req;
CIO_TRACE_EVENT(4, "stlck");
CIO_HEX_EVENT(4, &cdev->private->dev_id, sizeof(cdev->private->dev_id));
memset(req, 0, sizeof(*req));
req->timeout = PGID_TIMEOUT;
req->maxretries = PGID_RETRIES;
req->lpm = sch->schib.pmcw.pam & sch->opm;
req->data = data;
req->callback = stlck_callback;
stlck_build_cp(cdev, buf1, buf2);
ccw_request_start(cdev);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* serial register for STM32 support STM32F103VB and STM32F103ZE */
|
rt_err_t rt_hw_serial_register(rt_device_t device, const char *name, rt_uint32_t flag, struct avr32_serial_device *serial)
|
/* serial register for STM32 support STM32F103VB and STM32F103ZE */
rt_err_t rt_hw_serial_register(rt_device_t device, const char *name, rt_uint32_t flag, struct avr32_serial_device *serial)
|
{
RT_ASSERT(device != RT_NULL);
if ((flag & RT_DEVICE_FLAG_DMA_RX) ||
(flag & RT_DEVICE_FLAG_INT_TX))
{
RT_ASSERT(0);
}
device->type = RT_Device_Class_Char;
device->rx_indicate = RT_NULL;
device->tx_complete = RT_NULL;
device->init = rt_serial_init;
device->open = rt_serial_open;
device->close = rt_serial_close;
device->read = rt_serial_read;
device->write = rt_serial_write;
device->control = rt_serial_control;
device->user_data = serial;
return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR | flag);
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* The user Entry Point for module GraphicsConsole. The user code starts with this function. */
|
EFI_STATUS EFIAPI InitializeGraphicsConsole(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
/* The user Entry Point for module GraphicsConsole. The user code starts with this function. */
EFI_STATUS EFIAPI InitializeGraphicsConsole(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
{
EFI_STATUS Status;
EfiCreateProtocolNotifyEvent (
&gEfiHiiDatabaseProtocolGuid,
TPL_CALLBACK,
RegisterFontPackage,
NULL,
&mHiiRegistration
);
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
&gGraphicsConsoleDriverBinding,
ImageHandle,
&gGraphicsConsoleComponentName,
&gGraphicsConsoleComponentName2
);
ASSERT_EFI_ERROR (Status);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* do display state change process event until SM is stable */
|
void rmt(struct s_smc *smc, int event)
|
/* do display state change process event until SM is stable */
void rmt(struct s_smc *smc, int event)
|
{
int state ;
do {
DB_RMT("RMT : state %s%s",
(smc->mib.m[MAC0].fddiMACRMTState & AFLAG) ? "ACTIONS " : "",
rmt_states[smc->mib.m[MAC0].fddiMACRMTState & ~AFLAG]) ;
DB_RMT(" event %s\n",rmt_events[event],0) ;
state = smc->mib.m[MAC0].fddiMACRMTState ;
rmt_fsm(smc,event) ;
event = 0 ;
} while (state != smc->mib.m[MAC0].fddiMACRMTState) ;
rmt_state_change(smc,(int)smc->mib.m[MAC0].fddiMACRMTState) ;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* ixgbe_atr_get_src_ipv4_82599 - Gets the source IPv4 address @input: input stream to search @src_addr: the IP address to load */
|
static s32 ixgbe_atr_get_src_ipv4_82599(struct ixgbe_atr_input *input, u32 *src_addr)
|
/* ixgbe_atr_get_src_ipv4_82599 - Gets the source IPv4 address @input: input stream to search @src_addr: the IP address to load */
static s32 ixgbe_atr_get_src_ipv4_82599(struct ixgbe_atr_input *input, u32 *src_addr)
|
{
*src_addr = input->byte_stream[IXGBE_ATR_SRC_IPV4_OFFSET];
*src_addr |= input->byte_stream[IXGBE_ATR_SRC_IPV4_OFFSET + 1] << 8;
*src_addr |= input->byte_stream[IXGBE_ATR_SRC_IPV4_OFFSET + 2] << 16;
*src_addr |= input->byte_stream[IXGBE_ATR_SRC_IPV4_OFFSET + 3] << 24;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* LZ4F_compressBegin() : init streaming compression and writes frame header into dstBuffer. dstBuffer must be >= LZ4F_HEADER_SIZE_MAX bytes. preferencesPtr can be NULL, in which case default parameters are selected. */
|
size_t LZ4F_compressBegin(LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const LZ4F_preferences_t *preferencesPtr)
|
/* LZ4F_compressBegin() : init streaming compression and writes frame header into dstBuffer. dstBuffer must be >= LZ4F_HEADER_SIZE_MAX bytes. preferencesPtr can be NULL, in which case default parameters are selected. */
size_t LZ4F_compressBegin(LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const LZ4F_preferences_t *preferencesPtr)
|
{
return LZ4F_compressBegin_usingCDict(cctxPtr, dstBuffer, dstCapacity,
NULL, preferencesPtr);
}
|
xboot/xboot
|
C++
|
MIT License
| 779
|
/* Return the boot option corresponding to the Boot Manager Menu. It may automatically create one if the boot option hasn't been created yet. */
|
EFI_STATUS EFIAPI EfiBootManagerGetBootManagerMenu(EFI_BOOT_MANAGER_LOAD_OPTION *BootOption)
|
/* Return the boot option corresponding to the Boot Manager Menu. It may automatically create one if the boot option hasn't been created yet. */
EFI_STATUS EFIAPI EfiBootManagerGetBootManagerMenu(EFI_BOOT_MANAGER_LOAD_OPTION *BootOption)
|
{
EFI_STATUS Status;
UINTN BootOptionCount;
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
UINTN Index;
BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
for (Index = 0; Index < BootOptionCount; Index++) {
if (BmIsBootManagerMenuFilePath (BootOptions[Index].FilePath)) {
Status = EfiBootManagerInitializeLoadOption (
BootOption,
BootOptions[Index].OptionNumber,
BootOptions[Index].OptionType,
BootOptions[Index].Attributes,
BootOptions[Index].Description,
BootOptions[Index].FilePath,
BootOptions[Index].OptionalData,
BootOptions[Index].OptionalDataSize
);
ASSERT_EFI_ERROR (Status);
break;
}
}
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
if (Index == BootOptionCount) {
return BmRegisterBootManagerMenu (BootOption);
} else {
return EFI_SUCCESS;
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns: TRUE if the base stream will be closed. */
|
gboolean g_filter_output_stream_get_close_base_stream(GFilterOutputStream *stream)
|
/* Returns: TRUE if the base stream will be closed. */
gboolean g_filter_output_stream_get_close_base_stream(GFilterOutputStream *stream)
|
{
GFilterOutputStreamPrivate *priv;
g_return_val_if_fail (G_IS_FILTER_OUTPUT_STREAM (stream), FALSE);
priv = g_filter_output_stream_get_instance_private (stream);
return priv->close_base;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* USB Device Request - Status Out Stage Parameters: None Return Value: None */
|
void USBD_StatusOutStage(void)
|
/* USB Device Request - Status Out Stage Parameters: None Return Value: None */
void USBD_StatusOutStage(void)
|
{
USBD_ReadEP(0x00, USBD_EP0Buf, usbd_max_packet0);
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Create a command transfer TRB to support XHCI command interfaces. */
|
URB* XhcPeiCreateCmdTrb(IN PEI_XHC_DEV *Xhc, IN TRB_TEMPLATE *CmdTrb)
|
/* Create a command transfer TRB to support XHCI command interfaces. */
URB* XhcPeiCreateCmdTrb(IN PEI_XHC_DEV *Xhc, IN TRB_TEMPLATE *CmdTrb)
|
{
URB *Urb;
Urb = AllocateZeroPool (sizeof (URB));
if (Urb == NULL) {
return NULL;
}
Urb->Signature = XHC_URB_SIG;
Urb->Ring = &Xhc->CmdRing;
XhcPeiSyncTrsRing (Xhc, Urb->Ring);
Urb->TrbNum = 1;
Urb->TrbStart = Urb->Ring->RingEnqueue;
CopyMem (Urb->TrbStart, CmdTrb, sizeof (TRB_TEMPLATE));
Urb->TrbStart->CycleBit = Urb->Ring->RingPCS & BIT0;
Urb->TrbEnd = Urb->TrbStart;
return Urb;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Circular burst-mode (rounding) read of the output registers.. */
|
int32_t lsm6dso_rounding_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_rounding_t val)
|
/* Circular burst-mode (rounding) read of the output registers.. */
int32_t lsm6dso_rounding_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_rounding_t val)
|
{
lsm6dso_ctrl5_c_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t*)®, 1);
if (ret == 0) {
reg.rounding = (uint8_t)val;
ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t*)®, 1);
}
return ret;
}
|
alexander-g-dean/ESF
|
C++
| null | 41
|
/* @ie: information elements of a management frame from the mesh peer */
|
bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie)
|
/* @ie: information elements of a management frame from the mesh peer */
bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie)
|
{
return (ie->mesh_config->meshconf_cap &
MESHCONF_CAPAB_ACCEPT_PLINKS) != 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Sends a byte through the SPI interface and return the byte received from the SPI bus. */
|
uint8_t sEE_SendByte(uint8_t byte)
|
/* Sends a byte through the SPI interface and return the byte received from the SPI bus. */
uint8_t sEE_SendByte(uint8_t byte)
|
{
while (SPI_I2S_GetFlagStatus(sEE_SPI, SPI_I2S_FLAG_TXE) == RESET);
SPI_SendData(sEE_SPI, byte);
while (SPI_I2S_GetFlagStatus(sEE_SPI, SPI_I2S_FLAG_RXNE) == RESET);
return (uint8_t)SPI_ReceiveData(sEE_SPI);
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* not longer needed, will deleted. Actual init the SPD_BUS for compatibility. i2c_adap must be initialized beforehead with function pointers and data, including speed and slaveaddr. */
|
void i2c_init_all(void)
|
/* not longer needed, will deleted. Actual init the SPD_BUS for compatibility. i2c_adap must be initialized beforehead with function pointers and data, including speed and slaveaddr. */
void i2c_init_all(void)
|
{
i2c_init_board();
i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
return;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Multibyte write from device. A register write begins with the address and autoincrements for each additional byte in the transfer. */
|
int32_t ad5770r_spi_reg_write_multiple(struct ad5770r_dev *dev, uint8_t reg_addr, uint8_t *reg_data, uint16_t count)
|
/* Multibyte write from device. A register write begins with the address and autoincrements for each additional byte in the transfer. */
int32_t ad5770r_spi_reg_write_multiple(struct ad5770r_dev *dev, uint8_t reg_addr, uint8_t *reg_data, uint16_t count)
|
{
int32_t ret;
uint8_t *data;
if (!dev | !reg_data)
return FAILURE;
data = (uint8_t*)calloc(count + 1, sizeof(uint8_t));
data[0] = AD5770R_REG_WRITE(reg_addr);
memcpy(&data[1], reg_data, count);
ret = spi_write_and_read(dev->spi_desc, data, count + 1);
free(data);
return ret;
}
|
analogdevicesinc/EVAL-ADICUP3029
|
C++
|
Other
| 36
|
/* Disables USB related GPIOs from performing their USB function. */
|
void USBGPIODisable(void)
|
/* Disables USB related GPIOs from performing their USB function. */
void USBGPIODisable(void)
|
{
EALLOW;
GpioCtrlRegs.GPBLOCK.all = 0x00000000;
GpioCtrlRegs.GPBAMSEL.bit.GPIO42 = 0;
GpioCtrlRegs.GPBAMSEL.bit.GPIO43 = 0;
GpioCtrlRegs.GPDGMUX2.bit.GPIO120 = 0;
GpioCtrlRegs.GPDMUX2.bit.GPIO120 = 0;
GpioCtrlRegs.GPDGMUX2.bit.GPIO121 = 0;
GpioCtrlRegs.GPDMUX2.bit.GPIO121 = 0;
EDIS;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Set f to z, choosing the smallest precision for f so that z = f*(2^BPML)*zs*2^(RetVal) */
|
static int set_z(mpfr_ptr f, mpz_srcptr z, mp_size_t *zs)
|
/* Set f to z, choosing the smallest precision for f so that z = f*(2^BPML)*zs*2^(RetVal) */
static int set_z(mpfr_ptr f, mpz_srcptr z, mp_size_t *zs)
|
{
mp_limb_t *p;
mp_size_t s;
int c;
mpfr_prec_t pf;
MPFR_ASSERTD (mpz_sgn (z) != 0);
for (p = PTR (z), s = *zs = ABS (SIZ (z)) ; *p == 0; p++, s--)
MPFR_ASSERTD (s >= 0);
count_leading_zeros (c, p[s-1]);
pf = s * GMP_NUMB_BITS - c;
if (pf < MPFR_PREC_MIN)
pf = MPFR_PREC_MIN;
mpfr_init2 (f, pf);
if (MPFR_LIKELY (c))
mpn_lshift (MPFR_MANT (f), p, s, c);
else
MPN_COPY (MPFR_MANT (f), p, s);
MPFR_SET_SIGN (f, mpz_sgn (z));
MPFR_SET_EXP (f, 0);
return -c;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Interrupt handler (Yes, we can do it too !!!) */
|
static irqreturn_t simeth_interrupt(int irq, void *dev_id)
|
/* Interrupt handler (Yes, we can do it too !!!) */
static irqreturn_t simeth_interrupt(int irq, void *dev_id)
|
{
struct net_device *dev = dev_id;
while (simeth_rx(dev));
return IRQ_HANDLED;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* param base CMC peripheral base address. param mode System clock mode. */
|
void CMC_SetClockMode(CMC_Type *base, cmc_clock_mode_t mode)
|
/* param base CMC peripheral base address. param mode System clock mode. */
void CMC_SetClockMode(CMC_Type *base, cmc_clock_mode_t mode)
|
{
uint32_t reg;
reg = base->CKCTRL;
reg &= ~CMC_CKCTRL_CKMODE_MASK;
reg |= CMC_CKCTRL_CKMODE((mode));
base->CKCTRL = reg;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Converts an End-of-Device-Path structure to its string representative. */
|
VOID DevPathToTextEndInstance(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
|
/* Converts an End-of-Device-Path structure to its string representative. */
VOID DevPathToTextEndInstance(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
|
{
UefiDevicePathLibCatPrint (Str, L",");
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Unregisters an interrupt handler for a comparator interrupt. */
|
void ComparatorIntUnregister(unsigned long ulBase, unsigned long ulComp)
|
/* Unregisters an interrupt handler for a comparator interrupt. */
void ComparatorIntUnregister(unsigned long ulBase, unsigned long ulComp)
|
{
ASSERT(ulBase == COMP_BASE);
ASSERT(ulComp < 3);
HWREG(ulBase + COMP_O_ACINTEN) &= ~(1 << ulComp);
IntDisable(INT_COMP0 + ulComp);
IntUnregister(INT_COMP0 + ulComp);
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* Function to enable the Accessory Mode on Android Devices. */
|
void uhi_aoa_mode_enable_step3(usb_add_t, uhd_trans_status_t, uint16_t)
|
/* Function to enable the Accessory Mode on Android Devices. */
void uhi_aoa_mode_enable_step3(usb_add_t, uhd_trans_status_t, uint16_t)
|
{
(void)add;
(void)payload_trans;
if (status == UHD_TRANS_NOERROR) {
usb_setup_req_t req;
req.bmRequestType = USB_REQ_RECIP_DEVICE | USB_REQ_TYPE_VENDOR |
USB_REQ_DIR_OUT;
req.bRequest = (uint8_t)USB_REQ_AOA_STARTUP;
req.wValue = 0;
req.wIndex = 0;
req.wLength = 0;
uhd_setup_request(uhi_aoa_dev_sel->dev->address, &req, NULL, 0,
NULL, uhi_aoa_mode_enable_complete);
} else {
uhi_aoa_enable_stage = AOA_ENABLE_STAGE_FAILED;
}
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Print the decimal unsigned QWORD to instruction content. */
|
UINTN EdbPrintData64n(IN UINT64 Data64)
|
/* Print the decimal unsigned QWORD to instruction content. */
UINTN EdbPrintData64n(IN UINT64 Data64)
|
{
EDBSPrintWithOffset (
mInstructionString.Content,
EDB_INSTRUCTION_CONTENT_MAX_SIZE,
mInstructionContentOffset,
L"%ld",
Data64
);
mInstructionContentOffset = mInstructionContentOffset + EdbGetBitWidth (Data64);
return mInstructionContentOffset;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* If the interface is not supported, then ASSERT(). */
|
VOID EFIAPI DhFree(IN VOID *DhContext)
|
/* If the interface is not supported, then ASSERT(). */
VOID EFIAPI DhFree(IN VOID *DhContext)
|
{
CALL_VOID_CRYPTO_SERVICE (DhFree, (DhContext));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns the newly created (duplicated) instance of #CRNum. Must be freed by cr_num_destroy(). */
|
CRNum* cr_num_dup(CRNum *a_this)
|
/* Returns the newly created (duplicated) instance of #CRNum. Must be freed by cr_num_destroy(). */
CRNum* cr_num_dup(CRNum *a_this)
|
{
CRNum *result = NULL;
enum CRStatus status = CR_OK;
g_return_val_if_fail (a_this, NULL);
result = cr_num_new ();
g_return_val_if_fail (result, NULL);
status = cr_num_copy (result, a_this);
g_return_val_if_fail (status == CR_OK, NULL);
return result;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Eliminate the extra spaces in the Str to one space. */
|
VOID BmEliminateExtraSpaces(IN CHAR16 *Str)
|
/* Eliminate the extra spaces in the Str to one space. */
VOID BmEliminateExtraSpaces(IN CHAR16 *Str)
|
{
UINTN Index;
UINTN ActualIndex;
for (Index = 0, ActualIndex = 0; Str[Index] != L'\0'; Index++) {
if ((Str[Index] != L' ') || ((ActualIndex > 0) && (Str[ActualIndex - 1] != L' '))) {
Str[ActualIndex++] = Str[Index];
}
}
Str[ActualIndex] = L'\0';
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Divide two Big Numbers. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */
|
BOOLEAN EFIAPI CryptoServiceBigNumDiv(IN CONST VOID *BnA, IN CONST VOID *BnB, OUT VOID *BnRes)
|
/* Divide two Big Numbers. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */
BOOLEAN EFIAPI CryptoServiceBigNumDiv(IN CONST VOID *BnA, IN CONST VOID *BnB, OUT VOID *BnRes)
|
{
return CALL_BASECRYPTLIB (Bn.Services.Div, BigNumDiv, (BnA, BnB, BnRes), FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Must be called while holding a write on the xtime_lock */
|
void ntp_clear(void)
|
/* Must be called while holding a write on the xtime_lock */
void ntp_clear(void)
|
{
time_adjust = 0;
time_status |= STA_UNSYNC;
time_maxerror = NTP_PHASE_LIMIT;
time_esterror = NTP_PHASE_LIMIT;
ntp_update_frequency();
tick_length = tick_length_base;
time_offset = 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Clock backup before enter stop mode and mark it. */
|
void PWC_STOP_ClockBackup(void)
|
/* Clock backup before enter stop mode and mark it. */
void PWC_STOP_ClockBackup(void)
|
{
__disable_irq();
PWC_ClockBackup();
m_u8StopFlag = 1U;
__enable_irq();
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Note: elfcorehdr_addr is not just limited to vmcore. It is also used by is_kdump_kernel() to determine if we are booting after a panic. Hence ifdef it under CONFIG_CRASH_DUMP and not CONFIG_PROC_VMCORE. */
|
static int __init parse_elfcorehdr(char *p)
|
/* Note: elfcorehdr_addr is not just limited to vmcore. It is also used by is_kdump_kernel() to determine if we are booting after a panic. Hence ifdef it under CONFIG_CRASH_DUMP and not CONFIG_PROC_VMCORE. */
static int __init parse_elfcorehdr(char *p)
|
{
if (p)
elfcorehdr_addr = memparse(p, &p);
return 1;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* iwl3945_print_last_event_logs - Dump the newest # of event log to syslog */
|
static void iwl3945_print_last_event_logs(struct iwl_priv *priv, u32 capacity, u32 num_wraps, u32 next_entry, u32 size, u32 mode)
|
/* iwl3945_print_last_event_logs - Dump the newest # of event log to syslog */
static void iwl3945_print_last_event_logs(struct iwl_priv *priv, u32 capacity, u32 num_wraps, u32 next_entry, u32 size, u32 mode)
|
{
if (num_wraps) {
if (next_entry < size) {
iwl3945_print_event_log(priv,
capacity - (size - next_entry),
size - next_entry, mode);
iwl3945_print_event_log(priv, 0,
next_entry, mode);
} else
iwl3945_print_event_log(priv, next_entry - size,
size, mode);
} else {
if (next_entry < size)
iwl3945_print_event_log(priv, 0, next_entry, mode);
else
iwl3945_print_event_log(priv, next_entry - size,
size, mode);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* PRL_HR_Wait_for_Request Entry State.
All necessary Protocol Hard Reset States (Section 6.12.2.4) */
|
static void prl_hr_wait_for_request_entry(void *obj)
|
/* PRL_HR_Wait_for_Request Entry State.
All necessary Protocol Hard Reset States (Section 6.12.2.4) */
static void prl_hr_wait_for_request_entry(void *obj)
|
{
struct protocol_hard_reset_t *prl_hr = (struct protocol_hard_reset_t *)obj;
LOG_INF("PRL_HR_Wait_for_Request");
prl_hr->flags = ATOMIC_INIT(0);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Get Pairing Information.
This funtions is used to get the pairing information received in an SMP event. */
|
void adi_ble_GetPairingInfo(ADI_BLER_PAIR_INFO *pPairInfo)
|
/* Get Pairing Information.
This funtions is used to get the pairing information received in an SMP event. */
void adi_ble_GetPairingInfo(ADI_BLER_PAIR_INFO *pPairInfo)
|
{
ASSERT(pPairInfo != NULL);
memcpy(pPairInfo, &pBLERadio->sPairInfo, sizeof(ADI_BLER_PAIR_INFO));
}
|
analogdevicesinc/EVAL-ADICUP3029
|
C++
|
Other
| 36
|
/* sets the Duration/ID WiFi frame header conversion parameter */
|
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBWiFiDurationIDSet(IxEthDBPortId portID, UINT16 durationID)
|
/* sets the Duration/ID WiFi frame header conversion parameter */
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBWiFiDurationIDSet(IxEthDBPortId portID, UINT16 durationID)
|
{
IX_ETH_DB_CHECK_PORT(portID);
IX_ETH_DB_CHECK_SINGLE_NPE(portID);
IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
ixEthDBPortInfo[portID].frameControlDurationID = (ixEthDBPortInfo[portID].frameControlDurationID & 0xFFFF0000) | durationID;
return ixEthDBWiFiFrameControlDurationIDUpdate(portID);
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* The minimum duration (LSb = 1/ODR) of the Interrupt 1 event to be recognized .. */
|
int32_t lis2dh12_int2_gen_duration_set(stmdev_ctx_t *ctx, uint8_t val)
|
/* The minimum duration (LSb = 1/ODR) of the Interrupt 1 event to be recognized .. */
int32_t lis2dh12_int2_gen_duration_set(stmdev_ctx_t *ctx, uint8_t val)
|
{
lis2dh12_int2_duration_t int2_duration;
int32_t ret;
ret = lis2dh12_read_reg(ctx, LIS2DH12_INT2_DURATION,
(uint8_t *)&int2_duration, 1);
if (ret == 0)
{
int2_duration.d = val;
ret = lis2dh12_write_reg(ctx, LIS2DH12_INT2_DURATION,
(uint8_t *)&int2_duration, 1);
}
return ret;
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Disable endpoint for transferring data.
This function cancels transfers that are associated with endpoint and disabled endpoint itself. */
|
static bool reset_endpoint(const struct usb_ep_descriptor *ep_desc)
|
/* Disable endpoint for transferring data.
This function cancels transfers that are associated with endpoint and disabled endpoint itself. */
static bool reset_endpoint(const struct usb_ep_descriptor *ep_desc)
|
{
struct usb_dc_ep_cfg_data ep_cfg;
ep_cfg.ep_addr = ep_desc->bEndpointAddress;
ep_cfg.ep_type = ep_desc->bmAttributes & USB_EP_TRANSFER_TYPE_MASK;
LOG_DBG("Reset endpoint 0x%02x type %u",
ep_cfg.ep_addr, ep_cfg.ep_type);
usb_cancel_transfer(ep_cfg.ep_addr);
return disable_endpoint(ep_cfg.ep_addr) ? false : true;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* The alignment of data in here is downright odd. See data sheet. Converting this into a meaningful value is left to inline functions in userspace part of header. */
|
static ssize_t sca3000_read_temp(struct device *dev, struct device_attribute *attr, char *buf)
|
/* The alignment of data in here is downright odd. See data sheet. Converting this into a meaningful value is left to inline functions in userspace part of header. */
static ssize_t sca3000_read_temp(struct device *dev, struct device_attribute *attr, char *buf)
|
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct sca3000_state *st = indio_dev->dev_data;
int len = 0, ret;
int val;
u8 *rx;
ret = sca3000_read_data(st, SCA3000_REG_ADDR_TEMP_MSB, &rx, 2);
if (ret < 0)
goto error_ret;
val = ((rx[1]&0x3F) << 3) | ((rx[2] & 0xE0) >> 5);
len += sprintf(buf + len, "%d\n", val);
kfree(rx);
return len;
error_ret:
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Return a pointer to the extent record at file index idx. */
|
xfs_bmbt_rec_host_t* xfs_iext_get_ext(xfs_ifork_t *ifp, xfs_extnum_t idx)
|
/* Return a pointer to the extent record at file index idx. */
xfs_bmbt_rec_host_t* xfs_iext_get_ext(xfs_ifork_t *ifp, xfs_extnum_t idx)
|
{
ASSERT(idx >= 0);
if ((ifp->if_flags & XFS_IFEXTIREC) && (idx == 0)) {
return ifp->if_u1.if_ext_irec->er_extbuf;
} else if (ifp->if_flags & XFS_IFEXTIREC) {
xfs_ext_irec_t *erp;
int erp_idx = 0;
xfs_extnum_t page_idx = idx;
erp = xfs_iext_idx_to_irec(ifp, &page_idx, &erp_idx, 0);
return &erp->er_extbuf[page_idx];
} else if (ifp->if_bytes) {
return &ifp->if_u1.if_extents[idx];
} else {
return NULL;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Release cache entry, once usage count is zero it can be reused. */
|
void squashfs_cache_put(struct squashfs_cache_entry *entry)
|
/* Release cache entry, once usage count is zero it can be reused. */
void squashfs_cache_put(struct squashfs_cache_entry *entry)
|
{
struct squashfs_cache *cache = entry->cache;
spin_lock(&cache->lock);
entry->refcount--;
if (entry->refcount == 0) {
cache->unused++;
if (cache->num_waiters) {
spin_unlock(&cache->lock);
wake_up(&cache->wait_queue);
return;
}
}
spin_unlock(&cache->lock);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Return: 0 on success or a negative error code on failure. */
|
int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode)
|
/* Return: 0 on success or a negative error code on failure. */
int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode)
|
{
ssize_t err;
err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_POWER_MODE, mode,
sizeof(*mode));
if (err <= 0) {
if (err == 0)
err = -ENODATA;
return err;
}
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* recvrec_buf, recvrec_ack receives bytes from transport medium sendrec_buf, sendrec_ack send bytes to transport medium recvpld_buf, recvpld_ack receives payload data from engine sendpld_buf, sendpld_ack send payload data to engine */
|
static unsigned char* recvrec_buf(const br_ssl_engine_context *rc, size_t *len)
|
/* recvrec_buf, recvrec_ack receives bytes from transport medium sendrec_buf, sendrec_ack send bytes to transport medium recvpld_buf, recvpld_ack receives payload data from engine sendpld_buf, sendpld_ack send payload data to engine */
static unsigned char* recvrec_buf(const br_ssl_engine_context *rc, size_t *len)
|
{
if (rc->shutdown_recv) {
*len = 0;
return NULL;
}
switch (rc->iomode) {
case BR_IO_IN:
case BR_IO_INOUT:
if (rc->ixa == rc->ixb) {
size_t z;
z = rc->ixc;
if (z > rc->ibuf_len - rc->ixa) {
z = rc->ibuf_len - rc->ixa;
}
*len = z;
return rc->ibuf + rc->ixa;
}
break;
}
*len = 0;
return NULL;
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* The header type of IPv6 device path node is MESSAGING_DEVICE_PATH. The header subtype of IPv6 device path node is MSG_IPv6_DP. Get other info from parameters to make up the whole IPv6 device path node. */
|
VOID EFIAPI NetLibCreateIPv6DPathNode(IN OUT IPv6_DEVICE_PATH *Node, IN EFI_HANDLE Controller, IN EFI_IPv6_ADDRESS *LocalIp, IN UINT16 LocalPort, IN EFI_IPv6_ADDRESS *RemoteIp, IN UINT16 RemotePort, IN UINT16 Protocol)
|
/* The header type of IPv6 device path node is MESSAGING_DEVICE_PATH. The header subtype of IPv6 device path node is MSG_IPv6_DP. Get other info from parameters to make up the whole IPv6 device path node. */
VOID EFIAPI NetLibCreateIPv6DPathNode(IN OUT IPv6_DEVICE_PATH *Node, IN EFI_HANDLE Controller, IN EFI_IPv6_ADDRESS *LocalIp, IN UINT16 LocalPort, IN EFI_IPv6_ADDRESS *RemoteIp, IN UINT16 RemotePort, IN UINT16 Protocol)
|
{
ASSERT (Node != NULL && LocalIp != NULL && RemoteIp != NULL);
Node->Header.Type = MESSAGING_DEVICE_PATH;
Node->Header.SubType = MSG_IPv6_DP;
SetDevicePathNodeLength (&Node->Header, sizeof (IPv6_DEVICE_PATH));
CopyMem (&Node->LocalIpAddress, LocalIp, sizeof (EFI_IPv6_ADDRESS));
CopyMem (&Node->RemoteIpAddress, RemoteIp, sizeof (EFI_IPv6_ADDRESS));
Node->LocalPort = LocalPort;
Node->RemotePort = RemotePort;
Node->Protocol = Protocol;
Node->IpAddressOrigin = 0;
Node->PrefixLength = IP6_PREFIX_LENGTH;
ZeroMem (&Node->GatewayIpAddress, sizeof (EFI_IPv6_ADDRESS));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Note that different kinds of host controller have different "scheduling horizons". While one type might support scheduling only 32 frames into the future, others could support scheduling up to 1024 frames into the future. */
|
int usb_get_current_frame_number(struct usb_device *dev)
|
/* Note that different kinds of host controller have different "scheduling horizons". While one type might support scheduling only 32 frames into the future, others could support scheduling up to 1024 frames into the future. */
int usb_get_current_frame_number(struct usb_device *dev)
|
{
return usb_hcd_get_frame_number(dev);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If Length is not aligned on a 16-bit boundary, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). */
|
UINT16* EFIAPI MmioReadBuffer16(IN UINTN StartAddress, IN UINTN Length, OUT UINT16 *Buffer)
|
/* If Length is not aligned on a 16-bit boundary, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16* EFIAPI MmioReadBuffer16(IN UINTN StartAddress, IN UINTN Length, OUT UINT16 *Buffer)
|
{
UINT16 *ReturnBuffer;
ASSERT ((StartAddress & (sizeof (UINT16) - 1)) == 0);
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
ASSERT ((Length & (sizeof (UINT16) - 1)) == 0);
ASSERT (((UINTN)Buffer & (sizeof (UINT16) - 1)) == 0);
ReturnBuffer = Buffer;
while (Length != 0) {
*(Buffer++) = MmioRead16 (StartAddress);
StartAddress += sizeof (UINT16);
Length -= sizeof (UINT16);
}
return ReturnBuffer;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Variable EC point multiplication. EcPointResult = EcPoint * BnPScalar. */
|
BOOLEAN EFIAPI EcPointMul(IN CONST VOID *EcGroup, OUT VOID *EcPointResult, IN CONST VOID *EcPoint, IN CONST VOID *BnPScalar, IN VOID *BnCtx)
|
/* Variable EC point multiplication. EcPointResult = EcPoint * BnPScalar. */
BOOLEAN EFIAPI EcPointMul(IN CONST VOID *EcGroup, OUT VOID *EcPointResult, IN CONST VOID *EcPoint, IN CONST VOID *BnPScalar, IN VOID *BnCtx)
|
{
CALL_CRYPTO_SERVICE (EcPointMul, (EcGroup, EcPointResult, EcPoint, BnPScalar, BnCtx), FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* To read a phy register, mii managements frames are sent to the phy. The frames look like this: pre (32 bits): 0xffff ffff st (2 bits): 01 op (2bits): 10: read 01: write phyad (5 bits): xxxxx regad (5 bits): xxxxx ta (Bus release): data (16 bits): read data */
|
static u32 sh_eth_mii_read_phy_reg(int port, u8 phy_addr, int reg)
|
/* To read a phy register, mii managements frames are sent to the phy. The frames look like this: pre (32 bits): 0xffff ffff st (2 bits): 01 op (2bits): 10: read 01: write phyad (5 bits): xxxxx regad (5 bits): xxxxx ta (Bus release): data (16 bits): read data */
static u32 sh_eth_mii_read_phy_reg(int port, u8 phy_addr, int reg)
|
{
u32 val;
sh_eth_mii_write_phy_bits(port, PHY_INIT, 32);
sh_eth_mii_write_phy_bits(port, 0x1, 2);
sh_eth_mii_write_phy_bits(port, PHY_READ, 2);
sh_eth_mii_write_phy_bits(port, phy_addr, 5);
sh_eth_mii_write_phy_bits(port, reg, 5);
sh_eth_mii_bus_release(port);
sh_eth_mii_read_phy_bits(port, &val, 16);
return val;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* convert cnt from cputimer cnt to hrtimer cnt */
|
static unsigned long _cnt_convert(unsigned long cnt)
|
/* convert cnt from cputimer cnt to hrtimer cnt */
static unsigned long _cnt_convert(unsigned long cnt)
|
{
unsigned long rtn = 0;
unsigned long count = cnt - rt_ktime_cputimer_getcnt();
if (count > (_HRTIMER_MAX_CNT / 2))
return 0;
rtn = (count * rt_ktime_cputimer_getres()) / rt_ktime_hrtimer_getres();
return rtn == 0 ? 1 : rtn;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Reset the Rx CRCR and Tx CRCR registers. */
|
void SPI_ResetCRC(SPI_TypeDef *SPIx)
|
/* Reset the Rx CRCR and Tx CRCR registers. */
void SPI_ResetCRC(SPI_TypeDef *SPIx)
|
{
SPI_CalculateCRCCmd(SPIx, ENABLE);
SPI_Cmd(SPIx, ENABLE);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* This function gets the transparency status from DE_CONTROL register. It returns a double word with the transparent fields properly set, while other fields are 0. */
|
unsigned long deGetTransparency(void)
|
/* This function gets the transparency status from DE_CONTROL register. It returns a double word with the transparent fields properly set, while other fields are 0. */
unsigned long deGetTransparency(void)
|
{
unsigned long de_ctrl;
de_ctrl = SMTC_read2Dreg(DE_CONTROL);
de_ctrl &=
FIELD_MASK(DE_CONTROL_TRANSPARENCY_MATCH) |
FIELD_MASK(DE_CONTROL_TRANSPARENCY_SELECT) |
FIELD_MASK(DE_CONTROL_TRANSPARENCY);
return de_ctrl;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* HID class driver callback function for the creation of HID reports to the host. */
|
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *const HIDInterfaceInfo, uint8_t *const ReportID, const uint8_t ReportType, void *ReportData, uint16_t *const ReportSize)
|
/* HID class driver callback function for the creation of HID reports to the host. */
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *const HIDInterfaceInfo, uint8_t *const ReportID, const uint8_t ReportType, void *ReportData, uint16_t *const ReportSize)
|
{
USB_MediaReport_Data_t* MediaReport = (USB_MediaReport_Data_t*)ReportData;
uint8_t JoyStatus_LCL = Joystick_GetStatus();
uint8_t ButtonStatus_LCL = Buttons_GetStatus();
MediaReport->Mute = ((ButtonStatus_LCL & BUTTONS_BUTTON1) ? true : false);
MediaReport->PlayPause = ((JoyStatus_LCL & JOY_PRESS) ? true : false);
MediaReport->VolumeUp = ((JoyStatus_LCL & JOY_UP) ? true : false);
MediaReport->VolumeDown = ((JoyStatus_LCL & JOY_DOWN) ? true : false);
MediaReport->PreviousTrack = ((JoyStatus_LCL & JOY_LEFT) ? true : false);
MediaReport->NextTrack = ((JoyStatus_LCL & JOY_RIGHT) ? true : false);
*ReportSize = sizeof(USB_MediaReport_Data_t);
return false;
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Scroll the display left without changing the RAM. */
|
void samsungvfdScrollDisplayLeft(void)
|
/* Scroll the display left without changing the RAM. */
void samsungvfdScrollDisplayLeft(void)
|
{
samsungvfd_command(SAMSUNGVFD_CURSORSHIFT | SAMSUNGVFD_DISPLAYMOVE | SAMSUNGVFD_MOVELEFT);
}
|
microbuilder/LPC1343CodeBase
|
C++
|
Other
| 73
|
/* This file is part of the Simba project. */
|
int mock_write_rwlock_module_init(int res)
|
/* This file is part of the Simba project. */
int mock_write_rwlock_module_init(int res)
|
{
harness_mock_write("rwlock_module_init()",
NULL,
0);
harness_mock_write("rwlock_module_init(): return (res)",
&res,
sizeof(res));
return (0);
}
|
eerimoq/simba
|
C++
|
Other
| 337
|
/* BusLogic_ReleaseHostAdapter releases all resources previously acquired to support a specific Host Adapter, including the I/O Address range, and unregisters the BusLogic Host Adapter. */
|
static int __exit BusLogic_ReleaseHostAdapter(struct BusLogic_HostAdapter *HostAdapter)
|
/* BusLogic_ReleaseHostAdapter releases all resources previously acquired to support a specific Host Adapter, including the I/O Address range, and unregisters the BusLogic Host Adapter. */
static int __exit BusLogic_ReleaseHostAdapter(struct BusLogic_HostAdapter *HostAdapter)
|
{
struct Scsi_Host *Host = HostAdapter->SCSI_Host;
scsi_remove_host(Host);
if (BusLogic_FlashPointHostAdapterP(HostAdapter))
FlashPoint_ReleaseHostAdapter(HostAdapter->CardHandle);
BusLogic_DestroyCCBs(HostAdapter);
BusLogic_ReleaseResources(HostAdapter);
release_region(HostAdapter->IO_Address, HostAdapter->AddressCount);
list_del(&HostAdapter->host_list);
scsi_host_put(Host);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Deinitializes the DAC peripheral registers to their default reset values. */
|
void DAC_DeInit(DAC_TypeDef *DACx)
|
/* Deinitializes the DAC peripheral registers to their default reset values. */
void DAC_DeInit(DAC_TypeDef *DACx)
|
{
assert_param(IS_DAC_ALL_PERIPH(DACx));
if (DACx == DAC1)
{
RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC1, ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC1, DISABLE);
}
else
{
RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC2, ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC2, DISABLE);
}
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI channel. */
|
EFI_STATUS EFIAPI IScsiExtScsiPassThruGetNextTargetLun(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN OUT UINT8 **Target, IN OUT UINT64 *Lun)
|
/* Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI channel. */
EFI_STATUS EFIAPI IScsiExtScsiPassThruGetNextTargetLun(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN OUT UINT8 **Target, IN OUT UINT64 *Lun)
|
{
ISCSI_DRIVER_DATA *Private;
ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
UINT8 TargetId[TARGET_MAX_BYTES];
Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
ConfigNvData = &Private->Session->ConfigData->SessionConfigData;
if (((*Target)[0] == 0) && (CompareMem (Lun, ConfigNvData->BootLun, sizeof (UINT64)) == 0)) {
return EFI_NOT_FOUND;
}
SetMem (TargetId, TARGET_MAX_BYTES, 0xFF);
if (CompareMem (*Target, TargetId, TARGET_MAX_BYTES) == 0) {
(*Target)[0] = 0;
CopyMem (Lun, ConfigNvData->BootLun, sizeof (UINT64));
return EFI_SUCCESS;
}
return EFI_INVALID_PARAMETER;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* param config transceiver configurations. param bitWidth audio data bitWidth. param mode audio data channel. param saiChannelMask channel mask value to enable. */
|
void SAI_GetTDMConfig(sai_transceiver_t *config, sai_frame_sync_len_t frameSyncWidth, sai_word_width_t bitWidth, uint32_t dataWordNum, uint32_t saiChannelMask)
|
/* param config transceiver configurations. param bitWidth audio data bitWidth. param mode audio data channel. param saiChannelMask channel mask value to enable. */
void SAI_GetTDMConfig(sai_transceiver_t *config, sai_frame_sync_len_t frameSyncWidth, sai_word_width_t bitWidth, uint32_t dataWordNum, uint32_t saiChannelMask)
|
{
assert(NULL != config);
assert(saiChannelMask != 0U);
assert(dataWordNum <= 32U);
SAI_GetCommonConfig(config, bitWidth, kSAI_Stereo, saiChannelMask);
switch (frameSyncWidth)
{
case kSAI_FrameSyncLenOneBitClk:
config->frameSync.frameSyncWidth = 1U;
break;
case kSAI_FrameSyncLenPerWordWidth:
break;
default:
assert(false);
break;
}
config->frameSync.frameSyncEarly = false;
config->frameSync.frameSyncPolarity = kSAI_PolarityActiveHigh;
config->serialData.dataWordNum = (uint8_t)dataWordNum;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* If HmacSha384Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
|
BOOLEAN EFIAPI HmacSha384Update(IN OUT VOID *HmacSha384Context, IN CONST VOID *Data, IN UINTN DataSize)
|
/* If HmacSha384Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI HmacSha384Update(IN OUT VOID *HmacSha384Context, IN CONST VOID *Data, IN UINTN DataSize)
|
{
return HmacMdUpdate (HmacSha384Context, Data, DataSize);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Note: the TOD should store the current GMT */
|
int m48_tod_set(int year, int month, int day, int hour, int minute, int second)
|
/* Note: the TOD should store the current GMT */
int m48_tod_set(int year, int month, int day, int hour, int minute, int second)
|
{
SYS_TOD_UNPROTECT();
M48_ADDR[CONTROL] |= 0x80;
M48_ADDR[YEAR] = to_bcd(year % 100);
M48_ADDR[MONTH] = to_bcd(month);
M48_ADDR[DAY] = to_bcd(day);
M48_ADDR[DAY_OF_WEEK] = day_of_week(year, month, day) + 1;
M48_ADDR[HOUR] = to_bcd(hour);
M48_ADDR[MINUTE] = to_bcd(minute);
M48_ADDR[SECOND] = to_bcd(second);
M48_ADDR[CONTROL] &= ~0x80;
SYS_TOD_PROTECT();
return 0;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Serializes a pubrel packet into the supplied buffer. */
|
int mqtt_serialize_pubcomp(unsigned char *buf, int buflen, unsigned short packetid)
|
/* Serializes a pubrel packet into the supplied buffer. */
int mqtt_serialize_pubcomp(unsigned char *buf, int buflen, unsigned short packetid)
|
{
return mqtt_serialize_ack(buf, buflen, MQTTPACKET_PUBCOMP, 0, packetid);
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* Get Timer Interrupt status. This function is used to get timer interrupts status. */
|
unsigned long TimerIntStatusGet(unsigned long ulBase)
|
/* Get Timer Interrupt status. This function is used to get timer interrupts status. */
unsigned long TimerIntStatusGet(unsigned long ulBase)
|
{
xASSERT((ulBase == TIMER0_BASE) || (ulBase == TIMER1_BASE) ||
(ulBase == TIMER2_BASE) || (ulBase == TIMER3_BASE) );
return (xHWREG(ulBase + TIMER_IR));
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* NOTE! NOTE! NOTE! We're called with the inode lock held, and the drop function is supposed to release the lock! */
|
static void iput_final(struct inode *inode)
|
/* NOTE! NOTE! NOTE! We're called with the inode lock held, and the drop function is supposed to release the lock! */
static void iput_final(struct inode *inode)
|
{
const struct super_operations *op = inode->i_sb->s_op;
void (*drop)(struct inode *) = generic_drop_inode;
if (op && op->drop_inode)
drop = op->drop_inode;
drop(inode);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Return the max packet size for endpoint zero. This function is the first function called to get descriptors during bus enumeration. */
|
EFI_STATUS UsbGetMaxPacketSize0(IN USB_DEVICE *UsbDev)
|
/* Return the max packet size for endpoint zero. This function is the first function called to get descriptors during bus enumeration. */
EFI_STATUS UsbGetMaxPacketSize0(IN USB_DEVICE *UsbDev)
|
{
EFI_USB_DEVICE_DESCRIPTOR DevDesc;
EFI_STATUS Status;
UINTN Index;
for (Index = 0; Index < 3; Index++) {
Status = UsbCtrlGetDesc (UsbDev, USB_DESC_TYPE_DEVICE, 0, 0, &DevDesc, 8);
if (!EFI_ERROR (Status)) {
if ((DevDesc.BcdUSB >= 0x0300) && (DevDesc.MaxPacketSize0 == 9)) {
UsbDev->MaxPacket0 = 1 << 9;
return EFI_SUCCESS;
}
UsbDev->MaxPacket0 = DevDesc.MaxPacketSize0;
return EFI_SUCCESS;
}
gBS->Stall (USB_RETRY_MAX_PACK_SIZE_STALL);
}
return EFI_DEVICE_ERROR;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Checks whether the specified RTC flag is set or not. */
|
FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG)
|
/* Checks whether the specified RTC flag is set or not. */
FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG)
|
{
FlagStatus bitstatus = RESET;
assert_param(IS_RTC_GET_FLAG(RTC_FLAG));
if ((RTC->CRL & RTC_FLAG) != (uint16_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
|
gcallipo/RadioDSP-Stm32f103
|
C++
|
Common Creative - Attribution 3.0
| 51
|
/* The state of the device after initialization is: */
|
int XQspiPs_CfgInitialize(XQspiPs *InstancePtr, XQspiPs_Config *ConfigPtr, u32 EffectiveAddr)
|
/* The state of the device after initialization is: */
int XQspiPs_CfgInitialize(XQspiPs *InstancePtr, XQspiPs_Config *ConfigPtr, u32 EffectiveAddr)
|
{
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(ConfigPtr != NULL);
if (InstancePtr->IsBusy == TRUE) {
return XST_DEVICE_IS_STARTED;
}
InstancePtr->IsBusy = FALSE;
InstancePtr->Config.BaseAddress = EffectiveAddr;
InstancePtr->StatusHandler = StubStatusHandler;
InstancePtr->SendBufferPtr = NULL;
InstancePtr->RecvBufferPtr = NULL;
InstancePtr->RequestedBytes = 0;
InstancePtr->RemainingBytes = 0;
InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
InstancePtr->Config.ConnectionMode = ConfigPtr->ConnectionMode;
XQspiPs_Reset(InstancePtr);
return XST_SUCCESS;
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* This function is the ethernetif_input task, it is processed when a packet is ready to be read from the interface. It uses the function low_level_input() that should handle the actual reception of bytes from the network interface. Then the type of the received packet is determined and the appropriate input function is called. */
|
void ethernetif_input(void const *argument)
|
/* This function is the ethernetif_input task, it is processed when a packet is ready to be read from the interface. It uses the function low_level_input() that should handle the actual reception of bytes from the network interface. Then the type of the received packet is determined and the appropriate input function is called. */
void ethernetif_input(void const *argument)
|
{
struct pbuf *p;
struct netif *netif = (struct netif *) argument;
for( ;; )
{
if (osSemaphoreWait( s_xSemaphore, TIME_WAITING_FOR_INPUT)==osOK)
{
do
{
LOCK_TCPIP_CORE();
p = low_level_input( netif );
if (p != NULL)
{
if (netif->input( p, netif) != ERR_OK )
{
pbuf_free(p);
}
}
UNLOCK_TCPIP_CORE();
}while(p!=NULL);
}
}
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Returns the new blob or NULL if there's no memory available */
|
struct inode_smack* new_inode_smack(char *smack)
|
/* Returns the new blob or NULL if there's no memory available */
struct inode_smack* new_inode_smack(char *smack)
|
{
struct inode_smack *isp;
isp = kzalloc(sizeof(struct inode_smack), GFP_KERNEL);
if (isp == NULL)
return NULL;
isp->smk_inode = smack;
isp->smk_flags = 0;
mutex_init(&isp->smk_lock);
return isp;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* same as encode_bch(), but process input data one byte at a time */
|
static void encode_bch_unaligned(struct bch_control *bch, const unsigned char *data, unsigned int len, uint32_t *ecc)
|
/* same as encode_bch(), but process input data one byte at a time */
static void encode_bch_unaligned(struct bch_control *bch, const unsigned char *data, unsigned int len, uint32_t *ecc)
|
{
int i;
const uint32_t *p;
const int l = BCH_ECC_WORDS(bch)-1;
while (len--) {
p = bch->mod8_tab + (l+1)*(((ecc[0] >> 24)^(*data++)) & 0xff);
for (i = 0; i < l; i++)
ecc[i] = ((ecc[i] << 8)|(ecc[i+1] >> 24))^(*p++);
ecc[l] = (ecc[l] << 8)^(*p);
}
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Clear the FIFO buffer of the specified SPI port. */
|
void SPIFIFOClear(unsigned long ulBase, unsigned long ulRxTx)
|
/* Clear the FIFO buffer of the specified SPI port. */
void SPIFIFOClear(unsigned long ulBase, unsigned long ulRxTx)
|
{
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE)||(ulBase == SPI3_BASE) );
xHWREG(ulBase + SPI_FIFOCTL) |= ulRxTx;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* The Start() function is designed to be invoked from the EFI boot service ConnectController(). As a result, much of the error checking on the parameters to Start() has been moved into this common boot service. It is legal to call Start() from other locations, but the following calling restrictions must be followed or the system behavior will not be deterministic. */
|
EFI_STATUS EFIAPI IScsiIp6DriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
|
/* The Start() function is designed to be invoked from the EFI boot service ConnectController(). As a result, much of the error checking on the parameters to Start() has been moved into this common boot service. It is legal to call Start() from other locations, but the following calling restrictions must be followed or the system behavior will not be deterministic. */
EFI_STATUS EFIAPI IScsiIp6DriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
|
{
EFI_STATUS Status;
Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_6);
if (Status == EFI_ALREADY_STARTED) {
Status = EFI_SUCCESS;
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* publish the name of a keyring so that it can be found by name (if it has one) */
|
static void keyring_publish_name(struct key *keyring)
|
/* publish the name of a keyring so that it can be found by name (if it has one) */
static void keyring_publish_name(struct key *keyring)
|
{
int bucket;
if (keyring->description) {
bucket = keyring_hash(keyring->description);
write_lock(&keyring_name_lock);
if (!keyring_name_hash[bucket].next)
INIT_LIST_HEAD(&keyring_name_hash[bucket]);
list_add_tail(&keyring->type_data.link,
&keyring_name_hash[bucket]);
write_unlock(&keyring_name_lock);
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Initiates a reads packet operation.
The I2C_SLAVE_CALLBACK_WRITE_REQUEST callback can be used to call this function. */
|
enum status_code i2c_slave_read_packet_job(struct i2c_slave_module *const module, struct i2c_slave_packet *const packet)
|
/* Initiates a reads packet operation.
The I2C_SLAVE_CALLBACK_WRITE_REQUEST callback can be used to call this function. */
enum status_code i2c_slave_read_packet_job(struct i2c_slave_module *const module, struct i2c_slave_packet *const packet)
|
{
Assert(module);
Assert(module->hw);
Assert(packet);
if (module->buffer_remaining > 0) {
return STATUS_BUSY;
}
module->buffer = packet->data;
module->buffer_remaining = packet->data_length;
module->buffer_length = packet->data_length;
module->status = STATUS_BUSY;
SercomI2cs *const i2c_hw = &(module->hw->I2CS);
i2c_hw->INTENSET.reg = SERCOM_I2CS_INTFLAG_AMATCH |
SERCOM_I2CS_INTFLAG_DRDY | SERCOM_I2CS_INTFLAG_PREC;
return STATUS_OK;
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* IDL long NetrServerAuthenticate( IDL wchar_t *ServerName, IDL wchar_t *UserName, IDL short secure_challenge_type, IDL wchar_t *ComputerName, IDL CREDENTIAL client_challenge, IDL CREDENTIAL server_challenge IDL ); */
|
static int netlogon_dissect_netrserverauthenticate_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
|
/* IDL long NetrServerAuthenticate( IDL wchar_t *ServerName, IDL wchar_t *UserName, IDL short secure_challenge_type, IDL wchar_t *ComputerName, IDL CREDENTIAL client_challenge, IDL CREDENTIAL server_challenge IDL ); */
static int netlogon_dissect_netrserverauthenticate_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
|
{
offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
pinfo, tree, di, drep);
offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, di, drep,
NDR_POINTER_REF, "User Name", hf_netlogon_acct_name, CB_STR_COL_INFO);
offset = netlogon_dissect_NETLOGON_SECURE_CHANNEL_TYPE(tvb, offset,
pinfo, tree, di, drep);
offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, di, drep,
NDR_POINTER_REF, "Computer Name", hf_netlogon_computer_name, CB_STR_COL_INFO);
offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, di, drep,
netlogon_dissect_CREDENTIAL, NDR_POINTER_REF,
"CREDENTIAL: client challenge", -1);
return offset;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Return SMBIOS string for the given string number. */
|
CHAR8* LibGetSmbiosString(IN SMBIOS_STRUCTURE_POINTER *Smbios, IN UINT16 StringNumber)
|
/* Return SMBIOS string for the given string number. */
CHAR8* LibGetSmbiosString(IN SMBIOS_STRUCTURE_POINTER *Smbios, IN UINT16 StringNumber)
|
{
UINT16 Index;
CHAR8 *String;
ASSERT (Smbios != NULL);
String = (CHAR8 *)(Smbios->Raw + Smbios->Hdr->Length);
for (Index = 1; Index <= StringNumber; Index++) {
if (StringNumber == Index) {
return String;
}
for ( ; *String != 0; String++) {
}
String++;
if (*String == 0) {
Smbios->Raw = (UINT8 *)++String;
return NULL;
}
}
return NULL;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Indicates whether the autoreload match interrupt (ARRMIE) is enabled. @rmtoll IER ARRMIE LPTIM_IsEnabledIT_ARRM. */
|
uint32_t LPTIM_IsEnabledIT_ARRM(LPTIM_Module *LPTIMx)
|
/* Indicates whether the autoreload match interrupt (ARRMIE) is enabled. @rmtoll IER ARRMIE LPTIM_IsEnabledIT_ARRM. */
uint32_t LPTIM_IsEnabledIT_ARRM(LPTIM_Module *LPTIMx)
|
{
return (((READ_BIT(LPTIMx->INTEN, LPTIM_INTEN_ARRMIE) == LPTIM_INTEN_ARRMIE)? 1UL : 0UL));
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Returns the version numbers, identifiers, and capabilities from the processor module. */
|
int pdc_model_info(struct pdc_model *model)
|
/* Returns the version numbers, identifiers, and capabilities from the processor module. */
int pdc_model_info(struct pdc_model *model)
|
{
int retval;
unsigned long flags;
spin_lock_irqsave(&pdc_lock, flags);
retval = mem_pdc_call(PDC_MODEL, PDC_MODEL_INFO, __pa(pdc_result), 0);
convert_to_wide(pdc_result);
memcpy(model, pdc_result, sizeof(*model));
spin_unlock_irqrestore(&pdc_lock, flags);
return retval;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Builds fc hdr and ct hdr for FDMI requests. */
|
u16 fc_fdmi_reqhdr_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 cmd_code)
|
/* Builds fc hdr and ct hdr for FDMI requests. */
u16 fc_fdmi_reqhdr_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 cmd_code)
|
{
struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
u32 d_id = bfa_os_hton3b(FC_MGMT_SERVER);
fc_gs_fchdr_build(fchs, d_id, s_id, 0);
fc_gs_fdmi_cthdr_build(cthdr, s_id, cmd_code);
return sizeof(struct ct_hdr_s);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function must guarantee that all I/O read and write operations are serialized. If such operations are not supported, then ASSERT(). */
|
UINT64 EFIAPI IoWriteWorker(IN UINTN Port, IN EFI_CPU_IO_PROTOCOL_WIDTH Width, IN UINT64 Data)
|
/* This function must guarantee that all I/O read and write operations are serialized. If such operations are not supported, then ASSERT(). */
UINT64 EFIAPI IoWriteWorker(IN UINTN Port, IN EFI_CPU_IO_PROTOCOL_WIDTH Width, IN UINT64 Data)
|
{
EFI_STATUS Status;
Status = mCpuIo->Io.Write (mCpuIo, Width, Port, 1, &Data);
ASSERT_EFI_ERROR (Status);
return Data;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Get the on-disk location and compressed size of the datablock specified by index. Fill_meta_index() does most of the work. */
|
static int read_blocklist(struct inode *inode, int index, u64 *block)
|
/* Get the on-disk location and compressed size of the datablock specified by index. Fill_meta_index() does most of the work. */
static int read_blocklist(struct inode *inode, int index, u64 *block)
|
{
u64 start;
long long blks;
int offset;
__le32 size;
int res = fill_meta_index(inode, index, &start, &offset, block);
TRACE("read_blocklist: res %d, index %d, start 0x%llx, offset"
" 0x%x, block 0x%llx\n", res, index, start, offset,
*block);
if (res < 0)
return res;
if (res < index) {
blks = read_indexes(inode->i_sb, index - res, &start, &offset);
if (blks < 0)
return (int) blks;
*block += blks;
}
res = squashfs_read_metadata(inode->i_sb, &size, &start, &offset,
sizeof(size));
if (res < 0)
return res;
return le32_to_cpu(size);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Local Divide function.
This function does the divide */
|
static int tmrHw_divide(int num, int denom)
|
/* Local Divide function.
This function does the divide */
static int tmrHw_divide(int num, int denom)
|
{
int r;
int t = 1;
while ((denom & 0x40000000) == 0) {
denom = denom << 1;
t = t << 1;
}
r = 0;
do {
if ((num - denom) >= 0) {
num = num - denom;
r = r + t;
}
denom = denom >> 1;
t = t >> 1;
} while (t != 0);
return r;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.