21
21
#define ATR_MAX_SYMLINK_LEN 11 /* Longest name is 10 chars: "channel-99" */
22
22
23
23
/**
24
- * struct i2c_atr_alias_pair - Holds the alias assigned to a client.
24
+ * struct i2c_atr_alias_pair - Holds the alias assigned to a client address .
25
25
* @node: List node
26
- * @client: Pointer to the client on the child bus
26
+ * @addr: Address of the client on the child bus.
27
27
* @alias: I2C alias address assigned by the driver.
28
28
* This is the address that will be used to issue I2C transactions
29
29
* on the parent (physical) bus.
30
30
*/
31
31
struct i2c_atr_alias_pair {
32
32
struct list_head node ;
33
- const struct i2c_client * client ;
33
+ u16 addr ;
34
34
u16 alias ;
35
35
};
36
36
@@ -97,27 +97,13 @@ struct i2c_atr {
97
97
struct i2c_adapter * adapter [] __counted_by (max_adapters );
98
98
};
99
99
100
- static struct i2c_atr_alias_pair *
101
- i2c_atr_find_mapping_by_client (const struct list_head * list ,
102
- const struct i2c_client * client )
103
- {
104
- struct i2c_atr_alias_pair * c2a ;
105
-
106
- list_for_each_entry (c2a , list , node ) {
107
- if (c2a -> client == client )
108
- return c2a ;
109
- }
110
-
111
- return NULL ;
112
- }
113
-
114
100
static struct i2c_atr_alias_pair *
115
101
i2c_atr_find_mapping_by_addr (const struct list_head * list , u16 phys_addr )
116
102
{
117
103
struct i2c_atr_alias_pair * c2a ;
118
104
119
105
list_for_each_entry (c2a , list , node ) {
120
- if (c2a -> client -> addr == phys_addr )
106
+ if (c2a -> addr == phys_addr )
121
107
return c2a ;
122
108
}
123
109
@@ -313,8 +299,8 @@ static void i2c_atr_release_alias(struct i2c_atr *atr, u16 alias)
313
299
dev_warn (atr -> dev , "Unable to find mapped alias\n" );
314
300
}
315
301
316
- static int i2c_atr_attach_client (struct i2c_adapter * adapter ,
317
- const struct i2c_client * client )
302
+ static int i2c_atr_attach_addr (struct i2c_adapter * adapter ,
303
+ u16 addr )
318
304
{
319
305
struct i2c_atr_chan * chan = adapter -> algo_data ;
320
306
struct i2c_atr * atr = chan -> atr ;
@@ -334,14 +320,14 @@ static int i2c_atr_attach_client(struct i2c_adapter *adapter,
334
320
goto err_release_alias ;
335
321
}
336
322
337
- ret = atr -> ops -> attach_client (atr , chan -> chan_id , client , alias );
323
+ ret = atr -> ops -> attach_addr (atr , chan -> chan_id , addr , alias );
338
324
if (ret )
339
325
goto err_free ;
340
326
341
- dev_dbg (atr -> dev , "chan%u: client 0x%02x mapped at alias 0x%02x (%s) \n" ,
342
- chan -> chan_id , client -> addr , alias , client -> name );
327
+ dev_dbg (atr -> dev , "chan%u: using alias 0x%02x for addr 0x%02x\n" ,
328
+ chan -> chan_id , alias , addr );
343
329
344
- c2a -> client = client ;
330
+ c2a -> addr = addr ;
345
331
c2a -> alias = alias ;
346
332
list_add (& c2a -> node , & chan -> alias_list );
347
333
@@ -355,16 +341,16 @@ static int i2c_atr_attach_client(struct i2c_adapter *adapter,
355
341
return ret ;
356
342
}
357
343
358
- static void i2c_atr_detach_client (struct i2c_adapter * adapter ,
359
- const struct i2c_client * client )
344
+ static void i2c_atr_detach_addr (struct i2c_adapter * adapter ,
345
+ u16 addr )
360
346
{
361
347
struct i2c_atr_chan * chan = adapter -> algo_data ;
362
348
struct i2c_atr * atr = chan -> atr ;
363
349
struct i2c_atr_alias_pair * c2a ;
364
350
365
- atr -> ops -> detach_client (atr , chan -> chan_id , client );
351
+ atr -> ops -> detach_addr (atr , chan -> chan_id , addr );
366
352
367
- c2a = i2c_atr_find_mapping_by_client (& chan -> alias_list , client );
353
+ c2a = i2c_atr_find_mapping_by_addr (& chan -> alias_list , addr );
368
354
if (!c2a ) {
369
355
/* This should never happen */
370
356
dev_warn (atr -> dev , "Unable to find address mapping\n" );
@@ -374,8 +360,8 @@ static void i2c_atr_detach_client(struct i2c_adapter *adapter,
374
360
i2c_atr_release_alias (atr , c2a -> alias );
375
361
376
362
dev_dbg (atr -> dev ,
377
- "chan%u: client 0x%02x unmapped from alias 0x%02x (%s) \n" ,
378
- chan -> chan_id , client -> addr , c2a -> alias , client -> name );
363
+ "chan%u: detached alias 0x%02x from addr 0x%02x\n" ,
364
+ chan -> chan_id , c2a -> alias , addr );
379
365
380
366
list_del (& c2a -> node );
381
367
kfree (c2a );
@@ -405,15 +391,15 @@ static int i2c_atr_bus_notifier_call(struct notifier_block *nb,
405
391
406
392
switch (event ) {
407
393
case BUS_NOTIFY_ADD_DEVICE :
408
- ret = i2c_atr_attach_client (client -> adapter , client );
394
+ ret = i2c_atr_attach_addr (client -> adapter , client -> addr );
409
395
if (ret )
410
396
dev_err (atr -> dev ,
411
397
"Failed to attach remote client '%s': %d\n" ,
412
398
dev_name (dev ), ret );
413
399
break ;
414
400
415
401
case BUS_NOTIFY_REMOVED_DEVICE :
416
- i2c_atr_detach_client (client -> adapter , client );
402
+ i2c_atr_detach_addr (client -> adapter , client -> addr );
417
403
break ;
418
404
419
405
default :
@@ -506,7 +492,7 @@ struct i2c_atr *i2c_atr_new(struct i2c_adapter *parent, struct device *dev,
506
492
if (max_adapters > ATR_MAX_ADAPTERS )
507
493
return ERR_PTR (- EINVAL );
508
494
509
- if (!ops || !ops -> attach_client || !ops -> detach_client )
495
+ if (!ops || !ops -> attach_addr || !ops -> detach_addr )
510
496
return ERR_PTR (- EINVAL );
511
497
512
498
atr = kzalloc (struct_size (atr , adapter , max_adapters ), GFP_KERNEL );
0 commit comments