Skip to content

Commit

Permalink
Bluetoth related changes - initial changes - edp17
Browse files Browse the repository at this point in the history
  • Loading branch information
edp17 committed Nov 23, 2019
1 parent 3fb4e6f commit 56a84d4
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 211 deletions.
16 changes: 16 additions & 0 deletions arch/arm/mach-msm/lge/board-8974-rfkill.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@
#endif
#endif /* CONFIG_BCM4335BT */

/* Power on the device but do not allow rfkilling via GPIO */
#define DISABLE_RFKILL 1

#ifndef DISABLE_RFKILL
static struct rfkill *bt_rfk;
static const char bt_name[] = "brcm_Bluetooth_rfkill";
#endif /* DISABLE_RFKILL */

#ifdef CONFIG_BCM4335BT
#define BTLOCK_NAME "btlock"
Expand Down Expand Up @@ -194,14 +199,18 @@ static int bluetooth_set_power(void *data, bool blocked)
return 0;
}

#ifndef DISABLE_RFKILL
static struct rfkill_ops bluetooth_rfkill_ops = {
.set_block = bluetooth_set_power,
};
#endif /* DISABLE_RFKILL */

static int bluetooth_rfkill_probe(struct platform_device *pdev)
{
int rc = 0;
#ifndef DISABLE_RFKILL
bool default_state = true; /* off */
#endif /* DISABLE_RFKILL */

#ifdef CONFIG_BCM4335BT
bcm_btlock_init();
Expand All @@ -220,6 +229,10 @@ static int bluetooth_rfkill_probe(struct platform_device *pdev)
}
gpio_direction_output(GPIO_BT_RESET_N, 0);

#ifdef DISABLE_RFKILL
bluetooth_set_power(NULL, false);
return 0;
#else
bluetooth_set_power(NULL, default_state);

bt_rfk = rfkill_alloc(bt_name, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
Expand All @@ -244,6 +257,7 @@ static int bluetooth_rfkill_probe(struct platform_device *pdev)
err_rfkill_reg:
rfkill_destroy(bt_rfk);
err_rfkill_alloc:
#endif /* DISABLE_RFKILL */
err_gpio_reset:
gpio_free(GPIO_BT_RESET_N);
printk(KERN_ERR "bluetooth_rfkill_probe error!\n");
Expand All @@ -252,8 +266,10 @@ static int bluetooth_rfkill_probe(struct platform_device *pdev)

static int bluetooth_rfkill_remove(struct platform_device *dev)
{
#ifndef DISABLE_RFKILL
rfkill_unregister(bt_rfk);
rfkill_destroy(bt_rfk);
#endif /* DISABLE_RFKILL */
gpio_free(GPIO_BT_RESET_N);

#ifdef CONFIG_BCM4335BT
Expand Down
13 changes: 8 additions & 5 deletions fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@ static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd)
rcu_read_lock();
file = fcheck_files(files, fd);
if (file) {
unsigned i_mode, f_mode = file->f_mode;
unsigned f_mode = file->f_mode;

rcu_read_unlock();
put_files_struct(files);
Expand All @@ -1854,12 +1854,14 @@ static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd)
inode->i_gid = 0;
}

i_mode = S_IFLNK;
if (f_mode & FMODE_READ)
if (S_ISLNK(inode->i_mode)) {
unsigned i_mode = S_IFLNK;
if (f_mode & FMODE_READ)
i_mode |= S_IRUSR | S_IXUSR;
if (f_mode & FMODE_WRITE)
if (f_mode & FMODE_WRITE)
i_mode |= S_IWUSR | S_IXUSR;
inode->i_mode = i_mode;
inode->i_mode = i_mode;
}

security_task_to_inode(task, inode);
put_task_struct(task);
Expand Down Expand Up @@ -1894,6 +1896,7 @@ static struct dentry *proc_fd_instantiate(struct inode *dir,
ei = PROC_I(inode);
ei->fd = fd;

inode->i_mode = S_IFLNK;
inode->i_op = &proc_pid_link_inode_operations;
inode->i_size = 64;
ei->op.proc_get_link = proc_fd_link;
Expand Down
2 changes: 0 additions & 2 deletions include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,6 @@ int mgmt_encrypt_change(u16 index, bdaddr_t *bdaddr, u8 status);
/* LE SMP Management interface */
int le_user_confirm_reply(struct hci_conn *conn, u16 mgmt_op, void *cp);
int mgmt_remote_class(u16 index, bdaddr_t *bdaddr, u8 dev_class[3]);
int mgmt_remote_version(u16 index, bdaddr_t *bdaddr, u8 ver, u16 mnf,
u16 sub_ver);
int mgmt_remote_features(u16 index, bdaddr_t *bdaddr, u8 features[8]);

/* HCI info for socket */
Expand Down
8 changes: 0 additions & 8 deletions include/net/bluetooth/mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,6 @@ struct mgmt_ev_remote_class {
__u8 dev_class[3];
} __packed;

#define MGMT_EV_REMOTE_VERSION 0x0018
struct mgmt_ev_remote_version {
bdaddr_t bdaddr;
__u8 lmp_ver;
__u16 manufacturer;
__u16 lmp_subver;
} __packed;

#define MGMT_EV_REMOTE_FEATURES 0x0019
struct mgmt_ev_remote_features {
bdaddr_t bdaddr;
Expand Down
2 changes: 1 addition & 1 deletion include/net/bluetooth/sco.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define SCO_DEFAULT_FLUSH_TO 0xFFFF

#define SCO_CONN_TIMEOUT (HZ * 40)
#define SCO_DISCONN_TIMEOUT (HZ * 20)
#define SCO_DISCONN_TIMEOUT (HZ * 2)
#define SCO_CONN_IDLE_TIMEOUT (HZ * 60)

/* SCO socket address */
Expand Down
68 changes: 10 additions & 58 deletions net/bluetooth/hci_event.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -1665,14 +1665,14 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
if (test_bit(HCI_ENCRYPT, &hdev->flags))
conn->link_mode |= HCI_LM_ENCRYPT;

/* Get remote version */
/* Get remote features */
if (conn->type == ACL_LINK) {
struct hci_cp_read_remote_version cp;
struct hci_cp_read_remote_features cp;
cp.handle = ev->handle;
hci_send_cmd(hdev, HCI_OP_READ_CLOCK_OFFSET,
sizeof(cp), &cp);
hci_send_cmd(hdev, HCI_OP_READ_REMOTE_VERSION,
sizeof(cp), &cp);
hci_send_cmd(hdev, HCI_OP_READ_REMOTE_FEATURES,
sizeof(cp), &cp);
}

/* Set packet type for incoming connection */
Expand Down Expand Up @@ -1837,18 +1837,6 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s

conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
if (conn) {
if (ev->status == 0x06 && hdev->ssp_mode > 0 &&
conn->ssp_mode > 0) {
struct hci_cp_auth_requested cp;
hci_remove_link_key(hdev, &conn->dst);
cp.handle = cpu_to_le16(conn->handle);
hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED,
sizeof(cp), &cp);
hci_dev_unlock(hdev);
BT_INFO("Pin or key missing");
return;
}

if (!ev->status) {
conn->link_mode |= HCI_LM_AUTH;
conn->sec_level = conn->pending_sec_level;
Expand Down Expand Up @@ -1882,29 +1870,11 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s

if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) {
if (!ev->status) {
if (conn->link_mode & HCI_LM_ENCRYPT) {
/* Encryption implies authentication */
conn->link_mode |= HCI_LM_AUTH;
conn->link_mode |= HCI_LM_ENCRYPT;
conn->sec_level =
conn->pending_sec_level;
clear_bit(HCI_CONN_ENCRYPT_PEND,
&conn->pend);
hci_encrypt_cfm(conn, ev->status, 1);

if (test_bit(HCI_MGMT, &hdev->flags))
mgmt_encrypt_change(hdev->id,
&conn->dst,
ev->status);

} else {
struct hci_cp_set_conn_encrypt cp;
cp.handle = ev->handle;
cp.encrypt = 0x01;
hci_send_cmd(hdev,
HCI_OP_SET_CONN_ENCRYPT,
sizeof(cp), &cp);
}
struct hci_cp_set_conn_encrypt cp;
cp.handle = ev->handle;
cp.encrypt = 0x01;
hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT,
sizeof(cp), &cp);
} else {
clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend);
hci_encrypt_cfm(conn, ev->status, 0x00);
Expand Down Expand Up @@ -2070,24 +2040,7 @@ static inline void hci_remote_features_evt(struct hci_dev *hdev, struct sk_buff

static inline void hci_remote_version_evt(struct hci_dev *hdev, struct sk_buff *skb)
{
struct hci_ev_remote_version *ev = (void *) skb->data;
struct hci_cp_read_remote_features cp;
struct hci_conn *conn;
BT_DBG("%s status %d", hdev->name, ev->status);

hci_dev_lock(hdev);
cp.handle = ev->handle;
hci_send_cmd(hdev, HCI_OP_READ_REMOTE_FEATURES,
sizeof(cp), &cp);

conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
if (!conn)
goto unlock;
if (!ev->status)
mgmt_remote_version(hdev->id, &conn->dst, ev->lmp_ver,
ev->manufacturer, ev->lmp_subver);
unlock:
hci_dev_unlock(hdev);
BT_DBG("%s", hdev->name);
}

static inline void hci_qos_setup_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
Expand Down Expand Up @@ -2727,7 +2680,6 @@ static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff
conn->key_type = ev->key_type;
hci_disconnect_amp(conn, 0x06);

conn->link_mode &= ~HCI_LM_ENCRYPT;
pin_len = conn->pin_length;
hci_conn_put(conn);
hci_conn_enter_active_mode(conn, 0);
Expand Down
Loading

0 comments on commit 56a84d4

Please sign in to comment.