cbus patches
cover cbus patches
Hi all,
if you have n8x0/n770 board getting dust, please spend some minutes to boot test the following patches on that. After you do so, please reply with your Tested-by tag.
I'm also adding to this series Jarkko Nikula's ioctl fix since l-o doesn't compile without that.
Felipe Balbi (7):
cbus: remove device_release completion
cbus: retu: pass irq number via struct resource
cbus: retu: avoid section mismatch
cbus: tahvo: usb: convert to platform_driver
cbus: tahvo: remove device_release
cbus: tahvo: pass irq via struct resource
cbus: tahvo: avoid section mismatch
Jarkko Nikula (1):
cbus: Fix compile by converting ioctl calls to unlocked_ioctl calls
drivers/cbus/retu-headset.c | 3 +- drivers/cbus/retu-pwrbutton.c | 9 +-- drivers/cbus/retu-rtc.c | 7 +- drivers/cbus/retu-user.c | 5 +- drivers/cbus/retu-wdt.c | 13 ++-- drivers/cbus/retu.c | 123 ++++++++++++++++++++++------------------- drivers/cbus/tahvo-usb.c | 49 ++++++++-------- drivers/cbus/tahvo-user.c | 5 +- drivers/cbus/tahvo.c | 116 +++++++++++++++++++++------------------ 9 files changed, 172 insertions(+), 158 deletions(-)
Signature · 1 line
1.7.3.rc0.35.g8ac8c
PATCH 1/8 cbus: Fix compile by converting ioctl calls to unlocked_ioctl calls
From: Jarkko Nikula <[email protected]>
Locked .ioctl is gone from struct file_operations by commit b19dd42 so these cbus drivers don't compile. Also it seems there is no need for BKL anyway in these drivers.
--- drivers/cbus/retu-user.c | 5 ++--- drivers/cbus/retu-wdt.c | 6 +++--- drivers/cbus/tahvo-user.c | 5 ++--- 3 files changed, 7 insertions(+), 9 deletions(-)
drivers/cbus/retu-user.c +2 -3
@@ -270,8 +270,7 @@ static int retu_close(struct inode *inode, struct file *filp)/* * Device control (ioctl) */ -static int retu_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg) +static long retu_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {struct retu_tahvo_write_parms par;int ret;
@@ -360,7 +359,7 @@ static unsigned retu_poll(struct file *filp, struct poll_table_struct *pt)static struct file_operations retu_user_fileops = { .owner =THIS_MODULE , - .ioctl = retu_ioctl, + .unlocked_ioctl = retu_ioctl, .read = retu_read, .release = retu_close, .poll = retu_poll
drivers/cbus/retu-wdt.c +3 -3
@@ -184,8 +184,8 @@ static ssize_t retu_wdt_write(struct file *file, const char __user *data,return len; } -static int retu_wdt_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long retu_wdt_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) {int new_margin;
@@ -246,7 +246,7 @@ static int __devinit retu_wdt_ping(void)static const struct file_operations retu_wdt_fops = { .owner =THIS_MODULE , .write = retu_wdt_write, - .ioctl = retu_wdt_ioctl, + .unlocked_ioctl = retu_wdt_ioctl, .open = retu_wdt_open, .release = retu_wdt_release, };
drivers/cbus/tahvo-user.c +2 -3
@@ -254,8 +254,7 @@ static int tahvo_close(struct inode *inode, struct file *filp)/* * Device control (ioctl) */ -static int tahvo_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg) +static long tahvo_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {struct retu_tahvo_write_parms par;int ret;
@@ -342,7 +341,7 @@ static unsigned tahvo_poll(struct file *filp, struct poll_table_struct *pt)static struct file_operations tahvo_user_fileops = { .owner =THIS_MODULE , - .ioctl = tahvo_ioctl, + .unlocked_ioctl = tahvo_ioctl, .read = tahvo_read, .release = tahvo_close, .poll = tahvo_poll
Signature · 1 line
1.7.3.rc0.35.g8ac8c
PATCH 2/8 cbus: remove device_release completion
In reply to Felipe BalbiWe don't do anything before releasing the device
so we might as well return as soon as possible.
--- drivers/cbus/retu.c | 13 ------------- 1 files changed, 0 insertions(+), 13 deletions(-)
drivers/cbus/retu.c +0 -13
@@ -56,8 +56,6 @@ static int retu_is_vilma;static struct tasklet_struct retu_tasklet;spinlock_t retu_lock =SPIN_LOCK_UNLOCKED ; -static struct completion device_release; -struct retu_irq_handler_desc {int (*func)(unsigned long );unsigned long arg;
@@ -491,11 +489,6 @@ static int __devexit retu_remove(struct platform_device *pdev)return 0 ; } -static void retu_device_release (struct device *dev) -{ -complete (&device_release); -} -static struct platform_driver retu_driver = { .probe = retu_probe, .remove =__devexit_p (retu_remove),
@@ -507,9 +500,6 @@ static struct platform_driver retu_driver = {static struct platform_device retu_device = { .name ="retu" , .id =-1 , - .dev = { - .release = retu_device_release, - } };/**
@@ -525,8 +515,6 @@ static int __init retu_init(void) machine_is_nokia_n810() || machine_is_nokia_n810_wimax()))return -ENODEV ; -init_completion (&device_release); - ret =platform_driver_register (&retu_driver);if (ret <0 )return ret;
@@ -547,7 +535,6 @@ static void __exit retu_exit(void) {platform_device_unregister (&retu_device);platform_driver_unregister (&retu_driver); -wait_for_completion (&device_release); }subsys_initcall (retu_init);
Signature · 1 line
1.7.3.rc0.35.g8ac8c
PATCH 3/8 cbus: retu: pass irq number via struct resource
In reply to Felipe Balbithis patch prepares retu to be able to create and
register the platform_device on board files. IRQ
number is now being passed via struct resource as
it should be.
--- drivers/cbus/retu.c | 103 +++++++++++++++++++++++++++++++------------------- 1 files changed, 64 insertions(+), 39 deletions(-)
drivers/cbus/retu.c +64 -39
@@ -398,32 +398,12 @@ static int retu_allocate_children(struct device *parent)static int __devinit retu_probe (struct platform_device *pdev) {int rev, ret; +int irq;/* Prepare tasklet */ tasklet_init (&retu_tasklet, retu_tasklet_handler,0 ); -/* REVISIT: Pass these from board-*.c files in platform_data */ -if (machine_is_nokia770 ()) { - retu_irq_pin =62 ; - }else if (machine_is_nokia_n800 () ||machine_is_nokia_n810 () || -machine_is_nokia_n810_wimax ()) { - retu_irq_pin =108 ; - }else { -dev_err (&pdev->dev,"cbus: Unsupported board for tahvo\n" ); -return -ENODEV ; - } - - ret =gpio_request (retu_irq_pin,"RETU irq" ); -if (ret <0 ) { -dev_err (&pdev->dev,"Unable to reserve IRQ GPIO\n" ); -return ret; - } - -/* Set the pin as input */ -gpio_direction_input (retu_irq_pin); - -/* Rising edge triggers the IRQ */ -set_irq_type (gpio_to_irq (retu_irq_pin),IRQ_TYPE_EDGE_RISING ); + irq =platform_get_irq (pdev,0 ); retu_initialized =1 ;
@@ -437,14 +417,14 @@ static int __devinit retu_probe(struct platform_device *pdev)/* Mask all RETU interrupts */ retu_write_reg (RETU_REG_IMR ,0xffff ); - ret =request_irq (gpio_to_irq (retu_irq_pin), retu_irq_handler,0 , + ret =request_irq (irq, retu_irq_handler,0 ,"retu" ,0 );if (ret <0 ) {dev_err (&pdev->dev,"Unable to register IRQ handler\n" ); -gpio_free (retu_irq_pin);return ret; } -set_irq_wake (gpio_to_irq (retu_irq_pin),1 ); + +set_irq_wake (irq,1 );/* Register power off function */ pm_power_off = retu_power_off;
@@ -453,8 +433,7 @@ static int __devinit retu_probe(struct platform_device *pdev)/* Initialize user-space interface */ if (retu_user_init () <0 ) {dev_err (&pdev->dev,"Unable to initialize driver\n" ); -free_irq (gpio_to_irq (retu_irq_pin),0 ); -gpio_free (retu_irq_pin); +free_irq (irq,0 );return ret; }#endif
@@ -466,8 +445,7 @@ static int __devinit retu_probe(struct platform_device *pdev)retu_user_cleanup ();#endif retu_write_reg (RETU_REG_IMR ,0xffff ); -free_irq (gpio_to_irq (retu_irq_pin),0 ); -gpio_free (retu_irq_pin); +free_irq (irq,0 );tasklet_kill (&retu_tasklet);return ret; }
@@ -477,13 +455,16 @@ static int __devinit retu_probe(struct platform_device *pdev) static int __devexit retu_remove(struct platform_device *pdev) { +int irq; + + irq =platform_get_irq (pdev,0 ); +#ifdef CONFIG_CBUS_RETU_USER retu_user_cleanup ();#endif /* Mask all RETU interrupts */ retu_write_reg (RETU_REG_IMR ,0xffff ); -free_irq (gpio_to_irq (retu_irq_pin),0 ); -gpio_free (retu_irq_pin); +free_irq (irq,0 );tasklet_kill (&retu_tasklet);return 0 ;
@@ -497,9 +478,18 @@ static struct platform_driver retu_driver = { }, }; +static struct resource retu_resource[] = { + { + .start = -EINVAL ,/* set later */ + .flags =IORESOURCE_IRQ , + }, +}; +static struct platform_device retu_device = { .name ="retu" , .id =-1 , + .resource = retu_resource, + .num_resources =ARRAY_SIZE (retu_resource), };/**
@@ -511,21 +501,55 @@ static int __init retu_init(void) {int ret =0 ; -if (!(machine_is_nokia770 () ||machine_is_nokia_n800 () || -machine_is_nokia_n810 () ||machine_is_nokia_n810_wimax ())) -return -ENODEV ; +/* REVISIT: Pass these from board-*.c files in platform_data */ +if (machine_is_nokia770 ()) { + retu_irq_pin =62 ; + }else if (machine_is_nokia_n800 () ||machine_is_nokia_n810 () || +machine_is_nokia_n810_wimax ()) { + retu_irq_pin =108 ; + }else { +pr_err ("retu: Unsupported board for retu\n" ); + ret = -ENODEV ; + goto err0; + } + + ret =gpio_request (retu_irq_pin,"RETU irq" ); +if (ret <0 ) { +pr_err ("retu: Unable to reserve IRQ GPIO\n" ); + goto err0; + } + +/* Set the pin as input */ + ret =gpio_direction_input (retu_irq_pin); +if (ret <0 ) { +pr_err ("retu: Unable to change gpio direction\n" ); + goto err1; + } + +/* Rising edge triggers the IRQ */ +set_irq_type (gpio_to_irq (retu_irq_pin),IRQ_TYPE_EDGE_RISING ); + +/* Set up correct gpio number on struct resource */ + retu_resource[0 ].start =gpio_to_irq (retu_irq_pin); ret =platform_driver_register (&retu_driver);if (ret <0 ) -return ret; + goto err1; ret =platform_device_register (&retu_device); -if (ret <0 ) { -platform_driver_unregister (&retu_driver); -return ret; - } +if (ret <0 ) + goto err2;return 0 ; + +err2: +platform_driver_unregister (&retu_driver); + +err1: +gpio_free (retu_irq_pin); + +err0: +return ret; }/*
@@ -535,6 +559,7 @@ static void __exit retu_exit(void) {platform_device_unregister (&retu_device);platform_driver_unregister (&retu_driver); +gpio_free (retu_irq_pin); }subsys_initcall (retu_init);
Signature · 1 line
1.7.3.rc0.35.g8ac8c
PATCH 4/8 cbus: retu: avoid section mismatch
In reply to Felipe Balbi... by removing __init reference from platform_driver structure.
--- drivers/cbus/retu-headset.c | 3 +-- drivers/cbus/retu-pwrbutton.c | 9 ++++----- drivers/cbus/retu-rtc.c | 7 +++---- drivers/cbus/retu-wdt.c | 7 +++---- drivers/cbus/retu.c | 9 ++++----- 5 files changed, 15 insertions(+), 20 deletions(-)
drivers/cbus/retu-headset.c +1 -2
@@ -321,7 +321,6 @@ static int retu_headset_resume(struct platform_device *pdev) }static struct platform_driver retu_headset_driver = { - .probe = retu_headset_probe, .remove = retu_headset_remove, .suspend = retu_headset_suspend, .resume = retu_headset_resume,
@@ -332,7 +331,7 @@ static struct platform_driver retu_headset_driver = {static int __init retu_headset_init (void ) { -return platform_driver_register (&retu_headset_driver); +return platform_driver_probe (&retu_headset_driver, retu_headset_probe); } static void __exit retu_headset_exit(void)
drivers/cbus/retu-pwrbutton.c +4 -5
@@ -85,7 +85,7 @@ static void retubutton_irq(unsigned long arg)* Init function. * Allocates interrupt for power button and registers itself to input layer. */ -static int __devinit retubutton_probe (struct platform_device *pdev) +static int __init retubutton_probe (struct platform_device *pdev) {struct retu_pwrbutton *pwr;int ret =0 ;
@@ -143,7 +143,7 @@ err0:/** * Cleanup function which is called when driver is unloaded */ -static int __devexit retubutton_remove(struct platform_device *pdev) +static int __exit retubutton_remove(struct platform_device *pdev) {struct retu_pwrbutton *pwr =platform_get_drvdata (pdev);
@@ -157,8 +157,7 @@ static int __devexit retubutton_remove(struct platform_device *pdev) }static struct platform_driver retu_pwrbutton_driver = { - .probe = retubutton_probe, - .remove =__devexit_p (retubutton_remove), + .remove =__exit_p (retubutton_remove), .driver = { .name ="retu-pwrbutton" , },
@@ -166,7 +165,7 @@ static struct platform_driver retu_pwrbutton_driver = {static int __init retubutton_init (void ) { -return platform_driver_register (&retu_pwrbutton_driver); +return platform_driver_probe (&retu_pwrbutton_driver, retubutton_probe); }module_init (retubutton_init);
drivers/cbus/retu-rtc.c +3 -4
@@ -273,7 +273,7 @@ static struct rtc_class_ops retu_rtc_ops = { .set_alarm = retu_rtc_set_alarm, }; -static int __devinit retu_rtc_probe (struct platform_device *pdev) +static int __init retu_rtc_probe (struct platform_device *pdev) {struct retu_rtc *rtc;int r;
@@ -350,8 +350,7 @@ static int __devexit retu_rtc_remove(struct platform_device *pdev) }static struct platform_driver retu_rtc_driver = { - .probe = retu_rtc_probe, - .remove =__devexit_p (retu_rtc_remove), + .remove =__exit_p (retu_rtc_remove), .driver = { .name ="retu-rtc" , },
@@ -359,7 +358,7 @@ static struct platform_driver retu_rtc_driver = {static int __init retu_rtc_init (void ) { -return platform_driver_register (&retu_rtc_driver); +return platform_driver_probe (&retu_rtc_driver, retu_rtc_probe); } static void __exit retu_rtc_exit(void)
drivers/cbus/retu-wdt.c +3 -4
@@ -253,7 +253,7 @@ static const struct file_operations retu_wdt_fops = {/*----------------------------------------------------------------------------*/ -static int __devinit retu_wdt_probe (struct platform_device *pdev) +static int __init retu_wdt_probe (struct platform_device *pdev) {struct retu_wdt_dev *wdev;int ret;
@@ -340,8 +340,7 @@ static int __devexit retu_wdt_remove(struct platform_device *pdev) }static struct platform_driver retu_wdt_driver = { - .probe = retu_wdt_probe, - .remove =__devexit_p (retu_wdt_remove), + .remove =__exit_p (retu_wdt_remove), .driver = { .name ="retu-wdt" , },
@@ -349,7 +348,7 @@ static struct platform_driver retu_wdt_driver = {static int __init retu_wdt_init (void ) { -return platform_driver_register (&retu_wdt_driver); +return platform_driver_probe (&retu_wdt_driver, retu_wdt_probe); } static void __exit retu_wdt_exit(void)
drivers/cbus/retu.c +4 -5
@@ -395,7 +395,7 @@ static int retu_allocate_children(struct device *parent)* Probe for the Retu ASIC and allocate memory * for its device-struct if found */ -static int __devinit retu_probe (struct platform_device *pdev) +static int __init retu_probe (struct platform_device *pdev) {int rev, ret;int irq;
@@ -453,7 +453,7 @@ static int __devinit retu_probe(struct platform_device *pdev)return 0 ; } -static int __devexit retu_remove(struct platform_device *pdev) +static int __exit retu_remove(struct platform_device *pdev) {int irq;
@@ -471,8 +471,7 @@ static int __devexit retu_remove(struct platform_device *pdev) }static struct platform_driver retu_driver = { - .probe = retu_probe, - .remove =__devexit_p (retu_remove), + .remove =__exit_p (retu_remove), .driver = { .name ="retu" , },
@@ -532,7 +531,7 @@ static int __init retu_init(void)/* Set up correct gpio number on struct resource */ retu_resource[0 ].start =gpio_to_irq (retu_irq_pin); - ret =platform_driver_register (&retu_driver); + ret =platform_driver_probe (&retu_driver, retu_probe);if (ret <0 ) goto err1;
Signature · 1 line
1.7.3.rc0.35.g8ac8c
PATCH 5/8 cbus: tahvo: usb: convert to platform_driver
In reply to Felipe Balbitahvo-usb was already using a platform_device, now also convert device_driver into platform_driver.
--- drivers/cbus/tahvo-usb.c | 49 +++++++++++++++++++++++---------------------- 1 files changed, 25 insertions(+), 24 deletions(-)
drivers/cbus/tahvo-usb.c +25 -24
@@ -188,11 +188,11 @@ static int tahvo_otg_init(void)return 0 ; } -static int omap_otg_probe (struct device *dev) +static int __init omap_otg_probe (struct platform_device *pdev) {int ret; - tahvo_otg_dev =to_platform_device (dev); + tahvo_otg_dev = pdev; ret =tahvo_otg_init ();if (ret !=0 ) {printk (KERN_ERR "tahvo-usb: tahvo_otg_init failed\n" );
@@ -204,7 +204,7 @@ static int omap_otg_probe(struct device *dev) &tahvo_usb_device); } -static int omap_otg_remove (struct device *dev) +static int __exit omap_otg_remove(struct platform_device *pdev) {free_irq (tahvo_otg_dev->resource[1 ].start, &tahvo_usb_device); tahvo_otg_dev =NULL ;
@@ -212,11 +212,11 @@ static int omap_otg_remove(struct device *dev)return 0 ; } -struct device_driver omap_otg_driver = { - .name ="omap_otg" , - .bus = &platform_bus_type, - .probe = omap_otg_probe, - .remove = omap_otg_remove, +struct platform_driver omap_otg_driver = { + .driver = { + .name ="omap_otg" , + }, + .remove =__exit_p (omap_otg_remove), };/*
@@ -643,9 +643,10 @@ static ssize_t otg_mode_store(struct device *device, static DEVICE_ATTR(otg_mode, 0644, otg_mode_show, otg_mode_store);#endif -static int tahvo_usb_probe (struct device *dev) +static int __init tahvo_usb_probe (struct platform_device *pdev) {struct tahvo_usb *tu; +struct device *dev = &pdev->dev;int ret; ret =tahvo_get_status ();
@@ -720,25 +721,25 @@ static int tahvo_usb_probe(struct device *dev)return 0 ; } -static int tahvo_usb_remove (struct device *dev) +static int __exit tahvo_usb_remove(struct platform_device *pdev) { -dev_dbg (dev,"remove\n" ); +dev_dbg (&pdev->dev,"remove\n" );tahvo_free_irq (TAHVO_INT_VBUSON );flush_scheduled_work ();otg_set_transceiver (0 ); -device_remove_file (dev, &dev_attr_vbus_state); +device_remove_file (&pdev->dev, &dev_attr_vbus_state);#ifdef CONFIG_USB_OTG -device_remove_file (dev, &dev_attr_otg_mode); +device_remove_file (&pdev->dev, &dev_attr_otg_mode);#endif return 0 ; } -static struct device_driver tahvo_usb_driver = { - .name ="tahvo-usb" , - .bus = &platform_bus_type, - .probe = tahvo_usb_probe, - .remove = tahvo_usb_remove, +static struct platform_driver tahvo_usb_driver = { + .driver = { + .name ="tahvo-usb" , + }, + .remove =__exit_p (tahvo_usb_remove), };static struct platform_device tahvo_usb_device = {
@@ -751,18 +752,18 @@ static int __init tahvo_usb_init(void)int ret =0 ;printk (KERN_INFO "Tahvo USB transceiver driver initializing\n" ); - ret =driver_register (&tahvo_usb_driver); + ret =platform_driver_probe (&tahvo_usb_driver, tahvo_usb_probe);if (ret)return ret; ret =platform_device_register (&tahvo_usb_device);if (ret <0 ) { -driver_unregister (&tahvo_usb_driver); +platform_driver_unregister (&tahvo_usb_driver);return ret; } - ret =driver_register (&omap_otg_driver); + ret =platform_driver_probe (&omap_otg_driver, omap_otg_probe);if (ret) {platform_device_unregister (&tahvo_usb_device); -driver_unregister (&tahvo_usb_driver); +platform_driver_unregister (&tahvo_usb_driver);return ret; }return 0 ;
@@ -772,9 +773,9 @@ subsys_initcall(tahvo_usb_init); static void __exit tahvo_usb_exit(void) { -driver_unregister (&omap_otg_driver); +platform_driver_unregister (&omap_otg_driver);platform_device_unregister (&tahvo_usb_device); -driver_unregister (&tahvo_usb_driver); +platform_driver_unregister (&tahvo_usb_driver); }module_exit (tahvo_usb_exit);
Signature · 1 line
1.7.3.rc0.35.g8ac8c
PATCH 6/8 cbus: tahvo: remove device_release
In reply to Felipe Balbiit's useless as we don't do anything besideswait_for_completion(). Remove it.
--- drivers/cbus/tahvo.c | 13 ------------- 1 files changed, 0 insertions(+), 13 deletions(-)
drivers/cbus/tahvo.c +0 -13
@@ -56,8 +56,6 @@ static int tahvo_is_betty;static struct tasklet_struct tahvo_tasklet;spinlock_t tahvo_lock =SPIN_LOCK_UNLOCKED ; -static struct completion device_release; -struct tahvo_irq_handler_desc {int (*func)(unsigned long );unsigned long arg;
@@ -388,11 +386,6 @@ static int __devexit tahvo_remove(struct platform_device *pdev)return 0 ; } -static void tahvo_device_release (struct device *dev) -{ -complete (&device_release); -} -static struct platform_driver tahvo_driver = { .probe = tahvo_probe, .remove =__devexit_p (tahvo_remove),
@@ -404,9 +397,6 @@ static struct platform_driver tahvo_driver = {static struct platform_device tahvo_device = { .name ="tahvo" , .id =-1 , - .dev = { - .release = tahvo_device_release, - } };/**
@@ -422,8 +412,6 @@ static int __init tahvo_init(void) machine_is_nokia_n810() || machine_is_nokia_n810_wimax()))return -ENODEV ; -init_completion (&device_release); - ret =platform_driver_register (&tahvo_driver);if (ret)return ret;
@@ -443,7 +431,6 @@ static void __exit tahvo_exit(void) {platform_device_unregister (&tahvo_device);platform_driver_unregister (&tahvo_driver); -wait_for_completion (&device_release); }subsys_initcall (tahvo_init);
Signature · 1 line
1.7.3.rc0.35.g8ac8c
PATCH 7/8 cbus: tahvo: pass irq via struct resource
In reply to Felipe Balbiprepare tahvo for platform_device creation on
board files. Start passing irq number via
struct resource.
--- drivers/cbus/tahvo.c | 96 ++++++++++++++++++++++++++++++------------------- 1 files changed, 59 insertions(+), 37 deletions(-)
drivers/cbus/tahvo.c +59 -37
@@ -304,6 +304,7 @@ EXPORT_SYMBOL(tahvo_free_irq);static int __devinit tahvo_probe (struct platform_device *pdev) {int rev, id, ret; +int irq;/* Prepare tasklet */ tasklet_init (&tahvo_tasklet, tahvo_tasklet_handler,0 );
@@ -327,45 +328,22 @@ static int __devinit tahvo_probe(struct platform_device *pdev)dev_err (&pdev->dev,"%s v%d.%d found\n" , tahvo_is_betty ?"Betty" :"Tahvo" , (rev >>4 ) &0x0f , rev &0x0f ); -/* REVISIT: Pass these from board-*.c files in platform_data */ -if (machine_is_nokia770 ()) { - tahvo_irq_pin =40 ; - }else if (machine_is_nokia_n800 () ||machine_is_nokia_n810 () || -machine_is_nokia_n810_wimax ()) { - tahvo_irq_pin =111 ; - }else { -dev_err (&pdev->dev,"cbus: Unsupported board for tahvo\n" ); -return -ENODEV ; - } - - ret =gpio_request (tahvo_irq_pin,"TAHVO irq" ); -if (ret) { -dev_err (&pdev->dev,"Unable to reserve IRQ GPIO\n" ); -return ret; - } - -/* Set the pin as input */ -gpio_direction_input (tahvo_irq_pin); - -/* Rising edge triggers the IRQ */ -set_irq_type (gpio_to_irq (tahvo_irq_pin),IRQ_TYPE_EDGE_RISING ); + irq =platform_get_irq (pdev,0 );/* Mask all TAHVO interrupts */ tahvo_write_reg (TAHVO_REG_IMR ,0xffff ); - ret =request_irq (gpio_to_irq (tahvo_irq_pin), tahvo_irq_handler,0 , -"tahvo" ,0 ); + ret =request_irq (irq, tahvo_irq_handler,IRQF_TRIGGER_RISING , +"tahvo" ,0 );if (ret <0 ) {dev_err (&pdev->dev,"Unable to register IRQ handler\n" ); -gpio_free (tahvo_irq_pin);return ret; }#ifdef CONFIG_CBUS_TAHVO_USER /* Initialize user-space interface */ if (tahvo_user_init () <0 ) {dev_err (&pdev->dev,"Unable to initialize driver\n" ); -free_irq (gpio_to_irq (tahvo_irq_pin),0 ); -gpio_free (tahvo_irq_pin); +free_irq (irq,0 );return ret; }#endif
@@ -374,13 +352,16 @@ static int __devinit tahvo_probe(struct platform_device *pdev) static int __devexit tahvo_remove(struct platform_device *pdev) { +int irq; + + irq =platform_get_irq (pdev,0 ); +#ifdef CONFIG_CBUS_TAHVO_USER tahvo_user_cleanup ();#endif /* Mask all TAHVO interrupts */ tahvo_write_reg (TAHVO_REG_IMR ,0xffff ); -free_irq (gpio_to_irq (tahvo_irq_pin),0 ); -gpio_free (tahvo_irq_pin); +free_irq (irq,0 );tasklet_kill (&tahvo_tasklet);return 0 ;
@@ -394,9 +375,18 @@ static struct platform_driver tahvo_driver = { }, }; +static struct resource tahvo_resource[] = { + { + .start = -EINVAL ,/* set later */ + .flags =IORESOURCE_IRQ , + } +}; +static struct platform_device tahvo_device = { .name ="tahvo" , .id =-1 , + .resource = tahvo_resource, + .num_resources =ARRAY_SIZE (tahvo_resource), };/**
@@ -408,20 +398,51 @@ static int __init tahvo_init(void) {int ret =0 ; -if (!(machine_is_nokia770 () ||machine_is_nokia_n800 () || -machine_is_nokia_n810 () ||machine_is_nokia_n810_wimax ())) -return -ENODEV ; +/* REVISIT: Pass these from board-*.c files in platform_data */ +if (machine_is_nokia770 ()) { + tahvo_irq_pin =40 ; + }else if (machine_is_nokia_n800 () ||machine_is_nokia_n810 () || +machine_is_nokia_n810_wimax ()) { + tahvo_irq_pin =111 ; + }else { +pr_err ("tahvo: Unsupported board for tahvo\n" ); + ret = -ENODEV ; + goto err0; + } + + ret =gpio_request (tahvo_irq_pin,"TAHVO irq" ); +if (ret) { +pr_err ("tahvo: Unable to reserve IRQ GPIO\n" ); + goto err0; + } + +/* Set the pin as input */ + ret =gpio_direction_input (tahvo_irq_pin); +if (ret) { +pr_err ("tahvo: Unable to change direction\n" ); + goto err1; + } + + tahvo_resource[0 ].start =gpio_to_irq (tahvo_irq_pin); ret =platform_driver_register (&tahvo_driver);if (ret) -return ret; + goto err1; ret =platform_device_register (&tahvo_device); -if (ret) { -platform_driver_unregister (&tahvo_driver); -return ret; - } +if (ret) + goto err2; +return 0 ; + +err2: +platform_driver_unregister (&tahvo_driver); + +err1: +gpio_free (tahvo_irq_pin); + +err0: +return ret; }/*
@@ -431,6 +452,7 @@ static void __exit tahvo_exit(void) {platform_device_unregister (&tahvo_device);platform_driver_unregister (&tahvo_driver); +gpio_free (tahvo_irq_pin); }subsys_initcall (tahvo_init);
Signature · 1 line
1.7.3.rc0.35.g8ac8c
PATCH 8/8 cbus: tahvo: avoid section mismatch
In reply to Felipe Balbi... by removing references to init section fromplatform_driver structure
--- drivers/cbus/tahvo.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
drivers/cbus/tahvo.c +4 -5
@@ -301,7 +301,7 @@ EXPORT_SYMBOL(tahvo_free_irq);* Probe for the Tahvo ASIC and allocate memory * for its device-struct if found */ -static int __devinit tahvo_probe (struct platform_device *pdev) +static int __init tahvo_probe (struct platform_device *pdev) {int rev, id, ret;int irq;
@@ -350,7 +350,7 @@ static int __devinit tahvo_probe(struct platform_device *pdev)return 0 ; } -static int __devexit tahvo_remove(struct platform_device *pdev) +static int __exit tahvo_remove(struct platform_device *pdev) {int irq;
@@ -368,8 +368,7 @@ static int __devexit tahvo_remove(struct platform_device *pdev) }static struct platform_driver tahvo_driver = { - .probe = tahvo_probe, - .remove =__devexit_p (tahvo_remove), + .remove =__exit_p (tahvo_remove), .driver = { .name ="tahvo" , },
@@ -425,7 +424,7 @@ static int __init tahvo_init(void) tahvo_resource[0 ].start =gpio_to_irq (tahvo_irq_pin); - ret =platform_driver_register (&tahvo_driver); + ret =platform_driver_probe (&tahvo_driver, tahvo_probe);if (ret) goto err1;
Signature · 1 line
1.7.3.rc0.35.g8ac8c
Quoted 9 lines · Felipe Balbi
Hi all,
if you have n8x0/n770 board getting dust, please spend some minutes to boot test the following patches on that. After you do so, please reply with your Tested-by tag.
I'm also adding to this series Jarkko Nikula's ioctl fix since l-o doesn't compile without that.
Seems to kick the watchdog on N800 at least after the following fix. So I've pushed them all into the cbus branch for more testing :)
Regards,
Tony
From: Tony Lindgren <[email protected]>
Date: Thu, 16 Sep 2010 17:02:33 -0700
Subject: [PATCH] cbus: Fix retu init order
Device needs to be registered before the driver. Otherwise the driver register will fail.
Eventually the device register will move to the board-*.c files.
drivers/cbus/retu.c +2 -2
@@ -531,11 +531,11 @@ static int __init retu_init(void)/* Set up correct gpio number on struct resource */ retu_resource[0 ].start =gpio_to_irq (retu_irq_pin); - ret =platform_driver_probe (&retu_driver, retu_probe); + ret =platform_device_register (&retu_device);if (ret <0 ) goto err1; - ret =platform_device_register (&retu_device); + ret =platform_driver_probe (&retu_driver, retu_probe);if (ret <0 ) goto err2;
Hi,
drivers/cbus/retu.c static int __init retu_init(void) · line 534
Quoted 10 lines · Tony Lindgren
drivers/cbus/retu.c +1
-1@@ -531,11 +531,11 @@ static int __init retu_init(void)/* Set up correct gpio number on struct resource */ retu_resource[0 ].start =gpio_to_irq (retu_irq_pin); - ret =platform_driver_probe (&retu_driver, retu_probe); + ret =platform_device_register (&retu_device);
ok, good catch :-)
Thanks a lot.
Signature · 1 line
balbi