// SPDX-License-Identifier: GPL-2.0-only /* display7seg.c - Driver implementation for the 7-segment display * present on Sun Microsystems CP1400 and CP1500 * * Copyright (c) 2000 Eric Brower (ebrower@usa.net)
*/
/* Solaris compatibility flag - * The Solaris implementation omits support for several * documented driver features (ref Sun doc 806-0180-03). * By default, this module supports the documented driver * abilities, rather than the Solaris implementation: * * 1) Device ALWAYS reverts to OBP-specified FLIPPED mode * upon closure of device or module unload. * 2) Device ioctls D7SIOCRD/D7SIOCWR honor toggling of * FLIP bit * * If you wish the device to operate as under Solaris, * omitting above features, set this parameter to non-zero.
*/
module_param(sol_compat, int, 0);
MODULE_PARM_DESC(sol_compat, "Disables documented functionality omitted from Solaris driver");
MODULE_AUTHOR("Eric Brower ");
MODULE_DESCRIPTION("7-Segment Display driver for Sun Microsystems CP1400/1500");
MODULE_LICENSE("GPL");
staticint 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) { struct d7s *p = d7s_device;
u8 regval = 0;
if (D7S_MINOR != iminor(file_inode(file))) return -ENODEV;
mutex_lock(&d7s_mutex); switch (cmd) { case D7SIOCWR: /* assign device register values we mask-out D7S_FLIP * if in sol_compat mode
*/ if (get_user(ireg, (int __user *) arg)) {
error = -EFAULT; break;
} if (sol_compat) { if (regs & D7S_FLIP)
ireg |= D7S_FLIP; else
ireg &= ~D7S_FLIP;
}
writeb(ireg, p->regs); break;
case D7SIOCRD: /* retrieve device register values * NOTE: Solaris implementation returns D7S_FLIP bit * as toggled by user, even though it does not honor it. * This driver will not misinform you about the state * of your hardware while in sol_compat mode
*/ if (put_user(regs, (int __user *) arg)) {
error = -EFAULT; break;
} break;
err = misc_register(&d7s_miscdev); if (err) {
printk(KERN_ERR PFX "Unable to acquire miscdevice minor %i\n",
D7S_MINOR); goto out_iounmap;
}
/* OBP option "d7s-flipped?" is honored as default for the * device, and reset default when detached
*/
regs = readb(p->regs);
opts = of_find_node_by_path("/options"); if (opts)
p->flipped = of_property_read_bool(opts, "d7s-flipped?");
if (p->flipped)
regs |= D7S_FLIP; else
regs &= ~D7S_FLIP;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.