linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] Add vibrator driver support for Mediatek SoCs
@ 2020-06-15 11:42 Fengping Yu
       [not found] ` <20200615114203.116656-2-fengping.yu@mediatek.com>
       [not found] ` <20200615114203.116656-3-fengping.yu@mediatek.com>
  0 siblings, 2 replies; 5+ messages in thread
From: Fengping Yu @ 2020-06-15 11:42 UTC (permalink / raw)
  To: Dmitry Torokhov, Matthias Brugger, Catalin Marinas, Yingjoe Chen,
	Pavel Machek, Jacek Anaszewski
  Cc: linux-input, linux-arm-kernel, linux-mediatek


This serials adds regulator vibrator driver for Mediatek SoCs.

fengping.yu (3):
  dt-bindings:Add vibrator devicetree documentation
  drivers: input: misc: Add mtk vibrator driver
  defconfig: Add CONFIG_INPUT_REGULATOR_VIBRATOR=m

 .../bindings/input/regulator-vibrator.yaml    |  65 +++
 arch/arm64/configs/defconfig                  |   1 +
 drivers/input/misc/Kconfig                    |  10 +
 drivers/input/misc/Makefile                   |   1 +
 drivers/input/misc/regulator-vibrator.c       | 422 ++++++++++++++++++
 5 files changed, 499 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/regulator-vibrator.yaml
 create mode 100644 drivers/input/misc/regulator-vibrator.c

-- 
2.18.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver
       [not found] ` <20200615114203.116656-3-fengping.yu@mediatek.com>
@ 2020-06-15 15:07   ` kernel test robot
  2020-06-16 11:02   ` Pavel Machek
  2020-06-16 11:03   ` Pavel Machek
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2020-06-15 15:07 UTC (permalink / raw)
  To: Fengping Yu, Dmitry Torokhov, Matthias Brugger, Catalin Marinas,
	Yingjoe Chen, Pavel Machek, Jacek Anaszewski
  Cc: kbuild-all, fengping.yu, linux-mediatek, linux-arm-kernel, linux-input

[-- Attachment #1: Type: text/plain, Size: 4577 bytes --]

Hi Fengping,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on pavel-linux-leds/for-next v5.8-rc1 next-20200615]
[cannot apply to input/next]
[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/Fengping-Yu/dt-bindings-Add-vibrator-devicetree-documentation/20200615-204209
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        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
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

In file included from include/linux/device.h:15,
from drivers/input/misc/regulator-vibrator.c:7:
drivers/input/misc/regulator-vibrator.c: In function 'mt_vibra_parse_dt':
>> drivers/input/misc/regulator-vibrator.c:70:16: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long int' [-Wformat=]
70 |   dev_err(dev, "error load dts: get regulator return %dn",
|                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:19:22: note: in definition of macro 'dev_fmt'
19 | #define dev_fmt(fmt) fmt
|                      ^~~
>> drivers/input/misc/regulator-vibrator.c:70:3: note: in expansion of macro 'dev_err'
70 |   dev_err(dev, "error load dts: get regulator return %dn",
|   ^~~~~~~
drivers/input/misc/regulator-vibrator.c:70:55: note: format string is defined here
70 |   dev_err(dev, "error load dts: get regulator return %dn",
|                                                      ~^
|                                                       |
|                                                       int
|                                                      %ld
drivers/input/misc/regulator-vibrator.c: In function 'vib_probe':
drivers/input/misc/regulator-vibrator.c:334:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
334 |  if (ret) {
|     ^

vim +70 drivers/input/misc/regulator-vibrator.c

    46	
    47	static int mt_vibra_parse_dt(struct device *dev,
    48			struct reg_vibr_config *vibr_conf)
    49	{
    50		int ret;
    51	
    52		if (device_property_read_u32(dev, "min-limit",
    53					     &vibr_conf->min_limit))
    54			vibr_conf->min_limit = DEFAULT_MIN_LIMIT;
    55		vibr_conf->min_limit = max_t(unsigned int,
    56			vibr_conf->min_limit, DEFAULT_MIN_LIMIT);
    57	
    58		if (device_property_read_u32(dev, "max-limit",
    59					     &vibr_conf->max_limit))
    60			vibr_conf->max_limit = 0;
    61	
    62		if (!vibr_conf->max_limit &&
    63			vibr_conf->max_limit < vibr_conf->min_limit) {
    64			dev_err(dev, "error load dts: get error limitation(min > max)\n");
    65			return -EINVAL;
    66		}
    67	
    68		vibr_conf->reg = devm_regulator_get(dev, "vib");
    69		if (IS_ERR(vibr_conf->reg)) {
  > 70			dev_err(dev, "error load dts: get regulator return %d\n",
    71				PTR_ERR(vibr_conf->reg));
    72			vibr_conf->reg = NULL;
    73			return PTR_ERR(vibr_conf->reg);
    74		}
    75	
    76		if (device_property_read_u32(dev, "max-volt",
    77					     &vibr_conf->max_volt)) {
    78			dev_err(dev, "error load dts: get max-volt failed\n");
    79			return -EINVAL;
    80		}
    81	
    82		if (device_property_read_u32(dev, "min-volt",
    83					     &vibr_conf->min_volt)) {
    84			dev_err(dev, "error load dts: get min-volt failed!\n");
    85			return -EINVAL;
    86		}
    87	
    88		if (vibr_conf->min_volt > vibr_conf->max_volt) {
    89			dev_err(dev, "error load dts: get error voltage(min > max)\n");
    90			return -EINVAL;
    91		}
    92	
    93		dev_info(dev, "vibr_conf = %u, %u, %u-%u\n",
    94			 vibr_conf->min_limit, vibr_conf->max_limit,
    95			 vibr_conf->min_volt, vibr_conf->max_volt);
    96	
    97		return ret;
    98	}
    99	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 54017 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/3] dt-bindings:Add vibrator devicetree documentation
       [not found] ` <20200615114203.116656-2-fengping.yu@mediatek.com>
@ 2020-06-16 10:58   ` Pavel Machek
  0 siblings, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2020-06-16 10:58 UTC (permalink / raw)
  To: Fengping Yu
  Cc: Dmitry Torokhov, Matthias Brugger, Catalin Marinas, Yingjoe Chen,
	Jacek Anaszewski, linux-input, linux-arm-kernel, linux-mediatek

On Mon 2020-06-15 19:42:02, Fengping Yu wrote:
> From: "fengping.yu" <fengping.yu@mediatek.com>
> 
> Add Mediatek regulator vibrator dt-bindings doc as yaml schema
> 
> Signed-off-by: fengping.yu <fengping.yu@mediatek.com>
> ---
>  .../bindings/input/regulator-vibrator.yaml    | 65 +++++++++++++++++++
>  1 file changed, 65 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/regulator-vibrator.yaml
> 
> diff --git a/Documentation/devicetree/bindings/input/regulator-vibrator.yaml b/Documentation/devicetree/bindings/input/regulator-vibrator.yaml
> new file mode 100644
> index 000000000000..6511a8a80aff
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/regulator-vibrator.yaml
> @@ -0,0 +1,65 @@
> +# SPDX-License-Identifier: GPL-2.0
> +%YAML 1.2
> +---
> +version: 1
> +
> +$id: http://devicetree.org/schemas/input/regulator-vibrator.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Mediatek's regulator vibrator device tree bindings
> +
> +maintainer:
> +  - Fengping Yu <fengping.yu@mediatek.com>
> +
> +description: |
> +  Registers a regulator device as vibrator, where the on/off capability is controlled by a regulator.

Line length?

> +properties:
> +  compatible:
> +      const: "regulator-vibrator"
> +
> +	vibr-supply:
> +		description: Power supply to the vibrator.
> +		refs:Documentation/devicetree/bindings/regulator/regulator.txt for details.
> +
> +  max-volt:
> +    description: The maximum voltage value supplied to the vibrator regulator.
> +    						 The unit of the voltage is micro.
> +

should be -microvolt?

> +  min-volt:
> +    description: The minimum voltage value supplied to the vibrator regulator.
> +    						 The unit of the voltage is micro.
> +
> +  min-limit:
> +    description: The minimum duration time in ms for vibrator, default is 15ms.
> +    						 If user request smaller duration, the default value will be used
> +    						 instead. The default value comes from the smallest unit that can
> +    						 be sensored.

English?

Add -usec or something?

											Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver
       [not found] ` <20200615114203.116656-3-fengping.yu@mediatek.com>
  2020-06-15 15:07   ` [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver kernel test robot
@ 2020-06-16 11:02   ` Pavel Machek
  2020-06-16 11:03   ` Pavel Machek
  2 siblings, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2020-06-16 11:02 UTC (permalink / raw)
  To: Fengping Yu
  Cc: Dmitry Torokhov, Matthias Brugger, Catalin Marinas, Yingjoe Chen,
	Jacek Anaszewski, linux-input, linux-arm-kernel, linux-mediatek

Hi!

> +static int mt_vibra_parse_dt(struct device *dev,
> +		struct reg_vibr_config *vibr_conf)
> +{
> +	int ret;
> +
> +	if (device_property_read_u32(dev, "min-limit",
> +				     &vibr_conf->min_limit))
> +		vibr_conf->min_limit = DEFAULT_MIN_LIMIT;
> +	vibr_conf->min_limit = max_t(unsigned int,
> +		vibr_conf->min_limit, DEFAULT_MIN_LIMIT);
> +
> +	if (device_property_read_u32(dev, "max-limit",
> +				     &vibr_conf->max_limit))
> +		vibr_conf->max_limit = 0;

Is max_limit useful? Do you enforce it in useful way?

> +	if (!vibr_conf->max_limit &&
> +		vibr_conf->max_limit < vibr_conf->min_limit) {
> +		dev_err(dev, "error load dts: get error limitation(min > max)\n");
> +		return -EINVAL;
> +	}

Condition looks wrong.

> +static struct attribute *sysfs_attrs[] = { + &dev_attr_activate.attr, + 
> &dev_attr_state.attr, + &dev_attr_duration.attr, + NULL, +}; + +static struct 
> attribute_group vibr_group = { + .attrs = sysfs_attrs, +}; + +static int 
> regulator_oc_event(struct notifier_block *nb, + unsigned long event, void *data) +{ + 

Do you need custom attributes? Why? Where is their documentation?
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver
       [not found] ` <20200615114203.116656-3-fengping.yu@mediatek.com>
  2020-06-15 15:07   ` [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver kernel test robot
  2020-06-16 11:02   ` Pavel Machek
@ 2020-06-16 11:03   ` Pavel Machek
  2 siblings, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2020-06-16 11:03 UTC (permalink / raw)
  To: Fengping Yu
  Cc: Dmitry Torokhov, Matthias Brugger, Catalin Marinas, Yingjoe Chen,
	Jacek Anaszewski, linux-input, linux-arm-kernel, linux-mediatek

On Mon 2020-06-15 19:42:04, Fengping Yu wrote:
> From: "fengping.yu" <fengping.yu@mediatek.com>
> 
> This adds regulator vibrator driver for Mediatek SoCs.
> 
> Signed-off-by: fengping.yu <fengping.yu@mediatek.com>
> ---
>  drivers/input/misc/Kconfig              |  10 +
>  drivers/input/misc/Makefile             |   1 +
>  drivers/input/misc/regulator-vibrator.c | 422 ++++++++++++++++++++++++
>  3 files changed, 433 insertions(+)
>  create mode 100644 drivers/input/misc/regulator-vibrator.c
> 
> diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> index 7e2e658d551c..71a0dd7a5271 100644
> --- a/drivers/input/misc/Kconfig
> +++ b/drivers/input/misc/Kconfig
> @@ -459,6 +459,16 @@ config INPUT_REGULATOR_HAPTIC
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called regulator-haptic.
>  
> +config INPUT_REGULATOR_VIBRATOR

Can you look at input_regulator_haptic, and explain why you need separate driver?

										Pavel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-16 11:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15 11:42 [PATCH v1] Add vibrator driver support for Mediatek SoCs Fengping Yu
     [not found] ` <20200615114203.116656-2-fengping.yu@mediatek.com>
2020-06-16 10:58   ` [PATCH v1 1/3] dt-bindings:Add vibrator devicetree documentation Pavel Machek
     [not found] ` <20200615114203.116656-3-fengping.yu@mediatek.com>
2020-06-15 15:07   ` [PATCH v1 2/3] drivers: input: misc: Add mtk vibrator driver kernel test robot
2020-06-16 11:02   ` Pavel Machek
2020-06-16 11:03   ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).