From 5023a5ca8e144846ec0646554336000abb11e04f Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Thu, 16 Apr 2015 19:05:18 +0200 Subject: HSI: cmt_speech: fix timestamp interface The user interface for timestamps in the new cmt_speech driver is broken in multiple ways: - The layout is incompatible between 32-bit and 64-bit user space, because of the size differences in 'struct timespec'. This means that the driver can not work when used with 32-bit user space on a 64-bit kernel. - As there are plans to change 32-bit user space to use a 64-bit time_t type in the future, it will also be incompatible with new 32-bit user space. - It is using ktime_get_ts under it's deprecated alias (do_posix_clock_monotonic_gettime). To keep support for the user space tools written for this driver (which have lived many years out-of-tree), the interface has been hardened to unsigned 32-bit values. Reported-by: Arnd Bergmann Signed-off-by: Sebastian Reichel diff --git a/drivers/hsi/clients/cmt_speech.c b/drivers/hsi/clients/cmt_speech.c index 4983529..d04643f 100644 --- a/drivers/hsi/clients/cmt_speech.c +++ b/drivers/hsi/clients/cmt_speech.c @@ -451,9 +451,14 @@ static void cs_hsi_read_on_control_complete(struct hsi_msg *msg) dev_dbg(&hi->cl->device, "Read on control: %08X\n", cmd); cs_release_cmd(msg); if (hi->flags & CS_FEAT_TSTAMP_RX_CTRL) { - struct timespec *tstamp = + struct timespec tspec; + struct cs_timestamp *tstamp = &hi->mmap_cfg->tstamp_rx_ctrl; - do_posix_clock_monotonic_gettime(tstamp); + + ktime_get_ts(&tspec); + + tstamp->tv_sec = (__u32) tspec.tv_sec; + tstamp->tv_nsec = (__u32) tspec.tv_nsec; } spin_unlock(&hi->lock); diff --git a/include/uapi/linux/hsi/cs-protocol.h b/include/uapi/linux/hsi/cs-protocol.h index 4957bba..f153d6e 100644 --- a/include/uapi/linux/hsi/cs-protocol.h +++ b/include/uapi/linux/hsi/cs-protocol.h @@ -76,6 +76,15 @@ struct cs_buffer_config { }; /* + * struct for monotonic timestamp taken when the + * last control command was received + */ +struct cs_timestamp { + __u32 tv_sec; /* seconds */ + __u32 tv_nsec; /* nanoseconds */ +}; + +/* * Struct describing the layout and contents of the driver mmap area. * This information is meant as read-only information for the application. */ @@ -91,11 +100,8 @@ struct cs_mmap_config_block { __u32 rx_ptr; __u32 rx_ptr_boundary; __u32 reserved3[2]; - /* - * if enabled with CS_FEAT_TSTAMP_RX_CTRL, monotonic - * timestamp taken when the last control command was received - */ - struct timespec tstamp_rx_ctrl; + /* enabled with CS_FEAT_TSTAMP_RX_CTRL */ + struct cs_timestamp tstamp_rx_ctrl; }; #define CS_IO_MAGIC 'C' -- cgit v0.10.2 From 505875e12a6c3bf08f333d1dba59e5e14f883c05 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Mon, 4 May 2015 15:51:36 +0200 Subject: HSI: nokia-modem: Reduce missing driver message to debug level Reduce message priority from dev_err to dev_dbg for missing cmt-speech or ssi-protocol drivers, since they will be probed again and it may result in spamming the boot log. Reported-by: Aaro Koskinen Signed-off-by: Sebastian Reichel diff --git a/drivers/hsi/clients/nokia-modem.c b/drivers/hsi/clients/nokia-modem.c index bbb1923..f50d110 100644 --- a/drivers/hsi/clients/nokia-modem.c +++ b/drivers/hsi/clients/nokia-modem.c @@ -208,7 +208,7 @@ static int nokia_modem_probe(struct device *dev) err = device_attach(&modem->ssi_protocol->device); if (err == 0) { - dev_err(dev, "Missing ssi-protocol driver\n"); + dev_dbg(dev, "Missing ssi-protocol driver\n"); err = -EPROBE_DEFER; goto error3; } else if (err < 0) { @@ -231,7 +231,7 @@ static int nokia_modem_probe(struct device *dev) err = device_attach(&modem->cmt_speech->device); if (err == 0) { - dev_err(dev, "Missing cmt-speech driver\n"); + dev_dbg(dev, "Missing cmt-speech driver\n"); err = -EPROBE_DEFER; goto error4; } else if (err < 0) { -- cgit v0.10.2 From f451e76f896922137f8316cb071ae2cab78091ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Mon, 8 Jun 2015 11:53:45 +0200 Subject: HSI: nokia-modem: use flags argument of devm_gpiod_get to set direction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions) which appeared in v3.17-rc1, the gpiod_get* functions take an additional parameter that allows to specify direction and initial value for output. Use this to simplify the driver. Furthermore this is one caller less that stops us making the flags argument to gpiod_get*() mandatory. Signed-off-by: Uwe Kleine-König Acked-by: Alexandre Courbot Signed-off-by: Sebastian Reichel diff --git a/drivers/hsi/clients/nokia-modem.c b/drivers/hsi/clients/nokia-modem.c index f50d110..7f82c91 100644 --- a/drivers/hsi/clients/nokia-modem.c +++ b/drivers/hsi/clients/nokia-modem.c @@ -112,7 +112,8 @@ static int nokia_modem_gpio_probe(struct device *dev) modem->gpio_amount = gpio_count; for (i = 0; i < gpio_count; i++) { - modem->gpios[i].gpio = devm_gpiod_get_index(dev, NULL, i); + modem->gpios[i].gpio = devm_gpiod_get_index(dev, NULL, i, + GPIOD_OUT_LOW); if (IS_ERR(modem->gpios[i].gpio)) { dev_err(dev, "Could not get gpio %d\n", i); return PTR_ERR(modem->gpios[i].gpio); @@ -125,10 +126,6 @@ static int nokia_modem_gpio_probe(struct device *dev) return err; } - err = gpiod_direction_output(modem->gpios[i].gpio, 0); - if (err) - return err; - err = gpiod_export(modem->gpios[i].gpio, 0); if (err) return err; -- cgit v0.10.2