aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-mc9s08dz60.c21
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,
91static int mc9s08dz60_probe(struct i2c_client *client, 91static 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
124static int mc9s08dz60_remove(struct i2c_client *client) 115static 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
139static const struct i2c_device_id mc9s08dz60_id[] = { 124static const struct i2c_device_id mc9s08dz60_id[] = {