diff options
author | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-01 19:41:07 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-01 19:41:07 -0500 |
commit | 4549df891a31b9a05b7d183106c09049b79327be (patch) | |
tree | d4dfd0921f0dd0dba2525fd33c0962b26ba5ff1e /drivers/char/vt.c | |
parent | 6b8cc71ab2619a776b02869fd733ac1ead3db4e8 (diff) | |
parent | e17e0f51aeea4e59c7e450a1c0f26605b91c1260 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6: (36 commits)
Driver core: show drivers in /sys/module/
Documentation/driver-model/platform.txt update/rewrite
Driver core: platform_driver_probe(), can save codespace
driver core: Use klist_remove() in device_move()
driver core: Introduce device_move(): move a device to a new parent.
Driver core: make drivers/base/core.c:setup_parent() static
driver core: Introduce device_find_child().
sysfs: sysfs_write_file() writes zero terminated data
cpu topology: consider sysfs_create_group return value
Driver core: Call platform_notify_remove later
ACPI: Change ACPI to use dev_archdata instead of firmware_data
Driver core: add dev_archdata to struct device
Driver core: convert sound core to use struct device
Driver core: change mem class_devices to be real devices
Driver core: convert fb code to use struct device
Driver core: convert firmware code to use struct device
Driver core: convert mmc code to use struct device
Driver core: convert ppdev code to use struct device
Driver core: convert PPP code to use struct device
Driver core: convert cpuid code to use struct device
...
Diffstat (limited to 'drivers/char/vt.c')
-rw-r--r-- | drivers/char/vt.c | 81 |
1 files changed, 39 insertions, 42 deletions
diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 8e4413f6fbaf..87587b4385ab 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c | |||
@@ -112,7 +112,7 @@ | |||
112 | struct con_driver { | 112 | struct con_driver { |
113 | const struct consw *con; | 113 | const struct consw *con; |
114 | const char *desc; | 114 | const char *desc; |
115 | struct class_device *class_dev; | 115 | struct device *dev; |
116 | int node; | 116 | int node; |
117 | int first; | 117 | int first; |
118 | int last; | 118 | int last; |
@@ -3023,10 +3023,10 @@ static inline int vt_unbind(struct con_driver *con) | |||
3023 | } | 3023 | } |
3024 | #endif /* CONFIG_VT_HW_CONSOLE_BINDING */ | 3024 | #endif /* CONFIG_VT_HW_CONSOLE_BINDING */ |
3025 | 3025 | ||
3026 | static ssize_t store_bind(struct class_device *class_device, | 3026 | static ssize_t store_bind(struct device *dev, struct device_attribute *attr, |
3027 | const char *buf, size_t count) | 3027 | const char *buf, size_t count) |
3028 | { | 3028 | { |
3029 | struct con_driver *con = class_get_devdata(class_device); | 3029 | struct con_driver *con = dev_get_drvdata(dev); |
3030 | int bind = simple_strtoul(buf, NULL, 0); | 3030 | int bind = simple_strtoul(buf, NULL, 0); |
3031 | 3031 | ||
3032 | if (bind) | 3032 | if (bind) |
@@ -3037,17 +3037,19 @@ static ssize_t store_bind(struct class_device *class_device, | |||
3037 | return count; | 3037 | return count; |
3038 | } | 3038 | } |
3039 | 3039 | ||
3040 | static ssize_t show_bind(struct class_device *class_device, char *buf) | 3040 | static ssize_t show_bind(struct device *dev, struct device_attribute *attr, |
3041 | char *buf) | ||
3041 | { | 3042 | { |
3042 | struct con_driver *con = class_get_devdata(class_device); | 3043 | struct con_driver *con = dev_get_drvdata(dev); |
3043 | int bind = con_is_bound(con->con); | 3044 | int bind = con_is_bound(con->con); |
3044 | 3045 | ||
3045 | return snprintf(buf, PAGE_SIZE, "%i\n", bind); | 3046 | return snprintf(buf, PAGE_SIZE, "%i\n", bind); |
3046 | } | 3047 | } |
3047 | 3048 | ||
3048 | static ssize_t show_name(struct class_device *class_device, char *buf) | 3049 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, |
3050 | char *buf) | ||
3049 | { | 3051 | { |
3050 | struct con_driver *con = class_get_devdata(class_device); | 3052 | struct con_driver *con = dev_get_drvdata(dev); |
3051 | 3053 | ||
3052 | return snprintf(buf, PAGE_SIZE, "%s %s\n", | 3054 | return snprintf(buf, PAGE_SIZE, "%s %s\n", |
3053 | (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)", | 3055 | (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)", |
@@ -3055,43 +3057,40 @@ static ssize_t show_name(struct class_device *class_device, char *buf) | |||
3055 | 3057 | ||
3056 | } | 3058 | } |
3057 | 3059 | ||
3058 | static struct class_device_attribute class_device_attrs[] = { | 3060 | static struct device_attribute device_attrs[] = { |
3059 | __ATTR(bind, S_IRUGO|S_IWUSR, show_bind, store_bind), | 3061 | __ATTR(bind, S_IRUGO|S_IWUSR, show_bind, store_bind), |
3060 | __ATTR(name, S_IRUGO, show_name, NULL), | 3062 | __ATTR(name, S_IRUGO, show_name, NULL), |
3061 | }; | 3063 | }; |
3062 | 3064 | ||
3063 | static int vtconsole_init_class_device(struct con_driver *con) | 3065 | static int vtconsole_init_device(struct con_driver *con) |
3064 | { | 3066 | { |
3065 | int i; | 3067 | int i; |
3066 | int error = 0; | 3068 | int error = 0; |
3067 | 3069 | ||
3068 | con->flag |= CON_DRIVER_FLAG_ATTR; | 3070 | con->flag |= CON_DRIVER_FLAG_ATTR; |
3069 | class_set_devdata(con->class_dev, con); | 3071 | dev_set_drvdata(con->dev, con); |
3070 | for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) { | 3072 | for (i = 0; i < ARRAY_SIZE(device_attrs); i++) { |
3071 | error = class_device_create_file(con->class_dev, | 3073 | error = device_create_file(con->dev, &device_attrs[i]); |
3072 | &class_device_attrs[i]); | ||
3073 | if (error) | 3074 | if (error) |
3074 | break; | 3075 | break; |
3075 | } | 3076 | } |
3076 | 3077 | ||
3077 | if (error) { | 3078 | if (error) { |
3078 | while (--i >= 0) | 3079 | while (--i >= 0) |
3079 | class_device_remove_file(con->class_dev, | 3080 | device_remove_file(con->dev, &device_attrs[i]); |
3080 | &class_device_attrs[i]); | ||
3081 | con->flag &= ~CON_DRIVER_FLAG_ATTR; | 3081 | con->flag &= ~CON_DRIVER_FLAG_ATTR; |
3082 | } | 3082 | } |
3083 | 3083 | ||
3084 | return error; | 3084 | return error; |
3085 | } | 3085 | } |
3086 | 3086 | ||
3087 | static void vtconsole_deinit_class_device(struct con_driver *con) | 3087 | static void vtconsole_deinit_device(struct con_driver *con) |
3088 | { | 3088 | { |
3089 | int i; | 3089 | int i; |
3090 | 3090 | ||
3091 | if (con->flag & CON_DRIVER_FLAG_ATTR) { | 3091 | if (con->flag & CON_DRIVER_FLAG_ATTR) { |
3092 | for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) | 3092 | for (i = 0; i < ARRAY_SIZE(device_attrs); i++) |
3093 | class_device_remove_file(con->class_dev, | 3093 | device_remove_file(con->dev, &device_attrs[i]); |
3094 | &class_device_attrs[i]); | ||
3095 | con->flag &= ~CON_DRIVER_FLAG_ATTR; | 3094 | con->flag &= ~CON_DRIVER_FLAG_ATTR; |
3096 | } | 3095 | } |
3097 | } | 3096 | } |
@@ -3179,18 +3178,17 @@ int register_con_driver(const struct consw *csw, int first, int last) | |||
3179 | if (retval) | 3178 | if (retval) |
3180 | goto err; | 3179 | goto err; |
3181 | 3180 | ||
3182 | con_driver->class_dev = class_device_create(vtconsole_class, NULL, | 3181 | con_driver->dev = device_create(vtconsole_class, NULL, |
3183 | MKDEV(0, con_driver->node), | 3182 | MKDEV(0, con_driver->node), |
3184 | NULL, "vtcon%i", | 3183 | "vtcon%i", con_driver->node); |
3185 | con_driver->node); | ||
3186 | 3184 | ||
3187 | if (IS_ERR(con_driver->class_dev)) { | 3185 | if (IS_ERR(con_driver->dev)) { |
3188 | printk(KERN_WARNING "Unable to create class_device for %s; " | 3186 | printk(KERN_WARNING "Unable to create device for %s; " |
3189 | "errno = %ld\n", con_driver->desc, | 3187 | "errno = %ld\n", con_driver->desc, |
3190 | PTR_ERR(con_driver->class_dev)); | 3188 | PTR_ERR(con_driver->dev)); |
3191 | con_driver->class_dev = NULL; | 3189 | con_driver->dev = NULL; |
3192 | } else { | 3190 | } else { |
3193 | vtconsole_init_class_device(con_driver); | 3191 | vtconsole_init_device(con_driver); |
3194 | } | 3192 | } |
3195 | 3193 | ||
3196 | err: | 3194 | err: |
@@ -3226,12 +3224,12 @@ int unregister_con_driver(const struct consw *csw) | |||
3226 | 3224 | ||
3227 | if (con_driver->con == csw && | 3225 | if (con_driver->con == csw && |
3228 | con_driver->flag & CON_DRIVER_FLAG_MODULE) { | 3226 | con_driver->flag & CON_DRIVER_FLAG_MODULE) { |
3229 | vtconsole_deinit_class_device(con_driver); | 3227 | vtconsole_deinit_device(con_driver); |
3230 | class_device_destroy(vtconsole_class, | 3228 | device_destroy(vtconsole_class, |
3231 | MKDEV(0, con_driver->node)); | 3229 | MKDEV(0, con_driver->node)); |
3232 | con_driver->con = NULL; | 3230 | con_driver->con = NULL; |
3233 | con_driver->desc = NULL; | 3231 | con_driver->desc = NULL; |
3234 | con_driver->class_dev = NULL; | 3232 | con_driver->dev = NULL; |
3235 | con_driver->node = 0; | 3233 | con_driver->node = 0; |
3236 | con_driver->flag = 0; | 3234 | con_driver->flag = 0; |
3237 | con_driver->first = 0; | 3235 | con_driver->first = 0; |
@@ -3289,19 +3287,18 @@ static int __init vtconsole_class_init(void) | |||
3289 | for (i = 0; i < MAX_NR_CON_DRIVER; i++) { | 3287 | for (i = 0; i < MAX_NR_CON_DRIVER; i++) { |
3290 | struct con_driver *con = ®istered_con_driver[i]; | 3288 | struct con_driver *con = ®istered_con_driver[i]; |
3291 | 3289 | ||
3292 | if (con->con && !con->class_dev) { | 3290 | if (con->con && !con->dev) { |
3293 | con->class_dev = | 3291 | con->dev = device_create(vtconsole_class, NULL, |
3294 | class_device_create(vtconsole_class, NULL, | 3292 | MKDEV(0, con->node), |
3295 | MKDEV(0, con->node), NULL, | 3293 | "vtcon%i", con->node); |
3296 | "vtcon%i", con->node); | ||
3297 | 3294 | ||
3298 | if (IS_ERR(con->class_dev)) { | 3295 | if (IS_ERR(con->dev)) { |
3299 | printk(KERN_WARNING "Unable to create " | 3296 | printk(KERN_WARNING "Unable to create " |
3300 | "class_device for %s; errno = %ld\n", | 3297 | "device for %s; errno = %ld\n", |
3301 | con->desc, PTR_ERR(con->class_dev)); | 3298 | con->desc, PTR_ERR(con->dev)); |
3302 | con->class_dev = NULL; | 3299 | con->dev = NULL; |
3303 | } else { | 3300 | } else { |
3304 | vtconsole_init_class_device(con); | 3301 | vtconsole_init_device(con); |
3305 | } | 3302 | } |
3306 | } | 3303 | } |
3307 | } | 3304 | } |