From: Dmitry Torokhov <dtor@insightbb.com>
To: Richard Purdie <rpurdie@rpsys.net>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [patch 1/6] Convert to use default class device attributes
Date: Fri, 11 Aug 2006 01:03:11 -0400 [thread overview]
Message-ID: <20060811050611.030043094.dtor@insightbb.com> (raw)
In-Reply-To: <20060811050310.958962036.dtor@insightbb.com>
[-- Attachment #1: backlight-attributes.patch --]
[-- Type: text/plain, Size: 6119 bytes --]
Backlight: convert to use default class device attributes
Use provided by the driver core method of creating set of default
attributes for all devices belonging to a given class instead of
using homegrown code.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---
drivers/video/backlight/backlight.c | 49 ++++++++----------------------------
drivers/video/backlight/lcd.c | 44 +++++++-------------------------
2 files changed, 22 insertions(+), 71 deletions(-)
Index: work/drivers/video/backlight/backlight.c
===================================================================
--- work.orig/drivers/video/backlight/backlight.c
+++ work/drivers/video/backlight/backlight.c
@@ -130,25 +130,19 @@ static void backlight_class_release(stru
kfree(bd);
}
-static struct class backlight_class = {
- .name = "backlight",
- .release = backlight_class_release,
+static struct class_device_attribute bl_class_device_attributes[] = {
+ __ATTR(power, 0644, backlight_show_power, backlight_store_power),
+ __ATTR(brightness, 0644,
+ backlight_show_brightness, backlight_store_brightness),
+ __ATTR(actual_brightness, 0444, backlight_show_actual_brightness, NULL),
+ __ATTR(max_brightness, 0444, backlight_show_max_brightness, NULL),
+ __ATTR_NULL
};
-#define DECLARE_ATTR(_name,_mode,_show,_store) \
-{ \
- .attr = { .name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \
- .show = _show, \
- .store = _store, \
-}
-
-static struct class_device_attribute bl_class_device_attributes[] = {
- DECLARE_ATTR(power, 0644, backlight_show_power, backlight_store_power),
- DECLARE_ATTR(brightness, 0644, backlight_show_brightness,
- backlight_store_brightness),
- DECLARE_ATTR(actual_brightness, 0444, backlight_show_actual_brightness,
- NULL),
- DECLARE_ATTR(max_brightness, 0444, backlight_show_max_brightness, NULL),
+static struct class backlight_class = {
+ .name = "backlight",
+ .release = backlight_class_release,
+ .class_dev_attrs = bl_class_device_attributes,
};
/* This callback gets called when something important happens inside a
@@ -193,7 +187,7 @@ static int fb_notifier_callback(struct n
struct backlight_device *backlight_device_register(const char *name, void *devdata,
struct backlight_properties *bp)
{
- int i, rc;
+ int rc;
struct backlight_device *new_bd;
pr_debug("backlight_device_alloc: name=%s\n", name);
@@ -222,19 +216,6 @@ error: kfree(new_bd);
if (unlikely(rc))
goto error;
- for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++) {
- rc = class_device_create_file(&new_bd->class_dev,
- &bl_class_device_attributes[i]);
- if (unlikely(rc)) {
- while (--i >= 0)
- class_device_remove_file(&new_bd->class_dev,
- &bl_class_device_attributes[i]);
- class_device_unregister(&new_bd->class_dev);
- /* No need to kfree(new_bd) since release() method was called */
- return ERR_PTR(rc);
- }
- }
-
return new_bd;
}
EXPORT_SYMBOL(backlight_device_register);
@@ -247,17 +228,11 @@ EXPORT_SYMBOL(backlight_device_register)
*/
void backlight_device_unregister(struct backlight_device *bd)
{
- int i;
-
if (!bd)
return;
pr_debug("backlight_device_unregister: name=%s\n", bd->class_dev.class_id);
- for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++)
- class_device_remove_file(&bd->class_dev,
- &bl_class_device_attributes[i]);
-
down(&bd->sem);
if (likely(bd->props && bd->props->update_status)) {
bd->props->brightness = 0;
Index: work/drivers/video/backlight/lcd.c
===================================================================
--- work.orig/drivers/video/backlight/lcd.c
+++ work/drivers/video/backlight/lcd.c
@@ -109,22 +109,17 @@ static void lcd_class_release(struct cla
kfree(ld);
}
-static struct class lcd_class = {
- .name = "lcd",
- .release = lcd_class_release,
+static struct class_device_attribute lcd_class_device_attributes[] = {
+ __ATTR(power, 0644, lcd_show_power, lcd_store_power),
+ __ATTR(contrast, 0644, lcd_show_contrast, lcd_store_contrast),
+ __ATTR(max_contrast, 0444, lcd_show_max_contrast, NULL),
+ __ATTR_NULL
};
-#define DECLARE_ATTR(_name,_mode,_show,_store) \
-{ \
- .attr = { .name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \
- .show = _show, \
- .store = _store, \
-}
-
-static struct class_device_attribute lcd_class_device_attributes[] = {
- DECLARE_ATTR(power, 0644, lcd_show_power, lcd_store_power),
- DECLARE_ATTR(contrast, 0644, lcd_show_contrast, lcd_store_contrast),
- DECLARE_ATTR(max_contrast, 0444, lcd_show_max_contrast, NULL),
+static struct class lcd_class = {
+ .name = "lcd",
+ .release = lcd_class_release,
+ .class_dev_attrs = lcd_class_device_attributes,
};
/* This callback gets called when something important happens inside a
@@ -164,7 +159,7 @@ static int fb_notifier_callback(struct n
struct lcd_device *lcd_device_register(const char *name, void *devdata,
struct lcd_properties *lp)
{
- int i, rc;
+ int rc;
struct lcd_device *new_ld;
pr_debug("lcd_device_register: name=%s\n", name);
@@ -193,19 +188,6 @@ error: kfree(new_ld);
if (unlikely(rc))
goto error;
- for (i = 0; i < ARRAY_SIZE(lcd_class_device_attributes); i++) {
- rc = class_device_create_file(&new_ld->class_dev,
- &lcd_class_device_attributes[i]);
- if (unlikely(rc)) {
- while (--i >= 0)
- class_device_remove_file(&new_ld->class_dev,
- &lcd_class_device_attributes[i]);
- class_device_unregister(&new_ld->class_dev);
- /* No need to kfree(new_ld) since release() method was called */
- return ERR_PTR(rc);
- }
- }
-
return new_ld;
}
EXPORT_SYMBOL(lcd_device_register);
@@ -218,17 +200,11 @@ EXPORT_SYMBOL(lcd_device_register);
*/
void lcd_device_unregister(struct lcd_device *ld)
{
- int i;
-
if (!ld)
return;
pr_debug("lcd_device_unregister: name=%s\n", ld->class_dev.class_id);
- for (i = 0; i < ARRAY_SIZE(lcd_class_device_attributes); i++)
- class_device_remove_file(&ld->class_dev,
- &lcd_class_device_attributes[i]);
-
down(&ld->sem);
ld->props = NULL;
up(&ld->sem);
next prev parent reply other threads:[~2006-08-11 5:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-11 5:03 [patch 0/6] Backlight & lcd fixes/cleanups Dmitry Torokhov
2006-08-11 5:03 ` Dmitry Torokhov [this message]
2006-08-11 5:03 ` [patch 2/6] Fix error handling when registering new device Dmitry Torokhov
2006-08-11 5:03 ` [patch 3/6] Get rid of excessive amount of likely()s Dmitry Torokhov
2006-08-11 5:03 ` [patch 4/6] Remove "owner" from backlight_properties structure Dmitry Torokhov
2006-08-11 5:03 ` [patch 5/6] Convert to use mutexes instead of semaphores Dmitry Torokhov
2006-08-11 12:58 ` Dmitry Torokhov
2006-08-11 13:16 ` Richard Purdie
2006-08-11 13:34 ` Dmitry Torokhov
2006-08-11 13:42 ` Michael Hanselmann
2006-08-11 14:07 ` Dmitry Torokhov
2006-08-11 16:45 ` Richard Purdie
2006-08-11 17:20 ` Dmitry Torokhov
2006-08-29 20:54 ` Michael Hanselmann
2006-08-11 5:03 ` [patch 6/6] Move per-device data out of backlight_properties Dmitry Torokhov
2006-08-11 8:02 ` Richard Purdie
2006-08-11 12:27 ` Dmitry Torokhov
2006-08-11 12:55 ` Richard Purdie
2006-08-11 13:10 ` Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060811050611.030043094.dtor@insightbb.com \
--to=dtor@insightbb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rpurdie@rpsys.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®