History log of /linux-master/drivers/misc/ti-st/st_kim.c
Revision Date Author Comments
# f1a70d68 21-Feb-2024 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

misc: ti-st: st_kim: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/250337c967bdb5019a3c9fe8e0d082cd65400227.1708508896.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 14388ec0 03-Oct-2023 Justin Stitt <justinstitt@google.com>

drivers: misc: ti-st: replace deprecated strncpy with strscpy

`strncpy` is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string
interfaces.

We expect both `kim_data->dev_name` and `kim_gdata->dev_name` to be
NUL-terminated.

`kim_data->dev_name` seems to not require NUL-padding.

`kim_gdata` is already zero-allocated and as such does not require
NUL-padding:
| kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_KERNEL);

Considering the above, a suitable replacement is `strscpy` [2] due to
the fact that it guarantees NUL-termination on the destination buffer
without unnecessarily NUL-padding.

Let's also opt to use the more idiomatic strscpy usage of:
strscpy(dest, src, sizeof(dest))

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2]
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20231003-strncpy-drivers-misc-ti-st-st_kim-c-v2-1-79630447b0a1@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ead03e72 10-Aug-2023 Jiri Slaby (SUSE) <jirislaby@kernel.org>

misc: ti-st: make st_recv() conforming to tty_ldisc_ops::receive_buf()

That is change data type to u8 and count to unsigned int. And propagate
to both hooks (st_kim_recv() and kim_int_recv()).

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20230810091510.13006-19-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9b5752d1 31-Jul-2023 Jiri Slaby <jirislaby@kernel.org>

misc: ti-st: don't check for tty data == NULL

tty data passed to tty_ldisc_ops::receive_buf() are never NULL. Remove
this check.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20230731080244.2698-11-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a60b3017 31-Jul-2023 Jiri Slaby <jirislaby@kernel.org>

misc: ti-st: remove ptr from recv functions

ptr is the same as data, so use ptr directly as a parameter and drop the
useless local variable.

Likely, the two were introduced to have a different type. But 'char' and
'unsigned char' are the same in the kernel for a long time.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20230731080244.2698-10-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3caf1b48 26-Jun-2020 Lee Jones <lee.jones@linaro.org>

misc: ti-st: st_kim: Tidy-up bespoke commentry

If it's still in use and worth the effort, it sure looks like
this driver could do with a good scrub (clean).

This patch conserns itself with the non-standard comments located
thoughout the file.

It also fixes the following W=1 warnings by demoting the kerneldoc
function headers to standard comments, since there doesn't appear
to be a requirement for the function args to be documented:

/drivers/misc/ti-st/st_kim.c:42: warning: Function parameter or member 'id' not described in 'st_get_plat_device'
/drivers/misc/ti-st/st_kim.c:53: warning: Function parameter or member 'kim_gdata' not described in 'validate_firmware_response'
/drivers/misc/ti-st/st_kim.c:126: warning: Function parameter or member 'kim_gdata' not described in 'kim_int_recv'
/drivers/misc/ti-st/st_kim.c:126: warning: Function parameter or member 'data' not described in 'kim_int_recv'
/drivers/misc/ti-st/st_kim.c:126: warning: Function parameter or member 'count' not described in 'kim_int_recv'
/drivers/misc/ti-st/st_kim.c:272: warning: Function parameter or member 'kim_gdata' not described in 'download_firmware'
/drivers/misc/ti-st/st_kim.c:445: warning: Function parameter or member 'kim_data' not described in 'st_kim_start'
/drivers/misc/ti-st/st_kim.c:509: warning: Function parameter or member 'kim_data' not described in 'st_kim_stop'
/drivers/misc/ti-st/st_kim.c:661: warning: Function parameter or member 'core_data' not described in 'st_kim_ref'
/drivers/misc/ti-st/st_kim.c:661: warning: Function parameter or member 'id' not described in 'st_kim_ref'

Cc: Pavan Savoy <pavan_savoy@ti.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20200626130525.389469-4-lee.jones@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 909bad2d 11-Jun-2019 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ti-st: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the
return value. The function can work or not, but the code logic should
never do something different based on this.

Cc: linux-kernel@vger.kernel.org
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 45051539 29-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333

Based on 1 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license version 2 as
published by the free software foundation this program is
distributed in the hope that it will be useful but without any
warranty without even the implied warranty of merchantability or
fitness for a particular purpose see the gnu general public license
for more details you should have received a copy of the gnu general
public license along with this program if not write to the free
software foundation inc 59 temple place suite 330 boston ma 02111
1307 usa

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 136 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190530000436.384967451@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4b4bdfe7 29-Nov-2018 Colin Ian King <colin.king@canonical.com>

misc: ti-st: make array read_ver_cmd static, shrinks object size

Don't populate the const array read_ver_cmd on the stack but instead
make it static. Makes the object code smaller by 42 bytes:

Before:
text data bss dec hex filename
17262 6928 192 24382 5f3e drivers/misc/ti-st/st_kim.o

After:
text data bss dec hex filename
17156 6992 192 24340 5f14 drivers/misc/ti-st/st_kim.o

(gcc version 8.2.0 x86_64)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2796b43f 30-Nov-2018 Yangtao Li <tiny.windzz@gmail.com>

misc: remove GENWQE_DEBUGFS_RO()

We already have the DEFINE_SHOW_ATTRIBUTE.There is no need to define
such a macro,so remove GENWQE_DEBUGFS_RO.Also use DEFINE_SHOW_ATTRIBUTE
to simplify some code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 81ae962d 27-Jul-2018 Anton Vasilyev <vasilyev@ispras.ru>

misc: ti-st: Fix memory leak in the error path of probe()

Free resources instead of direct return of the error code if kim_probe
fails.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 53e44782 03-Jul-2018 Colin Ian King <colin.king@canonical.com>

misc: ti-st: remove redundant variable 'type'

Variable type is being assigned but is never used hence it is
redundant and can be removed.

Cleans up clang warning:
warning: variable 'type' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 24b6d3ee 10-Apr-2018 Jia-Ju Bai <baijiaju1990@gmail.com>

misc: ti-st: Replace GFP_ATOMIC with GFP_KERNEL in kim_probe

kim_probe() is never called in atomic context.
This function is only set as ".probe" in struct platform_driver.

Despite never getting called from atomic context,
kim_probe() calls kzalloc() with GFP_ATOMIC,
which does not sleep for allocation.
GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
which can sleep and improve the possibility of sucessful allocation.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9045f182 03-Aug-2017 Arvind Yadav <arvind.yadav.cs@gmail.com>

misc: ti-st: constify attribute_group structures.

attribute_group are not supposed to change at runtime. All functions
working with attribute_group provided by <linux/sysfs.h> work with
const attribute_group. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 59ae1d12 16-Jun-2017 Johannes Berg <johannes.berg@intel.com>

networking: introduce and use skb_put_data()

A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.

An spatch similar to the one for skb_put_zero() converts many
of the places using it:

@@
identifier p, p2;
expression len, skb, data;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_data(skb, data, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_data(skb, data, len);
)
(
p2 = (t2)p;
-memcpy(p2, data, len);
|
-memcpy(p, data, len);
)

@@
type t, t2;
identifier p, p2;
expression skb, data;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
)
(
p2 = (t2)p;
-memcpy(p2, data, sizeof(*p));
|
-memcpy(p, data, sizeof(*p));
)

@@
expression skb, len, data;
@@
-memcpy(skb_put(skb, len), data, len);
+skb_put_data(skb, data, len);

(again, manually post-processed to retain some comments)

Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# 8d026465 15-Apr-2016 Daniel Wagner <daniel.wagner@bmw-carit.de>

ti-st: Fix complete_all() wrong usage

complete_all() should only be called once, doing it twice is a clear bug.

8565adbc8214 ("drivers/misc/ti-st: fix read fw version cmd") added the
additional complete_all() call. Since we call complete_all() when
leaving the function we can drop the complete_all() call inside
true branch of the if statement.

Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Cc: Pavan Savoy <pavan_savoy@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 141124e6 10-Jul-2015 Krzysztof Kozlowski <krzk@kernel.org>

misc: Drop owner assignment from i2c_driver

i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 513da46d 23-Jun-2015 Jürg Billeter <j@bitron.ch>

ti-st: st_kim: use gpio_set_value_cansleep to fix warning

GPIO accessor functions may sleep.

Signed-off-by: Jürg Billeter <j@bitron.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c0bd1b9e 22-Jul-2015 Rob Herring <robh@kernel.org>

Revert "ti-st: add device tree support"

This reverts commit 46d0d33350e9b32642d745a8b46a954910196b4d.

This binding is horrible and never should have been merged. It is not
documented nor are there any in tree users, so reverting it will not
break anything we care about. Lets revert it before we do have users.

The problems with it are:

- It is not documented.

- The GPIO connection is described with a custom property and uses Linux
GPIO numbering.

- The UART connection is described using the Linux tty device name.

Cc: Gigi Joseph <gigi.joseph@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 14e51e59 10-Jul-2015 Krzysztof Kozlowski <krzk@kernel.org>

misc: Drop owner assignment from i2c_driver

i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0810f18f 12-May-2015 Colin Ian King <colin.king@canonical.com>

ti-st: handle null allocation return correctly.

static analysis with smatch picked up the following error:

get_platform_data() error: potential null dereference 'dt_pdata'.
(kzalloc returns null)

Instead, the code should return NULL to avoid the following null
pointer deference. Also, remove the error message as it is
redundant, the caller emits an error message to alert of a
failure anyhow.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 63e144c9 15-Jan-2015 Dan Carpenter <dan.carpenter@oracle.com>

ti-st: clean up data types (fix harmless memory corruption)

The big issue here is:

of_property_read_u32(np, "flow_cntrl", (u32 *)&dt_pdata->flow_cntrl);

"->flow_cntrl" is a char so when we write a 32 bit number to it then it
corrupts past the end of the char. It's probably hard to notice because
the struct has padding so the code works on little endian systems. But
on a big endian system the code would fail and on a 64 bit, big endian
systems then "nshutdown_gpio" and "baud_rate" would be buggy as well.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3f46d81a 19-Jan-2015 Nicholas Mc Guire <der.herr@hofr.at>

misc: ti-st: add handling of the signal case

if(!wait_for_completion_interruptible_timeout(...))
only handles the timeout case - this patch adds handling the
signal case the same as timeout.

Only the timeout case was being handled, the signal case
(-ERESTARTSYS) was treated just like the case of successful
completion, which is most likely not reasonable.

read_local_version() is called from download_firmware() where
it checks for !=0 return, so the error handling logic should be
preserved correctly.

download_firmware() is called from st_kim_start() which is
checking for !=0 return, so the error handling logic should be
preserved correctly

Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 868eba8e 08-Jan-2015 Gigi Joseph <gigi.joseph@gmail.com>

drivers: misc: ti-st: fix null pointer exception in st_kim_ref()

st_kim_ref() does not take care of the fact that platform_get_drvdata() might return NULL. On AM437x EVM, this causes the platform to stop booting as soon as the module is inserted.

This patch fixes the issue by checking for NULL return value. Oops log follows.

I have not tested BT functionality after this patch. But at least the platform boots now.

[ 12.675697] Unable to handle kernel NULL pointer dereference at virtual address 0000005c
[ 12.684310] pgd = c0004000
[ 12.687157] [0000005c] *pgd=00000000
[ 12.690927] Internal error: Oops: 17 [#1] SMP ARM
[ 12.695873] Modules linked in: btwilink bluetooth ti_vpfe dwc3(+) ov2659 videobuf2_core v4l2_common videodev ti_am335x_adc 6lowpan_iphc matrix_keypad panel_dpi kfifo_buf pixcir_i2c_ts media industrialio videobuf2_dma_contig c_can_platform videobuf2_memops dwc3_omap c_can can_dev
[ 12.721969] CPU: 0 PID: 1235 Comm: kworker/u3:0 Not tainted 3.14.25-02445-g9036ac6daed6 #128
[ 12.730937] Workqueue: hci0 hci_power_on [bluetooth]
[ 12.736165] task: ebd93b40 ti: ecd7c000 task.ti: ecd7c000
[ 12.741856] PC is at st_kim_ref+0x30/0x40
[ 12.746071] LR is at st_kim_ref+0x30/0x40
[ 12.750289] pc : [<c03caf58>] lr : [<c03caf58>] psr: a0000013
[ 12.750289] sp : ecd7de08 ip : ecd7de08 fp : ecd7de1c
[ 12.762365] r10: bf1e710c r9 : bf1e70ec r8 : bf1e7964
[ 12.767858] r7 : ebd2fd50 r6 : bf1e7964 r5 : 00000000 r4 : ecd7de24
[ 12.774723] r3 : c0957208 r2 : 00000000 r1 : c0957208 r0 : 00000000
[ 12.781589] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
[ 12.789274] Control: 10c5387d Table: abde4059 DAC: 00000015
[ 12.795315] Process kworker/u3:0 (pid: 1235, stack limit = 0xecd7c248)

Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Gigi Joseph <gigi.joseph@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c6ec0fb4 08-Jan-2015 Gigi Joseph <gigi.joseph@gmail.com>

drivers: misc: ti-st: fix debugfs creation error handling

In case the debugfs creation fails the whole init process was failing.
There is no need to do this as the shared transport can work without it.
Fix it so it just reports the failure and continue.

Signed-off-by: Eyal Reizer <eyalr@ti.com>
Signed-off-by: Gigi Joseph <gigi.joseph@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4b4aa3ab 08-Jan-2015 Gigi Joseph <gigi.joseph@gmail.com>

st_kim: allow suspend if callback is not registered

Suspend/resume was failing if callbacks were not registered.
As it is ok not to do anything when suspending fix this
so it soen't return an error and allow the system to suspend.

Signed-off-by: Eyal Reizer <eyalr@ti.com>
Signed-off-by: Gigi Joseph <gigi.joseph@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 46d0d333 08-Jan-2015 Gigi Joseph <gigi.joseph@gmail.com>

ti-st: add device tree support

When using device tree, driver configuration data need to be read from
device node.
Add support for getting the platform data information from the device
tree information stored in the .dtb file in case it exists.

Signed-off-by: Eyal Reizer <eyalr@ti.com>
Signed-off-by: bvijay <bvijay@ti.com>
Diff rendering mode:inlineside by side

Signed-off-by: Gigi Joseph <gigi.joseph@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 17149e4c 20-Oct-2014 Wolfram Sang <wsa@kernel.org>

misc: ti-st: drop owner assignment from platform_drivers

A platform_driver does not need to set an owner, it will be populated by the
driver core.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 4dcc2ab3 22-Jul-2014 Enric Balletbo i Serra <eballetbo@iseebcn.com>

drivers/misc/ti-st: Load firmware from ti-connectivity directory.

Looks like the default location for TI firmware is inside the ti-connectivity
directory, to be coherent with other firmware request used by TI drivers, load
the TIInit firmware from this directory instead of /lib/firmware directly.

Signed-off-by: Enric Balletbo i Serra <eballetbo@iseebcn.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3768528a 16-Jun-2014 Robin van der Gracht <robin@protonic.nl>

ti-st: st-kim: Dont let probe fail when debugfs is disabled

Signed-off-by: Robin van der Gracht <robin@protonic.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 94459a97 29-Nov-2013 Peter Hurley <peter@hurleysoftware.com>

drivers/misc/ti-st: Prefer tty_driver_flush_buffer

The tty core provides an interface for flushing the driver's
write buffer: tty_driver_flush_buffer(); prefer the provided
interface over open-coded. Open-coding can lead to errors
such as the duplicated call in the st_kim driver.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 16735d02 14-Nov-2013 Wolfram Sang <wsa@kernel.org>

tree-wide: use reinit_completion instead of INIT_COMPLETION

Use this new function to make code more comprehensible, since we are
reinitialzing the completion, not initializing.

[akpm@linux-foundation.org: linux-next resyncs]
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org> (personally at LCE13)
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 9093ca88 23-May-2013 Jingoo Han <jg1.han@samsung.com>

misc: use platform_{get,set}_drvdata()

Use the wrapper functions for getting and setting the driver data using
platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev,
so we can directly pass a struct platform_device.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a7e2ca17 21-Jan-2013 Luciano Coelho <coelho@ti.com>

Revert "drivers/misc/ti-st: remove gpio handling"

This reverts commit eccf2979b2c034b516e01b8a104c3739f7ef07d1.

The reason is that it broke TI WiLink shared transport on Panda.
Also, callback functions should not be added to board files anymore,
so revert to implementing the power functions in the driver itself.

Additionally, changed a variable name ('status' to 'err') so that this
revert compiles properly.

Cc: stable <stable@vger.kernel.org> [3.7]
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 55cd0e36 21-Jan-2013 Luciano Coelho <coelho@ti.com>

Revert "drivers/misc/ti-st: remove gpio handling"

This reverts commit eccf2979b2c034b516e01b8a104c3739f7ef07d1.

The reason is that it broke TI WiLink shared transport on Panda.
Also, callback functions should not be added to board files anymore,
so revert to implementing the power functions in the driver itself.

Additionally, changed a variable name ('status' to 'err') so that this
revert compiles properly.

Cc: stable <stable@vger.kernel.org> [3.7]
Signed-off-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b2997387 22-Nov-2012 Matthias Kaehlcke <matthias@kaehlcke.net>

misc/st_kim: Free resources in the error path of probe()

Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8565adbc 03-Aug-2012 Pavan Savoy <pavan_savoy@ti.com>

drivers/misc/ti-st: fix read fw version cmd

If the read firmware version response from the chip is split into multiple
frames of UART buffer being received by the host, the TI-ST driver as of today
is unable to put the pieces of response together unlike other responses.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 53702358 03-Aug-2012 Pavan Savoy <pavan_savoy@ti.com>

drivers/misc/ti-st: use cpu friendly completions

Be nice to CPU and don't hog the resources, use a nice wait_for_interruptible
timeout for completions instead of wait_for_timeout which is
non-interruptible.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b64365a5 03-Aug-2012 Pavan Savoy <pavan_savoy@ti.com>

drivers/misc/ti-st: chip_disable on timeout

If the communication with the WiLink breaks down for whatever reasons & the
ti-st driver is unable to un-install the line-discipline during clean-up in
st_kim_stop, the GPIO should be held low (BT_EN=0) & the platform's chip
disable hook shall also be called.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 27712b39 03-Aug-2012 Pavan Savoy <pavan_savoy@ti.com>

drivers/misc/ti-st: remove sparse warnings

remove sparse warnings by assigning right storage specifiers to functions and
also clean-up the declarations in the include/linux/ti_wilink_st.h

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# eccf2979 03-Aug-2012 Pavan Savoy <pavan_savoy@ti.com>

drivers/misc/ti-st: remove gpio handling

A platform hook to enable/disable the chip was introduced to perform specific
activities to power-up and power-down the WL chip.
Moving the power-up/down sequence also there makes more sense, since different
platforms have begun to have their own ways to power-up/down the chip.
This patch removes all of the gpio handling done by the driver in
st_kim_start/st_kim_stop & any of the gpio request done in the probe function.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b00e126f 22-Jan-2012 Axel Lin <axel.lin@gmail.com>

MISC: convert drivers/misc/* to use module_platform_driver()

This patch converts the drivers in drivers/misc/* to use the
module_platform_driver() macro which makes the code smaller and a bit
simpler.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Ira W. Snyder <iws@ovro.caltech.edu>
Cc: Pavan Savoy <pavan_savoy@ti.com>
Cc: Donggeun Kim <dg77.kim@samsung.com>
Acked-By: Pratyush Anand <pratyush.anand@st.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 933aae54 15-Dec-2011 Pavan Savoy <pavan_savoy@ti.com>

drivers:misc: ti-st: DEBUG uart, baud rate mods

To debug different UARTs at different baud-rates connected to the WiLink
connectivity combo-chipset, this patch enables the debugging code so that upon
boot different UARTs at different baud-rates can be tried out to verify the
interface with WiLink.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 18ccecf9 15-Dec-2011 Pavan Savoy <pavan_savoy@ti.com>

drivers:misc: ti-st: flush UART upon fw failure

Upon failure to read firmware version from chip or upon failure in responses
to firmware download the UART needs to be flushed of its existing buffers so
that the UIM can restart UART properly.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# eb12a679 03-Jul-2011 Paul Gortmaker <paul.gortmaker@windriver.com>

drivers/misc: Add module.h to files who are really modular.

These files really need the full module.h header file present, but
were just getting it implicitly before. Fix it up in advance so we
avoid build failures once the cleanup commit is present.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>


# 76ff0e64 10-Aug-2011 Pavan Savoy <pavan_savoy@ti.com>

drivers:misc: ti-st: free skb on firmware download

If during validation of the firmware download the data doesn't match what is
expected out of the chip, this calls for a firmware download failure and a
retry.
Free the SKB which collects response during such scenarios.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# d0344ef6 10-Aug-2011 Pavan Savoy <pavan_savoy@ti.com>

drivers:misc: ti-st: wait for completion at fail

When the line discipline install fails for reasons such as missing user-space
UIM or broken communication between UIM and ST driver, then the ST
attempts/retries to request for ldisc installation again.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 2f81a02c 10-Aug-2011 Pavan Savoy <pavan_savoy@ti.com>

drivers:misc: ti-st: reinit completion before send

download firmware behaves differently at different times, when logs are
enabled and the system is loaded, the wait_for_completion is able to wait for
every send, However during other times the wait does not happen.

So, for reliability reinitializing the completion before every send, makes
sure the wait happens for every send.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 74a4fcf1 10-Aug-2011 Pavan Savoy <pavan_savoy@ti.com>

drivers:misc: ti-st: reinit completion on ver read

After the version information has been read, the completion which assists in
wait_for_completion during the firmware send/wait sequence is being re-used
and hence this needs to be re-initialised for fool proof firmware download
retries.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 0d7c5f25 10-Aug-2011 Pavan Savoy <pavan_savoy@ti.com>

drivers:misc:ti-st: platform hooks for chip states

Certain platform specific or Host-WiLink Interface specific actions would be
required to be taken when the chip is being enabled and after the chip is
disabled such as configuration of the mux modes for the GPIO of host connected
to the nshutdown of the chip or relinquishing UART after the chip is disabled.

Similar actions can also be taken when the chip is in deep sleep or when the
chip is awake. Performance enhancements such as configuring the host to run
faster when chip is awake and slower when chip is asleep can also be made
here.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 9d031d94 23-May-2011 Shahar Lev <shahar@wizery.com>

drivers:misc: ti-st: fix skipping of change remote baud

Before the incrementing of ptr in skip_change_remote_baud,
it points to cur_action, but the increment is done by
the size of nxt_action instead. This could cause ptr
to not point to a bts_action structure, which is
harmful for the increment of ptr done in download_firmware.
Therefore, the skipping is first done for cur_action.

Signed-off-by: Shahar Lev <shahar@wizery.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 7316a9f2 23-May-2011 Steven Rostedt <rostedt@goodmis.org>

st_kim: Handle case of no device found for ID 0

Running ktest.pl, I hit this bug:

[ 19.780654] BUG: unable to handle kernel NULL pointer dereference at 0000000c
[ 19.780660] IP: [<c112efcd>] dev_get_drvdata+0xc/0x46
[ 19.780669] *pdpt = 0000000031daf001 *pde = 0000000000000000
[ 19.780673] Oops: 0000 [#1] SMP
[ 19.780680] Dumping ftrace buffer:^M
[ 19.780685] (ftrace buffer empty)
[ 19.780687] Modules linked in: ide_pci_generic firewire_ohci firewire_core evbug crc_itu_t e1000 ide_core i2c_i801 iTCO_wdt
[ 19.780697]
[ 19.780700] Pid: 346, comm: v4l_id Not tainted 2.6.39-test-02740-gcaebc16-dirty #4 /DG965MQ
[ 19.780706] EIP: 0060:[<c112efcd>] EFLAGS: 00010202 CPU: 0
[ 19.780709] EIP is at dev_get_drvdata+0xc/0x46
[ 19.780712] EAX: 00000008 EBX: f1e37da4 ECX: 00000000 EDX: 00000000
[ 19.780715] ESI: f1c3f200 EDI: c33ec95c EBP: f1e37d80 ESP: f1e37d80
[ 19.780718] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
[ 19.780721] Process v4l_id (pid: 346, ti=f1e36000 task=f2bc2a60 task.ti=f1e36000)
[ 19.780723] Stack:
[ 19.780725] f1e37d8c c117d395 c33ec93c f1e37db4 c117a0f9 00000002 00000000 c1725e54
[ 19.780732] 00000001 00000007 f2918c90 f1c3f200 c33ec95c f1e37dd4 c1789d3d 22222222
[ 19.780740] 22222222 22222222 f2918c90 f1c3f200 f29194f4 f1e37de8 c178d5c4 c1725e54
[ 19.780747] Call Trace:
[ 19.780752] [<c117d395>] st_kim_ref+0x28/0x41
[ 19.780756] [<c117a0f9>] st_register+0x29/0x562
[ 19.780761] [<c1725e54>] ? v4l2_open+0x111/0x1e3
[ 19.780766] [<c1789d3d>] fmc_prepare+0x97/0x424
[ 19.780770] [<c178d5c4>] fm_v4l2_fops_open+0x70/0x106
[ 19.780773] [<c1725e54>] ? v4l2_open+0x111/0x1e3
[ 19.780777] [<c1725e9b>] v4l2_open+0x158/0x1e3
[ 19.780782] [<c065173b>] chrdev_open+0x22c/0x276
[ 19.780787] [<c0647c4e>] __dentry_open+0x35c/0x581
[ 19.780792] [<c06498f9>] nameidata_to_filp+0x7c/0x96
[ 19.780795] [<c065150f>] ? cdev_put+0x57/0x57
[ 19.780800] [<c0660cad>] do_last+0x743/0x9d4
[ 19.780804] [<c065d5fc>] ? path_init+0x1ee/0x596
[ 19.780808] [<c0661481>] path_openat+0x10c/0x597
[ 19.780813] [<c05204a1>] ? trace_hardirqs_off+0x27/0x37
[ 19.780817] [<c0509651>] ? local_clock+0x78/0xc7
[ 19.780821] [<c0661945>] do_filp_open+0x39/0xc2
[ 19.780827] [<c1cabc76>] ? _raw_spin_unlock+0x4c/0x5d^M
[ 19.780831] [<c0674ccd>] ? alloc_fd+0x19e/0x1b7
[ 19.780836] [<c06499ca>] do_sys_open+0xb7/0x1bd
[ 19.780840] [<c0608eea>] ? sys_munmap+0x78/0x8d
[ 19.780844] [<c0649b06>] sys_open+0x36/0x58
[ 19.780849] [<c1cb809f>] sysenter_do_call+0x12/0x38
[ 19.780852] Code: d8 2f 20 c3 01 83 15 dc 2f 20 c3 00 f0 ff 00 83 05 e0 2f 20 c3 01 83 15 e4 2f 20 c3 00 5d c3 55 89 e5 3e 8d 74 26 00 85 c0 74 28 <8b> 40 04 83 05 e8 2f 20 c3 01 83 15 ec 2f 20 c3 00 85 c0 74 13 ^M
[ 19.780889] EIP: [<c112efcd>] dev_get_drvdata+0xc/0x46 SS:ESP 0068:f1e37d80
[ 19.780894] CR2: 000000000000000c
[ 19.780898] ---[ end trace e7d1d0f6a2d1d390 ]---

The id of 0 passed to st_kim_ref() found no device, keeping pdev null,
and causing pdev->dev cause a NULL pointer dereference. After having
st_kim_ref() check for NULL, the st_unregister() function needed to be
updated to handle the case that st_gdata was not set by the
st_kim_ref().

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 773d6790 26-Apr-2011 Randy Dunlap <randy.dunlap@oracle.com>

misc: fix ti-st build issues

st_drv uses skb*() interfaces, so it should depend on NET.
It also uses GPIO interfaces, so it should depend on GPIOLIB.

st_kim.c uses syss_*() calls, so it should #include
<linux/sysfs.h>.

Fixes these observed build errors:
ERROR: "skb_queue_purge" [drivers/misc/ti-st/st_drv.ko] undefined!
ERROR: "skb_pull" [drivers/misc/ti-st/st_drv.ko] undefined!
ERROR: "skb_queue_tail" [drivers/misc/ti-st/st_drv.ko] undefined!
ERROR: "__alloc_skb" [drivers/misc/ti-st/st_drv.ko] undefined!
ERROR: "kfree_skb" [drivers/misc/ti-st/st_drv.ko] undefined!
ERROR: "skb_dequeue" [drivers/misc/ti-st/st_drv.ko] undefined!
ERROR: "skb_put" [drivers/misc/ti-st/st_drv.ko] undefined!

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 25985edc 30-Mar-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi>

Fix common misspellings

Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>


# 781a7395 04-Feb-2011 Pavan Savoy <pavan_savoy@ti.com>

drivers:misc: ti-st: remove multiple gpio handling

TI shared transport driver previously intended to expose rfkill
entries for each of the protocol gpio that the chip would have.
However now in case such gpios exist, which requires to be enabled
for a specific protocol, the responsibility lay on protocol driver.
This patch removes the request/free of multiple gpios, rfkill struct
references and also removes the chip_toggle function.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# ef04d121 04-Feb-2011 Pavan Savoy <pavan_savoy@ti.com>

drivers:misc: ti-st: firmware download optimization

To fasten the process of firmware download, the chip allows
disabling of the command complete event generation from host.
In these cases, only few very essential commands would have
the command complete events and hence the wait associated with
them.

So now the driver would wait for a command complete event, only
when it comes across a wait event during firmware parsing.
This would also mean we need to skip not just the change baud
rate command but also the wait for it.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 70442664 04-Feb-2011 Pavan Savoy <pavan_savoy@ti.com>

drivers:misc: ti-st: fix error codes

set-right the error codes that the shared transport driver
returns.
Instead of magic numbers like -1, return relevant codes such as
ETIMEDOUT or EIO, EAGAIN when wait times out or uart write bytes don't
match expected value or when registration fails and needs to be
attempted again.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# ec60d0ad 04-Feb-2011 Pavan Savoy <pavan_savoy@ti.com>

drivers:misc: ti-st: move from rfkill to sysfs

The communication between ST KIM and UIM was interfaced
over the /dev/rfkill device node.
Move the interface to a simpler less abusive sysfs entry
mechanism and document it in Documentation/ABI/testing/
under sysfs-platform-kim.

Shared transport driver would now read the UART details
originally received by bootloader or firmware as platform
data.
The data read will be shared over sysfs entries for the user-space
UIM or other n/w manager/plugins to be read, and assist the driver
by opening up the UART, setting the baud-rate and installing the
line discipline.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 5c88b021 04-Feb-2011 Pavan Savoy <pavan_savoy@ti.com>

drivers:misc: ti-st: register with channel IDs

The architecture of shared transport had begun with individual
protocols like bluetooth, fm and gps telling the shared transport
what sort of protocol they are and then expecting the ST driver
to parse the incoming data from chip and forward data only
relevant to the protocol drivers.

This change would mean each protocol drivers would also send
information to ST driver as to how to intrepret their protocol
data coming out of the chip.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 73f12e8d 12-Oct-2010 Pavan Savoy <pavan_savoy@ti.com>

drivers: misc: ti-st: fix review comments

Based on comments from Jiri Slaby, drop the register
storage specifier, remove the unused code, cleanup
the const to non-const type casting.
Also make the line discipline ops structure static, since
its a singleton, unmodified structure which need not be
in heap.

Reported-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# a0cc2f3b 05-Oct-2010 Pavan Savoy <pavan_savoy@ti.com>

staging: ti-st: move TI_ST from staging to misc/

move the 3 source files st_core.c, st_kim.c and st_ll.c
from staging to drivers/misc/.

Texas Instrument's WiLink 7 chipset packs wireless technologies like
Bluetooth, FM, GPS and WLAN into a single die.
Among these the Bluetooth, FM Rx/Tx and GPS are interfaced to a apps processor
over a single UART.

This line discipline driver allows various protocol drivers such as Bluetooth
BlueZ driver, FM V4L2 driver and GPS simple character device driver
to communicate with its relevant core in the chip.

Each protocol or technologies use a logical channel to communicate with chip.
Bluetooth uses the HCI-H4 [channels 1-4], FM uses a CH-8 and
GPS a CH-9 protocol. The driver also constitutes the TI HCI-LL Power
Management protocol which use channels 30-33.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>