예제 #1
0
static void __exit d7s_cleanup(void)
{
	int regs = readb(d7s_regs);

	/* Honor OBP d7s-flipped? unless operating in solaris-compat mode */
	if (0 == sol_compat) {
		(0 == d7s_obpflipped())	? 
			writeb(regs |= D7S_FLIP,  d7s_regs):
			writeb(regs &= ~D7S_FLIP, d7s_regs);
	}

	misc_deregister(&d7s_miscdev);
	d7s_free();
}
예제 #2
0
static int d7s_release(struct inode *inode, struct file *f)
{
	/* Reset flipped state to OBP default only if
	 * no other users have the device open and we
	 * are not operating in solaris-compat mode
	 */
	if (atomic_dec_and_test(&d7s_users) && !sol_compat) {
		int regval = 0;

		regval = readb(d7s_regs);
		(0 == d7s_obpflipped())	? 
			writeb(regval |= D7S_FLIP,  d7s_regs): 
			writeb(regval &= ~D7S_FLIP, d7s_regs);
	}

	return 0;
}
예제 #3
0
static int __init d7s_init(void)
{
	struct linux_ebus *ebus = NULL;
	struct linux_ebus_device *edev = NULL;
	int iTmp = 0, regs = 0;

	for_each_ebus(ebus) {
		for_each_ebusdev(edev, ebus) {
			if (!strcmp(edev->prom_node->name, D7S_OBPNAME))
				goto ebus_done;
		}
	}

ebus_done:
	if(!edev) {
		printk("%s: unable to locate device\n", D7S_DEVNAME);
		return -ENODEV;
	}

	d7s_regs = ioremap(edev->resource[0].start, sizeof(__u8));

	iTmp = misc_register(&d7s_miscdev);
	if (0 != iTmp) {
		printk("%s: unable to acquire miscdevice minor %i\n",
		       D7S_DEVNAME, D7S_MINOR);
		iounmap(d7s_regs);
		return iTmp;
	}

	/* OBP option "d7s-flipped?" is honored as default
	 * for the device, and reset default when detached
	 */
	regs = readb(d7s_regs);
	iTmp = d7s_obpflipped();
	(0 == iTmp) ? 
		writeb(regs |= D7S_FLIP,  d7s_regs): 
		writeb(regs &= ~D7S_FLIP, d7s_regs);

	printk("%s: 7-Segment Display%s at 0x%lx %s\n", 
	       D7S_DEVNAME,
	       (0 == iTmp) ? (" (FLIPPED)") : (""),
	       edev->resource[0].start,
	       (0 != sol_compat) ? ("in sol_compat mode") : (""));

	return 0;
}
예제 #4
0
static int d7s_release(struct inode *inode, struct file *f)
{
	if (D7S_MINOR != minor(inode->i_rdev))
		return -ENODEV;
	
	MOD_DEC_USE_COUNT;

	/* Reset flipped state to OBP default only if
	 * no other users have the device open and we
	 * are not operating in solaris-compat mode
	 */
	if (0 == MOD_IN_USE && 0 == sol_compat) {
		int regval = 0;

		regval = readb(d7s_regs);
		(0 == d7s_obpflipped())	? 
			writeb(regval |= D7S_FLIP,  d7s_regs): 
			writeb(regval &= ~D7S_FLIP, d7s_regs);
	}

	return 0;
}