aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Taprogge <jens.taprogge@taprogge.org>2012-09-12 08:55:42 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-09-12 12:56:02 -0400
commit9c1d784afc6fc37d328623d1adf503031b524788 (patch)
treedee75b17f6c47b38eaaf1d5aebd6cf38d1af7b89
parent3f3a592798fe4a6eff0448685280925a9b1830f4 (diff)
Staging: ipack/devices/ipoctal: Get rid of ipoctal_list.
Use tty_dev->dev's drdata to associate struct ipocal_channel to the respective tty_struct. Signed-off-by: Jens Taprogge <jens.taprogge@taprogge.org> Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/ipack/devices/ipoctal.c39
1 files changed, 3 insertions, 36 deletions
diff --git a/drivers/staging/ipack/devices/ipoctal.c b/drivers/staging/ipack/devices/ipoctal.c
index a0c1e7651ea5..8b2be618fc9e 100644
--- a/drivers/staging/ipack/devices/ipoctal.c
+++ b/drivers/staging/ipack/devices/ipoctal.c
@@ -49,7 +49,6 @@ struct ipoctal_channel {
49}; 49};
50 50
51struct ipoctal { 51struct ipoctal {
52 struct list_head list;
53 struct ipack_device *dev; 52 struct ipack_device *dev;
54 unsigned int board_id; 53 unsigned int board_id;
55 struct ipoctal_channel channel[NR_CHANNELS]; 54 struct ipoctal_channel channel[NR_CHANNELS];
@@ -57,34 +56,11 @@ struct ipoctal {
57 struct tty_driver *tty_drv; 56 struct tty_driver *tty_drv;
58}; 57};
59 58
60/* Linked list to save the registered devices */
61static LIST_HEAD(ipoctal_list);
62
63static struct ipoctal *ipoctal_find_board(struct tty_struct *tty)
64{
65 struct ipoctal *p;
66
67 list_for_each_entry(p, &ipoctal_list, list) {
68 if (tty->driver->major == p->tty_drv->major)
69 return p;
70 }
71
72 return NULL;
73}
74
75static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty) 59static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
76{ 60{
77 struct ipoctal *ipoctal;
78 struct ipoctal_channel *channel; 61 struct ipoctal_channel *channel;
79 62
80 ipoctal = ipoctal_find_board(tty); 63 channel = dev_get_drvdata(tty->dev);
81
82 if (ipoctal == NULL) {
83 dev_err(tty->dev, "Device not found. Major %d\n",
84 tty->driver->major);
85 return -ENODEV;
86 }
87 channel = &ipoctal->channel[tty->index];
88 64
89 iowrite8(CR_ENABLE_RX, &channel->regs->w.cr); 65 iowrite8(CR_ENABLE_RX, &channel->regs->w.cr);
90 return 0; 66 return 0;
@@ -93,17 +69,9 @@ static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
93static int ipoctal_open(struct tty_struct *tty, struct file *file) 69static int ipoctal_open(struct tty_struct *tty, struct file *file)
94{ 70{
95 int res; 71 int res;
96 struct ipoctal *ipoctal;
97 struct ipoctal_channel *channel; 72 struct ipoctal_channel *channel;
98 73
99 ipoctal = ipoctal_find_board(tty); 74 channel = dev_get_drvdata(tty->dev);
100
101 if (ipoctal == NULL) {
102 dev_err(tty->dev, "Device not found. Major %d\n",
103 tty->driver->major);
104 return -ENODEV;
105 }
106 channel = &ipoctal->channel[tty->index];
107 75
108 if (atomic_read(&channel->open)) 76 if (atomic_read(&channel->open))
109 return -EBUSY; 77 return -EBUSY;
@@ -457,6 +425,7 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
457 dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n"); 425 dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n");
458 continue; 426 continue;
459 } 427 }
428 dev_set_drvdata(tty_dev, channel);
460 429
461 /* 430 /*
462 * Enable again the RX. TX will be enabled when 431 * Enable again the RX. TX will be enabled when
@@ -732,7 +701,6 @@ static int ipoctal_probe(struct ipack_device *dev)
732 goto out_uninst; 701 goto out_uninst;
733 702
734 dev_set_drvdata(&dev->dev, ipoctal); 703 dev_set_drvdata(&dev->dev, ipoctal);
735 list_add_tail(&ipoctal->list, &ipoctal_list);
736 return 0; 704 return 0;
737 705
738out_uninst: 706out_uninst:
@@ -754,7 +722,6 @@ static void __ipoctal_remove(struct ipoctal *ipoctal)
754 722
755 tty_unregister_driver(ipoctal->tty_drv); 723 tty_unregister_driver(ipoctal->tty_drv);
756 put_tty_driver(ipoctal->tty_drv); 724 put_tty_driver(ipoctal->tty_drv);
757 list_del(&ipoctal->list);
758 kfree(ipoctal); 725 kfree(ipoctal);
759} 726}
760 727