Skip to content

Commit d83219e

Browse files
PatrickRudolphgroeck
authored andcommitted
hwmon: pmbus: max15301: Use generic code
Use the generic pmbus bus access delay. Signed-off-by: Patrick Rudolph <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
1 parent 21d9e60 commit d83219e

File tree

1 file changed

+1
-91
lines changed

1 file changed

+1
-91
lines changed

drivers/hwmon/pmbus/max15301.c

Lines changed: 1 addition & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ MODULE_DEVICE_TABLE(i2c, max15301_id);
3131

3232
struct max15301_data {
3333
int id;
34-
ktime_t access; /* Chip access time */
35-
int delay; /* Delay between chip accesses in us */
3634
struct pmbus_driver_info info;
3735
};
3836

@@ -55,89 +53,6 @@ static struct max15301_data max15301_data = {
5553
}
5654
};
5755

58-
/* This chip needs a delay between accesses */
59-
static inline void max15301_wait(const struct max15301_data *data)
60-
{
61-
if (data->delay) {
62-
s64 delta = ktime_us_delta(ktime_get(), data->access);
63-
64-
if (delta < data->delay)
65-
udelay(data->delay - delta);
66-
}
67-
}
68-
69-
static int max15301_read_word_data(struct i2c_client *client, int page,
70-
int phase, int reg)
71-
{
72-
const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
73-
struct max15301_data *data = to_max15301_data(info);
74-
int ret;
75-
76-
if (page > 0)
77-
return -ENXIO;
78-
79-
if (reg >= PMBUS_VIRT_BASE)
80-
return -ENXIO;
81-
82-
max15301_wait(data);
83-
ret = pmbus_read_word_data(client, page, phase, reg);
84-
data->access = ktime_get();
85-
86-
return ret;
87-
}
88-
89-
static int max15301_read_byte_data(struct i2c_client *client, int page, int reg)
90-
{
91-
const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
92-
struct max15301_data *data = to_max15301_data(info);
93-
int ret;
94-
95-
if (page > 0)
96-
return -ENXIO;
97-
98-
max15301_wait(data);
99-
ret = pmbus_read_byte_data(client, page, reg);
100-
data->access = ktime_get();
101-
102-
return ret;
103-
}
104-
105-
static int max15301_write_word_data(struct i2c_client *client, int page, int reg,
106-
u16 word)
107-
{
108-
const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
109-
struct max15301_data *data = to_max15301_data(info);
110-
int ret;
111-
112-
if (page > 0)
113-
return -ENXIO;
114-
115-
if (reg >= PMBUS_VIRT_BASE)
116-
return -ENXIO;
117-
118-
max15301_wait(data);
119-
ret = pmbus_write_word_data(client, page, reg, word);
120-
data->access = ktime_get();
121-
122-
return ret;
123-
}
124-
125-
static int max15301_write_byte(struct i2c_client *client, int page, u8 value)
126-
{
127-
const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
128-
struct max15301_data *data = to_max15301_data(info);
129-
int ret;
130-
131-
if (page > 0)
132-
return -ENXIO;
133-
134-
max15301_wait(data);
135-
ret = pmbus_write_byte(client, page, value);
136-
data->access = ktime_get();
137-
138-
return ret;
139-
}
140-
14156
static int max15301_probe(struct i2c_client *client)
14257
{
14358
int status;
@@ -164,12 +79,7 @@ static int max15301_probe(struct i2c_client *client)
16479
return -ENODEV;
16580
}
16681

167-
max15301_data.delay = delay;
168-
169-
info->read_byte_data = max15301_read_byte_data;
170-
info->read_word_data = max15301_read_word_data;
171-
info->write_byte = max15301_write_byte;
172-
info->write_word_data = max15301_write_word_data;
82+
info->access_delay = delay;
17383

17484
return pmbus_do_probe(client, info);
17585
}

0 commit comments

Comments
 (0)