backlight
Subsystems (24)
Bruno Prémont
maintainercover backlight
This series improves backlight_ops's check_fb function, marks backlight_ops as const and fixes error checking when registering backlight device.
Bruno
Bruno Prémont
maintainerPATCH 1/3 backlight: Add backlight_device parameter to check_fb
check_fb from backlight_ops lacks a reference to the backlight_device that's being referred to. Add this parameter so a backlight_device can be mapped to a single framebuffer, especially if the same driver handles multiple devices on a single system.
--- drivers/video/backlight/adx_bl.c | 2 +- drivers/video/backlight/backlight.c | 2 +- include/linux/backlight.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/video/backlight/adx_bl.c +1 -1
@@ -56,7 +56,7 @@ static int adx_backlight_get_brightness(struct backlight_device *bldev)return brightness &0xff ; } -static int adx_backlight_check_fb (struct fb_info *fb) +static int adx_backlight_check_fb (struct backlight_device *bldev,struct fb_info *fb) {return 1 ; }
drivers/video/backlight/backlight.c +1 -1
@@ -38,7 +38,7 @@ static int fb_notifier_callback(struct notifier_block *self,mutex_lock (&bd->ops_lock);if (bd->ops)if (!bd->ops->check_fb || - bd->ops->check_fb (evdata->info)) { + bd->ops->check_fb (bd, evdata->info)) { bd->props.fb_blank = *(int *)evdata->data;if (bd->props.fb_blank =FB_BLANK_UNBLANK ) bd->props.state &= ~BL_CORE_FBBLANK ;
include/linux/backlight.h +1 -1
@@ -47,7 +47,7 @@ struct backlight_ops {int (*const get_brightness)(struct backlight_device *);/* Check if given framebuffer device is the one bound to this backlight; return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */ -int (*const check_fb)(struct fb_info *); +int (*const check_fb)(struct backlight_device *,struct fb_info *); };/* This structure defines all the properties of a backlight */
Signature · 1 line
1.6.4.4
Bruno Prémont
maintainerPATCH 1/3 picolcd: driver for PicoLCD HID device
Driver for graphic PicoLCD device ( http://www.picolcd.com ) with framebuffer support (using deferredio), backlight control via backlight class, contrast control via lcd class and input for keypad.
More features of the device include CIR and GPIO, support for them will be added at a later time.
---
Note, this patch requires
"backlight: Add backlight_device parameter to check_fb"
Some lines are longer than suggested 80 columns, especially those for the declaration of initial framebuffer content that I did format one framebuffer line (256 pixel) per source line.
drivers/hid/Kconfig | 18 ++ drivers/hid/Makefile | 1 + drivers/hid/hid-core.c | 1 + drivers/hid/hid-ids.h | 1 + drivers/hid/hid-picolcd.c | 1075 +++++++++++++++++++++++++ 5 files changed, 1096 insertions(+), 0 deletions(-)
drivers/hid/Kconfig +18 -0
@@ -183,6 +183,24 @@ config LOGIRUMBLEPAD2_FF Say Y here if you want to enable force feedback support for Logitech Rumblepad 2 devices. +config HID_PICOLCD + tristate "Minibox PicoLCD (graphic version)" + depends on FB + select FB_DEFERRED_IO + select FB_SYS_FILLRECT + select FB_SYS_COPYAREA + select FB_SYS_IMAGEBLIT + select FB_SYS_FOPS + select BACKLIGHT_LCD_SUPPORT + select BACKLIGHT_CLASS_DEVICE + select LCD_CLASS_DEVICE + help + This provides support for Minibox PicoLCD devices, currently + only the graphical ones are supported. This includes support + for the device as a keypad input with mappable keys as well as + a framebuffer for the LCD display. + Support for the GPIOs and IR is not yet implemented + config HID_MICROSOFT tristate "Microsoft" if EMBEDDED depends on USB_HID
drivers/hid/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_HID_GYRATION) += hid-gyration.o obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o obj-$(CONFIG_HID_KYE) += hid-kye.o obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o +obj-$(CONFIG_HID_PICOLCD) += hid-picolcd.o obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o obj-$(CONFIG_HID_NTRIG) += hid-ntrig.o
drivers/hid/hid-core.c +1 -0
@@ -1330,6 +1330,7 @@ static const struct hid_device_id hid_blacklist[] = { { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) }, + { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) }, { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) }, { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) },
drivers/hid/hid-ids.h +1 -0
@@ -330,6 +330,7 @@#define USB_VENDOR_ID_MICROCHIP 0x04d8#define USB_DEVICE_ID_PICKIT1 0x0032#define USB_DEVICE_ID_PICKIT2 0x0033 +#define USB_DEVICE_ID_PICOLCD 0xc002#define USB_VENDOR_ID_MICROSOFT 0x045e#define USB_DEVICE_ID_SIDEWINDER_GV 0x003b
drivers/hid/hid-picolcd.c +1075 -0
1,075 lines not on this page · raw message
Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device
Am Mittwoch, 24. Februar 2010 17:00:49 schrieb Bruno Prémont:
Quoted 24 lines
drivers/hid/hid-picolcd.c +24
-0+static int picolcd_raw_event (struct hid_device *hdev, +struct hid_report *report,u8 *raw_data,int size) +{ +struct picolcd_data *data =hid_get_drvdata (hdev); +char hexdata[25 ]; +int i; + +if (data =NULL ) +return 1 ; + +for (i =0 ; i <sizeof (hexdata) /2 ; i++) +sprintf (hexdata+2 *i,"%02hhx" , raw_data[i]); +if (size >=sizeof (hexdata)/2 ) { + hexdata[sizeof (hexdata)-4 ] ='.' ; + hexdata[sizeof (hexdata)-3 ] ='.' ; + hexdata[sizeof (hexdata)-2 ] ='.' ; + hexdata[sizeof (hexdata)-1 ] ='\0' ; + }else + hexdata[size*2 ] ='\0' ; + +switch (report->id) { +case REPORT_KEYPAD : +if (size =3 && raw_data[0 ] =0x11 && data->input_keys) { +return picolcd_raw_keypad (hdev, report, raw_data+1 , size-1 );
drivers/hid/hid-picolcd.c line 797
Quoted 10 lines
drivers/hid/hid-picolcd.c +10
-0+ }else { +dbg_hid (PICOLCD_NAME " unsupported key event (%d bytes): 0x%s\n" , size, hexdata); +break ; + } +break ; +case REPORT_VERSION : +if (size =3 ) +dev_info (&hdev->dev,"Firmware version is %hd.%hd\n" , raw_data[1 ], raw_data[2 ]); + +spin_lock (&data->lock);
If I recall correctly raw_event is called in interrupt. As you take a spinlock here, the lock in code not called in interrupt must disable interrupts, or you may deadlock.
Regards
Oliver
Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device
Quoted 37 lines · Oliver Neukum
Am Mittwoch, 24. Februar 2010 17:00:49 schrieb Bruno Prémont:
Quoted 36 lines
drivers/hid/hid-picolcd.c +23
-0+static int picolcd_raw_event(struct hid_device *hdev, + struct hid_report *report, u8 *raw_data, int size) +{ + struct picolcd_data *data = hid_get_drvdata(hdev); + char hexdata[25]; + int i; + + if (data = NULL) + return 1; + + for (i = 0; i < sizeof(hexdata) / 2; i++) + sprintf(hexdata+2*i, "%02hhx", raw_data[i]); + if (size >= sizeof(hexdata)/2) { + hexdata[sizeof(hexdata)-4] = '.'; + hexdata[sizeof(hexdata)-3] = '.'; + hexdata[sizeof(hexdata)-2] = '.'; + hexdata[sizeof(hexdata)-1] = '\0'; + } else + hexdata[size*2] = '\0'; + + switch (report->id) { + case REPORT_KEYPAD: + if (size = 3 && raw_data[0] = 0x11 &&
data->input_keys) {
+ return picolcd_raw_keypad(hdev, report,
raw_data+1, size-1);(quoted diff) +2
-0+ } else { + dbg_hid(PICOLCD_NAME " unsupported key event (%dbytes): 0x%s\n", size, hexdata);
drivers/hid/hid-picolcd.c +6
-0+break ; + } +break ; +case REPORT_VERSION : +if (size =3 ) + dev_info(&hdev->dev, "Firmware version is%hd.%hd\n", raw_data[1], raw_data[2]);
Quoted 9 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + spin_lock(&data->lock);If I recall correctly
raw_eventis called in interrupt. As you take a spinlock here,
the lock in code not called in interrupt must disable interrupts, or you may
deadlock.
The issue, as I understand it is that non-interrupt code may obtain the lock and then the interrupt code is executed... hence the deadlock and the need to use spin_lock_irqsave() and spin_unlock_irqrestore().
If that is correct, is there any problem with the following approach?
The key difference is the replacement of spin_lock() with spin_trylock() such that if the non-interrupt code has already obtained the lock, the interrupt will not deadlock but instead take the else path and schedule a framebuffer update at the next interval.
static void g13_fb_urb_completion(struct urb *urb)
{
struct g13_data *data = urb->context;
spin_unlock(&data->fb_urb_lock);
}static int g13_fb_send(struct hid_device *hdev)
{
struct usb_interface *intf;
struct usb_device *usb_dev;
struct g13_data *data = hid_get_g13data(hdev);
struct usb_host_endpoint *ep;
unsigned int pipe;
int retval = 0;
/*
* Try and lock the framebuffer urb to prevent access if we have
* submitted it. If we can't lock it we'll have to delay this update
* until the next framebuffer interval.
*
* Fortunately, we already have the infrastructure in place with the
* framebuffer deferred I/O driver to schedule the delayed update.
*/
if (likely(spin_trylock(&data->fb_urb_lock))) {
/* Get the usb device to send the image on */
intf = to_usb_interface(hdev->dev.parent);
usb_dev = interface_to_usbdev(intf);
pipe = usb_sndintpipe(usb_dev, 0x02);
ep = usb_dev->ep_out[usb_pipeendpoint(pipe)];
if (unlikely(!ep)) {
spin_unlock(&data->fb_urb_lock);
return -EINVAL;
}
pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30);
usb_fill_int_urb(data->fb_urb, usb_dev, pipe, data->fb_vbitmap,
G13_VBITMAP_SIZE, g13_fb_urb_completion, NULL,
ep->desc.bInterval);
data->fb_urb->context = data;
data->fb_urb->actual_length = 0;
retval = usb_submit_urb(data->fb_urb, GFP_NOIO);
if (unlikely(retval < 0)) {
/*
* We need to unlock the framebuffer urb lock since
* the urb submission failed and therefore
* g13_fb_urb_completion() won't be called.
*/
spin_unlock(&data->fb_urb_lock);
return retval;
}
} else {
schedule_delayed_work(&data->fb_info->deferred_work,
data->fb_defio.delay);
}
return retval;
}Thanks,
Signature · 1 line
Rick
Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device
Am Mittwoch, 24. Februar 2010 22:44:53 schrieb Rick L. Vinyard, Jr.:
Quoted 3 lines
The issue, as I understand it is that non-interrupt code may obtain the lock and then the interrupt code is executed... hence the deadlock and the need to use
spin_lock_irqsave()andspin_unlock_irqrestore().
Yes.
Quoted 1 line
If that is correct, is there any problem with the following approach?
Why not always a workqueue or alternatively spin_lock_irq() when you are not in interrupt? This approach seems needlessly complicated.
Secondly, when you hold a spinlock, you must use GFP_ATOMIC. GFP_NOIO is insufficient.
Regards
Oliver
Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device
In reply to Rick L. Vinyard, Jr.Quoted 32 lines · Jr.
Quoted 32 lines
Quoted 32 lines
drivers/hid/hid-picolcd.c +23
-0+static int picolcd_raw_event(struct hid_device *hdev, + struct hid_report *report, u8 *raw_data, int size) +{ + struct picolcd_data *data = hid_get_drvdata(hdev); + char hexdata[25]; + int i; + + if (data = NULL) + return 1; + + for (i = 0; i < sizeof(hexdata) / 2; i++) + sprintf(hexdata+2*i, "%02hhx", raw_data[i]); + if (size >= sizeof(hexdata)/2) { + hexdata[sizeof(hexdata)-4] = '.'; + hexdata[sizeof(hexdata)-3] = '.'; + hexdata[sizeof(hexdata)-2] = '.'; + hexdata[sizeof(hexdata)-1] = '\0'; + } else + hexdata[size*2] = '\0'; + + switch (report->id) { + case REPORT_KEYPAD: + if (size = 3 && raw_data[0] = 0x11 &&
data->input_keys) {
+ return picolcd_raw_keypad(hdev, report,
raw_data+1, size-1);(quoted diff) +2
-0+ } else { + dbg_hid(PICOLCD_NAME " unsupported key event (%dbytes): 0x%s\n", size, hexdata);
drivers/hid/hid-picolcd.c +3
-0+break ; + } +break ;
Quoted 8 lines
Quoted 8 lines
Review
Quoted 6 lines
drivers/hid/hid-picolcd.c +3
-0+case REPORT_VERSION : +if (size =3 ) + dev_info(&hdev->dev, "Firmware version is%hd.%hd\n", raw_data[1], raw_data[2]);
(quoted diff) +2
-0+ + spin_lock(&data->lock);If I recall correctly
raw_eventis called in interrupt.
Yes, that is correct.
Quoted 3 lines
The issue, as I understand it is that non-interrupt code may obtain the lock and then the interrupt code is executed... hence the deadlock and the need to use
spin_lock_irqsave()andspin_unlock_irqrestore().
Exactly. All the spinlocks that are aquired in interrupt code-paths must be acquired with _irqsave()/_irqrestore() from the non-interrupt code to prevent exactly this kind of deadlock.
Quoted 5 lines
The key difference is the replacement of
spin_lock()withspin_trylock()such that if the non-interrupt code has already obtained the lock, the interrupt will not deadlock but instead take the else path and schedule a framebuffer update at the next interval.
Why is _irqsave() and/or deferred work not enough? The aproach with _trylock() seems to be overly complicated for no good reason (I personally become very suspicious every time I see code that is using _trylock()).
[ by the way, Rick, are you planning to resubmit the G13 driver with incorporated feedback from the last review round? ]
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs, Novell Inc.
Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device
Quoted 8 lines · Jiri Kosina
Quoted 5 lines · Jr.
The key difference is the replacement of
spin_lock()withspin_trylock()such that if the non-interrupt code has already obtained the lock, the interrupt will not deadlock but instead take the else path and schedule a
framebuffer update at the next interval.
Quoted 4 lines
Why is
_irqsave()and/or deferred work not enough? The aproach with_trylock()seems to be overly complicated for no good reason (I personally become very suspicious every time I see code that is using_trylock()).
I was concerned about _irqsave() because the lock is split across two functions to protect the urb after it is handed off to the usb subsystem with usb_submit_urb(). It's locked in g13_fb_send() and unlocked in the urb completion callback.
As for deferred work, the g13_fb_send() is the I/O portion of the deferred framebuffer callback. I was concerned that without a lock one deferred update could hand the urb off to the usb subsystem and a second could try to access it before it was handed back to the driver.
In this case the _trylock() would fail and in the else patch we would defer yet again until the next update cycle.
I took this approach because usb_interrupt_msg() couldn't be used from an interrupt context, such as a resume hook because eventually down the chain it does a wait_for_completion_timeout().
It has the added benefit of reusing the urb instead of creating a new one for each framebuffer sent out, but that wasn't a reason... just a side effect.
The downside is that I had to manage the urb.
One thing I could do is forget about directly calling g13_fb_send() from any context and instead use the deferred framebuffer workqueue.
That's probably a simpler approach anyway.
Quoted 3 lines
[ by the way, Rick, are you planning to resubmit the G13 driver with incorporated feedback from the last review round? ]
Yes. I just wanted to get the details of suspend/resume worked out before resubmitting.
Signature · 1 line
Rick
Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device
Quoted 19 lines · Jr.
Quoted 8 lines · Jiri Kosina
Quoted 5 lines · Jr.
The key difference is the replacement of
spin_lock()withspin_trylock()such that if the non-interrupt code has already obtained the lock, the interrupt will not deadlock but instead take the else path and schedule a
framebuffer update at the next interval.Quoted 4 lines
Why is
_irqsave()and/or deferred work not enough? The aproach with_trylock()seems to be overly complicated for no good reason (I personally become very suspicious every time I see code that is using_trylock()).I was concerned about
_irqsave()because the lock is split across two functions to protect the urb after it is handed off to the usb subsystem withusb_submit_urb(). It's locked ing13_fb_send()and unlocked in the urb completion callback.
Quoted 8 lines
As for deferred work, the
g13_fb_send()is the I/O portion of the deferred framebuffer callback. I was concerned that without a lock one deferred update could hand the urb off to the usb subsystem and a second could try to access it before it was handed back to the driver.In this case the
_trylock()would fail and in the else patch we would defer yet again until the next update cycle.
What you are looking for here is called test_and_set_bit(). Do not muddy the waters with a lock.
Signature · 1 line
Dmitry
Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device
In reply to Bruno Prémontdrivers/hid/Kconfig config LOGIRUMBLEPAD2_FF · line 196
Quoted 11 lines · Bruno Prémont
drivers/hid/Kconfig +11
-0+config HID_PICOLCD + tristate "Minibox PicoLCD (graphic version)" + depends on FB + select FB_DEFERRED_IO + select FB_SYS_FILLRECT + select FB_SYS_COPYAREA + select FB_SYS_IMAGEBLIT + select FB_SYS_FOPS + select BACKLIGHT_LCD_SUPPORT + select BACKLIGHT_CLASS_DEVICE + select LCD_CLASS_DEVICE
I guess you need dependency on USB_HID as well, right?
drivers/hid/hid-picolcd.c line 9
Quoted 12 lines
drivers/hid/hid-picolcd.c +9
-0@@ -0,0 +1,1075 @@ +/*************************************************************************** +* Copyright (C) 2010 by Bruno Prémont <[email protected]> * +* * +* Based on Logitech G13 driver (v0.4) * +* Copyright (C) 2009 by Rick L. Vinyard, Jr. <[email protected]> * +* * +* This program is free software: you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation, either version 2 of the License. *
I support removing the 'or any later' clause, but I think your version has the grammar wrong :)
drivers/hid/hid-picolcd.c line 392
Quoted 11 lines
drivers/hid/hid-picolcd.c +11
-0+/* Update fb_vbitmap from the screen_base and send changed tiles to device */ +static void picolcd_fb_update (struct picolcd_data *data) +{ +int chip, tile; + +spin_lock (&data->lock); +if (!(data->status &PICOLCD_READY_FB )) { +spin_unlock (&data->lock); +picolcd_fb_reset (data->hdev,0 ); + }else +spin_unlock (&data->lock);
Please put the brackets to the else branch as well.
Also, it'd be great if the framebuffer part would get Ack from someone more familiar with framebuffer code than me.
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs, Novell Inc.
Bruno Prémont
maintainerRe: [PATCH 1/3] picolcd: driver for PicoLCD HID device
Quoted 15 lines · On Thu, 25 February 2010 Jiri Kosina <[email protected]> wrote:
drivers/hid/Kconfig config LOGIRUMBLEPAD2_FF · line 196
Quoted 11 lines · Bruno Prémont
drivers/hid/Kconfig +11
-0+config HID_PICOLCD + tristate "Minibox PicoLCD (graphic version)" + depends on FB + select FB_DEFERRED_IO + select FB_SYS_FILLRECT + select FB_SYS_COPYAREA + select FB_SYS_IMAGEBLIT + select FB_SYS_FOPS + select BACKLIGHT_LCD_SUPPORT + select BACKLIGHT_CLASS_DEVICE + select LCD_CLASS_DEVICEI guess you need dependency on
USB_HIDas well, right?
Yep, will add
Quoted 7 lines
Quoted 7 lines
drivers/hid/hid-picolcd.c +4
-0@@ -0,0 +1,1075 @@ +/*************************************************************************** +* Copyright (C) 2010 by Bruno Prémont <[email protected]> * +* * +* Based on Logitech G13 driver (v0.4) *
Quoted 8 lines
drivers/hid/hid-picolcd.c line 9
Quoted 5 lines
drivers/hid/hid-picolcd.c +5
-0+* Copyright (C) 2009 by Rick L. Vinyard, Jr. <[email protected]> * +* * +* This program is free software: you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation, either version 2 of the License. * I support removing the 'or any later' clause, but I think your version has the grammar wrong :)
Oops, will fix
Quoted 5 lines
Quoted 5 lines
drivers/hid/hid-picolcd.c +5
-0+/* Update fb_vbitmap from the screen_base and send changed tiles to device */ +static void picolcd_fb_update (struct picolcd_data *data) +{ +int chip, tile; +
Quoted 8 lines
drivers/hid/hid-picolcd.c line 392
Quoted 6 lines
drivers/hid/hid-picolcd.c +6
-0+spin_lock (&data->lock); +if (!(data->status &PICOLCD_READY_FB )) { +spin_unlock (&data->lock); +picolcd_fb_reset (data->hdev,0 ); + }else +spin_unlock (&data->lock);Please put the brackets to the else branch as well.
Ok, will add the brackets while switching from spin_(un)lock to spin_(un)lock_irq{save|restore}.
Quoted 2 lines
Also, it'd be great if the framebuffer part would get Ack from someone more familiar with framebuffer code than me.
I would appreciate such one as well, especially regarding the deferredio part and the more advanced fb use. For now I only tested read/write from /dev/fbx.
For the two sysfs attributes I currently use, the 'reset' one shall probably be moved to debugfs (I would like to place it under /sys/kernel/debug/hid/$device/ next to rdesc and event).
By the way, I'm wondering why event does not list any of the reports coming from my device though as I understand the code it should be doing that before my raw_event function gets called...
The one for deferredio refresh rate should ideally go below fb device (and I guess that might also be of use for other users of deferredio)
Thanks for the review,
Bruno
Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device
Quoted 3 lines · Bruno Prémont
For the two sysfs attributes I currently use, the 'reset' one shall probably be moved to debugfs (I would like to place it under
/sys/kernel/debug/hid/$device/next to rdesc and event).
Yes, that would make sense.
( ... which reminds me to finally to the Documentation/ABI part in sync with respect to current HID code again ... )
Quoted 3 lines
By the way, I'm wondering why event does not list any of the reports coming from my device though as I understand the code it should be doing that before my
raw_eventfunction gets called...
Sorry, what 'event' do you mean in 'event does not list any of the reports'?
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs, Novell Inc.
Bruno Prémont
maintainerRe: [PATCH 1/3] picolcd: driver for PicoLCD HID device
Quoted 8 lines · On Thu, 25 February 2010 Jiri Kosina <[email protected]> wrote:
Quoted 3 lines · Bruno Prémont
For the two sysfs attributes I currently use, the 'reset' one shall probably be moved to debugfs (I would like to place it under
/sys/kernel/debug/hid/$device/next to rdesc and event).Yes, that would make sense.
So I will move it.
Quoted 9 lines
( ... which reminds me to finally to the
Documentation/ABIpart in sync with respect to current HID code again ... )Quoted 3 lines
By the way, I'm wondering why event does not list any of the reports coming from my device though as I understand the code it should be doing that before my
raw_eventfunction gets called...Sorry, what 'event' do you mean in 'event does not list any of the reports'?
Sorry, one 's' that got eaten between my brain and mail client. I mean events file in debugfs.
For USB HID keyboard each key press generates "report dump" under /sys/kernel/debug/hid/$device/events but for my PicoLCD I don't get any entry in there. I'm wondering why.
Thanks,
Bruno
Bruno Prémont
maintainerRe: [PATCH 1/3] picolcd: driver for PicoLCD HID device
In reply to Jiri KosinaQuoted 7 lines · On Thu, 25 February 2010 Jiri Kosina <[email protected]>…
Quoted 3 lines · Bruno Prémont
For the two sysfs attributes I currently use, the 'reset' one shall probably be moved to debugfs (I would like to place it under
/sys/kernel/debug/hid/$device/next to rdesc and events).Yes, that would make sense.
Hm, that works only when driver module gets loaded when USBHID device is already plugged in.
When driver is registered and has it's probe function called on hotplug it runs right before hid-core registers the debugfs entries. As such hid_device's debug_dir is still NULL.
To get around this, in hid_add_device(), hid_debug_register() would have to be called before device_add() instead of right after.
Is something like below acceptable? (from error handling point of view it makes no difference...)
Thanks,
Bruno
file: drivers/hid/hid-core.c
int hid_add_device(struct hid_device *hdev)
{
static atomic_t id = ATOMIC_INIT(0);
int ret;
if (WARN_ON(hdev->status & HID_STAT_ADDED))
return -EBUSY;
/* we need to kill them here, otherwise they will stay allocated to
* wait for coming driver */
if (hid_ignore(hdev))
return -ENODEV;
/* XXX hack, any other cleaner solution after the driver core
* is converted to allow more than 20 bytes as the device name? */
dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
hdev->vendor, hdev->product, atomic_inc_return(&id));+ hid_debug_register(hdev, dev_name(&hdev->dev));
ret = device_add(&hdev->dev);
if (!ret)
hdev->status |= HID_STAT_ADDED;- hid_debug_register(hdev, dev_name(&hdev->dev));
return ret;
}
EXPORT_SYMBOL_GPL(hid_add_device);
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device
Quoted 26 lines · On Sat, 13 Mar 2010, Bruno [UTF-8] Prémont wrote:
Is something like below acceptable? (from error handling point of view it makes no difference...)
Thanks,
Brunofile:
drivers/hid/hid-core.cint
hid_add_device(struct hid_device *hdev){ static atomic_t id = ATOMIC_INIT(0); int ret; if (WARN_ON(hdev->status & HID_STAT_ADDED)) return -EBUSY; /* we need to kill them here, otherwise they will stay allocated to * wait for coming driver */ if (hid_ignore(hdev)) return -ENODEV; /* XXX hack, any other cleaner solution after the driver core * is converted to allow more than 20 bytes as the device name? */ dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, hdev->vendor, hdev->product, atomic_inc_return(&id));
Review
Quoted 9 lines
(quoted diff) +1
-1+ hid_debug_register(hdev, dev_name(&hdev->dev)); ret = device_add(&hdev->dev); if (!ret) hdev->status |= HID_STAT_ADDED; - hid_debug_register(hdev, dev_name(&hdev->dev)); return ret; }
If the device_add() fails, you should undo the hid_debug_register() call.
Alan Stern
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Bruno Prémont
maintainerPATCH 1/1 hid: Register debugfs entries before adding device
Quoted 3 lines · On Sat, 13 March 2010 Alan Stern <[email protected]> wrote:
If the
device_add()fails, you should undo thehid_debug_register()call.
Well I was wondering why hid_debug_register() was called no matter what device_add() returned but didn't dig around what happened when hid_add_device() would return an error.
Looking a few lines further, hid_remove_device() just unregisters debugfs entries when status has HID_STAT_ADDED so it definitely makes sense to do the proper cleanup (and hid_remove_device() is the only once calling hid_debug_unregister())
So patch for both below:
Register debugfs entries before calling device_add() so debugfs entries are already present when HID driver's probe function gets called on device hotplug.
Also undo debugfs entry registration if device_add() fails so status HID_STAT_ADDED and debugfs registration status remain consistent and we don't leak the debugfs entries.
---
drivers/hid/hid-core.c +3 -2
@@ -1759,11 +1759,12 @@ int hid_add_device(struct hid_device *hdev)dev_set_name (&hdev->dev,"%04X:%04X:%04X.%04X" , hdev->bus, hdev->vendor, hdev->product,atomic_inc_return (&id)); +hid_debug_register (hdev,dev_name (&hdev->dev)); ret =device_add (&hdev->dev);if (!ret) hdev->status |=HID_STAT_ADDED ; - -hid_debug_register (hdev,dev_name (&hdev->dev)); +else +hid_debug_unregister (hdev);return ret; }
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jiri Kosina
AppliedRe: [PATCH] hid: Register debugfs entries before adding device
Quoted 37 lines · Bruno Prémont
Quoted 2 lines
If the
device_add()fails, you should undo thehid_debug_register()call.Well I was wondering why
hid_debug_register()was called no matter whatdevice_add()returned but didn't dig around what happened whenhid_add_device()would return an error.Looking a few lines further,
hid_remove_device()just unregisters debugfs entries when status hasHID_STAT_ADDEDso it definitely makes sense to do the proper cleanup (andhid_remove_device()is the only once callinghid_debug_unregister())So patch for both below:
Register debugfs entries before calling
device_add()so debugfs entries are already present when HID driver's probe function gets called on device hotplug.
Also undo debugfs entry registration ifdevice_add()fails so statusHID_STAT_ADDEDand debugfs registration status remain consistent and we don't leak the debugfs entries.Signed-off-by Bruno Prémont <[email protected]>Cc Alan Stern <[email protected]>---
drivers/hid/hid-core.c +0
-0@@ -1759,11 +1759,12 @@ int hid_add_device(struct hid_device *hdev)dev_set_name (&hdev->dev,"%04X:%04X:%04X.%04X" , hdev->bus, hdev->vendor, hdev->product,atomic_inc_return (&id));
drivers/hid/hid-core.c int hid_add_device(struct hid_device *hdev) · line 1769
Quoted 10 lines
drivers/hid/hid-core.c +3
-2+hid_debug_register (hdev,dev_name (&hdev->dev)); ret =device_add (&hdev->dev);if (!ret) hdev->status |=HID_STAT_ADDED ; - -hid_debug_register (hdev,dev_name (&hdev->dev)); +else +hid_debug_unregister (hdev);return ret;
Applied, thank you Bruno.
Signature · 2 lines
Jiri Kosina SUSE Labs, Novell Inc.
Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device
In reply to Bruno PrémontQuoted 3 lines · Bruno Prémont
The one for deferredio refresh rate should ideally go below fb device (and I guess that might also be of use for other users of deferredio)
I'm testing a patch now. I didn't expect anyone else would really need it, but it does help with throttling bus traffic from userspace.
If it's in fbsysfs.c we can both eliminate it from our drivers.
Signature · 1 line
Rick
Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device
In reply to Jiri KosinaQuoted 16 lines · Jiri Kosina
drivers/hid/hid-picolcd.c line 392
Quoted 11 lines · Bruno Prémont
drivers/hid/hid-picolcd.c +11
-0+/* Update fb_vbitmap from the screen_base and send changed tiles to device */ +static void picolcd_fb_update (struct picolcd_data *data) +{ +int chip, tile; + +spin_lock (&data->lock); +if (!(data->status &PICOLCD_READY_FB )) { +spin_unlock (&data->lock); +picolcd_fb_reset (data->hdev,0 ); + }else +spin_unlock (&data->lock);Please put the brackets to the else branch as well.
Well, it looks like it can be rewritten as:
spin_lock(&data->lock); need_reset = !(data->status & PICOLCD_READY_FB); spin_unlock(&data->lock); if (need_reset) picolcd_fb_reset(data->hdev, 0);
Which plainly shows that the locking here is bogus.
Signature · 1 line
Dmitry
Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device
In reply to Bruno PrémontHi!
Quoted 14 lines
drivers/hid/hid-picolcd.c +14
-0+#ifdef CONFIG_LOGO +/* +* This is a default logo to be loaded upon driver initialization +* replacing the default PicoLCD image loaded on device +* initialization. This is to provide the user a cue that the +* Linux driver is loaded and ready. +* +* This logo contains the text PicoLCD in the center with one penguin +* on each side of the text. The penguins are a 64x64 rendition of +* the default framebuffer 80x80 monochrome image scaled down and +* cleaned up to retain something that looks a little better than +* a simple scaling. +* +* This logo is a simple xbm image created in GIMP and exported.
drivers/hid/hid-picolcd.c line 126
Quoted 10 lines
drivers/hid/hid-picolcd.c +10
-0+* To view the image copy the following two #defines plus the +* picolcd_bits to an ASCII text file and save with extension +* .xbm, then open with GIMP or any other graphical editor +* such as eog that recognizes the .xbm format. +*/ +#define picolcd_width 256 +#define picolcd_height 64 +static const u8 picolcd_bits[PICOLCDFB_SIZE ] = { +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xf8 ,0x1f ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xf8 ,0x1f ,0xff ,0xff ,0xff ,
Please remove this. There are less ugly/shorter ways to tell the user device is ready.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Bruno Prémont
maintainerPATCH 2/3 hid: add suspend/resume hooks for hid drivers
Add suspend/resume hooks for HID drivers so these can do some additional state adjustment when device gets suspended/resumed.
This patch calls these hooks from usbhid suspend/resume functions, only calling suspend on plain suspend, not autosuspend. (it might be worth adding an autosuspend parameter to suspend hook and calling suspend in both cases)
--- drivers/hid/hid-core.c | 19 ++- include/linux/hid.h | 8 + 2 files changed, 36 insertions(+), 1 deletions(-)
drivers/hid/usbhid/hid-core.c +18 -1
@@ -1272,6 +1272,11 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message) } }else { +if (hid->driver && hid->driver->suspend) { + status = hid->driver->suspend (hid); +if (status <0 ) +return status; + }spin_lock_irq (&usbhid->lock);set_bit (HID_REPORTED_IDLE , &usbhid->iofl);spin_unlock_irq (&usbhid->lock);
@@ -1326,6 +1331,11 @@ static int hid_resume(struct usb_interface *intf)hid_io_error (hid);usbhid_restart_queues (usbhid); +if (hid->driver && hid->driver->resume) { +int ret = hid->driver->resume (hid); +if (ret <0 && status ==0 ) + status = ret; + }dev_dbg (&intf->dev,"resume status %d\n" , status);return 0 ; }
@@ -1334,9 +1344,16 @@ static int hid_reset_resume(struct usb_interface *intf) {struct hid_device *hid =usb_get_intfdata (intf);struct usbhid_device *usbhid = hid->driver_data; +int status;clear_bit (HID_REPORTED_IDLE , &usbhid->iofl); -return hid_post_reset (intf); + status =hid_post_reset (intf); +if (hid->driver && hid->driver->reset_resume) { +int ret = hid->driver->reset_resume (hid); +if (ret <0 && status ==0 ) + status = ret; + } +return status; }#endif /* CONFIG_PM */
include/linux/hid.h +8 -0
@@ -589,6 +589,9 @@ struct hid_usage_id {* @report_fixup: called before report descriptor parsing (NULL means nop) * @input_mapping: invoked on input registering before mapping an usage * @input_mapped: invoked on input registering after mapping an usage +* @suspend: invoked on suspend (NULL means nop) +* @resume: invoked on resume if device was not reset (NULL means nop) +* @reset_resume: invoked on resume if device was reset (NULL means nop) * * raw_event and event should return 0 on no action performed, 1 when no * further processing should be done and negative on error
@@ -629,6 +632,11 @@ struct hid_driver {int (*input_mapped)(struct hid_device *hdev,struct hid_input *hidinput,struct hid_field *field,struct hid_usage *usage,unsigned long **bit,int *max); +#ifdef CONFIG_PM +int (*suspend)(struct hid_device *hdev); +int (*resume)(struct hid_device *hdev); +int (*reset_resume)(struct hid_device *hdev); +#endif /* private: */ struct device_driver driver; };
Re: [PATCH 2/3] hid: add suspend/resume hooks for hid drivers
Am Mittwoch, 24. Februar 2010 17:01:12 schrieb Bruno Prémont:
Quoted 7 lines
Add suspend/resume hooks for HID drivers so these can do some additional state adjustment when device gets suspended/resumed.
This patch calls these hooks from usbhid suspend/resume functions, only calling suspend on plain suspend, not autosuspend. (it might be worth adding an autosuspend parameter to suspend hook and calling suspend in both cases)
This is quite dirty. A driver that was autosuspended may be non-auto resumed. Secondly, do you really want to call the hook for reset_resume() if hid_post_reset() has failed?
Regards
Oliver
Bruno Prémont
maintainerRe: [PATCH 2/3] hid: add suspend/resume hooks for hid drivers
Quoted 10 lines · On Thu, 25 February 2010 Oliver Neukum <[email protected]> wrote:
Am Mittwoch, 24. Februar 2010 17:01:12 schrieb Bruno Prémont:
Quoted 7 lines
Add suspend/resume hooks for HID drivers so these can do some additional state adjustment when device gets suspended/resumed.
This patch calls these hooks from usbhid suspend/resume functions, only calling suspend on plain suspend, not autosuspend. (it might be worth adding an autosuspend parameter to suspend hook and calling suspend in both cases)
This is quite dirty.
Yeah, it covers what I did need (at least for success path). For the rest I was expecting feedback (and probably should have labeled the patch RFC)
Quoted 3 lines
A driver that was autosuspended may be non-auto resumed. Secondly, do you really want to call the hook for
reset_resume()ifhid_post_reset()has failed?
Possibly not though depending on why hid_post_reset failed the first USB operation would fail as well, thus it would fall under "normal" error conditions for the driver...
Opinion of USB/HID experts is welcome!
Quoted 2 lines
Regards
Oliver
Thanks for the review!
Regards,
Bruno
Bruno Prémont
maintainerPATCH 3/3 hid-picolcd: make use of new suspend/resume hooks
In reply to a message not in the archiveMake use of new suspend/resume hooks to disable backlight on suspend and restore backlight on simple resume or backlight, contrast and framebuffer content on reset-resume.
--- drivers/hid/hid-picolcd.c | 45 +++ 1 files changed, 45 insertions(+), 0 deletions(-)
drivers/hid/hid-picolcd.c +45 -0
@@ -833,6 +833,46 @@ }; +#ifdef CONFIG_PM +static int picolcd_suspend (struct hid_device *hdev) +{ +struct picolcd_data *data =hid_get_drvdata (hdev); +int bl_power = data->lcd_power; + + data->backlight->props.power =FB_BLANK_POWERDOWN ; +picolcd_set_brightness (data->backlight); + data->lcd_power = data->backlight->props.power = bl_power; +dbg_hid (PICOLCD_NAME " device ready for suspend, lcd_power=%d\n" , bl_power); +return 0 ; +} + +static int picolcd_resume (struct hid_device *hdev) +{ +struct picolcd_data *data =hid_get_drvdata (hdev); +int ret; + ret =picolcd_set_brightness (data->backlight); +if (ret) +dbg_hid (PICOLCD_NAME " restoring brightness failed: %d\n" , ret); + ret =picolcd_set_contrast (data->lcd, data->lcd_contrast); +if (ret) +dbg_hid (PICOLCD_NAME " restoring contrast failed: %d\n" , ret); +return 0 ; +} + +static int picolcd_reset_resume (struct hid_device *hdev) +{ +int ret; + ret =picolcd_reset (hdev); +if (ret) +dbg_hid (PICOLCD_NAME " resetting our device failed: %d\n" , ret); + ret =picolcd_fb_reset (hdev,0 ); +if (ret) +dbg_hid (PICOLCD_NAME " restoring framebuffer content failed: %d\n" , ret); +return 0 ; +} +#endif + +static int picolcd_probe (struct hid_device *hdev,const struct hid_device_id *id) {
@@ -1057,6 +1097,11 @@ .probe = picolcd_probe, .remove = picolcd_remove, .raw_event = picolcd_raw_event, +#ifdef CONFIG_PM + .suspend = picolcd_suspend, + .resume = picolcd_resume, + .reset_resume = picolcd_reset_resume, +#endif };static int __init picolcd_init (void )
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Bruno Prémont
maintainerPATCH 1/1 backlight: Add backlight_device parameter to check_fb
In reply to Bruno Prémontcheck_fb from backlight_ops lacks a reference to the backlight_device that's being referred to. Add this parameter so a backlight_device can be mapped to a single framebuffer, especially if the same driver handles multiple devices on a single system.
--- drivers/video/backlight/adx_bl.c | 2 +- drivers/video/backlight/backlight.c | 2 +- include/linux/backlight.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/video/backlight/adx_bl.c +1 -1
@@ -56,7 +56,7 @@ static int adx_backlight_get_brightness(struct backlight_device *bldev)return brightness &0xff ; } -static int adx_backlight_check_fb (struct fb_info *fb) +static int adx_backlight_check_fb (struct backlight_device *bldev,struct fb_info *fb) {return 1 ; }
drivers/video/backlight/backlight.c +1 -1
@@ -38,7 +38,7 @@ static int fb_notifier_callback(struct notifier_block *self,mutex_lock (&bd->ops_lock);if (bd->ops)if (!bd->ops->check_fb || - bd->ops->check_fb (evdata->info)) { + bd->ops->check_fb (bd, evdata->info)) { bd->props.fb_blank = *(int *)evdata->data;if (bd->props.fb_blank =FB_BLANK_UNBLANK ) bd->props.state &= ~BL_CORE_FBBLANK ;
include/linux/backlight.h +1 -1
@@ -47,7 +47,7 @@ struct backlight_ops {int (*const get_brightness)(struct backlight_device *);/* Check if given framebuffer device is the one bound to this backlight; return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */ -int (*const check_fb)(struct fb_info *); +int (*const check_fb)(struct backlight_device *,struct fb_info *); };/* This structure defines all the properties of a backlight */
Signature · 1 line
1.6.4.4
Bruno Prémont
maintainerPATCH 2/3 backlight: mark struct backlight_ops const
In reply to Bruno Prémont--- drivers/acpi/video.c | 2 +- drivers/gpu/drm/nouveau/nouveau_backlight.c | 4 ++-- drivers/macintosh/via-pmu-backlight.c | 4 ++-- drivers/platform/x86/acer-wmi.c | 2 +- drivers/platform/x86/asus-laptop.c | 2 +- drivers/platform/x86/asus_acpi.c | 2 +- drivers/platform/x86/classmate-laptop.c | 2 +- drivers/platform/x86/compal-laptop.c | 2 +- drivers/platform/x86/dell-laptop.c | 2 +- drivers/platform/x86/eeepc-laptop.c | 2 +- drivers/platform/x86/fujitsu-laptop.c | 2 +- drivers/platform/x86/msi-laptop.c | 2 +- drivers/platform/x86/msi-wmi.c | 2 +- drivers/platform/x86/panasonic-laptop.c | 2 +- drivers/platform/x86/sony-laptop.c | 2 +- drivers/platform/x86/thinkpad_acpi.c | 2 +- drivers/platform/x86/toshiba_acpi.c | 2 +- drivers/staging/samsung-laptop/samsung-laptop.c | 2 +- drivers/usb/misc/appledisplay.c | 2 +- drivers/video/atmel_lcdfb.c | 2 +- drivers/video/aty/aty128fb.c | 2 +- drivers/video/aty/atyfb_base.c | 2 +- drivers/video/aty/radeon_backlight.c | 2 +- drivers/video/bf54x-lq043fb.c | 2 +- drivers/video/bfin-t350mcqb-fb.c | 2 +- drivers/video/nvidia/nv_backlight.c | 2 +- drivers/video/omap2/displays/panel-taal.c | 2 +- drivers/video/riva/fbdev.c | 2 +- 28 files changed, 30 insertions(+), 30 deletions(-)
drivers/acpi/video.c +1 -1
@@ -366,7 +366,7 @@ static int acpi_video_set_brightness(struct backlight_device *bd) vd->brightness->levels[request_level]); } -static struct backlight_ops acpi_backlight_ops = { +static const struct backlight_ops acpi_backlight_ops = { .get_brightness = acpi_video_get_brightness, .update_status = acpi_video_set_brightness, };
drivers/gpu/drm/nouveau/nouveau_backlight.c +2 -2
@@ -58,7 +58,7 @@ static int nv40_set_intensity(struct backlight_device *bd)return 0 ; } -static struct backlight_ops nv40_bl_ops = { +static const struct backlight_ops nv40_bl_ops = { .options =BL_CORE_SUSPENDRESUME , .get_brightness = nv40_get_intensity, .update_status = nv40_set_intensity,
@@ -81,7 +81,7 @@ static int nv50_set_intensity(struct backlight_device *bd)return 0 ; } -static struct backlight_ops nv50_bl_ops = { +static const struct backlight_ops nv50_bl_ops = { .options =BL_CORE_SUSPENDRESUME , .get_brightness = nv50_get_intensity, .update_status = nv50_set_intensity,
drivers/macintosh/via-pmu-backlight.c +2 -2
@@ -15,7 +15,7 @@#define MAX_PMU_LEVEL 0xFF -static struct backlight_ops pmu_backlight_data; +static const struct backlight_ops pmu_backlight_data;static DEFINE_SPINLOCK (pmu_backlight_lock);static int sleeping, uses_pmu_bl;static u8 bl_curve[FB_BACKLIGHT_LEVELS ];
@@ -115,7 +115,7 @@ static int pmu_backlight_get_brightness(struct backlight_device *bd)return bd->props.brightness; } -static struct backlight_ops pmu_backlight_data = { +static const struct backlight_ops pmu_backlight_data = { .get_brightness = pmu_backlight_get_brightness, .update_status = pmu_backlight_update_status,
drivers/platform/x86/acer-wmi.c +1 -1
@@ -915,7 +915,7 @@ static int update_bl_status(struct backlight_device *bd)return 0 ; } -static struct backlight_ops acer_bl_ops = { +static const struct backlight_ops acer_bl_ops = { .get_brightness = read_brightness, .update_status = update_bl_status, };
drivers/platform/x86/asus-laptop.c +1 -1
@@ -251,7 +251,7 @@ static struct backlight_device *asus_backlight_device;*/ static int read_brightness (struct backlight_device *bd);static int update_bl_status (struct backlight_device *bd); -static struct backlight_ops asusbl_ops = { +static const struct backlight_ops asusbl_ops = { .get_brightness = read_brightness, .update_status = update_bl_status, };
drivers/platform/x86/asus_acpi.c +1 -1
@@ -1464,7 +1464,7 @@ static int asus_hotk_remove(struct acpi_device *device, int type)return 0 ; } -static struct backlight_ops asus_backlight_data = { +static const struct backlight_ops asus_backlight_data = { .get_brightness = read_brightness, .update_status = set_brightness_status, };
drivers/platform/x86/classmate-laptop.c +1 -1
@@ -452,7 +452,7 @@ static int cmpc_bl_update_status(struct backlight_device *bd)return -1 ; } -static struct backlight_ops cmpc_bl_ops = { +static const struct backlight_ops cmpc_bl_ops = { .get_brightness = cmpc_bl_get_brightness, .update_status = cmpc_bl_update_status };
drivers/platform/x86/compal-laptop.c +1 -1
@@ -162,7 +162,7 @@ static int bl_update_status(struct backlight_device *b)return set_lcd_level (b->props.brightness); } -static struct backlight_ops compalbl_ops = { +static const struct backlight_ops compalbl_ops = { .get_brightness = bl_get_brightness, .update_status = bl_update_status, };
drivers/platform/x86/dell-laptop.c +1 -1
@@ -333,7 +333,7 @@ static int dell_get_intensity(struct backlight_device *bd)return buffer.output[1 ]; } -static struct backlight_ops dell_ops = { +static const struct backlight_ops dell_ops = { .get_brightness = dell_get_intensity, .update_status = dell_send_intensity, };
drivers/platform/x86/eeepc-laptop.c +1 -1
@@ -1096,7 +1096,7 @@ static int update_bl_status(struct backlight_device *bd)return set_brightness (bd, bd->props.brightness); } -static struct backlight_ops eeepcbl_ops = { +static const struct backlight_ops eeepcbl_ops = { .get_brightness = read_brightness, .update_status = update_bl_status, };
drivers/platform/x86/fujitsu-laptop.c +1 -1
@@ -436,7 +436,7 @@ static int bl_update_status(struct backlight_device *b)return ret; } -static struct backlight_ops fujitsubl_ops = { +static const struct backlight_ops fujitsubl_ops = { .get_brightness = bl_get_brightness, .update_status = bl_update_status, };
drivers/platform/x86/msi-laptop.c +1 -1
@@ -161,7 +161,7 @@ static int bl_update_status(struct backlight_device *b)return set_lcd_level (b->props.brightness); } -static struct backlight_ops msibl_ops = { +static const struct backlight_ops msibl_ops = { .get_brightness = bl_get_brightness, .update_status = bl_update_status, };
drivers/platform/x86/msi-wmi.c +1 -1
@@ -138,7 +138,7 @@ static int bl_set_status(struct backlight_device *bd)return msi_wmi_set_block (0 , backlight_map[bright]); } -static struct backlight_ops msi_backlight_ops = { +static const struct backlight_ops msi_backlight_ops = { .get_brightness = bl_get, .update_status = bl_set_status, };
drivers/platform/x86/panasonic-laptop.c +1 -1
@@ -352,7 +352,7 @@ static int bl_set_status(struct backlight_device *bd)return acpi_pcc_write_sset (pcc,SINF_DC_CUR_BRIGHT , bright); } -static struct backlight_ops pcc_backlight_ops = { +static const struct backlight_ops pcc_backlight_ops = { .get_brightness = bl_get, .update_status = bl_set_status, };
drivers/platform/x86/sony-laptop.c +1 -1
@@ -853,7 +853,7 @@ static int sony_backlight_get_brightness(struct backlight_device *bd) }static struct backlight_device *sony_backlight_device; -static struct backlight_ops sony_backlight_ops = { +static const struct backlight_ops sony_backlight_ops = { .update_status = sony_backlight_update_status, .get_brightness = sony_backlight_get_brightness, };
drivers/platform/x86/thinkpad_acpi.c +1 -1
@@ -6112,7 +6112,7 @@ static void tpacpi_brightness_notify_change(void) BACKLIGHT_UPDATE_HOTKEY); } -static struct backlight_ops ibm_backlight_data = { +static const struct backlight_ops ibm_backlight_data = { .get_brightness = brightness_get, .update_status = brightness_update_status, };
drivers/platform/x86/toshiba_acpi.c +1 -1
@@ -706,7 +706,7 @@ static acpi_status remove_device(void)return AE_OK ; } -static struct backlight_ops toshiba_backlight_data = { +static const struct backlight_ops toshiba_backlight_data = { .get_brightness = get_lcd, .update_status = set_lcd_status, };
drivers/staging/samsung-laptop/samsung-laptop.c +1 -1
@@ -268,7 +268,7 @@ static int update_status(struct backlight_device *bd)return 0 ; } -static struct backlight_ops backlight_ops = { +static const struct backlight_ops backlight_ops = { .get_brightness = get_brightness, .update_status = update_status, };
drivers/usb/misc/appledisplay.c +1 -1
@@ -179,7 +179,7 @@ static int appledisplay_bl_get_brightness(struct backlight_device *bd)return pdata->msgdata[1 ]; } -static struct backlight_ops appledisplay_bl_data = { +static const struct backlight_ops appledisplay_bl_data = { .get_brightness = appledisplay_bl_get_brightness, .update_status = appledisplay_bl_update_status, };
drivers/video/atmel_lcdfb.c +1 -1
@@ -110,7 +110,7 @@ static int atmel_bl_get_brightness(struct backlight_device *bl)return lcdc_readl (sinfo,ATMEL_LCDC_CONTRAST_VAL ); } -static struct backlight_ops atmel_lcdc_bl_ops = { +static const struct backlight_ops atmel_lcdc_bl_ops = { .update_status = atmel_bl_update_status, .get_brightness = atmel_bl_get_brightness, };
drivers/video/aty/aty128fb.c +1 -1
@@ -1787,7 +1787,7 @@ static int aty128_bl_get_brightness(struct backlight_device *bd)return bd->props.brightness; } -static struct backlight_ops aty128_bl_data = { +static const struct backlight_ops aty128_bl_data = { .get_brightness = aty128_bl_get_brightness, .update_status = aty128_bl_update_status, };
drivers/video/aty/atyfb_base.c +1 -1
@@ -2225,7 +2225,7 @@ static int aty_bl_get_brightness(struct backlight_device *bd)return bd->props.brightness; } -static struct backlight_ops aty_bl_data = { +static const struct backlight_ops aty_bl_data = { .get_brightness = aty_bl_get_brightness, .update_status = aty_bl_update_status, };
drivers/video/aty/radeon_backlight.c +1 -1
@@ -127,7 +127,7 @@ static int radeon_bl_get_brightness(struct backlight_device *bd)return bd->props.brightness; } -static struct backlight_ops radeon_bl_data = { +static const struct backlight_ops radeon_bl_data = { .get_brightness = radeon_bl_get_brightness, .update_status = radeon_bl_update_status, };
drivers/video/bf54x-lq043fb.c +1 -1
@@ -463,7 +463,7 @@ static int bl_get_brightness(struct backlight_device *bd)return 0 ; } -static struct backlight_ops bfin_lq043fb_bl_ops = { +static const struct backlight_ops bfin_lq043fb_bl_ops = { .get_brightness = bl_get_brightness, };
drivers/video/bfin-t350mcqb-fb.c +1 -1
@@ -381,7 +381,7 @@ static int bl_get_brightness(struct backlight_device *bd)return 0 ; } -static struct backlight_ops bfin_lq043fb_bl_ops = { +static const struct backlight_ops bfin_lq043fb_bl_ops = { .get_brightness = bl_get_brightness, };
drivers/video/nvidia/nv_backlight.c +1 -1
@@ -87,7 +87,7 @@ static int nvidia_bl_get_brightness(struct backlight_device *bd)return bd->props.brightness; } -static struct backlight_ops nvidia_bl_ops = { +static const struct backlight_ops nvidia_bl_ops = { .get_brightness = nvidia_bl_get_brightness, .update_status = nvidia_bl_update_status, };
drivers/video/omap2/displays/panel-taal.c +1 -1
@@ -313,7 +313,7 @@ static int taal_bl_get_intensity(struct backlight_device *dev)return 0 ; } -static struct backlight_ops taal_bl_ops = { +static const struct backlight_ops taal_bl_ops = { .get_brightness = taal_bl_get_intensity, .update_status = taal_bl_update_status, };
drivers/video/riva/fbdev.c +1 -1
@@ -331,7 +331,7 @@ static int riva_bl_get_brightness(struct backlight_device *bd)return bd->props.brightness; } -static struct backlight_ops riva_bl_ops = { +static const struct backlight_ops riva_bl_ops = { .get_brightness = riva_bl_get_brightness, .update_status = riva_bl_update_status, };
Signature · 6 lines
1.6.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/3] backlight: mark struct backlight_ops const
Quoted 2 lines · Bruno Prémont
drivers/video/bf54x-lq043fb.c | 2 +-
drivers/video/bfin-t350mcqb-fb.c| 2 +-
-mike
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
ibm-acpi-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel
Bruno Prémont
maintainerPATCH 1/1 backlight: mark struct backlight_ops const
In reply to Bruno Prémont--- drivers/acpi/video.c | 2 +- drivers/gpu/drm/nouveau/nouveau_backlight.c | 4 ++-- drivers/macintosh/via-pmu-backlight.c | 4 ++-- drivers/platform/x86/acer-wmi.c | 2 +- drivers/platform/x86/asus-laptop.c | 2 +- drivers/platform/x86/asus_acpi.c | 2 +- drivers/platform/x86/compal-laptop.c | 2 +- drivers/platform/x86/dell-laptop.c | 2 +- drivers/platform/x86/eeepc-laptop.c | 2 +- drivers/platform/x86/fujitsu-laptop.c | 2 +- drivers/platform/x86/panasonic-laptop.c | 2 +- drivers/platform/x86/sony-laptop.c | 2 +- drivers/platform/x86/thinkpad_acpi.c | 2 +- drivers/platform/x86/toshiba_acpi.c | 2 +- drivers/staging/samsung-laptop/samsung-laptop.c | 2 +- drivers/video/atmel_lcdfb.c | 2 +- drivers/video/aty/aty128fb.c | 2 +- drivers/video/aty/atyfb_base.c | 2 +- drivers/video/aty/radeon_backlight.c | 2 +- drivers/video/nvidia/nv_backlight.c | 2 +- drivers/video/omap2/displays/panel-taal.c | 2 +- drivers/video/riva/fbdev.c | 2 +- 22 files changed, 24 insertions(+), 24 deletions(-)
drivers/acpi/video.c +1 -1
@@ -366,7 +366,7 @@ static int acpi_video_set_brightness(struct backlight_device *bd) vd->brightness->levels[request_level]); } -static struct backlight_ops acpi_backlight_ops = { +static const struct backlight_ops acpi_backlight_ops = { .get_brightness = acpi_video_get_brightness, .update_status = acpi_video_set_brightness, };
drivers/gpu/drm/nouveau/nouveau_backlight.c +2 -2
@@ -58,7 +58,7 @@ static int nv40_set_intensity(struct backlight_device *bd)return 0 ; } -static struct backlight_ops nv40_bl_ops = { +static const struct backlight_ops nv40_bl_ops = { .options =BL_CORE_SUSPENDRESUME , .get_brightness = nv40_get_intensity, .update_status = nv40_set_intensity,
@@ -81,7 +81,7 @@ static int nv50_set_intensity(struct backlight_device *bd)return 0 ; } -static struct backlight_ops nv50_bl_ops = { +static const struct backlight_ops nv50_bl_ops = { .options =BL_CORE_SUSPENDRESUME , .get_brightness = nv50_get_intensity, .update_status = nv50_set_intensity,
drivers/macintosh/via-pmu-backlight.c +2 -2
@@ -15,7 +15,7 @@#define MAX_PMU_LEVEL 0xFF -static struct backlight_ops pmu_backlight_data; +static const struct backlight_ops pmu_backlight_data;static DEFINE_SPINLOCK (pmu_backlight_lock);static int sleeping, uses_pmu_bl;static u8 bl_curve[FB_BACKLIGHT_LEVELS ];
@@ -115,7 +115,7 @@ static int pmu_backlight_get_brightness(struct backlight_device *bd)return bd->props.brightness; } -static struct backlight_ops pmu_backlight_data = { +static const struct backlight_ops pmu_backlight_data = { .get_brightness = pmu_backlight_get_brightness, .update_status = pmu_backlight_update_status,
drivers/platform/x86/acer-wmi.c +1 -1
@@ -915,7 +915,7 @@ static int update_bl_status(struct backlight_device *bd)return 0 ; } -static struct backlight_ops acer_bl_ops = { +static const struct backlight_ops acer_bl_ops = { .get_brightness = read_brightness, .update_status = update_bl_status, };
drivers/platform/x86/asus-laptop.c +1 -1
@@ -251,7 +251,7 @@ static struct backlight_device *asus_backlight_device;*/ static int read_brightness (struct backlight_device *bd);static int update_bl_status (struct backlight_device *bd); -static struct backlight_ops asusbl_ops = { +static const struct backlight_ops asusbl_ops = { .get_brightness = read_brightness, .update_status = update_bl_status, };
drivers/platform/x86/asus_acpi.c +1 -1
@@ -1464,7 +1464,7 @@ static int asus_hotk_remove(struct acpi_device *device, int type)return 0 ; } -static struct backlight_ops asus_backlight_data = { +static const struct backlight_ops asus_backlight_data = { .get_brightness = read_brightness, .update_status = set_brightness_status, };
drivers/platform/x86/compal-laptop.c +1 -1
@@ -162,7 +162,7 @@ static int bl_update_status(struct backlight_device *b)return set_lcd_level (b->props.brightness); } -static struct backlight_ops compalbl_ops = { +static const struct backlight_ops compalbl_ops = { .get_brightness = bl_get_brightness, .update_status = bl_update_status, };
drivers/platform/x86/dell-laptop.c +1 -1
@@ -333,7 +333,7 @@ static int dell_get_intensity(struct backlight_device *bd)return buffer.output[1 ]; } -static struct backlight_ops dell_ops = { +static const struct backlight_ops dell_ops = { .get_brightness = dell_get_intensity, .update_status = dell_send_intensity, };
drivers/platform/x86/eeepc-laptop.c +1 -1
@@ -1096,7 +1096,7 @@ static int update_bl_status(struct backlight_device *bd)return set_brightness (bd, bd->props.brightness); } -static struct backlight_ops eeepcbl_ops = { +static const struct backlight_ops eeepcbl_ops = { .get_brightness = read_brightness, .update_status = update_bl_status, };
drivers/platform/x86/fujitsu-laptop.c +1 -1
@@ -436,7 +436,7 @@ static int bl_update_status(struct backlight_device *b)return ret; } -static struct backlight_ops fujitsubl_ops = { +static const struct backlight_ops fujitsubl_ops = { .get_brightness = bl_get_brightness, .update_status = bl_update_status, };
drivers/platform/x86/sony-laptop.c +1 -1
@@ -853,7 +853,7 @@ static int sony_backlight_get_brightness(struct backlight_device *bd) }static struct backlight_device *sony_backlight_device; -static struct backlight_ops sony_backlight_ops = { +static const struct backlight_ops sony_backlight_ops = { .update_status = sony_backlight_update_status, .get_brightness = sony_backlight_get_brightness, };
drivers/platform/x86/thinkpad_acpi.c +1 -1
@@ -6112,7 +6112,7 @@ static void tpacpi_brightness_notify_change(void) BACKLIGHT_UPDATE_HOTKEY); } -static struct backlight_ops ibm_backlight_data = { +static const struct backlight_ops ibm_backlight_data = { .get_brightness = brightness_get, .update_status = brightness_update_status, };
drivers/platform/x86/toshiba_acpi.c +1 -1
@@ -706,7 +706,7 @@ static acpi_status remove_device(void)return AE_OK ; } -static struct backlight_ops toshiba_backlight_data = { +static const struct backlight_ops toshiba_backlight_data = { .get_brightness = get_lcd, .update_status = set_lcd_status, };
drivers/staging/samsung-laptop/samsung-laptop.c +1 -1
@@ -268,7 +268,7 @@ static int update_status(struct backlight_device *bd)return 0 ; } -static struct backlight_ops backlight_ops = { +static const struct backlight_ops backlight_ops = { .get_brightness = get_brightness, .update_status = update_status, };
drivers/video/atmel_lcdfb.c +1 -1
@@ -110,7 +110,7 @@ static int atmel_bl_get_brightness(struct backlight_device *bl)return lcdc_readl (sinfo,ATMEL_LCDC_CONTRAST_VAL ); } -static struct backlight_ops atmel_lcdc_bl_ops = { +static const struct backlight_ops atmel_lcdc_bl_ops = { .update_status = atmel_bl_update_status, .get_brightness = atmel_bl_get_brightness, };
drivers/video/aty/aty128fb.c +1 -1
@@ -1787,7 +1787,7 @@ static int aty128_bl_get_brightness(struct backlight_device *bd)return bd->props.brightness; } -static struct backlight_ops aty128_bl_data = { +static const struct backlight_ops aty128_bl_data = { .get_brightness = aty128_bl_get_brightness, .update_status = aty128_bl_update_status, };
drivers/video/aty/atyfb_base.c +1 -1
@@ -2225,7 +2225,7 @@ static int aty_bl_get_brightness(struct backlight_device *bd)return bd->props.brightness; } -static struct backlight_ops aty_bl_data = { +static const struct backlight_ops aty_bl_data = { .get_brightness = aty_bl_get_brightness, .update_status = aty_bl_update_status, };
drivers/video/aty/radeon_backlight.c +1 -1
@@ -127,7 +127,7 @@ static int radeon_bl_get_brightness(struct backlight_device *bd)return bd->props.brightness; } -static struct backlight_ops radeon_bl_data = { +static const struct backlight_ops radeon_bl_data = { .get_brightness = radeon_bl_get_brightness, .update_status = radeon_bl_update_status, };
drivers/video/nvidia/nv_backlight.c +1 -1
@@ -87,7 +87,7 @@ static int nvidia_bl_get_brightness(struct backlight_device *bd)return bd->props.brightness; } -static struct backlight_ops nvidia_bl_ops = { +static const struct backlight_ops nvidia_bl_ops = { .get_brightness = nvidia_bl_get_brightness, .update_status = nvidia_bl_update_status, };
drivers/video/omap2/displays/panel-taal.c +1 -1
@@ -313,7 +313,7 @@ static int taal_bl_get_intensity(struct backlight_device *dev)return 0 ; } -static struct backlight_ops taal_bl_ops = { +static const struct backlight_ops taal_bl_ops = { .get_brightness = taal_bl_get_intensity, .update_status = taal_bl_update_status, };
drivers/video/riva/fbdev.c +1 -1
@@ -331,7 +331,7 @@ static int riva_bl_get_brightness(struct backlight_device *bd)return bd->props.brightness; } -static struct backlight_ops riva_bl_ops = { +static const struct backlight_ops riva_bl_ops = { .get_brightness = riva_bl_get_brightness, .update_status = riva_bl_update_status, };
Signature · 1 line
1.6.4.4
Bruno Prémont
maintainerPATCH 3/3 backlight: fix missing/incomplete registration failure handling
In reply to Bruno PrémontCheck newly registered backlight_device for error and properly return error to parent
--- drivers/platform/x86/classmate-laptop.c | 2 ++ drivers/platform/x86/msi-wmi.c | 4 +++- drivers/platform/x86/panasonic-laptop.c | 4 +++- drivers/usb/misc/appledisplay.c | 1 + drivers/video/bf54x-lq043fb.c | 8 ++++++++ drivers/video/bfin-t350mcqb-fb.c | 8 ++++++++ 6 files changed, 25 insertions(+), 2 deletions(-)
drivers/platform/x86/classmate-laptop.c +2 -0
@@ -463,6 +463,8 @@ static int cmpc_bl_add(struct acpi_device *acpi) bd =backlight_device_register ("cmpc_bl" , &acpi->dev, acpi->handle, &cmpc_bl_ops); +if (IS_ERR (bd)) +return PTR_ERR (bd); bd->props.max_brightness =7 ;dev_set_drvdata (&acpi->dev, bd);return 0 ;
drivers/platform/x86/msi-wmi.c +3 -1
@@ -251,8 +251,10 @@ static int __init msi_wmi_init(void)if (!acpi_video_backlight_support ()) { backlight =backlight_device_register (DRV_NAME ,NULL ,NULL , &msi_backlight_ops); -if (IS_ERR (backlight)) +if (IS_ERR (backlight)) { + err =PTR_ERR (backlight); goto err_free_input; + } backlight->props.max_brightness =ARRAY_SIZE (backlight_map) -1 ; err =bl_get (NULL );
drivers/platform/x86/panasonic-laptop.c +3 -1
@@ -644,8 +644,10 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)/* initialize backlight */ pcc->backlight =backlight_device_register ("panasonic" ,NULL , pcc, &pcc_backlight_ops); -if (IS_ERR (pcc->backlight)) +if (IS_ERR (pcc->backlight)) { + result =PTR_ERR (pcc->backlight); goto out_input; + }if (!acpi_pcc_retrieve_biosdata (pcc, pcc->sinf)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
drivers/usb/misc/appledisplay.c +1 -0
@@ -283,6 +283,7 @@ static int appledisplay_probe(struct usb_interface *iface, &appledisplay_bl_data);if (IS_ERR (pdata->bd)) {dev_err (&iface->dev,"Backlight registration failed\n" ); + retval =PTR_ERR (pdata->bd); goto error; }
drivers/video/bf54x-lq043fb.c +8 -0
@@ -678,6 +678,12 @@ static int __devinit bfin_bf54x_probe(struct platform_device *pdev) bl_dev backlight_device_register("bf54x-bl", NULL, NULL, &bfin_lq043fb_bl_ops); +if (IS_ERR (bl_dev)) { + printk(KERN_ERR DRIVER_NAME + ": unable to register backlight.\n"); + ret = -EINVAL ; + goto out9; + } bl_dev->props.max_brightness =255 ; lcd_dev =lcd_device_register (DRIVER_NAME , &pdev->dev,NULL , &bfin_lcd_ops);
@@ -686,6 +692,8 @@ static int __devinit bfin_bf54x_probe(struct platform_device *pdev)return 0 ; +out9: +unregister_framebuffer (fbinfo); out8:free_irq (info->irq, info); out7:
drivers/video/bfin-t350mcqb-fb.c +8 -0
@@ -572,6 +572,12 @@ static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev) bl_dev backlight_device_register("bf52x-bl", NULL, NULL, &bfin_lq043fb_bl_ops); +if (IS_ERR (bl_dev)) { + printk(KERN_ERR DRIVER_NAME + ": unable to register backlight.\n"); + ret = -EINVAL ; + goto out9; + } bl_dev->props.max_brightness =255 ; lcd_dev =lcd_device_register (DRIVER_NAME ,NULL , &bfin_lcd_ops);
@@ -580,6 +586,8 @@ static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev)return 0 ; +out9: +unregister_framebuffer (fbinfo); out8:free_irq (info->irq, info); out7:
Signature · 1 line
1.6.4.4
Re: [PATCH 3/3] backlight: fix missing/incomplete registration failure handling
Quoted 4 lines · Bruno Prémont
Check newly registered
backlight_devicefor error and properly return error to parentSigned-off-by Bruno Prémont <[email protected]>
(for panasonic-laptop.c)
Signature · 4 lines
- Harald Welte <[email protected]> http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6)
Thadeu Lima de Souza Cascardo
maintainerRe: [PATCH 3/3] backlight: fix missing/incomplete registration failure handling
In reply to Bruno PrémontQuoted 4 lines · Bruno Prémont
Check newly registered
backlight_devicefor error and properly return error to parentSigned-off-by Bruno Prémont <[email protected]>
Quoted 9 lines
--- drivers/platform/x86/classmate-laptop.c | 2 ++ drivers/platform/x86/msi-wmi.c | 4 +++- drivers/platform/x86/panasonic-laptop.c | 4 +++- drivers/usb/misc/appledisplay.c | 1 + drivers/video/bf54x-lq043fb.c | 8 ++++++++ drivers/video/bfin-t350mcqb-fb.c | 8 ++++++++ 6 files changed, 25 insertions(+), 2 deletions(-)
I think you should split the patch for every driver. Then, every mantainer may ack only its particular section of the patch.
Quoted 112 lines
drivers/platform/x86/classmate-laptop.c +2
-0@@ -463,6 +463,8 @@ static int cmpc_bl_add(struct acpi_device *acpi) bd =backlight_device_register ("cmpc_bl" , &acpi->dev, acpi->handle, &cmpc_bl_ops); +if (IS_ERR (bd)) +return PTR_ERR (bd); bd->props.max_brightness =7 ;dev_set_drvdata (&acpi->dev, bd);return 0 ;drivers/platform/x86/msi-wmi.c +3
-1@@ -251,8 +251,10 @@ static int __init msi_wmi_init(void)if (!acpi_video_backlight_support ()) { backlight =backlight_device_register (DRV_NAME ,NULL ,NULL , &msi_backlight_ops); -if (IS_ERR (backlight)) +if (IS_ERR (backlight)) { + err =PTR_ERR (backlight); goto err_free_input; + } backlight->props.max_brightness =ARRAY_SIZE (backlight_map) -1 ; err =bl_get (NULL );drivers/platform/x86/panasonic-laptop.c +3
-1@@ -644,8 +644,10 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)/* initialize backlight */ pcc->backlight =backlight_device_register ("panasonic" ,NULL , pcc, &pcc_backlight_ops); -if (IS_ERR (pcc->backlight)) +if (IS_ERR (pcc->backlight)) { + result =PTR_ERR (pcc->backlight); goto out_input; + }if (!acpi_pcc_retrieve_biosdata (pcc, pcc->sinf)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR,drivers/usb/misc/appledisplay.c +1
-0@@ -283,6 +283,7 @@ static int appledisplay_probe(struct usb_interface *iface, &appledisplay_bl_data);if (IS_ERR (pdata->bd)) {dev_err (&iface->dev,"Backlight registration failed\n" ); + retval =PTR_ERR (pdata->bd); goto error; }drivers/video/bf54x-lq043fb.c +8
-0@@ -678,6 +678,12 @@ static int __devinit bfin_bf54x_probe(struct platform_device *pdev) bl_dev =backlight_device_register ("bf54x-bl" ,NULL ,NULL , &bfin_lq043fb_bl_ops); +if (IS_ERR (bl_dev)) { + printk(KERN_ERR DRIVER_NAME + ": unable to register backlight.\n"); + ret = -EINVAL ; + goto out9; + } bl_dev->props.max_brightness =255 ; lcd_dev =lcd_device_register (DRIVER_NAME , &pdev->dev,NULL , &bfin_lcd_ops);@@ -686,6 +692,8 @@ static int __devinit bfin_bf54x_probe(struct platform_device *pdev)return 0 ; +out9: +unregister_framebuffer (fbinfo); out8:free_irq (info->irq, info); out7:drivers/video/bfin-t350mcqb-fb.c +8
-0@@ -572,6 +572,12 @@ static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev) bl_dev =backlight_device_register ("bf52x-bl" ,NULL ,NULL , &bfin_lq043fb_bl_ops); +if (IS_ERR (bl_dev)) { + printk(KERN_ERR DRIVER_NAME + ": unable to register backlight.\n"); + ret = -EINVAL ; + goto out9; + } bl_dev->props.max_brightness =255 ; lcd_dev =lcd_device_register (DRIVER_NAME ,NULL , &bfin_lcd_ops);@@ -580,6 +586,8 @@ static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev)return 0 ; +out9: +unregister_framebuffer (fbinfo); out8:free_irq (info->irq, info); out7:Signature · 1 line
1.6.4.4
Re: [PATCH 3/3] backlight: fix missing/incomplete registration failure handling
Quoted 15 lines · Thadeu Lima de Souza Cascardo
Quoted 4 lines · Bruno Prémont
Check newly registered
backlight_devicefor error and properly return error to parentSigned-off-by Bruno Prémont <[email protected]>Quoted 9 lines
--- drivers/platform/x86/classmate-laptop.c | 2 ++ drivers/platform/x86/msi-wmi.c | 4 +++- drivers/platform/x86/panasonic-laptop.c | 4 +++- drivers/usb/misc/appledisplay.c | 1 + drivers/video/bf54x-lq043fb.c | 8 ++++++++ drivers/video/bfin-t350mcqb-fb.c | 8 ++++++++ 6 files changed, 25 insertions(+), 2 deletions(-)
Quoted 3 lines
I think you should split the patch for every driver. Then, every mantainer may ack only its particular section of the patch.
I agree.
Quoted 14 lines
Quoted 14 lines
drivers/platform/x86/msi-wmi.c +3
-1@@ -251,8 +251,10 @@ static int __init msi_wmi_init(void)if (!acpi_video_backlight_support ()) { backlight =backlight_device_register (DRV_NAME ,NULL ,NULL , &msi_backlight_ops); -if (IS_ERR (backlight)) +if (IS_ERR (backlight)) { + err =PTR_ERR (backlight); goto err_free_input; + }
Quoted 2 lines
drivers/platform/x86/msi-wmi.c static int __init msi_wmi_init(void) · line 260
Quoted 2 lines
drivers/platform/x86/msi-wmi.c +0
-0backlight->props.max_brightness =ARRAY_SIZE (backlight_map) -1 ; err =bl_get (NULL );
Anyway, the msi-wmi part looks good to me.
Anisse
Bruno Prémont
maintainerPATCH 1/1 backlight, blackfin: fix missing registration failure handling
In reply to Bruno PrémontCheck newly registered backlight_device for error and properly return error to parent
Mark struct backlight_ops as const.
--- drivers/video/bf54x-lq043fb.c | 10 +++++++++- drivers/video/bfin-t350mcqb-fb.c | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-)
drivers/video/bf54x-lq043fb.c +9 -1
@@ -463,7 +463,7 @@ static int bl_get_brightness(struct backlight_device *bd)return 0 ; } -static struct backlight_ops bfin_lq043fb_bl_ops = { +static const struct backlight_ops bfin_lq043fb_bl_ops = { .get_brightness = bl_get_brightness, };
@@ -678,6 +678,12 @@ static int __devinit bfin_bf54x_probe(struct platform_device *pdev) bl_dev backlight_device_register("bf54x-bl", NULL, NULL, &bfin_lq043fb_bl_ops); +if (IS_ERR (bl_dev)) { + printk(KERN_ERR DRIVER_NAME + ": unable to register backlight.\n"); + ret = -EINVAL ; + goto out9; + } bl_dev->props.max_brightness =255 ; lcd_dev =lcd_device_register (DRIVER_NAME , &pdev->dev,NULL , &bfin_lcd_ops);
@@ -686,6 +692,8 @@ static int __devinit bfin_bf54x_probe(struct platform_device *pdev)return 0 ; +out9: +unregister_framebuffer (fbinfo); out8:free_irq (info->irq, info); out7:
drivers/video/bfin-t350mcqb-fb.c +9 -1
@@ -381,7 +381,7 @@ static int bl_get_brightness(struct backlight_device *bd)return 0 ; } -static struct backlight_ops bfin_lq043fb_bl_ops = { +static const struct backlight_ops bfin_lq043fb_bl_ops = { .get_brightness = bl_get_brightness, };
@@ -572,6 +572,12 @@ static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev) bl_dev backlight_device_register("bf52x-bl", NULL, NULL, &bfin_lq043fb_bl_ops); +if (IS_ERR (bl_dev)) { + printk(KERN_ERR DRIVER_NAME + ": unable to register backlight.\n"); + ret = -EINVAL ; + goto out9; + } bl_dev->props.max_brightness =255 ; lcd_dev =lcd_device_register (DRIVER_NAME ,NULL , &bfin_lcd_ops);
@@ -580,6 +586,8 @@ static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev)return 0 ; +out9: +unregister_framebuffer (fbinfo); out8:free_irq (info->irq, info); out7:
Signature · 1 line
1.6.4.4
Bruno Prémont
maintainerPATCH 1/1 backlight, msi-laptop, msi-wmi: fix incomplete registration failure handling
In reply to Bruno PrémontProperly return backlight registration error to parent. Mark struct backlight_ops as const.
--- drivers/platform/x86/msi-laptop.c | 2 +- drivers/platform/x86/msi-wmi.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/platform/x86/msi-laptop.c +1 -1
@@ -161,7 +161,7 @@ static int bl_update_status(struct backlight_device *b)return set_lcd_level (b->props.brightness); } -static struct backlight_ops msibl_ops = { +static const struct backlight_ops msibl_ops = { .get_brightness = bl_get_brightness, .update_status = bl_update_status, };
drivers/platform/x86/msi-wmi.c +4 -2
@@ -138,7 +138,7 @@ static int bl_set_status(struct backlight_device *bd)return msi_wmi_set_block (0 , backlight_map[bright]); } -static struct backlight_ops msi_backlight_ops = { +static const struct backlight_ops msi_backlight_ops = { .get_brightness = bl_get, .update_status = bl_set_status, };
@@ -251,8 +251,10 @@ static int __init msi_wmi_init(void)if (!acpi_video_backlight_support ()) { backlight =backlight_device_register (DRV_NAME ,NULL ,NULL , &msi_backlight_ops); -if (IS_ERR (backlight)) +if (IS_ERR (backlight)) { + err =PTR_ERR (backlight); goto err_free_input; + } backlight->props.max_brightness =ARRAY_SIZE (backlight_map) -1 ; err =bl_get (NULL );
Signature · 1 line
1.6.4.4
Bruno Prémont
maintainerPATCH 1/1 backlight, panasonic-laptop: fix incomplete registration failure handling
In reply to Bruno PrémontProperly return backlight registration error to parent. Mark struct backlight_ops as const.
--- drivers/platform/x86/panasonic-laptop.c | 4 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/platform/x86/panasonic-laptop.c +4 -2
@@ -352,7 +352,7 @@ static int bl_set_status(struct backlight_device *bd)return acpi_pcc_write_sset (pcc,SINF_DC_CUR_BRIGHT , bright); } -static struct backlight_ops pcc_backlight_ops = { +static const struct backlight_ops pcc_backlight_ops = { .get_brightness = bl_get, .update_status = bl_set_status, };
@@ -644,8 +644,10 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)/* initialize backlight */ pcc->backlight =backlight_device_register ("panasonic" ,NULL , pcc, &pcc_backlight_ops); -if (IS_ERR (pcc->backlight)) +if (IS_ERR (pcc->backlight)) { + result =PTR_ERR (pcc->backlight); goto out_input; + }if (!acpi_pcc_retrieve_biosdata (pcc, pcc->sinf)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
Signature · 1 line
1.6.4.4
Bruno Prémont
maintainerPATCH 1/1 backlight, appledisplay: fix incomplete registration failure handling
In reply to Bruno PrémontOn error while registering backlight, return it to caller instead of returning 0.
Mark struct backlight_ops as const.
--- drivers/usb/misc/appledisplay.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/usb/misc/appledisplay.c +2 -1
@@ -179,7 +179,7 @@ static int appledisplay_bl_get_brightness(struct backlight_device *bd)return pdata->msgdata[1 ]; } -static struct backlight_ops appledisplay_bl_data = { +static const struct backlight_ops appledisplay_bl_data = { .get_brightness = appledisplay_bl_get_brightness, .update_status = appledisplay_bl_update_status, };
@@ -283,6 +283,7 @@ static int appledisplay_probe(struct usb_interface *iface, &appledisplay_bl_data);if (IS_ERR (pdata->bd)) {dev_err (&iface->dev,"Backlight registration failed\n" ); + retval =PTR_ERR (pdata->bd); goto error; }
Signature · 1 line
1.6.4.4
Bruno Prémont
maintainerPATCH 1/1 backlight, classmate-laptop: fix missing registration failure handling
In reply to Bruno PrémontCheck newly registered backlight_device for error and properly return error to parent.
Mark struct backlight_ops as const.
--- drivers/platform/x86/classmate-laptop.c | 2 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/platform/x86/classmate-laptop.c +3 -1
@@ -452,7 +452,7 @@ static int cmpc_bl_update_status(struct backlight_device *bd)return -1 ; } -static struct backlight_ops cmpc_bl_ops = { +static const struct backlight_ops cmpc_bl_ops = { .get_brightness = cmpc_bl_get_brightness, .update_status = cmpc_bl_update_status };
@@ -463,6 +463,8 @@ static int cmpc_bl_add(struct acpi_device *acpi) bd =backlight_device_register ("cmpc_bl" , &acpi->dev, acpi->handle, &cmpc_bl_ops); +if (IS_ERR (bd)) +return PTR_ERR (bd); bd->props.max_brightness =7 ;dev_set_drvdata (&acpi->dev, bd);return 0 ;
Signature · 1 line
1.6.4.4
Re: [PATCH] backlight, classmate-laptop: fix missing registration failure handling
Mathew,
Please apply the following patch.
Quoted 34 lines · Bruno Prémont
Check newly registered
backlight_devicefor error and properly return error to parent.
Mark structbacklight_opsas const.Signed-off-by Bruno Prémont <[email protected]>--- drivers/platform/x86/classmate-laptop.c | 2 +++- 1 files changed, 3 insertions(+), 1 deletions(-)drivers/platform/x86/classmate-laptop.c +3
-1@@ -452,7 +452,7 @@ static int cmpc_bl_update_status(struct backlight_device *bd)return -1 ; } -static struct backlight_ops cmpc_bl_ops = { +static const struct backlight_ops cmpc_bl_ops = { .get_brightness = cmpc_bl_get_brightness, .update_status = cmpc_bl_update_status };@@ -463,6 +463,8 @@ static int cmpc_bl_add(struct acpi_device *acpi) bd =backlight_device_register ("cmpc_bl" , &acpi->dev, acpi->handle, &cmpc_bl_ops); +if (IS_ERR (bd)) +return PTR_ERR (bd); bd->props.max_brightness =7 ;dev_set_drvdata (&acpi->dev, bd);return 0 ;Signature · 1 line
1.6.4.4
Re: [PATCH] backlight, classmate-laptop: fix missing registration failure handling
If Richard applies my patch to rework backlight registration, this won't apply. Richard, what's the situation there?
Signature · 1 line
Matthew Garrett | [email protected]
Re: [PATCH] backlight, classmate-laptop: fix missing registration failure handling
Quoted 2 lines · Matthew Garrett
If Richard applies my patch to rework backlight registration, this won't apply. Richard, what's the situation there?
Your patch has priority, publishing new patches at this point in time is getting a bit late.
Cheers,
Richard
Bruno Prémont
maintainerRe: [PATCH] backlight, classmate-laptop: fix missing registration failure handling
Hi Richard,
Quoted 6 lines · On Fri, 26 February 2010 Richard Purdie <[email protected]> wrote:
Quoted 2 lines · Matthew Garrett
If Richard applies my patch to rework backlight registration, this won't apply. Richard, what's the situation there?
Your patch has priority, publishing new patches at this point in time is getting a bit late.
I've been resending them, though I got no feedback from you on first submission about a week ago. (on any of the backlight patches, so I'm wondering if they reached you at all...)
Regards,
Bruno