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
/* param base DCDC peripheral base address. param config Pointer to configuration structure. See to "dcdc_internal_regulator_config_t". */
void DCDC_SetInternalRegulatorConfig(DCDC_Type *base, const dcdc_internal_regulator_config_t *config)
/* param base DCDC peripheral base address. param config Pointer to configuration structure. See to "dcdc_internal_regulator_config_t". */ void DCDC_SetInternalRegulatorConfig(DCDC_Type *base, const dcdc_internal_regulator_config_t *config)
{ assert(NULL != config); uint32_t tmp32; tmp32 = base->REG3 & ~DCDC_REG3_REG_FBK_SEL_MASK; tmp32 |= DCDC_REG3_REG_FBK_SEL(config->feedbackPoint); base->REG3 = tmp32; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Walk the tree, resetting CONFIGFS_USET_DROPPING wherever it was set. */
static void configfs_detach_rollback(struct dentry *dentry)
/* Walk the tree, resetting CONFIGFS_USET_DROPPING wherever it was set. */ static void configfs_detach_rollback(struct dentry *dentry)
{ struct configfs_dirent *parent_sd = dentry->d_fsdata; struct configfs_dirent *sd; parent_sd->s_type &= ~CONFIGFS_USET_DROPPING; list_for_each_entry(sd, &parent_sd->s_children, s_sibling) if (sd->s_type & CONFIGFS_USET_DEFAULT) configfs_detach_rollback(sd->s_dentry); }
robutest/uclinux
C++
GPL-2.0
60
/* This function should return TRUE if the socket is to be assumed to be dead. Most commonly this happens when the server has closed the connection due to inactivity. */
static bool SocketIsDead(curl_socket_t sock)
/* This function should return TRUE if the socket is to be assumed to be dead. Most commonly this happens when the server has closed the connection due to inactivity. */ static bool SocketIsDead(curl_socket_t sock)
{ int sval; bool ret_val = TRUE; sval = SOCKET_READABLE(sock, 0); if(sval == 0) ret_val = FALSE; return ret_val; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* This is a temperary function which will be removed when EfiReleaseLock() in UefiLib can handle the call in UEFI Runtimer driver in RT phase. It calls EfiReleaseLock() at boot time and simply returns at runtime. */
VOID ReleaseLockOnlyAtBootTime(IN EFI_LOCK *Lock)
/* This is a temperary function which will be removed when EfiReleaseLock() in UefiLib can handle the call in UEFI Runtimer driver in RT phase. It calls EfiReleaseLock() at boot time and simply returns at runtime. */ VOID ReleaseLockOnlyAtBootTime(IN EFI_LOCK *Lock)
{ if (!AtRuntime ()) { EfiReleaseLock (Lock); } }
tianocore/edk2
C++
Other
4,240
/* check the target process has a UID that matches the current process's */
static bool check_same_owner(struct task_struct *p)
/* check the target process has a UID that matches the current process's */ static bool check_same_owner(struct task_struct *p)
{ const struct cred *cred = current_cred(), *pcred; bool match; rcu_read_lock(); pcred = __task_cred(p); match = (cred->euid == pcred->euid || cred->euid == pcred->uid); rcu_read_unlock(); return match; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* adv_async_callback() - Adv Library asynchronous event callback function. */
static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
/* adv_async_callback() - Adv Library asynchronous event callback function. */ static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
{ switch (code) { case ADV_ASYNC_SCSI_BUS_RESET_DET: ASC_DBG(0, "ADV_ASYNC_SCSI_BUS_RESET_DET\n"); break; case ADV_ASYNC_RDMA_FAILURE: ASC_DBG(0, "ADV_ASYNC_RDMA_FAILURE\n"); AdvResetChipAndSB(adv_dvc_varp); break; case ADV_HOST_SCSI_BUS_RESET: ASC_DBG(0, "ADV_HOST_SCSI_BUS_RESET\n"); break; default: ASC_DBG(0, "unknown code 0x%x\n", code); break; } }
robutest/uclinux
C++
GPL-2.0
60
/* Check if the output descriptor has something connected to the slave side. */
int np_uart_slave_connected(int fd)
/* Check if the output descriptor has something connected to the slave side. */ int np_uart_slave_connected(int fd)
{ struct pollfd pfd = { .fd = fd, .events = POLLHUP }; int ret; ret = poll(&pfd, 1, 0); if (ret == -1) { int err = errno; if (err != EINTR) { ERROR("%s: unexpected error during poll, errno=%i,%s\n", __func__, err, strerror(err)); } } if (!(pfd.revents & POLLHUP)) { return 1; } return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* This re-enables EDMA hardware events on the specified channel. */
void edma_resume(unsigned channel)
/* This re-enables EDMA hardware events on the specified channel. */ void edma_resume(unsigned channel)
{ unsigned ctlr; ctlr = EDMA_CTLR(channel); channel = EDMA_CHAN_SLOT(channel); if (channel < edma_cc[ctlr]->num_channels) { unsigned int mask = BIT(channel & 0x1f); edma_shadow0_write_array(ctlr, SH_EESR, channel >> 5, mask); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* writes a WiFi header conversion record in NPE linear format */
IX_ETH_DB_PRIVATE void ixEthDBNPEWiFiNodeWrite(void *address, MacTreeNode *node)
/* writes a WiFi header conversion record in NPE linear format */ IX_ETH_DB_PRIVATE void ixEthDBNPEWiFiNodeWrite(void *address, MacTreeNode *node)
{ memcpy(address, node->descriptor->macAddress, IX_IEEE803_MAC_ADDRESS_SIZE); NPE_NODE_BYTE(address, IX_EDB_NPE_NODE_WIFI_INDEX_OFFSET) = node->descriptor->recordData.wifiData.gwAddressIndex; NPE_NODE_BYTE(address, IX_EDB_NPE_NODE_WIFI_FLAGS_OFFSET) = node->descriptor->recordData.wifiData.type << 1 | IX_EDB_FLAGS_VALID; }
EmcraftSystems/u-boot
C++
Other
181
/* Returns the interrupt number of SSI module . */
static uint32_t _SSIIntNumberGet(uint32_t ui32Base)
/* Returns the interrupt number of SSI module . */ static uint32_t _SSIIntNumberGet(uint32_t ui32Base)
{ uint_fast8_t ui8Idx, ui8Rows; const uint32_t (*ppui32SSIIntMap)[2]; ASSERT(_SSIBaseValid(ui32Base)); ppui32SSIIntMap = g_ppui32SSIIntMap; ui8Rows = g_ui8SSIIntMapRows; if(CLASS_IS_TM4C129) { ppui32SSIIntMap = g_ppui32SSIIntMapSnowflake; ui8Rows = g_ui8SSIIntMapSnowflakeRows; } for(ui8Idx = 0; ui8Idx < ui8Rows; ui8Idx++) { if(ppui32SSIIntMap[ui8Idx][0] == ui32Base) { return(ppui32SSIIntMap[ui8Idx][1]); } } return(0); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* A bootcount driver for the RTC IP block found on many TI platforms. This requires the RTC clocks, etc, to be enabled prior to use and not all boards with this IP block on it will have the RTC in use. */
void bootcount_store(ulong a)
/* A bootcount driver for the RTC IP block found on many TI platforms. This requires the RTC clocks, etc, to be enabled prior to use and not all boards with this IP block on it will have the RTC in use. */ void bootcount_store(ulong a)
{ struct davinci_rtc *reg = (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR; writel(RTC_KICK0R_WE, &reg->kick0r); writel(RTC_KICK1R_WE, &reg->kick1r); raw_bootcount_store(&reg->scratch2, (CONFIG_SYS_BOOTCOUNT_MAGIC & 0xffff0000) | (a & 0x0000ffff)); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Create a window and return its pointer. Use */
struct win_window* win_create(struct win_window *parent, const struct win_attributes *attributes)
/* Create a window and return its pointer. Use */ struct win_window* win_create(struct win_window *parent, const struct win_attributes *attributes)
{ struct win_window *win; Assert(parent != NULL); Assert(attributes != NULL); win = membag_alloc(sizeof(struct win_window)); if (!win) { return NULL; } win->attributes = *attributes; win->is_mapped = false; win->top_child = NULL; win_add_top_child(parent, win); return win; }
memfault/zero-to-main
C++
null
200
/* Program a word (32bit) in the flash device. */
int NORFLASH_ProgramWord32(uint32_t addr, uint32_t data)
/* Program a word (32bit) in the flash device. */ int NORFLASH_ProgramWord32(uint32_t addr, uint32_t data)
{ int status; if (addr & 3) return NORFLASH_MISALIGNED_ADDRESS; status = NORFLASH_ProgramWord16(addr, data & 0xFFFF); if (status == NORFLASH_STATUS_OK) { addr += 2; status = NORFLASH_ProgramWord16(addr, data >> 16); } return status; }
remotemcu/remcu-chip-sdks
C++
null
436
/* This function is called when an UDP datagrm has been received on the port UDP_PORT. */
static void receive_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
/* This function is called when an UDP datagrm has been received on the port UDP_PORT. */ static void receive_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
{ if (p) { printf("Msg received port:%d len:%d\n", port, p->len); uint8_t *buf = (uint8_t*) p->payload; printf("Msg received port:%d len:%d\nbuf: %s\n", port, p->len, buf); send_udp(upcb, addr, port); pbuf_free(p); } }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI PciSegmentWrite32(IN UINT64 Address, IN UINT32 Value)
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */ UINT32 EFIAPI PciSegmentWrite32(IN UINT64 Address, IN UINT32 Value)
{ ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 3); return PciWrite32 (PCI_SEGMENT_TO_PCI_ADDRESS (Address), Value); }
tianocore/edk2
C++
Other
4,240
/* Checks whether the specified RCC interrupt has occurred or not. */
ITStatus RCC_GetITStatus(RCC_IT_TypeDef it)
/* Checks whether the specified RCC interrupt has occurred or not. */ ITStatus RCC_GetITStatus(RCC_IT_TypeDef it)
{ return (ITStatus)READ_BIT(RCC->CIR, (it << RCC_CIR_LSIRDYF_Pos)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function searchs pending requests to the object */
static void coroutine_fn send_pending_req(BDRVSheepdogState *s, uint64_t oid)
/* This function searchs pending requests to the object */ static void coroutine_fn send_pending_req(BDRVSheepdogState *s, uint64_t oid)
{ AIOReq *aio_req; SheepdogAIOCB *acb; while ((aio_req = find_pending_req(s, oid)) != NULL) { acb = aio_req->aiocb; QLIST_REMOVE(aio_req, aio_siblings); QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings); add_aio_request(s, aio_req, acb->qiov->iov, acb->qiov->niov, false, acb->aiocb_type); } }
ve3wwg/teensy3_qemu
C++
Other
15
/* Returns the current status of the EEFC. Keep in mind that this function clears the value of some status bits (LOCKE, PROGE). */
unsigned int EFC_GetStatus(AT91S_EFC *pEfc)
/* Returns the current status of the EEFC. Keep in mind that this function clears the value of some status bits (LOCKE, PROGE). */ unsigned int EFC_GetStatus(AT91S_EFC *pEfc)
{ return pEfc->EFC_FSR; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* 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_data *conn = getconnection(L); if (lua_toboolean(L, 2)) { conn->auto_commit = 1; sqlite3_exec(conn->sql_conn, "ROLLBACK", NULL, NULL, NULL); } else { char *errmsg; int res; conn->auto_commit = 0; res = sqlite3_exec(conn->sql_conn, "BEGIN", NULL, NULL, &errmsg); if (res != SQLITE_OK) { lua_pushliteral(L, LUASQL_PREFIX); lua_pushstring(L, errmsg); sqlite3_free(errmsg); lua_concat(L, 2); lua_error(L); } } lua_pushboolean(L, 1); return 1; }
DC-SWAT/DreamShell
C++
null
404
/* A LEB may have fallen off of the bottom of a heap, and ended up as uncategorized even though it has enough space for us now. If that is the case this function will put the LEB back onto a heap. */
void ubifs_ensure_cat(struct ubifs_info *c, struct ubifs_lprops *lprops)
/* A LEB may have fallen off of the bottom of a heap, and ended up as uncategorized even though it has enough space for us now. If that is the case this function will put the LEB back onto a heap. */ void ubifs_ensure_cat(struct ubifs_info *c, struct ubifs_lprops *lprops)
{ int cat = lprops->flags & LPROPS_CAT_MASK; if (cat != LPROPS_UNCAT) return; cat = ubifs_categorize_lprops(c, lprops); if (cat == LPROPS_UNCAT) return; ubifs_remove_from_cat(c, lprops, LPROPS_UNCAT); ubifs_add_to_cat(c, lprops, cat); }
EmcraftSystems/u-boot
C++
Other
181
/* ioat_dma_do_interrupt_msix - handler used for vector-per-channel interrupt mode @irq: interrupt id @data: interrupt data */
static irqreturn_t ioat_dma_do_interrupt_msix(int irq, void *data)
/* ioat_dma_do_interrupt_msix - handler used for vector-per-channel interrupt mode @irq: interrupt id @data: interrupt data */ static irqreturn_t ioat_dma_do_interrupt_msix(int irq, void *data)
{ struct ioat_chan_common *chan = data; tasklet_schedule(&chan->cleanup_task); return IRQ_HANDLED; }
robutest/uclinux
C++
GPL-2.0
60
/* Fills each ADC_InitStruct member with its default value. */
void ADC_StructInit(ADC_InitTypeDef *ADC_InitStruct)
/* Fills each ADC_InitStruct member with its default value. */ void ADC_StructInit(ADC_InitTypeDef *ADC_InitStruct)
{ ADC_InitStruct->ADC_Resolution = ADC_Resolution_12b; ADC_InitStruct->ADC_ScanConvMode = DISABLE; ADC_InitStruct->ADC_ContinuousConvMode = DISABLE; ADC_InitStruct->ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; ADC_InitStruct->ADC_ExternalTrigConv = ADC_ExternalTrigConv_T2_CC2; ADC_InitStruct->ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStruct->ADC_NbrOfConversion = 1; }
avem-labs/Avem
C++
MIT License
1,752
/* Sets the pin mode and configures the pin for use by UART peripheral */
void PinTypeUART(unsigned long ulPin, unsigned long ulPinMode)
/* Sets the pin mode and configures the pin for use by UART peripheral */ void PinTypeUART(unsigned long ulPin, unsigned long ulPinMode)
{ PinModeSet(ulPin,ulPinMode); PinConfigSet(ulPin,PIN_STRENGTH_2MA,PIN_TYPE_STD); }
micropython/micropython
C++
Other
18,334
/* Note that in contrast to strncpy, strncat ensures the result is terminated. */
char* strncat(char *dest, const char *src, size_t n)
/* Note that in contrast to strncpy, strncat ensures the result is terminated. */ char* strncat(char *dest, const char *src, size_t n)
{ size_t len = __strnend(src, n) - src; char *p = __strend(dest); p[len] = '\0'; __builtin_memcpy(p, src, len); return dest; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Locking: takes tty_ldisc_lock to guard against ldisc races */
static struct tty_ldisc* tty_ldisc_get(int disc)
/* Locking: takes tty_ldisc_lock to guard against ldisc races */ static struct tty_ldisc* tty_ldisc_get(int disc)
{ struct tty_ldisc *ld; struct tty_ldisc_ops *ldops; if (disc < N_TTY || disc >= NR_LDISCS) return ERR_PTR(-EINVAL); ldops = get_ldops(disc); if (IS_ERR(ldops)) { request_module("tty-ldisc-%d", disc); ldops = get_ldops(disc); if (IS_ERR(ldops)) return ERR_CAST(ldops); } ld = kmalloc(sizeof(struct tty_ldisc), GFP_KERNEL); if (ld == NULL) { put_ldops(ldops); return ERR_PTR(-ENOMEM); } ld->ops = ldops; atomic_set(&ld->users, 1); return ld; }
robutest/uclinux
C++
GPL-2.0
60
/* Create all handles associate with every device path node. */
EFI_STATUS ShellConnectDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect)
/* Create all handles associate with every device path node. */ EFI_STATUS ShellConnectDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect)
{ EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath; EFI_STATUS Status; EFI_HANDLE Handle; EFI_HANDLE PreviousHandle; if (DevicePathToConnect == NULL) { return EFI_INVALID_PARAMETER; } PreviousHandle = NULL; do { RemainingDevicePath = DevicePathToConnect; Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle); if (!EFI_ERROR (Status) && (Handle != NULL)) { if (PreviousHandle == Handle) { Status = EFI_NOT_FOUND; } else { PreviousHandle = Handle; Status = gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE); } } } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath)); return Status; }
tianocore/edk2
C++
Other
4,240
/* Reset the board. This honors the por_cfg registers. */
void __cpld_reset(void)
/* Reset the board. This honors the por_cfg registers. */ void __cpld_reset(void)
{ CPLD_WRITE(system_rst, 1); }
4ms/stm32mp1-baremetal
C++
Other
137
/* We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */
void eprom_cs(struct net_device *dev, short bit)
/* We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ void eprom_cs(struct net_device *dev, short bit)
{ if(bit) write_nic_byte(dev, EPROM_CMD, (1<<EPROM_CS_SHIFT) | \ read_nic_byte(dev, EPROM_CMD)); else write_nic_byte(dev, EPROM_CMD, read_nic_byte(dev, EPROM_CMD)\ &~(1<<EPROM_CS_SHIFT)); force_pci_posting(dev); udelay(EPROM_DELAY); }
robutest/uclinux
C++
GPL-2.0
60
/* Fish for pollable events on the pollfd->fd file descriptor. We're only interested in events matching the pollfd->events mask, and the result matching that mask is both recorded in pollfd->revents and returned. The pwait poll_table will be used by the fd-provided poll handler for waiting, if non-NULL. */
static unsigned int do_pollfd(struct pollfd *pollfd, poll_table *pwait)
/* Fish for pollable events on the pollfd->fd file descriptor. We're only interested in events matching the pollfd->events mask, and the result matching that mask is both recorded in pollfd->revents and returned. The pwait poll_table will be used by the fd-provided poll handler for waiting, if non-NULL. */ static unsigned int do_pollfd(struct pollfd *pollfd, poll_table *pwait)
{ unsigned int mask; int fd; mask = 0; fd = pollfd->fd; if (fd >= 0) { int fput_needed; struct file * file; file = fget_light(fd, &fput_needed); mask = POLLNVAL; if (file != NULL) { mask = DEFAULT_POLLMASK; if (file->f_op && file->f_op->poll) { if (pwait) pwait->key = pollfd->events | POLLERR | POLLHUP; mask = file->f_op->poll(file, pwait); } mask &= pollfd->events | POLLERR | POLLHUP; fput_light(file, fput_needed); } } pollfd->revents = mask; return mask; }
robutest/uclinux
C++
GPL-2.0
60
/* This function walks LBC banks comparing "Base address" field of the BR registers with the supplied addr_base argument. When bases match this function returns bank number (starting with 0), otherwise it returns appropriate errno value. */
int fsl_lbc_find(phys_addr_t addr_base)
/* This function walks LBC banks comparing "Base address" field of the BR registers with the supplied addr_base argument. When bases match this function returns bank number (starting with 0), otherwise it returns appropriate errno value. */ int fsl_lbc_find(phys_addr_t addr_base)
{ int i; if (!fsl_lbc_regs) return -ENODEV; for (i = 0; i < ARRAY_SIZE(fsl_lbc_regs->bank); i++) { __be32 br = in_be32(&fsl_lbc_regs->bank[i].br); __be32 or = in_be32(&fsl_lbc_regs->bank[i].or); if (br & BR_V && (br & or & BR_BA) == addr_base) return i; } return -ENOENT; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Called for opcodes which are illegal and which are known to result in a SIGILL with a real 80486. */
void FPU_illegal(void)
/* Called for opcodes which are illegal and which are known to result in a SIGILL with a real 80486. */ void FPU_illegal(void)
{ math_abort(FPU_info, SIGILL); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Restart the card from scratch, as if from a cold-boot. At this point, the card has exprienced a hard reset, followed by fixups by BIOS, and has its config space set up identically to what it was at cold boot. */
static pci_ers_result_t s2io_io_slot_reset(struct pci_dev *pdev)
/* Restart the card from scratch, as if from a cold-boot. At this point, the card has exprienced a hard reset, followed by fixups by BIOS, and has its config space set up identically to what it was at cold boot. */ static pci_ers_result_t s2io_io_slot_reset(struct pci_dev *pdev)
{ struct net_device *netdev = pci_get_drvdata(pdev); struct s2io_nic *sp = netdev_priv(netdev); if (pci_enable_device(pdev)) { pr_err("Cannot re-enable PCI device after reset.\n"); return PCI_ERS_RESULT_DISCONNECT; } pci_set_master(pdev); s2io_reset(sp); return PCI_ERS_RESULT_RECOVERED; }
robutest/uclinux
C++
GPL-2.0
60
/* netxen_decode_crb_addr(0 - utility to translate from internal Phantom CRB address to external PCI CRB address. */
static u32 netxen_decode_crb_addr(u32 addr)
/* netxen_decode_crb_addr(0 - utility to translate from internal Phantom CRB address to external PCI CRB address. */ static u32 netxen_decode_crb_addr(u32 addr)
{ int i; u32 base_addr, offset, pci_base; crb_addr_transform_setup(); pci_base = NETXEN_ADDR_ERROR; base_addr = addr & 0xfff00000; offset = addr & 0x000fffff; for (i = 0; i < NETXEN_MAX_CRB_XFORM; i++) { if (crb_addr_xform[i] == base_addr) { pci_base = i << 20; break; } } if (pci_base == NETXEN_ADDR_ERROR) return pci_base; else return (pci_base + offset); }
robutest/uclinux
C++
GPL-2.0
60
/* Probe the given I2C chip address. Returns 0 if a chip responded, not 0 on failure. */
int i2c_probe(uchar chip)
/* Probe the given I2C chip address. Returns 0 if a chip responded, not 0 on failure. */ int i2c_probe(uchar chip)
{ printf("i2c_probe chip %d\n", (int) chip); return -1; }
EmcraftSystems/u-boot
C++
Other
181
/* Calculates the 16-bit CRC according to the Modbus RTU specification. */
static uint16_t XcpTpMbRtuCrcCalculate(uint8_t const *data, uint16_t len)
/* Calculates the 16-bit CRC according to the Modbus RTU specification. */ static uint16_t XcpTpMbRtuCrcCalculate(uint8_t const *data, uint16_t len)
{ uint16_t result = 0; uint8_t locCRCHi = 0xFF; uint8_t locCRCLo = 0xFF; uint16_t idx; assert((data != NULL) && (len > 0)); if ((data != NULL) && (len > 0)) { while (len--) { idx = locCRCLo ^ *data++; locCRCLo = locCRCHi ^ CRCHi[idx]; locCRCHi = CRCLo[idx]; } result = (locCRCHi << 8 | locCRCLo); } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Variables are stored by the firmware and may maintain their values across power cycles. Each vendor may create and manage its own variables without the risk of name conflicts by using a unique VendorGuid. */
EFI_STATUS EFIAPI EfiSetVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
/* Variables are stored by the firmware and may maintain their values across power cycles. Each vendor may create and manage its own variables without the risk of name conflicts by using a unique VendorGuid. */ EFI_STATUS EFIAPI EfiSetVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
{ return mInternalRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data); }
tianocore/edk2
C++
Other
4,240
/* returns the corresponding ascii symbol value for the given base64 code */
static char getsymbol(unsigned char code)
/* returns the corresponding ascii symbol value for the given base64 code */ static char getsymbol(unsigned char code)
{ if (code == BASE64_SLASH) { return '/'; } if (code == BASE64_PLUS) { return '+'; } if (code <= BASE64_CAPITAL_UPPER_BOUND) { return (code + 'A'); } if (code <= BASE64_SMALL_UPPER_BOUND) { return (code + ('z' - BASE64_SMALL_UPPER_BOUND)); } if (code <= BASE64_NUMBER_UPPER_BOUND) { return (code + ('9' - BASE64_NUMBER_UPPER_BOUND)); } return (char)BASE64_NOT_DEFINED; }
labapart/polymcu
C++
null
201
/* On 64-bit architectures, the check is hopefully optimized away by the compiler. */
static int ntfs_dir_open(struct inode *vi, struct file *filp)
/* On 64-bit architectures, the check is hopefully optimized away by the compiler. */ static int ntfs_dir_open(struct inode *vi, struct file *filp)
{ if (sizeof(unsigned long) < 8) { if (i_size_read(vi) > MAX_LFS_FILESIZE) return -EFBIG; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns CR_OK upon succesful completion, an error code otherwise. */
enum CRStatus cr_parser_get_parsing_location(CRParser *a_this, CRParsingLocation *a_loc)
/* Returns CR_OK upon succesful completion, an error code otherwise. */ enum CRStatus cr_parser_get_parsing_location(CRParser *a_this, CRParsingLocation *a_loc)
{ g_return_val_if_fail (a_this && PRIVATE (a_this) && a_loc, CR_BAD_PARAM_ERROR) ; return cr_tknzr_get_parsing_location (PRIVATE (a_this)->tknzr, a_loc) ; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This API is used to get the operation mode of the sensor. */
int8_t bme68x_get_op_mode(uint8_t *op_mode, struct bme68x_dev *dev)
/* This API is used to get the operation mode of the sensor. */ int8_t bme68x_get_op_mode(uint8_t *op_mode, struct bme68x_dev *dev)
{ int8_t rslt; uint8_t mode; if (op_mode) { rslt = bme68x_get_regs(BME68X_REG_CTRL_MEAS, &mode, 1, dev); *op_mode = mode & BME68X_MODE_MSK; } else { rslt = BME68X_E_NULL_PTR; } return rslt; }
eclipse-threadx/getting-started
C++
Other
310
/* If Cert is NULL, then return FALSE. If CertSize is 0, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI CryptoServiceX509GetSerialNumber(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *SerialNumber, OPTIONAL IN OUT UINTN *SerialNumberSize)
/* If Cert is NULL, then return FALSE. If CertSize is 0, then return FALSE. If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI CryptoServiceX509GetSerialNumber(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *SerialNumber, OPTIONAL IN OUT UINTN *SerialNumberSize)
{ return CALL_BASECRYPTLIB (X509.Services.GetSerialNumber, X509GetSerialNumber, (Cert, CertSize, SerialNumber, SerialNumberSize), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Decreases the reference count of the current instance of #CRStyle. If the reference count reaches 0, the instance of #CRStyle is destoyed. */
gboolean cr_style_unref(CRStyle *a_this)
/* Decreases the reference count of the current instance of #CRStyle. If the reference count reaches 0, the instance of #CRStyle is destoyed. */ gboolean cr_style_unref(CRStyle *a_this)
{ g_return_val_if_fail (a_this, FALSE); if (a_this->ref_count) a_this->ref_count--; if (!a_this->ref_count) { cr_style_destroy (a_this); return TRUE; } return FALSE; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* NOTE: this is only used when the mbuf is created by the controller; it should not be used for data packets (ACL data packets) that come from the host. This routine assumes that the entire pdu length can fit in one mbuf contiguously. */
void ble_ll_mbuf_init(struct os_mbuf *m, uint8_t pdulen, uint8_t hdr)
/* NOTE: this is only used when the mbuf is created by the controller; it should not be used for data packets (ACL data packets) that come from the host. This routine assumes that the entire pdu length can fit in one mbuf contiguously. */ void ble_ll_mbuf_init(struct os_mbuf *m, uint8_t pdulen, uint8_t hdr)
{ struct ble_mbuf_hdr *ble_hdr; m->om_len = pdulen; OS_MBUF_PKTHDR(m)->omp_len = pdulen; ble_hdr = BLE_MBUF_HDR_PTR(m); ble_hdr->txinfo.flags = 0; ble_hdr->txinfo.offset = 0; ble_hdr->txinfo.pyld_len = pdulen; ble_hdr->txinfo.hdr_byte = hdr; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* This function returns the size, in bytes, of the device path data structure specified by DevicePath including the end of device path node. If DevicePath is NULL or invalid, then 0 is returned. */
UINTN EFIAPI GetDevicePathSize(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
/* This function returns the size, in bytes, of the device path data structure specified by DevicePath including the end of device path node. If DevicePath is NULL or invalid, then 0 is returned. */ UINTN EFIAPI GetDevicePathSize(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
{ return UefiDevicePathLibGetDevicePathSize (DevicePath); }
tianocore/edk2
C++
Other
4,240
/* Probe the given I2C chip address. Returns 0 if a chip responded, not 0 on failure. */
int i2c_probe(uint8_t chip)
/* Probe the given I2C chip address. Returns 0 if a chip responded, not 0 on failure. */ int i2c_probe(uint8_t chip)
{ return I2C_ADAP->probe(I2C_ADAP, chip); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Send a command from interrupt state. If there is a command currently being executed then we return an error of -1. It simply isn't viable to wait around as commands may be slow. This can theoretically be starved on SMP, but it's hard to see a realistic situation. We do not wait for the command to complete */
static int mc32_command_nowait(struct net_device *dev, u16 cmd, void *data, int len)
/* Send a command from interrupt state. If there is a command currently being executed then we return an error of -1. It simply isn't viable to wait around as commands may be slow. This can theoretically be starved on SMP, but it's hard to see a realistic situation. We do not wait for the command to complete */ static int mc32_command_nowait(struct net_device *dev, u16 cmd, void *data, int len)
{ struct mc32_local *lp = netdev_priv(dev); int ioaddr = dev->base_addr; int ret = -1; if (down_trylock(&lp->cmd_mutex) == 0) { lp->cmd_nonblocking=1; lp->exec_box->mbox=0; lp->exec_box->mbox=cmd; memcpy((void *)lp->exec_box->data, data, len); barrier(); mc32_ready_poll(dev); outb(1<<6, ioaddr+HOST_CMD); ret = 0; } return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* param base Pointer to the FlexIO simulated peripheral type. param handle Pointer to the handler for FlexIO simulated peripheral. param isr FlexIO simulated peripheral interrupt handler. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */
status_t FLEXIO_RegisterHandleIRQ(void *base, void *handle, flexio_isr_t isr)
/* param base Pointer to the FlexIO simulated peripheral type. param handle Pointer to the handler for FlexIO simulated peripheral. param isr FlexIO simulated peripheral interrupt handler. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */ status_t FLEXIO_RegisterHandleIRQ(void *base, void *handle, flexio_isr_t isr)
{ assert(base != NULL); assert(handle != NULL); assert(isr != NULL); uint8_t index; for (index = 0U; index < (uint8_t)FLEXIO_HANDLE_COUNT; index++) { if (s_flexioHandle[index] == NULL) { s_flexioType[index] = base; s_flexioHandle[index] = handle; s_flexioIsr[index] = isr; break; } } if (index == (uint8_t)FLEXIO_HANDLE_COUNT) { return kStatus_OutOfRange; } else { return kStatus_Success; } }
eclipse-threadx/getting-started
C++
Other
310
/* This API sets the FIFO watermark level in the sensor. */
int8_t bmi160_set_fifo_wm(uint8_t fifo_wm, const struct bmi160_dev *dev)
/* This API sets the FIFO watermark level in the sensor. */ int8_t bmi160_set_fifo_wm(uint8_t fifo_wm, const struct bmi160_dev *dev)
{ int8_t rslt = 0; uint8_t data = fifo_wm; uint8_t reg_addr = BMI160_FIFO_CONFIG_0_ADDR; if (dev == NULL) { rslt = BMI160_E_NULL_PTR; } else { rslt = bmi160_set_regs(reg_addr, &data, BMI160_ONE, dev); } return rslt; }
eclipse-threadx/getting-started
C++
Other
310
/* In TDX a serial of TdIoRead32 is invoked to read data from the I/O port. */
VOID EFIAPI TdIoReadFifo32(IN UINTN Port, IN UINTN Count, OUT VOID *Buffer)
/* In TDX a serial of TdIoRead32 is invoked to read data from the I/O port. */ VOID EFIAPI TdIoReadFifo32(IN UINTN Port, IN UINTN Count, OUT VOID *Buffer)
{ UINT32 *Buf32; UINTN Index; Buf32 = (UINT32 *)Buffer; for (Index = 0; Index < Count; Index++) { Buf32[Index] = TdIoRead32 (Port); } }
tianocore/edk2
C++
Other
4,240
/* convert an IE from Gigaset hex string to ETSI binary representation including length byte return value: result length, -1 on error */
static int encode_ie(char *in, u8 *out, int maxlen)
/* convert an IE from Gigaset hex string to ETSI binary representation including length byte return value: result length, -1 on error */ static int encode_ie(char *in, u8 *out, int maxlen)
{ int l = 0; while (*in) { if (!ishexdigit(in[0]) || !ishexdigit(in[1]) || l >= maxlen) return -1; out[++l] = (hex2bin(in[0]) << 4) + hex2bin(in[1]); in += 2; } out[0] = l; return l; }
robutest/uclinux
C++
GPL-2.0
60
/* VM output consumer callback. Each time the virtual machine generates some outputs, the following function gets called by the underlying virtual machine to consume the generated output. All this function does is redirecting the VM output to STDOUT. This function is registered later via a call to ph7_vm_config() with a configuration verb set to: PH7_VM_CONFIG_OUTPUT. */
static int Output_Consumer(const void *pOutput, unsigned int nOutputLen, void *pUserData)
/* VM output consumer callback. Each time the virtual machine generates some outputs, the following function gets called by the underlying virtual machine to consume the generated output. All this function does is redirecting the VM output to STDOUT. This function is registered later via a call to ph7_vm_config() with a configuration verb set to: PH7_VM_CONFIG_OUTPUT. */ static int Output_Consumer(const void *pOutput, unsigned int nOutputLen, void *pUserData)
{ printf("%.*s", nOutputLen, (const char *)pOutput ); return PH7_OK; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Open an image. Try the created image decoder one by one. Once one is able to open the image that decoder is save in */
lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t *dsc, const void *src, const lv_style_t *style)
/* Open an image. Try the created image decoder one by one. Once one is able to open the image that decoder is save in */ lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t *dsc, const void *src, const lv_style_t *style)
{ dsc->style = style; dsc->src = src; dsc->src_type = lv_img_src_get_type(src); dsc->user_data = NULL; lv_res_t res = LV_RES_INV; lv_img_decoder_t * d; LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d) { if(d->info_cb == NULL || d->open_cb == NULL) continue; res = d->info_cb(d, src, &dsc->header); if(res != LV_RES_OK) continue; dsc->error_msg = NULL; dsc->img_data = NULL; dsc->decoder = d; res = d->open_cb(d, dsc); if(res == LV_RES_OK) break; } if(res == LV_RES_INV) { memset(dsc, 0, sizeof(lv_img_decoder_dsc_t)); } return res; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Set the header for the currently constructed HELLO message Called by oonf_api during message creation */
static void _nhdp_add_hello_msg_header_cb(struct rfc5444_writer *wr, struct rfc5444_writer_message *msg)
/* Set the header for the currently constructed HELLO message Called by oonf_api during message creation */ static void _nhdp_add_hello_msg_header_cb(struct rfc5444_writer *wr, struct rfc5444_writer_message *msg)
{ rfc5444_writer_set_msg_header(wr, msg, false, false, false, false); }
labapart/polymcu
C++
null
201
/* This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" documentation) by the application code so that the address and size of a requested descriptor can be given to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the USB host. */
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint16_t wIndex, const void **const DescriptorAddress)
/* This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" documentation) by the application code so that the address and size of a requested descriptor can be given to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the USB host. */ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint16_t wIndex, const void **const DescriptorAddress)
{ const uint8_t DescriptorType = (wValue >> 8); const void* Address = NULL; uint16_t Size = NO_DESCRIPTOR; if (DescriptorType == DTYPE_Device) { Address = &DeviceDescriptor; Size = sizeof(USB_Descriptor_Device_t); } else if (DescriptorType == DTYPE_Configuration) { Address = &ConfigurationDescriptor; Size = sizeof(USB_Descriptor_Configuration_t); } *DescriptorAddress = Address; return Size; }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Initialize the input controller module. This is called only once, when the decompression object is created. */
jinit_input_controller(j_decompress_ptr cinfo)
/* Initialize the input controller module. This is called only once, when the decompression object is created. */ jinit_input_controller(j_decompress_ptr cinfo)
{ my_inputctl_ptr inputctl; inputctl = (my_inputctl_ptr) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_input_controller)); cinfo->inputctl = &inputctl->pub; inputctl->pub.consume_input = consume_markers; inputctl->pub.reset_input_controller = reset_input_controller; inputctl->pub.start_input_pass = start_input_pass; inputctl->pub.finish_input_pass = finish_input_pass; inputctl->pub.has_multiple_scans = FALSE; inputctl->pub.eoi_reached = FALSE; inputctl->inheaders = 1; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Parses the command line to extract the program settings. */
static void ExtractProgramSettingsFromCommandLine(int argc, char const *const argv[], tProgramSettings *programSettings)
/* Parses the command line to extract the program settings. */ static void ExtractProgramSettingsFromCommandLine(int argc, char const *const argv[], tProgramSettings *programSettings)
{ uint8_t paramIdx; assert(argv != NULL); assert(programSettings != NULL); if ( (argv != NULL) && (programSettings != NULL) ) { programSettings->silentMode = false; for (paramIdx = 1; paramIdx < argc; paramIdx++) { if ( (strstr(argv[paramIdx], "-sm") != NULL) && (strlen(argv[paramIdx]) == 3) ) { programSettings->silentMode = true; continue; } } } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Interface function to be called by a channel to obtain write access to the transmission packet. Returns NULL is the packet is currently not accessible. Can by called to prepare the transmit packet before calling the transport layer's transmitFcn(). */
static tTbxMbTpPacket * TbxMbRtuGetTxPacket(tTbxMbTp transport)
/* Interface function to be called by a channel to obtain write access to the transmission packet. Returns NULL is the packet is currently not accessible. Can by called to prepare the transmit packet before calling the transport layer's transmitFcn(). */ static tTbxMbTpPacket * TbxMbRtuGetTxPacket(tTbxMbTp transport)
{ tTbxMbTpPacket * result = NULL; TBX_ASSERT(transport != NULL); if (transport != NULL) { tTbxMbTpCtx * tpCtx = (tTbxMbTpCtx *)transport; TBX_ASSERT(tpCtx->type == TBX_MB_RTU_CONTEXT_TYPE); TbxCriticalSectionEnter(); uint8_t currentState = tpCtx->state; TbxCriticalSectionExit(); if (currentState != TBX_MB_RTU_STATE_TRANSMISSION) { result = &tpCtx->txPacket; } } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Helper function to convert a sequence of 2 characters that represent a hexadecimal value to the actual byte value. Example: SRecParserHexStringToByte("2f") --> returns 47. */
static uint8_t SRecParserHexStringToByte(char const *hexstring)
/* Helper function to convert a sequence of 2 characters that represent a hexadecimal value to the actual byte value. Example: SRecParserHexStringToByte("2f") --> returns 47. */ static uint8_t SRecParserHexStringToByte(char const *hexstring)
{ uint8_t result = 0; int32_t c; uint8_t counter; assert(hexstring != NULL); if (hexstring != NULL) { for (counter = 0; counter < 2u; counter++) { c = toupper((int32_t)(hexstring[counter])); if (isxdigit(c)) { c -= '0'; if (c > 9) { c -= 7; } result = (uint8_t)((result << 4u) + c); } } } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* returns the index for 'key' if 'key' is an appropriate key to live in the array part of the table, 0 otherwise. */
static unsigned int arrayindex(const TValue *key)
/* returns the index for 'key' if 'key' is an appropriate key to live in the array part of the table, 0 otherwise. */ static unsigned int arrayindex(const TValue *key)
{ lua_Integer k = ivalue(key); if (0 < k && (lua_Unsigned)k <= MAXASIZE) return cast(unsigned int, k); } return 0; }
nodemcu/nodemcu-firmware
C++
MIT License
7,566
/* Called when the link layer has terminated, or an establishment request has failed. */
void x25_link_terminated(struct x25_neigh *nb)
/* Called when the link layer has terminated, or an establishment request has failed. */ void x25_link_terminated(struct x25_neigh *nb)
{ nb->state = X25_LINK_STATE_0; x25_kill_by_neigh(nb); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Create the appropriate control structures to manage a new EHCI host controller. */
int ehci_hcd_init(void)
/* Create the appropriate control structures to manage a new EHCI host controller. */ int ehci_hcd_init(void)
{ int ret; u32 vct_hccr; u32 vct_hcor; ret = vct_ehci_hcd_init(&vct_hccr, &vct_hcor); if (ret) return ret; hccr = (struct ehci_hccr *)vct_hccr; hcor = (struct ehci_hcor *)vct_hcor; return 0; }
EmcraftSystems/u-boot
C++
Other
181
/* also note that seeking relative to the "end of file" isn't supported: it has no meaning, so it returns -EINVAL. */
static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
/* also note that seeking relative to the "end of file" isn't supported: it has no meaning, so it returns -EINVAL. */ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
{ loff_t ret; mutex_lock(&file->f_path.dentry->d_inode->i_mutex); switch (orig) { case 0: file->f_pos = offset; ret = file->f_pos; force_successful_syscall_return(); break; case 1: file->f_pos += offset; ret = file->f_pos; force_successful_syscall_return(); break; default: ret = -EINVAL; } mutex_unlock(&file->f_path.dentry->d_inode->i_mutex); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Return: Success (LOOP_READY) : 0 Failed (LOOP_NOT_READY) : 1 */
static int qla2x00_wait_for_loop_ready(scsi_qla_host_t *vha)
/* Return: Success (LOOP_READY) : 0 Failed (LOOP_NOT_READY) : 1 */ static int qla2x00_wait_for_loop_ready(scsi_qla_host_t *vha)
{ int return_status = QLA_SUCCESS; unsigned long loop_timeout ; struct qla_hw_data *ha = vha->hw; scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); loop_timeout = jiffies + (MAX_LOOP_TIMEOUT * HZ); while ((!atomic_read(&base_vha->loop_down_timer) && atomic_read(&base_vha->loop_state) == LOOP_DOWN) || atomic_read(&base_vha->loop_state) != LOOP_READY) { if (atomic_read(&base_vha->loop_state) == LOOP_DEAD) { return_status = QLA_FUNCTION_FAILED; break; } msleep(1000); if (time_after_eq(jiffies, loop_timeout)) { return_status = QLA_FUNCTION_FAILED; break; } } return (return_status); }
robutest/uclinux
C++
GPL-2.0
60
/* Sets the control parameters for a DMA channel. Choose the destination address increment from one of */
void DMAChannelControlSet(unsigned long ulChannelID, unsigned long ulControl)
/* Sets the control parameters for a DMA channel. Choose the destination address increment from one of */ void DMAChannelControlSet(unsigned long ulChannelID, unsigned long ulControl)
{ xASSERT(xDMAChannelIDValid(ulChannelID)); xHWREG(g_psDMAChannelAddress[ulChannelID] + DMA_DCR) &= ~(DMA_DCR_SINC | DMA_DCR_SSIZE_M | DMA_DCR_DINC | DMA_DCR_DSIZE_M); xHWREG(g_psDMAChannelAddress[ulChannelID] + DMA_DCR) |= ulControl; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This API is used to parse and store the sensor time from the FIFO data in the structure instance dev. */
static void unpack_sensortime_frame(uint16_t *data_index, const struct bma4_dev *dev)
/* This API is used to parse and store the sensor time from the FIFO data in the structure instance dev. */ static void unpack_sensortime_frame(uint16_t *data_index, const struct bma4_dev *dev)
{ uint32_t sensor_time_byte3 = 0; uint16_t sensor_time_byte2 = 0; uint8_t sensor_time_byte1 = 0; if ((*data_index + BMA4_SENSOR_TIME_LENGTH) > dev->fifo->length) { *data_index = dev->fifo->length; } else { sensor_time_byte3 = dev->fifo->data[(*data_index) + BMA4_SENSOR_TIME_MSB_BYTE] << 16; sensor_time_byte2 = dev->fifo->data[(*data_index) + BMA4_SENSOR_TIME_XLSB_BYTE] << 8; sensor_time_byte1 = dev->fifo->data[(*data_index)]; dev->fifo->sensor_time = (uint32_t)(sensor_time_byte3 | sensor_time_byte2 | sensor_time_byte1); *data_index = (*data_index) + BMA4_SENSOR_TIME_LENGTH; } }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* User request to unload a context. Content is saved for possible reload. */
static int gru_unload_all_contexts(void)
/* User request to unload a context. Content is saved for possible reload. */ static int gru_unload_all_contexts(void)
{ struct gru_thread_state *gts; struct gru_state *gru; int gid, ctxnum; if (!capable(CAP_SYS_ADMIN)) return -EPERM; foreach_gid(gid) { gru = GID_TO_GRU(gid); spin_lock(&gru->gs_lock); for (ctxnum = 0; ctxnum < GRU_NUM_CCH; ctxnum++) { gts = gru->gs_gts[ctxnum]; if (gts && mutex_trylock(&gts->ts_ctxlock)) { spin_unlock(&gru->gs_lock); gru_unload_context(gts, 1); mutex_unlock(&gts->ts_ctxlock); spin_lock(&gru->gs_lock); } } spin_unlock(&gru->gs_lock); } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This function is called with hbalock held to post pending iocbs in the txq to the firmware. This function is called when driver detects space available in the ring. */
static void lpfc_sli_resume_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
/* This function is called with hbalock held to post pending iocbs in the txq to the firmware. This function is called when driver detects space available in the ring. */ static void lpfc_sli_resume_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
{ IOCB_t *iocb; struct lpfc_iocbq *nextiocb; if (pring->txq_cnt && lpfc_is_link_up(phba) && (pring->ringno != phba->sli.fcp_ring || phba->sli.sli_flag & LPFC_PROCESS_LA)) { while ((iocb = lpfc_sli_next_iocb_slot(phba, pring)) && (nextiocb = lpfc_sli_ringtx_get(phba, pring))) lpfc_sli_submit_iocb(phba, pring, iocb, nextiocb); if (iocb) lpfc_sli_update_ring(phba, pring); else lpfc_sli_update_full_ring(phba, pring); } return; }
robutest/uclinux
C++
GPL-2.0
60
/* Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source. */
VOID FillBuf(IN SCRATCH_DATA *Sd, IN UINT16 NumOfBits)
/* Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source. */ VOID FillBuf(IN SCRATCH_DATA *Sd, IN UINT16 NumOfBits)
{ Sd->mBitBuf = (UINT32)LShiftU64 (((UINT64)Sd->mBitBuf), NumOfBits); while (NumOfBits > Sd->mBitCount) { NumOfBits = (UINT16)(NumOfBits - Sd->mBitCount); Sd->mBitBuf |= (UINT32)LShiftU64 (((UINT64)Sd->mSubBitBuf), NumOfBits); if (Sd->mCompSize > 0) { Sd->mCompSize--; Sd->mSubBitBuf = Sd->mSrcBase[Sd->mInBuf++]; Sd->mBitCount = 8; } else { Sd->mSubBitBuf = 0; Sd->mBitCount = 8; } } Sd->mBitCount = (UINT16)(Sd->mBitCount - NumOfBits); Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount; }
tianocore/edk2
C++
Other
4,240
/* If Buffer is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16* EFIAPI S3MmioWriteBuffer16(IN UINTN StartAddress, IN UINTN Length, IN CONST UINT16 *Buffer)
/* If Buffer is not aligned on a 16-bit boundary, then ASSERT(). */ UINT16* EFIAPI S3MmioWriteBuffer16(IN UINTN StartAddress, IN UINTN Length, IN CONST UINT16 *Buffer)
{ UINT16 *ReturnBuffer; RETURN_STATUS Status; ReturnBuffer = MmioWriteBuffer16 (StartAddress, Length, Buffer); Status = S3BootScriptSaveMemWrite ( S3BootScriptWidthUint16, StartAddress, Length / sizeof (UINT16), ReturnBuffer ); ASSERT (Status == RETURN_SUCCESS); return ReturnBuffer; }
tianocore/edk2
C++
Other
4,240
/* Message: SendDtmfToneMessage Opcode: 0x0128 Type: CallControl Direction: pbx2dev VarLength: no */
static void handle_SendDtmfToneMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
/* Message: SendDtmfToneMessage Opcode: 0x0128 Type: CallControl Direction: pbx2dev VarLength: no */ static void handle_SendDtmfToneMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
{ ptvcursor_add(cursor, hf_skinny_tone, 4, ENC_LITTLE_ENDIAN); ptvcursor_add(cursor, hf_skinny_conferenceID, 4, ENC_LITTLE_ENDIAN); ptvcursor_add(cursor, hf_skinny_passthruPartyID, 4, ENC_LITTLE_ENDIAN); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* The "foo" file where the .foo variable is read from and written to. */
static ssize_t foo_show(struct foo_obj *foo_obj, struct foo_attribute *attr, char *buf)
/* The "foo" file where the .foo variable is read from and written to. */ static ssize_t foo_show(struct foo_obj *foo_obj, struct foo_attribute *attr, char *buf)
{ return sprintf(buf, "%d\n", foo_obj->foo); }
robutest/uclinux
C++
GPL-2.0
60
/* This routine is required by IAR DLIB library since EWAVR V6.10 the implementation is empty to be compatible with old IAR version. */
int __close(int handle)
/* This routine is required by IAR DLIB library since EWAVR V6.10 the implementation is empty to be compatible with old IAR version. */ int __close(int handle)
{ (void)(handle); return 0; }
eclipse-threadx/getting-started
C++
Other
310
/* Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France */
isl_ctx* isl_band_get_ctx(__isl_keep isl_band *band)
/* Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France */ isl_ctx* isl_band_get_ctx(__isl_keep isl_band *band)
{ return band ? isl_union_pw_multi_aff_get_ctx(band->pma) : NULL; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Written by Sven Verdoolaege, K.U.Leuven, Departement Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium */
uint32_t isl_gmp_hash(mpz_t v, uint32_t hash)
/* Written by Sven Verdoolaege, K.U.Leuven, Departement Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium */ uint32_t isl_gmp_hash(mpz_t v, uint32_t hash)
{ int sa = v[0]._mp_size; int abs_sa = sa < 0 ? -sa : sa; unsigned char *data = (unsigned char *)v[0]._mp_d; unsigned char *end = data + abs_sa * sizeof(v[0]._mp_d[0]); if (sa < 0) isl_hash_byte(hash, 0xFF); for (; data < end; ++data) isl_hash_byte(hash, *data); return hash; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Similar to TIFFWriteDirectory(), writes the directory out but leaves all data structures in memory so that it can be written again. This will make a partially written TIFF file readable before it is successfully completed/closed. */
int TIFFCheckpointDirectory(TIFF *tif)
/* Similar to TIFFWriteDirectory(), writes the directory out but leaves all data structures in memory so that it can be written again. This will make a partially written TIFF file readable before it is successfully completed/closed. */ int TIFFCheckpointDirectory(TIFF *tif)
{ int rc; if (tif->tif_dir.td_stripoffset == NULL) (void) TIFFSetupStrips(tif); rc = TIFFWriteDirectorySec(tif,TRUE,FALSE,NULL); (void) TIFFSetWriteOffset(tif, TIFFSeekFile(tif, 0, SEEK_END)); return rc; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* \Pxp reporter Initialization which initializes service,defines and start adv */
void pxp_reporter_init(void *param)
/* \Pxp reporter Initialization which initializes service,defines and start adv */ void pxp_reporter_init(void *param)
{ pxp_service_init(); pxp_service_define(); pxp_reporter_adv(); }
remotemcu/remcu-chip-sdks
C++
null
436
/* param pfd PFD control name. return PFD bypass status. */
bool CLOCK_IsUsb1PfdEnabled(clock_pfd_t pfd)
/* param pfd PFD control name. return PFD bypass status. */ bool CLOCK_IsUsb1PfdEnabled(clock_pfd_t pfd)
{ return ((CCM_ANALOG->PFD_480 & (uint32_t)CCM_ANALOG_PFD_480_PFD0_CLKGATE_MASK << (8UL * (uint32_t)pfd)) == 0U); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function wraps EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Pci.Read() service. It reads and returns the PCI configuration register specified by Address, the width of data is specified by Width. */
UINT32 DxePciSegmentLibPciRootBridgeIoReadWorker(IN UINT64 Address, IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width)
/* This function wraps EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Pci.Read() service. It reads and returns the PCI configuration register specified by Address, the width of data is specified by Width. */ UINT32 DxePciSegmentLibPciRootBridgeIoReadWorker(IN UINT64 Address, IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width)
{ UINT32 Data; EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo; PciRootBridgeIo = PciSegmentLibSearchForRootBridge (Address); ASSERT (PciRootBridgeIo != NULL); PciRootBridgeIo->Pci.Read ( PciRootBridgeIo, Width, PCI_TO_PCI_ROOT_BRIDGE_IO_ADDRESS (Address), 1, &Data ); return Data; }
tianocore/edk2
C++
Other
4,240
/* Typically, you won't use this function. Instead use functions specific to the type of source you are using. */
void g_source_set_callback(GSource *source, GSourceFunc func, gpointer data, GDestroyNotify notify)
/* Typically, you won't use this function. Instead use functions specific to the type of source you are using. */ void g_source_set_callback(GSource *source, GSourceFunc func, gpointer data, GDestroyNotify notify)
{ GSourceCallback *new_callback; g_return_if_fail (source != NULL); new_callback = g_new (GSourceCallback, 1); new_callback->ref_count = 1; new_callback->func = func; new_callback->data = data; new_callback->notify = notify; g_source_set_callback_indirect (source, new_callback, &g_source_callback_funcs); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* If the firmware passed a device tree use it for U-Boot. */
void* board_fdt_blob_setup(void)
/* If the firmware passed a device tree use it for U-Boot. */ void* board_fdt_blob_setup(void)
{ if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC) return NULL; return (void *)fw_dtb_pointer; }
4ms/stm32mp1-baremetal
C++
Other
137
/* param base asrc base pointer. param handle Pointer to the ASRC_handle_t structure which stores the transfer state. param count Bytes count sent. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. */
status_t ASRC_TransferGetConvertedCount(ASRC_Type *base, asrc_handle_t *handle, size_t *count)
/* param base asrc base pointer. param handle Pointer to the ASRC_handle_t structure which stores the transfer state. param count Bytes count sent. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. */ status_t ASRC_TransferGetConvertedCount(ASRC_Type *base, asrc_handle_t *handle, size_t *count)
{ assert(handle != NULL); status_t status = kStatus_Success; if (handle->state != (uint32_t)kStatus_ASRCBusy) { status = kStatus_ASRCIdle; } else { *count = handle->out.transferSamples[handle->out.queueDriver]; } return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This is a simple module to wait until all the async scans are complete. The idea is to use it in initrd/initramfs scripts. You modprobe it after all the modprobes of the root SCSI drivers and it will wait until they have all finished scanning their busses before allowing the boot to proceed */
static int __init wait_scan_init(void)
/* This is a simple module to wait until all the async scans are complete. The idea is to use it in initrd/initramfs scripts. You modprobe it after all the modprobes of the root SCSI drivers and it will wait until they have all finished scanning their busses before allowing the boot to proceed */ static int __init wait_scan_init(void)
{ wait_for_device_probe(); scsi_complete_async_scans(); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Log the leaf entries indicated from a leaf1 or leafn block. */
void xfs_dir2_leaf_log_ents(xfs_trans_t *tp, xfs_dabuf_t *bp, int first, int last)
/* Log the leaf entries indicated from a leaf1 or leafn block. */ void xfs_dir2_leaf_log_ents(xfs_trans_t *tp, xfs_dabuf_t *bp, int first, int last)
{ xfs_dir2_leaf_entry_t *firstlep; xfs_dir2_leaf_entry_t *lastlep; xfs_dir2_leaf_t *leaf; leaf = bp->data; ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC || be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); firstlep = &leaf->ents[first]; lastlep = &leaf->ents[last]; xfs_da_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf), (uint)((char *)lastlep - (char *)leaf + sizeof(*lastlep) - 1)); }
robutest/uclinux
C++
GPL-2.0
60
/* param config Pointer to DMA channel transfer configuration structure. param srcStartAddr source start address. param dstStartAddr destination start address. param xferCfg xfer configuration, user can reference DMA_CHANNEL_XFER about to how to get xferCfg value. param type transfer type. param trigger DMA channel trigger configurations. param nextDesc address of next descriptor. */
void DMA_PrepareChannelTransfer(dma_channel_config_t *config, void *srcStartAddr, void *dstStartAddr, uint32_t xferCfg, dma_transfer_type_t type, dma_channel_trigger_t *trigger, void *nextDesc)
/* param config Pointer to DMA channel transfer configuration structure. param srcStartAddr source start address. param dstStartAddr destination start address. param xferCfg xfer configuration, user can reference DMA_CHANNEL_XFER about to how to get xferCfg value. param type transfer type. param trigger DMA channel trigger configurations. param nextDesc address of next descriptor. */ void DMA_PrepareChannelTransfer(dma_channel_config_t *config, void *srcStartAddr, void *dstStartAddr, uint32_t xferCfg, dma_transfer_type_t type, dma_channel_trigger_t *trigger, void *nextDesc)
{ assert((NULL != config) && (NULL != srcStartAddr) && (NULL != dstStartAddr)); assert((((uint32_t)(uint32_t *)nextDesc) & ((uint32_t)FSL_FEATURE_DMA_LINK_DESCRIPTOR_ALIGN_SIZE - 1UL)) == 0UL); (void)memset(config, 0, sizeof(*config)); if (type == kDMA_MemoryToMemory) { config->isPeriph = false; } else if (type == kDMA_PeripheralToMemory) { config->isPeriph = true; } else if (type == kDMA_MemoryToPeripheral) { config->isPeriph = true; } else { config->isPeriph = true; } config->dstStartAddr = (uint8_t *)dstStartAddr; config->srcStartAddr = (uint8_t *)srcStartAddr; config->nextDesc = (uint8_t *)nextDesc; config->trigger = trigger; config->xferCfg = xferCfg; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* gfs2_holder_uninit - uninitialize a holder structure (drop glock reference) @gh: the holder structure */
void gfs2_holder_uninit(struct gfs2_holder *gh)
/* gfs2_holder_uninit - uninitialize a holder structure (drop glock reference) @gh: the holder structure */ void gfs2_holder_uninit(struct gfs2_holder *gh)
{ put_pid(gh->gh_owner_pid); gfs2_glock_put(gh->gh_gl); gh->gh_gl = NULL; gh->gh_ip = 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This macro is used to disable input channel interrupt. */
void ECAP_DisableINT(ECAP_T *ecap, uint32_t u32Mask)
/* This macro is used to disable input channel interrupt. */ void ECAP_DisableINT(ECAP_T *ecap, uint32_t u32Mask)
{ ecap->CTL0 &= ~(u32Mask); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns 0 on success, or EBUSY on error. A warning message is also printed on failure. */
int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
/* Returns 0 on success, or EBUSY on error. A warning message is also printed on failure. */ int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
{ return __pci_request_region(pdev, bar, res_name, 0); }
robutest/uclinux
C++
GPL-2.0
60
/* DAC Channel Trigger Enable. Enable a digital to analog converter channel external trigger mode. This allows an external trigger to initiate register transfers from the buffer register to the DAC output register, followed by a DMA transfer to the buffer register if DMA is enabled. The trigger source must also be selected. */
void dac_trigger_enable(data_channel dac_channel)
/* DAC Channel Trigger Enable. Enable a digital to analog converter channel external trigger mode. This allows an external trigger to initiate register transfers from the buffer register to the DAC output register, followed by a DMA transfer to the buffer register if DMA is enabled. The trigger source must also be selected. */ void dac_trigger_enable(data_channel dac_channel)
{ switch (dac_channel) { case CHANNEL_1: DAC_CR |= DAC_CR_TEN1; break; case CHANNEL_2: DAC_CR |= DAC_CR_TEN2; break; case CHANNEL_D: DAC_CR |= (DAC_CR_TEN1 | DAC_CR_TEN2); break; } }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely. */
int main(int argc, char *argv[])
/* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely. */ int main(int argc, char *argv[])
{ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n"); return 1; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param volume volume value, support 0 ~ 100, 0 is mute, 100 is the maximum volume value. return kStatus_Success is success, else configure failed. */
status_t HAL_CODEC_SetVolume(void *handle, uint32_t playChannel, uint32_t volume)
/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param volume volume value, support 0 ~ 100, 0 is mute, 100 is the maximum volume value. return kStatus_Success is success, else configure failed. */ status_t HAL_CODEC_SetVolume(void *handle, uint32_t playChannel, uint32_t volume)
{ assert(handle != NULL); status_t retVal = kStatus_Success; if ((playChannel & kWM8960_HeadphoneLeft) || (playChannel & kWM8960_HeadphoneRight)) { retVal = WM8960_SetVolume((wm8960_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)), kWM8960_ModuleHP, volume); } if ((playChannel & kWM8960_SpeakerLeft) || (playChannel & kWM8960_SpeakerRight)) { retVal = WM8960_SetVolume((wm8960_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)), kWM8960_ModuleSpeaker, volume); } return retVal; }
eclipse-threadx/getting-started
C++
Other
310
/* param base The I3C peripheral base address. param handle Pointer to the I3C master driver handle. retval #kStatus_Success A transaction was successfully aborted. retval #kStatus_I3C_Idle There is not a non-blocking transaction currently in progress. */
void I3C_MasterTransferAbort(I3C_Type *base, i3c_master_handle_t *handle)
/* param base The I3C peripheral base address. param handle Pointer to the I3C master driver handle. retval #kStatus_Success A transaction was successfully aborted. retval #kStatus_I3C_Idle There is not a non-blocking transaction currently in progress. */ void I3C_MasterTransferAbort(I3C_Type *base, i3c_master_handle_t *handle)
{ if (handle->state != (uint8_t)kIdleState) { I3C_MasterDisableInterrupts(base, (uint32_t)kMasterIrqFlags); base->MDATACTRL |= I3C_MDATACTRL_FLUSHTB_MASK | I3C_MDATACTRL_FLUSHFB_MASK; (void)I3C_MasterStop(base); handle->state = (uint8_t)kIdleState; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Configures the External Interrupt Controller to detect changes in the board button state. */
static void configure_extint(void)
/* Configures the External Interrupt Controller to detect changes in the board button state. */ static void configure_extint(void)
{ struct extint_chan_conf eint_chan_conf; extint_chan_get_config_defaults(&eint_chan_conf); eint_chan_conf.gpio_pin = BUTTON_0_EIC_PIN; eint_chan_conf.gpio_pin_mux = BUTTON_0_EIC_MUX; eint_chan_conf.detection_criteria = EXTINT_DETECT_BOTH; eint_chan_conf.filter_input_signal = true; extint_chan_set_config(BUTTON_0_EIC_LINE, &eint_chan_conf); }
memfault/zero-to-main
C++
null
200
/* Helper function for splitting a string into an argv-like array. originaly copied from lib/argv_split.c */
static const char* skip_sep(const char *cp)
/* Helper function for splitting a string into an argv-like array. originaly copied from lib/argv_split.c */ static const char* skip_sep(const char *cp)
{ while (*cp && isspace(*cp)) cp++; return cp; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Transfer qsound parameters to CSP, function should be called from interrupt routine */
static int snd_sb_csp_qsound_transfer(struct snd_sb_csp *p)
/* Transfer qsound parameters to CSP, function should be called from interrupt routine */ static int snd_sb_csp_qsound_transfer(struct snd_sb_csp *p)
{ int err = -ENXIO; spin_lock(&p->q_lock); if (p->running & SNDRV_SB_CSP_ST_QSOUND) { set_codec_parameter(p->chip, 0xe0, 0x01); set_codec_parameter(p->chip, 0x00, p->qpos_left); set_codec_parameter(p->chip, 0x02, 0x00); set_codec_parameter(p->chip, 0x00, p->qpos_right); set_codec_parameter(p->chip, 0x03, 0x00); err = 0; } p->qpos_changed = 0; spin_unlock(&p->q_lock); return err; }
robutest/uclinux
C++
GPL-2.0
60
/* Checks whether the specified I2C flag is set or not. */
u8 USI_I2C_CheckFlagState(USI_TypeDef *USIx, u32 USI_I2C_FLAG)
/* Checks whether the specified I2C flag is set or not. */ u8 USI_I2C_CheckFlagState(USI_TypeDef *USIx, u32 USI_I2C_FLAG)
{ u8 bit_status = 0; assert_param(IS_USI_I2C_ALL_PERIPH(USIx)); if((USIx->I2C_STATUS & USI_I2C_FLAG) != 0) { bit_status = 1; } return bit_status; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Cloning a stream means copying all the values of the input Stream in the ClonedStream. */
EFI_STATUS EFIAPI AmlStreamClone(IN CONST AML_STREAM *Stream, OUT AML_STREAM *ClonedStream)
/* Cloning a stream means copying all the values of the input Stream in the ClonedStream. */ EFI_STATUS EFIAPI AmlStreamClone(IN CONST AML_STREAM *Stream, OUT AML_STREAM *ClonedStream)
{ if (!IS_STREAM (Stream) || (ClonedStream == NULL)) { ASSERT (0); return EFI_INVALID_PARAMETER; } ClonedStream->Buffer = Stream->Buffer; ClonedStream->MaxBufferSize = Stream->MaxBufferSize; ClonedStream->Index = Stream->Index; ClonedStream->Direction = Stream->Direction; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Initialize the library and determine if the underlying is a UEFI Shell 2.0 or an EFI shell. */
RETURN_STATUS EFIAPI ShellCommandLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* Initialize the library and determine if the underlying is a UEFI Shell 2.0 or an EFI shell. */ RETURN_STATUS EFIAPI ShellCommandLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ EFI_STATUS Status; InitializeListHead (&gShellMapList.Link); InitializeListHead (&mCommandList.Link); InitializeListHead (&mAliasList.Link); InitializeListHead (&mScriptList.Link); InitializeListHead (&mFileHandleList.Link); mEchoState = TRUE; mExitRequested = FALSE; mExitScript = FALSE; mProfileListSize = 0; mProfileList = NULL; Status = CommandInit (); if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } return (RETURN_SUCCESS); }
tianocore/edk2
C++
Other
4,240
/* Event handler for the library USB Configuration Changed event. */
void EVENT_USB_Device_ConfigurationChanged(void)
/* Event handler for the library USB Configuration Changed event. */ void EVENT_USB_Device_ConfigurationChanged(void)
{ bool ConfigSuccess = true; ConfigSuccess &= Audio_Device_ConfigureEndpoints(&Speaker_Audio_Interface); LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Poll the acknowledge from AT24CXX. Support and FAQ: visit */
static void at24cxx_acknowledge_polling(twi_package_t *twi_package)
/* Poll the acknowledge from AT24CXX. Support and FAQ: visit */ static void at24cxx_acknowledge_polling(twi_package_t *twi_package)
{ uint8_t data = 0; uint8_t addr = twi_package->addr[0]; uint32_t addr_length = twi_package->addr_length; void *buffer = twi_package->buffer; uint32_t length = twi_package->length; twi_package->addr[0] = 0; twi_package->addr_length = 0; twi_package->buffer = &data; twi_package->length = 1; while (twi_master_write(BOARD_AT24C_TWI_INSTANCE, twi_package) != TWI_SUCCESS); twi_package->addr[0] = addr; twi_package->addr_length = addr_length; twi_package->buffer = buffer; twi_package->length = length; }
remotemcu/remcu-chip-sdks
C++
null
436
/* See if the directory is a single-block form directory. */
int xfs_dir2_isblock(xfs_trans_t *tp, xfs_inode_t *dp, int *vp)
/* See if the directory is a single-block form directory. */ int xfs_dir2_isblock(xfs_trans_t *tp, xfs_inode_t *dp, int *vp)
{ xfs_fileoff_t last; xfs_mount_t *mp; int rval; mp = dp->i_mount; if ((rval = xfs_bmap_last_offset(tp, dp, &last, XFS_DATA_FORK))) return rval; rval = XFS_FSB_TO_B(mp, last) == mp->m_dirblksize; ASSERT(rval == 0 || dp->i_d.di_size == mp->m_dirblksize); *vp = rval; return 0; }
robutest/uclinux
C++
GPL-2.0
60