static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, loff_t *ppos) { struct inode *ino = file_inode(file); struct pci_dev *dev = PDE_DATA(ino); int pos = *ppos; int size = dev->cfg_size; int cnt; if (pos >= size) return 0; if (nbytes >= size) nbytes = size; if (pos + nbytes > size) nbytes = size - pos; cnt = nbytes; if (!access_ok(VERIFY_READ, buf, cnt)) return -EINVAL; pci_config_pm_runtime_get(dev); if ((pos & 1) && cnt) { unsigned char val; __get_user(val, buf); pci_user_write_config_byte(dev, pos, val); buf++; pos++; cnt--; } if ((pos & 3) && cnt > 2) { __le16 val; __get_user(val, (__le16 __user *) buf); pci_user_write_config_word(dev, pos, le16_to_cpu(val)); buf += 2; pos += 2; cnt -= 2; } while (cnt >= 4) { __le32 val; __get_user(val, (__le32 __user *) buf); pci_user_write_config_dword(dev, pos, le32_to_cpu(val)); buf += 4; pos += 4; cnt -= 4; } if (cnt >= 2) { __le16 val; __get_user(val, (__le16 __user *) buf); pci_user_write_config_word(dev, pos, le16_to_cpu(val)); buf += 2; pos += 2; cnt -= 2; } if (cnt) { unsigned char val; __get_user(val, buf); pci_user_write_config_byte(dev, pos, val); buf++; pos++; cnt--; } pci_config_pm_runtime_put(dev); *ppos = pos; i_size_write(ino, dev->cfg_size); return nbytes; }
static int rpc_proc_open(struct inode *inode, struct file *file) { return single_open(file, rpc_proc_show, PDE_DATA(inode)); }
static int uf_proc_open(struct inode *inode, struct file *file) { return single_open_size(file, uf_proc_show, PDE_DATA(inode), UNIFI_DEBUG_TXT_BUFFER); }
static int snmp6_dev_seq_open(struct inode *inode, struct file *file) { return single_open(file, snmp6_dev_seq_show, PDE_DATA(inode)); }
static int mic_dma_reg_show(struct seq_file *m, void *v) { int i, j, chan_num, size, dtpr; struct mic_dma_ctx_t *dma_ctx = m->private; struct mic_dma_device *dma_dev = &dma_ctx->dma_dev; struct dma_channel *curr_chan; union md_mic_dma_desc desc; seq_printf(m, "========================================" "=======================================\n"); seq_printf(m, "SBOX_DCR: %#x\n", mic_sbox_read_mmio(dma_dev->mm_sbox, SBOX_DCR)); seq_printf(m, "DMA Channel Registers\n"); seq_printf(m, "========================================" "=======================================\n"); seq_printf(m, "%-10s| %-10s %-10s %-10s %-10s %-10s %-10s" #ifdef CONFIG_MK1OM " %-10s %-11s %-14s %-10s" #endif "\n", "Channel", "DCAR", "DTPR", "DHPR", "DRAR_HI", "DRAR_LO", #ifdef CONFIG_MK1OM "DSTATWB_LO", "DSTATWB_HI", "DSTAT_CHERR", "DSTAT_CHERRMSK", #endif "DSTAT"); seq_printf(m, "========================================" "=======================================\n"); #ifdef _MIC_SCIF_ for (i = 0; i < MAX_NUM_DMA_CHAN; i++) { #else for (i = first_dma_chan(); i <= last_dma_chan(); i++) { #endif curr_chan = &dma_ctx->dma_channels[i]; chan_num = curr_chan->ch_num; seq_printf(m, "%-10i| %-#10x %-#10x %-#10x %-#10x" " %-#10x" #ifdef CONFIG_MK1OM " %-#10x %-#11x %-#10x %-#14x" #endif " %-#10x\n", chan_num, md_mic_dma_read_mmio(dma_dev, chan_num, REG_DCAR), md_mic_dma_read_mmio(dma_dev, chan_num, REG_DTPR), md_mic_dma_read_mmio(dma_dev, chan_num, REG_DHPR), md_mic_dma_read_mmio(dma_dev, chan_num, REG_DRAR_HI), md_mic_dma_read_mmio(dma_dev, chan_num, REG_DRAR_LO), #ifdef CONFIG_MK1OM md_mic_dma_read_mmio(dma_dev, chan_num, REG_DSTATWB_LO), md_mic_dma_read_mmio(dma_dev, chan_num, REG_DSTATWB_HI), md_mic_dma_read_mmio(dma_dev, chan_num, REG_DCHERR), md_mic_dma_read_mmio(dma_dev, chan_num, REG_DCHERRMSK), #endif md_mic_dma_read_mmio(dma_dev, chan_num, REG_DSTAT)); } seq_printf(m, "\nDMA Channel Descriptor Rings\n"); seq_printf(m, "========================================" "=======================================\n"); for (i = first_dma_chan(); i <= last_dma_chan(); i++) { curr_chan = &dma_ctx->dma_channels[i]; chan_num = curr_chan->ch_num; dtpr = md_mic_dma_read_mmio(dma_dev, chan_num, REG_DTPR); seq_printf(m, "Channel %i: [", chan_num); size = ((int) md_mic_dma_read_mmio(dma_dev, chan_num, REG_DHPR) - dtpr) % curr_chan->chan->num_desc_in_ring; /* * In KNC B0, empty condition is tail = head -1 */ if (mic_hw_family(dma_ctx->device_num) == FAMILY_KNC && mic_hw_stepping(dma_ctx->device_num) >= KNC_B0_STEP) size -= 1; for (j = 0; j < size; j++) { desc = curr_chan->desc_ring[(j+dtpr) % curr_chan->chan->num_desc_in_ring]; switch (desc.desc.nop.type){ case NOP: seq_printf(m," {Type: NOP, 0x%#llx" " %#llx} ", desc.qwords.qw0, desc.qwords.qw1); case MEMCOPY: seq_printf(m," {Type: MEMCOPY, SAP:" " 0x%#llx, DAP: %#llx, length: %#llx} ", (uint64_t) desc.desc.memcopy.sap, (uint64_t) desc.desc.memcopy.dap, (uint64_t) desc.desc.memcopy.length); break; case STATUS: seq_printf(m," {Type: STATUS, data:" " 0x%#llx, DAP: %#llx, intr: %lli} ", (uint64_t) desc.desc.status.data, (uint64_t) desc.desc.status.dap, (uint64_t) desc.desc.status.intr); break; case GENERAL: seq_printf(m," {Type: GENERAL, " "DAP: %#llx, dword: %#llx} ", (uint64_t) desc.desc.general.dap, (uint64_t) desc.desc.general.data); break; case KEYNONCECNT: seq_printf(m," {Type: KEYNONCECNT, sel: " "%lli, h: %lli, index: %lli, cs: %lli," " value: %#llx} ", (uint64_t) desc.desc.keynoncecnt.sel, (uint64_t) desc.desc.keynoncecnt.h, (uint64_t) desc.desc.keynoncecnt.index, (uint64_t) desc.desc.keynoncecnt.cs, (uint64_t) desc.desc.keynoncecnt.data); break; case KEY: seq_printf(m," {Type: KEY, dest_ind" "ex: %lli, ski: %lli, skap: %#llx ", (uint64_t) desc.desc.key.di, (uint64_t) desc.desc.key.ski, (uint64_t) desc.desc.key.skap); break; default: seq_printf(m," {Uknown Type=%lli ," "%#llx %#llx} ",(uint64_t) desc.desc.nop.type, (uint64_t) desc.qwords.qw0, (uint64_t) desc.qwords.qw1); } } seq_printf(m, "]\n"); if (mic_hw_family(dma_ctx->device_num) == FAMILY_KNC && mic_hw_stepping(dma_ctx->device_num) >= KNC_B0_STEP && curr_chan->chan->dstat_wb_loc) seq_printf(m, "DSTAT_WB = 0x%x\n", *((uint32_t*)curr_chan->chan->dstat_wb_loc)); } return 0; } static int mic_dma_reg_open(struct inode *inode, struct file *file) { return single_open(file, mic_dma_reg_show, PDE_DATA(inode)); } static const struct file_operations mic_dma_reg_fops = { .owner = THIS_MODULE, .open = mic_dma_reg_open, .read = seq_read, .llseek = seq_lseek, .release = single_release }; static void mic_dma_proc_init(struct mic_dma_ctx_t *dma_ctx) { char name[64]; snprintf(name, 63, "%s%d", proc_dma_ring, dma_ctx->device_num); proc_create_data(name, S_IFREG | S_IRUGO, NULL, &mic_dma_ring_fops, dma_ctx); snprintf(name, 63, "%s%d", proc_dma_reg, dma_ctx->device_num); proc_create_data(name, S_IFREG | S_IRUGO, NULL, &mic_dma_reg_fops, dma_ctx); }
static int pfq_proc_stats_open(struct inode *inode, struct file *file) { return single_open(file, pfq_proc_stats, PDE_DATA(inode)); }
static int acpi_button_state_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_button_state_seq_show, PDE_DATA(inode)); }
static int _cl_bcct_open(struct inode *inode, struct file *file) { return single_open(file, _cl_bcct_read, PDE_DATA(inode)); }
static int ipsec_proc_open(struct inode *inode, struct file *file) { struct ipsec_proc_list *it = PDE_DATA(inode); return single_open(file, it->proc_open, it->data); }
static ssize_t video_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { struct toshiba_acpi_dev *dev = PDE_DATA(file_inode(file)); char *cmd, *buffer; int ret; int value; int remain = count; int lcd_out = -1; int crt_out = -1; int tv_out = -1; u32 video_out; cmd = kmalloc(count + 1, GFP_KERNEL); if (!cmd) return -ENOMEM; if (copy_from_user(cmd, buf, count)) { kfree(cmd); return -EFAULT; } cmd[count] = '\0'; buffer = cmd; /* scan expression. Multiple expressions may be delimited with ; * * NOTE: to keep scanning simple, invalid fields are ignored */ while (remain) { if (sscanf(buffer, " lcd_out : %i", &value) == 1) lcd_out = value & 1; else if (sscanf(buffer, " crt_out : %i", &value) == 1) crt_out = value & 1; else if (sscanf(buffer, " tv_out : %i", &value) == 1) tv_out = value & 1; /* advance to one character past the next ; */ do { ++buffer; --remain; } while (remain && *(buffer - 1) != ';'); } kfree(cmd); ret = get_video_status(dev, &video_out); if (!ret) { unsigned int new_video_out = video_out; if (lcd_out != -1) _set_bit(&new_video_out, HCI_VIDEO_OUT_LCD, lcd_out); if (crt_out != -1) _set_bit(&new_video_out, HCI_VIDEO_OUT_CRT, crt_out); if (tv_out != -1) _set_bit(&new_video_out, HCI_VIDEO_OUT_TV, tv_out); /* To avoid unnecessary video disruption, only write the new * video setting if something changed. */ if (new_video_out != video_out) ret = write_acpi_int(METHOD_VIDEO_OUT, new_video_out); } return ret ? ret : count; }
static int proc_fasttimer_open(struct inode *inode, struct file *file) { return single_open_size(file, proc_fasttimer_show, PDE_DATA(inode), BIG_BUF_SIZE); }
static int mdc_kuc_open(struct inode *inode, struct file *file) { return single_open(file, NULL, PDE_DATA(inode)); }
static ssize_t proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) { struct pci_dev *dev = PDE_DATA(file_inode(file)); unsigned int pos = *ppos; unsigned int cnt, size; /* * Normal users can read only the standardized portion of the * configuration space as several chips lock up when trying to read * undefined locations (think of Intel PIIX4 as a typical example). */ if (capable(CAP_SYS_ADMIN)) size = dev->cfg_size; else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) size = 128; else size = 64; if (pos >= size) return 0; if (nbytes >= size) nbytes = size; if (pos + nbytes > size) nbytes = size - pos; cnt = nbytes; if (!access_ok(VERIFY_WRITE, buf, cnt)) return -EINVAL; pci_config_pm_runtime_get(dev); if ((pos & 1) && cnt) { unsigned char val; pci_user_read_config_byte(dev, pos, &val); __put_user(val, buf); buf++; pos++; cnt--; } if ((pos & 3) && cnt > 2) { unsigned short val; pci_user_read_config_word(dev, pos, &val); __put_user(cpu_to_le16(val), (__le16 __user *) buf); buf += 2; pos += 2; cnt -= 2; } while (cnt >= 4) { unsigned int val; pci_user_read_config_dword(dev, pos, &val); __put_user(cpu_to_le32(val), (__le32 __user *) buf); buf += 4; pos += 4; cnt -= 4; } if (cnt >= 2) { unsigned short val; pci_user_read_config_word(dev, pos, &val); __put_user(cpu_to_le16(val), (__le16 __user *) buf); buf += 2; pos += 2; cnt -= 2; } if (cnt) { unsigned char val; pci_user_read_config_byte(dev, pos, &val); __put_user(val, buf); buf++; pos++; cnt--; } pci_config_pm_runtime_put(dev); *ppos = pos; return nbytes; }
static loff_t proc_bus_pci_lseek(struct file *file, loff_t off, int whence) { struct pci_dev *dev = PDE_DATA(file_inode(file)); return fixed_size_llseek(file, off, whence, dev->cfg_size); }
static int bluesleep_open_proc_btwrite(struct inode *inode, struct file *file) { return single_open(file, btwrite_proc_show, PDE_DATA(inode)); }
static int activity_stats_open(struct inode *inode, struct file *file) { return single_open(file, activity_stats_show, PDE_DATA(inode)); }
static int _mtk_cl_sd_rst_open(struct inode *inode, struct file *file) { return single_open(file, _mtk_cl_sd_rst_read, PDE_DATA(inode)); }
static int r_open(struct inode *inode, struct file *file) { return single_open(file, PDE_DATA(inode), proc_get_parent_data(inode)); }
static int segment_info_open_fs(struct inode *inode, struct file *file) { return single_open(file, segment_info_seq_show, PDE_DATA(inode)); }
static int fld_proc_cache_flush_open(struct inode *inode, struct file *file) { file->private_data = PDE_DATA(inode); return 0; }
static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) { return simple_read_from_buffer(buf, nbytes, ppos, PDE_DATA(file_inode(file)), PAGE_SIZE); }
static ssize_t atags_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct buffer *b = PDE_DATA(file_inode(file)); return simple_read_from_buffer(buf, count, ppos, b->data, b->size); }
static int mic_dma_ring_open(struct inode *inode, struct file *file) { return single_open(file, mic_dma_ring_show, PDE_DATA(inode)); }
static int dump_isp_vic_frd_open(struct inode *inode, struct file *file) { return single_open_size(file, isp_vic_frd_show, PDE_DATA(inode),8192); }
static int diag_led_open(struct inode *inode, struct file *file) { return single_open(file, diag_led_show, PDE_DATA(inode)); }
/** * @brief This function handle the generic file open * * @param inode A pointer to inode structure * @param file A pointer to file structure * @return BT_STATUS_SUCCESS or other error no. */ static int proc_open(struct inode *inode, struct file *file) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) struct proc_private_data *priv = PDE_DATA(inode); #else struct proc_private_data *priv = PDE(inode)->data; #endif struct proc_data *pdata; int i; char *p; u32 val = 0; ENTER(); priv->pbt->adapter->skb_pending = skb_queue_len(&priv->pbt->adapter->tx_queue); file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL); if (file->private_data == NULL) { PRINTM(ERROR, "BT: Can not alloc mem for proc_data\n"); LEAVE(); return -ENOMEM; } pdata = (struct proc_data *)file->private_data; pdata->rdbuf = kmalloc(priv->bufsize, GFP_KERNEL); if (pdata->rdbuf == NULL) { PRINTM(ERROR, "BT: Can not alloc mem for rdbuf\n"); kfree(file->private_data); LEAVE(); return -ENOMEM; } if (priv->fileflag == DEFAULT_FILE_PERM) { pdata->wrbuf = kzalloc(priv->bufsize, GFP_KERNEL); if (pdata->wrbuf == NULL) { PRINTM(ERROR, "BT: Can not alloc mem for wrbuf\n"); kfree(pdata->rdbuf); kfree(file->private_data); return -ENOMEM; } pdata->maxwrlen = priv->bufsize; pdata->on_close = proc_on_close; } p = pdata->rdbuf; for (i = 0; i < priv->num_items; i++) { if (priv->pdata[i].size == 1) val = *((u8 *)priv->pdata[i].addr); else if (priv->pdata[i].size == 2) val = *((u16 *) priv->pdata[i].addr); else if (priv->pdata[i].size == 4) val = *((u32 *)priv->pdata[i].addr); if (priv->pdata[i].flag & SHOW_INT) p += sprintf(p, "%s=%d\n", priv->pdata[i].name, val); else if (priv->pdata[i].flag & SHOW_HEX) p += sprintf(p, "%s=0x%x\n", priv->pdata[i].name, val); else if (priv->pdata[i].flag & SHOW_STRING) { if (!strncmp (priv->pdata[i].name, "sdcmd52rw", strlen("sdcmd52rw"))) { sd_read_cmd52_val(bpriv); form_cmd52_string(bpriv); } p += sprintf(p, "%s=%s\n", priv->pdata[i].name, (char *)priv->pdata[i].addr); } } pdata->rdlen = strlen(pdata->rdbuf); LEAVE(); return BT_STATUS_SUCCESS; }
static int ahbm_open(struct inode *inode, struct file *file) { return single_open(file, ahbm_show, PDE_DATA(inode)); }
if (v == &cell->proc_volumes) { seq_puts(m, "USE VID TY\n"); return 0; } seq_printf(m, "%3d %08llx %s\n", atomic_read(&vol->usage), vol->vid, afs_vol_types[vol->type]); return 0; } static void *afs_proc_cell_volumes_start(struct seq_file *m, loff_t *_pos) __acquires(cell->proc_lock) { struct afs_cell *cell = PDE_DATA(file_inode(m->file)); read_lock(&cell->proc_lock); return seq_list_start_head(&cell->proc_volumes, *_pos); } static void *afs_proc_cell_volumes_next(struct seq_file *m, void *v, loff_t *_pos) { struct afs_cell *cell = PDE_DATA(file_inode(m->file)); return seq_list_next(v, &cell->proc_volumes, _pos); } static void afs_proc_cell_volumes_stop(struct seq_file *m, void *v) __releases(cell->proc_lock)
static int litmus_active_proc_open(struct inode *inode, struct file *file) { return single_open(file, litmus_active_proc_show, PDE_DATA(inode)); }
static int ddr_mon3_proc_open(struct inode *inode, struct file *file) { return single_open(file, ddr_mon3_proc_read, PDE_DATA(inode)); }