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
/* Simply write the address register and read the configuration data. Note that the 4 nops ensure that we are able to handle a delayed abort (in theory.) */
static u32 iop3xx_read(unsigned long addr)
/* Simply write the address register and read the configuration data. Note that the 4 nops ensure that we are able to handle a delayed abort (in theory.) */ static u32 iop3xx_read(unsigned long addr)
{ u32 val; __asm__ __volatile__( "str %1, [%2]\n\t" "ldr %0, [%3]\n\t" "nop\n\t" "nop\n\t" "nop\n\t" "nop\n\t" : "=r" (val) : "r" (addr), "r" (IOP3XX_OCCAR), "r" (IOP3XX_OCCDR)); return val; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Add a struct btrfs_ordered_sum into the list of checksums to be inserted when an ordered extent is finished. If the list covers more than one ordered extent, it is split across multiples. */
int btrfs_add_ordered_sum(struct inode *inode, struct btrfs_ordered_extent *entry, struct btrfs_ordered_sum *sum)
/* Add a struct btrfs_ordered_sum into the list of checksums to be inserted when an ordered extent is finished. If the list covers more than one ordered extent, it is split across multiples. */ int btrfs_add_ordered_sum(struct inode *inode, struct btrfs_ordered_extent *entry, struct btrfs_ordered_sum *sum)
{ struct btrfs_ordered_inode_tree *tree; tree = &BTRFS_I(inode)->ordered_tree; mutex_lock(&tree->mutex); list_add_tail(&sum->list, &entry->list); mutex_unlock(&tree->mutex); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* The Bluetooth MAC address serves as the board serial number. */
void get_board_serial(struct tag_serialnr *serialnr)
/* The Bluetooth MAC address serves as the board serial number. */ void get_board_serial(struct tag_serialnr *serialnr)
{ u32 offset; u8 buf[6]; if (!board_rev) board_rev = get_board_rev(); offset = (board_rev == 3) ? EEPROM_REV_OFFSET : EEPROM_MAC_OFFSET; if (i2c_read(EEPROM_I2C_ADDR, offset, 2, buf, 6)) { printf("\nBoard serial read failed!\n"); } else { u8 *nr; nr = (u8 *)&serialnr->low; nr[0] = buf[5]; nr[1] = buf[...
4ms/stm32mp1-baremetal
C++
Other
137
/* Initiates resume signaling to wake a device from LPM suspend mode. */
void USBHostLPMResume(uint32_t ui32Base)
/* Initiates resume signaling to wake a device from LPM suspend mode. */ void USBHostLPMResume(uint32_t ui32Base)
{ ASSERT(ui32Base == USB0_BASE); HWREGB(ui32Base + USB_O_LPMCNTRL) |= USB_LPMCNTRL_RES; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Configure Timer Counter 0 (TC0) to generate an interrupt every second. This interrupt will be used to display the number of bytes received on the UART. */
static void configure_tc0(void)
/* Configure Timer Counter 0 (TC0) to generate an interrupt every second. This interrupt will be used to display the number of bytes received on the UART. */ static void configure_tc0(void)
{ pmc_enable_periph_clk(ID_TC0); tc_init(TC0, 0, 0x4 | TC_CMR_ACPC_SET | TC_CMR_WAVE | TC_CMR_ACPA_CLEAR | (0x2 << 13)); TC0->TC_CHANNEL[0].TC_RA = 16384; TC0->TC_CHANNEL[0].TC_RC = 32768; }
remotemcu/remcu-chip-sdks
C++
null
436
/* This API is used to get the fifo(int2_fifo) interrupt2 enable bits of the sensor in the registers 0x18 bit 5. */
BMG160_RETURN_FUNCTION_TYPE bmg160_get_intr2_fifo(u8 *v_intr_fifo_u8)
/* This API is used to get the fifo(int2_fifo) interrupt2 enable bits of the sensor in the registers 0x18 bit 5. */ BMG160_RETURN_FUNCTION_TYPE bmg160_get_intr2_fifo(u8 *v_intr_fifo_u8)
{ BMG160_RETURN_FUNCTION_TYPE comres = ERROR; u8 v_data_u8 = BMG160_INIT_VALUE; if (p_bmg160 == BMG160_NULL) { return E_BMG160_NULL_PTR; } else { comres = p_bmg160->BMG160_BUS_READ_FUNC(p_bmg160->dev_addr, BMG160_MAP_ONE_INTR2...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function provides minimum delay (in milliseconds) based on variable incremented. */
__weak void HAL_Delay(uint32_t Delay)
/* This function provides minimum delay (in milliseconds) based on variable incremented. */ __weak void HAL_Delay(uint32_t Delay)
{ uint32_t tickstart = HAL_GetTick(); uint32_t wait = Delay; if (wait < HAL_MAX_DELAY) { wait += (uint32_t)(uwTickFreq); } while ((HAL_GetTick() - tickstart) < wait) { } }
ua1arn/hftrx
C++
null
69
/* Retrieves Volume attributes. No polarity translations are done. */
EFI_STATUS EFIAPI FwVolBlockGetAttributes(IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, OUT EFI_FVB_ATTRIBUTES_2 *Attributes)
/* Retrieves Volume attributes. No polarity translations are done. */ EFI_STATUS EFIAPI FwVolBlockGetAttributes(IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, OUT EFI_FVB_ATTRIBUTES_2 *Attributes)
{ EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; FvbDevice = FVB_DEVICE_FROM_THIS (This); *Attributes = FvbDevice->FvbAttributes & ~EFI_FVB2_WRITE_STATUS; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* remote_vars points to a buffer that is cacheline aligned for BTE copies and assumed to be of size XPC_RP_VARS_SIZE. */
static enum xp_retval xpc_get_remote_vars_sn2(unsigned long remote_vars_pa, struct xpc_vars_sn2 *remote_vars)
/* remote_vars points to a buffer that is cacheline aligned for BTE copies and assumed to be of size XPC_RP_VARS_SIZE. */ static enum xp_retval xpc_get_remote_vars_sn2(unsigned long remote_vars_pa, struct xpc_vars_sn2 *remote_vars)
{ enum xp_retval ret; if (remote_vars_pa == 0) return xpVarsNotSet; ret = xp_remote_memcpy(xp_pa(remote_vars), remote_vars_pa, XPC_RP_VARS_SIZE); if (ret != xpSuccess) return ret; if (XPC_VERSION_MAJOR(remote_vars->version) != XPC_VERSION_MAJOR(XPC_V_VERSION)) { return xpBadVersion; } return...
robutest/uclinux
C++
GPL-2.0
60
/* See _g_freedesktop_dbus_call_list_activatable_names_sync() for the synchronous, blocking version of this method. */
void _g_freedesktop_dbus_call_list_activatable_names(_GFreedesktopDBus *proxy, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
/* See _g_freedesktop_dbus_call_list_activatable_names_sync() for the synchronous, blocking version of this method. */ void _g_freedesktop_dbus_call_list_activatable_names(_GFreedesktopDBus *proxy, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
{ g_dbus_proxy_call (G_DBUS_PROXY (proxy), "ListActivatableNames", g_variant_new ("()"), G_DBUS_CALL_FLAGS_NONE, -1, cancellable, callback, user_data); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* @ Funciton: NF_EraseBlock Parameter: block (max: 2048) Return: 0: Flash Operation OK 1: Flash Operation NG */
int NF_EraseBlock(unsigned int block)
/* @ Funciton: NF_EraseBlock Parameter: block (max: 2048) Return: 0: Flash Operation OK 1: Flash Operation NG */ int NF_EraseBlock(unsigned int block)
{ rt_uint32_t blockPage; trace_log("Erase block %d: ", block); NF_Init(); blockPage = (block << 5); NF_OE_L(); NF_DATA_OUT(); NF_CMD(NAND_CMD_ERASE1); NF_ADDR(blockPage & 0xff); NF_ADDR((blockPage >> 8) & 0xff); NF_CMD(NAND_CMD_ERASE2); if(NF_ReadStatus()) { NF_Re...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The class is removed from row at priorities marked in mask. It does nothing if mask == 0. */
static void htb_remove_class_from_row(struct htb_sched *q, struct htb_class *cl, int mask)
/* The class is removed from row at priorities marked in mask. It does nothing if mask == 0. */ static void htb_remove_class_from_row(struct htb_sched *q, struct htb_class *cl, int mask)
{ int m = 0; while (mask) { int prio = ffz(~mask); mask &= ~(1 << prio); if (q->ptr[cl->level][prio] == cl->node + prio) htb_next_rb_node(q->ptr[cl->level] + prio); htb_safe_rb_erase(cl->node + prio, q->row[cl->level] + prio); if (!q->row[cl->level][prio].rb_node) m |= 1 << prio; } q->row_mask[cl->l...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Read the bus for PHY at addr mii_id, register regnum, and return the value. Clears miimcom first. */
int fsl_pq_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
/* Read the bus for PHY at addr mii_id, register regnum, and return the value. Clears miimcom first. */ int fsl_pq_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
{ struct fsl_pq_mdio __iomem *regs = fsl_pq_mdio_get_regs(bus); return(fsl_pq_local_mdio_read(regs, mii_id, regnum)); }
robutest/uclinux
C++
GPL-2.0
60
/* Set SLCD blink mode. Set SLCD blink mode. */
enum status_code slcd_blink_set_config(struct slcd_blink_config *const blink_config)
/* Set SLCD blink mode. Set SLCD blink mode. */ enum status_code slcd_blink_set_config(struct slcd_blink_config *const blink_config)
{ if (!blink_config) { return STATUS_ERR_INVALID_ARG; } SLCD->BCFG.bit.MODE = (!(blink_config->blink_all_seg) << SLCD_BCFG_MODE_Pos); SLCD->BCFG.bit.FCS = SLCD_BCFG_FCS(blink_config->fc); return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* yaffs_put_handle Let go of a handle when closing a file or aborting an open or ending a read or write. */
static int yaffsfs_PutFileDes(int fdId)
/* yaffs_put_handle Let go of a handle when closing a file or aborting an open or ending a read or write. */ static int yaffsfs_PutFileDes(int fdId)
{ struct yaffsfs_FileDes *fd; if (fdId >= 0 && fdId < YAFFSFS_N_HANDLES) { fd = &yaffsfs_fd[fdId]; fd->handleCount--; if (fd->handleCount < 1) { if (fd->inodeId >= 0) { yaffsfs_PutInode(fd->inodeId); fd->inodeId = -1; } } } return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* set tx threshold.when TX FIFO depth <= threshold value, trigger interrupt */
void IR_SetTxThreshold(IR_TypeDef *IRx, uint8_t thd)
/* set tx threshold.when TX FIFO depth <= threshold value, trigger interrupt */ void IR_SetTxThreshold(IR_TypeDef *IRx, uint8_t thd)
{ u32 Tx_config; assert_param(IS_IR_ALL_PERIPH(IRx)); assert_param(IS_IR_RX_FIFO_THRESHOLD(thd)); Tx_config = IRx->IR_TX_CONFIG; Tx_config &= ~IR_TX_FIFO_THRESHOLD_MASK; Tx_config |= IR_TX_FIFO_THRESHOLD(thd); IRx->IR_TX_CONFIG = Tx_config; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Check if Execute Disable Bit (IA32_EFER.NXE) should be enabled or not. */
BOOLEAN IsEnableNonExecNeeded(VOID)
/* Check if Execute Disable Bit (IA32_EFER.NXE) should be enabled or not. */ BOOLEAN IsEnableNonExecNeeded(VOID)
{ if (!IsExecuteDisableBitAvailable ()) { return FALSE; } return (PcdGetBool (PcdSetNxForStack) || PcdGet64 (PcdDxeNxMemoryProtectionPolicy) != 0 || PcdGet32 (PcdImageProtectionPolicy) != 0); }
tianocore/edk2
C++
Other
4,240
/* tlsv1_server_deinit - Deinitialize TLSv1 server connection @conn: TLSv1 server connection data from tlsv1_server_init() */
void tlsv1_server_deinit(struct tlsv1_server *conn)
/* tlsv1_server_deinit - Deinitialize TLSv1 server connection @conn: TLSv1 server connection data from tlsv1_server_init() */ void tlsv1_server_deinit(struct tlsv1_server *conn)
{ tlsv1_server_clear_data(conn); os_free(conn); }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* Returns CR_OK upon successfull completion, an error code otherwise. */
enum CRStatus cr_statement_ruleset_get_sel_list(CRStatement *a_this, CRSelector **a_list)
/* Returns CR_OK upon successfull completion, an error code otherwise. */ enum CRStatus cr_statement_ruleset_get_sel_list(CRStatement *a_this, CRSelector **a_list)
{ g_return_val_if_fail (a_this && a_this->type == RULESET_STMT && a_this->kind.ruleset, CR_BAD_PARAM_ERROR); *a_list = a_this->kind.ruleset->sel_list; return CR_OK; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* drbd_al_apply_to_bm() - Sets the bitmap to diry(1) where covered ba active AL extents @mdev: DRBD device. */
void drbd_al_apply_to_bm(struct drbd_conf *mdev)
/* drbd_al_apply_to_bm() - Sets the bitmap to diry(1) where covered ba active AL extents @mdev: DRBD device. */ void drbd_al_apply_to_bm(struct drbd_conf *mdev)
{ unsigned int enr; unsigned long add = 0; char ppb[10]; int i; wait_event(mdev->al_wait, lc_try_lock(mdev->act_log)); for (i = 0; i < mdev->act_log->nr_elements; i++) { enr = lc_element_by_index(mdev->act_log, i)->lc_number; if (enr == LC_FREE) continue; add += drbd_bm_ALe_set_all(mdev, enr); } lc_unl...
robutest/uclinux
C++
GPL-2.0
60
/* 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 Value is larger than the bitmask value range specified by StartBit and ...
UINT16 EFIAPI PciBitFieldWrite16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 Value)
/* 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 Value is larger than the bitmask value range specified by StartBit and ...
{ return mRunningOnQ35 ? PciExpressBitFieldWrite16 (Address, StartBit, EndBit, Value) : PciCf8BitFieldWrite16 (Address, StartBit, EndBit, Value); }
tianocore/edk2
C++
Other
4,240
/* This function should be used by panic code. It stops ftrace but in a not so nice way. If you need to simply kill ftrace from a non-atomic section, use ftrace_kill. */
void ftrace_kill(void)
/* This function should be used by panic code. It stops ftrace but in a not so nice way. If you need to simply kill ftrace from a non-atomic section, use ftrace_kill. */ void ftrace_kill(void)
{ ftrace_disabled = 1; ftrace_enabled = 0; clear_ftrace_function(); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* EVFP exchange complete and VFT tagging is enabled. */
static void bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s *fabric, enum bfa_fcs_fabric_event event)
/* EVFP exchange complete and VFT tagging is enabled. */ static void bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s *fabric, enum bfa_fcs_fabric_event event)
{ bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); bfa_trc(fabric->fcs, event); }
robutest/uclinux
C++
GPL-2.0
60
/* Normally the volumes are freed at the release function of the volume device objects. However, on error paths the volumes have to be freed before the device objects have been initialized. */
static void free_user_volumes(struct ubi_device *ubi)
/* Normally the volumes are freed at the release function of the volume device objects. However, on error paths the volumes have to be freed before the device objects have been initialized. */ static void free_user_volumes(struct ubi_device *ubi)
{ int i; for (i = 0; i < ubi->vtbl_slots; i++) if (ubi->volumes[i]) { kfree(ubi->volumes[i]->eba_tbl); kfree(ubi->volumes[i]); } }
robutest/uclinux
C++
GPL-2.0
60
/* This function returns the CA certificate for the chosen TLS connection. */
EFI_STATUS EFIAPI CryptoServiceTlsGetCaCertificate(IN VOID *Tls, OUT VOID *Data, IN OUT UINTN *DataSize)
/* This function returns the CA certificate for the chosen TLS connection. */ EFI_STATUS EFIAPI CryptoServiceTlsGetCaCertificate(IN VOID *Tls, OUT VOID *Data, IN OUT UINTN *DataSize)
{ return CALL_BASECRYPTLIB (TlsGet.Services.CaCertificate, TlsGetCaCertificate, (Tls, Data, DataSize), EFI_UNSUPPORTED); }
tianocore/edk2
C++
Other
4,240
/* qentry_destroy(): Free all the memory allocated by a QDictEntry */
static void qentry_destroy(QDictEntry *e)
/* qentry_destroy(): Free all the memory allocated by a QDictEntry */ static void qentry_destroy(QDictEntry *e)
{ assert(e != NULL); assert(e->key != NULL); assert(e->value != NULL); qobject_decref(e->value); g_free(e->key); g_free(e); }
ve3wwg/teensy3_qemu
C++
Other
15
/* USBH_LL_Stop Stop the Low Level portion of the Host driver. */
USBH_StatusTypeDef USBH_LL_Stop(USBH_HandleTypeDef *phost)
/* USBH_LL_Stop Stop the Low Level portion of the Host driver. */ USBH_StatusTypeDef USBH_LL_Stop(USBH_HandleTypeDef *phost)
{ UNUSED(phost); return USBH_OK; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Indicate a busy-waiting vcpu in spinlock. We do not enable the PAUSE exiting, so only get here on cpu with PAUSE-Loop-Exiting. */
static int handle_pause(struct kvm_vcpu *vcpu)
/* Indicate a busy-waiting vcpu in spinlock. We do not enable the PAUSE exiting, so only get here on cpu with PAUSE-Loop-Exiting. */ static int handle_pause(struct kvm_vcpu *vcpu)
{ skip_emulated_instruction(vcpu); kvm_vcpu_on_spin(vcpu); return 1; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* fnic_update_mac() - set data MAC address and filters. @lport: local port. @new: newly-assigned FCoE MAC address. */
void fnic_update_mac(struct fc_lport *lport, u8 *new)
/* fnic_update_mac() - set data MAC address and filters. @lport: local port. @new: newly-assigned FCoE MAC address. */ void fnic_update_mac(struct fc_lport *lport, u8 *new)
{ struct fnic *fnic = lport_priv(lport); spin_lock_irq(&fnic->fnic_lock); fnic_update_mac_locked(fnic, new); spin_unlock_irq(&fnic->fnic_lock); }
robutest/uclinux
C++
GPL-2.0
60
/* 'mxmlSetUserData()' - Set the user data pointer for a node. */
int mxmlSetUserData(mxml_node_t *node, void *data)
/* 'mxmlSetUserData()' - Set the user data pointer for a node. */ int mxmlSetUserData(mxml_node_t *node, void *data)
{ if (!node) return (-1); node->user_data = data; return (0); }
DC-SWAT/DreamShell
C++
null
404
/* timer_interrupt - gets called when the decrementer overflows, with interrupts disabled. Trivial implementation - no need to be really accurate. */
void timer_interrupt_cpu(struct pt_regs *regs)
/* timer_interrupt - gets called when the decrementer overflows, with interrupts disabled. Trivial implementation - no need to be really accurate. */ void timer_interrupt_cpu(struct pt_regs *regs)
{ immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR; out_be32(&immr->im_clkrstk.cark_plprcrk, KAPWR_KEY); __asm__ ("nop"); setbits_be32(&immr->im_clkrst.car_plprcr, 0); }
4ms/stm32mp1-baremetal
C++
Other
137
/* ixgbe_standby_eeprom - Returns EEPROM to a "standby" state @hw: pointer to hardware structure */
static void ixgbe_standby_eeprom(struct ixgbe_hw *hw)
/* ixgbe_standby_eeprom - Returns EEPROM to a "standby" state @hw: pointer to hardware structure */ static void ixgbe_standby_eeprom(struct ixgbe_hw *hw)
{ u32 eec; eec = IXGBE_READ_REG(hw, IXGBE_EEC); eec |= IXGBE_EEC_CS; IXGBE_WRITE_REG(hw, IXGBE_EEC, eec); IXGBE_WRITE_FLUSH(hw); udelay(1); eec &= ~IXGBE_EEC_CS; IXGBE_WRITE_REG(hw, IXGBE_EEC, eec); IXGBE_WRITE_FLUSH(hw); udelay(1); }
robutest/uclinux
C++
GPL-2.0
60
/* This function returns %0 on success and a negative error code on failure. */
int ubifs_lpt_init(struct ubifs_info *c, int rd, int wr)
/* This function returns %0 on success and a negative error code on failure. */ int ubifs_lpt_init(struct ubifs_info *c, int rd, int wr)
{ int err; if (rd) { err = lpt_init_rd(c); if (err) return err; } if (wr) { err = lpt_init_wr(c); if (err) return err; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Register the Flash platform device with the kernel. */
void __init lpc178x_flash_init(void)
/* Register the Flash platform device with the kernel. */ void __init lpc178x_flash_init(void)
{ unsigned int size = 0; switch (lpc178x_platform_get()) { case PLATFORM_LPC178X_EA_LPC1788: size = 4*1024*1024; break; case PLATFORM_LPC178X_LNX_EVB: size = 16*1024*1024; break; default: printk(KERN_ERR "%s: Unknown platform %#x, exit\n", __func__, lpc178x_platform_get()); goto xit; } flash_resou...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Constructor register notification on when PPI updates. If PPI is alreay installed registering the notify will cause the handle to run. */
EFI_STATUS EFIAPI PeiServicesTablePointerLibConstructor(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
/* Constructor register notification on when PPI updates. If PPI is alreay installed registering the notify will cause the handle to run. */ EFI_STATUS EFIAPI PeiServicesTablePointerLibConstructor(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
{ EFI_STATUS Status; gPeiServices = (CONST EFI_PEI_SERVICES **)PeiServices; Status = (*PeiServices)->NotifyPpi (PeiServices, &mNotifyOnThunkList); ASSERT_EFI_ERROR (Status); return Status; }
tianocore/edk2
C++
Other
4,240
/* Cache MODE and HIEN register values to avoid having to read it before modifying register bits. */
static int max3421e_mode_setup(const struct device *dev)
/* Cache MODE and HIEN register values to avoid having to read it before modifying register bits. */ static int max3421e_mode_setup(const struct device *dev)
{ const uint8_t mode = MAX3421E_DPPULLDN | MAX3421E_DMPULLDN | MAX3421E_DELAYISO | MAX3421E_HOST; struct max3421e_data *priv = uhc_get_private(dev); uint8_t tmp; int ret; ret = max3421e_write_byte(dev, MAX3421E_REG_MODE, mode); if (ret) { return ret; } ret = max3421e_read(dev, MAX3421E_REG_MODE, &tmp,...
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* b Request Secondary PDP Context Activation Reject Direction: MS to network */
static void dtap_sm_req_sec_pdp_act_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
/* b Request Secondary PDP Context Activation Reject Direction: MS to network */ static void dtap_sm_req_sec_pdp_act_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
{ guint32 curr_offset; guint32 consumed; guint curr_len; curr_offset = offset; curr_len = len; pinfo->p2p_dir = P2P_DIR_UNKNOWN; pinfo->link_dir = P2P_DIR_UL; ELEM_MAND_V( GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL); ELEM_OPT_TLV( 0x27, GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT, NULL); ELEM_OPT_TLV(0x33, GSM_A_PDU_TYPE...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Attribute read call back for the Descriptor V8D1 attribute. */
static ssize_t read_des_v8d1(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
/* Attribute read call back for the Descriptor V8D1 attribute. */ static ssize_t read_des_v8d1(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
{ const uint8_t *value = attr->user_data; return bt_gatt_attr_read(conn, attr, buf, len, offset, value, sizeof(des_v8d1_value)); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* An error must be cleared or acked to take a FS out of readonly mode. */
void jbd2_journal_ack_err(journal_t *journal)
/* An error must be cleared or acked to take a FS out of readonly mode. */ void jbd2_journal_ack_err(journal_t *journal)
{ spin_lock(&journal->j_state_lock); if (journal->j_errno) journal->j_flags |= JBD2_ACK_ERR; spin_unlock(&journal->j_state_lock); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns -1 in case of error, file descriptor on success */
int inet_connect(const char *str, Error **errp)
/* Returns -1 in case of error, file descriptor on success */ int inet_connect(const char *str, Error **errp)
{ QemuOpts *opts; int sock = -1; InetSocketAddress *addr; addr = inet_parse(str, errp); if (addr != NULL) { opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); inet_addr_to_opts(opts, addr); qapi_free_InetSocketAddress(addr); sock = inet_connect_opts(opt...
ve3wwg/teensy3_qemu
C++
Other
15
/* All the journal write operations like 'ubifs_jnl_update()' here, which write multiple UBIFS nodes to the journal at one go, are atomic with respect to unclean reboots. Should the unclean reboot happen, the recovery code drops all the nodes. zero_ino_node_unused - zero out unused fields of an on-flash inode node. @in...
static void zero_ino_node_unused(struct ubifs_ino_node *ino)
/* All the journal write operations like 'ubifs_jnl_update()' here, which write multiple UBIFS nodes to the journal at one go, are atomic with respect to unclean reboots. Should the unclean reboot happen, the recovery code drops all the nodes. zero_ino_node_unused - zero out unused fields of an on-flash inode node. @in...
{ memset(ino->padding1, 0, 4); memset(ino->padding2, 0, 26); }
robutest/uclinux
C++
GPL-2.0
60
/* This API is used to parse and store the skipped_frame_count from the FIFO data in the structure instance dev. */
static void unpack_skipped_frame(uint16_t *data_index, const struct bma4_dev *dev)
/* This API is used to parse and store the skipped_frame_count from the FIFO data in the structure instance dev. */ static void unpack_skipped_frame(uint16_t *data_index, const struct bma4_dev *dev)
{ if (*data_index >= dev->fifo->length) { *data_index = dev->fifo->length; } else { dev->fifo->skipped_frame_count = dev->fifo->data[*data_index]; *data_index = (*data_index) + 1; } }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* relay_file_read_subbuf_avail - return bytes available in sub-buffer @read_pos: file read position @buf: relay channel buffer */
static size_t relay_file_read_subbuf_avail(size_t read_pos, struct rchan_buf *buf)
/* relay_file_read_subbuf_avail - return bytes available in sub-buffer @read_pos: file read position @buf: relay channel buffer */ static size_t relay_file_read_subbuf_avail(size_t read_pos, struct rchan_buf *buf)
{ size_t padding, avail = 0; size_t read_subbuf, read_offset, write_subbuf, write_offset; size_t subbuf_size = buf->chan->subbuf_size; write_subbuf = (buf->data - buf->start) / subbuf_size; write_offset = buf->offset > subbuf_size ? subbuf_size : buf->offset; read_subbuf = read_pos / subbuf_size; read_offset = r...
EmcraftSystems/linux-emcraft
C++
Other
266
/* The following functions are defined for gen2 (deviceid : 0x78 0x79) controllers megasas_enable_intr_gen2 - Enables interrupts @regs: MFI register set */
static void megasas_enable_intr_gen2(struct megasas_register_set __iomem *regs)
/* The following functions are defined for gen2 (deviceid : 0x78 0x79) controllers megasas_enable_intr_gen2 - Enables interrupts @regs: MFI register set */ static void megasas_enable_intr_gen2(struct megasas_register_set __iomem *regs)
{ writel(0xFFFFFFFF, &(regs)->outbound_doorbell_clear); writel(~MFI_GEN2_ENABLE_INTERRUPT_MASK, &(regs)->outbound_intr_mask); readl(&regs->outbound_intr_mask); }
robutest/uclinux
C++
GPL-2.0
60
/* flush_icache_range() can't be used here. we are here before cpu_init() which initializes ia64_i_cache_stride_shift. flush_icache_range() uses it. */
void __init_or_module paravirt_flush_i_cache_range(const void *instr, unsigned long size)
/* flush_icache_range() can't be used here. we are here before cpu_init() which initializes ia64_i_cache_stride_shift. flush_icache_range() uses it. */ void __init_or_module paravirt_flush_i_cache_range(const void *instr, unsigned long size)
{ extern void paravirt_fc_i(const void *addr); unsigned long i; for (i = 0; i < size; i += sizeof(bundle_t)) paravirt_fc_i(instr + i); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns the link containing the data or NULL */
static xmlLinkPtr xmlListLowerSearch(xmlListPtr l, void *data)
/* Returns the link containing the data or NULL */ static xmlLinkPtr xmlListLowerSearch(xmlListPtr l, void *data)
{ xmlLinkPtr lk; if (l == NULL) return(NULL); for(lk = l->sentinel->next;lk != l->sentinel && l->linkCompare(lk->data, data) <0 ;lk = lk->next); return lk; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* When a reset is required due to an internal error, the driver notifies the upper layer software of this need through the ErrorHandler callback and specific status codes. The upper layer software is responsible for calling this Reset function and then re-configuring the device. */
void XEmac_Reset(XEmac *InstancePtr)
/* When a reset is required due to an internal error, the driver notifies the upper layer software of this need through the ErrorHandler callback and specific status codes. The upper layer software is responsible for calling this Reset function and then re-configuring the device. */ void XEmac_Reset(XEmac *InstancePtr)
{ XASSERT_VOID(InstancePtr != NULL); XASSERT_VOID(InstancePtr->IsReady == XCOMPONENT_IS_READY); (void) XEmac_Stop(InstancePtr); InstancePtr->IsPolled = FALSE; XIIF_V123B_RESET(InstancePtr->BaseAddress); if (XEmac_mIsSgDma(InstancePtr)) { (void) XEmac_SetPktThreshold(InstancePtr, XEM_SEND, XEM_SGDMA_DF...
EmcraftSystems/u-boot
C++
Other
181
/* Insert a variable in the list of to-be-closed variables. */
void luaF_newtbcupval(lua_State *L, StkId level)
/* Insert a variable in the list of to-be-closed variables. */ void luaF_newtbcupval(lua_State *L, StkId level)
{ L->tbclist += MAXDELTA; L->tbclist->tbclist.delta = 0; } level->tbclist.delta = cast(unsigned short, level - L->tbclist); L->tbclist = level; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Disable the SPI interrupt of the specified SPI port. */
void SPIIntDisable(unsigned long ulBase, unsigned long ulIntFlags)
/* Disable the SPI interrupt of the specified SPI port. */ void SPIIntDisable(unsigned long ulBase, unsigned long ulIntFlags)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE)||(ulBase == SPI3_BASE) ); if(ulIntFlags & SPI_CNTRL_IE) { xHWREG(ulBase + SPI_CNTRL) &= ~SPI_CNTRL_IE; } if(ulIntFlags & SPI_CNTRL2_SSTA_INTEN) { xHWREG(ulBase + SPI_CNTRL2) &= ~SPI_CNTRL2_SSTA...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Magnetometer X-axis coordinates rotation (to be aligned to accelerometer/gyroscope axes orientation).. */
int32_t lsm6dso_mag_x_orient_set(stmdev_ctx_t *ctx, lsm6dso_mag_x_axis_t val)
/* Magnetometer X-axis coordinates rotation (to be aligned to accelerometer/gyroscope axes orientation).. */ int32_t lsm6dso_mag_x_orient_set(stmdev_ctx_t *ctx, lsm6dso_mag_x_axis_t val)
{ lsm6dso_mag_cfg_b_t reg; int32_t ret; ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_CFG_B, (uint8_t *)&reg); if (ret == 0) { reg.mag_x_axis = (uint8_t)val; ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_CFG_B, (uint8_t *)&reg); } ...
eclipse-threadx/getting-started
C++
Other
310
/* Get the Option Number for Driver#### that does not used. */
UINT16 BOpt_GetDriverOptionNumber(VOID)
/* Get the Option Number for Driver#### that does not used. */ UINT16 BOpt_GetDriverOptionNumber(VOID)
{ return BOpt_GetOptionNumber (L"Driver"); }
tianocore/edk2
C++
Other
4,240
/* More complex function where we determine which varible is being accessed by looking at the attribute for the "baz" and "bar" files. */
static ssize_t b_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
/* More complex function where we determine which varible is being accessed by looking at the attribute for the "baz" and "bar" files. */ static ssize_t b_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{ int var; if (strcmp(attr->attr.name, "baz") == 0) var = baz; else var = bar; return sprintf(buf, "%d\n", var); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns: a newly allocated string with the escaped text */
gchar* g_markup_escape_text(const gchar *text, gssize length)
/* Returns: a newly allocated string with the escaped text */ gchar* g_markup_escape_text(const gchar *text, gssize length)
{ GString *str; g_return_val_if_fail (text != NULL, NULL); if (length < 0) length = strlen (text); str = g_string_sized_new (length); append_escaped_text (str, text, length); return g_string_free (str, FALSE); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* flush all members of flush->mc_list from device dev->mc_list */
static void bond_mc_list_flush(struct net_device *bond_dev, struct net_device *slave_dev)
/* flush all members of flush->mc_list from device dev->mc_list */ static void bond_mc_list_flush(struct net_device *bond_dev, struct net_device *slave_dev)
{ struct bonding *bond = netdev_priv(bond_dev); struct dev_mc_list *dmi; for (dmi = bond_dev->mc_list; dmi; dmi = dmi->next) dev_mc_delete(slave_dev, dmi->dmi_addr, dmi->dmi_addrlen, 0); if (bond->params.mode == BOND_MODE_8023AD) { u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR; dev_mc_delete(slave_dev...
robutest/uclinux
C++
GPL-2.0
60
/* this kills every thread in the thread group. Note that any externally wait4()-ing process will get the correct exit code - even if this thread is not the thread group leader. */
SYSCALL_DEFINE1(exit_group, int, error_code)
/* this kills every thread in the thread group. Note that any externally wait4()-ing process will get the correct exit code - even if this thread is not the thread group leader. */ SYSCALL_DEFINE1(exit_group, int, error_code)
{ do_group_exit((error_code & 0xff) << 8); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Deinitializes the BAKPR peripheral registers to their default reset values. */
void BAKPR_ConfigTamperPinLevel(BAKPR_TAMPER_PIN_LEVEL_T value)
/* Deinitializes the BAKPR peripheral registers to their default reset values. */ void BAKPR_ConfigTamperPinLevel(BAKPR_TAMPER_PIN_LEVEL_T value)
{ BAKPR->CTRL_B.TPALCFG = value; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Polls the status of the Write In Progress (WIP) flag in the FLASH's status register and loop until write opertaion has completed. */
void sFLASH_WaitForWriteEnd(void)
/* Polls the status of the Write In Progress (WIP) flag in the FLASH's status register and loop until write opertaion has completed. */ void sFLASH_WaitForWriteEnd(void)
{ uint8_t flashstatus = 0; sFLASH_CS_LOW(); sFLASH_SendByte(sFLASH_CMD_RDSR); do { flashstatus = sFLASH_SendByte(sFLASH_DUMMY_BYTE); } while ((flashstatus & sFLASH_WIP_FLAG) == SET); sFLASH_CS_HIGH(); }
avem-labs/Avem
C++
MIT License
1,752
/* Set the Timer to Generate Update IRQ or DMA only from Under/Overflow Events. */
void timer_update_on_overflow(uint32_t timer_peripheral)
/* Set the Timer to Generate Update IRQ or DMA only from Under/Overflow Events. */ void timer_update_on_overflow(uint32_t timer_peripheral)
{ TIM_CR1(timer_peripheral) |= TIM_CR1_URS; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Given an ARP header type return the corresponding ethernet protocol. */
static __be16 llc_proto_type(u16 arphrd)
/* Given an ARP header type return the corresponding ethernet protocol. */ static __be16 llc_proto_type(u16 arphrd)
{ return arphrd == ARPHRD_IEEE802_TR ? htons(ETH_P_TR_802_2) : htons(ETH_P_802_2); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* wccp_bucket_info() takes an integer representing a "Hash Information" bitmap, and spits out the corresponding proto_tree entries, returning the next bucket number. */
static int wccp_bucket_info(guint8 bucket_info, proto_tree *bucket_tree, guint32 start, tvbuff_t *tvb, int offset)
/* wccp_bucket_info() takes an integer representing a "Hash Information" bitmap, and spits out the corresponding proto_tree entries, returning the next bucket number. */ static int wccp_bucket_info(guint8 bucket_info, proto_tree *bucket_tree, guint32 start, tvbuff_t *tvb, int offset)
{ guint32 i; for(i = 0; i < 8; i++) { proto_tree_add_uint_format(bucket_tree, hf_bucket_bit, tvb, offset, 1, bucket_info & 1<<i, "Bucket %3d: %s", start, (bucket_info & 1<<i ? "Assigned" : "Not Assigned") ); start++; } return(start); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function reads the value of the calibration enables from the Configuration Register 1. */
u16 XAdcPs_GetCalibEnables(XAdcPs *InstancePtr)
/* This function reads the value of the calibration enables from the Configuration Register 1. */ u16 XAdcPs_GetCalibEnables(XAdcPs *InstancePtr)
{ Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); return (u16) XAdcPs_ReadInternalReg(InstancePtr, XADCPS_CFR1_OFFSET) & XADCPS_CFR1_CAL_VALID_MASK; }
ua1arn/hftrx
C++
null
69
/* I/O work flow to wait input buffer empty in given time. */
EFI_STATUS WaitInputEmpty(IN UINTN Timeout)
/* I/O work flow to wait input buffer empty in given time. */ EFI_STATUS WaitInputEmpty(IN UINTN Timeout)
{ UINTN Delay; UINT8 Data; Delay = Timeout / 50; do { Data = IoRead8 (KBC_CMD_STS_PORT); if ((Data & KBC_INPB) == 0) { break; } gBS->Stall (50); Delay--; } while (Delay != 0); if (Delay == 0) { return EFI_TIMEOUT; } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Checks whether the specified I2C flag is set or not. */
uint8_t I2C_ReadStatusFlag(I2C_T *i2c, I2C_FLAG_T flag)
/* Checks whether the specified I2C flag is set or not. */ uint8_t I2C_ReadStatusFlag(I2C_T *i2c, I2C_FLAG_T flag)
{ uint32_t status = 0; status = (uint32_t)(i2c->STS & (flag)); if (status == flag ) { return SET; } return RESET; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Bit 0 = Data out (read from EEPROM) Bit 1 = Data in (write to EEPROM) Bit 2 = Clock Bit 3 = Chip Select Bit 7 = ~50 kHz clock for defined delays */
static void __init dlink_put_eeprom(unsigned char value, unsigned int addr)
/* Bit 0 = Data out (read from EEPROM) Bit 1 = Data in (write to EEPROM) Bit 2 = Clock Bit 3 = Chip Select Bit 7 = ~50 kHz clock for defined delays */ static void __init dlink_put_eeprom(unsigned char value, unsigned int addr)
{ int z; unsigned char v1, v2; outb(value, addr + 0x1e); for (z = 0; z < 2; z++) { do { v1 = inb(addr + 0x1e); v2 = inb(addr + 0x1e); } while (!((v1 ^ v2) & 0x80)); } }
robutest/uclinux
C++
GPL-2.0
60
/* Initialize the SLCD Glass component. This function initializes the LCD driver to control the LCD glass. It perform LCD module initialization according to the XPRO_LCD characteristics. */
status_code_genare_t xpro_lcd_init(void)
/* Initialize the SLCD Glass component. This function initializes the LCD driver to control the LCD glass. It perform LCD module initialization according to the XPRO_LCD characteristics. */ status_code_genare_t xpro_lcd_init(void)
{ struct slcd_config config; slcd_get_config_defaults(&config); config.waveform_mode = SLCD_STANDARD_WAVEFORM_MODE; slcd_init(&config); slcd_set_frame_counter(SLCD_FRAME_COUNTER_0, false, FRAME_COUNT_OVERFLOW); slcd_set_frame_counter(SLCD_FRAME_COUNTER_1, false, FRAME_COUNT_OVERFLOW); slcd_set_frame_counter(SLCD...
memfault/zero-to-main
C++
null
200
/* Add sysfs entries to ethernet device added to a bridge. Creates a brport subdirectory with bridge attributes. Puts symlink in bridge's brport subdirectory */
int br_sysfs_addif(struct net_bridge_port *p)
/* Add sysfs entries to ethernet device added to a bridge. Creates a brport subdirectory with bridge attributes. Puts symlink in bridge's brport subdirectory */ int br_sysfs_addif(struct net_bridge_port *p)
{ struct net_bridge *br = p->br; struct brport_attribute **a; int err; err = sysfs_create_link(&p->kobj, &br->dev->dev.kobj, SYSFS_BRIDGE_PORT_LINK); if (err) goto out2; for (a = brport_attrs; *a; ++a) { err = sysfs_create_file(&p->kobj, &((*a)->attr)); if (err) goto out2; } err = sysfs_create_link...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Wait end of transfer and check if received Data are well. */
void WaitAndCheckEndOfTransfer(void)
/* Wait end of transfer and check if received Data are well. */ void WaitAndCheckEndOfTransfer(void)
{ while (ubTransmitIndex != ubNbDataToTransmit) { } LL_SPI_DisableIT_TXE(SPI1); while (ubNbDataToReceive > ubReceiveIndex) { } LL_SPI_DisableIT_RXNE(SPI2); if(Buffercmp8((uint8_t*)aTxBuffer, (uint8_t*)aRxBuffer, ubNbDataToTransmit)) { LED_Blinking(LED_BLINK_ERROR); } else { LED_On(); ...
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Selects the initial output level. Only used in counter and PWM modes. */
void timer_output_level(uint32_t timer, enum timer_level level)
/* Selects the initial output level. Only used in counter and PWM modes. */ void timer_output_level(uint32_t timer, enum timer_level level)
{ TIMER_OUTPVAL(timer) = level; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Check device number to be within valid range for given device type. */
int mtd_device_validate(u8 type, u8 num, u32 *size)
/* Check device number to be within valid range for given device type. */ int mtd_device_validate(u8 type, u8 num, u32 *size)
{ struct mtd_info *mtd; char mtd_dev[16]; sprintf(mtd_dev, "%s%d", MTD_DEV_TYPE(type), num); mtd = get_mtd_device_nm(mtd_dev); if (IS_ERR(mtd)) { printf("Device %s not found!\n", mtd_dev); return 1; } *size = mtd->size; return 0; }
EmcraftSystems/u-boot
C++
Other
181
/* @obj: EFI object loaded image @pc: program counter (use NULL to suppress offset output) Return: status code */
static efi_status_t efi_print_image_info(struct efi_loaded_image_obj *obj, struct efi_loaded_image *image, void *pc)
/* @obj: EFI object loaded image @pc: program counter (use NULL to suppress offset output) Return: status code */ static efi_status_t efi_print_image_info(struct efi_loaded_image_obj *obj, struct efi_loaded_image *image, void *pc)
{ printf("UEFI image"); printf(" [0x%p:0x%p]", image->image_base, image->image_base + image->image_size - 1); if (pc && pc >= image->image_base && pc < image->image_base + image->image_size) printf(" pc=0x%zx", pc - image->image_base); if (image->file_path) printf(" '%pD'", image->file_path); prin...
4ms/stm32mp1-baremetal
C++
Other
137
/* Registers a callback. Registers a callback function which is implemented by the user. */
void pdm_register_callback(struct pdm_instance *const dev_inst, pdm_callback_t callback, enum pdm_callback_type type)
/* Registers a callback. Registers a callback function which is implemented by the user. */ void pdm_register_callback(struct pdm_instance *const dev_inst, pdm_callback_t callback, enum pdm_callback_type type)
{ Assert(dev_inst); Assert(callback); if (type < PDM_CALLBACK_N) { dev_inst->callbacks[type] = callback; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Returns copy of whole control register region Note: skip RAM address register because accessing it will cause bus hangs! */
static void skge_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
/* Returns copy of whole control register region Note: skip RAM address register because accessing it will cause bus hangs! */ static void skge_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
{ const struct skge_port *skge = netdev_priv(dev); const void __iomem *io = skge->hw->regs; regs->version = 1; memset(p, 0, regs->len); memcpy_fromio(p, io, B3_RAM_ADDR); memcpy_fromio(p + B3_RI_WTO_R1, io + B3_RI_WTO_R1, regs->len - B3_RI_WTO_R1); }
robutest/uclinux
C++
GPL-2.0
60
/* Retrieve the amount of cycles to delay for the given amount of us. */
uint32_t _get_cycles_for_us(const uint16_t us)
/* Retrieve the amount of cycles to delay for the given amount of us. */ uint32_t _get_cycles_for_us(const uint16_t us)
{ return _get_cycles_for_us_internal(us, CONF_HCLK_FREQUENCY, HCLK_FREQ_POWER); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* checks whether short string exists and reuses it or creates a new one */
static TString* internshrstr(lua_State *L, const char *str, size_t l)
/* checks whether short string exists and reuses it or creates a new one */ static TString* internshrstr(lua_State *L, const char *str, size_t l)
{ TString *ts = rawgco2ts(o); if (h == ts->tsv.hash && l == ts->tsv.len && (memcmp(str, getstr(ts), l * sizeof(char)) == 0)) { if (isdead(G(L), o)) changewhite(o); return ts; } } return newshrstr(L, str, l, h); }
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* The ->count variable represents how many more tasks can acquire this semaphore. If it's zero, there may be tasks waiting on the wait_list. */
static noinline void __sched __down(struct semaphore *sem)
/* The ->count variable represents how many more tasks can acquire this semaphore. If it's zero, there may be tasks waiting on the wait_list. */ static noinline void __sched __down(struct semaphore *sem)
{ __down_common(sem, TASK_UNINTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Deinitializes OPA peripheral registers to their default reset values. */
void OPA_DeInit(OPA_TypeDef *OPAx)
/* Deinitializes OPA peripheral registers to their default reset values. */ void OPA_DeInit(OPA_TypeDef *OPAx)
{ assert_param(IS_OPA_ALL_PERIPH(OPAx)); OPAx->CR = ((uint32_t)0x00000000); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* receive callback during tftp read operation (not on standard port 69) */
void rrq_recv_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
/* receive callback during tftp read operation (not on standard port 69) */ void rrq_recv_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
{ tftp_connection_args *args = (tftp_connection_args *)arg; if (tftp_is_correct_ack(p->payload, args->block)) { args->block++; } else { } if (args->data_len < TFTP_DATA_LEN_MAX) { tftp_cleanup_rd(upcb, args); pbuf_free(p); } tftp_send_next_block(upcb, args, addr, port); pbuf_free(p);...
STMicroelectronics/STM32CubeF4
C++
Other
789
/* param base The I2C peripheral base address. param timeout_Ms Timeout value in millisecond. param srcClock_Hz I2C functional clock frequency in Hertz. */
void I2C_MasterSetTimeoutValue(I2C_Type *base, uint8_t timeout_Ms, uint32_t srcClock_Hz)
/* param base The I2C peripheral base address. param timeout_Ms Timeout value in millisecond. param srcClock_Hz I2C functional clock frequency in Hertz. */ void I2C_MasterSetTimeoutValue(I2C_Type *base, uint8_t timeout_Ms, uint32_t srcClock_Hz)
{ assert((timeout_Ms != 0U) && (srcClock_Hz != 0U)); uint32_t timeoutValue = ((uint32_t)timeout_Ms * srcClock_Hz / 16UL / 100UL + 5UL) / 10UL; if (timeoutValue > 0x1000UL) { timeoutValue = 0x1000UL; } timeoutValue = ((timeoutValue - 1UL) << 4UL) | 0xFUL; base->TIMEOUT = timeoutValue...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* During initialisation, we need to reset the analog switch. We also preset the switch to map the 4 connectors on the card to the */
static void kodicom4400r_init(struct bttv *btv)
/* During initialisation, we need to reset the analog switch. We also preset the switch to map the 4 connectors on the card to the */ static void kodicom4400r_init(struct bttv *btv)
{ char *sw_status = (char *)(&btv->mbox_we); int ix; gpio_inout(0x0003ff, 0x0003ff); gpio_write(1 << 9); gpio_write(0); for (ix = 0; ix < 4; ix++) { sw_status[ix] = ix; kodicom4400r_write(btv, ix, ix, 1); } if ((btv->c.nr<1) || (btv->c.nr>BTTV_MAX-3)) return; master[btv->c.nr-1] = btv; master[btv->c....
robutest/uclinux
C++
GPL-2.0
60
/* Default handling if a filesystem does not provide a migration function. */
static int fallback_migrate_page(struct address_space *mapping, struct page *newpage, struct page *page)
/* Default handling if a filesystem does not provide a migration function. */ static int fallback_migrate_page(struct address_space *mapping, struct page *newpage, struct page *page)
{ if (PageDirty(page)) return writeout(mapping, page); if (page_has_private(page) && !try_to_release_page(page, GFP_KERNEL)) return -EAGAIN; return migrate_page(mapping, newpage, page); }
robutest/uclinux
C++
GPL-2.0
60
/* See the vsnprintf() documentation for format string extensions over C99. */
int sprintf(char *buf, const char *fmt,...)
/* See the vsnprintf() documentation for format string extensions over C99. */ int sprintf(char *buf, const char *fmt,...)
{ va_list args; int i; va_start(args, fmt); i = vsnprintf(buf, INT_MAX, fmt, args); va_end(args); return i; }
robutest/uclinux
C++
GPL-2.0
60
/* Append key point of a given address to Buffer if buffer is NULL, only count needed count */
VOID AppendKeyPointToBuffer(IN OUT UINT64 *Buffer, IN OUT UINTN *Count, IN UINT64 Address)
/* Append key point of a given address to Buffer if buffer is NULL, only count needed count */ VOID AppendKeyPointToBuffer(IN OUT UINT64 *Buffer, IN OUT UINTN *Count, IN UINT64 Address)
{ if ( Buffer != NULL) { Buffer[*Count] = Address; (*Count)++; Buffer[*Count] = Address+1; (*Count)++; Buffer[*Count] = Address-1; (*Count)++; } else { (*Count) = (*Count) +3; } }
tianocore/edk2
C++
Other
4,240
/* external IRQs operations: mask/unmask and clear on PERF external irq control register. */
static void bcm63xx_external_irq_mask(unsigned int irq)
/* external IRQs operations: mask/unmask and clear on PERF external irq control register. */ static void bcm63xx_external_irq_mask(unsigned int irq)
{ u32 reg; irq -= IRQ_EXT_BASE; reg = bcm_perf_readl(PERF_EXTIRQ_CFG_REG); reg &= ~EXTIRQ_CFG_MASK(irq); bcm_perf_writel(reg, PERF_EXTIRQ_CFG_REG); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* basic flash write, only used with offset aligned to flash write block size */
static int eeprom_emu_flash_write(const struct device *dev, off_t offset, const uint8_t *blk, size_t len)
/* basic flash write, only used with offset aligned to flash write block size */ static int eeprom_emu_flash_write(const struct device *dev, off_t offset, const uint8_t *blk, size_t len)
{ const struct eeprom_emu_config *dev_config = dev->config; int rc; rc = flash_write(dev_config->flash_dev, dev_config->flash_offset + offset, blk, len); return rc; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Notes: Only requests the failure of the io, not that all are flushed prior to returning. */
static void fc_timeout_fail_rport_io(struct work_struct *work)
/* Notes: Only requests the failure of the io, not that all are flushed prior to returning. */ static void fc_timeout_fail_rport_io(struct work_struct *work)
{ struct fc_rport *rport = container_of(work, struct fc_rport, fail_io_work.work); if (rport->port_state != FC_PORTSTATE_BLOCKED) return; rport->flags |= FC_RPORT_FAST_FAIL_TIMEDOUT; fc_terminate_rport_io(rport); }
robutest/uclinux
C++
GPL-2.0
60
/* Initialize a local message counter with random value between . This increases the difficulty of traffic analysis attacks by making it harder to determine how long a particular session has been open. The initial counter is always 1 or higher to guarantee first message is always greater than initial peer counter set t...
static void mc_randomize(matter_counter_t *c)
/* Initialize a local message counter with random value between . This increases the difficulty of traffic analysis attacks by making it harder to determine how long a particular session has been open. The initial counter is always 1 or higher to guarantee first message is always greater than initial peer counter set t...
{ c->counter = 1; } c->window.reset(); }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* For Serial ATA (SATA) controllers, this member function can be used to disqualify a higher transfer rate mode on a given channel. For example, a platform driver may inform the IDE controller driver to not use second-generation (Gen2) speeds for a certain SATA drive. */
EFI_STATUS EFIAPI IdeInitDisqualifyMode(IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, IN UINT8 Channel, IN UINT8 Device, IN EFI_ATA_COLLECTIVE_MODE *BadModes)
/* For Serial ATA (SATA) controllers, this member function can be used to disqualify a higher transfer rate mode on a given channel. For example, a platform driver may inform the IDE controller driver to not use second-generation (Gen2) speeds for a certain SATA drive. */ EFI_STATUS EFIAPI IdeInitDisqualifyMode(IN EFI_...
{ EFI_SATA_CONTROLLER_PRIVATE_DATA *Private; UINTN DeviceIndex; ASSERT (This != NULL); Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This); if ((Channel >= This->ChannelCount) || (BadModes == NULL) || (Device >= Private->DeviceCount)) { return EFI_INVALID_PARAMETER; } ...
tianocore/edk2
C++
Other
4,240
/* Unregisters an interrupt handler for a comparator interrupt. */
void ComparatorIntUnregister(uint32_t ui32Base, uint32_t ui32Comp)
/* Unregisters an interrupt handler for a comparator interrupt. */ void ComparatorIntUnregister(uint32_t ui32Base, uint32_t ui32Comp)
{ ASSERT(ui32Base == COMP_BASE); ASSERT(ui32Comp < 3); HWREG(ui32Base + COMP_O_ACINTEN) &= ~(1 << ui32Comp); IntDisable(INT_COMP0_BLIZZARD + ui32Comp); IntUnregister(INT_COMP0_BLIZZARD + ui32Comp); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* This function is registered to the SPI framework for this SPI master controller. It will queue the spi_message in the queue of driver if the queue is not stopped and return. */
static int pl022_transfer(struct spi_device *spi, struct spi_message *msg)
/* This function is registered to the SPI framework for this SPI master controller. It will queue the spi_message in the queue of driver if the queue is not stopped and return. */ static int pl022_transfer(struct spi_device *spi, struct spi_message *msg)
{ struct pl022 *pl022 = spi_master_get_devdata(spi->master); unsigned long flags; spin_lock_irqsave(&pl022->queue_lock, flags); if (!pl022->running) { spin_unlock_irqrestore(&pl022->queue_lock, flags); return -ESHUTDOWN; } msg->actual_length = 0; msg->status = -EINPROGRESS; msg->state = STATE_START; list_a...
EmcraftSystems/linux-emcraft
C++
Other
266
/* The author disclaims all warranties with regard to this software, including all implied warranties of merchantability and fitness. In no event shall the author be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of c...
void Iso7816_CreateSimpleAtr(uint8_t *const atr, uint8_t *const atrLength)
/* The author disclaims all warranties with regard to this software, including all implied warranties of merchantability and fitness. In no event shall the author be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of c...
{ atr[0] = 0x3B; uint8_t interfaceBytesPresence = 0; uint8_t historycalBytes[14] = "Lufa CCID Demo"; uint8_t historicalBytesLength = sizeof(historycalBytes); atr[1] = (interfaceBytesPresence << 4) + historicalBytesLength; memcpy(atr + 2, historycalBytes, historicalBytesLength); *atrLength = historicalBytesLeng...
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Fail all ouitstanding requests so handlers don't wait for the userspace to finish processing them. */
static void uinput_flush_requests(struct uinput_device *udev)
/* Fail all ouitstanding requests so handlers don't wait for the userspace to finish processing them. */ static void uinput_flush_requests(struct uinput_device *udev)
{ struct uinput_request *request; int i; spin_lock(&udev->requests_lock); for (i = 0; i < UINPUT_NUM_REQUESTS; i++) { request = udev->requests[i]; if (request) { request->retval = -ENODEV; uinput_request_done(udev, request); } } spin_unlock(&udev->requests_lock); }
robutest/uclinux
C++
GPL-2.0
60
/* This function performs periodic timer processing in the ARP module and should be called at regular intervals. The recommended interval is 10 seconds between the calls. */
void uip_arp_timer(void)
/* This function performs periodic timer processing in the ARP module and should be called at regular intervals. The recommended interval is 10 seconds between the calls. */ void uip_arp_timer(void)
{ struct arp_entry *tabptr; ++arptime; for( i = 0; i < UIP_ARPTAB_SIZE; ++i ) { tabptr = &arp_table[i]; if( (tabptr->ipaddr[0] | tabptr->ipaddr[1]) != 0 && arptime - tabptr->time >= UIP_ARP_MAXAGE ) { memset( tabptr->ipaddr, 0, 4 ); } } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Enables or disables the reporting of an uncorrectable bit error to the CPU. On this microcontroller, directly reading data from flash memory can result in a CPU trap, when that particular flash page was not previously newly programmed (IfxCpu_Trap_Bus_Id_dataAccessSynchronousError). */
static void CpuEnableUncorrectableBitErrorTrap(blt_bool enable)
/* Enables or disables the reporting of an uncorrectable bit error to the CPU. On this microcontroller, directly reading data from flash memory can result in a CPU trap, when that particular flash page was not previously newly programmed (IfxCpu_Trap_Bus_Id_dataAccessSynchronousError). */ static void CpuEnableUncorrec...
{ blt_int16u password; blt_int8u trapDisBitVal; trapDisBitVal = (enable == BLT_TRUE) ? 0 : 1; password = IfxScuWdt_getCpuWatchdogPassword(); IfxScuWdt_clearCpuEndinit(password); FLASH0_MARP.B.TRAPDIS = trapDisBitVal; IfxScuWdt_setCpuEndinit(password); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* All this reference to mapping stacks leads us neatly into the other complex part of the Host: page table handling. */
static void set_trap(struct lg_cpu *cpu, struct desc_struct *trap, unsigned int num, u32 lo, u32 hi)
/* All this reference to mapping stacks leads us neatly into the other complex part of the Host: page table handling. */ static void set_trap(struct lg_cpu *cpu, struct desc_struct *trap, unsigned int num, u32 lo, u32 hi)
{ u8 type = idt_type(lo, hi); if (!idt_present(lo, hi)) { trap->a = trap->b = 0; return; } if (type != 0xE && type != 0xF) kill_guest(cpu, "bad IDT type %i", type); trap->a = ((__KERNEL_CS|GUEST_PL)<<16) | (lo&0x0000FFFF); trap->b = (hi&0xFFFFEF00); }
robutest/uclinux
C++
GPL-2.0
60
/* Internal function to add stall opcode to the table. */
EFI_STATUS BootScriptWriteStall(IN VA_LIST Marker)
/* Internal function to add stall opcode to the table. */ EFI_STATUS BootScriptWriteStall(IN VA_LIST Marker)
{ UINT32 Duration; Duration = VA_ARG (Marker, UINT32); return S3BootScriptSaveStall (Duration); }
tianocore/edk2
C++
Other
4,240
/* Callback function called by PE to inform DPM about PE event. */
void USBPD_DPM_Notification(uint8_t PortNum, USBPD_NotifyEventValue_TypeDef EventVal)
/* Callback function called by PE to inform DPM about PE event. */ void USBPD_DPM_Notification(uint8_t PortNum, USBPD_NotifyEventValue_TypeDef EventVal)
{ switch(EventVal) { case USBPD_NOTIFY_POWER_EXPLICIT_CONTRACT : break; case USBPD_NOTIFY_STATE_SRC_DISABLED: { } break; default : break; } }
st-one/X-CUBE-USB-PD
C++
null
110
/* retval kStatus_Success Started successfully. retval kStatus_CSI_NoFullBuffer There is no full frame buffer in queue. */
status_t CSI_TransferGetFullBuffer(CSI_Type *base, csi_handle_t *handle, uint32_t *frameBuffer)
/* retval kStatus_Success Started successfully. retval kStatus_CSI_NoFullBuffer There is no full frame buffer in queue. */ status_t CSI_TransferGetFullBuffer(CSI_Type *base, csi_handle_t *handle, uint32_t *frameBuffer)
{ uint32_t csicr1; status_t status; uint8_t queueReadIdx; uint8_t queueWriteIdx; queueReadIdx = handle->queueReadIdx; queueWriteIdx = handle->queueWriteIdx; if (queueReadIdx == queueWriteIdx) { status = kStatus_CSI_NoFullBuffer; } else { csicr1 = base->CSICR1...
eclipse-threadx/getting-started
C++
Other
310
/* Attaches the synopGMAC device structure to the hardware. Device structure is populated with MAC/DMA and PHY base addresses. */
static s32 synopGMAC_scan_phyid(synopGMACdevice *gmacdev, u32 phyBase)
/* Attaches the synopGMAC device structure to the hardware. Device structure is populated with MAC/DMA and PHY base addresses. */ static s32 synopGMAC_scan_phyid(synopGMACdevice *gmacdev, u32 phyBase)
{ int i, j; u16 data; for (i = phyBase, j = 0; j < 32; i = (i + 1) & 0x1f, j++) { synopGMAC_read_phy_reg(gmacdev->MacBase, i, 2, &data); if (data != 0 && data != 0xffff) break; synopGMAC_read_phy_reg(gmacdev->MacBase, i, 3, &data); if (data != 0 && data != 0xffff) break; ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Convenience function for receiving data from the AC97 codec. */
unsigned short AC97C_ReadCodec(unsigned char address)
/* Convenience function for receiving data from the AC97 codec. */ unsigned short AC97C_ReadCodec(unsigned char address)
{ unsigned int sample; sample = AT91C_AC97C_READ | (address << 16); AC97C_Transfer(AC97C_CODEC_TRANSFER, (unsigned char *) &sample, 1, 0, 0); while (!AC97C_IsFinished(AC97C_CODEC_TRANSFER)); return sample; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Delete the device structure from the device lists and notify userspace (/sbin/hotplug), but only if the device in question is not being used by a driver. Returns 0 on success. */
void pci_remove_bus(struct pci_bus *pci_bus)
/* Delete the device structure from the device lists and notify userspace (/sbin/hotplug), but only if the device in question is not being used by a driver. Returns 0 on success. */ void pci_remove_bus(struct pci_bus *pci_bus)
{ pci_proc_detach_bus(pci_bus); down_write(&pci_bus_sem); list_del(&pci_bus->node); up_write(&pci_bus_sem); if (!pci_bus->is_added) return; pci_remove_legacy_files(pci_bus); device_remove_file(&pci_bus->dev, &dev_attr_cpuaffinity); device_remove_file(&pci_bus->dev, &dev_attr_cpulistaffinity); device_unregist...
robutest/uclinux
C++
GPL-2.0
60