diff options
author | Hansjoerg Lipp <hjlipp@web.de> | 2006-04-22 12:43:00 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-06-21 15:40:47 -0400 |
commit | 3dda4e373c7474cfe280f4270b70c1563f92a2a7 (patch) | |
tree | b38e2c22056859de773ef8e47b059f53a52d0215 | |
parent | 1cdcb6b43fda7424b7435dac8f80b2b5d8a48899 (diff) |
[PATCH] i4l gigaset: move sysfs entry to tty class device
Using the class device pointer returned by tty_register_device() with
part 1 of the patch, attach the Gigaset drivers' "cidmode" sysfs entry
to its tty class device, where it can be found more easily by users
who do not know nor care which USB port the device is attached to.
Signed-off-by: Hansjoerg Lipp <hjlipp@web.de>
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | Documentation/isdn/README.gigaset | 7 | ||||
-rw-r--r-- | drivers/isdn/gigaset/common.c | 13 | ||||
-rw-r--r-- | drivers/isdn/gigaset/gigaset.h | 1 | ||||
-rw-r--r-- | drivers/isdn/gigaset/interface.c | 10 | ||||
-rw-r--r-- | drivers/isdn/gigaset/proc.c | 21 |
5 files changed, 34 insertions, 18 deletions
diff --git a/Documentation/isdn/README.gigaset b/Documentation/isdn/README.gigaset index 85a64defd38..fa0d4cca964 100644 --- a/Documentation/isdn/README.gigaset +++ b/Documentation/isdn/README.gigaset | |||
@@ -124,7 +124,8 @@ GigaSet 307x Device Driver | |||
124 | 124 | ||
125 | You can use some configuration tool of your distribution to configure this | 125 | You can use some configuration tool of your distribution to configure this |
126 | "modem" or configure pppd/wvdial manually. There are some example ppp | 126 | "modem" or configure pppd/wvdial manually. There are some example ppp |
127 | configuration files and chat scripts in the gigaset-VERSION/ppp directory. | 127 | configuration files and chat scripts in the gigaset-VERSION/ppp directory |
128 | in the driver packages from http://sourceforge.net/projects/gigaset307x/. | ||
128 | Please note that the USB drivers are not able to change the state of the | 129 | Please note that the USB drivers are not able to change the state of the |
129 | control lines (the M105 driver can be configured to use some undocumented | 130 | control lines (the M105 driver can be configured to use some undocumented |
130 | control requests, if you really need the control lines, though). This means | 131 | control requests, if you really need the control lines, though). This means |
@@ -164,8 +165,8 @@ GigaSet 307x Device Driver | |||
164 | 165 | ||
165 | If you want both of these at once, you are out of luck. | 166 | If you want both of these at once, you are out of luck. |
166 | 167 | ||
167 | You can also use /sys/module/<name>/parameters/cidmode for changing | 168 | You can also use /sys/class/tty/ttyGxy/cidmode for changing the CID mode |
168 | the CID mode setting (<name> is usb_gigaset or bas_gigaset). | 169 | setting (ttyGxy is ttyGU0 or ttyGB0). |
169 | 170 | ||
170 | 171 | ||
171 | 3. Troubleshooting | 172 | 3. Troubleshooting |
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c index e55767b2ccd..acb7e265678 100644 --- a/drivers/isdn/gigaset/common.c +++ b/drivers/isdn/gigaset/common.c | |||
@@ -460,6 +460,9 @@ void gigaset_freecs(struct cardstate *cs) | |||
460 | 460 | ||
461 | switch (cs->cs_init) { | 461 | switch (cs->cs_init) { |
462 | default: | 462 | default: |
463 | /* clear device sysfs */ | ||
464 | gigaset_free_dev_sysfs(cs); | ||
465 | |||
463 | gigaset_if_free(cs); | 466 | gigaset_if_free(cs); |
464 | 467 | ||
465 | gig_dbg(DEBUG_INIT, "clearing hw"); | 468 | gig_dbg(DEBUG_INIT, "clearing hw"); |
@@ -699,6 +702,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
699 | cs->open_count = 0; | 702 | cs->open_count = 0; |
700 | cs->dev = NULL; | 703 | cs->dev = NULL; |
701 | cs->tty = NULL; | 704 | cs->tty = NULL; |
705 | cs->class = NULL; | ||
702 | cs->cidmode = cidmode != 0; | 706 | cs->cidmode = cidmode != 0; |
703 | 707 | ||
704 | //if(onechannel) { //FIXME | 708 | //if(onechannel) { //FIXME |
@@ -760,6 +764,9 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
760 | 764 | ||
761 | gigaset_if_init(cs); | 765 | gigaset_if_init(cs); |
762 | 766 | ||
767 | /* set up device sysfs */ | ||
768 | gigaset_init_dev_sysfs(cs); | ||
769 | |||
763 | spin_lock_irqsave(&cs->lock, flags); | 770 | spin_lock_irqsave(&cs->lock, flags); |
764 | cs->running = 1; | 771 | cs->running = 1; |
765 | spin_unlock_irqrestore(&cs->lock, flags); | 772 | spin_unlock_irqrestore(&cs->lock, flags); |
@@ -902,9 +909,6 @@ int gigaset_start(struct cardstate *cs) | |||
902 | 909 | ||
903 | wait_event(cs->waitqueue, !cs->waiting); | 910 | wait_event(cs->waitqueue, !cs->waiting); |
904 | 911 | ||
905 | /* set up device sysfs */ | ||
906 | gigaset_init_dev_sysfs(cs); | ||
907 | |||
908 | mutex_unlock(&cs->mutex); | 912 | mutex_unlock(&cs->mutex); |
909 | return 1; | 913 | return 1; |
910 | 914 | ||
@@ -969,9 +973,6 @@ void gigaset_stop(struct cardstate *cs) | |||
969 | //FIXME | 973 | //FIXME |
970 | } | 974 | } |
971 | 975 | ||
972 | /* clear device sysfs */ | ||
973 | gigaset_free_dev_sysfs(cs); | ||
974 | |||
975 | cleanup_cs(cs); | 976 | cleanup_cs(cs); |
976 | 977 | ||
977 | exit: | 978 | exit: |
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h index 22b9693f7c0..8d63d822104 100644 --- a/drivers/isdn/gigaset/gigaset.h +++ b/drivers/isdn/gigaset/gigaset.h | |||
@@ -445,6 +445,7 @@ struct cardstate { | |||
445 | struct gigaset_driver *driver; | 445 | struct gigaset_driver *driver; |
446 | unsigned minor_index; | 446 | unsigned minor_index; |
447 | struct device *dev; | 447 | struct device *dev; |
448 | struct class_device *class; | ||
448 | 449 | ||
449 | const struct gigaset_ops *ops; | 450 | const struct gigaset_ops *ops; |
450 | 451 | ||
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c index 08e4c4eea14..74fd234956c 100644 --- a/drivers/isdn/gigaset/interface.c +++ b/drivers/isdn/gigaset/interface.c | |||
@@ -625,7 +625,14 @@ void gigaset_if_init(struct cardstate *cs) | |||
625 | return; | 625 | return; |
626 | 626 | ||
627 | tasklet_init(&cs->if_wake_tasklet, &if_wake, (unsigned long) cs); | 627 | tasklet_init(&cs->if_wake_tasklet, &if_wake, (unsigned long) cs); |
628 | tty_register_device(drv->tty, cs->minor_index, NULL); | 628 | cs->class = tty_register_device(drv->tty, cs->minor_index, NULL); |
629 | |||
630 | if (!IS_ERR(cs->class)) | ||
631 | class_set_devdata(cs->class, cs); | ||
632 | else { | ||
633 | warn("could not register device to the tty subsystem"); | ||
634 | cs->class = NULL; | ||
635 | } | ||
629 | } | 636 | } |
630 | 637 | ||
631 | void gigaset_if_free(struct cardstate *cs) | 638 | void gigaset_if_free(struct cardstate *cs) |
@@ -638,6 +645,7 @@ void gigaset_if_free(struct cardstate *cs) | |||
638 | 645 | ||
639 | tasklet_disable(&cs->if_wake_tasklet); | 646 | tasklet_disable(&cs->if_wake_tasklet); |
640 | tasklet_kill(&cs->if_wake_tasklet); | 647 | tasklet_kill(&cs->if_wake_tasklet); |
648 | cs->class = NULL; | ||
641 | tty_unregister_device(drv->tty, cs->minor_index); | 649 | tty_unregister_device(drv->tty, cs->minor_index); |
642 | } | 650 | } |
643 | 651 | ||
diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c index d267a636b53..9ae3a7f3e7b 100644 --- a/drivers/isdn/gigaset/proc.c +++ b/drivers/isdn/gigaset/proc.c | |||
@@ -16,12 +16,11 @@ | |||
16 | #include "gigaset.h" | 16 | #include "gigaset.h" |
17 | #include <linux/ctype.h> | 17 | #include <linux/ctype.h> |
18 | 18 | ||
19 | static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr, | 19 | static ssize_t show_cidmode(struct class_device *class, char *buf) |
20 | char *buf) | ||
21 | { | 20 | { |
22 | int ret; | 21 | int ret; |
23 | unsigned long flags; | 22 | unsigned long flags; |
24 | struct cardstate *cs = dev_get_drvdata(dev); | 23 | struct cardstate *cs = class_get_devdata(class); |
25 | 24 | ||
26 | spin_lock_irqsave(&cs->lock, flags); | 25 | spin_lock_irqsave(&cs->lock, flags); |
27 | ret = sprintf(buf, "%u\n", cs->cidmode); | 26 | ret = sprintf(buf, "%u\n", cs->cidmode); |
@@ -30,10 +29,10 @@ static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr, | |||
30 | return ret; | 29 | return ret; |
31 | } | 30 | } |
32 | 31 | ||
33 | static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, | 32 | static ssize_t set_cidmode(struct class_device *class, |
34 | const char *buf, size_t count) | 33 | const char *buf, size_t count) |
35 | { | 34 | { |
36 | struct cardstate *cs = dev_get_drvdata(dev); | 35 | struct cardstate *cs = class_get_devdata(class); |
37 | long int value; | 36 | long int value; |
38 | char *end; | 37 | char *end; |
39 | 38 | ||
@@ -65,18 +64,24 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, | |||
65 | return count; | 64 | return count; |
66 | } | 65 | } |
67 | 66 | ||
68 | static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode); | 67 | static CLASS_DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode); |
69 | 68 | ||
70 | /* free sysfs for device */ | 69 | /* free sysfs for device */ |
71 | void gigaset_free_dev_sysfs(struct cardstate *cs) | 70 | void gigaset_free_dev_sysfs(struct cardstate *cs) |
72 | { | 71 | { |
72 | if (!cs->class) | ||
73 | return; | ||
74 | |||
73 | gig_dbg(DEBUG_INIT, "removing sysfs entries"); | 75 | gig_dbg(DEBUG_INIT, "removing sysfs entries"); |
74 | device_remove_file(cs->dev, &dev_attr_cidmode); | 76 | class_device_remove_file(cs->class, &class_device_attr_cidmode); |
75 | } | 77 | } |
76 | 78 | ||
77 | /* initialize sysfs for device */ | 79 | /* initialize sysfs for device */ |
78 | void gigaset_init_dev_sysfs(struct cardstate *cs) | 80 | void gigaset_init_dev_sysfs(struct cardstate *cs) |
79 | { | 81 | { |
82 | if (!cs->class) | ||
83 | return; | ||
84 | |||
80 | gig_dbg(DEBUG_INIT, "setting up sysfs"); | 85 | gig_dbg(DEBUG_INIT, "setting up sysfs"); |
81 | device_create_file(cs->dev, &dev_attr_cidmode); | 86 | class_device_create_file(cs->class, &class_device_attr_cidmode); |
82 | } | 87 | } |