docstring
stringlengths
22
576
signature
stringlengths
9
317
prompt
stringlengths
57
886
code
stringlengths
20
1.36k
repository
stringclasses
49 values
language
stringclasses
2 values
license
stringclasses
9 values
stars
int64
15
21.3k
/* param base PGMC basic power controller base address. param setPointMap Should be the OR'ed value of _pgmc_setpoint_map. param option The pointer of pgmc_bpc_setpoint_mode_option_t structure. */
void PGMC_BPC_ControlPowerDomainBySetPointMode(PGMC_BPC_Type *base, uint32_t setPointMap, const pgmc_bpc_setpoint_mode_option_t *option)
/* param base PGMC basic power controller base address. param setPointMap Should be the OR'ed value of _pgmc_setpoint_map. param option The pointer of pgmc_bpc_setpoint_mode_option_t structure. */ void PGMC_BPC_ControlPowerDomainBySetPointMode(PGMC_BPC_Type *base, uint32_t setPointMap, const pgmc_bpc_setpoint_mode_option_t *option)
{ assert(option != NULL); setPointMap &= 0xFFFFU; base->BPC_MODE = PGMC_BPC_BPC_MODE_CTRL_MODE(kPGMC_ControlledBySetPoint); if (option->powerOff) { base->BPC_POWER_CTRL |= PGMC_BPC_BPC_POWER_CTRL_PWR_OFF_AT_SP(setPointMap); } if (option->stateSave) { base->BPC_SSAR_SAVE_CTRL = PGMC_BPC_BPC_SSAR_SAVE_CTRL_SAVE_AT_SP(setPointMap); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Send a doorbell message to a RIO device. The doorbell message has a 16-bit info field provided by the data argument. */
int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid, u16 data)
/* Send a doorbell message to a RIO device. The doorbell message has a 16-bit info field provided by the data argument. */ int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid, u16 data)
{ int res; unsigned long flags; spin_lock_irqsave(&rio_doorbell_lock, flags); res = mport->ops->dsend(mport, mport->id, destid, data); spin_unlock_irqrestore(&rio_doorbell_lock, flags); return res; }
robutest/uclinux
C++
GPL-2.0
60
/* this must be called very early as the kernel might use some instruction that are emulated on the 060 */
void __init base_trap_init(void)
/* this must be called very early as the kernel might use some instruction that are emulated on the 060 */ void __init base_trap_init(void)
{ if(MACH_IS_SUN3X) { extern e_vector *sun3x_prom_vbr; __asm__ volatile ("movec %%vbr, %0" : "=r" (sun3x_prom_vbr)); } __asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)vectors)); if (CPU_IS_060) { asmlinkage void unimp_vec(void) asm ("_060_isp_unimp"); vectors[VEC_UNIMPII] = unimp_vec; } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return: 0 on success or a negative error code on failure. */
int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi, u16 *brightness)
/* Return: 0 on success or a negative error code on failure. */ int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi, u16 *brightness)
{ ssize_t err; err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_DISPLAY_BRIGHTNESS, brightness, sizeof(*brightness)); if (err <= 0) { if (err == 0) err = -ENODATA; return err; } return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Function for adding a key to the key packet. If key is found to be in the packet, it will not be added twice. Attempts to add more keys than the buffer capacity allows will be silently ignored. */
static void cherry8x16_keypacket_addkey(uint8_t key)
/* Function for adding a key to the key packet. If key is found to be in the packet, it will not be added twice. Attempts to add more keys than the buffer capacity allows will be silently ignored. */ static void cherry8x16_keypacket_addkey(uint8_t key)
{ for (uint_fast8_t i = KEY_PACKET_KEY_INDEX; i < KEY_PACKET_SIZE; i++) { if (m_key_packet[i] == key) { return; } } for (uint_fast8_t i = KEY_PACKET_KEY_INDEX; i < KEY_PACKET_SIZE; i++) { if (m_key_packet[i] == KEY_PACKET_NO_KEY) { m_key_packet[i] = key; return; } } }
labapart/polymcu
C++
null
201
/* Return a pointer to the first file handle in the packet. If the packet was truncated, return 0. */
static const uint32_t* parsereq(netdissect_options *ndo, register const struct sunrpc_msg *rp, register u_int length)
/* Return a pointer to the first file handle in the packet. If the packet was truncated, return 0. */ static const uint32_t* parsereq(netdissect_options *ndo, register const struct sunrpc_msg *rp, register u_int length)
{ register const uint32_t *dp; register u_int len; dp = (const uint32_t *)&rp->rm_call.cb_cred; ND_TCHECK(dp[1]); len = EXTRACT_32BITS(&dp[1]); if (len < length) { dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp); ND_TCHECK(dp[1]); len = EXTRACT_32BITS(&dp[1]); if (len < length) { dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp); ND_TCHECK2(dp[0], 0); return (dp); } } trunc: return (NULL); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* If Buffer is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16* EFIAPI MmioWriteBuffer16(IN UINTN StartAddress, IN UINTN Length, IN CONST UINT16 *Buffer)
/* If Buffer is not aligned on a 16-bit boundary, then ASSERT(). */ UINT16* EFIAPI MmioWriteBuffer16(IN UINTN StartAddress, IN UINTN Length, IN CONST UINT16 *Buffer)
{ UINT16 *ReturnBuffer; ASSERT ((StartAddress & (sizeof (UINT16) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); ASSERT ((Length & (sizeof (UINT16) - 1)) == 0); ASSERT (((UINTN)Buffer & (sizeof (UINT16) - 1)) == 0); ReturnBuffer = (UINT16 *)Buffer; while (Length != 0) { MmioWrite16 (StartAddress, *(Buffer++)); StartAddress += sizeof (UINT16); Length -= sizeof (UINT16); } return ReturnBuffer; }
tianocore/edk2
C++
Other
4,240
/* Function: MX25_WRDI Arguments: None. Description: The WRDI instruction is to reset Write Enable Latch (WEL) bit. Return Message: FlashOperationSuccess */
ReturnMsg MX25_WRDI(void)
/* Function: MX25_WRDI Arguments: None. Description: The WRDI instruction is to reset Write Enable Latch (WEL) bit. Return Message: FlashOperationSuccess */ ReturnMsg MX25_WRDI(void)
{ CS_Low(); SendByte( FLASH_CMD_WRDI, SIO ); CS_High(); return FlashOperationSuccess; }
remotemcu/remcu-chip-sdks
C++
null
436
/* "fail-sss": Indicates that the device is not operational. A serious error was detected in the device and it is unlikely to become operational without repair. The sss portion of the value is specific to the device and indicates the error condition detected. */
static rt_bool_t ofw_node_is_fail(const struct rt_ofw_node *np)
/* "fail-sss": Indicates that the device is not operational. A serious error was detected in the device and it is unlikely to become operational without repair. The sss portion of the value is specific to the device and indicates the error condition detected. */ static rt_bool_t ofw_node_is_fail(const struct rt_ofw_node *np)
{ rt_bool_t res = RT_FALSE; const char *status = rt_ofw_prop_read_raw(np, "status", RT_NULL); if (status) { res = !rt_strcmp(status, "fail") || !rt_strncmp(status, "fail-", 5); } return res; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Supply SD card with lowest clock frequency at initialization. */
EFI_STATUS SdPeimHcInitClockFreq(IN UINTN Bar)
/* Supply SD card with lowest clock frequency at initialization. */ EFI_STATUS SdPeimHcInitClockFreq(IN UINTN Bar)
{ EFI_STATUS Status; SD_HC_SLOT_CAP Capability; UINT32 InitFreq; Status = SdPeimHcGetCapability (Bar, &Capability); if (EFI_ERROR (Status)) { return Status; } if (Capability.BaseClkFreq == 0) { return EFI_UNSUPPORTED; } InitFreq = 400; Status = SdPeimHcClockSupply (Bar, InitFreq); return Status; }
tianocore/edk2
C++
Other
4,240
/* Return cache if it matches with size and tag of stored caches, otherwise return NULL. */
static struct frag_cache* get_reass_cache(uint16_t size, uint16_t tag)
/* Return cache if it matches with size and tag of stored caches, otherwise return NULL. */ static struct frag_cache* get_reass_cache(uint16_t size, uint16_t tag)
{ uint8_t i; for (i = 0U; i < REASS_CACHE_SIZE; i++) { if (cache[i].used) { if (cache[i].size == size && cache[i].tag == tag) { return &cache[i]; } } } return NULL; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* This function will attempt to read BufferSize bytes from the TLS object and places the data in Buffer. */
INTN EFIAPI CryptoServiceTlsCtrlTrafficOut(IN VOID *Tls, IN OUT VOID *Buffer, IN UINTN BufferSize)
/* This function will attempt to read BufferSize bytes from the TLS object and places the data in Buffer. */ INTN EFIAPI CryptoServiceTlsCtrlTrafficOut(IN VOID *Tls, IN OUT VOID *Buffer, IN UINTN BufferSize)
{ return CALL_BASECRYPTLIB (Tls.Services.CtrlTrafficOut, TlsCtrlTrafficOut, (Tls, Buffer, BufferSize), 0); }
tianocore/edk2
C++
Other
4,240
/* This must be called from context that can sleep. */
void spi_unregister_master(struct spi_master *master)
/* This must be called from context that can sleep. */ void spi_unregister_master(struct spi_master *master)
{ int dummy; dummy = device_for_each_child(master->dev.parent, &master->dev, __unregister); device_unregister(&master->dev); }
robutest/uclinux
C++
GPL-2.0
60
/* Adjusts the Internal High Speed oscillator (HSI) calibration value. */
void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue)
/* Adjusts the Internal High Speed oscillator (HSI) calibration value. */ void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue)
{ uint32_t tmpreg = 0; assert_param(IS_RCC_HSI_CALIBRATION_VALUE(HSICalibrationValue)); tmpreg = RCC->ICSCR; tmpreg &= ~RCC_ICSCR_HSITRIM; tmpreg |= (uint32_t)HSICalibrationValue << 8; RCC->ICSCR = tmpreg; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* This function only produces the offset where the new clusters should be written. It updates BDRVQEDState but does not make any changes to the image file. */
static uint64_t qed_alloc_clusters(BDRVQEDState *s, unsigned int n)
/* This function only produces the offset where the new clusters should be written. It updates BDRVQEDState but does not make any changes to the image file. */ static uint64_t qed_alloc_clusters(BDRVQEDState *s, unsigned int n)
{ uint64_t offset = s->file_size; s->file_size += n * s->header.cluster_size; return offset; }
ve3wwg/teensy3_qemu
C++
Other
15
/* If the conversion results in an overflow or an underflow condition, then Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUint32ToInt32(IN UINT32 Operand, OUT INT32 *Result)
/* If the conversion results in an overflow or an underflow condition, then Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeUint32ToInt32(IN UINT32 Operand, OUT INT32 *Result)
{ RETURN_STATUS Status; if (Result == NULL) { return RETURN_INVALID_PARAMETER; } if (Operand <= MAX_INT32) { *Result = (INT32)Operand; Status = RETURN_SUCCESS; } else { *Result = INT32_ERROR; Status = RETURN_BUFFER_TOO_SMALL; } return Status; }
tianocore/edk2
C++
Other
4,240
/* MTP_build_data_ObjInfo Copy the MTP_ObjectInfo dataset to the payload data. */
static uint32_t MTP_build_data_ObjInfo(USBD_HandleTypeDef *pdev, MTP_ObjectInfoTypeDef objinfo)
/* MTP_build_data_ObjInfo Copy the MTP_ObjectInfo dataset to the payload data. */ static uint32_t MTP_build_data_ObjInfo(USBD_HandleTypeDef *pdev, MTP_ObjectInfoTypeDef objinfo)
{ USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId]; uint32_t ObjInfo_len = offsetof(MTP_ObjectInfoTypeDef, Filename); (void)USBD_memcpy(hmtp->GenericContainer.data, (const uint8_t *)&objinfo, ObjInfo_len); (void)USBD_memcpy(hmtp->GenericContainer.data + ObjInfo_len, (const uint8_t *)&objinfo.Filename, objinfo.Filename_len * sizeof(uint16_t)); ObjInfo_len = ObjInfo_len + (objinfo.Filename_len * sizeof(uint16_t)); (void)USBD_memcpy(hmtp->GenericContainer.data + ObjInfo_len, (const uint8_t *)&objinfo.CaptureDate, sizeof(objinfo.CaptureDate)); ObjInfo_len = ObjInfo_len + sizeof(objinfo.CaptureDate); return ObjInfo_len; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* This code gets the current status of Variable Store. */
VARIABLE_STORE_STATUS GetVariableStoreStatus(IN VARIABLE_STORE_HEADER *VarStoreHeader)
/* This code gets the current status of Variable Store. */ VARIABLE_STORE_STATUS GetVariableStoreStatus(IN VARIABLE_STORE_HEADER *VarStoreHeader)
{ if ((CompareGuid (&VarStoreHeader->Signature, &gEfiAuthenticatedVariableGuid) || CompareGuid (&VarStoreHeader->Signature, &gEfiVariableGuid)) && (VarStoreHeader->Format == VARIABLE_STORE_FORMATTED) && (VarStoreHeader->State == VARIABLE_STORE_HEALTHY) ) { return EfiValid; } else if ((((UINT32 *)(&VarStoreHeader->Signature))[0] == 0xffffffff) && (((UINT32 *)(&VarStoreHeader->Signature))[1] == 0xffffffff) && (((UINT32 *)(&VarStoreHeader->Signature))[2] == 0xffffffff) && (((UINT32 *)(&VarStoreHeader->Signature))[3] == 0xffffffff) && (VarStoreHeader->Size == 0xffffffff) && (VarStoreHeader->Format == 0xff) && (VarStoreHeader->State == 0xff) ) { return EfiRaw; } else { return EfiInvalid; } }
tianocore/edk2
C++
Other
4,240
/* Put sensor in standby mode. This function places the KXTF9 device in standby mode. This can be done to save power, or to allow modification of various control registers. This function will return the value of the CTRL_REG1 register prior to entering standby mode, so that it can be restored. */
static uint8_t kxtf9_standby(sensor_hal_t *hal)
/* Put sensor in standby mode. This function places the KXTF9 device in standby mode. This can be done to save power, or to allow modification of various control registers. This function will return the value of the CTRL_REG1 register prior to entering standby mode, so that it can be restored. */ static uint8_t kxtf9_standby(sensor_hal_t *hal)
{ uint8_t const ctrl_reg1 = sensor_bus_get(hal, KXTF9_CTRL_REG1); sensor_bus_put(hal, KXTF9_CTRL_REG1, (ctrl_reg1 & ~CTRL_REG1_PC1)); return ctrl_reg1; }
memfault/zero-to-main
C++
null
200
/* By the time we get here, we already hold the mm semaphore */
int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, unsigned int flags)
/* By the time we get here, we already hold the mm semaphore */ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, unsigned int flags)
{ pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t *pte; __set_current_state(TASK_RUNNING); count_vm_event(PGFAULT); if (unlikely(is_vm_hugetlb_page(vma))) return hugetlb_fault(mm, vma, address, flags); pgd = pgd_offset(mm, address); pud = pud_alloc(mm, pgd, address); if (!pud) return VM_FAULT_OOM; pmd = pmd_alloc(mm, pud, address); if (!pmd) return VM_FAULT_OOM; pte = pte_alloc_map(mm, pmd, address); if (!pte) return VM_FAULT_OOM; return handle_pte_fault(mm, vma, address, pte, pmd, flags); }
robutest/uclinux
C++
GPL-2.0
60
/* Disable I2C interrupt of the specified I2C port. The */
void I2CIntDisable(unsigned long ulBase)
/* Disable I2C interrupt of the specified I2C port. The */ void I2CIntDisable(unsigned long ulBase)
{ xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE)); xHWREG(ulBase + I2C_O_CON) &= ~I2C_CON_EI; xIntDisable(INT_I2C0); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Note some of the name segments from which we'll fabricate a name. */
int x509_extract_name_segment(void *context, size_t hdrlen, unsigned char tag, const void *value, size_t vlen)
/* Note some of the name segments from which we'll fabricate a name. */ int x509_extract_name_segment(void *context, size_t hdrlen, unsigned char tag, const void *value, size_t vlen)
{ struct x509_parse_context *ctx = context; switch (ctx->last_oid) { case OID_commonName: ctx->cn_size = vlen; ctx->cn_offset = (unsigned long)value - ctx->data; break; case OID_organizationName: ctx->o_size = vlen; ctx->o_offset = (unsigned long)value - ctx->data; break; case OID_email_address: ctx->email_size = vlen; ctx->email_offset = (unsigned long)value - ctx->data; break; default: break; } return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Note, the delays are in there as a caution to ensure that the reset has time to take effect and then complete. Since the datasheet does not currently specify the exact sequence, we have chosen something that seems to work with our device. */
static void ks8851_soft_reset(struct ks8851_net *ks, unsigned op)
/* Note, the delays are in there as a caution to ensure that the reset has time to take effect and then complete. Since the datasheet does not currently specify the exact sequence, we have chosen something that seems to work with our device. */ static void ks8851_soft_reset(struct ks8851_net *ks, unsigned op)
{ ks8851_wrreg16(ks, KS_GRR, op); mdelay(1); ks8851_wrreg16(ks, KS_GRR, 0); mdelay(1); }
robutest/uclinux
C++
GPL-2.0
60
/* Internal Function:Poll for status of interrupt received by the PHY Independent Module. */
static uint32_t lpddr4_pollphyindepirq(const lpddr4_privatedata *pd, lpddr4_phyindepinterrupt irqbit, uint32_t delay)
/* Internal Function:Poll for status of interrupt received by the PHY Independent Module. */ static uint32_t lpddr4_pollphyindepirq(const lpddr4_privatedata *pd, lpddr4_phyindepinterrupt irqbit, uint32_t delay)
{ uint32_t result = 0U; uint32_t timeout = 0U; bool irqstatus = false; do { if (++timeout == delay) { result = EIO; break; } result = lpddr4_checkphyindepinterrupt(pd, irqbit, &irqstatus); } while ((irqstatus == false) && (result == (uint32_t) CDN_EOK)); return result; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Initialize RTC Interface. 1. Initializes the resources needed for the RTC interface 2.registers event callback function. */
rtc_handle_t csi_rtc_initialize(int32_t idx, rtc_event_cb_t cb_event)
/* Initialize RTC Interface. 1. Initializes the resources needed for the RTC interface 2.registers event callback function. */ rtc_handle_t csi_rtc_initialize(int32_t idx, rtc_event_cb_t cb_event)
{ if (idx < 0 || idx >= CONFIG_RTC_NUM) { return NULL; } int32_t real_idx; uint32_t base = 0u; uint32_t irq; real_idx = target_get_rtc(idx, &base, &irq); if (real_idx != idx) { return NULL; } ck_rtc_priv_t *rtc_priv; rtc_priv = &rtc_instance[idx]; rtc_priv->base = base; rtc_priv->irq = irq; ck_rtc_reg_t *addr = (ck_rtc_reg_t *)(rtc_priv->base); rtc_priv->cb_event = cb_event; addr->RTC_CCR = 0; drv_nvic_enable_irq(rtc_priv->irq); return (rtc_handle_t)rtc_priv; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return the current configuration variable address. Input : Length - How many bytes are needed. */
uint8_t* Standard_GetConfiguration(uint16_t Length)
/* Return the current configuration variable address. Input : Length - How many bytes are needed. */ uint8_t* Standard_GetConfiguration(uint16_t Length)
{ if (Length == 0) { pInformation->Ctrl_Info.Usb_wLength = sizeof(pInformation->CurrentConfiguration); return 0; } pUser_Standard_Requests->User_GetConfiguration(); return (uint8_t*)&pInformation->CurrentConfiguration; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Command response callback function for sd_ble_tx_packet_count_get BLE command. Callback for decoding the output parameters and the command response return code. */
static uint32_t tx_packet_count_get_rsp_dec(const uint8_t *p_buffer, uint16_t length)
/* Command response callback function for sd_ble_tx_packet_count_get BLE command. Callback for decoding the output parameters and the command response return code. */ static uint32_t tx_packet_count_get_rsp_dec(const uint8_t *p_buffer, uint16_t length)
{ uint32_t result_code; const uint32_t err_code = ble_tx_packet_count_get_rsp_dec(p_buffer, length, (uint8_t * *)&mp_out_params[0], &result_code); APP_ERROR_CHECK(err_code); return result_code; }
labapart/polymcu
C++
null
201
/* regulator_set_drvdata - set regulator driver data @regulator: regulator @data: data */
void regulator_set_drvdata(struct regulator *regulator, void *data)
/* regulator_set_drvdata - set regulator driver data @regulator: regulator @data: data */ void regulator_set_drvdata(struct regulator *regulator, void *data)
{ regulator->rdev->reg_data = data; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Initialize the DMA Channel for a multiple buffer transfer. */
void dmac_channel_multi_buf_transfer_init(Dmac *p_dmac, uint32_t ul_num, dma_transfer_descriptor_t *p_desc)
/* Initialize the DMA Channel for a multiple buffer transfer. */ void dmac_channel_multi_buf_transfer_init(Dmac *p_dmac, uint32_t ul_num, dma_transfer_descriptor_t *p_desc)
{ Assert(p_dmac); Assert(ul_num<=3); Assert(p_desc); p_dmac->DMAC_EBCISR; dmac_channel_set_descriptor_addr(p_dmac, ul_num, (uint32_t)p_desc); dmac_channel_set_ctrlB(p_dmac, ul_num, 0); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Callback function called by PE layer when HardReset message received from PRL. */
void USBPD_DPM_HardReset(uint8_t PortNum, USBPD_PortPowerRole_TypeDef CurrentRole, USBPD_HR_Status_TypeDef Status)
/* Callback function called by PE layer when HardReset message received from PRL. */ void USBPD_DPM_HardReset(uint8_t PortNum, USBPD_PortPowerRole_TypeDef CurrentRole, USBPD_HR_Status_TypeDef Status)
{ DPM_Ports[PortNum].DPM_TimerAlert = 0; DPM_Ports[PortNum].DPM_SendAlert.d32 = 0; switch (Status) { case USBPD_HR_STATUS_START_ACK: case USBPD_HR_STATUS_START_REQ: if (USBPD_PORTPOWERROLE_SRC == CurrentRole) { DPM_AssertRp(PortNum); DPM_TurnOffPower(PortNum, USBPD_PORTPOWERROLE_SRC); } else { USBPD_PWR_IF_VBUSIsEnabled(PortNum); } break; case USBPD_HR_STATUS_COMPLETED: if (USBPD_PORTPOWERROLE_SRC == CurrentRole) { DPM_TurnOnPower(PortNum,CurrentRole); } break; default: break; } }
st-one/X-CUBE-USB-PD
C++
null
110
/* Description: Free all memory associated with dynamic quirks - called before module unload. */
static void usbhid_remove_all_dquirks(void)
/* Description: Free all memory associated with dynamic quirks - called before module unload. */ static void usbhid_remove_all_dquirks(void)
{ struct quirks_list_struct *q, *temp; down_write(&dquirks_rwsem); list_for_each_entry_safe(q, temp, &dquirks_list, node) { list_del(&q->node); kfree(q); } up_write(&dquirks_rwsem); }
robutest/uclinux
C++
GPL-2.0
60
/* This function searches for DXE capsules from the associated device and returns the number and maximum size in bytes of the capsules discovered. Entry 1 is assumed to be the highest load priority and entry N is assumed to be the lowest priority. */
EFI_STATUS EFIAPI GetNumberRecoveryCapsules(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This, OUT UINTN *NumberRecoveryCapsules)
/* This function searches for DXE capsules from the associated device and returns the number and maximum size in bytes of the capsules discovered. Entry 1 is assumed to be the highest load priority and entry N is assumed to be the lowest priority. */ EFI_STATUS EFIAPI GetNumberRecoveryCapsules(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This, OUT UINTN *NumberRecoveryCapsules)
{ PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData; PrivateData = PEI_CD_EXPRESS_PRIVATE_DATA_FROM_THIS (This); UpdateBlocksAndVolumes (PrivateData, TRUE); UpdateBlocksAndVolumes (PrivateData, FALSE); *NumberRecoveryCapsules = PrivateData->CapsuleCount; if (*NumberRecoveryCapsules == 0) { return EFI_NOT_FOUND; } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* If the filename is an absolute path, then dirname is ignored. If it is a relative path, then we look in that directory for the file. */
static char* try_open(const char *dirname, const char *fname, FILE **fp)
/* If the filename is an absolute path, then dirname is ignored. If it is a relative path, then we look in that directory for the file. */ static char* try_open(const char *dirname, const char *fname, FILE **fp)
{ char *fullname; if (!dirname || fname[0] == '/') fullname = xstrdup(fname); else fullname = join_path(dirname, fname); *fp = fopen(fullname, "rb"); if (!*fp) { free(fullname); fullname = NULL; } return fullname; }
4ms/stm32mp1-baremetal
C++
Other
137
/* The are the file operation function for user access to /dev/nvram */
static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
/* The are the file operation function for user access to /dev/nvram */ static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
{ switch (origin) { case 0: break; case 1: offset += file->f_pos; break; case 2: offset += NVRAM_BYTES; break; } return (offset >= 0) ? (file->f_pos = offset) : -EINVAL; }
robutest/uclinux
C++
GPL-2.0
60
/* This sets the name of the kobject. If you have already added the kobject to the system, you must call kobject_rename() in order to change the name of the kobject. */
int kobject_set_name(struct kobject *kobj, const char *fmt,...)
/* This sets the name of the kobject. If you have already added the kobject to the system, you must call kobject_rename() in order to change the name of the kobject. */ int kobject_set_name(struct kobject *kobj, const char *fmt,...)
{ va_list vargs; int retval; va_start(vargs, fmt); retval = kobject_set_name_vargs(kobj, fmt, vargs); va_end(vargs); return retval; }
robutest/uclinux
C++
GPL-2.0
60
/* Set the ITG-3200 low-pass filter bandwidth. Valid filter bandwidths and the associated internal sample rate are as follows: */
static bool itg3200_set_bandwidth(sensor_hal_t *hal, int16_t band)
/* Set the ITG-3200 low-pass filter bandwidth. Valid filter bandwidths and the associated internal sample rate are as follows: */ static bool itg3200_set_bandwidth(sensor_hal_t *hal, int16_t band)
{ sensor_bus_put(hal, ITG3200_DLPF_FS, FS_SEL_2000 | band_table [band].reserved_val); if ((hal->bandwidth == 256) || (band_table [band].bandwidth_Hz == 256)) { hal->bandwidth = band_table [band].bandwidth_Hz; itg3200_set_sample_rate(hal, hal->sample_rate); } return true; }
memfault/zero-to-main
C++
null
200
/* Will be called only by the device core when all users of this macio device are done. This currently means never as we don't hot remove any macio device yet, though that will happen with mediabay based devices in a later implementation. */
static void macio_release_dev(struct device *dev)
/* Will be called only by the device core when all users of this macio device are done. This currently means never as we don't hot remove any macio device yet, though that will happen with mediabay based devices in a later implementation. */ static void macio_release_dev(struct device *dev)
{ struct macio_dev *mdev; mdev = to_macio_device(dev); kfree(mdev); }
robutest/uclinux
C++
GPL-2.0
60
/* Driver done interrupt service routine for channel 7. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC */
void XDmaPs_DoneISR_7(XDmaPs *InstPtr)
/* Driver done interrupt service routine for channel 7. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC */ void XDmaPs_DoneISR_7(XDmaPs *InstPtr)
{ XDmaPs_DoneISR_n(InstPtr, 7); }
ua1arn/hftrx
C++
null
69
/* Set a new standard ID for received messages. */
void can_ctrl_set_tx_sid(struct can_ctrl_dev *dev, uint16_t new_sid)
/* Set a new standard ID for received messages. */ void can_ctrl_set_tx_sid(struct can_ctrl_dev *dev, uint16_t new_sid)
{ dev->tx_sid = new_sid; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* doesn't do a whole lot for user, but oh so cleverly written so kernel code can use it to re-up the watchdog, thereby saving the kernel from having to create and maintain a timer, just to tickle another timer, which is just so wrong. */
irqreturn_t sbwdog_interrupt(int irq, void *addr)
/* doesn't do a whole lot for user, but oh so cleverly written so kernel code can use it to re-up the watchdog, thereby saving the kernel from having to create and maintain a timer, just to tickle another timer, which is just so wrong. */ irqreturn_t sbwdog_interrupt(int irq, void *addr)
{ unsigned long wd_init; char *wd_cfg_reg = (char *)addr; u8 cfg; cfg = __raw_readb(wd_cfg_reg); wd_init = __raw_readq(wd_cfg_reg - 8) & 0x7fffff; if (wd_cfg_reg == user_dog) printk(KERN_CRIT "%s in danger of initiating system reset " "in %ld.%01ld seconds\n", ident.identity, wd_init / 1000000, (wd_init / 100000) % 10); else cfg |= 1; __raw_writeb(cfg, wd_cfg_reg); return IRQ_HANDLED; }
robutest/uclinux
C++
GPL-2.0
60
/* Compare the chip keyset and the firmware one to check compatibility. */
static sl_status_t sl_wfx_compare_keysets(uint8_t chip_keyset, char *firmware_keyset)
/* Compare the chip keyset and the firmware one to check compatibility. */ static sl_status_t sl_wfx_compare_keysets(uint8_t chip_keyset, char *firmware_keyset)
{ sl_status_t result; char keyset_string[3]; uint8_t keyset_value; keyset_string[0] = *(firmware_keyset + 6); keyset_string[1] = *(firmware_keyset + 7); keyset_string[2] = '\0'; keyset_value = (uint8_t)strtoul(keyset_string, NULL, 16); if (keyset_value == chip_keyset) { result = SL_STATUS_OK; } else { result = SL_STATUS_WIFI_INVALID_KEY; } return result; }
eclipse-threadx/getting-started
C++
Other
310
/* I2C Send Start Condition. If in Master mode this will cause a restart condition to occur at the end of the current transmission. If in Slave mode, this will initiate a start condition when the current bus activity is completed. */
void i2c_send_start(uint32_t i2c)
/* I2C Send Start Condition. If in Master mode this will cause a restart condition to occur at the end of the current transmission. If in Slave mode, this will initiate a start condition when the current bus activity is completed. */ void i2c_send_start(uint32_t i2c)
{ I2C_CR2(i2c) |= I2C_CR2_START; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Get the IIS2MDC register value for magnetic sensor. */
int32_t IIS2MDC_Read_Reg(IIS2MDC_Object_t *pObj, uint8_t Reg, uint8_t *Data)
/* Get the IIS2MDC register value for magnetic sensor. */ int32_t IIS2MDC_Read_Reg(IIS2MDC_Object_t *pObj, uint8_t Reg, uint8_t *Data)
{ if (iis2mdc_read_reg(&(pObj->Ctx), Reg, Data, 1) != IIS2MDC_OK) { return IIS2MDC_ERROR; } return IIS2MDC_OK; }
eclipse-threadx/getting-started
C++
Other
310
/* Disable the MCP interface. The MCP interface will only be disabled once the number of calls to mcp_enable matches the number of calls to mcp_disable. */
void mcp_disable(struct mcp *mcp)
/* Disable the MCP interface. The MCP interface will only be disabled once the number of calls to mcp_enable matches the number of calls to mcp_disable. */ void mcp_disable(struct mcp *mcp)
{ unsigned long flags; spin_lock_irqsave(&mcp->lock, flags); if (--mcp->use_count == 0) mcp->ops->disable(mcp); spin_unlock_irqrestore(&mcp->lock, flags); }
robutest/uclinux
C++
GPL-2.0
60
/* pci_iov_release - release resources used by the IOV capability @dev: the PCI device */
void pci_iov_release(struct pci_dev *dev)
/* pci_iov_release - release resources used by the IOV capability @dev: the PCI device */ void pci_iov_release(struct pci_dev *dev)
{ if (dev->is_physfn) sriov_release(dev); }
robutest/uclinux
C++
GPL-2.0
60
/* RTC Alarm interrupt handler. Clear the RTC interrupt flag and */
void RTCAIntHandler(void)
/* RTC Alarm interrupt handler. Clear the RTC interrupt flag and */ void RTCAIntHandler(void)
{ unsigned long ulEventFlags; ulEventFlags = (xHWREG(RTC_SR) & RTC_SR_TAF ); xHWREG(RTC_TAR) = 0x00; if(g_pfnRTCHandlerCallbacks[0] != 0) { g_pfnRTCHandlerCallbacks[0](0, 0, ulEventFlags, 0); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Returns -1 if no match found. Otherwise returns the recommended PIO mode from ide_pio_blacklist. */
int ide_scan_pio_blacklist(char *model)
/* Returns -1 if no match found. Otherwise returns the recommended PIO mode from ide_pio_blacklist. */ int ide_scan_pio_blacklist(char *model)
{ struct ide_pio_info *p; for (p = ide_pio_blacklist; p->name != NULL; p++) { if (strncmp(p->name, model, strlen(p->name)) == 0) return p->pio; } return -1; }
robutest/uclinux
C++
GPL-2.0
60
/* Convert 112.16 fixed point value to 48.16 with clamping for the out of range values. */
static force_inline pixman_fixed_48_16_t fixed_112_16_to_fixed_48_16(int64_t hi, int64_t lo, pixman_bool_t *clampflag)
/* Convert 112.16 fixed point value to 48.16 with clamping for the out of range values. */ static force_inline pixman_fixed_48_16_t fixed_112_16_to_fixed_48_16(int64_t hi, int64_t lo, pixman_bool_t *clampflag)
{ if ((lo >> 63) != hi) { *clampflag = TRUE; return hi >= 0 ? INT64_MAX : INT64_MIN; } else { return lo; } }
xboot/xboot
C++
MIT License
779
/* Add Simple Pointer Device in Consplitter Simple Pointer list. */
EFI_STATUS ConSplitterSimplePointerAddDevice(IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer)
/* Add Simple Pointer Device in Consplitter Simple Pointer list. */ EFI_STATUS ConSplitterSimplePointerAddDevice(IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer)
{ EFI_STATUS Status; if (Private->CurrentNumberOfPointers >= Private->PointerListCount) { Status = ConSplitterGrowBuffer ( sizeof (EFI_SIMPLE_POINTER_PROTOCOL *), &Private->PointerListCount, (VOID **)&Private->PointerList ); if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } } Private->PointerList[Private->CurrentNumberOfPointers] = SimplePointer; Private->CurrentNumberOfPointers++; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* param base Pointer to FLEXIO_I2S_Type structure. param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state */
void FLEXIO_I2S_TransferAbortSend(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle)
/* param base Pointer to FLEXIO_I2S_Type structure. param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state */ void FLEXIO_I2S_TransferAbortSend(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle)
{ assert(handle); FLEXIO_I2S_DisableInterrupts(base, kFLEXIO_I2S_TxDataRegEmptyInterruptEnable); handle->state = kFLEXIO_I2S_Idle; memset(handle->queue, 0, sizeof(flexio_i2s_transfer_t) * FLEXIO_I2S_XFER_QUEUE_SIZE); handle->queueDriver = 0; handle->queueUser = 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* @handle handle of the loaded image @systable system table */
static int setup(const efi_handle_t img_handle, const struct efi_system_table *systable)
/* @handle handle of the loaded image @systable system table */ static int setup(const efi_handle_t img_handle, const struct efi_system_table *systable)
{ efi_status_t ret; boottime = systable->boottime; ret = boottime->install_protocol_interface( &handle_controller, &guid_controller, EFI_NATIVE_INTERFACE, &interface1); if (ret != EFI_SUCCESS) { efi_st_error("InstallProtocolInterface failed\n"); return EFI_ST_FAILURE; } ret = boottime->install_protocol_interface( &handle_driver, &guid_driver_binding_protocol, EFI_NATIVE_INTERFACE, &binding_interface); if (ret != EFI_SUCCESS) { efi_st_error("InstallProtocolInterface failed\n"); return EFI_ST_FAILURE; } return EFI_ST_SUCCESS; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Echoes characters received from CLI. Implements CLI feedback. */
int32_t cn0415_parse(struct cn0415_dev *dev)
/* Echoes characters received from CLI. Implements CLI feedback. */ int32_t cn0415_parse(struct cn0415_dev *dev)
{ int32_t ret; uint8_t c = 0, rdy = 1; ret = usr_uart_read_nb(dev->aducm3029_uart_desc, &c, &rdy); if(ret != 0) return ret; if(rdy == 1) { switch(c) { case _LF: case _CR: uart_cmd = UART_TRUE; break; case _BS: if(uart_line_index == 0) break; uart_line_index--; break; case _NC: break; default: uart_current_line[uart_line_index++] = c; if(uart_line_index == 256) { uart_line_index--; } } uart_current_line[uart_line_index] = '\0'; } return ret; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Check if global point is inside window. This function checks if point given in global coordinates is inside a given window. */
bool win_is_inside_window(const struct win_window *win, const struct win_point *point)
/* Check if global point is inside window. This function checks if point given in global coordinates is inside a given window. */ bool win_is_inside_window(const struct win_window *win, const struct win_point *point)
{ struct win_clip_region clip; win_compute_clipping(win, &win->attributes.area, &clip); return win_is_inside_clip(&clip, point); }
memfault/zero-to-main
C++
null
200
/* SYSCTRL I2C0 Bus Clock Disable and Reset Assert. */
void LL_SYSCTRL_I2C0_ClkDisRstAssert(void)
/* SYSCTRL I2C0 Bus Clock Disable and Reset Assert. */ void LL_SYSCTRL_I2C0_ClkDisRstAssert(void)
{ __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); __LL_SYSCTRL_I2C0BusClk_Dis(SYSCTRL); __LL_SYSCTRL_I2C0SoftRst_Assert(SYSCTRL); __LL_SYSCTRL_Reg_Lock(SYSCTRL); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Write a value to the specified pin(s). Write the corresponding bit values to the output pin(s) specified by */
void xGPIOPinWrite(unsigned long ulPort, unsigned long ulPins, unsigned long ucVal)
/* Write a value to the specified pin(s). Write the corresponding bit values to the output pin(s) specified by */ void xGPIOPinWrite(unsigned long ulPort, unsigned long ulPins, unsigned long ucVal)
{ GPIOPinWrite(ulPort, ulPins,ucVal); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* returns SUCCESS if it successfully received a message notification */
static s32 igb_poll_for_msg(struct e1000_hw *hw, u16 mbx_id)
/* returns SUCCESS if it successfully received a message notification */ static s32 igb_poll_for_msg(struct e1000_hw *hw, u16 mbx_id)
{ struct e1000_mbx_info *mbx = &hw->mbx; int countdown = mbx->timeout; if (!countdown || !mbx->ops.check_for_msg) goto out; while (countdown && mbx->ops.check_for_msg(hw, mbx_id)) { countdown--; if (!countdown) break; udelay(mbx->usec_delay); } if (!countdown) mbx->timeout = 0; out: return countdown ? 0 : -E1000_ERR_MBX; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns the clock source used as system clock. */
uint8_t RCC_GetSYSCLKSource(void)
/* Returns the clock source used as system clock. */ uint8_t RCC_GetSYSCLKSource(void)
{ return ((uint8_t)(RCC->CFGR & RCC_CFGR_SWS)); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* PCD MSP Initialization This function configures the hardware resources used in this example. */
void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
/* PCD MSP Initialization This function configures the hardware resources used in this example. */ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; if(hpcd->Instance==USB_OTG_FS) { __HAL_RCC_GPIOA_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); HAL_NVIC_SetPriority(OTG_FS_IRQn, 0, 0); HAL_NVIC_EnableIRQ(OTG_FS_IRQn); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* param base The LPI2C peripheral base address. param matchConfig Settings for the data match feature. */
void LPI2C_MasterConfigureDataMatch(LPI2C_Type *base, const lpi2c_data_match_config_t *matchConfig)
/* param base The LPI2C peripheral base address. param matchConfig Settings for the data match feature. */ void LPI2C_MasterConfigureDataMatch(LPI2C_Type *base, const lpi2c_data_match_config_t *matchConfig)
{ bool wasEnabled = (0U != ((base->MCR & LPI2C_MCR_MEN_MASK) >> LPI2C_MCR_MEN_SHIFT)); LPI2C_MasterEnable(base, false); base->MCFGR1 = (base->MCFGR1 & ~LPI2C_MCFGR1_MATCFG_MASK) | LPI2C_MCFGR1_MATCFG(matchConfig->matchMode); base->MCFGR0 = (base->MCFGR0 & ~LPI2C_MCFGR0_RDMO_MASK) | LPI2C_MCFGR0_RDMO(matchConfig->rxDataMatchOnly); base->MDMR = LPI2C_MDMR_MATCH0(matchConfig->match0) | LPI2C_MDMR_MATCH1(matchConfig->match1); if (wasEnabled) { LPI2C_MasterEnable(base, true); } }
eclipse-threadx/getting-started
C++
Other
310
/* Registers a callback. Registers a callback function which is implemented by the user. */
void sdadc_register_callback(struct sdadc_module *const module, sdadc_callback_t callback_func, enum sdadc_callback callback_type)
/* Registers a callback. Registers a callback function which is implemented by the user. */ void sdadc_register_callback(struct sdadc_module *const module, sdadc_callback_t callback_func, enum sdadc_callback callback_type)
{ Assert(module); Assert(callback_func); module->callback[callback_type] = callback_func; module->registered_callback_mask |= (1 << callback_type); }
memfault/zero-to-main
C++
null
200
/* Reset a non-running (STS_HALT == 1) controller. Must be called with interrupts enabled and the lock not held. */
int ehci_reset(struct ehci_hcd *ehci)
/* Reset a non-running (STS_HALT == 1) controller. Must be called with interrupts enabled and the lock not held. */ int ehci_reset(struct ehci_hcd *ehci)
{ int retval; u32 command = ehci_readl(ehci, &ehci->regs->command); command |= CMD_RESET; ehci_writel(ehci, command, &ehci->regs->command); ehci->rh_state = EHCI_RH_HALTED; retval = ehci_handshake(ehci, &ehci->regs->command, CMD_RESET, 0, 250 * 1000); if (ehci->has_hostpc) { ehci_writel(ehci, USBMODE_EX_HC | USBMODE_EX_VBPS, &ehci->regs->usbmode_ex); ehci_writel(ehci, TXFIFO_DEFAULT, &ehci->regs->txfill_tuning); } if (retval) return retval; ehci->port_c_suspend = ehci->suspended_ports = ehci->resuming_ports = 0; return retval; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set Click time limit value. you can use this function to set click time limit value. */
Result LIS302DLClickTimeLimitSet(uint8_t TimeLimit)
/* Set Click time limit value. you can use this function to set click time limit value. */ Result LIS302DLClickTimeLimitSet(uint8_t TimeLimit)
{ Result retv = SUCCESS; retv = LIS302DLRegWriteByte(CLICK_TiMELIMIT, TimeLimit); if(retv != SUCCESS) { return (FAILURE); } return (SUCCESS); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Returns the last conversion result data for regular channel of SDADC1 and SDADC2. RSYNC bit of the SDADC2 should be already set. */
uint32_t SDADC_GetConversionSDADC12Value(void)
/* Returns the last conversion result data for regular channel of SDADC1 and SDADC2. RSYNC bit of the SDADC2 should be already set. */ uint32_t SDADC_GetConversionSDADC12Value(void)
{ return (uint32_t) SDADC1->RDATA12R; }
avem-labs/Avem
C++
MIT License
1,752
/* This function may be called - with care - from IRQ context. */
void disable_irq(unsigned int irq)
/* This function may be called - with care - from IRQ context. */ void disable_irq(unsigned int irq)
{ struct irq_desc *desc = irq_to_desc(irq); if (!desc) return; disable_irq_nosync(irq); if (desc->action) synchronize_irq(irq); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* If the device supports DT mode, then it must be PPR capable. The PPR message will be used in place of the SDTR and WDTR messages to negotiate synchronous speed and offset, transfer width, and protocol options. */
static void advansys_wide_enable_ppr(ADV_DVC_VAR *adv_dvc, AdvPortAddr iop_base, unsigned short tidmask)
/* If the device supports DT mode, then it must be PPR capable. The PPR message will be used in place of the SDTR and WDTR messages to negotiate synchronous speed and offset, transfer width, and protocol options. */ static void advansys_wide_enable_ppr(ADV_DVC_VAR *adv_dvc, AdvPortAddr iop_base, unsigned short tidmask)
{ AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able); adv_dvc->ppr_able |= tidmask; AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able); }
robutest/uclinux
C++
GPL-2.0
60
/* hmatrix_sfr_set_bits - set bits in a slave's Special Function Register @slave_id: operate on the SFR belonging to this slave @mask: mask of bits to be set in the SFR */
void hmatrix_sfr_set_bits(unsigned int slave_id, u32 mask)
/* hmatrix_sfr_set_bits - set bits in a slave's Special Function Register @slave_id: operate on the SFR belonging to this slave @mask: mask of bits to be set in the SFR */ void hmatrix_sfr_set_bits(unsigned int slave_id, u32 mask)
{ u32 value; clk_enable(&at32_hmatrix_clk); value = __hmatrix_read_reg(HMATRIX_SFR(slave_id)); value |= mask; __hmatrix_write_reg(HMATRIX_SFR(slave_id), value); __hmatrix_read_reg(HMATRIX_SFR(slave_id)); clk_disable(&at32_hmatrix_clk); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Drives the sleep status instead of sleep change on INT pins (only if INT1_SLEEP_CHANGE or INT2_SLEEP_CHANGE bits are enabled).. */
int32_t lsm6dso_act_pin_notification_get(stmdev_ctx_t *ctx, lsm6dso_sleep_status_on_int_t *val)
/* Drives the sleep status instead of sleep change on INT pins (only if INT1_SLEEP_CHANGE or INT2_SLEEP_CHANGE bits are enabled).. */ int32_t lsm6dso_act_pin_notification_get(stmdev_ctx_t *ctx, lsm6dso_sleep_status_on_int_t *val)
{ lsm6dso_tap_cfg0_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)&reg, 1); switch (reg.sleep_status_on_int) { case LSM6DSO_DRIVE_SLEEP_CHG_EVENT: *val = LSM6DSO_DRIVE_SLEEP_CHG_EVENT; break; case LSM6DSO_DRIVE_SLEEP_STATUS: *val = LSM6DSO_DRIVE_SLEEP_STATUS; break; default: *val = LSM6DSO_DRIVE_SLEEP_CHG_EVENT; break; } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Clear out all data in the circular buffer. */
static void serial_buf_clear(struct circ_buf *cb)
/* Clear out all data in the circular buffer. */ static void serial_buf_clear(struct circ_buf *cb)
{ cb->head = cb->tail = 0; }
robutest/uclinux
C++
GPL-2.0
60
/* klist_add_after - Init a klist_node and add it after an existing node */
void klist_add_after(struct klist_node *n, struct klist_node *pos)
/* klist_add_after - Init a klist_node and add it after an existing node */ void klist_add_after(struct klist_node *n, struct klist_node *pos)
{ struct klist *k = knode_klist(pos); klist_node_init(k, n); spin_lock(&k->k_lock); list_add(&n->n_node, &pos->n_node); spin_unlock(&k->k_lock); }
robutest/uclinux
C++
GPL-2.0
60
/* ZigBee ZCL Thermostat User Interface Configuration cluster dissector for wireshark. */
static int dissect_zbee_zcl_thermostat_ui_config(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_)
/* ZigBee ZCL Thermostat User Interface Configuration cluster dissector for wireshark. */ static int dissect_zbee_zcl_thermostat_ui_config(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_)
{ return tvb_captured_length(tvb); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Create a Label node in the boot script table. */
RETURN_STATUS EFIAPI S3BootScriptLabelInternal(IN BOOLEAN BeforeOrAfter, IN OUT VOID **Position OPTIONAL, IN UINT32 InformationLength, IN CONST CHAR8 *Information)
/* Create a Label node in the boot script table. */ RETURN_STATUS EFIAPI S3BootScriptLabelInternal(IN BOOLEAN BeforeOrAfter, IN OUT VOID **Position OPTIONAL, IN UINT32 InformationLength, IN CONST CHAR8 *Information)
{ UINT8 Length; UINT8 *Script; EFI_BOOT_SCRIPT_INFORMATION ScriptInformation; if (!mS3BootScriptAcpiS3Enable) { return RETURN_SUCCESS; } if (InformationLength > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_INFORMATION)) { return RETURN_OUT_OF_RESOURCES; } Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_INFORMATION) + InformationLength); Script = S3BootScriptGetEntryAddAddress (Length); if (Script == NULL) { return RETURN_OUT_OF_RESOURCES; } ScriptInformation.OpCode = S3_BOOT_SCRIPT_LIB_LABEL_OPCODE; ScriptInformation.Length = Length; ScriptInformation.InformationLength = InformationLength; CopyMem ((VOID *)Script, (VOID *)&ScriptInformation, sizeof (EFI_BOOT_SCRIPT_INFORMATION)); CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION)), (VOID *)Information, (UINTN)InformationLength); SyncBootScript (Script); return S3BootScriptMoveLastOpcode (BeforeOrAfter, Position); }
tianocore/edk2
C++
Other
4,240
/* Signals the event. Queues the event to be notified if needed. */
EFI_STATUS EFIAPI CoreSignalEvent(IN EFI_EVENT UserEvent)
/* Signals the event. Queues the event to be notified if needed. */ EFI_STATUS EFIAPI CoreSignalEvent(IN EFI_EVENT UserEvent)
{ IEVENT *Event; Event = UserEvent; if (Event == NULL) { return EFI_INVALID_PARAMETER; } if (Event->Signature != EVENT_SIGNATURE) { return EFI_INVALID_PARAMETER; } CoreAcquireEventLock (); if (Event->SignalCount == 0x00000000) { Event->SignalCount++; if ((Event->Type & EVT_NOTIFY_SIGNAL) != 0) { if ((Event->ExFlag & EVT_EXFLAG_EVENT_GROUP) != 0) { CoreReleaseEventLock (); CoreNotifySignalList (&Event->EventGroup); CoreAcquireEventLock (); } else { CoreNotifyEvent (Event); } } } CoreReleaseEventLock (); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Checks whether the specified ADC flag is set or not. */
FlagStatus ADC_GetFlagStatus(ADC_TypeDef *ADCx, uint8_t ADC_FLAG)
/* Checks whether the specified ADC flag is set or not. */ FlagStatus ADC_GetFlagStatus(ADC_TypeDef *ADCx, uint8_t ADC_FLAG)
{ FlagStatus bitstatus = RESET; assert_param(IS_ADC_ALL_PERIPH(ADCx)); assert_param(IS_ADC_GET_FLAG(ADC_FLAG)); if ((ADCx->ADSTA & ADC_FLAG) != (uint8_t)RESET) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Decrement the use_count of the last object required, if any. */
static void kmemleak_seq_stop(struct seq_file *seq, void *v)
/* Decrement the use_count of the last object required, if any. */ static void kmemleak_seq_stop(struct seq_file *seq, void *v)
{ if (!IS_ERR(v)) { rcu_read_unlock(); mutex_unlock(&scan_mutex); if (v) put_object(v); } }
robutest/uclinux
C++
GPL-2.0
60
/* Minimum threshold to detect a peak. Default is 10h.. */
int32_t lsm6dsl_pedo_threshold_set(stmdev_ctx_t *ctx, uint8_t val)
/* Minimum threshold to detect a peak. Default is 10h.. */ int32_t lsm6dsl_pedo_threshold_set(stmdev_ctx_t *ctx, uint8_t val)
{ lsm6dsl_config_pedo_ths_min_t config_pedo_ths_min; int32_t ret; ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); if(ret == 0){ ret = lsm6dsl_read_reg(ctx, LSM6DSL_CONFIG_PEDO_THS_MIN, (uint8_t*)&config_pedo_ths_min, 1); if(ret == 0){ config_pedo_ths_min.ths_min = val; ret = lsm6dsl_write_reg(ctx, LSM6DSL_CONFIG_PEDO_THS_MIN, (uint8_t*)&config_pedo_ths_min, 1); if(ret == 0){ ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); } } } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* set the percentage of blocks at which to stop allocating */
static int cachefiles_daemon_bstop(struct cachefiles_cache *, char *)
/* set the percentage of blocks at which to stop allocating */ static int cachefiles_daemon_bstop(struct cachefiles_cache *, char *)
{ unsigned long bstop; _enter(",%s", args); if (!*args) return -EINVAL; bstop = simple_strtoul(args, &args, 10); if (args[0] != '%' || args[1] != '\0') return -EINVAL; if (bstop < 0 || bstop >= cache->bcull_percent) return cachefiles_daemon_range_error(cache, args); cache->bstop_percent = bstop; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* If DriverBinding is NULL, then ASSERT(). If DriverBinding can not be uninstalled, then ASSERT(). */
EFI_STATUS EFIAPI EfiLibUninstallDriverBinding(IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding)
/* If DriverBinding is NULL, then ASSERT(). If DriverBinding can not be uninstalled, then ASSERT(). */ EFI_STATUS EFIAPI EfiLibUninstallDriverBinding(IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding)
{ EFI_STATUS Status; ASSERT (DriverBinding != NULL); Status = gBS->UninstallMultipleProtocolInterfaces ( DriverBinding->DriverBindingHandle, &gEfiDriverBindingProtocolGuid, DriverBinding, NULL ); ASSERT_EFI_ERROR (Status); return Status; }
tianocore/edk2
C++
Other
4,240
/* mux the pin to the "C" internal peripheral role. */
int at91_pio3_set_c_periph(unsigned port, unsigned pin, int use_pullup)
/* mux the pin to the "C" internal peripheral role. */ int at91_pio3_set_c_periph(unsigned port, unsigned pin, int use_pullup)
{ struct at91_port *at91_port = at91_pio_get_port(port); u32 mask; if (at91_port && (pin < GPIO_PER_BANK)) { mask = 1 << pin; writel(mask, &at91_port->idr); at91_set_pio_pullup(port, pin, use_pullup); writel(readl(&at91_port->mux.pio3.abcdsr1) & ~mask, &at91_port->mux.pio3.abcdsr1); writel(readl(&at91_port->mux.pio3.abcdsr2) | mask, &at91_port->mux.pio3.abcdsr2); writel(mask, &at91_port->pdr); } return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* It may be assumed that this function implies a write memory barrier before changing the task state if and only if any tasks are woken up. */
void complete(struct completion *x)
/* It may be assumed that this function implies a write memory barrier before changing the task state if and only if any tasks are woken up. */ void complete(struct completion *x)
{ unsigned long flags; spin_lock_irqsave(&x->wait.lock, flags); x->done++; __wake_up_common(&x->wait, TASK_NORMAL, 1, 0, NULL); spin_unlock_irqrestore(&x->wait.lock, flags); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns #CRDeclaration at position itemnr, if itemnr > number of declarations - 1, it will return NULL. */
CRDeclaration* cr_declaration_get_from_list(CRDeclaration *a_this, int itemnr)
/* Returns #CRDeclaration at position itemnr, if itemnr > number of declarations - 1, it will return NULL. */ CRDeclaration* cr_declaration_get_from_list(CRDeclaration *a_this, int itemnr)
{ CRDeclaration *cur = NULL; int nr = 0; g_return_val_if_fail (a_this, NULL); for (cur = a_this; cur; cur = cur->next) if (nr++ == itemnr) return cur; return NULL; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Returns 0 if the exception was handled successfully, 1 otherwise. */
int __kprobes kprobe_handle_illslot(unsigned long pc)
/* Returns 0 if the exception was handled successfully, 1 otherwise. */ int __kprobes kprobe_handle_illslot(unsigned long pc)
{ struct kprobe *p = get_kprobe((kprobe_opcode_t *) pc + 1); if (p != NULL) { printk("Warning: removing kprobe from delay slot: 0x%.8x\n", (unsigned int)pc + 2); unregister_kprobe(p); return 0; } return 1; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Init interrupts callback for the specified UART Port. */
void xUARTIntCallbackInit(unsigned long ulBase, xtEventCallback xtUARTCallback)
/* Init interrupts callback for the specified UART Port. */ void xUARTIntCallbackInit(unsigned long ulBase, xtEventCallback xtUARTCallback)
{ xASSERT(UARTBaseValid(ulBase)); if (ulBase == UART0_BASE) { g_pfnUARTHandlerCallbacks[0] = xtUARTCallback; } else if (ulBase == UART1_BASE) { g_pfnUARTHandlerCallbacks[1] = xtUARTCallback; } else { g_pfnUARTHandlerCallbacks[2] = xtUARTCallback; } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* nr_of_pages counts pages of size (1 << pageshift). */
static int sddr09_read20(struct us_data *us, unsigned long fromaddress, int nr_of_pages, int pageshift, unsigned char *buf, int use_sg)
/* nr_of_pages counts pages of size (1 << pageshift). */ static int sddr09_read20(struct us_data *us, unsigned long fromaddress, int nr_of_pages, int pageshift, unsigned char *buf, int use_sg)
{ int bulklen = nr_of_pages << pageshift; return sddr09_readX(us, 0, fromaddress, nr_of_pages, bulklen, buf, use_sg); }
robutest/uclinux
C++
GPL-2.0
60
/* Setup CAAM interrupt. It enables or disables the related HW module interrupt, and attached the related sub-routine into the vector table. */
void caam_setup_interrupt(uint32_t irq_id, uint8_t state)
/* Setup CAAM interrupt. It enables or disables the related HW module interrupt, and attached the related sub-routine into the vector table. */ void caam_setup_interrupt(uint32_t irq_id, uint8_t state)
{ if (state == TRUE) { register_interrupt_routine(irq_id, &caam_interrupt_routine); enable_interrupt(irq_id, CPU_0, 0); } else disable_interrupt(irq_id, CPU_0); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Move all unreachable objects (or 'all' objects) that need finalization from list 'finobj' to list 'tobefnz' (to be finalized). (Note that objects after 'finobjold1' cannot be white, so they don't need to be traversed. In incremental mode, 'finobjold1' is NULL, so the whole list is traversed.) */
static void separatetobefnz(global_State *g, int all)
/* Move all unreachable objects (or 'all' objects) that need finalization from list 'finobj' to list 'tobefnz' (to be finalized). (Note that objects after 'finobjold1' cannot be white, so they don't need to be traversed. In incremental mode, 'finobjold1' is NULL, so the whole list is traversed.) */ static void separatetobefnz(global_State *g, int all)
{ lua_assert(tofinalize(curr)); if (!(iswhite(curr) || all)) p = &curr->next; else { if (curr == g->finobjsur) g->finobjsur = curr->next; *p = curr->next; curr->next = *lastnext; *lastnext = curr; lastnext = &curr->next; } } }
Nicholas3388/LuaNode
C++
Other
1,055
/* Disable the ADC. Use this function to disable the ADC. */
void am_hal_adc_disable(void)
/* Disable the ADC. Use this function to disable the ADC. */ void am_hal_adc_disable(void)
{ AM_BFW(ADC, CFG, ADCEN, 0x0); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Reads relative humidity and temperature from a Si7013 sensor. */
int32_t Si7013_ReadNoHoldRHAndTemp(I2C_TypeDef *i2c, uint8_t addr, uint32_t *rhData, int32_t *tData)
/* Reads relative humidity and temperature from a Si7013 sensor. */ int32_t Si7013_ReadNoHoldRHAndTemp(I2C_TypeDef *i2c, uint8_t addr, uint32_t *rhData, int32_t *tData)
{ int ret = Si7013_ReadNoHoldData(i2c, addr, rhData); if (ret == 2) { *rhData = (((*rhData) * 15625L) >> 13) - 6000; } else { return -1; } ret = Si7013_Measure(i2c, addr, (uint32_t *) tData, SI7013_READ_TEMP); if (ret == 2) { *tData = (((*tData) * 21965L) >> 13) - 46850; } else { return -1; } return 0; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Output the firmware version we got during initialization. */
void ethernut5_print_version(void)
/* Output the firmware version we got during initialization. */ void ethernut5_print_version(void)
{ printf("%u.%u\n", pwrman_major, pwrman_minor); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Set a pending interrupt bit in the NVIC (Software Interrupt) */
void am_hal_interrupt_pend_set(uint32_t ui32Interrupt)
/* Set a pending interrupt bit in the NVIC (Software Interrupt) */ void am_hal_interrupt_pend_set(uint32_t ui32Interrupt)
{ if ( ui32Interrupt > AM_HAL_INTERRUPT_MAX ) { return; } if ( ui32Interrupt > 15 ) { AM_REG(NVIC, ISPR0) = 0x1 << ((ui32Interrupt - 16) & 0x1F); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Determines the flash sector the address is in. */
static blt_int8u FlashGetSector(blt_addr address)
/* Determines the flash sector the address is in. */ static blt_int8u FlashGetSector(blt_addr address)
{ blt_int8u result = FLASH_INVALID_SECTOR; blt_int8u sectorIdx; for (sectorIdx = 0; sectorIdx < FLASH_TOTAL_SECTORS; sectorIdx++) { CopService(); if ((address >= flashLayout[sectorIdx].sector_start) && \ (address < (flashLayout[sectorIdx].sector_start + \ flashLayout[sectorIdx].sector_size))) { result = flashLayout[sectorIdx].sector_num; break; } } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Configures the PLL clock source and DM DN factor. This function must be used only when the PLL is disabled. */
void RCC_PLLDMDNConfig(uint32_t RCC_PLLSource, uint32_t RCC_PLLDN, uint32_t RCC_PLLDP, uint32_t RCC_PLLDM)
/* Configures the PLL clock source and DM DN factor. This function must be used only when the PLL is disabled. */ void RCC_PLLDMDNConfig(uint32_t RCC_PLLSource, uint32_t RCC_PLLDN, uint32_t RCC_PLLDP, uint32_t RCC_PLLDM)
{ uint32_t tmpreg0 = 0; assert_param(IS_RCC_PLL_SOURCE(RCC_PLLSource)); assert_param(IS_RCC_PLL_MUL(RCC_PLLMul)); if(RCC_PLLSource == 0) { tmpreg0 &= ~(1<<22); } else { TK499_PLL_FACTOR |= 0x10000; tmpreg0 |= (1<<22); } RCC_PLLDN &= 0x7f; RCC_PLLDP &= 0x3; RCC_PLLDM &= 0xf; tmpreg0 |= (u32)((u32)(RCC_PLLDN<<6))|((u32)(RCC_PLLDP<<4))|((u32)RCC_PLLDM); RCC->PLLCFGR = tmpreg0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns the most recent received data by the I2Cx peripheral. */
uint8_t I2C_ReceiveData(I2C_TypeDef *I2Cx)
/* Returns the most recent received data by the I2Cx peripheral. */ uint8_t I2C_ReceiveData(I2C_TypeDef *I2Cx)
{ assert_param(IS_I2C_ALL_PERIPH(I2Cx)); I2C_CMD_DIR= 0; return (uint8_t)I2Cx->IC_DATA_CMD; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set codec volume by controlling mon DAC channel dvol gain. */
void CODEC_SetVolume(u8 vol_lch, u8 vol_rch)
/* Set codec volume by controlling mon DAC channel dvol gain. */ void CODEC_SetVolume(u8 vol_lch, u8 vol_rch)
{ u32 reg_value = 0; reg_value = AUDIO_SI_ReadReg(DAC_L_CTRL); reg_value &= ~0xff; reg_value |= vol_lch; AUDIO_SI_WriteReg(DAC_L_CTRL, reg_value); reg_value = AUDIO_SI_ReadReg(DAC_R_CTRL); reg_value &= ~0xff; reg_value |= vol_rch; AUDIO_SI_WriteReg(DAC_R_CTRL, reg_value); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Refer to EMMC Electrical Standard Spec 5.1 Section 6.10.4 for details. */
EFI_STATUS EmmcPeimSelect(IN EMMC_PEIM_HC_SLOT *Slot, IN UINT32 Rca)
/* Refer to EMMC Electrical Standard Spec 5.1 Section 6.10.4 for details. */ EFI_STATUS EmmcPeimSelect(IN EMMC_PEIM_HC_SLOT *Slot, IN UINT32 Rca)
{ EMMC_COMMAND_BLOCK EmmcCmdBlk; EMMC_STATUS_BLOCK EmmcStatusBlk; EMMC_COMMAND_PACKET Packet; EFI_STATUS Status; ZeroMem (&EmmcCmdBlk, sizeof (EmmcCmdBlk)); ZeroMem (&EmmcStatusBlk, sizeof (EmmcStatusBlk)); ZeroMem (&Packet, sizeof (Packet)); Packet.EmmcCmdBlk = &EmmcCmdBlk; Packet.EmmcStatusBlk = &EmmcStatusBlk; Packet.Timeout = EMMC_TIMEOUT; EmmcCmdBlk.CommandIndex = EMMC_SELECT_DESELECT_CARD; EmmcCmdBlk.CommandType = EmmcCommandTypeAc; EmmcCmdBlk.ResponseType = EmmcResponceTypeR1; EmmcCmdBlk.CommandArgument = Rca << 16; Status = EmmcPeimExecCmd (Slot, &Packet); return Status; }
tianocore/edk2
C++
Other
4,240
/* Reservation functions here avoid a huge stack in xfs_trans_init due to register overflow from temporaries in the calculations. */
STATIC uint xfs_calc_write_reservation(xfs_mount_t *mp)
/* Reservation functions here avoid a huge stack in xfs_trans_init due to register overflow from temporaries in the calculations. */ STATIC uint xfs_calc_write_reservation(xfs_mount_t *mp)
{ return XFS_CALC_WRITE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp); }
robutest/uclinux
C++
GPL-2.0
60
/* Take an array of 5 integers, remove the maximum and minimum values and return the average. */
static int get_select_val(int *val)
/* Take an array of 5 integers, remove the maximum and minimum values and return the average. */ static int get_select_val(int *val)
{ int i, j, k, temp, sum = 0; temp = val[0]; j = 0; for (i = 1; i < 5; i++) { if (temp < val[i]) { temp = val[i]; j = i; } } temp = val[4]; k = 4; for (i = 3; i >= 0; i--) { if (temp > val[i]) { temp = val[i]; k = i; } } for (i = 0; i < 5; i++) if (i != j && i != k) sum += val[i]; dev_dbg(sharpsl_pm.dev, "Average: %d from values: %d, %d, %d, %d, %d\n", sum/3, val[0], val[1], val[2], val[3], val[4]); return sum/3; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* return the block group that starts at or after bytenr */
static struct btrfs_block_group_cache* btrfs_lookup_first_block_group(struct btrfs_fs_info *info, u64 bytenr)
/* return the block group that starts at or after bytenr */ static struct btrfs_block_group_cache* btrfs_lookup_first_block_group(struct btrfs_fs_info *info, u64 bytenr)
{ struct btrfs_block_group_cache *cache; cache = block_group_cache_tree_search(info, bytenr, 0); return cache; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns the temperature row value (in 16 bit format). */
uint32_t IOE_TempSens_GetData(void)
/* Returns the temperature row value (in 16 bit format). */ uint32_t IOE_TempSens_GetData(void)
{ static __IO uint32_t tmp = 0; I2C_WriteDeviceRegister(IOE_1_ADDR, IOE_REG_TEMP_CTRL, 0x03); tmp = (uint32_t)((I2C_ReadDeviceRegister(IOE_1_ADDR, IOE_REG_TEMP_DATA) & 0x03) << 8); tmp |= (uint32_t)I2C_ReadDeviceRegister(IOE_1_ADDR, IOE_REG_TEMP_DATA + 1); tmp = (uint32_t)((33 * tmp * 100) / 751); tmp = (uint32_t)((tmp + 5) / 10); return tmp; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Count the number of in-use tags in a journal descriptor block. */
static int count_tags(journal_t *journal, struct buffer_head *bh)
/* Count the number of in-use tags in a journal descriptor block. */ static int count_tags(journal_t *journal, struct buffer_head *bh)
{ char * tagp; journal_block_tag_t * tag; int nr = 0, size = journal->j_blocksize; int tag_bytes = journal_tag_bytes(journal); tagp = &bh->b_data[sizeof(journal_header_t)]; while ((tagp - bh->b_data + tag_bytes) <= size) { tag = (journal_block_tag_t *) tagp; nr++; tagp += tag_bytes; if (!(tag->t_flags & cpu_to_be32(JBD2_FLAG_SAME_UUID))) tagp += 16; if (tag->t_flags & cpu_to_be32(JBD2_FLAG_LAST_TAG)) break; } return nr; }
robutest/uclinux
C++
GPL-2.0
60
/* Function called in case of error detected in SPI IT Handler. */
void SPI_TransferError_Callback(void)
/* Function called in case of error detected in SPI IT Handler. */ void SPI_TransferError_Callback(void)
{ LL_SPI_DisableIT_TXE(SPI1); LL_SPI_DisableIT_RXNE(SPI2); LED_Blinking(LED_BLINK_ERROR); }
STMicroelectronics/STM32CubeF4
C++
Other
789