提交 3dda4e37 编写于 作者: H Hansjoerg Lipp 提交者: Greg Kroah-Hartman

[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: NHansjoerg Lipp <hjlipp@web.de>
Signed-off-by: NTilman Schmidt <tilman@imap.cc>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 1cdcb6b4
...@@ -124,7 +124,8 @@ GigaSet 307x Device Driver ...@@ -124,7 +124,8 @@ GigaSet 307x Device Driver
You can use some configuration tool of your distribution to configure this You can use some configuration tool of your distribution to configure this
"modem" or configure pppd/wvdial manually. There are some example ppp "modem" or configure pppd/wvdial manually. There are some example ppp
configuration files and chat scripts in the gigaset-VERSION/ppp directory. configuration files and chat scripts in the gigaset-VERSION/ppp directory
in the driver packages from http://sourceforge.net/projects/gigaset307x/.
Please note that the USB drivers are not able to change the state of the Please note that the USB drivers are not able to change the state of the
control lines (the M105 driver can be configured to use some undocumented control lines (the M105 driver can be configured to use some undocumented
control requests, if you really need the control lines, though). This means control requests, if you really need the control lines, though). This means
...@@ -164,8 +165,8 @@ GigaSet 307x Device Driver ...@@ -164,8 +165,8 @@ GigaSet 307x Device Driver
If you want both of these at once, you are out of luck. If you want both of these at once, you are out of luck.
You can also use /sys/module/<name>/parameters/cidmode for changing You can also use /sys/class/tty/ttyGxy/cidmode for changing the CID mode
the CID mode setting (<name> is usb_gigaset or bas_gigaset). setting (ttyGxy is ttyGU0 or ttyGB0).
3. Troubleshooting 3. Troubleshooting
......
...@@ -460,6 +460,9 @@ void gigaset_freecs(struct cardstate *cs) ...@@ -460,6 +460,9 @@ void gigaset_freecs(struct cardstate *cs)
switch (cs->cs_init) { switch (cs->cs_init) {
default: default:
/* clear device sysfs */
gigaset_free_dev_sysfs(cs);
gigaset_if_free(cs); gigaset_if_free(cs);
gig_dbg(DEBUG_INIT, "clearing hw"); gig_dbg(DEBUG_INIT, "clearing hw");
...@@ -699,6 +702,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -699,6 +702,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
cs->open_count = 0; cs->open_count = 0;
cs->dev = NULL; cs->dev = NULL;
cs->tty = NULL; cs->tty = NULL;
cs->class = NULL;
cs->cidmode = cidmode != 0; cs->cidmode = cidmode != 0;
//if(onechannel) { //FIXME //if(onechannel) { //FIXME
...@@ -760,6 +764,9 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -760,6 +764,9 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
gigaset_if_init(cs); gigaset_if_init(cs);
/* set up device sysfs */
gigaset_init_dev_sysfs(cs);
spin_lock_irqsave(&cs->lock, flags); spin_lock_irqsave(&cs->lock, flags);
cs->running = 1; cs->running = 1;
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
...@@ -902,9 +909,6 @@ int gigaset_start(struct cardstate *cs) ...@@ -902,9 +909,6 @@ int gigaset_start(struct cardstate *cs)
wait_event(cs->waitqueue, !cs->waiting); wait_event(cs->waitqueue, !cs->waiting);
/* set up device sysfs */
gigaset_init_dev_sysfs(cs);
mutex_unlock(&cs->mutex); mutex_unlock(&cs->mutex);
return 1; return 1;
...@@ -969,9 +973,6 @@ void gigaset_stop(struct cardstate *cs) ...@@ -969,9 +973,6 @@ void gigaset_stop(struct cardstate *cs)
//FIXME //FIXME
} }
/* clear device sysfs */
gigaset_free_dev_sysfs(cs);
cleanup_cs(cs); cleanup_cs(cs);
exit: exit:
......
...@@ -445,6 +445,7 @@ struct cardstate { ...@@ -445,6 +445,7 @@ struct cardstate {
struct gigaset_driver *driver; struct gigaset_driver *driver;
unsigned minor_index; unsigned minor_index;
struct device *dev; struct device *dev;
struct class_device *class;
const struct gigaset_ops *ops; const struct gigaset_ops *ops;
......
...@@ -625,7 +625,14 @@ void gigaset_if_init(struct cardstate *cs) ...@@ -625,7 +625,14 @@ void gigaset_if_init(struct cardstate *cs)
return; return;
tasklet_init(&cs->if_wake_tasklet, &if_wake, (unsigned long) cs); tasklet_init(&cs->if_wake_tasklet, &if_wake, (unsigned long) cs);
tty_register_device(drv->tty, cs->minor_index, NULL); cs->class = tty_register_device(drv->tty, cs->minor_index, NULL);
if (!IS_ERR(cs->class))
class_set_devdata(cs->class, cs);
else {
warn("could not register device to the tty subsystem");
cs->class = NULL;
}
} }
void gigaset_if_free(struct cardstate *cs) void gigaset_if_free(struct cardstate *cs)
...@@ -638,6 +645,7 @@ void gigaset_if_free(struct cardstate *cs) ...@@ -638,6 +645,7 @@ void gigaset_if_free(struct cardstate *cs)
tasklet_disable(&cs->if_wake_tasklet); tasklet_disable(&cs->if_wake_tasklet);
tasklet_kill(&cs->if_wake_tasklet); tasklet_kill(&cs->if_wake_tasklet);
cs->class = NULL;
tty_unregister_device(drv->tty, cs->minor_index); tty_unregister_device(drv->tty, cs->minor_index);
} }
......
...@@ -16,12 +16,11 @@ ...@@ -16,12 +16,11 @@
#include "gigaset.h" #include "gigaset.h"
#include <linux/ctype.h> #include <linux/ctype.h>
static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr, static ssize_t show_cidmode(struct class_device *class, char *buf)
char *buf)
{ {
int ret; int ret;
unsigned long flags; unsigned long flags;
struct cardstate *cs = dev_get_drvdata(dev); struct cardstate *cs = class_get_devdata(class);
spin_lock_irqsave(&cs->lock, flags); spin_lock_irqsave(&cs->lock, flags);
ret = sprintf(buf, "%u\n", cs->cidmode); ret = sprintf(buf, "%u\n", cs->cidmode);
...@@ -30,10 +29,10 @@ static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr, ...@@ -30,10 +29,10 @@ static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr,
return ret; return ret;
} }
static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, static ssize_t set_cidmode(struct class_device *class,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct cardstate *cs = dev_get_drvdata(dev); struct cardstate *cs = class_get_devdata(class);
long int value; long int value;
char *end; char *end;
...@@ -65,18 +64,24 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, ...@@ -65,18 +64,24 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr,
return count; return count;
} }
static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode); static CLASS_DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode);
/* free sysfs for device */ /* free sysfs for device */
void gigaset_free_dev_sysfs(struct cardstate *cs) void gigaset_free_dev_sysfs(struct cardstate *cs)
{ {
if (!cs->class)
return;
gig_dbg(DEBUG_INIT, "removing sysfs entries"); gig_dbg(DEBUG_INIT, "removing sysfs entries");
device_remove_file(cs->dev, &dev_attr_cidmode); class_device_remove_file(cs->class, &class_device_attr_cidmode);
} }
/* initialize sysfs for device */ /* initialize sysfs for device */
void gigaset_init_dev_sysfs(struct cardstate *cs) void gigaset_init_dev_sysfs(struct cardstate *cs)
{ {
if (!cs->class)
return;
gig_dbg(DEBUG_INIT, "setting up sysfs"); gig_dbg(DEBUG_INIT, "setting up sysfs");
device_create_file(cs->dev, &dev_attr_cidmode); class_device_create_file(cs->class, &class_device_attr_cidmode);
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册