Skip to content

Commit

Permalink
fbcon: use struct device instead of struct class_device
Browse files Browse the repository at this point in the history
Port fbcon.c to use struct device from using struct class_device

Signed-off-by: Antonino Daplas <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
adaplas authored and Linus Torvalds committed Jul 17, 2007
1 parent acba9cd commit 0c6c1ce
Showing 1 changed file with 29 additions and 28 deletions.
57 changes: 29 additions & 28 deletions drivers/video/console/fbcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ static void fbcon_modechanged(struct fb_info *info);
static void fbcon_set_all_vcs(struct fb_info *info);
static void fbcon_start(void);
static void fbcon_exit(void);
static struct class_device *fbcon_class_device;
static struct device *fbcon_device;

#ifdef CONFIG_MAC
/*
Expand Down Expand Up @@ -3246,8 +3246,9 @@ static struct notifier_block fbcon_event_notifier = {
.notifier_call = fbcon_event_notify,
};

static ssize_t store_rotate(struct class_device *class_device,
const char *buf, size_t count)
static ssize_t store_rotate(struct device *device,
struct device_attribute *attr, const char *buf,
size_t count)
{
struct fb_info *info;
int rotate, idx;
Expand All @@ -3270,8 +3271,9 @@ static ssize_t store_rotate(struct class_device *class_device,
return count;
}

static ssize_t store_rotate_all(struct class_device *class_device,
const char *buf, size_t count)
static ssize_t store_rotate_all(struct device *device,
struct device_attribute *attr,const char *buf,
size_t count)
{
struct fb_info *info;
int rotate, idx;
Expand All @@ -3294,7 +3296,8 @@ static ssize_t store_rotate_all(struct class_device *class_device,
return count;
}

static ssize_t show_rotate(struct class_device *class_device, char *buf)
static ssize_t show_rotate(struct device *device,
struct device_attribute *attr,char *buf)
{
struct fb_info *info;
int rotate = 0, idx;
Expand All @@ -3315,7 +3318,8 @@ static ssize_t show_rotate(struct class_device *class_device, char *buf)
return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
}

static ssize_t show_cursor_blink(struct class_device *class_device, char *buf)
static ssize_t show_cursor_blink(struct device *device,
struct device_attribute *attr, char *buf)
{
struct fb_info *info;
struct fbcon_ops *ops;
Expand All @@ -3342,7 +3346,8 @@ static ssize_t show_cursor_blink(struct class_device *class_device, char *buf)
return snprintf(buf, PAGE_SIZE, "%d\n", blink);
}

static ssize_t store_cursor_blink(struct class_device *clas_device,
static ssize_t store_cursor_blink(struct device *device,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct fb_info *info;
Expand Down Expand Up @@ -3378,31 +3383,29 @@ static ssize_t store_cursor_blink(struct class_device *clas_device,
return count;
}

static struct class_device_attribute class_device_attrs[] = {
static struct device_attribute device_attrs[] = {
__ATTR(rotate, S_IRUGO|S_IWUSR, show_rotate, store_rotate),
__ATTR(rotate_all, S_IWUSR, NULL, store_rotate_all),
__ATTR(cursor_blink, S_IRUGO|S_IWUSR, show_cursor_blink,
store_cursor_blink),
};

static int fbcon_init_class_device(void)
static int fbcon_init_device(void)
{
int i, error = 0;

fbcon_has_sysfs = 1;

for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) {
error = class_device_create_file(fbcon_class_device,
&class_device_attrs[i]);
for (i = 0; i < ARRAY_SIZE(device_attrs); i++) {
error = device_create_file(fbcon_device, &device_attrs[i]);

if (error)
break;
}

if (error) {
while (--i >= 0)
class_device_remove_file(fbcon_class_device,
&class_device_attrs[i]);
device_remove_file(fbcon_device, &device_attrs[i]);

fbcon_has_sysfs = 0;
}
Expand Down Expand Up @@ -3488,16 +3491,15 @@ static int __init fb_console_init(void)

acquire_console_sem();
fb_register_client(&fbcon_event_notifier);
fbcon_class_device =
class_device_create(fb_class, NULL, MKDEV(0, 0), NULL, "fbcon");
fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), "fbcon");

if (IS_ERR(fbcon_class_device)) {
printk(KERN_WARNING "Unable to create class_device "
if (IS_ERR(fbcon_device)) {
printk(KERN_WARNING "Unable to create device "
"for fbcon; errno = %ld\n",
PTR_ERR(fbcon_class_device));
fbcon_class_device = NULL;
PTR_ERR(fbcon_device));
fbcon_device = NULL;
} else
fbcon_init_class_device();
fbcon_init_device();

for (i = 0; i < MAX_NR_CONSOLES; i++)
con2fb_map[i] = -1;
Expand All @@ -3511,14 +3513,13 @@ module_init(fb_console_init);

#ifdef MODULE

static void __exit fbcon_deinit_class_device(void)
static void __exit fbcon_deinit_device(void)
{
int i;

if (fbcon_has_sysfs) {
for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
class_device_remove_file(fbcon_class_device,
&class_device_attrs[i]);
for (i = 0; i < ARRAY_SIZE(device_attrs); i++)
device_remove_file(fbcon_device, &device_attrs[i]);

fbcon_has_sysfs = 0;
}
Expand All @@ -3528,8 +3529,8 @@ static void __exit fb_console_exit(void)
{
acquire_console_sem();
fb_unregister_client(&fbcon_event_notifier);
fbcon_deinit_class_device();
class_device_destroy(fb_class, MKDEV(0, 0));
fbcon_deinit_device();
device_destroy(fb_class, MKDEV(0, 0));
fbcon_exit();
release_console_sem();
unregister_con_driver(&fb_con);
Expand Down

0 comments on commit 0c6c1ce

Please sign in to comment.