From: Thomas Renninger <trenn@suse.de>
To: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Julia Jomantaite <julia.jomantaite@gmail.com>,
Len Brown <len.brown@intel.com>,
ak@linux.intel.com, Andrew Morton <akpm@linux-foundation.org>,
linux-next@vger.kernel.org, Zhang Rui <rui.zhang@intel.com>
Subject: Re: [PATCH 55/84] ACPI: video: fix brightness allocation
Date: Wed, 2 Jul 2008 18:57:44 +0200 [thread overview]
Message-ID: <200807021857.45814.trenn@suse.de> (raw)
In-Reply-To: <985af41a38b76827c1f0692cf18469ebf0c4475b.1214631214.git.len.brown@intel.com>
On Saturday 28 June 2008 07:43:59 Len Brown wrote:
> From: Julia Jomantaite <julia.jomantaite@gmail.com>
>
> Fix use of uninitialized device->brightness.
Can this one be left out.
I did something similar and put the brightness (and display output)
initialization into separate functions for bug #9614:
http://bugzilla.kernel.org/show_bug.cgi?id=9614
My patches go a step further and make sure that not several drivers try to do
the switching.
They probably still need a bit testing and reviewing, but the first one:
Cleanup: Initialize brightness and display switching in separate functions
could replace this one (maybe a small one on top is still needed) already?
This would make things easier for me.
Could these three posted on the bug go into linux-next or into -mm?
Or should I better set up separate [PATCH 0/3] mails?
Thanks,
Thomas
>
> Signed-off-by: Julia Jomantaite <julia.jomantaite@gmail.com>
> Acked-by: Zhang Rui <rui.zhang@intel.com>
> Signed-off-by: Len Brown <len.brown@intel.com>
> ---
> drivers/acpi/video.c | 123
> +++++++++++++++++++++++++++++-------------------- 1 files changed, 73
> insertions(+), 50 deletions(-)
>
> diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
> index d089c45..0da8f55 100644
> --- a/drivers/acpi/video.c
> +++ b/drivers/acpi/video.c
> @@ -631,6 +631,76 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int
> bios_flag, int lcd_flag) * device : video output device (LCD, CRT, ..)
> *
> * Return Value:
> + * Maximum brightness level
> + *
> + * Allocate and initialize device->brightness.
> + */
> +
> +static int
> +acpi_video_init_brightness(struct acpi_video_device *device)
> +{
> + union acpi_object *obj = NULL;
> + int i, max_level = 0, count = 0;
> + union acpi_object *o;
> + struct acpi_video_device_brightness *br = NULL;
> +
> + if (!ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device, &obj))) {
> + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available "
> + "LCD brightness level\n"));
> + goto out;
> + }
> +
> + if (obj->package.count < 2)
> + goto out;
> +
> + br = kzalloc(sizeof(*br), GFP_KERNEL);
> + if (!br) {
> + printk(KERN_ERR "can't allocate memory\n");
> + goto out;
> + }
> +
> + br->levels = kmalloc(obj->package.count * sizeof *(br->levels),
> + GFP_KERNEL);
> + if (!br->levels)
> + goto out_free;
> +
> + for (i = 0; i < obj->package.count; i++) {
> + o = (union acpi_object *)&obj->package.elements[i];
> + if (o->type != ACPI_TYPE_INTEGER) {
> + printk(KERN_ERR PREFIX "Invalid data\n");
> + continue;
> + }
> + br->levels[count] = (u32) o->integer.value;
> +
> + if (br->levels[count] > max_level)
> + max_level = br->levels[count];
> + count++;
> + }
> +
> + if (count < 2)
> + goto out_free_levels;
> +
> + br->count = count;
> + device->brightness = br;
> + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "found %d brightness levels\n", count));
> + kfree(obj);
> + return max_level;
> +
> +out_free_levels:
> + kfree(br->levels);
> +out_free:
> + kfree(br);
> +out:
> + device->brightness = NULL;
> + kfree(obj);
> + return 0;
> +}
> +
> +/*
> + * Arg:
> + * device : video output device (LCD, CRT, ..)
> + *
> + * Return Value:
> * None
> *
> * Find out all required AML methods defined under the output
> @@ -640,10 +710,7 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int
> bios_flag, int lcd_flag) static void acpi_video_device_find_cap(struct
> acpi_video_device *device) {
> acpi_handle h_dummy1;
> - int i;
> u32 max_level = 0;
> - union acpi_object *obj = NULL;
> - struct acpi_video_device_brightness *br = NULL;
>
>
> memset(&device->cap, 0, sizeof(device->cap));
> @@ -672,53 +739,7 @@ static void acpi_video_device_find_cap(struct
> acpi_video_device *device) device->cap._DSS = 1;
> }
>
> - if (ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device, &obj))) {
> -
> - if (obj->package.count >= 2) {
> - int count = 0;
> - union acpi_object *o;
> -
> - br = kzalloc(sizeof(*br), GFP_KERNEL);
> - if (!br) {
> - printk(KERN_ERR "can't allocate memory\n");
> - } else {
> - br->levels = kmalloc(obj->package.count *
> - sizeof *(br->levels), GFP_KERNEL);
> - if (!br->levels)
> - goto out;
> -
> - for (i = 0; i < obj->package.count; i++) {
> - o = (union acpi_object *)&obj->package.
> - elements[i];
> - if (o->type != ACPI_TYPE_INTEGER) {
> - printk(KERN_ERR PREFIX "Invalid data\n");
> - continue;
> - }
> - br->levels[count] = (u32) o->integer.value;
> -
> - if (br->levels[count] > max_level)
> - max_level = br->levels[count];
> - count++;
> - }
> - out:
> - if (count < 2) {
> - kfree(br->levels);
> - kfree(br);
> - } else {
> - br->count = count;
> - device->brightness = br;
> - ACPI_DEBUG_PRINT((ACPI_DB_INFO,
> - "found %d brightness levels\n",
> - count));
> - }
> - }
> - }
> -
> - } else {
> - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available LCD
> brightness level\n")); - }
> -
> - kfree(obj);
> + max_level = acpi_video_init_brightness(device);
>
> if (device->cap._BCL && device->cap._BCM && device->cap._BQC && max_level
> > 0){ int result;
> @@ -1695,6 +1716,8 @@ static void
> acpi_video_switch_brightness(struct acpi_video_device *device, int event)
> {
> unsigned long level_current, level_next;
> + if (!device->brightness)
> + return;
> acpi_video_device_lcd_get_level_current(device, &level_current);
> level_next = acpi_video_get_next_level(device, level_current, event);
> acpi_video_device_lcd_set_level(device, level_next);
next prev parent reply other threads:[~2008-07-02 16:57 UTC|newest]
Thread overview: 90+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-28 5:43 ACPI patches for 2.6.27 merge window, ACPI maintainer change Len Brown
2008-06-28 5:43 ` [PATCH 01/84] fix a deadlock issue when poking "eject" file Len Brown
2008-06-28 5:43 ` [PATCH 02/84] force offline the processor during hot-removal Len Brown
2008-06-28 5:43 ` [PATCH 03/84] create sysfs link from acpi device to sysdev for cpu Len Brown
2008-06-28 5:43 ` [PATCH 04/84] misc,acpi,backlight: compal Laptop Extras Len Brown
2008-06-28 14:56 ` Matthew Garrett
2008-06-30 15:19 ` Cezary Jackiewicz
2008-06-30 15:21 ` Matthew Garrett
2008-06-28 5:43 ` [PATCH 05/84] ACPI: change processors from array to per_cpu variable Len Brown
2008-06-28 5:43 ` [PATCH 06/84] Fujitsu-laptop update Len Brown
2008-06-28 5:43 ` [PATCH 07/84] ACPI: fix checkpatch.pl complaints in scan.c Len Brown
2008-06-28 5:43 ` [PATCH 08/84] ACPI: fix acpi fan state set error Len Brown
2008-06-28 5:43 ` [PATCH 09/84] ACPI: fix processor throttling " Len Brown
2008-06-28 5:43 ` [PATCH 10/84] acpi: fix printk format warning Len Brown
2008-06-28 5:43 ` [PATCH 11/84] compal-laptop: remove unnecessary lcd_level attribute Len Brown
2008-06-28 5:43 ` [PATCH 12/84] x86 ACPI: normalize segment descriptor register on resume Len Brown
2008-06-28 5:43 ` [PATCH 13/84] Make GPE disable more robust Len Brown
2008-06-28 5:43 ` [PATCH 14/84] ACPICA: fix mutex names in debug code Len Brown
2008-06-28 5:43 ` [PATCH 15/84] eeepc-laptop: static Len Brown
2008-06-28 5:43 ` [PATCH 16/84] acer-wmi: Remove LED colour comment from documentation Len Brown
2008-06-28 5:43 ` [PATCH 17/84] acer-wmi: Blacklist backlight on Acer Aspire 1520 & 1360 series Len Brown
2008-06-28 5:43 ` [PATCH 18/84] acer-wmi: Respect framebuffer blanking in backlight Len Brown
2008-06-28 5:43 ` [PATCH 19/84] acer-wmi: Add EC quirk for Fujitsu Siemens Amilo Li 1718 Len Brown
2008-06-28 5:43 ` [PATCH 20/84] acer-wmi: Disable device autodetection on Fujitsu Siemens Amilo Li2732 Len Brown
2008-06-28 5:43 ` [PATCH 21/84] acer-wmi: Add debugfs file for device detection Len Brown
2008-06-28 5:43 ` [PATCH 22/84] acer-wmi: Remove version number Len Brown
2008-06-28 5:43 ` [PATCH 23/84] ACPI PM: acpi_pm_device_sleep_state() cleanup Len Brown
2008-06-28 5:43 ` [PATCH 24/84] PCI ACPI: Drop the second argument of platform_pci_choose_state Len Brown
2008-06-28 5:43 ` [PATCH 25/84] ACPI PM: Remove obsolete Toshiba workaround Len Brown
2008-06-28 5:43 ` [PATCH 26/84] APM emulation: Notify about all suspend events, not just APM invoked ones (v2) Len Brown
2008-06-28 5:43 ` [PATCH 27/84] Freezer: Introduce PF_FREEZER_NOSIG Len Brown
2008-06-28 5:43 ` [PATCH 28/84] snapshot: Push BKL down into ioctl handlers Len Brown
2008-06-28 5:43 ` [PATCH 29/84] snapshot: Use pm_mutex for mutual exclusion Len Brown
2008-06-28 5:43 ` [PATCH 30/84] fujitsu-laptop: depends on INPUT Len Brown
2008-06-28 5:43 ` [PATCH 31/84] ACPICA: Add argument count checking to control method invocation via acpi_evaluate_object Len Brown
2008-06-28 5:43 ` [PATCH 32/84] ACPICA: Fix for hang on GPE method invocation Len Brown
2008-06-28 5:43 ` [PATCH 33/84] ACPICA: Update tracking macros to reduce code/data size Len Brown
2008-06-28 5:43 ` [PATCH 34/84] ACPICA: Fix possible negative array index in acpi_ut_validate_exception Len Brown
2008-06-28 5:43 ` [PATCH 35/84] ACPICA: Eliminate acpi_native_uint type Len Brown
2008-06-28 5:43 ` [PATCH 36/84] ACPICA: Removed unused include files from source files Len Brown
2008-06-28 5:43 ` [PATCH 37/84] ACPICA: Several lint changes, no functional changes Len Brown
2008-06-28 5:43 ` [PATCH 38/84] ACPICA: Add const qualifier for appropriate string constants Len Brown
2008-06-28 5:43 ` [PATCH 39/84] ACPICA: Update version to 20080514 Len Brown
2008-06-28 5:43 ` [PATCH 40/84] ACPICA: Workaround for reversed _PRT entries from BIOS Len Brown
2008-06-28 5:43 ` [PATCH 41/84] ACPICA: Update DMAR and SRAT table definitions Len Brown
2008-06-28 5:43 ` [PATCH 42/84] ACPICA: Update disassembler for DMAR table changes Len Brown
2008-06-28 5:43 ` [PATCH 43/84] ACPICA: Fix for invalid large array index on 64-bit systems Len Brown
2008-06-28 5:43 ` [PATCH 44/84] ACPICA: Cleanup debug operand dump mechanism Len Brown
2008-06-28 5:43 ` [PATCH 45/84] ACPICA: Cleanup of _PRT parsing code Len Brown
2008-06-28 5:43 ` [PATCH 46/84] ACPICA: Fix mutex debug code for wrong loop termination value Len Brown
2008-06-28 5:43 ` [PATCH 47/84] ACPICA: Update version to 20080609 Len Brown
2008-06-28 5:43 ` [PATCH 48/84] ACPI: Enhance /sys/firmware/interrupts to allow enable/disable/clear from user-space Len Brown
2008-06-28 5:43 ` [PATCH 49/84] ACPI: Disable the C2C3_FFH access mode HW has no MWAIT support Len Brown
2008-06-28 5:43 ` [PATCH 50/84] ACPI: Create "idle=halt" bootparam Len Brown
2008-06-28 5:43 ` [PATCH 51/84] ACPI : Create "idle=nomwait" bootparam Len Brown
2008-06-28 5:43 ` [PATCH 52/84] ACPI: Disable MWAIT via DMI on broken Compal board Len Brown
2008-06-28 5:43 ` [PATCH 53/84] ACPI: Zhang Rui maintains ACPI THERMAL and FAN Len Brown
2008-06-28 5:43 ` [PATCH 54/84] ACPI: Andi Kleen maintains the ACPI sub-system Len Brown
2008-06-28 5:43 ` [PATCH 55/84] ACPI: video: fix brightness allocation Len Brown
2008-07-02 16:57 ` Thomas Renninger [this message]
2008-07-03 11:56 ` Thomas Renninger
2008-06-28 5:44 ` [PATCH 56/84] PNP: add detail to debug resource dump Len Brown
2008-06-28 5:44 ` [PATCH 57/84] PNP: remove pnp_resource.index Len Brown
2008-06-28 5:44 ` [PATCH 58/84] PNP: add pnp_resource_type() internal interface Len Brown
2008-06-28 5:44 ` [PATCH 59/84] PNP: add pnp_resource_type_name() helper function Len Brown
2008-06-28 5:44 ` [PATCH 60/84] PNP: make pnp_{port,mem,etc}_start(), et al work for invalid resources Len Brown
2008-06-28 5:44 ` [PATCH 61/84] PNP: replace pnp_resource_table with dynamically allocated resources Len Brown
2008-06-28 5:44 ` [PATCH 62/84] PNPACPI: keep disabled resources when parsing current config Len Brown
2008-06-28 5:44 ` [PATCH 63/84] PNP: remove ratelimit on add resource failures Len Brown
2008-06-28 5:44 ` [PATCH 64/84] PNP: dont sort by type in /sys/.../resources Len Brown
2008-06-28 5:44 ` [PATCH 65/84] PNP: add pnp_possible_config() -- can a device could be configured this way? Len Brown
2008-06-28 5:44 ` [PATCH 66/84] PNP: whitespace/coding style fixes Len Brown
2008-06-28 5:44 ` [PATCH 67/84] PNP: define PNP-specific IORESOURCE_IO_* flags alongside IRQ, DMA, MEM Len Brown
2008-06-28 5:44 ` [PATCH 68/84] PNP: make resource option structures private to PNP subsystem Len Brown
2008-06-28 5:44 ` [PATCH 69/84] PNP: introduce pnp_irq_mask_t typedef Len Brown
2008-06-28 5:44 ` [PATCH 70/84] PNP: increase I/O port & memory option address sizes Len Brown
2008-06-28 5:44 ` [PATCH 71/84] PNP: improve resource assignment debug Len Brown
2008-06-28 5:44 ` [PATCH 72/84] PNP: in debug resource dump, make empty list obvious Len Brown
2008-06-28 5:44 ` [PATCH 73/84] PNP: make resource assignment functions return 0 (success) or -EBUSY (failure) Len Brown
2008-06-28 5:44 ` [PATCH 74/84] PNP: remove redundant pnp_can_configure() check Len Brown
2008-06-28 5:44 ` [PATCH 75/84] PNP: centralize resource option allocations Len Brown
2008-06-28 5:44 ` [PATCH 76/84] PNPACPI: ignore _PRS interrupt numbers larger than PNP_IRQ_NR Len Brown
2008-06-28 5:44 ` [PATCH 77/84] PNP: rename pnp_register_*_resource() local variables Len Brown
2008-06-28 5:44 ` [PATCH 78/84] PNP: support optional IRQ resources Len Brown
2008-06-28 5:44 ` [PATCH 79/84] PNP: remove extra 0x100 bit from option priority Len Brown
2008-06-28 5:44 ` [PATCH 80/84] ISAPNP: handle independent options following dependent ones Len Brown
2008-06-28 5:44 ` [PATCH 81/84] PNP: convert resource options to single linked list Len Brown
2008-06-28 5:44 ` [PATCH 82/84] PNP: avoid legacy IDE IRQs Len Brown
2008-06-28 5:44 ` [PATCH 83/84] PNPACPI: add support for HP vendor-specific CCSR descriptors Len Brown
2008-06-28 5:44 ` [PATCH 84/84] ACPI: use dev_printk when possible Len Brown
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=200807021857.45814.trenn@suse.de \
--to=trenn@suse.de \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=julia.jomantaite@gmail.com \
--cc=len.brown@intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=rui.zhang@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).