[PATCH 3/5] pwm: set the actual number of pwms arguments defined in board dts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




For backward compatibility board device tree may define amount of only
mandatory pwm properties, which is compared to a pwm driver specific
value, by default it is 2 and may be overwritten by a driver.

Any additional arguments shall be considered as optional and they are
taken into account, only if #pwm-cells is increased accordingly.

As a positive side effect specific pwm-specifier array may have
variable size of #pwm-cells (but not less than amount of mandatory
arguments), which allows to omit optional arguments. The parameters
array of a specific PWM is updated according to the actual data taken
from device tree file.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@xxxxxxxxxx>
Cc: Lothar Waßmann <LW@xxxxxxxxxxxxxxxxxxx>
Cc: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
Cc: Thierry Reding <thierry.reding@xxxxxxxxx>
Cc: Shawn Guo <shawn.guo@xxxxxxxxxx>
---
 drivers/pwm/core.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index f6231c6..4d9fc7f 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -543,12 +543,13 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
 		goto put;
 	}
 
-	if (args.args_count != pc->of_pwm_n_cells) {
+	if (args.args_count < pc->of_pwm_n_cells) {
 		pr_err("%s: wrong #pwm-cells for %s\n", np->full_name,
 			 args.np->full_name);
 		pwm = ERR_PTR(-EINVAL);
 		goto put;
 	}
+	pc->of_pwm_n_cells = args.args_count;
 
 	pwm = pc->of_xlate(pc, &args);
 	if (IS_ERR(pwm))
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux