2 * IBM eServer Hypervisor Virtual Console Server Device Driver
3 * Copyright (C) 2003, 2004 IBM Corp.
4 * Ryan S. Arnold (rsa@us.ibm.com)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * Author(s) : Ryan S. Arnold <rsa@us.ibm.com>
22 * This is the device driver for the IBM Hypervisor Virtual Console Server,
23 * "hvcs". The IBM hvcs provides a tty driver interface to allow Linux
24 * user space applications access to the system consoles of logically
25 * partitioned operating systems, e.g. Linux, running on the same partitioned
26 * Power5 ppc64 system. Physical hardware consoles per partition are not
27 * practical on this hardware so system consoles are accessed by this driver
28 * using inter-partition firmware interfaces to virtual terminal devices.
30 * A vty is known to the HMC as a "virtual serial server adapter". It is a
31 * virtual terminal device that is created by firmware upon partition creation
32 * to act as a partitioned OS's console device.
34 * Firmware dynamically (via hotplug) exposes vty-servers to a running ppc64
35 * Linux system upon their creation by the HMC or their exposure during boot.
36 * The non-user interactive backend of this driver is implemented as a vio
37 * device driver so that it can receive notification of vty-server lifetimes
38 * after it registers with the vio bus to handle vty-server probe and remove
41 * Many vty-servers can be configured to connect to one vty, but a vty can
42 * only be actively connected to by a single vty-server, in any manner, at one
43 * time. If the HMC is currently hosting the console for a target Linux
44 * partition; attempts to open the tty device to the partition's console using
45 * the hvcs on any partition will return -EBUSY with every open attempt until
46 * the HMC frees the connection between its vty-server and the desired
47 * partition's vty device. Conversely, a vty-server may only be connected to
48 * a single vty at one time even though it may have several configured vty
49 * partner possibilities.
51 * Firmware does not provide notification of vty partner changes to this
52 * driver. This means that an HMC Super Admin may add or remove partner vtys
53 * from a vty-server's partner list but the changes will not be signaled to
54 * the vty-server. Firmware only notifies the driver when a vty-server is
55 * added or removed from the system. To compensate for this deficiency, this
56 * driver implements a sysfs update attribute which provides a method for
57 * rescanning partner information upon a user's request.
59 * Each vty-server, prior to being exposed to this driver is reference counted
60 * using the 2.6 Linux kernel kobject construct. This kobject is also used by
61 * the vio bus to provide a vio device sysfs entry that this driver attaches
62 * device specific attributes to, including partner information. The vio bus
63 * framework also provides a sysfs entry for each vio driver. The hvcs driver
64 * provides driver attributes in this entry.
66 * For direction on installation and usage of this driver please reference
67 * Documentation/powerpc/hvcs.txt.
70 #include <linux/device.h>
71 #include <linux/init.h>
72 #include <linux/interrupt.h>
73 #include <linux/kernel.h>
74 #include <linux/kobject.h>
75 #include <linux/kthread.h>
76 #include <linux/list.h>
77 #include <linux/major.h>
78 #include <linux/module.h>
79 #include <linux/moduleparam.h>
80 #include <linux/sched.h>
81 #include <linux/spinlock.h>
82 #include <linux/stat.h>
83 #include <linux/tty.h>
84 #include <linux/tty_flip.h>
85 #include <asm/hvconsole.h>
86 #include <asm/hvcserver.h>
87 #include <asm/uaccess.h>
91 * 1.0.0 -> 1.1.0 Added kernel_thread scheduling methodology to driver to
92 * replace wait_task constructs.
94 * 1.1.0 -> 1.2.0 Moved pi_buff initialization out of arch code into driver code
95 * and added locking to share this buffer between hvcs_struct instances. This
96 * is because the page_size kmalloc can't be done with a spin_lock held.
98 * Also added sysfs attribute to manually disconnect the vty-server from the vty
99 * due to stupid firmware behavior when opening the connection then sending data
100 * then then quickly closing the connection would cause data loss on the
101 * receiving side. This required some reordering of the termination code.
103 * Fixed the hangup scenario and fixed memory leaks on module_exit.
105 * 1.2.0 -> 1.3.0 Moved from manual kernel thread creation & execution to
106 * kthread construct which replaced in-kernel IPC for thread termination with
107 * kthread_stop and kthread_should_stop. Explicit wait_queue handling was
108 * removed because kthread handles this. Minor bug fix to postpone partner_info
109 * clearing on hvcs_close until adapter removal to preserve context data for
110 * printk on partner connection free. Added lock to protect hvcs_structs so
111 * that hvcs_struct instances aren't added or removed during list traversal.
112 * Cleaned up comment style, added spaces after commas, and broke function
113 * declaration lines to be under 80 columns.
115 #define HVCS_DRIVER_VERSION "1.3.0"
117 MODULE_AUTHOR("Ryan S. Arnold <rsa@us.ibm.com>");
118 MODULE_DESCRIPTION("IBM hvcs (Hypervisor Virtual Console Server) Driver");
119 MODULE_LICENSE("GPL");
120 MODULE_VERSION(HVCS_DRIVER_VERSION);
123 * Since the Linux TTY code does not currently (2-04-2004) support dynamic
124 * addition of tty derived devices and we shouldn't allocate thousands of
125 * tty_device pointers when the number of vty-server & vty partner connections
126 * will most often be much lower than this, we'll arbitrarily allocate
127 * HVCS_DEFAULT_SERVER_ADAPTERS tty_structs and cdev's by default when we
128 * register the tty_driver. This can be overridden using an insmod parameter.
130 #define HVCS_DEFAULT_SERVER_ADAPTERS 64
133 * The user can't insmod with more than HVCS_MAX_SERVER_ADAPTERS hvcs device
134 * nodes as a sanity check. Theoretically there can be over 1 Billion
135 * vty-server & vty partner connections.
137 #define HVCS_MAX_SERVER_ADAPTERS 1024
140 * We let Linux assign us a major number and we start the minors at zero. There
141 * is no intuitive mapping between minor number and the target partition. The
142 * mapping of minor number is related to the order the vty-servers are exposed
143 * to this driver via the hvcs_probe function.
145 #define HVCS_MINOR_START 0
148 * The hcall interface involves putting 8 chars into each of two registers.
149 * We load up those 2 registers (in arch/ppc64/hvconsole.c) by casting char[16]
150 * to long[2]. It would work without __ALIGNED__, but a little (tiny) bit
151 * slower because an unaligned load is slower than aligned load.
153 #define __ALIGNED__ __attribute__((__aligned__(8)))
155 /* Converged location code string length + 1 null terminator */
156 #define CLC_LENGTH 80
159 * How much data can firmware send with each hvc_put_chars()? Maybe this
160 * should be moved into an architecture specific area.
162 #define HVCS_BUFF_LEN 16
165 * This is the maximum amount of data we'll let the user send us (hvcs_write) at
166 * once in a chunk as a sanity check.
168 #define HVCS_MAX_FROM_USER 4096
171 * Be careful when adding flags to this line discipline. Don't add anything
172 * that will cause echoing or we'll go into recursive loop echoing chars back
173 * and forth with the console drivers.
175 static struct termios hvcs_tty_termios = {
176 .c_iflag = IGNBRK | IGNPAR,
178 .c_cflag = B38400 | CS8 | CREAD | HUPCL,
183 * This value is used to take the place of a command line parameter when the
184 * module is inserted. It starts as -1 and stays as such if the user doesn't
185 * specify a module insmod parameter. If they DO specify one then it is set to
186 * the value of the integer passed in.
188 static int hvcs_parm_num_devs = -1;
189 module_param(hvcs_parm_num_devs, int, 0);
191 char hvcs_driver_name[] = "hvcs";
192 char hvcs_device_node[] = "hvcs";
193 char hvcs_driver_string[]
194 = "IBM hvcs (Hypervisor Virtual Console Server) Driver";
196 /* Status of partner info rescan triggered via sysfs. */
197 static int hvcs_rescan_status = 0;
199 static struct tty_driver *hvcs_tty_driver;
202 * This is used to associate a vty-server, as it is exposed to this driver, with
203 * a preallocated tty_struct.index. The dev node and hvcs index numbers are not
204 * re-used after device removal otherwise removing and adding a new one would
205 * link a /dev/hvcs* entry to a different vty-server than it did before the
206 * removal. Incidentally, a newly exposed vty-server will always map to an
207 * incrementally higher /dev/hvcs* entry than the last exposed vty-server.
209 static int hvcs_struct_count = -1;
212 * Used by the khvcsd to pick up I/O operations when the kernel_thread is
213 * already awake but potentially shifted to TASK_INTERRUPTIBLE state.
215 static int hvcs_kicked = 0;
217 /* Used the the kthread construct for task operations */
218 static struct task_struct *hvcs_task;
221 * We allocate this for the use of all of the hvcs_structs when they fetch
224 static unsigned long *hvcs_pi_buff;
226 static spinlock_t hvcs_pi_lock;
228 /* One vty-server per hvcs_struct */
233 * This index identifies this hvcs device as the complement to a
234 * specific tty index.
238 struct tty_struct *tty;
239 unsigned int open_count;
242 * Used to tell the driver kernel_thread what operations need to take
243 * place upon this hvcs_struct instance.
248 * This buffer is required so that when hvcs_write_room() reports that
249 * it can send HVCS_BUFF_LEN characters that it will buffer the full
250 * HVCS_BUFF_LEN characters if need be. This is essential for opost
251 * writes since they do not do high level buffering and expect to be
252 * able to send what the driver commits to sending buffering
253 * [e.g. tab to space conversions in n_tty.c opost()].
255 char buffer[HVCS_BUFF_LEN];
259 * Any variable below the kobject is valid before a tty is connected and
260 * stays valid after the tty is disconnected. These shouldn't be
261 * whacked until the koject refcount reaches zero though some entries
262 * may be changed via sysfs initiatives.
264 struct kobject kobj; /* ref count & hvcs_struct lifetime */
265 int connected; /* is the vty-server currently connected to a vty? */
266 unsigned int p_unit_address; /* partner unit address */
267 unsigned int p_partition_ID; /* partner partition ID */
268 char p_location_code[CLC_LENGTH];
269 struct list_head next; /* list management */
270 struct vio_dev *vdev;
273 /* Required to back map a kobject to its containing object */
274 #define from_kobj(kobj) container_of(kobj, struct hvcs_struct, kobj)
276 static struct list_head hvcs_structs = LIST_HEAD_INIT(hvcs_structs);
277 static spinlock_t hvcs_structs_lock;
279 static void hvcs_unthrottle(struct tty_struct *tty);
280 static void hvcs_throttle(struct tty_struct *tty);
281 static irqreturn_t hvcs_handle_interrupt(int irq, void *dev_instance,
282 struct pt_regs *regs);
284 static int hvcs_write(struct tty_struct *tty, int from_user,
285 const unsigned char *buf, int count);
286 static int hvcs_write_room(struct tty_struct *tty);
287 static int hvcs_chars_in_buffer(struct tty_struct *tty);
289 static int hvcs_has_pi(struct hvcs_struct *hvcsd);
290 static void hvcs_set_pi(struct hvcs_partner_info *pi,
291 struct hvcs_struct *hvcsd);
292 static int hvcs_get_pi(struct hvcs_struct *hvcsd);
293 static int hvcs_rescan_devices_list(void);
295 static int hvcs_partner_connect(struct hvcs_struct *hvcsd);
296 static void hvcs_partner_free(struct hvcs_struct *hvcsd);
298 static int hvcs_enable_device(struct hvcs_struct *hvcsd,
299 uint32_t unit_address, unsigned int irq, struct vio_dev *dev);
300 static void hvcs_final_close(struct hvcs_struct *hvcsd);
302 static void destroy_hvcs_struct(struct kobject *kobj);
303 static int hvcs_open(struct tty_struct *tty, struct file *filp);
304 static void hvcs_close(struct tty_struct *tty, struct file *filp);
305 static void hvcs_hangup(struct tty_struct * tty);
307 static void hvcs_create_device_attrs(struct hvcs_struct *hvcsd);
308 static void hvcs_remove_device_attrs(struct vio_dev *vdev);
309 static void hvcs_create_driver_attrs(void);
310 static void hvcs_remove_driver_attrs(void);
312 static int __devinit hvcs_probe(struct vio_dev *dev,
313 const struct vio_device_id *id);
314 static int __devexit hvcs_remove(struct vio_dev *dev);
315 static int __init hvcs_module_init(void);
316 static void __exit hvcs_module_exit(void);
318 #define HVCS_SCHED_READ 0x00000001
319 #define HVCS_QUICK_READ 0x00000002
320 #define HVCS_TRY_WRITE 0x00000004
321 #define HVCS_READ_MASK (HVCS_SCHED_READ | HVCS_QUICK_READ)
323 static void hvcs_kick(void)
327 wake_up_process(hvcs_task);
330 static void hvcs_unthrottle(struct tty_struct *tty)
332 struct hvcs_struct *hvcsd = tty->driver_data;
335 spin_lock_irqsave(&hvcsd->lock, flags);
336 hvcsd->todo_mask |= HVCS_SCHED_READ;
337 spin_unlock_irqrestore(&hvcsd->lock, flags);
341 static void hvcs_throttle(struct tty_struct *tty)
343 struct hvcs_struct *hvcsd = tty->driver_data;
346 spin_lock_irqsave(&hvcsd->lock, flags);
347 vio_disable_interrupts(hvcsd->vdev);
348 spin_unlock_irqrestore(&hvcsd->lock, flags);
352 * If the device is being removed we don't have to worry about this interrupt
353 * handler taking any further interrupts because they are disabled which means
354 * the hvcs_struct will always be valid in this handler.
356 static irqreturn_t hvcs_handle_interrupt(int irq, void *dev_instance,
357 struct pt_regs *regs)
359 struct hvcs_struct *hvcsd = dev_instance;
362 spin_lock_irqsave(&hvcsd->lock, flags);
363 vio_disable_interrupts(hvcsd->vdev);
364 hvcsd->todo_mask |= HVCS_SCHED_READ;
365 spin_unlock_irqrestore(&hvcsd->lock, flags);
371 /* This function must be called with the hvcsd->lock held */
372 static void hvcs_try_write(struct hvcs_struct *hvcsd)
374 unsigned int unit_address = hvcsd->vdev->unit_address;
375 struct tty_struct *tty = hvcsd->tty;
378 if (hvcsd->todo_mask & HVCS_TRY_WRITE) {
379 /* won't send partial writes */
380 sent = hvc_put_chars(unit_address,
382 hvcsd->chars_in_buffer );
384 hvcsd->chars_in_buffer = 0;
386 hvcsd->todo_mask &= ~(HVCS_TRY_WRITE);
390 * We are still obligated to deliver the data to the
391 * hypervisor even if the tty has been closed because
392 * we commited to delivering it. But don't try to wake
393 * a non-existent tty.
396 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP))
397 && tty->ldisc.write_wakeup)
398 (tty->ldisc.write_wakeup) (tty);
399 wake_up_interruptible(&tty->write_wait);
405 static int hvcs_io(struct hvcs_struct *hvcsd)
407 unsigned int unit_address;
408 struct tty_struct *tty;
409 char buf[HVCS_BUFF_LEN] __ALIGNED__;
414 spin_lock_irqsave(&hvcsd->lock, flags);
416 unit_address = hvcsd->vdev->unit_address;
419 hvcs_try_write(hvcsd);
421 if (!tty || test_bit(TTY_THROTTLED, &tty->flags)) {
422 hvcsd->todo_mask &= ~(HVCS_READ_MASK);
424 } else if (!(hvcsd->todo_mask & (HVCS_READ_MASK)))
427 /* remove the read masks */
428 hvcsd->todo_mask &= ~(HVCS_READ_MASK);
430 if ((tty->flip.count + HVCS_BUFF_LEN) < TTY_FLIPBUF_SIZE) {
431 got = hvc_get_chars(unit_address,
434 for (i=0;got && i<got;i++)
435 tty_insert_flip_char(tty, buf[i], TTY_NORMAL);
438 /* Give the TTY time to process the data we just sent. */
440 hvcsd->todo_mask |= HVCS_QUICK_READ;
442 spin_unlock_irqrestore(&hvcsd->lock, flags);
443 if (tty->flip.count) {
444 /* This is synch because tty->low_latency == 1 */
445 tty_flip_buffer_push(tty);
449 /* Do this _after_ the flip_buffer_push */
450 spin_lock_irqsave(&hvcsd->lock, flags);
451 vio_enable_interrupts(hvcsd->vdev);
452 spin_unlock_irqrestore(&hvcsd->lock, flags);
455 return hvcsd->todo_mask;
458 spin_unlock_irqrestore(&hvcsd->lock, flags);
459 return hvcsd->todo_mask;
462 static int khvcsd(void *unused)
464 struct hvcs_struct *hvcsd = NULL;
465 struct list_head *element;
466 struct list_head *safe_temp;
468 unsigned long structs_flags;
470 __set_current_state(TASK_RUNNING);
477 spin_lock_irqsave(&hvcs_structs_lock, structs_flags);
478 list_for_each_safe(element, safe_temp, &hvcs_structs) {
479 hvcsd = list_entry(element, struct hvcs_struct, next);
480 hvcs_todo_mask |= hvcs_io(hvcsd);
482 spin_unlock_irqrestore(&hvcs_structs_lock, structs_flags);
485 * If any of the hvcs adapters want to try a write or quick read
486 * don't schedule(), yield a smidgen then execute the hvcs_io
487 * thread again for those that want the write.
489 if (hvcs_todo_mask & (HVCS_TRY_WRITE | HVCS_QUICK_READ)) {
494 set_current_state(TASK_INTERRUPTIBLE);
497 __set_current_state(TASK_RUNNING);
498 } while (!kthread_should_stop());
503 static struct vio_device_id hvcs_driver_table[] __devinitdata= {
504 {"serial-server", "hvterm2"},
507 MODULE_DEVICE_TABLE(vio, hvcs_driver_table);
509 /* callback when the kboject ref count reaches zero */
510 static void destroy_hvcs_struct(struct kobject *kobj)
512 struct hvcs_struct *hvcsd = from_kobj(kobj);
513 struct vio_dev *vdev;
516 spin_lock_irqsave(&hvcsd->lock, flags);
518 /* the list_del poisons the pointers */
519 list_del(&(hvcsd->next));
521 if (hvcsd->connected == 1) {
522 hvcs_partner_free(hvcsd);
523 printk(KERN_INFO "HVCS: Closed vty-server@%X and"
524 " partner vty@%X:%d connection.\n",
525 hvcsd->vdev->unit_address,
526 hvcsd->p_unit_address,
527 (unsigned int)hvcsd->p_partition_ID);
529 printk(KERN_INFO "HVCS: Destroyed hvcs_struct for vty-server@%X.\n",
530 hvcsd->vdev->unit_address);
535 hvcsd->p_unit_address = 0;
536 hvcsd->p_partition_ID = 0;
537 memset(&hvcsd->p_location_code[0], 0x00, CLC_LENGTH);
539 spin_unlock_irqrestore(&hvcsd->lock, flags);
541 hvcs_remove_device_attrs(vdev);
546 /* This function must be called with hvcsd->lock held. */
547 static void hvcs_final_close(struct hvcs_struct *hvcsd)
549 vio_disable_interrupts(hvcsd->vdev);
550 free_irq(hvcsd->vdev->irq, hvcsd);
552 hvcsd->todo_mask = 0;
554 /* These two may be redundant if the operation was a close. */
556 hvcsd->tty->driver_data = NULL;
560 hvcsd->open_count = 0;
562 memset(&hvcsd->buffer[0], 0x00, HVCS_BUFF_LEN);
563 hvcsd->chars_in_buffer = 0;
566 static struct kobj_type hvcs_kobj_type = {
567 .release = destroy_hvcs_struct,
570 static int __devinit hvcs_probe(
572 const struct vio_device_id *id)
574 struct hvcs_struct *hvcsd;
575 unsigned long structs_flags;
578 printk(KERN_ERR "HVCS: probed with invalid parameter.\n");
582 hvcsd = kmalloc(sizeof(*hvcsd), GFP_KERNEL);
587 /* hvcsd->tty is zeroed out with the memset */
588 memset(hvcsd, 0x00, sizeof(*hvcsd));
590 hvcsd->lock = SPIN_LOCK_UNLOCKED;
591 /* Automatically incs the refcount the first time */
592 kobject_init(&hvcsd->kobj);
593 /* Set up the callback for terminating the hvcs_struct's life */
594 hvcsd->kobj.ktype = &hvcs_kobj_type;
597 dev->dev.driver_data = hvcsd;
599 hvcsd->index = ++hvcs_struct_count;
600 hvcsd->chars_in_buffer = 0;
601 hvcsd->todo_mask = 0;
602 hvcsd->connected = 0;
605 * This will populate the hvcs_struct's partner info fields for the
608 if (hvcs_get_pi(hvcsd)) {
609 printk(KERN_ERR "HVCS: Failed to fetch partner"
610 " info for vty-server@%X on device probe.\n",
611 hvcsd->vdev->unit_address);
615 * If a user app opens a tty that corresponds to this vty-server before
616 * the hvcs_struct has been added to the devices list then the user app
620 spin_lock_irqsave(&hvcs_structs_lock, structs_flags);
622 list_add_tail(&(hvcsd->next), &hvcs_structs);
624 spin_unlock_irqrestore(&hvcs_structs_lock, structs_flags);
626 hvcs_create_device_attrs(hvcsd);
628 printk(KERN_INFO "HVCS: Added vty-server@%X.\n", dev->unit_address);
631 * DON'T enable interrupts here because there is no user to receive the
637 static int __devexit hvcs_remove(struct vio_dev *dev)
639 struct hvcs_struct *hvcsd = dev->dev.driver_data;
641 struct kobject *kobjp;
642 struct tty_struct *tty;
647 /* By this time the vty-server won't be getting any more interrups */
649 spin_lock_irqsave(&hvcsd->lock, flags);
653 kobjp = &hvcsd->kobj;
655 spin_unlock_irqrestore(&hvcsd->lock, flags);
658 * Let the last holder of this object cause it to be removed, which
659 * would probably be tty_hangup below.
664 * The hangup is a scheduled function which will auto chain call
665 * hvcs_hangup. The tty should always be valid at this time unless a
666 * simultaneous tty close already cleaned up the hvcs_struct.
671 printk(KERN_INFO "HVCS: vty-server@%X removed from the"
672 " vio bus.\n", dev->unit_address);
676 static struct vio_driver hvcs_vio_driver = {
677 .name = hvcs_driver_name,
678 .id_table = hvcs_driver_table,
680 .remove = hvcs_remove,
683 /* Only called from hvcs_get_pi please */
684 static void hvcs_set_pi(struct hvcs_partner_info *pi, struct hvcs_struct *hvcsd)
688 hvcsd->p_unit_address = pi->unit_address;
689 hvcsd->p_partition_ID = pi->partition_ID;
690 clclength = strlen(&pi->location_code[0]);
691 if (clclength > CLC_LENGTH - 1)
692 clclength = CLC_LENGTH - 1;
694 /* copy the null-term char too */
695 strncpy(&hvcsd->p_location_code[0],
696 &pi->location_code[0], clclength + 1);
700 * Traverse the list and add the partner info that is found to the hvcs_struct
701 * struct entry. NOTE: At this time I know that partner info will return a
702 * single entry but in the future there may be multiple partner info entries per
703 * vty-server and you'll want to zero out that list and reset it. If for some
704 * reason you have an old version of this driver but there IS more than one
705 * partner info then hvcsd->p_* will hold the last partner info data from the
706 * firmware query. A good way to update this code would be to replace the three
707 * partner info fields in hvcs_struct with a list of hvcs_partner_info
710 * This function must be called with the hvcsd->lock held.
712 static int hvcs_get_pi(struct hvcs_struct *hvcsd)
714 /* struct hvcs_partner_info *head_pi = NULL; */
715 struct hvcs_partner_info *pi = NULL;
716 unsigned int unit_address = hvcsd->vdev->unit_address;
717 struct list_head head;
721 spin_lock_irqsave(&hvcs_pi_lock, flags);
723 spin_unlock_irqrestore(&hvcs_pi_lock, flags);
726 retval = hvcs_get_partner_info(unit_address, &head, hvcs_pi_buff);
727 spin_unlock_irqrestore(&hvcs_pi_lock, flags);
729 printk(KERN_ERR "HVCS: Failed to fetch partner"
730 " info for vty-server@%x.\n", unit_address);
734 /* nixes the values if the partner vty went away */
735 hvcsd->p_unit_address = 0;
736 hvcsd->p_partition_ID = 0;
738 list_for_each_entry(pi, &head, node)
739 hvcs_set_pi(pi, hvcsd);
741 hvcs_free_partner_info(&head);
746 * This function is executed by the driver "rescan" sysfs entry. It shouldn't
747 * be executed elsewhere, in order to prevent deadlock issues.
749 static int hvcs_rescan_devices_list(void)
751 struct hvcs_struct *hvcsd = NULL;
753 unsigned long structs_flags;
755 spin_lock_irqsave(&hvcs_structs_lock, structs_flags);
757 list_for_each_entry(hvcsd, &hvcs_structs, next) {
758 spin_lock_irqsave(&hvcsd->lock, flags);
760 spin_unlock_irqrestore(&hvcsd->lock, flags);
763 spin_unlock_irqrestore(&hvcs_structs_lock, structs_flags);
769 * Farm this off into its own function because it could be more complex once
770 * multiple partners support is added. This function should be called with
771 * the hvcsd->lock held.
773 static int hvcs_has_pi(struct hvcs_struct *hvcsd)
775 if ((!hvcsd->p_unit_address) || (!hvcsd->p_partition_ID))
781 * NOTE: It is possible that the super admin removed a partner vty and then
782 * added a different vty as the new partner.
784 * This function must be called with the hvcsd->lock held.
786 static int hvcs_partner_connect(struct hvcs_struct *hvcsd)
789 unsigned int unit_address = hvcsd->vdev->unit_address;
792 * If there wasn't any pi when the device was added it doesn't meant
793 * there isn't any now. This driver isn't notified when a new partner
794 * vty is added to a vty-server so we discover changes on our own.
795 * Please see comments in hvcs_register_connection() for justification
796 * of this bizarre code.
798 retval = hvcs_register_connection(unit_address,
799 hvcsd->p_partition_ID,
800 hvcsd->p_unit_address);
802 hvcsd->connected = 1;
804 } else if (retval != -EINVAL)
808 * As per the spec re-get the pi and try again if -EINVAL after the
809 * first connection attempt.
811 if (hvcs_get_pi(hvcsd))
814 if (!hvcs_has_pi(hvcsd))
817 retval = hvcs_register_connection(unit_address,
818 hvcsd->p_partition_ID,
819 hvcsd->p_unit_address);
820 if (retval != -EINVAL) {
821 hvcsd->connected = 1;
826 * EBUSY is the most likely scenario though the vty could have been
827 * removed or there really could be an hcall error due to the parameter
828 * data but thanks to ambiguous firmware return codes we can't really
831 printk(KERN_INFO "HVCS: vty-server or partner"
832 " vty is busy. Try again later.\n");
836 /* This function must be called with the hvcsd->lock held */
837 static void hvcs_partner_free(struct hvcs_struct *hvcsd)
841 retval = hvcs_free_connection(hvcsd->vdev->unit_address);
842 } while (retval == -EBUSY);
843 hvcsd->connected = 0;
846 /* This helper function must be called WITHOUT the hvcsd->lock held */
847 static int hvcs_enable_device(struct hvcs_struct *hvcsd, uint32_t unit_address,
848 unsigned int irq, struct vio_dev *vdev)
853 * It is possible that the vty-server was removed between the time that
854 * the conn was registered and now.
856 if (!request_irq(irq, &hvcs_handle_interrupt,
857 SA_INTERRUPT, "ibmhvcs", hvcsd)) {
859 * It is possible the vty-server was removed after the irq was
860 * requested but before we have time to enable interrupts.
862 if (vio_enable_interrupts(vdev) == H_Success)
865 printk(KERN_ERR "HVCS: int enable failed for"
866 " vty-server@%X.\n", unit_address);
867 free_irq(irq, hvcsd);
870 printk(KERN_ERR "HVCS: irq req failed for"
871 " vty-server@%X.\n", unit_address);
873 spin_lock_irqsave(&hvcsd->lock, flags);
874 hvcs_partner_free(hvcsd);
875 spin_unlock_irqrestore(&hvcsd->lock, flags);
882 * This always increments the kobject ref count if the call is successful.
883 * Please remember to dec when you are done with the instance.
885 * NOTICE: Do NOT hold either the hvcs_struct.lock or hvcs_structs_lock when
886 * calling this function or you will get deadlock.
888 struct hvcs_struct *hvcs_get_by_index(int index)
890 struct hvcs_struct *hvcsd = NULL;
891 struct list_head *element;
892 struct list_head *safe_temp;
894 unsigned long structs_flags;
896 spin_lock_irqsave(&hvcs_structs_lock, structs_flags);
897 /* We can immediately discard OOB requests */
898 if (index >= 0 && index < HVCS_MAX_SERVER_ADAPTERS) {
899 list_for_each_safe(element, safe_temp, &hvcs_structs) {
900 hvcsd = list_entry(element, struct hvcs_struct, next);
901 spin_lock_irqsave(&hvcsd->lock, flags);
902 if (hvcsd->index == index) {
903 kobject_get(&hvcsd->kobj);
904 spin_unlock_irqrestore(&hvcsd->lock, flags);
905 spin_unlock_irqrestore(&hvcs_structs_lock,
909 spin_unlock_irqrestore(&hvcsd->lock, flags);
914 spin_unlock_irqrestore(&hvcs_structs_lock, structs_flags);
919 * This is invoked via the tty_open interface when a user app connects to the
922 static int hvcs_open(struct tty_struct *tty, struct file *filp)
924 struct hvcs_struct *hvcsd = NULL;
928 struct vio_dev *vdev;
929 unsigned long unit_address;
931 if (tty->driver_data)
935 * Is there a vty-server that shares the same index?
936 * This function increments the kobject index.
938 if (!(hvcsd = hvcs_get_by_index(tty->index))) {
939 printk(KERN_WARNING "HVCS: open failed, no index.\n");
943 spin_lock_irqsave(&hvcsd->lock, flags);
945 if (hvcsd->connected == 0)
946 if ((retval = hvcs_partner_connect(hvcsd)))
949 hvcsd->open_count = 1;
951 tty->driver_data = hvcsd;
954 * Set this driver to low latency so that we actually have a chance at
955 * catching a throttled TTY after we flip_buffer_push. Otherwise the
956 * flush_to_async may not execute until after the kernel_thread has
957 * yielded and resumed the next flip_buffer_push resulting in data
960 tty->low_latency = 1;
962 memset(&hvcsd->buffer[0], 0x3F, HVCS_BUFF_LEN);
965 * Save these in the spinlock for the enable operations that need them
966 * outside of the spinlock.
968 irq = hvcsd->vdev->irq;
970 unit_address = hvcsd->vdev->unit_address;
972 hvcsd->todo_mask |= HVCS_SCHED_READ;
973 spin_unlock_irqrestore(&hvcsd->lock, flags);
976 * This must be done outside of the spinlock because it requests irqs
977 * and will grab the spinlcok and free the connection if it fails.
979 if ((hvcs_enable_device(hvcsd, unit_address, irq, vdev))) {
980 kobject_put(&hvcsd->kobj);
981 printk(KERN_WARNING "HVCS: enable device failed.\n");
988 hvcsd = tty->driver_data;
990 spin_lock_irqsave(&hvcsd->lock, flags);
991 if (!kobject_get(&hvcsd->kobj)) {
992 spin_unlock_irqrestore(&hvcsd->lock, flags);
993 printk(KERN_ERR "HVCS: Kobject of open"
994 " hvcs doesn't exist.\n");
995 return -EFAULT; /* Is this the right return value? */
1000 hvcsd->todo_mask |= HVCS_SCHED_READ;
1001 spin_unlock_irqrestore(&hvcsd->lock, flags);
1005 printk(KERN_INFO "HVCS: vty-server@%X opened.\n",
1006 hvcsd->vdev->unit_address );
1011 spin_unlock_irqrestore(&hvcsd->lock, flags);
1012 kobject_put(&hvcsd->kobj);
1014 printk(KERN_WARNING "HVCS: HVCS partner connect failed.\n");
1018 static void hvcs_close(struct tty_struct *tty, struct file *filp)
1020 struct hvcs_struct *hvcsd;
1021 unsigned long flags;
1022 struct kobject *kobjp;
1025 * Is someone trying to close the file associated with this device after
1026 * we have hung up? If so tty->driver_data wouldn't be valid.
1028 if (tty_hung_up_p(filp))
1032 * No driver_data means that this close was probably issued after a
1033 * failed hvcs_open by the tty layer's release_dev() api and we can just
1036 if (!tty->driver_data)
1039 hvcsd = tty->driver_data;
1041 spin_lock_irqsave(&hvcsd->lock, flags);
1042 if (--hvcsd->open_count == 0) {
1045 * This line is important because it tells hvcs_open that this
1046 * device needs to be re-configured the next time hvcs_open is
1049 hvcsd->tty->driver_data = NULL;
1052 * NULL this early so that the kernel_thread doesn't try to
1053 * execute any operations on the TTY even though it is obligated
1054 * to deliver any pending I/O to the hypervisor.
1059 * Block the close until all the buffered data has been
1062 while(hvcsd->chars_in_buffer) {
1063 spin_unlock_irqrestore(&hvcsd->lock, flags);
1066 * Give the kernel thread the hvcs_struct so that it can
1067 * try to deliver the remaining data but block the close
1068 * operation by spinning in this function so that other
1069 * tty operations have to wait.
1072 spin_lock_irqsave(&hvcsd->lock, flags);
1075 hvcs_final_close(hvcsd);
1077 } else if (hvcsd->open_count < 0) {
1078 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
1079 " is missmanaged.\n",
1080 hvcsd->vdev->unit_address, hvcsd->open_count);
1082 kobjp = &hvcsd->kobj;
1084 spin_unlock_irqrestore(&hvcsd->lock, flags);
1089 static void hvcs_hangup(struct tty_struct * tty)
1091 struct hvcs_struct *hvcsd = tty->driver_data;
1092 unsigned long flags;
1093 int temp_open_count;
1094 struct kobject *kobjp;
1096 spin_lock_irqsave(&hvcsd->lock, flags);
1097 /* Preserve this so that we know how many kobject refs to put */
1098 temp_open_count = hvcsd->open_count;
1101 * Don't kobject put inside the spinlock because the destruction
1102 * callback may use the spinlock and it may get called before the
1103 * spinlock has been released. Get a pointer to the kobject and
1104 * kobject_put on that instead.
1106 kobjp = &hvcsd->kobj;
1108 /* Calling this will drop any buffered data on the floor. */
1109 hvcs_final_close(hvcsd);
1111 spin_unlock_irqrestore(&hvcsd->lock, flags);
1114 * We need to kobject_put() for every open_count we have since the
1115 * tty_hangup() function doesn't invoke a close per open connection on a
1116 * non-console device.
1118 while(temp_open_count) {
1121 * The final put will trigger destruction of the hvcs_struct.
1122 * NOTE: If this hangup was signaled from user space then the
1123 * final put will never happen.
1130 * NOTE: This is almost always from_user since user level apps interact with the
1131 * /dev nodes. I'm trusting that if hvcs_write gets called and interrupted by
1132 * hvcs_remove (which removes the target device and executes tty_hangup()) that
1133 * tty_hangup will allow hvcs_write time to complete execution before it
1134 * terminates our device.
1136 static int hvcs_write(struct tty_struct *tty, int from_user,
1137 const unsigned char *buf, int count)
1139 struct hvcs_struct *hvcsd = tty->driver_data;
1140 unsigned int unit_address;
1141 unsigned char *charbuf;
1142 unsigned long flags;
1148 * If they don't check the return code off of their open they may
1149 * attempt this even if there is no connected device.
1154 /* Reasonable size to prevent user level flooding */
1155 if (count > HVCS_MAX_FROM_USER) {
1156 printk(KERN_WARNING "HVCS write: count being truncated to"
1157 " HVCS_MAX_FROM_USER.\n");
1158 count = HVCS_MAX_FROM_USER;
1162 charbuf = (unsigned char *)buf;
1164 charbuf = kmalloc(count, GFP_KERNEL);
1166 printk(KERN_WARNING "HVCS: write -ENOMEM.\n");
1170 if (copy_from_user(charbuf, buf, count)) {
1172 printk(KERN_WARNING "HVCS: write -EFAULT.\n");
1177 spin_lock_irqsave(&hvcsd->lock, flags);
1180 * Somehow an open succedded but the device was removed or the
1181 * connection terminated between the vty-server and partner vty during
1182 * the middle of a write operation? This is a crummy place to do this
1183 * but we want to keep it all in the spinlock.
1185 if (hvcsd->open_count <= 0) {
1186 spin_unlock_irqrestore(&hvcsd->lock, flags);
1192 unit_address = hvcsd->vdev->unit_address;
1195 tosend = min(count, (HVCS_BUFF_LEN - hvcsd->chars_in_buffer));
1197 * No more space, this probably means that the last call to
1198 * hvcs_write() didn't succeed and the buffer was filled up.
1203 memcpy(&hvcsd->buffer[hvcsd->chars_in_buffer],
1204 &charbuf[total_sent],
1207 hvcsd->chars_in_buffer += tosend;
1212 * If this is true then we don't want to try writing to the
1213 * hypervisor because that is the kernel_threads job now. We'll
1214 * just add to the buffer.
1216 if (!(hvcsd->todo_mask & HVCS_TRY_WRITE))
1217 /* won't send partial writes */
1218 result = hvc_put_chars(unit_address,
1220 hvcsd->chars_in_buffer);
1223 * Since we know we have enough room in hvcsd->buffer for
1224 * tosend we record that it was sent regardless of whether the
1225 * hypervisor actually took it because we have it buffered.
1230 hvcsd->todo_mask |= HVCS_TRY_WRITE;
1235 hvcsd->chars_in_buffer = 0;
1237 * Test after the chars_in_buffer reset otherwise this could
1238 * deadlock our writes if hvc_put_chars fails.
1244 spin_unlock_irqrestore(&hvcsd->lock, flags);
1255 * This is really asking how much can we guarentee that we can send or that we
1256 * absolutely WILL BUFFER if we can't send it. This driver MUST honor the
1257 * return value, hence the reason for hvcs_struct buffering.
1259 static int hvcs_write_room(struct tty_struct *tty)
1261 struct hvcs_struct *hvcsd = tty->driver_data;
1262 unsigned long flags;
1265 if (!hvcsd || hvcsd->open_count <= 0)
1268 spin_lock_irqsave(&hvcsd->lock, flags);
1269 retval = HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
1270 spin_unlock_irqrestore(&hvcsd->lock, flags);
1274 static int hvcs_chars_in_buffer(struct tty_struct *tty)
1276 struct hvcs_struct *hvcsd = tty->driver_data;
1277 unsigned long flags;
1280 spin_lock_irqsave(&hvcsd->lock, flags);
1281 retval = hvcsd->chars_in_buffer;
1282 spin_unlock_irqrestore(&hvcsd->lock, flags);
1286 static struct tty_operations hvcs_ops = {
1288 .close = hvcs_close,
1289 .hangup = hvcs_hangup,
1290 .write = hvcs_write,
1291 .write_room = hvcs_write_room,
1292 .chars_in_buffer = hvcs_chars_in_buffer,
1293 .unthrottle = hvcs_unthrottle,
1294 .throttle = hvcs_throttle,
1297 static int __init hvcs_module_init(void)
1300 int num_ttys_to_alloc;
1302 printk(KERN_INFO "Initializing %s\n", hvcs_driver_string);
1304 /* Has the user specified an overload with an insmod param? */
1305 if (hvcs_parm_num_devs <= 0 ||
1306 (hvcs_parm_num_devs > HVCS_MAX_SERVER_ADAPTERS)) {
1307 num_ttys_to_alloc = HVCS_DEFAULT_SERVER_ADAPTERS;
1309 num_ttys_to_alloc = hvcs_parm_num_devs;
1311 hvcs_tty_driver = alloc_tty_driver(num_ttys_to_alloc);
1312 if (!hvcs_tty_driver)
1315 hvcs_tty_driver->owner = THIS_MODULE;
1317 hvcs_tty_driver->driver_name = hvcs_driver_name;
1318 hvcs_tty_driver->name = hvcs_device_node;
1321 * We'll let the system assign us a major number, indicated by leaving
1325 hvcs_tty_driver->minor_start = HVCS_MINOR_START;
1326 hvcs_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM;
1329 * We role our own so that we DONT ECHO. We can't echo because the
1330 * device we are connecting to already echoes by default and this would
1331 * throw us into a horrible recursive echo-echo-echo loop.
1333 hvcs_tty_driver->init_termios = hvcs_tty_termios;
1334 hvcs_tty_driver->flags = TTY_DRIVER_REAL_RAW;
1336 tty_set_operations(hvcs_tty_driver, &hvcs_ops);
1339 * The following call will result in sysfs entries that denote the
1340 * dynamically assigned major and minor numbers for our devices.
1342 if (tty_register_driver(hvcs_tty_driver)) {
1343 printk(KERN_ERR "HVCS: registration "
1344 " as a tty driver failed.\n");
1345 put_tty_driver(hvcs_tty_driver);
1349 hvcs_structs_lock = SPIN_LOCK_UNLOCKED;
1351 hvcs_pi_lock = SPIN_LOCK_UNLOCKED;
1352 hvcs_pi_buff = kmalloc(PAGE_SIZE, GFP_KERNEL);
1354 hvcs_task = kthread_run(khvcsd, NULL, "khvcsd");
1355 if (IS_ERR(hvcs_task)) {
1356 printk("khvcsd creation failed. Driver not loaded.\n");
1357 kfree(hvcs_pi_buff);
1358 put_tty_driver(hvcs_tty_driver);
1362 rc = vio_register_driver(&hvcs_vio_driver);
1365 * This needs to be done AFTER the vio_register_driver() call or else
1366 * the kobjects won't be initialized properly.
1368 hvcs_create_driver_attrs();
1370 printk(KERN_INFO "HVCS: driver module inserted.\n");
1375 static void __exit hvcs_module_exit(void)
1377 unsigned long flags;
1380 * This driver receives hvcs_remove callbacks for each device upon
1385 * This synchronous operation will wake the khvcsd kthread if it is
1386 * asleep and will return when khvcsd has terminated.
1388 kthread_stop(hvcs_task);
1390 spin_lock_irqsave(&hvcs_pi_lock, flags);
1391 kfree(hvcs_pi_buff);
1392 hvcs_pi_buff = NULL;
1393 spin_unlock_irqrestore(&hvcs_pi_lock, flags);
1395 hvcs_remove_driver_attrs();
1397 vio_unregister_driver(&hvcs_vio_driver);
1399 tty_unregister_driver(hvcs_tty_driver);
1401 put_tty_driver(hvcs_tty_driver);
1403 printk(KERN_INFO "HVCS: driver module removed.\n");
1406 module_init(hvcs_module_init);
1407 module_exit(hvcs_module_exit);
1409 static inline struct hvcs_struct *from_vio_dev(struct vio_dev *viod)
1411 return viod->dev.driver_data;
1413 /* The sysfs interface for the driver and devices */
1415 static ssize_t hvcs_partner_vtys_show(struct device *dev, char *buf)
1417 struct vio_dev *viod = to_vio_dev(dev);
1418 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1419 unsigned long flags;
1422 spin_lock_irqsave(&hvcsd->lock, flags);
1423 retval = sprintf(buf, "%X\n", hvcsd->p_unit_address);
1424 spin_unlock_irqrestore(&hvcsd->lock, flags);
1427 static DEVICE_ATTR(partner_vtys, S_IRUGO, hvcs_partner_vtys_show, NULL);
1429 static ssize_t hvcs_partner_clcs_show(struct device *dev, char *buf)
1431 struct vio_dev *viod = to_vio_dev(dev);
1432 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1433 unsigned long flags;
1436 spin_lock_irqsave(&hvcsd->lock, flags);
1437 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
1438 spin_unlock_irqrestore(&hvcsd->lock, flags);
1441 static DEVICE_ATTR(partner_clcs, S_IRUGO, hvcs_partner_clcs_show, NULL);
1443 static ssize_t hvcs_current_vty_store(struct device *dev, const char * buf,
1447 * Don't need this feature at the present time because firmware doesn't
1448 * yet support multiple partners.
1450 printk(KERN_INFO "HVCS: Denied current_vty change: -EPERM.\n");
1454 static ssize_t hvcs_current_vty_show(struct device *dev, char *buf)
1456 struct vio_dev *viod = to_vio_dev(dev);
1457 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1458 unsigned long flags;
1461 spin_lock_irqsave(&hvcsd->lock, flags);
1462 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
1463 spin_unlock_irqrestore(&hvcsd->lock, flags);
1467 static DEVICE_ATTR(current_vty,
1468 S_IRUGO | S_IWUSR, hvcs_current_vty_show, hvcs_current_vty_store);
1470 static ssize_t hvcs_vterm_state_store(struct device *dev, const char *buf,
1473 struct vio_dev *viod = to_vio_dev(dev);
1474 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1475 unsigned long flags;
1477 /* writing a '0' to this sysfs entry will result in the disconnect. */
1478 if (simple_strtol(buf, NULL, 0) != 0)
1481 spin_lock_irqsave(&hvcsd->lock, flags);
1483 if (hvcsd->open_count > 0) {
1484 spin_unlock_irqrestore(&hvcsd->lock, flags);
1485 printk(KERN_INFO "HVCS: vterm state unchanged. "
1486 "The hvcs device node is still in use.\n");
1490 if (hvcsd->connected == 0) {
1491 spin_unlock_irqrestore(&hvcsd->lock, flags);
1492 printk(KERN_INFO "HVCS: vterm state unchanged. The"
1493 " vty-server is not connected to a vty.\n");
1497 hvcs_partner_free(hvcsd);
1498 printk(KERN_INFO "HVCS: Closed vty-server@%X and"
1499 " partner vty@%X:%d connection.\n",
1500 hvcsd->vdev->unit_address,
1501 hvcsd->p_unit_address,
1502 (unsigned int)hvcsd->p_partition_ID);
1504 spin_unlock_irqrestore(&hvcsd->lock, flags);
1508 static ssize_t hvcs_vterm_state_show(struct device *dev, char *buf)
1510 struct vio_dev *viod = to_vio_dev(dev);
1511 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1512 unsigned long flags;
1515 spin_lock_irqsave(&hvcsd->lock, flags);
1516 retval = sprintf(buf, "%d\n", hvcsd->connected);
1517 spin_unlock_irqrestore(&hvcsd->lock, flags);
1520 static DEVICE_ATTR(vterm_state, S_IRUGO | S_IWUSR,
1521 hvcs_vterm_state_show, hvcs_vterm_state_store);
1523 static struct attribute *hvcs_attrs[] = {
1524 &dev_attr_partner_vtys.attr,
1525 &dev_attr_partner_clcs.attr,
1526 &dev_attr_current_vty.attr,
1527 &dev_attr_vterm_state.attr,
1531 static struct attribute_group hvcs_attr_group = {
1532 .attrs = hvcs_attrs,
1535 static void hvcs_create_device_attrs(struct hvcs_struct *hvcsd)
1537 struct vio_dev *vdev = hvcsd->vdev;
1538 sysfs_create_group(&vdev->dev.kobj, &hvcs_attr_group);
1541 static void hvcs_remove_device_attrs(struct vio_dev *vdev)
1543 sysfs_remove_group(&vdev->dev.kobj, &hvcs_attr_group);
1546 static ssize_t hvcs_rescan_show(struct device_driver *ddp, char *buf)
1548 /* A 1 means it is updating, a 0 means it is done updating */
1549 return snprintf(buf, PAGE_SIZE, "%d\n", hvcs_rescan_status);
1552 static ssize_t hvcs_rescan_store(struct device_driver *ddp, const char * buf,
1555 if ((simple_strtol(buf, NULL, 0) != 1)
1556 && (hvcs_rescan_status != 0))
1559 hvcs_rescan_status = 1;
1560 printk(KERN_INFO "HVCS: rescanning partner info for all"
1562 hvcs_rescan_devices_list();
1563 hvcs_rescan_status = 0;
1566 static DRIVER_ATTR(rescan,
1567 S_IRUGO | S_IWUSR, hvcs_rescan_show, hvcs_rescan_store);
1569 static void hvcs_create_driver_attrs(void)
1571 struct device_driver *driverfs = &(hvcs_vio_driver.driver);
1572 driver_create_file(driverfs, &driver_attr_rescan);
1575 static void hvcs_remove_driver_attrs(void)
1577 struct device_driver *driverfs = &(hvcs_vio_driver.driver);
1578 driver_remove_file(driverfs, &driver_attr_rescan);