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
/* Read a single color from the graphical memory. Limits have to be set prior to calling this function, e.g.: */
ili9325_color_t ili9325_read_gram(void)
/* Read a single color from the graphical memory. Limits have to be set prior to calling this function, e.g.: */ ili9325_color_t ili9325_read_gram(void)
{ uint8_t value[2]; ili9325_color_t color; LCD_IR(0); LCD_IR(ILI9325_GRAM_DATA_REG); value[0] = LCD_RD(); value[1] = LCD_RD(); value[0] = LCD_RD(); value[1] = LCD_RD(); color = ((value[0] & 0xF8)) | ((value[0] & 0x07) << 13) | ((value[1] & 0xE0) << 5) | ((value[1] & 0x1F) << 19); return color; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Mark Big Number for constant time computations. This function should be called before any constant time computations are performed on the given Big number. */
VOID EFIAPI BigNumConstTime(IN VOID *Bn)
/* Mark Big Number for constant time computations. This function should be called before any constant time computations are performed on the given Big number. */ VOID EFIAPI BigNumConstTime(IN VOID *Bn)
{ CALL_VOID_CRYPTO_SERVICE (BigNumConstTime, (Bn)); }
tianocore/edk2
C++
Other
4,240
/* This file is part of the Simba project. */
int mock_write_ssl_module_init(int res)
/* This file is part of the Simba project. */ int mock_write_ssl_module_init(int res)
{ harness_mock_write("ssl_module_init()", NULL, 0); harness_mock_write("ssl_module_init(): return (res)", &res, sizeof(res)); return (0); }
eerimoq/simba
C++
Other
337
/* VTData-ACK ::= SEQUENCE { allNewDataAccepted BOOLEAN, acceptedOctetCount Unsigned OPTIONAL */
static guint fVtDataAck(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
/* VTData-ACK ::= SEQUENCE { allNewDataAccepted BOOLEAN, acceptedOctetCount Unsigned OPTIONAL */ static guint fVtDataAck(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
{ guint lastoffset = 0; while (tvb_reported_length_remaining(tvb, offset) > 0) { lastoffset = offset; switch (fTagNo(tvb, offset)) { case 0: offset = fBooleanTag(tvb, pinfo, tree, offset, "all New Data Accepted: "); break; case 1: offset = fUnsignedTag(tvb, pinfo, tree, offset, "accepted Octet Count: "); break; default: return offset; } if (offset == lastoffset) break; } return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* PC_to_RDR_GetParameters Provides the ICC parameters to the host Response to this command message is the RDR_to_PC_Parameters. */
uint8_t PC_to_RDR_GetParameters(USBD_HandleTypeDef *pdev)
/* PC_to_RDR_GetParameters Provides the ICC parameters to the host Response to this command message is the RDR_to_PC_Parameters. */ uint8_t PC_to_RDR_GetParameters(USBD_HandleTypeDef *pdev)
{ uint8_t error; error = CCID_CheckCommandParams(pdev, CHK_PARAM_SLOT | CHK_PARAM_DWLENGTH | CHK_PARAM_CARD_PRESENT | CHK_PARAM_ABRFU3); if (error != 0U) { return error; } CCID_UpdateCommandStatus(pdev, (BM_COMMAND_STATUS_NO_ERROR), (BM_ICC_PRESENT_ACTIVE)); return SLOT_NO_ERROR; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Get Protected mode code segment from current GDT table. */
UINT16 GetProtectedModeCS(VOID)
/* Get Protected mode code segment from current GDT table. */ UINT16 GetProtectedModeCS(VOID)
{ IA32_DESCRIPTOR GdtrDesc; IA32_SEGMENT_DESCRIPTOR *GdtEntry; UINTN GdtEntryCount; UINT16 Index; AsmReadGdtr (&GdtrDesc); GdtEntryCount = (GdtrDesc.Limit + 1) / sizeof (IA32_SEGMENT_DESCRIPTOR); GdtEntry = (IA32_SEGMENT_DESCRIPTOR *)GdtrDesc.Base; for (Index = 0; Index < GdtEntryCount; Index++) { if (GdtEntry->Bits.L == 0) { if ((GdtEntry->Bits.Type > 8) && (GdtEntry->Bits.DB == 1)) { break; } } GdtEntry++; } ASSERT (Index != GdtEntryCount); return Index * 8; }
tianocore/edk2
C++
Other
4,240
/* Three ways to find out the number of additional hotplug CPUs: */
__init void prefill_possible_map(void)
/* Three ways to find out the number of additional hotplug CPUs: */ __init void prefill_possible_map(void)
{ int i, possible; if (!num_processors) num_processors = 1; if (setup_possible_cpus == -1) possible = num_processors + disabled_cpus; else possible = setup_possible_cpus; total_cpus = max_t(int, possible, num_processors + disabled_cpus); if (possible > CONFIG_NR_CPUS) { printk(KERN_WARNING "%d Processors exceeds NR_CPUS limit of %d\n", possible, CONFIG_NR_CPUS); possible = CONFIG_NR_CPUS; } printk(KERN_INFO "SMP: Allowing %d CPUs, %d hotplug CPUs\n", possible, max_t(int, possible - num_processors, 0)); for (i = 0; i < possible; i++) set_cpu_possible(i, true); nr_cpu_ids = possible; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* A wrapper to release access rights to the correct PHY. This is a function pointer entry point called by the api module. */
static void igb_release_phy_82575(struct e1000_hw *)
/* A wrapper to release access rights to the correct PHY. This is a function pointer entry point called by the api module. */ static void igb_release_phy_82575(struct e1000_hw *)
{ u16 mask = E1000_SWFW_PHY0_SM; if (hw->bus.func == E1000_FUNC_1) mask = E1000_SWFW_PHY1_SM; igb_release_swfw_sync_82575(hw, mask); }
robutest/uclinux
C++
GPL-2.0
60
/* Spurious interrupt handler. Installed in all _sw_isr_table slots at boot time. Throws an error if called. */
void z_irq_spurious(const void *unused)
/* Spurious interrupt handler. Installed in all _sw_isr_table slots at boot time. Throws an error if called. */ void z_irq_spurious(const void *unused)
{ ARG_UNUSED(unused); z_arm_fatal_error(K_ERR_SPURIOUS_IRQ, NULL); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* If String is NULL, then ASSERT(). If String is not aligned on a 16-bit boundary, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and String contains more than PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, then ASSERT(). */
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
/* If String is NULL, then ASSERT(). If String is not aligned on a 16-bit boundary, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and String contains more than PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, then ASSERT(). */ UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
{ return (StrLen (String) + 1) * sizeof (*String); }
tianocore/edk2
C++
Other
4,240
/* Function called in case of error detected in SPI IT Handler. */
void SPI1_TransferError_Callback(void)
/* Function called in case of error detected in SPI IT Handler. */ void SPI1_TransferError_Callback(void)
{ LL_DMA_DisableStream(DMA2, LL_DMA_STREAM_2); LL_DMA_DisableStream(DMA2, LL_DMA_STREAM_3); LED_Blinking(LED_BLINK_ERROR); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Rx flow control enable. When Enabled GMAC will decode the rx pause frame and disable the tx for a specified time. */
void synopGMAC_rx_flow_control_enable(synopGMACdevice *gmacdev)
/* Rx flow control enable. When Enabled GMAC will decode the rx pause frame and disable the tx for a specified time. */ void synopGMAC_rx_flow_control_enable(synopGMACdevice *gmacdev)
{ synopGMACSetBits(gmacdev->MacBase, GmacFlowControl, GmacRxFlowControl); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Go through timeout list (for this task only) and remove the first matching entry, even though the timeout has not triggered yet. */
void tls_untimeout_p(u8 timeo_assigned, tls_timeout_handler handler, void *arg)
/* Go through timeout list (for this task only) and remove the first matching entry, even though the timeout has not triggered yet. */ void tls_untimeout_p(u8 timeo_assigned, tls_timeout_handler handler, void *arg)
{ struct tls_timeo *prev_t, *t; struct tls_timeo **timeo = &next_timeout[timeo_assigned]; if (*timeo == NULL) { return; } for (t = *timeo, prev_t = NULL; t != NULL; prev_t = t, t = t->next) { if ((t->h == handler) && (t->arg == arg)) { if (prev_t == NULL) { *timeo = t->next; } else { prev_t->next = t->next; } if (t->next != NULL) { t->next->time += t->time; } tls_mem_free(t); return; } } return; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Duplicates the current instance of #CRStyle . The newly created instance of #CRStyle must be freed using cr_style_destroy (). */
CRStyle* cr_style_dup(CRStyle *a_this)
/* Duplicates the current instance of #CRStyle . The newly created instance of #CRStyle must be freed using cr_style_destroy (). */ CRStyle* cr_style_dup(CRStyle *a_this)
{ CRStyle *result = NULL; g_return_val_if_fail (a_this, NULL); result = cr_style_new (FALSE); if (!result) { cr_utils_trace_info ("Out of memory"); return NULL; } cr_style_copy (result, a_this); return result; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Return an allocated memory block back to a specific memory pool. */
osStatus osPoolFree(osPoolId pool_id, void *block)
/* Return an allocated memory block back to a specific memory pool. */ osStatus osPoolFree(osPoolId pool_id, void *block)
{ osPoolDef_t *osPool = (osPoolDef_t *)pool_id; k_mem_slab_free((struct k_mem_slab *)(osPool->pool), (void *)block); return osOK; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Enable the input direction of the specified GPIO. */
int32_t gpio_direction_input(gpio_desc *desc)
/* Enable the input direction of the specified GPIO. */ int32_t gpio_direction_input(gpio_desc *desc)
{ if (desc) { } return 0; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Description: Map the integrity vectors in request into a scatterlist. The scatterlist must be big enough to hold all elements. I.e. sized using blk_rq_count_integrity_sg(). */
int blk_rq_map_integrity_sg(struct request *rq, struct scatterlist *sglist)
/* Description: Map the integrity vectors in request into a scatterlist. The scatterlist must be big enough to hold all elements. I.e. sized using blk_rq_count_integrity_sg(). */ int blk_rq_map_integrity_sg(struct request *rq, struct scatterlist *sglist)
{ struct bio_vec *iv, *ivprv; struct req_iterator iter; struct scatterlist *sg; unsigned int segments; ivprv = NULL; sg = NULL; segments = 0; rq_for_each_integrity_segment(iv, rq, iter) { if (ivprv) { if (!BIOVEC_PHYS_MERGEABLE(ivprv, iv)) goto new_segment; sg->length += iv->bv_len; } else { new_segment: if (!sg) sg = sglist; else { sg->page_link &= ~0x02; sg = sg_next(sg); } sg_set_page(sg, iv->bv_page, iv->bv_len, iv->bv_offset); segments++; } ivprv = iv; } if (sg) sg_mark_end(sg); return segments; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Print a parser error, using the source file name and line number set by a previous call to SetParserPosition(). */
VOID ParserError(UINT32 MessageCode, CHAR8 *Text, CHAR8 *MsgFmt,...)
/* Print a parser error, using the source file name and line number set by a previous call to SetParserPosition(). */ VOID ParserError(UINT32 MessageCode, CHAR8 *Text, CHAR8 *MsgFmt,...)
{ va_list List; if (mPrintLimitsSet) { if (mMaxWarningsPlusErrors != 0) { if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) { PrintLimitExceeded (); return ; } } if (mMaxErrors != 0) { if (mErrorCount > mMaxErrors) { PrintLimitExceeded (); return ; } } } mErrorCount++; va_start (List, MsgFmt); PrintMessage ("ERROR", mSourceFileName, mSourceFileLineNum, MessageCode, Text, MsgFmt, List); va_end (List); }
tianocore/edk2
C++
Other
4,240
/* We register ourselves as hotplug enabled module and let PCI subsystem discover our adapters. */
static int __init megaraid_init(void)
/* We register ourselves as hotplug enabled module and let PCI subsystem discover our adapters. */ static int __init megaraid_init(void)
{ int rval; con_log(CL_ANN, (KERN_INFO "megaraid: %s %s\n", MEGARAID_VERSION, MEGARAID_EXT_VERSION)); if (megaraid_cmd_per_lun > MBOX_MAX_SCSI_CMDS) { con_log(CL_ANN, (KERN_WARNING "megaraid mailbox: max commands per lun reset to %d\n", MBOX_MAX_SCSI_CMDS)); megaraid_cmd_per_lun = MBOX_MAX_SCSI_CMDS; } rval = pci_register_driver(&megaraid_pci_driver); if (rval < 0) { con_log(CL_ANN, (KERN_WARNING "megaraid: could not register hotplug support.\n")); } return rval; }
robutest/uclinux
C++
GPL-2.0
60
/* Writes user data to the specified Data Backup Register. */
void BKP_WriteBackupRegister(uint16_t BKP_DR, uint16_t Data)
/* Writes user data to the specified Data Backup Register. */ void BKP_WriteBackupRegister(uint16_t BKP_DR, uint16_t Data)
{ assert_param(IS_BKP_DR(BKP_DR)); *(__IO uint16_t *) (BKP_BASE + BKP_DR) = Data; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* SPI MSP Initialization This function configures the hardware resources used in this example. */
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
/* SPI MSP Initialization This function configures the hardware resources used in this example. */ void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; if(hspi->Instance==SPI3) { __HAL_RCC_SPI3_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* 'pnum' is set to the number of sectors (including and immediately following the first one) that are known to be in the same allocated/unallocated state. */
static int is_allocated_sectors(const uint8_t *buf, int n, int *pnum)
/* 'pnum' is set to the number of sectors (including and immediately following the first one) that are known to be in the same allocated/unallocated state. */ static int is_allocated_sectors(const uint8_t *buf, int n, int *pnum)
{ bool is_zero; int i; if (n <= 0) { *pnum = 0; return 0; } is_zero = buffer_is_zero(buf, 512); for(i = 1; i < n; i++) { buf += 512; if (is_zero != buffer_is_zero(buf, 512)) { break; } } *pnum = i; return !is_zero; }
ve3wwg/teensy3_qemu
C
Other
15
/* Configures The selected interrupts on the IO Expanders. */
uint8_t IOE_ITConfig(uint32_t IOE_ITSRC_Source)
/* Configures The selected interrupts on the IO Expanders. */ uint8_t IOE_ITConfig(uint32_t IOE_ITSRC_Source)
{ IOE_ITOutConfig(Polarity_Low, Type_Level); if (IOE_ITSRC_Source & IOE_ITSRC_TSC) { IOE_GITCmd(IOE_1_ADDR, ENABLE); IOE_GITConfig(IOE_1_ADDR, (uint8_t)(IOE_GIT_TOUCH | IOE_GIT_FTH | IOE_GIT_FOV), ENABLE); I2C_ReadDeviceRegister(IOE_1_ADDR, IOE_REG_GPIO_INT_STA); } IOE_EXTI_Config(); return IOE_OK; }
remotemcu/remcu-chip-sdks
C++
null
436
/* remove an item and push it to the free items queue */
static void lv_lru_remove_item(lv_lru_t *cache, lv_lru_item_t *prev, lv_lru_item_t *item, uint32_t hash_index)
/* remove an item and push it to the free items queue */ static void lv_lru_remove_item(lv_lru_t *cache, lv_lru_item_t *prev, lv_lru_item_t *item, uint32_t hash_index)
{ if(prev) { prev->next = item->next; } else { cache->items[hash_index] = (lv_lru_item_t *) item->next; } cache->free_memory += item->value_length; cache->value_free(item->value); cache->key_free(item->key); lv_memzero(item, sizeof(lv_lru_item_t)); item->next = cache->free_items; cache->free_items = item; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* This function is used by ubi_leb_read() and ubi_leb_read_sg() to perform sanity checks. */
static int leb_read_sanity_check(struct ubi_volume_desc *desc, int lnum, int offset, int len)
/* This function is used by ubi_leb_read() and ubi_leb_read_sg() to perform sanity checks. */ static int leb_read_sanity_check(struct ubi_volume_desc *desc, int lnum, int offset, int len)
{ struct ubi_volume *vol = desc->vol; struct ubi_device *ubi = vol->ubi; int vol_id = vol->vol_id; if (vol_id < 0 || vol_id >= ubi->vtbl_slots || lnum < 0 || lnum >= vol->used_ebs || offset < 0 || len < 0 || offset + len > vol->usable_leb_size) return -EINVAL; if (vol->vol_type == UBI_STATIC_VOLUME) { if (vol->used_ebs == 0) return 0; if (lnum == vol->used_ebs - 1 && offset + len > vol->last_eb_bytes) return -EINVAL; } if (vol->upd_marker) return -EBADF; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Free an EFI_BOOT_MANGER_LOAD_OPTION array that was allocated by */
EFI_STATUS EFIAPI EfiBootManagerFreeLoadOptions(IN EFI_BOOT_MANAGER_LOAD_OPTION *Option, IN UINTN OptionCount)
/* Free an EFI_BOOT_MANGER_LOAD_OPTION array that was allocated by */ EFI_STATUS EFIAPI EfiBootManagerFreeLoadOptions(IN EFI_BOOT_MANAGER_LOAD_OPTION *Option, IN UINTN OptionCount)
{ UINTN Index; if (Option == NULL) { return EFI_NOT_FOUND; } for (Index = 0; Index < OptionCount; Index++) { EfiBootManagerFreeLoadOption (&Option[Index]); } FreePool (Option); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* fc_get_host_speed() - Return the speed of the given Scsi_Host @shost: The SCSI host whose port speed is to be determined */
void fc_get_host_speed(struct Scsi_Host *shost)
/* fc_get_host_speed() - Return the speed of the given Scsi_Host @shost: The SCSI host whose port speed is to be determined */ void fc_get_host_speed(struct Scsi_Host *shost)
{ struct fc_lport *lport = shost_priv(shost); fc_host_speed(shost) = lport->link_speed; }
robutest/uclinux
C++
GPL-2.0
60
/* Triggers a software capture on the designed capture unit. */
void HRTIM_SoftwareCapture(HRTIM_TypeDef *HRTIMx, uint32_t TimerIdx, uint32_t CaptureUnit)
/* Triggers a software capture on the designed capture unit. */ void HRTIM_SoftwareCapture(HRTIM_TypeDef *HRTIMx, uint32_t TimerIdx, uint32_t CaptureUnit)
{ assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx)); assert_param(IS_HRTIM_CAPTUREUNIT(CaptureUnit)); switch (CaptureUnit) { case HRTIM_CAPTUREUNIT_1: { HRTIMx->HRTIM_TIMERx[TimerIdx].CPT1xCR |= HRTIM_CPT1CR_SWCPT; } break; case HRTIM_CAPTUREUNIT_2: { HRTIMx->HRTIM_TIMERx[TimerIdx].CPT2xCR |= HRTIM_CPT2CR_SWCPT; } break; default: break; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Uses a critical section to determine if there is any space in a queue. */
static signed portBASE_TYPE prvIsQueueFull(const xQueueHandle pxQueue) PRIVILEGED_FUNCTION
/* Uses a critical section to determine if there is any space in a queue. */ static signed portBASE_TYPE prvIsQueueFull(const xQueueHandle pxQueue) PRIVILEGED_FUNCTION
{ signed portBASE_TYPE xReturn; taskENTER_CRITICAL(); xReturn = ( pxQueue->uxMessagesWaiting == pxQueue->uxLength ); taskEXIT_CRITICAL(); return xReturn; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Function for checking a write event for whether a CCCD was written during the write operation. */
static bool cccd_written(ble_gatts_evt_write_t *p_write_evt)
/* Function for checking a write event for whether a CCCD was written during the write operation. */ static bool cccd_written(ble_gatts_evt_write_t *p_write_evt)
{ return ( (p_write_evt->op == BLE_GATTS_OP_WRITE_REQ) && (p_write_evt->uuid.type == BLE_UUID_TYPE_BLE) && (p_write_evt->uuid.uuid == BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG) ); }
labapart/polymcu
C++
null
201
/* Dispose of the state data for the DIMM control loop */
static void dispose_dimms_state(struct dimm_pid_state *state)
/* Dispose of the state data for the DIMM control loop */ static void dispose_dimms_state(struct dimm_pid_state *state)
{ if (state->monitor == NULL) return; device_remove_file(&of_dev->dev, &dev_attr_dimms_temperature); state->monitor = NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* 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 UhciComponentNameGetDriverName(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 UhciComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
{ return LookupUnicodeString2 ( Language, This->SupportedLanguages, mUhciDriverNameTable, DriverName, (BOOLEAN)(This == &gUhciComponentName) ); }
tianocore/edk2
C++
Other
4,240
/* set operation mode; enabled: the thermal layer of the kernel takes care about the temperature and the fan. disabled: the BIOS takes control of the fan. */
static int acerhdf_set_mode(struct thermal_zone_device *thermal, enum thermal_device_mode mode)
/* set operation mode; enabled: the thermal layer of the kernel takes care about the temperature and the fan. disabled: the BIOS takes control of the fan. */ static int acerhdf_set_mode(struct thermal_zone_device *thermal, enum thermal_device_mode mode)
{ if (mode == THERMAL_DEVICE_DISABLED && kernelmode) acerhdf_revert_to_bios_mode(); else if (mode == THERMAL_DEVICE_ENABLED && !kernelmode) acerhdf_enable_kernelmode(); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* len <= EXT2_NAME_LEN and de != NULL are guaranteed by caller. */
static int ext2_match(int len, const char *const name, struct ext2_dir_entry_2 *de)
/* len <= EXT2_NAME_LEN and de != NULL are guaranteed by caller. */ static int ext2_match(int len, const char *const name, struct ext2_dir_entry_2 *de)
{ if (len != de->name_len) return 0; if (!de->inode) return 0; return !memcmp(name, de->name, len); }
robutest/uclinux
C++
GPL-2.0
60
/* Gets the device path information of the underlying NVM Express host controller. */
EFI_STATUS EFIAPI NvmePassThruGetDevicePath(IN EDKII_PEI_NVM_EXPRESS_PASS_THRU_PPI *This, OUT UINTN *DevicePathLength, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
/* Gets the device path information of the underlying NVM Express host controller. */ EFI_STATUS EFIAPI NvmePassThruGetDevicePath(IN EDKII_PEI_NVM_EXPRESS_PASS_THRU_PPI *This, OUT UINTN *DevicePathLength, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
{ PEI_NVME_CONTROLLER_PRIVATE_DATA *Private; if ((This == NULL) || (DevicePathLength == NULL) || (DevicePath == NULL)) { return EFI_INVALID_PARAMETER; } Private = GET_NVME_PEIM_HC_PRIVATE_DATA_FROM_THIS_NVME_PASSTHRU (This); *DevicePathLength = Private->DevicePathLength; *DevicePath = AllocateCopyPool (Private->DevicePathLength, Private->DevicePath); if (*DevicePath == NULL) { *DevicePathLength = 0; return EFI_OUT_OF_RESOURCES; } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Allocate page and record the information in PagesRecord */
VOID* EFIAPI RecordAllocatePages(IN ALLOCATE_PAGE_RECORDS *PagesRecord, IN UINTN Pages)
/* Allocate page and record the information in PagesRecord */ VOID* EFIAPI RecordAllocatePages(IN ALLOCATE_PAGE_RECORDS *PagesRecord, IN UINTN Pages)
{ VOID *Buffer; Buffer = NULL; if (PagesRecord->Count < PagesRecord->MaxCount) { Buffer = AllocatePages (Pages); PagesRecord->Records[PagesRecord->Count].Buffer = Buffer; PagesRecord->Records[PagesRecord->Count].Pages = Pages; PagesRecord->Count++; } ASSERT (Buffer != NULL); return Buffer; }
tianocore/edk2
C++
Other
4,240
/* Enables Broadcast frames. When enabled Address filtering module passes all incoming broadcast frames. */
void synopGMAC_broadcast_enable(synopGMACdevice *gmacdev)
/* Enables Broadcast frames. When enabled Address filtering module passes all incoming broadcast frames. */ void synopGMAC_broadcast_enable(synopGMACdevice *gmacdev)
{ synopGMACClearBits(gmacdev->MacBase, GmacFrameFilter, GmacBroadcast ); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Configures the Ethernet MAC PPS output in command mode. To use command mode, an application must call this function to enable the mode, then call: */
void EMACTimestampPPSCommandModeSet(uint32_t ui32Base, uint32_t ui32Config)
/* Configures the Ethernet MAC PPS output in command mode. To use command mode, an application must call this function to enable the mode, then call: */ void EMACTimestampPPSCommandModeSet(uint32_t ui32Base, uint32_t ui32Config)
{ ASSERT(ui32Base == EMAC0_BASE); ASSERT(!(ui32Config & (EMAC_PPS_TARGET_INT | EMAC_PPS_TARGET_PPS | EMAC_PPS_TARGET_BOTH))); while (HWREG(ui32Base + EMAC_O_PPSCTRL) & EMAC_PPSCTRL_PPSCTRL_M) { } HWREG(ui32Base + EMAC_O_PPSCTRL) = (EMAC_PPSCTRL_PPSEN0 | ui32Config); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Initialize the power controller and set the core and peripherals clock divider. */
int32_t pwr_setup(void)
/* Initialize the power controller and set the core and peripherals clock divider. */ int32_t pwr_setup(void)
{ int32_t ret; ret = adi_pwr_Init(); if(ret != SUCCESS) return FAILURE; ret = adi_pwr_SetClockDivider(ADI_CLOCK_HCLK,1); if(ret != SUCCESS) return FAILURE; return adi_pwr_SetClockDivider(ADI_CLOCK_PCLK,1); }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Sets the signal's duty cycle in percent (1-100). */
int pwmSetDutyCycle(uint32_t percentage)
/* Sets the signal's duty cycle in percent (1-100). */ int pwmSetDutyCycle(uint32_t percentage)
{ if ((percentage < 1) || (percentage > 100)) { return -1; } TMR_TMR16B1MR0 = (pwmPulseWidth * (100 - (pwmDutyCycle = percentage))) / 100; return 0; }
microbuilder/LPC1343CodeBase
C++
Other
73
/* This routine is called normally during driver unloading or exiting. */
void HvCleanup(void)
/* This routine is called normally during driver unloading or exiting. */ void HvCleanup(void)
{ union hv_x64_msr_hypercall_contents hypercallMsr; DPRINT_ENTER(VMBUS); if (gHvContext.SignalEventBuffer) { gHvContext.SignalEventBuffer = NULL; gHvContext.SignalEventParam = NULL; kfree(gHvContext.SignalEventBuffer); } if (gHvContext.GuestId == HV_LINUX_GUEST_ID) { if (gHvContext.HypercallPage) { hypercallMsr.AsUINT64 = 0; wrmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.AsUINT64); vfree(gHvContext.HypercallPage); gHvContext.HypercallPage = NULL; } } DPRINT_EXIT(VMBUS); }
robutest/uclinux
C++
GPL-2.0
60
/* Wake up a task on a specific queue */
void rpc_wake_up_queued_task(struct rpc_wait_queue *queue, struct rpc_task *task)
/* Wake up a task on a specific queue */ void rpc_wake_up_queued_task(struct rpc_wait_queue *queue, struct rpc_task *task)
{ spin_lock_bh(&queue->lock); rpc_wake_up_task_queue_locked(queue, task); spin_unlock_bh(&queue->lock); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Writes data to the specified GPIO data port. */
void GPIO_WriteOutputPort(GPIO_T *port, uint16_t portValue)
/* Writes data to the specified GPIO data port. */ void GPIO_WriteOutputPort(GPIO_T *port, uint16_t portValue)
{ port->ODATA = (uint32_t)portValue; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Returns: whether @handler_id identifies a handler connected to @instance. */
gboolean g_signal_handler_is_connected(gpointer instance, gulong handler_id)
/* Returns: whether @handler_id identifies a handler connected to @instance. */ gboolean g_signal_handler_is_connected(gpointer instance, gulong handler_id)
{ Handler *handler; gboolean connected; g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), FALSE); SIGNAL_LOCK (); handler = handler_lookup (instance, handler_id, NULL, NULL); connected = handler != NULL; SIGNAL_UNLOCK (); return connected; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function is called after a PCI bus error affecting this device has been detected. */
static pci_ers_result_t igb_io_error_detected(struct pci_dev *, pci_channel_state_t)
/* This function is called after a PCI bus error affecting this device has been detected. */ static pci_ers_result_t igb_io_error_detected(struct pci_dev *, pci_channel_state_t)
{ struct net_device *netdev = pci_get_drvdata(pdev); struct igb_adapter *adapter = netdev_priv(netdev); netif_device_detach(netdev); if (state == pci_channel_io_perm_failure) return PCI_ERS_RESULT_DISCONNECT; if (netif_running(netdev)) igb_down(adapter); pci_disable_device(pdev); return PCI_ERS_RESULT_NEED_RESET; }
robutest/uclinux
C++
GPL-2.0
60
/* This function triggers dummy write to the memory specified by the io_base, thus UPM pattern actually executed. Note that mar usage depends on the pre-programmed AMX bits in the UPM RAM. */
int fsl_upm_run_pattern(struct fsl_upm *upm, void __iomem *io_base, u32 mar)
/* This function triggers dummy write to the memory specified by the io_base, thus UPM pattern actually executed. Note that mar usage depends on the pre-programmed AMX bits in the UPM RAM. */ int fsl_upm_run_pattern(struct fsl_upm *upm, void __iomem *io_base, u32 mar)
{ int ret = 0; unsigned long flags; spin_lock_irqsave(&fsl_lbc_lock, flags); out_be32(&fsl_lbc_regs->mar, mar); switch (upm->width) { case 8: out_8(io_base, 0x0); break; case 16: out_be16(io_base, 0x0); break; case 32: out_be32(io_base, 0x0); break; default: ret = -EINVAL; break; } spin_unlock_irqrestore(&fsl_lbc_lock, flags); return ret; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* this routine takes the MAC address from the ethernet interface's data structure, and writes it into the ethernet adapter such that subsequent exchange of ethernet frames uses this address */
static int mcs7830_write_mac(struct eth_device *eth)
/* this routine takes the MAC address from the ethernet interface's data structure, and writes it into the ethernet adapter such that subsequent exchange of ethernet frames uses this address */ static int mcs7830_write_mac(struct eth_device *eth)
{ struct ueth_data *ueth = eth->priv; return mcs7830_write_mac_common(ueth->pusb_dev, eth->enetaddr); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Make sure that @bdata->disable_lock is locked when entering this function to avoid races with concurrent threads trying to enable the same button at the same time. */
static void gpio_keys_enable_button(struct gpio_button_data *bdata)
/* Make sure that @bdata->disable_lock is locked when entering this function to avoid races with concurrent threads trying to enable the same button at the same time. */ static void gpio_keys_enable_button(struct gpio_button_data *bdata)
{ if (bdata->disabled) { enable_irq(gpio_to_irq(bdata->button->gpio)); bdata->disabled = false; } }
robutest/uclinux
C++
GPL-2.0
60
/* param base LPSPI peripheral address. param handle LPSPI handle pointer to lpspi_slave_handle_t. param callback DSPI callback. param userData callback function parameter. */
void LPSPI_SlaveTransferCreateHandle(LPSPI_Type *base, lpspi_slave_handle_t *handle, lpspi_slave_transfer_callback_t callback, void *userData)
/* param base LPSPI peripheral address. param handle LPSPI handle pointer to lpspi_slave_handle_t. param callback DSPI callback. param userData callback function parameter. */ void LPSPI_SlaveTransferCreateHandle(LPSPI_Type *base, lpspi_slave_handle_t *handle, lpspi_slave_transfer_callback_t callback, void *userData)
{ assert(handle); (void)memset(handle, 0, sizeof(*handle)); s_lpspiHandle[LPSPI_GetInstance(base)] = handle; s_lpspiSlaveIsr = LPSPI_SlaveTransferHandleIRQ; handle->callback = callback; handle->userData = userData; }
eclipse-threadx/getting-started
C++
Other
310
/* First try a REPORT LUN scan, if that does not scan the target, do a sequential scan of LUNs on the target id. */
void scsi_scan_target(struct device *parent, unsigned int channel, unsigned int id, unsigned int lun, int rescan)
/* First try a REPORT LUN scan, if that does not scan the target, do a sequential scan of LUNs on the target id. */ void scsi_scan_target(struct device *parent, unsigned int channel, unsigned int id, unsigned int lun, int rescan)
{ struct Scsi_Host *shost = dev_to_shost(parent); if (strncmp(scsi_scan_type, "none", 4) == 0) return; mutex_lock(&shost->scan_mutex); if (!shost->async_scan) scsi_complete_async_scans(); if (scsi_host_scan_allowed(shost)) __scsi_scan_target(parent, channel, id, lun, rescan); mutex_unlock(&shost->scan_mutex); }
robutest/uclinux
C++
GPL-2.0
60
/* Set the update data swizzles, which will indicate how to swap the data before the Write Buffer is constructed. */
static void epdc_set_update_swizzle(unsigned int upd_swizzle)
/* Set the update data swizzles, which will indicate how to swap the data before the Write Buffer is constructed. */ static void epdc_set_update_swizzle(unsigned int upd_swizzle)
{ HW_EPDC_CTRL_CLR(EPDC_CTRL_UPD_DATA_SWIZZLE_MASK); HW_EPDC_CTRL_SET(upd_swizzle); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Works for both CAN and FDCAN frame lengths. If length is invalid value, then returns 0xFF. */
uint32_t fdcan_length_to_dlc(uint8_t length)
/* Works for both CAN and FDCAN frame lengths. If length is invalid value, then returns 0xFF. */ uint32_t fdcan_length_to_dlc(uint8_t length)
{ if (length <= 8) { return length; } else if (length <= 24) { if ((length % 4) != 0) { return 0xFF; } return 8 + ((length - 8) / 4); } else { if ((length % 16) != 0) { return 0xFF; } return 11 + (length / 16); } }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* STUSB1602 sets the the SINK DISCONNECT MODE (bit5 0x18 */
STUSB1602_StatusTypeDef STUSB1602_SNK_Disconnect_Mode_Status_Set(uint8_t Addr, SNK_Disconnect_Mode_TypeDef st)
/* STUSB1602 sets the the SINK DISCONNECT MODE (bit5 0x18 */ STUSB1602_StatusTypeDef STUSB1602_SNK_Disconnect_Mode_Status_Set(uint8_t Addr, SNK_Disconnect_Mode_TypeDef st)
{ STUSB1602_StatusTypeDef status = STUSB1602_OK; STUSB1602_CC_CAPABILITY_CTRL_RegTypeDef reg; STUSB1602_ReadReg(&reg.d8, Addr, STUSB1602_CC_CAPABILITY_CTRL_REG, 1); reg.b.SNK_DISCONNECT_MODE = st; status = STUSB1602_WriteReg(&reg.d8, Addr, STUSB1602_CC_CAPABILITY_CTRL_REG, 1); return status; }
st-one/X-CUBE-USB-PD
C++
null
110
/* Remove a RtkBuffer from specified rtkqueue at list tail. */
RTK_BUFFER* RtbDequeueTail(IN OUT RTB_QUEUE_HEAD *RtkQueueHead)
/* Remove a RtkBuffer from specified rtkqueue at list tail. */ RTK_BUFFER* RtbDequeueTail(IN OUT RTB_QUEUE_HEAD *RtkQueueHead)
{ RTK_BUFFER* Rtb = NULL; aos_mutex_lock(&RtkQueueHead->Lock, AOS_WAIT_FOREVER); if (RtbQueueIsEmpty(RtkQueueHead)) { aos_mutex_unlock(&RtkQueueHead->Lock); return NULL; } Rtb = (RTK_BUFFER*)RtkQueueHead->List.Prev; RtbRemoveNode(RtkQueueHead, Rtb); aos_mutex_unlock(&RtkQueueHead->Lock); return Rtb; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* We will call this function to format the output of the layer attribute file. */
static ssize_t pdcspath_layer_read(struct pdcspath_entry *entry, char *buf)
/* We will call this function to format the output of the layer attribute file. */ static ssize_t pdcspath_layer_read(struct pdcspath_entry *entry, char *buf)
{ char *out = buf; struct device_path *devpath; short i; if (!entry || !buf) return -EINVAL; read_lock(&entry->rw_lock); devpath = &entry->devpath; i = entry->ready; read_unlock(&entry->rw_lock); if (!i) return -ENODATA; for (i = 0; i < 6 && devpath->layers[i]; i++) out += sprintf(out, "%u ", devpath->layers[i]); out += sprintf(out, "\n"); return out - buf; }
robutest/uclinux
C++
GPL-2.0
60
/* Check if there is unused data and if there is warn about it. */
static gboolean c_warn_unused(proto_tree *tree, tvbuff_t *tvb, guint start, guint end, c_pkt_data *data)
/* Check if there is unused data and if there is warn about it. */ static gboolean c_warn_unused(proto_tree *tree, tvbuff_t *tvb, guint start, guint end, c_pkt_data *data)
{ guint diff; DISSECTOR_ASSERT_CMPUINT(start, <=, end); diff = end - start; if (!diff) return FALSE; proto_tree_add_expert_format(tree, data->pinfo, &ei_unused, tvb, start, diff, "%u unused byte%s", diff, diff == 1? "":"s"); return TRUE; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* The function is used to Get APB1 clock and the UNIT is in Hz. */
unsigned long SysCtlAPB1ClockGet(void)
/* The function is used to Get APB1 clock and the UNIT is in Hz. */ unsigned long SysCtlAPB1ClockGet(void)
{ unsigned long ulTemp,ulAPB1Clock; ulAPB1Clock = SysCtlHClockGet(); ulTemp = (xHWREG(RCC_CFGR) & RCC_CFGR_PPRE1_M) >> RCC_CFGR_PPRE1_S; ulTemp = (unsigned long)g_APBAHBPrescTable[ulTemp]; ulAPB1Clock = ulAPB1Clock >> ulTemp; return ulAPB1Clock; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This API reads the length of FIFO data available in the sensor in the units of bytes. */
uint16_t bma4_get_fifo_length(uint16_t *fifo_length, struct bma4_dev *dev)
/* This API reads the length of FIFO data available in the sensor in the units of bytes. */ uint16_t bma4_get_fifo_length(uint16_t *fifo_length, struct bma4_dev *dev)
{ uint16_t rslt = 0; uint8_t index = 0; uint8_t data[BMA4_FIFO_DATA_LENGTH] = {0, 0}; if (dev == NULL) { rslt |= BMA4_E_NULL_PTR; } else { rslt |= bma4_read_regs(BMA4_FIFO_LENGTH_0_ADDR, data, BMA4_FIFO_DATA_LENGTH, dev); if (rslt == BMA4_OK) { index = BMA4_FIFO_LENGTH_MSB_BYTE; data[index] = BMA4_GET_BITS_POS_0(data[index], BMA4_FIFO_BYTE_COUNTER_MSB); *fifo_length = ((data[index] << 8) | data[index - 1]); } } return rslt; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Return 1/0 according to whether or not it is permissible to set the tag's value. Note that we allow ImageLength to be changed so that we can append and extend to images. Any other tag may not be altered once writing has commenced, unless its value has no effect on the format of the data that is written. */
static int OkToChangeTag(TIFF *tif, uint32 tag)
/* Return 1/0 according to whether or not it is permissible to set the tag's value. Note that we allow ImageLength to be changed so that we can append and extend to images. Any other tag may not be altered once writing has commenced, unless its value has no effect on the format of the data that is written. */ static int OkToChangeTag(TIFF *tif, uint32 tag)
{ const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); if (!fip) { TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %u", tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag); return (0); } if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) && !fip->field_oktochange) { TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Cannot modify tag \"%s\" while writing", tif->tif_name, fip->field_name); return (0); } return (1); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* NOTE: Assumes wusbhc->usb_hcd has been already added by the upper layer (hwahc or whci) */
int wusbhc_b_create(struct wusbhc *wusbhc)
/* NOTE: Assumes wusbhc->usb_hcd has been already added by the upper layer (hwahc or whci) */ int wusbhc_b_create(struct wusbhc *wusbhc)
{ int result = 0; struct device *dev = wusbhc->usb_hcd.self.controller; result = sysfs_create_group(wusbhc_kobj(wusbhc), &wusbhc_attr_group); if (result < 0) { dev_err(dev, "Cannot register WUSBHC attributes: %d\n", result); goto error_create_attr_group; } result = wusbhc_pal_register(wusbhc); if (result < 0) goto error_pal_register; return 0; error_pal_register: sysfs_remove_group(wusbhc_kobj(wusbhc), &wusbhc_attr_group); error_create_attr_group: return result; }
robutest/uclinux
C++
GPL-2.0
60
/* The driver must call usb_free_urb() when it is finished with the urb. */
struct urb* usb_alloc_urb(int iso_packets, gfp_t mem_flags)
/* The driver must call usb_free_urb() when it is finished with the urb. */ struct urb* usb_alloc_urb(int iso_packets, gfp_t mem_flags)
{ struct urb *urb; urb = kmalloc(sizeof(struct urb) + iso_packets * sizeof(struct usb_iso_packet_descriptor), mem_flags); if (!urb) { printk(KERN_ERR "alloc_urb: kmalloc failed\n"); return NULL; } usb_init_urb(urb); return urb; }
robutest/uclinux
C++
GPL-2.0
60
/* Send an asynchronous request for the POD firmware version and device ID. */
static int pod_version_request_async(struct usb_line6_pod *pod)
/* Send an asynchronous request for the POD firmware version and device ID. */ static int pod_version_request_async(struct usb_line6_pod *pod)
{ return line6_send_raw_message_async(&pod->line6, pod->buffer_versionreq, sizeof(pod_request_version)); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns the number of bytes needed to hold the bitmap for this node. */
unsigned long __init init_bootmem_node(pg_data_t *pgdat, unsigned long freepfn, unsigned long startpfn, unsigned long endpfn)
/* Returns the number of bytes needed to hold the bitmap for this node. */ unsigned long __init init_bootmem_node(pg_data_t *pgdat, unsigned long freepfn, unsigned long startpfn, unsigned long endpfn)
{ return init_bootmem_core(pgdat->bdata, freepfn, startpfn, endpfn); }
robutest/uclinux
C++
GPL-2.0
60
/* Read the LSB of the 9-bit can Transmit Error Counter(TXERRCNT). */
uint8_t CAN_ReadLSBTxErrorCounter(CAN_T *can)
/* Read the LSB of the 9-bit can Transmit Error Counter(TXERRCNT). */ uint8_t CAN_ReadLSBTxErrorCounter(CAN_T *can)
{ return can->ERRSTS_B.TXERRCNT; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Selects the GPIO pin used as Event output. */
void GPIO_ConfigEventOutput(GPIO_PORT_SOURCE_T portSource, GPIO_PIN_SOURCE_T pinSource)
/* Selects the GPIO pin used as Event output. */ void GPIO_ConfigEventOutput(GPIO_PORT_SOURCE_T portSource, GPIO_PIN_SOURCE_T pinSource)
{ AFIO->EVCTRL_B.PORTSEL = portSource; AFIO->EVCTRL_B.PINSEL = pinSource; }
pikasTech/PikaPython
C++
MIT License
1,403
/* See if all fields of a variable of EFI_TIME type is correct. */
EFI_STATUS RtcTimeFieldsValid(IN EFI_TIME *Time)
/* See if all fields of a variable of EFI_TIME type is correct. */ EFI_STATUS RtcTimeFieldsValid(IN EFI_TIME *Time)
{ if ((Time->Year < mMinimalValidYear) || (Time->Year > mMaximalValidYear) || (Time->Month < 1) || (Time->Month > 12) || (!DayValid (Time)) || (Time->Hour > 23) || (Time->Minute > 59) || (Time->Second > 59) || (Time->Nanosecond > 999999999) || (!((Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE) || ((Time->TimeZone >= -1440) && (Time->TimeZone <= 1440)))) || ((Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT))) != 0)) { return EFI_INVALID_PARAMETER; } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Configure DAC (DAC instance: DAC1, DAC instance channel: channel1 ) and GPIO used by DAC channel. */
void Configure_DAC(void)
/* Configure DAC (DAC instance: DAC1, DAC instance channel: channel1 ) and GPIO used by DAC channel. */ void Configure_DAC(void)
{ LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA); LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_4, LL_GPIO_MODE_ANALOG); NVIC_SetPriority(TIM6_DAC_IRQn, 0); NVIC_EnableIRQ(TIM6_DAC_IRQn); LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_DAC1); LL_DAC_SetTriggerSource(DAC1, LL_DAC_CHANNEL_1, LL_DAC_TRIG_SOFTWARE); LL_DAC_EnableIT_DMAUDR1(DAC1); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* The entry point for UFS host controller driver, used to install this driver on the ImageHandle. */
EFI_STATUS EFIAPI UfsHcDriverEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* The entry point for UFS host controller driver, used to install this driver on the ImageHandle. */ EFI_STATUS EFIAPI UfsHcDriverEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ EFI_STATUS Status; Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gUfsHcDriverBinding, ImageHandle, &gUfsHcComponentName, &gUfsHcComponentName2 ); ASSERT_EFI_ERROR (Status); return Status; }
tianocore/edk2
C++
Other
4,240
/* If DhContext is NULL, then return FALSE. If Prime is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI CryptoServiceDhGenerateParameter(IN OUT VOID *DhContext, IN UINTN Generator, IN UINTN PrimeLength, OUT UINT8 *Prime)
/* If DhContext is NULL, then return FALSE. If Prime is NULL, then return FALSE. If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI CryptoServiceDhGenerateParameter(IN OUT VOID *DhContext, IN UINTN Generator, IN UINTN PrimeLength, OUT UINT8 *Prime)
{ return CALL_BASECRYPTLIB (Dh.Services.GenerateParameter, DhGenerateParameter, (DhContext, Generator, PrimeLength, Prime), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Start the execution of the program of the given engine. */
static int lp5562_start_program_exec(const struct device *dev, enum lp5562_led_sources engine)
/* Start the execution of the program of the given engine. */ static int lp5562_start_program_exec(const struct device *dev, enum lp5562_led_sources engine)
{ if (lp5562_set_engine_op_mode(dev, engine, LP5562_OP_MODE_RUN)) { return -EIO; } return lp5562_set_engine_exec_state(dev, engine, LP5562_ENGINE_MODE_RUN); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Closes an endpoint of the low level driver. */
USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
/* Closes an endpoint of the low level driver. */ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{ HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); switch (hal_status) { case HAL_OK : usb_status = USBD_OK; break; case HAL_ERROR : usb_status = USBD_FAIL; break; case HAL_BUSY : usb_status = USBD_BUSY; break; case HAL_TIMEOUT : usb_status = USBD_FAIL; break; default : usb_status = USBD_FAIL; break; } return usb_status; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* This file is part of the Simba project. */
int mock_write_upgrade_tftp_init(int port, int timeout_ms, int res)
/* This file is part of the Simba project. */ int mock_write_upgrade_tftp_init(int port, int timeout_ms, int res)
{ harness_mock_write("upgrade_tftp_init(port)", &port, sizeof(port)); harness_mock_write("upgrade_tftp_init(timeout_ms)", &timeout_ms, sizeof(timeout_ms)); harness_mock_write("upgrade_tftp_init(): return (res)", &res, sizeof(res)); return (0); }
eerimoq/simba
C++
Other
337
/* Go through all the DA filter tables (Unicast, Special Multicast & Other Multicast) and set each entry to 0. */
static void port_init_mac_tables(struct kwgbe_registers *regs)
/* Go through all the DA filter tables (Unicast, Special Multicast & Other Multicast) and set each entry to 0. */ static void port_init_mac_tables(struct kwgbe_registers *regs)
{ int table_index; for (table_index = 0; table_index < 4; ++table_index) KWGBEREG_WR(regs->dfut[table_index], 0); for (table_index = 0; table_index < 64; ++table_index) { KWGBEREG_WR(regs->dfsmt[table_index], 0); KWGBEREG_WR(regs->dfomt[table_index], 0); } }
EmcraftSystems/u-boot
C++
Other
181
/* param base SPDIF base pointer. param handle Pointer to the spdif_handle_t structure which stores the transfer state. param xfer Pointer to the spdif_transfer_t structure. retval kStatus_Success Successfully started the data receive. retval kStatus_SPDIF_TxBusy Previous receive still not finished. retval kStatus_InvalidArgument The input parameter is invalid. */
status_t SPDIF_TransferSendNonBlocking(SPDIF_Type *base, spdif_handle_t *handle, spdif_transfer_t *xfer)
/* param base SPDIF base pointer. param handle Pointer to the spdif_handle_t structure which stores the transfer state. param xfer Pointer to the spdif_transfer_t structure. retval kStatus_Success Successfully started the data receive. retval kStatus_SPDIF_TxBusy Previous receive still not finished. retval kStatus_InvalidArgument The input parameter is invalid. */ status_t SPDIF_TransferSendNonBlocking(SPDIF_Type *base, spdif_handle_t *handle, spdif_transfer_t *xfer)
{ assert(handle); if (handle->spdifQueue[handle->queueUser].data) { return kStatus_SPDIF_QueueFull; } handle->transferSize[handle->queueUser] = xfer->dataSize; handle->spdifQueue[handle->queueUser].data = xfer->data; handle->spdifQueue[handle->queueUser].dataSize = xfer->dataSize; handle->queueUser = (handle->queueUser + 1) % SPDIF_XFER_QUEUE_SIZE; handle->state = kSPDIF_Busy; SPDIF_EnableInterrupts(base, kSPDIF_TxFIFOEmpty); SPDIF_TxEnable(base, true); return kStatus_Success; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* retval kStatus_Success Reset successfully. retval kStatus_Fail Some other reset process is ongoing. */
status_t SEMA4_ResetGateNotify(SEMA4_Type *base, uint8_t gateNum)
/* retval kStatus_Success Reset successfully. retval kStatus_Fail Some other reset process is ongoing. */ status_t SEMA4_ResetGateNotify(SEMA4_Type *base, uint8_t gateNum)
{ status_t status; assert(!((gateNum < (uint8_t)SEMA4_GATE_NUM_RESET_ALL) && (gateNum >= (uint8_t)FSL_FEATURE_SEMA4_GATE_COUNT))); if (0U != (base->RSTNTF & SEMA4_RSTNTF_RSTNSM_MASK)) { status = kStatus_Fail; } else { base->RSTNTF = SEMA4_RSTNTF_RSTNSM_RSTNMS_RSTNDP(SEMA4_GATE_IRQ_RESET_PATTERN_1); base->RSTNTF = SEMA4_RSTNTF_RSTNSM_RSTNMS_RSTNDP(SEMA4_GATE_IRQ_RESET_PATTERN_2) | SEMA4_RSTNTF_RSTNTN(gateNum); status = kStatus_Success; } return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* xfs_trans_free_busy Free all of the busy lists from a transaction */
void xfs_trans_free_busy(xfs_trans_t *tp)
/* xfs_trans_free_busy Free all of the busy lists from a transaction */ void xfs_trans_free_busy(xfs_trans_t *tp)
{ xfs_log_busy_chunk_t *lbcp; xfs_log_busy_chunk_t *lbcq; lbcp = tp->t_busy.lbc_next; while (lbcp != NULL) { lbcq = lbcp->lbc_next; kmem_free(lbcp); lbcp = lbcq; } XFS_LBC_INIT(&tp->t_busy); tp->t_busy.lbc_unused = 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Add callback @new to be called when an event occurs in @rc. */
int uwb_notifs_register(struct uwb_rc *rc, struct uwb_notifs_handler *new)
/* Add callback @new to be called when an event occurs in @rc. */ int uwb_notifs_register(struct uwb_rc *rc, struct uwb_notifs_handler *new)
{ if (mutex_lock_interruptible(&rc->notifs_chain.mutex)) return -ERESTARTSYS; list_add(&new->list_node, &rc->notifs_chain.list); mutex_unlock(&rc->notifs_chain.mutex); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* The GSettingsBackend API is exported to allow third-party implementations, but does not carry the same stability guarantees as the public GIO API. For this reason, you have to define the C preprocessor symbol G_SETTINGS_ENABLE_BACKEND before including */
static gboolean is_key(const gchar *key)
/* The GSettingsBackend API is exported to allow third-party implementations, but does not carry the same stability guarantees as the public GIO API. For this reason, you have to define the C preprocessor symbol G_SETTINGS_ENABLE_BACKEND before including */ static gboolean is_key(const gchar *key)
{ gint length; gint i; g_return_val_if_fail (key != NULL, FALSE); g_return_val_if_fail (key[0] == '/', FALSE); for (i = 1; key[i]; i++) g_return_val_if_fail (key[i] != '/' || key[i + 1] != '/', FALSE); length = i; g_return_val_if_fail (key[length - 1] != '/', FALSE); return TRUE; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* param base SPI base pointer param enable True means enable DMA, false means disable DMA */
void SPI_EnableRxDMA(SPI_Type *base, bool enable)
/* param base SPI base pointer param enable True means enable DMA, false means disable DMA */ void SPI_EnableRxDMA(SPI_Type *base, bool enable)
{ if (enable) { base->FIFOCFG |= SPI_FIFOCFG_DMARX_MASK; } else { base->FIFOCFG &= ~SPI_FIFOCFG_DMARX_MASK; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Low-level drivers must call ib_dispatch_event() to dispatch the event to all registered event handlers when an asynchronous event occurs. */
void ib_dispatch_event(struct ib_event *event)
/* Low-level drivers must call ib_dispatch_event() to dispatch the event to all registered event handlers when an asynchronous event occurs. */ void ib_dispatch_event(struct ib_event *event)
{ unsigned long flags; struct ib_event_handler *handler; spin_lock_irqsave(&event->device->event_handler_lock, flags); list_for_each_entry(handler, &event->device->event_handler_list, list) handler->handler(handler, event); spin_unlock_irqrestore(&event->device->event_handler_lock, flags); }
robutest/uclinux
C++
GPL-2.0
60
/* Start receiver by submitting a request to the receive pipe. If nothing is available it will return after rx_interval. */
static int receive_start(struct stir_cb *stir)
/* Start receiver by submitting a request to the receive pipe. If nothing is available it will return after rx_interval. */ static int receive_start(struct stir_cb *stir)
{ stir->receiving = 1; stir->rx_buff.in_frame = FALSE; stir->rx_buff.state = OUTSIDE_FRAME; stir->rx_urb->status = 0; return usb_submit_urb(stir->rx_urb, GFP_KERNEL); }
robutest/uclinux
C++
GPL-2.0
60
/* SCSI_SenseCode Load the last error code in the error list. */
void SCSI_SenseCode(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t sKey, uint8_t ASC)
/* SCSI_SenseCode Load the last error code in the error list. */ void SCSI_SenseCode(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t sKey, uint8_t ASC)
{ UNUSED(lun); USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId]; if (hmsc == NULL) { return; } hmsc->scsi_sense[hmsc->scsi_sense_tail].Skey = sKey; hmsc->scsi_sense[hmsc->scsi_sense_tail].w.b.ASC = ASC; hmsc->scsi_sense[hmsc->scsi_sense_tail].w.b.ASCQ = 0U; hmsc->scsi_sense_tail++; if (hmsc->scsi_sense_tail == SENSE_LIST_DEEPTH) { hmsc->scsi_sense_tail = 0U; } }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Accelerometer Y-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range .. */
int32_t lsm6dso_xl_usr_offset_y_set(lsm6dso_ctx_t *ctx, uint8_t *buff)
/* Accelerometer Y-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range .. */ int32_t lsm6dso_xl_usr_offset_y_set(lsm6dso_ctx_t *ctx, uint8_t *buff)
{ int32_t ret; ret = lsm6dso_write_reg(ctx, LSM6DSO_Y_OFS_USR, buff, 1); return ret; }
alexander-g-dean/ESF
C++
null
41
/* ia64_log_init Reset the OS ia64 log buffer Inputs : info_type (SAL_INFO_TYPE_{MCA,INIT,CMC,CPE}) Outputs : None */
static void __init ia64_log_init(int sal_info_type)
/* ia64_log_init Reset the OS ia64 log buffer Inputs : info_type (SAL_INFO_TYPE_{MCA,INIT,CMC,CPE}) Outputs : None */ static void __init ia64_log_init(int sal_info_type)
{ u64 max_size = 0; IA64_LOG_NEXT_INDEX(sal_info_type) = 0; IA64_LOG_LOCK_INIT(sal_info_type); max_size = ia64_sal_get_state_info_size(sal_info_type); if (!max_size) return; IA64_LOG_ALLOCATE(sal_info_type, max_size); memset(IA64_LOG_CURR_BUFFER(sal_info_type), 0, max_size); memset(IA64_LOG_NEXT_BUFFER(sal_info_type), 0, max_size); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* DevicePathNode must be SerialCDROM Channel type and this will populate the MappingItem. */
EFI_STATUS DevPathSerialCdRom(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode, IN DEVICE_CONSIST_MAPPING_INFO *MappingItem, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
/* DevicePathNode must be SerialCDROM Channel type and this will populate the MappingItem. */ EFI_STATUS DevPathSerialCdRom(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode, IN DEVICE_CONSIST_MAPPING_INFO *MappingItem, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
{ CDROM_DEVICE_PATH *Cd; ASSERT (DevicePathNode != NULL); ASSERT (MappingItem != NULL); Cd = (CDROM_DEVICE_PATH *)DevicePathNode; MappingItem->Mtd = MTDTypeCDRom; return AppendCSDNum (MappingItem, Cd->BootEntry); }
tianocore/edk2
C++
Other
4,240
/* brief Enable USB HS clock. retval true The clock is set successfully. retval false The clock source is invalid to get proper USB HS clock. */
bool CLOCK_EnableUsbhsClock(void)
/* brief Enable USB HS clock. retval true The clock is set successfully. retval false The clock source is invalid to get proper USB HS clock. */ bool CLOCK_EnableUsbhsClock(void)
{ USBHS1__USBC->USBCMD |= USBHS_USBCMD_RST_MASK; for (uint32_t i = 0; i < 400000U; i++) { __ASM("nop"); } return true; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The ParseOptions() function parses the option fields in an MTFTPv6 OACK packet and returns the number of options that were found, and optionally, a list of pointers to the options in the packet. If one or more of the option fields are not valid, then EFI_PROTOCOL_ERROR is returned and OptionCount and *OptionList stop at the last valid option. */
EFI_STATUS EFIAPI EfiMtftp6ParseOptions(IN EFI_MTFTP6_PROTOCOL *This, IN UINT32 PacketLen, IN EFI_MTFTP6_PACKET *Packet, OUT UINT32 *OptionCount, OUT EFI_MTFTP6_OPTION **OptionList OPTIONAL)
/* The ParseOptions() function parses the option fields in an MTFTPv6 OACK packet and returns the number of options that were found, and optionally, a list of pointers to the options in the packet. If one or more of the option fields are not valid, then EFI_PROTOCOL_ERROR is returned and OptionCount and *OptionList stop at the last valid option. */ EFI_STATUS EFIAPI EfiMtftp6ParseOptions(IN EFI_MTFTP6_PROTOCOL *This, IN UINT32 PacketLen, IN EFI_MTFTP6_PACKET *Packet, OUT UINT32 *OptionCount, OUT EFI_MTFTP6_OPTION **OptionList OPTIONAL)
{ if (This == NULL) { return EFI_INVALID_PARAMETER; } return Mtftp6ParseStart (Packet, PacketLen, OptionCount, OptionList); }
tianocore/edk2
C++
Other
4,240
/* This function gets the thread creation stackaddr attribute in the attr object. */
int pthread_attr_getstackaddr(pthread_attr_t const *attr, void **stack_addr)
/* This function gets the thread creation stackaddr attribute in the attr object. */ int pthread_attr_getstackaddr(pthread_attr_t const *attr, void **stack_addr)
{ RT_ASSERT(attr != RT_NULL); return EOPNOTSUPP; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The other coefficients are changed so that the step is half the original step. This means that doing fd_fwd (f) n times with the input f results in the same f as doing fd_fwd (f) 2n times with the output f. */
static void fd_down(double f[4])
/* The other coefficients are changed so that the step is half the original step. This means that doing fd_fwd (f) n times with the input f results in the same f as doing fd_fwd (f) 2n times with the output f. */ static void fd_down(double f[4])
{ f[3] *= 0.125; f[2] = f[2] * 0.25 - f[3]; f[1] = (f[1] - f[2]) * 0.5; }
xboot/xboot
C++
MIT License
779
/* Converts a text device path node to USB IRDA bridge device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextUsbIrdaBridge(IN CHAR16 *TextDeviceNode)
/* Converts a text device path node to USB IRDA bridge device path structure. */ EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextUsbIrdaBridge(IN CHAR16 *TextDeviceNode)
{ USB_CLASS_TEXT UsbClassText; UsbClassText.ClassExist = FALSE; UsbClassText.Class = USB_CLASS_RESERVE; UsbClassText.SubClassExist = FALSE; UsbClassText.SubClass = USB_SUBCLASS_IRDA_BRIDGE; return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); }
tianocore/edk2
C++
Other
4,240
/* If the requested operation results in an overflow or an underflow condition, then Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt16Add(IN INT16 Augend, IN INT16 Addend, OUT INT16 *Result)
/* If the requested operation results in an overflow or an underflow condition, then Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeInt16Add(IN INT16 Augend, IN INT16 Addend, OUT INT16 *Result)
{ return SafeInt32ToInt16 (((INT32)Augend) + ((INT32)Addend), Result); }
tianocore/edk2
C++
Other
4,240
/* This function will return the length of a string, which terminate will null character. */
rt_size_t rt_strlen(const char *s)
/* This function will return the length of a string, which terminate will null character. */ rt_size_t rt_strlen(const char *s)
{ const char *sc; for (sc = s; *sc != '\0'; ++sc) ; return sc - s; }
pikasTech/PikaPython
C++
MIT License
1,403
/* g e t N u m b e r A r r a y */
returnValue Indexlist_getNumberArray(Indexlist *_THIS, int **const numberarray)
/* g e t N u m b e r A r r a y */ returnValue Indexlist_getNumberArray(Indexlist *_THIS, int **const numberarray)
{ if (numberarray == 0) return THROWERROR( RET_INVALID_ARGUMENTS ); *numberarray = _THIS->number; return SUCCESSFUL_RETURN; }
DanielMartensson/EmbeddedLapack
C++
MIT License
129
/* param base USART peripheral base address. param handle USART handle pointer. param count Receive bytes count. retval kStatus_NoTransferInProgress No receive in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter */
status_t USART_TransferGetReceiveCountDMA(USART_Type *base, usart_dma_handle_t *handle, uint32_t *count)
/* param base USART peripheral base address. param handle USART handle pointer. param count Receive bytes count. retval kStatus_NoTransferInProgress No receive in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter */ status_t USART_TransferGetReceiveCountDMA(USART_Type *base, usart_dma_handle_t *handle, uint32_t *count)
{ assert(NULL != handle); assert(NULL != handle->rxDmaHandle); assert(NULL != count); if ((uint8_t)kUSART_RxIdle == handle->rxState) { return kStatus_NoTransferInProgress; } *count = handle->rxDataSizeAll - DMA_GetRemainingBytes(handle->rxDmaHandle->base, handle->rxDmaHandle->channel); return kStatus_Success; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Note: first step is the protocol driver prepares a dma-capable memory, and this func just need translate the virt addr to physical */
static int map_dma_buffers(struct dw_spi *dws)
/* Note: first step is the protocol driver prepares a dma-capable memory, and this func just need translate the virt addr to physical */ static int map_dma_buffers(struct dw_spi *dws)
{ if (!dws->cur_msg->is_dma_mapped || !dws->dma_inited || !dws->cur_chip->enable_dma) return 0; if (dws->cur_transfer->tx_dma) dws->tx_dma = dws->cur_transfer->tx_dma; if (dws->cur_transfer->rx_dma) dws->rx_dma = dws->cur_transfer->rx_dma; return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Description: Invalidates and frees any entries in the CIPSO cache. Returns zero on success and negative values on failure. */
void cipso_v4_cache_invalidate(void)
/* Description: Invalidates and frees any entries in the CIPSO cache. Returns zero on success and negative values on failure. */ void cipso_v4_cache_invalidate(void)
{ struct cipso_v4_map_cache_entry *entry, *tmp_entry; u32 iter; for (iter = 0; iter < CIPSO_V4_CACHE_BUCKETS; iter++) { spin_lock_bh(&cipso_v4_cache[iter].lock); list_for_each_entry_safe(entry, tmp_entry, &cipso_v4_cache[iter].list, list) { list_del(&entry->list); cipso_v4_cache_entry_free(entry); } cipso_v4_cache[iter].size = 0; spin_unlock_bh(&cipso_v4_cache[iter].lock); } return; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Convert the D-PHY PLL CN to the value could be set to register. */
static uint8_t DSI_EncodeDphyPllCn(uint8_t cn)
/* Convert the D-PHY PLL CN to the value could be set to register. */ static uint8_t DSI_EncodeDphyPllCn(uint8_t cn)
{ assert((cn >= 1U) && (cn <= 32U)); if (1U == cn) { return 0x1FU; } else { return (uint8_t)((0x65BD44E0UL >> ((uint32_t)cn - 2U)) & 0x1FU); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Some Apple MacBook and MacBookPro's needs reboot=p to be able to reboot */
static int __init set_pci_reboot(const struct dmi_system_id *d)
/* Some Apple MacBook and MacBookPro's needs reboot=p to be able to reboot */ static int __init set_pci_reboot(const struct dmi_system_id *d)
{ if (reboot_type != BOOT_CF9) { reboot_type = BOOT_CF9; printk(KERN_INFO "%s series board detected. " "Selecting PCI-method for reboots.\n", d->ident); } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* return a SMB error string from a SMB buffer */
char* smb_errstr(int class, int num)
/* return a SMB error string from a SMB buffer */ char* smb_errstr(int class, int num)
{ static char ret[128]; int i, j; ret[0] = 0; for (i = 0; err_classes[i].class; i++) if (err_classes[i].code == class) { if (err_classes[i].err_msgs) { const err_code_struct *err = err_classes[i].err_msgs; for (j = 0; err[j].name; j++) if (num == err[j].code) { snprintf(ret, sizeof(ret), "%s - %s (%s)", err_classes[i].class, err[j].name, err[j].message); return ret; } } snprintf(ret, sizeof(ret), "%s - %d", err_classes[i].class, num); return ret; } snprintf(ret, sizeof(ret), "ERROR: Unknown error (%d,%d)", class, num); return(ret); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Reads the specified I2C register and returns its value. */
uint32_t I2C_ReadRegister(I2C_T *i2c, uint8_t registers)
/* Reads the specified I2C register and returns its value. */ uint32_t I2C_ReadRegister(I2C_T *i2c, uint8_t registers)
{ __IO uint32_t temp = 0; temp = (uint32_t)i2c; temp += registers; return (*(__IO uint32_t*) temp); }
pikasTech/PikaPython
C++
MIT License
1,403