linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Olimpiu Dejeu <olimpiu@arcticsand.com>
Cc: jg1.han@samsung.com, linux-kernel@vger.kernel.org,
	linux-fbdev@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 1/1] BACKLIGHT: Add Driver for ARCXCNN Chip
Date: Thu, 18 Aug 2016 11:07:48 +0000	[thread overview]
Message-ID: <20160818110748.GE27045@leverpostej> (raw)
In-Reply-To: <1471460799-16015-1-git-send-email-olimpiu@arcticsand.com>

On Wed, Aug 17, 2016 at 03:06:39PM -0400, Olimpiu Dejeu wrote:
> This is the driver for the Arctic Sand Technologies Inc. ARCXCNN LED
> backlight IC family.
> 
> Signed-off-by: Olimpiu Dejeu <olimpiu@arcticsand.com>
> ---
>  drivers/video/backlight/Kconfig      |   7 +
>  drivers/video/backlight/Makefile     |   1 +
>  drivers/video/backlight/arcxcnn_bl.c | 499 +++++++++++++++++++++++++++++++++++
>  include/linux/i2c/arcxcnn.h          |  41 +++
>  4 files changed, 547 insertions(+)
>  create mode 100644 drivers/video/backlight/arcxcnn_bl.c
>  create mode 100644 include/linux/i2c/arcxcnn.h

This is a one-patch series with no binding, yet the code below adds a new
compatible string ("arc,arcxcnn"), and DT parsing code assuming
uncommon, non-trivial properties.

You must write a device tree binding document for this.

Please see Documentation/devicetree/bindings/submitting-patches.txt.

> +static int arcxcnn_parse_dt(struct arcxcnn *lp)
> +{
> +	struct device *dev = lp->dev;
> +	struct device_node *node = dev->of_node;
> +	u32 prog_length;
> +
> +	if (!node) {
> +		dev_err(dev, "no platform data\n");
> +		return -EINVAL;
> +	}
> +
> +	of_property_read_string(node, "bl-name", &lp->pdata->name);
> +	of_property_read_u16(node, "init-brt", &lp->pdata->initial_brightness);
> +	of_property_read_u32(node, "pwm-period", &lp->pdata->period_ns);
> +
> +	if (lp->pdata->initial_brightness > MAX_BRIGHTNESS)
> +		lp->pdata->initial_brightness = MAX_BRIGHTNESS;
> +
> +	/* Fill program from platform data if defined
> +	*/
> +	lp->pdata->prog_entries = 0;
> +	prog_length = of_get_child_count(node);
> +	if (prog_length > 0) {
> +		struct device_node *child;
> +		u32 i = 0;
> +
> +		for_each_child_of_node(node, child) {
> +		    	if (i >= ARCXCNN_MAX_PROGENTRIES)
> +				break;
> +			of_property_read_u8(child, "prg-addr", &lp->pdata->prog_addr[i]);
> +			of_property_read_u8(child, "prg-data", &lp->pdata->prog_data[i]);

Don't bother using u8. The DTB is padded to u32 boundaries anyway, so this
just adds an additional burden on DT authors to use /bits/ 8
consistently, which inevitably someone will get wrong.

> +static int arcxcnn_probe(struct i2c_client *cl, const struct i2c_device_id *id)
> +{
> +	struct arcxcnn *lp;
> +	int ret;
> +	u32 i;
> +	u8 regval;
> +	u16 chipid;
> +
> +	if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
> +		return -EIO;
> +
> +	lp = devm_kzalloc(&cl->dev, sizeof(struct arcxcnn), GFP_KERNEL);

Nit: sizeof(*lp) is the preferred style.

> +static const struct of_device_id arcxcnn_dt_ids[] = {
> +	{ .compatible = "arc,arcxcnn", },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, arcxcnn_dt_ids);

Thanks,
Mark.

      reply	other threads:[~2016-08-18 11:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-17 19:06 [PATCH 1/1] BACKLIGHT: Add Driver for ARCXCNN Chip Olimpiu Dejeu
2016-08-18 11:07 ` Mark Rutland [this message]

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=20160818110748.GE27045@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jg1.han@samsung.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olimpiu@arcticsand.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).