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
/* Configures the specified DMA Tx Desc buffer1 and buffer2 sizes. */
void ETH_ConfigDmaTxDescBufSize(ETH_DMADescType *DMATxDesc, uint32_t BufferSize1, uint32_t BufferSize2)
/* Configures the specified DMA Tx Desc buffer1 and buffer2 sizes. */ void ETH_ConfigDmaTxDescBufSize(ETH_DMADescType *DMATxDesc, uint32_t BufferSize1, uint32_t BufferSize2)
{ assert_param(IS_ETH_DMA_TX_DESC_BUFFER_SIZE(BufferSize1)); assert_param(IS_ETH_DMA_TX_DESC_BUFFER_SIZE(BufferSize2)); DMATxDesc->CtrlOrBufSize |= (BufferSize1 | (BufferSize2 << ETH_DMA_TX_DESC_BUF2_SIZE_SHIFT)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns: The next rgrp in the recent list */
static struct gfs2_rgrpd* recent_rgrp_next(struct gfs2_rgrpd *cur_rgd)
/* Returns: The next rgrp in the recent list */ static struct gfs2_rgrpd* recent_rgrp_next(struct gfs2_rgrpd *cur_rgd)
{ struct gfs2_sbd *sdp = cur_rgd->rd_sbd; struct list_head *head; struct gfs2_rgrpd *rgd; spin_lock(&sdp->sd_rindex_spin); head = &sdp->sd_rindex_mru_list; if (unlikely(cur_rgd->rd_list_mru.next == head)) { spin_unlock(&sdp->sd_rindex_spin); return NULL; } rgd = list_entry(cur_rgd->rd_list_mru.next, struct gfs2_rgrpd, rd_list_mru); spin_unlock(&sdp->sd_rindex_spin); return rgd; }
robutest/uclinux
C++
GPL-2.0
60
/* Read all the interrupt/status flag of the device.. */
int32_t lps22hh_all_sources_get(stmdev_ctx_t *ctx, lps22hh_all_sources_t *val)
/* Read all the interrupt/status flag of the device.. */ int32_t lps22hh_all_sources_get(stmdev_ctx_t *ctx, lps22hh_all_sources_t *val)
{ int32_t ret; ret = lps22hh_read_reg(ctx, LPS22HH_INT_SOURCE, (uint8_t *) & (val->int_source), 1); if (ret == 0) { ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, (uint8_t *) & (val->fifo_status2), 1); } if (ret == 0) { ret = lps22hh_read_reg(ctx, LPS22HH_STATUS, (uint8_t *) & (val->status), 1); } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Configures system clock after wake-up from STOP: enable PLL and select PLL as system clock source. */
__STATIC_INLINE void SYSCLKConfig_FromSTOP(void)
/* Configures system clock after wake-up from STOP: enable PLL and select PLL as system clock source. */ __STATIC_INLINE void SYSCLKConfig_FromSTOP(void)
{ LL_RCC_HSE_Enable(); while(LL_RCC_HSE_IsReady() != 1) {}; LL_RCC_PLL_Enable(); while(LL_RCC_PLL_IsReady() != 1) { }; LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) { }; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* decodes the group of blocks / video packet header. */
static int ff_h261_resync(H261Context *h)
/* decodes the group of blocks / video packet header. */ static int ff_h261_resync(H261Context *h)
{ ret= h261_decode_gob_header(h); if(ret>=0) return 0; } else{ if(show_bits(&s->gb, 15)==0){ ret= h261_decode_gob_header(h); if(ret>=0) return 0; } s->gb= s->last_resync_gb; align_get_bits(&s->gb); left= get_bits_left(&s->gb); for(;left>15+1+4+5; left-=8){ if(show_bits(&s->gb, 15)==0){ GetBitContext bak= s->gb; ret= h261_decode_gob_header(h); if(ret>=0) return 0; s->gb= bak; } skip_bits(&s->gb, 8); } } return -1; }
DC-SWAT/DreamShell
C++
null
404
/* Event handler for the USB device Start Of Frame event. */
void EVENT_USB_Device_StartOfFrame(void)
/* Event handler for the USB device Start Of Frame event. */ void EVENT_USB_Device_StartOfFrame(void)
{ HID_Device_MillisecondElapsed(&Keyboard_HID_Interface); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* _detach is called to deconfigure a device. It should deallocate resources. This function is also called when _attach() fails, so it should be careful not to release resources that were not necessarily allocated by _attach(). dev->private and dev->subdevices are deallocated automatically by the core. */
static int pci230_detach(struct comedi_device *dev)
/* _detach is called to deconfigure a device. It should deallocate resources. This function is also called when _attach() fails, so it should be careful not to release resources that were not necessarily allocated by _attach(). dev->private and dev->subdevices are deallocated automatically by the core. */ static int pci230_detach(struct comedi_device *dev)
{ printk("comedi%d: amplc_pci230: remove\n", dev->minor); if (dev->subdevices && thisboard->have_dio) subdev_8255_cleanup(dev, dev->subdevices + 2); if (dev->irq) free_irq(dev->irq, dev); if (devpriv) { if (devpriv->pci_dev) { if (dev->iobase) { comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Fills each init_struct member with its default value. */
void SPI_StructInit(SPI_InitTypeDef *init_struct)
/* Fills each init_struct member with its default value. */ void SPI_StructInit(SPI_InitTypeDef *init_struct)
{ init_struct->SPI_Mode = SPI_Mode_Slave; init_struct->SPI_DataSize = SPI_DataSize_8b; init_struct->SPI_DataWidth = 8; init_struct->SPI_CPOL = SPI_CPOL_Low; init_struct->SPI_CPHA = SPI_CPHA_1Edge; init_struct->SPI_NSS = SPI_NSS_Soft; init_struct->SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2; init_struct->SPI_FirstBit = SPI_FirstBit_MSB; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Reset dac peripheral registers to their default reset values. */
void DAC_Reset(void)
/* Reset dac peripheral registers to their default reset values. */ void DAC_Reset(void)
{ RCM_EnableAPB1PeriphReset(RCM_APB1_PERIPH_DAC); RCM_DisableAPB1PeriphReset(RCM_APB1_PERIPH_DAC); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Return the list of DDC modes if available, or the BIOS fixed mode otherwise. */
static int intel_lvds_get_modes(struct drm_connector *connector)
/* Return the list of DDC modes if available, or the BIOS fixed mode otherwise. */ static int intel_lvds_get_modes(struct drm_connector *connector)
{ struct drm_device *dev = connector->dev; struct intel_output *intel_output = to_intel_output(connector); struct drm_i915_private *dev_priv = dev->dev_private; int ret = 0; ret = intel_ddc_get_modes(intel_output); if (ret) return ret; connector->display_info.min_vfreq = 0; connector->display_info.max_vfreq = 200; connector->display_info.min_hfreq = 0; connector->display_info.max_hfreq = 200; if (dev_priv->panel_fixed_mode != NULL) { struct drm_display_mode *mode; mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode); drm_mode_probed_add(connector, mode); return 1; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Dispatch specified Thread or Ready Thread with Highest Priority. */
void osRtxThreadDispatch(os_thread_t *thread)
/* Dispatch specified Thread or Ready Thread with Highest Priority. */ void osRtxThreadDispatch(os_thread_t *thread)
{ thread_ready = osRtxInfo.thread.ready.thread_list; if ((kernel_state == osRtxKernelRunning) && (thread_ready != NULL) && (thread_ready->priority > thread_running->priority)) { osRtxThreadListRemove(thread_ready); osRtxThreadBlock(thread_running); osRtxThreadSwitch(thread_ready); } } else { if ((kernel_state == osRtxKernelRunning) && (thread->priority > thread_running->priority)) { osRtxThreadBlock(thread_running); osRtxThreadSwitch(thread); } else { osRtxThreadReadyPut(thread); } } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Called for each entry in a dissector table. */
static void dissector_table_foreach_changed_func(gpointer key, gpointer value, gpointer user_data)
/* Called for each entry in a dissector table. */ static void dissector_table_foreach_changed_func(gpointer key, gpointer value, gpointer user_data)
{ dtbl_entry_t *dtbl_entry; dissector_foreach_info_t *info; g_assert(value); g_assert(user_data); dtbl_entry = (dtbl_entry_t *)value; if (dtbl_entry->initial == dtbl_entry->current) { return; } info = (dissector_foreach_info_t *)user_data; info->caller_func(info->table_name, info->selector_type, key, value, info->caller_data); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Notes: This routine assumes no locks are held on entry. */
static enum blk_eh_timer_return fc_timed_out(struct scsi_cmnd *scmd)
/* Notes: This routine assumes no locks are held on entry. */ static enum blk_eh_timer_return fc_timed_out(struct scsi_cmnd *scmd)
{ struct fc_rport *rport = starget_to_rport(scsi_target(scmd->device)); if (rport->port_state == FC_PORTSTATE_BLOCKED) return BLK_EH_RESET_TIMER; return BLK_EH_NOT_HANDLED; }
robutest/uclinux
C++
GPL-2.0
60
/* Resets the audio codec. It restores the default configuration of the codec (this function shall be called before initializing the codec). */
static void Codec_Reset(void)
/* Resets the audio codec. It restores the default configuration of the codec (this function shall be called before initializing the codec). */ static void Codec_Reset(void)
{ GPIO_WriteBit(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, Bit_RESET); Delay(CODEC_RESET_DELAY); GPIO_WriteBit(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, Bit_SET); }
avem-labs/Avem
C++
MIT License
1,752
/* Release selected PCI I/O and memory resources previously reserved. Call this function only after all use of the PCI regions has ceased. */
void pci_release_selected_regions(struct pci_dev *pdev, int bars)
/* Release selected PCI I/O and memory resources previously reserved. Call this function only after all use of the PCI regions has ceased. */ void pci_release_selected_regions(struct pci_dev *pdev, int bars)
{ int i; for (i = 0; i < 6; i++) if (bars & (1 << i)) pci_release_region(pdev, i); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns CR_OK upon successfull completion, an error code otherwise. */
enum CRStatus cr_statement_ruleset_set_decl_list(CRStatement *a_this, CRDeclaration *a_list)
/* Returns CR_OK upon successfull completion, an error code otherwise. */ enum CRStatus cr_statement_ruleset_set_decl_list(CRStatement *a_this, CRDeclaration *a_list)
{ g_return_val_if_fail (a_this && a_this->type == RULESET_STMT && a_this->kind.ruleset, CR_BAD_PARAM_ERROR); if (a_this->kind.ruleset->decl_list == a_list) return CR_OK; if (a_this->kind.ruleset->sel_list) { cr_declaration_destroy (a_this->kind.ruleset->decl_list); } a_this->kind.ruleset->sel_list = NULL; return CR_OK; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Convert a wide character, e.g. 'Á' little endian to be UTF-8 compatible */
static uint32_t lv_txt_utf8_conv_wc(uint32_t c)
/* Convert a wide character, e.g. 'Á' little endian to be UTF-8 compatible */ static uint32_t lv_txt_utf8_conv_wc(uint32_t c)
{ if((c & 0x80) != 0) { uint32_t swapped; uint8_t c8[4]; memcpy(c8, &c, 4); swapped = (c8[0] << 24) + (c8[1] << 16) + (c8[2] << 8) + (c8[3]); uint8_t i; for(i = 0; i < 4; i++) { if((swapped & 0xFF) == 0) swapped = (swapped >> 8); } c = swapped; } return c; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI PciExpressRead16(IN UINTN Address)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */ UINT16 EFIAPI PciExpressRead16(IN UINTN Address)
{ ASSERT_INVALID_PCI_ADDRESS (Address); if (Address >= PcdPciExpressBaseSize ()) { return (UINT16)-1; } return MmioRead16 ((UINTN)GetPciExpressBaseAddress () + Address); }
tianocore/edk2
C++
Other
4,240
/* Invert byte order within each 32-bits of an array. */
FourByteSwap(unsigned char *buf, size_t nbytes)
/* Invert byte order within each 32-bits of an array. */ FourByteSwap(unsigned char *buf, size_t nbytes)
{ for ( ; nbytes >= 4; nbytes -= 4, buf += 4 ) { unsigned char c; c = buf[0]; buf[0] = buf[3]; buf[3] = c; c = buf[1]; buf[1] = buf[2]; buf[2] = c; } }
pikasTech/PikaPython
C++
MIT License
1,403
/* Store the resolution of the clock selected by @which_clock in the variable pointed to by @tp. */
int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp)
/* Store the resolution of the clock selected by @which_clock in the variable pointed to by @tp. */ int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp)
{ struct hrtimer_cpu_base *cpu_base; cpu_base = &__raw_get_cpu_var(hrtimer_bases); *tp = ktime_to_timespec(cpu_base->clock_base[which_clock].resolution); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Look up a completion event file by FD. If lookup is successful, takes a ref to the event file struct that it returns; if unsuccessful, returns NULL. */
struct ib_uverbs_event_file* ib_uverbs_lookup_comp_file(int fd)
/* Look up a completion event file by FD. If lookup is successful, takes a ref to the event file struct that it returns; if unsuccessful, returns NULL. */ struct ib_uverbs_event_file* ib_uverbs_lookup_comp_file(int fd)
{ struct ib_uverbs_event_file *ev_file = NULL; struct file *filp; filp = fget(fd); if (!filp) return NULL; if (filp->f_op != &uverbs_event_fops) goto out; ev_file = filp->private_data; if (ev_file->is_async) { ev_file = NULL; goto out; } kref_get(&ev_file->ref); out: fput(filp); return ev_file; }
robutest/uclinux
C++
GPL-2.0
60
/* Writes a value to a PHY register hw - Struct containing variables accessed by shared code reg_addr - address of the PHY register to write data - data to write to the PHY */
static s32 atl2_write_phy_reg(struct atl2_hw *hw, u32 reg_addr, u16 phy_data)
/* Writes a value to a PHY register hw - Struct containing variables accessed by shared code reg_addr - address of the PHY register to write data - data to write to the PHY */ static s32 atl2_write_phy_reg(struct atl2_hw *hw, u32 reg_addr, u16 phy_data)
{ int i; u32 val; val = ((u32)(phy_data & MDIO_DATA_MASK)) << MDIO_DATA_SHIFT | (reg_addr & MDIO_REG_ADDR_MASK) << MDIO_REG_ADDR_SHIFT | MDIO_SUP_PREAMBLE | MDIO_START | MDIO_CLK_25_4 << MDIO_CLK_SEL_SHIFT; ATL2_WRITE_REG(hw, REG_MDIO_CTRL, val); wmb(); for (i = 0; i < MDIO_WAIT_TIMES; i++) { udelay(2); val = ATL2_READ_REG(hw, REG_MDIO_CTRL); if (!(val & (MDIO_START | MDIO_BUSY))) break; wmb(); } if (!(val & (MDIO_START | MDIO_BUSY))) return 0; return ATLX_ERR_PHY; }
robutest/uclinux
C++
GPL-2.0
60
/* mark_unsafe_pages - mark the pages that cannot be used for storing the image during resume, because they conflict with the pages that had been used before suspend */
static int mark_unsafe_pages(struct memory_bitmap *bm)
/* mark_unsafe_pages - mark the pages that cannot be used for storing the image during resume, because they conflict with the pages that had been used before suspend */ static int mark_unsafe_pages(struct memory_bitmap *bm)
{ struct zone *zone; unsigned long pfn, max_zone_pfn; for_each_populated_zone(zone) { max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages; for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) if (pfn_valid(pfn)) swsusp_unset_page_free(pfn_to_page(pfn)); } memory_bm_position_reset(bm); do { pfn = memory_bm_next_pfn(bm); if (likely(pfn != BM_END_OF_MAP)) { if (likely(pfn_valid(pfn))) swsusp_set_page_free(pfn_to_page(pfn)); else return -EFAULT; } } while (pfn != BM_END_OF_MAP); allocated_unsafe_pages = 0; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Gets the direction and mode of a pin. */
unsigned long xGPIODirModeGet(unsigned long ulPort, unsigned long ulPin)
/* Gets the direction and mode of a pin. */ unsigned long xGPIODirModeGet(unsigned long ulPort, unsigned long ulPin)
{ unsigned long ulBits; xASSERT(GPIOBaseValid(ulPort)); for(ulBits=0; ulBits<8; ulBits++) { if(ulPin & (1 << ulBits)) { break; } } return((xHWREG(ulPort + GPIO_PMD) & (3 << (ulBits * 2))) >> (ulBits * 2)); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Unlink a period-1 interrupt or async QH from the schedule */
static void unlink_async(struct uhci_hcd *uhci, struct uhci_qh *qh)
/* Unlink a period-1 interrupt or async QH from the schedule */ static void unlink_async(struct uhci_hcd *uhci, struct uhci_qh *qh)
{ struct uhci_qh *pqh; __le32 link_to_next_qh = qh->link; pqh = list_entry(qh->node.prev, struct uhci_qh, node); pqh->link = link_to_next_qh; if (pqh->skel < SKEL_FSBR && qh->skel >= SKEL_FSBR) uhci->skel_term_qh->link = link_to_next_qh; mb(); }
robutest/uclinux
C++
GPL-2.0
60
/* TO DO: active tuning and correction of cards without a bios. */
static u8 pci_bus_clock_list(u8 speed, struct chipset_bus_clock_list_entry *chipset_table)
/* TO DO: active tuning and correction of cards without a bios. */ static u8 pci_bus_clock_list(u8 speed, struct chipset_bus_clock_list_entry *chipset_table)
{ for ( ; chipset_table->xfer_speed ; chipset_table++) if (chipset_table->xfer_speed == speed) { return chipset_table->chipset_settings; } return chipset_table->chipset_settings; }
robutest/uclinux
C++
GPL-2.0
60
/* Return: true if a connected RX device was detected, false otherwise */
static bool is_connected(struct udevice *dev)
/* Return: true if a connected RX device was detected, false otherwise */ static bool is_connected(struct udevice *dev)
{ u8 retries = 0; do { int status = get_reg(dev, REG_INTERRUPT_SIG_STATE) & INTERRUPT_SIG_STATE_HPD_STATE_MASK; if (status) return true; udelay(1000); } while (retries++ < IS_CONNECTED_MAX_TIMEOUT_COUNT); return false; }
4ms/stm32mp1-baremetal
C++
Other
137
/* USBH_SetAddress This command sets the address to the connected device. */
USBH_Status USBH_SetAddress(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost, uint8_t DeviceAddress)
/* USBH_SetAddress This command sets the address to the connected device. */ USBH_Status USBH_SetAddress(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost, uint8_t DeviceAddress)
{ phost->Control.setup.b.bmRequestType = USB_H2D | USB_REQ_RECIPIENT_DEVICE | \ USB_REQ_TYPE_STANDARD; phost->Control.setup.b.bRequest = USB_REQ_SET_ADDRESS; phost->Control.setup.b.wValue.w = (uint16_t)DeviceAddress; phost->Control.setup.b.wIndex.w = 0; phost->Control.setup.b.wLength.w = 0; return USBH_CtlReq(pdev, phost, 0 , 0 ); }
MaJerle/stm32f429
C++
null
2,036
/* Returns result of operation - 0 is success, else negative errno */
int dm355evm_msp_write(u8 value, u8 reg)
/* Returns result of operation - 0 is success, else negative errno */ int dm355evm_msp_write(u8 value, u8 reg)
{ return i2c_smbus_write_byte_data(msp430, reg, value); }
robutest/uclinux
C++
GPL-2.0
60
/* atob(vp,p,base) converts p to binary result in vp, rtn 1 on success */
int atob(u_int32_t *vp, char *p, int base)
/* atob(vp,p,base) converts p to binary result in vp, rtn 1 on success */ int atob(u_int32_t *vp, char *p, int base)
{ u_quad_t v; if (base == 0) p = _getbase (p, &base); if (_atob (&v, p, base)) { *vp = v; return (1); } return (0); }
Nicholas3388/LuaNode
C++
Other
1,055
/* bsec_check_error() - Check status of one otp @base: base address of bsec IP @otp: otp number (0 - BSEC_OTP_MAX_VALUE) Return: 0 if no error, -EAGAIN or -ENOTSUPP */
static u32 bsec_check_error(u32 base, u32 otp)
/* bsec_check_error() - Check status of one otp @base: base address of bsec IP @otp: otp number (0 - BSEC_OTP_MAX_VALUE) Return: 0 if no error, -EAGAIN or -ENOTSUPP */ static u32 bsec_check_error(u32 base, u32 otp)
{ u32 bit; u32 bank; bit = 1 << (otp & OTP_LOCK_MASK); bank = ((otp >> OTP_LOCK_BANK_SHIFT) & OTP_LOCK_MASK) * sizeof(u32); if (readl(base + BSEC_DISTURBED_OFF + bank) & bit) return -EAGAIN; else if (readl(base + BSEC_ERROR_OFF + bank) & bit) return -ENOTSUPP; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Enable or Disable High Pass Filter on CLick. */
void LSM303DLHC_AccFilterClickCmd(uint8_t HighPassFilterClickState)
/* Enable or Disable High Pass Filter on CLick. */ void LSM303DLHC_AccFilterClickCmd(uint8_t HighPassFilterClickState)
{ uint8_t tmpreg; LSM303DLHC_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A, &tmpreg, 1); tmpreg &= 0xFB; tmpreg |= HighPassFilterClickState; LSM303DLHC_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A, &tmpreg); }
remotemcu/remcu-chip-sdks
C++
null
436
/* This function get detach state attribute in thread attributes object. PTHREAD_CREATE_JOINABLE Default value, it causes all threads created with attr to be in the joinable state. */
int pthread_attr_getdetachstate(pthread_attr_t const *attr, int *state)
/* This function get detach state attribute in thread attributes object. PTHREAD_CREATE_JOINABLE Default value, it causes all threads created with attr to be in the joinable state. */ int pthread_attr_getdetachstate(pthread_attr_t const *attr, int *state)
{ RT_ASSERT(attr != RT_NULL); *state = (int)attr->detachstate; return 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Call for each element in the list that defines flags for a variable */
static int set_flags(const char *name, const char *value, void *priv)
/* Call for each element in the list that defines flags for a variable */ static int set_flags(const char *name, const char *value, void *priv)
{ struct env_entry e, *ep; e.key = name; e.data = NULL; e.callback = NULL; hsearch_r(e, ENV_FIND, &ep, &env_htab, 0); if (ep != NULL) { if (value == NULL || strlen(value) == 0) ep->flags = 0; else ep->flags = env_parse_flags_to_bin(value); } return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Stops the TIMER one pulse signal generation on the complementary output. */
void ald_timer_one_pulse_n_stop(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
/* Stops the TIMER one pulse signal generation on the complementary output. */ void ald_timer_one_pulse_n_stop(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
{ ald_timer_ocn_stop(hperh, ch); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* They must be separated as otherwise the final stages could be starved by new requests which can block in the first stages due to memory allocation. */
static void crypt_endio(struct bio *clone, int error)
/* They must be separated as otherwise the final stages could be starved by new requests which can block in the first stages due to memory allocation. */ static void crypt_endio(struct bio *clone, int error)
{ struct dm_crypt_io *io = clone->bi_private; struct crypt_config *cc = io->target->private; unsigned rw = bio_data_dir(clone); if (unlikely(!bio_flagged(clone, BIO_UPTODATE) && !error)) error = -EIO; if (rw == WRITE) crypt_free_buffer_pages(cc, clone); bio_put(clone); if (rw == READ && !error) { kcryptd_queue_crypt(io); return; } if (unlikely(error)) io->error = error; crypt_dec_pending(io); }
robutest/uclinux
C++
GPL-2.0
60
/* call user callback fucntion to process the received data */
static void usb_host_cdc_receivedata(CDC_Xfer_TypeDef *cdc_Data)
/* call user callback fucntion to process the received data */ static void usb_host_cdc_receivedata(CDC_Xfer_TypeDef *cdc_Data)
{ uint8_t *ptr; if (cdc_Data->pEmptyBuff < cdc_Data->pFillBuff) { ptr = cdc_Data->pFillBuff; *ptr = 0x00; UserCb.Receive(cdc_Data->pEmptyBuff, cdc_Data->DataLength); cdc_Data->pFillBuff = cdc_Data->pEmptyBuff; cdc_Data->DataLength = 0; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If the source is not one of the standard GLib types, the @closure_callback and @closure_marshal fields of the #GSourceFuncs structure must have been filled in with pointers to appropriate functions. */
void g_source_set_dummy_callback(GSource *source)
/* If the source is not one of the standard GLib types, the @closure_callback and @closure_marshal fields of the #GSourceFuncs structure must have been filled in with pointers to appropriate functions. */ void g_source_set_dummy_callback(GSource *source)
{ GClosure *closure; closure = g_closure_new_simple (sizeof (GClosure), NULL); g_closure_set_meta_marshal (closure, NULL, dummy_closure_marshal); g_source_set_closure (source, closure); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* HCD MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhcd)
/* HCD MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhcd)
{ if(hhcd->Instance==USB_OTG_FS) { __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12); HAL_NVIC_DisableIRQ(OTG_FS_IRQn); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The created task to handle the USB demo functionality. */
static void vUSBDemoTask(void *pvParameters)
/* The created task to handle the USB demo functionality. */ static void vUSBDemoTask(void *pvParameters)
{ xISRStatus *pxMessage; ( void ) pvParameters; portENTER_CRITICAL(); vInitUSBInterface(); portEXIT_CRITICAL(); for( ;; ) { if( xQueueReceive( xUSBInterruptQueue, &pxMessage, usbSHORT_DELAY ) ) { if( pxMessage->ulISR & AT91C_UDP_EPINT0 ) { prvProcessEndPoint0Interrupt( pxMessage ); } if( pxMessage->ulISR & AT91C_UDP_ENDBUSRES ) { prvResetEndPoints(); } } else { if( eDriverState == eREADY_TO_SEND ) { prvTransmitSampleValues(); } } } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Update the master standby mode bits in @v to be @standbymode for the @oh hwmod. Does not write to the hardware. Returns -EINVAL upon error or 0 upon success. */
static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, u32 *v)
/* Update the master standby mode bits in @v to be @standbymode for the @oh hwmod. Does not write to the hardware. Returns -EINVAL upon error or 0 upon success. */ static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, u32 *v)
{ if (!oh->sysconfig || !(oh->sysconfig->sysc_flags & SYSC_HAS_MIDLEMODE)) return -EINVAL; *v &= ~SYSC_MIDLEMODE_MASK; *v |= __ffs(standbymode) << SYSC_MIDLEMODE_SHIFT; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return the current simulated RTC time in microseconds */
int64_t hwtimer_get_simu_rtc_time(void)
/* Return the current simulated RTC time in microseconds */ int64_t hwtimer_get_simu_rtc_time(void)
{ return nsi_hws_get_time() + rtc_offset; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* A periodic timer routine Polling PHY Chip Link Status */
static void r6040_timer(unsigned long data)
/* A periodic timer routine Polling PHY Chip Link Status */ static void r6040_timer(unsigned long data)
{ struct net_device *dev = (struct net_device *)data; struct r6040_private *lp = netdev_priv(dev); void __iomem *ioaddr = lp->base; u16 phy_mode; if (PHY_MODE == 0x3100) phy_mode = r6040_phy_mode_chk(dev); else phy_mode = (PHY_MODE & 0x0100) ? 0x8000:0x0; if (phy_mode != lp->phy_mode) { lp->phy_mode = phy_mode; lp->mcr0 = (lp->mcr0 & 0x7fff) | phy_mode; iowrite16(lp->mcr0, ioaddr); } mod_timer(&lp->timer, round_jiffies(jiffies + HZ)); }
robutest/uclinux
C++
GPL-2.0
60
/* Converts the unicode character of the string from uppercase to lowercase. This is a internal function. */
VOID HiiToLower(IN EFI_STRING ConfigString)
/* Converts the unicode character of the string from uppercase to lowercase. This is a internal function. */ VOID HiiToLower(IN EFI_STRING ConfigString)
{ EFI_STRING String; BOOLEAN Lower; ASSERT (ConfigString != NULL); for (String = ConfigString, Lower = FALSE; *String != L'\0'; String++) { if (*String == L'=') { Lower = TRUE; } else if (*String == L'&') { Lower = FALSE; } else if (Lower && (*String >= L'A') && (*String <= L'F')) { *String = (CHAR16)(*String - L'A' + L'a'); } } }
tianocore/edk2
C++
Other
4,240
/* Attempts to read one line from the file. The actual data read is pushed on the stack (or nil on EOF). */
static int File_read_line(lua_State *L, FILE_T ft)
/* Attempts to read one line from the file. The actual data read is pushed on the stack (or nil on EOF). */ static int File_read_line(lua_State *L, FILE_T ft)
{ lua_pushnil(L); return 0; } length = (gint)(file_tell(ft) - pos_before); if (linebuff[length-1] == '\n') { length--; if (length > 0 && linebuff[length - 1] == '\r') { length--; } linebuff[length] = '\0'; } lua_pushlstring(L, linebuff, length); return 1; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Initialization function for the Q31 sparse FIR filter. */
void arm_fir_sparse_init_q31(arm_fir_sparse_instance_q31 *S, uint16_t numTaps, const q31_t *pCoeffs, q31_t *pState, int32_t *pTapDelay, uint16_t maxDelay, uint32_t blockSize)
/* Initialization function for the Q31 sparse FIR filter. */ void arm_fir_sparse_init_q31(arm_fir_sparse_instance_q31 *S, uint16_t numTaps, const q31_t *pCoeffs, q31_t *pState, int32_t *pTapDelay, uint16_t maxDelay, uint32_t blockSize)
{ S->numTaps = numTaps; S->pCoeffs = pCoeffs; S->pTapDelay = pTapDelay; S->maxDelay = maxDelay; S->stateIndex = 0U; memset(pState, 0, (maxDelay + blockSize) * sizeof(q31_t)); S->pState = pState; }
pikasTech/PikaPython
C++
MIT License
1,403
/* RCC Set the Source for the System Clock. */
void rcc_set_sysclk_source(enum rcc_osc osc)
/* RCC Set the Source for the System Clock. */ void rcc_set_sysclk_source(enum rcc_osc osc)
{ switch (osc) { case RCC_PLL: RCC_CFGR |= RCC_CFGR_SW_PLL; break; case RCC_HSE: RCC_CFGR = (RCC_CFGR & ~RCC_CFGR_SW_MASK) | RCC_CFGR_SW_HSE; break; case RCC_HSI16: RCC_CFGR = (RCC_CFGR & ~RCC_CFGR_SW_MASK) | RCC_CFGR_SW_HSI16; break; case RCC_MSI: RCC_CFGR = (RCC_CFGR & ~RCC_CFGR_SW_MASK) | RCC_CFGR_SW_MSI; break; case RCC_HSI48: case RCC_LSE: case RCC_LSI: break; } }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* This function returns zero if the volume scanning information is consistent to the data read from the volume tabla, and %-EINVAL if not. */
static int check_sv(const struct ubi_volume *vol, const struct ubi_scan_volume *sv)
/* This function returns zero if the volume scanning information is consistent to the data read from the volume tabla, and %-EINVAL if not. */ static int check_sv(const struct ubi_volume *vol, const struct ubi_scan_volume *sv)
{ int err; if (sv->highest_lnum >= vol->reserved_pebs) { err = 1; goto bad; } if (sv->leb_count > vol->reserved_pebs) { err = 2; goto bad; } if (sv->vol_type != vol->vol_type) { err = 3; goto bad; } if (sv->used_ebs > vol->reserved_pebs) { err = 4; goto bad; } if (sv->data_pad != vol->data_pad) { err = 5; goto bad; } return 0; bad: ubi_err("bad scanning information, error %d", err); ubi_dbg_dump_sv(sv); ubi_dbg_dump_vol_info(vol); return -EINVAL; }
EmcraftSystems/u-boot
C++
Other
181
/* Append an urb_link (or a whole list of urb_links) to the tail of another list of urb_links. */
void urb_append(urb_link *hd, struct urb *urb)
/* Append an urb_link (or a whole list of urb_links) to the tail of another list of urb_links. */ void urb_append(urb_link *hd, struct urb *urb)
{ if (hd && urb) { urb_link *new = &urb->link; urb_link *pul = hd->prev; new->prev->next = hd; hd->prev = new->prev; new->prev = pul; pul->next = new; } }
EmcraftSystems/u-boot
C++
Other
181
/* Change Logs: Date Author Notes mojingxian first version */
void app_init_entry(void *parg)
/* Change Logs: Date Author Notes mojingxian first version */ void app_init_entry(void *parg)
{ parg = parg; rt_hw_core_timer_init(); rt_hw_isr_install(); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enables or disables the receiver Time Out feature. */
void USART_ReceiverTimeOutCmd(USART_TypeDef *USARTx, FunctionalState NewState)
/* Enables or disables the receiver Time Out feature. */ void USART_ReceiverTimeOutCmd(USART_TypeDef *USARTx, FunctionalState NewState)
{ assert_param(IS_USART_ALL_PERIPH(USARTx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { USARTx->CR2 |= USART_CR2_RTOEN; } else { USARTx->CR2 &= (uint32_t)~((uint32_t)USART_CR2_RTOEN); } }
ajhc/demo-cortex-m3
C++
null
38
/* Writes to the address space of a given SDIO function. Return value indicates if the transfer succeeded or not. */
int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr, void *src, int count)
/* Writes to the address space of a given SDIO function. Return value indicates if the transfer succeeded or not. */ int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr, void *src, int count)
{ return sdio_io_rw_ext_helper(func, 1, addr, 1, src, count); }
robutest/uclinux
C++
GPL-2.0
60
/* Checks whether the specified RTC interrupt has occurred or not. */
ITStatus RTC_GetITStatus(RTC_IT_TypeDef RTC_IT)
/* Checks whether the specified RTC interrupt has occurred or not. */ ITStatus RTC_GetITStatus(RTC_IT_TypeDef RTC_IT)
{ ITStatus itstatus = RESET; uint8_t enablestatus = 0, tmpreg = 0; assert_param(IS_RTC_GET_IT(RTC_IT)); enablestatus = (uint8_t)(RTC->CR2 & (uint16_t)RTC_IT); tmpreg = (uint8_t)(RTC->ISR2 & (uint8_t)((uint16_t)RTC_IT >> 4)); if ((enablestatus != (uint8_t)RESET) && (tmpreg != (uint8_t)RESET)) { itstatus = SET; } else { itstatus = RESET; } return (ITStatus)itstatus; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Return the entire driver board structure to a user app. */
static int stl_getbrdstruct(struct stlbrd __user *arg)
/* Return the entire driver board structure to a user app. */ static int stl_getbrdstruct(struct stlbrd __user *arg)
{ struct stlbrd stl_dummybrd; struct stlbrd *brdp; if (copy_from_user(&stl_dummybrd, arg, sizeof(struct stlbrd))) return -EFAULT; if (stl_dummybrd.brdnr >= STL_MAXBRDS) return -ENODEV; brdp = stl_brds[stl_dummybrd.brdnr]; if (!brdp) return -ENODEV; return copy_to_user(arg, brdp, sizeof(struct stlbrd)) ? -EFAULT : 0; }
robutest/uclinux
C++
GPL-2.0
60
/* If HmacSha384Context is NULL, then return FALSE. If HmacValue is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI HmacSha384Final(IN OUT VOID *HmacSha384Context, OUT UINT8 *HmacValue)
/* If HmacSha384Context is NULL, then return FALSE. If HmacValue is NULL, then return FALSE. If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI HmacSha384Final(IN OUT VOID *HmacSha384Context, OUT UINT8 *HmacValue)
{ return HmacMdFinal (HmacSha384Context, HmacValue); }
tianocore/edk2
C++
Other
4,240
/* Sets the baud rate, receive FIFO depth, transmit/receive time out, parity, data bits, and stop bits on a serial device. */
RETURN_STATUS EFIAPI SerialPortSetAttributes(IN OUT UINT64 *BaudRate, IN OUT UINT32 *ReceiveFifoDepth, IN OUT UINT32 *Timeout, IN OUT EFI_PARITY_TYPE *Parity, IN OUT UINT8 *DataBits, IN OUT EFI_STOP_BITS_TYPE *StopBits)
/* Sets the baud rate, receive FIFO depth, transmit/receive time out, parity, data bits, and stop bits on a serial device. */ RETURN_STATUS EFIAPI SerialPortSetAttributes(IN OUT UINT64 *BaudRate, IN OUT UINT32 *ReceiveFifoDepth, IN OUT UINT32 *Timeout, IN OUT EFI_PARITY_TYPE *Parity, IN OUT UINT8 *DataBits, IN OUT EFI_STOP_BITS_TYPE *StopBits)
{ RETURN_STATUS Status; if (RETURN_ERROR (SerialPortInitialize ())) { Status = RETURN_UNSUPPORTED; } else { Status = PL011UartInitializePort ( mSerialBaseAddress, FixedPcdGet32 (PL011UartClkInHz), BaudRate, ReceiveFifoDepth, Parity, DataBits, StopBits ); } return Status; }
tianocore/edk2
C++
Other
4,240
/* Disable the ip checksum offloading in receive path. Ip checksum offloading is disabled in the receive path. */
void synopGMAC_disable_rx_chksum_offload(synopGMACdevice *gmacdev)
/* Disable the ip checksum offloading in receive path. Ip checksum offloading is disabled in the receive path. */ void synopGMAC_disable_rx_chksum_offload(synopGMACdevice *gmacdev)
{ synopGMACClearBits(gmacdev->MacBase, GmacConfig, GmacRxIpcOffload); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return the Temperature: degrees / 10, Celcius or Fahrenheit. */
u16 UTIL_GetTemp(void)
/* Return the Temperature: degrees / 10, Celcius or Fahrenheit. */ u16 UTIL_GetTemp(void)
{ s32 temp; s16 *p=&ADC_ConvertedValue[1]; temp = (p[0]+p[1]+p[2]+p[3]+p[4]+p[5]+p[6]+p[7])/8; temp = temp & 0xFFF; temp = ( temp * VDD_VOLTAGE_MV ) / 0x1000; temp = (((1400-temp)*100000)/448)+25000; if ( fTemperatureInFahrenheit ) { temp = 32000 + (9 * temp) / 5 ; } return temp / 100; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Block UDMA on devices that cause trouble with this controller. */
static unsigned long hpt370_filter(struct ata_device *adev, unsigned long mask)
/* Block UDMA on devices that cause trouble with this controller. */ static unsigned long hpt370_filter(struct ata_device *adev, unsigned long mask)
{ if (adev->class == ATA_DEV_ATA) { if (hpt_dma_blacklisted(adev, "UDMA", bad_ata33)) mask &= ~ATA_MASK_UDMA; if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5)) mask &= ~(0xE0 << ATA_SHIFT_UDMA); } return ata_bmdma_mode_filter(adev, mask); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Set Input Polarity. The timer channel must be set to input capture mode. */
void timer_ic_set_polarity(uint32_t timer_peripheral, enum tim_ic_id ic, enum tim_ic_pol pol)
/* Set Input Polarity. The timer channel must be set to input capture mode. */ void timer_ic_set_polarity(uint32_t timer_peripheral, enum tim_ic_id ic, enum tim_ic_pol pol)
{ TIM_CCER(timer_peripheral) &= ~(0xa << (ic * 4)); switch (pol) { case TIM_IC_RISING: break; case TIM_IC_BOTH: TIM_CCER(timer_peripheral) |= (0xa << (ic * 4)); break; case TIM_IC_FALLING: TIM_CCER(timer_peripheral) |= (0x2 << (ic * 4)); } } /**@}
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* We model this as a regular bus type, and hang devices directly off this. */
static int sa1111_match(struct device *_dev, struct device_driver *_drv)
/* We model this as a regular bus type, and hang devices directly off this. */ static int sa1111_match(struct device *_dev, struct device_driver *_drv)
{ struct sa1111_dev *dev = SA1111_DEV(_dev); struct sa1111_driver *drv = SA1111_DRV(_drv); return dev->devid == drv->devid; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get convert status of specified channel in ADC priority mode. */
int32_t DAC_GetChConvertState(const CM_DAC_TypeDef *DACx, uint16_t u16Ch)
/* Get convert status of specified channel in ADC priority mode. */ int32_t DAC_GetChConvertState(const CM_DAC_TypeDef *DACx, uint16_t u16Ch)
{ int32_t i32Ret = LL_ERR_INVD_MD; DDL_ASSERT(IS_VALID_UNIT(DACx)); DDL_ASSERT(IS_VALID_CH(u16Ch)); if (0U != READ_REG16_BIT(DACx->DAADPCR, DAC_DAADPCR_ADPEN)) { i32Ret = LL_ERR_BUSY; if (READ_REG16_BIT(DACx->DAADPCR, (DAC_DAADPCR_DA1SF << u16Ch)) == 0U) { i32Ret = LL_OK; } } return i32Ret; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Global kernel interface to tell the VSP object in the primary partition to reboot this partition. */
void mf_reboot(char *cmd)
/* Global kernel interface to tell the VSP object in the primary partition to reboot this partition. */ void mf_reboot(char *cmd)
{ printk(KERN_INFO "mf.c: Preparing to bounce...\n"); signal_ce_msg_simple(0x4e, NULL); for (;;) ; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Reset the midi controllers on a particular channel to default values. */
static void snd_midi_reset_controllers(struct snd_midi_channel *chan)
/* Reset the midi controllers on a particular channel to default values. */ static void snd_midi_reset_controllers(struct snd_midi_channel *chan)
{ memset(chan->control, 0, sizeof(chan->control)); chan->gm_volume = 127; chan->gm_expression = 127; chan->gm_pan = 64; }
robutest/uclinux
C++
GPL-2.0
60
/* MSS_SPI_disable() See "mss_spi.h" for details of how to use this function. */
void MSS_SPI_disable(volatile mss_spi_instance_t *this_spi)
/* MSS_SPI_disable() See "mss_spi.h" for details of how to use this function. */ void MSS_SPI_disable(volatile mss_spi_instance_t *this_spi)
{ this_spi->hw_reg->CONTROL &= ~CTRL_ENABLE_MASK; }
EmcraftSystems/u-boot
C++
Other
181
/* percent - convert count to a percentage of total (rounding up or down) */
static u32 percent(u32 count, u32 total)
/* percent - convert count to a percentage of total (rounding up or down) */ static u32 percent(u32 count, u32 total)
{ return (count * 100 + (total / 2)) / total; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Calls a discover-all-services proc's callback with the specified parameters. If the proc has no callback, this function is a no-op. */
static int ble_gattc_disc_all_svcs_cb(struct ble_gattc_proc *proc, uint16_t status, uint16_t att_handle, struct ble_gatt_svc *service)
/* Calls a discover-all-services proc's callback with the specified parameters. If the proc has no callback, this function is a no-op. */ static int ble_gattc_disc_all_svcs_cb(struct ble_gattc_proc *proc, uint16_t status, uint16_t att_handle, struct ble_gatt_svc *service)
{ int rc; BLE_HS_DBG_ASSERT(!ble_hs_locked_by_cur_task()); BLE_HS_DBG_ASSERT(service != NULL || status != 0); ble_gattc_dbg_assert_proc_not_inserted(proc); if (status != 0 && status != BLE_HS_EDONE) { STATS_INC(ble_gattc_stats, disc_all_svcs_fail); } if (proc->disc_all_svcs.cb == NULL) { rc = 0; } else { rc = proc->disc_all_svcs.cb(proc->conn_handle, ble_gattc_error(status, att_handle), service, proc->disc_all_svcs.cb_arg); } return rc; }
Nicholas3388/LuaNode
C++
Other
1,055
/* This is a wrapper around register_netdevice that takes the rtnl semaphore and expands the device name if you passed a format string to alloc_netdev. */
int register_netdev(struct net_device *dev)
/* This is a wrapper around register_netdevice that takes the rtnl semaphore and expands the device name if you passed a format string to alloc_netdev. */ int register_netdev(struct net_device *dev)
{ int err; rtnl_lock(); if (strchr(dev->name, '%')) { err = dev_alloc_name(dev, dev->name); if (err < 0) goto out; } err = register_netdevice(dev); out: rtnl_unlock(); return err; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This API sets the auxiliary interface configuration in the sensor. */
uint16_t bma4_set_if_mode(uint8_t if_mode, struct bma4_dev *dev)
/* This API sets the auxiliary interface configuration in the sensor. */ uint16_t bma4_set_if_mode(uint8_t if_mode, struct bma4_dev *dev)
{ uint16_t rslt = 0; uint8_t data = 0; if (dev == NULL) { rslt |= BMA4_E_NULL_PTR; } else { if (if_mode <= BMA4_MAX_IF_MODE) { rslt |= bma4_read_regs(BMA4_IF_CONFIG_ADDR, &data, 1, dev); if (rslt == BMA4_OK) { data = BMA4_SET_BITSLICE(data, BMA4_IF_CONFIG_IF_MODE, if_mode); rslt |= bma4_write_regs(BMA4_IF_CONFIG_ADDR, &data, 1, dev); } } else { rslt |= BMA4_E_OUT_OF_RANGE; } } return rslt; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Clear the slave select pins of the specified SPI port. The */
void SPISSClear(unsigned long ulBase, unsigned long ulSlaveSel)
/* Clear the slave select pins of the specified SPI port. The */ void SPISSClear(unsigned long ulBase, unsigned long ulSlaveSel)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE)||(ulBase == SPI3_BASE) ); xASSERT((ulSlaveSel == SPI_SS_NONE) || (ulSlaveSel == SPI_SS0) || (ulSlaveSel == SPI_SS1) || (ulSlaveSel == SPI_SS0_SS1)); xHWREG(ulBase + SPI_SSR) &= ~ulSlaveSel; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* For all the DIVIL module LBAR, you should control the DIVIL LBAR reg and the RCONFx(0~5) reg to use the modules. */
static void divil_lbar_enable(void)
/* For all the DIVIL module LBAR, you should control the DIVIL LBAR reg and the RCONFx(0~5) reg to use the modules. */ static void divil_lbar_enable(void)
{ u32 hi, lo; int offset; for (offset = DIVIL_LBAR_SMB; offset <= DIVIL_LBAR_PMS; offset++) { _rdmsr(DIVIL_MSR_REG(offset), &hi, &lo); hi |= 0x01; _wrmsr(DIVIL_MSR_REG(DIVIL_LBAR_SMB), hi, lo); } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function checks whether the specified AP has finished the task assigned by StartupThisAP(), and whether timeout expires. */
EFI_STATUS CheckThisAP(IN UINTN ProcessorNumber)
/* This function checks whether the specified AP has finished the task assigned by StartupThisAP(), and whether timeout expires. */ EFI_STATUS CheckThisAP(IN UINTN ProcessorNumber)
{ CPU_MP_DATA *CpuMpData; CPU_AP_DATA *CpuData; CpuMpData = GetCpuMpData (); CpuData = &CpuMpData->CpuData[ProcessorNumber]; if (GetApState (CpuData) == CpuStateFinished) { if (CpuData->Finished != NULL) { *(CpuData->Finished) = TRUE; } SetApState (CpuData, CpuStateIdle); return EFI_SUCCESS; } else { if (CheckTimeout (&CpuData->CurrentTime, &CpuData->TotalTime, CpuData->ExpectedTime)) { if (CpuData->Finished != NULL) { *(CpuData->Finished) = FALSE; } ResetProcessorToIdleState (ProcessorNumber); return EFI_TIMEOUT; } } return EFI_NOT_READY; }
tianocore/edk2
C++
Other
4,240
/* Pop the most important thread from the ready list. */
static struct thrd_t* scheduler_ready_pop(void)
/* Pop the most important thread from the ready list. */ static struct thrd_t* scheduler_ready_pop(void)
{ return (thrd_prio_list_pop_isr(&module.scheduler.ready)->thrd_p); }
eerimoq/simba
C++
Other
337
/* Change Logs: Date Author Notes Meco Man first version Meco Man improve rt-thread initialization process */
void lv_user_gui_init(void)
/* Change Logs: Date Author Notes Meco Man first version Meco Man improve rt-thread initialization process */ void lv_user_gui_init(void)
{ extern void lv_demo_benchmark(void); lv_demo_benchmark(); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Search for 'objidx' in table at index -1. ('objidx' must be an absolute index.) Return 1 + string at top if it found a good name. */
static int findfield(lua_State *L, int objidx, int level)
/* Search for 'objidx' in table at index -1. ('objidx' must be an absolute index.) Return 1 + string at top if it found a good name. */ static int findfield(lua_State *L, int objidx, int level)
{ if (lua_type(L, -2) == LUA_TSTRING) { if (lua_rawequal(L, objidx, -1)) { lua_pop(L, 1); return 1; } else if (findfield(L, objidx, level - 1)) { lua_pushliteral(L, "."); lua_replace(L, -3); lua_concat(L, 3); return 1; } } lua_pop(L, 1); } return 0; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Clear the PWM interrupt flag of the PWM module. The */
void PWMIntFlagClear(unsigned long ulBase, unsigned long ulChannel, unsigned long ulIntType)
/* Clear the PWM interrupt flag of the PWM module. The */ void PWMIntFlagClear(unsigned long ulBase, unsigned long ulChannel, unsigned long ulIntType)
{ unsigned long ulChannelTemp; ulChannelTemp = (ulBase == PWMA_BASE) ? ulChannel : (ulChannel - 4); xASSERT(ulBase == PWMA_BASE); xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 3))); if (ulIntType & PWM_INT_PWM) { xHWREG(ulBase + PWM_PIIR) |= (PWM_PIER_PWMIE0 << ulChannelTemp); } if (ulIntType & PWM_INT_DUTY) { xHWREG(ulBase + PWM_PIIR) |= (PWM_PIER_PWMDIE0 << ulChannelTemp); } if (ulIntType & PWM_INT_CAP_BOTH) { xHWREG(ulBase + PWM_CCR0 + (ulChannelTemp << 1)) |= (PWM_CCR0_CAPIF0 << ((ulChannel % 2) ? 16 : 0)) ; } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Try to compile line on the stack as 'return <line>;'; on return, stack has either compiled chunk or original line (if compilation failed). */
static int addreturn(lua_State *L)
/* Try to compile line on the stack as 'return <line>;'; on return, stack has either compiled chunk or original line (if compilation failed). */ static int addreturn(lua_State *L)
{ lua_remove(L, -2); if (line[0] != '\0') { lua_saveline(L, line); } } else { lua_pop(L, 2); } return status; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Fills each COMP_InitStruct member with its default value. */
void COMP_StructInit(COMP_InitTypeDef *COMP_InitStruct)
/* Fills each COMP_InitStruct member with its default value. */ void COMP_StructInit(COMP_InitTypeDef *COMP_InitStruct)
{ COMP_InitStruct->COMP_InvertingInput = COMP_InvertingInput_1_4VREFINT; COMP_InitStruct->COMP_NonInvertingInput = COMP_NonInvertingInput_IO1; COMP_InitStruct->COMP_Output = COMP_Output_None; COMP_InitStruct->COMP_BlankingSrce = COMP_BlankingSrce_None; COMP_InitStruct->COMP_OutputPol = COMP_OutputPol_NonInverted; COMP_InitStruct->COMP_Hysteresis = COMP_Hysteresis_No; COMP_InitStruct->COMP_Mode = COMP_Mode_UltraLowPower; }
ajhc/demo-cortex-m3
C++
null
38
/* The destroy operation includes to call RamDisk.Unregister to unregister the RAM DISK from RAM DISK driver, free the memory allocated for the RAM Disk. */
VOID BmDestroyRamDisk(IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath)
/* The destroy operation includes to call RamDisk.Unregister to unregister the RAM DISK from RAM DISK driver, free the memory allocated for the RAM Disk. */ VOID BmDestroyRamDisk(IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath)
{ EFI_STATUS Status; VOID *RamDiskBuffer; UINTN RamDiskSizeInPages; ASSERT (RamDiskDevicePath != NULL); RamDiskBuffer = BmGetRamDiskMemoryInfo (RamDiskDevicePath, &RamDiskSizeInPages); if (mRamDisk == NULL) { Status = gBS->LocateProtocol (&gEfiRamDiskProtocolGuid, NULL, (VOID *)&mRamDisk); ASSERT_EFI_ERROR (Status); } Status = mRamDisk->Unregister (RamDiskDevicePath); ASSERT_EFI_ERROR (Status); FreePages (RamDiskBuffer, RamDiskSizeInPages); }
tianocore/edk2
C++
Other
4,240
/* imxfb_set_par(): Set the user defined part of the display for the specified console */
static int imxfb_set_par(struct fb_info *info)
/* imxfb_set_par(): Set the user defined part of the display for the specified console */ static int imxfb_set_par(struct fb_info *info)
{ struct imxfb_info *fbi = info->par; struct fb_var_screeninfo *var = &info->var; if (var->bits_per_pixel == 16 || var->bits_per_pixel == 32) info->fix.visual = FB_VISUAL_TRUECOLOR; else if (!fbi->cmap_static) info->fix.visual = FB_VISUAL_PSEUDOCOLOR; else { info->fix.visual = FB_VISUAL_STATIC_PSEUDOCOLOR; } info->fix.line_length = var->xres_virtual * var->bits_per_pixel / 8; fbi->palette_size = var->bits_per_pixel == 8 ? 256 : 16; imxfb_activate_var(var, info); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* init CFM state machine clear all CFM vars and flags */
void cfm_init(struct s_smc *smc)
/* init CFM state machine clear all CFM vars and flags */ void cfm_init(struct s_smc *smc)
{ smc->mib.fddiSMTCF_State = ACTIONS(SC0_ISOLATED) ; smc->r.rm_join = 0 ; smc->r.rm_loop = 0 ; smc->y[PA].scrub = 0 ; smc->y[PB].scrub = 0 ; smc->y[PA].cem_pst = CEM_PST_DOWN ; smc->y[PB].cem_pst = CEM_PST_DOWN ; }
robutest/uclinux
C++
GPL-2.0
60
/* Clear out all data in the circular buffer. */
static void pl2303_buf_clear(struct pl2303_buf *pb)
/* Clear out all data in the circular buffer. */ static void pl2303_buf_clear(struct pl2303_buf *pb)
{ if (pb != NULL) pb->buf_get = pb->buf_put; }
robutest/uclinux
C++
GPL-2.0
60
/* ibqptype2servicetype returns hcp service type corresponding to given ib qp type used by create_qp() */
static int ibqptype2servicetype(enum ib_qp_type ibqptype)
/* ibqptype2servicetype returns hcp service type corresponding to given ib qp type used by create_qp() */ static int ibqptype2servicetype(enum ib_qp_type ibqptype)
{ switch (ibqptype) { case IB_QPT_SMI: case IB_QPT_GSI: return ST_UD; case IB_QPT_RC: return ST_RC; case IB_QPT_UC: return ST_UC; case IB_QPT_UD: return ST_UD; case IB_QPT_RAW_IPV6: return -EINVAL; case IB_QPT_RAW_ETY: return -EINVAL; default: ehca_gen_err("Invalid ibqptype=%x", ibqptype); return -EINVAL; } }
robutest/uclinux
C++
GPL-2.0
60
/* Dissects the End Data specified in Section Note: many of the fields in this packet move from PTP/IP to PTP layer of the stack. Work will need to be done in future iterations to make this compatible with PTP/USB. */
void dissect_ptpIP_end_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 *offset)
/* Dissects the End Data specified in Section Note: many of the fields in this packet move from PTP/IP to PTP layer of the stack. Work will need to be done in future iterations to make this compatible with PTP/USB. */ void dissect_ptpIP_end_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 *offset)
{ col_set_str( pinfo->cinfo, COL_INFO, "End Data Packet "); dissect_ptp_transactionID(tvb, pinfo, tree, offset); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* param base Pointer to the FLEXIO_SPI_Type structure. param handle Pointer to the flexio_spi_master_handle_t structure to store the transfer state. param count Number of bytes transferred so far by the non-blocking transaction. retval kStatus_InvalidArgument count is Invalid. retval kStatus_Success Successfully return the count. */
status_t FLEXIO_SPI_MasterTransferGetCount(FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle, size_t *count)
/* param base Pointer to the FLEXIO_SPI_Type structure. param handle Pointer to the flexio_spi_master_handle_t structure to store the transfer state. param count Number of bytes transferred so far by the non-blocking transaction. retval kStatus_InvalidArgument count is Invalid. retval kStatus_Success Successfully return the count. */ status_t FLEXIO_SPI_MasterTransferGetCount(FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle, size_t *count)
{ assert(handle != NULL); if (NULL == count) { return kStatus_InvalidArgument; } if (handle->rxData != NULL) { *count = handle->transferSize - handle->rxRemainingBytes; } else { *count = handle->transferSize - handle->txRemainingBytes; } return kStatus_Success; }
eclipse-threadx/getting-started
C++
Other
310
/* Waits until the Si1133 is sleeping before proceeding. */
static uint32_t SI1133_waitUntilSleep(void)
/* Waits until the Si1133 is sleeping before proceeding. */ static uint32_t SI1133_waitUntilSleep(void)
{ uint32_t ret; uint8_t response; uint8_t count = 0; uint32_t retval; retval = SI1133_OK; while( count < 5 ) { ret = SI1133_registerRead( SI1133_REG_RESPONSE0, &response ); if( ( response & SI1133_RSP0_CHIPSTAT_MASK ) == SI1133_RSP0_SLEEP ) { break; } if( ret != SI1133_OK ) { retval = SI1133_ERROR_SLEEP_FAILED; break; } count++; } return retval; }
remotemcu/remcu-chip-sdks
C++
null
436
/* create a new mount for userspace and request it to be added into the namespace's tree */
static int do_new_mount(struct path *path, char *type, int flags, int mnt_flags, char *name, void *data)
/* create a new mount for userspace and request it to be added into the namespace's tree */ static int do_new_mount(struct path *path, char *type, int flags, int mnt_flags, char *name, void *data)
{ struct vfsmount *mnt; if (!type) return -EINVAL; if (!capable(CAP_SYS_ADMIN)) return -EPERM; lock_kernel(); mnt = do_kern_mount(type, flags, name, data); unlock_kernel(); if (IS_ERR(mnt)) return PTR_ERR(mnt); return do_add_mount(mnt, path, mnt_flags, NULL); }
robutest/uclinux
C++
GPL-2.0
60
/* Configure the selected source to generate a global interrupt or not. */
void stmpe811_TS_DisableIT(uint16_t DeviceAddr)
/* Configure the selected source to generate a global interrupt or not. */ void stmpe811_TS_DisableIT(uint16_t DeviceAddr)
{ stmpe811_DisableGlobalIT(DeviceAddr); stmpe811_DisableITSource(DeviceAddr, STMPE811_TS_IT); }
eclipse-threadx/getting-started
C++
Other
310
/* This function returns the split between preemptable priority levels and subpriority levels in the interrupt priority specification. */
unsigned long xIntPriorityGroupingGet(void)
/* This function returns the split between preemptable priority levels and subpriority levels in the interrupt priority specification. */ unsigned long xIntPriorityGroupingGet(void)
{ unsigned long ulLoop, ulValue; ulValue = xHWREG(NVIC_APINT) & NVIC_APINT_PRIGROUP_M; for(ulLoop = 0; ulLoop < NUM_PRIORITY; ulLoop++) { if(ulValue == g_pulPriority[ulLoop]) { break; } } return(ulLoop); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This function replaces the original UARTCharNonBlockingGet() API and performs the same actions. A macro is provided in */
long UARTCharGetNonBlocking(unsigned long ulBase)
/* This function replaces the original UARTCharNonBlockingGet() API and performs the same actions. A macro is provided in */ long UARTCharGetNonBlocking(unsigned long ulBase)
{ ASSERT(UARTBaseValid(ulBase)); if(!(HWREG(ulBase + UART_O_FR) & UART_FR_RXFE)) { return(HWREG(ulBase + UART_O_DR)); } else { return(-1); } }
watterott/WebRadio
C++
null
71
/* This file is part of the Simba project. */
int mock_write_esp_wifi_station_init(const char *ssid_p, const char *password_p, const uint8_t *bssid_p, const struct inet_if_ip_info_t *info_p, int res)
/* This file is part of the Simba project. */ int mock_write_esp_wifi_station_init(const char *ssid_p, const char *password_p, const uint8_t *bssid_p, const struct inet_if_ip_info_t *info_p, int res)
{ harness_mock_write("esp_wifi_station_init(ssid_p)", ssid_p, strlen(ssid_p) + 1); harness_mock_write("esp_wifi_station_init(password_p)", password_p, strlen(password_p) + 1); harness_mock_write("esp_wifi_station_init(bssid_p)", bssid_p, sizeof(*bssid_p)); harness_mock_write("esp_wifi_station_init(info_p)", info_p, sizeof(*info_p)); harness_mock_write("esp_wifi_station_init(): return (res)", &res, sizeof(res)); return (0); }
eerimoq/simba
C++
Other
337
/* Called very early, MMU is off, device-tree isn't unflattened */
static int __init sbc834x_probe(void)
/* Called very early, MMU is off, device-tree isn't unflattened */ static int __init sbc834x_probe(void)
{ unsigned long root = of_get_flat_dt_root(); return of_flat_dt_is_compatible(root, "SBC834x"); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* e1000_irq_disable - Mask off interrupt generation on the NIC @adapter: board private structure */
static void e1000_irq_disable(struct e1000_adapter *adapter)
/* e1000_irq_disable - Mask off interrupt generation on the NIC @adapter: board private structure */ static void e1000_irq_disable(struct e1000_adapter *adapter)
{ struct e1000_hw *hw = &adapter->hw; ew32(IMC, ~0); E1000_WRITE_FLUSH(); synchronize_irq(adapter->pdev->irq); }
robutest/uclinux
C++
GPL-2.0
60
/* onenand_default_bbt - Select a default bad block table for the device */
int onenand_default_bbt(struct mtd_info *mtd)
/* onenand_default_bbt - Select a default bad block table for the device */ int onenand_default_bbt(struct mtd_info *mtd)
{ struct onenand_chip *this = mtd->priv; struct bbm_info *bbm; this->bbm = malloc(sizeof(struct bbm_info)); if (!this->bbm) return -ENOMEM; bbm = this->bbm; memset(bbm, 0, sizeof(struct bbm_info)); if (!bbm->badblock_pattern) bbm->badblock_pattern = &largepage_memorybased; return onenand_scan_bbt(mtd, bbm->badblock_pattern); }
EmcraftSystems/u-boot
C++
Other
181
/* Disables a Generic Clock that was previously enabled. Stops the clock generation of a Generic Clock that was previously started via a call to */
void system_gclk_chan_disable(const uint8_t channel)
/* Disables a Generic Clock that was previously enabled. Stops the clock generation of a Generic Clock that was previously started via a call to */ void system_gclk_chan_disable(const uint8_t channel)
{ system_interrupt_enter_critical_section(); Assert(!GCLK->PCHCTRL[channel].bit.WRTLOCK); GCLK->PCHCTRL[channel].reg &= ~GCLK_PCHCTRL_CHEN; while (GCLK->PCHCTRL[channel].reg & GCLK_PCHCTRL_CHEN) { } system_interrupt_leave_critical_section(); }
memfault/zero-to-main
C++
null
200
/* AES key schedule (same for encryption or decryption, as hardware handles schedule) */
int esp_aes_setkey(esp_aes_context *ctx, const unsigned char *key, unsigned int keybits)
/* AES key schedule (same for encryption or decryption, as hardware handles schedule) */ int esp_aes_setkey(esp_aes_context *ctx, const unsigned char *key, unsigned int keybits)
{ if (keybits != 128 && keybits != 192 && keybits != 256) { return MBEDTLS_ERR_AES_INVALID_KEY_LENGTH; } ctx->key_bytes = keybits / 8; memcpy(ctx->key, key, ctx->key_bytes); return 0; }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* param src USB HS PHY PLL clock source. param freq The frequency specified by src. retval true The clock is set successfully. retval false The clock source is invalid to get proper USB HS clock. */
bool CLOCK_EnableUsbhs0PhyPllClock(clock_usb_phy_src_t src, uint32_t freq)
/* param src USB HS PHY PLL clock source. param freq The frequency specified by src. retval true The clock is set successfully. retval false The clock source is invalid to get proper USB HS clock. */ bool CLOCK_EnableUsbhs0PhyPllClock(clock_usb_phy_src_t src, uint32_t freq)
{ static const clock_usb_pll_config_t g_ccmConfigUsbPll = {.loopDivider = 0U}; if ((CCM_ANALOG->PLL_USB1 & CCM_ANALOG_PLL_USB1_ENABLE_MASK) != 0UL) { CCM_ANALOG->PLL_USB1 |= CCM_ANALOG_PLL_USB1_EN_USB_CLKS_MASK; } else { CLOCK_InitUsb1Pll(&g_ccmConfigUsbPll); } USBPHY->CTRL &= ~USBPHY_CTRL_SFTRST_MASK; USBPHY->CTRL &= ~USBPHY_CTRL_CLKGATE_MASK; USBPHY->PWD = 0; USBPHY->CTRL |= USBPHY_CTRL_ENAUTOCLR_PHY_PWD_MASK | USBPHY_CTRL_ENAUTOCLR_CLKGATE_MASK | USBPHY_CTRL_ENUTMILEVEL2_MASK | USBPHY_CTRL_ENUTMILEVEL3_MASK; return true; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function calls ProcessLibraryDestructorList() and the EFI Boot Service */
VOID EFIAPI Exit(IN EFI_STATUS Status)
/* This function calls ProcessLibraryDestructorList() and the EFI Boot Service */ VOID EFIAPI Exit(IN EFI_STATUS Status)
{ ProcessLibraryDestructorList (gImageHandle, gST); gBS->Exit (gImageHandle, Status, 0, NULL); }
tianocore/edk2
C++
Other
4,240
/* RCU completion callback to indicate item is deleted */
static void complete_edac_pci_list_del(struct rcu_head *head)
/* RCU completion callback to indicate item is deleted */ static void complete_edac_pci_list_del(struct rcu_head *head)
{ struct edac_pci_ctl_info *pci; pci = container_of(head, struct edac_pci_ctl_info, rcu); INIT_LIST_HEAD(&pci->link); }
robutest/uclinux
C++
GPL-2.0
60
/* If no format string is specified the Format must be NULL. */
VOID EFIAPI Dump4Chars(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr)
/* If no format string is specified the Format must be NULL. */ VOID EFIAPI Dump4Chars(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr)
{ Print ( (Format != NULL) ? Format : L"%c%c%c%c", Ptr[0], Ptr[1], Ptr[2], Ptr[3] ); }
tianocore/edk2
C++
Other
4,240