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

drm/exynos/ipp: simplify ipp_find_driver

The patch puts repeated code sequence into one function, removes verbose
comments and decreases log verbosity.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>

authored by

Andrzej Hajda and committed by
Inki Dae
9cc7d85e 12ff54d2

+21 -53
+21 -53
drivers/gpu/drm/exynos/exynos_drm_ipp.c
··· 174 174 return obj; 175 175 } 176 176 177 - static inline bool ipp_check_dedicated(struct exynos_drm_ippdrv *ippdrv, 178 - enum drm_exynos_ipp_cmd cmd) 177 + static int ipp_check_driver(struct exynos_drm_ippdrv *ippdrv, 178 + struct drm_exynos_ipp_property *property) 179 179 { 180 - /* 181 - * check dedicated flag and WB, OUTPUT operation with 182 - * power on state. 183 - */ 184 - if (ippdrv->dedicated || (!ipp_is_m2m_cmd(cmd) && 185 - !pm_runtime_suspended(ippdrv->dev))) 186 - return true; 180 + if (ippdrv->dedicated || (!ipp_is_m2m_cmd(property->cmd) && 181 + !pm_runtime_suspended(ippdrv->dev))) 182 + return -EBUSY; 187 183 188 - return false; 184 + if (ippdrv->check_property && 185 + ippdrv->check_property(ippdrv->dev, property)) 186 + return -EINVAL; 187 + 188 + return 0; 189 189 } 190 190 191 191 static struct exynos_drm_ippdrv *ipp_find_driver(struct ipp_context *ctx, ··· 193 193 { 194 194 struct exynos_drm_ippdrv *ippdrv; 195 195 u32 ipp_id = property->ipp_id; 196 - 197 - DRM_DEBUG_KMS("ipp_id[%d]\n", ipp_id); 196 + int ret; 198 197 199 198 if (ipp_id) { 200 - /* find ipp driver using idr */ 201 - ippdrv = ipp_find_obj(&ctx->ipp_idr, &ctx->ipp_lock, 202 - ipp_id); 199 + ippdrv = ipp_find_obj(&ctx->ipp_idr, &ctx->ipp_lock, ipp_id); 203 200 if (!ippdrv) { 204 - DRM_ERROR("not found ipp%d driver.\n", ipp_id); 201 + DRM_DEBUG("ipp%d driver not found\n", ipp_id); 205 202 return ERR_PTR(-ENODEV); 206 203 } 207 204 208 - /* 209 - * WB, OUTPUT opertion not supported multi-operation. 210 - * so, make dedicated state at set property ioctl. 211 - * when ipp driver finished operations, clear dedicated flags. 212 - */ 213 - if (ipp_check_dedicated(ippdrv, property->cmd)) { 214 - DRM_ERROR("already used choose device.\n"); 215 - return ERR_PTR(-EBUSY); 216 - } 217 - 218 - /* 219 - * This is necessary to find correct device in ipp drivers. 220 - * ipp drivers have different abilities, 221 - * so need to check property. 222 - */ 223 - if (ippdrv->check_property && 224 - ippdrv->check_property(ippdrv->dev, property)) { 225 - DRM_ERROR("not support property.\n"); 226 - return ERR_PTR(-EINVAL); 205 + ret = ipp_check_driver(ippdrv, property); 206 + if (ret < 0) { 207 + DRM_DEBUG("ipp%d driver check error %d\n", ipp_id, ret); 208 + return ERR_PTR(ret); 227 209 } 228 210 229 211 return ippdrv; 230 212 } else { 231 - /* 232 - * This case is search all ipp driver for finding. 233 - * user application don't set ipp_id in this case, 234 - * so ipp subsystem search correct driver in driver list. 235 - */ 236 213 list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) { 237 - if (ipp_check_dedicated(ippdrv, property->cmd)) { 238 - DRM_DEBUG_KMS("used device.\n"); 239 - continue; 240 - } 241 - 242 - if (ippdrv->check_property && 243 - ippdrv->check_property(ippdrv->dev, property)) { 244 - DRM_DEBUG_KMS("not support property.\n"); 245 - continue; 246 - } 247 - 248 - return ippdrv; 214 + ret = ipp_check_driver(ippdrv, property); 215 + if (ret == 0) 216 + return ippdrv; 249 217 } 250 218 251 - DRM_ERROR("not support ipp driver operations.\n"); 219 + DRM_DEBUG("cannot find driver suitable for given property.\n"); 252 220 } 253 221 254 222 return ERR_PTR(-ENODEV);