diff options
author | Jonathan Cameron <jic23@cam.ac.uk> | 2010-07-11 15:39:08 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-07-22 18:38:27 (GMT) |
commit | 3c9bbf58b2a7e9099343d36a2c0b206f8c2450df (patch) | |
tree | 19247eebf1b491a86d9c9d64cf123fd70b9dd356 /drivers/staging/iio/trigger | |
parent | cb46f472cbb08c44ae47a5bea80207c4e4407ee3 (diff) | |
download | linux-fsl-qoriq-3c9bbf58b2a7e9099343d36a2c0b206f8c2450df.tar.xz |
staging: iio: Use kasprintf to allocate and fill trig->name
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/trigger')
-rw-r--r-- | drivers/staging/iio/trigger/iio-trig-gpio.c | 9 | ||||
-rw-r--r-- | drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 12 |
2 files changed, 5 insertions, 16 deletions
diff --git a/drivers/staging/iio/trigger/iio-trig-gpio.c b/drivers/staging/iio/trigger/iio-trig-gpio.c index 1da285d..3c0614e 100644 --- a/drivers/staging/iio/trigger/iio-trig-gpio.c +++ b/drivers/staging/iio/trigger/iio-trig-gpio.c @@ -93,16 +93,11 @@ static int iio_gpio_trigger_probe(struct platform_device *pdev) trig->private_data = trig_info; trig_info->irq = irq; trig->owner = THIS_MODULE; - trig->name = kmalloc(IIO_TRIGGER_NAME_LENGTH, - GFP_KERNEL); - if (!trig->name) { + trig->name = kasprintf(GFP_KERNEL, "irqtrig%d", irq); + if (trig->name == NULL) { ret = -ENOMEM; goto error_free_trig_info; } - snprintf((char *)trig->name, - IIO_TRIGGER_NAME_LENGTH, - "irqtrig%d", irq); - ret = request_irq(irq, iio_gpio_trigger_poll, irqflags, trig->name, trig); if (ret) { diff --git a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c index 4ee3ae1..d8c58cb 100644 --- a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c +++ b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c @@ -25,7 +25,6 @@ static DEFINE_MUTEX(iio_prtc_trigger_list_lock); struct iio_prtc_trigger_info { struct rtc_device *rtc; int frequency; - char *name; struct rtc_task task; }; @@ -78,8 +77,7 @@ static ssize_t iio_trig_periodic_read_name(struct device *dev, char *buf) { struct iio_trigger *trig = dev_get_drvdata(dev); - struct iio_prtc_trigger_info *trig_info = trig->private_data; - return sprintf(buf, "%s\n", trig_info->name); + return sprintf(buf, "%s\n", trig->name); } static DEVICE_ATTR(name, S_IRUGO, @@ -129,16 +127,12 @@ static int iio_trig_periodic_rtc_probe(struct platform_device *dev) trig->private_data = trig_info; trig->owner = THIS_MODULE; trig->set_trigger_state = &iio_trig_periodic_rtc_set_state; - trig->name = kmalloc(IIO_TRIGGER_NAME_LENGTH, GFP_KERNEL); + trig->name = kasprintf(GFP_KERNEL, "periodic%s", pdata[i]); if (trig->name == NULL) { ret = -ENOMEM; goto error_free_trig_info; } - snprintf((char *)trig->name, - IIO_TRIGGER_NAME_LENGTH, - "periodic%s", - pdata[i]); - trig_info->name = (char *)trig->name; + /* RTC access */ trig_info->rtc = rtc_class_open(pdata[i]); |