public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Masayuki Ohtak <masa-korg@dsn.okisemi.com>
Cc: Randy Dunlap <randy.dunlap@oracle.com>,
	"Wang, Yong Y" <yong.y.wang@intel.com>,
	qi.wang@intel.com, joel.clark@intel.com,
	andrew.chih.howe.khor@intel.com,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Packet hub driver of Topcliff PCH
Date: Mon, 5 Jul 2010 17:04:00 +0200	[thread overview]
Message-ID: <201007051704.01100.arnd@arndb.de> (raw)
In-Reply-To: <4C3187A3.10407@dsn.okisemi.com>

I took another look and found some more things that should be improved.
Overall, the quality of this driver has improved enourmously, and I'm
optimistic that it will be a lot easier for you in your next device
driver with all the details you have learned about the coding style.

On Monday 05 July 2010, Masayuki Ohtak wrote:
 
> +struct pch_phub_reg {
> +	u32 phub_id_reg;
> +	u32 q_pri_val_reg;
> +	u32 rc_q_maxsize_reg;
> +	u32 bri_q_maxsize_reg;
> +	u32 comp_resp_timeout_reg;
> +	u32 bus_slave_control_reg;
> +	u32 deadlock_avoid_type_reg;
> +	u32 intpin_reg_wpermit_reg0;
> +	u32 intpin_reg_wpermit_reg1;
> +	u32 intpin_reg_wpermit_reg2;
> +	u32 intpin_reg_wpermit_reg3;
> +	u32 int_reduce_control_reg[MAX_NUM_INT_REDUCE_CONTROL_REG];
> +	u32 clkcfg_reg;
> +	void __iomem *pch_phub_base_address;
> +	void __iomem *pch_phub_extrom_base_address;
> +	int pch_phub_suspended;
> +} pch_phub_reg;

The variable you define here is in the global namespace, which it
should not be in. I'd suggest making it static and splitting the
type defintion from the variable definition to make that more obvious,
like:

struct pch_phub_reg {
	...
};

static struct pch_phub_reg pch_phub_reg;

> +static DEFINE_MUTEX(pch_phub_ioctl_mutex);
> +static DEFINE_MUTEX(pch_phub_read_mutex);
> +static DEFINE_MUTEX(pch_phub_write_mutex);

Having three mutexes here means that you have effectively no
serialization between the functions at all. The mutex only
has an effect if you use the same one in all three functions!

	Arnd

  reply	other threads:[~2010-07-05 15:04 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-22  5:33 [PATCH] Topcliff PHUB: Generate PacketHub driver Masayuki Ohtak
2010-06-22 10:33 ` Masayuki Ohtak
2010-06-22 22:12   ` Andrew Morton
2010-06-23  0:31     ` Masayuki Ohtake
2010-06-22 11:30 ` Arnd Bergmann
2010-06-22 13:52   ` Yong Wang
2010-06-29 23:31 ` Andy Isaacson
2010-06-30  5:58   ` Masayuki Ohtake
2010-06-30 18:28     ` Andy Isaacson
2010-07-01  4:08       ` Masayuki Ohtake
2010-06-30  7:51 ` [PATCH] Packet hub driver of Topcliff PCH Masayuki Ohtak
2010-06-30 18:05   ` Randy Dunlap
2010-07-01  2:52     ` Masayuki Ohtake
2010-07-01  5:14 ` Masayuki Ohtak
2010-07-01  6:58   ` Andy Isaacson
2010-07-01 10:13     ` Masayuki Ohtake
2010-07-01 10:38 ` Masayuki Ohtak
2010-07-01 15:44   ` Randy Dunlap
2010-07-05  7:20 ` Masayuki Ohtak
2010-07-05 15:04   ` Arnd Bergmann [this message]
2010-07-06 15:58   ` Randy Dunlap
2010-07-06  6:20 ` Masayuki Ohtak
2010-07-06  6:30   ` Arnd Bergmann
2010-07-07  1:19     ` Yong Wang
2010-07-09 20:00   ` Andrew Morton
2010-07-12  1:25     ` Masayuki Ohtake
2010-07-15  7:25 ` Masayuki Ohtak
2010-07-15  7:42 ` [PATCH] I2C " Masayuki Ohtak
2010-07-15 19:35   ` Arnd Bergmann
2010-07-20  0:05     ` Masayuki Ohtake
2010-07-20  4:55     ` Masayuki Ohtake
2010-07-20  9:27       ` Arnd Bergmann
2010-07-20 12:38         ` Masayuki Ohtake
2010-07-20  8:19     ` Masayuki Ohtake
2010-07-20  9:29       ` Arnd Bergmann
2010-07-20 12:40         ` Masayuki Ohtake
2010-07-21  6:46 ` Masayuki Ohtak

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=201007051704.01100.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=andrew.chih.howe.khor@intel.com \
    --cc=joel.clark@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masa-korg@dsn.okisemi.com \
    --cc=qi.wang@intel.com \
    --cc=randy.dunlap@oracle.com \
    --cc=yong.y.wang@intel.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