aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-09 15:08:59 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-09 15:08:59 -0500
commit21a2cb565a74bf794d343ce22300c5f6c1568ae1 (patch)
tree5cf49d94bc8cc31a299417b8a362f0645b41c543 /drivers/misc
parentc99516ca854770000c277b2680a15581c691e18c (diff)
parent2a5ac6f7a9c0a24adcf68e0dd634afbe083191c1 (diff)
Merge branch 'char-misc-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
* 'char-misc-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: isl29020: Remove a redundant semi-colon from return statement BMP085: Remove redundant semi-colon from return statement drivers:misc: ti-st: DEBUG uart, baud rate mods drivers:misc: ti-st: flush UART upon fw failure drivers:misc: ti-st: protect registrations char_dev.c: fix up some whitespace errors s390: tape_class.h: remove kobj_map.h inclusion misc: ad525x_dpot: Add support for SPI module device table matching
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/ad525x_dpot-i2c.c10
-rw-r--r--drivers/misc/ad525x_dpot-spi.c97
-rw-r--r--drivers/misc/ad525x_dpot.c24
-rw-r--r--drivers/misc/ad525x_dpot.h8
-rw-r--r--drivers/misc/bmp085.c2
-rw-r--r--drivers/misc/isl29020.c2
-rw-r--r--drivers/misc/ti-st/st_core.c18
-rw-r--r--drivers/misc/ti-st/st_kim.c84
8 files changed, 123 insertions, 122 deletions
diff --git a/drivers/misc/ad525x_dpot-i2c.c b/drivers/misc/ad525x_dpot-i2c.c
index a39e0555df63..83adab69bfd4 100644
--- a/drivers/misc/ad525x_dpot-i2c.c
+++ b/drivers/misc/ad525x_dpot-i2c.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for the Analog Devices digital potentiometers (I2C bus) 2 * Driver for the Analog Devices digital potentiometers (I2C bus)
3 * 3 *
4 * Copyright (C) 2010 Michael Hennerich, Analog Devices Inc. 4 * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc.
5 * 5 *
6 * Licensed under the GPL-2 or later. 6 * Licensed under the GPL-2 or later.
7 */ 7 */
@@ -11,7 +11,6 @@
11 11
12#include "ad525x_dpot.h" 12#include "ad525x_dpot.h"
13 13
14/* ------------------------------------------------------------------------- */
15/* I2C bus functions */ 14/* I2C bus functions */
16static int write_d8(void *client, u8 val) 15static int write_d8(void *client, u8 val)
17{ 16{
@@ -60,18 +59,13 @@ static int __devinit ad_dpot_i2c_probe(struct i2c_client *client,
60 .bops = &bops, 59 .bops = &bops,
61 }; 60 };
62 61
63 struct ad_dpot_id dpot_id = {
64 .name = (char *) &id->name,
65 .devid = id->driver_data,
66 };
67
68 if (!i2c_check_functionality(client->adapter, 62 if (!i2c_check_functionality(client->adapter,
69 I2C_FUNC_SMBUS_WORD_DATA)) { 63 I2C_FUNC_SMBUS_WORD_DATA)) {
70 dev_err(&client->dev, "SMBUS Word Data not Supported\n"); 64 dev_err(&client->dev, "SMBUS Word Data not Supported\n");
71 return -EIO; 65 return -EIO;
72 } 66 }
73 67
74 return ad_dpot_probe(&client->dev, &bdata, &dpot_id); 68 return ad_dpot_probe(&client->dev, &bdata, id->driver_data, id->name);
75} 69}
76 70
77static int __devexit ad_dpot_i2c_remove(struct i2c_client *client) 71static int __devexit ad_dpot_i2c_remove(struct i2c_client *client)
diff --git a/drivers/misc/ad525x_dpot-spi.c b/drivers/misc/ad525x_dpot-spi.c
index 7f9a55afe05d..822749e41fea 100644
--- a/drivers/misc/ad525x_dpot-spi.c
+++ b/drivers/misc/ad525x_dpot-spi.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for the Analog Devices digital potentiometers (SPI bus) 2 * Driver for the Analog Devices digital potentiometers (SPI bus)
3 * 3 *
4 * Copyright (C) 2010 Michael Hennerich, Analog Devices Inc. 4 * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc.
5 * 5 *
6 * Licensed under the GPL-2 or later. 6 * Licensed under the GPL-2 or later.
7 */ 7 */
@@ -11,40 +11,6 @@
11 11
12#include "ad525x_dpot.h" 12#include "ad525x_dpot.h"
13 13
14static const struct ad_dpot_id ad_dpot_spi_devlist[] = {
15 {.name = "ad5160", .devid = AD5160_ID},
16 {.name = "ad5161", .devid = AD5161_ID},
17 {.name = "ad5162", .devid = AD5162_ID},
18 {.name = "ad5165", .devid = AD5165_ID},
19 {.name = "ad5200", .devid = AD5200_ID},
20 {.name = "ad5201", .devid = AD5201_ID},
21 {.name = "ad5203", .devid = AD5203_ID},
22 {.name = "ad5204", .devid = AD5204_ID},
23 {.name = "ad5206", .devid = AD5206_ID},
24 {.name = "ad5207", .devid = AD5207_ID},
25 {.name = "ad5231", .devid = AD5231_ID},
26 {.name = "ad5232", .devid = AD5232_ID},
27 {.name = "ad5233", .devid = AD5233_ID},
28 {.name = "ad5235", .devid = AD5235_ID},
29 {.name = "ad5260", .devid = AD5260_ID},
30 {.name = "ad5262", .devid = AD5262_ID},
31 {.name = "ad5263", .devid = AD5263_ID},
32 {.name = "ad5290", .devid = AD5290_ID},
33 {.name = "ad5291", .devid = AD5291_ID},
34 {.name = "ad5292", .devid = AD5292_ID},
35 {.name = "ad5293", .devid = AD5293_ID},
36 {.name = "ad7376", .devid = AD7376_ID},
37 {.name = "ad8400", .devid = AD8400_ID},
38 {.name = "ad8402", .devid = AD8402_ID},
39 {.name = "ad8403", .devid = AD8403_ID},
40 {.name = "adn2850", .devid = ADN2850_ID},
41 {.name = "ad5270", .devid = AD5270_ID},
42 {.name = "ad5271", .devid = AD5271_ID},
43 {}
44};
45
46/* ------------------------------------------------------------------------- */
47
48/* SPI bus functions */ 14/* SPI bus functions */
49static int write8(void *client, u8 val) 15static int write8(void *client, u8 val)
50{ 16{
@@ -109,36 +75,16 @@ static const struct ad_dpot_bus_ops bops = {
109 .write_r8d8 = write16, 75 .write_r8d8 = write16,
110 .write_r8d16 = write24, 76 .write_r8d16 = write24,
111}; 77};
112
113static const struct ad_dpot_id *dpot_match_id(const struct ad_dpot_id *id,
114 char *name)
115{
116 while (id->name && id->name[0]) {
117 if (strcmp(name, id->name) == 0)
118 return id;
119 id++;
120 }
121 return NULL;
122}
123
124static int __devinit ad_dpot_spi_probe(struct spi_device *spi) 78static int __devinit ad_dpot_spi_probe(struct spi_device *spi)
125{ 79{
126 char *name = spi->dev.platform_data;
127 const struct ad_dpot_id *dpot_id;
128
129 struct ad_dpot_bus_data bdata = { 80 struct ad_dpot_bus_data bdata = {
130 .client = spi, 81 .client = spi,
131 .bops = &bops, 82 .bops = &bops,
132 }; 83 };
133 84
134 dpot_id = dpot_match_id(ad_dpot_spi_devlist, name); 85 return ad_dpot_probe(&spi->dev, &bdata,
135 86 spi_get_device_id(spi)->driver_data,
136 if (dpot_id == NULL) { 87 spi_get_device_id(spi)->name);
137 dev_err(&spi->dev, "%s not in supported device list", name);
138 return -ENODEV;
139 }
140
141 return ad_dpot_probe(&spi->dev, &bdata, dpot_id);
142} 88}
143 89
144static int __devexit ad_dpot_spi_remove(struct spi_device *spi) 90static int __devexit ad_dpot_spi_remove(struct spi_device *spi)
@@ -146,14 +92,47 @@ static int __devexit ad_dpot_spi_remove(struct spi_device *spi)
146 return ad_dpot_remove(&spi->dev); 92 return ad_dpot_remove(&spi->dev);
147} 93}
148 94
95static const struct spi_device_id ad_dpot_spi_id[] = {
96 {"ad5160", AD5160_ID},
97 {"ad5161", AD5161_ID},
98 {"ad5162", AD5162_ID},
99 {"ad5165", AD5165_ID},
100 {"ad5200", AD5200_ID},
101 {"ad5201", AD5201_ID},
102 {"ad5203", AD5203_ID},
103 {"ad5204", AD5204_ID},
104 {"ad5206", AD5206_ID},
105 {"ad5207", AD5207_ID},
106 {"ad5231", AD5231_ID},
107 {"ad5232", AD5232_ID},
108 {"ad5233", AD5233_ID},
109 {"ad5235", AD5235_ID},
110 {"ad5260", AD5260_ID},
111 {"ad5262", AD5262_ID},
112 {"ad5263", AD5263_ID},
113 {"ad5290", AD5290_ID},
114 {"ad5291", AD5291_ID},
115 {"ad5292", AD5292_ID},
116 {"ad5293", AD5293_ID},
117 {"ad7376", AD7376_ID},
118 {"ad8400", AD8400_ID},
119 {"ad8402", AD8402_ID},
120 {"ad8403", AD8403_ID},
121 {"adn2850", ADN2850_ID},
122 {"ad5270", AD5270_ID},
123 {"ad5271", AD5271_ID},
124 {}
125};
126MODULE_DEVICE_TABLE(spi, ad_dpot_spi_id);
127
149static struct spi_driver ad_dpot_spi_driver = { 128static struct spi_driver ad_dpot_spi_driver = {
150 .driver = { 129 .driver = {
151 .name = "ad_dpot", 130 .name = "ad_dpot",
152 .bus = &spi_bus_type,
153 .owner = THIS_MODULE, 131 .owner = THIS_MODULE,
154 }, 132 },
155 .probe = ad_dpot_spi_probe, 133 .probe = ad_dpot_spi_probe,
156 .remove = __devexit_p(ad_dpot_spi_remove), 134 .remove = __devexit_p(ad_dpot_spi_remove),
135 .id_table = ad_dpot_spi_id,
157}; 136};
158 137
159static int __init ad_dpot_spi_init(void) 138static int __init ad_dpot_spi_init(void)
diff --git a/drivers/misc/ad525x_dpot.c b/drivers/misc/ad525x_dpot.c
index 7cb911028d09..1d1d42615915 100644
--- a/drivers/misc/ad525x_dpot.c
+++ b/drivers/misc/ad525x_dpot.c
@@ -64,7 +64,7 @@
64 * Author: Chris Verges <chrisv@cyberswitching.com> 64 * Author: Chris Verges <chrisv@cyberswitching.com>
65 * 65 *
66 * derived from ad5252.c 66 * derived from ad5252.c
67 * Copyright (c) 2006 Michael Hennerich <hennerich@blackfin.uclinux.org> 67 * Copyright (c) 2006-2011 Michael Hennerich <hennerich@blackfin.uclinux.org>
68 * 68 *
69 * Licensed under the GPL-2 or later. 69 * Licensed under the GPL-2 or later.
70 */ 70 */
@@ -76,8 +76,6 @@
76#include <linux/delay.h> 76#include <linux/delay.h>
77#include <linux/slab.h> 77#include <linux/slab.h>
78 78
79#define DRIVER_VERSION "0.2"
80
81#include "ad525x_dpot.h" 79#include "ad525x_dpot.h"
82 80
83/* 81/*
@@ -687,8 +685,9 @@ inline void ad_dpot_remove_files(struct device *dev,
687 } 685 }
688} 686}
689 687
690__devinit int ad_dpot_probe(struct device *dev, 688int __devinit ad_dpot_probe(struct device *dev,
691 struct ad_dpot_bus_data *bdata, const struct ad_dpot_id *id) 689 struct ad_dpot_bus_data *bdata, unsigned long devid,
690 const char *name)
692{ 691{
693 692
694 struct dpot_data *data; 693 struct dpot_data *data;
@@ -704,13 +703,13 @@ __devinit int ad_dpot_probe(struct device *dev,
704 mutex_init(&data->update_lock); 703 mutex_init(&data->update_lock);
705 704
706 data->bdata = *bdata; 705 data->bdata = *bdata;
707 data->devid = id->devid; 706 data->devid = devid;
708 707
709 data->max_pos = 1 << DPOT_MAX_POS(data->devid); 708 data->max_pos = 1 << DPOT_MAX_POS(devid);
710 data->rdac_mask = data->max_pos - 1; 709 data->rdac_mask = data->max_pos - 1;
711 data->feat = DPOT_FEAT(data->devid); 710 data->feat = DPOT_FEAT(devid);
712 data->uid = DPOT_UID(data->devid); 711 data->uid = DPOT_UID(devid);
713 data->wipers = DPOT_WIPERS(data->devid); 712 data->wipers = DPOT_WIPERS(devid);
714 713
715 for (i = DPOT_RDAC0; i < MAX_RDACS; i++) 714 for (i = DPOT_RDAC0; i < MAX_RDACS; i++)
716 if (data->wipers & (1 << i)) { 715 if (data->wipers & (1 << i)) {
@@ -731,7 +730,7 @@ __devinit int ad_dpot_probe(struct device *dev,
731 } 730 }
732 731
733 dev_info(dev, "%s %d-Position Digital Potentiometer registered\n", 732 dev_info(dev, "%s %d-Position Digital Potentiometer registered\n",
734 id->name, data->max_pos); 733 name, data->max_pos);
735 734
736 return 0; 735 return 0;
737 736
@@ -745,7 +744,7 @@ exit_free:
745 dev_set_drvdata(dev, NULL); 744 dev_set_drvdata(dev, NULL);
746exit: 745exit:
747 dev_err(dev, "failed to create client for %s ID 0x%lX\n", 746 dev_err(dev, "failed to create client for %s ID 0x%lX\n",
748 id->name, id->devid); 747 name, devid);
749 return err; 748 return err;
750} 749}
751EXPORT_SYMBOL(ad_dpot_probe); 750EXPORT_SYMBOL(ad_dpot_probe);
@@ -770,4 +769,3 @@ MODULE_AUTHOR("Chris Verges <chrisv@cyberswitching.com>, "
770 "Michael Hennerich <hennerich@blackfin.uclinux.org>"); 769 "Michael Hennerich <hennerich@blackfin.uclinux.org>");
771MODULE_DESCRIPTION("Digital potentiometer driver"); 770MODULE_DESCRIPTION("Digital potentiometer driver");
772MODULE_LICENSE("GPL"); 771MODULE_LICENSE("GPL");
773MODULE_VERSION(DRIVER_VERSION);
diff --git a/drivers/misc/ad525x_dpot.h b/drivers/misc/ad525x_dpot.h
index 82b2cb77ae19..6bd1eba23bc0 100644
--- a/drivers/misc/ad525x_dpot.h
+++ b/drivers/misc/ad525x_dpot.h
@@ -208,12 +208,8 @@ struct ad_dpot_bus_data {
208 const struct ad_dpot_bus_ops *bops; 208 const struct ad_dpot_bus_ops *bops;
209}; 209};
210 210
211struct ad_dpot_id { 211int ad_dpot_probe(struct device *dev, struct ad_dpot_bus_data *bdata,
212 char *name; 212 unsigned long devid, const char *name);
213 unsigned long devid;
214};
215
216int ad_dpot_probe(struct device *dev, struct ad_dpot_bus_data *bdata, const struct ad_dpot_id *id);
217int ad_dpot_remove(struct device *dev); 213int ad_dpot_remove(struct device *dev);
218 214
219#endif 215#endif
diff --git a/drivers/misc/bmp085.c b/drivers/misc/bmp085.c
index 5f898cb706a6..b29a2be24591 100644
--- a/drivers/misc/bmp085.c
+++ b/drivers/misc/bmp085.c
@@ -216,7 +216,7 @@ static s32 bmp085_get_temperature(struct bmp085_data *data, int *temperature)
216 *temperature = (x1+x2+8) >> 4; 216 *temperature = (x1+x2+8) >> 4;
217 217
218exit: 218exit:
219 return status;; 219 return status;
220} 220}
221 221
222/* 222/*
diff --git a/drivers/misc/isl29020.c b/drivers/misc/isl29020.c
index 307aada5fffe..3d6cce663bea 100644
--- a/drivers/misc/isl29020.c
+++ b/drivers/misc/isl29020.c
@@ -158,7 +158,7 @@ static int als_set_default_config(struct i2c_client *client)
158 dev_err(&client->dev, "default write failed."); 158 dev_err(&client->dev, "default write failed.");
159 return retval; 159 return retval;
160 } 160 }
161 return 0;; 161 return 0;
162} 162}
163 163
164static int isl29020_probe(struct i2c_client *client, 164static int isl29020_probe(struct i2c_client *client,
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
index ba168a7d54d4..2b62232c2c6a 100644
--- a/drivers/misc/ti-st/st_core.c
+++ b/drivers/misc/ti-st/st_core.c
@@ -137,6 +137,8 @@ void st_send_frame(unsigned char chnl_id, struct st_data_s *st_gdata)
137 * st_reg_complete - 137 * st_reg_complete -
138 * to call registration complete callbacks 138 * to call registration complete callbacks
139 * of all protocol stack drivers 139 * of all protocol stack drivers
140 * This function is being called with spin lock held, protocol drivers are
141 * only expected to complete their waits and do nothing more than that.
140 */ 142 */
141void st_reg_complete(struct st_data_s *st_gdata, char err) 143void st_reg_complete(struct st_data_s *st_gdata, char err)
142{ 144{
@@ -538,11 +540,12 @@ long st_register(struct st_proto_s *new_proto)
538 set_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); 540 set_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
539 st_recv = st_kim_recv; 541 st_recv = st_kim_recv;
540 542
543 /* enable the ST LL - to set default chip state */
544 st_ll_enable(st_gdata);
545
541 /* release lock previously held - re-locked below */ 546 /* release lock previously held - re-locked below */
542 spin_unlock_irqrestore(&st_gdata->lock, flags); 547 spin_unlock_irqrestore(&st_gdata->lock, flags);
543 548
544 /* enable the ST LL - to set default chip state */
545 st_ll_enable(st_gdata);
546 /* this may take a while to complete 549 /* this may take a while to complete
547 * since it involves BT fw download 550 * since it involves BT fw download
548 */ 551 */
@@ -553,10 +556,13 @@ long st_register(struct st_proto_s *new_proto)
553 (test_bit(ST_REG_PENDING, &st_gdata->st_state))) { 556 (test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
554 pr_err(" KIM failure complete callback "); 557 pr_err(" KIM failure complete callback ");
555 st_reg_complete(st_gdata, err); 558 st_reg_complete(st_gdata, err);
559 clear_bit(ST_REG_PENDING, &st_gdata->st_state);
556 } 560 }
557 return -EINVAL; 561 return -EINVAL;
558 } 562 }
559 563
564 spin_lock_irqsave(&st_gdata->lock, flags);
565
560 clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); 566 clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
561 st_recv = st_int_recv; 567 st_recv = st_int_recv;
562 568
@@ -576,10 +582,10 @@ long st_register(struct st_proto_s *new_proto)
576 if (st_gdata->is_registered[new_proto->chnl_id] == true) { 582 if (st_gdata->is_registered[new_proto->chnl_id] == true) {
577 pr_err(" proto %d already registered ", 583 pr_err(" proto %d already registered ",
578 new_proto->chnl_id); 584 new_proto->chnl_id);
585 spin_unlock_irqrestore(&st_gdata->lock, flags);
579 return -EALREADY; 586 return -EALREADY;
580 } 587 }
581 588
582 spin_lock_irqsave(&st_gdata->lock, flags);
583 add_channel_to_table(st_gdata, new_proto); 589 add_channel_to_table(st_gdata, new_proto);
584 st_gdata->protos_registered++; 590 st_gdata->protos_registered++;
585 new_proto->write = st_write; 591 new_proto->write = st_write;
@@ -619,7 +625,7 @@ long st_unregister(struct st_proto_s *proto)
619 625
620 spin_lock_irqsave(&st_gdata->lock, flags); 626 spin_lock_irqsave(&st_gdata->lock, flags);
621 627
622 if (st_gdata->list[proto->chnl_id] == NULL) { 628 if (st_gdata->is_registered[proto->chnl_id] == false) {
623 pr_err(" chnl_id %d not registered", proto->chnl_id); 629 pr_err(" chnl_id %d not registered", proto->chnl_id);
624 spin_unlock_irqrestore(&st_gdata->lock, flags); 630 spin_unlock_irqrestore(&st_gdata->lock, flags);
625 return -EPROTONOSUPPORT; 631 return -EPROTONOSUPPORT;
@@ -629,6 +635,10 @@ long st_unregister(struct st_proto_s *proto)
629 remove_channel_from_table(st_gdata, proto); 635 remove_channel_from_table(st_gdata, proto);
630 spin_unlock_irqrestore(&st_gdata->lock, flags); 636 spin_unlock_irqrestore(&st_gdata->lock, flags);
631 637
638 /* paranoid check */
639 if (st_gdata->protos_registered < ST_EMPTY)
640 st_gdata->protos_registered = ST_EMPTY;
641
632 if ((st_gdata->protos_registered == ST_EMPTY) && 642 if ((st_gdata->protos_registered == ST_EMPTY) &&
633 (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) { 643 (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
634 pr_info(" all chnl_ids unregistered "); 644 pr_info(" all chnl_ids unregistered ");
diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
index 43ef8d162f2d..a7a861ceee2d 100644
--- a/drivers/misc/ti-st/st_kim.c
+++ b/drivers/misc/ti-st/st_kim.c
@@ -469,37 +469,21 @@ long st_kim_start(void *kim_data)
469 /* wait for ldisc to be installed */ 469 /* wait for ldisc to be installed */
470 err = wait_for_completion_timeout(&kim_gdata->ldisc_installed, 470 err = wait_for_completion_timeout(&kim_gdata->ldisc_installed,
471 msecs_to_jiffies(LDISC_TIME)); 471 msecs_to_jiffies(LDISC_TIME));
472 if (!err) { /* timeout */ 472 if (!err) {
473 pr_err("line disc installation timed out "); 473 /* ldisc installation timeout,
474 kim_gdata->ldisc_install = 0; 474 * flush uart, power cycle BT_EN */
475 pr_info("ldisc_install = 0"); 475 pr_err("ldisc installation timeout");
476 sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, 476 err = st_kim_stop(kim_gdata);
477 NULL, "install");
478 /* the following wait is never going to be completed,
479 * since the ldisc was never installed, hence serving
480 * as a mdelay of LDISC_TIME msecs */
481 err = wait_for_completion_timeout
482 (&kim_gdata->ldisc_installed,
483 msecs_to_jiffies(LDISC_TIME));
484 err = -ETIMEDOUT;
485 continue; 477 continue;
486 } else { 478 } else {
487 /* ldisc installed now */ 479 /* ldisc installed now */
488 pr_info(" line discipline installed "); 480 pr_info("line discipline installed");
489 err = download_firmware(kim_gdata); 481 err = download_firmware(kim_gdata);
490 if (err != 0) { 482 if (err != 0) {
483 /* ldisc installed but fw download failed,
484 * flush uart & power cycle BT_EN */
491 pr_err("download firmware failed"); 485 pr_err("download firmware failed");
492 kim_gdata->ldisc_install = 0; 486 err = st_kim_stop(kim_gdata);
493 pr_info("ldisc_install = 0");
494 sysfs_notify(&kim_gdata->kim_pdev->dev.kobj,
495 NULL, "install");
496 /* this wait might be completed, though in the
497 * tty_close() since the ldisc is already
498 * installed */
499 err = wait_for_completion_timeout
500 (&kim_gdata->ldisc_installed,
501 msecs_to_jiffies(LDISC_TIME));
502 err = -EINVAL;
503 continue; 487 continue;
504 } else { /* on success don't retry */ 488 } else { /* on success don't retry */
505 break; 489 break;
@@ -510,8 +494,14 @@ long st_kim_start(void *kim_data)
510} 494}
511 495
512/** 496/**
513 * st_kim_stop - called from ST Core, on the last un-registration 497 * st_kim_stop - stop communication with chip.
514 * toggle low the chip enable gpio 498 * This can be called from ST Core/KIM, on the-
499 * (a) last un-register when chip need not be powered there-after,
500 * (b) upon failure to either install ldisc or download firmware.
501 * The function is responsible to (a) notify UIM about un-installation,
502 * (b) flush UART if the ldisc was installed.
503 * (c) reset BT_EN - pull down nshutdown at the end.
504 * (d) invoke platform's chip disabling routine.
515 */ 505 */
516long st_kim_stop(void *kim_data) 506long st_kim_stop(void *kim_data)
517{ 507{
@@ -519,12 +509,16 @@ long st_kim_stop(void *kim_data)
519 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data; 509 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;
520 struct ti_st_plat_data *pdata = 510 struct ti_st_plat_data *pdata =
521 kim_gdata->kim_pdev->dev.platform_data; 511 kim_gdata->kim_pdev->dev.platform_data;
512 struct tty_struct *tty = kim_gdata->core_data->tty;
522 513
523 INIT_COMPLETION(kim_gdata->ldisc_installed); 514 INIT_COMPLETION(kim_gdata->ldisc_installed);
524 515
525 /* Flush any pending characters in the driver and discipline. */ 516 if (tty) { /* can be called before ldisc is installed */
526 tty_ldisc_flush(kim_gdata->core_data->tty); 517 /* Flush any pending characters in the driver and discipline. */
527 tty_driver_flush_buffer(kim_gdata->core_data->tty); 518 tty_ldisc_flush(tty);
519 tty_driver_flush_buffer(tty);
520 tty->ops->flush_buffer(tty);
521 }
528 522
529 /* send uninstall notification to UIM */ 523 /* send uninstall notification to UIM */
530 pr_info("ldisc_install = 0"); 524 pr_info("ldisc_install = 0");
@@ -579,6 +573,28 @@ static ssize_t show_install(struct device *dev,
579 return sprintf(buf, "%d\n", kim_data->ldisc_install); 573 return sprintf(buf, "%d\n", kim_data->ldisc_install);
580} 574}
581 575
576#ifdef DEBUG
577static ssize_t store_dev_name(struct device *dev,
578 struct device_attribute *attr, const char *buf, size_t count)
579{
580 struct kim_data_s *kim_data = dev_get_drvdata(dev);
581 pr_debug("storing dev name >%s<", buf);
582 strncpy(kim_data->dev_name, buf, count);
583 pr_debug("stored dev name >%s<", kim_data->dev_name);
584 return count;
585}
586
587static ssize_t store_baud_rate(struct device *dev,
588 struct device_attribute *attr, const char *buf, size_t count)
589{
590 struct kim_data_s *kim_data = dev_get_drvdata(dev);
591 pr_debug("storing baud rate >%s<", buf);
592 sscanf(buf, "%ld", &kim_data->baud_rate);
593 pr_debug("stored baud rate >%ld<", kim_data->baud_rate);
594 return count;
595}
596#endif /* if DEBUG */
597
582static ssize_t show_dev_name(struct device *dev, 598static ssize_t show_dev_name(struct device *dev,
583 struct device_attribute *attr, char *buf) 599 struct device_attribute *attr, char *buf)
584{ 600{
@@ -605,10 +621,18 @@ static struct kobj_attribute ldisc_install =
605__ATTR(install, 0444, (void *)show_install, NULL); 621__ATTR(install, 0444, (void *)show_install, NULL);
606 622
607static struct kobj_attribute uart_dev_name = 623static struct kobj_attribute uart_dev_name =
624#ifdef DEBUG /* TODO: move this to debug-fs if possible */
625__ATTR(dev_name, 0644, (void *)show_dev_name, (void *)store_dev_name);
626#else
608__ATTR(dev_name, 0444, (void *)show_dev_name, NULL); 627__ATTR(dev_name, 0444, (void *)show_dev_name, NULL);
628#endif
609 629
610static struct kobj_attribute uart_baud_rate = 630static struct kobj_attribute uart_baud_rate =
631#ifdef DEBUG /* TODO: move to debugfs */
632__ATTR(baud_rate, 0644, (void *)show_baud_rate, (void *)store_baud_rate);
633#else
611__ATTR(baud_rate, 0444, (void *)show_baud_rate, NULL); 634__ATTR(baud_rate, 0444, (void *)show_baud_rate, NULL);
635#endif
612 636
613static struct kobj_attribute uart_flow_cntrl = 637static struct kobj_attribute uart_flow_cntrl =
614__ATTR(flow_cntrl, 0444, (void *)show_flow_cntrl, NULL); 638__ATTR(flow_cntrl, 0444, (void *)show_flow_cntrl, NULL);