Re: [PATCH v12 04/16] leds: multicolor: Introduce a multicolor class definition

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

 



Hi Dan,

I love your patch! Yet something to improve:

[auto build test ERROR on j.anaszewski-leds/for-next]
[cannot apply to v5.4-rc3 next-20191011]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dan-Murphy/Multicolor-Framework-v12/20191014-103058
base:   https://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.git for-next
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=sparc64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

>> drivers//leds/led-class-multicolor.c:17:5: error: redefinition of 'led_mc_calc_color_components'
    int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers//leds/led-class-multicolor.c:7:0:
   include/linux/led-class-multicolor.h:119:19: note: previous definition of 'led_mc_calc_color_components' was here
    static inline int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev,
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers//leds/led-class-multicolor.c:182:5: error: redefinition of 'led_classdev_multicolor_register_ext'
    int led_classdev_multicolor_register_ext(struct device *parent,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers//leds/led-class-multicolor.c:7:0:
   include/linux/led-class-multicolor.h:104:19: note: previous definition of 'led_classdev_multicolor_register_ext' was here
    static inline int led_classdev_multicolor_register_ext(struct device *parent,
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers//leds/led-class-multicolor.c:204:6: error: redefinition of 'led_classdev_multicolor_unregister'
    void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev)
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers//leds/led-class-multicolor.c:7:0:
   include/linux/led-class-multicolor.h:117:20: note: previous definition of 'led_classdev_multicolor_unregister' was here
    static inline void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev) {}
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers//leds/led-class-multicolor.c:224:5: error: redefinition of 'devm_led_classdev_multicolor_register_ext'
    int devm_led_classdev_multicolor_register_ext(struct device *parent,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers//leds/led-class-multicolor.c:7:0:
   include/linux/led-class-multicolor.h:126:19: note: previous definition of 'devm_led_classdev_multicolor_register_ext' was here
    static inline int devm_led_classdev_multicolor_register_ext(struct device *parent,
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers//leds/led-class-multicolor.c:260:6: error: redefinition of 'devm_led_classdev_multicolor_unregister'
    void devm_led_classdev_multicolor_unregister(struct device *dev,
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers//leds/led-class-multicolor.c:7:0:
   include/linux/led-class-multicolor.h:139:20: note: previous definition of 'devm_led_classdev_multicolor_unregister' was here
    static inline void devm_led_classdev_multicolor_unregister(struct device *parent,
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/led_mc_calc_color_components +17 drivers//leds/led-class-multicolor.c

    16	
  > 17	int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev,
    18					 enum led_brightness brightness,
    19				       struct led_mc_color_conversion color_component[])
    20	{
    21		struct led_mc_color_entry *priv;
    22		int i = 0;
    23	
    24		list_for_each_entry(priv, &mcled_cdev->color_list, list) {
    25			color_component[i].color_id = priv->led_color_id;
    26			color_component[i].brightness = brightness *
    27						  priv->intensity / priv->max_intensity;
    28			i++;
    29		}
    30	
    31		return 0;
    32	}
    33	EXPORT_SYMBOL_GPL(led_mc_calc_color_components);
    34	
    35	static ssize_t intensity_store(struct device *dev,
    36					struct device_attribute *intensity_attr,
    37					const char *buf, size_t size)
    38	{
    39		struct led_mc_color_entry *priv = container_of(intensity_attr,
    40							    struct led_mc_color_entry,
    41							      intensity_attr);
    42		struct led_classdev *led_cdev = priv->mcled_cdev->led_cdev;
    43		unsigned long value;
    44		ssize_t ret;
    45	
    46		mutex_lock(&led_cdev->led_access);
    47	
    48		ret = kstrtoul(buf, 10, &value);
    49		if (ret)
    50			goto unlock;
    51	
    52		if (value > priv->max_intensity) {
    53			ret = -EINVAL;
    54			goto unlock;
    55		}
    56	
    57		priv->intensity = value;
    58		ret = size;
    59	
    60	unlock:
    61		mutex_unlock(&led_cdev->led_access);
    62		return ret;
    63	}
    64	
    65	static ssize_t intensity_show(struct device *dev,
    66				      struct device_attribute *intensity_attr,
    67				      char *buf)
    68	{
    69		struct led_mc_color_entry *priv = container_of(intensity_attr,
    70							    struct led_mc_color_entry,
    71							      intensity_attr);
    72	
    73		return sprintf(buf, "%d\n", priv->intensity);
    74	}
    75	
    76	static ssize_t max_intensity_show(struct device *dev,
    77					   struct device_attribute *max_intensity_attr,
    78					   char *buf)
    79	{
    80		struct led_mc_color_entry *priv = container_of(max_intensity_attr,
    81							    struct led_mc_color_entry,
    82							      max_intensity_attr);
    83	
    84		return sprintf(buf, "%d\n", priv->max_intensity);
    85	}
    86	
    87	static struct attribute *led_color_attrs[] = {
    88		NULL,
    89	};
    90	
    91	static struct attribute_group led_color_group = {
    92		.name = "colors",
    93		.attrs = led_color_attrs,
    94	};
    95	
    96	static int led_multicolor_init_color(struct led_classdev_mc *mcled_cdev,
    97					     int color_id)
    98	{
    99		struct led_classdev *led_cdev = mcled_cdev->led_cdev;
   100		struct led_mc_color_entry *mc_priv;
   101		char *intensity_file_name;
   102		char *max_intensity_file_name;
   103		size_t len;
   104		int ret;
   105	
   106		mc_priv = devm_kzalloc(led_cdev->dev, sizeof(*mc_priv), GFP_KERNEL);
   107		if (!mc_priv)
   108			return -ENOMEM;
   109	
   110		mc_priv->led_color_id = color_id;
   111		mc_priv->mcled_cdev = mcled_cdev;
   112	
   113		sysfs_attr_init(&mc_priv->intensity_attr.attr);
   114		len = strlen(led_colors[color_id]) + strlen(INTENSITY_NAME) + 1;
   115		intensity_file_name = kzalloc(len, GFP_KERNEL);
   116		if (!intensity_file_name)
   117			return -ENOMEM;
   118	
   119		snprintf(intensity_file_name, len, "%s%s",
   120			 led_colors[color_id], INTENSITY_NAME);
   121		mc_priv->intensity_attr.attr.name = intensity_file_name;
   122		mc_priv->intensity_attr.attr.mode = 0644;
   123		mc_priv->intensity_attr.store = intensity_store;
   124		mc_priv->intensity_attr.show = intensity_show;
   125		ret = sysfs_add_file_to_group(&led_cdev->dev->kobj,
   126					      &mc_priv->intensity_attr.attr,
   127					      led_color_group.name);
   128		if (ret)
   129			goto intensity_err_out;
   130	
   131		sysfs_attr_init(&mc_priv->max_intensity_attr.attr);
   132		len = strlen(led_colors[color_id]) + strlen(MAX_INTENSITY_NAME) + 1;
   133		max_intensity_file_name = kzalloc(len, GFP_KERNEL);
   134		if (!max_intensity_file_name) {
   135			ret = -ENOMEM;
   136			goto intensity_err_out;
   137		}
   138	
   139		snprintf(max_intensity_file_name, len, "%s%s",
   140			 led_colors[color_id], MAX_INTENSITY_NAME);
   141		mc_priv->max_intensity_attr.attr.name = max_intensity_file_name;
   142		mc_priv->max_intensity_attr.attr.mode = 0444;
   143		mc_priv->max_intensity_attr.show = max_intensity_show;
   144		ret = sysfs_add_file_to_group(&led_cdev->dev->kobj,
   145					      &mc_priv->max_intensity_attr.attr,
   146					      led_color_group.name);
   147		if (ret)
   148			goto max_intensity_err_out;
   149	
   150		mc_priv->max_intensity = LED_FULL;
   151		list_add_tail(&mc_priv->list, &mcled_cdev->color_list);
   152	
   153	max_intensity_err_out:
   154		kfree(max_intensity_file_name);
   155	intensity_err_out:
   156		kfree(intensity_file_name);
   157		return ret;
   158	}
   159	
   160	static int led_multicolor_init_color_dir(struct led_classdev_mc *mcled_cdev)
   161	{
   162		struct led_classdev *led_cdev = mcled_cdev->led_cdev;
   163		int ret;
   164		int i;
   165	
   166		ret = sysfs_create_group(&led_cdev->dev->kobj, &led_color_group);
   167		if (ret)
   168			return ret;
   169	
   170		for (i = 0; i < LED_COLOR_ID_MAX; i++) {
   171			if (test_bit(i, &mcled_cdev->available_colors)) {
   172				ret = led_multicolor_init_color(mcled_cdev, i);
   173				if (ret)
   174					break;
   175	
   176			}
   177		}
   178	
   179		return ret;
   180	}
   181	
 > 182	int led_classdev_multicolor_register_ext(struct device *parent,
   183					     struct led_classdev_mc *mcled_cdev,
   184					     struct led_init_data *init_data)
   185	{
   186		struct led_classdev *led_cdev;
   187		int ret;
   188	
   189		if (!mcled_cdev)
   190			return -EINVAL;
   191	
   192		led_cdev = mcled_cdev->led_cdev;
   193		INIT_LIST_HEAD(&mcled_cdev->color_list);
   194	
   195		/* Register led class device */
   196		ret = led_classdev_register_ext(parent, led_cdev, init_data);
   197		if (ret)
   198			return ret;
   199	
   200		return led_multicolor_init_color_dir(mcled_cdev);
   201	}
   202	EXPORT_SYMBOL_GPL(led_classdev_multicolor_register_ext);
   203	
 > 204	void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev)
   205	{
   206		struct led_mc_color_entry *priv, *next;
   207	
   208		if (!mcled_cdev)
   209			return;
   210	
   211		list_for_each_entry_safe(priv, next, &mcled_cdev->color_list, list)
   212			list_del(&priv->list);
   213	
   214		sysfs_remove_group(&mcled_cdev->led_cdev->dev->kobj, &led_color_group);
   215		led_classdev_unregister(mcled_cdev->led_cdev);
   216	}
   217	EXPORT_SYMBOL_GPL(led_classdev_multicolor_unregister);
   218	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux