LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 09-19-2007, 10:43 PM   #1
jmajor
Member
 
Registered: Nov 2004
Location: Australia
Distribution: Fedora, Ubuntu
Posts: 55
Blog Entries: 2

Rep: Reputation: 17
Updating driver from 2.6.9 to current for device no longer supported by manufacturer


We have 3 Cyclades PC400 cards (60 virtual modems over 2 E1 connections). I have drivers that supposedly compile against kernel 2.6.9 and and have them running successfully under RH7 kernel 2.4.x. We have bought some new server hardware and would like to run the cards in the newer hardware with the latest kernel, etc.

The problem is that the write function pointer in the tty_operations structure has more arguments in the old code than in the new. Specifically the from_user argument is no longer required. As the existing write function appears to have different behaviour depending on the value of this flag, I would like to know what the alternate mechanism is.

I have more than 15 years C programming experience, but zero in kernel drivers. If someone could give me some pointers, I'd be happy to post my changes back here for the other unfortunates in the same boat.

For reference, here is the 2.6.9 version of the write function:

Code:
    /* This routine gets called when tty_write has put something into
     * the write_queue.  The characters may come from user space or
     * kernel space.
     *
     * This routine will return the number of characters actually
     * accepted for writing.
     *
     * If the port is not already transmitting stuff, start it off by
     * enabling interrupts.  The interrupt service routine will then
     * ensure that the characters are sent.
     * If the port is already active, there is no need to kick it.
     *
     */
    static int pc400_write(struct tty_struct * tty, int from_user,
	    const ucchar *buf, int count)
    {
 	pc400_port_t *info = (pc400_port_t *)tty->driver_data;
 	uclong flags;
 	int c, ret = 0;

#ifdef PC400_DEBUG_IO
	printk("pc400: pc400_write ttyCM%d\n", info->line); /* */
#endif

	if (pc400_paranoia_check(info, tty->name, "pc400_write")) {
		return 0;
	}
        
	if (!tty || !info->xmit_buf || !tmp_buf) {
		return 0;
	}

	if (from_user) {
		down(&tmp_buf_sem);
		while (1) {
			c = MIN(count, MIN(SERIAL_XMIT_SIZE - info->xmit_cnt - 
				1, SERIAL_XMIT_SIZE - info->xmit_head));
			if (c <= 0) {
				break;
			}
			c -= copy_from_user(tmp_buf, buf, c);
			if (!c) {
				if (!ret) {
					ret = -EFAULT;
				}
				break;
			}
			PC400_LOCK_INFO(info, flags);
			c = MIN(c, MIN(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
				SERIAL_XMIT_SIZE - info->xmit_head));
			memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c);
			info->xmit_head = ((info->xmit_head + c) & 
				(SERIAL_XMIT_SIZE-1));
			info->xmit_cnt += c;
                        PC400_UNLOCK_INFO(info, flags);
			buf += c;
			count -= c;
			ret += c;
		}
		up(&tmp_buf_sem);
	} else {
   		PC400_LOCK_INFO(info, flags);
		while (1) {
			c = MIN(count, MIN(SERIAL_XMIT_SIZE - info->xmit_cnt - 
				1, SERIAL_XMIT_SIZE - info->xmit_head));
			if (c <= 0) {
				break;
			}
			memcpy(info->xmit_buf + info->xmit_head, buf, c);
			info->xmit_head = (info->xmit_head + c) & 
				(SERIAL_XMIT_SIZE-1);
			info->xmit_cnt += c;
			buf += c;
			count -= c;
			ret += c;
		}
		PC400_UNLOCK_INFO(info, flags);
	}

	info->idle_stats.xmit_bytes += ret;
	info->idle_stats.xmit_idle   = jiffies;

	if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) {
		start_xmit(info);
	}
	return ret;
    } /* pc400_write */
 
Old 09-21-2007, 08:14 AM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 326Reputation: 326Reputation: 326Reputation: 326
It looks like current kernels include the Cyclades driver. Have you tried using it? Check dmesg on the new system; it may be necessary to 'modprobe cyclades'.
 
Old 09-24-2007, 12:37 AM   #3
jmajor
Member
 
Registered: Nov 2004
Location: Australia
Distribution: Fedora, Ubuntu
Posts: 55
Blog Entries: 2

Original Poster
Rep: Reputation: 17
Sadly, the cyclades module, which has been around for many years, does not support the pc400 card as far as I am aware. It may be worth my while to review the code.

Thanks
 
Old 09-24-2007, 10:11 PM   #4
jmajor
Member
 
Registered: Nov 2004
Location: Australia
Distribution: Fedora, Ubuntu
Posts: 55
Blog Entries: 2

Original Poster
Rep: Reputation: 17
Progress

Searched the kernel changelogs:

looks like in 2.6.10-rc1 http://lwn.net/Articles/107826/ Linus moved the double shuffling to the next layer up. As this implies from_user=0 always, he removed the flag. I think this means I can get my axe out and start removing stuff.

Will see how I go.
 
Old 01-29-2008, 12:36 AM   #5
jmajor
Member
 
Registered: Nov 2004
Location: Australia
Distribution: Fedora, Ubuntu
Posts: 55
Blog Entries: 2

Original Poster
Rep: Reputation: 17
Progress:
I have finally had some time to dig through the pc400 driver code.

I now have the utilities compiling (can load firmware and reset board under 2.6.23)
I now have a module compiling and loading (and not crashing on a very early interrupt)

The system is core2 duo, but I am compiling for i386 and single cpu (as per what the doco says is supported)
I plan to do some more testing tomorrow. This will include things like smp and dialing / answering calls.

If anyone wants this code let me know. The comments in the code suggest it is GPL, but I didn't look to carefully.

John
 
  


Reply

Tags
driver, kernel


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Manufacturer supported drovers? iAlta Linux - Wireless Networking 14 03-12-2007 04:01 PM
Updating to Slackware current Panagiotis_IOA Slackware 3 09-21-2006 11:51 AM
X no longer loads after current Swaret upgrade shadowsnipes Slackware 7 06-25-2006 11:20 PM
kdesu No Longer Supported in FC5 Wheat_Thins Linux - Software 2 04-14-2006 01:45 PM
How to convince manufacturer to make driver? OldSarge Linux - Hardware 4 10-17-2003 06:28 AM


All times are GMT -5. The time now is 05:32 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration