lkml.org 
[lkml]   [2012]   [Jul]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 14/25] leds: convert PCA955x LED driver to devm_kzalloc() and cleanup error exit path
Date
Cc: Nate Case <ncase@xes-inc.com>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
---
drivers/leds/leds-pca955x.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index 5f462db..aef3cf0 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -293,15 +293,14 @@ static int __devinit pca955x_probe(struct i2c_client *client,
}
}

- pca955x = kzalloc(sizeof(*pca955x), GFP_KERNEL);
+ pca955x = devm_kzalloc(&client->dev, sizeof(*pca955x), GFP_KERNEL);
if (!pca955x)
return -ENOMEM;

- pca955x->leds = kzalloc(sizeof(*pca955x_led) * chip->bits, GFP_KERNEL);
- if (!pca955x->leds) {
- err = -ENOMEM;
- goto exit_nomem;
- }
+ pca955x->leds = devm_kzalloc(&client->dev,
+ sizeof(*pca955x_led) * chip->bits, GFP_KERNEL);
+ if (!pca955x->leds)
+ return -ENOMEM;

i2c_set_clientdata(client, pca955x);

@@ -361,10 +360,6 @@ exit:
cancel_work_sync(&pca955x->leds[i].work);
}

- kfree(pca955x->leds);
-exit_nomem:
- kfree(pca955x);
-
return err;
}

@@ -378,9 +373,6 @@ static int __devexit pca955x_remove(struct i2c_client *client)
cancel_work_sync(&pca955x->leds[i].work);
}

- kfree(pca955x->leds);
- kfree(pca955x);
-
return 0;
}

--
1.7.10.4


\
 
 \ /
  Last update: 2012-07-04 08:01    [W:0.192 / U:5.908 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site