|
8 | 8 | #include <linux/of_device.h>
|
9 | 9 | #include "pmbus.h"
|
10 | 10 |
|
| 11 | +enum chips { mpq8785 }; |
| 12 | + |
11 | 13 | static int mpq8785_identify(struct i2c_client *client,
|
12 | 14 | struct pmbus_driver_info *info)
|
13 | 15 | {
|
@@ -53,26 +55,46 @@ static struct pmbus_driver_info mpq8785_info = {
|
53 | 55 | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
|
54 | 56 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
|
55 | 57 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
|
56 |
| - .identify = mpq8785_identify, |
57 |
| -}; |
58 |
| - |
59 |
| -static int mpq8785_probe(struct i2c_client *client) |
60 |
| -{ |
61 |
| - return pmbus_do_probe(client, &mpq8785_info); |
62 | 58 | };
|
63 | 59 |
|
64 | 60 | static const struct i2c_device_id mpq8785_id[] = {
|
65 |
| - { "mpq8785" }, |
| 61 | + { "mpq8785", mpq8785 }, |
66 | 62 | { },
|
67 | 63 | };
|
68 | 64 | MODULE_DEVICE_TABLE(i2c, mpq8785_id);
|
69 | 65 |
|
70 | 66 | static const struct of_device_id __maybe_unused mpq8785_of_match[] = {
|
71 |
| - { .compatible = "mps,mpq8785" }, |
| 67 | + { .compatible = "mps,mpq8785", .data = (void *)mpq8785 }, |
72 | 68 | {}
|
73 | 69 | };
|
74 | 70 | MODULE_DEVICE_TABLE(of, mpq8785_of_match);
|
75 | 71 |
|
| 72 | +static int mpq8785_probe(struct i2c_client *client) |
| 73 | +{ |
| 74 | + struct device *dev = &client->dev; |
| 75 | + struct pmbus_driver_info *info; |
| 76 | + enum chips chip_id; |
| 77 | + |
| 78 | + info = devm_kmemdup(dev, &mpq8785_info, sizeof(*info), GFP_KERNEL); |
| 79 | + if (!info) |
| 80 | + return -ENOMEM; |
| 81 | + |
| 82 | + if (dev->of_node) |
| 83 | + chip_id = (kernel_ulong_t)of_device_get_match_data(dev); |
| 84 | + else |
| 85 | + chip_id = (kernel_ulong_t)i2c_get_match_data(client); |
| 86 | + |
| 87 | + switch (chip_id) { |
| 88 | + case mpq8785: |
| 89 | + info->identify = mpq8785_identify; |
| 90 | + break; |
| 91 | + default: |
| 92 | + return -ENODEV; |
| 93 | + } |
| 94 | + |
| 95 | + return pmbus_do_probe(client, info); |
| 96 | +}; |
| 97 | + |
76 | 98 | static struct i2c_driver mpq8785_driver = {
|
77 | 99 | .driver = {
|
78 | 100 | .name = "mpq8785",
|
|
0 commit comments