staging: gasket: core: Fix a coding style issue in gasket_core.c
PATCH v2 1/1 staging: gasket: core: Fix a coding style issue in gasket_core.c
A coding alignment issue is found by checkpatch.pl. Fix it by using a temporary for gasket_dev->bar_data[bar_num].
---
Please ignore the last email (if you received it) because I forgot to Cc the mailing list. Sorry for the noise...
Changes in v2:
- gasket_dev->bar_data[bar_num] was used everywhere. Now replace it with a struct gasket_bar_data *data, making the code more elegant. Thanks to Joe Perches.
drivers/staging/gasket/gasket_core.c | 29 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/staging/gasket/gasket_core.c +14 -15
@@ -261,6 +261,7 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num)const struct gasket_driver_desc *driver_desc = internal_desc->driver_desc;ulong desc_bytes = driver_desc->bar_descriptions[bar_num].size; +struct gasket_bar_data *data;int ret;if (desc_bytes ==0 )
@@ -270,31 +271,32 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num)/* not PCI: skip this entry */ return 0 ; } + + data = &gasket_dev->bar_data[bar_num]; +/* * pci_resource_start and pci_resource_len return a "resource_size_t", * which is safely castable to ulong (which itself is the arg to * request_mem_region). */ - gasket_dev->bar_data[bar_num].phys_base = + data->phys_base = (ulong )pci_resource_start (gasket_dev->pci_dev, bar_num); -if (!gasket_dev->bar_data[bar_num].phys_base) { +if (!data->phys_base) {dev_err (gasket_dev->dev,"Cannot get BAR%u base address\n" , bar_num);return -EINVAL ; } - gasket_dev->bar_data[bar_num].length_bytes = + data->length_bytes = (ulong )pci_resource_len (gasket_dev->pci_dev, bar_num); -if (gasket_dev->bar_data[bar_num].length_bytes < desc_bytes) { +if (data->length_bytes < desc_bytes) {dev_err (gasket_dev->dev,"PCI BAR %u space is too small: %lu; expected >= %lu\n" , - bar_num, gasket_dev->bar_data[bar_num].length_bytes, - desc_bytes); + bar_num, data->length_bytes, desc_bytes);return -ENOMEM ; } -if (!request_mem_region (gasket_dev->bar_data[bar_num].phys_base, - gasket_dev->bar_data[bar_num].length_bytes, +if (!request_mem_region (data->phys_base, data->length_bytes, gasket_dev->dev_info.name)) { dev_err(gasket_dev->dev, "Cannot get BAR %d memory region %p\n",
@@ -302,10 +304,8 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num)return -EINVAL ; } - gasket_dev->bar_data[bar_num].virt_base = -ioremap (gasket_dev->bar_data[bar_num].phys_base, - gasket_dev->bar_data[bar_num].length_bytes); -if (!gasket_dev->bar_data[bar_num].virt_base) { + data->virt_base =ioremap (data->phys_base, data->length_bytes); +if (!data->virt_base) {dev_err (gasket_dev->dev,"Cannot remap BAR %d memory region %p\n" , bar_num, &gasket_dev->pci_dev->resource[bar_num]);
@@ -319,9 +319,8 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num)return 0 ; fail: -iounmap (gasket_dev->bar_data[bar_num].virt_base); -release_mem_region (gasket_dev->bar_data[bar_num].phys_base, - gasket_dev->bar_data[bar_num].length_bytes); +iounmap (data->virt_base); +release_mem_region (data->phys_base, data->length_bytes);return ret; }
Signature · 1 line
2.17.1
drivers/staging/gasket/gasket_core.c static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num) · line 263
Quoted 8 lines · Zhixu Zhao
drivers/staging/gasket/gasket_core.c +0
-0@@ -261,6 +261,7 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num)const struct gasket_driver_desc *driver_desc = internal_desc->driver_desc;ulong desc_bytes = driver_desc->bar_descriptions[bar_num].size;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Get rid of this as well (below).
drivers/staging/gasket/gasket_core.c static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num) · line 275
Quoted 10 lines
drivers/staging/gasket/gasket_core.c +3
-0+struct gasket_bar_data *data;int ret;if (desc_bytes ==0 )@@ -270,31 +271,32 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num)/* not PCI: skip this entry */ return 0 ; } + + data = &gasket_dev->bar_data[bar_num];
It would be better to do this in the declaration block so you can change the earlier two uses in this function:
+ struct gasket_bar_data *data = &gasket_dev->bar_data[bar_num];
- ulong desc_bytes = driver_desc->bar_descriptions[bar_num].size;
+ ulong desc_bytes = data->size;
...
- if (driver_desc->bar_descriptions[bar_num].type != PCI_BAR) {
+ if (data->type != PCI_BAR) {
regards,
dan carpenter
Quoted 35 lines · Dan Carpenter
drivers/staging/gasket/gasket_core.c static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num) · line 263
Quoted 8 lines · Zhixu Zhao
drivers/staging/gasket/gasket_core.c +0
-0@@ -261,6 +261,7 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num)const struct gasket_driver_desc *driver_desc = internal_desc->driver_desc;ulong desc_bytes = driver_desc->bar_descriptions[bar_num].size;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Get rid of this as well (below).
drivers/staging/gasket/gasket_core.c static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num) · line 275
Quoted 10 lines
drivers/staging/gasket/gasket_core.c +3
-0+struct gasket_bar_data *data;int ret;if (desc_bytes ==0 )@@ -270,31 +271,32 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num)/* not PCI: skip this entry */ return 0 ; } + + data = &gasket_dev->bar_data[bar_num];It would be better to do this in the declaration block so you can change the earlier two uses in this function:
(quoted diff) +3
-2+ struct gasket_bar_data *data = &gasket_dev->bar_data[bar_num]; - ulong desc_bytes = driver_desc->bar_descriptions[bar_num].size; + ulong desc_bytes = data->size; - if (driver_desc->bar_descriptions[bar_num].type != PCI_BAR) { + if (data->type != PCI_BAR) {
Quoted 2 lines
regards,
dan carpenter
This issue has been resolved in https://lore.kernel.org/lkml/20200618140327.GS4151@kadam/
Zhixu
Review
Quoted 11 lines · Dan Carpenter
It would be better to do this in the declaration block so you can change the earlier two uses in this function:
(quoted diff) +3
-2+ struct gasket_bar_data *data = &gasket_dev->bar_data[bar_num]; - ulong desc_bytes = driver_desc->bar_descriptions[bar_num].size; + ulong desc_bytes = data->size; - if (driver_desc->bar_descriptions[bar_num].type != PCI_BAR) { + if (data->type != PCI_BAR) {
struct gasket_bar_data *data and driver_desc->bar_descriptions[bar_num] are not the same thing as I see it. Besides, struct gasket_bar_data doesn't have a size field (it does have a length_bytes field). So... did I miss anything?
Signature · 2 lines
Zhixu Zhao https://github.com/zhaozhixu
Dan Carpenter
Reviewed-byQuoted 10 lines · Zhixu Zhao
Quoted 9 lines · Dan Carpenter
It would be better to do this in the declaration block so you can change the earlier two uses in this function:
(quoted diff) +2
-1+ struct gasket_bar_data *data = &gasket_dev->bar_data[bar_num]; - ulong desc_bytes = driver_desc->bar_descriptions[bar_num].size; + ulong desc_bytes = data->size;
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +1
-1- if (driver_desc->bar_descriptions[bar_num].type != PCI_BAR) { + if (data->type != PCI_BAR) {
struct gasket_bar_data *dataanddriver_desc->bar_descriptions[bar_num]are not the same thing as I see it. Besides,struct gasket_bar_datadoesn't have asizefield (it does have alength_bytesfield). So... did I miss anything?
Ah wow... I'm so sorry. You're right. Sorry for the noise.
regards,
dan carpenter
Quoted 4 lines · Zhixu Zhao
A coding alignment issue is found by checkpatch.pl. Fix it by using a temporary for gasket_dev->bar_data[bar_num].
Signed-off-by Zhixu Zhao <[email protected]>
Hi, there~
Does anybody have any further comments on this?
Can it be merged?
Zhixu
Greg KH
maintainerQuoted 10 lines · Zhixu Zhao
Quoted 4 lines · Zhixu Zhao
A coding alignment issue is found by checkpatch.pl. Fix it by using a temporary for gasket_dev->bar_data[bar_num].
Signed-off-by Zhixu Zhao <[email protected]>Hi, there~
Does anybody have any further comments on this?
Can it be merged?
I never saw the first version of this, are you sure it got sent to the mailing list? It's not in any archives anywhere.
Also, 3 days is really fast for a simple coding style cleanup to be worried about. Give it usually at least 2 weeks.
thanks,
greg k-h
Quoted 7 lines · Greg KH
Quoted 6 lines · Zhixu Zhao
Quoted 4 lines · Zhixu Zhao
A coding alignment issue is found by checkpatch.pl. Fix it by using a temporary for gasket_dev->bar_data[bar_num].
Signed-off-by Zhixu Zhao <[email protected]>
Quoted 7 lines
Quoted 4 lines
Hi, there~
Does anybody have any further comments on this?
Can it be merged?I never saw the first version of this, are you sure it got sent to the mailing list? It's not in any archives anywhere.
I saw it. It's here:
https://lore.kernel.org/lkml/[email protected]/
Quoted 2 lines
Also, 3 days is really fast for a simple coding style cleanup to be worried about. Give it usually at least 2 weeks.
Originally sent June 17.
Greg KH
maintainerQuoted 10 lines · Joe Perches
Quoted 9 lines · Greg KH
Quoted 8 lines · Zhixu Zhao
Quoted 4 lines · Zhixu Zhao
A coding alignment issue is found by checkpatch.pl. Fix it by using a temporary for gasket_dev->bar_data[bar_num].
Signed-off-by Zhixu Zhao <[email protected]>Hi, there~
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Does anybody have any further comments on this?
Can it be merged?I never saw the first version of this, are you sure it got sent to the mailing list? It's not in any archives anywhere.
I saw it. It's here:
https://lore.kernel.org/lkml/[email protected]/
Ah, doh, sorry.
Zhixu, please address the comments given to you on the series and resend it as a new version.
thanks,
greg k-h
Quoted 17 lines · Greg KH
Quoted 16 lines · Joe Perches
Quoted 14 lines · Greg KH
Quoted 10 lines · Zhixu Zhao
Quoted 4 lines · Zhixu Zhao
A coding alignment issue is found by checkpatch.pl. Fix it by using a temporary for gasket_dev->bar_data[bar_num].
Signed-off-by Zhixu Zhao <[email protected]>Hi, there~
Does anybody have any further comments on this?
Can it be merged?I never saw the first version of this, are you sure it got sent to the mailing list? It's not in any archives anywhere.
Quoted 7 lines
Quoted 2 lines
I saw it. It's here:
https://lore.kernel.org/lkml/[email protected]/Ah, doh, sorry.
Zhixu, please address the comments given to you on the series and resend it as a new version.
He responded but not as a reply to my email. It turns out I made a mistake.
Anyway, just resend, Zhixu.
regards,
dan carpenter
Quoted 23 lines · Dan Carpenter
Quoted 22 lines · Greg KH
Quoted 10 lines · Joe Perches
Quoted 9 lines · Greg KH
Quoted 8 lines · Zhixu Zhao
Quoted 4 lines · Zhixu Zhao
A coding alignment issue is found by checkpatch.pl. Fix it by using a temporary for gasket_dev->bar_data[bar_num].
Signed-off-by Zhixu Zhao <[email protected]>Hi, there~
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Does anybody have any further comments on this?
Can it be merged?I never saw the first version of this, are you sure it got sent to the mailing list? It's not in any archives anywhere.
I saw it. It's here:
https://lore.kernel.org/lkml/[email protected]/Ah, doh, sorry.
Quoted 7 lines
Quoted 2 lines
Zhixu, please address the comments given to you on the series and resend it as a new version.
He responded but not as a reply to my email. It turns out I made a mistake.
Anyway, just resend, Zhixu.
It's a pity a resend is being requested.
It'd be a better process if the original patch could be applied via the link akin to a git pull.
Quoted 30 lines · Joe Perches
Quoted 29 lines · Dan Carpenter
Quoted 17 lines · Greg KH
Quoted 16 lines · Joe Perches
Quoted 14 lines · Greg KH
Quoted 10 lines · Zhixu Zhao
Quoted 4 lines · Zhixu Zhao
A coding alignment issue is found by checkpatch.pl. Fix it by using a temporary for gasket_dev->bar_data[bar_num].
Signed-off-by Zhixu Zhao <[email protected]>Hi, there~
Does anybody have any further comments on this?
Can it be merged?I never saw the first version of this, are you sure it got sent to the mailing list? It's not in any archives anywhere.
Quoted 7 lines
Quoted 2 lines
I saw it. It's here:
https://lore.kernel.org/lkml/[email protected]/Ah, doh, sorry.
Zhixu, please address the comments given to you on the series and resend it as a new version.
He responded but not as a reply to my email. It turns out I made a mistake.
Quoted 7 lines
Quoted 1 line
Anyway, just resend, Zhixu.
It's a pity a resend is being requested.
It'd be a better process if the original patch could be applied via the link akin to a git pull.
Yes. All comments have been resolved by now. Patch v2 is sufficient.
As Dan said, there was a tailing thread because I mis-replied his mail.
I just now replied that mail with a reference to the final resolution mail.
Quoted 35 lines · Zhao
Quoted 34 lines · Joe Perches
Quoted 23 lines · Dan Carpenter
Quoted 22 lines · Greg KH
Quoted 10 lines · Joe Perches
Quoted 9 lines · Greg KH
Quoted 8 lines · Zhixu Zhao
Quoted 4 lines · Zhixu Zhao
A coding alignment issue is found by checkpatch.pl. Fix it by using a temporary for gasket_dev->bar_data[bar_num].
Signed-off-by Zhixu Zhao <[email protected]>Hi, there~
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Does anybody have any further comments on this?
Can it be merged?I never saw the first version of this, are you sure it got sent to the mailing list? It's not in any archives anywhere.
I saw it. It's here:
https://lore.kernel.org/lkml/[email protected]/Ah, doh, sorry.
Quoted 7 lines
Quoted 2 lines
Zhixu, please address the comments given to you on the series and resend it as a new version.
He responded but not as a reply to my email. It turns out I made a mistake.
Anyway, just resend, Zhixu.
It's a pity a resend is being requested.
Quoted 8 lines
Quoted 3 lines
It'd be a better process if the original patch could be applied via the link akin to a git pull.
Yes. All comments have been resolved by now. Patch v2 is sufficient.
As Dan said, there was a tailing thread because I mis-replied his mail.
I just now replied that mail with a reference to the final resolution mail.
Just resend.
regards,
dan carpenter
PATCH v3 1/1 staging: gasket: core: Fix a coding style issue in gasket_core.c
In reply to Zhixu ZhaoA coding alignment issue is found by checkpatch.pl. Fix it by using a temporary for gasket_dev->bar_data[bar_num].
---
Changes in v2:
- gasket_dev->bar_data[bar_num] was used everywhere. Now replace it with a struct gasket_bar_data *data, making the code more elegant. Thanks to Joe Perches.
About v3:
- Resolved all comments in v2. Resending it...
drivers/staging/gasket/gasket_core.c | 29 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/staging/gasket/gasket_core.c +14 -15
@@ -261,6 +261,7 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num)const struct gasket_driver_desc *driver_desc = internal_desc->driver_desc;ulong desc_bytes = driver_desc->bar_descriptions[bar_num].size; +struct gasket_bar_data *data;int ret;if (desc_bytes ==0 )
@@ -270,31 +271,32 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num)/* not PCI: skip this entry */ return 0 ; } + + data = &gasket_dev->bar_data[bar_num]; +/* * pci_resource_start and pci_resource_len return a "resource_size_t", * which is safely castable to ulong (which itself is the arg to * request_mem_region). */ - gasket_dev->bar_data[bar_num].phys_base = + data->phys_base = (ulong )pci_resource_start (gasket_dev->pci_dev, bar_num); -if (!gasket_dev->bar_data[bar_num].phys_base) { +if (!data->phys_base) {dev_err (gasket_dev->dev,"Cannot get BAR%u base address\n" , bar_num);return -EINVAL ; } - gasket_dev->bar_data[bar_num].length_bytes = + data->length_bytes = (ulong )pci_resource_len (gasket_dev->pci_dev, bar_num); -if (gasket_dev->bar_data[bar_num].length_bytes < desc_bytes) { +if (data->length_bytes < desc_bytes) {dev_err (gasket_dev->dev,"PCI BAR %u space is too small: %lu; expected >= %lu\n" , - bar_num, gasket_dev->bar_data[bar_num].length_bytes, - desc_bytes); + bar_num, data->length_bytes, desc_bytes);return -ENOMEM ; } -if (!request_mem_region (gasket_dev->bar_data[bar_num].phys_base, - gasket_dev->bar_data[bar_num].length_bytes, +if (!request_mem_region (data->phys_base, data->length_bytes, gasket_dev->dev_info.name)) { dev_err(gasket_dev->dev, "Cannot get BAR %d memory region %p\n",
@@ -302,10 +304,8 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num)return -EINVAL ; } - gasket_dev->bar_data[bar_num].virt_base = -ioremap (gasket_dev->bar_data[bar_num].phys_base, - gasket_dev->bar_data[bar_num].length_bytes); -if (!gasket_dev->bar_data[bar_num].virt_base) { + data->virt_base =ioremap (data->phys_base, data->length_bytes); +if (!data->virt_base) {dev_err (gasket_dev->dev,"Cannot remap BAR %d memory region %p\n" , bar_num, &gasket_dev->pci_dev->resource[bar_num]);
@@ -319,9 +319,8 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num)return 0 ; fail: -iounmap (gasket_dev->bar_data[bar_num].virt_base); -release_mem_region (gasket_dev->bar_data[bar_num].phys_base, - gasket_dev->bar_data[bar_num].length_bytes); +iounmap (data->virt_base); +release_mem_region (data->phys_base, data->length_bytes);return ret; }
Signature · 1 line
2.17.1