diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-08-28 21:36:54 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-08-31 19:02:27 -0400 |
commit | 3c7051d7cc136a6b0293f8e6960f7c61afd6ae08 (patch) | |
tree | 7c5de63ed6794b650fc92485d3667e4e9bce795f | |
parent | 6e20a0a429bd4dc07d6de16d9c247270e04e4aa0 (diff) |
gpio: mc9s08dz60: Use devm_kzalloc API
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpio-mc9s08dz60.c | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/drivers/gpio/gpio-mc9s08dz60.c b/drivers/gpio/gpio-mc9s08dz60.c index 2738cc44d636..0ab700046a23 100644 --- a/drivers/gpio/gpio-mc9s08dz60.c +++ b/drivers/gpio/gpio-mc9s08dz60.c | |||
@@ -91,10 +91,9 @@ static int mc9s08dz60_direction_output(struct gpio_chip *gc, | |||
91 | static int mc9s08dz60_probe(struct i2c_client *client, | 91 | static int mc9s08dz60_probe(struct i2c_client *client, |
92 | const struct i2c_device_id *id) | 92 | const struct i2c_device_id *id) |
93 | { | 93 | { |
94 | int ret = 0; | ||
95 | struct mc9s08dz60 *mc9s; | 94 | struct mc9s08dz60 *mc9s; |
96 | 95 | ||
97 | mc9s = kzalloc(sizeof(*mc9s), GFP_KERNEL); | 96 | mc9s = devm_kzalloc(&client->dev, sizeof(*mc9s), GFP_KERNEL); |
98 | if (!mc9s) | 97 | if (!mc9s) |
99 | return -ENOMEM; | 98 | return -ENOMEM; |
100 | 99 | ||
@@ -110,30 +109,16 @@ static int mc9s08dz60_probe(struct i2c_client *client, | |||
110 | mc9s->client = client; | 109 | mc9s->client = client; |
111 | i2c_set_clientdata(client, mc9s); | 110 | i2c_set_clientdata(client, mc9s); |
112 | 111 | ||
113 | ret = gpiochip_add(&mc9s->chip); | 112 | return gpiochip_add(&mc9s->chip); |
114 | if (ret) | ||
115 | goto error; | ||
116 | |||
117 | return 0; | ||
118 | |||
119 | error: | ||
120 | kfree(mc9s); | ||
121 | return ret; | ||
122 | } | 113 | } |
123 | 114 | ||
124 | static int mc9s08dz60_remove(struct i2c_client *client) | 115 | static int mc9s08dz60_remove(struct i2c_client *client) |
125 | { | 116 | { |
126 | struct mc9s08dz60 *mc9s; | 117 | struct mc9s08dz60 *mc9s; |
127 | int ret; | ||
128 | 118 | ||
129 | mc9s = i2c_get_clientdata(client); | 119 | mc9s = i2c_get_clientdata(client); |
130 | 120 | ||
131 | ret = gpiochip_remove(&mc9s->chip); | 121 | return gpiochip_remove(&mc9s->chip); |
132 | if (!ret) | ||
133 | kfree(mc9s); | ||
134 | |||
135 | return ret; | ||
136 | |||
137 | } | 122 | } |
138 | 123 | ||
139 | static const struct i2c_device_id mc9s08dz60_id[] = { | 124 | static const struct i2c_device_id mc9s08dz60_id[] = { |