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

media: omap3isp: Quit using struct v4l2_subdev.host_priv field

struct v4l2_subdev.host_priv is intended to be used by another driver. This
is hardly good design but back in the days of platform data was a quick
hack to get things done.

As the sub-device specific bus information can be stored to the ISP driver
specific struct allocated along with v4l2_async_subdev, keep the
information there and only there.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

authored by

Sakari Ailus and committed by
Mauro Carvalho Chehab
02b1ce92 7e1db599

+25 -37
+7 -22
drivers/media/platform/omap3isp/isp.c
··· 2188 2188 return -EINVAL; 2189 2189 } 2190 2190 2191 - static int isp_subdev_notifier_bound(struct v4l2_async_notifier *async, 2192 - struct v4l2_subdev *subdev, 2193 - struct v4l2_async_subdev *asd) 2194 - { 2195 - struct isp_async_subdev *isd = 2196 - container_of(asd, struct isp_async_subdev, asd); 2197 - 2198 - isd->sd = subdev; 2199 - isd->sd->host_priv = &isd->bus; 2200 - 2201 - return 0; 2202 - } 2203 - 2204 2191 static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async) 2205 2192 { 2206 2193 struct isp_device *isp = container_of(async, struct isp_device, 2207 2194 notifier); 2208 2195 struct v4l2_device *v4l2_dev = &isp->v4l2_dev; 2209 2196 struct v4l2_subdev *sd; 2210 - struct isp_bus_cfg *bus; 2211 2197 int ret; 2212 2198 2213 2199 ret = media_entity_enum_init(&isp->crashed, &isp->media_dev); ··· 2201 2215 return ret; 2202 2216 2203 2217 list_for_each_entry(sd, &v4l2_dev->subdevs, list) { 2204 - /* Only try to link entities whose interface was set on bound */ 2205 - if (sd->host_priv) { 2206 - bus = (struct isp_bus_cfg *)sd->host_priv; 2207 - ret = isp_link_entity(isp, &sd->entity, bus->interface); 2208 - if (ret < 0) 2209 - return ret; 2210 - } 2218 + if (!sd->asd) 2219 + continue; 2220 + 2221 + ret = isp_link_entity(isp, &sd->entity, 2222 + v4l2_subdev_to_bus_cfg(sd)->interface); 2223 + if (ret < 0) 2224 + return ret; 2211 2225 } 2212 2226 2213 2227 ret = v4l2_device_register_subdev_nodes(&isp->v4l2_dev); ··· 2385 2399 if (ret < 0) 2386 2400 goto error_register_entities; 2387 2401 2388 - isp->notifier.bound = isp_subdev_notifier_bound; 2389 2402 isp->notifier.complete = isp_subdev_notifier_complete; 2390 2403 2391 2404 ret = v4l2_async_notifier_register(&isp->v4l2_dev, &isp->notifier);
+3 -1
drivers/media/platform/omap3isp/isp.h
··· 226 226 }; 227 227 228 228 struct isp_async_subdev { 229 - struct v4l2_subdev *sd; 230 229 struct isp_bus_cfg bus; 231 230 struct v4l2_async_subdev asd; 232 231 }; 232 + 233 + #define v4l2_subdev_to_bus_cfg(sd) \ 234 + (&container_of((sd)->asd, struct isp_async_subdev, asd)->bus) 233 235 234 236 #define v4l2_dev_to_isp_device(dev) \ 235 237 container_of(dev, struct isp_device, v4l2_dev)
+9 -7
drivers/media/platform/omap3isp/ispccdc.c
··· 1139 1139 pad = media_entity_remote_pad(&ccdc->pads[CCDC_PAD_SINK]); 1140 1140 sensor = media_entity_to_v4l2_subdev(pad->entity); 1141 1141 if (ccdc->input == CCDC_INPUT_PARALLEL) { 1142 - parcfg = &((struct isp_bus_cfg *)sensor->host_priv) 1143 - ->bus.parallel; 1142 + struct v4l2_subdev *sd = 1143 + to_isp_pipeline(&ccdc->subdev.entity)->external; 1144 + 1145 + parcfg = &v4l2_subdev_to_bus_cfg(sd)->bus.parallel; 1144 1146 ccdc->bt656 = parcfg->bt656; 1145 1147 } 1146 1148 ··· 2414 2412 2415 2413 /* We've got a parallel sensor here. */ 2416 2414 if (ccdc->input == CCDC_INPUT_PARALLEL) { 2417 - struct isp_parallel_cfg *parcfg = 2418 - &((struct isp_bus_cfg *) 2419 - media_entity_to_v4l2_subdev(link->source->entity) 2420 - ->host_priv)->bus.parallel; 2421 - parallel_shift = parcfg->data_lane_shift; 2415 + struct v4l2_subdev *sd = 2416 + media_entity_to_v4l2_subdev(link->source->entity); 2417 + struct isp_bus_cfg *bus_cfg = v4l2_subdev_to_bus_cfg(sd); 2418 + 2419 + parallel_shift = bus_cfg->bus.parallel.data_lane_shift; 2422 2420 } else { 2423 2421 parallel_shift = 0; 2424 2422 }
+2 -1
drivers/media/platform/omap3isp/ispccp2.c
··· 350 350 */ 351 351 static int ccp2_if_configure(struct isp_ccp2_device *ccp2) 352 352 { 353 + struct isp_pipeline *pipe = to_isp_pipeline(&ccp2->subdev.entity); 353 354 const struct isp_bus_cfg *buscfg; 354 355 struct v4l2_mbus_framefmt *format; 355 356 struct media_pad *pad; ··· 362 361 363 362 pad = media_entity_remote_pad(&ccp2->pads[CCP2_PAD_SINK]); 364 363 sensor = media_entity_to_v4l2_subdev(pad->entity); 365 - buscfg = sensor->host_priv; 364 + buscfg = v4l2_subdev_to_bus_cfg(pipe->external); 366 365 367 366 ret = ccp2_phyif_config(ccp2, &buscfg->bus.ccp2); 368 367 if (ret < 0)
+1 -1
drivers/media/platform/omap3isp/ispcsi2.c
··· 566 566 567 567 pad = media_entity_remote_pad(&csi2->pads[CSI2_PAD_SINK]); 568 568 sensor = media_entity_to_v4l2_subdev(pad->entity); 569 - buscfg = sensor->host_priv; 569 + buscfg = v4l2_subdev_to_bus_cfg(pipe->external); 570 570 571 571 csi2->frame_skip = 0; 572 572 v4l2_subdev_call(sensor, sensor, g_skip_frames, &csi2->frame_skip);
+3 -5
drivers/media/platform/omap3isp/ispcsiphy.c
··· 165 165 static int omap3isp_csiphy_config(struct isp_csiphy *phy) 166 166 { 167 167 struct isp_pipeline *pipe = to_isp_pipeline(phy->entity); 168 - struct isp_async_subdev *isd = 169 - container_of(pipe->external->asd, struct isp_async_subdev, asd); 170 - struct isp_bus_cfg *buscfg = pipe->external->host_priv ? 171 - pipe->external->host_priv : &isd->bus; 168 + struct isp_bus_cfg *buscfg = v4l2_subdev_to_bus_cfg(pipe->external); 172 169 struct isp_csiphy_lanes_cfg *lanes; 173 170 int csi2_ddrclk_khz; 174 171 unsigned int num_data_lanes, used_lanes = 0; ··· 308 311 mutex_lock(&phy->mutex); 309 312 if (phy->entity) { 310 313 struct isp_pipeline *pipe = to_isp_pipeline(phy->entity); 311 - struct isp_bus_cfg *buscfg = pipe->external->host_priv; 314 + struct isp_bus_cfg *buscfg = 315 + v4l2_subdev_to_bus_cfg(pipe->external); 312 316 313 317 csiphy_routing_cfg(phy, buscfg->interface, false, 314 318 buscfg->bus.ccp2.phy_layer);