mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] staging/sm7xxfb: use module_pci_driver macro
@ 2012-07-10  5:49 Devendra Naga
  2012-07-10  5:49 ` [PATCH 2/2] staging/sm7xxfb: return a proper err for smtc_alloc_fb_info failure Devendra Naga
  0 siblings, 1 reply; 2+ messages in thread
From: Devendra Naga @ 2012-07-10  5:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Teddy Wang, devel, linux-kernel; +Cc: Devendra Naga

as the manual of module_pci_driver says that
it can be used when the init and exit functions of
the module does nothing but the pci_register_driver
and pci_unregister_driver.

use it for the sm7xxfb driver, as the driver does nothing in
its _init and _exit functions but the register and unregister.

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
---
 drivers/staging/sm7xxfb/sm7xxfb.c |   13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c
index e3511ec..0c0b603 100644
--- a/drivers/staging/sm7xxfb/sm7xxfb.c
+++ b/drivers/staging/sm7xxfb/sm7xxfb.c
@@ -1058,18 +1058,7 @@ static struct pci_driver smtcfb_driver = {
 	.driver.pm  = SM7XX_PM_OPS,
 };
 
-static int __init smtcfb_init(void)
-{
-	return pci_register_driver(&smtcfb_driver);
-}
-
-static void __exit smtcfb_exit(void)
-{
-	pci_unregister_driver(&smtcfb_driver);
-}
-
-module_init(smtcfb_init);
-module_exit(smtcfb_exit);
+module_pci_driver(smtcfb_driver);
 
 MODULE_AUTHOR("Siliconmotion ");
 MODULE_DESCRIPTION("Framebuffer driver for SMI Graphic Cards");
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] staging/sm7xxfb: return a proper err for smtc_alloc_fb_info failure
  2012-07-10  5:49 [PATCH 1/2] staging/sm7xxfb: use module_pci_driver macro Devendra Naga
@ 2012-07-10  5:49 ` Devendra Naga
  0 siblings, 0 replies; 2+ messages in thread
From: Devendra Naga @ 2012-07-10  5:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Teddy Wang, devel, linux-kernel; +Cc: Devendra Naga

as smtc_alloc_fb_info can fail, but we are returning the 0,
how? because the pci_enable_device succeeded, which makes the probe
return 0, and may cause panics or some strange problems at remove
when driver unloaded by modprobe -r.

so return err properly as smtc_alloc_fb_info is doing kzallocs its
good to do -ENOMEM

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
---
 drivers/staging/sm7xxfb/sm7xxfb.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c
index 0c0b603..7395196 100644
--- a/drivers/staging/sm7xxfb/sm7xxfb.c
+++ b/drivers/staging/sm7xxfb/sm7xxfb.c
@@ -808,8 +808,10 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
 
 	sfb = smtc_alloc_fb_info(pdev, name);
 
-	if (!sfb)
+	if (!sfb) {
+		err = -ENOMEM;
 		goto failed_free;
+	}
 
 	sfb->chip_id = ent->device;
 	sprintf(name, "sm%Xfb", sfb->chip_id);
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-10  5:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-10  5:49 [PATCH 1/2] staging/sm7xxfb: use module_pci_driver macro Devendra Naga
2012-07-10  5:49 ` [PATCH 2/2] staging/sm7xxfb: return a proper err for smtc_alloc_fb_info failure Devendra Naga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome