aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavidlohr Bueso <dave@stgolabs.net>2018-03-26 17:09:24 -0400
committerWolfram Sang <wsa@the-dreams.de>2018-04-03 13:20:26 -0400
commit50888b015d1318a5d76c961f80bab79249cb1000 (patch)
tree60f01ea5e5338572868357b7bacc861509e632a7
parent4a3f7691e2f722421b231d3f3fa05b0a6670a20a (diff)
i2c: Update i2c_trace_msg static key to modern api
No changes in refcount semantics -- key init is false; replace static_key_slow_inc|dec with static_branch_inc|dec static_key_false with static_branch_unlikely Added a '_key' suffix to i2c_trace_msg, for better self documentation. Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Reviewed-by: David Howells <dhowells@redhat.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--drivers/i2c/i2c-core-base.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index a7909d196f4c..1adeebaa81b0 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -69,18 +69,18 @@ static DEFINE_IDR(i2c_adapter_idr);
69 69
70static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver); 70static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver);
71 71
72static struct static_key i2c_trace_msg = STATIC_KEY_INIT_FALSE; 72static DEFINE_STATIC_KEY_FALSE(i2c_trace_msg_key);
73static bool is_registered; 73static bool is_registered;
74 74
75int i2c_transfer_trace_reg(void) 75int i2c_transfer_trace_reg(void)
76{ 76{
77 static_key_slow_inc(&i2c_trace_msg); 77 static_branch_inc(&i2c_trace_msg_key);
78 return 0; 78 return 0;
79} 79}
80 80
81void i2c_transfer_trace_unreg(void) 81void i2c_transfer_trace_unreg(void)
82{ 82{
83 static_key_slow_dec(&i2c_trace_msg); 83 static_branch_dec(&i2c_trace_msg_key);
84} 84}
85 85
86const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id, 86const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,
@@ -1848,11 +1848,12 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
1848 if (adap->quirks && i2c_check_for_quirks(adap, msgs, num)) 1848 if (adap->quirks && i2c_check_for_quirks(adap, msgs, num))
1849 return -EOPNOTSUPP; 1849 return -EOPNOTSUPP;
1850 1850
1851 /* i2c_trace_msg gets enabled when tracepoint i2c_transfer gets 1851 /*
1852 * i2c_trace_msg_key gets enabled when tracepoint i2c_transfer gets
1852 * enabled. This is an efficient way of keeping the for-loop from 1853 * enabled. This is an efficient way of keeping the for-loop from
1853 * being executed when not needed. 1854 * being executed when not needed.
1854 */ 1855 */
1855 if (static_key_false(&i2c_trace_msg)) { 1856 if (static_branch_unlikely(&i2c_trace_msg_key)) {
1856 int i; 1857 int i;
1857 for (i = 0; i < num; i++) 1858 for (i = 0; i < num; i++)
1858 if (msgs[i].flags & I2C_M_RD) 1859 if (msgs[i].flags & I2C_M_RD)
@@ -1871,7 +1872,7 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
1871 break; 1872 break;
1872 } 1873 }
1873 1874
1874 if (static_key_false(&i2c_trace_msg)) { 1875 if (static_branch_unlikely(&i2c_trace_msg_key)) {
1875 int i; 1876 int i;
1876 for (i = 0; i < ret; i++) 1877 for (i = 0; i < ret; i++)
1877 if (msgs[i].flags & I2C_M_RD) 1878 if (msgs[i].flags & I2C_M_RD)