Пример #1
0
// This function is called when a /dev/osprdX file is finally closed.
// (If the file descriptor was dup2ed, this function is called only when the
// last copy is closed.)
static int osprd_close_last(struct inode *inode, struct file *filp)
{
	if (filp) {
		osprd_info_t *d = file2osprd(filp);
		int filp_writable = filp->f_mode & FMODE_WRITE;

		// EXERCISE: If the user closes a ramdisk file that holds
		// a lock, release the lock.  Also wake up blocked processes
		// as appropriate.
		
		if (filp->f_flags & F_OSPRD_LOCKED) {
			if (filp_writable) {
				if (d->write_lock == 1) d->write_lock = 0;
				else eprintk("file attempted to unlock write lock it didn't have\n");			
			}
			else {
				osp_spin_lock(&(d->mutex));

				if (d->read_lock > 0) d->read_lock--;
				else eprintk("file attempted to unlock read lock it didn't have\n");
				osp_spin_unlock(&(d->mutex));
			}			
		}

		wake_up_all(&(d->blockq));
	}

	return 0;
}
Пример #2
0
static int compare_leaves (tree_s *a, tree_s *b, leaf_s *aleaf, leaf_s *bleaf)
{
	unint	i;
	int	rc;

	if (aleaf->l_num != bleaf->l_num) {
		eprintk("leaf num doesn't match %x!=%x\n",
			aleaf->l_num, bleaf->l_num);
		return qERR_BAD_TREE;
	}
	if (aleaf->l_end != bleaf->l_end) {
		eprintk("leaf end doesn't match %x!=%x\n",
			aleaf->l_end, bleaf->l_end);
		return qERR_BAD_TREE;
	}
	if (aleaf->l_total != bleaf->l_total) {
		eprintk("leaf total doesn't match %x!=%x\n",
			aleaf->l_total, bleaf->l_total);
		return qERR_BAD_TREE;
	}
	for (i = 0; i < aleaf->l_num; i++) {
		rc = compare_rec( &aleaf->l_rec[i], &bleaf->l_rec[i]);
		if (rc) return rc;
	}
	return 0;
}
Пример #3
0
static int dumpfn(void *arg)
{
	int i;
	struct args_t *args = arg;
	int *pfd = args->pfd;
	char *argv[] = { "iptables-save", "-c", NULL };

	i = real_env_create(args->veid, VE_ENTER|VE_SKIPLOCK, 2, NULL, 0);
	if (i < 0) {
		eprintk("cannot enter ve to dump iptables\n");
		module_put(THIS_MODULE);
		return 255 << 8;
	}

	if (pfd[1] != 1)
		sc_dup2(pfd[1], 1);

	for (i=0; i<current->files->fdt->max_fds; i++) {
		if (i != 1)
			sc_close(i);
	}

	module_put(THIS_MODULE);

	set_fs(KERNEL_DS);
	i = sc_execve("/sbin/iptables-save", argv, NULL);
	if (i == -ENOENT)
		i = sc_execve("/usr/sbin/iptables-save", argv, NULL);
	eprintk("failed to exec iptables-save: %d\n", i);
	return 255 << 8;
}
Пример #4
0
static void run_hw_break_test(int is_write_test)
{
	test_complete = 0;
	init_simple_test();
	if (is_write_test) {
		ts.tst = hw_write_break_test;
		ts.name = "hw_write_break_test";
	} else {
		ts.tst = hw_access_break_test;
		ts.name = "hw_access_break_test";
	}
	/* Activate test with initial breakpoint */
	kgdb_breakpoint();
	hw_break_val_access();
	if (is_write_test) {
		if (test_complete == 2) {
			eprintk("kgdbts: ERROR %s broke on access\n",
				ts.name);
			hwbreaks_ok = 0;
		}
		hw_break_val_write();
	}
	kgdb_breakpoint();

	if (test_complete == 1)
		return;

	eprintk("kgdbts: ERROR %s test failed\n", ts.name);
	hwbreaks_ok = 0;
}
Пример #5
0
static int indirect_data(struct scsi_cmnd *scmd, struct srp_cmd *cmd,
			 struct srp_indirect_buf *id,
			 enum dma_data_direction dir, rdma_io_t rdma_io)
{
	struct iu_entry *iue = (struct iu_entry *) scmd->SCp.ptr;
	struct srp_target *target = iue->target;
	struct srp_direct_buf *md;
	struct scatterlist dummy, *sg = scmd->request_buffer;
	dma_addr_t token = 0;
	long err;
	unsigned int done = 0;
	int nmd, nsg;

	nmd = id->table_desc.len / sizeof(struct srp_direct_buf);

	dprintk("%p %u %u %u %u %d %d %d\n",
		iue, scmd->request_bufflen, scmd->bufflen,
		id->len, scmd->offset, nmd,
		cmd->data_in_desc_cnt, cmd->data_out_desc_cnt);

	if ((dir == DMA_FROM_DEVICE && nmd == cmd->data_in_desc_cnt) ||
	    (dir == DMA_TO_DEVICE && nmd == cmd->data_out_desc_cnt)) {
		md = &id->desc_list[0];
		goto rdma;
	}

	md = dma_alloc_coherent(target->dev, id->table_desc.len,
				 &token, GFP_KERNEL);
	if (!md) {
		eprintk("Can't get dma memory %u\n", id->table_desc.len);
		return 0;
	}

	sg_init_one(&dummy, md, id->table_desc.len);
	sg_dma_address(&dummy) = token;
	err = rdma_io(iue, &dummy, 1, &id->table_desc, 1, DMA_TO_DEVICE,
		      id->table_desc.len);
	if (err < 0) {
		eprintk("Error copying indirect table %ld\n", err);
		goto free_mem;
	}

rdma:
	nsg = dma_map_sg(target->dev, sg, scmd->use_sg, DMA_BIDIRECTIONAL);
	if (!nsg) {
		eprintk("fail to map %p %d\n", iue, scmd->use_sg);
		goto free_mem;
	}

	err = rdma_io(iue, sg, nsg, md, nmd, dir,
		      min(scmd->request_bufflen, id->len));
	dma_unmap_sg(target->dev, sg, nsg, DMA_BIDIRECTIONAL);

free_mem:
	if (token)
		dma_free_coherent(target->dev, id->table_desc.len, md, token);

	return done;
}
Пример #6
0
/*
 * osprd_process_request(d, req)
 *   Called when the user reads or writes a sector.
 *   Should perform the read or write, as appropriate.
 */
static void osprd_process_request(osprd_info_t *d, struct request *req)
{
  size_t offset;
  size_t num_bytes;

	if (!blk_fs_request(req)) {
		end_request(req, 0);
		return;
	}

	// EXERCISE: Perform the read or write request by copying data between
	// our data array and the request's buffer.
	// Hint: The 'struct request' argument tells you what kind of request
	// this is, and which sectors are being read or written.
	// Read about 'struct request' in <linux/blkdev.h>.
	// Consider the 'req->sector', 'req->current_nr_sectors', and
	// 'req->buffer' members, and the rq_data_dir() function.

  if (req->sector < 0 || req->sector >= nsectors)
  {
    // sector_t is defined as an unsigned long in <linux/types.h>
    eprintk("Invalid sector requested: [%lu]. max sectors: [%i]\n", (unsigned long)req->sector, nsectors);
    end_request(req, 0);
  }

  offset = req->sector * SECTOR_SIZE;

  // If the number of requested sectors would reach the end of the disk
  // use as many sectors as possible until the end is reached
  if(req->sector + req->current_nr_sectors > nsectors)
  {
    num_bytes = (nsectors - req->sector) * SECTOR_SIZE;
    eprintk("Requested sector [%lu] with [%u] additional sectors.\n", (unsigned long)req->sector, req->current_nr_sectors);
    eprintk("Using [%u] additional sectors instead.\n", num_bytes / SECTOR_SIZE);
  }
  else
  {
    num_bytes = req->current_nr_sectors * SECTOR_SIZE;
  }

  // According to http://www.makelinux.net/ldd3/chp-16-sect-3
  // it is save to dereference req->buffer and write to it.

  // Note from @ipetkov: I'm not sure if req->buffer needs to
  // be resized at all, I'm assuming linux will allocate the
  // memory before the request is sent. No issues are apparent
  // from the first 8 default test cases.
  spin_lock(&d->mutex);

  if(rq_data_dir(req) == READ)
    memcpy(req->buffer, d->data + offset, num_bytes);
  else // WRITE
    memcpy(d->data + offset, req->buffer, num_bytes);

  spin_unlock(&d->mutex);

	end_request(req, 1);
}
Пример #7
0
/*
 * osprd_process_request(d, req)
 *   Called when the user reads or writes a sector.
 *   Should perform the read or write, as appropriate.
 */
static void osprd_process_request(osprd_info_t *d, struct request *req)
{
        // Declare variables at the beginning
        // Calculate where to starta and the amount of data needed to copy
        int data_size = req->current_nr_sectors * SECTOR_SIZE;
        int data_offset = req->sector * SECTOR_SIZE;

        // Check for a bad request
        if (!blk_fs_request(req)) {
                end_request(req, 0);
                return;
        }

        // EXERCISE: Perform the read or write request by copying data between
        // our data array and the request's buffer.
        // Hint: The 'struct request' argument tells you what kind of request
        // this is, and which sectors are being read or written.
        // Read about 'struct request' in <linux/blkdev.h>.
        // Consider the 'req->sector', 'req->current_nr_sectors', and
        // 'req->buffer' members, and the rq_data_dir() function.

        // Your code here:
        
        // Check to see if we are trying to write to nonexistant sectors
        if(req->sector + req->current_nr_sectors > nsectors)
        {
                eprintk("Trying to write to nonexistant sectors\n");
                end_request(req, 0);
        }
        
        // Read from the RAMDISK
        // Copy the data in the requested sectors into the buffer
        if(rq_data_dir(req) == READ)
        {
                memcpy(req->buffer, d->data + data_offset, data_size);
        }
        
        // Write to the RAMDISK
        // Copy the data in the buffer into the requested sectors
        else if(rq_data_dir(req) == WRITE)
        {
                memcpy(d->data + data_offset, req->buffer, data_size);
        }
        
        // Trying to perform an invalid action
        else
        {
                eprintk("Neither a read nor a write\n");
                end_request(req,0);
        }
        
        end_request(req, 1);
}
Пример #8
0
static int emul_sstep_put(char *put_str, char *arg)
{
	if (!arch_needs_sstep_emulation) {
		char *ptr = &put_str[11];
		if (put_str[1] != 'T' || put_str[2] != '0')
			return 1;
		kgdb_hex2long(&ptr, &sstep_thread_id);
		return 0;
	}
	switch (sstep_state) {
	case 1:
		/* validate the "g" packet to get the IP */
		kgdb_hex2mem(&put_str[1], (char *)kgdbts_gdb_regs,
			 NUMREGBYTES);
		gdb_regs_to_pt_regs(kgdbts_gdb_regs, &kgdbts_regs);
		v2printk("Stopped at IP: %lx\n",
			 instruction_pointer(&kgdbts_regs));
		/* Want to stop at IP + break instruction size by default */
		sstep_addr = cont_addr + BREAK_INSTR_SIZE;
		break;
	case 2:
		if (strncmp(put_str, "$OK", 3)) {
			eprintk("kgdbts: failed sstep break set\n");
			return 1;
		}
		break;
	case 3:
		if (strncmp(put_str, "$T0", 3)) {
			eprintk("kgdbts: failed continue sstep\n");
			return 1;
		} else {
			char *ptr = &put_str[11];
			kgdb_hex2long(&ptr, &sstep_thread_id);
		}
		break;
	case 4:
		if (strncmp(put_str, "$OK", 3)) {
			eprintk("kgdbts: failed sstep break unset\n");
			return 1;
		}
		/* Single step is complete so continue on! */
		sstep_state = 0;
		return 0;
	default:
		eprintk("kgdbts: ERROR failed sstep put emulation\n");
	}

	/* Continue on the same test line until emulation is complete */
	ts.idx--;
	return 0;
}
Пример #9
0
static int bd6084gu_get_alc_level(struct bd6084gu_driver_data *drvdata)
{
	u8 level = 0;

	if(drvdata->mode == ALC_MODE) {
		if(bd6084gu_read(drvdata->client, 0x0C, &level))
			eprintk("Error while read register(0x13).\n");
		dprintk("alc level: %d\n", level);
	}
	else {
		eprintk("Current mode is not ALC mode\n");
	}

	return level;
}
Пример #10
0
pid_list_t
delete_check_deadlock_list (pid_list_t head,pid_list_t tail, pid_t current_pid)
{
	if (current_pid <0)
	{
		eprintk ("error delete");
		return NULL;
	}
	else
	{
		pid_list_t curr = head;
		while (curr->pid != current_pid)
		{
			curr = curr->next;
			if (curr == NULL)
			{
				eprintk ("can't find current_pid");
				return NULL;
			}
		}
		if (curr == head && curr== tail)
		{
			head = NULL;
			tail = NULL;
			kfree(curr);
		}
		else if (curr == head)
		{
			head = head->next;
			head->prev = NULL;
			kfree(curr);
		}
		else if (curr == tail)
		{
			tail = tail->prev;
			tail->next = NULL;
			kfree (curr);
		}
		else
		{
			curr->next->prev = curr->prev;
			curr->prev->next = curr->next;
			kfree(curr);
		}
		
	}
	return head;
}
Пример #11
0
/********************************************
 * Functions
 ********************************************/
static int aat28xx_setup_version(struct aat28xx_driver_data *drvdata)
{
	if(!drvdata)
		return -ENODEV;

	if(drvdata->version == 2862) {
		drvdata->cmds.normal = aat2862bl_normal_tbl;
		drvdata->cmds.alc = aat2862bl_alc_tbl;
		drvdata->cmds.sleep = aat2862bl_sleep_tbl;
		drvdata->reg_addrs.bl_m = AAT2862BL_REG_BLM;
		drvdata->reg_addrs.bl_s = AAT2862BL_REG_BLS;
		drvdata->reg_addrs.fade = AAT2862BL_REG_FADE;
		drvdata->reg_addrs.ldo_ab = AAT2862BL_REG_LDOAB;
		drvdata->reg_addrs.ldo_cd = AAT2862BL_REG_LDOCD;
		drvdata->reg_addrs.ldo_en = AAT2862BL_REG_LDOEN;
	}
	else if(drvdata->version == 2870) {
		drvdata->cmds.normal = aat2870bl_normal_tbl;
		drvdata->cmds.alc = aat2870bl_alc_tbl;
		drvdata->cmds.sleep = aat2870bl_sleep_tbl;
		drvdata->reg_addrs.bl_m = AAT2870BL_REG_BLM;
		drvdata->reg_addrs.ldo_ab = AAT2870BL_REG_LDOAB;
		drvdata->reg_addrs.ldo_cd = AAT2870BL_REG_LDOCD;
		drvdata->reg_addrs.ldo_en = AAT2870BL_REG_LDOEN;
	}
	else {
		eprintk("Not supported version!!\n");
		return -ENODEV;
	}

	return 0;
}
Пример #12
0
Файл: ua.c Проект: kissthink/IET
void ua_establish_for_session(struct iscsi_session *sess, u32 lun,
			      u8 asc, u8 ascq)
{
	struct list_head *l = &sess->ua_hash[ua_hashfn(lun)];
	struct ua_entry *ua = kmem_cache_alloc(ua_cache, GFP_KERNEL);
	struct ua_entry *e;

	if (!ua) {
		eprintk("%s", "Failed to alloc ua");
		return;
	}

	ua->asc = asc;
	ua->ascq = ascq;
	ua->lun = lun;
	ua->session = sess;
	INIT_LIST_HEAD(&ua->entry);

	spin_lock(&sess->ua_hash_lock);
	/* One UA per occurrence of an event */
	list_for_each_entry(e, l, entry) {
		if (e->session == sess && e->lun == lun &&
				e->asc == asc && e->ascq == ascq &&
				e->session->exp_cmd_sn == sess->exp_cmd_sn) {
			spin_unlock(&sess->ua_hash_lock);
			ua_free(ua);
			return;
		}
	}
	list_add_tail(&ua->entry, l);
	spin_unlock(&sess->ua_hash_lock);

	dprintk_ua(ua, sess, lun);
}
Пример #13
0
static void lm3530_sleep(struct lm3530_driver_data *drvdata)
{
	if (!drvdata || drvdata->state == SLEEP_STATE)
		return;

	dprintk("operation mode is %s\n", (drvdata->mode == NORMAL_MODE) ? "normal_mode" : "alc_mode");
	
	switch (drvdata->mode) {
		case NORMAL_MODE:
			drvdata->state = SLEEP_STATE;
			lm3530_set_table(drvdata, drvdata->cmds.sleep);
			break;

		case ALC_MODE:
			/* LGE_CHANGE
			 * Remove ALC mode
			 * 2010-07-26. [email protected]
			 */
			//drvdata->state = SLEEP_STATE;
			//lm3530_set_table(drvdata, drvdata->cmds.sleep);
			//udelay(500);
			//break;

		default:
			eprintk("Invalid Mode\n");
			break;
	}
	
	// [email protected] 20111024 set lcd_bl_en low for sleep current
	//#define LCD_BL_EN 124
	gpio_tlmm_config(GPIO_CFG(124, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
    	gpio_set_value(124, 0);    
    lm3530_current_state = SLEEP_STATE;
}
Пример #14
0
static void lm3530_sleep(struct lm3530_driver_data *drvdata)
{
	if (!drvdata || drvdata->state == SLEEP_STATE)
		return;

	dprintk("operation mode is %s\n", (drvdata->mode == NORMAL_MODE) ? "normal_mode" : "alc_mode");
	
	switch (drvdata->mode) {
		case NORMAL_MODE:
			drvdata->state = SLEEP_STATE;
			lm3530_set_table(drvdata, drvdata->cmds.sleep);
			break;

		case ALC_MODE:
			/* LGE_CHANGE
			 * Remove ALC mode
			 * 2010-07-26. [email protected]
			 */
			//drvdata->state = SLEEP_STATE;
			//lm3530_set_table(drvdata, drvdata->cmds.sleep);
			//udelay(500);
			//break;

		default:
			eprintk("Invalid Mode\n");
			break;
	}

	if (drvdata->client && gpio_is_valid(drvdata->gpio)) {
		gpio_tlmm_config(GPIO_CFG(drvdata->gpio, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
		bl_config_gpio(0);
		udelay(10);
		gpio_set_value(drvdata->gpio, 0);
	}	
}
Пример #15
0
static int check_and_rewind_pc(char *put_str, char *arg)
{
	unsigned long addr = lookup_addr(arg);
	int offset = 0;

	kgdb_hex2mem(&put_str[1], (char *)kgdbts_gdb_regs,
		 NUMREGBYTES);
	gdb_regs_to_pt_regs(kgdbts_gdb_regs, &kgdbts_regs);
	v2printk("Stopped at IP: %lx\n", instruction_pointer(&kgdbts_regs));
#ifdef CONFIG_X86
	/* On x86 a breakpoint stop requires it to be decremented */
	if (addr + 1 == kgdbts_regs.ip)
		offset = -1;
#endif
	if (strcmp(arg, "silent") &&
		instruction_pointer(&kgdbts_regs) + offset != addr) {
		eprintk("kgdbts: BP mismatch %lx expected %lx\n",
			   instruction_pointer(&kgdbts_regs) + offset, addr);
		return 1;
	}
#ifdef CONFIG_X86
	/* On x86 adjust the instruction pointer if needed */
	kgdbts_regs.ip += offset;
#endif
	return 0;
}
Пример #16
0
/*
 * osprd_process_request(d, req)
 *	 Called when the user reads or writes a sector.
 *	 Should perform the read or write, as appropriate.
 */
static void osprd_process_request(osprd_info_t *d, struct request *req)
{
	void *data_offset;
	unsigned int data_length;

	if (!blk_fs_request(req)) {
		end_request(req, 0);
		return;
	}

	// EXERCISE: Perform the read or write request by copying data between
	// our data array and the request's buffer.
	// Hint: The 'struct request' argument tells you what kind of request
	// this is, and which sectors are being read or written.
	// Read about 'struct request' in <linux/blkdev.h>.
	// Consider the 'req->sector', 'req->current_nr_sectors', and
	// 'req->buffer' members, and the rq_data_dir() function.

	data_offset = d->data + (SECTOR_SIZE * req->sector);
	data_length = req->current_nr_sectors * SECTOR_SIZE;

	// TODO: include a test for out-of-range read/writes
	if (rq_data_dir(req) == WRITE)
		memcpy(data_offset, req->buffer, data_length);
	else if (rq_data_dir(req) == READ)
		memcpy(req->buffer, data_offset, data_length);
	else {
		eprintk("Unrecognized command.\n");
		end_request(req, 0);
	}

	end_request(req, 1);
}
Пример #17
0
static int bd6084gu_set_table(struct bd6084gu_driver_data *drvdata, struct bd6084gu_ctrl_tbl *ptbl)
{
	unsigned int i = 0;

	if (ptbl == NULL) {
		eprintk("input ptr is null\n");
		return -EIO;
	}

	for( ;;) {
		if (ptbl->reg == 0xFF) {
			if (ptbl->val != 0xfe)
				udelay(ptbl->val);
			else
				break;
		}	
		else {
			if(bd6084gu_write(drvdata->client, ptbl->reg, ptbl->val) != 0)
				dprintk("i2c failed addr:%d, value:%d\n", ptbl->reg, ptbl->val);
		}
		ptbl++;
		i++;
	}
	return 0;
}
Пример #18
0
static void lm3530_sleep(struct lm3530_driver_data *drvdata)
{
	if (!drvdata || drvdata->state == SLEEP_STATE)
		return;

	dprintk("operation mode is %s\n", (drvdata->mode == NORMAL_MODE) ? "normal_mode" : "alc_mode");
	
	switch (drvdata->mode) {
		case NORMAL_MODE:
			drvdata->state = SLEEP_STATE;
			lm3530_set_table(drvdata, drvdata->cmds.sleep);
			break;

		case ALC_MODE:
			/* LGE_CHANGE
			 * Remove ALC mode
			 * 2010-07-26. [email protected]
			 */
			//drvdata->state = SLEEP_STATE;
			//lm3530_set_table(drvdata, drvdata->cmds.sleep);
			//udelay(500);
			//break;

		default:
			eprintk("Invalid Mode\n");
			break;
	}
    lm3530_current_state = SLEEP_STATE;
}
Пример #19
0
static void aat28xx_sleep(struct aat28xx_driver_data *drvdata)
{
	if (!drvdata || drvdata->state == SLEEP_STATE)
		return;

	dprintk("operation mode is %s\n", (drvdata->mode == NORMAL_MODE) ? "normal_mode" : "alc_mode");
	
	switch (drvdata->mode) {
		case NORMAL_MODE:
			drvdata->state = SLEEP_STATE;
			aat28xx_set_table(drvdata, drvdata->cmds.sleep);
			break;

		case ALC_MODE:
			/*           
                     
                                      
    */
			//drvdata->state = SLEEP_STATE;
			//aat28xx_set_table(drvdata, drvdata->cmds.sleep);
			//udelay(500);
			//break;

		default:
			eprintk("Invalid Mode\n");
			break;
	}
}
Пример #20
0
static int parse_nullio_params(struct iet_volume *volume, char *params)
{
	int err = 0;
	char *p, *q;

	while ((p = strsep(&params, ",")) != NULL) {
		substring_t args[MAX_OPT_ARGS];
		int token;
		if (!*p)
			continue;
		iet_strtolower(p);
		token = match_token(p, tokens, args);
		switch (token) {
		case opt_blk_cnt:
			q = match_strdup(&args[0]);
			if (!q)
				return -ENOMEM;
			volume->blk_cnt = simple_strtoull(q, NULL, 10);
			kfree(q);
			break;
		case opt_ignore:
			break;
		default:
			eprintk("Unknown %s\n", p);
			return -EINVAL;
			break;
		}
	}
	return err;
}
Пример #21
0
static void leds_brightness_set(struct led_classdev *led_cdev, enum led_brightness value)
{
	struct aat28xx_driver_data *drvdata = dev_get_drvdata(led_cdev->dev->parent);
	int brightness;
	int next;

	if (!drvdata) {
		eprintk("Error getting drvier data\n");
		return;
	}

	brightness = aat28xx_get_intensity(drvdata);

	next = value * drvdata->max_intensity / LED_FULL;
	/* If value is not 0, should not backlight off by bongkyu.kim */
	if (value !=0 && next == 0)
		next = 1;
		
	dprintk("input brightness value=%d]\n", next);

	if (brightness != next) {
		dprintk("brightness[current=%d, next=%d]\n", brightness, next);
		aat28xx_send_intensity(drvdata, next);
	}
}
Пример #22
0
static void emul_sstep_get(char *arg)
{
	if (!arch_needs_sstep_emulation) {
		fill_get_buf(arg);
		return;
	}
	switch (sstep_state) {
	case 0:
		v2printk("Emulate single step\n");
		/* Start by looking at the current PC */
		fill_get_buf("g");
		break;
	case 1:
		/* set breakpoint */
		break_helper("Z0", NULL, sstep_addr);
		break;
	case 2:
		/* Continue */
		fill_get_buf("c");
		break;
	case 3:
		/* Clear breakpoint */
		break_helper("z0", NULL, sstep_addr);
		break;
	default:
		eprintk("kgdbts: ERROR failed sstep get emulation\n");
	}
	sstep_state++;
}
Пример #23
0
int v9fs_get_idpool(struct v9fs_idpool *p)
{
	int i = 0;
	int error;

retry:
	if (idr_pre_get(&p->pool, GFP_KERNEL) == 0)
		return 0;

	if (down_interruptible(&p->lock) == -EINTR) {
		eprintk(KERN_WARNING, "Interrupted while locking\n");
		return -1;
	}

	/* no need to store exactly p, we just need something non-null */
	error = idr_get_new(&p->pool, p, &i);
	up(&p->lock);

	if (error == -EAGAIN)
		goto retry;
	else if (error)
		return -1;

	return i;
}
Пример #24
0
/*
 * osprd_process_request(d, req)
 *   Called when the user reads or writes a sector.
 *   Should perform the read or write, as appropriate.
 */
static void osprd_process_request(osprd_info_t *d, struct request *req)
{
	if (!blk_fs_request(req)) {
		end_request(req, 0);
		return;
	}

	// EXERCISE: Perform the read or write request by copying data between
	// our data array and the request's buffer.
	// Hint: The 'struct request' argument tells you what kind of request
	// this is, and which sectors are being read or written.
	// Read about 'struct request' in <linux/blkdev.h>.
	// Consider the 'req->sector', 'req->current_nr_sectors', and
	// 'req->buffer' members, and the rq_data_dir() function.

	// Your code here.
    unsigned long offset = req->sector*SECTOR_SIZE;
    unsigned long dataSize = req->current_nr_sectors*SECTOR_SIZE;
    
    if (rq_data_dir(req)==READ) {
        osp_spin_lock(&(d->mutex));
        memcpy(req->buffer, d->data+offset, dataSize);
        osp_spin_unlock(&(d->mutex));
    }else if (rq_data_dir(req)==WRITE){
        osp_spin_lock(&(d->mutex));
        memcpy(d->data+offset, req->buffer, dataSize);
        osp_spin_unlock(&(d->mutex));
    }else{
        end_request(req,1);
    }
    
	eprintk("Should process request...\n");

	end_request(req, 1);
}
Пример #25
0
static int lm3530_set_table(struct lm3530_driver_data *drvdata, struct lm3530_ctrl_tbl *ptbl)
{
	unsigned int i = 0;
	unsigned long delay = 0;

	if (ptbl == NULL) {
		eprintk("input ptr is null\n");
		return -EIO;
	}

	for( ;;) {
		if (ptbl->reg == 0xFF) {
			if (ptbl->val != 0xFE) {
				delay = (unsigned long)ptbl->val;
				udelay(delay);
			}
			else
				break;
		}	
		else {
			if (lm3530_write(drvdata->client, ptbl->reg, ptbl->val) != 0)
				dprintk("i2c failed addr:%d, value:%d\n", ptbl->reg, ptbl->val);
		}
		ptbl++;
		i++;
	}
	return 0;
}
Пример #26
0
static int event_recv_msg(struct tgt_event *ev)
{
	int err = 0;

	switch (ev->hdr.type) {
	case TGT_UEVENT_CMD_RSP:
		err = scsi_tgt_kspace_exec(ev->p.cmd_rsp.host_no,
					   ev->p.cmd_rsp.itn_id,
					   ev->p.cmd_rsp.result,
					   ev->p.cmd_rsp.tag,
					   ev->p.cmd_rsp.uaddr,
					   ev->p.cmd_rsp.len,
					   ev->p.cmd_rsp.sense_uaddr,
					   ev->p.cmd_rsp.sense_len,
					   ev->p.cmd_rsp.rw);
		break;
	case TGT_UEVENT_TSK_MGMT_RSP:
		err = scsi_tgt_kspace_tsk_mgmt(ev->p.tsk_mgmt_rsp.host_no,
					       ev->p.tsk_mgmt_rsp.itn_id,
					       ev->p.tsk_mgmt_rsp.mid,
					       ev->p.tsk_mgmt_rsp.result);
		break;
	case TGT_UEVENT_IT_NEXUS_RSP:
		err = scsi_tgt_kspace_it_nexus_rsp(ev->p.it_nexus_rsp.host_no,
						   ev->p.it_nexus_rsp.itn_id,
						   ev->p.it_nexus_rsp.result);
		break;
	default:
		eprintk("unknown type %d\n", ev->hdr.type);
		err = -EINVAL;
	}

	return err;
}
Пример #27
0
static int check_and_rewind_pc(char *put_str, char *arg)
{
	unsigned long addr = lookup_addr(arg);
	unsigned long ip;
	int offset = 0;

	kgdb_hex2mem(&put_str[1], (char *)kgdbts_gdb_regs,
		 NUMREGBYTES);
	gdb_regs_to_pt_regs(kgdbts_gdb_regs, &kgdbts_regs);
	ip = instruction_pointer(&kgdbts_regs);
	v2printk("Stopped at IP: %lx\n", ip);
#ifdef GDB_ADJUSTS_BREAK_OFFSET
	/* On some arches, a breakpoint stop requires it to be decremented */
	if (addr + BREAK_INSTR_SIZE == ip)
		offset = -BREAK_INSTR_SIZE;
#endif
	if (strcmp(arg, "silent") && ip + offset != addr) {
		eprintk("kgdbts: BP mismatch %lx expected %lx\n",
			   ip + offset, addr);
		return 1;
	}
	/* Readjust the instruction pointer if needed */
	ip += offset;
#ifdef GDB_ADJUSTS_BREAK_OFFSET
	instruction_pointer_set(&kgdbts_regs, ip);
#endif
	return 0;
}
Пример #28
0
/*
 * osprd_process_request(d, req)
 *   Called when the user reads or writes a sector.
 *   Should perform the read or write, as appropriate.
 */
static void osprd_process_request(osprd_info_t *d, struct request *req)
{
	if (!blk_fs_request(req)) {
		end_request(req, 0);
		return;
	}

	// EXERCISE: Perform the read or write request by copying data between
	// our data array and the request's buffer.
	// Hint: The 'struct request' argument tells you what kind of request
	// this is, and which sectors are being read or written.
	// Read about 'struct request' in <linux/blkdev.h>.
	// Consider the 'req->sector', 'req->current_nr_sectors', and
	// 'req->buffer' members, and the rq_data_dir() function.

	// Your code here.
    
    int offset = req->sector * SECTOR_SIZE;
    int bytes = req->current_nr_sectors * SECTOR_SIZE;
    // current_nr_sectors = number of sectors that is requested
    
    // rq_data_dir will tell if its a read or write
    if (rq_data_dir(req) == WRITE) memcpy(d->data + offset, req->buffer, bytes);
    else if (rq_data_dir(req) == READ) memcpy(req->buffer, d->data + offset, bytes);
    else eprintk("Must be read or written");

	end_request(req, 1);
}
Пример #29
0
int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, u64 itn_id,
			     struct scsi_lun *lun, u64 tag)
{
	struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd);
	struct tgt_event ev;
	int err;

	memset(&ev, 0, sizeof(ev));
	ev.p.cmd_req.host_no = shost->host_no;
	ev.p.cmd_req.itn_id = itn_id;
	ev.p.cmd_req.data_len = scsi_bufflen(cmd);
	memcpy(ev.p.cmd_req.scb, cmd->cmnd, sizeof(ev.p.cmd_req.scb));
	memcpy(ev.p.cmd_req.lun, lun, sizeof(ev.p.cmd_req.lun));
	ev.p.cmd_req.attribute = cmd->tag;
	ev.p.cmd_req.tag = tag;

	dprintk("%p %d %u %x %llx\n", cmd, shost->host_no,
		ev.p.cmd_req.data_len, cmd->tag,
		(unsigned long long) ev.p.cmd_req.tag);

	err = tgt_uspace_send_event(TGT_KEVENT_CMD_REQ, &ev);
	if (err)
		eprintk("tx buf is full, could not send\n");

	return err;
}
Пример #30
0
int itv_adapter_register(itv_adapter_t *p_iadapter, struct module *p_owner, struct device *p_dev)
{
    int retval = 0;
    int adapter_id;

    itv_object_t *iadapter;

    DEBUG_CALLSTACK

    spin_lock(&p_iadapter->register_lock);
    if((iadapter = itv_object_find_name(p_iadapter->icore, p_iadapter->psz_object_name, FIND_CHILD)) != NULL) {
        wprintk("This adapter is already exist : %s\n",p_iadapter->psz_object_name);
        spin_unlock(&p_iadapter->register_lock);
        return -1;
    }

    if((adapter_id = itv_get_adapter_id(p_iadapter->icore)) == ITV_UNSET) {
        eprintk("itv_get_adapter_id() is failed\n");
        spin_unlock(&p_iadapter->register_lock);
        return -1;
    }

    p_iadapter->id		= adapter_id;
    p_iadapter->dev		= p_dev;
    p_iadapter->owner	= p_owner;

    itv_object_attach(p_iadapter, p_iadapter->icore);

    spin_unlock(&p_iadapter->register_lock);

    return retval;
}