Skip to content

Commit 697894b

Browse files
pavelmachekLee Jones
authored andcommitted
mfd: ti-lmu: Use of_device_get_match_data() helper
Replace of_match_device() with of_device_get_match_data(), which slightly decreases lines of code and allows to move the DT table next to the I2C table. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Lee Jones <lee.jones@linaro.org>
1 parent 7891d37 commit 697894b

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

drivers/mfd/ti-lmu.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,34 +148,21 @@ TI_LMU_DATA(lm3633, LM3633_MAX_REG);
148148
TI_LMU_DATA(lm3695, LM3695_MAX_REG);
149149
TI_LMU_DATA(lm3697, LM3697_MAX_REG);
150150

151-
static const struct of_device_id ti_lmu_of_match[] = {
152-
{ .compatible = "ti,lm3532", .data = &lm3532_data },
153-
{ .compatible = "ti,lm3631", .data = &lm3631_data },
154-
{ .compatible = "ti,lm3632", .data = &lm3632_data },
155-
{ .compatible = "ti,lm3633", .data = &lm3633_data },
156-
{ .compatible = "ti,lm3695", .data = &lm3695_data },
157-
{ .compatible = "ti,lm3697", .data = &lm3697_data },
158-
{ }
159-
};
160-
MODULE_DEVICE_TABLE(of, ti_lmu_of_match);
161-
162151
static int ti_lmu_probe(struct i2c_client *cl, const struct i2c_device_id *id)
163152
{
164153
struct device *dev = &cl->dev;
165-
const struct of_device_id *match;
166154
const struct ti_lmu_data *data;
167155
struct regmap_config regmap_cfg;
168156
struct ti_lmu *lmu;
169157
int ret;
170158

171-
match = of_match_device(ti_lmu_of_match, dev);
172-
if (!match)
173-
return -ENODEV;
174159
/*
175160
* Get device specific data from of_match table.
176161
* This data is defined by using TI_LMU_DATA() macro.
177162
*/
178-
data = (struct ti_lmu_data *)match->data;
163+
data = of_device_get_match_data(dev);
164+
if (!data)
165+
return -ENODEV;
179166

180167
lmu = devm_kzalloc(dev, sizeof(*lmu), GFP_KERNEL);
181168
if (!lmu)
@@ -223,6 +210,17 @@ static int ti_lmu_probe(struct i2c_client *cl, const struct i2c_device_id *id)
223210
data->num_cells, NULL, 0, NULL);
224211
}
225212

213+
static const struct of_device_id ti_lmu_of_match[] = {
214+
{ .compatible = "ti,lm3532", .data = &lm3532_data },
215+
{ .compatible = "ti,lm3631", .data = &lm3631_data },
216+
{ .compatible = "ti,lm3632", .data = &lm3632_data },
217+
{ .compatible = "ti,lm3633", .data = &lm3633_data },
218+
{ .compatible = "ti,lm3695", .data = &lm3695_data },
219+
{ .compatible = "ti,lm3697", .data = &lm3697_data },
220+
{ }
221+
};
222+
MODULE_DEVICE_TABLE(of, ti_lmu_of_match);
223+
226224
static const struct i2c_device_id ti_lmu_ids[] = {
227225
{ "lm3532", LM3532 },
228226
{ "lm3631", LM3631 },

0 commit comments

Comments
 (0)