From ecbbe59bbb1cd2973e031c5b6ba28653d66a17de Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Tue, 13 May 2014 11:36:13 +0200 Subject: [PATCH 1/8] drm: Use size_t for blob property sizes size_t is the standard type when dealing with sizes of all kinds. Use it consistently when instantiating DRM blob properties. Signed-off-by: Thierry Reding --- drivers/gpu/drm/drm_crtc.c | 12 +++++++----- include/drm/drm_crtc.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index e79c8d3700d8..d4d783477c99 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -3938,8 +3938,9 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev, return ret; } -static struct drm_property_blob *drm_property_create_blob(struct drm_device *dev, int length, - void *data) +static struct drm_property_blob * +drm_property_create_blob(struct drm_device *dev, size_t length, + void *data) { struct drm_property_blob *blob; int ret; @@ -4023,8 +4024,8 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector, char *path) { struct drm_device *dev = connector->dev; - int ret, size; - size = strlen(path) + 1; + size_t size = strlen(path) + 1; + int ret; connector->path_blob_ptr = drm_property_create_blob(connector->dev, size, path); @@ -4053,7 +4054,8 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector, struct edid *edid) { struct drm_device *dev = connector->dev; - int ret, size; + size_t size; + int ret; /* ignore requests to set edid when overridden */ if (connector->override_edid) diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index c40070a92d6b..628369c08503 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -196,7 +196,7 @@ struct drm_framebuffer { struct drm_property_blob { struct drm_mode_object base; struct list_head head; - unsigned int length; + size_t length; unsigned char data[]; }; From 12e6cecd55e541d3e8110f7dfbb6a601e81733ff Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Tue, 13 May 2014 11:38:36 +0200 Subject: [PATCH 2/8] drm: Use const data when creating blob properties Creating a blob property will always copy the input data so the data that is passed in can be const. Signed-off-by: Thierry Reding --- drivers/gpu/drm/drm_crtc.c | 6 +++--- drivers/gpu/drm/i915/intel_dp_mst.c | 2 +- include/drm/drm_crtc.h | 4 ++-- include/drm/drm_dp_mst_helper.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index d4d783477c99..3ea31bc85263 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -3940,7 +3940,7 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev, static struct drm_property_blob * drm_property_create_blob(struct drm_device *dev, size_t length, - void *data) + const void *data) { struct drm_property_blob *blob; int ret; @@ -4021,7 +4021,7 @@ int drm_mode_getblob_ioctl(struct drm_device *dev, } int drm_mode_connector_set_path_property(struct drm_connector *connector, - char *path) + const char *path) { struct drm_device *dev = connector->dev; size_t size = strlen(path) + 1; @@ -4051,7 +4051,7 @@ EXPORT_SYMBOL(drm_mode_connector_set_path_property); * Zero on success, errno on failure. */ int drm_mode_connector_update_edid_property(struct drm_connector *connector, - struct edid *edid) + const struct edid *edid) { struct drm_device *dev = connector->dev; size_t size; diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c index d9a7a7865f66..eb023d6eafb6 100644 --- a/drivers/gpu/drm/i915/intel_dp_mst.c +++ b/drivers/gpu/drm/i915/intel_dp_mst.c @@ -393,7 +393,7 @@ static void intel_connector_remove_from_fbdev(struct intel_connector *connector) #endif } -static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, char *pathprop) +static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, const char *pathprop) { struct intel_dp *intel_dp = container_of(mgr, struct intel_dp, mst_mgr); struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 628369c08503..ce0dd6c2d73d 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -978,9 +978,9 @@ extern void drm_mode_config_reset(struct drm_device *dev); extern void drm_mode_config_cleanup(struct drm_device *dev); extern int drm_mode_connector_set_path_property(struct drm_connector *connector, - char *path); + const char *path); extern int drm_mode_connector_update_edid_property(struct drm_connector *connector, - struct edid *edid); + const struct edid *edid); static inline bool drm_property_type_is(struct drm_property *property, uint32_t type) diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h index 338fc1053835..fdcd7f271b66 100644 --- a/include/drm/drm_dp_mst_helper.h +++ b/include/drm/drm_dp_mst_helper.h @@ -371,7 +371,7 @@ struct drm_dp_sideband_msg_tx { struct drm_dp_mst_topology_mgr; struct drm_dp_mst_topology_cbs { /* create a connector for a port */ - struct drm_connector *(*add_connector)(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, char *path); + struct drm_connector *(*add_connector)(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, const char *path); void (*destroy_connector)(struct drm_dp_mst_topology_mgr *mgr, struct drm_connector *connector); void (*hotplug)(struct drm_dp_mst_topology_mgr *mgr); From c6a843256a2523c621eb109770c2868ebc29c508 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Thu, 2 Oct 2014 14:45:55 +0200 Subject: [PATCH 3/8] drm/gem: Fix typo in kerneldoc The function being documented is drm_gem_object_handle_free(), not drm_gem_object_free(). Signed-off-by: Thierry Reding --- drivers/gpu/drm/drm_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index f6ca51259fa3..973a9b6644d4 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -188,7 +188,7 @@ drm_gem_remove_prime_handles(struct drm_gem_object *obj, struct drm_file *filp) } /** - * drm_gem_object_free - release resources bound to userspace handles + * drm_gem_object_handle_free - release resources bound to userspace handles * @obj: GEM object to clean up. * * Called after the last handle to the object has been closed From 34eab43ed2483e69bc79fd2e3aaf5adfae771907 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Wed, 4 Jun 2014 09:18:29 +0200 Subject: [PATCH 4/8] drm/prime: Use unsigned type for number of pages The number of pages can never be negative, so an unsigned type is enough. This also matches the type of the n_pages argument of the sg_alloc_table_from_pages() function. Signed-off-by: Thierry Reding --- drivers/gpu/drm/drm_prime.c | 2 +- include/drm/drmP.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 78ca30808422..e15882fd45a3 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -669,7 +669,7 @@ int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data, * the driver is responsible for mapping the pages into the * importers address space for use with dma_buf itself. */ -struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages) +struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages) { struct sg_table *sg = NULL; int ret; diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 53ed87698a74..75b259492a8d 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -986,7 +986,7 @@ extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf); extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages, dma_addr_t *addrs, int max_pages); -extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages); +extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages); extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); From a9e3c90c9fa39ed00e3223dc8f93c9cd12abb750 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Tue, 5 Aug 2014 13:37:47 +0200 Subject: [PATCH 5/8] drm: Implement drm_get_pci_dev() dummy for !PCI Implementing a dummy of this function allows drivers that use it to be built on platforms that don't have PCI. This can happen for example if the nouveau driver is built on Tegra without PCI enabled (or on 64-bit ARM where PCI is not yet implemented). Signed-off-by: Thierry Reding --- include/drm/drmP.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 75b259492a8d..87aac391c605 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -1028,10 +1028,25 @@ void drm_pci_agp_destroy(struct drm_device *dev); extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver); extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver); +#ifdef CONFIG_PCI extern int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent, struct drm_driver *driver); extern int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master); +#else +static inline int drm_get_pci_dev(struct pci_dev *pdev, + const struct pci_device_id *ent, + struct drm_driver *driver) +{ + return -ENOSYS; +} + +static inline int drm_pci_set_busid(struct drm_device *dev, + struct drm_master *master) +{ + return -ENOSYS; +} +#endif #define DRM_PCIE_SPEED_25 1 #define DRM_PCIE_SPEED_50 2 From 2f7633125a1ca8a03b63bf91b5eca60551141ddb Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Mon, 13 Oct 2014 12:45:57 +0200 Subject: [PATCH 6/8] drm: Make drm_mode_create_tv_properties() signature consistent The prototype and the function implementation differ in their signature. Make them consistent and use an unsigned integer for the number of modes while at it. Signed-off-by: Thierry Reding --- drivers/gpu/drm/drm_crtc.c | 7 ++++--- include/drm/drm_crtc.h | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 3ea31bc85263..776ec41b73c9 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -1388,12 +1388,13 @@ EXPORT_SYMBOL(drm_mode_create_dvi_i_properties); * responsible for allocating a list of format names and passing them to * this routine. */ -int drm_mode_create_tv_properties(struct drm_device *dev, int num_modes, +int drm_mode_create_tv_properties(struct drm_device *dev, + unsigned int num_modes, char *modes[]) { struct drm_property *tv_selector; struct drm_property *tv_subconnector; - int i; + unsigned int i; if (dev->mode_config.tv_select_subconnector_property) return 0; @@ -2274,7 +2275,7 @@ static int __setplane_internal(struct drm_plane *plane, { int ret = 0; unsigned int fb_width, fb_height; - int i; + unsigned int i; /* No fb means shut it down */ if (!fb) { diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index ce0dd6c2d73d..48255076d1bd 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1041,8 +1041,9 @@ extern void drm_property_destroy(struct drm_device *dev, struct drm_property *pr extern int drm_property_add_enum(struct drm_property *property, int index, uint64_t value, const char *name); extern int drm_mode_create_dvi_i_properties(struct drm_device *dev); -extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats, - char *formats[]); +extern int drm_mode_create_tv_properties(struct drm_device *dev, + unsigned int num_modes, + char *modes[]); extern int drm_mode_create_scaling_mode_property(struct drm_device *dev); extern int drm_mode_create_aspect_ratio_property(struct drm_device *dev); extern int drm_mode_create_dirty_info_property(struct drm_device *dev); From 8446956ed2e877f8d725d7e3b59cbf35ee1081f0 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Tue, 5 Aug 2014 08:22:48 +0200 Subject: [PATCH 7/8] drm/gma500: mdfld: Reuse video/mipi_display.h The GMA500 driver redefines many constants already found in the generic header. Replace uses of the custom defines by the standard ones and get rid of the duplicate defininitions. Acked-by: Alan Cox Signed-off-by: Thierry Reding --- drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c | 75 ++++++++----------- drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.h | 12 --- 2 files changed, 31 insertions(+), 56 deletions(-) diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c b/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c index 87885d8c06e8..6b43ae3ffd73 100644 --- a/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c +++ b/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c @@ -25,6 +25,7 @@ */ #include +#include