[packages/linux-gpib] - fix building with kernel 5.0

baggins baggins at pld-linux.org
Sun Mar 10 19:07:05 CET 2019


commit 16f001016aa92189397e7f121fecc07aadef8988
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sun Mar 10 18:55:17 2019 +0100

    - fix building with kernel 5.0

 kernel-4.11.patch             |  13 -
 kernel-4.15.patch             | 676 ------------------------------------------
 kernel-5.0.patch              |  38 +++
 linux-gpib-destdir.patch      |  37 ---
 linux-gpib-include_file.patch |  22 --
 linux-gpib.spec               |  54 ++--
 6 files changed, 70 insertions(+), 770 deletions(-)
---
diff --git a/linux-gpib.spec b/linux-gpib.spec
index 903541e..df82614 100644
--- a/linux-gpib.spec
+++ b/linux-gpib.spec
@@ -33,26 +33,23 @@ exit 1
 %include	/usr/lib/rpm/macros.perl
 %define		php_name	php%{?php_suffix}
 
-%define		rel	3
+%define		rel	0.1
 %define		pname	linux-gpib
 Summary:	GPIB (IEEE 488) Linux support
 Summary(pl.UTF-8):	Obsługa GPIB (IEEE 488) dla Linuksa
 Name:		%{pname}%{?_pld_builder:%{?with_kernel:-kernel}}%{_alt_kernel}
-Version:	4.1.0
+Version:	4.2.0
 Release:	%{rel}%{?_pld_builder:%{?with_kernel:@%{_kernel_ver_str}}}
 License:	GPL v2+
 Group:		Applications/System
 Source0:	http://downloads.sourceforge.net/linux-gpib/%{pname}-%{version}.tar.gz
-# Source0-md5:	2614bb6dcfde4bf01f6047fdf0ea021f
-Patch0:		%{pname}-include_file.patch
-Patch1:		%{pname}-destdir.patch
+# Source0-md5:	0241dcc2d16f6d12a7aa2c3a623a55ff
 Patch2:		%{pname}-python.patch
 Patch3:		%{pname}-perl.patch
 Patch4:		%{pname}-firmwaredir.patch
 Patch5:		%{pname}-guile2.patch
 Patch6:		%{pname}-php7.patch
-Patch7:		kernel-4.11.patch
-Patch8:		kernel-4.15.patch
+Patch7:		kernel-5.0.patch
 URL:		http://linux-gpib.sourceforge.net/
 BuildRequires:	autoconf >= 2.50
 BuildRequires:	automake
@@ -240,8 +237,16 @@ Ten pakiet zawiera sterowniki dla Linuksa do urządzeń GPIB (IEEE 488).\
 %{nil}
 
 %define build_kernel_pkg()\
-TOPDIR=$(pwd)\
-%build_kernel_modules -C drivers/gpib -m gpib -- EARLYCPPFLAGS="-I$TOPDIR -I$TOPDIR/drivers/gpib/include -I$TOPDIR/include"\
+%configure \\\
+	%{?with_drivers_isa:--enable-isa} \\\
+	%{?with_drivers_pcmcia:--enable-pcmcia} \\\
+	%{!?with_docs:--disable-documentation} \\\
+	%{!?with_guile:--disable-guile-binding} \\\
+	%{!?with_perl:--disable-perl-binding} \\\
+	%{!?with_python:--disable-python-binding} \\\
+	%{!?with_tcl:--disable-tcl-binding} \\\
+	--with-linux-srcdir=%{_kernelsrcdir}\
+%{__make}\
 cd drivers/gpib\
 %install_kernel_modules -D installed -m agilent_82350b/agilent_82350b,cb7210/cb7210,cec/cec_gpib,hp_82335/hp82335,hp_82341/hp_82341,ines/ines_gpib,nec7210/nec7210,sys/gpib_common,tms9914/tms9914,tnt4882/tnt4882%{?with_drivers_isa:,pc2/pc2_gpib}%{?with_drivers_usb:,agilent_82357a/agilent_82357a,lpvo_usb_gpib/lpvo_usb_gpib,ni_usb/ni_usb_gpib} -d kernel/gpib\
 cd ../..\
@@ -254,15 +259,21 @@ cd ../..\
 
 %prep
 %setup -q -n %{pname}-%{version}
-%patch0 -p1
-%patch1 -p1
+%if %{with userspace}
+tar xzf linux-gpib-user-%{version}.tar.gz
+cd linux-gpib-user-%{version}
 %patch2 -p1
 %patch3 -p1
 %patch4 -p1
 %patch5 -p1
-%patch6 -p1
+#%patch6 -p1
+cd ..
+%endif
+
+%if %{with kernel}
+tar xzf linux-gpib-kernel-%{version}.tar.gz
+cd linux-gpib-kernel-%{version}
 %patch7 -p1
-%patch8 -p1
 
 # disable modules build by default, just install userspace header
 echo 'SUBDIRS = gpib/include' > drivers/Makefile.am
@@ -271,13 +282,11 @@ echo 'SUBDIRS = gpib/include' > drivers/Makefile.am
 for f in drivers/gpib/*/Makefile ; do
 echo 'override CC += $(EARLYCPPFLAGS)' >> $f
 done
+%endif
 
 %build
-%{__libtoolize}
-%{__aclocal} -I m4
-%{__autoconf}
-%{__autoheader}
-%{__automake}
+%if %{with userspace}
+cd linux-gpib-user-%{version}
 %if %{with guile}
 CPPFLAGS="%{rpmcppflags} -I/usr/include/guile/2.0"
 %endif
@@ -290,14 +299,14 @@ CPPFLAGS="%{rpmcppflags} -I/usr/include/guile/2.0"
 	%{!?with_php:--disable-php-binding} \
 	%{!?with_python:--disable-python-binding} \
 	%{?with_static_libs:--enable-static} \
-	%{!?with_tcl:--disable-tcl-binding} \
-	--with-linux-srcdir=%{_kernelsrcdir}
+	%{!?with_tcl:--disable-tcl-binding}
 
-%if %{with userspace}
 %{__make}
+cd ..
 %endif
 
 %if %{with kernel}
+cd linux-gpib-kernel-%{version}
 %{expand:%build_kernel_packages}
 %endif
 
@@ -306,12 +315,13 @@ rm -rf $RPM_BUILD_ROOT
 install -d $RPM_BUILD_ROOT%{_examplesdir}
 
 %if %{with kernel}
+cd linux-gpib-kernel-%{version}
 %{expand:%install_kernel_packages}
 cp -a drivers/gpib/installed/* $RPM_BUILD_ROOT
 %endif
 
 %if %{with userspace}
-%{__make} install \
+%{__make} -C linux-gpib-user-%{version} install \
 	DESTDIR=$RPM_BUILD_ROOT \
 	HOTPLUG_USB_CONF_DIR=/lib/udev \
 	UDEV_RULES_DIR=/lib/udev/rules.d \
diff --git a/kernel-4.11.patch b/kernel-4.11.patch
deleted file mode 100644
index 46f98cb..0000000
--- a/kernel-4.11.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff -ur linux-gpib-4.0.3/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c linux-gpib-4.0.3-4.11/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
---- linux-gpib-4.0.3/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c	2016-04-09 15:33:13.000000000 +0200
-+++ linux-gpib-4.0.3-4.11/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c	2017-05-10 07:38:40.555593617 +0200
-@@ -26,6 +26,9 @@
- #include <linux/version.h>
- #include <linux/module.h>
- #include <linux/sched.h>
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
-+#include <linux/sched/signal.h>
-+#endif
- #include <linux/init.h>
- #include <linux/kernel.h>
- #include <linux/tty.h>
diff --git a/kernel-4.15.patch b/kernel-4.15.patch
deleted file mode 100644
index e5b435a..0000000
--- a/kernel-4.15.patch
+++ /dev/null
@@ -1,676 +0,0 @@
-diff -ur linux-gpib-4.1.0/drivers/gpib/agilent_82357a/agilent_82357a.c linux-gpib-4.1.0-k415/drivers/gpib/agilent_82357a/agilent_82357a.c
---- linux-gpib-4.1.0/drivers/gpib/agilent_82357a/agilent_82357a.c	2017-01-16 10:26:30.000000000 +0100
-+++ linux-gpib-4.1.0-k415/drivers/gpib/agilent_82357a/agilent_82357a.c	2018-01-29 20:55:10.341502118 +0100
-@@ -42,9 +42,16 @@
- 	up(&context->complete);
- }
- 
-+#ifdef HAVE_TIMER_SETUP
-+static void agilent_82357a_timeout_handler(struct timer_list *t)
-+{
-+	agilent_82357a_private_t *a_priv = from_timer(a_priv, t, bulk_timer);
-+#else
- static void agilent_82357a_timeout_handler(unsigned long arg)
- {
--	agilent_82357a_urb_context_t *context = (agilent_82357a_urb_context_t *) arg;
-+	agilent_82357a_private_t *a_priv = (agilent_82357a_private_t *) arg;
-+#endif
-+	agilent_82357a_urb_context_t *context = &a_priv->context;
- 	context->timed_out = 1;
- 	up(&context->complete);
- }
-@@ -55,8 +62,7 @@
- 	struct usb_device *usb_dev;
- 	int retval;
- 	unsigned int out_pipe;
--	agilent_82357a_urb_context_t context;
--	struct timer_list *timer = NULL;
-+	agilent_82357a_urb_context_t *context = &a_priv->context;
- 
- 	*actual_data_length = 0;
- 	retval = mutex_lock_interruptible(&a_priv->bulk_alloc_lock);
-@@ -79,25 +85,14 @@
- 	}
- 	usb_dev = interface_to_usbdev(a_priv->bus_interface);
- 	out_pipe = usb_sndbulkpipe(usb_dev, a_priv->bulk_out_endpoint);
--	sema_init(&context.complete, 0);
--	context.timed_out = 0;
-+	sema_init(&context->complete, 0);
-+	context->timed_out = 0;
- 	usb_fill_bulk_urb(a_priv->bulk_urb, usb_dev, out_pipe, data, data_length,
--		&agilent_82357a_bulk_complete, &context);
-+		&agilent_82357a_bulk_complete, context);
-+
- 	if(timeout_msecs)
--	{
--		timer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
--		if(timer == NULL)
--		{
--			mutex_unlock(&a_priv->bulk_alloc_lock);
--			retval = -ENOMEM;
--			goto cleanup;
--		}
--		init_timer(timer);
--		timer->expires = jiffies + msecs_to_jiffies(timeout_msecs);
--		timer->function = agilent_82357a_timeout_handler;
--		timer->data = (unsigned long) &context;
--		add_timer(timer);
--	}
-+		mod_timer(&a_priv->bulk_timer, jiffies + msecs_to_jiffies(timeout_msecs));
-+
- 	//printk("%s: submitting urb\n", __FUNCTION__);
- 	retval = usb_submit_urb(a_priv->bulk_urb, GFP_KERNEL);
- 	if(retval)
-@@ -107,13 +102,13 @@
- 		goto cleanup;
- 	}
- 	mutex_unlock(&a_priv->bulk_alloc_lock);
--	if(down_interruptible(&context.complete))
-+	if(down_interruptible(&context->complete))
- 	{
- 		printk("%s: %s: interrupted\n", __FILE__, __FUNCTION__);
- 		retval = -ERESTARTSYS;
- 		goto cleanup;
- 	}
--	if(context.timed_out)
-+	if(context->timed_out)
- 	{
- 		retval = -ETIMEDOUT;
- 	}else
-@@ -122,11 +117,10 @@
- 		*actual_data_length = a_priv->bulk_urb->actual_length;
- 	}
- cleanup:
--	if(timer)
-+	if(timeout_msecs)
- 	{
--		if(timer_pending(timer))
--			del_timer_sync(timer);
--		kfree(timer);
-+		if(timer_pending(&a_priv->bulk_timer))
-+			del_timer_sync(&a_priv->bulk_timer);
- 	}
- 	mutex_lock(&a_priv->bulk_alloc_lock);
- 	if(a_priv->bulk_urb)
-@@ -145,8 +139,7 @@
- 	struct usb_device *usb_dev;
- 	int retval;
- 	unsigned int in_pipe;
--	agilent_82357a_urb_context_t context;
--	struct timer_list *timer = NULL;
-+	agilent_82357a_urb_context_t *context = &a_priv->context;
- 
- 	*actual_data_length = 0;
- 	retval = mutex_lock_interruptible(&a_priv->bulk_alloc_lock);
-@@ -169,25 +162,14 @@
- 	}
- 	usb_dev = interface_to_usbdev(a_priv->bus_interface);
- 	in_pipe = usb_rcvbulkpipe(usb_dev, AGILENT_82357_BULK_IN_ENDPOINT);
--	sema_init(&context.complete, 0);
--	context.timed_out = 0;
-+	sema_init(&context->complete, 0);
-+	context->timed_out = 0;
- 	usb_fill_bulk_urb(a_priv->bulk_urb, usb_dev, in_pipe, data, data_length,
--		&agilent_82357a_bulk_complete, &context);
-+		&agilent_82357a_bulk_complete, context);
-+
- 	if(timeout_msecs)
--	{
--		timer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
--		if(timer == NULL)
--		{
--			retval = -ENOMEM;
--			mutex_unlock(&a_priv->bulk_alloc_lock);
--			goto cleanup;
--		}
--		init_timer(timer);
--		timer->expires = jiffies + msecs_to_jiffies(timeout_msecs);
--		timer->function = agilent_82357a_timeout_handler;
--		timer->data = (unsigned long) &context;
--		add_timer(timer);
--	}
-+		mod_timer(&a_priv->bulk_timer, jiffies + msecs_to_jiffies(timeout_msecs));
-+
- 	//printk("%s: submitting urb\n", __FUNCTION__);
- 	retval = usb_submit_urb(a_priv->bulk_urb, GFP_KERNEL);
- 	if(retval)
-@@ -197,13 +179,13 @@
- 		goto cleanup;
- 	}
- 	mutex_unlock(&a_priv->bulk_alloc_lock);
--	if(down_interruptible(&context.complete))
-+	if(down_interruptible(&context->complete))
- 	{
- 		printk("%s: %s: interrupted\n", __FILE__, __FUNCTION__);
- 		retval = -ERESTARTSYS;
- 		goto cleanup;
- 	}
--	if(context.timed_out)
-+	if(context->timed_out)
- 	{
- 		retval = -ETIMEDOUT;
- 		goto cleanup;
-@@ -211,14 +193,9 @@
- 	retval = a_priv->bulk_urb->status;
- 	*actual_data_length = a_priv->bulk_urb->actual_length;
- cleanup:
--	if(timer)
--	{
--		if(timer_pending(timer))
--		{
--			del_timer_sync(timer);
--		}
--		kfree(timer);
--	}
-+	if(timeout_msecs)
-+		del_timer_sync(&a_priv->bulk_timer);
-+
- 	mutex_lock(&a_priv->bulk_alloc_lock);
- 	if(a_priv->bulk_urb)
- 	{
-@@ -1351,13 +1328,22 @@
- 		return retval;
- 	}
- 	//printk("%s: finished setup_urbs()()\n", __FUNCTION__);
-+
-+#ifdef HAVE_TIMER_SETUP
-+	timer_setup(&a_priv->bulk_timer, agilent_82357a_timeout_handler, 0);
-+#else
-+	setup_timer(&a_priv->bulk_timer, agilent_82357a_timeout_handler, (unsigned long) a_priv);
-+#endif
-+
- 	retval = agilent_82357a_init(board);
-+
- 	if(retval < 0)
- 	{
- 		mutex_unlock(&agilent_82357a_hotplug_lock);
- 		return retval;
- 	}
- 	//printk("%s: finished init()\n", __FUNCTION__);
-+
- 	printk("%s: attached\n", __FUNCTION__);
- 	mutex_unlock(&agilent_82357a_hotplug_lock);
- 	return retval;
-diff -ur linux-gpib-4.1.0/drivers/gpib/agilent_82357a/agilent_82357a.h linux-gpib-4.1.0-k415/drivers/gpib/agilent_82357a/agilent_82357a.h
---- linux-gpib-4.1.0/drivers/gpib/agilent_82357a/agilent_82357a.h	2017-01-16 09:31:39.000000000 +0100
-+++ linux-gpib-4.1.0-k415/drivers/gpib/agilent_82357a/agilent_82357a.h	2018-01-29 20:55:10.341502118 +0100
-@@ -19,6 +19,7 @@
- #ifndef _AGILENT_82357_H
- #define _AGILENT_82357_H
- 
-+#include <linux/kernel.h>
- #include <linux/mutex.h>
- #include <linux/semaphore.h>
- #include <linux/usb.h>
-@@ -140,6 +141,12 @@
- #define STATUS_DATA_LEN 8
- #define INTERRUPT_BUF_LEN 8
- 
-+typedef struct
-+{
-+	struct semaphore complete;
-+	unsigned timed_out : 1;
-+} agilent_82357a_urb_context_t ;
-+
- // struct which defines local data for each 82357 device
- typedef struct
- {
-@@ -155,17 +162,14 @@
- 	struct mutex bulk_alloc_lock;
- 	struct mutex interrupt_alloc_lock;
- 	struct mutex control_alloc_lock;
-+	struct timer_list bulk_timer;
-+        agilent_82357a_urb_context_t context;
- 	unsigned bulk_out_endpoint;
- 	unsigned interrupt_in_endpoint;
-         uint8_t *status_data;
- 	unsigned is_cic : 1;
- } agilent_82357a_private_t;
- 
--typedef struct
--{
--	struct semaphore complete;
--	unsigned timed_out : 1;
--} agilent_82357a_urb_context_t;
- 
- struct agilent_82357a_register_pairlet
- {
-diff -ur linux-gpib-4.1.0/drivers/gpib/include/gpib_proto.h linux-gpib-4.1.0-k415/drivers/gpib/include/gpib_proto.h
---- linux-gpib-4.1.0/drivers/gpib/include/gpib_proto.h	2016-06-22 10:48:46.000000000 +0200
-+++ linux-gpib-4.1.0-k415/drivers/gpib/include/gpib_proto.h	2018-01-29 20:55:10.341502118 +0100
-@@ -9,7 +9,7 @@
- long ibioctl(struct file *filep, unsigned int cmd, unsigned long arg );
- int osInit( void );
- void osReset( void );
--void watchdog_timeout( unsigned long arg );
-+//void watchdog_timeout( struct timer_list *t );
- void osStartTimer( gpib_board_t *board, unsigned int usec_timeout );
- void osRemoveTimer( gpib_board_t *board );
- void osSendEOI( void );
-diff -ur linux-gpib-4.1.0/drivers/gpib/include/gpib_types.h linux-gpib-4.1.0-k415/drivers/gpib/include/gpib_types.h
---- linux-gpib-4.1.0/drivers/gpib/include/gpib_types.h	2018-01-29 21:01:19.642149223 +0100
-+++ linux-gpib-4.1.0-k415/drivers/gpib/include/gpib_types.h	2018-01-29 20:55:10.344835496 +0100
-@@ -32,6 +32,10 @@
- #include <linux/timer.h>
- #include <linux/interrupt.h>
- 
-+#if defined(timer_setup) && defined(from_timer)
-+#define HAVE_TIMER_SETUP
-+#endif
-+
- typedef struct gpib_interface_struct gpib_interface_t;
- typedef struct gpib_board_struct gpib_board_t;
- 
-@@ -157,14 +161,21 @@
- {
- 	struct timer_list timer;
- 	irqreturn_t (*handler)(int, void * PT_REGS_ARG);
-+	gpib_board_t *board;
- 	atomic_t active;
- };
- 
- static inline void init_gpib_pseudo_irq( struct gpib_pseudo_irq *pseudo_irq)
- {
- 	pseudo_irq->handler = NULL;
--	init_timer(&pseudo_irq->timer);
-+#ifdef HAVE_TIMER_SETUP
-+	timer_setup(&pseudo_irq->timer, NULL, 0);
-+#else
-+	setup_timer(&pseudo_irq->timer, NULL, (unsigned long)pseudo_irq);
-+#endif
-+	smp_mb__before_atomic();
- 	atomic_set(&pseudo_irq->active, 0);
-+	smp_mb__after_atomic();
- }
- 
- /* list so we can make a linked list of drivers */
-diff -ur linux-gpib-4.1.0/drivers/gpib/ni_usb/ni_usb_gpib.c linux-gpib-4.1.0-k415/drivers/gpib/ni_usb/ni_usb_gpib.c
---- linux-gpib-4.1.0/drivers/gpib/ni_usb/ni_usb_gpib.c	2017-09-02 19:29:49.000000000 +0200
-+++ linux-gpib-4.1.0-k415/drivers/gpib/ni_usb/ni_usb_gpib.c	2018-01-29 20:55:10.341502118 +0100
-@@ -81,9 +81,16 @@
- 	up(&context->complete);
- }
- 
--static void ni_usb_timeout_handler(unsigned long arg)
-+#ifdef HAVE_TIMER_SETUP
-+static void ni_usb_timeout_handler(struct timer_list *t)
- {
--	ni_usb_urb_context_t *context = (ni_usb_urb_context_t *) arg;
-+	ni_usb_private_t *ni_priv = from_timer(ni_priv, t, bulk_timer);
-+#else
-+static void ni_usb_timeout_handler (unsigned long arg)
-+{
-+	ni_usb_private_t *ni_priv = (ni_usb_private_t *) arg;
-+#endif
-+	ni_usb_urb_context_t *context = &ni_priv->context;
- 	context->timed_out = 1;
- 	up(&context->complete);
- };
-@@ -94,8 +101,7 @@
- 	struct usb_device *usb_dev;
- 	int retval;
- 	unsigned int out_pipe;
--	ni_usb_urb_context_t context;
--	struct timer_list timer;
-+	ni_usb_urb_context_t *context = &ni_priv->context;
- 
- 	*actual_data_length = 0;
- 	mutex_lock(&ni_priv->bulk_transfer_lock);
-@@ -117,24 +123,19 @@
- 	}
- 	usb_dev = interface_to_usbdev(ni_priv->bus_interface);
- 	out_pipe = usb_sndbulkpipe(usb_dev, ni_priv->bulk_out_endpoint);
--	sema_init(&context.complete, 0);
--	context.timed_out = 0;
-+	sema_init(&context->complete, 0);
-+	context->timed_out = 0;
- 	usb_fill_bulk_urb(ni_priv->bulk_urb, usb_dev, out_pipe, data, data_length,
--		&ni_usb_bulk_complete, &context);
--	init_timer(&timer);
-+		&ni_usb_bulk_complete, context);
-+
- 	if(timeout_msecs)
--	{
--		timer.expires = jiffies + msecs_to_jiffies(timeout_msecs);
--		timer.function = ni_usb_timeout_handler;
--		timer.data = (unsigned long) &context;
--		add_timer(&timer);
--	}
-+		mod_timer(&ni_priv->bulk_timer, jiffies + msecs_to_jiffies(timeout_msecs));
-+
- 	//printk("%s: submitting urb\n", __FUNCTION__);
- 	retval = usb_submit_urb(ni_priv->bulk_urb, GFP_KERNEL);
- 	if(retval)
- 	{
--		if(timer_pending(&timer))
--			del_timer_sync(&timer);
-+		del_timer_sync(&ni_priv->bulk_timer);
- 		usb_free_urb(ni_priv->bulk_urb);
- 		ni_priv->bulk_urb = NULL;
- 		printk("%s: failed to submit bulk out urb, retval=%i\n", __FILE__, retval);
-@@ -142,16 +143,16 @@
- 		return retval;
- 	}
- 	mutex_unlock(&ni_priv->bulk_transfer_lock);
--	down(&context.complete);    // wait for ni_usb_bulk_complete
--	if(context.timed_out)
-+	down(&context->complete);    // wait for ni_usb_bulk_complete
-+	if(context->timed_out)
- 	{
- 		usb_kill_urb(ni_priv->bulk_urb);
- 		printk("%s: killed urb due to timeout\n", __FUNCTION__);
- 		retval = -ETIMEDOUT;
- 	}else
- 		retval = ni_priv->bulk_urb->status;
--	if(timer_pending(&timer))
--		del_timer_sync(&timer);
-+
-+	del_timer_sync(&ni_priv->bulk_timer);
- 	*actual_data_length = ni_priv->bulk_urb->actual_length;
- 	mutex_lock(&ni_priv->bulk_transfer_lock);
- 	usb_free_urb(ni_priv->bulk_urb);
-@@ -183,8 +184,7 @@
- 	struct usb_device *usb_dev;
- 	int retval;
- 	unsigned int in_pipe;
--	ni_usb_urb_context_t context;
--	struct timer_list timer;
-+	ni_usb_urb_context_t *context = &ni_priv->context;
- 
- 	*actual_data_length = 0;
- 	mutex_lock(&ni_priv->bulk_transfer_lock);
-@@ -206,24 +206,19 @@
- 	}
- 	usb_dev = interface_to_usbdev(ni_priv->bus_interface);
- 	in_pipe = usb_rcvbulkpipe(usb_dev, ni_priv->bulk_in_endpoint);
--	sema_init(&context.complete, 0);
--	context.timed_out = 0;
-+	sema_init(&context->complete, 0);
-+	context->timed_out = 0;
- 	usb_fill_bulk_urb(ni_priv->bulk_urb, usb_dev, in_pipe, data, data_length,
--		&ni_usb_bulk_complete, &context);
--	init_timer(&timer);
-+		&ni_usb_bulk_complete, context);
-+
- 	if(timeout_msecs)
--	{
--		timer.expires = jiffies + msecs_to_jiffies(timeout_msecs);
--		timer.function = ni_usb_timeout_handler;
--		timer.data = (unsigned long) &context;
--		add_timer(&timer);
--	}
-+		mod_timer(&ni_priv->bulk_timer, jiffies + msecs_to_jiffies(timeout_msecs));
-+
- 	//printk("%s: submitting urb\n", __FUNCTION__);
- 	retval = usb_submit_urb(ni_priv->bulk_urb, GFP_KERNEL);
- 	if(retval)
- 	{
--		if(timer_pending(&timer))
--			del_timer_sync(&timer);
-+		del_timer_sync(&ni_priv->bulk_timer);
- 		usb_free_urb(ni_priv->bulk_urb);
- 		ni_priv->bulk_urb = NULL;
- 		printk("%s: failed to submit bulk out urb, retval=%i\n", __FILE__, retval);
-@@ -233,7 +228,7 @@
- 	mutex_unlock(&ni_priv->bulk_transfer_lock);
- 	if(interruptible)
- 	{
--		if(down_interruptible(&context.complete))
-+		if(down_interruptible(&context->complete))
- 		{
- 			/* If we got interrupted by a signal while waiting for the usb gpib
- 				to respond, we should send a stop command so it will finish
-@@ -242,21 +237,21 @@
- 			retval = -ERESTARTSYS;
- 			/* now do an uninterruptible wait, it shouldn't take long
- 				for the board to respond now. */
--			down(&context.complete);
-+			down(&context->complete);
- 		}
- 	}else
- 	{
--		down(&context.complete);
-+		down(&context->complete);
- 	}
--	if(context.timed_out)
-+	if(context->timed_out)
- 	{
- 		usb_kill_urb(ni_priv->bulk_urb);
- 		printk("%s: killed urb due to timeout\n", __FUNCTION__);
- 		retval = -ETIMEDOUT;
- 	}else if(ni_priv->bulk_urb->status)
- 		retval = ni_priv->bulk_urb->status;
--	if(timer_pending(&timer))
--		del_timer_sync(&timer);
-+
-+	del_timer_sync(&ni_priv->bulk_timer);
- 	*actual_data_length = ni_priv->bulk_urb->actual_length;
- 	mutex_lock(&ni_priv->bulk_transfer_lock);
- 	usb_free_urb(ni_priv->bulk_urb);
-@@ -2170,6 +2165,13 @@
- 		mutex_unlock(&ni_usb_hotplug_lock);
- 		return retval;
- 	}
-+
-+#ifdef HAVE_TIMER_SETUP
-+	timer_setup(&ni_priv->bulk_timer, ni_usb_timeout_handler, 0);
-+#else
-+	setup_timer(&ni_priv->bulk_timer, ni_usb_timeout_handler, (unsigned long)ni_priv);
-+#endif
-+
- 	retval = ni_usb_init(board);
- 	if(retval < 0)
- 	{
-@@ -2182,6 +2184,7 @@
- 		mutex_unlock(&ni_usb_hotplug_lock);
- 		return retval;
- 	}
-+
- 	mutex_unlock(&ni_usb_hotplug_lock);
- 	return retval;
- }
-diff -ur linux-gpib-4.1.0/drivers/gpib/ni_usb/ni_usb_gpib.h linux-gpib-4.1.0-k415/drivers/gpib/ni_usb/ni_usb_gpib.h
---- linux-gpib-4.1.0/drivers/gpib/ni_usb/ni_usb_gpib.h	2017-09-01 17:32:15.000000000 +0200
-+++ linux-gpib-4.1.0-k415/drivers/gpib/ni_usb/ni_usb_gpib.h	2018-01-29 20:55:10.341502118 +0100
-@@ -73,6 +73,12 @@
- 	NIUSB_HS_PLUS_INTERRUPT_IN_ENDPOINT = 0x3,
- };
- 
-+typedef struct
-+{
-+	struct semaphore complete;
-+	unsigned timed_out : 1;
-+} ni_usb_urb_context_t;
-+
- // struct which defines private_data for ni_usb devices
- typedef struct
- {
-@@ -90,14 +96,10 @@
-         struct mutex bulk_transfer_lock;
- 	struct mutex control_transfer_lock;
- 	struct mutex interrupt_transfer_lock;
-+	struct timer_list bulk_timer;
-+	ni_usb_urb_context_t context;
- } ni_usb_private_t;
- 
--typedef struct
--{
--	struct semaphore complete;
--	unsigned timed_out : 1;
--} ni_usb_urb_context_t;
--
- struct ni_usb_status_block
- {
- 	short id;
-diff -ur linux-gpib-4.1.0/drivers/gpib/sys/ibwait.c linux-gpib-4.1.0-k415/drivers/gpib/sys/ibwait.c
---- linux-gpib-4.1.0/drivers/gpib/sys/ibwait.c	2017-09-02 15:19:47.000000000 +0200
-+++ linux-gpib-4.1.0-k415/drivers/gpib/sys/ibwait.c	2018-01-29 20:55:10.341502118 +0100
-@@ -28,11 +28,29 @@
- 	unsigned long usec_timeout;
- };
- 
-+
-+#ifdef HAVE_TIMER_SETUP
-+static void wait_timeout( struct timer_list *t )
-+{
-+	struct wait_info *winfo = from_timer(winfo, t, timer);
-+#else
-+static void wait_timeout( unsigned long arg )
-+{
-+	struct wait_info *winfo = ( struct wait_info * ) arg;
-+#endif
-+	winfo->timed_out = 1;
-+	wake_up_interruptible( &winfo->board->wait );
-+}
-+
- static void init_wait_info( struct wait_info *winfo )
- {
- 	winfo->board = NULL;
--	init_timer( &winfo->timer );
- 	winfo->timed_out = 0;
-+#ifdef HAVE_TIMER_SETUP
-+	timer_setup_on_stack( &winfo->timer, wait_timeout, 0 );
-+#else
-+	setup_timer( &winfo->timer, wait_timeout, (unsigned long)winfo );
-+#endif
- }
- 
- static int wait_satisfied( struct wait_info *winfo, gpib_status_queue_t *status_queue,
-@@ -63,15 +81,6 @@
- 	return 0;
- }
- 
--static void wait_timeout( unsigned long arg )
--/* Watchdog timeout routine */
--{
--	struct wait_info *winfo = ( struct wait_info * ) arg;
--
--	winfo->timed_out = 1;
--	wake_up_interruptible( &winfo->board->wait );
--}
--
- /* install timer interrupt handler */
- static void startWaitTimer( struct wait_info *winfo )
- /* Starts the timeout task  */
-@@ -80,17 +89,16 @@
- 
- 	if( winfo->usec_timeout > 0 )
- 	{
--		winfo->timer.expires = jiffies + usec_to_jiffies( winfo->usec_timeout );
--		winfo->timer.function = wait_timeout;
--		winfo->timer.data = (unsigned long) winfo;
--		add_timer( &winfo->timer );              /* add timer           */
-+		mod_timer( &winfo->timer, jiffies + usec_to_jiffies( winfo->usec_timeout ));
- 	}
- }
- 
- static void removeWaitTimer( struct wait_info *winfo )
- {
--	if( timer_pending( &winfo->timer ) )
--		del_timer_sync( &winfo->timer );
-+	del_timer_sync( &winfo->timer );
-+#ifdef HAVE_TIMER_SETUP
-+	destroy_timer_on_stack( &winfo->timer );
-+#endif
- }
- 
- /*
-diff -ur linux-gpib-4.1.0/drivers/gpib/sys/osinit.c linux-gpib-4.1.0-k415/drivers/gpib/sys/osinit.c
---- linux-gpib-4.1.0/drivers/gpib/sys/osinit.c	2017-09-29 19:25:30.000000000 +0200
-+++ linux-gpib-4.1.0-k415/drivers/gpib/sys/osinit.c	2018-01-29 20:55:10.341502118 +0100
-@@ -115,7 +115,11 @@
- 	board->locking_pid = 0;
- 	spin_lock_init(&board->locking_pid_spinlock);
- 	spin_lock_init(&board->spinlock);
--	init_timer(&board->timer);
-+#ifdef HAVE_TIMER_SETUP
-+	timer_setup(&board->timer, NULL, 0);
-+#else
-+	setup_timer(&board->timer, NULL, (unsigned long)board);
-+#endif
- 	board->ibbase = 0;
- 	board->ibirq = 0;
- 	board->ibdma = 0;
-diff -ur linux-gpib-4.1.0/drivers/gpib/sys/ostimer.c linux-gpib-4.1.0-k415/drivers/gpib/sys/ostimer.c
---- linux-gpib-4.1.0/drivers/gpib/sys/ostimer.c	2016-06-22 10:48:48.000000000 +0200
-+++ linux-gpib-4.1.0-k415/drivers/gpib/sys/ostimer.c	2018-01-29 21:00:09.728177393 +0100
-@@ -20,11 +20,17 @@
- /*
-  * Timer functions
-  */
--void watchdog_timeout( unsigned long arg )
- /* Watchdog timeout routine */
-+
-+#ifdef HAVE_TIMER_SETUP
-+void watchdog_timeout( struct timer_list *t )
-+{
-+	gpib_board_t *board = from_timer(board, t, timer);
-+#else
-+void watchdog_timeout( unsigned long arg )
- {
- 	gpib_board_t *board = (gpib_board_t*) arg;
--
-+#endif
- 	set_bit( TIMO_NUM, &board->status );
- 	wake_up_interruptible( &board->wait );
- }
-@@ -42,10 +48,8 @@
- 
- 	if( usec_timeout > 0 )
- 	{
--		board->timer.expires = jiffies + usec_to_jiffies( usec_timeout );   /* set number of ticks */
- 		board->timer.function = watchdog_timeout;
--		board->timer.data = (unsigned long) board;
--		add_timer( &board->timer );              /* add timer           */
-+		mod_timer(&board->timer, jiffies + usec_to_jiffies( usec_timeout ));   /* set number of ticks */
- 	}
- }
- 
-diff -ur linux-gpib-4.1.0/drivers/gpib/sys/osutil.c linux-gpib-4.1.0-k415/drivers/gpib/sys/osutil.c
---- linux-gpib-4.1.0/drivers/gpib/sys/osutil.c	2016-06-22 10:48:48.000000000 +0200
-+++ linux-gpib-4.1.0-k415/drivers/gpib/sys/osutil.c	2018-01-29 20:59:08.427580118 +0100
-@@ -49,19 +49,25 @@
- 	return (HZ + 99) / 100;
- }
- 
-+#ifdef HAVE_TIMER_SETUP
-+void pseudo_irq_handler(struct timer_list *t)
-+{
-+        struct gpib_pseudo_irq *pseudo_irq = from_timer(pseudo_irq, t, timer);
-+#else
- void pseudo_irq_handler(unsigned long arg)
- {
--	gpib_board_t *board = (gpib_board_t*) arg;
--	if(board->pseudo_irq.handler)
--		board->pseudo_irq.handler(0, board
-+	struct gpib_pseudo_irq *pseudo_irq = (struct gpib_pseudo_irq *)arg;
-+#endif
-+	if(pseudo_irq->handler)
-+		pseudo_irq->handler(0, pseudo_irq->board
- #ifdef HAVE_PT_REGS
- 		, NULL
- #endif
- 		);
- 	else
- 		printk("gpib: bug! pseudo_irq.handler is NULL\n");
--	if(atomic_read(&board->pseudo_irq.active))
--		mod_timer(&board->pseudo_irq.timer, jiffies + pseudo_irq_period());
-+	if(atomic_read(&pseudo_irq->active))
-+		mod_timer(&pseudo_irq->timer, jiffies + pseudo_irq_period());
- }
- 
- int gpib_request_pseudo_irq(gpib_board_t *board, irqreturn_t (*handler)(int, void * PT_REGS_ARG))
-@@ -73,11 +79,10 @@
- 	}
- 
- 	board->pseudo_irq.handler = handler;
--	board->pseudo_irq.timer.expires = jiffies + pseudo_irq_period();
- 	board->pseudo_irq.timer.function = pseudo_irq_handler;
--	board->pseudo_irq.timer.data = (unsigned long) board;
-+	board->pseudo_irq.board = board;
- 	atomic_set(&board->pseudo_irq.active, 1);
--	add_timer(&board->pseudo_irq.timer);
-+	mod_timer(&board->pseudo_irq.timer, jiffies + pseudo_irq_period());
- 
- 	return 0;
- }
diff --git a/kernel-5.0.patch b/kernel-5.0.patch
new file mode 100644
index 0000000..aa5739f
--- /dev/null
+++ b/kernel-5.0.patch
@@ -0,0 +1,38 @@
+--- linux-gpib-kernel-4.2.0/drivers/gpib/sys/osfuncs.c~	2018-11-07 15:58:07.000000000 +0100
++++ linux-gpib-kernel-4.2.0/drivers/gpib/sys/osfuncs.c	2019-03-10 18:51:26.364983014 +0100
+@@ -551,7 +551,11 @@
+ 	remain = read_cmd.requested_transfer_count - read_cmd.completed_transfer_count;
+ 
+ 	/* Check write access to buffer */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)
+ 	if(!access_ok(VERIFY_WRITE, userbuf, remain))
++#else
++	if(!access_ok(userbuf, remain))
++#endif
+ 		return -EFAULT;
+ 
+ 	smp_mb__before_atomic();
+@@ -626,7 +630,11 @@
+ 	remain = cmd.requested_transfer_count - cmd.completed_transfer_count;
+ 
+ 	/* Check read access to buffer */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)
+ 	if(!access_ok(VERIFY_READ, userbuf, remain))
++#else
++	if(!access_ok(userbuf, remain))
++#endif
+ 		return -EFAULT;
+ 
+ 	/* Write buffer loads till we empty the user supplied buffer.
+@@ -705,7 +713,11 @@
+ 	remain = write_cmd.requested_transfer_count - write_cmd.completed_transfer_count;
+ 
+ 	/* Check read access to buffer */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)
+ 	if(!access_ok(VERIFY_READ, userbuf, remain))
++#else
++	if(!access_ok(userbuf, remain))
++#endif
+ 		return -EFAULT;
+ 
+ 	smp_mb__before_atomic();
diff --git a/linux-gpib-destdir.patch b/linux-gpib-destdir.patch
deleted file mode 100644
index 7a6c19d..0000000
--- a/linux-gpib-destdir.patch
+++ /dev/null
@@ -1,37 +0,0 @@
---- linux-gpib-4.0.3/usb/Makefile.am.orig	2016-04-09 15:33:10.000000000 +0200
-+++ linux-gpib-4.0.3/usb/Makefile.am	2016-07-03 17:23:55.568395058 +0200
-@@ -12,5 +12,5 @@
- UDEV_RULES_DIR = /etc/udev/rules.d
- 
- install-data-local: 99-gpib-generic.rules
--	test -d $(UDEV_RULES_DIR) && test -e $(UDEV_RULES_DIR)/99-gpib-generic.rules || $(INSTALL_DATA) -D 99-gpib-generic.rules $(UDEV_RULES_DIR)/99-gpib-generic.rules
-+	test -d $(DESTDIR)$(UDEV_RULES_DIR) && test -e $(DESTDIR)$(UDEV_RULES_DIR)/99-gpib-generic.rules || $(INSTALL_DATA) -D 99-gpib-generic.rules $(DESTDIR)$(UDEV_RULES_DIR)/99-gpib-generic.rules
- 
---- linux-gpib-4.0.3/usb/agilent_82357a/Makefile.am.orig	2016-04-09 15:33:10.000000000 +0200
-+++ linux-gpib-4.0.3/usb/agilent_82357a/Makefile.am	2016-07-03 17:25:01.641370442 +0200
-@@ -19,7 +19,7 @@
- 	$(do_subst) < 99-agilent_82357a.rules.in >99-agilent_82357a.rules
- 
- install-data-local: 99-agilent_82357a.rules
--	test -e $(HOTPLUG_USB_CONF_DIR)/agilent_82357a || $(INSTALL_SCRIPT) -D agilent_82357a $(HOTPLUG_USB_CONF_DIR)/agilent_82357a
--	test -e $(HOTPLUG_USB_CONF_DIR)/agilent_82357a.usermap || $(INSTALL_DATA) -D agilent_82357a.usermap $(HOTPLUG_USB_CONF_DIR)/agilent_82357a.usermap
--	$(INSTALL) -d $(USB_FIRMWARE_DIR)/agilent_82357a
--	test -d $(UDEV_RULES_DIR) && test -e $(UDEV_RULES_DIR)/99-agilent_82357a.rules || $(INSTALL_DATA) -D 99-agilent_82357a.rules $(UDEV_RULES_DIR)/99-agilent_82357a.rules
-+	test -e $(DESTDIR)$(HOTPLUG_USB_CONF_DIR)/agilent_82357a || $(INSTALL_SCRIPT) -D agilent_82357a $(DESTDIR)$(HOTPLUG_USB_CONF_DIR)/agilent_82357a
-+	test -e $(DESTDIR)$(HOTPLUG_USB_CONF_DIR)/agilent_82357a.usermap || $(INSTALL_DATA) -D agilent_82357a.usermap $(DESTDIR)$(HOTPLUG_USB_CONF_DIR)/agilent_82357a.usermap
-+	$(INSTALL) -d $(DESTDIR)$(USB_FIRMWARE_DIR)/agilent_82357a
-+	test -d $(DESTDIR)$(UDEV_RULES_DIR) && test -e $(DESTDIR)$(UDEV_RULES_DIR)/99-agilent_82357a.rules || $(INSTALL_DATA) -D 99-agilent_82357a.rules $(DESTDIR)$(UDEV_RULES_DIR)/99-agilent_82357a.rules
---- linux-gpib-4.0.3/usb/ni_usb_gpib/Makefile.am.orig	2016-04-09 15:33:10.000000000 +0200
-+++ linux-gpib-4.0.3/usb/ni_usb_gpib/Makefile.am	2016-07-03 17:25:55.417745779 +0200
-@@ -19,7 +19,7 @@
- 	$(do_subst) < 99-ni_usb_gpib.rules.in >99-ni_usb_gpib.rules
- 
- install-data-local: 99-ni_usb_gpib.rules
--	test -e $(HOTPLUG_USB_CONF_DIR)/ni_usb_gpib || $(INSTALL_SCRIPT) -D ni_usb_gpib $(HOTPLUG_USB_CONF_DIR)/ni_usb_gpib
--	test -e $(HOTPLUG_USB_CONF_DIR)/ni_usb_gpib.usermap || $(INSTALL_DATA) -D ni_usb_gpib.usermap $(HOTPLUG_USB_CONF_DIR)/ni_usb_gpib.usermap
--	$(INSTALL) -d $(USB_FIRMWARE_DIR)/ni_usb_gpib
--	test -d $(UDEV_RULES_DIR) && test -e $(UDEV_RULES_DIR)/99-ni_usb_gpib.rules || $(INSTALL_DATA) -D 99-ni_usb_gpib.rules $(UDEV_RULES_DIR)/99-ni_usb_gpib.rules
-+	test -e $(DESTDIR)$(HOTPLUG_USB_CONF_DIR)/ni_usb_gpib || $(INSTALL_SCRIPT) -D ni_usb_gpib $(DESTDIR)$(HOTPLUG_USB_CONF_DIR)/ni_usb_gpib
-+	test -e $(DESTDIR)$(HOTPLUG_USB_CONF_DIR)/ni_usb_gpib.usermap || $(INSTALL_DATA) -D ni_usb_gpib.usermap $(DESTDIR)$(HOTPLUG_USB_CONF_DIR)/ni_usb_gpib.usermap
-+	$(INSTALL) -d $(DESTDIR)$(USB_FIRMWARE_DIR)/ni_usb_gpib
-+	test -d $(DESTDIR)$(UDEV_RULES_DIR) && test -e $(DESTDIR)$(UDEV_RULES_DIR)/99-ni_usb_gpib.rules || $(INSTALL_DATA) -D 99-ni_usb_gpib.rules $(DESTDIR)$(UDEV_RULES_DIR)/99-ni_usb_gpib.rules
diff --git a/linux-gpib-include_file.patch b/linux-gpib-include_file.patch
deleted file mode 100644
index f48cb56..0000000
--- a/linux-gpib-include_file.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- linux-gpib-4.0.3/drivers/gpib/include/gpib_types.h.orig	2016-07-02 16:36:26.318566419 +0200
-+++ linux-gpib-4.0.3/drivers/gpib/include/gpib_types.h	2016-07-02 16:47:34.328280834 +0200
-@@ -24,7 +24,7 @@
-  * and generic interface provided by gpib-common.
-  * This really should be in a different header file.
-  */
--#include "gpib/gpib_user.h"
-+#include "gpib_user.h"
- #include <asm/atomic.h>
- #include <linux/mutex.h>
- #include <linux/wait.h>
---- linux-gpib-3.2.09/drivers/gpib/include/gpibP.h.orig	2007-12-06 00:42:20.000000000 +0000
-+++ linux-gpib-3.2.09/drivers/gpib/include/gpibP.h	2007-12-06 00:47:22.000000000 +0000
-@@ -20,7 +20,7 @@
- 
- #include <linux/types.h>
- 
--#include "gpib/gpib_user.h"
-+#include "gpib_user.h"
- #include "gpib_types.h"
- #include "gpib_proto.h"
- #include "gpib_ioctl.h"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/linux-gpib.git/commitdiff/302b72f6120162d2579447b1cf7effd33825f5c9



More information about the pld-cvs-commit mailing list