linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Roy Im <roy.im.opensource@diasemi.com>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	Brian Masney <masneyb@onstation.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	Lee Jones <lee.jones@linaro.org>, Luca Weiss <luca@z3ntu.xyz>,
	Maximilian Luz <luzmaximilian@gmail.com>,
	Pascal PAILLET-LME <p.paillet@st.com>,
	Rob Herring <robh@kernel.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Support Opensource <support.opensource@diasemi.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pwm@vger.kernel.org
Subject: Re: [RESEND PATCH V8 3/3] Input: new da7280 haptic driver
Date: Tue, 11 Feb 2020 15:26:22 +0100	[thread overview]
Message-ID: <20200211142622.5vt34ftdt242agaq@pengutronix.de> (raw)
In-Reply-To: <ba04fc95afbf3d77a49ad6d52ade20fe79a4b7eb.1581383604.git.Roy.Im@diasemi.com>

On Tue, Feb 11, 2020 at 10:13:24AM +0900, Roy Im wrote:
> diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
> new file mode 100644
> index 0000000..4d1d1fc
> --- /dev/null
> +++ b/drivers/input/misc/da7280.c
> @@ -0,0 +1,1688 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * DA7280 Haptic device driver
> + *
> + * Copyright (c) 2019 Dialog Semiconductor.
> + * Author: Roy Im <Roy.Im.Opensource@diasemi.com>
> + */
> +
> +#include <linux/err.h>
> +#include <linux/i2c.h>
> +#include <linux/input.h>
> +#include <linux/interrupt.h>
> +#include <linux/module.h>
> +#include <linux/pwm.h>
> +#include <linux/regmap.h>
> +#include <linux/workqueue.h>
> +#include <linux/uaccess.h>
> +#include "da7280.h"

Don't introduce a header file that is only used once. Better put the
definitions into the c file then.

> [...]
> +static int da7280_haptic_set_pwm(struct da7280_haptic *haptics)
> +{
> +	struct pwm_args pargs;
> +	u64 period_mag_multi;
> +	unsigned int pwm_duty;
> +	int error;
> +
> +	pwm_get_args(haptics->pwm_dev, &pargs);
> +	period_mag_multi =
> +		(u64)(pargs.period * haptics->gain);

This cast does not do anything, does it?

> +	if (haptics->acc_en)
> +		pwm_duty =
> +			(unsigned int)(period_mag_multi >> 16);
> +	else
> +		pwm_duty =
> +			(unsigned int)((period_mag_multi >> 16)
> +				+ pargs.period) / 2;
> +
> +	error = pwm_config(haptics->pwm_dev,
> +			   pwm_duty, pargs.period);
> +	if (error) {
> +		dev_err(haptics->dev,
> +			"failed to configure pwm : %d\n", error);
> +		return error;
> +	}
> +
> +	error = pwm_enable(haptics->pwm_dev);
> +	if (error) {
> +		pwm_disable(haptics->pwm_dev);
> +		dev_err(haptics->dev,
> +			"failed to enable haptics pwm device : %d\n", error);
> +	}

You should not use the legacy pwm API. Please stick to
pwm_apply_state().

Also consider using %pE for more expressive error messages.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

  reply	other threads:[~2020-02-11 14:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11  1:13 [RESEND PATCH V8 0/3] da7280: haptic driver submission Roy Im
2020-02-11  1:13 ` [RESEND PATCH V8 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms Roy Im
2020-02-11  1:13 ` [RESEND PATCH V8 2/3] dt-bindings: input: Add document bindings for DA7280 Roy Im
2020-02-11  1:13 ` [RESEND PATCH V8 3/3] Input: new da7280 haptic driver Roy Im
2020-02-11 14:26   ` Uwe Kleine-König [this message]
2020-02-14  1:35     ` Roy Im
  -- strict thread matches above, loose matches on Subject: below --
2019-12-20  8:26 [RESEND PATCH V8 0/3] da7280: haptic driver submission Roy Im
2019-12-20  8:26 ` [RESEND PATCH V8 3/3] Input: new da7280 haptic driver Roy Im

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200211142622.5vt34ftdt242agaq@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=bgolaszewski@baylibre.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=luca@z3ntu.xyz \
    --cc=luzmaximilian@gmail.com \
    --cc=masneyb@onstation.org \
    --cc=p.paillet@st.com \
    --cc=robh@kernel.org \
    --cc=roy.im.opensource@diasemi.com \
    --cc=sameo@linux.intel.com \
    --cc=support.opensource@diasemi.com \
    --cc=tglx@linutronix.de \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).