linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Austin Hendrix <namniart@gmail.com>
To: linux-can@vger.kernel.org
Subject: [PATCH] sllin: update for kernels > 3.11
Date: Mon, 25 Apr 2016 15:46:53 -0700	[thread overview]
Message-ID: <571E9E5D.3000806@gmail.com> (raw)

I'm experimenting with sllin ( https://rtime.felk.cvut.cz/can/lin-bus/ 
), and I've found that it doesn't compile on linux kernels newer than 
3.11, so I've patched it to compile and (hopefully) run on newer kernels.

I've verified that these changes compile and the resulting module loads 
on the 4.2.0 kernel on my Ubuntu machine, but I don't have LIN hardware 
yet and haven't tried attaching the LIN serial line discipline to a 
serial port.

In the event that this driver is no longer maintained, I'm also hosting 
my copy of the source on github: https://github.com/trainman419/linux-lin

Author: Austin Hendrix <namniart@gmail.com>
Date:   Mon Apr 25 10:41:13 2016 -0700

     Update for changes in recent linux kernels

Signed-off-by: Austin Hendrix <namniart@gmail.com>
diff --git a/sllin/sllin.c b/sllin/sllin.c

index 8d7ad69..2db896f 100644
--- a/sllin/sllin.c
+++ b/sllin/sllin.c
@@ -210,7 +210,11 @@ static int sltty_change_speed(struct tty_struct 
*tty, unsigned speed)
      struct ktermios old_termios, termios;
      int cflag;

+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0)
      mutex_lock(&tty->termios_mutex);
+#else
+    down_write(&tty->termios_rwsem);
+#endif

  #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)
      old_termios = termios = *(tty->termios);
@@ -238,7 +242,11 @@ static int sltty_change_speed(struct tty_struct 
*tty, unsigned speed)
      if (tty->ops->set_termios)
          tty->ops->set_termios(tty, &old_termios);

+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0)
      mutex_unlock(&tty->termios_mutex);
+#else
+    up_write(&tty->termios_rwsem);
+#endif

      return 0;
  }
@@ -311,7 +319,12 @@ static void sllin_write_wakeup(struct tty_struct *tty)
              return;    /* ongoing concurrent processing */

          clear_bit(SLF_TXBUFF_RQ, &sl->flags);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)
          smp_mb__after_clear_bit();
+#else
+        smp_mb__after_atomic();
+#endif

          if (sl->lin_state != SLSTATE_BREAK_SENT)
              remains = sl->tx_lim - sl->tx_cnt;
@@ -325,7 +338,11 @@ static void sllin_write_wakeup(struct tty_struct *tty)
              remains -= actual;
          }
          clear_bit(SLF_TXBUFF_INPR, &sl->flags);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)
          smp_mb__after_clear_bit();
+#else
+        smp_mb__after_atomic();
+#endif

      } while (unlikely(test_bit(SLF_TXBUFF_RQ, &sl->flags)));

@@ -838,7 +855,11 @@ static int sllin_send_tx_buff(struct sllin *sl)
              return 0;    /* ongoing concurrent processing */

          clear_bit(SLF_TXBUFF_RQ, &sl->flags);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)
          smp_mb__after_clear_bit();
+#else
+        smp_mb__after_atomic();
+#endif

  #ifdef BREAK_BY_BAUD
          if (sl->lin_state != SLSTATE_BREAK_SENT)
@@ -872,7 +893,11 @@ static int sllin_send_tx_buff(struct sllin *sl)
                  sl->tx_cnt, remains);

          clear_bit(SLF_TXBUFF_INPR, &sl->flags);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)
          smp_mb__after_clear_bit();
+#else
+        smp_mb__after_atomic();
+#endif

      } while (unlikely(test_bit(SLF_TXBUFF_RQ, &sl->flags)));

@@ -1337,7 +1362,12 @@ static struct sllin *sll_alloc(dev_t line)
          char name[IFNAMSIZ];
          sprintf(name, "sllin%d", i);

+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0))
          dev = alloc_netdev(sizeof(*sl), name, sll_setup);
+#else
+        dev = alloc_netdev(sizeof(*sl), name, NET_NAME_UNKNOWN, sll_setup);
+#endif
+
          if (!dev)
              return NULL;
          dev->base_addr  = i;



             reply	other threads:[~2016-04-25 22:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-25 22:46 Austin Hendrix [this message]
2016-04-26  0:34 ` [PATCH] sllin: update for kernels > 3.11 Pavel Pisa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=571E9E5D.3000806@gmail.com \
    --to=namniart@gmail.com \
    --cc=linux-can@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).