All of lore.kernel.org
 help / color / mirror / Atom feed
From: malattia@linux.it
To: lenb@kernel.org
Cc: linux-acpi@vger.kernel.org, Mattia Dongili <malattia@linux.it>
Subject: [PATCH 4/4] Group functions and structures to better draw subsytems usage
Date: Wed,  7 Feb 2007 20:01:56 +0100	[thread overview]
Message-ID: <1170874916831-git-send-email-malattia@linux.it> (raw)
In-Reply-To: <11708749161762-git-send-email-malattia@linux.it>

From: Mattia Dongili <malattia@linux.it>

Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/misc/sony-laptop.c |   92 ++++++++++++++++++++++++-------------------
 1 files changed, 51 insertions(+), 41 deletions(-)

diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
index 1d14969..4a69ce7 100644
--- a/drivers/misc/sony-laptop.c
+++ b/drivers/misc/sony-laptop.c
@@ -54,16 +54,6 @@ module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help "
 			"the development of this driver");
 
-static int sony_backlight_update_status(struct backlight_device *bd);
-static int sony_backlight_get_brightness(struct backlight_device *bd);
-static struct backlight_device *sony_backlight_device;
-static struct backlight_properties sony_backlight_properties = {
-	.owner		= THIS_MODULE,
-	.update_status	= sony_backlight_update_status,
-	.get_brightness	= sony_backlight_get_brightness,
-	.max_brightness	= SONY_MAX_BRIGHTNESS - 1,
-};
-
 static ssize_t sony_acpi_show(struct device *, struct device_attribute *, char *);
 static ssize_t sony_acpi_store(struct device *, struct device_attribute *, const char *, size_t);
 
@@ -137,6 +127,9 @@ static struct sony_acpi_value sony_acpi_values[] = {
 static acpi_handle sony_acpi_handle;
 static struct acpi_device *sony_acpi_acpi_device = NULL;
 
+/*
+ * acpi_evaluate_object wrappers
+ */
 static int acpi_callgetfunc(acpi_handle handle, char *name, int *result)
 {
 	struct acpi_buffer output;
@@ -335,25 +328,37 @@ static void sony_snc_pf_remove(void)
 	platform_driver_unregister(&sncpf_driver);
 }
 
-static int sony_acpi_resume(struct acpi_device *device)
+/*
+ * Backlight device
+ */
+static int sony_backlight_update_status(struct backlight_device *bd)
 {
-	struct sony_acpi_value *item;
+	return acpi_callsetfunc(sony_acpi_handle, "SBRT",
+				bd->props->brightness + 1,
+				NULL);
+}
 
-	for (item = sony_acpi_values; item->name; item++) {
-		int ret;
+static int sony_backlight_get_brightness(struct backlight_device *bd)
+{
+	int value;
 
-		if (!item->valid)
-			continue;
-		ret = acpi_callsetfunc(sony_acpi_handle, *item->acpiset,
-					item->value, NULL);
-		if (ret < 0) {
-			printk("%s: %d\n", __FUNCTION__, ret);
-			break;
-		}
-	}
-	return 0;
+	if (acpi_callgetfunc(sony_acpi_handle, "GBRT", &value))
+		return 0;
+	/* brightness levels are 1-based, while backlight ones are 0-based */
+	return value - 1;
 }
 
+static struct backlight_device *sony_backlight_device;
+static struct backlight_properties sony_backlight_properties = {
+	.owner		= THIS_MODULE,
+	.update_status	= sony_backlight_update_status,
+	.get_brightness	= sony_backlight_get_brightness,
+	.max_brightness	= SONY_MAX_BRIGHTNESS - 1,
+};
+
+/*
+ * ACPI callbacks
+ */
 static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
 {
 	if (debug)
@@ -376,6 +381,28 @@ static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
 	return AE_OK;
 }
 
+/*
+ * ACPI device
+ */
+static int sony_acpi_resume(struct acpi_device *device)
+{
+	struct sony_acpi_value *item;
+
+	for (item = sony_acpi_values; item->name; item++) {
+		int ret;
+
+		if (!item->valid)
+			continue;
+		ret = acpi_callsetfunc(sony_acpi_handle, *item->acpiset,
+					item->value, NULL);
+		if (ret < 0) {
+			printk("%s: %d\n", __FUNCTION__, ret);
+			break;
+		}
+	}
+	return 0;
+}
+
 static int sony_acpi_add(struct acpi_device *device)
 {
 	acpi_status status;
@@ -461,23 +488,6 @@ static int sony_acpi_remove(struct acpi_device *device, int type)
 	return 0;
 }
 
-static int sony_backlight_update_status(struct backlight_device *bd)
-{
-	return acpi_callsetfunc(sony_acpi_handle, "SBRT",
-				bd->props->brightness + 1,
-				NULL);
-}
-
-static int sony_backlight_get_brightness(struct backlight_device *bd)
-{
-	int value;
-
-	if (acpi_callgetfunc(sony_acpi_handle, "GBRT", &value))
-		return 0;
-	/* brightness levels are 1-based, while backlight ones are 0-based */
-	return value - 1;
-}
-
 static struct acpi_driver sony_acpi_driver = {
 	.name	= ACPI_SNC_DRIVER_NAME,
 	.class	= ACPI_SNC_CLASS,
-- 
1.4.4.3


  reply	other threads:[~2007-02-07 19:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-07 19:01 [PATCH 0/4] sony_acpi-0.4: morph into sony-laptop malattia
2007-02-07 19:01 ` [PATCH 1/4] Create sony-laptop malattia
2007-02-07 19:01   ` [PATCH 2/4] Remove /proc/acpi/sony interface and implement platform_device malattia
2007-02-07 19:01     ` [PATCH 3/4] Small update to the Kconfig help to make people believe this driver is useful malattia
2007-02-07 19:01       ` malattia [this message]
2007-02-10  1:47     ` [PATCH 2/4] Remove /proc/acpi/sony interface and implement platform_device Alessandro Guido
2007-02-10 12:49       ` Mattia Dongili
2007-02-07 20:50   ` [PATCH 1/4] Create sony-laptop Len Brown
2007-02-07 21:37     ` Mattia Dongili
2007-02-08  9:04     ` Andrew Morton

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=1170874916831-git-send-email-malattia@linux.it \
    --to=malattia@linux.it \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.