|
27 | 27 | */
|
28 | 28 |
|
29 | 29 | #include <linux/bitops.h>
|
| 30 | +#include <linux/cleanup.h> |
30 | 31 | #include <linux/clk.h>
|
31 | 32 | #include <linux/delay.h>
|
32 | 33 | #include <linux/fwnode.h>
|
@@ -478,6 +479,8 @@ struct ub960_rxport {
|
478 | 479 | };
|
479 | 480 | } eq;
|
480 | 481 |
|
| 482 | + /* lock for aliased_addrs and associated registers */ |
| 483 | + struct mutex aliased_addrs_lock; |
481 | 484 | u16 aliased_addrs[UB960_MAX_PORT_ALIASES];
|
482 | 485 | };
|
483 | 486 |
|
@@ -1054,6 +1057,8 @@ static int ub960_atr_attach_client(struct i2c_atr *atr, u32 chan_id,
|
1054 | 1057 | struct device *dev = &priv->client->dev;
|
1055 | 1058 | unsigned int reg_idx;
|
1056 | 1059 |
|
| 1060 | + guard(mutex)(&rxport->aliased_addrs_lock); |
| 1061 | + |
1057 | 1062 | for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_addrs); reg_idx++) {
|
1058 | 1063 | if (!rxport->aliased_addrs[reg_idx])
|
1059 | 1064 | break;
|
@@ -1085,6 +1090,8 @@ static void ub960_atr_detach_client(struct i2c_atr *atr, u32 chan_id,
|
1085 | 1090 | struct device *dev = &priv->client->dev;
|
1086 | 1091 | unsigned int reg_idx;
|
1087 | 1092 |
|
| 1093 | + guard(mutex)(&rxport->aliased_addrs_lock); |
| 1094 | + |
1088 | 1095 | for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_addrs); reg_idx++) {
|
1089 | 1096 | if (rxport->aliased_addrs[reg_idx] == client->addr)
|
1090 | 1097 | break;
|
@@ -3235,6 +3242,8 @@ static void ub960_rxport_free_ports(struct ub960_data *priv)
|
3235 | 3242 | fwnode_handle_put(rxport->source.ep_fwnode);
|
3236 | 3243 | fwnode_handle_put(rxport->ser.fwnode);
|
3237 | 3244 |
|
| 3245 | + mutex_destroy(&rxport->aliased_addrs_lock); |
| 3246 | + |
3238 | 3247 | kfree(rxport);
|
3239 | 3248 | priv->rxports[nport] = NULL;
|
3240 | 3249 | }
|
@@ -3455,6 +3464,8 @@ static int ub960_parse_dt_rxport(struct ub960_data *priv, unsigned int nport,
|
3455 | 3464 | if (ret)
|
3456 | 3465 | goto err_put_remote_fwnode;
|
3457 | 3466 |
|
| 3467 | + mutex_init(&rxport->aliased_addrs_lock); |
| 3468 | + |
3458 | 3469 | return 0;
|
3459 | 3470 |
|
3460 | 3471 | err_put_remote_fwnode:
|
|
0 commit comments