* [PATCH] Staging: gdm724x: LTE: Fix trailing open parenthesis code style issue. @ 2018-02-16 21:40 Quytelda Kahja 2018-02-19 9:15 ` Dan Carpenter 2018-02-19 17:05 ` [PATCH] Staging: gdm724x: LTE: Fix trailing open parenthesis code style issue Greg KH 0 siblings, 2 replies; 16+ messages in thread From: Quytelda Kahja @ 2018-02-16 21:40 UTC (permalink / raw) To: gregkh, tulup, stephen; +Cc: devel, linux-kernel, Quytelda Kahja Fix a coding style problem causing warnings from checkpatch.pl. Signed-off-by: Quytelda Kahja <quytelda@tamalin.org> --- drivers/staging/gdm724x/gdm_lte.c | 50 ++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c index 0527b0d1c1d0..ff3fed9c4a81 100644 --- a/drivers/staging/gdm724x/gdm_lte.c +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -204,9 +204,12 @@ static __sum16 icmp6_checksum(struct ipv6hdr *ipv6, u16 *ptr, int len) pseudo_header.ph.ph_nxt = ipv6->nexthdr; w = (u16 *)&pseudo_header; - for (i = 0; i < ARRAY_SIZE(pseudo_header.pa); i++) - sum = csum_add(sum, csum_unfold( - (__force __sum16)pseudo_header.pa[i])); + for (i = 0; i < ARRAY_SIZE(pseudo_header.pa); i++) { + __wsum tmp_sum; + + tmp_sum = csum_unfold((__force __sum16)pseudo_header.pa[i]); + sum = csum_add(sum, tmp_sum); + } w = ptr; while (len > 1) { @@ -510,18 +513,18 @@ static int gdm_lte_event_send(struct net_device *dev, char *buf, int len) { struct nic *nic = netdev_priv(dev); struct hci_packet *hci = (struct hci_packet *)buf; + struct gdm_endian *phy_endian; int idx; + u16 cpu; int ret; ret = sscanf(dev->name, "lte%d", &idx); if (ret != 1) return -EINVAL; - return netlink_send(lte_event.sock, idx, 0, buf, - gdm_dev16_to_cpu( - nic->phy_dev->get_endian( - nic->phy_dev->priv_dev), hci->len) - + HCI_HEADER_SIZE); + phy_endian = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); + cpu = gdm_dev16_to_cpu(phy_endian, hci->len); + return netlink_send(lte_event.sock, idx, 0, buf, cpu + HCI_HEADER_SIZE); } static void gdm_lte_event_rcv(struct net_device *dev, u16 type, @@ -728,17 +731,21 @@ static void gdm_lte_pdn_table(struct net_device *dev, char *buf, int len) { struct nic *nic = netdev_priv(dev); struct hci_pdn_table_ind *pdn_table = (struct hci_pdn_table_ind *)buf; + struct gdm_endian *dft_endian; + struct gdm_endian *nic_endian; if (pdn_table->activate) { nic->pdn_table.activate = pdn_table->activate; - nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu( - nic->phy_dev->get_endian( - nic->phy_dev->priv_dev), - pdn_table->dft_eps_id); - nic->pdn_table.nic_type = gdm_dev32_to_cpu( - nic->phy_dev->get_endian( - nic->phy_dev->priv_dev), - pdn_table->nic_type); + + dft_endian = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); + nic_endian = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); + + nic->pdn_table.dft_eps_id = + gdm_dev32_to_cpu(dft_endian, + pdn_table->dft_eps_id); + nic->pdn_table.nic_type = + gdm_dev32_to_cpu(nic_endian, + pdn_table->nic_type); netdev_info(dev, "pdn activated, nic_type=0x%x\n", nic->pdn_table.nic_type); @@ -896,12 +903,11 @@ int register_lte_device(struct phy_dev *phy_dev, nic->phy_dev = phy_dev; nic->nic_id = index; - form_mac_address( - net->dev_addr, - nic->src_mac_addr, - nic->dest_mac_addr, - mac_address, - index); + form_mac_address(net->dev_addr, + nic->src_mac_addr, + nic->dest_mac_addr, + mac_address, + index); SET_NETDEV_DEV(net, dev); SET_NETDEV_DEVTYPE(net, &wwan_type); -- 2.16.1 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH] Staging: gdm724x: LTE: Fix trailing open parenthesis code style issue. 2018-02-16 21:40 [PATCH] Staging: gdm724x: LTE: Fix trailing open parenthesis code style issue Quytelda Kahja @ 2018-02-19 9:15 ` Dan Carpenter 2018-02-21 10:20 ` [PATCH] Staging: gdm724x: LTE: Fix trailing open parentheses Quytelda Kahja 2018-02-19 17:05 ` [PATCH] Staging: gdm724x: LTE: Fix trailing open parenthesis code style issue Greg KH 1 sibling, 1 reply; 16+ messages in thread From: Dan Carpenter @ 2018-02-19 9:15 UTC (permalink / raw) To: Quytelda Kahja; +Cc: gregkh, linux-kernel, devel On Fri, Feb 16, 2018 at 01:40:08PM -0800, Quytelda Kahja wrote: > @@ -728,17 +731,21 @@ static void gdm_lte_pdn_table(struct net_device *dev, char *buf, int len) > { > struct nic *nic = netdev_priv(dev); > struct hci_pdn_table_ind *pdn_table = (struct hci_pdn_table_ind *)buf; > + struct gdm_endian *dft_endian; > + struct gdm_endian *nic_endian; > > if (pdn_table->activate) { > nic->pdn_table.activate = pdn_table->activate; > - nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu( > - nic->phy_dev->get_endian( > - nic->phy_dev->priv_dev), > - pdn_table->dft_eps_id); > - nic->pdn_table.nic_type = gdm_dev32_to_cpu( > - nic->phy_dev->get_endian( > - nic->phy_dev->priv_dev), > - pdn_table->nic_type); > + > + dft_endian = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); > + nic_endian = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); We don't need both dft_endian abd nic_endian since they're the same endianness. Otherwise, this is a nice cleanup. > + > + nic->pdn_table.dft_eps_id = > + gdm_dev32_to_cpu(dft_endian, > + pdn_table->dft_eps_id); > + nic->pdn_table.nic_type = > + gdm_dev32_to_cpu(nic_endian, > + pdn_table->nic_type); > > netdev_info(dev, "pdn activated, nic_type=0x%x\n", > nic->pdn_table.nic_type); regards, dan carpenter _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH] Staging: gdm724x: LTE: Fix trailing open parentheses. 2018-02-19 9:15 ` Dan Carpenter @ 2018-02-21 10:20 ` Quytelda Kahja 2018-02-21 10:43 ` Dan Carpenter 0 siblings, 1 reply; 16+ messages in thread From: Quytelda Kahja @ 2018-02-21 10:20 UTC (permalink / raw) To: gregkh, jonathankim, deanahn, dan.carpenter Cc: devel, Quytelda Kahja, linux-kernel Fix lines with a trailing open parenthesis, which is a coding style issue. Signed-off-by: Quytelda Kahja <quytelda@tamalin.org> --- drivers/staging/gdm724x/gdm_lte.c | 44 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c index a6608637035a..8d492d6d6a12 100644 --- a/drivers/staging/gdm724x/gdm_lte.c +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -185,6 +185,7 @@ static __sum16 icmp6_checksum(struct ipv6hdr *ipv6, u16 *ptr, int len) unsigned short *w = ptr; __wsum sum = 0; int i; + u16 pa; union { struct { @@ -204,9 +205,10 @@ static __sum16 icmp6_checksum(struct ipv6hdr *ipv6, u16 *ptr, int len) pseudo_header.ph.ph_nxt = ipv6->nexthdr; w = (u16 *)&pseudo_header; - for (i = 0; i < ARRAY_SIZE(pseudo_header.pa); i++) - sum = csum_add(sum, csum_unfold( - (__force __sum16)pseudo_header.pa[i])); + for (i = 0; i < ARRAY_SIZE(pseudo_header.pa); i++) { + pa = pseudo_header.pa[i]; + sum = csum_add(sum, csum_unfold((__force __sum16)pa)); + } w = ptr; while (len > 1) { @@ -509,8 +511,9 @@ static struct net_device_stats *gdm_lte_stats(struct net_device *dev) static int gdm_lte_event_send(struct net_device *dev, char *buf, int len) { - struct nic *nic = netdev_priv(dev); + struct phy_dev *phy_dev = ((struct nic *)netdev_priv(dev))->phy_dev; struct hci_packet *hci = (struct hci_packet *)buf; + int length; int idx; int ret; @@ -518,11 +521,9 @@ static int gdm_lte_event_send(struct net_device *dev, char *buf, int len) if (ret != 1) return -EINVAL; - return netlink_send(lte_event.sock, idx, 0, buf, - gdm_dev16_to_cpu( - nic->phy_dev->get_endian( - nic->phy_dev->priv_dev), hci->len) - + HCI_HEADER_SIZE); + length = gdm_dev16_to_cpu(phy_dev->get_endian(phy_dev->priv_dev), + hci->len) + HCI_HEADER_SIZE; + return netlink_send(lte_event.sock, idx, 0, buf, length); } static void gdm_lte_event_rcv(struct net_device *dev, u16 type, @@ -731,15 +732,13 @@ static void gdm_lte_pdn_table(struct net_device *dev, char *buf, int len) struct hci_pdn_table_ind *pdn_table = (struct hci_pdn_table_ind *)buf; if (pdn_table->activate) { + struct gdm_endian *ed; + nic->pdn_table.activate = pdn_table->activate; - nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu( - nic->phy_dev->get_endian( - nic->phy_dev->priv_dev), - pdn_table->dft_eps_id); - nic->pdn_table.nic_type = gdm_dev32_to_cpu( - nic->phy_dev->get_endian( - nic->phy_dev->priv_dev), - pdn_table->nic_type); + + ed = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); + nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu(ed, pdn_table->dft_eps_id); + nic->pdn_table.nic_type = gdm_dev32_to_cpu(ed, pdn_table->nic_type); netdev_info(dev, "pdn activated, nic_type=0x%x\n", nic->pdn_table.nic_type); @@ -897,12 +896,11 @@ int register_lte_device(struct phy_dev *phy_dev, nic->phy_dev = phy_dev; nic->nic_id = index; - form_mac_address( - net->dev_addr, - nic->src_mac_addr, - nic->dest_mac_addr, - mac_address, - index); + form_mac_address(net->dev_addr, + nic->src_mac_addr, + nic->dest_mac_addr, + mac_address, + index); SET_NETDEV_DEV(net, dev); SET_NETDEV_DEVTYPE(net, &wwan_type); -- 2.16.2 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH] Staging: gdm724x: LTE: Fix trailing open parentheses. 2018-02-21 10:20 ` [PATCH] Staging: gdm724x: LTE: Fix trailing open parentheses Quytelda Kahja @ 2018-02-21 10:43 ` Dan Carpenter 2018-02-21 13:12 ` [PATCH 1/2] Staging: gdm724x: Simplify the struct gdm_endian to a variable Quytelda Kahja 0 siblings, 1 reply; 16+ messages in thread From: Dan Carpenter @ 2018-02-21 10:43 UTC (permalink / raw) To: Quytelda Kahja; +Cc: devel, gregkh, jonathankim, linux-kernel, deanahn This patch is fine. Acked-by: Dan Carpenter <dan.carpenter@oracle.com> But I have a some comments for later. On Wed, Feb 21, 2018 at 02:20:17AM -0800, Quytelda Kahja wrote: > @@ -509,8 +511,9 @@ static struct net_device_stats *gdm_lte_stats(struct net_device *dev) > > static int gdm_lte_event_send(struct net_device *dev, char *buf, int len) > { > - struct nic *nic = netdev_priv(dev); > + struct phy_dev *phy_dev = ((struct nic *)netdev_priv(dev))->phy_dev; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This is a bit unsightly. Better to make it two assignments: struct nic *nic = netdev_priv(dev); struct phy_dev *phy_dev = nic->phy_dev; > struct hci_packet *hci = (struct hci_packet *)buf; > + int length; > int idx; > int ret; > > @@ -518,11 +521,9 @@ static int gdm_lte_event_send(struct net_device *dev, char *buf, int len) > if (ret != 1) > return -EINVAL; > > - return netlink_send(lte_event.sock, idx, 0, buf, > - gdm_dev16_to_cpu( > - nic->phy_dev->get_endian( > - nic->phy_dev->priv_dev), hci->len) > - + HCI_HEADER_SIZE); > + length = gdm_dev16_to_cpu(phy_dev->get_endian(phy_dev->priv_dev), > + hci->len) + HCI_HEADER_SIZE; > + return netlink_send(lte_event.sock, idx, 0, buf, length); It would be nicer to store: struct gdm_endian *ed = phy_dev->get_endian(phy_dev->priv_dev); at the start of the function as well. Then this looks like: length = gdm_dev16_to_cpu(ed, hci->len) + HCI_HEADER_SIZE; netlink_send(lte_event.sock, idx, 0, buf, length); The endian information doesn't need to be a struct any more since we remove ed->host_ed in 77e8a50149a2 ("staging: gdm724x: Remove test for host endian"). We should change gdm_dev16_to_cpu() to just take dev_ed. > } > > static void gdm_lte_event_rcv(struct net_device *dev, u16 type, > @@ -731,15 +732,13 @@ static void gdm_lte_pdn_table(struct net_device *dev, char *buf, int len) > struct hci_pdn_table_ind *pdn_table = (struct hci_pdn_table_ind *)buf; > > if (pdn_table->activate) { > + struct gdm_endian *ed; > + > nic->pdn_table.activate = pdn_table->activate; > - nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu( > - nic->phy_dev->get_endian( > - nic->phy_dev->priv_dev), > - pdn_table->dft_eps_id); > - nic->pdn_table.nic_type = gdm_dev32_to_cpu( > - nic->phy_dev->get_endian( > - nic->phy_dev->priv_dev), > - pdn_table->nic_type); > + > + ed = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); > + nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu(ed, pdn_table->dft_eps_id); > + nic->pdn_table.nic_type = gdm_dev32_to_cpu(ed, pdn_table->nic_type); > > netdev_info(dev, "pdn activated, nic_type=0x%x\n", > nic->pdn_table.nic_type); Use the same three initial variables here: struct nic *nic = netdev_priv(dev); struct phy_dev *phy_dev = nic->phy_dev; struct gdm_endian *ed = phy_dev->get_endian(nic->phy_dev->priv_dev); Then reverse the ->active test: if (!pdn_table->activate) { memset(&nic->pdn_table, 0, sizeof(struct pdn_table)); netdev_info(dev, "pdn deactivated\n"); return; } Then pull everything in a tab: nic->pdn_table.activate = pdn_table->activate; nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu(ed, pdn_table->dft_eps_id); nic->pdn_table.nic_type = gdm_dev32_to_cpu(ed, pdn_table->nic_type); regards, dan carpenter _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/2] Staging: gdm724x: Simplify the struct gdm_endian to a variable. 2018-02-21 10:43 ` Dan Carpenter @ 2018-02-21 13:12 ` Quytelda Kahja 2018-02-21 13:12 ` [PATCH 2/2] Staging: gdm724x: LTE: Refactor gdm_lte_pdn_table() Quytelda Kahja ` (2 more replies) 0 siblings, 3 replies; 16+ messages in thread From: Quytelda Kahja @ 2018-02-21 13:12 UTC (permalink / raw) To: gregkh, jonathankim, deanahn, dan.carpenter Cc: devel, Quytelda Kahja, linux-kernel Since the testing for host endianness and in-driver conversion were removed in 77e8a50149a2, the gdm_endian struct contains only one member, and can therefore be simplified to a single u8 variable. Signed-off-by: Quytelda Kahja <quytelda@tamalin.org> --- drivers/staging/gdm724x/gdm_endian.c | 24 ++++++++---------------- drivers/staging/gdm724x/gdm_endian.h | 13 ++++--------- drivers/staging/gdm724x/gdm_lte.c | 7 +++---- drivers/staging/gdm724x/gdm_lte.h | 2 +- drivers/staging/gdm724x/gdm_usb.c | 30 +++++++++++++++--------------- drivers/staging/gdm724x/gdm_usb.h | 2 +- 6 files changed, 32 insertions(+), 46 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_endian.c b/drivers/staging/gdm724x/gdm_endian.c index d0b43e20ec06..4200391b1a97 100644 --- a/drivers/staging/gdm724x/gdm_endian.c +++ b/drivers/staging/gdm724x/gdm_endian.c @@ -14,41 +14,33 @@ #include <linux/kernel.h> #include "gdm_endian.h" -void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian) +__dev16 gdm_cpu_to_dev16(u8 dev_ed, u16 x) { - if (dev_endian == ENDIANNESS_BIG) - ed->dev_ed = ENDIANNESS_BIG; - else - ed->dev_ed = ENDIANNESS_LITTLE; -} - -__dev16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x) -{ - if (ed->dev_ed == ENDIANNESS_LITTLE) + if (dev_ed == ENDIANNESS_LITTLE) return (__force __dev16)cpu_to_le16(x); else return (__force __dev16)cpu_to_be16(x); } -u16 gdm_dev16_to_cpu(struct gdm_endian *ed, __dev16 x) +u16 gdm_dev16_to_cpu(u8 dev_ed, __dev16 x) { - if (ed->dev_ed == ENDIANNESS_LITTLE) + if (dev_ed == ENDIANNESS_LITTLE) return le16_to_cpu((__force __le16)x); else return be16_to_cpu((__force __be16)x); } -__dev32 gdm_cpu_to_dev32(struct gdm_endian *ed, u32 x) +__dev32 gdm_cpu_to_dev32(u8 dev_ed, u32 x) { - if (ed->dev_ed == ENDIANNESS_LITTLE) + if (dev_ed == ENDIANNESS_LITTLE) return (__force __dev32)cpu_to_le32(x); else return (__force __dev32)cpu_to_be32(x); } -u32 gdm_dev32_to_cpu(struct gdm_endian *ed, __dev32 x) +u32 gdm_dev32_to_cpu(u8 dev_ed, __dev32 x) { - if (ed->dev_ed == ENDIANNESS_LITTLE) + if (dev_ed == ENDIANNESS_LITTLE) return le32_to_cpu((__force __le32)x); else return be32_to_cpu((__force __be32)x); diff --git a/drivers/staging/gdm724x/gdm_endian.h b/drivers/staging/gdm724x/gdm_endian.h index a785f30bb369..e58d29f868ba 100644 --- a/drivers/staging/gdm724x/gdm_endian.h +++ b/drivers/staging/gdm724x/gdm_endian.h @@ -32,14 +32,9 @@ enum { ENDIANNESS_MAX }; -struct gdm_endian { - u8 dev_ed; -}; - -void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian); -__dev16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x); -u16 gdm_dev16_to_cpu(struct gdm_endian *ed, __dev16 x); -__dev32 gdm_cpu_to_dev32(struct gdm_endian *ed, u32 x); -u32 gdm_dev32_to_cpu(struct gdm_endian *ed, __dev32 x); +__dev16 gdm_cpu_to_dev16(u8 dev_ed, u16 x); +u16 gdm_dev16_to_cpu(u8 dev_ed, __dev16 x); +__dev32 gdm_cpu_to_dev32(u8 dev_ed, u32 x); +u32 gdm_dev32_to_cpu(u8 dev_ed, __dev32 x); #endif /*__GDM_ENDIAN_H__*/ diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c index 8d492d6d6a12..92cb9d115fe3 100644 --- a/drivers/staging/gdm724x/gdm_lte.c +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -685,7 +685,7 @@ static void gdm_lte_multi_sdu_pkt(struct phy_dev *phy_dev, char *buf, int len) struct net_device *dev; struct multi_sdu *multi_sdu = (struct multi_sdu *)buf; struct sdu *sdu = NULL; - struct gdm_endian *endian = phy_dev->get_endian(phy_dev->priv_dev); + u8 endian = phy_dev->get_endian(phy_dev->priv_dev); u8 *data = (u8 *)multi_sdu->data; u16 i = 0; u16 num_packet; @@ -730,10 +730,9 @@ static void gdm_lte_pdn_table(struct net_device *dev, char *buf, int len) { struct nic *nic = netdev_priv(dev); struct hci_pdn_table_ind *pdn_table = (struct hci_pdn_table_ind *)buf; + u8 ed; if (pdn_table->activate) { - struct gdm_endian *ed; - nic->pdn_table.activate = pdn_table->activate; ed = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); @@ -752,9 +751,9 @@ static int gdm_lte_receive_pkt(struct phy_dev *phy_dev, char *buf, int len) { struct hci_packet *hci = (struct hci_packet *)buf; struct hci_pdn_table_ind *pdn_table = (struct hci_pdn_table_ind *)buf; - struct gdm_endian *endian = phy_dev->get_endian(phy_dev->priv_dev); struct sdu *sdu; struct net_device *dev; + u8 endian = phy_dev->get_endian(phy_dev->priv_dev); int ret = 0; u16 cmd_evt; u32 nic_type; diff --git a/drivers/staging/gdm724x/gdm_lte.h b/drivers/staging/gdm724x/gdm_lte.h index 3ecaff1a40cb..bad0855e4721 100644 --- a/drivers/staging/gdm724x/gdm_lte.h +++ b/drivers/staging/gdm724x/gdm_lte.h @@ -56,7 +56,7 @@ struct phy_dev { int (*cb)(void *cb_data, void *data, int len, int context), void *cb_data, int context); - struct gdm_endian * (*get_endian)(void *priv_dev); + u8 (*get_endian)(void *priv_dev); }; struct nic { diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c index 87cd1f827455..c95bad4a8615 100644 --- a/drivers/staging/gdm724x/gdm_usb.c +++ b/drivers/staging/gdm724x/gdm_usb.c @@ -72,8 +72,8 @@ static int request_mac_address(struct lte_udev *udev) int actual; int ret = -1; - hci->cmd_evt = gdm_cpu_to_dev16(&udev->gdm_ed, LTE_GET_INFORMATION); - hci->len = gdm_cpu_to_dev16(&udev->gdm_ed, 1); + hci->cmd_evt = gdm_cpu_to_dev16(udev->gdm_ed, LTE_GET_INFORMATION); + hci->len = gdm_cpu_to_dev16(udev->gdm_ed, 1); hci->data[0] = MAC_ADDRESS; ret = usb_bulk_msg(usbdev, usb_sndbulkpipe(usbdev, 2), buf, 5, @@ -410,7 +410,7 @@ static void do_rx(struct work_struct *work) phy_dev = r->cb_data; udev = phy_dev->priv_dev; hci = (struct hci_packet *)r->buf; - cmd_evt = gdm_dev16_to_cpu(&udev->gdm_ed, hci->cmd_evt); + cmd_evt = gdm_dev16_to_cpu(udev->gdm_ed, hci->cmd_evt); switch (cmd_evt) { case LTE_GET_INFORMATION_RESULT: @@ -604,7 +604,7 @@ static u32 packet_aggregation(struct lte_udev *udev, u8 *send_buf) u16 num_packet = 0; unsigned long flags; - multi_sdu->cmd_evt = gdm_cpu_to_dev16(&udev->gdm_ed, LTE_TX_MULTI_SDU); + multi_sdu->cmd_evt = gdm_cpu_to_dev16(udev->gdm_ed, LTE_TX_MULTI_SDU); while (num_packet < MAX_PACKET_IN_MULTI_SDU) { spin_lock_irqsave(&tx->lock, flags); @@ -635,8 +635,8 @@ static u32 packet_aggregation(struct lte_udev *udev, u8 *send_buf) spin_unlock_irqrestore(&tx->lock, flags); } - multi_sdu->len = gdm_cpu_to_dev16(&udev->gdm_ed, send_len); - multi_sdu->num_packet = gdm_cpu_to_dev16(&udev->gdm_ed, num_packet); + multi_sdu->len = gdm_cpu_to_dev16(udev->gdm_ed, send_len); + multi_sdu->num_packet = gdm_cpu_to_dev16(udev->gdm_ed, num_packet); return send_len + offsetof(struct multi_sdu, data); } @@ -735,7 +735,7 @@ static int gdm_usb_sdu_send(void *priv_dev, void *data, int len, } sdu = (struct sdu *)t_sdu->buf; - sdu->cmd_evt = gdm_cpu_to_dev16(&udev->gdm_ed, LTE_TX_SDU); + sdu->cmd_evt = gdm_cpu_to_dev16(udev->gdm_ed, LTE_TX_SDU); if (nic_type == NIC_TYPE_ARP) { send_len = len + SDU_PARAM_LEN; memcpy(sdu->data, data, len); @@ -745,10 +745,10 @@ static int gdm_usb_sdu_send(void *priv_dev, void *data, int len, memcpy(sdu->data, data + ETH_HLEN, len - ETH_HLEN); } - sdu->len = gdm_cpu_to_dev16(&udev->gdm_ed, send_len); - sdu->dft_eps_ID = gdm_cpu_to_dev32(&udev->gdm_ed, dft_eps_ID); - sdu->bearer_ID = gdm_cpu_to_dev32(&udev->gdm_ed, eps_ID); - sdu->nic_type = gdm_cpu_to_dev32(&udev->gdm_ed, nic_type); + sdu->len = gdm_cpu_to_dev16(udev->gdm_ed, send_len); + sdu->dft_eps_ID = gdm_cpu_to_dev32(udev->gdm_ed, dft_eps_ID); + sdu->bearer_ID = gdm_cpu_to_dev32(udev->gdm_ed, eps_ID); + sdu->nic_type = gdm_cpu_to_dev32(udev->gdm_ed, nic_type); t_sdu->len = send_len + HCI_HEADER_SIZE; t_sdu->callback = cb; @@ -799,11 +799,11 @@ static int gdm_usb_hci_send(void *priv_dev, void *data, int len, return 0; } -static struct gdm_endian *gdm_usb_get_endian(void *priv_dev) +static u8 gdm_usb_get_endian(void *priv_dev) { struct lte_udev *udev = priv_dev; - return &udev->gdm_ed; + return udev->gdm_ed; } static int gdm_usb_probe(struct usb_interface *intf, @@ -859,9 +859,9 @@ static int gdm_usb_probe(struct usb_interface *intf, * defaults to little endian */ if (idProduct == PID_GDM7243) - gdm_set_endian(&udev->gdm_ed, ENDIANNESS_BIG); + udev->gdm_ed = ENDIANNESS_BIG; else - gdm_set_endian(&udev->gdm_ed, ENDIANNESS_LITTLE); + udev->gdm_ed = ENDIANNESS_LITTLE; ret = request_mac_address(udev); if (ret < 0) { diff --git a/drivers/staging/gdm724x/gdm_usb.h b/drivers/staging/gdm724x/gdm_usb.h index ffb3d995097d..701038685e23 100644 --- a/drivers/staging/gdm724x/gdm_usb.h +++ b/drivers/staging/gdm724x/gdm_usb.h @@ -93,11 +93,11 @@ struct rx_cxt { struct lte_udev { struct usb_device *usbdev; - struct gdm_endian gdm_ed; struct tx_cxt tx; struct rx_cxt rx; struct delayed_work work_tx; struct delayed_work work_rx; + u8 gdm_ed; u8 send_complete; u8 tx_stop; struct usb_interface *intf; -- 2.16.2 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/2] Staging: gdm724x: LTE: Refactor gdm_lte_pdn_table(). 2018-02-21 13:12 ` [PATCH 1/2] Staging: gdm724x: Simplify the struct gdm_endian to a variable Quytelda Kahja @ 2018-02-21 13:12 ` Quytelda Kahja 2018-02-21 13:21 ` [PATCH 1/2] Staging: gdm724x: Simplify the struct gdm_endian to a variable Dan Carpenter 2018-02-22 14:02 ` Greg KH 2 siblings, 0 replies; 16+ messages in thread From: Quytelda Kahja @ 2018-02-21 13:12 UTC (permalink / raw) To: gregkh, jonathankim, deanahn, dan.carpenter Cc: devel, Quytelda Kahja, linux-kernel Mostly this change just reverses the primary conditional so most of the code can be pulled back a tab, which fixes some code style warnings. Signed-off-by: Quytelda Kahja <quytelda@tamalin.org> --- drivers/staging/gdm724x/gdm_lte.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c index 92cb9d115fe3..4f3c518304f2 100644 --- a/drivers/staging/gdm724x/gdm_lte.c +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -730,21 +730,21 @@ static void gdm_lte_pdn_table(struct net_device *dev, char *buf, int len) { struct nic *nic = netdev_priv(dev); struct hci_pdn_table_ind *pdn_table = (struct hci_pdn_table_ind *)buf; - u8 ed; + u8 ed = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); - if (pdn_table->activate) { - nic->pdn_table.activate = pdn_table->activate; - - ed = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); - nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu(ed, pdn_table->dft_eps_id); - nic->pdn_table.nic_type = gdm_dev32_to_cpu(ed, pdn_table->nic_type); - - netdev_info(dev, "pdn activated, nic_type=0x%x\n", - nic->pdn_table.nic_type); - } else { + if (!pdn_table->activate) { memset(&nic->pdn_table, 0x00, sizeof(struct pdn_table)); netdev_info(dev, "pdn deactivated\n"); + + return; } + + nic->pdn_table.activate = pdn_table->activate; + nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu(ed, pdn_table->dft_eps_id); + nic->pdn_table.nic_type = gdm_dev32_to_cpu(ed, pdn_table->nic_type); + + netdev_info(dev, "pdn activated, nic_type=0x%x\n", + nic->pdn_table.nic_type); } static int gdm_lte_receive_pkt(struct phy_dev *phy_dev, char *buf, int len) -- 2.16.2 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] Staging: gdm724x: Simplify the struct gdm_endian to a variable. 2018-02-21 13:12 ` [PATCH 1/2] Staging: gdm724x: Simplify the struct gdm_endian to a variable Quytelda Kahja 2018-02-21 13:12 ` [PATCH 2/2] Staging: gdm724x: LTE: Refactor gdm_lte_pdn_table() Quytelda Kahja @ 2018-02-21 13:21 ` Dan Carpenter 2018-02-22 14:02 ` Greg KH 2 siblings, 0 replies; 16+ messages in thread From: Dan Carpenter @ 2018-02-21 13:21 UTC (permalink / raw) To: Quytelda Kahja; +Cc: devel, gregkh, jonathankim, linux-kernel, deanahn On Wed, Feb 21, 2018 at 05:12:36AM -0800, Quytelda Kahja wrote: > Since the testing for host endianness and in-driver conversion were > removed in 77e8a50149a2, the gdm_endian struct contains only one member, > and can therefore be simplified to a single u8 variable. > > Signed-off-by: Quytelda Kahja <quytelda@tamalin.org> This looks nice. Thanks! regards, dan carpenter _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] Staging: gdm724x: Simplify the struct gdm_endian to a variable. 2018-02-21 13:12 ` [PATCH 1/2] Staging: gdm724x: Simplify the struct gdm_endian to a variable Quytelda Kahja 2018-02-21 13:12 ` [PATCH 2/2] Staging: gdm724x: LTE: Refactor gdm_lte_pdn_table() Quytelda Kahja 2018-02-21 13:21 ` [PATCH 1/2] Staging: gdm724x: Simplify the struct gdm_endian to a variable Dan Carpenter @ 2018-02-22 14:02 ` Greg KH 2018-02-23 1:16 ` Quytelda Kahja 2 siblings, 1 reply; 16+ messages in thread From: Greg KH @ 2018-02-22 14:02 UTC (permalink / raw) To: Quytelda Kahja; +Cc: devel, deanahn, jonathankim, linux-kernel, dan.carpenter On Wed, Feb 21, 2018 at 05:12:36AM -0800, Quytelda Kahja wrote: > Since the testing for host endianness and in-driver conversion were > removed in 77e8a50149a2, the gdm_endian struct contains only one member, > and can therefore be simplified to a single u8 variable. > > Signed-off-by: Quytelda Kahja <quytelda@tamalin.org> This patch series does not apply to my tree :( _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] Staging: gdm724x: Simplify the struct gdm_endian to a variable. 2018-02-22 14:02 ` Greg KH @ 2018-02-23 1:16 ` Quytelda Kahja 2018-02-23 1:30 ` [PATCH 1/4] Staging: gdm724x: LTE: Fix trailing open parentheses Quytelda Kahja 2018-02-23 1:32 ` [PATCH 2/4] Staging: gdm724x: hci: Changed camel-case to snake-case Quytelda Kahja 0 siblings, 2 replies; 16+ messages in thread From: Quytelda Kahja @ 2018-02-23 1:16 UTC (permalink / raw) To: Greg KH; +Cc: devel, deanahn, jonathankim, linux-kernel, Dan Carpenter Sorry, it depends on the several patches I submitted earlier in that email thread, since they were in response to several suggestions for earlier patches. I will resend all of the patches in that thread as a consecutive patch series in response to this email to minimize confusion. Thank you, Quytelda Kahja On Thu, Feb 22, 2018 at 6:02 AM, Greg KH <gregkh@linuxfoundation.org> wrote: > On Wed, Feb 21, 2018 at 05:12:36AM -0800, Quytelda Kahja wrote: >> Since the testing for host endianness and in-driver conversion were >> removed in 77e8a50149a2, the gdm_endian struct contains only one member, >> and can therefore be simplified to a single u8 variable. >> >> Signed-off-by: Quytelda Kahja <quytelda@tamalin.org> > > This patch series does not apply to my tree :( _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/4] Staging: gdm724x: LTE: Fix trailing open parentheses. 2018-02-23 1:16 ` Quytelda Kahja @ 2018-02-23 1:30 ` Quytelda Kahja 2018-02-23 1:32 ` [PATCH 2/4] Staging: gdm724x: hci: Changed camel-case to snake-case Quytelda Kahja 1 sibling, 0 replies; 16+ messages in thread From: Quytelda Kahja @ 2018-02-23 1:30 UTC (permalink / raw) To: gregkh, jonathankim, deanahn, dan.carpenter Cc: devel, Quytelda Kahja, linux-kernel Fix lines with a trailing open parenthesis, which is a coding style issue. Signed-off-by: Quytelda Kahja <quytelda@tamalin.org> --- drivers/staging/gdm724x/gdm_lte.c | 44 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c index a6608637035a..8d492d6d6a12 100644 --- a/drivers/staging/gdm724x/gdm_lte.c +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -185,6 +185,7 @@ static __sum16 icmp6_checksum(struct ipv6hdr *ipv6, u16 *ptr, int len) unsigned short *w = ptr; __wsum sum = 0; int i; + u16 pa; union { struct { @@ -204,9 +205,10 @@ static __sum16 icmp6_checksum(struct ipv6hdr *ipv6, u16 *ptr, int len) pseudo_header.ph.ph_nxt = ipv6->nexthdr; w = (u16 *)&pseudo_header; - for (i = 0; i < ARRAY_SIZE(pseudo_header.pa); i++) - sum = csum_add(sum, csum_unfold( - (__force __sum16)pseudo_header.pa[i])); + for (i = 0; i < ARRAY_SIZE(pseudo_header.pa); i++) { + pa = pseudo_header.pa[i]; + sum = csum_add(sum, csum_unfold((__force __sum16)pa)); + } w = ptr; while (len > 1) { @@ -509,8 +511,9 @@ static struct net_device_stats *gdm_lte_stats(struct net_device *dev) static int gdm_lte_event_send(struct net_device *dev, char *buf, int len) { - struct nic *nic = netdev_priv(dev); + struct phy_dev *phy_dev = ((struct nic *)netdev_priv(dev))->phy_dev; struct hci_packet *hci = (struct hci_packet *)buf; + int length; int idx; int ret; @@ -518,11 +521,9 @@ static int gdm_lte_event_send(struct net_device *dev, char *buf, int len) if (ret != 1) return -EINVAL; - return netlink_send(lte_event.sock, idx, 0, buf, - gdm_dev16_to_cpu( - nic->phy_dev->get_endian( - nic->phy_dev->priv_dev), hci->len) - + HCI_HEADER_SIZE); + length = gdm_dev16_to_cpu(phy_dev->get_endian(phy_dev->priv_dev), + hci->len) + HCI_HEADER_SIZE; + return netlink_send(lte_event.sock, idx, 0, buf, length); } static void gdm_lte_event_rcv(struct net_device *dev, u16 type, @@ -731,15 +732,13 @@ static void gdm_lte_pdn_table(struct net_device *dev, char *buf, int len) struct hci_pdn_table_ind *pdn_table = (struct hci_pdn_table_ind *)buf; if (pdn_table->activate) { + struct gdm_endian *ed; + nic->pdn_table.activate = pdn_table->activate; - nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu( - nic->phy_dev->get_endian( - nic->phy_dev->priv_dev), - pdn_table->dft_eps_id); - nic->pdn_table.nic_type = gdm_dev32_to_cpu( - nic->phy_dev->get_endian( - nic->phy_dev->priv_dev), - pdn_table->nic_type); + + ed = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); + nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu(ed, pdn_table->dft_eps_id); + nic->pdn_table.nic_type = gdm_dev32_to_cpu(ed, pdn_table->nic_type); netdev_info(dev, "pdn activated, nic_type=0x%x\n", nic->pdn_table.nic_type); @@ -897,12 +896,11 @@ int register_lte_device(struct phy_dev *phy_dev, nic->phy_dev = phy_dev; nic->nic_id = index; - form_mac_address( - net->dev_addr, - nic->src_mac_addr, - nic->dest_mac_addr, - mac_address, - index); + form_mac_address(net->dev_addr, + nic->src_mac_addr, + nic->dest_mac_addr, + mac_address, + index); SET_NETDEV_DEV(net, dev); SET_NETDEV_DEVTYPE(net, &wwan_type); -- 2.16.2 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/4] Staging: gdm724x: hci: Changed camel-case to snake-case. 2018-02-23 1:16 ` Quytelda Kahja 2018-02-23 1:30 ` [PATCH 1/4] Staging: gdm724x: LTE: Fix trailing open parentheses Quytelda Kahja @ 2018-02-23 1:32 ` Quytelda Kahja 2018-02-23 1:33 ` [PATCH 3/4] Staging: gdm724x: Simplify the struct gdm_endian to a variable Quytelda Kahja ` (2 more replies) 1 sibling, 3 replies; 16+ messages in thread From: Quytelda Kahja @ 2018-02-23 1:32 UTC (permalink / raw) To: gregkh, jonathankim, deanahn, dan.carpenter Cc: devel, Quytelda Kahja, linux-kernel Changed a variable name from camel to snake case to fix a coding style issue. Signed-off-by: Quytelda Kahja <quytelda@tamalin.org> --- drivers/staging/gdm724x/hci_packet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gdm724x/hci_packet.h b/drivers/staging/gdm724x/hci_packet.h index 22ce8b9477b6..f8837c7103ac 100644 --- a/drivers/staging/gdm724x/hci_packet.h +++ b/drivers/staging/gdm724x/hci_packet.h @@ -50,7 +50,7 @@ struct tlv { struct sdu_header { __dev16 cmd_evt; __dev16 len; - __dev32 dftEpsId; + __dev32 dft_eps_ID; __dev32 bearer_ID; __dev32 nic_type; } __packed; -- 2.16.2 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 3/4] Staging: gdm724x: Simplify the struct gdm_endian to a variable. 2018-02-23 1:32 ` [PATCH 2/4] Staging: gdm724x: hci: Changed camel-case to snake-case Quytelda Kahja @ 2018-02-23 1:33 ` Quytelda Kahja 2018-02-23 1:33 ` [PATCH 4/4] Staging: gdm724x: LTE: Refactor gdm_lte_pdn_table() Quytelda Kahja 2018-02-23 8:15 ` [PATCH 2/4] Staging: gdm724x: hci: Changed camel-case to snake-case Greg KH 2 siblings, 0 replies; 16+ messages in thread From: Quytelda Kahja @ 2018-02-23 1:33 UTC (permalink / raw) To: gregkh, jonathankim, deanahn, dan.carpenter Cc: devel, Quytelda Kahja, linux-kernel Since the testing for host endianness and in-driver conversion were removed in 77e8a50149a2, the gdm_endian struct contains only one member, and can therefore be simplified to a single u8 variable. Signed-off-by: Quytelda Kahja <quytelda@tamalin.org> --- drivers/staging/gdm724x/gdm_endian.c | 24 ++++++++---------------- drivers/staging/gdm724x/gdm_endian.h | 13 ++++--------- drivers/staging/gdm724x/gdm_lte.c | 7 +++---- drivers/staging/gdm724x/gdm_lte.h | 2 +- drivers/staging/gdm724x/gdm_usb.c | 30 +++++++++++++++--------------- drivers/staging/gdm724x/gdm_usb.h | 2 +- 6 files changed, 32 insertions(+), 46 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_endian.c b/drivers/staging/gdm724x/gdm_endian.c index d0b43e20ec06..4200391b1a97 100644 --- a/drivers/staging/gdm724x/gdm_endian.c +++ b/drivers/staging/gdm724x/gdm_endian.c @@ -14,41 +14,33 @@ #include <linux/kernel.h> #include "gdm_endian.h" -void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian) +__dev16 gdm_cpu_to_dev16(u8 dev_ed, u16 x) { - if (dev_endian == ENDIANNESS_BIG) - ed->dev_ed = ENDIANNESS_BIG; - else - ed->dev_ed = ENDIANNESS_LITTLE; -} - -__dev16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x) -{ - if (ed->dev_ed == ENDIANNESS_LITTLE) + if (dev_ed == ENDIANNESS_LITTLE) return (__force __dev16)cpu_to_le16(x); else return (__force __dev16)cpu_to_be16(x); } -u16 gdm_dev16_to_cpu(struct gdm_endian *ed, __dev16 x) +u16 gdm_dev16_to_cpu(u8 dev_ed, __dev16 x) { - if (ed->dev_ed == ENDIANNESS_LITTLE) + if (dev_ed == ENDIANNESS_LITTLE) return le16_to_cpu((__force __le16)x); else return be16_to_cpu((__force __be16)x); } -__dev32 gdm_cpu_to_dev32(struct gdm_endian *ed, u32 x) +__dev32 gdm_cpu_to_dev32(u8 dev_ed, u32 x) { - if (ed->dev_ed == ENDIANNESS_LITTLE) + if (dev_ed == ENDIANNESS_LITTLE) return (__force __dev32)cpu_to_le32(x); else return (__force __dev32)cpu_to_be32(x); } -u32 gdm_dev32_to_cpu(struct gdm_endian *ed, __dev32 x) +u32 gdm_dev32_to_cpu(u8 dev_ed, __dev32 x) { - if (ed->dev_ed == ENDIANNESS_LITTLE) + if (dev_ed == ENDIANNESS_LITTLE) return le32_to_cpu((__force __le32)x); else return be32_to_cpu((__force __be32)x); diff --git a/drivers/staging/gdm724x/gdm_endian.h b/drivers/staging/gdm724x/gdm_endian.h index a785f30bb369..e58d29f868ba 100644 --- a/drivers/staging/gdm724x/gdm_endian.h +++ b/drivers/staging/gdm724x/gdm_endian.h @@ -32,14 +32,9 @@ enum { ENDIANNESS_MAX }; -struct gdm_endian { - u8 dev_ed; -}; - -void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian); -__dev16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x); -u16 gdm_dev16_to_cpu(struct gdm_endian *ed, __dev16 x); -__dev32 gdm_cpu_to_dev32(struct gdm_endian *ed, u32 x); -u32 gdm_dev32_to_cpu(struct gdm_endian *ed, __dev32 x); +__dev16 gdm_cpu_to_dev16(u8 dev_ed, u16 x); +u16 gdm_dev16_to_cpu(u8 dev_ed, __dev16 x); +__dev32 gdm_cpu_to_dev32(u8 dev_ed, u32 x); +u32 gdm_dev32_to_cpu(u8 dev_ed, __dev32 x); #endif /*__GDM_ENDIAN_H__*/ diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c index 8d492d6d6a12..92cb9d115fe3 100644 --- a/drivers/staging/gdm724x/gdm_lte.c +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -685,7 +685,7 @@ static void gdm_lte_multi_sdu_pkt(struct phy_dev *phy_dev, char *buf, int len) struct net_device *dev; struct multi_sdu *multi_sdu = (struct multi_sdu *)buf; struct sdu *sdu = NULL; - struct gdm_endian *endian = phy_dev->get_endian(phy_dev->priv_dev); + u8 endian = phy_dev->get_endian(phy_dev->priv_dev); u8 *data = (u8 *)multi_sdu->data; u16 i = 0; u16 num_packet; @@ -730,10 +730,9 @@ static void gdm_lte_pdn_table(struct net_device *dev, char *buf, int len) { struct nic *nic = netdev_priv(dev); struct hci_pdn_table_ind *pdn_table = (struct hci_pdn_table_ind *)buf; + u8 ed; if (pdn_table->activate) { - struct gdm_endian *ed; - nic->pdn_table.activate = pdn_table->activate; ed = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); @@ -752,9 +751,9 @@ static int gdm_lte_receive_pkt(struct phy_dev *phy_dev, char *buf, int len) { struct hci_packet *hci = (struct hci_packet *)buf; struct hci_pdn_table_ind *pdn_table = (struct hci_pdn_table_ind *)buf; - struct gdm_endian *endian = phy_dev->get_endian(phy_dev->priv_dev); struct sdu *sdu; struct net_device *dev; + u8 endian = phy_dev->get_endian(phy_dev->priv_dev); int ret = 0; u16 cmd_evt; u32 nic_type; diff --git a/drivers/staging/gdm724x/gdm_lte.h b/drivers/staging/gdm724x/gdm_lte.h index 3ecaff1a40cb..bad0855e4721 100644 --- a/drivers/staging/gdm724x/gdm_lte.h +++ b/drivers/staging/gdm724x/gdm_lte.h @@ -56,7 +56,7 @@ struct phy_dev { int (*cb)(void *cb_data, void *data, int len, int context), void *cb_data, int context); - struct gdm_endian * (*get_endian)(void *priv_dev); + u8 (*get_endian)(void *priv_dev); }; struct nic { diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c index 87cd1f827455..c95bad4a8615 100644 --- a/drivers/staging/gdm724x/gdm_usb.c +++ b/drivers/staging/gdm724x/gdm_usb.c @@ -72,8 +72,8 @@ static int request_mac_address(struct lte_udev *udev) int actual; int ret = -1; - hci->cmd_evt = gdm_cpu_to_dev16(&udev->gdm_ed, LTE_GET_INFORMATION); - hci->len = gdm_cpu_to_dev16(&udev->gdm_ed, 1); + hci->cmd_evt = gdm_cpu_to_dev16(udev->gdm_ed, LTE_GET_INFORMATION); + hci->len = gdm_cpu_to_dev16(udev->gdm_ed, 1); hci->data[0] = MAC_ADDRESS; ret = usb_bulk_msg(usbdev, usb_sndbulkpipe(usbdev, 2), buf, 5, @@ -410,7 +410,7 @@ static void do_rx(struct work_struct *work) phy_dev = r->cb_data; udev = phy_dev->priv_dev; hci = (struct hci_packet *)r->buf; - cmd_evt = gdm_dev16_to_cpu(&udev->gdm_ed, hci->cmd_evt); + cmd_evt = gdm_dev16_to_cpu(udev->gdm_ed, hci->cmd_evt); switch (cmd_evt) { case LTE_GET_INFORMATION_RESULT: @@ -604,7 +604,7 @@ static u32 packet_aggregation(struct lte_udev *udev, u8 *send_buf) u16 num_packet = 0; unsigned long flags; - multi_sdu->cmd_evt = gdm_cpu_to_dev16(&udev->gdm_ed, LTE_TX_MULTI_SDU); + multi_sdu->cmd_evt = gdm_cpu_to_dev16(udev->gdm_ed, LTE_TX_MULTI_SDU); while (num_packet < MAX_PACKET_IN_MULTI_SDU) { spin_lock_irqsave(&tx->lock, flags); @@ -635,8 +635,8 @@ static u32 packet_aggregation(struct lte_udev *udev, u8 *send_buf) spin_unlock_irqrestore(&tx->lock, flags); } - multi_sdu->len = gdm_cpu_to_dev16(&udev->gdm_ed, send_len); - multi_sdu->num_packet = gdm_cpu_to_dev16(&udev->gdm_ed, num_packet); + multi_sdu->len = gdm_cpu_to_dev16(udev->gdm_ed, send_len); + multi_sdu->num_packet = gdm_cpu_to_dev16(udev->gdm_ed, num_packet); return send_len + offsetof(struct multi_sdu, data); } @@ -735,7 +735,7 @@ static int gdm_usb_sdu_send(void *priv_dev, void *data, int len, } sdu = (struct sdu *)t_sdu->buf; - sdu->cmd_evt = gdm_cpu_to_dev16(&udev->gdm_ed, LTE_TX_SDU); + sdu->cmd_evt = gdm_cpu_to_dev16(udev->gdm_ed, LTE_TX_SDU); if (nic_type == NIC_TYPE_ARP) { send_len = len + SDU_PARAM_LEN; memcpy(sdu->data, data, len); @@ -745,10 +745,10 @@ static int gdm_usb_sdu_send(void *priv_dev, void *data, int len, memcpy(sdu->data, data + ETH_HLEN, len - ETH_HLEN); } - sdu->len = gdm_cpu_to_dev16(&udev->gdm_ed, send_len); - sdu->dft_eps_ID = gdm_cpu_to_dev32(&udev->gdm_ed, dft_eps_ID); - sdu->bearer_ID = gdm_cpu_to_dev32(&udev->gdm_ed, eps_ID); - sdu->nic_type = gdm_cpu_to_dev32(&udev->gdm_ed, nic_type); + sdu->len = gdm_cpu_to_dev16(udev->gdm_ed, send_len); + sdu->dft_eps_ID = gdm_cpu_to_dev32(udev->gdm_ed, dft_eps_ID); + sdu->bearer_ID = gdm_cpu_to_dev32(udev->gdm_ed, eps_ID); + sdu->nic_type = gdm_cpu_to_dev32(udev->gdm_ed, nic_type); t_sdu->len = send_len + HCI_HEADER_SIZE; t_sdu->callback = cb; @@ -799,11 +799,11 @@ static int gdm_usb_hci_send(void *priv_dev, void *data, int len, return 0; } -static struct gdm_endian *gdm_usb_get_endian(void *priv_dev) +static u8 gdm_usb_get_endian(void *priv_dev) { struct lte_udev *udev = priv_dev; - return &udev->gdm_ed; + return udev->gdm_ed; } static int gdm_usb_probe(struct usb_interface *intf, @@ -859,9 +859,9 @@ static int gdm_usb_probe(struct usb_interface *intf, * defaults to little endian */ if (idProduct == PID_GDM7243) - gdm_set_endian(&udev->gdm_ed, ENDIANNESS_BIG); + udev->gdm_ed = ENDIANNESS_BIG; else - gdm_set_endian(&udev->gdm_ed, ENDIANNESS_LITTLE); + udev->gdm_ed = ENDIANNESS_LITTLE; ret = request_mac_address(udev); if (ret < 0) { diff --git a/drivers/staging/gdm724x/gdm_usb.h b/drivers/staging/gdm724x/gdm_usb.h index ffb3d995097d..701038685e23 100644 --- a/drivers/staging/gdm724x/gdm_usb.h +++ b/drivers/staging/gdm724x/gdm_usb.h @@ -93,11 +93,11 @@ struct rx_cxt { struct lte_udev { struct usb_device *usbdev; - struct gdm_endian gdm_ed; struct tx_cxt tx; struct rx_cxt rx; struct delayed_work work_tx; struct delayed_work work_rx; + u8 gdm_ed; u8 send_complete; u8 tx_stop; struct usb_interface *intf; -- 2.16.2 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 4/4] Staging: gdm724x: LTE: Refactor gdm_lte_pdn_table(). 2018-02-23 1:32 ` [PATCH 2/4] Staging: gdm724x: hci: Changed camel-case to snake-case Quytelda Kahja 2018-02-23 1:33 ` [PATCH 3/4] Staging: gdm724x: Simplify the struct gdm_endian to a variable Quytelda Kahja @ 2018-02-23 1:33 ` Quytelda Kahja 2018-02-23 8:15 ` [PATCH 2/4] Staging: gdm724x: hci: Changed camel-case to snake-case Greg KH 2 siblings, 0 replies; 16+ messages in thread From: Quytelda Kahja @ 2018-02-23 1:33 UTC (permalink / raw) To: gregkh, jonathankim, deanahn, dan.carpenter Cc: devel, Quytelda Kahja, linux-kernel Mostly this change just reverses the primary conditional so most of the code can be pulled back a tab, which fixes some code style warnings. Signed-off-by: Quytelda Kahja <quytelda@tamalin.org> --- drivers/staging/gdm724x/gdm_lte.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c index 92cb9d115fe3..4f3c518304f2 100644 --- a/drivers/staging/gdm724x/gdm_lte.c +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -730,21 +730,21 @@ static void gdm_lte_pdn_table(struct net_device *dev, char *buf, int len) { struct nic *nic = netdev_priv(dev); struct hci_pdn_table_ind *pdn_table = (struct hci_pdn_table_ind *)buf; - u8 ed; + u8 ed = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); - if (pdn_table->activate) { - nic->pdn_table.activate = pdn_table->activate; - - ed = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); - nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu(ed, pdn_table->dft_eps_id); - nic->pdn_table.nic_type = gdm_dev32_to_cpu(ed, pdn_table->nic_type); - - netdev_info(dev, "pdn activated, nic_type=0x%x\n", - nic->pdn_table.nic_type); - } else { + if (!pdn_table->activate) { memset(&nic->pdn_table, 0x00, sizeof(struct pdn_table)); netdev_info(dev, "pdn deactivated\n"); + + return; } + + nic->pdn_table.activate = pdn_table->activate; + nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu(ed, pdn_table->dft_eps_id); + nic->pdn_table.nic_type = gdm_dev32_to_cpu(ed, pdn_table->nic_type); + + netdev_info(dev, "pdn activated, nic_type=0x%x\n", + nic->pdn_table.nic_type); } static int gdm_lte_receive_pkt(struct phy_dev *phy_dev, char *buf, int len) -- 2.16.2 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 2/4] Staging: gdm724x: hci: Changed camel-case to snake-case. 2018-02-23 1:32 ` [PATCH 2/4] Staging: gdm724x: hci: Changed camel-case to snake-case Quytelda Kahja 2018-02-23 1:33 ` [PATCH 3/4] Staging: gdm724x: Simplify the struct gdm_endian to a variable Quytelda Kahja 2018-02-23 1:33 ` [PATCH 4/4] Staging: gdm724x: LTE: Refactor gdm_lte_pdn_table() Quytelda Kahja @ 2018-02-23 8:15 ` Greg KH 2018-02-23 23:46 ` [PATCH] staging: gdm724x: hci: Remove unused struct sdu_header Quytelda Kahja 2 siblings, 1 reply; 16+ messages in thread From: Greg KH @ 2018-02-23 8:15 UTC (permalink / raw) To: Quytelda Kahja; +Cc: devel, deanahn, jonathankim, linux-kernel, dan.carpenter On Thu, Feb 22, 2018 at 05:32:59PM -0800, Quytelda Kahja wrote: > Changed a variable name from camel to snake case to fix a coding style > issue. > > Signed-off-by: Quytelda Kahja <quytelda@tamalin.org> > --- > drivers/staging/gdm724x/hci_packet.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/gdm724x/hci_packet.h b/drivers/staging/gdm724x/hci_packet.h > index 22ce8b9477b6..f8837c7103ac 100644 > --- a/drivers/staging/gdm724x/hci_packet.h > +++ b/drivers/staging/gdm724x/hci_packet.h > @@ -50,7 +50,7 @@ struct tlv { > struct sdu_header { > __dev16 cmd_evt; > __dev16 len; > - __dev32 dftEpsId; > + __dev32 dft_eps_ID; > __dev32 bearer_ID; > __dev32 nic_type; > } __packed; Why not just delete the whole structure if no one is using it? thanks, greg k-h _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH] staging: gdm724x: hci: Remove unused struct sdu_header. 2018-02-23 8:15 ` [PATCH 2/4] Staging: gdm724x: hci: Changed camel-case to snake-case Greg KH @ 2018-02-23 23:46 ` Quytelda Kahja 0 siblings, 0 replies; 16+ messages in thread From: Quytelda Kahja @ 2018-02-23 23:46 UTC (permalink / raw) To: gregkh, deanahn, dan.carpenter; +Cc: devel, linux-kernel, Quytelda Kahja struct sdu_header isn't actually used anywhere in this driver, so this change removes it on the assumption it isn't needed for any API. Signed-off-by: Quytelda Kahja <quytelda@tamalin.org> --- drivers/staging/gdm724x/hci_packet.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/gdm724x/hci_packet.h b/drivers/staging/gdm724x/hci_packet.h index f8837c7103ac..695482464596 100644 --- a/drivers/staging/gdm724x/hci_packet.h +++ b/drivers/staging/gdm724x/hci_packet.h @@ -47,14 +47,6 @@ struct tlv { u8 *data[1]; } __packed; -struct sdu_header { - __dev16 cmd_evt; - __dev16 len; - __dev32 dft_eps_ID; - __dev32 bearer_ID; - __dev32 nic_type; -} __packed; - struct sdu { __dev16 cmd_evt; __dev16 len; -- 2.16.2 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH] Staging: gdm724x: LTE: Fix trailing open parenthesis code style issue. 2018-02-16 21:40 [PATCH] Staging: gdm724x: LTE: Fix trailing open parenthesis code style issue Quytelda Kahja 2018-02-19 9:15 ` Dan Carpenter @ 2018-02-19 17:05 ` Greg KH 1 sibling, 0 replies; 16+ messages in thread From: Greg KH @ 2018-02-19 17:05 UTC (permalink / raw) To: Quytelda Kahja; +Cc: devel, linux-kernel On Fri, Feb 16, 2018 at 01:40:08PM -0800, Quytelda Kahja wrote: > Fix a coding style problem causing warnings from checkpatch.pl. > > Signed-off-by: Quytelda Kahja <quytelda@tamalin.org> > --- > drivers/staging/gdm724x/gdm_lte.c | 50 ++++++++++++++++++++++----------------- > 1 file changed, 28 insertions(+), 22 deletions(-) > > diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c > index 0527b0d1c1d0..ff3fed9c4a81 100644 > --- a/drivers/staging/gdm724x/gdm_lte.c > +++ b/drivers/staging/gdm724x/gdm_lte.c > @@ -204,9 +204,12 @@ static __sum16 icmp6_checksum(struct ipv6hdr *ipv6, u16 *ptr, int len) > pseudo_header.ph.ph_nxt = ipv6->nexthdr; > > w = (u16 *)&pseudo_header; > - for (i = 0; i < ARRAY_SIZE(pseudo_header.pa); i++) > - sum = csum_add(sum, csum_unfold( > - (__force __sum16)pseudo_header.pa[i])); > + for (i = 0; i < ARRAY_SIZE(pseudo_header.pa); i++) { > + __wsum tmp_sum; > + > + tmp_sum = csum_unfold((__force __sum16)pseudo_header.pa[i]); > + sum = csum_add(sum, tmp_sum); > + } > > w = ptr; > while (len > 1) { > @@ -510,18 +513,18 @@ static int gdm_lte_event_send(struct net_device *dev, char *buf, int len) > { > struct nic *nic = netdev_priv(dev); > struct hci_packet *hci = (struct hci_packet *)buf; > + struct gdm_endian *phy_endian; > int idx; > + u16 cpu; > int ret; > > ret = sscanf(dev->name, "lte%d", &idx); > if (ret != 1) > return -EINVAL; > > - return netlink_send(lte_event.sock, idx, 0, buf, > - gdm_dev16_to_cpu( > - nic->phy_dev->get_endian( > - nic->phy_dev->priv_dev), hci->len) > - + HCI_HEADER_SIZE); > + phy_endian = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); > + cpu = gdm_dev16_to_cpu(phy_endian, hci->len); > + return netlink_send(lte_event.sock, idx, 0, buf, cpu + HCI_HEADER_SIZE); > } > > static void gdm_lte_event_rcv(struct net_device *dev, u16 type, > @@ -728,17 +731,21 @@ static void gdm_lte_pdn_table(struct net_device *dev, char *buf, int len) > { > struct nic *nic = netdev_priv(dev); > struct hci_pdn_table_ind *pdn_table = (struct hci_pdn_table_ind *)buf; > + struct gdm_endian *dft_endian; > + struct gdm_endian *nic_endian; > > if (pdn_table->activate) { > nic->pdn_table.activate = pdn_table->activate; > - nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu( > - nic->phy_dev->get_endian( > - nic->phy_dev->priv_dev), > - pdn_table->dft_eps_id); > - nic->pdn_table.nic_type = gdm_dev32_to_cpu( > - nic->phy_dev->get_endian( > - nic->phy_dev->priv_dev), > - pdn_table->nic_type); > + > + dft_endian = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); > + nic_endian = nic->phy_dev->get_endian(nic->phy_dev->priv_dev); These are the same values :( _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2018-02-23 23:46 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-02-16 21:40 [PATCH] Staging: gdm724x: LTE: Fix trailing open parenthesis code style issue Quytelda Kahja 2018-02-19 9:15 ` Dan Carpenter 2018-02-21 10:20 ` [PATCH] Staging: gdm724x: LTE: Fix trailing open parentheses Quytelda Kahja 2018-02-21 10:43 ` Dan Carpenter 2018-02-21 13:12 ` [PATCH 1/2] Staging: gdm724x: Simplify the struct gdm_endian to a variable Quytelda Kahja 2018-02-21 13:12 ` [PATCH 2/2] Staging: gdm724x: LTE: Refactor gdm_lte_pdn_table() Quytelda Kahja 2018-02-21 13:21 ` [PATCH 1/2] Staging: gdm724x: Simplify the struct gdm_endian to a variable Dan Carpenter 2018-02-22 14:02 ` Greg KH 2018-02-23 1:16 ` Quytelda Kahja 2018-02-23 1:30 ` [PATCH 1/4] Staging: gdm724x: LTE: Fix trailing open parentheses Quytelda Kahja 2018-02-23 1:32 ` [PATCH 2/4] Staging: gdm724x: hci: Changed camel-case to snake-case Quytelda Kahja 2018-02-23 1:33 ` [PATCH 3/4] Staging: gdm724x: Simplify the struct gdm_endian to a variable Quytelda Kahja 2018-02-23 1:33 ` [PATCH 4/4] Staging: gdm724x: LTE: Refactor gdm_lte_pdn_table() Quytelda Kahja 2018-02-23 8:15 ` [PATCH 2/4] Staging: gdm724x: hci: Changed camel-case to snake-case Greg KH 2018-02-23 23:46 ` [PATCH] staging: gdm724x: hci: Remove unused struct sdu_header Quytelda Kahja 2018-02-19 17:05 ` [PATCH] Staging: gdm724x: LTE: Fix trailing open parenthesis code style issue Greg KH
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).