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
/* checks whether this descriptor contains start of frame. This function is to check whether the descriptor's data buffer contains a fresh ethernet frame? */
bool synopGMAC_is_sof_in_rx_desc(DmaDesc *desc)
/* checks whether this descriptor contains start of frame. This function is to check whether the descriptor's data buffer contains a fresh ethernet frame? */ bool synopGMAC_is_sof_in_rx_desc(DmaDesc *desc)
{ return ((desc -> status & DescRxFirst) == DescRxFirst); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* NOTICE: Do NOT hold either the hvcs_struct.lock or hvcs_structs_lock when calling this function or you will get deadlock. */
static struct hvcs_struct* hvcs_get_by_index(int index)
/* NOTICE: Do NOT hold either the hvcs_struct.lock or hvcs_structs_lock when calling this function or you will get deadlock. */ static struct hvcs_struct* hvcs_get_by_index(int index)
{ struct hvcs_struct *hvcsd = NULL; unsigned long flags; spin_lock(&hvcs_structs_lock); if (index >= 0 && index < HVCS_MAX_SERVER_ADAPTERS) { list_for_each_entry(hvcsd, &hvcs_structs, next) { spin_lock_irqsave(&hvcsd->lock, flags); if (hvcsd->index == index) { kref_get(&hvcsd->kref); spin_unlock_irqrestore(&hvcsd->lock, flags); spin_unlock(&hvcs_structs_lock); return hvcsd; } spin_unlock_irqrestore(&hvcsd->lock, flags); } hvcsd = NULL; } spin_unlock(&hvcs_structs_lock); return hvcsd; }
robutest/uclinux
C++
GPL-2.0
60
/* Therefore, if the application writer wants FPU registers to be saved on interrupt entry their IRQ handler must be called vApplicationFPUSafeIRQHandler(), and if the application writer does not want FPU registers to be saved on interrupt entry their IRQ handler must be called vApplicationIRQHandler(). */
void vApplicationFPUSafeIRQHandler(uint32_t ulICCIAR) __attribute__((weak))
/* Therefore, if the application writer wants FPU registers to be saved on interrupt entry their IRQ handler must be called vApplicationFPUSafeIRQHandler(), and if the application writer does not want FPU registers to be saved on interrupt entry their IRQ handler must be called vApplicationIRQHandler(). */ void vApplicationFPUSafeIRQHandler(uint32_t ulICCIAR) __attribute__((weak))
{ ( void ) ulICCIARx; configASSERT( ( volatile void * ) NULL ); }
ua1arn/hftrx
C++
null
69
/* Clear one bit of the runtime register while keeping other bits. */
VOID XhcPeiClearRuntimeRegBit(IN PEI_XHC_DEV *Xhc, IN UINT32 Offset, IN UINT32 Bit)
/* Clear one bit of the runtime register while keeping other bits. */ VOID XhcPeiClearRuntimeRegBit(IN PEI_XHC_DEV *Xhc, IN UINT32 Offset, IN UINT32 Bit)
{ UINT32 Data; Data = XhcPeiReadRuntimeReg (Xhc, Offset); Data &= ~Bit; XhcPeiWriteRuntimeReg (Xhc, Offset, Data); }
tianocore/edk2
C++
Other
4,240
/* This function unregisters poll callbacks from the associated file descriptor. Must be called with "mtx" held (or "epmutex" if called from ep_free). */
static void ep_unregister_pollwait(struct eventpoll *ep, struct epitem *epi)
/* This function unregisters poll callbacks from the associated file descriptor. Must be called with "mtx" held (or "epmutex" if called from ep_free). */ static void ep_unregister_pollwait(struct eventpoll *ep, struct epitem *epi)
{ struct list_head *lsthead = &epi->pwqlist; struct eppoll_entry *pwq; while (!list_empty(lsthead)) { pwq = list_first_entry(lsthead, struct eppoll_entry, llink); list_del(&pwq->llink); remove_wait_queue(pwq->whead, &pwq->wait); kmem_cache_free(pwq_cache, pwq); } }
robutest/uclinux
C++
GPL-2.0
60
/* Build and send a ACK packet for download. */
EFI_STATUS Mtftp6RrqSendAck(IN MTFTP6_INSTANCE *Instance, IN UINT16 BlockNum)
/* Build and send a ACK packet for download. */ EFI_STATUS Mtftp6RrqSendAck(IN MTFTP6_INSTANCE *Instance, IN UINT16 BlockNum)
{ EFI_MTFTP6_PACKET *Ack; NET_BUF *Packet; EFI_STATUS Status; Status = EFI_SUCCESS; Packet = NetbufAlloc (sizeof (EFI_MTFTP6_ACK_HEADER)); if (Packet == NULL) { return EFI_OUT_OF_RESOURCES; } Ack = (EFI_MTFTP6_PACKET *)NetbufAllocSpace ( Packet, sizeof (EFI_MTFTP6_ACK_HEADER), FALSE ); ASSERT (Ack != NULL); Ack->Ack.OpCode = HTONS (EFI_MTFTP6_OPCODE_ACK); Ack->Ack.Block[0] = HTONS (BlockNum); Instance->CurRetry = 0; Instance->LastPacket = Packet; Status = Mtftp6TransmitPacket (Instance, Packet); if (!EFI_ERROR (Status)) { Instance->AckedBlock = Instance->TotalBlock; } return Status; }
tianocore/edk2
C++
Other
4,240
/* If the pointer to the HOB list is NULL, then ASSERT(). */
VOID* EFIAPI GetHobList(VOID)
/* If the pointer to the HOB list is NULL, then ASSERT(). */ VOID* EFIAPI GetHobList(VOID)
{ EFI_STATUS Status; VOID *HobList; Status = PeiServicesGetHobList (&HobList); ASSERT_EFI_ERROR (Status); ASSERT (HobList != NULL); return HobList; }
tianocore/edk2
C++
Other
4,240
/* Send an unread alert notification to the given category. */
static int ble_svc_ans_unr_alert_notify(uint8_t cat_id)
/* Send an unread alert notification to the given category. */ static int ble_svc_ans_unr_alert_notify(uint8_t cat_id)
{ ble_svc_ans_unr_alert_stat[0] = cat_id; ble_svc_ans_unr_alert_stat[1] = ble_svc_ans_unr_alert_cnt[cat_id]; return ble_gattc_notify(ble_svc_ans_conn_handle, ble_svc_ans_unr_alert_val_handle); }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Function checking if length of event is correct, given the frame data. */
static bool length_is_valid(uint8_t *p_data, uint8_t length)
/* Function checking if length of event is correct, given the frame data. */ static bool length_is_valid(uint8_t *p_data, uint8_t length)
{ if (length == 0 || (length == 1 && p_data[0] == 0)) { return true; } else { switch ((es_frame_type_t)p_data[0]) { case ES_FRAME_TYPE_UID: return length == ESCS_UID_WRITE_LENGTH; case ES_FRAME_TYPE_URL: return ((length >= ESCS_URL_MIN_WRITE_LENGTH) && (length <= ESCS_URL_WRITE_LENGTH)); case ES_FRAME_TYPE_TLM: return (length == ESCS_TLM_WRITE_LENGTH); case ES_FRAME_TYPE_EID: return ((length == ESCS_EID_WRITE_ECDH_LENGTH) || (length == ESCS_EID_WRITE_IDK_LENGTH)); default: return false; } } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Find a variable with the given name 'n'. If it is an upvalue, add this upvalue into all intermediate functions. If it is a global, set 'var' as 'void' as a flag. */
static void singlevaraux(FuncState *fs, TString *n, expdesc *var, int base)
/* Find a variable with the given name 'n'. If it is an upvalue, add this upvalue into all intermediate functions. If it is a global, set 'var' as 'void' as a flag. */ static void singlevaraux(FuncState *fs, TString *n, expdesc *var, int base)
{ int v = searchvar(fs, n, var); if (v >= 0) { if (v == VLOCAL && !base) markupval(fs, var->u.var.vidx); } else { int idx = searchupvalue(fs, n); if (idx < 0) { singlevaraux(fs->prev, n, var, 0); if (var->k == VLOCAL || var->k == VUPVAL) idx = newupvalue(fs, n, var); else return; } init_exp(var, VUPVAL, idx); } } }
Nicholas3388/LuaNode
C++
Other
1,055
/* Enables or disables the analog watchdog on single/all regular or injected channels. */
void ADC_AnalogWatchdogCmd(ADC_TypeDef *ADCx, uint32_t ADC_AnalogWatchdog)
/* Enables or disables the analog watchdog on single/all regular or injected channels. */ void ADC_AnalogWatchdogCmd(ADC_TypeDef *ADCx, uint32_t ADC_AnalogWatchdog)
{ uint32_t tmpreg = 0; assert_param(IS_ADC_ALL_PERIPH(ADCx)); assert_param(IS_ADC_ANALOG_WATCHDOG(ADC_AnalogWatchdog)); tmpreg = ADCx->CR1; tmpreg &= CR1_AWDMode_Reset; tmpreg |= ADC_AnalogWatchdog; ADCx->CR1 = tmpreg; }
gcallipo/RadioDSP-Stm32f103
C++
Common Creative - Attribution 3.0
51
/* Put a request structure back to the free list */
static void raw3215_free_req(struct raw3215_req *req)
/* Put a request structure back to the free list */ static void raw3215_free_req(struct raw3215_req *req)
{ unsigned long flags; if (req->type == RAW3215_FREE) return; req->type = RAW3215_FREE; spin_lock_irqsave(&raw3215_freelist_lock, flags); req->next = raw3215_freelist; raw3215_freelist = req; spin_unlock_irqrestore(&raw3215_freelist_lock, flags); }
robutest/uclinux
C++
GPL-2.0
60
/* Reserve nocache dynamically proportionally to the amount of system RAM. */
static void srmmu_nocache_calcsize(void)
/* Reserve nocache dynamically proportionally to the amount of system RAM. */ static void srmmu_nocache_calcsize(void)
{ unsigned long sysmemavail = probe_memory() / 1024; int srmmu_nocache_npages; srmmu_nocache_npages = sysmemavail / SRMMU_NOCACHE_ALCRATIO / 1024 * 256; if (srmmu_nocache_npages < SRMMU_MIN_NOCACHE_PAGES) srmmu_nocache_npages = SRMMU_MIN_NOCACHE_PAGES; if (srmmu_nocache_npages > SRMMU_MAX_NOCACHE_PAGES) srmmu_nocache_npages = SRMMU_MAX_NOCACHE_PAGES; srmmu_nocache_size = srmmu_nocache_npages * PAGE_SIZE; srmmu_nocache_end = SRMMU_NOCACHE_VADDR + srmmu_nocache_size; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* We don't need to re-check for the cgroup/cpuset membership, since we're holding cgroup_lock() at this point. */
static void cpuset_change_flag(struct task_struct *tsk, struct cgroup_scanner *scan)
/* We don't need to re-check for the cgroup/cpuset membership, since we're holding cgroup_lock() at this point. */ static void cpuset_change_flag(struct task_struct *tsk, struct cgroup_scanner *scan)
{ cpuset_update_task_spread_flag(cgroup_cs(scan->cg), tsk); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enables or disables write access to IWDG_PR and IWDG_RLR registers. */
void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess)
/* Enables or disables write access to IWDG_PR and IWDG_RLR registers. */ void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess)
{ assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess)); IWDG->KR = IWDG_WriteAccess; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This is called if the connection has gone bad ... try to kill off all the current inodes. */
void smb_invalidate_inodes(struct smb_sb_info *server)
/* This is called if the connection has gone bad ... try to kill off all the current inodes. */ void smb_invalidate_inodes(struct smb_sb_info *server)
{ VERBOSE("\n"); shrink_dcache_sb(SB_of(server)); invalidate_inodes(SB_of(server)); }
robutest/uclinux
C++
GPL-2.0
60
/* Create the actual show/store functions and data structures. */
static ssize_t store_scan(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
/* Create the actual show/store functions and data structures. */ static ssize_t store_scan(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{ struct Scsi_Host *shost = class_to_shost(dev); int res; res = scsi_scan(shost, buf); if (res == 0) res = count; return res; }
robutest/uclinux
C++
GPL-2.0
60
/* N.B. this function is only ever called from knfsd and ownership of locks is never checked. */
int lock_may_write(struct inode *inode, loff_t start, unsigned long len)
/* N.B. this function is only ever called from knfsd and ownership of locks is never checked. */ int lock_may_write(struct inode *inode, loff_t start, unsigned long len)
{ struct file_lock *fl; int result = 1; lock_kernel(); for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { if (IS_POSIX(fl)) { if ((fl->fl_end < start) || (fl->fl_start > (start + len))) continue; } else if (IS_FLOCK(fl)) { if (!(fl->fl_type & LOCK_MAND)) continue; if (fl->fl_type & LOCK_WRITE) continue; } else continue; result = 0; break; } unlock_kernel(); return result; }
robutest/uclinux
C++
GPL-2.0
60
/* Config the DAC peripheral according to the specified parameters in the dacConfig. */
void DAC_Config(uint32_t channel, DAC_Config_T *dacConfig)
/* Config the DAC peripheral according to the specified parameters in the dacConfig. */ void DAC_Config(uint32_t channel, DAC_Config_T *dacConfig)
{ uint32_t temp1 = 0, temp2 = 0; temp1 = DAC->CTRL; temp1 &= ~(((uint32_t)0x00000FFE) << channel); temp2 = ((uint32_t)dacConfig->trigger | \ (uint32_t)dacConfig->waveGeneration | \ (uint32_t)dacConfig->maskAmplitudeSelect | \ (uint32_t)dacConfig->outputBuffer); temp1 |= temp2 << channel; DAC->CTRL = temp1; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* @fh: file handle @file_size: pointer to receive file size Return: status code */
static efi_status_t efi_get_file_size(struct file_handle *fh, loff_t *file_size)
/* @fh: file handle @file_size: pointer to receive file size Return: status code */ static efi_status_t efi_get_file_size(struct file_handle *fh, loff_t *file_size)
{ if (set_blk_dev(fh)) return EFI_DEVICE_ERROR; if (fs_size(fh->path, file_size)) return EFI_DEVICE_ERROR; return EFI_SUCCESS; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Select the Sleep mode or not in Peli workmode. */
void CAN_Peli_SleepMode_Cmd(FunctionalState state)
/* Select the Sleep mode or not in Peli workmode. */ void CAN_Peli_SleepMode_Cmd(FunctionalState state)
{ (state == ENABLE) ? (CAN1_PELI->MOD |= CAN_SleepMode) : (CAN1_PELI->MOD &= ~CAN_SleepMode); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If an error occurs, disable the video queue. This will wake all pending buffers, making sure userspace applications are notified of the problem instead of waiting forever. */
int uvc_video_resume(struct uvc_streaming *stream)
/* If an error occurs, disable the video queue. This will wake all pending buffers, making sure userspace applications are notified of the problem instead of waiting forever. */ int uvc_video_resume(struct uvc_streaming *stream)
{ int ret; stream->frozen = 0; ret = uvc_commit_video(stream, &stream->ctrl); if (ret < 0) { uvc_queue_enable(&stream->queue, 0); return ret; } if (!uvc_queue_streaming(&stream->queue)) return 0; ret = uvc_init_video(stream, GFP_NOIO); if (ret < 0) uvc_queue_enable(&stream->queue, 0); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* The function is used to configure several receive message objects. */
int32_t CAN_SetMultiRxMsg(CAN_T *tCAN, uint32_t u32MsgNum, uint32_t u32MsgCount, uint32_t u32IDType, uint32_t u32ID)
/* The function is used to configure several receive message objects. */ int32_t CAN_SetMultiRxMsg(CAN_T *tCAN, uint32_t u32MsgNum, uint32_t u32MsgCount, uint32_t u32IDType, uint32_t u32ID)
{ int32_t rev = (int32_t)TRUE; uint32_t i; uint32_t u32TimeOutCount; uint32_t u32EOB_Flag = 0ul; for (i = 1ul; i <= u32MsgCount; i++) { u32TimeOutCount = 0ul; u32MsgNum += (i - 1ul); if (i == u32MsgCount) { u32EOB_Flag = 1ul; } else { } while (CAN_SetRxMsgObj(tCAN, (uint8_t)u32MsgNum, (uint8_t)u32IDType, u32ID, (uint8_t)u32EOB_Flag) == (int32_t)FALSE) { if (++u32TimeOutCount >= RETRY_COUNTS) { rev = (int32_t)FALSE; break; } else { } } } return rev; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return code 0 - Successful (currently alway return 0) */
static int lpfc_rscn_recovery_check(struct lpfc_vport *vport)
/* Return code 0 - Successful (currently alway return 0) */ static int lpfc_rscn_recovery_check(struct lpfc_vport *vport)
{ struct lpfc_nodelist *ndlp = NULL; list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { if (!NLP_CHK_NODE_ACT(ndlp) || (ndlp->nlp_state == NLP_STE_UNUSED_NODE) || !lpfc_rscn_payload_check(vport, ndlp->nlp_DID)) continue; lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RECOVERY); lpfc_cancel_retry_delay_tmo(vport, ndlp); } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Check that the given (port, pin) pair is a valid LPC178x/7x GPIO pin. Returns 0 on success, -EINVAL otherwise. */
static int lpc178x_validate_gpio(const struct lpc178x_gpio_dsc *dsc)
/* Check that the given (port, pin) pair is a valid LPC178x/7x GPIO pin. Returns 0 on success, -EINVAL otherwise. */ static int lpc178x_validate_gpio(const struct lpc178x_gpio_dsc *dsc)
{ int rv; rv = 0; if (!dsc || dsc->port >= LPC178X_GPIO_PORTS || dsc->pin >= LPC178X_GPIO_NORMAL_PORT_PINS || (dsc->port == LPC178X_GPIO_PORTS - 1 && dsc->pin >= LPC178X_GPIO_LAST_PORT_PINS)) { if (gd->have_console) { printf("GPIO: incorrect params %d.%d.\n", dsc ? dsc->port : -1, dsc ? dsc->pin : -1); } rv = -EINVAL; } return rv; }
EmcraftSystems/u-boot
C++
Other
181
/* Set power and data role et PD message header. */
USBPD_StatusTypeDef fusb305_tcpc_set_msg_header(uint32_t PortNum, USBPD_PortPowerRole_TypeDef PowerRole, USBPD_PortDataRole_TypeDef DataRole)
/* Set power and data role et PD message header. */ USBPD_StatusTypeDef fusb305_tcpc_set_msg_header(uint32_t PortNum, USBPD_PortPowerRole_TypeDef PowerRole, USBPD_PortDataRole_TypeDef DataRole)
{ state[PortNum].Registers.FrameInfo.u1.MESSAGE_HEADER_INFO = TCPC_REG_MSG_HEADER_INFO_SET(DataRole, PowerRole); return USBPD_TCPCI_WriteRegister(PortNum, TCPC_REG_MSG_HEADER_INFO, &state[PortNum].Registers.FrameInfo.u1.MESSAGE_HEADER_INFO, 1); }
st-one/X-CUBE-USB-PD
C++
null
110
/* Copies descriptors into the buffer, returning the length or a negative error code if they can't all be copied. Useful when assembling descriptors for an associated set of interfaces used as part of configuring a composite device; or in other cases where sets of descriptors need to be marshaled. */
int usb_descriptor_fillbuf(void *buf, unsigned buflen, const struct usb_descriptor_header **src)
/* Copies descriptors into the buffer, returning the length or a negative error code if they can't all be copied. Useful when assembling descriptors for an associated set of interfaces used as part of configuring a composite device; or in other cases where sets of descriptors need to be marshaled. */ int usb_descriptor_fillbuf(void *buf, unsigned buflen, const struct usb_descriptor_header **src)
{ u8 *dest = buf; if (!src) return -EINVAL; for (; NULL != *src; src++) { unsigned len = (*src)->bLength; if (len > buflen) return -EINVAL; memcpy(dest, *src, len); buflen -= len; dest += len; } return dest - (u8 *)buf; }
robutest/uclinux
C++
GPL-2.0
60
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI S3PciSegmentWrite16(IN UINT64 Address, IN UINT16 Value)
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */ UINT16 EFIAPI S3PciSegmentWrite16(IN UINT64 Address, IN UINT16 Value)
{ return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentWrite16 (Address, Value)); }
tianocore/edk2
C++
Other
4,240
/* TEI interrupt processing for UART mode. The TEI interrupt fires after the last byte is transmitted on the TX pin. The user callback function is called with the UART_EVENT_TX_COMPLETE event code (if it is registered in */
void sci_uart_tei_isr(void)
/* TEI interrupt processing for UART mode. The TEI interrupt fires after the last byte is transmitted on the TX pin. The user callback function is called with the UART_EVENT_TX_COMPLETE event code (if it is registered in */ void sci_uart_tei_isr(void)
{ FSP_CONTEXT_SAVE; IRQn_Type irq = R_FSP_CurrentIrqGet(); sci_uart_instance_ctrl_t * p_ctrl = (sci_uart_instance_ctrl_t *) R_FSP_IsrContextGet(irq); p_ctrl->p_reg->SCR &= (uint8_t) ~(SCI_SCR_TIE_MASK | SCI_SCR_TEIE_MASK); r_sci_negate_de_pin(p_ctrl); if (NULL != p_ctrl->p_callback) { r_sci_uart_call_callback(p_ctrl, 0U, UART_EVENT_TX_COMPLETE); } R_BSP_IrqStatusClear(irq); FSP_CONTEXT_RESTORE; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* pci_allocate_cap_save_buffers - allocate buffers for saving capabilities @dev: the PCI device */
void pci_allocate_cap_save_buffers(struct pci_dev *dev)
/* pci_allocate_cap_save_buffers - allocate buffers for saving capabilities @dev: the PCI device */ void pci_allocate_cap_save_buffers(struct pci_dev *dev)
{ int error; error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_EXP, PCI_EXP_SAVE_REGS * sizeof(u16)); if (error) dev_err(&dev->dev, "unable to preallocate PCI Express save buffer\n"); error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_PCIX, sizeof(u16)); if (error) dev_err(&dev->dev, "unable to preallocate PCI-X save buffer\n"); }
robutest/uclinux
C++
GPL-2.0
60
/* Configure pins as Analog Input Output EVENT_OUT EXTI */
void MX_GPIO_Init(void)
/* Configure pins as Analog Input Output EVENT_OUT EXTI */ void MX_GPIO_Init(void)
{ LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOF); LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA); }
pikasTech/PikaPython
C++
MIT License
1,403
/* hwaddr_aton - Convert ASCII string to MAC address @txt: MAC address as a string (e.g., "00:11:22:33:44:55") @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes) Returns: 0 on success, -1 on failure (e.g., string not a MAC address) */
static int hwaddr_aton_i(const char *txt, u8 *addr)
/* hwaddr_aton - Convert ASCII string to MAC address @txt: MAC address as a string (e.g., "00:11:22:33:44:55") @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes) Returns: 0 on success, -1 on failure (e.g., string not a MAC address) */ static int hwaddr_aton_i(const char *txt, u8 *addr)
{ int i; for (i = 0; i < 6; i++) { int a, b; a = hex2num_i(*txt++); if (a < 0) return -1; b = hex2num_i(*txt++); if (b < 0) return -1; *addr++ = (a << 4) | b; if (i < 5 && *txt++ != ':') return -1; } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* attempts to read up to len bytes from SPI channel into a buffer starting at pBuff. */
int spi_Read_CPU(unsigned char *pBuff, int len)
/* attempts to read up to len bytes from SPI channel into a buffer starting at pBuff. */ int spi_Read_CPU(unsigned char *pBuff, int len)
{ unsigned long ulCnt; unsigned long ulStatusReg; unsigned long *ulDataIn; unsigned long ulTxReg; unsigned long ulRxReg; MAP_SPICSEnable(LSPI_BASE); ulDataIn = (unsigned long *)pBuff; ulCnt = (len + 3) >> 2; ulStatusReg = LSPI_BASE+MCSPI_O_CH0STAT; ulTxReg = LSPI_BASE + MCSPI_O_TX0; ulRxReg = LSPI_BASE + MCSPI_O_RX0; while(ulCnt--) { while(!( HWREG(ulStatusReg)& MCSPI_CH0STAT_TXS )); HWREG(ulTxReg) = 0xFFFFFFFF; while(!( HWREG(ulStatusReg)& MCSPI_CH0STAT_RXS )); *ulDataIn = HWREG(ulRxReg); ulDataIn++; } MAP_SPICSDisable(LSPI_BASE); return len; }
micropython/micropython
C++
Other
18,334
/* Try to detect the exact revision of the omap we're running on */
void __init omap2_check_revision(void)
/* Try to detect the exact revision of the omap we're running on */ void __init omap2_check_revision(void)
{ if (cpu_is_omap24xx()) { omap24xx_check_revision(); } else if (cpu_is_omap34xx()) { omap3_check_revision(); omap3_check_features(); omap3_cpuinfo(); return; } else if (cpu_is_omap44xx()) { omap4_check_revision(); return; } else { pr_err("OMAP revision unknown, please fix!\n"); } if (cpu_is_omap243x()) { omap_chip.oc |= CHIP_IS_OMAP2430; return; } else if (cpu_is_omap242x()) { omap_chip.oc |= CHIP_IS_OMAP2420; return; } pr_err("Uninitialized omap_chip, please fix!\n"); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Complete tag computation. The final tag is written in ctx->cbcmac. */
static void do_final(br_eax_context *ctx)
/* Complete tag computation. The final tag is written in ctx->cbcmac. */ static void do_final(br_eax_context *ctx)
{ size_t u; do_pad(ctx); for (u = 0; u < 16; u ++) { ctx->cbcmac[u] ^= ctx->nonce[u] ^ ctx->head[u]; } }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* CreateObject-Error ::= SEQUENCE { errorType Error, firstFailedElementNumber Unsigned } } */
static guint fCreateObjectError(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
/* CreateObject-Error ::= SEQUENCE { errorType Error, firstFailedElementNumber Unsigned } } */ static guint fCreateObjectError(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
{ guint lastoffset = 0; while (tvb_reported_length_remaining(tvb, offset) > 0) { lastoffset = offset; switch (fTagNo(tvb, offset)) { case 0: offset = fContextTaggedError(tvb, pinfo, tree, offset); break; case 1: offset = fUnsignedTag(tvb, pinfo, tree, offset, "first failed element number: "); break; default: return offset; } if (offset == lastoffset) break; } return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* SEQ OF Any enumeration (current usage is SEQ OF BACnetDoorAlarmState */
static guint fSequenceOfEnums(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, const gchar *label, const value_string *vs)
/* SEQ OF Any enumeration (current usage is SEQ OF BACnetDoorAlarmState */ static guint fSequenceOfEnums(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, const gchar *label, const value_string *vs)
{ guint8 tag_no, tag_info; guint32 lvt; guint lastoffset = 0; while (tvb_reported_length_remaining(tvb, offset) > 0) { lastoffset = offset; fTagHeader(tvb, pinfo, offset, &tag_no, &tag_info, &lvt); if (tag_is_closing(tag_info) ) { return offset; } offset = fApplicationTypesEnumerated(tvb, pinfo, tree, offset, label, vs); if ( offset == lastoffset ) break; } return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Enables AHB2 peripheral clock during Low Power (Sleep) mode. */
void RCM_EnableAHB2PeriphClockLPMode(uint32_t AHB2Periph)
/* Enables AHB2 peripheral clock during Low Power (Sleep) mode. */ void RCM_EnableAHB2PeriphClockLPMode(uint32_t AHB2Periph)
{ RCM->LPAHB2CLKEN |= AHB2Periph; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Disable the time tick or alarm interrupt of RTC. The */
void RTCIntDisable(unsigned long ulIntType)
/* Disable the time tick or alarm interrupt of RTC. The */ void RTCIntDisable(unsigned long ulIntType)
{ xASSERT(((ulIntType & RTC_INT_TIME_TICK) == RTC_INT_TIME_TICK) || ((ulIntType & RTC_INT_ALARM) == RTC_INT_ALARM) || ((ulIntType & RTC_INT_OVERFLOW) == RTC_INT_OVERFLOW)); xHWREG(RTC_IER) &= ~ulIntType; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Push buffered characters whether they were just recently buffered or waiting on a blocked hypervisor. Call this function with hp->lock held. */
static int hvc_push(struct hvc_struct *hp)
/* Push buffered characters whether they were just recently buffered or waiting on a blocked hypervisor. Call this function with hp->lock held. */ static int hvc_push(struct hvc_struct *hp)
{ int n; n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf); if (n <= 0) { if (n == 0) { hp->do_wakeup = 1; return 0; } hp->n_outbuf = 0; } else hp->n_outbuf -= n; if (hp->n_outbuf > 0) memmove(hp->outbuf, hp->outbuf + n, hp->n_outbuf); else hp->do_wakeup = 1; return n; }
robutest/uclinux
C++
GPL-2.0
60
/* atl1c_remove is called by the PCI subsystem to alert the driver that it should release a PCI device. The could be caused by a Hot-Plug event, or because the driver is going to be removed from memory. */
static void __devexit atl1c_remove(struct pci_dev *pdev)
/* atl1c_remove is called by the PCI subsystem to alert the driver that it should release a PCI device. The could be caused by a Hot-Plug event, or because the driver is going to be removed from memory. */ static void __devexit atl1c_remove(struct pci_dev *pdev)
{ struct net_device *netdev = pci_get_drvdata(pdev); struct atl1c_adapter *adapter = netdev_priv(netdev); unregister_netdev(netdev); atl1c_phy_disable(&adapter->hw); iounmap(adapter->hw.hw_addr); pci_release_regions(pdev); pci_disable_device(pdev); free_netdev(netdev); }
robutest/uclinux
C++
GPL-2.0
60
/* Select the low power mode used in deep sleep. */
void pwr_set_low_power_mode_selection(uint32_t lpms)
/* Select the low power mode used in deep sleep. */ void pwr_set_low_power_mode_selection(uint32_t lpms)
{ uint32_t reg32; reg32 = PWR_CR1; reg32 &= ~(PWR_CR1_LPMS_MASK << PWR_CR1_LPMS_SHIFT); PWR_CR1 = (reg32 | (lpms << PWR_CR1_LPMS_SHIFT)); }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Retrieve IRQ number for the given hardware instance. */
static uint8_t _usart_get_irq_num(const void *const hw)
/* Retrieve IRQ number for the given hardware instance. */ static uint8_t _usart_get_irq_num(const void *const hw)
{ ASSERT(hw); return USART0_IRQn + _usart_get_hardware_index(hw); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Register the Service B.5 and all its Characteristics... */
void service_b_5_2_init(void)
/* Register the Service B.5 and all its Characteristics... */ void service_b_5_2_init(void)
{ bt_gatt_service_register(&service_b_5_2_svc); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Burgundy volume: 0 - 100, stereo, 2-byte reg */
static void snd_pmac_burgundy_write_volume_2b(struct snd_pmac *chip, unsigned int address, long *volume, int off)
/* Burgundy volume: 0 - 100, stereo, 2-byte reg */ static void snd_pmac_burgundy_write_volume_2b(struct snd_pmac *chip, unsigned int address, long *volume, int off)
{ int lvolume, rvolume; off |= off << 2; lvolume = volume[0] ? volume[0] + BURGUNDY_VOLUME_OFFSET : 0; rvolume = volume[1] ? volume[1] + BURGUNDY_VOLUME_OFFSET : 0; snd_pmac_burgundy_wcb(chip, address + off, lvolume); snd_pmac_burgundy_wcb(chip, address + off + 0x500, rvolume); }
robutest/uclinux
C++
GPL-2.0
60
/* get SPI CRC send value or receive value */
uint16_t spi_crc_get(uint32_t spi_periph, uint8_t crc)
/* get SPI CRC send value or receive value */ uint16_t spi_crc_get(uint32_t spi_periph, uint8_t crc)
{ if(SPI_CRC_TX == crc){ return ((uint16_t)(SPI_TCRC(spi_periph))); }else{ return ((uint16_t)(SPI_RCRC(spi_periph))); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns 0 if @key1 and @key2 are equal. Returns >0 if @key1 is greater. Returns <0 if @key2 is greater.. */
static int befs_compare_strings(const void *key1, int keylen1, const void *key2, int keylen2)
/* Returns 0 if @key1 and @key2 are equal. Returns >0 if @key1 is greater. Returns <0 if @key2 is greater.. */ static int befs_compare_strings(const void *key1, int keylen1, const void *key2, int keylen2)
{ int len = min_t(int, keylen1, keylen2); int result = strncmp(key1, key2, len); if (result == 0) result = keylen1 - keylen2; return result; }
robutest/uclinux
C++
GPL-2.0
60
/* Mark all dentries for 'parent' as invalid, forcing them to be re-read */
void smb_invalidate_dircache_entries(struct dentry *parent)
/* Mark all dentries for 'parent' as invalid, forcing them to be re-read */ void smb_invalidate_dircache_entries(struct dentry *parent)
{ struct smb_sb_info *server = server_from_dentry(parent); struct list_head *next; struct dentry *dentry; spin_lock(&dcache_lock); next = parent->d_subdirs.next; while (next != &parent->d_subdirs) { dentry = list_entry(next, struct dentry, d_u.d_child); dentry->d_fsdata = NULL; smb_age_dentry(server, dentry); next = next->next; } spin_unlock(&dcache_lock); }
robutest/uclinux
C++
GPL-2.0
60
/* Update a specific portion of the physical screen */
void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h)
/* Update a specific portion of the physical screen */ void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h)
{ if ( screen ) { SDL_Rect rect; if ( w == 0 ) w = screen->w; if ( h == 0 ) h = screen->h; if ( (int)(x+w) > screen->w ) return; if ( (int)(y+h) > screen->h ) return; rect.x = (Sint16)x; rect.y = (Sint16)y; rect.w = (Uint16)w; rect.h = (Uint16)h; SDL_UpdateRects(screen, 1, &rect); } }
DC-SWAT/DreamShell
C++
null
404
/* Returns a monotonically increasing count for the platform. */
EFI_STATUS EFIAPI UnitTestGetNextMonotonicCount(OUT UINT64 *Count)
/* Returns a monotonically increasing count for the platform. */ EFI_STATUS EFIAPI UnitTestGetNextMonotonicCount(OUT UINT64 *Count)
{ STATIC UINT64 StaticCount = 0; *Count = StaticCount++; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* If any reserved bits in Address are set, then ASSERT(). */
UINT8 EFIAPI S3PciSegmentWrite8(IN UINT64 Address, IN UINT8 Value)
/* If any reserved bits in Address are set, then ASSERT(). */ UINT8 EFIAPI S3PciSegmentWrite8(IN UINT64 Address, IN UINT8 Value)
{ return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentWrite8 (Address, Value)); }
tianocore/edk2
C++
Other
4,240
/* param config Pointer to the structure pmu_static_lpsr_ana_ldo_config_t. Please refer to pmu_static_lpsr_ana_ldo_config_t. */
void PMU_StaticGetLpsrAnaLdoDefaultConfig(pmu_static_lpsr_ana_ldo_config_t *config)
/* param config Pointer to the structure pmu_static_lpsr_ana_ldo_config_t. Please refer to pmu_static_lpsr_ana_ldo_config_t. */ void PMU_StaticGetLpsrAnaLdoDefaultConfig(pmu_static_lpsr_ana_ldo_config_t *config)
{ assert(config != NULL); (void)memset(config, 0, sizeof(*config)); config->mode = kPMU_HighPowerMode; config->enable2mALoad = true; config->enable20uALoad = false; config->enable4mALoad = true; config->enableStandbyMode = false; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* mark the superblock by the MTD device it is using */
static int get_sb_mtd_set(struct super_block *sb, void *_mtd)
/* mark the superblock by the MTD device it is using */ static int get_sb_mtd_set(struct super_block *sb, void *_mtd)
{ struct mtd_info *mtd = _mtd; sb->s_mtd = mtd; sb->s_dev = MKDEV(MTD_BLOCK_MAJOR, mtd->index); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This function is used by repack to count the number of BPDT and S-BPDT entries that are present. It frees the current buffers used by the entries and allocates fresh buffers that can be used for repacking. Returns BPDT entries which are empty and need to be filled in. */
static void __bpdt_reset(struct buffer *b, size_t count, size_t size)
/* This function is used by repack to count the number of BPDT and S-BPDT entries that are present. It frees the current buffers used by the entries and allocates fresh buffers that can be used for repacking. Returns BPDT entries which are empty and need to be filled in. */ static void __bpdt_reset(struct buffer *b, size_t count, size_t size)
{ size_t bpdt_size = BPDT_HEADER_SIZE + count * BPDT_ENTRY_SIZE; assert(size >= bpdt_size); if (buffer_size(b) != size) { struct buffer temp; alloc_buffer(&temp, size, b->name); memcpy(buffer_get(&temp), buffer_get(b), buffer_size(b)); buffer_delete(b); *b = temp; } struct bpdt *bpdt = buffer_get(b); uint8_t *ptr = (uint8_t *)&bpdt->e[0]; size_t entries_size = BPDT_ENTRY_SIZE * count; memset(ptr, 0, entries_size); memset(ptr + entries_size, 0xFF, size - bpdt_size); bpdt->h.descriptor_count = count; }
4ms/stm32mp1-baremetal
C++
Other
137
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */
void Vector0_handler(void)
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */ void Vector0_handler(void)
{ asm { LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (0 * 2)) JMP 0,X } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Format ID is in bits: 128 127 124 123 122 (hf_gsm_a_rr_format_id) */
static guint16 dissect_arfcn_list(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
/* Format ID is in bits: 128 127 124 123 122 (hf_gsm_a_rr_format_id) */ static guint16 dissect_arfcn_list(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
{ guint32 curr_offset; guint8 oct; curr_offset = offset; oct = tvb_get_guint8(tvb, curr_offset); proto_tree_add_item(tree, hf_gsm_a_rr_format_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN); curr_offset += dissect_arfcn_list_core(tvb, tree, pinfo, offset, len, add_string, string_len, oct); return(curr_offset - offset); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Enable the PWM output of the PWM module. The */
void xPWMOutputEnable(unsigned long ulBase, unsigned long ulChannel)
/* Enable the PWM output of the PWM module. The */ void xPWMOutputEnable(unsigned long ulBase, unsigned long ulChannel)
{ PWMOutputEnable(ulBase, ulChannel); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* this function write time to SLCD DATA register */
void slcd_seg_time_display(uint8_t hour, uint8_t minute, uint8_t second)
/* this function write time to SLCD DATA register */ void slcd_seg_time_display(uint8_t hour, uint8_t minute, uint8_t second)
{ uint8_t i = 0x00 , ch[6]; ch[0] = hour/10; ch[1] = hour%10; ch[2] = minute/10; ch[3] = minute%10; ch[4] = second/10; ch[5] = second%10; while(slcd_flag_get(SLCD_FLAG_UPRF)); while (i < 6){ slcd_seg_digit_write(ch[i], i+1 , TIME); i++; } slcd_data_update_request(); }
liuxuming/trochili
C++
Apache License 2.0
132
/* Compute inverse MDCT of size N = 2^nbits */
void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input)
/* Compute inverse MDCT of size N = 2^nbits */ void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input)
{ int k; int n = 1 << s->mdct_bits; int n2 = n >> 1; int n4 = n >> 2; ff_imdct_half_c(s, output+n4, input); for(k = 0; k < n4; k++) { output[k] = -output[n2-k-1]; output[n-k-1] = output[n2+k]; } }
DC-SWAT/DreamShell
C++
null
404
/* retval kStatus_Success Enable System High Voltage Detect successfully. */
status_t SPC_EnableActiveModeSystemHighVoltageDetect(SPC_Type *base, bool enable)
/* retval kStatus_Success Enable System High Voltage Detect successfully. */ status_t SPC_EnableActiveModeSystemHighVoltageDetect(SPC_Type *base, bool enable)
{ status_t status = kStatus_Success; if (enable) { base->ACTIVE_CFG |= SPC_ACTIVE_CFG_SYS_HVDE_MASK; } else { base->ACTIVE_CFG &= ~SPC_ACTIVE_CFG_SYS_HVDE_MASK; } return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* BACnetObjectPropertyReference ::= SEQUENCE { objectIdentifier BACnetObjectIdentifier, propertyIdentifier BACnetPropertyIdentifier, propertyArrayIndex Unsigend OPTIONAL, } */
static guint fObjectPropertyReference(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
/* BACnetObjectPropertyReference ::= SEQUENCE { objectIdentifier BACnetObjectIdentifier, propertyIdentifier BACnetPropertyIdentifier, propertyArrayIndex Unsigend OPTIONAL, } */ static guint fObjectPropertyReference(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
{ return fDeviceObjectPropertyReference(tvb, pinfo, tree, offset); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Called to obtain a "prand" as defined in core V4.2 Vol 6 Part B 1.3.2.2 */
void ble_ll_rand_prand_get(uint8_t *prand)
/* Called to obtain a "prand" as defined in core V4.2 Vol 6 Part B 1.3.2.2 */ void ble_ll_rand_prand_get(uint8_t *prand)
{ uint16_t sum; while (1) { ble_ll_rand_data_get(prand, 3); sum = prand[0] + prand[1] + prand[2]; if ((sum != 0) && (sum != (3 * 0xff))) { break; } } prand[2] &= ~0xc0; prand[2] |= 0x40; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Not so, for quite unobvious reasons - register pressure. In user mode vfork() cannot have a stack frame, and if done by calling the "clone()" system call directly, you do not have enough call-clobbered registers to hold all the information you need. */
int sys_vfork(struct pt_regs *regs)
/* Not so, for quite unobvious reasons - register pressure. In user mode vfork() cannot have a stack frame, and if done by calling the "clone()" system call directly, you do not have enough call-clobbered registers to hold all the information you need. */ int sys_vfork(struct pt_regs *regs)
{ return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp, regs, 0, NULL, NULL); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* The command mechanism: Each rup has a chain of commands associated with it. This chain is maintained by routines in this file. Periodically we are called and we run a quick check of all the active chains to determine if there is a command to be executed, and if the rup is ready to accept it. Allocate an empty command block. */
struct CmdBlk* RIOGetCmdBlk(void)
/* The command mechanism: Each rup has a chain of commands associated with it. This chain is maintained by routines in this file. Periodically we are called and we run a quick check of all the active chains to determine if there is a command to be executed, and if the rup is ready to accept it. Allocate an empty command block. */ struct CmdBlk* RIOGetCmdBlk(void)
{ struct CmdBlk *CmdBlkP; CmdBlkP = kzalloc(sizeof(struct CmdBlk), GFP_ATOMIC); return CmdBlkP; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns the current value of the burst transfer counter. */
uint32_t I2CMasterBurstCountGet(uint32_t ui32Base)
/* Returns the current value of the burst transfer counter. */ uint32_t I2CMasterBurstCountGet(uint32_t ui32Base)
{ ASSERT(_I2CBaseValid(ui32Base)); return (HWREG(ui32Base + I2C_O_MBCNT)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Unregisters an interrupt handler for a I2S interrupt. */
void I2SIntUnregister(unsigned long ulBase)
/* Unregisters an interrupt handler for a I2S interrupt. */ void I2SIntUnregister(unsigned long ulBase)
{ IntDisable(INT_I2S); IntUnregister(INT_I2S); }
micropython/micropython
C++
Other
18,334
/* Set door bell and wait it to be ACKed by host controller. This function is used to synchronize with the hardware. */
EFI_STATUS EhcSetAndWaitDoorBell(IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Timeout)
/* Set door bell and wait it to be ACKed by host controller. This function is used to synchronize with the hardware. */ EFI_STATUS EhcSetAndWaitDoorBell(IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Timeout)
{ EFI_STATUS Status; UINT32 Data; EhcSetOpRegBit (Ehc, EHC_USBCMD_OFFSET, USBCMD_IAAD); Status = EhcWaitOpRegBit (Ehc, EHC_USBSTS_OFFSET, USBSTS_IAA, TRUE, Timeout); Data = EhcReadOpReg (Ehc, EHC_USBSTS_OFFSET); Data &= ~USBSTS_INTACK_MASK; Data |= USBSTS_IAA; EhcWriteOpReg (Ehc, EHC_USBSTS_OFFSET, Data); return Status; }
tianocore/edk2
C++
Other
4,240
/* Get the pointer to EFI_FW_VOL_INSTANCE from the buffer pointed by mFvbModuleGlobal.FvInstance based on a index. Each EFI_FW_VOL_INSTANCE is with variable length as we have a block map at the end of the EFI_FIRMWARE_VOLUME_HEADER. */
EFI_FW_VOL_INSTANCE* GetFvbInstance(IN UINTN Instance)
/* Get the pointer to EFI_FW_VOL_INSTANCE from the buffer pointed by mFvbModuleGlobal.FvInstance based on a index. Each EFI_FW_VOL_INSTANCE is with variable length as we have a block map at the end of the EFI_FIRMWARE_VOLUME_HEADER. */ EFI_FW_VOL_INSTANCE* GetFvbInstance(IN UINTN Instance)
{ EFI_FW_VOL_INSTANCE *FwhRecord; if ( Instance >= mFvbModuleGlobal.NumFv ) { ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER); return NULL; } FwhRecord = mFvbModuleGlobal.FvInstance; while ( Instance > 0 ) { FwhRecord = (EFI_FW_VOL_INSTANCE *)((UINTN)((UINT8 *)FwhRecord) + FwhRecord->VolumeHeader.HeaderLength + (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))); Instance--; } return FwhRecord; }
tianocore/edk2
C++
Other
4,240
/* Mask DRDY on pin (both XL & Gyro) until filter settling ends (XL and Gyro independently masked).. */
int32_t lsm6dso_filter_settling_mask_set(stmdev_ctx_t *ctx, uint8_t val)
/* Mask DRDY on pin (both XL & Gyro) until filter settling ends (XL and Gyro independently masked).. */ int32_t lsm6dso_filter_settling_mask_set(stmdev_ctx_t *ctx, uint8_t val)
{ lsm6dso_ctrl4_c_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)&reg, 1); if (ret == 0) { reg.drdy_mask = val; ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)&reg, 1); } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* These values are estimates at best, so no need for locking. */
void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
/* These values are estimates at best, so no need for locking. */ void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
{ loads[0] = (avenrun[0] + offset) << shift; loads[1] = (avenrun[1] + offset) << shift; loads[2] = (avenrun[2] + offset) << shift; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* read a one-byte data from a IDE port. */
UINT8 EFIAPI IdeReadPortB(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT16 Port)
/* read a one-byte data from a IDE port. */ UINT8 EFIAPI IdeReadPortB(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT16 Port)
{ UINT8 Data; ASSERT (PciIo != NULL); Data = 0; PciIo->Io.Read ( PciIo, EfiPciIoWidthUint8, EFI_PCI_IO_PASS_THROUGH_BAR, (UINT64)Port, 1, &Data ); return Data; }
tianocore/edk2
C++
Other
4,240
/* Map op to supported operations. We don't use a table since we would just have to relocate it from flash anyway. */
static int fpga_get_op(char *opstr)
/* Map op to supported operations. We don't use a table since we would just have to relocate it from flash anyway. */ static int fpga_get_op(char *opstr)
{ int op = FPGA_NONE; if (!strcmp ("info", opstr)) { op = FPGA_INFO; } else if (!strcmp ("loadb", opstr)) { op = FPGA_LOADB; } else if (!strcmp ("load", opstr)) { op = FPGA_LOAD; } else if (!strcmp ("loadmk", opstr)) { op = FPGA_LOADMK; } else if (!strcmp ("dump", opstr)) { op = FPGA_DUMP; } if (op == FPGA_NONE) { printf ("Unknown fpga operation \"%s\"\n", opstr); } return op; }
EmcraftSystems/u-boot
C++
Other
181
/* The channel must also be enabled using DMAChannelEnable() after calling this function. The transfer will not begin until the channel has been set up and enabled. Note that the channel is automatically disabled after the transfer is completed, meaning that DMAChannelEnable() must be called again after setting up the next transfer. */
void DMAChannelTransferSet(unsigned long ulChannelID, void *pvSrcAddr, void *pvDstAddr, unsigned long ulTransferSize)
/* The channel must also be enabled using DMAChannelEnable() after calling this function. The transfer will not begin until the channel has been set up and enabled. Note that the channel is automatically disabled after the transfer is completed, meaning that DMAChannelEnable() must be called again after setting up the next transfer. */ void DMAChannelTransferSet(unsigned long ulChannelID, void *pvSrcAddr, void *pvDstAddr, unsigned long ulTransferSize)
{ xASSERT(xDMAChannelIDValid(ulChannelID)); xASSERT((ulTransferSize >= 0)&&(ulTransferSize <= DMA_DSR_BCR_BCR_M)); xHWREG(g_psDMAChannelAddress[ulChannelID] + DMA_SAR) = (unsigned long)pvSrcAddr; xHWREG(g_psDMAChannelAddress[ulChannelID] + DMA_DAR) = (unsigned long)pvDstAddr; xHWREG(g_psDMAChannelAddress[ulChannelID] + DMA_DSR_BCR) &= ~DMA_DSR_BCR_BCR_M; xHWREG(g_psDMAChannelAddress[ulChannelID] + DMA_DSR_BCR) |= ulTransferSize; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Re-calculate pending state from the set of locally pending signals, globally pending signals, and blocked signals. */
static int has_pending_signals(sigset_t *signal, sigset_t *blocked)
/* Re-calculate pending state from the set of locally pending signals, globally pending signals, and blocked signals. */ static int has_pending_signals(sigset_t *signal, sigset_t *blocked)
{ unsigned long ready; long i; switch (_NSIG_WORDS) { default: for (i = _NSIG_WORDS, ready = 0; --i >= 0 ;) ready |= signal->sig[i] &~ blocked->sig[i]; break; case 4: ready = signal->sig[3] &~ blocked->sig[3]; ready |= signal->sig[2] &~ blocked->sig[2]; ready |= signal->sig[1] &~ blocked->sig[1]; ready |= signal->sig[0] &~ blocked->sig[0]; break; case 2: ready = signal->sig[1] &~ blocked->sig[1]; ready |= signal->sig[0] &~ blocked->sig[0]; break; case 1: ready = signal->sig[0] &~ blocked->sig[0]; } return ready != 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns the physical bit-width of the format, or a negative error code if unknown format. */
int snd_pcm_format_physical_width(snd_pcm_format_t format)
/* Returns the physical bit-width of the format, or a negative error code if unknown format. */ int snd_pcm_format_physical_width(snd_pcm_format_t format)
{ int val; if (format < 0 || format > SNDRV_PCM_FORMAT_LAST) return -EINVAL; if ((val = pcm_formats[format].phys) == 0) return -EINVAL; return val; }
robutest/uclinux
C++
GPL-2.0
60
/* Print out info about fatal segfaults, if the show_unhandled_signals sysctl is set: */
static void show_signal_msg(struct pt_regs *regs, unsigned long error_code, unsigned long address, struct task_struct *tsk)
/* Print out info about fatal segfaults, if the show_unhandled_signals sysctl is set: */ static void show_signal_msg(struct pt_regs *regs, unsigned long error_code, unsigned long address, struct task_struct *tsk)
{ if (!unhandled_signal(tsk, SIGSEGV)) return; if (!printk_ratelimit()) return; printk("%s%s[%d]: segfault at %lx ip %p sp %p error %lx", task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG, tsk->comm, task_pid_nr(tsk), address, (void *)regs->ip, (void *)regs->sp, error_code); print_vma_addr(KERN_CONT " in ", regs->ip); printk(KERN_CONT "\n"); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Set the starting position of the visible screen to var->yoffset */
static int tdfxfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
/* Set the starting position of the visible screen to var->yoffset */ static int tdfxfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
{ struct tdfx_par *par = info->par; u32 addr = var->yoffset * info->fix.line_length; if (nopan || var->xoffset) return -EINVAL; banshee_make_room(par, 1); tdfx_outl(par, VIDDESKSTART, addr); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* use ssd.lock to protect render_update_cookie_num. qxl_render_update is called by io thread or vcpu thread, and the completion callbacks are called by spice_server thread, defering to bh called from the io thread. */
void qxl_render_update(PCIQXLDevice *qxl)
/* use ssd.lock to protect render_update_cookie_num. qxl_render_update is called by io thread or vcpu thread, and the completion callbacks are called by spice_server thread, defering to bh called from the io thread. */ void qxl_render_update(PCIQXLDevice *qxl)
{ QXLCookie *cookie; qemu_mutex_lock(&qxl->ssd.lock); if (!runstate_is_running() || !qxl->guest_primary.commands) { qxl_render_update_area_unlocked(qxl); qemu_mutex_unlock(&qxl->ssd.lock); return; } qxl->guest_primary.commands = 0; qxl->render_update_cookie_num++; qemu_mutex_unlock(&qxl->ssd.lock); cookie = qxl_cookie_new(QXL_COOKIE_TYPE_RENDER_UPDATE_AREA, 0); qxl_set_rect_to_surface(qxl, &cookie->u.render.area); qxl_spice_update_area(qxl, 0, &cookie->u.render.area, NULL, 0, 1, QXL_ASYNC, cookie); }
ve3wwg/teensy3_qemu
C++
Other
15
/* Update the current state of tagged queuing for a given target. */
static void ahd_set_tags(struct ahd_softc *ahd, struct scsi_cmnd *cmd, struct ahd_devinfo *devinfo, ahd_queue_alg alg)
/* Update the current state of tagged queuing for a given target. */ static void ahd_set_tags(struct ahd_softc *ahd, struct scsi_cmnd *cmd, struct ahd_devinfo *devinfo, ahd_queue_alg alg)
{ struct scsi_device *sdev = cmd->device; ahd_platform_set_tags(ahd, sdev, devinfo, alg); ahd_send_async(ahd, devinfo->channel, devinfo->target, devinfo->lun, AC_TRANSFER_NEG); }
robutest/uclinux
C++
GPL-2.0
60
/* Set I2C peripheral registers to their default reset values. */
void SCI2C_Reset(SCI2C_T *i2c)
/* Set I2C peripheral registers to their default reset values. */ void SCI2C_Reset(SCI2C_T *i2c)
{ if(i2c == I2C3) { RCM_EnableAPB1PeriphReset(RCM_APB1_PERIPH_I2C1); RCM_DisableAPB1PeriphReset(RCM_APB1_PERIPH_I2C1); } else { RCM_EnableAPB1PeriphReset(RCM_APB1_PERIPH_I2C2); RCM_DisableAPB1PeriphReset(RCM_APB1_PERIPH_I2C2); } i2c->SW = 0; i2c->SW = 1; i2c->INTEN = 0; }
pikasTech/PikaPython
C++
MIT License
1,403
/* PCD MSP Initialization This function configures the hardware resources used in this example. */
void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
/* PCD MSP Initialization This function configures the hardware resources used in this example. */ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; if(hpcd->Instance==USB) { __HAL_RCC_GPIOA_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF10_USB; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); __HAL_RCC_USB_CLK_ENABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function gets the FspSmmInit UPD data pointer. */
VOID* EFIAPI GetFspSmmInitUpdDataPointer(VOID)
/* This function gets the FspSmmInit UPD data pointer. */ VOID* EFIAPI GetFspSmmInitUpdDataPointer(VOID)
{ FSP_GLOBAL_DATA *FspData; FspData = GetFspGlobalDataPointer (); return FspData->SmmInitUpdPtr; }
tianocore/edk2
C++
Other
4,240
/* 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | Reserved (R) | ATT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
static void dissect_pmip6_opt_att(const mip6_opt *optp _U_, tvbuff_t *tvb, int offset, guint optlen _U_, packet_info *pinfo _U_, proto_tree *opt_tree, proto_item *hdr_item _U_)
/* 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | Reserved (R) | ATT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ static void dissect_pmip6_opt_att(const mip6_opt *optp _U_, tvbuff_t *tvb, int offset, guint optlen _U_, packet_info *pinfo _U_, proto_tree *opt_tree, proto_item *hdr_item _U_)
{ guint8 att; offset++; proto_tree_add_item(opt_tree, hf_mip6_opt_len, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; proto_tree_add_item(opt_tree, hf_pmip6_att_reserved, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; att = tvb_get_guint8(tvb,offset); proto_tree_add_item(opt_tree, hf_pmip6_att_att, tvb, offset, PMIP6_ATT_ATT_LEN, ENC_BIG_ENDIAN); proto_item_append_text(hdr_item, ": %s", val_to_str_ext_const(att, &pmip6_att_att_value_ext, "<unknown>")); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Calculate Cumulative Clock low Time-out of SMBus active period. */
void I2C_SMBusClockLoTimeout(I2C_T *i2c, uint32_t ms, uint32_t u32Pclk)
/* Calculate Cumulative Clock low Time-out of SMBus active period. */ void I2C_SMBusClockLoTimeout(I2C_T *i2c, uint32_t ms, uint32_t u32Pclk)
{ uint32_t u32Div, u32Pclk_kHz; i2c->BUSCTL &= ~I2C_BUSCTL_TIDLE_Msk; i2c->TOCTL &= ~I2C_TOCTL_TOCEN_Msk; u32Pclk_kHz = u32Pclk / 1000U; u32Div = ((ms * u32Pclk_kHz) / (16U * 1024U)) - 1U; if (u32Div <= 0xFFU) { i2c->CLKTOUT = u32Div; } else { i2c->TOCTL |= I2C_TOCTL_TOCEN_Msk; i2c->CLKTOUT = (((ms * u32Pclk_kHz) / (16U * 1024U * 4U)) - 1U) & 0xFFU; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function provides accurate delay (in milliseconds) based on SysTick counter flag. */
void HAL_Delay(__IO uint32_t Delay)
/* This function provides accurate delay (in milliseconds) based on SysTick counter flag. */ void HAL_Delay(__IO uint32_t Delay)
{ while (Delay) { if (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) { Delay--; } } }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* This routine is called when the user clicks the "Close" button in the "Decode As..." dialog window. This routine simply calls the close routine as if the user had clicked the close button instead of the close button. */
static gboolean decode_delete_cb(GtkWidget *decode_w_lcl, GdkEvent *event _U_, gpointer user_data _U_)
/* This routine is called when the user clicks the "Close" button in the "Decode As..." dialog window. This routine simply calls the close routine as if the user had clicked the close button instead of the close button. */ static gboolean decode_delete_cb(GtkWidget *decode_w_lcl, GdkEvent *event _U_, gpointer user_data _U_)
{ decode_close_cb(NULL, decode_w_lcl); return FALSE; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Entry point of the MTFTP6 driver to install various protocols. */
EFI_STATUS EFIAPI Mtftp6DriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* Entry point of the MTFTP6 driver to install various protocols. */ EFI_STATUS EFIAPI Mtftp6DriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ return EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gMtftp6DriverBinding, ImageHandle, &gMtftp6ComponentName, &gMtftp6ComponentName2 ); }
tianocore/edk2
C++
Other
4,240
/* This function unregisters the handler to be called when a system control interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called. */
void SysCtlIntUnregister(void)
/* This function unregisters the handler to be called when a system control interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called. */ void SysCtlIntUnregister(void)
{ IntDisable(INT_SYSCTL_TM4C123); IntUnregister(INT_SYSCTL_TM4C123); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return: 0 on success or a negative error code on failure */
int mipi_dsi_dcs_set_tear_scanline(struct mipi_dsi_device *dsi, u16 scanline)
/* Return: 0 on success or a negative error code on failure */ int mipi_dsi_dcs_set_tear_scanline(struct mipi_dsi_device *dsi, u16 scanline)
{ u8 payload[3] = { MIPI_DCS_SET_TEAR_SCANLINE, scanline >> 8, scanline & 0xff }; ssize_t err; err = mipi_dsi_generic_write(dsi, payload, sizeof(payload)); if (err < 0) return err; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Map some physical address range into the kernel address space. */
void __iomem* __ioremap(unsigned long physaddr, unsigned long size, int cacheflag)
/* Map some physical address range into the kernel address space. */ void __iomem* __ioremap(unsigned long physaddr, unsigned long size, int cacheflag)
{ return (void __iomem *)physaddr; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Sets the end address of an area. Needs the I2C Password presentation to be effective. */
int32_t ST25DV_WriteEndZonex(ST25DV_Object_t *pObj, const ST25DV_END_ZONE EndZone, const uint8_t EndZ)
/* Sets the end address of an area. Needs the I2C Password presentation to be effective. */ int32_t ST25DV_WriteEndZonex(ST25DV_Object_t *pObj, const ST25DV_END_ZONE EndZone, const uint8_t EndZ)
{ int32_t status; switch( EndZone ) { case ST25DV_ZONE_END1: status = st25dv_set_enda1(&(pObj->Ctx),&EndZ); break; case ST25DV_ZONE_END2: status = st25dv_set_enda2(&(pObj->Ctx),&EndZ); break; case ST25DV_ZONE_END3: status = st25dv_set_enda3(&(pObj->Ctx),&EndZ); break; default: status = ST25DV_ERROR; } return status; }
eclipse-threadx/getting-started
C++
Other
310
/* Allocates some kernel memory that we can use for DMA. I think this means that the memory has to map to contiguous pages of physical memory. */
static struct snd_dma_buffer* get_dmabuf(struct snd_dma_buffer *buf, unsigned long size)
/* Allocates some kernel memory that we can use for DMA. I think this means that the memory has to map to contiguous pages of physical memory. */ static struct snd_dma_buffer* get_dmabuf(struct snd_dma_buffer *buf, unsigned long size)
{ if (buf) { if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(), size, buf) < 0) { snd_printk(KERN_ERR "sscape: Failed to allocate " "%lu bytes for DMA\n", size); return NULL; } } return buf; }
robutest/uclinux
C++
GPL-2.0
60
/* DMA Stream Read Current Memory Target. In double buffer mode, return the current memory target (M0 or M1). It is possible to update the memory pointer in the register that is */
uint8_t dma_get_target(uint32_t dma, uint8_t stream)
/* DMA Stream Read Current Memory Target. In double buffer mode, return the current memory target (M0 or M1). It is possible to update the memory pointer in the register that is */ uint8_t dma_get_target(uint32_t dma, uint8_t stream)
{ if (DMA_SCR(dma, stream) & DMA_SxCR_CT) { return 1; } return 0; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Get the current Aperture size from the x86-64. Note, that there may be multiple x86-64's, but we just return the value from the first one we find. The set_size functions keep the rest coherent anyway. Or at least should do. */
static int amd64_fetch_size(void)
/* Get the current Aperture size from the x86-64. Note, that there may be multiple x86-64's, but we just return the value from the first one we find. The set_size functions keep the rest coherent anyway. Or at least should do. */ static int amd64_fetch_size(void)
{ struct pci_dev *dev; int i; u32 temp; struct aper_size_info_32 *values; dev = k8_northbridges[0]; if (dev==NULL) return 0; pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &temp); temp = (temp & 0xe); values = A_SIZE_32(amd64_aperture_sizes); for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) { if (temp == values[i].size_value) { agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + i); agp_bridge->aperture_size_idx = i; return values[i].size; } } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* USBH_ErrorHandle This function handles the Error on Host side. */
void USBH_ErrorHandle(USBH_HOST *phost, USBH_Status errType)
/* USBH_ErrorHandle This function handles the Error on Host side. */ void USBH_ErrorHandle(USBH_HOST *phost, USBH_Status errType)
{ if ( (errType == USBH_ERROR_SPEED_UNKNOWN) || (errType == USBH_UNRECOVERED_ERROR) ) { phost->usr_cb->UnrecoveredError(); phost->gState = HOST_ERROR_STATE; } else if(errType == USBH_APPLY_DEINIT) { phost->gState = HOST_ERROR_STATE; phost->usr_cb->Init(); } }
MaJerle/stm32f429
C++
null
2,036
/* Initializes SLCD configurations struct to defaults. Initailizes SLCD configuration struct to predefined safe default settings. */
void slcd_get_config_defaults(struct slcd_config *config)
/* Initializes SLCD configurations struct to defaults. Initailizes SLCD configuration struct to predefined safe default settings. */ void slcd_get_config_defaults(struct slcd_config *config)
{ Assert(config); config->run_in_standby = false; config->waveform_mode = SLCD_LOW_POWER_WAVEFORM_MODE; config->low_resistance_duration = 0; config->enable_low_resistance = false; config->bias_buffer_duration = 0; config->enable_bias_buffer = false; }
memfault/zero-to-main
C++
null
200
/* Check if input string is valid Ascii string, valid EFI control characters or valid text graphics. */
EFI_STATUS AnsiTestString(IN TERMINAL_DEV *TerminalDevice, IN CHAR16 *WString)
/* Check if input string is valid Ascii string, valid EFI control characters or valid text graphics. */ EFI_STATUS AnsiTestString(IN TERMINAL_DEV *TerminalDevice, IN CHAR16 *WString)
{ CHAR8 GraphicChar; for ( ; *WString != CHAR_NULL; WString++) { if ( !(TerminalIsValidAscii (*WString) || TerminalIsValidEfiCntlChar (*WString) || TerminalIsValidTextGraphics (*WString, &GraphicChar, NULL))) { return EFI_UNSUPPORTED; } } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* These are passed a tvb that contains whatever occurs after the byte */
static void dissect_r3_upstreamcommand_reserved(tvbuff_t *tvb, guint32 start_offset, guint32 length, packet_info *pinfo, proto_tree *tree)
/* These are passed a tvb that contains whatever occurs after the byte */ static void dissect_r3_upstreamcommand_reserved(tvbuff_t *tvb, guint32 start_offset, guint32 length, packet_info *pinfo, proto_tree *tree)
{ proto_tree_add_expert(tree, pinfo, &ei_r3_reserved_upstream_command_value, tvb, start_offset, length); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Collect the processes who have the corrupted page mapped to kill. This is done in two steps for locking reasons. First preallocate one tokill structure outside the spin locks, so that we can kill at least one process reasonably reliable. */
static void collect_procs(struct page *page, struct list_head *tokill)
/* Collect the processes who have the corrupted page mapped to kill. This is done in two steps for locking reasons. First preallocate one tokill structure outside the spin locks, so that we can kill at least one process reasonably reliable. */ static void collect_procs(struct page *page, struct list_head *tokill)
{ struct to_kill *tk; if (!page->mapping) return; tk = kmalloc(sizeof(struct to_kill), GFP_NOIO); if (!tk) return; if (PageAnon(page)) collect_procs_anon(page, tokill, &tk); else collect_procs_file(page, tokill, &tk); kfree(tk); }
robutest/uclinux
C++
GPL-2.0
60
/* Retrieve the PCI configuration space data that interests us from the kernel PCI layer */
static int __devinit velocity_get_pci_info(struct velocity_info *vptr, struct pci_dev *pdev)
/* Retrieve the PCI configuration space data that interests us from the kernel PCI layer */ static int __devinit velocity_get_pci_info(struct velocity_info *vptr, struct pci_dev *pdev)
{ vptr->rev_id = pdev->revision; pci_set_master(pdev); vptr->ioaddr = pci_resource_start(pdev, 0); vptr->memaddr = pci_resource_start(pdev, 1); if (!(pci_resource_flags(pdev, 0) & IORESOURCE_IO)) { dev_err(&pdev->dev, "region #0 is not an I/O resource, aborting.\n"); return -EINVAL; } if ((pci_resource_flags(pdev, 1) & IORESOURCE_IO)) { dev_err(&pdev->dev, "region #1 is an I/O resource, aborting.\n"); return -EINVAL; } if (pci_resource_len(pdev, 1) < VELOCITY_IO_SIZE) { dev_err(&pdev->dev, "region #1 is too small.\n"); return -EINVAL; } vptr->pdev = pdev; return 0; }
robutest/uclinux
C++
GPL-2.0
60