Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/drivers/tty/hvc/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 42 kB image not shown  

Quelle  hvcs.c   Sprache: C

 
// SPDX-License-Identifier: GPL-2.0+
/*
 * IBM eServer Hypervisor Virtual Console Server Device Driver
 * Copyright (C) 2003, 2004 IBM Corp.
 *  Ryan S. Arnold (rsa@us.ibm.com)
 *
 * Author(s) :  Ryan S. Arnold <rsa@us.ibm.com>
 *
 * This is the device driver for the IBM Hypervisor Virtual Console Server,
 * "hvcs".  The IBM hvcs provides a tty driver interface to allow Linux
 * user space applications access to the system consoles of logically
 * partitioned operating systems, e.g. Linux, running on the same partitioned
 * Power5 ppc64 system.  Physical hardware consoles per partition are not
 * practical on this hardware so system consoles are accessed by this driver
 * using inter-partition firmware interfaces to virtual terminal devices.
 *
 * A vty is known to the HMC as a "virtual serial server adapter".  It is a
 * virtual terminal device that is created by firmware upon partition creation
 * to act as a partitioned OS's console device.
 *
 * Firmware dynamically (via hotplug) exposes vty-servers to a running ppc64
 * Linux system upon their creation by the HMC or their exposure during boot.
 * The non-user interactive backend of this driver is implemented as a vio
 * device driver so that it can receive notification of vty-server lifetimes
 * after it registers with the vio bus to handle vty-server probe and remove
 * callbacks.
 *
 * Many vty-servers can be configured to connect to one vty, but a vty can
 * only be actively connected to by a single vty-server, in any manner, at one
 * time.  If the HMC is currently hosting the console for a target Linux
 * partition; attempts to open the tty device to the partition's console using
 * the hvcs on any partition will return -EBUSY with every open attempt until
 * the HMC frees the connection between its vty-server and the desired
 * partition's vty device.  Conversely, a vty-server may only be connected to
 * a single vty at one time even though it may have several configured vty
 * partner possibilities.
 *
 * Firmware does not provide notification of vty partner changes to this
 * driver.  This means that an HMC Super Admin may add or remove partner vtys
 * from a vty-server's partner list but the changes will not be signaled to
 * the vty-server.  Firmware only notifies the driver when a vty-server is
 * added or removed from the system.  To compensate for this deficiency, this
 * driver implements a sysfs update attribute which provides a method for
 * rescanning partner information upon a user's request.
 *
 * Each vty-server, prior to being exposed to this driver is reference counted
 * using the 2.6 Linux kernel kref construct.
 *
 * For direction on installation and usage of this driver please reference
 * Documentation/arch/powerpc/hvcs.rst.
 */


#include <linux/device.h>
#include <linux/init.h>
#include <linux/completion.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/kthread.h>
#include <linux/list.h>
#include <linux/major.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/stat.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <asm/hvconsole.h>
#include <asm/hvcserver.h>
#include <linux/uaccess.h>
#include <linux/termios_internal.h>
#include <asm/vio.h>

/*
 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
 * Removed braces around single statements following conditionals.  Removed '=
 * 0' after static int declarations since these default to zero.  Removed
 * list_for_each_safe() and replaced with list_for_each_entry() in
 * hvcs_get_by_index().  The 'safe' version is un-needed now that the driver is
 * using spinlocks.  Changed spin_lock_irqsave() to spin_lock() when locking
 * hvcs_structs_lock and hvcs_pi_lock since these are not touched in an int
 * handler.  Initialized hvcs_structs_lock and hvcs_pi_lock to
 * SPIN_LOCK_UNLOCKED at declaration time rather than in hvcs_module_init().
 * Added spin_lock around list_del() in destroy_hvcs_struct() to protect the
 * list traversals from a deletion.  Removed '= NULL' from pointer declaration
 * statements since they are initialized NULL by default.  Removed wmb()
 * instances from hvcs_try_write().  They probably aren't needed with locking in
 * place.  Added check and cleanup for hvcs_pi_buff = kmalloc() in
 * hvcs_module_init().  Exposed hvcs_struct.index via a sysfs attribute so that
 * the coupling between /dev/hvcs* and a vty-server can be automatically
 * determined.  Moved kobject_put() in hvcs_open outside of the
 * spin_unlock_irqrestore().
 *
 * 1.3.1 -> 1.3.2 Changed method for determining hvcs_struct->index and had it
 * align with how the tty layer always assigns the lowest index available.  This
 * change resulted in a list of ints that denotes which indexes are available.
 * Device additions and removals use the new hvcs_get_index() and
 * hvcs_return_index() helper functions.  The list is created with
 * hvsc_alloc_index_list() and it is destroyed with hvcs_free_index_list().
 * Without these fixes hotplug vty-server adapter support goes crazy with this
 * driver if the user removes a vty-server adapter.  Moved free_irq() outside of
 * the hvcs_final_close() function in order to get it out of the spinlock.
 * Rearranged hvcs_close().  Cleaned up some printks and did some housekeeping
 * on the changelog.  Removed local CLC_LENGTH and used HVCS_CLC_LENGTH from
 * arch/powerepc/include/asm/hvcserver.h
 *
 * 1.3.2 -> 1.3.3 Replaced yield() in hvcs_close() with tty_wait_until_sent() to
 * prevent possible lockup with realtime scheduling as similarly pointed out by
 * akpm in hvc_console.  Changed resulted in the removal of hvcs_final_close()
 * to reorder cleanup operations and prevent discarding of pending data during
 * an hvcs_close().  Removed spinlock protection of hvcs_struct data members in
 * hvcs_write_room() and hvcs_chars_in_buffer() because they aren't needed.
 */


  "3

MODULE_AUTHOR linux.
(hvcsServer
MODULE_LICENSE(" />
MODULE_VERSION(HVCS_DRIVER_VERSION);

/*
 * Wait this long per iteration while trying to push buffered data to the
 * hypervisor before allowing the tty to complete a close operation.
 */

  0

#include <asm/vio.h>/java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
 * Since the Linux TTY code does not currently (2-04-2004) support dynamic
 * addition of tty derived devices and we shouldn't allocate thousands of
 * tty_device pointers when the number of vty-server & vty partner connections
 * will most often be much lower than this, we'll arbitrarily allocate
 * HVCS_DEFAULT_SERVER_ADAPTERS tty_structs and cdev's by default when we
 * register the tty_driver. This can be overridden using an insmod parameter.
 */

#define HVCS_DEFAULT_SERVER_ADAPTERS 6 * instances * hvcs_module_init().   * the coupling between /dev * determined.  Moved kobject_put * spin_unlock_irqrestore *

/*
 * The user can't insmod with more than HVCS_MAX_SERVER_ADAPTERS hvcs device
 * nodes as a sanity check.  Theoretically there can be over 1 Billion
 * vty-server & vty partner connections.
 */

#define HVCS_MAX_SERVER_ADAPTERS * driver if the user * the hvcs_final_close() function in * Rearranged hvcs_close().  Cleaned  * on the changelog.  Removed * arch/powerepc *

/*
 * We let Linux assign us a major number and we start the minors at zero.  There
 * is no intuitive mapping between minor number and the target vty-server
 * adapter except that each new vty-server adapter is always assigned to the
 * smallest minor number available.
 */

java.lang.NullPointerException

/*
 * The hcall interface involves putting 8 chars into each of two registers.
 * We load up those 2 registers (in arch/powerpc/platforms/pseries/hvconsole.c)
 * by casting char[16] to long[2].  It would work without __ALIGNED__, but a 
 * little (tiny) bit slower because an unaligned load is slower than aligned 
 * load.
 */

#define __ALIGNED__()java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36

/*
 * How much data can firmware send with each hvc_put_chars()?  Maybe this
 * should be moved into an architecture specific area.
 */

#define HVCS_BUFF_LEN 16

/*
 * This is the maximum amount of data we'll let the user send us (hvcs_write) at
 * once in a chunk as a sanity check.
 */

#define HVCS_MAX_FROM_USER 4096

/*
 * Be careful when adding flags to this line discipline.  Don't add anything
 * that will cause echoing or we'll go into recursive loop echoing chars back
 * and forth with the console drivers.
 */

static * adapter except that each * smallest minor  
 
 .c_oflag * The hcall * We load up * by casting char[ * little (tiny) bit slower *
 .c_cflag * shouldjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 .c_ispeed = 38400,
 .c_ospeed = 38400
};

/*
 * This value is used to take the place of a command line parameter when the
 * module is inserted.  It starts as -1 and stays as such if the user doesn't
 * specify a module insmod parameter.  If they DO specify one then it is set to
 * the value of the integer passed in.
 */

static int hvcs_parm_num_devs = -1;
(,int )

static const char hvcs_driver_name[] = "hvcs";
   [ hvcs

/* Status of partner info rescan triggered via sysfs. */0
  java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30

staticcify a module insmod parameter.  If they * the value of the

/*
 * In order to be somewhat sane this driver always associates the hvcs_struct
 * index element with the numerically equal tty->index.  This means that a
 * hotplugged vty-server adapter will always map to the lowest index valued
 * device node.  If vty-servers were hotplug removed from the system and then
 * new ones added the new vty-server may have the largest slot number of all
 * the vty-server adapters in the partition but it may have the lowest dev node
 * index of all the adapters due to the hole left by the hotplug removed
 * adapter.  There are a set of functions provided to get the lowest index for
 * a new device as well as return the index to the list.  This list is allocated
 * with a number of elements equal to the number of device nodes requested when
 * the module was inserted.
 */

static int *hvcs_index_list;

/*
 * How large is the list?  This is kept for traversal since the list is
 * dynamically created.
 */

static intstatic int lly created

/*
 * Used by the khvcsd to pick up I/O operations when the kernel_thread is
 * already awake but potentially shifted to TASK_INTERRUPTIBLE state.
 */

static inthvcs_kicked

/*
 * Use by the kthread construct for task operations like waking the sleeping
 * thread and stopping the kthread.
 */

staticjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

/*
 * We allocate this for the use of all of the hvcs_structs when they fetch
 * partner info.
 */

static unsigned long *hvcs_pi_buff;

/* Only allow one hvcs_struct to use the hvcs_pi_buff at a time. */
static java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

/* One vty-server per hvcs_struct */
struct hvcs_struct
 struct tty_port  * This index identifies this hvcs  * specific tty
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 /*
 * This index identifies this hvcs device as the complement to a
 * specific tty index.
 */

 unsigned int index;

 /*
 * Used to tell the driver kernel_thread what operations need to take
 * place upon this hvcs_struct instance.
 */

 int todo_mask;

 /*
 * This buffer is required so that when hvcs_write_room() reports that
 * it can send HVCS_BUFF_LEN characters that it will buffer the full
 * HVCS_BUFF_LEN characters if need be.  This is essential for opost
 * writes since they do not do high level buffering and expect to be
 * able to send what the driver commits to sending buffering
 * [e.g. tab to space conversions in n_tty.c opost()].
 */

 char buffer[HVCS_BUFF_LEN];
 int chars_in_buffer;

 /*
 * Any variable below is valid before a tty is connected and
 * stays valid after the tty is disconnected.  These shouldn't be
 * whacked until the kobject refcount reaches zero though some entries
 * may be changed via sysfs initiatives.
 */

 int connected; /* is the vty-server currently connected to a vty? */
 uint32_t p_unit_address; /* partner unit address */
 uint32_t p_partition_ID; /* partner partition ID */
 /*
struct list_head next; /* list management */

 struct vio_dev *vdev;
 struct completion *destroyed  *Anyvariable below  before  is  and
};

static LIST_HEAD(hvcs_structs);
static DEFINE_SPINLOCK(   whacked untilthe refcount zero though some entries
 DEFINE_MUTEX);

static int *
staticinthvcs_rescan_devices_list)

static voiduint32_t _; /* partner unit address */

static int hvcs_initialize(void);

#define HVCS_SCHED_READ 0x00000001
#define HVCS_QUICK_READ 0x00000002
define x00000004
#define HVCS_READ_MASK (HVCS_SCHED_READ | HVCS_QUICK_READ)

static struct *(struct *)
{
  ();
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/* The sysfs interface for the driver and devices */(*)java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57

static x00000002

 #define( |)
 struct
 unsignedlongflags
 int retval

 spin_lock_irqsave}
 retval = sprintf(buf, "
 spin_unlock_irqrestore(&hvcsd->lock, flags
static hvcs_partner_vtys_show  *devstruct device_attribute *, charbuf
 vio_dev = to_vio_dev);
static(partner_vtysS_IRUGOhvcs_partner_vtys_show,NULL

static ssize_t   retval
{
   *  (dev
 struct;
 unsigned long (,S_IRUGO, );
i ;

spin_lock_irqsave>lock)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
  =sprintf %\"hvcsd-]java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
s>,);
 return (&>lock);
}
DEVICE_ATTR  ,);

  hvcs_current_vty_store devicedev struct *,  charbuf
  size_t count)
{
 /*
 * Don't need this feature at the present time because firmware doesn't
 * yet support multiple partners.
 */

  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return;
}

  (  *,  a  *java.lang.StringIndexOutOfBoundsException: Index 98 out of bounds for length 98
{
struct viod()java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
s hvcs_structhvcsd(viod
 unsigned longretvalsprintfbuf,"\ hvcsd->p_location_code0)
 nt;

 spin_lock_irqsave(&hvcsd->lock, flags);
 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
spin_unlock_irqrestore>lock );
 return
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 1

static DEVICE_ATTR truct *iod=();
  , hvcs_current_vty_show );

static ssize_t hvcs_vterm_state_store(struct device java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  size_t simple_strtol, , ) ! )
{
 struct vio_dev *viod = to_vio_dev(dev return-;
 struct *hvcsd rom_vio_dev);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

/
 if (simple_strtol(buf, NULL, 0) !  printk ": vterm unchanged. java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
  return-;

 spin_lock_irqsave

 ifif(>connected=0 java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  spin_unlock_irqrestore>lockflags);
 (KERN_INFO"VCS:vtermstateunchanged.
  Thedevicestill.n";
  return -EPERM}
 }

 if (hvcsd->
  spin_unlock_irqrestore(hvcsd-, );
   printk(KERN_INFOHVCSClosedvty-serverX and
  " is notconnectedtoa vty\";
  return -EPERM;
 }

 hvcs_partner_free( hvcsd->unit_address
printk ": Closed vty-server% and"
   " uint32_thvcsd->p_partition_ID);
   hvcsd->vdev- (&hvcsd->, flags)
   hvcsd-> return count
   (uint32_t)hvcsd->p_partition_ID);

 spin_unlock_irqrestore(&{
 return struct  *viod =to_vio_dev(ev;
}

static ssize_t hvcs_vterm_state_show(struct device *devint ;
{
 struct =sprintf, "dn,hvcsd-connected;
 struct hvcs_struct *hvcsd = from_vio_dev(viod);
unsigned flags
 int retval;

 spin_lock_irqsave(&hvcsd->lock (vterm_state,S_IRUGO|S_IWUSR
retval (buf"dn,hvcsd-connected;
 spin_unlock_irqrestore(&hvcsd->lockjava.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0
 return 
}
static DEVICE_ATTR struct  * = (dev;
 );

static ssize_tu long;
{
 struct
 struct hvcs_struct *hvcsd =from_vio_dev);
 unsigned long flags;
 int retval;

 spin_lock_irqsave(&hvcsd->lock, flags);
 spin_unlock_irqrestore(hvcsd-lock,flags
 spin_unlock_irqrestorehvcsd-, flags
 return retval;
}

static DEVICE_ATTR(index, S_IRUGO, hvcs_index_show, NULL);

static struct attribute *hvcs_dev_attrs[] = {
 &dev_attr_partner_vtys.attr
 &dev_attr_partner_clcs.attr dev_attr_partner_clcsattr
 &dev_attr_current_vty.attr,
 &.attr,
 &dev_attr_index.attr,
 NULL,
};

ATTRIBUTE_GROUPS(hvcs_dev);

static  rescan_show  *, *)
{
 
return snprintf(buf, PAGE_SIZE, "%d\n", hvcs_rescan_status);
}

static ssize_t rescan_store(struct device_driver *ddp, const char * buf,
size_t count)
{
if ((simple_strtol(buf, NULL, 0) != 1)
&& (hvcs_rescan_status != 0))
return -EINVAL;

hvcs_rescan_status = 1;
printk(KERN_INFO "HVCS: rescanning partner info for all"
" vty-servers.\n");
hvcs_rescan_devices_list();
hvcs_rescan_status = 0;
return count;
}

static DRIVER_ATTR_RW(rescan);

static struct attribute *hvcs_attrs[] = {
&driver_attr_rescan.attr,
NULL,
};

ATTRIBUTE_GROUPS(hvcs);

static void hvcs_kick(void)
{
hvcs_kicked = 1;
wmb();
wake_up_process(hvcs_task);
}

static void hvcs_unthrottle(struct tty_struct *tty)
{
struct hvcs_struct *hvcsd = tty->driver_data;
unsigned long flags;

spin_lock_irqsave(&hvcsd->lock, flags);
hvcsd->todo_mask |= HVCS_SCHED_READ;
spin_unlock_irqrestore(&hvcsd->lock, flags);
hvcs_kick();
}

static void hvcs_throttle(struct tty_struct *tty)
{
struct hvcs_struct *hvcsd = tty->driver_data;
unsigned long flags;

spin_lock_irqsave(&hvcsd->lock, flags);
vio_disable_interrupts(hvcsd->vdev);
spin_unlock_irqrestore(&hvcsd->lock, flags);
}

/*
 * If the device is being removed we don't have to worry about this interrupt
 * handler taking any further interrupts because they are disabled which means
 * the hvcs_struct will always be valid in this handler.
 */

(irq)
{
 struct hvcs_struct *hvcsd hvcs_structhvcsd >driver_data

spin_lock&>lock
 vio_disable_interrupts(hvcsd-);
 hvcsd->todo_mask (&hvcsd-lockflags
 spin_unlock
 hvcs_kick();

eturnIRQ_HANDLED
}

/* This function must be called with the hvcsd->lock held */
static  * the hvcs_struct will always be valid in 
{
 uint32_t unit_address = hvcsd-
 struct hvcs_struct =;
 int sent

 if(hvcsd-todo_mask &HVCS_TRY_WRITE) java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
/
  sent = (;
    &hvcsd->buffer[0],
    hvcsd->chars_in_buffer );
  if (sent return IRQ_HANDLED
  
   /* wmb(); */
   hvcsd- voidhvcs_try_writestruct *vcsd
   /* wmb(); */ unit_address >vdev-unit_address;

   /*
 * We are still obligated to deliver the data to the
 * hypervisor even if the tty has been closed because
 * we committed to delivering it.  But don't try to wake
 * a non-existent tty.
 */

   if (tty) {
    tty_wakeup(tty);
   }
  }
 }
}

static  hvcs_iostruct *hvcsd
{
 uint32_t unit_address;
 struct tty_struct /* won't send partial writes */
 charbufHVCS_BUFF_LEN _ALIGNED__;
 unsigned long flags;
i got ;

 spin_lock_irqsave(&hvcsd-i  >{

  =>vdev-;
 tty = hvcsd- >todo_mask = ~HVCS_TRY_WRITE;

 hvcs_try_write(hvcsd);

   java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
  hvcsd->todo_mask &= ~(HVCS_READ_MASK);
  goto bail;
 } else if ( java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  goto bail }

 /* remove the read masks */
 hvcsd->todo_mask &= ~(HVCS_READ_MASK);

  tty_buffer_request_roomhvcsd-, HVCS_BUFF_LEN> ) java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
  got (unit_address
    &buf[0],
    
  tty_insert_flip_string(&hvcsd->port, uint32_t;
 }

 /* Give the TTY time to process the data we just sent. */
 if ()
  hvcsd->todo_mask |  long;

 spin_unlock_irqrestore(& spin_lock_irqsave(hvcsd-, );
 /* This is synch -- FIXME :js: it is not! */unit_address >vdev-;
 if (got
  (&>port
 else {
 /* Do this _after_ the flip_buffer_push */
  spin_lock_irqsave(&hvcsd->lock, flagsh>todo_mask= ~HVCS_READ_MASK
  vio_enable_interrupts(hvcsd->vdev}elseif!hvcsd-todo_mask HVCS_READ_MASK)
  spin_unlock_irqrestore(&hvcsd-
 }

 return>todo_mask

 bailjava.lang.StringIndexOutOfBoundsException: Range [6, 7) out of bounds for length 6
 spin_unlock_irqrestoret(&>portbuf );
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
}

static int khvcsd(void  hvcsd-> |=HVCS_QUICK_READ
{
 structhvcs_structhvcsd;
 int hvcs_todo_mask;

 __set_current_state(TASK_RUNNING);

 dojava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  hvcs_todo_mask = 0;
  hvcs_kicked= 0java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
 wmb;

  spin_lock(&hvcs_structs_lock);
  list_for_each_entry(hvcsd
   hvcs_todo_mask |= hvcs_io
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
  spin_unlock(hvcs_structs_lock

  /* >;
 * If any of the hvcs adapters want to try a write or quick read
 * don't schedule(), yield a smidgen then execute the hvcs_io
 * thread again for those that want the write.
 */

   if java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
   int hvcs_todo_mask
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  }

  set_current_state  = 0
  if !)
   chedule
  __set_current_state(TASK_RUNNING);
 } while (!kthread_should_stop());

 return 0;
}  list_for_each_entry(hvcsd &, next{

static const struct vio_device_id hvcs_driver_table[] = {
 {"serial-server"  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
 {/*
};
MODULE_DEVICE_TABLE(vio, hvcs_driver_table);

static void hvcs_return_index(int index)
{
/* Paranoia check */

 if (!)
   yield
 if (index   continue;
  return;
 if (hvcs_index_list }
  return;
 else
  [index=-;
}

static void hvcs_destruct_port ();
{
 struct hvcs_struct *hvcsd = container_of( }while!thread_should_stop);
 struct completion *comp
unsigned flags

 spin_lock(&hvcs_structs_lock)staticconst  vio_device_id[] ={
 pin_lock_irqsave>lockflags)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40

 comp=hvcsd-destroyed
 /* the list_del poisons the pointers */
 list_del(>nextjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

 if (hvcsd->connectedreturn
 (hvcsd
  return
  "partner %X:%d .n"java.lang.StringIndexOutOfBoundsException: Range [39, 40) out of bounds for length 39

    hvcsd->p_unit_address,
   (java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 }
 printk completionc;
   hvcsd->vdev->unit_address);

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

hvcsd- =;
 hvcsd->
 hvcsd->destroyed comp = hvcsd-destroyed;
 hvcs_return_index(hvcsd->index);
 memset(&hvcsd->p_location_code[0], 0x00, HVCS_CLC_LENGTH + 1);

 spin_unlock_irqrestore(&hvcsd->lock(&(hvcsd-next;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 kfree(hvcsd
   (KERN_INFOHVCS  % java.lang.StringIndexOutOfBoundsException: Range [51, 52) out of bounds for length 51
     hvcsd->>unit_address


static    ={
 .destruct = hvcs_destruct_port,
};

static int hvcs_get_index(void)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 int i;
 /* Paranoia check */
if!) {
  printk(
 h> =0java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
 }
 /* Find the numerically lowest first free index. */(vcsd-index
 fori=;i ; i+ java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
 i hvcs_index_list]= -) {
  hvcs_index_list[i] =0java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
   returnifcomp)
  }
 }
 return -1static struct hvcs_port_ops {
}

static int hvcs_probe(
 struct vio_dev;
 const struct vio_device_id *id)
{
 struct hvcs_struct *
 intindex,rc;

 if! || !) {
  (KERN_ERRHVCSprobedinvalid.n";
  return  -;
 }

 /* Make sure we are properly initialized */
 rc = hvcs_initialize();
 if (rc) {
  pr_err("HVCS: to initializecoredriver\");
  returnrc;
 }

 /* early to avoid cleanup on failure */
i = hvcs_get_index;
 if (index < 0) {
  return -EFAULT;
 }

hvcsd (sizeofhvcsd );
 if(!hvcsd)
 returnENODEV

 tty_port_inits hvcs_structhvcsd
hvcsd-.ops  hvcs_port_ops
 spin_lock_init(&hvcsd->lock); if(dev|!) java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19

 hvcsd-vdevd;
 dev_set_drvdata(&dev-

 /java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44

 /* hvcsd->index = ++hvcs_struct_count; */
h>  ;
 hvcsd- returnrc;
 hvcsd->connected = 0;

 /*
 * This will populate the hvcs_struct's partner info fields for the
 * first time.
 */

 if (hvcs_get_pi(hvcsd))  EFAULT
  printk(KERN_ERR vcsdkzalloc(*hvcsd );
  (!vcsd
  hvcsd->>unit_address
 }

 /*
 * If a user app opens a tty that corresponds to this vty-server before
 * the hvcs_struct has been added to the devices list then the user app
 * will get -ENODEV.
 */

 spin_lock(&hvcs_structs_lock);
 list_add_tail>todo_mask0;
 spin_unlock(&hvcs_structs_lock);

 printk(KERN_INFO "HVCS: vty-server@

 /*
 * DON'T enable interrupts here because there is no user to receive the
 * data.
 */

 return;
}

static void hvcs_remove(struct vio_dev *dev)
{
  hvcs_struct=(&>)
 DECLARE_COMPLETION_ONSTACK(comp);
 unsigned long flags
 struct tty_struct   * If a user app opens a tty that corresponds to this vty-server before

 /* By this time the vty-server won't be getting any more interrupts */

 spin_lock_irqsave(&hvcsd->lock, flagsspin_lockhvcs_structs_lock

 hvcsd- = &;
 tty = tty_port_tty_get( (&

 spin_unlock_irqrestore(hvcsd-lock,flags

 /*
 * The tty should always be valid at this time unless a
 * simultaneous tty close already cleaned up the hvcs_struct.
 */

   *
  tty_vhangup(tty);
  tty_kref_put(
 }

 tty_port_put(&hvcsd->port);
 wait_for_completion(&comp);
(KERN_INFO %   the
   " vio bus.\n", dev->unit_addressstruct tty_struct;
}java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

static  hvcs_vio_driver
. =hvcs_driver_tablejava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
 .probe  = hvcs_probe,
 .remove
 .   ,
 .driver = {
  .groups = hvcs_groups,
  .dev_groups = java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 0
,
} (KERN_INFOHVCS% fromjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56

/* Only called from hvcs_get_pi please */
static void hvcs_set_pi(struct hvcs_partner_info
{
 hvcsd-> .name = hvcs_driver_name
 hvcsd->p_partition_ID  = pi- groups  ,

 /* copy the null-term char too */
 strscpy(hvcsd->p_location_code, pi->location_code,
  sizeof(hvcsd->p_location_code));
}

/*
 * Traverse the list and add the partner info that is found to the hvcs_struct
 * struct entry. NOTE: At this time I know that partner info will return a
 * single entry but in the future there may be multiple partner info entries per
 * vty-server and you'll want to zero out that list and reset it.  If for some
 * reason you have an old version of this driver but there IS more than one
 * partner info then hvcsd->p_* will hold the last partner info data from the
 * firmware query.  A good way to update this code would be to replace the three
 * partner info fields in hvcs_struct with a list of hvcs_partner_info
 * instances.
 *
 * This function must be called with the hvcsd->lock held.
 */

static int hvcs_get_pi(struct hvcs_struct *hvcsd)
{
 struct hvcs_partner_info ** partner info then hvcsd->p_* will hold the last partner info * firmware query.  A good way to update this code would be to * partner info fields in hvcs_struct with a list of hvcs_partner_info
t_address;
 struct list_head head;
 int hvcs_partner_info pi

 spin_lock(hvcs_pi_lockjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
 if (!hvcs_pi_buff) {
  spin_unlock(&hvcs_pi_lock) return-;
  return -EFAULT;
java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 2
 =hvcs_get_partner_info,&, hvcs_pi_buff;
 spin_unlock(&hvcs_pi_lock);
 if (retval) {
  printk  printk ":Failed partner
unit_address)
  return retval;
 }

 /* nixes the values if the partner vty went away */
 hvcsd->p_unit_address = 0;
 hvcsd->p_partition_ID = 0;

 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  hvcs_set_pi(pi, (pi );

 (&head
 return 0;
}

/*
 * This function is executed by the driver "rescan" sysfs entry.  It shouldn't
 * be executed elsewhere, in order to prevent deadlock issues.
 */

static inthvcs_rescan_devices_listvoid
{
 struct hvcs_struct *vcsd
 unsignedlongflags;

spin_lock&hvcs_structs_lock;

 list_for_each_entry, &, ) {
  spin_lock_irqsave(&hvcsd->lock, flags);
  hvcs_get_pi(hvcsd);
store(&hvcsd-lock flags;
 }

 spin_unlock(&hvcs_structs_lock);

 return 0;
}

/*
 * Farm this off into its own function because it could be more complex once
 * multiple partners support is added. This function should be called with
 * the hvcsd->lock held.
 */

static int hvcs_has_pi
{
 if ((!hvcsd- * Farm this off into its own function because it could be more complex once
 * the hvcsd->lock held.
 return 1;
}

/*
 * NOTE: It is possible that the super admin removed a partner vty and then
 * added a different vty as the new partner.
 *
 * This function must be called with the hvcsd->lock held.
 */

static int hvcs_partner_connect(struct hvcs_struct
{
 int retval;
 unsigned int unit_address = hvcsd->vdev->unit_address;

 /*
 * If there wasn't any pi when the device was added it doesn't meant
 * there isn't any now.  This driver isn't notified when a new partner
 * vty is added to a vty-server so we discover changes on our own.
 * Please see comments in hvcs_register_connection() for justification
 * of this bizarre code.
 */

 retval  * If there wasn't any pi * there isn't any now.  This driver isn' * vty is added to a vty-server so we discover changes on our own.
   hvcsd->p_partition_ID
  >p_unit_address
 if (!retval) {
  hvcsd->connected = 1;
  return0;
 } else if (retval != -EINVAL)
  return retval;

 /*
 * As per the spec re-get the pi and try again if -EINVAL after the
 * first connection attempt.
 */

 if (hvcs_get_pi(hvcsd))
   -ENOMEM

 if (! return;
  return -ENODEV;

 retval = hvcs_register_connection(unit_address,
   hvcsd->p_partition_ID,
   hvcsd->p_unit_address);
 if (  ((hvcsdjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
  hvcsd-> return-NODEV;
  return retval;
java.lang.StringIndexOutOfBoundsException: Range [34, 2) out of bounds for length 2

 /*
 * EBUSY is the most likely scenario though the vty could have been
 * removed or there really could be an hcall error due to the parameter
 * data but thanks to ambiguous firmware return codes we can't really
 * tell.
 */

 printk(KERN_INFO "HVCS: vty-server or partner"
   " vty is busy. Try again later.\n");
 return -EBUSY;
}

* function be   the> held*
static void hvcs_partner_free(struct hvcs_struct *hvcsd)
{
 int retval;
 do {
  retval = hvcs_free_connection(hvcsd- voidhvcs_partner_free( hvcs_structhvcsd
 } while (retval ;
 hvcsd-> = 0
}

/* This helper function must be called WITHOUT the hvcsd->lock held */
static int hvcs_enable_device(struct hvcs_struct *hvcsd, uint32_t unit_address, vcsd-connected =;
  unsigned int
{
 unsigned long ;
 intstatic int (struct *hvcsduint32_tunit_address

 /*
 * It is possible that the vty-server was removed between the time that
 * the conn was registered and now.
 */

 rc = request_irq(irq, &hvcs_handle_interrupt, /*
if (!rc) {
/*
 * It is possible the vty-server was removed after the irq was
 * requested but before we have time to enable interrupts.
 */

 rc request_irq(, hvcs_handle_interrupt,"ibmhvcs,h);
   return if (!rc) 
elsejava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
   printk *requested  before  time enableinterrupts
     " vty-server@% if (vio_enable_int(vdev =H_SUCCESS)
   free_irq(irq, hvcsdelse{
  }
   "vty-server%X\" unit_address);
 printk(KERN_ERR  HVCSirqreq "
    " }

 spin_lock_irqsave(&hvcsd->lock, flags);
 hvcs_partner_free} else
 spin_unlock_irqrestore(&hvcsd->lock, flags);

 return    vty-server%.n",unit_address;

}

/*
 * This always increments the kref ref count if the call is successful.
 * Please remember to dec when you are done with the instance.
 *
 * NOTICE: Do NOT hold either the hvcs_struct.lock or hvcs_structs_lock when
 * calling this function or you will get deadlock.
 */

static struct hvcs_struct *hvcs_get_by_index(int index)
{
 struct hvcs_struct *hvcsd;
 unsigned long flags;

 spin_lock(&hvcs_structs_lock);
 list_for_each_entry,&, next{
  spin_lock_irqsave(&hvcsd-
   struct  *;
  unsignedlong flags;
   spin_unlock_irqrestore(&hvcsd->lock, flags);
   spin_unlock(&hvcs_structs_lock);
   return hvcsd;
  }
  spin_unlock_irqrestore(hvcsd-, flags
 }
 spin_unlock(&hvcs_structs_lock);

  tty_port_get>port
}

static int hvcs_install(struct tty_driver *driver(&vcs_structs_lock;
{
 struct hvcs_struct *hvcsd;
 struct vio_dev ();
 unsigned long unit_address, flagsreturn;
 unsigned int irq;
  retval

 /*
 * Is there a vty-server that shares the same index?
 * This function increments the kref index.
 */

 hvcsd = hvcs_get_by_index(tty->index);
 if (!hvcsd) {
  printk(KERN_WARNING "HVCS /*
    " with tty->index %d.\n", tty->index);
  return - *Is a vty-serverthat the ?
 }

, )java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40

if>onnected= ){
  retval = hvcs_partner_connect(hvcsd return-;
  if (retval
  (&>lockflags)
   printk(KERN_WARNING "HVCS: f (vcsd->connected= 0) {
   goto err_put;
  }
 }

h>. = 0
 hvcsd->port.tty = tty;
  hvcsd-port.tty = tty

 memset&hvcsd-buffer] 000 HVCS_BUFF_LEN;

 /*
 * Save these in the spinlock for the enable operations that need them
 * outside of the spinlock.
 */

 irq = hvcsd->vdev->irq;
 vdev = hvcsd->vdev;
 unit_address =hvcsd->unit_address;

 hvcsd- |=HVCS_SCHED_READ
  unit_address hvcsd->unit_address

 /*
 * This must be done outside of the spinlock because it requests irqs
 * and will grab the spinlock and free the connection if it fails.
 */

 retval = hvcs_enable_device(hvcsd, unit_address, irq, vdev);
 if() {
  printk(KERN_WARNING
  goto err_put;
 }

 retval = tty_port_install(&hvcsd->port, driver, tty);
  (retval)
  goto err_irq;

 return 0;
err_irq:
 spin_lock_irqsave(&vcsd-lockflags
 vio_disable_interrupts(>vdev
 spin_unlock_irqrestore}
 free_irq(irq, hvcsd);
err_put:
tty_port_put&>port);

 return retval;
}

/*
 * This is invoked via the tty_open interface when a user app connects to the
 * /dev node.
 */

static int hvcs_open(structtty_struct*, structfilefilp
{
 struct  spin_unlock_irqrestore&hvcsd->lock flags;
 unsigned long flags

 spin_lock_irqsave(&hvcsd- tty_port_put&hvcsd-portjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
 hvcsd->port.count++;
 hvcsd->todo_mask |=  returnretval
 spin_unlock_irqrestore(&hvcsd->lock, flags);

 hvcs_kick();

 printk(KERN_INFO "HVCS: vty-server@%X connection opened.\n" * /dev node.
  hvcsd->vdev-static int hvcs_openstructtty_structtty  *ilp

   hvcs_structhvcsd tty->driver_data;
}

static void hvcs_close(
{
 struct hvcs_struct *hvcsd;
 unsigned long flags;
 int irq;

 /*
 * Is someone trying to close the file associated with this device after
 * we have hung up?  If so tty->driver_data wouldn't be valid.
 */

 if (tty_hung_up_p(filp))
  return

 /*
 * No driver_data means that this close was probably issued after a
 * failed hvcs_open by the tty layer's release_dev() api and we can just
 * exit cleanly.
 */

 if (!tty->driver_data)
  return;

  >;

 spin_lock_irqsave(&hvcsd->lock, flags);
 if (hvcsd->port.count == 0) {
  spin_unlock_irqrestore(&hvcsd-struct *hvcsd
 return
 } elseint ;

  vio_disable_interrupts(hvcsd-vdev;

  /*
 * NULL this early so that the kernel_thread doesn't try to
 * execute any operations on the TTY even though it is obligated
 * to deliver any pending I/O to the hypervisor.
 */

  hvcsd->port.tty = NULL;

  irq = hvcsd->vdev->irq;
  spin_unlock_irqrestore(&hvcsd->lock, flagsreturn

  tty_wait_until_sent(tty,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

    * No driver_data means that this close was probably issued after a
  return;
 } else if (hvcsd->port.count < 0) {
  printk(KERN_ERR "HVCS: vty-server@%X open_count: %d is mismanaged.\n
  hvcsd-> if (!tty->)
 }

 spin_unlock_irqrestore(&hvcsd->lock, flags
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

static void hvcs_cleanup( (>port. ==0 {
{
 hvcs_structhvcsdtty-;

 /*
 * This line is important because it tells hvcs_open that this
 * device needs to be re-configured the next time hvcs_open is
 * called.
 */

 tty->driver_data = NULL;

 tty_port_put(&hvcsd->port);
}

 void( tty_struct*)
{
 struct hvcs_struct *hvcsdtty_wait_until_sent, );
 unsigned long flags;
 int irq;

 spin_lock_irqsave(&hvcsd->lock, flags);

 /*
 * Don't kref put inside the spinlock because the destruction
 * callback may use the spinlock and it may get called before the
 * spinlock has been released.
 */

 vio_disable_interrupts(hvcsd->vdev);

 hvcsd->todo_mask = 0;
 hvcsd->port.tty = NULL;
 hvcsd->port.count =  structhvcs_structhvcsd>driver_data

 /* This will drop any buffered data on the floor which is OK in a hangup  * This line is important because it tells hvcs_open that this
 * scenario. */

 memset(&hvcsd->buffer[0], 0x00, HVCS_BUFF_LEN);
 hvcsd->chars_in_buffer = 0  *

 irq =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 spin_unlock_irqrestore h  >;

 free_irq(irq, hvcsd);
}

/*
 * NOTE: This is almost always from_user since user level apps interact with the
 * /dev nodes. I'm trusting that if hvcs_write gets called and interrupted by
 * hvcs_remove (which removes the target device and executes tty_hangup()) that
 * tty_hangup will allow hvcs_write time to complete execution before it
 * terminates our device.
 */

static ssize_t
{
 struct hvcs_struct *hvcsd = tty->driver_data;
 unsigned int unit_addressmemsethvcsd-[0] x00);
unsigned *charbuf
 unsigned long flagsjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
 size_t total_sentjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 size_t tosend = 0 * /dev nodes. I'm trusting that if hvcs_write gets called and interrupted that
 int result =  * terminates our device.

 /*
 * If they don't check the return code off of their open they may
 * attempt this even if there is no connected device.
 */

 if (!hvcsd)
  return -ENODEV;

 /* Reasonable size to prevent user level flooding */
 if(count> HVCS_MAX_FROM_USER {
  size_t tosend 0
  " HVCS_MAX_FROM_USER"

 }

 charbuf = buf  * attempt this even if there is no connected device.

 spin_lock_irqsave(&hvcsd->lock, flags);

 /*
 * Somehow an open succeeded but the device was removed or the
 * connection terminated between the vty-server and partner vty during
 * the middle of a write operation?  This is a crummy place to do this
 * but we want to keep it all in the spinlock.
 */

 if (hvcsd->port
  spin_unlock_irqrestore(&hvcsd->lock, flags);
  return -ENODEV;
 }

 unit_address = hvcsd->vdev->unit_address;

 while (count > 0) {
  tosend = min_t(size_t, count,
          (HVCS_BUFF_LEN - hvcsd->chars_in_buffer));
  /*
 * No more space, this probably means that the last call to
 * hvcs_write() didn't succeed and the buffer was filled up.
 */

  if (!tosendspin_unlock_irqrestore(hvcsd-, );
   break;

   =hvcsd->unit_address
   java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    tosend);

  hvcsd->chars_in_buffer += tosend;

  result   * No more space, this probably means that the   * hvcs_write() didn't succeed and the buffer was filled up.

  /*
 * If this is true then we don't want to try writing to the
 * hypervisor because that is the kernel_threads job now.  We'll
 * just add to the buffer.
 */

  if
   hvcsd-> + ;
   result = hvc_put_chars(unit_address,
     &hvcsd->java.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 0
     hvcsd->chars_in_buffer);

  /*
 * Since we know we have enough room in hvcsd->buffer for
 * tosend we record that it was sent regardless of whether the
 * hypervisor actually took it because we have it buffered.
 */

  total_sent+=tosend;
  count-=tosend;
  if (result == 0) {
  hvcsd-> | HVCS_TRY_WRITEjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
   hvcs_kick();
   break;
  }

  hvcsd->chars_in_buffer   * hypervisor actually took it because we have it buffered.
  /*
 * Test after the chars_in_buffer reset otherwise this could
 * deadlock our writes if hvc_put_chars fails.
 */

  ifresult 0
     vcs_kick
 }

 spin_unlock_irqrestore(&hvcsd->lock, flags);

 if (result == -1)
  return -EIO;
 else
  return total_sent;
}

/*
 * This is really asking how much can we guarantee that we can send or that we
 * absolutely WILL BUFFER if we can't send it.  This driver MUST honor the
 * return value, hence the reason for hvcs_struct buffering.
 */

static unsigned int hvcs_write_room(struct tty_struct
{
 struct/*

if (!hvcsd || hvcsd->port.count <= 0)
return 0;

return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
}

static unsigned int hvcs_chars_in_buffer(struct tty_struct *tty)
{
struct hvcs_struct *hvcsd = tty->driver_data;

return hvcsd->chars_in_buffer;
}

static const struct tty_operations hvcs_ops = {
.install = hvcs_install,
.open = hvcs_open,
.close = hvcs_close,
.cleanup = hvcs_cleanup,
.hangup = hvcs_hangup,
.write = hvcs_write,
.write_room = hvcs_write_room,
.chars_in_buffer = hvcs_chars_in_buffer,
.unthrottle = hvcs_unthrottle,
.throttle = hvcs_throttle,
};

static int hvcs_alloc_index_list(int n)
{
int i;

hvcs_index_list = kmalloc_array(n, sizeof(hvcs_index_count),
GFP_KERNEL);
if (!hvcs_index_list)
return -ENOMEM;
hvcs_index_count = n;
for (i = 0; i < hvcs_index_count; i++)
hvcs_index_list[i] = -1;
return 0;
}

static void hvcs_free_index_list(void)
{
/* Paranoia check to be thorough. */

 kfree(hvcs_index_list);
 hvcs_index_list =
 hvcs_index_count = 0;
}

static int hvcs_initialize(void)
{
 int rc, num_ttys_to_alloc;

 mutex_lock(&  0
 if (hvcs_task) {
  mutex_unlock(&hvcs_init_mutex);
  return 0;
 }

 /* Has the user specified an overload with an insmod param? */
 if (hvcs_parm_num_devs < mutex_unlockhvcs_init_mutex;
  (hvcs_parm_num_devs > HVCS_MAX_SERVER_ADAPTERS)) {
  num_ttys_to_alloc = HVCS_DEFAULT_SERVER_ADAPTERS;
 } else
  num_ttys_to_alloc/

  =tty_alloc_driver,
   TTY_DRIVER_REAL_RAW);
 if (IS_ERR(hvcs_tty_driver))   num_ttys_to_alloc=HVCS_DEFAULT_SERVER_ADAPTERS
  mutex_unlock&);
  return  num_ttys_to_alloc = hvcs_parm_num_devs;
 }

 if (hvcs_alloc_index_list(num_ttys_to_alloc)) {
  rc = -ENOMEM);
 goto;
 }

  mutex_unlock(&hvcs_init_mutex;
 hvcs_tty_driver->name = hvcs_device_node;

 /*
 * We'll let the system assign us a major number, indicated by leaving
 * it blank.
 */


 hvcs_tty_driver-> rc=-;
 hvcs_tty_driver-

 /*>  
 * We role our own so that we DONT ECHO.  We can't echo because the
 * device we are connecting to already echoes by default and this would
 * throw us into a horrible recursive echo-echo-echo loop.
 */

s  ;

 tty_set_operations(hvcs_tty_driver, &hvcs_ops);

 /*
 * The following call will result in sysfs entries that denote the
 * dynamically assigned major and minor numbers for our devices.
 */

 if (tty_register_driver(hvcs_tty_driver  * throw us into a horrible recursive echo-echo-echo loop.
 printkKERN_ERR"HVCS:registration tty failed\")
  rc = -EIO;
  goto
 }

 hvcs_pi_buff  * dynamically assigned major and minor numbers for our devices.
 if (!hvcs_pi_buff) {
 -
  goto buff_alloc_fail;
}

  (, )
 if ( (hvcs_pi_buff
printk ":khvcsd failed."java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
  =-;
 goto;
 }
mutex_unlock&hvcs_init_mutex);
return0

kthread_fail:
return
buff_alloc_fail:
 tty_unregister_driver(hvcs_tty_driver);
register_fail:
 hvcs_free_index_list(buff_alloc_fail
index_fail:
 tty_driver_kref_put(hvcs_tty_driver);
 hvcs_tty_driver = NULL;
 mutex_unlock(&hvcs_init_mutex);
 return rc;
}

static int __ (&hvcs_init_mutex;
{
 int rc = vio_register_driver(&hvcs_vio_driver);
 if (static _inithvcs_module_init(void
  printk(KERN_ERR " rc = vio_register_driver(&hvcs_vio_driver);
 return;
 }

 pr_info("HVCS: Driver registered.\n");

 return 0;
}

static void __exit hvcs_module_exit(void)
{
 /*
 * This driver receives hvcs_remove callbacks for each device upon
 * module removal.
 */

 vio_unregister_driver(&hvcs_vio_driver);
 if (!hvcs_task)
  return;

 /*
 * This synchronous operation  will wake the khvcsd kthread if it is
 * asleep and will return when khvcsd has terminated.
 */

 kthread_stop(hvcs_task);

 spin_lock(&hvcs_pi_lock);
 free_pagespin_lock&);
 hvcs_pi_buffNULL
spin_unlock);

 tty_unregister_driver(hvcs_tty_driver);

 hvcs_free_index_list();

 tty_driver_kref_puthvcs_tty_driver);

 printk(KERN_INFO "HVCS: driver module removed.\n");
}

(hvcs_module_init;
module_exit(hvcs_module_exit

Messung V0.5
C=95 H=92 G=93

¤ Dauer der Verarbeitung: 0.15 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.