public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Felipe Balbi <me@felipebalbi.com>
Cc: linux-kernel@vger.kernel.org, dmitry.torokhov@gmail.com,
	felipe.balbi@nokia.com
Subject: Re: [PATCH] input: keyboard: introduce lm8323 driver
Date: Fri, 20 Feb 2009 13:42:37 -0800	[thread overview]
Message-ID: <20090220134237.50086106.akpm@linux-foundation.org> (raw)
In-Reply-To: <1235045654-29025-1-git-send-email-me@felipebalbi.com>

On Thu, 19 Feb 2009 14:14:14 +0200
Felipe Balbi <me@felipebalbi.com> wrote:

> From: Felipe Balbi <felipe.balbi@nokia.com>
> 
> lm8323 is the keypad driver used in n810 device. This
> driver has been sitting in linux-omap for quite a long
> time, it's about time to get comments from upstream and
> get it merged.
> 

Please feed it through scripts/checkpatch.pl and review the resulting
report?


> +static ssize_t lm8323_pwm_store_time(struct device *dev,
> +		struct device_attribute *attr, const char *buf, size_t len)
> +{
> +	struct led_classdev *led_cdev = dev_get_drvdata(dev);
> +	struct lm8323_pwm *pwm = cdev_to_pwm(led_cdev);
> +	int ret;
> +	int time;
> +
> +	ret = sscanf(buf, "%d", &time);
> +	/* Numbers only, please. */
> +	if (ret)
> +		return -EINVAL;

strict_strtoul() does a better job of this.

> +	pwm->fade_time = time;
> +
> +	return strlen(buf);
> +}
> +static DEVICE_ATTR(time, 0644, lm8323_pwm_show_time, lm8323_pwm_store_time);
> +
> +static int init_pwm(struct lm8323_chip *lm, int id, struct device *dev,
> +		    const char *name)
> +{
> +	struct lm8323_pwm *pwm = NULL;
> +
> +	BUG_ON(id > 3);
> +
> +	switch (id) {
> +	case 1:
> +		pwm = &lm->pwm1;
> +		break;
> +	case 2:
> +		pwm = &lm->pwm2;
> +		break;
> +	case 3:
> +		pwm = &lm->pwm3;
> +		break;
> +	}
> +
> +	pwm->id = id;
> +	pwm->fade_time = 0;
> +	pwm->brightness = 0;
> +	pwm->desired_brightness = 0;
> +	pwm->running = 0;
> +	mutex_init(&pwm->lock);
> +	if (name) {
> +		pwm->cdev.name = name;
> +		pwm->cdev.brightness_set = lm8323_pwm_set_brightness;
> +		if (led_classdev_register(dev, &pwm->cdev) < 0) {

I did't see a dependency on LEDS in the Kconfig entry.  Will it compile
with LEDS=n?


> +			dev_err(dev, "couldn't register PWM %d\n", id);
> +			return -1;
> +		}
> +		if (device_create_file(pwm->cdev.dev,
> +					     &dev_attr_time) < 0) {
> +			dev_err(dev, "couldn't register time attribute\n");
> +			led_classdev_unregister(&pwm->cdev);
> +			return -1;
> +		}
> +		INIT_WORK(&pwm->work, lm8323_pwm_work);
> +		pwm->enabled = 1;
> +	} else {
> +		pwm->enabled = 0;
> +	}
> +
> +	return 0;
> +}
> +
> +static struct i2c_driver lm8323_i2c_driver;
> +
> +static ssize_t lm8323_show_disable(struct device *dev,
> +				   struct device_attribute *attr, char *buf)
> +{
> +	struct lm8323_chip *lm = dev_get_drvdata(dev);
> +
> +	return sprintf(buf, "%u\n", !lm->kp_enabled);
> +}
> +
> +static ssize_t lm8323_set_disable(struct device *dev,
> +				  struct device_attribute *attr,
> +				  const char *buf, size_t count)
> +{
> +	struct lm8323_chip *lm = dev_get_drvdata(dev);
> +	int ret;
> +	int i;
> +
> +	i = sscanf(buf, "%d", &ret);

Again, strict_strto*() would be better.  It will disallow input of the
form "42foo".

> +	mutex_lock(&lm->lock);
> +	lm->kp_enabled = !i;
> +	mutex_unlock(&lm->lock);
> +
> +	return count;
> +}
>
> ...
>
> +static struct i2c_driver lm8323_i2c_driver = {
> +	.driver = {
> +		.name	 = "lm8323",
> +	},
> +	.probe		= lm8323_probe,
> +	.remove		= lm8323_remove,
> +	.suspend	= lm8323_suspend,
> +	.resume		= lm8323_resume,
> +	.id_table	= lm8323_id,
> +};

Does this compile and run OK with CONFIG_PM=n?

>
> ...
>


  parent reply	other threads:[~2009-02-20 21:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-19 12:14 [PATCH] input: keyboard: introduce lm8323 driver Felipe Balbi
2009-02-19 17:42 ` Trilok Soni
2009-02-19 17:53   ` Felipe Balbi
2009-02-20 21:42 ` Andrew Morton [this message]
2009-02-20 21:53   ` Felipe Balbi
  -- strict thread matches above, loose matches on Subject: below --
2009-02-19 12:31 Felipe Balbi
2009-02-20 22:15 ` Andrew Morton
2009-02-20 22:29   ` Felipe Balbi
2009-02-20 22:52     ` Felipe Balbi
2009-02-21  7:50       ` Trilok Soni
2009-02-20 22:54     ` Andrew Morton
2009-03-08  2:38 ` Dmitry Torokhov
2009-03-08 12:44   ` Felipe Balbi

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=20090220134237.50086106.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=felipe.balbi@nokia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@felipebalbi.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