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
/* Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations. */
UINTN EFIAPI Sha1GetContextSize(VOID)
/* Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations. */ UINTN EFIAPI Sha1GetContextSize(VOID)
{ return (UINTN)(sizeof (SHA_CTX)); }
tianocore/edk2
C++
Other
4,240
/* tegra_ahub_wait_for_space() - Wait for space in the FIFO */
static int tegra_ahub_wait_for_space(struct udevice *dev)
/* tegra_ahub_wait_for_space() - Wait for space in the FIFO */ static int tegra_ahub_wait_for_space(struct udevice *dev)
{ int i = 100000; ulong start; while (i--) { if (!tegra_ahub_apbif_is_full(dev)) return 0; } start = get_timer(0); while (tegra_ahub_apbif_is_full(dev)) { if (get_timer(start) > 100) return -ETIMEDOUT; } return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Wait until Elmer's MI1 interface is ready for new operations. */
static int mi1_wait_until_ready(adapter_t *adapter, int mi1_reg)
/* Wait until Elmer's MI1 interface is ready for new operations. */ static int mi1_wait_until_ready(adapter_t *adapter, int mi1_reg)
{ int attempts = 100, busy; do { u32 val; __t1_tpi_read(adapter, mi1_reg, &val); busy = val & F_MI1_OP_BUSY; if (busy) udelay(10); } while (busy && --attempts); if (busy) CH_ALERT("%s: MDIO operation timed out\n", adapter->name); return busy; }
robutest/uclinux
C++
GPL-2.0
60
/* IPCC MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_IPCC_MspDeInit(IPCC_HandleTypeDef *hipcc)
/* IPCC MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_IPCC_MspDeInit(IPCC_HandleTypeDef *hipcc)
{ if(hipcc->Instance==IPCC) { __HAL_RCC_IPCC_CLK_DISABLE(); HAL_NVIC_DisableIRQ(IPCC_RX1_IRQn); HAL_NVIC_DisableIRQ(IPCC_TX1_IRQn); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Flush a level 1 Data cache line. If the byte specified by the address (adr) is cached by the Data cache, the cacheline containing that byte is invalidated. If the cacheline is modified (dirty), the entire contents of the cacheline are written to system memory before the line is invalidated. */
void Xil_L1DCacheFlushLine(u32 adr)
/* Flush a level 1 Data cache line. If the byte specified by the address (adr) is cached by the Data cache, the cacheline containing that byte is invalidated. If the cacheline is modified (dirty), the entire contents of the cacheline are written to system memory before the line is invalidated. */ void Xil_L1DCacheFlushLine(u32 adr)
{ mtcp(XREG_CP15_CACHE_SIZE_SEL, 0U); mtcp(XREG_CP15_CLEAN_INVAL_DC_LINE_MVA_POC, (adr & (~0x1FU))); dsb(); }
ua1arn/hftrx
C++
null
69
/* This function is used for initialize the bus read and bus write functions and assign the chip id and I2C address of the gyro chip id is read in the register 0x00 bit from 0 to 7. */
BMG160_RETURN_FUNCTION_TYPE bmg160_init(struct bmg160_t *bmg160)
/* This function is used for initialize the bus read and bus write functions and assign the chip id and I2C address of the gyro chip id is read in the register 0x00 bit from 0 to 7. */ BMG160_RETURN_FUNCTION_TYPE bmg160_init(struct bmg160_t *bmg160)
{ BMG160_RETURN_FUNCTION_TYPE comres = ERROR; u8 v_data_u8 = BMG160_INIT_VALUE; p_bmg160 = bmg160; comres = p_bmg160->BMG160_BUS_READ_FUNC(p_bmg160->dev_addr, BMG160_CHIP_ID_ADDR, &v_data_u8, BMG160_GEN_READ_WRITE_DATA_LENGTH); p_bmg160->chip_id = v_data_u8; return comres; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* USBH_LL_Init Initialize the Low Level portion of the Host driver. */
USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost)
/* USBH_LL_Init Initialize the Low Level portion of the Host driver. */ USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost)
{ hhcd.Instance = USB_OTG_FS; hhcd.Init.Host_channels = 11; hhcd.Init.phy_itface = HCD_PHY_EMBEDDED; hhcd.Init.Sof_enable = 0; hhcd.Init.speed = HCD_SPEED_FULL; hhcd.pData = phost; phost->pData = &hhcd; HAL_HCD_Init(&hhcd); USBH_LL_SetTimer (phost, HAL_HCD_GetCurrentFrame(&hhcd)); return USBH_OK; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* if (to_qio == true) { spi_flash_switch_to_qio_raw(); } } Low level SPI flash write. Write block of data up to 64 bytes. */
static void IRAM spi_write_data(sdk_flashchip_t *chip, uint32_t addr, uint8_t *buf, uint32_t size)
/* if (to_qio == true) { spi_flash_switch_to_qio_raw(); } } Low level SPI flash write. Write block of data up to 64 bytes. */ static void IRAM spi_write_data(sdk_flashchip_t *chip, uint32_t addr, uint8_t *buf, uint32_t size)
{ uint32_t words = size >> 2; if (size & 0b11) { words++; } Wait_SPI_Idle(chip); SPI(0).ADDR = (addr & 0x00FFFFFF) | (size << 24); memcpy((void*)SPI(0).W, buf, words<<2); __asm__ volatile("memw"); SPI_write_enable(chip); SPI(0).CMD = SPI_CMD_PP; while (SPI(0).CMD) {} }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* This variant does not treat control characters specially. */
static void echo_char_raw(unsigned char c, struct n_tty_data *ldata)
/* This variant does not treat control characters specially. */ static void echo_char_raw(unsigned char c, struct n_tty_data *ldata)
{ if (c == ECHO_OP_START) { add_echo_byte(ECHO_OP_START, ldata); add_echo_byte(ECHO_OP_START, ldata); } else { add_echo_byte(c, ldata); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Internal function that looks for the target task in the TWDT task list. Returns the list item if found and returns null if not found. Also checks if all the other tasks have reset. Should be called within critical. */
static twdt_task_t* find_task_in_twdt_list(TaskHandle_t handle, bool *all_reset)
/* Internal function that looks for the target task in the TWDT task list. Returns the list item if found and returns null if not found. Also checks if all the other tasks have reset. Should be called within critical. */ static twdt_task_t* find_task_in_twdt_list(TaskHandle_t handle, bool *all_reset)
{ twdt_task_t *target = NULL; *all_reset = true; for(twdt_task_t *task = twdt_config->list; task != NULL; task = task->next){ if(task->task_handle == handle){ target = task; }else{ if(task->has_reset == false){ *all_reset = false; } } } return target; }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* Fills each GPIO_InitStruct member with its default value. */
void GPIO_InitStruct(GPIO_InitType *GPIO_InitStruct)
/* Fills each GPIO_InitStruct member with its default value. */ void GPIO_InitStruct(GPIO_InitType *GPIO_InitStruct)
{ GPIO_InitStruct->Pin = GPIO_PIN_ALL; GPIO_InitStruct->GPIO_Slew_Rate = GPIO_Slew_Rate_High; GPIO_InitStruct->GPIO_Mode = GPIO_Mode_Input; GPIO_InitStruct->GPIO_Alternate = GPIO_NO_AF; GPIO_InitStruct->GPIO_Pull = GPIO_No_Pull; GPIO_InitStruct->GPIO_Current = GPIO_DC_2mA; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Converts a big endian byte stream into a 32-bit long */
long inv_big8_to_int32(const unsigned char *big8)
/* Converts a big endian byte stream into a 32-bit long */ long inv_big8_to_int32(const unsigned char *big8)
{ long x; x = ((long)big8[0] << 24) | ((long)big8[1] << 16) | ((long)big8[2] << 8) | ((long)big8[3]); return x; }
Luos-io/luos_engine
C++
MIT License
496
/* Locate a certain GUID protocol interface in a Handle's protocols. */
PROTOCOL_INTERFACE* MmGetProtocolInterface(IN EFI_HANDLE UserHandle, IN EFI_GUID *Protocol)
/* Locate a certain GUID protocol interface in a Handle's protocols. */ PROTOCOL_INTERFACE* MmGetProtocolInterface(IN EFI_HANDLE UserHandle, IN EFI_GUID *Protocol)
{ EFI_STATUS Status; PROTOCOL_ENTRY *ProtEntry; PROTOCOL_INTERFACE *Prot; IHANDLE *Handle; LIST_ENTRY *Link; Status = MmValidateHandle (UserHandle); if (EFI_ERROR (Status)) { return NULL; } Handle = (IHANDLE *)UserHandle; for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) { Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE); ProtEntry = Prot->Protocol; if (CompareGuid (&ProtEntry->ProtocolID, Protocol)) { return Prot; } } return NULL; }
tianocore/edk2
C++
Other
4,240
/* This function reads the oldest value in the ADC fifo and then pops the fifo. Use this function when you actually want to pull data out of the fifo. */
uint32_t am_hal_adc_fifo_pop(void)
/* This function reads the oldest value in the ADC fifo and then pops the fifo. Use this function when you actually want to pull data out of the fifo. */ uint32_t am_hal_adc_fifo_pop(void)
{ uint32_t ui32FIFOValue; ui32FIFOValue = AM_REG(ADC, FIFO); AM_REG(ADC, FIFO) = 0; return ui32FIFOValue; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* here we handle horizontal blocks for the update. update_vert will handle spaning multiple pages. we break out each horizontal block in to individual blocks no taller than 64 pixels. */
static void arcfb_lcd_update_horiz(struct arcfb_par *par, unsigned int left, unsigned int right, unsigned int top, unsigned int h)
/* here we handle horizontal blocks for the update. update_vert will handle spaning multiple pages. we break out each horizontal block in to individual blocks no taller than 64 pixels. */ static void arcfb_lcd_update_horiz(struct arcfb_par *par, unsigned int left, unsigned int right, unsigned int top, unsigned int h)
{ unsigned int distance, upper, lower; distance = h; upper = floor8(top); lower = min(upper + distance - 1, ceil64(upper)); while (distance > 0) { distance -= ((lower - upper) + 1 ); arcfb_lcd_update_vert(par, upper, lower, left, right); upper = lower + 1; lower = min(upper + distance - 1, ceil64(upper)); } }
robutest/uclinux
C++
GPL-2.0
60
/* This is tightly woven into the driver->do_special can not touch. DON'T do it again until a total personality rewrite is committed. */
static int set_multcount(ide_drive_t *drive, int arg)
/* This is tightly woven into the driver->do_special can not touch. DON'T do it again until a total personality rewrite is committed. */ static int set_multcount(ide_drive_t *drive, int arg)
{ struct request *rq; int error; if (arg < 0 || arg > (drive->id[ATA_ID_MAX_MULTSECT] & 0xff)) return -EINVAL; if (drive->special_flags & IDE_SFLAG_SET_MULTMODE) return -EBUSY; rq = blk_get_request(drive->queue, READ, __GFP_WAIT); rq->cmd_type = REQ_TYPE_ATA_TASKFILE; drive->mult_req = arg; drive->special_flags |= IDE_SFLAG_SET_MULTMODE; error = blk_execute_rq(drive->queue, NULL, rq, 0); blk_put_request(rq); return (drive->mult_count == arg) ? 0 : -EIO; }
robutest/uclinux
C++
GPL-2.0
60
/* Handles I2Cx communication when starting transfer or during transfer. */
void I2C_HandlingTransfer(I2C_T *i2c, uint16_t address, uint8_t number, I2C_RELOAD_MODE_T reloadend, I2C_GENERATE_T generates)
/* Handles I2Cx communication when starting transfer or during transfer. */ void I2C_HandlingTransfer(I2C_T *i2c, uint16_t address, uint8_t number, I2C_RELOAD_MODE_T reloadend, I2C_GENERATE_T generates)
{ uint32_t temp = 0; temp = i2c->CTRL2; temp &= (uint32_t)~((uint32_t)(I2C_CTRL2_SADD | I2C_CTRL2_NUMBYT | I2C_CTRL2_MASK)); temp |= (uint32_t)(((uint32_t)address & I2C_CTRL2_SADD) | (((uint32_t)number << 16 ) & I2C_CTRL2_NUMBYT) | \ (uint32_t)reloadend | (uint32_t)generates); i2c->CTRL2 = temp; }
pikasTech/PikaPython
C++
MIT License
1,403
/* This callback is called when the error recovery driver tells us that its OK to resume normal operation. Implementation resembles the second-half of the igb_resume routine. */
static void igb_io_resume(struct pci_dev *)
/* This callback is called when the error recovery driver tells us that its OK to resume normal operation. Implementation resembles the second-half of the igb_resume routine. */ static void igb_io_resume(struct pci_dev *)
{ struct net_device *netdev = pci_get_drvdata(pdev); struct igb_adapter *adapter = netdev_priv(netdev); if (netif_running(netdev)) { if (igb_up(adapter)) { dev_err(&pdev->dev, "igb_up failed after reset\n"); return; } } netif_device_attach(netdev); igb_get_hw_control(adapter); }
robutest/uclinux
C++
GPL-2.0
60
/* Check whether the specified SPI/I2S interrupt has occurred or not. */
uint8_t SPI_I2S_ReadIntFlag(SPI_T *spi, SPI_I2S_INT_T flag)
/* Check whether the specified SPI/I2S interrupt has occurred or not. */ uint8_t SPI_I2S_ReadIntFlag(SPI_T *spi, SPI_I2S_INT_T flag)
{ uint32_t intEnable; uint32_t intStatus; intEnable = (uint32_t)(spi->CTRL2 & (flag >> 8)); intStatus = (uint32_t)(spi->STS & flag); if (intEnable && intStatus) { return SET; } return RESET; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* __port_is_enabled - check if the port's slave is in active state @port: the port we're looking at */
static int __port_is_enabled(struct port *port)
/* __port_is_enabled - check if the port's slave is in active state @port: the port we're looking at */ static int __port_is_enabled(struct port *port)
{ return(port->slave->state == BOND_STATE_ACTIVE); }
robutest/uclinux
C++
GPL-2.0
60
/* Copy the binary array pointed to by buf into mem. Fix $, #, and 0x7d escaped with 0x7d. Return a pointer to the character after the last byte written. */
static int kgdb_ebin2mem(char *buf, char *mem, int count)
/* Copy the binary array pointed to by buf into mem. Fix $, #, and 0x7d escaped with 0x7d. Return a pointer to the character after the last byte written. */ static int kgdb_ebin2mem(char *buf, char *mem, int count)
{ int err = 0; char c; while (count-- > 0) { c = *buf++; if (c == 0x7d) c = *buf++ ^ 0x20; err = probe_kernel_write(mem, &c, 1); if (err) break; mem++; } return err; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Reads and returns the current 16-bit LDTR descriptor value. This function is only available on IA-32 and x64. */
UINT16 EFIAPI AsmReadLdtr(VOID)
/* Reads and returns the current 16-bit LDTR descriptor value. This function is only available on IA-32 and x64. */ UINT16 EFIAPI AsmReadLdtr(VOID)
{ _asm { sldt ax } }
tianocore/edk2
C++
Other
4,240
/* param base Pointer to FLEXIO_SPI_Type structure. param handle FlexIO SPI eDMA handle pointer. param count Number of bytes transferred so far by the non-blocking transaction. */
status_t FLEXIO_SPI_MasterTransferGetCountEDMA(FLEXIO_SPI_Type *base, flexio_spi_master_edma_handle_t *handle, size_t *count)
/* param base Pointer to FLEXIO_SPI_Type structure. param handle FlexIO SPI eDMA handle pointer. param count Number of bytes transferred so far by the non-blocking transaction. */ status_t FLEXIO_SPI_MasterTransferGetCountEDMA(FLEXIO_SPI_Type *base, flexio_spi_master_edma_handle_t *handle, size_t *count)
{ assert(handle); if (!count) { return kStatus_InvalidArgument; } if (handle->rxInProgress) { *count = (handle->transferSize - (uint32_t)handle->nbytes * EDMA_GetRemainingMajorLoopCount(handle->rxHandle->base, handle->rxHandle->channel)); } else { *count = (handle->transferSize - (uint32_t)handle->nbytes * EDMA_GetRemainingMajorLoopCount(handle->txHandle->base, handle->txHandle->channel)); } return kStatus_Success; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* All of link_obj/unlink_obj/link_group/unlink_group require that subsys->su_mutex is held. */
static void unlink_obj(struct config_item *item)
/* All of link_obj/unlink_obj/link_group/unlink_group require that subsys->su_mutex is held. */ static void unlink_obj(struct config_item *item)
{ struct config_group *group; group = item->ci_group; if (group) { list_del_init(&item->ci_entry); item->ci_group = NULL; item->ci_parent = NULL; config_item_put(item); config_group_put(group); } }
robutest/uclinux
C++
GPL-2.0
60
/* This function is similar to 'ubi_open_volume()', but opens a volume the path to its character device node. */
struct ubi_volume_desc* ubi_open_volume_path(const char *pathname, int mode)
/* This function is similar to 'ubi_open_volume()', but opens a volume the path to its character device node. */ struct ubi_volume_desc* ubi_open_volume_path(const char *pathname, int mode)
{ int error, ubi_num, vol_id, mod; struct inode *inode; struct path path; dbg_gen("open volume %s, mode %d", pathname, mode); if (!pathname || !*pathname) return ERR_PTR(-EINVAL); error = kern_path(pathname, LOOKUP_FOLLOW, &path); if (error) return ERR_PTR(error); inode = d_backing_inode(path.dentry); mod = inode->i_mode; ubi_num = ubi_major2num(imajor(inode)); vol_id = iminor(inode) - 1; path_put(&path); if (!S_ISCHR(mod)) return ERR_PTR(-EINVAL); if (vol_id >= 0 && ubi_num >= 0) return ubi_open_volume(ubi_num, vol_id, mode); return ERR_PTR(-ENODEV); }
4ms/stm32mp1-baremetal
C++
Other
137
/* The function returns whether it has deactivated a pending timer or not. (ie. del_timer() of an inactive timer returns 0, del_timer() of an active timer returns 1.) */
int del_timer(struct timer_list *timer)
/* The function returns whether it has deactivated a pending timer or not. (ie. del_timer() of an inactive timer returns 0, del_timer() of an active timer returns 1.) */ int del_timer(struct timer_list *timer)
{ struct tvec_base *base; unsigned long flags; int ret = 0; timer_stats_timer_clear_start_info(timer); if (timer_pending(timer)) { base = lock_timer_base(timer, &flags); if (timer_pending(timer)) { detach_timer(timer, 1); if (timer->expires == base->next_timer && !tbase_get_deferrable(timer->base)) base->next_timer = base->timer_jiffies; ret = 1; } spin_unlock_irqrestore(&base->lock, flags); } return ret; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Clear free trigger duty interrupt flag of selected channel. */
void EPWM_ClearFTDutyIntFlag(EPWM_T *epwm, uint32_t u32ChannelNum)
/* Clear free trigger duty interrupt flag of selected channel. */ void EPWM_ClearFTDutyIntFlag(EPWM_T *epwm, uint32_t u32ChannelNum)
{ (epwm)->FTCI = ((EPWM_FTCI_FTCMU0_Msk | EPWM_FTCI_FTCMD0_Msk) << (u32ChannelNum >> 1)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Decode an ASN1 item, this currently behaves just like a standard 'd2i' function. 'in' points to a buffer to read the data from, in future we will have more advanced versions that can input data a piece at a time and this will simply be a special case. */
ASN1_VALUE* ASN1_item_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it)
/* Decode an ASN1 item, this currently behaves just like a standard 'd2i' function. 'in' points to a buffer to read the data from, in future we will have more advanced versions that can input data a piece at a time and this will simply be a special case. */ ASN1_VALUE* ASN1_item_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it)
{ ASN1_TLC c; ASN1_VALUE *ptmpval = NULL; if (!pval) pval = &ptmpval; asn1_tlc_clear_nc(&c); if (ASN1_item_ex_d2i(pval, in, len, it, -1, 0, 0, &c) > 0) return *pval; return NULL; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Abort the transmission of the specified transmit buffer. */
void CAN_AbortTx(CM_CAN_TypeDef *CANx, uint8_t u8TxBufType)
/* Abort the transmission of the specified transmit buffer. */ void CAN_AbortTx(CM_CAN_TypeDef *CANx, uint8_t u8TxBufType)
{ uint8_t au8Abort[] = {CAN_TCMD_TPA, CAN_TCMD_TSA}; DDL_ASSERT(IS_CAN_UNIT(CANx)); DDL_ASSERT(IS_CAN_TX_BUF_TYPE(u8TxBufType)); SET_REG8_BIT(CANx->TCMD, au8Abort[u8TxBufType]); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Retrieves the current set value of iSCSI Initiator Name. */
EFI_STATUS EFIAPI IScsiGetInitiatorName(IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
/* Retrieves the current set value of iSCSI Initiator Name. */ EFI_STATUS EFIAPI IScsiGetInitiatorName(IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
{ EFI_STATUS Status; if ((BufferSize == NULL) || (Buffer == NULL)) { return EFI_INVALID_PARAMETER; } Status = gRT->GetVariable ( ISCSI_INITIATOR_NAME_VAR_NAME, &gEfiIScsiInitiatorNameProtocolGuid, NULL, BufferSize, Buffer ); return Status; }
tianocore/edk2
C++
Other
4,240
/* SPI MSP Initialization This function configures the hardware resources used in this example. */
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
/* SPI MSP Initialization This function configures the hardware resources used in this example. */ void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; if(hspi->Instance==SPI2) { __HAL_RCC_SPI2_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* sets the BBSID value for the WiFi header conversion feature */
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBWiFiBBSIDSet(IxEthDBPortId portID, IxEthDBMacAddr *bbsid)
/* sets the BBSID value for the WiFi header conversion feature */ IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBWiFiBBSIDSet(IxEthDBPortId portID, IxEthDBMacAddr *bbsid)
{ IxNpeMhMessage message; IX_STATUS result; IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION); IX_ETH_DB_CHECK_REFERENCE(bbsid); memcpy(ixEthDBPortInfo[portID].bbsid, bbsid, sizeof (IxEthDBMacAddr)); FILL_SETBBSID_MSG(message, portID, bbsid); IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result); return result; }
EmcraftSystems/u-boot
C++
Other
181
/* Adds a #GTypeClassCacheFunc to be called before the reference count of a class goes from one to zero. This can be used to prevent premature class destruction. All installed #GTypeClassCacheFunc functions will be chained until one of them returns TRUE. The functions have to check the class id passed in to figure whether they actually want to cache the class of this type, since all classes are routed through the same #GTypeClassCacheFunc chain. */
void g_type_add_class_cache_func(gpointer cache_data, GTypeClassCacheFunc cache_func)
/* Adds a #GTypeClassCacheFunc to be called before the reference count of a class goes from one to zero. This can be used to prevent premature class destruction. All installed #GTypeClassCacheFunc functions will be chained until one of them returns TRUE. The functions have to check the class id passed in to figure whether they actually want to cache the class of this type, since all classes are routed through the same #GTypeClassCacheFunc chain. */ void g_type_add_class_cache_func(gpointer cache_data, GTypeClassCacheFunc cache_func)
{ guint i; g_return_if_fail (cache_func != NULL); G_WRITE_LOCK (&type_rw_lock); i = static_n_class_cache_funcs++; static_class_cache_funcs = g_renew (ClassCacheFunc, static_class_cache_funcs, static_n_class_cache_funcs); static_class_cache_funcs[i].cache_data = cache_data; static_class_cache_funcs[i].cache_func = cache_func; G_WRITE_UNLOCK (&type_rw_lock); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* NB: When computing the smoothed RTT and standard deviation, be careful not to produce negative intermediate results. */
void rpc_update_rtt(struct rpc_rtt *rt, unsigned timer, long m)
/* NB: When computing the smoothed RTT and standard deviation, be careful not to produce negative intermediate results. */ void rpc_update_rtt(struct rpc_rtt *rt, unsigned timer, long m)
{ long *srtt, *sdrtt; if (timer-- == 0) return; if (m < 0) return; if (m == 0) m = 1L; srtt = (long *)&rt->srtt[timer]; m -= *srtt >> 3; *srtt += m; if (m < 0) m = -m; sdrtt = (long *)&rt->sdrtt[timer]; m -= *sdrtt >> 2; *sdrtt += m; if (*sdrtt < RPC_RTO_MIN) *sdrtt = RPC_RTO_MIN; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Set the specified data holding register value for DAC channel1. */
void DAC_SetCh1Data(uint32_t DAC_Align, uint16_t Data)
/* Set the specified data holding register value for DAC channel1. */ void DAC_SetCh1Data(uint32_t DAC_Align, uint16_t Data)
{ __IO uint32_t tmp = 0; assert_param(IS_DAC_ALIGN(DAC_Align)); assert_param(IS_DAC_DATA(Data)); tmp = (uint32_t)DAC_BASE; tmp += DR12CH1_OFFSET + DAC_Align; *(__IO uint32_t*)tmp = Data; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the PDMA interrupt flag of a channel. */
xtBoolean PDMAChannelIntFlagGet(unsigned long ulChannelID, unsigned long ulIntFlags)
/* Get the PDMA interrupt flag of a channel. */ xtBoolean PDMAChannelIntFlagGet(unsigned long ulChannelID, unsigned long ulIntFlags)
{ xASSERT(xDMAChannelIDValid(ulChannelID)); xASSERT((ulIntFlags == PDMA_EVENT_TC) || (ulIntFlags == PDMA_EVENT_ERROR)); return ((xHWREG(g_psDMAChannelAddress[ulChannelID] + PDMA_ISR) | ulIntFlags) ? xtrue : xfalse); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Parameters: irq irq number to be enabled (the irq number NOT the vector number) prio irq priority. 0-15 levels. 0 max priority */
void set_irq_priority(int irq, int prio)
/* Parameters: irq irq number to be enabled (the irq number NOT the vector number) prio irq priority. 0-15 levels. 0 max priority */ void set_irq_priority(int irq, int prio)
{ uint8 *prio_reg; prio_reg = (uint8 *)(((uint32)&NVICIP0) + irq); *prio_reg = ( (prio&0xF) << (8 - ARM_INTERRUPT_LEVEL_BITS) ); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Call user provided callback function, and return the value the function returns. If the user doesn't provide a callback, a proper return value is selected to let the caller continue the normal process. */
EFI_STATUS DhcpCallUser(IN DHCP_SERVICE *DhcpSb, IN EFI_DHCP4_EVENT Event, IN EFI_DHCP4_PACKET *Packet OPTIONAL, OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL)
/* Call user provided callback function, and return the value the function returns. If the user doesn't provide a callback, a proper return value is selected to let the caller continue the normal process. */ EFI_STATUS DhcpCallUser(IN DHCP_SERVICE *DhcpSb, IN EFI_DHCP4_EVENT Event, IN EFI_DHCP4_PACKET *Packet OPTIONAL, OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL)
{ EFI_DHCP4_CONFIG_DATA *Config; EFI_STATUS Status; if (NewPacket != NULL) { *NewPacket = NULL; } Config = &DhcpSb->ActiveConfig; if (Config->Dhcp4Callback == NULL) { if (Event == Dhcp4RcvdOffer) { return EFI_NOT_READY; } return EFI_SUCCESS; } Status = Config->Dhcp4Callback ( &DhcpSb->ActiveChild->Dhcp4Protocol, Config->CallbackContext, (EFI_DHCP4_STATE)DhcpSb->DhcpState, Event, Packet, NewPacket ); if ((Status == EFI_SUCCESS) || (Status == EFI_NOT_READY)) { return Status; } return EFI_ABORTED; }
tianocore/edk2
C++
Other
4,240
/* set up the iterator to start reading from the cells list and return the first item */
static void * afs_proc_cell_volumes_start(struct seq_file *p, loff_t *pos)
/* set up the iterator to start reading from the cells list and return the first item */ static void * afs_proc_cell_volumes_start(struct seq_file *p, loff_t *pos)
{ struct afs_cell *cell = m->private; _enter("cell=%p pos=%Ld", cell, *_pos); down_read(&cell->vl_sem); return seq_list_start_head(&cell->vl_list, *_pos); }
robutest/uclinux
C++
GPL-2.0
60
/* This function must guarantee that all I/O read and write operations are serialized. If such operations are not supported, then ASSERT(). */
VOID EFIAPI IoWriteFifoWorker(IN UINTN Port, IN EFI_CPU_IO_PROTOCOL_WIDTH Width, IN UINTN Count, IN VOID *Buffer)
/* This function must guarantee that all I/O read and write operations are serialized. If such operations are not supported, then ASSERT(). */ VOID EFIAPI IoWriteFifoWorker(IN UINTN Port, IN EFI_CPU_IO_PROTOCOL_WIDTH Width, IN UINTN Count, IN VOID *Buffer)
{ EFI_STATUS Status; Status = mCpuIo->Io.Write (mCpuIo, Width, Port, Count, Buffer); ASSERT_EFI_ERROR (Status); }
tianocore/edk2
C++
Other
4,240
/* Pop (delete) the last 'num' invalidated areas from the buffer */
void lv_refr_pop_from_buf(uint16_t num)
/* Pop (delete) the last 'num' invalidated areas from the buffer */ void lv_refr_pop_from_buf(uint16_t num)
{ if(inv_buf_p < num) inv_buf_p = 0; else inv_buf_p -= num; }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Use the standard setup to tune the chipset and then finalise the configuration by writing the nibble of extra bits of data into the chip. */
static int optidma_set_mode(struct ata_link *link, struct ata_device **r_failed)
/* Use the standard setup to tune the chipset and then finalise the configuration by writing the nibble of extra bits of data into the chip. */ static int optidma_set_mode(struct ata_link *link, struct ata_device **r_failed)
{ struct ata_port *ap = link->ap; u8 r; int nybble = 4 * ap->port_no; struct pci_dev *pdev = to_pci_dev(ap->host->dev); int rc = ata_do_set_mode(link, r_failed); if (rc == 0) { pci_read_config_byte(pdev, 0x43, &r); r &= (0x0F << nybble); r |= (optidma_make_bits43(&link->device[0]) + (optidma_make_bits43(&link->device[0]) << 2)) << nybble; pci_write_config_byte(pdev, 0x43, r); } return rc; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Change Logs: Date Author Notes Wayne First version */
int main(int argc, char **argv)
/* Change Logs: Date Author Notes Wayne First version */ int main(int argc, char **argv)
{ rt_kprintf("cpu-%d %d\r\n", rt_hw_cpu_id(), nu_cpu_dcache_line_size()); return 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* read_outbnd_queue_table - read the outbound queue table and save it. @pm8001_ha: our hba card information */
static void __devinit read_outbnd_queue_table(struct pm8001_hba_info *pm8001_ha)
/* read_outbnd_queue_table - read the outbound queue table and save it. @pm8001_ha: our hba card information */ static void __devinit read_outbnd_queue_table(struct pm8001_hba_info *pm8001_ha)
{ int outbQ_num = 1; int i; void __iomem *address = pm8001_ha->outbnd_q_tbl_addr; for (i = 0; i < outbQ_num; i++) { u32 offset = i * 0x24; pm8001_ha->outbnd_q_tbl[i].ci_pci_bar = get_pci_bar_index(pm8001_mr32(address, (offset + 0x14))); pm8001_ha->outbnd_q_tbl[i].ci_offset = pm8001_mr32(address, (offset + 0x18)); } }
robutest/uclinux
C++
GPL-2.0
60
/* This function is the entrypoint of Network Common Driver. It installs Driver Binding Protocols together with Component Name Protocols. */
EFI_STATUS EFIAPI NetworkCommonEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* This function is the entrypoint of Network Common Driver. It installs Driver Binding Protocols together with Component Name Protocols. */ EFI_STATUS EFIAPI NetworkCommonEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ EFI_STATUS Status; gNetworkCommonDriverBinding.DriverBindingHandle = ImageHandle; gNetworkCommonDriverBinding.ImageHandle = ImageHandle; gRateLimitingEnable = PcdGetBool (PcdEnableUsbNetworkRateLimiting); gRateLimitingCredit = PcdGet32 (PcdUsbNetworkRateLimitingCredit); gRateLimitingPollTimer = PcdGet32 (PcdUsbNetworkRateLimitingFactor); Status = gBS->InstallMultipleProtocolInterfaces ( &gNetworkCommonDriverBinding.DriverBindingHandle, &gEfiDriverBindingProtocolGuid, &gNetworkCommonDriverBinding, &gEfiComponentName2ProtocolGuid, &gNetworkCommonComponentName2, NULL ); return Status; }
tianocore/edk2
C++
Other
4,240
/* frees or reduces the usage count of a mac tree node smart pointer */
IX_ETH_DB_PUBLIC void ixEthDBFreeMacTreeNode(MacTreeNode *macNode)
/* frees or reduces the usage count of a mac tree node smart pointer */ IX_ETH_DB_PUBLIC void ixEthDBFreeMacTreeNode(MacTreeNode *macNode)
{ if (macNode->descriptor != NULL) { ixEthDBFreeMacDescriptor(macNode->descriptor); } if (macNode->left != NULL) { ixEthDBFreeMacTreeNode(macNode->left); } if (macNode->right != NULL) { ixEthDBFreeMacTreeNode(macNode->right); } ixEthDBPoolFreeMacTreeNode(macNode); }
EmcraftSystems/u-boot
C++
Other
181
/* Emagic USB MIDI protocol: raw MIDI with "F5 xx" port switching. */
static void snd_usbmidi_emagic_init_out(struct snd_usb_midi_out_endpoint *ep)
/* Emagic USB MIDI protocol: raw MIDI with "F5 xx" port switching. */ static void snd_usbmidi_emagic_init_out(struct snd_usb_midi_out_endpoint *ep)
{ static const u8 init_data[] = { 0xf0, 0x00, 0x20, 0x31, 0x64, 0x0b, 0x00, 0x00, 0xf7 }; send_bulk_static_data(ep, init_data, sizeof(init_data)); send_bulk_static_data(ep, init_data, sizeof(init_data)); }
robutest/uclinux
C++
GPL-2.0
60
/* Called whenever a 32-bit process running under a 64-bit kernel performs an ioctl on /dev/drm. */
long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* Called whenever a 32-bit process running under a 64-bit kernel performs an ioctl on /dev/drm. */ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{ unsigned int nr = DRM_IOCTL_NR(cmd); drm_ioctl_compat_t *fn; int ret; if (nr >= ARRAY_SIZE(drm_compat_ioctls)) return drm_ioctl(filp, cmd, arg); fn = drm_compat_ioctls[nr]; if (fn != NULL) ret = (*fn) (filp, cmd, arg); else ret = drm_ioctl(filp, cmd, arg); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* This function returns after the IPI has been accepted by the target processor. */
VOID EFIAPI SendSmiIpi(IN UINT32 ApicId)
/* This function returns after the IPI has been accepted by the target processor. */ VOID EFIAPI SendSmiIpi(IN UINT32 ApicId)
{ LOCAL_APIC_ICR_LOW IcrLow; IcrLow.Uint32 = 0; IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_SMI; IcrLow.Bits.Level = 1; SendIpi (IcrLow.Uint32, ApicId); }
tianocore/edk2
C++
Other
4,240
/* Decode n bits (n <= 16) without modelling */
static int range_decode_bits(APEContext *ctx, int n)
/* Decode n bits (n <= 16) without modelling */ static int range_decode_bits(APEContext *ctx, int n)
{ int sym = range_decode_culshift(ctx, n); range_decode_update(ctx, 1, sym); return sym; }
DC-SWAT/DreamShell
C++
null
404
/* kcopyd does this every time it's woken up. */
static void do_work(struct work_struct *work)
/* kcopyd does this every time it's woken up. */ static void do_work(struct work_struct *work)
{ struct dm_kcopyd_client *kc = container_of(work, struct dm_kcopyd_client, kcopyd_work); process_jobs(&kc->complete_jobs, kc, run_complete_job); process_jobs(&kc->pages_jobs, kc, run_pages_job); process_jobs(&kc->io_jobs, kc, run_io_job); }
robutest/uclinux
C++
GPL-2.0
60
/* This function sets LEB properties for all replayed buds. Returns zero in case of success and a negative error code in case of failure. */
static int set_buds_lprops(struct ubifs_info *c)
/* This function sets LEB properties for all replayed buds. Returns zero in case of success and a negative error code in case of failure. */ static int set_buds_lprops(struct ubifs_info *c)
{ struct bud_entry *b; int err; list_for_each_entry(b, &c->replay_buds, list) { err = set_bud_lprops(c, b); if (err) return err; } return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Returns the flags representing the wake configuration for the Hibernation module. The return value will be a combination of the following flags: */
unsigned long HibernateWakeGet(void)
/* Returns the flags representing the wake configuration for the Hibernation module. The return value will be a combination of the following flags: */ unsigned long HibernateWakeGet(void)
{ return(HWREG(HIB_CTL) & (HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_RTC)); }
watterott/WebRadio
C++
null
71
/* This function retrieves the user-readable name of a driver in the form of a Unicode string. If the driver specified by This has a user-readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned. */
EFI_STATUS EFIAPI PxeBcComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
/* This function retrieves the user-readable name of a driver in the form of a Unicode string. If the driver specified by This has a user-readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned. */ EFI_STATUS EFIAPI PxeBcComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
{ return LookupUnicodeString2 ( Language, This->SupportedLanguages, mPxeBcDriverNameTable, DriverName, (BOOLEAN)(This == &gPxeBcComponentName) ); }
tianocore/edk2
C++
Other
4,240
/* Read entries from a directory. The NFSv3/4 verifier we ignore for now. */
__be32 nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp, struct readdir_cd *cdp, filldir_t func)
/* Read entries from a directory. The NFSv3/4 verifier we ignore for now. */ __be32 nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp, struct readdir_cd *cdp, filldir_t func)
{ __be32 err; struct file *file; loff_t offset = *offsetp; err = nfsd_open(rqstp, fhp, S_IFDIR, NFSD_MAY_READ, &file); if (err) goto out; offset = vfs_llseek(file, offset, 0); if (offset < 0) { err = nfserrno((int)offset); goto out_close; } err = nfsd_buffered_readdir(file, func, cdp, offsetp); if (err == nfserr_eof || err == nfserr_toosmall) err = nfs_ok; out_close: nfsd_close(file); out: return err; }
robutest/uclinux
C++
GPL-2.0
60
/* megasas_fire_cmd_ppc - Sends command to the FW @frame_phys_addr : Physical address of cmd @frame_count : Number of frames for the command @regs : MFI register set */
static void megasas_fire_cmd_ppc(struct megasas_instance *instance, dma_addr_t frame_phys_addr, u32 frame_count, struct megasas_register_set __iomem *regs)
/* megasas_fire_cmd_ppc - Sends command to the FW @frame_phys_addr : Physical address of cmd @frame_count : Number of frames for the command @regs : MFI register set */ static void megasas_fire_cmd_ppc(struct megasas_instance *instance, dma_addr_t frame_phys_addr, u32 frame_count, struct megasas_register_set __iomem *regs)
{ writel((frame_phys_addr | (frame_count<<1))|1, &(regs)->inbound_queue_port); }
robutest/uclinux
C++
GPL-2.0
60
/* Cleans up the LED blink driver. This is intended to be used upon program exit. */
void LedBlinkExit(void)
/* Cleans up the LED blink driver. This is intended to be used upon program exit. */ void LedBlinkExit(void)
{ LL_GPIO_ResetOutputPin(GPIOC, LL_GPIO_PIN_8); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Standard deviation of the elements of a floating-point vector. */
void arm_std_f64(const float64_t *pSrc, uint32_t blockSize, float64_t *pResult)
/* Standard deviation of the elements of a floating-point vector. */ void arm_std_f64(const float64_t *pSrc, uint32_t blockSize, float64_t *pResult)
{ float64_t var; arm_var_f64(pSrc,blockSize,&var); *pResult = sqrt(var); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Retrieve the endpoint descriptor from this interface setting. */
EFI_STATUS EFIAPI UsbIoGetEndpointDescriptor(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Index, OUT EFI_USB_ENDPOINT_DESCRIPTOR *Descriptor)
/* Retrieve the endpoint descriptor from this interface setting. */ EFI_STATUS EFIAPI UsbIoGetEndpointDescriptor(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Index, OUT EFI_USB_ENDPOINT_DESCRIPTOR *Descriptor)
{ USB_INTERFACE *UsbIf; EFI_TPL OldTpl; OldTpl = gBS->RaiseTPL (USB_BUS_TPL); UsbIf = USB_INTERFACE_FROM_USBIO (This); if ((Descriptor == NULL) || (Index > 15)) { gBS->RestoreTPL (OldTpl); return EFI_INVALID_PARAMETER; } if (Index >= UsbIf->IfSetting->Desc.NumEndpoints) { gBS->RestoreTPL (OldTpl); return EFI_NOT_FOUND; } CopyMem ( Descriptor, &(UsbIf->IfSetting->Endpoints[Index]->Desc), sizeof (EFI_USB_ENDPOINT_DESCRIPTOR) ); gBS->RestoreTPL (OldTpl); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Forces the tim output 4 waveform to active or inactive level. */
void TIM_ForcedOC4Config(TIM_TypeDef *tim, TIMOCMODE_Typedef forced_action)
/* Forces the tim output 4 waveform to active or inactive level. */ void TIM_ForcedOC4Config(TIM_TypeDef *tim, TIMOCMODE_Typedef forced_action)
{ MODIFY_REG(tim->CCMR2, TIM_CCMR2_OC4M, forced_action << 8); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enables the WDT's clock. This only enables the clock to the peripheral. */
void wdt_clock_enable(bool en)
/* Enables the WDT's clock. This only enables the clock to the peripheral. */ void wdt_clock_enable(bool en)
{ if (en) { SYSCTL_SYS_CFG_1 |= SYSCTL_SYS_CFG_1_WDT; } else { SYSCTL_SYS_CFG_1 &= ~SYSCTL_SYS_CFG_1_WDT; } }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Print a message passed to us by the controller firmware on the Adaptec board */
void aac_printf(struct aac_dev *dev, u32 val)
/* Print a message passed to us by the controller firmware on the Adaptec board */ void aac_printf(struct aac_dev *dev, u32 val)
{ char *cp = dev->printfbuf; if (dev->printf_enabled) { int length = val & 0xffff; int level = (val >> 16) & 0xffff; if (length > 255) length = 255; if (cp[length] != 0) cp[length] = 0; if (level == LOG_AAC_HIGH_ERROR) printk(KERN_WARNING "%s:%s", dev->name, cp); else printk(KERN_INFO "%s:%s", dev->name, cp); } memset(cp, 0, 256); }
robutest/uclinux
C++
GPL-2.0
60
/* Determines the flash page that the address belongs to. end of FlashGetBank */
static blt_int32u FlashGetPage(blt_addr address)
/* Determines the flash page that the address belongs to. end of FlashGetBank */ static blt_int32u FlashGetPage(blt_addr address)
{ blt_int32u result = 0; ASSERT_RT(address >= FLASH_BASE); ASSERT_RT((address - FLASH_BASE) < FLASH_SIZE); if (FlashGetBank(address) == FLASH_BANK_1) { result = (address - FLASH_BASE) / FLASH_PAGE_SIZE; } else { result = (address - (FLASH_BASE + FLASH_BANK_SIZE)) / FLASH_PAGE_SIZE; } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Ensures final expression result is in some (any) register and return that register. */
int luaK_exp2anyreg(FuncState *fs, expdesc *e)
/* Ensures final expression result is in some (any) register and return that register. */ int luaK_exp2anyreg(FuncState *fs, expdesc *e)
{ if (!hasjumps(e)) return e->u.info; if (e->u.info >= luaY_nvarstack(fs)) { exp2reg(fs, e, e->u.info); return e->u.info; } } luaK_exp2nextreg(fs, e); return e->u.info; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Shift the value and apply the specified mask. */
uint32_t field_prep(uint32_t mask, uint32_t val)
/* Shift the value and apply the specified mask. */ uint32_t field_prep(uint32_t mask, uint32_t val)
{ return (val << find_first_set_bit(mask)) & mask; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Resume I2C transaction. This function is unusual, but required to implement i2c exchange with this peripheral. */
void i2c_resume(uint32_t i2c)
/* Resume I2C transaction. This function is unusual, but required to implement i2c exchange with this peripheral. */ void i2c_resume(uint32_t i2c)
{ PERIPH_TRIGGER_TASK(I2C_TASK_RESUME(i2c)); }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* param base GPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.) param pin GPIO port pin number param config GPIO pin configuration pointer */
void GPIO_PinInit(GPIO_Type *base, uint32_t pin, const gpio_pin_config_t *config)
/* param base GPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.) param pin GPIO port pin number param config GPIO pin configuration pointer */ void GPIO_PinInit(GPIO_Type *base, uint32_t pin, const gpio_pin_config_t *config)
{ assert(NULL != config); uint32_t u32flag = 1; if (config->pinDirection == kGPIO_DigitalInput) { base->PDDR &= ~(u32flag << pin); } else { GPIO_PinWrite(base, pin, config->outputLogic); base->PDDR |= (u32flag << pin); } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Get number of pending frames for a specific queue */
u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue)
/* Get number of pending frames for a specific queue */ u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue)
{ u32 pending; ATH5K_TRACE(ah->ah_sc); AR5K_ASSERT_ENTRY(queue, ah->ah_capabilities.cap_queues.q_tx_num); if (ah->ah_txq[queue].tqi_type == AR5K_TX_QUEUE_INACTIVE) return false; if (ah->ah_version == AR5K_AR5210) return false; pending = ath5k_hw_reg_read(ah, AR5K_QUEUE_STATUS(queue)); pending &= AR5K_QCU_STS_FRMPENDCNT; if (!pending && AR5K_REG_READ_Q(ah, AR5K_QCU_TXE, queue)) return true; return pending; }
robutest/uclinux
C++
GPL-2.0
60
/* This is a stub for the status callback. The stub is here in case the upper layers forget to set the handler. */
static INLINE void StubHandler(void *CallBackRef, u32 StatusEvent)
/* This is a stub for the status callback. The stub is here in case the upper layers forget to set the handler. */ static INLINE void StubHandler(void *CallBackRef, u32 StatusEvent)
{ (void) ((void *)CallBackRef); (void) StatusEvent; Xil_AssertVoidAlways(); }
ua1arn/hftrx
C++
null
69
/* param handle codec handle. param module audio codec module. param powerOn true is power on, false is power down. return kStatus_Success is success, else configure failed. */
status_t HAL_CODEC_SetPower(void *handle, uint32_t module, bool powerOn)
/* param handle codec handle. param module audio codec module. param powerOn true is power on, false is power down. return kStatus_Success is success, else configure failed. */ status_t HAL_CODEC_SetPower(void *handle, uint32_t module, bool powerOn)
{ assert(handle != NULL); return WM8904_SetModulePower((wm8904_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)), HAL_WM8904_MAP_MODULE(module), powerOn); }
eclipse-threadx/getting-started
C++
Other
310
/* Enables sending of NACK on address match. Enables sending of NACK on address match, thus discarding any incoming transaction. */
void i2c_slave_enable_nack_on_address(struct i2c_slave_module *const module)
/* Enables sending of NACK on address match. Enables sending of NACK on address match, thus discarding any incoming transaction. */ void i2c_slave_enable_nack_on_address(struct i2c_slave_module *const module)
{ Assert(module); module->nack_on_address = true; }
memfault/zero-to-main
C++
null
200
/* rb_check_list - make sure a pointer to a list has the last bits zero */
static int rb_check_list(struct ring_buffer_per_cpu *cpu_buffer, struct list_head *list)
/* rb_check_list - make sure a pointer to a list has the last bits zero */ static int rb_check_list(struct ring_buffer_per_cpu *cpu_buffer, struct list_head *list)
{ if (RB_WARN_ON(cpu_buffer, rb_list_head(list->prev) != list->prev)) return 1; if (RB_WARN_ON(cpu_buffer, rb_list_head(list->next) != list->next)) return 1; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* param base SAI base pointer param handle SAI eDMA handle pointer. */
void SAI_TransferAbortReceiveEDMA(I2S_Type *base, sai_edma_handle_t *handle)
/* param base SAI base pointer param handle SAI eDMA handle pointer. */ void SAI_TransferAbortReceiveEDMA(I2S_Type *base, sai_edma_handle_t *handle)
{ assert(handle); EDMA_AbortTransfer(handle->dmaHandle); base->RCR3 &= ~I2S_RCR3_RCE_MASK; SAI_RxEnableDMA(base, kSAI_FIFORequestDMAEnable, false); SAI_RxEnable(base, false); base->RCSR |= (I2S_RCSR_FR_MASK | I2S_RCSR_SR_MASK); base->RCSR &= ~I2S_RCSR_SR_MASK; memset(&handle->saiQueue[handle->queueDriver], 0, sizeof(sai_transfer_t)); handle->queueDriver = (handle->queueDriver + 1) % SAI_XFER_QUEUE_SIZE; handle->state = kSAI_Idle; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The DRP Availability IE that this radio controller emits will need to be updated. */
int uwbd_evt_handle_rc_drp_avail(struct uwb_event *evt)
/* The DRP Availability IE that this radio controller emits will need to be updated. */ int uwbd_evt_handle_rc_drp_avail(struct uwb_event *evt)
{ int result; struct uwb_rc *rc = evt->rc; DECLARE_BITMAP(bmp, UWB_NUM_MAS); result = uwbd_evt_get_drp_avail(evt, bmp); if (result < 0) return result; mutex_lock(&rc->rsvs_mutex); bitmap_copy(rc->drp_avail.global, bmp, UWB_NUM_MAS); rc->drp_avail.ie_valid = false; uwb_rsv_handle_drp_avail_change(rc); mutex_unlock(&rc->rsvs_mutex); uwb_rsv_sched_update(rc); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Call back function to DhcpIterateOptions to consolidate each option's data. There are maybe several occurrence of the same option. */
EFI_STATUS DhcpFillOption(IN UINT8 Tag, IN UINT8 Len, IN UINT8 *Data, IN VOID *Context)
/* Call back function to DhcpIterateOptions to consolidate each option's data. There are maybe several occurrence of the same option. */ EFI_STATUS DhcpFillOption(IN UINT8 Tag, IN UINT8 Len, IN UINT8 *Data, IN VOID *Context)
{ DHCP_OPTION_CONTEXT *OptContext; DHCP_OPTION_COUNT *OptCount; DHCP_OPTION *Options; UINT8 *Buf; UINT8 Index; OptContext = (DHCP_OPTION_CONTEXT *)Context; OptCount = OptContext->OpCount; Index = OptCount[Tag].Index; Options = OptContext->Options; Buf = OptContext->Buf; if (Options[Index].Data == NULL) { Options[Index].Tag = Tag; Options[Index].Data = Buf + OptCount[Tag].Offset; } CopyMem (Buf + OptCount[Tag].Offset, Data, Len); OptCount[Tag].Offset = (UINT16)(OptCount[Tag].Offset + Len); Options[Index].Len = (UINT16)(Options[Index].Len + Len); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Encrypts the len-bytes in the specified data-array, using the specified 256-bit (32 bytes) key. The results are written back into the same array. */
bool UtilCryptoAes256Encrypt(uint8_t *data, uint32_t len, uint8_t const *key)
/* Encrypts the len-bytes in the specified data-array, using the specified 256-bit (32 bytes) key. The results are written back into the same array. */ bool UtilCryptoAes256Encrypt(uint8_t *data, uint32_t len, uint8_t const *key)
{ bool result = false; aes256_context ctx; assert(data != NULL); assert(key != NULL); if ( (data != NULL) && (key != NULL) && ((len % 16u) == 0) ) { aes256_init(&ctx, key); for (uint32_t i = 0; i < (len / 16u); i++) { aes256_encrypt_ecb(&ctx, &data[i * 16u]); } aes256_done(&ctx); result = true; } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* This internal function checks if a Unicode character is a decimal character. The valid decimal character is from L'0' to L'9'. */
BOOLEAN EFIAPI InternalIsDecimalDigitCharacter(IN CHAR16 Char)
/* This internal function checks if a Unicode character is a decimal character. The valid decimal character is from L'0' to L'9'. */ BOOLEAN EFIAPI InternalIsDecimalDigitCharacter(IN CHAR16 Char)
{ return (BOOLEAN)(Char >= L'0' && Char <= L'9'); }
tianocore/edk2
C++
Other
4,240
/* get the bit value of EXMC send write command bit or read ID command */
FlagStatus exmc_sqpipsram_send_command_state_get(uint32_t send_command_flag)
/* get the bit value of EXMC send write command bit or read ID command */ FlagStatus exmc_sqpipsram_send_command_state_get(uint32_t send_command_flag)
{ uint32_t flag = 0x00000000U; if(EXMC_SEND_COMMAND_FLAG_RDID == send_command_flag){ flag = EXMC_SRCMD; }else if(EXMC_SEND_COMMAND_FLAG_SC == send_command_flag){ flag = EXMC_SWCMD; }else{ } if (flag & send_command_flag){ return SET; }else{ return RESET; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function is called from the AP bus code after a crypto request "msg" has finished with the reply message "reply". It is called from tasklet context. @ap_dev: pointer to the AP device @msg: pointer to the AP message @reply: pointer to the AP reply message */
static void zcrypt_pcicc_receive(struct ap_device *, struct ap_message *, struct ap_message *)
/* This function is called from the AP bus code after a crypto request "msg" has finished with the reply message "reply". It is called from tasklet context. @ap_dev: pointer to the AP device @msg: pointer to the AP message @reply: pointer to the AP reply message */ static void zcrypt_pcicc_receive(struct ap_device *, struct ap_message *, struct ap_message *)
{ static struct error_hdr error_reply = { .type = TYPE82_RSP_CODE, .reply_code = REP82_ERROR_MACHINE_FAILURE, }; struct type86_reply *t86r; int length; if (IS_ERR(reply)) { memcpy(msg->message, &error_reply, sizeof(error_reply)); goto out; } t86r = reply->message; if (t86r->hdr.type == TYPE86_RSP_CODE && t86r->cprb.cprb_ver_id == 0x01) { length = sizeof(struct type86_reply) + t86r->length - 2; length = min(PCICC_MAX_RESPONSE_SIZE, length); memcpy(msg->message, reply->message, length); } else memcpy(msg->message, reply->message, sizeof error_reply); out: complete((struct completion *) msg->private); }
robutest/uclinux
C++
GPL-2.0
60
/* Truncate the given transfer width parameter to a value the current adapter type is capable of. */
static void ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo, u_int *bus_width, role_t role)
/* Truncate the given transfer width parameter to a value the current adapter type is capable of. */ static void ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo, u_int *bus_width, role_t role)
{ switch (*bus_width) { default: if (ahd->features & AHD_WIDE) { *bus_width = MSG_EXT_WDTR_BUS_16_BIT; break; } case MSG_EXT_WDTR_BUS_8_BIT: *bus_width = MSG_EXT_WDTR_BUS_8_BIT; break; } if (tinfo != NULL) { if (role == ROLE_TARGET) *bus_width = min((u_int)tinfo->user.width, *bus_width); else *bus_width = min((u_int)tinfo->goal.width, *bus_width); } }
robutest/uclinux
C++
GPL-2.0
60
/* This function allows a caller to extract the current configuration for one or more named elements from the target driver. */
EFI_STATUS EFIAPI LibExtractConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
/* This function allows a caller to extract the current configuration for one or more named elements from the target driver. */ EFI_STATUS EFIAPI LibExtractConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
{ if ((Progress == NULL) || (Results == NULL)) { return EFI_INVALID_PARAMETER; } *Progress = Request; return EFI_NOT_FOUND; }
tianocore/edk2
C++
Other
4,240
/* Function called in case of error detected in RNG IT Handler. */
void Error_Callback(void)
/* Function called in case of error detected in RNG IT Handler. */ void Error_Callback(void)
{ NVIC_DisableIRQ(HASH_RNG_IRQn); LED_Blinking(LED_BLINK_ERROR); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* param base TDET peripheral base address return kStatus_Fail when Tamper Seconds Register writing is not allowed return kStatus_Success when Tamper Seconds Register is written */
status_t TDET_ForceTamper(DIGTMP_Type *base)
/* param base TDET peripheral base address return kStatus_Fail when Tamper Seconds Register writing is not allowed return kStatus_Success when Tamper Seconds Register is written */ status_t TDET_ForceTamper(DIGTMP_Type *base)
{ status_t status; if (tdet_IsRegisterWriteAllowed(base, DIGTMP_LR_TSL_MASK)) { base->TSR = 0; status = kStatus_Success; } else { status = kStatus_Fail; } return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return task->normal_prio when the waiter list is empty or when the waiter is not allowed to do priority boosting */
int rt_mutex_getprio(struct task_struct *task)
/* Return task->normal_prio when the waiter list is empty or when the waiter is not allowed to do priority boosting */ int rt_mutex_getprio(struct task_struct *task)
{ if (likely(!task_has_pi_waiters(task))) return task->normal_prio; return min(task_top_pi_waiter(task)->pi_list_entry.prio, task->normal_prio); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Create the 'arg' table, which stores all arguments from the command line ('argv'). It should be aligned so that, at index 0, it has 'argv', which is the script name. The arguments to the script (everything after 'script') go to positive indices; other arguments (before the script name) go to negative indices. If there is no script name, assume interpreter's name as base. */
static void createargtable(lua_State *L, char **argv, int argc, int script)
/* Create the 'arg' table, which stores all arguments from the command line ('argv'). It should be aligned so that, at index 0, it has 'argv', which is the script name. The arguments to the script (everything after 'script') go to positive indices; other arguments (before the script name) go to negative indices. If there is no script name, assume interpreter's name as base. */ static void createargtable(lua_State *L, char **argv, int argc, int script)
{ lua_pushstring(L, argv[i]); lua_rawseti(L, -2, i - script); } lua_setglobal(L, "arg"); }
Nicholas3388/LuaNode
C++
Other
1,055
/* allow the slow work item processor to discard a ref on an operation */
static void fscache_op_put_ref(struct slow_work *work)
/* allow the slow work item processor to discard a ref on an operation */ static void fscache_op_put_ref(struct slow_work *work)
{ struct fscache_operation *op = container_of(work, struct fscache_operation, slow_work); fscache_put_operation(op); }
robutest/uclinux
C++
GPL-2.0
60
/* Write SEE bit in config register. nv = 0 - Writes to SEEPROM registers behave like EEPROM nv = 1 - Writes to SEEPROM registers behave like SRAM */
int ds4510_see_write(uint8_t chip, uint8_t nv)
/* Write SEE bit in config register. nv = 0 - Writes to SEEPROM registers behave like EEPROM nv = 1 - Writes to SEEPROM registers behave like SRAM */ int ds4510_see_write(uint8_t chip, uint8_t nv)
{ uint8_t data; if (i2c_read(chip, DS4510_CFG, 1, &data, 1)) return -1; if (nv) data &= ~DS4510_CFG_SEE; else data |= DS4510_CFG_SEE; return ds4510_mem_write(chip, DS4510_CFG, &data, 1); }
EmcraftSystems/u-boot
C++
Other
181
/* Clear SWPMI transceiver ready flag @rmtoll ISR CRDYF LL_SWPMI_ClearFlag_RDY. */
void LL_SWPMI_ClearFlag_RDY(SWPMI_TypeDef *SWPMIx)
/* Clear SWPMI transceiver ready flag @rmtoll ISR CRDYF LL_SWPMI_ClearFlag_RDY. */ void LL_SWPMI_ClearFlag_RDY(SWPMI_TypeDef *SWPMIx)
{ WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CRDYF); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Unmap any PCI mapping/IOMMU resources allocated when the command was mapped originally as part of initio_build_scb */
static void i91u_unmap_scb(struct pci_dev *pci_dev, struct scsi_cmnd *cmnd)
/* Unmap any PCI mapping/IOMMU resources allocated when the command was mapped originally as part of initio_build_scb */ static void i91u_unmap_scb(struct pci_dev *pci_dev, struct scsi_cmnd *cmnd)
{ if (cmnd->SCp.ptr) { dma_unmap_single(&pci_dev->dev, (dma_addr_t)((unsigned long)cmnd->SCp.ptr), SENSE_SIZE, DMA_FROM_DEVICE); cmnd->SCp.ptr = NULL; } if (scsi_sg_count(cmnd)) { dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle, sizeof(struct sg_entry) * TOTAL_SG_ENTRY, DMA_BIDIRECTIONAL); scsi_dma_unmap(cmnd); } }
robutest/uclinux
C++
GPL-2.0
60
/* This function setup a slave interrupt-driven send. It set the repeated start for the device is the transfer size is larger than FIFO depth. Data processing for the send is initiated by the interrupt handler. */
void XIicPs_SlaveSend(XIicPs *InstancePtr, u8 *MsgPtr, s32 ByteCount)
/* This function setup a slave interrupt-driven send. It set the repeated start for the device is the transfer size is larger than FIFO depth. Data processing for the send is initiated by the interrupt handler. */ void XIicPs_SlaveSend(XIicPs *InstancePtr, u8 *MsgPtr, s32 ByteCount)
{ u32 BaseAddr; Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(MsgPtr != NULL); Xil_AssertVoid(InstancePtr->IsReady == (u32)XIL_COMPONENT_IS_READY); BaseAddr = InstancePtr->Config.BaseAddress; InstancePtr->SendBufferPtr = MsgPtr; InstancePtr->SendByteCount = ByteCount; InstancePtr->RecvBufferPtr = NULL; XIicPs_WriteReg(BaseAddr, XIICPS_ISR_OFFSET, XIICPS_IXR_ALL_INTR_MASK); XIicPs_EnableInterrupts(BaseAddr, (u32)XIICPS_IXR_DATA_MASK | (u32)XIICPS_IXR_COMP_MASK | (u32)XIICPS_IXR_TO_MASK | (u32)XIICPS_IXR_NACK_MASK | (u32)XIICPS_IXR_TX_OVR_MASK); }
ua1arn/hftrx
C++
null
69
/* "abinary" is Ascend's binary format for filters. See dissect_ascend_data_filter(). */
void radius_abinary(radius_attr_info_t *a, proto_tree *tree, packet_info *pinfo _U_, tvbuff_t *tvb, int offset, int len, proto_item *avp_item)
/* "abinary" is Ascend's binary format for filters. See dissect_ascend_data_filter(). */ void radius_abinary(radius_attr_info_t *a, proto_tree *tree, packet_info *pinfo _U_, tvbuff_t *tvb, int offset, int len, proto_item *avp_item)
{ proto_tree_add_item(tree, a->hf, tvb, offset, len, ENC_NA); proto_item_append_text(avp_item, "%s", tvb_bytes_to_str(wmem_packet_scope(), tvb, offset, len)); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Configure drive strength and input sensing for given GPIO port. */
void gpio_set_options(uint32_t gpioport, uint32_t drive, uint32_t sense, uint32_t gpios)
/* Configure drive strength and input sensing for given GPIO port. */ void gpio_set_options(uint32_t gpioport, uint32_t drive, uint32_t sense, uint32_t gpios)
{ (void) gpioport; uint8_t i = 0; while (gpios) { if (gpios & 1) { GPIO_PIN_CNF(i) = (GPIO_PIN_CNF(i) & ~((GPIO_CNF_DRIVE_MASK << GPIO_CNF_DRIVE_SHIFT) | (GPIO_CNF_SENSE_MASK << GPIO_CNF_SENSE_SHIFT) ) ) | (drive << GPIO_CNF_DRIVE_SHIFT) | (sense << GPIO_CNF_SENSE_SHIFT); } ++i; gpios >>= 1; } }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* This searches for expander device based on sas_address, then returns the sas_node object. */
struct _sas_node* mpt2sas_scsih_expander_find_by_sas_address(struct MPT2SAS_ADAPTER *ioc, u64 sas_address)
/* This searches for expander device based on sas_address, then returns the sas_node object. */ struct _sas_node* mpt2sas_scsih_expander_find_by_sas_address(struct MPT2SAS_ADAPTER *ioc, u64 sas_address)
{ struct _sas_node *sas_expander, *r; r = NULL; list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { if (sas_expander->sas_address != sas_address) continue; r = sas_expander; goto out; } out: return r; }
robutest/uclinux
C++
GPL-2.0
60
/* generate a list of extant and dead calls in /proc/net/rxrpc_calls */
static void* rxrpc_call_seq_start(struct seq_file *seq, loff_t *_pos)
/* generate a list of extant and dead calls in /proc/net/rxrpc_calls */ static void* rxrpc_call_seq_start(struct seq_file *seq, loff_t *_pos)
{ read_lock(&rxrpc_call_lock); return seq_list_start_head(&rxrpc_calls, *_pos); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* If mpol_dup() sees current->cpuset == cpuset_being_rebound, then it rebinds the mempolicy its copying by calling mpol_rebind_policy() with the mems_allowed returned by cpuset_mems_allowed(). This keeps mempolicies cpuset relative after its cpuset moves. See further kernel/cpuset.c update_nodemask(). */
struct mempolicy* __mpol_dup(struct mempolicy *old)
/* If mpol_dup() sees current->cpuset == cpuset_being_rebound, then it rebinds the mempolicy its copying by calling mpol_rebind_policy() with the mems_allowed returned by cpuset_mems_allowed(). This keeps mempolicies cpuset relative after its cpuset moves. See further kernel/cpuset.c update_nodemask(). */ struct mempolicy* __mpol_dup(struct mempolicy *old)
{ struct mempolicy *new = kmem_cache_alloc(policy_cache, GFP_KERNEL); if (!new) return ERR_PTR(-ENOMEM); if (current_cpuset_is_being_rebound()) { nodemask_t mems = cpuset_mems_allowed(current); mpol_rebind_policy(old, &mems); } *new = *old; atomic_set(&new->refcnt, 1); return new; }
robutest/uclinux
C++
GPL-2.0
60
/* atl1c_irq_disable - Mask off interrupt generation on the NIC @adapter: board private structure */
static void atl1c_irq_disable(struct atl1c_adapter *adapter)
/* atl1c_irq_disable - Mask off interrupt generation on the NIC @adapter: board private structure */ static void atl1c_irq_disable(struct atl1c_adapter *adapter)
{ atomic_inc(&adapter->irq_sem); AT_WRITE_REG(&adapter->hw, REG_IMR, 0); AT_WRITE_FLUSH(&adapter->hw); synchronize_irq(adapter->pdev->irq); }
robutest/uclinux
C++
GPL-2.0
60
/* USBH_SetCfg The command sets the configuration value to the connected device. */
USBH_Status USBH_SetCfg(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost, uint16_t cfg_idx)
/* USBH_SetCfg The command sets the configuration value to the connected device. */ USBH_Status USBH_SetCfg(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost, uint16_t cfg_idx)
{ phost->Control.setup.b.bmRequestType = USB_H2D | USB_REQ_RECIPIENT_DEVICE |\ USB_REQ_TYPE_STANDARD; phost->Control.setup.b.bRequest = USB_REQ_SET_CONFIGURATION; phost->Control.setup.b.wValue.w = cfg_idx; phost->Control.setup.b.wIndex.w = 0; phost->Control.setup.b.wLength.w = 0; return USBH_CtlReq(pdev, phost, 0 , 0 ); }
MaJerle/stm32f429
C++
null
2,036
/* This initialises the LAN switch in the KS8695 to a known-good set of defaults. */
static void __devinit ks8695_init_switch(struct ks8695_priv *ksp)
/* This initialises the LAN switch in the KS8695 to a known-good set of defaults. */ static void __devinit ks8695_init_switch(struct ks8695_priv *ksp)
{ u32 ctrl; ctrl = 0x40819e00; ctrl &= ~(SEC0_LLED1S | SEC0_LLED0S); ctrl |= (LLED0S_LINK | LLED1S_LINK_ACTIVITY); ctrl |= SEC0_ENABLE; writel(ctrl, ksp->phyiface_regs + KS8695_SEC0); writel(0x9400100, ksp->phyiface_regs + KS8695_SEC1); }
robutest/uclinux
C++
GPL-2.0
60
/* This service is a wrapper for the PEI Service RegisterForShadow(), except the pointer to the PEI Services Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface Specification for details. */
EFI_STATUS EFIAPI PeiServicesRegisterForShadow(IN EFI_PEI_FILE_HANDLE FileHandle)
/* This service is a wrapper for the PEI Service RegisterForShadow(), except the pointer to the PEI Services Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface Specification for details. */ EFI_STATUS EFIAPI PeiServicesRegisterForShadow(IN EFI_PEI_FILE_HANDLE FileHandle)
{ return (*GetPeiServicesTablePointer ())->RegisterForShadow (FileHandle); }
tianocore/edk2
C++
Other
4,240
/* Function for determining whether the keyboard matrix state has changed compared to the state before. */
static bool cherry8x16_have_keys_changed(const uint8_t *state_now, uint8_t number_of_now_pressed_keys, const uint8_t *state_before, uint8_t number_of_before_pressed_keys)
/* Function for determining whether the keyboard matrix state has changed compared to the state before. */ static bool cherry8x16_have_keys_changed(const uint8_t *state_now, uint8_t number_of_now_pressed_keys, const uint8_t *state_before, uint8_t number_of_before_pressed_keys)
{ if (number_of_now_pressed_keys != number_of_before_pressed_keys) { return true; } else { for (uint_fast8_t i = number_of_now_pressed_keys; i--;) { if (state_now[i] != state_before[i]) { return true; } } } return false; }
labapart/polymcu
C++
null
201