aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-07-02 14:43:33 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-02 14:43:33 -0400
commitfe3c22bd5cadd8e36977b218b27fbea821381ec8 (patch)
treecc4d4479a077c0db22e5de40d181ad6963fc3993 /drivers/misc
parentce49b6289fa3878b190f15192e54bb23dca552b6 (diff)
parent380672698b8e64f0b5e418412b1ed370bd366428 (diff)
Merge tag 'char-misc-3.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc updates from Greg KH: "Here's the big char/misc driver tree merge for 3.11-rc1 A variety of different driver patches here. All of these have been in linux-next for a while, and the networking patches were acked-by David Miller, as it made sense for those patches to come through this tree" * tag 'char-misc-3.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (102 commits) Revert "char: misc: assign file->private_data in all cases" drivers: uio_pdrv_genirq: Use of_match_ptr() macro mei: check whether hw start has succeeded mei: check if the hardware reset succeeded mei: mei_cl_connect: don't multiply the timeout twice mei: do not override a client writing state when buffering mei: move mei_cl_irq_write_complete to client.c UIO: Fix concurrency issue drivers: uio_dmem_genirq: Use of_match_ptr() macro char: misc: assign file->private_data in all cases drivers: hv: allocate synic structures before hv_synic_init() drivers: hv: check interrupt mask before read_index vme: vme_tsi148.c: fix error return code in tsi148_probe() FMC: fix error handling in probe() function fmc: avoid readl/writel namespace conflict FMC: NULL dereference on allocation failure UIO: fix uio_pdrv_genirq with device tree but no interrupt UIO: allow binding uio_pdrv_genirq.c to devices using command line option FMC: add a char-device mezzanine driver FMC: add a driver to write mezzanine EEPROM ...
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/Kconfig1
-rw-r--r--drivers/misc/ad525x_dpot.c2
-rw-r--r--drivers/misc/apds9802als.c5
-rw-r--r--drivers/misc/apds990x.c37
-rw-r--r--drivers/misc/arm-charlcd.c5
-rw-r--r--drivers/misc/bh1770glc.c59
-rw-r--r--drivers/misc/bh1780gli.c2
-rw-r--r--drivers/misc/carma/carma-fpga-program.c14
-rw-r--r--drivers/misc/carma/carma-fpga.c8
-rw-r--r--drivers/misc/eeprom/at24.c44
-rw-r--r--drivers/misc/eeprom/at25.c25
-rw-r--r--drivers/misc/ep93xx_pwm.c188
-rw-r--r--drivers/misc/hmc6352.c5
-rw-r--r--drivers/misc/isl29003.c24
-rw-r--r--drivers/misc/isl29020.c6
-rw-r--r--drivers/misc/lis3lv02d/lis3lv02d.c6
-rw-r--r--drivers/misc/mei/amthif.c6
-rw-r--r--drivers/misc/mei/client.c92
-rw-r--r--drivers/misc/mei/client.h4
-rw-r--r--drivers/misc/mei/hbm.c37
-rw-r--r--drivers/misc/mei/hbm.h2
-rw-r--r--drivers/misc/mei/hw-me.c3
-rw-r--r--drivers/misc/mei/init.c18
-rw-r--r--drivers/misc/mei/interrupt.c205
-rw-r--r--drivers/misc/mei/main.c49
-rw-r--r--drivers/misc/mei/mei_dev.h29
-rw-r--r--drivers/misc/mei/pci-me.c19
-rw-r--r--drivers/misc/mei/wd.c6
-rw-r--r--drivers/misc/pch_phub.c44
-rw-r--r--drivers/misc/sgi-gru/gruprocfs.c14
-rw-r--r--drivers/misc/spear13xx_pcie_gadget.c69
-rw-r--r--drivers/misc/sram.c9
-rw-r--r--drivers/misc/ti-st/st_kim.c6
-rw-r--r--drivers/misc/ti_dac7512.c6
-rw-r--r--drivers/misc/tsl2550.c4
35 files changed, 491 insertions, 562 deletions
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index c002d8660e30..80889d5f95f5 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -480,6 +480,7 @@ config BMP085_SPI
480 480
481config PCH_PHUB 481config PCH_PHUB
482 tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) PHUB" 482 tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) PHUB"
483 select GENERIC_NET_UTILS
483 depends on PCI 484 depends on PCI
484 help 485 help
485 This driver is for PCH(Platform controller Hub) PHUB(Packet Hub) of 486 This driver is for PCH(Platform controller Hub) PHUB(Packet Hub) of
diff --git a/drivers/misc/ad525x_dpot.c b/drivers/misc/ad525x_dpot.c
index 8f99e8e3f0ac..0daadcf1ed7a 100644
--- a/drivers/misc/ad525x_dpot.c
+++ b/drivers/misc/ad525x_dpot.c
@@ -470,7 +470,7 @@ static ssize_t sysfs_set_reg(struct device *dev,
470 !test_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask)) 470 !test_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask))
471 return -EPERM; 471 return -EPERM;
472 472
473 err = strict_strtoul(buf, 10, &value); 473 err = kstrtoul(buf, 10, &value);
474 if (err) 474 if (err)
475 return err; 475 return err;
476 476
diff --git a/drivers/misc/apds9802als.c b/drivers/misc/apds9802als.c
index 5b5fd8416b3e..0c6e037153d2 100644
--- a/drivers/misc/apds9802als.c
+++ b/drivers/misc/apds9802als.c
@@ -126,8 +126,9 @@ static ssize_t als_sensing_range_store(struct device *dev,
126 int ret_val; 126 int ret_val;
127 unsigned long val; 127 unsigned long val;
128 128
129 if (strict_strtoul(buf, 10, &val)) 129 ret_val = kstrtoul(buf, 10, &val);
130 return -EINVAL; 130 if (ret_val)
131 return ret_val;
131 132
132 if (val < 4096) 133 if (val < 4096)
133 val = 1; 134 val = 1;
diff --git a/drivers/misc/apds990x.c b/drivers/misc/apds990x.c
index 98f9bb26492a..868a30a1b417 100644
--- a/drivers/misc/apds990x.c
+++ b/drivers/misc/apds990x.c
@@ -696,9 +696,11 @@ static ssize_t apds990x_lux_calib_store(struct device *dev,
696{ 696{
697 struct apds990x_chip *chip = dev_get_drvdata(dev); 697 struct apds990x_chip *chip = dev_get_drvdata(dev);
698 unsigned long value; 698 unsigned long value;
699 int ret;
699 700
700 if (strict_strtoul(buf, 0, &value)) 701 ret = kstrtoul(buf, 0, &value);
701 return -EINVAL; 702 if (ret)
703 return ret;
702 704
703 chip->lux_calib = value; 705 chip->lux_calib = value;
704 706
@@ -759,8 +761,9 @@ static ssize_t apds990x_rate_store(struct device *dev,
759 unsigned long value; 761 unsigned long value;
760 int ret; 762 int ret;
761 763
762 if (strict_strtoul(buf, 0, &value)) 764 ret = kstrtoul(buf, 0, &value);
763 return -EINVAL; 765 if (ret)
766 return ret;
764 767
765 mutex_lock(&chip->mutex); 768 mutex_lock(&chip->mutex);
766 ret = apds990x_set_arate(chip, value); 769 ret = apds990x_set_arate(chip, value);
@@ -813,9 +816,11 @@ static ssize_t apds990x_prox_enable_store(struct device *dev,
813{ 816{
814 struct apds990x_chip *chip = dev_get_drvdata(dev); 817 struct apds990x_chip *chip = dev_get_drvdata(dev);
815 unsigned long value; 818 unsigned long value;
819 int ret;
816 820
817 if (strict_strtoul(buf, 0, &value)) 821 ret = kstrtoul(buf, 0, &value);
818 return -EINVAL; 822 if (ret)
823 return ret;
819 824
820 mutex_lock(&chip->mutex); 825 mutex_lock(&chip->mutex);
821 826
@@ -892,11 +897,12 @@ static ssize_t apds990x_lux_thresh_below_show(struct device *dev,
892static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target, 897static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target,
893 const char *buf) 898 const char *buf)
894{ 899{
895 int ret = 0;
896 unsigned long thresh; 900 unsigned long thresh;
901 int ret;
897 902
898 if (strict_strtoul(buf, 0, &thresh)) 903 ret = kstrtoul(buf, 0, &thresh);
899 return -EINVAL; 904 if (ret)
905 return ret;
900 906
901 if (thresh > APDS_RANGE) 907 if (thresh > APDS_RANGE)
902 return -EINVAL; 908 return -EINVAL;
@@ -957,9 +963,11 @@ static ssize_t apds990x_prox_threshold_store(struct device *dev,
957{ 963{
958 struct apds990x_chip *chip = dev_get_drvdata(dev); 964 struct apds990x_chip *chip = dev_get_drvdata(dev);
959 unsigned long value; 965 unsigned long value;
966 int ret;
960 967
961 if (strict_strtoul(buf, 0, &value)) 968 ret = kstrtoul(buf, 0, &value);
962 return -EINVAL; 969 if (ret)
970 return ret;
963 971
964 if ((value > APDS_RANGE) || (value == 0) || 972 if ((value > APDS_RANGE) || (value == 0) ||
965 (value < APDS_PROX_HYSTERESIS)) 973 (value < APDS_PROX_HYSTERESIS))
@@ -990,9 +998,12 @@ static ssize_t apds990x_power_state_store(struct device *dev,
990{ 998{
991 struct apds990x_chip *chip = dev_get_drvdata(dev); 999 struct apds990x_chip *chip = dev_get_drvdata(dev);
992 unsigned long value; 1000 unsigned long value;
1001 int ret;
1002
1003 ret = kstrtoul(buf, 0, &value);
1004 if (ret)
1005 return ret;
993 1006
994 if (strict_strtoul(buf, 0, &value))
995 return -EINVAL;
996 if (value) { 1007 if (value) {
997 pm_runtime_get_sync(dev); 1008 pm_runtime_get_sync(dev);
998 mutex_lock(&chip->mutex); 1009 mutex_lock(&chip->mutex);
diff --git a/drivers/misc/arm-charlcd.c b/drivers/misc/arm-charlcd.c
index 48651ef0028c..1256a4bf1c04 100644
--- a/drivers/misc/arm-charlcd.c
+++ b/drivers/misc/arm-charlcd.c
@@ -291,7 +291,7 @@ static int __init charlcd_probe(struct platform_device *pdev)
291 lcd->virtbase = ioremap(lcd->phybase, lcd->physize); 291 lcd->virtbase = ioremap(lcd->phybase, lcd->physize);
292 if (!lcd->virtbase) { 292 if (!lcd->virtbase) {
293 ret = -ENOMEM; 293 ret = -ENOMEM;
294 goto out_no_remap; 294 goto out_no_memregion;
295 } 295 }
296 296
297 lcd->irq = platform_get_irq(pdev, 0); 297 lcd->irq = platform_get_irq(pdev, 0);
@@ -320,8 +320,6 @@ static int __init charlcd_probe(struct platform_device *pdev)
320 320
321out_no_irq: 321out_no_irq:
322 iounmap(lcd->virtbase); 322 iounmap(lcd->virtbase);
323out_no_remap:
324 platform_set_drvdata(pdev, NULL);
325out_no_memregion: 323out_no_memregion:
326 release_mem_region(lcd->phybase, SZ_4K); 324 release_mem_region(lcd->phybase, SZ_4K);
327out_no_resource: 325out_no_resource:
@@ -337,7 +335,6 @@ static int __exit charlcd_remove(struct platform_device *pdev)
337 free_irq(lcd->irq, lcd); 335 free_irq(lcd->irq, lcd);
338 iounmap(lcd->virtbase); 336 iounmap(lcd->virtbase);
339 release_mem_region(lcd->phybase, lcd->physize); 337 release_mem_region(lcd->phybase, lcd->physize);
340 platform_set_drvdata(pdev, NULL);
341 kfree(lcd); 338 kfree(lcd);
342 } 339 }
343 340
diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c
index f4975f7d0d5b..99a04686e45f 100644
--- a/drivers/misc/bh1770glc.c
+++ b/drivers/misc/bh1770glc.c
@@ -651,8 +651,9 @@ static ssize_t bh1770_power_state_store(struct device *dev,
651 unsigned long value; 651 unsigned long value;
652 ssize_t ret; 652 ssize_t ret;
653 653
654 if (strict_strtoul(buf, 0, &value)) 654 ret = kstrtoul(buf, 0, &value);
655 return -EINVAL; 655 if (ret)
656 return ret;
656 657
657 mutex_lock(&chip->mutex); 658 mutex_lock(&chip->mutex);
658 if (value) { 659 if (value) {
@@ -726,9 +727,11 @@ static ssize_t bh1770_prox_enable_store(struct device *dev,
726{ 727{
727 struct bh1770_chip *chip = dev_get_drvdata(dev); 728 struct bh1770_chip *chip = dev_get_drvdata(dev);
728 unsigned long value; 729 unsigned long value;
730 int ret;
729 731
730 if (strict_strtoul(buf, 0, &value)) 732 ret = kstrtoul(buf, 0, &value);
731 return -EINVAL; 733 if (ret)
734 return ret;
732 735
733 mutex_lock(&chip->mutex); 736 mutex_lock(&chip->mutex);
734 /* Assume no proximity. Sensor will tell real state soon */ 737 /* Assume no proximity. Sensor will tell real state soon */
@@ -824,9 +827,11 @@ static ssize_t bh1770_set_prox_rate_above(struct device *dev,
824{ 827{
825 struct bh1770_chip *chip = dev_get_drvdata(dev); 828 struct bh1770_chip *chip = dev_get_drvdata(dev);
826 unsigned long value; 829 unsigned long value;
830 int ret;
827 831
828 if (strict_strtoul(buf, 0, &value)) 832 ret = kstrtoul(buf, 0, &value);
829 return -EINVAL; 833 if (ret)
834 return ret;
830 835
831 mutex_lock(&chip->mutex); 836 mutex_lock(&chip->mutex);
832 chip->prox_rate_threshold = bh1770_prox_rate_validate(value); 837 chip->prox_rate_threshold = bh1770_prox_rate_validate(value);
@@ -840,9 +845,11 @@ static ssize_t bh1770_set_prox_rate_below(struct device *dev,
840{ 845{
841 struct bh1770_chip *chip = dev_get_drvdata(dev); 846 struct bh1770_chip *chip = dev_get_drvdata(dev);
842 unsigned long value; 847 unsigned long value;
848 int ret;
843 849
844 if (strict_strtoul(buf, 0, &value)) 850 ret = kstrtoul(buf, 0, &value);
845 return -EINVAL; 851 if (ret)
852 return ret;
846 853
847 mutex_lock(&chip->mutex); 854 mutex_lock(&chip->mutex);
848 chip->prox_rate = bh1770_prox_rate_validate(value); 855 chip->prox_rate = bh1770_prox_rate_validate(value);
@@ -865,8 +872,10 @@ static ssize_t bh1770_set_prox_thres(struct device *dev,
865 unsigned long value; 872 unsigned long value;
866 int ret; 873 int ret;
867 874
868 if (strict_strtoul(buf, 0, &value)) 875 ret = kstrtoul(buf, 0, &value);
869 return -EINVAL; 876 if (ret)
877 return ret;
878
870 if (value > BH1770_PROX_RANGE) 879 if (value > BH1770_PROX_RANGE)
871 return -EINVAL; 880 return -EINVAL;
872 881
@@ -893,9 +902,11 @@ static ssize_t bh1770_prox_persistence_store(struct device *dev,
893{ 902{
894 struct bh1770_chip *chip = dev_get_drvdata(dev); 903 struct bh1770_chip *chip = dev_get_drvdata(dev);
895 unsigned long value; 904 unsigned long value;
905 int ret;
896 906
897 if (strict_strtoul(buf, 0, &value)) 907 ret = kstrtoul(buf, 0, &value);
898 return -EINVAL; 908 if (ret)
909 return ret;
899 910
900 if (value > BH1770_PROX_MAX_PERSISTENCE) 911 if (value > BH1770_PROX_MAX_PERSISTENCE)
901 return -EINVAL; 912 return -EINVAL;
@@ -918,9 +929,11 @@ static ssize_t bh1770_prox_abs_thres_store(struct device *dev,
918{ 929{
919 struct bh1770_chip *chip = dev_get_drvdata(dev); 930 struct bh1770_chip *chip = dev_get_drvdata(dev);
920 unsigned long value; 931 unsigned long value;
932 int ret;
921 933
922 if (strict_strtoul(buf, 0, &value)) 934 ret = kstrtoul(buf, 0, &value);
923 return -EINVAL; 935 if (ret)
936 return ret;
924 937
925 if (value > BH1770_PROX_RANGE) 938 if (value > BH1770_PROX_RANGE)
926 return -EINVAL; 939 return -EINVAL;
@@ -963,9 +976,11 @@ static ssize_t bh1770_lux_calib_store(struct device *dev,
963 unsigned long value; 976 unsigned long value;
964 u32 old_calib; 977 u32 old_calib;
965 u32 new_corr; 978 u32 new_corr;
979 int ret;
966 980
967 if (strict_strtoul(buf, 0, &value)) 981 ret = kstrtoul(buf, 0, &value);
968 return -EINVAL; 982 if (ret)
983 return ret;
969 984
970 mutex_lock(&chip->mutex); 985 mutex_lock(&chip->mutex);
971 old_calib = chip->lux_calib; 986 old_calib = chip->lux_calib;
@@ -1012,8 +1027,9 @@ static ssize_t bh1770_set_lux_rate(struct device *dev,
1012 unsigned long rate_hz; 1027 unsigned long rate_hz;
1013 int ret, i; 1028 int ret, i;
1014 1029
1015 if (strict_strtoul(buf, 0, &rate_hz)) 1030 ret = kstrtoul(buf, 0, &rate_hz);
1016 return -EINVAL; 1031 if (ret)
1032 return ret;
1017 1033
1018 for (i = 0; i < ARRAY_SIZE(lux_rates_hz) - 1; i++) 1034 for (i = 0; i < ARRAY_SIZE(lux_rates_hz) - 1; i++)
1019 if (rate_hz >= lux_rates_hz[i]) 1035 if (rate_hz >= lux_rates_hz[i])
@@ -1047,11 +1063,12 @@ static ssize_t bh1770_get_lux_thresh_below(struct device *dev,
1047static ssize_t bh1770_set_lux_thresh(struct bh1770_chip *chip, u16 *target, 1063static ssize_t bh1770_set_lux_thresh(struct bh1770_chip *chip, u16 *target,
1048 const char *buf) 1064 const char *buf)
1049{ 1065{
1050 int ret = 0;
1051 unsigned long thresh; 1066 unsigned long thresh;
1067 int ret;
1052 1068
1053 if (strict_strtoul(buf, 0, &thresh)) 1069 ret = kstrtoul(buf, 0, &thresh);
1054 return -EINVAL; 1070 if (ret)
1071 return ret;
1055 1072
1056 if (thresh > BH1770_LUX_RANGE) 1073 if (thresh > BH1770_LUX_RANGE)
1057 return -EINVAL; 1074 return -EINVAL;
diff --git a/drivers/misc/bh1780gli.c b/drivers/misc/bh1780gli.c
index 818f3a0e62bf..057580e026c0 100644
--- a/drivers/misc/bh1780gli.c
+++ b/drivers/misc/bh1780gli.c
@@ -107,7 +107,7 @@ static ssize_t bh1780_store_power_state(struct device *dev,
107 unsigned long val; 107 unsigned long val;
108 int error; 108 int error;
109 109
110 error = strict_strtoul(buf, 0, &val); 110 error = kstrtoul(buf, 0, &val);
111 if (error) 111 if (error)
112 return error; 112 return error;
113 113
diff --git a/drivers/misc/carma/carma-fpga-program.c b/drivers/misc/carma/carma-fpga-program.c
index 736c7714f565..c6bd7e84de24 100644
--- a/drivers/misc/carma/carma-fpga-program.c
+++ b/drivers/misc/carma/carma-fpga-program.c
@@ -830,8 +830,9 @@ static ssize_t penable_store(struct device *dev, struct device_attribute *attr,
830 unsigned long val; 830 unsigned long val;
831 int ret; 831 int ret;
832 832
833 if (strict_strtoul(buf, 0, &val)) 833 ret = kstrtoul(buf, 0, &val);
834 return -EINVAL; 834 if (ret)
835 return ret;
835 836
836 if (val) { 837 if (val) {
837 ret = fpga_enable_power_supplies(priv); 838 ret = fpga_enable_power_supplies(priv);
@@ -859,8 +860,9 @@ static ssize_t program_store(struct device *dev, struct device_attribute *attr,
859 unsigned long val; 860 unsigned long val;
860 int ret; 861 int ret;
861 862
862 if (strict_strtoul(buf, 0, &val)) 863 ret = kstrtoul(buf, 0, &val);
863 return -EINVAL; 864 if (ret)
865 return ret;
864 866
865 /* We can't have an image writer and be programming simultaneously */ 867 /* We can't have an image writer and be programming simultaneously */
866 if (mutex_lock_interruptible(&priv->lock)) 868 if (mutex_lock_interruptible(&priv->lock))
@@ -919,7 +921,7 @@ static bool dma_filter(struct dma_chan *chan, void *data)
919 921
920static int fpga_of_remove(struct platform_device *op) 922static int fpga_of_remove(struct platform_device *op)
921{ 923{
922 struct fpga_dev *priv = dev_get_drvdata(&op->dev); 924 struct fpga_dev *priv = platform_get_drvdata(op);
923 struct device *this_device = priv->miscdev.this_device; 925 struct device *this_device = priv->miscdev.this_device;
924 926
925 sysfs_remove_group(&this_device->kobj, &fpga_attr_group); 927 sysfs_remove_group(&this_device->kobj, &fpga_attr_group);
@@ -969,7 +971,7 @@ static int fpga_of_probe(struct platform_device *op)
969 971
970 kref_init(&priv->ref); 972 kref_init(&priv->ref);
971 973
972 dev_set_drvdata(&op->dev, priv); 974 platform_set_drvdata(op, priv);
973 priv->dev = &op->dev; 975 priv->dev = &op->dev;
974 mutex_init(&priv->lock); 976 mutex_init(&priv->lock);
975 init_completion(&priv->completion); 977 init_completion(&priv->completion);
diff --git a/drivers/misc/carma/carma-fpga.c b/drivers/misc/carma/carma-fpga.c
index 7508cafff103..7b56563f8b74 100644
--- a/drivers/misc/carma/carma-fpga.c
+++ b/drivers/misc/carma/carma-fpga.c
@@ -1002,10 +1002,10 @@ static ssize_t data_en_set(struct device *dev, struct device_attribute *attr,
1002 unsigned long enable; 1002 unsigned long enable;
1003 int ret; 1003 int ret;
1004 1004
1005 ret = strict_strtoul(buf, 0, &enable); 1005 ret = kstrtoul(buf, 0, &enable);
1006 if (ret) { 1006 if (ret) {
1007 dev_err(priv->dev, "unable to parse enable input\n"); 1007 dev_err(priv->dev, "unable to parse enable input\n");
1008 return -EINVAL; 1008 return ret;
1009 } 1009 }
1010 1010
1011 /* protect against concurrent enable/disable */ 1011 /* protect against concurrent enable/disable */
@@ -1296,7 +1296,7 @@ static int data_of_probe(struct platform_device *op)
1296 goto out_return; 1296 goto out_return;
1297 } 1297 }
1298 1298
1299 dev_set_drvdata(&op->dev, priv); 1299 platform_set_drvdata(op, priv);
1300 priv->dev = &op->dev; 1300 priv->dev = &op->dev;
1301 kref_init(&priv->ref); 1301 kref_init(&priv->ref);
1302 mutex_init(&priv->mutex); 1302 mutex_init(&priv->mutex);
@@ -1400,7 +1400,7 @@ out_return:
1400 1400
1401static int data_of_remove(struct platform_device *op) 1401static int data_of_remove(struct platform_device *op)
1402{ 1402{
1403 struct fpga_device *priv = dev_get_drvdata(&op->dev); 1403 struct fpga_device *priv = platform_get_drvdata(op);
1404 struct device *this_device = priv->miscdev.this_device; 1404 struct device *this_device = priv->miscdev.this_device;
1405 1405
1406 /* remove all sysfs files, now the device cannot be re-enabled */ 1406 /* remove all sysfs files, now the device cannot be re-enabled */
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 2baeec56edfe..5d4fd69d04ca 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -492,10 +492,9 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
492 if (client->dev.platform_data) { 492 if (client->dev.platform_data) {
493 chip = *(struct at24_platform_data *)client->dev.platform_data; 493 chip = *(struct at24_platform_data *)client->dev.platform_data;
494 } else { 494 } else {
495 if (!id->driver_data) { 495 if (!id->driver_data)
496 err = -ENODEV; 496 return -ENODEV;
497 goto err_out; 497
498 }
499 magic = id->driver_data; 498 magic = id->driver_data;
500 chip.byte_len = BIT(magic & AT24_BITMASK(AT24_SIZE_BYTELEN)); 499 chip.byte_len = BIT(magic & AT24_BITMASK(AT24_SIZE_BYTELEN));
501 magic >>= AT24_SIZE_BYTELEN; 500 magic >>= AT24_SIZE_BYTELEN;
@@ -519,8 +518,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
519 "byte_len looks suspicious (no power of 2)!\n"); 518 "byte_len looks suspicious (no power of 2)!\n");
520 if (!chip.page_size) { 519 if (!chip.page_size) {
521 dev_err(&client->dev, "page_size must not be 0!\n"); 520 dev_err(&client->dev, "page_size must not be 0!\n");
522 err = -EINVAL; 521 return -EINVAL;
523 goto err_out;
524 } 522 }
525 if (!is_power_of_2(chip.page_size)) 523 if (!is_power_of_2(chip.page_size))
526 dev_warn(&client->dev, 524 dev_warn(&client->dev,
@@ -528,10 +526,9 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
528 526
529 /* Use I2C operations unless we're stuck with SMBus extensions. */ 527 /* Use I2C operations unless we're stuck with SMBus extensions. */
530 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 528 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
531 if (chip.flags & AT24_FLAG_ADDR16) { 529 if (chip.flags & AT24_FLAG_ADDR16)
532 err = -EPFNOSUPPORT; 530 return -EPFNOSUPPORT;
533 goto err_out; 531
534 }
535 if (i2c_check_functionality(client->adapter, 532 if (i2c_check_functionality(client->adapter,
536 I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { 533 I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
537 use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; 534 use_smbus = I2C_SMBUS_I2C_BLOCK_DATA;
@@ -542,8 +539,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
542 I2C_FUNC_SMBUS_READ_BYTE_DATA)) { 539 I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
543 use_smbus = I2C_SMBUS_BYTE_DATA; 540 use_smbus = I2C_SMBUS_BYTE_DATA;
544 } else { 541 } else {
545 err = -EPFNOSUPPORT; 542 return -EPFNOSUPPORT;
546 goto err_out;
547 } 543 }
548 } 544 }
549 545
@@ -553,12 +549,10 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
553 num_addresses = DIV_ROUND_UP(chip.byte_len, 549 num_addresses = DIV_ROUND_UP(chip.byte_len,
554 (chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256); 550 (chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
555 551
556 at24 = kzalloc(sizeof(struct at24_data) + 552 at24 = devm_kzalloc(&client->dev, sizeof(struct at24_data) +
557 num_addresses * sizeof(struct i2c_client *), GFP_KERNEL); 553 num_addresses * sizeof(struct i2c_client *), GFP_KERNEL);
558 if (!at24) { 554 if (!at24)
559 err = -ENOMEM; 555 return -ENOMEM;
560 goto err_out;
561 }
562 556
563 mutex_init(&at24->lock); 557 mutex_init(&at24->lock);
564 at24->use_smbus = use_smbus; 558 at24->use_smbus = use_smbus;
@@ -596,11 +590,10 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
596 at24->write_max = write_max; 590 at24->write_max = write_max;
597 591
598 /* buffer (data + address at the beginning) */ 592 /* buffer (data + address at the beginning) */
599 at24->writebuf = kmalloc(write_max + 2, GFP_KERNEL); 593 at24->writebuf = devm_kzalloc(&client->dev,
600 if (!at24->writebuf) { 594 write_max + 2, GFP_KERNEL);
601 err = -ENOMEM; 595 if (!at24->writebuf)
602 goto err_struct; 596 return -ENOMEM;
603 }
604 } else { 597 } else {
605 dev_warn(&client->dev, 598 dev_warn(&client->dev,
606 "cannot write due to controller restrictions."); 599 "cannot write due to controller restrictions.");
@@ -648,11 +641,6 @@ err_clients:
648 if (at24->client[i]) 641 if (at24->client[i])
649 i2c_unregister_device(at24->client[i]); 642 i2c_unregister_device(at24->client[i]);
650 643
651 kfree(at24->writebuf);
652err_struct:
653 kfree(at24);
654err_out:
655 dev_dbg(&client->dev, "probe error %d\n", err);
656 return err; 644 return err;
657} 645}
658 646
@@ -667,8 +655,6 @@ static int at24_remove(struct i2c_client *client)
667 for (i = 1; i < at24->num_addresses; i++) 655 for (i = 1; i < at24->num_addresses; i++)
668 i2c_unregister_device(at24->client[i]); 656 i2c_unregister_device(at24->client[i]);
669 657
670 kfree(at24->writebuf);
671 kfree(at24);
672 return 0; 658 return 0;
673} 659}
674 660
diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c
index ad8fd8e64937..840b3594a5ae 100644
--- a/drivers/misc/eeprom/at25.c
+++ b/drivers/misc/eeprom/at25.c
@@ -371,11 +371,10 @@ static int at25_probe(struct spi_device *spi)
371 if (np) { 371 if (np) {
372 err = at25_np_to_chip(&spi->dev, np, &chip); 372 err = at25_np_to_chip(&spi->dev, np, &chip);
373 if (err) 373 if (err)
374 goto fail; 374 return err;
375 } else { 375 } else {
376 dev_err(&spi->dev, "Error: no chip description\n"); 376 dev_err(&spi->dev, "Error: no chip description\n");
377 err = -ENODEV; 377 return -ENODEV;
378 goto fail;
379 } 378 }
380 } else 379 } else
381 chip = *(struct spi_eeprom *)spi->dev.platform_data; 380 chip = *(struct spi_eeprom *)spi->dev.platform_data;
@@ -389,8 +388,7 @@ static int at25_probe(struct spi_device *spi)
389 addrlen = 3; 388 addrlen = 3;
390 else { 389 else {
391 dev_dbg(&spi->dev, "unsupported address type\n"); 390 dev_dbg(&spi->dev, "unsupported address type\n");
392 err = -EINVAL; 391 return -EINVAL;
393 goto fail;
394 } 392 }
395 393
396 /* Ping the chip ... the status register is pretty portable, 394 /* Ping the chip ... the status register is pretty portable,
@@ -400,14 +398,12 @@ static int at25_probe(struct spi_device *spi)
400 sr = spi_w8r8(spi, AT25_RDSR); 398 sr = spi_w8r8(spi, AT25_RDSR);
401 if (sr < 0 || sr & AT25_SR_nRDY) { 399 if (sr < 0 || sr & AT25_SR_nRDY) {
402 dev_dbg(&spi->dev, "rdsr --> %d (%02x)\n", sr, sr); 400 dev_dbg(&spi->dev, "rdsr --> %d (%02x)\n", sr, sr);
403 err = -ENXIO; 401 return -ENXIO;
404 goto fail;
405 } 402 }
406 403
407 if (!(at25 = kzalloc(sizeof *at25, GFP_KERNEL))) { 404 at25 = devm_kzalloc(&spi->dev, sizeof(struct at25_data), GFP_KERNEL);
408 err = -ENOMEM; 405 if (!at25)
409 goto fail; 406 return -ENOMEM;
410 }
411 407
412 mutex_init(&at25->lock); 408 mutex_init(&at25->lock);
413 at25->chip = chip; 409 at25->chip = chip;
@@ -439,7 +435,7 @@ static int at25_probe(struct spi_device *spi)
439 435
440 err = sysfs_create_bin_file(&spi->dev.kobj, &at25->bin); 436 err = sysfs_create_bin_file(&spi->dev.kobj, &at25->bin);
441 if (err) 437 if (err)
442 goto fail; 438 return err;
443 439
444 if (chip.setup) 440 if (chip.setup)
445 chip.setup(&at25->mem, chip.context); 441 chip.setup(&at25->mem, chip.context);
@@ -453,10 +449,6 @@ static int at25_probe(struct spi_device *spi)
453 (chip.flags & EE_READONLY) ? " (readonly)" : "", 449 (chip.flags & EE_READONLY) ? " (readonly)" : "",
454 at25->chip.page_size); 450 at25->chip.page_size);
455 return 0; 451 return 0;
456fail:
457 dev_dbg(&spi->dev, "probe err %d\n", err);
458 kfree(at25);
459 return err;
460} 452}
461 453
462static int at25_remove(struct spi_device *spi) 454static int at25_remove(struct spi_device *spi)
@@ -465,7 +457,6 @@ static int at25_remove(struct spi_device *spi)
465 457
466 at25 = spi_get_drvdata(spi); 458 at25 = spi_get_drvdata(spi);
467 sysfs_remove_bin_file(&spi->dev.kobj, &at25->bin); 459 sysfs_remove_bin_file(&spi->dev.kobj, &at25->bin);
468 kfree(at25);
469 return 0; 460 return 0;
470} 461}
471 462
diff --git a/drivers/misc/ep93xx_pwm.c b/drivers/misc/ep93xx_pwm.c
index 96787ec15cad..cdb67a9c1959 100644
--- a/drivers/misc/ep93xx_pwm.c
+++ b/drivers/misc/ep93xx_pwm.c
@@ -39,63 +39,6 @@ struct ep93xx_pwm {
39 u32 duty_percent; 39 u32 duty_percent;
40}; 40};
41 41
42static inline void ep93xx_pwm_writel(struct ep93xx_pwm *pwm,
43 unsigned int val, unsigned int off)
44{
45 __raw_writel(val, pwm->mmio_base + off);
46}
47
48static inline unsigned int ep93xx_pwm_readl(struct ep93xx_pwm *pwm,
49 unsigned int off)
50{
51 return __raw_readl(pwm->mmio_base + off);
52}
53
54static inline void ep93xx_pwm_write_tc(struct ep93xx_pwm *pwm, u16 value)
55{
56 ep93xx_pwm_writel(pwm, value, EP93XX_PWMx_TERM_COUNT);
57}
58
59static inline u16 ep93xx_pwm_read_tc(struct ep93xx_pwm *pwm)
60{
61 return ep93xx_pwm_readl(pwm, EP93XX_PWMx_TERM_COUNT);
62}
63
64static inline void ep93xx_pwm_write_dc(struct ep93xx_pwm *pwm, u16 value)
65{
66 ep93xx_pwm_writel(pwm, value, EP93XX_PWMx_DUTY_CYCLE);
67}
68
69static inline void ep93xx_pwm_enable(struct ep93xx_pwm *pwm)
70{
71 ep93xx_pwm_writel(pwm, 0x1, EP93XX_PWMx_ENABLE);
72}
73
74static inline void ep93xx_pwm_disable(struct ep93xx_pwm *pwm)
75{
76 ep93xx_pwm_writel(pwm, 0x0, EP93XX_PWMx_ENABLE);
77}
78
79static inline int ep93xx_pwm_is_enabled(struct ep93xx_pwm *pwm)
80{
81 return ep93xx_pwm_readl(pwm, EP93XX_PWMx_ENABLE) & 0x1;
82}
83
84static inline void ep93xx_pwm_invert(struct ep93xx_pwm *pwm)
85{
86 ep93xx_pwm_writel(pwm, 0x1, EP93XX_PWMx_INVERT);
87}
88
89static inline void ep93xx_pwm_normal(struct ep93xx_pwm *pwm)
90{
91 ep93xx_pwm_writel(pwm, 0x0, EP93XX_PWMx_INVERT);
92}
93
94static inline int ep93xx_pwm_is_inverted(struct ep93xx_pwm *pwm)
95{
96 return ep93xx_pwm_readl(pwm, EP93XX_PWMx_INVERT) & 0x1;
97}
98
99/* 42/*
100 * /sys/devices/platform/ep93xx-pwm.N 43 * /sys/devices/platform/ep93xx-pwm.N
101 * /min_freq read-only minimum pwm output frequency 44 * /min_freq read-only minimum pwm output frequency
@@ -131,9 +74,9 @@ static ssize_t ep93xx_pwm_get_freq(struct device *dev,
131 struct platform_device *pdev = to_platform_device(dev); 74 struct platform_device *pdev = to_platform_device(dev);
132 struct ep93xx_pwm *pwm = platform_get_drvdata(pdev); 75 struct ep93xx_pwm *pwm = platform_get_drvdata(pdev);
133 76
134 if (ep93xx_pwm_is_enabled(pwm)) { 77 if (readl(pwm->mmio_base + EP93XX_PWMx_ENABLE) & 0x1) {
135 unsigned long rate = clk_get_rate(pwm->clk); 78 unsigned long rate = clk_get_rate(pwm->clk);
136 u16 term = ep93xx_pwm_read_tc(pwm); 79 u16 term = readl(pwm->mmio_base + EP93XX_PWMx_TERM_COUNT);
137 80
138 return sprintf(buf, "%ld\n", rate / (term + 1)); 81 return sprintf(buf, "%ld\n", rate / (term + 1));
139 } else { 82 } else {
@@ -149,12 +92,12 @@ static ssize_t ep93xx_pwm_set_freq(struct device *dev,
149 long val; 92 long val;
150 int err; 93 int err;
151 94
152 err = strict_strtol(buf, 10, &val); 95 err = kstrtol(buf, 10, &val);
153 if (err) 96 if (err)
154 return -EINVAL; 97 return -EINVAL;
155 98
156 if (val == 0) { 99 if (val == 0) {
157 ep93xx_pwm_disable(pwm); 100 writel(0x0, pwm->mmio_base + EP93XX_PWMx_ENABLE);
158 } else if (val <= (clk_get_rate(pwm->clk) / 2)) { 101 } else if (val <= (clk_get_rate(pwm->clk) / 2)) {
159 u32 term, duty; 102 u32 term, duty;
160 103
@@ -164,20 +107,20 @@ static ssize_t ep93xx_pwm_set_freq(struct device *dev,
164 if (val < 1) 107 if (val < 1)
165 val = 1; 108 val = 1;
166 109
167 term = ep93xx_pwm_read_tc(pwm); 110 term = readl(pwm->mmio_base + EP93XX_PWMx_TERM_COUNT);
168 duty = ((val + 1) * pwm->duty_percent / 100) - 1; 111 duty = ((val + 1) * pwm->duty_percent / 100) - 1;
169 112
170 /* If pwm is running, order is important */ 113 /* If pwm is running, order is important */
171 if (val > term) { 114 if (val > term) {
172 ep93xx_pwm_write_tc(pwm, val); 115 writel(val, pwm->mmio_base + EP93XX_PWMx_TERM_COUNT);
173 ep93xx_pwm_write_dc(pwm, duty); 116 writel(duty, pwm->mmio_base + EP93XX_PWMx_DUTY_CYCLE);
174 } else { 117 } else {
175 ep93xx_pwm_write_dc(pwm, duty); 118 writel(duty, pwm->mmio_base + EP93XX_PWMx_DUTY_CYCLE);
176 ep93xx_pwm_write_tc(pwm, val); 119 writel(val, pwm->mmio_base + EP93XX_PWMx_TERM_COUNT);
177 } 120 }
178 121
179 if (!ep93xx_pwm_is_enabled(pwm)) 122 if (!readl(pwm->mmio_base + EP93XX_PWMx_ENABLE) & 0x1)
180 ep93xx_pwm_enable(pwm); 123 writel(0x1, pwm->mmio_base + EP93XX_PWMx_ENABLE);
181 } else { 124 } else {
182 return -EINVAL; 125 return -EINVAL;
183 } 126 }
@@ -202,13 +145,15 @@ static ssize_t ep93xx_pwm_set_duty_percent(struct device *dev,
202 long val; 145 long val;
203 int err; 146 int err;
204 147
205 err = strict_strtol(buf, 10, &val); 148 err = kstrtol(buf, 10, &val);
206 if (err) 149 if (err)
207 return -EINVAL; 150 return -EINVAL;
208 151
209 if (val > 0 && val < 100) { 152 if (val > 0 && val < 100) {
210 u32 term = ep93xx_pwm_read_tc(pwm); 153 u32 term = readl(pwm->mmio_base + EP93XX_PWMx_TERM_COUNT);
211 ep93xx_pwm_write_dc(pwm, ((term + 1) * val / 100) - 1); 154 u32 duty = ((term + 1) * val / 100) - 1;
155
156 writel(duty, pwm->mmio_base + EP93XX_PWMx_DUTY_CYCLE);
212 pwm->duty_percent = val; 157 pwm->duty_percent = val;
213 return count; 158 return count;
214 } 159 }
@@ -221,8 +166,9 @@ static ssize_t ep93xx_pwm_get_invert(struct device *dev,
221{ 166{
222 struct platform_device *pdev = to_platform_device(dev); 167 struct platform_device *pdev = to_platform_device(dev);
223 struct ep93xx_pwm *pwm = platform_get_drvdata(pdev); 168 struct ep93xx_pwm *pwm = platform_get_drvdata(pdev);
169 int inverted = readl(pwm->mmio_base + EP93XX_PWMx_INVERT) & 0x1;
224 170
225 return sprintf(buf, "%d\n", ep93xx_pwm_is_inverted(pwm)); 171 return sprintf(buf, "%d\n", inverted);
226} 172}
227 173
228static ssize_t ep93xx_pwm_set_invert(struct device *dev, 174static ssize_t ep93xx_pwm_set_invert(struct device *dev,
@@ -233,14 +179,14 @@ static ssize_t ep93xx_pwm_set_invert(struct device *dev,
233 long val; 179 long val;
234 int err; 180 int err;
235 181
236 err = strict_strtol(buf, 10, &val); 182 err = kstrtol(buf, 10, &val);
237 if (err) 183 if (err)
238 return -EINVAL; 184 return -EINVAL;
239 185
240 if (val == 0) 186 if (val == 0)
241 ep93xx_pwm_normal(pwm); 187 writel(0x0, pwm->mmio_base + EP93XX_PWMx_INVERT);
242 else if (val == 1) 188 else if (val == 1)
243 ep93xx_pwm_invert(pwm); 189 writel(0x1, pwm->mmio_base + EP93XX_PWMx_INVERT);
244 else 190 else
245 return -EINVAL; 191 return -EINVAL;
246 192
@@ -269,89 +215,55 @@ static const struct attribute_group ep93xx_pwm_sysfs_files = {
269 .attrs = ep93xx_pwm_attrs, 215 .attrs = ep93xx_pwm_attrs,
270}; 216};
271 217
272static int __init ep93xx_pwm_probe(struct platform_device *pdev) 218static int ep93xx_pwm_probe(struct platform_device *pdev)
273{ 219{
274 struct ep93xx_pwm *pwm; 220 struct ep93xx_pwm *pwm;
275 struct resource *res; 221 struct resource *res;
276 int err; 222 int ret;
277 223
278 err = ep93xx_pwm_acquire_gpio(pdev); 224 pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL);
279 if (err) 225 if (!pwm)
280 return err; 226 return -ENOMEM;
281 227
282 pwm = kzalloc(sizeof(struct ep93xx_pwm), GFP_KERNEL); 228 pwm->clk = devm_clk_get(&pdev->dev, "pwm_clk");
283 if (!pwm) { 229 if (IS_ERR(pwm->clk))
284 err = -ENOMEM; 230 return PTR_ERR(pwm->clk);
285 goto fail_no_mem;
286 }
287 231
288 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 232 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
289 if (res == NULL) { 233 pwm->mmio_base = devm_ioremap_resource(&pdev->dev, res);
290 err = -ENXIO; 234 if (IS_ERR(pwm->mmio_base))
291 goto fail_no_mem_resource; 235 return PTR_ERR(pwm->mmio_base);
292 } 236
293 237 ret = ep93xx_pwm_acquire_gpio(pdev);
294 res = request_mem_region(res->start, resource_size(res), pdev->name); 238 if (ret)
295 if (res == NULL) { 239 return ret;
296 err = -EBUSY; 240
297 goto fail_no_mem_resource; 241 ret = sysfs_create_group(&pdev->dev.kobj, &ep93xx_pwm_sysfs_files);
298 } 242 if (ret) {
299 243 ep93xx_pwm_release_gpio(pdev);
300 pwm->mmio_base = ioremap(res->start, resource_size(res)); 244 return ret;
301 if (pwm->mmio_base == NULL) {
302 err = -ENXIO;
303 goto fail_no_ioremap;
304 }
305
306 err = sysfs_create_group(&pdev->dev.kobj, &ep93xx_pwm_sysfs_files);
307 if (err)
308 goto fail_no_sysfs;
309
310 pwm->clk = clk_get(&pdev->dev, "pwm_clk");
311 if (IS_ERR(pwm->clk)) {
312 err = PTR_ERR(pwm->clk);
313 goto fail_no_clk;
314 } 245 }
315 246
316 pwm->duty_percent = 50; 247 pwm->duty_percent = 50;
317 248
318 platform_set_drvdata(pdev, pwm);
319
320 /* disable pwm at startup. Avoids zero value. */ 249 /* disable pwm at startup. Avoids zero value. */
321 ep93xx_pwm_disable(pwm); 250 writel(0x0, pwm->mmio_base + EP93XX_PWMx_ENABLE);
322 ep93xx_pwm_write_tc(pwm, EP93XX_PWM_MAX_COUNT); 251 writel(EP93XX_PWM_MAX_COUNT, pwm->mmio_base + EP93XX_PWMx_TERM_COUNT);
323 ep93xx_pwm_write_dc(pwm, EP93XX_PWM_MAX_COUNT / 2); 252 writel(EP93XX_PWM_MAX_COUNT/2, pwm->mmio_base + EP93XX_PWMx_DUTY_CYCLE);
324 253
325 clk_enable(pwm->clk); 254 clk_enable(pwm->clk);
326 255
256 platform_set_drvdata(pdev, pwm);
327 return 0; 257 return 0;
328
329fail_no_clk:
330 sysfs_remove_group(&pdev->dev.kobj, &ep93xx_pwm_sysfs_files);
331fail_no_sysfs:
332 iounmap(pwm->mmio_base);
333fail_no_ioremap:
334 release_mem_region(res->start, resource_size(res));
335fail_no_mem_resource:
336 kfree(pwm);
337fail_no_mem:
338 ep93xx_pwm_release_gpio(pdev);
339 return err;
340} 258}
341 259
342static int __exit ep93xx_pwm_remove(struct platform_device *pdev) 260static int ep93xx_pwm_remove(struct platform_device *pdev)
343{ 261{
344 struct ep93xx_pwm *pwm = platform_get_drvdata(pdev); 262 struct ep93xx_pwm *pwm = platform_get_drvdata(pdev);
345 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
346 263
347 ep93xx_pwm_disable(pwm); 264 writel(0x0, pwm->mmio_base + EP93XX_PWMx_ENABLE);
348 clk_disable(pwm->clk); 265 clk_disable(pwm->clk);
349 clk_put(pwm->clk);
350 platform_set_drvdata(pdev, NULL);
351 sysfs_remove_group(&pdev->dev.kobj, &ep93xx_pwm_sysfs_files); 266 sysfs_remove_group(&pdev->dev.kobj, &ep93xx_pwm_sysfs_files);
352 iounmap(pwm->mmio_base);
353 release_mem_region(res->start, resource_size(res));
354 kfree(pwm);
355 ep93xx_pwm_release_gpio(pdev); 267 ep93xx_pwm_release_gpio(pdev);
356 268
357 return 0; 269 return 0;
@@ -362,10 +274,10 @@ static struct platform_driver ep93xx_pwm_driver = {
362 .name = "ep93xx-pwm", 274 .name = "ep93xx-pwm",
363 .owner = THIS_MODULE, 275 .owner = THIS_MODULE,
364 }, 276 },
365 .remove = __exit_p(ep93xx_pwm_remove), 277 .probe = ep93xx_pwm_probe,
278 .remove = ep93xx_pwm_remove,
366}; 279};
367 280module_platform_driver(ep93xx_pwm_driver);
368module_platform_driver_probe(ep93xx_pwm_driver, ep93xx_pwm_probe);
369 281
370MODULE_AUTHOR("Matthieu Crapet <mcrapet@gmail.com>, " 282MODULE_AUTHOR("Matthieu Crapet <mcrapet@gmail.com>, "
371 "H Hartley Sweeten <hsweeten@visionengravers.com>"); 283 "H Hartley Sweeten <hsweeten@visionengravers.com>");
diff --git a/drivers/misc/hmc6352.c b/drivers/misc/hmc6352.c
index 423cd40f1c0f..170bd3daf336 100644
--- a/drivers/misc/hmc6352.c
+++ b/drivers/misc/hmc6352.c
@@ -46,8 +46,9 @@ static int compass_store(struct device *dev, const char *buf, size_t count,
46 int ret; 46 int ret;
47 unsigned long val; 47 unsigned long val;
48 48
49 if (strict_strtoul(buf, 10, &val)) 49 ret = kstrtoul(buf, 10, &val);
50 return -EINVAL; 50 if (ret)
51 return ret;
51 if (val >= strlen(map)) 52 if (val >= strlen(map))
52 return -EINVAL; 53 return -EINVAL;
53 mutex_lock(&compass_mutex); 54 mutex_lock(&compass_mutex);
diff --git a/drivers/misc/isl29003.c b/drivers/misc/isl29003.c
index c5145b3fcce8..e3183f26216b 100644
--- a/drivers/misc/isl29003.c
+++ b/drivers/misc/isl29003.c
@@ -208,7 +208,11 @@ static ssize_t isl29003_store_range(struct device *dev,
208 unsigned long val; 208 unsigned long val;
209 int ret; 209 int ret;
210 210
211 if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3)) 211 ret = kstrtoul(buf, 10, &val);
212 if (ret)
213 return ret;
214
215 if (val > 3)
212 return -EINVAL; 216 return -EINVAL;
213 217
214 ret = isl29003_set_range(client, val); 218 ret = isl29003_set_range(client, val);
@@ -239,7 +243,11 @@ static ssize_t isl29003_store_resolution(struct device *dev,
239 unsigned long val; 243 unsigned long val;
240 int ret; 244 int ret;
241 245
242 if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3)) 246 ret = kstrtoul(buf, 10, &val);
247 if (ret)
248 return ret;
249
250 if (val > 3)
243 return -EINVAL; 251 return -EINVAL;
244 252
245 ret = isl29003_set_resolution(client, val); 253 ret = isl29003_set_resolution(client, val);
@@ -267,7 +275,11 @@ static ssize_t isl29003_store_mode(struct device *dev,
267 unsigned long val; 275 unsigned long val;
268 int ret; 276 int ret;
269 277
270 if ((strict_strtoul(buf, 10, &val) < 0) || (val > 2)) 278 ret = kstrtoul(buf, 10, &val);
279 if (ret)
280 return ret;
281
282 if (val > 2)
271 return -EINVAL; 283 return -EINVAL;
272 284
273 ret = isl29003_set_mode(client, val); 285 ret = isl29003_set_mode(client, val);
@@ -298,7 +310,11 @@ static ssize_t isl29003_store_power_state(struct device *dev,
298 unsigned long val; 310 unsigned long val;
299 int ret; 311 int ret;
300 312
301 if ((strict_strtoul(buf, 10, &val) < 0) || (val > 1)) 313 ret = kstrtoul(buf, 10, &val);
314 if (ret)
315 return ret;
316
317 if (val > 1)
302 return -EINVAL; 318 return -EINVAL;
303 319
304 ret = isl29003_set_power_state(client, val); 320 ret = isl29003_set_power_state(client, val);
diff --git a/drivers/misc/isl29020.c b/drivers/misc/isl29020.c
index 0aa08c746463..b7f84dacf822 100644
--- a/drivers/misc/isl29020.c
+++ b/drivers/misc/isl29020.c
@@ -90,8 +90,10 @@ static ssize_t als_sensing_range_store(struct device *dev,
90 int ret_val; 90 int ret_val;
91 unsigned long val; 91 unsigned long val;
92 92
93 if (strict_strtoul(buf, 10, &val)) 93 ret_val = kstrtoul(buf, 10, &val);
94 return -EINVAL; 94 if (ret_val)
95 return ret_val;
96
95 if (val < 1 || val > 64000) 97 if (val < 1 || val > 64000)
96 return -EINVAL; 98 return -EINVAL;
97 99
diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
index 4cd4a3d2a76a..036effe9a795 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d.c
@@ -831,9 +831,11 @@ static ssize_t lis3lv02d_rate_set(struct device *dev,
831{ 831{
832 struct lis3lv02d *lis3 = dev_get_drvdata(dev); 832 struct lis3lv02d *lis3 = dev_get_drvdata(dev);
833 unsigned long rate; 833 unsigned long rate;
834 int ret;
834 835
835 if (strict_strtoul(buf, 0, &rate)) 836 ret = kstrtoul(buf, 0, &rate);
836 return -EINVAL; 837 if (ret)
838 return ret;
837 839
838 lis3lv02d_sysfs_poweron(lis3); 840 lis3lv02d_sysfs_poweron(lis3);
839 if (lis3lv02d_set_odr(lis3, rate)) 841 if (lis3lv02d_set_odr(lis3, rate))
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index b3e50984d2c8..749452f8e2f6 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -443,11 +443,11 @@ unsigned int mei_amthif_poll(struct mei_device *dev,
443 * 443 *
444 * returns 0, OK; otherwise, error. 444 * returns 0, OK; otherwise, error.
445 */ 445 */
446int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots, 446int mei_amthif_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
447 struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list) 447 s32 *slots, struct mei_cl_cb *cmpl_list)
448{ 448{
449 struct mei_device *dev = cl->dev;
449 struct mei_msg_hdr mei_hdr; 450 struct mei_msg_hdr mei_hdr;
450 struct mei_cl *cl = cb->cl;
451 size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index; 451 size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index;
452 u32 msg_slots = mei_data2slots(len); 452 u32 msg_slots = mei_data2slots(len);
453 453
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index e310ca6ed1a3..21d3f5aa8353 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -485,7 +485,6 @@ int mei_cl_connect(struct mei_cl *cl, struct file *file)
485{ 485{
486 struct mei_device *dev; 486 struct mei_device *dev;
487 struct mei_cl_cb *cb; 487 struct mei_cl_cb *cb;
488 long timeout = mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT);
489 int rets; 488 int rets;
490 489
491 if (WARN_ON(!cl || !cl->dev)) 490 if (WARN_ON(!cl || !cl->dev))
@@ -518,7 +517,7 @@ int mei_cl_connect(struct mei_cl *cl, struct file *file)
518 rets = wait_event_timeout(dev->wait_recvd_msg, 517 rets = wait_event_timeout(dev->wait_recvd_msg,
519 (cl->state == MEI_FILE_CONNECTED || 518 (cl->state == MEI_FILE_CONNECTED ||
520 cl->state == MEI_FILE_DISCONNECTED), 519 cl->state == MEI_FILE_DISCONNECTED),
521 timeout * HZ); 520 mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT));
522 mutex_lock(&dev->device_lock); 521 mutex_lock(&dev->device_lock);
523 522
524 if (cl->state != MEI_FILE_CONNECTED) { 523 if (cl->state != MEI_FILE_CONNECTED) {
@@ -682,6 +681,68 @@ err:
682} 681}
683 682
684/** 683/**
684 * mei_cl_irq_write_complete - write a message to device
685 * from the interrupt thread context
686 *
687 * @cl: client
688 * @cb: callback block.
689 * @slots: free slots.
690 * @cmpl_list: complete list.
691 *
692 * returns 0, OK; otherwise error.
693 */
694int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
695 s32 *slots, struct mei_cl_cb *cmpl_list)
696{
697 struct mei_device *dev = cl->dev;
698 struct mei_msg_hdr mei_hdr;
699 size_t len = cb->request_buffer.size - cb->buf_idx;
700 u32 msg_slots = mei_data2slots(len);
701
702 mei_hdr.host_addr = cl->host_client_id;
703 mei_hdr.me_addr = cl->me_client_id;
704 mei_hdr.reserved = 0;
705
706 if (*slots >= msg_slots) {
707 mei_hdr.length = len;
708 mei_hdr.msg_complete = 1;
709 /* Split the message only if we can write the whole host buffer */
710 } else if (*slots == dev->hbuf_depth) {
711 msg_slots = *slots;
712 len = (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
713 mei_hdr.length = len;
714 mei_hdr.msg_complete = 0;
715 } else {
716 /* wait for next time the host buffer is empty */
717 return 0;
718 }
719
720 dev_dbg(&dev->pdev->dev, "buf: size = %d idx = %lu\n",
721 cb->request_buffer.size, cb->buf_idx);
722 dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(&mei_hdr));
723
724 *slots -= msg_slots;
725 if (mei_write_message(dev, &mei_hdr,
726 cb->request_buffer.data + cb->buf_idx)) {
727 cl->status = -ENODEV;
728 list_move_tail(&cb->list, &cmpl_list->list);
729 return -ENODEV;
730 }
731
732 cl->status = 0;
733 cl->writing_state = MEI_WRITING;
734 cb->buf_idx += mei_hdr.length;
735
736 if (mei_hdr.msg_complete) {
737 if (mei_cl_flow_ctrl_reduce(cl))
738 return -ENODEV;
739 list_move_tail(&cb->list, &dev->write_waiting_list.list);
740 }
741
742 return 0;
743}
744
745/**
685 * mei_cl_write - submit a write cb to mei device 746 * mei_cl_write - submit a write cb to mei device
686 assumes device_lock is locked 747 assumes device_lock is locked
687 * 748 *
@@ -723,7 +784,6 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking)
723 cb->buf_idx = 0; 784 cb->buf_idx = 0;
724 /* unseting complete will enqueue the cb for write */ 785 /* unseting complete will enqueue the cb for write */
725 mei_hdr.msg_complete = 0; 786 mei_hdr.msg_complete = 0;
726 cl->writing_state = MEI_WRITING;
727 rets = buf->size; 787 rets = buf->size;
728 goto out; 788 goto out;
729 } 789 }
@@ -785,6 +845,32 @@ err:
785} 845}
786 846
787 847
848/**
849 * mei_cl_complete - processes completed operation for a client
850 *
851 * @cl: private data of the file object.
852 * @cb: callback block.
853 */
854void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb)
855{
856 if (cb->fop_type == MEI_FOP_WRITE) {
857 mei_io_cb_free(cb);
858 cb = NULL;
859 cl->writing_state = MEI_WRITE_COMPLETE;
860 if (waitqueue_active(&cl->tx_wait))
861 wake_up_interruptible(&cl->tx_wait);
862
863 } else if (cb->fop_type == MEI_FOP_READ &&
864 MEI_READING == cl->reading_state) {
865 cl->reading_state = MEI_READ_COMPLETE;
866 if (waitqueue_active(&cl->rx_wait))
867 wake_up_interruptible(&cl->rx_wait);
868 else
869 mei_cl_bus_rx_event(cl);
870
871 }
872}
873
788 874
789/** 875/**
790 * mei_cl_all_disconnect - disconnect forcefully all connected clients 876 * mei_cl_all_disconnect - disconnect forcefully all connected clients
diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h
index cfdb144526aa..26b157d8bad5 100644
--- a/drivers/misc/mei/client.h
+++ b/drivers/misc/mei/client.h
@@ -89,6 +89,10 @@ int mei_cl_disconnect(struct mei_cl *cl);
89int mei_cl_connect(struct mei_cl *cl, struct file *file); 89int mei_cl_connect(struct mei_cl *cl, struct file *file);
90int mei_cl_read_start(struct mei_cl *cl, size_t length); 90int mei_cl_read_start(struct mei_cl *cl, size_t length);
91int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking); 91int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking);
92int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
93 s32 *slots, struct mei_cl_cb *cmpl_list);
94
95void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb);
92 96
93void mei_host_client_init(struct work_struct *work); 97void mei_host_client_init(struct work_struct *work);
94 98
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index 6916045166eb..565027b1bc73 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -536,6 +536,20 @@ static void mei_hbm_fw_disconnect_req(struct mei_device *dev,
536 536
537 537
538/** 538/**
539 * mei_hbm_version_is_supported - checks whether the driver can
540 * support the hbm version of the device
541 *
542 * @dev: the device structure
543 * returns true if driver can support hbm version of the device
544 */
545bool mei_hbm_version_is_supported(struct mei_device *dev)
546{
547 return (dev->version.major_version < HBM_MAJOR_VERSION) ||
548 (dev->version.major_version == HBM_MAJOR_VERSION &&
549 dev->version.minor_version <= HBM_MINOR_VERSION);
550}
551
552/**
539 * mei_hbm_dispatch - bottom half read routine after ISR to 553 * mei_hbm_dispatch - bottom half read routine after ISR to
540 * handle the read bus message cmd processing. 554 * handle the read bus message cmd processing.
541 * 555 *
@@ -562,9 +576,24 @@ void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
562 switch (mei_msg->hbm_cmd) { 576 switch (mei_msg->hbm_cmd) {
563 case HOST_START_RES_CMD: 577 case HOST_START_RES_CMD:
564 version_res = (struct hbm_host_version_response *)mei_msg; 578 version_res = (struct hbm_host_version_response *)mei_msg;
565 if (!version_res->host_version_supported) { 579
566 dev->version = version_res->me_max_version; 580 dev_dbg(&dev->pdev->dev, "HBM VERSION: DRIVER=%02d:%02d DEVICE=%02d:%02d\n",
567 dev_dbg(&dev->pdev->dev, "version mismatch.\n"); 581 HBM_MAJOR_VERSION, HBM_MINOR_VERSION,
582 version_res->me_max_version.major_version,
583 version_res->me_max_version.minor_version);
584
585 if (version_res->host_version_supported) {
586 dev->version.major_version = HBM_MAJOR_VERSION;
587 dev->version.minor_version = HBM_MINOR_VERSION;
588 } else {
589 dev->version.major_version =
590 version_res->me_max_version.major_version;
591 dev->version.minor_version =
592 version_res->me_max_version.minor_version;
593 }
594
595 if (!mei_hbm_version_is_supported(dev)) {
596 dev_warn(&dev->pdev->dev, "hbm version mismatch: stopping the driver.\n");
568 597
569 dev->hbm_state = MEI_HBM_STOP; 598 dev->hbm_state = MEI_HBM_STOP;
570 mei_hbm_stop_req_prepare(dev, &dev->wr_msg.hdr, 599 mei_hbm_stop_req_prepare(dev, &dev->wr_msg.hdr,
@@ -575,8 +604,6 @@ void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
575 return; 604 return;
576 } 605 }
577 606
578 dev->version.major_version = HBM_MAJOR_VERSION;
579 dev->version.minor_version = HBM_MINOR_VERSION;
580 if (dev->dev_state == MEI_DEV_INIT_CLIENTS && 607 if (dev->dev_state == MEI_DEV_INIT_CLIENTS &&
581 dev->hbm_state == MEI_HBM_START) { 608 dev->hbm_state == MEI_HBM_START) {
582 dev->init_clients_timer = 0; 609 dev->init_clients_timer = 0;
diff --git a/drivers/misc/mei/hbm.h b/drivers/misc/mei/hbm.h
index e80dc24ef3e2..4ae2e56e404f 100644
--- a/drivers/misc/mei/hbm.h
+++ b/drivers/misc/mei/hbm.h
@@ -54,7 +54,7 @@ int mei_hbm_start_wait(struct mei_device *dev);
54int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl); 54int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl);
55int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl); 55int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl);
56int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl); 56int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl);
57 57bool mei_hbm_version_is_supported(struct mei_device *dev);
58 58
59#endif /* _MEI_HBM_H_ */ 59#endif /* _MEI_HBM_H_ */
60 60
diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c
index 822170f00348..e4f8dec4dc3c 100644
--- a/drivers/misc/mei/hw-me.c
+++ b/drivers/misc/mei/hw-me.c
@@ -171,7 +171,7 @@ static void mei_me_hw_reset_release(struct mei_device *dev)
171 * @dev: the device structure 171 * @dev: the device structure
172 * @intr_enable: if interrupt should be enabled after reset. 172 * @intr_enable: if interrupt should be enabled after reset.
173 */ 173 */
174static void mei_me_hw_reset(struct mei_device *dev, bool intr_enable) 174static int mei_me_hw_reset(struct mei_device *dev, bool intr_enable)
175{ 175{
176 struct mei_me_hw *hw = to_me_hw(dev); 176 struct mei_me_hw *hw = to_me_hw(dev);
177 u32 hcsr = mei_hcsr_read(hw); 177 u32 hcsr = mei_hcsr_read(hw);
@@ -191,6 +191,7 @@ static void mei_me_hw_reset(struct mei_device *dev, bool intr_enable)
191 mei_me_hw_reset_release(dev); 191 mei_me_hw_reset_release(dev);
192 192
193 dev_dbg(&dev->pdev->dev, "current HCSR = 0x%08x.\n", mei_hcsr_read(hw)); 193 dev_dbg(&dev->pdev->dev, "current HCSR = 0x%08x.\n", mei_hcsr_read(hw));
194 return 0;
194} 195}
195 196
196/** 197/**
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index f580d30bb784..6fc573cef178 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -106,8 +106,7 @@ int mei_start(struct mei_device *dev)
106 goto err; 106 goto err;
107 } 107 }
108 108
109 if (dev->version.major_version != HBM_MAJOR_VERSION || 109 if (!mei_hbm_version_is_supported(dev)) {
110 dev->version.minor_version != HBM_MINOR_VERSION) {
111 dev_dbg(&dev->pdev->dev, "MEI start failed.\n"); 110 dev_dbg(&dev->pdev->dev, "MEI start failed.\n");
112 goto err; 111 goto err;
113 } 112 }
@@ -133,13 +132,19 @@ EXPORT_SYMBOL_GPL(mei_start);
133void mei_reset(struct mei_device *dev, int interrupts_enabled) 132void mei_reset(struct mei_device *dev, int interrupts_enabled)
134{ 133{
135 bool unexpected; 134 bool unexpected;
135 int ret;
136 136
137 unexpected = (dev->dev_state != MEI_DEV_INITIALIZING && 137 unexpected = (dev->dev_state != MEI_DEV_INITIALIZING &&
138 dev->dev_state != MEI_DEV_DISABLED && 138 dev->dev_state != MEI_DEV_DISABLED &&
139 dev->dev_state != MEI_DEV_POWER_DOWN && 139 dev->dev_state != MEI_DEV_POWER_DOWN &&
140 dev->dev_state != MEI_DEV_POWER_UP); 140 dev->dev_state != MEI_DEV_POWER_UP);
141 141
142 mei_hw_reset(dev, interrupts_enabled); 142 ret = mei_hw_reset(dev, interrupts_enabled);
143 if (ret) {
144 dev_err(&dev->pdev->dev, "hw reset failed disabling the device\n");
145 interrupts_enabled = false;
146 dev->dev_state = MEI_DEV_DISABLED;
147 }
143 148
144 dev->hbm_state = MEI_HBM_IDLE; 149 dev->hbm_state = MEI_HBM_IDLE;
145 150
@@ -176,7 +181,12 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled)
176 return; 181 return;
177 } 182 }
178 183
179 mei_hw_start(dev); 184 ret = mei_hw_start(dev);
185 if (ret) {
186 dev_err(&dev->pdev->dev, "hw_start failed disabling the device\n");
187 dev->dev_state = MEI_DEV_DISABLED;
188 return;
189 }
180 190
181 dev_dbg(&dev->pdev->dev, "link is established start sending messages.\n"); 191 dev_dbg(&dev->pdev->dev, "link is established start sending messages.\n");
182 /* link is established * start sending messages. */ 192 /* link is established * start sending messages. */
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 2ad736989410..4b59cb742dee 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -31,32 +31,6 @@
31 31
32 32
33/** 33/**
34 * mei_cl_complete_handler - processes completed operation for a client
35 *
36 * @cl: private data of the file object.
37 * @cb: callback block.
38 */
39static void mei_cl_complete_handler(struct mei_cl *cl, struct mei_cl_cb *cb)
40{
41 if (cb->fop_type == MEI_FOP_WRITE) {
42 mei_io_cb_free(cb);
43 cb = NULL;
44 cl->writing_state = MEI_WRITE_COMPLETE;
45 if (waitqueue_active(&cl->tx_wait))
46 wake_up_interruptible(&cl->tx_wait);
47
48 } else if (cb->fop_type == MEI_FOP_READ &&
49 MEI_READING == cl->reading_state) {
50 cl->reading_state = MEI_READ_COMPLETE;
51 if (waitqueue_active(&cl->rx_wait))
52 wake_up_interruptible(&cl->rx_wait);
53 else
54 mei_cl_bus_rx_event(cl);
55
56 }
57}
58
59/**
60 * mei_irq_compl_handler - dispatch complete handelers 34 * mei_irq_compl_handler - dispatch complete handelers
61 * for the completed callbacks 35 * for the completed callbacks
62 * 36 *
@@ -78,7 +52,7 @@ void mei_irq_compl_handler(struct mei_device *dev, struct mei_cl_cb *compl_list)
78 if (cl == &dev->iamthif_cl) 52 if (cl == &dev->iamthif_cl)
79 mei_amthif_complete(dev, cb); 53 mei_amthif_complete(dev, cb);
80 else 54 else
81 mei_cl_complete_handler(cl, cb); 55 mei_cl_complete(cl, cb);
82 } 56 }
83} 57}
84EXPORT_SYMBOL_GPL(mei_irq_compl_handler); 58EXPORT_SYMBOL_GPL(mei_irq_compl_handler);
@@ -189,21 +163,21 @@ static int mei_cl_irq_read_msg(struct mei_device *dev,
189} 163}
190 164
191/** 165/**
192 * _mei_irq_thread_close - processes close related operation. 166 * mei_cl_irq_close - processes close related operation from
167 * interrupt thread context - send disconnect request
193 * 168 *
194 * @dev: the device structure. 169 * @cl: client
170 * @cb: callback block.
195 * @slots: free slots. 171 * @slots: free slots.
196 * @cb_pos: callback block.
197 * @cl: private data of the file object.
198 * @cmpl_list: complete list. 172 * @cmpl_list: complete list.
199 * 173 *
200 * returns 0, OK; otherwise, error. 174 * returns 0, OK; otherwise, error.
201 */ 175 */
202static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots, 176static int mei_cl_irq_close(struct mei_cl *cl, struct mei_cl_cb *cb,
203 struct mei_cl_cb *cb_pos, 177 s32 *slots, struct mei_cl_cb *cmpl_list)
204 struct mei_cl *cl,
205 struct mei_cl_cb *cmpl_list)
206{ 178{
179 struct mei_device *dev = cl->dev;
180
207 u32 msg_slots = 181 u32 msg_slots =
208 mei_data2slots(sizeof(struct hbm_client_connect_request)); 182 mei_data2slots(sizeof(struct hbm_client_connect_request));
209 183
@@ -214,15 +188,15 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
214 188
215 if (mei_hbm_cl_disconnect_req(dev, cl)) { 189 if (mei_hbm_cl_disconnect_req(dev, cl)) {
216 cl->status = 0; 190 cl->status = 0;
217 cb_pos->buf_idx = 0; 191 cb->buf_idx = 0;
218 list_move_tail(&cb_pos->list, &cmpl_list->list); 192 list_move_tail(&cb->list, &cmpl_list->list);
219 return -EIO; 193 return -EIO;
220 } 194 }
221 195
222 cl->state = MEI_FILE_DISCONNECTING; 196 cl->state = MEI_FILE_DISCONNECTING;
223 cl->status = 0; 197 cl->status = 0;
224 cb_pos->buf_idx = 0; 198 cb->buf_idx = 0;
225 list_move_tail(&cb_pos->list, &dev->ctrl_rd_list.list); 199 list_move_tail(&cb->list, &dev->ctrl_rd_list.list);
226 cl->timer_count = MEI_CONNECT_TIMEOUT; 200 cl->timer_count = MEI_CONNECT_TIMEOUT;
227 201
228 return 0; 202 return 0;
@@ -230,26 +204,26 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
230 204
231 205
232/** 206/**
233 * _mei_irq_thread_read - processes read related operation. 207 * mei_cl_irq_close - processes client read related operation from the
208 * interrupt thread context - request for flow control credits
234 * 209 *
235 * @dev: the device structure. 210 * @cl: client
211 * @cb: callback block.
236 * @slots: free slots. 212 * @slots: free slots.
237 * @cb_pos: callback block.
238 * @cl: private data of the file object.
239 * @cmpl_list: complete list. 213 * @cmpl_list: complete list.
240 * 214 *
241 * returns 0, OK; otherwise, error. 215 * returns 0, OK; otherwise, error.
242 */ 216 */
243static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots, 217static int mei_cl_irq_read(struct mei_cl *cl, struct mei_cl_cb *cb,
244 struct mei_cl_cb *cb_pos, 218 s32 *slots, struct mei_cl_cb *cmpl_list)
245 struct mei_cl *cl,
246 struct mei_cl_cb *cmpl_list)
247{ 219{
220 struct mei_device *dev = cl->dev;
221
248 u32 msg_slots = mei_data2slots(sizeof(struct hbm_flow_control)); 222 u32 msg_slots = mei_data2slots(sizeof(struct hbm_flow_control));
249 223
250 if (*slots < msg_slots) { 224 if (*slots < msg_slots) {
251 /* return the cancel routine */ 225 /* return the cancel routine */
252 list_del(&cb_pos->list); 226 list_del(&cb->list);
253 return -EMSGSIZE; 227 return -EMSGSIZE;
254 } 228 }
255 229
@@ -257,38 +231,38 @@ static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots,
257 231
258 if (mei_hbm_cl_flow_control_req(dev, cl)) { 232 if (mei_hbm_cl_flow_control_req(dev, cl)) {
259 cl->status = -ENODEV; 233 cl->status = -ENODEV;
260 cb_pos->buf_idx = 0; 234 cb->buf_idx = 0;
261 list_move_tail(&cb_pos->list, &cmpl_list->list); 235 list_move_tail(&cb->list, &cmpl_list->list);
262 return -ENODEV; 236 return -ENODEV;
263 } 237 }
264 list_move_tail(&cb_pos->list, &dev->read_list.list); 238 list_move_tail(&cb->list, &dev->read_list.list);
265 239
266 return 0; 240 return 0;
267} 241}
268 242
269 243
270/** 244/**
271 * _mei_irq_thread_ioctl - processes ioctl related operation. 245 * mei_cl_irq_ioctl - processes client ioctl related operation from the
246 * interrupt thread context - send connection request
272 * 247 *
273 * @dev: the device structure. 248 * @cl: client
249 * @cb: callback block.
274 * @slots: free slots. 250 * @slots: free slots.
275 * @cb_pos: callback block.
276 * @cl: private data of the file object.
277 * @cmpl_list: complete list. 251 * @cmpl_list: complete list.
278 * 252 *
279 * returns 0, OK; otherwise, error. 253 * returns 0, OK; otherwise, error.
280 */ 254 */
281static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots, 255static int mei_cl_irq_ioctl(struct mei_cl *cl, struct mei_cl_cb *cb,
282 struct mei_cl_cb *cb_pos, 256 s32 *slots, struct mei_cl_cb *cmpl_list)
283 struct mei_cl *cl,
284 struct mei_cl_cb *cmpl_list)
285{ 257{
258 struct mei_device *dev = cl->dev;
259
286 u32 msg_slots = 260 u32 msg_slots =
287 mei_data2slots(sizeof(struct hbm_client_connect_request)); 261 mei_data2slots(sizeof(struct hbm_client_connect_request));
288 262
289 if (*slots < msg_slots) { 263 if (*slots < msg_slots) {
290 /* return the cancel routine */ 264 /* return the cancel routine */
291 list_del(&cb_pos->list); 265 list_del(&cb->list);
292 return -EMSGSIZE; 266 return -EMSGSIZE;
293 } 267 }
294 268
@@ -298,76 +272,17 @@ static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
298 272
299 if (mei_hbm_cl_connect_req(dev, cl)) { 273 if (mei_hbm_cl_connect_req(dev, cl)) {
300 cl->status = -ENODEV; 274 cl->status = -ENODEV;
301 cb_pos->buf_idx = 0; 275 cb->buf_idx = 0;
302 list_del(&cb_pos->list); 276 list_del(&cb->list);
303 return -ENODEV;
304 } else {
305 list_move_tail(&cb_pos->list, &dev->ctrl_rd_list.list);
306 cl->timer_count = MEI_CONNECT_TIMEOUT;
307 }
308 return 0;
309}
310
311/**
312 * mei_irq_thread_write_complete - write messages to device.
313 *
314 * @dev: the device structure.
315 * @slots: free slots.
316 * @cb: callback block.
317 * @cmpl_list: complete list.
318 *
319 * returns 0, OK; otherwise, error.
320 */
321static int mei_irq_thread_write_complete(struct mei_device *dev, s32 *slots,
322 struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list)
323{
324 struct mei_msg_hdr mei_hdr;
325 struct mei_cl *cl = cb->cl;
326 size_t len = cb->request_buffer.size - cb->buf_idx;
327 u32 msg_slots = mei_data2slots(len);
328
329 mei_hdr.host_addr = cl->host_client_id;
330 mei_hdr.me_addr = cl->me_client_id;
331 mei_hdr.reserved = 0;
332
333 if (*slots >= msg_slots) {
334 mei_hdr.length = len;
335 mei_hdr.msg_complete = 1;
336 /* Split the message only if we can write the whole host buffer */
337 } else if (*slots == dev->hbuf_depth) {
338 msg_slots = *slots;
339 len = (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
340 mei_hdr.length = len;
341 mei_hdr.msg_complete = 0;
342 } else {
343 /* wait for next time the host buffer is empty */
344 return 0;
345 }
346
347 dev_dbg(&dev->pdev->dev, "buf: size = %d idx = %lu\n",
348 cb->request_buffer.size, cb->buf_idx);
349 dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(&mei_hdr));
350
351 *slots -= msg_slots;
352 if (mei_write_message(dev, &mei_hdr,
353 cb->request_buffer.data + cb->buf_idx)) {
354 cl->status = -ENODEV;
355 list_move_tail(&cb->list, &cmpl_list->list);
356 return -ENODEV; 277 return -ENODEV;
357 } 278 }
358 279
359 280 list_move_tail(&cb->list, &dev->ctrl_rd_list.list);
360 cl->status = 0; 281 cl->timer_count = MEI_CONNECT_TIMEOUT;
361 cb->buf_idx += mei_hdr.length;
362 if (mei_hdr.msg_complete) {
363 if (mei_cl_flow_ctrl_reduce(cl))
364 return -ENODEV;
365 list_move_tail(&cb->list, &dev->write_waiting_list.list);
366 }
367
368 return 0; 282 return 0;
369} 283}
370 284
285
371/** 286/**
372 * mei_irq_read_handler - bottom half read routine after ISR to 287 * mei_irq_read_handler - bottom half read routine after ISR to
373 * handle the read processing. 288 * handle the read processing.
@@ -481,7 +396,7 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
481{ 396{
482 397
483 struct mei_cl *cl; 398 struct mei_cl *cl;
484 struct mei_cl_cb *pos = NULL, *next = NULL; 399 struct mei_cl_cb *cb, *next;
485 struct mei_cl_cb *list; 400 struct mei_cl_cb *list;
486 s32 slots; 401 s32 slots;
487 int ret; 402 int ret;
@@ -498,19 +413,19 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
498 dev_dbg(&dev->pdev->dev, "complete all waiting for write cb.\n"); 413 dev_dbg(&dev->pdev->dev, "complete all waiting for write cb.\n");
499 414
500 list = &dev->write_waiting_list; 415 list = &dev->write_waiting_list;
501 list_for_each_entry_safe(pos, next, &list->list, list) { 416 list_for_each_entry_safe(cb, next, &list->list, list) {
502 cl = pos->cl; 417 cl = cb->cl;
503 if (cl == NULL) 418 if (cl == NULL)
504 continue; 419 continue;
505 420
506 cl->status = 0; 421 cl->status = 0;
507 list_del(&pos->list); 422 list_del(&cb->list);
508 if (MEI_WRITING == cl->writing_state && 423 if (MEI_WRITING == cl->writing_state &&
509 pos->fop_type == MEI_FOP_WRITE && 424 cb->fop_type == MEI_FOP_WRITE &&
510 cl != &dev->iamthif_cl) { 425 cl != &dev->iamthif_cl) {
511 dev_dbg(&dev->pdev->dev, "MEI WRITE COMPLETE\n"); 426 dev_dbg(&dev->pdev->dev, "MEI WRITE COMPLETE\n");
512 cl->writing_state = MEI_WRITE_COMPLETE; 427 cl->writing_state = MEI_WRITE_COMPLETE;
513 list_add_tail(&pos->list, &cmpl_list->list); 428 list_add_tail(&cb->list, &cmpl_list->list);
514 } 429 }
515 if (cl == &dev->iamthif_cl) { 430 if (cl == &dev->iamthif_cl) {
516 dev_dbg(&dev->pdev->dev, "check iamthif flow control.\n"); 431 dev_dbg(&dev->pdev->dev, "check iamthif flow control.\n");
@@ -552,25 +467,23 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
552 467
553 /* complete control write list CB */ 468 /* complete control write list CB */
554 dev_dbg(&dev->pdev->dev, "complete control write list cb.\n"); 469 dev_dbg(&dev->pdev->dev, "complete control write list cb.\n");
555 list_for_each_entry_safe(pos, next, &dev->ctrl_wr_list.list, list) { 470 list_for_each_entry_safe(cb, next, &dev->ctrl_wr_list.list, list) {
556 cl = pos->cl; 471 cl = cb->cl;
557 if (!cl) { 472 if (!cl) {
558 list_del(&pos->list); 473 list_del(&cb->list);
559 return -ENODEV; 474 return -ENODEV;
560 } 475 }
561 switch (pos->fop_type) { 476 switch (cb->fop_type) {
562 case MEI_FOP_CLOSE: 477 case MEI_FOP_CLOSE:
563 /* send disconnect message */ 478 /* send disconnect message */
564 ret = _mei_irq_thread_close(dev, &slots, pos, 479 ret = mei_cl_irq_close(cl, cb, &slots, cmpl_list);
565 cl, cmpl_list);
566 if (ret) 480 if (ret)
567 return ret; 481 return ret;
568 482
569 break; 483 break;
570 case MEI_FOP_READ: 484 case MEI_FOP_READ:
571 /* send flow control message */ 485 /* send flow control message */
572 ret = _mei_irq_thread_read(dev, &slots, pos, 486 ret = mei_cl_irq_read(cl, cb, &slots, cmpl_list);
573 cl, cmpl_list);
574 if (ret) 487 if (ret)
575 return ret; 488 return ret;
576 489
@@ -579,8 +492,7 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
579 /* connect message */ 492 /* connect message */
580 if (mei_cl_is_other_connecting(cl)) 493 if (mei_cl_is_other_connecting(cl))
581 continue; 494 continue;
582 ret = _mei_irq_thread_ioctl(dev, &slots, pos, 495 ret = mei_cl_irq_ioctl(cl, cb, &slots, cmpl_list);
583 cl, cmpl_list);
584 if (ret) 496 if (ret)
585 return ret; 497 return ret;
586 498
@@ -593,8 +505,8 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
593 } 505 }
594 /* complete write list CB */ 506 /* complete write list CB */
595 dev_dbg(&dev->pdev->dev, "complete write list cb.\n"); 507 dev_dbg(&dev->pdev->dev, "complete write list cb.\n");
596 list_for_each_entry_safe(pos, next, &dev->write_list.list, list) { 508 list_for_each_entry_safe(cb, next, &dev->write_list.list, list) {
597 cl = pos->cl; 509 cl = cb->cl;
598 if (cl == NULL) 510 if (cl == NULL)
599 continue; 511 continue;
600 if (mei_cl_flow_ctrl_creds(cl) <= 0) { 512 if (mei_cl_flow_ctrl_creds(cl) <= 0) {
@@ -605,14 +517,13 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
605 } 517 }
606 518
607 if (cl == &dev->iamthif_cl) 519 if (cl == &dev->iamthif_cl)
608 ret = mei_amthif_irq_write_complete(dev, &slots, 520 ret = mei_amthif_irq_write_complete(cl, cb,
609 pos, cmpl_list); 521 &slots, cmpl_list);
610 else 522 else
611 ret = mei_irq_thread_write_complete(dev, &slots, pos, 523 ret = mei_cl_irq_write_complete(cl, cb,
612 cmpl_list); 524 &slots, cmpl_list);
613 if (ret) 525 if (ret)
614 return ret; 526 return ret;
615
616 } 527 }
617 return 0; 528 return 0;
618} 529}
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 053139f61086..5e11b5b9b65d 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -194,7 +194,6 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
194 struct mei_cl_cb *cb_pos = NULL; 194 struct mei_cl_cb *cb_pos = NULL;
195 struct mei_cl_cb *cb = NULL; 195 struct mei_cl_cb *cb = NULL;
196 struct mei_device *dev; 196 struct mei_device *dev;
197 int i;
198 int rets; 197 int rets;
199 int err; 198 int err;
200 199
@@ -210,38 +209,26 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
210 goto out; 209 goto out;
211 } 210 }
212 211
213 if ((cl->sm_state & MEI_WD_STATE_INDEPENDENCE_MSG_SENT) == 0) {
214 /* Do not allow to read watchdog client */
215 i = mei_me_cl_by_uuid(dev, &mei_wd_guid);
216 if (i >= 0) {
217 struct mei_me_client *me_client = &dev->me_clients[i];
218 if (cl->me_client_id == me_client->client_id) {
219 rets = -EBADF;
220 goto out;
221 }
222 }
223 } else {
224 cl->sm_state &= ~MEI_WD_STATE_INDEPENDENCE_MSG_SENT;
225 }
226
227 if (cl == &dev->iamthif_cl) { 212 if (cl == &dev->iamthif_cl) {
228 rets = mei_amthif_read(dev, file, ubuf, length, offset); 213 rets = mei_amthif_read(dev, file, ubuf, length, offset);
229 goto out; 214 goto out;
230 } 215 }
231 216
232 if (cl->read_cb && cl->read_cb->buf_idx > *offset) { 217 if (cl->read_cb) {
233 cb = cl->read_cb;
234 goto copy_buffer;
235 } else if (cl->read_cb && cl->read_cb->buf_idx > 0 &&
236 cl->read_cb->buf_idx <= *offset) {
237 cb = cl->read_cb; 218 cb = cl->read_cb;
238 rets = 0; 219 /* read what left */
239 goto free; 220 if (cb->buf_idx > *offset)
240 } else if ((!cl->read_cb || !cl->read_cb->buf_idx) && *offset > 0) { 221 goto copy_buffer;
241 /*Offset needs to be cleaned for contiguous reads*/ 222 /* offset is beyond buf_idx we have no more data return 0 */
223 if (cb->buf_idx > 0 && cb->buf_idx <= *offset) {
224 rets = 0;
225 goto free;
226 }
227 /* Offset needs to be cleaned for contiguous reads*/
228 if (cb->buf_idx == 0 && *offset > 0)
229 *offset = 0;
230 } else if (*offset > 0) {
242 *offset = 0; 231 *offset = 0;
243 rets = 0;
244 goto out;
245 } 232 }
246 233
247 err = mei_cl_read_start(cl, length); 234 err = mei_cl_read_start(cl, length);
@@ -420,16 +407,6 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
420 if (rets) 407 if (rets)
421 goto out; 408 goto out;
422 409
423 cl->sm_state = 0;
424 if (length == 4 &&
425 ((memcmp(mei_wd_state_independence_msg[0],
426 write_cb->request_buffer.data, 4) == 0) ||
427 (memcmp(mei_wd_state_independence_msg[1],
428 write_cb->request_buffer.data, 4) == 0) ||
429 (memcmp(mei_wd_state_independence_msg[2],
430 write_cb->request_buffer.data, 4) == 0)))
431 cl->sm_state |= MEI_WD_STATE_INDEPENDENCE_MSG_SENT;
432
433 if (cl == &dev->iamthif_cl) { 410 if (cl == &dev->iamthif_cl) {
434 rets = mei_amthif_write(dev, write_cb); 411 rets = mei_amthif_write(dev, write_cb);
435 412
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 4de5140e7379..7b918b2fb894 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -56,11 +56,6 @@ extern const uuid_le mei_amthif_guid;
56extern const uuid_le mei_wd_guid; 56extern const uuid_le mei_wd_guid;
57 57
58/* 58/*
59 * Watchdog independence state message
60 */
61extern const u8 mei_wd_state_independence_msg[3][4];
62
63/*
64 * Number of Maximum MEI Clients 59 * Number of Maximum MEI Clients
65 */ 60 */
66#define MEI_CLIENTS_MAX 256 61#define MEI_CLIENTS_MAX 256
@@ -201,7 +196,6 @@ struct mei_cl {
201 u8 timer_count; 196 u8 timer_count;
202 enum mei_file_transaction_states reading_state; 197 enum mei_file_transaction_states reading_state;
203 enum mei_file_transaction_states writing_state; 198 enum mei_file_transaction_states writing_state;
204 int sm_state;
205 struct mei_cl_cb *read_cb; 199 struct mei_cl_cb *read_cb;
206 200
207 /* MEI CL bus data */ 201 /* MEI CL bus data */
@@ -239,7 +233,7 @@ struct mei_hw_ops {
239 bool (*host_is_ready) (struct mei_device *dev); 233 bool (*host_is_ready) (struct mei_device *dev);
240 234
241 bool (*hw_is_ready) (struct mei_device *dev); 235 bool (*hw_is_ready) (struct mei_device *dev);
242 void (*hw_reset) (struct mei_device *dev, bool enable); 236 int (*hw_reset) (struct mei_device *dev, bool enable);
243 int (*hw_start) (struct mei_device *dev); 237 int (*hw_start) (struct mei_device *dev);
244 void (*hw_config) (struct mei_device *dev); 238 void (*hw_config) (struct mei_device *dev);
245 239
@@ -502,8 +496,8 @@ struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,
502 496
503void mei_amthif_run_next_cmd(struct mei_device *dev); 497void mei_amthif_run_next_cmd(struct mei_device *dev);
504 498
505int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots, 499int mei_amthif_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
506 struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list); 500 s32 *slots, struct mei_cl_cb *cmpl_list);
507 501
508void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb); 502void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb);
509int mei_amthif_irq_read_msg(struct mei_device *dev, 503int mei_amthif_irq_read_msg(struct mei_device *dev,
@@ -522,15 +516,6 @@ void mei_nfc_host_exit(void);
522 */ 516 */
523extern const uuid_le mei_nfc_guid; 517extern const uuid_le mei_nfc_guid;
524 518
525int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,
526 struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list);
527
528void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb);
529int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list,
530 struct mei_device *dev, struct mei_msg_hdr *mei_hdr);
531int mei_amthif_irq_read(struct mei_device *dev, s32 *slots);
532
533
534int mei_wd_send(struct mei_device *dev); 519int mei_wd_send(struct mei_device *dev);
535int mei_wd_stop(struct mei_device *dev); 520int mei_wd_stop(struct mei_device *dev);
536int mei_wd_host_init(struct mei_device *dev); 521int mei_wd_host_init(struct mei_device *dev);
@@ -554,14 +539,14 @@ static inline void mei_hw_config(struct mei_device *dev)
554{ 539{
555 dev->ops->hw_config(dev); 540 dev->ops->hw_config(dev);
556} 541}
557static inline void mei_hw_reset(struct mei_device *dev, bool enable) 542static inline int mei_hw_reset(struct mei_device *dev, bool enable)
558{ 543{
559 dev->ops->hw_reset(dev, enable); 544 return dev->ops->hw_reset(dev, enable);
560} 545}
561 546
562static inline void mei_hw_start(struct mei_device *dev) 547static inline int mei_hw_start(struct mei_device *dev)
563{ 548{
564 dev->ops->hw_start(dev); 549 return dev->ops->hw_start(dev);
565} 550}
566 551
567static inline void mei_clear_interrupts(struct mei_device *dev) 552static inline void mei_clear_interrupts(struct mei_device *dev)
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
index 0f268329bd3a..1b3844e82379 100644
--- a/drivers/misc/mei/pci-me.c
+++ b/drivers/misc/mei/pci-me.c
@@ -43,9 +43,6 @@
43#include "hw-me.h" 43#include "hw-me.h"
44#include "client.h" 44#include "client.h"
45 45
46/* AMT device is a singleton on the platform */
47static struct pci_dev *mei_pdev;
48
49/* mei_pci_tbl - PCI Device ID Table */ 46/* mei_pci_tbl - PCI Device ID Table */
50static DEFINE_PCI_DEVICE_TABLE(mei_me_pci_tbl) = { 47static DEFINE_PCI_DEVICE_TABLE(mei_me_pci_tbl) = {
51 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82946GZ)}, 48 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82946GZ)},
@@ -88,8 +85,6 @@ static DEFINE_PCI_DEVICE_TABLE(mei_me_pci_tbl) = {
88 85
89MODULE_DEVICE_TABLE(pci, mei_me_pci_tbl); 86MODULE_DEVICE_TABLE(pci, mei_me_pci_tbl);
90 87
91static DEFINE_MUTEX(mei_mutex);
92
93/** 88/**
94 * mei_quirk_probe - probe for devices that doesn't valid ME interface 89 * mei_quirk_probe - probe for devices that doesn't valid ME interface
95 * 90 *
@@ -126,17 +121,12 @@ static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
126 struct mei_me_hw *hw; 121 struct mei_me_hw *hw;
127 int err; 122 int err;
128 123
129 mutex_lock(&mei_mutex);
130 124
131 if (!mei_me_quirk_probe(pdev, ent)) { 125 if (!mei_me_quirk_probe(pdev, ent)) {
132 err = -ENODEV; 126 err = -ENODEV;
133 goto end; 127 goto end;
134 } 128 }
135 129
136 if (mei_pdev) {
137 err = -EEXIST;
138 goto end;
139 }
140 /* enable pci dev */ 130 /* enable pci dev */
141 err = pci_enable_device(pdev); 131 err = pci_enable_device(pdev);
142 if (err) { 132 if (err) {
@@ -195,13 +185,10 @@ static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
195 if (err) 185 if (err)
196 goto release_irq; 186 goto release_irq;
197 187
198 mei_pdev = pdev;
199 pci_set_drvdata(pdev, dev); 188 pci_set_drvdata(pdev, dev);
200 189
201 schedule_delayed_work(&dev->timer_work, HZ); 190 schedule_delayed_work(&dev->timer_work, HZ);
202 191
203 mutex_unlock(&mei_mutex);
204
205 pr_debug("initialization successful.\n"); 192 pr_debug("initialization successful.\n");
206 193
207 return 0; 194 return 0;
@@ -220,7 +207,6 @@ release_regions:
220disable_device: 207disable_device:
221 pci_disable_device(pdev); 208 pci_disable_device(pdev);
222end: 209end:
223 mutex_unlock(&mei_mutex);
224 dev_err(&pdev->dev, "initialization failed.\n"); 210 dev_err(&pdev->dev, "initialization failed.\n");
225 return err; 211 return err;
226} 212}
@@ -238,9 +224,6 @@ static void mei_me_remove(struct pci_dev *pdev)
238 struct mei_device *dev; 224 struct mei_device *dev;
239 struct mei_me_hw *hw; 225 struct mei_me_hw *hw;
240 226
241 if (mei_pdev != pdev)
242 return;
243
244 dev = pci_get_drvdata(pdev); 227 dev = pci_get_drvdata(pdev);
245 if (!dev) 228 if (!dev)
246 return; 229 return;
@@ -251,8 +234,6 @@ static void mei_me_remove(struct pci_dev *pdev)
251 dev_err(&pdev->dev, "stop\n"); 234 dev_err(&pdev->dev, "stop\n");
252 mei_stop(dev); 235 mei_stop(dev);
253 236
254 mei_pdev = NULL;
255
256 /* disable interrupts */ 237 /* disable interrupts */
257 mei_disable_interrupts(dev); 238 mei_disable_interrupts(dev);
258 239
diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c
index 6251a4ee7067..b8921432e89d 100644
--- a/drivers/misc/mei/wd.c
+++ b/drivers/misc/mei/wd.c
@@ -31,12 +31,6 @@
31static const u8 mei_start_wd_params[] = { 0x02, 0x12, 0x13, 0x10 }; 31static const u8 mei_start_wd_params[] = { 0x02, 0x12, 0x13, 0x10 };
32static const u8 mei_stop_wd_params[] = { 0x02, 0x02, 0x14, 0x10 }; 32static const u8 mei_stop_wd_params[] = { 0x02, 0x02, 0x14, 0x10 };
33 33
34const u8 mei_wd_state_independence_msg[3][4] = {
35 {0x05, 0x02, 0x51, 0x10},
36 {0x05, 0x02, 0x52, 0x10},
37 {0x07, 0x02, 0x01, 0x10}
38};
39
40/* 34/*
41 * AMT Watchdog Device 35 * AMT Watchdog Device
42 */ 36 */
diff --git a/drivers/misc/pch_phub.c b/drivers/misc/pch_phub.c
index 931e635aa491..a5925f7f17f6 100644
--- a/drivers/misc/pch_phub.c
+++ b/drivers/misc/pch_phub.c
@@ -633,17 +633,13 @@ static ssize_t show_pch_mac(struct device *dev, struct device_attribute *attr,
633static ssize_t store_pch_mac(struct device *dev, struct device_attribute *attr, 633static ssize_t store_pch_mac(struct device *dev, struct device_attribute *attr,
634 const char *buf, size_t count) 634 const char *buf, size_t count)
635{ 635{
636 u8 mac[6]; 636 u8 mac[ETH_ALEN];
637 ssize_t rom_size; 637 ssize_t rom_size;
638 struct pch_phub_reg *chip = dev_get_drvdata(dev); 638 struct pch_phub_reg *chip = dev_get_drvdata(dev);
639 639
640 if (count != 18) 640 if (!mac_pton(buf, mac))
641 return -EINVAL; 641 return -EINVAL;
642 642
643 sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
644 (u32 *)&mac[0], (u32 *)&mac[1], (u32 *)&mac[2], (u32 *)&mac[3],
645 (u32 *)&mac[4], (u32 *)&mac[5]);
646
647 chip->pch_phub_extrom_base_address = pci_map_rom(chip->pdev, &rom_size); 643 chip->pch_phub_extrom_base_address = pci_map_rom(chip->pdev, &rom_size);
648 if (!chip->pch_phub_extrom_base_address) 644 if (!chip->pch_phub_extrom_base_address)
649 return -ENOMEM; 645 return -ENOMEM;
@@ -669,8 +665,6 @@ static struct bin_attribute pch_bin_attr = {
669static int pch_phub_probe(struct pci_dev *pdev, 665static int pch_phub_probe(struct pci_dev *pdev,
670 const struct pci_device_id *id) 666 const struct pci_device_id *id)
671{ 667{
672 int retval;
673
674 int ret; 668 int ret;
675 struct pch_phub_reg *chip; 669 struct pch_phub_reg *chip;
676 670
@@ -713,13 +707,13 @@ static int pch_phub_probe(struct pci_dev *pdev,
713 if (id->driver_data == 1) { /* EG20T PCH */ 707 if (id->driver_data == 1) { /* EG20T PCH */
714 const char *board_name; 708 const char *board_name;
715 709
716 retval = sysfs_create_file(&pdev->dev.kobj, 710 ret = sysfs_create_file(&pdev->dev.kobj,
717 &dev_attr_pch_mac.attr); 711 &dev_attr_pch_mac.attr);
718 if (retval) 712 if (ret)
719 goto err_sysfs_create; 713 goto err_sysfs_create;
720 714
721 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr); 715 ret = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr);
722 if (retval) 716 if (ret)
723 goto exit_bin_attr; 717 goto exit_bin_attr;
724 718
725 pch_phub_read_modify_write_reg(chip, 719 pch_phub_read_modify_write_reg(chip,
@@ -743,8 +737,8 @@ static int pch_phub_probe(struct pci_dev *pdev,
743 chip->pch_opt_rom_start_address = PCH_PHUB_ROM_START_ADDR_EG20T; 737 chip->pch_opt_rom_start_address = PCH_PHUB_ROM_START_ADDR_EG20T;
744 chip->pch_mac_start_address = PCH_PHUB_MAC_START_ADDR_EG20T; 738 chip->pch_mac_start_address = PCH_PHUB_MAC_START_ADDR_EG20T;
745 } else if (id->driver_data == 2) { /* ML7213 IOH */ 739 } else if (id->driver_data == 2) { /* ML7213 IOH */
746 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr); 740 ret = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr);
747 if (retval) 741 if (ret)
748 goto err_sysfs_create; 742 goto err_sysfs_create;
749 /* set the prefech value 743 /* set the prefech value
750 * Device2(USB OHCI #1/ USB EHCI #1/ USB Device):a 744 * Device2(USB OHCI #1/ USB EHCI #1/ USB Device):a
@@ -766,12 +760,12 @@ static int pch_phub_probe(struct pci_dev *pdev,
766 PCH_PHUB_ROM_START_ADDR_ML7223; 760 PCH_PHUB_ROM_START_ADDR_ML7223;
767 chip->pch_mac_start_address = PCH_PHUB_MAC_START_ADDR_ML7223; 761 chip->pch_mac_start_address = PCH_PHUB_MAC_START_ADDR_ML7223;
768 } else if (id->driver_data == 4) { /* ML7223 IOH Bus-n*/ 762 } else if (id->driver_data == 4) { /* ML7223 IOH Bus-n*/
769 retval = sysfs_create_file(&pdev->dev.kobj, 763 ret = sysfs_create_file(&pdev->dev.kobj,
770 &dev_attr_pch_mac.attr); 764 &dev_attr_pch_mac.attr);
771 if (retval) 765 if (ret)
772 goto err_sysfs_create; 766 goto err_sysfs_create;
773 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr); 767 ret = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr);
774 if (retval) 768 if (ret)
775 goto exit_bin_attr; 769 goto exit_bin_attr;
776 /* set the prefech value 770 /* set the prefech value
777 * Device2(USB OHCI #0,1,2,3/ USB EHCI #0):a 771 * Device2(USB OHCI #0,1,2,3/ USB EHCI #0):a
@@ -783,13 +777,13 @@ static int pch_phub_probe(struct pci_dev *pdev,
783 PCH_PHUB_ROM_START_ADDR_ML7223; 777 PCH_PHUB_ROM_START_ADDR_ML7223;
784 chip->pch_mac_start_address = PCH_PHUB_MAC_START_ADDR_ML7223; 778 chip->pch_mac_start_address = PCH_PHUB_MAC_START_ADDR_ML7223;
785 } else if (id->driver_data == 5) { /* ML7831 */ 779 } else if (id->driver_data == 5) { /* ML7831 */
786 retval = sysfs_create_file(&pdev->dev.kobj, 780 ret = sysfs_create_file(&pdev->dev.kobj,
787 &dev_attr_pch_mac.attr); 781 &dev_attr_pch_mac.attr);
788 if (retval) 782 if (ret)
789 goto err_sysfs_create; 783 goto err_sysfs_create;
790 784
791 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr); 785 ret = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr);
792 if (retval) 786 if (ret)
793 goto exit_bin_attr; 787 goto exit_bin_attr;
794 788
795 /* set the prefech value */ 789 /* set the prefech value */
diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
index 797d7962cc88..4f7635922394 100644
--- a/drivers/misc/sgi-gru/gruprocfs.c
+++ b/drivers/misc/sgi-gru/gruprocfs.c
@@ -160,15 +160,11 @@ static int options_show(struct seq_file *s, void *p)
160static ssize_t options_write(struct file *file, const char __user *userbuf, 160static ssize_t options_write(struct file *file, const char __user *userbuf,
161 size_t count, loff_t *data) 161 size_t count, loff_t *data)
162{ 162{
163 char buf[20]; 163 int ret;
164 164
165 if (count >= sizeof(buf)) 165 ret = kstrtoul_from_user(userbuf, count, 0, &gru_options);
166 return -EINVAL; 166 if (ret)
167 if (copy_from_user(buf, userbuf, count)) 167 return ret;
168 return -EFAULT;
169 buf[count] = '\0';
170 if (strict_strtoul(buf, 0, &gru_options))
171 return -EINVAL;
172 168
173 return count; 169 return count;
174} 170}
diff --git a/drivers/misc/spear13xx_pcie_gadget.c b/drivers/misc/spear13xx_pcie_gadget.c
index 7deb25dc86a7..2e13614d41e8 100644
--- a/drivers/misc/spear13xx_pcie_gadget.c
+++ b/drivers/misc/spear13xx_pcie_gadget.c
@@ -316,8 +316,12 @@ static ssize_t pcie_gadget_store_no_of_msi(
316 struct spear_pcie_gadget_config *config, 316 struct spear_pcie_gadget_config *config,
317 const char *buf, size_t count) 317 const char *buf, size_t count)
318{ 318{
319 if (strict_strtoul(buf, 0, &config->requested_msi)) 319 int ret;
320 return -EINVAL; 320
321 ret = kstrtoul(buf, 0, &config->requested_msi);
322 if (ret)
323 return ret;
324
321 if (config->requested_msi > 32) 325 if (config->requested_msi > 32)
322 config->requested_msi = 32; 326 config->requested_msi = 32;
323 327
@@ -330,9 +334,11 @@ static ssize_t pcie_gadget_store_inta(
330{ 334{
331 struct pcie_app_reg __iomem *app_reg = config->va_app_base; 335 struct pcie_app_reg __iomem *app_reg = config->va_app_base;
332 ulong en; 336 ulong en;
337 int ret;
333 338
334 if (strict_strtoul(buf, 0, &en)) 339 ret = kstrtoul(buf, 0, &en);
335 return -EINVAL; 340 if (ret)
341 return ret;
336 342
337 if (en) 343 if (en)
338 writel(readl(&app_reg->app_ctrl_0) | (1 << SYS_INT_ID), 344 writel(readl(&app_reg->app_ctrl_0) | (1 << SYS_INT_ID),
@@ -351,9 +357,11 @@ static ssize_t pcie_gadget_store_send_msi(
351 struct pcie_app_reg __iomem *app_reg = config->va_app_base; 357 struct pcie_app_reg __iomem *app_reg = config->va_app_base;
352 ulong vector; 358 ulong vector;
353 u32 ven_msi; 359 u32 ven_msi;
360 int ret;
354 361
355 if (strict_strtoul(buf, 0, &vector)) 362 ret = kstrtoul(buf, 0, &vector);
356 return -EINVAL; 363 if (ret)
364 return ret;
357 365
358 if (!config->configured_msi) 366 if (!config->configured_msi)
359 return -EINVAL; 367 return -EINVAL;
@@ -395,9 +403,11 @@ static ssize_t pcie_gadget_store_vendor_id(
395 const char *buf, size_t count) 403 const char *buf, size_t count)
396{ 404{
397 ulong id; 405 ulong id;
406 int ret;
398 407
399 if (strict_strtoul(buf, 0, &id)) 408 ret = kstrtoul(buf, 0, &id);
400 return -EINVAL; 409 if (ret)
410 return ret;
401 411
402 spear_dbi_write_reg(config, PCI_VENDOR_ID, 2, id); 412 spear_dbi_write_reg(config, PCI_VENDOR_ID, 2, id);
403 413
@@ -420,9 +430,11 @@ static ssize_t pcie_gadget_store_device_id(
420 const char *buf, size_t count) 430 const char *buf, size_t count)
421{ 431{
422 ulong id; 432 ulong id;
433 int ret;
423 434
424 if (strict_strtoul(buf, 0, &id)) 435 ret = kstrtoul(buf, 0, &id);
425 return -EINVAL; 436 if (ret)
437 return ret;
426 438
427 spear_dbi_write_reg(config, PCI_DEVICE_ID, 2, id); 439 spear_dbi_write_reg(config, PCI_DEVICE_ID, 2, id);
428 440
@@ -443,9 +455,12 @@ static ssize_t pcie_gadget_store_bar0_size(
443 ulong size; 455 ulong size;
444 u32 pos, pos1; 456 u32 pos, pos1;
445 u32 no_of_bit = 0; 457 u32 no_of_bit = 0;
458 int ret;
459
460 ret = kstrtoul(buf, 0, &size);
461 if (ret)
462 return ret;
446 463
447 if (strict_strtoul(buf, 0, &size))
448 return -EINVAL;
449 /* min bar size is 256 */ 464 /* min bar size is 256 */
450 if (size <= 0x100) 465 if (size <= 0x100)
451 size = 0x100; 466 size = 0x100;
@@ -490,9 +505,11 @@ static ssize_t pcie_gadget_store_bar0_address(
490{ 505{
491 struct pcie_app_reg __iomem *app_reg = config->va_app_base; 506 struct pcie_app_reg __iomem *app_reg = config->va_app_base;
492 ulong address; 507 ulong address;
508 int ret;
493 509
494 if (strict_strtoul(buf, 0, &address)) 510 ret = kstrtoul(buf, 0, &address);
495 return -EINVAL; 511 if (ret)
512 return ret;
496 513
497 address &= ~(config->bar0_size - 1); 514 address &= ~(config->bar0_size - 1);
498 if (config->va_bar0_address) 515 if (config->va_bar0_address)
@@ -518,9 +535,11 @@ static ssize_t pcie_gadget_store_bar0_rw_offset(
518 const char *buf, size_t count) 535 const char *buf, size_t count)
519{ 536{
520 ulong offset; 537 ulong offset;
538 int ret;
521 539
522 if (strict_strtoul(buf, 0, &offset)) 540 ret = kstrtoul(buf, 0, &offset);
523 return -EINVAL; 541 if (ret)
542 return ret;
524 543
525 if (offset % 4) 544 if (offset % 4)
526 return -EINVAL; 545 return -EINVAL;
@@ -549,9 +568,11 @@ static ssize_t pcie_gadget_store_bar0_data(
549 const char *buf, size_t count) 568 const char *buf, size_t count)
550{ 569{
551 ulong data; 570 ulong data;
571 int ret;
552 572
553 if (strict_strtoul(buf, 0, &data)) 573 ret = kstrtoul(buf, 0, &data);
554 return -EINVAL; 574 if (ret)
575 return ret;
555 576
556 if (!config->va_bar0_address) 577 if (!config->va_bar0_address)
557 return -ENOMEM; 578 return -ENOMEM;
@@ -776,7 +797,7 @@ static int spear_pcie_gadget_probe(struct platform_device *pdev)
776 goto err_iounmap_app; 797 goto err_iounmap_app;
777 } 798 }
778 799
779 dev_set_drvdata(&pdev->dev, target); 800 platform_set_drvdata(pdev, target);
780 801
781 irq = platform_get_irq(pdev, 0); 802 irq = platform_get_irq(pdev, 0);
782 if (irq < 0) { 803 if (irq < 0) {
@@ -814,9 +835,11 @@ static int spear_pcie_gadget_probe(struct platform_device *pdev)
814 clk = clk_get_sys("pcie1", NULL); 835 clk = clk_get_sys("pcie1", NULL);
815 if (IS_ERR(clk)) { 836 if (IS_ERR(clk)) {
816 pr_err("%s:couldn't get clk for pcie1\n", __func__); 837 pr_err("%s:couldn't get clk for pcie1\n", __func__);
838 status = PTR_ERR(clk);
817 goto err_irq; 839 goto err_irq;
818 } 840 }
819 if (clk_enable(clk)) { 841 status = clk_enable(clk);
842 if (status) {
820 pr_err("%s:couldn't enable clk for pcie1\n", __func__); 843 pr_err("%s:couldn't enable clk for pcie1\n", __func__);
821 goto err_irq; 844 goto err_irq;
822 } 845 }
@@ -828,9 +851,11 @@ static int spear_pcie_gadget_probe(struct platform_device *pdev)
828 clk = clk_get_sys("pcie2", NULL); 851 clk = clk_get_sys("pcie2", NULL);
829 if (IS_ERR(clk)) { 852 if (IS_ERR(clk)) {
830 pr_err("%s:couldn't get clk for pcie2\n", __func__); 853 pr_err("%s:couldn't get clk for pcie2\n", __func__);
854 status = PTR_ERR(clk);
831 goto err_irq; 855 goto err_irq;
832 } 856 }
833 if (clk_enable(clk)) { 857 status = clk_enable(clk);
858 if (status) {
834 pr_err("%s:couldn't enable clk for pcie2\n", __func__); 859 pr_err("%s:couldn't enable clk for pcie2\n", __func__);
835 goto err_irq; 860 goto err_irq;
836 } 861 }
@@ -863,7 +888,7 @@ static int spear_pcie_gadget_remove(struct platform_device *pdev)
863 res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); 888 res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
864 res1 = platform_get_resource(pdev, IORESOURCE_MEM, 1); 889 res1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
865 irq = platform_get_irq(pdev, 0); 890 irq = platform_get_irq(pdev, 0);
866 target = dev_get_drvdata(&pdev->dev); 891 target = platform_get_drvdata(pdev);
867 config = &target->config; 892 config = &target->config;
868 893
869 free_irq(irq, NULL); 894 free_irq(irq, NULL);
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
index 437192e43006..d87cc91bc016 100644
--- a/drivers/misc/sram.c
+++ b/drivers/misc/sram.c
@@ -45,15 +45,12 @@ static int sram_probe(struct platform_device *pdev)
45 int ret; 45 int ret;
46 46
47 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 47 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
48 if (!res) 48 virt_base = devm_ioremap_resource(&pdev->dev, res);
49 return -EINVAL; 49 if (IS_ERR(virt_base))
50 return PTR_ERR(virt_base);
50 51
51 size = resource_size(res); 52 size = resource_size(res);
52 53
53 virt_base = devm_request_and_ioremap(&pdev->dev, res);
54 if (!virt_base)
55 return -EADDRNOTAVAIL;
56
57 sram = devm_kzalloc(&pdev->dev, sizeof(*sram), GFP_KERNEL); 54 sram = devm_kzalloc(&pdev->dev, sizeof(*sram), GFP_KERNEL);
58 if (!sram) 55 if (!sram)
59 return -ENOMEM; 56 return -ENOMEM;
diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
index 83269f1d16e3..83907c720594 100644
--- a/drivers/misc/ti-st/st_kim.c
+++ b/drivers/misc/ti-st/st_kim.c
@@ -680,7 +680,7 @@ void st_kim_ref(struct st_data_s **core_data, int id)
680 *core_data = NULL; 680 *core_data = NULL;
681 return; 681 return;
682 } 682 }
683 kim_gdata = dev_get_drvdata(&pdev->dev); 683 kim_gdata = platform_get_drvdata(pdev);
684 *core_data = kim_gdata->core_data; 684 *core_data = kim_gdata->core_data;
685} 685}
686 686
@@ -735,7 +735,7 @@ static int kim_probe(struct platform_device *pdev)
735 pr_err("no mem to allocate"); 735 pr_err("no mem to allocate");
736 return -ENOMEM; 736 return -ENOMEM;
737 } 737 }
738 dev_set_drvdata(&pdev->dev, kim_gdata); 738 platform_set_drvdata(pdev, kim_gdata);
739 739
740 err = st_core_init(&kim_gdata->core_data); 740 err = st_core_init(&kim_gdata->core_data);
741 if (err != 0) { 741 if (err != 0) {
@@ -810,7 +810,7 @@ static int kim_remove(struct platform_device *pdev)
810 struct ti_st_plat_data *pdata = pdev->dev.platform_data; 810 struct ti_st_plat_data *pdata = pdev->dev.platform_data;
811 struct kim_data_s *kim_gdata; 811 struct kim_data_s *kim_gdata;
812 812
813 kim_gdata = dev_get_drvdata(&pdev->dev); 813 kim_gdata = platform_get_drvdata(pdev);
814 814
815 /* Free the Bluetooth/FM/GPIO 815 /* Free the Bluetooth/FM/GPIO
816 * nShutdown gpio from the system 816 * nShutdown gpio from the system
diff --git a/drivers/misc/ti_dac7512.c b/drivers/misc/ti_dac7512.c
index 1d86407189eb..9b237221bc4e 100644
--- a/drivers/misc/ti_dac7512.c
+++ b/drivers/misc/ti_dac7512.c
@@ -33,9 +33,11 @@ static ssize_t dac7512_store_val(struct device *dev,
33 struct spi_device *spi = to_spi_device(dev); 33 struct spi_device *spi = to_spi_device(dev);
34 unsigned char tmp[2]; 34 unsigned char tmp[2];
35 unsigned long val; 35 unsigned long val;
36 int ret;
36 37
37 if (strict_strtoul(buf, 10, &val) < 0) 38 ret = kstrtoul(buf, 10, &val);
38 return -EINVAL; 39 if (ret)
40 return ret;
39 41
40 tmp[0] = val >> 8; 42 tmp[0] = val >> 8;
41 tmp[1] = val & 0xff; 43 tmp[1] = val & 0xff;
diff --git a/drivers/misc/tsl2550.c b/drivers/misc/tsl2550.c
index 1dfde4d543db..5bc10fa193de 100644
--- a/drivers/misc/tsl2550.c
+++ b/drivers/misc/tsl2550.c
@@ -204,7 +204,7 @@ static ssize_t tsl2550_store_power_state(struct device *dev,
204 unsigned long val = simple_strtoul(buf, NULL, 10); 204 unsigned long val = simple_strtoul(buf, NULL, 10);
205 int ret; 205 int ret;
206 206
207 if (val < 0 || val > 1) 207 if (val > 1)
208 return -EINVAL; 208 return -EINVAL;
209 209
210 mutex_lock(&data->update_lock); 210 mutex_lock(&data->update_lock);
@@ -236,7 +236,7 @@ static ssize_t tsl2550_store_operating_mode(struct device *dev,
236 unsigned long val = simple_strtoul(buf, NULL, 10); 236 unsigned long val = simple_strtoul(buf, NULL, 10);
237 int ret; 237 int ret;
238 238
239 if (val < 0 || val > 1) 239 if (val > 1)
240 return -EINVAL; 240 return -EINVAL;
241 241
242 if (data->power_state == 0) 242 if (data->power_state == 0)