Skip to content

Commit 4640a1f

Browse files
kmaincentPaolo Abeni
authored andcommitted
net: pse-pd: Remove is_enabled callback from drivers
The is_enabled callback is now redundant as the admin_state can be obtained directly from the driver and provides the same information. To simplify functionality, the core will handle this internally, making the is_enabled callback unnecessary at the driver level. Remove the callback from all drivers. Acked-by: Oleksij Rempel <[email protected]> Signed-off-by: Kory Maincent <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 3e9dbfe commit 4640a1f

File tree

5 files changed

+11
-68
lines changed

5 files changed

+11
-68
lines changed

drivers/net/pse-pd/pd692x0.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -431,31 +431,6 @@ static int pd692x0_pi_disable(struct pse_controller_dev *pcdev, int id)
431431
return 0;
432432
}
433433

434-
static int pd692x0_pi_is_enabled(struct pse_controller_dev *pcdev, int id)
435-
{
436-
struct pd692x0_priv *priv = to_pd692x0_priv(pcdev);
437-
struct pd692x0_msg msg, buf = {0};
438-
int ret;
439-
440-
ret = pd692x0_fw_unavailable(priv);
441-
if (ret)
442-
return ret;
443-
444-
msg = pd692x0_msg_template_list[PD692X0_MSG_GET_PORT_STATUS];
445-
msg.sub[2] = id;
446-
ret = pd692x0_sendrecv_msg(priv, &msg, &buf);
447-
if (ret < 0)
448-
return ret;
449-
450-
if (buf.sub[1]) {
451-
priv->admin_state[id] = ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED;
452-
return 1;
453-
} else {
454-
priv->admin_state[id] = ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED;
455-
return 0;
456-
}
457-
}
458-
459434
struct pd692x0_pse_ext_state_mapping {
460435
u32 status_code;
461436
enum ethtool_c33_pse_ext_state pse_ext_state;
@@ -1105,7 +1080,6 @@ static const struct pse_controller_ops pd692x0_ops = {
11051080
.pi_get_actual_pw = pd692x0_pi_get_actual_pw,
11061081
.pi_enable = pd692x0_pi_enable,
11071082
.pi_disable = pd692x0_pi_disable,
1108-
.pi_is_enabled = pd692x0_pi_is_enabled,
11091083
.pi_get_voltage = pd692x0_pi_get_voltage,
11101084
.pi_get_pw_limit = pd692x0_pi_get_pw_limit,
11111085
.pi_set_pw_limit = pd692x0_pi_set_pw_limit,

drivers/net/pse-pd/pse_core.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,25 @@ static int of_load_pse_pis(struct pse_controller_dev *pcdev)
210210
static int pse_pi_is_enabled(struct regulator_dev *rdev)
211211
{
212212
struct pse_controller_dev *pcdev = rdev_get_drvdata(rdev);
213+
struct pse_admin_state admin_state = {0};
213214
const struct pse_controller_ops *ops;
214215
int id, ret;
215216

216217
ops = pcdev->ops;
217-
if (!ops->pi_is_enabled)
218+
if (!ops->pi_get_admin_state)
218219
return -EOPNOTSUPP;
219220

220221
id = rdev_get_id(rdev);
221222
mutex_lock(&pcdev->lock);
222-
ret = ops->pi_is_enabled(pcdev, id);
223+
ret = ops->pi_get_admin_state(pcdev, id, &admin_state);
224+
if (ret)
225+
goto out;
226+
227+
if (admin_state.podl_admin_state == ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED ||
228+
admin_state.c33_admin_state == ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED)
229+
ret = 1;
230+
231+
out:
223232
mutex_unlock(&pcdev->lock);
224233

225234
return ret;

drivers/net/pse-pd/pse_regulator.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ pse_reg_pi_disable(struct pse_controller_dev *pcdev, int id)
5151
return 0;
5252
}
5353

54-
static int
55-
pse_reg_pi_is_enabled(struct pse_controller_dev *pcdev, int id)
56-
{
57-
struct pse_reg_priv *priv = to_pse_reg(pcdev);
58-
59-
return regulator_is_enabled(priv->ps);
60-
}
61-
6254
static int
6355
pse_reg_pi_get_admin_state(struct pse_controller_dev *pcdev, int id,
6456
struct pse_admin_state *admin_state)
@@ -95,7 +87,6 @@ static const struct pse_controller_ops pse_reg_ops = {
9587
.pi_get_admin_state = pse_reg_pi_get_admin_state,
9688
.pi_get_pw_status = pse_reg_pi_get_pw_status,
9789
.pi_enable = pse_reg_pi_enable,
98-
.pi_is_enabled = pse_reg_pi_is_enabled,
9990
.pi_disable = pse_reg_pi_disable,
10091
};
10192

drivers/net/pse-pd/tps23881.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -174,33 +174,6 @@ static int tps23881_pi_disable(struct pse_controller_dev *pcdev, int id)
174174
return i2c_smbus_write_word_data(client, TPS23881_REG_DET_CLA_EN, val);
175175
}
176176

177-
static int tps23881_pi_is_enabled(struct pse_controller_dev *pcdev, int id)
178-
{
179-
struct tps23881_priv *priv = to_tps23881_priv(pcdev);
180-
struct i2c_client *client = priv->client;
181-
bool enabled;
182-
u8 chan;
183-
u16 val;
184-
int ret;
185-
186-
ret = i2c_smbus_read_word_data(client, TPS23881_REG_PW_STATUS);
187-
if (ret < 0)
188-
return ret;
189-
190-
chan = priv->port[id].chan[0];
191-
val = tps23881_calc_val(ret, chan, 0, BIT(chan % 4));
192-
enabled = !!(val);
193-
194-
if (priv->port[id].is_4p) {
195-
chan = priv->port[id].chan[1];
196-
val = tps23881_calc_val(ret, chan, 0, BIT(chan % 4));
197-
enabled &= !!(val);
198-
}
199-
200-
/* Return enabled status only if both channel are on this state */
201-
return enabled;
202-
}
203-
204177
static int
205178
tps23881_pi_get_admin_state(struct pse_controller_dev *pcdev, int id,
206179
struct pse_admin_state *admin_state)
@@ -690,7 +663,6 @@ static const struct pse_controller_ops tps23881_ops = {
690663
.setup_pi_matrix = tps23881_setup_pi_matrix,
691664
.pi_enable = tps23881_pi_enable,
692665
.pi_disable = tps23881_pi_disable,
693-
.pi_is_enabled = tps23881_pi_is_enabled,
694666
.pi_get_admin_state = tps23881_pi_get_admin_state,
695667
.pi_get_pw_status = tps23881_pi_get_pw_status,
696668
};

include/linux/pse-pd/pse.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ struct ethtool_pse_control_status {
122122
* @pi_get_ext_state: Get the extended state of the PSE PI.
123123
* @pi_get_pw_class: Get the power class of the PSE PI.
124124
* @pi_get_actual_pw: Get actual power of the PSE PI in mW.
125-
* @pi_is_enabled: Return 1 if the PSE PI is enabled, 0 if not.
126-
* May also return negative errno.
127125
* @pi_enable: Configure the PSE PI as enabled.
128126
* @pi_disable: Configure the PSE PI as disabled.
129127
* @pi_get_voltage: Return voltage similarly to get_voltage regulator
@@ -145,7 +143,6 @@ struct pse_controller_ops {
145143
struct pse_ext_state_info *ext_state_info);
146144
int (*pi_get_pw_class)(struct pse_controller_dev *pcdev, int id);
147145
int (*pi_get_actual_pw)(struct pse_controller_dev *pcdev, int id);
148-
int (*pi_is_enabled)(struct pse_controller_dev *pcdev, int id);
149146
int (*pi_enable)(struct pse_controller_dev *pcdev, int id);
150147
int (*pi_disable)(struct pse_controller_dev *pcdev, int id);
151148
int (*pi_get_voltage)(struct pse_controller_dev *pcdev, int id);

0 commit comments

Comments
 (0)