Commit bb7f4552 authored by Ben Collins's avatar Ben Collins

IEEE1394/dv(r1177): Fix dv1394 devfs cleanup.

parent a7672d54
...@@ -2222,7 +2222,7 @@ static int dv1394_init(struct ti_ohci *ohci, enum pal_or_ntsc format, enum modes ...@@ -2222,7 +2222,7 @@ static int dv1394_init(struct ti_ohci *ohci, enum pal_or_ntsc format, enum modes
video->ohci = ohci; video->ohci = ohci;
/* lower 2 bits of id indicate which of four "plugs" /* lower 2 bits of id indicate which of four "plugs"
per host */ per host */
video->id = ohci->id << 2; video->id = ohci->host->id << 2;
if (format == DV1394_NTSC) if (format == DV1394_NTSC)
video->id |= mode; video->id |= mode;
else else
...@@ -2302,47 +2302,49 @@ static void dv1394_un_init(struct video_card *video) ...@@ -2302,47 +2302,49 @@ static void dv1394_un_init(struct video_card *video)
); );
devfs_remove("ieee1394/%s", buf); devfs_remove("ieee1394/%s", buf);
list_del(&video->list);
kfree(video); kfree(video);
} }
static void dv1394_remove_host (struct hpsb_host *host) static void dv1394_remove_host (struct hpsb_host *host)
{ {
struct ti_ohci *ohci; struct video_card *video;
struct video_card *video = NULL;
unsigned long flags; unsigned long flags;
struct list_head *lh, *templh; int id = host->id;
int n;
/* We only work with the OHCI-1394 driver */ /* We only work with the OHCI-1394 driver */
if (strcmp(host->driver->name, OHCI1394_DRIVER_NAME)) if (strcmp(host->driver->name, OHCI1394_DRIVER_NAME))
return; return;
ohci = (struct ti_ohci *)host->hostdata; /* find the corresponding video_cards */
do {
struct video_card *tmp_vid;
video = NULL;
/* find the corresponding video_cards */ spin_lock_irqsave(&dv1394_cards_lock, flags);
spin_lock_irqsave(&dv1394_cards_lock, flags); list_for_each_entry(tmp_vid, &dv1394_cards, list) {
if (!list_empty(&dv1394_cards)) { if ((tmp_vid->id >> 2) == id) {
list_for_each_safe(lh, templh, &dv1394_cards) { list_del(&tmp_vid->list);
video = list_entry(lh, struct video_card, list); video = tmp_vid;
if ((video->id >> 2) == ohci->id) break;
dv1394_un_init(video); }
} }
} spin_unlock_irqrestore(&dv1394_cards_lock, flags);
spin_unlock_irqrestore(&dv1394_cards_lock, flags);
n = (video->id >> 2); if (video)
dv1394_un_init(video);
} while (video != NULL);
devfs_remove("ieee1394/dv/host%d/NTSC", n); devfs_remove("ieee1394/dv/host%d/NTSC", id);
devfs_remove("ieee1394/dv/host%d/PAL", n); devfs_remove("ieee1394/dv/host%d/PAL", id);
devfs_remove("ieee1394/dv/host%d", n); devfs_remove("ieee1394/dv/host%d", id);
} }
static void dv1394_add_host (struct hpsb_host *host) static void dv1394_add_host (struct hpsb_host *host)
{ {
struct ti_ohci *ohci; struct ti_ohci *ohci;
int id = host->id;
/* We only work with the OHCI-1394 driver */ /* We only work with the OHCI-1394 driver */
if (strcmp(host->driver->name, OHCI1394_DRIVER_NAME)) if (strcmp(host->driver->name, OHCI1394_DRIVER_NAME))
...@@ -2350,9 +2352,9 @@ static void dv1394_add_host (struct hpsb_host *host) ...@@ -2350,9 +2352,9 @@ static void dv1394_add_host (struct hpsb_host *host)
ohci = (struct ti_ohci *)host->hostdata; ohci = (struct ti_ohci *)host->hostdata;
devfs_mk_dir("ieee1394/dv/host%d", ohci->id); devfs_mk_dir("ieee1394/dv/host%d", id);
devfs_mk_dir("ieee1394/dv/host%d/NTSC", ohci->id); devfs_mk_dir("ieee1394/dv/host%d/NTSC", id);
devfs_mk_dir("ieee1394/dv/host%d/PAL", ohci->id); devfs_mk_dir("ieee1394/dv/host%d/PAL", id);
dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE); dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE);
dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT); dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT);
...@@ -2369,7 +2371,7 @@ static void dv1394_add_host (struct hpsb_host *host) ...@@ -2369,7 +2371,7 @@ static void dv1394_add_host (struct hpsb_host *host)
static void dv1394_host_reset(struct hpsb_host *host) static void dv1394_host_reset(struct hpsb_host *host)
{ {
struct ti_ohci *ohci; struct ti_ohci *ohci;
struct video_card *video = NULL; struct video_card *video = NULL, *tmp_vid;
unsigned long flags; unsigned long flags;
/* We only work with the OHCI-1394 driver */ /* We only work with the OHCI-1394 driver */
...@@ -2381,10 +2383,10 @@ static void dv1394_host_reset(struct hpsb_host *host) ...@@ -2381,10 +2383,10 @@ static void dv1394_host_reset(struct hpsb_host *host)
/* find the corresponding video_cards */ /* find the corresponding video_cards */
spin_lock_irqsave(&dv1394_cards_lock, flags); spin_lock_irqsave(&dv1394_cards_lock, flags);
if (!list_empty(&dv1394_cards)) { list_for_each_entry(tmp_vid, &dv1394_cards, list) {
list_for_each_entry(video, &dv1394_cards, list) { if ((tmp_vid->id >> 2) == host->id) {
if ((video->id >> 2) == ohci->id) video = tmp_vid;
break; break;
} }
} }
spin_unlock_irqrestore(&dv1394_cards_lock, flags); spin_unlock_irqrestore(&dv1394_cards_lock, flags);
......
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