* [PATCH, RFC] ARM: OMAP: Convert gpio-switch to platform_driver
@ 2006-11-06 1:33 andrzej zaborowski
2006-11-09 23:29 ` Tony Lindgren
0 siblings, 1 reply; 2+ messages in thread
From: andrzej zaborowski @ 2006-11-06 1:33 UTC (permalink / raw)
To: Linux-OMAP
[-- Attachment #1: Type: text/plain, Size: 1061 bytes --]
[I'm not very sure about this, but shouldn't the driver be a platform
driver if its parent bus is the platform bus? It's especially annoying
on resuming from sleep because the driver structure is passed to
platform_resume_early() where it is casted to struct platform_device
and .resume_early returns a bogus value. The kernel Oops'es but since
the LCD is not yet resumed the device looks like dead and it's hard to
track down.]
Converts the gpio-switch driver to platform_driver to avoid bad cast
which occurs because the bus type is set to platform bus. Also
silences the following warnings:
arch/arm/plat-omap/gpio-switch.c:292: warning: ignoring return value
of 'device_create_file', declared with attribute warn_unused_result
arch/arm/plat-omap/gpio-switch.c:293: warning: ignoring return value
of 'device_create_file', declared with attribute warn_unused_result
arch/arm/plat-omap/gpio-switch.c:294: warning: ignoring return value
of 'device_create_file', declared with attribute warn_unused_result
Signed-off-by: Andrzej Zaborowski <balrog@zabor.org>
[-- Attachment #2: omap-gpiosw-platform.patch --]
[-- Type: application/octet-stream, Size: 2641 bytes --]
diff --git a/arch/arm/plat-omap/gpio-switch.c b/arch/arm/plat-omap/gpio-switch.c
index f2e09e2..7cf47cc 100644
--- a/arch/arm/plat-omap/gpio-switch.c
+++ b/arch/arm/plat-omap/gpio-switch.c
@@ -49,7 +49,7 @@ struct gpio_switch {
static LIST_HEAD(gpio_switches);
static struct platform_device *gpio_sw_platform_dev;
-static struct device_driver gpio_sw_driver;
+static struct platform_driver gpio_sw_driver;
static const struct omap_gpio_switch *board_gpio_sw_table;
static int board_gpio_sw_count;
@@ -266,7 +266,7 @@ static int __init new_switch(struct gpio
sw->pdev.id = -1;
sw->pdev.dev.parent = &gpio_sw_platform_dev->dev;
- sw->pdev.dev.driver = &gpio_sw_driver;
+ sw->pdev.dev.driver = &gpio_sw_driver.driver;
sw->pdev.dev.release = gpio_sw_release;
r = platform_device_register(&sw->pdev);
@@ -289,9 +289,13 @@ static int __init new_switch(struct gpio
sw->state = gpio_sw_get_state(sw);
- device_create_file(&sw->pdev.dev, &dev_attr_state);
- device_create_file(&sw->pdev.dev, &dev_attr_type);
- device_create_file(&sw->pdev.dev, &dev_attr_direction);
+ r = 0;
+ r |= device_create_file(&sw->pdev.dev, &dev_attr_state);
+ r |= device_create_file(&sw->pdev.dev, &dev_attr_type);
+ r |= device_create_file(&sw->pdev.dev, &dev_attr_direction);
+ if (r)
+ printk(KERN_ERR "gpio-switch: attribute file creation "
+ "failed for %s\n", sw->name);
if (!direction)
return 0;
@@ -469,14 +473,16 @@ static void __init report_initial_state(
}
}
-static void gpio_sw_shutdown(struct device *dev)
+static int gpio_sw_remove(struct platform_device *dev)
{
+ return 0;
}
-static struct device_driver gpio_sw_driver = {
- .name = "gpio-switch",
- .bus = &platform_bus_type,
- .shutdown = gpio_sw_shutdown,
+static struct platform_driver gpio_sw_driver = {
+ .remove = gpio_sw_remove,
+ .driver = {
+ .name = "gpio-switch",
+ },
};
void __init omap_register_gpio_switches(const struct omap_gpio_switch *tbl,
@@ -494,7 +500,7 @@ static int __init gpio_sw_init(void)
printk(KERN_INFO "OMAP GPIO switch handler initializing\n");
- r = driver_register(&gpio_sw_driver);
+ r = platform_driver_register(&gpio_sw_driver);
if (r)
return r;
@@ -520,7 +526,7 @@ err2:
gpio_sw_cleanup();
platform_device_unregister(gpio_sw_platform_dev);
err1:
- driver_unregister(&gpio_sw_driver);
+ platform_driver_unregister(&gpio_sw_driver);
return r;
}
@@ -528,7 +534,7 @@ static void __exit gpio_sw_exit(void)
{
gpio_sw_cleanup();
platform_device_unregister(gpio_sw_platform_dev);
- driver_unregister(&gpio_sw_driver);
+ platform_driver_unregister(&gpio_sw_driver);
}
#ifndef MODULE
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH, RFC] ARM: OMAP: Convert gpio-switch to platform_driver
2006-11-06 1:33 [PATCH, RFC] ARM: OMAP: Convert gpio-switch to platform_driver andrzej zaborowski
@ 2006-11-09 23:29 ` Tony Lindgren
0 siblings, 0 replies; 2+ messages in thread
From: Tony Lindgren @ 2006-11-09 23:29 UTC (permalink / raw)
To: balrogg; +Cc: Linux-OMAP
* andrzej zaborowski <balrog@zabor.org> [061106 03:42]:
> [I'm not very sure about this, but shouldn't the driver be a platform
> driver if its parent bus is the platform bus? It's especially annoying
> on resuming from sleep because the driver structure is passed to
> platform_resume_early() where it is casted to struct platform_device
> and .resume_early returns a bogus value. The kernel Oops'es but since
> the LCD is not yet resumed the device looks like dead and it's hard to
> track down.]
>
> Converts the gpio-switch driver to platform_driver to avoid bad cast
> which occurs because the bus type is set to platform bus. Also
> silences the following warnings:
>
> arch/arm/plat-omap/gpio-switch.c:292: warning: ignoring return value
> of 'device_create_file', declared with attribute warn_unused_result
> arch/arm/plat-omap/gpio-switch.c:293: warning: ignoring return value
> of 'device_create_file', declared with attribute warn_unused_result
> arch/arm/plat-omap/gpio-switch.c:294: warning: ignoring return value
> of 'device_create_file', declared with attribute warn_unused_result
Sounds like this code had missed the platform device conversion earlier.
Pushing today.
Tony
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-11-09 23:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-06 1:33 [PATCH, RFC] ARM: OMAP: Convert gpio-switch to platform_driver andrzej zaborowski
2006-11-09 23:29 ` Tony Lindgren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox