Re: [PATCH v2] staging: gasket: core: Fix a coding style issue in gasket_core.c

Dan Carpenter
2020-06-17T19:10:25Z

On Thu, Jun 18, 2020 at 12:11:27AM +0800, Zhixu Zhao wrote:
> diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c
> index 67325fbaf760..28dab302183b 100644
> --- a/drivers/staging/gasket/gasket_core.c
> +++ b/drivers/staging/gasket/gasket_core.c
> @@ -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).

> + 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