diff options
author | Ashish Singh <assingh@nvidia.com> | 2017-04-19 14:54:46 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-06-06 15:52:04 -0400 |
commit | 116abc54568b8b55e4d73c929076f65fbc03ac30 (patch) | |
tree | ccc00afebb2057dd542af7ef3a02bd67c31b82dc /drivers/i2c | |
parent | a2325ffc01eeea20af0e142ef5bfc5fce8dc47c0 (diff) |
tegra: i2c: camrtc: I2C single driver cleanup
Minor cleanup of i2c single driver code, to remove
not needed functions and add a TIMEOUT macro.
Bug 1837424
Change-Id: If36a96bb2c3a679be292b5c0c0602c8412a6d2ea
Signed-off-by: Ashish Singh <assingh@nvidia.com>
Reviewed-on: http://git-master/r/1466038
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Anna Dvinsky <advinsky@nvidia.com>
Reviewed-by: Jihoon Bang <jbang@nvidia.com>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-camrtc-single.c | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/drivers/i2c/busses/i2c-camrtc-single.c b/drivers/i2c/busses/i2c-camrtc-single.c index 09e286ff3..1878e39cd 100644 --- a/drivers/i2c/busses/i2c-camrtc-single.c +++ b/drivers/i2c/busses/i2c-camrtc-single.c | |||
@@ -32,6 +32,8 @@ | |||
32 | 32 | ||
33 | #define TEGRA_I2C_SINGLE_MAX_DEV 4 | 33 | #define TEGRA_I2C_SINGLE_MAX_DEV 4 |
34 | 34 | ||
35 | #define I2C_CAMRTC_RPC_TIMEOUT_MS 250 | ||
36 | |||
35 | /* Define speed modes */ | 37 | /* Define speed modes */ |
36 | #define I2C_STANDARD_MODE 100000 | 38 | #define I2C_STANDARD_MODE 100000 |
37 | #define I2C_FAST_MODE 400000 | 39 | #define I2C_FAST_MODE 400000 |
@@ -816,7 +818,7 @@ static int tegra_ivc_i2c_add_single( | |||
816 | ivc_dev->rpc_i2c_req.response = &ivc_dev->rpc_i2c_rsp; | 818 | ivc_dev->rpc_i2c_req.response = &ivc_dev->rpc_i2c_rsp; |
817 | ivc_dev->rpc_i2c_req.callback = NULL; | 819 | ivc_dev->rpc_i2c_req.callback = NULL; |
818 | ivc_dev->rpc_i2c_req.callback_param = NULL; | 820 | ivc_dev->rpc_i2c_req.callback_param = NULL; |
819 | ivc_dev->rpc_i2c_req.timeout_ms = 100; | 821 | ivc_dev->rpc_i2c_req.timeout_ms = I2C_CAMRTC_RPC_TIMEOUT_MS; |
820 | ivc_dev->chan->is_ready = true; | 822 | ivc_dev->chan->is_ready = true; |
821 | 823 | ||
822 | atomic_inc(&ivc_dev->in_add_single); | 824 | atomic_inc(&ivc_dev->in_add_single); |
@@ -826,7 +828,7 @@ static int tegra_ivc_i2c_add_single( | |||
826 | fail_remove_chan: | 828 | fail_remove_chan: |
827 | tegra_ivc_rpc_channel_remove(chan); | 829 | tegra_ivc_rpc_channel_remove(chan); |
828 | ivc_dev->is_failed = true; | 830 | ivc_dev->is_failed = true; |
829 | return 0; | 831 | return ret; |
830 | } | 832 | } |
831 | 833 | ||
832 | static void tegra_ivc_i2c_add_single_worker(struct work_struct *work) | 834 | static void tegra_ivc_i2c_add_single_worker(struct work_struct *work) |
@@ -862,33 +864,12 @@ static struct tegra_ivc_rpc_ops tegra_ivc_rpc_user_ops = { | |||
862 | }; | 864 | }; |
863 | 865 | ||
864 | /* Platform device */ | 866 | /* Platform device */ |
865 | static struct platform_device *tegra_i2c_get(struct device *dev) | ||
866 | { | ||
867 | struct device_node *i2c_node; | ||
868 | struct platform_device *i2c_pdev; | ||
869 | |||
870 | i2c_node = of_parse_phandle(dev->of_node, "device", 0); | ||
871 | if (i2c_node == NULL) { | ||
872 | dev_err(dev, "cannot get VI device"); | ||
873 | return ERR_PTR(-ENODEV); | ||
874 | } | ||
875 | |||
876 | i2c_pdev = of_find_device_by_node(i2c_node); | ||
877 | of_node_put(i2c_node); | ||
878 | |||
879 | if (i2c_pdev == NULL) | ||
880 | return ERR_PTR(-EPROBE_DEFER); | ||
881 | |||
882 | return i2c_pdev; | ||
883 | } | ||
884 | |||
885 | static int tegra_ivc_rpc_i2c_single_probe(struct tegra_ivc_channel *chan) | 867 | static int tegra_ivc_rpc_i2c_single_probe(struct tegra_ivc_channel *chan) |
886 | { | 868 | { |
887 | int ret; | 869 | int ret; |
888 | int i; | 870 | int i; |
889 | struct tegra_i2c_ivc_dev *ivc_dev; | 871 | struct tegra_i2c_ivc_dev *ivc_dev; |
890 | struct platform_device *i2c_dev; | 872 | struct device_node *i2c_node; |
891 | struct device_node *np; | ||
892 | 873 | ||
893 | /* Find an empty slot */ | 874 | /* Find an empty slot */ |
894 | for (i = 0; i < TEGRA_I2C_SINGLE_MAX_DEV; ++i) { | 875 | for (i = 0; i < TEGRA_I2C_SINGLE_MAX_DEV; ++i) { |
@@ -899,17 +880,14 @@ static int tegra_ivc_rpc_i2c_single_probe(struct tegra_ivc_channel *chan) | |||
899 | if (i == TEGRA_I2C_SINGLE_MAX_DEV) | 880 | if (i == TEGRA_I2C_SINGLE_MAX_DEV) |
900 | return -ENOMEM; | 881 | return -ENOMEM; |
901 | 882 | ||
902 | i2c_dev = tegra_i2c_get(&chan->dev); | ||
903 | if (IS_ERR(i2c_dev)) { | ||
904 | dev_err(&chan->dev, "Cannot read property device: %ld\n", | ||
905 | PTR_ERR(i2c_dev)); | ||
906 | return PTR_ERR(i2c_dev); | ||
907 | } | ||
908 | |||
909 | np = i2c_dev->dev.of_node; | ||
910 | |||
911 | ivc_dev = g_ivc_devs + i; | 883 | ivc_dev = g_ivc_devs + i; |
912 | 884 | ||
885 | i2c_node = of_parse_phandle(chan->dev.of_node, "device", 0); | ||
886 | if (i2c_node == NULL) { | ||
887 | dev_err(&chan->dev, "Cannot get i2c device node"); | ||
888 | return -ENODEV; | ||
889 | } | ||
890 | |||
913 | /* Read properties */ | 891 | /* Read properties */ |
914 | ret = of_property_read_string(chan->dev.of_node, "nvidia,service", | 892 | ret = of_property_read_string(chan->dev.of_node, "nvidia,service", |
915 | &ivc_dev->name); | 893 | &ivc_dev->name); |
@@ -927,18 +905,19 @@ static int tegra_ivc_rpc_i2c_single_probe(struct tegra_ivc_channel *chan) | |||
927 | } | 905 | } |
928 | 906 | ||
929 | chan->is_ready = false; | 907 | chan->is_ready = false; |
930 | ivc_dev->is_taken = true; | ||
931 | ivc_dev->is_failed = false; | 908 | ivc_dev->is_failed = false; |
932 | ivc_dev->reg_base = tegra_i2c_get_reg_base(np); | 909 | ivc_dev->reg_base = tegra_i2c_get_reg_base(i2c_node); |
933 | ivc_dev->bus_clk_rate = tegra_i2c_get_clk_freq(np); | 910 | ivc_dev->bus_clk_rate = tegra_i2c_get_clk_freq(i2c_node); |
934 | atomic_set(&ivc_dev->in_add_single, 1); | 911 | atomic_set(&ivc_dev->in_add_single, 1); |
935 | ivc_dev->chan = chan; | 912 | ivc_dev->chan = chan; |
936 | tegra_ivc_channel_set_drvdata(chan, ivc_dev); | 913 | tegra_ivc_channel_set_drvdata(chan, ivc_dev); |
937 | INIT_WORK(&ivc_dev->work, tegra_ivc_i2c_add_single_worker); | 914 | INIT_WORK(&ivc_dev->work, tegra_ivc_i2c_add_single_worker); |
915 | ivc_dev->is_taken = true; | ||
938 | 916 | ||
939 | return 0; | 917 | return 0; |
940 | 918 | ||
941 | fail_free_ivc_dev: | 919 | fail_free_ivc_dev: |
920 | devm_kfree(&chan->dev, ivc_dev); | ||
942 | return ret; | 921 | return ret; |
943 | } | 922 | } |
944 | 923 | ||