[Intel-gfx] [PATCH v5 1/2] drm/dp: Add a drm_aux-dev module for reading/writing dpcd registers.

kbuild test robot lkp at intel.com
Fri Oct 9 17:49:24 PDT 2015


Hi Rafael,

[auto build test WARNING on drm/drm-next -- if it's inappropriate base, please ignore]

config: mn10300-allyesconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=mn10300 

All warnings (new ones prefixed by >>):

   In file included from include/linux/list.h:8:0,
                    from include/linux/kobject.h:20,
                    from include/linux/device.h:17,
                    from drivers/gpu/drm/drm_dp_aux_dev.c:28:
   drivers/gpu/drm/drm_dp_aux_dev.c: In function 'auxdev_read':
   include/linux/kernel.h:722:17: warning: comparison of distinct pointer types lacks a cast
     (void) (&_min1 == &_min2);  \
                    ^
>> drivers/gpu/drm/drm_dp_aux_dev.c:180:18: note: in expansion of macro 'min'
      ssize_t todo = min(bytes_pending, sizeof(localbuf));
                     ^
   drivers/gpu/drm/drm_dp_aux_dev.c: In function 'auxdev_write':
   include/linux/kernel.h:722:17: warning: comparison of distinct pointer types lacks a cast
     (void) (&_min1 == &_min2);  \
                    ^
   drivers/gpu/drm/drm_dp_aux_dev.c:220:18: note: in expansion of macro 'min'
      ssize_t todo = min(bytes_pending, sizeof(localbuf));
                     ^

vim +/min +180 drivers/gpu/drm/drm_dp_aux_dev.c

    22	 *
    23	 * Authors:
    24	 *    Rafael Antognolli <rafael.antognolli at intel.com>
    25	 *
    26	 */
    27	
  > 28	#include <linux/device.h>
    29	#include <linux/fs.h>
    30	#include <linux/slab.h>
    31	#include <linux/init.h>
    32	#include <linux/kernel.h>
    33	#include <linux/module.h>
    34	#include <asm/uaccess.h>
    35	#include <drm/drm_dp_helper.h>
    36	#include <drm/drm_crtc.h>
    37	
    38	struct drm_dp_aux_dev {
    39		unsigned index;
    40		struct drm_dp_aux *aux;
    41		struct device *dev;
    42		struct kref refcount;
    43		bool removed;
    44		spinlock_t removed_lock;
    45	};
    46	
    47	#define DRM_AUX_MINORS	256
    48	#define AUX_MAX_OFFSET	(1 << 20)
    49	static DEFINE_IDR(aux_idr);
    50	static DEFINE_SPINLOCK(aux_idr_lock);
    51	static struct class *drm_dp_aux_dev_class;
    52	static int drm_dev_major = -1;
    53	
    54	static struct drm_dp_aux_dev *drm_dp_aux_dev_get_by_minor(unsigned index)
    55	{
    56		struct drm_dp_aux_dev *aux_dev = NULL;
    57	
    58		spin_lock(&aux_idr_lock);
    59		aux_dev = idr_find(&aux_idr, index);
    60		if (!kref_get_unless_zero(&aux_dev->refcount))
    61			aux_dev = NULL;
    62		spin_unlock(&aux_idr_lock);
    63	
    64		return aux_dev;
    65	}
    66	
    67	static struct drm_dp_aux_dev *alloc_drm_dp_aux_dev(struct drm_dp_aux *aux)
    68	{
    69		struct drm_dp_aux_dev *aux_dev;
    70		int index;
    71	
    72	
    73		aux_dev = kzalloc(sizeof(*aux_dev), GFP_KERNEL);
    74		if (!aux_dev)
    75			return ERR_PTR(-ENOMEM);
    76		aux_dev->aux = aux;
    77		aux_dev->removed = false;
    78		spin_lock_init(&aux_dev->removed_lock);
    79		kref_init(&aux_dev->refcount);
    80	
    81		idr_preload(GFP_KERNEL);
    82		spin_lock(&aux_idr_lock);
    83		index = idr_alloc_cyclic(&aux_idr, aux_dev, 0, DRM_AUX_MINORS,
    84					 GFP_NOWAIT);
    85		spin_unlock(&aux_idr_lock);
    86		idr_preload_end();
    87		if (index < 0) {
    88			kfree(aux_dev);
    89			return ERR_PTR(-ENOMEM);
    90		}
    91		aux_dev->index = index;
    92	
    93		return aux_dev;
    94	}
    95	
    96	static void free_drm_dp_aux_dev(struct drm_dp_aux_dev *aux_dev)
    97	{
    98		spin_lock(&aux_idr_lock);
    99		idr_remove(&aux_idr, aux_dev->index);
   100		spin_unlock(&aux_idr_lock);
   101		kfree(aux_dev);
   102	}
   103	
   104	static void release_drm_dp_aux_dev(struct kref *ref)
   105	{
   106		int minor;
   107		struct drm_dp_aux_dev *aux_dev =
   108			container_of(ref, struct drm_dp_aux_dev, refcount);
   109		minor = aux_dev->index;
   110		device_destroy(drm_dp_aux_dev_class, MKDEV(drm_dev_major, minor));
   111	
   112		free_drm_dp_aux_dev(aux_dev);
   113	}
   114	
   115	static ssize_t name_show(struct device *dev,
   116				 struct device_attribute *attr, char *buf)
   117	{
   118		ssize_t res;
   119		struct drm_dp_aux_dev *aux_dev =
   120			drm_dp_aux_dev_get_by_minor(MINOR(dev->devt));
   121	
   122		if (!aux_dev)
   123			return -ENODEV;
   124	
   125		res = sprintf(buf, "%s\n", aux_dev->aux->name);
   126		kref_put(&aux_dev->refcount, release_drm_dp_aux_dev);
   127	
   128		return res;
   129	}
   130	static DEVICE_ATTR_RO(name);
   131	
   132	static struct attribute *drm_dp_aux_attrs[] = {
   133		&dev_attr_name.attr,
   134		NULL,
   135	};
   136	ATTRIBUTE_GROUPS(drm_dp_aux);
   137	
   138	static int auxdev_open(struct inode *inode, struct file *file)
   139	{
   140		unsigned int minor = iminor(inode);
   141		struct drm_dp_aux_dev *aux_dev;
   142	
   143		aux_dev = drm_dp_aux_dev_get_by_minor(minor);
   144		if (!aux_dev)
   145			return -ENODEV;
   146	
   147		file->private_data = aux_dev;
   148		return 0;
   149	}
   150	
   151	static loff_t auxdev_llseek(struct file *file, loff_t offset, int whence)
   152	{
   153		return fixed_size_llseek(file, offset, whence, AUX_MAX_OFFSET);
   154	}
   155	
   156	static ssize_t auxdev_read(struct file *file, char __user *buf, size_t count,
   157				   loff_t *offset)
   158	{
   159		size_t bytes_pending, num_bytes_processed = 0;
   160		struct drm_dp_aux_dev *aux_dev = file->private_data;
   161		bool aux_removed;
   162	
   163		if (count < 0)
   164			return -EINVAL;
   165	
   166		spin_lock(&aux_dev->removed_lock);
   167		aux_removed = aux_dev->removed;
   168		spin_unlock(&aux_dev->removed_lock);
   169		if (aux_removed)
   170			return -ENODEV;
   171	
   172		bytes_pending = min((loff_t)count, AUX_MAX_OFFSET - (*offset));
   173	
   174		if (!access_ok(VERIFY_WRITE, buf, bytes_pending))
   175			return -EFAULT;
   176	
   177		while (bytes_pending > 0) {
   178			uint8_t localbuf[DP_AUX_MAX_PAYLOAD_BYTES];
   179			ssize_t res;
 > 180			ssize_t todo = min(bytes_pending, sizeof(localbuf));
   181	
   182			res = drm_dp_dpcd_read(aux_dev->aux, *offset, localbuf, todo);
   183			if (res <= 0)

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 36227 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/dri-devel/attachments/20151010/8a5d919a/attachment-0001.obj>


More information about the dri-devel mailing list