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
/* We received a GRANT_RES callback. Try to find the corresponding block. */
void nlmsvc_grant_reply(struct nlm_cookie *cookie, __be32 status)
/* We received a GRANT_RES callback. Try to find the corresponding block. */ void nlmsvc_grant_reply(struct nlm_cookie *cookie, __be32 status)
{ struct nlm_block *block; dprintk("grant_reply: looking for cookie %x, s=%d \n", *(unsigned int *)(cookie->data), status); if (!(block = nlmsvc_find_block(cookie))) return; if (block) { if (status == nlm_lck_denied_grace_period) { nlmsvc_insert_block(block, 10 * HZ); } else { nlmsvc_unlink_block(bloc...
robutest/uclinux
C++
GPL-2.0
60
/* Grow the configuration string to a desired length. Usually the first growth is plenty. */
static void grow_config(int len)
/* Grow the configuration string to a desired length. Usually the first growth is plenty. */ static void grow_config(int len)
{ while (len_config + len > size_config) { if (size_config == 0) size_config = 2048; str_config = realloc(str_config, size_config *= 2); if (str_config == NULL) { perror("fixdep:malloc"); exit(1); } } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns CR_OK upon successful completion, an error code otherwise. */
enum CRStatus cr_rgb_compute_from_percentage(CRRgb *a_this)
/* Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_rgb_compute_from_percentage(CRRgb *a_this)
{ g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR); if (a_this->is_percentage == FALSE) return CR_OK; a_this->red = a_this->red * 255 / 100; a_this->green = a_this->green * 255 / 100; a_this->blue = a_this->blue * 255 / 100; a_this->is_percentage = FALSE;...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Set the Number of Wait States. Used to match the system clock to the FLASH memory access time. See the reference manual for more information on clock speed ranges for each wait state. The latency must be changed to the appropriate value */
void flash_set_ws(uint32_t ws)
/* Set the Number of Wait States. Used to match the system clock to the FLASH memory access time. See the reference manual for more information on clock speed ranges for each wait state. The latency must be changed to the appropriate value */ void flash_set_ws(uint32_t ws)
{ FLASH_ACR = (FLASH_ACR & ~FLASH_ACR_LATENCY) | ws; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* find out if the net_device which this lp belongs to (lp can be master or slave) is busy. It's busy iff all (master and slave) queues are busy */
static __inline__ int isdn_net_device_busy(isdn_net_local *lp)
/* find out if the net_device which this lp belongs to (lp can be master or slave) is busy. It's busy iff all (master and slave) queues are busy */ static __inline__ int isdn_net_device_busy(isdn_net_local *lp)
{ isdn_net_local *nlp; isdn_net_dev *nd; unsigned long flags; if (!isdn_net_lp_busy(lp)) return 0; if (lp->master) nd = ISDN_MASTER_PRIV(lp)->netdev; else nd = lp->netdev; spin_lock_irqsave(&nd->queue_lock, flags); nlp = lp->next; while (nlp != lp) { if (!isdn_net_lp_busy(nlp)) { spin_unlock_irqrest...
robutest/uclinux
C++
GPL-2.0
60
/* The ReturnNode must be generated inside a Method body scope. */
STATIC EFI_STATUS EFIAPI AmlCodeGenReturnInteger(IN UINT64 Integer, IN AML_NODE_HEADER *ParentNode OPTIONAL, OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
/* The ReturnNode must be generated inside a Method body scope. */ STATIC EFI_STATUS EFIAPI AmlCodeGenReturnInteger(IN UINT64 Integer, IN AML_NODE_HEADER *ParentNode OPTIONAL, OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
{ EFI_STATUS Status; AML_OBJECT_NODE *IntNode; IntNode = NULL; Status = AmlCodeGenInteger (Integer, &IntNode); if (EFI_ERROR (Status)) { ASSERT (0); return Status; } Status = AmlCodeGenReturn ( (AML_NODE_HEADER *)IntNode, ParentNode, NewObjectNode ...
tianocore/edk2
C++
Other
4,240
/* Remove one serial port. This may not be called from interrupt context. We hand the port back to the our control. */
void serial8250_unregister_port(int line)
/* Remove one serial port. This may not be called from interrupt context. We hand the port back to the our control. */ void serial8250_unregister_port(int line)
{ struct uart_8250_port *uart = &serial8250_ports[line]; mutex_lock(&serial_mutex); uart_remove_one_port(&serial8250_reg, &uart->port); if (serial8250_isa_devs) { uart->port.flags &= ~UPF_BOOT_AUTOCONF; uart->port.type = PORT_UNKNOWN; uart->port.dev = &serial8250_isa_devs->dev; uart_add_one_port(&serial8250...
robutest/uclinux
C++
GPL-2.0
60
/* Ethernet interface initialisation function Inits interface, sets interface link MAC address. */
static void eth_cyclonev_iface_init(struct net_if *iface)
/* Ethernet interface initialisation function Inits interface, sets interface link MAC address. */ static void eth_cyclonev_iface_init(struct net_if *iface)
{ const struct device *dev = net_if_get_device(iface); const struct eth_cyclonev_config *config = dev->config; struct eth_cyclonev_priv *p = dev->data; p->iface = iface; ethernet_init(iface); net_if_set_link_addr(iface, p->mac_addr, sizeof(p->mac_addr), NET_LINK_ETHERNET); k_sem_init(&p->free_tx_descs, NB_TX_DES...
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Create an empty route table. This includes its internal route cache. */
IP6_ROUTE_TABLE* Ip6CreateRouteTable(VOID)
/* Create an empty route table. This includes its internal route cache. */ IP6_ROUTE_TABLE* Ip6CreateRouteTable(VOID)
{ IP6_ROUTE_TABLE *RtTable; UINT32 Index; RtTable = AllocatePool (sizeof (IP6_ROUTE_TABLE)); if (RtTable == NULL) { return NULL; } RtTable->RefCnt = 1; RtTable->TotalNum = 0; for (Index = 0; Index <= IP6_PREFIX_MAX; Index++) { InitializeListHead (&RtTable->RouteArea[Index]); } f...
tianocore/edk2
C++
Other
4,240
/* This function sets the thread creation stackaddr attribute in the attr object. */
int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stack_addr)
/* This function sets the thread creation stackaddr attribute in the attr object. */ int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stack_addr)
{ RT_ASSERT(attr != RT_NULL); return EOPNOTSUPP; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enables or disable the reverse operation on output data. The reverse operation on output data is performed on 32-bit. */
void CRC_ReverseOutputDataCmd(FunctionalState NewState)
/* Enables or disable the reverse operation on output data. The reverse operation on output data is performed on 32-bit. */ void CRC_ReverseOutputDataCmd(FunctionalState NewState)
{ assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { CRC->CR |= CRC_CR_REV_OUT; } else { CRC->CR &= (uint32_t)~((uint32_t)CRC_CR_REV_OUT); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* A child source always has the same priority as its parent. It is not permitted to change the priority of a source once it has been added as a child of another source. */
void g_source_set_priority(GSource *source, gint priority)
/* A child source always has the same priority as its parent. It is not permitted to change the priority of a source once it has been added as a child of another source. */ void g_source_set_priority(GSource *source, gint priority)
{ GMainContext *context; g_return_if_fail (source != NULL); g_return_if_fail (source->priv->parent_source == NULL); context = source->context; if (context) LOCK_CONTEXT (context); g_source_set_priority_unlocked (source, context, priority); if (context) UNLOCK_CONTEXT (source->context); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* ixgb_irq_disable - Mask off interrupt generation on the NIC @adapter: board private structure */
static void ixgb_irq_disable(struct ixgb_adapter *adapter)
/* ixgb_irq_disable - Mask off interrupt generation on the NIC @adapter: board private structure */ static void ixgb_irq_disable(struct ixgb_adapter *adapter)
{ IXGB_WRITE_REG(&adapter->hw, IMC, ~0); IXGB_WRITE_FLUSH(&adapter->hw); synchronize_irq(adapter->pdev->irq); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns: (type GObject.TypeInterface) (transfer none): the default vtable for the interface, or NULL if the type is not currently in use */
gpointer g_type_default_interface_peek(GType g_type)
/* Returns: (type GObject.TypeInterface) (transfer none): the default vtable for the interface, or NULL if the type is not currently in use */ gpointer g_type_default_interface_peek(GType g_type)
{ TypeNode *node; gpointer vtable; node = lookup_type_node_I (g_type); if (node && NODE_IS_IFACE (node) && NODE_REFCOUNT (node)) vtable = node->data->iface.dflt_vtable; else vtable = NULL; return vtable; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* We split the mutex lock/unlock logic into separate fastpath and slowpath functions, to reduce the register pressure on the fastpath. We also put the fastpath first in the kernel image, to make sure the branch is predicted by the CPU as default-untaken. */
static __used noinline void __sched __mutex_lock_slowpath(atomic_t *lock_count)
/* We split the mutex lock/unlock logic into separate fastpath and slowpath functions, to reduce the register pressure on the fastpath. We also put the fastpath first in the kernel image, to make sure the branch is predicted by the CPU as default-untaken. */ static __used noinline void __sched __mutex_lock_slowpath(at...
{ struct mutex *lock = container_of(lock_count, struct mutex, count); __mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, 0, _RET_IP_); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Transfer a message to a specified SPI slave @s SPI slave @m message to transfer */
static int spi_stm32_transfer(struct spi_device *s, struct spi_message *msg)
/* Transfer a message to a specified SPI slave @s SPI slave @m message to transfer */ static int spi_stm32_transfer(struct spi_device *s, struct spi_message *msg)
{ struct spi_stm32 *c = spi_master_get_devdata(s->master); unsigned long f; int ret = 0; if (c->stopping) { ret = -ESHUTDOWN; goto Done; } if (unlikely(list_empty(&msg->transfers))) { ret = -EINVAL; goto Done; } msg->status = -EINPROGRESS; msg->actual_length = 0; spin_lock_irqsave(&c->lock, f); list_...
robutest/uclinux
C++
GPL-2.0
60
/* Function for marking a user flag as acquired. */
static void user_flag_acquire(ble_conn_state_user_flag_id_t flag_id)
/* Function for marking a user flag as acquired. */ static void user_flag_acquire(ble_conn_state_user_flag_id_t flag_id)
{ m_bcs.acquired_flags |= (1 << flag_id); }
labapart/polymcu
C++
null
201
/* LPTIM MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim)
/* LPTIM MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim)
{ if(hlptim->Instance==LPTIM1) { __HAL_RCC_LPTIM1_CLK_DISABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Determines the size of a flash pages, defined by hardware. This also defines the minimal erase size. */
static blt_int32u FlashGetPageSize(void)
/* Determines the size of a flash pages, defined by hardware. This also defines the minimal erase size. */ static blt_int32u FlashGetPageSize(void)
{ blt_int32u result; if (FlashIsDualBankMode() == BLT_TRUE) { result = FLASH_PAGE_SIZE; } else { result = FLASH_PAGE_SIZE_128_BITS; } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* scsi_tgt_queue_command - queue command for userspace processing @cmd: scsi command @scsilun: scsi lun @tag: unique value to identify this command for tmf */
int scsi_tgt_queue_command(struct scsi_cmnd *cmd, u64 itn_id, struct scsi_lun *scsilun, u64 tag)
/* scsi_tgt_queue_command - queue command for userspace processing @cmd: scsi command @scsilun: scsi lun @tag: unique value to identify this command for tmf */ int scsi_tgt_queue_command(struct scsi_cmnd *cmd, u64 itn_id, struct scsi_lun *scsilun, u64 tag)
{ struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data; int err; init_scsi_tgt_cmd(cmd->request, tcmd, itn_id, tag); err = scsi_tgt_uspace_send_cmd(cmd, itn_id, scsilun, tag); if (err) cmd_hashlist_del(cmd); return err; }
robutest/uclinux
C++
GPL-2.0
60
/* In SPL we have no device tree, so we use the machine parameters */
static void clock_get_mem_selection(enum ddr_mode *mem_type, unsigned *frequency_mhz, unsigned *arm_freq, enum mem_manuf *mem_manuf)
/* In SPL we have no device tree, so we use the machine parameters */ static void clock_get_mem_selection(enum ddr_mode *mem_type, unsigned *frequency_mhz, unsigned *arm_freq, enum mem_manuf *mem_manuf)
{ struct spl_machine_param *params; params = spl_get_machine_params(); *mem_type = params->mem_type; *frequency_mhz = params->frequency_mhz; *arm_freq = params->arm_freq_mhz; *mem_manuf = params->mem_manuf; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Performs read and write operations on the NVRAM device attached to a network interface. */
EFI_STATUS EmuSnpNvData(IN EMU_SNP_PROTOCOL *This, IN BOOLEAN ReadWrite, IN UINTN Offset, IN UINTN BufferSize, IN OUT VOID *Buffer)
/* Performs read and write operations on the NVRAM device attached to a network interface. */ EFI_STATUS EmuSnpNvData(IN EMU_SNP_PROTOCOL *This, IN BOOLEAN ReadWrite, IN UINTN Offset, IN UINTN BufferSize, IN OUT VOID *Buffer)
{ EMU_SNP_PRIVATE *Private; Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This); return EFI_UNSUPPORTED; }
tianocore/edk2
C++
Other
4,240
/* If Address > 0x0FFFFFFF, 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(). */
UINT8 EFIAPI PciBitFieldRead8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
/* If Address > 0x0FFFFFFF, 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(). */ UINT8 EFIAPI PciBitFieldRead8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
{ return PciCf8BitFieldRead8 (Address, StartBit, EndBit); }
tianocore/edk2
C++
Other
4,240
/* This function allocates data buffer required for all the FC nodes of the vport to collect statistical data. */
void lpfc_alloc_bucket(struct lpfc_vport *vport)
/* This function allocates data buffer required for all the FC nodes of the vport to collect statistical data. */ void lpfc_alloc_bucket(struct lpfc_vport *vport)
{ struct lpfc_nodelist *ndlp = NULL, *next_ndlp = NULL; list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { if (!NLP_CHK_NODE_ACT(ndlp)) continue; kfree(ndlp->lat_data); ndlp->lat_data = NULL; if (ndlp->nlp_state == NLP_STE_MAPPED_NODE) { ndlp->lat_data = kcalloc(LPFC_MAX_BUCKET_COU...
robutest/uclinux
C++
GPL-2.0
60
/* param base LPUART peripheral base address. param handle LPUART handle pointer. */
void LPUART_TransferStopRingBuffer(LPUART_Type *base, lpuart_handle_t *handle)
/* param base LPUART peripheral base address. param handle LPUART handle pointer. */ void LPUART_TransferStopRingBuffer(LPUART_Type *base, lpuart_handle_t *handle)
{ assert(NULL != handle); if (handle->rxState == (uint8_t)kLPUART_RxIdle) { LPUART_DisableInterrupts( base, (uint32_t)kLPUART_RxDataRegFullInterruptEnable | (uint32_t)kLPUART_RxOverrunInterruptEnable); } handle->rxRingBuffer = NULL; handle->rxRingBufferSize = 0U; hand...
eclipse-threadx/getting-started
C++
Other
310
/* Configure the mask bits of 7-bit Slave Address. */
void I2C_SetSlaveAddrMask(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddrMask)
/* Configure the mask bits of 7-bit Slave Address. */ void I2C_SetSlaveAddrMask(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddrMask)
{ switch (u8SlaveNo) { case 1: i2c->ADDRMSK1 = (uint32_t)u8SlaveAddrMask << 1U; break; case 2: i2c->ADDRMSK2 = (uint32_t)u8SlaveAddrMask << 1U; break; case 3: i2c->ADDRMSK3 = (uint32_t)u8SlaveAddrMask << 1U; break; case 0: default: i...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Allocates an skb, builds the netlink message, and sends it to the pid. No failure notifications. */
void audit_send_reply(int pid, int seq, int type, int done, int multi, void *payload, int size)
/* Allocates an skb, builds the netlink message, and sends it to the pid. No failure notifications. */ void audit_send_reply(int pid, int seq, int type, int done, int multi, void *payload, int size)
{ struct sk_buff *skb; struct task_struct *tsk; struct audit_reply *reply = kmalloc(sizeof(struct audit_reply), GFP_KERNEL); if (!reply) return; skb = audit_make_reply(pid, seq, type, done, multi, payload, size); if (!skb) goto out; reply->pid = pid; reply->skb = skb; tsk = kthread_run(audit_send_...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Sets the RTC BCD calendar value. The year value should only be the abbreviated year tens, meaning if 2021 is desired pass in only 21. */
void rtc_calendar_set_date(uint8_t year, uint8_t month, uint8_t day, enum rtc_weekday rtc_dr_wdu)
/* Sets the RTC BCD calendar value. The year value should only be the abbreviated year tens, meaning if 2021 is desired pass in only 21. */ void rtc_calendar_set_date(uint8_t year, uint8_t month, uint8_t day, enum rtc_weekday rtc_dr_wdu)
{ rtc_calendar_set_year(year); rtc_calendar_set_month(month); rtc_calendar_set_weekday(rtc_dr_wdu); rtc_calendar_set_day(day); }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Polarity is determined based on the PHY specific status register. */
s32 e1000_check_polarity_82577(struct e1000_hw *hw)
/* Polarity is determined based on the PHY specific status register. */ s32 e1000_check_polarity_82577(struct e1000_hw *hw)
{ struct e1000_phy_info *phy = &hw->phy; s32 ret_val; u16 data; ret_val = phy->ops.read_reg(hw, I82577_PHY_STATUS_2, &data); if (!ret_val) phy->cable_polarity = (data & I82577_PHY_STATUS2_REV_POLARITY) ? e1000_rev_polarity_reversed : e1000_rev_polarity_normal; ret...
robutest/uclinux
C++
GPL-2.0
60
/* Do CTR encryption. This also does CTR encryption of a single block at address 'xortag' with the counter value appropriate for the final processing of the authentication tag. */
static void do_ctr(br_sslrec_gcm_context *cc, const void *nonce, void *data, size_t len, void *xortag)
/* Do CTR encryption. This also does CTR encryption of a single block at address 'xortag' with the counter value appropriate for the final processing of the authentication tag. */ static void do_ctr(br_sslrec_gcm_context *cc, const void *nonce, void *data, size_t len, void *xortag)
{ unsigned char iv[12]; memcpy(iv, cc->iv, 4); memcpy(iv + 4, nonce, 8); cc->bc.vtable->run(&cc->bc.vtable, iv, 2, data, len); cc->bc.vtable->run(&cc->bc.vtable, iv, 1, xortag, 16); }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Initializes the ADC channel sequence. Initializes the ADC channel sequence by the sequence of pin_array. */
void adc_regular_ain_channel(uint32_t *pin_array, uint8_t size)
/* Initializes the ADC channel sequence. Initializes the ADC channel sequence by the sequence of pin_array. */ void adc_regular_ain_channel(uint32_t *pin_array, uint8_t size)
{ for (int i = 0; i < size; i++) { _adc_configure_ain_pin(pin_array[i]); } }
remotemcu/remcu-chip-sdks
C++
null
436
/* UART Read a Received Data Word with Blocking. Wait until a data word has been received then return the word. */
uint16_t uart_recv_blocking(uint32_t uart)
/* UART Read a Received Data Word with Blocking. Wait until a data word has been received then return the word. */ uint16_t uart_recv_blocking(uint32_t uart)
{ uart_wait_recv_ready(uart); return uart_recv(uart); } /**@}
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Description: Returns the index of the first valid setting less than or equal to the one pointed to by idx, as determined by the mask in features. Returns the index of the last setting if nothing else matches. */
static int phy_find_valid(int idx, u32 features)
/* Description: Returns the index of the first valid setting less than or equal to the one pointed to by idx, as determined by the mask in features. Returns the index of the last setting if nothing else matches. */ static int phy_find_valid(int idx, u32 features)
{ while (idx < MAX_NUM_SETTINGS && !(settings[idx].setting & features)) idx++; return idx < MAX_NUM_SETTINGS ? idx : MAX_NUM_SETTINGS - 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Note that the definition of this function is a bit odd because of the X coordinate space (y increasing downwards). */
static int clockwise(const pixman_point_fixed_t *ref, const pixman_point_fixed_t *a, const pixman_point_fixed_t *b)
/* Note that the definition of this function is a bit odd because of the X coordinate space (y increasing downwards). */ static int clockwise(const pixman_point_fixed_t *ref, const pixman_point_fixed_t *a, const pixman_point_fixed_t *b)
{ pixman_point_fixed_t ad, bd; ad.x = a->x - ref->x; ad.y = a->y - ref->y; bd.x = b->x - ref->x; bd.y = b->y - ref->y; return ((pixman_fixed_32_32_t) bd.y * ad.x - (pixman_fixed_32_32_t) ad.y * bd.x) < 0; }
xboot/xboot
C++
MIT License
779
/* Get the LPSCI instance from peripheral base address. */
uint32_t LPSCI_GetInstance(UART0_Type *base)
/* Get the LPSCI instance from peripheral base address. */ uint32_t LPSCI_GetInstance(UART0_Type *base)
{ uint32_t instance; for (instance = 0; instance < FSL_FEATURE_SOC_LPSCI_COUNT; instance++) { if (s_lpsciBases[instance] == base) { break; } } assert(instance < FSL_FEATURE_SOC_LPSCI_COUNT); return instance; }
labapart/polymcu
C++
null
201
/* This function reads the specified signal of the GPIO device. It returns 0 if the signal clear, 1 if signal is set or negative value on error. */
static int xgpio_get(struct gpio_chip *gc, unsigned int gpio)
/* This function reads the specified signal of the GPIO device. It returns 0 if the signal clear, 1 if signal is set or negative value on error. */ static int xgpio_get(struct gpio_chip *gc, unsigned int gpio)
{ struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); return (in_be32(mm_gc->regs + XGPIO_DATA_OFFSET) >> gpio) & 1; }
robutest/uclinux
C++
GPL-2.0
60
/* put a big endian short (16bits) to a pointer Caller should ensure parameters are valid. */
void BytesPutBe16(void *ptr, uint16_t v)
/* put a big endian short (16bits) to a pointer Caller should ensure parameters are valid. */ void BytesPutBe16(void *ptr, uint16_t v)
{ uint8_t *p = (uint8_t *)ptr; p[0] = (v >> 8) & 0xff; p[1] = v & 0xff; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Perform I2C transfer. This driver only supports master mode, single bus-master. It does not return until the transfer is complete, polling for completion. */
I2C_TransferReturn_TypeDef I2CSPM_Transfer(I2C_TypeDef *i2c, I2C_TransferSeq_TypeDef *seq)
/* Perform I2C transfer. This driver only supports master mode, single bus-master. It does not return until the transfer is complete, polling for completion. */ I2C_TransferReturn_TypeDef I2CSPM_Transfer(I2C_TypeDef *i2c, I2C_TransferSeq_TypeDef *seq)
{ I2C_TransferReturn_TypeDef ret; uint32_t timeout = I2CSPM_TRANSFER_TIMEOUT; ret = I2C_TransferInit(i2c, seq); while (ret == i2cTransferInProgress && timeout--) { ret = I2C_Transfer(i2c); } return ret; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Possible return values and states of snap_src and snap_dest. 0: NULL, NULL - first new snapshot 1: snap_src, NULL - normal snapshot 2: snap_src, snap_dest - waiting for handover 2: snap_src, NULL - handed over, waiting for old to be deleted 1: NULL, snap_dest - source got destroyed without handover */
static int __find_snapshots_sharing_cow(struct dm_snapshot *snap, struct dm_snapshot **snap_src, struct dm_snapshot **snap_dest, struct dm_snapshot **snap_merge)
/* Possible return values and states of snap_src and snap_dest. 0: NULL, NULL - first new snapshot 1: snap_src, NULL - normal snapshot 2: snap_src, snap_dest - waiting for handover 2: snap_src, NULL - handed over, waiting for old to be deleted 1: NULL, snap_dest - source got destroyed without handover */ static int __...
{ struct dm_snapshot *s; struct origin *o; int count = 0; int active; o = __lookup_origin(snap->origin->bdev); if (!o) goto out; list_for_each_entry(s, &o->snapshots, list) { if (dm_target_is_snapshot_merge(s->ti) && snap_merge) *snap_merge = s; if (!bdev_equal(s->cow->bdev, snap->cow->bdev)) continu...
robutest/uclinux
C++
GPL-2.0
60
/* Unloads the Kvaser CANLIB DLL and resets the API function pointers. */
static void LeafLightLibUnloadDll(void)
/* Unloads the Kvaser CANLIB DLL and resets the API function pointers. */ static void LeafLightLibUnloadDll(void)
{ leafLightLibFuncInitializeLibraryPtr = NULL; leafLightLibFuncUnloadLibraryPtr = NULL; leafLightLibFuncOpenChannelPtr = NULL; leafLightLibFuncSetBusParamsPtr = NULL; leafLightLibFuncSetBusOutputControlPtr = NULL; leafLightLibFuncSetAcceptanceFilterPtr = NULL; leafLightLibFuncIoCtlPtr = NULL; leafLightL...
feaser/openblt
C++
GNU General Public License v3.0
601
/* Allocate an event channel for the given xenbus_device, assigning the newly created local port to *port. Return 0 on success, or -errno on error. On error, the device will switch to XenbusStateClosing, and the error will be saved in the store. */
int xenbus_alloc_evtchn(struct xenbus_device *dev, int *port)
/* Allocate an event channel for the given xenbus_device, assigning the newly created local port to *port. Return 0 on success, or -errno on error. On error, the device will switch to XenbusStateClosing, and the error will be saved in the store. */ int xenbus_alloc_evtchn(struct xenbus_device *dev, int *port)
{ struct evtchn_alloc_unbound alloc_unbound; int err; alloc_unbound.dom = DOMID_SELF; alloc_unbound.remote_dom = dev->otherend_id; err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &alloc_unbound); if (err) xenbus_dev_fatal(dev, err, "allocating event channel"); else *port = alloc_unbound.port...
robutest/uclinux
C++
GPL-2.0
60
/* As an example, using digital rollover mode and a 25-MHz main oscillator clock with a desired IEEE 1588 clock accuracy of 12.5 MHz, and having made a previous call to */
void EMACTimestampAddendSet(uint32_t ui32Base, uint32_t ui32Increment)
/* As an example, using digital rollover mode and a 25-MHz main oscillator clock with a desired IEEE 1588 clock accuracy of 12.5 MHz, and having made a previous call to */ void EMACTimestampAddendSet(uint32_t ui32Base, uint32_t ui32Increment)
{ ASSERT(ui32Base == EMAC0_BASE); HWREG(ui32Base + EMAC_O_TIMADD) = ui32Increment; while (HWREG(ui32Base + EMAC_O_TIMSTCTRL) & EMAC_TIMSTCTRL_ADDREGUP) { } HWREG(ui32Base + EMAC_O_TIMSTCTRL) |= EMAC_TIMSTCTRL_ADDREGUP; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Gets the 16-bit color of the pixel at the specified location. */
uint16_t lcdGetPixel(uint16_t x, uint16_t y)
/* Gets the 16-bit color of the pixel at the specified location. */ uint16_t lcdGetPixel(uint16_t x, uint16_t y)
{ uint16_t preFetch = 0; ili9325SetCursor(x, y); ili9325WriteCmd(ILI9325_COMMANDS_WRITEDATATOGRAM); preFetch = ili9325ReadData(); ili9325SetCursor(x, y); ili9325WriteCmd(ILI9325_COMMANDS_WRITEDATATOGRAM); return ili9325ReadData(); }
microbuilder/LPC1343CodeBase
C++
Other
73
/* This function mark all Rx descriptors as LAST_BD. */
void hif_rx_desc_disable(void)
/* This function mark all Rx descriptors as LAST_BD. */ void hif_rx_desc_disable(void)
{ int i; struct rx_desc_s *rx_desc; struct buf_desc *bd_va; if (!g_rx_desc) { printf("%s: HIF Rx desc not initialized\n", __func__); return; } rx_desc = g_rx_desc; bd_va = rx_desc->rx_base; for (i = 0; i < rx_desc->rx_ring_size; i++) { writel(readl(&bd_va->ctrl) | BD_CTRL_LAST_BD, &bd_va->ctrl); bd_va++...
4ms/stm32mp1-baremetal
C++
Other
137
/* Allocate a RTK_BUFFER with specified data length and reserved headroom. If caller does not know actual headroom to reserve for further usage, specify it to zero to use default value. */
RTK_BUFFER* RtbAllocate(uint32_t Length, uint32_t HeadRoom)
/* Allocate a RTK_BUFFER with specified data length and reserved headroom. If caller does not know actual headroom to reserve for further usage, specify it to zero to use default value. */ RTK_BUFFER* RtbAllocate(uint32_t Length, uint32_t HeadRoom)
{ RTK_BUFFER* Rtb = NULL; Rtb = malloc( sizeof(RTK_BUFFER) ); if(Rtb) { uint32_t BufferLen = HeadRoom ? (Length + HeadRoom) : (Length + DEFAULT_HEADER_SIZE); BufferLen = RTB_DATA_ALIGN(BufferLen); Rtb->Head = malloc(BufferLen); if(Rtb->Head) { Rtb->Hea...
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Stops the PWM signal generation in interrupt mode. */
void ald_timer_pwm_stop_by_it(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
/* Stops the PWM signal generation in interrupt mode. */ void ald_timer_pwm_stop_by_it(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
{ ald_timer_oc_stop_by_it(hperh, ch); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* only call from an error condition inside reiserfs_read_super! */
int journal_release_error(struct reiserfs_transaction_handle *th, struct super_block *sb)
/* only call from an error condition inside reiserfs_read_super! */ int journal_release_error(struct reiserfs_transaction_handle *th, struct super_block *sb)
{ return do_journal_release(th, sb, 1); }
robutest/uclinux
C++
GPL-2.0
60
/* Build the language ID table for string descriptors. */
EFI_STATUS UsbBuildLangTable(IN USB_DEVICE *UsbDev)
/* Build the language ID table for string descriptors. */ EFI_STATUS UsbBuildLangTable(IN USB_DEVICE *UsbDev)
{ EFI_USB_STRING_DESCRIPTOR *Desc; EFI_STATUS Status; UINTN Index; UINTN Max; UINT16 *Point; Desc = UsbGetOneString (UsbDev, 0, 0); if (Desc == NULL) { return EFI_UNSUPPORTED; } if (Desc->Length < 4) { Status = EFI_...
tianocore/edk2
C++
Other
4,240
/* Returns 1 if the PCI bus has ACPI based ejectable slots, 0 otherwise. */
int acpi_pci_detect_ejectable(acpi_handle handle)
/* Returns 1 if the PCI bus has ACPI based ejectable slots, 0 otherwise. */ int acpi_pci_detect_ejectable(acpi_handle handle)
{ int found = 0; if (!handle) return found; acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1, check_hotplug, NULL, (void *)&found, NULL); return found; }
robutest/uclinux
C++
GPL-2.0
60
/* Starts the TIMER PWM signal generation in DMA mode. */
ald_status_t ald_timer_pwm_start_by_dma(ald_timer_handle_t *hperh, ald_timer_channel_t ch, uint16_t *buf, uint32_t len, uint8_t dma_ch)
/* Starts the TIMER PWM signal generation in DMA mode. */ ald_status_t ald_timer_pwm_start_by_dma(ald_timer_handle_t *hperh, ald_timer_channel_t ch, uint16_t *buf, uint32_t len, uint8_t dma_ch)
{ return ald_timer_oc_start_by_dma(hperh, ch, buf, len, dma_ch); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Efi items have no locking, so just return. */
STATIC void xfs_efi_item_unlock(xfs_efi_log_item_t *)
/* Efi items have no locking, so just return. */ STATIC void xfs_efi_item_unlock(xfs_efi_log_item_t *)
{ if (efip->efi_item.li_flags & XFS_LI_ABORTED) xfs_efi_item_free(efip); return; }
robutest/uclinux
C++
GPL-2.0
60
/* An interrupt from the chip has arrived. Time to do some work */
static irqreturn_t w83977af_interrupt(int irq, void *dev_id)
/* An interrupt from the chip has arrived. Time to do some work */ static irqreturn_t w83977af_interrupt(int irq, void *dev_id)
{ struct net_device *dev = dev_id; struct w83977af_ir *self; __u8 set, icr, isr; int iobase; self = netdev_priv(dev); iobase = self->io.fir_base; set = inb(iobase+SSR); switch_bank(iobase, SET0); icr = inb(iobase+ICR); isr = inb(iobase+ISR) & icr; outb(0, iobase+ICR); if (isr) { if (self->io.speed > PIO...
robutest/uclinux
C++
GPL-2.0
60
/* @acb: The adapter which we are to un-initialize. */
static void adapter_uninit(struct AdapterCtlBlk *acb)
/* @acb: The adapter which we are to un-initialize. */ static void adapter_uninit(struct AdapterCtlBlk *acb)
{ unsigned long flags; DC395x_LOCK_IO(acb->scsi_host, flags); if (timer_pending(&acb->waiting_timer)) del_timer(&acb->waiting_timer); if (timer_pending(&acb->selto_timer)) del_timer(&acb->selto_timer); adapter_uninit_chip(acb); adapter_remove_and_free_all_devices(acb); DC395x_UNLOCK_IO(acb->scsi_host, flags)...
robutest/uclinux
C++
GPL-2.0
60
/* 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 Vector45_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 Vector45_handler(void)
{ asm { LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (45 * 2)) JMP 0,X } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Device unload callback. Called on an unplug or on module unload for each active device that is present. Disconnects the device from the network layer and frees all the resources */
static void __devexit velocity_remove1(struct pci_dev *pdev)
/* Device unload callback. Called on an unplug or on module unload for each active device that is present. Disconnects the device from the network layer and frees all the resources */ static void __devexit velocity_remove1(struct pci_dev *pdev)
{ struct net_device *dev = pci_get_drvdata(pdev); struct velocity_info *vptr = netdev_priv(dev); unregister_netdev(dev); iounmap(vptr->mac_regs); pci_release_regions(pdev); pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); free_netdev(dev); velocity_nics--; }
robutest/uclinux
C++
GPL-2.0
60
/* Open the network interface. The number of the interface to be opened is set by the configNETWORK_INTERFACE_TO_USE constant in FreeRTOSConfig.h. */
static void prvOpenSelectedNetworkInterface(pcap_if_t *pxAllNetworkInterfaces)
/* Open the network interface. The number of the interface to be opened is set by the configNETWORK_INTERFACE_TO_USE constant in FreeRTOSConfig.h. */ static void prvOpenSelectedNetworkInterface(pcap_if_t *pxAllNetworkInterfaces)
{ pcap_if_t *xInterface; long x; xInterface = pxAllNetworkInterfaces; for( x = 0L; x < ( configNETWORK_INTERFACE_TO_USE - 1L ); x++ ) { xInterface = xInterface->next; } pxOpenedInterfaceHandle = pcap_open( xInterface->name, UIP_CONF_BUFFER_SIZE, PCAP_OPENFLAG_PROMISCUOUS, 0xff...
apopple/Pandaboard-FreeRTOS
C++
null
25
/* This function returns the driver version number at runtime. */
uint32_t R_BYTEQ_GetVersion(void)
/* This function returns the driver version number at runtime. */ uint32_t R_BYTEQ_GetVersion(void)
{ uint32_t const version = (BYTEQ_VERSION_MAJOR << 16) | BYTEQ_VERSION_MINOR; return version; }
eclipse-threadx/getting-started
C++
Other
310
/* Perform basic hardware initialization at boot. This needs to be run from the very beginning. So the init priority has to be 0 (zero). */
static int stm32f1_init(void)
/* Perform basic hardware initialization at boot. This needs to be run from the very beginning. So the init priority has to be 0 (zero). */ static int stm32f1_init(void)
{ SystemCoreClock = 8000000; return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Initialize the ft6x06 communication bus from MCU to FT6206 : ie I2C channel initialization (if required). */
void ft6x06_Init(uint16_t DeviceAddr)
/* Initialize the ft6x06 communication bus from MCU to FT6206 : ie I2C channel initialization (if required). */ void ft6x06_Init(uint16_t DeviceAddr)
{ uint8_t instance; uint8_t empty; instance = ft6x06_GetInstance(DeviceAddr); if(instance == 0xFF) { empty = ft6x06_GetInstance(0); if(empty < FT6x06_MAX_INSTANCE) { ft6x06[empty] = DeviceAddr; TS_IO_Init(); } } }
eclipse-threadx/getting-started
C++
Other
310
/* According to the known GUID gVfrArrayAttractGuid to get the base address from FFS. */
EFI_STATUS SearchVfrBinInFfs(IN VOID *Ffs, IN VOID *EfiAddr, IN UINTN Length, OUT UINTN **Offset, OUT UINT8 *NumOfMatchingOffset)
/* According to the known GUID gVfrArrayAttractGuid to get the base address from FFS. */ EFI_STATUS SearchVfrBinInFfs(IN VOID *Ffs, IN VOID *EfiAddr, IN UINTN Length, OUT UINTN **Offset, OUT UINT8 *NumOfMatchingOffset)
{ UINTN Index; EFI_STATUS Status; UINTN VirOffValue; if ((Ffs == NULL) || (Offset == NULL)) { return EFI_NOT_FOUND; } Status = GetAddressByGuid ( Ffs, &gVfrArrayAttractGuid, Length, Offset, NumOfMatchingOffset ); ...
tianocore/edk2
C++
Other
4,240
/* Check the busy status of the specified SPI port. */
xtBoolean SPIIsBusy(unsigned long ulBase)
/* Check the busy status of the specified SPI port. */ xtBoolean SPIIsBusy(unsigned long ulBase)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)); return ((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_GO_BUSY) ? xtrue : xfalse); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Request the bootloader to upload the specified range of memory. The data is stored in the data byte array to which the pointer was specified. */
bool SessionReadData(uint32_t address, uint32_t len, uint8_t *data)
/* Request the bootloader to upload the specified range of memory. The data is stored in the data byte array to which the pointer was specified. */ bool SessionReadData(uint32_t address, uint32_t len, uint8_t *data)
{ bool result = false; assert(data != NULL); assert(len > 0); if ( (data != NULL) && (len > 0) ) { result = protocolPtr->ReadData(address, len, data); } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Set command code to ccw of a request. */
void raw3270_request_set_cmd(struct raw3270_request *rq, u8 cmd)
/* Set command code to ccw of a request. */ void raw3270_request_set_cmd(struct raw3270_request *rq, u8 cmd)
{ rq->ccw.cmd_code = cmd; }
robutest/uclinux
C++
GPL-2.0
60
/* WARNING: From here it is not very safe to access anything hanging off wusb_dev */
static void __wusbhc_dev_disconnect(struct wusbhc *wusbhc, struct wusb_port *port)
/* WARNING: From here it is not very safe to access anything hanging off wusb_dev */ static void __wusbhc_dev_disconnect(struct wusbhc *wusbhc, struct wusb_port *port)
{ struct wusb_dev *wusb_dev = port->wusb_dev; port->status &= ~(USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE | USB_PORT_STAT_SUSPEND | USB_PORT_STAT_RESET | USB_PORT_STAT_LOW_SPEED | USB_PORT_STAT_HIGH_SPEED); port->change |= USB_PORT_STAT_C_CONNECTION | USB_PORT_STAT_C_ENABLE; if (wusb_dev) { dev_db...
robutest/uclinux
C++
GPL-2.0
60
/* Returns the number of bytes received on success, or else the status code returned by the underlying usb_control_msg() call. */
static int usb_get_string(struct usb_device *dev, unsigned short langid, unsigned char index, void *buf, int size)
/* Returns the number of bytes received on success, or else the status code returned by the underlying usb_control_msg() call. */ static int usb_get_string(struct usb_device *dev, unsigned short langid, unsigned char index, void *buf, int size)
{ int i; int result; for (i = 0; i < 3; ++i) { result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, (USB_DT_STRING << 8) + index, langid, buf, size, USB_CTRL_GET_TIMEOUT); if (result == 0 || result == -EPIPE) continue; if (result > 1 && ((u8 *) buf)[1] != USB_D...
robutest/uclinux
C++
GPL-2.0
60
/* param base MCAN peripheral base address. param fifoBlock MCAN Fifo block, 0 or 1. param handle MCAN handle pointer. */
void MCAN_TransferAbortReceiveFifo(CAN_Type *base, uint8_t fifoBlock, mcan_handle_t *handle)
/* param base MCAN peripheral base address. param fifoBlock MCAN Fifo block, 0 or 1. param handle MCAN handle pointer. */ void MCAN_TransferAbortReceiveFifo(CAN_Type *base, uint8_t fifoBlock, mcan_handle_t *handle)
{ assert(NULL != handle); assert((0U == fifoBlock) || (1U == fifoBlock)); if (1U == fifoBlock) { MCAN_DisableInterrupts(base, CAN_IE_RF1NE_MASK); } else { MCAN_DisableInterrupts(base, CAN_IE_RF0NE_MASK); } handle->rxFifoFrameBuf = NULL; handle->rxFifoState = (uint...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Callbacks could take time, so they are done outside the scope of the global state machine log lock. */
STATIC void xlog_state_done_syncing(xlog_in_core_t *iclog, int)
/* Callbacks could take time, so they are done outside the scope of the global state machine log lock. */ STATIC void xlog_state_done_syncing(xlog_in_core_t *iclog, int)
{ xlog_t *log = iclog->ic_log; spin_lock(&log->l_icloglock); ASSERT(iclog->ic_state == XLOG_STATE_SYNCING || iclog->ic_state == XLOG_STATE_IOERROR); ASSERT(atomic_read(&iclog->ic_refcnt) == 0); ASSERT(iclog->ic_bwritecnt == 1 || iclog->ic_bwritecnt == 2); if (iclog->ic_state != XLOG_STATE_IOERROR) { ...
robutest/uclinux
C++
GPL-2.0
60
/* Perform basic hardware initialization. Initializes the base clocks and LPFLL using helpers provided by the HAL. */
static int soc_rv32m1_init(void)
/* Perform basic hardware initialization. Initializes the base clocks and LPFLL using helpers provided by the HAL. */ static int soc_rv32m1_init(void)
{ unsigned int key; key = irq_lock(); rv32m1_switch_to_sirc(); CLOCK_InitFirc(&rv32m1_firc_config); rv32m1_switch_sys_clk(&rv32m1_sys_clk_config_firc); CLOCK_InitLpFll(&rv32m1_lpfll_cfg); rv32m1_setup_peripheral_clocks(); irq_unlock(key); return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Event handler for the USB_ConfigurationChanged event. This is fired when the host sets the current configuration of the USB device after enumeration - the device endpoints are configured and the mouse reporting task started. */
void EVENT_USB_Device_ConfigurationChanged(void)
/* Event handler for the USB_ConfigurationChanged event. This is fired when the host sets the current configuration of the USB device after enumeration - the device endpoints are configured and the mouse reporting task started. */ void EVENT_USB_Device_ConfigurationChanged(void)
{ bool ConfigSuccess = true; ConfigSuccess &= Endpoint_ConfigureEndpoint(MOUSE_EPADDR, EP_TYPE_INTERRUPT, MOUSE_EPSIZE, 1); USB_Device_EnableSOFEvents(); LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Walk our list of auto-learnt fdb entries and return a port to forward or BR_FLOOD if unknown */
bridgeif_portmask_t bridgeif_fdb_get_dst_ports(void *fdb_ptr, struct eth_addr *dst_addr)
/* Walk our list of auto-learnt fdb entries and return a port to forward or BR_FLOOD if unknown */ bridgeif_portmask_t bridgeif_fdb_get_dst_ports(void *fdb_ptr, struct eth_addr *dst_addr)
{ int i; bridgeif_dfdb_t *fdb = (bridgeif_dfdb_t *)fdb_ptr; BRIDGEIF_DECL_PROTECT(lev); BRIDGEIF_READ_PROTECT(lev); for (i = 0; i < fdb->max_fdb_entries; i++) { bridgeif_dfdb_entry_t *e = &fdb->fdb[i]; if (e->used && e->ts) { if (!memcmp(&e->addr, dst_addr, sizeof(struct eth_addr))) { br...
ua1arn/hftrx
C++
null
69
/* spider_net_write_phy reads from an arbitrary PHY register via the spider GPCROPCMD register */
static int spider_net_read_phy(struct net_device *netdev, int mii_id, int reg)
/* spider_net_write_phy reads from an arbitrary PHY register via the spider GPCROPCMD register */ static int spider_net_read_phy(struct net_device *netdev, int mii_id, int reg)
{ struct spider_net_card *card = netdev_priv(netdev); u32 readvalue; readvalue = ((u32)mii_id << 21) | ((u32)reg << 16); spider_net_write_reg(card, SPIDER_NET_GPCROPCMD, readvalue); do { readvalue = spider_net_read_reg(card, SPIDER_NET_GPCROPCMD); } while (readvalue & SPIDER_NET_GPREXEC); readvalue &= SPIDER_N...
robutest/uclinux
C++
GPL-2.0
60
/* Configure the memory protection unit (MPU) to allow full access to the whole 4GB address space. */
void cortex_m3_mpu_full_access(void)
/* Configure the memory protection unit (MPU) to allow full access to the whole 4GB address space. */ void cortex_m3_mpu_full_access(void)
{ cortex_m3_mpu_set_region(0, 0x00000000, CM3_MPU_RASR_AP_RW_RW | CM3_MPU_RASR_SIZE_4GB | CM3_MPU_RASR_EN); cortex_m3_mpu_enable(1); }
EmcraftSystems/u-boot
C++
Other
181
/* This function gets called by ctrl-alt-del - ie the keyboard interrupt. As it's called within an interrupt, it may NOT sync: the only choice is whether to reboot at once, or just ignore the ctrl-alt-del. */
void ctrl_alt_del(void)
/* This function gets called by ctrl-alt-del - ie the keyboard interrupt. As it's called within an interrupt, it may NOT sync: the only choice is whether to reboot at once, or just ignore the ctrl-alt-del. */ void ctrl_alt_del(void)
{ static DECLARE_WORK(cad_work, deferred_cad); if (C_A_D) schedule_work(&cad_work); else kill_cad_pid(SIGINT, 1); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Adds all QDict entries to the QemuOpts that can be added and removes them from the QDict. When this function returns, the QDict contains only those entries that couldn't be added to the QemuOpts. */
void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp)
/* Adds all QDict entries to the QemuOpts that can be added and removes them from the QDict. When this function returns, the QDict contains only those entries that couldn't be added to the QemuOpts. */ void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp)
{ const QDictEntry *entry, *next; entry = qdict_first(qdict); while (entry != NULL) { Error *local_err = NULL; OptsFromQDictState state = { .errp = &local_err, .opts = opts, }; next = qdict_next(qdict, entry); if (find_desc_by_name(opts->list->...
ve3wwg/teensy3_qemu
C++
Other
15
/* This file is part of the Simba project. */
int mock_write_math_radians_to_degrees(float value, float res)
/* This file is part of the Simba project. */ int mock_write_math_radians_to_degrees(float value, float res)
{ harness_mock_write("math_radians_to_degrees(value)", &value, sizeof(value)); harness_mock_write("math_radians_to_degrees(): return (res)", &res, sizeof(res)); return (0); }
eerimoq/simba
C++
Other
337
/* Selects the specified I2C NACK position in master receiver mode. This function is useful in I2C Master Receiver mode when the number of data to be received is equal to 2. In this case, this function should be called (with parameter I2C_NACK_POS_NEXT) before data reception starts,as described in the 2-byte reception ...
void I2C_ConfigNackLocation(I2C_Module *I2Cx, uint16_t I2C_NACKPosition)
/* Selects the specified I2C NACK position in master receiver mode. This function is useful in I2C Master Receiver mode when the number of data to be received is equal to 2. In this case, this function should be called (with parameter I2C_NACK_POS_NEXT) before data reception starts,as described in the 2-byte reception ...
{ assert_param(IS_I2C_PERIPH(I2Cx)); assert_param(IS_I2C_NACK_POS(I2C_NACKPosition)); if (I2C_NACKPosition == I2C_NACK_POS_NEXT) { I2Cx->CTRL1 |= I2C_NACK_POS_NEXT; } else { I2Cx->CTRL1 &= I2C_NACK_POS_CURRENT; } }
pikasTech/PikaPython
C++
MIT License
1,403
/* USART pinmux initialization function. Set each required pin to USART functionality */
void TARGET_IO_PORT_init()
/* USART pinmux initialization function. Set each required pin to USART functionality */ void TARGET_IO_PORT_init()
{ gpio_set_pin_function(PA22, PINMUX_PA22C_SERCOM3_PAD0); gpio_set_pin_function(PA23, PINMUX_PA23C_SERCOM3_PAD1); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* put a little endian word (32bits) to a pointer Caller should ensure parameters are valid. */
void BytesPutLe32(void *ptr, uint32_t v)
/* put a little endian word (32bits) to a pointer Caller should ensure parameters are valid. */ void BytesPutLe32(void *ptr, uint32_t v)
{ uint8_t *p = (uint8_t *)ptr; p[0] = v & 0xff; p[1] = (v >> 8) & 0xff; p[2] = (v >> 16) & 0xff; p[3] = (v >> 24) & 0xff; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Scroll cursor to end of the current line. */
EFI_STATUS FileBufferEnd(VOID)
/* Scroll cursor to end of the current line. */ EFI_STATUS FileBufferEnd(VOID)
{ EFI_EDITOR_LINE *Line; UINTN FRow; UINTN FCol; Line = FileBuffer.CurrentLine; FRow = FileBuffer.FilePosition.Row; FCol = Line->Size + 1; FileBufferMovePosition (FRow, FCol); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and...
UINT16 EFIAPI PciBitFieldOr16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 OrData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and...
{ return PciWrite16 ( Address, BitFieldOr16 (PciRead16 (Address), StartBit, EndBit, OrData) ); }
tianocore/edk2
C++
Other
4,240
/* _base_restore_msix_table - this restores the msix vector table @ioc: per adapter object */
static void _base_restore_msix_table(struct MPT2SAS_ADAPTER *ioc)
/* _base_restore_msix_table - this restores the msix vector table @ioc: per adapter object */ static void _base_restore_msix_table(struct MPT2SAS_ADAPTER *ioc)
{ int i; if (!ioc->msix_enable || ioc->msix_table_backup == NULL) return; for (i = 0; i < ioc->msix_vector_count; i++) ioc->msix_table[i] = ioc->msix_table_backup[i]; }
robutest/uclinux
C++
GPL-2.0
60
/* DAC960_ProcessCompletedBuffer performs completion processing for an individual Buffer. */
static bool DAC960_ProcessCompletedRequest(DAC960_Command_T *Command, bool SuccessfulIO)
/* DAC960_ProcessCompletedBuffer performs completion processing for an individual Buffer. */ static bool DAC960_ProcessCompletedRequest(DAC960_Command_T *Command, bool SuccessfulIO)
{ struct request *Request = Command->Request; int Error = SuccessfulIO ? 0 : -EIO; pci_unmap_sg(Command->Controller->PCIDevice, Command->cmd_sglist, Command->SegmentCount, Command->DmaDirection); if (!__blk_end_request(Request, Error, Command->BlockCount << 9)) { if (Command->Completion) { complete(Command-...
robutest/uclinux
C++
GPL-2.0
60
/* Get the real time Note that this function is valid only if */
void DateTime_get(Ifx_DateTime *dt)
/* Get the real time Note that this function is valid only if */ void DateTime_get(Ifx_DateTime *dt)
{ sint32 seconds = (sint32)(now() / TimeConst_1s); seconds = seconds + g_DateTimeOffset; dt->hours = seconds / 3600; dt->minutes = seconds / 60; dt->minutes = dt->minutes % 60; dt->seconds = seconds % 60; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Loads an image of size = rows * columns, starting at the coordinate (x,y). */
void halLcdImage(const unsigned int Image[], int Columns, int Rows, int x, int y)
/* Loads an image of size = rows * columns, starting at the coordinate (x,y). */ void halLcdImage(const unsigned int Image[], int Columns, int Rows, int x, int y)
{ int i, CurrentLocation; CurrentLocation = (y << 5) + (x >> 3); halLcdSetAddress(CurrentLocation); for (i=0; i < Rows; i++) { halLcdDrawCurrentLine(Image, Columns); Image += Columns; CurrentLocation += 0x20; halLcdSetAddress(CurrentLocation); } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Initialize sercom i2c module to use in async mode. */
int32_t _i2c_m_async_init(struct _i2c_m_async_device *const i2c_dev, void *const hw)
/* Initialize sercom i2c module to use in async mode. */ int32_t _i2c_m_async_init(struct _i2c_m_async_device *const i2c_dev, void *const hw)
{ int32_t init_status; ASSERT(i2c_dev); i2c_dev->hw = hw; init_status = _i2c_m_sync_init_impl(&i2c_dev->service, hw); if (init_status) { return init_status; } _sercom_init_irq_param(hw, (void *)i2c_dev); NVIC_DisableIRQ((IRQn_Type)_sercom_get_irq_num(hw)); NVIC_ClearPendingIRQ((IRQn_Type)_sercom_get_irq_num(...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This service lets the caller get one enabled AP to execute a caller-provided function. */
EFI_STATUS EFIAPI MpInitLibStartupThisAP(IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, OUT BOOLEAN *Finished OPTIONAL)
/* This service lets the caller get one enabled AP to execute a caller-provided function. */ EFI_STATUS EFIAPI MpInitLibStartupThisAP(IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, OUT BOOLEAN *Finished OPTIO...
{ if (WaitEvent != NULL) { return EFI_UNSUPPORTED; } return StartupThisAPWorker ( Procedure, ProcessorNumber, NULL, TimeoutInMicroseconds, ProcedureArgument, Finished ); }
tianocore/edk2
C++
Other
4,240
/* Driver's initial design makes no race condition possible on i2c bus, so there is no need in any locking. Keep it in mind, while playing with the code. */
static s32 synaptics_i2c_reg_get(struct i2c_client *client, u16 reg)
/* Driver's initial design makes no race condition possible on i2c bus, so there is no need in any locking. Keep it in mind, while playing with the code. */ static s32 synaptics_i2c_reg_get(struct i2c_client *client, u16 reg)
{ int ret; ret = i2c_smbus_write_byte_data(client, PAGE_SEL_REG, reg >> 8); if (ret == 0) ret = i2c_smbus_read_byte_data(client, reg & 0xff); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Switch to Y plate resistance mode. Set MY to ground, PY to supply. Measure current. */
static unsigned int ucb1x00_ts_read_yres(struct ucb1x00_ts *ts)
/* Switch to Y plate resistance mode. Set MY to ground, PY to supply. Measure current. */ static unsigned int ucb1x00_ts_read_yres(struct ucb1x00_ts *ts)
{ ucb1x00_reg_write(ts->ucb, UCB_TS_CR, UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); return ucb1x00_adc_read(ts->ucb, 0, ts->adcsync); }
robutest/uclinux
C++
GPL-2.0
60
/* Allocate a route entry then initialize it with the Dest/Netmask and Gateway. */
IP4_ROUTE_ENTRY* Ip4CreateRouteEntry(IN IP4_ADDR Dest, IN IP4_ADDR Netmask, IN IP4_ADDR GateWay)
/* Allocate a route entry then initialize it with the Dest/Netmask and Gateway. */ IP4_ROUTE_ENTRY* Ip4CreateRouteEntry(IN IP4_ADDR Dest, IN IP4_ADDR Netmask, IN IP4_ADDR GateWay)
{ IP4_ROUTE_ENTRY *RtEntry; RtEntry = AllocatePool (sizeof (IP4_ROUTE_ENTRY)); if (RtEntry == NULL) { return NULL; } InitializeListHead (&RtEntry->Link); RtEntry->RefCnt = 1; RtEntry->Dest = Dest; RtEntry->Netmask = Netmask; RtEntry->NextHop = GateWay; RtEntry->Flag = 0; return RtEntry...
tianocore/edk2
C++
Other
4,240
/* Sets the @attribute to contain the given @attr_value, if possible. */
void g_file_info_set_attribute_uint64(GFileInfo *info, const char *attribute, guint64 attr_value)
/* Sets the @attribute to contain the given @attr_value, if possible. */ void g_file_info_set_attribute_uint64(GFileInfo *info, const char *attribute, guint64 attr_value)
{ g_return_if_fail (G_IS_FILE_INFO (info)); g_return_if_fail (attribute != NULL && *attribute != '\0'); _g_file_info_set_attribute_uint64_by_id (info, lookup_attribute (attribute), attr_value); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Write to card's Host Adapter Command Register. Include a delay for those times when it is needed. */
static void hacr_write_slow(unsigned long ioaddr, u16 hacr)
/* Write to card's Host Adapter Command Register. Include a delay for those times when it is needed. */ static void hacr_write_slow(unsigned long ioaddr, u16 hacr)
{ hacr_write(ioaddr, hacr); mdelay(1); }
robutest/uclinux
C++
GPL-2.0
60
/* Return code 0 - Successfully processed lirr iocb (currently always return 0) */
static int lpfc_els_rcv_lirr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, struct lpfc_nodelist *ndlp)
/* Return code 0 - Successfully processed lirr iocb (currently always return 0) */ static int lpfc_els_rcv_lirr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, struct lpfc_nodelist *ndlp)
{ struct ls_rjt stat; stat.un.b.lsRjtRsvd0 = 0; stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; stat.un.b.vendorUnique = 0; lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This function is called by DiscoverIdeDevice() during its device identification. It sends out the ATA Identify Command to the specified device. Only ATA device responses to this command. If the command succeeds, it returns the Identify data structure which contains information about the device. This function extract...
EFI_STATUS EFIAPI AtaIdentify(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT8 Channel, IN UINT8 Device, IN OUT EFI_IDENTIFY_DATA *Buffer, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock)
/* This function is called by DiscoverIdeDevice() during its device identification. It sends out the ATA Identify Command to the specified device. Only ATA device responses to this command. If the command succeeds, it returns the Identify data structure which contains information about the device. This function extract...
{ EFI_STATUS Status; EFI_ATA_COMMAND_BLOCK AtaCommandBlock; ZeroMem (&AtaCommandBlock, sizeof (EFI_ATA_COMMAND_BLOCK)); AtaCommandBlock.AtaCommand = ATA_CMD_IDENTIFY_DRIVE; AtaCommandBlock.AtaDeviceHead = (UINT8)(Device << 0x4); Status = AtaPioDataInOut ( Instance->PciIo, ...
tianocore/edk2
C++
Other
4,240
/* Enables the I2C Slave block. This will enable operation of the I2C Slave block. */
void xI2CSlaveEnable(unsigned long ulBase)
/* Enables the I2C Slave block. This will enable operation of the I2C Slave block. */ void xI2CSlaveEnable(unsigned long ulBase)
{ xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE) || (ulBase == I2C2_BASE) || (ulBase == I2C3_BASE) || (ulBase == I2C4_BASE)); xHWREG(ulBase + I2C_CON) |= I2C_CON_ENS1; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This function is a wrapper to write file using TFTP. */
EFI_STATUS PxeBcTftpWriteFile(IN PXEBC_PRIVATE_DATA *Private, IN VOID *Config, IN UINT8 *Filename, IN BOOLEAN Overwrite, IN UINTN *BlockSize, IN UINT8 *BufferPtr, IN OUT UINT64 *BufferSize)
/* This function is a wrapper to write file using TFTP. */ EFI_STATUS PxeBcTftpWriteFile(IN PXEBC_PRIVATE_DATA *Private, IN VOID *Config, IN UINT8 *Filename, IN BOOLEAN Overwrite, IN UINTN *BlockSize, IN UINT8 *BufferPtr, IN OUT UINT64 *BufferSize)
{ if (Private->PxeBc.Mode->UsingIpv6) { return PxeBcMtftp6WriteFile ( Private, (EFI_MTFTP6_CONFIG_DATA *)Config, Filename, Overwrite, BlockSize, BufferPtr, BufferSize ); } else { return PxeBcMtftp4WriteFi...
tianocore/edk2
C++
Other
4,240
/* This is our per-port timeout handler, for checking the modem status signals. */
static void imx_timeout(unsigned long data)
/* This is our per-port timeout handler, for checking the modem status signals. */ static void imx_timeout(unsigned long data)
{ struct imx_port *sport = (struct imx_port *)data; unsigned long flags; if (sport->port.state) { spin_lock_irqsave(&sport->port.lock, flags); imx_mctrl_check(sport); spin_unlock_irqrestore(&sport->port.lock, flags); mod_timer(&sport->timer, jiffies + MCTRL_TIMEOUT); } }
robutest/uclinux
C++
GPL-2.0
60
/* Callback to receive the subscribed Message. Prototype for MQTT subscribe Callback */
void SubscribeHandler(MessageData *msgData)
/* Callback to receive the subscribed Message. Prototype for MQTT subscribe Callback */ void SubscribeHandler(MessageData *msgData)
{ printf("\r\n %.*s",msgData->topicName->lenstring.len,msgData->topicName->lenstring.data); printf(" >> "); printf("%.*s",msgData->message->payloadlen,(char *)msgData->message->payload);}
remotemcu/remcu-chip-sdks
C++
null
436
/* If the adapter is link-on, set the auto-negotiate enable/reset bit. autong_complete should be set to 0 when starting auto-negotiation. autong_complete should be set to 1 if we didn't start auto-negotiation. sis900_timer will wait for link on again if autong_complete = 0. */
static void sis900_auto_negotiate(struct net_device *net_dev, int phy_addr)
/* If the adapter is link-on, set the auto-negotiate enable/reset bit. autong_complete should be set to 0 when starting auto-negotiation. autong_complete should be set to 1 if we didn't start auto-negotiation. sis900_timer will wait for link on again if autong_complete = 0. */ static void sis900_auto_negotiate(struct ...
{ struct sis900_private *sis_priv = netdev_priv(net_dev); int i = 0; u32 status; for (i = 0; i < 2; i++) status = mdio_read(net_dev, phy_addr, MII_STATUS); if (!(status & MII_STAT_LINK)){ if(netif_msg_link(sis_priv)) printk(KERN_INFO "%s: Media Link Off\n", net_dev->name); sis_priv->autong_complete = 1; ...
robutest/uclinux
C++
GPL-2.0
60
/* 7.3.2.3 Supplemental enhancement information RBSP syntax sei_rbsp( ) */
static int dissect_h264_sei_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
/* 7.3.2.3 Supplemental enhancement information RBSP syntax sei_rbsp( ) */ static int dissect_h264_sei_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
{ gint bit_offset; bit_offset = offset <<3; bit_offset = dissect_h264_sei_message( tree, tvb, pinfo, bit_offset); if (tvb_reported_length_remaining (tvb, bit_offset >> 3) != 0 || (bit_offset & 0x7) != 0) { bit_offset = dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset); } retu...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Function to enable the Accessory Mode on Android Devices. */
void uhi_aoa_mode_enable_complete(usb_add_t, uhd_trans_status_t, uint16_t)
/* Function to enable the Accessory Mode on Android Devices. */ void uhi_aoa_mode_enable_complete(usb_add_t, uhd_trans_status_t, uint16_t)
{ (void)add; (void)payload_trans; if (status == UHD_TRANS_NOERROR) { uhi_aoa_enable_stage = AOA_ENABLE_STAGE_SUCCESSFUL; uhi_aoa_enable_success(); } else { uhi_aoa_enable_stage = AOA_ENABLE_STAGE_FAILED; } }
remotemcu/remcu-chip-sdks
C++
null
436