@@ -838,12 +838,15 @@ struct regmap *__regmap_init(struct device *dev,
838
838
map -> reg_stride_order = ilog2 (map -> reg_stride );
839
839
else
840
840
map -> reg_stride_order = -1 ;
841
- map -> use_single_read = config -> use_single_read || !bus || ! bus -> read ;
842
- map -> use_single_write = config -> use_single_write || !bus || ! bus -> write ;
843
- map -> can_multi_write = config -> can_multi_write && bus && bus -> write ;
841
+ map -> use_single_read = config -> use_single_read || !( config -> read || ( bus && bus -> read )) ;
842
+ map -> use_single_write = config -> use_single_write || !( config -> write || ( bus && bus -> write )) ;
843
+ map -> can_multi_write = config -> can_multi_write && ( config -> write || ( bus && bus -> write )) ;
844
844
if (bus ) {
845
845
map -> max_raw_read = bus -> max_raw_read ;
846
846
map -> max_raw_write = bus -> max_raw_write ;
847
+ } else if (config -> max_raw_read && config -> max_raw_write ) {
848
+ map -> max_raw_read = config -> max_raw_read ;
849
+ map -> max_raw_write = config -> max_raw_write ;
847
850
}
848
851
map -> dev = dev ;
849
852
map -> bus = bus ;
@@ -877,7 +880,16 @@ struct regmap *__regmap_init(struct device *dev,
877
880
map -> read_flag_mask = bus -> read_flag_mask ;
878
881
}
879
882
880
- if (!bus ) {
883
+ if (config && config -> read && config -> write ) {
884
+ map -> reg_read = _regmap_bus_read ;
885
+
886
+ /* Bulk read/write */
887
+ map -> read = config -> read ;
888
+ map -> write = config -> write ;
889
+
890
+ reg_endian = REGMAP_ENDIAN_NATIVE ;
891
+ val_endian = REGMAP_ENDIAN_NATIVE ;
892
+ } else if (!bus ) {
881
893
map -> reg_read = config -> reg_read ;
882
894
map -> reg_write = config -> reg_write ;
883
895
map -> reg_update_bits = config -> reg_update_bits ;
@@ -894,10 +906,13 @@ struct regmap *__regmap_init(struct device *dev,
894
906
} else {
895
907
map -> reg_read = _regmap_bus_read ;
896
908
map -> reg_update_bits = bus -> reg_update_bits ;
897
- }
909
+ /* Bulk read/write */
910
+ map -> read = bus -> read ;
911
+ map -> write = bus -> write ;
898
912
899
- reg_endian = regmap_get_reg_endian (bus , config );
900
- val_endian = regmap_get_val_endian (dev , bus , config );
913
+ reg_endian = regmap_get_reg_endian (bus , config );
914
+ val_endian = regmap_get_val_endian (dev , bus , config );
915
+ }
901
916
902
917
switch (config -> reg_bits + map -> reg_shift ) {
903
918
case 2 :
@@ -1671,8 +1686,6 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg,
1671
1686
size_t len ;
1672
1687
int i ;
1673
1688
1674
- WARN_ON (!map -> bus );
1675
-
1676
1689
/* Check for unwritable or noinc registers in range
1677
1690
* before we start
1678
1691
*/
@@ -1754,7 +1767,7 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg,
1754
1767
val = work_val ;
1755
1768
}
1756
1769
1757
- if (map -> async && map -> bus -> async_write ) {
1770
+ if (map -> async && map -> bus && map -> bus -> async_write ) {
1758
1771
struct regmap_async * async ;
1759
1772
1760
1773
trace_regmap_async_write_start (map , reg , val_len );
@@ -1822,11 +1835,11 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg,
1822
1835
* write.
1823
1836
*/
1824
1837
if (val == work_val )
1825
- ret = map -> bus -> write (map -> bus_context , map -> work_buf ,
1826
- map -> format .reg_bytes +
1827
- map -> format .pad_bytes +
1828
- val_len );
1829
- else if (map -> bus -> gather_write )
1838
+ ret = map -> write (map -> bus_context , map -> work_buf ,
1839
+ map -> format .reg_bytes +
1840
+ map -> format .pad_bytes +
1841
+ val_len );
1842
+ else if (map -> bus && map -> bus -> gather_write )
1830
1843
ret = map -> bus -> gather_write (map -> bus_context , map -> work_buf ,
1831
1844
map -> format .reg_bytes +
1832
1845
map -> format .pad_bytes ,
@@ -1844,7 +1857,7 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg,
1844
1857
memcpy (buf , map -> work_buf , map -> format .reg_bytes );
1845
1858
memcpy (buf + map -> format .reg_bytes + map -> format .pad_bytes ,
1846
1859
val , val_len );
1847
- ret = map -> bus -> write (map -> bus_context , buf , len );
1860
+ ret = map -> write (map -> bus_context , buf , len );
1848
1861
1849
1862
kfree (buf );
1850
1863
} else if (ret != 0 && !map -> cache_bypass && map -> format .parse_val ) {
@@ -1901,7 +1914,7 @@ static int _regmap_bus_formatted_write(void *context, unsigned int reg,
1901
1914
struct regmap_range_node * range ;
1902
1915
struct regmap * map = context ;
1903
1916
1904
- WARN_ON (!map -> bus || ! map -> format .format_write );
1917
+ WARN_ON (!map -> format .format_write );
1905
1918
1906
1919
range = _regmap_range_lookup (map , reg );
1907
1920
if (range ) {
@@ -1916,8 +1929,7 @@ static int _regmap_bus_formatted_write(void *context, unsigned int reg,
1916
1929
1917
1930
trace_regmap_hw_write_start (map , reg , 1 );
1918
1931
1919
- ret = map -> bus -> write (map -> bus_context , map -> work_buf ,
1920
- map -> format .buf_size );
1932
+ ret = map -> write (map -> bus_context , map -> work_buf , map -> format .buf_size );
1921
1933
1922
1934
trace_regmap_hw_write_done (map , reg , 1 );
1923
1935
@@ -1937,7 +1949,7 @@ static int _regmap_bus_raw_write(void *context, unsigned int reg,
1937
1949
{
1938
1950
struct regmap * map = context ;
1939
1951
1940
- WARN_ON (!map -> bus || ! map -> format .format_val );
1952
+ WARN_ON (!map -> format .format_val );
1941
1953
1942
1954
map -> format .format_val (map -> work_buf + map -> format .reg_bytes
1943
1955
+ map -> format .pad_bytes , val , 0 );
@@ -1951,7 +1963,7 @@ static int _regmap_bus_raw_write(void *context, unsigned int reg,
1951
1963
1952
1964
static inline void * _regmap_map_get_context (struct regmap * map )
1953
1965
{
1954
- return (map -> bus ) ? map : map -> bus_context ;
1966
+ return (map -> bus || (! map -> bus && map -> read ) ) ? map : map -> bus_context ;
1955
1967
}
1956
1968
1957
1969
int _regmap_write (struct regmap * map , unsigned int reg ,
@@ -2363,7 +2375,7 @@ static int _regmap_raw_multi_reg_write(struct regmap *map,
2363
2375
u8 = buf ;
2364
2376
* u8 |= map -> write_flag_mask ;
2365
2377
2366
- ret = map -> bus -> write (map -> bus_context , buf , len );
2378
+ ret = map -> write (map -> bus_context , buf , len );
2367
2379
2368
2380
kfree (buf );
2369
2381
@@ -2669,9 +2681,7 @@ static int _regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
2669
2681
struct regmap_range_node * range ;
2670
2682
int ret ;
2671
2683
2672
- WARN_ON (!map -> bus );
2673
-
2674
- if (!map -> bus || !map -> bus -> read )
2684
+ if (!map -> read )
2675
2685
return - EINVAL ;
2676
2686
2677
2687
range = _regmap_range_lookup (map , reg );
@@ -2689,9 +2699,9 @@ static int _regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
2689
2699
map -> read_flag_mask );
2690
2700
trace_regmap_hw_read_start (map , reg , val_len / map -> format .val_bytes );
2691
2701
2692
- ret = map -> bus -> read (map -> bus_context , map -> work_buf ,
2693
- map -> format .reg_bytes + map -> format .pad_bytes ,
2694
- val , val_len );
2702
+ ret = map -> read (map -> bus_context , map -> work_buf ,
2703
+ map -> format .reg_bytes + map -> format .pad_bytes ,
2704
+ val , val_len );
2695
2705
2696
2706
trace_regmap_hw_read_done (map , reg , val_len / map -> format .val_bytes );
2697
2707
@@ -2802,8 +2812,6 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
2802
2812
unsigned int v ;
2803
2813
int ret , i ;
2804
2814
2805
- if (!map -> bus )
2806
- return - EINVAL ;
2807
2815
if (val_len % map -> format .val_bytes )
2808
2816
return - EINVAL ;
2809
2817
if (!IS_ALIGNED (reg , map -> reg_stride ))
@@ -2818,7 +2826,7 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
2818
2826
size_t chunk_count , chunk_bytes ;
2819
2827
size_t chunk_regs = val_count ;
2820
2828
2821
- if (!map -> bus -> read ) {
2829
+ if (!map -> read ) {
2822
2830
ret = - ENOTSUPP ;
2823
2831
goto out ;
2824
2832
}
@@ -2878,7 +2886,7 @@ EXPORT_SYMBOL_GPL(regmap_raw_read);
2878
2886
* @val: Pointer to data buffer
2879
2887
* @val_len: Length of output buffer in bytes.
2880
2888
*
2881
- * The regmap API usually assumes that bulk bus read operations will read a
2889
+ * The regmap API usually assumes that bulk read operations will read a
2882
2890
* range of registers. Some devices have certain registers for which a read
2883
2891
* operation read will read from an internal FIFO.
2884
2892
*
@@ -2896,10 +2904,6 @@ int regmap_noinc_read(struct regmap *map, unsigned int reg,
2896
2904
size_t read_len ;
2897
2905
int ret ;
2898
2906
2899
- if (!map -> bus )
2900
- return - EINVAL ;
2901
- if (!map -> bus -> read )
2902
- return - ENOTSUPP ;
2903
2907
if (val_len % map -> format .val_bytes )
2904
2908
return - EINVAL ;
2905
2909
if (!IS_ALIGNED (reg , map -> reg_stride ))
@@ -3013,7 +3017,7 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
3013
3017
if (val_count == 0 )
3014
3018
return - EINVAL ;
3015
3019
3016
- if (map -> bus && map -> format .parse_inplace && (vol || map -> cache_type == REGCACHE_NONE )) {
3020
+ if (map -> format .parse_inplace && (vol || map -> cache_type == REGCACHE_NONE )) {
3017
3021
ret = regmap_raw_read (map , reg , val , val_bytes * val_count );
3018
3022
if (ret != 0 )
3019
3023
return ret ;
0 commit comments