Re: [PATCH v4 3/3] input: pwm-beeper: add devicetree bindings to set volume levels

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

 




Hi Frieder,

[auto build test ERROR on robh/for-next]
[also build test ERROR on v4.10-rc8]
[cannot apply to input/next next-20170216]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Frieder-Schrempf/input-pwm-beeper-add-feature-to-set-volume-level/20170217-064600
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: x86_64-randconfig-it0-02170238 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   drivers/input/misc/pwm-beeper.c: In function 'pwm_beeper_probe':
>> drivers/input/misc/pwm-beeper.c:189:9: error: 'struct pwm_beeper' has no member named 'max_volume_level'
      beeper->max_volume_level = 1;
            ^
   drivers/input/misc/pwm-beeper.c:191:9: error: 'struct pwm_beeper' has no member named 'max_volume_level'
      beeper->max_volume_level = length;
            ^
   In file included from include/uapi/linux/stddef.h:1:0,
                    from include/linux/stddef.h:4,
                    from include/uapi/linux/posix_types.h:4,
                    from include/uapi/linux/types.h:13,
                    from include/linux/types.h:5,
                    from include/uapi/linux/sysinfo.h:4,
                    from include/uapi/linux/kernel.h:4,
                    from include/linux/cache.h:4,
                    from include/linux/time.h:4,
                    from include/linux/input.h:11,
                    from drivers/input/misc/pwm-beeper.c:20:
   drivers/input/misc/pwm-beeper.c:194:12: error: 'struct pwm_beeper' has no member named 'max_volume_level'
     if (beeper->max_volume_level > 0) {
               ^
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^
>> drivers/input/misc/pwm-beeper.c:194:2: note: in expansion of macro 'if'
     if (beeper->max_volume_level > 0) {
     ^
   drivers/input/misc/pwm-beeper.c:194:12: error: 'struct pwm_beeper' has no member named 'max_volume_level'
     if (beeper->max_volume_level > 0) {
               ^
   include/linux/compiler.h:149:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^
>> drivers/input/misc/pwm-beeper.c:194:2: note: in expansion of macro 'if'
     if (beeper->max_volume_level > 0) {
     ^
   drivers/input/misc/pwm-beeper.c:194:12: error: 'struct pwm_beeper' has no member named 'max_volume_level'
     if (beeper->max_volume_level > 0) {
               ^
   include/linux/compiler.h:160:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^
>> drivers/input/misc/pwm-beeper.c:194:2: note: in expansion of macro 'if'
     if (beeper->max_volume_level > 0) {
     ^
   drivers/input/misc/pwm-beeper.c:196:10: error: 'struct pwm_beeper' has no member named 'max_volume_level'
       beeper->max_volume_level;
             ^
   drivers/input/misc/pwm-beeper.c:206:13: error: 'struct pwm_beeper' has no member named 'max_volume_level'
          beeper->max_volume_level);
                ^
   drivers/input/misc/pwm-beeper.c:216:19: error: 'struct pwm_beeper' has no member named 'max_volume_level'
        value = beeper->max_volume_level - 1;
                      ^
   drivers/input/misc/pwm-beeper.c:224:9: error: 'struct pwm_beeper' has no member named 'max_volume_level'
      beeper->max_volume_level--;
            ^
   drivers/input/misc/pwm-beeper.c:158:9: warning: unused variable 'size' [-Wunused-variable]
     size_t size;
            ^

vim +189 drivers/input/misc/pwm-beeper.c

    14	 *  You should have received a copy of the GNU General Public License along
    15	 *  with this program; if not, write to the Free Software Foundation, Inc.,
    16	 *  675 Mass Ave, Cambridge, MA 02139, USA.
    17	 *
    18	 */
    19	
  > 20	#include <linux/input.h>
    21	#include <linux/module.h>
    22	#include <linux/kernel.h>
    23	#include <linux/of.h>
    24	#include <linux/platform_device.h>
    25	#include <linux/pwm.h>
    26	#include <linux/slab.h>
    27	#include <linux/workqueue.h>
    28	
    29	struct pwm_beeper {
    30		struct input_dev *input;
    31		struct pwm_device *pwm;
    32		struct work_struct work;
    33		unsigned long period;
    34		unsigned int volume;
    35		unsigned int *volume_levels;
    36		unsigned int max_volume;
    37	};
    38	
    39	#define HZ_TO_NANOSECONDS(x) (1000000000UL/(x))
    40	
    41	static ssize_t beeper_show_volume(struct device *dev,
    42			struct device_attribute *attr, char *buf)
    43	{
    44		struct pwm_beeper *beeper = dev_get_drvdata(dev);
    45	
    46		return sprintf(buf, "%d\n", beeper->volume);
    47	}
    48	
    49	static ssize_t beeper_show_max_volume(struct device *dev,
    50			struct device_attribute *attr, char *buf)
    51	{
    52		struct pwm_beeper *beeper = dev_get_drvdata(dev);
    53	
    54		return sprintf(buf, "%d\n", beeper->max_volume);
    55	}
    56	
    57	static ssize_t beeper_store_volume(struct device *dev,
    58			struct device_attribute *attr, const char *buf, size_t count)
    59	{
    60		int rc;
    61		struct pwm_beeper *beeper = dev_get_drvdata(dev);
    62		unsigned int volume;
    63	
    64		rc = kstrtouint(buf, 0, &volume);
    65		if (rc)
    66			return rc;
    67	
    68		if (volume > beeper->max_volume)
    69			return -EINVAL;
    70		pr_debug("set volume to %u\n", volume);
    71		beeper->volume = volume;
    72	
    73		return count;
    74	}
    75	
    76	static DEVICE_ATTR(volume, 0644, beeper_show_volume, beeper_store_volume);
    77	static DEVICE_ATTR(max_volume, 0644, beeper_show_max_volume, NULL);
    78	
    79	static struct attribute *pwm_beeper_attributes[] = {
    80		&dev_attr_volume.attr,
    81		&dev_attr_max_volume.attr,
    82		NULL,
    83	};
    84	
    85	static struct attribute_group pwm_beeper_attribute_group = {
    86		.attrs = pwm_beeper_attributes,
    87	};
    88	
    89	static void __pwm_beeper_set(struct pwm_beeper *beeper)
    90	{
    91		unsigned long period = beeper->period;
    92	
    93		if (period) {
    94			pwm_config(beeper->pwm,
    95				period / 1000 * beeper->volume_levels[beeper->volume],
    96				period);
    97			pwm_enable(beeper->pwm);
    98		} else
    99			pwm_disable(beeper->pwm);
   100	}
   101	
   102	static void pwm_beeper_work(struct work_struct *work)
   103	{
   104		struct pwm_beeper *beeper =
   105			container_of(work, struct pwm_beeper, work);
   106	
   107		__pwm_beeper_set(beeper);
   108	}
   109	
   110	static int pwm_beeper_event(struct input_dev *input,
   111				    unsigned int type, unsigned int code, int value)
   112	{
   113		struct pwm_beeper *beeper = input_get_drvdata(input);
   114	
   115		if (type != EV_SND || value < 0)
   116			return -EINVAL;
   117	
   118		switch (code) {
   119		case SND_BELL:
   120			value = value ? 1000 : 0;
   121			break;
   122		case SND_TONE:
   123			break;
   124		default:
   125			return -EINVAL;
   126		}
   127	
   128		if (value == 0)
   129			beeper->period = 0;
   130		else
   131			beeper->period = HZ_TO_NANOSECONDS(value);
   132	
   133		schedule_work(&beeper->work);
   134	
   135		return 0;
   136	}
   137	
   138	static void pwm_beeper_stop(struct pwm_beeper *beeper)
   139	{
   140		cancel_work_sync(&beeper->work);
   141	
   142		if (beeper->period)
   143			pwm_disable(beeper->pwm);
   144	}
   145	
   146	static void pwm_beeper_close(struct input_dev *input)
   147	{
   148		struct pwm_beeper *beeper = input_get_drvdata(input);
   149	
   150		pwm_beeper_stop(beeper);
   151	}
   152	
   153	static int pwm_beeper_probe(struct platform_device *pdev)
   154	{
   155		unsigned long pwm_id = (unsigned long)dev_get_platdata(&pdev->dev);
   156		struct pwm_beeper *beeper;
   157		int error, length;
   158		size_t size;
   159		u32 value;
   160	
   161		beeper = kzalloc(sizeof(*beeper), GFP_KERNEL);
   162		if (!beeper)
   163			return -ENOMEM;
   164	
   165		beeper->pwm = pwm_get(&pdev->dev, NULL);
   166		if (IS_ERR(beeper->pwm)) {
   167			dev_dbg(&pdev->dev, "unable to request PWM, trying legacy API\n");
   168			beeper->pwm = pwm_request(pwm_id, "pwm beeper");
   169		}
   170	
   171		if (IS_ERR(beeper->pwm)) {
   172			error = PTR_ERR(beeper->pwm);
   173			dev_err(&pdev->dev, "Failed to request pwm device: %d\n", error);
   174			goto err_free;
   175		}
   176	
   177		/*
   178		 * FIXME: pwm_apply_args() should be removed when switching to
   179		 * the atomic PWM API.
   180		 */
   181		pwm_apply_args(beeper->pwm);
   182	
   183		INIT_WORK(&beeper->work, pwm_beeper_work);
   184	
   185		/* determine the number of volume levels */
   186		length = device_property_read_u32_array(&pdev->dev, "volume-levels", NULL, 0);
   187		if (length <= 0) {
   188			dev_dbg(&pdev->dev, "no volume levels specified, using max volume\n");
 > 189			beeper->max_volume_level = 1;
   190		} else
   191			beeper->max_volume_level = length;
   192	
   193		/* read volume levels from DT property */
 > 194		if (beeper->max_volume_level > 0) {
   195			size_t size = sizeof(*beeper->volume_levels) *
   196				beeper->max_volume_level;
   197	

---
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]     [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