bool port_initialized;
};
-static struct dpi_data dpi_data;
+static struct dpi_data *dpi_get_data_from_dssdev(struct omap_dss_device *dssdev)
+{
+ return container_of(dssdev, struct dpi_data, output);
+}
+
+static struct dpi_data *dpi_get_data_from_pdev(struct platform_device *pdev)
+{
+ return dev_get_drvdata(&pdev->dev);
+}
static struct platform_device *dpi_get_dsidev(enum omap_channel channel)
{
static int dpi_display_enable(struct omap_dss_device *dssdev)
{
- struct dpi_data *dpi = &dpi_data;
+ struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
struct omap_dss_device *out = &dpi->output;
int r;
static void dpi_display_disable(struct omap_dss_device *dssdev)
{
- struct dpi_data *dpi = &dpi_data;
+ struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
struct omap_overlay_manager *mgr = dpi->output.manager;
mutex_lock(&dpi->lock);
static void dpi_set_timings(struct omap_dss_device *dssdev,
struct omap_video_timings *timings)
{
- struct dpi_data *dpi = &dpi_data;
+ struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
DSSDBG("dpi_set_timings\n");
static void dpi_get_timings(struct omap_dss_device *dssdev,
struct omap_video_timings *timings)
{
- struct dpi_data *dpi = &dpi_data;
+ struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
mutex_lock(&dpi->lock);
static int dpi_check_timings(struct omap_dss_device *dssdev,
struct omap_video_timings *timings)
{
- struct dpi_data *dpi = &dpi_data;
+ struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
struct omap_overlay_manager *mgr = dpi->output.manager;
int lck_div, pck_div;
unsigned long fck;
static void dpi_set_data_lines(struct omap_dss_device *dssdev, int data_lines)
{
- struct dpi_data *dpi = &dpi_data;
+ struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
mutex_lock(&dpi->lock);
static int dpi_connect(struct omap_dss_device *dssdev,
struct omap_dss_device *dst)
{
- struct dpi_data *dpi = &dpi_data;
+ struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
struct omap_overlay_manager *mgr;
int r;
static void dpi_init_output(struct platform_device *pdev)
{
- struct dpi_data *dpi = &dpi_data;
+ struct dpi_data *dpi = dpi_get_data_from_pdev(pdev);
struct omap_dss_device *out = &dpi->output;
out->dev = &pdev->dev;
static void __exit dpi_uninit_output(struct platform_device *pdev)
{
- struct dpi_data *dpi = &dpi_data;
+ struct dpi_data *dpi = dpi_get_data_from_pdev(pdev);
struct omap_dss_device *out = &dpi->output;
omapdss_unregister_output(out);
static int omap_dpi_probe(struct platform_device *pdev)
{
- struct dpi_data *dpi = &dpi_data;
+ struct dpi_data *dpi;
+
+ dpi = devm_kzalloc(&pdev->dev, sizeof(*dpi), GFP_KERNEL);
+ if (!dpi)
+ return -ENOMEM;
dpi->pdev = pdev;
int __init dpi_init_port(struct platform_device *pdev, struct device_node *port)
{
- struct dpi_data *dpi = &dpi_data;
+ struct dpi_data *dpi;
struct device_node *ep;
u32 datalines;
int r;
+ dpi = devm_kzalloc(&pdev->dev, sizeof(*dpi), GFP_KERNEL);
+ if (!dpi)
+ return -ENOMEM;
+
ep = omapdss_of_get_next_endpoint(port, NULL);
if (!ep)
return 0;
dpi->port_initialized = true;
+ dev_set_drvdata(&pdev->dev, dpi);
+
return 0;
err_datalines:
return r;
}
-void __exit dpi_uninit_port(void)
+void __exit dpi_uninit_port(struct platform_device *pdev)
{
- struct dpi_data *dpi = &dpi_data;
+ struct dpi_data *dpi = dpi_get_data_from_pdev(pdev);
if (!dpi->port_initialized)
return;