Commit b1d47464 authored by Tilman Schmidt's avatar Tilman Schmidt Committed by Linus Torvalds

[PATCH] isdn4linux: Siemens Gigaset drivers: sysfs usage

With Hansjoerg Lipp <hjlipp@web.de>

Correct the way the Gigaset drivers create their sysfs entries.
Signed-off-by: default avatarHansjoerg Lipp <hjlipp@web.de>
Signed-off-by: default avatarTilman Schmidt <tilman@imap.cc>
Cc: Karsten Keil <kkeil@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 784d5858
...@@ -2217,7 +2217,7 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -2217,7 +2217,7 @@ static int gigaset_probe(struct usb_interface *interface,
usb_get_dev(udev); usb_get_dev(udev);
ucs->udev = udev; ucs->udev = udev;
ucs->interface = interface; ucs->interface = interface;
cs->dev = &udev->dev; cs->dev = &interface->dev;
/* allocate URBs: /* allocate URBs:
* - one for the interrupt pipe * - one for the interrupt pipe
...@@ -2289,14 +2289,13 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -2289,14 +2289,13 @@ static int gigaset_probe(struct usb_interface *interface,
/* tell common part that the device is ready */ /* tell common part that the device is ready */
if (startmode == SM_LOCKED) if (startmode == SM_LOCKED)
atomic_set(&cs->mstate, MS_LOCKED); atomic_set(&cs->mstate, MS_LOCKED);
if (!gigaset_start(cs))
goto error;
/* save address of controller structure */ /* save address of controller structure */
usb_set_intfdata(interface, cs); usb_set_intfdata(interface, cs);
/* set up device sysfs */ if (!gigaset_start(cs))
gigaset_init_dev_sysfs(interface); goto error;
return 0; return 0;
error: error:
...@@ -2313,23 +2312,24 @@ static void gigaset_disconnect(struct usb_interface *interface) ...@@ -2313,23 +2312,24 @@ static void gigaset_disconnect(struct usb_interface *interface)
struct cardstate *cs; struct cardstate *cs;
struct bas_cardstate *ucs; struct bas_cardstate *ucs;
/* clear device sysfs */
gigaset_free_dev_sysfs(interface);
cs = usb_get_intfdata(interface); cs = usb_get_intfdata(interface);
usb_set_intfdata(interface, NULL);
IFNULLRET(cs); IFNULLRET(cs);
ucs = cs->hw.bas; ucs = cs->hw.bas;
IFNULLRET(ucs); IFNULLRET(ucs);
dev_info(cs->dev, "disconnecting GigaSet base"); dev_info(cs->dev, "disconnecting Gigaset base\n");
gigaset_stop(cs); gigaset_stop(cs);
freeurbs(cs); freeurbs(cs);
usb_set_intfdata(interface, NULL);
kfree(ucs->rcvbuf); kfree(ucs->rcvbuf);
ucs->rcvbuf = NULL; ucs->rcvbuf = NULL;
ucs->rcvbuf_size = 0; ucs->rcvbuf_size = 0;
atomic_set(&ucs->basstate, 0); atomic_set(&ucs->basstate, 0);
usb_put_dev(ucs->udev);
ucs->interface = NULL;
ucs->udev = NULL;
cs->dev = NULL;
gigaset_unassign(cs); gigaset_unassign(cs);
} }
......
...@@ -833,6 +833,9 @@ int gigaset_start(struct cardstate *cs) ...@@ -833,6 +833,9 @@ 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);
up(&cs->sem); up(&cs->sem);
return 1; return 1;
...@@ -882,6 +885,9 @@ void gigaset_stop(struct cardstate *cs) ...@@ -882,6 +885,9 @@ void gigaset_stop(struct cardstate *cs)
{ {
down(&cs->sem); down(&cs->sem);
/* clear device sysfs */
gigaset_free_dev_sysfs(cs);
atomic_set(&cs->connected, 0); atomic_set(&cs->connected, 0);
cs->waiting = 1; cs->waiting = 1;
......
...@@ -778,8 +778,8 @@ void gigaset_handle_modem_response(struct cardstate *cs); ...@@ -778,8 +778,8 @@ void gigaset_handle_modem_response(struct cardstate *cs);
*/ */
/* initialize sysfs for device */ /* initialize sysfs for device */
void gigaset_init_dev_sysfs(struct usb_interface *interface); void gigaset_init_dev_sysfs(struct cardstate *cs);
void gigaset_free_dev_sysfs(struct usb_interface *interface); void gigaset_free_dev_sysfs(struct cardstate *cs);
/* =========================================================================== /* ===========================================================================
* Functions implemented in common.c/gigaset.h * Functions implemented in common.c/gigaset.h
......
...@@ -19,16 +19,14 @@ ...@@ -19,16 +19,14 @@
static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr, static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct usb_interface *intf = to_usb_interface(dev); struct cardstate *cs = dev_get_drvdata(dev);
struct cardstate *cs = usb_get_intfdata(intf);
return sprintf(buf, "%d\n", atomic_read(&cs->cidmode)); return sprintf(buf, "%d\n", atomic_read(&cs->cidmode));
} }
static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct usb_interface *intf = to_usb_interface(dev); struct cardstate *cs = dev_get_drvdata(dev);
struct cardstate *cs = usb_get_intfdata(intf);
long int value; long int value;
char *end; char *end;
...@@ -63,17 +61,15 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, ...@@ -63,17 +61,15 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr,
static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode); static 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 usb_interface *interface) void gigaset_free_dev_sysfs(struct cardstate *cs)
{ {
gig_dbg(DEBUG_INIT, "removing sysfs entries"); gig_dbg(DEBUG_INIT, "removing sysfs entries");
device_remove_file(&interface->dev, &dev_attr_cidmode); device_remove_file(cs->dev, &dev_attr_cidmode);
} }
EXPORT_SYMBOL_GPL(gigaset_free_dev_sysfs);
/* initialize sysfs for device */ /* initialize sysfs for device */
void gigaset_init_dev_sysfs(struct usb_interface *interface) void gigaset_init_dev_sysfs(struct cardstate *cs)
{ {
gig_dbg(DEBUG_INIT, "setting up sysfs"); gig_dbg(DEBUG_INIT, "setting up sysfs");
device_create_file(&interface->dev, &dev_attr_cidmode); device_create_file(cs->dev, &dev_attr_cidmode);
} }
EXPORT_SYMBOL_GPL(gigaset_init_dev_sysfs);
...@@ -748,7 +748,10 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -748,7 +748,10 @@ static int gigaset_probe(struct usb_interface *interface,
usb_get_dev(udev); usb_get_dev(udev);
ucs->udev = udev; ucs->udev = udev;
ucs->interface = interface; ucs->interface = interface;
cs->dev = &udev->dev; cs->dev = &interface->dev;
/* save address of controller structure */
usb_set_intfdata(interface, cs); // dev_set_drvdata(&interface->dev, cs);
endpoint = &hostif->endpoint[0].desc; endpoint = &hostif->endpoint[0].desc;
...@@ -805,17 +808,12 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -805,17 +808,12 @@ static int gigaset_probe(struct usb_interface *interface,
/* tell common part that the device is ready */ /* tell common part that the device is ready */
if (startmode == SM_LOCKED) if (startmode == SM_LOCKED)
atomic_set(&cs->mstate, MS_LOCKED); atomic_set(&cs->mstate, MS_LOCKED);
if (!gigaset_start(cs)) { if (!gigaset_start(cs)) {
tasklet_kill(&cs->write_tasklet); tasklet_kill(&cs->write_tasklet);
retval = -ENODEV; //FIXME retval = -ENODEV; //FIXME
goto error; goto error;
} }
/* save address of controller structure */
usb_set_intfdata(interface, cs);
/* set up device sysfs */
gigaset_init_dev_sysfs(interface);
return 0; return 0;
error: error:
...@@ -827,6 +825,7 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -827,6 +825,7 @@ static int gigaset_probe(struct usb_interface *interface,
kfree(cs->inbuf[0].rcvbuf); kfree(cs->inbuf[0].rcvbuf);
if (ucs->read_urb != NULL) if (ucs->read_urb != NULL)
usb_free_urb(ucs->read_urb); usb_free_urb(ucs->read_urb);
usb_set_intfdata(interface, NULL);
ucs->read_urb = ucs->bulk_out_urb = NULL; ucs->read_urb = ucs->bulk_out_urb = NULL;
cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL; cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL;
usb_put_dev(ucs->udev); usb_put_dev(ucs->udev);
...@@ -845,16 +844,12 @@ static void gigaset_disconnect(struct usb_interface *interface) ...@@ -845,16 +844,12 @@ static void gigaset_disconnect(struct usb_interface *interface)
struct usb_cardstate *ucs; struct usb_cardstate *ucs;
cs = usb_get_intfdata(interface); cs = usb_get_intfdata(interface);
/* clear device sysfs */
gigaset_free_dev_sysfs(interface);
usb_set_intfdata(interface, NULL);
ucs = cs->hw.usb; ucs = cs->hw.usb;
usb_kill_urb(ucs->read_urb); usb_kill_urb(ucs->read_urb);
gigaset_stop(cs); gigaset_stop(cs);
usb_set_intfdata(interface, NULL);
tasklet_kill(&cs->write_tasklet); tasklet_kill(&cs->write_tasklet);
usb_kill_urb(ucs->bulk_out_urb); /* FIXME: only if active? */ usb_kill_urb(ucs->bulk_out_urb); /* FIXME: only if active? */
...@@ -868,6 +863,10 @@ static void gigaset_disconnect(struct usb_interface *interface) ...@@ -868,6 +863,10 @@ static void gigaset_disconnect(struct usb_interface *interface)
ucs->read_urb = ucs->bulk_out_urb = NULL; ucs->read_urb = ucs->bulk_out_urb = NULL;
cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL; cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL;
usb_put_dev(ucs->udev);
ucs->interface = NULL;
ucs->udev = NULL;
cs->dev = NULL;
gigaset_unassign(cs); gigaset_unassign(cs);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment