code stringlengths 20 1.36k | prompt stringlengths 57 685 |
|---|---|
{
const char *z;
char *cpy;
if( y==0 ) return 0;
z = Strsafe_find(y);
if( z==0 && (cpy=(char *)malloc( lemonStrlen(y)+1 ))!=0 ){
lemon_strcpy(cpy,y);
z = cpy;
Strsafe_insert(z);
}
MemoryCheck(z);
return z;
} | /* All code in this file has been automatically generated from a specification in the file "table.q" by the associative array code building program "aagen". Do not edit this file! Instead, edit the specification file, then rerun aagen. Code for processing tables in the LEMON parser generator. */
const char * Strsafe(c... |
{
u8 reg5b;
u32 reg5c;
int tries;
for(tries = 0; tries < 0x5000; tries++) {
udelay(50);
pci_read_config_byte(dev, 0x5b, ®5b);
if (reg5b & 0x80) {
for(tries = 0; tries < 0x1000; tries ++) {
pci_read_config_byte(dev, 0x5b, ®5b);
if ((reg5b & 0x80) == 0)
return 0;
}
pci_read_config_dw... | /* Perform a calibration cycle on the HPT37x DPLL. Returns 1 if this succeeds */
static int hpt37x_calibrate_dpll(struct pci_dev *dev) |
{
struct mpath_node *node;
struct hlist_node *p;
int i;
int j = 0;
for_each_mesh_entry(mesh_paths, p, node, i) {
if (sdata && node->mpath->sdata != sdata)
continue;
if (j++ == idx) {
if (MPATH_EXPIRED(node->mpath)) {
spin_lock_bh(&node->mpath->state_lock);
if (MPATH_EXPIRED(node->mpath))
nod... | /* Locking: must be called within a read rcu section. */
struct mesh_path* mesh_path_lookup_by_idx(int idx, struct ieee80211_sub_if_data *sdata) |
{
if (!AirpcapLoaded) return FALSE;
return g_PAirpcapSetDecryptionState(ah,Enable);
} | /* Airpcap wrapper, used to set the decryption enabling of an airpcap adapter */
gboolean airpcap_if_set_decryption_state(PAirpcapHandle ah, AirpcapDecryptionState Enable) |
{
uint32_t words = size >> 2;
if (size & 0b11) {
words++;
}
Wait_SPI_Idle(chip);
SPI(0).ADDR = (addr & 0x00FFFFFF) | (size << 24);
memcpy((void*)SPI(0).W, buf, words<<2);
__asm__ volatile("memw");
SPI_write_enable(chip);
SPI(0).CMD = SPI_CMD_PP;
while (SPI(0).CMD) {}
} | /* if (to_qio == true) { spi_flash_switch_to_qio_raw(); } } Low level SPI flash write. Write block of data up to 64 bytes. */
static void IRAM spi_write_data(sdk_flashchip_t *chip, uint32_t addr, uint8_t *buf, uint32_t size) |
{
n_tty_flush_buffer(tty);
if (tty->read_buf) {
kfree(tty->read_buf);
tty->read_buf = NULL;
}
if (tty->echo_buf) {
kfree(tty->echo_buf);
tty->echo_buf = NULL;
}
} | /* Called from the terminal layer when this line discipline is being shut down, either because of a close or becsuse of a discipline change. The function will not be called while other ldisc methods are in progress. */
static void n_tty_close(struct tty_struct *tty) |
{
struct v4l2_captureparm *cp = &parms->parm.capture;
unsigned char clkrc;
int ret;
if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
ret = ov7670_read(sd, REG_CLKRC, &clkrc);
if (ret < 0)
return ret;
memset(cp, 0, sizeof(struct v4l2_captureparm));
cp->capability = V4L2_CAP_TIMEPERFRAME;
cp->... | /* Implement G/S_PARM. There is a "high quality" mode we could try to do someday; for now, we just do the frame rate tweak. */
static int ov7670_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms) |
{
FLASH_SR |= FLASH_SR_ERSERR;
} | /* Clear the Erase Sequence Error Flag.
This flag is set when an erase operation is performed with control register has not been correctly set. */
void flash_clear_erserr_flag(void) |
{
unsigned long flags = 0;
irda_queue_t* entry;
spin_lock_irqsave(&hashbin->hb_spinlock, flags);
entry = (irda_queue_t* ) hashbin_find( hashbin, hashv, name );
if(entry) {
hashbin->hb_current = entry;
*pnext = hashbin_get_next( hashbin );
} else
*pnext = NULL;
spin_unlock_irqrestore(&hashbin->hb_spinlock, ... | /* This function allow to do concurrent enumerations without the need to lock over the whole session, because the caller keep the context of the search. On the other hand, it might fail and return NULL if the entry is removed. - Jean II */
void* hashbin_find_next(hashbin_t *hashbin, long hashv, const char *name, void ... |
{
lv_ll_node_t * n_new;
n_new = lv_mem_alloc(ll_p->n_size + LL_NODE_META_SIZE);
if(n_new != NULL) {
node_set_prev(ll_p, n_new, NULL);
node_set_next(ll_p, n_new, ll_p->head);
if(ll_p->head != NULL) {
node_set_prev(ll_p, ll_p->head, n_new);
}
ll_p->head = n_... | /* Add a new head to a linked list */
void* _lv_ll_ins_head(lv_ll_t *ll_p) |
{
LIST_ENTRY *Entry;
MNP_INSTANCE_DATA *Instance;
NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);
NET_LIST_FOR_EACH (Entry, &MnpServiceData->ChildrenList) {
Instance = NET_LIST_USER_STRUCT (Entry, MNP_INSTANCE_DATA, InstEntry);
NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_... | /* Deliver the received packet for the instances belonging to the MnpServiceData. */
VOID MnpDeliverPacket(IN MNP_SERVICE_DATA *MnpServiceData) |
{
i2s->IEN &= ~u32Mask;
} | /* This function disables the interrupt according to the mask parameter. */
void I2S_DisableInt(I2S_T *i2s, uint32_t u32Mask) |
{
UINT32 TotalSize;
if (!AmlIsNameString (Root, ParentPrefix, SegCount)) {
ASSERT (0);
return 0;
}
TotalSize = Root + ParentPrefix;
TotalSize += (SegCount == 0) ? 1 : (SegCount * AML_NAME_SEG_SIZE);
TotalSize += (SegCount > 2) ? 2 : ((SegCount == 2) ? 1 : 0);
return TotalSize;
} | /* Compute the AML NameString/path size from NameString information (Root, ParentPrefix, SegCount). */
UINT32 EFIAPI AmlComputeNameStringSize(IN UINT32 Root, IN UINT32 ParentPrefix, IN UINT32 SegCount) |
{
return InternalSaveMmioWrite8ValueToBootScript (Address, MmioBitFieldRead8 (Address, StartBit, EndBit));
} | /* If 8-bit MMIO register operations are not supported, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
UINT8 EFIAPI S3MmioBitFieldRead8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit) |
{
unsigned long ulInt;
ASSERT(SSIBaseValid(ulBase));
ulInt = SSIIntNumberGet(ulBase);
IntDisable(ulInt);
IntUnregister(ulInt);
} | /* Unregisters an interrupt handler for the synchronous serial interface. */
void SSIIntUnregister(unsigned long ulBase) |
{
u32 status;
status = readl(®s->outbound_intr_status);
if (!(status & MFI_GEN2_ENABLE_INTERRUPT_MASK))
return 1;
writel(status, ®s->outbound_doorbell_clear);
readl(®s->outbound_intr_status);
return 0;
} | /* megasas_clear_interrupt_gen2 - Check & clear interrupt @regs: MFI register set */
static int megasas_clear_intr_gen2(struct megasas_register_set __iomem *regs) |
{
xASSERT(ulBase == SPI0_BASE);
return ((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_TX_FULL)? xtrue : xfalse);
} | /* Check the status of the Tx buffer of the specified SPI port. */
xtBoolean SPIIsTxFull(unsigned long ulBase) |
{
u_short st = inpw(PLC(PB,PL_INTR_EVENT)) ;
plc_irq(smc,PB,st) ;
} | /* interrupt source= plc1 this function is called in nwfbisr.asm */
void plc1_irq(struct s_smc *smc) |
{
unsigned long *addr;
if (regno == PT_USP)
addr = &task->thread.usp;
else if (regno < ARRAY_SIZE(regoff))
addr = (unsigned long *)(task->thread.esp0 + regoff[regno]);
else
return 0;
return *addr;
} | /* Get contents of register REGNO in task TASK. */
static long get_reg(struct task_struct *task, int regno) |
{
struct ifmcaddr6 *i;
ipv6_mc_down(idev);
__ipv6_dev_mc_dec(idev, &in6addr_linklocal_allnodes);
if (idev->cnf.forwarding)
__ipv6_dev_mc_dec(idev, &in6addr_linklocal_allrouters);
write_lock_bh(&idev->lock);
while ((i = idev->mc_list) != NULL) {
idev->mc_list = i->next;
write_unlock_bh(&idev->lock);
igmp6_... | /* Device is about to be destroyed: clean up. */
void ipv6_mc_destroy_dev(struct inet6_dev *idev) |
{
lsm6dso_wake_up_dur_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t*)®, 1);
if (ret == 0) {
reg.wake_ths_w = (uint8_t)val;
ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t*)®, 1);
}
return ret;
} | /* Weight of 1 LSB of wakeup threshold. 0: 1 LSB =FS_XL / 64 1: 1 LSB = FS_XL / 256. */
int32_t lsm6dso_wkup_ths_weight_set(lsm6dso_ctx_t *ctx, lsm6dso_wake_ths_w_t val) |
{
pgd_t *pgd = pgd_offset_k(address);
pud_t *pud;
pmd_t *pmd;
*level = PG_LEVEL_NONE;
if (pgd_none(*pgd))
return NULL;
pud = pud_offset(pgd, address);
if (pud_none(*pud))
return NULL;
*level = PG_LEVEL_1G;
if (pud_large(*pud) || !pud_present(*pud))
return (pte_t *)pud;
pmd = pmd_offset(pud, address);
i... | /* Note: We return pud and pmd either when the entry is marked large or when the present bit is not set. Otherwise we would return a pointer to a nonexisting mapping. */
pte_t* lookup_address(unsigned long address, unsigned int *level) |
{
if(huart->Instance==USART1)
{
__HAL_RCC_USART1_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
HAL_NVIC_DisableIRQ(USART1_IRQn);
}
else if(huart->Instance==USART2)
{
__HAL_RCC_USART2_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
}
else if(huart->Instanc... | /* UART MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart) |
{
return (BOOLEAN)BN_is_word (Bn, Num);
} | /* Checks if Big Number equals to the given Num. */
BOOLEAN EFIAPI BigNumIsWord(IN CONST VOID *Bn, IN UINTN Num) |
{
cairo_status_t status;
if (entry->size && ! cache->freeze_count)
_cairo_cache_shrink_to_accommodate (cache, entry->size);
status = _cairo_hash_table_insert (cache->hash_table,
(cairo_hash_entry_t *) entry);
if (unlikely (status))
return status;
cache->size += entry->size;
return C... | /* Return value: CAIRO_STATUS_SUCCESS if successful or CAIRO_STATUS_NO_MEMORY if insufficient memory is available. */
cairo_status_t _cairo_cache_insert(cairo_cache_t *cache, cairo_cache_entry_t *entry) |
{
struct cdrom_info *info = drive->driver_data;
if (!rq->errors)
info->write_timeout = jiffies + ATAPI_WAIT_WRITE_BUSY;
rq->errors = 1;
if (time_after(jiffies, info->write_timeout))
return 0;
else {
struct request_queue *q = drive->queue;
unsigned long flags;
spin_lock_irqsave(q->queue_lock, flags);
bl... | /* returns: 0 failed (write timeout expired) 1 success */
static int ide_cd_breathe(ide_drive_t *drive, struct request *rq) |
{
uint32_t i = 0, j = 0;
uint8_t m = 0;
uint8_t bytesPerWord = bitWidth / 8U;
uint32_t data = 0;
for (i = 0; i < size / bytesPerWord; i++)
{
for (j = channel; j <= endChannel; j++)
{
if (IS_SAI_FLAG_SET((1UL << j), channelMask))
{
... | /* Receive a piece of data in non-blocking way. */
static void SAI_ReadNonBlocking(I2S_Type *base, uint32_t channel, uint32_t channelMask, uint32_t endChannel, uint8_t bitWidth, uint8_t *buffer, uint32_t size) |
{
struct proc_dir_entry *ent;
int found = 0;
spin_lock(&proc_subdir_lock);
for (ent = de->subdir; ent != NULL; ent = ent->next) {
if (strcmp(ent->name, name) == 0) {
found = 1;
break;
}
}
spin_unlock(&proc_subdir_lock);
return found;
} | /* Various dodgy firmware might give us nodes and/or properties with conflicting names. That's generally ok, except for exporting via /proc, so munge names here to ensure they're unique. */
static int duplicate_name(struct proc_dir_entry *de, const char *name) |
{
struct svcxprt_rdma *rdma =
container_of(xprt, struct svcxprt_rdma, sc_xprt);
dprintk("svc: svc_rdma_detach(%p)\n", xprt);
rdma_disconnect(rdma->sc_cm_id);
} | /* At a minimum one references should still be held. */
static void svc_rdma_detach(struct svc_xprt *xprt) |
{
guint32 packetid;
packetid = tvb_get_guint8(buffer, offset+2) << 14;
packetid += tvb_get_guint8(buffer, offset+1) << 6;
packetid += tvb_get_guint8(buffer, offset) & 63;
proto_tree_add_uint(tree, hf_knet_packetid, buffer, 0, 3, packetid);
return packetid;
} | /* dissect_packetid is a utility function which calculates the packets Packet ID from the data. Packet ID is a field located in the datagram header. */
static guint32 dissect_packetid(tvbuff_t *buffer, int offset, proto_tree *tree) |
{
if (s_tempmon.alarmCallback)
{
float currentTemp = tempmon_get_temp();
s_tempmon.alarmCallback(currentTemp);
}
BF_SET(PMU_MISC1, IRQ_TEMPSENSE);
} | /* Interrupt handler for the over-temperature alarm.
This interrupt handler gets the current die temperature and calls the alarm callback function that was previously installed with tempmon_set_alarm(). If for some reason there is no alarm callback set, this routine does nothing except clear the IRQ. */
static void t... |
{
ASSERT (FALSE);
return MiscChassisTypeUnknown;
} | /* Gets the type of chassis for the system. */
MISC_CHASSIS_TYPE EFIAPI OemGetChassisType(VOID) |
{
assert(config != NULL);
(void)memset(config, 0, sizeof(*config));
config->rtcCalEnable = false;
config->rtcCalValue = 0U;
config->periodicInterruptFreq = 0U;
} | /* The default values are as follows. code config->rtccalenable = false; config->rtccalvalue = 0U; config->PIFreq = 0U; endcode param config Pointer to the user's SNVS configuration structure. */
void SNVS_HP_RTC_GetDefaultConfig(snvs_hp_rtc_config_t *config) |
{
int byte_count = 1;
if(tvb_get_guint8(tvb, offset) & 0x80)
byte_count = 2;
if(tvb_get_guint8(tvb, offset+1) & 0x80)
byte_count = 4;
return byte_count;
} | /* counts length of the variable length encoded field */
static int count_vle_bytes(tvbuff_t *tvb, int offset) |
{
char c;
while ((c = *s++) != del) {
if (c == '\\' && *s == 'x') {
s++;
if (!isxdigit(*s++))
return NULL;
if (!isxdigit(*s++))
return NULL;
}
}
return s;
} | /* parses and copies one argument enclosed in del from *sp to *dp, recognising the \x special. returns pointer to the copied argument or NULL in case of an error (and sets err) or null argument length. */
static char* scanarg(char *s, char del) |
{
ASSERT((v & xfs_mask64hi(9)) == 0);
r->l0 = (r->l0 & (xfs_bmbt_rec_base_t) xfs_mask64hi(1)) |
((xfs_bmbt_rec_base_t)v << 9) |
(r->l0 & (xfs_bmbt_rec_base_t)xfs_mask64lo(9));
} | /* Set the startoff field in a bmap extent record. */
void xfs_bmbt_set_startoff(xfs_bmbt_rec_host_t *r, xfs_fileoff_t v) |
{
u8 cb_idx;
last_drv_idx = MPT_MAX_PROTOCOL_DRIVERS;
for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) {
if (MptCallbacks[cb_idx] == NULL) {
MptCallbacks[cb_idx] = cbfunc;
MptDriverClass[cb_idx] = dclass;
MptEvHandlers[cb_idx] = NULL;
last_drv_idx = cb_idx;
break;
}
}
return last_drv_... | /* Returns u8 valued "handle" in the range (and S.O.D. order) {N,...,7,6,5,...,1} if successful. A return value of MPT_MAX_PROTOCOL_DRIVERS (including zero!) should be considered an error by the caller. */
u8 mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass) |
{
flush_tlb_mm(vma->vm_mm);
} | /* Currently, for range flushing, we just do a full mm flush. This should be optimized based on a threshold on the size of the range, since some implementation can stack multiple tlbivax before a tlbsync but for now, we keep it that way */
void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned ... |
{
ieee11073_g_phdc_metadata_out.opaquedata = ieee11073_g_opaquedata_out;
ieee11073_g_phdc_metadata_out.opaque_size =
IEEE11073_LGT_OPAQUEDATA_OUT;
ieee11073_g_phdc_metadata_out.metadata = ieee11073_g_metadata_out;
ieee11073_g_phdc_metadata_out.metadata_size =
IEEE11073_LGT_METADATA_OUT;
if (!udi_phdc_waitdat... | /* Start the reception of data on communication line. */
static bool ieee11073_enable_reception(void) |
{
unsigned long offset, addr = (unsigned long)from;
int type = in_nmi() ? KM_NMI : KM_IRQ0;
unsigned long size, len = 0;
struct page *page;
void *map;
int ret;
do {
ret = __get_user_pages_fast(addr, 1, 0, &page);
if (!ret)
break;
offset = addr & (PAGE_SIZE - 1);
size = min(PAGE_SIZE - offset, n - len)... | /* best effort, GUP based copy_from_user() that assumes IRQ or NMI context */
static unsigned long copy_from_user_nmi(void *to, const void __user *from, unsigned long n) |
{
unsigned long ulEvent = 0;
ulEvent = xHWREG(DMA0_BASE + DMA_DSR_BCR) & 0x71000000;
xHWREG(DMA3_BASE + DMA_DSR_BCR) |= DMA_DSR_BCR_DONE;
if(g_psDMAChannelAssignTable[3].pfnDMAChannelHandlerCallback != 0)
{
g_psDMAChannelAssignTable[3].pfnDMAChannelHandlerCallback(0,0,ulEvent,0);
}
} | /* The interrupt handler for DMA interrupts from the memory channel. */
void DMA3IntHandler(void) |
{
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: ",
BACnetReinitialize... | /* 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_in... |
{
s32 Status;
u16 BlkSize;
BlkSize = XSDPS_BLK_SIZE_512_MASK;
XSdPs_SetupWriteDma(InstancePtr, BlkCnt, BlkSize, Buff);
if (BlkCnt == 1U) {
Status = XSdPs_CmdTransfer(InstancePtr, CMD24, Arg, BlkCnt);
if (Status != XST_SUCCESS) {
Status = XST_FAILURE;
goto RETU... | /* This function performs SD write in polled mode. */
s32 XSdPs_Write(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, const u8 *Buff) |
{
sys_mutex_lock(&g_lwip_protect_mutex);
return (sys_prot_t) 1;
} | /* sys_arch_protect() is only required if your port is supporting an operating system. */
sys_prot_t sys_arch_protect(void) |
{
struct iotlb_lock l;
clk_enable(obj->clk);
l.base = 0;
l.vict = 0;
iotlb_lock_set(obj, &l);
iommu_write_reg(obj, 1, MMU_GFLUSH);
clk_disable(obj->clk);
} | /* flush_iotlb_all - Clear all iommu tlb entries @obj: target iommu */
void flush_iotlb_all(struct iommu *obj) |
{
struct sk_buff *skb;
unsigned char *dptr;
int len;
len = AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN + 3;
if ((skb = alloc_skb(len, GFP_ATOMIC)) == NULL)
return;
skb_reserve(skb, AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN);
dptr = skb_put(skb, ROSE_MIN_LEN + 3);
*dptr++ = AX25_P_ROSE;
*dptr++ =... | /* This routine is called when a Restart Request is needed */
static void rose_transmit_restart_request(struct rose_neigh *neigh) |
{
if ((whitelist->addr_count != 0) || (whitelist->irk_count != 0))
{
return true;
}
return false;
} | /* Function for checking that the whitelist has entries. */
static bool whitelist_has_entries(ble_gap_whitelist_t const *whitelist) |
{
int err = -ENOMEM;
pte_t *pte;
spinlock_t *ptl;
pte = get_locked_pte(mm, addr, &ptl);
if (!pte)
goto out;
if (!pte_none(*pte))
zap_pte(mm, vma, addr, pte);
set_pte_at(mm, addr, pte, pgoff_to_pte(pgoff));
pte_unmap_unlock(pte, ptl);
err = 0;
out:
return err;
} | /* Install a file pte to a given virtual memory address, release any previously existing mapping. */
static int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long pgoff, pgprot_t prot) |
{
SDIO_CmdInitStruct->SDIO_Argument = 0x00;
SDIO_CmdInitStruct->SDIO_CmdIndex = 0x00;
SDIO_CmdInitStruct->SDIO_Response = SDIO_Response_No;
SDIO_CmdInitStruct->SDIO_Wait = SDIO_Wait_No;
} | /* Fills each SDIO_CmdInitStruct member with its default value. */
void SDIO_CmdStructInit(SDIO_CmdInitTypeDef *SDIO_CmdInitStruct) |
{
unsigned element_size;
if (fifo_id == 0) {
element_size = FDCAN_RXESC(canport) >> FDCAN_RXESC_F0DS_SHIFT;
} else {
element_size = FDCAN_RXESC(canport) >> FDCAN_RXESC_F1DS_SHIFT;
}
return 8 + fdcan_dlc_to_length((element_size & FDCAN_RXESC_F0DS_MASK) | 0x8);
} | /* Obtains value of FIFO entry length. This value covers both fixed-size frame header block and payload buffer. User can configure payload buffer size individually for each FIFO and designated RX buffer. */
unsigned fdcan_get_fifo_element_size(uint32_t canport, unsigned fifo_id) |
{
mask &= _BLOCKABLE;
spin_lock_irq(¤t->sighand->siglock);
current->saved_sigmask = current->blocked;
siginitset(¤t->blocked, mask);
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
current->state = TASK_INTERRUPTIBLE;
schedule();
set_restore_sigmask();
return -ERESTARTNOHAND;
} | /* Atomically swap in the new signal mask, and wait for a signal. */
asmlinkage int sys_sigsuspend(old_sigset_t mask, unsigned long r5, unsigned long r6, unsigned long r7, struct pt_regs __regs) |
{
*mode = sensor->mod;
return true;
} | /* Get a sensor mode.
These execution states are not supported in all devices. The function return value will indicate whether or not the request could be processed. The result of the request, when supported, is device dependent. */
bool sensor_get_state(sensor_t *sensor, sensor_state_t *mode) |
{
ASSERT(_UARTBaseValid(ui32Base));
HWREG(ui32Base + UART_O_CTL) |= UART_CTL_LBE;
} | /* Enables internal loopback mode for a UART port */
void UARTLoopbackEnable(uint32_t ui32Base) |
{
WARN_ON(packet->complete_routine != NULL);
packet->complete_routine = routine;
packet->complete_data = data;
return;
} | /* Typically, the complete @routine is responsible to call hpsb_free_packet(). */
void hpsb_set_packet_complete_task(struct hpsb_packet *packet, void(*routine)(void *), void *data) |
{
if (!(cctl & PL080_CONTROL_DST_INCR)) {
*mbus = &bd->dstbus;
*sbus = &bd->srcbus;
} else if (!(cctl & PL080_CONTROL_SRC_INCR)) {
*mbus = &bd->srcbus;
*sbus = &bd->dstbus;
} else {
if (bd->dstbus.buswidth >= bd->srcbus.buswidth) {
*mbus = &bd->dstbus;
*sbus = &bd->srcbus;
} else {
*mbus = &bd->... | /* Autoselect a master bus to use for the transfer. Slave will be the chosen as victim in case src & dest are not similarly aligned. i.e. If after aligning masters address with width requirements of transfer (by sending few byte by byte data), slave is still not aligned, then its width will be reduced to BYTE. */
stati... |
{
at91sam9260_initialize(10000000);
at91_register_uart(0, 0, 0);
at91_set_serial_console(0);
} | /* You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
static void __init cam60_map_io(void) |
{
struct tsb *tsb = NULL;
char *sense = NULL;
if (scsw_is_tm(&irb->scsw) && (irb->scsw.tm.fcxs == 0x01)) {
if (irb->scsw.tm.tcw)
tsb = tcw_get_tsb((struct tcw *)(unsigned long)
irb->scsw.tm.tcw);
if (tsb && tsb->length == 64 && tsb->flags)
switch (tsb->flags & 0x07) {
case 1:
sense = tsb->tsa... | /* In command mode and transport mode we need to look for sense data in different places. The sense data itself is allways an array of 32 bytes, so we can unify the sense data access for both modes. */
char* dasd_get_sense(struct irb *irb) |
{
return USBPD_PE_SVDM_RequestSpecific(PortNum, SOPType, SVDM_SPECIFIC_2, SVID);
} | /* Request the PE to send a Display Port Config. */
USBPD_StatusTypeDef USBPD_DPM_RequestDisplayPortConfig(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, uint16_t SVID) |
{
pFlashExeCmdFct pExecCommandFct;
blt_int8u cnt;
for (cnt=0; cnt<(sizeof(flashExecCmd)/sizeof(flashExecCmd[0])); cnt++)
{
flashExecCmdRam[cnt] = flashExecCmd[cnt];
}
pExecCommandFct = (pFlashExeCmdFct)((void *)flashExecCmdRam);
pExecCommandFct();
} | /* Executes the command. The actual code for the command execution is stored as location independant machine code in array flashExecCmd. The contents of this array are temporarily copied to RAM. This way the function can be executed from RAM avoiding problem when try to perform a flash operation on the same flash block... |
{
struct xl_private *xl_priv=netdev_priv(dev);
u8 __iomem * xl_mmio = xl_priv->xl_mmio ;
unsigned long t;
writew( GLOBAL_RESET, xl_mmio + MMIO_COMMAND ) ;
t=jiffies;
while (readw(xl_mmio + MMIO_INTSTATUS) & INTSTAT_CMD_IN_PROGRESS) {
if (time_after(jiffies, t + 40 * HZ)) {
printk(KERN_ERR "3COM 3C359 Vel... | /* This is ruthless, it doesn't care what state the card is in it will completely reset the adapter. */
static void xl_reset(struct net_device *dev) |
{
return (ifindex & (SEL_NETIF_HASH_SIZE - 1));
} | /* Description: This is the hashing function for the network interface table, it returns the bucket number for the given interface. */
static u32 sel_netif_hashfn(int ifindex) |
{
ASSERT(ui32Match == 0);
return (HWREG(HIB_RTCM0));
} | /* Gets the value of the requested RTC match register. */
uint32_t HibernateRTCMatchGet(uint32_t ui32Match) |
{
InternalX86Delay (
(UINT32)DivU64x32 (
MultU64x64 (
InternalX86GetTimerFrequency (),
MicroSeconds
),
1000000u
)
);
return MicroSeconds;
} | /* Stalls the CPU for the number of microseconds specified by MicroSeconds. */
UINTN EFIAPI MicroSecondDelay(IN UINTN MicroSeconds) |
{
while (InterlockedCompareExchange32 (
(UINT32 *)ApStartupSignalBuffer,
WAKEUP_AP_SIGNAL,
WAKEUP_AP_SIGNAL
) != 0)
{
CpuPause ();
}
} | /* Wait for AP wakeup and write AP start-up signal till AP is waken up. */
VOID WaitApWakeup(IN volatile UINT32 *ApStartupSignalBuffer) |
{
int i;
for (i = 0; i < banks; i++) {
m->status = mce_rdmsrl(MSR_IA32_MCx_STATUS(i));
if (mce_severity(m, tolerant, msg) >= MCE_PANIC_SEVERITY)
return 1;
}
return 0;
} | /* Do a quick check if any of the events requires a panic. This decides if we keep the events around or clear them. */
static int mce_no_way_out(struct mce *m, char **msg) |
{
UINT64 Data64;
UINT32 Data32;
UINT8 *Ptr;
if (ADDRESS_IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) {
return *(UINT64 *)(VmPtr->Ip + Offset);
}
Ptr = (UINT8 *)&Data64;
Data32 = VmReadCode32 (VmPtr, Offset);
*(UINT32 *)Ptr = Data32;
Ptr += sizeof (Data3... | /* This routine provides the ability to read raw unsigned data from the code stream. */
UINT64 VmReadCode64(IN VM_CONTEXT *VmPtr, IN UINT32 Offset) |
{
struct onenand_chip *this = mtd->priv;
void __iomem *bufferram;
bufferram = this->base + area;
bufferram += onenand_bufferram_offset(mtd, area);
this->mmcontrol(mtd, ONENAND_SYS_CFG1_SYNC_READ);
if (ONENAND_CHECK_BYTE_ACCESS(count)) {
unsigned short word;
count--;
word = this->read_word(bufferram + offset... | /* onenand_sync_read_bufferram - Read the bufferram area with Sync. Burst mode */
static int onenand_sync_read_bufferram(struct mtd_info *mtd, int area, unsigned char *buffer, int offset, size_t count) |
{
int i;
xGPIOSPinWrite(PE2, 1);
for(i = 0; i < 5; i++);
xGPIOSPinWrite(PE2, 0);
for(i = 0; i < 5; i++);
} | /* \breif This function is used to generate a falling edge, as the of Timer counting source. */
void EdgeGenerate(void) |
{
int irq_src = IRQ_SRC(irq);
int irq_idx = IRQ_IDX(irq);
int irq_bit = 1 << irq_idx;
if (irq_src == 1) {
return via1[vIFR] & irq_bit;
} else if (irq_src == 2) {
return via2[gIFR] & irq_bit;
} else if (irq_src == 7) {
return ~via2[gBufA] & irq_bit;
}
return 0;
} | /* Returns nonzero if an interrupt is pending on the given VIA/IRQ combination. */
int via_irq_pending(int irq) |
{
loff_t isize, left;
int ret;
isize = i_size_read(in->f_mapping->host);
if (unlikely(*ppos >= isize))
return 0;
left = isize - *ppos;
if (unlikely(left < len))
len = left;
ret = __generic_file_splice_read(in, ppos, pipe, len, flags);
if (ret > 0) {
*ppos += ret;
file_accessed(in);
}
return ret;
} | /* Description: Will read pages from given file and fill them into a pipe. Can be used as long as the address_space operations for the source implements a readpage() hook. */
ssize_t generic_file_splice_read(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags) |
{
Init();
while (1)
{
LedToggle();
}
return 0;
} | /* This is the entry point for the bootloader application and is called by the reset interrupt vector after the C-startup routines executed. */
int main(void) |
{
gd_eval_ledinit(LED1);
gd_eval_ledinit(LED2);
gd_eval_ledon(LED1);
gd_eval_keyinit(KEY_TAMPER, KEY_MODE_EXTI);
while (1);
} | /* main function
, V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */
int main(void) |
{
guint i;
for (i = 0; i < airpcap_if_selected->numSupportedChannels; i++) {
if (airpcap_if_selected->pSupportedChannels[i].Frequency == chan_freq) {
gtk_combo_box_set_active(GTK_COMBO_BOX(cb), i);
break;
}
}
} | /* Set the combo box entry string given a channel frequency */
void airpcap_channel_combo_set_by_frequency(GtkWidget *cb, guint chan_freq) |
{
iscsi_remove_session(session);
ISCSI_DBG_TRANS_SESSION(session, "Completing session destruction\n");
iscsi_free_session(session);
return 0;
} | /* Can be called by a LLD or iscsi_transport. There must not be any running connections. */
int iscsi_destroy_session(struct iscsi_cls_session *session) |
{
if (decinum % 5 == 0) {
deciden /= 5;
decinum /= 5;
}
while (decinum % 3 == 0 && deciden % 3 == 0) {
deciden /= 3;
decinum /= 3;
}
while (decinum % 2 == 0 && deciden % 2 == 0) {
decinum /= 2;
deciden /= 2;
}
while (deciden > 32) {
deciden /= 2;
decinum = (decinum + 1) / 2;
}
if (deciden == 32... | /* Turn 16bit ratios into best small ratio the chipset can grok */
static void pms_vertdeci(struct pms *dev, unsigned short decinum, unsigned short deciden) |
{
float kp, ki, kd;
ki = atof((char *)args);
kp = dev->controller->kp;
kd = dev->controller->kd / dev->controller->f_loop;
pid_set_constants(dev->controller, kp, ki, kd);
dev->param_array[PID_KI_INT] = dev->controller->ki;
dev->param_array[PID_KI_DEC] =
(uint32_t)(dev->controller->ki * 10000) % 10000;
return ... | /* Set integral constant, Ki, for the PID controller. */
int32_t cn0415_pid_set_ki(struct cn0415_dev *dev, uint8_t *args) |
{
__list_add(new, head->prev, head);
} | /* Insert a new entry before the specified head. This is useful for implementing queues. */
static void list_add_tail(struct list_head *new, struct list_head *head) |
{
EFI_STATUS Status;
PCI_ROOT_BRIDGE_INSTANCE *RootBridge;
UINT64 Translation;
Status = RootBridgeIoCheckParameter (
This,
MemOperation,
Width,
Address,
Count,
Buffer
);
if (EFI_ERROR ... | /* The Mem.Read(), and Mem.Write() functions enable a driver to access PCI controller registers in the PCI root bridge memory space. The memory operations are carried out exactly as requested. The caller is responsible for satisfying any alignment and memory width restrictions that a PCI Root Bridge on a platform might... |
{
if (i2c == I2C3)
{
RCM_EnableAPB1PeriphReset(RCM_APB1_PERIPH_I2C1);
RCM_DisableAPB1PeriphReset(RCM_APB1_PERIPH_I2C1);
}
else
{
RCM_EnableAPB1PeriphReset(RCM_APB1_PERIPH_I2C2);
RCM_DisableAPB1PeriphReset(RCM_APB1_PERIPH_I2C2);
}
i2c->SW = 0;
i2c->SW = 1;
... | /* Set I2C peripheral registers to their default reset values. */
void SCI2C_Reset(SCI2C_T *i2c) |
{
uint8_t *error, check_val;
check_val = strtol((char *)arg, (char **)&error, 16);
if(error == arg)
return FAILURE;
sprintf((char *)buff, "%x", check_val);
dev->sw_flash_buffer[CN0503_FLASH_RATM_IDX] = check_val;
return SUCCESS;
} | /* Update the RATMASK setting of the flash buffer. */
static int32_t cn0503_flash_write_ratmask(struct cn0503_dev *dev, uint8_t *arg, uint8_t *buff) |
{
sk->s_flags |= NL_MSG_PEEK;
} | /* Enable use of MSG_PEEK when reading from socket */
void nl_socket_enable_msg_peek(struct nl_sock *sk) |
{
int count = 0;
struct bonding *bond = to_bond(d);
if (bond->primary_slave)
count = sprintf(buf, "%s\n", bond->primary_slave->dev->name);
return count;
} | /* Show and set the primary slave. The store function is much simpler than bonding_store_slaves function because it only needs to handle one interface name. The bond must be a mode that supports a primary for this be set. */
static ssize_t bonding_show_primary(struct device *d, struct device_attribute *attr, char *buf... |
{
assert_param(IsAdcModule(ADCx));
assert_param(IsAdcValid(HighThreshold));
assert_param(IsAdcValid(LowThreshold));
ADCx->WDGHIGH = HighThreshold;
ADCx->WDGLOW = LowThreshold;
} | /* Configures the high and low thresholds of the analog watchdog. */
void ADC_ConfigAnalogWatchdogThresholds(ADC_Module *ADCx, uint16_t HighThreshold, uint16_t LowThreshold) |
{
struct iis3dhhc_data *iis3dhhc = dev->data;
const struct iis3dhhc_config *config = dev->config;
int16_t raw[3];
if (!config->int_gpio.port) {
return -ENOTSUP;
}
if (trig->chan == SENSOR_CHAN_ACCEL_XYZ) {
iis3dhhc->handler_drdy = handler;
iis3dhhc->trig_drdy = trig;
if (handler) {
iis3dhhc_acceleratio... | /* iis3dhhc_trigger_set - link external trigger to event data ready */
int iis3dhhc_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) |
{
int rv;
rv = gfs2_lm_withdraw(sdp,
"GFS2: fsid=%s: fatal: filesystem consistency error\n"
"GFS2: fsid=%s: function = %s, file = %s, line = %u\n",
sdp->sd_fsname,
sdp->sd_fsname, function, file, line);
return rv;
} | /* gfs2_consist_i - Flag a filesystem consistency error and withdraw Returns: -1 if this call withdrew the machine, 0 if it was already withdrawn */
int gfs2_consist_i(struct gfs2_sbd *sdp, int cluster_wide, const char *function, char *file, unsigned int line) |
{
struct pci_slot *tmp;
down_write(&pci_bus_sem);
list_for_each_entry(tmp, &slot->bus->slots, list) {
WARN_ON(tmp->number == slot_nr);
goto out;
}
slot->number = slot_nr;
out:
up_write(&pci_bus_sem);
} | /* The primary purpose of this interface is to allow callers who earlier created a placeholder slot in pci_create_slot() by passing a -1 as slot_nr, to update their struct pci_slot with the correct @slot_nr. */
void pci_renumber_slot(struct pci_slot *slot, int slot_nr) |
{
if (scsi_sg_count(cmd->Current_SCpnt))
dma_unmap_sg(lu->ud->ne->host->device.parent,
scsi_sglist(cmd->Current_SCpnt),
scsi_sg_count(cmd->Current_SCpnt),
cmd->Current_SCpnt->sc_data_direction);
list_move_tail(&cmd->list, &lu->cmd_orb_completed);
} | /* Unmaps the DMAs of a command and moves the command to the completed ORB list. Must be called with lu->cmd_orb_lock held. */
static void sbp2util_mark_command_completed(struct sbp2_lu *lu, struct sbp2_command_info *cmd) |
{
struct rpc_buffer *buf;
if (!buffer)
return;
buf = container_of(buffer, struct rpc_buffer, data);
free_page((unsigned long)buf);
} | /* Free the space allocated in the bc_alloc routine */
void bc_free(void *buffer) |
{
unsigned long ulCMRData;
unsigned long ulCNRData;
xASSERT(ulBase == PWMA_BASE);
xASSERT(((ulChannel >= 0) || (ulChannel <= 1)));
ulCNRData = (xHWREG(ulBase + PWM_CNR0 +(ulChannel * 12)));
ulCMRData = (xHWREG(ulBase + PWM_CMR0 +(ulChannel * 12)));
ulChannel = (ulCMRData + 1) * 100 / (ulCNRD... | /* Get the PWM duty of the PWM module.
The */
unsigned long xPWMDutyGet(unsigned long ulBase, unsigned long ulChannel) |
{
U32 *ptr;
ptr = GetEpCmdStatPtr(EPNum);
*ptr |= TOOGLE_RESET;
} | /* Reset USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */
void USBD_ResetEP(U32 EPNum) |
{
EFI_STATUS Status;
Status = gBS->LocateProtocol (
&gEdkiiMemoryProfileGuid,
NULL,
(VOID **)&mLibProfileProtocol
);
if (EFI_ERROR (Status)) {
mLibProfileProtocol = NULL;
}
return EFI_SUCCESS;
} | /* The constructor function initializes memory profile for DXE phase. */
EFI_STATUS EFIAPI MemoryProfileLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) |
{
SDL_Surface *surface;
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, depth,
Rmask, Gmask, Bmask, Amask);
if ( surface != NULL ) {
surface->flags |= SDL_PREALLOC;
surface->pixels = pixels;
surface->w = width;
surface->h = height;
surface->pitch = pitch;
SDL_SetClipRe... | /* Create an RGB surface from an existing memory buffer */
SDL_Surface* SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) |
{
return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);
} | /* If Alignment is not a power of two and Alignment is not zero, then ASSERT(). If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT(). */
VOID* EFIAPI AllocateAlignedRuntimePages(IN UINTN Pages, IN UINTN Alignment) |
{
UINTN Index;
UINT32 TotalMtrrCount;
UINT32 *CountPerType[5];
CountPerType[0] = UcCount;
CountPerType[1] = WtCount;
CountPerType[2] = WbCount;
CountPerType[3] = WpCount;
CountPerType[4] = WcCount;
for (Index = 0; Index < ARRAY_SIZE (CountPerType); Index++) {
*(CountPerType[Index]) = 0;
}
... | /* Generate random count of MTRRs for each cache type. */
VOID GenerateRandomMemoryTypeCombination(IN UINT32 TotalCount, OUT UINT32 *UcCount, OUT UINT32 *WtCount, OUT UINT32 *WbCount, OUT UINT32 *WpCount, OUT UINT32 *WcCount) |
{
do {
head = memq_peek(head, tail, mem);
if (head == NULL) {
return NULL;
}
head = head->next;
} while (n--);
return head;
} | /* Non-destructive peek of nth (zero indexed) element of queue. */
memq_link_t* memq_peek_n(memq_link_t *head, memq_link_t *tail, uint8_t n, void **mem) |
{
int len;
ubifs_err(c, "corruption at LEB %d:%d", lnum, offs);
len = c->leb_size - offs;
if (len > 8192)
len = 8192;
ubifs_err(c, "first %d bytes from LEB %d:%d", len, lnum, offs);
print_hex_dump("", DUMP_PREFIX_OFFSET, 32, 4, buf, len, 1);
} | /* ubifs_scanned_corruption - print information after UBIFS scanned corruption. */
void ubifs_scanned_corruption(const struct ubifs_info *c, int lnum, int offs, void *buf) |
{
unsigned int irq = (unsigned int) args;
rm9k_cpu_irq_enable(irq);
} | /* Performance counter interrupts are global on all processors. */
static void local_rm9k_perfcounter_irq_startup(void *args) |
{
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags;
if (!desc)
return;
raw_spin_lock_irqsave(&desc->lock, flags);
if (nest)
desc->status |= IRQ_NESTED_THREAD;
else
desc->status &= ~IRQ_NESTED_THREAD;
raw_spin_unlock_irqrestore(&desc->lock, flags);
} | /* The IRQ_NESTED_THREAD flag indicates that on request_threaded_irq() no separate interrupt thread should be created for the irq as the handler are called nested in the context of a demultiplexing interrupt handler thread. */
void set_irq_nested_thread(unsigned int irq, int nest) |
{
thread0 = thread0->thread_prev;
}
object = osRtxObject(thread0);
if (object != NULL) {
osRtxThreadListRemove(thread);
osRtxThreadListPut(object, thread);
}
} | /* Re-sort a Thread in linked Object list by Priority (Highest at Head). */
void osRtxThreadListSort(os_thread_t *thread) |
{
uint32_t ui32Base, ui32Shift;
ASSERT(((ui32PinConfig >> 16) & 0xff) < 18);
ASSERT(((ui32PinConfig >> 8) & 0xe3) == 0);
ui32Base = (ui32PinConfig >> 16) & 0xff;
ui32Base = g_pui32GPIOBaseAddrs[ui32Base];
ui32Shift = (ui32PinConfig >> 8) & 0xff;
HWREG(ui32Base + GPIO_O_PCTL) = ((HWREG(ui32Ba... | /* The available mappings are supplied on a per-device basis in */
void GPIOPinConfigure(uint32_t ui32PinConfig) |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 7