moxa.c changes to MOXA_GET_CONF ioctl breaks moxaload (userspace application for firmware download to MOXA Intellio CPU boards). Attached (and included inline below) is a patch to solve a problem introduced by changes to struct moxa_board_conf in drivers/char/moxa.c. AFAICS from the changelogs, moxa.c was rewritten to a new API in 2.6.21, but I've only tested it (and moxaload) on kernels up to 2.6.19.2 (where it works) and on 2.6.22.6 and various later kernels, including the latest (2.6.23.14), where it doesn't work. Steps to reproduce: Call the moxaload program (from MOXA) to download the firmware. moxaload will fail on most systems (all the ones I've tried), because it thinks there is a memory conflict, although this behaviour will depend on the exact contents of struct moxa_board_conf (in drivers/char/moxa.c). The problem is, that moxaload uses the MOXA_GET_CONF ioctl, which returns (verbatim) the contents of struct moxa_board_conf, the structure (and contents) of which has changed heavily. This patch corrects this problem by reverting the behaviour of the MOXA_GET_CONF ioctl, so it returns the info that moxaload expects. I'm not on the kernel list, so please CC: me with any questions and/or comments. To Jiri Slaby <jirislaby@gmail.com>: I've CC'ed this to you, although linux/MAINTAINERS doesn't mention you as the maintainer of moxa.c, since the changelogs seems to indicate, that you're the current maintainer. linux/MAINTAINERS mentions you (Jiri) as the maintainer of mxser, but that is the driver for other MOXA boards, so I hope that I've guessed right ... =D8yvind. PS: Jiri, you may receive this twice (sorry 'bout that), but it seems that pine doesn't encode the From: field properly, so my first mail got rejected by vger.kernel.org due to the iso-latin-1 Ooblique char in my name. What a depressingly stupid program :-( ************************************************************************** * =D8yvind Aabling E-mail : Oyvind.Aabling@uni-c.dk /~\ The ASCII = * * UNI-C Lyngby Phone : +45 35 87 88 89 \ / Ribbon * * DTU Building 304 Phone : +45 35 87 89 51 (direct) X Campaign * * DK-2800 LYNGBY Fax : +45 35 87 89 90 / \ Against * * Denmark HTML Email! * ************************************************************************** --- linux-2.6.23.14/drivers/char/moxa.c=092008-01-14 21:49:56.000000000 +01= 00 +++ linux/drivers/char/moxa.c=092008-01-20 18:30:15.000000000 +0100 @@ -109,6 +109,8 @@ =09int busType; =09int loadstat; +=09unsigned short busNum; +=09unsigned short devNum; =09void __iomem *basemem; =09void __iomem *intNdx; @@ -116,6 +118,16 @@ =09void __iomem *intTable; } moxa_boards[MAX_BOARDS]; +/* Used by userspace application moxaload (firmware download) */ +static struct moxa_board_info { +=09int boardType; +=09int numPorts; +=09unsigned long baseAddr; +=09int busType; +=09unsigned short busNum; +=09unsigned short devNum; +} moxa_board_info[MAX_BOARDS]; + struct mxser_mstatus { =09tcflag_t cflag; =09int cts; @@ -304,6 +316,9 @@ =09=09goto err; =09board->boardType =3D board_type; +=09board->baseAddr =3D pci_resource_start(pdev, 2); +=09board->busNum =3D pdev->bus->number; +=09board->devNum =3D PCI_SLOT(pdev->devfn); =09switch (board_type) { =09case MOXA_BOARD_C218_ISA: =09case MOXA_BOARD_C218_PCI: @@ -1494,8 +1509,16 @@ =09} =09switch (cmd) { =09case MOXA_GET_CONF: -=09=09if(copy_to_user(argp, &moxa_boards, MAX_BOARDS * -=09=09=09=09sizeof(struct moxa_board_conf))) +=09=09for (i =3D 0; i < MAX_BOARDS; i++) { +=09=09=09moxa_board_info[i].boardType =3D moxa_boards[i].boardType; +=09=09=09moxa_board_info[i].numPorts =3D moxa_boards[i].numPorts; +=09=09=09moxa_board_info[i].baseAddr =3D moxa_boards[i].baseAddr; +=09=09=09moxa_board_info[i].busType =3D moxa_boards[i].busType; +=09=09=09moxa_board_info[i].busNum =3D moxa_boards[i].busNum; +=09=09=09moxa_board_info[i].devNum =3D moxa_boards[i].devNum; +=09=09} +=09=09if(copy_to_user(argp, &moxa_board_info, MAX_BOARDS * +=09=09=09=09sizeof(struct moxa_board_info))) =09=09=09return -EFAULT; =09=09return (0); =09case MOXA_INIT_DRIVER:
| Ian Campbell | Re: [PATCH] x86: Construct 32 bit boot time page tables in native format. |
| Greg Kroah-Hartman | [PATCH 001/196] Chinese: Add the known_regression URI to the HOWTO |
| Justin Piszcz | Linux Software RAID 5 Performance Optimizations: 2.6.19.1: (211MB/s read & 195... |
| Alan | Re: [RFC] Heads up on sys_fallocate() |
| Matthias Scheler | Re: HEADS UP: timecounters (branch simonb-timecounters) merged into -current |
| David Laight | long usernames |
| Quentin Garnier | Re: Understanding foo_open, foo_read, etc. |
| Jared D. McNeill | Breaking binary compatibility for /dev/joy |
git: | |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Gerrit Renker | [PATCH 0/37] dccp: Feature negotiation - last call for comments |
| David Miller | [GIT]: Networking |
| Natalie Protasevich | [BUG] New Kernel Bugs |
