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 |
|---|---|---|---|---|---|---|---|
/* This function should typically be called before the filesystem releases resources associated with the freed range (eg. deallocates blocks). This way, pagecache will always stay logically coherent with on-disk format, and the filesystem would not have to deal with situations such as writepage being called for a page that has already had its underlying blocks deallocated. */ | void truncate_pagecache(struct inode *inode, loff_t old, loff_t new) | /* This function should typically be called before the filesystem releases resources associated with the freed range (eg. deallocates blocks). This way, pagecache will always stay logically coherent with on-disk format, and the filesystem would not have to deal with situations such as writepage being called for a page that has already had its underlying blocks deallocated. */
void truncate_pagecache(struct inode *inode, loff_t old, loff_t new) | {
struct address_space *mapping = inode->i_mapping;
unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1);
truncate_inode_pages(mapping, new);
unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Sysfs operation for forwarding read call to the show method of the attribute owner */ | static ssize_t wlp_wss_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) | /* Sysfs operation for forwarding read call to the show method of the attribute owner */
static ssize_t wlp_wss_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) | {
struct wlp_wss_attribute *wss_attr = attr_to_wlp_wss_attr(attr);
struct wlp_wss *wss = kobj_to_wlp_wss(kobj);
ssize_t ret = -EIO;
if (wss_attr->show)
ret = wss_attr->show(wss, buf);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function is the handler for Delayed Recovery event triggered by timer. After a device error occurs, the event would be triggered with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY is defined in USB standard for error handling. */ | VOID EFIAPI USBMouseRecoveryHandler(IN EFI_EVENT Event, IN VOID *Context) | /* This function is the handler for Delayed Recovery event triggered by timer. After a device error occurs, the event would be triggered with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY is defined in USB standard for error handling. */
VOID EFIAPI USBMouseRecoveryHandler(IN EFI_EVENT Event, IN VOID *Context) | {
USB_MOUSE_DEV *UsbMouseDev;
EFI_USB_IO_PROTOCOL *UsbIo;
UsbMouseDev = (USB_MOUSE_DEV *)Context;
UsbIo = UsbMouseDev->UsbIo;
UsbIo->UsbAsyncInterruptTransfer (
UsbIo,
UsbMouseDev->IntEndpointDescriptor.EndpointAddress,
TRUE,
UsbMouseDev->IntEndpointDescriptor.Interval,
UsbMouseDev->IntEndpointDescriptor.MaxPacketSize,
OnMouseInterruptComplete,
UsbMouseDev
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Like "tvb_format_text()", but for null-padded strings; don't show the null padding characters as "\000". */ | gchar* tvb_format_stringzpad(tvbuff_t *tvb, const gint offset, const gint size) | /* Like "tvb_format_text()", but for null-padded strings; don't show the null padding characters as "\000". */
gchar* tvb_format_stringzpad(tvbuff_t *tvb, const gint offset, const gint size) | {
const guint8 *ptr, *p;
gint len;
gint stringlen;
len = (size > 0) ? size : 0;
ptr = ensure_contiguous(tvb, offset, size);
for (p = ptr, stringlen = 0; stringlen < len && *p != '\0'; p++, stringlen++)
;
return format_text(ptr, stringlen);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Enable the output buffer.
Enables the output buffer and drives the DAC output to the VOUT pin. */ | void dac_chan_enable_output_buffer(struct dac_module *const module_inst, enum dac_channel channel) | /* Enable the output buffer.
Enables the output buffer and drives the DAC output to the VOUT pin. */
void dac_chan_enable_output_buffer(struct dac_module *const module_inst, enum dac_channel channel) | {
Assert(module_inst);
Assert(module_inst->hw);
UNUSED(channel);
Dac *const dac_module = module_inst->hw;
dac_module->CTRLB.reg |= DAC_OUTPUT_EXTERNAL;
} | memfault/zero-to-main | C++ | null | 200 |
/* serial core request to start/stop emitting break char */ | static void bcm_uart_break_ctl(struct uart_port *port, int ctl) | /* serial core request to start/stop emitting break char */
static void bcm_uart_break_ctl(struct uart_port *port, int ctl) | {
unsigned long flags;
unsigned int val;
spin_lock_irqsave(&port->lock, flags);
val = bcm_uart_readl(port, UART_CTL_REG);
if (ctl)
val |= UART_CTL_XMITBRK_MASK;
else
val &= ~UART_CTL_XMITBRK_MASK;
bcm_uart_writel(port, val, UART_CTL_REG);
spin_unlock_irqrestore(&port->lock, flags);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Given a string of the form "<pref name>:<pref value>", as might appear as an argument to a "-o" option, parse it and set the preference in question. Return an indication of whether it succeeded or failed in some fashion. */ | prefs_set_pref_e prefs_set_pref(char *prefarg) | /* Given a string of the form "<pref name>:<pref value>", as might appear as an argument to a "-o" option, parse it and set the preference in question. Return an indication of whether it succeeded or failed in some fashion. */
prefs_set_pref_e prefs_set_pref(char *prefarg) | {
gchar *p, *colonp;
prefs_set_pref_e ret;
mgcp_tcp_port_count = -1;
mgcp_udp_port_count = -1;
colonp = strchr(prefarg, ':');
if (colonp == NULL)
return PREFS_SET_SYNTAX_ERR;
p = colonp;
*p++ = '\0';
while (g_ascii_isspace(*p))
p++;
if (*p == '\0') {
*colonp = ':';
return PREFS_SET_SYNTAX_ERR;
}
if (strcmp(prefarg, "uat")) {
ret = set_pref(prefarg, p, NULL, TRUE);
} else {
ret = prefs_set_uat_pref(p) ? PREFS_SET_OK : PREFS_SET_SYNTAX_ERR;
}
*colonp = ':';
return ret;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Open LIN mode on the specified UART.
The */ | void xUARTLINConfig(unsigned long ulBase, unsigned long ulBaud, unsigned long ulConfig) | /* Open LIN mode on the specified UART.
The */
void xUARTLINConfig(unsigned long ulBase, unsigned long ulBaud, unsigned long ulConfig) | {
xASSERT(UARTBaseValid(ulBase));
xASSERT((ulConfig&UART_CONFIG_BKFL_MASK)<16);
xUARTConfigSet(ulBase, ulBaud,
xUART_CONFIG_WLEN_8 |
xUART_CONFIG_STOP_1 |
xUART_CONFIG_PAR_NONE);
xUARTLINEnable(ulBase);
xHWREG(ulBase + UART_LIN_CON) &= ~UART_LIN_CON_LIN_BKFL_M;
xHWREG(ulBase + UART_LIN_CON) |= ulConfig;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Sets the specified data holding register value for DAC channel2. */ | void DAC_ConfigChannel2Data(DAC_DATA_ALIGN_T dataAlign, uint16_t data) | /* Sets the specified data holding register value for DAC channel2. */
void DAC_ConfigChannel2Data(DAC_DATA_ALIGN_T dataAlign, uint16_t data) | {
__IO uint32_t tmp = 0;
tmp = (uint32_t)DAC_BASE;
tmp += DH12RCH2_OFFSET + dataAlign;
*(__IO uint32_t*)tmp = data;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* meson_spifc_drain_buffer() - copy data from device buffer to memory @spifc: the Meson SPI device @buf: the destination buffer @len: number of bytes to copy */ | static void meson_spifc_drain_buffer(struct meson_spifc_priv *spifc, u8 *buf, int len) | /* meson_spifc_drain_buffer() - copy data from device buffer to memory @spifc: the Meson SPI device @buf: the destination buffer @len: number of bytes to copy */
static void meson_spifc_drain_buffer(struct meson_spifc_priv *spifc, u8 *buf, int len) | {
u32 data;
int i = 0;
while (i < len) {
regmap_read(spifc->regmap, REG_C0 + i, &data);
if (len - i >= 4) {
*((u32 *)buf) = data;
buf += 4;
} else {
memcpy(buf, &data, len - i);
break;
}
i += 4;
}
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Config the slave select pins of the specified SPI port.
The */ | void SPISSConfig(unsigned long ulBase, unsigned long ulSSTriggerMode, unsigned long ulSSActType) | /* Config the slave select pins of the specified SPI port.
The */
void SPISSConfig(unsigned long ulBase, unsigned long ulSSTriggerMode, unsigned long ulSSActType) | {
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE) );
xASSERT((ulSSTriggerMode == SPI_SS_EDGE_TRIGGER) ||
(ulSSTriggerMode == SPI_SS_LEVEL_TRIGGER));
xASSERT((ulSSActType == SPI_SS_ACTIVE_LOW_FALLING) ||
(ulSSActType == SPI_SS_ACTIVE_HIGH_RISING));
xHWREG(ulBase + SPI_SSR) |= ulSSTriggerMode | ulSSActType;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* param base BEE peripheral address. param region Selection of the BEE region to be configured. param nonce AES nonce (in little-endian format). param nonceSize Size of AES nonce. */ | status_t BEE_SetRegionNonce(BEE_Type *base, bee_region_t region, const uint8_t *nonce, size_t nonceSize) | /* param base BEE peripheral address. param region Selection of the BEE region to be configured. param nonce AES nonce (in little-endian format). param nonceSize Size of AES nonce. */
status_t BEE_SetRegionNonce(BEE_Type *base, bee_region_t region, const uint8_t *nonce, size_t nonceSize) | {
if ((0U != ((uintptr_t)nonce & 0x3u)) || (nonceSize != 16U))
{
return kStatus_InvalidArgument;
}
while (0U == (BEE_GetStatusFlags(base) & (uint32_t)kBEE_IdleFlag))
{
}
if (region == kBEE_Region0)
{
aligned_memcpy((uint32_t *)(uint32_t)&base->CTR_NONCE0_W0, nonce, nonceSize);
}
else if (region == kBEE_Region1)
{
aligned_memcpy((uint32_t *)(uint32_t)&base->CTR_NONCE1_W0, nonce, nonceSize);
}
else
{
return kStatus_InvalidArgument;
}
return kStatus_Success;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* This function does the actual unregistering of the interrupt handler. It clears the handler to be called when a PRCM interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called. */ | void PRCMIntUnregister(void) | /* This function does the actual unregistering of the interrupt handler. It clears the handler to be called when a PRCM interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called. */
void PRCMIntUnregister(void) | {
IntDisable(INT_PRCM);
IntUnregister(INT_PRCM);
} | micropython/micropython | C++ | Other | 18,334 |
/* Read both port 0 and port 1 registers of certain register function.
Given the register in reg, read the pair of port 0 and port 1. */ | static int read_port_regs(const struct device *dev, uint8_t reg, uint16_t *cache, uint16_t *buf) | /* Read both port 0 and port 1 registers of certain register function.
Given the register in reg, read the pair of port 0 and port 1. */
static int read_port_regs(const struct device *dev, uint8_t reg, uint16_t *cache, uint16_t *buf) | {
const struct gpio_pca95xx_config * const config = dev->config;
uint16_t port_data, value;
int ret;
ret = i2c_burst_read_dt(&config->bus, reg, (uint8_t *)&port_data,
sizeof(port_data));
if (ret != 0) {
LOG_ERR("PCA95XX[0x%X]: error reading register 0x%X (%d)",
config->bus.addr, reg, ret);
return ret;
}
value = sys_le16_to_cpu(port_data);
*cache = value;
*buf = value;
LOG_DBG("PCA95XX[0x%X]: Read: REG[0x%X] = 0x%X, REG[0x%X] = 0x%X",
config->bus.addr, reg, (*buf & 0xFF), (reg + 1), (*buf >> 8));
return 0;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Allocate the next available QPN and put the QP into the hash table. The hash table holds a reference to the QP. */ | static int ipath_alloc_qpn(struct ipath_qp_table *qpt, struct ipath_qp *qp, enum ib_qp_type type) | /* Allocate the next available QPN and put the QP into the hash table. The hash table holds a reference to the QP. */
static int ipath_alloc_qpn(struct ipath_qp_table *qpt, struct ipath_qp *qp, enum ib_qp_type type) | {
unsigned long flags;
int ret;
ret = alloc_qpn(qpt, type);
if (ret < 0)
goto bail;
qp->ibqp.qp_num = ret;
spin_lock_irqsave(&qpt->lock, flags);
ret %= qpt->max;
qp->next = qpt->table[ret];
qpt->table[ret] = qp;
atomic_inc(&qp->refcount);
spin_unlock_irqrestore(&qpt->lock, flags);
ret = 0;
bail:
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Initialize a lease, use the default lock manager operations */ | static int lease_init(struct file *filp, int type, struct file_lock *fl) | /* Initialize a lease, use the default lock manager operations */
static int lease_init(struct file *filp, int type, struct file_lock *fl) | {
if (assign_type(fl, type) != 0)
return -EINVAL;
fl->fl_owner = current->files;
fl->fl_pid = current->tgid;
fl->fl_file = filp;
fl->fl_flags = FL_LEASE;
fl->fl_start = 0;
fl->fl_end = OFFSET_MAX;
fl->fl_ops = NULL;
fl->fl_lmops = &lease_manager_ops;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* retval BFA_STATUS_OK On success. retval BFA_STATUS_INPROGRESS VF is being stopped. */ | bfa_status_t bfa_fcs_vf_stop(bfa_fcs_vf_t *vf) | /* retval BFA_STATUS_OK On success. retval BFA_STATUS_INPROGRESS VF is being stopped. */
bfa_status_t bfa_fcs_vf_stop(bfa_fcs_vf_t *vf) | {
bfa_trc(vf->fcs, vf->vf_id);
return BFA_STATUS_OK;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Write a whole GPIO Port.
Sets all 32 GPIOs of a Port. */ | void gpio_port_write(uint32_t gpioport, uint32_t data) | /* Write a whole GPIO Port.
Sets all 32 GPIOs of a Port. */
void gpio_port_write(uint32_t gpioport, uint32_t data) | {
GPIO_PDOR(gpioport) = data;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Description: This is the IPv4 hashing function for the node interface table, it returns the bucket number for the given IP address. */ | static unsigned int sel_netnode_hashfn_ipv4(__be32 addr) | /* Description: This is the IPv4 hashing function for the node interface table, it returns the bucket number for the given IP address. */
static unsigned int sel_netnode_hashfn_ipv4(__be32 addr) | {
return (addr & (SEL_NETNODE_HASH_SIZE - 1));
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* fill the target region with a given 8bit colour */ | arm_fsm_rt_t arm_2dp_c8bit_fill_colour(arm_2d_op_fill_cl_t *ptOP, const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, uint_fast8_t chColour) | /* fill the target region with a given 8bit colour */
arm_fsm_rt_t arm_2dp_c8bit_fill_colour(arm_2d_op_fill_cl_t *ptOP, const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, uint_fast8_t chColour) | {
assert(NULL != ptTarget);
ARM_2D_IMPL(arm_2d_op_fill_cl_t, ptOP);
if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) {
return arm_fsm_rt_on_going;
}
OP_CORE.ptOp = &ARM_2D_OP_FILL_COLOUR_C8BIT;
this.Target.ptTile = ptTarget;
this.Target.ptRegion = ptRegion;
this.chColour = chColour;
return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis);
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Base on the type to compare the value. */ | BOOLEAN IsValuesEqual(IN EFI_IFR_TYPE_VALUE *Value1, IN EFI_IFR_TYPE_VALUE *Value2, IN UINT8 Type) | /* Base on the type to compare the value. */
BOOLEAN IsValuesEqual(IN EFI_IFR_TYPE_VALUE *Value1, IN EFI_IFR_TYPE_VALUE *Value2, IN UINT8 Type) | {
switch (Type) {
case EFI_IFR_TYPE_BOOLEAN:
case EFI_IFR_TYPE_NUM_SIZE_8:
return (BOOLEAN)(Value1->u8 == Value2->u8);
case EFI_IFR_TYPE_NUM_SIZE_16:
return (BOOLEAN)(Value1->u16 == Value2->u16);
case EFI_IFR_TYPE_NUM_SIZE_32:
return (BOOLEAN)(Value1->u32 == Value2->u32);
case EFI_IFR_TYPE_NUM_SIZE_64:
return (BOOLEAN)(Value1->u64 == Value2->u64);
default:
ASSERT (FALSE);
return FALSE;
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* ixgbe_atr_get_flex_byte_82599 - Gets the flexible bytes @input: input stream to modify @flex_bytes: the flexible bytes to load */ | static s32 ixgbe_atr_get_flex_byte_82599(struct ixgbe_atr_input *input, u16 *flex_byte) | /* ixgbe_atr_get_flex_byte_82599 - Gets the flexible bytes @input: input stream to modify @flex_bytes: the flexible bytes to load */
static s32 ixgbe_atr_get_flex_byte_82599(struct ixgbe_atr_input *input, u16 *flex_byte) | {
*flex_byte = input->byte_stream[IXGBE_ATR_FLEX_BYTE_OFFSET];
*flex_byte |= input->byte_stream[IXGBE_ATR_FLEX_BYTE_OFFSET + 1] << 8;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Disable the interrupt mode for the selected IT source. */ | void mfxstm32l152_DisableITSource(uint16_t DeviceAddr, uint8_t Source) | /* Disable the interrupt mode for the selected IT source. */
void mfxstm32l152_DisableITSource(uint16_t DeviceAddr, uint8_t Source) | {
uint8_t tmp = 0;
tmp = MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_SRC_EN);
tmp &= ~Source;
MFX_IO_Write(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_SRC_EN, tmp);
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* This function will do USB_REQ_SET_FEATURE request for the device instance to set feature of the hub port. */ | rt_err_t rt_usb_hub_set_port_feature(uhubinst_t uhub, rt_uint16_t port, rt_uint16_t feature) | /* This function will do USB_REQ_SET_FEATURE request for the device instance to set feature of the hub port. */
rt_err_t rt_usb_hub_set_port_feature(uhubinst_t uhub, rt_uint16_t port, rt_uint16_t feature) | {
struct ureqest setup;
int timeout = 100;
RT_ASSERT(uhub != RT_NULL);
if(uhub->is_roothub)
{
rt_usb_hcd_hub_control(uhub->hcd, port, RH_SET_PORT_FEATURE,
(void*)feature);
return RT_EOK;
}
setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS |
USB_REQ_TYPE_OTHER;
setup.request = USB_REQ_SET_FEATURE;
setup.index = port;
setup.length = 0;
setup.value = feature;
if(rt_usb_hcd_control_xfer(uhub->hcd, uhub->self, &setup, RT_NULL, 0,
timeout) == 0) return RT_EOK;
else return -RT_FALSE;
} | armink/FreeModbus_Slave-Master-RTT-STM32 | C++ | Other | 1,477 |
/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ` */ | size_t atomicio(ssize_t(*f)(int, void *, size_t), int fd, void *_s, size_t n) | /* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ` */
size_t atomicio(ssize_t(*f)(int, void *, size_t), int fd, void *_s, size_t n) | {
char *s = _s;
size_t pos = 0;
ssize_t res;
struct pollfd pfd;
pfd.fd = fd;
pfd.events = f == read ? POLLIN : POLLOUT;
while (n > pos) {
res = (f) (fd, s + pos, n - pos);
switch (res) {
case -1:
if (errno == EINTR)
continue;
if ((errno == EAGAIN) || (errno == ENOBUFS)) {
(void)poll(&pfd, 1, -1);
continue;
}
return 0;
case 0:
errno = EPIPE;
return pos;
default:
pos += (size_t)res;
}
}
return (pos);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* param base PXP peripheral base address. param upperLeftX X of the upper left corner. param upperLeftY Y of the upper left corner. param lowerRightX X of the lower right corner. param lowerRightY Y of the lower right corner. */ | void PXP_SetAlphaSurfacePosition(PXP_Type *base, uint16_t upperLeftX, uint16_t upperLeftY, uint16_t lowerRightX, uint16_t lowerRightY) | /* param base PXP peripheral base address. param upperLeftX X of the upper left corner. param upperLeftY Y of the upper left corner. param lowerRightX X of the lower right corner. param lowerRightY Y of the lower right corner. */
void PXP_SetAlphaSurfacePosition(PXP_Type *base, uint16_t upperLeftX, uint16_t upperLeftY, uint16_t lowerRightX, uint16_t lowerRightY) | {
base->OUT_AS_ULC = PXP_OUT_AS_ULC_Y(upperLeftY) | PXP_OUT_AS_ULC_X(upperLeftX);
base->OUT_AS_LRC = PXP_OUT_AS_LRC_Y(lowerRightY) | PXP_OUT_AS_LRC_X(lowerRightX);
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Registers a USB host pipe callback.
Registers a callback function which is implemented by the user. */ | enum status_code usb_host_pipe_register_callback(struct usb_module *module_inst, uint8_t pipe_num, enum usb_host_pipe_callback callback_type, usb_host_pipe_callback_t callback_func) | /* Registers a USB host pipe callback.
Registers a callback function which is implemented by the user. */
enum status_code usb_host_pipe_register_callback(struct usb_module *module_inst, uint8_t pipe_num, enum usb_host_pipe_callback callback_type, usb_host_pipe_callback_t callback_func) | {
Assert(module_inst);
Assert(pipe_num < USB_PIPE_NUM);
Assert(callback_func);
module_inst->host_pipe_callback[pipe_num][callback_type] = callback_func;
module_inst->host_pipe_registered_callback_mask[pipe_num] |= (1 << callback_type);
return STATUS_OK;
} | memfault/zero-to-main | C++ | null | 200 |
/* Checks whether the specified EXTI line flag is set or not. */ | FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line) | /* Checks whether the specified EXTI line flag is set or not. */
FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line) | {
FlagStatus bitstatus = RESET;
assert_param(IS_GET_EXTI_LINE(EXTI_Line));
if ((*(__IO uint32_t *) (((uint32_t) &(EXTI->PR)) + ((EXTI_Line) >> 5 ) * 0x20)& (uint32_t)(1 << (EXTI_Line & 0x1F))) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
} | ajhc/demo-cortex-m3 | C++ | null | 38 |
/* Restarts a previously interrupted write. The caller must provide the block protocol needed to complete the interrupted write. */ | EFI_STATUS EFIAPI FtwRestart(IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This, IN EFI_HANDLE FvBlockHandle) | /* Restarts a previously interrupted write. The caller must provide the block protocol needed to complete the interrupted write. */
EFI_STATUS EFIAPI FtwRestart(IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This, IN EFI_HANDLE FvBlockHandle) | {
EFI_STATUS Status;
UINTN PayloadSize;
EFI_MM_COMMUNICATE_HEADER *SmmCommunicateHeader;
SMM_FTW_RESTART_HEADER *SmmFtwRestartHeader;
PayloadSize = sizeof (SMM_FTW_RESTART_HEADER);
InitCommunicateBuffer ((VOID **)&SmmCommunicateHeader, (VOID **)&SmmFtwRestartHeader, PayloadSize, FTW_FUNCTION_RESTART);
Status = ConvertFvbHandle (FvBlockHandle, &SmmFtwRestartHeader->FvbBaseAddress, &SmmFtwRestartHeader->FvbAttributes);
if (EFI_ERROR (Status)) {
FreePool (SmmCommunicateHeader);
return EFI_ABORTED;
}
Status = SendCommunicateBuffer (SmmCommunicateHeader, PayloadSize);
FreePool (SmmCommunicateHeader);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Parse a GUID from the input stream. Stop when you discover white space. */ | BOOLEAN SFPGetGuidToken(CHAR8 *Str, UINT32 Len) | /* Parse a GUID from the input stream. Stop when you discover white space. */
BOOLEAN SFPGetGuidToken(CHAR8 *Str, UINT32 Len) | {
UINT32 Index;
SkipWhiteSpace (&mGlobals.SourceFile);
if (EndOfFile (&mGlobals.SourceFile)) {
return FALSE;
}
Index = 0;
while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) {
if (IsWhiteSpace (&mGlobals.SourceFile)) {
if (Index > 0) {
Str[Index] = 0;
return TRUE;
}
return FALSE;
} else {
Str[Index] = mGlobals.SourceFile.FileBufferPtr[0];
mGlobals.SourceFile.FileBufferPtr++;
Index++;
}
}
return FALSE;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Get an inode and join it to the transaction. */ | int xfs_trans_iget(xfs_mount_t *mp, xfs_trans_t *tp, xfs_ino_t ino, uint flags, uint lock_flags, xfs_inode_t **ipp) | /* Get an inode and join it to the transaction. */
int xfs_trans_iget(xfs_mount_t *mp, xfs_trans_t *tp, xfs_ino_t ino, uint flags, uint lock_flags, xfs_inode_t **ipp) | {
int error;
error = xfs_iget(mp, tp, ino, flags, lock_flags, ipp, 0);
if (!error && tp)
xfs_trans_ijoin(tp, *ipp, lock_flags);
return error;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* s2io_init_pci -Initialization of PCI and PCI-X configuration registers . @sp : private member of the device structure, which is a pointer to the s2io_nic structure. Description: This function initializes a few of the PCI and PCI-X configuration registers with recommended values. Return value: void */ | static void s2io_init_pci(struct s2io_nic *sp) | /* s2io_init_pci -Initialization of PCI and PCI-X configuration registers . @sp : private member of the device structure, which is a pointer to the s2io_nic structure. Description: This function initializes a few of the PCI and PCI-X configuration registers with recommended values. Return value: void */
static void s2io_init_pci(struct s2io_nic *sp) | {
u16 pci_cmd = 0, pcix_cmd = 0;
pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
&(pcix_cmd));
pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
(pcix_cmd | 1));
pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
&(pcix_cmd));
pci_read_config_word(sp->pdev, PCI_COMMAND, &pci_cmd);
pci_write_config_word(sp->pdev, PCI_COMMAND,
(pci_cmd | PCI_COMMAND_PARITY));
pci_read_config_word(sp->pdev, PCI_COMMAND, &pci_cmd);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* __scsi_put_command - Free a struct scsi_cmnd @shost: dev->host @cmd: Command to free @dev: parent scsi device */ | void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd, struct device *dev) | /* __scsi_put_command - Free a struct scsi_cmnd @shost: dev->host @cmd: Command to free @dev: parent scsi device */
void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd, struct device *dev) | {
unsigned long flags;
spin_lock_irqsave(&shost->free_list_lock, flags);
if (unlikely(list_empty(&shost->free_list))) {
list_add(&cmd->list, &shost->free_list);
cmd = NULL;
}
spin_unlock_irqrestore(&shost->free_list_lock, flags);
if (likely(cmd != NULL))
scsi_pool_free_command(shost->cmd_pool, cmd);
put_device(dev);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function will install or confirm action for specified signal. */ | int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) | /* This function will install or confirm action for specified signal. */
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) | {
rt_sighandler_t old = RT_NULL;
if (!sig_valid(signum)) return -RT_ERROR;
if (act)
old = rt_signal_install(signum, act->sa_handler);
else
{
old = rt_signal_install(signum, RT_NULL);
rt_signal_install(signum, old);
}
if (oldact)
oldact->sa_handler = old;
return 0;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* DMAMUX Enable Request Generator Channel.
Enable Request Generator Channel, Producting DMA Request on input signal trigger. These Requests are usable by the DMA Request Router. */ | void dmamux_enable_request_generator(uint32_t dmamux, uint8_t rg_channel) | /* DMAMUX Enable Request Generator Channel.
Enable Request Generator Channel, Producting DMA Request on input signal trigger. These Requests are usable by the DMA Request Router. */
void dmamux_enable_request_generator(uint32_t dmamux, uint8_t rg_channel) | {
DMAMUX_RGxCR(dmamux, rg_channel) |= DMAMUX_RGxCR_GE;
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* This function creates a new TLS object for a connection. The new object inherits the setting of the underlying context TlsCtx: connection method, options, verification setting. */ | VOID* EFIAPI CryptoServiceTlsNew(IN VOID *TlsCtx) | /* This function creates a new TLS object for a connection. The new object inherits the setting of the underlying context TlsCtx: connection method, options, verification setting. */
VOID* EFIAPI CryptoServiceTlsNew(IN VOID *TlsCtx) | {
return CALL_BASECRYPTLIB (Tls.Services.New, TlsNew, (TlsCtx), NULL);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Create a template DHCPv4 packet as a seed. */ | VOID PxeBcSeedDhcp4Packet(OUT EFI_DHCP4_PACKET *Seed, IN EFI_UDP4_PROTOCOL *Udp4) | /* Create a template DHCPv4 packet as a seed. */
VOID PxeBcSeedDhcp4Packet(OUT EFI_DHCP4_PACKET *Seed, IN EFI_UDP4_PROTOCOL *Udp4) | {
EFI_SIMPLE_NETWORK_MODE Mode;
EFI_DHCP4_HEADER *Header;
Udp4->GetModeData (Udp4, NULL, NULL, NULL, &Mode);
Seed->Size = sizeof (EFI_DHCP4_PACKET);
Seed->Length = sizeof (Seed->Dhcp4);
Header = &Seed->Dhcp4.Header;
ZeroMem (Header, sizeof (EFI_DHCP4_HEADER));
Header->OpCode = PXEBC_DHCP4_OPCODE_REQUEST;
Header->HwType = Mode.IfType;
Header->HwAddrLen = (UINT8)Mode.HwAddressSize;
CopyMem (Header->ClientHwAddr, &Mode.CurrentAddress, Header->HwAddrLen);
Seed->Dhcp4.Magik = PXEBC_DHCP4_MAGIC;
Seed->Dhcp4.Option[0] = DHCP4_TAG_EOP;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* ubi_dump_mkvol_req - dump a &struct ubi_mkvol_req object. @req: the object to dump */ | void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req) | /* ubi_dump_mkvol_req - dump a &struct ubi_mkvol_req object. @req: the object to dump */
void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req) | {
char nm[17];
pr_err("Volume creation request dump:\n");
pr_err("\tvol_id %d\n", req->vol_id);
pr_err("\talignment %d\n", req->alignment);
pr_err("\tbytes %lld\n", (long long)req->bytes);
pr_err("\tvol_type %d\n", req->vol_type);
pr_err("\tname_len %d\n", req->name_len);
memcpy(nm, req->name, 16);
nm[16] = 0;
pr_err("\t1st 16 characters of name: %s\n", nm);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* SPI Enable the CRC.
The SPI peripheral is set to use a CRC field for transmit and receive. */ | void spi_enable_crc(uint32_t spi) | /* SPI Enable the CRC.
The SPI peripheral is set to use a CRC field for transmit and receive. */
void spi_enable_crc(uint32_t spi) | {
SPI_CR1(spi) |= SPI_CR1_CRCEN;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* A lot of BIOS fill in 10 (= no distance) everywhere. This messes up the NUMA heuristics which wants the local node to have a smaller distance than the others. Do some quick checks here and only use the SLIT if it passes. */ | static __init int slit_valid(struct acpi_table_slit *slit) | /* A lot of BIOS fill in 10 (= no distance) everywhere. This messes up the NUMA heuristics which wants the local node to have a smaller distance than the others. Do some quick checks here and only use the SLIT if it passes. */
static __init int slit_valid(struct acpi_table_slit *slit) | {
int i, j;
int d = slit->locality_count;
for (i = 0; i < d; i++) {
for (j = 0; j < d; j++) {
u8 val = slit->entry[d*i + j];
if (i == j) {
if (val != LOCAL_DISTANCE)
return 0;
} else if (val <= LOCAL_DISTANCE)
return 0;
}
}
return 1;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Specifies the ouput polarity of the PWM at the specified state of counter. */ | void TMRA_PWM_SetPolarity(CM_TMRA_TypeDef *TMRAx, uint32_t u32Ch, uint8_t u8CountState, uint16_t u16Polarity) | /* Specifies the ouput polarity of the PWM at the specified state of counter. */
void TMRA_PWM_SetPolarity(CM_TMRA_TypeDef *TMRAx, uint32_t u32Ch, uint8_t u8CountState, uint16_t u16Polarity) | {
uint32_t u32PCONRAddr;
DDL_ASSERT(IS_TMRA_UNIT_CH(TMRAx, u32Ch));
DDL_ASSERT(IS_TMRA_PWM_POLARITY(u8CountState, u16Polarity));
u32PCONRAddr = (uint32_t)&TMRAx->PCONR1 + (u32Ch * 4U);
MODIFY_REG16(RW_MEM16(u32PCONRAddr),
(uint16_t)TMRA_PWM_POLARITY_MASK << (u8CountState * 2U),
u16Polarity << (u8CountState * 2U));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* First part error handler. This is called whenever any error CRB interrupt is generated by the II. */ | void bte_crb_error_handler(cnodeid_t cnode, int btenum, int crbnum, ioerror_t *ioe, int bteop) | /* First part error handler. This is called whenever any error CRB interrupt is generated by the II. */
void bte_crb_error_handler(cnodeid_t cnode, int btenum, int crbnum, ioerror_t *ioe, int bteop) | {
struct bteinfo_s *bte;
bte = &(NODEPDA(cnode)->bte_if[btenum]);
bte->bh_error = ioe->ie_errortype + BTEFAIL_OFFSET;
bte->bte_error_count++;
BTE_PRINTK(("Got an error on cnode %d bte %d: HW error type 0x%x\n",
bte->bte_cnode, bte->bte_num, ioe->ie_errortype));
bte_error_handler((unsigned long) NODEPDA(cnode));
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Write data element to the SPI interface with Noblock. */ | long xSPIDataPutNonBlocking(unsigned long ulBase, unsigned long ulData) | /* Write data element to the SPI interface with Noblock. */
long xSPIDataPutNonBlocking(unsigned long ulBase, unsigned long ulData) | {
unsigned char ucBitLength = SPIBitLengthGet(ulBase);
unsigned long ulFlag;
xASSERT(ulBase == SPI0_BASE);
ulFlag = xHWREG(ulBase + SPI_FCR) & SPI_FCR_FIFOEN;
if(ulFlag != SPI_FCR_FIFOEN)
{
if(!(xHWREG(ulBase + SPI_SR) & SPI_SR_TXE))
{
return 0;
}
}
else
{
if(!(xHWREG(ulBase + SPI_SR) & SPI_SR_TXBE))
{ return 0;
}
}
if(ucBitLength <= 8 && ucBitLength != 0)
{
xHWREG(ulBase + SPI_DR) = ulData & 0xFF;
}
else
{
xHWREG(ulBase + SPI_DR) = ulData & 0xFFFF;
}
return 1;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Return value: the LCD filter for the font options object */ | cairo_lcd_filter_t _cairo_font_options_get_lcd_filter(const cairo_font_options_t *options) | /* Return value: the LCD filter for the font options object */
cairo_lcd_filter_t _cairo_font_options_get_lcd_filter(const cairo_font_options_t *options) | {
if (cairo_font_options_status ((cairo_font_options_t *) options))
return CAIRO_LCD_FILTER_DEFAULT;
return options->lcd_filter;
} | xboot/xboot | C++ | MIT License | 779 |
/* Search a Question in Formset scope using its QuestionId. */ | HII_STATEMENT* QuestionIdInFormset(IN HII_FORMSET *FormSet, IN HII_FORM *Form, IN UINT16 QuestionId) | /* Search a Question in Formset scope using its QuestionId. */
HII_STATEMENT* QuestionIdInFormset(IN HII_FORMSET *FormSet, IN HII_FORM *Form, IN UINT16 QuestionId) | {
LIST_ENTRY *Link;
HII_STATEMENT *Question;
if ((FormSet == NULL) || (Form == NULL)) {
return NULL;
}
Question = QuestionIdInForm (Form, QuestionId);
if (Question != NULL) {
return Question;
}
Link = GetFirstNode (&FormSet->FormListHead);
while (!IsNull (&FormSet->FormListHead, Link)) {
Form = HII_FORM_FROM_LINK (Link);
Question = QuestionIdInForm (Form, QuestionId);
if (Question != NULL) {
if (Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
GetQuestionValue (FormSet, Form, Question, GetSetValueWithHiiDriver);
}
return Question;
}
Link = GetNextNode (&FormSet->FormListHead, Link);
}
return NULL;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Builds a Request Data Object (RDO) with the following properties: */ | static uint32_t build_rdo(const struct port0_data_t *dpm_data) | /* Builds a Request Data Object (RDO) with the following properties: */
static uint32_t build_rdo(const struct port0_data_t *dpm_data) | {
union pd_rdo rdo;
rdo.fixed.min_or_max_operating_current = PD_CONVERT_MA_TO_FIXED_PDO_CURRENT(100);
rdo.fixed.operating_current = PD_CONVERT_MA_TO_FIXED_PDO_CURRENT(100);
rdo.fixed.unchunked_ext_msg_supported = 0;
rdo.fixed.no_usb_suspend = 1;
rdo.fixed.usb_comm_capable = 0;
rdo.fixed.cap_mismatch = 0;
rdo.fixed.giveback = 0;
rdo.fixed.object_pos = 1;
return rdo.raw_value;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Restore the given page to saved presence state. */ | static void disarm_kmmio_fault_page(struct kmmio_fault_page *f) | /* Restore the given page to saved presence state. */
static void disarm_kmmio_fault_page(struct kmmio_fault_page *f) | {
int ret = clear_page_presence(f, false);
WARN_ONCE(ret < 0,
KERN_ERR "kmmio disarming 0x%08lx failed.\n", f->page);
f->armed = false;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Try to release metadata pages (indirect blocks, directories) which are mapped via the block device. Since these pages could have journal heads which would prevent try_to_free_buffers() from freeing them, we must use jbd2 layer's try_to_free_buffers() function to release them. */ | static int bdev_try_to_free_page(struct super_block *sb, struct page *page, gfp_t wait) | /* Try to release metadata pages (indirect blocks, directories) which are mapped via the block device. Since these pages could have journal heads which would prevent try_to_free_buffers() from freeing them, we must use jbd2 layer's try_to_free_buffers() function to release them. */
static int bdev_try_to_free_page(struct super_block *sb, struct page *page, gfp_t wait) | {
journal_t *journal = EXT4_SB(sb)->s_journal;
WARN_ON(PageChecked(page));
if (!page_has_buffers(page))
return 0;
if (journal)
return jbd2_journal_try_to_free_buffers(journal, page,
wait & ~__GFP_WAIT);
return try_to_free_buffers(page);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Clear a bit in the reserved memory bitmap in a thread safe manner */ | STATIC VOID ClearReservedMemBit(IN UINT32 ReservedMemBit) | /* Clear a bit in the reserved memory bitmap in a thread safe manner */
STATIC VOID ClearReservedMemBit(IN UINT32 ReservedMemBit) | {
UINT32 ReservedMemBitmap;
do {
ReservedMemBitmap = mReservedMemBitmap;
} while (ReservedMemBitmap != InterlockedCompareExchange32 (
&mReservedMemBitmap,
ReservedMemBitmap,
ReservedMemBitmap & ~ReservedMemBit
));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Snoop PTP packet for version 2 format When set the PTP packets are snooped using the version 2 format. */ | void synopGMAC_TS_pkt_snoop_ver1(synopGMACdevice *gmacdev) | /* Snoop PTP packet for version 2 format When set the PTP packets are snooped using the version 2 format. */
void synopGMAC_TS_pkt_snoop_ver1(synopGMACdevice *gmacdev) | {
synopGMACClearBits(gmacdev->MacBase, GmacTSControl, GmacTSVER2ENA);
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Resets the RCC clock configuration to the default reset state. */ | void RCC_DeInit(void) | /* Resets the RCC clock configuration to the default reset state. */
void RCC_DeInit(void) | {
RCC->CTRL |= (uint32_t)0x00000001;
RCC->CFG &= (uint32_t)0xF8FFC000;
RCC->CTRL &= (uint32_t)0xFEF6FFFF;
RCC->CTRL &= (uint32_t)0xFFFBFFFF;
RCC->CFG &= (uint32_t)0xF700FFFF;
RCC->CFG2 = 0x00003800;
RCC->CFG3 = 0x00003800;
RCC->CLKINT = 0x009F0000;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This comparator searches for the next Bulk Endpoint descriptor of the current Printer interface, aborting the search if another interface descriptor is found before the next endpoint. */ | uint8_t DComp_NextPrinterInterfaceBulkDataEndpoint(void *CurrentDescriptor) | /* This comparator searches for the next Bulk Endpoint descriptor of the current Printer interface, aborting the search if another interface descriptor is found before the next endpoint. */
uint8_t DComp_NextPrinterInterfaceBulkDataEndpoint(void *CurrentDescriptor) | {
USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
if (Header->Type == DTYPE_Endpoint)
{
USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
if ((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_BULK)
return DESCRIPTOR_SEARCH_Found;
}
else if (Header->Type == DTYPE_Interface)
{
return DESCRIPTOR_SEARCH_Fail;
}
return DESCRIPTOR_SEARCH_NotFound;
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* The function is used to set HCLK clock source. */ | void SysCtlHCLKSourceSet(unsigned long ulHclkSrcSel) | /* The function is used to set HCLK clock source. */
void SysCtlHCLKSourceSet(unsigned long ulHclkSrcSel) | {
unsigned long ulRegValue;
xASSERT((ulEnable == SYSCTL_HLCK_S_INT48M) ||
(ulEnable == SYSCTL_HLCK_S_EXT32K) ||
(ulEnable == SYSCTL_HLCK_S_INT16K));
SysCtlKeyAddrUnlock();
ulRegValue = xHWREG(SYSCLK_CLKSEL0);
ulRegValue &= ~SYSCLK_CLKSEL0_HCLK_S_M;
ulRegValue |= ulHclkSrcSel;
xHWREG(SYSCLK_CLKSEL0) = ulRegValue;
SysCtlKeyAddrLock();
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Programs n word at a specified start address. */ | void FLASH_ProgramWord(uint32_t Addr, uint32_t *WordBuffer, uint32_t Length) | /* Programs n word at a specified start address. */
void FLASH_ProgramWord(uint32_t Addr, uint32_t *WordBuffer, uint32_t Length) | {
uint32_t i;
assert_parameters(IS_FLASH_ADRRW(Addr));
FLASH->PGADDR = Addr;
FLASH->PASS = FLASH_PASS_KEY;
for (i=0; i<Length; i++)
{
FLASH->PGDATA = *(WordBuffer++);
while (FLASH->STS != 1);
}
FLASH->PASS = 0;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Check if the passed bus width is supported by controller and card. */ | BOOLEAN EmmcIsBusWidthSupported(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN SD_MMC_BUS_MODE BusTiming, IN UINT16 BusWidth) | /* Check if the passed bus width is supported by controller and card. */
BOOLEAN EmmcIsBusWidthSupported(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN SD_MMC_BUS_MODE BusTiming, IN UINT16 BusWidth) | {
if ((BusWidth == 8) && (Private->Capability[SlotIndex].BusWidth8 != 0)) {
return TRUE;
} else if ((BusWidth == 4) && (BusTiming != SdMmcMmcHs400)) {
return TRUE;
} else if ((BusWidth == 1) && ((BusTiming == SdMmcMmcHsSdr) || (BusTiming == SdMmcMmcLegacy))) {
return TRUE;
}
return FALSE;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Copies
All pointer and size alignments are supported. */ | volatile void* flashcalw_memset32(volatile void *dst, uint32_t src, size_t nbytes, bool erase) | /* Copies
All pointer and size alignments are supported. */
volatile void* flashcalw_memset32(volatile void *dst, uint32_t src, size_t nbytes, bool erase) | {
return flashcalw_memset64(dst, src | (uint64_t)src << 32, nbytes,
erase);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* It seems that the card insertion interrupt remains active after we've acknowledged it. We therefore ignore the interrupt, and rely on reading it from the SIC. This also means that we must clear the latched interrupt. */ | static unsigned int mmc_status(struct device *dev) | /* It seems that the card insertion interrupt remains active after we've acknowledged it. We therefore ignore the interrupt, and rely on reading it from the SIC. This also means that we must clear the latched interrupt. */
static unsigned int mmc_status(struct device *dev) | {
unsigned int status = readl(IO_ADDRESS(0xca000000) + 4);
writel(8, IO_ADDRESS(0xcb000000) + 8);
return status & 8;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Disables a Generic Clock Generator that was previously enabled.
Stops the clock generation of a Generic Clock Generator that was previously started via a call to */ | void system_gclk_gen_disable(const uint8_t generator) | /* Disables a Generic Clock Generator that was previously enabled.
Stops the clock generation of a Generic Clock Generator that was previously started via a call to */
void system_gclk_gen_disable(const uint8_t generator) | {
while (system_gclk_is_syncing(generator)) {
};
system_interrupt_enter_critical_section();
GCLK->GENCTRL[generator].reg &= ~GCLK_GENCTRL_GENEN;
while (GCLK->GENCTRL[generator].reg & GCLK_GENCTRL_GENEN) {
}
system_interrupt_leave_critical_section();
} | memfault/zero-to-main | C++ | null | 200 |
/* Submit a USB set configuration request for the USB device specified by UsbIo and set the device configuration to the value specified by ConfigurationValue. The status of the transfer is returned in Status. If UsbIo is NULL, then ASSERT(). If Status is NULL, then ASSERT(). */ | EFI_STATUS EFIAPI UsbSetConfiguration(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT16 ConfigurationValue, OUT UINT32 *Status) | /* Submit a USB set configuration request for the USB device specified by UsbIo and set the device configuration to the value specified by ConfigurationValue. The status of the transfer is returned in Status. If UsbIo is NULL, then ASSERT(). If Status is NULL, then ASSERT(). */
EFI_STATUS EFIAPI UsbSetConfiguration(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT16 ConfigurationValue, OUT UINT32 *Status) | {
EFI_USB_DEVICE_REQUEST DevReq;
ASSERT (UsbIo != NULL);
ASSERT (Status != NULL);
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
DevReq.RequestType = USB_DEV_SET_CONFIGURATION_REQ_TYPE;
DevReq.Request = USB_REQ_SET_CONFIG;
DevReq.Value = ConfigurationValue;
return UsbIo->UsbControlTransfer (
UsbIo,
&DevReq,
EfiUsbNoData,
PcdGet32 (PcdUsbTransferTimeoutValue),
NULL,
0,
Status
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Gets the FIFO level at which DMA requests or interrupts are generated. */ | void SPIFIFOLevelGet(unsigned long ulBase, unsigned long *pulTxLevel, unsigned long *pulRxLevel) | /* Gets the FIFO level at which DMA requests or interrupts are generated. */
void SPIFIFOLevelGet(unsigned long ulBase, unsigned long *pulTxLevel, unsigned long *pulRxLevel) | {
unsigned long ulRegVal;
ulRegVal = HWREG(ulBase + MCSPI_O_XFERLEVEL);
*pulTxLevel = (ulRegVal & 0xFF);
*pulRxLevel = ((ulRegVal >> 8) & 0xFF);
} | micropython/micropython | C++ | Other | 18,334 |
/* Submit a USB get descriptor request for the USB device specified by UsbIo, Value, and Index, and return the descriptor in the buffer specified by Descriptor. The status of the transfer is returned in Status. If UsbIo is NULL, then ASSERT(). If Descriptor is NULL, then ASSERT(). If Status is NULL, then ASSERT(). */ | EFI_STATUS EFIAPI UsbGetDescriptor(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT16 Value, IN UINT16 Index, IN UINT16 DescriptorLength, OUT VOID *Descriptor, OUT UINT32 *Status) | /* Submit a USB get descriptor request for the USB device specified by UsbIo, Value, and Index, and return the descriptor in the buffer specified by Descriptor. The status of the transfer is returned in Status. If UsbIo is NULL, then ASSERT(). If Descriptor is NULL, then ASSERT(). If Status is NULL, then ASSERT(). */
EFI_STATUS EFIAPI UsbGetDescriptor(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT16 Value, IN UINT16 Index, IN UINT16 DescriptorLength, OUT VOID *Descriptor, OUT UINT32 *Status) | {
EFI_USB_DEVICE_REQUEST DevReq;
ASSERT (UsbIo != NULL);
ASSERT (Descriptor != NULL);
ASSERT (Status != NULL);
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
DevReq.RequestType = USB_DEV_GET_DESCRIPTOR_REQ_TYPE;
DevReq.Request = USB_REQ_GET_DESCRIPTOR;
DevReq.Value = Value;
DevReq.Index = Index;
DevReq.Length = DescriptorLength;
return UsbIo->UsbControlTransfer (
UsbIo,
&DevReq,
EfiUsbDataIn,
PcdGet32 (PcdUsbTransferTimeoutValue),
Descriptor,
DescriptorLength,
Status
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Must NOT be called with interrupt disabled or spinlock held */ | void dwc2_hcd_qh_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) | /* Must NOT be called with interrupt disabled or spinlock held */
void dwc2_hcd_qh_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) | {
u32 buf_size;
if (hsotg->core_params->dma_desc_enable > 0) {
dwc2_hcd_qh_free_ddma(hsotg, qh);
} else if (qh->dw_align_buf) {
if (qh->ep_type == USB_ENDPOINT_XFER_ISOC)
buf_size = 4096;
else
buf_size = hsotg->core_params->max_transfer_size;
dma_free_coherent(hsotg->dev, buf_size, qh->dw_align_buf,
qh->dw_align_buf_dma);
}
kfree(qh);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Enable timestamp count. The count is saved in TIMESTAMP0_REG (40h), TIMESTAMP1_REG (41h) and TIMESTAMP2_REG (42h).. */ | int32_t lsm6dsl_timestamp_get(stmdev_ctx_t *ctx, uint8_t *val) | /* Enable timestamp count. The count is saved in TIMESTAMP0_REG (40h), TIMESTAMP1_REG (41h) and TIMESTAMP2_REG (42h).. */
int32_t lsm6dsl_timestamp_get(stmdev_ctx_t *ctx, uint8_t *val) | {
lsm6dsl_ctrl10_c_t ctrl10_c;
int32_t ret;
ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t*)&ctrl10_c, 1);
*val = ctrl10_c.timer_en;
return ret;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* The following routines are taken from page 170 of the 7th ARRL Computer Networking Conference paper, as is the whole state machine. */ | void nr_establish_data_link(struct sock *sk) | /* The following routines are taken from page 170 of the 7th ARRL Computer Networking Conference paper, as is the whole state machine. */
void nr_establish_data_link(struct sock *sk) | {
struct nr_sock *nr = nr_sk(sk);
nr->condition = 0x00;
nr->n2count = 0;
nr_write_internal(sk, NR_CONNREQ);
nr_stop_t2timer(sk);
nr_stop_t4timer(sk);
nr_stop_idletimer(sk);
nr_start_t1timer(sk);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* ALE bit 4 autcpu12_pedr CLE bit 5 autcpu12_pedr NCE bit 0 fio_ctrl */ | static void autcpu12_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl) | /* ALE bit 4 autcpu12_pedr CLE bit 5 autcpu12_pedr NCE bit 0 fio_ctrl */
static void autcpu12_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl) | {
struct nand_chip *chip = mtd->priv;
if (ctrl & NAND_CTRL_CHANGE) {
void __iomem *addr;
unsigned char bits;
addr = CS89712_VIRT_BASE + AUTCPU12_SMC_PORT_OFFSET;
bits = (ctrl & NAND_CLE) << 4;
bits |= (ctrl & NAND_ALE) << 2;
writeb((readb(addr) & ~0x30) | bits, addr);
addr = autcpu12_fio_base + AUTCPU12_SMC_SELECT_OFFSET;
writeb((readb(addr) & ~0x1) | (ctrl & NAND_NCE), addr);
}
if (cmd != NAND_CMD_NONE)
writeb(cmd, chip->IO_ADDR_W);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function implements the FatToStr() service of the EFI_UNICODE_COLLATION_PROTOCOL. */ | static void EFIAPI efi_fat_to_str(struct efi_unicode_collation_protocol *this, efi_uintn_t fat_size, char *fat, u16 *string) | /* This function implements the FatToStr() service of the EFI_UNICODE_COLLATION_PROTOCOL. */
static void EFIAPI efi_fat_to_str(struct efi_unicode_collation_protocol *this, efi_uintn_t fat_size, char *fat, u16 *string) | {
efi_uintn_t i;
u16 c;
EFI_ENTRY("%p, %zu, %s, %p", this, fat_size, fat, string);
for (i = 0; i < fat_size; ++i) {
c = (unsigned char)fat[i];
if (c > 0x80)
c = codepage[i - 0x80];
string[i] = c;
if (!c)
break;
}
string[i] = 0;
EFI_EXIT(EFI_SUCCESS);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Set up timer interrupt, and return the current time in seconds. */ | static void __init shark_timer_init(void) | /* Set up timer interrupt, and return the current time in seconds. */
static void __init shark_timer_init(void) | {
outb(0x34, 0x43);
outb(HZ_TIME & 0xff, 0x40);
outb(HZ_TIME >> 8, 0x40);
setup_irq(IRQ_TIMER, &shark_timer_irq);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Description: Process a user generated ADDDEF message and respond accordingly. Returns zero on success, negative values on failure. */ | static int netlbl_mgmt_adddef(struct sk_buff *skb, struct genl_info *info) | /* Description: Process a user generated ADDDEF message and respond accordingly. Returns zero on success, negative values on failure. */
static int netlbl_mgmt_adddef(struct sk_buff *skb, struct genl_info *info) | {
struct netlbl_audit audit_info;
if ((!info->attrs[NLBL_MGMT_A_PROTOCOL]) ||
(info->attrs[NLBL_MGMT_A_IPV4ADDR] &&
info->attrs[NLBL_MGMT_A_IPV6ADDR]) ||
(info->attrs[NLBL_MGMT_A_IPV4MASK] &&
info->attrs[NLBL_MGMT_A_IPV6MASK]) ||
((info->attrs[NLBL_MGMT_A_IPV4ADDR] != NULL) ^
(info->attrs[NLBL_MGMT_A_IPV4MASK] != NULL)) ||
((info->attrs[NLBL_MGMT_A_IPV6ADDR] != NULL) ^
(info->attrs[NLBL_MGMT_A_IPV6MASK] != NULL)))
return -EINVAL;
netlbl_netlink_auditinfo(skb, &audit_info);
return netlbl_mgmt_add_common(info, &audit_info);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Displays the code value as a character, not its ASCII value, as would be done by BASE_DEC and friends. */ | static void format_trade_correction_reason(char *buf, guint32 value) | /* Displays the code value as a character, not its ASCII value, as would be done by BASE_DEC and friends. */
static void format_trade_correction_reason(char *buf, guint32 value) | {
g_snprintf(buf, ITEM_LABEL_LENGTH,
"%s (%c)",
val_to_str_const(value,
ouch_trade_correction_reason_val,
"Unknown"),
value);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Returns zero if the buffer with the given size is allocated successfuly, other a negative value at error. */ | int snd_dma_alloc_pages_fallback(int type, struct device *device, size_t size, struct snd_dma_buffer *dmab) | /* Returns zero if the buffer with the given size is allocated successfuly, other a negative value at error. */
int snd_dma_alloc_pages_fallback(int type, struct device *device, size_t size, struct snd_dma_buffer *dmab) | {
int err;
while ((err = snd_dma_alloc_pages(type, device, size, dmab)) < 0) {
size_t aligned_size;
if (err != -ENOMEM)
return err;
if (size <= PAGE_SIZE)
return -ENOMEM;
aligned_size = PAGE_SIZE << get_order(size);
if (size != aligned_size)
size = aligned_size;
else
size >>= 1;
}
if (! dmab->area)
return -ENOMEM;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Get The Timer counter current up timer or up event counter value. */ | unsigned long xTimerValueGet(unsigned long ulBase, unsigned long ulChannel) | /* Get The Timer counter current up timer or up event counter value. */
unsigned long xTimerValueGet(unsigned long ulBase, unsigned long ulChannel) | {
xASSERT((ulBase == TIMER3_BASE) || (ulBase == TIMER2_BASE) ||
(ulBase == TIMER1_BASE) || (ulBase == TIMER0_BASE));
return (xHWREG(ulBase + TIMER_TDR) & TIMER_TDR_DATA_M);
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Disables I2C 10-bit header only mode with read direction. */ | void I2C_Disable10BitAddressHeader(I2C_T *i2c) | /* Disables I2C 10-bit header only mode with read direction. */
void I2C_Disable10BitAddressHeader(I2C_T *i2c) | {
i2c->CTRL2_B.ADDR10 = BIT_RESET;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Send channel number (i.e., switch to a different sound). */ | static void pod_send_channel(struct usb_line6_pod *pod, int value) | /* Send channel number (i.e., switch to a different sound). */
static void pod_send_channel(struct usb_line6_pod *pod, int value) | {
line6_invalidate_current(&pod->dumpreq);
if (line6_send_program(&pod->line6, value) == 0)
pod->channel_num = value;
else
line6_dump_finished(&pod->dumpreq);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Print strings that represent PCI device class, subclass and programmed I/F. */ | VOID PciPrintClassCode(IN UINT8 *ClassCodePtr, IN BOOLEAN IncludePIF) | /* Print strings that represent PCI device class, subclass and programmed I/F. */
VOID PciPrintClassCode(IN UINT8 *ClassCodePtr, IN BOOLEAN IncludePIF) | {
UINT32 ClassCode;
PCI_CLASS_STRINGS ClassStrings;
ClassCode = 0;
ClassCode |= (UINT32)ClassCodePtr[0];
ClassCode |= (UINT32)(ClassCodePtr[1] << 8);
ClassCode |= (UINT32)(ClassCodePtr[2] << 16);
PciGetClassStrings (ClassCode, &ClassStrings);
if (IncludePIF) {
ShellPrintEx (
-1,
-1,
L"%s - %s - %s",
ClassStrings.BaseClass,
ClassStrings.SubClass,
ClassStrings.PIFClass
);
} else {
ShellPrintEx (
-1,
-1,
L"%s - %s",
ClassStrings.BaseClass,
ClassStrings.SubClass
);
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Get RXBD read pointer, updated by SDIO IP. */ | u16 SDIO_RXBD_RPTR_Get(void) | /* Get RXBD read pointer, updated by SDIO IP. */
u16 SDIO_RXBD_RPTR_Get(void) | {
return HAL_SDIO_READ16(REG_SPDIO_RXBD_C2H_RPTR);
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* This function returns the TLS/SSL session ID currently used by the specified TLS connection. */ | EFI_STATUS EFIAPI CryptoServiceTlsGetSessionId(IN VOID *Tls, IN OUT UINT8 *SessionId, IN OUT UINT16 *SessionIdLen) | /* This function returns the TLS/SSL session ID currently used by the specified TLS connection. */
EFI_STATUS EFIAPI CryptoServiceTlsGetSessionId(IN VOID *Tls, IN OUT UINT8 *SessionId, IN OUT UINT16 *SessionIdLen) | {
return CALL_BASECRYPTLIB (TlsGet.Services.SessionId, TlsGetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* check if we do signal or reject an incoming call */ | static int pcbit_check_msn(struct pcbit_dev *dev, char *msn) | /* check if we do signal or reject an incoming call */
static int pcbit_check_msn(struct pcbit_dev *dev, char *msn) | {
struct msn_entry *ptr;
for (ptr=dev->msn_list; ptr; ptr=ptr->next) {
if (ptr->msn == NULL)
return 1;
if (strcmp(ptr->msn, msn) == 0)
return 1;
}
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns: (element-type GUnixMountPoint) (transfer full): a #GList of the UNIX mountpoints. */ | GList* g_unix_mount_points_get(guint64 *time_read) | /* Returns: (element-type GUnixMountPoint) (transfer full): a #GList of the UNIX mountpoints. */
GList* g_unix_mount_points_get(guint64 *time_read) | {
if (time_read)
*time_read = get_mount_points_timestamp ();
return _g_get_unix_mount_points ();
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Gets the status of a job.
Gets the status of an ongoing or the last job. */ | enum status_code dac_chan_get_job_status(struct dac_module *module_inst, const enum dac_channel channel) | /* Gets the status of a job.
Gets the status of an ongoing or the last job. */
enum status_code dac_chan_get_job_status(struct dac_module *module_inst, const enum dac_channel channel) | {
Assert(module_inst);
UNUSED(channel);
return module_inst->job_status;
} | memfault/zero-to-main | C++ | null | 200 |
/* Open/create errors are reported with an console message in TShark. */ | static void open_failure_message(const char *filename, int err, gboolean for_writing) | /* Open/create errors are reported with an console message in TShark. */
static void open_failure_message(const char *filename, int err, gboolean for_writing) | {
fprintf(stderr, "tshark: ");
fprintf(stderr, file_open_error_message(err, for_writing), filename);
fprintf(stderr, "\n");
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* vmbus_device_release - Final callback release of the vmbus child device */ | static void vmbus_device_release(struct device *device) | /* vmbus_device_release - Final callback release of the vmbus child device */
static void vmbus_device_release(struct device *device) | {
struct device_context *device_ctx = device_to_device_context(device);
DPRINT_ENTER(VMBUS_DRV);
kfree(device_ctx);
DPRINT_EXIT(VMBUS_DRV);
return;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* XXX - replace with APIs that let us handle multiple comments. */ | void wtap_write_shb_comment(wtap *wth, gchar *comment) | /* XXX - replace with APIs that let us handle multiple comments. */
void wtap_write_shb_comment(wtap *wth, gchar *comment) | {
if ((wth != NULL) && (wth->shb_hdrs != NULL) && (wth->shb_hdrs->len > 0)) {
wtap_block_set_nth_string_option_value(g_array_index(wth->shb_hdrs, wtap_block_t, 0), OPT_COMMENT, 0, comment, (gsize)(comment ? strlen(comment) : 0));
}
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Special start-of-pass hook. This is called by jpeg_write_scanlines if call_pass_startup is TRUE. In single-pass processing, we need this hook because we don't want to write frame/scan headers during jpeg_start_compress; we want to let the application write COM markers etc. between jpeg_start_compress and the jpeg_write_scanlines loop. In multi-pass processing, this routine is not used. */ | pass_startup(j_compress_ptr cinfo) | /* Special start-of-pass hook. This is called by jpeg_write_scanlines if call_pass_startup is TRUE. In single-pass processing, we need this hook because we don't want to write frame/scan headers during jpeg_start_compress; we want to let the application write COM markers etc. between jpeg_start_compress and the jpeg_write_scanlines loop. In multi-pass processing, this routine is not used. */
pass_startup(j_compress_ptr cinfo) | {
cinfo->master->call_pass_startup = FALSE;
(*cinfo->marker->write_frame_header) (cinfo);
(*cinfo->marker->write_scan_header) (cinfo);
} | nanoframework/nf-interpreter | C++ | MIT License | 293 |
/* checks whether this descriptor contains start of frame. This function is to check whether the descriptor's data buffer contains a fresh ethernet frame? */ | bool synopGMAC_is_sof_in_rx_desc(DmaDesc *desc) | /* checks whether this descriptor contains start of frame. This function is to check whether the descriptor's data buffer contains a fresh ethernet frame? */
bool synopGMAC_is_sof_in_rx_desc(DmaDesc *desc) | {
return ((desc->status & DescRxFirst) == DescRxFirst);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function returns zero in case of success and a negative error code in case of failure. */ | static int add_replay_bud(struct ubifs_info *c, int lnum, int offs, int jhead, unsigned long long sqnum) | /* This function returns zero in case of success and a negative error code in case of failure. */
static int add_replay_bud(struct ubifs_info *c, int lnum, int offs, int jhead, unsigned long long sqnum) | {
struct ubifs_bud *bud;
struct bud_entry *b;
dbg_mnt("add replay bud LEB %d:%d, head %d", lnum, offs, jhead);
bud = kmalloc(sizeof(struct ubifs_bud), GFP_KERNEL);
if (!bud)
return -ENOMEM;
b = kmalloc(sizeof(struct bud_entry), GFP_KERNEL);
if (!b) {
kfree(bud);
return -ENOMEM;
}
bud->lnum = lnum;
bud->start = offs;
bud->jhead = jhead;
ubifs_add_bud(c, bud);
b->bud = bud;
b->sqnum = sqnum;
list_add_tail(&b->list, &c->replay_buds);
return 0;
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Note that phys_device is optional. It is here to allow for differentiation between which */ | static int add_memory_block(int nid, struct mem_section *section, unsigned long state, int phys_device, enum mem_add_context context) | /* Note that phys_device is optional. It is here to allow for differentiation between which */
static int add_memory_block(int nid, struct mem_section *section, unsigned long state, int phys_device, enum mem_add_context context) | {
struct memory_block *mem = kzalloc(sizeof(*mem), GFP_KERNEL);
int ret = 0;
if (!mem)
return -ENOMEM;
mem->phys_index = __section_nr(section);
mem->state = state;
mutex_init(&mem->state_mutex);
mem->phys_device = phys_device;
ret = register_memory(mem, section);
if (!ret)
ret = mem_create_simple_file(mem, phys_index);
if (!ret)
ret = mem_create_simple_file(mem, state);
if (!ret)
ret = mem_create_simple_file(mem, phys_device);
if (!ret)
ret = mem_create_simple_file(mem, removable);
if (!ret) {
if (context == HOTPLUG)
ret = register_mem_sect_under_node(mem, nid);
}
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* configure RCU function
, V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */ | void rcu_config(void) | /* configure RCU function
, V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */
void rcu_config(void) | {
rcu_adc_clock_config(RCU_ADCCK_APB2_DIV8);
rcu_periph_clock_enable(RCU_OPAIVREF);
rcu_periph_clock_enable(RCU_GPIOA);
rcu_periph_clock_enable(RCU_GPIOC);
rcu_periph_clock_enable(RCU_ADC);
} | liuxuming/trochili | C++ | Apache License 2.0 | 132 |
/* Context: This function must not be called in interrupt context. */ | void isc_register(unsigned int isc) | /* Context: This function must not be called in interrupt context. */
void isc_register(unsigned int isc) | {
if (isc > MAX_ISC) {
WARN_ON(1);
return;
}
spin_lock(&isc_ref_lock);
if (isc_refs[isc] == 0)
ctl_set_bit(6, 31 - isc);
isc_refs[isc]++;
spin_unlock(&isc_ref_lock);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Sets an alternate lookup key for the hostinfo bound to this @hl driver and @host. */ | void hpsb_set_hostinfo_key(struct hpsb_highlevel *hl, struct hpsb_host *host, unsigned long key) | /* Sets an alternate lookup key for the hostinfo bound to this @hl driver and @host. */
void hpsb_set_hostinfo_key(struct hpsb_highlevel *hl, struct hpsb_host *host, unsigned long key) | {
struct hl_host_info *hi;
hi = hl_get_hostinfo(hl, host);
if (hi)
hi->key = key;
return;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Set the SOFTRESET bit in @v for hwmod @oh. Returns -EINVAL upon error or 0 upon success. */ | static int _set_softreset(struct omap_hwmod *oh, u32 *v) | /* Set the SOFTRESET bit in @v for hwmod @oh. Returns -EINVAL upon error or 0 upon success. */
static int _set_softreset(struct omap_hwmod *oh, u32 *v) | {
if (!oh->sysconfig ||
!(oh->sysconfig->sysc_flags & SYSC_HAS_SOFTRESET))
return -EINVAL;
*v |= SYSC_SOFTRESET_MASK;
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Returns the Stall status of the Tx endpoint. */ | uint16_t USB_GetTxStallSts(uint8_t bEpNum) | /* Returns the Stall status of the Tx endpoint. */
uint16_t USB_GetTxStallSts(uint8_t bEpNum) | {
return (_GetTxStallStatus(bEpNum));
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* If the application is using a static interrupt vector table stored in flash, then it is not necessary to register the interrupt handler this way. Instead, IntEnable() should be used to enable CAN interrupts on the interrupt controller. */ | void CANIntRegister(uint32_t ui32Base, void(*pfnHandler)(void)) | /* If the application is using a static interrupt vector table stored in flash, then it is not necessary to register the interrupt handler this way. Instead, IntEnable() should be used to enable CAN interrupts on the interrupt controller. */
void CANIntRegister(uint32_t ui32Base, void(*pfnHandler)(void)) | {
uint_fast8_t ui8IntNumber;
ASSERT(_CANBaseValid(ui32Base));
ui8IntNumber = _CANIntNumberGet(ui32Base);
ASSERT(ui8IntNumber != 0);
IntRegister(ui8IntNumber, pfnHandler);
IntEnable(ui8IntNumber);
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* sunxi_lcd_dsi_clk_disable - disable dsi clk. @screen_id: The index of screen. */ | s32 sunxi_lcd_dsi_clk_disable(u32 screen_id) | /* sunxi_lcd_dsi_clk_disable - disable dsi clk. @screen_id: The index of screen. */
s32 sunxi_lcd_dsi_clk_disable(u32 screen_id) | {
if (g_lcd_drv.src_ops.sunxi_lcd_dsi_clk_enable)
return g_lcd_drv.src_ops.sunxi_lcd_dsi_clk_enable(screen_id, 0);
return -1;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function is used to clear dma interrupt flag. */ | void tls_dma_irq_clr(unsigned char ch, unsigned char flags) | /* This function is used to clear dma interrupt flag. */
void tls_dma_irq_clr(unsigned char ch, unsigned char flags) | {
unsigned int int_src = 0;
int_src |= flags << 2 * ch;
tls_reg_write32(HR_DMA_INT_SRC, int_src);
return;
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* We need to consider the worse case, when one new block per extent. */ | int ext4_writepage_trans_blocks(struct inode *inode) | /* We need to consider the worse case, when one new block per extent. */
int ext4_writepage_trans_blocks(struct inode *inode) | {
int bpp = ext4_journal_blocks_per_page(inode);
int ret;
ret = ext4_meta_trans_blocks(inode, bpp, 0);
if (ext4_should_journal_data(inode))
ret += bpp;
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Slave finish up a transfer. It would call back if there is callback function and set the state to idle. This is not a public API. */ | static void LPSPI_SlaveTransferComplete(LPSPI_Type *base, lpspi_slave_handle_t *handle) | /* Slave finish up a transfer. It would call back if there is callback function and set the state to idle. This is not a public API. */
static void LPSPI_SlaveTransferComplete(LPSPI_Type *base, lpspi_slave_handle_t *handle) | {
assert(handle != NULL);
status_t status = kStatus_Success;
LPSPI_DisableInterrupts(base, (uint32_t)kLPSPI_AllInterruptEnable);
if (handle->state == (uint8_t)kLPSPI_Error)
{
status = kStatus_LPSPI_Error;
}
else
{
status = kStatus_Success;
}
handle->state = (uint8_t)kLPSPI_Idle;
if (handle->callback != NULL)
{
handle->callback(base, handle, status, handle->userData);
}
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Writes the radio register at the specified address. */ | void RadioWrite(uint32_t addr, uint8_t data) | /* Writes the radio register at the specified address. */
void RadioWrite(uint32_t addr, uint8_t data) | {
SX126xWriteRegister( addr, data );
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* This is the task that runs the Link Layer. */ | void ble_ll_task(void *arg) | /* This is the task that runs the Link Layer. */
void ble_ll_task(void *arg) | {
struct ble_npl_event *ev;
ble_phy_init();
ble_phy_txpwr_set(MYNEWT_VAL(BLE_LL_TX_PWR_DBM));
ble_hci_trans_cfg_ll(ble_ll_hci_cmd_rx, NULL, ble_ll_hci_acl_rx, NULL);
ble_ll_hci_send_noop();
while (1) {
ev = ble_npl_eventq_get(&g_ble_ll_data.ll_evq, BLE_NPL_TIME_FOREVER);
assert(ev);
ble_npl_event_run(ev);
}
} | arendst/Tasmota | C++ | GNU General Public License v3.0 | 21,318 |
/* Get the controller version information from the specified slot. */ | EFI_STATUS SdMmcHcGetControllerVersion(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, OUT UINT16 *Version) | /* Get the controller version information from the specified slot. */
EFI_STATUS SdMmcHcGetControllerVersion(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, OUT UINT16 *Version) | {
EFI_STATUS Status;
Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_CTRL_VER, TRUE, sizeof (UINT16), Version);
if (EFI_ERROR (Status)) {
return Status;
}
*Version &= 0xFF;
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* SC_SaveVoltage Saves the voltage value to be saved for further usage. */ | static void SC_SaveVoltage(uint8_t voltage) | /* SC_SaveVoltage Saves the voltage value to be saved for further usage. */
static void SC_SaveVoltage(uint8_t voltage) | {
SC_Param.voltage = voltage;
return;
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.