diff mbox series

[v2,3/9] i2c: atr: find_mapping() -> get_mapping()

Message ID 20250225113939.49811-4-demonsingur@gmail.com
State Superseded
Headers show
Series i2c: atr: allow usage of nested ATRs | expand

Commit Message

Cosmin Tanislav Feb. 25, 2025, 11:39 a.m. UTC
A find operation implies that a null result is not an error.

Use get naming to clarify things and to prepare for splitting up the
logic inside this function.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 drivers/i2c/i2c-atr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Romain Gantois Feb. 27, 2025, 1:25 p.m. UTC | #1
On mardi 25 février 2025 12:39:31 heure normale d’Europe centrale Cosmin 
Tanislav wrote:
> A find operation implies that a null result is not an error.
> 
> Use get naming to clarify things and to prepare for splitting up the
> logic inside this function.
> 
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
>  drivers/i2c/i2c-atr.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-atr.c b/drivers/i2c/i2c-atr.c
> index f6033c99f474..f2485d1670a2 100644
> --- a/drivers/i2c/i2c-atr.c
> +++ b/drivers/i2c/i2c-atr.c
> @@ -241,7 +241,7 @@ static void i2c_atr_release_alias(struct
> i2c_atr_alias_pool *alias_pool, u16 ali
> 
>  /* Must be called with alias_pairs_lock held */
>  static struct i2c_atr_alias_pair *
> -i2c_atr_find_mapping_by_addr(struct i2c_atr_chan *chan, u16 addr)
> +i2c_atr_get_mapping_by_addr(struct i2c_atr_chan *chan, u16 addr)
>  {
>  	struct i2c_atr *atr = chan->atr;
>  	struct i2c_atr_alias_pair *c2a;
> @@ -335,7 +335,7 @@ static int i2c_atr_map_msgs(struct i2c_atr_chan *chan,
> struct i2c_msg *msgs, for (i = 0; i < num; i++) {
>  		chan->orig_addrs[i] = msgs[i].addr;
> 
> -		c2a = i2c_atr_find_mapping_by_addr(chan, msgs[i].addr);
> +		c2a = i2c_atr_get_mapping_by_addr(chan, msgs[i].addr);
> 
>  		if (!c2a) {
>  			dev_err(atr->dev, "client 0x%02x not mapped!\n",
> @@ -428,7 +428,7 @@ static int i2c_atr_smbus_xfer(struct i2c_adapter *adap,
> u16 addr,
> 
>  	mutex_lock(&chan->alias_pairs_lock);
> 
> -	c2a = i2c_atr_find_mapping_by_addr(chan, addr);
> +	c2a = i2c_atr_get_mapping_by_addr(chan, addr);
> 
>  	if (!c2a) {
>  		dev_err(atr->dev, "client 0x%02x not mapped!\n", addr);
> @@ -536,7 +536,7 @@ static void i2c_atr_detach_addr(struct i2c_adapter
> *adapter,
> 
>  	mutex_lock(&chan->alias_pairs_lock);
> 
> -	c2a = i2c_atr_find_mapping_by_addr(chan, addr);
> +	c2a = i2c_atr_get_mapping_by_addr(chan, addr);
>  	if (!c2a) {
>  		 /* This should never happen */
>  		dev_warn(atr->dev, "Unable to find address mapping\n");

Looks good to me. This is more of a preparation/improvement patch rather than 
a fix so I think it's okay to leave it in your series.

Reviewed-by: Romain Gantois <romain.gantois@bootlin.com>
diff mbox series

Patch

diff --git a/drivers/i2c/i2c-atr.c b/drivers/i2c/i2c-atr.c
index f6033c99f474..f2485d1670a2 100644
--- a/drivers/i2c/i2c-atr.c
+++ b/drivers/i2c/i2c-atr.c
@@ -241,7 +241,7 @@  static void i2c_atr_release_alias(struct i2c_atr_alias_pool *alias_pool, u16 ali
 
 /* Must be called with alias_pairs_lock held */
 static struct i2c_atr_alias_pair *
-i2c_atr_find_mapping_by_addr(struct i2c_atr_chan *chan, u16 addr)
+i2c_atr_get_mapping_by_addr(struct i2c_atr_chan *chan, u16 addr)
 {
 	struct i2c_atr *atr = chan->atr;
 	struct i2c_atr_alias_pair *c2a;
@@ -335,7 +335,7 @@  static int i2c_atr_map_msgs(struct i2c_atr_chan *chan, struct i2c_msg *msgs,
 	for (i = 0; i < num; i++) {
 		chan->orig_addrs[i] = msgs[i].addr;
 
-		c2a = i2c_atr_find_mapping_by_addr(chan, msgs[i].addr);
+		c2a = i2c_atr_get_mapping_by_addr(chan, msgs[i].addr);
 
 		if (!c2a) {
 			dev_err(atr->dev, "client 0x%02x not mapped!\n",
@@ -428,7 +428,7 @@  static int i2c_atr_smbus_xfer(struct i2c_adapter *adap, u16 addr,
 
 	mutex_lock(&chan->alias_pairs_lock);
 
-	c2a = i2c_atr_find_mapping_by_addr(chan, addr);
+	c2a = i2c_atr_get_mapping_by_addr(chan, addr);
 
 	if (!c2a) {
 		dev_err(atr->dev, "client 0x%02x not mapped!\n", addr);
@@ -536,7 +536,7 @@  static void i2c_atr_detach_addr(struct i2c_adapter *adapter,
 
 	mutex_lock(&chan->alias_pairs_lock);
 
-	c2a = i2c_atr_find_mapping_by_addr(chan, addr);
+	c2a = i2c_atr_get_mapping_by_addr(chan, addr);
 	if (!c2a) {
 		 /* This should never happen */
 		dev_warn(atr->dev, "Unable to find address mapping\n");