* [PATCH 0/2] staging: sm750fb: Switch to using managed resources
@ 2016-02-28 15:51 Amitoj Kaur Chawla
2016-02-28 15:51 ` [PATCH 1/2] staging: sm750fb: Replace kzalloc with devm_kzalloc Amitoj Kaur Chawla
2016-02-28 15:52 ` [PATCH 2/2] staging: sm750fb: Use pcim_enable_device() Amitoj Kaur Chawla
0 siblings, 2 replies; 3+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-28 15:51 UTC (permalink / raw)
To: outreachy-kernel
This patchset uses devres API to switch to managed resources
in the sm750fb driver.
Convert the driver to use devm_kzalloc and pcim_enable_device
instead of kzalloc and pci_enable_device respectively.
Amitoj Kaur Chawla (2):
staging: sm750fb: Replace kzalloc with devm_kzalloc
staging: sm750fb: Use pcim_enable_device()
drivers/staging/sm750fb/sm750.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] staging: sm750fb: Replace kzalloc with devm_kzalloc
2016-02-28 15:51 [PATCH 0/2] staging: sm750fb: Switch to using managed resources Amitoj Kaur Chawla
@ 2016-02-28 15:51 ` Amitoj Kaur Chawla
2016-02-28 15:52 ` [PATCH 2/2] staging: sm750fb: Use pcim_enable_device() Amitoj Kaur Chawla
1 sibling, 0 replies; 3+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-28 15:51 UTC (permalink / raw)
To: outreachy-kernel
Devm_ functions allocate memory that is released when a driver
detaches.
Replace kzalloc with devm_kzalloc and remove corresponding
kfrees from probe and remove functions of a pci_dev.
Also, an unnecessary label has been removed by replacing it
with a direct return statement.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
drivers/staging/sm750fb/sm750.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index de996a6..7967a85 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -1058,7 +1058,7 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
return err;
err = -ENOMEM;
- sm750_dev = kzalloc(sizeof(*sm750_dev), GFP_KERNEL);
+ sm750_dev = devm_kzalloc(&pdev->dev, sizeof(*sm750_dev), GFP_KERNEL);
if (!sm750_dev)
goto disable_pci;
@@ -1090,7 +1090,7 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
/* call chip specific mmap routine */
err = hw_sm750_map(sm750_dev, pdev);
if (err)
- goto free_sm750_dev;
+ return err;
if (!sm750_dev->mtrr_off)
sm750_dev->mtrr.vram = arch_phys_wc_add(sm750_dev->vidmem_start,
@@ -1115,8 +1115,6 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
release_fb:
sm750fb_frambuffer_release(sm750_dev);
-free_sm750_dev:
- kfree(sm750_dev);
disable_pci:
pci_disable_device(pdev);
return err;
@@ -1134,7 +1132,6 @@ static void lynxfb_pci_remove(struct pci_dev *pdev)
iounmap(sm750_dev->pvReg);
iounmap(sm750_dev->pvMem);
kfree(g_settings);
- kfree(sm750_dev);
}
static int __init lynxfb_setup(char *options)
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] staging: sm750fb: Use pcim_enable_device()
2016-02-28 15:51 [PATCH 0/2] staging: sm750fb: Switch to using managed resources Amitoj Kaur Chawla
2016-02-28 15:51 ` [PATCH 1/2] staging: sm750fb: Replace kzalloc with devm_kzalloc Amitoj Kaur Chawla
@ 2016-02-28 15:52 ` Amitoj Kaur Chawla
1 sibling, 0 replies; 3+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-28 15:52 UTC (permalink / raw)
To: outreachy-kernel
Devm_ functions allocate memory that is released when a driver
detaches.
Replace pci_enable_device with the managed pcim_enable_device
and remove corresponding pci_disable_device from probe and
suspend functions of a pci_dev.
Also, an unnecessary label has been removed by replacing it
with a direct return statement.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
drivers/staging/sm750fb/sm750.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 7967a85..fde79ee 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -422,7 +422,6 @@ static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg)
return ret;
}
- pci_disable_device(pdev);
ret = pci_set_power_state(pdev, pci_choose_state(pdev, mesg));
if (ret) {
pr_err("error:%d occurred in pci_set_power_state\n", ret);
@@ -1053,14 +1052,14 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
int err;
/* enable device */
- err = pci_enable_device(pdev);
+ err = pcim_enable_device(pdev);
if (err)
return err;
err = -ENOMEM;
sm750_dev = devm_kzalloc(&pdev->dev, sizeof(*sm750_dev), GFP_KERNEL);
if (!sm750_dev)
- goto disable_pci;
+ return err;
sm750_dev->fbinfo[0] = sm750_dev->fbinfo[1] = NULL;
sm750_dev->devid = pdev->device;
@@ -1115,8 +1114,6 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
release_fb:
sm750fb_frambuffer_release(sm750_dev);
-disable_pci:
- pci_disable_device(pdev);
return err;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-28 15:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-28 15:51 [PATCH 0/2] staging: sm750fb: Switch to using managed resources Amitoj Kaur Chawla
2016-02-28 15:51 ` [PATCH 1/2] staging: sm750fb: Replace kzalloc with devm_kzalloc Amitoj Kaur Chawla
2016-02-28 15:52 ` [PATCH 2/2] staging: sm750fb: Use pcim_enable_device() Amitoj Kaur Chawla
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.