mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 05:31:37 -04:00
drm/tilcdc: Remove the use of drm_device private_data
The DRM core documentation recommends against using dev_private: "Instead of using this pointer it is recommended that drivers use embed the struct &drm_device in their larger per-device structure." This patch refactors the tilcdc driver to follow this recommendation by embedding struct drm_device within struct tilcdc_drm_private and replacing all dev->dev_private accesses with the ddev_to_tilcdc_priv() helper macro that uses container_of(). This change aligns the driver with modern DRM best practices. Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com> Link: https://patch.msgid.link/20260123-feature_tilcdc-v5-17-5a44d2aa3f6f@bootlin.com Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
This commit is contained in:
committed by
Luca Ceresoli
parent
3301302060
commit
968fefee98
@@ -59,7 +59,7 @@ struct tilcdc_crtc {
|
||||
static void set_scanout(struct drm_crtc *crtc, struct drm_framebuffer *fb)
|
||||
{
|
||||
struct drm_device *dev = crtc->dev;
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
struct drm_gem_dma_object *gem;
|
||||
dma_addr_t start, end;
|
||||
u64 dma_base_and_ceiling;
|
||||
@@ -94,7 +94,7 @@ static void tilcdc_crtc_load_palette(struct drm_crtc *crtc)
|
||||
{
|
||||
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
|
||||
struct drm_device *dev = crtc->dev;
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
int ret;
|
||||
|
||||
reinit_completion(&tilcdc_crtc->palette_loaded);
|
||||
@@ -136,7 +136,7 @@ static void tilcdc_crtc_load_palette(struct drm_crtc *crtc)
|
||||
|
||||
static void tilcdc_crtc_enable_irqs(struct drm_device *dev)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
|
||||
tilcdc_clear_irqstatus(dev, 0xffffffff);
|
||||
|
||||
@@ -153,7 +153,7 @@ static void tilcdc_crtc_enable_irqs(struct drm_device *dev)
|
||||
|
||||
static void tilcdc_crtc_disable_irqs(struct drm_device *dev)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
|
||||
/* disable irqs that we might have enabled: */
|
||||
if (priv->rev == 1) {
|
||||
@@ -173,7 +173,7 @@ static void tilcdc_crtc_disable_irqs(struct drm_device *dev)
|
||||
static void reset(struct drm_crtc *crtc)
|
||||
{
|
||||
struct drm_device *dev = crtc->dev;
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
|
||||
if (priv->rev != 2)
|
||||
return;
|
||||
@@ -198,7 +198,7 @@ static unsigned int tilcdc_pclk_diff(unsigned long rate,
|
||||
static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
|
||||
{
|
||||
struct drm_device *dev = crtc->dev;
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
|
||||
unsigned long clk_rate, real_pclk_rate, pclk_rate;
|
||||
unsigned int clkdiv;
|
||||
@@ -270,7 +270,7 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
|
||||
{
|
||||
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
|
||||
struct drm_device *dev = crtc->dev;
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
uint32_t reg, hbp, hfp, hsw, vbp, vfp, vsw;
|
||||
struct drm_display_mode *mode = &crtc->state->adjusted_mode;
|
||||
struct drm_framebuffer *fb = crtc->primary->state->fb;
|
||||
@@ -557,7 +557,7 @@ static void tilcdc_crtc_recover_work(struct work_struct *work)
|
||||
|
||||
void tilcdc_crtc_destroy(struct drm_crtc *crtc)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = crtc->dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(crtc->dev);
|
||||
|
||||
tilcdc_crtc_shutdown(crtc);
|
||||
|
||||
@@ -647,7 +647,7 @@ static int tilcdc_crtc_enable_vblank(struct drm_crtc *crtc)
|
||||
{
|
||||
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
|
||||
struct drm_device *dev = crtc->dev;
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&tilcdc_crtc->irq_lock, flags);
|
||||
@@ -670,7 +670,7 @@ static void tilcdc_crtc_disable_vblank(struct drm_crtc *crtc)
|
||||
{
|
||||
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
|
||||
struct drm_device *dev = crtc->dev;
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&tilcdc_crtc->irq_lock, flags);
|
||||
@@ -728,7 +728,7 @@ static enum drm_mode_status
|
||||
tilcdc_crtc_mode_valid(struct drm_crtc *crtc,
|
||||
const struct drm_display_mode *mode)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = crtc->dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(crtc->dev);
|
||||
unsigned int bandwidth;
|
||||
uint32_t hbp, hfp, hsw, vbp, vfp, vsw;
|
||||
|
||||
@@ -826,7 +826,7 @@ static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
|
||||
void tilcdc_crtc_update_clk(struct drm_crtc *crtc)
|
||||
{
|
||||
struct drm_device *dev = crtc->dev;
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
|
||||
|
||||
drm_modeset_lock(&crtc->mutex, NULL);
|
||||
@@ -850,7 +850,7 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
|
||||
{
|
||||
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
|
||||
struct drm_device *dev = crtc->dev;
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
uint32_t stat, reg;
|
||||
|
||||
stat = tilcdc_read_irqstatus(dev);
|
||||
@@ -958,7 +958,7 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
|
||||
|
||||
int tilcdc_crtc_create(struct drm_device *dev)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
struct tilcdc_crtc *tilcdc_crtc;
|
||||
struct drm_crtc *crtc;
|
||||
int ret;
|
||||
|
||||
@@ -80,7 +80,7 @@ static const struct drm_mode_config_funcs mode_config_funcs = {
|
||||
|
||||
static void modeset_init(struct drm_device *dev)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
|
||||
dev->mode_config.min_width = 0;
|
||||
dev->mode_config.min_height = 0;
|
||||
@@ -106,14 +106,14 @@ static int cpufreq_transition(struct notifier_block *nb,
|
||||
static irqreturn_t tilcdc_irq(int irq, void *arg)
|
||||
{
|
||||
struct drm_device *dev = arg;
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
|
||||
return tilcdc_crtc_irq(priv->crtc);
|
||||
}
|
||||
|
||||
static int tilcdc_irq_install(struct drm_device *dev, unsigned int irq)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
int ret;
|
||||
|
||||
ret = request_irq(irq, tilcdc_irq, 0, dev->driver->name, dev);
|
||||
@@ -127,7 +127,7 @@ static int tilcdc_irq_install(struct drm_device *dev, unsigned int irq)
|
||||
|
||||
static void tilcdc_irq_uninstall(struct drm_device *dev)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
|
||||
if (!priv->irq_enabled)
|
||||
return;
|
||||
@@ -175,7 +175,7 @@ static int tilcdc_regs_show(struct seq_file *m, void *arg)
|
||||
{
|
||||
struct drm_info_node *node = (struct drm_info_node *) m->private;
|
||||
struct drm_device *dev = node->minor->dev;
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
unsigned i;
|
||||
|
||||
pm_runtime_get_sync(dev->dev);
|
||||
@@ -276,7 +276,6 @@ static int tilcdc_pdev_probe(struct platform_device *pdev)
|
||||
|
||||
variant = (uintptr_t)of_device_get_match_data(dev);
|
||||
|
||||
ddev->dev_private = priv;
|
||||
platform_set_drvdata(pdev, priv);
|
||||
ddev = &priv->ddev;
|
||||
ret = drmm_mode_config_init(ddev);
|
||||
|
||||
@@ -85,6 +85,8 @@ struct tilcdc_drm_private {
|
||||
|
||||
#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
|
||||
|
||||
#define ddev_to_tilcdc_priv(x) container_of(x, struct tilcdc_drm_private, ddev)
|
||||
|
||||
int tilcdc_crtc_create(struct drm_device *dev);
|
||||
irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc);
|
||||
void tilcdc_crtc_update_clk(struct drm_crtc *crtc);
|
||||
|
||||
@@ -34,7 +34,7 @@ struct drm_connector *tilcdc_encoder_find_connector(struct drm_device *ddev,
|
||||
static
|
||||
int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = ddev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(ddev);
|
||||
int ret;
|
||||
|
||||
priv->encoder->possible_crtcs = BIT(0);
|
||||
@@ -52,7 +52,7 @@ int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
|
||||
|
||||
int tilcdc_encoder_create(struct drm_device *ddev)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = ddev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(ddev);
|
||||
struct drm_bridge *bridge;
|
||||
struct drm_panel *panel;
|
||||
int ret;
|
||||
|
||||
@@ -101,7 +101,7 @@ static const struct drm_plane_helper_funcs plane_helper_funcs = {
|
||||
int tilcdc_plane_init(struct drm_device *dev,
|
||||
struct drm_plane *plane)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
int ret;
|
||||
|
||||
ret = drm_universal_plane_init(dev, plane, 1, &tilcdc_plane_funcs,
|
||||
|
||||
@@ -113,13 +113,13 @@
|
||||
|
||||
static inline void tilcdc_write(struct drm_device *dev, u32 reg, u32 data)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
iowrite32(data, priv->mmio + reg);
|
||||
}
|
||||
|
||||
static inline void tilcdc_write64(struct drm_device *dev, u32 reg, u64 data)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
volatile void __iomem *addr = priv->mmio + reg;
|
||||
|
||||
#if defined(iowrite64) && !defined(iowrite64_is_nonatomic)
|
||||
@@ -133,7 +133,7 @@ static inline void tilcdc_write64(struct drm_device *dev, u32 reg, u64 data)
|
||||
|
||||
static inline u32 tilcdc_read(struct drm_device *dev, u32 reg)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
return ioread32(priv->mmio + reg);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ static inline void tilcdc_clear(struct drm_device *dev, u32 reg, u32 mask)
|
||||
/* the register to read/clear irqstatus differs between v1 and v2 of the IP */
|
||||
static inline u32 tilcdc_irqstatus_reg(struct drm_device *dev)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = dev->dev_private;
|
||||
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
|
||||
return (priv->rev == 2) ? LCDC_MASKED_STAT_REG : LCDC_STAT_REG;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user