2.6.0-test5-mm2: dgap driver looks ugly

From: Adrian Bunk (bunk_at_fs.tum.de)
Date: 09/16/03

  • Next message: Edward Macfarlane Smith: "Re: 2.4.23-pre4 ide-scsi irq timeout"
    Date:	Tue, 16 Sep 2003 00:08:29 +0200
    To: Andrew Morton <akpm@osdl.org>, Scott_Kilau@digi.com
    
    

    On Sun, Sep 14, 2003 at 11:48:43PM -0700, Andrew Morton wrote:
    >...
    > Changes since 2.6.0-test5-mm1:
    >...
    > +dgap.patch
    >
    > Digi Acceleport driver
    >...

    This driver seems to need a serious cleanup.

    The patch below does:
    - remove MIN/MAN
    - remove (unused) userspace program/conffile locations
    - remove a check that compares an ushort witha value it never has on
      Linux

    There seem to be more cleanups needed, these should only be some
    examples.

    cu
    Adrian

    --- linux-2.6.0-test5-mm2-no-smp/drivers/char/digi/dgap/dgap_driver.h.old 2003-09-15 17:52:47.000000000 +0200
    +++ linux-2.6.0-test5-mm2-no-smp/drivers/char/digi/dgap/dgap_driver.h 2003-09-15 23:57:28.000000000 +0200
    @@ -215,7 +215,6 @@
     #define MYFLIPLEN N_TTY_BUF_SIZE
     
     #define SBREAK_TIME 0x25
    -#define USHRT_MAX 65535
     #define U2BSIZE 0x400
     #define dgap_jiffies_from_ms(a) (((a) * HZ) / 1000)
     
    @@ -231,10 +230,6 @@
     # define DIGI_DGAP_MAJOR 22
     #endif
     
    -/* The default location of the config script. */
    -#define DGAP_CONFIG_PROGRAM "/usr/sbin/dgap_config"
    -#define DGAP_CONFIG_FILE "/etc/dgap.conf"
    -
     /*
      * The parameters we use to define the periods of the moving averages.
      */
    @@ -274,20 +269,6 @@
     #endif
     
     /*
    - * Only define these in case they are not present in the kernel headers.
    - * A grep of /usr/src/linux-<version>/include/linux
    - * show others worry about this as well.
    - */
    -#if !defined(MIN)
    -# define MIN(a,b) ((a) < (b) ? (a) : (b))
    -#endif
    -
    -#if !defined(MAX)
    -# define MAX(a,b) ((a) > (b) ? (a) : (b))
    -#endif
    -
    -
    -/*
      * All the possible states the driver can be while being loaded.
      */
     enum {
    --- linux-2.6.0-test5-mm2-no-smp/drivers/char/digi/dgap/dgap_tty.c.old 2003-09-15 23:47:21.000000000 +0200
    +++ linux-2.6.0-test5-mm2-no-smp/drivers/char/digi/dgap/dgap_tty.c 2003-09-15 23:50:54.000000000 +0200
    @@ -1278,8 +1278,8 @@
                     flip_len = TTY_FLIPBUF_SIZE - tp->flip.count;
             }
     
    - len = MIN(data_len, flip_len);
    - len = MIN(len, (N_TTY_BUF_SIZE - 1) - tp->read_cnt);
    + len = min(data_len, flip_len);
    + len = min(len, (N_TTY_BUF_SIZE - 1) - tp->read_cnt);
     
             if (len <= 0) {
                     writeb(1, &(bs->idata));
    @@ -1315,7 +1315,7 @@
             while (n) {
     
                     s = ((head >= tail) ? head : ch->ch_rsize) - tail;
    - s = MIN(s, n);
    + s = min(s, n);
     
                     if (s <= 0)
                             break;
    @@ -2513,7 +2513,7 @@
                             cps_limit = 0;
                     }
     
    - bytes_available = MIN(cps_limit, bytes_available);
    + bytes_available = min(cps_limit, bytes_available);
             }
     
             return (bytes_available);
    @@ -2705,7 +2705,7 @@
              * Take minimum of what the user wants to send, and the
              * space available in the FEP buffer.
              */
    - count = MIN(count, bufcount);
    + count = min(count, bufcount);
     
             /*
              * Bail if no space left.
    @@ -2743,7 +2743,7 @@
                             goto out;
                     }
     
    - count = MIN(count, WRITEBUFLEN);
    + count = min(count, WRITEBUFLEN);
     
                     /*
                      * copy_from_user() returns the number
    @@ -3230,9 +3230,6 @@
             if (ch->ch_digi.digi_bufsize < 10)
                     ch->ch_digi.digi_bufsize = 10;
     
    - if (ch->ch_digi.digi_bufsize > 100000)
    - ch->ch_digi.digi_bufsize = MIN(100000, USHRT_MAX);
    -
             if (ch->ch_digi.digi_maxchar < 1)
                     ch->ch_digi.digi_maxchar = 1;
     
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: Edward Macfarlane Smith: "Re: 2.4.23-pre4 ide-scsi irq timeout"

    Relevant Pages

    • Re: Linux 2.6.13-rc2
      ... and cleanup of xtensa. ... sound/pci/bt87x.c:807: error: `driver' undeclared ... sound/pci/bt87x.c:807: error: (Each undeclared identifier is reported only once ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • [PATCH] I2C: Cleanup adm1021 unused defines
      ... I2C: Cleanup adm1021 unused defines ... While working on the adm1021 driver, I found that this driver has a ... number of unused (and useless) defines we could get rid of. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Linux 2.6.11-rc1
      ... small char/generic_serial.c cleanup ... lockd: fix two struct definitions ... serial driver for TI USB 3410/5052 chips ... Split ACPI boot table parsing ...
      (Linux-Kernel)
    • Re: My thoughts on the "new development model"
      ... |>>> 2.6 tree is great for gentoo users who like gcc consuming all CPU ... |>> that after a month or so of fixes etc it will be a very stable kernel ... driver for 2.6.7 for an ADSL card; a development driver for 2.6.5 for a ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: sata related hang with linux-2.6
      ... IMHO there's something not quite right with the Silicon Image libata ... Perhaps the driver is enabling the hardware to generate interrupts ... before setting up the interrupt routine for it? ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)