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
/* match_device - Report whether this driver can handle this device @driver: the PA-RISC driver to try @dev: the PA-RISC device to try */
static int match_device(struct parisc_driver *driver, struct parisc_device *dev)
/* match_device - Report whether this driver can handle this device @driver: the PA-RISC driver to try @dev: the PA-RISC device to try */ static int match_device(struct parisc_driver *driver, struct parisc_device *dev)
{ const struct parisc_device_id *ids; for (ids = driver->id_table; ids->sversion; ids++) { if ((ids->sversion != SVERSION_ANY_ID) && (ids->sversion != dev->id.sversion)) continue; if ((ids->hw_type != HWTYPE_ANY_ID) && (ids->hw_type != dev->id.hw_type)) continue; if ((ids->hversion != HVERSION_ANY_ID) && (ids->hversion != dev->id.hversion)) continue; return 1; } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns the number of USB endpoint pairs on the device. */
uint32_t USBNumEndpointsGet(uint32_t ui32Base)
/* Returns the number of USB endpoint pairs on the device. */ uint32_t USBNumEndpointsGet(uint32_t ui32Base)
{ return (HWREGB(ui32Base + USB_O_EPINFO) & USB_EPINFO_TXEP_M); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* SYSCTRL I2C1 Bus Clock Enable and Reset Release. */
void LL_SYSCTRL_I2C1_ClkEnRstRelease(void)
/* SYSCTRL I2C1 Bus Clock Enable and Reset Release. */ void LL_SYSCTRL_I2C1_ClkEnRstRelease(void)
{ __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); __LL_SYSCTRL_I2C1BusClk_En(SYSCTRL); __LL_SYSCTRL_I2C1SoftRst_Release(SYSCTRL); __LL_SYSCTRL_Reg_Lock(SYSCTRL); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Sets the FIFO level at which DMA requests or interrupts are generated. */
void SPIFIFOLevelSet(unsigned long ulBase, unsigned long ulTxLevel, unsigned long ulRxLevel)
/* Sets the FIFO level at which DMA requests or interrupts are generated. */ void SPIFIFOLevelSet(unsigned long ulBase, unsigned long ulTxLevel, unsigned long ulRxLevel)
{ unsigned long ulRegVal; ulRegVal = HWREG(ulBase + MCSPI_O_XFERLEVEL); ulRegVal = ((ulRegVal & 0xFFFF0000) | (((ulRxLevel-1) << 8) | (ulTxLevel-1))); HWREG(ulBase + MCSPI_O_XFERLEVEL) = ulRegVal; }
micropython/micropython
C++
Other
18,334
/* Returns TIPC error status code (TIPC_OK if message is not to be rejected) */
static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
/* Returns TIPC error status code (TIPC_OK if message is not to be rejected) */ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
{ struct sock *sk = (struct sock *)tport->usr_handle; u32 res; bh_lock_sock(sk); if (!sock_owned_by_user(sk)) { res = filter_rcv(sk, buf); } else { sk_add_backlog(sk, buf); res = TIPC_OK; } bh_unlock_sock(sk); return res; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Erase whole chip memory with build-in erase program. */
void AT45DB161_EraseChip()
/* Erase whole chip memory with build-in erase program. */ void AT45DB161_EraseChip()
{ if(AT45DB161_WaitReady() == 0)return; AT45DB161_CS = 0; xSPIDataWrite(AT45DB161_SPI_PORT, AT45DB161_CMD_CPER, 4); AT45DB161_CS = 1; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* RETURN VALUE: -EINVAL if the requested state is invalid. -EIO if device does not support PCI PM or its PM capabilities register has a wrong version, or device doesn't support the requested state. 0 if device already is in the requested state. 0 if device's power state has been successfully changed. */
int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
/* RETURN VALUE: -EINVAL if the requested state is invalid. -EIO if device does not support PCI PM or its PM capabilities register has a wrong version, or device doesn't support the requested state. 0 if device already is in the requested state. 0 if device's power state has been successfully changed. */ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
{ int error; if (state > PCI_D3hot) state = PCI_D3hot; else if (state < PCI_D0) state = PCI_D0; else if ((state == PCI_D1 || state == PCI_D2) && pci_no_d1d2(dev)) return 0; if (dev->current_state == state) return 0; __pci_start_power_transition(dev, state); if (state == PCI_D3hot && (dev->dev_flags & PCI_DEV_FLAGS_NO_D3)) return 0; error = pci_raw_set_power_state(dev, state); if (!__pci_complete_power_transition(dev, state)) error = 0; return error; }
robutest/uclinux
C++
GPL-2.0
60
/* Look up and bind the tty and the driver together. Initialize any needed private data (in our case the termios) */
static int sdio_uart_install(struct tty_driver *driver, struct tty_struct *tty)
/* Look up and bind the tty and the driver together. Initialize any needed private data (in our case the termios) */ static int sdio_uart_install(struct tty_driver *driver, struct tty_struct *tty)
{ int idx = tty->index; struct sdio_uart_port *port = sdio_uart_port_get(idx); int ret = tty_init_termios(tty); if (ret == 0) { tty_driver_kref_get(driver); tty->count++; tty->driver_data = port; driver->ttys[idx] = tty; } else sdio_uart_port_put(port); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* If the first argument, db, is not NULL and a malloc() error has occurred, then the connection error-code (the value returned by sqlite3_errcode()) is set to SQLITE_NOMEM. */
SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int)
/* If the first argument, db, is not NULL and a malloc() error has occurred, then the connection error-code (the value returned by sqlite3_errcode()) is set to SQLITE_NOMEM. */ SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int)
{ assert( !db || sqlite3_mutex_held(db->mutex) ); if( db && (db->mallocFailed || rc==SQLITE_IOERR_NOMEM) ){ sqlite3Error(db, SQLITE_NOMEM, 0); db->mallocFailed = 0; rc = SQLITE_NOMEM; } return rc & (db ? db->errMask : 0xff); }
DC-SWAT/DreamShell
C++
null
404
/* Authors: Mitsuru KANDA @USAGI Kazunori MIYAZAWA @USAGI Kunihiro Ishiguro */
int xfrm6_extract_input(struct xfrm_state *x, struct sk_buff *skb)
/* Authors: Mitsuru KANDA @USAGI Kazunori MIYAZAWA @USAGI Kunihiro Ishiguro */ int xfrm6_extract_input(struct xfrm_state *x, struct sk_buff *skb)
{ return xfrm6_extract_header(skb); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Function for finding backend instance with given name. */
static const struct log_backend* backend_find(char const *name)
/* Function for finding backend instance with given name. */ static const struct log_backend* backend_find(char const *name)
{ size_t slen = strlen(name); STRUCT_SECTION_FOREACH(log_backend, backend) { if (strncmp(name, backend->name, slen) == 0) { return backend; } } return NULL; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Set "auto commit" property of the connection. If 'true', then rollback current transaction. If 'false', then start a new transaction. */
static int conn_setautocommit(lua_State *L)
/* Set "auto commit" property of the connection. If 'true', then rollback current transaction. If 'false', then start a new transaction. */ static int conn_setautocommit(lua_State *L)
{ conn->auto_commit = 1; sql_rollback(conn); } else { conn->auto_commit = 0; sql_begin(conn); } lua_pushboolean(L, 1); return 1; }
DC-SWAT/DreamShell
C++
null
404
/* Find sub-partition type given its name. If the name does not exist, returns -1. */
static int find_type_by_name(const char *name)
/* Find sub-partition type given its name. If the name does not exist, returns -1. */ static int find_type_by_name(const char *name)
{ int i; for (i = 0; i < MAX_SUBPARTS; i++) { if ((strlen(subparts[i].name) == strlen(name)) && (!strcmp(subparts[i].name, name))) break; } if (i == MAX_SUBPARTS) { ERROR("Invalid sub-partition name %s.\n", name); return -1; } return i; }
4ms/stm32mp1-baremetal
C++
Other
137
/* BusLogic_Failure prints a standardized error message, and then returns false. */
static bool BusLogic_Failure(struct BusLogic_HostAdapter *HostAdapter, char *ErrorMessage)
/* BusLogic_Failure prints a standardized error message, and then returns false. */ static bool BusLogic_Failure(struct BusLogic_HostAdapter *HostAdapter, char *ErrorMessage)
{ BusLogic_AnnounceDriver(HostAdapter); if (HostAdapter->HostAdapterBusType == BusLogic_PCI_Bus) { BusLogic_Error("While configuring BusLogic PCI Host Adapter at\n", HostAdapter); BusLogic_Error("Bus %d Device %d I/O Address 0x%X PCI Address 0x%X:\n", HostAdapter, HostAdapter->Bus, HostAdapter->Device, HostAdapter->IO_Address, HostAdapter->PCI_Address); } else BusLogic_Error("While configuring BusLogic Host Adapter at " "I/O Address 0x%X:\n", HostAdapter, HostAdapter->IO_Address); BusLogic_Error("%s FAILED - DETACHING\n", HostAdapter, ErrorMessage); if (BusLogic_CommandFailureReason != NULL) BusLogic_Error("ADDITIONAL FAILURE INFO - %s\n", HostAdapter, BusLogic_CommandFailureReason); return false; }
robutest/uclinux
C++
GPL-2.0
60
/* NOTE: This is an internal function which does not propagate the size when a new node is added. */
EFI_STATUS EFIAPI AmlVarListAddTailInternal(IN AML_NODE_HEADER *ParentNode, IN AML_NODE_HEADER *NewNode)
/* NOTE: This is an internal function which does not propagate the size when a new node is added. */ EFI_STATUS EFIAPI AmlVarListAddTailInternal(IN AML_NODE_HEADER *ParentNode, IN AML_NODE_HEADER *NewNode)
{ LIST_ENTRY *ChildrenList; if ((!IS_AML_ROOT_NODE (ParentNode) && !IS_AML_OBJECT_NODE (ParentNode)) || (!IS_AML_DATA_NODE (NewNode) && !IS_AML_OBJECT_NODE (NewNode)) || !AML_NODE_IS_DETACHED (NewNode)) { ASSERT (0); return EFI_INVALID_PARAMETER; } ChildrenList = AmlNodeGetVariableArgList (ParentNode); if (ChildrenList == NULL) { ASSERT (0); return EFI_INVALID_PARAMETER; } InsertTailList (ChildrenList, &NewNode->Link); NewNode->Parent = ParentNode; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Clear the Programming Sequence Error Flag This flag is set when incorrect programming configuration has been made. */
void flash_clear_pgserr_flag(void)
/* Clear the Programming Sequence Error Flag This flag is set when incorrect programming configuration has been made. */ void flash_clear_pgserr_flag(void)
{ FLASH_SR |= FLASH_SR_PGSERR; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* send_args send_common send_request receive_request send_convert receive_convert send_unlock receive_unlock send_cancel receive_cancel send_grant receive_grant send_bast receive_bast send_lookup receive_lookup send_remove receive_remove */
static int _create_message(struct dlm_ls *ls, int mb_len, int to_nodeid, int mstype, struct dlm_message **ms_ret, struct dlm_mhandle **mh_ret)
/* send_args send_common send_request receive_request send_convert receive_convert send_unlock receive_unlock send_cancel receive_cancel send_grant receive_grant send_bast receive_bast send_lookup receive_lookup send_remove receive_remove */ static int _create_message(struct dlm_ls *ls, int mb_len, int to_nodeid, int mstype, struct dlm_message **ms_ret, struct dlm_mhandle **mh_ret)
{ struct dlm_message *ms; struct dlm_mhandle *mh; char *mb; mh = dlm_lowcomms_get_buffer(to_nodeid, mb_len, GFP_NOFS, &mb); if (!mh) return -ENOBUFS; memset(mb, 0, mb_len); ms = (struct dlm_message *) mb; ms->m_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR); ms->m_header.h_lockspace = ls->ls_global_id; ms->m_header.h_nodeid = dlm_our_nodeid(); ms->m_header.h_length = mb_len; ms->m_header.h_cmd = DLM_MSG; ms->m_type = mstype; *mh_ret = mh; *ms_ret = ms; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* One notified function to cleanup the allocated resources at the end of PEI. */
EFI_STATUS EFIAPI NvmePeimEndOfPei(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
/* One notified function to cleanup the allocated resources at the end of PEI. */ EFI_STATUS EFIAPI NvmePeimEndOfPei(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
{ PEI_NVME_CONTROLLER_PRIVATE_DATA *Private; Private = GET_NVME_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY (NotifyDescriptor); NvmeFreeDmaResource (Private); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Description: Given a PHY device, and a PHY driver, return 1 if the driver supports the device. Otherwise, return 0. */
static int mdio_bus_match(struct device *dev, struct device_driver *drv)
/* Description: Given a PHY device, and a PHY driver, return 1 if the driver supports the device. Otherwise, return 0. */ static int mdio_bus_match(struct device *dev, struct device_driver *drv)
{ struct phy_device *phydev = to_phy_device(dev); struct phy_driver *phydrv = to_phy_driver(drv); return ((phydrv->phy_id & phydrv->phy_id_mask) == (phydev->phy_id & phydrv->phy_id_mask)); }
robutest/uclinux
C++
GPL-2.0
60
/* This function is called after a PCI bus error affecting this device has been detected. */
static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
/* This function is called after a PCI bus error affecting this device has been detected. */ static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
{ struct net_device *netdev = pci_get_drvdata(pdev); struct e1000_adapter *adapter = netdev_priv(netdev); netif_device_detach(netdev); if (state == pci_channel_io_perm_failure) return PCI_ERS_RESULT_DISCONNECT; if (netif_running(netdev)) e1000e_down(adapter); pci_disable_device(pdev); return PCI_ERS_RESULT_NEED_RESET; }
robutest/uclinux
C++
GPL-2.0
60
/* These dissectors are used to dissect the setup part and the data for URB_CONTROL_INPUT / SYNCH FRAME */
static int dissect_usb_setup_synch_frame_request(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, usb_conv_info_t *usb_conv_info _U_)
/* These dissectors are used to dissect the setup part and the data for URB_CONTROL_INPUT / SYNCH FRAME */ static int dissect_usb_setup_synch_frame_request(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, usb_conv_info_t *usb_conv_info _U_)
{ proto_tree_add_item(tree, hf_usb_value, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; proto_tree_add_item(tree, hf_usb_wEndpoint, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; proto_tree_add_item(tree, hf_usb_length, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Special API for POWER to configure the vectors through a side channel. Should never be used by devices. */
void msi_set_message(PCIDevice *dev, MSIMessage msg)
/* Special API for POWER to configure the vectors through a side channel. Should never be used by devices. */ void msi_set_message(PCIDevice *dev, MSIMessage msg)
{ uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev)); bool msi64bit = flags & PCI_MSI_FLAGS_64BIT; if (msi64bit) { pci_set_quad(dev->config + msi_address_lo_off(dev), msg.address); } else { pci_set_long(dev->config + msi_address_lo_off(dev), msg.address); } pci_set_word(dev->config + msi_data_off(dev, msi64bit), msg.data); }
ve3wwg/teensy3_qemu
C++
Other
15
/* Functionally similar to acpi_ex_eisa_id_to_string(), but that's buried in the ACPI CA, and we can't depend on it being present. */
void pnp_eisa_id_to_string(u32 id, char *str)
/* Functionally similar to acpi_ex_eisa_id_to_string(), but that's buried in the ACPI CA, and we can't depend on it being present. */ void pnp_eisa_id_to_string(u32 id, char *str)
{ id = be32_to_cpu(id); str[0] = 'A' + ((id >> 26) & 0x3f) - 1; str[1] = 'A' + ((id >> 21) & 0x1f) - 1; str[2] = 'A' + ((id >> 16) & 0x1f) - 1; str[3] = hex_asc_hi(id >> 8); str[4] = hex_asc_lo(id >> 8); str[5] = hex_asc_hi(id); str[6] = hex_asc_lo(id); str[7] = '\0'; }
robutest/uclinux
C++
GPL-2.0
60
/* Check the status of the Tx buffer of the specified SPI port. */
xtBoolean SPIIsTxEmpty(unsigned long ulBase)
/* Check the status of the Tx buffer of the specified SPI port. */ xtBoolean SPIIsTxEmpty(unsigned long ulBase)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE) ); return ((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_TX_EMPTY)? xtrue : xfalse); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* idr_remove - remove the given id and free it's slot @idp: idr handle @id: unique key */
void idr_remove(struct idr *idp, int id)
/* idr_remove - remove the given id and free it's slot @idp: idr handle @id: unique key */ void idr_remove(struct idr *idp, int id)
{ struct idr_layer *p; struct idr_layer *to_free; id &= MAX_ID_MASK; sub_remove(idp, (idp->layers - 1) * IDR_BITS, id); if (idp->top && idp->top->count == 1 && (idp->layers > 1) && idp->top->ary[0]) { to_free = idp->top; p = idp->top->ary[0]; rcu_assign_pointer(idp->top, p); --idp->layers; to_free->bitmap = to_free->count = 0; free_layer(to_free); } while (idp->id_free_cnt >= IDR_FREE_MAX) { p = get_from_free_list(idp); kmem_cache_free(idr_layer_cache, p); } return; }
robutest/uclinux
C++
GPL-2.0
60
/* Wait for the env to be ready for execute specified TRB. */
EFI_STATUS SdMmcWaitTrbEnv(IN SD_MMC_HC_PRIVATE_DATA *Private, IN SD_MMC_HC_TRB *Trb)
/* Wait for the env to be ready for execute specified TRB. */ EFI_STATUS SdMmcWaitTrbEnv(IN SD_MMC_HC_PRIVATE_DATA *Private, IN SD_MMC_HC_TRB *Trb)
{ EFI_STATUS Status; EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet; UINT64 Timeout; BOOLEAN InfiniteWait; Packet = Trb->Packet; Timeout = Packet->Timeout; if (Timeout == 0) { InfiniteWait = TRUE; } else { InfiniteWait = FALSE; } while (InfiniteWait || (Timeout > 0)) { Status = SdMmcCheckTrbEnv (Private, Trb); if (Status != EFI_NOT_READY) { return Status; } gBS->Stall (1); Timeout--; } return EFI_TIMEOUT; }
tianocore/edk2
C++
Other
4,240
/* This version takes a sigset mask and looks at all signals, not just those in the first mask word. */
static int rm_from_queue_full(sigset_t *mask, struct sigpending *s)
/* This version takes a sigset mask and looks at all signals, not just those in the first mask word. */ static int rm_from_queue_full(sigset_t *mask, struct sigpending *s)
{ struct sigqueue *q, *n; sigset_t m; sigandsets(&m, mask, &s->signal); if (sigisemptyset(&m)) return 0; signandsets(&s->signal, &s->signal, mask); list_for_each_entry_safe(q, n, &s->list, list) { if (sigismember(mask, q->info.si_signo)) { list_del_init(&q->list); __sigqueue_free(q); } } return 1; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This routine is called to indicate that the described extent is to be logged as having been freed. It should be called once for each extent freed. */
void xfs_trans_log_efd_extent(xfs_trans_t *tp, xfs_efd_log_item_t *efdp, xfs_fsblock_t start_block, xfs_extlen_t ext_len)
/* This routine is called to indicate that the described extent is to be logged as having been freed. It should be called once for each extent freed. */ void xfs_trans_log_efd_extent(xfs_trans_t *tp, xfs_efd_log_item_t *efdp, xfs_fsblock_t start_block, xfs_extlen_t ext_len)
{ xfs_log_item_desc_t *lidp; uint next_extent; xfs_extent_t *extp; lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)efdp); ASSERT(lidp != NULL); tp->t_flags |= XFS_TRANS_DIRTY; lidp->lid_flags |= XFS_LID_DIRTY; next_extent = efdp->efd_next_extent; ASSERT(next_extent < efdp->efd_format.efd_nextents); extp = &(efdp->efd_format.efd_extents[next_extent]); extp->ext_start = start_block; extp->ext_len = ext_len; efdp->efd_next_extent++; }
robutest/uclinux
C++
GPL-2.0
60
/* Function for the LEDs initialization. Initializes all LEDs used by this application. */
static void leds_init(void)
/* Function for the LEDs initialization. Initializes all LEDs used by this application. */ static void leds_init(void)
{ nrf_gpio_cfg_output(ADVERTISING_LED_PIN_NO); nrf_gpio_cfg_output(CONNECTED_LED_PIN_NO); nrf_gpio_pin_set(ADVERTISING_LED_PIN_NO); nrf_gpio_pin_set(CONNECTED_LED_PIN_NO); }
labapart/polymcu
C++
null
201
/* Converts a Mode Register bit mask to a data bit configuration enum value. Converts a bit mask representing the UART's data bit setting within the UART's Mode Register into a value of an enumeration type provided by the UART driver API. */
static enum uart_config_data_bits uart_xlnx_ps_ll2cfg_databits(uint32_t mode_reg)
/* Converts a Mode Register bit mask to a data bit configuration enum value. Converts a bit mask representing the UART's data bit setting within the UART's Mode Register into a value of an enumeration type provided by the UART driver API. */ static enum uart_config_data_bits uart_xlnx_ps_ll2cfg_databits(uint32_t mode_reg)
{ switch ((mode_reg & XUARTPS_MR_CHARLEN_MASK)) { case XUARTPS_MR_CHARLEN_8_BIT: default: return UART_CFG_DATA_BITS_8; case XUARTPS_MR_CHARLEN_7_BIT: return UART_CFG_DATA_BITS_7; case XUARTPS_MR_CHARLEN_6_BIT: return UART_CFG_DATA_BITS_6; } }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* This function returns IRQ_HANDLED when interrupt is handled, else it returns IRQ_NONE. */
irqreturn_t lpfc_sli4_intr_handler(int irq, void *dev_id)
/* This function returns IRQ_HANDLED when interrupt is handled, else it returns IRQ_NONE. */ irqreturn_t lpfc_sli4_intr_handler(int irq, void *dev_id)
{ struct lpfc_hba *phba; irqreturn_t sp_irq_rc, fp_irq_rc; bool fp_handled = false; uint32_t fcp_eqidx; phba = (struct lpfc_hba *)dev_id; if (unlikely(!phba)) return IRQ_NONE; sp_irq_rc = lpfc_sli4_sp_intr_handler(irq, dev_id); for (fcp_eqidx = 0; fcp_eqidx < phba->cfg_fcp_eq_count; fcp_eqidx++) { fp_irq_rc = lpfc_sli4_fp_intr_handler(irq, &phba->sli4_hba.fcp_eq_hdl[fcp_eqidx]); if (fp_irq_rc == IRQ_HANDLED) fp_handled |= true; } return (fp_handled == true) ? IRQ_HANDLED : sp_irq_rc; }
robutest/uclinux
C++
GPL-2.0
60
/* Decides whether a PE/COFF image can execute on this system, either natively or via emulation/interpretation. In the latter case, the PeCoffEmu member of the LOADED_IMAGE_PRIVATE_DATA struct pointer is populated with a pointer to the emulator protocol that supports this image. */
STATIC BOOLEAN CoreIsImageTypeSupported(IN OUT LOADED_IMAGE_PRIVATE_DATA *Image)
/* Decides whether a PE/COFF image can execute on this system, either natively or via emulation/interpretation. In the latter case, the PeCoffEmu member of the LOADED_IMAGE_PRIVATE_DATA struct pointer is populated with a pointer to the emulator protocol that supports this image. */ STATIC BOOLEAN CoreIsImageTypeSupported(IN OUT LOADED_IMAGE_PRIVATE_DATA *Image)
{ LIST_ENTRY *Link; EMULATOR_ENTRY *Entry; for (Link = GetFirstNode (&mAvailableEmulators); !IsNull (&mAvailableEmulators, Link); Link = GetNextNode (&mAvailableEmulators, Link)) { Entry = BASE_CR (Link, EMULATOR_ENTRY, Link); if (Entry->MachineType != Image->ImageContext.Machine) { continue; } if (Entry->Emulator->IsImageSupported ( Entry->Emulator, Image->ImageContext.ImageType, Image->Info.FilePath )) { Image->PeCoffEmu = Entry->Emulator; return TRUE; } } return EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Image->ImageContext.Machine) || EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED (Image->ImageContext.Machine); }
tianocore/edk2
C++
Other
4,240
/* Reads a byte of EEPROM out from the EEPROM memory space. */
static uint8_t ReadEEPROMByte(const uint8_t *const Address)
/* Reads a byte of EEPROM out from the EEPROM memory space. */ static uint8_t ReadEEPROMByte(const uint8_t *const Address)
{ return eeprom_read_byte(Address); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned. */
EFI_STATUS EFIAPI SioBusComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned. */ EFI_STATUS EFIAPI SioBusComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
{ return LookupUnicodeString2 ( Language, This->SupportedLanguages, mSioBusDriverNameTable, DriverName, (BOOLEAN)(This == &gSioBusComponentName) ); }
tianocore/edk2
C++
Other
4,240
/* If RsaContext is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI CryptoServiceRsaGenerateKey(IN OUT VOID *RsaContext, IN UINTN ModulusLength, IN CONST UINT8 *PublicExponent, IN UINTN PublicExponentSize)
/* If RsaContext is NULL, then return FALSE. If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI CryptoServiceRsaGenerateKey(IN OUT VOID *RsaContext, IN UINTN ModulusLength, IN CONST UINT8 *PublicExponent, IN UINTN PublicExponentSize)
{ return CALL_BASECRYPTLIB (Rsa.Services.GenerateKey, RsaGenerateKey, (RsaContext, ModulusLength, PublicExponent, PublicExponentSize), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Special API for POWER to configure the vectors through a side channel. Should never be used by devices. */
void msix_set_message(PCIDevice *dev, int vector, struct MSIMessage msg)
/* Special API for POWER to configure the vectors through a side channel. Should never be used by devices. */ void msix_set_message(PCIDevice *dev, int vector, struct MSIMessage msg)
{ uint8_t *table_entry = dev->msix_table + vector * PCI_MSIX_ENTRY_SIZE; pci_set_quad(table_entry + PCI_MSIX_ENTRY_LOWER_ADDR, msg.address); pci_set_long(table_entry + PCI_MSIX_ENTRY_DATA, msg.data); table_entry[PCI_MSIX_ENTRY_VECTOR_CTRL] &= ~PCI_MSIX_ENTRY_CTRL_MASKBIT; }
ve3wwg/teensy3_qemu
C++
Other
15
/* All those INTC hookups (direct, plus several IRQ banks) can also serve as EDMA event triggers. */
static void gpio_irq_disable(unsigned irq)
/* All those INTC hookups (direct, plus several IRQ banks) can also serve as EDMA event triggers. */ static void gpio_irq_disable(unsigned irq)
{ struct gpio_controller *__iomem g = get_irq_chip_data(irq); u32 mask = (u32) get_irq_data(irq); __raw_writel(mask, &g->clr_falling); __raw_writel(mask, &g->clr_rising); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* host send ctrl request to get line coding */
HOST_STATUS usb_host_cdc_getlinecoding(usb_core_instance *pdev, USBH_HOST *phost)
/* host send ctrl request to get line coding */ HOST_STATUS usb_host_cdc_getlinecoding(usb_core_instance *pdev, USBH_HOST *phost)
{ phost->ctrlparam.setup.b.bmRequestType = USB_D2H | USB_REQ_TYPE_CLASS | \ USB_REQ_RECIPIENT_INTERFACE; phost->ctrlparam.setup.b.bRequest = CDC_GET_LINE_CODING; phost->ctrlparam.setup.b.wValue.w = 0; phost->ctrlparam.setup.b.wIndex.w = CDC_Desc.CDC_UnionFuncDesc.bControlInterface; phost->ctrlparam.setup.b.wLength.w = LINE_CODING_STRUCTURE_SIZE; return usb_host_ctrlreq(pdev, phost, CDC_GetLineCode.Array, LINE_CODING_STRUCTURE_SIZE); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function also allow to identify whether a node is a method invocation node. If the input node is not a method invocation node, just return. */
EFI_STATUS EFIAPI AmlGetMethodInvocationArgCount(IN CONST AML_OBJECT_NODE *MethodInvocationNode, OUT BOOLEAN *IsMethodInvocation, OUT UINT8 *ArgCount)
/* This function also allow to identify whether a node is a method invocation node. If the input node is not a method invocation node, just return. */ EFI_STATUS EFIAPI AmlGetMethodInvocationArgCount(IN CONST AML_OBJECT_NODE *MethodInvocationNode, OUT BOOLEAN *IsMethodInvocation, OUT UINT8 *ArgCount)
{ AML_DATA_NODE *NumArgsNode; if (!IS_AML_NODE_VALID (MethodInvocationNode) || (IsMethodInvocation == NULL) || (ArgCount == NULL)) { ASSERT (0); return EFI_INVALID_PARAMETER; } if (!AmlNodeCompareOpCode (MethodInvocationNode, AML_METHOD_INVOC_OP, 0)) { *IsMethodInvocation = FALSE; *ArgCount = 0; return EFI_SUCCESS; } NumArgsNode = (AML_DATA_NODE *)AmlGetFixedArgument ( (AML_OBJECT_NODE *)MethodInvocationNode, EAmlParseIndexTerm1 ); if (!IS_AML_NODE_VALID (NumArgsNode) || (NumArgsNode->Buffer == NULL) || (NumArgsNode->DataType != EAmlNodeDataTypeUInt) || (NumArgsNode->Size != 1)) { ASSERT (0); return EFI_INVALID_PARAMETER; } *ArgCount = *NumArgsNode->Buffer; *IsMethodInvocation = TRUE; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* If the security protocol command completes without an error, the function shall return EFI_SUCCESS. If the security protocol command completes with an error, the function shall return EFI_DEVICE_ERROR. */
EFI_STATUS EFIAPI SecurityReceiveData(IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This, IN UINT32 MediaId, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, OUT VOID *PayloadBuffer, OUT UINTN *PayloadTransferSize)
/* If the security protocol command completes without an error, the function shall return EFI_SUCCESS. If the security protocol command completes with an error, the function shall return EFI_DEVICE_ERROR. */ EFI_STATUS EFIAPI SecurityReceiveData(IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This, IN UINT32 MediaId, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, OUT VOID *PayloadBuffer, OUT UINTN *PayloadTransferSize)
{ OPAL_PEI_DEVICE *PeiDev; PeiDev = OPAL_PEI_DEVICE_FROM_THIS (This); if (PeiDev == NULL) { return EFI_DEVICE_ERROR; } return PeiDev->SscPpi->ReceiveData ( PeiDev->SscPpi, PeiDev->DeviceIndex, SSC_PPI_GENERIC_TIMEOUT, SecurityProtocolId, SecurityProtocolSpecificData, PayloadBufferSize, PayloadBuffer, PayloadTransferSize ); }
tianocore/edk2
C++
Other
4,240
/* GPMI Set And Start Data Sample Delay. This function sets the NAND Timing register which controls the delay in the data read sampling. It then set the delay hardware to be active (if needed by hardware) */
void gpmi_set_and_enable_data_sample_delay(uint32_t u32DelayCycles, uint32_t u32GpmiPeriod_ns)
/* GPMI Set And Start Data Sample Delay. This function sets the NAND Timing register which controls the delay in the data read sampling. It then set the delay hardware to be active (if needed by hardware) */ void gpmi_set_and_enable_data_sample_delay(uint32_t u32DelayCycles, uint32_t u32GpmiPeriod_ns)
{ BW_GPMI_CTRL1_DLL_ENABLE(0); if ((u32DelayCycles == 0) || (u32GpmiPeriod_ns > GPMI_MAX_DLL_PERIOD_NS) ) { BW_GPMI_CTRL1_RDN_DELAY(0); BW_GPMI_CTRL1_HALF_PERIOD(0); } else { uint32_t waitTimeNeeded; BW_GPMI_CTRL1_RDN_DELAY(u32DelayCycles); BW_GPMI_CTRL1_DLL_ENABLE(1); waitTimeNeeded = (u32GpmiPeriod_ns * GPMI_WAIT_CYCLES_AFTER_DLL_ENABLE) / 1000; hal_delay_us(waitTimeNeeded); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Whether to stop the peripheral2 while mcu core stop. */
void DBGC_Periph2Cmd(uint32_t u32Periph, en_functional_state_t enNewState)
/* Whether to stop the peripheral2 while mcu core stop. */ void DBGC_Periph2Cmd(uint32_t u32Periph, en_functional_state_t enNewState)
{ DDL_ASSERT(IS_FUNCTIONAL_STATE(enNewState)); if (ENABLE == enNewState) { CLR_REG32_BIT(CM_DBGC->MCUSTPCTL2, u32Periph); } else { SET_REG32_BIT(CM_DBGC->MCUSTPCTL2, u32Periph); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* param base Quad Timer peripheral base address param channel Quad Timer channel number param capturePin Pin through which we receive the input signal to trigger the capture param inputPolarity true: invert polarity of the input signal, false: no inversion param reloadOnCapture true: reload the counter when an input capture occurs, false: no reload param captureMode Specifies which edge of the input signal triggers a capture */
void QTMR_SetupInputCapture(TMR_Type *base, qtmr_channel_selection_t channel, qtmr_input_source_t capturePin, bool inputPolarity, bool reloadOnCapture, qtmr_input_capture_edge_t captureMode)
/* param base Quad Timer peripheral base address param channel Quad Timer channel number param capturePin Pin through which we receive the input signal to trigger the capture param inputPolarity true: invert polarity of the input signal, false: no inversion param reloadOnCapture true: reload the counter when an input capture occurs, false: no reload param captureMode Specifies which edge of the input signal triggers a capture */ void QTMR_SetupInputCapture(TMR_Type *base, qtmr_channel_selection_t channel, qtmr_input_source_t capturePin, bool inputPolarity, bool reloadOnCapture, qtmr_input_capture_edge_t captureMode)
{ uint16_t reg; reg = base->CHANNEL[channel].CTRL & (~TMR_CTRL_SCS_MASK); reg |= TMR_CTRL_SCS(capturePin); base->CHANNEL[channel].CTRL = reg; reg = base->CHANNEL[channel].SCTRL & (~(TMR_SCTRL_IPS_MASK | TMR_SCTRL_CAPTURE_MODE_MASK | TMR_SCTRL_OEN_MASK)); reg |= (TMR_SCTRL_IPS(inputPolarity) | TMR_SCTRL_CAPTURE_MODE(captureMode)); base->CHANNEL[channel].SCTRL = reg; if (reloadOnCapture) { base->CHANNEL[channel].CSCTRL |= TMR_CSCTRL_ROC_MASK; } else { base->CHANNEL[channel].CSCTRL &= ~TMR_CSCTRL_ROC_MASK; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Update an ARM MOVW/MOVT immediate instruction instruction pair. */
VOID EFIAPI ThumbMovwMovtImmediatePatch(IN OUT UINT16 *Instructions, IN UINT32 Address)
/* Update an ARM MOVW/MOVT immediate instruction instruction pair. */ VOID EFIAPI ThumbMovwMovtImmediatePatch(IN OUT UINT16 *Instructions, IN UINT32 Address)
{ UINT16 *Word; UINT16 *Top; Word = (UINT16 *)Instructions; Top = Word + 2; ThumbMovtImmediatePatch (Word, (UINT16)(Address & 0xffff)); ThumbMovtImmediatePatch (Top, (UINT16)(Address >> 16)); }
tianocore/edk2
C++
Other
4,240
/* return < 0 on transport error. *status is valid only if return >= 0 */
static int v9fs_receive_status(V9fsProxy *proxy, struct iovec *reply, int *status)
/* return < 0 on transport error. *status is valid only if return >= 0 */ static int v9fs_receive_status(V9fsProxy *proxy, struct iovec *reply, int *status)
{ int retval; ProxyHeader header; *status = 0; reply->iov_len = 0; retval = socket_read(proxy->sockfd, reply->iov_base, PROXY_HDR_SZ); if (retval < 0) { return retval; } reply->iov_len = PROXY_HDR_SZ; proxy_unmarshal(reply, 0, "dd", &header.type, &header.size); if (header.size != sizeof(int)) { *status = -ENOBUFS; return 0; } retval = socket_read(proxy->sockfd, reply->iov_base + PROXY_HDR_SZ, header.size); if (retval < 0) { return retval; } reply->iov_len += header.size; proxy_unmarshal(reply, PROXY_HDR_SZ, "d", status); return 0; }
ve3wwg/teensy3_qemu
C++
Other
15
/* This function will install a interrupt service routine to a interrupt. */
void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
/* This function will install a interrupt service routine to a interrupt. */ void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
{ if(vector < MAX_HANDLERS) { if (old_handler != RT_NULL) *old_handler = isr_table[vector]; if (new_handler != RT_NULL) isr_table[vector] = new_handler; } }
armink/FreeModbus_Slave-Master-RTT-STM32
C++
Other
1,477
/* Return the address of the two dwords in memory used for time setting. */
static u32* sep_time_address(struct sep_device *sep)
/* Return the address of the two dwords in memory used for time setting. */ static u32* sep_time_address(struct sep_device *sep)
{ return sep->shared_addr + SEP_DRIVER_SYSTEM_TIME_MEMORY_OFFSET_IN_BYTES; }
robutest/uclinux
C++
GPL-2.0
60
/* Given a psc number return the dev_clk associated with it */
static struct clk* psc_dev_clk(int pscnum)
/* Given a psc number return the dev_clk associated with it */ static struct clk* psc_dev_clk(int pscnum)
{ int reg, bit; struct clk *clk; reg = 0; bit = 27 - pscnum; clk = &dev_clks[reg][bit]; clk->reg = 0; clk->bit = bit; return clk; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Load a value relative to the specified absolute offset. */
static struct slist * gen_load_absoffsetrel(compiler_state_t *, bpf_abs_offset *, u_int, u_int)
/* Load a value relative to the specified absolute offset. */ static struct slist * gen_load_absoffsetrel(compiler_state_t *, bpf_abs_offset *, u_int, u_int)
{ struct slist *s, *s2; s = gen_abs_offset_varpart(cstate, abs_offset); if (s != NULL) { s2 = new_stmt(cstate, BPF_LD|BPF_IND|size); s2->s.k = abs_offset->constant_part + offset; sappend(s, s2); } else { s = new_stmt(cstate, BPF_LD|BPF_ABS|size); s->s.k = abs_offset->constant_part + offset; } return s; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Find Hii variable node by name and GUID. */
VAR_CHECK_HII_VARIABLE_NODE* FindHiiVariableNode(IN CHAR16 *Name, IN EFI_GUID *Guid)
/* Find Hii variable node by name and GUID. */ VAR_CHECK_HII_VARIABLE_NODE* FindHiiVariableNode(IN CHAR16 *Name, IN EFI_GUID *Guid)
{ VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode; LIST_ENTRY *Link; for (Link = mVarCheckHiiList.ForwardLink ; Link != &mVarCheckHiiList ; Link = Link->ForwardLink) { HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (Link); if ((StrCmp (Name, (CHAR16 *)(HiiVariableNode->HiiVariable + 1)) == 0) && CompareGuid (Guid, &HiiVariableNode->HiiVariable->Guid)) { return HiiVariableNode; } } return NULL; }
tianocore/edk2
C++
Other
4,240
/* This API is used to get the data(data_enable) interrupt enable bits of the sensor in the registers 0x15 bit 7. */
BMG160_RETURN_FUNCTION_TYPE bmg160_get_data_enable(u8 *v_data_enable_u8)
/* This API is used to get the data(data_enable) interrupt enable bits of the sensor in the registers 0x15 bit 7. */ BMG160_RETURN_FUNCTION_TYPE bmg160_get_data_enable(u8 *v_data_enable_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_INTR_ENABLE0_DATA__REG, &v_data_u8, BMG160_GEN_READ_WRITE_DATA_LENGTH); *v_data_enable_u8 = BMG160_GET_BITSLICE(v_data_u8, BMG160_INTR_ENABLE0_DATA); } return comres; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* param base SNVS peripheral base address param config Pointer to the user's SNVS configuration structure. */
void SNVS_HP_RTC_Init(SNVS_Type *base, const snvs_hp_rtc_config_t *config)
/* param base SNVS peripheral base address param config Pointer to the user's SNVS configuration structure. */ void SNVS_HP_RTC_Init(SNVS_Type *base, const snvs_hp_rtc_config_t *config)
{ assert(config != NULL); SNVS_HP_Init(base); base->HPCOMR |= SNVS_HPCOMR_NPSWA_EN_MASK; base->HPCR = (base->HPCR & ~SNVS_HPCR_PI_FREQ_MASK) | SNVS_HPCR_PI_FREQ(config->periodicInterruptFreq); if (config->rtcCalEnable) { base->HPCR = (base->HPCR & ~SNVS_HPCR_HPCALB_VAL_MASK) | SNVS_HPCR_HPCALB_VAL(config->rtcCalValue); base->HPCR |= SNVS_HPCR_HPCALB_EN_MASK; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function will disable the USB controller's PLL which is used by it's physical layer. The USB registers are still accessible, but the physical layer will no longer function. */
void SysCtlUSBPLLDisable(void)
/* This function will disable the USB controller's PLL which is used by it's physical layer. The USB registers are still accessible, but the physical layer will no longer function. */ void SysCtlUSBPLLDisable(void)
{ HWREG(SYSCTL_RCC2) |= SYSCTL_RCC2_USBPWRDN; }
watterott/WebRadio
C++
null
71
/* Wait for one or more bits in flag change. HDQ_FLAG_SET: wait until any bit in the flag is set. HDQ_FLAG_CLEAR: wait until all bits in the flag are cleared. return 0 on success and -ETIMEDOUT in the case of timeout. */
static int hdq_wait_for_flag(struct hdq_data *hdq_data, u32 offset, u8 flag, u8 flag_set, u8 *status)
/* Wait for one or more bits in flag change. HDQ_FLAG_SET: wait until any bit in the flag is set. HDQ_FLAG_CLEAR: wait until all bits in the flag are cleared. return 0 on success and -ETIMEDOUT in the case of timeout. */ static int hdq_wait_for_flag(struct hdq_data *hdq_data, u32 offset, u8 flag, u8 flag_set, u8 *status)
{ int ret = 0; unsigned long timeout = jiffies + OMAP_HDQ_TIMEOUT; if (flag_set == OMAP_HDQ_FLAG_CLEAR) { while (((*status = hdq_reg_in(hdq_data, offset)) & flag) && time_before(jiffies, timeout)) { schedule_timeout_uninterruptible(1); } if (*status & flag) ret = -ETIMEDOUT; } else if (flag_set == OMAP_HDQ_FLAG_SET) { while (!((*status = hdq_reg_in(hdq_data, offset)) & flag) && time_before(jiffies, timeout)) { schedule_timeout_uninterruptible(1); } if (!(*status & flag)) ret = -ETIMEDOUT; } else return -EINVAL; return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Get the end address of the specified DMC chip. */
uint32_t EXMC_DMC_GetChipEndAddr(uint32_t u32Chip)
/* Get the end address of the specified DMC chip. */ uint32_t EXMC_DMC_GetChipEndAddr(uint32_t u32Chip)
{ uint32_t u32Mask; uint32_t u32Match; __IO uint32_t *DMC_CSCRx; DDL_ASSERT(IS_EXMC_DMC_CHIP(u32Chip)); DMC_CSCRx = EXMC_DMC_CSCRx(u32Chip); u32Mask = (READ_REG32_BIT(*DMC_CSCRx, DMC_CSCR_ADDMSK) >> DMC_CSCR_ADDMSK_POS); u32Match = (READ_REG32_BIT(*DMC_CSCRx, DMC_CSCR_ADDMAT) >> DMC_CSCR_ADDMAT_POS); return EXMC_DMC_MAP_ADDR(u32Match, u32Mask); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Free the boxed structure @boxed which is of type @boxed_type. */
void g_boxed_free(GType boxed_type, gpointer boxed)
/* Free the boxed structure @boxed which is of type @boxed_type. */ void g_boxed_free(GType boxed_type, gpointer boxed)
{ GTypeValueTable *value_table; g_return_if_fail (G_TYPE_IS_BOXED (boxed_type)); g_return_if_fail (G_TYPE_IS_ABSTRACT (boxed_type) == FALSE); g_return_if_fail (boxed != NULL); value_table = g_type_value_table_peek (boxed_type); if (!value_table) g_return_if_fail (G_TYPE_IS_VALUE_TYPE (boxed_type)); if (value_table->value_free == boxed_proxy_value_free) _g_type_boxed_free (boxed_type, boxed); else { GValue value; value_meminit (&value, boxed_type); value.data[0].v_pointer = boxed; value_table->value_free (&value); } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Gets the states of the RI, DCD, DSR and CTS modem status signals. */
unsigned long UARTModemStatusGet(unsigned long ulBase)
/* Gets the states of the RI, DCD, DSR and CTS modem status signals. */ unsigned long UARTModemStatusGet(unsigned long ulBase)
{ ASSERT(!CLASS_IS_SANDSTORM && !CLASS_IS_FURY && !CLASS_IS_DUSTDEVIL); ASSERT(ulBase == UART1_BASE); return(HWREG(ulBase + UART_O_FR) & (UART_INPUT_RI | UART_INPUT_DCD | UART_INPUT_CTS | UART_INPUT_DSR)); }
watterott/WebRadio
C++
null
71
/* Returns 0 if permission is granted, otherwise errno */
static int dest_name_check(struct sockaddr_tipc *dest, struct msghdr *m)
/* Returns 0 if permission is granted, otherwise errno */ static int dest_name_check(struct sockaddr_tipc *dest, struct msghdr *m)
{ struct tipc_cfg_msg_hdr hdr; if (likely(dest->addr.name.name.type >= TIPC_RESERVED_TYPES)) return 0; if (likely(dest->addr.name.name.type == TIPC_TOP_SRV)) return 0; if (likely(dest->addr.name.name.type != TIPC_CFG_SRV)) return -EACCES; if (copy_from_user(&hdr, m->msg_iov[0].iov_base, sizeof(hdr))) return -EFAULT; if ((ntohs(hdr.tcm_type) & 0xC000) && (!capable(CAP_NET_ADMIN))) return -EACCES; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return the item in the AIL with the current lsn. Return the current tree generation number for use in calls to xfs_trans_next_ail(). */
xfs_log_item_t* xfs_trans_ail_cursor_first(struct xfs_ail *ailp, struct xfs_ail_cursor *cur, xfs_lsn_t lsn)
/* Return the item in the AIL with the current lsn. Return the current tree generation number for use in calls to xfs_trans_next_ail(). */ xfs_log_item_t* xfs_trans_ail_cursor_first(struct xfs_ail *ailp, struct xfs_ail_cursor *cur, xfs_lsn_t lsn)
{ xfs_log_item_t *lip; xfs_trans_ail_cursor_init(ailp, cur); lip = xfs_ail_min(ailp); if (lsn == 0) goto out; list_for_each_entry(lip, &ailp->xa_ail, li_ail) { if (XFS_LSN_CMP(lip->li_lsn, lsn) >= 0) goto out; } lip = NULL; out: xfs_trans_ail_cursor_set(ailp, cur, lip); return lip; }
robutest/uclinux
C++
GPL-2.0
60
/* Set SPI clock to a low frequency suitable for initial card initialization. */
void MICROSD_SpiClkSlow(void)
/* Set SPI clock to a low frequency suitable for initial card initialization. */ void MICROSD_SpiClkSlow(void)
{ USART_BaudrateSyncSet(MICROSD_USART, 0, MICROSD_LO_SPI_FREQ); xfersPrMsec = MICROSD_LO_SPI_FREQ / 8000; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Change Logs: Date Author Notes armink the first version xqyjlj perf rt_hw_interrupt_disable/enable ring block buffer object initialization */
void rt_rbb_init(rt_rbb_t rbb, rt_uint8_t *buf, rt_size_t buf_size, rt_rbb_blk_t block_set, rt_size_t blk_max_num)
/* Change Logs: Date Author Notes armink the first version xqyjlj perf rt_hw_interrupt_disable/enable ring block buffer object initialization */ void rt_rbb_init(rt_rbb_t rbb, rt_uint8_t *buf, rt_size_t buf_size, rt_rbb_blk_t block_set, rt_size_t blk_max_num)
{ rt_size_t i; RT_ASSERT(rbb); RT_ASSERT(buf); RT_ASSERT(block_set); rbb->buf = buf; rbb->buf_size = buf_size; rbb->blk_set = block_set; rbb->blk_max_num = blk_max_num; rbb->tail = &rbb->blk_list; rt_slist_init(&rbb->blk_list); rt_slist_init(&rbb->free_list); for (i = 0; i < blk_max_num; i++) { block_set[i].status = RT_RBB_BLK_UNUSED; rt_slist_init(&block_set[i].list); rt_slist_insert(&rbb->free_list, &block_set[i].list); } rt_spin_lock_init(&(rbb->spinlock)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Update on-disk file size now that data has been written to disk. The current in-memory file size is i_size. If a write is beyond eof i_new_size will be the intended file size until i_size is updated. If this write does not extend all the way to the valid file size then restrict this update to the end of the write. */
STATIC void xfs_setfilesize(xfs_ioend_t *ioend)
/* Update on-disk file size now that data has been written to disk. The current in-memory file size is i_size. If a write is beyond eof i_new_size will be the intended file size until i_size is updated. If this write does not extend all the way to the valid file size then restrict this update to the end of the write. */ STATIC void xfs_setfilesize(xfs_ioend_t *ioend)
{ xfs_inode_t *ip = XFS_I(ioend->io_inode); xfs_fsize_t isize; ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG); ASSERT(ioend->io_type != IOMAP_READ); if (unlikely(ioend->io_error)) return; xfs_ilock(ip, XFS_ILOCK_EXCL); isize = xfs_ioend_new_eof(ioend); if (isize) { ip->i_d.di_size = isize; xfs_mark_inode_dirty_sync(ip); } xfs_iunlock(ip, XFS_ILOCK_EXCL); }
robutest/uclinux
C++
GPL-2.0
60
/* returns true if the PF has set the reset done bit or else false */
static s32 e1000_check_for_rst_vf(struct e1000_hw *hw)
/* returns true if the PF has set the reset done bit or else false */ static s32 e1000_check_for_rst_vf(struct e1000_hw *hw)
{ s32 ret_val = -E1000_ERR_MBX; if (!e1000_check_for_bit_vf(hw, (E1000_V2PMAILBOX_RSTD | E1000_V2PMAILBOX_RSTI))) { ret_val = E1000_SUCCESS; hw->mbx.stats.rsts++; } return ret_val; }
robutest/uclinux
C++
GPL-2.0
60
/* 10.a CLIR suppression No data 10.b CLIR invocation No data 10. Congestion level handled inline 10. Connected number */
static guint16 de_conn_num(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string, int string_len)
/* 10.a CLIR suppression No data 10.b CLIR invocation No data 10. Congestion level handled inline 10. Connected number */ static guint16 de_conn_num(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string, int string_len)
{ const gchar *extr_addr; de_bcd_num(tvb, tree, pinfo, offset, len, hf_gsm_a_dtap_conn_num, &extr_addr); if (extr_addr && add_string) g_snprintf(add_string, string_len, " - (%s)", extr_addr); return (len); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* @num_consumers: Number of consumers @consumers: Consumer data; clients are stored here. */
int regulator_bulk_disable(int num_consumers, struct regulator_bulk_data *consumers)
/* @num_consumers: Number of consumers @consumers: Consumer data; clients are stored here. */ int regulator_bulk_disable(int num_consumers, struct regulator_bulk_data *consumers)
{ int i; int ret; for (i = 0; i < num_consumers; i++) { ret = regulator_disable(consumers[i].consumer); if (ret != 0) goto err; } return 0; err: printk(KERN_ERR "Failed to disable %s: %d\n", consumers[i].supply, ret); for (--i; i >= 0; --i) regulator_enable(consumers[i].consumer); return ret; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Announces that a buffer were filled and request the next */
static void buffer_filled(struct au0828_dev *dev, struct au0828_dmaqueue *dma_q, struct au0828_buffer *buf)
/* Announces that a buffer were filled and request the next */ static void buffer_filled(struct au0828_dev *dev, struct au0828_dmaqueue *dma_q, struct au0828_buffer *buf)
{ au0828_isocdbg("[%p/%d] wakeup\n", buf, buf->vb.i); buf->vb.state = VIDEOBUF_DONE; buf->vb.field_count++; do_gettimeofday(&buf->vb.ts); dev->isoc_ctl.buf = NULL; list_del(&buf->vb.queue); wake_up(&buf->vb.done); }
robutest/uclinux
C++
GPL-2.0
60
/* Calculates 32 bits CRC value of given data, using standart Ethernet CRC function. */
uint32_t mss_ethernet_crc(const uint8_t *data, uint32_t data_length)
/* Calculates 32 bits CRC value of given data, using standart Ethernet CRC function. */ uint32_t mss_ethernet_crc(const uint8_t *data, uint32_t data_length)
{ return mss_mac_crc32( 0xffffffffUL, data, data_length ); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Cleanup interrupt masks, etc after wakeup by power switch */
static void mb93093_power_switch_cleanup(void)
/* Cleanup interrupt masks, etc after wakeup by power switch */ static void mb93093_power_switch_cleanup(void)
{ *(volatile unsigned long *)0xfeff9820 = imask; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Set new values of counters for CNT and INT timers */
static void exynos4210_ltick_set_cntb(struct tick_timer *s, uint32_t new_cnt, uint32_t new_int)
/* Set new values of counters for CNT and INT timers */ static void exynos4210_ltick_set_cntb(struct tick_timer *s, uint32_t new_cnt, uint32_t new_int)
{ uint32_t cnt_stopped = 0; uint32_t int_stopped = 0; if (s->cnt_run) { exynos4210_ltick_cnt_stop(s); cnt_stopped = 1; } if (s->int_run) { exynos4210_ltick_int_stop(s); int_stopped = 1; } s->tcntb = new_cnt + 1; s->icntb = new_int + 1; if (cnt_stopped) { exynos4210_ltick_cnt_start(s); } if (int_stopped) { exynos4210_ltick_int_start(s); } }
ve3wwg/teensy3_qemu
C++
Other
15
/* Set data transfer width. Possible data transfer width is 1-bit, 4-bits or 8-bits. */
static void usdhc_set_data_transfer_width(uint32_t instance, int data_width)
/* Set data transfer width. Possible data transfer width is 1-bit, 4-bits or 8-bits. */ static void usdhc_set_data_transfer_width(uint32_t instance, int data_width)
{ HW_USDHC_PROT_CTRL(instance).U |= (data_width & BM_USDHC_PROT_CTRL_DTW); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Function for splitting UART command bit fields into separate command parameters for the DTM library. */
static uint32_t dtm_cmd_put(uint16_t command)
/* Function for splitting UART command bit fields into separate command parameters for the DTM library. */ static uint32_t dtm_cmd_put(uint16_t command)
{ dtm_cmd_t command_code = (command >> 14) & 0x03; dtm_freq_t freq = (command >> 8) & 0x3F; uint32_t length = (command >> 2) & 0x3F; dtm_pkt_type_t payload = command & 0x03; if (payload == 0x03) { payload = DTM_PKT_VENDORSPECIFIC; } return dtm_cmd(command_code, freq, length, payload); }
labapart/polymcu
C++
null
201
/* __device_refresh - request a refresh from the accelerometer. Does not wait for refresh to complete. Callers must hold hdaps_mtx. */
static void __device_refresh(void)
/* __device_refresh - request a refresh from the accelerometer. Does not wait for refresh to complete. Callers must hold hdaps_mtx. */ static void __device_refresh(void)
{ udelay(200); if (inb(0x1604) != STATE_FRESH) { outb(0x11, 0x1610); outb(0x01, 0x161f); } }
robutest/uclinux
C++
GPL-2.0
60
/* This function is the entrypoint of this module. It installs Driver Binding Protocols together with Component Name Protocols. */
EFI_STATUS EFIAPI InitializeConPlatform(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* This function is the entrypoint of this module. It installs Driver Binding Protocols together with Component Name Protocols. */ EFI_STATUS EFIAPI InitializeConPlatform(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ EFI_STATUS Status; Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gConPlatformTextInDriverBinding, ImageHandle, &gConPlatformComponentName, &gConPlatformComponentName2 ); ASSERT_EFI_ERROR (Status); Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gConPlatformTextOutDriverBinding, NULL, &gConPlatformComponentName, &gConPlatformComponentName2 ); ASSERT_EFI_ERROR (Status); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* qfloat_destroy_obj(): Free all memory allocated by a QFloat object */
static void qfloat_destroy_obj(QObject *obj)
/* qfloat_destroy_obj(): Free all memory allocated by a QFloat object */ static void qfloat_destroy_obj(QObject *obj)
{ assert(obj != NULL); g_free(qobject_to_qfloat(obj)); }
ve3wwg/teensy3_qemu
C++
Other
15
/* Same as fuse_invalidate_entry_cache(), but also try to remove the dentry from the hash */
static void fuse_invalidate_entry(struct dentry *entry)
/* Same as fuse_invalidate_entry_cache(), but also try to remove the dentry from the hash */ static void fuse_invalidate_entry(struct dentry *entry)
{ d_invalidate(entry); fuse_invalidate_entry_cache(entry); }
robutest/uclinux
C++
GPL-2.0
60
/* Initializes the TIMER Output Compare according to the specified parameters in the timer_handle_t and create the associated handle. */
ald_status_t ald_timer_oc_init(ald_timer_handle_t *hperh)
/* Initializes the TIMER Output Compare according to the specified parameters in the timer_handle_t and create the associated handle. */ ald_status_t ald_timer_oc_init(ald_timer_handle_t *hperh)
{ return ald_timer_base_init(hperh); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Waits for auto-negotiation to complete or for the auto-negotiation time limit to expire, which ever happens first. */
static s32 e1000_wait_autoneg(struct e1000_hw *hw)
/* Waits for auto-negotiation to complete or for the auto-negotiation time limit to expire, which ever happens first. */ static s32 e1000_wait_autoneg(struct e1000_hw *hw)
{ s32 ret_val = 0; u16 i, phy_status; for (i = PHY_AUTO_NEG_LIMIT; i > 0; i--) { ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status); if (ret_val) break; ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status); if (ret_val) break; if (phy_status & MII_SR_AUTONEG_COMPLETE) break; msleep(100); } return ret_val; }
robutest/uclinux
C++
GPL-2.0
60
/* This function returns zero in case of success and a negative error code in case of failure. */
static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, void *buf, int len, int used_ebs)
/* This function returns zero in case of success and a negative error code in case of failure. */ static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, void *buf, int len, int used_ebs)
{ int err; if (vol->vol_type == UBI_DYNAMIC_VOLUME) { int l = ALIGN(len, ubi->min_io_size); memset(buf + len, 0xFF, l - len); len = ubi_calc_data_len(ubi, buf, l); if (len == 0) { dbg_gen("all %d bytes contain 0xFF - skip", len); return 0; } err = ubi_eba_write_leb(ubi, vol, lnum, buf, 0, len, UBI_UNKNOWN); } else { memset(buf + len, 0, vol->usable_leb_size - len); err = ubi_eba_write_leb_st(ubi, vol, lnum, buf, len, UBI_UNKNOWN, used_ebs); } return err; }
robutest/uclinux
C++
GPL-2.0
60
/* The default values are as follows. code config->srtccalenable = false; config->srtccalvalue = 0U; endcode param config Pointer to the user's SNVS configuration structure. */
void SNVS_LP_SRTC_GetDefaultConfig(snvs_lp_srtc_config_t *config)
/* The default values are as follows. code config->srtccalenable = false; config->srtccalvalue = 0U; endcode param config Pointer to the user's SNVS configuration structure. */ void SNVS_LP_SRTC_GetDefaultConfig(snvs_lp_srtc_config_t *config)
{ assert(config != NULL); (void)memset(config, 0, sizeof(*config)); config->srtcCalEnable = false; config->srtcCalValue = 0U; }
eclipse-threadx/getting-started
C++
Other
310
/* Get the base address for programs of the given execution engine. */
static int lp5562_get_engine_ram_base_addr(enum lp5562_led_sources engine, uint8_t *base_addr)
/* Get the base address for programs of the given execution engine. */ static int lp5562_get_engine_ram_base_addr(enum lp5562_led_sources engine, uint8_t *base_addr)
{ switch (engine) { case LP5562_SOURCE_ENGINE_1: *base_addr = LP5562_PROG_MEM_ENG1_BASE; break; case LP5562_SOURCE_ENGINE_2: *base_addr = LP5562_PROG_MEM_ENG2_BASE; break; case LP5562_SOURCE_ENGINE_3: *base_addr = LP5562_PROG_MEM_ENG3_BASE; break; default: return -EINVAL; } return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Use an index to get a CRTerm from the expression. */
CRTerm* cr_term_get_from_list(CRTerm *a_this, int itemnr)
/* Use an index to get a CRTerm from the expression. */ CRTerm* cr_term_get_from_list(CRTerm *a_this, int itemnr)
{ CRTerm *cur = NULL ; int nr = 0; g_return_val_if_fail (a_this, NULL) ; for (cur = a_this ; cur ; cur = cur->next) if (nr++ == itemnr) return cur; return NULL; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Get the vector of dragging of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON) */
void lv_indev_get_vect(const lv_indev_t *indev, lv_point_t *point)
/* Get the vector of dragging of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON) */ void lv_indev_get_vect(const lv_indev_t *indev, lv_point_t *point)
{ if(indev->driver.type != LV_INDEV_TYPE_POINTER && indev->driver.type != LV_INDEV_TYPE_BUTTON) { point->x = 0; point->y = 0; } else { point->x = indev->proc.vect.x; point->y = indev->proc.vect.y; } }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Transmitting I2C data. Will busy-wait until the transfer is complete. */
void performI2CTransfer(void)
/* Transmitting I2C data. Will busy-wait until the transfer is complete. */ void performI2CTransfer(void)
{ I2C_TransferSeq_TypeDef i2cTransfer; i2cTransfer.addr = CPT112S_I2C_ADDRESS; i2cTransfer.flags = I2C_FLAG_READ; i2cTransfer.buf[0].data = i2c_rxBuffer; i2cTransfer.buf[0].len = CPT112S_I2C_RXBUFFER_SIZE; I2C_TransferInit(I2C0, &i2cTransfer); while (I2C_Transfer(I2C0) == i2cTransferInProgress); }
remotemcu/remcu-chip-sdks
C++
null
436
/* This file is part of the Simba project. */
static int test_crc_32(void)
/* This file is part of the Simba project. */ static int test_crc_32(void)
{ uint32_t crc; char string[] = "The quick brown fox jumps over the lazy dog"; BTASSERT(crc_32(0, string, strlen(string)) == 0x414fa339); crc = crc_32(0, string, 10); BTASSERT(crc == 0xa3ec1434); BTASSERT(crc_32(crc, &string[10], strlen(string) - 10) == 0x414fa339); return (0); }
eerimoq/simba
C++
Other
337
/* Base on the prompt string id to find the question. */
UINT8* FindQuestionFromStringId(IN HII_IFR_PACKAGE_INSTANCE *FormPackage, IN EFI_STRING_ID KeywordStrId)
/* Base on the prompt string id to find the question. */ UINT8* FindQuestionFromStringId(IN HII_IFR_PACKAGE_INSTANCE *FormPackage, IN EFI_STRING_ID KeywordStrId)
{ UINT8 *OpCodeData; UINT32 Offset; EFI_IFR_STATEMENT_HEADER *StatementHeader; EFI_IFR_OP_HEADER *OpCodeHeader; UINT32 FormDataLen; ASSERT (FormPackage != NULL); FormDataLen = FormPackage->FormPkgHdr.Length - sizeof (EFI_HII_PACKAGE_HEADER); Offset = 0; while (Offset < FormDataLen) { OpCodeData = FormPackage->IfrData + Offset; OpCodeHeader = (EFI_IFR_OP_HEADER *)OpCodeData; if (IsStatementOpCode (OpCodeHeader->OpCode)) { StatementHeader = (EFI_IFR_STATEMENT_HEADER *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER)); if (StatementHeader->Prompt == KeywordStrId) { return OpCodeData; } } Offset += OpCodeHeader->Length; } return NULL; }
tianocore/edk2
C++
Other
4,240
/* Add a sample to the global event buffer. If possible the sample is converted into a persistent dentry/offset pair for later lookup from userspace. Return 0 on failure. */
static int add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
/* Add a sample to the global event buffer. If possible the sample is converted into a persistent dentry/offset pair for later lookup from userspace. Return 0 on failure. */ static int add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
{ unsigned long cookie; off_t offset; if (in_kernel) { add_sample_entry(s->eip, s->event); return 1; } if (!mm) { atomic_inc(&oprofile_stats.sample_lost_no_mm); return 0; } cookie = lookup_dcookie(mm, s->eip, &offset); if (cookie == INVALID_COOKIE) { atomic_inc(&oprofile_stats.sample_lost_no_mapping); return 0; } if (cookie != last_cookie) { add_cookie_switch(cookie); last_cookie = cookie; } add_sample_entry(offset, s->event); return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* NOTE! We have to be ready to update the memory sharing between the file and the memory map for a potential last incomplete page. Ugly, but necessary. */
int vmtruncate(struct inode *inode, loff_t offset)
/* NOTE! We have to be ready to update the memory sharing between the file and the memory map for a potential last incomplete page. Ugly, but necessary. */ int vmtruncate(struct inode *inode, loff_t offset)
{ loff_t oldsize; int error; error = inode_newsize_ok(inode, offset); if (error) return error; oldsize = inode->i_size; i_size_write(inode, offset); truncate_pagecache(inode, oldsize, offset); if (inode->i_op->truncate) inode->i_op->truncate(inode); return error; }
robutest/uclinux
C++
GPL-2.0
60
/* Get the register for the given LED channel used to directly write a brightness value instead of using the execution engines. */
static int lp5562_get_pwm_reg(enum lp5562_led_channels channel, uint8_t *reg)
/* Get the register for the given LED channel used to directly write a brightness value instead of using the execution engines. */ static int lp5562_get_pwm_reg(enum lp5562_led_channels channel, uint8_t *reg)
{ switch (channel) { case LP5562_CHANNEL_W: *reg = LP5562_W_PWM; break; case LP5562_CHANNEL_R: *reg = LP5562_R_PWM; break; case LP5562_CHANNEL_G: *reg = LP5562_G_PWM; break; case LP5562_CHANNEL_B: *reg = LP5562_B_PWM; break; default: LOG_ERR("Invalid channel given."); return -EINVAL; } return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Programs an ISA DMA transfer for the given buffer. */
void snd_dma_program(unsigned long dma, unsigned long addr, unsigned int size, unsigned short mode)
/* Programs an ISA DMA transfer for the given buffer. */ void snd_dma_program(unsigned long dma, unsigned long addr, unsigned int size, unsigned short mode)
{ unsigned long flags; flags = claim_dma_lock(); disable_dma(dma); clear_dma_ff(dma); set_dma_mode(dma, mode); set_dma_addr(dma, addr); set_dma_count(dma, size); if (!(mode & DMA_MODE_NO_ENABLE)) enable_dma(dma); release_dma_lock(flags); }
robutest/uclinux
C++
GPL-2.0
60
/* When user-space is happy that a context is established, it places an entry in the rpcsec_context cache. The key for this cache is the context_handle. The content includes: uid/gidlist - for determining access rights mechanism type mechanism specific information, such as a key */
static int netobj_equal(struct xdr_netobj *a, struct xdr_netobj *b)
/* When user-space is happy that a context is established, it places an entry in the rpcsec_context cache. The key for this cache is the context_handle. The content includes: uid/gidlist - for determining access rights mechanism type mechanism specific information, such as a key */ static int netobj_equal(struct xdr_netobj *a, struct xdr_netobj *b)
{ return a->len == b->len && 0 == memcmp(a->data, b->data, a->len); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* qt_set_parameters function This will fill the default threshold values in the configuration data structure.But User can change the values of these parameters . */
static void qt_set_parameters(void)
/* qt_set_parameters function This will fill the default threshold values in the configuration data structure.But User can change the values of these parameters . */ static void qt_set_parameters(void)
{ qt_config_data.qt_di = DEF_QT_DI; qt_config_data.qt_neg_drift_rate = DEF_QT_NEG_DRIFT_RATE; qt_config_data.qt_pos_drift_rate = DEF_QT_POS_DRIFT_RATE; qt_config_data.qt_max_on_duration = DEF_QT_MAX_ON_DURATION; qt_config_data.qt_drift_hold_time = DEF_QT_DRIFT_HOLD_TIME; qt_config_data.qt_recal_threshold = DEF_QT_RECAL_THRESHOLD; qt_config_data.qt_pos_recal_delay = DEF_QT_POS_RECAL_DELAY; }
remotemcu/remcu-chip-sdks
C++
null
436
/* i8042_filter() filters out unwanted bytes from the input data stream. It is called from i8042_interrupt and thus is running with interrupts off and i8042_lock held. */
static bool i8042_filter(unsigned char data, unsigned char str, struct serio *serio)
/* i8042_filter() filters out unwanted bytes from the input data stream. It is called from i8042_interrupt and thus is running with interrupts off and i8042_lock held. */ static bool i8042_filter(unsigned char data, unsigned char str, struct serio *serio)
{ if (unlikely(i8042_suppress_kbd_ack)) { if ((~str & I8042_STR_AUXDATA) && (data == 0xfa || data == 0xfe)) { i8042_suppress_kbd_ack--; dbg("Extra keyboard ACK - filtered out\n"); return true; } } if (i8042_platform_filter && i8042_platform_filter(data, str, serio)) { dbg("Filtered out by platfrom filter\n"); return true; } return false; }
robutest/uclinux
C++
GPL-2.0
60
/* This API sets the down-sampling rates for Accel FIFO. */
uint16_t bma4_set_fifo_down_accel(uint8_t fifo_down, struct bma4_dev *dev)
/* This API sets the down-sampling rates for Accel FIFO. */ uint16_t bma4_set_fifo_down_accel(uint8_t fifo_down, struct bma4_dev *dev)
{ uint16_t rslt = 0; uint8_t data = 0; if (dev == NULL) { rslt |= BMA4_E_NULL_PTR; } else { rslt |= bma4_read_regs(BMA4_FIFO_DOWN_ADDR, &data, 1, dev); if (rslt == BMA4_OK) { data = BMA4_SET_BITSLICE(data, BMA4_FIFO_DOWN_ACCEL, fifo_down); rslt |= bma4_write_regs(BMA4_FIFO_DOWN_ADDR, &data, 1, dev); } } return rslt; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* UART MSP Initialization This function configures the hardware resources used in this example. */
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
/* UART MSP Initialization This function configures the hardware resources used in this example. */ void HAL_UART_MspInit(UART_HandleTypeDef *huart)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; if(huart->Instance==USART1) { __HAL_RCC_USART1_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_NVIC_SetPriority(USART1_IRQn, 5, 0); HAL_NVIC_EnableIRQ(USART1_IRQn); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* When double tap recognition is enabled, this register expresses the maximum time between two consecutive detected taps to determine a double tap event. The default value of these bits is 0000b which corresponds to 16*ODR_XL time. If the DUR bits are set to a different value, 1LSB corresponds to 32*ODR_XL time.. */
int32_t lsm6dso_tap_dur_set(lsm6dso_ctx_t *ctx, uint8_t val)
/* When double tap recognition is enabled, this register expresses the maximum time between two consecutive detected taps to determine a double tap event. The default value of these bits is 0000b which corresponds to 16*ODR_XL time. If the DUR bits are set to a different value, 1LSB corresponds to 32*ODR_XL time.. */ int32_t lsm6dso_tap_dur_set(lsm6dso_ctx_t *ctx, uint8_t val)
{ lsm6dso_int_dur2_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t*)&reg, 1); if (ret == 0) { reg.dur = val; ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t*)&reg, 1); } return ret; }
alexander-g-dean/ESF
C++
null
41
/* Bare-bones access to getattr: this is for nfs_get_root/nfs_get_sb */
static int nfs3_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fsinfo *info)
/* Bare-bones access to getattr: this is for nfs_get_root/nfs_get_sb */ static int nfs3_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fsinfo *info)
{ int status; status = do_proc_get_root(server->client, fhandle, info); if (status && server->nfs_client->cl_rpcclient != server->client) status = do_proc_get_root(server->nfs_client->cl_rpcclient, fhandle, info); return status; }
robutest/uclinux
C++
GPL-2.0
60
/* Allocate data buffer. Returns -1 if memory allocation fails, else 0. */
int pcap_alloc_databuf(pcap_t *p)
/* Allocate data buffer. Returns -1 if memory allocation fails, else 0. */ int pcap_alloc_databuf(pcap_t *p)
{ p->bufsize = PKTBUFSIZE; p->buffer = malloc(p->bufsize + p->offset); if (p->buffer == NULL) { pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, errno, "malloc"); return (-1); } return (0); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* param base LPUART peripheral base address. param lpuartEdmaHandle LPUART handle pointer. */
void LPUART_TransferEdmaHandleIRQ(LPUART_Type *base, void *lpuartEdmaHandle)
/* param base LPUART peripheral base address. param lpuartEdmaHandle LPUART handle pointer. */ void LPUART_TransferEdmaHandleIRQ(LPUART_Type *base, void *lpuartEdmaHandle)
{ assert(lpuartEdmaHandle != NULL); lpuart_edma_handle_t *handle = (lpuart_edma_handle_t *)lpuartEdmaHandle; LPUART_DisableInterrupts(base, (uint32_t)kLPUART_TransmissionCompleteInterruptEnable); handle->txState = (uint8_t)kLPUART_TxIdle; if (handle->callback != NULL) { handle->callback(base, handle, kStatus_LPUART_TxIdle, handle->userData); } }
eclipse-threadx/getting-started
C++
Other
310
/* Checks for error conditions for no response command. */
static int32_t SDMMC_GetCmdError(CM_SDIOC_TypeDef *SDIOCx)
/* Checks for error conditions for no response command. */ static int32_t SDMMC_GetCmdError(CM_SDIOC_TypeDef *SDIOCx)
{ __IO uint32_t u32Count; int32_t i32Ret = LL_OK; u32Count = SDMMC_CMD_TIMEOUT * (HCLK_VALUE / 20000UL); while (RESET == SDIOC_GetIntStatus(SDIOCx, SDIOC_INT_FLAG_CC)) { if (0UL == u32Count) { i32Ret = LL_ERR_TIMEOUT; break; } u32Count--; } if (LL_OK == i32Ret) { SDIOC_ClearIntStatus(SDIOCx, SDIOC_INT_STATIC_FLAGS); } return i32Ret; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* SPI MSP Initialization This function configures the hardware resources used in this example: */
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
/* SPI MSP Initialization This function configures the hardware resources used in this example: */ void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
{ GPIO_InitTypeDef GPIO_InitStruct; SPIx_SCK_GPIO_CLK_ENABLE(); SPIx_MISO_GPIO_CLK_ENABLE(); SPIx_MOSI_GPIO_CLK_ENABLE(); GPIO_InitStruct.Pin = SPIx_SCK_PIN; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLDOWN; GPIO_InitStruct.Speed = GPIO_SPEED_FAST; GPIO_InitStruct.Alternate = SPIx_SCK_AF; HAL_GPIO_Init(SPIx_SCK_GPIO_PORT, &GPIO_InitStruct); GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Pin = SPIx_MISO_PIN; HAL_GPIO_Init(SPIx_MISO_GPIO_PORT, &GPIO_InitStruct); GPIO_InitStruct.Pin = SPIx_MOSI_PIN; HAL_GPIO_Init(SPIx_MOSI_GPIO_PORT, &GPIO_InitStruct); SPIx_CLK_ENABLE(); }
STMicroelectronics/STM32CubeF4
C++
Other
789