Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 41178
b: refs/heads/master
c: 805952a
h: refs/heads/master
v: v3
  • Loading branch information
Greg Kroah-Hartman committed Dec 1, 2006
1 parent 941684f commit 35c211d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 43 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 805fab474ed75f9603dbde6fa74a2976868b4bd2
refs/heads/master: 805952a889c4d0fdab23307c14c5ce9571f81233
81 changes: 39 additions & 42 deletions trunk/drivers/char/vt.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
struct con_driver {
const struct consw *con;
const char *desc;
struct class_device *class_dev;
struct device *dev;
int node;
int first;
int last;
Expand Down Expand Up @@ -3023,10 +3023,10 @@ static inline int vt_unbind(struct con_driver *con)
}
#endif /* CONFIG_VT_HW_CONSOLE_BINDING */

static ssize_t store_bind(struct class_device *class_device,
static ssize_t store_bind(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct con_driver *con = class_get_devdata(class_device);
struct con_driver *con = dev_get_drvdata(dev);
int bind = simple_strtoul(buf, NULL, 0);

if (bind)
Expand All @@ -3037,61 +3037,60 @@ static ssize_t store_bind(struct class_device *class_device,
return count;
}

static ssize_t show_bind(struct class_device *class_device, char *buf)
static ssize_t show_bind(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct con_driver *con = class_get_devdata(class_device);
struct con_driver *con = dev_get_drvdata(dev);
int bind = con_is_bound(con->con);

return snprintf(buf, PAGE_SIZE, "%i\n", bind);
}

static ssize_t show_name(struct class_device *class_device, char *buf)
static ssize_t show_name(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct con_driver *con = class_get_devdata(class_device);
struct con_driver *con = dev_get_drvdata(dev);

return snprintf(buf, PAGE_SIZE, "%s %s\n",
(con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)",
con->desc);

}

static struct class_device_attribute class_device_attrs[] = {
static struct device_attribute device_attrs[] = {
__ATTR(bind, S_IRUGO|S_IWUSR, show_bind, store_bind),
__ATTR(name, S_IRUGO, show_name, NULL),
};

static int vtconsole_init_class_device(struct con_driver *con)
static int vtconsole_init_device(struct con_driver *con)
{
int i;
int error = 0;

con->flag |= CON_DRIVER_FLAG_ATTR;
class_set_devdata(con->class_dev, con);
for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) {
error = class_device_create_file(con->class_dev,
&class_device_attrs[i]);
dev_set_drvdata(con->dev, con);
for (i = 0; i < ARRAY_SIZE(device_attrs); i++) {
error = device_create_file(con->dev, &device_attrs[i]);
if (error)
break;
}

if (error) {
while (--i >= 0)
class_device_remove_file(con->class_dev,
&class_device_attrs[i]);
device_remove_file(con->dev, &device_attrs[i]);
con->flag &= ~CON_DRIVER_FLAG_ATTR;
}

return error;
}

static void vtconsole_deinit_class_device(struct con_driver *con)
static void vtconsole_deinit_device(struct con_driver *con)
{
int i;

if (con->flag & CON_DRIVER_FLAG_ATTR) {
for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
class_device_remove_file(con->class_dev,
&class_device_attrs[i]);
for (i = 0; i < ARRAY_SIZE(device_attrs); i++)
device_remove_file(con->dev, &device_attrs[i]);
con->flag &= ~CON_DRIVER_FLAG_ATTR;
}
}
Expand Down Expand Up @@ -3179,18 +3178,17 @@ int register_con_driver(const struct consw *csw, int first, int last)
if (retval)
goto err;

con_driver->class_dev = class_device_create(vtconsole_class, NULL,
MKDEV(0, con_driver->node),
NULL, "vtcon%i",
con_driver->node);
con_driver->dev = device_create(vtconsole_class, NULL,
MKDEV(0, con_driver->node),
"vtcon%i", con_driver->node);

if (IS_ERR(con_driver->class_dev)) {
printk(KERN_WARNING "Unable to create class_device for %s; "
if (IS_ERR(con_driver->dev)) {
printk(KERN_WARNING "Unable to create device for %s; "
"errno = %ld\n", con_driver->desc,
PTR_ERR(con_driver->class_dev));
con_driver->class_dev = NULL;
PTR_ERR(con_driver->dev));
con_driver->dev = NULL;
} else {
vtconsole_init_class_device(con_driver);
vtconsole_init_device(con_driver);
}

err:
Expand Down Expand Up @@ -3226,12 +3224,12 @@ int unregister_con_driver(const struct consw *csw)

if (con_driver->con == csw &&
con_driver->flag & CON_DRIVER_FLAG_MODULE) {
vtconsole_deinit_class_device(con_driver);
class_device_destroy(vtconsole_class,
MKDEV(0, con_driver->node));
vtconsole_deinit_device(con_driver);
device_destroy(vtconsole_class,
MKDEV(0, con_driver->node));
con_driver->con = NULL;
con_driver->desc = NULL;
con_driver->class_dev = NULL;
con_driver->dev = NULL;
con_driver->node = 0;
con_driver->flag = 0;
con_driver->first = 0;
Expand Down Expand Up @@ -3289,19 +3287,18 @@ static int __init vtconsole_class_init(void)
for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
struct con_driver *con = &registered_con_driver[i];

if (con->con && !con->class_dev) {
con->class_dev =
class_device_create(vtconsole_class, NULL,
MKDEV(0, con->node), NULL,
"vtcon%i", con->node);
if (con->con && !con->dev) {
con->dev = device_create(vtconsole_class, NULL,
MKDEV(0, con->node),
"vtcon%i", con->node);

if (IS_ERR(con->class_dev)) {
if (IS_ERR(con->dev)) {
printk(KERN_WARNING "Unable to create "
"class_device for %s; errno = %ld\n",
con->desc, PTR_ERR(con->class_dev));
con->class_dev = NULL;
"device for %s; errno = %ld\n",
con->desc, PTR_ERR(con->dev));
con->dev = NULL;
} else {
vtconsole_init_class_device(con);
vtconsole_init_device(con);
}
}
}
Expand Down

0 comments on commit 35c211d

Please sign in to comment.