From owner-svn-src-head@freebsd.org Mon Dec 26 09:48:37 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D2876C8F87A; Mon, 26 Dec 2016 09:48:37 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 85795103F; Mon, 26 Dec 2016 09:48:37 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [62.141.129.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 5F2641FE157; Mon, 26 Dec 2016 10:48:27 +0100 (CET) Subject: Re: svn commit: r310559 - in head/sys/compat/linuxkpi/common: include/linux src To: mmel@freebsd.org, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201612260118.uBQ1I8Dm015288@repo.freebsd.org> From: Hans Petter Selasky Message-ID: <4cd92dee-4cb2-954d-7157-6fcd122131c2@selasky.org> Date: Mon, 26 Dec 2016 10:48:03 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Dec 2016 09:48:37 -0000 On 12/26/16 10:38, Michal Meloun wrote: > > > On 26.12.2016 2:18, Hans Petter Selasky wrote: >> Author: hselasky >> Date: Mon Dec 26 01:18:07 2016 >> New Revision: 310559 >> URL: https://svnweb.freebsd.org/changeset/base/310559 >> >> Log: >> Implement register and unregister chrdev in the LinuxKPI. >> >> Obtained from: kmacy @ >> MFC after: 1 week >> Sponsored by: Mellanox Technologies >> >> Modified: >> head/sys/compat/linuxkpi/common/include/linux/cdev.h >> head/sys/compat/linuxkpi/common/include/linux/fs.h >> head/sys/compat/linuxkpi/common/src/linux_compat.c >> >> Modified: head/sys/compat/linuxkpi/common/include/linux/cdev.h >> ============================================================================== >> --- head/sys/compat/linuxkpi/common/include/linux/cdev.h Sun Dec 25 22:32:16 2016 (r310558) >> +++ head/sys/compat/linuxkpi/common/include/linux/cdev.h Mon Dec 26 01:18:07 2016 (r310559) >> @@ -95,7 +95,7 @@ cdev_add(struct linux_cdev *cdev, dev_t >> args.mda_gid = 0; >> args.mda_mode = 0700; >> args.mda_si_drv1 = cdev; >> - args.mda_unit = MINOR(dev); >> + args.mda_unit = dev; >> >> error = make_dev_s(&args, &cdev->cdev, "%s", >> kobject_name(&cdev->kobj)); >> @@ -121,7 +121,7 @@ cdev_add_ext(struct linux_cdev *cdev, de >> args.mda_gid = gid; >> args.mda_mode = mode; >> args.mda_si_drv1 = cdev; >> - args.mda_unit = MINOR(dev); >> + args.mda_unit = dev; >> >> error = make_dev_s(&args, &cdev->cdev, "%s/%d", >> kobject_name(&cdev->kobj), MINOR(dev)); >> @@ -142,6 +142,8 @@ cdev_del(struct linux_cdev *cdev) >> kobject_put(&cdev->kobj); >> } >> >> +struct linux_cdev *linux_find_cdev(const char *name, unsigned major, unsigned minor); >> + >> #define cdev linux_cdev >> >> #endif /* _LINUX_CDEV_H_ */ >> >> Modified: head/sys/compat/linuxkpi/common/include/linux/fs.h >> ============================================================================== >> --- head/sys/compat/linuxkpi/common/include/linux/fs.h Sun Dec 25 22:32:16 2016 (r310558) >> +++ head/sys/compat/linuxkpi/common/include/linux/fs.h Mon Dec 26 01:18:07 2016 (r310559) >> @@ -2,7 +2,7 @@ >> * Copyright (c) 2010 Isilon Systems, Inc. >> * Copyright (c) 2010 iX Systems, Inc. >> * Copyright (c) 2010 Panasas, Inc. >> - * Copyright (c) 2013 Mellanox Technologies, Ltd. >> + * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. >> * All rights reserved. >> * >> * Redistribution and use in source and binary forms, with or without >> @@ -151,6 +151,39 @@ struct file_operations { >> #define FMODE_WRITE FWRITE >> #define FMODE_EXEC FEXEC >> >> +int __register_chrdev(unsigned int major, unsigned int baseminor, >> + unsigned int count, const char *name, >> + const struct file_operations *fops); >> +int __register_chrdev_p(unsigned int major, unsigned int baseminor, >> + unsigned int count, const char *name, >> + const struct file_operations *fops, uid_t uid, >> + gid_t gid, int mode); >> +void __unregister_chrdev(unsigned int major, unsigned int baseminor, >> + unsigned int count, const char *name); >> + >> +static inline void >> +unregister_chrdev(unsigned int major, const char *name) >> +{ >> + >> + __unregister_chrdev(major, 0, 256, name); >> +} >> + >> +static inline int >> +register_chrdev(unsigned int major, const char *name, >> + const struct file_operations *fops) >> +{ >> + >> + return (__register_chrdev(major, 0, 256, name, fops)); >> +} >> + >> +static inline int >> +register_chrdev_p(unsigned int major, const char *name, >> + const struct file_operations *fops, uid_t uid, gid_t gid, int mode) >> +{ >> + >> + return (__register_chrdev_p(major, 0, 256, name, fops, uid, gid, mode)); >> +} >> + >> static inline int >> register_chrdev_region(dev_t dev, unsigned range, const char *name) >> { >> @@ -184,7 +217,7 @@ static inline dev_t >> iminor(struct inode *inode) >> { >> >> - return dev2unit(inode->v_rdev); >> + return (MINOR(dev2unit(inode->v_rdev))); > > This breaks many kernels: > > --- all_subdir_ibcore --- > In file included from > /usr2/Meloun/svn/src/sys/modules/ibcore/../../ofed/drivers/infiniband/core/ucma.c:34: > In file included from > /usr2/Meloun/svn/src/sys/modules/ibcore/../../compat/linuxkpi/common/include/linux/file.h:41: > /usr2/Meloun/svn/src/sys/modules/ibcore/../../compat/linuxkpi/common/include/linux/fs.h:220:10: error: implicit declaration of function 'MINOR' is invalid in C99 > [-Werror,-Wimplicit-function-declaration] > return (MINOR(dev2unit(inode->v_rdev))); > ^ > I'll fix shortly. --HPS