lkml.org 
[lkml]   [2017]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 1/2] eeprom: Add IDT 89HPESx EEPROM/CSR driver
On Tue, Dec 13, 2016 at 05:22:50PM +0300, Serge Semin wrote:
> +struct idt_89hpesx_dev {
> + u32 eesize;
> + bool eero;
> + u8 eeaddr;
> +
> + u8 inieecmd;
> + u8 inicsrcmd;
> + u8 iniccode;
> +
> + atomic_t csr;

Why is this an atomic_t and not just a "normal" u32 or u64? I don't see
the need for an atomic variable at all here, do you?


> +
> + int (*smb_write)(struct idt_89hpesx_dev *, const struct idt_smb_seq *);
> + int (*smb_read)(struct idt_89hpesx_dev *, struct idt_smb_seq *);
> + struct mutex smb_mtx;
> +
> + struct i2c_client *client;
> +
> + struct bin_attribute *ee_file;
> + struct dentry *csr_dir;
> + struct dentry *csr_file;
> +};

<snip>

> +
> +static int idt_create_dbgfs_files(struct idt_89hpesx_dev *pdev)
> +{
> + struct device *dev = &pdev->client->dev;
> + struct i2c_client *cli = pdev->client;
> + char fname[CSRNAME_LEN];
> +
> + /* Initialize basic value of CSR debugfs dentries */
> + pdev->csr_dir = NULL;
> + pdev->csr_file = NULL;
> +
> + /* Return failure if root directory doesn't exist */
> + if (!csr_dbgdir) {
> + dev_dbg(dev, "No Debugfs root directory");
> + return -EINVAL;
> + }

If debugfs is not enabled, don't error out, just keep going, it should
never stop kernel code from running properly.

Also, this test isn't really doing what you think it is doing...

> + /* Create Debugfs directory for CSR file */
> + snprintf(fname, CSRNAME_LEN, "%d-%04hx", cli->adapter->nr, cli->addr);
> + pdev->csr_dir = debugfs_create_dir(fname, csr_dbgdir);
> + if (IS_ERR_OR_NULL(pdev->csr_dir)) {
> + dev_err(dev, "Failed to create CSR node directory");
> + return -EINVAL;

Again, don't do this, you really don't care if debugfs worked or not.

> + }
> +
> + /* Create Debugfs file for CSR read/write operations */
> + pdev->csr_file = debugfs_create_file(cli->name, 0600,
> + pdev->csr_dir, pdev, &csr_dbgfs_ops);
> + if (IS_ERR_OR_NULL(pdev->csr_file)) {
> + dev_err(dev, "Failed to create CSR dbgfs-node");
> + debugfs_remove_recursive(pdev->csr_dir);
> + return -EINVAL;

Same here, just create the file and move on.

> + }
> +
> + dev_dbg(dev, "Debugfs-files created");

You do know about ftrace, right? Please remove all of these
"trace-like" debugging lines, they aren't needed for anyone.

thanks,

greg k-h

\
 
 \ /
  Last update: 2017-01-11 09:21    [W:0.094 / U:6.448 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site