From: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
To: Pantelis Antoniou
<pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
Cc: Frank Rowand
<frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
Alon Ronen <aronen-3r7Miqu9kMnR7s880joybQ@public.gmane.org>,
Debjit Ghosh <dghosh-3r7Miqu9kMnR7s880joybQ@public.gmane.org>,
Dhruva Diveneni
<ddevineni-3r7Miqu9kMnR7s880joybQ@public.gmane.org>,
Georgi Vlaev <gvlaev-3r7Miqu9kMnR7s880joybQ@public.gmane.org>,
Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>,
Yu-Lin Lu <ylu-3r7Miqu9kMnR7s880joybQ@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b@public.gmane.org
Subject: Re: [RFC 1/2] staging: jnx: Add Juniper connector driver
Date: Fri, 07 Oct 2016 09:25:27 -0700 [thread overview]
Message-ID: <1475857527.1945.7.camel@perches.com> (raw)
In-Reply-To: <1475853372-21997-2-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
On Fri, 2016-10-07 at 18:16 +0300, Pantelis Antoniou wrote:
> diff --git a/drivers/staging/jnx/jnx-connector.c b/drivers/staging/jnx/jnx-connector.c
[]
> +struct jnx_conn_data {
> + struct device *dev; /* parent (platform) device */
> + const char *name[NUM_OVERLAYS]; /* overlay file names */
> + bool enabled; /* true if can handle interrupts */
> + bool poweron; /* true if assumed to be powered on */
maybe use pahole and remove some of the wasteful padding
> + int attention_button; /* attention button gpio pin */
> + bool have_attention_button; /* true if attention button exists */
> + unsigned long attention_button_holdtime;/* button hold time, jiffies */
> + bool attention_ignore; /* true if handled by user space */
> + int power_enable; /* power enable gpio pin */
> + bool auto_enable; /* true if board should auto-enable */
> + struct jnx_i2c_power_seq pon; /* power-on sequence */
[]
> + u32 gpio_flags;
> + u16 assembly_id;
> + int slot; /* slot number */
> + int type; /* card type */
> + bool static_assembly_id; /* true if assembly_id is static */
> + bool assembly_id_valid; /* true if assembly_id is valid */
> + int adapter; /* parent i2c adapter number */
[]
> + struct mutex mutex; /* mutex to protect state changes */
> + bool synchronous; /* true if state changes are ok */
> + struct mutex fdt_mutex; /* mutex to protect fdt accesses */
[]
> + bool standby_to_master; /* standby:master_ev processing */
> +};
[]
> +/*
> + * jnx_conn_insert_ideeprom()
> + * Inserts ideeprom with a parent from OF prop
> + */
> +static int jnx_conn_insert_ideeprom(struct jnx_conn_data *data,
> + struct i2c_adapter *adap,
> + struct device_node *node,
> + struct i2c_board_info *info)
> +{
> + struct device *dev = data->dev;
> + struct i2c_adapter *parent = NULL;
> + struct i2c_client *client;
> + struct device_node *anode;
> + struct at24_platform_data at24_pdata = {
> + .byte_len = 256,
> + .page_size = 4,
> + .setup = jnx_conn_at24_callback,
> + .context = data,
> + };
> +
> + info->platform_data = &at24_pdata;
Assigning a temporary address through a pointer argument?
Isn't there a better way?
> +/*
> + * jnx_conn_verify_overlay()
> + *
> + * Verify if overlay is compatible with this board/slot
> + */
> +static int jnx_conn_verify_overlay(struct jnx_conn_data *data,
> + struct device_node *np)
> +{
[]
> + ret = of_property_read_u32(np, "type", &var);
> + if (ret) {
> + dev_err(dev, "Missing type property\n");
> + return ret;
> + }
> + if (var != data->type) {
> + dev_err(dev, "Wrong type: Expected %d, got %d\n",
> + data->type, var);
> + return -EINVAL;
> + }
> +
> + /*
> + * 'assembly-ids' property must exist, and one of its entries must match
> + * the card assembly id
> + */
> + assembly_ids = of_get_property(np, "assembly-ids", &size);
> + if (!assembly_ids || size < sizeof(u32)) {
> + dev_err(dev, "Bad assembly-ids property\n");
> + return -EINVAL;
> + }
> + ret = -EINVAL;
> + for (i = 0; i < size / sizeof(u32); i++) {
> + if (be32_to_cpu(assembly_ids[i]) == data->assembly_id) {
> + ret = 0;
> + break;
> + }
> + }
> + if (ret) {
> + dev_err(dev, "Assembly ID 0x%x not supported by overlay\n",
> + data->assembly_id);
> + return ret;
> + }
Given all the direct returns above here, perhaps
for (i = 0; i < size / sizeof(u32); i++) {
if (be32_to_cpu(assembly_ids[i]) == data->assembly_id)
return 0;
}
dev_err(...);
return -EINVAL;
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Joe Perches <joe@perches.com>
To: Pantelis Antoniou <pantelis.antoniou@konsulko.com>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>
Cc: Frank Rowand <frowand.list@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alon Ronen <aronen@juniper.net>,
Debjit Ghosh <dghosh@juniper.net>,
Dhruva Diveneni <ddevineni@juniper.net>,
Georgi Vlaev <gvlaev@juniper.net>,
Guenter Roeck <linux@roeck-us.net>, Yu-Lin Lu <ylu@juniper.net>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
devel@driverdev.osuosl.org
Subject: Re: [RFC 1/2] staging: jnx: Add Juniper connector driver
Date: Fri, 07 Oct 2016 09:25:27 -0700 [thread overview]
Message-ID: <1475857527.1945.7.camel@perches.com> (raw)
In-Reply-To: <1475853372-21997-2-git-send-email-pantelis.antoniou@konsulko.com>
On Fri, 2016-10-07 at 18:16 +0300, Pantelis Antoniou wrote:
> diff --git a/drivers/staging/jnx/jnx-connector.c b/drivers/staging/jnx/jnx-connector.c
[]
> +struct jnx_conn_data {
> + struct device *dev; /* parent (platform) device */
> + const char *name[NUM_OVERLAYS]; /* overlay file names */
> + bool enabled; /* true if can handle interrupts */
> + bool poweron; /* true if assumed to be powered on */
maybe use pahole and remove some of the wasteful padding
> + int attention_button; /* attention button gpio pin */
> + bool have_attention_button; /* true if attention button exists */
> + unsigned long attention_button_holdtime;/* button hold time, jiffies */
> + bool attention_ignore; /* true if handled by user space */
> + int power_enable; /* power enable gpio pin */
> + bool auto_enable; /* true if board should auto-enable */
> + struct jnx_i2c_power_seq pon; /* power-on sequence */
[]
> + u32 gpio_flags;
> + u16 assembly_id;
> + int slot; /* slot number */
> + int type; /* card type */
> + bool static_assembly_id; /* true if assembly_id is static */
> + bool assembly_id_valid; /* true if assembly_id is valid */
> + int adapter; /* parent i2c adapter number */
[]
> + struct mutex mutex; /* mutex to protect state changes */
> + bool synchronous; /* true if state changes are ok */
> + struct mutex fdt_mutex; /* mutex to protect fdt accesses */
[]
> + bool standby_to_master; /* standby:master_ev processing */
> +};
[]
> +/*
> + * jnx_conn_insert_ideeprom()
> + * Inserts ideeprom with a parent from OF prop
> + */
> +static int jnx_conn_insert_ideeprom(struct jnx_conn_data *data,
> + struct i2c_adapter *adap,
> + struct device_node *node,
> + struct i2c_board_info *info)
> +{
> + struct device *dev = data->dev;
> + struct i2c_adapter *parent = NULL;
> + struct i2c_client *client;
> + struct device_node *anode;
> + struct at24_platform_data at24_pdata = {
> + .byte_len = 256,
> + .page_size = 4,
> + .setup = jnx_conn_at24_callback,
> + .context = data,
> + };
> +
> + info->platform_data = &at24_pdata;
Assigning a temporary address through a pointer argument?
Isn't there a better way?
> +/*
> + * jnx_conn_verify_overlay()
> + *
> + * Verify if overlay is compatible with this board/slot
> + */
> +static int jnx_conn_verify_overlay(struct jnx_conn_data *data,
> + struct device_node *np)
> +{
[]
> + ret = of_property_read_u32(np, "type", &var);
> + if (ret) {
> + dev_err(dev, "Missing type property\n");
> + return ret;
> + }
> + if (var != data->type) {
> + dev_err(dev, "Wrong type: Expected %d, got %d\n",
> + data->type, var);
> + return -EINVAL;
> + }
> +
> + /*
> + * 'assembly-ids' property must exist, and one of its entries must match
> + * the card assembly id
> + */
> + assembly_ids = of_get_property(np, "assembly-ids", &size);
> + if (!assembly_ids || size < sizeof(u32)) {
> + dev_err(dev, "Bad assembly-ids property\n");
> + return -EINVAL;
> + }
> + ret = -EINVAL;
> + for (i = 0; i < size / sizeof(u32); i++) {
> + if (be32_to_cpu(assembly_ids[i]) == data->assembly_id) {
> + ret = 0;
> + break;
> + }
> + }
> + if (ret) {
> + dev_err(dev, "Assembly ID 0x%x not supported by overlay\n",
> + data->assembly_id);
> + return ret;
> + }
Given all the direct returns above here, perhaps
for (i = 0; i < size / sizeof(u32); i++) {
if (be32_to_cpu(assembly_ids[i]) == data->assembly_id)
return 0;
}
dev_err(...);
return -EINVAL;
next prev parent reply other threads:[~2016-10-07 16:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-07 15:16 [RFC 0/2] Juniper DT based connector driver Pantelis Antoniou
[not found] ` <1475853372-21997-1-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-10-07 15:16 ` [RFC 1/2] staging: jnx: Add Juniper " Pantelis Antoniou
2016-10-07 15:16 ` Pantelis Antoniou
[not found] ` <1475853372-21997-2-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-10-07 16:25 ` Joe Perches [this message]
2016-10-07 16:25 ` Joe Perches
[not found] ` <1475857527.1945.7.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2016-10-07 18:57 ` Pantelis Antoniou
2016-10-07 18:57 ` Pantelis Antoniou
2016-10-07 15:16 ` [RFC 2/2] staging: jnx-connector: add device tree binding Pantelis Antoniou
2016-10-07 15:16 ` Pantelis Antoniou
[not found] ` <1475853372-21997-3-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-10-08 16:05 ` Rob Herring
2016-10-08 16:05 ` Rob Herring
2016-10-07 15:30 ` [RFC 0/2] Juniper DT based connector driver Greg Kroah-Hartman
2016-10-08 16:10 ` Rob Herring
2016-10-08 16:10 ` Rob Herring
2016-10-08 16:11 ` Pantelis Antoniou
2016-10-08 16:11 ` Pantelis Antoniou
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=1475857527.1945.7.camel@perches.com \
--to=joe-6d6dil74uinbdgjk7y7tuq@public.gmane.org \
--cc=aronen-3r7Miqu9kMnR7s880joybQ@public.gmane.org \
--cc=ddevineni-3r7Miqu9kMnR7s880joybQ@public.gmane.org \
--cc=devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=dghosh-3r7Miqu9kMnR7s880joybQ@public.gmane.org \
--cc=frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=gvlaev-3r7Miqu9kMnR7s880joybQ@public.gmane.org \
--cc=linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=ylu-3r7Miqu9kMnR7s880joybQ@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.