[PATCH 2/2 linux-next] PNPACPI: use unsigned int in pnpacpi_encode_resources()

2015-05-02 Thread Fabian Frederick
use unsigned int for port, irq, dma and mem used for pnp_get_resource()
This fixes gcc warnings of type "conversion to unsigned int
from int may change the sign of the result"

Signed-off-by: Fabian Frederick 
---
 drivers/pnp/pnpacpi/rsparser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 23a08d1..0579649 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -873,7 +873,7 @@ int pnpacpi_encode_resources(struct pnp_dev *dev, struct 
acpi_buffer *buffer)
/* pnpacpi_build_resource_template allocates extra mem */
int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1;
struct acpi_resource *resource = buffer->pointer;
-   int port = 0, irq = 0, dma = 0, mem = 0;
+   unsigned int port = 0, irq = 0, dma = 0, mem = 0;
 
pnp_dbg(>dev, "encode %d resources\n", res_cnt);
while (i < res_cnt) {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] PNP: move EXPORT_SYMBOL after functions

2015-05-02 Thread Fabian Frederick
EXPORT macro must be placed directly after functions.
See Documentation/CodingStyle Chapter 6

Signed-off-by: Fabian Frederick f...@skynet.be
---
 drivers/pnp/driver.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index 153a493..b690e6b 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -67,6 +67,7 @@ int pnp_device_attach(struct pnp_dev *pnp_dev)
mutex_unlock(pnp_lock);
return 0;
 }
+EXPORT_SYMBOL(pnp_device_attach);
 
 void pnp_device_detach(struct pnp_dev *pnp_dev)
 {
@@ -76,6 +77,7 @@ void pnp_device_detach(struct pnp_dev *pnp_dev)
mutex_unlock(pnp_lock);
pnp_disable_dev(pnp_dev);
 }
+EXPORT_SYMBOL(pnp_device_detach);
 
 static int pnp_device_probe(struct device *dev)
 {
@@ -266,11 +268,13 @@ int pnp_register_driver(struct pnp_driver *drv)
 
return driver_register(drv-driver);
 }
+EXPORT_SYMBOL(pnp_register_driver);
 
 void pnp_unregister_driver(struct pnp_driver *drv)
 {
driver_unregister(drv-driver);
 }
+EXPORT_SYMBOL(pnp_unregister_driver);
 
 /**
  * pnp_add_id - adds an EISA id to the specified device
@@ -305,8 +309,3 @@ struct pnp_id *pnp_add_id(struct pnp_dev *dev, const char 
*id)
 
return dev_id;
 }
-
-EXPORT_SYMBOL(pnp_register_driver);
-EXPORT_SYMBOL(pnp_unregister_driver);
-EXPORT_SYMBOL(pnp_device_attach);
-EXPORT_SYMBOL(pnp_device_detach);
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2 linux-next] PNPACPI: use u8 instead of int in acpi_resource_extended_irq context

2015-05-02 Thread Fabian Frederick
acpi_resource_extented_irq variables are all u8.
Use that type for triggering, polarity and shareable.
This fixes gcc warnings of type
conversion to u8 from int may alter its value

Signed-off-by: Fabian Frederick f...@skynet.be
---
 drivers/pnp/pnpacpi/rsparser.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index ff0356f..23a08d1 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -28,8 +28,8 @@
 #include ../base.h
 #include pnpacpi.h
 
-static void decode_irq_flags(struct pnp_dev *dev, int flags, int *triggering,
-int *polarity, int *shareable)
+static void decode_irq_flags(struct pnp_dev *dev, int flags, u8 *triggering,
+u8 *polarity, u8 *shareable)
 {
switch (flags  (IORESOURCE_IRQ_LOWLEVEL | IORESOURCE_IRQ_HIGHLEVEL |
 IORESOURCE_IRQ_LOWEDGE  | IORESOURCE_IRQ_HIGHEDGE)) {
@@ -654,7 +654,7 @@ static void pnpacpi_encode_irq(struct pnp_dev *dev,
   struct resource *p)
 {
struct acpi_resource_irq *irq = resource-data.irq;
-   int triggering, polarity, shareable;
+   u8 triggering, polarity, shareable;
 
if (!pnp_resource_enabled(p)) {
irq-interrupt_count = 0;
@@ -683,7 +683,7 @@ static void pnpacpi_encode_ext_irq(struct pnp_dev *dev,
   struct resource *p)
 {
struct acpi_resource_extended_irq *extended_irq = 
resource-data.extended_irq;
-   int triggering, polarity, shareable;
+   u8 triggering, polarity, shareable;
 
if (!pnp_resource_enabled(p)) {
extended_irq-interrupt_count = 0;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2 linux-next] PNPACPI: use unsigned int in pnpacpi_encode_resources()

2015-05-02 Thread Fabian Frederick
use unsigned int for port, irq, dma and mem used for pnp_get_resource()
This fixes gcc warnings of type conversion to unsigned int
from int may change the sign of the result

Signed-off-by: Fabian Frederick f...@skynet.be
---
 drivers/pnp/pnpacpi/rsparser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 23a08d1..0579649 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -873,7 +873,7 @@ int pnpacpi_encode_resources(struct pnp_dev *dev, struct 
acpi_buffer *buffer)
/* pnpacpi_build_resource_template allocates extra mem */
int res_cnt = (buffer-length - 1) / sizeof(struct acpi_resource) - 1;
struct acpi_resource *resource = buffer-pointer;
-   int port = 0, irq = 0, dma = 0, mem = 0;
+   unsigned int port = 0, irq = 0, dma = 0, mem = 0;
 
pnp_dbg(dev-dev, encode %d resources\n, res_cnt);
while (i  res_cnt) {
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] gfs2: kerneldoc warning fixes

2015-05-02 Thread Fabian Frederick
Fixes the following kernel-doc warnings:
Warning(fs/gfs2/aops.c:180): No description found for parameter 'wbc'
Warning(fs/gfs2/aops.c:236): No description found for parameter 'end'
Warning(fs/gfs2/aops.c:236): No description found for parameter 'done_index'
Warning(fs/gfs2/aops.c:236): Excess function parameter 'writepage' description 
in 'gfs2_write_jdata_pagevec'
Warning(fs/gfs2/aops.c:346): Excess function parameter 'writepage' description 
in 'gfs2_write_cache_jdata'
Warning(fs/gfs2/aops.c:346): Excess function parameter 'data' description in 
'gfs2_write_cache_jdata'
Warning(fs/gfs2/aops.c:605): No description found for parameter 'file'
Warning(fs/gfs2/aops.c:605): No description found for parameter 'mapping'
Warning(fs/gfs2/aops.c:605): No description found for parameter 'pages'
Warning(fs/gfs2/aops.c:605): No description found for parameter 'nr_pages'
Warning(fs/gfs2/aops.c:870): No description found for parameter 'copied'

Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/gfs2/aops.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 5551fea..1caee05 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -171,6 +171,7 @@ static int __gfs2_jdata_writepage(struct page *page, struct 
writeback_control *w
 /**
  * gfs2_jdata_writepage - Write complete page
  * @page: Page to write
+ * @wbc: The writeback control
  *
  * Returns: errno
  *
@@ -221,9 +222,10 @@ static int gfs2_writepages(struct address_space *mapping,
  * gfs2_write_jdata_pagevec - Write back a pagevec's worth of pages
  * @mapping: The mapping
  * @wbc: The writeback control
- * @writepage: The writepage function to call for each page
  * @pvec: The vector of pages
  * @nr_pages: The number of pages to write
+ * @end: End position
+ * @done_index: Page index
  *
  * Returns: non-zero if loop should terminate, zero otherwise
  */
@@ -333,8 +335,6 @@ continue_unlock:
  * gfs2_write_cache_jdata - Like write_cache_pages but different
  * @mapping: The mapping to write
  * @wbc: The writeback control
- * @writepage: The writepage function to call
- * @data: The data to pass to writepage
  *
  * The reason that we use our own function here is that we need to
  * start transactions before we grab page locks. This allows us
@@ -588,6 +588,10 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, 
loff_t *pos,
 
 /**
  * gfs2_readpages - Read a bunch of pages at once
+ * @file: The file to read from
+ * @mapping: Address space info
+ * @pages: List of pages to read
+ * @nr_pages: Number of pages to read
  *
  * Some notes:
  * 1. This is only for readahead, so we can simply ignore any things
@@ -853,7 +857,7 @@ static int gfs2_stuffed_write_end(struct inode *inode, 
struct buffer_head *dibh,
  * @mapping: The address space to write to
  * @pos: The file position
  * @len: The length of the data
- * @copied:
+ * @copied: How much was actually copied by the VFS
  * @page: The page that has been written
  * @fsdata: The fsdata (unused in GFS2)
  *
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] affs: add default case in switch

2015-05-02 Thread Fabian Frederick
Fix gcc -Wswitch-default warnings

Cc: Andrew Morton a...@linux-foundation.org
Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/affs/inode.c | 2 ++
 fs/affs/namei.c | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 1734950..623398e 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -143,6 +143,8 @@ struct inode *affs_iget(struct super_block *sb, unsigned 
long ino)
inode-i_op = affs_symlink_inode_operations;
inode-i_data.a_ops = affs_symlink_aops;
break;
+   default:
+   break;
}
 
inode-i_mtime.tv_sec = inode-i_atime.tv_sec = inode-i_ctime.tv_sec
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index 181e05b..517926d 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -237,6 +237,9 @@ affs_lookup(struct inode *dir, struct dentry *dentry, 
unsigned int flags)
//case ST_LINKDIR:
case ST_LINKFILE:
ino = be32_to_cpu(AFFS_TAIL(sb, bh)-original);
+   break;
+   default:
+   break;
}
affs_brelse(bh);
inode = affs_iget(sb, ino);
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] [media] siano: define SRVM_MAX_PID_FILTERS only once

2015-05-02 Thread Fabian Frederick
SRVM_MAX_PID_FILTERS was defined in 2 sms_tx_stats structures

Signed-off-by: Fabian Frederick f...@skynet.be
---
 drivers/media/common/siano/smscoreapi.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/common/siano/smscoreapi.h 
b/drivers/media/common/siano/smscoreapi.h
index eb8bd68..4cc39e4 100644
--- a/drivers/media/common/siano/smscoreapi.h
+++ b/drivers/media/common/siano/smscoreapi.h
@@ -1010,6 +1010,7 @@ struct sms_rx_stats_ex {
s32 mrc_in_band_pwr;/* In band power in dBM */
 };
 
+#defineSRVM_MAX_PID_FILTERS 8
 
 /* statistics information returned as response for
  * SmsHostApiGetstatisticsEx_Req for DVB applications, SMS1100 and up */
@@ -1021,7 +1022,6 @@ struct sms_stats_dvb {
struct sms_tx_stats transmission_data;
 
/* Burst parameters, valid only for DVB-H */
-#defineSRVM_MAX_PID_FILTERS 8
struct sms_pid_data pid_data[SRVM_MAX_PID_FILTERS];
 };
 
@@ -1035,7 +1035,6 @@ struct sms_stats_dvb_ex {
struct sms_tx_stats transmission_data;
 
/* Burst parameters, valid only for DVB-H */
-#defineSRVM_MAX_PID_FILTERS 8
struct sms_pid_data pid_data[SRVM_MAX_PID_FILTERS];
 };
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V3 2/2 linux-next] cpufreq: pxa: make pxa_freqs arrays const

2015-05-01 Thread Fabian Frederick
pxa255_run_freqs and pxa255_turbo_freqs are only read.
This patch updates arrays declaration, find_freq_tables()
and its callsites.

Suggested-by: Joe Perches 
Signed-off-by: Fabian Frederick 
---
Compiled but untested.

 drivers/cpufreq/pxa2xx-cpufreq.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index fcf6e34..1d99c97 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -86,7 +86,7 @@ static unsigned int sdram_rows;
 /* Use the run mode frequencies for the CPUFREQ_POLICY_PERFORMANCE policy */
 #define CCLKCFGCCLKCFG_TURBO | CCLKCFG_FCS
 
-static struct pxa_freqs pxa255_run_freqs[] =
+static const struct pxa_freqs pxa255_run_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus 
SDRAM */
{ 99500,  99500, 0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -98,7 +98,7 @@ static struct pxa_freqs pxa255_run_freqs[] =
 };
 
 /* Use the turbo mode frequencies for the CPUFREQ_POLICY_POWERSAVE policy */
-static struct pxa_freqs pxa255_turbo_freqs[] =
+static const struct pxa_freqs pxa255_turbo_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus SDRAM */
{ 99500, 99500,  0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -171,7 +171,7 @@ extern unsigned get_clk_frequency_khz(int info);
 
 #ifdef CONFIG_REGULATOR
 
-static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
+static int pxa_cpufreq_change_voltage(const struct pxa_freqs *pxa_freq)
 {
int ret = 0;
int vmin, vmax;
@@ -211,7 +211,7 @@ static void __init pxa_cpufreq_init_voltages(void) { }
 #endif
 
 static void find_freq_tables(struct cpufreq_frequency_table **freq_table,
-struct pxa_freqs **pxa_freqs)
+const struct pxa_freqs **pxa_freqs)
 {
if (cpu_is_pxa25x()) {
if (!pxa255_turbo_table) {
@@ -270,7 +270,7 @@ static unsigned int pxa_cpufreq_get(unsigned int cpu)
 static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 {
struct cpufreq_frequency_table *pxa_freqs_table;
-   struct pxa_freqs *pxa_freq_settings;
+   const struct pxa_freqs *pxa_freq_settings;
unsigned long flags;
unsigned int new_freq_cpu, new_freq_mem;
unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
@@ -361,7 +361,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
int i;
unsigned int freq;
struct cpufreq_frequency_table *pxa255_freq_table;
-   struct pxa_freqs *pxa255_freqs;
+   const struct pxa_freqs *pxa255_freqs;
 
/* try to guess pxa27x cpu */
if (cpu_is_pxa27x())
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V3 1/2 linux-next] cpufreq: pxa: replace typedef pxa_freqs_t by structure

2015-05-01 Thread Fabian Frederick
typedef is not really useful here. Replace it by structure
to improve readability. typedef should only be used in some cases.
(See Documentation/CodingStyle Chapter 5 for details).

Signed-off-by: Fabian Frederick 
---
Compiled but untested.

V3: -constify arrays(patch 2) (suggested by Joe Perches)
-fix typo in changelog (thanks to Viresh Kumar)
V2: -verbose changelog.

 drivers/cpufreq/pxa2xx-cpufreq.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index e24269a..fcf6e34 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -56,7 +56,7 @@ module_param(pxa27x_maxfreq, uint, 0);
 MODULE_PARM_DESC(pxa27x_maxfreq, "Set the pxa27x maxfreq in MHz"
 "(typically 624=>pxa270, 416=>pxa271, 520=>pxa272)");
 
-typedef struct {
+struct pxa_freqs {
unsigned int khz;
unsigned int membus;
unsigned int cccr;
@@ -64,7 +64,7 @@ typedef struct {
unsigned int cclkcfg;
int vmin;
int vmax;
-} pxa_freqs_t;
+};
 
 /* Define the refresh period in mSec for the SDRAM and the number of rows */
 #define SDRAM_TREF 64  /* standard 64ms SDRAM */
@@ -86,7 +86,7 @@ static unsigned int sdram_rows;
 /* Use the run mode frequencies for the CPUFREQ_POLICY_PERFORMANCE policy */
 #define CCLKCFGCCLKCFG_TURBO | CCLKCFG_FCS
 
-static pxa_freqs_t pxa255_run_freqs[] =
+static struct pxa_freqs pxa255_run_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus 
SDRAM */
{ 99500,  99500, 0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -98,7 +98,7 @@ static pxa_freqs_t pxa255_run_freqs[] =
 };
 
 /* Use the turbo mode frequencies for the CPUFREQ_POLICY_POWERSAVE policy */
-static pxa_freqs_t pxa255_turbo_freqs[] =
+static struct pxa_freqs pxa255_turbo_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus SDRAM */
{ 99500, 99500,  0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -153,7 +153,7 @@ MODULE_PARM_DESC(pxa255_turbo_table, "Selects the frequency 
table (0 = run table
((HT) ? CCLKCFG_HALFTURBO : 0) | \
((T)  ? CCLKCFG_TURBO : 0))
 
-static pxa_freqs_t pxa27x_freqs[] = {
+static struct pxa_freqs pxa27x_freqs[] = {
{104000, 104000, PXA27x_CCCR(1,  8, 2), 0, CCLKCFG2(1, 0, 1),  90, 
1705000 },
{156000, 104000, PXA27x_CCCR(1,  8, 3), 0, CCLKCFG2(1, 0, 1), 100, 
1705000 },
{208000, 208000, PXA27x_CCCR(0, 16, 2), 1, CCLKCFG2(0, 0, 1), 118, 
1705000 },
@@ -171,7 +171,7 @@ extern unsigned get_clk_frequency_khz(int info);
 
 #ifdef CONFIG_REGULATOR
 
-static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
+static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
 {
int ret = 0;
int vmin, vmax;
@@ -202,7 +202,7 @@ static void __init pxa_cpufreq_init_voltages(void)
}
 }
 #else
-static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
+static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
 {
return 0;
 }
@@ -211,7 +211,7 @@ static void __init pxa_cpufreq_init_voltages(void) { }
 #endif
 
 static void find_freq_tables(struct cpufreq_frequency_table **freq_table,
-pxa_freqs_t **pxa_freqs)
+struct pxa_freqs **pxa_freqs)
 {
if (cpu_is_pxa25x()) {
if (!pxa255_turbo_table) {
@@ -270,7 +270,7 @@ static unsigned int pxa_cpufreq_get(unsigned int cpu)
 static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 {
struct cpufreq_frequency_table *pxa_freqs_table;
-   pxa_freqs_t *pxa_freq_settings;
+   struct pxa_freqs *pxa_freq_settings;
unsigned long flags;
unsigned int new_freq_cpu, new_freq_mem;
unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
@@ -361,7 +361,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
int i;
unsigned int freq;
struct cpufreq_frequency_table *pxa255_freq_table;
-   pxa_freqs_t *pxa255_freqs;
+   struct pxa_freqs *pxa255_freqs;
 
/* try to guess pxa27x cpu */
if (cpu_is_pxa27x())
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V3 1/2 linux-next] cpufreq: pxa: replace typedef pxa_freqs_t by structure

2015-05-01 Thread Fabian Frederick
typedef is not really useful here. Replace it by structure
to improve readability. typedef should only be used in some cases.
(See Documentation/CodingStyle Chapter 5 for details).

Signed-off-by: Fabian Frederick f...@skynet.be
---
Compiled but untested.

V3: -constify arrays(patch 2) (suggested by Joe Perches)
-fix typo in changelog (thanks to Viresh Kumar)
V2: -verbose changelog.

 drivers/cpufreq/pxa2xx-cpufreq.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index e24269a..fcf6e34 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -56,7 +56,7 @@ module_param(pxa27x_maxfreq, uint, 0);
 MODULE_PARM_DESC(pxa27x_maxfreq, Set the pxa27x maxfreq in MHz
 (typically 624=pxa270, 416=pxa271, 520=pxa272));
 
-typedef struct {
+struct pxa_freqs {
unsigned int khz;
unsigned int membus;
unsigned int cccr;
@@ -64,7 +64,7 @@ typedef struct {
unsigned int cclkcfg;
int vmin;
int vmax;
-} pxa_freqs_t;
+};
 
 /* Define the refresh period in mSec for the SDRAM and the number of rows */
 #define SDRAM_TREF 64  /* standard 64ms SDRAM */
@@ -86,7 +86,7 @@ static unsigned int sdram_rows;
 /* Use the run mode frequencies for the CPUFREQ_POLICY_PERFORMANCE policy */
 #define CCLKCFGCCLKCFG_TURBO | CCLKCFG_FCS
 
-static pxa_freqs_t pxa255_run_freqs[] =
+static struct pxa_freqs pxa255_run_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus 
SDRAM */
{ 99500,  99500, 0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -98,7 +98,7 @@ static pxa_freqs_t pxa255_run_freqs[] =
 };
 
 /* Use the turbo mode frequencies for the CPUFREQ_POLICY_POWERSAVE policy */
-static pxa_freqs_t pxa255_turbo_freqs[] =
+static struct pxa_freqs pxa255_turbo_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus SDRAM */
{ 99500, 99500,  0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -153,7 +153,7 @@ MODULE_PARM_DESC(pxa255_turbo_table, Selects the frequency 
table (0 = run table
((HT) ? CCLKCFG_HALFTURBO : 0) | \
((T)  ? CCLKCFG_TURBO : 0))
 
-static pxa_freqs_t pxa27x_freqs[] = {
+static struct pxa_freqs pxa27x_freqs[] = {
{104000, 104000, PXA27x_CCCR(1,  8, 2), 0, CCLKCFG2(1, 0, 1),  90, 
1705000 },
{156000, 104000, PXA27x_CCCR(1,  8, 3), 0, CCLKCFG2(1, 0, 1), 100, 
1705000 },
{208000, 208000, PXA27x_CCCR(0, 16, 2), 1, CCLKCFG2(0, 0, 1), 118, 
1705000 },
@@ -171,7 +171,7 @@ extern unsigned get_clk_frequency_khz(int info);
 
 #ifdef CONFIG_REGULATOR
 
-static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
+static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
 {
int ret = 0;
int vmin, vmax;
@@ -202,7 +202,7 @@ static void __init pxa_cpufreq_init_voltages(void)
}
 }
 #else
-static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
+static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
 {
return 0;
 }
@@ -211,7 +211,7 @@ static void __init pxa_cpufreq_init_voltages(void) { }
 #endif
 
 static void find_freq_tables(struct cpufreq_frequency_table **freq_table,
-pxa_freqs_t **pxa_freqs)
+struct pxa_freqs **pxa_freqs)
 {
if (cpu_is_pxa25x()) {
if (!pxa255_turbo_table) {
@@ -270,7 +270,7 @@ static unsigned int pxa_cpufreq_get(unsigned int cpu)
 static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 {
struct cpufreq_frequency_table *pxa_freqs_table;
-   pxa_freqs_t *pxa_freq_settings;
+   struct pxa_freqs *pxa_freq_settings;
unsigned long flags;
unsigned int new_freq_cpu, new_freq_mem;
unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
@@ -361,7 +361,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
int i;
unsigned int freq;
struct cpufreq_frequency_table *pxa255_freq_table;
-   pxa_freqs_t *pxa255_freqs;
+   struct pxa_freqs *pxa255_freqs;
 
/* try to guess pxa27x cpu */
if (cpu_is_pxa27x())
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V3 2/2 linux-next] cpufreq: pxa: make pxa_freqs arrays const

2015-05-01 Thread Fabian Frederick
pxa255_run_freqs and pxa255_turbo_freqs are only read.
This patch updates arrays declaration, find_freq_tables()
and its callsites.

Suggested-by: Joe Perches j...@perches.com
Signed-off-by: Fabian Frederick f...@skynet.be
---
Compiled but untested.

 drivers/cpufreq/pxa2xx-cpufreq.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index fcf6e34..1d99c97 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -86,7 +86,7 @@ static unsigned int sdram_rows;
 /* Use the run mode frequencies for the CPUFREQ_POLICY_PERFORMANCE policy */
 #define CCLKCFGCCLKCFG_TURBO | CCLKCFG_FCS
 
-static struct pxa_freqs pxa255_run_freqs[] =
+static const struct pxa_freqs pxa255_run_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus 
SDRAM */
{ 99500,  99500, 0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -98,7 +98,7 @@ static struct pxa_freqs pxa255_run_freqs[] =
 };
 
 /* Use the turbo mode frequencies for the CPUFREQ_POLICY_POWERSAVE policy */
-static struct pxa_freqs pxa255_turbo_freqs[] =
+static const struct pxa_freqs pxa255_turbo_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus SDRAM */
{ 99500, 99500,  0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -171,7 +171,7 @@ extern unsigned get_clk_frequency_khz(int info);
 
 #ifdef CONFIG_REGULATOR
 
-static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
+static int pxa_cpufreq_change_voltage(const struct pxa_freqs *pxa_freq)
 {
int ret = 0;
int vmin, vmax;
@@ -211,7 +211,7 @@ static void __init pxa_cpufreq_init_voltages(void) { }
 #endif
 
 static void find_freq_tables(struct cpufreq_frequency_table **freq_table,
-struct pxa_freqs **pxa_freqs)
+const struct pxa_freqs **pxa_freqs)
 {
if (cpu_is_pxa25x()) {
if (!pxa255_turbo_table) {
@@ -270,7 +270,7 @@ static unsigned int pxa_cpufreq_get(unsigned int cpu)
 static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 {
struct cpufreq_frequency_table *pxa_freqs_table;
-   struct pxa_freqs *pxa_freq_settings;
+   const struct pxa_freqs *pxa_freq_settings;
unsigned long flags;
unsigned int new_freq_cpu, new_freq_mem;
unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
@@ -361,7 +361,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
int i;
unsigned int freq;
struct cpufreq_frequency_table *pxa255_freq_table;
-   struct pxa_freqs *pxa255_freqs;
+   const struct pxa_freqs *pxa255_freqs;
 
/* try to guess pxa27x cpu */
if (cpu_is_pxa27x())
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1 linux-next] exofs: convert simple_str to kstr

2015-04-30 Thread Fabian Frederick


> On 30 April 2015 at 09:55 Boaz Harrosh  wrote:
>
>
> On 04/29/2015 08:58 PM, Fabian Frederick wrote:
> > replace obsolete function.
> >
> > Signed-off-by: Fabian Frederick 
>
> Thanks.
> ACK-by: Boaz Harrosh 
>
> Are you pushing all these through some tree, or
> You need that I push it? Maybe push all these changes
> through some central place, like Andrew's tree?

Thanks Boaz, I don't use any tree ; I could forward this patch to Andrew but I
guess you
prefer Alexey's solution which uses parse_integer() instead of
match_strlcpy() ?

http://marc.info/?l=linux-kernel=143039354303440=2

Regards,
Fabian

>
> Boaz
>
> > ---
> > This is untested.
> >
> >  fs/exofs/super.c | 8 +++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/exofs/super.c b/fs/exofs/super.c
> > index b795c56..b667f73 100644
> > --- a/fs/exofs/super.c
> > +++ b/fs/exofs/super.c
> > @@ -108,9 +108,14 @@ static int parse_options(char *options, struct
> > exofs_mountopt *opts)
> >                     opts->is_osdname = true;
> >                     break;
> >             case Opt_pid:
> > +           {
> > +                   int rc;
> > +
> >                     if (0 == match_strlcpy(str, [0], sizeof(str)))
> >                             return -EINVAL;
> > -                   opts->pid = simple_strtoull(str, NULL, 0);
> > +                   rc = kstrtoull(str, 0, >pid);
> > +                   if (rc)
> > +                           return rc;
> >                     if (opts->pid < EXOFS_MIN_PID) {
> >                             EXOFS_ERR("Partition ID must be >= %u",
> >                                       EXOFS_MIN_PID);
> > @@ -118,6 +123,7 @@ static int parse_options(char *options, struct
> > exofs_mountopt *opts)
> >                     }
> >                     s_pid = 1;
> >                     break;
> > +           }
> >             case Opt_to:
> >                     if (match_int([0], ))
> >                             return -EINVAL;
> >
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2 linux-next] cpufreq: pxa: replace typedef pxa_freqs_t by structure

2015-04-30 Thread Fabian Frederick


> On 30 April 2015 at 06:46 Joe Perches  wrote:
>
>
> On Wed, 2015-04-29 at 21:32 +0200, Fabian Frederick wrote:
> > typedef is not really useful here. Replace it by structure
> > to improve readability.typedef should only be used in some cases.
> > (See Documentation/CodingStyle Chapter 5 for details).
>
> trivia:
>
> > diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c
> > b/drivers/cpufreq/pxa2xx-cpufreq.c
> []
> > @@ -86,7 +86,7 @@ static unsigned int sdram_rows;
> >  /* Use the run mode frequencies for the CPUFREQ_POLICY_PERFORMANCE policy
> >*/
> >  #define CCLKCFG                    CCLKCFG_TURBO | CCLKCFG_FCS
> > 
> > -static pxa_freqs_t pxa255_run_freqs[] =
> > +static struct pxa_freqs pxa255_run_freqs[] =
>
> Should these be const?

AFAICS yes but this needs some fixes:
drivers/cpufreq/pxa2xx-cpufreq.c: In function 'find_freq_tables':
drivers/cpufreq/pxa2xx-cpufreq.c:218:15: warning: assignment discards 'const'
qualifier from pointer target type
    *pxa_freqs = pxa255_run_freqs;
               ^
Maybe another patch ?

Regards,
Fabian
>
> >  {
> >     /* CPU   MEMBUS  CCCR  DIV2 CCLKCFG                run  turbo PXbus
> >SDRAM */
> >     { 99500,  99500, 0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50, 
> > 50  */
> > @@ -98,7 +98,7 @@ static pxa_freqs_t pxa255_run_freqs[] =
> >  };
> > 
> >  /* Use the turbo mode frequencies for the CPUFREQ_POLICY_POWERSAVE policy
> >*/
> > -static pxa_freqs_t pxa255_turbo_freqs[] =
> > +static struct pxa_freqs pxa255_turbo_freqs[] =
> >  {
> >     /* CPU   MEMBUS  CCCR  DIV2 CCLKCFG        run  turbo PXbus SDRAM */
> >     { 99500, 99500,  0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50, 
> > 50  */
> > @@ -153,7 +153,7 @@ MODULE_PARM_DESC(pxa255_turbo_table, "Selects the
> > frequency table (0 = run table
> >     ((HT) ? CCLKCFG_HALFTURBO : 0) | \
> >     ((T)  ? CCLKCFG_TURBO : 0))
> > 
> > -static pxa_freqs_t pxa27x_freqs[] = {
> > +static struct pxa_freqs pxa27x_freqs[] = {
> >     {104000, 104000, PXA27x_CCCR(1,  8, 2), 0, CCLKCFG2(1, 0, 1),  90,
> >1705000 },
> >     {156000, 104000, PXA27x_CCCR(1,  8, 3), 0, CCLKCFG2(1, 0, 1), 100,
> >1705000 },
> >     {208000, 208000, PXA27x_CCCR(0, 16, 2), 1, CCLKCFG2(0, 0, 1), 118,
> >1705000 },
> > @@ -171,7 +171,7 @@ extern unsigned get_clk_frequency_khz(int info);
> > 
> >  #ifdef CONFIG_REGULATOR
> > 
> > -static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
> > +static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
> >  {
> >     int ret = 0;
> >     int vmin, vmax;
> > @@ -202,7 +202,7 @@ static void __init pxa_cpufreq_init_voltages(void)
> >     }
> >  }
> >  #else
> > -static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
> > +static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
> >  {
> >     return 0;
> >  }
> > @@ -211,7 +211,7 @@ static void __init pxa_cpufreq_init_voltages(void) { }
> >  #endif
> > 
> >  static void find_freq_tables(struct cpufreq_frequency_table **freq_table,
> > -                        pxa_freqs_t **pxa_freqs)
> > +                        struct pxa_freqs **pxa_freqs)
> >  {
> >     if (cpu_is_pxa25x()) {
> >             if (!pxa255_turbo_table) {
> > @@ -270,7 +270,7 @@ static unsigned int pxa_cpufreq_get(unsigned int cpu)
> >  static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
> >  {
> >     struct cpufreq_frequency_table *pxa_freqs_table;
> > -   pxa_freqs_t *pxa_freq_settings;
> > +   struct pxa_freqs *pxa_freq_settings;
> >     unsigned long flags;
> >     unsigned int new_freq_cpu, new_freq_mem;
> >     unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
> > @@ -361,7 +361,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy
> > *policy)
> >     int i;
> >     unsigned int freq;
> >     struct cpufreq_frequency_table *pxa255_freq_table;
> > -   pxa_freqs_t *pxa255_freqs;
> > +   struct pxa_freqs *pxa255_freqs;
> > 
> >     /* try to guess pxa27x cpu */
> >     if (cpu_is_pxa27x())
> > --
> > 1.9.1
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majord...@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 linux-next] gfs2: convert simple_str to kstr

2015-04-30 Thread Fabian Frederick
-Remove obsolete simple_str functions.
-Return error code when kstr failed.
-This patch also calls functions corresponding to destination type.

Thanks to Alexey Dobriyan for suggesting improvements in
block_store() and wdack_store()

Signed-off-by: Fabian Frederick 
---
 fs/gfs2/sys.c | 69 ++-
 1 file changed, 49 insertions(+), 20 deletions(-)

diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index ae8e881..3a2de91 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -101,8 +101,11 @@ static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
 
 static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
-   int error;
-   int n = simple_strtol(buf, NULL, 0);
+   int error, n;
+
+   error = kstrtoint(buf, 0, );
+   if (error)
+   return error;
 
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
@@ -134,10 +137,16 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char 
*buf)
 
 static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t 
len)
 {
+   int error, val;
+
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   if (simple_strtol(buf, NULL, 0) != 1)
+   error = kstrtoint(buf, 0, );
+   if (error)
+   return error;
+
+   if (val != -1)
return -EINVAL;
 
gfs2_lm_withdraw(sdp, "withdrawing from cluster at user's request\n");
@@ -148,10 +157,16 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp, const 
char *buf, size_t len)
 static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
 size_t len)
 {
+   int error, val;
+
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   if (simple_strtol(buf, NULL, 0) != 1)
+   error = kstrtoint(buf, 0, );
+   if (error)
+   return error;
+
+   if (val != -1)
return -EINVAL;
 
gfs2_statfs_sync(sdp->sd_vfs, 0);
@@ -161,10 +176,16 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, 
const char *buf,
 static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
size_t len)
 {
+   int error, val;
+
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   if (simple_strtol(buf, NULL, 0) != 1)
+   error = kstrtoint(buf, 0, );
+   if (error)
+   return error;
+
+   if (val != -1)
return -EINVAL;
 
gfs2_quota_sync(sdp->sd_vfs, 0);
@@ -181,7 +202,9 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd 
*sdp, const char *buf,
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   id = simple_strtoul(buf, NULL, 0);
+   error = kstrtou32(buf, 0, );
+   if (error)
+   return error;
 
qid = make_kqid(current_user_ns(), USRQUOTA, id);
if (!qid_valid(qid))
@@ -201,7 +224,9 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd 
*sdp, const char *buf,
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   id = simple_strtoul(buf, NULL, 0);
+   error = kstrtou32(buf, 0, );
+   if (error)
+   return error;
 
qid = make_kqid(current_user_ns(), GRPQUOTA, id);
if (!qid_valid(qid))
@@ -324,10 +349,11 @@ static ssize_t block_show(struct gfs2_sbd *sdp, char *buf)
 static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
struct lm_lockstruct *ls = >sd_lockstruct;
-   ssize_t ret = len;
-   int val;
+   int ret, val;
 
-   val = simple_strtol(buf, NULL, 0);
+   ret = kstrtoint(buf, 0, );
+   if (ret)
+   return ret;
 
if (val == 1)
set_bit(DFL_BLOCK_LOCKS, >ls_recover_flags);
@@ -335,10 +361,9 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const 
char *buf, size_t len)
clear_bit(DFL_BLOCK_LOCKS, >ls_recover_flags);
smp_mb__after_atomic();
gfs2_glock_thaw(sdp);
-   } else {
-   ret = -EINVAL;
-   }
-   return ret;
+   } else
+   return -EINVAL;
+   return len;
 }
 
 static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf)
@@ -350,17 +375,18 @@ static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf)
 
 static ssize_t wdack_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
-   ssize_t ret = len;
-   int val;
+   int ret, val;
 
-   val = simple_strtol(buf, NULL, 0);
+   ret = kstrtoint(buf, 0, );
+   if (ret)
+   return ret;
 
if ((val == 1) &&
!strcmp(sdp->sd_lockstruct.ls_ops->lm_proto_name, "lock_dlm"))
complete(>sd_wdack);
else
-   ret = -EINVAL;
-   return ret;
+   return -EINVAL;
+   return len;
 }
 
 static ssize_t lkfirst_show(struct gfs2_sbd *

Re: [PATCH V2 linux-next] cpufreq: pxa: replace typedef pxa_freqs_t by structure

2015-04-30 Thread Fabian Frederick


 On 30 April 2015 at 06:46 Joe Perches j...@perches.com wrote:


 On Wed, 2015-04-29 at 21:32 +0200, Fabian Frederick wrote:
  typedef is not really useful here. Replace it by structure
  to improve readability.typedef should only be used in some cases.
  (See Documentation/CodingStyle Chapter 5 for details).

 trivia:

  diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c
  b/drivers/cpufreq/pxa2xx-cpufreq.c
 []
  @@ -86,7 +86,7 @@ static unsigned int sdram_rows;
   /* Use the run mode frequencies for the CPUFREQ_POLICY_PERFORMANCE policy
 */
   #define CCLKCFG                    CCLKCFG_TURBO | CCLKCFG_FCS
  
  -static pxa_freqs_t pxa255_run_freqs[] =
  +static struct pxa_freqs pxa255_run_freqs[] =

 Should these be const?

AFAICS yes but this needs some fixes:
drivers/cpufreq/pxa2xx-cpufreq.c: In function 'find_freq_tables':
drivers/cpufreq/pxa2xx-cpufreq.c:218:15: warning: assignment discards 'const'
qualifier from pointer target type
    *pxa_freqs = pxa255_run_freqs;
               ^
Maybe another patch ?

Regards,
Fabian

   {
      /* CPU   MEMBUS  CCCR  DIV2 CCLKCFG                run  turbo PXbus
 SDRAM */
      { 99500,  99500, 0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50, 
  50  */
  @@ -98,7 +98,7 @@ static pxa_freqs_t pxa255_run_freqs[] =
   };
  
   /* Use the turbo mode frequencies for the CPUFREQ_POLICY_POWERSAVE policy
 */
  -static pxa_freqs_t pxa255_turbo_freqs[] =
  +static struct pxa_freqs pxa255_turbo_freqs[] =
   {
      /* CPU   MEMBUS  CCCR  DIV2 CCLKCFG        run  turbo PXbus SDRAM */
      { 99500, 99500,  0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50, 
  50  */
  @@ -153,7 +153,7 @@ MODULE_PARM_DESC(pxa255_turbo_table, Selects the
  frequency table (0 = run table
      ((HT) ? CCLKCFG_HALFTURBO : 0) | \
      ((T)  ? CCLKCFG_TURBO : 0))
  
  -static pxa_freqs_t pxa27x_freqs[] = {
  +static struct pxa_freqs pxa27x_freqs[] = {
      {104000, 104000, PXA27x_CCCR(1,  8, 2), 0, CCLKCFG2(1, 0, 1),  90,
 1705000 },
      {156000, 104000, PXA27x_CCCR(1,  8, 3), 0, CCLKCFG2(1, 0, 1), 100,
 1705000 },
      {208000, 208000, PXA27x_CCCR(0, 16, 2), 1, CCLKCFG2(0, 0, 1), 118,
 1705000 },
  @@ -171,7 +171,7 @@ extern unsigned get_clk_frequency_khz(int info);
  
   #ifdef CONFIG_REGULATOR
  
  -static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
  +static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
   {
      int ret = 0;
      int vmin, vmax;
  @@ -202,7 +202,7 @@ static void __init pxa_cpufreq_init_voltages(void)
      }
   }
   #else
  -static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
  +static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
   {
      return 0;
   }
  @@ -211,7 +211,7 @@ static void __init pxa_cpufreq_init_voltages(void) { }
   #endif
  
   static void find_freq_tables(struct cpufreq_frequency_table **freq_table,
  -                        pxa_freqs_t **pxa_freqs)
  +                        struct pxa_freqs **pxa_freqs)
   {
      if (cpu_is_pxa25x()) {
              if (!pxa255_turbo_table) {
  @@ -270,7 +270,7 @@ static unsigned int pxa_cpufreq_get(unsigned int cpu)
   static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
   {
      struct cpufreq_frequency_table *pxa_freqs_table;
  -   pxa_freqs_t *pxa_freq_settings;
  +   struct pxa_freqs *pxa_freq_settings;
      unsigned long flags;
      unsigned int new_freq_cpu, new_freq_mem;
      unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
  @@ -361,7 +361,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy
  *policy)
      int i;
      unsigned int freq;
      struct cpufreq_frequency_table *pxa255_freq_table;
  -   pxa_freqs_t *pxa255_freqs;
  +   struct pxa_freqs *pxa255_freqs;
  
      /* try to guess pxa27x cpu */
      if (cpu_is_pxa27x())
  --
  1.9.1
 
  --
  To unsubscribe from this list: send the line unsubscribe linux-kernel in
  the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
  Please read the FAQ at  http://www.tux.org/lkml/



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 linux-next] gfs2: convert simple_str to kstr

2015-04-30 Thread Fabian Frederick
-Remove obsolete simple_str functions.
-Return error code when kstr failed.
-This patch also calls functions corresponding to destination type.

Thanks to Alexey Dobriyan for suggesting improvements in
block_store() and wdack_store()

Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/gfs2/sys.c | 69 ++-
 1 file changed, 49 insertions(+), 20 deletions(-)

diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index ae8e881..3a2de91 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -101,8 +101,11 @@ static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
 
 static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
-   int error;
-   int n = simple_strtol(buf, NULL, 0);
+   int error, n;
+
+   error = kstrtoint(buf, 0, n);
+   if (error)
+   return error;
 
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
@@ -134,10 +137,16 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char 
*buf)
 
 static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t 
len)
 {
+   int error, val;
+
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   if (simple_strtol(buf, NULL, 0) != 1)
+   error = kstrtoint(buf, 0, val);
+   if (error)
+   return error;
+
+   if (val != -1)
return -EINVAL;
 
gfs2_lm_withdraw(sdp, withdrawing from cluster at user's request\n);
@@ -148,10 +157,16 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp, const 
char *buf, size_t len)
 static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
 size_t len)
 {
+   int error, val;
+
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   if (simple_strtol(buf, NULL, 0) != 1)
+   error = kstrtoint(buf, 0, val);
+   if (error)
+   return error;
+
+   if (val != -1)
return -EINVAL;
 
gfs2_statfs_sync(sdp-sd_vfs, 0);
@@ -161,10 +176,16 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, 
const char *buf,
 static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
size_t len)
 {
+   int error, val;
+
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   if (simple_strtol(buf, NULL, 0) != 1)
+   error = kstrtoint(buf, 0, val);
+   if (error)
+   return error;
+
+   if (val != -1)
return -EINVAL;
 
gfs2_quota_sync(sdp-sd_vfs, 0);
@@ -181,7 +202,9 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd 
*sdp, const char *buf,
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   id = simple_strtoul(buf, NULL, 0);
+   error = kstrtou32(buf, 0, id);
+   if (error)
+   return error;
 
qid = make_kqid(current_user_ns(), USRQUOTA, id);
if (!qid_valid(qid))
@@ -201,7 +224,9 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd 
*sdp, const char *buf,
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   id = simple_strtoul(buf, NULL, 0);
+   error = kstrtou32(buf, 0, id);
+   if (error)
+   return error;
 
qid = make_kqid(current_user_ns(), GRPQUOTA, id);
if (!qid_valid(qid))
@@ -324,10 +349,11 @@ static ssize_t block_show(struct gfs2_sbd *sdp, char *buf)
 static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
struct lm_lockstruct *ls = sdp-sd_lockstruct;
-   ssize_t ret = len;
-   int val;
+   int ret, val;
 
-   val = simple_strtol(buf, NULL, 0);
+   ret = kstrtoint(buf, 0, val);
+   if (ret)
+   return ret;
 
if (val == 1)
set_bit(DFL_BLOCK_LOCKS, ls-ls_recover_flags);
@@ -335,10 +361,9 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const 
char *buf, size_t len)
clear_bit(DFL_BLOCK_LOCKS, ls-ls_recover_flags);
smp_mb__after_atomic();
gfs2_glock_thaw(sdp);
-   } else {
-   ret = -EINVAL;
-   }
-   return ret;
+   } else
+   return -EINVAL;
+   return len;
 }
 
 static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf)
@@ -350,17 +375,18 @@ static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf)
 
 static ssize_t wdack_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
-   ssize_t ret = len;
-   int val;
+   int ret, val;
 
-   val = simple_strtol(buf, NULL, 0);
+   ret = kstrtoint(buf, 0, val);
+   if (ret)
+   return ret;
 
if ((val == 1) 
!strcmp(sdp-sd_lockstruct.ls_ops-lm_proto_name, lock_dlm))
complete(sdp-sd_wdack);
else
-   ret = -EINVAL;
-   return ret;
+   return -EINVAL;
+   return len;
 }
 
 static ssize_t lkfirst_show(struct gfs2_sbd *sdp, char *buf

Re: [PATCH 1/1 linux-next] exofs: convert simple_str to kstr

2015-04-30 Thread Fabian Frederick


 On 30 April 2015 at 09:55 Boaz Harrosh o...@electrozaur.com wrote:


 On 04/29/2015 08:58 PM, Fabian Frederick wrote:
  replace obsolete function.
 
  Signed-off-by: Fabian Frederick f...@skynet.be

 Thanks.
 ACK-by: Boaz Harrosh o...@electrozaur.com

 Are you pushing all these through some tree, or
 You need that I push it? Maybe push all these changes
 through some central place, like Andrew's tree?

Thanks Boaz, I don't use any tree ; I could forward this patch to Andrew but I
guess you
prefer Alexey's solution which uses parse_integer() instead of
match_strlcpy() ?

http://marc.info/?l=linux-kernelm=143039354303440w=2

Regards,
Fabian


 Boaz

  ---
  This is untested.
 
   fs/exofs/super.c | 8 +++-
   1 file changed, 7 insertions(+), 1 deletion(-)
 
  diff --git a/fs/exofs/super.c b/fs/exofs/super.c
  index b795c56..b667f73 100644
  --- a/fs/exofs/super.c
  +++ b/fs/exofs/super.c
  @@ -108,9 +108,14 @@ static int parse_options(char *options, struct
  exofs_mountopt *opts)
                      opts-is_osdname = true;
                      break;
              case Opt_pid:
  +           {
  +                   int rc;
  +
                      if (0 == match_strlcpy(str, args[0], sizeof(str)))
                              return -EINVAL;
  -                   opts-pid = simple_strtoull(str, NULL, 0);
  +                   rc = kstrtoull(str, 0, opts-pid);
  +                   if (rc)
  +                           return rc;
                      if (opts-pid  EXOFS_MIN_PID) {
                              EXOFS_ERR(Partition ID must be = %u,
                                        EXOFS_MIN_PID);
  @@ -118,6 +123,7 @@ static int parse_options(char *options, struct
  exofs_mountopt *opts)
                      }
                      s_pid = 1;
                      break;
  +           }
              case Opt_to:
                      if (match_int(args[0], option))
                              return -EINVAL;
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 linux-next] cpufreq: pxa: replace typedef pxa_freqs_t by structure

2015-04-29 Thread Fabian Frederick
typedef is not really useful here. Replace it by structure
to improve readability.typedef should only be used in some cases.
(See Documentation/CodingStyle Chapter 5 for details).

Signed-off-by: Fabian Frederick 
---
V2: verbose changelog.

 drivers/cpufreq/pxa2xx-cpufreq.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index e24269a..fcf6e34 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -56,7 +56,7 @@ module_param(pxa27x_maxfreq, uint, 0);
 MODULE_PARM_DESC(pxa27x_maxfreq, "Set the pxa27x maxfreq in MHz"
 "(typically 624=>pxa270, 416=>pxa271, 520=>pxa272)");
 
-typedef struct {
+struct pxa_freqs {
unsigned int khz;
unsigned int membus;
unsigned int cccr;
@@ -64,7 +64,7 @@ typedef struct {
unsigned int cclkcfg;
int vmin;
int vmax;
-} pxa_freqs_t;
+};
 
 /* Define the refresh period in mSec for the SDRAM and the number of rows */
 #define SDRAM_TREF 64  /* standard 64ms SDRAM */
@@ -86,7 +86,7 @@ static unsigned int sdram_rows;
 /* Use the run mode frequencies for the CPUFREQ_POLICY_PERFORMANCE policy */
 #define CCLKCFGCCLKCFG_TURBO | CCLKCFG_FCS
 
-static pxa_freqs_t pxa255_run_freqs[] =
+static struct pxa_freqs pxa255_run_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus 
SDRAM */
{ 99500,  99500, 0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -98,7 +98,7 @@ static pxa_freqs_t pxa255_run_freqs[] =
 };
 
 /* Use the turbo mode frequencies for the CPUFREQ_POLICY_POWERSAVE policy */
-static pxa_freqs_t pxa255_turbo_freqs[] =
+static struct pxa_freqs pxa255_turbo_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus SDRAM */
{ 99500, 99500,  0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -153,7 +153,7 @@ MODULE_PARM_DESC(pxa255_turbo_table, "Selects the frequency 
table (0 = run table
((HT) ? CCLKCFG_HALFTURBO : 0) | \
((T)  ? CCLKCFG_TURBO : 0))
 
-static pxa_freqs_t pxa27x_freqs[] = {
+static struct pxa_freqs pxa27x_freqs[] = {
{104000, 104000, PXA27x_CCCR(1,  8, 2), 0, CCLKCFG2(1, 0, 1),  90, 
1705000 },
{156000, 104000, PXA27x_CCCR(1,  8, 3), 0, CCLKCFG2(1, 0, 1), 100, 
1705000 },
{208000, 208000, PXA27x_CCCR(0, 16, 2), 1, CCLKCFG2(0, 0, 1), 118, 
1705000 },
@@ -171,7 +171,7 @@ extern unsigned get_clk_frequency_khz(int info);
 
 #ifdef CONFIG_REGULATOR
 
-static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
+static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
 {
int ret = 0;
int vmin, vmax;
@@ -202,7 +202,7 @@ static void __init pxa_cpufreq_init_voltages(void)
}
 }
 #else
-static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
+static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
 {
return 0;
 }
@@ -211,7 +211,7 @@ static void __init pxa_cpufreq_init_voltages(void) { }
 #endif
 
 static void find_freq_tables(struct cpufreq_frequency_table **freq_table,
-pxa_freqs_t **pxa_freqs)
+struct pxa_freqs **pxa_freqs)
 {
if (cpu_is_pxa25x()) {
if (!pxa255_turbo_table) {
@@ -270,7 +270,7 @@ static unsigned int pxa_cpufreq_get(unsigned int cpu)
 static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 {
struct cpufreq_frequency_table *pxa_freqs_table;
-   pxa_freqs_t *pxa_freq_settings;
+   struct pxa_freqs *pxa_freq_settings;
unsigned long flags;
unsigned int new_freq_cpu, new_freq_mem;
unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
@@ -361,7 +361,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
int i;
unsigned int freq;
struct cpufreq_frequency_table *pxa255_freq_table;
-   pxa_freqs_t *pxa255_freqs;
+   struct pxa_freqs *pxa255_freqs;
 
/* try to guess pxa27x cpu */
if (cpu_is_pxa27x())
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] iommu/msm: make msm_iommu_lock static

2015-04-29 Thread Fabian Frederick
msm_iommu_lock is only used in msm_iommu.c

Signed-off-by: Fabian Frederick 
---
 drivers/iommu/msm_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
index 15a2063..f2a6321 100644
--- a/drivers/iommu/msm_iommu.c
+++ b/drivers/iommu/msm_iommu.c
@@ -47,7 +47,7 @@ __asm__ __volatile__ (
\
 
 static int msm_iommu_tex_class[4];
 
-DEFINE_SPINLOCK(msm_iommu_lock);
+static DEFINE_SPINLOCK(msm_iommu_lock);
 
 struct msm_priv {
unsigned long *pgtable;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC 1/1 linux-next] gfs2: convert simple_str to kstr

2015-04-29 Thread Fabian Frederick
-Remove obsolete simple_str functions.
-Return error code when kstr failed.
-This patch also calls functions corresponding to destination type.

Basically it's an RFC because of the type mismatch all over the place.
ie code was doing simple_strtol to integer...
Newer kstr functions detect such problems.
By default I used destination type as a reference. Maybe it's wrong and we
really want to read long, unsigned long from source ?

Signed-off-by: Fabian Frederick 
---
 fs/gfs2/sys.c | 56 
 1 file changed, 44 insertions(+), 12 deletions(-)

diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index ae8e881..436bdeb 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -101,8 +101,11 @@ static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
 
 static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
-   int error;
-   int n = simple_strtol(buf, NULL, 0);
+   int error, n;
+
+   error = kstrtoint(buf, 0, );
+   if (error)
+   return error;
 
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
@@ -134,10 +137,16 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char 
*buf)
 
 static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t 
len)
 {
+   int error, val;
+
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   if (simple_strtol(buf, NULL, 0) != 1)
+   error = kstrtoint(buf, 0, );
+   if (error)
+   return error;
+
+   if (val != -1)
return -EINVAL;
 
gfs2_lm_withdraw(sdp, "withdrawing from cluster at user's request\n");
@@ -148,10 +157,16 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp, const 
char *buf, size_t len)
 static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
 size_t len)
 {
+   int error, val;
+
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   if (simple_strtol(buf, NULL, 0) != 1)
+   error = kstrtoint(buf, 0, );
+   if (error)
+   return error;
+
+   if (val != -1)
return -EINVAL;
 
gfs2_statfs_sync(sdp->sd_vfs, 0);
@@ -161,10 +176,16 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, 
const char *buf,
 static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
size_t len)
 {
+   int error, val;
+
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   if (simple_strtol(buf, NULL, 0) != 1)
+   error = kstrtoint(buf, 0, );
+   if (error)
+   return error;
+
+   if (val != -1)
return -EINVAL;
 
gfs2_quota_sync(sdp->sd_vfs, 0);
@@ -181,7 +202,9 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd 
*sdp, const char *buf,
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   id = simple_strtoul(buf, NULL, 0);
+   error = kstrtou32(buf, 0, );
+   if (error)
+   return error;
 
qid = make_kqid(current_user_ns(), USRQUOTA, id);
if (!qid_valid(qid))
@@ -201,7 +224,9 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd 
*sdp, const char *buf,
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   id = simple_strtoul(buf, NULL, 0);
+   error = kstrtou32(buf, 0, );
+   if (error)
+   return error;
 
qid = make_kqid(current_user_ns(), GRPQUOTA, id);
if (!qid_valid(qid))
@@ -325,9 +350,11 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const 
char *buf, size_t len)
 {
struct lm_lockstruct *ls = >sd_lockstruct;
ssize_t ret = len;
-   int val;
+   int val, error;
 
-   val = simple_strtol(buf, NULL, 0);
+   error = kstrtoint(buf, 0, );
+   if (error)
+   return error;
 
if (val == 1)
set_bit(DFL_BLOCK_LOCKS, >ls_recover_flags);
@@ -351,9 +378,11 @@ static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf)
 static ssize_t wdack_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
ssize_t ret = len;
-   int val;
+   int val, error;
 
-   val = simple_strtol(buf, NULL, 0);
+   error = kstrtoint(buf, 0, );
+   if (error)
+   return error;
 
if ((val == 1) &&
!strcmp(sdp->sd_lockstruct.ls_ops->lm_proto_name, "lock_dlm"))
@@ -553,11 +582,14 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned 
int *field,
 {
struct gfs2_tune *gt = >sd_tune;
unsigned int x;
+   int error;
 
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   x = simple_strtoul(buf, NULL, 0);
+   error = kstrtouint(buf, 0, );
+   if (error)
+   return error;
 
if (check_zero && !x)
return -EINVAL;
-- 
1.9.1

--
To unsubscribe from this list: send the

[PATCH 1/1 linux-next] bnx2fc: make bnx2fc_global_lock static

2015-04-29 Thread Fabian Frederick
bnx2fc_global_lock is only used in bnx2fc_fcoe.c

Signed-off-by: Fabian Frederick 
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 98d06d1..66fb527 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -49,7 +49,7 @@ struct workqueue_struct *bnx2fc_wq;
  * Here the io threads are per cpu but the l2 thread is just one
  */
 struct fcoe_percpu_s bnx2fc_global;
-DEFINE_SPINLOCK(bnx2fc_global_lock);
+static DEFINE_SPINLOCK(bnx2fc_global_lock);
 
 static struct cnic_ulp_ops bnx2fc_cnic_cb;
 static struct libfc_function_template bnx2fc_libfc_fcn_templ;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] exofs: convert simple_str to kstr

2015-04-29 Thread Fabian Frederick
replace obsolete function.

Signed-off-by: Fabian Frederick 
---
This is untested.

 fs/exofs/super.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/exofs/super.c b/fs/exofs/super.c
index b795c56..b667f73 100644
--- a/fs/exofs/super.c
+++ b/fs/exofs/super.c
@@ -108,9 +108,14 @@ static int parse_options(char *options, struct 
exofs_mountopt *opts)
opts->is_osdname = true;
break;
case Opt_pid:
+   {
+   int rc;
+
if (0 == match_strlcpy(str, [0], sizeof(str)))
return -EINVAL;
-   opts->pid = simple_strtoull(str, NULL, 0);
+   rc = kstrtoull(str, 0, >pid);
+   if (rc)
+   return rc;
if (opts->pid < EXOFS_MIN_PID) {
EXOFS_ERR("Partition ID must be >= %u",
  EXOFS_MIN_PID);
@@ -118,6 +123,7 @@ static int parse_options(char *options, struct 
exofs_mountopt *opts)
}
s_pid = 1;
break;
+   }
case Opt_to:
if (match_int([0], ))
return -EINVAL;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] configfs: unexport/make static config_item_init()

2015-04-29 Thread Fabian Frederick
config_item_init() is only used in item.c

Signed-off-by: Fabian Frederick 
---
 fs/configfs/item.c   | 3 +--
 include/linux/configfs.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/configfs/item.c b/fs/configfs/item.c
index e65f9ff..4d6a30e 100644
--- a/fs/configfs/item.c
+++ b/fs/configfs/item.c
@@ -47,12 +47,11 @@ static void config_item_release(struct kref *kref);
  * config_item_init - initialize item.
  * @item:  item in question.
  */
-void config_item_init(struct config_item *item)
+static void config_item_init(struct config_item *item)
 {
kref_init(>ci_kref);
INIT_LIST_HEAD(>ci_entry);
 }
-EXPORT_SYMBOL(config_item_init);
 
 /**
  * config_item_set_name - Set the name of an item
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 34025df..c9e5c57 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -71,7 +71,6 @@ static inline char *config_item_name(struct config_item * 
item)
return item->ci_name;
 }
 
-extern void config_item_init(struct config_item *);
 extern void config_item_init_type_name(struct config_item *item,
   const char *name,
   struct config_item_type *type);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] configfs: unexport/make static config_item_init()

2015-04-29 Thread Fabian Frederick
config_item_init() is only used in item.c

Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/configfs/item.c   | 3 +--
 include/linux/configfs.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/configfs/item.c b/fs/configfs/item.c
index e65f9ff..4d6a30e 100644
--- a/fs/configfs/item.c
+++ b/fs/configfs/item.c
@@ -47,12 +47,11 @@ static void config_item_release(struct kref *kref);
  * config_item_init - initialize item.
  * @item:  item in question.
  */
-void config_item_init(struct config_item *item)
+static void config_item_init(struct config_item *item)
 {
kref_init(item-ci_kref);
INIT_LIST_HEAD(item-ci_entry);
 }
-EXPORT_SYMBOL(config_item_init);
 
 /**
  * config_item_set_name - Set the name of an item
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 34025df..c9e5c57 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -71,7 +71,6 @@ static inline char *config_item_name(struct config_item * 
item)
return item-ci_name;
 }
 
-extern void config_item_init(struct config_item *);
 extern void config_item_init_type_name(struct config_item *item,
   const char *name,
   struct config_item_type *type);
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 linux-next] cpufreq: pxa: replace typedef pxa_freqs_t by structure

2015-04-29 Thread Fabian Frederick
typedef is not really useful here. Replace it by structure
to improve readability.typedef should only be used in some cases.
(See Documentation/CodingStyle Chapter 5 for details).

Signed-off-by: Fabian Frederick f...@skynet.be
---
V2: verbose changelog.

 drivers/cpufreq/pxa2xx-cpufreq.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index e24269a..fcf6e34 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -56,7 +56,7 @@ module_param(pxa27x_maxfreq, uint, 0);
 MODULE_PARM_DESC(pxa27x_maxfreq, Set the pxa27x maxfreq in MHz
 (typically 624=pxa270, 416=pxa271, 520=pxa272));
 
-typedef struct {
+struct pxa_freqs {
unsigned int khz;
unsigned int membus;
unsigned int cccr;
@@ -64,7 +64,7 @@ typedef struct {
unsigned int cclkcfg;
int vmin;
int vmax;
-} pxa_freqs_t;
+};
 
 /* Define the refresh period in mSec for the SDRAM and the number of rows */
 #define SDRAM_TREF 64  /* standard 64ms SDRAM */
@@ -86,7 +86,7 @@ static unsigned int sdram_rows;
 /* Use the run mode frequencies for the CPUFREQ_POLICY_PERFORMANCE policy */
 #define CCLKCFGCCLKCFG_TURBO | CCLKCFG_FCS
 
-static pxa_freqs_t pxa255_run_freqs[] =
+static struct pxa_freqs pxa255_run_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus 
SDRAM */
{ 99500,  99500, 0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -98,7 +98,7 @@ static pxa_freqs_t pxa255_run_freqs[] =
 };
 
 /* Use the turbo mode frequencies for the CPUFREQ_POLICY_POWERSAVE policy */
-static pxa_freqs_t pxa255_turbo_freqs[] =
+static struct pxa_freqs pxa255_turbo_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus SDRAM */
{ 99500, 99500,  0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -153,7 +153,7 @@ MODULE_PARM_DESC(pxa255_turbo_table, Selects the frequency 
table (0 = run table
((HT) ? CCLKCFG_HALFTURBO : 0) | \
((T)  ? CCLKCFG_TURBO : 0))
 
-static pxa_freqs_t pxa27x_freqs[] = {
+static struct pxa_freqs pxa27x_freqs[] = {
{104000, 104000, PXA27x_CCCR(1,  8, 2), 0, CCLKCFG2(1, 0, 1),  90, 
1705000 },
{156000, 104000, PXA27x_CCCR(1,  8, 3), 0, CCLKCFG2(1, 0, 1), 100, 
1705000 },
{208000, 208000, PXA27x_CCCR(0, 16, 2), 1, CCLKCFG2(0, 0, 1), 118, 
1705000 },
@@ -171,7 +171,7 @@ extern unsigned get_clk_frequency_khz(int info);
 
 #ifdef CONFIG_REGULATOR
 
-static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
+static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
 {
int ret = 0;
int vmin, vmax;
@@ -202,7 +202,7 @@ static void __init pxa_cpufreq_init_voltages(void)
}
 }
 #else
-static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
+static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
 {
return 0;
 }
@@ -211,7 +211,7 @@ static void __init pxa_cpufreq_init_voltages(void) { }
 #endif
 
 static void find_freq_tables(struct cpufreq_frequency_table **freq_table,
-pxa_freqs_t **pxa_freqs)
+struct pxa_freqs **pxa_freqs)
 {
if (cpu_is_pxa25x()) {
if (!pxa255_turbo_table) {
@@ -270,7 +270,7 @@ static unsigned int pxa_cpufreq_get(unsigned int cpu)
 static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 {
struct cpufreq_frequency_table *pxa_freqs_table;
-   pxa_freqs_t *pxa_freq_settings;
+   struct pxa_freqs *pxa_freq_settings;
unsigned long flags;
unsigned int new_freq_cpu, new_freq_mem;
unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
@@ -361,7 +361,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
int i;
unsigned int freq;
struct cpufreq_frequency_table *pxa255_freq_table;
-   pxa_freqs_t *pxa255_freqs;
+   struct pxa_freqs *pxa255_freqs;
 
/* try to guess pxa27x cpu */
if (cpu_is_pxa27x())
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC 1/1 linux-next] gfs2: convert simple_str to kstr

2015-04-29 Thread Fabian Frederick
-Remove obsolete simple_str functions.
-Return error code when kstr failed.
-This patch also calls functions corresponding to destination type.

Basically it's an RFC because of the type mismatch all over the place.
ie code was doing simple_strtol to integer...
Newer kstr functions detect such problems.
By default I used destination type as a reference. Maybe it's wrong and we
really want to read long, unsigned long from source ?

Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/gfs2/sys.c | 56 
 1 file changed, 44 insertions(+), 12 deletions(-)

diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index ae8e881..436bdeb 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -101,8 +101,11 @@ static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
 
 static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
-   int error;
-   int n = simple_strtol(buf, NULL, 0);
+   int error, n;
+
+   error = kstrtoint(buf, 0, n);
+   if (error)
+   return error;
 
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
@@ -134,10 +137,16 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char 
*buf)
 
 static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t 
len)
 {
+   int error, val;
+
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   if (simple_strtol(buf, NULL, 0) != 1)
+   error = kstrtoint(buf, 0, val);
+   if (error)
+   return error;
+
+   if (val != -1)
return -EINVAL;
 
gfs2_lm_withdraw(sdp, withdrawing from cluster at user's request\n);
@@ -148,10 +157,16 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp, const 
char *buf, size_t len)
 static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
 size_t len)
 {
+   int error, val;
+
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   if (simple_strtol(buf, NULL, 0) != 1)
+   error = kstrtoint(buf, 0, val);
+   if (error)
+   return error;
+
+   if (val != -1)
return -EINVAL;
 
gfs2_statfs_sync(sdp-sd_vfs, 0);
@@ -161,10 +176,16 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, 
const char *buf,
 static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
size_t len)
 {
+   int error, val;
+
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   if (simple_strtol(buf, NULL, 0) != 1)
+   error = kstrtoint(buf, 0, val);
+   if (error)
+   return error;
+
+   if (val != -1)
return -EINVAL;
 
gfs2_quota_sync(sdp-sd_vfs, 0);
@@ -181,7 +202,9 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd 
*sdp, const char *buf,
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   id = simple_strtoul(buf, NULL, 0);
+   error = kstrtou32(buf, 0, id);
+   if (error)
+   return error;
 
qid = make_kqid(current_user_ns(), USRQUOTA, id);
if (!qid_valid(qid))
@@ -201,7 +224,9 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd 
*sdp, const char *buf,
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   id = simple_strtoul(buf, NULL, 0);
+   error = kstrtou32(buf, 0, id);
+   if (error)
+   return error;
 
qid = make_kqid(current_user_ns(), GRPQUOTA, id);
if (!qid_valid(qid))
@@ -325,9 +350,11 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const 
char *buf, size_t len)
 {
struct lm_lockstruct *ls = sdp-sd_lockstruct;
ssize_t ret = len;
-   int val;
+   int val, error;
 
-   val = simple_strtol(buf, NULL, 0);
+   error = kstrtoint(buf, 0, val);
+   if (error)
+   return error;
 
if (val == 1)
set_bit(DFL_BLOCK_LOCKS, ls-ls_recover_flags);
@@ -351,9 +378,11 @@ static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf)
 static ssize_t wdack_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
ssize_t ret = len;
-   int val;
+   int val, error;
 
-   val = simple_strtol(buf, NULL, 0);
+   error = kstrtoint(buf, 0, val);
+   if (error)
+   return error;
 
if ((val == 1) 
!strcmp(sdp-sd_lockstruct.ls_ops-lm_proto_name, lock_dlm))
@@ -553,11 +582,14 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned 
int *field,
 {
struct gfs2_tune *gt = sdp-sd_tune;
unsigned int x;
+   int error;
 
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   x = simple_strtoul(buf, NULL, 0);
+   error = kstrtouint(buf, 0, x);
+   if (error)
+   return error;
 
if (check_zero  !x)
return -EINVAL;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel

[PATCH 1/1 linux-next] iommu/msm: make msm_iommu_lock static

2015-04-29 Thread Fabian Frederick
msm_iommu_lock is only used in msm_iommu.c

Signed-off-by: Fabian Frederick f...@skynet.be
---
 drivers/iommu/msm_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
index 15a2063..f2a6321 100644
--- a/drivers/iommu/msm_iommu.c
+++ b/drivers/iommu/msm_iommu.c
@@ -47,7 +47,7 @@ __asm__ __volatile__ (
\
 
 static int msm_iommu_tex_class[4];
 
-DEFINE_SPINLOCK(msm_iommu_lock);
+static DEFINE_SPINLOCK(msm_iommu_lock);
 
 struct msm_priv {
unsigned long *pgtable;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] bnx2fc: make bnx2fc_global_lock static

2015-04-29 Thread Fabian Frederick
bnx2fc_global_lock is only used in bnx2fc_fcoe.c

Signed-off-by: Fabian Frederick f...@skynet.be
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 98d06d1..66fb527 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -49,7 +49,7 @@ struct workqueue_struct *bnx2fc_wq;
  * Here the io threads are per cpu but the l2 thread is just one
  */
 struct fcoe_percpu_s bnx2fc_global;
-DEFINE_SPINLOCK(bnx2fc_global_lock);
+static DEFINE_SPINLOCK(bnx2fc_global_lock);
 
 static struct cnic_ulp_ops bnx2fc_cnic_cb;
 static struct libfc_function_template bnx2fc_libfc_fcn_templ;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] exofs: convert simple_str to kstr

2015-04-29 Thread Fabian Frederick
replace obsolete function.

Signed-off-by: Fabian Frederick f...@skynet.be
---
This is untested.

 fs/exofs/super.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/exofs/super.c b/fs/exofs/super.c
index b795c56..b667f73 100644
--- a/fs/exofs/super.c
+++ b/fs/exofs/super.c
@@ -108,9 +108,14 @@ static int parse_options(char *options, struct 
exofs_mountopt *opts)
opts-is_osdname = true;
break;
case Opt_pid:
+   {
+   int rc;
+
if (0 == match_strlcpy(str, args[0], sizeof(str)))
return -EINVAL;
-   opts-pid = simple_strtoull(str, NULL, 0);
+   rc = kstrtoull(str, 0, opts-pid);
+   if (rc)
+   return rc;
if (opts-pid  EXOFS_MIN_PID) {
EXOFS_ERR(Partition ID must be = %u,
  EXOFS_MIN_PID);
@@ -118,6 +123,7 @@ static int parse_options(char *options, struct 
exofs_mountopt *opts)
}
s_pid = 1;
break;
+   }
case Opt_to:
if (match_int(args[0], option))
return -EINVAL;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: revert "fs/befs/linuxvfs.c: replace strncpy by strlcpy"

2015-04-28 Thread Fabian Frederick


> On 28 April 2015 at 19:39 Al Viro  wrote:
>
>
> On Tue, Apr 28, 2015 at 06:42:10PM +0200, Fabian Frederick wrote:
> >
> >
> > > On 28 April 2015 at 18:05 Al Viro  wrote:
> > >
> > >
> > > On Tue, Apr 28, 2015 at 07:35:10AM +0200, Fabian Frederick wrote:
> > >
> > > > > Al, very unhappy about the prospect of looking through ~2000 calls of
> > > > > strlcpy()
> > > > > we have in the tree...
> > > >
> > > > Sorry Al, I thought it was more secure.
> > >
> > > It's not just you, unfortunately, and dumping all that annoyance on you
> > > as a proxy for everyone who does that kind of thing had been unfair.
> > > My apologies...
> >
> > No problem Al :) but why can't we harden strlcpy at first with
> > something like a strlen limited to max char.
> > (I don't know if it's already in kernel libs).
> >
> > size_t strlenl(const char *s, size_t maxlen)
>
> aka strnlen()
>
> >         const char *sc = s;
> >         size_t i = 0;
> >
> >         while (*sc != '\0' && (i < maxlen)) {
> >                 i++;
> >                 sc++;
> >         }
> >         return sc - s;
> > }
> >
> > Then we could solve problems downstream ...
>
> Can't.  Seriously, look what strlcpy() is supposed to return; it's pretty
> much a microoptimized snprintf(dst, size, "%s", src).  It's certainly
> been patterned after snprintf(3) - "don't exceed that size, NUL-terminate
> unless the size is zero, return the number of characters (excluding NUL)
> that would've been written if the size had been large enough".
>
> The following is a legitimate use of strlcpy():
>
> int foo(char *);      /* modifies string */
>
> int const_foo(const char *s)
> {
>       int res;
>       char buf[32], *p = buf;
>       size_t wanted = strlcpy(buf, sizeof(buf), s);
>       if (wanted >= sizeof(buf)) {
>               p = malloc(wanted + 1);
>               if (!p)
>                       return -ENOMEM;
>               memcpy(p, s, wanted + 1);
>       }
>       res = foo(p);
>       if (p != buf)
>               free(p);
>       return res;
> }
>
> None of the kernel callers are of exactly that form (and most ignore the
> return value completely), but if we make that sucker return something
> different from what strlcpy(3) would return, we'd damn better _not_ keep
> the name; there's enough confusion in that area as it is.
Of course with another function name. There's no other way to do it ...
strlncpy/strlncat ? :)

Regards,
Fabian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: revert "fs/befs/linuxvfs.c: replace strncpy by strlcpy"

2015-04-28 Thread Fabian Frederick


> On 28 April 2015 at 18:05 Al Viro  wrote:
>
>
> On Tue, Apr 28, 2015 at 07:35:10AM +0200, Fabian Frederick wrote:
>
> > > Al, very unhappy about the prospect of looking through ~2000 calls of
> > > strlcpy()
> > > we have in the tree...
> >
> > Sorry Al, I thought it was more secure.
>
> It's not just you, unfortunately, and dumping all that annoyance on you
> as a proxy for everyone who does that kind of thing had been unfair.
> My apologies...

No problem Al :) but why can't we harden strlcpy at first with
something like a strlen limited to max char.
(I don't know if it's already in kernel libs).

size_t strlenl(const char *s, size_t maxlen)
{
        const char *sc = s;
        size_t i = 0;

        while (*sc != '\0' && (i < maxlen)) {
                i++;
                sc++;
        }
        return sc - s;
}

Then we could solve problems downstream ...

Regards,
Fabian

>
> > I guess the 2 following patches should be reversed as well :
> >
> > 6cb103b6f45a
> > "fs/befs/btree.c: replace strncpy by strlcpy + coding style fixing"
> >
> > 69201bb11327
> > "fs/ocfs2/super.c: use OCFS2_MAX_VOL_LABEL_LEN and strlcpy"
>
> AFAICS, they should.
>
> Unfortunately, we _can't_ make strlcpy() never look past src + size - 1 -
> not without changing its semantics.  Its callers expect it to return
> the length of source; one of the intended uses is
>       wanted = strlcpy(dst, src, dst_size);
>       if (wanted >= dst_size) {
>               p = realloc(dst, wanted + 1);
>               if (!p) {
>                       // too bad
>               } else {
>                       dst = p;
>                       memcpy(dst, src, wanted + 1);
>               }
>       }
> and that really wants the accurate length.  Now, the absolute majority of
> strlcpy() users in the kernel completely ignore the return value, i.e. go for
> silent truncation.  About 1% do not.
>
> Out of those, some are correctly implemented "fail if truncated" uses.
> The rest...  Some are weirdly open-coded snprintf() (series of strlcpy and
> strlcat) and some are _very_ dubious.  Either they really never get
> truncated, or we have a problem.  For example, this
> kernel/module.c:2349:                 s += strlcpy(s,
> >strtab[src[i].st_name],
> smells really bad.  We are truncating a bunch of strings dowsn to
> KSYM_NAME_LEN
> there and storing them in a buffer, with spacing that matches _untruncated_
> strings.
>
> drivers/s390/scsi/zfcp_fc.c:825:      len = strlcpy(rspn_req->rspn.fr_name,
> fc_host_symbolic_name(shost),
> also looks fishy - what happens there is
>         len = strlcpy(rspn_req->rspn.fr_name, fc_host_symbolic_name(shost),
>                       FC_SYMBOLIC_NAME_SIZE);
>         rspn_req->rspn.fr_name_len = len;
>
> drivers/usb/gadget/function/f_midi.c:976:     result = strlcpy(page, opts->id,
> PAGE_SIZE);
> drivers/usb/gadget/function/f_printer.c:1172: result = strlcpy(page,
> opts->pnp_string + 2, PNP_STRING_LEN - 2);
> drivers/usb/gadget/function/f_printer.c:1184: result =
> strlcpy(opts->pnp_string + 2, page, PNP_STRING_LEN - 2);
>
> are also strange...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: revert fs/befs/linuxvfs.c: replace strncpy by strlcpy

2015-04-28 Thread Fabian Frederick


 On 28 April 2015 at 18:05 Al Viro v...@zeniv.linux.org.uk wrote:


 On Tue, Apr 28, 2015 at 07:35:10AM +0200, Fabian Frederick wrote:

   Al, very unhappy about the prospect of looking through ~2000 calls of
   strlcpy()
   we have in the tree...
 
  Sorry Al, I thought it was more secure.

 It's not just you, unfortunately, and dumping all that annoyance on you
 as a proxy for everyone who does that kind of thing had been unfair.
 My apologies...

No problem Al :) but why can't we harden strlcpy at first with
something like a strlen limited to max char.
(I don't know if it's already in kernel libs).

size_t strlenl(const char *s, size_t maxlen)
{
        const char *sc = s;
        size_t i = 0;

        while (*sc != '\0'  (i  maxlen)) {
                i++;
                sc++;
        }
        return sc - s;
}

Then we could solve problems downstream ...

Regards,
Fabian


  I guess the 2 following patches should be reversed as well :
 
  6cb103b6f45a
  fs/befs/btree.c: replace strncpy by strlcpy + coding style fixing
 
  69201bb11327
  fs/ocfs2/super.c: use OCFS2_MAX_VOL_LABEL_LEN and strlcpy

 AFAICS, they should.

 Unfortunately, we _can't_ make strlcpy() never look past src + size - 1 -
 not without changing its semantics.  Its callers expect it to return
 the length of source; one of the intended uses is
       wanted = strlcpy(dst, src, dst_size);
       if (wanted = dst_size) {
               p = realloc(dst, wanted + 1);
               if (!p) {
                       // too bad
               } else {
                       dst = p;
                       memcpy(dst, src, wanted + 1);
               }
       }
 and that really wants the accurate length.  Now, the absolute majority of
 strlcpy() users in the kernel completely ignore the return value, i.e. go for
 silent truncation.  About 1% do not.

 Out of those, some are correctly implemented fail if truncated uses.
 The rest...  Some are weirdly open-coded snprintf() (series of strlcpy and
 strlcat) and some are _very_ dubious.  Either they really never get
 truncated, or we have a problem.  For example, this
 kernel/module.c:2349:                 s += strlcpy(s,
 mod-strtab[src[i].st_name],
 smells really bad.  We are truncating a bunch of strings dowsn to
 KSYM_NAME_LEN
 there and storing them in a buffer, with spacing that matches _untruncated_
 strings.

 drivers/s390/scsi/zfcp_fc.c:825:      len = strlcpy(rspn_req-rspn.fr_name,
 fc_host_symbolic_name(shost),
 also looks fishy - what happens there is
         len = strlcpy(rspn_req-rspn.fr_name, fc_host_symbolic_name(shost),
                       FC_SYMBOLIC_NAME_SIZE);
         rspn_req-rspn.fr_name_len = len;

 drivers/usb/gadget/function/f_midi.c:976:     result = strlcpy(page, opts-id,
 PAGE_SIZE);
 drivers/usb/gadget/function/f_printer.c:1172: result = strlcpy(page,
 opts-pnp_string + 2, PNP_STRING_LEN - 2);
 drivers/usb/gadget/function/f_printer.c:1184: result =
 strlcpy(opts-pnp_string + 2, page, PNP_STRING_LEN - 2);

 are also strange...
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: revert fs/befs/linuxvfs.c: replace strncpy by strlcpy

2015-04-28 Thread Fabian Frederick


 On 28 April 2015 at 19:39 Al Viro v...@zeniv.linux.org.uk wrote:


 On Tue, Apr 28, 2015 at 06:42:10PM +0200, Fabian Frederick wrote:
 
 
   On 28 April 2015 at 18:05 Al Viro v...@zeniv.linux.org.uk wrote:
  
  
   On Tue, Apr 28, 2015 at 07:35:10AM +0200, Fabian Frederick wrote:
  
 Al, very unhappy about the prospect of looking through ~2000 calls of
 strlcpy()
 we have in the tree...
   
Sorry Al, I thought it was more secure.
  
   It's not just you, unfortunately, and dumping all that annoyance on you
   as a proxy for everyone who does that kind of thing had been unfair.
   My apologies...
 
  No problem Al :) but why can't we harden strlcpy at first with
  something like a strlen limited to max char.
  (I don't know if it's already in kernel libs).
 
  size_t strlenl(const char *s, size_t maxlen)

 aka strnlen()

          const char *sc = s;
          size_t i = 0;
 
          while (*sc != '\0'  (i  maxlen)) {
                  i++;
                  sc++;
          }
          return sc - s;
  }
 
  Then we could solve problems downstream ...

 Can't.  Seriously, look what strlcpy() is supposed to return; it's pretty
 much a microoptimized snprintf(dst, size, %s, src).  It's certainly
 been patterned after snprintf(3) - don't exceed that size, NUL-terminate
 unless the size is zero, return the number of characters (excluding NUL)
 that would've been written if the size had been large enough.

 The following is a legitimate use of strlcpy():

 int foo(char *);      /* modifies string */

 int const_foo(const char *s)
 {
       int res;
       char buf[32], *p = buf;
       size_t wanted = strlcpy(buf, sizeof(buf), s);
       if (wanted = sizeof(buf)) {
               p = malloc(wanted + 1);
               if (!p)
                       return -ENOMEM;
               memcpy(p, s, wanted + 1);
       }
       res = foo(p);
       if (p != buf)
               free(p);
       return res;
 }

 None of the kernel callers are of exactly that form (and most ignore the
 return value completely), but if we make that sucker return something
 different from what strlcpy(3) would return, we'd damn better _not_ keep
 the name; there's enough confusion in that area as it is.
Of course with another function name. There's no other way to do it ...
strlncpy/strlncat ? :)

Regards,
Fabian
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: revert "fs/befs/linuxvfs.c: replace strncpy by strlcpy"

2015-04-27 Thread Fabian Frederick


> On 28 April 2015 at 05:48 Al Viro  wrote:
>
>
> commit 39d7a29f867bd5a4a551fad6bb3812ceddb0bce1
> Author: Fabian Frederick 
> Date:   Fri Jun 6 14:36:15 2014 -0700
>
>     fs/befs/linuxvfs.c: replace strncpy by strlcpy
>     
>     strncpy + end of string assignment replaced by strlcpy
>
> replaces perfectly safe code with undefined behaviour.  All in the name
> of "security hardening", presumably.  Folks, seeing the words "designed to be
> safer, more consistent, and less error prone replacement" in a manpage does
> *NOT* mean "OK, quit reading it - no need to go further, not even to the end
> of the paragraph".  Because in the end of that paragraph it says "This means
> that for strlcpy() src must be NUL-terminated".  And sure enough, our
> implementation relies on that - it starts with strlen().
>
> strncpy() is guaranteed not to look further than size.  strlcpy() is *NOT*.
> strncpy() on unvalidated source is safe, provided that you sanitize the copy;
> strlcpy() on anything like that is an invitation for nasal daemons.
>
> Sure, we can (and probably should) make strlcpy(dst, src, n) never access
> memory beyond src + n - 1, but this kind of cargo-culting is a Bad Thing(tm);
> mindless "security improvements" without so much as bothering to RTFM are
> asking for trouble.  And in userland code anything like that _can't_ be
> papered over afterwards - not unless you can patch every libc implementation
> out there.
>
> This particular code is completely pointless - if anything, it should've been
> memcpy() + nd_terminate_link()...
>
> Al, very unhappy about the prospect of looking through ~2000 calls of
> strlcpy()
> we have in the tree...

Sorry Al, I thought it was more secure.
I guess the 2 following patches should be reversed as well :

6cb103b6f45a
"fs/befs/btree.c: replace strncpy by strlcpy + coding style fixing"

69201bb11327
"fs/ocfs2/super.c: use OCFS2_MAX_VOL_LABEL_LEN and strlcpy"

Regards,
Fabian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1 linux-next] fs/coda/upcall.c: remove UPARG flow control macro

2015-04-27 Thread Fabian Frederick


> On 27 April 2015 at 20:37 Jan Harkes  wrote:
>
>
> On Mon, Apr 27, 2015 at 07:23:06PM +0200, Fabian Frederick wrote:
> > Move UPARG code to alloc_upcall() and test errors/return in callsites.
> > This patch removes flow control in macros which must be avoided.
> > (See Documentation/CodingStyle)
>
> At first glance this is not a correct patch.
>
> UPARG allocates a buffer that is large enough to hold both the upcall
> message going to userspace as well as the incoming reply message. At
> first glance this patch only seems to allocate insize. It may still be
> doing the right thing because insize is defined at the call level as
> MAX(sizeof(inarg), sizeof(outarg)). This it looks like quite a few
> changes for an untested patch and not enough for an actual cleanup of
> the related code.
>
> Jan

Sorry Jan but I don't see any problem in that patch.
outarg is processed the same way:

New alloc_upcall(**inp, **outp):
*outp = (union outputArgs *)inp;
*outsize = insize;

UPARG macro:
outp = (union outputArgs *)(inp); \
outsize = insize; \

Regards,
Fabian


>
> > ---
> > This is untested.
> >
> >  fs/coda/upcall.c | 107
> >+++
> >  1 file changed, 69 insertions(+), 38 deletions(-)
> >
> > diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
> > index 9b1ffaa..7524f630 100644
> > --- a/fs/coda/upcall.c
> > +++ b/fs/coda/upcall.c
> > @@ -41,30 +41,24 @@
> >  static int coda_upcall(struct venus_comm *vc, int inSize, int *outSize,
> >                    union inputArgs *buffer);
> > 
> > -static void *alloc_upcall(int opcode, int size)
> > +static int alloc_upcall(int opcode, int insize, int *outsize,
> > +                   union inputArgs **inp, union outputArgs **outp)
> >  {
> > -   union inputArgs *inp;
> > +   CODA_ALLOC(*inp, union inputArgs *, insize);
> > +   if (!*inp)
> > +           return -ENOMEM;
> > 
> > -   CODA_ALLOC(inp, union inputArgs *, size);
> > -        if (!inp)
> > -           return ERR_PTR(-ENOMEM);
> ...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] fs/coda/upcall.c: remove UPARG flow control macro

2015-04-27 Thread Fabian Frederick
Move UPARG code to alloc_upcall() and test errors/return in callsites.
This patch removes flow control in macros which must be avoided.
(See Documentation/CodingStyle)

Signed-off-by: Fabian Frederick 
---
This is untested.

 fs/coda/upcall.c | 107 +++
 1 file changed, 69 insertions(+), 38 deletions(-)

diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index 9b1ffaa..7524f630 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -41,30 +41,24 @@
 static int coda_upcall(struct venus_comm *vc, int inSize, int *outSize,
   union inputArgs *buffer);
 
-static void *alloc_upcall(int opcode, int size)
+static int alloc_upcall(int opcode, int insize, int *outsize,
+   union inputArgs **inp, union outputArgs **outp)
 {
-   union inputArgs *inp;
+   CODA_ALLOC(*inp, union inputArgs *, insize);
+   if (!*inp)
+   return -ENOMEM;
 
-   CODA_ALLOC(inp, union inputArgs *, size);
-if (!inp)
-   return ERR_PTR(-ENOMEM);
+   (*inp)->ih.opcode = opcode;
+   (*inp)->ih.pid = task_pid_nr_ns(current, _pid_ns);
+   (*inp)->ih.pgid = task_pgrp_nr_ns(current, _pid_ns);
+   (*inp)->ih.uid = from_kuid(_user_ns, current_fsuid());
 
-inp->ih.opcode = opcode;
-   inp->ih.pid = task_pid_nr_ns(current, _pid_ns);
-   inp->ih.pgid = task_pgrp_nr_ns(current, _pid_ns);
-   inp->ih.uid = from_kuid(_user_ns, current_fsuid());
+   *outp = (union outputArgs *)inp;
+   *outsize = insize;
 
-   return (void*)inp;
+   return 0;
 }
 
-#define UPARG(op)\
-do {\
-   inp = (union inputArgs *)alloc_upcall(op, insize); \
-if (IS_ERR(inp)) { return PTR_ERR(inp); }\
-outp = (union outputArgs *)(inp); \
-outsize = insize; \
-} while (0)
-
 #define INSIZE(tag) sizeof(struct coda_ ## tag ## _in)
 #define OUTSIZE(tag) sizeof(struct coda_ ## tag ## _out)
 #define SIZE(tag)  max_t(unsigned int, INSIZE(tag), OUTSIZE(tag))
@@ -78,7 +72,9 @@ int venus_rootfid(struct super_block *sb, struct CodaFid 
*fidp)
 int insize, outsize, error;
 
 insize = SIZE(root);
-UPARG(CODA_ROOT);
+   error = alloc_upcall(CODA_ROOT, insize, , , );
+   if (error)
+   return error;
 
error = coda_upcall(coda_vcp(sb), insize, , inp);
if (!error)
@@ -96,7 +92,10 @@ int venus_getattr(struct super_block *sb, struct CodaFid 
*fid,
 int insize, outsize, error;
 
 insize = SIZE(getattr); 
-   UPARG(CODA_GETATTR);
+   error = alloc_upcall(CODA_GETATTR, insize, , , );
+   if (error)
+   return error;
+
 inp->coda_getattr.VFid = *fid;
 
error = coda_upcall(coda_vcp(sb), insize, , inp);
@@ -115,7 +114,9 @@ int venus_setattr(struct super_block *sb, struct CodaFid 
*fid,
 int insize, outsize, error;

insize = SIZE(setattr);
-   UPARG(CODA_SETATTR);
+   error = alloc_upcall(CODA_SETATTR, insize, , , );
+   if (error)
+   return error;
 
 inp->coda_setattr.VFid = *fid;
inp->coda_setattr.attr = *vattr;
@@ -137,7 +138,9 @@ int venus_lookup(struct super_block *sb, struct CodaFid 
*fid,
 
offset = INSIZE(lookup);
 insize = max_t(unsigned int, offset + length +1, OUTSIZE(lookup));
-   UPARG(CODA_LOOKUP);
+   error = alloc_upcall(CODA_LOOKUP, insize, , , );
+   if (error)
+   return error;
 
 inp->coda_lookup.VFid = *fid;
inp->coda_lookup.name = offset;
@@ -164,8 +167,10 @@ int venus_close(struct super_block *sb, struct CodaFid 
*fid, int flags,
int insize, outsize, error;

insize = SIZE(release);
-   UPARG(CODA_CLOSE);
-   
+   error = alloc_upcall(CODA_CLOSE, insize, , , );
+   if (error)
+   return error;
+
inp->ih.uid = from_kuid(_user_ns, uid);
 inp->coda_close.VFid = *fid;
 inp->coda_close.flags = flags;
@@ -184,7 +189,9 @@ int venus_open(struct super_block *sb, struct CodaFid *fid,
 int insize, outsize, error;

insize = SIZE(open_by_fd);
-   UPARG(CODA_OPEN_BY_FD);
+   error = alloc_upcall(CODA_OPEN_BY_FD, insize, , , );
+   if (error)
+   return error;
 
inp->coda_open_by_fd.VFid = *fid;
inp->coda_open_by_fd.flags = flags;
@@ -208,7 +215,9 @@ int venus_mkdir(struct super_block *sb, struct CodaFid 
*dirfid,
 
offset = INSIZE(mkdir);
insize = max_t(unsigned int, offset + length + 1, OUTSIZE(mkdir));
-   UPARG(CODA_MKDIR);
+   error = alloc_upcall(CODA_MKDIR, insize, , , );
+   if (error)
+   return error;
 
 inp->coda_mkdir.VFid = *dirfid;
 inp->coda_mkdir.attr = *attrs;
@@ -241,7 +250,9 @@ int venus_rename(struct super_block *sb, struct CodaFid 
*old_fid,
offset = INSIZE(rename);
i

[PATCH 1/1 linux-next RESEND] pinctrl: use ERR_CAST instead of ERR_PTR/PTR_ERR

2015-04-27 Thread Fabian Frederick
Inspired by scripts/coccinelle/api/err_cast.cocci

Signed-off-by: Fabian Frederick 
---
 include/linux/pinctrl/consumer.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h
index 18eccef..d7e5d60 100644
--- a/include/linux/pinctrl/consumer.h
+++ b/include/linux/pinctrl/consumer.h
@@ -142,7 +142,7 @@ static inline struct pinctrl * __must_check 
pinctrl_get_select(
s = pinctrl_lookup_state(p, name);
if (IS_ERR(s)) {
pinctrl_put(p);
-   return ERR_PTR(PTR_ERR(s));
+   return ERR_CAST(s);
}
 
ret = pinctrl_select_state(p, s);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1 linux-next] fs/coda/upcall.c: remove UPARG flow control macro

2015-04-27 Thread Fabian Frederick


 On 27 April 2015 at 20:37 Jan Harkes jahar...@cs.cmu.edu wrote:


 On Mon, Apr 27, 2015 at 07:23:06PM +0200, Fabian Frederick wrote:
  Move UPARG code to alloc_upcall() and test errors/return in callsites.
  This patch removes flow control in macros which must be avoided.
  (See Documentation/CodingStyle)

 At first glance this is not a correct patch.

 UPARG allocates a buffer that is large enough to hold both the upcall
 message going to userspace as well as the incoming reply message. At
 first glance this patch only seems to allocate insize. It may still be
 doing the right thing because insize is defined at the call level as
 MAX(sizeof(inarg), sizeof(outarg)). This it looks like quite a few
 changes for an untested patch and not enough for an actual cleanup of
 the related code.

 Jan

Sorry Jan but I don't see any problem in that patch.
outarg is processed the same way:

New alloc_upcall(**inp, **outp):
*outp = (union outputArgs *)inp;
*outsize = insize;

UPARG macro:
outp = (union outputArgs *)(inp); \
outsize = insize; \

Regards,
Fabian



  ---
  This is untested.
 
   fs/coda/upcall.c | 107
 +++
   1 file changed, 69 insertions(+), 38 deletions(-)
 
  diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
  index 9b1ffaa..7524f630 100644
  --- a/fs/coda/upcall.c
  +++ b/fs/coda/upcall.c
  @@ -41,30 +41,24 @@
   static int coda_upcall(struct venus_comm *vc, int inSize, int *outSize,
                     union inputArgs *buffer);
  
  -static void *alloc_upcall(int opcode, int size)
  +static int alloc_upcall(int opcode, int insize, int *outsize,
  +                   union inputArgs **inp, union outputArgs **outp)
   {
  -   union inputArgs *inp;
  +   CODA_ALLOC(*inp, union inputArgs *, insize);
  +   if (!*inp)
  +           return -ENOMEM;
  
  -   CODA_ALLOC(inp, union inputArgs *, size);
  -        if (!inp)
  -           return ERR_PTR(-ENOMEM);
 ...
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next RESEND] pinctrl: use ERR_CAST instead of ERR_PTR/PTR_ERR

2015-04-27 Thread Fabian Frederick
Inspired by scripts/coccinelle/api/err_cast.cocci

Signed-off-by: Fabian Frederick f...@skynet.be
---
 include/linux/pinctrl/consumer.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h
index 18eccef..d7e5d60 100644
--- a/include/linux/pinctrl/consumer.h
+++ b/include/linux/pinctrl/consumer.h
@@ -142,7 +142,7 @@ static inline struct pinctrl * __must_check 
pinctrl_get_select(
s = pinctrl_lookup_state(p, name);
if (IS_ERR(s)) {
pinctrl_put(p);
-   return ERR_PTR(PTR_ERR(s));
+   return ERR_CAST(s);
}
 
ret = pinctrl_select_state(p, s);
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] fs/coda/upcall.c: remove UPARG flow control macro

2015-04-27 Thread Fabian Frederick
Move UPARG code to alloc_upcall() and test errors/return in callsites.
This patch removes flow control in macros which must be avoided.
(See Documentation/CodingStyle)

Signed-off-by: Fabian Frederick f...@skynet.be
---
This is untested.

 fs/coda/upcall.c | 107 +++
 1 file changed, 69 insertions(+), 38 deletions(-)

diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index 9b1ffaa..7524f630 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -41,30 +41,24 @@
 static int coda_upcall(struct venus_comm *vc, int inSize, int *outSize,
   union inputArgs *buffer);
 
-static void *alloc_upcall(int opcode, int size)
+static int alloc_upcall(int opcode, int insize, int *outsize,
+   union inputArgs **inp, union outputArgs **outp)
 {
-   union inputArgs *inp;
+   CODA_ALLOC(*inp, union inputArgs *, insize);
+   if (!*inp)
+   return -ENOMEM;
 
-   CODA_ALLOC(inp, union inputArgs *, size);
-if (!inp)
-   return ERR_PTR(-ENOMEM);
+   (*inp)-ih.opcode = opcode;
+   (*inp)-ih.pid = task_pid_nr_ns(current, init_pid_ns);
+   (*inp)-ih.pgid = task_pgrp_nr_ns(current, init_pid_ns);
+   (*inp)-ih.uid = from_kuid(init_user_ns, current_fsuid());
 
-inp-ih.opcode = opcode;
-   inp-ih.pid = task_pid_nr_ns(current, init_pid_ns);
-   inp-ih.pgid = task_pgrp_nr_ns(current, init_pid_ns);
-   inp-ih.uid = from_kuid(init_user_ns, current_fsuid());
+   *outp = (union outputArgs *)inp;
+   *outsize = insize;
 
-   return (void*)inp;
+   return 0;
 }
 
-#define UPARG(op)\
-do {\
-   inp = (union inputArgs *)alloc_upcall(op, insize); \
-if (IS_ERR(inp)) { return PTR_ERR(inp); }\
-outp = (union outputArgs *)(inp); \
-outsize = insize; \
-} while (0)
-
 #define INSIZE(tag) sizeof(struct coda_ ## tag ## _in)
 #define OUTSIZE(tag) sizeof(struct coda_ ## tag ## _out)
 #define SIZE(tag)  max_t(unsigned int, INSIZE(tag), OUTSIZE(tag))
@@ -78,7 +72,9 @@ int venus_rootfid(struct super_block *sb, struct CodaFid 
*fidp)
 int insize, outsize, error;
 
 insize = SIZE(root);
-UPARG(CODA_ROOT);
+   error = alloc_upcall(CODA_ROOT, insize, outsize, inp, outp);
+   if (error)
+   return error;
 
error = coda_upcall(coda_vcp(sb), insize, outsize, inp);
if (!error)
@@ -96,7 +92,10 @@ int venus_getattr(struct super_block *sb, struct CodaFid 
*fid,
 int insize, outsize, error;
 
 insize = SIZE(getattr); 
-   UPARG(CODA_GETATTR);
+   error = alloc_upcall(CODA_GETATTR, insize, outsize, inp, outp);
+   if (error)
+   return error;
+
 inp-coda_getattr.VFid = *fid;
 
error = coda_upcall(coda_vcp(sb), insize, outsize, inp);
@@ -115,7 +114,9 @@ int venus_setattr(struct super_block *sb, struct CodaFid 
*fid,
 int insize, outsize, error;

insize = SIZE(setattr);
-   UPARG(CODA_SETATTR);
+   error = alloc_upcall(CODA_SETATTR, insize, outsize, inp, outp);
+   if (error)
+   return error;
 
 inp-coda_setattr.VFid = *fid;
inp-coda_setattr.attr = *vattr;
@@ -137,7 +138,9 @@ int venus_lookup(struct super_block *sb, struct CodaFid 
*fid,
 
offset = INSIZE(lookup);
 insize = max_t(unsigned int, offset + length +1, OUTSIZE(lookup));
-   UPARG(CODA_LOOKUP);
+   error = alloc_upcall(CODA_LOOKUP, insize, outsize, inp, outp);
+   if (error)
+   return error;
 
 inp-coda_lookup.VFid = *fid;
inp-coda_lookup.name = offset;
@@ -164,8 +167,10 @@ int venus_close(struct super_block *sb, struct CodaFid 
*fid, int flags,
int insize, outsize, error;

insize = SIZE(release);
-   UPARG(CODA_CLOSE);
-   
+   error = alloc_upcall(CODA_CLOSE, insize, outsize, inp, outp);
+   if (error)
+   return error;
+
inp-ih.uid = from_kuid(init_user_ns, uid);
 inp-coda_close.VFid = *fid;
 inp-coda_close.flags = flags;
@@ -184,7 +189,9 @@ int venus_open(struct super_block *sb, struct CodaFid *fid,
 int insize, outsize, error;

insize = SIZE(open_by_fd);
-   UPARG(CODA_OPEN_BY_FD);
+   error = alloc_upcall(CODA_OPEN_BY_FD, insize, outsize, inp, outp);
+   if (error)
+   return error;
 
inp-coda_open_by_fd.VFid = *fid;
inp-coda_open_by_fd.flags = flags;
@@ -208,7 +215,9 @@ int venus_mkdir(struct super_block *sb, struct CodaFid 
*dirfid,
 
offset = INSIZE(mkdir);
insize = max_t(unsigned int, offset + length + 1, OUTSIZE(mkdir));
-   UPARG(CODA_MKDIR);
+   error = alloc_upcall(CODA_MKDIR, insize, outsize, inp, outp);
+   if (error)
+   return error;
 
 inp-coda_mkdir.VFid = *dirfid;
 inp-coda_mkdir.attr = *attrs;
@@ -241,7 +250,9 @@ int venus_rename(struct super_block

Re: revert fs/befs/linuxvfs.c: replace strncpy by strlcpy

2015-04-27 Thread Fabian Frederick


 On 28 April 2015 at 05:48 Al Viro v...@zeniv.linux.org.uk wrote:


 commit 39d7a29f867bd5a4a551fad6bb3812ceddb0bce1
 Author: Fabian Frederick f...@skynet.be
 Date:   Fri Jun 6 14:36:15 2014 -0700

     fs/befs/linuxvfs.c: replace strncpy by strlcpy
     
     strncpy + end of string assignment replaced by strlcpy

 replaces perfectly safe code with undefined behaviour.  All in the name
 of security hardening, presumably.  Folks, seeing the words designed to be
 safer, more consistent, and less error prone replacement in a manpage does
 *NOT* mean OK, quit reading it - no need to go further, not even to the end
 of the paragraph.  Because in the end of that paragraph it says This means
 that for strlcpy() src must be NUL-terminated.  And sure enough, our
 implementation relies on that - it starts with strlen().

 strncpy() is guaranteed not to look further than size.  strlcpy() is *NOT*.
 strncpy() on unvalidated source is safe, provided that you sanitize the copy;
 strlcpy() on anything like that is an invitation for nasal daemons.

 Sure, we can (and probably should) make strlcpy(dst, src, n) never access
 memory beyond src + n - 1, but this kind of cargo-culting is a Bad Thing(tm);
 mindless security improvements without so much as bothering to RTFM are
 asking for trouble.  And in userland code anything like that _can't_ be
 papered over afterwards - not unless you can patch every libc implementation
 out there.

 This particular code is completely pointless - if anything, it should've been
 memcpy() + nd_terminate_link()...

 Al, very unhappy about the prospect of looking through ~2000 calls of
 strlcpy()
 we have in the tree...

Sorry Al, I thought it was more secure.
I guess the 2 following patches should be reversed as well :

6cb103b6f45a
fs/befs/btree.c: replace strncpy by strlcpy + coding style fixing

69201bb11327
fs/ocfs2/super.c: use OCFS2_MAX_VOL_LABEL_LEN and strlcpy

Regards,
Fabian
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] fs/befs/btree.c: remove unneeded initializations

2015-04-25 Thread Fabian Frederick
bh, od_sup and this_node are unconditionally initialized in
befs_bt_read_super() and befs_btree_find()

Cc: Andrew Morton 
Signed-off-by: Fabian Frederick 
---
 fs/befs/btree.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/befs/btree.c b/fs/befs/btree.c
index 0826e91..22c16628 100644
--- a/fs/befs/btree.c
+++ b/fs/befs/btree.c
@@ -137,8 +137,8 @@ static int
 befs_bt_read_super(struct super_block *sb, befs_data_stream * ds,
   befs_btree_super * sup)
 {
-   struct buffer_head *bh = NULL;
-   befs_disk_btree_super *od_sup = NULL;
+   struct buffer_head *bh;
+   befs_disk_btree_super *od_sup;
 
befs_debug(sb, "---> %s", __func__);
 
@@ -250,7 +250,7 @@ int
 befs_btree_find(struct super_block *sb, befs_data_stream * ds,
const char *key, befs_off_t * value)
 {
-   struct befs_btree_node *this_node = NULL;
+   struct befs_btree_node *this_node;
befs_btree_super bt_super;
befs_off_t node_off;
int res;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] fs/affs/inode.c: remove unneeded initialization

2015-04-25 Thread Fabian Frederick
bh is initialized unconditionally in affs_add_entry()

Cc: Andrew Morton 
Signed-off-by: Fabian Frederick 
---
 fs/affs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index a022f4a..1734950 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -346,7 +346,7 @@ affs_add_entry(struct inode *dir, struct inode *inode, 
struct dentry *dentry, s3
 {
struct super_block *sb = dir->i_sb;
struct buffer_head *inode_bh = NULL;
-   struct buffer_head *bh = NULL;
+   struct buffer_head *bh;
u32 block = 0;
int retval;
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] fs/affs/amigaffs.c: remove unneeded initialization

2015-04-25 Thread Fabian Frederick
bh is initialized unconditionally in affs_remove_link()

Cc: Andrew Morton 
Signed-off-by: Fabian Frederick 
---
 fs/affs/amigaffs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 1df7478..4ff6edb 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -140,7 +140,7 @@ affs_remove_link(struct dentry *dentry)
 {
struct inode *dir, *inode = d_inode(dentry);
struct super_block *sb = inode->i_sb;
-   struct buffer_head *bh = NULL, *link_bh = NULL;
+   struct buffer_head *bh, *link_bh = NULL;
u32 link_ino, ino;
int retval;
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] drm/i915: use ERR_CAST instead of ERR_PTR/PTR_ERR

2015-04-25 Thread Fabian Frederick
Inspired by scripts/coccinelle/api/err_cast.cocci

Signed-off-by: Fabian Frederick 
---
 drivers/gpu/drm/i915/intel_drv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 897f17d..d52f267 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1310,7 +1310,7 @@ intel_atomic_get_crtc_state(struct drm_atomic_state 
*state,
struct drm_crtc_state *crtc_state;
crtc_state = drm_atomic_get_crtc_state(state, >base);
if (IS_ERR(crtc_state))
-   return ERR_PTR(PTR_ERR(crtc_state));
+   return ERR_CAST(crtc_state);
 
return to_intel_crtc_state(crtc_state);
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] cpufreq: pxa: replace typedef pxa_freqs_t by structure

2015-04-25 Thread Fabian Frederick
See Documentation/CodingStyle.

Signed-off-by: Fabian Frederick 
---
 drivers/cpufreq/pxa2xx-cpufreq.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index e24269a..fcf6e34 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -56,7 +56,7 @@ module_param(pxa27x_maxfreq, uint, 0);
 MODULE_PARM_DESC(pxa27x_maxfreq, "Set the pxa27x maxfreq in MHz"
 "(typically 624=>pxa270, 416=>pxa271, 520=>pxa272)");
 
-typedef struct {
+struct pxa_freqs {
unsigned int khz;
unsigned int membus;
unsigned int cccr;
@@ -64,7 +64,7 @@ typedef struct {
unsigned int cclkcfg;
int vmin;
int vmax;
-} pxa_freqs_t;
+};
 
 /* Define the refresh period in mSec for the SDRAM and the number of rows */
 #define SDRAM_TREF 64  /* standard 64ms SDRAM */
@@ -86,7 +86,7 @@ static unsigned int sdram_rows;
 /* Use the run mode frequencies for the CPUFREQ_POLICY_PERFORMANCE policy */
 #define CCLKCFGCCLKCFG_TURBO | CCLKCFG_FCS
 
-static pxa_freqs_t pxa255_run_freqs[] =
+static struct pxa_freqs pxa255_run_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus 
SDRAM */
{ 99500,  99500, 0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -98,7 +98,7 @@ static pxa_freqs_t pxa255_run_freqs[] =
 };
 
 /* Use the turbo mode frequencies for the CPUFREQ_POLICY_POWERSAVE policy */
-static pxa_freqs_t pxa255_turbo_freqs[] =
+static struct pxa_freqs pxa255_turbo_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus SDRAM */
{ 99500, 99500,  0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -153,7 +153,7 @@ MODULE_PARM_DESC(pxa255_turbo_table, "Selects the frequency 
table (0 = run table
((HT) ? CCLKCFG_HALFTURBO : 0) | \
((T)  ? CCLKCFG_TURBO : 0))
 
-static pxa_freqs_t pxa27x_freqs[] = {
+static struct pxa_freqs pxa27x_freqs[] = {
{104000, 104000, PXA27x_CCCR(1,  8, 2), 0, CCLKCFG2(1, 0, 1),  90, 
1705000 },
{156000, 104000, PXA27x_CCCR(1,  8, 3), 0, CCLKCFG2(1, 0, 1), 100, 
1705000 },
{208000, 208000, PXA27x_CCCR(0, 16, 2), 1, CCLKCFG2(0, 0, 1), 118, 
1705000 },
@@ -171,7 +171,7 @@ extern unsigned get_clk_frequency_khz(int info);
 
 #ifdef CONFIG_REGULATOR
 
-static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
+static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
 {
int ret = 0;
int vmin, vmax;
@@ -202,7 +202,7 @@ static void __init pxa_cpufreq_init_voltages(void)
}
 }
 #else
-static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
+static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
 {
return 0;
 }
@@ -211,7 +211,7 @@ static void __init pxa_cpufreq_init_voltages(void) { }
 #endif
 
 static void find_freq_tables(struct cpufreq_frequency_table **freq_table,
-pxa_freqs_t **pxa_freqs)
+struct pxa_freqs **pxa_freqs)
 {
if (cpu_is_pxa25x()) {
if (!pxa255_turbo_table) {
@@ -270,7 +270,7 @@ static unsigned int pxa_cpufreq_get(unsigned int cpu)
 static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 {
struct cpufreq_frequency_table *pxa_freqs_table;
-   pxa_freqs_t *pxa_freq_settings;
+   struct pxa_freqs *pxa_freq_settings;
unsigned long flags;
unsigned int new_freq_cpu, new_freq_mem;
unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
@@ -361,7 +361,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
int i;
unsigned int freq;
struct cpufreq_frequency_table *pxa255_freq_table;
-   pxa_freqs_t *pxa255_freqs;
+   struct pxa_freqs *pxa255_freqs;
 
/* try to guess pxa27x cpu */
if (cpu_is_pxa27x())
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] Btrfs: avoid using NULL compressed_pages in insert_inline_extent()

2015-04-25 Thread Fabian Frederick
insert_inline_extent() checked for compressed_pages to be NULL then
it accessed it under compress_type != BTRFS_COMPRESS_NONE.
This patch adds a BUG() when compress_size != 0, compress_type !=
BTRFS_COMPRESS_NONE and compressed_pages == 0.

Signed-off-by: Fabian Frederick 
---
 fs/btrfs/inode.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ada4d24..449653d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -150,8 +150,12 @@ static int insert_inline_extent(struct btrfs_trans_handle 
*trans,
size_t cur_size = size;
unsigned long offset;
 
-   if (compressed_size && compressed_pages)
-   cur_size = compressed_size;
+   if (compressed_size) {
+   if (compressed_pages)
+   cur_size = compressed_size;
+   else if (compress_type != BTRFS_COMPRESS_NONE)
+   BUG();
+   }
 
inode_add_bytes(inode, size);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] drm/i915: use ERR_CAST instead of ERR_PTR/PTR_ERR

2015-04-25 Thread Fabian Frederick
Inspired by scripts/coccinelle/api/err_cast.cocci

Signed-off-by: Fabian Frederick f...@skynet.be
---
 drivers/gpu/drm/i915/intel_drv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 897f17d..d52f267 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1310,7 +1310,7 @@ intel_atomic_get_crtc_state(struct drm_atomic_state 
*state,
struct drm_crtc_state *crtc_state;
crtc_state = drm_atomic_get_crtc_state(state, crtc-base);
if (IS_ERR(crtc_state))
-   return ERR_PTR(PTR_ERR(crtc_state));
+   return ERR_CAST(crtc_state);
 
return to_intel_crtc_state(crtc_state);
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] fs/affs/inode.c: remove unneeded initialization

2015-04-25 Thread Fabian Frederick
bh is initialized unconditionally in affs_add_entry()

Cc: Andrew Morton a...@linux-foundation.org
Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/affs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index a022f4a..1734950 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -346,7 +346,7 @@ affs_add_entry(struct inode *dir, struct inode *inode, 
struct dentry *dentry, s3
 {
struct super_block *sb = dir-i_sb;
struct buffer_head *inode_bh = NULL;
-   struct buffer_head *bh = NULL;
+   struct buffer_head *bh;
u32 block = 0;
int retval;
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] Btrfs: avoid using NULL compressed_pages in insert_inline_extent()

2015-04-25 Thread Fabian Frederick
insert_inline_extent() checked for compressed_pages to be NULL then
it accessed it under compress_type != BTRFS_COMPRESS_NONE.
This patch adds a BUG() when compress_size != 0, compress_type !=
BTRFS_COMPRESS_NONE and compressed_pages == 0.

Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/btrfs/inode.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ada4d24..449653d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -150,8 +150,12 @@ static int insert_inline_extent(struct btrfs_trans_handle 
*trans,
size_t cur_size = size;
unsigned long offset;
 
-   if (compressed_size  compressed_pages)
-   cur_size = compressed_size;
+   if (compressed_size) {
+   if (compressed_pages)
+   cur_size = compressed_size;
+   else if (compress_type != BTRFS_COMPRESS_NONE)
+   BUG();
+   }
 
inode_add_bytes(inode, size);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] fs/affs/amigaffs.c: remove unneeded initialization

2015-04-25 Thread Fabian Frederick
bh is initialized unconditionally in affs_remove_link()

Cc: Andrew Morton a...@linux-foundation.org
Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/affs/amigaffs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 1df7478..4ff6edb 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -140,7 +140,7 @@ affs_remove_link(struct dentry *dentry)
 {
struct inode *dir, *inode = d_inode(dentry);
struct super_block *sb = inode-i_sb;
-   struct buffer_head *bh = NULL, *link_bh = NULL;
+   struct buffer_head *bh, *link_bh = NULL;
u32 link_ino, ino;
int retval;
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] cpufreq: pxa: replace typedef pxa_freqs_t by structure

2015-04-25 Thread Fabian Frederick
See Documentation/CodingStyle.

Signed-off-by: Fabian Frederick f...@skynet.be
---
 drivers/cpufreq/pxa2xx-cpufreq.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index e24269a..fcf6e34 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -56,7 +56,7 @@ module_param(pxa27x_maxfreq, uint, 0);
 MODULE_PARM_DESC(pxa27x_maxfreq, Set the pxa27x maxfreq in MHz
 (typically 624=pxa270, 416=pxa271, 520=pxa272));
 
-typedef struct {
+struct pxa_freqs {
unsigned int khz;
unsigned int membus;
unsigned int cccr;
@@ -64,7 +64,7 @@ typedef struct {
unsigned int cclkcfg;
int vmin;
int vmax;
-} pxa_freqs_t;
+};
 
 /* Define the refresh period in mSec for the SDRAM and the number of rows */
 #define SDRAM_TREF 64  /* standard 64ms SDRAM */
@@ -86,7 +86,7 @@ static unsigned int sdram_rows;
 /* Use the run mode frequencies for the CPUFREQ_POLICY_PERFORMANCE policy */
 #define CCLKCFGCCLKCFG_TURBO | CCLKCFG_FCS
 
-static pxa_freqs_t pxa255_run_freqs[] =
+static struct pxa_freqs pxa255_run_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus 
SDRAM */
{ 99500,  99500, 0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -98,7 +98,7 @@ static pxa_freqs_t pxa255_run_freqs[] =
 };
 
 /* Use the turbo mode frequencies for the CPUFREQ_POLICY_POWERSAVE policy */
-static pxa_freqs_t pxa255_turbo_freqs[] =
+static struct pxa_freqs pxa255_turbo_freqs[] =
 {
/* CPU   MEMBUS  CCCR  DIV2 CCLKCFGrun  turbo PXbus SDRAM */
{ 99500, 99500,  0x121, 1,  CCLKCFG, -1, -1},   /*  99,   99,   50,   
50  */
@@ -153,7 +153,7 @@ MODULE_PARM_DESC(pxa255_turbo_table, Selects the frequency 
table (0 = run table
((HT) ? CCLKCFG_HALFTURBO : 0) | \
((T)  ? CCLKCFG_TURBO : 0))
 
-static pxa_freqs_t pxa27x_freqs[] = {
+static struct pxa_freqs pxa27x_freqs[] = {
{104000, 104000, PXA27x_CCCR(1,  8, 2), 0, CCLKCFG2(1, 0, 1),  90, 
1705000 },
{156000, 104000, PXA27x_CCCR(1,  8, 3), 0, CCLKCFG2(1, 0, 1), 100, 
1705000 },
{208000, 208000, PXA27x_CCCR(0, 16, 2), 1, CCLKCFG2(0, 0, 1), 118, 
1705000 },
@@ -171,7 +171,7 @@ extern unsigned get_clk_frequency_khz(int info);
 
 #ifdef CONFIG_REGULATOR
 
-static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
+static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
 {
int ret = 0;
int vmin, vmax;
@@ -202,7 +202,7 @@ static void __init pxa_cpufreq_init_voltages(void)
}
 }
 #else
-static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq)
+static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
 {
return 0;
 }
@@ -211,7 +211,7 @@ static void __init pxa_cpufreq_init_voltages(void) { }
 #endif
 
 static void find_freq_tables(struct cpufreq_frequency_table **freq_table,
-pxa_freqs_t **pxa_freqs)
+struct pxa_freqs **pxa_freqs)
 {
if (cpu_is_pxa25x()) {
if (!pxa255_turbo_table) {
@@ -270,7 +270,7 @@ static unsigned int pxa_cpufreq_get(unsigned int cpu)
 static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
 {
struct cpufreq_frequency_table *pxa_freqs_table;
-   pxa_freqs_t *pxa_freq_settings;
+   struct pxa_freqs *pxa_freq_settings;
unsigned long flags;
unsigned int new_freq_cpu, new_freq_mem;
unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
@@ -361,7 +361,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
int i;
unsigned int freq;
struct cpufreq_frequency_table *pxa255_freq_table;
-   pxa_freqs_t *pxa255_freqs;
+   struct pxa_freqs *pxa255_freqs;
 
/* try to guess pxa27x cpu */
if (cpu_is_pxa27x())
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] fs/befs/btree.c: remove unneeded initializations

2015-04-25 Thread Fabian Frederick
bh, od_sup and this_node are unconditionally initialized in
befs_bt_read_super() and befs_btree_find()

Cc: Andrew Morton a...@linux-foundation.org
Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/befs/btree.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/befs/btree.c b/fs/befs/btree.c
index 0826e91..22c16628 100644
--- a/fs/befs/btree.c
+++ b/fs/befs/btree.c
@@ -137,8 +137,8 @@ static int
 befs_bt_read_super(struct super_block *sb, befs_data_stream * ds,
   befs_btree_super * sup)
 {
-   struct buffer_head *bh = NULL;
-   befs_disk_btree_super *od_sup = NULL;
+   struct buffer_head *bh;
+   befs_disk_btree_super *od_sup;
 
befs_debug(sb, --- %s, __func__);
 
@@ -250,7 +250,7 @@ int
 befs_btree_find(struct super_block *sb, befs_data_stream * ds,
const char *key, befs_off_t * value)
 {
-   struct befs_btree_node *this_node = NULL;
+   struct befs_btree_node *this_node;
befs_btree_super bt_super;
befs_off_t node_off;
int res;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 linux-next] scripts/coccinelle/misc/bugon.cocci: update bug_on conversion warning

2015-04-09 Thread Fabian Frederick
if()/BUG conversion to BUG_ON must be avoided when there's side effect
in condition. The reason being BUG_ON won't execute the condition when 
CONFIG_BUG
is not defined.

Inspired-by: J. Bruce Fields 
Suggested-by: Julia Lawall 
Acked-by: Julia Lawall 
Signed-off-by: Fabian Frederick 
---
V2: s/condition/the condition/

 scripts/coccinelle/misc/bugon.cocci | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/coccinelle/misc/bugon.cocci 
b/scripts/coccinelle/misc/bugon.cocci
index 3b7eec2..27c97f1 100644
--- a/scripts/coccinelle/misc/bugon.cocci
+++ b/scripts/coccinelle/misc/bugon.cocci
@@ -57,6 +57,6 @@ coccilib.org.print_todo(p[0], "WARNING use BUG_ON")
 p << r.p;
 @@
 
-msg="WARNING: Use BUG_ON"
+msg="WARNING: Use BUG_ON instead of if condition followed by BUG.\nPlease make 
sure the condition has no side effects (see conditional BUG_ON definition in 
include/asm-generic/bug.h)"
 coccilib.report.print_report(p[0], msg)
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] slob: statify slob_alloc_node() and remove symbol

2015-04-09 Thread Fabian Frederick
slob_alloc_node() is only used in slob.c
This patch removes EXPORT_SYMBOL and statify function

Signed-off-by: Fabian Frederick 
---
 mm/slob.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/slob.c b/mm/slob.c
index 6d55710..495df8e 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -532,7 +532,7 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long 
flags)
return 0;
 }
 
-void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
+static void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
 {
void *b;
 
@@ -558,7 +558,6 @@ void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, 
int node)
kmemleak_alloc_recursive(b, c->size, 1, c->flags, flags);
return b;
 }
-EXPORT_SYMBOL(slob_alloc_node);
 
 void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags)
 {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] scripts/coccinelle/misc/bugon.cocci: update bug_on conversion warning

2015-04-09 Thread Fabian Frederick
if()/BUG conversion to BUG_ON must be avoided when there's side effect
in condition. The reason being BUG_ON won't execute condition when CONFIG_BUG
is not defined.

Inspired-by: J. Bruce Fields 
Suggested-by: Julia Lawall 
Signed-off-by: Fabian Frederick 
---
 scripts/coccinelle/misc/bugon.cocci | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/coccinelle/misc/bugon.cocci 
b/scripts/coccinelle/misc/bugon.cocci
index 3b7eec2..0d18022 100644
--- a/scripts/coccinelle/misc/bugon.cocci
+++ b/scripts/coccinelle/misc/bugon.cocci
@@ -57,6 +57,6 @@ coccilib.org.print_todo(p[0], "WARNING use BUG_ON")
 p << r.p;
 @@
 
-msg="WARNING: Use BUG_ON"
+msg="WARNING: Use BUG_ON instead of if condition followed by BUG.\nPlease make 
sure condition has no side effects (see conditional BUG_ON definition in 
include/asm-generic/bug.h)"
 coccilib.report.print_report(p[0], msg)
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] slob: statify slob_alloc_node() and remove symbol

2015-04-09 Thread Fabian Frederick
slob_alloc_node() is only used in slob.c
This patch removes EXPORT_SYMBOL and statify function

Signed-off-by: Fabian Frederick f...@skynet.be
---
 mm/slob.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/slob.c b/mm/slob.c
index 6d55710..495df8e 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -532,7 +532,7 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long 
flags)
return 0;
 }
 
-void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
+static void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
 {
void *b;
 
@@ -558,7 +558,6 @@ void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, 
int node)
kmemleak_alloc_recursive(b, c-size, 1, c-flags, flags);
return b;
 }
-EXPORT_SYMBOL(slob_alloc_node);
 
 void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags)
 {
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 linux-next] scripts/coccinelle/misc/bugon.cocci: update bug_on conversion warning

2015-04-09 Thread Fabian Frederick
if()/BUG conversion to BUG_ON must be avoided when there's side effect
in condition. The reason being BUG_ON won't execute the condition when 
CONFIG_BUG
is not defined.

Inspired-by: J. Bruce Fields bfie...@fieldses.org
Suggested-by: Julia Lawall julia.law...@lip6.fr
Acked-by: Julia Lawall julia.law...@lip6.fr
Signed-off-by: Fabian Frederick f...@skynet.be
---
V2: s/condition/the condition/

 scripts/coccinelle/misc/bugon.cocci | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/coccinelle/misc/bugon.cocci 
b/scripts/coccinelle/misc/bugon.cocci
index 3b7eec2..27c97f1 100644
--- a/scripts/coccinelle/misc/bugon.cocci
+++ b/scripts/coccinelle/misc/bugon.cocci
@@ -57,6 +57,6 @@ coccilib.org.print_todo(p[0], WARNING use BUG_ON)
 p  r.p;
 @@
 
-msg=WARNING: Use BUG_ON
+msg=WARNING: Use BUG_ON instead of if condition followed by BUG.\nPlease make 
sure the condition has no side effects (see conditional BUG_ON definition in 
include/asm-generic/bug.h)
 coccilib.report.print_report(p[0], msg)
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1 linux-next] scripts/coccinelle/misc/bugon.cocci: update bug_on conversion warning

2015-04-09 Thread Fabian Frederick
if()/BUG conversion to BUG_ON must be avoided when there's side effect
in condition. The reason being BUG_ON won't execute condition when CONFIG_BUG
is not defined.

Inspired-by: J. Bruce Fields bfie...@fieldses.org
Suggested-by: Julia Lawall julia.law...@lip6.fr
Signed-off-by: Fabian Frederick f...@skynet.be
---
 scripts/coccinelle/misc/bugon.cocci | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/coccinelle/misc/bugon.cocci 
b/scripts/coccinelle/misc/bugon.cocci
index 3b7eec2..0d18022 100644
--- a/scripts/coccinelle/misc/bugon.cocci
+++ b/scripts/coccinelle/misc/bugon.cocci
@@ -57,6 +57,6 @@ coccilib.org.print_todo(p[0], WARNING use BUG_ON)
 p  r.p;
 @@
 
-msg=WARNING: Use BUG_ON
+msg=WARNING: Use BUG_ON instead of if condition followed by BUG.\nPlease make 
sure condition has no side effects (see conditional BUG_ON definition in 
include/asm-generic/bug.h)
 coccilib.report.print_report(p[0], msg)
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 5/9 linux-next] udf: improve error management in udf_CS0toNLS()

2015-04-08 Thread Fabian Frederick
Only callsite udf_get_filename() now returns
error code as well.

Suggested-by: Jan Kara 
Signed-off-by: Fabian Frederick 
---
 fs/udf/unicode.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 9008a36..488a838 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -257,7 +257,7 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr 
*utf_o,
ocu_len = ocu_i->u_len;
if (ocu_len == 0) {
memset(utf_o, 0, sizeof(struct ustr));
-   return 0;
+   return -EINVAL;
}
 
cmp_id = ocu_i->u_cmpID;
@@ -265,7 +265,7 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr 
*utf_o,
memset(utf_o, 0, sizeof(struct ustr));
pr_err("unknown compression code (%d) stri=%s\n",
   cmp_id, ocu_i->u_name);
-   return 0;
+   return -EINVAL;
}
 
ocu = ocu_i->u_name;
@@ -357,8 +357,9 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
goto out2;
}
} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
-   if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, filename,
- unifilename)) {
+   ret = udf_CS0toNLS(UDF_SB(sb)->s_nls_map, filename,
+  unifilename);
+   if (ret < 0) {
udf_debug("Failed in udf_get_filename: sname = %s\n",
  sname);
goto out2;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 4/9 linux-next] udf: improve error management in udf_CS0toUTF8()

2015-04-08 Thread Fabian Frederick
udf_CS0toUTF8() now returns -EINVAL on error.
udf_load_pvoldesc() and udf_get_filename() do the same.

Suggested-by: Jan Kara 
Signed-off-by: Fabian Frederick 
---
 fs/udf/super.c   | 23 ++-
 fs/udf/unicode.c |  9 +
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 6299f34..c6a8f5f 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -927,17 +927,22 @@ static int udf_load_pvoldesc(struct super_block *sb, 
sector_t block)
 #endif
}
 
-   if (!udf_build_ustr(instr, pvoldesc->volIdent, 32))
-   if (udf_CS0toUTF8(outstr, instr)) {
-   strncpy(UDF_SB(sb)->s_volume_ident, outstr->u_name,
-   outstr->u_len > 31 ? 31 : outstr->u_len);
-   udf_debug("volIdent[] = '%s'\n",
- UDF_SB(sb)->s_volume_ident);
-   }
+   if (!udf_build_ustr(instr, pvoldesc->volIdent, 32)) {
+   ret = udf_CS0toUTF8(outstr, instr);
+   if (ret < 0)
+   goto out_bh;
+
+   strncpy(UDF_SB(sb)->s_volume_ident, outstr->u_name,
+   outstr->u_len > 31 ? 31 : outstr->u_len);
+   udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident);
+   }
 
if (!udf_build_ustr(instr, pvoldesc->volSetIdent, 128))
-   if (udf_CS0toUTF8(outstr, instr))
-   udf_debug("volSetIdent[] = '%s'\n", outstr->u_name);
+   ret = udf_CS0toUTF8(outstr, instr);
+   if (ret < 0)
+   goto out_bh;
+
+   udf_debug("volSetIdent[] = '%s'\n", outstr->u_name);
 
ret = 0;
 out_bh:
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 41c3bef..9008a36 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -89,7 +89,7 @@ static void udf_build_ustr_exact(struct ustr *dest, dstring 
*ptr, int exactsize)
  * both of type "struct ustr *"
  *
  * POST-CONDITIONS
- * Zero on success.
+ * >= 0 on success.
  *
  * HISTORY
  * November 12, 1997 - Andrew E. Mileski
@@ -104,7 +104,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr 
*ocu_i)
ocu_len = ocu_i->u_len;
if (ocu_len == 0) {
memset(utf_o, 0, sizeof(struct ustr));
-   return 0;
+   return -EINVAL;
}
 
cmp_id = ocu_i->u_cmpID;
@@ -112,7 +112,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr 
*ocu_i)
memset(utf_o, 0, sizeof(struct ustr));
pr_err("unknown compression code (%d) stri=%s\n",
   cmp_id, ocu_i->u_name);
-   return 0;
+   return -EINVAL;
}
 
ocu = ocu_i->u_name;
@@ -350,7 +350,8 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
 
udf_build_ustr_exact(unifilename, sname, slen);
if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
-   if (!udf_CS0toUTF8(filename, unifilename)) {
+   ret = udf_CS0toUTF8(filename, unifilename);
+   if (ret < 0) {
udf_debug("Failed in udf_get_filename: sname = %s\n",
  sname);
goto out2;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 2/9 linux-next] udf: remove unnecessary test in udf_build_ustr_exact()

2015-04-08 Thread Fabian Frederick
We can remove parameter checks:

udf_build_ustr_exact() is only called by udf_get_filename()
which now assures dest is not NULL

udf_find_entry() and udf_readdir() call udf_get_filename()
after checking sname
udf_symlink_filler() calls udf_pc_to_char() with sname=kmap(page).

udf_find_entry() and udf_readdir() call udf_get_filename with UDF_NAME_LEN
udf_pc_to_char() with PAGE_SIZE

Suggested-by: Jan Kara 
Signed-off-by: Fabian Frederick 
---
V2: Return -EIO if slen = 0 in udf_get_filename()
(suggested by Jan Kara)

 fs/udf/unicode.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 4911c1d..e2c079a 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -68,17 +68,12 @@ int udf_build_ustr(struct ustr *dest, dstring *ptr, int 
size)
 /*
  * udf_build_ustr_exact
  */
-static int udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize)
+static void udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int 
exactsize)
 {
-   if ((!dest) || (!ptr) || (!exactsize))
-   return -1;
-
memset(dest, 0, sizeof(struct ustr));
dest->u_cmpID = ptr[0];
dest->u_len = exactsize - 1;
memcpy(dest->u_name, ptr + 1, exactsize - 1);
-
-   return 0;
 }
 
 /*
@@ -340,6 +335,9 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
struct ustr *filename, *unifilename;
int ret = 0;
 
+   if (!slen)
+   return -EIO;
+
filename = kmalloc(sizeof(struct ustr), GFP_NOFS);
if (!filename)
return -ENOMEM;
@@ -350,9 +348,7 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
goto out1;
}
 
-   if (udf_build_ustr_exact(unifilename, sname, slen))
-   goto out2;
-
+   udf_build_ustr_exact(unifilename, sname, slen);
if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
if (!udf_CS0toUTF8(filename, unifilename)) {
udf_debug("Failed in udf_get_filename: sname = %s\n",
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 0/9 linux-next] udf: improve error management

2015-04-08 Thread Fabian Frederick
This small patchset tries to solve error management in udf
unicode and callsites.

Thanks a lot to Jan Kara for all suggestions and code reviewing !

V2:
-Cc to lkml
-Patch 2 and 8 updated (See commit log)
-Adding patch 9

Of course this patchset would need extended testing.

Fabian Frederick (9):
  udf: udf_get_filename(): return -ENOMEM when allocation fails
  udf: remove unneccessary test in udf_build_ustr_exact()
  udf: unicode: update function name in comments
  udf: improve error management in udf_CS0toUTF8()
  udf: improve error management in udf_CS0toNLS()
  udf: bug on exotic flag in udf_get_filename()
  udf: return error when newIndex is 0 in udf_translate_to_linux()
  udf: propagate udf_get_filename() errors
  udf: add function definition for udf_find_entry()

 fs/udf/dir.c |  2 +-
 fs/udf/namei.c   | 85 +++-
 fs/udf/super.c   | 23 +--
 fs/udf/symlink.c |  3 ++
 fs/udf/unicode.c | 52 +-
 5 files changed, 109 insertions(+), 56 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 7/9 linux-next] udf: return error when newIndex is 0 in udf_translate_to_linux()

2015-04-08 Thread Fabian Frederick
udf_get_filename() and its callsites considered 0 as an error
without propagating an error value.

udf_translate_to_linux() now returns -EINVAL when newIndex is 0.
other functions are updated accordingly.

Signed-off-by: Fabian Frederick 
---
 fs/udf/dir.c | 2 +-
 fs/udf/namei.c   | 2 +-
 fs/udf/unicode.c | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/udf/dir.c b/fs/udf/dir.c
index fcf227e..541d9c6 100644
--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -168,7 +168,7 @@ static int udf_readdir(struct file *file, struct 
dir_context *ctx)
}
 
flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
-   if (flen <= 0)
+   if (flen < 0)
continue;
 
tloc = lelb_to_cpu(cfi.icb.extLocation);
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 59b340c..dd648b7 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -234,7 +234,7 @@ static struct fileIdentDesc *udf_find_entry(struct inode 
*dir,
continue;
 
flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
-   if ((flen > 0) && udf_match(flen, fname, child->len,
+   if ((flen >= 0) && udf_match(flen, fname, child->len,
child->name))
goto out_ok;
}
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index f37123b..3b1efbb 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -333,7 +333,7 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
 uint8_t *dname, int dlen)
 {
struct ustr *filename, *unifilename;
-   int ret = 0;
+   int ret;
 
if (!slen)
return -EIO;
@@ -492,5 +492,5 @@ static int udf_translate_to_linux(uint8_t *newName, int 
newLen,
}
}
 
-   return newIndex;
+   return newIndex ? : -EINVAL;
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 1/9 linux-next] udf: udf_get_filename(): return -ENOMEM when allocation fails

2015-04-08 Thread Fabian Frederick
udf_pc_to_char() now returns error accordingly.
udf_readdir() and udf_find_entry() process is done on
positive result.

Signed-off-by: Fabian Frederick 
---
 fs/udf/dir.c |  2 +-
 fs/udf/namei.c   |  3 ++-
 fs/udf/symlink.c |  3 +++
 fs/udf/unicode.c | 12 +++-
 4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/fs/udf/dir.c b/fs/udf/dir.c
index 541a12b..fcf227e 100644
--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -168,7 +168,7 @@ static int udf_readdir(struct file *file, struct 
dir_context *ctx)
}
 
flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
-   if (!flen)
+   if (flen <= 0)
continue;
 
tloc = lelb_to_cpu(cfi.icb.extLocation);
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index fbf3d90..59b340c 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -234,7 +234,8 @@ static struct fileIdentDesc *udf_find_entry(struct inode 
*dir,
continue;
 
flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
-   if (flen && udf_match(flen, fname, child->len, child->name))
+   if ((flen > 0) && udf_match(flen, fname, child->len,
+   child->name))
goto out_ok;
}
 
diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c
index 8dfbc40..862535b 100644
--- a/fs/udf/symlink.c
+++ b/fs/udf/symlink.c
@@ -82,6 +82,9 @@ static int udf_pc_to_char(struct super_block *sb, unsigned 
char *from,
comp_len = udf_get_filename(sb, pc->componentIdent,
pc->lengthComponentIdent,
p, tolen);
+   if (comp_len < 0)
+   return comp_len;
+
p += comp_len;
tolen -= comp_len;
if (tolen == 0)
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index b84fee3..4911c1d 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -338,15 +338,17 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
 uint8_t *dname, int dlen)
 {
struct ustr *filename, *unifilename;
-   int len = 0;
+   int ret = 0;
 
filename = kmalloc(sizeof(struct ustr), GFP_NOFS);
if (!filename)
-   return 0;
+   return -ENOMEM;
 
unifilename = kmalloc(sizeof(struct ustr), GFP_NOFS);
-   if (!unifilename)
+   if (!unifilename) {
+   ret = -ENOMEM;
goto out1;
+   }
 
if (udf_build_ustr_exact(unifilename, sname, slen))
goto out2;
@@ -367,14 +369,14 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
} else
goto out2;
 
-   len = udf_translate_to_linux(dname, dlen,
+   ret = udf_translate_to_linux(dname, dlen,
 filename->u_name, filename->u_len,
 unifilename->u_name, unifilename->u_len);
 out2:
kfree(unifilename);
 out1:
kfree(filename);
-   return len;
+   return ret;
 }
 
 int udf_put_filename(struct super_block *sb, const uint8_t *sname,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 8/9 linux-next] udf: propagate udf_get_filename() errors

2015-04-08 Thread Fabian Frederick
-Return udf_get_filename() error from udf_readdir()
-Return -ENOMEM from udf_find_entry() when unable to allocate
fname and udf_get_filename() error
-udf_find_entry() callsites are also updated:
udf_lookup(), udf_rmdir(), udf_unlink() and udf_rename()

Suggested-by: Jan Kara 
Signed-off-by: Fabian Frederick 
---
V2:
-Don't set error in udf_readdir()
-Improve code flow
-Merge if(nfi) if (!inode) in udf_rename()

 fs/udf/namei.c | 70 ++
 1 file changed, 51 insertions(+), 19 deletions(-)

diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index dd648b7..891c067 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -167,8 +167,11 @@ static struct fileIdentDesc *udf_find_entry(struct inode 
*dir,
fibh->soffset = fibh->eoffset = f_pos & (sb->s_blocksize - 1);
if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
if (inode_bmap(dir, f_pos >> sb->s_blocksize_bits, ,
-   , , ) != (EXT_RECORDED_ALLOCATED >> 30))
+   , , ) != (EXT_RECORDED_ALLOCATED >> 30)) {
+   fi = ERR_PTR(-EINVAL);
goto out_err;
+   }
+
block = udf_get_lb_pblock(sb, , offset);
if ((++offset << sb->s_blocksize_bits) < elen) {
if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
@@ -179,19 +182,25 @@ static struct fileIdentDesc *udf_find_entry(struct inode 
*dir,
offset = 0;
 
fibh->sbh = fibh->ebh = udf_tread(sb, block);
-   if (!fibh->sbh)
+   if (!fibh->sbh) {
+   fi = ERR_PTR(-EINVAL);
goto out_err;
+   }
}
 
fname = kmalloc(UDF_NAME_LEN, GFP_NOFS);
-   if (!fname)
+   if (!fname) {
+   fi = ERR_PTR(-ENOMEM);
goto out_err;
+   }
 
while (f_pos < size) {
fi = udf_fileident_read(dir, _pos, fibh, cfi, , ,
, );
-   if (!fi)
+   if (!fi) {
+   fi = ERR_PTR(-EINVAL);
goto out_err;
+   }
 
liu = le16_to_cpu(cfi->lengthOfImpUse);
lfi = cfi->lengthFileIdent;
@@ -234,13 +243,18 @@ static struct fileIdentDesc *udf_find_entry(struct inode 
*dir,
continue;
 
flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
+   if (flen < 0) {
+   fi = ERR_PTR(flen);
+   goto out_err;
+   }
+
if ((flen >= 0) && udf_match(flen, fname, child->len,
child->name))
goto out_ok;
}
 
-out_err:
fi = NULL;
+out_err:
if (fibh->sbh != fibh->ebh)
brelse(fibh->ebh);
brelse(fibh->sbh);
@@ -257,6 +271,7 @@ static struct dentry *udf_lookup(struct inode *dir, struct 
dentry *dentry,
struct inode *inode = NULL;
struct fileIdentDesc cfi;
struct udf_fileident_bh fibh;
+   struct fileIdentDesc *fi;
 
if (dentry->d_name.len > UDF_NAME_LEN - 2)
return ERR_PTR(-ENAMETOOLONG);
@@ -276,7 +291,11 @@ static struct dentry *udf_lookup(struct inode *dir, struct 
dentry *dentry,
} else
 #endif /* UDF_RECOVERY */
 
-   if (udf_find_entry(dir, >d_name, , )) {
+   fi = udf_find_entry(dir, >d_name, , );
+   if (IS_ERR(fi))
+   return ERR_CAST(fi);
+
+   if (fi) {
struct kernel_lb_addr loc;
 
if (fibh.sbh != fibh.ebh)
@@ -774,8 +793,11 @@ static int udf_rmdir(struct inode *dir, struct dentry 
*dentry)
 
retval = -ENOENT;
fi = udf_find_entry(dir, >d_name, , );
-   if (!fi)
+   if (IS_ERR_OR_NULL(fi)) {
+   if (fi)
+   retval = PTR_ERR(fi);
goto out;
+   }
 
retval = -EIO;
tloc = lelb_to_cpu(cfi.icb.extLocation);
@@ -817,8 +839,12 @@ static int udf_unlink(struct inode *dir, struct dentry 
*dentry)
 
retval = -ENOENT;
fi = udf_find_entry(dir, >d_name, , );
-   if (!fi)
+
+   if (IS_ERR_OR_NULL(fi)) {
+   if (fi)
+   retval = PTR_ERR(fi);
goto out;
+   }
 
retval = -EIO;
tloc = lelb_to_cpu(cfi.icb.extLocation);
@@ -1047,24 +1073,30 @@ static int udf_rename(struct inode *old_dir, struct 
dentry *old_dentry,
struct udf_inode_info *old_iinfo = UDF_I(old_inode);
 
ofi = udf_find_entry(old_dir, _dentry->d_name, , );
-   if (ofi) {
-   if (ofibh.sbh != ofibh.ebh)
-   brelse(ofibh.ebh);
- 

[PATCH V2 3/9 linux-next] udf: unicode: update function name in comments

2015-04-08 Thread Fabian Frederick
Signed-off-by: Fabian Frederick 
---
 fs/udf/unicode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index e2c079a..41c3bef 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -77,7 +77,7 @@ static void udf_build_ustr_exact(struct ustr *dest, dstring 
*ptr, int exactsize)
 }
 
 /*
- * udf_ocu_to_utf8
+ * udf_CS0toUTF8
  *
  * PURPOSE
  * Convert OSTA Compressed Unicode to the UTF-8 equivalent.
@@ -149,7 +149,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr 
*ocu_i)
 
 /*
  *
- * udf_utf8_to_ocu
+ * udf_UTF8toCS0
  *
  * PURPOSE
  * Convert UTF-8 to the OSTA Compressed Unicode equivalent.
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 6/9 linux-next] udf: bug on exotic flag in udf_get_filename()

2015-04-08 Thread Fabian Frederick
UDF volume is only mounted with UDF_FLAG_UTF8
or UDF_FLAG_NLS_MAP (see fill udf_fill_super().
BUG() if we have something different in udf_get_filename()

Suggested-by: Jan Kara 
Signed-off-by: Fabian Frederick 
---
 fs/udf/unicode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 488a838..f37123b 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -365,7 +365,7 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
goto out2;
}
} else
-   goto out2;
+   BUG();
 
ret = udf_translate_to_linux(dname, dlen,
 filename->u_name, filename->u_len,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 9/9 linux-next] udf: add function definition for udf_find_entry()

2015-04-08 Thread Fabian Frederick
Function return changed lately.

Suggested-by: Jan Kara 
Signed-off-by: Fabian Frederick 
---
 fs/udf/namei.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 891c067..1f8e4d0 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -138,6 +138,18 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc 
*cfi,
return 0;
 }
 
+/**
+ * udf_find_entry - find entry in given directory.
+ *
+ * @dir:   directory inode
+ * @child: qstr of the name
+ * @fibh:  udf file identifier buffer head
+ * @cfi:   current file identifier descriptor
+ *
+ * Return pointer to file identifier, NULL when nothing found or error code.
+ */
+
+
 static struct fileIdentDesc *udf_find_entry(struct inode *dir,
const struct qstr *child,
struct udf_fileident_bh *fibh,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 6/9 linux-next] udf: bug on exotic flag in udf_get_filename()

2015-04-08 Thread Fabian Frederick
UDF volume is only mounted with UDF_FLAG_UTF8
or UDF_FLAG_NLS_MAP (see fill udf_fill_super().
BUG() if we have something different in udf_get_filename()

Suggested-by: Jan Kara j...@suse.cz
Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/udf/unicode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 488a838..f37123b 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -365,7 +365,7 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
goto out2;
}
} else
-   goto out2;
+   BUG();
 
ret = udf_translate_to_linux(dname, dlen,
 filename-u_name, filename-u_len,
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 9/9 linux-next] udf: add function definition for udf_find_entry()

2015-04-08 Thread Fabian Frederick
Function return changed lately.

Suggested-by: Jan Kara j...@suse.cz
Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/udf/namei.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 891c067..1f8e4d0 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -138,6 +138,18 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc 
*cfi,
return 0;
 }
 
+/**
+ * udf_find_entry - find entry in given directory.
+ *
+ * @dir:   directory inode
+ * @child: qstr of the name
+ * @fibh:  udf file identifier buffer head
+ * @cfi:   current file identifier descriptor
+ *
+ * Return pointer to file identifier, NULL when nothing found or error code.
+ */
+
+
 static struct fileIdentDesc *udf_find_entry(struct inode *dir,
const struct qstr *child,
struct udf_fileident_bh *fibh,
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 8/9 linux-next] udf: propagate udf_get_filename() errors

2015-04-08 Thread Fabian Frederick
-Return udf_get_filename() error from udf_readdir()
-Return -ENOMEM from udf_find_entry() when unable to allocate
fname and udf_get_filename() error
-udf_find_entry() callsites are also updated:
udf_lookup(), udf_rmdir(), udf_unlink() and udf_rename()

Suggested-by: Jan Kara j...@suse.cz
Signed-off-by: Fabian Frederick f...@skynet.be
---
V2:
-Don't set error in udf_readdir()
-Improve code flow
-Merge if(nfi) if (!inode) in udf_rename()

 fs/udf/namei.c | 70 ++
 1 file changed, 51 insertions(+), 19 deletions(-)

diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index dd648b7..891c067 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -167,8 +167,11 @@ static struct fileIdentDesc *udf_find_entry(struct inode 
*dir,
fibh-soffset = fibh-eoffset = f_pos  (sb-s_blocksize - 1);
if (dinfo-i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
if (inode_bmap(dir, f_pos  sb-s_blocksize_bits, epos,
-   eloc, elen, offset) != (EXT_RECORDED_ALLOCATED  30))
+   eloc, elen, offset) != (EXT_RECORDED_ALLOCATED  30)) {
+   fi = ERR_PTR(-EINVAL);
goto out_err;
+   }
+
block = udf_get_lb_pblock(sb, eloc, offset);
if ((++offset  sb-s_blocksize_bits)  elen) {
if (dinfo-i_alloc_type == ICBTAG_FLAG_AD_SHORT)
@@ -179,19 +182,25 @@ static struct fileIdentDesc *udf_find_entry(struct inode 
*dir,
offset = 0;
 
fibh-sbh = fibh-ebh = udf_tread(sb, block);
-   if (!fibh-sbh)
+   if (!fibh-sbh) {
+   fi = ERR_PTR(-EINVAL);
goto out_err;
+   }
}
 
fname = kmalloc(UDF_NAME_LEN, GFP_NOFS);
-   if (!fname)
+   if (!fname) {
+   fi = ERR_PTR(-ENOMEM);
goto out_err;
+   }
 
while (f_pos  size) {
fi = udf_fileident_read(dir, f_pos, fibh, cfi, epos, eloc,
elen, offset);
-   if (!fi)
+   if (!fi) {
+   fi = ERR_PTR(-EINVAL);
goto out_err;
+   }
 
liu = le16_to_cpu(cfi-lengthOfImpUse);
lfi = cfi-lengthFileIdent;
@@ -234,13 +243,18 @@ static struct fileIdentDesc *udf_find_entry(struct inode 
*dir,
continue;
 
flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
+   if (flen  0) {
+   fi = ERR_PTR(flen);
+   goto out_err;
+   }
+
if ((flen = 0)  udf_match(flen, fname, child-len,
child-name))
goto out_ok;
}
 
-out_err:
fi = NULL;
+out_err:
if (fibh-sbh != fibh-ebh)
brelse(fibh-ebh);
brelse(fibh-sbh);
@@ -257,6 +271,7 @@ static struct dentry *udf_lookup(struct inode *dir, struct 
dentry *dentry,
struct inode *inode = NULL;
struct fileIdentDesc cfi;
struct udf_fileident_bh fibh;
+   struct fileIdentDesc *fi;
 
if (dentry-d_name.len  UDF_NAME_LEN - 2)
return ERR_PTR(-ENAMETOOLONG);
@@ -276,7 +291,11 @@ static struct dentry *udf_lookup(struct inode *dir, struct 
dentry *dentry,
} else
 #endif /* UDF_RECOVERY */
 
-   if (udf_find_entry(dir, dentry-d_name, fibh, cfi)) {
+   fi = udf_find_entry(dir, dentry-d_name, fibh, cfi);
+   if (IS_ERR(fi))
+   return ERR_CAST(fi);
+
+   if (fi) {
struct kernel_lb_addr loc;
 
if (fibh.sbh != fibh.ebh)
@@ -774,8 +793,11 @@ static int udf_rmdir(struct inode *dir, struct dentry 
*dentry)
 
retval = -ENOENT;
fi = udf_find_entry(dir, dentry-d_name, fibh, cfi);
-   if (!fi)
+   if (IS_ERR_OR_NULL(fi)) {
+   if (fi)
+   retval = PTR_ERR(fi);
goto out;
+   }
 
retval = -EIO;
tloc = lelb_to_cpu(cfi.icb.extLocation);
@@ -817,8 +839,12 @@ static int udf_unlink(struct inode *dir, struct dentry 
*dentry)
 
retval = -ENOENT;
fi = udf_find_entry(dir, dentry-d_name, fibh, cfi);
-   if (!fi)
+
+   if (IS_ERR_OR_NULL(fi)) {
+   if (fi)
+   retval = PTR_ERR(fi);
goto out;
+   }
 
retval = -EIO;
tloc = lelb_to_cpu(cfi.icb.extLocation);
@@ -1047,24 +1073,30 @@ static int udf_rename(struct inode *old_dir, struct 
dentry *old_dentry,
struct udf_inode_info *old_iinfo = UDF_I(old_inode);
 
ofi = udf_find_entry(old_dir, old_dentry-d_name, ofibh, ocfi);
-   if (ofi) {
-   if (ofibh.sbh != ofibh.ebh)
-   brelse(ofibh.ebh);
-   brelse(ofibh.sbh

[PATCH V2 3/9 linux-next] udf: unicode: update function name in comments

2015-04-08 Thread Fabian Frederick
Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/udf/unicode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index e2c079a..41c3bef 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -77,7 +77,7 @@ static void udf_build_ustr_exact(struct ustr *dest, dstring 
*ptr, int exactsize)
 }
 
 /*
- * udf_ocu_to_utf8
+ * udf_CS0toUTF8
  *
  * PURPOSE
  * Convert OSTA Compressed Unicode to the UTF-8 equivalent.
@@ -149,7 +149,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr 
*ocu_i)
 
 /*
  *
- * udf_utf8_to_ocu
+ * udf_UTF8toCS0
  *
  * PURPOSE
  * Convert UTF-8 to the OSTA Compressed Unicode equivalent.
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 0/9 linux-next] udf: improve error management

2015-04-08 Thread Fabian Frederick
This small patchset tries to solve error management in udf
unicode and callsites.

Thanks a lot to Jan Kara for all suggestions and code reviewing !

V2:
-Cc to lkml
-Patch 2 and 8 updated (See commit log)
-Adding patch 9

Of course this patchset would need extended testing.

Fabian Frederick (9):
  udf: udf_get_filename(): return -ENOMEM when allocation fails
  udf: remove unneccessary test in udf_build_ustr_exact()
  udf: unicode: update function name in comments
  udf: improve error management in udf_CS0toUTF8()
  udf: improve error management in udf_CS0toNLS()
  udf: bug on exotic flag in udf_get_filename()
  udf: return error when newIndex is 0 in udf_translate_to_linux()
  udf: propagate udf_get_filename() errors
  udf: add function definition for udf_find_entry()

 fs/udf/dir.c |  2 +-
 fs/udf/namei.c   | 85 +++-
 fs/udf/super.c   | 23 +--
 fs/udf/symlink.c |  3 ++
 fs/udf/unicode.c | 52 +-
 5 files changed, 109 insertions(+), 56 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 7/9 linux-next] udf: return error when newIndex is 0 in udf_translate_to_linux()

2015-04-08 Thread Fabian Frederick
udf_get_filename() and its callsites considered 0 as an error
without propagating an error value.

udf_translate_to_linux() now returns -EINVAL when newIndex is 0.
other functions are updated accordingly.

Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/udf/dir.c | 2 +-
 fs/udf/namei.c   | 2 +-
 fs/udf/unicode.c | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/udf/dir.c b/fs/udf/dir.c
index fcf227e..541d9c6 100644
--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -168,7 +168,7 @@ static int udf_readdir(struct file *file, struct 
dir_context *ctx)
}
 
flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
-   if (flen = 0)
+   if (flen  0)
continue;
 
tloc = lelb_to_cpu(cfi.icb.extLocation);
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 59b340c..dd648b7 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -234,7 +234,7 @@ static struct fileIdentDesc *udf_find_entry(struct inode 
*dir,
continue;
 
flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
-   if ((flen  0)  udf_match(flen, fname, child-len,
+   if ((flen = 0)  udf_match(flen, fname, child-len,
child-name))
goto out_ok;
}
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index f37123b..3b1efbb 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -333,7 +333,7 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
 uint8_t *dname, int dlen)
 {
struct ustr *filename, *unifilename;
-   int ret = 0;
+   int ret;
 
if (!slen)
return -EIO;
@@ -492,5 +492,5 @@ static int udf_translate_to_linux(uint8_t *newName, int 
newLen,
}
}
 
-   return newIndex;
+   return newIndex ? : -EINVAL;
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 2/9 linux-next] udf: remove unnecessary test in udf_build_ustr_exact()

2015-04-08 Thread Fabian Frederick
We can remove parameter checks:

udf_build_ustr_exact() is only called by udf_get_filename()
which now assures dest is not NULL

udf_find_entry() and udf_readdir() call udf_get_filename()
after checking sname
udf_symlink_filler() calls udf_pc_to_char() with sname=kmap(page).

udf_find_entry() and udf_readdir() call udf_get_filename with UDF_NAME_LEN
udf_pc_to_char() with PAGE_SIZE

Suggested-by: Jan Kara j...@suse.cz
Signed-off-by: Fabian Frederick f...@skynet.be
---
V2: Return -EIO if slen = 0 in udf_get_filename()
(suggested by Jan Kara)

 fs/udf/unicode.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 4911c1d..e2c079a 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -68,17 +68,12 @@ int udf_build_ustr(struct ustr *dest, dstring *ptr, int 
size)
 /*
  * udf_build_ustr_exact
  */
-static int udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize)
+static void udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int 
exactsize)
 {
-   if ((!dest) || (!ptr) || (!exactsize))
-   return -1;
-
memset(dest, 0, sizeof(struct ustr));
dest-u_cmpID = ptr[0];
dest-u_len = exactsize - 1;
memcpy(dest-u_name, ptr + 1, exactsize - 1);
-
-   return 0;
 }
 
 /*
@@ -340,6 +335,9 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
struct ustr *filename, *unifilename;
int ret = 0;
 
+   if (!slen)
+   return -EIO;
+
filename = kmalloc(sizeof(struct ustr), GFP_NOFS);
if (!filename)
return -ENOMEM;
@@ -350,9 +348,7 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
goto out1;
}
 
-   if (udf_build_ustr_exact(unifilename, sname, slen))
-   goto out2;
-
+   udf_build_ustr_exact(unifilename, sname, slen);
if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
if (!udf_CS0toUTF8(filename, unifilename)) {
udf_debug(Failed in udf_get_filename: sname = %s\n,
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 1/9 linux-next] udf: udf_get_filename(): return -ENOMEM when allocation fails

2015-04-08 Thread Fabian Frederick
udf_pc_to_char() now returns error accordingly.
udf_readdir() and udf_find_entry() process is done on
positive result.

Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/udf/dir.c |  2 +-
 fs/udf/namei.c   |  3 ++-
 fs/udf/symlink.c |  3 +++
 fs/udf/unicode.c | 12 +++-
 4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/fs/udf/dir.c b/fs/udf/dir.c
index 541a12b..fcf227e 100644
--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -168,7 +168,7 @@ static int udf_readdir(struct file *file, struct 
dir_context *ctx)
}
 
flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
-   if (!flen)
+   if (flen = 0)
continue;
 
tloc = lelb_to_cpu(cfi.icb.extLocation);
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index fbf3d90..59b340c 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -234,7 +234,8 @@ static struct fileIdentDesc *udf_find_entry(struct inode 
*dir,
continue;
 
flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
-   if (flen  udf_match(flen, fname, child-len, child-name))
+   if ((flen  0)  udf_match(flen, fname, child-len,
+   child-name))
goto out_ok;
}
 
diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c
index 8dfbc40..862535b 100644
--- a/fs/udf/symlink.c
+++ b/fs/udf/symlink.c
@@ -82,6 +82,9 @@ static int udf_pc_to_char(struct super_block *sb, unsigned 
char *from,
comp_len = udf_get_filename(sb, pc-componentIdent,
pc-lengthComponentIdent,
p, tolen);
+   if (comp_len  0)
+   return comp_len;
+
p += comp_len;
tolen -= comp_len;
if (tolen == 0)
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index b84fee3..4911c1d 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -338,15 +338,17 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
 uint8_t *dname, int dlen)
 {
struct ustr *filename, *unifilename;
-   int len = 0;
+   int ret = 0;
 
filename = kmalloc(sizeof(struct ustr), GFP_NOFS);
if (!filename)
-   return 0;
+   return -ENOMEM;
 
unifilename = kmalloc(sizeof(struct ustr), GFP_NOFS);
-   if (!unifilename)
+   if (!unifilename) {
+   ret = -ENOMEM;
goto out1;
+   }
 
if (udf_build_ustr_exact(unifilename, sname, slen))
goto out2;
@@ -367,14 +369,14 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
} else
goto out2;
 
-   len = udf_translate_to_linux(dname, dlen,
+   ret = udf_translate_to_linux(dname, dlen,
 filename-u_name, filename-u_len,
 unifilename-u_name, unifilename-u_len);
 out2:
kfree(unifilename);
 out1:
kfree(filename);
-   return len;
+   return ret;
 }
 
 int udf_put_filename(struct super_block *sb, const uint8_t *sname,
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 4/9 linux-next] udf: improve error management in udf_CS0toUTF8()

2015-04-08 Thread Fabian Frederick
udf_CS0toUTF8() now returns -EINVAL on error.
udf_load_pvoldesc() and udf_get_filename() do the same.

Suggested-by: Jan Kara j...@suse.cz
Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/udf/super.c   | 23 ++-
 fs/udf/unicode.c |  9 +
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 6299f34..c6a8f5f 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -927,17 +927,22 @@ static int udf_load_pvoldesc(struct super_block *sb, 
sector_t block)
 #endif
}
 
-   if (!udf_build_ustr(instr, pvoldesc-volIdent, 32))
-   if (udf_CS0toUTF8(outstr, instr)) {
-   strncpy(UDF_SB(sb)-s_volume_ident, outstr-u_name,
-   outstr-u_len  31 ? 31 : outstr-u_len);
-   udf_debug(volIdent[] = '%s'\n,
- UDF_SB(sb)-s_volume_ident);
-   }
+   if (!udf_build_ustr(instr, pvoldesc-volIdent, 32)) {
+   ret = udf_CS0toUTF8(outstr, instr);
+   if (ret  0)
+   goto out_bh;
+
+   strncpy(UDF_SB(sb)-s_volume_ident, outstr-u_name,
+   outstr-u_len  31 ? 31 : outstr-u_len);
+   udf_debug(volIdent[] = '%s'\n, UDF_SB(sb)-s_volume_ident);
+   }
 
if (!udf_build_ustr(instr, pvoldesc-volSetIdent, 128))
-   if (udf_CS0toUTF8(outstr, instr))
-   udf_debug(volSetIdent[] = '%s'\n, outstr-u_name);
+   ret = udf_CS0toUTF8(outstr, instr);
+   if (ret  0)
+   goto out_bh;
+
+   udf_debug(volSetIdent[] = '%s'\n, outstr-u_name);
 
ret = 0;
 out_bh:
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 41c3bef..9008a36 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -89,7 +89,7 @@ static void udf_build_ustr_exact(struct ustr *dest, dstring 
*ptr, int exactsize)
  * both of type struct ustr *
  *
  * POST-CONDITIONS
- * returnZero on success.
+ * return= 0 on success.
  *
  * HISTORY
  * November 12, 1997 - Andrew E. Mileski
@@ -104,7 +104,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr 
*ocu_i)
ocu_len = ocu_i-u_len;
if (ocu_len == 0) {
memset(utf_o, 0, sizeof(struct ustr));
-   return 0;
+   return -EINVAL;
}
 
cmp_id = ocu_i-u_cmpID;
@@ -112,7 +112,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr 
*ocu_i)
memset(utf_o, 0, sizeof(struct ustr));
pr_err(unknown compression code (%d) stri=%s\n,
   cmp_id, ocu_i-u_name);
-   return 0;
+   return -EINVAL;
}
 
ocu = ocu_i-u_name;
@@ -350,7 +350,8 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
 
udf_build_ustr_exact(unifilename, sname, slen);
if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
-   if (!udf_CS0toUTF8(filename, unifilename)) {
+   ret = udf_CS0toUTF8(filename, unifilename);
+   if (ret  0) {
udf_debug(Failed in udf_get_filename: sname = %s\n,
  sname);
goto out2;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 5/9 linux-next] udf: improve error management in udf_CS0toNLS()

2015-04-08 Thread Fabian Frederick
Only callsite udf_get_filename() now returns
error code as well.

Suggested-by: Jan Kara j...@suse.cz
Signed-off-by: Fabian Frederick f...@skynet.be
---
 fs/udf/unicode.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 9008a36..488a838 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -257,7 +257,7 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr 
*utf_o,
ocu_len = ocu_i-u_len;
if (ocu_len == 0) {
memset(utf_o, 0, sizeof(struct ustr));
-   return 0;
+   return -EINVAL;
}
 
cmp_id = ocu_i-u_cmpID;
@@ -265,7 +265,7 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr 
*utf_o,
memset(utf_o, 0, sizeof(struct ustr));
pr_err(unknown compression code (%d) stri=%s\n,
   cmp_id, ocu_i-u_name);
-   return 0;
+   return -EINVAL;
}
 
ocu = ocu_i-u_name;
@@ -357,8 +357,9 @@ int udf_get_filename(struct super_block *sb, uint8_t 
*sname, int slen,
goto out2;
}
} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
-   if (!udf_CS0toNLS(UDF_SB(sb)-s_nls_map, filename,
- unifilename)) {
+   ret = udf_CS0toNLS(UDF_SB(sb)-s_nls_map, filename,
+  unifilename);
+   if (ret  0) {
udf_debug(Failed in udf_get_filename: sname = %s\n,
  sname);
goto out2;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 4/9 net-next] ipv6: replace if/BUG by BUG_ON

2015-04-03 Thread Fabian Frederick


> On 31 March 2015 at 17:17 David Miller  wrote:
>
>
> From: YOSHIFUJI Hideaki 
> Date: Tue, 31 Mar 2015 12:50:27 +0900
>
> > Hi,
> >
> > Fabian Frederick wrote:
> >> Signed-off-by: Fabian Frederick 
> >> ---
> >>  net/ipv6/addrconf.c                     | 3 +--
> >>  net/ipv6/esp6.c                         | 3 +--
> >>  net/ipv6/netfilter/nf_conntrack_reasm.c | 3 +--
> >>  3 files changed, 3 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> >> index 2660263..e205918 100644
> >> --- a/net/ipv6/addrconf.c
> >> +++ b/net/ipv6/addrconf.c
> >> @@ -4805,8 +4805,7 @@ static int inet6_set_link_af(struct net_device *dev,
> >> const struct nlattr *nla)
> >>    if (!idev)
> >>            return -EAFNOSUPPORT;
> >> 
> >> -  if (nla_parse_nested(tb, IFLA_INET6_MAX, nla, NULL) < 0)
> >> -          BUG();
> >> +  BUG_ON(nla_parse_nested(tb, IFLA_INET6_MAX, nla, NULL) < 0);
> >> 
> >
> > NACK, I do not prefer using BUG_ON() with side effects.
>
> Agreed, I do not like these changes at all and will not be
> applying them.

I guess patches like these should be reverted then ?

e3f0b86b996d
"ipv6: Use BUG_ON"

8242fc33925c
"net: ipv6: Use BUG_ON"

Some existing BUG_ON() as well ? ; eg second one in net/decnet/dn_rules.c:
void __init dn_fib_rules_init(void)
{
        dn_fib_rules_ops =
                fib_rules_register(_fib_rules_ops_template, _net);
        BUG_ON(IS_ERR(dn_fib_rules_ops));
        BUG_ON(fib_default_rule_add(dn_fib_rules_ops, 0x7fff,
                                    RT_TABLE_MAIN, 0));
}

Regards,
Fabian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 linux-next] Btrfs: use BTRFS_COMPRESS_NONE instead of 0

2015-04-03 Thread Fabian Frederick
cow_file_range_inline() was called with 0 instead of actual definition.

btrfs_finish_ordered_io() initialized compress_type with 0 as well.
(Thanks to David Sterba for suggesting this update).

Signed-off-by: Fabian Frederick 
---

V2: also replace 0 in btrfs_finish_ordered_io()

 fs/btrfs/inode.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5b6fbae..2f064d7 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -524,7 +524,8 @@ cont:
 * to make an uncompressed inline extent.
 */
ret = cow_file_range_inline(root, inode, start, end,
-   0, 0, NULL);
+   0, BTRFS_COMPRESS_NONE,
+   NULL);
} else {
/* try making a compressed inline extent */
ret = cow_file_range_inline(root, inode, start, end,
@@ -943,8 +944,8 @@ static noinline int cow_file_range(struct inode *inode,
 
if (start == 0) {
/* lets try to make an inline extent */
-   ret = cow_file_range_inline(root, inode, start, end, 0, 0,
-   NULL);
+   ret = cow_file_range_inline(root, inode, start, end, 0,
+   BTRFS_COMPRESS_NONE, NULL);
if (ret == 0) {
extent_clear_unlock_delalloc(inode, start, end, NULL,
 EXTENT_LOCKED | EXTENT_DELALLOC |
@@ -2793,7 +2794,7 @@ static int btrfs_finish_ordered_io(struct 
btrfs_ordered_extent *ordered_extent)
struct extent_io_tree *io_tree = _I(inode)->io_tree;
struct extent_state *cached_state = NULL;
struct new_sa_defrag_extent *new = NULL;
-   int compress_type = 0;
+   int compress_type = BTRFS_COMPRESS_NONE;
int ret = 0;
u64 logical_len = ordered_extent->len;
bool nolock;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 4/9 net-next] ipv6: replace if/BUG by BUG_ON

2015-04-03 Thread Fabian Frederick


 On 31 March 2015 at 17:17 David Miller da...@davemloft.net wrote:


 From: YOSHIFUJI Hideaki hideaki.yoshif...@miraclelinux.com
 Date: Tue, 31 Mar 2015 12:50:27 +0900

  Hi,
 
  Fabian Frederick wrote:
  Signed-off-by: Fabian Frederick f...@skynet.be
  ---
   net/ipv6/addrconf.c                     | 3 +--
   net/ipv6/esp6.c                         | 3 +--
   net/ipv6/netfilter/nf_conntrack_reasm.c | 3 +--
   3 files changed, 3 insertions(+), 6 deletions(-)
 
  diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
  index 2660263..e205918 100644
  --- a/net/ipv6/addrconf.c
  +++ b/net/ipv6/addrconf.c
  @@ -4805,8 +4805,7 @@ static int inet6_set_link_af(struct net_device *dev,
  const struct nlattr *nla)
     if (!idev)
             return -EAFNOSUPPORT;
  
  -  if (nla_parse_nested(tb, IFLA_INET6_MAX, nla, NULL)  0)
  -          BUG();
  +  BUG_ON(nla_parse_nested(tb, IFLA_INET6_MAX, nla, NULL)  0);
  
 
  NACK, I do not prefer using BUG_ON() with side effects.

 Agreed, I do not like these changes at all and will not be
 applying them.

I guess patches like these should be reverted then ?

e3f0b86b996d
ipv6: Use BUG_ON

8242fc33925c
net: ipv6: Use BUG_ON

Some existing BUG_ON() as well ? ; eg second one in net/decnet/dn_rules.c:
void __init dn_fib_rules_init(void)
{
        dn_fib_rules_ops =
                fib_rules_register(dn_fib_rules_ops_template, init_net);
        BUG_ON(IS_ERR(dn_fib_rules_ops));
        BUG_ON(fib_default_rule_add(dn_fib_rules_ops, 0x7fff,
                                    RT_TABLE_MAIN, 0));
}

Regards,
Fabian
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 linux-next] Btrfs: use BTRFS_COMPRESS_NONE instead of 0

2015-04-03 Thread Fabian Frederick
cow_file_range_inline() was called with 0 instead of actual definition.

btrfs_finish_ordered_io() initialized compress_type with 0 as well.
(Thanks to David Sterba for suggesting this update).

Signed-off-by: Fabian Frederick f...@skynet.be
---

V2: also replace 0 in btrfs_finish_ordered_io()

 fs/btrfs/inode.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5b6fbae..2f064d7 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -524,7 +524,8 @@ cont:
 * to make an uncompressed inline extent.
 */
ret = cow_file_range_inline(root, inode, start, end,
-   0, 0, NULL);
+   0, BTRFS_COMPRESS_NONE,
+   NULL);
} else {
/* try making a compressed inline extent */
ret = cow_file_range_inline(root, inode, start, end,
@@ -943,8 +944,8 @@ static noinline int cow_file_range(struct inode *inode,
 
if (start == 0) {
/* lets try to make an inline extent */
-   ret = cow_file_range_inline(root, inode, start, end, 0, 0,
-   NULL);
+   ret = cow_file_range_inline(root, inode, start, end, 0,
+   BTRFS_COMPRESS_NONE, NULL);
if (ret == 0) {
extent_clear_unlock_delalloc(inode, start, end, NULL,
 EXTENT_LOCKED | EXTENT_DELALLOC |
@@ -2793,7 +2794,7 @@ static int btrfs_finish_ordered_io(struct 
btrfs_ordered_extent *ordered_extent)
struct extent_io_tree *io_tree = BTRFS_I(inode)-io_tree;
struct extent_state *cached_state = NULL;
struct new_sa_defrag_extent *new = NULL;
-   int compress_type = 0;
+   int compress_type = BTRFS_COMPRESS_NONE;
int ret = 0;
u64 logical_len = ordered_extent-len;
bool nolock;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 7/9 net-next] sunrpc: replace if/BUG by BUG_ON

2015-03-31 Thread Fabian Frederick


> On 31 March 2015 at 21:11 Julia Lawall  wrote:
>
>
>
>
> On Tue, 31 Mar 2015, Fabian Frederick wrote:
>
> >
> >
> > > On 30 March 2015 at 23:25 "J. Bruce Fields"  wrote:
> > >
> > >
> > > Huh, I thought this wasn't recommended:
> > >
> > >       http://lkml.kernel.org/r/20040828125816.206ef7fa.a...@osdl.org
> > >
> > >       "I'd prefer that we not move code which has side-effects into
> > >       BUG_ONs"
> >
> > Thanks for the link, I wasn't aware of that problem. Maybe we should add
> > some
> > documentation and fix coccinelle detection then ?
>
> Maybe the comment in the Coccinelle rule could just be made more clear? 

Fair enough. Current "WARNING: Use BUG_ON" looks misleading.
Maybe some BUG_ON(function()) detection script would be interesting as well ?
There are nearly 5000 BUG_ON() in drivers branch only ... 

Regards,
Fabian
> The only practical choices are to ignore all function calls and to allow
> all fuction calls, since Coccinelle doesn't know which ones have side
> effects.
>
> julia
>
> > Regards,
> > Fabian
> >
> > >
> > > --b.
> > >
> > > On Mon, Mar 30, 2015 at 11:13:15PM +0200, Fabian Frederick wrote:
> > > > Signed-off-by: Fabian Frederick 
> > > > ---
> > > >  net/sunrpc/auth_gss/svcauth_gss.c | 9 +++--
> > > >  net/sunrpc/svc_xprt.c             | 3 +--
> > > >  2 files changed, 4 insertions(+), 8 deletions(-)
> > > >
> > > > diff --git a/net/sunrpc/auth_gss/svcauth_gss.c
> > > > b/net/sunrpc/auth_gss/svcauth_gss.c
> > > > index 1095be9..09f8a1c6 100644
> > > > --- a/net/sunrpc/auth_gss/svcauth_gss.c
> > > > +++ b/net/sunrpc/auth_gss/svcauth_gss.c
> > > > @@ -840,11 +840,9 @@ unwrap_integ_data(struct svc_rqst *rqstp, struct
> > > > xdr_buf *buf, u32 seq, struct g
> > > >             return stat;
> > > >     if (integ_len > buf->len)
> > > >             return stat;
> > > > -   if (xdr_buf_subsegment(buf, _buf, 0, integ_len))
> > > > -           BUG();
> > > > +   BUG_ON(xdr_buf_subsegment(buf, _buf, 0, integ_len));
> > > >     /* copy out mic... */
> > > > -   if (read_u32_from_xdr_buf(buf, integ_len, ))
> > > > -           BUG();
> > > > +   BUG_ON(read_u32_from_xdr_buf(buf, integ_len, ));
> > > >     if (mic.len > RPC_MAX_AUTH_SIZE)
> > > >             return stat;
> > > >     mic.data = kmalloc(mic.len, GFP_KERNEL);
> > > > @@ -1595,8 +1593,7 @@ svcauth_gss_wrap_resp_integ(struct svc_rqst
> > > > *rqstp)
> > > >     BUG_ON(integ_len % 4);
> > > >     *p++ = htonl(integ_len);
> > > >     *p++ = htonl(gc->gc_seq);
> > > > -   if (xdr_buf_subsegment(resbuf, _buf, integ_offset, integ_len))
> > > > -           BUG();
> > > > +   BUG_ON(xdr_buf_subsegment(resbuf, _buf, integ_offset,
> > > > integ_len));
> > > >     if (resbuf->tail[0].iov_base == NULL) {
> > > >             if (resbuf->head[0].iov_len + RPC_MAX_AUTH_SIZE > PAGE_SIZE)
> > > >                     goto out_err;
> > > > diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
> > > > index 163ac45..2f82e8b 100644
> > > > --- a/net/sunrpc/svc_xprt.c
> > > > +++ b/net/sunrpc/svc_xprt.c
> > > > @@ -960,8 +960,7 @@ static void svc_delete_xprt(struct svc_xprt *xprt)
> > > >     struct svc_deferred_req *dr;
> > > > 
> > > >     /* Only do this once */
> > > > -   if (test_and_set_bit(XPT_DEAD, >xpt_flags))
> > > > -           BUG();
> > > > +   BUG_ON(test_and_set_bit(XPT_DEAD, >xpt_flags));
> > > > 
> > > >     dprintk("svc: svc_delete_xprt(%p)\n", xprt);
> > > >     xprt->xpt_ops->xpo_detach(xprt);
> > > > --
> > > > 1.9.1
> >
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V3 linux-next] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally

2015-03-31 Thread Fabian Frederick
Currently checkpatch warns when asm/file.h is included and linux/file.h
exists. That conversion can be made when linux/file.h includes asm/file.h
which is not always the case.(See signal.h)

Signed-off-by: Fabian Frederick 
---
V3:
Only grep when $root/$checkfile exists (suggested by Joe Perches)
V2:
Apply suggestions by Joe Perches:
-Remove superfluous -i in grep
-Use $root to make checkpatch callable from anywhere
-Process all include cases.

 scripts/checkpatch.pl | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d54a814..c72e7ee 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4242,7 +4242,8 @@ sub process {
}
}
 
-#warn if  is #included and  is available (uses RAW 
line)
+# warn if  is #included and  is available and includes
+# itself  (uses RAW line)
if ($tree && $rawline =~ 
m{^.\s*\#\s*include\s*\}) {
my $file = "$1.h";
my $checkfile = "include/linux/$file";
@@ -4250,12 +4251,15 @@ sub process {
$realfile ne $checkfile &&
$1 !~ /$allowed_asm_includes/)
{
-   if ($realfile =~ m{^arch/}) {
-   CHK("ARCH_INCLUDE_LINUX",
-   "Consider using #include 
 instead of \n" . $herecurr);
-   } else {
-   WARN("INCLUDE_LINUX",
-"Use #include  
instead of \n" . $herecurr);
+   my $asminclude = `grep -Ec 
"#include\\s+" $root/$checkfile`;
+   if ($asminclude > 0) {
+   if ($realfile =~ m{^arch/}) {
+   CHK("ARCH_INCLUDE_LINUX",
+   "Consider using #include 
 instead of \n" . $herecurr);
+   } else {
+   WARN("INCLUDE_LINUX",
+"Use #include 
 instead of \n" . $herecurr);
+   }
}
}
}
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: linux-next: build warning after merge of the char-misc tree

2015-03-31 Thread Fabian Frederick


> On 27 March 2015 at 08:48 Stephen Rothwell  wrote:
>
>
> Hi all,
>
> After merging the char-misc tree, today's linux-next build (powerpc
> allyesconfig) produced this warning:
>
> In file included from include/linux/module.h:17:0,
>                  from drivers/uio/uio_pdrv_genirq.c:21:
> include/linux/moduleparam.h:326:22: warning: initialization discards 'const'
> qualifier from pointer target type
>   static const struct kparam_string __param_string_##name  \
>                       ^
> drivers/uio/uio_pdrv_genirq.c:260:1: note: in expansion of macro
> 'module_param_string'
>  module_param_string(of_id, uio_of_genirq_match[0].compatible, 128, 0);
>  ^
>
> Introduced by commit 4d8beff2ae07 ("uio: constify of_device_id array").

Hi Stephen,

Absolutely, my patch is wrong ; comment below explains struct is filled
afterwards.Sorry.
Greg, should I send you a revert or maybe we could standardize that driver ? (it
seems it's the only one to work that way).

static const struct of_device_id uio_of_genirq_match[] = {
        { /* This is filled with module_parm */ },
        { /* Sentinel */ },
};

Regards,
Fabian

> --
> Cheers,
> Stephen Rothwell                    s...@canb.auug.org.au
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC 1/1 linux-next] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally

2015-03-31 Thread Fabian Frederick


> On 30 March 2015 at 22:49 Joe Perches  wrote:
>
>
> On Mon, 2015-03-30 at 22:36 +0200, Fabian Frederick wrote:
> > Currently checkpatch warns when asm/file.h is included and linux/file.h
> > exists. That conversion can be made when linux/file.h includes asm/file.h
> > which is not always the case.(See signal.h)
> []
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
> > -#warn if  is #included and  is available (uses RAW
> > line)
> > +# warn if  is #included and  is available and
> > includes
> > +# itself  (uses RAW line)
> >             if ($tree && $rawline =~
> >m{^.\s*\#\s*include\s*\}) {
> >                     my $file = "$1.h";
> >                     my $checkfile = "include/linux/$file";
> > +                   my $asminclude = `grep -ci "#include "
> > $checkfile`;
>
> This won't work with #include forms like:
>       #include        
> or when checkpatch is run from somewhere other
> than the top of tree.
>
> why the -i?

Hi Joe,

This was just an RFC. I guess you're ok with the idea so I added your
suggestions in V2.

Regards,
Fabian

>
> >                     if (-f "$root/$checkfile" &&
> >                         $realfile ne $checkfile &&
> > -                       $1 !~ /$allowed_asm_includes/)
> > +                       $1 !~ /$allowed_asm_includes/ &&
> > +                       $asminclude > 0 )
> >                     {
> >                             if ($realfile =~ m{^arch/}) {
> >                                     CHK("ARCH_INCLUDE_LINUX",
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally

2015-03-31 Thread Fabian Frederick
Currently checkpatch warns when asm/file.h is included and linux/file.h
exists. That conversion can be made when linux/file.h includes asm/file.h
which is not always the case.(See signal.h)

Signed-off-by: Fabian Frederick 
---
V2:
Apply suggestions by Joe Perches:
-Remove superfluous -i in grep
-Use $root to make checkpatch callable from anywhere
-Process all include cases.

 scripts/checkpatch.pl | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d54a814..9e70cd7 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4242,13 +4242,16 @@ sub process {
}
}
 
-#warn if  is #included and  is available (uses RAW 
line)
+# warn if  is #included and  is available and includes
+# itself  (uses RAW line)
if ($tree && $rawline =~ 
m{^.\s*\#\s*include\s*\}) {
my $file = "$1.h";
my $checkfile = "include/linux/$file";
+   my $asminclude = `grep -Ec "#include\\s+" 
$root/$checkfile`;
if (-f "$root/$checkfile" &&
$realfile ne $checkfile &&
-   $1 !~ /$allowed_asm_includes/)
+   $1 !~ /$allowed_asm_includes/ &&
+   $asminclude > 0 )
{
if ($realfile =~ m{^arch/}) {
CHK("ARCH_INCLUDE_LINUX",
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 32/35 linux-next] clk: constify of_device_id array

2015-03-31 Thread Fabian Frederick


> On 27 March 2015 at 08:19 Stephen Boyd  wrote:
>
>
> On 03/22, Fabian Frederick wrote:
> >
> >
> > > On 18 March 2015 at 15:15 Michael Turquette  wrote:
> > >
> > >
> > > Quoting Fabian Frederick (2015-03-16 12:59:06)
> > > > of_device_id is always used as const.
> > > > (See driver.of_match_table and open firmware functions)
> > > >
> > > > Signed-off-by: Fabian Frederick 
> > >
> > > Acked-by: Michael Turquette 
> >
> > Thanks :)
> >
> > btw, something I forgot to mention in changelog is the __initdata ->
> > __initconst
> > for ti_clkdm_match_table[]
> >
> > I can send it again with a new changelog if necessary ...
> >
>
> Did you want us to take this through clk-next? If so please
> resend with the new commit text.

Of course :) I hope V2 is ok.

Regards,
Fabian
>
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 7/9 net-next] sunrpc: replace if/BUG by BUG_ON

2015-03-31 Thread Fabian Frederick


> On 30 March 2015 at 23:25 "J. Bruce Fields"  wrote:
>
>
> Huh, I thought this wasn't recommended:
>
>       http://lkml.kernel.org/r/20040828125816.206ef7fa.a...@osdl.org
>
>       "I'd prefer that we not move code which has side-effects into
>       BUG_ONs"

Thanks for the link, I wasn't aware of that problem. Maybe we should add some
documentation and fix coccinelle detection then ?

Regards,
Fabian

>
> --b.
>
> On Mon, Mar 30, 2015 at 11:13:15PM +0200, Fabian Frederick wrote:
> > Signed-off-by: Fabian Frederick 
> > ---
> >  net/sunrpc/auth_gss/svcauth_gss.c | 9 +++--
> >  net/sunrpc/svc_xprt.c             | 3 +--
> >  2 files changed, 4 insertions(+), 8 deletions(-)
> >
> > diff --git a/net/sunrpc/auth_gss/svcauth_gss.c
> > b/net/sunrpc/auth_gss/svcauth_gss.c
> > index 1095be9..09f8a1c6 100644
> > --- a/net/sunrpc/auth_gss/svcauth_gss.c
> > +++ b/net/sunrpc/auth_gss/svcauth_gss.c
> > @@ -840,11 +840,9 @@ unwrap_integ_data(struct svc_rqst *rqstp, struct
> > xdr_buf *buf, u32 seq, struct g
> >             return stat;
> >     if (integ_len > buf->len)
> >             return stat;
> > -   if (xdr_buf_subsegment(buf, _buf, 0, integ_len))
> > -           BUG();
> > +   BUG_ON(xdr_buf_subsegment(buf, _buf, 0, integ_len));
> >     /* copy out mic... */
> > -   if (read_u32_from_xdr_buf(buf, integ_len, ))
> > -           BUG();
> > +   BUG_ON(read_u32_from_xdr_buf(buf, integ_len, ));
> >     if (mic.len > RPC_MAX_AUTH_SIZE)
> >             return stat;
> >     mic.data = kmalloc(mic.len, GFP_KERNEL);
> > @@ -1595,8 +1593,7 @@ svcauth_gss_wrap_resp_integ(struct svc_rqst *rqstp)
> >     BUG_ON(integ_len % 4);
> >     *p++ = htonl(integ_len);
> >     *p++ = htonl(gc->gc_seq);
> > -   if (xdr_buf_subsegment(resbuf, _buf, integ_offset, integ_len))
> > -           BUG();
> > +   BUG_ON(xdr_buf_subsegment(resbuf, _buf, integ_offset, integ_len));
> >     if (resbuf->tail[0].iov_base == NULL) {
> >             if (resbuf->head[0].iov_len + RPC_MAX_AUTH_SIZE > PAGE_SIZE)
> >                     goto out_err;
> > diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
> > index 163ac45..2f82e8b 100644
> > --- a/net/sunrpc/svc_xprt.c
> > +++ b/net/sunrpc/svc_xprt.c
> > @@ -960,8 +960,7 @@ static void svc_delete_xprt(struct svc_xprt *xprt)
> >     struct svc_deferred_req *dr;
> > 
> >     /* Only do this once */
> > -   if (test_and_set_bit(XPT_DEAD, >xpt_flags))
> > -           BUG();
> > +   BUG_ON(test_and_set_bit(XPT_DEAD, >xpt_flags));
> > 
> >     dprintk("svc: svc_delete_xprt(%p)\n", xprt);
> >     xprt->xpt_ops->xpo_detach(xprt);
> > --
> > 1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 linux-next] clk: constify of_device_id array

2015-03-31 Thread Fabian Frederick
of_device_id is always used as const.
(See driver.of_match_table and open firmware functions)

__initdata updated to __initconst for
static const struct of_device_id ti_clkdm_match_table[]

Signed-off-by: Fabian Frederick 
---
V2:
add __initdata -> __initconst in changelog

 drivers/clk/clk-palmas.c | 2 +-
 drivers/clk/st/clkgen-fsyn.c | 2 +-
 drivers/clk/st/clkgen-mux.c  | 8 
 drivers/clk/st/clkgen-pll.c  | 4 ++--
 drivers/clk/ti/clk-dra7-atl.c| 2 +-
 drivers/clk/ti/clockdomain.c | 2 +-
 drivers/clk/versatile/clk-vexpress-osc.c | 2 +-
 7 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/clk-palmas.c b/drivers/clk/clk-palmas.c
index 8d45992..45a535a 100644
--- a/drivers/clk/clk-palmas.c
+++ b/drivers/clk/clk-palmas.c
@@ -161,7 +161,7 @@ static struct palmas_clks_of_match_data 
palmas_of_clk32kgaudio = {
},
 };
 
-static struct of_device_id palmas_clks_of_match[] = {
+static const struct of_device_id palmas_clks_of_match[] = {
{
.compatible = "ti,palmas-clk32kg",
.data = _of_clk32kg,
diff --git a/drivers/clk/st/clkgen-fsyn.c b/drivers/clk/st/clkgen-fsyn.c
index af94ed8..a917c4c 100644
--- a/drivers/clk/st/clkgen-fsyn.c
+++ b/drivers/clk/st/clkgen-fsyn.c
@@ -1057,7 +1057,7 @@ static struct clk * __init st_clk_register_quadfs_fsynth(
return clk;
 }
 
-static struct of_device_id quadfs_of_match[] = {
+static const struct of_device_id quadfs_of_match[] = {
{
.compatible = "st,stih416-quadfs216",
.data = _fs216c65_416
diff --git a/drivers/clk/st/clkgen-mux.c b/drivers/clk/st/clkgen-mux.c
index 9a15ec3..fdcff10 100644
--- a/drivers/clk/st/clkgen-mux.c
+++ b/drivers/clk/st/clkgen-mux.c
@@ -341,7 +341,7 @@ static struct clkgena_divmux_data st_divmux_c32odf3 = {
.fb_start_bit_idx = 24,
 };
 
-static struct of_device_id clkgena_divmux_of_match[] = {
+static const struct of_device_id clkgena_divmux_of_match[] = {
{
.compatible = "st,clkgena-divmux-c65-hs",
.data = _divmux_c65hs,
@@ -479,7 +479,7 @@ static struct clkgena_prediv_data prediv_c32_data = {
.table = prediv_table16,
 };
 
-static struct of_device_id clkgena_prediv_of_match[] = {
+static const struct of_device_id clkgena_prediv_of_match[] = {
{ .compatible = "st,clkgena-prediv-c65", .data = _c65_data },
{ .compatible = "st,clkgena-prediv-c32", .data = _c32_data },
{}
@@ -586,7 +586,7 @@ static struct clkgen_mux_data stih407_a9_mux_data = {
.width = 2,
 };
 
-static struct of_device_id mux_of_match[] = {
+static const struct of_device_id mux_of_match[] = {
{
.compatible = "st,stih416-clkgenc-vcc-hd",
.data = _mux_c_vcc_hd_416,
@@ -693,7 +693,7 @@ static struct clkgen_vcc_data st_clkgenf_vcc_416 = {
.lock = _lock,
 };
 
-static struct of_device_id vcc_of_match[] = {
+static const struct of_device_id vcc_of_match[] = {
{ .compatible = "st,stih416-clkgenc", .data = _clkgenc_vcc_416 },
{ .compatible = "st,stih416-clkgenf", .data = _clkgenf_vcc_416 },
{}
diff --git a/drivers/clk/st/clkgen-pll.c b/drivers/clk/st/clkgen-pll.c
index 29769d7..d204ba8 100644
--- a/drivers/clk/st/clkgen-pll.c
+++ b/drivers/clk/st/clkgen-pll.c
@@ -593,7 +593,7 @@ static struct clk * __init clkgen_odf_register(const char 
*parent_name,
return clk;
 }
 
-static struct of_device_id c32_pll_of_match[] = {
+static const struct of_device_id c32_pll_of_match[] = {
{
.compatible = "st,plls-c32-a1x-0",
.data = _pll3200c32_a1x_0,
@@ -708,7 +708,7 @@ err:
 }
 CLK_OF_DECLARE(clkgen_c32_pll, "st,clkgen-plls-c32", clkgen_c32_pll_setup);
 
-static struct of_device_id c32_gpu_pll_of_match[] = {
+static const struct of_device_id c32_gpu_pll_of_match[] = {
{
.compatible = "st,stih415-gpu-pll-c32",
.data = _pll1200c32_gpu_415,
diff --git a/drivers/clk/ti/clk-dra7-atl.c b/drivers/clk/ti/clk-dra7-atl.c
index 59bb4b3..d86bc46 100644
--- a/drivers/clk/ti/clk-dra7-atl.c
+++ b/drivers/clk/ti/clk-dra7-atl.c
@@ -294,7 +294,7 @@ static int of_dra7_atl_clk_remove(struct platform_device 
*pdev)
return 0;
 }
 
-static struct of_device_id of_dra7_atl_clk_match_tbl[] = {
+static const struct of_device_id of_dra7_atl_clk_match_tbl[] = {
{ .compatible = "ti,dra7-atl", },
{},
 };
diff --git a/drivers/clk/ti/clockdomain.c b/drivers/clk/ti/clockdomain.c
index b4c5fac..35fe108 100644
--- a/drivers/clk/ti/clockdomain.c
+++ b/drivers/clk/ti/clockdomain.c
@@ -52,7 +52,7 @@ static void __init of_ti_clockdomain_setup(struct device_node 
*node)
}
 }
 
-static struct of_device_id ti_clkdm_match_table[] __initdata = {
+static const 

Re: [PATCH 7/9 net-next] sunrpc: replace if/BUG by BUG_ON

2015-03-31 Thread Fabian Frederick


 On 30 March 2015 at 23:25 J. Bruce Fields bfie...@fieldses.org wrote:


 Huh, I thought this wasn't recommended:

       http://lkml.kernel.org/r/20040828125816.206ef7fa.a...@osdl.org

       I'd prefer that we not move code which has side-effects into
       BUG_ONs

Thanks for the link, I wasn't aware of that problem. Maybe we should add some
documentation and fix coccinelle detection then ?

Regards,
Fabian


 --b.

 On Mon, Mar 30, 2015 at 11:13:15PM +0200, Fabian Frederick wrote:
  Signed-off-by: Fabian Frederick f...@skynet.be
  ---
   net/sunrpc/auth_gss/svcauth_gss.c | 9 +++--
   net/sunrpc/svc_xprt.c             | 3 +--
   2 files changed, 4 insertions(+), 8 deletions(-)
 
  diff --git a/net/sunrpc/auth_gss/svcauth_gss.c
  b/net/sunrpc/auth_gss/svcauth_gss.c
  index 1095be9..09f8a1c6 100644
  --- a/net/sunrpc/auth_gss/svcauth_gss.c
  +++ b/net/sunrpc/auth_gss/svcauth_gss.c
  @@ -840,11 +840,9 @@ unwrap_integ_data(struct svc_rqst *rqstp, struct
  xdr_buf *buf, u32 seq, struct g
              return stat;
      if (integ_len  buf-len)
              return stat;
  -   if (xdr_buf_subsegment(buf, integ_buf, 0, integ_len))
  -           BUG();
  +   BUG_ON(xdr_buf_subsegment(buf, integ_buf, 0, integ_len));
      /* copy out mic... */
  -   if (read_u32_from_xdr_buf(buf, integ_len, mic.len))
  -           BUG();
  +   BUG_ON(read_u32_from_xdr_buf(buf, integ_len, mic.len));
      if (mic.len  RPC_MAX_AUTH_SIZE)
              return stat;
      mic.data = kmalloc(mic.len, GFP_KERNEL);
  @@ -1595,8 +1593,7 @@ svcauth_gss_wrap_resp_integ(struct svc_rqst *rqstp)
      BUG_ON(integ_len % 4);
      *p++ = htonl(integ_len);
      *p++ = htonl(gc-gc_seq);
  -   if (xdr_buf_subsegment(resbuf, integ_buf, integ_offset, integ_len))
  -           BUG();
  +   BUG_ON(xdr_buf_subsegment(resbuf, integ_buf, integ_offset, integ_len));
      if (resbuf-tail[0].iov_base == NULL) {
              if (resbuf-head[0].iov_len + RPC_MAX_AUTH_SIZE  PAGE_SIZE)
                      goto out_err;
  diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
  index 163ac45..2f82e8b 100644
  --- a/net/sunrpc/svc_xprt.c
  +++ b/net/sunrpc/svc_xprt.c
  @@ -960,8 +960,7 @@ static void svc_delete_xprt(struct svc_xprt *xprt)
      struct svc_deferred_req *dr;
  
      /* Only do this once */
  -   if (test_and_set_bit(XPT_DEAD, xprt-xpt_flags))
  -           BUG();
  +   BUG_ON(test_and_set_bit(XPT_DEAD, xprt-xpt_flags));
  
      dprintk(svc: svc_delete_xprt(%p)\n, xprt);
      xprt-xpt_ops-xpo_detach(xprt);
  --
  1.9.1
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 linux-next] clk: constify of_device_id array

2015-03-31 Thread Fabian Frederick
of_device_id is always used as const.
(See driver.of_match_table and open firmware functions)

__initdata updated to __initconst for
static const struct of_device_id ti_clkdm_match_table[]

Signed-off-by: Fabian Frederick f...@skynet.be
---
V2:
add __initdata - __initconst in changelog

 drivers/clk/clk-palmas.c | 2 +-
 drivers/clk/st/clkgen-fsyn.c | 2 +-
 drivers/clk/st/clkgen-mux.c  | 8 
 drivers/clk/st/clkgen-pll.c  | 4 ++--
 drivers/clk/ti/clk-dra7-atl.c| 2 +-
 drivers/clk/ti/clockdomain.c | 2 +-
 drivers/clk/versatile/clk-vexpress-osc.c | 2 +-
 7 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/clk-palmas.c b/drivers/clk/clk-palmas.c
index 8d45992..45a535a 100644
--- a/drivers/clk/clk-palmas.c
+++ b/drivers/clk/clk-palmas.c
@@ -161,7 +161,7 @@ static struct palmas_clks_of_match_data 
palmas_of_clk32kgaudio = {
},
 };
 
-static struct of_device_id palmas_clks_of_match[] = {
+static const struct of_device_id palmas_clks_of_match[] = {
{
.compatible = ti,palmas-clk32kg,
.data = palmas_of_clk32kg,
diff --git a/drivers/clk/st/clkgen-fsyn.c b/drivers/clk/st/clkgen-fsyn.c
index af94ed8..a917c4c 100644
--- a/drivers/clk/st/clkgen-fsyn.c
+++ b/drivers/clk/st/clkgen-fsyn.c
@@ -1057,7 +1057,7 @@ static struct clk * __init st_clk_register_quadfs_fsynth(
return clk;
 }
 
-static struct of_device_id quadfs_of_match[] = {
+static const struct of_device_id quadfs_of_match[] = {
{
.compatible = st,stih416-quadfs216,
.data = st_fs216c65_416
diff --git a/drivers/clk/st/clkgen-mux.c b/drivers/clk/st/clkgen-mux.c
index 9a15ec3..fdcff10 100644
--- a/drivers/clk/st/clkgen-mux.c
+++ b/drivers/clk/st/clkgen-mux.c
@@ -341,7 +341,7 @@ static struct clkgena_divmux_data st_divmux_c32odf3 = {
.fb_start_bit_idx = 24,
 };
 
-static struct of_device_id clkgena_divmux_of_match[] = {
+static const struct of_device_id clkgena_divmux_of_match[] = {
{
.compatible = st,clkgena-divmux-c65-hs,
.data = st_divmux_c65hs,
@@ -479,7 +479,7 @@ static struct clkgena_prediv_data prediv_c32_data = {
.table = prediv_table16,
 };
 
-static struct of_device_id clkgena_prediv_of_match[] = {
+static const struct of_device_id clkgena_prediv_of_match[] = {
{ .compatible = st,clkgena-prediv-c65, .data = prediv_c65_data },
{ .compatible = st,clkgena-prediv-c32, .data = prediv_c32_data },
{}
@@ -586,7 +586,7 @@ static struct clkgen_mux_data stih407_a9_mux_data = {
.width = 2,
 };
 
-static struct of_device_id mux_of_match[] = {
+static const struct of_device_id mux_of_match[] = {
{
.compatible = st,stih416-clkgenc-vcc-hd,
.data = clkgen_mux_c_vcc_hd_416,
@@ -693,7 +693,7 @@ static struct clkgen_vcc_data st_clkgenf_vcc_416 = {
.lock = clkgenf_lock,
 };
 
-static struct of_device_id vcc_of_match[] = {
+static const struct of_device_id vcc_of_match[] = {
{ .compatible = st,stih416-clkgenc, .data = st_clkgenc_vcc_416 },
{ .compatible = st,stih416-clkgenf, .data = st_clkgenf_vcc_416 },
{}
diff --git a/drivers/clk/st/clkgen-pll.c b/drivers/clk/st/clkgen-pll.c
index 29769d7..d204ba8 100644
--- a/drivers/clk/st/clkgen-pll.c
+++ b/drivers/clk/st/clkgen-pll.c
@@ -593,7 +593,7 @@ static struct clk * __init clkgen_odf_register(const char 
*parent_name,
return clk;
 }
 
-static struct of_device_id c32_pll_of_match[] = {
+static const struct of_device_id c32_pll_of_match[] = {
{
.compatible = st,plls-c32-a1x-0,
.data = st_pll3200c32_a1x_0,
@@ -708,7 +708,7 @@ err:
 }
 CLK_OF_DECLARE(clkgen_c32_pll, st,clkgen-plls-c32, clkgen_c32_pll_setup);
 
-static struct of_device_id c32_gpu_pll_of_match[] = {
+static const struct of_device_id c32_gpu_pll_of_match[] = {
{
.compatible = st,stih415-gpu-pll-c32,
.data = st_pll1200c32_gpu_415,
diff --git a/drivers/clk/ti/clk-dra7-atl.c b/drivers/clk/ti/clk-dra7-atl.c
index 59bb4b3..d86bc46 100644
--- a/drivers/clk/ti/clk-dra7-atl.c
+++ b/drivers/clk/ti/clk-dra7-atl.c
@@ -294,7 +294,7 @@ static int of_dra7_atl_clk_remove(struct platform_device 
*pdev)
return 0;
 }
 
-static struct of_device_id of_dra7_atl_clk_match_tbl[] = {
+static const struct of_device_id of_dra7_atl_clk_match_tbl[] = {
{ .compatible = ti,dra7-atl, },
{},
 };
diff --git a/drivers/clk/ti/clockdomain.c b/drivers/clk/ti/clockdomain.c
index b4c5fac..35fe108 100644
--- a/drivers/clk/ti/clockdomain.c
+++ b/drivers/clk/ti/clockdomain.c
@@ -52,7 +52,7 @@ static void __init of_ti_clockdomain_setup(struct device_node 
*node)
}
 }
 
-static struct of_device_id ti_clkdm_match_table[] __initdata = {
+static const struct of_device_id ti_clkdm_match_table[] __initconst = {
{ .compatible = ti

[PATCH V3 linux-next] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally

2015-03-31 Thread Fabian Frederick
Currently checkpatch warns when asm/file.h is included and linux/file.h
exists. That conversion can be made when linux/file.h includes asm/file.h
which is not always the case.(See signal.h)

Signed-off-by: Fabian Frederick f...@skynet.be
---
V3:
Only grep when $root/$checkfile exists (suggested by Joe Perches)
V2:
Apply suggestions by Joe Perches:
-Remove superfluous -i in grep
-Use $root to make checkpatch callable from anywhere
-Process all include cases.

 scripts/checkpatch.pl | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d54a814..c72e7ee 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4242,7 +4242,8 @@ sub process {
}
}
 
-#warn if asm/foo.h is #included and linux/foo.h is available (uses RAW 
line)
+# warn if asm/foo.h is #included and linux/foo.h is available and includes
+# itself asm/foo.h (uses RAW line)
if ($tree  $rawline =~ 
m{^.\s*\#\s*include\s*\asm\/(.*)\.h\}) {
my $file = $1.h;
my $checkfile = include/linux/$file;
@@ -4250,12 +4251,15 @@ sub process {
$realfile ne $checkfile 
$1 !~ /$allowed_asm_includes/)
{
-   if ($realfile =~ m{^arch/}) {
-   CHK(ARCH_INCLUDE_LINUX,
-   Consider using #include 
linux/$file instead of asm/$file\n . $herecurr);
-   } else {
-   WARN(INCLUDE_LINUX,
-Use #include linux/$file 
instead of asm/$file\n . $herecurr);
+   my $asminclude = `grep -Ec 
#include\\s+asm/$file $root/$checkfile`;
+   if ($asminclude  0) {
+   if ($realfile =~ m{^arch/}) {
+   CHK(ARCH_INCLUDE_LINUX,
+   Consider using #include 
linux/$file instead of asm/$file\n . $herecurr);
+   } else {
+   WARN(INCLUDE_LINUX,
+Use #include 
linux/$file instead of asm/$file\n . $herecurr);
+   }
}
}
}
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 32/35 linux-next] clk: constify of_device_id array

2015-03-31 Thread Fabian Frederick


 On 27 March 2015 at 08:19 Stephen Boyd sb...@codeaurora.org wrote:


 On 03/22, Fabian Frederick wrote:
 
 
   On 18 March 2015 at 15:15 Michael Turquette mturque...@linaro.org wrote:
  
  
   Quoting Fabian Frederick (2015-03-16 12:59:06)
of_device_id is always used as const.
(See driver.of_match_table and open firmware functions)
   
Signed-off-by: Fabian Frederick f...@skynet.be
  
   Acked-by: Michael Turquette mturque...@linaro.org
 
  Thanks :)
 
  btw, something I forgot to mention in changelog is the __initdata -
  __initconst
  for ti_clkdm_match_table[]
 
  I can send it again with a new changelog if necessary ...
 

 Did you want us to take this through clk-next? If so please
 resend with the new commit text.

Of course :) I hope V2 is ok.

Regards,
Fabian

 --
 Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
 a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC 1/1 linux-next] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally

2015-03-31 Thread Fabian Frederick


 On 30 March 2015 at 22:49 Joe Perches j...@perches.com wrote:


 On Mon, 2015-03-30 at 22:36 +0200, Fabian Frederick wrote:
  Currently checkpatch warns when asm/file.h is included and linux/file.h
  exists. That conversion can be made when linux/file.h includes asm/file.h
  which is not always the case.(See signal.h)
 []
  diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
 []
  -#warn if asm/foo.h is #included and linux/foo.h is available (uses RAW
  line)
  +# warn if asm/foo.h is #included and linux/foo.h is available and
  includes
  +# itself asm/foo.h (uses RAW line)
              if ($tree  $rawline =~
 m{^.\s*\#\s*include\s*\asm\/(.*)\.h\}) {
                      my $file = $1.h;
                      my $checkfile = include/linux/$file;
  +                   my $asminclude = `grep -ci #include asm/$file.h
  $checkfile`;

 This won't work with #include forms like:
       #include        asm/foo.h
 or when checkpatch is run from somewhere other
 than the top of tree.

 why the -i?

Hi Joe,

This was just an RFC. I guess you're ok with the idea so I added your
suggestions in V2.

Regards,
Fabian


                      if (-f $root/$checkfile 
                          $realfile ne $checkfile 
  -                       $1 !~ /$allowed_asm_includes/)
  +                       $1 !~ /$allowed_asm_includes/ 
  +                       $asminclude  0 )
                      {
                              if ($realfile =~ m{^arch/}) {
                                      CHK(ARCH_INCLUDE_LINUX,


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: linux-next: build warning after merge of the char-misc tree

2015-03-31 Thread Fabian Frederick


 On 27 March 2015 at 08:48 Stephen Rothwell s...@canb.auug.org.au wrote:


 Hi all,

 After merging the char-misc tree, today's linux-next build (powerpc
 allyesconfig) produced this warning:

 In file included from include/linux/module.h:17:0,
                  from drivers/uio/uio_pdrv_genirq.c:21:
 include/linux/moduleparam.h:326:22: warning: initialization discards 'const'
 qualifier from pointer target type
   static const struct kparam_string __param_string_##name  \
                       ^
 drivers/uio/uio_pdrv_genirq.c:260:1: note: in expansion of macro
 'module_param_string'
  module_param_string(of_id, uio_of_genirq_match[0].compatible, 128, 0);
  ^

 Introduced by commit 4d8beff2ae07 (uio: constify of_device_id array).

Hi Stephen,

Absolutely, my patch is wrong ; comment below explains struct is filled
afterwards.Sorry.
Greg, should I send you a revert or maybe we could standardize that driver ? (it
seems it's the only one to work that way).

static const struct of_device_id uio_of_genirq_match[] = {
        { /* This is filled with module_parm */ },
        { /* Sentinel */ },
};

Regards,
Fabian

 --
 Cheers,
 Stephen Rothwell                    s...@canb.auug.org.au
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally

2015-03-31 Thread Fabian Frederick
Currently checkpatch warns when asm/file.h is included and linux/file.h
exists. That conversion can be made when linux/file.h includes asm/file.h
which is not always the case.(See signal.h)

Signed-off-by: Fabian Frederick f...@skynet.be
---
V2:
Apply suggestions by Joe Perches:
-Remove superfluous -i in grep
-Use $root to make checkpatch callable from anywhere
-Process all include cases.

 scripts/checkpatch.pl | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d54a814..9e70cd7 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4242,13 +4242,16 @@ sub process {
}
}
 
-#warn if asm/foo.h is #included and linux/foo.h is available (uses RAW 
line)
+# warn if asm/foo.h is #included and linux/foo.h is available and includes
+# itself asm/foo.h (uses RAW line)
if ($tree  $rawline =~ 
m{^.\s*\#\s*include\s*\asm\/(.*)\.h\}) {
my $file = $1.h;
my $checkfile = include/linux/$file;
+   my $asminclude = `grep -Ec #include\\s+asm/$file 
$root/$checkfile`;
if (-f $root/$checkfile 
$realfile ne $checkfile 
-   $1 !~ /$allowed_asm_includes/)
+   $1 !~ /$allowed_asm_includes/ 
+   $asminclude  0 )
{
if ($realfile =~ m{^arch/}) {
CHK(ARCH_INCLUDE_LINUX,
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 7/9 net-next] sunrpc: replace if/BUG by BUG_ON

2015-03-31 Thread Fabian Frederick


 On 31 March 2015 at 21:11 Julia Lawall julia.law...@lip6.fr wrote:




 On Tue, 31 Mar 2015, Fabian Frederick wrote:

 
 
   On 30 March 2015 at 23:25 J. Bruce Fields bfie...@fieldses.org wrote:
  
  
   Huh, I thought this wasn't recommended:
  
         http://lkml.kernel.org/r/20040828125816.206ef7fa.a...@osdl.org
  
         I'd prefer that we not move code which has side-effects into
         BUG_ONs
 
  Thanks for the link, I wasn't aware of that problem. Maybe we should add
  some
  documentation and fix coccinelle detection then ?

 Maybe the comment in the Coccinelle rule could just be made more clear? 

Fair enough. Current WARNING: Use BUG_ON looks misleading.
Maybe some BUG_ON(function()) detection script would be interesting as well ?
There are nearly 5000 BUG_ON() in drivers branch only ... 

Regards,
Fabian
 The only practical choices are to ignore all function calls and to allow
 all fuction calls, since Coccinelle doesn't know which ones have side
 effects.

 julia

  Regards,
  Fabian
 
  
   --b.
  
   On Mon, Mar 30, 2015 at 11:13:15PM +0200, Fabian Frederick wrote:
Signed-off-by: Fabian Frederick f...@skynet.be
---
     net/sunrpc/auth_gss/svcauth_gss.c | 9 +++--
     net/sunrpc/svc_xprt.c             | 3 +--
     2 files changed, 4 insertions(+), 8 deletions(-)
   
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c
b/net/sunrpc/auth_gss/svcauth_gss.c
index 1095be9..09f8a1c6 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -840,11 +840,9 @@ unwrap_integ_data(struct svc_rqst *rqstp, struct
xdr_buf *buf, u32 seq, struct g
                return stat;
        if (integ_len  buf-len)
                return stat;
-   if (xdr_buf_subsegment(buf, integ_buf, 0, integ_len))
-           BUG();
+   BUG_ON(xdr_buf_subsegment(buf, integ_buf, 0, integ_len));
        /* copy out mic... */
-   if (read_u32_from_xdr_buf(buf, integ_len, mic.len))
-           BUG();
+   BUG_ON(read_u32_from_xdr_buf(buf, integ_len, mic.len));
        if (mic.len  RPC_MAX_AUTH_SIZE)
                return stat;
        mic.data = kmalloc(mic.len, GFP_KERNEL);
@@ -1595,8 +1593,7 @@ svcauth_gss_wrap_resp_integ(struct svc_rqst
*rqstp)
        BUG_ON(integ_len % 4);
        *p++ = htonl(integ_len);
        *p++ = htonl(gc-gc_seq);
-   if (xdr_buf_subsegment(resbuf, integ_buf, integ_offset, integ_len))
-           BUG();
+   BUG_ON(xdr_buf_subsegment(resbuf, integ_buf, integ_offset,
integ_len));
        if (resbuf-tail[0].iov_base == NULL) {
                if (resbuf-head[0].iov_len + RPC_MAX_AUTH_SIZE  PAGE_SIZE)
                        goto out_err;
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index 163ac45..2f82e8b 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -960,8 +960,7 @@ static void svc_delete_xprt(struct svc_xprt *xprt)
        struct svc_deferred_req *dr;
    
        /* Only do this once */
-   if (test_and_set_bit(XPT_DEAD, xprt-xpt_flags))
-           BUG();
+   BUG_ON(test_and_set_bit(XPT_DEAD, xprt-xpt_flags));
    
        dprintk(svc: svc_delete_xprt(%p)\n, xprt);
        xprt-xpt_ops-xpo_detach(xprt);
--
1.9.1
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/9 net-next] ipv4: replace if/BUG by BUG_ON

2015-03-30 Thread Fabian Frederick
Signed-off-by: Fabian Frederick 
---
 net/ipv4/devinet.c   | 3 +--
 net/ipv4/esp4.c  | 3 +--
 net/ipv4/icmp.c  | 3 +--
 net/ipv4/ip_output.c | 4 ++--
 net/ipv4/ping.c  | 3 +--
 net/ipv4/tcp_input.c | 8 
 net/ipv4/tcp_minisocks.c | 4 ++--
 net/ipv4/tcp_output.c| 3 +--
 8 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 975ee5e..e4b53f7 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1715,8 +1715,7 @@ static int inet_set_link_af(struct net_device *dev, const 
struct nlattr *nla)
if (!in_dev)
return -EAFNOSUPPORT;
 
-   if (nla_parse_nested(tb, IFLA_INET_MAX, nla, NULL) < 0)
-   BUG();
+   BUG_ON(nla_parse_nested(tb, IFLA_INET_MAX, nla, NULL) < 0);
 
if (tb[IFLA_INET_CONF]) {
nla_for_each_nested(a, tb[IFLA_INET_CONF], rem)
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 60173d4..02d41d0 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -289,8 +289,7 @@ static int esp_input_done2(struct sk_buff *skb, int err)
if (unlikely(err))
goto out;
 
-   if (skb_copy_bits(skb, skb->len-alen-2, nexthdr, 2))
-   BUG();
+   BUG_ON(skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2));
 
err = -EINVAL;
padlen = nexthdr[0];
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 5e56401..6d59e26 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -922,8 +922,7 @@ static bool icmp_timestamp(struct sk_buff *skb)
icmp_param.data.times[1] = htonl((tv.tv_sec % 86400) * MSEC_PER_SEC +
 tv.tv_nsec / NSEC_PER_MSEC);
icmp_param.data.times[2] = icmp_param.data.times[1];
-   if (skb_copy_bits(skb, 0, _param.data.times[0], 4))
-   BUG();
+   BUG_ON(skb_copy_bits(skb, 0, _param.data.times[0], 4));
icmp_param.data.icmph  = *icmp_hdr(skb);
icmp_param.data.icmph.type = ICMP_TIMESTAMPREPLY;
icmp_param.data.icmph.code = 0;
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 8259e77..f58f52b 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -695,8 +695,8 @@ slow_path:
/*
 *  Copy a block of the IP datagram.
 */
-   if (skb_copy_bits(skb, ptr, skb_transport_header(skb2), len))
-   BUG();
+   BUG_ON(skb_copy_bits(skb, ptr, skb_transport_header(skb2),
+len));
left -= len;
 
/*
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 344e7cd..5536c2b 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -608,8 +608,7 @@ int ping_getfrag(void *from, char *to,
 
if (offset == 0) {
fraglen -= sizeof(struct icmphdr);
-   if (fraglen < 0)
-   BUG();
+   BUG_ON(fraglen < 0);
if (csum_and_copy_from_iter(to + sizeof(struct icmphdr),
fraglen, >wcheck,
>msg->msg_iter) != fraglen)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 023196f..7ae07a4 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4642,8 +4642,9 @@ restart:
BUG_ON(offset < 0);
if (size > 0) {
size = min(copy, size);
-   if (skb_copy_bits(skb, offset, skb_put(nskb, 
size), size))
-   BUG();
+   BUG_ON(skb_copy_bits(skb, offset,
+skb_put(nskb, size),
+size));
TCP_SKB_CB(nskb)->end_seq += size;
copy -= size;
start += size;
@@ -4966,8 +4967,7 @@ static void tcp_urg(struct sock *sk, struct sk_buff *skb, 
const struct tcphdr *t
/* Is the urgent pointer pointing into this packet? */
if (ptr < skb->len) {
u8 tmp;
-   if (skb_copy_bits(skb, ptr, , 1))
-   BUG();
+   BUG_ON(skb_copy_bits(skb, ptr, , 1));
tp->urg_data = TCP_URG_VALID | tmp;
if (!sock_flag(sk, SOCK_DEAD))
sk->sk_data_ready(sk);
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 274e96f..90e5c9f 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -334,8 +334,8 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)
key = tp->af_specific->md5_lookup(sk, sk);
if (key != NULL) {
tcpt

<    3   4   5   6   7   8   9   10   11   12   >