Exemplo n.º 1
0
int proc_avs_0_colorformat_write(struct file *file, const char __user *buf, unsigned long count, void *data)
{
	char *page;
	char *myString;
	ssize_t ret = -ENOMEM;

	printk("%s %ld - ", __FUNCTION__, count);

	page = (char *)__get_free_page(GFP_KERNEL);
	if (page)
	{
		struct stmfb_info *info = stmfb_get_fbinfo_ptr();

		struct stmfbio_output_configuration outputConfig;
		int err = 0;
		int alpha = 0;
		int hdmi_colour = 0;
		int scart_colour = 0;
		int hdmi0scart1yuv2 = 1;

		ret = -EFAULT;
		if (copy_from_user(page, buf, count))
			goto out;

		myString = (char *) kmalloc(count + 1, GFP_KERNEL);
		strncpy(myString, page, count);
		myString[count] = '\0';

		printk("%s\n", myString);

		sscanf(myString, "%d", &alpha);

		//0rgb 1yuv 2422
		if (strncmp("hdmi_rgb", page, count - 1) == 0)
		{
			hdmi_colour = 0;
			hdmi0scart1yuv2 = 0;
		}
		else if (strncmp("hdmi_yuv", page, count - 1) == 0)
		{
			hdmi_colour = 1;
			hdmi0scart1yuv2 = 0;
		}
		else if (strncmp("hdmi_422", page, count - 1) == 0)
		{
			hdmi_colour = 2;
			hdmi0scart1yuv2 = 0;
		}
		else if (strncmp("rgb", page, count - 1) == 0)
		{
			scart_colour = SAA_MODE_RGB;
			hdmi0scart1yuv2 = 1;
		}
		else if (strncmp("cvbs", page, count - 1) == 0)
		{
			scart_colour = SAA_MODE_FBAS;
			hdmi0scart1yuv2 = 1;
		}
		else if (strncmp("svideo", page, count - 1) == 0)
		{
			scart_colour = SAA_MODE_SVIDEO;
			hdmi0scart1yuv2 = 1;
		}
		else if  (strncmp("yuv", page, count - 1) == 0)
		{
			hdmi0scart1yuv2 = 2;
		}

		if (hdmi0scart1yuv2 == 0)
		{
			outputConfig.outputid = 1;

			stmfb_get_output_configuration(&outputConfig,info);

			outputConfig.caps = 0;
			outputConfig.activate = 0; //STMFBIO_ACTIVATE_IMMEDIATE;

			outputConfig.caps |= STMFBIO_OUTPUT_CAPS_HDMI_CONFIG;
			outputConfig.hdmi_config &= ~(STMFBIO_OUTPUT_HDMI_YUV|STMFBIO_OUTPUT_HDMI_422);

			switch(hdmi_colour)
			{
				case 1:
					outputConfig.hdmi_config |= STMFBIO_OUTPUT_HDMI_YUV;
					break;
				case 2:
					outputConfig.hdmi_config |= (STMFBIO_OUTPUT_HDMI_YUV|STMFBIO_OUTPUT_HDMI_422);
					break;
				default:
					break;
			}

			err = stmfb_set_output_configuration(&outputConfig, info);
		}
		else if (hdmi0scart1yuv2 == 1)
		{
			avs_command_kernel(SAAIOSMODE, (void*) scart_colour);

			outputConfig.outputid = 1;

			stmfb_get_output_configuration(&outputConfig,info);

			outputConfig.caps = 0;
			outputConfig.activate = 0; //STMFBIO_ACTIVATE_IMMEDIATE;

			outputConfig.caps |= STMFBIO_OUTPUT_CAPS_ANALOGUE_CONFIG;
			outputConfig.analogue_config = 0;

			switch(scart_colour)
			{
				case SAA_MODE_RGB:
					outputConfig.analogue_config |= (STMFBIO_OUTPUT_ANALOGUE_RGB|STMFBIO_OUTPUT_ANALOGUE_CVBS);
					break;
				case SAA_MODE_FBAS:
					outputConfig.analogue_config |= STMFBIO_OUTPUT_ANALOGUE_CVBS;
					break;
				case SAA_MODE_SVIDEO:
					outputConfig.analogue_config |= STMFBIO_OUTPUT_ANALOGUE_YC;
					break;
				default:
					break;
			}

			err = stmfb_set_output_configuration(&outputConfig, info);
			if (err != 0)
			{
				printk("SET SCART COLOR - %ld - ", count);
			}

		}
		else
		{
			outputConfig.outputid = 1;

			stmfb_get_output_configuration(&outputConfig,info);

			outputConfig.caps = 0;
			outputConfig.activate = 0; //STMFBIO_ACTIVATE_IMMEDIATE;

			outputConfig.caps |= STMFBIO_OUTPUT_CAPS_ANALOGUE_CONFIG;
			outputConfig.analogue_config = 0;

			outputConfig.analogue_config |= STMFBIO_OUTPUT_ANALOGUE_YPrPb;

			err = stmfb_set_output_configuration(&outputConfig, info);
			if (err != 0)
			{
				printk("SET SCART COLOR - %ld - ", count);
			}
		}

		//if(ioctl(fbfd, STMFBIO_SET_OUTPUT_CONFIG, &outputConfig)<0)
		//perror("setting output configuration failed");

		kfree(myString);
	}

	ret = count;
out:

	free_page((unsigned long)page);
	return ret;
}
Exemplo n.º 2
0
int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env)
{
	struct power_supply *psy = dev_get_drvdata(dev);
	int ret = 0, j;
	char *prop_buf;
	char *attrname;

	dev_dbg(dev, "uevent\n");

	if (!psy || !psy->dev) {
		dev_dbg(dev, "No power supply yet\n");
		return ret;
	}

	dev_dbg(dev, "POWER_SUPPLY_NAME=%s\n", psy->name);

	ret = add_uevent_var(env, "POWER_SUPPLY_NAME=%s", psy->name);
	if (ret)
		return ret;

	prop_buf = (char *)get_zeroed_page(GFP_KERNEL);
	if (!prop_buf)
		return -ENOMEM;

	for (j = 0; j < psy->num_properties; j++) {
		struct device_attribute *attr;
		char *line;

		attr = &power_supply_attrs[psy->properties[j]];

		ret = power_supply_show_property(dev, attr, prop_buf);
		if (ret == -ENODEV || ret == -ENODATA) {
			/* When a battery is absent, we expect -ENODEV. Don't abort;
			   send the uevent with at least the the PRESENT=0 property */
			ret = 0;
			continue;
		}

		if (ret < 0)
			goto out;

		line = strchr(prop_buf, '\n');
		if (line)
			*line = 0;

		attrname = kstruprdup(attr->attr.name, GFP_KERNEL);
		if (!attrname) {
			ret = -ENOMEM;
			goto out;
		}

		dev_dbg(dev, "prop %s=%s\n", attrname, prop_buf);

		ret = add_uevent_var(env, "POWER_SUPPLY_%s=%s", attrname, prop_buf);
		kfree(attrname);
		if (ret)
			goto out;
	}

out:
	free_page((unsigned long)prop_buf);

	return ret;
}
Exemplo n.º 3
0
static void release_swap_reader(struct swap_map_handle *handle)
{
	if (handle->cur)
		free_page((unsigned long)handle->cur);
	handle->cur = NULL;
}
Exemplo n.º 4
0
void shutdown_tpmfront(struct tpmfront_dev* dev)
{
   char* err;
   char path[512];
   if(dev == NULL) {
      return;
   }
   TPMFRONT_LOG("Shutting down tpmfront\n");
   /* disconnect */
   if(dev->state == XenbusStateConnected) {
      /* Tell backend we are closing */
      dev->state = XenbusStateClosing;
      if((err = xenbus_printf(XBT_NIL, dev->nodename, "state", "%u", (unsigned int) dev->state))) {
	 TPMFRONT_ERR("Unable to write to %s, error was %s", dev->nodename, err);
	 free(err);
      }

      /* Clean up xenstore entries */
      snprintf(path, 512, "%s/event-channel", dev->nodename);
      if((err = xenbus_rm(XBT_NIL, path))) {
	 free(err);
      }
      snprintf(path, 512, "%s/ring-ref", dev->nodename);
      if((err = xenbus_rm(XBT_NIL, path))) {
	 free(err);
      }

      /* Tell backend we are closed */
      dev->state = XenbusStateClosed;
      if((err = xenbus_printf(XBT_NIL, dev->nodename, "state", "%u", (unsigned int) dev->state))) {
	 TPMFRONT_ERR("Unable to write to %s, error was %s", dev->nodename, err);
	 free(err);
      }

      /* Wait for the backend to close and unmap shared pages, ignore any errors */
      wait_for_backend_state_changed(dev, XenbusStateClosed);

      /* Prepare for a later reopen (possibly by a kexec'd kernel) */
      dev->state = XenbusStateInitialising;
      if((err = xenbus_printf(XBT_NIL, dev->nodename, "state", "%u", (unsigned int) dev->state))) {
	 TPMFRONT_ERR("Unable to write to %s, error was %s", dev->nodename, err);
	 free(err);
      }

      /* Close event channel and unmap shared page */
      mask_evtchn(dev->evtchn);
      unbind_evtchn(dev->evtchn);
      gnttab_end_access(dev->ring_ref);

      free_page(dev->page);
   }

   /* Cleanup memory usage */
   if(dev->respbuf) {
      free(dev->respbuf);
   }
   if(dev->bepath) {
      free(dev->bepath);
   }
   if(dev->nodename) {
      free(dev->nodename);
   }
   free(dev);
}
static int sdcardfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
{
	int err = 0;
	int make_nomedia_in_obb = 0;
	struct dentry *lower_dentry;
	struct dentry *lower_parent_dentry = NULL;
	struct path lower_path;
	struct sdcardfs_sb_info *sbi = SDCARDFS_SB(dentry->d_sb);
	const struct cred *saved_cred = NULL;
	struct sdcardfs_inode_info *pi = SDCARDFS_I(dir);
	char *page_buf;
	char *nomedia_dir_name;
	char *nomedia_fullpath;
	int fullpath_namelen;
	int touch_err = 0;

	int has_rw = get_caller_has_rw_locked(sbi->pkgl_id, sbi->options.derive);
	if(!check_caller_access_to_name(dir, dentry->d_name.name, sbi->options.derive, 1, has_rw)) {
		printk(KERN_INFO "%s: need to check the caller's gid in packages.list\n" 
						 "  dentry: %s, task:%s\n",
						 __func__, dentry->d_name.name, current->comm);
		err = -EACCES;
		goto out_eacces;
	}

	/* save current_cred and override it */
	OVERRIDE_CRED(SDCARDFS_SB(dir->i_sb), saved_cred);

	/* check disk space */
	if (!check_min_free_space(dentry, 0, 1)) {
		printk(KERN_INFO "sdcardfs: No minimum free space.\n");
		err = -ENOSPC;
		goto out_revert;
	}

	/* the lower_dentry is negative here */
	sdcardfs_get_lower_path(dentry, &lower_path);
	lower_dentry = lower_path.dentry;
	lower_parent_dentry = lock_parent(lower_dentry);

	err = mnt_want_write(lower_path.mnt);
	if (err) {
		unlock_dir(lower_parent_dentry);
		goto out_unlock;
	}

	/* set last 16bytes of mode field to 0775 */
	mode = (mode & S_IFMT) | 00775; 
	err = vfs_mkdir(lower_parent_dentry->d_inode, lower_dentry, mode);

	if (err) {
		unlock_dir(lower_parent_dentry);
		goto out;
	}
	
	/* if it is a local obb dentry, setup it with the base obbpath */
	if(need_graft_path(dentry)) {

		err = setup_obb_dentry(dentry, &lower_path);
		if(err) {
			/* if the sbi->obbpath is not available, the lower_path won't be 
			 * changed by setup_obb_dentry() but the lower path is saved to 
             * its orig_path. this dentry will be revalidated later.
			 * but now, the lower_path should be NULL */
			sdcardfs_put_reset_lower_path(dentry);

			/* the newly created lower path which saved to its orig_path or
			 * the lower_path is the base obbpath. 
             * therefore, an additional path_get is required */
			path_get(&lower_path);
		} else
			make_nomedia_in_obb = 1;
	}

	err = sdcardfs_interpose(dentry, dir->i_sb, &lower_path);
	if (err) {
		unlock_dir(lower_parent_dentry);
		goto out;
	}

	fsstack_copy_attr_times(dir, sdcardfs_lower_inode(dir));
	fsstack_copy_inode_size(dir, lower_parent_dentry->d_inode);
	/* update number of links on parent directory */
	set_nlink(dir, sdcardfs_lower_inode(dir)->i_nlink);

	unlock_dir(lower_parent_dentry);

	if ((sbi->options.derive == DERIVE_UNIFIED) && (!strcasecmp(dentry->d_name.name, "obb"))
		&& (pi->perm == PERM_ANDROID) && (pi->userid == 0))
		make_nomedia_in_obb = 1;

	/* When creating /Android/data and /Android/obb, mark them as .nomedia */
	if (make_nomedia_in_obb ||
		((pi->perm == PERM_ANDROID) && (!strcasecmp(dentry->d_name.name, "data")))) {

		page_buf = (char *)__get_free_page(GFP_KERNEL);
		if (!page_buf) {
			printk(KERN_ERR "sdcardfs: failed to allocate page buf\n");
			goto out;
		}

		nomedia_dir_name = d_absolute_path(&lower_path, page_buf, PAGE_SIZE);
		if (IS_ERR(nomedia_dir_name)) {
			free_page((unsigned long)page_buf);
			printk(KERN_ERR "sdcardfs: failed to get .nomedia dir name\n");
			goto out;
		}

		fullpath_namelen = page_buf + PAGE_SIZE - nomedia_dir_name - 1;
		fullpath_namelen += strlen("/.nomedia");
		nomedia_fullpath = kzalloc(fullpath_namelen + 1, GFP_KERNEL);
		if (!nomedia_fullpath) {
			free_page((unsigned long)page_buf);
			printk(KERN_ERR "sdcardfs: failed to allocate .nomedia fullpath buf\n");
			goto out;
		}

		strcpy(nomedia_fullpath, nomedia_dir_name);
		free_page((unsigned long)page_buf);
		strcat(nomedia_fullpath, "/.nomedia");
		touch_err = touch(nomedia_fullpath, 0664);
		if (touch_err) {
			printk(KERN_ERR "sdcardfs: failed to touch(%s): %d\n",
							nomedia_fullpath, touch_err);
			kfree(nomedia_fullpath);
			goto out;
		}
		kfree(nomedia_fullpath);
	}
out:
	mnt_drop_write(lower_path.mnt);
out_unlock:
	sdcardfs_put_lower_path(dentry, &lower_path);
out_revert:
	REVERT_CRED(saved_cred);
out_eacces:
	return err;
}
Exemplo n.º 6
0
static void free_link(char *link)
{
	if (!IS_ERR(link))
		free_page((unsigned long) link);
}
Exemplo n.º 7
0
static int sel_make_bools(void)
{
	int i, ret;
	ssize_t len;
	struct dentry *dentry = NULL;
	struct dentry *dir = bool_dir;
	struct inode *inode = NULL;
	struct inode_security_struct *isec;
	char **names = NULL, *page;
	int num;
	int *values = NULL;
	u32 sid;

	
	for (i = 0; i < bool_num; i++)
		kfree(bool_pending_names[i]);
	kfree(bool_pending_names);
	kfree(bool_pending_values);
	bool_pending_names = NULL;
	bool_pending_values = NULL;

	sel_remove_entries(dir);

	ret = -ENOMEM;
	page = (char *)get_zeroed_page(GFP_KERNEL);
	if (!page)
		goto out;

	ret = security_get_bools(&num, &names, &values);
	if (ret)
		goto out;

	for (i = 0; i < num; i++) {
		ret = -ENOMEM;
		dentry = d_alloc_name(dir, names[i]);
		if (!dentry)
			goto out;

		ret = -ENOMEM;
		inode = sel_make_inode(dir->d_sb, S_IFREG | S_IRUGO | S_IWUSR);
		if (!inode)
			goto out;

		ret = -EINVAL;
		len = snprintf(page, PAGE_SIZE, "/%s/%s", BOOL_DIR_NAME, names[i]);
		if (len < 0)
			goto out;

		ret = -ENAMETOOLONG;
		if (len >= PAGE_SIZE)
			goto out;

		isec = (struct inode_security_struct *)inode->i_security;
		ret = security_genfs_sid("selinuxfs", page, SECCLASS_FILE, &sid);
		if (ret)
			goto out;

		isec->sid = sid;
		isec->initialized = 1;
		inode->i_fop = &sel_bool_ops;
		inode->i_ino = i|SEL_BOOL_INO_OFFSET;
		d_add(dentry, inode);
	}
	bool_num = num;
	bool_pending_names = names;
	bool_pending_values = values;

	free_page((unsigned long)page);
	return 0;
out:
	free_page((unsigned long)page);

	if (names) {
		for (i = 0; i < num; i++)
			kfree(names[i]);
		kfree(names);
	}
	kfree(values);
	sel_remove_entries(dir);

	return ret;
}
Exemplo n.º 8
0
int proc_video_policy_write(struct file* file, const char __user* buf, unsigned long count, void* data)
{
	char* page;
	char* myString;
	ssize_t ret = -ENOMEM;
	int result;
#ifdef VERY_VERBOSE
	printk("%s %ld - ", __FUNCTION__, count);
#endif
	mutex_lock(&(ProcDeviceContext->DvbContext->Lock));
	page = (char*)__get_free_page(GFP_KERNEL);
	if (page)
	{
		if (copy_from_user(page, buf, count))
			goto out;
		myString = (char*) kmalloc(count + 1, GFP_KERNEL);
		strncpy(myString, page, count);
		myString[count] = '\0';
#ifdef VERY_VERBOSE
		printk("%s\n", myString);
#endif
		if (strncmp("letterbox", myString, count - 1) == 0)
		{
			policy_e2 = VIDEO_POL_LETTER_BOX;
		}
		else if (strncmp("panscan", myString, count - 1) == 0)
		{
			policy_e2 = VIDEO_POL_PAN_SCAN;
		}
		else if (strncmp("bestfit", myString, count - 1) == 0)
		{
			policy_e2 = VIDEO_POL_BEST_FIT;
		}
		else if (strncmp("non", myString, count - 1) == 0)
		{
			policy_e2 = VIDEO_POL_NON_LINEAR;
		}
		else if (strncmp("nonlinear", myString, count - 1) == 0)
		{
			// e2 writes nonlinear
			policy_e2 = VIDEO_POL_NON_LINEAR;
		}
		kfree(myString);
		if (ProcDeviceContext->VideoStream != NULL)
		{
			policy_ply = proc_video_policy_get();
			aspect_ply = proc_video_aspect_get();
			//printk("Calling DvbStreamSetOption ->PLAY_OPTION_VIDEO_ASPECT_RATIO\n");
			result = DvbStreamSetOption(ProcDeviceContext->VideoStream, PLAY_OPTION_VIDEO_ASPECT_RATIO, aspect_ply);
			if (result != 0)
				printk("Error setting stream option %d\n", result);
			else
				ProcDeviceContext->VideoState.video_format = (video_format_t)aspect_ply;
			result = DvbStreamSetOption(ProcDeviceContext->VideoStream, PLAY_OPTION_VIDEO_DISPLAY_FORMAT, policy_ply);
			if (result != 0)
				printk("Failed to set option %d\n", result);
			else
				ProcDeviceContext->VideoState.display_format = (video_displayformat_t)policy_ply;
		}
		else
			printk("Can't set policy, VideoStream NULL\n");
	}
	ret = count;
out:
	free_page((unsigned long)page);
	mutex_unlock(&(ProcDeviceContext->DvbContext->Lock));
	return ret;
}
Exemplo n.º 9
0
/* hack hack ;-) */
int proc_video_videomode_write(struct file* file, const char __user* buf, unsigned long count, void* data)
{
	char* page;
	ssize_t ret = -ENOMEM;
	/* int result; */
	int vLoop;
	int new_count;
	char* myString = kmalloc(count + 1, GFP_KERNEL);
	void* fb;
	struct fb_info *info;
#ifdef VERY_VERBOSE
	printk("%s %ld - ", __FUNCTION__, count);
#endif
	mutex_lock(&(ProcDeviceContext->DvbContext->Lock));
	fb = stmfb_get_fbinfo_ptr();
	info = (struct fb_info*) fb;
	page = (char*)__get_free_page(GFP_KERNEL);
	if (page)
	{
		int modeToSet = -1;
		int aktmode = -1;
		ret = -EFAULT;
		if (copy_from_user(page, buf, count))
			goto out;
		/* Dagobert: echo add a \n which will be counted as a char */
		if (page[count - 1] == '\n')
			new_count = count - 1;
		else
			new_count = count;
		strncpy(myString, page, new_count);
		myString[new_count] = '\0';
#ifdef VERY_VERBOSE
		printk("%s\n", myString);
#endif
		//whithout -1 write a unsupportet string hangs the driver
		for (vLoop = 0; vLoop < (sizeof(Options) / sizeof(struct Modes)) - 1; vLoop++)
		{
			if (Options[vLoop].xres     == info->var.xres &&
					Options[vLoop].yres     == info->var.yres &&
					Options[vLoop].vxres    == info->var.xres_virtual &&
					Options[vLoop].vyres    == info->var.yres_virtual &&
					Options[vLoop].pixclock == info->var.pixclock &&
					Options[vLoop].left     == info->var.left_margin &&
					Options[vLoop].right    == info->var.right_margin &&
					Options[vLoop].upper    == info->var.upper_margin &&
					Options[vLoop].lower    == info->var.lower_margin &&
					Options[vLoop].hslen    == info->var.hsync_len &&
					Options[vLoop].vslen    == info->var.vsync_len &&
					Options[vLoop].sync     == info->var.sync/* &&
                    Options[vLoop].vmode    == info->var.vmode*/)
			{
				aktmode = vLoop;
			}
			if (strncmp(myString, Options[vLoop].name, new_count) == 0)
			{
				printk("Found mode to set %s at %d\n",  Options[vLoop].name, vLoop);
				modeToSet = vLoop;
			}
		}
		if (aktmode == modeToSet)
			modeToSet = -1;
		if (modeToSet != -1)
		{
			struct fb_var_screeninfo screen_info;
			int createNew = 0;
			memcpy(&screen_info, &info->var, sizeof(struct fb_var_screeninfo));
			if (fb != NULL)
			{
				int err;
				/* otherwise we got EBUSY from stmfb device */
				/* Dagobert: Bugfix: "demux stop" bug; ticket #10 */
				if (ProcDeviceContext != NULL)
				{
					if (ProcDeviceContext->VideoState.play_state != VIDEO_STOPPED)
						VideoIoctlStop(ProcDeviceContext, 1);
					if (isDisplayCreated(BACKEND_VIDEO_ID, ProcDeviceContext->Id))
					{
						createNew = 1;
#ifdef VERY_VERBOSE
						printk("delete display\n");
#endif
						DvbDisplayDelete(BACKEND_VIDEO_ID, ProcDeviceContext->Id);
					}
				}
				info->flags |= FBINFO_MISC_USEREVENT;
				screen_info.xres = Options[modeToSet].xres;         /* visible resolution */
				screen_info.yres = Options[modeToSet].yres;
				screen_info.xres_virtual = Options[modeToSet].vxres;        /* virtual resolution */
				screen_info.yres_virtual = Options[modeToSet].vyres;
				screen_info.pixclock = Options[modeToSet].pixclock;
				screen_info.left_margin = Options[modeToSet].left;
				screen_info.right_margin = Options[modeToSet].right;
				screen_info.upper_margin = Options[modeToSet].upper;
				screen_info.lower_margin = Options[modeToSet].lower;
				screen_info.hsync_len = Options[modeToSet].hslen;
				screen_info.vsync_len = Options[modeToSet].vslen;
				screen_info.sync = Options[modeToSet].sync;
				screen_info.vmode = Options[modeToSet].vmode;
				screen_info.activate = FB_ACTIVATE_FORCE;
				err = fb_set_var(fb, &screen_info);
				if (err != 0)
					printk("error setting new resolution %d\n", err);
				if ((ProcDeviceContext != NULL) && (createNew == 1))
				{
#ifdef VERY_VERBOSE
					printk("create new display\n");
#endif
					DisplayCreate(BACKEND_VIDEO_ID, ProcDeviceContext->Id);
					VideoIoctlPlay(ProcDeviceContext);
					err = DvbStreamSetOutputWindow(ProcDeviceContext->VideoStream,
												   0, 0, Options[modeToSet].xres, Options[modeToSet].yres);
					if (err != 0)
					{
						printk("failed to set output window %d, %d, %d\n",  Options[modeToSet].xres,  Options[modeToSet].yres, err);
					}
#ifdef VERY_VERBOSE
					else
						printk("set output window to %d, %d ok\n",  Options[modeToSet].xres,  Options[modeToSet].yres);
#endif
				}
			}
			else
			{
				printk("Cannot get stmfb_info struct\n");
			}
		}
		/* always return count to avoid endless loop */
		ret = count;
	}
out:
	free_page((unsigned long)page);
	kfree(myString);
	mutex_unlock(&(ProcDeviceContext->DvbContext->Lock));
	return ret;
}
Exemplo n.º 10
0
static void mmu_free_memory_cache(struct kvm_mmu_memory_cache *mc)
{
    while (mc->nobjs)
        free_page((unsigned long)mc->objects[--mc->nobjs]);
}
Exemplo n.º 11
0
int proc_video_switch_write(struct file* file, const char __user* buf, unsigned long count, void* data)
{
	char* page;
	char* myString;
	ssize_t ret = -ENOMEM;
	unsigned long mlen;
	printk("%s %ld - ", __FUNCTION__, count);
	mutex_lock(&(ProcDeviceContext->DvbContext->Lock));
	page = (char*)__get_free_page(GFP_KERNEL);
	if (page)
	{
		ret = -EFAULT;
		if (copy_from_user(page, buf, count))
			goto out;
		myString = (char*) kmalloc(count + 1, GFP_KERNEL);
		strncpy(myString, page, count);
		myString[count] = '\0';
		mlen = count;
		if ((count > 0) && (myString[count - 1] == '\n'))
		{
			myString[count - 1] = '\0';
			count--;
		}
		printk("proc_video_switch_write >> %s\n", myString);
		if (video_switch_type == 0)
		{
			if (fms6403_in2_sel_pin == NULL)
				fms6403_in2_sel_pin = stpio_request_pin(5, 3, "fms6403_in2_sel_pin", STPIO_OUT);
			if (fms6403_fsel0_pin == NULL)
				fms6403_fsel0_pin = stpio_request_pin(4, 6, "fms6403_fsel0_pin", STPIO_OUT);
			if (fms6403_fsel1_pin == NULL)
				fms6403_fsel1_pin = stpio_request_pin(3, 5, "fms6403_fsel1_pin", STPIO_OUT);
			if (strncmp("scart", myString, count) == 0)
			{
				stpio_set_pin(fms6403_in2_sel_pin, 0); //0=rgb 1=yvu
				printk("!!!!!!!!!!!!! SET PAL !!!!!!!!!!!!!!\n");
				video_switch = 0;
			}
			else if (strncmp("component1080p", myString, count) == 0)
			{
				stpio_set_pin(fms6403_in2_sel_pin, 1); //0=rgb 1=yvu
				stpio_set_pin(fms6403_fsel0_pin, 1); //1080p50
				stpio_set_pin(fms6403_fsel1_pin, 1);
				printk("!!!!!!!!!!!!! SET Filter Bypass !!!!!!!!!!!!!!\n");
				video_switch = 1;
			}
			else if (strncmp("component1080i", myString, count) == 0)
			{
				stpio_set_pin(fms6403_in2_sel_pin, 1); //0=rgb 1=yvu
				stpio_set_pin(fms6403_fsel0_pin, 0); //720p/1080i
				stpio_set_pin(fms6403_fsel1_pin, 1);
				printk("!!!!!!!!!!!!! SET Filter FMS6403 32Mhz !!!!!!!!!!!!!!\n");
				video_switch = 2;
			}
			else if (strncmp("component720p", myString, count) == 0)
			{
				stpio_set_pin(fms6403_in2_sel_pin, 1); //0=rgb 1=yvu
				stpio_set_pin(fms6403_fsel0_pin, 0); //720p/1080i
				stpio_set_pin(fms6403_fsel1_pin, 1);
				printk("!!!!!!!!!!!!! SET Filter FMS6403 32Mhz !!!!!!!!!!!!!!\n");
				video_switch = 3;
			}
			else if (strncmp("component576p", myString, count) == 0)
			{
				stpio_set_pin(fms6403_in2_sel_pin, 1); //0=rgb 1=yvu
				stpio_set_pin(fms6403_fsel0_pin, 1); //576p
				stpio_set_pin(fms6403_fsel1_pin, 0);
				printk("!!!!!!!!!!!!! SET Filter FMS6403 15Mhz !!!!!!!!!!!!!!\n");
				video_switch = 4;
			}
			else if (strncmp("component576i", myString, count) == 0)
			{
				stpio_set_pin(fms6403_in2_sel_pin, 1); //0=rgb 1=yvu
				stpio_set_pin(fms6403_fsel0_pin, 1); //576p
				stpio_set_pin(fms6403_fsel1_pin, 0);
				printk("!!!!!!!!!!!!! SET Filter FMS6403 15Mhz !!!!!!!!!!!!!!\n");
				video_switch = 5;
			}
		} //switch type
		if (video_switch_type == 1) //bxzb
		{
			if (pin02 == NULL)
				pin02 = stpio_request_pin(0, 2, "pin02", STPIO_OUT);
			if (pin06 == NULL)
				pin06 = stpio_request_pin(0, 6, "pin06", STPIO_OUT);
			if (pin24 == NULL)
				pin24 = stpio_request_pin(2, 4, "pin23", STPIO_OUT);
			//0 0 1 - jest rgb
			//0 0 0 - jest rgb
			stpio_set_pin(pin02, 0); //pin6 - E
			stpio_set_pin(pin06, 0);
			stpio_set_pin(pin24, 1); //1-rgb
		}
		/* always return count to avoid endless loop */
		//ret = count;
		ret = mlen;
		kfree(myString);
	}
out:
	free_page((unsigned long)page);
	mutex_unlock(&(ProcDeviceContext->DvbContext->Lock));
	return ret;
}
Exemplo n.º 12
0
/*
 * Proc info file read handler.
 *
 * This function is called when the 'info' file is opened for reading.
 * It prints the following driver related information -
 *      - Driver name
 *      - Driver version
 *      - Driver extended version
 *      - Interface name
 *      - BSS mode
 *      - Media state (connected or disconnected)
 *      - MAC address
 *      - Total number of Tx bytes
 *      - Total number of Rx bytes
 *      - Total number of Tx packets
 *      - Total number of Rx packets
 *      - Total number of dropped Tx packets
 *      - Total number of dropped Rx packets
 *      - Total number of corrupted Tx packets
 *      - Total number of corrupted Rx packets
 *      - Carrier status (on or off)
 *      - Tx queue status (started or stopped)
 *
 * For STA mode drivers, it also prints the following extra -
 *      - ESSID
 *      - BSSID
 *      - Channel
 *      - Region code
 *      - Multicast count
 *      - Multicast addresses
 */
static ssize_t
mwifiex_info_read(struct file *file, char __user *ubuf,
		  size_t count, loff_t *ppos)
{
	struct mwifiex_private *priv =
		(struct mwifiex_private *) file->private_data;
	struct net_device *netdev = priv->netdev;
	struct netdev_hw_addr *ha;
	struct netdev_queue *txq;
	unsigned long page = get_zeroed_page(GFP_KERNEL);
	char *p = (char *) page, fmt[64];
	struct mwifiex_bss_info info;
	ssize_t ret;
	int i = 0;

	if (!p)
		return -ENOMEM;

	memset(&info, 0, sizeof(info));
	ret = mwifiex_get_bss_info(priv, &info);
	if (ret)
		goto free_and_exit;

	mwifiex_drv_get_driver_version(priv->adapter, fmt, sizeof(fmt) - 1);

	if (!priv->version_str[0])
		mwifiex_get_ver_ext(priv);

	p += sprintf(p, "driver_name = " "\"mwifiex\"\n");
	p += sprintf(p, "driver_version = %s", fmt);
	p += sprintf(p, "\nverext = %s", priv->version_str);
	p += sprintf(p, "\ninterface_name=\"%s\"\n", netdev->name);

	if (info.bss_mode >= ARRAY_SIZE(bss_modes))
		p += sprintf(p, "bss_mode=\"%d\"\n", info.bss_mode);
	else
		p += sprintf(p, "bss_mode=\"%s\"\n", bss_modes[info.bss_mode]);

	p += sprintf(p, "media_state=\"%s\"\n",
		     (!priv->media_connected ? "Disconnected" : "Connected"));
	p += sprintf(p, "mac_address=\"%pM\"\n", netdev->dev_addr);

	if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) {
		p += sprintf(p, "multicast_count=\"%d\"\n",
			     netdev_mc_count(netdev));
		p += sprintf(p, "essid=\"%s\"\n", info.ssid.ssid);
		p += sprintf(p, "bssid=\"%pM\"\n", info.bssid);
		p += sprintf(p, "channel=\"%d\"\n", (int) info.bss_chan);
		p += sprintf(p, "country_code = \"%s\"\n", info.country_code);

		netdev_for_each_mc_addr(ha, netdev)
			p += sprintf(p, "multicast_address[%d]=\"%pM\"\n",
					i++, ha->addr);
	}

	p += sprintf(p, "num_tx_bytes = %lu\n", priv->stats.tx_bytes);
	p += sprintf(p, "num_rx_bytes = %lu\n", priv->stats.rx_bytes);
	p += sprintf(p, "num_tx_pkts = %lu\n", priv->stats.tx_packets);
	p += sprintf(p, "num_rx_pkts = %lu\n", priv->stats.rx_packets);
	p += sprintf(p, "num_tx_pkts_dropped = %lu\n", priv->stats.tx_dropped);
	p += sprintf(p, "num_rx_pkts_dropped = %lu\n", priv->stats.rx_dropped);
	p += sprintf(p, "num_tx_pkts_err = %lu\n", priv->stats.tx_errors);
	p += sprintf(p, "num_rx_pkts_err = %lu\n", priv->stats.rx_errors);
	p += sprintf(p, "carrier %s\n", ((netif_carrier_ok(priv->netdev))
					 ? "on" : "off"));
	p += sprintf(p, "tx queue");
	for (i = 0; i < netdev->num_tx_queues; i++) {
		txq = netdev_get_tx_queue(netdev, i);
		p += sprintf(p, " %d:%s", i, netif_tx_queue_stopped(txq) ?
			     "stopped" : "started");
	}
	p += sprintf(p, "\n");

	ret = simple_read_from_buffer(ubuf, count, ppos, (char *) page,
				      (unsigned long) p - page);

free_and_exit:
	free_page(page);
	return ret;
}
Exemplo n.º 13
0
/*
 * Proc getlog file read handler.
 *
 * This function is called when the 'getlog' file is opened for reading
 * It prints the following log information -
 *      - Number of multicast Tx frames
 *      - Number of failed packets
 *      - Number of Tx retries
 *      - Number of multicast Tx retries
 *      - Number of duplicate frames
 *      - Number of RTS successes
 *      - Number of RTS failures
 *      - Number of ACK failures
 *      - Number of fragmented Rx frames
 *      - Number of multicast Rx frames
 *      - Number of FCS errors
 *      - Number of Tx frames
 *      - WEP ICV error counts
 *      - Number of received beacons
 *      - Number of missed beacons
 */
static ssize_t
mwifiex_getlog_read(struct file *file, char __user *ubuf,
		    size_t count, loff_t *ppos)
{
	struct mwifiex_private *priv =
		(struct mwifiex_private *) file->private_data;
	unsigned long page = get_zeroed_page(GFP_KERNEL);
	char *p = (char *) page;
	ssize_t ret;
	struct mwifiex_ds_get_stats stats;

	if (!p)
		return -ENOMEM;

	memset(&stats, 0, sizeof(stats));
	ret = mwifiex_get_stats_info(priv, &stats);
	if (ret)
		goto free_and_exit;

	p += sprintf(p, "\n"
		     "mcasttxframe     %u\n"
		     "failed           %u\n"
		     "retry            %u\n"
		     "multiretry       %u\n"
		     "framedup         %u\n"
		     "rtssuccess       %u\n"
		     "rtsfailure       %u\n"
		     "ackfailure       %u\n"
		     "rxfrag           %u\n"
		     "mcastrxframe     %u\n"
		     "fcserror         %u\n"
		     "txframe          %u\n"
		     "wepicverrcnt-1   %u\n"
		     "wepicverrcnt-2   %u\n"
		     "wepicverrcnt-3   %u\n"
		     "wepicverrcnt-4   %u\n"
		     "bcn_rcv_cnt   %u\n"
		     "bcn_miss_cnt   %u\n",
		     stats.mcast_tx_frame,
		     stats.failed,
		     stats.retry,
		     stats.multi_retry,
		     stats.frame_dup,
		     stats.rts_success,
		     stats.rts_failure,
		     stats.ack_failure,
		     stats.rx_frag,
		     stats.mcast_rx_frame,
		     stats.fcs_error,
		     stats.tx_frame,
		     stats.wep_icv_error[0],
		     stats.wep_icv_error[1],
		     stats.wep_icv_error[2],
		     stats.wep_icv_error[3],
		     stats.bcn_rcv_cnt,
		     stats.bcn_miss_cnt);


	ret = simple_read_from_buffer(ubuf, count, ppos, (char *) page,
				      (unsigned long) p - page);

free_and_exit:
	free_page(page);
	return ret;
}
Exemplo n.º 14
0
//TODO: say avs to send the widescreenflag if needed
int proc_video_aspect_write(struct file *file, const char __user *buf, unsigned long count, void *data)
{
	char *page;
	char *myString;
	ssize_t ret = -ENOMEM;
	/* int result; */

#ifdef VERY_VERBOSE
	printk("%s %ld - ", __FUNCTION__, count);

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
	printk("%p, %p, %p", ProcDeviceContext, ProcDeviceContext->DvbContext, ProcDeviceContext->VideoStream);
#else
	printk("%p, %p, %d, %p", ProcDeviceContext, ProcDeviceContext->DvbContext, ProcDeviceContext->DvbContext->Lock.count.counter, ProcDeviceContext->VideoStream);
#endif
#endif

	mutex_lock (&(ProcDeviceContext->DvbContext->Lock));

	page = (char *)__get_free_page(GFP_KERNEL);
	if (page)
	{
		ret = -EFAULT;
		if (copy_from_user(page, buf, count))
			goto out;

		myString = (char *) kmalloc(count + 1, GFP_KERNEL);
		strncpy(myString, page, count);
		myString[count] = '\0';
		//printk("%s\n", myString);

		aspect_e2 = VIDEO_FORMAT_16_9;

#ifdef VERY_VERBOSE
		printk("%s\n", myString);
#endif

		if (strncmp("4:3", myString, count - 1) == 0)
		{
			aspect_e2 = VIDEO_FORMAT_4_3;
		}

		if (strncmp("16:9", myString, count - 1) == 0)
		{
			aspect_e2 = VIDEO_FORMAT_16_9;
		}

		/*if (strncmp("221:1", myString, count - 1) == 0)
		{
			aspect_e2 = VIDEO_FORMAT_221_1;
		}*/

		//we dont support any, whatever this is
		if (strncmp("any", myString, count - 1) == 0)
		{
			aspect_e2 = VIDEO_FORMAT_4_3;
		}

		//printk("Video Format = %d\n", format);

		/* always return count to avoid endless loop */
		ret = count;
		kfree(myString);
	}

out:
	free_page((unsigned long)page);
	mutex_unlock (&(ProcDeviceContext->DvbContext->Lock));
	return ret;
}
static int serial_m3110_probe(struct spi_device *spi)
{
	struct uart_max3110 *max;
	void *buffer;
	u16 res;
	int ret = 0;
	struct plat_max3110 *pdata = spi->dev.platform_data;
	if (!pdata)
		return -EINVAL;

	max = kzalloc(sizeof(*max), GFP_KERNEL);
	if (!max)
		return -ENOMEM;

	/* Set spi info */
	spi->bits_per_word = 16;
	max->clock = MAX3110_HIGH_CLK;

	spi_setup(spi);

	max->port.type = PORT_MAX3100;
	max->port.fifosize = 2;		/* Only have 16b buffer */
	max->port.ops = &serial_m3110_ops;
	max->port.line = 0;
	max->port.dev = &spi->dev;
	max->port.uartclk = 115200;

	max->spi = spi;
	strcpy(max->name, spi->modalias);
	max->irq = (u16)spi->irq;

	mutex_init(&max->thread_mutex);
	mutex_init(&max->io_mutex);

	max->word_7bits = 0;
	max->parity = 0;
	max->baud = 0;

	max->cur_conf = 0;
	max->uart_flags = 0;

	/* Check if reading configuration register returns something sane */

	res = RC_TAG;
	ret = max3110_write_then_read(max, (u8 *)&res, (u8 *)&res, 2, 0);
	if (ret < 0 || res == 0 || res == 0xffff) {
		dev_dbg(&spi->dev, "MAX3111 deemed not present (conf reg %04x)",
									res);
		ret = -ENODEV;
		goto err_get_page;
	}

	buffer = (void *)__get_free_page(GFP_KERNEL);
	if (!buffer) {
		ret = -ENOMEM;
		goto err_get_page;
	}
	max->con_xmit.buf = buffer;
	max->con_xmit.head = 0;
	max->con_xmit.tail = 0;

	init_waitqueue_head(&max->wq);

	max->main_thread = kthread_run(max3110_main_thread,
					max, "max3110_main");
	if (IS_ERR(max->main_thread)) {
		ret = PTR_ERR(max->main_thread);
		goto err_kthread;
	}

	max->irq_edge_triggered = pdata->irq_edge_triggered;

	if (max->irq > 0) {
		if (max->irq_edge_triggered) {
			ret = request_irq(max->irq, serial_m3110_irq,
					IRQ_TYPE_EDGE_FALLING, "max3110", max);
		} else {
			ret = request_threaded_irq(max->irq, NULL,
					serial_m3110_irq,
					IRQF_ONESHOT, "max3110", max);
		}

		if (ret) {
			max->irq = 0;
			dev_warn(&spi->dev,
			"unable to allocate IRQ, will use polling method\n");
		}
	}

	spi_set_drvdata(spi, max);
	pmax = max;

	/* Give membase a psudo value to pass serial_core's check */
	max->port.membase = (void *)0xff110000;
	uart_add_one_port(&serial_m3110_reg, &max->port);

	return 0;

err_kthread:
	free_page((unsigned long)buffer);
err_get_page:
	kfree(max);
	return ret;
}
Exemplo n.º 16
0
int proc_video_pal_h_start_write(struct file* file, const char __user* buf, unsigned long count, void* data)
{
	char* page;
	ssize_t ret = -ENOMEM;
	/* int result; */
	int value;
	char* myString = kmalloc(count + 1, GFP_KERNEL);
#ifdef VERY_VERBOSE
	printk("%s %ld - ", __FUNCTION__, count);
#endif
	mutex_lock(&(ProcDeviceContext->DvbContext->Lock));
	page = (char*)__get_free_page(GFP_KERNEL);
	if (page)
	{
		void* fb;
		struct fb_info* info;
		struct fb_var_screeninfo screen_info;
		int createNew = 0;
		ret = -EFAULT;
		if (copy_from_user(page, buf, count))
			goto out;
		strncpy(myString, page, count);
		myString[count] = '\0';
#ifdef VERY_VERBOSE
		printk("%s\n", myString);
#endif
		sscanf(myString, "%x", &value);
		fb = stmfb_get_fbinfo_ptr();
		info = (struct fb_info*) fb;
		memcpy(&screen_info, &info->var, sizeof(struct fb_var_screeninfo));
		if (fb != NULL)
		{
			int err;
			/* otherwise we got EBUSY from stmfb device */
			/* Dagobert: Bugfix: "demux stop" bug; ticket #10 */
			if (ProcDeviceContext != NULL)
			{
				if (ProcDeviceContext->VideoState.play_state != VIDEO_STOPPED)
					VideoIoctlStop(ProcDeviceContext, 1);
				if (isDisplayCreated(BACKEND_VIDEO_ID, ProcDeviceContext->Id))
				{
					createNew = 1;
#ifdef VERY_VERBOSE
					printk("delete display\n");
#endif
					DvbDisplayDelete(BACKEND_VIDEO_ID, ProcDeviceContext->Id);
				}
			}
			info->flags |= FBINFO_MISC_USEREVENT;
			screen_info.left_margin = value;
			err = fb_set_var(fb, &screen_info);
			if (err != 0)
				printk("error setting new resolution %d\n", err);
			if ((ProcDeviceContext != NULL) && (createNew == 1))
			{
#ifdef VERY_VERBOSE
				printk("create new display\n");
#endif
				DisplayCreate(BACKEND_VIDEO_ID, ProcDeviceContext->Id);
				VideoIoctlPlay(ProcDeviceContext);
				err = DvbStreamSetOutputWindow(ProcDeviceContext->VideoStream,
											   0, 0, screen_info.xres, screen_info.yres);
				if (err != 0)
				{
					printk("failed to set output window %d, %d, %d\n",  screen_info.xres,  screen_info.yres, err);
				}
#ifdef VERY_VERBOSE
				else
					printk("set output window to %d, %d ok\n",  screen_info.xres,  screen_info.yres);
#endif
			}
		}
		else
		{
			printk("Cannot get stmfb_info struct\n");
		}
		/* always return count to avoid endless loop */
		ret = count;
	}
out:
	free_page((unsigned long)page);
	kfree(myString);
	mutex_unlock(&(ProcDeviceContext->DvbContext->Lock));
	return ret;
}
Exemplo n.º 17
0
/**
 *    write_suspend_image - Write entire image to disk.
 *
 *    After writing suspend signature to the disk, suspend may no
 *    longer fail: we have ready-to-run image in swap, and rollback
 *    would happen on next reboot -- corrupting data.
 *
 *    Note: The buffer we allocate to use to write the suspend header is
 *    not freed; its not needed since system is going down anyway
 *    (plus it causes oops and I'm lazy^H^H^H^Htoo busy).
 */
static int write_suspend_image(void)
{
	int i;
	swp_entry_t entry, prev = { 0 };
	int nr_pgdir_pages = SUSPEND_PD_PAGES(nr_copy_pages);
	union diskpage *cur,  *buffer = (union diskpage *)get_zeroed_page(GFP_ATOMIC);
	unsigned long address;
	struct page *page;

	if (!buffer)
		return -ENOMEM;

	printk( "Writing data to swap (%d pages): ", nr_copy_pages );
	for (i=0; i<nr_copy_pages; i++) {
		if (!(i%100))
			printk( "." );
		if (!(entry = get_swap_page()).val)
			panic("\nNot enough swapspace when writing data" );
		
		if (swapfile_used[swp_type(entry)] != SWAPFILE_SUSPEND)
			panic("\nPage %d: not enough swapspace on suspend device", i );
	    
		address = (pagedir_nosave+i)->address;
		page = virt_to_page(address);
		rw_swap_page_sync(WRITE, entry, page);
		(pagedir_nosave+i)->swap_address = entry;
	}
	printk( "|\n" );
	printk( "Writing pagedir (%d pages): ", nr_pgdir_pages);
	for (i=0; i<nr_pgdir_pages; i++) {
		cur = (union diskpage *)((char *) pagedir_nosave)+i;
		BUG_ON ((char *) cur != (((char *) pagedir_nosave) + i*PAGE_SIZE));
		printk( "." );
		if (!(entry = get_swap_page()).val) {
			printk(KERN_CRIT "Not enough swapspace when writing pgdir\n" );
			panic("Don't know how to recover");
			free_page((unsigned long) buffer);
			return -ENOSPC;
		}

		if(swapfile_used[swp_type(entry)] != SWAPFILE_SUSPEND)
			panic("\nNot enough swapspace for pagedir on suspend device" );

		BUG_ON (sizeof(swp_entry_t) != sizeof(long));
		BUG_ON (PAGE_SIZE % sizeof(struct pbe));

		cur->link.next = prev;				
		page = virt_to_page((unsigned long)cur);
		rw_swap_page_sync(WRITE, entry, page);
		prev = entry;
	}
	printk("H");
	BUG_ON (sizeof(struct suspend_header) > PAGE_SIZE-sizeof(swp_entry_t));
	BUG_ON (sizeof(union diskpage) != PAGE_SIZE);
	if (!(entry = get_swap_page()).val)
		panic( "\nNot enough swapspace when writing header" );
	if (swapfile_used[swp_type(entry)] != SWAPFILE_SUSPEND)
		panic("\nNot enough swapspace for header on suspend device" );

	cur = (void *) buffer;
	if (fill_suspend_header(&cur->sh))
		panic("\nOut of memory while writing header");
		
	cur->link.next = prev;

	page = virt_to_page((unsigned long)cur);
	rw_swap_page_sync(WRITE, entry, page);
	prev = entry;

	printk( "S" );
	mark_swapfiles(prev, MARK_SWAP_SUSPEND);
	printk( "|\n" );

	MDELAY(1000);
	return 0;
}
Exemplo n.º 18
0
static int rpavscsi_init_crq_queue(struct crq_queue *queue,
				   struct ibmvscsi_host_data *hostdata,
				   int max_requests)
{
	int rc;
	int retrc;
	struct vio_dev *vdev = to_vio_dev(hostdata->dev);

	queue->msgs = (struct viosrp_crq *)get_zeroed_page(GFP_KERNEL);

	if (!queue->msgs)
		goto malloc_failed;
	queue->size = PAGE_SIZE / sizeof(*queue->msgs);

	queue->msg_token = dma_map_single(hostdata->dev, queue->msgs,
					  queue->size * sizeof(*queue->msgs),
					  DMA_BIDIRECTIONAL);

	if (dma_mapping_error(hostdata->dev, queue->msg_token))
		goto map_failed;

	gather_partition_info();
	set_adapter_info(hostdata);

	retrc = rc = plpar_hcall_norets(H_REG_CRQ,
				vdev->unit_address,
				queue->msg_token, PAGE_SIZE);
	if (rc == H_RESOURCE)
		
		rc = rpavscsi_reset_crq_queue(queue,
					      hostdata);

	if (rc == 2) {
		
		dev_warn(hostdata->dev, "Partner adapter not ready\n");
		retrc = 0;
	} else if (rc != 0) {
		dev_warn(hostdata->dev, "Error %d opening adapter\n", rc);
		goto reg_crq_failed;
	}

	queue->cur = 0;
	spin_lock_init(&queue->lock);

	tasklet_init(&hostdata->srp_task, (void *)rpavscsi_task,
		     (unsigned long)hostdata);

	if (request_irq(vdev->irq,
			rpavscsi_handle_event,
			0, "ibmvscsi", (void *)hostdata) != 0) {
		dev_err(hostdata->dev, "couldn't register irq 0x%x\n",
			vdev->irq);
		goto req_irq_failed;
	}

	rc = vio_enable_interrupts(vdev);
	if (rc != 0) {
		dev_err(hostdata->dev, "Error %d enabling interrupts!!!\n", rc);
		goto req_irq_failed;
	}

	return retrc;

      req_irq_failed:
	tasklet_kill(&hostdata->srp_task);
	rc = 0;
	do {
		if (rc)
			msleep(100);
		rc = plpar_hcall_norets(H_FREE_CRQ, vdev->unit_address);
	} while ((rc == H_BUSY) || (H_IS_LONG_BUSY(rc)));
      reg_crq_failed:
	dma_unmap_single(hostdata->dev,
			 queue->msg_token,
			 queue->size * sizeof(*queue->msgs), DMA_BIDIRECTIONAL);
      map_failed:
	free_page((unsigned long)queue->msgs);
      malloc_failed:
	return -1;
}
Exemplo n.º 19
0
static int handle_stsi(struct kvm_vcpu *vcpu)
{
	int fc = (vcpu->run->s.regs.gprs[0] & 0xf0000000) >> 28;
	int sel1 = vcpu->run->s.regs.gprs[0] & 0xff;
	int sel2 = vcpu->run->s.regs.gprs[1] & 0xffff;
	unsigned long mem = 0;
	u64 operand2;
	int rc = 0;

	vcpu->stat.instruction_stsi++;
	VCPU_EVENT(vcpu, 4, "stsi: fc: %x sel1: %x sel2: %x", fc, sel1, sel2);

	if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
		return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);

	if (fc > 3) {
		kvm_s390_set_psw_cc(vcpu, 3);
		return 0;
	}

	if (vcpu->run->s.regs.gprs[0] & 0x0fffff00
	    || vcpu->run->s.regs.gprs[1] & 0xffff0000)
		return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);

	if (fc == 0) {
		vcpu->run->s.regs.gprs[0] = 3 << 28;
		kvm_s390_set_psw_cc(vcpu, 0);
		return 0;
	}

	operand2 = kvm_s390_get_base_disp_s(vcpu);

	if (operand2 & 0xfff)
		return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);

	switch (fc) {
	case 1: /* same handling for 1 and 2 */
	case 2:
		mem = get_zeroed_page(GFP_KERNEL);
		if (!mem)
			goto out_no_data;
		if (stsi((void *) mem, fc, sel1, sel2))
			goto out_no_data;
		break;
	case 3:
		if (sel1 != 2 || sel2 != 2)
			goto out_no_data;
		mem = get_zeroed_page(GFP_KERNEL);
		if (!mem)
			goto out_no_data;
		handle_stsi_3_2_2(vcpu, (void *) mem);
		break;
	}

	if (copy_to_guest_absolute(vcpu, operand2, (void *) mem, PAGE_SIZE)) {
		rc = kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
		goto out_exception;
	}
	trace_kvm_s390_handle_stsi(vcpu, fc, sel1, sel2, operand2);
	free_page(mem);
	kvm_s390_set_psw_cc(vcpu, 0);
	vcpu->run->s.regs.gprs[0] = 0;
	return 0;
out_no_data:
	kvm_s390_set_psw_cc(vcpu, 3);
out_exception:
	free_page(mem);
	return rc;
}
Exemplo n.º 20
0
static void ghes_estatus_pool_free_chunk_page(struct gen_pool *pool,
					      struct gen_pool_chunk *chunk,
					      void *data)
{
	free_page(chunk->start_addr);
}
Exemplo n.º 21
0
static int proc_ide_write_settings(struct file *file, const char __user *buffer,
				   unsigned long count, void *data)
{
	ide_drive_t	*drive = (ide_drive_t *) data;
	char		name[MAX_LEN + 1];
	int		for_real = 0;
	unsigned long	n;
	ide_settings_t	*setting;
	char *buf, *s;

	if (!capable(CAP_SYS_ADMIN))
		return -EACCES;

	proc_ide_settings_warn();

	if (count >= PAGE_SIZE)
		return -EINVAL;

	s = buf = (char *)__get_free_page(GFP_USER);
	if (!buf)
		return -ENOMEM;

	if (copy_from_user(buf, buffer, count)) {
		free_page((unsigned long)buf);
		return -EFAULT;
	}

	buf[count] = '\0';

	/*
	 * Skip over leading whitespace
	 */
	while (count && isspace(*s)) {
		--count;
		++s;
	}
	/*
	 * Do one full pass to verify all parameters,
	 * then do another to actually write the new settings.
	 */
	do {
		char *p = s;
		n = count;
		while (n > 0) {
			unsigned val;
			char *q = p;

			while (n > 0 && *p != ':') {
				--n;
				p++;
			}
			if (*p != ':')
				goto parse_error;
			if (p - q > MAX_LEN)
				goto parse_error;
			memcpy(name, q, p - q);
			name[p - q] = 0;

			if (n > 0) {
				--n;
				p++;
			} else
				goto parse_error;

			val = simple_strtoul(p, &q, 10);
			n -= q - p;
			p = q;
			if (n > 0 && !isspace(*p))
				goto parse_error;
			while (n > 0 && isspace(*p)) {
				--n;
				++p;
			}

			mutex_lock(&ide_setting_mtx);
			setting = ide_find_setting_by_name(drive, name);
			if (!setting) {
				mutex_unlock(&ide_setting_mtx);
				goto parse_error;
			}
			if (for_real)
				ide_write_setting(drive, setting, val * setting->div_factor / setting->mul_factor);
			mutex_unlock(&ide_setting_mtx);
		}
	} while (!for_real++);
	free_page((unsigned long)buf);
	return count;
parse_error:
	free_page((unsigned long)buf);
	printk("proc_ide_write_settings(): parse error\n");
	return -EINVAL;
}
Exemplo n.º 22
0
static int serial_omap_startup(struct uart_port *port)
{
	struct uart_omap_port *up = (struct uart_omap_port *)port;
	unsigned long flags = 0;
	int retval;

	/*
	 * Allocate the IRQ
	 */
	retval = request_irq(up->port.irq, serial_omap_irq, up->port.irqflags,
				up->name, up);
	if (retval)
		return retval;

	dev_dbg(up->port.dev, "serial_omap_startup+%d\n", up->port.line);

	pm_runtime_get_sync(&up->pdev->dev);
	/*
	 * Clear the FIFO buffers and disable them.
	 * (they will be reenabled in set_termios())
	 */
	serial_omap_clear_fifos(up);
	/* For Hardware flow control */
	serial_out(up, UART_MCR, UART_MCR_RTS);

	/*
	 * Clear the interrupt registers.
	 */
	(void) serial_in(up, UART_LSR);
	if (serial_in(up, UART_LSR) & UART_LSR_DR)
		(void) serial_in(up, UART_RX);
	(void) serial_in(up, UART_IIR);
	(void) serial_in(up, UART_MSR);

	/*
	 * Now, initialize the UART
	 */
	serial_out(up, UART_LCR, UART_LCR_WLEN8);
	spin_lock_irqsave(&up->port.lock, flags);
	/*
	 * Most PC uarts need OUT2 raised to enable interrupts.
	 */
	up->port.mctrl |= TIOCM_OUT2;
	serial_omap_set_mctrl(&up->port, up->port.mctrl);
	spin_unlock_irqrestore(&up->port.lock, flags);

	up->msr_saved_flags = 0;
	if (up->use_dma) {
		free_page((unsigned long)up->port.state->xmit.buf);
		up->port.state->xmit.buf = dma_alloc_coherent(NULL,
			UART_XMIT_SIZE,
			(dma_addr_t *)&(up->uart_dma.tx_buf_dma_phys),
			0);
		init_timer(&(up->uart_dma.rx_timer));
		up->uart_dma.rx_timer.function = serial_omap_rxdma_poll;
		up->uart_dma.rx_timer.data = up->port.line;
		/* Currently the buffer size is 4KB. Can increase it */
		up->uart_dma.rx_buf = dma_alloc_coherent(NULL,
			up->uart_dma.rx_buf_size,
			(dma_addr_t *)&(up->uart_dma.rx_buf_dma_phys), 0);
	}
	/*
	 * Finally, enable interrupts. Note: Modem status interrupts
	 * are set via set_termios(), which will be occurring imminently
	 * anyway, so we don't enable them here.
	 */
	up->ier = UART_IER_RLSI | UART_IER_RDI;
	serial_out(up, UART_IER, up->ier);

	/* Enable module level wake up */
	serial_out(up, UART_OMAP_WER, OMAP_UART_WER_MOD_WKUP);

	pm_runtime_mark_last_busy(&up->pdev->dev);
	pm_runtime_put_autosuspend(&up->pdev->dev);
	up->port_activity = jiffies;
	return 0;
}
Exemplo n.º 23
0
int init_new_context_skas(struct task_struct *task, struct mm_struct *mm)
{
 	struct mmu_context_skas *from_mm = NULL;
	struct mmu_context_skas *to_mm = &mm->context.skas;
	unsigned long stack = 0;
	int ret = -ENOMEM;

	if(skas_needs_stub){
		stack = get_zeroed_page(GFP_KERNEL);
		if(stack == 0)
			goto out;

		/* This zeros the entry that pgd_alloc didn't, needed since
		 * we are about to reinitialize it, and want mm.nr_ptes to
		 * be accurate.
		 */
		mm->pgd[USER_PTRS_PER_PGD] = __pgd(0);

		ret = init_stub_pte(mm, CONFIG_STUB_CODE,
				    (unsigned long) &__syscall_stub_start);
		if(ret)
			goto out_free;

		ret = init_stub_pte(mm, CONFIG_STUB_DATA, stack);
		if(ret)
			goto out_free;

		mm->nr_ptes--;
	}

	to_mm->id.stack = stack;
	if(current->mm != NULL && current->mm != &init_mm)
		from_mm = &current->mm->context.skas;

	if(proc_mm){
		ret = new_mm(stack);
		if(ret < 0){
			printk("init_new_context_skas - new_mm failed, "
			       "errno = %d\n", ret);
			goto out_free;
		}
		to_mm->id.u.mm_fd = ret;
	}
	else {
		if(from_mm)
			to_mm->id.u.pid = copy_context_skas0(stack,
							     from_mm->id.u.pid);
		else to_mm->id.u.pid = start_userspace(stack);
	}

	ret = init_new_ldt(to_mm, from_mm);
	if(ret < 0){
		printk("init_new_context_skas - init_ldt"
		       " failed, errno = %d\n", ret);
		goto out_free;
	}

	return 0;

 out_free:
	if(to_mm->id.stack != 0)
		free_page(to_mm->id.stack);
 out:
	return ret;
}
Exemplo n.º 24
0
static void ati_free_page_map(struct ati_page_map *page_map)
{
	unmap_page_from_agp(virt_to_page(page_map->real));
	set_memory_wb((unsigned long)page_map->real, 1);
	free_page((unsigned long) page_map->real);
}
static void serverworks_free_page_map(struct serverworks_page_map *page_map)
{
	iounmap(page_map->remapped);
	ClearPageReserved(virt_to_page(page_map->real));
	free_page((unsigned long) page_map->real);
}
Exemplo n.º 26
0
asmlinkage long sys_poll(struct pollfd * ufds, unsigned int nfds, long timeout)
{
	int i, j, fdcount, err;
	struct pollfd **fds;
	poll_table table, *wait;
	int nchunks, nleft;

	/* Do a sanity check on nfds ... */
	if (nfds > current->files->max_fdset && nfds > OPEN_MAX)
		return -EINVAL;

	if (timeout) {
		/* Careful about overflow in the intermediate values */
		if ((unsigned long) timeout < MAX_SCHEDULE_TIMEOUT / HZ)
			timeout = (unsigned long)(timeout*HZ+999)/1000+1;
		else /* Negative or overflow */
			timeout = MAX_SCHEDULE_TIMEOUT;
	}

	poll_initwait(&table);
	wait = &table;
	if (!timeout)
		wait = NULL;

	err = -ENOMEM;
	fds = NULL;
	if (nfds != 0) {
		fds = (struct pollfd **)kmalloc(
			(1 + (nfds - 1) / POLLFD_PER_PAGE) * sizeof(struct pollfd *),
			GFP_KERNEL);
		if (fds == NULL)
			goto out;
	}

	nchunks = 0;
	nleft = nfds;
	while (nleft > POLLFD_PER_PAGE) { /* allocate complete PAGE_SIZE chunks */
		fds[nchunks] = (struct pollfd *)__get_free_page(GFP_KERNEL);
		if (fds[nchunks] == NULL)
			goto out_fds;
		nchunks++;
		nleft -= POLLFD_PER_PAGE;
	}
	if (nleft) { /* allocate last PAGE_SIZE chunk, only nleft elements used */
		fds[nchunks] = (struct pollfd *)__get_free_page(GFP_KERNEL);
		if (fds[nchunks] == NULL)
			goto out_fds;
	}

	err = -EFAULT;
	for (i=0; i < nchunks; i++)
		if (copy_from_user(fds[i], ufds + i*POLLFD_PER_PAGE, PAGE_SIZE))
			goto out_fds1;
	if (nleft) {
		if (copy_from_user(fds[nchunks], ufds + nchunks*POLLFD_PER_PAGE, 
				nleft * sizeof(struct pollfd)))
			goto out_fds1;
	}

	fdcount = do_poll(nfds, nchunks, nleft, fds, wait, timeout);

	/* OK, now copy the revents fields back to user space. */
	for(i=0; i < nchunks; i++)
		for (j=0; j < POLLFD_PER_PAGE; j++, ufds++)
			__put_user((fds[i] + j)->revents, &ufds->revents);
	if (nleft)
		for (j=0; j < nleft; j++, ufds++)
			__put_user((fds[nchunks] + j)->revents, &ufds->revents);

	err = fdcount;
	if (!fdcount && signal_pending(current))
		err = -EINTR;

out_fds1:
	if (nleft)
		free_page((unsigned long)(fds[nchunks]));
out_fds:
	for (i=0; i < nchunks; i++)
		free_page((unsigned long)(fds[i]));
	if (nfds != 0)
		kfree(fds);
out:
	poll_freewait(&table);
	return err;
}
Exemplo n.º 27
0
// LAB2: below code is used to check the first fit allocation algorithm (your EXERCISE 1) 
// NOTICE: You SHOULD NOT CHANGE basic_check, default_check functions!
static void
default_check(void) {
    int count = 0, total = 0;
    list_entry_t *le = &free_list;
    while ((le = list_next(le)) != &free_list) {
        struct Page *p = le2page(le, page_link);
        assert(PageProperty(p));
        count ++, total += p->property;
    }
    assert(total == nr_free_pages());

    basic_check();

    struct Page *p0 = alloc_pages(5), *p1, *p2;
    assert(p0 != NULL);
    assert(!PageProperty(p0));

    list_entry_t free_list_store = free_list;
    list_init(&free_list);
    assert(list_empty(&free_list));
    assert(alloc_page() == NULL);

    unsigned int nr_free_store = nr_free;
    nr_free = 0;

    free_pages(p0 + 2, 3);
    assert(alloc_pages(4) == NULL);
    assert(PageProperty(p0 + 2) && p0[2].property == 3);
    assert((p1 = alloc_pages(3)) != NULL);
    assert(alloc_page() == NULL);
    assert(p0 + 2 == p1);

    p2 = p0 + 1;
    free_page(p0);
    free_pages(p1, 3);
    assert(PageProperty(p0) && p0->property == 1);
    assert(PageProperty(p1) && p1->property == 3);

    assert((p0 = alloc_page()) == p2 - 1);
    free_page(p0);
    assert((p0 = alloc_pages(2)) == p2 + 1);

    free_pages(p0, 2);
    free_page(p2);

    assert((p0 = alloc_pages(5)) != NULL);
    assert(alloc_page() == NULL);

    assert(nr_free == 0);
    nr_free = nr_free_store;

    free_list = free_list_store;
    free_pages(p0, 5);

    le = &free_list;
    while ((le = list_next(le)) != &free_list) {
        struct Page *p = le2page(le, page_link);
        count --, total -= p->property;
    }
    assert(count == 0);
    assert(total == 0);
}
Exemplo n.º 28
0
static ssize_t sel_write_enforce(struct file *file, const char __user *buf,
				 size_t count, loff_t *ppos)

{
	char *page = NULL;
	ssize_t length;
	int new_value;

	length = -ENOMEM;
	if (count >= PAGE_SIZE)
		goto out;

	/* No partial writes. */
	length = -EINVAL;
	if (*ppos != 0)
		goto out;

	length = -ENOMEM;
	page = (char *)get_zeroed_page(GFP_KERNEL);
	if (!page)
		goto out;

	length = -EFAULT;
	if (copy_from_user(page, buf, count))
		goto out;

	length = -EINVAL;
	if (sscanf(page, "%d", &new_value) != 1)
		goto out;
#ifdef CONFIG_ALWAYS_ENFORCE
	// If build is user build and enforce option is set, selinux is always enforcing
	new_value = 1;
	length = task_has_security(current, SECURITY__SETENFORCE);
	audit_log(current->audit_context, GFP_KERNEL, AUDIT_MAC_STATUS,
                        "config_always_enforce - true; enforcing=%d old_enforcing=%d auid=%u ses=%u",
                        new_value, selinux_enforcing,
                        from_kuid(&init_user_ns, audit_get_loginuid(current)),
                        audit_get_sessionid(current));
	selinux_enforcing = new_value;
	avc_ss_reset(0);
	selnl_notify_setenforce(new_value);
	selinux_status_update_setenforce(new_value);
#else
	if (new_value != selinux_enforcing) {
		length = task_has_security(current, SECURITY__SETENFORCE);
		if (length)
			goto out;
		audit_log(current->audit_context, GFP_KERNEL, AUDIT_MAC_STATUS,
			"enforcing=%d old_enforcing=%d auid=%u ses=%u",
			new_value, selinux_enforcing,
			from_kuid(&init_user_ns, audit_get_loginuid(current)),
			audit_get_sessionid(current));
		selinux_enforcing = new_value;
		if (selinux_enforcing)
			avc_ss_reset(0);
		selnl_notify_setenforce(selinux_enforcing);
		selinux_status_update_setenforce(selinux_enforcing);
	}
#endif
	length = count;
out:
	free_page((unsigned long) page);
	return length;
}
IM_RET dmmupwl_alloc_linear_page_align_memory(OUT IM_Buffer *buffer)
{
	struct page *pg;
	//ptable_mem_t ptm = {0};
	IM_INFOMSG((IM_STR("%s()"), IM_STR(_IM_FUNC_)));

	IM_ASSERT(PMM_PAGE_SHIFT == PAGE_SHIFT);
	IM_ASSERT(PMM_PAGE_SIZE == PAGE_SIZE);
#if 0
	//ptm.kVirAddr = kmalloc(pageNum << PMM_PAGE_SHIFT, GFP_KERNEL);
	ptm.kVirAddr = (void *)__get_free_page(GFP_KERNEL | __GFP_NOWARN | __GFP_COLD | __GFP_REPEAT);
	if(ptm.kVirAddr == IM_NULL){
		//IM_ERRMSG((IM_STR("kmalloc() failed")));
		IM_ERRMSG((IM_STR("__get_free_page() failed")));
		return IM_RET_FAILED;
	}

	buffer->phy_addr = __pa(ptm.kVirAddr);
	buffer->size = 1 << PMM_PAGE_SHIFT;
	buffer->flag = IM_BUFFER_FLAG_PHY;

	IM_INFOMSG((IM_STR("ptm.kVirAddr=0x%x"), (IM_INT32)ptm.kVirAddr));
	IM_INFOMSG((IM_STR("buffer->phy_addr=0x%x"), buffer->phy_addr));
	IM_INFOMSG((IM_STR("buffer->size=%d"), buffer->size));
	IM_INFOMSG((IM_STR("buffer->flag=0x%x"), buffer->flag));

	ptm.kVirAddrRemap = ioremap_nocache(buffer->phy_addr, buffer->size);
	if(ptm.kVirAddrRemap == IM_NULL){
		IM_ERRMSG((IM_STR("ioremap_nocache() failed")));
		goto Fail;
	}
	IM_INFOMSG((IM_STR("ptm.kVirAddrRemap=0x%x"), (IM_INT32)ptm.kVirAddrRemap));

	if(im_list_put_back(gPwl->ptmlist, &ptm) != IM_RET_OK){
		IM_ERRMSG((IM_STR("im_list_put_back() failed")));
		goto Fail;
	}

	buffer->vir_addr = ptm.kVirAddrRemap;
	return IM_RET_OK;

Fail:
	if(ptm.kVirAddrRemap != IM_NULL){
		iounmap(ptm.kVirAddrRemap);
	}
	//kfree(ptm.kVirAddr);
	free_page((IM_UINT32)ptm.kVirAddr);
	return IM_RET_FAILED;
#else
	pg = alloc_page(/*GFP_HIGHUSER | */__GFP_ZERO | __GFP_REPEAT | __GFP_NOWARN | __GFP_COLD);
	if(pg == IM_NULL){
		IM_ERRMSG((IM_STR("alloc_page() failed")));
		return IM_RET_FAILED;
	}
	buffer->vir_addr = page_address(pg);
	buffer->phy_addr = dma_map_page(NULL, pg, 0, PAGE_SIZE, DMA_BIDIRECTIONAL);
	buffer->size = DMMU_PAGE_SIZE;
	buffer->flag = IM_BUFFER_FLAG_PHY;

	IM_INFOMSG((IM_STR("buffer vir_addr=0x%x, phy_addr=0x%x"), (IM_UINT32)buffer->vir_addr, buffer->phy_addr));
	return IM_RET_OK;
#endif	
}
Exemplo n.º 30
0
int proc_avs_0_input_write(struct file *file, const char __user *buf, unsigned long count, void *data)
{
	char *page;
	char *myString;
	ssize_t ret = -ENOMEM;
	/* int result; */

#if defined(ADB_BOX)
	struct stmfbio_output_configuration outputConfig;
	struct stmfb_info *info = stmfb_get_fbinfo_ptr();
	int err;

	outputConfig.outputid = 1;
	stmfb_get_output_configuration(&outputConfig,info);

	outputConfig.caps = 0;
	outputConfig.activate = 0;//STMFBIO_ACTIVATE_IMMEDIATE;
	outputConfig.analogue_config = 0;
	outputConfig.caps |= STMFBIO_OUTPUT_CAPS_HDMI_CONFIG;
#endif

	printk("%s %ld - ", __FUNCTION__, count);

	page = (char *)__get_free_page(GFP_KERNEL);
	if (page)
	{
		ret = -EFAULT;
		if (copy_from_user(page, buf, count))
			goto out;

		myString = (char *) kmalloc(count + 1, GFP_KERNEL);
		strncpy(myString, page, count);
		myString[count] = '\0';

		printk("%s\n", myString);

		if(!strncmp("encoder", myString, count - 1))
		{
			avs_command_kernel(SAAIOSSRCSEL, SAA_SRC_ENC);

			// Note: Volumne is not changed directly but by using the MIXER instead of the AVS. 
			// So this should always be set to the maximum
			#if defined(UFS910) || defined(ADB_BOX)
			avs_command_kernel(AVSIOSVOL, (void*) 31);
			#else
			avs_command_kernel(AVSIOSVOL, (void*) 0);
			#endif
			#if defined(ADB_BOX)
			avs_command_kernel(SAAIOSWSS, (void*) SAA_WSS_43F);
			outputConfig.hdmi_config &= ~STMFBIO_OUTPUT_HDMI_DISABLED;
			#endif
			current_input = ENCODER;
		}

		if(!strncmp("scart", myString, count - 1))
		{
			avs_command_kernel(SAAIOSSRCSEL, (void*) SAA_SRC_SCART);

			avs_command_kernel(AVSIOSVOL, (void*) current_volume);
			#if defined(ADB_BOX)
				avs_command_kernel(SAAIOSWSS, (void*) SAA_WSS_OFF);
				outputConfig.hdmi_config |= STMFBIO_OUTPUT_HDMI_DISABLED;
			#endif
			current_input = SCART;
		}

#if defined(ADB_BOX)
		err = stmfb_set_output_configuration(&outputConfig, info);
		if (err != 0) {
			printk("HDMI Config Disabled - Failed !!!!!!!!!!");
		}
#endif

		kfree(myString);
		//result = sscanf(page, "%3s %3s %3s %3s %3s", s1, s2, s3, s4, s5);
	}

	ret = count;
out:

	free_page((unsigned long)page);
	return ret;
}