Skip to content

Commit bd0df44

Browse files
committed
gpiolib: acpi: Reuse struct acpi_gpio_params in struct acpi_gpio_lookup
Some of the contents of struct acpi_gpio_lookup repeats what we have in the struct acpi_gpio_params. Reuse the latter in the former. Acked-by: Mika Westerberg <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andy Shevchenko <[email protected]>
1 parent 8de5426 commit bd0df44

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

drivers/gpio/gpiolib-acpi.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -744,16 +744,15 @@ static int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags,
744744

745745
struct acpi_gpio_lookup {
746746
struct acpi_gpio_info info;
747-
int index;
748-
u16 pin_index;
749-
bool active_low;
747+
struct acpi_gpio_params params;
750748
struct gpio_desc *desc;
751749
int n;
752750
};
753751

754752
static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
755753
{
756754
struct acpi_gpio_lookup *lookup = data;
755+
struct acpi_gpio_params *params = &lookup->params;
757756

758757
if (ares->type != ACPI_RESOURCE_TYPE_GPIO)
759758
return 1;
@@ -765,12 +764,12 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
765764
u16 pin_index;
766765

767766
if (lookup->info.quirks & ACPI_GPIO_QUIRK_ONLY_GPIOIO && gpioint)
768-
lookup->index++;
767+
params->crs_entry_index++;
769768

770-
if (lookup->n++ != lookup->index)
769+
if (lookup->n++ != params->crs_entry_index)
771770
return 1;
772771

773-
pin_index = lookup->pin_index;
772+
pin_index = params->line_index;
774773
if (pin_index >= agpio->pin_table_length)
775774
return 1;
776775

@@ -796,7 +795,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
796795
lookup->info.polarity = agpio->polarity;
797796
lookup->info.triggering = agpio->triggering;
798797
} else {
799-
lookup->info.polarity = lookup->active_low;
798+
lookup->info.polarity = params->active_low;
800799
}
801800

802801
lookup->info.flags = acpi_gpio_to_gpiod_flags(agpio, lookup->info.polarity);
@@ -834,7 +833,8 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode, const char *p
834833
struct acpi_gpio_lookup *lookup)
835834
{
836835
struct fwnode_reference_args args;
837-
unsigned int index = lookup->index;
836+
struct acpi_gpio_params *params = &lookup->params;
837+
unsigned int index = params->crs_entry_index;
838838
unsigned int quirks = 0;
839839
int ret;
840840

@@ -857,9 +857,9 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode, const char *p
857857
if (args.nargs != 3)
858858
return -EPROTO;
859859

860-
lookup->index = args.args[0];
861-
lookup->pin_index = args.args[1];
862-
lookup->active_low = !!args.args[2];
860+
params->crs_entry_index = args.args[0];
861+
params->line_index = args.args[1];
862+
params->active_low = !!args.args[2];
863863

864864
lookup->info.adev = to_acpi_device_node(args.fwnode);
865865
lookup->info.quirks = quirks;
@@ -897,10 +897,11 @@ static struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev,
897897
struct acpi_gpio_info *info)
898898
{
899899
struct acpi_gpio_lookup lookup;
900+
struct acpi_gpio_params *params = &lookup.params;
900901
int ret;
901902

902903
memset(&lookup, 0, sizeof(lookup));
903-
lookup.index = index;
904+
params->crs_entry_index = index;
904905

905906
if (propname) {
906907
dev_dbg(&adev->dev, "GPIO: looking up %s\n", propname);
@@ -909,11 +910,11 @@ static struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev,
909910
if (ret)
910911
return ERR_PTR(ret);
911912

912-
dev_dbg(&adev->dev, "GPIO: _DSD returned %s %d %u %u\n",
913-
dev_name(&lookup.info.adev->dev), lookup.index,
914-
lookup.pin_index, lookup.active_low);
913+
dev_dbg(&adev->dev, "GPIO: _DSD returned %s %u %u %u\n",
914+
dev_name(&lookup.info.adev->dev),
915+
params->crs_entry_index, params->line_index, params->active_low);
915916
} else {
916-
dev_dbg(&adev->dev, "GPIO: looking up %d in _CRS\n", index);
917+
dev_dbg(&adev->dev, "GPIO: looking up %u in _CRS\n", params->crs_entry_index);
917918
lookup.info.adev = adev;
918919
}
919920

@@ -943,6 +944,7 @@ static struct gpio_desc *acpi_get_gpiod_from_data(struct fwnode_handle *fwnode,
943944
struct acpi_gpio_info *info)
944945
{
945946
struct acpi_gpio_lookup lookup;
947+
struct acpi_gpio_params *params = &lookup.params;
946948
int ret;
947949

948950
if (!is_acpi_data_node(fwnode))
@@ -952,7 +954,7 @@ static struct gpio_desc *acpi_get_gpiod_from_data(struct fwnode_handle *fwnode,
952954
return ERR_PTR(-EINVAL);
953955

954956
memset(&lookup, 0, sizeof(lookup));
955-
lookup.index = index;
957+
params->crs_entry_index = index;
956958

957959
ret = acpi_gpio_property_lookup(fwnode, propname, &lookup);
958960
if (ret)

0 commit comments

Comments
 (0)