Re: [PATCH] Add Silicom Platform Driver

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

 



Le 18/07/2023 à 18:01, Henry Shi a écrit :
The Silicom platform (silicom-platform) Linux driver for Swisscom
Business Box (Swisscom BB) as well as Cordoba family products is a
software solution designed to facilitate the efficient management
and control of devices through the integration of various Linux
frameworks. This platform driver provides seamless support for
device management via the Linux LED framework, GPIO framework,
Hardware Monitoring (HWMON), and device attributes. The Silicom
platform driver's compatibility with these Linux frameworks allows
applications to access and control Cordoba family devices using
existing software that is compatible with these frameworks. This
compatibility simplifies the development process, reduces
dependencies on proprietary solutions, and promotes
interoperability with other Linux-based systems and software.

Signed-off-by: Henry Shi <henryshi2018@xxxxxxxxx>
---

[...]

+static int __init silicom_mc_leds_register(struct device *dev,
+					   const struct led_classdev_mc *mc_leds)
+{
+	struct led_classdev_mc *led;
+	int i, err;
+
+	for (i = 0; mc_leds[i].led_cdev.name; i++) {
+		/* allocate and copy data from the init constansts */
+		led = devm_kzalloc(dev, sizeof(struct led_classdev_mc), GFP_KERNEL);

sizeof(*led) is shorter.
Mostly a matter of taste.

Maybe even devm_kmemdup()?

+		if (IS_ERR_OR_NULL(led)) {

if (!led)
is enough.

+			dev_err(dev, "Failed to alloc led_classdev_mc[%d]: %ld\n", i, PTR_ERR(led));

This kind of message is useless and should be removed (checkpatch should warn about it)

+			return -ENOMEM;
+		}
+		memcpy(led, &mc_leds[i], sizeof(*led));
+
+		led->subled_info = devm_kzalloc(dev, led->num_colors * sizeof(struct mc_subled),
+						GFP_KERNEL);

Maybe even devm_kmemdup()?

+		if (IS_ERR_OR_NULL(led->subled_info)) {

if (!led->subled_info)
is enough.

+			dev_err(dev, "Failed to alloc subled_info[%d]: %ld\n",
+				i, PTR_ERR(led->subled_info));

This kind of message is useless and should be removed (checkpatch should warn about it)

+			return -ENOMEM;
+		}
+		memcpy(led->subled_info, mc_leds[i].subled_info,
+			led->num_colors * sizeof(struct mc_subled));
+
+		err = devm_led_classdev_multicolor_register(dev, led);
+		if (err) {
+			dev_err(dev, "Failed to register[%d]: %d\n", i, err);
+			return err;
+		}
+	}
+
+	return 0;
+}

[...]




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux