Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: imx335: Handle runtime PM in leaf functions

Simplify .s_stream callback implementation by moving the runtime PM
calls to the leaf functions. This patch should not affect any
functionality.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>

authored by

Jai Luthra and committed by
Hans Verkuil
34af620e d64ec84a

+22 -29
+22 -29
drivers/media/i2c/imx335.c
··· 912 912 const struct imx335_reg_list *reg_list; 913 913 int ret; 914 914 915 + ret = pm_runtime_resume_and_get(imx335->dev); 916 + if (ret < 0) 917 + return ret; 918 + 915 919 /* Setup PLL */ 916 920 reg_list = &link_freq_reglist[__ffs(imx335->link_freq_bitmap)]; 917 921 ret = cci_multi_reg_write(imx335->cci, reg_list->regs, 918 922 reg_list->num_of_regs, NULL); 919 923 if (ret) { 920 924 dev_err(imx335->dev, "%s failed to set plls\n", __func__); 921 - return ret; 925 + goto err_rpm_put; 922 926 } 923 927 924 928 /* Write sensor mode registers */ ··· 931 927 reg_list->num_of_regs, NULL); 932 928 if (ret) { 933 929 dev_err(imx335->dev, "fail to write initial registers\n"); 934 - return ret; 930 + goto err_rpm_put; 935 931 } 936 932 937 933 ret = imx335_set_framefmt(imx335); 938 934 if (ret) { 939 935 dev_err(imx335->dev, "%s failed to set frame format: %d\n", 940 936 __func__, ret); 941 - return ret; 937 + goto err_rpm_put; 942 938 } 943 939 944 940 /* Configure lanes */ 945 941 ret = cci_write(imx335->cci, IMX335_REG_LANEMODE, 946 942 imx335->lane_mode, NULL); 947 943 if (ret) 948 - return ret; 944 + goto err_rpm_put; 949 945 950 946 /* Setup handler will write actual exposure and gain */ 951 947 ret = __v4l2_ctrl_handler_setup(imx335->sd.ctrl_handler); 952 948 if (ret) { 953 949 dev_err(imx335->dev, "fail to setup handler\n"); 954 - return ret; 950 + goto err_rpm_put; 955 951 } 956 952 957 953 /* Start streaming */ ··· 959 955 IMX335_MODE_STREAMING, NULL); 960 956 if (ret) { 961 957 dev_err(imx335->dev, "fail to start streaming\n"); 962 - return ret; 958 + goto err_rpm_put; 963 959 } 964 960 965 961 /* Initial regulator stabilization period */ 966 962 usleep_range(18000, 20000); 967 963 968 964 return 0; 965 + 966 + err_rpm_put: 967 + pm_runtime_put(imx335->dev); 968 + 969 + return ret; 969 970 } 970 971 971 972 /** 972 973 * imx335_stop_streaming() - Stop sensor stream 973 974 * @imx335: pointer to imx335 device 974 - * 975 - * Return: 0 if successful, error code otherwise. 976 975 */ 977 - static int imx335_stop_streaming(struct imx335 *imx335) 976 + static void imx335_stop_streaming(struct imx335 *imx335) 978 977 { 979 - return cci_write(imx335->cci, IMX335_REG_MODE_SELECT, 980 - IMX335_MODE_STANDBY, NULL); 978 + cci_write(imx335->cci, IMX335_REG_MODE_SELECT, 979 + IMX335_MODE_STANDBY, NULL); 980 + pm_runtime_put(imx335->dev); 981 981 } 982 982 983 983 /** ··· 994 986 static int imx335_set_stream(struct v4l2_subdev *sd, int enable) 995 987 { 996 988 struct imx335 *imx335 = to_imx335(sd); 997 - int ret; 989 + int ret = 0; 998 990 999 991 mutex_lock(&imx335->mutex); 1000 992 1001 - if (enable) { 1002 - ret = pm_runtime_resume_and_get(imx335->dev); 1003 - if (ret) 1004 - goto error_unlock; 1005 - 993 + if (enable) 1006 994 ret = imx335_start_streaming(imx335); 1007 - if (ret) 1008 - goto error_power_off; 1009 - } else { 995 + else 1010 996 imx335_stop_streaming(imx335); 1011 - pm_runtime_put(imx335->dev); 1012 - } 1013 997 1014 - mutex_unlock(&imx335->mutex); 1015 - 1016 - return 0; 1017 - 1018 - error_power_off: 1019 - pm_runtime_put(imx335->dev); 1020 - error_unlock: 1021 998 mutex_unlock(&imx335->mutex); 1022 999 1023 1000 return ret;