On Sat, Sep 17, 2022 at 11:14 AM Jean-Jacques HiblotCould be done but I have no good name for the variable and I think it would just make things harder to understand. In that form I think it is clear that this is a cross-multiplication.
<jjhiblot@xxxxxxxxxxxxxxx> wrote:
By allowing to group multiple monochrome LED into multicolor LEDs,...
all involved LEDs can be controlled in-sync. This enables using effects
using triggers, etc.
+config LEDS_GRP_MULTICOLORWhat will be the module name in case of "m" choice?
+ tristate "Multi-color LED grouping support"
+ help
+ This option enables support for monochrome LEDs that are
+ grouped into multicolor LEDs.
...
+ struct led_mcg_priv *priv =One line?
+ container_of(mc_cdev, struct led_mcg_priv, mc_cdev);
...
+ /*Usually we put a grammar period at the end of sentences in multi-line comments.
+ * Scale the intensity according the max brightness of the
+ * monochromatic LED
+ */...
+ actual_led_brightness = DIV_ROUND_CLOSEST(Can you fix an indentation, so it won't leave the line ending by open
+ mono->max_brightness * mc_cdev->subled_info[i].brightness,
+ mc_cdev->led_cdev.max_brightness);
parenthesis? I believe with the help of a temporary variable it can be
easily achieved.
...
+ for (;;) {Why _of_ variant? Please, make this OF independent since it's
+ struct led_classdev *led_cdev;
+ led_cdev = devm_of_led_get(dev, count);
pretending to cover not only OF-based systems.
+ if (IS_ERR(led_cdev)) {Looks like the above needs an _optional() variant
+ /* Reached the end of the list ? */
+ if (PTR_ERR(led_cdev) == -ENOENT)
+ break;
+ return dev_err_probe(dev, PTR_ERR(led_cdev),...
+ "Unable to get led #%d", count);
+ }
+ priv->monochromatics = devm_krealloc(dev, priv->monochromatics,This needs at minimum to use one of the helpers from overflow.h,
+ count * sizeof(*priv->monochromatics),
+ GFP_KERNEL);
ideally you may implement devm_krealloc_array() as a suitable wrapper
for that.
+ if (!priv->monochromatics)...
+ return -ENOMEM;
+ subled = devm_kzalloc(dev, count * sizeof(*subled), GFP_KERNEL);NIH devm_kcalloc()
+ if (!subled)--
+ return -ENOMEM;
With Best Regards,
Andy Shevchenko