Message ID | 201412030021.07882.PeterHuewe@gmx.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi, On Wed, Dec 03, 2014 at 12:21:07AM +0100, Peter Hüwe wrote: > --- a/drivers/char/tpm/tpm_i2c_nuvoton.c > +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c > @@ -605,10 +605,8 @@ static int i2c_nuvoton_probe(struct i2c_client *client, > return -ENODEV; > > rc = tpm_chip_register(chip); > - if (rc) > - return rc; > > - return 0; > + return rc; Maybe just return tpm_chip_register(chip)? A. ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
Am Mittwoch, 3. Dezember 2014, 00:24:43 schrieb Aaro Koskinen: > Hi, > > On Wed, Dec 03, 2014 at 12:21:07AM +0100, Peter Hüwe wrote: > > --- a/drivers/char/tpm/tpm_i2c_nuvoton.c > > +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c > > @@ -605,10 +605,8 @@ static int i2c_nuvoton_probe(struct i2c_client > > *client, > > > > return -ENODEV; > > > > rc = tpm_chip_register(chip); > > > > - if (rc) > > - return rc; > > > > - return 0; > > + return rc; > > Maybe just return tpm_chip_register(chip)? Even better. (I should go to bed now ;) Peter ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
On Wed, 2014-12-03 at 00:33 +0100, Peter Hüwe wrote: > Am Mittwoch, 3. Dezember 2014, 00:24:43 schrieb Aaro Koskinen: > > On Wed, Dec 03, 2014 at 12:21:07AM +0100, Peter Hüwe wrote: > > > --- a/drivers/char/tpm/tpm_i2c_nuvoton.c > > > +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c > > > @@ -605,10 +605,8 @@ static int i2c_nuvoton_probe(struct i2c_client > > > *client, > > > > > > return -ENODEV; > > > > > > rc = tpm_chip_register(chip); > > > > > > - if (rc) > > > - return rc; > > > > > > - return 0; > > > + return rc; > > > > Maybe just return tpm_chip_register(chip)? > > Even better. The pattern: foo = bar(); if (foo) return foo; return 0; is fairly common. There are a few hundred in the kernel. $ grep-2.5.4 -nrP --include=*.[ch] "\b(\w+)\s*=\s*[^;]*;\s*if\s*\(\s*\1\s*\)\s*return\s*\1\s*;\s*return\s*0;" * | \ grep -oP '^.+:\d+:' | \ wc -l 308 ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
On Wed, 3 Dec 2014, Peter Hüwe wrote: > From: Peter Huewe <peterhuewe@gmx.de> > Date: Wed, 3 Dec 2014 00:18:52 +0100 > Subject: [PATCH] tpm:tpm_i2c_nuvoton: simpyl return statements simpyl? > if !rc evals to false it is 0 > -> we can return rc in both cases Why assigning rc and returning it when you can return the result of tpm_chip_register() right away? Thanks, tglx ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c index 14246e2..79f4fef 100644 --- a/drivers/char/tpm/tpm_i2c_nuvoton.c +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c @@ -605,10 +605,8 @@ static int i2c_nuvoton_probe(struct i2c_client *client, return -ENODEV; rc = tpm_chip_register(chip); - if (rc) - return rc; - return 0; + return rc; } static int i2c_nuvoton_remove(struct i2c_client *client)