···8080extern long st_register(struct st_proto_s *);8181extern long st_unregister(enum proto_type);82828383-extern struct platform_device *st_get_plat_device(void);8483#endif /* ST_H */
+4-5
drivers/staging/ti-st/st_core.c
···3838#include "st_ll.h"3939#include "st.h"40404141-#define VERBOSE4241/* strings to be used for rfkill entries and by4342 * ST Core to be used for sysfs debug entry4443 */···580581 long err = 0;581582 unsigned long flags = 0;582583583583- st_kim_ref(&st_gdata);584584+ st_kim_ref(&st_gdata, 0);584585 pr_info("%s(%d) ", __func__, new_proto->type);585586 if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL586587 || new_proto->reg_complete_cb == NULL) {···712713713714 pr_debug("%s: %d ", __func__, type);714715715715- st_kim_ref(&st_gdata);716716+ st_kim_ref(&st_gdata, 0);716717 if (type < ST_BT || type >= ST_MAX) {717718 pr_err(" protocol %d not supported", type);718719 return -EPROTONOSUPPORT;···766767#endif767768 long len;768769769769- st_kim_ref(&st_gdata);770770+ st_kim_ref(&st_gdata, 0);770771 if (unlikely(skb == NULL || st_gdata == NULL771772 || st_gdata->tty == NULL)) {772773 pr_err("data/tty unavailable to perform write");···817818 struct st_data_s *st_gdata;818819 pr_info("%s ", __func__);819820820820- st_kim_ref(&st_gdata);821821+ st_kim_ref(&st_gdata, 0);821822 st_gdata->tty = tty;822823 tty->disc_data = st_gdata;823824
+1-1
drivers/staging/ti-st/st_core.h
···117117void st_core_exit(struct st_data_s *);118118119119/* ask for reference from KIM */120120-void st_kim_ref(struct st_data_s **);120120+void st_kim_ref(struct st_data_s **, int);121121122122#define GPS_STUB_TEST123123#ifdef GPS_STUB_TEST
+19-3
drivers/staging/ti-st/st_kim.c
···7272 PROTO_ENTRY(ST_GPS, "GPS"),7373};74747575+#define MAX_ST_DEVICES 3 /* Imagine 1 on each UART for now */7676+struct platform_device *st_kim_devices[MAX_ST_DEVICES];75777678/**********************************************************************/7779/* internal functions */8080+8181+/**8282+ * st_get_plat_device -8383+ * function which returns the reference to the platform device8484+ * requested by id. As of now only 1 such device exists (id=0)8585+ * the context requesting for reference can get the id to be8686+ * requested by a. The protocol driver which is registering or8787+ * b. the tty device which is opened.8888+ */8989+static struct platform_device *st_get_plat_device(int id)9090+{9191+ return st_kim_devices[id];9292+}78937994/**8095 * validate_firmware_response -···368353 struct kim_data_s *kim_gdata;369354 pr_info(" %s ", __func__);370355371371- kim_pdev = st_get_plat_device();356356+ kim_pdev = st_get_plat_device(0);372357 kim_gdata = dev_get_drvdata(&kim_pdev->dev);373358374359 if (kim_gdata->gpios[type] == -1) {···589574 * This would enable multiple such platform devices to exist590575 * on a given platform591576 */592592-void st_kim_ref(struct st_data_s **core_data)577577+void st_kim_ref(struct st_data_s **core_data, int id)593578{594579 struct platform_device *pdev;595580 struct kim_data_s *kim_gdata;596581 /* get kim_gdata reference from platform device */597597- pdev = st_get_plat_device();582582+ pdev = st_get_plat_device(id);598583 kim_gdata = dev_get_drvdata(&pdev->dev);599584 *core_data = kim_gdata->core_data;600585}···638623 long *gpios = pdev->dev.platform_data;639624 struct kim_data_s *kim_gdata;640625626626+ st_kim_devices[pdev->id] = pdev;641627 kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_ATOMIC);642628 if (!kim_gdata) {643629 pr_err("no mem to allocate");