diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-05-10 21:29:51 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-05-20 11:27:03 -0400 |
commit | 6608a5e2dd0dff73fe1bf912036349ad5ed78bdb (patch) | |
tree | 43ed1803ba9f430564496231ea03b19bcdeec670 /drivers/mfd/da9052-i2c.c | |
parent | 805b237a63f686f87870af000a5ac464633cb9c8 (diff) |
mfd: Convert da9052 to use devm_* APIs
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/da9052-i2c.c')
-rw-r--r-- | drivers/mfd/da9052-i2c.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/drivers/mfd/da9052-i2c.c b/drivers/mfd/da9052-i2c.c index 8410065f135f..82c9d6450286 100644 --- a/drivers/mfd/da9052-i2c.c +++ b/drivers/mfd/da9052-i2c.c | |||
@@ -70,7 +70,7 @@ static int __devinit da9052_i2c_probe(struct i2c_client *client, | |||
70 | struct da9052 *da9052; | 70 | struct da9052 *da9052; |
71 | int ret; | 71 | int ret; |
72 | 72 | ||
73 | da9052 = kzalloc(sizeof(struct da9052), GFP_KERNEL); | 73 | da9052 = devm_kzalloc(&client->dev, sizeof(struct da9052), GFP_KERNEL); |
74 | if (!da9052) | 74 | if (!da9052) |
75 | return -ENOMEM; | 75 | return -ENOMEM; |
76 | 76 | ||
@@ -78,8 +78,7 @@ static int __devinit da9052_i2c_probe(struct i2c_client *client, | |||
78 | I2C_FUNC_SMBUS_BYTE_DATA)) { | 78 | I2C_FUNC_SMBUS_BYTE_DATA)) { |
79 | dev_info(&client->dev, "Error in %s:i2c_check_functionality\n", | 79 | dev_info(&client->dev, "Error in %s:i2c_check_functionality\n", |
80 | __func__); | 80 | __func__); |
81 | ret = -ENODEV; | 81 | return -ENODEV; |
82 | goto err; | ||
83 | } | 82 | } |
84 | 83 | ||
85 | da9052->dev = &client->dev; | 84 | da9052->dev = &client->dev; |
@@ -87,17 +86,17 @@ static int __devinit da9052_i2c_probe(struct i2c_client *client, | |||
87 | 86 | ||
88 | i2c_set_clientdata(client, da9052); | 87 | i2c_set_clientdata(client, da9052); |
89 | 88 | ||
90 | da9052->regmap = regmap_init_i2c(client, &da9052_regmap_config); | 89 | da9052->regmap = devm_regmap_init_i2c(client, &da9052_regmap_config); |
91 | if (IS_ERR(da9052->regmap)) { | 90 | if (IS_ERR(da9052->regmap)) { |
92 | ret = PTR_ERR(da9052->regmap); | 91 | ret = PTR_ERR(da9052->regmap); |
93 | dev_err(&client->dev, "Failed to allocate register map: %d\n", | 92 | dev_err(&client->dev, "Failed to allocate register map: %d\n", |
94 | ret); | 93 | ret); |
95 | goto err; | 94 | return ret; |
96 | } | 95 | } |
97 | 96 | ||
98 | ret = da9052_i2c_enable_multiwrite(da9052); | 97 | ret = da9052_i2c_enable_multiwrite(da9052); |
99 | if (ret < 0) | 98 | if (ret < 0) |
100 | goto err_regmap; | 99 | return ret; |
101 | 100 | ||
102 | #ifdef CONFIG_OF | 101 | #ifdef CONFIG_OF |
103 | if (!id) { | 102 | if (!id) { |
@@ -112,20 +111,14 @@ static int __devinit da9052_i2c_probe(struct i2c_client *client, | |||
112 | if (!id) { | 111 | if (!id) { |
113 | ret = -ENODEV; | 112 | ret = -ENODEV; |
114 | dev_err(&client->dev, "id is null.\n"); | 113 | dev_err(&client->dev, "id is null.\n"); |
115 | goto err_regmap; | 114 | return ret; |
116 | } | 115 | } |
117 | 116 | ||
118 | ret = da9052_device_init(da9052, id->driver_data); | 117 | ret = da9052_device_init(da9052, id->driver_data); |
119 | if (ret != 0) | 118 | if (ret != 0) |
120 | goto err_regmap; | 119 | return ret; |
121 | 120 | ||
122 | return 0; | 121 | return 0; |
123 | |||
124 | err_regmap: | ||
125 | regmap_exit(da9052->regmap); | ||
126 | err: | ||
127 | kfree(da9052); | ||
128 | return ret; | ||
129 | } | 122 | } |
130 | 123 | ||
131 | static int __devexit da9052_i2c_remove(struct i2c_client *client) | 124 | static int __devexit da9052_i2c_remove(struct i2c_client *client) |
@@ -133,9 +126,6 @@ static int __devexit da9052_i2c_remove(struct i2c_client *client) | |||
133 | struct da9052 *da9052 = i2c_get_clientdata(client); | 126 | struct da9052 *da9052 = i2c_get_clientdata(client); |
134 | 127 | ||
135 | da9052_device_exit(da9052); | 128 | da9052_device_exit(da9052); |
136 | regmap_exit(da9052->regmap); | ||
137 | kfree(da9052); | ||
138 | |||
139 | return 0; | 129 | return 0; |
140 | } | 130 | } |
141 | 131 | ||