Skip to content

Commit fa99e70

Browse files
Sai Krishna Potthurilinusw
authored andcommitted
pinctrl: zynqmp: some code cleanups
Some minor code cleanups and updates which includes - Mention module name under help in Kconfig. - Remove extra lines and duplicate Pin range checks. - Replace 'return ret' with 'return 0' in success path. - Copyright year update. - use devm_pinctrl_register() instead pinctrl_register() in probe. Signed-off-by: Sai Krishna Potthuri <[email protected]> Link: https://lore.kernel.org/r/1624273214-66849-1-git-send-email-lakshmi.sai.krishna.potthuri@xilinx.com Signed-off-by: Linus Walleij <[email protected]>
1 parent 0c3ae64 commit fa99e70

File tree

2 files changed

+22
-30
lines changed

2 files changed

+22
-30
lines changed

drivers/pinctrl/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ config PINCTRL_ZYNQMP
336336
Configuration can include the mux function to select on those
337337
pin(s)/group(s), and various pin configuration parameters
338338
such as pull-up, slew rate, etc.
339+
This driver can also be built as a module. If so, the module
340+
will be called pinctrl-zynqmp.
339341

340342
config PINCTRL_INGENIC
341343
bool "Pinctrl driver for the Ingenic JZ47xx SoCs"

drivers/pinctrl/pinctrl-zynqmp.c

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* ZynqMP pin controller
44
*
5-
* Copyright (C) 2020 Xilinx, Inc.
5+
* Copyright (C) 2020, 2021 Xilinx, Inc.
66
*
77
* Sai Krishna Potthuri <[email protected]>
88
* Rajan Vaja <[email protected]>
@@ -252,9 +252,6 @@ static int zynqmp_pinconf_cfg_get(struct pinctrl_dev *pctldev,
252252
unsigned int arg, param = pinconf_to_config_param(*config);
253253
int ret;
254254

255-
if (pin >= zynqmp_desc.npins)
256-
return -EOPNOTSUPP;
257-
258255
switch (param) {
259256
case PIN_CONFIG_SLEW_RATE:
260257
param = PM_PINCTRL_CONFIG_SLEW_RATE;
@@ -317,7 +314,7 @@ static int zynqmp_pinconf_cfg_get(struct pinctrl_dev *pctldev,
317314
}
318315
break;
319316
default:
320-
ret = -EOPNOTSUPP;
317+
ret = -ENOTSUPP;
321318
break;
322319
}
323320

@@ -348,9 +345,6 @@ static int zynqmp_pinconf_cfg_set(struct pinctrl_dev *pctldev,
348345
{
349346
int i, ret;
350347

351-
if (pin >= zynqmp_desc.npins)
352-
return -EOPNOTSUPP;
353-
354348
for (i = 0; i < num_configs; i++) {
355349
unsigned int param = pinconf_to_config_param(configs[i]);
356350
unsigned int arg = pinconf_to_config_argument(configs[i]);
@@ -428,7 +422,7 @@ static int zynqmp_pinconf_cfg_set(struct pinctrl_dev *pctldev,
428422
dev_warn(pctldev->dev,
429423
"unsupported configuration parameter '%u'\n",
430424
param);
431-
ret = -EOPNOTSUPP;
425+
ret = -ENOTSUPP;
432426
break;
433427
}
434428

@@ -504,7 +498,7 @@ static int zynqmp_pinctrl_get_function_groups(u32 fid, u32 index, u16 *groups)
504498

505499
memcpy(groups, &payload[1], PINCTRL_GET_FUNC_GROUPS_RESP_LEN);
506500

507-
return ret;
501+
return 0;
508502
}
509503

510504
static int zynqmp_pinctrl_get_func_num_groups(u32 fid, unsigned int *ngroups)
@@ -522,7 +516,7 @@ static int zynqmp_pinctrl_get_func_num_groups(u32 fid, unsigned int *ngroups)
522516

523517
*ngroups = payload[1];
524518

525-
return ret;
519+
return 0;
526520
}
527521

528522
/**
@@ -533,16 +527,16 @@ static int zynqmp_pinctrl_get_func_num_groups(u32 fid, unsigned int *ngroups)
533527
* @groups: Groups data.
534528
*
535529
* Query firmware to get group IDs for each function. Firmware returns
536-
* group IDs. Based on group index for the function, group names in
530+
* group IDs. Based on the group index for the function, group names in
537531
* the function are stored. For example, the first group in "eth0" function
538-
* is named as "eth0_0" and second group as "eth0_1" and so on.
532+
* is named as "eth0_0" and the second group as "eth0_1" and so on.
539533
*
540534
* Based on the group ID received from the firmware, function stores name of
541535
* the group for that group ID. For example, if "eth0" first group ID
542536
* is x, groups[x] name will be stored as "eth0_0".
543537
*
544538
* Once done for each function, each function would have its group names
545-
* and each groups would also have their names.
539+
* and each group would also have their names.
546540
*
547541
* Return: 0 on success else error code.
548542
*/
@@ -552,7 +546,7 @@ static int zynqmp_pinctrl_prepare_func_groups(struct device *dev, u32 fid,
552546
{
553547
u16 resp[NUM_GROUPS_PER_RESP] = {0};
554548
const char **fgroups;
555-
int ret = 0, index, i;
549+
int ret, index, i;
556550

557551
fgroups = devm_kzalloc(dev, sizeof(*fgroups) * func->ngroups, GFP_KERNEL);
558552
if (!fgroups)
@@ -588,7 +582,7 @@ static int zynqmp_pinctrl_prepare_func_groups(struct device *dev, u32 fid,
588582
done:
589583
func->groups = fgroups;
590584

591-
return ret;
585+
return 0;
592586
}
593587

594588
static void zynqmp_pinctrl_get_function_name(u32 fid, char *name)
@@ -622,7 +616,7 @@ static int zynqmp_pinctrl_get_num_functions(unsigned int *nfuncs)
622616

623617
*nfuncs = payload[1];
624618

625-
return ret;
619+
return 0;
626620
}
627621

628622
static int zynqmp_pinctrl_get_pin_groups(u32 pin, u32 index, u16 *groups)
@@ -641,7 +635,7 @@ static int zynqmp_pinctrl_get_pin_groups(u32 pin, u32 index, u16 *groups)
641635

642636
memcpy(groups, &payload[1], PINCTRL_GET_PIN_GROUPS_RESP_LEN);
643637

644-
return ret;
638+
return 0;
645639
}
646640

647641
static void zynqmp_pinctrl_group_add_pin(struct zynqmp_pctrl_group *group,
@@ -660,7 +654,7 @@ static void zynqmp_pinctrl_group_add_pin(struct zynqmp_pctrl_group *group,
660654
* Based on the firmware response(group IDs for the pin), add
661655
* pin number to the respective group's pin array.
662656
*
663-
* Once all pins are queries, each groups would have its number
657+
* Once all pins are queries, each group would have its number
664658
* of pins and pin numbers data.
665659
*
666660
* Return: 0 on success else error code.
@@ -689,7 +683,7 @@ static int zynqmp_pinctrl_create_pin_groups(struct device *dev,
689683
index += NUM_GROUPS_PER_RESP;
690684
} while (index <= MAX_PIN_GROUPS);
691685

692-
return ret;
686+
return 0;
693687
}
694688

695689
/**
@@ -727,7 +721,7 @@ static int zynqmp_pinctrl_prepare_group_pins(struct device *dev,
727721
* prepare pin control driver data.
728722
*
729723
* Query number of functions and number of function groups (number
730-
* of groups in given function) to allocate required memory buffers
724+
* of groups in the given function) to allocate required memory buffers
731725
* for functions and groups. Once buffers are allocated to store
732726
* functions and groups data, query and store required information
733727
* (number of groups and group names for each function, number of
@@ -778,7 +772,7 @@ static int zynqmp_pinctrl_prepare_function_info(struct device *dev,
778772
pctrl->funcs = funcs;
779773
pctrl->groups = groups;
780774

781-
return ret;
775+
return 0;
782776
}
783777

784778
static int zynqmp_pinctrl_get_num_pins(unsigned int *npins)
@@ -795,7 +789,7 @@ static int zynqmp_pinctrl_get_num_pins(unsigned int *npins)
795789

796790
*npins = payload[1];
797791

798-
return ret;
792+
return 0;
799793
}
800794

801795
/**
@@ -853,19 +847,17 @@ static int zynqmp_pinctrl_probe(struct platform_device *pdev)
853847
&zynqmp_desc.pins,
854848
&zynqmp_desc.npins);
855849
if (ret) {
856-
dev_err(&pdev->dev, "pin desc prepare fail with %d\n",
857-
ret);
850+
dev_err(&pdev->dev, "pin desc prepare fail with %d\n", ret);
858851
return ret;
859852
}
860853

861854
ret = zynqmp_pinctrl_prepare_function_info(&pdev->dev, pctrl);
862855
if (ret) {
863-
dev_err(&pdev->dev, "function info prepare fail with %d\n",
864-
ret);
856+
dev_err(&pdev->dev, "function info prepare fail with %d\n", ret);
865857
return ret;
866858
}
867859

868-
pctrl->pctrl = pinctrl_register(&zynqmp_desc, &pdev->dev, pctrl);
860+
pctrl->pctrl = devm_pinctrl_register(&pdev->dev, &zynqmp_desc, pctrl);
869861
if (IS_ERR(pctrl->pctrl))
870862
return PTR_ERR(pctrl->pctrl);
871863

@@ -887,7 +879,6 @@ static const struct of_device_id zynqmp_pinctrl_of_match[] = {
887879
{ .compatible = "xlnx,zynqmp-pinctrl" },
888880
{ }
889881
};
890-
891882
MODULE_DEVICE_TABLE(of, zynqmp_pinctrl_of_match);
892883

893884
static struct platform_driver zynqmp_pinctrl_driver = {
@@ -898,7 +889,6 @@ static struct platform_driver zynqmp_pinctrl_driver = {
898889
.probe = zynqmp_pinctrl_probe,
899890
.remove = zynqmp_pinctrl_remove,
900891
};
901-
902892
module_platform_driver(zynqmp_pinctrl_driver);
903893

904894
MODULE_AUTHOR("Sai Krishna Potthuri <[email protected]>");

0 commit comments

Comments
 (0)