summaryrefslogtreecommitdiff
path: root/drivers/pwm
diff options
context:
space:
mode:
authorHector Palacios <hector.palacios@digi.com>2009-07-31 13:57:17 +0200
committerHector Palacios <hector.palacios@digi.com>2009-07-31 15:46:07 +0200
commit124475800d18f242f27a49ebf11abe790863bc17 (patch)
treeeba10d5bbb08f6507d85fd196b50e3df29c29286 /drivers/pwm
parent96544a460f26858f707f56b63247798471c9d5cb (diff)
pwm: remove overflow check and fix Kconfig
An overflow function was checking values exceeding 2^32, but doing a string comparision. This lead to overflows on any number starting with a character bigger than '5'. The overflow check is not needed because the 'sscanf' function is used to parse values as unsigned long, and this is already truncating values bigger than 2^32 to that limit. The dependencies on the Kconfig for the PWM support didn't let you enable SPI support in the kernel. The correct dependency should check for the platform SPI master. Signed-off-by: Hector Palacios <hector.palacios@digi.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r--drivers/pwm/Kconfig2
-rw-r--r--drivers/pwm/pwm.c36
2 files changed, 1 insertions, 37 deletions
diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 236bfeeaf741..c44227ebfa4e 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -23,7 +23,7 @@ config ATMEL_PWM
config NS9XXX_PWM
tristate "Digi NS9XXX PWM support"
- depends on ARCH_NS9XXX && !CC9P9215JS_SERIAL_PORTA && !SPI && !CC9P9215JS_SERIAL_PORTC_CTSRTSRXTX && !CC9P9215JS_SERIAL_PORTC_FULL
+ depends on ARCH_NS9XXX && !CC9P9215JS_SERIAL_PORTA && !CC9P9215JS_SPI && !CC9P9215JS_SERIAL_PORTC_CTSRTSRXTX && !CC9P9215JS_SERIAL_PORTC_FULL
help
This option enables device driver support for the PWMC
peripheral channels found on certain NetSilicon processors.
diff --git a/drivers/pwm/pwm.c b/drivers/pwm/pwm.c
index 44524228fe21..32e84f86bf62 100644
--- a/drivers/pwm/pwm.c
+++ b/drivers/pwm/pwm.c
@@ -39,28 +39,6 @@ static DEFINE_MUTEX(device_list_mutex);
static struct class pwm_class;
static struct workqueue_struct *pwm_handler_workqueue;
-/* Function that checks for overflows */
-static int check_flow(const char *buf)
-{
-
- int i;
- const char *overflow = "4294967295";
-
- i = strcmp(buf, overflow);
- pr_debug("buffer is ");
- if (i < 0)
- pr_debug("minor than");
- else if (i > 0) {
- pr_debug("greater than");
- pr_err("This value is greater that 32-bit value.\n");
- return -EINVAL;
- } else
- pr_debug("equals to");
- pr_debug(" %s\n", overflow);
-
- return 0;
-}
-
int pwm_register(struct pwm_device *pwm)
{
struct pwm_channel *p;
@@ -513,13 +491,6 @@ static ssize_t pwm_duty_ns_store(struct device *dev,
{
unsigned long duty_ns;
struct pwm_channel *p = dev_get_drvdata(dev);
- int ret;
-
- ret = check_flow(buf);
- if (ret) {
- pr_err("Overflow or underflow detected.\n");
- return -EINVAL;
- }
if (1 == sscanf(buf, "%lu", &duty_ns))
pwm_set_duty_ns(p, duty_ns);
@@ -539,13 +510,6 @@ static ssize_t pwm_period_ns_store(struct device *dev,
{
unsigned long period_ns;
struct pwm_channel *p = dev_get_drvdata(dev);
- int ret;
-
- ret = check_flow(buf);
- if (ret) {
- pr_err("Overflow or underflow detected.\n");
- return -EINVAL;
- }
if (1 == sscanf(buf, "%lu", &period_ns))
pwm_set_period_ns(p, period_ns);