docstring
stringlengths
22
576
signature
stringlengths
9
317
prompt
stringlengths
57
886
code
stringlengths
20
1.36k
repository
stringclasses
49 values
language
stringclasses
2 values
license
stringclasses
9 values
stars
int64
15
21.3k
/* This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag in */
static void ami_pan_var(struct fb_var_screeninfo *var)
/* This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag in */ static void ami_pan_var(struct fb_var_screeninfo *var)
{ struct amifb_par *par = &currentpar; par->xoffset = var->xoffset; par->yoffset = var->yoffset; if (var->vmode & FB_VMODE_YWRAP) par->vmode |= FB_VMODE_YWRAP; else par->vmode &= ~FB_VMODE_YWRAP; do_vmode_pan = 0; ami_update_par(); do_vmode_pan = 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Special call, doesn't claim any locks. This is only to be called at panic or halt time, in run-to-completion mode, when the caller is the only CPU and the only thing that will be going is these IPMI calls. */
static void panic_halt_ipmi_set_timeout(void)
/* Special call, doesn't claim any locks. This is only to be called at panic or halt time, in run-to-completion mode, when the caller is the only CPU and the only thing that will be going is these IPMI calls. */ static void panic_halt_ipmi_set_timeout(void)
{ int send_heartbeat_now; int rv; while (atomic_read(&panic_done_count) != 0) ipmi_poll_interface(watchdog_user); rv = i_ipmi_set_timeout(&panic_halt_smi_msg, &panic_halt_recv_msg, &send_heartbeat_now); if (!rv) { atomic_add(2, &panic_done_count); if (send_heartbeat_now) panic_halt_ipmi_heartbeat(); } else printk(KERN_WARNING PFX "Unable to extend the watchdog timeout."); while (atomic_read(&panic_done_count) != 0) ipmi_poll_interface(watchdog_user); }
robutest/uclinux
C++
GPL-2.0
60
/* Read TSC and the reference counters. Take care of SMI disturbance */
static u64 tsc_read_refs(u64 *p, int hpet)
/* Read TSC and the reference counters. Take care of SMI disturbance */ static u64 tsc_read_refs(u64 *p, int hpet)
{ u64 t1, t2; int i; for (i = 0; i < MAX_RETRIES; i++) { t1 = get_cycles(); if (hpet) *p = hpet_readl(HPET_COUNTER) & 0xFFFFFFFF; else *p = acpi_pm_read_early(); t2 = get_cycles(); if ((t2 - t1) < SMI_TRESHOLD) return t2; } return ULLONG_MAX; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* These functions get/set/update the registers of the sc26198 UARTs. Access to the sc26198 registers is via an address/data io port pair. (Maybe should make this inline...) */
static int stl_sc26198getreg(struct stlport *portp, int regnr)
/* These functions get/set/update the registers of the sc26198 UARTs. Access to the sc26198 registers is via an address/data io port pair. (Maybe should make this inline...) */ static int stl_sc26198getreg(struct stlport *portp, int regnr)
{ outb((regnr | portp->uartaddr), (portp->ioaddr + XP_ADDR)); return inb(portp->ioaddr + XP_DATA); }
robutest/uclinux
C++
GPL-2.0
60
/* Get bit mask for the 'VPN without index' field. See ISA, 4.6.5.6, data format for RxTLB0 */
static uint32_t get_vpn_mask(const CPUXtensaState *env, bool dtlb, uint32_t way)
/* Get bit mask for the 'VPN without index' field. See ISA, 4.6.5.6, data format for RxTLB0 */ static uint32_t get_vpn_mask(const CPUXtensaState *env, bool dtlb, uint32_t way)
{ if (way < 4) { bool is32 = (dtlb ? env->config->dtlb.nrefillentries : env->config->itlb.nrefillentries) == 32; return is32 ? 0xffff8000 : 0xffffc000; } else if (way == 4) { return xtensa_tlb_get_addr_mask(env, dtlb, way) << 2; } else if (way <= 6) { uint32_t mask = xtensa_tlb_get_addr_mask(env, dtlb, way); bool varway56 = dtlb ? env->config->dtlb.varway56 : env->config->itlb.varway56; if (varway56) { return mask << (way == 5 ? 2 : 3); } else { return mask << 1; } } else { return 0xfffff000; } }
ve3wwg/teensy3_qemu
C++
Other
15
/* Set the elapsed time based on the given instance and the pointer to the elapsed time option. */
VOID SetElapsedTime(IN UINT16 *Elapsed, IN DHCP_PROTOCOL *Instance)
/* Set the elapsed time based on the given instance and the pointer to the elapsed time option. */ VOID SetElapsedTime(IN UINT16 *Elapsed, IN DHCP_PROTOCOL *Instance)
{ WriteUnaligned16 (Elapsed, HTONS (Instance->ElaspedTime)); }
tianocore/edk2
C++
Other
4,240
/* ADC MSP Initialization This function configures the hardware resources used in this example. */
void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
/* ADC MSP Initialization This function configures the hardware resources used in this example. */ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; if(hadc->Instance==ADC1) { __HAL_RCC_ADC1_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This comparator searches for the next Interface descriptor of the correct CDC control Class, Subclass and Protocol values. */
uint8_t DComp_NextCDCControlInterface(void *CurrentDescriptor)
/* This comparator searches for the next Interface descriptor of the correct CDC control Class, Subclass and Protocol values. */ uint8_t DComp_NextCDCControlInterface(void *CurrentDescriptor)
{ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); if (Header->Type == DTYPE_Interface) { USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t); if ((Interface->Class == CDC_CSCP_CDCClass) && (Interface->SubClass == CDC_CSCP_ACMSubclass) && (Interface->Protocol == CDC_CSCP_VendorSpecificProtocol)) { return DESCRIPTOR_SEARCH_Found; } } return DESCRIPTOR_SEARCH_NotFound; }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Parses an expresion as defined by the css2 spec and builds the expression as a list of terms. */
CRTerm* cr_term_parse_expression_from_buf(const guchar *a_buf, enum CREncoding a_encoding)
/* Parses an expresion as defined by the css2 spec and builds the expression as a list of terms. */ CRTerm* cr_term_parse_expression_from_buf(const guchar *a_buf, enum CREncoding a_encoding)
{ CRParser *parser = NULL; CRTerm *result = NULL; enum CRStatus status = CR_OK; g_return_val_if_fail (a_buf, NULL); parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf), a_encoding, FALSE); g_return_val_if_fail (parser, NULL); status = cr_parser_try_to_skip_spaces_and_comments (parser); if (status != CR_OK) { goto cleanup; } status = cr_parser_parse_expr (parser, &result); if (status != CR_OK) { if (result) { cr_term_destroy (result); result = NULL; } } cleanup: if (parser) { cr_parser_destroy (parser); parser = NULL; } return result; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* The constructor calls an internal OpenSSL function which fetches a local copy of the hardware capability flags, used to enable native crypto instructions. */
RETURN_STATUS EFIAPI OpensslLibConstructor(VOID)
/* The constructor calls an internal OpenSSL function which fetches a local copy of the hardware capability flags, used to enable native crypto instructions. */ RETURN_STATUS EFIAPI OpensslLibConstructor(VOID)
{ OPENSSL_cpuid_setup (); return RETURN_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Returns the record size for the special blocks of the cdl format. Only returns something useful if dasd_eckd_cdl_special is true for the recid. */
static int dasd_eckd_cdl_reclen(int recid)
/* Returns the record size for the special blocks of the cdl format. Only returns something useful if dasd_eckd_cdl_special is true for the recid. */ static int dasd_eckd_cdl_reclen(int recid)
{ if (recid < 3) return sizes_trk0[recid]; return LABEL_SIZE; }
robutest/uclinux
C++
GPL-2.0
60
/* Displays the code value as a character, not its ASCII value, as would be done by BASE_DEC and friends. */
static void format_iso_eligibility(char *buf, guint32 value)
/* Displays the code value as a character, not its ASCII value, as would be done by BASE_DEC and friends. */ static void format_iso_eligibility(char *buf, guint32 value)
{ g_snprintf(buf, ITEM_LABEL_LENGTH, "%s (%c)", val_to_str_const(value, ouch_iso_eligibility_val, "Unknown"), value); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Set an register shifted for the given execution engine. */
static int lp5562_set_engine_reg(const struct device *dev, enum lp5562_led_sources engine, uint8_t reg, uint8_t val)
/* Set an register shifted for the given execution engine. */ static int lp5562_set_engine_reg(const struct device *dev, enum lp5562_led_sources engine, uint8_t reg, uint8_t val)
{ const struct lp5562_config *config = dev->config; uint8_t shift; int ret; ret = lp5562_get_engine_reg_shift(engine, &shift); if (ret) { return ret; } if (i2c_reg_update_byte_dt(&config->bus, reg, LP5562_MASK << shift, val << shift)) { return -EIO; } return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Set the callback for the Device Policy Manager policy check. */
void usbc_set_policy_cb_check(const struct device *dev, const policy_cb_check_t policy_cb_check)
/* Set the callback for the Device Policy Manager policy check. */ void usbc_set_policy_cb_check(const struct device *dev, const policy_cb_check_t policy_cb_check)
{ struct usbc_port_data *data = dev->data; data->policy_cb_check = policy_cb_check; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Interpret the binary form state and save it as persistent platform configuration. */
STATIC EFI_STATUS EFIAPI FormStateToPlatformConfig(IN CONST MAIN_FORM_STATE *MainFormState)
/* Interpret the binary form state and save it as persistent platform configuration. */ STATIC EFI_STATUS EFIAPI FormStateToPlatformConfig(IN CONST MAIN_FORM_STATE *MainFormState)
{ EFI_STATUS Status; PLATFORM_CONFIG PlatformConfig; CONST GOP_MODE *GopMode; if (MainFormState->NextPreferredResolution >= mNumGopModes) { return EFI_INVALID_PARAMETER; } GopMode = mGopModes + MainFormState->NextPreferredResolution; ZeroMem (&PlatformConfig, sizeof PlatformConfig); PlatformConfig.HorizontalResolution = GopMode->X; PlatformConfig.VerticalResolution = GopMode->Y; Status = PlatformConfigSave (&PlatformConfig); return Status; }
tianocore/edk2
C++
Other
4,240
/* USBH_MSC_BOT_Abort This function manages the different Error handling for STALL. */
USBH_Status USBH_MSC_BOT_Abort(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost, uint8_t direction)
/* USBH_MSC_BOT_Abort This function manages the different Error handling for STALL. */ USBH_Status USBH_MSC_BOT_Abort(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost, uint8_t direction)
{ USBH_Status status; status = USBH_BUSY; switch (direction) { case USBH_MSC_DIR_IN : status = USBH_ClrFeature(pdev, phost, MSC_Machine.MSBulkInEp, MSC_Machine.hc_num_in); break; case USBH_MSC_DIR_OUT : status = USBH_ClrFeature(pdev, phost, MSC_Machine.MSBulkOutEp, MSC_Machine.hc_num_out); break; default: break; } BOTStallErrorCount++; if (BOTStallErrorCount > MAX_BULK_STALL_COUNT_LIMIT ) { status = USBH_UNRECOVERED_ERROR; } return status; }
MaJerle/stm32f429
C++
null
2,036
/* Initializes input capture of the Timer channel. The */
void TimerCHPSCConfigure(unsigned long ulBase, unsigned long ulChannel, unsigned long ulPrescaler)
/* Initializes input capture of the Timer channel. The */ void TimerCHPSCConfigure(unsigned long ulBase, unsigned long ulChannel, unsigned long ulPrescaler)
{ xASSERT((ulBase == TIMER1_BASE) || (ulBase == TIMER0_BASE)); xASSERT((ulChannel == TIMER_CH_0) || (ulChannel == TIMER_CH_1) || (ulChannel == TIMER_CH_2) || (ulChannel == TIMER_CH_3)); xASSERT((ulPrescaler == TIMER_CHPSC_OFF) || (ulPrescaler == TIMER_CHPSC_2) || (ulPrescaler == TIMER_CHPSC_4) || (ulPrescaler == TIMER_CHPSC_8)); xHWREG(ulBase + TIMER_CH0ICFR + ulChannel * 4) &= ~TIMER_CH0ICFR_CH0PSC_M; xHWREG(ulBase + TIMER_CH0ICFR + ulChannel * 4) |= ulPrescaler; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* display a header line followed by a load of cell lines */
static int afs_proc_cells_show(struct seq_file *m, void *v)
/* display a header line followed by a load of cell lines */ static int afs_proc_cells_show(struct seq_file *m, void *v)
{ struct afs_cell *cell = list_entry(v, struct afs_cell, proc_link); if (v == &afs_proc_cells) { seq_puts(m, "USE NAME\n"); return 0; } seq_printf(m, "%3d %s\n", atomic_read(&cell->usage), cell->name); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Get the union of all the flags for all the tap listeners; that gives an indication of whether the protocol tree, or the columns, are required by any taps. */
guint union_of_tap_listener_flags(void)
/* Get the union of all the flags for all the tap listeners; that gives an indication of whether the protocol tree, or the columns, are required by any taps. */ guint union_of_tap_listener_flags(void)
{ volatile tap_listener_t *tl; guint flags = 0; for(tl=tap_listener_queue;tl;tl=tl->next){ flags|=tl->flags; } return flags; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This is called by driver's core in order to free memory once the last reference is released. */
static void usb_udc_release(struct device *dev)
/* This is called by driver's core in order to free memory once the last reference is released. */ static void usb_udc_release(struct device *dev)
{ struct usb_udc *udc; udc = container_of(dev, struct usb_udc, dev); kfree(udc); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Returns the newly built instance of #CRNum or NULL if an error arises. */
CRNum* cr_num_new_with_val(gdouble a_val, enum CRNumType a_type)
/* Returns the newly built instance of #CRNum or NULL if an error arises. */ CRNum* cr_num_new_with_val(gdouble a_val, enum CRNumType a_type)
{ CRNum *result = NULL; result = cr_num_new (); g_return_val_if_fail (result, NULL); result->val = a_val; result->type = a_type; return result; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Decode and handle standard interface requests originating on the control end point. */
static void prvHandleStandardInterfaceRequest(xUSB_REQUEST *pxRequest)
/* Decode and handle standard interface requests originating on the control end point. */ static void prvHandleStandardInterfaceRequest(xUSB_REQUEST *pxRequest)
{ unsigned short usStatus = 0; switch( pxRequest->ucRequest ) { case usbGET_STATUS_REQUEST: prvSendControlData( ( unsigned char * ) &usStatus, sizeof( usStatus ), sizeof( usStatus ), pdFALSE ); break; case usbGET_DESCRIPTOR_REQUEST: prvGetStandardInterfaceDescriptor( pxRequest ); break; case usbGET_INTERFACE_REQUEST: case usbSET_FEATURE_REQUEST: case usbSET_INTERFACE_REQUEST: default: prvSendStall(); break; } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* ReinitializeDevice-Request ::= SEQUENCE { reinitializedStateOfDevice ENUMERATED { coldstart (0), warmstart (1), startbackup (2), endbackup (3), startrestore (4), endrestore (5), abortrestor (6) }, password CharacterString (SIZE(1..20)) OPTIONAL } */
static guint fReinitializeDeviceRequest(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
/* ReinitializeDevice-Request ::= SEQUENCE { reinitializedStateOfDevice ENUMERATED { coldstart (0), warmstart (1), startbackup (2), endbackup (3), startrestore (4), endrestore (5), abortrestor (6) }, password CharacterString (SIZE(1..20)) OPTIONAL } */ static guint fReinitializeDeviceRequest(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 = fEnumeratedTag(tvb, pinfo, tree, offset, "reinitialized State Of Device: ", BACnetReinitializedStateOfDevice); break; case 1: offset = fCharacterString(tvb, pinfo, tree, offset, "Password: "); break; default: return offset; } if (offset == lastoffset) break; } return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Each protocol-specific driver should call this routine when it does not (or can no longer) handle IOC reset handling, or when its module is unloaded. */
void mpt_reset_deregister(u8 cb_idx)
/* Each protocol-specific driver should call this routine when it does not (or can no longer) handle IOC reset handling, or when its module is unloaded. */ void mpt_reset_deregister(u8 cb_idx)
{ if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) return; MptResetHandlers[cb_idx] = NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Checks whether the TIM interrupt has occurred or not. */
ITStatus TIM_GetITStatus(TIM_TypeDef *TIMx, uint16_t TIM_IT)
/* Checks whether the TIM interrupt has occurred or not. */ ITStatus TIM_GetITStatus(TIM_TypeDef *TIMx, uint16_t TIM_IT)
{ ITStatus bitstatus = RESET; uint16_t itstatus = 0x0, itenable = 0x0; assert_param(IS_TIM_ALL_PERIPH(TIMx)); assert_param(IS_TIM_GET_IT(TIM_IT)); assert_param(IS_TIM_PERIPH_IT(TIMx, TIM_IT)); itstatus = TIMx->SR & TIM_IT; itenable = TIMx->DIER & TIM_IT; if ((itstatus != (uint16_t)RESET) && (itenable != (uint16_t)RESET)) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get if anti-aliasing is enabled for a display or not */
bool lv_disp_get_antialiasing(lv_disp_t *disp)
/* Get if anti-aliasing is enabled for a display or not */ bool lv_disp_get_antialiasing(lv_disp_t *disp)
{ if(disp == NULL) disp = lv_disp_get_default(); if(disp == NULL) return false; return disp->driver->antialiasing ? true : false; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Sets the speed and duplex to gigabit full duplex (the only possible option) for fiber/serdes links. */
s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, u16 *duplex)
/* Sets the speed and duplex to gigabit full duplex (the only possible option) for fiber/serdes links. */ s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, u16 *duplex)
{ *speed = SPEED_1000; *duplex = FULL_DUPLEX; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* NOTE: This is one of few API functions that are allowed to be called from within a callback. */
CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag,...)
/* NOTE: This is one of few API functions that are allowed to be called from within a callback. */ CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag,...)
{ va_list arg; CURLcode result; if(!data) return CURLE_BAD_FUNCTION_ARGUMENT; va_start(arg, tag); result = vsetopt(data, tag, arg); va_end(arg); return result; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Not static inline because used by IP27 special magic initialization code */
unsigned long setup_zero_pages(void)
/* Not static inline because used by IP27 special magic initialization code */ unsigned long setup_zero_pages(void)
{ unsigned int order; unsigned long size; struct page *page; if (cpu_has_vce) order = 3; else order = 0; empty_zero_page = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order); if (!empty_zero_page) panic("Oh boy, that early out of memory?"); page = virt_to_page((void *)empty_zero_page); split_page(page, order); while (page < virt_to_page((void *)(empty_zero_page + (PAGE_SIZE << order)))) { SetPageReserved(page); page++; } size = PAGE_SIZE << order; zero_page_mask = (size - 1) & PAGE_MASK; return 1UL << order; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Ethernet MAC "misc" clock: dma clocks and main clock on 6348 */
static void enet_misc_set(struct clk *clk, int enable)
/* Ethernet MAC "misc" clock: dma clocks and main clock on 6348 */ static void enet_misc_set(struct clk *clk, int enable)
{ u32 mask; if (BCMCPU_IS_6338()) mask = CKCTL_6338_ENET_EN; else if (BCMCPU_IS_6345()) mask = CKCTL_6345_ENET_EN; else if (BCMCPU_IS_6348()) mask = CKCTL_6348_ENET_EN; else mask = CKCTL_6358_EMUSB_EN; bcm_hwclock_set(mask, enable); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* If cache is not frozen, eject entries randomly until the size of the cache is at least @additional bytes less than cache->max_size. That is, make enough room to accommodate a new entry of size @additional. */
static void _cairo_cache_shrink_to_accommodate(cairo_cache_t *cache, unsigned long additional)
/* If cache is not frozen, eject entries randomly until the size of the cache is at least @additional bytes less than cache->max_size. That is, make enough room to accommodate a new entry of size @additional. */ static void _cairo_cache_shrink_to_accommodate(cairo_cache_t *cache, unsigned long additional)
{ while (cache->size + additional > cache->max_size) { if (! _cairo_cache_remove_random (cache)) return; } }
xboot/xboot
C++
MIT License
779
/* Set the remap function and AF function of the GPIO pin. */
void exGPIO_PinAFConfig(GPIO_TypeDef *gpio, u16 pin, s32 remap, s8 alternate_function)
/* Set the remap function and AF function of the GPIO pin. */ void exGPIO_PinAFConfig(GPIO_TypeDef *gpio, u16 pin, s32 remap, s8 alternate_function)
{ u8 i; u8 shift; u32* ptr; if (alternate_function >= 0) { for (i = 0; i < 32; i++) { if (pin & 0x01) { pin = i; break; } pin >>= 1; } shift = (pin & 0x07) * 4; ptr = (pin < 8) ? (u32*)&gpio->AFRL : (u32*)&gpio->AFRH; *ptr = (*ptr & ~(0x0F << shift)) | (alternate_function << shift); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Called when we run out of PIO buffers. If we are now in the error state, return zero to flush the send work request. */
static int ipath_no_bufs_available(struct ipath_qp *qp, struct ipath_ibdev *dev)
/* Called when we run out of PIO buffers. If we are now in the error state, return zero to flush the send work request. */ static int ipath_no_bufs_available(struct ipath_qp *qp, struct ipath_ibdev *dev)
{ unsigned long flags; int ret = 1; spin_lock_irqsave(&qp->s_lock, flags); if (ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK) { dev->n_piowait++; qp->s_flags |= IPATH_S_WAITING; qp->s_flags &= ~IPATH_S_BUSY; spin_lock(&dev->pending_lock); if (list_empty(&qp->piowait)) list_add_tail(&qp->piowait, &dev->piowait); spin_unlock(&dev->pending_lock); } else ret = 0; spin_unlock_irqrestore(&qp->s_lock, flags); if (ret) want_buffer(dev->dd, qp); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Reads the sensor and returns the data as a sensors_event_t. */
err_t mpl115a2GetSensorEvent(sensors_event_t *event)
/* Reads the sensor and returns the data as a sensors_event_t. */ err_t mpl115a2GetSensorEvent(sensors_event_t *event)
{ float pressure_kPa; memset(event, 0, sizeof(sensors_event_t)); event->version = sizeof(sensors_event_t); event->sensor_id = _mpl115a2SensorID; event->type = SENSOR_TYPE_PRESSURE; event->timestamp = delayGetTicks(); ASSERT_STATUS(mpl115a2GetPressure(&pressure_kPa)); event->pressure = pressure_kPa * 10; return ERROR_NONE; }
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* Changes baud rate based on predetermined register settings. */
static void r_sci_uart_baud_set(R_SCI0_Type *p_sci_reg, baud_setting_t const *const p_baud_setting)
/* Changes baud rate based on predetermined register settings. */ static void r_sci_uart_baud_set(R_SCI0_Type *p_sci_reg, baud_setting_t const *const p_baud_setting)
{ p_sci_reg->BRR = p_baud_setting->brr; p_sci_reg->SMR_b.CKS = (uint8_t) (SCI_SMR_CKS_VALUE_MASK & p_baud_setting->cks); p_sci_reg->MDDR = p_baud_setting->mddr; p_sci_reg->SEMR = (uint8_t) ((p_sci_reg->SEMR & ~(SCI_UART_SEMR_BAUD_SETTING_MASK)) | (p_baud_setting->semr_baudrate_bits & SCI_UART_SEMR_BAUD_SETTING_MASK)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* SPI NSS pin low level in software mode. */
void spi_nss_internal_low(uint32_t spi_periph)
/* SPI NSS pin low level in software mode. */ void spi_nss_internal_low(uint32_t spi_periph)
{ SPI_CTL0(spi_periph) &= (uint32_t)(~SPI_CTL0_SWNSS); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Portions derived from work (c) 1995,1996 Christian Vogelgsang, and from work (c) 1998 Mike Shaver. */
static int efs_readpage(struct file *file, struct page *page)
/* Portions derived from work (c) 1995,1996 Christian Vogelgsang, and from work (c) 1998 Mike Shaver. */ static int efs_readpage(struct file *file, struct page *page)
{ return block_read_full_page(page,efs_get_block); }
robutest/uclinux
C++
GPL-2.0
60
/* Used as a "done" callback by when sending adapter_info. */
static void capabilities_rsp(struct srp_event_struct *evt_struct)
/* Used as a "done" callback by when sending adapter_info. */ static void capabilities_rsp(struct srp_event_struct *evt_struct)
{ struct ibmvscsi_host_data *hostdata = evt_struct->hostdata; if (evt_struct->xfer_iu->mad.capabilities.common.status) { dev_err(hostdata->dev, "error 0x%X getting capabilities info\n", evt_struct->xfer_iu->mad.capabilities.common.status); } else { if (hostdata->caps.migration.common.server_support != SERVER_SUPPORTS_CAP) dev_info(hostdata->dev, "Partition migration not supported\n"); if (client_reserve) { if (hostdata->caps.reserve.common.server_support == SERVER_SUPPORTS_CAP) dev_info(hostdata->dev, "Client reserve enabled\n"); else dev_info(hostdata->dev, "Client reserve not supported\n"); } } send_srp_login(hostdata); }
robutest/uclinux
C++
GPL-2.0
60
/* Sets a TCC module compare value and buffer value. Writes compare value and buffer to the given TCC module compare/capture channel. Usually as preparation for double buffer or circulared double buffer (circular buffer). */
enum status_code tcc_set_double_buffer_compare_values(struct tcc_module *const module_inst, const enum tcc_match_capture_channel channel_index, const uint32_t compare, const uint32_t compare_buffer)
/* Sets a TCC module compare value and buffer value. Writes compare value and buffer to the given TCC module compare/capture channel. Usually as preparation for double buffer or circulared double buffer (circular buffer). */ enum status_code tcc_set_double_buffer_compare_values(struct tcc_module *const module_inst, const enum tcc_match_capture_channel channel_index, const uint32_t compare, const uint32_t compare_buffer)
{ Assert(module_inst); enum status_code status; status = _tcc_set_compare_value(module_inst, channel_index, compare, false); if (status != STATUS_OK) { return status; } return _tcc_set_compare_value(module_inst, channel_index, compare_buffer, true); }
memfault/zero-to-main
C++
null
200
/* Configures link settings. hw - Struct containing variables accessed by shared code Assumes the hardware has previously been reset and the transmitter and receiver are not enabled. */
static s32 atl1_setup_link(struct atl1_hw *hw)
/* Configures link settings. hw - Struct containing variables accessed by shared code Assumes the hardware has previously been reset and the transmitter and receiver are not enabled. */ static s32 atl1_setup_link(struct atl1_hw *hw)
{ struct pci_dev *pdev = hw->back->pdev; struct atl1_adapter *adapter = hw->back; s32 ret_val; ret_val = atl1_phy_setup_autoneg_adv(hw); if (ret_val) { if (netif_msg_link(adapter)) dev_dbg(&pdev->dev, "error setting up autonegotiation\n"); return ret_val; } ret_val = atl1_phy_reset(hw); if (ret_val) { if (netif_msg_link(adapter)) dev_dbg(&pdev->dev, "error resetting phy\n"); return ret_val; } hw->phy_configured = true; return ret_val; }
robutest/uclinux
C++
GPL-2.0
60
/* Sample a process (thread group) timer for the given group_leader task. Must be called with tasklist_lock held for reading. */
static int cpu_timer_sample_group(const clockid_t which_clock, struct task_struct *p, union cpu_time_count *cpu)
/* Sample a process (thread group) timer for the given group_leader task. Must be called with tasklist_lock held for reading. */ static int cpu_timer_sample_group(const clockid_t which_clock, struct task_struct *p, union cpu_time_count *cpu)
{ struct task_cputime cputime; thread_group_cputimer(p, &cputime); switch (CPUCLOCK_WHICH(which_clock)) { default: return -EINVAL; case CPUCLOCK_PROF: cpu->cpu = cputime_add(cputime.utime, cputime.stime); break; case CPUCLOCK_VIRT: cpu->cpu = cputime.utime; break; case CPUCLOCK_SCHED: cpu->sched = cputime.sum_exec_runtime + task_delta_exec(p); break; } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns: 0 on success -EINTR when interrupted by a signal -ETIMEDOUT when the timeout expired -EDEADLK when the lock would deadlock (when deadlock detection is on) */
int rt_mutex_timed_lock(struct rt_mutex *lock, struct hrtimer_sleeper *timeout, int detect_deadlock)
/* Returns: 0 on success -EINTR when interrupted by a signal -ETIMEDOUT when the timeout expired -EDEADLK when the lock would deadlock (when deadlock detection is on) */ int rt_mutex_timed_lock(struct rt_mutex *lock, struct hrtimer_sleeper *timeout, int detect_deadlock)
{ might_sleep(); return rt_mutex_timed_fastlock(lock, TASK_INTERRUPTIBLE, timeout, detect_deadlock, rt_mutex_slowlock); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* STUSB1602 sets the Data Role SWAP status (bit3 0x18 */
STUSB1602_StatusTypeDef STUSB1602_Data_Role_Swap_Status_Set(uint8_t Addr, Data_Role_Swap_TypeDef st)
/* STUSB1602 sets the Data Role SWAP status (bit3 0x18 */ STUSB1602_StatusTypeDef STUSB1602_Data_Role_Swap_Status_Set(uint8_t Addr, Data_Role_Swap_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.DR_SWAP_EN = st; status = STUSB1602_WriteReg(&reg.d8, Addr, STUSB1602_CC_CAPABILITY_CTRL_REG, 1); return status; }
st-one/X-CUBE-USB-PD
C++
null
110
/* Allocates a new string and copies 'String' to clone it */
CHAR8* CloneString(IN CHAR8 *String)
/* Allocates a new string and copies 'String' to clone it */ CHAR8* CloneString(IN CHAR8 *String)
{ CHAR8* NewString; NewString = malloc (strlen (String) + 1); if (NewString != NULL) { strcpy (NewString, String); } return NewString; }
tianocore/edk2
C++
Other
4,240
/* Toggles the state of a gpio pin that is configured as an output. Toggles the current output level of a gpio pin. */
void gpio_pin_toggle_output_level(const uint8_t gpio_pin)
/* Toggles the state of a gpio pin that is configured as an output. Toggles the current output level of a gpio pin. */ void gpio_pin_toggle_output_level(const uint8_t gpio_pin)
{ if (gpio_pin < 16) { GPIO0->DATAOUT.reg ^= (1 << gpio_pin); } else if (gpio_pin < 32) { GPIO1->DATAOUT.reg ^= (1 << (gpio_pin % 16)); } else { GPIO2->DATAOUT.reg ^= (1 << (gpio_pin % 16)); } }
memfault/zero-to-main
C++
null
200
/* This API used to set the x and y repetition in the register 0x51 bit 0 to 7. */
BMM050_RETURN_FUNCTION_TYPE bmm050_set_rep_XY(u8 v_rep_xy_u8)
/* This API used to set the x and y repetition in the register 0x51 bit 0 to 7. */ BMM050_RETURN_FUNCTION_TYPE bmm050_set_rep_XY(u8 v_rep_xy_u8)
{ BMM050_RETURN_FUNCTION_TYPE com_rslt = ERROR; u8 v_data_u8 = BMM050_INIT_VALUE; if (p_bmm050 == BMM050_NULL) { return E_BMM050_NULL_PTR; } else { v_data_u8 = v_rep_xy_u8; com_rslt = p_bmm050->BMM050_BUS_WRITE_FUNC( p_bmm050->dev_addr, BMM050_REP_XY, &v_data_u8, BMM050_GEN_READ_WRITE_DATA_LENGTH); } return com_rslt; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
void GPIOPinTypeEthernetLED(uint32_t ui32Port, uint8_t ui8Pins)
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */ void GPIOPinTypeEthernetLED(uint32_t ui32Port, uint8_t ui8Pins)
{ ASSERT(_GPIOBaseValid(ui32Port)); GPIODirModeSet(ui32Port, ui8Pins, GPIO_DIR_MODE_HW); GPIOPadConfigSet(ui32Port, ui8Pins, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Prepare the send buffer for the payload data. Padding and checksumming will all be taken care of by the iscsi_segment routines. */
static int iscsi_sw_tcp_send_data_prep(struct iscsi_conn *conn, struct scatterlist *sg, unsigned int count, unsigned int offset, unsigned int len)
/* Prepare the send buffer for the payload data. Padding and checksumming will all be taken care of by the iscsi_segment routines. */ static int iscsi_sw_tcp_send_data_prep(struct iscsi_conn *conn, struct scatterlist *sg, unsigned int count, unsigned int offset, unsigned int len)
{ struct iscsi_tcp_conn *tcp_conn = conn->dd_data; struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data; struct hash_desc *tx_hash = NULL; unsigned int hdr_spec_len; ISCSI_SW_TCP_DBG(conn, "offset=%d, datalen=%d %s\n", offset, len, conn->datadgst_en ? "digest enabled" : "digest disabled"); hdr_spec_len = ntoh24(tcp_sw_conn->out.hdr->dlength); WARN_ON(iscsi_padded(len) != iscsi_padded(hdr_spec_len)); if (conn->datadgst_en) tx_hash = &tcp_sw_conn->tx_hash; return iscsi_segment_seek_sg(&tcp_sw_conn->out.data_segment, sg, count, offset, len, NULL, tx_hash); }
robutest/uclinux
C++
GPL-2.0
60
/* Called from xfs_bmap_add_attrfork to handle extents format files. */
STATIC int xfs_bmap_add_attrfork_extents(xfs_trans_t *tp, xfs_inode_t *ip, xfs_fsblock_t *firstblock, xfs_bmap_free_t *flist, int *flags)
/* Called from xfs_bmap_add_attrfork to handle extents format files. */ STATIC int xfs_bmap_add_attrfork_extents(xfs_trans_t *tp, xfs_inode_t *ip, xfs_fsblock_t *firstblock, xfs_bmap_free_t *flist, int *flags)
{ xfs_btree_cur_t *cur; int error; if (ip->i_d.di_nextents * sizeof(xfs_bmbt_rec_t) <= XFS_IFORK_DSIZE(ip)) return 0; cur = NULL; error = xfs_bmap_extents_to_btree(tp, ip, firstblock, flist, &cur, 0, flags, XFS_DATA_FORK); if (cur) { cur->bc_private.b.allocated = 0; xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR); } return error; }
robutest/uclinux
C++
GPL-2.0
60
/* Internal function reserves the enough buffer for current opcode. When the buffer is not enough, Opcode buffer will be extended. */
UINT8* EFIAPI InternalHiiGrowOpCodeHandle(IN VOID *OpCodeHandle, IN UINTN Size)
/* Internal function reserves the enough buffer for current opcode. When the buffer is not enough, Opcode buffer will be extended. */ UINT8* EFIAPI InternalHiiGrowOpCodeHandle(IN VOID *OpCodeHandle, IN UINTN Size)
{ HII_LIB_OPCODE_BUFFER *OpCodeBuffer; UINT8 *Buffer; ASSERT (OpCodeHandle != NULL); OpCodeBuffer = (HII_LIB_OPCODE_BUFFER *)OpCodeHandle; if (OpCodeBuffer->Position + Size > OpCodeBuffer->BufferSize) { Buffer = ReallocatePool ( OpCodeBuffer->BufferSize, OpCodeBuffer->BufferSize + (Size + HII_LIB_OPCODE_ALLOCATION_SIZE), OpCodeBuffer->Buffer ); ASSERT (Buffer != NULL); OpCodeBuffer->Buffer = Buffer; OpCodeBuffer->BufferSize += (Size + HII_LIB_OPCODE_ALLOCATION_SIZE); } Buffer = OpCodeBuffer->Buffer + OpCodeBuffer->Position; OpCodeBuffer->Position += Size; return Buffer; }
tianocore/edk2
C++
Other
4,240
/* Converts the runtime memory range physical addresses to virtual addresses. */
VOID ConvertRuntimeMemoryRangeAddresses(IN PRM_RUNTIME_MMIO_RANGES *RuntimeMmioRanges)
/* Converts the runtime memory range physical addresses to virtual addresses. */ VOID ConvertRuntimeMemoryRangeAddresses(IN PRM_RUNTIME_MMIO_RANGES *RuntimeMmioRanges)
{ UINTN Index; if ((RuntimeMmioRanges == NULL) || (RuntimeMmioRanges->Count == 0)) { return; } for (Index = 0; Index < (UINTN)RuntimeMmioRanges->Count; Index++) { RuntimeMmioRanges->Range[Index].VirtualBaseAddress = RuntimeMmioRanges->Range[Index].PhysicalBaseAddress; gRT->ConvertPointer (0x0, (VOID **)&(RuntimeMmioRanges->Range[Index].VirtualBaseAddress)); } }
tianocore/edk2
C++
Other
4,240
/* e1000_clean_all_rx_rings - Free Rx Buffers for all queues @adapter: board private structure */
static void e1000_clean_all_rx_rings(struct e1000_adapter *adapter)
/* e1000_clean_all_rx_rings - Free Rx Buffers for all queues @adapter: board private structure */ static void e1000_clean_all_rx_rings(struct e1000_adapter *adapter)
{ int i; for (i = 0; i < adapter->num_rx_queues; i++) e1000_clean_rx_ring(adapter, &adapter->rx_ring[i]); }
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 EmuBlockIoComponentNameGetDriverName(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 EmuBlockIoComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
{ return LookupUnicodeString2 ( Language, This->SupportedLanguages, mEmuBlockIoDriverNameTable, DriverName, (BOOLEAN)(This == &gEmuBlockIoComponentName) ); }
tianocore/edk2
C++
Other
4,240
/* Flush a CBE from cache. The CBE is clean in the cache. Dirty the CBE cacheline so that the line will be written back to home agent. Otherwise the line may be silently dropped. This has no impact except on performance. */
static void gru_flush_cache_cbe(struct gru_control_block_extended *cbe)
/* Flush a CBE from cache. The CBE is clean in the cache. Dirty the CBE cacheline so that the line will be written back to home agent. Otherwise the line may be silently dropped. This has no impact except on performance. */ static void gru_flush_cache_cbe(struct gru_control_block_extended *cbe)
{ if (unlikely(cbe)) { cbe->cbrexecstatus = 0; gru_flush_cache(cbe); } }
robutest/uclinux
C++
GPL-2.0
60
/* Print an unsigned relative number of seconds (e.g. hold time, prune timer) in the form 5m1s. This does no truncation, so 32230861 seconds is represented as 1y1w1d1h1m1s. */
void unsigned_relts_print(netdissect_options *ndo, uint32_t secs)
/* Print an unsigned relative number of seconds (e.g. hold time, prune timer) in the form 5m1s. This does no truncation, so 32230861 seconds is represented as 1y1w1d1h1m1s. */ void unsigned_relts_print(netdissect_options *ndo, uint32_t secs)
{ static const char *lengths[] = {"y", "w", "d", "h", "m", "s"}; static const u_int seconds[] = {31536000, 604800, 86400, 3600, 60, 1}; const char **l = lengths; const u_int *s = seconds; if (secs == 0) { ND_PRINT((ndo, "0s")); return; } while (secs > 0) { if (secs >= *s) { ND_PRINT((ndo, "%d%s", secs / *s, *l)); secs -= (secs / *s) * *s; } s++; l++; } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT32 EFIAPI PciExpressBitFieldWrite32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT32 EFIAPI PciExpressBitFieldWrite32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value)
{ if (Address >= mSmmPciExpressLibPciExpressBaseSize) { return (UINT32)-1; } return MmioBitFieldWrite32 ( GetPciExpressAddress (Address), StartBit, EndBit, Value ); }
tianocore/edk2
C++
Other
4,240
/* Thaw local file systems using Volume Shadow-copy Service. */
int64_t qmp_guest_fsfreeze_thaw(Error **err)
/* Thaw local file systems using Volume Shadow-copy Service. */ int64_t qmp_guest_fsfreeze_thaw(Error **err)
{ int i; if (!vss_initialized()) { error_set(err, QERR_UNSUPPORTED); return 0; } qga_vss_fsfreeze(&i, err, false); ga_unset_frozen(ga_state); return i; }
ve3wwg/teensy3_qemu
C++
Other
15
/* Generic function for queueing a TRB on a ring. The caller must have checked to make sure there's room on the ring. */
static struct xhci_generic_trb* queue_trb(struct xhci_ctrl *ctrl, struct xhci_ring *ring, bool more_trbs_coming, unsigned int *trb_fields)
/* Generic function for queueing a TRB on a ring. The caller must have checked to make sure there's room on the ring. */ static struct xhci_generic_trb* queue_trb(struct xhci_ctrl *ctrl, struct xhci_ring *ring, bool more_trbs_coming, unsigned int *trb_fields)
{ struct xhci_generic_trb *trb; int i; trb = &ring->enqueue->generic; for (i = 0; i < 4; i++) trb->field[i] = cpu_to_le32(trb_fields[i]); xhci_flush_cache((uintptr_t)trb, sizeof(struct xhci_generic_trb)); inc_enq(ctrl, ring, more_trbs_coming); return trb; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Output a string to the usb client port - implementing flow control */
static void __usbtty_puts(const char *str, int len)
/* Output a string to the usb client port - implementing flow control */ static void __usbtty_puts(const char *str, int len)
{ int maxlen = usbtty_output.totalsize; int space, n; while (len > 0) { usbtty_poll (); space = maxlen - usbtty_output.size; if (space) { write_buffer (&usbtty_output); n = min(space, min(len, maxlen)); buf_push (&usbtty_output, str, n); str += n; len -= n; } } }
4ms/stm32mp1-baremetal
C++
Other
137
/* Initialize DPM (port power role, PWR_IF, CAD and PE Init procedures) */
USBPD_StatusTypeDef USBPD_DPM_UserInit(void)
/* Initialize DPM (port power role, PWR_IF, CAD and PE Init procedures) */ USBPD_StatusTypeDef USBPD_DPM_UserInit(void)
{ Led_Init(); Led_Set(LED_PORT0_ROLE, ((DPM_Settings[USBPD_PORT_0].PE_DefaultRole == USBPD_PORTPOWERROLE_SNK) ? LED_MODE_BLINK_ROLE_SNK : LED_MODE_BLINK_ROLE_SRC), 0); Led_Set(LED_PORT1_ROLE, LED_MODE_OFF, 0); USBPD_PWR_IF_Init(); if(USBPD_OK != USBPD_PWR_IF_PowerResetGlobal()) return USBPD_ERROR; osMessageQDef(MsgBox, DPM_BOX_MESSAGES_MAX, uint32_t); DPMMsgBox = osMessageCreate(osMessageQ(MsgBox), NULL); osThreadDef(DPM, USBPD_DPM_UserExecute, osPriorityLow, 0, 120); if(NULL == osThreadCreate(osThread(DPM), &DPMMsgBox)) { return USBPD_ERROR; } return USBPD_OK; }
st-one/X-CUBE-USB-PD
C++
null
110
/* XDR unsigned long integers same as xdr_long - open coded to save a proc call! */
bool_t xdr_u_long(XDR *xdrs, unsigned long *ulp)
/* XDR unsigned long integers same as xdr_long - open coded to save a proc call! */ bool_t xdr_u_long(XDR *xdrs, unsigned long *ulp)
{ if (xdrs->x_op == XDR_DECODE) { long l; if (XDR_GETLONG(xdrs, &l) == FALSE) return FALSE; *ulp = (uint32_t) l; return TRUE; } if (xdrs->x_op == XDR_ENCODE) { if (sizeof(uint32_t) != sizeof(unsigned long) && (uint32_t) *ulp != *ulp) return FALSE; return (XDR_PUTLONG(xdrs, (long *) ulp)); } if (xdrs->x_op == XDR_FREE) return (TRUE); return (FALSE); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Get the clock frequency as reflected by CCCR and the turbo flag. We assume these values have been applied via a fcs. If info is not 0 we also display the current settings. */
unsigned int get_clk_frequency_khz(int info)
/* Get the clock frequency as reflected by CCCR and the turbo flag. We assume these values have been applied via a fcs. If info is not 0 we also display the current settings. */ unsigned int get_clk_frequency_khz(int info)
{ if (cpu_is_pxa25x()) return pxa25x_get_clk_frequency_khz(info); else if (cpu_is_pxa27x()) return pxa27x_get_clk_frequency_khz(info); else return pxa3xx_get_clk_frequency_khz(info); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* param base XBARA peripheral address. param output XBARA output number. param controlConfig Pointer to structure that keeps configuration of control register. */
void XBARA_SetOutputSignalConfig(XBARA_Type *base, xbar_output_signal_t output, const xbara_control_config_t *controlConfig)
/* param base XBARA peripheral address. param output XBARA output number. param controlConfig Pointer to structure that keeps configuration of control register. */ void XBARA_SetOutputSignalConfig(XBARA_Type *base, xbar_output_signal_t output, const xbara_control_config_t *controlConfig)
{ uint8_t outputIndex = (uint8_t)output; uint8_t regIndex; uint8_t byteInReg; xbara_u8_u16_t regVal; assert(outputIndex < (uint32_t)FSL_FEATURE_XBARA_INTERRUPT_COUNT); regIndex = outputIndex / 2U; byteInReg = outputIndex % 2U; regVal._u16 = XBARA_CTRLx(base, regIndex); regVal._u16 &= (uint16_t)(~(XBARA_CTRL0_STS0_MASK | XBARA_CTRL0_STS1_MASK)); regVal._u8[byteInReg] = (uint8_t)(XBARA_CTRL0_EDGE0(controlConfig->activeEdge) | (uint16_t)(((uint32_t)controlConfig->requestType) << XBARA_CTRL0_DEN0_SHIFT)); XBARA_CTRLx(base, regIndex) = regVal._u16; }
eclipse-threadx/getting-started
C++
Other
310
/* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious initialization constants. */
void cifs_MD5_init(struct MD5Context *ctx)
/* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious initialization constants. */ void cifs_MD5_init(struct MD5Context *ctx)
{ ctx->buf[0] = 0x67452301; ctx->buf[1] = 0xefcdab89; ctx->buf[2] = 0x98badcfe; ctx->buf[3] = 0x10325476; ctx->bits[0] = 0; ctx->bits[1] = 0; }
robutest/uclinux
C++
GPL-2.0
60
/* no dcache_lock, please. The caller must decrement dentry_stat.nr_dentry inside dcache_lock. */
static void d_free(struct dentry *dentry)
/* no dcache_lock, please. The caller must decrement dentry_stat.nr_dentry inside dcache_lock. */ static void d_free(struct dentry *dentry)
{ if (dentry->d_op && dentry->d_op->d_release) dentry->d_op->d_release(dentry); if (hlist_unhashed(&dentry->d_hash)) __d_free(dentry); else call_rcu(&dentry->d_u.d_rcu, d_callback); }
robutest/uclinux
C++
GPL-2.0
60
/* Query whether specified timing controller support the output_type spcified @disp: the index of timing controller @output_type: the display output type On support, returns 1. Otherwise, returns 0. */
s32 bsp_disp_feat_is_supported_output_types(u32 disp, u32 output_type)
/* Query whether specified timing controller support the output_type spcified @disp: the index of timing controller @output_type: the display output type On support, returns 1. Otherwise, returns 0. */ s32 bsp_disp_feat_is_supported_output_types(u32 disp, u32 output_type)
{ return de_feat_is_supported_output_types(disp, output_type); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Called after processes are frozen, but before we shutdown devices. */
static int at91_pm_begin(suspend_state_t state)
/* Called after processes are frozen, but before we shutdown devices. */ static int at91_pm_begin(suspend_state_t state)
{ target_state = state; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* pci_save_state - save the PCI configuration space of a device before suspending @dev: - PCI device that we're dealing with */
int pci_save_state(struct pci_dev *dev)
/* pci_save_state - save the PCI configuration space of a device before suspending @dev: - PCI device that we're dealing with */ int pci_save_state(struct pci_dev *dev)
{ int i; for (i = 0; i < 16; i++) pci_read_config_dword(dev, i * 4, &dev->saved_config_space[i]); dev->state_saved = true; if ((i = pci_save_pcie_state(dev)) != 0) return i; if ((i = pci_save_pcix_state(dev)) != 0) return i; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* deliver reply data to an FS.RemoveFile or FS.RemoveDir */
static int afs_deliver_fs_remove(struct afs_call *call, struct sk_buff *skb, bool last)
/* deliver reply data to an FS.RemoveFile or FS.RemoveDir */ static int afs_deliver_fs_remove(struct afs_call *call, struct sk_buff *skb, bool last)
{ struct afs_vnode *vnode = call->reply; const __be32 *bp; _enter("{%u},{%u},%d", call->unmarshall, skb->len, last); afs_transfer_reply(call, skb); if (!last) return 0; if (call->reply_size != call->reply_max) return -EBADMSG; bp = call->buffer; xdr_decode_AFSFetchStatus(&bp, &vnode->status, vnode, NULL); _leave(" = 0 [done]"); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns the set of fault triggers currently configured for a given PWM generator. */
unsigned long PWMGenFaultTriggerGet(unsigned long ulBase, unsigned long ulGen, unsigned long ulGroup)
/* Returns the set of fault triggers currently configured for a given PWM generator. */ unsigned long PWMGenFaultTriggerGet(unsigned long ulBase, unsigned long ulGen, unsigned long ulGroup)
{ ASSERT((ulBase == PWM0_BASE) || (ulBase == PWM1_BASE)); ASSERT(PWMGenValid(ulGen)); ASSERT((ulGroup == PWM_FAULT_GROUP_0) || (ulGroup == PWM_FAULT_GROUP_1)); if(ulGroup == PWM_FAULT_GROUP_0) { return(HWREG(PWM_GEN_BADDR(ulBase, ulGen) + PWM_O_X_FLTSRC0)); } else { return(HWREG(PWM_GEN_BADDR(ulBase, ulGen) + PWM_O_X_FLTSRC1)); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns the localised string corresponding to the specified 'key' value. */
char* localisation_GetString(localisedTextKeys_t key)
/* Returns the localised string corresponding to the specified 'key' value. */ char* localisation_GetString(localisedTextKeys_t key)
{ return (char*)localised_strings[_localisation_currentCulture][key]; }
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* Extract the port number of the given pin. */
static uint8_t _port_num(gpio_t pin)
/* Extract the port number of the given pin. */ static uint8_t _port_num(gpio_t pin)
{ return (pin >> 4) & 0x0f; }
labapart/polymcu
C++
null
201
/* Read specified bytes from Lba from the device. */
EFI_STATUS AhciRead(IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData, OUT VOID *Buffer, IN EFI_LBA StartLba, IN UINTN BufferSize)
/* Read specified bytes from Lba from the device. */ EFI_STATUS AhciRead(IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData, OUT VOID *Buffer, IN EFI_LBA StartLba, IN UINTN BufferSize)
{ EFI_STATUS Status; UINTN BlockSize; UINTN NumberOfBlocks; if (Buffer == NULL) { return EFI_INVALID_PARAMETER; } if (BufferSize == 0) { return EFI_SUCCESS; } BlockSize = DeviceData->Media.BlockSize; if ((BufferSize % BlockSize) != 0) { return EFI_BAD_BUFFER_SIZE; } if (StartLba > DeviceData->Media.LastBlock) { return EFI_INVALID_PARAMETER; } NumberOfBlocks = BufferSize / BlockSize; if (NumberOfBlocks - 1 > DeviceData->Media.LastBlock - StartLba) { return EFI_INVALID_PARAMETER; } Status = AccessAtaDevice (DeviceData, Buffer, StartLba, NumberOfBlocks); return Status; }
tianocore/edk2
C++
Other
4,240
/* get the clock stabilization interrupt and ckm flags */
FlagStatus rcu_interrupt_flag_get(rcu_int_flag_enum int_flag)
/* get the clock stabilization interrupt and ckm flags */ FlagStatus rcu_interrupt_flag_get(rcu_int_flag_enum int_flag)
{ if(RESET != (RCU_REG_VAL(int_flag) & BIT(RCU_BIT_POS(int_flag)))){ return SET; }else{ return RESET; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns the last ADC1 and ADC2 OR last ADC3 and ADC4 conversion result data in dual mode. */
uint32_t ADC_GetDualModeConversionDat(ADC_Module *ADCx)
/* Returns the last ADC1 and ADC2 OR last ADC3 and ADC4 conversion result data in dual mode. */ uint32_t ADC_GetDualModeConversionDat(ADC_Module *ADCx)
{ assert_param(IsAdcModule(ADCx)); if(ADCx==ADC1 | ADCx==ADC2) return (uint32_t)ADC1->DAT; else return (uint32_t)ADC3->DAT; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns the base address of an SOC or PCI node */
u64 fdt_get_base_address(const void *fdt, int node)
/* Returns the base address of an SOC or PCI node */ u64 fdt_get_base_address(const void *fdt, int node)
{ int size; const fdt32_t *prop; prop = fdt_getprop(fdt, node, "reg", &size); return prop ? fdt_translate_address(fdt, node, prop) : OF_BAD_ADDR; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Gets the number of free places in the list. */
uint32_t LIST_GetAvailableSize(list_handle_t list)
/* Gets the number of free places in the list. */ uint32_t LIST_GetAvailableSize(list_handle_t list)
{ return ((uint32_t)list->max - (uint32_t)list->size); }
eclipse-threadx/getting-started
C++
Other
310
/* iseriesvscsi_send_crq: - Send a CRQ @hostdata: the adapter @word1: the first 64 bits of the data @word2: the second 64 bits of the data */
static int iseriesvscsi_send_crq(struct ibmvscsi_host_data *hostdata, u64 word1, u64 word2)
/* iseriesvscsi_send_crq: - Send a CRQ @hostdata: the adapter @word1: the first 64 bits of the data @word2: the second 64 bits of the data */ static int iseriesvscsi_send_crq(struct ibmvscsi_host_data *hostdata, u64 word1, u64 word2)
{ single_host_data = hostdata; return HvCallEvent_signalLpEventFast(viopath_hostLp, HvLpEvent_Type_VirtualIo, viomajorsubtype_scsi, HvLpEvent_AckInd_NoAck, HvLpEvent_AckType_ImmediateAck, viopath_sourceinst(viopath_hostLp), viopath_targetinst(viopath_hostLp), 0, VIOVERSION << 16, word1, word2, 0, 0); }
robutest/uclinux
C++
GPL-2.0
60
/* get_pkeys - return the PKEY table for port 0 @dd: the infinipath device @pkeys: the pkey table is placed here */
static int get_pkeys(struct ipath_devdata *dd, u16 *pkeys)
/* get_pkeys - return the PKEY table for port 0 @dd: the infinipath device @pkeys: the pkey table is placed here */ static int get_pkeys(struct ipath_devdata *dd, u16 *pkeys)
{ struct ipath_portdata *pd = dd->ipath_pd[0]; memcpy(pkeys, pd->port_pkeys, sizeof(pd->port_pkeys)); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* sets the value of an EthDB property Also note that once this function is called the effect is irreversible, unless EthDB is complete unloaded and re-initialized. */
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFeaturePropertySet(IxEthDBPortId portID, IxEthDBFeature feature, IxEthDBProperty property, void *value)
/* sets the value of an EthDB property Also note that once this function is called the effect is irreversible, unless EthDB is complete unloaded and re-initialized. */ IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFeaturePropertySet(IxEthDBPortId portID, IxEthDBFeature feature, IxEthDBProperty property, void *value)
{ IX_ETH_DB_CHECK_PORT_EXISTS(portID); if ((feature == IX_ETH_DB_VLAN_QOS) && (property == IX_ETH_DB_QOS_QUEUE_CONFIGURATION_COMPLETE)) { ixEthDBPortInfo[portID].ixEthDBTrafficClassAvailable = ixEthDBPortInfo[portID].ixEthDBTrafficClassCount; return IX_ETH_DB_SUCCESS; } return IX_ETH_DB_INVALID_ARG; }
EmcraftSystems/u-boot
C++
Other
181
/* Sets the FW busy flag and reduces the host->can_queue if the cmd has not been completed within the timeout period. */
static enum blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
/* Sets the FW busy flag and reduces the host->can_queue if the cmd has not been completed within the timeout period. */ static enum blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
{ struct megasas_cmd *cmd = (struct megasas_cmd *)scmd->SCp.ptr; struct megasas_instance *instance; unsigned long flags; if (time_after(jiffies, scmd->jiffies_at_alloc + (MEGASAS_DEFAULT_CMD_TIMEOUT * 2) * HZ)) { return BLK_EH_NOT_HANDLED; } instance = cmd->instance; if (!(instance->flag & MEGASAS_FW_BUSY)) { spin_lock_irqsave(instance->host->host_lock, flags); instance->host->can_queue = 16; instance->last_time = jiffies; instance->flag |= MEGASAS_FW_BUSY; spin_unlock_irqrestore(instance->host->host_lock, flags); } return BLK_EH_RESET_TIMER; }
robutest/uclinux
C++
GPL-2.0
60
/* Will be called only by the device core when all users of this usb device are done. */
static void usb_release_dev(struct device *dev)
/* Will be called only by the device core when all users of this usb device are done. */ static void usb_release_dev(struct device *dev)
{ struct usb_device *udev; struct usb_hcd *hcd; udev = to_usb_device(dev); hcd = bus_to_hcd(udev->bus); usb_destroy_configuration(udev); if (hcd->driver->free_dev && udev->parent) hcd->driver->free_dev(hcd, udev); usb_put_hcd(hcd); kfree(udev->product); kfree(udev->manufacturer); kfree(udev->serial); kfree(udev); }
robutest/uclinux
C++
GPL-2.0
60
/* Enables the I2C Slave block. This will enable operation of the I2C Slave block. */
void xI2CSlaveEnable(unsigned long ulBase)
/* Enables the I2C Slave block. This will enable operation of the I2C Slave block. */ void xI2CSlaveEnable(unsigned long ulBase)
{ xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE)); xHWREG(ulBase + I2C_CON) |= I2C_CON_ENS1; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* param base SMC peripheral base address. return SMC configuration error code. */
status_t SMC_SetPowerModeVlps(SMC_Type *base)
/* param base SMC peripheral base address. return SMC configuration error code. */ status_t SMC_SetPowerModeVlps(SMC_Type *base)
{ uint8_t reg; reg = base->PMCTRL; reg &= ~(uint8_t)SMC_PMCTRL_STOPM_MASK; reg |= ((uint8_t)kSMC_StopVlps << SMC_PMCTRL_STOPM_SHIFT); base->PMCTRL = reg; SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; (void)base->PMCTRL; SMC_EnterStopRamFunc(); if (0U != (base->PMCTRL & SMC_PMCTRL_STOPA_MASK)) { return kStatus_SMC_StopAbort; } else { return kStatus_Success; } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* The destructor function frees resources allocated by constructor. */
EFI_STATUS EFIAPI SmmPerformanceLibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* The destructor function frees resources allocated by constructor. */ EFI_STATUS EFIAPI SmmPerformanceLibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ EFI_STATUS Status; Status = gSmst->SmmRegisterProtocolNotify ( &gEdkiiSmmExitBootServicesProtocolGuid, NULL, &mPerformanceLibExitBootServicesRegistration ); ASSERT_EFI_ERROR (Status); return Status; }
tianocore/edk2
C++
Other
4,240
/* Fills each TIM_ICInitStruct member with its default value. */
void TIM_InitIcStruct(TIM_ICInitType *TIM_ICInitStruct)
/* Fills each TIM_ICInitStruct member with its default value. */ void TIM_InitIcStruct(TIM_ICInitType *TIM_ICInitStruct)
{ TIM_ICInitStruct->Channel = TIM_CH_1; TIM_ICInitStruct->IcPolarity = TIM_IC_POLARITY_RISING; TIM_ICInitStruct->IcSelection = TIM_IC_SELECTION_DIRECTTI; TIM_ICInitStruct->IcPrescaler = TIM_IC_PSC_DIV1; TIM_ICInitStruct->IcFilter = 0x00; }
pikasTech/PikaPython
C++
MIT License
1,403
/* ic3_tx_empty - Is the transmitter empty? @port: Port to operate on */
static unsigned int ic3_tx_empty(struct uart_port *the_port)
/* ic3_tx_empty - Is the transmitter empty? @port: Port to operate on */ static unsigned int ic3_tx_empty(struct uart_port *the_port)
{ unsigned int ret = 0; struct ioc3_port *port = get_ioc3_port(the_port); if (readl(&port->ip_serial_regs->shadow) & SHADOW_TEMT) ret = TIOCSER_TEMT; return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Clear the fifo read and write pointers and set the length to zero. */
void uartRxBufferClearFIFO()
/* Clear the fifo read and write pointers and set the length to zero. */ void uartRxBufferClearFIFO()
{ uart_pcb_t *pcb = uartGetPCB(); pcb->rxfifo.rd_ptr = 0; pcb->rxfifo.wr_ptr = 0; pcb->rxfifo.len = 0; }
microbuilder/LPC1343CodeBase
C++
Other
73
/* Indicates whether or not the I2C bus is busy. This function returns an indication of whether or not the I2C bus is busy. This function can be used in a multi-master environment to determine if another master is currently using the bus. */
xtBoolean xI2CMasterBusBusy(unsigned long ulBase)
/* Indicates whether or not the I2C bus is busy. This function returns an indication of whether or not the I2C bus is busy. This function can be used in a multi-master environment to determine if another master is currently using the bus. */ xtBoolean xI2CMasterBusBusy(unsigned long ulBase)
{ xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE)); return ((xHWREG(I2C_STATUS)&0xF8) == 0xF8)? xfalse : xtrue; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This API gets the parameter1 to parameter7 settings of the step counter feature. */
uint16_t bma423_stepcounter_get_parameter(struct bma423_stepcounter_settings *setting, struct bma4_dev *dev)
/* This API gets the parameter1 to parameter7 settings of the step counter feature. */ uint16_t bma423_stepcounter_get_parameter(struct bma423_stepcounter_settings *setting, struct bma4_dev *dev)
{ uint8_t feature_config[BMA423_FEATURE_SIZE] = {0}; uint16_t *data_p = (uint16_t *)feature_config; uint16_t rslt = BMA4_OK; if (dev != NULL) { if (dev->chip_id == BMA423_CHIP_ID) { rslt = bma4_read_regs(BMA4_FEATURE_CONFIG_ADDR, feature_config, BMA423_FEATURE_SIZE, dev); if (rslt == BMA4_OK) { data_p = data_p + BMA423_STEP_CNTR_PARAM_OFFSET/2; extract_stepcounter_parameter(setting, data_p); } } else { rslt = BMA4_E_INVALID_SENSOR; } } else { rslt = BMA4_E_NULL_PTR; } return rslt; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Unless you're the timekeeping code, you should not be using this! */
static void timekeeper_setup_internals(struct clocksource *clock)
/* Unless you're the timekeeping code, you should not be using this! */ static void timekeeper_setup_internals(struct clocksource *clock)
{ cycle_t interval; u64 tmp; timekeeper.clock = clock; clock->cycle_last = clock->read(clock); tmp = NTP_INTERVAL_LENGTH; tmp <<= clock->shift; tmp += clock->mult/2; do_div(tmp, clock->mult); if (tmp == 0) tmp = 1; interval = (cycle_t) tmp; timekeeper.cycle_interval = interval; timekeeper.xtime_interval = (u64) interval * clock->mult; timekeeper.raw_interval = ((u64) interval * clock->mult) >> clock->shift; timekeeper.xtime_nsec = 0; timekeeper.shift = clock->shift; timekeeper.ntp_error = 0; timekeeper.ntp_error_shift = NTP_SCALE_SHIFT - clock->shift; timekeeper.mult = clock->mult; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* . Get or set fragmented interleave (SCTP_FRAGMENT_INTERLEAVE) (chapter and verse is quoted at sctp_setsockopt_fragment_interleave()) */
static int sctp_getsockopt_fragment_interleave(struct sock *sk, int len, char __user *optval, int __user *optlen)
/* . Get or set fragmented interleave (SCTP_FRAGMENT_INTERLEAVE) (chapter and verse is quoted at sctp_setsockopt_fragment_interleave()) */ static int sctp_getsockopt_fragment_interleave(struct sock *sk, int len, char __user *optval, int __user *optlen)
{ int val; if (len < sizeof(int)) return -EINVAL; len = sizeof(int); val = sctp_sk(sk)->frag_interleave; if (put_user(len, optlen)) return -EFAULT; if (copy_to_user(optval, &val, len)) return -EFAULT; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* HPF or SLOPE filter selection on wake-up and Activity/Inactivity functions.. */
int32_t lsm6dsl_xl_hp_path_internal_get(stmdev_ctx_t *ctx, lsm6dsl_slope_fds_t *val)
/* HPF or SLOPE filter selection on wake-up and Activity/Inactivity functions.. */ int32_t lsm6dsl_xl_hp_path_internal_get(stmdev_ctx_t *ctx, lsm6dsl_slope_fds_t *val)
{ lsm6dsl_tap_cfg_t tap_cfg; int32_t ret; ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t*)&tap_cfg, 1); switch (tap_cfg.slope_fds) { case LSM6DSL_USE_SLOPE: *val = LSM6DSL_USE_SLOPE; break; case LSM6DSL_USE_HPF: *val = LSM6DSL_USE_HPF; break; default: *val = LSM6DSL_HP_PATH_ND; break; } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
void GPIOPinIntClear(unsigned long ulPort, unsigned char ucPins)
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */ void GPIOPinIntClear(unsigned long ulPort, unsigned char ucPins)
{ ASSERT(GPIOBaseValid(ulPort)); HWREG(ulPort + GPIO_O_ICR) = ucPins; }
watterott/WebRadio
C++
null
71
/* Insert one pre-fetched key into the Unicode FIFO buffer. */
BOOLEAN UnicodeFiFoInsertOneKey(TERMINAL_DEV *TerminalDevice, UINT16 Input)
/* Insert one pre-fetched key into the Unicode FIFO buffer. */ BOOLEAN UnicodeFiFoInsertOneKey(TERMINAL_DEV *TerminalDevice, UINT16 Input)
{ UINT8 Tail; Tail = TerminalDevice->UnicodeFiFo->Tail; ASSERT (Tail < FIFO_MAX_NUMBER + 1); if (IsUnicodeFiFoFull (TerminalDevice)) { return FALSE; } TerminalDevice->UnicodeFiFo->Data[Tail] = Input; TerminalDevice->UnicodeFiFo->Tail = (UINT8)((Tail + 1) % (FIFO_MAX_NUMBER + 1)); return TRUE; }
tianocore/edk2
C++
Other
4,240
/* Post operation attributes are printed if vflag >= 1 */
static const uint32_t * parse_post_op_attr(netdissect_options *, const uint32_t *, int)
/* Post operation attributes are printed if vflag >= 1 */ static const uint32_t * parse_post_op_attr(netdissect_options *, const uint32_t *, int)
{ ND_TCHECK(dp[0]); if (!EXTRACT_32BITS(&dp[0])) return (dp + 1); dp++; if (verbose) { return parsefattr(ndo, dp, verbose, 1); } else return (dp + (NFSX_V3FATTR / sizeof (uint32_t))); trunc: return (NULL); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUint64ToUint8(IN UINT64 Operand, OUT UINT8 *Result)
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeUint64ToUint8(IN UINT64 Operand, OUT UINT8 *Result)
{ RETURN_STATUS Status; if (Result == NULL) { return RETURN_INVALID_PARAMETER; } if (Operand <= MAX_UINT8) { *Result = (UINT8)Operand; Status = RETURN_SUCCESS; } else { *Result = UINT8_ERROR; Status = RETURN_BUFFER_TOO_SMALL; } return Status; }
tianocore/edk2
C++
Other
4,240
/* This call triggers the elimination of storage associated with the transport classdev. Note: all it really does is relinquish a reference to the classdev. The memory will not be freed until the last reference goes to zero. Note also that the classdev retains a reference count on dev, so dev too will remain for as long as the transport class device remains around. */
void transport_destroy_device(struct device *dev)
/* This call triggers the elimination of storage associated with the transport classdev. Note: all it really does is relinquish a reference to the classdev. The memory will not be freed until the last reference goes to zero. Note also that the classdev retains a reference count on dev, so dev too will remain for as long as the transport class device remains around. */ void transport_destroy_device(struct device *dev)
{ attribute_container_remove_device(dev, transport_destroy_classdev); }
robutest/uclinux
C++
GPL-2.0
60
/* Xvid's default 2-pass doesn't allow us to create data as we need to, so this section spends time replacing the first pass plugin so we can write statistic information as libavcodec requests in. We have another kludge that allows us to pass data to the second pass in Xvid without a custom rate-control plugin. Initializes the two-pass plugin and context. */
static int xvid_ff_2pass_create(xvid_plg_create_t *param, void **handle)
/* Xvid's default 2-pass doesn't allow us to create data as we need to, so this section spends time replacing the first pass plugin so we can write statistic information as libavcodec requests in. We have another kludge that allows us to pass data to the second pass in Xvid without a custom rate-control plugin. Initializes the two-pass plugin and context. */ static int xvid_ff_2pass_create(xvid_plg_create_t *param, void **handle)
{ struct xvid_ff_pass1 *x = (struct xvid_ff_pass1 *)param->param; char *log = x->context->twopassbuffer; if( log == NULL ) return XVID_ERR_FAIL; log[0] = 0; snprintf(log, BUFFER_REMAINING(log), "# ffmpeg 2-pass log file, using xvid codec\n"); snprintf(BUFFER_CAT(log), BUFFER_REMAINING(log), "# Do not modify. libxvidcore version: %d.%d.%d\n\n", XVID_VERSION_MAJOR(XVID_VERSION), XVID_VERSION_MINOR(XVID_VERSION), XVID_VERSION_PATCH(XVID_VERSION)); *handle = x->context; return 0; }
DC-SWAT/DreamShell
C++
null
404
/* Copy data from "real" memory space to IO memory space. This needs to be optimized. */
void _memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
/* Copy data from "real" memory space to IO memory space. This needs to be optimized. */ void _memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
{ const unsigned char *f = from; while (count) { count--; writeb(*f, to); f++; to++; } }
robutest/uclinux
C++
GPL-2.0
60