···80extern long st_register(struct st_proto_s *);81extern long st_unregister(enum proto_type);8283-extern struct platform_device *st_get_plat_device(void);84#endif /* ST_H */
···80extern long st_register(struct st_proto_s *);81extern long st_unregister(enum proto_type);82083#endif /* ST_H */
+4-5
drivers/staging/ti-st/st_core.c
···38#include "st_ll.h"39#include "st.h"4041-#define VERBOSE42/* strings to be used for rfkill entries and by43 * ST Core to be used for sysfs debug entry44 */···580 long err = 0;581 unsigned long flags = 0;582583- st_kim_ref(&st_gdata);584 pr_info("%s(%d) ", __func__, new_proto->type);585 if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL586 || new_proto->reg_complete_cb == NULL) {···712713 pr_debug("%s: %d ", __func__, type);714715- st_kim_ref(&st_gdata);716 if (type < ST_BT || type >= ST_MAX) {717 pr_err(" protocol %d not supported", type);718 return -EPROTONOSUPPORT;···766#endif767 long len;768769- st_kim_ref(&st_gdata);770 if (unlikely(skb == NULL || st_gdata == NULL771 || st_gdata->tty == NULL)) {772 pr_err("data/tty unavailable to perform write");···817 struct st_data_s *st_gdata;818 pr_info("%s ", __func__);819820- st_kim_ref(&st_gdata);821 st_gdata->tty = tty;822 tty->disc_data = st_gdata;823
···38#include "st_ll.h"39#include "st.h"40041/* strings to be used for rfkill entries and by42 * ST Core to be used for sysfs debug entry43 */···581 long err = 0;582 unsigned long flags = 0;583584+ st_kim_ref(&st_gdata, 0);585 pr_info("%s(%d) ", __func__, new_proto->type);586 if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL587 || new_proto->reg_complete_cb == NULL) {···713714 pr_debug("%s: %d ", __func__, type);715716+ st_kim_ref(&st_gdata, 0);717 if (type < ST_BT || type >= ST_MAX) {718 pr_err(" protocol %d not supported", type);719 return -EPROTONOSUPPORT;···767#endif768 long len;769770+ st_kim_ref(&st_gdata, 0);771 if (unlikely(skb == NULL || st_gdata == NULL772 || st_gdata->tty == NULL)) {773 pr_err("data/tty unavailable to perform write");···818 struct st_data_s *st_gdata;819 pr_info("%s ", __func__);820821+ st_kim_ref(&st_gdata, 0);822 st_gdata->tty = tty;823 tty->disc_data = st_gdata;824
+1-1
drivers/staging/ti-st/st_core.h
···117void st_core_exit(struct st_data_s *);118119/* ask for reference from KIM */120-void st_kim_ref(struct st_data_s **);121122#define GPS_STUB_TEST123#ifdef GPS_STUB_TEST
···117void st_core_exit(struct st_data_s *);118119/* ask for reference from KIM */120+void st_kim_ref(struct st_data_s **, int);121122#define GPS_STUB_TEST123#ifdef GPS_STUB_TEST
+19-3
drivers/staging/ti-st/st_kim.c
···72 PROTO_ENTRY(ST_GPS, "GPS"),73};74007576/**********************************************************************/77/* internal functions */00000000000007879/**80 * validate_firmware_response -···368 struct kim_data_s *kim_gdata;369 pr_info(" %s ", __func__);370371- kim_pdev = st_get_plat_device();372 kim_gdata = dev_get_drvdata(&kim_pdev->dev);373374 if (kim_gdata->gpios[type] == -1) {···589 * This would enable multiple such platform devices to exist590 * on a given platform591 */592-void st_kim_ref(struct st_data_s **core_data)593{594 struct platform_device *pdev;595 struct kim_data_s *kim_gdata;596 /* get kim_gdata reference from platform device */597- pdev = st_get_plat_device();598 kim_gdata = dev_get_drvdata(&pdev->dev);599 *core_data = kim_gdata->core_data;600}···638 long *gpios = pdev->dev.platform_data;639 struct kim_data_s *kim_gdata;6400641 kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_ATOMIC);642 if (!kim_gdata) {643 pr_err("no mem to allocate");
···72 PROTO_ENTRY(ST_GPS, "GPS"),73};7475+#define MAX_ST_DEVICES 3 /* Imagine 1 on each UART for now */76+struct platform_device *st_kim_devices[MAX_ST_DEVICES];7778/**********************************************************************/79/* internal functions */80+81+/**82+ * st_get_plat_device -83+ * function which returns the reference to the platform device84+ * requested by id. As of now only 1 such device exists (id=0)85+ * the context requesting for reference can get the id to be86+ * requested by a. The protocol driver which is registering or87+ * b. the tty device which is opened.88+ */89+static struct platform_device *st_get_plat_device(int id)90+{91+ return st_kim_devices[id];92+}9394/**95 * validate_firmware_response -···353 struct kim_data_s *kim_gdata;354 pr_info(" %s ", __func__);355356+ kim_pdev = st_get_plat_device(0);357 kim_gdata = dev_get_drvdata(&kim_pdev->dev);358359 if (kim_gdata->gpios[type] == -1) {···574 * This would enable multiple such platform devices to exist575 * on a given platform576 */577+void st_kim_ref(struct st_data_s **core_data, int id)578{579 struct platform_device *pdev;580 struct kim_data_s *kim_gdata;581 /* get kim_gdata reference from platform device */582+ pdev = st_get_plat_device(id);583 kim_gdata = dev_get_drvdata(&pdev->dev);584 *core_data = kim_gdata->core_data;585}···623 long *gpios = pdev->dev.platform_data;624 struct kim_data_s *kim_gdata;625626+ st_kim_devices[pdev->id] = pdev;627 kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_ATOMIC);628 if (!kim_gdata) {629 pr_err("no mem to allocate");